splide.cjs.js 95 KB

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