@slidejs/runner-swiper 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,908 @@
1
+ import { Swiper as F } from "swiper";
2
+ import { parseSlideDSL as K, compile as X } from "@slidejs/dsl";
3
+ import { SlideRunner as Y } from "@slidejs/runner";
4
+ function z(s) {
5
+ return s !== null && typeof s == "object" && "constructor" in s && s.constructor === Object;
6
+ }
7
+ function I(s, e) {
8
+ s === void 0 && (s = {}), e === void 0 && (e = {});
9
+ const a = ["__proto__", "constructor", "prototype"];
10
+ Object.keys(e).filter((n) => a.indexOf(n) < 0).forEach((n) => {
11
+ typeof s[n] > "u" ? s[n] = e[n] : z(e[n]) && z(s[n]) && Object.keys(e[n]).length > 0 && I(s[n], e[n]);
12
+ });
13
+ }
14
+ const V = {
15
+ body: {},
16
+ addEventListener() {
17
+ },
18
+ removeEventListener() {
19
+ },
20
+ activeElement: {
21
+ blur() {
22
+ },
23
+ nodeName: ""
24
+ },
25
+ querySelector() {
26
+ return null;
27
+ },
28
+ querySelectorAll() {
29
+ return [];
30
+ },
31
+ getElementById() {
32
+ return null;
33
+ },
34
+ createEvent() {
35
+ return {
36
+ initEvent() {
37
+ }
38
+ };
39
+ },
40
+ createElement() {
41
+ return {
42
+ children: [],
43
+ childNodes: [],
44
+ style: {},
45
+ setAttribute() {
46
+ },
47
+ getElementsByTagName() {
48
+ return [];
49
+ }
50
+ };
51
+ },
52
+ createElementNS() {
53
+ return {};
54
+ },
55
+ importNode() {
56
+ return null;
57
+ },
58
+ location: {
59
+ hash: "",
60
+ host: "",
61
+ hostname: "",
62
+ href: "",
63
+ origin: "",
64
+ pathname: "",
65
+ protocol: "",
66
+ search: ""
67
+ }
68
+ };
69
+ function R() {
70
+ const s = typeof document < "u" ? document : {};
71
+ return I(s, V), s;
72
+ }
73
+ const J = {
74
+ document: V,
75
+ navigator: {
76
+ userAgent: ""
77
+ },
78
+ location: {
79
+ hash: "",
80
+ host: "",
81
+ hostname: "",
82
+ href: "",
83
+ origin: "",
84
+ pathname: "",
85
+ protocol: "",
86
+ search: ""
87
+ },
88
+ history: {
89
+ replaceState() {
90
+ },
91
+ pushState() {
92
+ },
93
+ go() {
94
+ },
95
+ back() {
96
+ }
97
+ },
98
+ CustomEvent: function() {
99
+ return this;
100
+ },
101
+ addEventListener() {
102
+ },
103
+ removeEventListener() {
104
+ },
105
+ getComputedStyle() {
106
+ return {
107
+ getPropertyValue() {
108
+ return "";
109
+ }
110
+ };
111
+ },
112
+ Image() {
113
+ },
114
+ Date() {
115
+ },
116
+ screen: {},
117
+ setTimeout() {
118
+ },
119
+ clearTimeout() {
120
+ },
121
+ matchMedia() {
122
+ return {};
123
+ },
124
+ requestAnimationFrame(s) {
125
+ return typeof setTimeout > "u" ? (s(), null) : setTimeout(s, 0);
126
+ },
127
+ cancelAnimationFrame(s) {
128
+ typeof setTimeout > "u" || clearTimeout(s);
129
+ }
130
+ };
131
+ function O() {
132
+ const s = typeof window < "u" ? window : {};
133
+ return I(s, J), s;
134
+ }
135
+ function Q(s) {
136
+ return s === void 0 && (s = ""), s.trim().split(" ").filter((e) => !!e.trim());
137
+ }
138
+ function Z(s, e) {
139
+ e === void 0 && (e = "");
140
+ const a = O(), n = [...s.children];
141
+ return a.HTMLSlotElement && s instanceof HTMLSlotElement && n.push(...s.assignedElements()), e ? n.filter((o) => o.matches(e)) : n;
142
+ }
143
+ function ee(s, e) {
144
+ e === void 0 && (e = []);
145
+ const a = document.createElement(s);
146
+ return a.classList.add(...Array.isArray(e) ? e : Q(e)), a;
147
+ }
148
+ function te(s) {
149
+ const e = O(), a = R(), n = s.getBoundingClientRect(), o = a.body, r = s.clientTop || o.clientTop || 0, g = s.clientLeft || o.clientLeft || 0, b = s === e ? e.scrollY : s.scrollTop, m = s === e ? e.scrollX : s.scrollLeft;
150
+ return {
151
+ top: n.top + b - r,
152
+ left: n.left + m - g
153
+ };
154
+ }
155
+ function W(s) {
156
+ let e = s, a;
157
+ if (e) {
158
+ for (a = 0; (e = e.previousSibling) !== null; )
159
+ e.nodeType === 1 && (a += 1);
160
+ return a;
161
+ }
162
+ }
163
+ function N(s, e) {
164
+ const a = [];
165
+ let n = s.parentElement;
166
+ for (; n; )
167
+ e ? n.matches(e) && a.push(n) : a.push(n), n = n.parentElement;
168
+ return a;
169
+ }
170
+ function ne(s, e, a) {
171
+ const n = O();
172
+ return s[e === "width" ? "offsetWidth" : "offsetHeight"] + parseFloat(n.getComputedStyle(s, null).getPropertyValue(e === "width" ? "margin-right" : "margin-top")) + parseFloat(n.getComputedStyle(s, null).getPropertyValue(e === "width" ? "margin-left" : "margin-bottom"));
173
+ }
174
+ function L(s) {
175
+ return (Array.isArray(s) ? s : [s]).filter((e) => !!e);
176
+ }
177
+ function q(s, e) {
178
+ e === void 0 && (e = ""), typeof trustedTypes < "u" ? s.innerHTML = trustedTypes.createPolicy("html", {
179
+ createHTML: (a) => a
180
+ }).createHTML(e) : s.innerHTML = e;
181
+ }
182
+ function j(s) {
183
+ let {
184
+ swiper: e,
185
+ extendParams: a,
186
+ on: n,
187
+ emit: o
188
+ } = s;
189
+ const r = R(), g = O();
190
+ e.keyboard = {
191
+ enabled: !1
192
+ }, a({
193
+ keyboard: {
194
+ enabled: !1,
195
+ onlyInViewport: !0,
196
+ pageUpDown: !0
197
+ }
198
+ });
199
+ function b(H) {
200
+ if (!e.enabled) return;
201
+ const {
202
+ rtlTranslate: $
203
+ } = e;
204
+ let h = H;
205
+ h.originalEvent && (h = h.originalEvent);
206
+ const x = h.keyCode || h.charCode, d = e.params.keyboard.pageUpDown, c = d && x === 33, f = d && x === 34, u = x === 37, t = x === 39, i = x === 38, l = x === 40;
207
+ if (!e.allowSlideNext && (e.isHorizontal() && t || e.isVertical() && l || f) || !e.allowSlidePrev && (e.isHorizontal() && u || e.isVertical() && i || c))
208
+ return !1;
209
+ if (!(h.shiftKey || h.altKey || h.ctrlKey || h.metaKey) && !(r.activeElement && (r.activeElement.isContentEditable || r.activeElement.nodeName && (r.activeElement.nodeName.toLowerCase() === "input" || r.activeElement.nodeName.toLowerCase() === "textarea")))) {
210
+ if (e.params.keyboard.onlyInViewport && (c || f || u || t || i || l)) {
211
+ let p = !1;
212
+ if (N(e.el, `.${e.params.slideClass}, swiper-slide`).length > 0 && N(e.el, `.${e.params.slideActiveClass}`).length === 0)
213
+ return;
214
+ const E = e.el, T = E.clientWidth, B = E.clientHeight, w = g.innerWidth, A = g.innerHeight, v = te(E);
215
+ $ && (v.left -= E.scrollLeft);
216
+ const D = [[v.left, v.top], [v.left + T, v.top], [v.left, v.top + B], [v.left + T, v.top + B]];
217
+ for (let C = 0; C < D.length; C += 1) {
218
+ const y = D[C];
219
+ if (y[0] >= 0 && y[0] <= w && y[1] >= 0 && y[1] <= A) {
220
+ if (y[0] === 0 && y[1] === 0) continue;
221
+ p = !0;
222
+ }
223
+ }
224
+ if (!p) return;
225
+ }
226
+ e.isHorizontal() ? ((c || f || u || t) && (h.preventDefault ? h.preventDefault() : h.returnValue = !1), ((f || t) && !$ || (c || u) && $) && e.slideNext(), ((c || u) && !$ || (f || t) && $) && e.slidePrev()) : ((c || f || i || l) && (h.preventDefault ? h.preventDefault() : h.returnValue = !1), (f || l) && e.slideNext(), (c || i) && e.slidePrev()), o("keyPress", x);
227
+ }
228
+ }
229
+ function m() {
230
+ e.keyboard.enabled || (r.addEventListener("keydown", b), e.keyboard.enabled = !0);
231
+ }
232
+ function k() {
233
+ e.keyboard.enabled && (r.removeEventListener("keydown", b), e.keyboard.enabled = !1);
234
+ }
235
+ n("init", () => {
236
+ e.params.keyboard.enabled && m();
237
+ }), n("destroy", () => {
238
+ e.keyboard.enabled && k();
239
+ }), Object.assign(e.keyboard, {
240
+ enable: m,
241
+ disable: k
242
+ });
243
+ }
244
+ function G(s, e, a, n) {
245
+ return s.params.createElements && Object.keys(n).forEach((o) => {
246
+ if (!a[o] && a.auto === !0) {
247
+ let r = Z(s.el, `.${n[o]}`)[0];
248
+ r || (r = ee("div", n[o]), r.className = n[o], s.el.append(r)), a[o] = r, e[o] = r;
249
+ }
250
+ }), a;
251
+ }
252
+ function U(s) {
253
+ let {
254
+ swiper: e,
255
+ extendParams: a,
256
+ on: n,
257
+ emit: o
258
+ } = s;
259
+ a({
260
+ navigation: {
261
+ nextEl: null,
262
+ prevEl: null,
263
+ hideOnClick: !1,
264
+ disabledClass: "swiper-button-disabled",
265
+ hiddenClass: "swiper-button-hidden",
266
+ lockClass: "swiper-button-lock",
267
+ navigationDisabledClass: "swiper-navigation-disabled"
268
+ }
269
+ }), e.navigation = {
270
+ nextEl: null,
271
+ prevEl: null
272
+ };
273
+ function r(d) {
274
+ let c;
275
+ return d && typeof d == "string" && e.isElement && (c = e.el.querySelector(d) || e.hostEl.querySelector(d), c) ? c : (d && (typeof d == "string" && (c = [...document.querySelectorAll(d)]), e.params.uniqueNavElements && typeof d == "string" && c && c.length > 1 && e.el.querySelectorAll(d).length === 1 ? c = e.el.querySelector(d) : c && c.length === 1 && (c = c[0])), d && !c ? d : c);
276
+ }
277
+ function g(d, c) {
278
+ const f = e.params.navigation;
279
+ d = L(d), d.forEach((u) => {
280
+ u && (u.classList[c ? "add" : "remove"](...f.disabledClass.split(" ")), u.tagName === "BUTTON" && (u.disabled = c), e.params.watchOverflow && e.enabled && u.classList[e.isLocked ? "add" : "remove"](f.lockClass));
281
+ });
282
+ }
283
+ function b() {
284
+ const {
285
+ nextEl: d,
286
+ prevEl: c
287
+ } = e.navigation;
288
+ if (e.params.loop) {
289
+ g(c, !1), g(d, !1);
290
+ return;
291
+ }
292
+ g(c, e.isBeginning && !e.params.rewind), g(d, e.isEnd && !e.params.rewind);
293
+ }
294
+ function m(d) {
295
+ d.preventDefault(), !(e.isBeginning && !e.params.loop && !e.params.rewind) && (e.slidePrev(), o("navigationPrev"));
296
+ }
297
+ function k(d) {
298
+ d.preventDefault(), !(e.isEnd && !e.params.loop && !e.params.rewind) && (e.slideNext(), o("navigationNext"));
299
+ }
300
+ function H() {
301
+ const d = e.params.navigation;
302
+ if (e.params.navigation = G(e, e.originalParams.navigation, e.params.navigation, {
303
+ nextEl: "swiper-button-next",
304
+ prevEl: "swiper-button-prev"
305
+ }), !(d.nextEl || d.prevEl)) return;
306
+ let c = r(d.nextEl), f = r(d.prevEl);
307
+ Object.assign(e.navigation, {
308
+ nextEl: c,
309
+ prevEl: f
310
+ }), c = L(c), f = L(f);
311
+ const u = (t, i) => {
312
+ t && t.addEventListener("click", i === "next" ? k : m), !e.enabled && t && t.classList.add(...d.lockClass.split(" "));
313
+ };
314
+ c.forEach((t) => u(t, "next")), f.forEach((t) => u(t, "prev"));
315
+ }
316
+ function $() {
317
+ let {
318
+ nextEl: d,
319
+ prevEl: c
320
+ } = e.navigation;
321
+ d = L(d), c = L(c);
322
+ const f = (u, t) => {
323
+ u.removeEventListener("click", t === "next" ? k : m), u.classList.remove(...e.params.navigation.disabledClass.split(" "));
324
+ };
325
+ d.forEach((u) => f(u, "next")), c.forEach((u) => f(u, "prev"));
326
+ }
327
+ n("init", () => {
328
+ e.params.navigation.enabled === !1 ? x() : (H(), b());
329
+ }), n("toEdge fromEdge lock unlock", () => {
330
+ b();
331
+ }), n("destroy", () => {
332
+ $();
333
+ }), n("enable disable", () => {
334
+ let {
335
+ nextEl: d,
336
+ prevEl: c
337
+ } = e.navigation;
338
+ if (d = L(d), c = L(c), e.enabled) {
339
+ b();
340
+ return;
341
+ }
342
+ [...d, ...c].filter((f) => !!f).forEach((f) => f.classList.add(e.params.navigation.lockClass));
343
+ }), n("click", (d, c) => {
344
+ let {
345
+ nextEl: f,
346
+ prevEl: u
347
+ } = e.navigation;
348
+ f = L(f), u = L(u);
349
+ const t = c.target;
350
+ let i = u.includes(t) || f.includes(t);
351
+ if (e.isElement && !i) {
352
+ const l = c.path || c.composedPath && c.composedPath();
353
+ l && (i = l.find((p) => f.includes(p) || u.includes(p)));
354
+ }
355
+ if (e.params.navigation.hideOnClick && !i) {
356
+ if (e.pagination && e.params.pagination && e.params.pagination.clickable && (e.pagination.el === t || e.pagination.el.contains(t))) return;
357
+ let l;
358
+ f.length ? l = f[0].classList.contains(e.params.navigation.hiddenClass) : u.length && (l = u[0].classList.contains(e.params.navigation.hiddenClass)), o(l === !0 ? "navigationShow" : "navigationHide"), [...f, ...u].filter((p) => !!p).forEach((p) => p.classList.toggle(e.params.navigation.hiddenClass));
359
+ }
360
+ });
361
+ const h = () => {
362
+ e.el.classList.remove(...e.params.navigation.navigationDisabledClass.split(" ")), H(), b();
363
+ }, x = () => {
364
+ e.el.classList.add(...e.params.navigation.navigationDisabledClass.split(" ")), $();
365
+ };
366
+ Object.assign(e.navigation, {
367
+ enable: h,
368
+ disable: x,
369
+ update: b,
370
+ init: H,
371
+ destroy: $
372
+ });
373
+ }
374
+ function P(s) {
375
+ return s === void 0 && (s = ""), `.${s.trim().replace(/([\.:!+\/()[\]])/g, "\\$1").replace(/ /g, ".")}`;
376
+ }
377
+ function _(s) {
378
+ let {
379
+ swiper: e,
380
+ extendParams: a,
381
+ on: n,
382
+ emit: o
383
+ } = s;
384
+ const r = "swiper-pagination";
385
+ a({
386
+ pagination: {
387
+ el: null,
388
+ bulletElement: "span",
389
+ clickable: !1,
390
+ hideOnClick: !1,
391
+ renderBullet: null,
392
+ renderProgressbar: null,
393
+ renderFraction: null,
394
+ renderCustom: null,
395
+ progressbarOpposite: !1,
396
+ type: "bullets",
397
+ // 'bullets' or 'progressbar' or 'fraction' or 'custom'
398
+ dynamicBullets: !1,
399
+ dynamicMainBullets: 1,
400
+ formatFractionCurrent: (t) => t,
401
+ formatFractionTotal: (t) => t,
402
+ bulletClass: `${r}-bullet`,
403
+ bulletActiveClass: `${r}-bullet-active`,
404
+ modifierClass: `${r}-`,
405
+ currentClass: `${r}-current`,
406
+ totalClass: `${r}-total`,
407
+ hiddenClass: `${r}-hidden`,
408
+ progressbarFillClass: `${r}-progressbar-fill`,
409
+ progressbarOppositeClass: `${r}-progressbar-opposite`,
410
+ clickableClass: `${r}-clickable`,
411
+ lockClass: `${r}-lock`,
412
+ horizontalClass: `${r}-horizontal`,
413
+ verticalClass: `${r}-vertical`,
414
+ paginationDisabledClass: `${r}-disabled`
415
+ }
416
+ }), e.pagination = {
417
+ el: null,
418
+ bullets: []
419
+ };
420
+ let g, b = 0;
421
+ function m() {
422
+ return !e.params.pagination.el || !e.pagination.el || Array.isArray(e.pagination.el) && e.pagination.el.length === 0;
423
+ }
424
+ function k(t, i) {
425
+ const {
426
+ bulletActiveClass: l
427
+ } = e.params.pagination;
428
+ t && (t = t[`${i === "prev" ? "previous" : "next"}ElementSibling`], t && (t.classList.add(`${l}-${i}`), t = t[`${i === "prev" ? "previous" : "next"}ElementSibling`], t && t.classList.add(`${l}-${i}-${i}`)));
429
+ }
430
+ function H(t, i, l) {
431
+ if (t = t % l, i = i % l, i === t + 1)
432
+ return "next";
433
+ if (i === t - 1)
434
+ return "previous";
435
+ }
436
+ function $(t) {
437
+ const i = t.target.closest(P(e.params.pagination.bulletClass));
438
+ if (!i)
439
+ return;
440
+ t.preventDefault();
441
+ const l = W(i) * e.params.slidesPerGroup;
442
+ if (e.params.loop) {
443
+ if (e.realIndex === l) return;
444
+ const p = H(e.realIndex, l, e.slides.length);
445
+ p === "next" ? e.slideNext() : p === "previous" ? e.slidePrev() : e.slideToLoop(l);
446
+ } else
447
+ e.slideTo(l);
448
+ }
449
+ function h() {
450
+ const t = e.rtl, i = e.params.pagination;
451
+ if (m()) return;
452
+ let l = e.pagination.el;
453
+ l = L(l);
454
+ let p, E;
455
+ const T = e.virtual && e.params.virtual.enabled ? e.virtual.slides.length : e.slides.length, B = e.params.loop ? Math.ceil(T / e.params.slidesPerGroup) : e.snapGrid.length;
456
+ if (e.params.loop ? (E = e.previousRealIndex || 0, p = e.params.slidesPerGroup > 1 ? Math.floor(e.realIndex / e.params.slidesPerGroup) : e.realIndex) : typeof e.snapIndex < "u" ? (p = e.snapIndex, E = e.previousSnapIndex) : (E = e.previousIndex || 0, p = e.activeIndex || 0), i.type === "bullets" && e.pagination.bullets && e.pagination.bullets.length > 0) {
457
+ const w = e.pagination.bullets;
458
+ let A, v, D;
459
+ if (i.dynamicBullets && (g = ne(w[0], e.isHorizontal() ? "width" : "height"), l.forEach((C) => {
460
+ C.style[e.isHorizontal() ? "width" : "height"] = `${g * (i.dynamicMainBullets + 4)}px`;
461
+ }), i.dynamicMainBullets > 1 && E !== void 0 && (b += p - (E || 0), b > i.dynamicMainBullets - 1 ? b = i.dynamicMainBullets - 1 : b < 0 && (b = 0)), A = Math.max(p - b, 0), v = A + (Math.min(w.length, i.dynamicMainBullets) - 1), D = (v + A) / 2), w.forEach((C) => {
462
+ const y = [...["", "-next", "-next-next", "-prev", "-prev-prev", "-main"].map((S) => `${i.bulletActiveClass}${S}`)].map((S) => typeof S == "string" && S.includes(" ") ? S.split(" ") : S).flat();
463
+ C.classList.remove(...y);
464
+ }), l.length > 1)
465
+ w.forEach((C) => {
466
+ const y = W(C);
467
+ y === p ? C.classList.add(...i.bulletActiveClass.split(" ")) : e.isElement && C.setAttribute("part", "bullet"), i.dynamicBullets && (y >= A && y <= v && C.classList.add(...`${i.bulletActiveClass}-main`.split(" ")), y === A && k(C, "prev"), y === v && k(C, "next"));
468
+ });
469
+ else {
470
+ const C = w[p];
471
+ if (C && C.classList.add(...i.bulletActiveClass.split(" ")), e.isElement && w.forEach((y, S) => {
472
+ y.setAttribute("part", S === p ? "bullet-active" : "bullet");
473
+ }), i.dynamicBullets) {
474
+ const y = w[A], S = w[v];
475
+ for (let M = A; M <= v; M += 1)
476
+ w[M] && w[M].classList.add(...`${i.bulletActiveClass}-main`.split(" "));
477
+ k(y, "prev"), k(S, "next");
478
+ }
479
+ }
480
+ if (i.dynamicBullets) {
481
+ const C = Math.min(w.length, i.dynamicMainBullets + 4), y = (g * C - g) / 2 - D * g, S = t ? "right" : "left";
482
+ w.forEach((M) => {
483
+ M.style[e.isHorizontal() ? S : "top"] = `${y}px`;
484
+ });
485
+ }
486
+ }
487
+ l.forEach((w, A) => {
488
+ if (i.type === "fraction" && (w.querySelectorAll(P(i.currentClass)).forEach((v) => {
489
+ v.textContent = i.formatFractionCurrent(p + 1);
490
+ }), w.querySelectorAll(P(i.totalClass)).forEach((v) => {
491
+ v.textContent = i.formatFractionTotal(B);
492
+ })), i.type === "progressbar") {
493
+ let v;
494
+ i.progressbarOpposite ? v = e.isHorizontal() ? "vertical" : "horizontal" : v = e.isHorizontal() ? "horizontal" : "vertical";
495
+ const D = (p + 1) / B;
496
+ let C = 1, y = 1;
497
+ v === "horizontal" ? C = D : y = D, w.querySelectorAll(P(i.progressbarFillClass)).forEach((S) => {
498
+ S.style.transform = `translate3d(0,0,0) scaleX(${C}) scaleY(${y})`, S.style.transitionDuration = `${e.params.speed}ms`;
499
+ });
500
+ }
501
+ i.type === "custom" && i.renderCustom ? (q(w, i.renderCustom(e, p + 1, B)), A === 0 && o("paginationRender", w)) : (A === 0 && o("paginationRender", w), o("paginationUpdate", w)), e.params.watchOverflow && e.enabled && w.classList[e.isLocked ? "add" : "remove"](i.lockClass);
502
+ });
503
+ }
504
+ function x() {
505
+ const t = e.params.pagination;
506
+ if (m()) return;
507
+ const i = e.virtual && e.params.virtual.enabled ? e.virtual.slides.length : e.grid && e.params.grid.rows > 1 ? e.slides.length / Math.ceil(e.params.grid.rows) : e.slides.length;
508
+ let l = e.pagination.el;
509
+ l = L(l);
510
+ let p = "";
511
+ if (t.type === "bullets") {
512
+ let E = e.params.loop ? Math.ceil(i / e.params.slidesPerGroup) : e.snapGrid.length;
513
+ e.params.freeMode && e.params.freeMode.enabled && E > i && (E = i);
514
+ for (let T = 0; T < E; T += 1)
515
+ t.renderBullet ? p += t.renderBullet.call(e, T, t.bulletClass) : p += `<${t.bulletElement} ${e.isElement ? 'part="bullet"' : ""} class="${t.bulletClass}"></${t.bulletElement}>`;
516
+ }
517
+ t.type === "fraction" && (t.renderFraction ? p = t.renderFraction.call(e, t.currentClass, t.totalClass) : p = `<span class="${t.currentClass}"></span> / <span class="${t.totalClass}"></span>`), t.type === "progressbar" && (t.renderProgressbar ? p = t.renderProgressbar.call(e, t.progressbarFillClass) : p = `<span class="${t.progressbarFillClass}"></span>`), e.pagination.bullets = [], l.forEach((E) => {
518
+ t.type !== "custom" && q(E, p || ""), t.type === "bullets" && e.pagination.bullets.push(...E.querySelectorAll(P(t.bulletClass)));
519
+ }), t.type !== "custom" && o("paginationRender", l[0]);
520
+ }
521
+ function d() {
522
+ e.params.pagination = G(e, e.originalParams.pagination, e.params.pagination, {
523
+ el: "swiper-pagination"
524
+ });
525
+ const t = e.params.pagination;
526
+ if (!t.el) return;
527
+ let i;
528
+ typeof t.el == "string" && e.isElement && (i = e.el.querySelector(t.el)), !i && typeof t.el == "string" && (i = [...document.querySelectorAll(t.el)]), i || (i = t.el), !(!i || i.length === 0) && (e.params.uniqueNavElements && typeof t.el == "string" && Array.isArray(i) && i.length > 1 && (i = [...e.el.querySelectorAll(t.el)], i.length > 1 && (i = i.find((l) => N(l, ".swiper")[0] === e.el))), Array.isArray(i) && i.length === 1 && (i = i[0]), Object.assign(e.pagination, {
529
+ el: i
530
+ }), i = L(i), i.forEach((l) => {
531
+ t.type === "bullets" && t.clickable && l.classList.add(...(t.clickableClass || "").split(" ")), l.classList.add(t.modifierClass + t.type), l.classList.add(e.isHorizontal() ? t.horizontalClass : t.verticalClass), t.type === "bullets" && t.dynamicBullets && (l.classList.add(`${t.modifierClass}${t.type}-dynamic`), b = 0, t.dynamicMainBullets < 1 && (t.dynamicMainBullets = 1)), t.type === "progressbar" && t.progressbarOpposite && l.classList.add(t.progressbarOppositeClass), t.clickable && l.addEventListener("click", $), e.enabled || l.classList.add(t.lockClass);
532
+ }));
533
+ }
534
+ function c() {
535
+ const t = e.params.pagination;
536
+ if (m()) return;
537
+ let i = e.pagination.el;
538
+ i && (i = L(i), i.forEach((l) => {
539
+ l.classList.remove(t.hiddenClass), l.classList.remove(t.modifierClass + t.type), l.classList.remove(e.isHorizontal() ? t.horizontalClass : t.verticalClass), t.clickable && (l.classList.remove(...(t.clickableClass || "").split(" ")), l.removeEventListener("click", $));
540
+ })), e.pagination.bullets && e.pagination.bullets.forEach((l) => l.classList.remove(...t.bulletActiveClass.split(" ")));
541
+ }
542
+ n("changeDirection", () => {
543
+ if (!e.pagination || !e.pagination.el) return;
544
+ const t = e.params.pagination;
545
+ let {
546
+ el: i
547
+ } = e.pagination;
548
+ i = L(i), i.forEach((l) => {
549
+ l.classList.remove(t.horizontalClass, t.verticalClass), l.classList.add(e.isHorizontal() ? t.horizontalClass : t.verticalClass);
550
+ });
551
+ }), n("init", () => {
552
+ e.params.pagination.enabled === !1 ? u() : (d(), x(), h());
553
+ }), n("activeIndexChange", () => {
554
+ typeof e.snapIndex > "u" && h();
555
+ }), n("snapIndexChange", () => {
556
+ h();
557
+ }), n("snapGridLengthChange", () => {
558
+ x(), h();
559
+ }), n("destroy", () => {
560
+ c();
561
+ }), n("enable disable", () => {
562
+ let {
563
+ el: t
564
+ } = e.pagination;
565
+ t && (t = L(t), t.forEach((i) => i.classList[e.enabled ? "remove" : "add"](e.params.pagination.lockClass)));
566
+ }), n("lock unlock", () => {
567
+ h();
568
+ }), n("click", (t, i) => {
569
+ const l = i.target, p = L(e.pagination.el);
570
+ if (e.params.pagination.el && e.params.pagination.hideOnClick && p && p.length > 0 && !l.classList.contains(e.params.pagination.bulletClass)) {
571
+ if (e.navigation && (e.navigation.nextEl && l === e.navigation.nextEl || e.navigation.prevEl && l === e.navigation.prevEl)) return;
572
+ const E = p[0].classList.contains(e.params.pagination.hiddenClass);
573
+ o(E === !0 ? "paginationShow" : "paginationHide"), p.forEach((T) => T.classList.toggle(e.params.pagination.hiddenClass));
574
+ }
575
+ });
576
+ const f = () => {
577
+ e.el.classList.remove(e.params.pagination.paginationDisabledClass);
578
+ let {
579
+ el: t
580
+ } = e.pagination;
581
+ t && (t = L(t), t.forEach((i) => i.classList.remove(e.params.pagination.paginationDisabledClass))), d(), x(), h();
582
+ }, u = () => {
583
+ e.el.classList.add(e.params.pagination.paginationDisabledClass);
584
+ let {
585
+ el: t
586
+ } = e.pagination;
587
+ t && (t = L(t), t.forEach((i) => i.classList.add(e.params.pagination.paginationDisabledClass))), c();
588
+ };
589
+ Object.assign(e.pagination, {
590
+ enable: f,
591
+ disable: u,
592
+ render: x,
593
+ update: h,
594
+ init: d,
595
+ destroy: c
596
+ });
597
+ }
598
+ F.use([U, _, j]);
599
+ class ie {
600
+ constructor() {
601
+ this.name = "swiper", this.eventHandlers = /* @__PURE__ */ new Map();
602
+ }
603
+ /**
604
+ * 初始化 Swiper 适配器
605
+ *
606
+ * @param container - 容器元素
607
+ * @param options - Swiper 选项
608
+ */
609
+ async initialize(e, a) {
610
+ try {
611
+ if (this.createSwiperStructure(e), !this.swiperContainer || !this.swiperWrapper)
612
+ throw new Error("Swiper container not created");
613
+ const n = {
614
+ // 默认配置
615
+ direction: "horizontal",
616
+ loop: !1,
617
+ speed: 300,
618
+ spaceBetween: 30,
619
+ slidesPerView: 1,
620
+ // 注册模块
621
+ modules: [U, _, j],
622
+ // 导航配置
623
+ navigation: {
624
+ nextEl: ".swiper-button-next",
625
+ prevEl: ".swiper-button-prev"
626
+ },
627
+ // 分页配置
628
+ pagination: {
629
+ el: ".swiper-pagination",
630
+ clickable: !0
631
+ },
632
+ // 键盘控制配置
633
+ keyboard: {
634
+ enabled: !0,
635
+ onlyInViewport: !0
636
+ },
637
+ ...a == null ? void 0 : a.swiperConfig
638
+ };
639
+ this.swiper = new F(this.swiperContainer, n), await new Promise((o) => {
640
+ requestAnimationFrame(() => {
641
+ o();
642
+ });
643
+ }), this.setupEventListeners(), this.emit("ready");
644
+ } catch (n) {
645
+ const o = n instanceof Error ? n.message : String(n);
646
+ throw this.emit("error", { message: o }), new Error(`Failed to initialize SwiperAdapter: ${o}`);
647
+ }
648
+ }
649
+ /**
650
+ * 渲染幻灯片
651
+ *
652
+ * @param slides - 幻灯片定义数组
653
+ */
654
+ async render(e) {
655
+ if (!this.swiperWrapper || !this.swiper)
656
+ throw new Error("SwiperAdapter not initialized");
657
+ try {
658
+ this.swiperWrapper.innerHTML = "";
659
+ for (const a of e) {
660
+ const n = await this.renderSlide(a);
661
+ this.swiperWrapper.appendChild(n);
662
+ }
663
+ this.swiper.update(), this.emit("slideRendered", { totalSlides: e.length });
664
+ } catch (a) {
665
+ const n = a instanceof Error ? a.message : String(a);
666
+ throw this.emit("error", { message: n }), new Error(`Failed to render slides: ${n}`);
667
+ }
668
+ }
669
+ /**
670
+ * 销毁适配器
671
+ */
672
+ async destroy() {
673
+ this.swiper && (this.swiper.destroy(!0, !0), this.swiper = void 0), this.swiperContainer && (this.swiperContainer.innerHTML = "", this.swiperContainer = void 0), this.swiperWrapper = void 0, this.eventHandlers.clear();
674
+ }
675
+ /**
676
+ * 导航到指定幻灯片
677
+ *
678
+ * @param index - 幻灯片索引
679
+ */
680
+ navigateTo(e) {
681
+ if (!this.swiper)
682
+ throw new Error("SwiperAdapter not initialized");
683
+ this.swiper.slideTo(e);
684
+ }
685
+ /**
686
+ * 获取当前幻灯片索引
687
+ */
688
+ getCurrentIndex() {
689
+ return this.swiper ? this.swiper.activeIndex : 0;
690
+ }
691
+ /**
692
+ * 获取幻灯片总数
693
+ */
694
+ getTotalSlides() {
695
+ return this.swiper ? this.swiper.slides.length : 0;
696
+ }
697
+ /**
698
+ * 更新指定幻灯片
699
+ *
700
+ * @param index - 幻灯片索引
701
+ * @param slide - 新的幻灯片定义
702
+ */
703
+ async updateSlide(e, a) {
704
+ if (!this.swiperWrapper || !this.swiper)
705
+ throw new Error("SwiperAdapter not initialized");
706
+ try {
707
+ const o = this.swiperWrapper.querySelectorAll(".swiper-slide")[e];
708
+ if (!o)
709
+ throw new Error(`Slide at index ${e} not found`);
710
+ const r = await this.renderSlide(a);
711
+ o.replaceWith(r), this.swiper.update();
712
+ } catch (n) {
713
+ const o = n instanceof Error ? n.message : String(n);
714
+ throw this.emit("error", { message: o }), new Error(`Failed to update slide: ${o}`);
715
+ }
716
+ }
717
+ /**
718
+ * 注册事件监听器
719
+ *
720
+ * @param event - 事件类型
721
+ * @param handler - 事件处理器
722
+ */
723
+ on(e, a) {
724
+ this.eventHandlers.has(e) || this.eventHandlers.set(e, /* @__PURE__ */ new Set()), this.eventHandlers.get(e).add(a);
725
+ }
726
+ /**
727
+ * 移除事件监听器
728
+ *
729
+ * @param event - 事件类型
730
+ * @param handler - 事件处理器
731
+ */
732
+ off(e, a) {
733
+ const n = this.eventHandlers.get(e);
734
+ n && n.delete(a);
735
+ }
736
+ /**
737
+ * 创建 Swiper DOM 结构
738
+ *
739
+ * @param container - 容器元素
740
+ */
741
+ createSwiperStructure(e) {
742
+ const a = document.createElement("div");
743
+ a.className = "swiper";
744
+ const n = document.createElement("div");
745
+ n.className = "swiper-wrapper";
746
+ const o = document.createElement("div");
747
+ o.className = "swiper-button-prev";
748
+ const r = document.createElement("div");
749
+ r.className = "swiper-button-next";
750
+ const g = document.createElement("div");
751
+ g.className = "swiper-pagination", a.appendChild(n), a.appendChild(o), a.appendChild(r), a.appendChild(g), e.appendChild(a), this.swiperContainer = a, this.swiperWrapper = n;
752
+ }
753
+ /**
754
+ * 设置 Swiper 事件监听
755
+ */
756
+ setupEventListeners() {
757
+ this.swiper && this.swiper.on("slideChange", () => {
758
+ const e = this.swiper.activeIndex, a = this.swiper.previousIndex;
759
+ this.emit("slideChanged", {
760
+ index: e,
761
+ previousIndex: a,
762
+ from: a,
763
+ to: e
764
+ });
765
+ });
766
+ }
767
+ /**
768
+ * 渲染单张幻灯片
769
+ *
770
+ * @param slide - 幻灯片定义
771
+ * @returns slide 元素
772
+ */
773
+ async renderSlide(e) {
774
+ var n;
775
+ const a = document.createElement("div");
776
+ if (a.className = "swiper-slide", (n = e.behavior) != null && n.transition) {
777
+ const o = this.mapTransition(e.behavior.transition.type);
778
+ o && a.classList.add(`slide-transition-${o}`);
779
+ }
780
+ if (e.content.type === "dynamic") {
781
+ const o = await this.renderDynamicContent(e.content.component, e.content.props);
782
+ a.appendChild(o);
783
+ } else {
784
+ const o = this.renderTextContent(e.content.lines);
785
+ a.appendChild(o);
786
+ }
787
+ return a;
788
+ }
789
+ /**
790
+ * 渲染动态内容(Web Component)
791
+ *
792
+ * 支持所有 Web Components,包括:
793
+ * - 标准 Web Components(原生 Custom Elements)
794
+ * - wsx 组件(编译为标准 Web Components)
795
+ * - 其他框架的 Web Components(Vue、React、Angular 等)
796
+ *
797
+ * @param component - 组件名称
798
+ * @param props - 组件属性
799
+ * @returns 组件元素
800
+ */
801
+ async renderDynamicContent(e, a) {
802
+ const n = document.createElement(e);
803
+ for (const [o, r] of Object.entries(a))
804
+ typeof r == "string" || typeof r == "number" ? n.setAttribute(o, String(r)) : typeof r == "boolean" ? r && n.setAttribute(o, "") : n[o] = r;
805
+ return n;
806
+ }
807
+ /**
808
+ * 渲染文本内容
809
+ *
810
+ * 支持以下格式:
811
+ * - # 标题 -> h1
812
+ * - ## 标题 -> h2
813
+ * - ### 标题 -> h3
814
+ * - ![alt](url) -> img
815
+ * - - 列表项 -> ul/li
816
+ * - 普通文本 -> p
817
+ *
818
+ * @param lines - 文本行数组
819
+ * @returns 内容容器元素
820
+ */
821
+ renderTextContent(e) {
822
+ const a = document.createElement("div");
823
+ a.className = "slide-content";
824
+ let n = null;
825
+ for (const o of e) {
826
+ const r = o.trim();
827
+ if (!r) {
828
+ n = null;
829
+ continue;
830
+ }
831
+ if (r.startsWith("# ")) {
832
+ n = null;
833
+ const m = document.createElement("h1");
834
+ m.textContent = r.substring(2), a.appendChild(m);
835
+ continue;
836
+ }
837
+ if (r.startsWith("## ")) {
838
+ n = null;
839
+ const m = document.createElement("h2");
840
+ m.textContent = r.substring(3), a.appendChild(m);
841
+ continue;
842
+ }
843
+ if (r.startsWith("### ")) {
844
+ n = null;
845
+ const m = document.createElement("h3");
846
+ m.textContent = r.substring(4), a.appendChild(m);
847
+ continue;
848
+ }
849
+ const g = r.match(/^!\[(.*?)\]\((.*?)\)$/);
850
+ if (g) {
851
+ n = null;
852
+ const m = document.createElement("img");
853
+ m.alt = g[1], m.src = g[2], m.style.maxWidth = "80%", m.style.maxHeight = "500px", a.appendChild(m);
854
+ continue;
855
+ }
856
+ if (r.startsWith("- ")) {
857
+ n || (n = document.createElement("ul"), a.appendChild(n));
858
+ const m = document.createElement("li");
859
+ m.textContent = r.substring(2), n.appendChild(m);
860
+ continue;
861
+ }
862
+ n = null;
863
+ const b = document.createElement("p");
864
+ b.textContent = r, a.appendChild(b);
865
+ }
866
+ return a;
867
+ }
868
+ /**
869
+ * 映射 Slide DSL 过渡效果到 Swiper 过渡效果
870
+ *
871
+ * @param transition - Slide DSL 过渡效果
872
+ * @returns Swiper 过渡效果类名(用于 CSS)
873
+ */
874
+ mapTransition(e) {
875
+ return !e || e === "none" ? null : e;
876
+ }
877
+ /**
878
+ * 触发事件
879
+ *
880
+ * @param event - 事件类型
881
+ * @param data - 事件数据
882
+ */
883
+ emit(e, a) {
884
+ const n = this.eventHandlers.get(e);
885
+ if (n)
886
+ for (const o of n)
887
+ try {
888
+ o(a);
889
+ } catch (r) {
890
+ console.error(`Error in ${e} handler:`, r);
891
+ }
892
+ }
893
+ }
894
+ async function le(s, e, a) {
895
+ const n = await K(s), o = X(n), r = new ie(), g = new Y({
896
+ container: a.container,
897
+ adapter: r,
898
+ adapterOptions: {
899
+ swiperConfig: a.swiperOptions
900
+ }
901
+ });
902
+ return await g.run(o, e), g;
903
+ }
904
+ export {
905
+ ie as SwiperAdapter,
906
+ le as createSlideRunner
907
+ };
908
+ //# sourceMappingURL=index.js.map