@ptcwebops/ptcw-design 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/dist/cjs/bundle-example.cjs.entry.js +1 -1
  2. package/dist/cjs/bundle-jumbotron-example.cjs.entry.js +43 -0
  3. package/dist/cjs/core-fd18b67a.js +3771 -0
  4. package/dist/cjs/icon-asset.cjs.entry.js +53 -0
  5. package/dist/cjs/interfaces-0ecd8027.js +15 -0
  6. package/dist/cjs/list-item.cjs.entry.js +33 -0
  7. package/dist/cjs/loader.cjs.js +1 -1
  8. package/dist/cjs/max-width-container_5.cjs.entry.js +452 -0
  9. package/dist/cjs/ptc-breadcrumb_2.cjs.entry.js +141 -0
  10. package/dist/cjs/ptc-button_8.cjs.entry.js +528 -0
  11. package/dist/cjs/ptc-checkbox.cjs.entry.js +1 -1
  12. package/dist/cjs/ptc-dropdown.cjs.entry.js +1 -1
  13. package/dist/cjs/ptc-filter-tag.cjs.entry.js +1 -1
  14. package/dist/cjs/ptc-icon-minimize.cjs.entry.js +8 -1
  15. package/dist/cjs/ptc-pagenation.cjs.entry.js +5 -5
  16. package/dist/cjs/ptc-pricing-block.cjs.entry.js +1 -1
  17. package/dist/cjs/ptc-pricing-tabs.cjs.entry.js +3 -3
  18. package/dist/cjs/ptc-tab-list.cjs.entry.js +1 -1
  19. package/dist/cjs/ptc-tab.cjs.entry.js +1 -1
  20. package/dist/cjs/ptc-tabs.cjs.entry.js +1 -1
  21. package/dist/cjs/ptc-title.cjs.entry.js +78 -0
  22. package/dist/cjs/ptc-tooltip.cjs.entry.js +90 -0
  23. package/dist/cjs/ptcw-design.cjs.js +1 -1
  24. package/dist/cjs/sequential-bundle.cjs.entry.js +100 -0
  25. package/dist/cjs/tab-header.cjs.entry.js +1 -1
  26. package/dist/collection/collection-manifest.json +4 -2
  27. package/dist/collection/components/list-item/list-item.css +7 -0
  28. package/dist/collection/components/list-item/list-item.js +2 -2
  29. package/dist/collection/components/{bundle-example → organism-bundles/bundle-example}/bundle-example.css +14 -4
  30. package/dist/collection/components/{bundle-jumbotron-example → organism-bundles/bundle-jumbotron-example}/bundle-jumbotron-example.js +1 -1
  31. package/dist/collection/components/organism-bundles/sequential-bundle/sequential-bundle.css +22 -0
  32. package/dist/collection/components/organism-bundles/sequential-bundle/sequential-bundle.js +116 -0
  33. package/dist/collection/components/organism-bundles/sequential-bundle-example/sequential-bundle-example.css +781 -0
  34. package/dist/collection/components/organism-bundles/sequential-bundle-example/sequential-bundle-example.js +152 -0
  35. package/dist/collection/components/ptc-announcement/ptc-announcement.js +0 -1
  36. package/dist/collection/components/ptc-checkbox/ptc-checkbox.css +1 -1
  37. package/dist/collection/components/ptc-dropdown/ptc-dropdown.css +1 -1
  38. package/dist/collection/components/ptc-dynamic-card/ptc-dynamic-card.css +4 -2
  39. package/dist/collection/components/ptc-dynamic-card/ptc-dynamic-card.js +47 -55
  40. package/dist/collection/components/ptc-filter-tag/ptc-filter-tag.css +3 -3
  41. package/dist/collection/components/ptc-icon-minimize/ptc-icon-minimize.css +8 -4
  42. package/dist/collection/components/ptc-icon-minimize/ptc-icon-minimize.js +32 -0
  43. package/dist/collection/components/ptc-jumbotron/ptc-jumbotron.css +1 -0
  44. package/dist/collection/components/ptc-jumbotron/ptc-jumbotron.js +8 -4
  45. package/dist/collection/components/ptc-pagenation/ptc-pagenation.css +12 -5
  46. package/dist/collection/components/ptc-pagenation/ptc-pagenation.js +4 -4
  47. package/dist/collection/components/ptc-picture/ptc-picture.js +8 -5
  48. package/dist/collection/components/ptc-pricing-block/ptc-pricing-block.css +1 -0
  49. package/dist/collection/components/ptc-pricing-tabs/ptc-pricing-tabs.css +6 -4
  50. package/dist/collection/components/ptc-pricing-tabs/ptc-pricing-tabs.js +2 -2
  51. package/dist/collection/components/ptc-tab-list/ptc-tab-list.css +4 -0
  52. package/dist/collection/components/ptc-tabs/ptc-tabs.css +1 -0
  53. package/dist/collection/components/ptc-title/ptc-title.css +1 -1
  54. package/dist/collection/components/tab-header/tab-header.css +1 -1
  55. package/dist/custom-elements/index.d.ts +12 -0
  56. package/dist/custom-elements/index.js +4042 -56
  57. package/dist/esm/bundle-example.entry.js +2 -2
  58. package/dist/esm/bundle-jumbotron-example.entry.js +39 -0
  59. package/dist/esm/core-1c9d4889.js +3769 -0
  60. package/dist/esm/dropdown-item.entry.js +1 -1
  61. package/dist/esm/icon-asset.entry.js +49 -0
  62. package/dist/esm/{index-8e63c32d.js → index-4afc9d28.js} +1 -1
  63. package/dist/esm/interfaces-c1c73092.js +12 -0
  64. package/dist/esm/list-item.entry.js +29 -0
  65. package/dist/esm/loader.js +3 -3
  66. package/dist/esm/lottie-player.entry.js +1 -1
  67. package/dist/esm/max-width-container_5.entry.js +444 -0
  68. package/dist/esm/my-component.entry.js +1 -1
  69. package/dist/esm/ptc-accordion-item.entry.js +1 -1
  70. package/dist/esm/ptc-accordion.entry.js +1 -1
  71. package/dist/esm/ptc-announcement.entry.js +1 -1
  72. package/dist/esm/ptc-breadcrumb_2.entry.js +136 -0
  73. package/dist/esm/ptc-button_8.entry.js +517 -0
  74. package/dist/esm/ptc-card-bottom_3.entry.js +1 -1
  75. package/dist/esm/ptc-card.entry.js +1 -1
  76. package/dist/esm/ptc-checkbox.entry.js +2 -2
  77. package/dist/esm/ptc-collapse-list.entry.js +1 -1
  78. package/dist/esm/ptc-container.entry.js +1 -1
  79. package/dist/esm/ptc-date.entry.js +1 -1
  80. package/dist/esm/ptc-dropdown.entry.js +2 -2
  81. package/dist/esm/ptc-ellipsis-dropdown.entry.js +1 -1
  82. package/dist/esm/ptc-filter-tag.entry.js +2 -2
  83. package/dist/esm/ptc-hero-footer-cta.entry.js +1 -1
  84. package/dist/esm/ptc-hero.entry.js +1 -1
  85. package/dist/esm/ptc-icon-list.entry.js +1 -1
  86. package/dist/esm/ptc-icon-minimize.entry.js +9 -2
  87. package/dist/esm/ptc-link.entry.js +1 -1
  88. package/dist/esm/ptc-list.entry.js +1 -1
  89. package/dist/esm/ptc-lottie.entry.js +1 -1
  90. package/dist/esm/ptc-media-card.entry.js +1 -1
  91. package/dist/esm/ptc-minimized-footer.entry.js +1 -1
  92. package/dist/esm/ptc-minimized-header.entry.js +1 -1
  93. package/dist/esm/ptc-mobile-select.entry.js +1 -1
  94. package/dist/esm/ptc-nav-card.entry.js +1 -1
  95. package/dist/esm/ptc-pagenation.entry.js +6 -6
  96. package/dist/esm/ptc-previous-url.entry.js +1 -1
  97. package/dist/esm/ptc-pricing-block.entry.js +2 -2
  98. package/dist/esm/ptc-pricing-tabs.entry.js +4 -4
  99. package/dist/esm/ptc-quote.entry.js +1 -1
  100. package/dist/esm/ptc-readmore.entry.js +1 -1
  101. package/dist/esm/ptc-responsive-wrapper.entry.js +1 -1
  102. package/dist/esm/ptc-search-field.entry.js +1 -1
  103. package/dist/esm/ptc-shopping-cart.entry.js +1 -1
  104. package/dist/esm/ptc-social-share.entry.js +1 -1
  105. package/dist/esm/ptc-span.entry.js +1 -1
  106. package/dist/esm/ptc-sticky-icons.entry.js +1 -1
  107. package/dist/esm/ptc-tab-list.entry.js +2 -2
  108. package/dist/esm/ptc-tab.entry.js +2 -2
  109. package/dist/esm/ptc-tabs.entry.js +2 -2
  110. package/dist/esm/ptc-text-copy-with-background.entry.js +1 -1
  111. package/dist/esm/ptc-title.entry.js +74 -0
  112. package/dist/esm/ptc-tooltip.entry.js +86 -0
  113. package/dist/esm/ptc-two-column-media.entry.js +1 -1
  114. package/dist/esm/ptcw-design.js +3 -3
  115. package/dist/esm/sequential-bundle.entry.js +96 -0
  116. package/dist/esm/tab-content.entry.js +1 -1
  117. package/dist/esm/tab-header.entry.js +2 -2
  118. package/dist/ptcw-design/{p-f55984c2.entry.js → p-00b2c937.entry.js} +1 -1
  119. package/dist/ptcw-design/p-07059441.entry.js +1 -0
  120. package/dist/ptcw-design/{p-462567d1.entry.js → p-08f40716.entry.js} +1 -1
  121. package/dist/ptcw-design/{p-8c6b069b.entry.js → p-09a6b0a7.entry.js} +1 -1
  122. package/dist/ptcw-design/{p-1bc06d03.entry.js → p-0c1e7f62.entry.js} +1 -1
  123. package/dist/ptcw-design/p-0eeebc10.entry.js +1 -0
  124. package/dist/ptcw-design/{p-366528df.entry.js → p-10555016.entry.js} +1 -1
  125. package/dist/ptcw-design/p-11d73140.entry.js +1 -0
  126. package/dist/ptcw-design/{p-b922e3a5.entry.js → p-2ac4eb02.entry.js} +1 -1
  127. package/dist/ptcw-design/{p-fa0e4fe3.entry.js → p-2d0de92a.entry.js} +1 -1
  128. package/dist/ptcw-design/p-2feb5db1.entry.js +1 -0
  129. package/dist/ptcw-design/p-36a3f48e.entry.js +1 -0
  130. package/dist/ptcw-design/{p-cdff68d4.entry.js → p-372a6bb1.entry.js} +1 -1
  131. package/dist/ptcw-design/{p-00c9ae79.entry.js → p-3bc3c801.entry.js} +1 -1
  132. package/dist/ptcw-design/{p-ca6d7814.entry.js → p-3f88508e.entry.js} +1 -1
  133. package/dist/ptcw-design/{p-6872e11b.entry.js → p-4132db6b.entry.js} +1 -1
  134. package/dist/ptcw-design/{p-3bb54c51.entry.js → p-42424ba0.entry.js} +1 -1
  135. package/dist/ptcw-design/p-50e52c88.js +1 -0
  136. package/dist/ptcw-design/{p-61d91a69.entry.js → p-536abb90.entry.js} +1 -1
  137. package/dist/ptcw-design/p-55d7245e.entry.js +1 -0
  138. package/dist/ptcw-design/{p-f958e8c7.entry.js → p-588eb1d3.entry.js} +1 -1
  139. package/dist/ptcw-design/{p-c64a3715.entry.js → p-603576bb.entry.js} +1 -1
  140. package/dist/ptcw-design/{p-a43f3c42.entry.js → p-6756c89e.entry.js} +1 -1
  141. package/dist/ptcw-design/p-69dddd51.js +1 -0
  142. package/dist/ptcw-design/{p-d7d6eff1.entry.js → p-6a0b0d0e.entry.js} +1 -1
  143. package/dist/ptcw-design/{p-d43ff8d4.entry.js → p-6ab6a1e2.entry.js} +1 -1
  144. package/dist/ptcw-design/{p-8a1c2577.entry.js → p-6acd380a.entry.js} +1 -1
  145. package/dist/ptcw-design/{p-609f7161.entry.js → p-6bbccda8.entry.js} +1 -1
  146. package/dist/ptcw-design/{p-de1ceba8.entry.js → p-6f244989.entry.js} +1 -1
  147. package/dist/ptcw-design/p-7650e042.entry.js +1 -0
  148. package/dist/ptcw-design/{p-f81d880d.entry.js → p-77d3b816.entry.js} +1 -1
  149. package/dist/ptcw-design/p-7a83cae3.entry.js +1 -0
  150. package/dist/ptcw-design/{p-343f216f.entry.js → p-7f7594ee.entry.js} +1 -1
  151. package/dist/ptcw-design/{p-6e8222ce.entry.js → p-91db9d8a.entry.js} +1 -1
  152. package/dist/ptcw-design/p-91dc58c5.entry.js +1 -0
  153. package/dist/ptcw-design/{p-2181c8c7.entry.js → p-9805a542.entry.js} +1 -1
  154. package/dist/ptcw-design/p-9bbfeec6.entry.js +1 -0
  155. package/dist/ptcw-design/{p-63c06667.js → p-9dd25c18.js} +1 -1
  156. package/dist/ptcw-design/p-a4d49579.entry.js +1 -0
  157. package/dist/ptcw-design/{p-8a6acf0d.entry.js → p-a76bf4d6.entry.js} +1 -1
  158. package/dist/ptcw-design/p-aa62ab8c.entry.js +1 -0
  159. package/dist/ptcw-design/{p-1c9ed21b.entry.js → p-aae3d333.entry.js} +1 -1
  160. package/dist/ptcw-design/p-ab9d5bb9.entry.js +1 -0
  161. package/dist/ptcw-design/{p-af975d78.entry.js → p-b2d0228f.entry.js} +1 -1
  162. package/dist/ptcw-design/{p-a7b20fe7.entry.js → p-b5064c43.entry.js} +1 -1
  163. package/dist/ptcw-design/{p-55d298f5.entry.js → p-b73ea53a.entry.js} +1 -1
  164. package/dist/ptcw-design/p-bcbf087c.entry.js +1 -0
  165. package/dist/ptcw-design/{p-2ae39c65.entry.js → p-c0b1c34c.entry.js} +1 -1
  166. package/dist/ptcw-design/p-c17514f5.entry.js +1 -0
  167. package/dist/ptcw-design/{p-12780f09.entry.js → p-c326164f.entry.js} +1 -1
  168. package/dist/ptcw-design/{p-0f8784e9.entry.js → p-c5975914.entry.js} +1 -1
  169. package/dist/ptcw-design/p-c80aebb8.entry.js +1 -0
  170. package/dist/ptcw-design/{p-574680c3.entry.js → p-c83efab5.entry.js} +1 -1
  171. package/dist/ptcw-design/{p-a24ecd75.entry.js → p-c9342bd2.entry.js} +1 -1
  172. package/dist/ptcw-design/{p-ea19d8f6.entry.js → p-cb7b03fb.entry.js} +1 -1
  173. package/dist/ptcw-design/{p-dd6501a8.entry.js → p-cff0b2b0.entry.js} +1 -1
  174. package/dist/ptcw-design/{p-59058faa.entry.js → p-deed8ef6.entry.js} +1 -1
  175. package/dist/ptcw-design/{p-c7bd4d99.entry.js → p-e282af3d.entry.js} +1 -1
  176. package/dist/ptcw-design/{p-e4f1e8fd.entry.js → p-f733dad8.entry.js} +1 -1
  177. package/dist/ptcw-design/ptcw-design.esm.js +1 -1
  178. package/dist/types/components/list-item/list-item.d.ts +1 -1
  179. package/dist/types/components/organism-bundles/sequential-bundle/sequential-bundle.d.ts +12 -0
  180. package/dist/types/components/organism-bundles/sequential-bundle-example/sequential-bundle-example.d.ts +16 -0
  181. package/dist/types/components/ptc-dynamic-card/ptc-dynamic-card.d.ts +5 -6
  182. package/dist/types/components/ptc-icon-minimize/ptc-icon-minimize.d.ts +3 -0
  183. package/dist/types/components/ptc-jumbotron/ptc-jumbotron.d.ts +1 -0
  184. package/dist/types/components.d.ts +43 -7
  185. package/package.json +3 -4
  186. package/readme.md +1 -1
  187. package/dist/cjs/bundle-jumbotron-example_16.cjs.entry.js +0 -1131
  188. package/dist/cjs/ptc-card-content.cjs.entry.js +0 -68
  189. package/dist/cjs/ptc-dynamic-card.cjs.entry.js +0 -57
  190. package/dist/cjs/ptc-overlay.cjs.entry.js +0 -34
  191. package/dist/esm/bundle-jumbotron-example_16.entry.js +0 -1112
  192. package/dist/esm/ptc-card-content.entry.js +0 -64
  193. package/dist/esm/ptc-dynamic-card.entry.js +0 -53
  194. package/dist/esm/ptc-overlay.entry.js +0 -30
  195. package/dist/ptcw-design/p-46a6b69c.entry.js +0 -1
  196. package/dist/ptcw-design/p-46afd828.entry.js +0 -1
  197. package/dist/ptcw-design/p-47b2c76f.entry.js +0 -1
  198. package/dist/ptcw-design/p-598d16e5.entry.js +0 -1
  199. package/dist/ptcw-design/p-6b1eb02f.entry.js +0 -1
  200. package/dist/ptcw-design/p-a4e1afa5.entry.js +0 -1
  201. package/dist/ptcw-design/p-af3d5be7.entry.js +0 -1
  202. package/dist/ptcw-design/p-ce9f0355.entry.js +0 -1
  203. package/dist/ptcw-design/p-e91fbd67.entry.js +0 -1
  204. package/dist/ptcw-design/p-f6fe5efe.entry.js +0 -1
  205. package/dist/ptcw-design/p-fe1ff7d2.entry.js +0 -1
  206. /package/dist/collection/components/{bundle-example → organism-bundles/bundle-example}/bundle-example.js +0 -0
  207. /package/dist/collection/components/{bundle-jumbotron-example → organism-bundles/bundle-jumbotron-example}/bundle-jumbotron-example.css +0 -0
  208. /package/dist/types/components/{bundle-example → organism-bundles/bundle-example}/bundle-example.d.ts +0 -0
  209. /package/dist/types/components/{bundle-jumbotron-example → organism-bundles/bundle-jumbotron-example}/bundle-jumbotron-example.d.ts +0 -0
