splide.cjs.js 87 KB

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