@gravity-ui/page-constructor 8.13.0-beta.1 → 8.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,9 +28,14 @@ module.exports = __toCommonJS(swiper_exports);
28
28
  function isObject(obj) {
29
29
  return obj !== null && typeof obj === "object" && "constructor" in obj && obj.constructor === Object;
30
30
  }
31
- function extend(target = {}, src = {}) {
32
- const noExtend = ["__proto__", "constructor", "prototype"];
33
- Object.keys(src).filter((key) => noExtend.indexOf(key) < 0).forEach((key) => {
31
+ function extend(target, src) {
32
+ if (target === void 0) {
33
+ target = {};
34
+ }
35
+ if (src === void 0) {
36
+ src = {};
37
+ }
38
+ Object.keys(src).forEach((key) => {
34
39
  if (typeof target[key] === "undefined") target[key] = src[key];
35
40
  else if (isObject(src[key]) && isObject(target[key]) && Object.keys(src[key]).length > 0) {
36
41
  extend(target[key], src[key]);
@@ -169,9 +174,6 @@ function getWindow() {
169
174
  }
170
175
 
171
176
  // node_modules/swiper/shared/utils.mjs
172
- function classesToTokens(classes2 = "") {
173
- return classes2.trim().split(" ").filter((c) => !!c.trim());
174
- }
175
177
  function deleteProps(obj) {
176
178
  const object = obj;
177
179
  Object.keys(object).forEach((key) => {
@@ -185,7 +187,10 @@ function deleteProps(obj) {
185
187
  }
186
188
  });
187
189
  }
188
- function nextTick(callback, delay = 0) {
190
+ function nextTick(callback, delay) {
191
+ if (delay === void 0) {
192
+ delay = 0;
193
+ }
189
194
  return setTimeout(callback, delay);
190
195
  }
191
196
  function now() {
@@ -205,7 +210,10 @@ function getComputedStyle2(el) {
205
210
  }
206
211
  return style;
207
212
  }
208
- function getTranslate(el, axis = "x") {
213
+ function getTranslate(el, axis) {
214
+ if (axis === void 0) {
215
+ axis = "x";
216
+ }
209
217
  const window2 = getWindow();
210
218
  let matrix;
211
219
  let curTransform;
@@ -242,12 +250,13 @@ function isNode(node) {
242
250
  }
243
251
  return node && (node.nodeType === 1 || node.nodeType === 11);
244
252
  }
245
- function extend2(...args) {
246
- const to = Object(args[0]);
247
- for (let i = 1; i < args.length; i += 1) {
248
- const nextSource = args[i];
253
+ function extend2() {
254
+ const to = Object(arguments.length <= 0 ? void 0 : arguments[0]);
255
+ const noExtend = ["__proto__", "constructor", "prototype"];
256
+ for (let i = 1; i < arguments.length; i += 1) {
257
+ const nextSource = i < 0 || arguments.length <= i ? void 0 : arguments[i];
249
258
  if (nextSource !== void 0 && nextSource !== null && !isNode(nextSource)) {
250
- const keysArray = Object.keys(Object(nextSource)).filter((key) => key !== "__proto__" && key !== "constructor" && key !== "prototype");
259
+ const keysArray = Object.keys(Object(nextSource)).filter((key) => noExtend.indexOf(key) < 0);
251
260
  for (let nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) {
252
261
  const nextKey = keysArray[nextIndex];
253
262
  const desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
@@ -277,11 +286,12 @@ function extend2(...args) {
277
286
  function setCSSProperty(el, varName, varValue) {
278
287
  el.style.setProperty(varName, varValue);
279
288
  }
280
- function animateCSSModeScroll({
281
- swiper,
282
- targetPosition,
283
- side
284
- }) {
289
+ function animateCSSModeScroll(_ref) {
290
+ let {
291
+ swiper,
292
+ targetPosition,
293
+ side
294
+ } = _ref;
285
295
  const window2 = getWindow();
286
296
  const startPosition = -swiper.translate;
287
297
  let startTime = null;
@@ -323,49 +333,18 @@ function animateCSSModeScroll({
323
333
  };
324
334
  animate();
325
335
  }
326
- function elementChildren(element, selector = "") {
327
- const window2 = getWindow();
328
- const children = [...element.children];
329
- if (window2.HTMLSlotElement && element instanceof HTMLSlotElement) {
330
- children.push(...element.assignedElements());
331
- }
332
- if (!selector) {
333
- return children;
334
- }
335
- return children.filter((el) => el.matches(selector));
336
- }
337
- function elementIsChildOfSlot(el, slot) {
338
- const elementsQueue = [slot];
339
- while (elementsQueue.length > 0) {
340
- const elementToCheck = elementsQueue.shift();
341
- if (el === elementToCheck) {
342
- return true;
343
- }
344
- elementsQueue.push(...elementToCheck.children, ...elementToCheck.shadowRoot ? elementToCheck.shadowRoot.children : [], ...elementToCheck.assignedElements ? elementToCheck.assignedElements() : []);
345
- }
346
- }
347
- function elementIsChildOf(el, parent) {
348
- const window2 = getWindow();
349
- let isChild = parent.contains(el);
350
- if (!isChild && window2.HTMLSlotElement && parent instanceof HTMLSlotElement) {
351
- const children = [...parent.assignedElements()];
352
- isChild = children.includes(el);
353
- if (!isChild) {
354
- isChild = elementIsChildOfSlot(el, parent);
355
- }
336
+ function elementChildren(element, selector) {
337
+ if (selector === void 0) {
338
+ selector = "";
356
339
  }
357
- return isChild;
340
+ return [...element.children].filter((el) => el.matches(selector));
358
341
  }
359
- function showWarning(text) {
360
- try {
361
- console.warn(text);
362
- return;
363
- } catch (err) {
342
+ function createElement(tag, classes2) {
343
+ if (classes2 === void 0) {
344
+ classes2 = [];
364
345
  }
365
- }
366
- function createElement(tag, classes2 = []) {
367
346
  const el = document.createElement(tag);
368
- el.classList.add(...Array.isArray(classes2) ? classes2 : classesToTokens(classes2));
347
+ el.classList.add(...Array.isArray(classes2) ? classes2 : [classes2]);
369
348
  return el;
370
349
  }
371
350
  function elementPrevAll(el, selector) {
@@ -444,9 +423,10 @@ function getSupport() {
444
423
  return support;
445
424
  }
446
425
  var deviceCached;
447
- function calcDevice({
448
- userAgent
449
- } = {}) {
426
+ function calcDevice(_temp) {
427
+ let {
428
+ userAgent
429
+ } = _temp === void 0 ? {} : _temp;
450
430
  const support2 = getSupport();
451
431
  const window2 = getWindow();
452
432
  const platform = window2.navigator.platform;
@@ -458,7 +438,7 @@ function calcDevice({
458
438
  const screenWidth = window2.screen.width;
459
439
  const screenHeight = window2.screen.height;
460
440
  const android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
461
- let ipad = ua.match(/(iPad)(?!\1).*OS\s([\d_]+)/);
441
+ let ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
462
442
  const ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
463
443
  const iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/);
464
444
  const windows = platform === "Win32";
@@ -479,7 +459,10 @@ function calcDevice({
479
459
  }
480
460
  return device;
481
461
  }
482
- function getDevice(overrides = {}) {
462
+ function getDevice(overrides) {
463
+ if (overrides === void 0) {
464
+ overrides = {};
465
+ }
483
466
  if (!deviceCached) {
484
467
  deviceCached = calcDevice(overrides);
485
468
  }
@@ -488,7 +471,6 @@ function getDevice(overrides = {}) {
488
471
  var browser;
489
472
  function calcBrowser() {
490
473
  const window2 = getWindow();
491
- const device = getDevice();
492
474
  let needPerspectiveFix = false;
493
475
  function isSafari() {
494
476
  const ua = window2.navigator.userAgent.toLowerCase();
@@ -501,14 +483,10 @@ function calcBrowser() {
501
483
  needPerspectiveFix = major < 16 || major === 16 && minor < 2;
502
484
  }
503
485
  }
504
- const isWebView = /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window2.navigator.userAgent);
505
- const isSafariBrowser = isSafari();
506
- const need3dFix = isSafariBrowser || isWebView && device.ios;
507
486
  return {
508
- isSafari: needPerspectiveFix || isSafariBrowser,
487
+ isSafari: needPerspectiveFix || isSafari(),
509
488
  needPerspectiveFix,
510
- need3dFix,
511
- isWebView
489
+ isWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window2.navigator.userAgent)
512
490
  };
513
491
  }
514
492
  function getBrowser() {
@@ -517,11 +495,12 @@ function getBrowser() {
517
495
  }
518
496
  return browser;
519
497
  }
520
- function Resize({
521
- swiper,
522
- on,
523
- emit
524
- }) {
498
+ function Resize(_ref) {
499
+ let {
500
+ swiper,
501
+ on,
502
+ emit
503
+ } = _ref;
525
504
  const window2 = getWindow();
526
505
  let observer = null;
527
506
  let animationFrame = null;
@@ -540,11 +519,12 @@ function Resize({
540
519
  } = swiper;
541
520
  let newWidth = width;
542
521
  let newHeight = height;
543
- entries.forEach(({
544
- contentBoxSize,
545
- contentRect,
546
- target
547
- }) => {
522
+ entries.forEach((_ref2) => {
523
+ let {
524
+ contentBoxSize,
525
+ contentRect,
526
+ target
527
+ } = _ref2;
548
528
  if (target && target !== swiper.el) return;
549
529
  newWidth = contentRect ? contentRect.width : (contentBoxSize[0] || contentBoxSize).inlineSize;
550
530
  newHeight = contentRect ? contentRect.height : (contentBoxSize[0] || contentBoxSize).blockSize;
@@ -583,15 +563,19 @@ function Resize({
583
563
  window2.removeEventListener("orientationchange", orientationChangeHandler);
584
564
  });
585
565
  }
586
- function Observer({
587
- swiper,
588
- extendParams,
589
- on,
590
- emit
591
- }) {
566
+ function Observer(_ref) {
567
+ let {
568
+ swiper,
569
+ extendParams,
570
+ on,
571
+ emit
572
+ } = _ref;
592
573
  const observers = [];
593
574
  const window2 = getWindow();
594
- const attach = (target, options = {}) => {
575
+ const attach = function(target, options) {
576
+ if (options === void 0) {
577
+ options = {};
578
+ }
595
579
  const ObserverFunc = window2.MutationObserver || window2.WebkitMutationObserver;
596
580
  const observer = new ObserverFunc((mutations) => {
597
581
  if (swiper.__preventObserver__) return;
@@ -610,7 +594,7 @@ function Observer({
610
594
  });
611
595
  observer.observe(target, {
612
596
  attributes: typeof options.attributes === "undefined" ? true : options.attributes,
613
- childList: swiper.isElement || (typeof options.childList === "undefined" ? true : options).childList,
597
+ childList: typeof options.childList === "undefined" ? true : options.childList,
614
598
  characterData: typeof options.characterData === "undefined" ? true : options.characterData
615
599
  });
616
600
  observers.push(observer);
@@ -660,11 +644,14 @@ var eventsEmitter = {
660
644
  const self = this;
661
645
  if (!self.eventsListeners || self.destroyed) return self;
662
646
  if (typeof handler !== "function") return self;
663
- function onceHandler(...args) {
647
+ function onceHandler() {
664
648
  self.off(events2, onceHandler);
665
649
  if (onceHandler.__emitterProxy) {
666
650
  delete onceHandler.__emitterProxy;
667
651
  }
652
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
653
+ args[_key] = arguments[_key];
654
+ }
668
655
  handler.apply(self, args);
669
656
  }
670
657
  onceHandler.__emitterProxy = handler;
@@ -707,13 +694,16 @@ var eventsEmitter = {
707
694
  });
708
695
  return self;
709
696
  },
710
- emit(...args) {
697
+ emit() {
711
698
  const self = this;
712
699
  if (!self.eventsListeners || self.destroyed) return self;
713
700
  if (!self.eventsListeners) return self;
714
701
  let events2;
715
702
  let data;
716
703
  let context;
704
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
705
+ args[_key2] = arguments[_key2];
706
+ }
717
707
  if (typeof args[0] === "string" || Array.isArray(args[0])) {
718
708
  events2 = args[0];
719
709
  data = args.slice(1, args.length);
@@ -770,13 +760,29 @@ function updateSize() {
770
760
  }
771
761
  function updateSlides() {
772
762
  const swiper = this;
763
+ function getDirectionLabel(property) {
764
+ if (swiper.isHorizontal()) {
765
+ return property;
766
+ }
767
+ return {
768
+ "width": "height",
769
+ "margin-top": "margin-left",
770
+ "margin-bottom ": "margin-right",
771
+ "margin-left": "margin-top",
772
+ "margin-right": "margin-bottom",
773
+ "padding-left": "padding-top",
774
+ "padding-right": "padding-bottom",
775
+ "marginRight": "marginBottom"
776
+ }[property];
777
+ }
773
778
  function getDirectionPropertyValue(node, label) {
774
- return parseFloat(node.getPropertyValue(swiper.getDirectionLabel(label)) || 0);
779
+ return parseFloat(node.getPropertyValue(getDirectionLabel(label)) || 0);
775
780
  }
776
781
  const params = swiper.params;
777
782
  const {
778
783
  wrapperEl,
779
784
  slidesEl,
785
+ size: swiperSize,
780
786
  rtlTranslate: rtl,
781
787
  wrongRTL
782
788
  } = swiper;
@@ -797,7 +803,6 @@ function updateSlides() {
797
803
  }
798
804
  const previousSnapGridLength = swiper.snapGrid.length;
799
805
  const previousSlidesGridLength = swiper.slidesGrid.length;
800
- const swiperSize = swiper.size - offsetBefore - offsetAfter;
801
806
  let spaceBetween = params.spaceBetween;
802
807
  let slidePosition = -offsetBefore;
803
808
  let prevSlideSize = 0;
@@ -810,7 +815,7 @@ function updateSlides() {
810
815
  } else if (typeof spaceBetween === "string") {
811
816
  spaceBetween = parseFloat(spaceBetween);
812
817
  }
813
- swiper.virtualSize = -spaceBetween - offsetBefore - offsetAfter;
818
+ swiper.virtualSize = -spaceBetween;
814
819
  slides.forEach((slideEl) => {
815
820
  if (rtl) {
816
821
  slideEl.style.marginLeft = "";
@@ -824,15 +829,9 @@ function updateSlides() {
824
829
  setCSSProperty(wrapperEl, "--swiper-centered-offset-before", "");
825
830
  setCSSProperty(wrapperEl, "--swiper-centered-offset-after", "");
826
831
  }
827
- if (params.cssMode) {
828
- setCSSProperty(wrapperEl, "--swiper-slides-offset-before", `${offsetBefore}px`);
829
- setCSSProperty(wrapperEl, "--swiper-slides-offset-after", `${offsetAfter}px`);
830
- }
831
832
  const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid;
832
833
  if (gridEnabled) {
833
- swiper.grid.initSlides(slides);
834
- } else if (swiper.grid) {
835
- swiper.grid.unsetSlides();
834
+ swiper.grid.initSlides(slidesLength);
836
835
  }
837
836
  let slideSize;
838
837
  const shouldResetSlideSize = params.slidesPerView === "auto" && params.breakpoints && Object.keys(params.breakpoints).filter((key) => {
@@ -840,24 +839,15 @@ function updateSlides() {
840
839
  }).length > 0;
841
840
  for (let i = 0; i < slidesLength; i += 1) {
842
841
  slideSize = 0;
843
- const slide2 = slides[i];
844
- if (slide2) {
845
- if (gridEnabled) {
846
- swiper.grid.updateSlide(i, slide2, slides);
847
- }
848
- if (elementStyle(slide2, "display") === "none") continue;
842
+ let slide2;
843
+ if (slides[i]) slide2 = slides[i];
844
+ if (gridEnabled) {
845
+ swiper.grid.updateSlide(i, slide2, slidesLength, getDirectionLabel);
849
846
  }
850
- if (isVirtual && params.slidesPerView === "auto") {
851
- if (params.virtual.slidesPerViewAutoSlideSize) {
852
- slideSize = params.virtual.slidesPerViewAutoSlideSize;
853
- }
854
- if (slideSize && slide2) {
855
- if (params.roundLengths) slideSize = Math.floor(slideSize);
856
- slide2.style[swiper.getDirectionLabel("width")] = `${slideSize}px`;
857
- }
858
- } else if (params.slidesPerView === "auto") {
847
+ if (slides[i] && elementStyle(slide2, "display") === "none") continue;
848
+ if (params.slidesPerView === "auto") {
859
849
  if (shouldResetSlideSize) {
860
- slide2.style[swiper.getDirectionLabel("width")] = ``;
850
+ slides[i].style[getDirectionLabel("width")] = ``;
861
851
  }
862
852
  const slideStyles = getComputedStyle(slide2);
863
853
  const currentTransform = slide2.style.transform;
@@ -897,12 +887,12 @@ function updateSlides() {
897
887
  } else {
898
888
  slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
899
889
  if (params.roundLengths) slideSize = Math.floor(slideSize);
900
- if (slide2) {
901
- slide2.style[swiper.getDirectionLabel("width")] = `${slideSize}px`;
890
+ if (slides[i]) {
891
+ slides[i].style[getDirectionLabel("width")] = `${slideSize}px`;
902
892
  }
903
893
  }
904
- if (slide2) {
905
- slide2.swiperSlideSize = slideSize;
894
+ if (slides[i]) {
895
+ slides[i].swiperSlideSize = slideSize;
906
896
  }
907
897
  slidesSizesGrid.push(slideSize);
908
898
  if (params.centeredSlides) {
@@ -928,50 +918,23 @@ function updateSlides() {
928
918
  wrapperEl.style.width = `${swiper.virtualSize + spaceBetween}px`;
929
919
  }
930
920
  if (params.setWrapperSize) {
931
- wrapperEl.style[swiper.getDirectionLabel("width")] = `${swiper.virtualSize + spaceBetween}px`;
921
+ wrapperEl.style[getDirectionLabel("width")] = `${swiper.virtualSize + spaceBetween}px`;
932
922
  }
933
923
  if (gridEnabled) {
934
- swiper.grid.updateWrapperSize(slideSize, snapGrid);
924
+ swiper.grid.updateWrapperSize(slideSize, snapGrid, getDirectionLabel);
935
925
  }
936
926
  if (!params.centeredSlides) {
937
- const isFractionalSlidesPerView = params.slidesPerView !== "auto" && params.slidesPerView % 1 !== 0;
938
- const shouldSnapToSlideEdge = params.snapToSlideEdge && !params.loop && (params.slidesPerView === "auto" || isFractionalSlidesPerView);
939
- let lastAllowedSnapIndex = snapGrid.length;
940
- if (shouldSnapToSlideEdge) {
941
- let minVisibleSlides;
942
- if (params.slidesPerView === "auto") {
943
- minVisibleSlides = 1;
944
- let accumulatedSize = 0;
945
- for (let i = slidesSizesGrid.length - 1; i >= 0; i -= 1) {
946
- accumulatedSize += slidesSizesGrid[i] + (i < slidesSizesGrid.length - 1 ? spaceBetween : 0);
947
- if (accumulatedSize <= swiperSize) {
948
- minVisibleSlides = slidesSizesGrid.length - i;
949
- } else {
950
- break;
951
- }
952
- }
953
- } else {
954
- minVisibleSlides = Math.floor(params.slidesPerView);
955
- }
956
- lastAllowedSnapIndex = Math.max(slidesLength - minVisibleSlides, 0);
957
- }
958
927
  const newSlidesGrid = [];
959
928
  for (let i = 0; i < snapGrid.length; i += 1) {
960
929
  let slidesGridItem = snapGrid[i];
961
930
  if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
962
- if (shouldSnapToSlideEdge) {
963
- if (i <= lastAllowedSnapIndex) {
964
- newSlidesGrid.push(slidesGridItem);
965
- }
966
- } else if (snapGrid[i] <= swiper.virtualSize - swiperSize) {
931
+ if (snapGrid[i] <= swiper.virtualSize - swiperSize) {
967
932
  newSlidesGrid.push(slidesGridItem);
968
933
  }
969
934
  }
970
935
  snapGrid = newSlidesGrid;
971
936
  if (Math.floor(swiper.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
972
- if (!shouldSnapToSlideEdge) {
973
- snapGrid.push(swiper.virtualSize - swiperSize);
974
- }
937
+ snapGrid.push(swiper.virtualSize - swiperSize);
975
938
  }
976
939
  }
977
940
  if (isVirtual && params.loop) {
@@ -993,7 +956,7 @@ function updateSlides() {
993
956
  }
994
957
  if (snapGrid.length === 0) snapGrid = [0];
995
958
  if (spaceBetween !== 0) {
996
- const key = swiper.isHorizontal() && rtl ? "marginLeft" : swiper.getDirectionLabel("marginRight");
959
+ const key = swiper.isHorizontal() && rtl ? "marginLeft" : getDirectionLabel("marginRight");
997
960
  slides.filter((_, slideIndex) => {
998
961
  if (!params.cssMode || params.loop) return true;
999
962
  if (slideIndex === slides.length - 1) {
@@ -1010,7 +973,7 @@ function updateSlides() {
1010
973
  allSlidesSize += slideSizeValue + (spaceBetween || 0);
1011
974
  });
1012
975
  allSlidesSize -= spaceBetween;
1013
- const maxSnap = allSlidesSize > swiperSize ? allSlidesSize - swiperSize : 0;
976
+ const maxSnap = allSlidesSize - swiperSize;
1014
977
  snapGrid = snapGrid.map((snap) => {
1015
978
  if (snap <= 0) return -offsetBefore;
1016
979
  if (snap > maxSnap) return maxSnap + offsetAfter;
@@ -1060,7 +1023,6 @@ function updateSlides() {
1060
1023
  if (params.watchSlidesProgress) {
1061
1024
  swiper.updateSlidesOffset();
1062
1025
  }
1063
- swiper.emit("slidesUpdated");
1064
1026
  if (!isVirtual && !params.cssMode && (params.effect === "slide" || params.effect === "fade")) {
1065
1027
  const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`;
1066
1028
  const hasClassBackfaceClassAdded = swiper.el.classList.contains(backFaceHiddenClass);
@@ -1119,14 +1081,10 @@ function updateSlidesOffset() {
1119
1081
  slides[i].swiperSlideOffset = (swiper.isHorizontal() ? slides[i].offsetLeft : slides[i].offsetTop) - minusOffset - swiper.cssOverflowAdjustment();
1120
1082
  }
1121
1083
  }
1122
- var toggleSlideClasses$1 = (slideEl, condition, className) => {
1123
- if (condition && !slideEl.classList.contains(className)) {
1124
- slideEl.classList.add(className);
1125
- } else if (!condition && slideEl.classList.contains(className)) {
1126
- slideEl.classList.remove(className);
1084
+ function updateSlidesProgress(translate2) {
1085
+ if (translate2 === void 0) {
1086
+ translate2 = this && this.translate || 0;
1127
1087
  }
1128
- };
1129
- function updateSlidesProgress(translate2 = this && this.translate || 0) {
1130
1088
  const swiper = this;
1131
1089
  const params = swiper.params;
1132
1090
  const {
@@ -1138,6 +1096,9 @@ function updateSlidesProgress(translate2 = this && this.translate || 0) {
1138
1096
  if (typeof slides[0].swiperSlideOffset === "undefined") swiper.updateSlidesOffset();
1139
1097
  let offsetCenter = -translate2;
1140
1098
  if (rtl) offsetCenter = translate2;
1099
+ slides.forEach((slideEl) => {
1100
+ slideEl.classList.remove(params.slideVisibleClass);
1101
+ });
1141
1102
  swiper.visibleSlidesIndexes = [];
1142
1103
  swiper.visibleSlides = [];
1143
1104
  let spaceBetween = params.spaceBetween;
@@ -1156,14 +1117,12 @@ function updateSlidesProgress(translate2 = this && this.translate || 0) {
1156
1117
  const originalSlideProgress = (offsetCenter - snapGrid[0] + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide2.swiperSlideSize + spaceBetween);
1157
1118
  const slideBefore = -(offsetCenter - slideOffset);
1158
1119
  const slideAfter = slideBefore + swiper.slidesSizesGrid[i];
1159
- const isFullyVisible = slideBefore >= 0 && slideBefore <= swiper.size - swiper.slidesSizesGrid[i];
1160
1120
  const isVisible = slideBefore >= 0 && slideBefore < swiper.size - 1 || slideAfter > 1 && slideAfter <= swiper.size || slideBefore <= 0 && slideAfter >= swiper.size;
1161
1121
  if (isVisible) {
1162
1122
  swiper.visibleSlides.push(slide2);
1163
1123
  swiper.visibleSlidesIndexes.push(i);
1124
+ slides[i].classList.add(params.slideVisibleClass);
1164
1125
  }
1165
- toggleSlideClasses$1(slide2, isVisible, params.slideVisibleClass);
1166
- toggleSlideClasses$1(slide2, isFullyVisible, params.slideFullyVisibleClass);
1167
1126
  slide2.progress = rtl ? -slideProgress : slideProgress;
1168
1127
  slide2.originalProgress = rtl ? -originalSlideProgress : originalSlideProgress;
1169
1128
  }
@@ -1229,13 +1188,6 @@ function updateProgress(translate2) {
1229
1188
  }
1230
1189
  swiper.emit("progress", progress);
1231
1190
  }
1232
- var toggleSlideClasses = (slideEl, condition, className) => {
1233
- if (condition && !slideEl.classList.contains(className)) {
1234
- slideEl.classList.add(className);
1235
- } else if (!condition && slideEl.classList.contains(className)) {
1236
- slideEl.classList.remove(className);
1237
- }
1238
- };
1239
1191
  function updateSlidesClasses() {
1240
1192
  const swiper = this;
1241
1193
  const {
@@ -1245,13 +1197,13 @@ function updateSlidesClasses() {
1245
1197
  activeIndex
1246
1198
  } = swiper;
1247
1199
  const isVirtual = swiper.virtual && params.virtual.enabled;
1248
- const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
1249
1200
  const getFilteredSlide = (selector) => {
1250
1201
  return elementChildren(slidesEl, `.${params.slideClass}${selector}, swiper-slide${selector}`)[0];
1251
1202
  };
1203
+ slides.forEach((slideEl) => {
1204
+ slideEl.classList.remove(params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
1205
+ });
1252
1206
  let activeSlide;
1253
- let prevSlide;
1254
- let nextSlide;
1255
1207
  if (isVirtual) {
1256
1208
  if (params.loop) {
1257
1209
  let slideIndex = activeIndex - swiper.virtual.slidesBefore;
@@ -1262,31 +1214,25 @@ function updateSlidesClasses() {
1262
1214
  activeSlide = getFilteredSlide(`[data-swiper-slide-index="${activeIndex}"]`);
1263
1215
  }
1264
1216
  } else {
1265
- if (gridEnabled) {
1266
- activeSlide = slides.find((slideEl) => slideEl.column === activeIndex);
1267
- nextSlide = slides.find((slideEl) => slideEl.column === activeIndex + 1);
1268
- prevSlide = slides.find((slideEl) => slideEl.column === activeIndex - 1);
1269
- } else {
1270
- activeSlide = slides[activeIndex];
1271
- }
1217
+ activeSlide = slides[activeIndex];
1272
1218
  }
1273
1219
  if (activeSlide) {
1274
- if (!gridEnabled) {
1275
- nextSlide = elementNextAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
1276
- if (params.loop && !nextSlide) {
1277
- nextSlide = slides[0];
1278
- }
1279
- prevSlide = elementPrevAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
1280
- if (params.loop && !prevSlide === 0) {
1281
- prevSlide = slides[slides.length - 1];
1282
- }
1220
+ activeSlide.classList.add(params.slideActiveClass);
1221
+ let nextSlide = elementNextAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
1222
+ if (params.loop && !nextSlide) {
1223
+ nextSlide = slides[0];
1224
+ }
1225
+ if (nextSlide) {
1226
+ nextSlide.classList.add(params.slideNextClass);
1227
+ }
1228
+ let prevSlide = elementPrevAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
1229
+ if (params.loop && !prevSlide === 0) {
1230
+ prevSlide = slides[slides.length - 1];
1231
+ }
1232
+ if (prevSlide) {
1233
+ prevSlide.classList.add(params.slidePrevClass);
1283
1234
  }
1284
1235
  }
1285
- slides.forEach((slideEl) => {
1286
- toggleSlideClasses(slideEl, slideEl === activeSlide, params.slideActiveClass);
1287
- toggleSlideClasses(slideEl, slideEl === nextSlide, params.slideNextClass);
1288
- toggleSlideClasses(slideEl, slideEl === prevSlide, params.slidePrevClass);
1289
- });
1290
1236
  swiper.emitSlidesClasses();
1291
1237
  }
1292
1238
  var processLazyPreloader = (swiper, imageEl) => {
@@ -1302,12 +1248,12 @@ var processLazyPreloader = (swiper, imageEl) => {
1302
1248
  requestAnimationFrame(() => {
1303
1249
  if (slideEl.shadowRoot) {
1304
1250
  lazyEl = slideEl.shadowRoot.querySelector(`.${swiper.params.lazyPreloaderClass}`);
1305
- if (lazyEl && !lazyEl.lazyPreloaderManaged) lazyEl.remove();
1251
+ if (lazyEl) lazyEl.remove();
1306
1252
  }
1307
1253
  });
1308
1254
  }
1309
1255
  }
1310
- if (lazyEl && !lazyEl.lazyPreloaderManaged) lazyEl.remove();
1256
+ if (lazyEl) lazyEl.remove();
1311
1257
  }
1312
1258
  };
1313
1259
  var unlazy = (swiper, index) => {
@@ -1405,39 +1351,21 @@ function updateActiveIndex(newActiveIndex) {
1405
1351
  snapIndex = skip + Math.floor((activeIndex - skip) / params.slidesPerGroup);
1406
1352
  }
1407
1353
  if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
1408
- if (activeIndex === previousIndex && !swiper.params.loop) {
1354
+ if (activeIndex === previousIndex) {
1409
1355
  if (snapIndex !== previousSnapIndex) {
1410
1356
  swiper.snapIndex = snapIndex;
1411
1357
  swiper.emit("snapIndexChange");
1412
1358
  }
1359
+ if (swiper.params.loop && swiper.virtual && swiper.params.virtual.enabled) {
1360
+ swiper.realIndex = getVirtualRealIndex(activeIndex);
1361
+ }
1413
1362
  return;
1414
1363
  }
1415
- if (activeIndex === previousIndex && swiper.params.loop && swiper.virtual && swiper.params.virtual.enabled) {
1416
- swiper.realIndex = getVirtualRealIndex(activeIndex);
1417
- return;
1418
- }
1419
- const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
1420
1364
  let realIndex;
1421
- if (swiper.virtual && params.virtual.enabled) {
1422
- if (params.loop) {
1423
- realIndex = getVirtualRealIndex(activeIndex);
1424
- } else {
1425
- realIndex = activeIndex;
1426
- }
1427
- } else if (gridEnabled) {
1428
- const firstSlideInColumn = swiper.slides.find((slideEl) => slideEl.column === activeIndex);
1429
- let activeSlideIndex = parseInt(firstSlideInColumn.getAttribute("data-swiper-slide-index"), 10);
1430
- if (Number.isNaN(activeSlideIndex)) {
1431
- activeSlideIndex = Math.max(swiper.slides.indexOf(firstSlideInColumn), 0);
1432
- }
1433
- realIndex = Math.floor(activeSlideIndex / params.grid.rows);
1365
+ if (swiper.virtual && params.virtual.enabled && params.loop) {
1366
+ realIndex = getVirtualRealIndex(activeIndex);
1434
1367
  } else if (swiper.slides[activeIndex]) {
1435
- const slideIndex = swiper.slides[activeIndex].getAttribute("data-swiper-slide-index");
1436
- if (slideIndex) {
1437
- realIndex = parseInt(slideIndex, 10);
1438
- } else {
1439
- realIndex = activeIndex;
1440
- }
1368
+ realIndex = parseInt(swiper.slides[activeIndex].getAttribute("data-swiper-slide-index") || activeIndex, 10);
1441
1369
  } else {
1442
1370
  realIndex = activeIndex;
1443
1371
  }
@@ -1510,7 +1438,10 @@ var update = {
1510
1438
  updateActiveIndex,
1511
1439
  updateClickedSlide
1512
1440
  };
1513
- function getSwiperTranslate(axis = this.isHorizontal() ? "x" : "y") {
1441
+ function getSwiperTranslate(axis) {
1442
+ if (axis === void 0) {
1443
+ axis = this.isHorizontal() ? "x" : "y";
1444
+ }
1514
1445
  const swiper = this;
1515
1446
  const {
1516
1447
  params,
@@ -1579,7 +1510,19 @@ function minTranslate() {
1579
1510
  function maxTranslate() {
1580
1511
  return -this.snapGrid[this.snapGrid.length - 1];
1581
1512
  }
1582
- function translateTo(translate2 = 0, speed = this.params.speed, runCallbacks = true, translateBounds = true, internal) {
1513
+ function translateTo(translate2, speed, runCallbacks, translateBounds, internal) {
1514
+ if (translate2 === void 0) {
1515
+ translate2 = 0;
1516
+ }
1517
+ if (speed === void 0) {
1518
+ speed = this.params.speed;
1519
+ }
1520
+ if (runCallbacks === void 0) {
1521
+ runCallbacks = true;
1522
+ }
1523
+ if (translateBounds === void 0) {
1524
+ translateBounds = true;
1525
+ }
1583
1526
  const swiper = this;
1584
1527
  const {
1585
1528
  params,
@@ -1638,7 +1581,6 @@ function translateTo(translate2 = 0, speed = this.params.speed, runCallbacks = t
1638
1581
  swiper.wrapperEl.removeEventListener("transitionend", swiper.onTranslateToWrapperTransitionEnd);
1639
1582
  swiper.onTranslateToWrapperTransitionEnd = null;
1640
1583
  delete swiper.onTranslateToWrapperTransitionEnd;
1641
- swiper.animating = false;
1642
1584
  if (runCallbacks) {
1643
1585
  swiper.emit("transitionEnd");
1644
1586
  }
@@ -1664,12 +1606,13 @@ function setTransition(duration, byController) {
1664
1606
  }
1665
1607
  swiper.emit("setTransition", duration, byController);
1666
1608
  }
1667
- function transitionEmit({
1668
- swiper,
1669
- runCallbacks,
1670
- direction,
1671
- step
1672
- }) {
1609
+ function transitionEmit(_ref) {
1610
+ let {
1611
+ swiper,
1612
+ runCallbacks,
1613
+ direction,
1614
+ step
1615
+ } = _ref;
1673
1616
  const {
1674
1617
  activeIndex,
1675
1618
  previousIndex
@@ -1681,9 +1624,11 @@ function transitionEmit({
1681
1624
  else dir = "reset";
1682
1625
  }
1683
1626
  swiper.emit(`transition${step}`);
1684
- if (runCallbacks && dir === "reset") {
1685
- swiper.emit(`slideResetTransition${step}`);
1686
- } else if (runCallbacks && activeIndex !== previousIndex) {
1627
+ if (runCallbacks && activeIndex !== previousIndex) {
1628
+ if (dir === "reset") {
1629
+ swiper.emit(`slideResetTransition${step}`);
1630
+ return;
1631
+ }
1687
1632
  swiper.emit(`slideChangeTransition${step}`);
1688
1633
  if (dir === "next") {
1689
1634
  swiper.emit(`slideNextTransition${step}`);
@@ -1692,7 +1637,10 @@ function transitionEmit({
1692
1637
  }
1693
1638
  }
1694
1639
  }
1695
- function transitionStart(runCallbacks = true, direction) {
1640
+ function transitionStart(runCallbacks, direction) {
1641
+ if (runCallbacks === void 0) {
1642
+ runCallbacks = true;
1643
+ }
1696
1644
  const swiper = this;
1697
1645
  const {
1698
1646
  params
@@ -1708,7 +1656,10 @@ function transitionStart(runCallbacks = true, direction) {
1708
1656
  step: "Start"
1709
1657
  });
1710
1658
  }
1711
- function transitionEnd(runCallbacks = true, direction) {
1659
+ function transitionEnd(runCallbacks, direction) {
1660
+ if (runCallbacks === void 0) {
1661
+ runCallbacks = true;
1662
+ }
1712
1663
  const swiper = this;
1713
1664
  const {
1714
1665
  params
@@ -1728,7 +1679,16 @@ var transition = {
1728
1679
  transitionStart,
1729
1680
  transitionEnd
1730
1681
  };
1731
- function slideTo(index = 0, speed, runCallbacks = true, internal, initial) {
1682
+ function slideTo(index, speed, runCallbacks, internal, initial) {
1683
+ if (index === void 0) {
1684
+ index = 0;
1685
+ }
1686
+ if (speed === void 0) {
1687
+ speed = this.params.speed;
1688
+ }
1689
+ if (runCallbacks === void 0) {
1690
+ runCallbacks = true;
1691
+ }
1732
1692
  if (typeof index === "string") {
1733
1693
  index = parseInt(index, 10);
1734
1694
  }
@@ -1745,12 +1705,9 @@ function slideTo(index = 0, speed, runCallbacks = true, internal, initial) {
1745
1705
  wrapperEl,
1746
1706
  enabled
1747
1707
  } = swiper;
1748
- if (!enabled && !internal && !initial || swiper.destroyed || swiper.animating && params.preventInteractionOnTransition) {
1708
+ if (swiper.animating && params.preventInteractionOnTransition || !enabled && !internal && !initial) {
1749
1709
  return false;
1750
1710
  }
1751
- if (typeof speed === "undefined") {
1752
- speed = swiper.params.speed;
1753
- }
1754
1711
  const skip = Math.min(swiper.params.slidesPerGroupSkip, slideIndex);
1755
1712
  let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
1756
1713
  if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
@@ -1789,9 +1746,7 @@ function slideTo(index = 0, speed, runCallbacks = true, internal, initial) {
1789
1746
  if (slideIndex > activeIndex) direction = "next";
1790
1747
  else if (slideIndex < activeIndex) direction = "prev";
1791
1748
  else direction = "reset";
1792
- const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
1793
- const isInitialVirtual = isVirtual && initial;
1794
- if (!isInitialVirtual && (rtl && -translate2 === swiper.translate || !rtl && translate2 === swiper.translate)) {
1749
+ if (rtl && -translate2 === swiper.translate || !rtl && translate2 === swiper.translate) {
1795
1750
  swiper.updateActiveIndex(slideIndex);
1796
1751
  if (params.autoHeight) {
1797
1752
  swiper.updateAutoHeight();
@@ -1810,6 +1765,7 @@ function slideTo(index = 0, speed, runCallbacks = true, internal, initial) {
1810
1765
  const isH = swiper.isHorizontal();
1811
1766
  const t = rtl ? translate2 : -translate2;
1812
1767
  if (speed === 0) {
1768
+ const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
1813
1769
  if (isVirtual) {
1814
1770
  swiper.wrapperEl.style.scrollSnapType = "none";
1815
1771
  swiper._immediateVirtual = true;
@@ -1844,11 +1800,6 @@ function slideTo(index = 0, speed, runCallbacks = true, internal, initial) {
1844
1800
  }
1845
1801
  return true;
1846
1802
  }
1847
- const browser2 = getBrowser();
1848
- const isSafari = browser2.isSafari;
1849
- if (isVirtual && !initial && isSafari && swiper.isElement) {
1850
- swiper.virtual.update(false, false, slideIndex);
1851
- }
1852
1803
  swiper.setTransition(speed);
1853
1804
  swiper.setTranslate(translate2);
1854
1805
  swiper.updateActiveIndex(slideIndex);
@@ -1873,85 +1824,45 @@ function slideTo(index = 0, speed, runCallbacks = true, internal, initial) {
1873
1824
  }
1874
1825
  return true;
1875
1826
  }
1876
- function slideToLoop(index = 0, speed, runCallbacks = true, internal) {
1827
+ function slideToLoop(index, speed, runCallbacks, internal) {
1828
+ if (index === void 0) {
1829
+ index = 0;
1830
+ }
1831
+ if (speed === void 0) {
1832
+ speed = this.params.speed;
1833
+ }
1834
+ if (runCallbacks === void 0) {
1835
+ runCallbacks = true;
1836
+ }
1877
1837
  if (typeof index === "string") {
1878
1838
  const indexAsNumber = parseInt(index, 10);
1879
1839
  index = indexAsNumber;
1880
1840
  }
1881
1841
  const swiper = this;
1882
- if (swiper.destroyed) return;
1883
- if (typeof speed === "undefined") {
1884
- speed = swiper.params.speed;
1885
- }
1886
- const gridEnabled = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1;
1887
1842
  let newIndex = index;
1888
1843
  if (swiper.params.loop) {
1889
1844
  if (swiper.virtual && swiper.params.virtual.enabled) {
1890
1845
  newIndex = newIndex + swiper.virtual.slidesBefore;
1891
1846
  } else {
1892
- let targetSlideIndex;
1893
- if (gridEnabled) {
1894
- const slideIndex = newIndex * swiper.params.grid.rows;
1895
- targetSlideIndex = swiper.slides.find((slideEl) => slideEl.getAttribute("data-swiper-slide-index") * 1 === slideIndex).column;
1896
- } else {
1897
- targetSlideIndex = swiper.getSlideIndexByData(newIndex);
1898
- }
1899
- const cols = gridEnabled ? Math.ceil(swiper.slides.length / swiper.params.grid.rows) : swiper.slides.length;
1900
- const {
1901
- centeredSlides,
1902
- slidesOffsetBefore,
1903
- slidesOffsetAfter
1904
- } = swiper.params;
1905
- const bothDirections = centeredSlides || !!slidesOffsetBefore || !!slidesOffsetAfter;
1906
- let slidesPerView = swiper.params.slidesPerView;
1907
- if (slidesPerView === "auto") {
1908
- slidesPerView = swiper.slidesPerViewDynamic();
1909
- } else {
1910
- slidesPerView = Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
1911
- if (bothDirections && slidesPerView % 2 === 0) {
1912
- slidesPerView = slidesPerView + 1;
1913
- }
1914
- }
1915
- let needLoopFix = cols - targetSlideIndex < slidesPerView;
1916
- if (bothDirections) {
1917
- needLoopFix = needLoopFix || targetSlideIndex < Math.ceil(slidesPerView / 2);
1918
- }
1919
- if (internal && bothDirections && swiper.params.slidesPerView !== "auto" && !gridEnabled) {
1920
- needLoopFix = false;
1921
- }
1922
- if (needLoopFix) {
1923
- const direction = bothDirections ? targetSlideIndex < swiper.activeIndex ? "prev" : "next" : targetSlideIndex - swiper.activeIndex - 1 < swiper.params.slidesPerView ? "next" : "prev";
1924
- swiper.loopFix({
1925
- direction,
1926
- slideTo: true,
1927
- activeSlideIndex: direction === "next" ? targetSlideIndex + 1 : targetSlideIndex - cols + 1,
1928
- slideRealIndex: direction === "next" ? swiper.realIndex : void 0
1929
- });
1930
- }
1931
- if (gridEnabled) {
1932
- const slideIndex = newIndex * swiper.params.grid.rows;
1933
- newIndex = swiper.slides.find((slideEl) => slideEl.getAttribute("data-swiper-slide-index") * 1 === slideIndex).column;
1934
- } else {
1935
- newIndex = swiper.getSlideIndexByData(newIndex);
1936
- }
1847
+ newIndex = swiper.getSlideIndexByData(newIndex);
1937
1848
  }
1938
1849
  }
1939
- requestAnimationFrame(() => {
1940
- swiper.slideTo(newIndex, speed, runCallbacks, internal);
1941
- });
1942
- return swiper;
1850
+ return swiper.slideTo(newIndex, speed, runCallbacks, internal);
1943
1851
  }
1944
- function slideNext(speed, runCallbacks = true, internal) {
1852
+ function slideNext(speed, runCallbacks, internal) {
1853
+ if (speed === void 0) {
1854
+ speed = this.params.speed;
1855
+ }
1856
+ if (runCallbacks === void 0) {
1857
+ runCallbacks = true;
1858
+ }
1945
1859
  const swiper = this;
1946
1860
  const {
1947
1861
  enabled,
1948
1862
  params,
1949
1863
  animating
1950
1864
  } = swiper;
1951
- if (!enabled || swiper.destroyed) return swiper;
1952
- if (typeof speed === "undefined") {
1953
- speed = swiper.params.speed;
1954
- }
1865
+ if (!enabled) return swiper;
1955
1866
  let perGroup = params.slidesPerGroup;
1956
1867
  if (params.slidesPerView === "auto" && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
1957
1868
  perGroup = Math.max(swiper.slidesPerViewDynamic("current", true), 1);
@@ -1976,7 +1887,13 @@ function slideNext(speed, runCallbacks = true, internal) {
1976
1887
  }
1977
1888
  return swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal);
1978
1889
  }
1979
- function slidePrev(speed, runCallbacks = true, internal) {
1890
+ function slidePrev(speed, runCallbacks, internal) {
1891
+ if (speed === void 0) {
1892
+ speed = this.params.speed;
1893
+ }
1894
+ if (runCallbacks === void 0) {
1895
+ runCallbacks = true;
1896
+ }
1980
1897
  const swiper = this;
1981
1898
  const {
1982
1899
  params,
@@ -1986,10 +1903,7 @@ function slidePrev(speed, runCallbacks = true, internal) {
1986
1903
  enabled,
1987
1904
  animating
1988
1905
  } = swiper;
1989
- if (!enabled || swiper.destroyed) return swiper;
1990
- if (typeof speed === "undefined") {
1991
- speed = swiper.params.speed;
1992
- }
1906
+ if (!enabled) return swiper;
1993
1907
  const isVirtual = swiper.virtual && params.virtual.enabled;
1994
1908
  if (params.loop) {
1995
1909
  if (animating && !isVirtual && params.loopPreventsSliding) return false;
@@ -2005,9 +1919,8 @@ function slidePrev(speed, runCallbacks = true, internal) {
2005
1919
  }
2006
1920
  const normalizedTranslate = normalize(translate2);
2007
1921
  const normalizedSnapGrid = snapGrid.map((val) => normalize(val));
2008
- const isFreeMode = params.freeMode && params.freeMode.enabled;
2009
1922
  let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
2010
- if (typeof prevSnap === "undefined" && (params.cssMode || isFreeMode)) {
1923
+ if (typeof prevSnap === "undefined" && params.cssMode) {
2011
1924
  let prevSnapIndex;
2012
1925
  snapGrid.forEach((snap, snapIndex) => {
2013
1926
  if (normalizedTranslate >= snap) {
@@ -2015,7 +1928,7 @@ function slidePrev(speed, runCallbacks = true, internal) {
2015
1928
  }
2016
1929
  });
2017
1930
  if (typeof prevSnapIndex !== "undefined") {
2018
- prevSnap = isFreeMode ? snapGrid[prevSnapIndex] : snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
1931
+ prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
2019
1932
  }
2020
1933
  }
2021
1934
  let prevIndex = 0;
@@ -2038,20 +1951,27 @@ function slidePrev(speed, runCallbacks = true, internal) {
2038
1951
  }
2039
1952
  return swiper.slideTo(prevIndex, speed, runCallbacks, internal);
2040
1953
  }
2041
- function slideReset(speed, runCallbacks = true, internal) {
2042
- const swiper = this;
2043
- if (swiper.destroyed) return;
2044
- if (typeof speed === "undefined") {
2045
- speed = swiper.params.speed;
1954
+ function slideReset(speed, runCallbacks, internal) {
1955
+ if (speed === void 0) {
1956
+ speed = this.params.speed;
1957
+ }
1958
+ if (runCallbacks === void 0) {
1959
+ runCallbacks = true;
2046
1960
  }
1961
+ const swiper = this;
2047
1962
  return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal);
2048
1963
  }
2049
- function slideToClosest(speed, runCallbacks = true, internal, threshold = 0.5) {
2050
- const swiper = this;
2051
- if (swiper.destroyed) return;
2052
- if (typeof speed === "undefined") {
2053
- speed = swiper.params.speed;
1964
+ function slideToClosest(speed, runCallbacks, internal, threshold) {
1965
+ if (speed === void 0) {
1966
+ speed = this.params.speed;
2054
1967
  }
1968
+ if (runCallbacks === void 0) {
1969
+ runCallbacks = true;
1970
+ }
1971
+ if (threshold === void 0) {
1972
+ threshold = 0.5;
1973
+ }
1974
+ const swiper = this;
2055
1975
  let index = swiper.activeIndex;
2056
1976
  const skip = Math.min(swiper.params.slidesPerGroupSkip, index);
2057
1977
  const snapIndex = skip + Math.floor((index - skip) / swiper.params.slidesPerGroup);
@@ -2075,22 +1995,28 @@ function slideToClosest(speed, runCallbacks = true, internal, threshold = 0.5) {
2075
1995
  }
2076
1996
  function slideToClickedSlide() {
2077
1997
  const swiper = this;
2078
- if (swiper.destroyed) return;
2079
1998
  const {
2080
1999
  params,
2081
2000
  slidesEl
2082
2001
  } = swiper;
2083
2002
  const slidesPerView = params.slidesPerView === "auto" ? swiper.slidesPerViewDynamic() : params.slidesPerView;
2084
- let slideToIndex = swiper.getSlideIndexWhenGrid(swiper.clickedIndex);
2003
+ let slideToIndex = swiper.clickedIndex;
2085
2004
  let realIndex;
2086
2005
  const slideSelector = swiper.isElement ? `swiper-slide` : `.${params.slideClass}`;
2087
- const isGrid = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1;
2088
2006
  if (params.loop) {
2089
2007
  if (swiper.animating) return;
2090
2008
  realIndex = parseInt(swiper.clickedSlide.getAttribute("data-swiper-slide-index"), 10);
2091
2009
  if (params.centeredSlides) {
2092
- swiper.slideToLoop(realIndex);
2093
- } else if (slideToIndex > (isGrid ? (swiper.slides.length - slidesPerView) / 2 - (swiper.params.grid.rows - 1) : swiper.slides.length - slidesPerView)) {
2010
+ if (slideToIndex < swiper.loopedSlides - slidesPerView / 2 || slideToIndex > swiper.slides.length - swiper.loopedSlides + slidesPerView / 2) {
2011
+ swiper.loopFix();
2012
+ slideToIndex = swiper.getSlideIndex(elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0]);
2013
+ nextTick(() => {
2014
+ swiper.slideTo(slideToIndex);
2015
+ });
2016
+ } else {
2017
+ swiper.slideTo(slideToIndex);
2018
+ }
2019
+ } else if (slideToIndex > swiper.slides.length - slidesPerView) {
2094
2020
  swiper.loopFix();
2095
2021
  slideToIndex = swiper.getSlideIndex(elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0]);
2096
2022
  nextTick(() => {
@@ -2112,82 +2038,32 @@ var slide = {
2112
2038
  slideToClosest,
2113
2039
  slideToClickedSlide
2114
2040
  };
2115
- function loopCreate(slideRealIndex, initial) {
2041
+ function loopCreate(slideRealIndex) {
2116
2042
  const swiper = this;
2117
2043
  const {
2118
2044
  params,
2119
2045
  slidesEl
2120
2046
  } = swiper;
2121
2047
  if (!params.loop || swiper.virtual && swiper.params.virtual.enabled) return;
2122
- const initSlides = () => {
2123
- const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
2124
- slides.forEach((el, index) => {
2125
- el.setAttribute("data-swiper-slide-index", index);
2126
- });
2127
- };
2128
- const clearBlankSlides = () => {
2129
- const slides = elementChildren(slidesEl, `.${params.slideBlankClass}`);
2130
- slides.forEach((el) => {
2131
- el.remove();
2132
- });
2133
- if (slides.length > 0) {
2134
- swiper.recalcSlides();
2135
- swiper.updateSlides();
2136
- }
2137
- };
2138
- const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
2139
- if (params.loopAddBlankSlides && (params.slidesPerGroup > 1 || gridEnabled)) {
2140
- clearBlankSlides();
2141
- }
2142
- const slidesPerGroup = params.slidesPerGroup * (gridEnabled ? params.grid.rows : 1);
2143
- const shouldFillGroup = swiper.slides.length % slidesPerGroup !== 0;
2144
- const shouldFillGrid = gridEnabled && swiper.slides.length % params.grid.rows !== 0;
2145
- const addBlankSlides = (amountOfSlides) => {
2146
- for (let i = 0; i < amountOfSlides; i += 1) {
2147
- const slideEl = swiper.isElement ? createElement("swiper-slide", [params.slideBlankClass]) : createElement("div", [params.slideClass, params.slideBlankClass]);
2148
- swiper.slidesEl.append(slideEl);
2149
- }
2150
- };
2151
- if (shouldFillGroup) {
2152
- if (params.loopAddBlankSlides) {
2153
- const slidesToAdd = slidesPerGroup - swiper.slides.length % slidesPerGroup;
2154
- addBlankSlides(slidesToAdd);
2155
- swiper.recalcSlides();
2156
- swiper.updateSlides();
2157
- } else {
2158
- 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)");
2159
- }
2160
- initSlides();
2161
- } else if (shouldFillGrid) {
2162
- if (params.loopAddBlankSlides) {
2163
- const slidesToAdd = params.grid.rows - swiper.slides.length % params.grid.rows;
2164
- addBlankSlides(slidesToAdd);
2165
- swiper.recalcSlides();
2166
- swiper.updateSlides();
2167
- } else {
2168
- 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)");
2169
- }
2170
- initSlides();
2171
- } else {
2172
- initSlides();
2173
- }
2174
- const bothDirections = params.centeredSlides || !!params.slidesOffsetBefore || !!params.slidesOffsetAfter;
2048
+ const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
2049
+ slides.forEach((el, index) => {
2050
+ el.setAttribute("data-swiper-slide-index", index);
2051
+ });
2175
2052
  swiper.loopFix({
2176
2053
  slideRealIndex,
2177
- direction: bothDirections ? void 0 : "next",
2178
- initial
2054
+ direction: params.centeredSlides ? void 0 : "next"
2179
2055
  });
2180
2056
  }
2181
- function loopFix({
2182
- slideRealIndex,
2183
- slideTo: slideTo2 = true,
2184
- direction,
2185
- setTranslate: setTranslate2,
2186
- activeSlideIndex,
2187
- initial,
2188
- byController,
2189
- byMousewheel
2190
- } = {}) {
2057
+ function loopFix(_temp) {
2058
+ let {
2059
+ slideRealIndex,
2060
+ slideTo: slideTo2 = true,
2061
+ direction,
2062
+ setTranslate: setTranslate2,
2063
+ activeSlideIndex,
2064
+ byController,
2065
+ byMousewheel
2066
+ } = _temp === void 0 ? {} : _temp;
2191
2067
  const swiper = this;
2192
2068
  if (!swiper.params.loop) return;
2193
2069
  swiper.emit("beforeLoopFix");
@@ -2198,20 +2074,13 @@ function loopFix({
2198
2074
  slidesEl,
2199
2075
  params
2200
2076
  } = swiper;
2201
- const {
2202
- centeredSlides,
2203
- slidesOffsetBefore,
2204
- slidesOffsetAfter,
2205
- initialSlide
2206
- } = params;
2207
- const bothDirections = centeredSlides || !!slidesOffsetBefore || !!slidesOffsetAfter;
2208
2077
  swiper.allowSlidePrev = true;
2209
2078
  swiper.allowSlideNext = true;
2210
2079
  if (swiper.virtual && params.virtual.enabled) {
2211
2080
  if (slideTo2) {
2212
- if (!bothDirections && swiper.snapIndex === 0) {
2081
+ if (!params.centeredSlides && swiper.snapIndex === 0) {
2213
2082
  swiper.slideTo(swiper.virtual.slides.length, 0, false, true);
2214
- } else if (bothDirections && swiper.snapIndex < params.slidesPerView) {
2083
+ } else if (params.centeredSlides && swiper.snapIndex < params.slidesPerView) {
2215
2084
  swiper.slideTo(swiper.virtual.slides.length + swiper.snapIndex, 0, false, true);
2216
2085
  } else if (swiper.snapIndex === swiper.snapGrid.length - 1) {
2217
2086
  swiper.slideTo(swiper.virtual.slidesBefore, 0, false, true);
@@ -2222,35 +2091,17 @@ function loopFix({
2222
2091
  swiper.emit("loopFix");
2223
2092
  return;
2224
2093
  }
2225
- let slidesPerView = params.slidesPerView;
2226
- if (slidesPerView === "auto") {
2227
- slidesPerView = swiper.slidesPerViewDynamic();
2228
- } else {
2229
- slidesPerView = Math.ceil(parseFloat(params.slidesPerView, 10));
2230
- if (bothDirections && slidesPerView % 2 === 0) {
2231
- slidesPerView = slidesPerView + 1;
2232
- }
2233
- }
2234
- const slidesPerGroup = params.slidesPerGroupAuto ? slidesPerView : params.slidesPerGroup;
2235
- let loopedSlides = bothDirections ? Math.max(slidesPerGroup, Math.ceil(slidesPerView / 2)) : slidesPerGroup;
2236
- if (loopedSlides % slidesPerGroup !== 0) {
2237
- loopedSlides += slidesPerGroup - loopedSlides % slidesPerGroup;
2094
+ const slidesPerView = params.slidesPerView === "auto" ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10));
2095
+ let loopedSlides = params.loopedSlides || slidesPerView;
2096
+ if (loopedSlides % params.slidesPerGroup !== 0) {
2097
+ loopedSlides += params.slidesPerGroup - loopedSlides % params.slidesPerGroup;
2238
2098
  }
2239
- loopedSlides += params.loopAdditionalSlides;
2240
2099
  swiper.loopedSlides = loopedSlides;
2241
- const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
2242
- if (slides.length < slidesPerView + loopedSlides || swiper.params.effect === "cards" && slides.length < slidesPerView + loopedSlides * 2) {
2243
- showWarning("Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled or not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters");
2244
- } else if (gridEnabled && params.grid.fill === "row") {
2245
- showWarning("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");
2246
- }
2247
2100
  const prependSlidesIndexes = [];
2248
2101
  const appendSlidesIndexes = [];
2249
- const cols = gridEnabled ? Math.ceil(slides.length / params.grid.rows) : slides.length;
2250
- const isInitialOverflow = initial && cols - initialSlide < slidesPerView && !bothDirections;
2251
- let activeIndex = isInitialOverflow ? initialSlide : swiper.activeIndex;
2102
+ let activeIndex = swiper.activeIndex;
2252
2103
  if (typeof activeSlideIndex === "undefined") {
2253
- activeSlideIndex = swiper.getSlideIndex(slides.find((el) => el.classList.contains(params.slideActiveClass)));
2104
+ activeSlideIndex = swiper.getSlideIndex(swiper.slides.filter((el) => el.classList.contains(params.slideActiveClass))[0]);
2254
2105
  } else {
2255
2106
  activeIndex = activeSlideIndex;
2256
2107
  }
@@ -2258,70 +2109,36 @@ function loopFix({
2258
2109
  const isPrev = direction === "prev" || !direction;
2259
2110
  let slidesPrepended = 0;
2260
2111
  let slidesAppended = 0;
2261
- const activeColIndex = gridEnabled ? slides[activeSlideIndex].column : activeSlideIndex;
2262
- const activeColIndexWithShift = activeColIndex + (bothDirections && typeof setTranslate2 === "undefined" ? -slidesPerView / 2 + 0.5 : 0);
2263
- if (activeColIndexWithShift < loopedSlides) {
2264
- slidesPrepended = Math.max(loopedSlides - activeColIndexWithShift, slidesPerGroup);
2265
- for (let i = 0; i < loopedSlides - activeColIndexWithShift; i += 1) {
2266
- const index = i - Math.floor(i / cols) * cols;
2267
- if (gridEnabled) {
2268
- const colIndexToPrepend = cols - index - 1;
2269
- for (let i2 = slides.length - 1; i2 >= 0; i2 -= 1) {
2270
- if (slides[i2].column === colIndexToPrepend) prependSlidesIndexes.push(i2);
2271
- }
2272
- } else {
2273
- prependSlidesIndexes.push(cols - index - 1);
2274
- }
2275
- }
2276
- } else if (activeColIndexWithShift + slidesPerView > cols - loopedSlides) {
2277
- slidesAppended = Math.max(activeColIndexWithShift - (cols - loopedSlides * 2), slidesPerGroup);
2278
- if (isInitialOverflow) {
2279
- slidesAppended = Math.max(slidesAppended, slidesPerView - cols + initialSlide + 1);
2280
- }
2112
+ if (activeSlideIndex < loopedSlides) {
2113
+ slidesPrepended = Math.max(loopedSlides - activeSlideIndex, params.slidesPerGroup);
2114
+ for (let i = 0; i < loopedSlides - activeSlideIndex; i += 1) {
2115
+ const index = i - Math.floor(i / slides.length) * slides.length;
2116
+ prependSlidesIndexes.push(slides.length - index - 1);
2117
+ }
2118
+ } else if (activeSlideIndex > swiper.slides.length - loopedSlides * 2) {
2119
+ slidesAppended = Math.max(activeSlideIndex - (swiper.slides.length - loopedSlides * 2), params.slidesPerGroup);
2281
2120
  for (let i = 0; i < slidesAppended; i += 1) {
2282
- const index = i - Math.floor(i / cols) * cols;
2283
- if (gridEnabled) {
2284
- slides.forEach((slide2, slideIndex) => {
2285
- if (slide2.column === index) appendSlidesIndexes.push(slideIndex);
2286
- });
2287
- } else {
2288
- appendSlidesIndexes.push(index);
2289
- }
2290
- }
2291
- }
2292
- swiper.__preventObserver__ = true;
2293
- requestAnimationFrame(() => {
2294
- swiper.__preventObserver__ = false;
2295
- });
2296
- if (swiper.params.effect === "cards" && slides.length < slidesPerView + loopedSlides * 2) {
2297
- if (appendSlidesIndexes.includes(activeSlideIndex)) {
2298
- appendSlidesIndexes.splice(appendSlidesIndexes.indexOf(activeSlideIndex), 1);
2299
- }
2300
- if (prependSlidesIndexes.includes(activeSlideIndex)) {
2301
- prependSlidesIndexes.splice(prependSlidesIndexes.indexOf(activeSlideIndex), 1);
2121
+ const index = i - Math.floor(i / slides.length) * slides.length;
2122
+ appendSlidesIndexes.push(index);
2302
2123
  }
2303
2124
  }
2304
2125
  if (isPrev) {
2305
2126
  prependSlidesIndexes.forEach((index) => {
2306
- slides[index].swiperLoopMoveDOM = true;
2307
- slidesEl.prepend(slides[index]);
2308
- slides[index].swiperLoopMoveDOM = false;
2127
+ swiper.slides[index].swiperLoopMoveDOM = true;
2128
+ slidesEl.prepend(swiper.slides[index]);
2129
+ swiper.slides[index].swiperLoopMoveDOM = false;
2309
2130
  });
2310
2131
  }
2311
2132
  if (isNext) {
2312
2133
  appendSlidesIndexes.forEach((index) => {
2313
- slides[index].swiperLoopMoveDOM = true;
2314
- slidesEl.append(slides[index]);
2315
- slides[index].swiperLoopMoveDOM = false;
2134
+ swiper.slides[index].swiperLoopMoveDOM = true;
2135
+ slidesEl.append(swiper.slides[index]);
2136
+ swiper.slides[index].swiperLoopMoveDOM = false;
2316
2137
  });
2317
2138
  }
2318
2139
  swiper.recalcSlides();
2319
2140
  if (params.slidesPerView === "auto") {
2320
2141
  swiper.updateSlides();
2321
- } else if (gridEnabled && (prependSlidesIndexes.length > 0 && isPrev || appendSlidesIndexes.length > 0 && isNext)) {
2322
- swiper.slides.forEach((slide2, slideIndex) => {
2323
- swiper.grid.updateSlide(slideIndex, slide2, swiper.slides);
2324
- });
2325
2142
  }
2326
2143
  if (params.watchSlidesProgress) {
2327
2144
  swiper.updateSlidesOffset();
@@ -2335,16 +2152,15 @@ function loopFix({
2335
2152
  if (byMousewheel) {
2336
2153
  swiper.setTranslate(swiper.translate - diff);
2337
2154
  } else {
2338
- swiper.slideTo(activeIndex + Math.ceil(slidesPrepended), 0, false, true);
2155
+ swiper.slideTo(activeIndex + slidesPrepended, 0, false, true);
2339
2156
  if (setTranslate2) {
2340
- swiper.touchEventsData.startTranslate = swiper.touchEventsData.startTranslate - diff;
2341
- swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
2157
+ swiper.touches[swiper.isHorizontal() ? "startX" : "startY"] += diff;
2158
+ swiper.touchEventsData.currentTranslate = swiper.translate;
2342
2159
  }
2343
2160
  }
2344
2161
  } else {
2345
2162
  if (setTranslate2) {
2346
- const shift = gridEnabled ? prependSlidesIndexes.length / params.grid.rows : prependSlidesIndexes.length;
2347
- swiper.slideTo(swiper.activeIndex + shift, 0, false, true);
2163
+ swiper.slideToLoop(slideRealIndex, 0, false, true);
2348
2164
  swiper.touchEventsData.currentTranslate = swiper.translate;
2349
2165
  }
2350
2166
  }
@@ -2358,13 +2174,12 @@ function loopFix({
2358
2174
  } else {
2359
2175
  swiper.slideTo(activeIndex - slidesAppended, 0, false, true);
2360
2176
  if (setTranslate2) {
2361
- swiper.touchEventsData.startTranslate = swiper.touchEventsData.startTranslate - diff;
2362
- swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
2177
+ swiper.touches[swiper.isHorizontal() ? "startX" : "startY"] += diff;
2178
+ swiper.touchEventsData.currentTranslate = swiper.translate;
2363
2179
  }
2364
2180
  }
2365
2181
  } else {
2366
- const shift = gridEnabled ? appendSlidesIndexes.length / params.grid.rows : appendSlidesIndexes.length;
2367
- swiper.slideTo(swiper.activeIndex - shift, 0, false, true);
2182
+ swiper.slideToLoop(slideRealIndex, 0, false, true);
2368
2183
  }
2369
2184
  }
2370
2185
  }
@@ -2400,7 +2215,7 @@ function loopDestroy() {
2400
2215
  params,
2401
2216
  slidesEl
2402
2217
  } = swiper;
2403
- if (!params.loop || !slidesEl || swiper.virtual && swiper.params.virtual.enabled) return;
2218
+ if (!params.loop || swiper.virtual && swiper.params.virtual.enabled) return;
2404
2219
  swiper.recalcSlides();
2405
2220
  const newSlidesOrder = [];
2406
2221
  swiper.slides.forEach((slideEl) => {
@@ -2455,7 +2270,10 @@ var grabCursor = {
2455
2270
  setGrabCursor,
2456
2271
  unsetGrabCursor
2457
2272
  };
2458
- function closestElement(selector, base = this) {
2273
+ function closestElement(selector, base) {
2274
+ if (base === void 0) {
2275
+ base = this;
2276
+ }
2459
2277
  function __closestFrom(el) {
2460
2278
  if (!el || el === getDocument() || el === getWindow()) return null;
2461
2279
  if (el.assignedSlot) el = el.assignedSlot;
@@ -2467,63 +2285,36 @@ function closestElement(selector, base = this) {
2467
2285
  }
2468
2286
  return __closestFrom(base);
2469
2287
  }
2470
- function preventEdgeSwipe(swiper, event, startX) {
2471
- const window2 = getWindow();
2472
- const {
2473
- params
2474
- } = swiper;
2475
- const edgeSwipeDetection = params.edgeSwipeDetection;
2476
- const edgeSwipeThreshold = params.edgeSwipeThreshold;
2477
- if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window2.innerWidth - edgeSwipeThreshold)) {
2478
- if (edgeSwipeDetection === "prevent") {
2479
- event.preventDefault();
2480
- return true;
2481
- }
2482
- return false;
2483
- }
2484
- return true;
2485
- }
2486
2288
  function onTouchStart(event) {
2487
2289
  const swiper = this;
2488
- if (swiper.destroyed) return;
2489
2290
  const document2 = getDocument();
2490
- let e = event;
2491
- if (e.originalEvent) e = e.originalEvent;
2291
+ const window2 = getWindow();
2492
2292
  const data = swiper.touchEventsData;
2493
- if (e.type === "pointerdown") {
2494
- if (data.pointerId !== null && data.pointerId !== e.pointerId) {
2495
- return;
2496
- }
2497
- data.pointerId = e.pointerId;
2498
- } else if (e.type === "touchstart" && e.targetTouches.length === 1) {
2499
- data.touchId = e.targetTouches[0].identifier;
2500
- }
2501
- if (e.type === "touchstart") {
2502
- preventEdgeSwipe(swiper, e, e.targetTouches[0].pageX);
2503
- return;
2504
- }
2293
+ data.evCache.push(event);
2505
2294
  const {
2506
2295
  params,
2507
2296
  touches,
2508
2297
  enabled
2509
2298
  } = swiper;
2510
2299
  if (!enabled) return;
2511
- if (!params.simulateTouch && e.pointerType === "mouse") return;
2300
+ if (!params.simulateTouch && event.pointerType === "mouse") return;
2512
2301
  if (swiper.animating && params.preventInteractionOnTransition) {
2513
2302
  return;
2514
2303
  }
2515
2304
  if (!swiper.animating && params.cssMode && params.loop) {
2516
2305
  swiper.loopFix();
2517
2306
  }
2307
+ let e = event;
2308
+ if (e.originalEvent) e = e.originalEvent;
2518
2309
  let targetEl = e.target;
2519
2310
  if (params.touchEventsTarget === "wrapper") {
2520
- if (!elementIsChildOf(targetEl, swiper.wrapperEl)) return;
2311
+ if (!swiper.wrapperEl.contains(targetEl)) return;
2521
2312
  }
2522
2313
  if ("which" in e && e.which === 3) return;
2523
2314
  if ("button" in e && e.button > 0) return;
2524
2315
  if (data.isTouched && data.isMoved) return;
2525
2316
  const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== "";
2526
- const eventPath = e.composedPath ? e.composedPath() : e.path;
2317
+ const eventPath = event.composedPath ? event.composedPath() : event.path;
2527
2318
  if (swipingClassHasValue && e.target && e.target.shadowRoot && eventPath) {
2528
2319
  targetEl = eventPath[0];
2529
2320
  }
@@ -2540,8 +2331,14 @@ function onTouchStart(event) {
2540
2331
  touches.currentY = e.pageY;
2541
2332
  const startX = touches.currentX;
2542
2333
  const startY = touches.currentY;
2543
- if (!preventEdgeSwipe(swiper, e, startX)) {
2544
- return;
2334
+ const edgeSwipeDetection = params.edgeSwipeDetection || params.iOSEdgeSwipeDetection;
2335
+ const edgeSwipeThreshold = params.edgeSwipeThreshold || params.iOSEdgeSwipeThreshold;
2336
+ if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window2.innerWidth - edgeSwipeThreshold)) {
2337
+ if (edgeSwipeDetection === "prevent") {
2338
+ event.preventDefault();
2339
+ } else {
2340
+ return;
2341
+ }
2545
2342
  }
2546
2343
  Object.assign(data, {
2547
2344
  isTouched: true,
@@ -2564,7 +2361,7 @@ function onTouchStart(event) {
2564
2361
  data.isTouched = false;
2565
2362
  }
2566
2363
  }
2567
- if (document2.activeElement && document2.activeElement.matches(data.focusableElements) && document2.activeElement !== targetEl && (e.pointerType === "mouse" || e.pointerType !== "mouse" && !targetEl.matches(data.focusableElements))) {
2364
+ if (document2.activeElement && document2.activeElement.matches(data.focusableElements) && document2.activeElement !== targetEl) {
2568
2365
  document2.activeElement.blur();
2569
2366
  }
2570
2367
  const shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault;
@@ -2579,7 +2376,6 @@ function onTouchStart(event) {
2579
2376
  function onTouchMove(event) {
2580
2377
  const document2 = getDocument();
2581
2378
  const swiper = this;
2582
- if (swiper.destroyed) return;
2583
2379
  const data = swiper.touchEventsData;
2584
2380
  const {
2585
2381
  params,
@@ -2591,24 +2387,15 @@ function onTouchMove(event) {
2591
2387
  if (!params.simulateTouch && event.pointerType === "mouse") return;
2592
2388
  let e = event;
2593
2389
  if (e.originalEvent) e = e.originalEvent;
2594
- if (e.type === "pointermove") {
2595
- if (data.touchId !== null) return;
2596
- const id = e.pointerId;
2597
- if (id !== data.pointerId) return;
2598
- }
2599
- let targetTouch;
2600
- if (e.type === "touchmove") {
2601
- targetTouch = [...e.changedTouches].find((t) => t.identifier === data.touchId);
2602
- if (!targetTouch || targetTouch.identifier !== data.touchId) return;
2603
- } else {
2604
- targetTouch = e;
2605
- }
2606
2390
  if (!data.isTouched) {
2607
2391
  if (data.startMoving && data.isScrolling) {
2608
2392
  swiper.emit("touchMoveOpposite", e);
2609
2393
  }
2610
2394
  return;
2611
2395
  }
2396
+ const pointerIndex = data.evCache.findIndex((cachedEv) => cachedEv.pointerId === e.pointerId);
2397
+ if (pointerIndex >= 0) data.evCache[pointerIndex] = e;
2398
+ const targetTouch = data.evCache.length > 1 ? data.evCache[0] : e;
2612
2399
  const pageX = targetTouch.pageX;
2613
2400
  const pageY = targetTouch.pageY;
2614
2401
  if (e.preventedByNestedSwiper) {
@@ -2624,6 +2411,8 @@ function onTouchMove(event) {
2624
2411
  Object.assign(touches, {
2625
2412
  startX: pageX,
2626
2413
  startY: pageY,
2414
+ prevX: swiper.touches.currentX,
2415
+ prevY: swiper.touches.currentY,
2627
2416
  currentX: pageX,
2628
2417
  currentY: pageY
2629
2418
  });
@@ -2638,15 +2427,10 @@ function onTouchMove(event) {
2638
2427
  data.isMoved = false;
2639
2428
  return;
2640
2429
  }
2641
- } else if (rtl && (pageX > touches.startX && -swiper.translate <= swiper.maxTranslate() || pageX < touches.startX && -swiper.translate >= swiper.minTranslate())) {
2642
- return;
2643
- } else if (!rtl && (pageX < touches.startX && swiper.translate <= swiper.maxTranslate() || pageX > touches.startX && swiper.translate >= swiper.minTranslate())) {
2430
+ } else if (pageX < touches.startX && swiper.translate <= swiper.maxTranslate() || pageX > touches.startX && swiper.translate >= swiper.minTranslate()) {
2644
2431
  return;
2645
2432
  }
2646
2433
  }
2647
- if (document2.activeElement && document2.activeElement.matches(data.focusableElements) && document2.activeElement !== e.target && e.pointerType !== "mouse") {
2648
- document2.activeElement.blur();
2649
- }
2650
2434
  if (document2.activeElement) {
2651
2435
  if (e.target === document2.activeElement && e.target.matches(data.focusableElements)) {
2652
2436
  data.isMoved = true;
@@ -2657,8 +2441,7 @@ function onTouchMove(event) {
2657
2441
  if (data.allowTouchCallbacks) {
2658
2442
  swiper.emit("touchMove", e);
2659
2443
  }
2660
- touches.previousX = touches.currentX;
2661
- touches.previousY = touches.currentY;
2444
+ if (e.targetTouches && e.targetTouches.length > 1) return;
2662
2445
  touches.currentX = pageX;
2663
2446
  touches.currentY = pageY;
2664
2447
  const diffX = touches.currentX - touches.startX;
@@ -2683,7 +2466,7 @@ function onTouchMove(event) {
2683
2466
  data.startMoving = true;
2684
2467
  }
2685
2468
  }
2686
- if (data.isScrolling || e.type === "touchmove" && data.preventTouchMoveFromPointerMove) {
2469
+ if (data.isScrolling || swiper.zoom && swiper.params.zoom && swiper.params.zoom.enabled && data.evCache.length > 1) {
2687
2470
  data.isTouched = false;
2688
2471
  return;
2689
2472
  }
@@ -2713,7 +2496,7 @@ function onTouchMove(event) {
2713
2496
  swiper.swipeDirection = diff > 0 ? "prev" : "next";
2714
2497
  swiper.touchesDirection = touchesDiff > 0 ? "prev" : "next";
2715
2498
  const isLoop = swiper.params.loop && !params.cssMode;
2716
- const allowLoopFix = swiper.touchesDirection === "next" && swiper.allowSlideNext || swiper.touchesDirection === "prev" && swiper.allowSlidePrev;
2499
+ const allowLoopFix = swiper.swipeDirection === "next" && swiper.allowSlideNext || swiper.swipeDirection === "prev" && swiper.allowSlidePrev;
2717
2500
  if (!data.isMoved) {
2718
2501
  if (isLoop && allowLoopFix) {
2719
2502
  swiper.loopFix({
@@ -2725,10 +2508,7 @@ function onTouchMove(event) {
2725
2508
  if (swiper.animating) {
2726
2509
  const evt = new window.CustomEvent("transitionend", {
2727
2510
  bubbles: true,
2728
- cancelable: true,
2729
- detail: {
2730
- bySwiperTouchMove: true
2731
- }
2511
+ cancelable: true
2732
2512
  });
2733
2513
  swiper.wrapperEl.dispatchEvent(evt);
2734
2514
  }
@@ -2739,18 +2519,12 @@ function onTouchMove(event) {
2739
2519
  swiper.emit("sliderFirstMove", e);
2740
2520
  }
2741
2521
  let loopFixed;
2742
- (/* @__PURE__ */ new Date()).getTime();
2743
- if (params._loopSwapReset !== false && data.isMoved && data.allowThresholdMove && prevTouchesDirection !== swiper.touchesDirection && isLoop && allowLoopFix && Math.abs(diff) >= 1) {
2744
- Object.assign(touches, {
2745
- startX: pageX,
2746
- startY: pageY,
2747
- currentX: pageX,
2748
- currentY: pageY,
2749
- startTranslate: data.currentTranslate
2522
+ if (data.isMoved && prevTouchesDirection !== swiper.touchesDirection && isLoop && allowLoopFix && Math.abs(diff) >= 1) {
2523
+ swiper.loopFix({
2524
+ direction: swiper.swipeDirection,
2525
+ setTranslate: true
2750
2526
  });
2751
- data.loopSwapReset = true;
2752
- data.startTranslate = data.currentTranslate;
2753
- return;
2527
+ loopFixed = true;
2754
2528
  }
2755
2529
  swiper.emit("sliderMove", e);
2756
2530
  data.isMoved = true;
@@ -2761,7 +2535,7 @@ function onTouchMove(event) {
2761
2535
  resistanceRatio = 0;
2762
2536
  }
2763
2537
  if (diff > 0) {
2764
- if (isLoop && allowLoopFix && !loopFixed && data.allowThresholdMove && data.currentTranslate > (params.centeredSlides ? swiper.minTranslate() - swiper.slidesSizesGrid[swiper.activeIndex + 1] - (params.slidesPerView !== "auto" && swiper.slides.length - params.slidesPerView >= 2 ? swiper.slidesSizesGrid[swiper.activeIndex + 1] + swiper.params.spaceBetween : 0) - swiper.params.spaceBetween : swiper.minTranslate())) {
2538
+ if (isLoop && allowLoopFix && !loopFixed && data.currentTranslate > (params.centeredSlides ? swiper.minTranslate() - swiper.size / 2 : swiper.minTranslate())) {
2765
2539
  swiper.loopFix({
2766
2540
  direction: "prev",
2767
2541
  setTranslate: true,
@@ -2775,7 +2549,7 @@ function onTouchMove(event) {
2775
2549
  }
2776
2550
  }
2777
2551
  } else if (diff < 0) {
2778
- if (isLoop && allowLoopFix && !loopFixed && data.allowThresholdMove && data.currentTranslate < (params.centeredSlides ? swiper.maxTranslate() + swiper.slidesSizesGrid[swiper.slidesSizesGrid.length - 1] + swiper.params.spaceBetween + (params.slidesPerView !== "auto" && swiper.slides.length - params.slidesPerView >= 2 ? swiper.slidesSizesGrid[swiper.slidesSizesGrid.length - 1] + swiper.params.spaceBetween : 0) : swiper.maxTranslate())) {
2552
+ if (isLoop && allowLoopFix && !loopFixed && data.currentTranslate < (params.centeredSlides ? swiper.maxTranslate() + swiper.size / 2 : swiper.maxTranslate())) {
2779
2553
  swiper.loopFix({
2780
2554
  direction: "next",
2781
2555
  setTranslate: true,
@@ -2829,28 +2603,17 @@ function onTouchMove(event) {
2829
2603
  }
2830
2604
  function onTouchEnd(event) {
2831
2605
  const swiper = this;
2832
- if (swiper.destroyed) return;
2833
2606
  const data = swiper.touchEventsData;
2834
- let e = event;
2835
- if (e.originalEvent) e = e.originalEvent;
2836
- let targetTouch;
2837
- const isTouchEvent = e.type === "touchend" || e.type === "touchcancel";
2838
- if (!isTouchEvent) {
2839
- if (data.touchId !== null) return;
2840
- if (e.pointerId !== data.pointerId) return;
2841
- targetTouch = e;
2842
- } else {
2843
- targetTouch = [...e.changedTouches].find((t) => t.identifier === data.touchId);
2844
- if (!targetTouch || targetTouch.identifier !== data.touchId) return;
2607
+ const pointerIndex = data.evCache.findIndex((cachedEv) => cachedEv.pointerId === event.pointerId);
2608
+ if (pointerIndex >= 0) {
2609
+ data.evCache.splice(pointerIndex, 1);
2845
2610
  }
2846
- if (["pointercancel", "pointerout", "pointerleave", "contextmenu"].includes(e.type)) {
2847
- const proceed = ["pointercancel", "contextmenu"].includes(e.type) && (swiper.browser.isSafari || swiper.browser.isWebView);
2611
+ if (["pointercancel", "pointerout", "pointerleave", "contextmenu"].includes(event.type)) {
2612
+ const proceed = ["pointercancel", "contextmenu"].includes(event.type) && (swiper.browser.isSafari || swiper.browser.isWebView);
2848
2613
  if (!proceed) {
2849
2614
  return;
2850
2615
  }
2851
2616
  }
2852
- data.pointerId = null;
2853
- data.touchId = null;
2854
2617
  const {
2855
2618
  params,
2856
2619
  touches,
@@ -2859,7 +2622,9 @@ function onTouchEnd(event) {
2859
2622
  enabled
2860
2623
  } = swiper;
2861
2624
  if (!enabled) return;
2862
- if (!params.simulateTouch && e.pointerType === "mouse") return;
2625
+ if (!params.simulateTouch && event.pointerType === "mouse") return;
2626
+ let e = event;
2627
+ if (e.originalEvent) e = e.originalEvent;
2863
2628
  if (data.allowTouchCallbacks) {
2864
2629
  swiper.emit("touchEnd", e);
2865
2630
  }
@@ -2889,7 +2654,7 @@ function onTouchEnd(event) {
2889
2654
  nextTick(() => {
2890
2655
  if (!swiper.destroyed) swiper.allowClick = true;
2891
2656
  });
2892
- if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 && !data.loopSwapReset || data.currentTranslate === data.startTranslate && !data.loopSwapReset) {
2657
+ if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 || data.currentTranslate === data.startTranslate) {
2893
2658
  data.isTouched = false;
2894
2659
  data.isMoved = false;
2895
2660
  data.startMoving = false;
@@ -2913,17 +2678,16 @@ function onTouchEnd(event) {
2913
2678
  });
2914
2679
  return;
2915
2680
  }
2916
- const swipeToLast = currentPos >= -swiper.maxTranslate() && !swiper.params.loop;
2917
2681
  let stopIndex = 0;
2918
2682
  let groupSize = swiper.slidesSizesGrid[0];
2919
2683
  for (let i = 0; i < slidesGrid.length; i += i < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup) {
2920
2684
  const increment2 = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
2921
2685
  if (typeof slidesGrid[i + increment2] !== "undefined") {
2922
- if (swipeToLast || currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + increment2]) {
2686
+ if (currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + increment2]) {
2923
2687
  stopIndex = i;
2924
2688
  groupSize = slidesGrid[i + increment2] - slidesGrid[i];
2925
2689
  }
2926
- } else if (swipeToLast || currentPos >= slidesGrid[i]) {
2690
+ } else if (currentPos >= slidesGrid[i]) {
2927
2691
  stopIndex = i;
2928
2692
  groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2];
2929
2693
  }
@@ -3000,8 +2764,7 @@ function onResize() {
3000
2764
  swiper.updateSlidesClasses();
3001
2765
  const isVirtualLoop = isVirtual && params.loop;
3002
2766
  if ((params.slidesPerView === "auto" || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides && !isVirtualLoop) {
3003
- const slides = isVirtual ? swiper.virtual.slides : swiper.slides;
3004
- swiper.slideTo(slides.length - 1, 0, false, true);
2767
+ swiper.slideTo(swiper.slides.length - 1, 0, false, true);
3005
2768
  } else {
3006
2769
  if (swiper.params.loop && !isVirtual) {
3007
2770
  swiper.slideToLoop(swiper.realIndex, 0, false, true);
@@ -3025,7 +2788,6 @@ function onResize() {
3025
2788
  }
3026
2789
  function onClick(e) {
3027
2790
  const swiper = this;
3028
- if (swiper.destroyed) return;
3029
2791
  if (!swiper.enabled) return;
3030
2792
  if (!swiper.allowClick) {
3031
2793
  if (swiper.params.preventClicks) e.preventDefault();
@@ -3037,7 +2799,6 @@ function onClick(e) {
3037
2799
  }
3038
2800
  function onScroll() {
3039
2801
  const swiper = this;
3040
- if (swiper.destroyed) return;
3041
2802
  const {
3042
2803
  wrapperEl,
3043
2804
  rtlTranslate,
@@ -3067,21 +2828,14 @@ function onScroll() {
3067
2828
  }
3068
2829
  function onLoad(e) {
3069
2830
  const swiper = this;
3070
- if (swiper.destroyed) return;
3071
2831
  processLazyPreloader(swiper, e.target);
3072
2832
  if (swiper.params.cssMode || swiper.params.slidesPerView !== "auto" && !swiper.params.autoHeight) {
3073
2833
  return;
3074
2834
  }
3075
2835
  swiper.update();
3076
2836
  }
3077
- function onDocumentTouchStart() {
3078
- const swiper = this;
3079
- if (swiper.destroyed) return;
3080
- if (swiper.documentTouchHandlerProceeded) return;
3081
- swiper.documentTouchHandlerProceeded = true;
3082
- if (swiper.params.touchReleaseOnEdges) {
3083
- swiper.el.style.touchAction = "auto";
3084
- }
2837
+ var dummyEventAttached = false;
2838
+ function dummyEventListener() {
3085
2839
  }
3086
2840
  var events = (swiper, method) => {
3087
2841
  const document2 = getDocument();
@@ -3094,37 +2848,19 @@ var events = (swiper, method) => {
3094
2848
  const capture = !!params.nested;
3095
2849
  const domMethod = method === "on" ? "addEventListener" : "removeEventListener";
3096
2850
  const swiperMethod = method;
3097
- if (!el || typeof el === "string") return;
3098
- document2[domMethod]("touchstart", swiper.onDocumentTouchStart, {
3099
- passive: false,
3100
- capture
3101
- });
3102
- el[domMethod]("touchstart", swiper.onTouchStart, {
3103
- passive: false
3104
- });
3105
2851
  el[domMethod]("pointerdown", swiper.onTouchStart, {
3106
2852
  passive: false
3107
2853
  });
3108
- document2[domMethod]("touchmove", swiper.onTouchMove, {
3109
- passive: false,
3110
- capture
3111
- });
3112
2854
  document2[domMethod]("pointermove", swiper.onTouchMove, {
3113
2855
  passive: false,
3114
2856
  capture
3115
2857
  });
3116
- document2[domMethod]("touchend", swiper.onTouchEnd, {
3117
- passive: true
3118
- });
3119
2858
  document2[domMethod]("pointerup", swiper.onTouchEnd, {
3120
2859
  passive: true
3121
2860
  });
3122
2861
  document2[domMethod]("pointercancel", swiper.onTouchEnd, {
3123
2862
  passive: true
3124
2863
  });
3125
- document2[domMethod]("touchcancel", swiper.onTouchEnd, {
3126
- passive: true
3127
- });
3128
2864
  document2[domMethod]("pointerout", swiper.onTouchEnd, {
3129
2865
  passive: true
3130
2866
  });
@@ -3151,18 +2887,22 @@ var events = (swiper, method) => {
3151
2887
  };
3152
2888
  function attachEvents() {
3153
2889
  const swiper = this;
2890
+ const document2 = getDocument();
3154
2891
  const {
3155
2892
  params
3156
2893
  } = swiper;
3157
2894
  swiper.onTouchStart = onTouchStart.bind(swiper);
3158
2895
  swiper.onTouchMove = onTouchMove.bind(swiper);
3159
2896
  swiper.onTouchEnd = onTouchEnd.bind(swiper);
3160
- swiper.onDocumentTouchStart = onDocumentTouchStart.bind(swiper);
3161
2897
  if (params.cssMode) {
3162
2898
  swiper.onScroll = onScroll.bind(swiper);
3163
2899
  }
3164
2900
  swiper.onClick = onClick.bind(swiper);
3165
2901
  swiper.onLoad = onLoad.bind(swiper);
2902
+ if (!dummyEventAttached) {
2903
+ document2.addEventListener("touchstart", dummyEventListener);
2904
+ dummyEventAttached = true;
2905
+ }
3166
2906
  events(swiper, "on");
3167
2907
  }
3168
2908
  function detachEvents() {
@@ -3186,17 +2926,12 @@ function setBreakpoint() {
3186
2926
  } = swiper;
3187
2927
  const breakpoints2 = params.breakpoints;
3188
2928
  if (!breakpoints2 || breakpoints2 && Object.keys(breakpoints2).length === 0) return;
3189
- const document2 = getDocument();
3190
- const breakpointsBase = params.breakpointsBase === "window" || !params.breakpointsBase ? params.breakpointsBase : "container";
3191
- const breakpointContainer = ["window", "container"].includes(params.breakpointsBase) || !params.breakpointsBase ? swiper.el : document2.querySelector(params.breakpointsBase);
3192
- const breakpoint = swiper.getBreakpoint(breakpoints2, breakpointsBase, breakpointContainer);
2929
+ const breakpoint = swiper.getBreakpoint(breakpoints2, swiper.params.breakpointsBase, swiper.el);
3193
2930
  if (!breakpoint || swiper.currentBreakpoint === breakpoint) return;
3194
2931
  const breakpointOnlyParams = breakpoint in breakpoints2 ? breakpoints2[breakpoint] : void 0;
3195
2932
  const breakpointParams = breakpointOnlyParams || swiper.originalParams;
3196
2933
  const wasMultiRow = isGridEnabled(swiper, params);
3197
2934
  const isMultiRow = isGridEnabled(swiper, breakpointParams);
3198
- const wasGrabCursor = swiper.params.grabCursor;
3199
- const isGrabCursor = breakpointParams.grabCursor;
3200
2935
  const wasEnabled = params.enabled;
3201
2936
  if (wasMultiRow && !isMultiRow) {
3202
2937
  el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`);
@@ -3208,11 +2943,6 @@ function setBreakpoint() {
3208
2943
  }
3209
2944
  swiper.emitContainerClasses();
3210
2945
  }
3211
- if (wasGrabCursor && !isGrabCursor) {
3212
- swiper.unsetGrabCursor();
3213
- } else if (!wasGrabCursor && isGrabCursor) {
3214
- swiper.setGrabCursor();
3215
- }
3216
2946
  ["navigation", "pagination", "scrollbar"].forEach((prop) => {
3217
2947
  if (typeof breakpointParams[prop] === "undefined") return;
3218
2948
  const wasModuleEnabled = params[prop] && params[prop].enabled;
@@ -3259,7 +2989,10 @@ function setBreakpoint() {
3259
2989
  }
3260
2990
  swiper.emit("breakpoint", breakpointParams);
3261
2991
  }
3262
- function getBreakpoint(breakpoints2, base = "window", containerEl) {
2992
+ function getBreakpoint(breakpoints2, base, containerEl) {
2993
+ if (base === void 0) {
2994
+ base = "window";
2995
+ }
3263
2996
  if (!breakpoints2 || base === "container" && !containerEl) return void 0;
3264
2997
  let breakpoint = false;
3265
2998
  const window2 = getWindow();
@@ -3353,7 +3086,6 @@ function removeClasses() {
3353
3086
  el,
3354
3087
  classNames
3355
3088
  } = swiper;
3356
- if (!el || typeof el === "string") return;
3357
3089
  el.classList.remove(...classNames);
3358
3090
  swiper.emitContainerClasses();
3359
3091
  }
@@ -3397,7 +3129,6 @@ var defaults = {
3397
3129
  init: true,
3398
3130
  direction: "horizontal",
3399
3131
  oneWayMovement: false,
3400
- swiperElementNodeName: "SWIPER-CONTAINER",
3401
3132
  touchEventsTarget: "wrapper",
3402
3133
  initialSlide: 0,
3403
3134
  speed: 300,
@@ -3406,7 +3137,6 @@ var defaults = {
3406
3137
  resizeObserver: true,
3407
3138
  nested: false,
3408
3139
  createElements: false,
3409
- eventsPrefix: "swiper",
3410
3140
  enabled: true,
3411
3141
  focusableElements: "input, select, option, textarea, button, video, label",
3412
3142
  // Overrides
@@ -3446,7 +3176,6 @@ var defaults = {
3446
3176
  // in px
3447
3177
  normalizeSlideIndex: true,
3448
3178
  centerInsufficientSlides: false,
3449
- snapToSlideEdge: false,
3450
3179
  // Disable swiper and hide navigation when container not overflow
3451
3180
  watchOverflow: true,
3452
3181
  // Round length
@@ -3481,8 +3210,7 @@ var defaults = {
3481
3210
  slideToClickedSlide: false,
3482
3211
  // loop
3483
3212
  loop: false,
3484
- loopAddBlankSlides: true,
3485
- loopAdditionalSlides: 0,
3213
+ loopedSlides: null,
3486
3214
  loopPreventsSliding: true,
3487
3215
  // rewind
3488
3216
  rewind: false,
@@ -3501,10 +3229,8 @@ var defaults = {
3501
3229
  containerModifierClass: "swiper-",
3502
3230
  // NEW
3503
3231
  slideClass: "swiper-slide",
3504
- slideBlankClass: "swiper-slide-blank",
3505
3232
  slideActiveClass: "swiper-slide-active",
3506
3233
  slideVisibleClass: "swiper-slide-visible",
3507
- slideFullyVisibleClass: "swiper-slide-fully-visible",
3508
3234
  slideNextClass: "swiper-slide-next",
3509
3235
  slidePrevClass: "swiper-slide-prev",
3510
3236
  wrapperClass: "swiper-wrapper",
@@ -3516,7 +3242,10 @@ var defaults = {
3516
3242
  _emitClasses: false
3517
3243
  };
3518
3244
  function moduleExtendParams(params, allModulesParams) {
3519
- return function extendParams(obj = {}) {
3245
+ return function extendParams(obj) {
3246
+ if (obj === void 0) {
3247
+ obj = {};
3248
+ }
3520
3249
  const moduleParamName = Object.keys(obj)[0];
3521
3250
  const moduleParams = obj[moduleParamName];
3522
3251
  if (typeof moduleParams !== "object" || moduleParams === null) {
@@ -3562,9 +3291,12 @@ var prototypes = {
3562
3291
  };
3563
3292
  var extendedDefaults = {};
3564
3293
  var Swiper = class _Swiper {
3565
- constructor(...args) {
3294
+ constructor() {
3566
3295
  let el;
3567
3296
  let params;
3297
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3298
+ args[_key] = arguments[_key];
3299
+ }
3568
3300
  if (args.length === 1 && args[0].constructor && Object.prototype.toString.call(args[0]).slice(8, -1) === "Object") {
3569
3301
  params = args[0];
3570
3302
  } else {
@@ -3595,11 +3327,7 @@ var Swiper = class _Swiper {
3595
3327
  swiper.eventsAnyListeners = [];
3596
3328
  swiper.modules = [...swiper.__modules__];
3597
3329
  if (params.modules && Array.isArray(params.modules)) {
3598
- params.modules.forEach((mod) => {
3599
- if (typeof mod === "function" && swiper.modules.indexOf(mod) < 0) {
3600
- swiper.modules.push(mod);
3601
- }
3602
- });
3330
+ swiper.modules.push(...params.modules);
3603
3331
  }
3604
3332
  const allModulesParams = {};
3605
3333
  swiper.modules.forEach((mod) => {
@@ -3679,8 +3407,7 @@ var Swiper = class _Swiper {
3679
3407
  velocities: [],
3680
3408
  allowMomentumBounce: void 0,
3681
3409
  startMoving: void 0,
3682
- pointerId: null,
3683
- touchId: null
3410
+ evCache: []
3684
3411
  },
3685
3412
  // Clicks
3686
3413
  allowClick: true,
@@ -3703,21 +3430,6 @@ var Swiper = class _Swiper {
3703
3430
  }
3704
3431
  return swiper;
3705
3432
  }
3706
- getDirectionLabel(property) {
3707
- if (this.isHorizontal()) {
3708
- return property;
3709
- }
3710
- return {
3711
- "width": "height",
3712
- "margin-top": "margin-left",
3713
- "margin-bottom ": "margin-right",
3714
- "margin-left": "margin-top",
3715
- "margin-right": "margin-bottom",
3716
- "padding-left": "padding-top",
3717
- "padding-right": "padding-bottom",
3718
- "marginRight": "marginBottom"
3719
- }[property];
3720
- }
3721
3433
  getSlideIndex(slideEl) {
3722
3434
  const {
3723
3435
  slidesEl,
@@ -3728,17 +3440,7 @@ var Swiper = class _Swiper {
3728
3440
  return elementIndex(slideEl) - firstSlideIndex;
3729
3441
  }
3730
3442
  getSlideIndexByData(index) {
3731
- return this.getSlideIndex(this.slides.find((slideEl) => slideEl.getAttribute("data-swiper-slide-index") * 1 === index));
3732
- }
3733
- getSlideIndexWhenGrid(index) {
3734
- if (this.grid && this.params.grid && this.params.grid.rows > 1) {
3735
- if (this.params.grid.fill === "column") {
3736
- index = Math.floor(index / this.params.grid.rows);
3737
- } else if (this.params.grid.fill === "row") {
3738
- index = index % Math.ceil(this.slides.length / this.params.grid.rows);
3739
- }
3740
- }
3741
- return index;
3443
+ return this.getSlideIndex(this.slides.filter((slideEl) => slideEl.getAttribute("data-swiper-slide-index") * 1 === index)[0]);
3742
3444
  }
3743
3445
  recalcSlides() {
3744
3446
  const swiper = this;
@@ -3805,7 +3507,13 @@ var Swiper = class _Swiper {
3805
3507
  });
3806
3508
  swiper.emit("_slideClasses", updates);
3807
3509
  }
3808
- slidesPerViewDynamic(view = "current", exact = false) {
3510
+ slidesPerViewDynamic(view, exact) {
3511
+ if (view === void 0) {
3512
+ view = "current";
3513
+ }
3514
+ if (exact === void 0) {
3515
+ exact = false;
3516
+ }
3809
3517
  const swiper = this;
3810
3518
  const {
3811
3519
  params,
@@ -3818,11 +3526,11 @@ var Swiper = class _Swiper {
3818
3526
  let spv = 1;
3819
3527
  if (typeof params.slidesPerView === "number") return params.slidesPerView;
3820
3528
  if (params.centeredSlides) {
3821
- let slideSize = slides[activeIndex] ? Math.ceil(slides[activeIndex].swiperSlideSize) : 0;
3529
+ let slideSize = slides[activeIndex] ? slides[activeIndex].swiperSlideSize : 0;
3822
3530
  let breakLoop;
3823
3531
  for (let i = activeIndex + 1; i < slides.length; i += 1) {
3824
3532
  if (slides[i] && !breakLoop) {
3825
- slideSize += Math.ceil(slides[i].swiperSlideSize);
3533
+ slideSize += slides[i].swiperSlideSize;
3826
3534
  spv += 1;
3827
3535
  if (slideSize > swiperSize) breakLoop = true;
3828
3536
  }
@@ -3901,7 +3609,10 @@ var Swiper = class _Swiper {
3901
3609
  }
3902
3610
  swiper.emit("update");
3903
3611
  }
3904
- changeDirection(newDirection, needUpdate = true) {
3612
+ changeDirection(newDirection, needUpdate) {
3613
+ if (needUpdate === void 0) {
3614
+ needUpdate = true;
3615
+ }
3905
3616
  const swiper = this;
3906
3617
  const currentDirection = swiper.params.direction;
3907
3618
  if (!newDirection) {
@@ -3950,7 +3661,7 @@ var Swiper = class _Swiper {
3950
3661
  return false;
3951
3662
  }
3952
3663
  el.swiper = swiper;
3953
- if (el.parentNode && el.parentNode.host && el.parentNode.host.nodeName === swiper.params.swiperElementNodeName.toUpperCase()) {
3664
+ if (el.parentNode && el.parentNode.host && el.parentNode.host.nodeName === "SWIPER-CONTAINER") {
3954
3665
  swiper.isElement = true;
3955
3666
  }
3956
3667
  const getWrapperSelector = () => {
@@ -4008,7 +3719,7 @@ var Swiper = class _Swiper {
4008
3719
  swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
4009
3720
  }
4010
3721
  if (swiper.params.loop) {
4011
- swiper.loopCreate(void 0, true);
3722
+ swiper.loopCreate();
4012
3723
  }
4013
3724
  swiper.attachEvents();
4014
3725
  const lazyElements = [...swiper.el.querySelectorAll('[loading="lazy"]')];
@@ -4031,7 +3742,13 @@ var Swiper = class _Swiper {
4031
3742
  swiper.emit("afterInit");
4032
3743
  return swiper;
4033
3744
  }
4034
- destroy(deleteInstance = true, cleanStyles = true) {
3745
+ destroy(deleteInstance, cleanStyles) {
3746
+ if (deleteInstance === void 0) {
3747
+ deleteInstance = true;
3748
+ }
3749
+ if (cleanStyles === void 0) {
3750
+ cleanStyles = true;
3751
+ }
4035
3752
  const swiper = this;
4036
3753
  const {
4037
3754
  params,
@@ -4050,15 +3767,11 @@ var Swiper = class _Swiper {
4050
3767
  }
4051
3768
  if (cleanStyles) {
4052
3769
  swiper.removeClasses();
4053
- if (el && typeof el !== "string") {
4054
- el.removeAttribute("style");
4055
- }
4056
- if (wrapperEl) {
4057
- wrapperEl.removeAttribute("style");
4058
- }
3770
+ el.removeAttribute("style");
3771
+ wrapperEl.removeAttribute("style");
4059
3772
  if (slides && slides.length) {
4060
3773
  slides.forEach((slideEl) => {
4061
- slideEl.classList.remove(params.slideVisibleClass, params.slideFullyVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
3774
+ slideEl.classList.remove(params.slideVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
4062
3775
  slideEl.removeAttribute("style");
4063
3776
  slideEl.removeAttribute("data-swiper-slide-index");
4064
3777
  });
@@ -4069,9 +3782,7 @@ var Swiper = class _Swiper {
4069
3782
  swiper.off(eventName);
4070
3783
  });
4071
3784
  if (deleteInstance !== false) {
4072
- if (swiper.el && typeof swiper.el !== "string") {
4073
- swiper.el.swiper = null;
4074
- }
3785
+ swiper.el.swiper = null;
4075
3786
  deleteProps(swiper);
4076
3787
  }
4077
3788
  swiper.destroyed = true;