splide.cjs.js 97 KB

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