@ozdao/martyrs 0.2.511 → 0.2.513

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 (156) hide show
  1. package/dist/{main-B1XN9Zjg.cjs → main-CVOBCkmD.cjs} +5 -5
  2. package/dist/{main-u7zgfMGL.js → main-CVRRj-vK.js} +259 -262
  3. package/dist/martyrs/src/components/Button/Button.vue2.cjs.map +1 -1
  4. package/dist/martyrs/src/components/Button/Button.vue2.js.map +1 -1
  5. package/dist/martyrs/src/components/Menu/{Menu.vue.cjs → Menu.vue2.cjs} +2 -2
  6. package/dist/martyrs/src/components/Menu/Menu.vue2.cjs.map +1 -0
  7. package/dist/martyrs/src/components/Menu/{Menu.vue.js → Menu.vue2.js} +2 -2
  8. package/dist/martyrs/src/components/Menu/Menu.vue2.js.map +1 -0
  9. package/dist/martyrs/src/components/Menu/MenuItem.vue.cjs +2 -2
  10. package/dist/martyrs/src/components/Menu/MenuItem.vue.cjs.map +1 -1
  11. package/dist/martyrs/src/components/Menu/MenuItem.vue.js +2 -2
  12. package/dist/martyrs/src/components/Menu/MenuItem.vue.js.map +1 -1
  13. package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.cjs +2 -2
  14. package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.cjs.map +1 -1
  15. package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.js +2 -2
  16. package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.js.map +1 -1
  17. package/dist/martyrs/src/modules/chats/components/sections/ChatWindow.vue.cjs +0 -2
  18. package/dist/martyrs/src/modules/chats/components/sections/ChatWindow.vue.cjs.map +1 -1
  19. package/dist/martyrs/src/modules/chats/components/sections/ChatWindow.vue.js +0 -2
  20. package/dist/martyrs/src/modules/chats/components/sections/ChatWindow.vue.js.map +1 -1
  21. package/dist/martyrs/src/modules/events/components/pages/EventsBackoffice.vue.cjs +3 -5
  22. package/dist/martyrs/src/modules/events/components/pages/EventsBackoffice.vue.cjs.map +1 -1
  23. package/dist/martyrs/src/modules/events/components/pages/EventsBackoffice.vue.js +3 -5
  24. package/dist/martyrs/src/modules/events/components/pages/EventsBackoffice.vue.js.map +1 -1
  25. package/dist/martyrs/src/modules/globals/globals.client.cjs +10 -1
  26. package/dist/martyrs/src/modules/globals/globals.client.cjs.map +1 -1
  27. package/dist/martyrs/src/modules/globals/globals.client.js +31 -22
  28. package/dist/martyrs/src/modules/globals/globals.client.js.map +1 -1
  29. package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.cjs.map +1 -1
  30. package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.js.map +1 -1
  31. package/dist/martyrs/src/modules/globals/views/components/sections/Filters.vue2.cjs +42 -46
  32. package/dist/martyrs/src/modules/globals/views/components/sections/Filters.vue2.cjs.map +1 -1
  33. package/dist/martyrs/src/modules/globals/views/components/sections/Filters.vue2.js +45 -49
  34. package/dist/martyrs/src/modules/globals/views/components/sections/Filters.vue2.js.map +1 -1
  35. package/dist/martyrs/src/modules/globals/views/components/sections/Walkthrough.vue.cjs +308 -0
  36. package/dist/martyrs/src/modules/globals/views/components/sections/Walkthrough.vue.cjs.map +1 -0
  37. package/dist/martyrs/src/modules/globals/views/components/sections/Walkthrough.vue.js +308 -0
  38. package/dist/martyrs/src/modules/globals/views/components/sections/Walkthrough.vue.js.map +1 -0
  39. package/dist/martyrs/src/modules/inventory/components/pages/Inventory.vue.cjs +14 -16
  40. package/dist/martyrs/src/modules/inventory/components/pages/Inventory.vue.cjs.map +1 -1
  41. package/dist/martyrs/src/modules/inventory/components/pages/Inventory.vue.js +13 -15
  42. package/dist/martyrs/src/modules/inventory/components/pages/Inventory.vue.js.map +1 -1
  43. package/dist/martyrs/src/modules/notifications/notifications.client.cjs +101 -32
  44. package/dist/martyrs/src/modules/notifications/notifications.client.cjs.map +1 -1
  45. package/dist/martyrs/src/modules/notifications/notifications.client.js +101 -32
  46. package/dist/martyrs/src/modules/notifications/notifications.client.js.map +1 -1
  47. package/dist/martyrs/src/modules/notifications/store/notifications.store.cjs +45 -12
  48. package/dist/martyrs/src/modules/notifications/store/notifications.store.cjs.map +1 -1
  49. package/dist/martyrs/src/modules/notifications/store/notifications.store.js +38 -5
  50. package/dist/martyrs/src/modules/notifications/store/notifications.store.js.map +1 -1
  51. package/dist/martyrs/src/modules/orders/components/blocks/CardOrderItem.vue.cjs +19 -18
  52. package/dist/martyrs/src/modules/orders/components/blocks/CardOrderItem.vue.cjs.map +1 -1
  53. package/dist/martyrs/src/modules/orders/components/blocks/CardOrderItem.vue.js +19 -18
  54. package/dist/martyrs/src/modules/orders/components/blocks/CardOrderItem.vue.js.map +1 -1
  55. package/dist/martyrs/src/modules/orders/components/forms/FormCustomerDetails.vue.cjs +82 -61
  56. package/dist/martyrs/src/modules/orders/components/forms/FormCustomerDetails.vue.cjs.map +1 -1
  57. package/dist/martyrs/src/modules/orders/components/forms/FormCustomerDetails.vue.js +83 -62
  58. package/dist/martyrs/src/modules/orders/components/forms/FormCustomerDetails.vue.js.map +1 -1
  59. package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.cjs +3 -3
  60. package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.cjs.map +1 -1
  61. package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.js +3 -3
  62. package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.js.map +1 -1
  63. package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.cjs +4 -2
  64. package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.cjs.map +1 -1
  65. package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.js +4 -2
  66. package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.js.map +1 -1
  67. package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.cjs +2 -2
  68. package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.cjs.map +1 -1
  69. package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.js +2 -2
  70. package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.js.map +1 -1
  71. package/dist/martyrs/src/modules/orders/orders.client.cjs +1 -0
  72. package/dist/martyrs/src/modules/orders/orders.client.cjs.map +1 -1
  73. package/dist/martyrs/src/modules/orders/orders.client.js +2 -0
  74. package/dist/martyrs/src/modules/orders/orders.client.js.map +1 -1
  75. package/dist/martyrs/src/modules/orders/store/shopcart.cjs +33 -23
  76. package/dist/martyrs/src/modules/orders/store/shopcart.cjs.map +1 -1
  77. package/dist/martyrs/src/modules/orders/store/shopcart.js +31 -21
  78. package/dist/martyrs/src/modules/orders/store/shopcart.js.map +1 -1
  79. package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
  80. package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.js +1 -1
  81. package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.cjs +3 -18
  82. package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.cjs.map +1 -1
  83. package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.js +4 -19
  84. package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.js.map +1 -1
  85. package/dist/martyrs/src/modules/organizations/components/pages/OrganizationBackoffice.vue.cjs +1 -1
  86. package/dist/martyrs/src/modules/organizations/components/pages/OrganizationBackoffice.vue.js +1 -1
  87. package/dist/martyrs/src/modules/organizations/configs/navigation.organization.config.cjs +37 -43
  88. package/dist/martyrs/src/modules/organizations/configs/navigation.organization.config.cjs.map +1 -1
  89. package/dist/martyrs/src/modules/organizations/configs/navigation.organization.config.js +48 -54
  90. package/dist/martyrs/src/modules/organizations/configs/navigation.organization.config.js.map +1 -1
  91. package/dist/martyrs/src/modules/organizations/router/organizations.cjs +1 -1
  92. package/dist/martyrs/src/modules/organizations/router/organizations.js +1 -1
  93. package/dist/martyrs/src/modules/products/components/pages/Products.vue.cjs +11 -8
  94. package/dist/martyrs/src/modules/products/components/pages/Products.vue.cjs.map +1 -1
  95. package/dist/martyrs/src/modules/products/components/pages/Products.vue.js +11 -8
  96. package/dist/martyrs/src/modules/products/components/pages/Products.vue.js.map +1 -1
  97. package/dist/martyrs.cjs.js +1 -1
  98. package/dist/martyrs.css +1 -1
  99. package/dist/martyrs.es.js +1 -1
  100. package/dist/node_modules/.pnpm/capacitor-plugin-app-tracking-transparency@2.0.5_@capacitor_core@7.2.0/node_modules/capacitor-plugin-app-tracking-transparency/dist/esm/index.cjs +8 -0
  101. package/dist/node_modules/.pnpm/capacitor-plugin-app-tracking-transparency@2.0.5_@capacitor_core@7.2.0/node_modules/capacitor-plugin-app-tracking-transparency/dist/esm/index.cjs.map +1 -0
  102. package/dist/node_modules/.pnpm/capacitor-plugin-app-tracking-transparency@2.0.5_@capacitor_core@7.2.0/node_modules/capacitor-plugin-app-tracking-transparency/dist/esm/index.js +8 -0
  103. package/dist/node_modules/.pnpm/capacitor-plugin-app-tracking-transparency@2.0.5_@capacitor_core@7.2.0/node_modules/capacitor-plugin-app-tracking-transparency/dist/esm/index.js.map +1 -0
  104. package/dist/node_modules/.pnpm/capacitor-plugin-app-tracking-transparency@2.0.5_@capacitor_core@7.2.0/node_modules/capacitor-plugin-app-tracking-transparency/dist/esm/web.cjs +13 -0
  105. package/dist/node_modules/.pnpm/capacitor-plugin-app-tracking-transparency@2.0.5_@capacitor_core@7.2.0/node_modules/capacitor-plugin-app-tracking-transparency/dist/esm/web.cjs.map +1 -0
  106. package/dist/node_modules/.pnpm/capacitor-plugin-app-tracking-transparency@2.0.5_@capacitor_core@7.2.0/node_modules/capacitor-plugin-app-tracking-transparency/dist/esm/web.js +13 -0
  107. package/dist/node_modules/.pnpm/capacitor-plugin-app-tracking-transparency@2.0.5_@capacitor_core@7.2.0/node_modules/capacitor-plugin-app-tracking-transparency/dist/esm/web.js.map +1 -0
  108. package/dist/node_modules/.pnpm/embla-carousel-reactive-utils@8.6.0_embla-carousel@8.6.0/node_modules/embla-carousel-reactive-utils/esm/embla-carousel-reactive-utils.esm.cjs +43 -0
  109. package/dist/node_modules/.pnpm/embla-carousel-reactive-utils@8.6.0_embla-carousel@8.6.0/node_modules/embla-carousel-reactive-utils/esm/embla-carousel-reactive-utils.esm.cjs.map +1 -0
  110. package/dist/node_modules/.pnpm/embla-carousel-reactive-utils@8.6.0_embla-carousel@8.6.0/node_modules/embla-carousel-reactive-utils/esm/embla-carousel-reactive-utils.esm.js +43 -0
  111. package/dist/node_modules/.pnpm/embla-carousel-reactive-utils@8.6.0_embla-carousel@8.6.0/node_modules/embla-carousel-reactive-utils/esm/embla-carousel-reactive-utils.esm.js.map +1 -0
  112. package/dist/node_modules/.pnpm/embla-carousel-vue@8.6.0_vue@3.5.13_typescript@5.8.3_/node_modules/embla-carousel-vue/esm/embla-carousel-vue.esm.cjs +43 -0
  113. package/dist/node_modules/.pnpm/embla-carousel-vue@8.6.0_vue@3.5.13_typescript@5.8.3_/node_modules/embla-carousel-vue/esm/embla-carousel-vue.esm.cjs.map +1 -0
  114. package/dist/node_modules/.pnpm/embla-carousel-vue@8.6.0_vue@3.5.13_typescript@5.8.3_/node_modules/embla-carousel-vue/esm/embla-carousel-vue.esm.js +43 -0
  115. package/dist/node_modules/.pnpm/embla-carousel-vue@8.6.0_vue@3.5.13_typescript@5.8.3_/node_modules/embla-carousel-vue/esm/embla-carousel-vue.esm.js.map +1 -0
  116. package/dist/node_modules/.pnpm/embla-carousel@8.6.0/node_modules/embla-carousel/esm/embla-carousel.esm.cjs +1630 -0
  117. package/dist/node_modules/.pnpm/embla-carousel@8.6.0/node_modules/embla-carousel/esm/embla-carousel.esm.cjs.map +1 -0
  118. package/dist/node_modules/.pnpm/embla-carousel@8.6.0/node_modules/embla-carousel/esm/embla-carousel.esm.js +1630 -0
  119. package/dist/node_modules/.pnpm/embla-carousel@8.6.0/node_modules/embla-carousel/esm/embla-carousel.esm.js.map +1 -0
  120. package/dist/notifications.server.cjs +205 -11
  121. package/dist/notifications.server.js +205 -11
  122. package/dist/style.css +258 -242
  123. package/dist/{web--8-wgr6b.js → web-BW449LVt.js} +1 -1
  124. package/dist/{web-BS6utuAZ.cjs → web-CO3tWG6J.cjs} +1 -1
  125. package/package.json +1 -1
  126. package/src/components/Button/Button.vue +2 -2
  127. package/src/components/Menu/MenuItem.vue +11 -6
  128. package/src/modules/auth/views/components/pages/Profile.vue +1 -1
  129. package/src/modules/chats/components/sections/ChatWindow.vue +1 -1
  130. package/src/modules/events/components/pages/EventsBackoffice.vue +0 -1
  131. package/src/modules/globals/globals.client.js +17 -0
  132. package/src/modules/globals/views/components/layouts/Client.vue +1 -0
  133. package/src/modules/globals/views/components/sections/Filters.vue +2 -4
  134. package/src/modules/globals/views/components/sections/Walkthrough.vue +245 -57
  135. package/src/modules/inventory/components/pages/Inventory.vue +0 -1
  136. package/src/modules/notifications/FIXES.md +1 -0
  137. package/src/modules/notifications/controllers/notifications.controller.js +147 -7
  138. package/src/modules/notifications/models/user-device.model.js +10 -2
  139. package/src/modules/notifications/notifications.client.js +127 -41
  140. package/src/modules/notifications/routes/notifications.routes.js +4 -0
  141. package/src/modules/notifications/services/notification.service.js +93 -0
  142. package/src/modules/notifications/store/notifications.store.js +47 -7
  143. package/src/modules/orders/components/blocks/CardOrderItem.vue +1 -1
  144. package/src/modules/orders/components/forms/FormCustomerDetails.vue +52 -35
  145. package/src/modules/orders/components/pages/OrderBackoffice.vue +2 -2
  146. package/src/modules/orders/components/pages/OrderCreate.vue +3 -1
  147. package/src/modules/orders/components/sections/FormDelivery.vue +2 -2
  148. package/src/modules/orders/orders.client.js +2 -0
  149. package/src/modules/orders/store/shopcart.js +34 -23
  150. package/src/modules/organizations/components/pages/Organization.vue +6 -2
  151. package/src/modules/organizations/configs/navigation.organization.config.js +36 -36
  152. package/src/modules/products/components/pages/Products.vue +11 -9
  153. package/src/modules/products/migrations/categories-to-materialized-path.js +0 -3
  154. package/src/styles/base/backgrounds.scss +1 -0
  155. package/dist/martyrs/src/components/Menu/Menu.vue.cjs.map +0 -1
  156. package/dist/martyrs/src/components/Menu/Menu.vue.js.map +0 -1
