splide.js 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483
  1. /*!
  2. * Splide.js
  3. * Version : 4.1.3
  4. * License : MIT
  5. * Copyright: 2022 Naotoshi Fujita
  6. */
  7. (function (global, factory) {
  8. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  9. typeof define === 'function' && define.amd ? define(factory) :
  10. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Splide = factory());
  11. })(this, (function () { 'use strict';
  12. const MEDIA_PREFERS_REDUCED_MOTION = "(prefers-reduced-motion: reduce)";
  13. const CREATED = 1;
  14. const MOUNTED = 2;
  15. const IDLE = 3;
  16. const MOVING = 4;
  17. const SCROLLING = 5;
  18. const DRAGGING = 6;
  19. const DESTROYED = 7;
  20. const STATES = {
  21. CREATED,
  22. MOUNTED,
  23. IDLE,
  24. MOVING,
  25. SCROLLING,
  26. DRAGGING,
  27. DESTROYED
  28. };
  29. function N(n) {
  30. n.length = 0;
  31. }
  32. function a(n, ...t) {
  33. return n.bind(null, ...t);
  34. }
  35. const dn = setTimeout, an = () => {
  36. };
  37. function P(n) {
  38. return requestAnimationFrame(n);
  39. }
  40. function m(n, t) {
  41. return typeof t === n;
  42. }
  43. function y(n) {
  44. return !S(n) && m("object", n);
  45. }
  46. const g = Array.isArray, ln = a(m, "function"), p = a(m, "string"); a(m, "boolean"); const Z = a(m, "undefined");
  47. function S(n) {
  48. return n === null;
  49. }
  50. function x(n) {
  51. try {
  52. return n instanceof (n.ownerDocument.defaultView || window).HTMLElement;
  53. } catch {
  54. return false;
  55. }
  56. }
  57. function q(n) {
  58. return g(n) ? n : [n];
  59. }
  60. function d(n, t) {
  61. q(n).forEach(t);
  62. }
  63. function G(n, t) {
  64. return n.includes(t);
  65. }
  66. function pn(n, t) {
  67. return n.push(...q(t)), n;
  68. }
  69. const D = Array.prototype;
  70. function F(n, t, e) {
  71. return D.slice.call(n, t, e);
  72. }
  73. function I(n, t, e) {
  74. n && d(p(t) ? t.split(" ") : t, (i) => {
  75. i && n.classList.toggle(i, e);
  76. });
  77. }
  78. function J(n, t) {
  79. I(n, t, true);
  80. }
  81. function Q(n, t) {
  82. d(t, n.appendChild.bind(n));
  83. }
  84. function yn(n, t) {
  85. d(n, (e) => {
  86. const i = (t || e).parentNode;
  87. i && i.insertBefore(e, t);
  88. });
  89. }
  90. function W(n, t) {
  91. return x(n) && n.matches(t);
  92. }
  93. function X(n, t) {
  94. const e = n ? F(n.children) : [];
  95. return t ? e.filter((i) => W(i, t)) : e;
  96. }
  97. function Y(n, t) {
  98. return t ? X(n, t)[0] : n.firstElementChild;
  99. }
  100. function En(n, t) {
  101. return n.closest(t);
  102. }
  103. const v = Object.assign, A = Object.keys;
  104. function L(n, t, e) {
  105. return n && (e ? A(n).reverse() : A(n)).forEach((i) => {
  106. i !== "__proto__" && t(n[i], i);
  107. }), n;
  108. }
  109. function k(n, ...t) {
  110. return t.forEach((e) => {
  111. L(e, (i, r) => {
  112. g(i) ? i = i.slice() : y(i) && (i = k({}, y(n[r]) ? n[r] : {}, i)), n[r] = i;
  113. });
  114. }), n;
  115. }
  116. function gn(n, t) {
  117. return d(t || A(n), (e) => {
  118. delete n[e];
  119. }), n;
  120. }
  121. function U(n, t) {
  122. d(n, (e) => {
  123. d(t, (i) => {
  124. e && e.removeAttribute(i);
  125. });
  126. });
  127. }
  128. function M(n, t, e) {
  129. y(t) ? L(t, (i, r) => {
  130. M(n, r, i);
  131. }) : d(n, (i) => {
  132. S(e) || e === "" ? U(i, t) : i.setAttribute(t, String(e));
  133. });
  134. }
  135. function j(n, t, e) {
  136. const i = document.createElement(n);
  137. return t && (p(t) ? J(i, t) : M(i, t)), e && Q(e, i), i;
  138. }
  139. function nn(n, t, e) {
  140. if (Z(e))
  141. return getComputedStyle(n)[t];
  142. S(e) || (n.style[t] = `${e}`);
  143. }
  144. function An(n, t) {
  145. nn(n, "display", t);
  146. }
  147. function $n(n) {
  148. x(n) && n.focus({ preventScroll: true });
  149. }
  150. function wn(n, t) {
  151. return n.getAttribute(t);
  152. }
  153. function Cn(n, t) {
  154. return !!n && n.classList.contains(t);
  155. }
  156. function tn(n) {
  157. return n.getBoundingClientRect();
  158. }
  159. function en(n) {
  160. d(n, (t) => {
  161. t && t.parentNode && t.parentNode.removeChild(t);
  162. });
  163. }
  164. function qn(n) {
  165. return Y(new DOMParser().parseFromString(n, "text/html").body);
  166. }
  167. function Ln(n, t) {
  168. n.preventDefault(), t && (n.stopPropagation(), n.stopImmediatePropagation());
  169. }
  170. function On(n, t) {
  171. return n && n.querySelector(t);
  172. }
  173. function Tn(n, t) {
  174. return t && n ? F(n.querySelectorAll(t)) : [];
  175. }
  176. function Pn(n, t) {
  177. I(n, t, false);
  178. }
  179. function Bn(n) {
  180. return n.timeStamp;
  181. }
  182. function Nn(n) {
  183. return p(n) ? n : n ? `${n}px` : "";
  184. }
  185. function rn(n) {
  186. let t = "";
  187. return L(n, (e, i) => {
  188. t += e || e === 0 ? ` ${i}${e !== true ? `="${e}"` : ""}` : "";
  189. }), t.trim();
  190. }
  191. function _(...n) {
  192. return n.reduce((t, e) => `${t} ${g(e) ? _(...e) : e || ""}`.trim(), "");
  193. }
  194. function on(n, t) {
  195. return t = g(t) || !y(t) ? { class: _(t) } : t, `<${`${n} ${t ? rn(t) : ""}`.trim()}>`;
  196. }
  197. a(on, "div"); const { min: E, max: $, floor: Dn, ceil: Fn, abs: un, sign: In } = Math;
  198. function Mn(n, t, e) {
  199. return un(n - t) < e;
  200. }
  201. function _n(n, t, e, i) {
  202. const r = E(t, e), o = $(t, e);
  203. return i ? r < n && n < o : r <= n && n <= o;
  204. }
  205. function bn(n, t, e) {
  206. const i = E(t, e), r = $(t, e);
  207. return E($(i, n), r);
  208. }
  209. function Kn(n, t) {
  210. return d(t, (e) => {
  211. n = n.replace("%s", `${e}`);
  212. }), n;
  213. }
  214. function cn(n, t = 2) {
  215. return `${n}`.padStart(t, "0");
  216. }
  217. const B = {};
  218. function zn(n) {
  219. return `${n}${cn(B[n] = (B[n] || 0) + 1)}`;
  220. }
  221. function w(n, t) {
  222. d(n, (e) => {
  223. p(e) && e.split(" ").forEach(t);
  224. });
  225. }
  226. function C(n, t) {
  227. const e = [];
  228. for (let i = n.length - 1; i >= 0; i--)
  229. t(n[i]) && e.push(...n.splice(i, 1));
  230. return e;
  231. }
  232. function b(n) {
  233. const t = n || [], e = n ? {} : void 0;
  234. function i(o, f, u, c) {
  235. w(f, (s) => {
  236. o.addEventListener(s, u, c), t.push([o.removeEventListener.bind(o, s, u, c), e]);
  237. });
  238. }
  239. function r() {
  240. e ? C(t, (o) => o[1] === e).forEach((o) => {
  241. o[0]();
  242. }) : (t.forEach((o) => {
  243. o[0]();
  244. }), N(t));
  245. }
  246. return {
  247. bind: i,
  248. create: a(b, t),
  249. destroy: r
  250. };
  251. }
  252. function H(n) {
  253. const t = n || [], e = n ? {} : void 0;
  254. function i(u, c) {
  255. w(u, (s) => {
  256. t.push([s, c, e]);
  257. });
  258. }
  259. function r(u, c) {
  260. w(u, (s) => {
  261. C(t, (l) => l[0] === s && (!c || l[1] === c) && l[2] === e);
  262. });
  263. }
  264. function o(u, ...c) {
  265. t.slice().forEach((s) => {
  266. s[0] === u && s[1](...c);
  267. });
  268. }
  269. function f() {
  270. e ? C(t, (u) => u[2] === e) : N(t);
  271. }
  272. return {
  273. on: i,
  274. off: r,
  275. emit: o,
  276. create: a(H, t),
  277. destroy: f
  278. };
  279. }
  280. function fn(n = b(), t = H()) {
  281. function e() {
  282. return fn(n.create(), t.create());
  283. }
  284. function i() {
  285. n.destroy(), t.destroy();
  286. }
  287. return v({}, n, t, { create: e, destroy: i });
  288. }
  289. function sn(n, t, e, i) {
  290. const { now: r } = Date;
  291. let o, f = 0, u, c = true, s = 0;
  292. function l() {
  293. if (!c) {
  294. if (f = n ? E((r() - o) / n, 1) : 1, e && e(f), f >= 1 && (t(), o = r(), i && ++s >= i))
  295. return O();
  296. u = P(l);
  297. }
  298. }
  299. function K(h) {
  300. h || T(), o = r() - (h ? f * n : 0), c = false, u = P(l);
  301. }
  302. function O() {
  303. c = true;
  304. }
  305. function z() {
  306. o = r(), f = 0, e && e(f);
  307. }
  308. function T() {
  309. u && cancelAnimationFrame(u), f = 0, u = 0, c = true;
  310. }
  311. function R(h) {
  312. n = h;
  313. }
  314. function V() {
  315. return c;
  316. }
  317. return {
  318. start: K,
  319. rewind: z,
  320. pause: O,
  321. cancel: T,
  322. set: R,
  323. isPaused: V
  324. };
  325. }
  326. function Rn(n) {
  327. let t = n;
  328. function e(r) {
  329. t = r;
  330. }
  331. function i(r) {
  332. return G(q(r), t);
  333. }
  334. return { set: e, is: i };
  335. }
  336. function Vn(n, t) {
  337. const e = sn(t || 0, n, void 0, 1);
  338. return () => {
  339. e.isPaused() && e.start();
  340. };
  341. }
  342. const EVENT_MOUNTED = "mounted";
  343. const EVENT_READY = "ready";
  344. const EVENT_MOVE = "move";
  345. const EVENT_MOVED = "moved";
  346. const EVENT_CLICK = "click";
  347. const EVENT_ACTIVE = "active";
  348. const EVENT_INACTIVE = "inactive";
  349. const EVENT_VISIBLE = "visible";
  350. const EVENT_HIDDEN = "hidden";
  351. const EVENT_REFRESH = "refresh";
  352. const EVENT_UPDATED = "updated";
  353. const EVENT_RESIZE = "resize";
  354. const EVENT_RESIZED = "resized";
  355. const EVENT_DRAG = "drag";
  356. const EVENT_DRAGGING = "dragging";
  357. const EVENT_DRAGGED = "dragged";
  358. const EVENT_SCROLL = "scroll";
  359. const EVENT_SCROLLED = "scrolled";
  360. const EVENT_OVERFLOW = "overflow";
  361. const EVENT_DESTROY = "destroy";
  362. const EVENT_ARROWS_MOUNTED = "arrows:mounted";
  363. const EVENT_ARROWS_UPDATED = "arrows:updated";
  364. const EVENT_PAGINATION_MOUNTED = "pagination:mounted";
  365. const EVENT_PAGINATION_UPDATED = "pagination:updated";
  366. const EVENT_NAVIGATION_MOUNTED = "navigation:mounted";
  367. const EVENT_AUTOPLAY_PLAY = "autoplay:play";
  368. const EVENT_AUTOPLAY_PLAYING = "autoplay:playing";
  369. const EVENT_AUTOPLAY_PAUSE = "autoplay:pause";
  370. const EVENT_LAZYLOAD_LOADED = "lazyload:loaded";
  371. const EVENT_SLIDE_KEYDOWN = "sk";
  372. const EVENT_SHIFTED = "sh";
  373. const EVENT_END_INDEX_CHANGED = "ei";
  374. function Media(Splide2, Components2, options) {
  375. const { state } = Splide2;
  376. const breakpoints = options.breakpoints || {};
  377. const reducedMotion = options.reducedMotion || {};
  378. const binder = b();
  379. const queries = [];
  380. function setup() {
  381. const isMin = options.mediaQuery === "min";
  382. A(breakpoints).sort((n, m) => isMin ? +n - +m : +m - +n).forEach((key) => {
  383. register(breakpoints[key], `(${isMin ? "min" : "max"}-width:${key}px)`);
  384. });
  385. register(reducedMotion, MEDIA_PREFERS_REDUCED_MOTION);
  386. update();
  387. }
  388. function destroy(completely) {
  389. if (completely) {
  390. binder.destroy();
  391. }
  392. }
  393. function register(options2, query) {
  394. const queryList = matchMedia(query);
  395. binder.bind(queryList, "change", update);
  396. queries.push([options2, queryList]);
  397. }
  398. function update() {
  399. const destroyed = state.is(DESTROYED);
  400. const direction = options.direction;
  401. const merged = queries.reduce((merged2, entry) => {
  402. return k(merged2, entry[1].matches ? entry[0] : {});
  403. }, {});
  404. gn(options);
  405. set(merged);
  406. if (options.destroy) {
  407. Splide2.destroy(options.destroy === "completely");
  408. } else if (destroyed) {
  409. destroy(true);
  410. Splide2.mount();
  411. } else {
  412. direction !== options.direction && Splide2.refresh();
  413. }
  414. }
  415. function reduce(enable) {
  416. if (matchMedia(MEDIA_PREFERS_REDUCED_MOTION).matches) {
  417. enable ? k(options, reducedMotion) : gn(options, A(reducedMotion));
  418. }
  419. }
  420. function set(opts, base, notify) {
  421. k(options, opts);
  422. base && k(Object.getPrototypeOf(options), opts);
  423. if (notify || !state.is(CREATED)) {
  424. Splide2.emit(EVENT_UPDATED, options);
  425. }
  426. }
  427. return {
  428. setup,
  429. destroy,
  430. reduce,
  431. set
  432. };
  433. }
  434. const ARROW = "Arrow";
  435. const ARROW_LEFT = `${ARROW}Left`;
  436. const ARROW_RIGHT = `${ARROW}Right`;
  437. const ARROW_UP = `${ARROW}Up`;
  438. const ARROW_DOWN = `${ARROW}Down`;
  439. const RTL = "rtl";
  440. const TTB = "ttb";
  441. const ORIENTATION_MAP = {
  442. width: ["height"],
  443. left: ["top", "right"],
  444. right: ["bottom", "left"],
  445. x: ["y"],
  446. X: ["Y"],
  447. Y: ["X"],
  448. ArrowLeft: [ARROW_UP, ARROW_RIGHT],
  449. ArrowRight: [ARROW_DOWN, ARROW_LEFT]
  450. };
  451. function Direction(Splide2, Components2, options) {
  452. function resolve(prop, axisOnly, direction) {
  453. direction = direction || options.direction;
  454. const index = direction === RTL && !axisOnly ? 1 : direction === TTB ? 0 : -1;
  455. return ORIENTATION_MAP[prop] && ORIENTATION_MAP[prop][index] || prop.replace(/width|left|right/i, (match, offset) => {
  456. const replacement = ORIENTATION_MAP[match.toLowerCase()][index] || match;
  457. return offset > 0 ? replacement.charAt(0).toUpperCase() + replacement.slice(1) : replacement;
  458. });
  459. }
  460. function orient(value) {
  461. return value * (options.direction === RTL ? 1 : -1);
  462. }
  463. return {
  464. resolve,
  465. orient
  466. };
  467. }
  468. const ROLE = "role";
  469. const TAB_INDEX = "tabindex";
  470. const DISABLED = "disabled";
  471. const ARIA_PREFIX = "aria-";
  472. const ARIA_CONTROLS = `${ARIA_PREFIX}controls`;
  473. const ARIA_CURRENT = `${ARIA_PREFIX}current`;
  474. const ARIA_SELECTED = `${ARIA_PREFIX}selected`;
  475. const ARIA_LABEL = `${ARIA_PREFIX}label`;
  476. const ARIA_LABELLEDBY = `${ARIA_PREFIX}labelledby`;
  477. const ARIA_HIDDEN = `${ARIA_PREFIX}hidden`;
  478. const ARIA_ORIENTATION = `${ARIA_PREFIX}orientation`;
  479. const ARIA_ROLEDESCRIPTION = `${ARIA_PREFIX}roledescription`;
  480. const ARIA_LIVE = `${ARIA_PREFIX}live`;
  481. const ARIA_BUSY = `${ARIA_PREFIX}busy`;
  482. const ARIA_ATOMIC = `${ARIA_PREFIX}atomic`;
  483. const ALL_ATTRIBUTES = [
  484. ROLE,
  485. TAB_INDEX,
  486. DISABLED,
  487. ARIA_CONTROLS,
  488. ARIA_CURRENT,
  489. ARIA_LABEL,
  490. ARIA_LABELLEDBY,
  491. ARIA_HIDDEN,
  492. ARIA_ORIENTATION,
  493. ARIA_ROLEDESCRIPTION
  494. ];
  495. const PROJECT_CODE = "splide";
  496. const DATA_ATTRIBUTE = `data-${PROJECT_CODE}`;
  497. const CLASS_PREFIX = `${PROJECT_CODE}__`;
  498. const STATUS_CLASS_PREFIX = "is-";
  499. const CLASS_ROOT = PROJECT_CODE;
  500. const CLASS_TRACK = `${CLASS_PREFIX}track`;
  501. const CLASS_LIST = `${CLASS_PREFIX}list`;
  502. const CLASS_SLIDE = `${CLASS_PREFIX}slide`;
  503. const CLASS_CLONE = `${CLASS_SLIDE}--clone`;
  504. const CLASS_CONTAINER = `${CLASS_SLIDE}__container`;
  505. const CLASS_ARROWS = `${CLASS_PREFIX}arrows`;
  506. const CLASS_ARROW = `${CLASS_PREFIX}arrow`;
  507. const CLASS_ARROW_PREV = `${CLASS_ARROW}--prev`;
  508. const CLASS_ARROW_NEXT = `${CLASS_ARROW}--next`;
  509. const CLASS_PAGINATION = `${CLASS_PREFIX}pagination`;
  510. const CLASS_PAGINATION_PAGE = `${CLASS_PAGINATION}__page`;
  511. const CLASS_PROGRESS = `${CLASS_PREFIX}progress`;
  512. const CLASS_PROGRESS_BAR = `${CLASS_PROGRESS}__bar`;
  513. const CLASS_TOGGLE = `${CLASS_PREFIX}toggle`;
  514. const CLASS_SPINNER = `${CLASS_PREFIX}spinner`;
  515. const CLASS_SR = `${CLASS_PREFIX}sr`;
  516. const CLASS_INITIALIZED = `${STATUS_CLASS_PREFIX}initialized`;
  517. const CLASS_ACTIVE = `${STATUS_CLASS_PREFIX}active`;
  518. const CLASS_PREV = `${STATUS_CLASS_PREFIX}prev`;
  519. const CLASS_NEXT = `${STATUS_CLASS_PREFIX}next`;
  520. const CLASS_VISIBLE = `${STATUS_CLASS_PREFIX}visible`;
  521. const CLASS_LOADING = `${STATUS_CLASS_PREFIX}loading`;
  522. const CLASS_FOCUS_IN = `${STATUS_CLASS_PREFIX}focus-in`;
  523. const CLASS_OVERFLOW = `${STATUS_CLASS_PREFIX}overflow`;
  524. const STATUS_CLASSES = [
  525. CLASS_ACTIVE,
  526. CLASS_VISIBLE,
  527. CLASS_PREV,
  528. CLASS_NEXT,
  529. CLASS_LOADING,
  530. CLASS_FOCUS_IN,
  531. CLASS_OVERFLOW
  532. ];
  533. const CLASSES = {
  534. slide: CLASS_SLIDE,
  535. clone: CLASS_CLONE,
  536. arrows: CLASS_ARROWS,
  537. arrow: CLASS_ARROW,
  538. prev: CLASS_ARROW_PREV,
  539. next: CLASS_ARROW_NEXT,
  540. pagination: CLASS_PAGINATION,
  541. page: CLASS_PAGINATION_PAGE,
  542. spinner: CLASS_SPINNER
  543. };
  544. function assert(condition, message) {
  545. if (!condition) {
  546. throw new Error(`[${PROJECT_CODE}] ${message || ""}`);
  547. }
  548. }
  549. const FRICTION = 5;
  550. const LOG_INTERVAL = 200;
  551. const POINTER_DOWN_EVENTS = "touchstart mousedown";
  552. const POINTER_MOVE_EVENTS = "touchmove mousemove";
  553. const POINTER_UP_EVENTS = "touchend touchcancel mouseup click";
  554. function Elements(Splide2, Components2, options, event) {
  555. const { on, bind } = event;
  556. const { root } = Splide2;
  557. const { i18n } = options;
  558. const elements = {};
  559. const slides = [];
  560. let rootClasses = [];
  561. let trackClasses = [];
  562. let track;
  563. let list;
  564. let isUsingKey;
  565. function setup() {
  566. collect();
  567. init();
  568. update();
  569. }
  570. function mount() {
  571. on(EVENT_REFRESH, destroy);
  572. on(EVENT_REFRESH, setup);
  573. on(EVENT_UPDATED, update);
  574. bind(document, `${POINTER_DOWN_EVENTS} keydown`, (e) => {
  575. isUsingKey = e.type === "keydown";
  576. }, { capture: true });
  577. bind(root, "focusin", () => {
  578. I(root, CLASS_FOCUS_IN, !!isUsingKey);
  579. });
  580. }
  581. function destroy(completely) {
  582. const attrs = ALL_ATTRIBUTES.concat("style");
  583. N(slides);
  584. Pn(root, rootClasses);
  585. Pn(track, trackClasses);
  586. U([track, list], attrs);
  587. U(root, completely ? attrs : ["style", ARIA_ROLEDESCRIPTION]);
  588. }
  589. function update() {
  590. Pn(root, rootClasses);
  591. Pn(track, trackClasses);
  592. rootClasses = getClasses(CLASS_ROOT);
  593. trackClasses = getClasses(CLASS_TRACK);
  594. J(root, rootClasses);
  595. J(track, trackClasses);
  596. M(root, ARIA_LABEL, options.label);
  597. M(root, ARIA_LABELLEDBY, options.labelledby);
  598. }
  599. function collect() {
  600. track = find(CLASS_TRACK);
  601. list = Y(track, `.${CLASS_LIST}`);
  602. assert(track && list, "A track/list element is missing.");
  603. pn(slides, X(list, `.${CLASS_SLIDE}:not(.${CLASS_CLONE})`));
  604. v(elements, {
  605. root,
  606. track,
  607. list,
  608. slides,
  609. arrows: find(CLASS_ARROWS),
  610. pagination: find(CLASS_PAGINATION),
  611. prev: find(CLASS_ARROW_PREV),
  612. next: find(CLASS_ARROW_NEXT),
  613. bar: find(CLASS_PROGRESS_BAR),
  614. toggle: find(CLASS_TOGGLE)
  615. });
  616. }
  617. function init() {
  618. const id = root.id || zn(PROJECT_CODE);
  619. const role = options.role;
  620. root.id = id;
  621. track.id = track.id || `${id}-track`;
  622. list.id = list.id || `${id}-list`;
  623. if (!wn(root, ROLE) && root.tagName !== "SECTION" && role) {
  624. M(root, ROLE, role);
  625. }
  626. M(root, ARIA_ROLEDESCRIPTION, i18n.carousel);
  627. M(list, ROLE, "presentation");
  628. }
  629. function find(className) {
  630. const elm = On(root, `.${className}`);
  631. return elm && En(elm, `.${CLASS_ROOT}`) === root ? elm : void 0;
  632. }
  633. function getClasses(base) {
  634. return [
  635. `${base}--${options.type}`,
  636. `${base}--${options.direction}`,
  637. options.drag && `${base}--draggable`,
  638. options.isNavigation && `${base}--nav`,
  639. base === CLASS_ROOT && CLASS_ACTIVE
  640. ];
  641. }
  642. return v(elements, {
  643. setup,
  644. mount,
  645. destroy
  646. });
  647. }
  648. const SLIDE = "slide";
  649. const LOOP = "loop";
  650. const FADE = "fade";
  651. function Slide$1(Splide2, index, slideIndex, slide) {
  652. const event = Splide2.event.create();
  653. const { on, emit, bind } = event;
  654. const { Components, root, options } = Splide2;
  655. const { isNavigation, updateOnMove, i18n, pagination, slideFocus } = options;
  656. const { Elements } = Components;
  657. const { resolve } = Components.Direction;
  658. const styles = wn(slide, "style");
  659. const label = wn(slide, ARIA_LABEL);
  660. const isClone = slideIndex > -1;
  661. const container = Y(slide, `.${CLASS_CONTAINER}`);
  662. let destroyed;
  663. function mount() {
  664. if (!isClone) {
  665. slide.id = `${root.id}-slide${cn(index + 1)}`;
  666. M(slide, ROLE, pagination ? "tabpanel" : "group");
  667. M(slide, ARIA_ROLEDESCRIPTION, i18n.slide);
  668. M(slide, ARIA_LABEL, label || Kn(i18n.slideLabel, [index + 1, Splide2.length]));
  669. }
  670. listen();
  671. }
  672. function listen() {
  673. bind(slide, "click", a(emit, EVENT_CLICK, self));
  674. bind(slide, "keydown", a(emit, EVENT_SLIDE_KEYDOWN, self));
  675. on([EVENT_MOVED, EVENT_SHIFTED, EVENT_SCROLLED], update);
  676. on(EVENT_NAVIGATION_MOUNTED, initNavigation);
  677. if (updateOnMove) {
  678. on(EVENT_MOVE, onMove);
  679. }
  680. }
  681. function destroy() {
  682. destroyed = true;
  683. event.destroy();
  684. Pn(slide, STATUS_CLASSES);
  685. U(slide, ALL_ATTRIBUTES);
  686. M(slide, "style", styles);
  687. M(slide, ARIA_LABEL, label || "");
  688. }
  689. function initNavigation() {
  690. const controls = Splide2.splides.map((target) => {
  691. const Slide2 = target.splide.Components.Slides.getAt(index);
  692. return Slide2 ? Slide2.slide.id : "";
  693. }).join(" ");
  694. M(slide, ARIA_LABEL, Kn(i18n.slideX, (isClone ? slideIndex : index) + 1));
  695. M(slide, ARIA_CONTROLS, controls);
  696. M(slide, ROLE, slideFocus ? "button" : "");
  697. slideFocus && U(slide, ARIA_ROLEDESCRIPTION);
  698. }
  699. function onMove() {
  700. if (!destroyed) {
  701. update();
  702. }
  703. }
  704. function update() {
  705. if (!destroyed) {
  706. const { index: curr } = Splide2;
  707. updateActivity();
  708. updateVisibility();
  709. I(slide, CLASS_PREV, index === curr - 1);
  710. I(slide, CLASS_NEXT, index === curr + 1);
  711. }
  712. }
  713. function updateActivity() {
  714. const active = isActive();
  715. if (active !== Cn(slide, CLASS_ACTIVE)) {
  716. I(slide, CLASS_ACTIVE, active);
  717. M(slide, ARIA_CURRENT, isNavigation && active || "");
  718. emit(active ? EVENT_ACTIVE : EVENT_INACTIVE, self);
  719. }
  720. }
  721. function updateVisibility() {
  722. const visible = isVisible();
  723. const hidden = !visible && (!isActive() || isClone);
  724. if (!Splide2.state.is([MOVING, SCROLLING])) {
  725. M(slide, ARIA_HIDDEN, hidden || "");
  726. }
  727. M(Tn(slide, options.focusableNodes || ""), TAB_INDEX, hidden ? -1 : "");
  728. if (slideFocus) {
  729. M(slide, TAB_INDEX, hidden ? -1 : 0);
  730. }
  731. if (visible !== Cn(slide, CLASS_VISIBLE)) {
  732. I(slide, CLASS_VISIBLE, visible);
  733. emit(visible ? EVENT_VISIBLE : EVENT_HIDDEN, self);
  734. }
  735. if (!visible && document.activeElement === slide) {
  736. const Slide2 = Components.Slides.getAt(Splide2.index);
  737. Slide2 && $n(Slide2.slide);
  738. }
  739. }
  740. function style(prop, value, useContainer) {
  741. nn(useContainer && container || slide, prop, value);
  742. }
  743. function isActive() {
  744. const { index: curr } = Splide2;
  745. return curr === index || options.cloneStatus && curr === slideIndex;
  746. }
  747. function isVisible() {
  748. if (Splide2.is(FADE)) {
  749. return isActive();
  750. }
  751. const trackRect = tn(Elements.track);
  752. const slideRect = tn(slide);
  753. const left = resolve("left", true);
  754. const right = resolve("right", true);
  755. return Dn(trackRect[left]) <= Fn(slideRect[left]) && Dn(slideRect[right]) <= Fn(trackRect[right]);
  756. }
  757. function isWithin(from, distance) {
  758. let diff = un(from - index);
  759. if (!isClone && (options.rewind || Splide2.is(LOOP))) {
  760. diff = E(diff, Splide2.length - diff);
  761. }
  762. return diff <= distance;
  763. }
  764. function pos() {
  765. const left = resolve("left");
  766. return un(tn(slide)[left] - tn(Elements.list)[left]);
  767. }
  768. function size() {
  769. return tn(slide)[resolve("width")];
  770. }
  771. const self = {
  772. index,
  773. slideIndex,
  774. slide,
  775. container,
  776. isClone,
  777. mount,
  778. destroy,
  779. update,
  780. pos,
  781. size,
  782. style,
  783. isWithin
  784. };
  785. return self;
  786. }
  787. function Slides(Splide2, Components2, options, event) {
  788. const { on, emit, bind } = event;
  789. const { slides, list } = Components2.Elements;
  790. const Slides2 = [];
  791. function mount() {
  792. init();
  793. on(EVENT_REFRESH, destroy);
  794. on(EVENT_REFRESH, init);
  795. }
  796. function init() {
  797. slides.forEach((slide, index) => {
  798. register(slide, index, -1);
  799. });
  800. }
  801. function destroy() {
  802. forEach((Slide2) => {
  803. Slide2.destroy();
  804. });
  805. N(Slides2);
  806. }
  807. function update() {
  808. forEach((Slide2) => {
  809. Slide2.update();
  810. });
  811. }
  812. function register(slide, index, slideIndex) {
  813. const object = Slide$1(Splide2, index, slideIndex, slide);
  814. object.mount();
  815. Slides2.push(object);
  816. Slides2.sort((Slide1, Slide2) => Slide1.index - Slide2.index);
  817. }
  818. function get(excludeClones) {
  819. return excludeClones ? filter((Slide2) => !Slide2.isClone) : Slides2;
  820. }
  821. function getIn(page) {
  822. const { Controller } = Components2;
  823. const index = Controller.toIndex(page);
  824. const max = Controller.hasFocus() ? 1 : options.perPage;
  825. return filter((Slide2) => _n(Slide2.index, index, index + max - 1));
  826. }
  827. function getAt(index) {
  828. return filter(index)[0];
  829. }
  830. function add(items, index) {
  831. d(items, (slide) => {
  832. if (p(slide)) {
  833. slide = qn(slide);
  834. }
  835. if (x(slide)) {
  836. const ref = slides[index];
  837. ref ? yn(slide, ref) : Q(list, slide);
  838. J(slide, options.classes.slide);
  839. observeImages(slide, a(emit, EVENT_RESIZE));
  840. }
  841. });
  842. emit(EVENT_REFRESH);
  843. }
  844. function remove(matcher) {
  845. en(filter(matcher).map((Slide2) => Slide2.slide));
  846. emit(EVENT_REFRESH);
  847. }
  848. function forEach(iteratee, excludeClones) {
  849. get(excludeClones).forEach(iteratee);
  850. }
  851. function filter(matcher) {
  852. return Slides2.filter(
  853. ln(matcher) ? matcher : (Slide2) => p(matcher) ? W(Slide2.slide, matcher) : G(q(matcher), Slide2.index)
  854. );
  855. }
  856. function style(prop, value, useContainer) {
  857. forEach((Slide2) => {
  858. Slide2.style(prop, value, useContainer);
  859. });
  860. }
  861. function observeImages(elm, callback) {
  862. const images = Tn(elm, "img");
  863. let { length } = images;
  864. if (length) {
  865. images.forEach((img) => {
  866. bind(img, "load error", () => {
  867. if (!--length) {
  868. callback();
  869. }
  870. });
  871. });
  872. } else {
  873. callback();
  874. }
  875. }
  876. function getLength(excludeClones) {
  877. return excludeClones ? slides.length : Slides2.length;
  878. }
  879. function isEnough() {
  880. return Slides2.length > options.perPage;
  881. }
  882. return {
  883. mount,
  884. destroy,
  885. update,
  886. register,
  887. get,
  888. getIn,
  889. getAt,
  890. add,
  891. remove,
  892. forEach,
  893. filter,
  894. style,
  895. getLength,
  896. isEnough
  897. };
  898. }
  899. function Layout(Splide2, Components2, options, event) {
  900. const { on, bind, emit } = event;
  901. const { Slides } = Components2;
  902. const { resolve } = Components2.Direction;
  903. const { root, track, list } = Components2.Elements;
  904. const { getAt, style: styleSlides } = Slides;
  905. let vertical;
  906. let rootRect;
  907. let overflow;
  908. function mount() {
  909. init();
  910. bind(window, "resize load", Vn(a(emit, EVENT_RESIZE)));
  911. on([EVENT_UPDATED, EVENT_REFRESH], init);
  912. on(EVENT_RESIZE, resize);
  913. }
  914. function init() {
  915. vertical = options.direction === TTB;
  916. nn(root, "maxWidth", Nn(options.width));
  917. nn(track, resolve("paddingLeft"), cssPadding(false));
  918. nn(track, resolve("paddingRight"), cssPadding(true));
  919. resize(true);
  920. }
  921. function resize(force) {
  922. const newRect = tn(root);
  923. if (force || rootRect.width !== newRect.width || rootRect.height !== newRect.height) {
  924. nn(track, "height", cssTrackHeight());
  925. styleSlides(resolve("marginRight"), Nn(options.gap));
  926. styleSlides("width", cssSlideWidth());
  927. styleSlides("height", cssSlideHeight(), true);
  928. rootRect = newRect;
  929. emit(EVENT_RESIZED);
  930. if (overflow !== (overflow = isOverflow())) {
  931. I(root, CLASS_OVERFLOW, overflow);
  932. emit(EVENT_OVERFLOW, overflow);
  933. }
  934. }
  935. }
  936. function cssPadding(right) {
  937. const { padding } = options;
  938. const prop = resolve(right ? "right" : "left");
  939. return padding && Nn(padding[prop] || (y(padding) ? 0 : padding)) || "0px";
  940. }
  941. function cssTrackHeight() {
  942. let height = "";
  943. if (vertical) {
  944. height = cssHeight();
  945. assert(height, "height or heightRatio is missing.");
  946. height = `calc(${height} - ${cssPadding(false)} - ${cssPadding(true)})`;
  947. }
  948. return height;
  949. }
  950. function cssHeight() {
  951. return Nn(options.height || tn(list).width * options.heightRatio);
  952. }
  953. function cssSlideWidth() {
  954. return options.autoWidth ? null : Nn(options.fixedWidth) || (vertical ? "" : cssSlideSize());
  955. }
  956. function cssSlideHeight() {
  957. return Nn(options.fixedHeight) || (vertical ? options.autoHeight ? null : cssSlideSize() : cssHeight());
  958. }
  959. function cssSlideSize() {
  960. const gap = Nn(options.gap);
  961. return `calc((100%${gap && ` + ${gap}`})/${options.perPage || 1}${gap && ` - ${gap}`})`;
  962. }
  963. function listSize() {
  964. return tn(list)[resolve("width")];
  965. }
  966. function slideSize(index = 0, withoutGap) {
  967. const Slide = getAt(index);
  968. return (Slide ? Slide.size() : 0) + (withoutGap ? 0 : getGap());
  969. }
  970. function totalSize(index, withoutGap) {
  971. const Slide = getAt(index);
  972. return Slide ? Slide.pos() + Slide.size() + (withoutGap ? 0 : getGap()) : 0;
  973. }
  974. function sliderSize(withoutGap) {
  975. return totalSize(Splide2.length - 1) - totalSize(0) + slideSize(0, withoutGap);
  976. }
  977. function getGap() {
  978. const first = getAt(0);
  979. const second = getAt(1);
  980. return first && second ? second.pos() - first.pos() - first.size() : 0;
  981. }
  982. function getPadding(right) {
  983. return parseFloat(nn(
  984. track,
  985. resolve(`padding${right ? "Right" : "Left"}`)
  986. )) || 0;
  987. }
  988. function isOverflow() {
  989. return Splide2.is(FADE) || sliderSize(true) > listSize();
  990. }
  991. return {
  992. mount,
  993. resize,
  994. listSize,
  995. slideSize,
  996. sliderSize,
  997. totalSize,
  998. getPadding,
  999. isOverflow
  1000. };
  1001. }
  1002. const MULTIPLIER = 2;
  1003. function Clones(Splide2, Components2, options, event) {
  1004. const { on } = event;
  1005. const { Elements, Slides } = Components2;
  1006. const { resolve } = Components2.Direction;
  1007. const clones = [];
  1008. let cloneCount;
  1009. function mount() {
  1010. on(EVENT_REFRESH, remount);
  1011. on([EVENT_UPDATED, EVENT_RESIZE], observe);
  1012. if (cloneCount = computeCloneCount()) {
  1013. generate(cloneCount);
  1014. Components2.Layout.resize(true);
  1015. }
  1016. }
  1017. function remount() {
  1018. destroy();
  1019. mount();
  1020. }
  1021. function destroy() {
  1022. en(clones);
  1023. N(clones);
  1024. event.destroy();
  1025. }
  1026. function observe() {
  1027. const count = computeCloneCount();
  1028. if (cloneCount !== count) {
  1029. if (cloneCount < count || !count) {
  1030. event.emit(EVENT_REFRESH);
  1031. }
  1032. }
  1033. }
  1034. function generate(count) {
  1035. const slides = Slides.get().slice();
  1036. const { length } = slides;
  1037. if (length) {
  1038. while (slides.length < count) {
  1039. pn(slides, slides);
  1040. }
  1041. pn(slides.slice(-count), slides.slice(0, count)).forEach((Slide, index) => {
  1042. const isHead = index < count;
  1043. const clone = cloneDeep(Slide.slide, index);
  1044. isHead ? yn(clone, slides[0].slide) : Q(Elements.list, clone);
  1045. pn(clones, clone);
  1046. Slides.register(clone, index - count + (isHead ? 0 : length), Slide.index);
  1047. });
  1048. }
  1049. }
  1050. function cloneDeep(elm, index) {
  1051. const clone = elm.cloneNode(true);
  1052. J(clone, options.classes.clone);
  1053. clone.id = `${Splide2.root.id}-clone${cn(index + 1)}`;
  1054. return clone;
  1055. }
  1056. function computeCloneCount() {
  1057. let { clones: clones2 } = options;
  1058. if (!Splide2.is(LOOP)) {
  1059. clones2 = 0;
  1060. } else if (Z(clones2)) {
  1061. const fixedSize = options[resolve("fixedWidth")] && Components2.Layout.slideSize(0);
  1062. const fixedCount = fixedSize && Fn(tn(Elements.track)[resolve("width")] / fixedSize);
  1063. clones2 = fixedCount || options[resolve("autoWidth")] && Splide2.length || options.perPage * MULTIPLIER;
  1064. }
  1065. return clones2;
  1066. }
  1067. return {
  1068. mount,
  1069. destroy
  1070. };
  1071. }
  1072. function Move(Splide2, Components2, options, event) {
  1073. const { on, emit } = event;
  1074. const { set } = Splide2.state;
  1075. const { Slides } = Components2;
  1076. const { slideSize, getPadding, listSize, sliderSize } = Components2.Layout;
  1077. const { resolve, orient } = Components2.Direction;
  1078. const { list, track } = Components2.Elements;
  1079. let Transition;
  1080. function mount() {
  1081. Transition = Components2.Transition;
  1082. on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition);
  1083. }
  1084. function reposition() {
  1085. if (!Components2.Controller.isBusy()) {
  1086. Components2.Scroll.cancel();
  1087. jump(Splide2.index);
  1088. Components2.Slides.update();
  1089. }
  1090. }
  1091. function move(dest, index, prev, callback) {
  1092. if (dest !== index && canShift(dest > prev)) {
  1093. cancel();
  1094. translate(shift(getPosition(), dest > prev), true);
  1095. }
  1096. set(MOVING);
  1097. emit(EVENT_MOVE, index, prev, dest);
  1098. Transition.start(index, () => {
  1099. set(IDLE);
  1100. emit(EVENT_MOVED, index, prev, dest);
  1101. callback && callback();
  1102. });
  1103. }
  1104. function jump(index) {
  1105. translate(toPosition(index, true));
  1106. }
  1107. function translate(position, preventLoop) {
  1108. if (!Splide2.is(FADE)) {
  1109. const destination = preventLoop ? position : loop(position);
  1110. nn(list, "transform", `translate${resolve("X")}(${destination}px)`);
  1111. position !== destination && emit(EVENT_SHIFTED);
  1112. }
  1113. }
  1114. function loop(position) {
  1115. if (Splide2.is(LOOP)) {
  1116. const index = toIndex(position);
  1117. const exceededMax = index > Components2.Controller.getEnd();
  1118. const exceededMin = index < 0;
  1119. if (exceededMin || exceededMax) {
  1120. position = shift(position, exceededMax);
  1121. }
  1122. }
  1123. return position;
  1124. }
  1125. function shift(position, backwards) {
  1126. const excess = position - getLimit(backwards);
  1127. const size = sliderSize();
  1128. position -= orient(size * (Fn(un(excess) / size) || 1)) * (backwards ? 1 : -1);
  1129. return position;
  1130. }
  1131. function cancel() {
  1132. translate(getPosition(), true);
  1133. Transition.cancel();
  1134. }
  1135. function toIndex(position) {
  1136. const slides = Slides.get();
  1137. let index = 0;
  1138. let minDistance = Infinity;
  1139. for (let i = 0; i < slides.length; i++) {
  1140. const slideIndex = slides[i].index;
  1141. const distance = un(toPosition(slideIndex, true) - position);
  1142. if (distance <= minDistance) {
  1143. minDistance = distance;
  1144. index = slideIndex;
  1145. } else {
  1146. break;
  1147. }
  1148. }
  1149. return index;
  1150. }
  1151. function toPosition(index, trimming) {
  1152. const Slide = Slides.getAt(index);
  1153. const position = Slide ? orient(Slide.pos() - offset(index)) : 0;
  1154. return trimming ? trim(position) : position;
  1155. }
  1156. function getPosition() {
  1157. const left = resolve("left");
  1158. return tn(list)[left] - tn(track)[left] + orient(getPadding(false));
  1159. }
  1160. function trim(position) {
  1161. if (options.trimSpace && Splide2.is(SLIDE)) {
  1162. position = bn(position, 0, orient(sliderSize(true) - listSize()));
  1163. }
  1164. return position;
  1165. }
  1166. function offset(index) {
  1167. const { focus } = options;
  1168. return focus === "center" ? (listSize() - slideSize(index, true)) / 2 : +focus * slideSize(index) || 0;
  1169. }
  1170. function getLimit(max) {
  1171. return toPosition(max ? Components2.Controller.getEnd() : 0, !!options.trimSpace);
  1172. }
  1173. function canShift(backwards) {
  1174. const padding = getPadding(false);
  1175. const shifted = orient(shift(getPosition(), backwards));
  1176. return backwards ? shifted >= padding : shifted <= list[resolve("scrollWidth")] - tn(track)[resolve("width")] + padding;
  1177. }
  1178. function exceededLimit(max, position) {
  1179. position = Z(position) ? getPosition() : position;
  1180. const exceededMin = max !== true && orient(position) < orient(getLimit(false));
  1181. const exceededMax = max !== false && orient(position) > orient(getLimit(true));
  1182. return exceededMin || exceededMax;
  1183. }
  1184. return {
  1185. mount,
  1186. move,
  1187. jump,
  1188. translate,
  1189. shift,
  1190. cancel,
  1191. toIndex,
  1192. toPosition,
  1193. getPosition,
  1194. getLimit,
  1195. exceededLimit,
  1196. reposition
  1197. };
  1198. }
  1199. function Controller(Splide2, Components2, options, event) {
  1200. const { on, emit } = event;
  1201. const { Move } = Components2;
  1202. const { getPosition, getLimit, toPosition } = Move;
  1203. const { isEnough, getLength } = Components2.Slides;
  1204. const { omitEnd } = options;
  1205. const isLoop = Splide2.is(LOOP);
  1206. const isSlide = Splide2.is(SLIDE);
  1207. const getNext = a(getAdjacent, false);
  1208. const getPrev = a(getAdjacent, true);
  1209. let currIndex = options.start || 0;
  1210. let endIndex;
  1211. let prevIndex = currIndex;
  1212. let slideCount;
  1213. let perMove;
  1214. let perPage;
  1215. function mount() {
  1216. init();
  1217. on([EVENT_UPDATED, EVENT_REFRESH, EVENT_END_INDEX_CHANGED], init);
  1218. on(EVENT_RESIZED, onResized);
  1219. }
  1220. function init() {
  1221. slideCount = getLength(true);
  1222. perMove = options.perMove;
  1223. perPage = options.perPage;
  1224. endIndex = getEnd();
  1225. const end = omitEnd ? endIndex : slideCount - 1;
  1226. const index = bn(currIndex, 0, end);
  1227. prevIndex = bn(currIndex, 0, end);
  1228. if (index !== currIndex) {
  1229. currIndex = index;
  1230. Move.reposition();
  1231. }
  1232. }
  1233. function onResized() {
  1234. if (endIndex !== getEnd()) {
  1235. emit(EVENT_END_INDEX_CHANGED);
  1236. }
  1237. }
  1238. function go(control, allowSameIndex, callback) {
  1239. if (!isBusy()) {
  1240. const dest = parse(control);
  1241. const index = loop(dest);
  1242. if (index > -1 && (allowSameIndex || index !== currIndex)) {
  1243. setIndex(index);
  1244. Move.move(dest, index, prevIndex, callback);
  1245. }
  1246. }
  1247. }
  1248. function scroll(destination, duration, snap, callback) {
  1249. Components2.Scroll.scroll(destination, duration, snap, () => {
  1250. const index = loop(Move.toIndex(getPosition()));
  1251. setIndex(omitEnd ? E(index, endIndex) : index);
  1252. callback && callback();
  1253. });
  1254. }
  1255. function parse(control) {
  1256. let index = currIndex;
  1257. if (p(control)) {
  1258. const [, indicator, number] = control.match(/([+\-<>])(\d+)?/) || [];
  1259. if (indicator === "+" || indicator === "-") {
  1260. index = computeDestIndex(currIndex + +`${indicator}${+number || 1}`, currIndex);
  1261. } else if (indicator === ">") {
  1262. index = number ? toIndex(+number) : getNext(true);
  1263. } else if (indicator === "<") {
  1264. index = getPrev(true);
  1265. }
  1266. } else {
  1267. index = isLoop ? control : bn(control, 0, endIndex);
  1268. }
  1269. return index;
  1270. }
  1271. function getAdjacent(prev, destination) {
  1272. const number = perMove || (hasFocus() ? 1 : perPage);
  1273. const dest = computeDestIndex(currIndex + number * (prev ? -1 : 1), currIndex, !(perMove || hasFocus()));
  1274. if (dest === -1 && isSlide) {
  1275. if (!Mn(getPosition(), getLimit(!prev), 1)) {
  1276. return prev ? 0 : endIndex;
  1277. }
  1278. }
  1279. return destination ? dest : loop(dest);
  1280. }
  1281. function computeDestIndex(dest, from, snapPage) {
  1282. if (isEnough() || hasFocus()) {
  1283. const index = computeMovableDestIndex(dest);
  1284. if (index !== dest) {
  1285. from = dest;
  1286. dest = index;
  1287. snapPage = false;
  1288. }
  1289. if (dest < 0 || dest > endIndex) {
  1290. if (!perMove && (_n(0, dest, from, true) || _n(endIndex, from, dest, true))) {
  1291. dest = toIndex(toPage(dest));
  1292. } else {
  1293. if (isLoop) {
  1294. dest = snapPage ? dest < 0 ? -(slideCount % perPage || perPage) : slideCount : dest;
  1295. } else if (options.rewind) {
  1296. dest = dest < 0 ? endIndex : 0;
  1297. } else {
  1298. dest = -1;
  1299. }
  1300. }
  1301. } else {
  1302. if (snapPage && dest !== from) {
  1303. dest = toIndex(toPage(from) + (dest < from ? -1 : 1));
  1304. }
  1305. }
  1306. } else {
  1307. dest = -1;
  1308. }
  1309. return dest;
  1310. }
  1311. function computeMovableDestIndex(dest) {
  1312. if (isSlide && options.trimSpace === "move" && dest !== currIndex) {
  1313. const position = getPosition();
  1314. while (position === toPosition(dest, true) && _n(dest, 0, Splide2.length - 1, !options.rewind)) {
  1315. dest < currIndex ? --dest : ++dest;
  1316. }
  1317. }
  1318. return dest;
  1319. }
  1320. function loop(index) {
  1321. return isLoop ? (index + slideCount) % slideCount || 0 : index;
  1322. }
  1323. function getEnd() {
  1324. let end = slideCount - (hasFocus() || isLoop && perMove ? 1 : perPage);
  1325. while (omitEnd && end-- > 0) {
  1326. if (toPosition(slideCount - 1, true) !== toPosition(end, true)) {
  1327. end++;
  1328. break;
  1329. }
  1330. }
  1331. return bn(end, 0, slideCount - 1);
  1332. }
  1333. function toIndex(page) {
  1334. return bn(hasFocus() ? page : perPage * page, 0, endIndex);
  1335. }
  1336. function toPage(index) {
  1337. return hasFocus() ? E(index, endIndex) : Dn((index >= endIndex ? slideCount - 1 : index) / perPage);
  1338. }
  1339. function toDest(destination) {
  1340. const closest = Move.toIndex(destination);
  1341. return isSlide ? bn(closest, 0, endIndex) : closest;
  1342. }
  1343. function setIndex(index) {
  1344. if (index !== currIndex) {
  1345. prevIndex = currIndex;
  1346. currIndex = index;
  1347. }
  1348. }
  1349. function getIndex(prev) {
  1350. return prev ? prevIndex : currIndex;
  1351. }
  1352. function hasFocus() {
  1353. return !Z(options.focus) || options.isNavigation;
  1354. }
  1355. function isBusy() {
  1356. return Splide2.state.is([MOVING, SCROLLING]) && !!options.waitForTransition;
  1357. }
  1358. return {
  1359. mount,
  1360. go,
  1361. scroll,
  1362. getNext,
  1363. getPrev,
  1364. getAdjacent,
  1365. getEnd,
  1366. setIndex,
  1367. getIndex,
  1368. toIndex,
  1369. toPage,
  1370. toDest,
  1371. hasFocus,
  1372. isBusy
  1373. };
  1374. }
  1375. const XML_NAME_SPACE = "http://www.w3.org/2000/svg";
  1376. const PATH = "m15.5 0.932-4.3 4.38 14.5 14.6-14.5 14.5 4.3 4.4 14.6-14.6 4.4-4.3-4.4-4.4-14.6-14.6z";
  1377. const SIZE = 40;
  1378. function Arrows(Splide2, Components2, options, event) {
  1379. const { on, bind, emit } = event;
  1380. const { classes, i18n } = options;
  1381. const { Elements, Controller } = Components2;
  1382. const { arrows: placeholder, track } = Elements;
  1383. let wrapper = placeholder;
  1384. let prev = Elements.prev;
  1385. let next = Elements.next;
  1386. let created;
  1387. let wrapperClasses;
  1388. const arrows = {};
  1389. function mount() {
  1390. init();
  1391. on(EVENT_UPDATED, remount);
  1392. }
  1393. function remount() {
  1394. destroy();
  1395. mount();
  1396. }
  1397. function init() {
  1398. const enabled = options.arrows;
  1399. if (enabled && !(prev && next)) {
  1400. createArrows();
  1401. }
  1402. if (prev && next) {
  1403. v(arrows, { prev, next });
  1404. An(wrapper, enabled ? "" : "none");
  1405. J(wrapper, wrapperClasses = `${CLASS_ARROWS}--${options.direction}`);
  1406. if (enabled) {
  1407. listen();
  1408. update();
  1409. M([prev, next], ARIA_CONTROLS, track.id);
  1410. emit(EVENT_ARROWS_MOUNTED, prev, next);
  1411. }
  1412. }
  1413. }
  1414. function destroy() {
  1415. event.destroy();
  1416. Pn(wrapper, wrapperClasses);
  1417. if (created) {
  1418. en(placeholder ? [prev, next] : wrapper);
  1419. prev = next = null;
  1420. } else {
  1421. U([prev, next], ALL_ATTRIBUTES);
  1422. }
  1423. }
  1424. function listen() {
  1425. on([EVENT_MOUNTED, EVENT_MOVED, EVENT_REFRESH, EVENT_SCROLLED, EVENT_END_INDEX_CHANGED], update);
  1426. bind(next, "click", a(go, ">"));
  1427. bind(prev, "click", a(go, "<"));
  1428. }
  1429. function go(control) {
  1430. Controller.go(control, true);
  1431. }
  1432. function createArrows() {
  1433. wrapper = placeholder || j("div", classes.arrows);
  1434. prev = createArrow(true);
  1435. next = createArrow(false);
  1436. created = true;
  1437. Q(wrapper, [prev, next]);
  1438. !placeholder && yn(wrapper, track);
  1439. }
  1440. function createArrow(prev2) {
  1441. const arrow = `<button class="${classes.arrow} ${prev2 ? classes.prev : classes.next}" type="button"><svg xmlns="${XML_NAME_SPACE}" viewBox="0 0 ${SIZE} ${SIZE}" width="${SIZE}" height="${SIZE}"><path d="${options.arrowPath || PATH}" />`;
  1442. return qn(arrow);
  1443. }
  1444. function update() {
  1445. if (prev && next) {
  1446. const index = Splide2.index;
  1447. const prevIndex = Controller.getPrev();
  1448. const nextIndex = Controller.getNext();
  1449. const prevLabel = prevIndex > -1 && index < prevIndex ? i18n.last : i18n.prev;
  1450. const nextLabel = nextIndex > -1 && index > nextIndex ? i18n.first : i18n.next;
  1451. prev.disabled = prevIndex < 0;
  1452. next.disabled = nextIndex < 0;
  1453. M(prev, ARIA_LABEL, prevLabel);
  1454. M(next, ARIA_LABEL, nextLabel);
  1455. emit(EVENT_ARROWS_UPDATED, prev, next, prevIndex, nextIndex);
  1456. }
  1457. }
  1458. return {
  1459. arrows,
  1460. mount,
  1461. destroy,
  1462. update
  1463. };
  1464. }
  1465. const INTERVAL_DATA_ATTRIBUTE = `${DATA_ATTRIBUTE}-interval`;
  1466. function Autoplay(Splide2, Components2, options, event) {
  1467. const { on, bind, emit } = event;
  1468. const interval = sn(options.interval, Splide2.go.bind(Splide2, ">"), onAnimationFrame);
  1469. const { isPaused } = interval;
  1470. const { Elements, Elements: { root, toggle } } = Components2;
  1471. const { autoplay } = options;
  1472. let hovered;
  1473. let focused;
  1474. let stopped = autoplay === "pause";
  1475. function mount() {
  1476. if (autoplay) {
  1477. listen();
  1478. toggle && M(toggle, ARIA_CONTROLS, Elements.track.id);
  1479. stopped || play();
  1480. update();
  1481. }
  1482. }
  1483. function listen() {
  1484. if (options.pauseOnHover) {
  1485. bind(root, "mouseenter mouseleave", (e) => {
  1486. hovered = e.type === "mouseenter";
  1487. autoToggle();
  1488. });
  1489. }
  1490. if (options.pauseOnFocus) {
  1491. bind(root, "focusin focusout", (e) => {
  1492. focused = e.type === "focusin";
  1493. autoToggle();
  1494. });
  1495. }
  1496. if (toggle) {
  1497. bind(toggle, "click", () => {
  1498. stopped ? play() : pause(true);
  1499. });
  1500. }
  1501. on([EVENT_MOVE, EVENT_SCROLL, EVENT_REFRESH], interval.rewind);
  1502. on(EVENT_MOVE, onMove);
  1503. }
  1504. function play() {
  1505. if (isPaused() && Components2.Slides.isEnough()) {
  1506. interval.start(!options.resetProgress);
  1507. focused = hovered = stopped = false;
  1508. update();
  1509. emit(EVENT_AUTOPLAY_PLAY);
  1510. }
  1511. }
  1512. function pause(stop = true) {
  1513. stopped = !!stop;
  1514. update();
  1515. if (!isPaused()) {
  1516. interval.pause();
  1517. emit(EVENT_AUTOPLAY_PAUSE);
  1518. }
  1519. }
  1520. function autoToggle() {
  1521. if (!stopped) {
  1522. hovered || focused ? pause(false) : play();
  1523. }
  1524. }
  1525. function update() {
  1526. if (toggle) {
  1527. I(toggle, CLASS_ACTIVE, !stopped);
  1528. M(toggle, ARIA_LABEL, options.i18n[stopped ? "play" : "pause"]);
  1529. }
  1530. }
  1531. function onAnimationFrame(rate) {
  1532. const { bar } = Elements;
  1533. bar && nn(bar, "width", `${rate * 100}%`);
  1534. emit(EVENT_AUTOPLAY_PLAYING, rate);
  1535. }
  1536. function onMove(index) {
  1537. const Slide = Components2.Slides.getAt(index);
  1538. interval.set(Slide && +wn(Slide.slide, INTERVAL_DATA_ATTRIBUTE) || options.interval);
  1539. }
  1540. return {
  1541. mount,
  1542. destroy: interval.cancel,
  1543. play,
  1544. pause,
  1545. isPaused
  1546. };
  1547. }
  1548. function Cover(Splide2, Components2, options, event) {
  1549. const { on } = event;
  1550. function mount() {
  1551. if (options.cover) {
  1552. on(EVENT_LAZYLOAD_LOADED, a(toggle, true));
  1553. on([EVENT_MOUNTED, EVENT_UPDATED, EVENT_REFRESH], a(cover, true));
  1554. }
  1555. }
  1556. function cover(cover2) {
  1557. Components2.Slides.forEach((Slide) => {
  1558. const img = Y(Slide.container || Slide.slide, "img");
  1559. if (img && img.src) {
  1560. toggle(cover2, img, Slide);
  1561. }
  1562. });
  1563. }
  1564. function toggle(cover2, img, Slide) {
  1565. Slide.style("background", cover2 ? `center/cover no-repeat url("${img.src}")` : "", true);
  1566. An(img, cover2 ? "none" : "");
  1567. }
  1568. return {
  1569. mount,
  1570. destroy: a(cover, false)
  1571. };
  1572. }
  1573. const BOUNCE_DIFF_THRESHOLD = 10;
  1574. const BOUNCE_DURATION = 600;
  1575. const FRICTION_FACTOR = 0.6;
  1576. const BASE_VELOCITY = 1.5;
  1577. const MIN_DURATION = 800;
  1578. function Scroll(Splide2, Components2, options, event) {
  1579. const { on, emit } = event;
  1580. const { state: { set } } = Splide2;
  1581. const { Move } = Components2;
  1582. const { getPosition, getLimit, exceededLimit, translate } = Move;
  1583. const isSlide = Splide2.is(SLIDE);
  1584. let interval;
  1585. let callback;
  1586. let friction = 1;
  1587. function mount() {
  1588. on(EVENT_MOVE, clear);
  1589. on([EVENT_UPDATED, EVENT_REFRESH], cancel);
  1590. }
  1591. function scroll(destination, duration, snap, onScrolled, noConstrain) {
  1592. const from = getPosition();
  1593. clear();
  1594. if (snap && (!isSlide || !exceededLimit())) {
  1595. const size = Components2.Layout.sliderSize();
  1596. const offset = In(destination) * size * Dn(un(destination) / size) || 0;
  1597. destination = Move.toPosition(Components2.Controller.toDest(destination % size)) + offset;
  1598. }
  1599. const noDistance = Mn(from, destination, 1);
  1600. friction = 1;
  1601. duration = noDistance ? 0 : duration || $(un(destination - from) / BASE_VELOCITY, MIN_DURATION);
  1602. callback = onScrolled;
  1603. interval = sn(duration, onEnd, a(update, from, destination, noConstrain), 1);
  1604. set(SCROLLING);
  1605. emit(EVENT_SCROLL);
  1606. interval.start();
  1607. }
  1608. function onEnd() {
  1609. set(IDLE);
  1610. callback && callback();
  1611. emit(EVENT_SCROLLED);
  1612. }
  1613. function update(from, to, noConstrain, rate) {
  1614. const position = getPosition();
  1615. const target = from + (to - from) * easing(rate);
  1616. const diff = (target - position) * friction;
  1617. translate(position + diff);
  1618. if (isSlide && !noConstrain && exceededLimit()) {
  1619. friction *= FRICTION_FACTOR;
  1620. if (un(diff) < BOUNCE_DIFF_THRESHOLD) {
  1621. scroll(getLimit(exceededLimit(true)), BOUNCE_DURATION, false, callback, true);
  1622. }
  1623. }
  1624. }
  1625. function clear() {
  1626. if (interval) {
  1627. interval.cancel();
  1628. }
  1629. }
  1630. function cancel() {
  1631. if (interval && !interval.isPaused()) {
  1632. clear();
  1633. onEnd();
  1634. }
  1635. }
  1636. function easing(t) {
  1637. const { easingFunc } = options;
  1638. return easingFunc ? easingFunc(t) : 1 - Math.pow(1 - t, 4);
  1639. }
  1640. return {
  1641. mount,
  1642. destroy: clear,
  1643. scroll,
  1644. cancel
  1645. };
  1646. }
  1647. const SCROLL_LISTENER_OPTIONS = { passive: false, capture: true };
  1648. function Drag(Splide2, Components2, options, event) {
  1649. const { on, emit, bind } = event;
  1650. const binder = event.create();
  1651. const { state } = Splide2;
  1652. const { Move, Scroll, Controller, Elements: { track }, Media: { reduce } } = Components2;
  1653. const { resolve, orient } = Components2.Direction;
  1654. const { getPosition, exceededLimit } = Move;
  1655. let basePosition;
  1656. let baseEvent;
  1657. let prevBaseEvent;
  1658. let isFree;
  1659. let dragging;
  1660. let exceeded = false;
  1661. let clickPrevented;
  1662. let disabled;
  1663. let target;
  1664. function mount() {
  1665. bind(track, POINTER_MOVE_EVENTS, an, SCROLL_LISTENER_OPTIONS);
  1666. bind(track, POINTER_UP_EVENTS, an, SCROLL_LISTENER_OPTIONS);
  1667. bind(track, POINTER_DOWN_EVENTS, onPointerDown, SCROLL_LISTENER_OPTIONS);
  1668. bind(track, "click", onClick, { capture: true });
  1669. bind(track, "dragstart", Ln);
  1670. on([EVENT_MOUNTED, EVENT_UPDATED], init);
  1671. }
  1672. function init() {
  1673. const { drag } = options;
  1674. disable(!drag);
  1675. isFree = drag === "free";
  1676. }
  1677. function onPointerDown(e) {
  1678. clickPrevented = false;
  1679. if (!disabled) {
  1680. const isTouch = isTouchEvent(e);
  1681. if (isDraggable(e.target) && (isTouch || !e.button)) {
  1682. if (!Controller.isBusy()) {
  1683. target = isTouch ? track : window;
  1684. dragging = state.is([MOVING, SCROLLING]);
  1685. prevBaseEvent = null;
  1686. binder.bind(target, POINTER_MOVE_EVENTS, onPointerMove, SCROLL_LISTENER_OPTIONS);
  1687. binder.bind(target, POINTER_UP_EVENTS, onPointerUp, SCROLL_LISTENER_OPTIONS);
  1688. Move.cancel();
  1689. Scroll.cancel();
  1690. save(e);
  1691. } else {
  1692. Ln(e, true);
  1693. }
  1694. }
  1695. }
  1696. }
  1697. function onPointerMove(e) {
  1698. if (!state.is(DRAGGING)) {
  1699. state.set(DRAGGING);
  1700. emit(EVENT_DRAG);
  1701. }
  1702. if (e.cancelable) {
  1703. if (dragging) {
  1704. Move.translate(basePosition + constrain(diffCoord(e)));
  1705. const expired = diffTime(e) > LOG_INTERVAL;
  1706. const hasExceeded = exceeded !== (exceeded = exceededLimit());
  1707. if (expired || hasExceeded) {
  1708. save(e);
  1709. }
  1710. clickPrevented = true;
  1711. emit(EVENT_DRAGGING);
  1712. Ln(e);
  1713. } else if (isSliderDirection(e)) {
  1714. dragging = shouldStart(e);
  1715. Ln(e);
  1716. }
  1717. }
  1718. }
  1719. function onPointerUp(e) {
  1720. if (state.is(DRAGGING)) {
  1721. state.set(IDLE);
  1722. emit(EVENT_DRAGGED);
  1723. }
  1724. if (dragging) {
  1725. move(e);
  1726. Ln(e);
  1727. }
  1728. binder.destroy();
  1729. dragging = false;
  1730. }
  1731. function onClick(e) {
  1732. if (!disabled && clickPrevented) {
  1733. Ln(e, true);
  1734. }
  1735. }
  1736. function save(e) {
  1737. prevBaseEvent = baseEvent;
  1738. baseEvent = e;
  1739. basePosition = getPosition();
  1740. }
  1741. function move(e) {
  1742. const velocity = computeVelocity(e);
  1743. const destination = computeDestination(velocity);
  1744. const rewind = options.rewind && options.rewindByDrag;
  1745. reduce(false);
  1746. if (isFree) {
  1747. Controller.scroll(destination, 0, options.snap);
  1748. } else if (Splide2.is(FADE)) {
  1749. Controller.go(orient(In(velocity)) < 0 ? rewind ? "<" : "-" : rewind ? ">" : "+");
  1750. } else if (Splide2.is(SLIDE) && exceeded && rewind) {
  1751. Controller.go(exceededLimit(true) ? ">" : "<");
  1752. } else {
  1753. Controller.go(Controller.toDest(destination), true);
  1754. }
  1755. reduce(true);
  1756. }
  1757. function shouldStart(e) {
  1758. const { dragMinThreshold: thresholds } = options;
  1759. const isObj = y(thresholds);
  1760. const mouse = isObj && thresholds.mouse || 0;
  1761. const touch = (isObj ? thresholds.touch : +thresholds) || 10;
  1762. return un(diffCoord(e)) > (isTouchEvent(e) ? touch : mouse);
  1763. }
  1764. function isSliderDirection(e) {
  1765. return un(diffCoord(e)) > un(diffCoord(e, true));
  1766. }
  1767. function computeVelocity(e) {
  1768. if (Splide2.is(LOOP) || !exceeded) {
  1769. const time = diffTime(e);
  1770. if (time && time < LOG_INTERVAL) {
  1771. return diffCoord(e) / time;
  1772. }
  1773. }
  1774. return 0;
  1775. }
  1776. function computeDestination(velocity) {
  1777. return getPosition() + In(velocity) * E(
  1778. un(velocity) * (options.flickPower || 600),
  1779. isFree ? Infinity : Components2.Layout.listSize() * (options.flickMaxPages || 1)
  1780. );
  1781. }
  1782. function diffCoord(e, orthogonal) {
  1783. return coordOf(e, orthogonal) - coordOf(getBaseEvent(e), orthogonal);
  1784. }
  1785. function diffTime(e) {
  1786. return Bn(e) - Bn(getBaseEvent(e));
  1787. }
  1788. function getBaseEvent(e) {
  1789. return baseEvent === e && prevBaseEvent || baseEvent;
  1790. }
  1791. function coordOf(e, orthogonal) {
  1792. return (isTouchEvent(e) ? e.changedTouches[0] : e)[`page${resolve(orthogonal ? "Y" : "X")}`];
  1793. }
  1794. function constrain(diff) {
  1795. return diff / (exceeded && Splide2.is(SLIDE) ? FRICTION : 1);
  1796. }
  1797. function isDraggable(target2) {
  1798. const { noDrag } = options;
  1799. return !W(target2, `.${CLASS_PAGINATION_PAGE}, .${CLASS_ARROW}`) && (!noDrag || !W(target2, noDrag));
  1800. }
  1801. function isTouchEvent(e) {
  1802. return typeof TouchEvent !== "undefined" && e instanceof TouchEvent;
  1803. }
  1804. function isDragging() {
  1805. return dragging;
  1806. }
  1807. function disable(value) {
  1808. disabled = value;
  1809. }
  1810. return {
  1811. mount,
  1812. disable,
  1813. isDragging
  1814. };
  1815. }
  1816. const KEYBOARD_EVENT = "keydown";
  1817. function Keyboard(Splide2, Components2, options, event) {
  1818. const { on, bind, destroy } = event;
  1819. const { root } = Splide2;
  1820. const { resolve } = Components2.Direction;
  1821. let target;
  1822. let disabled;
  1823. function mount() {
  1824. init();
  1825. on(EVENT_UPDATED, destroy);
  1826. on(EVENT_UPDATED, init);
  1827. on(EVENT_MOVE, onMove);
  1828. }
  1829. function init() {
  1830. const { keyboard } = options;
  1831. if (keyboard) {
  1832. target = keyboard === "global" ? window : root;
  1833. bind(target, KEYBOARD_EVENT, onKeydown);
  1834. }
  1835. }
  1836. function disable(value) {
  1837. disabled = value;
  1838. }
  1839. function onMove() {
  1840. const _disabled = disabled;
  1841. disabled = true;
  1842. dn(() => {
  1843. disabled = _disabled;
  1844. });
  1845. }
  1846. function onKeydown(e) {
  1847. if (!disabled) {
  1848. if (e.key === resolve(ARROW_LEFT)) {
  1849. Splide2.go("<");
  1850. } else if (e.key === resolve(ARROW_RIGHT)) {
  1851. Splide2.go(">");
  1852. }
  1853. }
  1854. }
  1855. return {
  1856. mount,
  1857. destroy,
  1858. disable
  1859. };
  1860. }
  1861. const SRC_DATA_ATTRIBUTE = `${DATA_ATTRIBUTE}-lazy`;
  1862. const SRCSET_DATA_ATTRIBUTE = `${SRC_DATA_ATTRIBUTE}-srcset`;
  1863. const IMAGE_SELECTOR = `[${SRC_DATA_ATTRIBUTE}], [${SRCSET_DATA_ATTRIBUTE}]`;
  1864. function LazyLoad(Splide2, Components2, options, event) {
  1865. const { on, off, bind, emit } = event;
  1866. const isSequential = options.lazyLoad === "sequential";
  1867. const events = [EVENT_MOVED, EVENT_SCROLLED];
  1868. let entries = [];
  1869. function mount() {
  1870. if (options.lazyLoad) {
  1871. init();
  1872. on(EVENT_REFRESH, init);
  1873. }
  1874. }
  1875. function init() {
  1876. N(entries);
  1877. register();
  1878. if (isSequential) {
  1879. loadNext();
  1880. } else {
  1881. off(events);
  1882. on(events, check);
  1883. check();
  1884. }
  1885. }
  1886. function register() {
  1887. Components2.Slides.forEach((Slide) => {
  1888. Tn(Slide.slide, IMAGE_SELECTOR).forEach((img) => {
  1889. const src = wn(img, SRC_DATA_ATTRIBUTE);
  1890. const srcset = wn(img, SRCSET_DATA_ATTRIBUTE);
  1891. if (src !== img.src || srcset !== img.srcset) {
  1892. const className = options.classes.spinner;
  1893. const parent = img.parentElement;
  1894. const spinner = Y(parent, `.${className}`) || j("span", className, parent);
  1895. entries.push([img, Slide, spinner]);
  1896. img.src || An(img, "none");
  1897. }
  1898. });
  1899. });
  1900. }
  1901. function check() {
  1902. entries = entries.filter((data) => {
  1903. const distance = options.perPage * ((options.preloadPages || 1) + 1) - 1;
  1904. return data[1].isWithin(Splide2.index, distance) ? load(data) : true;
  1905. });
  1906. entries.length || off(events);
  1907. }
  1908. function load(data) {
  1909. const [img] = data;
  1910. J(data[1].slide, CLASS_LOADING);
  1911. bind(img, "load error", a(onLoad, data));
  1912. M(img, "src", wn(img, SRC_DATA_ATTRIBUTE));
  1913. M(img, "srcset", wn(img, SRCSET_DATA_ATTRIBUTE));
  1914. U(img, SRC_DATA_ATTRIBUTE);
  1915. U(img, SRCSET_DATA_ATTRIBUTE);
  1916. }
  1917. function onLoad(data, e) {
  1918. const [img, Slide] = data;
  1919. Pn(Slide.slide, CLASS_LOADING);
  1920. if (e.type !== "error") {
  1921. en(data[2]);
  1922. An(img, "");
  1923. emit(EVENT_LAZYLOAD_LOADED, img, Slide);
  1924. emit(EVENT_RESIZE);
  1925. }
  1926. isSequential && loadNext();
  1927. }
  1928. function loadNext() {
  1929. entries.length && load(entries.shift());
  1930. }
  1931. return {
  1932. mount,
  1933. destroy: a(N, entries),
  1934. check
  1935. };
  1936. }
  1937. function Pagination(Splide2, Components2, options, event) {
  1938. const { on, emit, bind } = event;
  1939. const { Slides, Elements, Controller } = Components2;
  1940. const { hasFocus, getIndex, go } = Controller;
  1941. const { resolve } = Components2.Direction;
  1942. const { pagination: placeholder } = Elements;
  1943. const items = [];
  1944. let list;
  1945. let paginationClasses;
  1946. function mount() {
  1947. destroy();
  1948. on([EVENT_UPDATED, EVENT_REFRESH, EVENT_END_INDEX_CHANGED], mount);
  1949. const enabled = options.pagination;
  1950. placeholder && An(placeholder, enabled ? "" : "none");
  1951. if (enabled) {
  1952. on([EVENT_MOVE, EVENT_SCROLL, EVENT_SCROLLED], update);
  1953. createPagination();
  1954. update();
  1955. emit(EVENT_PAGINATION_MOUNTED, { list, items }, getAt(Splide2.index));
  1956. }
  1957. }
  1958. function destroy() {
  1959. if (list) {
  1960. en(placeholder ? F(list.children) : list);
  1961. Pn(list, paginationClasses);
  1962. N(items);
  1963. list = null;
  1964. }
  1965. event.destroy();
  1966. }
  1967. function createPagination() {
  1968. const { length } = Splide2;
  1969. const { classes, i18n, perPage } = options;
  1970. const max = hasFocus() ? Controller.getEnd() + 1 : Fn(length / perPage);
  1971. list = placeholder || j("ul", classes.pagination, Elements.track.parentElement);
  1972. J(list, paginationClasses = `${CLASS_PAGINATION}--${getDirection()}`);
  1973. M(list, ROLE, "tablist");
  1974. M(list, ARIA_LABEL, i18n.select);
  1975. M(list, ARIA_ORIENTATION, getDirection() === TTB ? "vertical" : "");
  1976. for (let i = 0; i < max; i++) {
  1977. const li = j("li", null, list);
  1978. const button = j("button", { class: classes.page, type: "button" }, li);
  1979. const controls = Slides.getIn(i).map((Slide) => Slide.slide.id);
  1980. const text = !hasFocus() && perPage > 1 ? i18n.pageX : i18n.slideX;
  1981. bind(button, "click", a(onClick, i));
  1982. if (options.paginationKeyboard) {
  1983. bind(button, "keydown", a(onKeydown, i));
  1984. }
  1985. M(li, ROLE, "presentation");
  1986. M(button, ROLE, "tab");
  1987. M(button, ARIA_CONTROLS, controls.join(" "));
  1988. M(button, ARIA_LABEL, Kn(text, i + 1));
  1989. M(button, TAB_INDEX, -1);
  1990. items.push({ li, button, page: i });
  1991. }
  1992. }
  1993. function onClick(page) {
  1994. go(`>${page}`, true);
  1995. }
  1996. function onKeydown(page, e) {
  1997. const { length } = items;
  1998. const { key } = e;
  1999. const dir = getDirection();
  2000. let nextPage = -1;
  2001. if (key === resolve(ARROW_RIGHT, false, dir)) {
  2002. nextPage = ++page % length;
  2003. } else if (key === resolve(ARROW_LEFT, false, dir)) {
  2004. nextPage = (--page + length) % length;
  2005. } else if (key === "Home") {
  2006. nextPage = 0;
  2007. } else if (key === "End") {
  2008. nextPage = length - 1;
  2009. }
  2010. const item = items[nextPage];
  2011. if (item) {
  2012. $n(item.button);
  2013. go(`>${nextPage}`);
  2014. Ln(e, true);
  2015. }
  2016. }
  2017. function getDirection() {
  2018. return options.paginationDirection || options.direction;
  2019. }
  2020. function getAt(index) {
  2021. return items[Controller.toPage(index)];
  2022. }
  2023. function update() {
  2024. const prev = getAt(getIndex(true));
  2025. const curr = getAt(getIndex());
  2026. if (prev) {
  2027. const { button } = prev;
  2028. Pn(button, CLASS_ACTIVE);
  2029. U(button, ARIA_SELECTED);
  2030. M(button, TAB_INDEX, -1);
  2031. }
  2032. if (curr) {
  2033. const { button } = curr;
  2034. J(button, CLASS_ACTIVE);
  2035. M(button, ARIA_SELECTED, true);
  2036. M(button, TAB_INDEX, "");
  2037. }
  2038. emit(EVENT_PAGINATION_UPDATED, { list, items }, prev, curr);
  2039. }
  2040. return {
  2041. items,
  2042. mount,
  2043. destroy,
  2044. getAt,
  2045. update
  2046. };
  2047. }
  2048. const TRIGGER_KEYS = [" ", "Enter"];
  2049. function Sync(Splide2, Components2, options, event) {
  2050. const { isNavigation, slideFocus } = options;
  2051. const events = [];
  2052. function mount() {
  2053. Splide2.splides.forEach((target) => {
  2054. if (!target.isParent) {
  2055. sync(Splide2, target.splide);
  2056. sync(target.splide, Splide2);
  2057. }
  2058. });
  2059. if (isNavigation) {
  2060. navigate();
  2061. }
  2062. }
  2063. function destroy() {
  2064. events.forEach((event2) => {
  2065. event2.destroy();
  2066. });
  2067. N(events);
  2068. }
  2069. function remount() {
  2070. destroy();
  2071. mount();
  2072. }
  2073. function sync(splide, target) {
  2074. const event2 = splide.event.create();
  2075. event2.on(EVENT_MOVE, (index, prev, dest) => {
  2076. target.go(target.is(LOOP) ? dest : index);
  2077. });
  2078. events.push(event2);
  2079. }
  2080. function navigate() {
  2081. const ev = event.create();
  2082. const { on } = ev;
  2083. on(EVENT_CLICK, onClick);
  2084. on(EVENT_SLIDE_KEYDOWN, onKeydown);
  2085. on([EVENT_MOUNTED, EVENT_UPDATED], update);
  2086. events.push(ev);
  2087. ev.emit(EVENT_NAVIGATION_MOUNTED, Splide2.splides);
  2088. }
  2089. function update() {
  2090. M(
  2091. Components2.Elements.list,
  2092. ARIA_ORIENTATION,
  2093. options.direction === TTB ? "vertical" : ""
  2094. );
  2095. }
  2096. function onClick(Slide) {
  2097. Splide2.go(Slide.index);
  2098. }
  2099. function onKeydown(Slide, e) {
  2100. if (G(TRIGGER_KEYS, e.key)) {
  2101. onClick(Slide);
  2102. Ln(e);
  2103. }
  2104. }
  2105. return {
  2106. setup: a(
  2107. Components2.Media.set,
  2108. { slideFocus: Z(slideFocus) ? isNavigation : slideFocus },
  2109. true
  2110. ),
  2111. mount,
  2112. destroy,
  2113. remount
  2114. };
  2115. }
  2116. function Wheel(Splide2, Components2, options, event) {
  2117. let lastTime = 0;
  2118. function mount() {
  2119. if (options.wheel) {
  2120. event.bind(Components2.Elements.track, "wheel", onWheel, SCROLL_LISTENER_OPTIONS);
  2121. }
  2122. }
  2123. function onWheel(e) {
  2124. if (e.cancelable) {
  2125. const { deltaY } = e;
  2126. const backwards = deltaY < 0;
  2127. const timeStamp = Bn(e);
  2128. const min = options.wheelMinThreshold || 0;
  2129. const sleep = options.wheelSleep || 0;
  2130. if (un(deltaY) > min && timeStamp - lastTime > sleep) {
  2131. Splide2.go(backwards ? "<" : ">");
  2132. lastTime = timeStamp;
  2133. }
  2134. shouldPrevent(backwards) && Ln(e);
  2135. }
  2136. }
  2137. function shouldPrevent(backwards) {
  2138. return !options.releaseWheel || Splide2.state.is(MOVING) || Components2.Controller.getAdjacent(backwards) !== -1;
  2139. }
  2140. return {
  2141. mount
  2142. };
  2143. }
  2144. const SR_REMOVAL_DELAY = 90;
  2145. function Live(Splide2, Components2, options, event) {
  2146. const { on } = event;
  2147. const { track } = Components2.Elements;
  2148. const enabled = options.live && !options.isNavigation;
  2149. const sr = j("span", CLASS_SR);
  2150. const interval = sn(SR_REMOVAL_DELAY, a(toggle, false));
  2151. function mount() {
  2152. if (enabled) {
  2153. disable(!Components2.Autoplay.isPaused());
  2154. M(track, ARIA_ATOMIC, true);
  2155. sr.textContent = "\u2026";
  2156. on(EVENT_AUTOPLAY_PLAY, a(disable, true));
  2157. on(EVENT_AUTOPLAY_PAUSE, a(disable, false));
  2158. on([EVENT_MOVED, EVENT_SCROLLED], a(toggle, true));
  2159. }
  2160. }
  2161. function toggle(active) {
  2162. M(track, ARIA_BUSY, active);
  2163. if (active) {
  2164. Q(track, sr);
  2165. interval.start();
  2166. } else {
  2167. en(sr);
  2168. interval.cancel();
  2169. }
  2170. }
  2171. function destroy() {
  2172. U(track, [ARIA_LIVE, ARIA_ATOMIC, ARIA_BUSY]);
  2173. en(sr);
  2174. }
  2175. function disable(disabled) {
  2176. if (enabled) {
  2177. M(track, ARIA_LIVE, disabled ? "off" : "polite");
  2178. }
  2179. }
  2180. return {
  2181. mount,
  2182. disable,
  2183. destroy
  2184. };
  2185. }
  2186. var ComponentConstructors = /*#__PURE__*/Object.freeze({
  2187. __proto__: null,
  2188. Media: Media,
  2189. Direction: Direction,
  2190. Elements: Elements,
  2191. Slides: Slides,
  2192. Layout: Layout,
  2193. Clones: Clones,
  2194. Move: Move,
  2195. Controller: Controller,
  2196. Arrows: Arrows,
  2197. Autoplay: Autoplay,
  2198. Cover: Cover,
  2199. Scroll: Scroll,
  2200. Drag: Drag,
  2201. Keyboard: Keyboard,
  2202. LazyLoad: LazyLoad,
  2203. Pagination: Pagination,
  2204. Sync: Sync,
  2205. Wheel: Wheel,
  2206. Live: Live
  2207. });
  2208. const I18N = {
  2209. prev: "Previous slide",
  2210. next: "Next slide",
  2211. first: "Go to first slide",
  2212. last: "Go to last slide",
  2213. slideX: "Go to slide %s",
  2214. pageX: "Go to page %s",
  2215. play: "Start autoplay",
  2216. pause: "Pause autoplay",
  2217. carousel: "carousel",
  2218. slide: "slide",
  2219. select: "Select a slide to show",
  2220. slideLabel: "%s of %s"
  2221. };
  2222. const DEFAULTS = {
  2223. type: "slide",
  2224. role: "region",
  2225. speed: 400,
  2226. perPage: 1,
  2227. cloneStatus: true,
  2228. arrows: true,
  2229. pagination: true,
  2230. paginationKeyboard: true,
  2231. interval: 5e3,
  2232. pauseOnHover: true,
  2233. pauseOnFocus: true,
  2234. resetProgress: true,
  2235. easing: "cubic-bezier(0.25, 1, 0.5, 1)",
  2236. drag: true,
  2237. direction: "ltr",
  2238. trimSpace: true,
  2239. focusableNodes: "a, button, textarea, input, select, iframe",
  2240. live: true,
  2241. classes: CLASSES,
  2242. i18n: I18N,
  2243. reducedMotion: {
  2244. speed: 0,
  2245. rewindSpeed: 0,
  2246. autoplay: "pause"
  2247. }
  2248. };
  2249. function Fade(Splide2, Components2, options, event) {
  2250. const { Slides } = Components2;
  2251. function mount() {
  2252. event.on([EVENT_MOUNTED, EVENT_REFRESH], init);
  2253. }
  2254. function init() {
  2255. Slides.forEach((Slide) => {
  2256. Slide.style("transform", `translateX(-${100 * Slide.index}%)`);
  2257. });
  2258. }
  2259. function start(index, done) {
  2260. Slides.style("transition", `opacity ${options.speed}ms ${options.easing}`);
  2261. dn(done);
  2262. }
  2263. return {
  2264. mount,
  2265. start,
  2266. cancel: an
  2267. };
  2268. }
  2269. function Slide(Splide2, Components2, options, event) {
  2270. const { Move, Controller, Scroll } = Components2;
  2271. const { list } = Components2.Elements;
  2272. const transition = a(nn, list, "transition");
  2273. let endCallback;
  2274. function mount() {
  2275. event.bind(list, "transitionend", (e) => {
  2276. if (e.target === list && endCallback) {
  2277. cancel();
  2278. endCallback();
  2279. }
  2280. });
  2281. }
  2282. function start(index, done) {
  2283. const destination = Move.toPosition(index, true);
  2284. const position = Move.getPosition();
  2285. const speed = getSpeed(index);
  2286. if (un(destination - position) >= 1 && speed >= 1) {
  2287. if (options.useScroll) {
  2288. Scroll.scroll(destination, speed, false, done);
  2289. } else {
  2290. transition(`transform ${speed}ms ${options.easing}`);
  2291. Move.translate(destination, true);
  2292. endCallback = done;
  2293. }
  2294. } else {
  2295. Move.jump(index);
  2296. done();
  2297. }
  2298. }
  2299. function cancel() {
  2300. transition("");
  2301. Scroll.cancel();
  2302. }
  2303. function getSpeed(index) {
  2304. const { rewindSpeed } = options;
  2305. if (Splide2.is(SLIDE) && rewindSpeed) {
  2306. const prev = Controller.getIndex(true);
  2307. const end = Controller.getEnd();
  2308. if (prev === 0 && index >= end || prev >= end && index === 0) {
  2309. return rewindSpeed;
  2310. }
  2311. }
  2312. return options.speed;
  2313. }
  2314. return {
  2315. mount,
  2316. start,
  2317. cancel
  2318. };
  2319. }
  2320. class Splide {
  2321. static defaults = {};
  2322. static STATES = STATES;
  2323. root;
  2324. event = fn();
  2325. Components = {};
  2326. state = Rn(CREATED);
  2327. splides = [];
  2328. _o = {};
  2329. _C;
  2330. _E = {};
  2331. _T;
  2332. constructor(target, options) {
  2333. const root = p(target) ? On(document, target) : target;
  2334. assert(root, `${root} is invalid.`);
  2335. this.root = root;
  2336. options = k({
  2337. label: wn(root, ARIA_LABEL) || "",
  2338. labelledby: wn(root, ARIA_LABELLEDBY) || ""
  2339. }, DEFAULTS, Splide.defaults, options || {});
  2340. try {
  2341. k(options, JSON.parse(wn(root, DATA_ATTRIBUTE)));
  2342. } catch (e) {
  2343. assert(false, "Invalid JSON");
  2344. }
  2345. this._o = Object.create(k({}, options));
  2346. }
  2347. mount(Extensions, Transition) {
  2348. const { state, Components: Components2 } = this;
  2349. assert(state.is([CREATED, DESTROYED]), "Already mounted!");
  2350. state.set(CREATED);
  2351. this._C = Components2;
  2352. this._T = Transition || this._T || (this.is(FADE) ? Fade : Slide);
  2353. this._E = Extensions || this._E;
  2354. const Constructors = v({}, ComponentConstructors, this._E, { Transition: this._T });
  2355. L(Constructors, (Component, key) => {
  2356. const component = Component(this, Components2, this._o, this.event.create());
  2357. Components2[key] = component;
  2358. component.setup && component.setup();
  2359. });
  2360. L(Components2, (component) => {
  2361. component.mount && component.mount();
  2362. });
  2363. this.emit(EVENT_MOUNTED);
  2364. J(this.root, CLASS_INITIALIZED);
  2365. state.set(IDLE);
  2366. this.emit(EVENT_READY);
  2367. return this;
  2368. }
  2369. sync(splide) {
  2370. this.splides.push({ splide });
  2371. splide.splides.push({ splide: this, isParent: true });
  2372. if (this.state.is(IDLE)) {
  2373. this._C.Sync.remount();
  2374. splide.Components.Sync.remount();
  2375. }
  2376. return this;
  2377. }
  2378. go(control) {
  2379. this._C.Controller.go(control);
  2380. return this;
  2381. }
  2382. on(events, callback) {
  2383. this.event.on(events, callback);
  2384. return this;
  2385. }
  2386. off(events, callback) {
  2387. this.event.off(events, callback);
  2388. return this;
  2389. }
  2390. emit(event) {
  2391. this.event.emit(event, ...F(arguments, 1));
  2392. return this;
  2393. }
  2394. add(slides, index) {
  2395. this._C.Slides.add(slides, index);
  2396. return this;
  2397. }
  2398. remove(matcher) {
  2399. this._C.Slides.remove(matcher);
  2400. return this;
  2401. }
  2402. is(type) {
  2403. return this._o.type === type;
  2404. }
  2405. refresh() {
  2406. this.emit(EVENT_REFRESH);
  2407. return this;
  2408. }
  2409. destroy(completely = true) {
  2410. const { event, state } = this;
  2411. if (state.is(CREATED)) {
  2412. this.on(EVENT_READY, this.destroy.bind(this, completely));
  2413. } else {
  2414. L(this._C, (component) => {
  2415. component.destroy && component.destroy(completely);
  2416. }, true);
  2417. event.emit(EVENT_DESTROY);
  2418. event.destroy();
  2419. completely && N(this.splides);
  2420. state.set(DESTROYED);
  2421. }
  2422. return this;
  2423. }
  2424. get options() {
  2425. return this._o;
  2426. }
  2427. set options(options) {
  2428. this._C.Media.set(options, true, true);
  2429. }
  2430. get length() {
  2431. return this._C.Slides.getLength(true);
  2432. }
  2433. get index() {
  2434. return this._C.Controller.getIndex();
  2435. }
  2436. }
  2437. return Splide;
  2438. }));