splide.esm.js 95 KB

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