splide.cjs.js 94 KB

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