@@ -0,0 +1,3771 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * SSR Window 4.0.2
5
+ * Better handling for window object in SSR environment
6
+ * https://github.com/nolimits4web/ssr-window
7
+ *
8
+ * Copyright 2021, Vladimir Kharlampidi
9
+ *
10
+ * Licensed under MIT
11
+ *
12
+ * Released on: December 13, 2021
13
+ */
14
+ /* eslint-disable no-param-reassign */
15
+ function isObject$1(obj) {
16
+ return (obj !== null &&
17
+ typeof obj === 'object' &&
18
+ 'constructor' in obj &&
19
+ obj.constructor === Object);
20
+ }
21
+ function extend$1(target = {}, src = {}) {
22
+ Object.keys(src).forEach((key) => {
23
+ if (typeof target[key] === 'undefined')
24
+ target[key] = src[key];
25
+ else if (isObject$1(src[key]) &&
26
+ isObject$1(target[key]) &&
27
+ Object.keys(src[key]).length > 0) {
28
+ extend$1(target[key], src[key]);
29
+ }
30
+ });
31
+ }
32
+
33
+ const ssrDocument = {
34
+ body: {},
35
+ addEventListener() { },
36
+ removeEventListener() { },
37
+ activeElement: {
38
+ blur() { },
39
+ nodeName: '',
40
+ },
41
+ querySelector() {
42
+ return null;
43
+ },
44
+ querySelectorAll() {
45
+ return [];
46
+ },
47
+ getElementById() {
48
+ return null;
49
+ },
50
+ createEvent() {
51
+ return {
52
+ initEvent() { },
53
+ };
54
+ },
55
+ createElement() {
56
+ return {
57
+ children: [],
58
+ childNodes: [],
59
+ style: {},
60
+ setAttribute() { },
61
+ getElementsByTagName() {
62
+ return [];
63
+ },
64
+ };
65
+ },
66
+ createElementNS() {
67
+ return {};
68
+ },
69
+ importNode() {
70
+ return null;
71
+ },
72
+ location: {
73
+ hash: '',
74
+ host: '',
75
+ hostname: '',
76
+ href: '',
77
+ origin: '',
78
+ pathname: '',
79
+ protocol: '',
80
+ search: '',
81
+ },
82
+ };
83
+ function getDocument() {
84
+ const doc = typeof document !== 'undefined' ? document : {};
85
+ extend$1(doc, ssrDocument);
86
+ return doc;
87
+ }
88
+
89
+ const ssrWindow = {
90
+ document: ssrDocument,
91
+ navigator: {
92
+ userAgent: '',
93
+ },
94
+ location: {
95
+ hash: '',
96
+ host: '',
97
+ hostname: '',
98
+ href: '',
99
+ origin: '',
100
+ pathname: '',
101
+ protocol: '',
102
+ search: '',
103
+ },
104
+ history: {
105
+ replaceState() { },
106
+ pushState() { },
107
+ go() { },
108
+ back() { },
109
+ },
110
+ CustomEvent: function CustomEvent() {
111
+ return this;
112
+ },
113
+ addEventListener() { },
114
+ removeEventListener() { },
115
+ getComputedStyle() {
116
+ return {
117
+ getPropertyValue() {
118
+ return '';
119
+ },
120
+ };
121
+ },
122
+ Image() { },
123
+ Date() { },
124
+ screen: {},
125
+ setTimeout() { },
126
+ clearTimeout() { },
127
+ matchMedia() {
128
+ return {};
129
+ },
130
+ requestAnimationFrame(callback) {
131
+ if (typeof setTimeout === 'undefined') {
132
+ callback();
133
+ return null;
134
+ }
135
+ return setTimeout(callback, 0);
136
+ },
137
+ cancelAnimationFrame(id) {
138
+ if (typeof setTimeout === 'undefined') {
139
+ return;
140
+ }
141
+ clearTimeout(id);
142
+ },
143
+ };
144
+ function getWindow() {
145
+ const win = typeof window !== 'undefined' ? window : {};
146
+ extend$1(win, ssrWindow);
147
+ return win;
148
+ }
149
+
150
+ function deleteProps(obj) {
151
+ const object = obj;
152
+ Object.keys(object).forEach(key => {
153
+ try {
154
+ object[key] = null;
155
+ } catch (e) {
156
+ // no getter for object
157
+ }
158
+ try {
159
+ delete object[key];
160
+ } catch (e) {
161
+ // something got wrong
162
+ }
163
+ });
164
+ }
165
+ function nextTick(callback, delay = 0) {
166
+ return setTimeout(callback, delay);
167
+ }
168
+ function now() {
169
+ return Date.now();
170
+ }
171
+ function getComputedStyle$1(el) {
172
+ const window = getWindow();
173
+ let style;
174
+ if (window.getComputedStyle) {
175
+ style = window.getComputedStyle(el, null);
176
+ }
177
+ if (!style && el.currentStyle) {
178
+ style = el.currentStyle;
179
+ }
180
+ if (!style) {
181
+ style = el.style;
182
+ }
183
+ return style;
184
+ }
185
+ function getTranslate(el, axis = 'x') {
186
+ const window = getWindow();
187
+ let matrix;
188
+ let curTransform;
189
+ let transformMatrix;
190
+ const curStyle = getComputedStyle$1(el);
191
+ if (window.WebKitCSSMatrix) {
192
+ curTransform = curStyle.transform || curStyle.webkitTransform;
193
+ if (curTransform.split(',').length > 6) {
194
+ curTransform = curTransform.split(', ').map(a => a.replace(',', '.')).join(', ');
195
+ }
196
+ // Some old versions of Webkit choke when 'none' is passed; pass
197
+ // empty string instead in this case
198
+ transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
199
+ } else {
200
+ transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
201
+ matrix = transformMatrix.toString().split(',');
202
+ }
203
+ if (axis === 'x') {
204
+ // Latest Chrome and webkits Fix
205
+ if (window.WebKitCSSMatrix) curTransform = transformMatrix.m41;
206
+ // Crazy IE10 Matrix
207
+ else if (matrix.length === 16) curTransform = parseFloat(matrix[12]);
208
+ // Normal Browsers
209
+ else curTransform = parseFloat(matrix[4]);
210
+ }
211
+ if (axis === 'y') {
212
+ // Latest Chrome and webkits Fix
213
+ if (window.WebKitCSSMatrix) curTransform = transformMatrix.m42;
214
+ // Crazy IE10 Matrix
215
+ else if (matrix.length === 16) curTransform = parseFloat(matrix[13]);
216
+ // Normal Browsers
217
+ else curTransform = parseFloat(matrix[5]);
218
+ }
219
+ return curTransform || 0;
220
+ }
221
+ function isObject(o) {
222
+ return typeof o === 'object' && o !== null && o.constructor && Object.prototype.toString.call(o).slice(8, -1) === 'Object';
223
+ }
224
+ function isNode(node) {
225
+ // eslint-disable-next-line
226
+ if (typeof window !== 'undefined' && typeof window.HTMLElement !== 'undefined') {
227
+ return node instanceof HTMLElement;
228
+ }
229
+ return node && (node.nodeType === 1 || node.nodeType === 11);
230
+ }
231
+ function extend(...args) {
232
+ const to = Object(args[0]);
233
+ const noExtend = ['__proto__', 'constructor', 'prototype'];
234
+ for (let i = 1; i < args.length; i += 1) {
235
+ const nextSource = args[i];
236
+ if (nextSource !== undefined && nextSource !== null && !isNode(nextSource)) {
237
+ const keysArray = Object.keys(Object(nextSource)).filter(key => noExtend.indexOf(key) < 0);
238
+ for (let nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) {
239
+ const nextKey = keysArray[nextIndex];
240
+ const desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
241
+ if (desc !== undefined && desc.enumerable) {
242
+ if (isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
243
+ if (nextSource[nextKey].__swiper__) {
244
+ to[nextKey] = nextSource[nextKey];
245
+ } else {
246
+ extend(to[nextKey], nextSource[nextKey]);
247
+ }
248
+ } else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
249
+ to[nextKey] = {};
250
+ if (nextSource[nextKey].__swiper__) {
251
+ to[nextKey] = nextSource[nextKey];
252
+ } else {
253
+ extend(to[nextKey], nextSource[nextKey]);
254
+ }
255
+ } else {
256
+ to[nextKey] = nextSource[nextKey];
257
+ }
258
+ }
259
+ }
260
+ }
261
+ }
262
+ return to;
263
+ }
264
+ function setCSSProperty(el, varName, varValue) {
265
+ el.style.setProperty(varName, varValue);
266
+ }
267
+ function animateCSSModeScroll({
268
+ swiper,
269
+ targetPosition,
270
+ side
271
+ }) {
272
+ const window = getWindow();
273
+ const startPosition = -swiper.translate;
274
+ let startTime = null;
275
+ let time;
276
+ const duration = swiper.params.speed;
277
+ swiper.wrapperEl.style.scrollSnapType = 'none';
278
+ window.cancelAnimationFrame(swiper.cssModeFrameID);
279
+ const dir = targetPosition > startPosition ? 'next' : 'prev';
280
+ const isOutOfBound = (current, target) => {
281
+ return dir === 'next' && current >= target || dir === 'prev' && current <= target;
282
+ };
283
+ const animate = () => {
284
+ time = new Date().getTime();
285
+ if (startTime === null) {
286
+ startTime = time;
287
+ }
288
+ const progress = Math.max(Math.min((time - startTime) / duration, 1), 0);
289
+ const easeProgress = 0.5 - Math.cos(progress * Math.PI) / 2;
290
+ let currentPosition = startPosition + easeProgress * (targetPosition - startPosition);
291
+ if (isOutOfBound(currentPosition, targetPosition)) {
292
+ currentPosition = targetPosition;
293
+ }
294
+ swiper.wrapperEl.scrollTo({
295
+ [side]: currentPosition
296
+ });
297
+ if (isOutOfBound(currentPosition, targetPosition)) {
298
+ swiper.wrapperEl.style.overflow = 'hidden';
299
+ swiper.wrapperEl.style.scrollSnapType = '';
300
+ setTimeout(() => {
301
+ swiper.wrapperEl.style.overflow = '';
302
+ swiper.wrapperEl.scrollTo({
303
+ [side]: currentPosition
304
+ });
305
+ });
306
+ window.cancelAnimationFrame(swiper.cssModeFrameID);
307
+ return;
308
+ }
309
+ swiper.cssModeFrameID = window.requestAnimationFrame(animate);
310
+ };
311
+ animate();
312
+ }
313
+ function elementChildren(element, selector = '') {
314
+ return [...element.children].filter(el => el.matches(selector));
315
+ }
316
+ function createElement(tag, classes = []) {
317
+ const el = document.createElement(tag);
318
+ el.classList.add(...(Array.isArray(classes) ? classes : [classes]));
319
+ return el;
320
+ }
321
+ function elementPrevAll(el, selector) {
322
+ const prevEls = [];
323
+ while (el.previousElementSibling) {
324
+ const prev = el.previousElementSibling; // eslint-disable-line
325
+ if (selector) {
326
+ if (prev.matches(selector)) prevEls.push(prev);
327
+ } else prevEls.push(prev);
328
+ el = prev;
329
+ }
330
+ return prevEls;
331
+ }
332
+ function elementNextAll(el, selector) {
333
+ const nextEls = [];
334
+ while (el.nextElementSibling) {
335
+ const next = el.nextElementSibling; // eslint-disable-line
336
+ if (selector) {
337
+ if (next.matches(selector)) nextEls.push(next);
338
+ } else nextEls.push(next);
339
+ el = next;
340
+ }
341
+ return nextEls;
342
+ }
343
+ function elementStyle(el, prop) {
344
+ const window = getWindow();
345
+ return window.getComputedStyle(el, null).getPropertyValue(prop);
346
+ }
347
+ function elementIndex(el) {
348
+ let child = el;
349
+ let i;
350
+ if (child) {
351
+ i = 0;
352
+ // eslint-disable-next-line
353
+ while ((child = child.previousSibling) !== null) {
354
+ if (child.nodeType === 1) i += 1;
355
+ }
356
+ return i;
357
+ }
358
+ return undefined;
359
+ }
360
+ function elementParents(el, selector) {
361
+ const parents = []; // eslint-disable-line
362
+ let parent = el.parentElement; // eslint-disable-line
363
+ while (parent) {
364
+ if (selector) {
365
+ if (parent.matches(selector)) parents.push(parent);
366
+ } else {
367
+ parents.push(parent);
368
+ }
369
+ parent = parent.parentElement;
370
+ }
371
+ return parents;
372
+ }
373
+ function elementOuterSize(el, size, includeMargins) {
374
+ const window = getWindow();
375
+ if (includeMargins) {
376
+ return el[size === 'width' ? 'offsetWidth' : 'offsetHeight'] + parseFloat(window.getComputedStyle(el, null).getPropertyValue(size === 'width' ? 'margin-right' : 'margin-top')) + parseFloat(window.getComputedStyle(el, null).getPropertyValue(size === 'width' ? 'margin-left' : 'margin-bottom'));
377
+ }
378
+ return el.offsetWidth;
379
+ }
380
+
381
+ let support;
382
+ function calcSupport() {
383
+ const window = getWindow();
384
+ const document = getDocument();
385
+ return {
386
+ smoothScroll: document.documentElement && 'scrollBehavior' in document.documentElement.style,
387
+ touch: !!('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch)
388
+ };
389
+ }
390
+ function getSupport() {
391
+ if (!support) {
392
+ support = calcSupport();
393
+ }
394
+ return support;
395
+ }
396
+
397
+ let deviceCached;
398
+ function calcDevice({
399
+ userAgent
400
+ } = {}) {
401
+ const support = getSupport();
402
+ const window = getWindow();
403
+ const platform = window.navigator.platform;
404
+ const ua = userAgent || window.navigator.userAgent;
405
+ const device = {
406
+ ios: false,
407
+ android: false
408
+ };
409
+ const screenWidth = window.screen.width;
410
+ const screenHeight = window.screen.height;
411
+ const android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); // eslint-disable-line
412
+ let ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
413
+ const ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
414
+ const iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/);
415
+ const windows = platform === 'Win32';
416
+ let macos = platform === 'MacIntel';
417
+
418
+ // iPadOs 13 fix
419
+ const iPadScreens = ['1024x1366', '1366x1024', '834x1194', '1194x834', '834x1112', '1112x834', '768x1024', '1024x768', '820x1180', '1180x820', '810x1080', '1080x810'];
420
+ if (!ipad && macos && support.touch && iPadScreens.indexOf(`${screenWidth}x${screenHeight}`) >= 0) {
421
+ ipad = ua.match(/(Version)\/([\d.]+)/);
422
+ if (!ipad) ipad = [0, 1, '13_0_0'];
423
+ macos = false;
424
+ }
425
+
426
+ // Android
427
+ if (android && !windows) {
428
+ device.os = 'android';
429
+ device.android = true;
430
+ }
431
+ if (ipad || iphone || ipod) {
432
+ device.os = 'ios';
433
+ device.ios = true;
434
+ }
435
+
436
+ // Export object
437
+ return device;
438
+ }
439
+ function getDevice(overrides = {}) {
440
+ if (!deviceCached) {
441
+ deviceCached = calcDevice(overrides);
442
+ }
443
+ return deviceCached;
444
+ }
445
+
446
+ let browser;
447
+ function calcBrowser() {
448
+ const window = getWindow();
449
+ let needPerspectiveFix = false;
450
+ function isSafari() {
451
+ const ua = window.navigator.userAgent.toLowerCase();
452
+ return ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0;
453
+ }
454
+ if (isSafari()) {
455
+ const ua = String(window.navigator.userAgent);
456
+ if (ua.includes('Version/')) {
457
+ const [major, minor] = ua.split('Version/')[1].split(' ')[0].split('.').map(num => Number(num));
458
+ needPerspectiveFix = major < 16 || major === 16 && minor < 2;
459
+ }
460
+ }
461
+ return {
462
+ isSafari: needPerspectiveFix || isSafari(),
463
+ needPerspectiveFix,
464
+ isWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window.navigator.userAgent)
465
+ };
466
+ }
467
+ function getBrowser() {
468
+ if (!browser) {
469
+ browser = calcBrowser();
470
+ }
471
+ return browser;
472
+ }
473
+
474
+ function Resize({
475
+ swiper,
476
+ on,
477
+ emit
478
+ }) {
479
+ const window = getWindow();
480
+ let observer = null;
481
+ let animationFrame = null;
482
+ const resizeHandler = () => {
483
+ if (!swiper || swiper.destroyed || !swiper.initialized) return;
484
+ emit('beforeResize');
485
+ emit('resize');
486
+ };
487
+ const createObserver = () => {
488
+ if (!swiper || swiper.destroyed || !swiper.initialized) return;
489
+ observer = new ResizeObserver(entries => {
490
+ animationFrame = window.requestAnimationFrame(() => {
491
+ const {
492
+ width,
493
+ height
494
+ } = swiper;
495
+ let newWidth = width;
496
+ let newHeight = height;
497
+ entries.forEach(({
498
+ contentBoxSize,
499
+ contentRect,
500
+ target
501
+ }) => {
502
+ if (target && target !== swiper.el) return;
503
+ newWidth = contentRect ? contentRect.width : (contentBoxSize[0] || contentBoxSize).inlineSize;
504
+ newHeight = contentRect ? contentRect.height : (contentBoxSize[0] || contentBoxSize).blockSize;
505
+ });
506
+ if (newWidth !== width || newHeight !== height) {
507
+ resizeHandler();
508
+ }
509
+ });
510
+ });
511
+ observer.observe(swiper.el);
512
+ };
513
+ const removeObserver = () => {
514
+ if (animationFrame) {
515
+ window.cancelAnimationFrame(animationFrame);
516
+ }
517
+ if (observer && observer.unobserve && swiper.el) {
518
+ observer.unobserve(swiper.el);
519
+ observer = null;
520
+ }
521
+ };
522
+ const orientationChangeHandler = () => {
523
+ if (!swiper || swiper.destroyed || !swiper.initialized) return;
524
+ emit('orientationchange');
525
+ };
526
+ on('init', () => {
527
+ if (swiper.params.resizeObserver && typeof window.ResizeObserver !== 'undefined') {
528
+ createObserver();
529
+ return;
530
+ }
531
+ window.addEventListener('resize', resizeHandler);
532
+ window.addEventListener('orientationchange', orientationChangeHandler);
533
+ });
534
+ on('destroy', () => {
535
+ removeObserver();
536
+ window.removeEventListener('resize', resizeHandler);
537
+ window.removeEventListener('orientationchange', orientationChangeHandler);
538
+ });
539
+ }
540
+
541
+ function Observer({
542
+ swiper,
543
+ extendParams,
544
+ on,
545
+ emit
546
+ }) {
547
+ const observers = [];
548
+ const window = getWindow();
549
+ const attach = (target, options = {}) => {
550
+ const ObserverFunc = window.MutationObserver || window.WebkitMutationObserver;
551
+ const observer = new ObserverFunc(mutations => {
552
+ // The observerUpdate event should only be triggered
553
+ // once despite the number of mutations. Additional
554
+ // triggers are redundant and are very costly
555
+ if (swiper.__preventObserver__) return;
556
+ if (mutations.length === 1) {
557
+ emit('observerUpdate', mutations[0]);
558
+ return;
559
+ }
560
+ const observerUpdate = function observerUpdate() {
561
+ emit('observerUpdate', mutations[0]);
562
+ };
563
+ if (window.requestAnimationFrame) {
564
+ window.requestAnimationFrame(observerUpdate);
565
+ } else {
566
+ window.setTimeout(observerUpdate, 0);
567
+ }
568
+ });
569
+ observer.observe(target, {
570
+ attributes: typeof options.attributes === 'undefined' ? true : options.attributes,
571
+ childList: typeof options.childList === 'undefined' ? true : options.childList,
572
+ characterData: typeof options.characterData === 'undefined' ? true : options.characterData
573
+ });
574
+ observers.push(observer);
575
+ };
576
+ const init = () => {
577
+ if (!swiper.params.observer) return;
578
+ if (swiper.params.observeParents) {
579
+ const containerParents = elementParents(swiper.el);
580
+ for (let i = 0; i < containerParents.length; i += 1) {
581
+ attach(containerParents[i]);
582
+ }
583
+ }
584
+ // Observe container
585
+ attach(swiper.el, {
586
+ childList: swiper.params.observeSlideChildren
587
+ });
588
+
589
+ // Observe wrapper
590
+ attach(swiper.wrapperEl, {
591
+ attributes: false
592
+ });
593
+ };
594
+ const destroy = () => {
595
+ observers.forEach(observer => {
596
+ observer.disconnect();
597
+ });
598
+ observers.splice(0, observers.length);
599
+ };
600
+ extendParams({
601
+ observer: false,
602
+ observeParents: false,
603
+ observeSlideChildren: false
604
+ });
605
+ on('init', init);
606
+ on('destroy', destroy);
607
+ }
608
+
609
+ /* eslint-disable no-underscore-dangle */
610
+
611
+ const eventsEmitter = {
612
+ on(events, handler, priority) {
613
+ const self = this;
614
+ if (!self.eventsListeners || self.destroyed) return self;
615
+ if (typeof handler !== 'function') return self;
616
+ const method = priority ? 'unshift' : 'push';
617
+ events.split(' ').forEach(event => {
618
+ if (!self.eventsListeners[event]) self.eventsListeners[event] = [];
619
+ self.eventsListeners[event][method](handler);
620
+ });
621
+ return self;
622
+ },
623
+ once(events, handler, priority) {
624
+ const self = this;
625
+ if (!self.eventsListeners || self.destroyed) return self;
626
+ if (typeof handler !== 'function') return self;
627
+ function onceHandler(...args) {
628
+ self.off(events, onceHandler);
629
+ if (onceHandler.__emitterProxy) {
630
+ delete onceHandler.__emitterProxy;
631
+ }
632
+ handler.apply(self, args);
633
+ }
634
+ onceHandler.__emitterProxy = handler;
635
+ return self.on(events, onceHandler, priority);
636
+ },
637
+ onAny(handler, priority) {
638
+ const self = this;
639
+ if (!self.eventsListeners || self.destroyed) return self;
640
+ if (typeof handler !== 'function') return self;
641
+ const method = priority ? 'unshift' : 'push';
642
+ if (self.eventsAnyListeners.indexOf(handler) < 0) {
643
+ self.eventsAnyListeners[method](handler);
644
+ }
645
+ return self;
646
+ },
647
+ offAny(handler) {
648
+ const self = this;
649
+ if (!self.eventsListeners || self.destroyed) return self;
650
+ if (!self.eventsAnyListeners) return self;
651
+ const index = self.eventsAnyListeners.indexOf(handler);
652
+ if (index >= 0) {
653
+ self.eventsAnyListeners.splice(index, 1);
654
+ }
655
+ return self;
656
+ },
657
+ off(events, handler) {
658
+ const self = this;
659
+ if (!self.eventsListeners || self.destroyed) return self;
660
+ if (!self.eventsListeners) return self;
661
+ events.split(' ').forEach(event => {
662
+ if (typeof handler === 'undefined') {
663
+ self.eventsListeners[event] = [];
664
+ } else if (self.eventsListeners[event]) {
665
+ self.eventsListeners[event].forEach((eventHandler, index) => {
666
+ if (eventHandler === handler || eventHandler.__emitterProxy && eventHandler.__emitterProxy === handler) {
667
+ self.eventsListeners[event].splice(index, 1);
668
+ }
669
+ });
670
+ }
671
+ });
672
+ return self;
673
+ },
674
+ emit(...args) {
675
+ const self = this;
676
+ if (!self.eventsListeners || self.destroyed) return self;
677
+ if (!self.eventsListeners) return self;
678
+ let events;
679
+ let data;
680
+ let context;
681
+ if (typeof args[0] === 'string' || Array.isArray(args[0])) {
682
+ events = args[0];
683
+ data = args.slice(1, args.length);
684
+ context = self;
685
+ } else {
686
+ events = args[0].events;
687
+ data = args[0].data;
688
+ context = args[0].context || self;
689
+ }
690
+ data.unshift(context);
691
+ const eventsArray = Array.isArray(events) ? events : events.split(' ');
692
+ eventsArray.forEach(event => {
693
+ if (self.eventsAnyListeners && self.eventsAnyListeners.length) {
694
+ self.eventsAnyListeners.forEach(eventHandler => {
695
+ eventHandler.apply(context, [event, ...data]);
696
+ });
697
+ }
698
+ if (self.eventsListeners && self.eventsListeners[event]) {
699
+ self.eventsListeners[event].forEach(eventHandler => {
700
+ eventHandler.apply(context, data);
701
+ });
702
+ }
703
+ });
704
+ return self;
705
+ }
706
+ };
707
+
708
+ function updateSize() {
709
+ const swiper = this;
710
+ let width;
711
+ let height;
712
+ const el = swiper.el;
713
+ if (typeof swiper.params.width !== 'undefined' && swiper.params.width !== null) {
714
+ width = swiper.params.width;
715
+ } else {
716
+ width = el.clientWidth;
717
+ }
718
+ if (typeof swiper.params.height !== 'undefined' && swiper.params.height !== null) {
719
+ height = swiper.params.height;
720
+ } else {
721
+ height = el.clientHeight;
722
+ }
723
+ if (width === 0 && swiper.isHorizontal() || height === 0 && swiper.isVertical()) {
724
+ return;
725
+ }
726
+
727
+ // Subtract paddings
728
+ width = width - parseInt(elementStyle(el, 'padding-left') || 0, 10) - parseInt(elementStyle(el, 'padding-right') || 0, 10);
729
+ height = height - parseInt(elementStyle(el, 'padding-top') || 0, 10) - parseInt(elementStyle(el, 'padding-bottom') || 0, 10);
730
+ if (Number.isNaN(width)) width = 0;
731
+ if (Number.isNaN(height)) height = 0;
732
+ Object.assign(swiper, {
733
+ width,
734
+ height,
735
+ size: swiper.isHorizontal() ? width : height
736
+ });
737
+ }
738
+
739
+ function updateSlides() {
740
+ const swiper = this;
741
+ function getDirectionLabel(property) {
742
+ if (swiper.isHorizontal()) {
743
+ return property;
744
+ }
745
+ // prettier-ignore
746
+ return {
747
+ 'width': 'height',
748
+ 'margin-top': 'margin-left',
749
+ 'margin-bottom ': 'margin-right',
750
+ 'margin-left': 'margin-top',
751
+ 'margin-right': 'margin-bottom',
752
+ 'padding-left': 'padding-top',
753
+ 'padding-right': 'padding-bottom',
754
+ 'marginRight': 'marginBottom'
755
+ }[property];
756
+ }
757
+ function getDirectionPropertyValue(node, label) {
758
+ return parseFloat(node.getPropertyValue(getDirectionLabel(label)) || 0);
759
+ }
760
+ const params = swiper.params;
761
+ const {
762
+ wrapperEl,
763
+ slidesEl,
764
+ size: swiperSize,
765
+ rtlTranslate: rtl,
766
+ wrongRTL
767
+ } = swiper;
768
+ const isVirtual = swiper.virtual && params.virtual.enabled;
769
+ const previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length;
770
+ const slides = elementChildren(slidesEl, `.${swiper.params.slideClass}, swiper-slide`);
771
+ const slidesLength = isVirtual ? swiper.virtual.slides.length : slides.length;
772
+ let snapGrid = [];
773
+ const slidesGrid = [];
774
+ const slidesSizesGrid = [];
775
+ let offsetBefore = params.slidesOffsetBefore;
776
+ if (typeof offsetBefore === 'function') {
777
+ offsetBefore = params.slidesOffsetBefore.call(swiper);
778
+ }
779
+ let offsetAfter = params.slidesOffsetAfter;
780
+ if (typeof offsetAfter === 'function') {
781
+ offsetAfter = params.slidesOffsetAfter.call(swiper);
782
+ }
783
+ const previousSnapGridLength = swiper.snapGrid.length;
784
+ const previousSlidesGridLength = swiper.slidesGrid.length;
785
+ let spaceBetween = params.spaceBetween;
786
+ let slidePosition = -offsetBefore;
787
+ let prevSlideSize = 0;
788
+ let index = 0;
789
+ if (typeof swiperSize === 'undefined') {
790
+ return;
791
+ }
792
+ if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
793
+ spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize;
794
+ }
795
+ swiper.virtualSize = -spaceBetween;
796
+
797
+ // reset margins
798
+ slides.forEach(slideEl => {
799
+ if (rtl) {
800
+ slideEl.style.marginLeft = '';
801
+ } else {
802
+ slideEl.style.marginRight = '';
803
+ }
804
+ slideEl.style.marginBottom = '';
805
+ slideEl.style.marginTop = '';
806
+ });
807
+
808
+ // reset cssMode offsets
809
+ if (params.centeredSlides && params.cssMode) {
810
+ setCSSProperty(wrapperEl, '--swiper-centered-offset-before', '');
811
+ setCSSProperty(wrapperEl, '--swiper-centered-offset-after', '');
812
+ }
813
+ const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid;
814
+ if (gridEnabled) {
815
+ swiper.grid.initSlides(slidesLength);
816
+ }
817
+
818
+ // Calc slides
819
+ let slideSize;
820
+ const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key => {
821
+ return typeof params.breakpoints[key].slidesPerView !== 'undefined';
822
+ }).length > 0;
823
+ for (let i = 0; i < slidesLength; i += 1) {
824
+ slideSize = 0;
825
+ let slide;
826
+ if (slides[i]) slide = slides[i];
827
+ if (gridEnabled) {
828
+ swiper.grid.updateSlide(i, slide, slidesLength, getDirectionLabel);
829
+ }
830
+ if (slides[i] && elementStyle(slide, 'display') === 'none') continue; // eslint-disable-line
831
+
832
+ if (params.slidesPerView === 'auto') {
833
+ if (shouldResetSlideSize) {
834
+ slides[i].style[getDirectionLabel('width')] = ``;
835
+ }
836
+ const slideStyles = getComputedStyle(slide);
837
+ const currentTransform = slide.style.transform;
838
+ const currentWebKitTransform = slide.style.webkitTransform;
839
+ if (currentTransform) {
840
+ slide.style.transform = 'none';
841
+ }
842
+ if (currentWebKitTransform) {
843
+ slide.style.webkitTransform = 'none';
844
+ }
845
+ if (params.roundLengths) {
846
+ slideSize = swiper.isHorizontal() ? elementOuterSize(slide, 'width', true) : elementOuterSize(slide, 'height', true);
847
+ } else {
848
+ // eslint-disable-next-line
849
+ const width = getDirectionPropertyValue(slideStyles, 'width');
850
+ const paddingLeft = getDirectionPropertyValue(slideStyles, 'padding-left');
851
+ const paddingRight = getDirectionPropertyValue(slideStyles, 'padding-right');
852
+ const marginLeft = getDirectionPropertyValue(slideStyles, 'margin-left');
853
+ const marginRight = getDirectionPropertyValue(slideStyles, 'margin-right');
854
+ const boxSizing = slideStyles.getPropertyValue('box-sizing');
855
+ if (boxSizing && boxSizing === 'border-box') {
856
+ slideSize = width + marginLeft + marginRight;
857
+ } else {
858
+ const {
859
+ clientWidth,
860
+ offsetWidth
861
+ } = slide;
862
+ slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
863
+ }
864
+ }
865
+ if (currentTransform) {
866
+ slide.style.transform = currentTransform;
867
+ }
868
+ if (currentWebKitTransform) {
869
+ slide.style.webkitTransform = currentWebKitTransform;
870
+ }
871
+ if (params.roundLengths) slideSize = Math.floor(slideSize);
872
+ } else {
873
+ slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
874
+ if (params.roundLengths) slideSize = Math.floor(slideSize);
875
+ if (slides[i]) {
876
+ slides[i].style[getDirectionLabel('width')] = `${slideSize}px`;
877
+ }
878
+ }
879
+ if (slides[i]) {
880
+ slides[i].swiperSlideSize = slideSize;
881
+ }
882
+ slidesSizesGrid.push(slideSize);
883
+ if (params.centeredSlides) {
884
+ slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
885
+ if (prevSlideSize === 0 && i !== 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
886
+ if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
887
+ if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
888
+ if (params.roundLengths) slidePosition = Math.floor(slidePosition);
889
+ if (index % params.slidesPerGroup === 0) snapGrid.push(slidePosition);
890
+ slidesGrid.push(slidePosition);
891
+ } else {
892
+ if (params.roundLengths) slidePosition = Math.floor(slidePosition);
893
+ if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) snapGrid.push(slidePosition);
894
+ slidesGrid.push(slidePosition);
895
+ slidePosition = slidePosition + slideSize + spaceBetween;
896
+ }
897
+ swiper.virtualSize += slideSize + spaceBetween;
898
+ prevSlideSize = slideSize;
899
+ index += 1;
900
+ }
901
+ swiper.virtualSize = Math.max(swiper.virtualSize, swiperSize) + offsetAfter;
902
+ if (rtl && wrongRTL && (params.effect === 'slide' || params.effect === 'coverflow')) {
903
+ wrapperEl.style.width = `${swiper.virtualSize + params.spaceBetween}px`;
904
+ }
905
+ if (params.setWrapperSize) {
906
+ wrapperEl.style[getDirectionLabel('width')] = `${swiper.virtualSize + params.spaceBetween}px`;
907
+ }
908
+ if (gridEnabled) {
909
+ swiper.grid.updateWrapperSize(slideSize, snapGrid, getDirectionLabel);
910
+ }
911
+
912
+ // Remove last grid elements depending on width
913
+ if (!params.centeredSlides) {
914
+ const newSlidesGrid = [];
915
+ for (let i = 0; i < snapGrid.length; i += 1) {
916
+ let slidesGridItem = snapGrid[i];
917
+ if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
918
+ if (snapGrid[i] <= swiper.virtualSize - swiperSize) {
919
+ newSlidesGrid.push(slidesGridItem);
920
+ }
921
+ }
922
+ snapGrid = newSlidesGrid;
923
+ if (Math.floor(swiper.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
924
+ snapGrid.push(swiper.virtualSize - swiperSize);
925
+ }
926
+ }
927
+ if (isVirtual && params.loop) {
928
+ const size = slidesSizesGrid[0] + spaceBetween;
929
+ if (params.slidesPerGroup > 1) {
930
+ const groups = Math.ceil((swiper.virtual.slidesBefore + swiper.virtual.slidesAfter) / params.slidesPerGroup);
931
+ const groupSize = size * params.slidesPerGroup;
932
+ for (let i = 0; i < groups; i += 1) {
933
+ snapGrid.push(snapGrid[snapGrid.length - 1] + groupSize);
934
+ }
935
+ }
936
+ for (let i = 0; i < swiper.virtual.slidesBefore + swiper.virtual.slidesAfter; i += 1) {
937
+ if (params.slidesPerGroup === 1) {
938
+ snapGrid.push(snapGrid[snapGrid.length - 1] + size);
939
+ }
940
+ slidesGrid.push(slidesGrid[slidesGrid.length - 1] + size);
941
+ swiper.virtualSize += size;
942
+ }
943
+ }
944
+ if (snapGrid.length === 0) snapGrid = [0];
945
+ if (params.spaceBetween !== 0) {
946
+ const key = swiper.isHorizontal() && rtl ? 'marginLeft' : getDirectionLabel('marginRight');
947
+ slides.filter((_, slideIndex) => {
948
+ if (!params.cssMode || params.loop) return true;
949
+ if (slideIndex === slides.length - 1) {
950
+ return false;
951
+ }
952
+ return true;
953
+ }).forEach(slideEl => {
954
+ slideEl.style[key] = `${spaceBetween}px`;
955
+ });
956
+ }
957
+ if (params.centeredSlides && params.centeredSlidesBounds) {
958
+ let allSlidesSize = 0;
959
+ slidesSizesGrid.forEach(slideSizeValue => {
960
+ allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0);
961
+ });
962
+ allSlidesSize -= params.spaceBetween;
963
+ const maxSnap = allSlidesSize - swiperSize;
964
+ snapGrid = snapGrid.map(snap => {
965
+ if (snap < 0) return -offsetBefore;
966
+ if (snap > maxSnap) return maxSnap + offsetAfter;
967
+ return snap;
968
+ });
969
+ }
970
+ if (params.centerInsufficientSlides) {
971
+ let allSlidesSize = 0;
972
+ slidesSizesGrid.forEach(slideSizeValue => {
973
+ allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0);
974
+ });
975
+ allSlidesSize -= params.spaceBetween;
976
+ if (allSlidesSize < swiperSize) {
977
+ const allSlidesOffset = (swiperSize - allSlidesSize) / 2;
978
+ snapGrid.forEach((snap, snapIndex) => {
979
+ snapGrid[snapIndex] = snap - allSlidesOffset;
980
+ });
981
+ slidesGrid.forEach((snap, snapIndex) => {
982
+ slidesGrid[snapIndex] = snap + allSlidesOffset;
983
+ });
984
+ }
985
+ }
986
+ Object.assign(swiper, {
987
+ slides,
988
+ snapGrid,
989
+ slidesGrid,
990
+ slidesSizesGrid
991
+ });
992
+ if (params.centeredSlides && params.cssMode && !params.centeredSlidesBounds) {
993
+ setCSSProperty(wrapperEl, '--swiper-centered-offset-before', `${-snapGrid[0]}px`);
994
+ setCSSProperty(wrapperEl, '--swiper-centered-offset-after', `${swiper.size / 2 - slidesSizesGrid[slidesSizesGrid.length - 1] / 2}px`);
995
+ const addToSnapGrid = -swiper.snapGrid[0];
996
+ const addToSlidesGrid = -swiper.slidesGrid[0];
997
+ swiper.snapGrid = swiper.snapGrid.map(v => v + addToSnapGrid);
998
+ swiper.slidesGrid = swiper.slidesGrid.map(v => v + addToSlidesGrid);
999
+ }
1000
+ if (slidesLength !== previousSlidesLength) {
1001
+ swiper.emit('slidesLengthChange');
1002
+ }
1003
+ if (snapGrid.length !== previousSnapGridLength) {
1004
+ if (swiper.params.watchOverflow) swiper.checkOverflow();
1005
+ swiper.emit('snapGridLengthChange');
1006
+ }
1007
+ if (slidesGrid.length !== previousSlidesGridLength) {
1008
+ swiper.emit('slidesGridLengthChange');
1009
+ }
1010
+ if (params.watchSlidesProgress) {
1011
+ swiper.updateSlidesOffset();
1012
+ }
1013
+ if (!isVirtual && !params.cssMode && (params.effect === 'slide' || params.effect === 'fade')) {
1014
+ const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`;
1015
+ const hasClassBackfaceClassAdded = swiper.el.classList.contains(backFaceHiddenClass);
1016
+ if (slidesLength <= params.maxBackfaceHiddenSlides) {
1017
+ if (!hasClassBackfaceClassAdded) swiper.el.classList.add(backFaceHiddenClass);
1018
+ } else if (hasClassBackfaceClassAdded) {
1019
+ swiper.el.classList.remove(backFaceHiddenClass);
1020
+ }
1021
+ }
1022
+ }
1023
+
1024
+ function updateAutoHeight(speed) {
1025
+ const swiper = this;
1026
+ const activeSlides = [];
1027
+ const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
1028
+ let newHeight = 0;
1029
+ let i;
1030
+ if (typeof speed === 'number') {
1031
+ swiper.setTransition(speed);
1032
+ } else if (speed === true) {
1033
+ swiper.setTransition(swiper.params.speed);
1034
+ }
1035
+ const getSlideByIndex = index => {
1036
+ if (isVirtual) {
1037
+ return swiper.getSlideIndexByData(index);
1038
+ }
1039
+ return swiper.slides[index];
1040
+ };
1041
+ // Find slides currently in view
1042
+ if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) {
1043
+ if (swiper.params.centeredSlides) {
1044
+ (swiper.visibleSlides || []).forEach(slide => {
1045
+ activeSlides.push(slide);
1046
+ });
1047
+ } else {
1048
+ for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
1049
+ const index = swiper.activeIndex + i;
1050
+ if (index > swiper.slides.length && !isVirtual) break;
1051
+ activeSlides.push(getSlideByIndex(index));
1052
+ }
1053
+ }
1054
+ } else {
1055
+ activeSlides.push(getSlideByIndex(swiper.activeIndex));
1056
+ }
1057
+
1058
+ // Find new height from highest slide in view
1059
+ for (i = 0; i < activeSlides.length; i += 1) {
1060
+ if (typeof activeSlides[i] !== 'undefined') {
1061
+ const height = activeSlides[i].offsetHeight;
1062
+ newHeight = height > newHeight ? height : newHeight;
1063
+ }
1064
+ }
1065
+
1066
+ // Update Height
1067
+ if (newHeight || newHeight === 0) swiper.wrapperEl.style.height = `${newHeight}px`;
1068
+ }
1069
+
1070
+ function updateSlidesOffset() {
1071
+ const swiper = this;
1072
+ const slides = swiper.slides;
1073
+ // eslint-disable-next-line
1074
+ const minusOffset = swiper.isElement ? swiper.isHorizontal() ? swiper.wrapperEl.offsetLeft : swiper.wrapperEl.offsetTop : 0;
1075
+ for (let i = 0; i < slides.length; i += 1) {
1076
+ slides[i].swiperSlideOffset = (swiper.isHorizontal() ? slides[i].offsetLeft : slides[i].offsetTop) - minusOffset;
1077
+ }
1078
+ }
1079
+
1080
+ function updateSlidesProgress(translate = this && this.translate || 0) {
1081
+ const swiper = this;
1082
+ const params = swiper.params;
1083
+ const {
1084
+ slides,
1085
+ rtlTranslate: rtl,
1086
+ snapGrid
1087
+ } = swiper;
1088
+ if (slides.length === 0) return;
1089
+ if (typeof slides[0].swiperSlideOffset === 'undefined') swiper.updateSlidesOffset();
1090
+ let offsetCenter = -translate;
1091
+ if (rtl) offsetCenter = translate;
1092
+
1093
+ // Visible Slides
1094
+ slides.forEach(slideEl => {
1095
+ slideEl.classList.remove(params.slideVisibleClass);
1096
+ });
1097
+ swiper.visibleSlidesIndexes = [];
1098
+ swiper.visibleSlides = [];
1099
+ for (let i = 0; i < slides.length; i += 1) {
1100
+ const slide = slides[i];
1101
+ let slideOffset = slide.swiperSlideOffset;
1102
+ if (params.cssMode && params.centeredSlides) {
1103
+ slideOffset -= slides[0].swiperSlideOffset;
1104
+ }
1105
+ const slideProgress = (offsetCenter + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + params.spaceBetween);
1106
+ const originalSlideProgress = (offsetCenter - snapGrid[0] + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + params.spaceBetween);
1107
+ const slideBefore = -(offsetCenter - slideOffset);
1108
+ const slideAfter = slideBefore + swiper.slidesSizesGrid[i];
1109
+ const isVisible = slideBefore >= 0 && slideBefore < swiper.size - 1 || slideAfter > 1 && slideAfter <= swiper.size || slideBefore <= 0 && slideAfter >= swiper.size;
1110
+ if (isVisible) {
1111
+ swiper.visibleSlides.push(slide);
1112
+ swiper.visibleSlidesIndexes.push(i);
1113
+ slides[i].classList.add(params.slideVisibleClass);
1114
+ }
1115
+ slide.progress = rtl ? -slideProgress : slideProgress;
1116
+ slide.originalProgress = rtl ? -originalSlideProgress : originalSlideProgress;
1117
+ }
1118
+ }
1119
+
1120
+ function updateProgress(translate) {
1121
+ const swiper = this;
1122
+ if (typeof translate === 'undefined') {
1123
+ const multiplier = swiper.rtlTranslate ? -1 : 1;
1124
+ // eslint-disable-next-line
1125
+ translate = swiper && swiper.translate && swiper.translate * multiplier || 0;
1126
+ }
1127
+ const params = swiper.params;
1128
+ const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
1129
+ let {
1130
+ progress,
1131
+ isBeginning,
1132
+ isEnd,
1133
+ progressLoop
1134
+ } = swiper;
1135
+ const wasBeginning = isBeginning;
1136
+ const wasEnd = isEnd;
1137
+ if (translatesDiff === 0) {
1138
+ progress = 0;
1139
+ isBeginning = true;
1140
+ isEnd = true;
1141
+ } else {
1142
+ progress = (translate - swiper.minTranslate()) / translatesDiff;
1143
+ const isBeginningRounded = Math.abs(translate - swiper.minTranslate()) < 1;
1144
+ const isEndRounded = Math.abs(translate - swiper.maxTranslate()) < 1;
1145
+ isBeginning = isBeginningRounded || progress <= 0;
1146
+ isEnd = isEndRounded || progress >= 1;
1147
+ if (isBeginningRounded) progress = 0;
1148
+ if (isEndRounded) progress = 1;
1149
+ }
1150
+ if (params.loop) {
1151
+ const firstSlideIndex = swiper.getSlideIndexByData(0);
1152
+ const lastSlideIndex = swiper.getSlideIndexByData(swiper.slides.length - 1);
1153
+ const firstSlideTranslate = swiper.slidesGrid[firstSlideIndex];
1154
+ const lastSlideTranslate = swiper.slidesGrid[lastSlideIndex];
1155
+ const translateMax = swiper.slidesGrid[swiper.slidesGrid.length - 1];
1156
+ const translateAbs = Math.abs(translate);
1157
+ if (translateAbs >= firstSlideTranslate) {
1158
+ progressLoop = (translateAbs - firstSlideTranslate) / translateMax;
1159
+ } else {
1160
+ progressLoop = (translateAbs + translateMax - lastSlideTranslate) / translateMax;
1161
+ }
1162
+ if (progressLoop > 1) progressLoop -= 1;
1163
+ }
1164
+ Object.assign(swiper, {
1165
+ progress,
1166
+ progressLoop,
1167
+ isBeginning,
1168
+ isEnd
1169
+ });
1170
+ if (params.watchSlidesProgress || params.centeredSlides && params.autoHeight) swiper.updateSlidesProgress(translate);
1171
+ if (isBeginning && !wasBeginning) {
1172
+ swiper.emit('reachBeginning toEdge');
1173
+ }
1174
+ if (isEnd && !wasEnd) {
1175
+ swiper.emit('reachEnd toEdge');
1176
+ }
1177
+ if (wasBeginning && !isBeginning || wasEnd && !isEnd) {
1178
+ swiper.emit('fromEdge');
1179
+ }
1180
+ swiper.emit('progress', progress);
1181
+ }
1182
+
1183
+ function updateSlidesClasses() {
1184
+ const swiper = this;
1185
+ const {
1186
+ slides,
1187
+ params,
1188
+ slidesEl,
1189
+ activeIndex
1190
+ } = swiper;
1191
+ const isVirtual = swiper.virtual && params.virtual.enabled;
1192
+ const getFilteredSlide = selector => {
1193
+ return elementChildren(slidesEl, `.${params.slideClass}${selector}, swiper-slide${selector}`)[0];
1194
+ };
1195
+ slides.forEach(slideEl => {
1196
+ slideEl.classList.remove(params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
1197
+ });
1198
+ let activeSlide;
1199
+ if (isVirtual) {
1200
+ if (params.loop) {
1201
+ let slideIndex = activeIndex - swiper.virtual.slidesBefore;
1202
+ if (slideIndex < 0) slideIndex = swiper.virtual.slides.length + slideIndex;
1203
+ if (slideIndex >= swiper.virtual.slides.length) slideIndex -= swiper.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
+ activeSlide = slides[activeIndex];
1210
+ }
1211
+ if (activeSlide) {
1212
+ // Active classes
1213
+ activeSlide.classList.add(params.slideActiveClass);
1214
+
1215
+ // Next Slide
1216
+ let nextSlide = elementNextAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
1217
+ if (params.loop && !nextSlide) {
1218
+ nextSlide = slides[0];
1219
+ }
1220
+ if (nextSlide) {
1221
+ nextSlide.classList.add(params.slideNextClass);
1222
+ }
1223
+ // Prev Slide
1224
+ let prevSlide = elementPrevAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
1225
+ if (params.loop && !prevSlide === 0) {
1226
+ prevSlide = slides[slides.length - 1];
1227
+ }
1228
+ if (prevSlide) {
1229
+ prevSlide.classList.add(params.slidePrevClass);
1230
+ }
1231
+ }
1232
+ swiper.emitSlidesClasses();
1233
+ }
1234
+
1235
+ function getActiveIndexByTranslate(swiper) {
1236
+ const {
1237
+ slidesGrid,
1238
+ params
1239
+ } = swiper;
1240
+ const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
1241
+ let activeIndex;
1242
+ for (let i = 0; i < slidesGrid.length; i += 1) {
1243
+ if (typeof slidesGrid[i + 1] !== 'undefined') {
1244
+ if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1] - (slidesGrid[i + 1] - slidesGrid[i]) / 2) {
1245
+ activeIndex = i;
1246
+ } else if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1]) {
1247
+ activeIndex = i + 1;
1248
+ }
1249
+ } else if (translate >= slidesGrid[i]) {
1250
+ activeIndex = i;
1251
+ }
1252
+ }
1253
+ // Normalize slideIndex
1254
+ if (params.normalizeSlideIndex) {
1255
+ if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0;
1256
+ }
1257
+ return activeIndex;
1258
+ }
1259
+ function updateActiveIndex(newActiveIndex) {
1260
+ const swiper = this;
1261
+ const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
1262
+ const {
1263
+ snapGrid,
1264
+ params,
1265
+ activeIndex: previousIndex,
1266
+ realIndex: previousRealIndex,
1267
+ snapIndex: previousSnapIndex
1268
+ } = swiper;
1269
+ let activeIndex = newActiveIndex;
1270
+ let snapIndex;
1271
+ const getVirtualRealIndex = aIndex => {
1272
+ let realIndex = aIndex - swiper.virtual.slidesBefore;
1273
+ if (realIndex < 0) {
1274
+ realIndex = swiper.virtual.slides.length + realIndex;
1275
+ }
1276
+ if (realIndex >= swiper.virtual.slides.length) {
1277
+ realIndex -= swiper.virtual.slides.length;
1278
+ }
1279
+ return realIndex;
1280
+ };
1281
+ if (typeof activeIndex === 'undefined') {
1282
+ activeIndex = getActiveIndexByTranslate(swiper);
1283
+ }
1284
+ if (snapGrid.indexOf(translate) >= 0) {
1285
+ snapIndex = snapGrid.indexOf(translate);
1286
+ } else {
1287
+ const skip = Math.min(params.slidesPerGroupSkip, activeIndex);
1288
+ snapIndex = skip + Math.floor((activeIndex - skip) / params.slidesPerGroup);
1289
+ }
1290
+ if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
1291
+ if (activeIndex === previousIndex) {
1292
+ if (snapIndex !== previousSnapIndex) {
1293
+ swiper.snapIndex = snapIndex;
1294
+ swiper.emit('snapIndexChange');
1295
+ }
1296
+ if (swiper.params.loop && swiper.virtual && swiper.params.virtual.enabled) {
1297
+ swiper.realIndex = getVirtualRealIndex(activeIndex);
1298
+ }
1299
+ return;
1300
+ }
1301
+ // Get real index
1302
+ let realIndex;
1303
+ if (swiper.virtual && params.virtual.enabled && params.loop) {
1304
+ realIndex = getVirtualRealIndex(activeIndex);
1305
+ } else if (swiper.slides[activeIndex]) {
1306
+ realIndex = parseInt(swiper.slides[activeIndex].getAttribute('data-swiper-slide-index') || activeIndex, 10);
1307
+ } else {
1308
+ realIndex = activeIndex;
1309
+ }
1310
+ Object.assign(swiper, {
1311
+ snapIndex,
1312
+ realIndex,
1313
+ previousIndex,
1314
+ activeIndex
1315
+ });
1316
+ swiper.emit('activeIndexChange');
1317
+ swiper.emit('snapIndexChange');
1318
+ if (previousRealIndex !== realIndex) {
1319
+ swiper.emit('realIndexChange');
1320
+ }
1321
+ if (swiper.initialized || swiper.params.runCallbacksOnInit) {
1322
+ swiper.emit('slideChange');
1323
+ }
1324
+ }
1325
+
1326
+ function updateClickedSlide(e) {
1327
+ const swiper = this;
1328
+ const params = swiper.params;
1329
+ const slide = e.closest(`.${params.slideClass}, swiper-slide`);
1330
+ let slideFound = false;
1331
+ let slideIndex;
1332
+ if (slide) {
1333
+ for (let i = 0; i < swiper.slides.length; i += 1) {
1334
+ if (swiper.slides[i] === slide) {
1335
+ slideFound = true;
1336
+ slideIndex = i;
1337
+ break;
1338
+ }
1339
+ }
1340
+ }
1341
+ if (slide && slideFound) {
1342
+ swiper.clickedSlide = slide;
1343
+ if (swiper.virtual && swiper.params.virtual.enabled) {
1344
+ swiper.clickedIndex = parseInt(slide.getAttribute('data-swiper-slide-index'), 10);
1345
+ } else {
1346
+ swiper.clickedIndex = slideIndex;
1347
+ }
1348
+ } else {
1349
+ swiper.clickedSlide = undefined;
1350
+ swiper.clickedIndex = undefined;
1351
+ return;
1352
+ }
1353
+ if (params.slideToClickedSlide && swiper.clickedIndex !== undefined && swiper.clickedIndex !== swiper.activeIndex) {
1354
+ swiper.slideToClickedSlide();
1355
+ }
1356
+ }
1357
+
1358
+ const update = {
1359
+ updateSize,
1360
+ updateSlides,
1361
+ updateAutoHeight,
1362
+ updateSlidesOffset,
1363
+ updateSlidesProgress,
1364
+ updateProgress,
1365
+ updateSlidesClasses,
1366
+ updateActiveIndex,
1367
+ updateClickedSlide
1368
+ };
1369
+
1370
+ function getSwiperTranslate(axis = this.isHorizontal() ? 'x' : 'y') {
1371
+ const swiper = this;
1372
+ const {
1373
+ params,
1374
+ rtlTranslate: rtl,
1375
+ translate,
1376
+ wrapperEl
1377
+ } = swiper;
1378
+ if (params.virtualTranslate) {
1379
+ return rtl ? -translate : translate;
1380
+ }
1381
+ if (params.cssMode) {
1382
+ return translate;
1383
+ }
1384
+ let currentTranslate = getTranslate(wrapperEl, axis);
1385
+ if (rtl) currentTranslate = -currentTranslate;
1386
+ return currentTranslate || 0;
1387
+ }
1388
+
1389
+ function setTranslate(translate, byController) {
1390
+ const swiper = this;
1391
+ const {
1392
+ rtlTranslate: rtl,
1393
+ params,
1394
+ wrapperEl,
1395
+ progress
1396
+ } = swiper;
1397
+ let x = 0;
1398
+ let y = 0;
1399
+ const z = 0;
1400
+ if (swiper.isHorizontal()) {
1401
+ x = rtl ? -translate : translate;
1402
+ } else {
1403
+ y = translate;
1404
+ }
1405
+ if (params.roundLengths) {
1406
+ x = Math.floor(x);
1407
+ y = Math.floor(y);
1408
+ }
1409
+ if (params.cssMode) {
1410
+ wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y;
1411
+ } else if (!params.virtualTranslate) {
1412
+ wrapperEl.style.transform = `translate3d(${x}px, ${y}px, ${z}px)`;
1413
+ }
1414
+ swiper.previousTranslate = swiper.translate;
1415
+ swiper.translate = swiper.isHorizontal() ? x : y;
1416
+
1417
+ // Check if we need to update progress
1418
+ let newProgress;
1419
+ const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
1420
+ if (translatesDiff === 0) {
1421
+ newProgress = 0;
1422
+ } else {
1423
+ newProgress = (translate - swiper.minTranslate()) / translatesDiff;
1424
+ }
1425
+ if (newProgress !== progress) {
1426
+ swiper.updateProgress(translate);
1427
+ }
1428
+ swiper.emit('setTranslate', swiper.translate, byController);
1429
+ }
1430
+
1431
+ function minTranslate() {
1432
+ return -this.snapGrid[0];
1433
+ }
1434
+
1435
+ function maxTranslate() {
1436
+ return -this.snapGrid[this.snapGrid.length - 1];
1437
+ }
1438
+
1439
+ function translateTo(translate = 0, speed = this.params.speed, runCallbacks = true, translateBounds = true, internal) {
1440
+ const swiper = this;
1441
+ const {
1442
+ params,
1443
+ wrapperEl
1444
+ } = swiper;
1445
+ if (swiper.animating && params.preventInteractionOnTransition) {
1446
+ return false;
1447
+ }
1448
+ const minTranslate = swiper.minTranslate();
1449
+ const maxTranslate = swiper.maxTranslate();
1450
+ let newTranslate;
1451
+ if (translateBounds && translate > minTranslate) newTranslate = minTranslate;else if (translateBounds && translate < maxTranslate) newTranslate = maxTranslate;else newTranslate = translate;
1452
+
1453
+ // Update progress
1454
+ swiper.updateProgress(newTranslate);
1455
+ if (params.cssMode) {
1456
+ const isH = swiper.isHorizontal();
1457
+ if (speed === 0) {
1458
+ wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = -newTranslate;
1459
+ } else {
1460
+ if (!swiper.support.smoothScroll) {
1461
+ animateCSSModeScroll({
1462
+ swiper,
1463
+ targetPosition: -newTranslate,
1464
+ side: isH ? 'left' : 'top'
1465
+ });
1466
+ return true;
1467
+ }
1468
+ wrapperEl.scrollTo({
1469
+ [isH ? 'left' : 'top']: -newTranslate,
1470
+ behavior: 'smooth'
1471
+ });
1472
+ }
1473
+ return true;
1474
+ }
1475
+ if (speed === 0) {
1476
+ swiper.setTransition(0);
1477
+ swiper.setTranslate(newTranslate);
1478
+ if (runCallbacks) {
1479
+ swiper.emit('beforeTransitionStart', speed, internal);
1480
+ swiper.emit('transitionEnd');
1481
+ }
1482
+ } else {
1483
+ swiper.setTransition(speed);
1484
+ swiper.setTranslate(newTranslate);
1485
+ if (runCallbacks) {
1486
+ swiper.emit('beforeTransitionStart', speed, internal);
1487
+ swiper.emit('transitionStart');
1488
+ }
1489
+ if (!swiper.animating) {
1490
+ swiper.animating = true;
1491
+ if (!swiper.onTranslateToWrapperTransitionEnd) {
1492
+ swiper.onTranslateToWrapperTransitionEnd = function transitionEnd(e) {
1493
+ if (!swiper || swiper.destroyed) return;
1494
+ if (e.target !== this) return;
1495
+ swiper.wrapperEl.removeEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd);
1496
+ swiper.onTranslateToWrapperTransitionEnd = null;
1497
+ delete swiper.onTranslateToWrapperTransitionEnd;
1498
+ if (runCallbacks) {
1499
+ swiper.emit('transitionEnd');
1500
+ }
1501
+ };
1502
+ }
1503
+ swiper.wrapperEl.addEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd);
1504
+ }
1505
+ }
1506
+ return true;
1507
+ }
1508
+
1509
+ const translate = {
1510
+ getTranslate: getSwiperTranslate,
1511
+ setTranslate,
1512
+ minTranslate,
1513
+ maxTranslate,
1514
+ translateTo
1515
+ };
1516
+
1517
+ function setTransition(duration, byController) {
1518
+ const swiper = this;
1519
+ if (!swiper.params.cssMode) {
1520
+ swiper.wrapperEl.style.transitionDuration = `${duration}ms`;
1521
+ }
1522
+ swiper.emit('setTransition', duration, byController);
1523
+ }
1524
+
1525
+ function transitionEmit({
1526
+ swiper,
1527
+ runCallbacks,
1528
+ direction,
1529
+ step
1530
+ }) {
1531
+ const {
1532
+ activeIndex,
1533
+ previousIndex
1534
+ } = swiper;
1535
+ let dir = direction;
1536
+ if (!dir) {
1537
+ if (activeIndex > previousIndex) dir = 'next';else if (activeIndex < previousIndex) dir = 'prev';else dir = 'reset';
1538
+ }
1539
+ swiper.emit(`transition${step}`);
1540
+ if (runCallbacks && activeIndex !== previousIndex) {
1541
+ if (dir === 'reset') {
1542
+ swiper.emit(`slideResetTransition${step}`);
1543
+ return;
1544
+ }
1545
+ swiper.emit(`slideChangeTransition${step}`);
1546
+ if (dir === 'next') {
1547
+ swiper.emit(`slideNextTransition${step}`);
1548
+ } else {
1549
+ swiper.emit(`slidePrevTransition${step}`);
1550
+ }
1551
+ }
1552
+ }
1553
+
1554
+ function transitionStart(runCallbacks = true, direction) {
1555
+ const swiper = this;
1556
+ const {
1557
+ params
1558
+ } = swiper;
1559
+ if (params.cssMode) return;
1560
+ if (params.autoHeight) {
1561
+ swiper.updateAutoHeight();
1562
+ }
1563
+ transitionEmit({
1564
+ swiper,
1565
+ runCallbacks,
1566
+ direction,
1567
+ step: 'Start'
1568
+ });
1569
+ }
1570
+
1571
+ function transitionEnd(runCallbacks = true, direction) {
1572
+ const swiper = this;
1573
+ const {
1574
+ params
1575
+ } = swiper;
1576
+ swiper.animating = false;
1577
+ if (params.cssMode) return;
1578
+ swiper.setTransition(0);
1579
+ transitionEmit({
1580
+ swiper,
1581
+ runCallbacks,
1582
+ direction,
1583
+ step: 'End'
1584
+ });
1585
+ }
1586
+
1587
+ const transition = {
1588
+ setTransition,
1589
+ transitionStart,
1590
+ transitionEnd
1591
+ };
1592
+
1593
+ function slideTo(index = 0, speed = this.params.speed, runCallbacks = true, internal, initial) {
1594
+ if (typeof index === 'string') {
1595
+ index = parseInt(index, 10);
1596
+ }
1597
+ const swiper = this;
1598
+ let slideIndex = index;
1599
+ if (slideIndex < 0) slideIndex = 0;
1600
+ const {
1601
+ params,
1602
+ snapGrid,
1603
+ slidesGrid,
1604
+ previousIndex,
1605
+ activeIndex,
1606
+ rtlTranslate: rtl,
1607
+ wrapperEl,
1608
+ enabled
1609
+ } = swiper;
1610
+ if (swiper.animating && params.preventInteractionOnTransition || !enabled && !internal && !initial) {
1611
+ return false;
1612
+ }
1613
+ const skip = Math.min(swiper.params.slidesPerGroupSkip, slideIndex);
1614
+ let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
1615
+ if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
1616
+ const translate = -snapGrid[snapIndex];
1617
+ // Normalize slideIndex
1618
+ if (params.normalizeSlideIndex) {
1619
+ for (let i = 0; i < slidesGrid.length; i += 1) {
1620
+ const normalizedTranslate = -Math.floor(translate * 100);
1621
+ const normalizedGrid = Math.floor(slidesGrid[i] * 100);
1622
+ const normalizedGridNext = Math.floor(slidesGrid[i + 1] * 100);
1623
+ if (typeof slidesGrid[i + 1] !== 'undefined') {
1624
+ if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext - (normalizedGridNext - normalizedGrid) / 2) {
1625
+ slideIndex = i;
1626
+ } else if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext) {
1627
+ slideIndex = i + 1;
1628
+ }
1629
+ } else if (normalizedTranslate >= normalizedGrid) {
1630
+ slideIndex = i;
1631
+ }
1632
+ }
1633
+ }
1634
+ // Directions locks
1635
+ if (swiper.initialized && slideIndex !== activeIndex) {
1636
+ if (!swiper.allowSlideNext && translate < swiper.translate && translate < swiper.minTranslate()) {
1637
+ return false;
1638
+ }
1639
+ if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) {
1640
+ if ((activeIndex || 0) !== slideIndex) {
1641
+ return false;
1642
+ }
1643
+ }
1644
+ }
1645
+ if (slideIndex !== (previousIndex || 0) && runCallbacks) {
1646
+ swiper.emit('beforeSlideChangeStart');
1647
+ }
1648
+
1649
+ // Update progress
1650
+ swiper.updateProgress(translate);
1651
+ let direction;
1652
+ if (slideIndex > activeIndex) direction = 'next';else if (slideIndex < activeIndex) direction = 'prev';else direction = 'reset';
1653
+
1654
+ // Update Index
1655
+ if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) {
1656
+ swiper.updateActiveIndex(slideIndex);
1657
+ // Update Height
1658
+ if (params.autoHeight) {
1659
+ swiper.updateAutoHeight();
1660
+ }
1661
+ swiper.updateSlidesClasses();
1662
+ if (params.effect !== 'slide') {
1663
+ swiper.setTranslate(translate);
1664
+ }
1665
+ if (direction !== 'reset') {
1666
+ swiper.transitionStart(runCallbacks, direction);
1667
+ swiper.transitionEnd(runCallbacks, direction);
1668
+ }
1669
+ return false;
1670
+ }
1671
+ if (params.cssMode) {
1672
+ const isH = swiper.isHorizontal();
1673
+ const t = rtl ? translate : -translate;
1674
+ if (speed === 0) {
1675
+ const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
1676
+ if (isVirtual) {
1677
+ swiper.wrapperEl.style.scrollSnapType = 'none';
1678
+ swiper._immediateVirtual = true;
1679
+ }
1680
+ if (isVirtual && !swiper._cssModeVirtualInitialSet && swiper.params.initialSlide > 0) {
1681
+ swiper._cssModeVirtualInitialSet = true;
1682
+ requestAnimationFrame(() => {
1683
+ wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
1684
+ });
1685
+ } else {
1686
+ wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
1687
+ }
1688
+ if (isVirtual) {
1689
+ requestAnimationFrame(() => {
1690
+ swiper.wrapperEl.style.scrollSnapType = '';
1691
+ swiper._immediateVirtual = false;
1692
+ });
1693
+ }
1694
+ } else {
1695
+ if (!swiper.support.smoothScroll) {
1696
+ animateCSSModeScroll({
1697
+ swiper,
1698
+ targetPosition: t,
1699
+ side: isH ? 'left' : 'top'
1700
+ });
1701
+ return true;
1702
+ }
1703
+ wrapperEl.scrollTo({
1704
+ [isH ? 'left' : 'top']: t,
1705
+ behavior: 'smooth'
1706
+ });
1707
+ }
1708
+ return true;
1709
+ }
1710
+ swiper.setTransition(speed);
1711
+ swiper.setTranslate(translate);
1712
+ swiper.updateActiveIndex(slideIndex);
1713
+ swiper.updateSlidesClasses();
1714
+ swiper.emit('beforeTransitionStart', speed, internal);
1715
+ swiper.transitionStart(runCallbacks, direction);
1716
+ if (speed === 0) {
1717
+ swiper.transitionEnd(runCallbacks, direction);
1718
+ } else if (!swiper.animating) {
1719
+ swiper.animating = true;
1720
+ if (!swiper.onSlideToWrapperTransitionEnd) {
1721
+ swiper.onSlideToWrapperTransitionEnd = function transitionEnd(e) {
1722
+ if (!swiper || swiper.destroyed) return;
1723
+ if (e.target !== this) return;
1724
+ swiper.wrapperEl.removeEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
1725
+ swiper.onSlideToWrapperTransitionEnd = null;
1726
+ delete swiper.onSlideToWrapperTransitionEnd;
1727
+ swiper.transitionEnd(runCallbacks, direction);
1728
+ };
1729
+ }
1730
+ swiper.wrapperEl.addEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
1731
+ }
1732
+ return true;
1733
+ }
1734
+
1735
+ function slideToLoop(index = 0, speed = this.params.speed, runCallbacks = true, internal) {
1736
+ if (typeof index === 'string') {
1737
+ const indexAsNumber = parseInt(index, 10);
1738
+ index = indexAsNumber;
1739
+ }
1740
+ const swiper = this;
1741
+ let newIndex = index;
1742
+ if (swiper.params.loop) {
1743
+ if (swiper.virtual && swiper.params.virtual.enabled) {
1744
+ // eslint-disable-next-line
1745
+ newIndex = newIndex + swiper.virtual.slidesBefore;
1746
+ } else {
1747
+ newIndex = swiper.getSlideIndexByData(newIndex);
1748
+ }
1749
+ }
1750
+ return swiper.slideTo(newIndex, speed, runCallbacks, internal);
1751
+ }
1752
+
1753
+ /* eslint no-unused-vars: "off" */
1754
+ function slideNext(speed = this.params.speed, runCallbacks = true, internal) {
1755
+ const swiper = this;
1756
+ const {
1757
+ enabled,
1758
+ params,
1759
+ animating
1760
+ } = swiper;
1761
+ if (!enabled) return swiper;
1762
+ let perGroup = params.slidesPerGroup;
1763
+ if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
1764
+ perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1);
1765
+ }
1766
+ const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup;
1767
+ const isVirtual = swiper.virtual && params.virtual.enabled;
1768
+ if (params.loop) {
1769
+ if (animating && !isVirtual && params.loopPreventsSliding) return false;
1770
+ swiper.loopFix({
1771
+ direction: 'next'
1772
+ });
1773
+ // eslint-disable-next-line
1774
+ swiper._clientLeft = swiper.wrapperEl.clientLeft;
1775
+ }
1776
+ if (params.rewind && swiper.isEnd) {
1777
+ return swiper.slideTo(0, speed, runCallbacks, internal);
1778
+ }
1779
+ return swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal);
1780
+ }
1781
+
1782
+ /* eslint no-unused-vars: "off" */
1783
+ function slidePrev(speed = this.params.speed, runCallbacks = true, internal) {
1784
+ const swiper = this;
1785
+ const {
1786
+ params,
1787
+ snapGrid,
1788
+ slidesGrid,
1789
+ rtlTranslate,
1790
+ enabled,
1791
+ animating
1792
+ } = swiper;
1793
+ if (!enabled) return swiper;
1794
+ const isVirtual = swiper.virtual && params.virtual.enabled;
1795
+ if (params.loop) {
1796
+ if (animating && !isVirtual && params.loopPreventsSliding) return false;
1797
+ swiper.loopFix({
1798
+ direction: 'prev'
1799
+ });
1800
+ // eslint-disable-next-line
1801
+ swiper._clientLeft = swiper.wrapperEl.clientLeft;
1802
+ }
1803
+ const translate = rtlTranslate ? swiper.translate : -swiper.translate;
1804
+ function normalize(val) {
1805
+ if (val < 0) return -Math.floor(Math.abs(val));
1806
+ return Math.floor(val);
1807
+ }
1808
+ const normalizedTranslate = normalize(translate);
1809
+ const normalizedSnapGrid = snapGrid.map(val => normalize(val));
1810
+ let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
1811
+ if (typeof prevSnap === 'undefined' && params.cssMode) {
1812
+ let prevSnapIndex;
1813
+ snapGrid.forEach((snap, snapIndex) => {
1814
+ if (normalizedTranslate >= snap) {
1815
+ // prevSnap = snap;
1816
+ prevSnapIndex = snapIndex;
1817
+ }
1818
+ });
1819
+ if (typeof prevSnapIndex !== 'undefined') {
1820
+ prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
1821
+ }
1822
+ }
1823
+ let prevIndex = 0;
1824
+ if (typeof prevSnap !== 'undefined') {
1825
+ prevIndex = slidesGrid.indexOf(prevSnap);
1826
+ if (prevIndex < 0) prevIndex = swiper.activeIndex - 1;
1827
+ if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
1828
+ prevIndex = prevIndex - swiper.slidesPerViewDynamic('previous', true) + 1;
1829
+ prevIndex = Math.max(prevIndex, 0);
1830
+ }
1831
+ }
1832
+ if (params.rewind && swiper.isBeginning) {
1833
+ const lastIndex = swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1;
1834
+ return swiper.slideTo(lastIndex, speed, runCallbacks, internal);
1835
+ }
1836
+ return swiper.slideTo(prevIndex, speed, runCallbacks, internal);
1837
+ }
1838
+
1839
+ /* eslint no-unused-vars: "off" */
1840
+ function slideReset(speed = this.params.speed, runCallbacks = true, internal) {
1841
+ const swiper = this;
1842
+ return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal);
1843
+ }
1844
+
1845
+ /* eslint no-unused-vars: "off" */
1846
+ function slideToClosest(speed = this.params.speed, runCallbacks = true, internal, threshold = 0.5) {
1847
+ const swiper = this;
1848
+ let index = swiper.activeIndex;
1849
+ const skip = Math.min(swiper.params.slidesPerGroupSkip, index);
1850
+ const snapIndex = skip + Math.floor((index - skip) / swiper.params.slidesPerGroup);
1851
+ const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
1852
+ if (translate >= swiper.snapGrid[snapIndex]) {
1853
+ // The current translate is on or after the current snap index, so the choice
1854
+ // is between the current index and the one after it.
1855
+ const currentSnap = swiper.snapGrid[snapIndex];
1856
+ const nextSnap = swiper.snapGrid[snapIndex + 1];
1857
+ if (translate - currentSnap > (nextSnap - currentSnap) * threshold) {
1858
+ index += swiper.params.slidesPerGroup;
1859
+ }
1860
+ } else {
1861
+ // The current translate is before the current snap index, so the choice
1862
+ // is between the current index and the one before it.
1863
+ const prevSnap = swiper.snapGrid[snapIndex - 1];
1864
+ const currentSnap = swiper.snapGrid[snapIndex];
1865
+ if (translate - prevSnap <= (currentSnap - prevSnap) * threshold) {
1866
+ index -= swiper.params.slidesPerGroup;
1867
+ }
1868
+ }
1869
+ index = Math.max(index, 0);
1870
+ index = Math.min(index, swiper.slidesGrid.length - 1);
1871
+ return swiper.slideTo(index, speed, runCallbacks, internal);
1872
+ }
1873
+
1874
+ function slideToClickedSlide() {
1875
+ const swiper = this;
1876
+ const {
1877
+ params,
1878
+ slidesEl
1879
+ } = swiper;
1880
+ const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
1881
+ let slideToIndex = swiper.clickedIndex;
1882
+ let realIndex;
1883
+ const slideSelector = swiper.isElement ? `swiper-slide` : `.${params.slideClass}`;
1884
+ if (params.loop) {
1885
+ if (swiper.animating) return;
1886
+ realIndex = parseInt(swiper.clickedSlide.getAttribute('data-swiper-slide-index'), 10);
1887
+ if (params.centeredSlides) {
1888
+ if (slideToIndex < swiper.loopedSlides - slidesPerView / 2 || slideToIndex > swiper.slides.length - swiper.loopedSlides + slidesPerView / 2) {
1889
+ swiper.loopFix();
1890
+ slideToIndex = swiper.getSlideIndex(elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0]);
1891
+ nextTick(() => {
1892
+ swiper.slideTo(slideToIndex);
1893
+ });
1894
+ } else {
1895
+ swiper.slideTo(slideToIndex);
1896
+ }
1897
+ } else if (slideToIndex > swiper.slides.length - slidesPerView) {
1898
+ swiper.loopFix();
1899
+ slideToIndex = swiper.getSlideIndex(elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0]);
1900
+ nextTick(() => {
1901
+ swiper.slideTo(slideToIndex);
1902
+ });
1903
+ } else {
1904
+ swiper.slideTo(slideToIndex);
1905
+ }
1906
+ } else {
1907
+ swiper.slideTo(slideToIndex);
1908
+ }
1909
+ }
1910
+
1911
+ const slide = {
1912
+ slideTo,
1913
+ slideToLoop,
1914
+ slideNext,
1915
+ slidePrev,
1916
+ slideReset,
1917
+ slideToClosest,
1918
+ slideToClickedSlide
1919
+ };
1920
+
1921
+ function loopCreate(slideRealIndex) {
1922
+ const swiper = this;
1923
+ const {
1924
+ params,
1925
+ slidesEl
1926
+ } = swiper;
1927
+ if (!params.loop || swiper.virtual && swiper.params.virtual.enabled) return;
1928
+ const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
1929
+ slides.forEach((el, index) => {
1930
+ el.setAttribute('data-swiper-slide-index', index);
1931
+ });
1932
+ swiper.loopFix({
1933
+ slideRealIndex,
1934
+ direction: params.centeredSlides ? undefined : 'next'
1935
+ });
1936
+ }
1937
+
1938
+ function loopFix({
1939
+ slideRealIndex,
1940
+ slideTo = true,
1941
+ direction,
1942
+ setTranslate,
1943
+ activeSlideIndex,
1944
+ byController,
1945
+ byMousewheel
1946
+ } = {}) {
1947
+ const swiper = this;
1948
+ if (!swiper.params.loop) return;
1949
+ swiper.emit('beforeLoopFix');
1950
+ const {
1951
+ slides,
1952
+ allowSlidePrev,
1953
+ allowSlideNext,
1954
+ slidesEl,
1955
+ params
1956
+ } = swiper;
1957
+ swiper.allowSlidePrev = true;
1958
+ swiper.allowSlideNext = true;
1959
+ if (swiper.virtual && params.virtual.enabled) {
1960
+ if (slideTo) {
1961
+ if (!params.centeredSlides && swiper.snapIndex === 0) {
1962
+ swiper.slideTo(swiper.virtual.slides.length, 0, false, true);
1963
+ } else if (params.centeredSlides && swiper.snapIndex < params.slidesPerView) {
1964
+ swiper.slideTo(swiper.virtual.slides.length + swiper.snapIndex, 0, false, true);
1965
+ } else if (swiper.snapIndex === swiper.snapGrid.length - 1) {
1966
+ swiper.slideTo(swiper.virtual.slidesBefore, 0, false, true);
1967
+ }
1968
+ }
1969
+ swiper.allowSlidePrev = allowSlidePrev;
1970
+ swiper.allowSlideNext = allowSlideNext;
1971
+ swiper.emit('loopFix');
1972
+ return;
1973
+ }
1974
+ const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10));
1975
+ let loopedSlides = params.loopedSlides || slidesPerView;
1976
+ if (loopedSlides % params.slidesPerGroup !== 0) {
1977
+ loopedSlides += params.slidesPerGroup - loopedSlides % params.slidesPerGroup;
1978
+ }
1979
+ swiper.loopedSlides = loopedSlides;
1980
+ const prependSlidesIndexes = [];
1981
+ const appendSlidesIndexes = [];
1982
+ let activeIndex = swiper.activeIndex;
1983
+ if (typeof activeSlideIndex === 'undefined') {
1984
+ activeSlideIndex = swiper.getSlideIndex(swiper.slides.filter(el => el.classList.contains(params.slideActiveClass))[0]);
1985
+ } else {
1986
+ activeIndex = activeSlideIndex;
1987
+ }
1988
+ const isNext = direction === 'next' || !direction;
1989
+ const isPrev = direction === 'prev' || !direction;
1990
+ let slidesPrepended = 0;
1991
+ let slidesAppended = 0;
1992
+ // prepend last slides before start
1993
+ if (activeSlideIndex < loopedSlides) {
1994
+ slidesPrepended = Math.max(loopedSlides - activeSlideIndex, params.slidesPerGroup);
1995
+ for (let i = 0; i < loopedSlides - activeSlideIndex; i += 1) {
1996
+ const index = i - Math.floor(i / slides.length) * slides.length;
1997
+ prependSlidesIndexes.push(slides.length - index - 1);
1998
+ }
1999
+ } else if (activeSlideIndex /* + slidesPerView */ > swiper.slides.length - loopedSlides * 2) {
2000
+ slidesAppended = Math.max(activeSlideIndex - (swiper.slides.length - loopedSlides * 2), params.slidesPerGroup);
2001
+ for (let i = 0; i < slidesAppended; i += 1) {
2002
+ const index = i - Math.floor(i / slides.length) * slides.length;
2003
+ appendSlidesIndexes.push(index);
2004
+ }
2005
+ }
2006
+ if (isPrev) {
2007
+ prependSlidesIndexes.forEach(index => {
2008
+ slidesEl.prepend(swiper.slides[index]);
2009
+ });
2010
+ }
2011
+ if (isNext) {
2012
+ appendSlidesIndexes.forEach(index => {
2013
+ slidesEl.append(swiper.slides[index]);
2014
+ });
2015
+ }
2016
+ swiper.recalcSlides();
2017
+ if (params.watchSlidesProgress) {
2018
+ swiper.updateSlidesOffset();
2019
+ }
2020
+ if (slideTo) {
2021
+ if (prependSlidesIndexes.length > 0 && isPrev) {
2022
+ if (typeof slideRealIndex === 'undefined') {
2023
+ const currentSlideTranslate = swiper.slidesGrid[activeIndex];
2024
+ const newSlideTranslate = swiper.slidesGrid[activeIndex + slidesPrepended];
2025
+ const diff = newSlideTranslate - currentSlideTranslate;
2026
+ if (byMousewheel) {
2027
+ swiper.setTranslate(swiper.translate - diff);
2028
+ } else {
2029
+ swiper.slideTo(activeIndex + slidesPrepended, 0, false, true);
2030
+ if (setTranslate) {
2031
+ swiper.touches[swiper.isHorizontal() ? 'startX' : 'startY'] += diff;
2032
+ }
2033
+ }
2034
+ } else {
2035
+ if (setTranslate) {
2036
+ swiper.slideToLoop(slideRealIndex, 0, false, true);
2037
+ }
2038
+ }
2039
+ } else if (appendSlidesIndexes.length > 0 && isNext) {
2040
+ if (typeof slideRealIndex === 'undefined') {
2041
+ const currentSlideTranslate = swiper.slidesGrid[activeIndex];
2042
+ const newSlideTranslate = swiper.slidesGrid[activeIndex - slidesAppended];
2043
+ const diff = newSlideTranslate - currentSlideTranslate;
2044
+ if (byMousewheel) {
2045
+ swiper.setTranslate(swiper.translate - diff);
2046
+ } else {
2047
+ swiper.slideTo(activeIndex - slidesAppended, 0, false, true);
2048
+ if (setTranslate) {
2049
+ swiper.touches[swiper.isHorizontal() ? 'startX' : 'startY'] += diff;
2050
+ }
2051
+ }
2052
+ } else {
2053
+ swiper.slideToLoop(slideRealIndex, 0, false, true);
2054
+ }
2055
+ }
2056
+ }
2057
+ swiper.allowSlidePrev = allowSlidePrev;
2058
+ swiper.allowSlideNext = allowSlideNext;
2059
+ if (swiper.controller && swiper.controller.control && !byController) {
2060
+ const loopParams = {
2061
+ slideRealIndex,
2062
+ slideTo: false,
2063
+ direction,
2064
+ setTranslate,
2065
+ activeSlideIndex,
2066
+ byController: true
2067
+ };
2068
+ if (Array.isArray(swiper.controller.control)) {
2069
+ swiper.controller.control.forEach(c => {
2070
+ if (!c.destroyed && c.params.loop) c.loopFix(loopParams);
2071
+ });
2072
+ } else if (swiper.controller.control instanceof swiper.constructor && swiper.controller.control.params.loop) {
2073
+ swiper.controller.control.loopFix(loopParams);
2074
+ }
2075
+ }
2076
+ swiper.emit('loopFix');
2077
+ }
2078
+
2079
+ function loopDestroy() {
2080
+ const swiper = this;
2081
+ const {
2082
+ params,
2083
+ slidesEl
2084
+ } = swiper;
2085
+ if (!params.loop || swiper.virtual && swiper.params.virtual.enabled) return;
2086
+ swiper.recalcSlides();
2087
+ const newSlidesOrder = [];
2088
+ swiper.slides.forEach(slideEl => {
2089
+ const index = typeof slideEl.swiperSlideIndex === 'undefined' ? slideEl.getAttribute('data-swiper-slide-index') * 1 : slideEl.swiperSlideIndex;
2090
+ newSlidesOrder[index] = slideEl;
2091
+ });
2092
+ swiper.slides.forEach(slideEl => {
2093
+ slideEl.removeAttribute('data-swiper-slide-index');
2094
+ });
2095
+ newSlidesOrder.forEach(slideEl => {
2096
+ slidesEl.append(slideEl);
2097
+ });
2098
+ swiper.recalcSlides();
2099
+ swiper.slideTo(swiper.realIndex, 0);
2100
+ }
2101
+
2102
+ const loop = {
2103
+ loopCreate,
2104
+ loopFix,
2105
+ loopDestroy
2106
+ };
2107
+
2108
+ function setGrabCursor(moving) {
2109
+ const swiper = this;
2110
+ if (!swiper.params.simulateTouch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) return;
2111
+ const el = swiper.params.touchEventsTarget === 'container' ? swiper.el : swiper.wrapperEl;
2112
+ if (swiper.isElement) {
2113
+ swiper.__preventObserver__ = true;
2114
+ }
2115
+ el.style.cursor = 'move';
2116
+ el.style.cursor = moving ? 'grabbing' : 'grab';
2117
+ if (swiper.isElement) {
2118
+ requestAnimationFrame(() => {
2119
+ swiper.__preventObserver__ = false;
2120
+ });
2121
+ }
2122
+ }
2123
+
2124
+ function unsetGrabCursor() {
2125
+ const swiper = this;
2126
+ if (swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) {
2127
+ return;
2128
+ }
2129
+ if (swiper.isElement) {
2130
+ swiper.__preventObserver__ = true;
2131
+ }
2132
+ swiper[swiper.params.touchEventsTarget === 'container' ? 'el' : 'wrapperEl'].style.cursor = '';
2133
+ if (swiper.isElement) {
2134
+ requestAnimationFrame(() => {
2135
+ swiper.__preventObserver__ = false;
2136
+ });
2137
+ }
2138
+ }
2139
+
2140
+ const grabCursor = {
2141
+ setGrabCursor,
2142
+ unsetGrabCursor
2143
+ };
2144
+
2145
+ // Modified from https://stackoverflow.com/questions/54520554/custom-element-getrootnode-closest-function-crossing-multiple-parent-shadowd
2146
+ function closestElement(selector, base = this) {
2147
+ function __closestFrom(el) {
2148
+ if (!el || el === getDocument() || el === getWindow()) return null;
2149
+ if (el.assignedSlot) el = el.assignedSlot;
2150
+ const found = el.closest(selector);
2151
+ if (!found && !el.getRootNode) {
2152
+ return null;
2153
+ }
2154
+ return found || __closestFrom(el.getRootNode().host);
2155
+ }
2156
+ return __closestFrom(base);
2157
+ }
2158
+ function onTouchStart(event) {
2159
+ const swiper = this;
2160
+ const document = getDocument();
2161
+ const window = getWindow();
2162
+ const data = swiper.touchEventsData;
2163
+ data.evCache.push(event);
2164
+ const {
2165
+ params,
2166
+ touches,
2167
+ enabled
2168
+ } = swiper;
2169
+ if (!enabled) return;
2170
+ if (!params.simulateTouch && event.pointerType === 'mouse') return;
2171
+ if (swiper.animating && params.preventInteractionOnTransition) {
2172
+ return;
2173
+ }
2174
+ if (!swiper.animating && params.cssMode && params.loop) {
2175
+ swiper.loopFix();
2176
+ }
2177
+ let e = event;
2178
+ if (e.originalEvent) e = e.originalEvent;
2179
+ let targetEl = e.target;
2180
+ if (params.touchEventsTarget === 'wrapper') {
2181
+ if (!swiper.wrapperEl.contains(targetEl)) return;
2182
+ }
2183
+ if ('which' in e && e.which === 3) return;
2184
+ if ('button' in e && e.button > 0) return;
2185
+ if (data.isTouched && data.isMoved) return;
2186
+
2187
+ // change target el for shadow root component
2188
+ const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== '';
2189
+ // eslint-disable-next-line
2190
+ const eventPath = event.composedPath ? event.composedPath() : event.path;
2191
+ if (swipingClassHasValue && e.target && e.target.shadowRoot && eventPath) {
2192
+ targetEl = eventPath[0];
2193
+ }
2194
+ const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`;
2195
+ const isTargetShadow = !!(e.target && e.target.shadowRoot);
2196
+
2197
+ // use closestElement for shadow root element to get the actual closest for nested shadow root element
2198
+ if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, targetEl) : targetEl.closest(noSwipingSelector))) {
2199
+ swiper.allowClick = true;
2200
+ return;
2201
+ }
2202
+ if (params.swipeHandler) {
2203
+ if (!targetEl.closest(params.swipeHandler)) return;
2204
+ }
2205
+ touches.currentX = e.pageX;
2206
+ touches.currentY = e.pageY;
2207
+ const startX = touches.currentX;
2208
+ const startY = touches.currentY;
2209
+
2210
+ // Do NOT start if iOS edge swipe is detected. Otherwise iOS app cannot swipe-to-go-back anymore
2211
+
2212
+ const edgeSwipeDetection = params.edgeSwipeDetection || params.iOSEdgeSwipeDetection;
2213
+ const edgeSwipeThreshold = params.edgeSwipeThreshold || params.iOSEdgeSwipeThreshold;
2214
+ if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window.innerWidth - edgeSwipeThreshold)) {
2215
+ if (edgeSwipeDetection === 'prevent') {
2216
+ event.preventDefault();
2217
+ } else {
2218
+ return;
2219
+ }
2220
+ }
2221
+ Object.assign(data, {
2222
+ isTouched: true,
2223
+ isMoved: false,
2224
+ allowTouchCallbacks: true,
2225
+ isScrolling: undefined,
2226
+ startMoving: undefined
2227
+ });
2228
+ touches.startX = startX;
2229
+ touches.startY = startY;
2230
+ data.touchStartTime = now();
2231
+ swiper.allowClick = true;
2232
+ swiper.updateSize();
2233
+ swiper.swipeDirection = undefined;
2234
+ if (params.threshold > 0) data.allowThresholdMove = false;
2235
+ let preventDefault = true;
2236
+ if (targetEl.matches(data.focusableElements)) {
2237
+ preventDefault = false;
2238
+ if (targetEl.nodeName === 'SELECT') {
2239
+ data.isTouched = false;
2240
+ }
2241
+ }
2242
+ if (document.activeElement && document.activeElement.matches(data.focusableElements) && document.activeElement !== targetEl) {
2243
+ document.activeElement.blur();
2244
+ }
2245
+ const shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault;
2246
+ if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !targetEl.isContentEditable) {
2247
+ e.preventDefault();
2248
+ }
2249
+ if (swiper.params.freeMode && swiper.params.freeMode.enabled && swiper.freeMode && swiper.animating && !params.cssMode) {
2250
+ swiper.freeMode.onTouchStart();
2251
+ }
2252
+ swiper.emit('touchStart', e);
2253
+ }
2254
+
2255
+ function onTouchMove(event) {
2256
+ const document = getDocument();
2257
+ const swiper = this;
2258
+ const data = swiper.touchEventsData;
2259
+ const {
2260
+ params,
2261
+ touches,
2262
+ rtlTranslate: rtl,
2263
+ enabled
2264
+ } = swiper;
2265
+ if (!enabled) return;
2266
+ if (!params.simulateTouch && event.pointerType === 'mouse') return;
2267
+ let e = event;
2268
+ if (e.originalEvent) e = e.originalEvent;
2269
+ if (!data.isTouched) {
2270
+ if (data.startMoving && data.isScrolling) {
2271
+ swiper.emit('touchMoveOpposite', e);
2272
+ }
2273
+ return;
2274
+ }
2275
+ const pointerIndex = data.evCache.findIndex(cachedEv => cachedEv.pointerId === e.pointerId);
2276
+ if (pointerIndex >= 0) data.evCache[pointerIndex] = e;
2277
+ const targetTouch = data.evCache.length > 1 ? data.evCache[0] : e;
2278
+ const pageX = targetTouch.pageX;
2279
+ const pageY = targetTouch.pageY;
2280
+ if (e.preventedByNestedSwiper) {
2281
+ touches.startX = pageX;
2282
+ touches.startY = pageY;
2283
+ return;
2284
+ }
2285
+ if (!swiper.allowTouchMove) {
2286
+ if (!e.target.matches(data.focusableElements)) {
2287
+ swiper.allowClick = false;
2288
+ }
2289
+ if (data.isTouched) {
2290
+ Object.assign(touches, {
2291
+ startX: pageX,
2292
+ startY: pageY,
2293
+ prevX: swiper.touches.currentX,
2294
+ prevY: swiper.touches.currentY,
2295
+ currentX: pageX,
2296
+ currentY: pageY
2297
+ });
2298
+ data.touchStartTime = now();
2299
+ }
2300
+ return;
2301
+ }
2302
+ if (params.touchReleaseOnEdges && !params.loop) {
2303
+ if (swiper.isVertical()) {
2304
+ // Vertical
2305
+ if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) {
2306
+ data.isTouched = false;
2307
+ data.isMoved = false;
2308
+ return;
2309
+ }
2310
+ } else if (pageX < touches.startX && swiper.translate <= swiper.maxTranslate() || pageX > touches.startX && swiper.translate >= swiper.minTranslate()) {
2311
+ return;
2312
+ }
2313
+ }
2314
+ if (document.activeElement) {
2315
+ if (e.target === document.activeElement && e.target.matches(data.focusableElements)) {
2316
+ data.isMoved = true;
2317
+ swiper.allowClick = false;
2318
+ return;
2319
+ }
2320
+ }
2321
+ if (data.allowTouchCallbacks) {
2322
+ swiper.emit('touchMove', e);
2323
+ }
2324
+ if (e.targetTouches && e.targetTouches.length > 1) return;
2325
+ touches.currentX = pageX;
2326
+ touches.currentY = pageY;
2327
+ const diffX = touches.currentX - touches.startX;
2328
+ const diffY = touches.currentY - touches.startY;
2329
+ if (swiper.params.threshold && Math.sqrt(diffX ** 2 + diffY ** 2) < swiper.params.threshold) return;
2330
+ if (typeof data.isScrolling === 'undefined') {
2331
+ let touchAngle;
2332
+ if (swiper.isHorizontal() && touches.currentY === touches.startY || swiper.isVertical() && touches.currentX === touches.startX) {
2333
+ data.isScrolling = false;
2334
+ } else {
2335
+ // eslint-disable-next-line
2336
+ if (diffX * diffX + diffY * diffY >= 25) {
2337
+ touchAngle = Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180 / Math.PI;
2338
+ data.isScrolling = swiper.isHorizontal() ? touchAngle > params.touchAngle : 90 - touchAngle > params.touchAngle;
2339
+ }
2340
+ }
2341
+ }
2342
+ if (data.isScrolling) {
2343
+ swiper.emit('touchMoveOpposite', e);
2344
+ }
2345
+ if (typeof data.startMoving === 'undefined') {
2346
+ if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) {
2347
+ data.startMoving = true;
2348
+ }
2349
+ }
2350
+ if (data.isScrolling || swiper.zoom && swiper.params.zoom && swiper.params.zoom.enabled && data.evCache.length > 1) {
2351
+ data.isTouched = false;
2352
+ return;
2353
+ }
2354
+ if (!data.startMoving) {
2355
+ return;
2356
+ }
2357
+ swiper.allowClick = false;
2358
+ if (!params.cssMode && e.cancelable) {
2359
+ e.preventDefault();
2360
+ }
2361
+ if (params.touchMoveStopPropagation && !params.nested) {
2362
+ e.stopPropagation();
2363
+ }
2364
+ let diff = swiper.isHorizontal() ? diffX : diffY;
2365
+ let touchesDiff = swiper.isHorizontal() ? touches.currentX - touches.previousX : touches.currentY - touches.previousY;
2366
+ if (params.oneWayMovement) {
2367
+ diff = Math.abs(diff) * (rtl ? 1 : -1);
2368
+ touchesDiff = Math.abs(touchesDiff) * (rtl ? 1 : -1);
2369
+ }
2370
+ touches.diff = diff;
2371
+ diff *= params.touchRatio;
2372
+ if (rtl) {
2373
+ diff = -diff;
2374
+ touchesDiff = -touchesDiff;
2375
+ }
2376
+ const prevTouchesDirection = swiper.touchesDirection;
2377
+ swiper.swipeDirection = diff > 0 ? 'prev' : 'next';
2378
+ swiper.touchesDirection = touchesDiff > 0 ? 'prev' : 'next';
2379
+ const isLoop = swiper.params.loop && !params.cssMode;
2380
+ if (!data.isMoved) {
2381
+ if (isLoop) {
2382
+ swiper.loopFix({
2383
+ direction: swiper.swipeDirection
2384
+ });
2385
+ }
2386
+ data.startTranslate = swiper.getTranslate();
2387
+ swiper.setTransition(0);
2388
+ if (swiper.animating) {
2389
+ const evt = new window.CustomEvent('transitionend', {
2390
+ bubbles: true,
2391
+ cancelable: true
2392
+ });
2393
+ swiper.wrapperEl.dispatchEvent(evt);
2394
+ }
2395
+ data.allowMomentumBounce = false;
2396
+ // Grab Cursor
2397
+ if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
2398
+ swiper.setGrabCursor(true);
2399
+ }
2400
+ swiper.emit('sliderFirstMove', e);
2401
+ }
2402
+ let loopFixed;
2403
+ if (data.isMoved && prevTouchesDirection !== swiper.touchesDirection && isLoop && Math.abs(diff) >= 1) {
2404
+ // need another loop fix
2405
+ swiper.loopFix({
2406
+ direction: swiper.swipeDirection,
2407
+ setTranslate: true
2408
+ });
2409
+ loopFixed = true;
2410
+ }
2411
+ swiper.emit('sliderMove', e);
2412
+ data.isMoved = true;
2413
+ data.currentTranslate = diff + data.startTranslate;
2414
+ let disableParentSwiper = true;
2415
+ let resistanceRatio = params.resistanceRatio;
2416
+ if (params.touchReleaseOnEdges) {
2417
+ resistanceRatio = 0;
2418
+ }
2419
+ if (diff > 0) {
2420
+ if (isLoop && !loopFixed && data.currentTranslate > (params.centeredSlides ? swiper.minTranslate() - swiper.size / 2 : swiper.minTranslate())) {
2421
+ swiper.loopFix({
2422
+ direction: 'prev',
2423
+ setTranslate: true,
2424
+ activeSlideIndex: 0
2425
+ });
2426
+ }
2427
+ if (data.currentTranslate > swiper.minTranslate()) {
2428
+ disableParentSwiper = false;
2429
+ if (params.resistance) {
2430
+ data.currentTranslate = swiper.minTranslate() - 1 + (-swiper.minTranslate() + data.startTranslate + diff) ** resistanceRatio;
2431
+ }
2432
+ }
2433
+ } else if (diff < 0) {
2434
+ if (isLoop && !loopFixed && data.currentTranslate < (params.centeredSlides ? swiper.maxTranslate() + swiper.size / 2 : swiper.maxTranslate())) {
2435
+ swiper.loopFix({
2436
+ direction: 'next',
2437
+ setTranslate: true,
2438
+ activeSlideIndex: swiper.slides.length - (params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10)))
2439
+ });
2440
+ }
2441
+ if (data.currentTranslate < swiper.maxTranslate()) {
2442
+ disableParentSwiper = false;
2443
+ if (params.resistance) {
2444
+ data.currentTranslate = swiper.maxTranslate() + 1 - (swiper.maxTranslate() - data.startTranslate - diff) ** resistanceRatio;
2445
+ }
2446
+ }
2447
+ }
2448
+ if (disableParentSwiper) {
2449
+ e.preventedByNestedSwiper = true;
2450
+ }
2451
+
2452
+ // Directions locks
2453
+ if (!swiper.allowSlideNext && swiper.swipeDirection === 'next' && data.currentTranslate < data.startTranslate) {
2454
+ data.currentTranslate = data.startTranslate;
2455
+ }
2456
+ if (!swiper.allowSlidePrev && swiper.swipeDirection === 'prev' && data.currentTranslate > data.startTranslate) {
2457
+ data.currentTranslate = data.startTranslate;
2458
+ }
2459
+ if (!swiper.allowSlidePrev && !swiper.allowSlideNext) {
2460
+ data.currentTranslate = data.startTranslate;
2461
+ }
2462
+
2463
+ // Threshold
2464
+ if (params.threshold > 0) {
2465
+ if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
2466
+ if (!data.allowThresholdMove) {
2467
+ data.allowThresholdMove = true;
2468
+ touches.startX = touches.currentX;
2469
+ touches.startY = touches.currentY;
2470
+ data.currentTranslate = data.startTranslate;
2471
+ touches.diff = swiper.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches.startY;
2472
+ return;
2473
+ }
2474
+ } else {
2475
+ data.currentTranslate = data.startTranslate;
2476
+ return;
2477
+ }
2478
+ }
2479
+ if (!params.followFinger || params.cssMode) return;
2480
+
2481
+ // Update active index in free mode
2482
+ if (params.freeMode && params.freeMode.enabled && swiper.freeMode || params.watchSlidesProgress) {
2483
+ swiper.updateActiveIndex();
2484
+ swiper.updateSlidesClasses();
2485
+ }
2486
+ if (swiper.params.freeMode && params.freeMode.enabled && swiper.freeMode) {
2487
+ swiper.freeMode.onTouchMove();
2488
+ }
2489
+ // Update progress
2490
+ swiper.updateProgress(data.currentTranslate);
2491
+ // Update translate
2492
+ swiper.setTranslate(data.currentTranslate);
2493
+ }
2494
+
2495
+ function onTouchEnd(event) {
2496
+ const swiper = this;
2497
+ const data = swiper.touchEventsData;
2498
+ const pointerIndex = data.evCache.findIndex(cachedEv => cachedEv.pointerId === event.pointerId);
2499
+ if (pointerIndex >= 0) {
2500
+ data.evCache.splice(pointerIndex, 1);
2501
+ }
2502
+ if (['pointercancel', 'pointerout', 'pointerleave'].includes(event.type)) {
2503
+ const proceed = event.type === 'pointercancel' && (swiper.browser.isSafari || swiper.browser.isWebView);
2504
+ if (!proceed) {
2505
+ return;
2506
+ }
2507
+ }
2508
+ const {
2509
+ params,
2510
+ touches,
2511
+ rtlTranslate: rtl,
2512
+ slidesGrid,
2513
+ enabled
2514
+ } = swiper;
2515
+ if (!enabled) return;
2516
+ if (!params.simulateTouch && event.pointerType === 'mouse') return;
2517
+ let e = event;
2518
+ if (e.originalEvent) e = e.originalEvent;
2519
+ if (data.allowTouchCallbacks) {
2520
+ swiper.emit('touchEnd', e);
2521
+ }
2522
+ data.allowTouchCallbacks = false;
2523
+ if (!data.isTouched) {
2524
+ if (data.isMoved && params.grabCursor) {
2525
+ swiper.setGrabCursor(false);
2526
+ }
2527
+ data.isMoved = false;
2528
+ data.startMoving = false;
2529
+ return;
2530
+ }
2531
+ // Return Grab Cursor
2532
+ if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
2533
+ swiper.setGrabCursor(false);
2534
+ }
2535
+
2536
+ // Time diff
2537
+ const touchEndTime = now();
2538
+ const timeDiff = touchEndTime - data.touchStartTime;
2539
+
2540
+ // Tap, doubleTap, Click
2541
+ if (swiper.allowClick) {
2542
+ const pathTree = e.path || e.composedPath && e.composedPath();
2543
+ swiper.updateClickedSlide(pathTree && pathTree[0] || e.target);
2544
+ swiper.emit('tap click', e);
2545
+ if (timeDiff < 300 && touchEndTime - data.lastClickTime < 300) {
2546
+ swiper.emit('doubleTap doubleClick', e);
2547
+ }
2548
+ }
2549
+ data.lastClickTime = now();
2550
+ nextTick(() => {
2551
+ if (!swiper.destroyed) swiper.allowClick = true;
2552
+ });
2553
+ if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 || data.currentTranslate === data.startTranslate) {
2554
+ data.isTouched = false;
2555
+ data.isMoved = false;
2556
+ data.startMoving = false;
2557
+ return;
2558
+ }
2559
+ data.isTouched = false;
2560
+ data.isMoved = false;
2561
+ data.startMoving = false;
2562
+ let currentPos;
2563
+ if (params.followFinger) {
2564
+ currentPos = rtl ? swiper.translate : -swiper.translate;
2565
+ } else {
2566
+ currentPos = -data.currentTranslate;
2567
+ }
2568
+ if (params.cssMode) {
2569
+ return;
2570
+ }
2571
+ if (swiper.params.freeMode && params.freeMode.enabled) {
2572
+ swiper.freeMode.onTouchEnd({
2573
+ currentPos
2574
+ });
2575
+ return;
2576
+ }
2577
+
2578
+ // Find current slide
2579
+ let stopIndex = 0;
2580
+ let groupSize = swiper.slidesSizesGrid[0];
2581
+ for (let i = 0; i < slidesGrid.length; i += i < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup) {
2582
+ const increment = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
2583
+ if (typeof slidesGrid[i + increment] !== 'undefined') {
2584
+ if (currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + increment]) {
2585
+ stopIndex = i;
2586
+ groupSize = slidesGrid[i + increment] - slidesGrid[i];
2587
+ }
2588
+ } else if (currentPos >= slidesGrid[i]) {
2589
+ stopIndex = i;
2590
+ groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2];
2591
+ }
2592
+ }
2593
+ let rewindFirstIndex = null;
2594
+ let rewindLastIndex = null;
2595
+ if (params.rewind) {
2596
+ if (swiper.isBeginning) {
2597
+ rewindLastIndex = swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1;
2598
+ } else if (swiper.isEnd) {
2599
+ rewindFirstIndex = 0;
2600
+ }
2601
+ }
2602
+ // Find current slide size
2603
+ const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
2604
+ const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
2605
+ if (timeDiff > params.longSwipesMs) {
2606
+ // Long touches
2607
+ if (!params.longSwipes) {
2608
+ swiper.slideTo(swiper.activeIndex);
2609
+ return;
2610
+ }
2611
+ if (swiper.swipeDirection === 'next') {
2612
+ if (ratio >= params.longSwipesRatio) swiper.slideTo(params.rewind && swiper.isEnd ? rewindFirstIndex : stopIndex + increment);else swiper.slideTo(stopIndex);
2613
+ }
2614
+ if (swiper.swipeDirection === 'prev') {
2615
+ if (ratio > 1 - params.longSwipesRatio) {
2616
+ swiper.slideTo(stopIndex + increment);
2617
+ } else if (rewindLastIndex !== null && ratio < 0 && Math.abs(ratio) > params.longSwipesRatio) {
2618
+ swiper.slideTo(rewindLastIndex);
2619
+ } else {
2620
+ swiper.slideTo(stopIndex);
2621
+ }
2622
+ }
2623
+ } else {
2624
+ // Short swipes
2625
+ if (!params.shortSwipes) {
2626
+ swiper.slideTo(swiper.activeIndex);
2627
+ return;
2628
+ }
2629
+ const isNavButtonTarget = swiper.navigation && (e.target === swiper.navigation.nextEl || e.target === swiper.navigation.prevEl);
2630
+ if (!isNavButtonTarget) {
2631
+ if (swiper.swipeDirection === 'next') {
2632
+ swiper.slideTo(rewindFirstIndex !== null ? rewindFirstIndex : stopIndex + increment);
2633
+ }
2634
+ if (swiper.swipeDirection === 'prev') {
2635
+ swiper.slideTo(rewindLastIndex !== null ? rewindLastIndex : stopIndex);
2636
+ }
2637
+ } else if (e.target === swiper.navigation.nextEl) {
2638
+ swiper.slideTo(stopIndex + increment);
2639
+ } else {
2640
+ swiper.slideTo(stopIndex);
2641
+ }
2642
+ }
2643
+ }
2644
+
2645
+ let timeout;
2646
+ function onResize() {
2647
+ const swiper = this;
2648
+ const {
2649
+ params,
2650
+ el
2651
+ } = swiper;
2652
+ if (el && el.offsetWidth === 0) return;
2653
+
2654
+ // Breakpoints
2655
+ if (params.breakpoints) {
2656
+ swiper.setBreakpoint();
2657
+ }
2658
+
2659
+ // Save locks
2660
+ const {
2661
+ allowSlideNext,
2662
+ allowSlidePrev,
2663
+ snapGrid
2664
+ } = swiper;
2665
+ const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
2666
+
2667
+ // Disable locks on resize
2668
+ swiper.allowSlideNext = true;
2669
+ swiper.allowSlidePrev = true;
2670
+ swiper.updateSize();
2671
+ swiper.updateSlides();
2672
+ swiper.updateSlidesClasses();
2673
+ const isVirtualLoop = isVirtual && params.loop;
2674
+ if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides && !isVirtualLoop) {
2675
+ swiper.slideTo(swiper.slides.length - 1, 0, false, true);
2676
+ } else {
2677
+ if (swiper.params.loop && !isVirtual) {
2678
+ swiper.slideToLoop(swiper.realIndex, 0, false, true);
2679
+ } else {
2680
+ swiper.slideTo(swiper.activeIndex, 0, false, true);
2681
+ }
2682
+ }
2683
+ if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
2684
+ clearTimeout(timeout);
2685
+ timeout = setTimeout(() => {
2686
+ if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
2687
+ swiper.autoplay.resume();
2688
+ }
2689
+ }, 500);
2690
+ }
2691
+ // Return locks after resize
2692
+ swiper.allowSlidePrev = allowSlidePrev;
2693
+ swiper.allowSlideNext = allowSlideNext;
2694
+ if (swiper.params.watchOverflow && snapGrid !== swiper.snapGrid) {
2695
+ swiper.checkOverflow();
2696
+ }
2697
+ }
2698
+
2699
+ function onClick(e) {
2700
+ const swiper = this;
2701
+ if (!swiper.enabled) return;
2702
+ if (!swiper.allowClick) {
2703
+ if (swiper.params.preventClicks) e.preventDefault();
2704
+ if (swiper.params.preventClicksPropagation && swiper.animating) {
2705
+ e.stopPropagation();
2706
+ e.stopImmediatePropagation();
2707
+ }
2708
+ }
2709
+ }
2710
+
2711
+ function onScroll() {
2712
+ const swiper = this;
2713
+ const {
2714
+ wrapperEl,
2715
+ rtlTranslate,
2716
+ enabled
2717
+ } = swiper;
2718
+ if (!enabled) return;
2719
+ swiper.previousTranslate = swiper.translate;
2720
+ if (swiper.isHorizontal()) {
2721
+ swiper.translate = -wrapperEl.scrollLeft;
2722
+ } else {
2723
+ swiper.translate = -wrapperEl.scrollTop;
2724
+ }
2725
+ // eslint-disable-next-line
2726
+ if (swiper.translate === 0) swiper.translate = 0;
2727
+ swiper.updateActiveIndex();
2728
+ swiper.updateSlidesClasses();
2729
+ let newProgress;
2730
+ const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
2731
+ if (translatesDiff === 0) {
2732
+ newProgress = 0;
2733
+ } else {
2734
+ newProgress = (swiper.translate - swiper.minTranslate()) / translatesDiff;
2735
+ }
2736
+ if (newProgress !== swiper.progress) {
2737
+ swiper.updateProgress(rtlTranslate ? -swiper.translate : swiper.translate);
2738
+ }
2739
+ swiper.emit('setTranslate', swiper.translate, false);
2740
+ }
2741
+
2742
+ const processLazyPreloader = (swiper, imageEl) => {
2743
+ if (!swiper || swiper.destroyed || !swiper.params) return;
2744
+ const slideSelector = () => swiper.isElement ? `swiper-slide` : `.${swiper.params.slideClass}`;
2745
+ const slideEl = imageEl.closest(slideSelector());
2746
+ if (slideEl) {
2747
+ const lazyEl = slideEl.querySelector(`.${swiper.params.lazyPreloaderClass}`);
2748
+ if (lazyEl) lazyEl.remove();
2749
+ }
2750
+ };
2751
+
2752
+ function onLoad(e) {
2753
+ const swiper = this;
2754
+ processLazyPreloader(swiper, e.target);
2755
+ swiper.update();
2756
+ }
2757
+
2758
+ let dummyEventAttached = false;
2759
+ function dummyEventListener() {}
2760
+ const events = (swiper, method) => {
2761
+ const document = getDocument();
2762
+ const {
2763
+ params,
2764
+ el,
2765
+ wrapperEl,
2766
+ device
2767
+ } = swiper;
2768
+ const capture = !!params.nested;
2769
+ const domMethod = method === 'on' ? 'addEventListener' : 'removeEventListener';
2770
+ const swiperMethod = method;
2771
+
2772
+ // Touch Events
2773
+ el[domMethod]('pointerdown', swiper.onTouchStart, {
2774
+ passive: false
2775
+ });
2776
+ document[domMethod]('pointermove', swiper.onTouchMove, {
2777
+ passive: false,
2778
+ capture
2779
+ });
2780
+ document[domMethod]('pointerup', swiper.onTouchEnd, {
2781
+ passive: true
2782
+ });
2783
+ document[domMethod]('pointercancel', swiper.onTouchEnd, {
2784
+ passive: true
2785
+ });
2786
+ document[domMethod]('pointerout', swiper.onTouchEnd, {
2787
+ passive: true
2788
+ });
2789
+ document[domMethod]('pointerleave', swiper.onTouchEnd, {
2790
+ passive: true
2791
+ });
2792
+
2793
+ // Prevent Links Clicks
2794
+ if (params.preventClicks || params.preventClicksPropagation) {
2795
+ el[domMethod]('click', swiper.onClick, true);
2796
+ }
2797
+ if (params.cssMode) {
2798
+ wrapperEl[domMethod]('scroll', swiper.onScroll);
2799
+ }
2800
+
2801
+ // Resize handler
2802
+ if (params.updateOnWindowResize) {
2803
+ swiper[swiperMethod](device.ios || device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate', onResize, true);
2804
+ } else {
2805
+ swiper[swiperMethod]('observerUpdate', onResize, true);
2806
+ }
2807
+
2808
+ // Images loader
2809
+ el[domMethod]('load', swiper.onLoad, {
2810
+ capture: true
2811
+ });
2812
+ };
2813
+ function attachEvents() {
2814
+ const swiper = this;
2815
+ const document = getDocument();
2816
+ const {
2817
+ params
2818
+ } = swiper;
2819
+ swiper.onTouchStart = onTouchStart.bind(swiper);
2820
+ swiper.onTouchMove = onTouchMove.bind(swiper);
2821
+ swiper.onTouchEnd = onTouchEnd.bind(swiper);
2822
+ if (params.cssMode) {
2823
+ swiper.onScroll = onScroll.bind(swiper);
2824
+ }
2825
+ swiper.onClick = onClick.bind(swiper);
2826
+ swiper.onLoad = onLoad.bind(swiper);
2827
+ if (!dummyEventAttached) {
2828
+ document.addEventListener('touchstart', dummyEventListener);
2829
+ dummyEventAttached = true;
2830
+ }
2831
+ events(swiper, 'on');
2832
+ }
2833
+ function detachEvents() {
2834
+ const swiper = this;
2835
+ events(swiper, 'off');
2836
+ }
2837
+ const events$1 = {
2838
+ attachEvents,
2839
+ detachEvents
2840
+ };
2841
+
2842
+ const isGridEnabled = (swiper, params) => {
2843
+ return swiper.grid && params.grid && params.grid.rows > 1;
2844
+ };
2845
+ function setBreakpoint() {
2846
+ const swiper = this;
2847
+ const {
2848
+ realIndex,
2849
+ initialized,
2850
+ params,
2851
+ el
2852
+ } = swiper;
2853
+ const breakpoints = params.breakpoints;
2854
+ if (!breakpoints || breakpoints && Object.keys(breakpoints).length === 0) return;
2855
+
2856
+ // Get breakpoint for window width and update parameters
2857
+ const breakpoint = swiper.getBreakpoint(breakpoints, swiper.params.breakpointsBase, swiper.el);
2858
+ if (!breakpoint || swiper.currentBreakpoint === breakpoint) return;
2859
+ const breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined;
2860
+ const breakpointParams = breakpointOnlyParams || swiper.originalParams;
2861
+ const wasMultiRow = isGridEnabled(swiper, params);
2862
+ const isMultiRow = isGridEnabled(swiper, breakpointParams);
2863
+ const wasEnabled = params.enabled;
2864
+ if (wasMultiRow && !isMultiRow) {
2865
+ el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`);
2866
+ swiper.emitContainerClasses();
2867
+ } else if (!wasMultiRow && isMultiRow) {
2868
+ el.classList.add(`${params.containerModifierClass}grid`);
2869
+ if (breakpointParams.grid.fill && breakpointParams.grid.fill === 'column' || !breakpointParams.grid.fill && params.grid.fill === 'column') {
2870
+ el.classList.add(`${params.containerModifierClass}grid-column`);
2871
+ }
2872
+ swiper.emitContainerClasses();
2873
+ }
2874
+
2875
+ // Toggle navigation, pagination, scrollbar
2876
+ ['navigation', 'pagination', 'scrollbar'].forEach(prop => {
2877
+ const wasModuleEnabled = params[prop] && params[prop].enabled;
2878
+ const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
2879
+ if (wasModuleEnabled && !isModuleEnabled) {
2880
+ swiper[prop].disable();
2881
+ }
2882
+ if (!wasModuleEnabled && isModuleEnabled) {
2883
+ swiper[prop].enable();
2884
+ }
2885
+ });
2886
+ const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction;
2887
+ const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged);
2888
+ if (directionChanged && initialized) {
2889
+ swiper.changeDirection();
2890
+ }
2891
+ extend(swiper.params, breakpointParams);
2892
+ const isEnabled = swiper.params.enabled;
2893
+ Object.assign(swiper, {
2894
+ allowTouchMove: swiper.params.allowTouchMove,
2895
+ allowSlideNext: swiper.params.allowSlideNext,
2896
+ allowSlidePrev: swiper.params.allowSlidePrev
2897
+ });
2898
+ if (wasEnabled && !isEnabled) {
2899
+ swiper.disable();
2900
+ } else if (!wasEnabled && isEnabled) {
2901
+ swiper.enable();
2902
+ }
2903
+ swiper.currentBreakpoint = breakpoint;
2904
+ swiper.emit('_beforeBreakpoint', breakpointParams);
2905
+ if (needsReLoop && initialized) {
2906
+ swiper.loopDestroy();
2907
+ swiper.loopCreate(realIndex);
2908
+ swiper.updateSlides();
2909
+ }
2910
+ swiper.emit('breakpoint', breakpointParams);
2911
+ }
2912
+
2913
+ function getBreakpoint(breakpoints, base = 'window', containerEl) {
2914
+ if (!breakpoints || base === 'container' && !containerEl) return undefined;
2915
+ let breakpoint = false;
2916
+ const window = getWindow();
2917
+ const currentHeight = base === 'window' ? window.innerHeight : containerEl.clientHeight;
2918
+ const points = Object.keys(breakpoints).map(point => {
2919
+ if (typeof point === 'string' && point.indexOf('@') === 0) {
2920
+ const minRatio = parseFloat(point.substr(1));
2921
+ const value = currentHeight * minRatio;
2922
+ return {
2923
+ value,
2924
+ point
2925
+ };
2926
+ }
2927
+ return {
2928
+ value: point,
2929
+ point
2930
+ };
2931
+ });
2932
+ points.sort((a, b) => parseInt(a.value, 10) - parseInt(b.value, 10));
2933
+ for (let i = 0; i < points.length; i += 1) {
2934
+ const {
2935
+ point,
2936
+ value
2937
+ } = points[i];
2938
+ if (base === 'window') {
2939
+ if (window.matchMedia(`(min-width: ${value}px)`).matches) {
2940
+ breakpoint = point;
2941
+ }
2942
+ } else if (value <= containerEl.clientWidth) {
2943
+ breakpoint = point;
2944
+ }
2945
+ }
2946
+ return breakpoint || 'max';
2947
+ }
2948
+
2949
+ const breakpoints = {
2950
+ setBreakpoint,
2951
+ getBreakpoint
2952
+ };
2953
+
2954
+ function prepareClasses(entries, prefix) {
2955
+ const resultClasses = [];
2956
+ entries.forEach(item => {
2957
+ if (typeof item === 'object') {
2958
+ Object.keys(item).forEach(classNames => {
2959
+ if (item[classNames]) {
2960
+ resultClasses.push(prefix + classNames);
2961
+ }
2962
+ });
2963
+ } else if (typeof item === 'string') {
2964
+ resultClasses.push(prefix + item);
2965
+ }
2966
+ });
2967
+ return resultClasses;
2968
+ }
2969
+ function addClasses() {
2970
+ const swiper = this;
2971
+ const {
2972
+ classNames,
2973
+ params,
2974
+ rtl,
2975
+ el,
2976
+ device
2977
+ } = swiper;
2978
+ // prettier-ignore
2979
+ const suffixes = prepareClasses(['initialized', params.direction, {
2980
+ 'free-mode': swiper.params.freeMode && params.freeMode.enabled
2981
+ }, {
2982
+ 'autoheight': params.autoHeight
2983
+ }, {
2984
+ 'rtl': rtl
2985
+ }, {
2986
+ 'grid': params.grid && params.grid.rows > 1
2987
+ }, {
2988
+ 'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column'
2989
+ }, {
2990
+ 'android': device.android
2991
+ }, {
2992
+ 'ios': device.ios
2993
+ }, {
2994
+ 'css-mode': params.cssMode
2995
+ }, {
2996
+ 'centered': params.cssMode && params.centeredSlides
2997
+ }, {
2998
+ 'watch-progress': params.watchSlidesProgress
2999
+ }], params.containerModifierClass);
3000
+ classNames.push(...suffixes);
3001
+ el.classList.add(...classNames);
3002
+ swiper.emitContainerClasses();
3003
+ }
3004
+
3005
+ function removeClasses() {
3006
+ const swiper = this;
3007
+ const {
3008
+ el,
3009
+ classNames
3010
+ } = swiper;
3011
+ el.classList.remove(...classNames);
3012
+ swiper.emitContainerClasses();
3013
+ }
3014
+
3015
+ const classes = {
3016
+ addClasses,
3017
+ removeClasses
3018
+ };
3019
+
3020
+ function checkOverflow() {
3021
+ const swiper = this;
3022
+ const {
3023
+ isLocked: wasLocked,
3024
+ params
3025
+ } = swiper;
3026
+ const {
3027
+ slidesOffsetBefore
3028
+ } = params;
3029
+ if (slidesOffsetBefore) {
3030
+ const lastSlideIndex = swiper.slides.length - 1;
3031
+ const lastSlideRightEdge = swiper.slidesGrid[lastSlideIndex] + swiper.slidesSizesGrid[lastSlideIndex] + slidesOffsetBefore * 2;
3032
+ swiper.isLocked = swiper.size > lastSlideRightEdge;
3033
+ } else {
3034
+ swiper.isLocked = swiper.snapGrid.length === 1;
3035
+ }
3036
+ if (params.allowSlideNext === true) {
3037
+ swiper.allowSlideNext = !swiper.isLocked;
3038
+ }
3039
+ if (params.allowSlidePrev === true) {
3040
+ swiper.allowSlidePrev = !swiper.isLocked;
3041
+ }
3042
+ if (wasLocked && wasLocked !== swiper.isLocked) {
3043
+ swiper.isEnd = false;
3044
+ }
3045
+ if (wasLocked !== swiper.isLocked) {
3046
+ swiper.emit(swiper.isLocked ? 'lock' : 'unlock');
3047
+ }
3048
+ }
3049
+ const checkOverflow$1 = {
3050
+ checkOverflow
3051
+ };
3052
+
3053
+ const defaults = {
3054
+ init: true,
3055
+ direction: 'horizontal',
3056
+ oneWayMovement: false,
3057
+ touchEventsTarget: 'wrapper',
3058
+ initialSlide: 0,
3059
+ speed: 300,
3060
+ cssMode: false,
3061
+ updateOnWindowResize: true,
3062
+ resizeObserver: true,
3063
+ nested: false,
3064
+ createElements: false,
3065
+ enabled: true,
3066
+ focusableElements: 'input, select, option, textarea, button, video, label',
3067
+ // Overrides
3068
+ width: null,
3069
+ height: null,
3070
+ //
3071
+ preventInteractionOnTransition: false,
3072
+ // ssr
3073
+ userAgent: null,
3074
+ url: null,
3075
+ // To support iOS's swipe-to-go-back gesture (when being used in-app).
3076
+ edgeSwipeDetection: false,
3077
+ edgeSwipeThreshold: 20,
3078
+ // Autoheight
3079
+ autoHeight: false,
3080
+ // Set wrapper width
3081
+ setWrapperSize: false,
3082
+ // Virtual Translate
3083
+ virtualTranslate: false,
3084
+ // Effects
3085
+ effect: 'slide',
3086
+ // 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
3087
+
3088
+ // Breakpoints
3089
+ breakpoints: undefined,
3090
+ breakpointsBase: 'window',
3091
+ // Slides grid
3092
+ spaceBetween: 0,
3093
+ slidesPerView: 1,
3094
+ slidesPerGroup: 1,
3095
+ slidesPerGroupSkip: 0,
3096
+ slidesPerGroupAuto: false,
3097
+ centeredSlides: false,
3098
+ centeredSlidesBounds: false,
3099
+ slidesOffsetBefore: 0,
3100
+ // in px
3101
+ slidesOffsetAfter: 0,
3102
+ // in px
3103
+ normalizeSlideIndex: true,
3104
+ centerInsufficientSlides: false,
3105
+ // Disable swiper and hide navigation when container not overflow
3106
+ watchOverflow: true,
3107
+ // Round length
3108
+ roundLengths: false,
3109
+ // Touches
3110
+ touchRatio: 1,
3111
+ touchAngle: 45,
3112
+ simulateTouch: true,
3113
+ shortSwipes: true,
3114
+ longSwipes: true,
3115
+ longSwipesRatio: 0.5,
3116
+ longSwipesMs: 300,
3117
+ followFinger: true,
3118
+ allowTouchMove: true,
3119
+ threshold: 5,
3120
+ touchMoveStopPropagation: false,
3121
+ touchStartPreventDefault: true,
3122
+ touchStartForcePreventDefault: false,
3123
+ touchReleaseOnEdges: false,
3124
+ // Unique Navigation Elements
3125
+ uniqueNavElements: true,
3126
+ // Resistance
3127
+ resistance: true,
3128
+ resistanceRatio: 0.85,
3129
+ // Progress
3130
+ watchSlidesProgress: false,
3131
+ // Cursor
3132
+ grabCursor: false,
3133
+ // Clicks
3134
+ preventClicks: true,
3135
+ preventClicksPropagation: true,
3136
+ slideToClickedSlide: false,
3137
+ // loop
3138
+ loop: false,
3139
+ loopedSlides: null,
3140
+ loopPreventsSliding: true,
3141
+ // rewind
3142
+ rewind: false,
3143
+ // Swiping/no swiping
3144
+ allowSlidePrev: true,
3145
+ allowSlideNext: true,
3146
+ swipeHandler: null,
3147
+ // '.swipe-handler',
3148
+ noSwiping: true,
3149
+ noSwipingClass: 'swiper-no-swiping',
3150
+ noSwipingSelector: null,
3151
+ // Passive Listeners
3152
+ passiveListeners: true,
3153
+ maxBackfaceHiddenSlides: 10,
3154
+ // NS
3155
+ containerModifierClass: 'swiper-',
3156
+ // NEW
3157
+ slideClass: 'swiper-slide',
3158
+ slideActiveClass: 'swiper-slide-active',
3159
+ slideVisibleClass: 'swiper-slide-visible',
3160
+ slideNextClass: 'swiper-slide-next',
3161
+ slidePrevClass: 'swiper-slide-prev',
3162
+ wrapperClass: 'swiper-wrapper',
3163
+ lazyPreloaderClass: 'swiper-lazy-preloader',
3164
+ // Callbacks
3165
+ runCallbacksOnInit: true,
3166
+ // Internals
3167
+ _emitClasses: false
3168
+ };
3169
+
3170
+ function moduleExtendParams(params, allModulesParams) {
3171
+ return function extendParams(obj = {}) {
3172
+ const moduleParamName = Object.keys(obj)[0];
3173
+ const moduleParams = obj[moduleParamName];
3174
+ if (typeof moduleParams !== 'object' || moduleParams === null) {
3175
+ extend(allModulesParams, obj);
3176
+ return;
3177
+ }
3178
+ if (['navigation', 'pagination', 'scrollbar'].indexOf(moduleParamName) >= 0 && params[moduleParamName] === true) {
3179
+ params[moduleParamName] = {
3180
+ auto: true
3181
+ };
3182
+ }
3183
+ if (!(moduleParamName in params && 'enabled' in moduleParams)) {
3184
+ extend(allModulesParams, obj);
3185
+ return;
3186
+ }
3187
+ if (params[moduleParamName] === true) {
3188
+ params[moduleParamName] = {
3189
+ enabled: true
3190
+ };
3191
+ }
3192
+ if (typeof params[moduleParamName] === 'object' && !('enabled' in params[moduleParamName])) {
3193
+ params[moduleParamName].enabled = true;
3194
+ }
3195
+ if (!params[moduleParamName]) params[moduleParamName] = {
3196
+ enabled: false
3197
+ };
3198
+ extend(allModulesParams, obj);
3199
+ };
3200
+ }
3201
+
3202
+ /* eslint no-param-reassign: "off" */
3203
+ const prototypes = {
3204
+ eventsEmitter,
3205
+ update,
3206
+ translate,
3207
+ transition,
3208
+ slide,
3209
+ loop,
3210
+ grabCursor,
3211
+ events: events$1,
3212
+ breakpoints,
3213
+ checkOverflow: checkOverflow$1,
3214
+ classes
3215
+ };
3216
+ const extendedDefaults = {};
3217
+ class Swiper {
3218
+ constructor(...args) {
3219
+ let el;
3220
+ let params;
3221
+ if (args.length === 1 && args[0].constructor && Object.prototype.toString.call(args[0]).slice(8, -1) === 'Object') {
3222
+ params = args[0];
3223
+ } else {
3224
+ [el, params] = args;
3225
+ }
3226
+ if (!params) params = {};
3227
+ params = extend({}, params);
3228
+ if (el && !params.el) params.el = el;
3229
+ const document = getDocument();
3230
+ if (params.el && typeof params.el === 'string' && document.querySelectorAll(params.el).length > 1) {
3231
+ const swipers = [];
3232
+ document.querySelectorAll(params.el).forEach(containerEl => {
3233
+ const newParams = extend({}, params, {
3234
+ el: containerEl
3235
+ });
3236
+ swipers.push(new Swiper(newParams));
3237
+ });
3238
+ // eslint-disable-next-line no-constructor-return
3239
+ return swipers;
3240
+ }
3241
+
3242
+ // Swiper Instance
3243
+ const swiper = this;
3244
+ swiper.__swiper__ = true;
3245
+ swiper.support = getSupport();
3246
+ swiper.device = getDevice({
3247
+ userAgent: params.userAgent
3248
+ });
3249
+ swiper.browser = getBrowser();
3250
+ swiper.eventsListeners = {};
3251
+ swiper.eventsAnyListeners = [];
3252
+ swiper.modules = [...swiper.__modules__];
3253
+ if (params.modules && Array.isArray(params.modules)) {
3254
+ swiper.modules.push(...params.modules);
3255
+ }
3256
+ const allModulesParams = {};
3257
+ swiper.modules.forEach(mod => {
3258
+ mod({
3259
+ params,
3260
+ swiper,
3261
+ extendParams: moduleExtendParams(params, allModulesParams),
3262
+ on: swiper.on.bind(swiper),
3263
+ once: swiper.once.bind(swiper),
3264
+ off: swiper.off.bind(swiper),
3265
+ emit: swiper.emit.bind(swiper)
3266
+ });
3267
+ });
3268
+
3269
+ // Extend defaults with modules params
3270
+ const swiperParams = extend({}, defaults, allModulesParams);
3271
+
3272
+ // Extend defaults with passed params
3273
+ swiper.params = extend({}, swiperParams, extendedDefaults, params);
3274
+ swiper.originalParams = extend({}, swiper.params);
3275
+ swiper.passedParams = extend({}, params);
3276
+
3277
+ // add event listeners
3278
+ if (swiper.params && swiper.params.on) {
3279
+ Object.keys(swiper.params.on).forEach(eventName => {
3280
+ swiper.on(eventName, swiper.params.on[eventName]);
3281
+ });
3282
+ }
3283
+ if (swiper.params && swiper.params.onAny) {
3284
+ swiper.onAny(swiper.params.onAny);
3285
+ }
3286
+
3287
+ // Extend Swiper
3288
+ Object.assign(swiper, {
3289
+ enabled: swiper.params.enabled,
3290
+ el,
3291
+ // Classes
3292
+ classNames: [],
3293
+ // Slides
3294
+ slides: [],
3295
+ slidesGrid: [],
3296
+ snapGrid: [],
3297
+ slidesSizesGrid: [],
3298
+ // isDirection
3299
+ isHorizontal() {
3300
+ return swiper.params.direction === 'horizontal';
3301
+ },
3302
+ isVertical() {
3303
+ return swiper.params.direction === 'vertical';
3304
+ },
3305
+ // Indexes
3306
+ activeIndex: 0,
3307
+ realIndex: 0,
3308
+ //
3309
+ isBeginning: true,
3310
+ isEnd: false,
3311
+ // Props
3312
+ translate: 0,
3313
+ previousTranslate: 0,
3314
+ progress: 0,
3315
+ velocity: 0,
3316
+ animating: false,
3317
+ // Locks
3318
+ allowSlideNext: swiper.params.allowSlideNext,
3319
+ allowSlidePrev: swiper.params.allowSlidePrev,
3320
+ // Touch Events
3321
+ touchEventsData: {
3322
+ isTouched: undefined,
3323
+ isMoved: undefined,
3324
+ allowTouchCallbacks: undefined,
3325
+ touchStartTime: undefined,
3326
+ isScrolling: undefined,
3327
+ currentTranslate: undefined,
3328
+ startTranslate: undefined,
3329
+ allowThresholdMove: undefined,
3330
+ // Form elements to match
3331
+ focusableElements: swiper.params.focusableElements,
3332
+ // Last click time
3333
+ lastClickTime: now(),
3334
+ clickTimeout: undefined,
3335
+ // Velocities
3336
+ velocities: [],
3337
+ allowMomentumBounce: undefined,
3338
+ startMoving: undefined,
3339
+ evCache: []
3340
+ },
3341
+ // Clicks
3342
+ allowClick: true,
3343
+ // Touches
3344
+ allowTouchMove: swiper.params.allowTouchMove,
3345
+ touches: {
3346
+ startX: 0,
3347
+ startY: 0,
3348
+ currentX: 0,
3349
+ currentY: 0,
3350
+ diff: 0
3351
+ },
3352
+ // Images
3353
+ imagesToLoad: [],
3354
+ imagesLoaded: 0
3355
+ });
3356
+ swiper.emit('_swiper');
3357
+
3358
+ // Init
3359
+ if (swiper.params.init) {
3360
+ swiper.init();
3361
+ }
3362
+
3363
+ // Return app instance
3364
+ // eslint-disable-next-line no-constructor-return
3365
+ return swiper;
3366
+ }
3367
+ getSlideIndex(slideEl) {
3368
+ const {
3369
+ slidesEl,
3370
+ params
3371
+ } = this;
3372
+ const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
3373
+ const firstSlideIndex = elementIndex(slides[0]);
3374
+ return elementIndex(slideEl) - firstSlideIndex;
3375
+ }
3376
+ getSlideIndexByData(index) {
3377
+ return this.getSlideIndex(this.slides.filter(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === index)[0]);
3378
+ }
3379
+ recalcSlides() {
3380
+ const swiper = this;
3381
+ const {
3382
+ slidesEl,
3383
+ params
3384
+ } = swiper;
3385
+ swiper.slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
3386
+ }
3387
+ enable() {
3388
+ const swiper = this;
3389
+ if (swiper.enabled) return;
3390
+ swiper.enabled = true;
3391
+ if (swiper.params.grabCursor) {
3392
+ swiper.setGrabCursor();
3393
+ }
3394
+ swiper.emit('enable');
3395
+ }
3396
+ disable() {
3397
+ const swiper = this;
3398
+ if (!swiper.enabled) return;
3399
+ swiper.enabled = false;
3400
+ if (swiper.params.grabCursor) {
3401
+ swiper.unsetGrabCursor();
3402
+ }
3403
+ swiper.emit('disable');
3404
+ }
3405
+ setProgress(progress, speed) {
3406
+ const swiper = this;
3407
+ progress = Math.min(Math.max(progress, 0), 1);
3408
+ const min = swiper.minTranslate();
3409
+ const max = swiper.maxTranslate();
3410
+ const current = (max - min) * progress + min;
3411
+ swiper.translateTo(current, typeof speed === 'undefined' ? 0 : speed);
3412
+ swiper.updateActiveIndex();
3413
+ swiper.updateSlidesClasses();
3414
+ }
3415
+ emitContainerClasses() {
3416
+ const swiper = this;
3417
+ if (!swiper.params._emitClasses || !swiper.el) return;
3418
+ const cls = swiper.el.className.split(' ').filter(className => {
3419
+ return className.indexOf('swiper') === 0 || className.indexOf(swiper.params.containerModifierClass) === 0;
3420
+ });
3421
+ swiper.emit('_containerClasses', cls.join(' '));
3422
+ }
3423
+ getSlideClasses(slideEl) {
3424
+ const swiper = this;
3425
+ if (swiper.destroyed) return '';
3426
+ return slideEl.className.split(' ').filter(className => {
3427
+ return className.indexOf('swiper-slide') === 0 || className.indexOf(swiper.params.slideClass) === 0;
3428
+ }).join(' ');
3429
+ }
3430
+ emitSlidesClasses() {
3431
+ const swiper = this;
3432
+ if (!swiper.params._emitClasses || !swiper.el) return;
3433
+ const updates = [];
3434
+ swiper.slides.forEach(slideEl => {
3435
+ const classNames = swiper.getSlideClasses(slideEl);
3436
+ updates.push({
3437
+ slideEl,
3438
+ classNames
3439
+ });
3440
+ swiper.emit('_slideClass', slideEl, classNames);
3441
+ });
3442
+ swiper.emit('_slideClasses', updates);
3443
+ }
3444
+ slidesPerViewDynamic(view = 'current', exact = false) {
3445
+ const swiper = this;
3446
+ const {
3447
+ params,
3448
+ slides,
3449
+ slidesGrid,
3450
+ slidesSizesGrid,
3451
+ size: swiperSize,
3452
+ activeIndex
3453
+ } = swiper;
3454
+ let spv = 1;
3455
+ if (params.centeredSlides) {
3456
+ let slideSize = slides[activeIndex].swiperSlideSize;
3457
+ let breakLoop;
3458
+ for (let i = activeIndex + 1; i < slides.length; i += 1) {
3459
+ if (slides[i] && !breakLoop) {
3460
+ slideSize += slides[i].swiperSlideSize;
3461
+ spv += 1;
3462
+ if (slideSize > swiperSize) breakLoop = true;
3463
+ }
3464
+ }
3465
+ for (let i = activeIndex - 1; i >= 0; i -= 1) {
3466
+ if (slides[i] && !breakLoop) {
3467
+ slideSize += slides[i].swiperSlideSize;
3468
+ spv += 1;
3469
+ if (slideSize > swiperSize) breakLoop = true;
3470
+ }
3471
+ }
3472
+ } else {
3473
+ // eslint-disable-next-line
3474
+ if (view === 'current') {
3475
+ for (let i = activeIndex + 1; i < slides.length; i += 1) {
3476
+ const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize;
3477
+ if (slideInView) {
3478
+ spv += 1;
3479
+ }
3480
+ }
3481
+ } else {
3482
+ // previous
3483
+ for (let i = activeIndex - 1; i >= 0; i -= 1) {
3484
+ const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize;
3485
+ if (slideInView) {
3486
+ spv += 1;
3487
+ }
3488
+ }
3489
+ }
3490
+ }
3491
+ return spv;
3492
+ }
3493
+ update() {
3494
+ const swiper = this;
3495
+ if (!swiper || swiper.destroyed) return;
3496
+ const {
3497
+ snapGrid,
3498
+ params
3499
+ } = swiper;
3500
+ // Breakpoints
3501
+ if (params.breakpoints) {
3502
+ swiper.setBreakpoint();
3503
+ }
3504
+ [...swiper.el.querySelectorAll('[loading="lazy"]')].forEach(imageEl => {
3505
+ if (imageEl.complete) {
3506
+ processLazyPreloader(swiper, imageEl);
3507
+ }
3508
+ });
3509
+ swiper.updateSize();
3510
+ swiper.updateSlides();
3511
+ swiper.updateProgress();
3512
+ swiper.updateSlidesClasses();
3513
+ function setTranslate() {
3514
+ const translateValue = swiper.rtlTranslate ? swiper.translate * -1 : swiper.translate;
3515
+ const newTranslate = Math.min(Math.max(translateValue, swiper.maxTranslate()), swiper.minTranslate());
3516
+ swiper.setTranslate(newTranslate);
3517
+ swiper.updateActiveIndex();
3518
+ swiper.updateSlidesClasses();
3519
+ }
3520
+ let translated;
3521
+ if (swiper.params.freeMode && swiper.params.freeMode.enabled) {
3522
+ setTranslate();
3523
+ if (swiper.params.autoHeight) {
3524
+ swiper.updateAutoHeight();
3525
+ }
3526
+ } else {
3527
+ if ((swiper.params.slidesPerView === 'auto' || swiper.params.slidesPerView > 1) && swiper.isEnd && !swiper.params.centeredSlides) {
3528
+ translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true);
3529
+ } else {
3530
+ translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
3531
+ }
3532
+ if (!translated) {
3533
+ setTranslate();
3534
+ }
3535
+ }
3536
+ if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
3537
+ swiper.checkOverflow();
3538
+ }
3539
+ swiper.emit('update');
3540
+ }
3541
+ changeDirection(newDirection, needUpdate = true) {
3542
+ const swiper = this;
3543
+ const currentDirection = swiper.params.direction;
3544
+ if (!newDirection) {
3545
+ // eslint-disable-next-line
3546
+ newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal';
3547
+ }
3548
+ if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') {
3549
+ return swiper;
3550
+ }
3551
+ swiper.el.classList.remove(`${swiper.params.containerModifierClass}${currentDirection}`);
3552
+ swiper.el.classList.add(`${swiper.params.containerModifierClass}${newDirection}`);
3553
+ swiper.emitContainerClasses();
3554
+ swiper.params.direction = newDirection;
3555
+ swiper.slides.forEach(slideEl => {
3556
+ if (newDirection === 'vertical') {
3557
+ slideEl.style.width = '';
3558
+ } else {
3559
+ slideEl.style.height = '';
3560
+ }
3561
+ });
3562
+ swiper.emit('changeDirection');
3563
+ if (needUpdate) swiper.update();
3564
+ return swiper;
3565
+ }
3566
+ changeLanguageDirection(direction) {
3567
+ const swiper = this;
3568
+ if (swiper.rtl && direction === 'rtl' || !swiper.rtl && direction === 'ltr') return;
3569
+ swiper.rtl = direction === 'rtl';
3570
+ swiper.rtlTranslate = swiper.params.direction === 'horizontal' && swiper.rtl;
3571
+ if (swiper.rtl) {
3572
+ swiper.el.classList.add(`${swiper.params.containerModifierClass}rtl`);
3573
+ swiper.el.dir = 'rtl';
3574
+ } else {
3575
+ swiper.el.classList.remove(`${swiper.params.containerModifierClass}rtl`);
3576
+ swiper.el.dir = 'ltr';
3577
+ }
3578
+ swiper.update();
3579
+ }
3580
+ mount(element) {
3581
+ const swiper = this;
3582
+ if (swiper.mounted) return true;
3583
+
3584
+ // Find el
3585
+ let el = element || swiper.params.el;
3586
+ if (typeof el === 'string') {
3587
+ el = document.querySelector(el);
3588
+ }
3589
+ if (!el) {
3590
+ return false;
3591
+ }
3592
+ el.swiper = swiper;
3593
+ if (el.shadowEl) {
3594
+ swiper.isElement = true;
3595
+ }
3596
+ const getWrapperSelector = () => {
3597
+ return `.${(swiper.params.wrapperClass || '').trim().split(' ').join('.')}`;
3598
+ };
3599
+ const getWrapper = () => {
3600
+ if (el && el.shadowRoot && el.shadowRoot.querySelector) {
3601
+ const res = el.shadowRoot.querySelector(getWrapperSelector());
3602
+ // Children needs to return slot items
3603
+ return res;
3604
+ }
3605
+ return elementChildren(el, getWrapperSelector())[0];
3606
+ };
3607
+ // Find Wrapper
3608
+ let wrapperEl = getWrapper();
3609
+ if (!wrapperEl && swiper.params.createElements) {
3610
+ wrapperEl = createElement('div', swiper.params.wrapperClass);
3611
+ el.append(wrapperEl);
3612
+ elementChildren(el, `.${swiper.params.slideClass}`).forEach(slideEl => {
3613
+ wrapperEl.append(slideEl);
3614
+ });
3615
+ }
3616
+ Object.assign(swiper, {
3617
+ el,
3618
+ wrapperEl,
3619
+ slidesEl: swiper.isElement ? el : wrapperEl,
3620
+ mounted: true,
3621
+ // RTL
3622
+ rtl: el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl',
3623
+ rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl'),
3624
+ wrongRTL: elementStyle(wrapperEl, 'display') === '-webkit-box'
3625
+ });
3626
+ return true;
3627
+ }
3628
+ init(el) {
3629
+ const swiper = this;
3630
+ if (swiper.initialized) return swiper;
3631
+ const mounted = swiper.mount(el);
3632
+ if (mounted === false) return swiper;
3633
+ swiper.emit('beforeInit');
3634
+
3635
+ // Set breakpoint
3636
+ if (swiper.params.breakpoints) {
3637
+ swiper.setBreakpoint();
3638
+ }
3639
+
3640
+ // Add Classes
3641
+ swiper.addClasses();
3642
+
3643
+ // Update size
3644
+ swiper.updateSize();
3645
+
3646
+ // Update slides
3647
+ swiper.updateSlides();
3648
+ if (swiper.params.watchOverflow) {
3649
+ swiper.checkOverflow();
3650
+ }
3651
+
3652
+ // Set Grab Cursor
3653
+ if (swiper.params.grabCursor && swiper.enabled) {
3654
+ swiper.setGrabCursor();
3655
+ }
3656
+
3657
+ // Slide To Initial Slide
3658
+ if (swiper.params.loop && swiper.virtual && swiper.params.virtual.enabled) {
3659
+ swiper.slideTo(swiper.params.initialSlide + swiper.virtual.slidesBefore, 0, swiper.params.runCallbacksOnInit, false, true);
3660
+ } else {
3661
+ swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
3662
+ }
3663
+
3664
+ // Create loop
3665
+ if (swiper.params.loop) {
3666
+ swiper.loopCreate();
3667
+ }
3668
+
3669
+ // Attach events
3670
+ swiper.attachEvents();
3671
+ [...swiper.el.querySelectorAll('[loading="lazy"]')].forEach(imageEl => {
3672
+ if (imageEl.complete) {
3673
+ processLazyPreloader(swiper, imageEl);
3674
+ } else {
3675
+ imageEl.addEventListener('load', e => {
3676
+ processLazyPreloader(swiper, e.target);
3677
+ });
3678
+ }
3679
+ });
3680
+
3681
+ // Init Flag
3682
+ swiper.initialized = true;
3683
+
3684
+ // Emit
3685
+ swiper.emit('init');
3686
+ swiper.emit('afterInit');
3687
+ return swiper;
3688
+ }
3689
+ destroy(deleteInstance = true, cleanStyles = true) {
3690
+ const swiper = this;
3691
+ const {
3692
+ params,
3693
+ el,
3694
+ wrapperEl,
3695
+ slides
3696
+ } = swiper;
3697
+ if (typeof swiper.params === 'undefined' || swiper.destroyed) {
3698
+ return null;
3699
+ }
3700
+ swiper.emit('beforeDestroy');
3701
+
3702
+ // Init Flag
3703
+ swiper.initialized = false;
3704
+
3705
+ // Detach events
3706
+ swiper.detachEvents();
3707
+
3708
+ // Destroy loop
3709
+ if (params.loop) {
3710
+ swiper.loopDestroy();
3711
+ }
3712
+
3713
+ // Cleanup styles
3714
+ if (cleanStyles) {
3715
+ swiper.removeClasses();
3716
+ el.removeAttribute('style');
3717
+ wrapperEl.removeAttribute('style');
3718
+ if (slides && slides.length) {
3719
+ slides.forEach(slideEl => {
3720
+ slideEl.classList.remove(params.slideVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
3721
+ slideEl.removeAttribute('style');
3722
+ slideEl.removeAttribute('data-swiper-slide-index');
3723
+ });
3724
+ }
3725
+ }
3726
+ swiper.emit('destroy');
3727
+
3728
+ // Detach emitter events
3729
+ Object.keys(swiper.eventsListeners).forEach(eventName => {
3730
+ swiper.off(eventName);
3731
+ });
3732
+ if (deleteInstance !== false) {
3733
+ swiper.el.swiper = null;
3734
+ deleteProps(swiper);
3735
+ }
3736
+ swiper.destroyed = true;
3737
+ return null;
3738
+ }
3739
+ static extendDefaults(newDefaults) {
3740
+ extend(extendedDefaults, newDefaults);
3741
+ }
3742
+ static get extendedDefaults() {
3743
+ return extendedDefaults;
3744
+ }
3745
+ static get defaults() {
3746
+ return defaults;
3747
+ }
3748
+ static installModule(mod) {
3749
+ if (!Swiper.prototype.__modules__) Swiper.prototype.__modules__ = [];
3750
+ const modules = Swiper.prototype.__modules__;
3751
+ if (typeof mod === 'function' && modules.indexOf(mod) < 0) {
3752
+ modules.push(mod);
3753
+ }
3754
+ }
3755
+ static use(module) {
3756
+ if (Array.isArray(module)) {
3757
+ module.forEach(m => Swiper.installModule(m));
3758
+ return Swiper;
3759
+ }
3760
+ Swiper.installModule(module);
3761
+ return Swiper;
3762
+ }
3763
+ }
3764
+ Object.keys(prototypes).forEach(prototypeGroup => {
3765
+ Object.keys(prototypes[prototypeGroup]).forEach(protoMethod => {
3766
+ Swiper.prototype[protoMethod] = prototypes[prototypeGroup][protoMethod];
3767
+ });
3768
+ });
3769
+ Swiper.use([Resize, Observer]);
3770
+
3771
+ exports.Swiper = Swiper;