splide.cjs.js 97 KB

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