splide.cjs.js 96 KB

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