splide.esm.js 95 KB

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