splide.esm.js 95 KB

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