splide.cjs.js 95 KB

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