splide.esm.js 93 KB

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