splide.cjs.js 94 KB

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