Nessuna descrizione

simplebar.js 151KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453
  1. /**
  2. * SimpleBar.js - v4.0.0-alpha.5
  3. * Scrollbars, simpler.
  4. * https://grsmto.github.io/simplebar/
  5. *
  6. * Made by Adrien Denat from a fork by Jonathan Nicol
  7. * Under MIT License
  8. */
  9. (function (global, factory) {
  10. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  11. typeof define === 'function' && define.amd ? define(factory) :
  12. (global = global || self, global.SimpleBar = factory());
  13. }(this, function () { 'use strict';
  14. var aFunction = function (it) {
  15. if (typeof it != 'function') {
  16. throw TypeError(String(it) + ' is not a function');
  17. } return it;
  18. };
  19. // optional / simple context binding
  20. var bindContext = function (fn, that, length) {
  21. aFunction(fn);
  22. if (that === undefined) return fn;
  23. switch (length) {
  24. case 0: return function () {
  25. return fn.call(that);
  26. };
  27. case 1: return function (a) {
  28. return fn.call(that, a);
  29. };
  30. case 2: return function (a, b) {
  31. return fn.call(that, a, b);
  32. };
  33. case 3: return function (a, b, c) {
  34. return fn.call(that, a, b, c);
  35. };
  36. }
  37. return function (/* ...args */) {
  38. return fn.apply(that, arguments);
  39. };
  40. };
  41. var fails = function (exec) {
  42. try {
  43. return !!exec();
  44. } catch (error) {
  45. return true;
  46. }
  47. };
  48. var toString = {}.toString;
  49. var classofRaw = function (it) {
  50. return toString.call(it).slice(8, -1);
  51. };
  52. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  53. var split = ''.split;
  54. var indexedObject = fails(function () {
  55. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  56. // eslint-disable-next-line no-prototype-builtins
  57. return !Object('z').propertyIsEnumerable(0);
  58. }) ? function (it) {
  59. return classofRaw(it) == 'String' ? split.call(it, '') : Object(it);
  60. } : Object;
  61. // `RequireObjectCoercible` abstract operation
  62. // https://tc39.github.io/ecma262/#sec-requireobjectcoercible
  63. var requireObjectCoercible = function (it) {
  64. if (it == undefined) throw TypeError("Can't call method on " + it);
  65. return it;
  66. };
  67. // `ToObject` abstract operation
  68. // https://tc39.github.io/ecma262/#sec-toobject
  69. var toObject = function (argument) {
  70. return Object(requireObjectCoercible(argument));
  71. };
  72. var ceil = Math.ceil;
  73. var floor = Math.floor;
  74. // `ToInteger` abstract operation
  75. // https://tc39.github.io/ecma262/#sec-tointeger
  76. var toInteger = function (argument) {
  77. return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
  78. };
  79. var min = Math.min;
  80. // `ToLength` abstract operation
  81. // https://tc39.github.io/ecma262/#sec-tolength
  82. var toLength = function (argument) {
  83. return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
  84. };
  85. var isObject = function (it) {
  86. return typeof it === 'object' ? it !== null : typeof it === 'function';
  87. };
  88. // `IsArray` abstract operation
  89. // https://tc39.github.io/ecma262/#sec-isarray
  90. var isArray = Array.isArray || function isArray(arg) {
  91. return classofRaw(arg) == 'Array';
  92. };
  93. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  94. function createCommonjsModule(fn, module) {
  95. return module = { exports: {} }, fn(module, module.exports), module.exports;
  96. }
  97. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  98. var global$1 = typeof window == 'object' && window && window.Math == Math ? window
  99. : typeof self == 'object' && self && self.Math == Math ? self
  100. // eslint-disable-next-line no-new-func
  101. : Function('return this')();
  102. // Thank's IE8 for his funny defineProperty
  103. var descriptors = !fails(function () {
  104. return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
  105. });
  106. var document$1 = global$1.document;
  107. // typeof document.createElement is 'object' in old IE
  108. var exist = isObject(document$1) && isObject(document$1.createElement);
  109. var documentCreateElement = function (it) {
  110. return exist ? document$1.createElement(it) : {};
  111. };
  112. // Thank's IE8 for his funny defineProperty
  113. var ie8DomDefine = !descriptors && !fails(function () {
  114. return Object.defineProperty(documentCreateElement('div'), 'a', {
  115. get: function () { return 7; }
  116. }).a != 7;
  117. });
  118. var anObject = function (it) {
  119. if (!isObject(it)) {
  120. throw TypeError(String(it) + ' is not an object');
  121. } return it;
  122. };
  123. // 7.1.1 ToPrimitive(input [, PreferredType])
  124. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  125. // and the second argument - flag - preferred type is a string
  126. var toPrimitive = function (it, S) {
  127. if (!isObject(it)) return it;
  128. var fn, val;
  129. if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  130. if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
  131. if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  132. throw TypeError("Can't convert object to primitive value");
  133. };
  134. var nativeDefineProperty = Object.defineProperty;
  135. var f = descriptors ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
  136. anObject(O);
  137. P = toPrimitive(P, true);
  138. anObject(Attributes);
  139. if (ie8DomDefine) try {
  140. return nativeDefineProperty(O, P, Attributes);
  141. } catch (error) { /* empty */ }
  142. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
  143. if ('value' in Attributes) O[P] = Attributes.value;
  144. return O;
  145. };
  146. var objectDefineProperty = {
  147. f: f
  148. };
  149. var createPropertyDescriptor = function (bitmap, value) {
  150. return {
  151. enumerable: !(bitmap & 1),
  152. configurable: !(bitmap & 2),
  153. writable: !(bitmap & 4),
  154. value: value
  155. };
  156. };
  157. var hide = descriptors ? function (object, key, value) {
  158. return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value));
  159. } : function (object, key, value) {
  160. object[key] = value;
  161. return object;
  162. };
  163. var setGlobal = function (key, value) {
  164. try {
  165. hide(global$1, key, value);
  166. } catch (error) {
  167. global$1[key] = value;
  168. } return value;
  169. };
  170. var shared = createCommonjsModule(function (module) {
  171. var SHARED = '__core-js_shared__';
  172. var store = global$1[SHARED] || setGlobal(SHARED, {});
  173. (module.exports = function (key, value) {
  174. return store[key] || (store[key] = value !== undefined ? value : {});
  175. })('versions', []).push({
  176. version: '3.0.1',
  177. mode: 'global',
  178. copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
  179. });
  180. });
  181. var id = 0;
  182. var postfix = Math.random();
  183. var uid = function (key) {
  184. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + postfix).toString(36));
  185. };
  186. // Chrome 38 Symbol has incorrect toString conversion
  187. var nativeSymbol = !fails(function () {
  188. // eslint-disable-next-line no-undef
  189. return !String(Symbol());
  190. });
  191. var store = shared('wks');
  192. var Symbol$1 = global$1.Symbol;
  193. var wellKnownSymbol = function (name) {
  194. return store[name] || (store[name] = nativeSymbol && Symbol$1[name]
  195. || (nativeSymbol ? Symbol$1 : uid)('Symbol.' + name));
  196. };
  197. var SPECIES = wellKnownSymbol('species');
  198. // `ArraySpeciesCreate` abstract operation
  199. // https://tc39.github.io/ecma262/#sec-arrayspeciescreate
  200. var arraySpeciesCreate = function (originalArray, length) {
  201. var C;
  202. if (isArray(originalArray)) {
  203. C = originalArray.constructor;
  204. // cross-realm fallback
  205. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  206. else if (isObject(C)) {
  207. C = C[SPECIES];
  208. if (C === null) C = undefined;
  209. }
  210. } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
  211. };
  212. // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex }` methods implementation
  213. // 0 -> Array#forEach
  214. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  215. // 1 -> Array#map
  216. // https://tc39.github.io/ecma262/#sec-array.prototype.map
  217. // 2 -> Array#filter
  218. // https://tc39.github.io/ecma262/#sec-array.prototype.filter
  219. // 3 -> Array#some
  220. // https://tc39.github.io/ecma262/#sec-array.prototype.some
  221. // 4 -> Array#every
  222. // https://tc39.github.io/ecma262/#sec-array.prototype.every
  223. // 5 -> Array#find
  224. // https://tc39.github.io/ecma262/#sec-array.prototype.find
  225. // 6 -> Array#findIndex
  226. // https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
  227. var arrayMethods = function (TYPE, specificCreate) {
  228. var IS_MAP = TYPE == 1;
  229. var IS_FILTER = TYPE == 2;
  230. var IS_SOME = TYPE == 3;
  231. var IS_EVERY = TYPE == 4;
  232. var IS_FIND_INDEX = TYPE == 6;
  233. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  234. var create = specificCreate || arraySpeciesCreate;
  235. return function ($this, callbackfn, that) {
  236. var O = toObject($this);
  237. var self = indexedObject(O);
  238. var boundFunction = bindContext(callbackfn, that, 3);
  239. var length = toLength(self.length);
  240. var index = 0;
  241. var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  242. var value, result;
  243. for (;length > index; index++) if (NO_HOLES || index in self) {
  244. value = self[index];
  245. result = boundFunction(value, index, O);
  246. if (TYPE) {
  247. if (IS_MAP) target[index] = result; // map
  248. else if (result) switch (TYPE) {
  249. case 3: return true; // some
  250. case 5: return value; // find
  251. case 6: return index; // findIndex
  252. case 2: target.push(value); // filter
  253. } else if (IS_EVERY) return false; // every
  254. }
  255. }
  256. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
  257. };
  258. };
  259. var SPECIES$1 = wellKnownSymbol('species');
  260. var arrayMethodHasSpeciesSupport = function (METHOD_NAME) {
  261. return !fails(function () {
  262. var array = [];
  263. var constructor = array.constructor = {};
  264. constructor[SPECIES$1] = function () {
  265. return { foo: 1 };
  266. };
  267. return array[METHOD_NAME](Boolean).foo !== 1;
  268. });
  269. };
  270. var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
  271. var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  272. // Nashorn ~ JDK8 bug
  273. var NASHORN_BUG = nativeGetOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);
  274. var f$1 = NASHORN_BUG ? function propertyIsEnumerable(V) {
  275. var descriptor = nativeGetOwnPropertyDescriptor(this, V);
  276. return !!descriptor && descriptor.enumerable;
  277. } : nativePropertyIsEnumerable;
  278. var objectPropertyIsEnumerable = {
  279. f: f$1
  280. };
  281. // toObject with fallback for non-array-like ES3 strings
  282. var toIndexedObject = function (it) {
  283. return indexedObject(requireObjectCoercible(it));
  284. };
  285. var hasOwnProperty = {}.hasOwnProperty;
  286. var has = function (it, key) {
  287. return hasOwnProperty.call(it, key);
  288. };
  289. var nativeGetOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
  290. var f$2 = descriptors ? nativeGetOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) {
  291. O = toIndexedObject(O);
  292. P = toPrimitive(P, true);
  293. if (ie8DomDefine) try {
  294. return nativeGetOwnPropertyDescriptor$1(O, P);
  295. } catch (error) { /* empty */ }
  296. if (has(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]);
  297. };
  298. var objectGetOwnPropertyDescriptor = {
  299. f: f$2
  300. };
  301. var functionToString = shared('native-function-to-string', Function.toString);
  302. var WeakMap$1 = global$1.WeakMap;
  303. var nativeWeakMap = typeof WeakMap$1 === 'function' && /native code/.test(functionToString.call(WeakMap$1));
  304. var shared$1 = shared('keys');
  305. var sharedKey = function (key) {
  306. return shared$1[key] || (shared$1[key] = uid(key));
  307. };
  308. var hiddenKeys = {};
  309. var WeakMap$2 = global$1.WeakMap;
  310. var set, get, has$1;
  311. var enforce = function (it) {
  312. return has$1(it) ? get(it) : set(it, {});
  313. };
  314. var getterFor = function (TYPE) {
  315. return function (it) {
  316. var state;
  317. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  318. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  319. } return state;
  320. };
  321. };
  322. if (nativeWeakMap) {
  323. var store$1 = new WeakMap$2();
  324. var wmget = store$1.get;
  325. var wmhas = store$1.has;
  326. var wmset = store$1.set;
  327. set = function (it, metadata) {
  328. wmset.call(store$1, it, metadata);
  329. return metadata;
  330. };
  331. get = function (it) {
  332. return wmget.call(store$1, it) || {};
  333. };
  334. has$1 = function (it) {
  335. return wmhas.call(store$1, it);
  336. };
  337. } else {
  338. var STATE = sharedKey('state');
  339. hiddenKeys[STATE] = true;
  340. set = function (it, metadata) {
  341. hide(it, STATE, metadata);
  342. return metadata;
  343. };
  344. get = function (it) {
  345. return has(it, STATE) ? it[STATE] : {};
  346. };
  347. has$1 = function (it) {
  348. return has(it, STATE);
  349. };
  350. }
  351. var internalState = {
  352. set: set,
  353. get: get,
  354. has: has$1,
  355. enforce: enforce,
  356. getterFor: getterFor
  357. };
  358. var redefine = createCommonjsModule(function (module) {
  359. var getInternalState = internalState.get;
  360. var enforceInternalState = internalState.enforce;
  361. var TEMPLATE = String(functionToString).split('toString');
  362. shared('inspectSource', function (it) {
  363. return functionToString.call(it);
  364. });
  365. (module.exports = function (O, key, value, options) {
  366. var unsafe = options ? !!options.unsafe : false;
  367. var simple = options ? !!options.enumerable : false;
  368. var noTargetGet = options ? !!options.noTargetGet : false;
  369. if (typeof value == 'function') {
  370. if (typeof key == 'string' && !has(value, 'name')) hide(value, 'name', key);
  371. enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');
  372. }
  373. if (O === global$1) {
  374. if (simple) O[key] = value;
  375. else setGlobal(key, value);
  376. return;
  377. } else if (!unsafe) {
  378. delete O[key];
  379. } else if (!noTargetGet && O[key]) {
  380. simple = true;
  381. }
  382. if (simple) O[key] = value;
  383. else hide(O, key, value);
  384. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  385. })(Function.prototype, 'toString', function toString() {
  386. return typeof this == 'function' && getInternalState(this).source || functionToString.call(this);
  387. });
  388. });
  389. var max = Math.max;
  390. var min$1 = Math.min;
  391. // Helper for a popular repeating case of the spec:
  392. // Let integer be ? ToInteger(index).
  393. // If integer < 0, let result be max((length + integer), 0); else let result be min(length, length).
  394. var toAbsoluteIndex = function (index, length) {
  395. var integer = toInteger(index);
  396. return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
  397. };
  398. // `Array.prototype.{ indexOf, includes }` methods implementation
  399. // false -> Array#indexOf
  400. // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
  401. // true -> Array#includes
  402. // https://tc39.github.io/ecma262/#sec-array.prototype.includes
  403. var arrayIncludes = function (IS_INCLUDES) {
  404. return function ($this, el, fromIndex) {
  405. var O = toIndexedObject($this);
  406. var length = toLength(O.length);
  407. var index = toAbsoluteIndex(fromIndex, length);
  408. var value;
  409. // Array#includes uses SameValueZero equality algorithm
  410. // eslint-disable-next-line no-self-compare
  411. if (IS_INCLUDES && el != el) while (length > index) {
  412. value = O[index++];
  413. // eslint-disable-next-line no-self-compare
  414. if (value != value) return true;
  415. // Array#indexOf ignores holes, Array#includes - not
  416. } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
  417. if (O[index] === el) return IS_INCLUDES || index || 0;
  418. } return !IS_INCLUDES && -1;
  419. };
  420. };
  421. var arrayIndexOf = arrayIncludes(false);
  422. var objectKeysInternal = function (object, names) {
  423. var O = toIndexedObject(object);
  424. var i = 0;
  425. var result = [];
  426. var key;
  427. for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);
  428. // Don't enum bug & hidden keys
  429. while (names.length > i) if (has(O, key = names[i++])) {
  430. ~arrayIndexOf(result, key) || result.push(key);
  431. }
  432. return result;
  433. };
  434. // IE8- don't enum bug keys
  435. var enumBugKeys = [
  436. 'constructor',
  437. 'hasOwnProperty',
  438. 'isPrototypeOf',
  439. 'propertyIsEnumerable',
  440. 'toLocaleString',
  441. 'toString',
  442. 'valueOf'
  443. ];
  444. // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
  445. var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype');
  446. var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  447. return objectKeysInternal(O, hiddenKeys$1);
  448. };
  449. var objectGetOwnPropertyNames = {
  450. f: f$3
  451. };
  452. var f$4 = Object.getOwnPropertySymbols;
  453. var objectGetOwnPropertySymbols = {
  454. f: f$4
  455. };
  456. var Reflect = global$1.Reflect;
  457. // all object keys, includes non-enumerable and symbols
  458. var ownKeys = Reflect && Reflect.ownKeys || function ownKeys(it) {
  459. var keys = objectGetOwnPropertyNames.f(anObject(it));
  460. var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
  461. return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
  462. };
  463. var copyConstructorProperties = function (target, source) {
  464. var keys = ownKeys(source);
  465. var defineProperty = objectDefineProperty.f;
  466. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  467. for (var i = 0; i < keys.length; i++) {
  468. var key = keys[i];
  469. if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  470. }
  471. };
  472. var replacement = /#|\.prototype\./;
  473. var isForced = function (feature, detection) {
  474. var value = data[normalize(feature)];
  475. return value == POLYFILL ? true
  476. : value == NATIVE ? false
  477. : typeof detection == 'function' ? fails(detection)
  478. : !!detection;
  479. };
  480. var normalize = isForced.normalize = function (string) {
  481. return String(string).replace(replacement, '.').toLowerCase();
  482. };
  483. var data = isForced.data = {};
  484. var NATIVE = isForced.NATIVE = 'N';
  485. var POLYFILL = isForced.POLYFILL = 'P';
  486. var isForced_1 = isForced;
  487. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  488. /*
  489. options.target - name of the target object
  490. options.global - target is the global object
  491. options.stat - export as static methods of target
  492. options.proto - export as prototype methods of target
  493. options.real - real prototype method for the `pure` version
  494. options.forced - export even if the native feature is available
  495. options.bind - bind methods to the target, required for the `pure` version
  496. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  497. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  498. options.sham - add a flag to not completely full polyfills
  499. options.enumerable - export as enumerable property
  500. options.noTargetGet - prevent calling a getter on target
  501. */
  502. var _export = function (options, source) {
  503. var TARGET = options.target;
  504. var GLOBAL = options.global;
  505. var STATIC = options.stat;
  506. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  507. if (GLOBAL) {
  508. target = global$1;
  509. } else if (STATIC) {
  510. target = global$1[TARGET] || setGlobal(TARGET, {});
  511. } else {
  512. target = (global$1[TARGET] || {}).prototype;
  513. }
  514. if (target) for (key in source) {
  515. sourceProperty = source[key];
  516. if (options.noTargetGet) {
  517. descriptor = getOwnPropertyDescriptor(target, key);
  518. targetProperty = descriptor && descriptor.value;
  519. } else targetProperty = target[key];
  520. FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  521. // contained in target
  522. if (!FORCED && targetProperty !== undefined) {
  523. if (typeof sourceProperty === typeof targetProperty) continue;
  524. copyConstructorProperties(sourceProperty, targetProperty);
  525. }
  526. // add a flag to not completely full polyfills
  527. if (options.sham || (targetProperty && targetProperty.sham)) {
  528. hide(sourceProperty, 'sham', true);
  529. }
  530. // extend global
  531. redefine(target, key, sourceProperty, options);
  532. }
  533. };
  534. var internalFilter = arrayMethods(2);
  535. var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('filter');
  536. // `Array.prototype.filter` method
  537. // https://tc39.github.io/ecma262/#sec-array.prototype.filter
  538. // with adding support of @@species
  539. _export({ target: 'Array', proto: true, forced: !SPECIES_SUPPORT }, {
  540. filter: function filter(callbackfn /* , thisArg */) {
  541. return internalFilter(this, callbackfn, arguments[1]);
  542. }
  543. });
  544. var sloppyArrayMethod = function (METHOD_NAME, argument) {
  545. var method = [][METHOD_NAME];
  546. return !method || !fails(function () {
  547. // eslint-disable-next-line no-useless-call,no-throw-literal
  548. method.call(null, argument || function () { throw 1; }, 1);
  549. });
  550. };
  551. var nativeForEach = [].forEach;
  552. var internalForEach = arrayMethods(0);
  553. var SLOPPY_METHOD = sloppyArrayMethod('forEach');
  554. // `Array.prototype.forEach` method implementation
  555. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  556. var arrayForEach = SLOPPY_METHOD ? function forEach(callbackfn /* , thisArg */) {
  557. return internalForEach(this, callbackfn, arguments[1]);
  558. } : nativeForEach;
  559. // `Array.prototype.forEach` method
  560. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  561. _export({ target: 'Array', proto: true, forced: [].forEach != arrayForEach }, { forEach: arrayForEach });
  562. // `Array.prototype.{ reduce, reduceRight }` methods implementation
  563. // https://tc39.github.io/ecma262/#sec-array.prototype.reduce
  564. // https://tc39.github.io/ecma262/#sec-array.prototype.reduceright
  565. var arrayReduce = function (that, callbackfn, argumentsLength, memo, isRight) {
  566. aFunction(callbackfn);
  567. var O = toObject(that);
  568. var self = indexedObject(O);
  569. var length = toLength(O.length);
  570. var index = isRight ? length - 1 : 0;
  571. var i = isRight ? -1 : 1;
  572. if (argumentsLength < 2) while (true) {
  573. if (index in self) {
  574. memo = self[index];
  575. index += i;
  576. break;
  577. }
  578. index += i;
  579. if (isRight ? index < 0 : length <= index) {
  580. throw TypeError('Reduce of empty array with no initial value');
  581. }
  582. }
  583. for (;isRight ? index >= 0 : length > index; index += i) if (index in self) {
  584. memo = callbackfn(memo, self[index], index, O);
  585. }
  586. return memo;
  587. };
  588. var SLOPPY_METHOD$1 = sloppyArrayMethod('reduce');
  589. // `Array.prototype.reduce` method
  590. // https://tc39.github.io/ecma262/#sec-array.prototype.reduce
  591. _export({ target: 'Array', proto: true, forced: SLOPPY_METHOD$1 }, {
  592. reduce: function reduce(callbackfn /* , initialValue */) {
  593. return arrayReduce(this, callbackfn, arguments.length, arguments[1], false);
  594. }
  595. });
  596. var defineProperty = objectDefineProperty.f;
  597. var FunctionPrototype = Function.prototype;
  598. var FunctionPrototypeToString = FunctionPrototype.toString;
  599. var nameRE = /^\s*function ([^ (]*)/;
  600. var NAME = 'name';
  601. // Function instances `.name` property
  602. // https://tc39.github.io/ecma262/#sec-function-instances-name
  603. if (descriptors && !(NAME in FunctionPrototype)) {
  604. defineProperty(FunctionPrototype, NAME, {
  605. configurable: true,
  606. get: function () {
  607. try {
  608. return FunctionPrototypeToString.call(this).match(nameRE)[1];
  609. } catch (error) {
  610. return '';
  611. }
  612. }
  613. });
  614. }
  615. // 19.1.2.14 / 15.2.3.14 Object.keys(O)
  616. var objectKeys = Object.keys || function keys(O) {
  617. return objectKeysInternal(O, enumBugKeys);
  618. };
  619. // 19.1.2.1 Object.assign(target, source, ...)
  620. var nativeAssign = Object.assign;
  621. // should work with symbols and should have deterministic property order (V8 bug)
  622. var objectAssign = !nativeAssign || fails(function () {
  623. var A = {};
  624. var B = {};
  625. // eslint-disable-next-line no-undef
  626. var symbol = Symbol();
  627. var alphabet = 'abcdefghijklmnopqrst';
  628. A[symbol] = 7;
  629. alphabet.split('').forEach(function (chr) { B[chr] = chr; });
  630. return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet;
  631. }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
  632. var T = toObject(target);
  633. var argumentsLength = arguments.length;
  634. var index = 1;
  635. var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
  636. var propertyIsEnumerable = objectPropertyIsEnumerable.f;
  637. while (argumentsLength > index) {
  638. var S = indexedObject(arguments[index++]);
  639. var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S);
  640. var length = keys.length;
  641. var j = 0;
  642. var key;
  643. while (length > j) if (propertyIsEnumerable.call(S, key = keys[j++])) T[key] = S[key];
  644. } return T;
  645. } : nativeAssign;
  646. // `Object.assign` method
  647. // https://tc39.github.io/ecma262/#sec-object.assign
  648. _export({ target: 'Object', stat: true, forced: Object.assign !== objectAssign }, { assign: objectAssign });
  649. // a string of all valid unicode whitespaces
  650. // eslint-disable-next-line max-len
  651. var whitespaces = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
  652. var whitespace = '[' + whitespaces + ']';
  653. var ltrim = RegExp('^' + whitespace + whitespace + '*');
  654. var rtrim = RegExp(whitespace + whitespace + '*$');
  655. // 1 -> String#trimStart
  656. // 2 -> String#trimEnd
  657. // 3 -> String#trim
  658. var stringTrim = function (string, TYPE) {
  659. string = String(requireObjectCoercible(string));
  660. if (TYPE & 1) string = string.replace(ltrim, '');
  661. if (TYPE & 2) string = string.replace(rtrim, '');
  662. return string;
  663. };
  664. var nativeParseInt = global$1.parseInt;
  665. var hex = /^[-+]?0[xX]/;
  666. var FORCED = nativeParseInt(whitespaces + '08') !== 8 || nativeParseInt(whitespaces + '0x16') !== 22;
  667. var _parseInt = FORCED ? function parseInt(str, radix) {
  668. var string = stringTrim(String(str), 3);
  669. return nativeParseInt(string, (radix >>> 0) || (hex.test(string) ? 16 : 10));
  670. } : nativeParseInt;
  671. // `parseInt` method
  672. // https://tc39.github.io/ecma262/#sec-parseint-string-radix
  673. _export({ global: true, forced: parseInt != _parseInt }, {
  674. parseInt: _parseInt
  675. });
  676. // `RegExp.prototype.flags` getter implementation
  677. // https://tc39.github.io/ecma262/#sec-get-regexp.prototype.flags
  678. var regexpFlags = function () {
  679. var that = anObject(this);
  680. var result = '';
  681. if (that.global) result += 'g';
  682. if (that.ignoreCase) result += 'i';
  683. if (that.multiline) result += 'm';
  684. if (that.unicode) result += 'u';
  685. if (that.sticky) result += 'y';
  686. return result;
  687. };
  688. var nativeExec = RegExp.prototype.exec;
  689. // This always refers to the native implementation, because the
  690. // String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,
  691. // which loads this file before patching the method.
  692. var nativeReplace = String.prototype.replace;
  693. var patchedExec = nativeExec;
  694. var UPDATES_LAST_INDEX_WRONG = (function () {
  695. var re1 = /a/;
  696. var re2 = /b*/g;
  697. nativeExec.call(re1, 'a');
  698. nativeExec.call(re2, 'a');
  699. return re1.lastIndex !== 0 || re2.lastIndex !== 0;
  700. })();
  701. // nonparticipating capturing group, copied from es5-shim's String#split patch.
  702. var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
  703. var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED;
  704. if (PATCH) {
  705. patchedExec = function exec(str) {
  706. var re = this;
  707. var lastIndex, reCopy, match, i;
  708. if (NPCG_INCLUDED) {
  709. reCopy = new RegExp('^' + re.source + '$(?!\\s)', regexpFlags.call(re));
  710. }
  711. if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
  712. match = nativeExec.call(re, str);
  713. if (UPDATES_LAST_INDEX_WRONG && match) {
  714. re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
  715. }
  716. if (NPCG_INCLUDED && match && match.length > 1) {
  717. // Fix browsers whose `exec` methods don't consistently return `undefined`
  718. // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
  719. nativeReplace.call(match[0], reCopy, function () {
  720. for (i = 1; i < arguments.length - 2; i++) {
  721. if (arguments[i] === undefined) match[i] = undefined;
  722. }
  723. });
  724. }
  725. return match;
  726. };
  727. }
  728. var regexpExec = patchedExec;
  729. _export({ target: 'RegExp', proto: true, forced: /./.exec !== regexpExec }, {
  730. exec: regexpExec
  731. });
  732. // CONVERT_TO_STRING: true -> String#at
  733. // CONVERT_TO_STRING: false -> String#codePointAt
  734. var stringAt = function (that, pos, CONVERT_TO_STRING) {
  735. var S = String(requireObjectCoercible(that));
  736. var position = toInteger(pos);
  737. var size = S.length;
  738. var first, second;
  739. if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
  740. first = S.charCodeAt(position);
  741. return first < 0xD800 || first > 0xDBFF || position + 1 === size
  742. || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF
  743. ? CONVERT_TO_STRING ? S.charAt(position) : first
  744. : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
  745. };
  746. // `AdvanceStringIndex` abstract operation
  747. // https://tc39.github.io/ecma262/#sec-advancestringindex
  748. var advanceStringIndex = function (S, index, unicode) {
  749. return index + (unicode ? stringAt(S, index, true).length : 1);
  750. };
  751. // `RegExpExec` abstract operation
  752. // https://tc39.github.io/ecma262/#sec-regexpexec
  753. var regexpExecAbstract = function (R, S) {
  754. var exec = R.exec;
  755. if (typeof exec === 'function') {
  756. var result = exec.call(R, S);
  757. if (typeof result !== 'object') {
  758. throw TypeError('RegExp exec method returned something other than an Object or null');
  759. }
  760. return result;
  761. }
  762. if (classofRaw(R) !== 'RegExp') {
  763. throw TypeError('RegExp#exec called on incompatible receiver');
  764. }
  765. return regexpExec.call(R, S);
  766. };
  767. var SPECIES$2 = wellKnownSymbol('species');
  768. var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
  769. // #replace needs built-in support for named groups.
  770. // #match works fine because it just return the exec results, even if it has
  771. // a "grops" property.
  772. var re = /./;
  773. re.exec = function () {
  774. var result = [];
  775. result.groups = { a: '7' };
  776. return result;
  777. };
  778. return ''.replace(re, '$<a>') !== '7';
  779. });
  780. // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
  781. // Weex JS has frozen built-in prototypes, so use try / catch wrapper
  782. var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
  783. var re = /(?:)/;
  784. var originalExec = re.exec;
  785. re.exec = function () { return originalExec.apply(this, arguments); };
  786. var result = 'ab'.split(re);
  787. return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
  788. });
  789. var fixRegexpWellKnownSymbolLogic = function (KEY, length, exec, sham) {
  790. var SYMBOL = wellKnownSymbol(KEY);
  791. var DELEGATES_TO_SYMBOL = !fails(function () {
  792. // String methods call symbol-named RegEp methods
  793. var O = {};
  794. O[SYMBOL] = function () { return 7; };
  795. return ''[KEY](O) != 7;
  796. });
  797. var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () {
  798. // Symbol-named RegExp methods call .exec
  799. var execCalled = false;
  800. var re = /a/;
  801. re.exec = function () { execCalled = true; return null; };
  802. if (KEY === 'split') {
  803. // RegExp[@@split] doesn't call the regex's exec method, but first creates
  804. // a new one. We need to return the patched regex when creating the new one.
  805. re.constructor = {};
  806. re.constructor[SPECIES$2] = function () { return re; };
  807. }
  808. re[SYMBOL]('');
  809. return !execCalled;
  810. });
  811. if (
  812. !DELEGATES_TO_SYMBOL ||
  813. !DELEGATES_TO_EXEC ||
  814. (KEY === 'replace' && !REPLACE_SUPPORTS_NAMED_GROUPS) ||
  815. (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)
  816. ) {
  817. var nativeRegExpMethod = /./[SYMBOL];
  818. var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
  819. if (regexp.exec === regexpExec) {
  820. if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
  821. // The native String method already delegates to @@method (this
  822. // polyfilled function), leasing to infinite recursion.
  823. // We avoid it by directly calling the native @@method method.
  824. return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };
  825. }
  826. return { done: true, value: nativeMethod.call(str, regexp, arg2) };
  827. }
  828. return { done: false };
  829. });
  830. var stringMethod = methods[0];
  831. var regexMethod = methods[1];
  832. redefine(String.prototype, KEY, stringMethod);
  833. redefine(RegExp.prototype, SYMBOL, length == 2
  834. // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
  835. // 21.2.5.11 RegExp.prototype[@@split](string, limit)
  836. ? function (string, arg) { return regexMethod.call(string, this, arg); }
  837. // 21.2.5.6 RegExp.prototype[@@match](string)
  838. // 21.2.5.9 RegExp.prototype[@@search](string)
  839. : function (string) { return regexMethod.call(string, this); }
  840. );
  841. if (sham) hide(RegExp.prototype[SYMBOL], 'sham', true);
  842. }
  843. };
  844. // @@match logic
  845. fixRegexpWellKnownSymbolLogic(
  846. 'match',
  847. 1,
  848. function (MATCH, nativeMatch, maybeCallNative) {
  849. return [
  850. // `String.prototype.match` method
  851. // https://tc39.github.io/ecma262/#sec-string.prototype.match
  852. function match(regexp) {
  853. var O = requireObjectCoercible(this);
  854. var matcher = regexp == undefined ? undefined : regexp[MATCH];
  855. return matcher !== undefined ? matcher.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
  856. },
  857. // `RegExp.prototype[@@match]` method
  858. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match
  859. function (regexp) {
  860. var res = maybeCallNative(nativeMatch, regexp, this);
  861. if (res.done) return res.value;
  862. var rx = anObject(regexp);
  863. var S = String(this);
  864. if (!rx.global) return regexpExecAbstract(rx, S);
  865. var fullUnicode = rx.unicode;
  866. rx.lastIndex = 0;
  867. var A = [];
  868. var n = 0;
  869. var result;
  870. while ((result = regexpExecAbstract(rx, S)) !== null) {
  871. var matchStr = String(result[0]);
  872. A[n] = matchStr;
  873. if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
  874. n++;
  875. }
  876. return n === 0 ? null : A;
  877. }
  878. ];
  879. }
  880. );
  881. var max$1 = Math.max;
  882. var min$2 = Math.min;
  883. var floor$1 = Math.floor;
  884. var SUBSTITUTION_SYMBOLS = /\$([$&`']|\d\d?|<[^>]*>)/g;
  885. var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&`']|\d\d?)/g;
  886. var maybeToString = function (it) {
  887. return it === undefined ? it : String(it);
  888. };
  889. // @@replace logic
  890. fixRegexpWellKnownSymbolLogic(
  891. 'replace',
  892. 2,
  893. function (REPLACE, nativeReplace, maybeCallNative) {
  894. return [
  895. // `String.prototype.replace` method
  896. // https://tc39.github.io/ecma262/#sec-string.prototype.replace
  897. function replace(searchValue, replaceValue) {
  898. var O = requireObjectCoercible(this);
  899. var replacer = searchValue == undefined ? undefined : searchValue[REPLACE];
  900. return replacer !== undefined
  901. ? replacer.call(searchValue, O, replaceValue)
  902. : nativeReplace.call(String(O), searchValue, replaceValue);
  903. },
  904. // `RegExp.prototype[@@replace]` method
  905. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace
  906. function (regexp, replaceValue) {
  907. var res = maybeCallNative(nativeReplace, regexp, this, replaceValue);
  908. if (res.done) return res.value;
  909. var rx = anObject(regexp);
  910. var S = String(this);
  911. var functionalReplace = typeof replaceValue === 'function';
  912. if (!functionalReplace) replaceValue = String(replaceValue);
  913. var global = rx.global;
  914. if (global) {
  915. var fullUnicode = rx.unicode;
  916. rx.lastIndex = 0;
  917. }
  918. var results = [];
  919. while (true) {
  920. var result = regexpExecAbstract(rx, S);
  921. if (result === null) break;
  922. results.push(result);
  923. if (!global) break;
  924. var matchStr = String(result[0]);
  925. if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
  926. }
  927. var accumulatedResult = '';
  928. var nextSourcePosition = 0;
  929. for (var i = 0; i < results.length; i++) {
  930. result = results[i];
  931. var matched = String(result[0]);
  932. var position = max$1(min$2(toInteger(result.index), S.length), 0);
  933. var captures = [];
  934. // NOTE: This is equivalent to
  935. // captures = result.slice(1).map(maybeToString)
  936. // but for some reason `nativeSlice.call(result, 1, result.length)` (called in
  937. // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
  938. // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
  939. for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));
  940. var namedCaptures = result.groups;
  941. if (functionalReplace) {
  942. var replacerArgs = [matched].concat(captures, position, S);
  943. if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);
  944. var replacement = String(replaceValue.apply(undefined, replacerArgs));
  945. } else {
  946. replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
  947. }
  948. if (position >= nextSourcePosition) {
  949. accumulatedResult += S.slice(nextSourcePosition, position) + replacement;
  950. nextSourcePosition = position + matched.length;
  951. }
  952. }
  953. return accumulatedResult + S.slice(nextSourcePosition);
  954. }
  955. ];
  956. // https://tc39.github.io/ecma262/#sec-getsubstitution
  957. function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {
  958. var tailPos = position + matched.length;
  959. var m = captures.length;
  960. var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
  961. if (namedCaptures !== undefined) {
  962. namedCaptures = toObject(namedCaptures);
  963. symbols = SUBSTITUTION_SYMBOLS;
  964. }
  965. return nativeReplace.call(replacement, symbols, function (match, ch) {
  966. var capture;
  967. switch (ch.charAt(0)) {
  968. case '$': return '$';
  969. case '&': return matched;
  970. case '`': return str.slice(0, position);
  971. case "'": return str.slice(tailPos);
  972. case '<':
  973. capture = namedCaptures[ch.slice(1, -1)];
  974. break;
  975. default: // \d\d?
  976. var n = +ch;
  977. if (n === 0) return match;
  978. if (n > m) {
  979. var f = floor$1(n / 10);
  980. if (f === 0) return match;
  981. if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);
  982. return match;
  983. }
  984. capture = captures[n - 1];
  985. }
  986. return capture === undefined ? '' : capture;
  987. });
  988. }
  989. }
  990. );
  991. // iterable DOM collections
  992. // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
  993. var domIterables = {
  994. CSSRuleList: 0,
  995. CSSStyleDeclaration: 0,
  996. CSSValueList: 0,
  997. ClientRectList: 0,
  998. DOMRectList: 0,
  999. DOMStringList: 0,
  1000. DOMTokenList: 1,
  1001. DataTransferItemList: 0,
  1002. FileList: 0,
  1003. HTMLAllCollection: 0,
  1004. HTMLCollection: 0,
  1005. HTMLFormElement: 0,
  1006. HTMLSelectElement: 0,
  1007. MediaList: 0,
  1008. MimeTypeArray: 0,
  1009. NamedNodeMap: 0,
  1010. NodeList: 1,
  1011. PaintRequestList: 0,
  1012. Plugin: 0,
  1013. PluginArray: 0,
  1014. SVGLengthList: 0,
  1015. SVGNumberList: 0,
  1016. SVGPathSegList: 0,
  1017. SVGPointList: 0,
  1018. SVGStringList: 0,
  1019. SVGTransformList: 0,
  1020. SourceBufferList: 0,
  1021. StyleSheetList: 0,
  1022. TextTrackCueList: 0,
  1023. TextTrackList: 0,
  1024. TouchList: 0
  1025. };
  1026. for (var COLLECTION_NAME in domIterables) {
  1027. var Collection = global$1[COLLECTION_NAME];
  1028. var CollectionPrototype = Collection && Collection.prototype;
  1029. // some Chrome versions have non-configurable methods on DOMTokenList
  1030. if (CollectionPrototype && CollectionPrototype.forEach !== arrayForEach) try {
  1031. hide(CollectionPrototype, 'forEach', arrayForEach);
  1032. } catch (error) {
  1033. CollectionPrototype.forEach = arrayForEach;
  1034. }
  1035. }
  1036. var scrollbarWidth = createCommonjsModule(function (module, exports) {
  1037. /*! scrollbarWidth.js v0.1.3 | felixexter | MIT | https://github.com/felixexter/scrollbarWidth */
  1038. (function (root, factory) {
  1039. {
  1040. module.exports = factory();
  1041. }
  1042. }(commonjsGlobal, function () {
  1043. function scrollbarWidth() {
  1044. if (typeof document === 'undefined') {
  1045. return 0
  1046. }
  1047. var
  1048. body = document.body,
  1049. box = document.createElement('div'),
  1050. boxStyle = box.style,
  1051. width;
  1052. boxStyle.position = 'absolute';
  1053. boxStyle.top = boxStyle.left = '-9999px';
  1054. boxStyle.width = boxStyle.height = '100px';
  1055. boxStyle.overflow = 'scroll';
  1056. body.appendChild(box);
  1057. width = box.offsetWidth - box.clientWidth;
  1058. body.removeChild(box);
  1059. return width;
  1060. }
  1061. return scrollbarWidth;
  1062. }));
  1063. });
  1064. /**
  1065. * lodash (Custom Build) <https://lodash.com/>
  1066. * Build: `lodash modularize exports="npm" -o ./`
  1067. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  1068. * Released under MIT license <https://lodash.com/license>
  1069. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  1070. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  1071. */
  1072. /** Used as the `TypeError` message for "Functions" methods. */
  1073. var FUNC_ERROR_TEXT = 'Expected a function';
  1074. /** Used as references for various `Number` constants. */
  1075. var NAN = 0 / 0;
  1076. /** `Object#toString` result references. */
  1077. var symbolTag = '[object Symbol]';
  1078. /** Used to match leading and trailing whitespace. */
  1079. var reTrim = /^\s+|\s+$/g;
  1080. /** Used to detect bad signed hexadecimal string values. */
  1081. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  1082. /** Used to detect binary string values. */
  1083. var reIsBinary = /^0b[01]+$/i;
  1084. /** Used to detect octal string values. */
  1085. var reIsOctal = /^0o[0-7]+$/i;
  1086. /** Built-in method references without a dependency on `root`. */
  1087. var freeParseInt = parseInt;
  1088. /** Detect free variable `global` from Node.js. */
  1089. var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
  1090. /** Detect free variable `self`. */
  1091. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  1092. /** Used as a reference to the global object. */
  1093. var root = freeGlobal || freeSelf || Function('return this')();
  1094. /** Used for built-in method references. */
  1095. var objectProto = Object.prototype;
  1096. /**
  1097. * Used to resolve the
  1098. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  1099. * of values.
  1100. */
  1101. var objectToString = objectProto.toString;
  1102. /* Built-in method references for those with the same name as other `lodash` methods. */
  1103. var nativeMax = Math.max,
  1104. nativeMin = Math.min;
  1105. /**
  1106. * Gets the timestamp of the number of milliseconds that have elapsed since
  1107. * the Unix epoch (1 January 1970 00:00:00 UTC).
  1108. *
  1109. * @static
  1110. * @memberOf _
  1111. * @since 2.4.0
  1112. * @category Date
  1113. * @returns {number} Returns the timestamp.
  1114. * @example
  1115. *
  1116. * _.defer(function(stamp) {
  1117. * console.log(_.now() - stamp);
  1118. * }, _.now());
  1119. * // => Logs the number of milliseconds it took for the deferred invocation.
  1120. */
  1121. var now = function() {
  1122. return root.Date.now();
  1123. };
  1124. /**
  1125. * Creates a debounced function that delays invoking `func` until after `wait`
  1126. * milliseconds have elapsed since the last time the debounced function was
  1127. * invoked. The debounced function comes with a `cancel` method to cancel
  1128. * delayed `func` invocations and a `flush` method to immediately invoke them.
  1129. * Provide `options` to indicate whether `func` should be invoked on the
  1130. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  1131. * with the last arguments provided to the debounced function. Subsequent
  1132. * calls to the debounced function return the result of the last `func`
  1133. * invocation.
  1134. *
  1135. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  1136. * invoked on the trailing edge of the timeout only if the debounced function
  1137. * is invoked more than once during the `wait` timeout.
  1138. *
  1139. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  1140. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  1141. *
  1142. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  1143. * for details over the differences between `_.debounce` and `_.throttle`.
  1144. *
  1145. * @static
  1146. * @memberOf _
  1147. * @since 0.1.0
  1148. * @category Function
  1149. * @param {Function} func The function to debounce.
  1150. * @param {number} [wait=0] The number of milliseconds to delay.
  1151. * @param {Object} [options={}] The options object.
  1152. * @param {boolean} [options.leading=false]
  1153. * Specify invoking on the leading edge of the timeout.
  1154. * @param {number} [options.maxWait]
  1155. * The maximum time `func` is allowed to be delayed before it's invoked.
  1156. * @param {boolean} [options.trailing=true]
  1157. * Specify invoking on the trailing edge of the timeout.
  1158. * @returns {Function} Returns the new debounced function.
  1159. * @example
  1160. *
  1161. * // Avoid costly calculations while the window size is in flux.
  1162. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  1163. *
  1164. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  1165. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  1166. * 'leading': true,
  1167. * 'trailing': false
  1168. * }));
  1169. *
  1170. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  1171. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  1172. * var source = new EventSource('/stream');
  1173. * jQuery(source).on('message', debounced);
  1174. *
  1175. * // Cancel the trailing debounced invocation.
  1176. * jQuery(window).on('popstate', debounced.cancel);
  1177. */
  1178. function debounce(func, wait, options) {
  1179. var lastArgs,
  1180. lastThis,
  1181. maxWait,
  1182. result,
  1183. timerId,
  1184. lastCallTime,
  1185. lastInvokeTime = 0,
  1186. leading = false,
  1187. maxing = false,
  1188. trailing = true;
  1189. if (typeof func != 'function') {
  1190. throw new TypeError(FUNC_ERROR_TEXT);
  1191. }
  1192. wait = toNumber(wait) || 0;
  1193. if (isObject$1(options)) {
  1194. leading = !!options.leading;
  1195. maxing = 'maxWait' in options;
  1196. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  1197. trailing = 'trailing' in options ? !!options.trailing : trailing;
  1198. }
  1199. function invokeFunc(time) {
  1200. var args = lastArgs,
  1201. thisArg = lastThis;
  1202. lastArgs = lastThis = undefined;
  1203. lastInvokeTime = time;
  1204. result = func.apply(thisArg, args);
  1205. return result;
  1206. }
  1207. function leadingEdge(time) {
  1208. // Reset any `maxWait` timer.
  1209. lastInvokeTime = time;
  1210. // Start the timer for the trailing edge.
  1211. timerId = setTimeout(timerExpired, wait);
  1212. // Invoke the leading edge.
  1213. return leading ? invokeFunc(time) : result;
  1214. }
  1215. function remainingWait(time) {
  1216. var timeSinceLastCall = time - lastCallTime,
  1217. timeSinceLastInvoke = time - lastInvokeTime,
  1218. result = wait - timeSinceLastCall;
  1219. return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
  1220. }
  1221. function shouldInvoke(time) {
  1222. var timeSinceLastCall = time - lastCallTime,
  1223. timeSinceLastInvoke = time - lastInvokeTime;
  1224. // Either this is the first call, activity has stopped and we're at the
  1225. // trailing edge, the system time has gone backwards and we're treating
  1226. // it as the trailing edge, or we've hit the `maxWait` limit.
  1227. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  1228. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  1229. }
  1230. function timerExpired() {
  1231. var time = now();
  1232. if (shouldInvoke(time)) {
  1233. return trailingEdge(time);
  1234. }
  1235. // Restart the timer.
  1236. timerId = setTimeout(timerExpired, remainingWait(time));
  1237. }
  1238. function trailingEdge(time) {
  1239. timerId = undefined;
  1240. // Only invoke if we have `lastArgs` which means `func` has been
  1241. // debounced at least once.
  1242. if (trailing && lastArgs) {
  1243. return invokeFunc(time);
  1244. }
  1245. lastArgs = lastThis = undefined;
  1246. return result;
  1247. }
  1248. function cancel() {
  1249. if (timerId !== undefined) {
  1250. clearTimeout(timerId);
  1251. }
  1252. lastInvokeTime = 0;
  1253. lastArgs = lastCallTime = lastThis = timerId = undefined;
  1254. }
  1255. function flush() {
  1256. return timerId === undefined ? result : trailingEdge(now());
  1257. }
  1258. function debounced() {
  1259. var time = now(),
  1260. isInvoking = shouldInvoke(time);
  1261. lastArgs = arguments;
  1262. lastThis = this;
  1263. lastCallTime = time;
  1264. if (isInvoking) {
  1265. if (timerId === undefined) {
  1266. return leadingEdge(lastCallTime);
  1267. }
  1268. if (maxing) {
  1269. // Handle invocations in a tight loop.
  1270. timerId = setTimeout(timerExpired, wait);
  1271. return invokeFunc(lastCallTime);
  1272. }
  1273. }
  1274. if (timerId === undefined) {
  1275. timerId = setTimeout(timerExpired, wait);
  1276. }
  1277. return result;
  1278. }
  1279. debounced.cancel = cancel;
  1280. debounced.flush = flush;
  1281. return debounced;
  1282. }
  1283. /**
  1284. * Creates a throttled function that only invokes `func` at most once per
  1285. * every `wait` milliseconds. The throttled function comes with a `cancel`
  1286. * method to cancel delayed `func` invocations and a `flush` method to
  1287. * immediately invoke them. Provide `options` to indicate whether `func`
  1288. * should be invoked on the leading and/or trailing edge of the `wait`
  1289. * timeout. The `func` is invoked with the last arguments provided to the
  1290. * throttled function. Subsequent calls to the throttled function return the
  1291. * result of the last `func` invocation.
  1292. *
  1293. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  1294. * invoked on the trailing edge of the timeout only if the throttled function
  1295. * is invoked more than once during the `wait` timeout.
  1296. *
  1297. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  1298. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  1299. *
  1300. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  1301. * for details over the differences between `_.throttle` and `_.debounce`.
  1302. *
  1303. * @static
  1304. * @memberOf _
  1305. * @since 0.1.0
  1306. * @category Function
  1307. * @param {Function} func The function to throttle.
  1308. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  1309. * @param {Object} [options={}] The options object.
  1310. * @param {boolean} [options.leading=true]
  1311. * Specify invoking on the leading edge of the timeout.
  1312. * @param {boolean} [options.trailing=true]
  1313. * Specify invoking on the trailing edge of the timeout.
  1314. * @returns {Function} Returns the new throttled function.
  1315. * @example
  1316. *
  1317. * // Avoid excessively updating the position while scrolling.
  1318. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  1319. *
  1320. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  1321. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  1322. * jQuery(element).on('click', throttled);
  1323. *
  1324. * // Cancel the trailing throttled invocation.
  1325. * jQuery(window).on('popstate', throttled.cancel);
  1326. */
  1327. function throttle(func, wait, options) {
  1328. var leading = true,
  1329. trailing = true;
  1330. if (typeof func != 'function') {
  1331. throw new TypeError(FUNC_ERROR_TEXT);
  1332. }
  1333. if (isObject$1(options)) {
  1334. leading = 'leading' in options ? !!options.leading : leading;
  1335. trailing = 'trailing' in options ? !!options.trailing : trailing;
  1336. }
  1337. return debounce(func, wait, {
  1338. 'leading': leading,
  1339. 'maxWait': wait,
  1340. 'trailing': trailing
  1341. });
  1342. }
  1343. /**
  1344. * Checks if `value` is the
  1345. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  1346. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  1347. *
  1348. * @static
  1349. * @memberOf _
  1350. * @since 0.1.0
  1351. * @category Lang
  1352. * @param {*} value The value to check.
  1353. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  1354. * @example
  1355. *
  1356. * _.isObject({});
  1357. * // => true
  1358. *
  1359. * _.isObject([1, 2, 3]);
  1360. * // => true
  1361. *
  1362. * _.isObject(_.noop);
  1363. * // => true
  1364. *
  1365. * _.isObject(null);
  1366. * // => false
  1367. */
  1368. function isObject$1(value) {
  1369. var type = typeof value;
  1370. return !!value && (type == 'object' || type == 'function');
  1371. }
  1372. /**
  1373. * Checks if `value` is object-like. A value is object-like if it's not `null`
  1374. * and has a `typeof` result of "object".
  1375. *
  1376. * @static
  1377. * @memberOf _
  1378. * @since 4.0.0
  1379. * @category Lang
  1380. * @param {*} value The value to check.
  1381. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  1382. * @example
  1383. *
  1384. * _.isObjectLike({});
  1385. * // => true
  1386. *
  1387. * _.isObjectLike([1, 2, 3]);
  1388. * // => true
  1389. *
  1390. * _.isObjectLike(_.noop);
  1391. * // => false
  1392. *
  1393. * _.isObjectLike(null);
  1394. * // => false
  1395. */
  1396. function isObjectLike(value) {
  1397. return !!value && typeof value == 'object';
  1398. }
  1399. /**
  1400. * Checks if `value` is classified as a `Symbol` primitive or object.
  1401. *
  1402. * @static
  1403. * @memberOf _
  1404. * @since 4.0.0
  1405. * @category Lang
  1406. * @param {*} value The value to check.
  1407. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  1408. * @example
  1409. *
  1410. * _.isSymbol(Symbol.iterator);
  1411. * // => true
  1412. *
  1413. * _.isSymbol('abc');
  1414. * // => false
  1415. */
  1416. function isSymbol(value) {
  1417. return typeof value == 'symbol' ||
  1418. (isObjectLike(value) && objectToString.call(value) == symbolTag);
  1419. }
  1420. /**
  1421. * Converts `value` to a number.
  1422. *
  1423. * @static
  1424. * @memberOf _
  1425. * @since 4.0.0
  1426. * @category Lang
  1427. * @param {*} value The value to process.
  1428. * @returns {number} Returns the number.
  1429. * @example
  1430. *
  1431. * _.toNumber(3.2);
  1432. * // => 3.2
  1433. *
  1434. * _.toNumber(Number.MIN_VALUE);
  1435. * // => 5e-324
  1436. *
  1437. * _.toNumber(Infinity);
  1438. * // => Infinity
  1439. *
  1440. * _.toNumber('3.2');
  1441. * // => 3.2
  1442. */
  1443. function toNumber(value) {
  1444. if (typeof value == 'number') {
  1445. return value;
  1446. }
  1447. if (isSymbol(value)) {
  1448. return NAN;
  1449. }
  1450. if (isObject$1(value)) {
  1451. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  1452. value = isObject$1(other) ? (other + '') : other;
  1453. }
  1454. if (typeof value != 'string') {
  1455. return value === 0 ? value : +value;
  1456. }
  1457. value = value.replace(reTrim, '');
  1458. var isBinary = reIsBinary.test(value);
  1459. return (isBinary || reIsOctal.test(value))
  1460. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  1461. : (reIsBadHex.test(value) ? NAN : +value);
  1462. }
  1463. var lodash_throttle = throttle;
  1464. /**
  1465. * lodash (Custom Build) <https://lodash.com/>
  1466. * Build: `lodash modularize exports="npm" -o ./`
  1467. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  1468. * Released under MIT license <https://lodash.com/license>
  1469. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  1470. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  1471. */
  1472. /** Used as the `TypeError` message for "Functions" methods. */
  1473. var FUNC_ERROR_TEXT$1 = 'Expected a function';
  1474. /** Used as references for various `Number` constants. */
  1475. var NAN$1 = 0 / 0;
  1476. /** `Object#toString` result references. */
  1477. var symbolTag$1 = '[object Symbol]';
  1478. /** Used to match leading and trailing whitespace. */
  1479. var reTrim$1 = /^\s+|\s+$/g;
  1480. /** Used to detect bad signed hexadecimal string values. */
  1481. var reIsBadHex$1 = /^[-+]0x[0-9a-f]+$/i;
  1482. /** Used to detect binary string values. */
  1483. var reIsBinary$1 = /^0b[01]+$/i;
  1484. /** Used to detect octal string values. */
  1485. var reIsOctal$1 = /^0o[0-7]+$/i;
  1486. /** Built-in method references without a dependency on `root`. */
  1487. var freeParseInt$1 = parseInt;
  1488. /** Detect free variable `global` from Node.js. */
  1489. var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
  1490. /** Detect free variable `self`. */
  1491. var freeSelf$1 = typeof self == 'object' && self && self.Object === Object && self;
  1492. /** Used as a reference to the global object. */
  1493. var root$1 = freeGlobal$1 || freeSelf$1 || Function('return this')();
  1494. /** Used for built-in method references. */
  1495. var objectProto$1 = Object.prototype;
  1496. /**
  1497. * Used to resolve the
  1498. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  1499. * of values.
  1500. */
  1501. var objectToString$1 = objectProto$1.toString;
  1502. /* Built-in method references for those with the same name as other `lodash` methods. */
  1503. var nativeMax$1 = Math.max,
  1504. nativeMin$1 = Math.min;
  1505. /**
  1506. * Gets the timestamp of the number of milliseconds that have elapsed since
  1507. * the Unix epoch (1 January 1970 00:00:00 UTC).
  1508. *
  1509. * @static
  1510. * @memberOf _
  1511. * @since 2.4.0
  1512. * @category Date
  1513. * @returns {number} Returns the timestamp.
  1514. * @example
  1515. *
  1516. * _.defer(function(stamp) {
  1517. * console.log(_.now() - stamp);
  1518. * }, _.now());
  1519. * // => Logs the number of milliseconds it took for the deferred invocation.
  1520. */
  1521. var now$1 = function() {
  1522. return root$1.Date.now();
  1523. };
  1524. /**
  1525. * Creates a debounced function that delays invoking `func` until after `wait`
  1526. * milliseconds have elapsed since the last time the debounced function was
  1527. * invoked. The debounced function comes with a `cancel` method to cancel
  1528. * delayed `func` invocations and a `flush` method to immediately invoke them.
  1529. * Provide `options` to indicate whether `func` should be invoked on the
  1530. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  1531. * with the last arguments provided to the debounced function. Subsequent
  1532. * calls to the debounced function return the result of the last `func`
  1533. * invocation.
  1534. *
  1535. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  1536. * invoked on the trailing edge of the timeout only if the debounced function
  1537. * is invoked more than once during the `wait` timeout.
  1538. *
  1539. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  1540. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  1541. *
  1542. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  1543. * for details over the differences between `_.debounce` and `_.throttle`.
  1544. *
  1545. * @static
  1546. * @memberOf _
  1547. * @since 0.1.0
  1548. * @category Function
  1549. * @param {Function} func The function to debounce.
  1550. * @param {number} [wait=0] The number of milliseconds to delay.
  1551. * @param {Object} [options={}] The options object.
  1552. * @param {boolean} [options.leading=false]
  1553. * Specify invoking on the leading edge of the timeout.
  1554. * @param {number} [options.maxWait]
  1555. * The maximum time `func` is allowed to be delayed before it's invoked.
  1556. * @param {boolean} [options.trailing=true]
  1557. * Specify invoking on the trailing edge of the timeout.
  1558. * @returns {Function} Returns the new debounced function.
  1559. * @example
  1560. *
  1561. * // Avoid costly calculations while the window size is in flux.
  1562. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  1563. *
  1564. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  1565. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  1566. * 'leading': true,
  1567. * 'trailing': false
  1568. * }));
  1569. *
  1570. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  1571. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  1572. * var source = new EventSource('/stream');
  1573. * jQuery(source).on('message', debounced);
  1574. *
  1575. * // Cancel the trailing debounced invocation.
  1576. * jQuery(window).on('popstate', debounced.cancel);
  1577. */
  1578. function debounce$1(func, wait, options) {
  1579. var lastArgs,
  1580. lastThis,
  1581. maxWait,
  1582. result,
  1583. timerId,
  1584. lastCallTime,
  1585. lastInvokeTime = 0,
  1586. leading = false,
  1587. maxing = false,
  1588. trailing = true;
  1589. if (typeof func != 'function') {
  1590. throw new TypeError(FUNC_ERROR_TEXT$1);
  1591. }
  1592. wait = toNumber$1(wait) || 0;
  1593. if (isObject$2(options)) {
  1594. leading = !!options.leading;
  1595. maxing = 'maxWait' in options;
  1596. maxWait = maxing ? nativeMax$1(toNumber$1(options.maxWait) || 0, wait) : maxWait;
  1597. trailing = 'trailing' in options ? !!options.trailing : trailing;
  1598. }
  1599. function invokeFunc(time) {
  1600. var args = lastArgs,
  1601. thisArg = lastThis;
  1602. lastArgs = lastThis = undefined;
  1603. lastInvokeTime = time;
  1604. result = func.apply(thisArg, args);
  1605. return result;
  1606. }
  1607. function leadingEdge(time) {
  1608. // Reset any `maxWait` timer.
  1609. lastInvokeTime = time;
  1610. // Start the timer for the trailing edge.
  1611. timerId = setTimeout(timerExpired, wait);
  1612. // Invoke the leading edge.
  1613. return leading ? invokeFunc(time) : result;
  1614. }
  1615. function remainingWait(time) {
  1616. var timeSinceLastCall = time - lastCallTime,
  1617. timeSinceLastInvoke = time - lastInvokeTime,
  1618. result = wait - timeSinceLastCall;
  1619. return maxing ? nativeMin$1(result, maxWait - timeSinceLastInvoke) : result;
  1620. }
  1621. function shouldInvoke(time) {
  1622. var timeSinceLastCall = time - lastCallTime,
  1623. timeSinceLastInvoke = time - lastInvokeTime;
  1624. // Either this is the first call, activity has stopped and we're at the
  1625. // trailing edge, the system time has gone backwards and we're treating
  1626. // it as the trailing edge, or we've hit the `maxWait` limit.
  1627. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  1628. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  1629. }
  1630. function timerExpired() {
  1631. var time = now$1();
  1632. if (shouldInvoke(time)) {
  1633. return trailingEdge(time);
  1634. }
  1635. // Restart the timer.
  1636. timerId = setTimeout(timerExpired, remainingWait(time));
  1637. }
  1638. function trailingEdge(time) {
  1639. timerId = undefined;
  1640. // Only invoke if we have `lastArgs` which means `func` has been
  1641. // debounced at least once.
  1642. if (trailing && lastArgs) {
  1643. return invokeFunc(time);
  1644. }
  1645. lastArgs = lastThis = undefined;
  1646. return result;
  1647. }
  1648. function cancel() {
  1649. if (timerId !== undefined) {
  1650. clearTimeout(timerId);
  1651. }
  1652. lastInvokeTime = 0;
  1653. lastArgs = lastCallTime = lastThis = timerId = undefined;
  1654. }
  1655. function flush() {
  1656. return timerId === undefined ? result : trailingEdge(now$1());
  1657. }
  1658. function debounced() {
  1659. var time = now$1(),
  1660. isInvoking = shouldInvoke(time);
  1661. lastArgs = arguments;
  1662. lastThis = this;
  1663. lastCallTime = time;
  1664. if (isInvoking) {
  1665. if (timerId === undefined) {
  1666. return leadingEdge(lastCallTime);
  1667. }
  1668. if (maxing) {
  1669. // Handle invocations in a tight loop.
  1670. timerId = setTimeout(timerExpired, wait);
  1671. return invokeFunc(lastCallTime);
  1672. }
  1673. }
  1674. if (timerId === undefined) {
  1675. timerId = setTimeout(timerExpired, wait);
  1676. }
  1677. return result;
  1678. }
  1679. debounced.cancel = cancel;
  1680. debounced.flush = flush;
  1681. return debounced;
  1682. }
  1683. /**
  1684. * Checks if `value` is the
  1685. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  1686. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  1687. *
  1688. * @static
  1689. * @memberOf _
  1690. * @since 0.1.0
  1691. * @category Lang
  1692. * @param {*} value The value to check.
  1693. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  1694. * @example
  1695. *
  1696. * _.isObject({});
  1697. * // => true
  1698. *
  1699. * _.isObject([1, 2, 3]);
  1700. * // => true
  1701. *
  1702. * _.isObject(_.noop);
  1703. * // => true
  1704. *
  1705. * _.isObject(null);
  1706. * // => false
  1707. */
  1708. function isObject$2(value) {
  1709. var type = typeof value;
  1710. return !!value && (type == 'object' || type == 'function');
  1711. }
  1712. /**
  1713. * Checks if `value` is object-like. A value is object-like if it's not `null`
  1714. * and has a `typeof` result of "object".
  1715. *
  1716. * @static
  1717. * @memberOf _
  1718. * @since 4.0.0
  1719. * @category Lang
  1720. * @param {*} value The value to check.
  1721. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  1722. * @example
  1723. *
  1724. * _.isObjectLike({});
  1725. * // => true
  1726. *
  1727. * _.isObjectLike([1, 2, 3]);
  1728. * // => true
  1729. *
  1730. * _.isObjectLike(_.noop);
  1731. * // => false
  1732. *
  1733. * _.isObjectLike(null);
  1734. * // => false
  1735. */
  1736. function isObjectLike$1(value) {
  1737. return !!value && typeof value == 'object';
  1738. }
  1739. /**
  1740. * Checks if `value` is classified as a `Symbol` primitive or object.
  1741. *
  1742. * @static
  1743. * @memberOf _
  1744. * @since 4.0.0
  1745. * @category Lang
  1746. * @param {*} value The value to check.
  1747. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  1748. * @example
  1749. *
  1750. * _.isSymbol(Symbol.iterator);
  1751. * // => true
  1752. *
  1753. * _.isSymbol('abc');
  1754. * // => false
  1755. */
  1756. function isSymbol$1(value) {
  1757. return typeof value == 'symbol' ||
  1758. (isObjectLike$1(value) && objectToString$1.call(value) == symbolTag$1);
  1759. }
  1760. /**
  1761. * Converts `value` to a number.
  1762. *
  1763. * @static
  1764. * @memberOf _
  1765. * @since 4.0.0
  1766. * @category Lang
  1767. * @param {*} value The value to process.
  1768. * @returns {number} Returns the number.
  1769. * @example
  1770. *
  1771. * _.toNumber(3.2);
  1772. * // => 3.2
  1773. *
  1774. * _.toNumber(Number.MIN_VALUE);
  1775. * // => 5e-324
  1776. *
  1777. * _.toNumber(Infinity);
  1778. * // => Infinity
  1779. *
  1780. * _.toNumber('3.2');
  1781. * // => 3.2
  1782. */
  1783. function toNumber$1(value) {
  1784. if (typeof value == 'number') {
  1785. return value;
  1786. }
  1787. if (isSymbol$1(value)) {
  1788. return NAN$1;
  1789. }
  1790. if (isObject$2(value)) {
  1791. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  1792. value = isObject$2(other) ? (other + '') : other;
  1793. }
  1794. if (typeof value != 'string') {
  1795. return value === 0 ? value : +value;
  1796. }
  1797. value = value.replace(reTrim$1, '');
  1798. var isBinary = reIsBinary$1.test(value);
  1799. return (isBinary || reIsOctal$1.test(value))
  1800. ? freeParseInt$1(value.slice(2), isBinary ? 2 : 8)
  1801. : (reIsBadHex$1.test(value) ? NAN$1 : +value);
  1802. }
  1803. var lodash_debounce = debounce$1;
  1804. /**
  1805. * lodash (Custom Build) <https://lodash.com/>
  1806. * Build: `lodash modularize exports="npm" -o ./`
  1807. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  1808. * Released under MIT license <https://lodash.com/license>
  1809. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  1810. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  1811. */
  1812. /** Used as the `TypeError` message for "Functions" methods. */
  1813. var FUNC_ERROR_TEXT$2 = 'Expected a function';
  1814. /** Used to stand-in for `undefined` hash values. */
  1815. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  1816. /** `Object#toString` result references. */
  1817. var funcTag = '[object Function]',
  1818. genTag = '[object GeneratorFunction]';
  1819. /**
  1820. * Used to match `RegExp`
  1821. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  1822. */
  1823. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  1824. /** Used to detect host constructors (Safari). */
  1825. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  1826. /** Detect free variable `global` from Node.js. */
  1827. var freeGlobal$2 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
  1828. /** Detect free variable `self`. */
  1829. var freeSelf$2 = typeof self == 'object' && self && self.Object === Object && self;
  1830. /** Used as a reference to the global object. */
  1831. var root$2 = freeGlobal$2 || freeSelf$2 || Function('return this')();
  1832. /**
  1833. * Gets the value at `key` of `object`.
  1834. *
  1835. * @private
  1836. * @param {Object} [object] The object to query.
  1837. * @param {string} key The key of the property to get.
  1838. * @returns {*} Returns the property value.
  1839. */
  1840. function getValue(object, key) {
  1841. return object == null ? undefined : object[key];
  1842. }
  1843. /**
  1844. * Checks if `value` is a host object in IE < 9.
  1845. *
  1846. * @private
  1847. * @param {*} value The value to check.
  1848. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  1849. */
  1850. function isHostObject(value) {
  1851. // Many host objects are `Object` objects that can coerce to strings
  1852. // despite having improperly defined `toString` methods.
  1853. var result = false;
  1854. if (value != null && typeof value.toString != 'function') {
  1855. try {
  1856. result = !!(value + '');
  1857. } catch (e) {}
  1858. }
  1859. return result;
  1860. }
  1861. /** Used for built-in method references. */
  1862. var arrayProto = Array.prototype,
  1863. funcProto = Function.prototype,
  1864. objectProto$2 = Object.prototype;
  1865. /** Used to detect overreaching core-js shims. */
  1866. var coreJsData = root$2['__core-js_shared__'];
  1867. /** Used to detect methods masquerading as native. */
  1868. var maskSrcKey = (function() {
  1869. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  1870. return uid ? ('Symbol(src)_1.' + uid) : '';
  1871. }());
  1872. /** Used to resolve the decompiled source of functions. */
  1873. var funcToString = funcProto.toString;
  1874. /** Used to check objects for own properties. */
  1875. var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
  1876. /**
  1877. * Used to resolve the
  1878. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  1879. * of values.
  1880. */
  1881. var objectToString$2 = objectProto$2.toString;
  1882. /** Used to detect if a method is native. */
  1883. var reIsNative = RegExp('^' +
  1884. funcToString.call(hasOwnProperty$1).replace(reRegExpChar, '\\$&')
  1885. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  1886. );
  1887. /** Built-in value references. */
  1888. var splice = arrayProto.splice;
  1889. /* Built-in method references that are verified to be native. */
  1890. var Map$1 = getNative(root$2, 'Map'),
  1891. nativeCreate = getNative(Object, 'create');
  1892. /**
  1893. * Creates a hash object.
  1894. *
  1895. * @private
  1896. * @constructor
  1897. * @param {Array} [entries] The key-value pairs to cache.
  1898. */
  1899. function Hash(entries) {
  1900. var index = -1,
  1901. length = entries ? entries.length : 0;
  1902. this.clear();
  1903. while (++index < length) {
  1904. var entry = entries[index];
  1905. this.set(entry[0], entry[1]);
  1906. }
  1907. }
  1908. /**
  1909. * Removes all key-value entries from the hash.
  1910. *
  1911. * @private
  1912. * @name clear
  1913. * @memberOf Hash
  1914. */
  1915. function hashClear() {
  1916. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  1917. }
  1918. /**
  1919. * Removes `key` and its value from the hash.
  1920. *
  1921. * @private
  1922. * @name delete
  1923. * @memberOf Hash
  1924. * @param {Object} hash The hash to modify.
  1925. * @param {string} key The key of the value to remove.
  1926. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  1927. */
  1928. function hashDelete(key) {
  1929. return this.has(key) && delete this.__data__[key];
  1930. }
  1931. /**
  1932. * Gets the hash value for `key`.
  1933. *
  1934. * @private
  1935. * @name get
  1936. * @memberOf Hash
  1937. * @param {string} key The key of the value to get.
  1938. * @returns {*} Returns the entry value.
  1939. */
  1940. function hashGet(key) {
  1941. var data = this.__data__;
  1942. if (nativeCreate) {
  1943. var result = data[key];
  1944. return result === HASH_UNDEFINED ? undefined : result;
  1945. }
  1946. return hasOwnProperty$1.call(data, key) ? data[key] : undefined;
  1947. }
  1948. /**
  1949. * Checks if a hash value for `key` exists.
  1950. *
  1951. * @private
  1952. * @name has
  1953. * @memberOf Hash
  1954. * @param {string} key The key of the entry to check.
  1955. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1956. */
  1957. function hashHas(key) {
  1958. var data = this.__data__;
  1959. return nativeCreate ? data[key] !== undefined : hasOwnProperty$1.call(data, key);
  1960. }
  1961. /**
  1962. * Sets the hash `key` to `value`.
  1963. *
  1964. * @private
  1965. * @name set
  1966. * @memberOf Hash
  1967. * @param {string} key The key of the value to set.
  1968. * @param {*} value The value to set.
  1969. * @returns {Object} Returns the hash instance.
  1970. */
  1971. function hashSet(key, value) {
  1972. var data = this.__data__;
  1973. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  1974. return this;
  1975. }
  1976. // Add methods to `Hash`.
  1977. Hash.prototype.clear = hashClear;
  1978. Hash.prototype['delete'] = hashDelete;
  1979. Hash.prototype.get = hashGet;
  1980. Hash.prototype.has = hashHas;
  1981. Hash.prototype.set = hashSet;
  1982. /**
  1983. * Creates an list cache object.
  1984. *
  1985. * @private
  1986. * @constructor
  1987. * @param {Array} [entries] The key-value pairs to cache.
  1988. */
  1989. function ListCache(entries) {
  1990. var index = -1,
  1991. length = entries ? entries.length : 0;
  1992. this.clear();
  1993. while (++index < length) {
  1994. var entry = entries[index];
  1995. this.set(entry[0], entry[1]);
  1996. }
  1997. }
  1998. /**
  1999. * Removes all key-value entries from the list cache.
  2000. *
  2001. * @private
  2002. * @name clear
  2003. * @memberOf ListCache
  2004. */
  2005. function listCacheClear() {
  2006. this.__data__ = [];
  2007. }
  2008. /**
  2009. * Removes `key` and its value from the list cache.
  2010. *
  2011. * @private
  2012. * @name delete
  2013. * @memberOf ListCache
  2014. * @param {string} key The key of the value to remove.
  2015. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2016. */
  2017. function listCacheDelete(key) {
  2018. var data = this.__data__,
  2019. index = assocIndexOf(data, key);
  2020. if (index < 0) {
  2021. return false;
  2022. }
  2023. var lastIndex = data.length - 1;
  2024. if (index == lastIndex) {
  2025. data.pop();
  2026. } else {
  2027. splice.call(data, index, 1);
  2028. }
  2029. return true;
  2030. }
  2031. /**
  2032. * Gets the list cache value for `key`.
  2033. *
  2034. * @private
  2035. * @name get
  2036. * @memberOf ListCache
  2037. * @param {string} key The key of the value to get.
  2038. * @returns {*} Returns the entry value.
  2039. */
  2040. function listCacheGet(key) {
  2041. var data = this.__data__,
  2042. index = assocIndexOf(data, key);
  2043. return index < 0 ? undefined : data[index][1];
  2044. }
  2045. /**
  2046. * Checks if a list cache value for `key` exists.
  2047. *
  2048. * @private
  2049. * @name has
  2050. * @memberOf ListCache
  2051. * @param {string} key The key of the entry to check.
  2052. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2053. */
  2054. function listCacheHas(key) {
  2055. return assocIndexOf(this.__data__, key) > -1;
  2056. }
  2057. /**
  2058. * Sets the list cache `key` to `value`.
  2059. *
  2060. * @private
  2061. * @name set
  2062. * @memberOf ListCache
  2063. * @param {string} key The key of the value to set.
  2064. * @param {*} value The value to set.
  2065. * @returns {Object} Returns the list cache instance.
  2066. */
  2067. function listCacheSet(key, value) {
  2068. var data = this.__data__,
  2069. index = assocIndexOf(data, key);
  2070. if (index < 0) {
  2071. data.push([key, value]);
  2072. } else {
  2073. data[index][1] = value;
  2074. }
  2075. return this;
  2076. }
  2077. // Add methods to `ListCache`.
  2078. ListCache.prototype.clear = listCacheClear;
  2079. ListCache.prototype['delete'] = listCacheDelete;
  2080. ListCache.prototype.get = listCacheGet;
  2081. ListCache.prototype.has = listCacheHas;
  2082. ListCache.prototype.set = listCacheSet;
  2083. /**
  2084. * Creates a map cache object to store key-value pairs.
  2085. *
  2086. * @private
  2087. * @constructor
  2088. * @param {Array} [entries] The key-value pairs to cache.
  2089. */
  2090. function MapCache(entries) {
  2091. var index = -1,
  2092. length = entries ? entries.length : 0;
  2093. this.clear();
  2094. while (++index < length) {
  2095. var entry = entries[index];
  2096. this.set(entry[0], entry[1]);
  2097. }
  2098. }
  2099. /**
  2100. * Removes all key-value entries from the map.
  2101. *
  2102. * @private
  2103. * @name clear
  2104. * @memberOf MapCache
  2105. */
  2106. function mapCacheClear() {
  2107. this.__data__ = {
  2108. 'hash': new Hash,
  2109. 'map': new (Map$1 || ListCache),
  2110. 'string': new Hash
  2111. };
  2112. }
  2113. /**
  2114. * Removes `key` and its value from the map.
  2115. *
  2116. * @private
  2117. * @name delete
  2118. * @memberOf MapCache
  2119. * @param {string} key The key of the value to remove.
  2120. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2121. */
  2122. function mapCacheDelete(key) {
  2123. return getMapData(this, key)['delete'](key);
  2124. }
  2125. /**
  2126. * Gets the map value for `key`.
  2127. *
  2128. * @private
  2129. * @name get
  2130. * @memberOf MapCache
  2131. * @param {string} key The key of the value to get.
  2132. * @returns {*} Returns the entry value.
  2133. */
  2134. function mapCacheGet(key) {
  2135. return getMapData(this, key).get(key);
  2136. }
  2137. /**
  2138. * Checks if a map value for `key` exists.
  2139. *
  2140. * @private
  2141. * @name has
  2142. * @memberOf MapCache
  2143. * @param {string} key The key of the entry to check.
  2144. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2145. */
  2146. function mapCacheHas(key) {
  2147. return getMapData(this, key).has(key);
  2148. }
  2149. /**
  2150. * Sets the map `key` to `value`.
  2151. *
  2152. * @private
  2153. * @name set
  2154. * @memberOf MapCache
  2155. * @param {string} key The key of the value to set.
  2156. * @param {*} value The value to set.
  2157. * @returns {Object} Returns the map cache instance.
  2158. */
  2159. function mapCacheSet(key, value) {
  2160. getMapData(this, key).set(key, value);
  2161. return this;
  2162. }
  2163. // Add methods to `MapCache`.
  2164. MapCache.prototype.clear = mapCacheClear;
  2165. MapCache.prototype['delete'] = mapCacheDelete;
  2166. MapCache.prototype.get = mapCacheGet;
  2167. MapCache.prototype.has = mapCacheHas;
  2168. MapCache.prototype.set = mapCacheSet;
  2169. /**
  2170. * Gets the index at which the `key` is found in `array` of key-value pairs.
  2171. *
  2172. * @private
  2173. * @param {Array} array The array to inspect.
  2174. * @param {*} key The key to search for.
  2175. * @returns {number} Returns the index of the matched value, else `-1`.
  2176. */
  2177. function assocIndexOf(array, key) {
  2178. var length = array.length;
  2179. while (length--) {
  2180. if (eq(array[length][0], key)) {
  2181. return length;
  2182. }
  2183. }
  2184. return -1;
  2185. }
  2186. /**
  2187. * The base implementation of `_.isNative` without bad shim checks.
  2188. *
  2189. * @private
  2190. * @param {*} value The value to check.
  2191. * @returns {boolean} Returns `true` if `value` is a native function,
  2192. * else `false`.
  2193. */
  2194. function baseIsNative(value) {
  2195. if (!isObject$3(value) || isMasked(value)) {
  2196. return false;
  2197. }
  2198. var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
  2199. return pattern.test(toSource(value));
  2200. }
  2201. /**
  2202. * Gets the data for `map`.
  2203. *
  2204. * @private
  2205. * @param {Object} map The map to query.
  2206. * @param {string} key The reference key.
  2207. * @returns {*} Returns the map data.
  2208. */
  2209. function getMapData(map, key) {
  2210. var data = map.__data__;
  2211. return isKeyable(key)
  2212. ? data[typeof key == 'string' ? 'string' : 'hash']
  2213. : data.map;
  2214. }
  2215. /**
  2216. * Gets the native function at `key` of `object`.
  2217. *
  2218. * @private
  2219. * @param {Object} object The object to query.
  2220. * @param {string} key The key of the method to get.
  2221. * @returns {*} Returns the function if it's native, else `undefined`.
  2222. */
  2223. function getNative(object, key) {
  2224. var value = getValue(object, key);
  2225. return baseIsNative(value) ? value : undefined;
  2226. }
  2227. /**
  2228. * Checks if `value` is suitable for use as unique object key.
  2229. *
  2230. * @private
  2231. * @param {*} value The value to check.
  2232. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  2233. */
  2234. function isKeyable(value) {
  2235. var type = typeof value;
  2236. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  2237. ? (value !== '__proto__')
  2238. : (value === null);
  2239. }
  2240. /**
  2241. * Checks if `func` has its source masked.
  2242. *
  2243. * @private
  2244. * @param {Function} func The function to check.
  2245. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  2246. */
  2247. function isMasked(func) {
  2248. return !!maskSrcKey && (maskSrcKey in func);
  2249. }
  2250. /**
  2251. * Converts `func` to its source code.
  2252. *
  2253. * @private
  2254. * @param {Function} func The function to process.
  2255. * @returns {string} Returns the source code.
  2256. */
  2257. function toSource(func) {
  2258. if (func != null) {
  2259. try {
  2260. return funcToString.call(func);
  2261. } catch (e) {}
  2262. try {
  2263. return (func + '');
  2264. } catch (e) {}
  2265. }
  2266. return '';
  2267. }
  2268. /**
  2269. * Creates a function that memoizes the result of `func`. If `resolver` is
  2270. * provided, it determines the cache key for storing the result based on the
  2271. * arguments provided to the memoized function. By default, the first argument
  2272. * provided to the memoized function is used as the map cache key. The `func`
  2273. * is invoked with the `this` binding of the memoized function.
  2274. *
  2275. * **Note:** The cache is exposed as the `cache` property on the memoized
  2276. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  2277. * constructor with one whose instances implement the
  2278. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  2279. * method interface of `delete`, `get`, `has`, and `set`.
  2280. *
  2281. * @static
  2282. * @memberOf _
  2283. * @since 0.1.0
  2284. * @category Function
  2285. * @param {Function} func The function to have its output memoized.
  2286. * @param {Function} [resolver] The function to resolve the cache key.
  2287. * @returns {Function} Returns the new memoized function.
  2288. * @example
  2289. *
  2290. * var object = { 'a': 1, 'b': 2 };
  2291. * var other = { 'c': 3, 'd': 4 };
  2292. *
  2293. * var values = _.memoize(_.values);
  2294. * values(object);
  2295. * // => [1, 2]
  2296. *
  2297. * values(other);
  2298. * // => [3, 4]
  2299. *
  2300. * object.a = 2;
  2301. * values(object);
  2302. * // => [1, 2]
  2303. *
  2304. * // Modify the result cache.
  2305. * values.cache.set(object, ['a', 'b']);
  2306. * values(object);
  2307. * // => ['a', 'b']
  2308. *
  2309. * // Replace `_.memoize.Cache`.
  2310. * _.memoize.Cache = WeakMap;
  2311. */
  2312. function memoize(func, resolver) {
  2313. if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
  2314. throw new TypeError(FUNC_ERROR_TEXT$2);
  2315. }
  2316. var memoized = function() {
  2317. var args = arguments,
  2318. key = resolver ? resolver.apply(this, args) : args[0],
  2319. cache = memoized.cache;
  2320. if (cache.has(key)) {
  2321. return cache.get(key);
  2322. }
  2323. var result = func.apply(this, args);
  2324. memoized.cache = cache.set(key, result);
  2325. return result;
  2326. };
  2327. memoized.cache = new (memoize.Cache || MapCache);
  2328. return memoized;
  2329. }
  2330. // Assign cache to `_.memoize`.
  2331. memoize.Cache = MapCache;
  2332. /**
  2333. * Performs a
  2334. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  2335. * comparison between two values to determine if they are equivalent.
  2336. *
  2337. * @static
  2338. * @memberOf _
  2339. * @since 4.0.0
  2340. * @category Lang
  2341. * @param {*} value The value to compare.
  2342. * @param {*} other The other value to compare.
  2343. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  2344. * @example
  2345. *
  2346. * var object = { 'a': 1 };
  2347. * var other = { 'a': 1 };
  2348. *
  2349. * _.eq(object, object);
  2350. * // => true
  2351. *
  2352. * _.eq(object, other);
  2353. * // => false
  2354. *
  2355. * _.eq('a', 'a');
  2356. * // => true
  2357. *
  2358. * _.eq('a', Object('a'));
  2359. * // => false
  2360. *
  2361. * _.eq(NaN, NaN);
  2362. * // => true
  2363. */
  2364. function eq(value, other) {
  2365. return value === other || (value !== value && other !== other);
  2366. }
  2367. /**
  2368. * Checks if `value` is classified as a `Function` object.
  2369. *
  2370. * @static
  2371. * @memberOf _
  2372. * @since 0.1.0
  2373. * @category Lang
  2374. * @param {*} value The value to check.
  2375. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  2376. * @example
  2377. *
  2378. * _.isFunction(_);
  2379. * // => true
  2380. *
  2381. * _.isFunction(/abc/);
  2382. * // => false
  2383. */
  2384. function isFunction(value) {
  2385. // The use of `Object#toString` avoids issues with the `typeof` operator
  2386. // in Safari 8-9 which returns 'object' for typed array and other constructors.
  2387. var tag = isObject$3(value) ? objectToString$2.call(value) : '';
  2388. return tag == funcTag || tag == genTag;
  2389. }
  2390. /**
  2391. * Checks if `value` is the
  2392. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  2393. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  2394. *
  2395. * @static
  2396. * @memberOf _
  2397. * @since 0.1.0
  2398. * @category Lang
  2399. * @param {*} value The value to check.
  2400. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  2401. * @example
  2402. *
  2403. * _.isObject({});
  2404. * // => true
  2405. *
  2406. * _.isObject([1, 2, 3]);
  2407. * // => true
  2408. *
  2409. * _.isObject(_.noop);
  2410. * // => true
  2411. *
  2412. * _.isObject(null);
  2413. * // => false
  2414. */
  2415. function isObject$3(value) {
  2416. var type = typeof value;
  2417. return !!value && (type == 'object' || type == 'function');
  2418. }
  2419. var lodash_memoize = memoize;
  2420. /**
  2421. * A collection of shims that provide minimal functionality of the ES6 collections.
  2422. *
  2423. * These implementations are not meant to be used outside of the ResizeObserver
  2424. * modules as they cover only a limited range of use cases.
  2425. */
  2426. /* eslint-disable require-jsdoc, valid-jsdoc */
  2427. var MapShim = (function () {
  2428. if (typeof Map !== 'undefined') {
  2429. return Map;
  2430. }
  2431. /**
  2432. * Returns index in provided array that matches the specified key.
  2433. *
  2434. * @param {Array<Array>} arr
  2435. * @param {*} key
  2436. * @returns {number}
  2437. */
  2438. function getIndex(arr, key) {
  2439. var result = -1;
  2440. arr.some(function (entry, index) {
  2441. if (entry[0] === key) {
  2442. result = index;
  2443. return true;
  2444. }
  2445. return false;
  2446. });
  2447. return result;
  2448. }
  2449. return /** @class */ (function () {
  2450. function class_1() {
  2451. this.__entries__ = [];
  2452. }
  2453. Object.defineProperty(class_1.prototype, "size", {
  2454. /**
  2455. * @returns {boolean}
  2456. */
  2457. get: function () {
  2458. return this.__entries__.length;
  2459. },
  2460. enumerable: true,
  2461. configurable: true
  2462. });
  2463. /**
  2464. * @param {*} key
  2465. * @returns {*}
  2466. */
  2467. class_1.prototype.get = function (key) {
  2468. var index = getIndex(this.__entries__, key);
  2469. var entry = this.__entries__[index];
  2470. return entry && entry[1];
  2471. };
  2472. /**
  2473. * @param {*} key
  2474. * @param {*} value
  2475. * @returns {void}
  2476. */
  2477. class_1.prototype.set = function (key, value) {
  2478. var index = getIndex(this.__entries__, key);
  2479. if (~index) {
  2480. this.__entries__[index][1] = value;
  2481. }
  2482. else {
  2483. this.__entries__.push([key, value]);
  2484. }
  2485. };
  2486. /**
  2487. * @param {*} key
  2488. * @returns {void}
  2489. */
  2490. class_1.prototype.delete = function (key) {
  2491. var entries = this.__entries__;
  2492. var index = getIndex(entries, key);
  2493. if (~index) {
  2494. entries.splice(index, 1);
  2495. }
  2496. };
  2497. /**
  2498. * @param {*} key
  2499. * @returns {void}
  2500. */
  2501. class_1.prototype.has = function (key) {
  2502. return !!~getIndex(this.__entries__, key);
  2503. };
  2504. /**
  2505. * @returns {void}
  2506. */
  2507. class_1.prototype.clear = function () {
  2508. this.__entries__.splice(0);
  2509. };
  2510. /**
  2511. * @param {Function} callback
  2512. * @param {*} [ctx=null]
  2513. * @returns {void}
  2514. */
  2515. class_1.prototype.forEach = function (callback, ctx) {
  2516. if (ctx === void 0) { ctx = null; }
  2517. for (var _i = 0, _a = this.__entries__; _i < _a.length; _i++) {
  2518. var entry = _a[_i];
  2519. callback.call(ctx, entry[1], entry[0]);
  2520. }
  2521. };
  2522. return class_1;
  2523. }());
  2524. })();
  2525. /**
  2526. * Detects whether window and document objects are available in current environment.
  2527. */
  2528. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && window.document === document;
  2529. // Returns global object of a current environment.
  2530. var global$1$1 = (function () {
  2531. if (typeof global !== 'undefined' && global.Math === Math) {
  2532. return global;
  2533. }
  2534. if (typeof self !== 'undefined' && self.Math === Math) {
  2535. return self;
  2536. }
  2537. if (typeof window !== 'undefined' && window.Math === Math) {
  2538. return window;
  2539. }
  2540. // eslint-disable-next-line no-new-func
  2541. return Function('return this')();
  2542. })();
  2543. /**
  2544. * A shim for the requestAnimationFrame which falls back to the setTimeout if
  2545. * first one is not supported.
  2546. *
  2547. * @returns {number} Requests' identifier.
  2548. */
  2549. var requestAnimationFrame$1 = (function () {
  2550. if (typeof requestAnimationFrame === 'function') {
  2551. // It's required to use a bounded function because IE sometimes throws
  2552. // an "Invalid calling object" error if rAF is invoked without the global
  2553. // object on the left hand side.
  2554. return requestAnimationFrame.bind(global$1$1);
  2555. }
  2556. return function (callback) { return setTimeout(function () { return callback(Date.now()); }, 1000 / 60); };
  2557. })();
  2558. // Defines minimum timeout before adding a trailing call.
  2559. var trailingTimeout = 2;
  2560. /**
  2561. * Creates a wrapper function which ensures that provided callback will be
  2562. * invoked only once during the specified delay period.
  2563. *
  2564. * @param {Function} callback - Function to be invoked after the delay period.
  2565. * @param {number} delay - Delay after which to invoke callback.
  2566. * @returns {Function}
  2567. */
  2568. function throttle$1 (callback, delay) {
  2569. var leadingCall = false, trailingCall = false, lastCallTime = 0;
  2570. /**
  2571. * Invokes the original callback function and schedules new invocation if
  2572. * the "proxy" was called during current request.
  2573. *
  2574. * @returns {void}
  2575. */
  2576. function resolvePending() {
  2577. if (leadingCall) {
  2578. leadingCall = false;
  2579. callback();
  2580. }
  2581. if (trailingCall) {
  2582. proxy();
  2583. }
  2584. }
  2585. /**
  2586. * Callback invoked after the specified delay. It will further postpone
  2587. * invocation of the original function delegating it to the
  2588. * requestAnimationFrame.
  2589. *
  2590. * @returns {void}
  2591. */
  2592. function timeoutCallback() {
  2593. requestAnimationFrame$1(resolvePending);
  2594. }
  2595. /**
  2596. * Schedules invocation of the original function.
  2597. *
  2598. * @returns {void}
  2599. */
  2600. function proxy() {
  2601. var timeStamp = Date.now();
  2602. if (leadingCall) {
  2603. // Reject immediately following calls.
  2604. if (timeStamp - lastCallTime < trailingTimeout) {
  2605. return;
  2606. }
  2607. // Schedule new call to be in invoked when the pending one is resolved.
  2608. // This is important for "transitions" which never actually start
  2609. // immediately so there is a chance that we might miss one if change
  2610. // happens amids the pending invocation.
  2611. trailingCall = true;
  2612. }
  2613. else {
  2614. leadingCall = true;
  2615. trailingCall = false;
  2616. setTimeout(timeoutCallback, delay);
  2617. }
  2618. lastCallTime = timeStamp;
  2619. }
  2620. return proxy;
  2621. }
  2622. // Minimum delay before invoking the update of observers.
  2623. var REFRESH_DELAY = 20;
  2624. // A list of substrings of CSS properties used to find transition events that
  2625. // might affect dimensions of observed elements.
  2626. var transitionKeys = ['top', 'right', 'bottom', 'left', 'width', 'height', 'size', 'weight'];
  2627. // Check if MutationObserver is available.
  2628. var mutationObserverSupported = typeof MutationObserver !== 'undefined';
  2629. /**
  2630. * Singleton controller class which handles updates of ResizeObserver instances.
  2631. */
  2632. var ResizeObserverController = /** @class */ (function () {
  2633. /**
  2634. * Creates a new instance of ResizeObserverController.
  2635. *
  2636. * @private
  2637. */
  2638. function ResizeObserverController() {
  2639. /**
  2640. * Indicates whether DOM listeners have been added.
  2641. *
  2642. * @private {boolean}
  2643. */
  2644. this.connected_ = false;
  2645. /**
  2646. * Tells that controller has subscribed for Mutation Events.
  2647. *
  2648. * @private {boolean}
  2649. */
  2650. this.mutationEventsAdded_ = false;
  2651. /**
  2652. * Keeps reference to the instance of MutationObserver.
  2653. *
  2654. * @private {MutationObserver}
  2655. */
  2656. this.mutationsObserver_ = null;
  2657. /**
  2658. * A list of connected observers.
  2659. *
  2660. * @private {Array<ResizeObserverSPI>}
  2661. */
  2662. this.observers_ = [];
  2663. this.onTransitionEnd_ = this.onTransitionEnd_.bind(this);
  2664. this.refresh = throttle$1(this.refresh.bind(this), REFRESH_DELAY);
  2665. }
  2666. /**
  2667. * Adds observer to observers list.
  2668. *
  2669. * @param {ResizeObserverSPI} observer - Observer to be added.
  2670. * @returns {void}
  2671. */
  2672. ResizeObserverController.prototype.addObserver = function (observer) {
  2673. if (!~this.observers_.indexOf(observer)) {
  2674. this.observers_.push(observer);
  2675. }
  2676. // Add listeners if they haven't been added yet.
  2677. if (!this.connected_) {
  2678. this.connect_();
  2679. }
  2680. };
  2681. /**
  2682. * Removes observer from observers list.
  2683. *
  2684. * @param {ResizeObserverSPI} observer - Observer to be removed.
  2685. * @returns {void}
  2686. */
  2687. ResizeObserverController.prototype.removeObserver = function (observer) {
  2688. var observers = this.observers_;
  2689. var index = observers.indexOf(observer);
  2690. // Remove observer if it's present in registry.
  2691. if (~index) {
  2692. observers.splice(index, 1);
  2693. }
  2694. // Remove listeners if controller has no connected observers.
  2695. if (!observers.length && this.connected_) {
  2696. this.disconnect_();
  2697. }
  2698. };
  2699. /**
  2700. * Invokes the update of observers. It will continue running updates insofar
  2701. * it detects changes.
  2702. *
  2703. * @returns {void}
  2704. */
  2705. ResizeObserverController.prototype.refresh = function () {
  2706. var changesDetected = this.updateObservers_();
  2707. // Continue running updates if changes have been detected as there might
  2708. // be future ones caused by CSS transitions.
  2709. if (changesDetected) {
  2710. this.refresh();
  2711. }
  2712. };
  2713. /**
  2714. * Updates every observer from observers list and notifies them of queued
  2715. * entries.
  2716. *
  2717. * @private
  2718. * @returns {boolean} Returns "true" if any observer has detected changes in
  2719. * dimensions of it's elements.
  2720. */
  2721. ResizeObserverController.prototype.updateObservers_ = function () {
  2722. // Collect observers that have active observations.
  2723. var activeObservers = this.observers_.filter(function (observer) {
  2724. return observer.gatherActive(), observer.hasActive();
  2725. });
  2726. // Deliver notifications in a separate cycle in order to avoid any
  2727. // collisions between observers, e.g. when multiple instances of
  2728. // ResizeObserver are tracking the same element and the callback of one
  2729. // of them changes content dimensions of the observed target. Sometimes
  2730. // this may result in notifications being blocked for the rest of observers.
  2731. activeObservers.forEach(function (observer) { return observer.broadcastActive(); });
  2732. return activeObservers.length > 0;
  2733. };
  2734. /**
  2735. * Initializes DOM listeners.
  2736. *
  2737. * @private
  2738. * @returns {void}
  2739. */
  2740. ResizeObserverController.prototype.connect_ = function () {
  2741. // Do nothing if running in a non-browser environment or if listeners
  2742. // have been already added.
  2743. if (!isBrowser || this.connected_) {
  2744. return;
  2745. }
  2746. // Subscription to the "Transitionend" event is used as a workaround for
  2747. // delayed transitions. This way it's possible to capture at least the
  2748. // final state of an element.
  2749. document.addEventListener('transitionend', this.onTransitionEnd_);
  2750. window.addEventListener('resize', this.refresh);
  2751. if (mutationObserverSupported) {
  2752. this.mutationsObserver_ = new MutationObserver(this.refresh);
  2753. this.mutationsObserver_.observe(document, {
  2754. attributes: true,
  2755. childList: true,
  2756. characterData: true,
  2757. subtree: true
  2758. });
  2759. }
  2760. else {
  2761. document.addEventListener('DOMSubtreeModified', this.refresh);
  2762. this.mutationEventsAdded_ = true;
  2763. }
  2764. this.connected_ = true;
  2765. };
  2766. /**
  2767. * Removes DOM listeners.
  2768. *
  2769. * @private
  2770. * @returns {void}
  2771. */
  2772. ResizeObserverController.prototype.disconnect_ = function () {
  2773. // Do nothing if running in a non-browser environment or if listeners
  2774. // have been already removed.
  2775. if (!isBrowser || !this.connected_) {
  2776. return;
  2777. }
  2778. document.removeEventListener('transitionend', this.onTransitionEnd_);
  2779. window.removeEventListener('resize', this.refresh);
  2780. if (this.mutationsObserver_) {
  2781. this.mutationsObserver_.disconnect();
  2782. }
  2783. if (this.mutationEventsAdded_) {
  2784. document.removeEventListener('DOMSubtreeModified', this.refresh);
  2785. }
  2786. this.mutationsObserver_ = null;
  2787. this.mutationEventsAdded_ = false;
  2788. this.connected_ = false;
  2789. };
  2790. /**
  2791. * "Transitionend" event handler.
  2792. *
  2793. * @private
  2794. * @param {TransitionEvent} event
  2795. * @returns {void}
  2796. */
  2797. ResizeObserverController.prototype.onTransitionEnd_ = function (_a) {
  2798. var _b = _a.propertyName, propertyName = _b === void 0 ? '' : _b;
  2799. // Detect whether transition may affect dimensions of an element.
  2800. var isReflowProperty = transitionKeys.some(function (key) {
  2801. return !!~propertyName.indexOf(key);
  2802. });
  2803. if (isReflowProperty) {
  2804. this.refresh();
  2805. }
  2806. };
  2807. /**
  2808. * Returns instance of the ResizeObserverController.
  2809. *
  2810. * @returns {ResizeObserverController}
  2811. */
  2812. ResizeObserverController.getInstance = function () {
  2813. if (!this.instance_) {
  2814. this.instance_ = new ResizeObserverController();
  2815. }
  2816. return this.instance_;
  2817. };
  2818. /**
  2819. * Holds reference to the controller's instance.
  2820. *
  2821. * @private {ResizeObserverController}
  2822. */
  2823. ResizeObserverController.instance_ = null;
  2824. return ResizeObserverController;
  2825. }());
  2826. /**
  2827. * Defines non-writable/enumerable properties of the provided target object.
  2828. *
  2829. * @param {Object} target - Object for which to define properties.
  2830. * @param {Object} props - Properties to be defined.
  2831. * @returns {Object} Target object.
  2832. */
  2833. var defineConfigurable = (function (target, props) {
  2834. for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
  2835. var key = _a[_i];
  2836. Object.defineProperty(target, key, {
  2837. value: props[key],
  2838. enumerable: false,
  2839. writable: false,
  2840. configurable: true
  2841. });
  2842. }
  2843. return target;
  2844. });
  2845. /**
  2846. * Returns the global object associated with provided element.
  2847. *
  2848. * @param {Object} target
  2849. * @returns {Object}
  2850. */
  2851. var getWindowOf = (function (target) {
  2852. // Assume that the element is an instance of Node, which means that it
  2853. // has the "ownerDocument" property from which we can retrieve a
  2854. // corresponding global object.
  2855. var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
  2856. // Return the local global object if it's not possible extract one from
  2857. // provided element.
  2858. return ownerGlobal || global$1$1;
  2859. });
  2860. // Placeholder of an empty content rectangle.
  2861. var emptyRect = createRectInit(0, 0, 0, 0);
  2862. /**
  2863. * Converts provided string to a number.
  2864. *
  2865. * @param {number|string} value
  2866. * @returns {number}
  2867. */
  2868. function toFloat(value) {
  2869. return parseFloat(value) || 0;
  2870. }
  2871. /**
  2872. * Extracts borders size from provided styles.
  2873. *
  2874. * @param {CSSStyleDeclaration} styles
  2875. * @param {...string} positions - Borders positions (top, right, ...)
  2876. * @returns {number}
  2877. */
  2878. function getBordersSize(styles) {
  2879. var positions = [];
  2880. for (var _i = 1; _i < arguments.length; _i++) {
  2881. positions[_i - 1] = arguments[_i];
  2882. }
  2883. return positions.reduce(function (size, position) {
  2884. var value = styles['border-' + position + '-width'];
  2885. return size + toFloat(value);
  2886. }, 0);
  2887. }
  2888. /**
  2889. * Extracts paddings sizes from provided styles.
  2890. *
  2891. * @param {CSSStyleDeclaration} styles
  2892. * @returns {Object} Paddings box.
  2893. */
  2894. function getPaddings(styles) {
  2895. var positions = ['top', 'right', 'bottom', 'left'];
  2896. var paddings = {};
  2897. for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
  2898. var position = positions_1[_i];
  2899. var value = styles['padding-' + position];
  2900. paddings[position] = toFloat(value);
  2901. }
  2902. return paddings;
  2903. }
  2904. /**
  2905. * Calculates content rectangle of provided SVG element.
  2906. *
  2907. * @param {SVGGraphicsElement} target - Element content rectangle of which needs
  2908. * to be calculated.
  2909. * @returns {DOMRectInit}
  2910. */
  2911. function getSVGContentRect(target) {
  2912. var bbox = target.getBBox();
  2913. return createRectInit(0, 0, bbox.width, bbox.height);
  2914. }
  2915. /**
  2916. * Calculates content rectangle of provided HTMLElement.
  2917. *
  2918. * @param {HTMLElement} target - Element for which to calculate the content rectangle.
  2919. * @returns {DOMRectInit}
  2920. */
  2921. function getHTMLElementContentRect(target) {
  2922. // Client width & height properties can't be
  2923. // used exclusively as they provide rounded values.
  2924. var clientWidth = target.clientWidth, clientHeight = target.clientHeight;
  2925. // By this condition we can catch all non-replaced inline, hidden and
  2926. // detached elements. Though elements with width & height properties less
  2927. // than 0.5 will be discarded as well.
  2928. //
  2929. // Without it we would need to implement separate methods for each of
  2930. // those cases and it's not possible to perform a precise and performance
  2931. // effective test for hidden elements. E.g. even jQuery's ':visible' filter
  2932. // gives wrong results for elements with width & height less than 0.5.
  2933. if (!clientWidth && !clientHeight) {
  2934. return emptyRect;
  2935. }
  2936. var styles = getWindowOf(target).getComputedStyle(target);
  2937. var paddings = getPaddings(styles);
  2938. var horizPad = paddings.left + paddings.right;
  2939. var vertPad = paddings.top + paddings.bottom;
  2940. // Computed styles of width & height are being used because they are the
  2941. // only dimensions available to JS that contain non-rounded values. It could
  2942. // be possible to utilize the getBoundingClientRect if only it's data wasn't
  2943. // affected by CSS transformations let alone paddings, borders and scroll bars.
  2944. var width = toFloat(styles.width), height = toFloat(styles.height);
  2945. // Width & height include paddings and borders when the 'border-box' box
  2946. // model is applied (except for IE).
  2947. if (styles.boxSizing === 'border-box') {
  2948. // Following conditions are required to handle Internet Explorer which
  2949. // doesn't include paddings and borders to computed CSS dimensions.
  2950. //
  2951. // We can say that if CSS dimensions + paddings are equal to the "client"
  2952. // properties then it's either IE, and thus we don't need to subtract
  2953. // anything, or an element merely doesn't have paddings/borders styles.
  2954. if (Math.round(width + horizPad) !== clientWidth) {
  2955. width -= getBordersSize(styles, 'left', 'right') + horizPad;
  2956. }
  2957. if (Math.round(height + vertPad) !== clientHeight) {
  2958. height -= getBordersSize(styles, 'top', 'bottom') + vertPad;
  2959. }
  2960. }
  2961. // Following steps can't be applied to the document's root element as its
  2962. // client[Width/Height] properties represent viewport area of the window.
  2963. // Besides, it's as well not necessary as the <html> itself neither has
  2964. // rendered scroll bars nor it can be clipped.
  2965. if (!isDocumentElement(target)) {
  2966. // In some browsers (only in Firefox, actually) CSS width & height
  2967. // include scroll bars size which can be removed at this step as scroll
  2968. // bars are the only difference between rounded dimensions + paddings
  2969. // and "client" properties, though that is not always true in Chrome.
  2970. var vertScrollbar = Math.round(width + horizPad) - clientWidth;
  2971. var horizScrollbar = Math.round(height + vertPad) - clientHeight;
  2972. // Chrome has a rather weird rounding of "client" properties.
  2973. // E.g. for an element with content width of 314.2px it sometimes gives
  2974. // the client width of 315px and for the width of 314.7px it may give
  2975. // 314px. And it doesn't happen all the time. So just ignore this delta
  2976. // as a non-relevant.
  2977. if (Math.abs(vertScrollbar) !== 1) {
  2978. width -= vertScrollbar;
  2979. }
  2980. if (Math.abs(horizScrollbar) !== 1) {
  2981. height -= horizScrollbar;
  2982. }
  2983. }
  2984. return createRectInit(paddings.left, paddings.top, width, height);
  2985. }
  2986. /**
  2987. * Checks whether provided element is an instance of the SVGGraphicsElement.
  2988. *
  2989. * @param {Element} target - Element to be checked.
  2990. * @returns {boolean}
  2991. */
  2992. var isSVGGraphicsElement = (function () {
  2993. // Some browsers, namely IE and Edge, don't have the SVGGraphicsElement
  2994. // interface.
  2995. if (typeof SVGGraphicsElement !== 'undefined') {
  2996. return function (target) { return target instanceof getWindowOf(target).SVGGraphicsElement; };
  2997. }
  2998. // If it's so, then check that element is at least an instance of the
  2999. // SVGElement and that it has the "getBBox" method.
  3000. // eslint-disable-next-line no-extra-parens
  3001. return function (target) { return (target instanceof getWindowOf(target).SVGElement &&
  3002. typeof target.getBBox === 'function'); };
  3003. })();
  3004. /**
  3005. * Checks whether provided element is a document element (<html>).
  3006. *
  3007. * @param {Element} target - Element to be checked.
  3008. * @returns {boolean}
  3009. */
  3010. function isDocumentElement(target) {
  3011. return target === getWindowOf(target).document.documentElement;
  3012. }
  3013. /**
  3014. * Calculates an appropriate content rectangle for provided html or svg element.
  3015. *
  3016. * @param {Element} target - Element content rectangle of which needs to be calculated.
  3017. * @returns {DOMRectInit}
  3018. */
  3019. function getContentRect(target) {
  3020. if (!isBrowser) {
  3021. return emptyRect;
  3022. }
  3023. if (isSVGGraphicsElement(target)) {
  3024. return getSVGContentRect(target);
  3025. }
  3026. return getHTMLElementContentRect(target);
  3027. }
  3028. /**
  3029. * Creates rectangle with an interface of the DOMRectReadOnly.
  3030. * Spec: https://drafts.fxtf.org/geometry/#domrectreadonly
  3031. *
  3032. * @param {DOMRectInit} rectInit - Object with rectangle's x/y coordinates and dimensions.
  3033. * @returns {DOMRectReadOnly}
  3034. */
  3035. function createReadOnlyRect(_a) {
  3036. var x = _a.x, y = _a.y, width = _a.width, height = _a.height;
  3037. // If DOMRectReadOnly is available use it as a prototype for the rectangle.
  3038. var Constr = typeof DOMRectReadOnly !== 'undefined' ? DOMRectReadOnly : Object;
  3039. var rect = Object.create(Constr.prototype);
  3040. // Rectangle's properties are not writable and non-enumerable.
  3041. defineConfigurable(rect, {
  3042. x: x, y: y, width: width, height: height,
  3043. top: y,
  3044. right: x + width,
  3045. bottom: height + y,
  3046. left: x
  3047. });
  3048. return rect;
  3049. }
  3050. /**
  3051. * Creates DOMRectInit object based on the provided dimensions and the x/y coordinates.
  3052. * Spec: https://drafts.fxtf.org/geometry/#dictdef-domrectinit
  3053. *
  3054. * @param {number} x - X coordinate.
  3055. * @param {number} y - Y coordinate.
  3056. * @param {number} width - Rectangle's width.
  3057. * @param {number} height - Rectangle's height.
  3058. * @returns {DOMRectInit}
  3059. */
  3060. function createRectInit(x, y, width, height) {
  3061. return { x: x, y: y, width: width, height: height };
  3062. }
  3063. /**
  3064. * Class that is responsible for computations of the content rectangle of
  3065. * provided DOM element and for keeping track of it's changes.
  3066. */
  3067. var ResizeObservation = /** @class */ (function () {
  3068. /**
  3069. * Creates an instance of ResizeObservation.
  3070. *
  3071. * @param {Element} target - Element to be observed.
  3072. */
  3073. function ResizeObservation(target) {
  3074. /**
  3075. * Broadcasted width of content rectangle.
  3076. *
  3077. * @type {number}
  3078. */
  3079. this.broadcastWidth = 0;
  3080. /**
  3081. * Broadcasted height of content rectangle.
  3082. *
  3083. * @type {number}
  3084. */
  3085. this.broadcastHeight = 0;
  3086. /**
  3087. * Reference to the last observed content rectangle.
  3088. *
  3089. * @private {DOMRectInit}
  3090. */
  3091. this.contentRect_ = createRectInit(0, 0, 0, 0);
  3092. this.target = target;
  3093. }
  3094. /**
  3095. * Updates content rectangle and tells whether it's width or height properties
  3096. * have changed since the last broadcast.
  3097. *
  3098. * @returns {boolean}
  3099. */
  3100. ResizeObservation.prototype.isActive = function () {
  3101. var rect = getContentRect(this.target);
  3102. this.contentRect_ = rect;
  3103. return (rect.width !== this.broadcastWidth ||
  3104. rect.height !== this.broadcastHeight);
  3105. };
  3106. /**
  3107. * Updates 'broadcastWidth' and 'broadcastHeight' properties with a data
  3108. * from the corresponding properties of the last observed content rectangle.
  3109. *
  3110. * @returns {DOMRectInit} Last observed content rectangle.
  3111. */
  3112. ResizeObservation.prototype.broadcastRect = function () {
  3113. var rect = this.contentRect_;
  3114. this.broadcastWidth = rect.width;
  3115. this.broadcastHeight = rect.height;
  3116. return rect;
  3117. };
  3118. return ResizeObservation;
  3119. }());
  3120. var ResizeObserverEntry = /** @class */ (function () {
  3121. /**
  3122. * Creates an instance of ResizeObserverEntry.
  3123. *
  3124. * @param {Element} target - Element that is being observed.
  3125. * @param {DOMRectInit} rectInit - Data of the element's content rectangle.
  3126. */
  3127. function ResizeObserverEntry(target, rectInit) {
  3128. var contentRect = createReadOnlyRect(rectInit);
  3129. // According to the specification following properties are not writable
  3130. // and are also not enumerable in the native implementation.
  3131. //
  3132. // Property accessors are not being used as they'd require to define a
  3133. // private WeakMap storage which may cause memory leaks in browsers that
  3134. // don't support this type of collections.
  3135. defineConfigurable(this, { target: target, contentRect: contentRect });
  3136. }
  3137. return ResizeObserverEntry;
  3138. }());
  3139. var ResizeObserverSPI = /** @class */ (function () {
  3140. /**
  3141. * Creates a new instance of ResizeObserver.
  3142. *
  3143. * @param {ResizeObserverCallback} callback - Callback function that is invoked
  3144. * when one of the observed elements changes it's content dimensions.
  3145. * @param {ResizeObserverController} controller - Controller instance which
  3146. * is responsible for the updates of observer.
  3147. * @param {ResizeObserver} callbackCtx - Reference to the public
  3148. * ResizeObserver instance which will be passed to callback function.
  3149. */
  3150. function ResizeObserverSPI(callback, controller, callbackCtx) {
  3151. /**
  3152. * Collection of resize observations that have detected changes in dimensions
  3153. * of elements.
  3154. *
  3155. * @private {Array<ResizeObservation>}
  3156. */
  3157. this.activeObservations_ = [];
  3158. /**
  3159. * Registry of the ResizeObservation instances.
  3160. *
  3161. * @private {Map<Element, ResizeObservation>}
  3162. */
  3163. this.observations_ = new MapShim();
  3164. if (typeof callback !== 'function') {
  3165. throw new TypeError('The callback provided as parameter 1 is not a function.');
  3166. }
  3167. this.callback_ = callback;
  3168. this.controller_ = controller;
  3169. this.callbackCtx_ = callbackCtx;
  3170. }
  3171. /**
  3172. * Starts observing provided element.
  3173. *
  3174. * @param {Element} target - Element to be observed.
  3175. * @returns {void}
  3176. */
  3177. ResizeObserverSPI.prototype.observe = function (target) {
  3178. if (!arguments.length) {
  3179. throw new TypeError('1 argument required, but only 0 present.');
  3180. }
  3181. // Do nothing if current environment doesn't have the Element interface.
  3182. if (typeof Element === 'undefined' || !(Element instanceof Object)) {
  3183. return;
  3184. }
  3185. if (!(target instanceof getWindowOf(target).Element)) {
  3186. throw new TypeError('parameter 1 is not of type "Element".');
  3187. }
  3188. var observations = this.observations_;
  3189. // Do nothing if element is already being observed.
  3190. if (observations.has(target)) {
  3191. return;
  3192. }
  3193. observations.set(target, new ResizeObservation(target));
  3194. this.controller_.addObserver(this);
  3195. // Force the update of observations.
  3196. this.controller_.refresh();
  3197. };
  3198. /**
  3199. * Stops observing provided element.
  3200. *
  3201. * @param {Element} target - Element to stop observing.
  3202. * @returns {void}
  3203. */
  3204. ResizeObserverSPI.prototype.unobserve = function (target) {
  3205. if (!arguments.length) {
  3206. throw new TypeError('1 argument required, but only 0 present.');
  3207. }
  3208. // Do nothing if current environment doesn't have the Element interface.
  3209. if (typeof Element === 'undefined' || !(Element instanceof Object)) {
  3210. return;
  3211. }
  3212. if (!(target instanceof getWindowOf(target).Element)) {
  3213. throw new TypeError('parameter 1 is not of type "Element".');
  3214. }
  3215. var observations = this.observations_;
  3216. // Do nothing if element is not being observed.
  3217. if (!observations.has(target)) {
  3218. return;
  3219. }
  3220. observations.delete(target);
  3221. if (!observations.size) {
  3222. this.controller_.removeObserver(this);
  3223. }
  3224. };
  3225. /**
  3226. * Stops observing all elements.
  3227. *
  3228. * @returns {void}
  3229. */
  3230. ResizeObserverSPI.prototype.disconnect = function () {
  3231. this.clearActive();
  3232. this.observations_.clear();
  3233. this.controller_.removeObserver(this);
  3234. };
  3235. /**
  3236. * Collects observation instances the associated element of which has changed
  3237. * it's content rectangle.
  3238. *
  3239. * @returns {void}
  3240. */
  3241. ResizeObserverSPI.prototype.gatherActive = function () {
  3242. var _this = this;
  3243. this.clearActive();
  3244. this.observations_.forEach(function (observation) {
  3245. if (observation.isActive()) {
  3246. _this.activeObservations_.push(observation);
  3247. }
  3248. });
  3249. };
  3250. /**
  3251. * Invokes initial callback function with a list of ResizeObserverEntry
  3252. * instances collected from active resize observations.
  3253. *
  3254. * @returns {void}
  3255. */
  3256. ResizeObserverSPI.prototype.broadcastActive = function () {
  3257. // Do nothing if observer doesn't have active observations.
  3258. if (!this.hasActive()) {
  3259. return;
  3260. }
  3261. var ctx = this.callbackCtx_;
  3262. // Create ResizeObserverEntry instance for every active observation.
  3263. var entries = this.activeObservations_.map(function (observation) {
  3264. return new ResizeObserverEntry(observation.target, observation.broadcastRect());
  3265. });
  3266. this.callback_.call(ctx, entries, ctx);
  3267. this.clearActive();
  3268. };
  3269. /**
  3270. * Clears the collection of active observations.
  3271. *
  3272. * @returns {void}
  3273. */
  3274. ResizeObserverSPI.prototype.clearActive = function () {
  3275. this.activeObservations_.splice(0);
  3276. };
  3277. /**
  3278. * Tells whether observer has active observations.
  3279. *
  3280. * @returns {boolean}
  3281. */
  3282. ResizeObserverSPI.prototype.hasActive = function () {
  3283. return this.activeObservations_.length > 0;
  3284. };
  3285. return ResizeObserverSPI;
  3286. }());
  3287. // Registry of internal observers. If WeakMap is not available use current shim
  3288. // for the Map collection as it has all required methods and because WeakMap
  3289. // can't be fully polyfilled anyway.
  3290. var observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim();
  3291. /**
  3292. * ResizeObserver API. Encapsulates the ResizeObserver SPI implementation
  3293. * exposing only those methods and properties that are defined in the spec.
  3294. */
  3295. var ResizeObserver = /** @class */ (function () {
  3296. /**
  3297. * Creates a new instance of ResizeObserver.
  3298. *
  3299. * @param {ResizeObserverCallback} callback - Callback that is invoked when
  3300. * dimensions of the observed elements change.
  3301. */
  3302. function ResizeObserver(callback) {
  3303. if (!(this instanceof ResizeObserver)) {
  3304. throw new TypeError('Cannot call a class as a function.');
  3305. }
  3306. if (!arguments.length) {
  3307. throw new TypeError('1 argument required, but only 0 present.');
  3308. }
  3309. var controller = ResizeObserverController.getInstance();
  3310. var observer = new ResizeObserverSPI(callback, controller, this);
  3311. observers.set(this, observer);
  3312. }
  3313. return ResizeObserver;
  3314. }());
  3315. // Expose public methods of ResizeObserver.
  3316. [
  3317. 'observe',
  3318. 'unobserve',
  3319. 'disconnect'
  3320. ].forEach(function (method) {
  3321. ResizeObserver.prototype[method] = function () {
  3322. var _a;
  3323. return (_a = observers.get(this))[method].apply(_a, arguments);
  3324. };
  3325. });
  3326. var index = (function () {
  3327. // Export existing implementation if available.
  3328. if (typeof global$1$1.ResizeObserver !== 'undefined') {
  3329. return global$1$1.ResizeObserver;
  3330. }
  3331. return ResizeObserver;
  3332. })();
  3333. var canUseDOM = !!(
  3334. typeof window !== 'undefined' &&
  3335. window.document &&
  3336. window.document.createElement
  3337. );
  3338. var canUseDom = canUseDOM;
  3339. var SimpleBar =
  3340. /*#__PURE__*/
  3341. function () {
  3342. function SimpleBar(element, options) {
  3343. var _this = this;
  3344. this.onScroll = function () {
  3345. if (!_this.scrollXTicking) {
  3346. window.requestAnimationFrame(_this.scrollX);
  3347. _this.scrollXTicking = true;
  3348. }
  3349. if (!_this.scrollYTicking) {
  3350. window.requestAnimationFrame(_this.scrollY);
  3351. _this.scrollYTicking = true;
  3352. }
  3353. };
  3354. this.scrollX = function () {
  3355. if (_this.axis.x.isOverflowing) {
  3356. _this.showScrollbar('x');
  3357. _this.positionScrollbar('x');
  3358. }
  3359. _this.scrollXTicking = false;
  3360. };
  3361. this.scrollY = function () {
  3362. if (_this.axis.y.isOverflowing) {
  3363. _this.showScrollbar('y');
  3364. _this.positionScrollbar('y');
  3365. }
  3366. _this.scrollYTicking = false;
  3367. };
  3368. this.onMouseEnter = function () {
  3369. _this.showScrollbar('x');
  3370. _this.showScrollbar('y');
  3371. };
  3372. this.onMouseMove = function (e) {
  3373. _this.mouseX = e.clientX;
  3374. _this.mouseY = e.clientY;
  3375. if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
  3376. _this.onMouseMoveForAxis('x');
  3377. }
  3378. if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
  3379. _this.onMouseMoveForAxis('y');
  3380. }
  3381. };
  3382. this.onMouseLeave = function () {
  3383. _this.onMouseMove.cancel();
  3384. if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
  3385. _this.onMouseLeaveForAxis('x');
  3386. }
  3387. if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
  3388. _this.onMouseLeaveForAxis('y');
  3389. }
  3390. _this.mouseX = -1;
  3391. _this.mouseY = -1;
  3392. };
  3393. this.onWindowResize = function () {
  3394. // Recalculate scrollbarWidth in case it's a zoom
  3395. _this.scrollbarWidth = scrollbarWidth();
  3396. _this.hideNativeScrollbar();
  3397. };
  3398. this.hideScrollbars = function () {
  3399. _this.axis.x.track.rect = _this.axis.x.track.el.getBoundingClientRect();
  3400. _this.axis.y.track.rect = _this.axis.y.track.el.getBoundingClientRect();
  3401. if (!_this.isWithinBounds(_this.axis.y.track.rect)) {
  3402. _this.axis.y.scrollbar.el.classList.remove(_this.classNames.visible);
  3403. _this.axis.y.isVisible = false;
  3404. }
  3405. if (!_this.isWithinBounds(_this.axis.x.track.rect)) {
  3406. _this.axis.x.scrollbar.el.classList.remove(_this.classNames.visible);
  3407. _this.axis.x.isVisible = false;
  3408. }
  3409. };
  3410. this.onPointerEvent = function (e) {
  3411. var isWithinBoundsY, isWithinBoundsX;
  3412. _this.axis.x.scrollbar.rect = _this.axis.x.scrollbar.el.getBoundingClientRect();
  3413. _this.axis.y.scrollbar.rect = _this.axis.y.scrollbar.el.getBoundingClientRect();
  3414. if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
  3415. isWithinBoundsX = _this.isWithinBounds(_this.axis.x.scrollbar.rect);
  3416. }
  3417. if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
  3418. isWithinBoundsY = _this.isWithinBounds(_this.axis.y.scrollbar.rect);
  3419. } // If any pointer event is called on the scrollbar
  3420. if (isWithinBoundsY || isWithinBoundsX) {
  3421. // Preventing the event's default action stops text being
  3422. // selectable during the drag.
  3423. e.preventDefault(); // Prevent event leaking
  3424. e.stopPropagation();
  3425. if (e.type === 'mousedown') {
  3426. if (isWithinBoundsY) {
  3427. _this.onDragStart(e, 'y');
  3428. }
  3429. if (isWithinBoundsX) {
  3430. _this.onDragStart(e, 'x');
  3431. }
  3432. }
  3433. }
  3434. };
  3435. this.drag = function (e) {
  3436. var eventOffset;
  3437. var track = _this.axis[_this.draggedAxis].track;
  3438. var trackSize = track.rect[_this.axis[_this.draggedAxis].sizeAttr];
  3439. var scrollbar = _this.axis[_this.draggedAxis].scrollbar;
  3440. e.preventDefault();
  3441. e.stopPropagation();
  3442. if (_this.draggedAxis === 'y') {
  3443. eventOffset = e.pageY;
  3444. } else {
  3445. eventOffset = e.pageX;
  3446. } // Calculate how far the user's mouse is from the top/left of the scrollbar (minus the dragOffset).
  3447. var dragPos = eventOffset - track.rect[_this.axis[_this.draggedAxis].offsetAttr] - _this.axis[_this.draggedAxis].dragOffset; // Convert the mouse position into a percentage of the scrollbar height/width.
  3448. var dragPerc = dragPos / track.rect[_this.axis[_this.draggedAxis].sizeAttr]; // Scroll the content by the same percentage.
  3449. var scrollPos = dragPerc * _this.contentWrapperEl[_this.axis[_this.draggedAxis].scrollSizeAttr]; // Fix browsers inconsistency on RTL
  3450. if (_this.draggedAxis === 'x') {
  3451. scrollPos = _this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? scrollPos - (trackSize + scrollbar.size) : scrollPos;
  3452. scrollPos = _this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollPos : scrollPos;
  3453. }
  3454. _this.contentWrapperEl[_this.axis[_this.draggedAxis].scrollOffsetAttr] = scrollPos;
  3455. };
  3456. this.onEndDrag = function (e) {
  3457. e.preventDefault();
  3458. e.stopPropagation();
  3459. _this.el.classList.remove(_this.classNames.dragging);
  3460. document.removeEventListener('mousemove', _this.drag);
  3461. document.removeEventListener('mouseup', _this.onEndDrag);
  3462. };
  3463. this.el = element;
  3464. this.flashTimeout;
  3465. this.contentEl;
  3466. this.contentWrapperEl;
  3467. this.offsetEl;
  3468. this.maskEl;
  3469. this.globalObserver;
  3470. this.mutationObserver;
  3471. this.resizeObserver;
  3472. this.scrollbarWidth;
  3473. this.minScrollbarWidth = 20;
  3474. this.options = Object.assign({}, SimpleBar.defaultOptions, options);
  3475. this.classNames = Object.assign({}, SimpleBar.defaultOptions.classNames, this.options.classNames);
  3476. this.isRtl;
  3477. this.axis = {
  3478. x: {
  3479. scrollOffsetAttr: 'scrollLeft',
  3480. sizeAttr: 'width',
  3481. scrollSizeAttr: 'scrollWidth',
  3482. offsetAttr: 'left',
  3483. overflowAttr: 'overflowX',
  3484. dragOffset: 0,
  3485. isOverflowing: true,
  3486. isVisible: false,
  3487. forceVisible: false,
  3488. track: {},
  3489. scrollbar: {}
  3490. },
  3491. y: {
  3492. scrollOffsetAttr: 'scrollTop',
  3493. sizeAttr: 'height',
  3494. scrollSizeAttr: 'scrollHeight',
  3495. offsetAttr: 'top',
  3496. overflowAttr: 'overflowY',
  3497. dragOffset: 0,
  3498. isOverflowing: true,
  3499. isVisible: false,
  3500. forceVisible: false,
  3501. track: {},
  3502. scrollbar: {}
  3503. }
  3504. }; // Don't re-instantiate over an existing one
  3505. if (this.el.SimpleBar) {
  3506. return;
  3507. }
  3508. this.recalculate = lodash_throttle(this.recalculate.bind(this), 64);
  3509. this.onMouseMove = lodash_throttle(this.onMouseMove.bind(this), 64);
  3510. this.hideScrollbars = lodash_debounce(this.hideScrollbars.bind(this), this.options.timeout);
  3511. this.onWindowResize = lodash_debounce(this.onWindowResize.bind(this), 64, {
  3512. leading: true
  3513. });
  3514. SimpleBar.getRtlHelpers = lodash_memoize(SimpleBar.getRtlHelpers);
  3515. this.init();
  3516. }
  3517. /**
  3518. * Static properties
  3519. */
  3520. /**
  3521. * Helper to fix browsers inconsistency on RTL:
  3522. * - Firefox inverts the scrollbar initial position
  3523. * - IE11 inverts both scrollbar position and scrolling offset
  3524. * Directly inspired by @KingSora's OverlayScrollbars https://github.com/KingSora/OverlayScrollbars/blob/master/js/OverlayScrollbars.js#L1634
  3525. */
  3526. SimpleBar.getRtlHelpers = function getRtlHelpers() {
  3527. var dummyDiv = document.createElement('div');
  3528. dummyDiv.innerHTML = '<div class="hs-dummy-scrollbar-size"><div style="height: 200%; width: 200%; margin: 10px 0;"></div></div>';
  3529. var scrollbarDummyEl = dummyDiv.firstElementChild;
  3530. document.body.appendChild(scrollbarDummyEl);
  3531. var dummyContainerChild = scrollbarDummyEl.firstElementChild;
  3532. scrollbarDummyEl.scrollLeft = 0;
  3533. var dummyContainerOffset = SimpleBar.getOffset(scrollbarDummyEl);
  3534. var dummyContainerChildOffset = SimpleBar.getOffset(dummyContainerChild);
  3535. scrollbarDummyEl.scrollLeft = 999;
  3536. var dummyContainerScrollOffsetAfterScroll = SimpleBar.getOffset(dummyContainerChild);
  3537. return {
  3538. // determines if the scrolling is responding with negative values
  3539. isRtlScrollingInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left && dummyContainerChildOffset.left - dummyContainerScrollOffsetAfterScroll.left !== 0,
  3540. // determines if the origin scrollbar position is inverted or not (positioned on left or right)
  3541. isRtlScrollbarInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left
  3542. };
  3543. };
  3544. SimpleBar.initHtmlApi = function initHtmlApi() {
  3545. this.initDOMLoadedElements = this.initDOMLoadedElements.bind(this); // MutationObserver is IE11+
  3546. if (typeof MutationObserver !== 'undefined') {
  3547. // Mutation observer to observe dynamically added elements
  3548. this.globalObserver = new MutationObserver(function (mutations) {
  3549. mutations.forEach(function (mutation) {
  3550. Array.prototype.forEach.call(mutation.addedNodes, function (addedNode) {
  3551. if (addedNode.nodeType === 1) {
  3552. if (addedNode.hasAttribute('data-simplebar')) {
  3553. !addedNode.SimpleBar && new SimpleBar(addedNode, SimpleBar.getElOptions(addedNode));
  3554. } else {
  3555. Array.prototype.forEach.call(addedNode.querySelectorAll('[data-simplebar]'), function (el) {
  3556. !el.SimpleBar && new SimpleBar(el, SimpleBar.getElOptions(el));
  3557. });
  3558. }
  3559. }
  3560. });
  3561. Array.prototype.forEach.call(mutation.removedNodes, function (removedNode) {
  3562. if (removedNode.nodeType === 1) {
  3563. if (removedNode.hasAttribute('data-simplebar')) {
  3564. removedNode.SimpleBar && removedNode.SimpleBar.unMount();
  3565. } else {
  3566. Array.prototype.forEach.call(removedNode.querySelectorAll('[data-simplebar]'), function (el) {
  3567. el.SimpleBar && el.SimpleBar.unMount();
  3568. });
  3569. }
  3570. }
  3571. });
  3572. });
  3573. });
  3574. this.globalObserver.observe(document, {
  3575. childList: true,
  3576. subtree: true
  3577. });
  3578. } // Taken from jQuery `ready` function
  3579. // Instantiate elements already present on the page
  3580. if (document.readyState === 'complete' || document.readyState !== 'loading' && !document.documentElement.doScroll) {
  3581. // Handle it asynchronously to allow scripts the opportunity to delay init
  3582. window.setTimeout(this.initDOMLoadedElements);
  3583. } else {
  3584. document.addEventListener('DOMContentLoaded', this.initDOMLoadedElements);
  3585. window.addEventListener('load', this.initDOMLoadedElements);
  3586. }
  3587. } // Helper function to retrieve options from element attributes
  3588. ;
  3589. SimpleBar.getElOptions = function getElOptions(el) {
  3590. var options = Array.prototype.reduce.call(el.attributes, function (acc, attribute) {
  3591. var option = attribute.name.match(/data-simplebar-(.+)/);
  3592. if (option) {
  3593. var key = option[1].replace(/\W+(.)/g, function (x, chr) {
  3594. return chr.toUpperCase();
  3595. });
  3596. switch (attribute.value) {
  3597. case 'true':
  3598. acc[key] = true;
  3599. break;
  3600. case 'false':
  3601. acc[key] = false;
  3602. break;
  3603. case undefined:
  3604. acc[key] = true;
  3605. break;
  3606. default:
  3607. acc[key] = attribute.value;
  3608. }
  3609. }
  3610. return acc;
  3611. }, {});
  3612. return options;
  3613. };
  3614. SimpleBar.removeObserver = function removeObserver() {
  3615. this.globalObserver.disconnect();
  3616. };
  3617. SimpleBar.initDOMLoadedElements = function initDOMLoadedElements() {
  3618. document.removeEventListener('DOMContentLoaded', this.initDOMLoadedElements);
  3619. window.removeEventListener('load', this.initDOMLoadedElements);
  3620. Array.prototype.forEach.call(document.querySelectorAll('[data-simplebar]'), function (el) {
  3621. if (!el.SimpleBar) new SimpleBar(el, SimpleBar.getElOptions(el));
  3622. });
  3623. };
  3624. SimpleBar.getOffset = function getOffset(el) {
  3625. var rect = el.getBoundingClientRect();
  3626. return {
  3627. top: rect.top + (window.pageYOffset || document.documentElement.scrollTop),
  3628. left: rect.left + (window.pageXOffset || document.documentElement.scrollLeft)
  3629. };
  3630. };
  3631. var _proto = SimpleBar.prototype;
  3632. _proto.init = function init() {
  3633. // Save a reference to the instance, so we know this DOM node has already been instancied
  3634. this.el.SimpleBar = this; // We stop here on server-side
  3635. if (canUseDom) {
  3636. this.initDOM();
  3637. this.scrollbarWidth = scrollbarWidth();
  3638. this.recalculate();
  3639. this.initListeners();
  3640. }
  3641. };
  3642. _proto.initDOM = function initDOM() {
  3643. var _this2 = this;
  3644. // make sure this element doesn't have the elements yet
  3645. if (Array.prototype.filter.call(this.el.children, function (child) {
  3646. return child.classList.contains(_this2.classNames.wrapper);
  3647. }).length) {
  3648. // assume that element has his DOM already initiated
  3649. this.wrapperEl = this.el.querySelector("." + this.classNames.wrapper);
  3650. this.contentWrapperEl = this.el.querySelector("." + this.classNames.contentWrapper);
  3651. this.offsetEl = this.el.querySelector("." + this.classNames.offset);
  3652. this.maskEl = this.el.querySelector("." + this.classNames.mask);
  3653. this.contentEl = this.el.querySelector("." + this.classNames.contentEl);
  3654. this.placeholderEl = this.el.querySelector("." + this.classNames.placeholder);
  3655. this.heightAutoObserverWrapperEl = this.el.querySelector("." + this.classNames.heightAutoObserverWrapperEl);
  3656. this.heightAutoObserverEl = this.el.querySelector("." + this.classNames.heightAutoObserverEl);
  3657. this.axis.x.track.el = this.el.querySelector("." + this.classNames.track + "." + this.classNames.horizontal);
  3658. this.axis.y.track.el = this.el.querySelector("." + this.classNames.track + "." + this.classNames.vertical);
  3659. } else {
  3660. // Prepare DOM
  3661. this.wrapperEl = document.createElement('div');
  3662. this.contentWrapperEl = document.createElement('div');
  3663. this.offsetEl = document.createElement('div');
  3664. this.maskEl = document.createElement('div');
  3665. this.contentEl = document.createElement('div');
  3666. this.placeholderEl = document.createElement('div');
  3667. this.heightAutoObserverWrapperEl = document.createElement('div');
  3668. this.heightAutoObserverEl = document.createElement('div');
  3669. this.wrapperEl.classList.add(this.classNames.wrapper);
  3670. this.contentWrapperEl.classList.add(this.classNames.contentWrapper);
  3671. this.offsetEl.classList.add(this.classNames.offset);
  3672. this.maskEl.classList.add(this.classNames.mask);
  3673. this.contentEl.classList.add(this.classNames.contentEl);
  3674. this.placeholderEl.classList.add(this.classNames.placeholder);
  3675. this.heightAutoObserverWrapperEl.classList.add(this.classNames.heightAutoObserverWrapperEl);
  3676. this.heightAutoObserverEl.classList.add(this.classNames.heightAutoObserverEl);
  3677. while (this.el.firstChild) {
  3678. this.contentEl.appendChild(this.el.firstChild);
  3679. }
  3680. this.contentWrapperEl.appendChild(this.contentEl);
  3681. this.offsetEl.appendChild(this.contentWrapperEl);
  3682. this.maskEl.appendChild(this.offsetEl);
  3683. this.heightAutoObserverWrapperEl.appendChild(this.heightAutoObserverEl);
  3684. this.wrapperEl.appendChild(this.heightAutoObserverWrapperEl);
  3685. this.wrapperEl.appendChild(this.maskEl);
  3686. this.wrapperEl.appendChild(this.placeholderEl);
  3687. this.el.appendChild(this.wrapperEl);
  3688. }
  3689. if (!this.axis.x.track.el || !this.axis.y.track.el) {
  3690. var track = document.createElement('div');
  3691. var scrollbar = document.createElement('div');
  3692. track.classList.add(this.classNames.track);
  3693. scrollbar.classList.add(this.classNames.scrollbar);
  3694. track.appendChild(scrollbar);
  3695. this.axis.x.track.el = track.cloneNode(true);
  3696. this.axis.x.track.el.classList.add(this.classNames.horizontal);
  3697. this.axis.y.track.el = track.cloneNode(true);
  3698. this.axis.y.track.el.classList.add(this.classNames.vertical);
  3699. this.el.appendChild(this.axis.x.track.el);
  3700. this.el.appendChild(this.axis.y.track.el);
  3701. }
  3702. this.axis.x.scrollbar.el = this.axis.x.track.el.querySelector("." + this.classNames.scrollbar);
  3703. this.axis.y.scrollbar.el = this.axis.y.track.el.querySelector("." + this.classNames.scrollbar);
  3704. if (!this.options.autoHide) {
  3705. this.axis.x.scrollbar.el.classList.add(this.classNames.visible);
  3706. this.axis.y.scrollbar.el.classList.add(this.classNames.visible);
  3707. }
  3708. this.el.setAttribute('data-simplebar', 'init');
  3709. };
  3710. _proto.initListeners = function initListeners() {
  3711. var _this3 = this;
  3712. // Event listeners
  3713. if (this.options.autoHide) {
  3714. this.el.addEventListener('mouseenter', this.onMouseEnter);
  3715. }
  3716. ['mousedown', 'click', 'dblclick', 'touchstart', 'touchend', 'touchmove'].forEach(function (e) {
  3717. _this3.el.addEventListener(e, _this3.onPointerEvent, true);
  3718. });
  3719. this.el.addEventListener('mousemove', this.onMouseMove);
  3720. this.el.addEventListener('mouseleave', this.onMouseLeave);
  3721. this.contentWrapperEl.addEventListener('scroll', this.onScroll); // Browser zoom triggers a window resize
  3722. window.addEventListener('resize', this.onWindowResize);
  3723. this.resizeObserver = new index(this.recalculate);
  3724. this.resizeObserver.observe(this.el);
  3725. this.resizeObserver.observe(this.contentEl);
  3726. };
  3727. _proto.recalculate = function recalculate() {
  3728. var isHeightAuto = this.heightAutoObserverEl.offsetHeight <= 1;
  3729. var isWidthAuto = this.heightAutoObserverEl.offsetWidth <= 1;
  3730. this.elStyles = window.getComputedStyle(this.el);
  3731. this.isRtl = this.elStyles.direction === 'rtl';
  3732. this.contentEl.style.padding = this.elStyles.paddingTop + " " + this.elStyles.paddingRight + " " + this.elStyles.paddingBottom + " " + this.elStyles.paddingLeft;
  3733. this.wrapperEl.style.margin = "-" + this.elStyles.paddingTop + " -" + this.elStyles.paddingRight + " -" + this.elStyles.paddingBottom + " -" + this.elStyles.paddingLeft;
  3734. this.contentWrapperEl.style.height = isHeightAuto ? 'auto' : '100%'; // Determine placeholder size
  3735. this.placeholderEl.style.width = isWidthAuto ? this.contentEl.offsetWidth + "px" : 'auto';
  3736. this.placeholderEl.style.height = this.contentEl.scrollHeight + "px"; // Set isOverflowing to false if scrollbar is not necessary (content is shorter than offset)
  3737. this.axis.x.isOverflowing = this.contentWrapperEl.scrollWidth > this.contentWrapperEl.offsetWidth;
  3738. this.axis.y.isOverflowing = this.contentWrapperEl.scrollHeight > this.contentWrapperEl.offsetHeight; // Set isOverflowing to false if user explicitely set hidden overflow
  3739. this.axis.x.isOverflowing = this.elStyles.overflowX === 'hidden' ? false : this.axis.x.isOverflowing;
  3740. this.axis.y.isOverflowing = this.elStyles.overflowY === 'hidden' ? false : this.axis.y.isOverflowing;
  3741. this.axis.x.forceVisible = this.options.forceVisible === 'x' || this.options.forceVisible === true;
  3742. this.axis.y.forceVisible = this.options.forceVisible === 'y' || this.options.forceVisible === true;
  3743. this.hideNativeScrollbar();
  3744. this.axis.x.track.rect = this.axis.x.track.el.getBoundingClientRect();
  3745. this.axis.y.track.rect = this.axis.y.track.el.getBoundingClientRect();
  3746. this.axis.x.scrollbar.size = this.getScrollbarSize('x');
  3747. this.axis.y.scrollbar.size = this.getScrollbarSize('y');
  3748. this.axis.x.scrollbar.el.style.width = this.axis.x.scrollbar.size + "px";
  3749. this.axis.y.scrollbar.el.style.height = this.axis.y.scrollbar.size + "px";
  3750. this.positionScrollbar('x');
  3751. this.positionScrollbar('y');
  3752. this.toggleTrackVisibility('x');
  3753. this.toggleTrackVisibility('y');
  3754. }
  3755. /**
  3756. * Calculate scrollbar size
  3757. */
  3758. ;
  3759. _proto.getScrollbarSize = function getScrollbarSize(axis) {
  3760. if (axis === void 0) {
  3761. axis = 'y';
  3762. }
  3763. var contentSize = this.scrollbarWidth ? this.contentWrapperEl[this.axis[axis].scrollSizeAttr] : this.contentWrapperEl[this.axis[axis].scrollSizeAttr] - this.minScrollbarWidth;
  3764. var trackSize = this.axis[axis].track.rect[this.axis[axis].sizeAttr];
  3765. var scrollbarSize;
  3766. if (!this.axis[axis].isOverflowing) {
  3767. return;
  3768. }
  3769. var scrollbarRatio = trackSize / contentSize; // Calculate new height/position of drag handle.
  3770. scrollbarSize = Math.max(~~(scrollbarRatio * trackSize), this.options.scrollbarMinSize);
  3771. if (this.options.scrollbarMaxSize) {
  3772. scrollbarSize = Math.min(scrollbarSize, this.options.scrollbarMaxSize);
  3773. }
  3774. return scrollbarSize;
  3775. };
  3776. _proto.positionScrollbar = function positionScrollbar(axis) {
  3777. if (axis === void 0) {
  3778. axis = 'y';
  3779. }
  3780. var contentSize = this.contentWrapperEl[this.axis[axis].scrollSizeAttr];
  3781. var trackSize = this.axis[axis].track.rect[this.axis[axis].sizeAttr];
  3782. var hostSize = parseInt(this.elStyles[this.axis[axis].sizeAttr], 10);
  3783. var scrollbar = this.axis[axis].scrollbar;
  3784. var scrollOffset = this.contentWrapperEl[this.axis[axis].scrollOffsetAttr];
  3785. scrollOffset = axis === 'x' && this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollOffset : scrollOffset;
  3786. var scrollPourcent = scrollOffset / (contentSize - hostSize);
  3787. var handleOffset = ~~((trackSize - scrollbar.size) * scrollPourcent);
  3788. handleOffset = axis === 'x' && this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? handleOffset + (trackSize - scrollbar.size) : handleOffset;
  3789. scrollbar.el.style.transform = axis === 'x' ? "translate3d(" + handleOffset + "px, 0, 0)" : "translate3d(0, " + handleOffset + "px, 0)";
  3790. };
  3791. _proto.toggleTrackVisibility = function toggleTrackVisibility(axis) {
  3792. if (axis === void 0) {
  3793. axis = 'y';
  3794. }
  3795. var track = this.axis[axis].track.el;
  3796. var scrollbar = this.axis[axis].scrollbar.el;
  3797. if (this.axis[axis].isOverflowing || this.axis[axis].forceVisible) {
  3798. track.style.visibility = 'visible';
  3799. this.contentWrapperEl.style[this.axis[axis].overflowAttr] = 'scroll';
  3800. } else {
  3801. track.style.visibility = 'hidden';
  3802. this.contentWrapperEl.style[this.axis[axis].overflowAttr] = 'hidden';
  3803. } // Even if forceVisible is enabled, scrollbar itself should be hidden
  3804. if (this.axis[axis].isOverflowing) {
  3805. scrollbar.style.display = 'block';
  3806. } else {
  3807. scrollbar.style.display = 'none';
  3808. }
  3809. };
  3810. _proto.hideNativeScrollbar = function hideNativeScrollbar() {
  3811. this.offsetEl.style[this.isRtl ? 'left' : 'right'] = this.axis.y.isOverflowing || this.axis.y.forceVisible ? "-" + (this.scrollbarWidth || this.minScrollbarWidth) + "px" : 0;
  3812. this.offsetEl.style.bottom = this.axis.x.isOverflowing || this.axis.x.forceVisible ? "-" + (this.scrollbarWidth || this.minScrollbarWidth) + "px" : 0; // If floating scrollbar
  3813. if (!this.scrollbarWidth) {
  3814. var paddingDirection = [this.isRtl ? 'paddingLeft' : 'paddingRight'];
  3815. this.contentWrapperEl.style[paddingDirection] = this.axis.y.isOverflowing || this.axis.y.forceVisible ? this.minScrollbarWidth + "px" : 0;
  3816. this.contentWrapperEl.style.paddingBottom = this.axis.x.isOverflowing || this.axis.x.forceVisible ? this.minScrollbarWidth + "px" : 0;
  3817. }
  3818. }
  3819. /**
  3820. * On scroll event handling
  3821. */
  3822. ;
  3823. _proto.onMouseMoveForAxis = function onMouseMoveForAxis(axis) {
  3824. if (axis === void 0) {
  3825. axis = 'y';
  3826. }
  3827. this.axis[axis].track.rect = this.axis[axis].track.el.getBoundingClientRect();
  3828. this.axis[axis].scrollbar.rect = this.axis[axis].scrollbar.el.getBoundingClientRect();
  3829. var isWithinScrollbarBoundsX = this.isWithinBounds(this.axis[axis].scrollbar.rect);
  3830. if (isWithinScrollbarBoundsX) {
  3831. this.axis[axis].scrollbar.el.classList.add(this.classNames.hover);
  3832. } else {
  3833. this.axis[axis].scrollbar.el.classList.remove(this.classNames.hover);
  3834. }
  3835. if (this.isWithinBounds(this.axis[axis].track.rect)) {
  3836. this.showScrollbar(axis);
  3837. this.axis[axis].track.el.classList.add(this.classNames.hover);
  3838. } else {
  3839. this.axis[axis].track.el.classList.remove(this.classNames.hover);
  3840. }
  3841. };
  3842. _proto.onMouseLeaveForAxis = function onMouseLeaveForAxis(axis) {
  3843. if (axis === void 0) {
  3844. axis = 'y';
  3845. }
  3846. this.axis[axis].track.el.classList.remove(this.classNames.hover);
  3847. this.axis[axis].scrollbar.el.classList.remove(this.classNames.hover);
  3848. };
  3849. /**
  3850. * Show scrollbar
  3851. */
  3852. _proto.showScrollbar = function showScrollbar(axis) {
  3853. if (axis === void 0) {
  3854. axis = 'y';
  3855. }
  3856. var scrollbar = this.axis[axis].scrollbar.el;
  3857. if (!this.axis[axis].isVisible) {
  3858. scrollbar.classList.add(this.classNames.visible);
  3859. this.axis[axis].isVisible = true;
  3860. }
  3861. if (this.options.autoHide) {
  3862. this.hideScrollbars();
  3863. }
  3864. }
  3865. /**
  3866. * Hide Scrollbar
  3867. */
  3868. ;
  3869. /**
  3870. * on scrollbar handle drag movement starts
  3871. */
  3872. _proto.onDragStart = function onDragStart(e, axis) {
  3873. if (axis === void 0) {
  3874. axis = 'y';
  3875. }
  3876. var scrollbar = this.axis[axis].scrollbar.el; // Measure how far the user's mouse is from the top of the scrollbar drag handle.
  3877. var eventOffset = axis === 'y' ? e.pageY : e.pageX;
  3878. this.axis[axis].dragOffset = eventOffset - scrollbar.getBoundingClientRect()[this.axis[axis].offsetAttr];
  3879. this.draggedAxis = axis;
  3880. this.el.classList.add(this.classNames.dragging);
  3881. document.addEventListener('mousemove', this.drag);
  3882. document.addEventListener('mouseup', this.onEndDrag);
  3883. }
  3884. /**
  3885. * Drag scrollbar handle
  3886. */
  3887. ;
  3888. /**
  3889. * Getter for content element
  3890. */
  3891. _proto.getContentElement = function getContentElement() {
  3892. return this.contentEl;
  3893. }
  3894. /**
  3895. * Getter for original scrolling element
  3896. */
  3897. ;
  3898. _proto.getScrollElement = function getScrollElement() {
  3899. return this.contentWrapperEl;
  3900. };
  3901. _proto.removeListeners = function removeListeners() {
  3902. var _this4 = this;
  3903. // Event listeners
  3904. if (this.options.autoHide) {
  3905. this.el.removeEventListener('mouseenter', this.onMouseEnter);
  3906. }
  3907. ['mousedown', 'click', 'dblclick', 'touchstart', 'touchend', 'touchmove'].forEach(function (e) {
  3908. _this4.el.removeEventListener(e, _this4.onPointerEvent);
  3909. });
  3910. this.el.removeEventListener('mousemove', this.onMouseMove);
  3911. this.el.removeEventListener('mouseleave', this.onMouseLeave);
  3912. this.contentWrapperEl.removeEventListener('scroll', this.onScroll);
  3913. window.removeEventListener('resize', this.onWindowResize);
  3914. this.mutationObserver && this.mutationObserver.disconnect();
  3915. this.resizeObserver.disconnect(); // Cancel all debounced functions
  3916. this.recalculate.cancel();
  3917. this.onMouseMove.cancel();
  3918. this.hideScrollbars.cancel();
  3919. this.onWindowResize.cancel();
  3920. }
  3921. /**
  3922. * UnMount mutation observer and delete SimpleBar instance from DOM element
  3923. */
  3924. ;
  3925. _proto.unMount = function unMount() {
  3926. this.removeListeners();
  3927. this.el.SimpleBar = null;
  3928. }
  3929. /**
  3930. * Recursively walks up the parent nodes looking for this.el
  3931. */
  3932. ;
  3933. _proto.isChildNode = function isChildNode(el) {
  3934. if (el === null) return false;
  3935. if (el === this.el) return true;
  3936. return this.isChildNode(el.parentNode);
  3937. }
  3938. /**
  3939. * Check if mouse is within bounds
  3940. */
  3941. ;
  3942. _proto.isWithinBounds = function isWithinBounds(bbox) {
  3943. return this.mouseX >= bbox.left && this.mouseX <= bbox.left + bbox.width && this.mouseY >= bbox.top && this.mouseY <= bbox.top + bbox.height;
  3944. };
  3945. return SimpleBar;
  3946. }();
  3947. /**
  3948. * HTML API
  3949. * Called only in a browser env.
  3950. */
  3951. SimpleBar.defaultOptions = {
  3952. autoHide: true,
  3953. forceVisible: false,
  3954. classNames: {
  3955. contentEl: 'simplebar-content',
  3956. contentWrapper: 'simplebar-content-wrapper',
  3957. offset: 'simplebar-offset',
  3958. mask: 'simplebar-mask',
  3959. wrapper: 'simplebar-wrapper',
  3960. placeholder: 'simplebar-placeholder',
  3961. scrollbar: 'simplebar-scrollbar',
  3962. track: 'simplebar-track',
  3963. heightAutoObserverWrapperEl: 'simplebar-height-auto-observer-wrapper',
  3964. heightAutoObserverEl: 'simplebar-height-auto-observer',
  3965. visible: 'simplebar-visible',
  3966. horizontal: 'simplebar-horizontal',
  3967. vertical: 'simplebar-vertical',
  3968. hover: 'simplebar-hover',
  3969. dragging: 'simplebar-dragging'
  3970. },
  3971. scrollbarMinSize: 25,
  3972. scrollbarMaxSize: 0,
  3973. timeout: 1000
  3974. };
  3975. if (canUseDom) {
  3976. SimpleBar.initHtmlApi();
  3977. }
  3978. return SimpleBar;
  3979. }));