mimir-ui-kit 1.1.9 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4881 +1,10 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import React, { forwardRef, useState, useRef, useEffect, useLayoutEffect, createContext, useContext, useCallback, useMemo } from "react";
2
+ import { useRef, useState, useCallback } from "react";
3
3
  import { c as classNames } from "../../index-CweZ_OcN.js";
4
+ import { g as getDocument, S as Swiper, N as NavigationButtons, a as SwiperSlide } from "../../NavigationButtons-B8tMfqrg.js";
4
5
  import { ProgressBar } from "./ProgressBar/ProgressBar.js";
5
6
  import { AppImage } from "../Image/Image.js";
6
- import { MergedButton } from "../MergedButton/MergedButton.js";
7
- import '../../assets/Slider.css';function isObject$2(obj) {
8
- return obj !== null && typeof obj === "object" && "constructor" in obj && obj.constructor === Object;
9
- }
10
- function extend$2(target, src) {
11
- if (target === void 0) {
12
- target = {};
13
- }
14
- if (src === void 0) {
15
- src = {};
16
- }
17
- Object.keys(src).forEach((key) => {
18
- if (typeof target[key] === "undefined") target[key] = src[key];
19
- else if (isObject$2(src[key]) && isObject$2(target[key]) && Object.keys(src[key]).length > 0) {
20
- extend$2(target[key], src[key]);
21
- }
22
- });
23
- }
24
- const ssrDocument = {
25
- body: {},
26
- addEventListener() {
27
- },
28
- removeEventListener() {
29
- },
30
- activeElement: {
31
- blur() {
32
- },
33
- nodeName: ""
34
- },
35
- querySelector() {
36
- return null;
37
- },
38
- querySelectorAll() {
39
- return [];
40
- },
41
- getElementById() {
42
- return null;
43
- },
44
- createEvent() {
45
- return {
46
- initEvent() {
47
- }
48
- };
49
- },
50
- createElement() {
51
- return {
52
- children: [],
53
- childNodes: [],
54
- style: {},
55
- setAttribute() {
56
- },
57
- getElementsByTagName() {
58
- return [];
59
- }
60
- };
61
- },
62
- createElementNS() {
63
- return {};
64
- },
65
- importNode() {
66
- return null;
67
- },
68
- location: {
69
- hash: "",
70
- host: "",
71
- hostname: "",
72
- href: "",
73
- origin: "",
74
- pathname: "",
75
- protocol: "",
76
- search: ""
77
- }
78
- };
79
- function getDocument() {
80
- const doc = typeof document !== "undefined" ? document : {};
81
- extend$2(doc, ssrDocument);
82
- return doc;
83
- }
84
- const ssrWindow = {
85
- document: ssrDocument,
86
- navigator: {
87
- userAgent: ""
88
- },
89
- location: {
90
- hash: "",
91
- host: "",
92
- hostname: "",
93
- href: "",
94
- origin: "",
95
- pathname: "",
96
- protocol: "",
97
- search: ""
98
- },
99
- history: {
100
- replaceState() {
101
- },
102
- pushState() {
103
- },
104
- go() {
105
- },
106
- back() {
107
- }
108
- },
109
- CustomEvent: function CustomEvent() {
110
- return this;
111
- },
112
- addEventListener() {
113
- },
114
- removeEventListener() {
115
- },
116
- getComputedStyle() {
117
- return {
118
- getPropertyValue() {
119
- return "";
120
- }
121
- };
122
- },
123
- Image() {
124
- },
125
- Date() {
126
- },
127
- screen: {},
128
- setTimeout() {
129
- },
130
- clearTimeout() {
131
- },
132
- matchMedia() {
133
- return {};
134
- },
135
- requestAnimationFrame(callback) {
136
- if (typeof setTimeout === "undefined") {
137
- callback();
138
- return null;
139
- }
140
- return setTimeout(callback, 0);
141
- },
142
- cancelAnimationFrame(id) {
143
- if (typeof setTimeout === "undefined") {
144
- return;
145
- }
146
- clearTimeout(id);
147
- }
148
- };
149
- function getWindow() {
150
- const win = typeof window !== "undefined" ? window : {};
151
- extend$2(win, ssrWindow);
152
- return win;
153
- }
154
- function classesToTokens(classes2) {
155
- if (classes2 === void 0) {
156
- classes2 = "";
157
- }
158
- return classes2.trim().split(" ").filter((c) => !!c.trim());
159
- }
160
- function deleteProps(obj) {
161
- const object = obj;
162
- Object.keys(object).forEach((key) => {
163
- try {
164
- object[key] = null;
165
- } catch (e) {
166
- }
167
- try {
168
- delete object[key];
169
- } catch (e) {
170
- }
171
- });
172
- }
173
- function nextTick(callback, delay) {
174
- if (delay === void 0) {
175
- delay = 0;
176
- }
177
- return setTimeout(callback, delay);
178
- }
179
- function now() {
180
- return Date.now();
181
- }
182
- function getComputedStyle$1(el) {
183
- const window2 = getWindow();
184
- let style;
185
- if (window2.getComputedStyle) {
186
- style = window2.getComputedStyle(el, null);
187
- }
188
- if (!style && el.currentStyle) {
189
- style = el.currentStyle;
190
- }
191
- if (!style) {
192
- style = el.style;
193
- }
194
- return style;
195
- }
196
- function getTranslate(el, axis) {
197
- if (axis === void 0) {
198
- axis = "x";
199
- }
200
- const window2 = getWindow();
201
- let matrix;
202
- let curTransform;
203
- let transformMatrix;
204
- const curStyle = getComputedStyle$1(el);
205
- if (window2.WebKitCSSMatrix) {
206
- curTransform = curStyle.transform || curStyle.webkitTransform;
207
- if (curTransform.split(",").length > 6) {
208
- curTransform = curTransform.split(", ").map((a) => a.replace(",", ".")).join(", ");
209
- }
210
- transformMatrix = new window2.WebKitCSSMatrix(curTransform === "none" ? "" : curTransform);
211
- } else {
212
- transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue("transform").replace("translate(", "matrix(1, 0, 0, 1,");
213
- matrix = transformMatrix.toString().split(",");
214
- }
215
- if (axis === "x") {
216
- if (window2.WebKitCSSMatrix) curTransform = transformMatrix.m41;
217
- else if (matrix.length === 16) curTransform = parseFloat(matrix[12]);
218
- else curTransform = parseFloat(matrix[4]);
219
- }
220
- if (axis === "y") {
221
- if (window2.WebKitCSSMatrix) curTransform = transformMatrix.m42;
222
- else if (matrix.length === 16) curTransform = parseFloat(matrix[13]);
223
- else curTransform = parseFloat(matrix[5]);
224
- }
225
- return curTransform || 0;
226
- }
227
- function isObject$1(o) {
228
- return typeof o === "object" && o !== null && o.constructor && Object.prototype.toString.call(o).slice(8, -1) === "Object";
229
- }
230
- function isNode(node) {
231
- if (typeof window !== "undefined" && typeof window.HTMLElement !== "undefined") {
232
- return node instanceof HTMLElement;
233
- }
234
- return node && (node.nodeType === 1 || node.nodeType === 11);
235
- }
236
- function extend$1() {
237
- const to = Object(arguments.length <= 0 ? void 0 : arguments[0]);
238
- const noExtend = ["__proto__", "constructor", "prototype"];
239
- for (let i = 1; i < arguments.length; i += 1) {
240
- const nextSource = i < 0 || arguments.length <= i ? void 0 : arguments[i];
241
- if (nextSource !== void 0 && nextSource !== null && !isNode(nextSource)) {
242
- const keysArray = Object.keys(Object(nextSource)).filter((key) => noExtend.indexOf(key) < 0);
243
- for (let nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) {
244
- const nextKey = keysArray[nextIndex];
245
- const desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
246
- if (desc !== void 0 && desc.enumerable) {
247
- if (isObject$1(to[nextKey]) && isObject$1(nextSource[nextKey])) {
248
- if (nextSource[nextKey].__swiper__) {
249
- to[nextKey] = nextSource[nextKey];
250
- } else {
251
- extend$1(to[nextKey], nextSource[nextKey]);
252
- }
253
- } else if (!isObject$1(to[nextKey]) && isObject$1(nextSource[nextKey])) {
254
- to[nextKey] = {};
255
- if (nextSource[nextKey].__swiper__) {
256
- to[nextKey] = nextSource[nextKey];
257
- } else {
258
- extend$1(to[nextKey], nextSource[nextKey]);
259
- }
260
- } else {
261
- to[nextKey] = nextSource[nextKey];
262
- }
263
- }
264
- }
265
- }
266
- }
267
- return to;
268
- }
269
- function setCSSProperty(el, varName, varValue) {
270
- el.style.setProperty(varName, varValue);
271
- }
272
- function animateCSSModeScroll(_ref) {
273
- let {
274
- swiper: swiper2,
275
- targetPosition,
276
- side
277
- } = _ref;
278
- const window2 = getWindow();
279
- const startPosition = -swiper2.translate;
280
- let startTime = null;
281
- let time;
282
- const duration = swiper2.params.speed;
283
- swiper2.wrapperEl.style.scrollSnapType = "none";
284
- window2.cancelAnimationFrame(swiper2.cssModeFrameID);
285
- const dir = targetPosition > startPosition ? "next" : "prev";
286
- const isOutOfBound = (current, target) => {
287
- return dir === "next" && current >= target || dir === "prev" && current <= target;
288
- };
289
- const animate = () => {
290
- time = (/* @__PURE__ */ new Date()).getTime();
291
- if (startTime === null) {
292
- startTime = time;
293
- }
294
- const progress = Math.max(Math.min((time - startTime) / duration, 1), 0);
295
- const easeProgress = 0.5 - Math.cos(progress * Math.PI) / 2;
296
- let currentPosition = startPosition + easeProgress * (targetPosition - startPosition);
297
- if (isOutOfBound(currentPosition, targetPosition)) {
298
- currentPosition = targetPosition;
299
- }
300
- swiper2.wrapperEl.scrollTo({
301
- [side]: currentPosition
302
- });
303
- if (isOutOfBound(currentPosition, targetPosition)) {
304
- swiper2.wrapperEl.style.overflow = "hidden";
305
- swiper2.wrapperEl.style.scrollSnapType = "";
306
- setTimeout(() => {
307
- swiper2.wrapperEl.style.overflow = "";
308
- swiper2.wrapperEl.scrollTo({
309
- [side]: currentPosition
310
- });
311
- });
312
- window2.cancelAnimationFrame(swiper2.cssModeFrameID);
313
- return;
314
- }
315
- swiper2.cssModeFrameID = window2.requestAnimationFrame(animate);
316
- };
317
- animate();
318
- }
319
- function elementChildren(element, selector) {
320
- if (selector === void 0) {
321
- selector = "";
322
- }
323
- return [...element.children].filter((el) => el.matches(selector));
324
- }
325
- function showWarning(text) {
326
- try {
327
- console.warn(text);
328
- return;
329
- } catch (err) {
330
- }
331
- }
332
- function createElement(tag, classes2) {
333
- if (classes2 === void 0) {
334
- classes2 = [];
335
- }
336
- const el = document.createElement(tag);
337
- el.classList.add(...Array.isArray(classes2) ? classes2 : classesToTokens(classes2));
338
- return el;
339
- }
340
- function elementPrevAll(el, selector) {
341
- const prevEls = [];
342
- while (el.previousElementSibling) {
343
- const prev = el.previousElementSibling;
344
- if (selector) {
345
- if (prev.matches(selector)) prevEls.push(prev);
346
- } else prevEls.push(prev);
347
- el = prev;
348
- }
349
- return prevEls;
350
- }
351
- function elementNextAll(el, selector) {
352
- const nextEls = [];
353
- while (el.nextElementSibling) {
354
- const next = el.nextElementSibling;
355
- if (selector) {
356
- if (next.matches(selector)) nextEls.push(next);
357
- } else nextEls.push(next);
358
- el = next;
359
- }
360
- return nextEls;
361
- }
362
- function elementStyle(el, prop) {
363
- const window2 = getWindow();
364
- return window2.getComputedStyle(el, null).getPropertyValue(prop);
365
- }
366
- function elementIndex(el) {
367
- let child = el;
368
- let i;
369
- if (child) {
370
- i = 0;
371
- while ((child = child.previousSibling) !== null) {
372
- if (child.nodeType === 1) i += 1;
373
- }
374
- return i;
375
- }
376
- return void 0;
377
- }
378
- function elementParents(el, selector) {
379
- const parents = [];
380
- let parent = el.parentElement;
381
- while (parent) {
382
- {
383
- parents.push(parent);
384
- }
385
- parent = parent.parentElement;
386
- }
387
- return parents;
388
- }
389
- function elementOuterSize(el, size, includeMargins) {
390
- const window2 = getWindow();
391
- {
392
- return el[size === "width" ? "offsetWidth" : "offsetHeight"] + parseFloat(window2.getComputedStyle(el, null).getPropertyValue(size === "width" ? "margin-right" : "margin-top")) + parseFloat(window2.getComputedStyle(el, null).getPropertyValue(size === "width" ? "margin-left" : "margin-bottom"));
393
- }
394
- }
395
- let support;
396
- function calcSupport() {
397
- const window2 = getWindow();
398
- const document2 = getDocument();
399
- return {
400
- smoothScroll: document2.documentElement && document2.documentElement.style && "scrollBehavior" in document2.documentElement.style,
401
- touch: !!("ontouchstart" in window2 || window2.DocumentTouch && document2 instanceof window2.DocumentTouch)
402
- };
403
- }
404
- function getSupport() {
405
- if (!support) {
406
- support = calcSupport();
407
- }
408
- return support;
409
- }
410
- let deviceCached;
411
- function calcDevice(_temp) {
412
- let {
413
- userAgent
414
- } = _temp === void 0 ? {} : _temp;
415
- const support2 = getSupport();
416
- const window2 = getWindow();
417
- const platform = window2.navigator.platform;
418
- const ua = userAgent || window2.navigator.userAgent;
419
- const device = {
420
- ios: false,
421
- android: false
422
- };
423
- const screenWidth = window2.screen.width;
424
- const screenHeight = window2.screen.height;
425
- const android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
426
- let ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
427
- const ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
428
- const iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/);
429
- const windows = platform === "Win32";
430
- let macos = platform === "MacIntel";
431
- const iPadScreens = ["1024x1366", "1366x1024", "834x1194", "1194x834", "834x1112", "1112x834", "768x1024", "1024x768", "820x1180", "1180x820", "810x1080", "1080x810"];
432
- if (!ipad && macos && support2.touch && iPadScreens.indexOf(`${screenWidth}x${screenHeight}`) >= 0) {
433
- ipad = ua.match(/(Version)\/([\d.]+)/);
434
- if (!ipad) ipad = [0, 1, "13_0_0"];
435
- macos = false;
436
- }
437
- if (android && !windows) {
438
- device.os = "android";
439
- device.android = true;
440
- }
441
- if (ipad || iphone || ipod) {
442
- device.os = "ios";
443
- device.ios = true;
444
- }
445
- return device;
446
- }
447
- function getDevice(overrides) {
448
- if (overrides === void 0) {
449
- overrides = {};
450
- }
451
- if (!deviceCached) {
452
- deviceCached = calcDevice(overrides);
453
- }
454
- return deviceCached;
455
- }
456
- let browser;
457
- function calcBrowser() {
458
- const window2 = getWindow();
459
- const device = getDevice();
460
- let needPerspectiveFix = false;
461
- function isSafari() {
462
- const ua = window2.navigator.userAgent.toLowerCase();
463
- return ua.indexOf("safari") >= 0 && ua.indexOf("chrome") < 0 && ua.indexOf("android") < 0;
464
- }
465
- if (isSafari()) {
466
- const ua = String(window2.navigator.userAgent);
467
- if (ua.includes("Version/")) {
468
- const [major, minor] = ua.split("Version/")[1].split(" ")[0].split(".").map((num) => Number(num));
469
- needPerspectiveFix = major < 16 || major === 16 && minor < 2;
470
- }
471
- }
472
- const isWebView = /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window2.navigator.userAgent);
473
- const isSafariBrowser = isSafari();
474
- const need3dFix = isSafariBrowser || isWebView && device.ios;
475
- return {
476
- isSafari: needPerspectiveFix || isSafariBrowser,
477
- needPerspectiveFix,
478
- need3dFix,
479
- isWebView
480
- };
481
- }
482
- function getBrowser() {
483
- if (!browser) {
484
- browser = calcBrowser();
485
- }
486
- return browser;
487
- }
488
- function Resize(_ref) {
489
- let {
490
- swiper: swiper2,
491
- on,
492
- emit
493
- } = _ref;
494
- const window2 = getWindow();
495
- let observer = null;
496
- let animationFrame = null;
497
- const resizeHandler = () => {
498
- if (!swiper2 || swiper2.destroyed || !swiper2.initialized) return;
499
- emit("beforeResize");
500
- emit("resize");
501
- };
502
- const createObserver = () => {
503
- if (!swiper2 || swiper2.destroyed || !swiper2.initialized) return;
504
- observer = new ResizeObserver((entries) => {
505
- animationFrame = window2.requestAnimationFrame(() => {
506
- const {
507
- width,
508
- height
509
- } = swiper2;
510
- let newWidth = width;
511
- let newHeight = height;
512
- entries.forEach((_ref2) => {
513
- let {
514
- contentBoxSize,
515
- contentRect,
516
- target
517
- } = _ref2;
518
- if (target && target !== swiper2.el) return;
519
- newWidth = contentRect ? contentRect.width : (contentBoxSize[0] || contentBoxSize).inlineSize;
520
- newHeight = contentRect ? contentRect.height : (contentBoxSize[0] || contentBoxSize).blockSize;
521
- });
522
- if (newWidth !== width || newHeight !== height) {
523
- resizeHandler();
524
- }
525
- });
526
- });
527
- observer.observe(swiper2.el);
528
- };
529
- const removeObserver = () => {
530
- if (animationFrame) {
531
- window2.cancelAnimationFrame(animationFrame);
532
- }
533
- if (observer && observer.unobserve && swiper2.el) {
534
- observer.unobserve(swiper2.el);
535
- observer = null;
536
- }
537
- };
538
- const orientationChangeHandler = () => {
539
- if (!swiper2 || swiper2.destroyed || !swiper2.initialized) return;
540
- emit("orientationchange");
541
- };
542
- on("init", () => {
543
- if (swiper2.params.resizeObserver && typeof window2.ResizeObserver !== "undefined") {
544
- createObserver();
545
- return;
546
- }
547
- window2.addEventListener("resize", resizeHandler);
548
- window2.addEventListener("orientationchange", orientationChangeHandler);
549
- });
550
- on("destroy", () => {
551
- removeObserver();
552
- window2.removeEventListener("resize", resizeHandler);
553
- window2.removeEventListener("orientationchange", orientationChangeHandler);
554
- });
555
- }
556
- function Observer(_ref) {
557
- let {
558
- swiper: swiper2,
559
- extendParams,
560
- on,
561
- emit
562
- } = _ref;
563
- const observers = [];
564
- const window2 = getWindow();
565
- const attach = function(target, options) {
566
- if (options === void 0) {
567
- options = {};
568
- }
569
- const ObserverFunc = window2.MutationObserver || window2.WebkitMutationObserver;
570
- const observer = new ObserverFunc((mutations) => {
571
- if (swiper2.__preventObserver__) return;
572
- if (mutations.length === 1) {
573
- emit("observerUpdate", mutations[0]);
574
- return;
575
- }
576
- const observerUpdate = function observerUpdate2() {
577
- emit("observerUpdate", mutations[0]);
578
- };
579
- if (window2.requestAnimationFrame) {
580
- window2.requestAnimationFrame(observerUpdate);
581
- } else {
582
- window2.setTimeout(observerUpdate, 0);
583
- }
584
- });
585
- observer.observe(target, {
586
- attributes: typeof options.attributes === "undefined" ? true : options.attributes,
587
- childList: swiper2.isElement || (typeof options.childList === "undefined" ? true : options).childList,
588
- characterData: typeof options.characterData === "undefined" ? true : options.characterData
589
- });
590
- observers.push(observer);
591
- };
592
- const init = () => {
593
- if (!swiper2.params.observer) return;
594
- if (swiper2.params.observeParents) {
595
- const containerParents = elementParents(swiper2.hostEl);
596
- for (let i = 0; i < containerParents.length; i += 1) {
597
- attach(containerParents[i]);
598
- }
599
- }
600
- attach(swiper2.hostEl, {
601
- childList: swiper2.params.observeSlideChildren
602
- });
603
- attach(swiper2.wrapperEl, {
604
- attributes: false
605
- });
606
- };
607
- const destroy = () => {
608
- observers.forEach((observer) => {
609
- observer.disconnect();
610
- });
611
- observers.splice(0, observers.length);
612
- };
613
- extendParams({
614
- observer: false,
615
- observeParents: false,
616
- observeSlideChildren: false
617
- });
618
- on("init", init);
619
- on("destroy", destroy);
620
- }
621
- var eventsEmitter = {
622
- on(events2, handler, priority) {
623
- const self = this;
624
- if (!self.eventsListeners || self.destroyed) return self;
625
- if (typeof handler !== "function") return self;
626
- const method = priority ? "unshift" : "push";
627
- events2.split(" ").forEach((event) => {
628
- if (!self.eventsListeners[event]) self.eventsListeners[event] = [];
629
- self.eventsListeners[event][method](handler);
630
- });
631
- return self;
632
- },
633
- once(events2, handler, priority) {
634
- const self = this;
635
- if (!self.eventsListeners || self.destroyed) return self;
636
- if (typeof handler !== "function") return self;
637
- function onceHandler() {
638
- self.off(events2, onceHandler);
639
- if (onceHandler.__emitterProxy) {
640
- delete onceHandler.__emitterProxy;
641
- }
642
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
643
- args[_key] = arguments[_key];
644
- }
645
- handler.apply(self, args);
646
- }
647
- onceHandler.__emitterProxy = handler;
648
- return self.on(events2, onceHandler, priority);
649
- },
650
- onAny(handler, priority) {
651
- const self = this;
652
- if (!self.eventsListeners || self.destroyed) return self;
653
- if (typeof handler !== "function") return self;
654
- const method = priority ? "unshift" : "push";
655
- if (self.eventsAnyListeners.indexOf(handler) < 0) {
656
- self.eventsAnyListeners[method](handler);
657
- }
658
- return self;
659
- },
660
- offAny(handler) {
661
- const self = this;
662
- if (!self.eventsListeners || self.destroyed) return self;
663
- if (!self.eventsAnyListeners) return self;
664
- const index = self.eventsAnyListeners.indexOf(handler);
665
- if (index >= 0) {
666
- self.eventsAnyListeners.splice(index, 1);
667
- }
668
- return self;
669
- },
670
- off(events2, handler) {
671
- const self = this;
672
- if (!self.eventsListeners || self.destroyed) return self;
673
- if (!self.eventsListeners) return self;
674
- events2.split(" ").forEach((event) => {
675
- if (typeof handler === "undefined") {
676
- self.eventsListeners[event] = [];
677
- } else if (self.eventsListeners[event]) {
678
- self.eventsListeners[event].forEach((eventHandler, index) => {
679
- if (eventHandler === handler || eventHandler.__emitterProxy && eventHandler.__emitterProxy === handler) {
680
- self.eventsListeners[event].splice(index, 1);
681
- }
682
- });
683
- }
684
- });
685
- return self;
686
- },
687
- emit() {
688
- const self = this;
689
- if (!self.eventsListeners || self.destroyed) return self;
690
- if (!self.eventsListeners) return self;
691
- let events2;
692
- let data;
693
- let context;
694
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
695
- args[_key2] = arguments[_key2];
696
- }
697
- if (typeof args[0] === "string" || Array.isArray(args[0])) {
698
- events2 = args[0];
699
- data = args.slice(1, args.length);
700
- context = self;
701
- } else {
702
- events2 = args[0].events;
703
- data = args[0].data;
704
- context = args[0].context || self;
705
- }
706
- data.unshift(context);
707
- const eventsArray = Array.isArray(events2) ? events2 : events2.split(" ");
708
- eventsArray.forEach((event) => {
709
- if (self.eventsAnyListeners && self.eventsAnyListeners.length) {
710
- self.eventsAnyListeners.forEach((eventHandler) => {
711
- eventHandler.apply(context, [event, ...data]);
712
- });
713
- }
714
- if (self.eventsListeners && self.eventsListeners[event]) {
715
- self.eventsListeners[event].forEach((eventHandler) => {
716
- eventHandler.apply(context, data);
717
- });
718
- }
719
- });
720
- return self;
721
- }
722
- };
723
- function updateSize() {
724
- const swiper2 = this;
725
- let width;
726
- let height;
727
- const el = swiper2.el;
728
- if (typeof swiper2.params.width !== "undefined" && swiper2.params.width !== null) {
729
- width = swiper2.params.width;
730
- } else {
731
- width = el.clientWidth;
732
- }
733
- if (typeof swiper2.params.height !== "undefined" && swiper2.params.height !== null) {
734
- height = swiper2.params.height;
735
- } else {
736
- height = el.clientHeight;
737
- }
738
- if (width === 0 && swiper2.isHorizontal() || height === 0 && swiper2.isVertical()) {
739
- return;
740
- }
741
- width = width - parseInt(elementStyle(el, "padding-left") || 0, 10) - parseInt(elementStyle(el, "padding-right") || 0, 10);
742
- height = height - parseInt(elementStyle(el, "padding-top") || 0, 10) - parseInt(elementStyle(el, "padding-bottom") || 0, 10);
743
- if (Number.isNaN(width)) width = 0;
744
- if (Number.isNaN(height)) height = 0;
745
- Object.assign(swiper2, {
746
- width,
747
- height,
748
- size: swiper2.isHorizontal() ? width : height
749
- });
750
- }
751
- function updateSlides() {
752
- const swiper2 = this;
753
- function getDirectionPropertyValue(node, label) {
754
- return parseFloat(node.getPropertyValue(swiper2.getDirectionLabel(label)) || 0);
755
- }
756
- const params = swiper2.params;
757
- const {
758
- wrapperEl,
759
- slidesEl,
760
- size: swiperSize,
761
- rtlTranslate: rtl,
762
- wrongRTL
763
- } = swiper2;
764
- const isVirtual = swiper2.virtual && params.virtual.enabled;
765
- const previousSlidesLength = isVirtual ? swiper2.virtual.slides.length : swiper2.slides.length;
766
- const slides2 = elementChildren(slidesEl, `.${swiper2.params.slideClass}, swiper-slide`);
767
- const slidesLength = isVirtual ? swiper2.virtual.slides.length : slides2.length;
768
- let snapGrid = [];
769
- const slidesGrid = [];
770
- const slidesSizesGrid = [];
771
- let offsetBefore = params.slidesOffsetBefore;
772
- if (typeof offsetBefore === "function") {
773
- offsetBefore = params.slidesOffsetBefore.call(swiper2);
774
- }
775
- let offsetAfter = params.slidesOffsetAfter;
776
- if (typeof offsetAfter === "function") {
777
- offsetAfter = params.slidesOffsetAfter.call(swiper2);
778
- }
779
- const previousSnapGridLength = swiper2.snapGrid.length;
780
- const previousSlidesGridLength = swiper2.slidesGrid.length;
781
- let spaceBetween = params.spaceBetween;
782
- let slidePosition = -offsetBefore;
783
- let prevSlideSize = 0;
784
- let index = 0;
785
- if (typeof swiperSize === "undefined") {
786
- return;
787
- }
788
- if (typeof spaceBetween === "string" && spaceBetween.indexOf("%") >= 0) {
789
- spaceBetween = parseFloat(spaceBetween.replace("%", "")) / 100 * swiperSize;
790
- } else if (typeof spaceBetween === "string") {
791
- spaceBetween = parseFloat(spaceBetween);
792
- }
793
- swiper2.virtualSize = -spaceBetween;
794
- slides2.forEach((slideEl) => {
795
- if (rtl) {
796
- slideEl.style.marginLeft = "";
797
- } else {
798
- slideEl.style.marginRight = "";
799
- }
800
- slideEl.style.marginBottom = "";
801
- slideEl.style.marginTop = "";
802
- });
803
- if (params.centeredSlides && params.cssMode) {
804
- setCSSProperty(wrapperEl, "--swiper-centered-offset-before", "");
805
- setCSSProperty(wrapperEl, "--swiper-centered-offset-after", "");
806
- }
807
- const gridEnabled = params.grid && params.grid.rows > 1 && swiper2.grid;
808
- if (gridEnabled) {
809
- swiper2.grid.initSlides(slides2);
810
- } else if (swiper2.grid) {
811
- swiper2.grid.unsetSlides();
812
- }
813
- let slideSize;
814
- const shouldResetSlideSize = params.slidesPerView === "auto" && params.breakpoints && Object.keys(params.breakpoints).filter((key) => {
815
- return typeof params.breakpoints[key].slidesPerView !== "undefined";
816
- }).length > 0;
817
- for (let i = 0; i < slidesLength; i += 1) {
818
- slideSize = 0;
819
- let slide2;
820
- if (slides2[i]) slide2 = slides2[i];
821
- if (gridEnabled) {
822
- swiper2.grid.updateSlide(i, slide2, slides2);
823
- }
824
- if (slides2[i] && elementStyle(slide2, "display") === "none") continue;
825
- if (params.slidesPerView === "auto") {
826
- if (shouldResetSlideSize) {
827
- slides2[i].style[swiper2.getDirectionLabel("width")] = ``;
828
- }
829
- const slideStyles = getComputedStyle(slide2);
830
- const currentTransform = slide2.style.transform;
831
- const currentWebKitTransform = slide2.style.webkitTransform;
832
- if (currentTransform) {
833
- slide2.style.transform = "none";
834
- }
835
- if (currentWebKitTransform) {
836
- slide2.style.webkitTransform = "none";
837
- }
838
- if (params.roundLengths) {
839
- slideSize = swiper2.isHorizontal() ? elementOuterSize(slide2, "width") : elementOuterSize(slide2, "height");
840
- } else {
841
- const width = getDirectionPropertyValue(slideStyles, "width");
842
- const paddingLeft = getDirectionPropertyValue(slideStyles, "padding-left");
843
- const paddingRight = getDirectionPropertyValue(slideStyles, "padding-right");
844
- const marginLeft = getDirectionPropertyValue(slideStyles, "margin-left");
845
- const marginRight = getDirectionPropertyValue(slideStyles, "margin-right");
846
- const boxSizing = slideStyles.getPropertyValue("box-sizing");
847
- if (boxSizing && boxSizing === "border-box") {
848
- slideSize = width + marginLeft + marginRight;
849
- } else {
850
- const {
851
- clientWidth,
852
- offsetWidth
853
- } = slide2;
854
- slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
855
- }
856
- }
857
- if (currentTransform) {
858
- slide2.style.transform = currentTransform;
859
- }
860
- if (currentWebKitTransform) {
861
- slide2.style.webkitTransform = currentWebKitTransform;
862
- }
863
- if (params.roundLengths) slideSize = Math.floor(slideSize);
864
- } else {
865
- slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
866
- if (params.roundLengths) slideSize = Math.floor(slideSize);
867
- if (slides2[i]) {
868
- slides2[i].style[swiper2.getDirectionLabel("width")] = `${slideSize}px`;
869
- }
870
- }
871
- if (slides2[i]) {
872
- slides2[i].swiperSlideSize = slideSize;
873
- }
874
- slidesSizesGrid.push(slideSize);
875
- if (params.centeredSlides) {
876
- slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
877
- if (prevSlideSize === 0 && i !== 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
878
- if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
879
- if (Math.abs(slidePosition) < 1 / 1e3) slidePosition = 0;
880
- if (params.roundLengths) slidePosition = Math.floor(slidePosition);
881
- if (index % params.slidesPerGroup === 0) snapGrid.push(slidePosition);
882
- slidesGrid.push(slidePosition);
883
- } else {
884
- if (params.roundLengths) slidePosition = Math.floor(slidePosition);
885
- if ((index - Math.min(swiper2.params.slidesPerGroupSkip, index)) % swiper2.params.slidesPerGroup === 0) snapGrid.push(slidePosition);
886
- slidesGrid.push(slidePosition);
887
- slidePosition = slidePosition + slideSize + spaceBetween;
888
- }
889
- swiper2.virtualSize += slideSize + spaceBetween;
890
- prevSlideSize = slideSize;
891
- index += 1;
892
- }
893
- swiper2.virtualSize = Math.max(swiper2.virtualSize, swiperSize) + offsetAfter;
894
- if (rtl && wrongRTL && (params.effect === "slide" || params.effect === "coverflow")) {
895
- wrapperEl.style.width = `${swiper2.virtualSize + spaceBetween}px`;
896
- }
897
- if (params.setWrapperSize) {
898
- wrapperEl.style[swiper2.getDirectionLabel("width")] = `${swiper2.virtualSize + spaceBetween}px`;
899
- }
900
- if (gridEnabled) {
901
- swiper2.grid.updateWrapperSize(slideSize, snapGrid);
902
- }
903
- if (!params.centeredSlides) {
904
- const newSlidesGrid = [];
905
- for (let i = 0; i < snapGrid.length; i += 1) {
906
- let slidesGridItem = snapGrid[i];
907
- if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
908
- if (snapGrid[i] <= swiper2.virtualSize - swiperSize) {
909
- newSlidesGrid.push(slidesGridItem);
910
- }
911
- }
912
- snapGrid = newSlidesGrid;
913
- if (Math.floor(swiper2.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
914
- snapGrid.push(swiper2.virtualSize - swiperSize);
915
- }
916
- }
917
- if (isVirtual && params.loop) {
918
- const size = slidesSizesGrid[0] + spaceBetween;
919
- if (params.slidesPerGroup > 1) {
920
- const groups = Math.ceil((swiper2.virtual.slidesBefore + swiper2.virtual.slidesAfter) / params.slidesPerGroup);
921
- const groupSize = size * params.slidesPerGroup;
922
- for (let i = 0; i < groups; i += 1) {
923
- snapGrid.push(snapGrid[snapGrid.length - 1] + groupSize);
924
- }
925
- }
926
- for (let i = 0; i < swiper2.virtual.slidesBefore + swiper2.virtual.slidesAfter; i += 1) {
927
- if (params.slidesPerGroup === 1) {
928
- snapGrid.push(snapGrid[snapGrid.length - 1] + size);
929
- }
930
- slidesGrid.push(slidesGrid[slidesGrid.length - 1] + size);
931
- swiper2.virtualSize += size;
932
- }
933
- }
934
- if (snapGrid.length === 0) snapGrid = [0];
935
- if (spaceBetween !== 0) {
936
- const key = swiper2.isHorizontal() && rtl ? "marginLeft" : swiper2.getDirectionLabel("marginRight");
937
- slides2.filter((_, slideIndex) => {
938
- if (!params.cssMode || params.loop) return true;
939
- if (slideIndex === slides2.length - 1) {
940
- return false;
941
- }
942
- return true;
943
- }).forEach((slideEl) => {
944
- slideEl.style[key] = `${spaceBetween}px`;
945
- });
946
- }
947
- if (params.centeredSlides && params.centeredSlidesBounds) {
948
- let allSlidesSize = 0;
949
- slidesSizesGrid.forEach((slideSizeValue) => {
950
- allSlidesSize += slideSizeValue + (spaceBetween || 0);
951
- });
952
- allSlidesSize -= spaceBetween;
953
- const maxSnap = allSlidesSize - swiperSize;
954
- snapGrid = snapGrid.map((snap) => {
955
- if (snap <= 0) return -offsetBefore;
956
- if (snap > maxSnap) return maxSnap + offsetAfter;
957
- return snap;
958
- });
959
- }
960
- if (params.centerInsufficientSlides) {
961
- let allSlidesSize = 0;
962
- slidesSizesGrid.forEach((slideSizeValue) => {
963
- allSlidesSize += slideSizeValue + (spaceBetween || 0);
964
- });
965
- allSlidesSize -= spaceBetween;
966
- const offsetSize = (params.slidesOffsetBefore || 0) + (params.slidesOffsetAfter || 0);
967
- if (allSlidesSize + offsetSize < swiperSize) {
968
- const allSlidesOffset = (swiperSize - allSlidesSize - offsetSize) / 2;
969
- snapGrid.forEach((snap, snapIndex) => {
970
- snapGrid[snapIndex] = snap - allSlidesOffset;
971
- });
972
- slidesGrid.forEach((snap, snapIndex) => {
973
- slidesGrid[snapIndex] = snap + allSlidesOffset;
974
- });
975
- }
976
- }
977
- Object.assign(swiper2, {
978
- slides: slides2,
979
- snapGrid,
980
- slidesGrid,
981
- slidesSizesGrid
982
- });
983
- if (params.centeredSlides && params.cssMode && !params.centeredSlidesBounds) {
984
- setCSSProperty(wrapperEl, "--swiper-centered-offset-before", `${-snapGrid[0]}px`);
985
- setCSSProperty(wrapperEl, "--swiper-centered-offset-after", `${swiper2.size / 2 - slidesSizesGrid[slidesSizesGrid.length - 1] / 2}px`);
986
- const addToSnapGrid = -swiper2.snapGrid[0];
987
- const addToSlidesGrid = -swiper2.slidesGrid[0];
988
- swiper2.snapGrid = swiper2.snapGrid.map((v) => v + addToSnapGrid);
989
- swiper2.slidesGrid = swiper2.slidesGrid.map((v) => v + addToSlidesGrid);
990
- }
991
- if (slidesLength !== previousSlidesLength) {
992
- swiper2.emit("slidesLengthChange");
993
- }
994
- if (snapGrid.length !== previousSnapGridLength) {
995
- if (swiper2.params.watchOverflow) swiper2.checkOverflow();
996
- swiper2.emit("snapGridLengthChange");
997
- }
998
- if (slidesGrid.length !== previousSlidesGridLength) {
999
- swiper2.emit("slidesGridLengthChange");
1000
- }
1001
- if (params.watchSlidesProgress) {
1002
- swiper2.updateSlidesOffset();
1003
- }
1004
- swiper2.emit("slidesUpdated");
1005
- if (!isVirtual && !params.cssMode && (params.effect === "slide" || params.effect === "fade")) {
1006
- const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`;
1007
- const hasClassBackfaceClassAdded = swiper2.el.classList.contains(backFaceHiddenClass);
1008
- if (slidesLength <= params.maxBackfaceHiddenSlides) {
1009
- if (!hasClassBackfaceClassAdded) swiper2.el.classList.add(backFaceHiddenClass);
1010
- } else if (hasClassBackfaceClassAdded) {
1011
- swiper2.el.classList.remove(backFaceHiddenClass);
1012
- }
1013
- }
1014
- }
1015
- function updateAutoHeight(speed) {
1016
- const swiper2 = this;
1017
- const activeSlides = [];
1018
- const isVirtual = swiper2.virtual && swiper2.params.virtual.enabled;
1019
- let newHeight = 0;
1020
- let i;
1021
- if (typeof speed === "number") {
1022
- swiper2.setTransition(speed);
1023
- } else if (speed === true) {
1024
- swiper2.setTransition(swiper2.params.speed);
1025
- }
1026
- const getSlideByIndex = (index) => {
1027
- if (isVirtual) {
1028
- return swiper2.slides[swiper2.getSlideIndexByData(index)];
1029
- }
1030
- return swiper2.slides[index];
1031
- };
1032
- if (swiper2.params.slidesPerView !== "auto" && swiper2.params.slidesPerView > 1) {
1033
- if (swiper2.params.centeredSlides) {
1034
- (swiper2.visibleSlides || []).forEach((slide2) => {
1035
- activeSlides.push(slide2);
1036
- });
1037
- } else {
1038
- for (i = 0; i < Math.ceil(swiper2.params.slidesPerView); i += 1) {
1039
- const index = swiper2.activeIndex + i;
1040
- if (index > swiper2.slides.length && !isVirtual) break;
1041
- activeSlides.push(getSlideByIndex(index));
1042
- }
1043
- }
1044
- } else {
1045
- activeSlides.push(getSlideByIndex(swiper2.activeIndex));
1046
- }
1047
- for (i = 0; i < activeSlides.length; i += 1) {
1048
- if (typeof activeSlides[i] !== "undefined") {
1049
- const height = activeSlides[i].offsetHeight;
1050
- newHeight = height > newHeight ? height : newHeight;
1051
- }
1052
- }
1053
- if (newHeight || newHeight === 0) swiper2.wrapperEl.style.height = `${newHeight}px`;
1054
- }
1055
- function updateSlidesOffset() {
1056
- const swiper2 = this;
1057
- const slides2 = swiper2.slides;
1058
- const minusOffset = swiper2.isElement ? swiper2.isHorizontal() ? swiper2.wrapperEl.offsetLeft : swiper2.wrapperEl.offsetTop : 0;
1059
- for (let i = 0; i < slides2.length; i += 1) {
1060
- slides2[i].swiperSlideOffset = (swiper2.isHorizontal() ? slides2[i].offsetLeft : slides2[i].offsetTop) - minusOffset - swiper2.cssOverflowAdjustment();
1061
- }
1062
- }
1063
- const toggleSlideClasses$1 = (slideEl, condition, className) => {
1064
- if (condition && !slideEl.classList.contains(className)) {
1065
- slideEl.classList.add(className);
1066
- } else if (!condition && slideEl.classList.contains(className)) {
1067
- slideEl.classList.remove(className);
1068
- }
1069
- };
1070
- function updateSlidesProgress(translate2) {
1071
- if (translate2 === void 0) {
1072
- translate2 = this && this.translate || 0;
1073
- }
1074
- const swiper2 = this;
1075
- const params = swiper2.params;
1076
- const {
1077
- slides: slides2,
1078
- rtlTranslate: rtl,
1079
- snapGrid
1080
- } = swiper2;
1081
- if (slides2.length === 0) return;
1082
- if (typeof slides2[0].swiperSlideOffset === "undefined") swiper2.updateSlidesOffset();
1083
- let offsetCenter = -translate2;
1084
- if (rtl) offsetCenter = translate2;
1085
- swiper2.visibleSlidesIndexes = [];
1086
- swiper2.visibleSlides = [];
1087
- let spaceBetween = params.spaceBetween;
1088
- if (typeof spaceBetween === "string" && spaceBetween.indexOf("%") >= 0) {
1089
- spaceBetween = parseFloat(spaceBetween.replace("%", "")) / 100 * swiper2.size;
1090
- } else if (typeof spaceBetween === "string") {
1091
- spaceBetween = parseFloat(spaceBetween);
1092
- }
1093
- for (let i = 0; i < slides2.length; i += 1) {
1094
- const slide2 = slides2[i];
1095
- let slideOffset = slide2.swiperSlideOffset;
1096
- if (params.cssMode && params.centeredSlides) {
1097
- slideOffset -= slides2[0].swiperSlideOffset;
1098
- }
1099
- const slideProgress = (offsetCenter + (params.centeredSlides ? swiper2.minTranslate() : 0) - slideOffset) / (slide2.swiperSlideSize + spaceBetween);
1100
- const originalSlideProgress = (offsetCenter - snapGrid[0] + (params.centeredSlides ? swiper2.minTranslate() : 0) - slideOffset) / (slide2.swiperSlideSize + spaceBetween);
1101
- const slideBefore = -(offsetCenter - slideOffset);
1102
- const slideAfter = slideBefore + swiper2.slidesSizesGrid[i];
1103
- const isFullyVisible = slideBefore >= 0 && slideBefore <= swiper2.size - swiper2.slidesSizesGrid[i];
1104
- const isVisible = slideBefore >= 0 && slideBefore < swiper2.size - 1 || slideAfter > 1 && slideAfter <= swiper2.size || slideBefore <= 0 && slideAfter >= swiper2.size;
1105
- if (isVisible) {
1106
- swiper2.visibleSlides.push(slide2);
1107
- swiper2.visibleSlidesIndexes.push(i);
1108
- }
1109
- toggleSlideClasses$1(slide2, isVisible, params.slideVisibleClass);
1110
- toggleSlideClasses$1(slide2, isFullyVisible, params.slideFullyVisibleClass);
1111
- slide2.progress = rtl ? -slideProgress : slideProgress;
1112
- slide2.originalProgress = rtl ? -originalSlideProgress : originalSlideProgress;
1113
- }
1114
- }
1115
- function updateProgress(translate2) {
1116
- const swiper2 = this;
1117
- if (typeof translate2 === "undefined") {
1118
- const multiplier = swiper2.rtlTranslate ? -1 : 1;
1119
- translate2 = swiper2 && swiper2.translate && swiper2.translate * multiplier || 0;
1120
- }
1121
- const params = swiper2.params;
1122
- const translatesDiff = swiper2.maxTranslate() - swiper2.minTranslate();
1123
- let {
1124
- progress,
1125
- isBeginning,
1126
- isEnd,
1127
- progressLoop
1128
- } = swiper2;
1129
- const wasBeginning = isBeginning;
1130
- const wasEnd = isEnd;
1131
- if (translatesDiff === 0) {
1132
- progress = 0;
1133
- isBeginning = true;
1134
- isEnd = true;
1135
- } else {
1136
- progress = (translate2 - swiper2.minTranslate()) / translatesDiff;
1137
- const isBeginningRounded = Math.abs(translate2 - swiper2.minTranslate()) < 1;
1138
- const isEndRounded = Math.abs(translate2 - swiper2.maxTranslate()) < 1;
1139
- isBeginning = isBeginningRounded || progress <= 0;
1140
- isEnd = isEndRounded || progress >= 1;
1141
- if (isBeginningRounded) progress = 0;
1142
- if (isEndRounded) progress = 1;
1143
- }
1144
- if (params.loop) {
1145
- const firstSlideIndex = swiper2.getSlideIndexByData(0);
1146
- const lastSlideIndex = swiper2.getSlideIndexByData(swiper2.slides.length - 1);
1147
- const firstSlideTranslate = swiper2.slidesGrid[firstSlideIndex];
1148
- const lastSlideTranslate = swiper2.slidesGrid[lastSlideIndex];
1149
- const translateMax = swiper2.slidesGrid[swiper2.slidesGrid.length - 1];
1150
- const translateAbs = Math.abs(translate2);
1151
- if (translateAbs >= firstSlideTranslate) {
1152
- progressLoop = (translateAbs - firstSlideTranslate) / translateMax;
1153
- } else {
1154
- progressLoop = (translateAbs + translateMax - lastSlideTranslate) / translateMax;
1155
- }
1156
- if (progressLoop > 1) progressLoop -= 1;
1157
- }
1158
- Object.assign(swiper2, {
1159
- progress,
1160
- progressLoop,
1161
- isBeginning,
1162
- isEnd
1163
- });
1164
- if (params.watchSlidesProgress || params.centeredSlides && params.autoHeight) swiper2.updateSlidesProgress(translate2);
1165
- if (isBeginning && !wasBeginning) {
1166
- swiper2.emit("reachBeginning toEdge");
1167
- }
1168
- if (isEnd && !wasEnd) {
1169
- swiper2.emit("reachEnd toEdge");
1170
- }
1171
- if (wasBeginning && !isBeginning || wasEnd && !isEnd) {
1172
- swiper2.emit("fromEdge");
1173
- }
1174
- swiper2.emit("progress", progress);
1175
- }
1176
- const toggleSlideClasses = (slideEl, condition, className) => {
1177
- if (condition && !slideEl.classList.contains(className)) {
1178
- slideEl.classList.add(className);
1179
- } else if (!condition && slideEl.classList.contains(className)) {
1180
- slideEl.classList.remove(className);
1181
- }
1182
- };
1183
- function updateSlidesClasses() {
1184
- const swiper2 = this;
1185
- const {
1186
- slides: slides2,
1187
- params,
1188
- slidesEl,
1189
- activeIndex
1190
- } = swiper2;
1191
- const isVirtual = swiper2.virtual && params.virtual.enabled;
1192
- const gridEnabled = swiper2.grid && params.grid && params.grid.rows > 1;
1193
- const getFilteredSlide = (selector) => {
1194
- return elementChildren(slidesEl, `.${params.slideClass}${selector}, swiper-slide${selector}`)[0];
1195
- };
1196
- let activeSlide;
1197
- let prevSlide;
1198
- let nextSlide;
1199
- if (isVirtual) {
1200
- if (params.loop) {
1201
- let slideIndex = activeIndex - swiper2.virtual.slidesBefore;
1202
- if (slideIndex < 0) slideIndex = swiper2.virtual.slides.length + slideIndex;
1203
- if (slideIndex >= swiper2.virtual.slides.length) slideIndex -= swiper2.virtual.slides.length;
1204
- activeSlide = getFilteredSlide(`[data-swiper-slide-index="${slideIndex}"]`);
1205
- } else {
1206
- activeSlide = getFilteredSlide(`[data-swiper-slide-index="${activeIndex}"]`);
1207
- }
1208
- } else {
1209
- if (gridEnabled) {
1210
- activeSlide = slides2.filter((slideEl) => slideEl.column === activeIndex)[0];
1211
- nextSlide = slides2.filter((slideEl) => slideEl.column === activeIndex + 1)[0];
1212
- prevSlide = slides2.filter((slideEl) => slideEl.column === activeIndex - 1)[0];
1213
- } else {
1214
- activeSlide = slides2[activeIndex];
1215
- }
1216
- }
1217
- if (activeSlide) {
1218
- if (!gridEnabled) {
1219
- nextSlide = elementNextAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
1220
- if (params.loop && !nextSlide) {
1221
- nextSlide = slides2[0];
1222
- }
1223
- prevSlide = elementPrevAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
1224
- if (params.loop && !prevSlide === 0) {
1225
- prevSlide = slides2[slides2.length - 1];
1226
- }
1227
- }
1228
- }
1229
- slides2.forEach((slideEl) => {
1230
- toggleSlideClasses(slideEl, slideEl === activeSlide, params.slideActiveClass);
1231
- toggleSlideClasses(slideEl, slideEl === nextSlide, params.slideNextClass);
1232
- toggleSlideClasses(slideEl, slideEl === prevSlide, params.slidePrevClass);
1233
- });
1234
- swiper2.emitSlidesClasses();
1235
- }
1236
- const processLazyPreloader = (swiper2, imageEl) => {
1237
- if (!swiper2 || swiper2.destroyed || !swiper2.params) return;
1238
- const slideSelector = () => swiper2.isElement ? `swiper-slide` : `.${swiper2.params.slideClass}`;
1239
- const slideEl = imageEl.closest(slideSelector());
1240
- if (slideEl) {
1241
- let lazyEl = slideEl.querySelector(`.${swiper2.params.lazyPreloaderClass}`);
1242
- if (!lazyEl && swiper2.isElement) {
1243
- if (slideEl.shadowRoot) {
1244
- lazyEl = slideEl.shadowRoot.querySelector(`.${swiper2.params.lazyPreloaderClass}`);
1245
- } else {
1246
- requestAnimationFrame(() => {
1247
- if (slideEl.shadowRoot) {
1248
- lazyEl = slideEl.shadowRoot.querySelector(`.${swiper2.params.lazyPreloaderClass}`);
1249
- if (lazyEl) lazyEl.remove();
1250
- }
1251
- });
1252
- }
1253
- }
1254
- if (lazyEl) lazyEl.remove();
1255
- }
1256
- };
1257
- const unlazy = (swiper2, index) => {
1258
- if (!swiper2.slides[index]) return;
1259
- const imageEl = swiper2.slides[index].querySelector('[loading="lazy"]');
1260
- if (imageEl) imageEl.removeAttribute("loading");
1261
- };
1262
- const preload = (swiper2) => {
1263
- if (!swiper2 || swiper2.destroyed || !swiper2.params) return;
1264
- let amount = swiper2.params.lazyPreloadPrevNext;
1265
- const len = swiper2.slides.length;
1266
- if (!len || !amount || amount < 0) return;
1267
- amount = Math.min(amount, len);
1268
- const slidesPerView = swiper2.params.slidesPerView === "auto" ? swiper2.slidesPerViewDynamic() : Math.ceil(swiper2.params.slidesPerView);
1269
- const activeIndex = swiper2.activeIndex;
1270
- if (swiper2.params.grid && swiper2.params.grid.rows > 1) {
1271
- const activeColumn = activeIndex;
1272
- const preloadColumns = [activeColumn - amount];
1273
- preloadColumns.push(...Array.from({
1274
- length: amount
1275
- }).map((_, i) => {
1276
- return activeColumn + slidesPerView + i;
1277
- }));
1278
- swiper2.slides.forEach((slideEl, i) => {
1279
- if (preloadColumns.includes(slideEl.column)) unlazy(swiper2, i);
1280
- });
1281
- return;
1282
- }
1283
- const slideIndexLastInView = activeIndex + slidesPerView - 1;
1284
- if (swiper2.params.rewind || swiper2.params.loop) {
1285
- for (let i = activeIndex - amount; i <= slideIndexLastInView + amount; i += 1) {
1286
- const realIndex = (i % len + len) % len;
1287
- if (realIndex < activeIndex || realIndex > slideIndexLastInView) unlazy(swiper2, realIndex);
1288
- }
1289
- } else {
1290
- for (let i = Math.max(activeIndex - amount, 0); i <= Math.min(slideIndexLastInView + amount, len - 1); i += 1) {
1291
- if (i !== activeIndex && (i > slideIndexLastInView || i < activeIndex)) {
1292
- unlazy(swiper2, i);
1293
- }
1294
- }
1295
- }
1296
- };
1297
- function getActiveIndexByTranslate(swiper2) {
1298
- const {
1299
- slidesGrid,
1300
- params
1301
- } = swiper2;
1302
- const translate2 = swiper2.rtlTranslate ? swiper2.translate : -swiper2.translate;
1303
- let activeIndex;
1304
- for (let i = 0; i < slidesGrid.length; i += 1) {
1305
- if (typeof slidesGrid[i + 1] !== "undefined") {
1306
- if (translate2 >= slidesGrid[i] && translate2 < slidesGrid[i + 1] - (slidesGrid[i + 1] - slidesGrid[i]) / 2) {
1307
- activeIndex = i;
1308
- } else if (translate2 >= slidesGrid[i] && translate2 < slidesGrid[i + 1]) {
1309
- activeIndex = i + 1;
1310
- }
1311
- } else if (translate2 >= slidesGrid[i]) {
1312
- activeIndex = i;
1313
- }
1314
- }
1315
- if (params.normalizeSlideIndex) {
1316
- if (activeIndex < 0 || typeof activeIndex === "undefined") activeIndex = 0;
1317
- }
1318
- return activeIndex;
1319
- }
1320
- function updateActiveIndex(newActiveIndex) {
1321
- const swiper2 = this;
1322
- const translate2 = swiper2.rtlTranslate ? swiper2.translate : -swiper2.translate;
1323
- const {
1324
- snapGrid,
1325
- params,
1326
- activeIndex: previousIndex,
1327
- realIndex: previousRealIndex,
1328
- snapIndex: previousSnapIndex
1329
- } = swiper2;
1330
- let activeIndex = newActiveIndex;
1331
- let snapIndex;
1332
- const getVirtualRealIndex = (aIndex) => {
1333
- let realIndex2 = aIndex - swiper2.virtual.slidesBefore;
1334
- if (realIndex2 < 0) {
1335
- realIndex2 = swiper2.virtual.slides.length + realIndex2;
1336
- }
1337
- if (realIndex2 >= swiper2.virtual.slides.length) {
1338
- realIndex2 -= swiper2.virtual.slides.length;
1339
- }
1340
- return realIndex2;
1341
- };
1342
- if (typeof activeIndex === "undefined") {
1343
- activeIndex = getActiveIndexByTranslate(swiper2);
1344
- }
1345
- if (snapGrid.indexOf(translate2) >= 0) {
1346
- snapIndex = snapGrid.indexOf(translate2);
1347
- } else {
1348
- const skip = Math.min(params.slidesPerGroupSkip, activeIndex);
1349
- snapIndex = skip + Math.floor((activeIndex - skip) / params.slidesPerGroup);
1350
- }
1351
- if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
1352
- if (activeIndex === previousIndex && !swiper2.params.loop) {
1353
- if (snapIndex !== previousSnapIndex) {
1354
- swiper2.snapIndex = snapIndex;
1355
- swiper2.emit("snapIndexChange");
1356
- }
1357
- return;
1358
- }
1359
- if (activeIndex === previousIndex && swiper2.params.loop && swiper2.virtual && swiper2.params.virtual.enabled) {
1360
- swiper2.realIndex = getVirtualRealIndex(activeIndex);
1361
- return;
1362
- }
1363
- const gridEnabled = swiper2.grid && params.grid && params.grid.rows > 1;
1364
- let realIndex;
1365
- if (swiper2.virtual && params.virtual.enabled && params.loop) {
1366
- realIndex = getVirtualRealIndex(activeIndex);
1367
- } else if (gridEnabled) {
1368
- const firstSlideInColumn = swiper2.slides.filter((slideEl) => slideEl.column === activeIndex)[0];
1369
- let activeSlideIndex = parseInt(firstSlideInColumn.getAttribute("data-swiper-slide-index"), 10);
1370
- if (Number.isNaN(activeSlideIndex)) {
1371
- activeSlideIndex = Math.max(swiper2.slides.indexOf(firstSlideInColumn), 0);
1372
- }
1373
- realIndex = Math.floor(activeSlideIndex / params.grid.rows);
1374
- } else if (swiper2.slides[activeIndex]) {
1375
- const slideIndex = swiper2.slides[activeIndex].getAttribute("data-swiper-slide-index");
1376
- if (slideIndex) {
1377
- realIndex = parseInt(slideIndex, 10);
1378
- } else {
1379
- realIndex = activeIndex;
1380
- }
1381
- } else {
1382
- realIndex = activeIndex;
1383
- }
1384
- Object.assign(swiper2, {
1385
- previousSnapIndex,
1386
- snapIndex,
1387
- previousRealIndex,
1388
- realIndex,
1389
- previousIndex,
1390
- activeIndex
1391
- });
1392
- if (swiper2.initialized) {
1393
- preload(swiper2);
1394
- }
1395
- swiper2.emit("activeIndexChange");
1396
- swiper2.emit("snapIndexChange");
1397
- if (swiper2.initialized || swiper2.params.runCallbacksOnInit) {
1398
- if (previousRealIndex !== realIndex) {
1399
- swiper2.emit("realIndexChange");
1400
- }
1401
- swiper2.emit("slideChange");
1402
- }
1403
- }
1404
- function updateClickedSlide(el, path) {
1405
- const swiper2 = this;
1406
- const params = swiper2.params;
1407
- let slide2 = el.closest(`.${params.slideClass}, swiper-slide`);
1408
- if (!slide2 && swiper2.isElement && path && path.length > 1 && path.includes(el)) {
1409
- [...path.slice(path.indexOf(el) + 1, path.length)].forEach((pathEl) => {
1410
- if (!slide2 && pathEl.matches && pathEl.matches(`.${params.slideClass}, swiper-slide`)) {
1411
- slide2 = pathEl;
1412
- }
1413
- });
1414
- }
1415
- let slideFound = false;
1416
- let slideIndex;
1417
- if (slide2) {
1418
- for (let i = 0; i < swiper2.slides.length; i += 1) {
1419
- if (swiper2.slides[i] === slide2) {
1420
- slideFound = true;
1421
- slideIndex = i;
1422
- break;
1423
- }
1424
- }
1425
- }
1426
- if (slide2 && slideFound) {
1427
- swiper2.clickedSlide = slide2;
1428
- if (swiper2.virtual && swiper2.params.virtual.enabled) {
1429
- swiper2.clickedIndex = parseInt(slide2.getAttribute("data-swiper-slide-index"), 10);
1430
- } else {
1431
- swiper2.clickedIndex = slideIndex;
1432
- }
1433
- } else {
1434
- swiper2.clickedSlide = void 0;
1435
- swiper2.clickedIndex = void 0;
1436
- return;
1437
- }
1438
- if (params.slideToClickedSlide && swiper2.clickedIndex !== void 0 && swiper2.clickedIndex !== swiper2.activeIndex) {
1439
- swiper2.slideToClickedSlide();
1440
- }
1441
- }
1442
- var update = {
1443
- updateSize,
1444
- updateSlides,
1445
- updateAutoHeight,
1446
- updateSlidesOffset,
1447
- updateSlidesProgress,
1448
- updateProgress,
1449
- updateSlidesClasses,
1450
- updateActiveIndex,
1451
- updateClickedSlide
1452
- };
1453
- function getSwiperTranslate(axis) {
1454
- if (axis === void 0) {
1455
- axis = this.isHorizontal() ? "x" : "y";
1456
- }
1457
- const swiper2 = this;
1458
- const {
1459
- params,
1460
- rtlTranslate: rtl,
1461
- translate: translate2,
1462
- wrapperEl
1463
- } = swiper2;
1464
- if (params.virtualTranslate) {
1465
- return rtl ? -translate2 : translate2;
1466
- }
1467
- if (params.cssMode) {
1468
- return translate2;
1469
- }
1470
- let currentTranslate = getTranslate(wrapperEl, axis);
1471
- currentTranslate += swiper2.cssOverflowAdjustment();
1472
- if (rtl) currentTranslate = -currentTranslate;
1473
- return currentTranslate || 0;
1474
- }
1475
- function setTranslate(translate2, byController) {
1476
- const swiper2 = this;
1477
- const {
1478
- rtlTranslate: rtl,
1479
- params,
1480
- wrapperEl,
1481
- progress
1482
- } = swiper2;
1483
- let x = 0;
1484
- let y = 0;
1485
- const z = 0;
1486
- if (swiper2.isHorizontal()) {
1487
- x = rtl ? -translate2 : translate2;
1488
- } else {
1489
- y = translate2;
1490
- }
1491
- if (params.roundLengths) {
1492
- x = Math.floor(x);
1493
- y = Math.floor(y);
1494
- }
1495
- swiper2.previousTranslate = swiper2.translate;
1496
- swiper2.translate = swiper2.isHorizontal() ? x : y;
1497
- if (params.cssMode) {
1498
- wrapperEl[swiper2.isHorizontal() ? "scrollLeft" : "scrollTop"] = swiper2.isHorizontal() ? -x : -y;
1499
- } else if (!params.virtualTranslate) {
1500
- if (swiper2.isHorizontal()) {
1501
- x -= swiper2.cssOverflowAdjustment();
1502
- } else {
1503
- y -= swiper2.cssOverflowAdjustment();
1504
- }
1505
- wrapperEl.style.transform = `translate3d(${x}px, ${y}px, ${z}px)`;
1506
- }
1507
- let newProgress;
1508
- const translatesDiff = swiper2.maxTranslate() - swiper2.minTranslate();
1509
- if (translatesDiff === 0) {
1510
- newProgress = 0;
1511
- } else {
1512
- newProgress = (translate2 - swiper2.minTranslate()) / translatesDiff;
1513
- }
1514
- if (newProgress !== progress) {
1515
- swiper2.updateProgress(translate2);
1516
- }
1517
- swiper2.emit("setTranslate", swiper2.translate, byController);
1518
- }
1519
- function minTranslate() {
1520
- return -this.snapGrid[0];
1521
- }
1522
- function maxTranslate() {
1523
- return -this.snapGrid[this.snapGrid.length - 1];
1524
- }
1525
- function translateTo(translate2, speed, runCallbacks, translateBounds, internal) {
1526
- if (translate2 === void 0) {
1527
- translate2 = 0;
1528
- }
1529
- if (speed === void 0) {
1530
- speed = this.params.speed;
1531
- }
1532
- if (runCallbacks === void 0) {
1533
- runCallbacks = true;
1534
- }
1535
- if (translateBounds === void 0) {
1536
- translateBounds = true;
1537
- }
1538
- const swiper2 = this;
1539
- const {
1540
- params,
1541
- wrapperEl
1542
- } = swiper2;
1543
- if (swiper2.animating && params.preventInteractionOnTransition) {
1544
- return false;
1545
- }
1546
- const minTranslate2 = swiper2.minTranslate();
1547
- const maxTranslate2 = swiper2.maxTranslate();
1548
- let newTranslate;
1549
- if (translateBounds && translate2 > minTranslate2) newTranslate = minTranslate2;
1550
- else if (translateBounds && translate2 < maxTranslate2) newTranslate = maxTranslate2;
1551
- else newTranslate = translate2;
1552
- swiper2.updateProgress(newTranslate);
1553
- if (params.cssMode) {
1554
- const isH = swiper2.isHorizontal();
1555
- if (speed === 0) {
1556
- wrapperEl[isH ? "scrollLeft" : "scrollTop"] = -newTranslate;
1557
- } else {
1558
- if (!swiper2.support.smoothScroll) {
1559
- animateCSSModeScroll({
1560
- swiper: swiper2,
1561
- targetPosition: -newTranslate,
1562
- side: isH ? "left" : "top"
1563
- });
1564
- return true;
1565
- }
1566
- wrapperEl.scrollTo({
1567
- [isH ? "left" : "top"]: -newTranslate,
1568
- behavior: "smooth"
1569
- });
1570
- }
1571
- return true;
1572
- }
1573
- if (speed === 0) {
1574
- swiper2.setTransition(0);
1575
- swiper2.setTranslate(newTranslate);
1576
- if (runCallbacks) {
1577
- swiper2.emit("beforeTransitionStart", speed, internal);
1578
- swiper2.emit("transitionEnd");
1579
- }
1580
- } else {
1581
- swiper2.setTransition(speed);
1582
- swiper2.setTranslate(newTranslate);
1583
- if (runCallbacks) {
1584
- swiper2.emit("beforeTransitionStart", speed, internal);
1585
- swiper2.emit("transitionStart");
1586
- }
1587
- if (!swiper2.animating) {
1588
- swiper2.animating = true;
1589
- if (!swiper2.onTranslateToWrapperTransitionEnd) {
1590
- swiper2.onTranslateToWrapperTransitionEnd = function transitionEnd2(e) {
1591
- if (!swiper2 || swiper2.destroyed) return;
1592
- if (e.target !== this) return;
1593
- swiper2.wrapperEl.removeEventListener("transitionend", swiper2.onTranslateToWrapperTransitionEnd);
1594
- swiper2.onTranslateToWrapperTransitionEnd = null;
1595
- delete swiper2.onTranslateToWrapperTransitionEnd;
1596
- swiper2.animating = false;
1597
- if (runCallbacks) {
1598
- swiper2.emit("transitionEnd");
1599
- }
1600
- };
1601
- }
1602
- swiper2.wrapperEl.addEventListener("transitionend", swiper2.onTranslateToWrapperTransitionEnd);
1603
- }
1604
- }
1605
- return true;
1606
- }
1607
- var translate = {
1608
- getTranslate: getSwiperTranslate,
1609
- setTranslate,
1610
- minTranslate,
1611
- maxTranslate,
1612
- translateTo
1613
- };
1614
- function setTransition(duration, byController) {
1615
- const swiper2 = this;
1616
- if (!swiper2.params.cssMode) {
1617
- swiper2.wrapperEl.style.transitionDuration = `${duration}ms`;
1618
- swiper2.wrapperEl.style.transitionDelay = duration === 0 ? `0ms` : "";
1619
- }
1620
- swiper2.emit("setTransition", duration, byController);
1621
- }
1622
- function transitionEmit(_ref) {
1623
- let {
1624
- swiper: swiper2,
1625
- runCallbacks,
1626
- direction,
1627
- step
1628
- } = _ref;
1629
- const {
1630
- activeIndex,
1631
- previousIndex
1632
- } = swiper2;
1633
- let dir = direction;
1634
- if (!dir) {
1635
- if (activeIndex > previousIndex) dir = "next";
1636
- else if (activeIndex < previousIndex) dir = "prev";
1637
- else dir = "reset";
1638
- }
1639
- swiper2.emit(`transition${step}`);
1640
- if (runCallbacks && activeIndex !== previousIndex) {
1641
- if (dir === "reset") {
1642
- swiper2.emit(`slideResetTransition${step}`);
1643
- return;
1644
- }
1645
- swiper2.emit(`slideChangeTransition${step}`);
1646
- if (dir === "next") {
1647
- swiper2.emit(`slideNextTransition${step}`);
1648
- } else {
1649
- swiper2.emit(`slidePrevTransition${step}`);
1650
- }
1651
- }
1652
- }
1653
- function transitionStart(runCallbacks, direction) {
1654
- if (runCallbacks === void 0) {
1655
- runCallbacks = true;
1656
- }
1657
- const swiper2 = this;
1658
- const {
1659
- params
1660
- } = swiper2;
1661
- if (params.cssMode) return;
1662
- if (params.autoHeight) {
1663
- swiper2.updateAutoHeight();
1664
- }
1665
- transitionEmit({
1666
- swiper: swiper2,
1667
- runCallbacks,
1668
- direction,
1669
- step: "Start"
1670
- });
1671
- }
1672
- function transitionEnd(runCallbacks, direction) {
1673
- if (runCallbacks === void 0) {
1674
- runCallbacks = true;
1675
- }
1676
- const swiper2 = this;
1677
- const {
1678
- params
1679
- } = swiper2;
1680
- swiper2.animating = false;
1681
- if (params.cssMode) return;
1682
- swiper2.setTransition(0);
1683
- transitionEmit({
1684
- swiper: swiper2,
1685
- runCallbacks,
1686
- direction,
1687
- step: "End"
1688
- });
1689
- }
1690
- var transition = {
1691
- setTransition,
1692
- transitionStart,
1693
- transitionEnd
1694
- };
1695
- function slideTo(index, speed, runCallbacks, internal, initial) {
1696
- if (index === void 0) {
1697
- index = 0;
1698
- }
1699
- if (runCallbacks === void 0) {
1700
- runCallbacks = true;
1701
- }
1702
- if (typeof index === "string") {
1703
- index = parseInt(index, 10);
1704
- }
1705
- const swiper2 = this;
1706
- let slideIndex = index;
1707
- if (slideIndex < 0) slideIndex = 0;
1708
- const {
1709
- params,
1710
- snapGrid,
1711
- slidesGrid,
1712
- previousIndex,
1713
- activeIndex,
1714
- rtlTranslate: rtl,
1715
- wrapperEl,
1716
- enabled
1717
- } = swiper2;
1718
- if (!enabled && !internal && !initial || swiper2.destroyed || swiper2.animating && params.preventInteractionOnTransition) {
1719
- return false;
1720
- }
1721
- if (typeof speed === "undefined") {
1722
- speed = swiper2.params.speed;
1723
- }
1724
- const skip = Math.min(swiper2.params.slidesPerGroupSkip, slideIndex);
1725
- let snapIndex = skip + Math.floor((slideIndex - skip) / swiper2.params.slidesPerGroup);
1726
- if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
1727
- const translate2 = -snapGrid[snapIndex];
1728
- if (params.normalizeSlideIndex) {
1729
- for (let i = 0; i < slidesGrid.length; i += 1) {
1730
- const normalizedTranslate = -Math.floor(translate2 * 100);
1731
- const normalizedGrid = Math.floor(slidesGrid[i] * 100);
1732
- const normalizedGridNext = Math.floor(slidesGrid[i + 1] * 100);
1733
- if (typeof slidesGrid[i + 1] !== "undefined") {
1734
- if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext - (normalizedGridNext - normalizedGrid) / 2) {
1735
- slideIndex = i;
1736
- } else if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext) {
1737
- slideIndex = i + 1;
1738
- }
1739
- } else if (normalizedTranslate >= normalizedGrid) {
1740
- slideIndex = i;
1741
- }
1742
- }
1743
- }
1744
- if (swiper2.initialized && slideIndex !== activeIndex) {
1745
- if (!swiper2.allowSlideNext && (rtl ? translate2 > swiper2.translate && translate2 > swiper2.minTranslate() : translate2 < swiper2.translate && translate2 < swiper2.minTranslate())) {
1746
- return false;
1747
- }
1748
- if (!swiper2.allowSlidePrev && translate2 > swiper2.translate && translate2 > swiper2.maxTranslate()) {
1749
- if ((activeIndex || 0) !== slideIndex) {
1750
- return false;
1751
- }
1752
- }
1753
- }
1754
- if (slideIndex !== (previousIndex || 0) && runCallbacks) {
1755
- swiper2.emit("beforeSlideChangeStart");
1756
- }
1757
- swiper2.updateProgress(translate2);
1758
- let direction;
1759
- if (slideIndex > activeIndex) direction = "next";
1760
- else if (slideIndex < activeIndex) direction = "prev";
1761
- else direction = "reset";
1762
- if (rtl && -translate2 === swiper2.translate || !rtl && translate2 === swiper2.translate) {
1763
- swiper2.updateActiveIndex(slideIndex);
1764
- if (params.autoHeight) {
1765
- swiper2.updateAutoHeight();
1766
- }
1767
- swiper2.updateSlidesClasses();
1768
- if (params.effect !== "slide") {
1769
- swiper2.setTranslate(translate2);
1770
- }
1771
- if (direction !== "reset") {
1772
- swiper2.transitionStart(runCallbacks, direction);
1773
- swiper2.transitionEnd(runCallbacks, direction);
1774
- }
1775
- return false;
1776
- }
1777
- if (params.cssMode) {
1778
- const isH = swiper2.isHorizontal();
1779
- const t = rtl ? translate2 : -translate2;
1780
- if (speed === 0) {
1781
- const isVirtual = swiper2.virtual && swiper2.params.virtual.enabled;
1782
- if (isVirtual) {
1783
- swiper2.wrapperEl.style.scrollSnapType = "none";
1784
- swiper2._immediateVirtual = true;
1785
- }
1786
- if (isVirtual && !swiper2._cssModeVirtualInitialSet && swiper2.params.initialSlide > 0) {
1787
- swiper2._cssModeVirtualInitialSet = true;
1788
- requestAnimationFrame(() => {
1789
- wrapperEl[isH ? "scrollLeft" : "scrollTop"] = t;
1790
- });
1791
- } else {
1792
- wrapperEl[isH ? "scrollLeft" : "scrollTop"] = t;
1793
- }
1794
- if (isVirtual) {
1795
- requestAnimationFrame(() => {
1796
- swiper2.wrapperEl.style.scrollSnapType = "";
1797
- swiper2._immediateVirtual = false;
1798
- });
1799
- }
1800
- } else {
1801
- if (!swiper2.support.smoothScroll) {
1802
- animateCSSModeScroll({
1803
- swiper: swiper2,
1804
- targetPosition: t,
1805
- side: isH ? "left" : "top"
1806
- });
1807
- return true;
1808
- }
1809
- wrapperEl.scrollTo({
1810
- [isH ? "left" : "top"]: t,
1811
- behavior: "smooth"
1812
- });
1813
- }
1814
- return true;
1815
- }
1816
- swiper2.setTransition(speed);
1817
- swiper2.setTranslate(translate2);
1818
- swiper2.updateActiveIndex(slideIndex);
1819
- swiper2.updateSlidesClasses();
1820
- swiper2.emit("beforeTransitionStart", speed, internal);
1821
- swiper2.transitionStart(runCallbacks, direction);
1822
- if (speed === 0) {
1823
- swiper2.transitionEnd(runCallbacks, direction);
1824
- } else if (!swiper2.animating) {
1825
- swiper2.animating = true;
1826
- if (!swiper2.onSlideToWrapperTransitionEnd) {
1827
- swiper2.onSlideToWrapperTransitionEnd = function transitionEnd2(e) {
1828
- if (!swiper2 || swiper2.destroyed) return;
1829
- if (e.target !== this) return;
1830
- swiper2.wrapperEl.removeEventListener("transitionend", swiper2.onSlideToWrapperTransitionEnd);
1831
- swiper2.onSlideToWrapperTransitionEnd = null;
1832
- delete swiper2.onSlideToWrapperTransitionEnd;
1833
- swiper2.transitionEnd(runCallbacks, direction);
1834
- };
1835
- }
1836
- swiper2.wrapperEl.addEventListener("transitionend", swiper2.onSlideToWrapperTransitionEnd);
1837
- }
1838
- return true;
1839
- }
1840
- function slideToLoop(index, speed, runCallbacks, internal) {
1841
- if (index === void 0) {
1842
- index = 0;
1843
- }
1844
- if (runCallbacks === void 0) {
1845
- runCallbacks = true;
1846
- }
1847
- if (typeof index === "string") {
1848
- const indexAsNumber = parseInt(index, 10);
1849
- index = indexAsNumber;
1850
- }
1851
- const swiper2 = this;
1852
- if (swiper2.destroyed) return;
1853
- if (typeof speed === "undefined") {
1854
- speed = swiper2.params.speed;
1855
- }
1856
- const gridEnabled = swiper2.grid && swiper2.params.grid && swiper2.params.grid.rows > 1;
1857
- let newIndex = index;
1858
- if (swiper2.params.loop) {
1859
- if (swiper2.virtual && swiper2.params.virtual.enabled) {
1860
- newIndex = newIndex + swiper2.virtual.slidesBefore;
1861
- } else {
1862
- let targetSlideIndex;
1863
- if (gridEnabled) {
1864
- const slideIndex = newIndex * swiper2.params.grid.rows;
1865
- targetSlideIndex = swiper2.slides.filter((slideEl) => slideEl.getAttribute("data-swiper-slide-index") * 1 === slideIndex)[0].column;
1866
- } else {
1867
- targetSlideIndex = swiper2.getSlideIndexByData(newIndex);
1868
- }
1869
- const cols = gridEnabled ? Math.ceil(swiper2.slides.length / swiper2.params.grid.rows) : swiper2.slides.length;
1870
- const {
1871
- centeredSlides
1872
- } = swiper2.params;
1873
- let slidesPerView = swiper2.params.slidesPerView;
1874
- if (slidesPerView === "auto") {
1875
- slidesPerView = swiper2.slidesPerViewDynamic();
1876
- } else {
1877
- slidesPerView = Math.ceil(parseFloat(swiper2.params.slidesPerView, 10));
1878
- if (centeredSlides && slidesPerView % 2 === 0) {
1879
- slidesPerView = slidesPerView + 1;
1880
- }
1881
- }
1882
- let needLoopFix = cols - targetSlideIndex < slidesPerView;
1883
- if (centeredSlides) {
1884
- needLoopFix = needLoopFix || targetSlideIndex < Math.ceil(slidesPerView / 2);
1885
- }
1886
- if (internal && centeredSlides && swiper2.params.slidesPerView !== "auto" && !gridEnabled) {
1887
- needLoopFix = false;
1888
- }
1889
- if (needLoopFix) {
1890
- const direction = centeredSlides ? targetSlideIndex < swiper2.activeIndex ? "prev" : "next" : targetSlideIndex - swiper2.activeIndex - 1 < swiper2.params.slidesPerView ? "next" : "prev";
1891
- swiper2.loopFix({
1892
- direction,
1893
- slideTo: true,
1894
- activeSlideIndex: direction === "next" ? targetSlideIndex + 1 : targetSlideIndex - cols + 1,
1895
- slideRealIndex: direction === "next" ? swiper2.realIndex : void 0
1896
- });
1897
- }
1898
- if (gridEnabled) {
1899
- const slideIndex = newIndex * swiper2.params.grid.rows;
1900
- newIndex = swiper2.slides.filter((slideEl) => slideEl.getAttribute("data-swiper-slide-index") * 1 === slideIndex)[0].column;
1901
- } else {
1902
- newIndex = swiper2.getSlideIndexByData(newIndex);
1903
- }
1904
- }
1905
- }
1906
- requestAnimationFrame(() => {
1907
- swiper2.slideTo(newIndex, speed, runCallbacks, internal);
1908
- });
1909
- return swiper2;
1910
- }
1911
- function slideNext(speed, runCallbacks, internal) {
1912
- if (runCallbacks === void 0) {
1913
- runCallbacks = true;
1914
- }
1915
- const swiper2 = this;
1916
- const {
1917
- enabled,
1918
- params,
1919
- animating
1920
- } = swiper2;
1921
- if (!enabled || swiper2.destroyed) return swiper2;
1922
- if (typeof speed === "undefined") {
1923
- speed = swiper2.params.speed;
1924
- }
1925
- let perGroup = params.slidesPerGroup;
1926
- if (params.slidesPerView === "auto" && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
1927
- perGroup = Math.max(swiper2.slidesPerViewDynamic("current", true), 1);
1928
- }
1929
- const increment = swiper2.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup;
1930
- const isVirtual = swiper2.virtual && params.virtual.enabled;
1931
- if (params.loop) {
1932
- if (animating && !isVirtual && params.loopPreventsSliding) return false;
1933
- swiper2.loopFix({
1934
- direction: "next"
1935
- });
1936
- swiper2._clientLeft = swiper2.wrapperEl.clientLeft;
1937
- if (swiper2.activeIndex === swiper2.slides.length - 1 && params.cssMode) {
1938
- requestAnimationFrame(() => {
1939
- swiper2.slideTo(swiper2.activeIndex + increment, speed, runCallbacks, internal);
1940
- });
1941
- return true;
1942
- }
1943
- }
1944
- if (params.rewind && swiper2.isEnd) {
1945
- return swiper2.slideTo(0, speed, runCallbacks, internal);
1946
- }
1947
- return swiper2.slideTo(swiper2.activeIndex + increment, speed, runCallbacks, internal);
1948
- }
1949
- function slidePrev(speed, runCallbacks, internal) {
1950
- if (runCallbacks === void 0) {
1951
- runCallbacks = true;
1952
- }
1953
- const swiper2 = this;
1954
- const {
1955
- params,
1956
- snapGrid,
1957
- slidesGrid,
1958
- rtlTranslate,
1959
- enabled,
1960
- animating
1961
- } = swiper2;
1962
- if (!enabled || swiper2.destroyed) return swiper2;
1963
- if (typeof speed === "undefined") {
1964
- speed = swiper2.params.speed;
1965
- }
1966
- const isVirtual = swiper2.virtual && params.virtual.enabled;
1967
- if (params.loop) {
1968
- if (animating && !isVirtual && params.loopPreventsSliding) return false;
1969
- swiper2.loopFix({
1970
- direction: "prev"
1971
- });
1972
- swiper2._clientLeft = swiper2.wrapperEl.clientLeft;
1973
- }
1974
- const translate2 = rtlTranslate ? swiper2.translate : -swiper2.translate;
1975
- function normalize(val) {
1976
- if (val < 0) return -Math.floor(Math.abs(val));
1977
- return Math.floor(val);
1978
- }
1979
- const normalizedTranslate = normalize(translate2);
1980
- const normalizedSnapGrid = snapGrid.map((val) => normalize(val));
1981
- let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
1982
- if (typeof prevSnap === "undefined" && params.cssMode) {
1983
- let prevSnapIndex;
1984
- snapGrid.forEach((snap, snapIndex) => {
1985
- if (normalizedTranslate >= snap) {
1986
- prevSnapIndex = snapIndex;
1987
- }
1988
- });
1989
- if (typeof prevSnapIndex !== "undefined") {
1990
- prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
1991
- }
1992
- }
1993
- let prevIndex = 0;
1994
- if (typeof prevSnap !== "undefined") {
1995
- prevIndex = slidesGrid.indexOf(prevSnap);
1996
- if (prevIndex < 0) prevIndex = swiper2.activeIndex - 1;
1997
- if (params.slidesPerView === "auto" && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
1998
- prevIndex = prevIndex - swiper2.slidesPerViewDynamic("previous", true) + 1;
1999
- prevIndex = Math.max(prevIndex, 0);
2000
- }
2001
- }
2002
- if (params.rewind && swiper2.isBeginning) {
2003
- const lastIndex = swiper2.params.virtual && swiper2.params.virtual.enabled && swiper2.virtual ? swiper2.virtual.slides.length - 1 : swiper2.slides.length - 1;
2004
- return swiper2.slideTo(lastIndex, speed, runCallbacks, internal);
2005
- } else if (params.loop && swiper2.activeIndex === 0 && params.cssMode) {
2006
- requestAnimationFrame(() => {
2007
- swiper2.slideTo(prevIndex, speed, runCallbacks, internal);
2008
- });
2009
- return true;
2010
- }
2011
- return swiper2.slideTo(prevIndex, speed, runCallbacks, internal);
2012
- }
2013
- function slideReset(speed, runCallbacks, internal) {
2014
- if (runCallbacks === void 0) {
2015
- runCallbacks = true;
2016
- }
2017
- const swiper2 = this;
2018
- if (swiper2.destroyed) return;
2019
- if (typeof speed === "undefined") {
2020
- speed = swiper2.params.speed;
2021
- }
2022
- return swiper2.slideTo(swiper2.activeIndex, speed, runCallbacks, internal);
2023
- }
2024
- function slideToClosest(speed, runCallbacks, internal, threshold) {
2025
- if (runCallbacks === void 0) {
2026
- runCallbacks = true;
2027
- }
2028
- if (threshold === void 0) {
2029
- threshold = 0.5;
2030
- }
2031
- const swiper2 = this;
2032
- if (swiper2.destroyed) return;
2033
- if (typeof speed === "undefined") {
2034
- speed = swiper2.params.speed;
2035
- }
2036
- let index = swiper2.activeIndex;
2037
- const skip = Math.min(swiper2.params.slidesPerGroupSkip, index);
2038
- const snapIndex = skip + Math.floor((index - skip) / swiper2.params.slidesPerGroup);
2039
- const translate2 = swiper2.rtlTranslate ? swiper2.translate : -swiper2.translate;
2040
- if (translate2 >= swiper2.snapGrid[snapIndex]) {
2041
- const currentSnap = swiper2.snapGrid[snapIndex];
2042
- const nextSnap = swiper2.snapGrid[snapIndex + 1];
2043
- if (translate2 - currentSnap > (nextSnap - currentSnap) * threshold) {
2044
- index += swiper2.params.slidesPerGroup;
2045
- }
2046
- } else {
2047
- const prevSnap = swiper2.snapGrid[snapIndex - 1];
2048
- const currentSnap = swiper2.snapGrid[snapIndex];
2049
- if (translate2 - prevSnap <= (currentSnap - prevSnap) * threshold) {
2050
- index -= swiper2.params.slidesPerGroup;
2051
- }
2052
- }
2053
- index = Math.max(index, 0);
2054
- index = Math.min(index, swiper2.slidesGrid.length - 1);
2055
- return swiper2.slideTo(index, speed, runCallbacks, internal);
2056
- }
2057
- function slideToClickedSlide() {
2058
- const swiper2 = this;
2059
- if (swiper2.destroyed) return;
2060
- const {
2061
- params,
2062
- slidesEl
2063
- } = swiper2;
2064
- const slidesPerView = params.slidesPerView === "auto" ? swiper2.slidesPerViewDynamic() : params.slidesPerView;
2065
- let slideToIndex = swiper2.clickedIndex;
2066
- let realIndex;
2067
- const slideSelector = swiper2.isElement ? `swiper-slide` : `.${params.slideClass}`;
2068
- if (params.loop) {
2069
- if (swiper2.animating) return;
2070
- realIndex = parseInt(swiper2.clickedSlide.getAttribute("data-swiper-slide-index"), 10);
2071
- if (params.centeredSlides) {
2072
- if (slideToIndex < swiper2.loopedSlides - slidesPerView / 2 || slideToIndex > swiper2.slides.length - swiper2.loopedSlides + slidesPerView / 2) {
2073
- swiper2.loopFix();
2074
- slideToIndex = swiper2.getSlideIndex(elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0]);
2075
- nextTick(() => {
2076
- swiper2.slideTo(slideToIndex);
2077
- });
2078
- } else {
2079
- swiper2.slideTo(slideToIndex);
2080
- }
2081
- } else if (slideToIndex > swiper2.slides.length - slidesPerView) {
2082
- swiper2.loopFix();
2083
- slideToIndex = swiper2.getSlideIndex(elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0]);
2084
- nextTick(() => {
2085
- swiper2.slideTo(slideToIndex);
2086
- });
2087
- } else {
2088
- swiper2.slideTo(slideToIndex);
2089
- }
2090
- } else {
2091
- swiper2.slideTo(slideToIndex);
2092
- }
2093
- }
2094
- var slide$1 = {
2095
- slideTo,
2096
- slideToLoop,
2097
- slideNext,
2098
- slidePrev,
2099
- slideReset,
2100
- slideToClosest,
2101
- slideToClickedSlide
2102
- };
2103
- function loopCreate(slideRealIndex) {
2104
- const swiper2 = this;
2105
- const {
2106
- params,
2107
- slidesEl
2108
- } = swiper2;
2109
- if (!params.loop || swiper2.virtual && swiper2.params.virtual.enabled) return;
2110
- const initSlides = () => {
2111
- const slides2 = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
2112
- slides2.forEach((el, index) => {
2113
- el.setAttribute("data-swiper-slide-index", index);
2114
- });
2115
- };
2116
- const gridEnabled = swiper2.grid && params.grid && params.grid.rows > 1;
2117
- const slidesPerGroup = params.slidesPerGroup * (gridEnabled ? params.grid.rows : 1);
2118
- const shouldFillGroup = swiper2.slides.length % slidesPerGroup !== 0;
2119
- const shouldFillGrid = gridEnabled && swiper2.slides.length % params.grid.rows !== 0;
2120
- const addBlankSlides = (amountOfSlides) => {
2121
- for (let i = 0; i < amountOfSlides; i += 1) {
2122
- const slideEl = swiper2.isElement ? createElement("swiper-slide", [params.slideBlankClass]) : createElement("div", [params.slideClass, params.slideBlankClass]);
2123
- swiper2.slidesEl.append(slideEl);
2124
- }
2125
- };
2126
- if (shouldFillGroup) {
2127
- if (params.loopAddBlankSlides) {
2128
- const slidesToAdd = slidesPerGroup - swiper2.slides.length % slidesPerGroup;
2129
- addBlankSlides(slidesToAdd);
2130
- swiper2.recalcSlides();
2131
- swiper2.updateSlides();
2132
- } else {
2133
- showWarning("Swiper Loop Warning: The number of slides is not even to slidesPerGroup, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");
2134
- }
2135
- initSlides();
2136
- } else if (shouldFillGrid) {
2137
- if (params.loopAddBlankSlides) {
2138
- const slidesToAdd = params.grid.rows - swiper2.slides.length % params.grid.rows;
2139
- addBlankSlides(slidesToAdd);
2140
- swiper2.recalcSlides();
2141
- swiper2.updateSlides();
2142
- } else {
2143
- showWarning("Swiper Loop Warning: The number of slides is not even to grid.rows, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");
2144
- }
2145
- initSlides();
2146
- } else {
2147
- initSlides();
2148
- }
2149
- swiper2.loopFix({
2150
- slideRealIndex,
2151
- direction: params.centeredSlides ? void 0 : "next"
2152
- });
2153
- }
2154
- function loopFix(_temp) {
2155
- let {
2156
- slideRealIndex,
2157
- slideTo: slideTo2 = true,
2158
- direction,
2159
- setTranslate: setTranslate2,
2160
- activeSlideIndex,
2161
- byController,
2162
- byMousewheel
2163
- } = _temp === void 0 ? {} : _temp;
2164
- const swiper2 = this;
2165
- if (!swiper2.params.loop) return;
2166
- swiper2.emit("beforeLoopFix");
2167
- const {
2168
- slides: slides2,
2169
- allowSlidePrev,
2170
- allowSlideNext,
2171
- slidesEl,
2172
- params
2173
- } = swiper2;
2174
- const {
2175
- centeredSlides
2176
- } = params;
2177
- swiper2.allowSlidePrev = true;
2178
- swiper2.allowSlideNext = true;
2179
- if (swiper2.virtual && params.virtual.enabled) {
2180
- if (slideTo2) {
2181
- if (!params.centeredSlides && swiper2.snapIndex === 0) {
2182
- swiper2.slideTo(swiper2.virtual.slides.length, 0, false, true);
2183
- } else if (params.centeredSlides && swiper2.snapIndex < params.slidesPerView) {
2184
- swiper2.slideTo(swiper2.virtual.slides.length + swiper2.snapIndex, 0, false, true);
2185
- } else if (swiper2.snapIndex === swiper2.snapGrid.length - 1) {
2186
- swiper2.slideTo(swiper2.virtual.slidesBefore, 0, false, true);
2187
- }
2188
- }
2189
- swiper2.allowSlidePrev = allowSlidePrev;
2190
- swiper2.allowSlideNext = allowSlideNext;
2191
- swiper2.emit("loopFix");
2192
- return;
2193
- }
2194
- let slidesPerView = params.slidesPerView;
2195
- if (slidesPerView === "auto") {
2196
- slidesPerView = swiper2.slidesPerViewDynamic();
2197
- } else {
2198
- slidesPerView = Math.ceil(parseFloat(params.slidesPerView, 10));
2199
- if (centeredSlides && slidesPerView % 2 === 0) {
2200
- slidesPerView = slidesPerView + 1;
2201
- }
2202
- }
2203
- const slidesPerGroup = params.slidesPerGroupAuto ? slidesPerView : params.slidesPerGroup;
2204
- let loopedSlides = slidesPerGroup;
2205
- if (loopedSlides % slidesPerGroup !== 0) {
2206
- loopedSlides += slidesPerGroup - loopedSlides % slidesPerGroup;
2207
- }
2208
- loopedSlides += params.loopAdditionalSlides;
2209
- swiper2.loopedSlides = loopedSlides;
2210
- const gridEnabled = swiper2.grid && params.grid && params.grid.rows > 1;
2211
- if (slides2.length < slidesPerView + loopedSlides) {
2212
- showWarning("Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled and not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters");
2213
- } else if (gridEnabled && params.grid.fill === "row") {
2214
- showWarning("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");
2215
- }
2216
- const prependSlidesIndexes = [];
2217
- const appendSlidesIndexes = [];
2218
- let activeIndex = swiper2.activeIndex;
2219
- if (typeof activeSlideIndex === "undefined") {
2220
- activeSlideIndex = swiper2.getSlideIndex(slides2.filter((el) => el.classList.contains(params.slideActiveClass))[0]);
2221
- } else {
2222
- activeIndex = activeSlideIndex;
2223
- }
2224
- const isNext = direction === "next" || !direction;
2225
- const isPrev = direction === "prev" || !direction;
2226
- let slidesPrepended = 0;
2227
- let slidesAppended = 0;
2228
- const cols = gridEnabled ? Math.ceil(slides2.length / params.grid.rows) : slides2.length;
2229
- const activeColIndex = gridEnabled ? slides2[activeSlideIndex].column : activeSlideIndex;
2230
- const activeColIndexWithShift = activeColIndex + (centeredSlides && typeof setTranslate2 === "undefined" ? -slidesPerView / 2 + 0.5 : 0);
2231
- if (activeColIndexWithShift < loopedSlides) {
2232
- slidesPrepended = Math.max(loopedSlides - activeColIndexWithShift, slidesPerGroup);
2233
- for (let i = 0; i < loopedSlides - activeColIndexWithShift; i += 1) {
2234
- const index = i - Math.floor(i / cols) * cols;
2235
- if (gridEnabled) {
2236
- const colIndexToPrepend = cols - index - 1;
2237
- for (let i2 = slides2.length - 1; i2 >= 0; i2 -= 1) {
2238
- if (slides2[i2].column === colIndexToPrepend) prependSlidesIndexes.push(i2);
2239
- }
2240
- } else {
2241
- prependSlidesIndexes.push(cols - index - 1);
2242
- }
2243
- }
2244
- } else if (activeColIndexWithShift + slidesPerView > cols - loopedSlides) {
2245
- slidesAppended = Math.max(activeColIndexWithShift - (cols - loopedSlides * 2), slidesPerGroup);
2246
- for (let i = 0; i < slidesAppended; i += 1) {
2247
- const index = i - Math.floor(i / cols) * cols;
2248
- if (gridEnabled) {
2249
- slides2.forEach((slide2, slideIndex) => {
2250
- if (slide2.column === index) appendSlidesIndexes.push(slideIndex);
2251
- });
2252
- } else {
2253
- appendSlidesIndexes.push(index);
2254
- }
2255
- }
2256
- }
2257
- swiper2.__preventObserver__ = true;
2258
- requestAnimationFrame(() => {
2259
- swiper2.__preventObserver__ = false;
2260
- });
2261
- if (isPrev) {
2262
- prependSlidesIndexes.forEach((index) => {
2263
- slides2[index].swiperLoopMoveDOM = true;
2264
- slidesEl.prepend(slides2[index]);
2265
- slides2[index].swiperLoopMoveDOM = false;
2266
- });
2267
- }
2268
- if (isNext) {
2269
- appendSlidesIndexes.forEach((index) => {
2270
- slides2[index].swiperLoopMoveDOM = true;
2271
- slidesEl.append(slides2[index]);
2272
- slides2[index].swiperLoopMoveDOM = false;
2273
- });
2274
- }
2275
- swiper2.recalcSlides();
2276
- if (params.slidesPerView === "auto") {
2277
- swiper2.updateSlides();
2278
- } else if (gridEnabled && (prependSlidesIndexes.length > 0 && isPrev || appendSlidesIndexes.length > 0 && isNext)) {
2279
- swiper2.slides.forEach((slide2, slideIndex) => {
2280
- swiper2.grid.updateSlide(slideIndex, slide2, swiper2.slides);
2281
- });
2282
- }
2283
- if (params.watchSlidesProgress) {
2284
- swiper2.updateSlidesOffset();
2285
- }
2286
- if (slideTo2) {
2287
- if (prependSlidesIndexes.length > 0 && isPrev) {
2288
- if (typeof slideRealIndex === "undefined") {
2289
- const currentSlideTranslate = swiper2.slidesGrid[activeIndex];
2290
- const newSlideTranslate = swiper2.slidesGrid[activeIndex + slidesPrepended];
2291
- const diff = newSlideTranslate - currentSlideTranslate;
2292
- if (byMousewheel) {
2293
- swiper2.setTranslate(swiper2.translate - diff);
2294
- } else {
2295
- swiper2.slideTo(activeIndex + Math.ceil(slidesPrepended), 0, false, true);
2296
- if (setTranslate2) {
2297
- swiper2.touchEventsData.startTranslate = swiper2.touchEventsData.startTranslate - diff;
2298
- swiper2.touchEventsData.currentTranslate = swiper2.touchEventsData.currentTranslate - diff;
2299
- }
2300
- }
2301
- } else {
2302
- if (setTranslate2) {
2303
- const shift = gridEnabled ? prependSlidesIndexes.length / params.grid.rows : prependSlidesIndexes.length;
2304
- swiper2.slideTo(swiper2.activeIndex + shift, 0, false, true);
2305
- swiper2.touchEventsData.currentTranslate = swiper2.translate;
2306
- }
2307
- }
2308
- } else if (appendSlidesIndexes.length > 0 && isNext) {
2309
- if (typeof slideRealIndex === "undefined") {
2310
- const currentSlideTranslate = swiper2.slidesGrid[activeIndex];
2311
- const newSlideTranslate = swiper2.slidesGrid[activeIndex - slidesAppended];
2312
- const diff = newSlideTranslate - currentSlideTranslate;
2313
- if (byMousewheel) {
2314
- swiper2.setTranslate(swiper2.translate - diff);
2315
- } else {
2316
- swiper2.slideTo(activeIndex - slidesAppended, 0, false, true);
2317
- if (setTranslate2) {
2318
- swiper2.touchEventsData.startTranslate = swiper2.touchEventsData.startTranslate - diff;
2319
- swiper2.touchEventsData.currentTranslate = swiper2.touchEventsData.currentTranslate - diff;
2320
- }
2321
- }
2322
- } else {
2323
- const shift = gridEnabled ? appendSlidesIndexes.length / params.grid.rows : appendSlidesIndexes.length;
2324
- swiper2.slideTo(swiper2.activeIndex - shift, 0, false, true);
2325
- }
2326
- }
2327
- }
2328
- swiper2.allowSlidePrev = allowSlidePrev;
2329
- swiper2.allowSlideNext = allowSlideNext;
2330
- if (swiper2.controller && swiper2.controller.control && !byController) {
2331
- const loopParams = {
2332
- slideRealIndex,
2333
- direction,
2334
- setTranslate: setTranslate2,
2335
- activeSlideIndex,
2336
- byController: true
2337
- };
2338
- if (Array.isArray(swiper2.controller.control)) {
2339
- swiper2.controller.control.forEach((c) => {
2340
- if (!c.destroyed && c.params.loop) c.loopFix({
2341
- ...loopParams,
2342
- slideTo: c.params.slidesPerView === params.slidesPerView ? slideTo2 : false
2343
- });
2344
- });
2345
- } else if (swiper2.controller.control instanceof swiper2.constructor && swiper2.controller.control.params.loop) {
2346
- swiper2.controller.control.loopFix({
2347
- ...loopParams,
2348
- slideTo: swiper2.controller.control.params.slidesPerView === params.slidesPerView ? slideTo2 : false
2349
- });
2350
- }
2351
- }
2352
- swiper2.emit("loopFix");
2353
- }
2354
- function loopDestroy() {
2355
- const swiper2 = this;
2356
- const {
2357
- params,
2358
- slidesEl
2359
- } = swiper2;
2360
- if (!params.loop || swiper2.virtual && swiper2.params.virtual.enabled) return;
2361
- swiper2.recalcSlides();
2362
- const newSlidesOrder = [];
2363
- swiper2.slides.forEach((slideEl) => {
2364
- const index = typeof slideEl.swiperSlideIndex === "undefined" ? slideEl.getAttribute("data-swiper-slide-index") * 1 : slideEl.swiperSlideIndex;
2365
- newSlidesOrder[index] = slideEl;
2366
- });
2367
- swiper2.slides.forEach((slideEl) => {
2368
- slideEl.removeAttribute("data-swiper-slide-index");
2369
- });
2370
- newSlidesOrder.forEach((slideEl) => {
2371
- slidesEl.append(slideEl);
2372
- });
2373
- swiper2.recalcSlides();
2374
- swiper2.slideTo(swiper2.realIndex, 0);
2375
- }
2376
- var loop = {
2377
- loopCreate,
2378
- loopFix,
2379
- loopDestroy
2380
- };
2381
- function setGrabCursor(moving) {
2382
- const swiper2 = this;
2383
- if (!swiper2.params.simulateTouch || swiper2.params.watchOverflow && swiper2.isLocked || swiper2.params.cssMode) return;
2384
- const el = swiper2.params.touchEventsTarget === "container" ? swiper2.el : swiper2.wrapperEl;
2385
- if (swiper2.isElement) {
2386
- swiper2.__preventObserver__ = true;
2387
- }
2388
- el.style.cursor = "move";
2389
- el.style.cursor = moving ? "grabbing" : "grab";
2390
- if (swiper2.isElement) {
2391
- requestAnimationFrame(() => {
2392
- swiper2.__preventObserver__ = false;
2393
- });
2394
- }
2395
- }
2396
- function unsetGrabCursor() {
2397
- const swiper2 = this;
2398
- if (swiper2.params.watchOverflow && swiper2.isLocked || swiper2.params.cssMode) {
2399
- return;
2400
- }
2401
- if (swiper2.isElement) {
2402
- swiper2.__preventObserver__ = true;
2403
- }
2404
- swiper2[swiper2.params.touchEventsTarget === "container" ? "el" : "wrapperEl"].style.cursor = "";
2405
- if (swiper2.isElement) {
2406
- requestAnimationFrame(() => {
2407
- swiper2.__preventObserver__ = false;
2408
- });
2409
- }
2410
- }
2411
- var grabCursor = {
2412
- setGrabCursor,
2413
- unsetGrabCursor
2414
- };
2415
- function closestElement(selector, base) {
2416
- if (base === void 0) {
2417
- base = this;
2418
- }
2419
- function __closestFrom(el) {
2420
- if (!el || el === getDocument() || el === getWindow()) return null;
2421
- if (el.assignedSlot) el = el.assignedSlot;
2422
- const found = el.closest(selector);
2423
- if (!found && !el.getRootNode) {
2424
- return null;
2425
- }
2426
- return found || __closestFrom(el.getRootNode().host);
2427
- }
2428
- return __closestFrom(base);
2429
- }
2430
- function preventEdgeSwipe(swiper2, event, startX) {
2431
- const window2 = getWindow();
2432
- const {
2433
- params
2434
- } = swiper2;
2435
- const edgeSwipeDetection = params.edgeSwipeDetection;
2436
- const edgeSwipeThreshold = params.edgeSwipeThreshold;
2437
- if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window2.innerWidth - edgeSwipeThreshold)) {
2438
- if (edgeSwipeDetection === "prevent") {
2439
- event.preventDefault();
2440
- return true;
2441
- }
2442
- return false;
2443
- }
2444
- return true;
2445
- }
2446
- function onTouchStart(event) {
2447
- const swiper2 = this;
2448
- const document2 = getDocument();
2449
- let e = event;
2450
- if (e.originalEvent) e = e.originalEvent;
2451
- const data = swiper2.touchEventsData;
2452
- if (e.type === "pointerdown") {
2453
- if (data.pointerId !== null && data.pointerId !== e.pointerId) {
2454
- return;
2455
- }
2456
- data.pointerId = e.pointerId;
2457
- } else if (e.type === "touchstart" && e.targetTouches.length === 1) {
2458
- data.touchId = e.targetTouches[0].identifier;
2459
- }
2460
- if (e.type === "touchstart") {
2461
- preventEdgeSwipe(swiper2, e, e.targetTouches[0].pageX);
2462
- return;
2463
- }
2464
- const {
2465
- params,
2466
- touches,
2467
- enabled
2468
- } = swiper2;
2469
- if (!enabled) return;
2470
- if (!params.simulateTouch && e.pointerType === "mouse") return;
2471
- if (swiper2.animating && params.preventInteractionOnTransition) {
2472
- return;
2473
- }
2474
- if (!swiper2.animating && params.cssMode && params.loop) {
2475
- swiper2.loopFix();
2476
- }
2477
- let targetEl = e.target;
2478
- if (params.touchEventsTarget === "wrapper") {
2479
- if (!swiper2.wrapperEl.contains(targetEl)) return;
2480
- }
2481
- if ("which" in e && e.which === 3) return;
2482
- if ("button" in e && e.button > 0) return;
2483
- if (data.isTouched && data.isMoved) return;
2484
- const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== "";
2485
- const eventPath = e.composedPath ? e.composedPath() : e.path;
2486
- if (swipingClassHasValue && e.target && e.target.shadowRoot && eventPath) {
2487
- targetEl = eventPath[0];
2488
- }
2489
- const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`;
2490
- const isTargetShadow = !!(e.target && e.target.shadowRoot);
2491
- if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, targetEl) : targetEl.closest(noSwipingSelector))) {
2492
- swiper2.allowClick = true;
2493
- return;
2494
- }
2495
- if (params.swipeHandler) {
2496
- if (!targetEl.closest(params.swipeHandler)) return;
2497
- }
2498
- touches.currentX = e.pageX;
2499
- touches.currentY = e.pageY;
2500
- const startX = touches.currentX;
2501
- const startY = touches.currentY;
2502
- if (!preventEdgeSwipe(swiper2, e, startX)) {
2503
- return;
2504
- }
2505
- Object.assign(data, {
2506
- isTouched: true,
2507
- isMoved: false,
2508
- allowTouchCallbacks: true,
2509
- isScrolling: void 0,
2510
- startMoving: void 0
2511
- });
2512
- touches.startX = startX;
2513
- touches.startY = startY;
2514
- data.touchStartTime = now();
2515
- swiper2.allowClick = true;
2516
- swiper2.updateSize();
2517
- swiper2.swipeDirection = void 0;
2518
- if (params.threshold > 0) data.allowThresholdMove = false;
2519
- let preventDefault = true;
2520
- if (targetEl.matches(data.focusableElements)) {
2521
- preventDefault = false;
2522
- if (targetEl.nodeName === "SELECT") {
2523
- data.isTouched = false;
2524
- }
2525
- }
2526
- if (document2.activeElement && document2.activeElement.matches(data.focusableElements) && document2.activeElement !== targetEl) {
2527
- document2.activeElement.blur();
2528
- }
2529
- const shouldPreventDefault = preventDefault && swiper2.allowTouchMove && params.touchStartPreventDefault;
2530
- if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !targetEl.isContentEditable) {
2531
- e.preventDefault();
2532
- }
2533
- if (params.freeMode && params.freeMode.enabled && swiper2.freeMode && swiper2.animating && !params.cssMode) {
2534
- swiper2.freeMode.onTouchStart();
2535
- }
2536
- swiper2.emit("touchStart", e);
2537
- }
2538
- function onTouchMove(event) {
2539
- const document2 = getDocument();
2540
- const swiper2 = this;
2541
- const data = swiper2.touchEventsData;
2542
- const {
2543
- params,
2544
- touches,
2545
- rtlTranslate: rtl,
2546
- enabled
2547
- } = swiper2;
2548
- if (!enabled) return;
2549
- if (!params.simulateTouch && event.pointerType === "mouse") return;
2550
- let e = event;
2551
- if (e.originalEvent) e = e.originalEvent;
2552
- if (e.type === "pointermove") {
2553
- if (data.touchId !== null) return;
2554
- const id = e.pointerId;
2555
- if (id !== data.pointerId) return;
2556
- }
2557
- let targetTouch;
2558
- if (e.type === "touchmove") {
2559
- targetTouch = [...e.changedTouches].filter((t) => t.identifier === data.touchId)[0];
2560
- if (!targetTouch || targetTouch.identifier !== data.touchId) return;
2561
- } else {
2562
- targetTouch = e;
2563
- }
2564
- if (!data.isTouched) {
2565
- if (data.startMoving && data.isScrolling) {
2566
- swiper2.emit("touchMoveOpposite", e);
2567
- }
2568
- return;
2569
- }
2570
- const pageX = targetTouch.pageX;
2571
- const pageY = targetTouch.pageY;
2572
- if (e.preventedByNestedSwiper) {
2573
- touches.startX = pageX;
2574
- touches.startY = pageY;
2575
- return;
2576
- }
2577
- if (!swiper2.allowTouchMove) {
2578
- if (!e.target.matches(data.focusableElements)) {
2579
- swiper2.allowClick = false;
2580
- }
2581
- if (data.isTouched) {
2582
- Object.assign(touches, {
2583
- startX: pageX,
2584
- startY: pageY,
2585
- currentX: pageX,
2586
- currentY: pageY
2587
- });
2588
- data.touchStartTime = now();
2589
- }
2590
- return;
2591
- }
2592
- if (params.touchReleaseOnEdges && !params.loop) {
2593
- if (swiper2.isVertical()) {
2594
- if (pageY < touches.startY && swiper2.translate <= swiper2.maxTranslate() || pageY > touches.startY && swiper2.translate >= swiper2.minTranslate()) {
2595
- data.isTouched = false;
2596
- data.isMoved = false;
2597
- return;
2598
- }
2599
- } else if (pageX < touches.startX && swiper2.translate <= swiper2.maxTranslate() || pageX > touches.startX && swiper2.translate >= swiper2.minTranslate()) {
2600
- return;
2601
- }
2602
- }
2603
- if (document2.activeElement) {
2604
- if (e.target === document2.activeElement && e.target.matches(data.focusableElements)) {
2605
- data.isMoved = true;
2606
- swiper2.allowClick = false;
2607
- return;
2608
- }
2609
- }
2610
- if (data.allowTouchCallbacks) {
2611
- swiper2.emit("touchMove", e);
2612
- }
2613
- touches.previousX = touches.currentX;
2614
- touches.previousY = touches.currentY;
2615
- touches.currentX = pageX;
2616
- touches.currentY = pageY;
2617
- const diffX = touches.currentX - touches.startX;
2618
- const diffY = touches.currentY - touches.startY;
2619
- if (swiper2.params.threshold && Math.sqrt(diffX ** 2 + diffY ** 2) < swiper2.params.threshold) return;
2620
- if (typeof data.isScrolling === "undefined") {
2621
- let touchAngle;
2622
- if (swiper2.isHorizontal() && touches.currentY === touches.startY || swiper2.isVertical() && touches.currentX === touches.startX) {
2623
- data.isScrolling = false;
2624
- } else {
2625
- if (diffX * diffX + diffY * diffY >= 25) {
2626
- touchAngle = Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180 / Math.PI;
2627
- data.isScrolling = swiper2.isHorizontal() ? touchAngle > params.touchAngle : 90 - touchAngle > params.touchAngle;
2628
- }
2629
- }
2630
- }
2631
- if (data.isScrolling) {
2632
- swiper2.emit("touchMoveOpposite", e);
2633
- }
2634
- if (typeof data.startMoving === "undefined") {
2635
- if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) {
2636
- data.startMoving = true;
2637
- }
2638
- }
2639
- if (data.isScrolling || e.type === "touchmove" && data.preventTouchMoveFromPointerMove) {
2640
- data.isTouched = false;
2641
- return;
2642
- }
2643
- if (!data.startMoving) {
2644
- return;
2645
- }
2646
- swiper2.allowClick = false;
2647
- if (!params.cssMode && e.cancelable) {
2648
- e.preventDefault();
2649
- }
2650
- if (params.touchMoveStopPropagation && !params.nested) {
2651
- e.stopPropagation();
2652
- }
2653
- let diff = swiper2.isHorizontal() ? diffX : diffY;
2654
- let touchesDiff = swiper2.isHorizontal() ? touches.currentX - touches.previousX : touches.currentY - touches.previousY;
2655
- if (params.oneWayMovement) {
2656
- diff = Math.abs(diff) * (rtl ? 1 : -1);
2657
- touchesDiff = Math.abs(touchesDiff) * (rtl ? 1 : -1);
2658
- }
2659
- touches.diff = diff;
2660
- diff *= params.touchRatio;
2661
- if (rtl) {
2662
- diff = -diff;
2663
- touchesDiff = -touchesDiff;
2664
- }
2665
- const prevTouchesDirection = swiper2.touchesDirection;
2666
- swiper2.swipeDirection = diff > 0 ? "prev" : "next";
2667
- swiper2.touchesDirection = touchesDiff > 0 ? "prev" : "next";
2668
- const isLoop = swiper2.params.loop && !params.cssMode;
2669
- const allowLoopFix = swiper2.touchesDirection === "next" && swiper2.allowSlideNext || swiper2.touchesDirection === "prev" && swiper2.allowSlidePrev;
2670
- if (!data.isMoved) {
2671
- if (isLoop && allowLoopFix) {
2672
- swiper2.loopFix({
2673
- direction: swiper2.swipeDirection
2674
- });
2675
- }
2676
- data.startTranslate = swiper2.getTranslate();
2677
- swiper2.setTransition(0);
2678
- if (swiper2.animating) {
2679
- const evt = new window.CustomEvent("transitionend", {
2680
- bubbles: true,
2681
- cancelable: true,
2682
- detail: {
2683
- bySwiperTouchMove: true
2684
- }
2685
- });
2686
- swiper2.wrapperEl.dispatchEvent(evt);
2687
- }
2688
- data.allowMomentumBounce = false;
2689
- if (params.grabCursor && (swiper2.allowSlideNext === true || swiper2.allowSlidePrev === true)) {
2690
- swiper2.setGrabCursor(true);
2691
- }
2692
- swiper2.emit("sliderFirstMove", e);
2693
- }
2694
- let loopFixed;
2695
- (/* @__PURE__ */ new Date()).getTime();
2696
- if (data.isMoved && data.allowThresholdMove && prevTouchesDirection !== swiper2.touchesDirection && isLoop && allowLoopFix && Math.abs(diff) >= 1) {
2697
- Object.assign(touches, {
2698
- startX: pageX,
2699
- startY: pageY,
2700
- currentX: pageX,
2701
- currentY: pageY,
2702
- startTranslate: data.currentTranslate
2703
- });
2704
- data.loopSwapReset = true;
2705
- data.startTranslate = data.currentTranslate;
2706
- return;
2707
- }
2708
- swiper2.emit("sliderMove", e);
2709
- data.isMoved = true;
2710
- data.currentTranslate = diff + data.startTranslate;
2711
- let disableParentSwiper = true;
2712
- let resistanceRatio = params.resistanceRatio;
2713
- if (params.touchReleaseOnEdges) {
2714
- resistanceRatio = 0;
2715
- }
2716
- if (diff > 0) {
2717
- if (isLoop && allowLoopFix && !loopFixed && data.allowThresholdMove && data.currentTranslate > (params.centeredSlides ? swiper2.minTranslate() - swiper2.slidesSizesGrid[swiper2.activeIndex + 1] : swiper2.minTranslate())) {
2718
- swiper2.loopFix({
2719
- direction: "prev",
2720
- setTranslate: true,
2721
- activeSlideIndex: 0
2722
- });
2723
- }
2724
- if (data.currentTranslate > swiper2.minTranslate()) {
2725
- disableParentSwiper = false;
2726
- if (params.resistance) {
2727
- data.currentTranslate = swiper2.minTranslate() - 1 + (-swiper2.minTranslate() + data.startTranslate + diff) ** resistanceRatio;
2728
- }
2729
- }
2730
- } else if (diff < 0) {
2731
- if (isLoop && allowLoopFix && !loopFixed && data.allowThresholdMove && data.currentTranslate < (params.centeredSlides ? swiper2.maxTranslate() + swiper2.slidesSizesGrid[swiper2.slidesSizesGrid.length - 1] : swiper2.maxTranslate())) {
2732
- swiper2.loopFix({
2733
- direction: "next",
2734
- setTranslate: true,
2735
- activeSlideIndex: swiper2.slides.length - (params.slidesPerView === "auto" ? swiper2.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10)))
2736
- });
2737
- }
2738
- if (data.currentTranslate < swiper2.maxTranslate()) {
2739
- disableParentSwiper = false;
2740
- if (params.resistance) {
2741
- data.currentTranslate = swiper2.maxTranslate() + 1 - (swiper2.maxTranslate() - data.startTranslate - diff) ** resistanceRatio;
2742
- }
2743
- }
2744
- }
2745
- if (disableParentSwiper) {
2746
- e.preventedByNestedSwiper = true;
2747
- }
2748
- if (!swiper2.allowSlideNext && swiper2.swipeDirection === "next" && data.currentTranslate < data.startTranslate) {
2749
- data.currentTranslate = data.startTranslate;
2750
- }
2751
- if (!swiper2.allowSlidePrev && swiper2.swipeDirection === "prev" && data.currentTranslate > data.startTranslate) {
2752
- data.currentTranslate = data.startTranslate;
2753
- }
2754
- if (!swiper2.allowSlidePrev && !swiper2.allowSlideNext) {
2755
- data.currentTranslate = data.startTranslate;
2756
- }
2757
- if (params.threshold > 0) {
2758
- if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
2759
- if (!data.allowThresholdMove) {
2760
- data.allowThresholdMove = true;
2761
- touches.startX = touches.currentX;
2762
- touches.startY = touches.currentY;
2763
- data.currentTranslate = data.startTranslate;
2764
- touches.diff = swiper2.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches.startY;
2765
- return;
2766
- }
2767
- } else {
2768
- data.currentTranslate = data.startTranslate;
2769
- return;
2770
- }
2771
- }
2772
- if (!params.followFinger || params.cssMode) return;
2773
- if (params.freeMode && params.freeMode.enabled && swiper2.freeMode || params.watchSlidesProgress) {
2774
- swiper2.updateActiveIndex();
2775
- swiper2.updateSlidesClasses();
2776
- }
2777
- if (params.freeMode && params.freeMode.enabled && swiper2.freeMode) {
2778
- swiper2.freeMode.onTouchMove();
2779
- }
2780
- swiper2.updateProgress(data.currentTranslate);
2781
- swiper2.setTranslate(data.currentTranslate);
2782
- }
2783
- function onTouchEnd(event) {
2784
- const swiper2 = this;
2785
- const data = swiper2.touchEventsData;
2786
- let e = event;
2787
- if (e.originalEvent) e = e.originalEvent;
2788
- let targetTouch;
2789
- const isTouchEvent = e.type === "touchend" || e.type === "touchcancel";
2790
- if (!isTouchEvent) {
2791
- if (data.touchId !== null) return;
2792
- if (e.pointerId !== data.pointerId) return;
2793
- targetTouch = e;
2794
- } else {
2795
- targetTouch = [...e.changedTouches].filter((t) => t.identifier === data.touchId)[0];
2796
- if (!targetTouch || targetTouch.identifier !== data.touchId) return;
2797
- }
2798
- if (["pointercancel", "pointerout", "pointerleave", "contextmenu"].includes(e.type)) {
2799
- const proceed = ["pointercancel", "contextmenu"].includes(e.type) && (swiper2.browser.isSafari || swiper2.browser.isWebView);
2800
- if (!proceed) {
2801
- return;
2802
- }
2803
- }
2804
- data.pointerId = null;
2805
- data.touchId = null;
2806
- const {
2807
- params,
2808
- touches,
2809
- rtlTranslate: rtl,
2810
- slidesGrid,
2811
- enabled
2812
- } = swiper2;
2813
- if (!enabled) return;
2814
- if (!params.simulateTouch && e.pointerType === "mouse") return;
2815
- if (data.allowTouchCallbacks) {
2816
- swiper2.emit("touchEnd", e);
2817
- }
2818
- data.allowTouchCallbacks = false;
2819
- if (!data.isTouched) {
2820
- if (data.isMoved && params.grabCursor) {
2821
- swiper2.setGrabCursor(false);
2822
- }
2823
- data.isMoved = false;
2824
- data.startMoving = false;
2825
- return;
2826
- }
2827
- if (params.grabCursor && data.isMoved && data.isTouched && (swiper2.allowSlideNext === true || swiper2.allowSlidePrev === true)) {
2828
- swiper2.setGrabCursor(false);
2829
- }
2830
- const touchEndTime = now();
2831
- const timeDiff = touchEndTime - data.touchStartTime;
2832
- if (swiper2.allowClick) {
2833
- const pathTree = e.path || e.composedPath && e.composedPath();
2834
- swiper2.updateClickedSlide(pathTree && pathTree[0] || e.target, pathTree);
2835
- swiper2.emit("tap click", e);
2836
- if (timeDiff < 300 && touchEndTime - data.lastClickTime < 300) {
2837
- swiper2.emit("doubleTap doubleClick", e);
2838
- }
2839
- }
2840
- data.lastClickTime = now();
2841
- nextTick(() => {
2842
- if (!swiper2.destroyed) swiper2.allowClick = true;
2843
- });
2844
- if (!data.isTouched || !data.isMoved || !swiper2.swipeDirection || touches.diff === 0 && !data.loopSwapReset || data.currentTranslate === data.startTranslate && !data.loopSwapReset) {
2845
- data.isTouched = false;
2846
- data.isMoved = false;
2847
- data.startMoving = false;
2848
- return;
2849
- }
2850
- data.isTouched = false;
2851
- data.isMoved = false;
2852
- data.startMoving = false;
2853
- let currentPos;
2854
- if (params.followFinger) {
2855
- currentPos = rtl ? swiper2.translate : -swiper2.translate;
2856
- } else {
2857
- currentPos = -data.currentTranslate;
2858
- }
2859
- if (params.cssMode) {
2860
- return;
2861
- }
2862
- if (params.freeMode && params.freeMode.enabled) {
2863
- swiper2.freeMode.onTouchEnd({
2864
- currentPos
2865
- });
2866
- return;
2867
- }
2868
- const swipeToLast = currentPos >= -swiper2.maxTranslate() && !swiper2.params.loop;
2869
- let stopIndex = 0;
2870
- let groupSize = swiper2.slidesSizesGrid[0];
2871
- for (let i = 0; i < slidesGrid.length; i += i < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup) {
2872
- const increment2 = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
2873
- if (typeof slidesGrid[i + increment2] !== "undefined") {
2874
- if (swipeToLast || currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + increment2]) {
2875
- stopIndex = i;
2876
- groupSize = slidesGrid[i + increment2] - slidesGrid[i];
2877
- }
2878
- } else if (swipeToLast || currentPos >= slidesGrid[i]) {
2879
- stopIndex = i;
2880
- groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2];
2881
- }
2882
- }
2883
- let rewindFirstIndex = null;
2884
- let rewindLastIndex = null;
2885
- if (params.rewind) {
2886
- if (swiper2.isBeginning) {
2887
- rewindLastIndex = params.virtual && params.virtual.enabled && swiper2.virtual ? swiper2.virtual.slides.length - 1 : swiper2.slides.length - 1;
2888
- } else if (swiper2.isEnd) {
2889
- rewindFirstIndex = 0;
2890
- }
2891
- }
2892
- const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
2893
- const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
2894
- if (timeDiff > params.longSwipesMs) {
2895
- if (!params.longSwipes) {
2896
- swiper2.slideTo(swiper2.activeIndex);
2897
- return;
2898
- }
2899
- if (swiper2.swipeDirection === "next") {
2900
- if (ratio >= params.longSwipesRatio) swiper2.slideTo(params.rewind && swiper2.isEnd ? rewindFirstIndex : stopIndex + increment);
2901
- else swiper2.slideTo(stopIndex);
2902
- }
2903
- if (swiper2.swipeDirection === "prev") {
2904
- if (ratio > 1 - params.longSwipesRatio) {
2905
- swiper2.slideTo(stopIndex + increment);
2906
- } else if (rewindLastIndex !== null && ratio < 0 && Math.abs(ratio) > params.longSwipesRatio) {
2907
- swiper2.slideTo(rewindLastIndex);
2908
- } else {
2909
- swiper2.slideTo(stopIndex);
2910
- }
2911
- }
2912
- } else {
2913
- if (!params.shortSwipes) {
2914
- swiper2.slideTo(swiper2.activeIndex);
2915
- return;
2916
- }
2917
- const isNavButtonTarget = swiper2.navigation && (e.target === swiper2.navigation.nextEl || e.target === swiper2.navigation.prevEl);
2918
- if (!isNavButtonTarget) {
2919
- if (swiper2.swipeDirection === "next") {
2920
- swiper2.slideTo(rewindFirstIndex !== null ? rewindFirstIndex : stopIndex + increment);
2921
- }
2922
- if (swiper2.swipeDirection === "prev") {
2923
- swiper2.slideTo(rewindLastIndex !== null ? rewindLastIndex : stopIndex);
2924
- }
2925
- } else if (e.target === swiper2.navigation.nextEl) {
2926
- swiper2.slideTo(stopIndex + increment);
2927
- } else {
2928
- swiper2.slideTo(stopIndex);
2929
- }
2930
- }
2931
- }
2932
- function onResize() {
2933
- const swiper2 = this;
2934
- const {
2935
- params,
2936
- el
2937
- } = swiper2;
2938
- if (el && el.offsetWidth === 0) return;
2939
- if (params.breakpoints) {
2940
- swiper2.setBreakpoint();
2941
- }
2942
- const {
2943
- allowSlideNext,
2944
- allowSlidePrev,
2945
- snapGrid
2946
- } = swiper2;
2947
- const isVirtual = swiper2.virtual && swiper2.params.virtual.enabled;
2948
- swiper2.allowSlideNext = true;
2949
- swiper2.allowSlidePrev = true;
2950
- swiper2.updateSize();
2951
- swiper2.updateSlides();
2952
- swiper2.updateSlidesClasses();
2953
- const isVirtualLoop = isVirtual && params.loop;
2954
- if ((params.slidesPerView === "auto" || params.slidesPerView > 1) && swiper2.isEnd && !swiper2.isBeginning && !swiper2.params.centeredSlides && !isVirtualLoop) {
2955
- swiper2.slideTo(swiper2.slides.length - 1, 0, false, true);
2956
- } else {
2957
- if (swiper2.params.loop && !isVirtual) {
2958
- swiper2.slideToLoop(swiper2.realIndex, 0, false, true);
2959
- } else {
2960
- swiper2.slideTo(swiper2.activeIndex, 0, false, true);
2961
- }
2962
- }
2963
- if (swiper2.autoplay && swiper2.autoplay.running && swiper2.autoplay.paused) {
2964
- clearTimeout(swiper2.autoplay.resizeTimeout);
2965
- swiper2.autoplay.resizeTimeout = setTimeout(() => {
2966
- if (swiper2.autoplay && swiper2.autoplay.running && swiper2.autoplay.paused) {
2967
- swiper2.autoplay.resume();
2968
- }
2969
- }, 500);
2970
- }
2971
- swiper2.allowSlidePrev = allowSlidePrev;
2972
- swiper2.allowSlideNext = allowSlideNext;
2973
- if (swiper2.params.watchOverflow && snapGrid !== swiper2.snapGrid) {
2974
- swiper2.checkOverflow();
2975
- }
2976
- }
2977
- function onClick(e) {
2978
- const swiper2 = this;
2979
- if (!swiper2.enabled) return;
2980
- if (!swiper2.allowClick) {
2981
- if (swiper2.params.preventClicks) e.preventDefault();
2982
- if (swiper2.params.preventClicksPropagation && swiper2.animating) {
2983
- e.stopPropagation();
2984
- e.stopImmediatePropagation();
2985
- }
2986
- }
2987
- }
2988
- function onScroll() {
2989
- const swiper2 = this;
2990
- const {
2991
- wrapperEl,
2992
- rtlTranslate,
2993
- enabled
2994
- } = swiper2;
2995
- if (!enabled) return;
2996
- swiper2.previousTranslate = swiper2.translate;
2997
- if (swiper2.isHorizontal()) {
2998
- swiper2.translate = -wrapperEl.scrollLeft;
2999
- } else {
3000
- swiper2.translate = -wrapperEl.scrollTop;
3001
- }
3002
- if (swiper2.translate === 0) swiper2.translate = 0;
3003
- swiper2.updateActiveIndex();
3004
- swiper2.updateSlidesClasses();
3005
- let newProgress;
3006
- const translatesDiff = swiper2.maxTranslate() - swiper2.minTranslate();
3007
- if (translatesDiff === 0) {
3008
- newProgress = 0;
3009
- } else {
3010
- newProgress = (swiper2.translate - swiper2.minTranslate()) / translatesDiff;
3011
- }
3012
- if (newProgress !== swiper2.progress) {
3013
- swiper2.updateProgress(rtlTranslate ? -swiper2.translate : swiper2.translate);
3014
- }
3015
- swiper2.emit("setTranslate", swiper2.translate, false);
3016
- }
3017
- function onLoad(e) {
3018
- const swiper2 = this;
3019
- processLazyPreloader(swiper2, e.target);
3020
- if (swiper2.params.cssMode || swiper2.params.slidesPerView !== "auto" && !swiper2.params.autoHeight) {
3021
- return;
3022
- }
3023
- swiper2.update();
3024
- }
3025
- function onDocumentTouchStart() {
3026
- const swiper2 = this;
3027
- if (swiper2.documentTouchHandlerProceeded) return;
3028
- swiper2.documentTouchHandlerProceeded = true;
3029
- if (swiper2.params.touchReleaseOnEdges) {
3030
- swiper2.el.style.touchAction = "auto";
3031
- }
3032
- }
3033
- const events = (swiper2, method) => {
3034
- const document2 = getDocument();
3035
- const {
3036
- params,
3037
- el,
3038
- wrapperEl,
3039
- device
3040
- } = swiper2;
3041
- const capture = !!params.nested;
3042
- const domMethod = method === "on" ? "addEventListener" : "removeEventListener";
3043
- const swiperMethod = method;
3044
- if (!el || typeof el === "string") return;
3045
- document2[domMethod]("touchstart", swiper2.onDocumentTouchStart, {
3046
- passive: false,
3047
- capture
3048
- });
3049
- el[domMethod]("touchstart", swiper2.onTouchStart, {
3050
- passive: false
3051
- });
3052
- el[domMethod]("pointerdown", swiper2.onTouchStart, {
3053
- passive: false
3054
- });
3055
- document2[domMethod]("touchmove", swiper2.onTouchMove, {
3056
- passive: false,
3057
- capture
3058
- });
3059
- document2[domMethod]("pointermove", swiper2.onTouchMove, {
3060
- passive: false,
3061
- capture
3062
- });
3063
- document2[domMethod]("touchend", swiper2.onTouchEnd, {
3064
- passive: true
3065
- });
3066
- document2[domMethod]("pointerup", swiper2.onTouchEnd, {
3067
- passive: true
3068
- });
3069
- document2[domMethod]("pointercancel", swiper2.onTouchEnd, {
3070
- passive: true
3071
- });
3072
- document2[domMethod]("touchcancel", swiper2.onTouchEnd, {
3073
- passive: true
3074
- });
3075
- document2[domMethod]("pointerout", swiper2.onTouchEnd, {
3076
- passive: true
3077
- });
3078
- document2[domMethod]("pointerleave", swiper2.onTouchEnd, {
3079
- passive: true
3080
- });
3081
- document2[domMethod]("contextmenu", swiper2.onTouchEnd, {
3082
- passive: true
3083
- });
3084
- if (params.preventClicks || params.preventClicksPropagation) {
3085
- el[domMethod]("click", swiper2.onClick, true);
3086
- }
3087
- if (params.cssMode) {
3088
- wrapperEl[domMethod]("scroll", swiper2.onScroll);
3089
- }
3090
- if (params.updateOnWindowResize) {
3091
- swiper2[swiperMethod](device.ios || device.android ? "resize orientationchange observerUpdate" : "resize observerUpdate", onResize, true);
3092
- } else {
3093
- swiper2[swiperMethod]("observerUpdate", onResize, true);
3094
- }
3095
- el[domMethod]("load", swiper2.onLoad, {
3096
- capture: true
3097
- });
3098
- };
3099
- function attachEvents() {
3100
- const swiper2 = this;
3101
- const {
3102
- params
3103
- } = swiper2;
3104
- swiper2.onTouchStart = onTouchStart.bind(swiper2);
3105
- swiper2.onTouchMove = onTouchMove.bind(swiper2);
3106
- swiper2.onTouchEnd = onTouchEnd.bind(swiper2);
3107
- swiper2.onDocumentTouchStart = onDocumentTouchStart.bind(swiper2);
3108
- if (params.cssMode) {
3109
- swiper2.onScroll = onScroll.bind(swiper2);
3110
- }
3111
- swiper2.onClick = onClick.bind(swiper2);
3112
- swiper2.onLoad = onLoad.bind(swiper2);
3113
- events(swiper2, "on");
3114
- }
3115
- function detachEvents() {
3116
- const swiper2 = this;
3117
- events(swiper2, "off");
3118
- }
3119
- var events$1 = {
3120
- attachEvents,
3121
- detachEvents
3122
- };
3123
- const isGridEnabled = (swiper2, params) => {
3124
- return swiper2.grid && params.grid && params.grid.rows > 1;
3125
- };
3126
- function setBreakpoint() {
3127
- const swiper2 = this;
3128
- const {
3129
- realIndex,
3130
- initialized,
3131
- params,
3132
- el
3133
- } = swiper2;
3134
- const breakpoints2 = params.breakpoints;
3135
- if (!breakpoints2 || breakpoints2 && Object.keys(breakpoints2).length === 0) return;
3136
- const breakpoint = swiper2.getBreakpoint(breakpoints2, swiper2.params.breakpointsBase, swiper2.el);
3137
- if (!breakpoint || swiper2.currentBreakpoint === breakpoint) return;
3138
- const breakpointOnlyParams = breakpoint in breakpoints2 ? breakpoints2[breakpoint] : void 0;
3139
- const breakpointParams = breakpointOnlyParams || swiper2.originalParams;
3140
- const wasMultiRow = isGridEnabled(swiper2, params);
3141
- const isMultiRow = isGridEnabled(swiper2, breakpointParams);
3142
- const wasGrabCursor = swiper2.params.grabCursor;
3143
- const isGrabCursor = breakpointParams.grabCursor;
3144
- const wasEnabled = params.enabled;
3145
- if (wasMultiRow && !isMultiRow) {
3146
- el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`);
3147
- swiper2.emitContainerClasses();
3148
- } else if (!wasMultiRow && isMultiRow) {
3149
- el.classList.add(`${params.containerModifierClass}grid`);
3150
- if (breakpointParams.grid.fill && breakpointParams.grid.fill === "column" || !breakpointParams.grid.fill && params.grid.fill === "column") {
3151
- el.classList.add(`${params.containerModifierClass}grid-column`);
3152
- }
3153
- swiper2.emitContainerClasses();
3154
- }
3155
- if (wasGrabCursor && !isGrabCursor) {
3156
- swiper2.unsetGrabCursor();
3157
- } else if (!wasGrabCursor && isGrabCursor) {
3158
- swiper2.setGrabCursor();
3159
- }
3160
- ["navigation", "pagination", "scrollbar"].forEach((prop) => {
3161
- if (typeof breakpointParams[prop] === "undefined") return;
3162
- const wasModuleEnabled = params[prop] && params[prop].enabled;
3163
- const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
3164
- if (wasModuleEnabled && !isModuleEnabled) {
3165
- swiper2[prop].disable();
3166
- }
3167
- if (!wasModuleEnabled && isModuleEnabled) {
3168
- swiper2[prop].enable();
3169
- }
3170
- });
3171
- const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction;
3172
- const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged);
3173
- const wasLoop = params.loop;
3174
- if (directionChanged && initialized) {
3175
- swiper2.changeDirection();
3176
- }
3177
- extend$1(swiper2.params, breakpointParams);
3178
- const isEnabled = swiper2.params.enabled;
3179
- const hasLoop = swiper2.params.loop;
3180
- Object.assign(swiper2, {
3181
- allowTouchMove: swiper2.params.allowTouchMove,
3182
- allowSlideNext: swiper2.params.allowSlideNext,
3183
- allowSlidePrev: swiper2.params.allowSlidePrev
3184
- });
3185
- if (wasEnabled && !isEnabled) {
3186
- swiper2.disable();
3187
- } else if (!wasEnabled && isEnabled) {
3188
- swiper2.enable();
3189
- }
3190
- swiper2.currentBreakpoint = breakpoint;
3191
- swiper2.emit("_beforeBreakpoint", breakpointParams);
3192
- if (initialized) {
3193
- if (needsReLoop) {
3194
- swiper2.loopDestroy();
3195
- swiper2.loopCreate(realIndex);
3196
- swiper2.updateSlides();
3197
- } else if (!wasLoop && hasLoop) {
3198
- swiper2.loopCreate(realIndex);
3199
- swiper2.updateSlides();
3200
- } else if (wasLoop && !hasLoop) {
3201
- swiper2.loopDestroy();
3202
- }
3203
- }
3204
- swiper2.emit("breakpoint", breakpointParams);
3205
- }
3206
- function getBreakpoint(breakpoints2, base, containerEl) {
3207
- if (base === void 0) {
3208
- base = "window";
3209
- }
3210
- if (!breakpoints2 || base === "container" && !containerEl) return void 0;
3211
- let breakpoint = false;
3212
- const window2 = getWindow();
3213
- const currentHeight = base === "window" ? window2.innerHeight : containerEl.clientHeight;
3214
- const points = Object.keys(breakpoints2).map((point) => {
3215
- if (typeof point === "string" && point.indexOf("@") === 0) {
3216
- const minRatio = parseFloat(point.substr(1));
3217
- const value = currentHeight * minRatio;
3218
- return {
3219
- value,
3220
- point
3221
- };
3222
- }
3223
- return {
3224
- value: point,
3225
- point
3226
- };
3227
- });
3228
- points.sort((a, b) => parseInt(a.value, 10) - parseInt(b.value, 10));
3229
- for (let i = 0; i < points.length; i += 1) {
3230
- const {
3231
- point,
3232
- value
3233
- } = points[i];
3234
- if (base === "window") {
3235
- if (window2.matchMedia(`(min-width: ${value}px)`).matches) {
3236
- breakpoint = point;
3237
- }
3238
- } else if (value <= containerEl.clientWidth) {
3239
- breakpoint = point;
3240
- }
3241
- }
3242
- return breakpoint || "max";
3243
- }
3244
- var breakpoints = {
3245
- setBreakpoint,
3246
- getBreakpoint
3247
- };
3248
- function prepareClasses(entries, prefix) {
3249
- const resultClasses = [];
3250
- entries.forEach((item) => {
3251
- if (typeof item === "object") {
3252
- Object.keys(item).forEach((classNames2) => {
3253
- if (item[classNames2]) {
3254
- resultClasses.push(prefix + classNames2);
3255
- }
3256
- });
3257
- } else if (typeof item === "string") {
3258
- resultClasses.push(prefix + item);
3259
- }
3260
- });
3261
- return resultClasses;
3262
- }
3263
- function addClasses() {
3264
- const swiper2 = this;
3265
- const {
3266
- classNames: classNames2,
3267
- params,
3268
- rtl,
3269
- el,
3270
- device
3271
- } = swiper2;
3272
- const suffixes = prepareClasses(["initialized", params.direction, {
3273
- "free-mode": swiper2.params.freeMode && params.freeMode.enabled
3274
- }, {
3275
- "autoheight": params.autoHeight
3276
- }, {
3277
- "rtl": rtl
3278
- }, {
3279
- "grid": params.grid && params.grid.rows > 1
3280
- }, {
3281
- "grid-column": params.grid && params.grid.rows > 1 && params.grid.fill === "column"
3282
- }, {
3283
- "android": device.android
3284
- }, {
3285
- "ios": device.ios
3286
- }, {
3287
- "css-mode": params.cssMode
3288
- }, {
3289
- "centered": params.cssMode && params.centeredSlides
3290
- }, {
3291
- "watch-progress": params.watchSlidesProgress
3292
- }], params.containerModifierClass);
3293
- classNames2.push(...suffixes);
3294
- el.classList.add(...classNames2);
3295
- swiper2.emitContainerClasses();
3296
- }
3297
- function removeClasses() {
3298
- const swiper2 = this;
3299
- const {
3300
- el,
3301
- classNames: classNames2
3302
- } = swiper2;
3303
- if (!el || typeof el === "string") return;
3304
- el.classList.remove(...classNames2);
3305
- swiper2.emitContainerClasses();
3306
- }
3307
- var classes = {
3308
- addClasses,
3309
- removeClasses
3310
- };
3311
- function checkOverflow() {
3312
- const swiper2 = this;
3313
- const {
3314
- isLocked: wasLocked,
3315
- params
3316
- } = swiper2;
3317
- const {
3318
- slidesOffsetBefore
3319
- } = params;
3320
- if (slidesOffsetBefore) {
3321
- const lastSlideIndex = swiper2.slides.length - 1;
3322
- const lastSlideRightEdge = swiper2.slidesGrid[lastSlideIndex] + swiper2.slidesSizesGrid[lastSlideIndex] + slidesOffsetBefore * 2;
3323
- swiper2.isLocked = swiper2.size > lastSlideRightEdge;
3324
- } else {
3325
- swiper2.isLocked = swiper2.snapGrid.length === 1;
3326
- }
3327
- if (params.allowSlideNext === true) {
3328
- swiper2.allowSlideNext = !swiper2.isLocked;
3329
- }
3330
- if (params.allowSlidePrev === true) {
3331
- swiper2.allowSlidePrev = !swiper2.isLocked;
3332
- }
3333
- if (wasLocked && wasLocked !== swiper2.isLocked) {
3334
- swiper2.isEnd = false;
3335
- }
3336
- if (wasLocked !== swiper2.isLocked) {
3337
- swiper2.emit(swiper2.isLocked ? "lock" : "unlock");
3338
- }
3339
- }
3340
- var checkOverflow$1 = {
3341
- checkOverflow
3342
- };
3343
- var defaults = {
3344
- init: true,
3345
- direction: "horizontal",
3346
- oneWayMovement: false,
3347
- swiperElementNodeName: "SWIPER-CONTAINER",
3348
- touchEventsTarget: "wrapper",
3349
- initialSlide: 0,
3350
- speed: 300,
3351
- cssMode: false,
3352
- updateOnWindowResize: true,
3353
- resizeObserver: true,
3354
- nested: false,
3355
- createElements: false,
3356
- eventsPrefix: "swiper",
3357
- enabled: true,
3358
- focusableElements: "input, select, option, textarea, button, video, label",
3359
- // Overrides
3360
- width: null,
3361
- height: null,
3362
- //
3363
- preventInteractionOnTransition: false,
3364
- // ssr
3365
- userAgent: null,
3366
- url: null,
3367
- // To support iOS's swipe-to-go-back gesture (when being used in-app).
3368
- edgeSwipeDetection: false,
3369
- edgeSwipeThreshold: 20,
3370
- // Autoheight
3371
- autoHeight: false,
3372
- // Set wrapper width
3373
- setWrapperSize: false,
3374
- // Virtual Translate
3375
- virtualTranslate: false,
3376
- // Effects
3377
- effect: "slide",
3378
- // 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
3379
- // Breakpoints
3380
- breakpoints: void 0,
3381
- breakpointsBase: "window",
3382
- // Slides grid
3383
- spaceBetween: 0,
3384
- slidesPerView: 1,
3385
- slidesPerGroup: 1,
3386
- slidesPerGroupSkip: 0,
3387
- slidesPerGroupAuto: false,
3388
- centeredSlides: false,
3389
- centeredSlidesBounds: false,
3390
- slidesOffsetBefore: 0,
3391
- // in px
3392
- slidesOffsetAfter: 0,
3393
- // in px
3394
- normalizeSlideIndex: true,
3395
- centerInsufficientSlides: false,
3396
- // Disable swiper and hide navigation when container not overflow
3397
- watchOverflow: true,
3398
- // Round length
3399
- roundLengths: false,
3400
- // Touches
3401
- touchRatio: 1,
3402
- touchAngle: 45,
3403
- simulateTouch: true,
3404
- shortSwipes: true,
3405
- longSwipes: true,
3406
- longSwipesRatio: 0.5,
3407
- longSwipesMs: 300,
3408
- followFinger: true,
3409
- allowTouchMove: true,
3410
- threshold: 5,
3411
- touchMoveStopPropagation: false,
3412
- touchStartPreventDefault: true,
3413
- touchStartForcePreventDefault: false,
3414
- touchReleaseOnEdges: false,
3415
- // Unique Navigation Elements
3416
- uniqueNavElements: true,
3417
- // Resistance
3418
- resistance: true,
3419
- resistanceRatio: 0.85,
3420
- // Progress
3421
- watchSlidesProgress: false,
3422
- // Cursor
3423
- grabCursor: false,
3424
- // Clicks
3425
- preventClicks: true,
3426
- preventClicksPropagation: true,
3427
- slideToClickedSlide: false,
3428
- // loop
3429
- loop: false,
3430
- loopAddBlankSlides: true,
3431
- loopAdditionalSlides: 0,
3432
- loopPreventsSliding: true,
3433
- // rewind
3434
- rewind: false,
3435
- // Swiping/no swiping
3436
- allowSlidePrev: true,
3437
- allowSlideNext: true,
3438
- swipeHandler: null,
3439
- // '.swipe-handler',
3440
- noSwiping: true,
3441
- noSwipingClass: "swiper-no-swiping",
3442
- noSwipingSelector: null,
3443
- // Passive Listeners
3444
- passiveListeners: true,
3445
- maxBackfaceHiddenSlides: 10,
3446
- // NS
3447
- containerModifierClass: "swiper-",
3448
- // NEW
3449
- slideClass: "swiper-slide",
3450
- slideBlankClass: "swiper-slide-blank",
3451
- slideActiveClass: "swiper-slide-active",
3452
- slideVisibleClass: "swiper-slide-visible",
3453
- slideFullyVisibleClass: "swiper-slide-fully-visible",
3454
- slideNextClass: "swiper-slide-next",
3455
- slidePrevClass: "swiper-slide-prev",
3456
- wrapperClass: "swiper-wrapper",
3457
- lazyPreloaderClass: "swiper-lazy-preloader",
3458
- lazyPreloadPrevNext: 0,
3459
- // Callbacks
3460
- runCallbacksOnInit: true,
3461
- // Internals
3462
- _emitClasses: false
3463
- };
3464
- function moduleExtendParams(params, allModulesParams) {
3465
- return function extendParams(obj) {
3466
- if (obj === void 0) {
3467
- obj = {};
3468
- }
3469
- const moduleParamName = Object.keys(obj)[0];
3470
- const moduleParams = obj[moduleParamName];
3471
- if (typeof moduleParams !== "object" || moduleParams === null) {
3472
- extend$1(allModulesParams, obj);
3473
- return;
3474
- }
3475
- if (params[moduleParamName] === true) {
3476
- params[moduleParamName] = {
3477
- enabled: true
3478
- };
3479
- }
3480
- if (moduleParamName === "navigation" && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].prevEl && !params[moduleParamName].nextEl) {
3481
- params[moduleParamName].auto = true;
3482
- }
3483
- if (["pagination", "scrollbar"].indexOf(moduleParamName) >= 0 && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].el) {
3484
- params[moduleParamName].auto = true;
3485
- }
3486
- if (!(moduleParamName in params && "enabled" in moduleParams)) {
3487
- extend$1(allModulesParams, obj);
3488
- return;
3489
- }
3490
- if (typeof params[moduleParamName] === "object" && !("enabled" in params[moduleParamName])) {
3491
- params[moduleParamName].enabled = true;
3492
- }
3493
- if (!params[moduleParamName]) params[moduleParamName] = {
3494
- enabled: false
3495
- };
3496
- extend$1(allModulesParams, obj);
3497
- };
3498
- }
3499
- const prototypes = {
3500
- eventsEmitter,
3501
- update,
3502
- translate,
3503
- transition,
3504
- slide: slide$1,
3505
- loop,
3506
- grabCursor,
3507
- events: events$1,
3508
- breakpoints,
3509
- checkOverflow: checkOverflow$1,
3510
- classes
3511
- };
3512
- const extendedDefaults = {};
3513
- let Swiper$1 = class Swiper {
3514
- constructor() {
3515
- let el;
3516
- let params;
3517
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3518
- args[_key] = arguments[_key];
3519
- }
3520
- if (args.length === 1 && args[0].constructor && Object.prototype.toString.call(args[0]).slice(8, -1) === "Object") {
3521
- params = args[0];
3522
- } else {
3523
- [el, params] = args;
3524
- }
3525
- if (!params) params = {};
3526
- params = extend$1({}, params);
3527
- if (el && !params.el) params.el = el;
3528
- const document2 = getDocument();
3529
- if (params.el && typeof params.el === "string" && document2.querySelectorAll(params.el).length > 1) {
3530
- const swipers = [];
3531
- document2.querySelectorAll(params.el).forEach((containerEl) => {
3532
- const newParams = extend$1({}, params, {
3533
- el: containerEl
3534
- });
3535
- swipers.push(new Swiper(newParams));
3536
- });
3537
- return swipers;
3538
- }
3539
- const swiper2 = this;
3540
- swiper2.__swiper__ = true;
3541
- swiper2.support = getSupport();
3542
- swiper2.device = getDevice({
3543
- userAgent: params.userAgent
3544
- });
3545
- swiper2.browser = getBrowser();
3546
- swiper2.eventsListeners = {};
3547
- swiper2.eventsAnyListeners = [];
3548
- swiper2.modules = [...swiper2.__modules__];
3549
- if (params.modules && Array.isArray(params.modules)) {
3550
- swiper2.modules.push(...params.modules);
3551
- }
3552
- const allModulesParams = {};
3553
- swiper2.modules.forEach((mod) => {
3554
- mod({
3555
- params,
3556
- swiper: swiper2,
3557
- extendParams: moduleExtendParams(params, allModulesParams),
3558
- on: swiper2.on.bind(swiper2),
3559
- once: swiper2.once.bind(swiper2),
3560
- off: swiper2.off.bind(swiper2),
3561
- emit: swiper2.emit.bind(swiper2)
3562
- });
3563
- });
3564
- const swiperParams = extend$1({}, defaults, allModulesParams);
3565
- swiper2.params = extend$1({}, swiperParams, extendedDefaults, params);
3566
- swiper2.originalParams = extend$1({}, swiper2.params);
3567
- swiper2.passedParams = extend$1({}, params);
3568
- if (swiper2.params && swiper2.params.on) {
3569
- Object.keys(swiper2.params.on).forEach((eventName) => {
3570
- swiper2.on(eventName, swiper2.params.on[eventName]);
3571
- });
3572
- }
3573
- if (swiper2.params && swiper2.params.onAny) {
3574
- swiper2.onAny(swiper2.params.onAny);
3575
- }
3576
- Object.assign(swiper2, {
3577
- enabled: swiper2.params.enabled,
3578
- el,
3579
- // Classes
3580
- classNames: [],
3581
- // Slides
3582
- slides: [],
3583
- slidesGrid: [],
3584
- snapGrid: [],
3585
- slidesSizesGrid: [],
3586
- // isDirection
3587
- isHorizontal() {
3588
- return swiper2.params.direction === "horizontal";
3589
- },
3590
- isVertical() {
3591
- return swiper2.params.direction === "vertical";
3592
- },
3593
- // Indexes
3594
- activeIndex: 0,
3595
- realIndex: 0,
3596
- //
3597
- isBeginning: true,
3598
- isEnd: false,
3599
- // Props
3600
- translate: 0,
3601
- previousTranslate: 0,
3602
- progress: 0,
3603
- velocity: 0,
3604
- animating: false,
3605
- cssOverflowAdjustment() {
3606
- return Math.trunc(this.translate / 2 ** 23) * 2 ** 23;
3607
- },
3608
- // Locks
3609
- allowSlideNext: swiper2.params.allowSlideNext,
3610
- allowSlidePrev: swiper2.params.allowSlidePrev,
3611
- // Touch Events
3612
- touchEventsData: {
3613
- isTouched: void 0,
3614
- isMoved: void 0,
3615
- allowTouchCallbacks: void 0,
3616
- touchStartTime: void 0,
3617
- isScrolling: void 0,
3618
- currentTranslate: void 0,
3619
- startTranslate: void 0,
3620
- allowThresholdMove: void 0,
3621
- // Form elements to match
3622
- focusableElements: swiper2.params.focusableElements,
3623
- // Last click time
3624
- lastClickTime: 0,
3625
- clickTimeout: void 0,
3626
- // Velocities
3627
- velocities: [],
3628
- allowMomentumBounce: void 0,
3629
- startMoving: void 0,
3630
- pointerId: null,
3631
- touchId: null
3632
- },
3633
- // Clicks
3634
- allowClick: true,
3635
- // Touches
3636
- allowTouchMove: swiper2.params.allowTouchMove,
3637
- touches: {
3638
- startX: 0,
3639
- startY: 0,
3640
- currentX: 0,
3641
- currentY: 0,
3642
- diff: 0
3643
- },
3644
- // Images
3645
- imagesToLoad: [],
3646
- imagesLoaded: 0
3647
- });
3648
- swiper2.emit("_swiper");
3649
- if (swiper2.params.init) {
3650
- swiper2.init();
3651
- }
3652
- return swiper2;
3653
- }
3654
- getDirectionLabel(property) {
3655
- if (this.isHorizontal()) {
3656
- return property;
3657
- }
3658
- return {
3659
- "width": "height",
3660
- "margin-top": "margin-left",
3661
- "margin-bottom ": "margin-right",
3662
- "margin-left": "margin-top",
3663
- "margin-right": "margin-bottom",
3664
- "padding-left": "padding-top",
3665
- "padding-right": "padding-bottom",
3666
- "marginRight": "marginBottom"
3667
- }[property];
3668
- }
3669
- getSlideIndex(slideEl) {
3670
- const {
3671
- slidesEl,
3672
- params
3673
- } = this;
3674
- const slides2 = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
3675
- const firstSlideIndex = elementIndex(slides2[0]);
3676
- return elementIndex(slideEl) - firstSlideIndex;
3677
- }
3678
- getSlideIndexByData(index) {
3679
- return this.getSlideIndex(this.slides.filter((slideEl) => slideEl.getAttribute("data-swiper-slide-index") * 1 === index)[0]);
3680
- }
3681
- recalcSlides() {
3682
- const swiper2 = this;
3683
- const {
3684
- slidesEl,
3685
- params
3686
- } = swiper2;
3687
- swiper2.slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
3688
- }
3689
- enable() {
3690
- const swiper2 = this;
3691
- if (swiper2.enabled) return;
3692
- swiper2.enabled = true;
3693
- if (swiper2.params.grabCursor) {
3694
- swiper2.setGrabCursor();
3695
- }
3696
- swiper2.emit("enable");
3697
- }
3698
- disable() {
3699
- const swiper2 = this;
3700
- if (!swiper2.enabled) return;
3701
- swiper2.enabled = false;
3702
- if (swiper2.params.grabCursor) {
3703
- swiper2.unsetGrabCursor();
3704
- }
3705
- swiper2.emit("disable");
3706
- }
3707
- setProgress(progress, speed) {
3708
- const swiper2 = this;
3709
- progress = Math.min(Math.max(progress, 0), 1);
3710
- const min = swiper2.minTranslate();
3711
- const max = swiper2.maxTranslate();
3712
- const current = (max - min) * progress + min;
3713
- swiper2.translateTo(current, typeof speed === "undefined" ? 0 : speed);
3714
- swiper2.updateActiveIndex();
3715
- swiper2.updateSlidesClasses();
3716
- }
3717
- emitContainerClasses() {
3718
- const swiper2 = this;
3719
- if (!swiper2.params._emitClasses || !swiper2.el) return;
3720
- const cls2 = swiper2.el.className.split(" ").filter((className) => {
3721
- return className.indexOf("swiper") === 0 || className.indexOf(swiper2.params.containerModifierClass) === 0;
3722
- });
3723
- swiper2.emit("_containerClasses", cls2.join(" "));
3724
- }
3725
- getSlideClasses(slideEl) {
3726
- const swiper2 = this;
3727
- if (swiper2.destroyed) return "";
3728
- return slideEl.className.split(" ").filter((className) => {
3729
- return className.indexOf("swiper-slide") === 0 || className.indexOf(swiper2.params.slideClass) === 0;
3730
- }).join(" ");
3731
- }
3732
- emitSlidesClasses() {
3733
- const swiper2 = this;
3734
- if (!swiper2.params._emitClasses || !swiper2.el) return;
3735
- const updates = [];
3736
- swiper2.slides.forEach((slideEl) => {
3737
- const classNames2 = swiper2.getSlideClasses(slideEl);
3738
- updates.push({
3739
- slideEl,
3740
- classNames: classNames2
3741
- });
3742
- swiper2.emit("_slideClass", slideEl, classNames2);
3743
- });
3744
- swiper2.emit("_slideClasses", updates);
3745
- }
3746
- slidesPerViewDynamic(view, exact) {
3747
- if (view === void 0) {
3748
- view = "current";
3749
- }
3750
- if (exact === void 0) {
3751
- exact = false;
3752
- }
3753
- const swiper2 = this;
3754
- const {
3755
- params,
3756
- slides: slides2,
3757
- slidesGrid,
3758
- slidesSizesGrid,
3759
- size: swiperSize,
3760
- activeIndex
3761
- } = swiper2;
3762
- let spv = 1;
3763
- if (typeof params.slidesPerView === "number") return params.slidesPerView;
3764
- if (params.centeredSlides) {
3765
- let slideSize = slides2[activeIndex] ? Math.ceil(slides2[activeIndex].swiperSlideSize) : 0;
3766
- let breakLoop;
3767
- for (let i = activeIndex + 1; i < slides2.length; i += 1) {
3768
- if (slides2[i] && !breakLoop) {
3769
- slideSize += Math.ceil(slides2[i].swiperSlideSize);
3770
- spv += 1;
3771
- if (slideSize > swiperSize) breakLoop = true;
3772
- }
3773
- }
3774
- for (let i = activeIndex - 1; i >= 0; i -= 1) {
3775
- if (slides2[i] && !breakLoop) {
3776
- slideSize += slides2[i].swiperSlideSize;
3777
- spv += 1;
3778
- if (slideSize > swiperSize) breakLoop = true;
3779
- }
3780
- }
3781
- } else {
3782
- if (view === "current") {
3783
- for (let i = activeIndex + 1; i < slides2.length; i += 1) {
3784
- const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize;
3785
- if (slideInView) {
3786
- spv += 1;
3787
- }
3788
- }
3789
- } else {
3790
- for (let i = activeIndex - 1; i >= 0; i -= 1) {
3791
- const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize;
3792
- if (slideInView) {
3793
- spv += 1;
3794
- }
3795
- }
3796
- }
3797
- }
3798
- return spv;
3799
- }
3800
- update() {
3801
- const swiper2 = this;
3802
- if (!swiper2 || swiper2.destroyed) return;
3803
- const {
3804
- snapGrid,
3805
- params
3806
- } = swiper2;
3807
- if (params.breakpoints) {
3808
- swiper2.setBreakpoint();
3809
- }
3810
- [...swiper2.el.querySelectorAll('[loading="lazy"]')].forEach((imageEl) => {
3811
- if (imageEl.complete) {
3812
- processLazyPreloader(swiper2, imageEl);
3813
- }
3814
- });
3815
- swiper2.updateSize();
3816
- swiper2.updateSlides();
3817
- swiper2.updateProgress();
3818
- swiper2.updateSlidesClasses();
3819
- function setTranslate2() {
3820
- const translateValue = swiper2.rtlTranslate ? swiper2.translate * -1 : swiper2.translate;
3821
- const newTranslate = Math.min(Math.max(translateValue, swiper2.maxTranslate()), swiper2.minTranslate());
3822
- swiper2.setTranslate(newTranslate);
3823
- swiper2.updateActiveIndex();
3824
- swiper2.updateSlidesClasses();
3825
- }
3826
- let translated;
3827
- if (params.freeMode && params.freeMode.enabled && !params.cssMode) {
3828
- setTranslate2();
3829
- if (params.autoHeight) {
3830
- swiper2.updateAutoHeight();
3831
- }
3832
- } else {
3833
- if ((params.slidesPerView === "auto" || params.slidesPerView > 1) && swiper2.isEnd && !params.centeredSlides) {
3834
- const slides2 = swiper2.virtual && params.virtual.enabled ? swiper2.virtual.slides : swiper2.slides;
3835
- translated = swiper2.slideTo(slides2.length - 1, 0, false, true);
3836
- } else {
3837
- translated = swiper2.slideTo(swiper2.activeIndex, 0, false, true);
3838
- }
3839
- if (!translated) {
3840
- setTranslate2();
3841
- }
3842
- }
3843
- if (params.watchOverflow && snapGrid !== swiper2.snapGrid) {
3844
- swiper2.checkOverflow();
3845
- }
3846
- swiper2.emit("update");
3847
- }
3848
- changeDirection(newDirection, needUpdate) {
3849
- if (needUpdate === void 0) {
3850
- needUpdate = true;
3851
- }
3852
- const swiper2 = this;
3853
- const currentDirection = swiper2.params.direction;
3854
- if (!newDirection) {
3855
- newDirection = currentDirection === "horizontal" ? "vertical" : "horizontal";
3856
- }
3857
- if (newDirection === currentDirection || newDirection !== "horizontal" && newDirection !== "vertical") {
3858
- return swiper2;
3859
- }
3860
- swiper2.el.classList.remove(`${swiper2.params.containerModifierClass}${currentDirection}`);
3861
- swiper2.el.classList.add(`${swiper2.params.containerModifierClass}${newDirection}`);
3862
- swiper2.emitContainerClasses();
3863
- swiper2.params.direction = newDirection;
3864
- swiper2.slides.forEach((slideEl) => {
3865
- if (newDirection === "vertical") {
3866
- slideEl.style.width = "";
3867
- } else {
3868
- slideEl.style.height = "";
3869
- }
3870
- });
3871
- swiper2.emit("changeDirection");
3872
- if (needUpdate) swiper2.update();
3873
- return swiper2;
3874
- }
3875
- changeLanguageDirection(direction) {
3876
- const swiper2 = this;
3877
- if (swiper2.rtl && direction === "rtl" || !swiper2.rtl && direction === "ltr") return;
3878
- swiper2.rtl = direction === "rtl";
3879
- swiper2.rtlTranslate = swiper2.params.direction === "horizontal" && swiper2.rtl;
3880
- if (swiper2.rtl) {
3881
- swiper2.el.classList.add(`${swiper2.params.containerModifierClass}rtl`);
3882
- swiper2.el.dir = "rtl";
3883
- } else {
3884
- swiper2.el.classList.remove(`${swiper2.params.containerModifierClass}rtl`);
3885
- swiper2.el.dir = "ltr";
3886
- }
3887
- swiper2.update();
3888
- }
3889
- mount(element) {
3890
- const swiper2 = this;
3891
- if (swiper2.mounted) return true;
3892
- let el = element || swiper2.params.el;
3893
- if (typeof el === "string") {
3894
- el = document.querySelector(el);
3895
- }
3896
- if (!el) {
3897
- return false;
3898
- }
3899
- el.swiper = swiper2;
3900
- if (el.parentNode && el.parentNode.host && el.parentNode.host.nodeName === swiper2.params.swiperElementNodeName.toUpperCase()) {
3901
- swiper2.isElement = true;
3902
- }
3903
- const getWrapperSelector = () => {
3904
- return `.${(swiper2.params.wrapperClass || "").trim().split(" ").join(".")}`;
3905
- };
3906
- const getWrapper = () => {
3907
- if (el && el.shadowRoot && el.shadowRoot.querySelector) {
3908
- const res = el.shadowRoot.querySelector(getWrapperSelector());
3909
- return res;
3910
- }
3911
- return elementChildren(el, getWrapperSelector())[0];
3912
- };
3913
- let wrapperEl = getWrapper();
3914
- if (!wrapperEl && swiper2.params.createElements) {
3915
- wrapperEl = createElement("div", swiper2.params.wrapperClass);
3916
- el.append(wrapperEl);
3917
- elementChildren(el, `.${swiper2.params.slideClass}`).forEach((slideEl) => {
3918
- wrapperEl.append(slideEl);
3919
- });
3920
- }
3921
- Object.assign(swiper2, {
3922
- el,
3923
- wrapperEl,
3924
- slidesEl: swiper2.isElement && !el.parentNode.host.slideSlots ? el.parentNode.host : wrapperEl,
3925
- hostEl: swiper2.isElement ? el.parentNode.host : el,
3926
- mounted: true,
3927
- // RTL
3928
- rtl: el.dir.toLowerCase() === "rtl" || elementStyle(el, "direction") === "rtl",
3929
- rtlTranslate: swiper2.params.direction === "horizontal" && (el.dir.toLowerCase() === "rtl" || elementStyle(el, "direction") === "rtl"),
3930
- wrongRTL: elementStyle(wrapperEl, "display") === "-webkit-box"
3931
- });
3932
- return true;
3933
- }
3934
- init(el) {
3935
- const swiper2 = this;
3936
- if (swiper2.initialized) return swiper2;
3937
- const mounted = swiper2.mount(el);
3938
- if (mounted === false) return swiper2;
3939
- swiper2.emit("beforeInit");
3940
- if (swiper2.params.breakpoints) {
3941
- swiper2.setBreakpoint();
3942
- }
3943
- swiper2.addClasses();
3944
- swiper2.updateSize();
3945
- swiper2.updateSlides();
3946
- if (swiper2.params.watchOverflow) {
3947
- swiper2.checkOverflow();
3948
- }
3949
- if (swiper2.params.grabCursor && swiper2.enabled) {
3950
- swiper2.setGrabCursor();
3951
- }
3952
- if (swiper2.params.loop && swiper2.virtual && swiper2.params.virtual.enabled) {
3953
- swiper2.slideTo(swiper2.params.initialSlide + swiper2.virtual.slidesBefore, 0, swiper2.params.runCallbacksOnInit, false, true);
3954
- } else {
3955
- swiper2.slideTo(swiper2.params.initialSlide, 0, swiper2.params.runCallbacksOnInit, false, true);
3956
- }
3957
- if (swiper2.params.loop) {
3958
- swiper2.loopCreate();
3959
- }
3960
- swiper2.attachEvents();
3961
- const lazyElements = [...swiper2.el.querySelectorAll('[loading="lazy"]')];
3962
- if (swiper2.isElement) {
3963
- lazyElements.push(...swiper2.hostEl.querySelectorAll('[loading="lazy"]'));
3964
- }
3965
- lazyElements.forEach((imageEl) => {
3966
- if (imageEl.complete) {
3967
- processLazyPreloader(swiper2, imageEl);
3968
- } else {
3969
- imageEl.addEventListener("load", (e) => {
3970
- processLazyPreloader(swiper2, e.target);
3971
- });
3972
- }
3973
- });
3974
- preload(swiper2);
3975
- swiper2.initialized = true;
3976
- preload(swiper2);
3977
- swiper2.emit("init");
3978
- swiper2.emit("afterInit");
3979
- return swiper2;
3980
- }
3981
- destroy(deleteInstance, cleanStyles) {
3982
- if (deleteInstance === void 0) {
3983
- deleteInstance = true;
3984
- }
3985
- if (cleanStyles === void 0) {
3986
- cleanStyles = true;
3987
- }
3988
- const swiper2 = this;
3989
- const {
3990
- params,
3991
- el,
3992
- wrapperEl,
3993
- slides: slides2
3994
- } = swiper2;
3995
- if (typeof swiper2.params === "undefined" || swiper2.destroyed) {
3996
- return null;
3997
- }
3998
- swiper2.emit("beforeDestroy");
3999
- swiper2.initialized = false;
4000
- swiper2.detachEvents();
4001
- if (params.loop) {
4002
- swiper2.loopDestroy();
4003
- }
4004
- if (cleanStyles) {
4005
- swiper2.removeClasses();
4006
- if (el && typeof el !== "string") {
4007
- el.removeAttribute("style");
4008
- }
4009
- if (wrapperEl) {
4010
- wrapperEl.removeAttribute("style");
4011
- }
4012
- if (slides2 && slides2.length) {
4013
- slides2.forEach((slideEl) => {
4014
- slideEl.classList.remove(params.slideVisibleClass, params.slideFullyVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
4015
- slideEl.removeAttribute("style");
4016
- slideEl.removeAttribute("data-swiper-slide-index");
4017
- });
4018
- }
4019
- }
4020
- swiper2.emit("destroy");
4021
- Object.keys(swiper2.eventsListeners).forEach((eventName) => {
4022
- swiper2.off(eventName);
4023
- });
4024
- if (deleteInstance !== false) {
4025
- if (swiper2.el && typeof swiper2.el !== "string") {
4026
- swiper2.el.swiper = null;
4027
- }
4028
- deleteProps(swiper2);
4029
- }
4030
- swiper2.destroyed = true;
4031
- return null;
4032
- }
4033
- static extendDefaults(newDefaults) {
4034
- extend$1(extendedDefaults, newDefaults);
4035
- }
4036
- static get extendedDefaults() {
4037
- return extendedDefaults;
4038
- }
4039
- static get defaults() {
4040
- return defaults;
4041
- }
4042
- static installModule(mod) {
4043
- if (!Swiper.prototype.__modules__) Swiper.prototype.__modules__ = [];
4044
- const modules = Swiper.prototype.__modules__;
4045
- if (typeof mod === "function" && modules.indexOf(mod) < 0) {
4046
- modules.push(mod);
4047
- }
4048
- }
4049
- static use(module) {
4050
- if (Array.isArray(module)) {
4051
- module.forEach((m) => Swiper.installModule(m));
4052
- return Swiper;
4053
- }
4054
- Swiper.installModule(module);
4055
- return Swiper;
4056
- }
4057
- };
4058
- Object.keys(prototypes).forEach((prototypeGroup) => {
4059
- Object.keys(prototypes[prototypeGroup]).forEach((protoMethod) => {
4060
- Swiper$1.prototype[protoMethod] = prototypes[prototypeGroup][protoMethod];
4061
- });
4062
- });
4063
- Swiper$1.use([Resize, Observer]);
4064
- const paramsList = [
4065
- "eventsPrefix",
4066
- "injectStyles",
4067
- "injectStylesUrls",
4068
- "modules",
4069
- "init",
4070
- "_direction",
4071
- "oneWayMovement",
4072
- "swiperElementNodeName",
4073
- "touchEventsTarget",
4074
- "initialSlide",
4075
- "_speed",
4076
- "cssMode",
4077
- "updateOnWindowResize",
4078
- "resizeObserver",
4079
- "nested",
4080
- "focusableElements",
4081
- "_enabled",
4082
- "_width",
4083
- "_height",
4084
- "preventInteractionOnTransition",
4085
- "userAgent",
4086
- "url",
4087
- "_edgeSwipeDetection",
4088
- "_edgeSwipeThreshold",
4089
- "_freeMode",
4090
- "_autoHeight",
4091
- "setWrapperSize",
4092
- "virtualTranslate",
4093
- "_effect",
4094
- "breakpoints",
4095
- "breakpointsBase",
4096
- "_spaceBetween",
4097
- "_slidesPerView",
4098
- "maxBackfaceHiddenSlides",
4099
- "_grid",
4100
- "_slidesPerGroup",
4101
- "_slidesPerGroupSkip",
4102
- "_slidesPerGroupAuto",
4103
- "_centeredSlides",
4104
- "_centeredSlidesBounds",
4105
- "_slidesOffsetBefore",
4106
- "_slidesOffsetAfter",
4107
- "normalizeSlideIndex",
4108
- "_centerInsufficientSlides",
4109
- "_watchOverflow",
4110
- "roundLengths",
4111
- "touchRatio",
4112
- "touchAngle",
4113
- "simulateTouch",
4114
- "_shortSwipes",
4115
- "_longSwipes",
4116
- "longSwipesRatio",
4117
- "longSwipesMs",
4118
- "_followFinger",
4119
- "allowTouchMove",
4120
- "_threshold",
4121
- "touchMoveStopPropagation",
4122
- "touchStartPreventDefault",
4123
- "touchStartForcePreventDefault",
4124
- "touchReleaseOnEdges",
4125
- "uniqueNavElements",
4126
- "_resistance",
4127
- "_resistanceRatio",
4128
- "_watchSlidesProgress",
4129
- "_grabCursor",
4130
- "preventClicks",
4131
- "preventClicksPropagation",
4132
- "_slideToClickedSlide",
4133
- "_loop",
4134
- "loopAdditionalSlides",
4135
- "loopAddBlankSlides",
4136
- "loopPreventsSliding",
4137
- "_rewind",
4138
- "_allowSlidePrev",
4139
- "_allowSlideNext",
4140
- "_swipeHandler",
4141
- "_noSwiping",
4142
- "noSwipingClass",
4143
- "noSwipingSelector",
4144
- "passiveListeners",
4145
- "containerModifierClass",
4146
- "slideClass",
4147
- "slideActiveClass",
4148
- "slideVisibleClass",
4149
- "slideFullyVisibleClass",
4150
- "slideNextClass",
4151
- "slidePrevClass",
4152
- "slideBlankClass",
4153
- "wrapperClass",
4154
- "lazyPreloaderClass",
4155
- "lazyPreloadPrevNext",
4156
- "runCallbacksOnInit",
4157
- "observer",
4158
- "observeParents",
4159
- "observeSlideChildren",
4160
- // modules
4161
- "a11y",
4162
- "_autoplay",
4163
- "_controller",
4164
- "coverflowEffect",
4165
- "cubeEffect",
4166
- "fadeEffect",
4167
- "flipEffect",
4168
- "creativeEffect",
4169
- "cardsEffect",
4170
- "hashNavigation",
4171
- "history",
4172
- "keyboard",
4173
- "mousewheel",
4174
- "_navigation",
4175
- "_pagination",
4176
- "parallax",
4177
- "_scrollbar",
4178
- "_thumbs",
4179
- "virtual",
4180
- "zoom",
4181
- "control"
4182
- ];
4183
- function isObject(o) {
4184
- return typeof o === "object" && o !== null && o.constructor && Object.prototype.toString.call(o).slice(8, -1) === "Object" && !o.__swiper__;
4185
- }
4186
- function extend(target, src) {
4187
- const noExtend = ["__proto__", "constructor", "prototype"];
4188
- Object.keys(src).filter((key) => noExtend.indexOf(key) < 0).forEach((key) => {
4189
- if (typeof target[key] === "undefined") target[key] = src[key];
4190
- else if (isObject(src[key]) && isObject(target[key]) && Object.keys(src[key]).length > 0) {
4191
- if (src[key].__swiper__) target[key] = src[key];
4192
- else extend(target[key], src[key]);
4193
- } else {
4194
- target[key] = src[key];
4195
- }
4196
- });
4197
- }
4198
- function needsNavigation(params) {
4199
- if (params === void 0) {
4200
- params = {};
4201
- }
4202
- return params.navigation && typeof params.navigation.nextEl === "undefined" && typeof params.navigation.prevEl === "undefined";
4203
- }
4204
- function needsPagination(params) {
4205
- if (params === void 0) {
4206
- params = {};
4207
- }
4208
- return params.pagination && typeof params.pagination.el === "undefined";
4209
- }
4210
- function needsScrollbar(params) {
4211
- if (params === void 0) {
4212
- params = {};
4213
- }
4214
- return params.scrollbar && typeof params.scrollbar.el === "undefined";
4215
- }
4216
- function uniqueClasses(classNames2) {
4217
- if (classNames2 === void 0) {
4218
- classNames2 = "";
4219
- }
4220
- const classes2 = classNames2.split(" ").map((c) => c.trim()).filter((c) => !!c);
4221
- const unique = [];
4222
- classes2.forEach((c) => {
4223
- if (unique.indexOf(c) < 0) unique.push(c);
4224
- });
4225
- return unique.join(" ");
4226
- }
4227
- function wrapperClass(className) {
4228
- if (className === void 0) {
4229
- className = "";
4230
- }
4231
- if (!className) return "swiper-wrapper";
4232
- if (!className.includes("swiper-wrapper")) return `swiper-wrapper ${className}`;
4233
- return className;
4234
- }
4235
- function updateSwiper(_ref) {
4236
- let {
4237
- swiper: swiper2,
4238
- slides: slides2,
4239
- passedParams,
4240
- changedParams,
4241
- nextEl,
4242
- prevEl,
4243
- scrollbarEl,
4244
- paginationEl
4245
- } = _ref;
4246
- const updateParams = changedParams.filter((key) => key !== "children" && key !== "direction" && key !== "wrapperClass");
4247
- const {
4248
- params: currentParams,
4249
- pagination: pagination2,
4250
- navigation: navigation2,
4251
- scrollbar,
4252
- virtual,
4253
- thumbs
4254
- } = swiper2;
4255
- let needThumbsInit;
4256
- let needControllerInit;
4257
- let needPaginationInit;
4258
- let needScrollbarInit;
4259
- let needNavigationInit;
4260
- let loopNeedDestroy;
4261
- let loopNeedEnable;
4262
- let loopNeedReloop;
4263
- if (changedParams.includes("thumbs") && passedParams.thumbs && passedParams.thumbs.swiper && currentParams.thumbs && !currentParams.thumbs.swiper) {
4264
- needThumbsInit = true;
4265
- }
4266
- if (changedParams.includes("controller") && passedParams.controller && passedParams.controller.control && currentParams.controller && !currentParams.controller.control) {
4267
- needControllerInit = true;
4268
- }
4269
- if (changedParams.includes("pagination") && passedParams.pagination && (passedParams.pagination.el || paginationEl) && (currentParams.pagination || currentParams.pagination === false) && pagination2 && !pagination2.el) {
4270
- needPaginationInit = true;
4271
- }
4272
- if (changedParams.includes("scrollbar") && passedParams.scrollbar && (passedParams.scrollbar.el || scrollbarEl) && (currentParams.scrollbar || currentParams.scrollbar === false) && scrollbar && !scrollbar.el) {
4273
- needScrollbarInit = true;
4274
- }
4275
- if (changedParams.includes("navigation") && passedParams.navigation && (passedParams.navigation.prevEl || prevEl) && (passedParams.navigation.nextEl || nextEl) && (currentParams.navigation || currentParams.navigation === false) && navigation2 && !navigation2.prevEl && !navigation2.nextEl) {
4276
- needNavigationInit = true;
4277
- }
4278
- const destroyModule = (mod) => {
4279
- if (!swiper2[mod]) return;
4280
- swiper2[mod].destroy();
4281
- if (mod === "navigation") {
4282
- if (swiper2.isElement) {
4283
- swiper2[mod].prevEl.remove();
4284
- swiper2[mod].nextEl.remove();
4285
- }
4286
- currentParams[mod].prevEl = void 0;
4287
- currentParams[mod].nextEl = void 0;
4288
- swiper2[mod].prevEl = void 0;
4289
- swiper2[mod].nextEl = void 0;
4290
- } else {
4291
- if (swiper2.isElement) {
4292
- swiper2[mod].el.remove();
4293
- }
4294
- currentParams[mod].el = void 0;
4295
- swiper2[mod].el = void 0;
4296
- }
4297
- };
4298
- if (changedParams.includes("loop") && swiper2.isElement) {
4299
- if (currentParams.loop && !passedParams.loop) {
4300
- loopNeedDestroy = true;
4301
- } else if (!currentParams.loop && passedParams.loop) {
4302
- loopNeedEnable = true;
4303
- } else {
4304
- loopNeedReloop = true;
4305
- }
4306
- }
4307
- updateParams.forEach((key) => {
4308
- if (isObject(currentParams[key]) && isObject(passedParams[key])) {
4309
- Object.assign(currentParams[key], passedParams[key]);
4310
- if ((key === "navigation" || key === "pagination" || key === "scrollbar") && "enabled" in passedParams[key] && !passedParams[key].enabled) {
4311
- destroyModule(key);
4312
- }
4313
- } else {
4314
- const newValue = passedParams[key];
4315
- if ((newValue === true || newValue === false) && (key === "navigation" || key === "pagination" || key === "scrollbar")) {
4316
- if (newValue === false) {
4317
- destroyModule(key);
4318
- }
4319
- } else {
4320
- currentParams[key] = passedParams[key];
4321
- }
4322
- }
4323
- });
4324
- if (updateParams.includes("controller") && !needControllerInit && swiper2.controller && swiper2.controller.control && currentParams.controller && currentParams.controller.control) {
4325
- swiper2.controller.control = currentParams.controller.control;
4326
- }
4327
- if (changedParams.includes("children") && slides2 && virtual && currentParams.virtual.enabled) {
4328
- virtual.slides = slides2;
4329
- virtual.update(true);
4330
- } else if (changedParams.includes("virtual") && virtual && currentParams.virtual.enabled) {
4331
- if (slides2) virtual.slides = slides2;
4332
- virtual.update(true);
4333
- }
4334
- if (changedParams.includes("children") && slides2 && currentParams.loop) {
4335
- loopNeedReloop = true;
4336
- }
4337
- if (needThumbsInit) {
4338
- const initialized = thumbs.init();
4339
- if (initialized) thumbs.update(true);
4340
- }
4341
- if (needControllerInit) {
4342
- swiper2.controller.control = currentParams.controller.control;
4343
- }
4344
- if (needPaginationInit) {
4345
- if (swiper2.isElement && (!paginationEl || typeof paginationEl === "string")) {
4346
- paginationEl = document.createElement("div");
4347
- paginationEl.classList.add("swiper-pagination");
4348
- paginationEl.part.add("pagination");
4349
- swiper2.el.appendChild(paginationEl);
4350
- }
4351
- if (paginationEl) currentParams.pagination.el = paginationEl;
4352
- pagination2.init();
4353
- pagination2.render();
4354
- pagination2.update();
4355
- }
4356
- if (needScrollbarInit) {
4357
- if (swiper2.isElement && (!scrollbarEl || typeof scrollbarEl === "string")) {
4358
- scrollbarEl = document.createElement("div");
4359
- scrollbarEl.classList.add("swiper-scrollbar");
4360
- scrollbarEl.part.add("scrollbar");
4361
- swiper2.el.appendChild(scrollbarEl);
4362
- }
4363
- if (scrollbarEl) currentParams.scrollbar.el = scrollbarEl;
4364
- scrollbar.init();
4365
- scrollbar.updateSize();
4366
- scrollbar.setTranslate();
4367
- }
4368
- if (needNavigationInit) {
4369
- if (swiper2.isElement) {
4370
- if (!nextEl || typeof nextEl === "string") {
4371
- nextEl = document.createElement("div");
4372
- nextEl.classList.add("swiper-button-next");
4373
- nextEl.innerHTML = swiper2.hostEl.constructor.nextButtonSvg;
4374
- nextEl.part.add("button-next");
4375
- swiper2.el.appendChild(nextEl);
4376
- }
4377
- if (!prevEl || typeof prevEl === "string") {
4378
- prevEl = document.createElement("div");
4379
- prevEl.classList.add("swiper-button-prev");
4380
- prevEl.innerHTML = swiper2.hostEl.constructor.prevButtonSvg;
4381
- prevEl.part.add("button-prev");
4382
- swiper2.el.appendChild(prevEl);
4383
- }
4384
- }
4385
- if (nextEl) currentParams.navigation.nextEl = nextEl;
4386
- if (prevEl) currentParams.navigation.prevEl = prevEl;
4387
- navigation2.init();
4388
- navigation2.update();
4389
- }
4390
- if (changedParams.includes("allowSlideNext")) {
4391
- swiper2.allowSlideNext = passedParams.allowSlideNext;
4392
- }
4393
- if (changedParams.includes("allowSlidePrev")) {
4394
- swiper2.allowSlidePrev = passedParams.allowSlidePrev;
4395
- }
4396
- if (changedParams.includes("direction")) {
4397
- swiper2.changeDirection(passedParams.direction, false);
4398
- }
4399
- if (loopNeedDestroy || loopNeedReloop) {
4400
- swiper2.loopDestroy();
4401
- }
4402
- if (loopNeedEnable || loopNeedReloop) {
4403
- swiper2.loopCreate();
4404
- }
4405
- swiper2.update();
4406
- }
4407
- function getParams(obj, splitEvents) {
4408
- if (obj === void 0) {
4409
- obj = {};
4410
- }
4411
- if (splitEvents === void 0) {
4412
- splitEvents = true;
4413
- }
4414
- const params = {
4415
- on: {}
4416
- };
4417
- const events2 = {};
4418
- const passedParams = {};
4419
- extend(params, defaults);
4420
- params._emitClasses = true;
4421
- params.init = false;
4422
- const rest = {};
4423
- const allowedParams = paramsList.map((key) => key.replace(/_/, ""));
4424
- const plainObj = Object.assign({}, obj);
4425
- Object.keys(plainObj).forEach((key) => {
4426
- if (typeof obj[key] === "undefined") return;
4427
- if (allowedParams.indexOf(key) >= 0) {
4428
- if (isObject(obj[key])) {
4429
- params[key] = {};
4430
- passedParams[key] = {};
4431
- extend(params[key], obj[key]);
4432
- extend(passedParams[key], obj[key]);
4433
- } else {
4434
- params[key] = obj[key];
4435
- passedParams[key] = obj[key];
4436
- }
4437
- } else if (key.search(/on[A-Z]/) === 0 && typeof obj[key] === "function") {
4438
- if (splitEvents) {
4439
- events2[`${key[2].toLowerCase()}${key.substr(3)}`] = obj[key];
4440
- } else {
4441
- params.on[`${key[2].toLowerCase()}${key.substr(3)}`] = obj[key];
4442
- }
4443
- } else {
4444
- rest[key] = obj[key];
4445
- }
4446
- });
4447
- ["navigation", "pagination", "scrollbar"].forEach((key) => {
4448
- if (params[key] === true) params[key] = {};
4449
- if (params[key] === false) delete params[key];
4450
- });
4451
- return {
4452
- params,
4453
- passedParams,
4454
- rest,
4455
- events: events2
4456
- };
4457
- }
4458
- function mountSwiper(_ref, swiperParams) {
4459
- let {
4460
- el,
4461
- nextEl,
4462
- prevEl,
4463
- paginationEl,
4464
- scrollbarEl,
4465
- swiper: swiper2
4466
- } = _ref;
4467
- if (needsNavigation(swiperParams) && nextEl && prevEl) {
4468
- swiper2.params.navigation.nextEl = nextEl;
4469
- swiper2.originalParams.navigation.nextEl = nextEl;
4470
- swiper2.params.navigation.prevEl = prevEl;
4471
- swiper2.originalParams.navigation.prevEl = prevEl;
4472
- }
4473
- if (needsPagination(swiperParams) && paginationEl) {
4474
- swiper2.params.pagination.el = paginationEl;
4475
- swiper2.originalParams.pagination.el = paginationEl;
4476
- }
4477
- if (needsScrollbar(swiperParams) && scrollbarEl) {
4478
- swiper2.params.scrollbar.el = scrollbarEl;
4479
- swiper2.originalParams.scrollbar.el = scrollbarEl;
4480
- }
4481
- swiper2.init(el);
4482
- }
4483
- function getChangedParams(swiperParams, oldParams, children, oldChildren, getKey) {
4484
- const keys = [];
4485
- if (!oldParams) return keys;
4486
- const addKey = (key) => {
4487
- if (keys.indexOf(key) < 0) keys.push(key);
4488
- };
4489
- if (children && oldChildren) {
4490
- const oldChildrenKeys = oldChildren.map(getKey);
4491
- const childrenKeys = children.map(getKey);
4492
- if (oldChildrenKeys.join("") !== childrenKeys.join("")) addKey("children");
4493
- if (oldChildren.length !== children.length) addKey("children");
4494
- }
4495
- const watchParams = paramsList.filter((key) => key[0] === "_").map((key) => key.replace(/_/, ""));
4496
- watchParams.forEach((key) => {
4497
- if (key in swiperParams && key in oldParams) {
4498
- if (isObject(swiperParams[key]) && isObject(oldParams[key])) {
4499
- const newKeys = Object.keys(swiperParams[key]);
4500
- const oldKeys = Object.keys(oldParams[key]);
4501
- if (newKeys.length !== oldKeys.length) {
4502
- addKey(key);
4503
- } else {
4504
- newKeys.forEach((newKey) => {
4505
- if (swiperParams[key][newKey] !== oldParams[key][newKey]) {
4506
- addKey(key);
4507
- }
4508
- });
4509
- oldKeys.forEach((oldKey) => {
4510
- if (swiperParams[key][oldKey] !== oldParams[key][oldKey]) addKey(key);
4511
- });
4512
- }
4513
- } else if (swiperParams[key] !== oldParams[key]) {
4514
- addKey(key);
4515
- }
4516
- }
4517
- });
4518
- return keys;
4519
- }
4520
- const updateOnVirtualData = (swiper2) => {
4521
- if (!swiper2 || swiper2.destroyed || !swiper2.params.virtual || swiper2.params.virtual && !swiper2.params.virtual.enabled) return;
4522
- swiper2.updateSlides();
4523
- swiper2.updateProgress();
4524
- swiper2.updateSlidesClasses();
4525
- if (swiper2.parallax && swiper2.params.parallax && swiper2.params.parallax.enabled) {
4526
- swiper2.parallax.setTranslate();
4527
- }
4528
- };
4529
- function _extends() {
4530
- _extends = Object.assign ? Object.assign.bind() : function(target) {
4531
- for (var i = 1; i < arguments.length; i++) {
4532
- var source = arguments[i];
4533
- for (var key in source) {
4534
- if (Object.prototype.hasOwnProperty.call(source, key)) {
4535
- target[key] = source[key];
4536
- }
4537
- }
4538
- }
4539
- return target;
4540
- };
4541
- return _extends.apply(this, arguments);
4542
- }
4543
- function isChildSwiperSlide(child) {
4544
- return child.type && child.type.displayName && child.type.displayName.includes("SwiperSlide");
4545
- }
4546
- function processChildren(c) {
4547
- const slides2 = [];
4548
- React.Children.toArray(c).forEach((child) => {
4549
- if (isChildSwiperSlide(child)) {
4550
- slides2.push(child);
4551
- } else if (child.props && child.props.children) {
4552
- processChildren(child.props.children).forEach((slide2) => slides2.push(slide2));
4553
- }
4554
- });
4555
- return slides2;
4556
- }
4557
- function getChildren(c) {
4558
- const slides2 = [];
4559
- const slots = {
4560
- "container-start": [],
4561
- "container-end": [],
4562
- "wrapper-start": [],
4563
- "wrapper-end": []
4564
- };
4565
- React.Children.toArray(c).forEach((child) => {
4566
- if (isChildSwiperSlide(child)) {
4567
- slides2.push(child);
4568
- } else if (child.props && child.props.slot && slots[child.props.slot]) {
4569
- slots[child.props.slot].push(child);
4570
- } else if (child.props && child.props.children) {
4571
- const foundSlides = processChildren(child.props.children);
4572
- if (foundSlides.length > 0) {
4573
- foundSlides.forEach((slide2) => slides2.push(slide2));
4574
- } else {
4575
- slots["container-end"].push(child);
4576
- }
4577
- } else {
4578
- slots["container-end"].push(child);
4579
- }
4580
- });
4581
- return {
4582
- slides: slides2,
4583
- slots
4584
- };
4585
- }
4586
- function renderVirtual(swiper2, slides2, virtualData) {
4587
- if (!virtualData) return null;
4588
- const getSlideIndex = (index) => {
4589
- let slideIndex = index;
4590
- if (index < 0) {
4591
- slideIndex = slides2.length + index;
4592
- } else if (slideIndex >= slides2.length) {
4593
- slideIndex = slideIndex - slides2.length;
4594
- }
4595
- return slideIndex;
4596
- };
4597
- const style = swiper2.isHorizontal() ? {
4598
- [swiper2.rtlTranslate ? "right" : "left"]: `${virtualData.offset}px`
4599
- } : {
4600
- top: `${virtualData.offset}px`
4601
- };
4602
- const {
4603
- from,
4604
- to
4605
- } = virtualData;
4606
- const loopFrom = swiper2.params.loop ? -slides2.length : 0;
4607
- const loopTo = swiper2.params.loop ? slides2.length * 2 : slides2.length;
4608
- const slidesToRender = [];
4609
- for (let i = loopFrom; i < loopTo; i += 1) {
4610
- if (i >= from && i <= to) {
4611
- slidesToRender.push(slides2[getSlideIndex(i)]);
4612
- }
4613
- }
4614
- return slidesToRender.map((child, index) => {
4615
- return /* @__PURE__ */ React.cloneElement(child, {
4616
- swiper: swiper2,
4617
- style,
4618
- key: child.props.virtualIndex || child.key || `slide-${index}`
4619
- });
4620
- });
4621
- }
4622
- function useIsomorphicLayoutEffect(callback, deps) {
4623
- if (typeof window === "undefined") return useEffect(callback, deps);
4624
- return useLayoutEffect(callback, deps);
4625
- }
4626
- const SwiperSlideContext = /* @__PURE__ */ createContext(null);
4627
- const SwiperContext = /* @__PURE__ */ createContext(null);
4628
- const useSwiper = () => {
4629
- return useContext(SwiperContext);
4630
- };
4631
- const Swiper2 = /* @__PURE__ */ forwardRef(function(_temp, externalElRef) {
4632
- let {
4633
- className,
4634
- tag: Tag = "div",
4635
- wrapperTag: WrapperTag = "div",
4636
- children,
4637
- onSwiper,
4638
- ...rest
4639
- } = _temp === void 0 ? {} : _temp;
4640
- let eventsAssigned = false;
4641
- const [containerClasses, setContainerClasses] = useState("swiper");
4642
- const [virtualData, setVirtualData] = useState(null);
4643
- const [breakpointChanged, setBreakpointChanged] = useState(false);
4644
- const initializedRef = useRef(false);
4645
- const swiperElRef = useRef(null);
4646
- const swiperRef = useRef(null);
4647
- const oldPassedParamsRef = useRef(null);
4648
- const oldSlides = useRef(null);
4649
- const nextElRef = useRef(null);
4650
- const prevElRef = useRef(null);
4651
- const paginationElRef = useRef(null);
4652
- const scrollbarElRef = useRef(null);
4653
- const {
4654
- params: swiperParams,
4655
- passedParams,
4656
- rest: restProps,
4657
- events: events2
4658
- } = getParams(rest);
4659
- const {
4660
- slides: slides2,
4661
- slots
4662
- } = getChildren(children);
4663
- const onBeforeBreakpoint = () => {
4664
- setBreakpointChanged(!breakpointChanged);
4665
- };
4666
- Object.assign(swiperParams.on, {
4667
- _containerClasses(swiper2, classes2) {
4668
- setContainerClasses(classes2);
4669
- }
4670
- });
4671
- const initSwiper = () => {
4672
- Object.assign(swiperParams.on, events2);
4673
- eventsAssigned = true;
4674
- const passParams = {
4675
- ...swiperParams
4676
- };
4677
- delete passParams.wrapperClass;
4678
- swiperRef.current = new Swiper$1(passParams);
4679
- if (swiperRef.current.virtual && swiperRef.current.params.virtual.enabled) {
4680
- swiperRef.current.virtual.slides = slides2;
4681
- const extendWith = {
4682
- cache: false,
4683
- slides: slides2,
4684
- renderExternal: setVirtualData,
4685
- renderExternalUpdate: false
4686
- };
4687
- extend(swiperRef.current.params.virtual, extendWith);
4688
- extend(swiperRef.current.originalParams.virtual, extendWith);
4689
- }
4690
- };
4691
- if (!swiperElRef.current) {
4692
- initSwiper();
4693
- }
4694
- if (swiperRef.current) {
4695
- swiperRef.current.on("_beforeBreakpoint", onBeforeBreakpoint);
4696
- }
4697
- const attachEvents2 = () => {
4698
- if (eventsAssigned || !events2 || !swiperRef.current) return;
4699
- Object.keys(events2).forEach((eventName) => {
4700
- swiperRef.current.on(eventName, events2[eventName]);
4701
- });
4702
- };
4703
- const detachEvents2 = () => {
4704
- if (!events2 || !swiperRef.current) return;
4705
- Object.keys(events2).forEach((eventName) => {
4706
- swiperRef.current.off(eventName, events2[eventName]);
4707
- });
4708
- };
4709
- useEffect(() => {
4710
- return () => {
4711
- if (swiperRef.current) swiperRef.current.off("_beforeBreakpoint", onBeforeBreakpoint);
4712
- };
4713
- });
4714
- useEffect(() => {
4715
- if (!initializedRef.current && swiperRef.current) {
4716
- swiperRef.current.emitSlidesClasses();
4717
- initializedRef.current = true;
4718
- }
4719
- });
4720
- useIsomorphicLayoutEffect(() => {
4721
- if (externalElRef) {
4722
- externalElRef.current = swiperElRef.current;
4723
- }
4724
- if (!swiperElRef.current) return;
4725
- if (swiperRef.current.destroyed) {
4726
- initSwiper();
4727
- }
4728
- mountSwiper({
4729
- el: swiperElRef.current,
4730
- nextEl: nextElRef.current,
4731
- prevEl: prevElRef.current,
4732
- paginationEl: paginationElRef.current,
4733
- scrollbarEl: scrollbarElRef.current,
4734
- swiper: swiperRef.current
4735
- }, swiperParams);
4736
- if (onSwiper && !swiperRef.current.destroyed) onSwiper(swiperRef.current);
4737
- return () => {
4738
- if (swiperRef.current && !swiperRef.current.destroyed) {
4739
- swiperRef.current.destroy(true, false);
4740
- }
4741
- };
4742
- }, []);
4743
- useIsomorphicLayoutEffect(() => {
4744
- attachEvents2();
4745
- const changedParams = getChangedParams(passedParams, oldPassedParamsRef.current, slides2, oldSlides.current, (c) => c.key);
4746
- oldPassedParamsRef.current = passedParams;
4747
- oldSlides.current = slides2;
4748
- if (changedParams.length && swiperRef.current && !swiperRef.current.destroyed) {
4749
- updateSwiper({
4750
- swiper: swiperRef.current,
4751
- slides: slides2,
4752
- passedParams,
4753
- changedParams,
4754
- nextEl: nextElRef.current,
4755
- prevEl: prevElRef.current,
4756
- scrollbarEl: scrollbarElRef.current,
4757
- paginationEl: paginationElRef.current
4758
- });
4759
- }
4760
- return () => {
4761
- detachEvents2();
4762
- };
4763
- });
4764
- useIsomorphicLayoutEffect(() => {
4765
- updateOnVirtualData(swiperRef.current);
4766
- }, [virtualData]);
4767
- function renderSlides() {
4768
- if (swiperParams.virtual) {
4769
- return renderVirtual(swiperRef.current, slides2, virtualData);
4770
- }
4771
- return slides2.map((child, index) => {
4772
- return /* @__PURE__ */ React.cloneElement(child, {
4773
- swiper: swiperRef.current,
4774
- swiperSlideIndex: index
4775
- });
4776
- });
4777
- }
4778
- return /* @__PURE__ */ React.createElement(Tag, _extends({
4779
- ref: swiperElRef,
4780
- className: uniqueClasses(`${containerClasses}${className ? ` ${className}` : ""}`)
4781
- }, restProps), /* @__PURE__ */ React.createElement(SwiperContext.Provider, {
4782
- value: swiperRef.current
4783
- }, slots["container-start"], /* @__PURE__ */ React.createElement(WrapperTag, {
4784
- className: wrapperClass(swiperParams.wrapperClass)
4785
- }, slots["wrapper-start"], renderSlides(), slots["wrapper-end"]), needsNavigation(swiperParams) && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
4786
- ref: prevElRef,
4787
- className: "swiper-button-prev"
4788
- }), /* @__PURE__ */ React.createElement("div", {
4789
- ref: nextElRef,
4790
- className: "swiper-button-next"
4791
- })), needsScrollbar(swiperParams) && /* @__PURE__ */ React.createElement("div", {
4792
- ref: scrollbarElRef,
4793
- className: "swiper-scrollbar"
4794
- }), needsPagination(swiperParams) && /* @__PURE__ */ React.createElement("div", {
4795
- ref: paginationElRef,
4796
- className: "swiper-pagination"
4797
- }), slots["container-end"]));
4798
- });
4799
- Swiper2.displayName = "Swiper";
4800
- const SwiperSlide = /* @__PURE__ */ forwardRef(function(_temp, externalRef) {
4801
- let {
4802
- tag: Tag = "div",
4803
- children,
4804
- className = "",
4805
- swiper: swiper2,
4806
- zoom,
4807
- lazy,
4808
- virtualIndex,
4809
- swiperSlideIndex,
4810
- ...rest
4811
- } = _temp === void 0 ? {} : _temp;
4812
- const slideElRef = useRef(null);
4813
- const [slideClasses, setSlideClasses] = useState("swiper-slide");
4814
- const [lazyLoaded, setLazyLoaded] = useState(false);
4815
- function updateClasses(_s, el, classNames2) {
4816
- if (el === slideElRef.current) {
4817
- setSlideClasses(classNames2);
4818
- }
4819
- }
4820
- useIsomorphicLayoutEffect(() => {
4821
- if (typeof swiperSlideIndex !== "undefined") {
4822
- slideElRef.current.swiperSlideIndex = swiperSlideIndex;
4823
- }
4824
- if (externalRef) {
4825
- externalRef.current = slideElRef.current;
4826
- }
4827
- if (!slideElRef.current || !swiper2) {
4828
- return;
4829
- }
4830
- if (swiper2.destroyed) {
4831
- if (slideClasses !== "swiper-slide") {
4832
- setSlideClasses("swiper-slide");
4833
- }
4834
- return;
4835
- }
4836
- swiper2.on("_slideClass", updateClasses);
4837
- return () => {
4838
- if (!swiper2) return;
4839
- swiper2.off("_slideClass", updateClasses);
4840
- };
4841
- });
4842
- useIsomorphicLayoutEffect(() => {
4843
- if (swiper2 && slideElRef.current && !swiper2.destroyed) {
4844
- setSlideClasses(swiper2.getSlideClasses(slideElRef.current));
4845
- }
4846
- }, [swiper2]);
4847
- const slideData = {
4848
- isActive: slideClasses.indexOf("swiper-slide-active") >= 0,
4849
- isVisible: slideClasses.indexOf("swiper-slide-visible") >= 0,
4850
- isPrev: slideClasses.indexOf("swiper-slide-prev") >= 0,
4851
- isNext: slideClasses.indexOf("swiper-slide-next") >= 0
4852
- };
4853
- const renderChildren = () => {
4854
- return typeof children === "function" ? children(slideData) : children;
4855
- };
4856
- const onLoad2 = () => {
4857
- setLazyLoaded(true);
4858
- };
4859
- return /* @__PURE__ */ React.createElement(Tag, _extends({
4860
- ref: slideElRef,
4861
- className: uniqueClasses(`${slideClasses}${className ? ` ${className}` : ""}`),
4862
- "data-swiper-slide-index": virtualIndex,
4863
- onLoad: onLoad2
4864
- }, rest), zoom && /* @__PURE__ */ React.createElement(SwiperSlideContext.Provider, {
4865
- value: slideData
4866
- }, /* @__PURE__ */ React.createElement("div", {
4867
- className: "swiper-zoom-container",
4868
- "data-swiper-zoom": typeof zoom === "number" ? zoom : void 0
4869
- }, renderChildren(), lazy && !lazyLoaded && /* @__PURE__ */ React.createElement("div", {
4870
- className: "swiper-lazy-preloader"
4871
- }))), !zoom && /* @__PURE__ */ React.createElement(SwiperSlideContext.Provider, {
4872
- value: slideData
4873
- }, renderChildren(), lazy && !lazyLoaded && /* @__PURE__ */ React.createElement("div", {
4874
- className: "swiper-lazy-preloader"
4875
- })));
4876
- });
4877
- SwiperSlide.displayName = "SwiperSlide";
4878
- function Autoplay(_ref) {
7
+ import '../../assets/Slider.css';function Autoplay(_ref) {
4879
8
  let {
4880
9
  swiper: swiper2,
4881
10
  extendParams,
@@ -5055,12 +184,12 @@ function Autoplay(_ref) {
5055
184
  };
5056
185
  const onVisibilityChange = () => {
5057
186
  if (swiper2.destroyed || !swiper2.autoplay.running) return;
5058
- const document2 = getDocument();
5059
- if (document2.visibilityState === "hidden") {
187
+ const document = getDocument();
188
+ if (document.visibilityState === "hidden") {
5060
189
  pausedByInteraction = true;
5061
190
  pause(true);
5062
191
  }
5063
- if (document2.visibilityState === "visible") {
192
+ if (document.visibilityState === "visible") {
5064
193
  resume();
5065
194
  }
5066
195
  };
@@ -5091,12 +220,12 @@ function Autoplay(_ref) {
5091
220
  }
5092
221
  };
5093
222
  const attachDocumentEvents = () => {
5094
- const document2 = getDocument();
5095
- document2.addEventListener("visibilitychange", onVisibilityChange);
223
+ const document = getDocument();
224
+ document.addEventListener("visibilitychange", onVisibilityChange);
5096
225
  };
5097
226
  const detachDocumentEvents = () => {
5098
- const document2 = getDocument();
5099
- document2.removeEventListener("visibilitychange", onVisibilityChange);
227
+ const document = getDocument();
228
+ document.removeEventListener("visibilitychange", onVisibilityChange);
5100
229
  };
5101
230
  on("init", () => {
5102
231
  if (swiper2.params.autoplay.enabled) {
@@ -5216,7 +345,7 @@ const Slider = ({
5216
345
  []
5217
346
  );
5218
347
  return /* @__PURE__ */ jsxs(
5219
- Swiper2,
348
+ Swiper,
5220
349
  {
5221
350
  ref: swiperRef,
5222
351
  className: classNames(cls.swiper, swiperClassName),
@@ -5265,33 +394,6 @@ const Slider = ({
5265
394
  }
5266
395
  );
5267
396
  };
5268
- function NavigationButtons() {
5269
- const swiper2 = useSwiper();
5270
- const handleNextSlide = useCallback(() => {
5271
- swiper2.slideNext();
5272
- }, [swiper2]);
5273
- const handlePrevSlide = useCallback(() => {
5274
- swiper2.slidePrev();
5275
- }, [swiper2]);
5276
- const buttons = useMemo(
5277
- () => [
5278
- {
5279
- isIconButton: true,
5280
- iconName: "ArrowLeft16px",
5281
- variant: "gray",
5282
- onClick: handlePrevSlide
5283
- },
5284
- {
5285
- isIconButton: true,
5286
- iconName: "ArrowRight16px",
5287
- variant: "gray",
5288
- onClick: handleNextSlide
5289
- }
5290
- ],
5291
- [handlePrevSlide, handleNextSlide]
5292
- );
5293
- return /* @__PURE__ */ jsx(MergedButton, { buttons });
5294
- }
5295
397
  export {
5296
398
  Slider
5297
399
  };