@@ -0,0 +1,1630 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ function isNumber(subject) {
4
+ return typeof subject === "number";
5
+ }
6
+ function isString(subject) {
7
+ return typeof subject === "string";
8
+ }
9
+ function isBoolean(subject) {
10
+ return typeof subject === "boolean";
11
+ }
12
+ function isObject(subject) {
13
+ return Object.prototype.toString.call(subject) === "[object Object]";
14
+ }
15
+ function mathAbs(n) {
16
+ return Math.abs(n);
17
+ }
18
+ function mathSign(n) {
19
+ return Math.sign(n);
20
+ }
21
+ function deltaAbs(valueB, valueA) {
22
+ return mathAbs(valueB - valueA);
23
+ }
24
+ function factorAbs(valueB, valueA) {
25
+ if (valueB === 0 || valueA === 0) return 0;
26
+ if (mathAbs(valueB) <= mathAbs(valueA)) return 0;
27
+ const diff = deltaAbs(mathAbs(valueB), mathAbs(valueA));
28
+ return mathAbs(diff / valueB);
29
+ }
30
+ function roundToTwoDecimals(num) {
31
+ return Math.round(num * 100) / 100;
32
+ }
33
+ function arrayKeys(array) {
34
+ return objectKeys(array).map(Number);
35
+ }
36
+ function arrayLast(array) {
37
+ return array[arrayLastIndex(array)];
38
+ }
39
+ function arrayLastIndex(array) {
40
+ return Math.max(0, array.length - 1);
41
+ }
42
+ function arrayIsLastIndex(array, index) {
43
+ return index === arrayLastIndex(array);
44
+ }
45
+ function arrayFromNumber(n, startAt = 0) {
46
+ return Array.from(Array(n), (_, i) => startAt + i);
47
+ }
48
+ function objectKeys(object) {
49
+ return Object.keys(object);
50
+ }
51
+ function objectsMergeDeep(objectA, objectB) {
52
+ return [objectA, objectB].reduce((mergedObjects, currentObject) => {
53
+ objectKeys(currentObject).forEach((key) => {
54
+ const valueA = mergedObjects[key];
55
+ const valueB = currentObject[key];
56
+ const areObjects = isObject(valueA) && isObject(valueB);
57
+ mergedObjects[key] = areObjects ? objectsMergeDeep(valueA, valueB) : valueB;
58
+ });
59
+ return mergedObjects;
60
+ }, {});
61
+ }
62
+ function isMouseEvent(evt, ownerWindow) {
63
+ return typeof ownerWindow.MouseEvent !== "undefined" && evt instanceof ownerWindow.MouseEvent;
64
+ }
65
+ function Alignment(align, viewSize) {
66
+ const predefined = {
67
+ start,
68
+ center,
69
+ end
70
+ };
71
+ function start() {
72
+ return 0;
73
+ }
74
+ function center(n) {
75
+ return end(n) / 2;
76
+ }
77
+ function end(n) {
78
+ return viewSize - n;
79
+ }
80
+ function measure(n, index) {
81
+ if (isString(align)) return predefined[align](n);
82
+ return align(viewSize, n, index);
83
+ }
84
+ const self = {
85
+ measure
86
+ };
87
+ return self;
88
+ }
89
+ function EventStore() {
90
+ let listeners = [];
91
+ function add(node, type, handler, options = {
92
+ passive: true
93
+ }) {
94
+ let removeListener;
95
+ if ("addEventListener" in node) {
96
+ node.addEventListener(type, handler, options);
97
+ removeListener = () => node.removeEventListener(type, handler, options);
98
+ } else {
99
+ const legacyMediaQueryList = node;
100
+ legacyMediaQueryList.addListener(handler);
101
+ removeListener = () => legacyMediaQueryList.removeListener(handler);
102
+ }
103
+ listeners.push(removeListener);
104
+ return self;
105
+ }
106
+ function clear() {
107
+ listeners = listeners.filter((remove) => remove());
108
+ }
109
+ const self = {
110
+ add,
111
+ clear
112
+ };
113
+ return self;
114
+ }
115
+ function Animations(ownerDocument, ownerWindow, update, render) {
116
+ const documentVisibleHandler = EventStore();
117
+ const fixedTimeStep = 1e3 / 60;
118
+ let lastTimeStamp = null;
119
+ let accumulatedTime = 0;
120
+ let animationId = 0;
121
+ function init() {
122
+ documentVisibleHandler.add(ownerDocument, "visibilitychange", () => {
123
+ if (ownerDocument.hidden) reset();
124
+ });
125
+ }
126
+ function destroy() {
127
+ stop();
128
+ documentVisibleHandler.clear();
129
+ }
130
+ function animate(timeStamp) {
131
+ if (!animationId) return;
132
+ if (!lastTimeStamp) {
133
+ lastTimeStamp = timeStamp;
134
+ update();
135
+ update();
136
+ }
137
+ const timeElapsed = timeStamp - lastTimeStamp;
138
+ lastTimeStamp = timeStamp;
139
+ accumulatedTime += timeElapsed;
140
+ while (accumulatedTime >= fixedTimeStep) {
141
+ update();
142
+ accumulatedTime -= fixedTimeStep;
143
+ }
144
+ const alpha = accumulatedTime / fixedTimeStep;
145
+ render(alpha);
146
+ if (animationId) {
147
+ animationId = ownerWindow.requestAnimationFrame(animate);
148
+ }
149
+ }
150
+ function start() {
151
+ if (animationId) return;
152
+ animationId = ownerWindow.requestAnimationFrame(animate);
153
+ }
154
+ function stop() {
155
+ ownerWindow.cancelAnimationFrame(animationId);
156
+ lastTimeStamp = null;
157
+ accumulatedTime = 0;
158
+ animationId = 0;
159
+ }
160
+ function reset() {
161
+ lastTimeStamp = null;
162
+ accumulatedTime = 0;
163
+ }
164
+ const self = {
165
+ init,
166
+ destroy,
167
+ start,
168
+ stop,
169
+ update,
170
+ render
171
+ };
172
+ return self;
173
+ }
174
+ function Axis(axis, contentDirection) {
175
+ const isRightToLeft = contentDirection === "rtl";
176
+ const isVertical = axis === "y";
177
+ const scroll = isVertical ? "y" : "x";
178
+ const cross = isVertical ? "x" : "y";
179
+ const sign = !isVertical && isRightToLeft ? -1 : 1;
180
+ const startEdge = getStartEdge();
181
+ const endEdge = getEndEdge();
182
+ function measureSize(nodeRect) {
183
+ const {
184
+ height,
185
+ width
186
+ } = nodeRect;
187
+ return isVertical ? height : width;
188
+ }
189
+ function getStartEdge() {
190
+ if (isVertical) return "top";
191
+ return isRightToLeft ? "right" : "left";
192
+ }
193
+ function getEndEdge() {
194
+ if (isVertical) return "bottom";
195
+ return isRightToLeft ? "left" : "right";
196
+ }
197
+ function direction(n) {
198
+ return n * sign;
199
+ }
200
+ const self = {
201
+ scroll,
202
+ cross,
203
+ startEdge,
204
+ endEdge,
205
+ measureSize,
206
+ direction
207
+ };
208
+ return self;
209
+ }
210
+ function Limit(min = 0, max = 0) {
211
+ const length = mathAbs(min - max);
212
+ function reachedMin(n) {
213
+ return n < min;
214
+ }
215
+ function reachedMax(n) {
216
+ return n > max;
217
+ }
218
+ function reachedAny(n) {
219
+ return reachedMin(n) || reachedMax(n);
220
+ }
221
+ function constrain(n) {
222
+ if (!reachedAny(n)) return n;
223
+ return reachedMin(n) ? min : max;
224
+ }
225
+ function removeOffset(n) {
226
+ if (!length) return n;
227
+ return n - length * Math.ceil((n - max) / length);
228
+ }
229
+ const self = {
230
+ length,
231
+ max,
232
+ min,
233
+ constrain,
234
+ reachedAny,
235
+ reachedMax,
236
+ reachedMin,
237
+ removeOffset
238
+ };
239
+ return self;
240
+ }
241
+ function Counter(max, start, loop) {
242
+ const {
243
+ constrain
244
+ } = Limit(0, max);
245
+ const loopEnd = max + 1;
246
+ let counter = withinLimit(start);
247
+ function withinLimit(n) {
248
+ return !loop ? constrain(n) : mathAbs((loopEnd + n) % loopEnd);
249
+ }
250
+ function get() {
251
+ return counter;
252
+ }
253
+ function set(n) {
254
+ counter = withinLimit(n);
255
+ return self;
256
+ }
257
+ function add(n) {
258
+ return clone().set(get() + n);
259
+ }
260
+ function clone() {
261
+ return Counter(max, get(), loop);
262
+ }
263
+ const self = {
264
+ get,
265
+ set,
266
+ add,
267
+ clone
268
+ };
269
+ return self;
270
+ }
271
+ function DragHandler(axis, rootNode, ownerDocument, ownerWindow, target, dragTracker, location, animation, scrollTo, scrollBody, scrollTarget, index, eventHandler, percentOfView, dragFree, dragThreshold, skipSnaps, baseFriction, watchDrag) {
272
+ const {
273
+ cross: crossAxis,
274
+ direction
275
+ } = axis;
276
+ const focusNodes = ["INPUT", "SELECT", "TEXTAREA"];
277
+ const nonPassiveEvent = {
278
+ passive: false
279
+ };
280
+ const initEvents = EventStore();
281
+ const dragEvents = EventStore();
282
+ const goToNextThreshold = Limit(50, 225).constrain(percentOfView.measure(20));
283
+ const snapForceBoost = {
284
+ mouse: 300,
285
+ touch: 400
286
+ };
287
+ const freeForceBoost = {
288
+ mouse: 500,
289
+ touch: 600
290
+ };
291
+ const baseSpeed = dragFree ? 43 : 25;
292
+ let isMoving = false;
293
+ let startScroll = 0;
294
+ let startCross = 0;
295
+ let pointerIsDown = false;
296
+ let preventScroll = false;
297
+ let preventClick = false;
298
+ let isMouse = false;
299
+ function init(emblaApi) {
300
+ if (!watchDrag) return;
301
+ function downIfAllowed(evt) {
302
+ if (isBoolean(watchDrag) || watchDrag(emblaApi, evt)) down(evt);
303
+ }
304
+ const node = rootNode;
305
+ initEvents.add(node, "dragstart", (evt) => evt.preventDefault(), nonPassiveEvent).add(node, "touchmove", () => void 0, nonPassiveEvent).add(node, "touchend", () => void 0).add(node, "touchstart", downIfAllowed).add(node, "mousedown", downIfAllowed).add(node, "touchcancel", up).add(node, "contextmenu", up).add(node, "click", click, true);
306
+ }
307
+ function destroy() {
308
+ initEvents.clear();
309
+ dragEvents.clear();
310
+ }
311
+ function addDragEvents() {
312
+ const node = isMouse ? ownerDocument : rootNode;
313
+ dragEvents.add(node, "touchmove", move, nonPassiveEvent).add(node, "touchend", up).add(node, "mousemove", move, nonPassiveEvent).add(node, "mouseup", up);
314
+ }
315
+ function isFocusNode(node) {
316
+ const nodeName = node.nodeName || "";
317
+ return focusNodes.includes(nodeName);
318
+ }
319
+ function forceBoost() {
320
+ const boost = dragFree ? freeForceBoost : snapForceBoost;
321
+ const type = isMouse ? "mouse" : "touch";
322
+ return boost[type];
323
+ }
324
+ function allowedForce(force, targetChanged) {
325
+ const next = index.add(mathSign(force) * -1);
326
+ const baseForce = scrollTarget.byDistance(force, !dragFree).distance;
327
+ if (dragFree || mathAbs(force) < goToNextThreshold) return baseForce;
328
+ if (skipSnaps && targetChanged) return baseForce * 0.5;
329
+ return scrollTarget.byIndex(next.get(), 0).distance;
330
+ }
331
+ function down(evt) {
332
+ const isMouseEvt = isMouseEvent(evt, ownerWindow);
333
+ isMouse = isMouseEvt;
334
+ preventClick = dragFree && isMouseEvt && !evt.buttons && isMoving;
335
+ isMoving = deltaAbs(target.get(), location.get()) >= 2;
336
+ if (isMouseEvt && evt.button !== 0) return;
337
+ if (isFocusNode(evt.target)) return;
338
+ pointerIsDown = true;
339
+ dragTracker.pointerDown(evt);
340
+ scrollBody.useFriction(0).useDuration(0);
341
+ target.set(location);
342
+ addDragEvents();
343
+ startScroll = dragTracker.readPoint(evt);
344
+ startCross = dragTracker.readPoint(evt, crossAxis);
345
+ eventHandler.emit("pointerDown");
346
+ }
347
+ function move(evt) {
348
+ const isTouchEvt = !isMouseEvent(evt, ownerWindow);
349
+ if (isTouchEvt && evt.touches.length >= 2) return up(evt);
350
+ const lastScroll = dragTracker.readPoint(evt);
351
+ const lastCross = dragTracker.readPoint(evt, crossAxis);
352
+ const diffScroll = deltaAbs(lastScroll, startScroll);
353
+ const diffCross = deltaAbs(lastCross, startCross);
354
+ if (!preventScroll && !isMouse) {
355
+ if (!evt.cancelable) return up(evt);
356
+ preventScroll = diffScroll > diffCross;
357
+ if (!preventScroll) return up(evt);
358
+ }
359
+ const diff = dragTracker.pointerMove(evt);
360
+ if (diffScroll > dragThreshold) preventClick = true;
361
+ scrollBody.useFriction(0.3).useDuration(0.75);
362
+ animation.start();
363
+ target.add(direction(diff));
364
+ evt.preventDefault();
365
+ }
366
+ function up(evt) {
367
+ const currentLocation = scrollTarget.byDistance(0, false);
368
+ const targetChanged = currentLocation.index !== index.get();
369
+ const rawForce = dragTracker.pointerUp(evt) * forceBoost();
370
+ const force = allowedForce(direction(rawForce), targetChanged);
371
+ const forceFactor = factorAbs(rawForce, force);
372
+ const speed = baseSpeed - 10 * forceFactor;
373
+ const friction = baseFriction + forceFactor / 50;
374
+ preventScroll = false;
375
+ pointerIsDown = false;
376
+ dragEvents.clear();
377
+ scrollBody.useDuration(speed).useFriction(friction);
378
+ scrollTo.distance(force, !dragFree);
379
+ isMouse = false;
380
+ eventHandler.emit("pointerUp");
381
+ }
382
+ function click(evt) {
383
+ if (preventClick) {
384
+ evt.stopPropagation();
385
+ evt.preventDefault();
386
+ preventClick = false;
387
+ }
388
+ }
389
+ function pointerDown() {
390
+ return pointerIsDown;
391
+ }
392
+ const self = {
393
+ init,
394
+ destroy,
395
+ pointerDown
396
+ };
397
+ return self;
398
+ }
399
+ function DragTracker(axis, ownerWindow) {
400
+ const logInterval = 170;
401
+ let startEvent;
402
+ let lastEvent;
403
+ function readTime(evt) {
404
+ return evt.timeStamp;
405
+ }
406
+ function readPoint(evt, evtAxis) {
407
+ const property = evtAxis || axis.scroll;
408
+ const coord = `client${property === "x" ? "X" : "Y"}`;
409
+ return (isMouseEvent(evt, ownerWindow) ? evt : evt.touches[0])[coord];
410
+ }
411
+ function pointerDown(evt) {
412
+ startEvent = evt;
413
+ lastEvent = evt;
414
+ return readPoint(evt);
415
+ }
416
+ function pointerMove(evt) {
417
+ const diff = readPoint(evt) - readPoint(lastEvent);
418
+ const expired = readTime(evt) - readTime(startEvent) > logInterval;
419
+ lastEvent = evt;
420
+ if (expired) startEvent = evt;
421
+ return diff;
422
+ }
423
+ function pointerUp(evt) {
424
+ if (!startEvent || !lastEvent) return 0;
425
+ const diffDrag = readPoint(lastEvent) - readPoint(startEvent);
426
+ const diffTime = readTime(evt) - readTime(startEvent);
427
+ const expired = readTime(evt) - readTime(lastEvent) > logInterval;
428
+ const force = diffDrag / diffTime;
429
+ const isFlick = diffTime && !expired && mathAbs(force) > 0.1;
430
+ return isFlick ? force : 0;
431
+ }
432
+ const self = {
433
+ pointerDown,
434
+ pointerMove,
435
+ pointerUp,
436
+ readPoint
437
+ };
438
+ return self;
439
+ }
440
+ function NodeRects() {
441
+ function measure(node) {
442
+ const {
443
+ offsetTop,
444
+ offsetLeft,
445
+ offsetWidth,
446
+ offsetHeight
447
+ } = node;
448
+ const offset = {
449
+ top: offsetTop,
450
+ right: offsetLeft + offsetWidth,
451
+ bottom: offsetTop + offsetHeight,
452
+ left: offsetLeft,
453
+ width: offsetWidth,
454
+ height: offsetHeight
455
+ };
456
+ return offset;
457
+ }
458
+ const self = {
459
+ measure
460
+ };
461
+ return self;
462
+ }
463
+ function PercentOfView(viewSize) {
464
+ function measure(n) {
465
+ return viewSize * (n / 100);
466
+ }
467
+ const self = {
468
+ measure
469
+ };
470
+ return self;
471
+ }
472
+ function ResizeHandler(container, eventHandler, ownerWindow, slides, axis, watchResize, nodeRects) {
473
+ const observeNodes = [container].concat(slides);
474
+ let resizeObserver;
475
+ let containerSize;
476
+ let slideSizes = [];
477
+ let destroyed = false;
478
+ function readSize(node) {
479
+ return axis.measureSize(nodeRects.measure(node));
480
+ }
481
+ function init(emblaApi) {
482
+ if (!watchResize) return;
483
+ containerSize = readSize(container);
484
+ slideSizes = slides.map(readSize);
485
+ function defaultCallback(entries) {
486
+ for (const entry of entries) {
487
+ if (destroyed) return;
488
+ const isContainer = entry.target === container;
489
+ const slideIndex = slides.indexOf(entry.target);
490
+ const lastSize = isContainer ? containerSize : slideSizes[slideIndex];
491
+ const newSize = readSize(isContainer ? container : slides[slideIndex]);
492
+ const diffSize = mathAbs(newSize - lastSize);
493
+ if (diffSize >= 0.5) {
494
+ emblaApi.reInit();
495
+ eventHandler.emit("resize");
496
+ break;
497
+ }
498
+ }
499
+ }
500
+ resizeObserver = new ResizeObserver((entries) => {
501
+ if (isBoolean(watchResize) || watchResize(emblaApi, entries)) {
502
+ defaultCallback(entries);
503
+ }
504
+ });
505
+ ownerWindow.requestAnimationFrame(() => {
506
+ observeNodes.forEach((node) => resizeObserver.observe(node));
507
+ });
508
+ }
509
+ function destroy() {
510
+ destroyed = true;
511
+ if (resizeObserver) resizeObserver.disconnect();
512
+ }
513
+ const self = {
514
+ init,
515
+ destroy
516
+ };
517
+ return self;
518
+ }
519
+ function ScrollBody(location, offsetLocation, previousLocation, target, baseDuration, baseFriction) {
520
+ let scrollVelocity = 0;
521
+ let scrollDirection = 0;
522
+ let scrollDuration = baseDuration;
523
+ let scrollFriction = baseFriction;
524
+ let rawLocation = location.get();
525
+ let rawLocationPrevious = 0;
526
+ function seek() {
527
+ const displacement = target.get() - location.get();
528
+ const isInstant = !scrollDuration;
529
+ let scrollDistance = 0;
530
+ if (isInstant) {
531
+ scrollVelocity = 0;
532
+ previousLocation.set(target);
533
+ location.set(target);
534
+ scrollDistance = displacement;
535
+ } else {
536
+ previousLocation.set(location);
537
+ scrollVelocity += displacement / scrollDuration;
538
+ scrollVelocity *= scrollFriction;
539
+ rawLocation += scrollVelocity;
540
+ location.add(scrollVelocity);
541
+ scrollDistance = rawLocation - rawLocationPrevious;
542
+ }
543
+ scrollDirection = mathSign(scrollDistance);
544
+ rawLocationPrevious = rawLocation;
545
+ return self;
546
+ }
547
+ function settled() {
548
+ const diff = target.get() - offsetLocation.get();
549
+ return mathAbs(diff) < 1e-3;
550
+ }
551
+ function duration() {
552
+ return scrollDuration;
553
+ }
554
+ function direction() {
555
+ return scrollDirection;
556
+ }
557
+ function velocity() {
558
+ return scrollVelocity;
559
+ }
560
+ function useBaseDuration() {
561
+ return useDuration(baseDuration);
562
+ }
563
+ function useBaseFriction() {
564
+ return useFriction(baseFriction);
565
+ }
566
+ function useDuration(n) {
567
+ scrollDuration = n;
568
+ return self;
569
+ }
570
+ function useFriction(n) {
571
+ scrollFriction = n;
572
+ return self;
573
+ }
574
+ const self = {
575
+ direction,
576
+ duration,
577
+ velocity,
578
+ seek,
579
+ settled,
580
+ useBaseFriction,
581
+ useBaseDuration,
582
+ useFriction,
583
+ useDuration
584
+ };
585
+ return self;
586
+ }
587
+ function ScrollBounds(limit, location, target, scrollBody, percentOfView) {
588
+ const pullBackThreshold = percentOfView.measure(10);
589
+ const edgeOffsetTolerance = percentOfView.measure(50);
590
+ const frictionLimit = Limit(0.1, 0.99);
591
+ let disabled = false;
592
+ function shouldConstrain() {
593
+ if (disabled) return false;
594
+ if (!limit.reachedAny(target.get())) return false;
595
+ if (!limit.reachedAny(location.get())) return false;
596
+ return true;
597
+ }
598
+ function constrain(pointerDown) {
599
+ if (!shouldConstrain()) return;
600
+ const edge = limit.reachedMin(location.get()) ? "min" : "max";
601
+ const diffToEdge = mathAbs(limit[edge] - location.get());
602
+ const diffToTarget = target.get() - location.get();
603
+ const friction = frictionLimit.constrain(diffToEdge / edgeOffsetTolerance);
604
+ target.subtract(diffToTarget * friction);
605
+ if (!pointerDown && mathAbs(diffToTarget) < pullBackThreshold) {
606
+ target.set(limit.constrain(target.get()));
607
+ scrollBody.useDuration(25).useBaseFriction();
608
+ }
609
+ }
610
+ function toggleActive(active) {
611
+ disabled = !active;
612
+ }
613
+ const self = {
614
+ shouldConstrain,
615
+ constrain,
616
+ toggleActive
617
+ };
618
+ return self;
619
+ }
620
+ function ScrollContain(viewSize, contentSize, snapsAligned, containScroll, pixelTolerance) {
621
+ const scrollBounds = Limit(-contentSize + viewSize, 0);
622
+ const snapsBounded = measureBounded();
623
+ const scrollContainLimit = findScrollContainLimit();
624
+ const snapsContained = measureContained();
625
+ function usePixelTolerance(bound, snap) {
626
+ return deltaAbs(bound, snap) <= 1;
627
+ }
628
+ function findScrollContainLimit() {
629
+ const startSnap = snapsBounded[0];
630
+ const endSnap = arrayLast(snapsBounded);
631
+ const min = snapsBounded.lastIndexOf(startSnap);
632
+ const max = snapsBounded.indexOf(endSnap) + 1;
633
+ return Limit(min, max);
634
+ }
635
+ function measureBounded() {
636
+ return snapsAligned.map((snapAligned, index) => {
637
+ const {
638
+ min,
639
+ max
640
+ } = scrollBounds;
641
+ const snap = scrollBounds.constrain(snapAligned);
642
+ const isFirst = !index;
643
+ const isLast = arrayIsLastIndex(snapsAligned, index);
644
+ if (isFirst) return max;
645
+ if (isLast) return min;
646
+ if (usePixelTolerance(min, snap)) return min;
647
+ if (usePixelTolerance(max, snap)) return max;
648
+ return snap;
649
+ }).map((scrollBound) => parseFloat(scrollBound.toFixed(3)));
650
+ }
651
+ function measureContained() {
652
+ if (contentSize <= viewSize + pixelTolerance) return [scrollBounds.max];
653
+ if (containScroll === "keepSnaps") return snapsBounded;
654
+ const {
655
+ min,
656
+ max
657
+ } = scrollContainLimit;
658
+ return snapsBounded.slice(min, max);
659
+ }
660
+ const self = {
661
+ snapsContained,
662
+ scrollContainLimit
663
+ };
664
+ return self;
665
+ }
666
+ function ScrollLimit(contentSize, scrollSnaps, loop) {
667
+ const max = scrollSnaps[0];
668
+ const min = loop ? max - contentSize : arrayLast(scrollSnaps);
669
+ const limit = Limit(min, max);
670
+ const self = {
671
+ limit
672
+ };
673
+ return self;
674
+ }
675
+ function ScrollLooper(contentSize, limit, location, vectors) {
676
+ const jointSafety = 0.1;
677
+ const min = limit.min + jointSafety;
678
+ const max = limit.max + jointSafety;
679
+ const {
680
+ reachedMin,
681
+ reachedMax
682
+ } = Limit(min, max);
683
+ function shouldLoop(direction) {
684
+ if (direction === 1) return reachedMax(location.get());
685
+ if (direction === -1) return reachedMin(location.get());
686
+ return false;
687
+ }
688
+ function loop(direction) {
689
+ if (!shouldLoop(direction)) return;
690
+ const loopDistance = contentSize * (direction * -1);
691
+ vectors.forEach((v) => v.add(loopDistance));
692
+ }
693
+ const self = {
694
+ loop
695
+ };
696
+ return self;
697
+ }
698
+ function ScrollProgress(limit) {
699
+ const {
700
+ max,
701
+ length
702
+ } = limit;
703
+ function get(n) {
704
+ const currentLocation = n - max;
705
+ return length ? currentLocation / -length : 0;
706
+ }
707
+ const self = {
708
+ get
709
+ };
710
+ return self;
711
+ }
712
+ function ScrollSnaps(axis, alignment, containerRect, slideRects, slidesToScroll) {
713
+ const {
714
+ startEdge,
715
+ endEdge
716
+ } = axis;
717
+ const {
718
+ groupSlides
719
+ } = slidesToScroll;
720
+ const alignments = measureSizes().map(alignment.measure);
721
+ const snaps = measureUnaligned();
722
+ const snapsAligned = measureAligned();
723
+ function measureSizes() {
724
+ return groupSlides(slideRects).map((rects) => arrayLast(rects)[endEdge] - rects[0][startEdge]).map(mathAbs);
725
+ }
726
+ function measureUnaligned() {
727
+ return slideRects.map((rect) => containerRect[startEdge] - rect[startEdge]).map((snap) => -mathAbs(snap));
728
+ }
729
+ function measureAligned() {
730
+ return groupSlides(snaps).map((g) => g[0]).map((snap, index) => snap + alignments[index]);
731
+ }
732
+ const self = {
733
+ snaps,
734
+ snapsAligned
735
+ };
736
+ return self;
737
+ }
738
+ function SlideRegistry(containSnaps, containScroll, scrollSnaps, scrollContainLimit, slidesToScroll, slideIndexes) {
739
+ const {
740
+ groupSlides
741
+ } = slidesToScroll;
742
+ const {
743
+ min,
744
+ max
745
+ } = scrollContainLimit;
746
+ const slideRegistry = createSlideRegistry();
747
+ function createSlideRegistry() {
748
+ const groupedSlideIndexes = groupSlides(slideIndexes);
749
+ const doNotContain = !containSnaps || containScroll === "keepSnaps";
750
+ if (scrollSnaps.length === 1) return [slideIndexes];
751
+ if (doNotContain) return groupedSlideIndexes;
752
+ return groupedSlideIndexes.slice(min, max).map((group, index, groups) => {
753
+ const isFirst = !index;
754
+ const isLast = arrayIsLastIndex(groups, index);
755
+ if (isFirst) {
756
+ const range = arrayLast(groups[0]) + 1;
757
+ return arrayFromNumber(range);
758
+ }
759
+ if (isLast) {
760
+ const range = arrayLastIndex(slideIndexes) - arrayLast(groups)[0] + 1;
761
+ return arrayFromNumber(range, arrayLast(groups)[0]);
762
+ }
763
+ return group;
764
+ });
765
+ }
766
+ const self = {
767
+ slideRegistry
768
+ };
769
+ return self;
770
+ }
771
+ function ScrollTarget(loop, scrollSnaps, contentSize, limit, targetVector) {
772
+ const {
773
+ reachedAny,
774
+ removeOffset,
775
+ constrain
776
+ } = limit;
777
+ function minDistance(distances) {
778
+ return distances.concat().sort((a, b) => mathAbs(a) - mathAbs(b))[0];
779
+ }
780
+ function findTargetSnap(target) {
781
+ const distance = loop ? removeOffset(target) : constrain(target);
782
+ const ascDiffsToSnaps = scrollSnaps.map((snap, index2) => ({
783
+ diff: shortcut(snap - distance, 0),
784
+ index: index2
785
+ })).sort((d1, d2) => mathAbs(d1.diff) - mathAbs(d2.diff));
786
+ const {
787
+ index
788
+ } = ascDiffsToSnaps[0];
789
+ return {
790
+ index,
791
+ distance
792
+ };
793
+ }
794
+ function shortcut(target, direction) {
795
+ const targets = [target, target + contentSize, target - contentSize];
796
+ if (!loop) return target;
797
+ if (!direction) return minDistance(targets);
798
+ const matchingTargets = targets.filter((t) => mathSign(t) === direction);
799
+ if (matchingTargets.length) return minDistance(matchingTargets);
800
+ return arrayLast(targets) - contentSize;
801
+ }
802
+ function byIndex(index, direction) {
803
+ const diffToSnap = scrollSnaps[index] - targetVector.get();
804
+ const distance = shortcut(diffToSnap, direction);
805
+ return {
806
+ index,
807
+ distance
808
+ };
809
+ }
810
+ function byDistance(distance, snap) {
811
+ const target = targetVector.get() + distance;
812
+ const {
813
+ index,
814
+ distance: targetSnapDistance
815
+ } = findTargetSnap(target);
816
+ const reachedBound = !loop && reachedAny(target);
817
+ if (!snap || reachedBound) return {
818
+ index,
819
+ distance
820
+ };
821
+ const diffToSnap = scrollSnaps[index] - targetSnapDistance;
822
+ const snapDistance = distance + shortcut(diffToSnap, 0);
823
+ return {
824
+ index,
825
+ distance: snapDistance
826
+ };
827
+ }
828
+ const self = {
829
+ byDistance,
830
+ byIndex,
831
+ shortcut
832
+ };
833
+ return self;
834
+ }
835
+ function ScrollTo(animation, indexCurrent, indexPrevious, scrollBody, scrollTarget, targetVector, eventHandler) {
836
+ function scrollTo(target) {
837
+ const distanceDiff = target.distance;
838
+ const indexDiff = target.index !== indexCurrent.get();
839
+ targetVector.add(distanceDiff);
840
+ if (distanceDiff) {
841
+ if (scrollBody.duration()) {
842
+ animation.start();
843
+ } else {
844
+ animation.update();
845
+ animation.render(1);
846
+ animation.update();
847
+ }
848
+ }
849
+ if (indexDiff) {
850
+ indexPrevious.set(indexCurrent.get());
851
+ indexCurrent.set(target.index);
852
+ eventHandler.emit("select");
853
+ }
854
+ }
855
+ function distance(n, snap) {
856
+ const target = scrollTarget.byDistance(n, snap);
857
+ scrollTo(target);
858
+ }
859
+ function index(n, direction) {
860
+ const targetIndex = indexCurrent.clone().set(n);
861
+ const target = scrollTarget.byIndex(targetIndex.get(), direction);
862
+ scrollTo(target);
863
+ }
864
+ const self = {
865
+ distance,
866
+ index
867
+ };
868
+ return self;
869
+ }
870
+ function SlideFocus(root, slides, slideRegistry, scrollTo, scrollBody, eventStore, eventHandler, watchFocus) {
871
+ const focusListenerOptions = {
872
+ passive: true,
873
+ capture: true
874
+ };
875
+ let lastTabPressTime = 0;
876
+ function init(emblaApi) {
877
+ if (!watchFocus) return;
878
+ function defaultCallback(index) {
879
+ const nowTime = (/* @__PURE__ */ new Date()).getTime();
880
+ const diffTime = nowTime - lastTabPressTime;
881
+ if (diffTime > 10) return;
882
+ eventHandler.emit("slideFocusStart");
883
+ root.scrollLeft = 0;
884
+ const group = slideRegistry.findIndex((group2) => group2.includes(index));
885
+ if (!isNumber(group)) return;
886
+ scrollBody.useDuration(0);
887
+ scrollTo.index(group, 0);
888
+ eventHandler.emit("slideFocus");
889
+ }
890
+ eventStore.add(document, "keydown", registerTabPress, false);
891
+ slides.forEach((slide, slideIndex) => {
892
+ eventStore.add(slide, "focus", (evt) => {
893
+ if (isBoolean(watchFocus) || watchFocus(emblaApi, evt)) {
894
+ defaultCallback(slideIndex);
895
+ }
896
+ }, focusListenerOptions);
897
+ });
898
+ }
899
+ function registerTabPress(event) {
900
+ if (event.code === "Tab") lastTabPressTime = (/* @__PURE__ */ new Date()).getTime();
901
+ }
902
+ const self = {
903
+ init
904
+ };
905
+ return self;
906
+ }
907
+ function Vector1D(initialValue) {
908
+ let value = initialValue;
909
+ function get() {
910
+ return value;
911
+ }
912
+ function set(n) {
913
+ value = normalizeInput(n);
914
+ }
915
+ function add(n) {
916
+ value += normalizeInput(n);
917
+ }
918
+ function subtract(n) {
919
+ value -= normalizeInput(n);
920
+ }
921
+ function normalizeInput(n) {
922
+ return isNumber(n) ? n : n.get();
923
+ }
924
+ const self = {
925
+ get,
926
+ set,
927
+ add,
928
+ subtract
929
+ };
930
+ return self;
931
+ }
932
+ function Translate(axis, container) {
933
+ const translate = axis.scroll === "x" ? x : y;
934
+ const containerStyle = container.style;
935
+ let previousTarget = null;
936
+ let disabled = false;
937
+ function x(n) {
938
+ return `translate3d(${n}px,0px,0px)`;
939
+ }
940
+ function y(n) {
941
+ return `translate3d(0px,${n}px,0px)`;
942
+ }
943
+ function to(target) {
944
+ if (disabled) return;
945
+ const newTarget = roundToTwoDecimals(axis.direction(target));
946
+ if (newTarget === previousTarget) return;
947
+ containerStyle.transform = translate(newTarget);
948
+ previousTarget = newTarget;
949
+ }
950
+ function toggleActive(active) {
951
+ disabled = !active;
952
+ }
953
+ function clear() {
954
+ if (disabled) return;
955
+ containerStyle.transform = "";
956
+ if (!container.getAttribute("style")) container.removeAttribute("style");
957
+ }
958
+ const self = {
959
+ clear,
960
+ to,
961
+ toggleActive
962
+ };
963
+ return self;
964
+ }
965
+ function SlideLooper(axis, viewSize, contentSize, slideSizes, slideSizesWithGaps, snaps, scrollSnaps, location, slides) {
966
+ const roundingSafety = 0.5;
967
+ const ascItems = arrayKeys(slideSizesWithGaps);
968
+ const descItems = arrayKeys(slideSizesWithGaps).reverse();
969
+ const loopPoints = startPoints().concat(endPoints());
970
+ function removeSlideSizes(indexes, from) {
971
+ return indexes.reduce((a, i) => {
972
+ return a - slideSizesWithGaps[i];
973
+ }, from);
974
+ }
975
+ function slidesInGap(indexes, gap) {
976
+ return indexes.reduce((a, i) => {
977
+ const remainingGap = removeSlideSizes(a, gap);
978
+ return remainingGap > 0 ? a.concat([i]) : a;
979
+ }, []);
980
+ }
981
+ function findSlideBounds(offset) {
982
+ return snaps.map((snap, index) => ({
983
+ start: snap - slideSizes[index] + roundingSafety + offset,
984
+ end: snap + viewSize - roundingSafety + offset
985
+ }));
986
+ }
987
+ function findLoopPoints(indexes, offset, isEndEdge) {
988
+ const slideBounds = findSlideBounds(offset);
989
+ return indexes.map((index) => {
990
+ const initial = isEndEdge ? 0 : -contentSize;
991
+ const altered = isEndEdge ? contentSize : 0;
992
+ const boundEdge = isEndEdge ? "end" : "start";
993
+ const loopPoint = slideBounds[index][boundEdge];
994
+ return {
995
+ index,
996
+ loopPoint,
997
+ slideLocation: Vector1D(-1),
998
+ translate: Translate(axis, slides[index]),
999
+ target: () => location.get() > loopPoint ? initial : altered
1000
+ };
1001
+ });
1002
+ }
1003
+ function startPoints() {
1004
+ const gap = scrollSnaps[0];
1005
+ const indexes = slidesInGap(descItems, gap);
1006
+ return findLoopPoints(indexes, contentSize, false);
1007
+ }
1008
+ function endPoints() {
1009
+ const gap = viewSize - scrollSnaps[0] - 1;
1010
+ const indexes = slidesInGap(ascItems, gap);
1011
+ return findLoopPoints(indexes, -contentSize, true);
1012
+ }
1013
+ function canLoop() {
1014
+ return loopPoints.every(({
1015
+ index
1016
+ }) => {
1017
+ const otherIndexes = ascItems.filter((i) => i !== index);
1018
+ return removeSlideSizes(otherIndexes, viewSize) <= 0.1;
1019
+ });
1020
+ }
1021
+ function loop() {
1022
+ loopPoints.forEach((loopPoint) => {
1023
+ const {
1024
+ target,
1025
+ translate,
1026
+ slideLocation
1027
+ } = loopPoint;
1028
+ const shiftLocation = target();
1029
+ if (shiftLocation === slideLocation.get()) return;
1030
+ translate.to(shiftLocation);
1031
+ slideLocation.set(shiftLocation);
1032
+ });
1033
+ }
1034
+ function clear() {
1035
+ loopPoints.forEach((loopPoint) => loopPoint.translate.clear());
1036
+ }
1037
+ const self = {
1038
+ canLoop,
1039
+ clear,
1040
+ loop,
1041
+ loopPoints
1042
+ };
1043
+ return self;
1044
+ }
1045
+ function SlidesHandler(container, eventHandler, watchSlides) {
1046
+ let mutationObserver;
1047
+ let destroyed = false;
1048
+ function init(emblaApi) {
1049
+ if (!watchSlides) return;
1050
+ function defaultCallback(mutations) {
1051
+ for (const mutation of mutations) {
1052
+ if (mutation.type === "childList") {
1053
+ emblaApi.reInit();
1054
+ eventHandler.emit("slidesChanged");
1055
+ break;
1056
+ }
1057
+ }
1058
+ }
1059
+ mutationObserver = new MutationObserver((mutations) => {
1060
+ if (destroyed) return;
1061
+ if (isBoolean(watchSlides) || watchSlides(emblaApi, mutations)) {
1062
+ defaultCallback(mutations);
1063
+ }
1064
+ });
1065
+ mutationObserver.observe(container, {
1066
+ childList: true
1067
+ });
1068
+ }
1069
+ function destroy() {
1070
+ if (mutationObserver) mutationObserver.disconnect();
1071
+ destroyed = true;
1072
+ }
1073
+ const self = {
1074
+ init,
1075
+ destroy
1076
+ };
1077
+ return self;
1078
+ }
1079
+ function SlidesInView(container, slides, eventHandler, threshold) {
1080
+ const intersectionEntryMap = {};
1081
+ let inViewCache = null;
1082
+ let notInViewCache = null;
1083
+ let intersectionObserver;
1084
+ let destroyed = false;
1085
+ function init() {
1086
+ intersectionObserver = new IntersectionObserver((entries) => {
1087
+ if (destroyed) return;
1088
+ entries.forEach((entry) => {
1089
+ const index = slides.indexOf(entry.target);
1090
+ intersectionEntryMap[index] = entry;
1091
+ });
1092
+ inViewCache = null;
1093
+ notInViewCache = null;
1094
+ eventHandler.emit("slidesInView");
1095
+ }, {
1096
+ root: container.parentElement,
1097
+ threshold
1098
+ });
1099
+ slides.forEach((slide) => intersectionObserver.observe(slide));
1100
+ }
1101
+ function destroy() {
1102
+ if (intersectionObserver) intersectionObserver.disconnect();
1103
+ destroyed = true;
1104
+ }
1105
+ function createInViewList(inView) {
1106
+ return objectKeys(intersectionEntryMap).reduce((list, slideIndex) => {
1107
+ const index = parseInt(slideIndex);
1108
+ const {
1109
+ isIntersecting
1110
+ } = intersectionEntryMap[index];
1111
+ const inViewMatch = inView && isIntersecting;
1112
+ const notInViewMatch = !inView && !isIntersecting;
1113
+ if (inViewMatch || notInViewMatch) list.push(index);
1114
+ return list;
1115
+ }, []);
1116
+ }
1117
+ function get(inView = true) {
1118
+ if (inView && inViewCache) return inViewCache;
1119
+ if (!inView && notInViewCache) return notInViewCache;
1120
+ const slideIndexes = createInViewList(inView);
1121
+ if (inView) inViewCache = slideIndexes;
1122
+ if (!inView) notInViewCache = slideIndexes;
1123
+ return slideIndexes;
1124
+ }
1125
+ const self = {
1126
+ init,
1127
+ destroy,
1128
+ get
1129
+ };
1130
+ return self;
1131
+ }
1132
+ function SlideSizes(axis, containerRect, slideRects, slides, readEdgeGap, ownerWindow) {
1133
+ const {
1134
+ measureSize,
1135
+ startEdge,
1136
+ endEdge
1137
+ } = axis;
1138
+ const withEdgeGap = slideRects[0] && readEdgeGap;
1139
+ const startGap = measureStartGap();
1140
+ const endGap = measureEndGap();
1141
+ const slideSizes = slideRects.map(measureSize);
1142
+ const slideSizesWithGaps = measureWithGaps();
1143
+ function measureStartGap() {
1144
+ if (!withEdgeGap) return 0;
1145
+ const slideRect = slideRects[0];
1146
+ return mathAbs(containerRect[startEdge] - slideRect[startEdge]);
1147
+ }
1148
+ function measureEndGap() {
1149
+ if (!withEdgeGap) return 0;
1150
+ const style = ownerWindow.getComputedStyle(arrayLast(slides));
1151
+ return parseFloat(style.getPropertyValue(`margin-${endEdge}`));
1152
+ }
1153
+ function measureWithGaps() {
1154
+ return slideRects.map((rect, index, rects) => {
1155
+ const isFirst = !index;
1156
+ const isLast = arrayIsLastIndex(rects, index);
1157
+ if (isFirst) return slideSizes[index] + startGap;
1158
+ if (isLast) return slideSizes[index] + endGap;
1159
+ return rects[index + 1][startEdge] - rect[startEdge];
1160
+ }).map(mathAbs);
1161
+ }
1162
+ const self = {
1163
+ slideSizes,
1164
+ slideSizesWithGaps,
1165
+ startGap,
1166
+ endGap
1167
+ };
1168
+ return self;
1169
+ }
1170
+ function SlidesToScroll(axis, viewSize, slidesToScroll, loop, containerRect, slideRects, startGap, endGap, pixelTolerance) {
1171
+ const {
1172
+ startEdge,
1173
+ endEdge,
1174
+ direction
1175
+ } = axis;
1176
+ const groupByNumber = isNumber(slidesToScroll);
1177
+ function byNumber(array, groupSize) {
1178
+ return arrayKeys(array).filter((i) => i % groupSize === 0).map((i) => array.slice(i, i + groupSize));
1179
+ }
1180
+ function bySize(array) {
1181
+ if (!array.length) return [];
1182
+ return arrayKeys(array).reduce((groups, rectB, index) => {
1183
+ const rectA = arrayLast(groups) || 0;
1184
+ const isFirst = rectA === 0;
1185
+ const isLast = rectB === arrayLastIndex(array);
1186
+ const edgeA = containerRect[startEdge] - slideRects[rectA][startEdge];
1187
+ const edgeB = containerRect[startEdge] - slideRects[rectB][endEdge];
1188
+ const gapA = !loop && isFirst ? direction(startGap) : 0;
1189
+ const gapB = !loop && isLast ? direction(endGap) : 0;
1190
+ const chunkSize = mathAbs(edgeB - gapB - (edgeA + gapA));
1191
+ if (index && chunkSize > viewSize + pixelTolerance) groups.push(rectB);
1192
+ if (isLast) groups.push(array.length);
1193
+ return groups;
1194
+ }, []).map((currentSize, index, groups) => {
1195
+ const previousSize = Math.max(groups[index - 1] || 0);
1196
+ return array.slice(previousSize, currentSize);
1197
+ });
1198
+ }
1199
+ function groupSlides(array) {
1200
+ return groupByNumber ? byNumber(array, slidesToScroll) : bySize(array);
1201
+ }
1202
+ const self = {
1203
+ groupSlides
1204
+ };
1205
+ return self;
1206
+ }
1207
+ function Engine(root, container, slides, ownerDocument, ownerWindow, options, eventHandler) {
1208
+ const {
1209
+ align,
1210
+ axis: scrollAxis,
1211
+ direction,
1212
+ startIndex,
1213
+ loop,
1214
+ duration,
1215
+ dragFree,
1216
+ dragThreshold,
1217
+ inViewThreshold,
1218
+ slidesToScroll: groupSlides,
1219
+ skipSnaps,
1220
+ containScroll,
1221
+ watchResize,
1222
+ watchSlides,
1223
+ watchDrag,
1224
+ watchFocus
1225
+ } = options;
1226
+ const pixelTolerance = 2;
1227
+ const nodeRects = NodeRects();
1228
+ const containerRect = nodeRects.measure(container);
1229
+ const slideRects = slides.map(nodeRects.measure);
1230
+ const axis = Axis(scrollAxis, direction);
1231
+ const viewSize = axis.measureSize(containerRect);
1232
+ const percentOfView = PercentOfView(viewSize);
1233
+ const alignment = Alignment(align, viewSize);
1234
+ const containSnaps = !loop && !!containScroll;
1235
+ const readEdgeGap = loop || !!containScroll;
1236
+ const {
1237
+ slideSizes,
1238
+ slideSizesWithGaps,
1239
+ startGap,
1240
+ endGap
1241
+ } = SlideSizes(axis, containerRect, slideRects, slides, readEdgeGap, ownerWindow);
1242
+ const slidesToScroll = SlidesToScroll(axis, viewSize, groupSlides, loop, containerRect, slideRects, startGap, endGap, pixelTolerance);
1243
+ const {
1244
+ snaps,
1245
+ snapsAligned
1246
+ } = ScrollSnaps(axis, alignment, containerRect, slideRects, slidesToScroll);
1247
+ const contentSize = -arrayLast(snaps) + arrayLast(slideSizesWithGaps);
1248
+ const {
1249
+ snapsContained,
1250
+ scrollContainLimit
1251
+ } = ScrollContain(viewSize, contentSize, snapsAligned, containScroll, pixelTolerance);
1252
+ const scrollSnaps = containSnaps ? snapsContained : snapsAligned;
1253
+ const {
1254
+ limit
1255
+ } = ScrollLimit(contentSize, scrollSnaps, loop);
1256
+ const index = Counter(arrayLastIndex(scrollSnaps), startIndex, loop);
1257
+ const indexPrevious = index.clone();
1258
+ const slideIndexes = arrayKeys(slides);
1259
+ const update = ({
1260
+ dragHandler,
1261
+ scrollBody: scrollBody2,
1262
+ scrollBounds,
1263
+ options: {
1264
+ loop: loop2
1265
+ }
1266
+ }) => {
1267
+ if (!loop2) scrollBounds.constrain(dragHandler.pointerDown());
1268
+ scrollBody2.seek();
1269
+ };
1270
+ const render = ({
1271
+ scrollBody: scrollBody2,
1272
+ translate,
1273
+ location: location2,
1274
+ offsetLocation: offsetLocation2,
1275
+ previousLocation: previousLocation2,
1276
+ scrollLooper,
1277
+ slideLooper,
1278
+ dragHandler,
1279
+ animation: animation2,
1280
+ eventHandler: eventHandler2,
1281
+ scrollBounds,
1282
+ options: {
1283
+ loop: loop2
1284
+ }
1285
+ }, alpha) => {
1286
+ const shouldSettle = scrollBody2.settled();
1287
+ const withinBounds = !scrollBounds.shouldConstrain();
1288
+ const hasSettled = loop2 ? shouldSettle : shouldSettle && withinBounds;
1289
+ const hasSettledAndIdle = hasSettled && !dragHandler.pointerDown();
1290
+ if (hasSettledAndIdle) animation2.stop();
1291
+ const interpolatedLocation = location2.get() * alpha + previousLocation2.get() * (1 - alpha);
1292
+ offsetLocation2.set(interpolatedLocation);
1293
+ if (loop2) {
1294
+ scrollLooper.loop(scrollBody2.direction());
1295
+ slideLooper.loop();
1296
+ }
1297
+ translate.to(offsetLocation2.get());
1298
+ if (hasSettledAndIdle) eventHandler2.emit("settle");
1299
+ if (!hasSettled) eventHandler2.emit("scroll");
1300
+ };
1301
+ const animation = Animations(ownerDocument, ownerWindow, () => update(engine), (alpha) => render(engine, alpha));
1302
+ const friction = 0.68;
1303
+ const startLocation = scrollSnaps[index.get()];
1304
+ const location = Vector1D(startLocation);
1305
+ const previousLocation = Vector1D(startLocation);
1306
+ const offsetLocation = Vector1D(startLocation);
1307
+ const target = Vector1D(startLocation);
1308
+ const scrollBody = ScrollBody(location, offsetLocation, previousLocation, target, duration, friction);
1309
+ const scrollTarget = ScrollTarget(loop, scrollSnaps, contentSize, limit, target);
1310
+ const scrollTo = ScrollTo(animation, index, indexPrevious, scrollBody, scrollTarget, target, eventHandler);
1311
+ const scrollProgress = ScrollProgress(limit);
1312
+ const eventStore = EventStore();
1313
+ const slidesInView = SlidesInView(container, slides, eventHandler, inViewThreshold);
1314
+ const {
1315
+ slideRegistry
1316
+ } = SlideRegistry(containSnaps, containScroll, scrollSnaps, scrollContainLimit, slidesToScroll, slideIndexes);
1317
+ const slideFocus = SlideFocus(root, slides, slideRegistry, scrollTo, scrollBody, eventStore, eventHandler, watchFocus);
1318
+ const engine = {
1319
+ ownerDocument,
1320
+ ownerWindow,
1321
+ eventHandler,
1322
+ containerRect,
1323
+ slideRects,
1324
+ animation,
1325
+ axis,
1326
+ dragHandler: DragHandler(axis, root, ownerDocument, ownerWindow, target, DragTracker(axis, ownerWindow), location, animation, scrollTo, scrollBody, scrollTarget, index, eventHandler, percentOfView, dragFree, dragThreshold, skipSnaps, friction, watchDrag),
1327
+ eventStore,
1328
+ percentOfView,
1329
+ index,
1330
+ indexPrevious,
1331
+ limit,
1332
+ location,
1333
+ offsetLocation,
1334
+ previousLocation,
1335
+ options,
1336
+ resizeHandler: ResizeHandler(container, eventHandler, ownerWindow, slides, axis, watchResize, nodeRects),
1337
+ scrollBody,
1338
+ scrollBounds: ScrollBounds(limit, offsetLocation, target, scrollBody, percentOfView),
1339
+ scrollLooper: ScrollLooper(contentSize, limit, offsetLocation, [location, offsetLocation, previousLocation, target]),
1340
+ scrollProgress,
1341
+ scrollSnapList: scrollSnaps.map(scrollProgress.get),
1342
+ scrollSnaps,
1343
+ scrollTarget,
1344
+ scrollTo,
1345
+ slideLooper: SlideLooper(axis, viewSize, contentSize, slideSizes, slideSizesWithGaps, snaps, scrollSnaps, offsetLocation, slides),
1346
+ slideFocus,
1347
+ slidesHandler: SlidesHandler(container, eventHandler, watchSlides),
1348
+ slidesInView,
1349
+ slideIndexes,
1350
+ slideRegistry,
1351
+ slidesToScroll,
1352
+ target,
1353
+ translate: Translate(axis, container)
1354
+ };
1355
+ return engine;
1356
+ }
1357
+ function EventHandler() {
1358
+ let listeners = {};
1359
+ let api;
1360
+ function init(emblaApi) {
1361
+ api = emblaApi;
1362
+ }
1363
+ function getListeners(evt) {
1364
+ return listeners[evt] || [];
1365
+ }
1366
+ function emit(evt) {
1367
+ getListeners(evt).forEach((e) => e(api, evt));
1368
+ return self;
1369
+ }
1370
+ function on(evt, cb) {
1371
+ listeners[evt] = getListeners(evt).concat([cb]);
1372
+ return self;
1373
+ }
1374
+ function off(evt, cb) {
1375
+ listeners[evt] = getListeners(evt).filter((e) => e !== cb);
1376
+ return self;
1377
+ }
1378
+ function clear() {
1379
+ listeners = {};
1380
+ }
1381
+ const self = {
1382
+ init,
1383
+ emit,
1384
+ off,
1385
+ on,
1386
+ clear
1387
+ };
1388
+ return self;
1389
+ }
1390
+ const defaultOptions = {
1391
+ align: "center",
1392
+ axis: "x",
1393
+ container: null,
1394
+ slides: null,
1395
+ containScroll: "trimSnaps",
1396
+ direction: "ltr",
1397
+ slidesToScroll: 1,
1398
+ inViewThreshold: 0,
1399
+ breakpoints: {},
1400
+ dragFree: false,
1401
+ dragThreshold: 10,
1402
+ loop: false,
1403
+ skipSnaps: false,
1404
+ duration: 25,
1405
+ startIndex: 0,
1406
+ active: true,
1407
+ watchDrag: true,
1408
+ watchResize: true,
1409
+ watchSlides: true,
1410
+ watchFocus: true
1411
+ };
1412
+ function OptionsHandler(ownerWindow) {
1413
+ function mergeOptions(optionsA, optionsB) {
1414
+ return objectsMergeDeep(optionsA, optionsB || {});
1415
+ }
1416
+ function optionsAtMedia(options) {
1417
+ const optionsAtMedia2 = options.breakpoints || {};
1418
+ const matchedMediaOptions = objectKeys(optionsAtMedia2).filter((media) => ownerWindow.matchMedia(media).matches).map((media) => optionsAtMedia2[media]).reduce((a, mediaOption) => mergeOptions(a, mediaOption), {});
1419
+ return mergeOptions(options, matchedMediaOptions);
1420
+ }
1421
+ function optionsMediaQueries(optionsList) {
1422
+ return optionsList.map((options) => objectKeys(options.breakpoints || {})).reduce((acc, mediaQueries) => acc.concat(mediaQueries), []).map(ownerWindow.matchMedia);
1423
+ }
1424
+ const self = {
1425
+ mergeOptions,
1426
+ optionsAtMedia,
1427
+ optionsMediaQueries
1428
+ };
1429
+ return self;
1430
+ }
1431
+ function PluginsHandler(optionsHandler) {
1432
+ let activePlugins = [];
1433
+ function init(emblaApi, plugins) {
1434
+ activePlugins = plugins.filter(({
1435
+ options
1436
+ }) => optionsHandler.optionsAtMedia(options).active !== false);
1437
+ activePlugins.forEach((plugin) => plugin.init(emblaApi, optionsHandler));
1438
+ return plugins.reduce((map, plugin) => Object.assign(map, {
1439
+ [plugin.name]: plugin
1440
+ }), {});
1441
+ }
1442
+ function destroy() {
1443
+ activePlugins = activePlugins.filter((plugin) => plugin.destroy());
1444
+ }
1445
+ const self = {
1446
+ init,
1447
+ destroy
1448
+ };
1449
+ return self;
1450
+ }
1451
+ function EmblaCarousel(root, userOptions, userPlugins) {
1452
+ const ownerDocument = root.ownerDocument;
1453
+ const ownerWindow = ownerDocument.defaultView;
1454
+ const optionsHandler = OptionsHandler(ownerWindow);
1455
+ const pluginsHandler = PluginsHandler(optionsHandler);
1456
+ const mediaHandlers = EventStore();
1457
+ const eventHandler = EventHandler();
1458
+ const {
1459
+ mergeOptions,
1460
+ optionsAtMedia,
1461
+ optionsMediaQueries
1462
+ } = optionsHandler;
1463
+ const {
1464
+ on,
1465
+ off,
1466
+ emit
1467
+ } = eventHandler;
1468
+ const reInit = reActivate;
1469
+ let destroyed = false;
1470
+ let engine;
1471
+ let optionsBase = mergeOptions(defaultOptions, EmblaCarousel.globalOptions);
1472
+ let options = mergeOptions(optionsBase);
1473
+ let pluginList = [];
1474
+ let pluginApis;
1475
+ let container;
1476
+ let slides;
1477
+ function storeElements() {
1478
+ const {
1479
+ container: userContainer,
1480
+ slides: userSlides
1481
+ } = options;
1482
+ const customContainer = isString(userContainer) ? root.querySelector(userContainer) : userContainer;
1483
+ container = customContainer || root.children[0];
1484
+ const customSlides = isString(userSlides) ? container.querySelectorAll(userSlides) : userSlides;
1485
+ slides = [].slice.call(customSlides || container.children);
1486
+ }
1487
+ function createEngine(options2) {
1488
+ const engine2 = Engine(root, container, slides, ownerDocument, ownerWindow, options2, eventHandler);
1489
+ if (options2.loop && !engine2.slideLooper.canLoop()) {
1490
+ const optionsWithoutLoop = Object.assign({}, options2, {
1491
+ loop: false
1492
+ });
1493
+ return createEngine(optionsWithoutLoop);
1494
+ }
1495
+ return engine2;
1496
+ }
1497
+ function activate(withOptions, withPlugins) {
1498
+ if (destroyed) return;
1499
+ optionsBase = mergeOptions(optionsBase, withOptions);
1500
+ options = optionsAtMedia(optionsBase);
1501
+ pluginList = withPlugins || pluginList;
1502
+ storeElements();
1503
+ engine = createEngine(options);
1504
+ optionsMediaQueries([optionsBase, ...pluginList.map(({
1505
+ options: options2
1506
+ }) => options2)]).forEach((query) => mediaHandlers.add(query, "change", reActivate));
1507
+ if (!options.active) return;
1508
+ engine.translate.to(engine.location.get());
1509
+ engine.animation.init();
1510
+ engine.slidesInView.init();
1511
+ engine.slideFocus.init(self);
1512
+ engine.eventHandler.init(self);
1513
+ engine.resizeHandler.init(self);
1514
+ engine.slidesHandler.init(self);
1515
+ if (engine.options.loop) engine.slideLooper.loop();
1516
+ if (container.offsetParent && slides.length) engine.dragHandler.init(self);
1517
+ pluginApis = pluginsHandler.init(self, pluginList);
1518
+ }
1519
+ function reActivate(withOptions, withPlugins) {
1520
+ const startIndex = selectedScrollSnap();
1521
+ deActivate();
1522
+ activate(mergeOptions({
1523
+ startIndex
1524
+ }, withOptions), withPlugins);
1525
+ eventHandler.emit("reInit");
1526
+ }
1527
+ function deActivate() {
1528
+ engine.dragHandler.destroy();
1529
+ engine.eventStore.clear();
1530
+ engine.translate.clear();
1531
+ engine.slideLooper.clear();
1532
+ engine.resizeHandler.destroy();
1533
+ engine.slidesHandler.destroy();
1534
+ engine.slidesInView.destroy();
1535
+ engine.animation.destroy();
1536
+ pluginsHandler.destroy();
1537
+ mediaHandlers.clear();
1538
+ }
1539
+ function destroy() {
1540
+ if (destroyed) return;
1541
+ destroyed = true;
1542
+ mediaHandlers.clear();
1543
+ deActivate();
1544
+ eventHandler.emit("destroy");
1545
+ eventHandler.clear();
1546
+ }
1547
+ function scrollTo(index, jump, direction) {
1548
+ if (!options.active || destroyed) return;
1549
+ engine.scrollBody.useBaseFriction().useDuration(jump === true ? 0 : options.duration);
1550
+ engine.scrollTo.index(index, direction || 0);
1551
+ }
1552
+ function scrollNext(jump) {
1553
+ const next = engine.index.add(1).get();
1554
+ scrollTo(next, jump, -1);
1555
+ }
1556
+ function scrollPrev(jump) {
1557
+ const prev = engine.index.add(-1).get();
1558
+ scrollTo(prev, jump, 1);
1559
+ }
1560
+ function canScrollNext() {
1561
+ const next = engine.index.add(1).get();
1562
+ return next !== selectedScrollSnap();
1563
+ }
1564
+ function canScrollPrev() {
1565
+ const prev = engine.index.add(-1).get();
1566
+ return prev !== selectedScrollSnap();
1567
+ }
1568
+ function scrollSnapList() {
1569
+ return engine.scrollSnapList;
1570
+ }
1571
+ function scrollProgress() {
1572
+ return engine.scrollProgress.get(engine.offsetLocation.get());
1573
+ }
1574
+ function selectedScrollSnap() {
1575
+ return engine.index.get();
1576
+ }
1577
+ function previousScrollSnap() {
1578
+ return engine.indexPrevious.get();
1579
+ }
1580
+ function slidesInView() {
1581
+ return engine.slidesInView.get();
1582
+ }
1583
+ function slidesNotInView() {
1584
+ return engine.slidesInView.get(false);
1585
+ }
1586
+ function plugins() {
1587
+ return pluginApis;
1588
+ }
1589
+ function internalEngine() {
1590
+ return engine;
1591
+ }
1592
+ function rootNode() {
1593
+ return root;
1594
+ }
1595
+ function containerNode() {
1596
+ return container;
1597
+ }
1598
+ function slideNodes() {
1599
+ return slides;
1600
+ }
1601
+ const self = {
1602
+ canScrollNext,
1603
+ canScrollPrev,
1604
+ containerNode,
1605
+ internalEngine,
1606
+ destroy,
1607
+ off,
1608
+ on,
1609
+ emit,
1610
+ plugins,
1611
+ previousScrollSnap,
1612
+ reInit,
1613
+ rootNode,
1614
+ scrollNext,
1615
+ scrollPrev,
1616
+ scrollProgress,
1617
+ scrollSnapList,
1618
+ scrollTo,
1619
+ selectedScrollSnap,
1620
+ slideNodes,
1621
+ slidesInView,
1622
+ slidesNotInView
1623
+ };
1624
+ activate(userOptions, userPlugins);
1625
+ setTimeout(() => eventHandler.emit("init"), 0);
1626
+ return self;
1627
+ }
1628
+ EmblaCarousel.globalOptions = void 0;
1629
+ exports.default = EmblaCarousel;
1630
+ //# sourceMappingURL=embla-carousel.esm.cjs.map