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