splide.cjs.js 97 KB

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