splide.esm.js 85 KB

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