splide.cjs.js 94 KB

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