splide.cjs.js 97 KB

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