splide.esm.js 93 KB

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