splide.cjs.js 93 KB

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