splide.cjs.js 94 KB

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