splide.esm.js 94 KB

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