1;(function() { 2 3 if (typeof window.BX === 'function') 4 { 5 return; 6 } 7 8/** 9 * Babel external helpers 10 * (c) 2018 Babel 11 * @license MIT 12 */ 13(function (global) { 14 var babelHelpers = global.babelHelpers = {}; 15 16 function _typeof(obj) { 17 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 18 babelHelpers.typeof = _typeof = function (obj) { 19 return typeof obj; 20 }; 21 } else { 22 babelHelpers.typeof = _typeof = function (obj) { 23 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 24 }; 25 } 26 27 return _typeof(obj); 28 } 29 30 babelHelpers.typeof = _typeof; 31 var REACT_ELEMENT_TYPE; 32 33 function _createRawReactElement(type, props, key, children) { 34 if (!REACT_ELEMENT_TYPE) { 35 REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; 36 } 37 38 var defaultProps = type && type.defaultProps; 39 var childrenLength = arguments.length - 3; 40 41 if (!props && childrenLength !== 0) { 42 props = { 43 children: void 0 44 }; 45 } 46 47 if (props && defaultProps) { 48 for (var propName in defaultProps) { 49 if (props[propName] === void 0) { 50 props[propName] = defaultProps[propName]; 51 } 52 } 53 } else if (!props) { 54 props = defaultProps || {}; 55 } 56 57 if (childrenLength === 1) { 58 props.children = children; 59 } else if (childrenLength > 1) { 60 var childArray = new Array(childrenLength); 61 62 for (var i = 0; i < childrenLength; i++) { 63 childArray[i] = arguments[i + 3]; 64 } 65 66 props.children = childArray; 67 } 68 69 return { 70 $$typeof: REACT_ELEMENT_TYPE, 71 type: type, 72 key: key === undefined ? null : '' + key, 73 ref: null, 74 props: props, 75 _owner: null 76 }; 77 } 78 79 babelHelpers.jsx = _createRawReactElement; 80 81 function _asyncIterator(iterable) { 82 var method; 83 84 if (typeof Symbol === "function") { 85 if (Symbol.asyncIterator) { 86 method = iterable[Symbol.asyncIterator]; 87 if (method != null) return method.call(iterable); 88 } 89 90 if (Symbol.iterator) { 91 method = iterable[Symbol.iterator]; 92 if (method != null) return method.call(iterable); 93 } 94 } 95 96 throw new TypeError("Object is not async iterable"); 97 } 98 99 babelHelpers.asyncIterator = _asyncIterator; 100 101 function _AwaitValue(value) { 102 this.wrapped = value; 103 } 104 105 babelHelpers.AwaitValue = _AwaitValue; 106 107 function AsyncGenerator(gen) { 108 var front, back; 109 110 function send(key, arg) { 111 return new Promise(function (resolve, reject) { 112 var request = { 113 key: key, 114 arg: arg, 115 resolve: resolve, 116 reject: reject, 117 next: null 118 }; 119 120 if (back) { 121 back = back.next = request; 122 } else { 123 front = back = request; 124 resume(key, arg); 125 } 126 }); 127 } 128 129 function resume(key, arg) { 130 try { 131 var result = gen[key](arg); 132 var value = result.value; 133 var wrappedAwait = value instanceof babelHelpers.AwaitValue; 134 Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { 135 if (wrappedAwait) { 136 resume("next", arg); 137 return; 138 } 139 140 settle(result.done ? "return" : "normal", arg); 141 }, function (err) { 142 resume("throw", err); 143 }); 144 } catch (err) { 145 settle("throw", err); 146 } 147 } 148 149 function settle(type, value) { 150 switch (type) { 151 case "return": 152 front.resolve({ 153 value: value, 154 done: true 155 }); 156 break; 157 158 case "throw": 159 front.reject(value); 160 break; 161 162 default: 163 front.resolve({ 164 value: value, 165 done: false 166 }); 167 break; 168 } 169 170 front = front.next; 171 172 if (front) { 173 resume(front.key, front.arg); 174 } else { 175 back = null; 176 } 177 } 178 179 this._invoke = send; 180 181 if (typeof gen.return !== "function") { 182 this.return = undefined; 183 } 184 } 185 186 if (typeof Symbol === "function" && Symbol.asyncIterator) { 187 AsyncGenerator.prototype[Symbol.asyncIterator] = function () { 188 return this; 189 }; 190 } 191 192 AsyncGenerator.prototype.next = function (arg) { 193 return this._invoke("next", arg); 194 }; 195 196 AsyncGenerator.prototype.throw = function (arg) { 197 return this._invoke("throw", arg); 198 }; 199 200 AsyncGenerator.prototype.return = function (arg) { 201 return this._invoke("return", arg); 202 }; 203 204 babelHelpers.AsyncGenerator = AsyncGenerator; 205 206 function _wrapAsyncGenerator(fn) { 207 return function () { 208 return new babelHelpers.AsyncGenerator(fn.apply(this, arguments)); 209 }; 210 } 211 212 babelHelpers.wrapAsyncGenerator = _wrapAsyncGenerator; 213 214 function _awaitAsyncGenerator(value) { 215 return new babelHelpers.AwaitValue(value); 216 } 217 218 babelHelpers.awaitAsyncGenerator = _awaitAsyncGenerator; 219 220 function _asyncGeneratorDelegate(inner, awaitWrap) { 221 var iter = {}, 222 waiting = false;
223 224 function pump(key, value) { 225 waiting = true; 226 value = new Promise(function (resolve) { 227 resolve(inner[key](value)); 228 }); 229 return { 230 done: false, 231 value: awaitWrap(value) 232 }; 233 } 234 235 ; 236 237 if (typeof Symbol === "function" && Symbol.iterator) { 238 iter[Symbol.iterator] = function () { 239 return this; 240 }; 241 } 242 243 iter.next = function (value) { 244 if (waiting) { 245 waiting = false; 246 return value; 247 } 248 249 return pump("next", value); 250 }; 251 252 if (typeof inner.throw === "function") { 253 iter.throw = function (value) { 254 if (waiting) { 255 waiting = false; 256 throw value; 257 } 258 259 return pump("throw", value); 260 }; 261 } 262 263 if (typeof inner.return === "function") { 264 iter.return = function (value) { 265 return pump("return", value); 266 }; 267 } 268 269 return iter; 270 } 271 272 babelHelpers.asyncGeneratorDelegate = _asyncGeneratorDelegate; 273 274 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { 275 try { 276 var info = gen[key](arg); 277 var value = info.value; 278 } catch (error) { 279 reject(error); 280 return; 281 } 282 283 if (info.done) { 284 resolve(value); 285 } else { 286 Promise.resolve(value).then(_next, _throw); 287 } 288 } 289 290 function _asyncToGenerator(fn) { 291 return function () { 292 var self = this, 293 args = arguments; 294 return new Promise(function (resolve, reject) { 295 var gen = fn.apply(self, args); 296 297 function _next(value) { 298 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); 299 } 300 301 function _throw(err) { 302 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); 303 } 304 305 _next(undefined); 306 }); 307 }; 308 } 309 310 babelHelpers.asyncToGenerator = _asyncToGenerator; 311 312 function _classCallCheck(instance, Constructor) { 313 if (!(instance instanceof Constructor)) { 314 throw new TypeError("Cannot call a class as a function"); 315 } 316 } 317 318 babelHelpers.classCallCheck = _classCallCheck; 319 320 function _defineProperties(target, props) { 321 for (var i = 0; i < props.length; i++) { 322 var descriptor = props[i]; 323 descriptor.enumerable = descriptor.enumerable || false; 324 descriptor.configurable = true; 325 if ("value" in descriptor) descriptor.writable = true; 326 Object.defineProperty(target, descriptor.key, descriptor); 327 } 328 } 329 330 function _createClass(Constructor, protoProps, staticProps) { 331 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 332 if (staticProps) _defineProperties(Constructor, staticProps); 333 return Constructor; 334 } 335 336 babelHelpers.createClass = _createClass; 337 338 function _defineEnumerableProperties(obj, descs) { 339 for (var key in descs) { 340 var desc = descs[key]; 341 desc.configurable = desc.enumerable = true; 342 if ("value" in desc) desc.writable = true; 343 Object.defineProperty(obj, key, desc); 344 } 345 346 if (Object.getOwnPropertySymbols) { 347 var objectSymbols = Object.getOwnPropertySymbols(descs); 348 349 for (var i = 0; i < objectSymbols.length; i++) { 350 var sym = objectSymbols[i]; 351 var desc = descs[sym]; 352 desc.configurable = desc.enumerable = true; 353 if ("value" in desc) desc.writable = true; 354 Object.defineProperty(obj, sym, desc); 355 } 356 } 357 358 return obj; 359 } 360 361 babelHelpers.defineEnumerableProperties = _defineEnumerableProperties; 362 363 function _defaults(obj, defaults) { 364 var keys = Object.getOwnPropertyNames(defaults); 365 366 for (var i = 0; i < keys.length; i++) { 367 var key = keys[i]; 368 var value = Object.getOwnPropertyDescriptor(defaults, key); 369 370 if (value && value.configurable && obj[key] === undefined) { 371 Object.defineProperty(obj, key, value); 372 } 373 } 374 375 return obj; 376 } 377 378 babelHelpers.defaults = _defaults; 379 380 function _defineProperty(obj, key, value) { 381 if (key in obj) { 382 Object.defineProperty(obj, key, { 383 value: value, 384 enumerable: true, 385 configurable: true, 386 writable: true 387 }); 388 } else { 389 obj[key] = value; 390 } 391 392 return obj; 393 } 394 395 babelHelpers.defineProperty = _defineProperty; 396 397 function _extends() { 398 babelHelpers.extends = _extends = Object.assign || function (target) { 399 for (var i = 1; i < arguments.length; i++) { 400 var source = arguments[i]; 401 402 for (var key in source) { 403 if (Object.prototype.hasOwnProperty.call(source, key)) { 404 target[key] = source[key]; 405 } 406 } 407 } 408 409 return target; 410 }; 411 412 return _extends.apply(this, arguments); 413 } 414 415 babelHelpers.extends = _extends; 416 417 function _objectSpread(target) { 418 for (var i = 1; i < arguments.length; i++) { 419 var source = arguments[i] != null ? arguments[i] : {}; 420 var ownKeys = Object.keys(source); 421 422 if (typeof Object.getOwnPropertySymbols === 'function') { 423 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { 424 return Object.getOwnPropertyDescriptor(source, sym).enumerable; 425 })); 426 } 427 428 ownKeys.forEach(function (key) { 429 babelHelpers.defineProperty(target, key, source[key]); 430 }); 431 } 432 433 return target; 434 } 435 436 babelHelpers.objectSpread = _objectSpread; 437 438 function _inherits(subClass, superClass) { 439 if (typeof superClass !== "function" && superClass !== null) { 440 throw new TypeError("Super expression must either be null or a function"); 441 } 442 443 subClass.prototype = Object.create(superClass && superClass.prototype, { 444 constructor: { 445 value: subClass, 446 writable: true, 447 configurable: true 448 } 449 }); 450 if (superClass) babelHelpers.setPrototypeOf(subClass, superClass); 451 } 452 453 babelHelpers.inherits = _inherits; 454 455 function _inheritsLoose(subClass, superClass) { 456 subClass.prototype = Object.create(superClass.prototype); 457 subClass.prototype.constructor = subClass; 458 subClass.__proto__ = superClass; 459 } 460 461 babelHelpers.inheritsLoose = _inheritsLoose; 462
463 function _getPrototypeOf(o) { 464 babelHelpers.getPrototypeOf = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { 465 return o.__proto__ || Object.getPrototypeOf(o); 466 }; 467 return _getPrototypeOf(o); 468 } 469 470 babelHelpers.getPrototypeOf = _getPrototypeOf; 471 472 function _setPrototypeOf(o, p) { 473 babelHelpers.setPrototypeOf = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { 474 o.__proto__ = p; 475 return o; 476 }; 477 478 return _setPrototypeOf(o, p); 479 } 480 481 babelHelpers.setPrototypeOf = _setPrototypeOf; 482 483 function isNativeReflectConstruct() { 484 if (typeof Reflect === "undefined" || !Reflect.construct) return false; 485 if (Reflect.construct.sham) return false; 486 if (typeof Proxy === "function") return true; 487 488 try { 489 Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); 490 return true; 491 } catch (e) { 492 return false; 493 } 494 } 495 496 function _construct(Parent, args, Class) { 497 if (isNativeReflectConstruct()) { 498 babelHelpers.construct = _construct = Reflect.construct; 499 } else { 500 babelHelpers.construct = _construct = function _construct(Parent, args, Class) { 501 var a = [null]; 502 a.push.apply(a, args); 503 var Constructor = Function.bind.apply(Parent, a); 504 var instance = new Constructor(); 505 if (Class) babelHelpers.setPrototypeOf(instance, Class.prototype); 506 return instance; 507 }; 508 } 509 510 return _construct.apply(null, arguments); 511 } 512 513 babelHelpers.construct = _construct; 514 515 function _isNativeFunction(fn) { 516 return Function.toString.call(fn).indexOf("[native code]") !== -1; 517 } 518 519 babelHelpers.isNativeFunction = _isNativeFunction; 520 521 function _wrapNativeSuper(Class) { 522 var _cache = typeof Map === "function" ? new Map() : undefined; 523 524 babelHelpers.wrapNativeSuper = _wrapNativeSuper = function _wrapNativeSuper(Class) { 525 if (Class === null || !babelHelpers.isNativeFunction(Class)) return Class; 526 527 if (typeof Class !== "function") { 528 throw new TypeError("Super expression must either be null or a function"); 529 } 530 531 if (typeof _cache !== "undefined") { 532 if (_cache.has(Class)) return _cache.get(Class); 533 534 _cache.set(Class, Wrapper); 535 } 536 537 function Wrapper() { 538 return babelHelpers.construct(Class, arguments, babelHelpers.getPrototypeOf(this).constructor); 539 } 540 541 Wrapper.prototype = Object.create(Class.prototype, { 542 constructor: { 543 value: Wrapper, 544 enumerable: false, 545 writable: true, 546 configurable: true 547 } 548 }); 549 return babelHelpers.setPrototypeOf(Wrapper, Class); 550 }; 551 552 return _wrapNativeSuper(Class); 553 } 554 555 babelHelpers.wrapNativeSuper = _wrapNativeSuper; 556 557 function _instanceof(left, right) { 558 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { 559 return right[Symbol.hasInstance](left); 560 } else { 561 return left instanceof right; 562 } 563 } 564 565 babelHelpers.instanceof = _instanceof; 566 567 function _interopRequireDefault(obj) { 568 return obj && obj.__esModule ? obj : { 569 default: obj 570 }; 571 } 572 573 babelHelpers.interopRequireDefault = _interopRequireDefault; 574 575 function _interopRequireWildcard(obj) { 576 if (obj && obj.__esModule) { 577 return obj; 578 } else { 579 var newObj = {}; 580 581 if (obj != null) { 582 for (var key in obj) { 583 if (Object.prototype.hasOwnProperty.call(obj, key)) { 584 var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; 585 586 if (desc.get || desc.set) { 587 Object.defineProperty(newObj, key, desc); 588 } else { 589 newObj[key] = obj[key]; 590 } 591 } 592 } 593 } 594 595 newObj.default = obj; 596 return newObj; 597 } 598 } 599 600 babelHelpers.interopRequireWildcard = _interopRequireWildcard; 601 602 function _newArrowCheck(innerThis, boundThis) { 603 if (innerThis !== boundThis) { 604 throw new TypeError("Cannot instantiate an arrow function"); 605 } 606 } 607 608 babelHelpers.newArrowCheck = _newArrowCheck; 609 610 function _objectDestructuringEmpty(obj) { 611 if (obj == null) throw new TypeError("Cannot destructure undefined"); 612 } 613 614 babelHelpers.objectDestructuringEmpty = _objectDestructuringEmpty; 615 616 function _objectWithoutPropertiesLoose(source, excluded) { 617 if (source == null) return {}; 618 var target = {}; 619 var sourceKeys = Object.keys(source); 620 var key, i; 621 622 for (i = 0; i < sourceKeys.length; i++) { 623 key = sourceKeys[i]; 624 if (excluded.indexOf(key) >= 0) continue; 625 target[key] = source[key]; 626 } 627 628 return target; 629 } 630 631 babelHelpers.objectWithoutPropertiesLoose = _objectWithoutPropertiesLoose; 632 633 function _objectWithoutProperties(source, excluded) { 634 if (source == null) return {}; 635 var target = babelHelpers.objectWithoutPropertiesLoose(source, excluded); 636 var key, i; 637 638 if (Object.getOwnPropertySymbols) { 639 var sourceSymbolKeys = Object.getOwnPropertySymbols(source); 640 641 for (i = 0; i < sourceSymbolKeys.length; i++) { 642 key = sourceSymbolKeys[i]; 643 if (excluded.indexOf(key) >= 0) continue; 644 if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; 645 target[key] = source[key]; 646 } 647 } 648 649 return target; 650 } 651 652 babelHelpers.objectWithoutProperties = _objectWithoutProperties; 653 654 function _assertThisInitialized(self) { 655 if (self === void 0) { 656 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 657 } 658 659 return self; 660 } 661 662 babelHelpers.assertThisInitialized = _assertThisInitialized; 663 664 function _possibleConstructorReturn(self, call) { 665 if (call && (typeof call === "object" || typeof call === "function")) { 666 return call; 667 } 668 669 return babelHelpers.assertThisInitialized(self); 670 } 671 672 babelHelpers.possibleConstructorReturn = _possibleConstructorReturn; 673 674 function _superPropBase(object, property) { 675 while (!Object.prototype.hasOwnProperty.call(object, property)) { 676 object = babelHelpers.getPrototypeOf(object); 677 if (object === null) break; 678 } 679 680 return object; 681 } 682 683 babelHelpers.superPropBase = _superPropBase; 684 685 function _get(target, property, receiver) { 686 if (typeof Reflect !== "undefined" && Reflect.get) { 687 babelHelpers.get = _get = Reflect.get; 688 } else { 689 babelHelpers.get = _get = function _get(target, property, receiver) { 690 var base = babelHelpers.superPropBase(target, property); 691 if (!base) return; 692 var desc = Object.getOwnPropertyDescriptor(base, property); 693 694 if (desc.get) { 695 return desc.get.call(receiver); 696 } 697 698 return desc.value; 699 }; 700 } 701 702 return _get(target, property, receiver || target); 703 } 704 705 babelHelpers.get = _get; 706 707 function set(target, property, value, receiver) { 708 if (typeof Reflect !== "undefined" && Reflect.set) { 709 set = Reflect.set; 710 } else { 711 set = function set(target, property, value, receiver) { 712 var base = babelHelpers.superPropBase(target, property); 713 var desc; 714 715 if (base) { 716 desc = Object.getOwnPropertyDescriptor(base, property); 717 718 if (desc.set) { 719 desc.set.call(receiver, value); 720 return true; 721 } else if (!desc.writable) { 722 return false;
723 } 724 } 725 726 desc = Object.getOwnPropertyDescriptor(receiver, property); 727 728 if (desc) { 729 if (!desc.writable) { 730 return false; 731 } 732 733 desc.value = value; 734 Object.defineProperty(receiver, property, desc); 735 } else { 736 babelHelpers.defineProperty(receiver, property, value); 737 } 738 739 return true; 740 }; 741 } 742 743 return set(target, property, value, receiver); 744 } 745 746 function _set(target, property, value, receiver, isStrict) { 747 var s = set(target, property, value, receiver || target); 748 749 if (!s && isStrict) { 750 throw new Error('failed to set property'); 751 } 752 753 return value; 754 } 755 756 babelHelpers.set = _set; 757 758 function _taggedTemplateLiteral(strings, raw) { 759 if (!raw) { 760 raw = strings.slice(0); 761 } 762 763 return Object.freeze(Object.defineProperties(strings, { 764 raw: { 765 value: Object.freeze(raw) 766 } 767 })); 768 } 769 770 babelHelpers.taggedTemplateLiteral = _taggedTemplateLiteral; 771 772 function _taggedTemplateLiteralLoose(strings, raw) { 773 if (!raw) { 774 raw = strings.slice(0); 775 } 776 777 strings.raw = raw; 778 return strings; 779 } 780 781 babelHelpers.taggedTemplateLiteralLoose = _taggedTemplateLiteralLoose; 782 783 function _temporalRef(val, name) { 784 if (val === babelHelpers.temporalUndefined) { 785 throw new ReferenceError(name + " is not defined - temporal dead zone"); 786 } else { 787 return val; 788 } 789 } 790 791 babelHelpers.temporalRef = _temporalRef; 792 793 function _readOnlyError(name) { 794 throw new Error("\"" + name + "\" is read-only"); 795 } 796 797 babelHelpers.readOnlyError = _readOnlyError; 798 799 function _classNameTDZError(name) { 800 throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); 801 } 802 803 babelHelpers.classNameTDZError = _classNameTDZError; 804 babelHelpers.temporalUndefined = {}; 805 806 function _slicedToArray(arr, i) { 807 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArrayLimit(arr, i) || babelHelpers.nonIterableRest(); 808 } 809 810 babelHelpers.slicedToArray = _slicedToArray; 811 812 function _slicedToArrayLoose(arr, i) { 813 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArrayLimitLoose(arr, i) || babelHelpers.nonIterableRest(); 814 } 815 816 babelHelpers.slicedToArrayLoose = _slicedToArrayLoose; 817 818 function _toArray(arr) { 819 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArray(arr) || babelHelpers.nonIterableRest(); 820 } 821 822 babelHelpers.toArray = _toArray; 823 824 function _toConsumableArray(arr) { 825 return babelHelpers.arrayWithoutHoles(arr) || babelHelpers.iterableToArray(arr) || babelHelpers.nonIterableSpread(); 826 } 827 828 babelHelpers.toConsumableArray = _toConsumableArray; 829 830 function _arrayWithoutHoles(arr) { 831 if (Array.isArray(arr)) { 832 for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; 833 834 return arr2; 835 } 836 } 837 838 babelHelpers.arrayWithoutHoles = _arrayWithoutHoles; 839 840 function _arrayWithHoles(arr) { 841 if (Array.isArray(arr)) return arr; 842 } 843 844 babelHelpers.arrayWithHoles = _arrayWithHoles; 845 846 function _iterableToArray(iter) { 847 if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); 848 } 849 850 babelHelpers.iterableToArray = _iterableToArray; 851 852 function _iterableToArrayLimit(arr, i) { 853 var _arr = []; 854 var _n = true; 855 var _d = false; 856 var _e = undefined; 857 858 try { 859 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { 860 _arr.push(_s.value); 861 862 if (i && _arr.length === i) break; 863 } 864 } catch (err) { 865 _d = true; 866 _e = err; 867 } finally { 868 try { 869 if (!_n && _i["return"] != null) _i["return"](); 870 } finally { 871 if (_d) throw _e; 872 } 873 } 874 875 return _arr; 876 } 877 878 babelHelpers.iterableToArrayLimit = _iterableToArrayLimit; 879 880 function _iterableToArrayLimitLoose(arr, i) { 881 var _arr = []; 882 883 for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { 884 _arr.push(_step.value); 885 886 if (i && _arr.length === i) break; 887 } 888 889 return _arr; 890 } 891 892 babelHelpers.iterableToArrayLimitLoose = _iterableToArrayLimitLoose; 893 894 function _nonIterableSpread() { 895 throw new TypeError("Invalid attempt to spread non-iterable instance"); 896 } 897 898 babelHelpers.nonIterableSpread = _nonIterableSpread; 899 900 function _nonIterableRest() {
901 throw new TypeError("Invalid attempt to destructure non-iterable instance"); 902 } 903 904 babelHelpers.nonIterableRest = _nonIterableRest; 905 906 function _skipFirstGeneratorNext(fn) { 907 return function () { 908 var it = fn.apply(this, arguments); 909 it.next(); 910 return it; 911 }; 912 } 913 914 babelHelpers.skipFirstGeneratorNext = _skipFirstGeneratorNext; 915 916 function _toPropertyKey(key) { 917 if (typeof key === "symbol") { 918 return key; 919 } else { 920 return String(key); 921 } 922 } 923 924 babelHelpers.toPropertyKey = _toPropertyKey; 925 926 function _initializerWarningHelper(descriptor, context) { 927 throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and set to use loose mode. ' + 'To use proposal-class-properties in spec mode with decorators, wait for ' + 'the next major version of decorators in stage 2.'); 928 } 929 930 babelHelpers.initializerWarningHelper = _initializerWarningHelper; 931 932 function _initializerDefineProperty(target, property, descriptor, context) { 933 if (!descriptor) return; 934 Object.defineProperty(target, property, { 935 enumerable: descriptor.enumerable, 936 configurable: descriptor.configurable, 937 writable: descriptor.writable, 938 value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 939 }); 940 } 941 942 babelHelpers.initializerDefineProperty = _initializerDefineProperty; 943 944 function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { 945 var desc = {}; 946 Object['ke' + 'ys'](descriptor).forEach(function (key) { 947 desc[key] = descriptor[key]; 948 }); 949 desc.enumerable = !!desc.enumerable; 950 desc.configurable = !!desc.configurable; 951 952 if ('value' in desc || desc.initializer) { 953 desc.writable = true; 954 } 955 956 desc = decorators.slice().reverse().reduce(function (desc, decorator) { 957 return decorator(target, property, desc) || desc; 958 }, desc); 959 960 if (context && desc.initializer !== void 0) { 961 desc.value = desc.initializer ? desc.initializer.call(context) : void 0; 962 desc.initializer = undefined; 963 } 964 965 if (desc.initializer === void 0) { 966 Object['define' + 'Property'](target, property, desc); 967 desc = null; 968 } 969 970 return desc; 971 } 972 973 babelHelpers.applyDecoratedDescriptor = _applyDecoratedDescriptor; 974 var id = 0; 975 976 function _classPrivateFieldKey(name) { 977 return "__private_" + id++ + "_" + name; 978 } 979 980 babelHelpers.classPrivateFieldLooseKey = _classPrivateFieldKey; 981 982 function _classPrivateFieldBase(receiver, privateKey) { 983 if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { 984 throw new TypeError("attempted to use private field on non-instance"); 985 } 986 987 return receiver; 988 } 989 990 babelHelpers.classPrivateFieldLooseBase = _classPrivateFieldBase; 991 992 function _classPrivateFieldGet(receiver, privateMap) { 993 if (!privateMap.has(receiver)) { 994 throw new TypeError("attempted to get private field on non-instance"); 995 } 996 997 return privateMap.get(receiver).value; 998 } 999 1000 babelHelpers.classPrivateFieldGet = _classPrivateFieldGet; 1001 1002 function _classPrivateFieldSet(receiver, privateMap, value) { 1003 if (!privateMap.has(receiver)) { 1004 throw new TypeError("attempted to set private field on non-instance"); 1005 } 1006 1007 var descriptor = privateMap.get(receiver); 1008 1009 if (!descriptor.writable) { 1010 throw new TypeError("attempted to set read only private field"); 1011 } 1012 1013 descriptor.value = value; 1014 return value; 1015 } 1016 1017 babelHelpers.classPrivateFieldSet = _classPrivateFieldSet; 1018})(typeof global === "undefined" ? window : global); 1019 1020/** 1021 * Copyright (c) 2014-present, Facebook, Inc. 1022 * 1023 * This source code is licensed under the MIT license found in the 1024 * LICENSE file in the root directory of this source tree. 1025 */ 1026 1027!(function(global) { 1028 "use strict"; 1029 1030 var Op = Object.prototype; 1031 var hasOwn = Op.hasOwnProperty; 1032 var undefined; // More compressible than void 0. 1033 var $Symbol = typeof Symbol === "function" ? Symbol : {}; 1034 var iteratorSymbol = $Symbol.iterator || "@@iterator"; 1035 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; 1036 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; 1037 1038 // Define the runtime globally (as expected by generated code) as either 1039 // module.exports (if we're in a module) or a new, empty object. 1040 var runtime = global.regeneratorRuntime = {}; 1041 1042 function wrap(innerFn, outerFn, self, tryLocsList) { 1043 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. 1044 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; 1045 var generator = Object.create(protoGenerator.prototype); 1046 var context = new Context(tryLocsList || []); 1047 1048 // The ._invoke method unifies the implementations of the .next, 1049 // .throw, and .return methods. 1050 generator._invoke = makeInvokeMethod(innerFn, self, context); 1051 1052 return generator; 1053 } 1054 runtime.wrap = wrap; 1055 1056 // Try/catch helper to minimize deoptimizations. Returns a completion 1057 // record like context.tryEntries[i].completion. This interface could
vendor: 10,591 bytes, lines 1058-1351
1058 // have been (and was previously) designed to take a closure to be 1059 // invoked without arguments, but in all the cases we care about we 1060 // already have an existing method we want to call, so there's no need 1061 // to create a new function object. We can even get away with assuming 1062 // the method takes exactly one argument, since that happens to be true 1063 // in every case, so we don't have to touch the arguments object. The 1064 // only additional allocation required is the completion record, which 1065 // has a stable shape and so hopefully should be cheap to allocate. 1066 function tryCatch(fn, obj, arg) { 1067 try { 1068 return { type: "normal", arg: fn.call(obj, arg) }; 1069 } catch (err) { 1070 return { type: "throw", arg: err }; 1071 } 1072 } 1073 1074 var GenStateSuspendedStart = "suspendedStart"; 1075 var GenStateSuspendedYield = "suspendedYield"; 1076 var GenStateExecuting = "executing"; 1077 var GenStateCompleted = "completed"; 1078 1079 // Returning this object from the innerFn has the same effect as 1080 // breaking out of the dispatch switch statement. 1081 var ContinueSentinel = {}; 1082 1083 // Dummy constructor functions that we use as the .constructor and 1084 // .constructor.prototype properties for functions that return Generator 1085 // objects. For full spec compliance, you may wish to configure your 1086 // minifier not to mangle the names of these two functions. 1087 function Generator() {} 1088 function GeneratorFunction() {} 1089 function GeneratorFunctionPrototype() {} 1090 1091 // This is a polyfill for %IteratorPrototype% for environments that 1092 // don't natively support it. 1093 var IteratorPrototype = {}; 1094 IteratorPrototype[iteratorSymbol] = function () { 1095 return this; 1096 }; 1097 1098 var getProto = Object.getPrototypeOf; 1099 var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); 1100 if (NativeIteratorPrototype && 1101 NativeIteratorPrototype !== Op && 1102 hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { 1103 // This environment has a native %IteratorPrototype%; use it instead 1104 // of the polyfill. 1105 IteratorPrototype = NativeIteratorPrototype; 1106 } 1107 1108 var Gp = GeneratorFunctionPrototype.prototype = 1109 Generator.prototype = Object.create(IteratorPrototype); 1110 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; 1111 GeneratorFunctionPrototype.constructor = GeneratorFunction; 1112 GeneratorFunctionPrototype[toStringTagSymbol] = 1113 GeneratorFunction.displayName = "GeneratorFunction"; 1114 1115 // Helper for defining the .next, .throw, and .return methods of the 1116 // Iterator interface in terms of a single ._invoke method. 1117 function defineIteratorMethods(prototype) { 1118 ["next", "throw", "return"].forEach(function(method) { 1119 prototype[method] = function(arg) { 1120 return this._invoke(method, arg); 1121 }; 1122 }); 1123 } 1124 1125 runtime.isGeneratorFunction = function(genFun) { 1126 var ctor = typeof genFun === "function" && genFun.constructor; 1127 return ctor 1128 ? ctor === GeneratorFunction || 1129 // For the native GeneratorFunction constructor, the best we can 1130 // do is to check its .name property. 1131 (ctor.displayName || ctor.name) === "GeneratorFunction" 1132 : false; 1133 }; 1134 1135 runtime.mark = function(genFun) { 1136 if (Object.setPrototypeOf) { 1137 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); 1138 } else { 1139 genFun.__proto__ = GeneratorFunctionPrototype; 1140 if (!(toStringTagSymbol in genFun)) { 1141 genFun[toStringTagSymbol] = "GeneratorFunction"; 1142 } 1143 } 1144 genFun.prototype = Object.create(Gp); 1145 return genFun; 1146 }; 1147 1148 // Within the body of any async function, `await x` is transformed to 1149 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test 1150 // `hasOwn.call(value, "__await")` to determine if the yielded value is 1151 // meant to be awaited. 1152 runtime.awrap = function(arg) { 1153 return { __await: arg }; 1154 }; 1155 1156 function AsyncIterator(generator) { 1157 function invoke(method, arg, resolve, reject) { 1158 var record = tryCatch(generator[method], generator, arg); 1159 if (record.type === "throw") { 1160 reject(record.arg); 1161 } else { 1162 var result = record.arg; 1163 var value = result.value; 1164 if (value && 1165 typeof value === "object" && 1166 hasOwn.call(value, "__await")) { 1167 return Promise.resolve(value.__await).then(function(value) { 1168 invoke("next", value, resolve, reject); 1169 }, function(err) { 1170 invoke("throw", err, resolve, reject); 1171 }); 1172 } 1173 1174 return Promise.resolve(value).then(function(unwrapped) { 1175 // When a yielded Promise is resolved, its final value becomes 1176 // the .value of the Promise<{value,done}> result for the 1177 // current iteration. If the Promise is rejected, however, the 1178 // result for this iteration will be rejected with the same 1179 // reason. Note that rejections of yielded Promises are not 1180 // thrown back into the generator function, as is the case 1181 // when an awaited Promise is rejected. This difference in 1182 // behavior between yield and await is important, because it 1183 // allows the consumer to decide what to do with the yielded 1184 // rejection (swallow it and continue, manually .throw it back 1185 // into the generator, abandon iteration, whatever). With 1186 // await, by contrast, there is no opportunity to examine the 1187 // rejection reason outside the generator function, so the 1188 // only option is to throw it from the await expression, and 1189 // let the generator function handle the exception. 1190 result.value = unwrapped; 1191 resolve(result); 1192 }, reject); 1193 } 1194 } 1195 1196 var previousPromise; 1197 1198 function enqueue(method, arg) { 1199 function callInvokeWithMethodAndArg() { 1200 return new Promise(function(resolve, reject) { 1201 invoke(method, arg, resolve, reject); 1202 }); 1203 } 1204 1205 return previousPromise = 1206 // If enqueue has been called before, then we want to wait until 1207 // all previous Promises have been resolved before calling invoke, 1208 // so that results are always delivered in the correct order. If 1209 // enqueue has not been called before, then it is important to 1210 // call invoke immediately, without waiting on a callback to fire, 1211 // so that the async generator function has the opportunity to do 1212 // any necessary setup in a predictable way. This predictability 1213 // is why the Promise constructor synchronously invokes its 1214 // executor callback, and why async functions synchronously 1215 // execute code before the first await. Since we implement simple 1216 // async functions in terms of async generators, it is especially 1217 // important to get this right, even though it requires care. 1218 previousPromise ? previousPromise.then( 1219 callInvokeWithMethodAndArg, 1220 // Avoid propagating failures to Promises returned by later 1221 // invocations of the iterator. 1222 callInvokeWithMethodAndArg 1223 ) : callInvokeWithMethodAndArg(); 1224 } 1225 1226 // Define the unified helper method that is used to implement .next, 1227 // .throw, and .return (see defineIteratorMethods). 1228 this._invoke = enqueue; 1229 } 1230 1231 defineIteratorMethods(AsyncIterator.prototype); 1232 AsyncIterator.prototype[asyncIteratorSymbol] = function () { 1233 return this; 1234 }; 1235 runtime.AsyncIterator = AsyncIterator; 1236 1237 // Note that simple async functions are implemented on top of 1238 // AsyncIterator objects; they just return a Promise for the value of 1239 // the final result produced by the iterator. 1240 runtime.async = function(innerFn, outerFn, self, tryLocsList) { 1241 var iter = new AsyncIterator( 1242 wrap(innerFn, outerFn, self, tryLocsList) 1243 ); 1244 1245 return runtime.isGeneratorFunction(outerFn) 1246 ? iter // If outerFn is a generator, return the full iterator. 1247 : iter.next().then(function(result) { 1248 return result.done ? result.value : iter.next(); 1249 }); 1250 }; 1251 1252 function makeInvokeMethod(innerFn, self, context) { 1253 var state = GenStateSuspendedStart; 1254 1255 return function invoke(method, arg) { 1256 if (state === GenStateExecuting) { 1257 throw new Error("Generator is already running"); 1258 } 1259 1260 if (state === GenStateCompleted) { 1261 if (method === "throw") { 1262 throw arg; 1263 } 1264 1265 // Be forgiving, per 25.3.3.3.3 of the spec: 1266 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume 1267 return doneResult(); 1268 } 1269 1270 context.method = method; 1271 context.arg = arg; 1272 1273 while (true) { 1274 var delegate = context.delegate; 1275 if (delegate) { 1276 var delegateResult = maybeInvokeDelegate(delegate, context); 1277 if (delegateResult) { 1278 if (delegateResult === ContinueSentinel) continue; 1279 return delegateResult; 1280 } 1281 } 1282 1283 if (context.method === "next") { 1284 // Setting context._sent for legacy support of Babel's 1285 // function.sent implementation. 1286 context.sent = context._sent = context.arg; 1287 1288 } else if (context.method === "throw") { 1289 if (state === GenStateSuspendedStart) { 1290 state = GenStateCompleted; 1291 throw context.arg; 1292 } 1293 1294 context.dispatchException(context.arg); 1295 1296 } else if (context.method === "return") { 1297 context.abrupt("return", context.arg); 1298 } 1299 1300 state = GenStateExecuting; 1301 1302 var record = tryCatch(innerFn, self, context); 1303 if (record.type === "normal") { 1304 // If an exception is thrown from innerFn, we leave state === 1305 // GenStateExecuting and loop back for another invocation. 1306 state = context.done 1307 ? GenStateCompleted 1308 : GenStateSuspendedYield; 1309 1310 if (record.arg === ContinueSentinel) { 1311 continue; 1312 } 1313 1314 return { 1315 value: record.arg, 1316 done: context.done 1317 }; 1318 1319 } else if (record.type === "throw") { 1320 state = GenStateCompleted; 1321 // Dispatch the exception by looping back around to the 1322 // context.dispatchException(context.arg) call above. 1323 context.method = "throw"; 1324 context.arg = record.arg; 1325 } 1326 } 1327 }; 1328 } 1329 1330 // Call delegate.iterator[context.method](context.arg) and handle the 1331 // result, either by returning a { value, done } result from the 1332 // delegate iterator, or by modifying context.method and context.arg, 1333 // setting context.delegate to null, and returning the ContinueSentinel. 1334 function maybeInvokeDelegate(delegate, context) { 1335 var method = delegate.iterator[context.method]; 1336 if (method === undefined) { 1337 // A .throw or .return when the delegate iterator has no .throw 1338 // method always terminates the yield* loop. 1339 context.delegate = null; 1340 1341 if (context.method === "throw") { 1342 if (delegate.iterator.return) { 1343 // If the delegate iterator has a return method, give it a 1344 // chance to clean up. 1345 context.method = "return"; 1346 context.arg = undefined; 1347 maybeInvokeDelegate(delegate, context); 1348 1349 if (context.method === "throw") { 1350 // If maybeInvokeDelegate(context) changed context.method from 1351 // "return" to "throw", let that override the TypeError below.
vendor: 4,172 bytes, lines 1352-1505
1352 return ContinueSentinel; 1353 } 1354 } 1355 1356 context.method = "throw"; 1357 context.arg = new TypeError( 1358 "The iterator does not provide a 'throw' method"); 1359 } 1360 1361 return ContinueSentinel; 1362 } 1363 1364 var record = tryCatch(method, delegate.iterator, context.arg); 1365 1366 if (record.type === "throw") { 1367 context.method = "throw"; 1368 context.arg = record.arg; 1369 context.delegate = null; 1370 return ContinueSentinel; 1371 } 1372 1373 var info = record.arg; 1374 1375 if (! info) { 1376 context.method = "throw"; 1377 context.arg = new TypeError("iterator result is not an object"); 1378 context.delegate = null; 1379 return ContinueSentinel; 1380 } 1381 1382 if (info.done) { 1383 // Assign the result of the finished delegate to the temporary 1384 // variable specified by delegate.resultName (see delegateYield). 1385 context[delegate.resultName] = info.value; 1386 1387 // Resume execution at the desired location (see delegateYield). 1388 context.next = delegate.nextLoc; 1389 1390 // If context.method was "throw" but the delegate handled the 1391 // exception, let the outer generator proceed normally. If 1392 // context.method was "next", forget context.arg since it has been 1393 // "consumed" by the delegate iterator. If context.method was 1394 // "return", allow the original .return call to continue in the 1395 // outer generator. 1396 if (context.method !== "return") { 1397 context.method = "next"; 1398 context.arg = undefined; 1399 } 1400 1401 } else { 1402 // Re-yield the result returned by the delegate method. 1403 return info; 1404 } 1405 1406 // The delegate iterator is finished, so forget it and continue with 1407 // the outer generator. 1408 context.delegate = null; 1409 return ContinueSentinel; 1410 } 1411 1412 // Define Generator.prototype.{next,throw,return} in terms of the 1413 // unified ._invoke helper method. 1414 defineIteratorMethods(Gp); 1415 1416 Gp[toStringTagSymbol] = "Generator"; 1417 1418 // A Generator should always return itself as the iterator object when the 1419 // @@iterator function is called on it. Some browsers' implementations of the 1420 // iterator prototype chain incorrectly implement this, causing the Generator 1421 // object to not be returned from this call. This ensures that doesn't happen. 1422 // See https://github.com/facebook/regenerator/issues/274 for more details. 1423 Gp[iteratorSymbol] = function() { 1424 return this; 1425 }; 1426 1427 Gp.toString = function() { 1428 return "[object Generator]"; 1429 }; 1430 1431 function pushTryEntry(locs) { 1432 var entry = { tryLoc: locs[0] }; 1433 1434 if (1 in locs) { 1435 entry.catchLoc = locs[1]; 1436 } 1437 1438 if (2 in locs) { 1439 entry.finallyLoc = locs[2]; 1440 entry.afterLoc = locs[3]; 1441 } 1442 1443 this.tryEntries.push(entry); 1444 } 1445 1446 function resetTryEntry(entry) { 1447 var record = entry.completion || {}; 1448 record.type = "normal"; 1449 delete record.arg; 1450 entry.completion = record; 1451 } 1452 1453 function Context(tryLocsList) { 1454 // The root entry object (effectively a try statement without a catch 1455 // or a finally block) gives us a place to store values thrown from 1456 // locations where there is no enclosing try statement. 1457 this.tryEntries = [{ tryLoc: "root" }]; 1458 tryLocsList.forEach(pushTryEntry, this); 1459 this.reset(true); 1460 } 1461 1462 runtime.keys = function(object) { 1463 var keys = []; 1464 for (var key in object) { 1465 keys.push(key); 1466 } 1467 keys.reverse(); 1468 1469 // Rather than returning an object with a next method, we keep 1470 // things simple and return the next function itself. 1471 return function next() { 1472 while (keys.length) { 1473 var key = keys.pop(); 1474 if (key in object) { 1475 next.value = key; 1476 next.done = false; 1477 return next; 1478 } 1479 } 1480 1481 // To avoid creating an additional object, we just hang the .value 1482 // and .done properties off the next function object itself. This 1483 // also ensures that the minifier will not anonymize the function. 1484 next.done = true; 1485 return next; 1486 }; 1487 }; 1488 1489 function values(iterable) { 1490 if (iterable) { 1491 var iteratorMethod = iterable[iteratorSymbol]; 1492 if (iteratorMethod) { 1493 return iteratorMethod.call(iterable); 1494 } 1495 1496 if (typeof iterable.next === "function") { 1497 return iterable; 1498 } 1499 1500 if (!isNaN(iterable.length)) { 1501 var i = -1, next = function next() { 1502 while (++i < iterable.length) { 1503 if (hasOwn.call(iterable, i)) { 1504 next.value = iterable[i]; 1505 next.done = false;
vendor: 10,304 bytes, lines 1506-1901
1506 return next; 1507 } 1508 } 1509 1510 next.value = undefined; 1511 next.done = true; 1512 1513 return next; 1514 }; 1515 1516 return next.next = next; 1517 } 1518 } 1519 1520 // Return an iterator with no values. 1521 return { next: doneResult }; 1522 } 1523 runtime.values = values; 1524 1525 function doneResult() { 1526 return { value: undefined, done: true }; 1527 } 1528 1529 Context.prototype = { 1530 constructor: Context, 1531 1532 reset: function(skipTempReset) { 1533 this.prev = 0; 1534 this.next = 0; 1535 // Resetting context._sent for legacy support of Babel's 1536 // function.sent implementation. 1537 this.sent = this._sent = undefined; 1538 this.done = false; 1539 this.delegate = null; 1540 1541 this.method = "next"; 1542 this.arg = undefined; 1543 1544 this.tryEntries.forEach(resetTryEntry); 1545 1546 if (!skipTempReset) { 1547 for (var name in this) { 1548 // Not sure about the optimal order of these conditions: 1549 if (name.charAt(0) === "t" && 1550 hasOwn.call(this, name) && 1551 !isNaN(+name.slice(1))) { 1552 this[name] = undefined; 1553 } 1554 } 1555 } 1556 }, 1557 1558 stop: function() { 1559 this.done = true; 1560 1561 var rootEntry = this.tryEntries[0]; 1562 var rootRecord = rootEntry.completion; 1563 if (rootRecord.type === "throw") { 1564 throw rootRecord.arg; 1565 } 1566 1567 return this.rval; 1568 }, 1569 1570 dispatchException: function(exception) { 1571 if (this.done) { 1572 throw exception; 1573 } 1574 1575 var context = this; 1576 function handle(loc, caught) { 1577 record.type = "throw"; 1578 record.arg = exception; 1579 context.next = loc; 1580 1581 if (caught) { 1582 // If the dispatched exception was caught by a catch block, 1583 // then let that catch block handle the exception normally. 1584 context.method = "next"; 1585 context.arg = undefined; 1586 } 1587 1588 return !! caught; 1589 } 1590 1591 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1592 var entry = this.tryEntries[i]; 1593 var record = entry.completion; 1594 1595 if (entry.tryLoc === "root") { 1596 // Exception thrown outside of any try block that could handle 1597 // it, so set the completion value of the entire function to 1598 // throw the exception. 1599 return handle("end"); 1600 } 1601 1602 if (entry.tryLoc <= this.prev) { 1603 var hasCatch = hasOwn.call(entry, "catchLoc"); 1604 var hasFinally = hasOwn.call(entry, "finallyLoc"); 1605 1606 if (hasCatch && hasFinally) { 1607 if (this.prev < entry.catchLoc) { 1608 return handle(entry.catchLoc, true); 1609 } else if (this.prev < entry.finallyLoc) { 1610 return handle(entry.finallyLoc); 1611 } 1612 1613 } else if (hasCatch) { 1614 if (this.prev < entry.catchLoc) { 1615 return handle(entry.catchLoc, true); 1616 } 1617 1618 } else if (hasFinally) { 1619 if (this.prev < entry.finallyLoc) { 1620 return handle(entry.finallyLoc); 1621 } 1622 1623 } else { 1624 throw new Error("try statement without catch or finally"); 1625 } 1626 } 1627 } 1628 }, 1629 1630 abrupt: function(type, arg) { 1631 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1632 var entry = this.tryEntries[i]; 1633 if (entry.tryLoc <= this.prev && 1634 hasOwn.call(entry, "finallyLoc") && 1635 this.prev < entry.finallyLoc) { 1636 var finallyEntry = entry; 1637 break; 1638 } 1639 } 1640 1641 if (finallyEntry && 1642 (type === "break" || 1643 type === "continue") && 1644 finallyEntry.tryLoc <= arg && 1645 arg <= finallyEntry.finallyLoc) { 1646 // Ignore the finally entry if control is not jumping to a 1647 // location outside the try/catch block. 1648 finallyEntry = null; 1649 } 1650 1651 var record = finallyEntry ? finallyEntry.completion : {}; 1652 record.type = type; 1653 record.arg = arg; 1654 1655 if (finallyEntry) { 1656 this.method = "next"; 1657 this.next = finallyEntry.finallyLoc; 1658 return ContinueSentinel; 1659 } 1660 1661 return this.complete(record); 1662 }, 1663 1664 complete: function(record, afterLoc) { 1665 if (record.type === "throw") { 1666 throw record.arg; 1667 } 1668 1669 if (record.type === "break" || 1670 record.type === "continue") { 1671 this.next = record.arg; 1672 } else if (record.type === "return") { 1673 this.rval = this.arg = record.arg; 1674 this.method = "return"; 1675 this.next = "end"; 1676 } else if (record.type === "normal" && afterLoc) { 1677 this.next = afterLoc; 1678 } 1679 1680 return ContinueSentinel; 1681 }, 1682 1683 finish: function(finallyLoc) { 1684 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1685 var entry = this.tryEntries[i]; 1686 if (entry.finallyLoc === finallyLoc) { 1687 this.complete(entry.completion, entry.afterLoc); 1688 resetTryEntry(entry); 1689 return ContinueSentinel; 1690 } 1691 } 1692 }, 1693 1694 "catch": function(tryLoc) { 1695 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1696 var entry = this.tryEntries[i]; 1697 if (entry.tryLoc === tryLoc) { 1698 var record = entry.completion; 1699 if (record.type === "throw") { 1700 var thrown = record.arg; 1701 resetTryEntry(entry); 1702 } 1703 return thrown; 1704 } 1705 } 1706 1707 // The context.catch method must only be called with a location 1708 // argument that corresponds to a known catch block. 1709 throw new Error("illegal catch attempt"); 1710 }, 1711 1712 delegateYield: function(iterable, resultName, nextLoc) { 1713 this.delegate = { 1714 iterator: values(iterable), 1715 resultName: resultName, 1716 nextLoc: nextLoc 1717 }; 1718 1719 if (this.method === "next") { 1720 // Deliberately forget the last sent value so that we don't 1721 // accidentally pass it on to the delegate. 1722 this.arg = undefined; 1723 } 1724 1725 return ContinueSentinel; 1726 } 1727 }; 1728})( 1729 // In sloppy mode, unbound `this` refers to the global object, fallback to 1730 // Function constructor if we're in global strict mode. That is sadly a form 1731 // of indirect eval which violates Content Security Policy. 1732 (function() { return this })() || Function("return this")() 1733); 1734 1735(function (exports) { 1736 'use strict'; 1737 1738 function createCommonjsModule(fn, module) { 1739 return module = { 1740 exports: {} 1741 }, fn(module, module.exports), module.exports; 1742 } 1743 1744 var _global = createCommonjsModule(function (module) { 1745 // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 1746 var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self // eslint-disable-next-line no-new-func 1747 : Function('return this')(); 1748 if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef 1749 }); 1750 1751 var hasOwnProperty = {}.hasOwnProperty; 1752 1753 var _has = function (it, key) { 1754 return hasOwnProperty.call(it, key); 1755 }; 1756 1757 var _fails = function (exec) { 1758 try { 1759 return !!exec(); 1760 } catch (e) { 1761 return true; 1762 } 1763 }; 1764 1765 // Thank's IE8 for his funny defineProperty 1766 var _descriptors = !_fails(function () { 1767 return Object.defineProperty({}, 'a', { 1768 get: function get() { 1769 return 7; 1770 } 1771 }).a != 7; 1772 }); 1773 1774 var _core = createCommonjsModule(function (module) { 1775 var core = module.exports = { 1776 version: '2.6.3' 1777 }; 1778 if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef 1779 }); 1780 var _core_1 = _core.version; 1781 1782 var _isObject = function (it) { 1783 return babelHelpers.typeof(it) === 'object' ? it !== null : typeof it === 'function'; 1784 }; 1785 1786 var _anObject = function (it) { 1787 if (!_isObject(it)) throw TypeError(it + ' is not an object!'); 1788 return it; 1789 }; 1790 1791 var document$1 = _global.document; // typeof document.createElement is 'object' in old IE 1792 1793 1794 var is = _isObject(document$1) && _isObject(document$1.createElement); 1795 1796 var _domCreate = function (it) { 1797 return is ? document$1.createElement(it) : {}; 1798 }; 1799 1800 var _ie8DomDefine = !_descriptors && !_fails(function () { 1801 return Object.defineProperty(_domCreate('div'), 'a', { 1802 get: function get() { 1803 return 7; 1804 } 1805 }).a != 7; 1806 }); 1807 1808 // 7.1.1 ToPrimitive(input [, PreferredType]) 1809 // instead of the ES6 spec version, we didn't implement @@toPrimitive case 1810 // and the second argument - flag - preferred type is a string 1811 1812 1813 var _toPrimitive = function (it, S) { 1814 if (!_isObject(it)) return it; 1815 var fn, val; 1816 if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val; 1817 if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val; 1818 if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val; 1819 throw TypeError("Can't convert object to primitive value"); 1820 }; 1821 1822 var dP = Object.defineProperty; 1823 var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) { 1824 _anObject(O); 1825 P = _toPrimitive(P, true); 1826 _anObject(Attributes); 1827 if (_ie8DomDefine) try { 1828 return dP(O, P, Attributes); 1829 } catch (e) { 1830 /* empty */ 1831 } 1832 if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!'); 1833 if ('value' in Attributes) O[P] = Attributes.value; 1834 return O; 1835 }; 1836 1837 var _objectDp = { 1838 f: f 1839 }; 1840 1841 var _propertyDesc = function (bitmap, value) { 1842 return { 1843 enumerable: !(bitmap & 1), 1844 configurable: !(bitmap & 2), 1845 writable: !(bitmap & 4), 1846 value: value 1847 }; 1848 }; 1849 1850 var _hide = _descriptors ? function (object, key, value) { 1851 return _objectDp.f(object, key, _propertyDesc(1, value)); 1852 } : function (object, key, value) { 1853 object[key] = value; 1854 return object; 1855 }; 1856 1857 var id = 0; 1858 var px = Math.random(); 1859 1860 var _uid = function (key) { 1861 return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); 1862 }; 1863 1864 var _redefine = createCommonjsModule(function (module) { 1865 var SRC = _uid('src'); 1866 1867 var TO_STRING = 'toString'; 1868 var $toString = Function[TO_STRING]; 1869 var TPL = ('' + $toString).split(TO_STRING); 1870 1871 _core.inspectSource = function (it) { 1872 return $toString.call(it); 1873 }; 1874 1875 (module.exports = function (O, key, val, safe) { 1876 var isFunction = typeof val == 'function'; 1877 if (isFunction) _has(val, 'name') || _hide(val, 'name', key); 1878 if (O[key] === val) return; 1879 if (isFunction) _has(val, SRC) || _hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); 1880 1881 if (O === _global) { 1882 O[key] = val; 1883 } else if (!safe) { 1884 delete O[key]; 1885 _hide(O, key, val); 1886 } else if (O[key]) { 1887 O[key] = val; 1888 } else { 1889 _hide(O, key, val); 1890 } // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative 1891 1892 })(Function.prototype, TO_STRING, function toString() { 1893 return typeof this == 'function' && this[SRC] || $toString.call(this); 1894 }); 1895 }); 1896 1897 var _aFunction = function (it) { 1898 if (typeof it != 'function') throw TypeError(it + ' is not a function!'); 1899 return it; 1900 }; 1901
vendor: 4,977 bytes, lines 1902-2111
1902 // optional / simple context binding 1903 1904 1905 var _ctx = function (fn, that, length) { 1906 _aFunction(fn); 1907 if (that === undefined) return fn; 1908 1909 switch (length) { 1910 case 1: 1911 return function (a) { 1912 return fn.call(that, a); 1913 }; 1914 1915 case 2: 1916 return function (a, b) { 1917 return fn.call(that, a, b); 1918 }; 1919 1920 case 3: 1921 return function (a, b, c) { 1922 return fn.call(that, a, b, c); 1923 }; 1924 } 1925 1926 return function () 1927 /* ...args */ 1928 { 1929 return fn.apply(that, arguments); 1930 }; 1931 }; 1932 1933 var PROTOTYPE = 'prototype'; 1934 1935 var $export = function $export(type, name, source) { 1936 var IS_FORCED = type & $export.F; 1937 var IS_GLOBAL = type & $export.G; 1938 var IS_STATIC = type & $export.S; 1939 var IS_PROTO = type & $export.P; 1940 var IS_BIND = type & $export.B; 1941 var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] || (_global[name] = {}) : (_global[name] || {})[PROTOTYPE]; 1942 var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {}); 1943 var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {}); 1944 var key, own, out, exp; 1945 if (IS_GLOBAL) source = name; 1946 1947 for (key in source) { 1948 // contains in native 1949 own = !IS_FORCED && target && target[key] !== undefined; // export native or passed 1950 1951 out = (own ? target : source)[key]; // bind timers to global for call from export context 1952 1953 exp = IS_BIND && own ? _ctx(out, _global) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out; // extend global 1954 1955 if (target) _redefine(target, key, out, type & $export.U); // export 1956 1957 if (exports[key] != out) _hide(exports, key, exp); 1958 if (IS_PROTO && expProto[key] != out) expProto[key] = out; 1959 } 1960 }; 1961 1962 $export.F = 1; // forced 1963 1964 $export.G = 2; // global 1965 1966 $export.S = 4; // static 1967 1968 $export.P = 8; // proto 1969 1970 $export.B = 16; // bind 1971 1972 $export.W = 32; // wrap 1973 1974 $export.U = 64; // safe 1975 1976 $export.R = 128; // real proto method for `library` 1977 1978 var _export = $export; 1979 1980 var _meta = createCommonjsModule(function (module) { 1981 var META = _uid('meta'); 1982 1983 1984 1985 1986 1987 var setDesc = _objectDp.f; 1988 1989 var id = 0; 1990 1991 var isExtensible = Object.isExtensible || function () { 1992 return true; 1993 }; 1994 1995 var FREEZE = !_fails(function () { 1996 return isExtensible(Object.preventExtensions({})); 1997 }); 1998 1999 var setMeta = function setMeta(it) { 2000 setDesc(it, META, { 2001 value: { 2002 i: 'O' + ++id, 2003 // object ID 2004 w: {} // weak collections IDs 2005 2006 } 2007 }); 2008 }; 2009 2010 var fastKey = function fastKey(it, create) { 2011 // return primitive with prefix 2012 if (!_isObject(it)) return babelHelpers.typeof(it) == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; 2013 2014 if (!_has(it, META)) { 2015 // can't set metadata to uncaught frozen object 2016 if (!isExtensible(it)) return 'F'; // not necessary to add metadata 2017 2018 if (!create) return 'E'; // add missing metadata 2019 2020 setMeta(it); // return object ID 2021 } 2022 2023 return it[META].i; 2024 }; 2025 2026 var getWeak = function getWeak(it, create) { 2027 if (!_has(it, META)) { 2028 // can't set metadata to uncaught frozen object 2029 if (!isExtensible(it)) return true; // not necessary to add metadata 2030 2031 if (!create) return false; // add missing metadata 2032 2033 setMeta(it); // return hash weak collections IDs 2034 } 2035 2036 return it[META].w; 2037 }; // add metadata on freeze-family methods calling 2038 2039 2040 var onFreeze = function onFreeze(it) { 2041 if (FREEZE && meta.NEED && isExtensible(it) && !_has(it, META)) setMeta(it); 2042 return it; 2043 }; 2044 2045 var meta = module.exports = { 2046 KEY: META, 2047 NEED: false, 2048 fastKey: fastKey, 2049 getWeak: getWeak, 2050 onFreeze: onFreeze 2051 }; 2052 }); 2053 var _meta_1 = _meta.KEY; 2054 var _meta_2 = _meta.NEED; 2055 var _meta_3 = _meta.fastKey; 2056 var _meta_4 = _meta.getWeak; 2057 var _meta_5 = _meta.onFreeze; 2058 2059 var _library = false; 2060 2061 var _shared = createCommonjsModule(function (module) { 2062 var SHARED = '__core-js_shared__'; 2063 var store = _global[SHARED] || (_global[SHARED] = {}); 2064 (module.exports = function (key, value) { 2065 return store[key] || (store[key] = value !== undefined ? value : {}); 2066 })('versions', []).push({ 2067 version: _core.version, 2068 mode: _library ? 'pure' : 'global', 2069 copyright: '(c) 2019 Denis Pushkarev (zloirock.ru)' 2070 }); 2071 }); 2072 2073 var _wks = createCommonjsModule(function (module) { 2074 var store = _shared('wks'); 2075 2076 2077 2078 var _Symbol = _global.Symbol; 2079 2080 var USE_SYMBOL = typeof _Symbol == 'function'; 2081 2082 var $exports = module.exports = function (name) { 2083 return store[name] || (store[name] = USE_SYMBOL && _Symbol[name] || (USE_SYMBOL ? _Symbol : _uid)('Symbol.' + name)); 2084 }; 2085 2086 $exports.store = store; 2087 }); 2088 2089 var def = _objectDp.f; 2090 2091 2092 2093 var TAG = _wks('toStringTag'); 2094 2095 var _setToStringTag = function (it, tag, stat) { 2096 if (it && !_has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { 2097 configurable: true, 2098 value: tag 2099 }); 2100 }; 2101 2102 var f$1 = _wks; 2103 2104 var _wksExt = { 2105 f: f$1 2106 }; 2107 2108 var defineProperty = _objectDp.f; 2109 2110 var _wksDefine = function (name) { 2111 var $Symbol = _core.Symbol || (_core.Symbol = _library ? {}
vendor: 2,295 bytes, lines 2111-2204
2111 : _global.Symbol || {}); 2112 if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { 2113 value: _wksExt.f(name) 2114 }); 2115 }; 2116 2117 var toString = {}.toString; 2118 2119 var _cof = function (it) { 2120 return toString.call(it).slice(8, -1); 2121 }; 2122 2123 // fallback for non-array-like ES3 and non-enumerable old V8 strings 2124 // eslint-disable-next-line no-prototype-builtins 2125 2126 2127 var _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) { 2128 return _cof(it) == 'String' ? it.split('') : Object(it); 2129 }; 2130 2131 // 7.2.1 RequireObjectCoercible(argument) 2132 var _defined = function (it) { 2133 if (it == undefined) throw TypeError("Can't call method on " + it); 2134 return it; 2135 }; 2136 2137 // to indexed object, toObject with fallback for non-array-like ES3 strings 2138 2139 2140 2141 2142 var _toIobject = function (it) { 2143 return _iobject(_defined(it)); 2144 }; 2145 2146 // 7.1.4 ToInteger 2147 var ceil = Math.ceil; 2148 var floor = Math.floor; 2149 2150 var _toInteger = function (it) { 2151 return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); 2152 }; 2153 2154 // 7.1.15 ToLength 2155 2156 2157 var min = Math.min; 2158 2159 var _toLength = function (it) { 2160 return it > 0 ? min(_toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 2161 }; 2162 2163 var max = Math.max; 2164 var min$1 = Math.min; 2165 2166 var _toAbsoluteIndex = function (index, length) { 2167 index = _toInteger(index); 2168 return index < 0 ? max(index + length, 0) : min$1(index, length); 2169 }; 2170 2171 // false -> Array#indexOf 2172 // true -> Array#includes 2173 2174 2175 2176 2177 2178 2179 var _arrayIncludes = function (IS_INCLUDES) { 2180 return function ($this, el, fromIndex) { 2181 var O = _toIobject($this); 2182 var length = _toLength(O.length); 2183 var index = _toAbsoluteIndex(fromIndex, length); 2184 var value; // Array#includes uses SameValueZero equality algorithm 2185 // eslint-disable-next-line no-self-compare 2186 2187 if (IS_INCLUDES && el != el) while (length > index) { 2188 value = O[index++]; // eslint-disable-next-line no-self-compare 2189 2190 if (value != value) return true; // Array#indexOf ignores holes, Array#includes - not 2191 } else for (; length > index; index++) { 2192 if (IS_INCLUDES || index in O) { 2193 if (O[index] === el) return IS_INCLUDES || index || 0; 2194 } 2195 } 2196 return !IS_INCLUDES && -1; 2197 }; 2198 }; 2199 2200 var shared = _shared('keys'); 2201 2202 2203 2204 var _sharedKey = function (key) {
2205 return shared[key] || (shared[key] = _uid(key)); 2206 }; 2207 2208 var arrayIndexOf = _arrayIncludes(false); 2209 2210 var IE_PROTO = _sharedKey('IE_PROTO'); 2211 2212 var _objectKeysInternal = function (object, names) { 2213 var O = _toIobject(object); 2214 var i = 0; 2215 var result = []; 2216 var key; 2217 2218 for (key in O) { 2219 if (key != IE_PROTO) _has(O, key) && result.push(key); 2220 } // Don't enum bug & hidden keys 2221 2222 2223 while (names.length > i) { 2224 if (_has(O, key = names[i++])) { 2225 ~arrayIndexOf(result, key) || result.push(key); 2226 } 2227 } 2228 2229 return result; 2230 }; 2231 2232 // IE 8- don't enum bug keys 2233 var _enumBugKeys = 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'.split(','); 2234 2235 // 19.1.2.14 / 15.2.3.14 Object.keys(O) 2236 2237 2238 2239 2240 var _objectKeys = Object.keys || function keys(O) { 2241 return _objectKeysInternal(O, _enumBugKeys); 2242 }; 2243 2244 var f$2 = Object.getOwnPropertySymbols; 2245 2246 var _objectGops = { 2247 f: f$2 2248 }; 2249 2250 var f$3 = {}.propertyIsEnumerable; 2251 2252 var _objectPie = { 2253 f: f$3 2254 }; 2255 2256 // all enumerable object keys, includes symbols 2257 2258 2259 2260 2261 2262 2263 var _enumKeys = function (it) { 2264 var result = _objectKeys(it); 2265 var getSymbols = _objectGops.f; 2266 2267 if (getSymbols) { 2268 var symbols = getSymbols(it); 2269 var isEnum = _objectPie.f; 2270 var i = 0; 2271 var key; 2272 2273 while (symbols.length > i) { 2274 if (isEnum.call(it, key = symbols[i++])) result.push(key); 2275 } 2276 } 2277 2278 return result; 2279 }; 2280 2281 // 7.2.2 IsArray(argument) 2282 2283 2284 var _isArray = Array.isArray || function isArray(arg) { 2285 return _cof(arg) == 'Array'; 2286 }; 2287 2288 var _objectDps = _descriptors ? Object.defineProperties : function defineProperties(O, Properties) { 2289 _anObject(O); 2290 var keys = _objectKeys(Properties); 2291 var length = keys.length; 2292 var i = 0; 2293 var P; 2294 2295 while (length > i) { 2296 _objectDp.f(O, P = keys[i++], Properties[P]); 2297 } 2298 2299 return O; 2300 }; 2301 2302 var document$2 = _global.document; 2303 2304 var _html = document$2 && document$2.documentElement; 2305 2306 // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) 2307 2308 2309 2310 2311 2312 2313 var IE_PROTO$1 = _sharedKey('IE_PROTO'); 2314 2315 var Empty = function Empty() { 2316 /* empty */ 2317 }; 2318 2319 var PROTOTYPE$1 = 'prototype'; // Create object with fake `null` prototype: use iframe Object with cleared prototype 2320 2321 var _createDict = function createDict() { 2322 // Thrash, waste and sodomy: IE GC bug 2323 var iframe = _domCreate('iframe'); 2324 2325 var i = _enumBugKeys.length; 2326 var lt = '<'; 2327 var gt = '>'; 2328 var iframeDocument; 2329 iframe.style.display = 'none'; 2330 2331 _html.appendChild(iframe); 2332 2333 iframe.src = 'javascript:'; // eslint-disable-line no-script-url 2334 // createDict = iframe.contentWindow.Object; 2335 // html.removeChild(iframe); 2336 2337 iframeDocument = iframe.contentWindow.document; 2338 iframeDocument.open(); 2339 iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt); 2340 iframeDocument.close(); 2341 _createDict = iframeDocument.F; 2342 2343 while (i--) { 2344 delete _createDict[PROTOTYPE$1][_enumBugKeys[i]]; 2345 } 2346 2347 return _createDict(); 2348 }; 2349 2350 var _objectCreate = Object.create || function create(O, Properties) { 2351 var result; 2352 2353 if (O !== null) { 2354 Empty[PROTOTYPE$1] = _anObject(O); 2355 result = new Empty(); 2356 Empty[PROTOTYPE$1] = null; // add "__proto__" for Object.getPrototypeOf polyfill 2357 2358 result[IE_PROTO$1] = O; 2359 } else result = _createDict(); 2360 2361 return Properties === undefined ? result : _objectDps(result, Properties); 2362 }; 2363 2364 // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) 2365 2366 2367 var hiddenKeys = _enumBugKeys.concat('length', 'prototype'); 2368 2369 var f$4 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { 2370 return _objectKeysInternal(O, hiddenKeys); 2371 }; 2372 2373 var _objectGopn = { 2374 f: f$4 2375 }; 2376 2377 // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window 2378 2379 2380 var gOPN = _objectGopn.f; 2381 2382 var toString$1 = {}.toString; 2383 var windowNames = (typeof window === "undefined" ? "undefined" : babelHelpers.typeof(window)) == 'object' && window && Object.getOwnPropertyNames ? Object.getOwnPropertyNames(window) : []; 2384 2385 var getWindowNames = function getWindowNames(it) { 2386 try { 2387 return gOPN(it); 2388 } catch (e) { 2389 return windowNames.slice(); 2390 } 2391 }; 2392 2393 var f$5 = function getOwnPropertyNames(it) { 2394 return windowNames && toString$1.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(_toIobject(it)); 2395 }; 2396 2397 var _objectGopnExt = { 2398 f: f$5 2399 }; 2400 2401 var gOPD = Object.getOwnPropertyDescriptor; 2402 var f$6 = _descriptors ? gOPD : function getOwnPropertyDescriptor(O, P) { 2403 O = _toIobject(O); 2404 P = _toPrimitive(P, true); 2405 if (_ie8DomDefine) try { 2406 return gOPD(O, P); 2407 } catch (e) { 2408 /* empty */ 2409 } 2410 if (_has(O, P)) return _propertyDesc(!_objectPie.f.call(O, P), O[P]); 2411 }; 2412 2413 var _objectGopd = { 2414 f: f$6 2415 }; 2416 2417 var META = _meta.KEY; 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 var gOPD$1 = _objectGopd.f; 2458 var dP$1 = _objectDp.f; 2459 var gOPN$1 = _objectGopnExt.f; 2460 var $Symbol = _global.Symbol; 2461 var $JSON = _global.JSON; 2462 2463 var _stringify = $JSON && $JSON.stringify; 2464 2465 var PROTOTYPE$2 = 'prototype'; 2466 var HIDDEN = _wks('_hidden'); 2467 var TO_PRIMITIVE = _wks('toPrimitive'); 2468 var isEnum = {}.propertyIsEnumerable; 2469 var SymbolRegistry = _shared('symbol-registry'); 2470 var AllSymbols = _shared('symbols');
vendor: 4,817 bytes, lines 2471-2626
2471 var OPSymbols = _shared('op-symbols'); 2472 var ObjectProto = Object[PROTOTYPE$2]; 2473 var USE_NATIVE = typeof $Symbol == 'function'; 2474 var QObject = _global.QObject; // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173 2475 2476 var setter = !QObject || !QObject[PROTOTYPE$2] || !QObject[PROTOTYPE$2].findChild; // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687 2477 2478 var setSymbolDesc = _descriptors && _fails(function () { 2479 return _objectCreate(dP$1({}, 'a', { 2480 get: function get() { 2481 return dP$1(this, 'a', { 2482 value: 7 2483 }).a; 2484 } 2485 })).a != 7; 2486 }) ? function (it, key, D) { 2487 var protoDesc = gOPD$1(ObjectProto, key); 2488 if (protoDesc) delete ObjectProto[key]; 2489 dP$1(it, key, D); 2490 if (protoDesc && it !== ObjectProto) dP$1(ObjectProto, key, protoDesc); 2491 } : dP$1; 2492 2493 var wrap = function wrap(tag) { 2494 var sym = AllSymbols[tag] = _objectCreate($Symbol[PROTOTYPE$2]); 2495 2496 sym._k = tag; 2497 return sym; 2498 }; 2499 2500 var isSymbol = USE_NATIVE && babelHelpers.typeof($Symbol.iterator) == 'symbol' ? function (it) { 2501 return babelHelpers.typeof(it) == 'symbol'; 2502 } : function (it) { 2503 return it instanceof $Symbol; 2504 }; 2505 2506 var $defineProperty = function defineProperty(it, key, D) { 2507 if (it === ObjectProto) $defineProperty(OPSymbols, key, D); 2508 _anObject(it); 2509 key = _toPrimitive(key, true); 2510 _anObject(D); 2511 2512 if (_has(AllSymbols, key)) { 2513 if (!D.enumerable) { 2514 if (!_has(it, HIDDEN)) dP$1(it, HIDDEN, _propertyDesc(1, {})); 2515 it[HIDDEN][key] = true; 2516 } else { 2517 if (_has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false; 2518 D = _objectCreate(D, { 2519 enumerable: _propertyDesc(0, false) 2520 }); 2521 } 2522 2523 return setSymbolDesc(it, key, D); 2524 } 2525 2526 return dP$1(it, key, D); 2527 }; 2528 2529 var $defineProperties = function defineProperties(it, P) { 2530 _anObject(it); 2531 var keys = _enumKeys(P = _toIobject(P)); 2532 var i = 0; 2533 var l = keys.length; 2534 var key; 2535 2536 while (l > i) { 2537 $defineProperty(it, key = keys[i++], P[key]); 2538 } 2539 2540 return it; 2541 }; 2542 2543 var $create = function create(it, P) { 2544 return P === undefined ? _objectCreate(it) : $defineProperties(_objectCreate(it), P); 2545 }; 2546 2547 var $propertyIsEnumerable = function propertyIsEnumerable(key) { 2548 var E = isEnum.call(this, key = _toPrimitive(key, true)); 2549 if (this === ObjectProto && _has(AllSymbols, key) && !_has(OPSymbols, key)) return false; 2550 return E || !_has(this, key) || !_has(AllSymbols, key) || _has(this, HIDDEN) && this[HIDDEN][key] ? E : true; 2551 }; 2552 2553 var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) { 2554 it = _toIobject(it); 2555 key = _toPrimitive(key, true); 2556 if (it === ObjectProto && _has(AllSymbols, key) && !_has(OPSymbols, key)) return; 2557 var D = gOPD$1(it, key); 2558 if (D && _has(AllSymbols, key) && !(_has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true; 2559 return D; 2560 }; 2561 2562 var $getOwnPropertyNames = function getOwnPropertyNames(it) { 2563 var names = gOPN$1(_toIobject(it)); 2564 var result = []; 2565 var i = 0; 2566 var key; 2567 2568 while (names.length > i) { 2569 if (!_has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key); 2570 } 2571 2572 return result; 2573 }; 2574 2575 var $getOwnPropertySymbols = function getOwnPropertySymbols(it) { 2576 var IS_OP = it === ObjectProto; 2577 var names = gOPN$1(IS_OP ? OPSymbols : _toIobject(it)); 2578 var result = []; 2579 var i = 0; 2580 var key; 2581 2582 while (names.length > i) { 2583 if (_has(AllSymbols, key = names[i++]) && (IS_OP ? _has(ObjectProto, key) : true)) result.push(AllSymbols[key]); 2584 } 2585 2586 return result; 2587 }; // 19.4.1.1 Symbol([description]) 2588 2589 2590 if (!USE_NATIVE) { 2591 $Symbol = function _Symbol() { 2592 if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!'); 2593 var tag = _uid(arguments.length > 0 ? arguments[0] : undefined); 2594 2595 var $set = function $set(value) { 2596 if (this === ObjectProto) $set.call(OPSymbols, value); 2597 if (_has(this, HIDDEN) && _has(this[HIDDEN], tag)) this[HIDDEN][tag] = false; 2598 setSymbolDesc(this, tag, _propertyDesc(1, value)); 2599 }; 2600 2601 if (_descriptors && setter) setSymbolDesc(ObjectProto, tag, { 2602 configurable: true, 2603 set: $set 2604 }); 2605 return wrap(tag); 2606 }; 2607 2608 _redefine($Symbol[PROTOTYPE$2], 'toString', function toString() { 2609 return this._k; 2610 }); 2611 _objectGopd.f = $getOwnPropertyDescriptor; 2612 _objectDp.f = $defineProperty; 2613 _objectGopn.f = _objectGopnExt.f = $getOwnPropertyNames; 2614 _objectPie.f = $propertyIsEnumerable; 2615 _objectGops.f = $getOwnPropertySymbols; 2616 2617 if (_descriptors && !_library) { 2618 _redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true); 2619 } 2620 2621 _wksExt.f = function (name) { 2622 return wrap(_wks(name)); 2623 }; 2624 } 2625 2626 _export(_export.G + _export.W + _export.F * !USE_NATIVE, {
2627 Symbol: $Symbol 2628 }); 2629 2630 for (var es6Symbols = // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14 2631 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'.split(','), j = 0; es6Symbols.length > j;) { 2632 _wks(es6Symbols[j++]); 2633 } 2634 2635 for (var wellKnownSymbols = _objectKeys(_wks.store), k = 0; wellKnownSymbols.length > k;) { 2636 _wksDefine(wellKnownSymbols[k++]); 2637 } 2638 2639 _export(_export.S + _export.F * !USE_NATIVE, 'Symbol', { 2640 // 19.4.2.1 Symbol.for(key) 2641 'for': function _for(key) { 2642 return _has(SymbolRegistry, key += '') ? SymbolRegistry[key] : SymbolRegistry[key] = $Symbol(key); 2643 }, 2644 // 19.4.2.5 Symbol.keyFor(sym) 2645 keyFor: function keyFor(sym) { 2646 if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!'); 2647 2648 for (var key in SymbolRegistry) { 2649 if (SymbolRegistry[key] === sym) return key; 2650 } 2651 }, 2652 useSetter: function useSetter() { 2653 setter = true; 2654 }, 2655 useSimple: function useSimple() { 2656 setter = false; 2657 } 2658 }); 2659 _export(_export.S + _export.F * !USE_NATIVE, 'Object', { 2660 // 19.1.2.2 Object.create(O [, Properties]) 2661 create: $create, 2662 // 19.1.2.4 Object.defineProperty(O, P, Attributes) 2663 defineProperty: $defineProperty, 2664 // 19.1.2.3 Object.defineProperties(O, Properties) 2665 defineProperties: $defineProperties, 2666 // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) 2667 getOwnPropertyDescriptor: $getOwnPropertyDescriptor, 2668 // 19.1.2.7 Object.getOwnPropertyNames(O) 2669 getOwnPropertyNames: $getOwnPropertyNames, 2670 // 19.1.2.8 Object.getOwnPropertySymbols(O) 2671 getOwnPropertySymbols: $getOwnPropertySymbols 2672 }); // 24.3.2 JSON.stringify(value [, replacer [, space]]) 2673 2674 $JSON && _export(_export.S + _export.F * (!USE_NATIVE || _fails(function () { 2675 var S = $Symbol(); // MS Edge converts symbol values to JSON as {} 2676 // WebKit converts symbol values to JSON as null 2677 // V8 throws on boxed symbols 2678 2679 return _stringify([S]) != '[null]' || _stringify({ 2680 a: S 2681 }) != '{}' || _stringify(Object(S)) != '{}'; 2682 })), 'JSON', { 2683 stringify: function stringify(it) { 2684 var args = [it]; 2685 var i = 1; 2686 var replacer, $replacer; 2687 2688 while (arguments.length > i) { 2689 args.push(arguments[i++]); 2690 } 2691 2692 $replacer = replacer = args[1]; 2693 if (!_isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined 2694 2695 if (!_isArray(replacer)) replacer = function replacer(key, value) { 2696 if (typeof $replacer == 'function') value = $replacer.call(this, key, value); 2697 if (!isSymbol(value)) return value; 2698 }; 2699 args[1] = replacer; 2700 return _stringify.apply($JSON, args); 2701 } 2702 }); // 19.4.3.4 Symbol.prototype[@@toPrimitive](hint) 2703 2704 $Symbol[PROTOTYPE$2][TO_PRIMITIVE] || _hide($Symbol[PROTOTYPE$2], TO_PRIMITIVE, $Symbol[PROTOTYPE$2].valueOf); // 19.4.3.5 Symbol.prototype[@@toStringTag] 2705 2706 _setToStringTag($Symbol, 'Symbol'); // 20.2.1.9 Math[@@toStringTag] 2707 2708 _setToStringTag(Math, 'Math', true); // 24.3.3 JSON[@@toStringTag] 2709 2710 _setToStringTag(_global.JSON, 'JSON', true); 2711 2712 // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) 2713 2714 2715 _export(_export.S, 'Object', { 2716 create: _objectCreate 2717 }); 2718 2719 // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes) 2720 2721 2722 _export(_export.S + _export.F * !_descriptors, 'Object', { 2723 defineProperty: _objectDp.f 2724 }); 2725 2726 // 19.1.2.3 / 15.2.3.7 Object.defineProperties(O, Properties) 2727 2728 2729 _export(_export.S + _export.F * !_descriptors, 'Object', { 2730 defineProperties: _objectDps 2731 }); 2732 2733 // most Object methods by ES6 should accept primitives 2734 2735 2736 2737 2738 2739 2740 var _objectSap = function (KEY, exec) { 2741 var fn = (_core.Object || {})[KEY] || Object[KEY]; 2742 var exp = {}; 2743 exp[KEY] = exec(fn); 2744 _export(_export.S + _export.F * _fails(function () { 2745 fn(1); 2746 }), 'Object', exp); 2747 }; 2748 2749 // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) 2750 2751 2752 var $getOwnPropertyDescriptor$1 = _objectGopd.f; 2753 2754 _objectSap('getOwnPropertyDescriptor', function () { 2755 return function getOwnPropertyDescriptor(it, key) { 2756 return $getOwnPropertyDescriptor$1(_toIobject(it), key); 2757 }; 2758 }); 2759 2760 // 7.1.13 ToObject(argument) 2761 2762 2763 var _toObject = function (it) { 2764 return Object(_defined(it)); 2765 }; 2766 2767 // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) 2768 2769 2770 2771 2772 var IE_PROTO$2 = _sharedKey('IE_PROTO'); 2773 2774 var ObjectProto$1 = Object.prototype; 2775 2776 var _objectGpo = Object.getPrototypeOf || function (O) { 2777 O = _toObject(O); 2778 if (_has(O, IE_PROTO$2)) return O[IE_PROTO$2]; 2779 2780 if (typeof O.constructor == 'function' && O instanceof O.constructor) { 2781 return O.constructor.prototype; 2782 } 2783 2784 return O instanceof Object ? ObjectProto$1 : null; 2785 }; 2786 2787 // 19.1.2.9 Object.getPrototypeOf(O) 2788 2789 2790 2791 2792 _objectSap('getPrototypeOf', function () { 2793 return function getPrototypeOf(it) { 2794 return _objectGpo(_toObject(it)); 2795 }; 2796 }); 2797
vendor: 37,188 bytes, lines 2798-4260
2798 // 19.1.2.14 Object.keys(O) 2799 2800 2801 2802 2803 _objectSap('keys', function () { 2804 return function keys(it) { 2805 return _objectKeys(_toObject(it)); 2806 }; 2807 }); 2808 2809 // 19.1.2.7 Object.getOwnPropertyNames(O) 2810 _objectSap('getOwnPropertyNames', function () { 2811 return _objectGopnExt.f; 2812 }); 2813 2814 // 19.1.2.5 Object.freeze(O) 2815 2816 2817 var meta = _meta.onFreeze; 2818 2819 _objectSap('freeze', function ($freeze) { 2820 return function freeze(it) { 2821 return $freeze && _isObject(it) ? $freeze(meta(it)) : it; 2822 }; 2823 }); 2824 2825 // 19.1.2.17 Object.seal(O) 2826 2827 2828 var meta$1 = _meta.onFreeze; 2829 2830 _objectSap('seal', function ($seal) { 2831 return function seal(it) { 2832 return $seal && _isObject(it) ? $seal(meta$1(it)) : it; 2833 }; 2834 }); 2835 2836 // 19.1.2.15 Object.preventExtensions(O) 2837 2838 2839 var meta$2 = _meta.onFreeze; 2840 2841 _objectSap('preventExtensions', function ($preventExtensions) { 2842 return function preventExtensions(it) { 2843 return $preventExtensions && _isObject(it) ? $preventExtensions(meta$2(it)) : it; 2844 }; 2845 }); 2846 2847 // 19.1.2.12 Object.isFrozen(O) 2848 2849 2850 _objectSap('isFrozen', function ($isFrozen) { 2851 return function isFrozen(it) { 2852 return _isObject(it) ? $isFrozen ? $isFrozen(it) : false : true; 2853 }; 2854 }); 2855 2856 // 19.1.2.13 Object.isSealed(O) 2857 2858 2859 _objectSap('isSealed', function ($isSealed) { 2860 return function isSealed(it) { 2861 return _isObject(it) ? $isSealed ? $isSealed(it) : false : true; 2862 }; 2863 }); 2864 2865 // 19.1.2.11 Object.isExtensible(O) 2866 2867 2868 _objectSap('isExtensible', function ($isExtensible) { 2869 return function isExtensible(it) { 2870 return _isObject(it) ? $isExtensible ? $isExtensible(it) : true : false; 2871 }; 2872 }); 2873 2874 var $assign = Object.assign; // should work with symbols and should have deterministic property order (V8 bug) 2875 2876 var _objectAssign = !$assign || _fails(function () { 2877 var A = {}; 2878 var B = {}; // eslint-disable-next-line no-undef 2879 2880 var S = Symbol(); 2881 var K = 'abcdefghijklmnopqrst'; 2882 A[S] = 7; 2883 K.split('').forEach(function (k) { 2884 B[k] = k; 2885 }); 2886 return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K; 2887 }) ? function assign(target, source) { 2888 // eslint-disable-line no-unused-vars 2889 var T = _toObject(target); 2890 var aLen = arguments.length; 2891 var index = 1; 2892 var getSymbols = _objectGops.f; 2893 var isEnum = _objectPie.f; 2894 2895 while (aLen > index) { 2896 var S = _iobject(arguments[index++]); 2897 var keys = getSymbols ? _objectKeys(S).concat(getSymbols(S)) : _objectKeys(S); 2898 var length = keys.length; 2899 var j = 0; 2900 var key; 2901 2902 while (length > j) { 2903 if (isEnum.call(S, key = keys[j++])) T[key] = S[key]; 2904 } 2905 } 2906 2907 return T; 2908 } : $assign; 2909 2910 // 19.1.3.1 Object.assign(target, source) 2911 2912 2913 _export(_export.S + _export.F, 'Object', { 2914 assign: _objectAssign 2915 }); 2916 2917 // 7.2.9 SameValue(x, y) 2918 var _sameValue = Object.is || function is(x, y) { 2919 // eslint-disable-next-line no-self-compare 2920 return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y; 2921 }; 2922 2923 // 19.1.3.10 Object.is(value1, value2) 2924 2925 2926 _export(_export.S, 'Object', { 2927 is: _sameValue 2928 }); 2929 2930 // Works with __proto__ only. Old v8 can't work with null proto objects. 2931 2932 /* eslint-disable no-proto */ 2933 2934 2935 2936 2937 var check = function check(O, proto) { 2938 _anObject(O); 2939 if (!_isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!"); 2940 }; 2941 2942 var _setProto = { 2943 set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line 2944 function (test, buggy, set) { 2945 try { 2946 set = _ctx(Function.call, _objectGopd.f(Object.prototype, '__proto__').set, 2); 2947 set(test, []); 2948 buggy = !(test instanceof Array); 2949 } catch (e) { 2950 buggy = true; 2951 } 2952 2953 return function setPrototypeOf(O, proto) { 2954 check(O, proto); 2955 if (buggy) O.__proto__ = proto;else set(O, proto); 2956 return O; 2957 }; 2958 }({}, false) : undefined), 2959 check: check 2960 }; 2961 2962 // 19.1.3.19 Object.setPrototypeOf(O, proto) 2963 2964 2965 _export(_export.S, 'Object', { 2966 setPrototypeOf: _setProto.set 2967 }); 2968 2969 // getting tag from 19.1.3.6 Object.prototype.toString() 2970 2971 2972 var TAG$1 = _wks('toStringTag'); // ES3 wrong here 2973 2974 2975 var ARG = _cof(function () { 2976 return arguments; 2977 }()) == 'Arguments'; // fallback for IE11 Script Access Denied error 2978 2979 var tryGet = function tryGet(it, key) { 2980 try { 2981 return it[key]; 2982 } catch (e) { 2983 /* empty */ 2984 } 2985 }; 2986 2987 var _classof = function (it) { 2988 var O, T, B; 2989 return it === undefined ? 'Undefined' : it === null ? 'Null' // @@toStringTag case 2990 : typeof (T = tryGet(O = Object(it), TAG$1)) == 'string' ? T // builtinTag case 2991 : ARG ? _cof(O) // ES3 arguments fallback 2992 : (B = _cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; 2993 }; 2994 2995 var test = {}; 2996 test[_wks('toStringTag')] = 'z'; 2997 2998 if (test + '' != '[object z]') { 2999 _redefine(Object.prototype, 'toString', function toString() { 3000 return '[object ' + _classof(this) + ']'; 3001 }, true); 3002 } 3003 3004 // fast apply, http://jsperf.lnkit.com/fast-apply/5 3005 var _invoke = function (fn, args, that) { 3006 var un = that === undefined; 3007 3008 switch (args.length) { 3009 case 0: 3010 return un ? fn() : fn.call(that); 3011 3012 case 1: 3013 return un ? fn(args[0]) : fn.call(that, args[0]); 3014 3015 case 2: 3016 return un ? fn(args[0], args[1]) : fn.call(that, args[0], args[1]); 3017 3018 case 3: 3019 return un ? fn(args[0], args[1], args[2]) : fn.call(that, args[0], args[1], args[2]); 3020 3021 case 4: 3022 return un ? fn(args[0], args[1], args[2], args[3]) : fn.call(that, args[0], args[1], args[2], args[3]); 3023 } 3024 3025 return fn.apply(that, args); 3026 }; 3027 3028 var arraySlice = [].slice; 3029 var factories = {}; 3030 3031 var construct = function construct(F, len, args) { 3032 if (!(len in factories)) { 3033 for (var n = [], i = 0; i < len; i++) { 3034 n[i] = 'a[' + i + ']'; 3035 } // eslint-disable-next-line no-new-func 3036 3037 3038 factories[len] = Function('F,a', 'return new F(' + n.join(',') + ')'); 3039 } 3040 3041 return factories[len](F, args); 3042 }; 3043 3044 var _bind = Function.bind || function bind(that 3045 /* , ...args */ 3046 ) { 3047 var fn = _aFunction(this); 3048 var partArgs = arraySlice.call(arguments, 1); 3049 3050 var bound = function bound() 3051 /* args... */ 3052 { 3053 var args = partArgs.concat(arraySlice.call(arguments)); 3054 return this instanceof bound ? construct(fn, args.length, args) : _invoke(fn, args, that); 3055 }; 3056 3057 if (_isObject(fn.prototype)) bound.prototype = fn.prototype; 3058 return bound; 3059 }; 3060 3061 // 19.2.3.2 / 15.3.4.5 Function.prototype.bind(thisArg, args...) 3062 3063 3064 _export(_export.P, 'Function', { 3065 bind: _bind 3066 }); 3067 3068 var dP$2 = _objectDp.f; 3069 3070 var FProto = Function.prototype; 3071 var nameRE = /^\s*function ([^ (]*)/; 3072 var NAME = 'name'; // 19.2.4.2 name 3073 3074 NAME in FProto || _descriptors && dP$2(FProto, NAME, { 3075 configurable: true, 3076 get: function get() { 3077 try { 3078 return ('' + this).match(nameRE)[1]; 3079 } catch (e) { 3080 return ''; 3081 } 3082 } 3083 }); 3084 3085 var HAS_INSTANCE = _wks('hasInstance'); 3086 3087 var FunctionProto = Function.prototype; // 19.2.3.6 Function.prototype[@@hasInstance](V) 3088 3089 if (!(HAS_INSTANCE in FunctionProto)) _objectDp.f(FunctionProto, HAS_INSTANCE, { 3090 value: function value(O) { 3091 if (typeof this != 'function' || !_isObject(O)) return false; 3092 if (!_isObject(this.prototype)) return O instanceof this; // for environment w/o native `@@hasInstance` logic enough `instanceof`, but add this: 3093 3094 while (O = _objectGpo(O)) { 3095 if (this.prototype === O) return true; 3096 } 3097 3098 return false; 3099 } 3100 }); 3101 3102 var _stringWs = "\t\n\x0B\f\r \xA0\u1680\u180E\u2000\u2001\u2002\u2003" + "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF"; 3103 3104 var space = '[' + _stringWs + ']'; 3105 var non = "\u200B\x85"; 3106 var ltrim = RegExp('^' + space + space + '*'); 3107 var rtrim = RegExp(space + space + '*$'); 3108 3109 var exporter = function exporter(KEY, exec, ALIAS) { 3110 var exp = {}; 3111 var FORCE = _fails(function () { 3112 return !!_stringWs[KEY]() || non[KEY]() != non; 3113 }); 3114 var fn = exp[KEY] = FORCE ? exec(trim) : _stringWs[KEY]; 3115 if (ALIAS) exp[ALIAS] = fn; 3116 _export(_export.P + _export.F * FORCE, 'String', exp); 3117 }; // 1 -> String#trimLeft 3118 // 2 -> String#trimRight 3119 // 3 -> String#trim 3120 3121 3122 var trim = exporter.trim = function (string, TYPE) { 3123 string = String(_defined(string)); 3124 if (TYPE & 1) string = string.replace(ltrim, ''); 3125 if (TYPE & 2) string = string.replace(rtrim, ''); 3126 return string; 3127 }; 3128 3129 var _stringTrim = exporter; 3130 3131 var $parseInt = _global.parseInt; 3132 3133 var $trim = _stringTrim.trim; 3134 3135 3136 3137 var hex = /^[-+]?0[xX]/; 3138 var _parseInt = $parseInt(_stringWs + '08') !== 8 || $parseInt(_stringWs + '0x16') !== 22 ? function parseInt(str, radix) { 3139 var string = $trim(String(str), 3); 3140 return $parseInt(string, radix >>> 0 || (hex.test(string) ? 16 : 10)); 3141 } : $parseInt; 3142 3143 // 18.2.5 parseInt(string, radix) 3144 3145 3146 _export(_export.G + _export.F * (parseInt != _parseInt), { 3147 parseInt: _parseInt 3148 }); 3149 3150 var $parseFloat = _global.parseFloat; 3151 3152 var $trim$1 = _stringTrim.trim; 3153 3154 var _parseFloat = 1 / $parseFloat(_stringWs + '-0') !== -Infinity ? function parseFloat(str) { 3155 var string = $trim$1(String(str), 3); 3156 var result = $parseFloat(string); 3157 return result === 0 && string.charAt(0) == '-' ? -0 : result; 3158 } : $parseFloat; 3159 3160 // 18.2.4 parseFloat(string) 3161 3162 3163 _export(_export.G + _export.F * (parseFloat != _parseFloat), { 3164 parseFloat: _parseFloat 3165 }); 3166 3167 var setPrototypeOf = _setProto.set; 3168 3169 var _inheritIfRequired = function (that, target, C) { 3170 var S = target.constructor; 3171 var P; 3172 3173 if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && _isObject(P) && setPrototypeOf) { 3174 setPrototypeOf(that, P); 3175 } 3176 3177 return that; 3178 }; 3179 3180 var gOPN$2 = _objectGopn.f; 3181 3182 var gOPD$2 = _objectGopd.f; 3183 3184 var dP$3 = _objectDp.f; 3185 3186 var $trim$2 = _stringTrim.trim; 3187 3188 var NUMBER = 'Number'; 3189 var $Number = _global[NUMBER]; 3190 var Base = $Number; 3191 var proto = $Number.prototype; // Opera ~12 has broken Object#toString 3192 3193 var BROKEN_COF = _cof(_objectCreate(proto)) == NUMBER; 3194 var TRIM = 'trim' in String.prototype; // 7.1.3 ToNumber(argument) 3195 3196 var toNumber = function toNumber(argument) { 3197 var it = _toPrimitive(argument, false); 3198 3199 if (typeof it == 'string' && it.length > 2) { 3200 it = TRIM ? it.trim() : $trim$2(it, 3); 3201 var first = it.charCodeAt(0); 3202 var third, radix, maxCode; 3203 3204 if (first === 43 || first === 45) { 3205 third = it.charCodeAt(2); 3206 if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix 3207 } else if (first === 48) { 3208 switch (it.charCodeAt(1)) { 3209 case 66: 3210 case 98: 3211 radix = 2; 3212 maxCode = 49; 3213 break; 3214 // fast equal /^0b[01]+$/i 3215 3216 case 79: 3217 case 111: 3218 radix = 8; 3219 maxCode = 55; 3220 break; 3221 // fast equal /^0o[0-7]+$/i 3222 3223 default: 3224 return +it; 3225 } 3226 3227 for (var digits = it.slice(2), i = 0, l = digits.length, code; i < l; i++) { 3228 code = digits.charCodeAt(i); // parseInt parses a string to a first unavailable symbol 3229 // but ToNumber should return NaN if a string contains unavailable symbols 3230 3231 if (code < 48 || code > maxCode) return NaN; 3232 } 3233 3234 return parseInt(digits, radix); 3235 } 3236 } 3237 3238 return +it; 3239 }; 3240 3241 if (!$Number(' 0o1') || !$Number('0b1') || $Number('+0x1')) { 3242 $Number = function Number(value) { 3243 var it = arguments.length < 1 ? 0 : value; 3244 var that = this; 3245 return that instanceof $Number // check on 1..constructor(foo) case 3246 && (BROKEN_COF ? _fails(function () { 3247 proto.valueOf.call(that); 3248 }) : _cof(that) != NUMBER) ? _inheritIfRequired(new Base(toNumber(it)), that, $Number) : toNumber(it); 3249 }; 3250 3251 for (var keys = _descriptors ? gOPN$2(Base) : ( // ES3: 3252 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' + // ES6 (in case, if modules with ES6 Number statics required before): 3253 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' + 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger').split(','), j$1 = 0, key; keys.length > j$1; j$1++) { 3254 if (_has(Base, key = keys[j$1]) && !_has($Number, key)) { 3255 dP$3($Number, key, gOPD$2(Base, key)); 3256 } 3257 } 3258 3259 $Number.prototype = proto; 3260 proto.constructor = $Number; 3261 3262 _redefine(_global, NUMBER, $Number); 3263 } 3264 3265 var _aNumberValue = function (it, msg) { 3266 if (typeof it != 'number' && _cof(it) != 'Number') throw TypeError(msg); 3267 return +it; 3268 }; 3269 3270 var _stringRepeat = function repeat(count) { 3271 var str = String(_defined(this)); 3272 var res = ''; 3273 var n = _toInteger(count); 3274 if (n < 0 || n == Infinity) throw RangeError("Count can't be negative"); 3275 3276 for (; n > 0; (n >>>= 1) && (str += str)) { 3277 if (n & 1) res += str; 3278 } 3279 3280 return res; 3281 }; 3282 3283 var $toFixed = 1.0.toFixed; 3284 var floor$1 = Math.floor; 3285 var data = [0, 0, 0, 0, 0, 0]; 3286 var ERROR = 'Number.toFixed: incorrect invocation!'; 3287 var ZERO = '0'; 3288 3289 var multiply = function multiply(n, c) { 3290 var i = -1; 3291 var c2 = c; 3292 3293 while (++i < 6) { 3294 c2 += n * data[i]; 3295 data[i] = c2 % 1e7; 3296 c2 = floor$1(c2 / 1e7); 3297 } 3298 }; 3299 3300 var divide = function divide(n) { 3301 var i = 6; 3302 var c = 0; 3303 3304 while (--i >= 0) { 3305 c += data[i]; 3306 data[i] = floor$1(c / n); 3307 c = c % n * 1e7; 3308 } 3309 }; 3310 3311 var numToString = function numToString() { 3312 var i = 6; 3313 var s = ''; 3314 3315 while (--i >= 0) { 3316 if (s !== '' || i === 0 || data[i] !== 0) { 3317 var t = String(data[i]); 3318 s = s === '' ? t : s + _stringRepeat.call(ZERO, 7 - t.length) + t; 3319 } 3320 } 3321 3322 return s; 3323 }; 3324 3325 var pow = function pow(x, n, acc) { 3326 return n === 0 ? acc : n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc); 3327 }; 3328 3329 var log = function log(x) { 3330 var n = 0; 3331 var x2 = x; 3332 3333 while (x2 >= 4096) { 3334 n += 12; 3335 x2 /= 4096; 3336 } 3337 3338 while (x2 >= 2) { 3339 n += 1; 3340 x2 /= 2; 3341 } 3342 3343 return n; 3344 }; 3345 3346 _export(_export.P + _export.F * (!!$toFixed && (0.00008.toFixed(3) !== '0.000' || 0.9.toFixed(0) !== '1' || 1.255.toFixed(2) !== '1.25' || 1000000000000000128.0.toFixed(0) !== '1000000000000000128') || !_fails(function () { 3347 // V8 ~ Android 4.3- 3348 $toFixed.call({}); 3349 })), 'Number', { 3350 toFixed: function toFixed(fractionDigits) { 3351 var x = _aNumberValue(this, ERROR); 3352 var f = _toInteger(fractionDigits); 3353 var s = ''; 3354 var m = ZERO; 3355 var e, z, j, k; 3356 if (f < 0 || f > 20) throw RangeError(ERROR); // eslint-disable-next-line no-self-compare 3357 3358 if (x != x) return 'NaN'; 3359 if (x <= -1e21 || x >= 1e21) return String(x); 3360 3361 if (x < 0) { 3362 s = '-'; 3363 x = -x; 3364 } 3365 3366 if (x > 1e-21) { 3367 e = log(x * pow(2, 69, 1)) - 69; 3368 z = e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1); 3369 z *= 0x10000000000000; 3370 e = 52 - e; 3371 3372 if (e > 0) { 3373 multiply(0, z); 3374 j = f; 3375 3376 while (j >= 7) { 3377 multiply(1e7, 0); 3378 j -= 7; 3379 } 3380 3381 multiply(pow(10, j, 1), 0); 3382 j = e - 1; 3383 3384 while (j >= 23) { 3385 divide(1 << 23); 3386 j -= 23; 3387 } 3388 3389 divide(1 << j); 3390 multiply(1, 1); 3391 divide(2); 3392 m = numToString(); 3393 } else { 3394 multiply(0, z); 3395 multiply(1 << -e, 0); 3396 m = numToString() + _stringRepeat.call(ZERO, f); 3397 } 3398 } 3399 3400 if (f > 0) { 3401 k = m.length; 3402 m = s + (k <= f ? '0.' + _stringRepeat.call(ZERO, f - k) + m : m.slice(0, k - f) + '.' + m.slice(k - f)); 3403 } else { 3404 m = s + m; 3405 } 3406 3407 return m; 3408 } 3409 }); 3410 3411 var $toPrecision = 1.0.toPrecision; 3412 _export(_export.P + _export.F * (_fails(function () { 3413 // IE7- 3414 return $toPrecision.call(1, undefined) !== '1'; 3415 }) || !_fails(function () { 3416 // V8 ~ Android 4.3- 3417 $toPrecision.call({}); 3418 })), 'Number', { 3419 toPrecision: function toPrecision(precision) { 3420 var that = _aNumberValue(this, 'Number#toPrecision: incorrect invocation!'); 3421 return precision === undefined ? $toPrecision.call(that) : $toPrecision.call(that, precision); 3422 } 3423 }); 3424 3425 // 20.1.2.1 Number.EPSILON 3426 3427 3428 _export(_export.S, 'Number', { 3429 EPSILON: Math.pow(2, -52) 3430 }); 3431 3432 // 20.1.2.2 Number.isFinite(number) 3433 3434 3435 var _isFinite = _global.isFinite; 3436 3437 _export(_export.S, 'Number', { 3438 isFinite: function isFinite(it) { 3439 return typeof it == 'number' && _isFinite(it); 3440 } 3441 }); 3442 3443 // 20.1.2.3 Number.isInteger(number) 3444 3445 3446 var floor$2 = Math.floor; 3447 3448 var _isInteger = function isInteger(it) { 3449 return !_isObject(it) && isFinite(it) && floor$2(it) === it; 3450 }; 3451 3452 // 20.1.2.3 Number.isInteger(number) 3453 3454 3455 _export(_export.S, 'Number', { 3456 isInteger: _isInteger 3457 }); 3458 3459 // 20.1.2.4 Number.isNaN(number) 3460 3461 3462 _export(_export.S, 'Number', { 3463 isNaN: function isNaN(number) { 3464 // eslint-disable-next-line no-self-compare 3465 return number != number; 3466 } 3467 }); 3468 3469 // 20.1.2.5 Number.isSafeInteger(number) 3470 3471 3472 3473 3474 var abs = Math.abs; 3475 _export(_export.S, 'Number', { 3476 isSafeInteger: function isSafeInteger(number) { 3477 return _isInteger(number) && abs(number) <= 0x1fffffffffffff; 3478 } 3479 }); 3480 3481 // 20.1.2.6 Number.MAX_SAFE_INTEGER 3482 3483 3484 _export(_export.S, 'Number', { 3485 MAX_SAFE_INTEGER: 0x1fffffffffffff 3486 }); 3487 3488 // 20.1.2.10 Number.MIN_SAFE_INTEGER 3489 3490 3491 _export(_export.S, 'Number', { 3492 MIN_SAFE_INTEGER: -0x1fffffffffffff 3493 }); 3494 3495 // 20.1.2.12 Number.parseFloat(string) 3496 3497 3498 _export(_export.S + _export.F * (Number.parseFloat != _parseFloat), 'Number', { 3499 parseFloat: _parseFloat 3500 }); 3501 3502 // 20.1.2.13 Number.parseInt(string, radix) 3503 3504 3505 _export(_export.S + _export.F * (Number.parseInt != _parseInt), 'Number', { 3506 parseInt: _parseInt 3507 }); 3508 3509 // 20.2.2.20 Math.log1p(x) 3510 var _mathLog1p = Math.log1p || function log1p(x) { 3511 return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : Math.log(1 + x); 3512 }; 3513 3514 // 20.2.2.3 Math.acosh(x) 3515 3516 3517 3518 3519 var sqrt = Math.sqrt; 3520 var $acosh = Math.acosh; 3521 _export(_export.S + _export.F * !($acosh // V8 bug: https://code.google.com/p/v8/issues/detail?id=3509 3522 && Math.floor($acosh(Number.MAX_VALUE)) == 710 // Tor Browser bug: Math.acosh(Infinity) -> NaN 3523 && $acosh(Infinity) == Infinity), 'Math', { 3524 acosh: function acosh(x) { 3525 return (x = +x) < 1 ? NaN : x > 94906265.62425156 ? Math.log(x) + Math.LN2 : _mathLog1p(x - 1 + sqrt(x - 1) * sqrt(x + 1)); 3526 } 3527 }); 3528 3529 // 20.2.2.5 Math.asinh(x) 3530 3531 3532 var $asinh = Math.asinh; 3533 3534 function asinh(x) { 3535 return !isFinite(x = +x) || x == 0 ? x : x < 0 ? -asinh(-x) : Math.log(x + Math.sqrt(x * x + 1)); 3536 } // Tor Browser bug: Math.asinh(0) -> -0 3537 3538 3539 _export(_export.S + _export.F * !($asinh && 1 / $asinh(0) > 0), 'Math', { 3540 asinh: asinh 3541 }); 3542 3543 // 20.2.2.7 Math.atanh(x) 3544 3545 3546 var $atanh = Math.atanh; // Tor Browser bug: Math.atanh(-0) -> 0 3547 3548 _export(_export.S + _export.F * !($atanh && 1 / $atanh(-0) < 0), 'Math', { 3549 atanh: function atanh(x) { 3550 return (x = +x) == 0 ? x : Math.log((1 + x) / (1 - x)) / 2; 3551 } 3552 }); 3553 3554 // 20.2.2.28 Math.sign(x) 3555 var _mathSign = Math.sign || function sign(x) { 3556 // eslint-disable-next-line no-self-compare 3557 return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1; 3558 }; 3559 3560 // 20.2.2.9 Math.cbrt(x) 3561 3562 3563 3564 3565 _export(_export.S, 'Math', { 3566 cbrt: function cbrt(x) { 3567 return _mathSign(x = +x) * Math.pow(Math.abs(x), 1 / 3); 3568 } 3569 }); 3570 3571 // 20.2.2.11 Math.clz32(x) 3572 3573 3574 _export(_export.S, 'Math', { 3575 clz32: function clz32(x) { 3576 return (x >>>= 0) ? 31 - Math.floor(Math.log(x + 0.5) * Math.LOG2E) : 32; 3577 } 3578 }); 3579 3580 // 20.2.2.12 Math.cosh(x) 3581 3582 3583 var exp = Math.exp; 3584 _export(_export.S, 'Math', { 3585 cosh: function cosh(x) { 3586 return (exp(x = +x) + exp(-x)) / 2; 3587 } 3588 }); 3589 3590 // 20.2.2.14 Math.expm1(x) 3591 var $expm1 = Math.expm1; 3592 var _mathExpm1 = !$expm1 // Old FF bug 3593 || $expm1(10) > 22025.465794806719 || $expm1(10) < 22025.4657948067165168 // Tor Browser bug 3594 || $expm1(-2e-17) != -2e-17 ? function expm1(x) { 3595 return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : Math.exp(x) - 1; 3596 } : $expm1; 3597 3598 // 20.2.2.14 Math.expm1(x) 3599 3600 3601 3602 3603 _export(_export.S + _export.F * (_mathExpm1 != Math.expm1), 'Math', { 3604 expm1: _mathExpm1 3605 }); 3606 3607 // 20.2.2.16 Math.fround(x) 3608 3609 3610 var pow$1 = Math.pow; 3611 var EPSILON = pow$1(2, -52); 3612 var EPSILON32 = pow$1(2, -23); 3613 var MAX32 = pow$1(2, 127) * (2 - EPSILON32); 3614 var MIN32 = pow$1(2, -126); 3615 3616 var roundTiesToEven = function roundTiesToEven(n) { 3617 return n + 1 / EPSILON - 1 / EPSILON; 3618 }; 3619 3620 var _mathFround = Math.fround || function fround(x) { 3621 var $abs = Math.abs(x); 3622 var $sign = _mathSign(x); 3623 var a, result; 3624 if ($abs < MIN32) return $sign * roundTiesToEven($abs / MIN32 / EPSILON32) * MIN32 * EPSILON32; 3625 a = (1 + EPSILON32 / EPSILON) * $abs; 3626 result = a - (a - $abs); // eslint-disable-next-line no-self-compare 3627 3628 if (result > MAX32 || result != result) return $sign * Infinity; 3629 return $sign * result; 3630 }; 3631 3632 // 20.2.2.16 Math.fround(x) 3633 3634 3635 _export(_export.S, 'Math', { 3636 fround: _mathFround 3637 }); 3638 3639 // 20.2.2.17 Math.hypot([value1[, value2[, ... ]]]) 3640 3641 3642 var abs$1 = Math.abs; 3643 _export(_export.S, 'Math', { 3644 hypot: function hypot(value1, value2) { 3645 // eslint-disable-line no-unused-vars 3646 var sum = 0; 3647 var i = 0; 3648 var aLen = arguments.length; 3649 var larg = 0; 3650 var arg, div; 3651 3652 while (i < aLen) { 3653 arg = abs$1(arguments[i++]); 3654 3655 if (larg < arg) { 3656 div = larg / arg; 3657 sum = sum * div * div + 1; 3658 larg = arg; 3659 } else if (arg > 0) { 3660 div = arg / larg; 3661 sum += div * div; 3662 } else sum += arg; 3663 } 3664 3665 return larg === Infinity ? Infinity : larg * Math.sqrt(sum); 3666 } 3667 }); 3668 3669 // 20.2.2.18 Math.imul(x, y) 3670 3671 3672 var $imul = Math.imul; // some WebKit versions fails with big numbers, some has wrong arity 3673 3674 _export(_export.S + _export.F * _fails(function () { 3675 return $imul(0xffffffff, 5) != -5 || $imul.length != 2; 3676 }), 'Math', { 3677 imul: function imul(x, y) { 3678 var UINT16 = 0xffff; 3679 var xn = +x; 3680 var yn = +y; 3681 var xl = UINT16 & xn; 3682 var yl = UINT16 & yn; 3683 return 0 | xl * yl + ((UINT16 & xn >>> 16) * yl + xl * (UINT16 & yn >>> 16) << 16 >>> 0); 3684 } 3685 }); 3686 3687 // 20.2.2.21 Math.log10(x) 3688 3689 3690 _export(_export.S, 'Math', { 3691 log10: function log10(x) { 3692 return Math.log(x) * Math.LOG10E; 3693 } 3694 }); 3695 3696 // 20.2.2.20 Math.log1p(x) 3697 3698 3699 _export(_export.S, 'Math', { 3700 log1p: _mathLog1p 3701 }); 3702 3703 // 20.2.2.22 Math.log2(x) 3704 3705 3706 _export(_export.S, 'Math', { 3707 log2: function log2(x) { 3708 return Math.log(x) / Math.LN2; 3709 } 3710 }); 3711 3712 // 20.2.2.28 Math.sign(x) 3713 3714 3715 _export(_export.S, 'Math', { 3716 sign: _mathSign 3717 }); 3718 3719 // 20.2.2.30 Math.sinh(x) 3720 3721 3722 3723 3724 var exp$1 = Math.exp; // V8 near Chromium 38 has a problem with very small numbers 3725 3726 _export(_export.S + _export.F * _fails(function () { 3727 return !Math.sinh(-2e-17) != -2e-17; 3728 }), 'Math', { 3729 sinh: function sinh(x) { 3730 return Math.abs(x = +x) < 1 ? (_mathExpm1(x) - _mathExpm1(-x)) / 2 : (exp$1(x - 1) - exp$1(-x - 1)) * (Math.E / 2); 3731 } 3732 }); 3733 3734 // 20.2.2.33 Math.tanh(x) 3735 3736 3737 3738 3739 var exp$2 = Math.exp; 3740 _export(_export.S, 'Math', { 3741 tanh: function tanh(x) { 3742 var a = _mathExpm1(x = +x); 3743 var b = _mathExpm1(-x); 3744 return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp$2(x) + exp$2(-x)); 3745 } 3746 }); 3747 3748 // 20.2.2.34 Math.trunc(x) 3749 3750 3751 _export(_export.S, 'Math', { 3752 trunc: function trunc(it) { 3753 return (it > 0 ? Math.floor : Math.ceil)(it); 3754 } 3755 }); 3756 3757 var fromCharCode = String.fromCharCode; 3758 var $fromCodePoint = String.fromCodePoint; // length should be 1, old FF problem 3759 3760 _export(_export.S + _export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', { 3761 // 21.1.2.2 String.fromCodePoint(...codePoints) 3762 fromCodePoint: function fromCodePoint(x) { 3763 // eslint-disable-line no-unused-vars 3764 var res = []; 3765 var aLen = arguments.length; 3766 var i = 0; 3767 var code; 3768 3769 while (aLen > i) { 3770 code = +arguments[i++]; 3771 if (_toAbsoluteIndex(code, 0x10ffff) !== code) throw RangeError(code + ' is not a valid code point'); 3772 res.push(code < 0x10000 ? fromCharCode(code) : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)); 3773 } 3774 3775 return res.join(''); 3776 } 3777 }); 3778 3779 _export(_export.S, 'String', { 3780 // 21.1.2.4 String.raw(callSite, ...substitutions) 3781 raw: function raw(callSite) { 3782 var tpl = _toIobject(callSite.raw); 3783 var len = _toLength(tpl.length); 3784 var aLen = arguments.length; 3785 var res = []; 3786 var i = 0; 3787 3788 while (len > i) { 3789 res.push(String(tpl[i++])); 3790 if (i < aLen) res.push(String(arguments[i])); 3791 } 3792 3793 return res.join(''); 3794 } 3795 }); 3796 3797 _stringTrim('trim', function ($trim) { 3798 return function trim() { 3799 return $trim(this, 3); 3800 }; 3801 }); 3802 3803 // true -> String#at 3804 // false -> String#codePointAt 3805 3806 3807 var _stringAt = function (TO_STRING) { 3808 return function (that, pos) { 3809 var s = String(_defined(that)); 3810 var i = _toInteger(pos); 3811 var l = s.length; 3812 var a, b; 3813 if (i < 0 || i >= l) return TO_STRING ? '' : undefined; 3814 a = s.charCodeAt(i); 3815 return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff ? TO_STRING ? s.charAt(i) : a : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; 3816 }; 3817 }; 3818 3819 var _iterators = {}; 3820 3821 var IteratorPrototype = {}; // 25.1.2.1.1 %IteratorPrototype%[@@iterator]() 3822 3823 _hide(IteratorPrototype, _wks('iterator'), function () { 3824 return this; 3825 }); 3826 3827 var _iterCreate = function (Constructor, NAME, next) { 3828 Constructor.prototype = _objectCreate(IteratorPrototype, { 3829 next: _propertyDesc(1, next) 3830 }); 3831 _setToStringTag(Constructor, NAME + ' Iterator'); 3832 }; 3833 3834 var ITERATOR = _wks('iterator'); 3835 3836 var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next` 3837 3838 var FF_ITERATOR = '@@iterator'; 3839 var KEYS = 'keys'; 3840 var VALUES = 'values'; 3841 3842 var returnThis = function returnThis() { 3843 return this; 3844 }; 3845 3846 var _iterDefine = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) { 3847 _iterCreate(Constructor, NAME, next); 3848 3849 var getMethod = function getMethod(kind) { 3850 if (!BUGGY && kind in proto) return proto[kind]; 3851 3852 switch (kind) { 3853 case KEYS: 3854 return function keys() { 3855 return new Constructor(this, kind); 3856 }; 3857 3858 case VALUES: 3859 return function values() { 3860 return new Constructor(this, kind); 3861 }; 3862 } 3863 3864 return function entries() { 3865 return new Constructor(this, kind); 3866 }; 3867 }; 3868 3869 var TAG = NAME + ' Iterator'; 3870 var DEF_VALUES = DEFAULT == VALUES; 3871 var VALUES_BUG = false; 3872 var proto = Base.prototype; 3873 var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]; 3874 var $default = $native || getMethod(DEFAULT); 3875 var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined; 3876 var $anyNative = NAME == 'Array' ? proto.entries || $native : $native; 3877 var methods, key, IteratorPrototype; // Fix native 3878 3879 if ($anyNative) { 3880 IteratorPrototype = _objectGpo($anyNative.call(new Base())); 3881 3882 if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) { 3883 // Set @@toStringTag to native iterators 3884 _setToStringTag(IteratorPrototype, TAG, true); // fix for some old engines 3885 3886 if (typeof IteratorPrototype[ITERATOR] != 'function') _hide(IteratorPrototype, ITERATOR, returnThis); 3887 } 3888 } // fix Array#{values, @@iterator}.name in V8 / FF 3889 3890 3891 if (DEF_VALUES && $native && $native.name !== VALUES) { 3892 VALUES_BUG = true; 3893 3894 $default = function values() { 3895 return $native.call(this); 3896 }; 3897 } // Define iterator 3898 3899 3900 if (BUGGY || VALUES_BUG || !proto[ITERATOR]) { 3901 _hide(proto, ITERATOR, $default); 3902 } // Plug for library 3903 3904 3905 _iterators[NAME] = $default; 3906 _iterators[TAG] = returnThis; 3907 3908 if (DEFAULT) { 3909 methods = { 3910 values: DEF_VALUES ? $default : getMethod(VALUES), 3911 keys: IS_SET ? $default : getMethod(KEYS), 3912 entries: $entries 3913 }; 3914 if (FORCED) for (key in methods) { 3915 if (!(key in proto)) _redefine(proto, key, methods[key]); 3916 } else _export(_export.P + _export.F * (BUGGY || VALUES_BUG), NAME, methods); 3917 } 3918 3919 return methods; 3920 }; 3921 3922 var $at = _stringAt(true); // 21.1.3.27 String.prototype[@@iterator]() 3923 3924 3925 _iterDefine(String, 'String', function (iterated) { 3926 this._t = String(iterated); // target 3927 3928 this._i = 0; // next index 3929 // 21.1.5.2.1 %StringIteratorPrototype%.next() 3930 }, function () { 3931 var O = this._t; 3932 var index = this._i; 3933 var point; 3934 if (index >= O.length) return { 3935 value: undefined, 3936 done: true 3937 }; 3938 point = $at(O, index); 3939 this._i += point.length; 3940 return { 3941 value: point, 3942 done: false 3943 }; 3944 }); 3945 3946 var $at$1 = _stringAt(false); 3947 3948 _export(_export.P, 'String', { 3949 // 21.1.3.3 String.prototype.codePointAt(pos) 3950 codePointAt: function codePointAt(pos) { 3951 return $at$1(this, pos); 3952 } 3953 }); 3954 3955 // 7.2.8 IsRegExp(argument) 3956 3957 3958 3959 3960 var MATCH = _wks('match'); 3961 3962 var _isRegexp = function (it) { 3963 var isRegExp; 3964 return _isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : _cof(it) == 'RegExp'); 3965 }; 3966 3967 // helper for String#{startsWith, endsWith, includes} 3968 3969 3970 3971 3972 var _stringContext = function (that, searchString, NAME) { 3973 if (_isRegexp(searchString)) throw TypeError('String#' + NAME + " doesn't accept regex!"); 3974 return String(_defined(that)); 3975 }; 3976 3977 var MATCH$1 = _wks('match'); 3978 3979 var _failsIsRegexp = function (KEY) { 3980 var re = /./; 3981 3982 try { 3983 '/./'[KEY](re); 3984 } catch (e) { 3985 try { 3986 re[MATCH$1] = false; 3987 return !'/./'[KEY](re); 3988 } catch (f) { 3989 /* empty */ 3990 } 3991 } 3992 3993 return true; 3994 }; 3995 3996 var ENDS_WITH = 'endsWith'; 3997 var $endsWith = ''[ENDS_WITH]; 3998 _export(_export.P + _export.F * _failsIsRegexp(ENDS_WITH), 'String', { 3999 endsWith: function endsWith(searchString 4000 /* , endPosition = @length */ 4001 ) { 4002 var that = _stringContext(this, searchString, ENDS_WITH); 4003 var endPosition = arguments.length > 1 ? arguments[1] : undefined; 4004 var len = _toLength(that.length); 4005 var end = endPosition === undefined ? len : Math.min(_toLength(endPosition), len); 4006 var search = String(searchString); 4007 return $endsWith ? $endsWith.call(that, search, end) : that.slice(end - search.length, end) === search; 4008 } 4009 }); 4010 4011 var INCLUDES = 'includes'; 4012 _export(_export.P + _export.F * _failsIsRegexp(INCLUDES), 'String', { 4013 includes: function includes(searchString 4014 /* , position = 0 */ 4015 ) { 4016 return !!~_stringContext(this, searchString, INCLUDES).indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined); 4017 } 4018 }); 4019 4020 _export(_export.P, 'String', { 4021 // 21.1.3.13 String.prototype.repeat(count) 4022 repeat: _stringRepeat 4023 }); 4024 4025 var STARTS_WITH = 'startsWith'; 4026 var $startsWith = ''[STARTS_WITH]; 4027 _export(_export.P + _export.F * _failsIsRegexp(STARTS_WITH), 'String', { 4028 startsWith: function startsWith(searchString 4029 /* , position = 0 */ 4030 ) { 4031 var that = _stringContext(this, searchString, STARTS_WITH); 4032 var index = _toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length)); 4033 var search = String(searchString); 4034 return $startsWith ? $startsWith.call(that, search, index) : that.slice(index, index + search.length) === search; 4035 } 4036 }); 4037 4038 var quot = /"/g; // B.2.3.2.1 CreateHTML(string, tag, attribute, value) 4039 4040 var createHTML = function createHTML(string, tag, attribute, value) { 4041 var S = String(_defined(string)); 4042 var p1 = '<' + tag; 4043 if (attribute !== '') p1 += ' ' + attribute + '="' + String(value).replace(quot, '"') + '"'; 4044 return p1 + '>' + S + '</' + tag + '>'; 4045 }; 4046 4047 var _stringHtml = function (NAME, exec) { 4048 var O = {}; 4049 O[NAME] = exec(createHTML); 4050 _export(_export.P + _export.F * _fails(function () { 4051 var test = ''[NAME]('"'); 4052 return test !== test.toLowerCase() || test.split('"').length > 3; 4053 }), 'String', O); 4054 }; 4055 4056 _stringHtml('anchor', function (createHTML) { 4057 return function anchor(name) { 4058 return createHTML(this, 'a', 'name', name); 4059 }; 4060 }); 4061 4062 _stringHtml('big', function (createHTML) { 4063 return function big() { 4064 return createHTML(this, 'big', '', ''); 4065 }; 4066 }); 4067 4068 _stringHtml('blink', function (createHTML) { 4069 return function blink() { 4070 return createHTML(this, 'blink', '', ''); 4071 }; 4072 }); 4073 4074 _stringHtml('bold', function (createHTML) { 4075 return function bold() { 4076 return createHTML(this, 'b', '', ''); 4077 }; 4078 }); 4079 4080 _stringHtml('fixed', function (createHTML) { 4081 return function fixed() { 4082 return createHTML(this, 'tt', '', ''); 4083 }; 4084 }); 4085 4086 _stringHtml('fontcolor', function (createHTML) { 4087 return function fontcolor(color) { 4088 return createHTML(this, 'font', 'color', color); 4089 }; 4090 }); 4091 4092 _stringHtml('fontsize', function (createHTML) { 4093 return function fontsize(size) { 4094 return createHTML(this, 'font', 'size', size); 4095 }; 4096 }); 4097 4098 _stringHtml('italics', function (createHTML) { 4099 return function italics() { 4100 return createHTML(this, 'i', '', ''); 4101 }; 4102 }); 4103 4104 _stringHtml('link', function (createHTML) { 4105 return function link(url) { 4106 return createHTML(this, 'a', 'href', url); 4107 }; 4108 }); 4109 4110 _stringHtml('small', function (createHTML) { 4111 return function small() { 4112 return createHTML(this, 'small', '', ''); 4113 }; 4114 }); 4115 4116 _stringHtml('strike', function (createHTML) { 4117 return function strike() { 4118 return createHTML(this, 'strike', '', ''); 4119 }; 4120 }); 4121 4122 _stringHtml('sub', function (createHTML) { 4123 return function sub() { 4124 return createHTML(this, 'sub', '', ''); 4125 }; 4126 }); 4127 4128 _stringHtml('sup', function (createHTML) { 4129 return function sup() { 4130 return createHTML(this, 'sup', '', ''); 4131 }; 4132 }); 4133 4134 // 20.3.3.1 / 15.9.4.4 Date.now() 4135 4136 4137 _export(_export.S, 'Date', { 4138 now: function now() { 4139 return new Date().getTime(); 4140 } 4141 }); 4142 4143 _export(_export.P + _export.F * _fails(function () { 4144 return new Date(NaN).toJSON() !== null || Date.prototype.toJSON.call({ 4145 toISOString: function toISOString() { 4146 return 1; 4147 } 4148 }) !== 1; 4149 }), 'Date', { 4150 // eslint-disable-next-line no-unused-vars 4151 toJSON: function toJSON(key) { 4152 var O = _toObject(this); 4153 var pv = _toPrimitive(O); 4154 return typeof pv == 'number' && !isFinite(pv) ? null : O.toISOString(); 4155 } 4156 }); 4157 4158 var getTime = Date.prototype.getTime; 4159 var $toISOString = Date.prototype.toISOString; 4160 4161 var lz = function lz(num) { 4162 return num > 9 ? num : '0' + num; 4163 }; // PhantomJS / old WebKit has a broken implementations 4164 4165 4166 var _dateToIsoString = _fails(function () { 4167 return $toISOString.call(new Date(-5e13 - 1)) != '0385-07-25T07:06:39.999Z'; 4168 }) || !_fails(function () { 4169 $toISOString.call(new Date(NaN)); 4170 }) ? function toISOString() { 4171 if (!isFinite(getTime.call(this))) throw RangeError('Invalid time value'); 4172 var d = this; 4173 var y = d.getUTCFullYear(); 4174 var m = d.getUTCMilliseconds(); 4175 var s = y < 0 ? '-' : y > 9999 ? '+' : ''; 4176 return s + ('00000' + Math.abs(y)).slice(s ? -6 : -4) + '-' + lz(d.getUTCMonth() + 1) + '-' + lz(d.getUTCDate()) + 'T' + lz(d.getUTCHours()) + ':' + lz(d.getUTCMinutes()) + ':' + lz(d.getUTCSeconds()) + '.' + (m > 99 ? m : '0' + lz(m)) + 'Z'; 4177 } : $toISOString; 4178 4179 // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString() 4180 4181 4182 // PhantomJS / old WebKit has a broken implementations 4183 4184 4185 _export(_export.P + _export.F * (Date.prototype.toISOString !== _dateToIsoString), 'Date', { 4186 toISOString: _dateToIsoString 4187 }); 4188 4189 var DateProto = Date.prototype; 4190 var INVALID_DATE = 'Invalid Date'; 4191 var TO_STRING = 'toString'; 4192 var $toString = DateProto[TO_STRING]; 4193 var getTime$1 = DateProto.getTime; 4194 4195 if (new Date(NaN) + '' != INVALID_DATE) { 4196 _redefine(DateProto, TO_STRING, function toString() { 4197 var value = getTime$1.call(this); // eslint-disable-next-line no-self-compare 4198 4199 return value === value ? $toString.call(this) : INVALID_DATE; 4200 }); 4201 } 4202 4203 var NUMBER$1 = 'number'; 4204 4205 var _dateToPrimitive = function (hint) { 4206 if (hint !== 'string' && hint !== NUMBER$1 && hint !== 'default') throw TypeError('Incorrect hint'); 4207 return _toPrimitive(_anObject(this), hint != NUMBER$1); 4208 }; 4209 4210 var TO_PRIMITIVE$1 = _wks('toPrimitive'); 4211 4212 var proto$1 = Date.prototype; 4213 if (!(TO_PRIMITIVE$1 in proto$1)) _hide(proto$1, TO_PRIMITIVE$1, _dateToPrimitive); 4214 4215 // 22.1.2.2 / 15.4.3.2 Array.isArray(arg) 4216 4217 4218 _export(_export.S, 'Array', { 4219 isArray: _isArray 4220 }); 4221 4222 // call something on iterator step with safe closing on error 4223 4224 4225 var _iterCall = function (iterator, fn, value, entries) { 4226 try { 4227 return entries ? fn(_anObject(value)[0], value[1]) : fn(value); // 7.4.6 IteratorClose(iterator, completion) 4228 } catch (e) { 4229 var ret = iterator['return']; 4230 if (ret !== undefined) _anObject(ret.call(iterator)); 4231 throw e; 4232 } 4233 }; 4234 4235 // check on default Array iterator 4236 4237 4238 var ITERATOR$1 = _wks('iterator'); 4239 4240 var ArrayProto = Array.prototype; 4241 4242 var _isArrayIter = function (it) { 4243 return it !== undefined && (_iterators.Array === it || ArrayProto[ITERATOR$1] === it); 4244 }; 4245 4246 var _createProperty = function (object, index, value) { 4247 if (index in object) _objectDp.f(object, index, _propertyDesc(0, value));else object[index] = value; 4248 }; 4249 4250 var ITERATOR$2 = _wks('iterator'); 4251 4252 4253 4254 var core_getIteratorMethod = _core.getIteratorMethod = function (it) { 4255 if (it != undefined) return it[ITERATOR$2] || it['@@iterator'] || _iterators[_classof(it)]; 4256 }; 4257 4258 var ITERATOR$3 = _wks('iterator'); 4259 4260 var SAFE_CLOSING = false;
vendor: 12,581 bytes, lines 4261-4727
4261 4262 try { 4263 var riter = [7][ITERATOR$3](); 4264 4265 riter['return'] = function () { 4266 SAFE_CLOSING = true; 4267 }; // eslint-disable-next-line no-throw-literal 4268 } catch (e) { 4269 /* empty */ 4270 } 4271 4272 var _iterDetect = function (exec, skipClosing) { 4273 if (!skipClosing && !SAFE_CLOSING) return false; 4274 var safe = false; 4275 4276 try { 4277 var arr = [7]; 4278 var iter = arr[ITERATOR$3](); 4279 4280 iter.next = function () { 4281 return { 4282 done: safe = true 4283 }; 4284 }; 4285 4286 arr[ITERATOR$3] = function () { 4287 return iter; 4288 }; 4289 4290 exec(arr); 4291 } catch (e) { 4292 /* empty */ 4293 } 4294 4295 return safe; 4296 }; 4297 4298 _export(_export.S + _export.F * !_iterDetect(function (iter) { 4299 }), 'Array', { 4300 // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined) 4301 from: function from(arrayLike 4302 /* , mapfn = undefined, thisArg = undefined */ 4303 ) { 4304 var O = _toObject(arrayLike); 4305 var C = typeof this == 'function' ? this : Array; 4306 var aLen = arguments.length; 4307 var mapfn = aLen > 1 ? arguments[1] : undefined; 4308 var mapping = mapfn !== undefined; 4309 var index = 0; 4310 var iterFn = core_getIteratorMethod(O); 4311 var length, result, step, iterator; 4312 if (mapping) mapfn = _ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2); // if object isn't iterable or it's array with default iterator - use simple case 4313 4314 if (iterFn != undefined && !(C == Array && _isArrayIter(iterFn))) { 4315 for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) { 4316 _createProperty(result, index, mapping ? _iterCall(iterator, mapfn, [step.value, index], true) : step.value); 4317 } 4318 } else { 4319 length = _toLength(O.length); 4320 4321 for (result = new C(length); length > index; index++) { 4322 _createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]); 4323 } 4324 } 4325 4326 result.length = index; 4327 return result; 4328 } 4329 }); 4330 4331 // WebKit Array.of isn't generic 4332 4333 4334 _export(_export.S + _export.F * _fails(function () { 4335 function F() { 4336 /* empty */ 4337 } 4338 4339 return !(Array.of.call(F) instanceof F); 4340 }), 'Array', { 4341 // 22.1.2.3 Array.of( ...items) 4342 of: function of() 4343 /* ...args */ 4344 { 4345 var index = 0; 4346 var aLen = arguments.length; 4347 var result = new (typeof this == 'function' ? this : Array)(aLen); 4348 4349 while (aLen > index) { 4350 _createProperty(result, index, arguments[index++]); 4351 } 4352 4353 result.length = aLen; 4354 return result; 4355 } 4356 }); 4357 4358 var _strictMethod = function (method, arg) { 4359 return !!method && _fails(function () { 4360 // eslint-disable-next-line no-useless-call 4361 arg ? method.call(null, function () { 4362 /* empty */ 4363 }, 1) : method.call(null); 4364 }); 4365 }; 4366 4367 var arrayJoin = [].join; // fallback for not array-like strings 4368 4369 _export(_export.P + _export.F * (_iobject != Object || !_strictMethod(arrayJoin)), 'Array', { 4370 join: function join(separator) { 4371 return arrayJoin.call(_toIobject(this), separator === undefined ? ',' : separator); 4372 } 4373 }); 4374 4375 var arraySlice$1 = [].slice; // fallback for not array-like ES3 strings and DOM objects 4376 4377 _export(_export.P + _export.F * _fails(function () { 4378 if (_html) arraySlice$1.call(_html); 4379 }), 'Array', { 4380 slice: function slice(begin, end) { 4381 var len = _toLength(this.length); 4382 var klass = _cof(this); 4383 end = end === undefined ? len : end; 4384 if (klass == 'Array') return arraySlice$1.call(this, begin, end); 4385 var start = _toAbsoluteIndex(begin, len); 4386 var upTo = _toAbsoluteIndex(end, len); 4387 var size = _toLength(upTo - start); 4388 var cloned = new Array(size); 4389 var i = 0; 4390 4391 for (; i < size; i++) { 4392 cloned[i] = klass == 'String' ? this.charAt(start + i) : this[start + i]; 4393 } 4394 4395 return cloned; 4396 } 4397 }); 4398 4399 var $sort = [].sort; 4400 var test$1 = [1, 2, 3]; 4401 _export(_export.P + _export.F * (_fails(function () { 4402 // IE8- 4403 test$1.sort(undefined); 4404 }) || !_fails(function () { 4405 // V8 bug 4406 test$1.sort(null); // Old WebKit 4407 }) || !_strictMethod($sort)), 'Array', { 4408 // 22.1.3.25 Array.prototype.sort(comparefn) 4409 sort: function sort(comparefn) { 4410 return comparefn === undefined ? $sort.call(_toObject(this)) : $sort.call(_toObject(this), _aFunction(comparefn)); 4411 } 4412 }); 4413 4414 var SPECIES = _wks('species'); 4415 4416 var _arraySpeciesConstructor = function (original) { 4417 var C; 4418 4419 if (_isArray(original)) { 4420 C = original.constructor; // cross-realm fallback 4421 4422 if (typeof C == 'function' && (C === Array || _isArray(C.prototype))) C = undefined; 4423 4424 if (_isObject(C)) { 4425 C = C[SPECIES]; 4426 if (C === null) C = undefined; 4427 } 4428 } 4429 4430 return C === undefined ? Array : C; 4431 }; 4432 4433 // 9.4.2.3 ArraySpeciesCreate(originalArray, length) 4434 4435 4436 var _arraySpeciesCreate = function (original, length) { 4437 return new (_arraySpeciesConstructor(original))(length); 4438 }; 4439 4440 // 0 -> Array#forEach 4441 // 1 -> Array#map 4442 // 2 -> Array#filter 4443 // 3 -> Array#some 4444 // 4 -> Array#every 4445 // 5 -> Array#find 4446 // 6 -> Array#findIndex 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 var _arrayMethods = function (TYPE, $create) { 4458 var IS_MAP = TYPE == 1; 4459 var IS_FILTER = TYPE == 2; 4460 var IS_SOME = TYPE == 3; 4461 var IS_EVERY = TYPE == 4; 4462 var IS_FIND_INDEX = TYPE == 6; 4463 var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; 4464 var create = $create || _arraySpeciesCreate; 4465 return function ($this, callbackfn, that) { 4466 var O = _toObject($this); 4467 var self = _iobject(O); 4468 var f = _ctx(callbackfn, that, 3); 4469 var length = _toLength(self.length); 4470 var index = 0; 4471 var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined; 4472 var val, res; 4473 4474 for (; length > index; index++) { 4475 if (NO_HOLES || index in self) { 4476 val = self[index]; 4477 res = f(val, index, O); 4478 4479 if (TYPE) { 4480 if (IS_MAP) result[index] = res; // map 4481 else if (res) switch (TYPE) { 4482 case 3: 4483 return true; 4484 // some 4485 4486 case 5: 4487 return val; 4488 // find 4489 4490 case 6: 4491 return index; 4492 // findIndex 4493 4494 case 2: 4495 result.push(val); 4496 // filter 4497 } else if (IS_EVERY) return false; // every 4498 } 4499 } 4500 } 4501 4502 return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result; 4503 }; 4504 }; 4505 4506 var $forEach = _arrayMethods(0); 4507 4508 var STRICT = _strictMethod([].forEach, true); 4509 4510 _export(_export.P + _export.F * !STRICT, 'Array', { 4511 // 22.1.3.10 / 15.4.4.18 Array.prototype.forEach(callbackfn [, thisArg]) 4512 forEach: function forEach(callbackfn 4513 /* , thisArg */ 4514 ) { 4515 return $forEach(this, callbackfn, arguments[1]); 4516 } 4517 }); 4518 4519 var $map = _arrayMethods(1); 4520 4521 _export(_export.P + _export.F * !_strictMethod([].map, true), 'Array', { 4522 // 22.1.3.15 / 15.4.4.19 Array.prototype.map(callbackfn [, thisArg]) 4523 map: function map(callbackfn 4524 /* , thisArg */ 4525 ) { 4526 return $map(this, callbackfn, arguments[1]); 4527 } 4528 }); 4529 4530 var $filter = _arrayMethods(2); 4531 4532 _export(_export.P + _export.F * !_strictMethod([].filter, true), 'Array', { 4533 // 22.1.3.7 / 15.4.4.20 Array.prototype.filter(callbackfn [, thisArg]) 4534 filter: function filter(callbackfn 4535 /* , thisArg */ 4536 ) { 4537 return $filter(this, callbackfn, arguments[1]); 4538 } 4539 }); 4540 4541 var $some = _arrayMethods(3); 4542 4543 _export(_export.P + _export.F * !_strictMethod([].some, true), 'Array', { 4544 // 22.1.3.23 / 15.4.4.17 Array.prototype.some(callbackfn [, thisArg]) 4545 some: function some(callbackfn 4546 /* , thisArg */ 4547 ) { 4548 return $some(this, callbackfn, arguments[1]); 4549 } 4550 }); 4551 4552 var $every = _arrayMethods(4); 4553 4554 _export(_export.P + _export.F * !_strictMethod([].every, true), 'Array', { 4555 // 22.1.3.5 / 15.4.4.16 Array.prototype.every(callbackfn [, thisArg]) 4556 every: function every(callbackfn 4557 /* , thisArg */ 4558 ) { 4559 return $every(this, callbackfn, arguments[1]); 4560 } 4561 }); 4562 4563 var _arrayReduce = function (that, callbackfn, aLen, memo, isRight) { 4564 _aFunction(callbackfn); 4565 var O = _toObject(that); 4566 var self = _iobject(O); 4567 var length = _toLength(O.length); 4568 var index = isRight ? length - 1 : 0; 4569 var i = isRight ? -1 : 1; 4570 if (aLen < 2) for (;;) { 4571 if (index in self) { 4572 memo = self[index]; 4573 index += i; 4574 break; 4575 } 4576 4577 index += i; 4578 4579 if (isRight ? index < 0 : length <= index) { 4580 throw TypeError('Reduce of empty array with no initial value'); 4581 } 4582 } 4583 4584 for (; isRight ? index >= 0 : length > index; index += i) { 4585 if (index in self) { 4586 memo = callbackfn(memo, self[index], index, O); 4587 } 4588 } 4589 4590 return memo; 4591 }; 4592 4593 _export(_export.P + _export.F * !_strictMethod([].reduce, true), 'Array', { 4594 // 22.1.3.18 / 15.4.4.21 Array.prototype.reduce(callbackfn [, initialValue]) 4595 reduce: function reduce(callbackfn 4596 /* , initialValue */ 4597 ) { 4598 return _arrayReduce(this, callbackfn, arguments.length, arguments[1], false); 4599 } 4600 }); 4601 4602 _export(_export.P + _export.F * !_strictMethod([].reduceRight, true), 'Array', { 4603 // 22.1.3.19 / 15.4.4.22 Array.prototype.reduceRight(callbackfn [, initialValue]) 4604 reduceRight: function reduceRight(callbackfn 4605 /* , initialValue */ 4606 ) { 4607 return _arrayReduce(this, callbackfn, arguments.length, arguments[1], true); 4608 } 4609 }); 4610 4611 var $indexOf = _arrayIncludes(false); 4612 4613 var $native = [].indexOf; 4614 var NEGATIVE_ZERO = !!$native && 1 / [1].indexOf(1, -0) < 0; 4615 _export(_export.P + _export.F * (NEGATIVE_ZERO || !_strictMethod($native)), 'Array', { 4616 // 22.1.3.11 / 15.4.4.14 Array.prototype.indexOf(searchElement [, fromIndex]) 4617 indexOf: function indexOf(searchElement 4618 /* , fromIndex = 0 */ 4619 ) { 4620 return NEGATIVE_ZERO // convert -0 to +0 4621 ? $native.apply(this, arguments) || 0 : $indexOf(this, searchElement, arguments[1]); 4622 } 4623 }); 4624 4625 var $native$1 = [].lastIndexOf; 4626 var NEGATIVE_ZERO$1 = !!$native$1 && 1 / [1].lastIndexOf(1, -0) < 0; 4627 _export(_export.P + _export.F * (NEGATIVE_ZERO$1 || !_strictMethod($native$1)), 'Array', { 4628 // 22.1.3.14 / 15.4.4.15 Array.prototype.lastIndexOf(searchElement [, fromIndex]) 4629 lastIndexOf: function lastIndexOf(searchElement 4630 /* , fromIndex = @[*-1] */ 4631 ) { 4632 // convert -0 to +0 4633 if (NEGATIVE_ZERO$1) return $native$1.apply(this, arguments) || 0; 4634 var O = _toIobject(this); 4635 var length = _toLength(O.length); 4636 var index = length - 1; 4637 if (arguments.length > 1) index = Math.min(index, _toInteger(arguments[1])); 4638 if (index < 0) index = length + index; 4639 4640 for (; index >= 0; index--) { 4641 if (index in O) if (O[index] === searchElement) return index || 0; 4642 } 4643 4644 return -1; 4645 } 4646 }); 4647 4648 var _arrayCopyWithin = [].copyWithin || function copyWithin(target 4649 /* = 0 */ 4650 , start 4651 /* = 0, end = @length */ 4652 ) { 4653 var O = _toObject(this); 4654 var len = _toLength(O.length); 4655 var to = _toAbsoluteIndex(target, len); 4656 var from = _toAbsoluteIndex(start, len); 4657 var end = arguments.length > 2 ? arguments[2] : undefined; 4658 var count = Math.min((end === undefined ? len : _toAbsoluteIndex(end, len)) - from, len - to); 4659 var inc = 1; 4660 4661 if (from < to && to < from + count) { 4662 inc = -1; 4663 from += count - 1; 4664 to += count - 1; 4665 } 4666 4667 while (count-- > 0) { 4668 if (from in O) O[to] = O[from];else delete O[to]; 4669 to += inc; 4670 from += inc; 4671 } 4672 4673 return O; 4674 }; 4675 4676 // 22.1.3.31 Array.prototype[@@unscopables] 4677 var UNSCOPABLES = _wks('unscopables'); 4678 4679 var ArrayProto$1 = Array.prototype; 4680 if (ArrayProto$1[UNSCOPABLES] == undefined) _hide(ArrayProto$1, UNSCOPABLES, {}); 4681 4682 var _addToUnscopables = function (key) { 4683 ArrayProto$1[UNSCOPABLES][key] = true; 4684 }; 4685 4686 // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length) 4687 4688 4689 _export(_export.P, 'Array', { 4690 copyWithin: _arrayCopyWithin 4691 }); 4692 4693 _addToUnscopables('copyWithin'); 4694 4695 var _arrayFill = function fill(value 4696 /* , start = 0, end = @length */ 4697 ) { 4698 var O = _toObject(this); 4699 var length = _toLength(O.length); 4700 var aLen = arguments.length; 4701 var index = _toAbsoluteIndex(aLen > 1 ? arguments[1] : undefined, length); 4702 var end = aLen > 2 ? arguments[2] : undefined; 4703 var endPos = end === undefined ? length : _toAbsoluteIndex(end, length); 4704 4705 while (endPos > index) { 4706 O[index++] = value; 4707 } 4708 4709 return O; 4710 }; 4711 4712 // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length) 4713 4714 4715 _export(_export.P, 'Array', { 4716 fill: _arrayFill 4717 }); 4718 4719 _addToUnscopables('fill'); 4720 4721 var $find = _arrayMethods(5); 4722 4723 var KEY = 'find'; 4724 var forced = true; // Shouldn't skip holes 4725 4726 if (KEY in []) Array(1)[KEY](function () { 4727 forced = false;
vendor: 14,207 bytes, lines 4728-5201
4728 }); 4729 _export(_export.P + _export.F * forced, 'Array', { 4730 find: function find(callbackfn 4731 /* , that = undefined */ 4732 ) { 4733 return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); 4734 } 4735 }); 4736 4737 _addToUnscopables(KEY); 4738 4739 var $find$1 = _arrayMethods(6); 4740 4741 var KEY$1 = 'findIndex'; 4742 var forced$1 = true; // Shouldn't skip holes 4743 4744 if (KEY$1 in []) Array(1)[KEY$1](function () { 4745 forced$1 = false; 4746 }); 4747 _export(_export.P + _export.F * forced$1, 'Array', { 4748 findIndex: function findIndex(callbackfn 4749 /* , that = undefined */ 4750 ) { 4751 return $find$1(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); 4752 } 4753 }); 4754 4755 _addToUnscopables(KEY$1); 4756 4757 var SPECIES$1 = _wks('species'); 4758 4759 var _setSpecies = function (KEY) { 4760 var C = _global[KEY]; 4761 if (_descriptors && C && !C[SPECIES$1]) _objectDp.f(C, SPECIES$1, { 4762 configurable: true, 4763 get: function get() { 4764 return this; 4765 } 4766 }); 4767 }; 4768 4769 _setSpecies('Array'); 4770 4771 var _iterStep = function (done, value) { 4772 return { 4773 value: value, 4774 done: !!done 4775 }; 4776 }; 4777 4778 // 22.1.3.4 Array.prototype.entries() 4779 // 22.1.3.13 Array.prototype.keys() 4780 // 22.1.3.29 Array.prototype.values() 4781 // 22.1.3.30 Array.prototype[@@iterator]() 4782 4783 4784 var es6_array_iterator = _iterDefine(Array, 'Array', function (iterated, kind) { 4785 this._t = _toIobject(iterated); // target 4786 4787 this._i = 0; // next index 4788 4789 this._k = kind; // kind 4790 // 22.1.5.2.1 %ArrayIteratorPrototype%.next() 4791 }, function () { 4792 var O = this._t; 4793 var kind = this._k; 4794 var index = this._i++; 4795 4796 if (!O || index >= O.length) { 4797 this._t = undefined; 4798 return _iterStep(1); 4799 } 4800 4801 if (kind == 'keys') return _iterStep(0, index); 4802 if (kind == 'values') return _iterStep(0, O[index]); 4803 return _iterStep(0, [index, O[index]]); 4804 }, 'values'); // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7) 4805 4806 _iterators.Arguments = _iterators.Array; 4807 _addToUnscopables('keys'); 4808 _addToUnscopables('values'); 4809 _addToUnscopables('entries'); 4810 4811 var _flags = function () { 4812 var that = _anObject(this); 4813 var result = ''; 4814 if (that.global) result += 'g'; 4815 if (that.ignoreCase) result += 'i'; 4816 if (that.multiline) result += 'm'; 4817 if (that.unicode) result += 'u'; 4818 if (that.sticky) result += 'y'; 4819 return result; 4820 }; 4821 4822 var dP$4 = _objectDp.f; 4823 4824 var gOPN$3 = _objectGopn.f; 4825 4826 4827 4828 4829 4830 var $RegExp = _global.RegExp; 4831 var Base$1 = $RegExp; 4832 var proto$2 = $RegExp.prototype; 4833 var re1 = /a/g; 4834 var re2 = /a/g; // "new" creates a new object, old webkit buggy here 4835 4836 var CORRECT_NEW = new $RegExp(re1) !== re1; 4837 4838 if (_descriptors && (!CORRECT_NEW || _fails(function () { 4839 re2[_wks('match')] = false; // RegExp constructor can alter flags and IsRegExp works correct with @@match 4840 4841 return $RegExp(re1) != re1 || $RegExp(re2) == re2 || $RegExp(re1, 'i') != '/a/i'; 4842 }))) { 4843 $RegExp = function RegExp(p, f) { 4844 var tiRE = this instanceof $RegExp; 4845 var piRE = _isRegexp(p); 4846 var fiU = f === undefined; 4847 return !tiRE && piRE && p.constructor === $RegExp && fiU ? p : _inheritIfRequired(CORRECT_NEW ? new Base$1(piRE && !fiU ? p.source : p, f) : Base$1((piRE = p instanceof $RegExp) ? p.source : p, piRE && fiU ? _flags.call(p) : f), tiRE ? this : proto$2, $RegExp); 4848 }; 4849 4850 var proxy = function proxy(key) { 4851 key in $RegExp || dP$4($RegExp, key, { 4852 configurable: true, 4853 get: function get() { 4854 return Base$1[key]; 4855 }, 4856 set: function set(it) { 4857 Base$1[key] = it; 4858 } 4859 }); 4860 }; 4861 4862 for (var keys$1 = gOPN$3(Base$1), i = 0; keys$1.length > i;) { 4863 proxy(keys$1[i++]); 4864 } 4865 4866 proto$2.constructor = $RegExp; 4867 $RegExp.prototype = proto$2; 4868 4869 _redefine(_global, 'RegExp', $RegExp); 4870 } 4871 4872 _setSpecies('RegExp'); 4873 4874 var nativeExec = RegExp.prototype.exec; // This always refers to the native implementation, because the 4875 // String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js, 4876 // which loads this file before patching the method. 4877 4878 var nativeReplace = String.prototype.replace; 4879 var patchedExec = nativeExec; 4880 var LAST_INDEX = 'lastIndex'; 4881 4882 var UPDATES_LAST_INDEX_WRONG = function () { 4883 var re1 = /a/, 4884 re2 = /b*/g; 4885 nativeExec.call(re1, 'a'); 4886 nativeExec.call(re2, 'a'); 4887 return re1[LAST_INDEX] !== 0 || re2[LAST_INDEX] !== 0; 4888 }(); // nonparticipating capturing group, copied from es5-shim's String#split patch. 4889 4890 4891 var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; 4892 var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED; 4893 4894 if (PATCH) { 4895 patchedExec = function exec(str) { 4896 var re = this; 4897 var lastIndex, reCopy, match, i; 4898 4899 if (NPCG_INCLUDED) { 4900 reCopy = new RegExp('^' + re.source + '$(?!\\s)', _flags.call(re)); 4901 } 4902 4903 if (UPDATES_LAST_INDEX_WRONG) lastIndex = re[LAST_INDEX]; 4904 match = nativeExec.call(re, str); 4905 4906 if (UPDATES_LAST_INDEX_WRONG && match) { 4907 re[LAST_INDEX] = re.global ? match.index + match[0].length : lastIndex; 4908 } 4909 4910 if (NPCG_INCLUDED && match && match.length > 1) { 4911 // Fix browsers whose `exec` methods don't consistently return `undefined` 4912 // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/ 4913 // eslint-disable-next-line no-loop-func 4914 nativeReplace.call(match[0], reCopy, function () { 4915 for (i = 1; i < arguments.length - 2; i++) { 4916 if (arguments[i] === undefined) match[i] = undefined; 4917 } 4918 }); 4919 } 4920 4921 return match; 4922 }; 4923 } 4924 4925 var _regexpExec = patchedExec; 4926 4927 _export({ 4928 target: 'RegExp', 4929 proto: true, 4930 forced: _regexpExec !== /./.exec 4931 }, { 4932 exec: _regexpExec 4933 }); 4934 4935 // 21.2.5.3 get RegExp.prototype.flags() 4936 if (_descriptors && /./g.flags != 'g') _objectDp.f(RegExp.prototype, 'flags', { 4937 configurable: true, 4938 get: _flags 4939 }); 4940 4941 var TO_STRING$1 = 'toString'; 4942 var $toString$1 = /./[TO_STRING$1]; 4943 4944 var define = function define(fn) { 4945 _redefine(RegExp.prototype, TO_STRING$1, fn, true); 4946 }; // 21.2.5.14 RegExp.prototype.toString() 4947 4948 4949 if (_fails(function () { 4950 return $toString$1.call({ 4951 source: 'a', 4952 flags: 'b' 4953 }) != '/a/b'; 4954 })) { 4955 define(function toString() { 4956 var R = _anObject(this); 4957 return '/'.concat(R.source, '/', 'flags' in R ? R.flags : !_descriptors && R instanceof RegExp ? _flags.call(R) : undefined); 4958 }); // FF44- RegExp#toString has a wrong name 4959 } else if ($toString$1.name != TO_STRING$1) { 4960 define(function toString() { 4961 return $toString$1.call(this); 4962 }); 4963 } 4964 4965 var at = _stringAt(true); // `AdvanceStringIndex` abstract operation 4966 // https://tc39.github.io/ecma262/#sec-advancestringindex 4967 4968 4969 var _advanceStringIndex = function (S, index, unicode) { 4970 return index + (unicode ? at(S, index).length : 1); 4971 }; 4972 4973 var builtinExec = RegExp.prototype.exec; // `RegExpExec` abstract operation 4974 // https://tc39.github.io/ecma262/#sec-regexpexec 4975 4976 var _regexpExecAbstract = function (R, S) { 4977 var exec = R.exec; 4978 4979 if (typeof exec === 'function') { 4980 var result = exec.call(R, S); 4981 4982 if (babelHelpers.typeof(result) !== 'object') { 4983 throw new TypeError('RegExp exec method returned something other than an Object or null'); 4984 } 4985 4986 return result; 4987 } 4988 4989 if (_classof(R) !== 'RegExp') { 4990 throw new TypeError('RegExp#exec called on incompatible receiver'); 4991 } 4992 4993 return builtinExec.call(R, S); 4994 }; 4995 4996 var SPECIES$2 = _wks('species'); 4997 var REPLACE_SUPPORTS_NAMED_GROUPS = !_fails(function () { 4998 // #replace needs built-in support for named groups. 4999 // #match works fine because it just return the exec results, even if it has 5000 // a "grops" property. 5001 var re = /./; 5002 5003 re.exec = function () { 5004 var result = []; 5005 result.groups = { 5006 a: '7' 5007 }; 5008 return result; 5009 }; 5010 5011 return ''.replace(re, '$<a>') !== '7'; 5012 }); 5013 5014 var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = function () { 5015 // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec 5016 var re = /(?:)/; 5017 var originalExec = re.exec; 5018 5019 re.exec = function () { 5020 return originalExec.apply(this, arguments); 5021 }; 5022 5023 var result = 'ab'.split(re); 5024 return result.length === 2 && result[0] === 'a' && result[1] === 'b'; 5025 }(); 5026 5027 var _fixReWks = function (KEY, length, exec) { 5028 var SYMBOL = _wks(KEY); 5029 var DELEGATES_TO_SYMBOL = !_fails(function () { 5030 // String methods call symbol-named RegEp methods 5031 var O = {}; 5032 5033 O[SYMBOL] = function () { 5034 return 7; 5035 }; 5036 5037 return ''[KEY](O) != 7; 5038 }); 5039 var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL ? !_fails(function () { 5040 // Symbol-named RegExp methods call .exec 5041 var execCalled = false; 5042 var re = /a/; 5043 5044 re.exec = function () { 5045 execCalled = true; 5046 return null; 5047 }; 5048 5049 if (KEY === 'split') { 5050 // RegExp[@@split] doesn't call the regex's exec method, but first creates 5051 // a new one. We need to return the patched regex when creating the new one. 5052 re.constructor = {}; 5053 5054 re.constructor[SPECIES$2] = function () { 5055 return re; 5056 }; 5057 } 5058 5059 re[SYMBOL](''); 5060 return !execCalled; 5061 }) : undefined; 5062 5063 if (!DELEGATES_TO_SYMBOL || !DELEGATES_TO_EXEC || KEY === 'replace' && !REPLACE_SUPPORTS_NAMED_GROUPS || KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC) { 5064 var nativeRegExpMethod = /./[SYMBOL]; 5065 var fns = exec(_defined, SYMBOL, ''[KEY], function maybeCallNative(nativeMethod, regexp, str, arg2, forceStringMethod) { 5066 if (regexp.exec === _regexpExec) { 5067 if (DELEGATES_TO_SYMBOL && !forceStringMethod) { 5068 // The native String method already delegates to @@method (this 5069 // polyfilled function), leasing to infinite recursion. 5070 // We avoid it by directly calling the native @@method method. 5071 return { 5072 done: true, 5073 value: nativeRegExpMethod.call(regexp, str, arg2) 5074 }; 5075 } 5076 5077 return { 5078 done: true, 5079 value: nativeMethod.call(str, regexp, arg2) 5080 }; 5081 } 5082 5083 return { 5084 done: false 5085 }; 5086 }); 5087 var strfn = fns[0]; 5088 var rxfn = fns[1]; 5089 _redefine(String.prototype, KEY, strfn); 5090 _hide(RegExp.prototype, SYMBOL, length == 2 // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue) 5091 // 21.2.5.11 RegExp.prototype[@@split](string, limit) 5092 ? function (string, arg) { 5093 return rxfn.call(string, this, arg); 5094 } // 21.2.5.6 RegExp.prototype[@@match](string) 5095 // 21.2.5.9 RegExp.prototype[@@search](string) 5096 : function (string) { 5097 return rxfn.call(string, this); 5098 }); 5099 } 5100 }; 5101 5102 // @@match logic 5103 5104 5105 _fixReWks('match', 1, function (defined, MATCH, $match, maybeCallNative) { 5106 return [// `String.prototype.match` method 5107 // https://tc39.github.io/ecma262/#sec-string.prototype.match 5108 function match(regexp) { 5109 var O = defined(this); 5110 var fn = regexp == undefined ? undefined : regexp[MATCH]; 5111 return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O)); 5112 }, // `RegExp.prototype[@@match]` method 5113 // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match 5114 function (regexp) { 5115 var res = maybeCallNative($match, regexp, this); 5116 if (res.done) return res.value; 5117 var rx = _anObject(regexp); 5118 var S = String(this); 5119 if (!rx.global) return _regexpExecAbstract(rx, S); 5120 var fullUnicode = rx.unicode; 5121 rx.lastIndex = 0; 5122 var A = []; 5123 var n = 0; 5124 var result; 5125 5126 while ((result = _regexpExecAbstract(rx, S)) !== null) { 5127 var matchStr = String(result[0]); 5128 A[n] = matchStr; 5129 if (matchStr === '') rx.lastIndex = _advanceStringIndex(S, _toLength(rx.lastIndex), fullUnicode); 5130 n++; 5131 } 5132 5133 return n === 0 ? null : A; 5134 }]; 5135 }); 5136 5137 var max$1 = Math.max; 5138 var min$2 = Math.min; 5139 var floor$3 = Math.floor; 5140 var SUBSTITUTION_SYMBOLS = /\$([$&`']|\d\d?|<[^>]*>)/g; 5141 var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&`']|\d\d?)/g; 5142 5143 var maybeToString = function maybeToString(it) { 5144 return it === undefined ? it : String(it); 5145 }; // @@replace logic 5146 5147 5148 _fixReWks('replace', 2, function (defined, REPLACE, $replace, maybeCallNative) { 5149 return [// `String.prototype.replace` method 5150 // https://tc39.github.io/ecma262/#sec-string.prototype.replace 5151 function replace(searchValue, replaceValue) { 5152 var O = defined(this); 5153 var fn = searchValue == undefined ? undefined : searchValue[REPLACE]; 5154 return fn !== undefined ? fn.call(searchValue, O, replaceValue) : $replace.call(String(O), searchValue, replaceValue); 5155 }, // `RegExp.prototype[@@replace]` method 5156 // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace 5157 function (regexp, replaceValue) { 5158 var res = maybeCallNative($replace, regexp, this, replaceValue); 5159 if (res.done) return res.value; 5160 var rx = _anObject(regexp); 5161 var S = String(this); 5162 var functionalReplace = typeof replaceValue === 'function'; 5163 if (!functionalReplace) replaceValue = String(replaceValue); 5164 var global = rx.global; 5165 5166 if (global) { 5167 var fullUnicode = rx.unicode; 5168 rx.lastIndex = 0; 5169 } 5170 5171 var results = []; 5172 5173 while (true) { 5174 var result = _regexpExecAbstract(rx, S); 5175 if (result === null) break; 5176 results.push(result); 5177 if (!global) break; 5178 var matchStr = String(result[0]); 5179 if (matchStr === '') rx.lastIndex = _advanceStringIndex(S, _toLength(rx.lastIndex), fullUnicode); 5180 } 5181 5182 var accumulatedResult = ''; 5183 var nextSourcePosition = 0; 5184 5185 for (var i = 0; i < results.length; i++) { 5186 result = results[i]; 5187 var matched = String(result[0]); 5188 var position = max$1(min$2(_toInteger(result.index), S.length), 0); 5189 var captures = []; // NOTE: This is equivalent to 5190 // captures = result.slice(1).map(maybeToString) 5191 // but for some reason `nativeSlice.call(result, 1, result.length)` (called in 5192 // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and 5193 // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it. 5194 5195 for (var j = 1; j < result.length; j++) { 5196 captures.push(maybeToString(result[j])); 5197 } 5198 5199 var namedCaptures = result.groups; 5200 5201 if (functionalReplace) {
vendor: 6,187 bytes, lines 5202-5369
5202 var replacerArgs = [matched].concat(captures, position, S); 5203 if (namedCaptures !== undefined) replacerArgs.push(namedCaptures); 5204 var replacement = String(replaceValue.apply(undefined, replacerArgs)); 5205 } else { 5206 replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue); 5207 } 5208 5209 if (position >= nextSourcePosition) { 5210 accumulatedResult += S.slice(nextSourcePosition, position) + replacement; 5211 nextSourcePosition = position + matched.length; 5212 } 5213 } 5214 5215 return accumulatedResult + S.slice(nextSourcePosition); 5216 }]; // https://tc39.github.io/ecma262/#sec-getsubstitution 5217 5218 function getSubstitution(matched, str, position, captures, namedCaptures, replacement) { 5219 var tailPos = position + matched.length; 5220 var m = captures.length; 5221 var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED; 5222 5223 if (namedCaptures !== undefined) { 5224 namedCaptures = _toObject(namedCaptures); 5225 symbols = SUBSTITUTION_SYMBOLS; 5226 } 5227 5228 return $replace.call(replacement, symbols, function (match, ch) { 5229 var capture; 5230 5231 switch (ch.charAt(0)) { 5232 case '$': 5233 return '$'; 5234 5235 case '&': 5236 return matched; 5237 5238 case '`': 5239 return str.slice(0, position); 5240 5241 case "'": 5242 return str.slice(tailPos); 5243 5244 case '<': 5245 capture = namedCaptures[ch.slice(1, -1)]; 5246 break; 5247 5248 default: 5249 // \d\d? 5250 var n = +ch; 5251 if (n === 0) return match; 5252 5253 if (n > m) { 5254 var f = floor$3(n / 10); 5255 if (f === 0) return match; 5256 if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1); 5257 return match; 5258 } 5259 5260 capture = captures[n - 1]; 5261 } 5262 5263 return capture === undefined ? '' : capture; 5264 }); 5265 } 5266 }); 5267 5268 // @@search logic 5269 5270 5271 _fixReWks('search', 1, function (defined, SEARCH, $search, maybeCallNative) { 5272 return [// `String.prototype.search` method 5273 // https://tc39.github.io/ecma262/#sec-string.prototype.search 5274 function search(regexp) { 5275 var O = defined(this); 5276 var fn = regexp == undefined ? undefined : regexp[SEARCH]; 5277 return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O)); 5278 }, // `RegExp.prototype[@@search]` method 5279 // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@search 5280 function (regexp) { 5281 var res = maybeCallNative($search, regexp, this); 5282 if (res.done) return res.value; 5283 var rx = _anObject(regexp); 5284 var S = String(this); 5285 var previousLastIndex = rx.lastIndex; 5286 if (!_sameValue(previousLastIndex, 0)) rx.lastIndex = 0; 5287 var result = _regexpExecAbstract(rx, S); 5288 if (!_sameValue(rx.lastIndex, previousLastIndex)) rx.lastIndex = previousLastIndex; 5289 return result === null ? -1 : result.index; 5290 }]; 5291 }); 5292 5293 // 7.3.20 SpeciesConstructor(O, defaultConstructor) 5294 5295 5296 5297 5298 var SPECIES$3 = _wks('species'); 5299 5300 var _speciesConstructor = function (O, D) { 5301 var C = _anObject(O).constructor; 5302 var S; 5303 return C === undefined || (S = _anObject(C)[SPECIES$3]) == undefined ? D : _aFunction(S); 5304 }; 5305 5306 var $min = Math.min; 5307 var $push = [].push; 5308 var $SPLIT = 'split'; 5309 var LENGTH = 'length'; 5310 var LAST_INDEX$1 = 'lastIndex'; 5311 var MAX_UINT32 = 0xffffffff; // babel-minify transpiles RegExp('x', 'y') -> /x/y and it causes SyntaxError 5312 5313 var SUPPORTS_Y = !_fails(function () { 5314 }); // @@split logic 5315 5316 _fixReWks('split', 2, function (defined, SPLIT, $split, maybeCallNative) { 5317 var internalSplit; 5318 5319 if ('abbc'[$SPLIT](/(b)*/)[1] == 'c' || 'test'[$SPLIT](/(?:)/, -1)[LENGTH] != 4 || 'ab'[$SPLIT](/(?:ab)*/)[LENGTH] != 2 || '.'[$SPLIT](/(.?)(.?)/)[LENGTH] != 4 || '.'[$SPLIT](/()()/)[LENGTH] > 1 || ''[$SPLIT](/.?/)[LENGTH]) { 5320 // based on es5-shim implementation, need to rework it 5321 internalSplit = function internalSplit(separator, limit) { 5322 var string = String(this); 5323 if (separator === undefined && limit === 0) return []; // If `separator` is not a regex, use native split 5324 5325 if (!_isRegexp(separator)) return $split.call(string, separator, limit); 5326 var output = []; 5327 var flags = (separator.ignoreCase ? 'i' : '') + (separator.multiline ? 'm' : '') + (separator.unicode ? 'u' : '') + (separator.sticky ? 'y' : ''); 5328 var lastLastIndex = 0; 5329 var splitLimit = limit === undefined ? MAX_UINT32 : limit >>> 0; // Make `global` and avoid `lastIndex` issues by working with a copy 5330 5331 var separatorCopy = new RegExp(separator.source, flags + 'g'); 5332 var match, lastIndex, lastLength; 5333 5334 while (match = _regexpExec.call(separatorCopy, string)) { 5335 lastIndex = separatorCopy[LAST_INDEX$1]; 5336 5337 if (lastIndex > lastLastIndex) { 5338 output.push(string.slice(lastLastIndex, match.index)); 5339 if (match[LENGTH] > 1 && match.index < string[LENGTH]) $push.apply(output, match.slice(1)); 5340 lastLength = match[0][LENGTH]; 5341 lastLastIndex = lastIndex; 5342 if (output[LENGTH] >= splitLimit) break; 5343 } 5344 5345 if (separatorCopy[LAST_INDEX$1] === match.index) separatorCopy[LAST_INDEX$1]++; // Avoid an infinite loop 5346 } 5347 5348 if (lastLastIndex === string[LENGTH]) { 5349 if (lastLength || !separatorCopy.test('')) output.push(''); 5350 } else output.push(string.slice(lastLastIndex)); 5351 5352 return output[LENGTH] > splitLimit ? output.slice(0, splitLimit) : output; 5353 }; // Chakra, V8 5354 5355 } else if ('0'[$SPLIT](undefined, 0)[LENGTH]) { 5356 internalSplit = function internalSplit(separator, limit) { 5357 return separator === undefined && limit === 0 ? [] : $split.call(this, separator, limit); 5358 }; 5359 } else { 5360 internalSplit = $split; 5361 } 5362 5363 return [// `String.prototype.split` method 5364 // https://tc39.github.io/ecma262/#sec-string.prototype.split 5365 function split(separator, limit) { 5366 var O = defined(this); 5367 var splitter = separator == undefined ? undefined : separator[SPLIT]; 5368 return splitter !== undefined ? splitter.call(separator, O, limit) : internalSplit.call(String(O), separator, limit); 5369 }
vendor: 70,404 bytes, lines 5369-7869
5369, // `RegExp.prototype[@@split]` method 5370 // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@split 5371 // 5372 // NOTE: This cannot be properly polyfilled in engines that don't support 5373 // the 'y' flag. 5374 function (regexp, limit) { 5375 var res = maybeCallNative(internalSplit, regexp, this, limit, internalSplit !== $split); 5376 if (res.done) return res.value; 5377 var rx = _anObject(regexp); 5378 var S = String(this); 5379 var C = _speciesConstructor(rx, RegExp); 5380 var unicodeMatching = rx.unicode; 5381 var flags = (rx.ignoreCase ? 'i' : '') + (rx.multiline ? 'm' : '') + (rx.unicode ? 'u' : '') + (SUPPORTS_Y ? 'y' : 'g'); // ^(? + rx + ) is needed, in combination with some S slicing, to 5382 // simulate the 'y' flag. 5383 5384 var splitter = new C(SUPPORTS_Y ? rx : '^(?:' + rx.source + ')', flags); 5385 var lim = limit === undefined ? MAX_UINT32 : limit >>> 0; 5386 if (lim === 0) return []; 5387 if (S.length === 0) return _regexpExecAbstract(splitter, S) === null ? [S] : []; 5388 var p = 0; 5389 var q = 0; 5390 var A = []; 5391 5392 while (q < S.length) { 5393 splitter.lastIndex = SUPPORTS_Y ? q : 0; 5394 var z = _regexpExecAbstract(splitter, SUPPORTS_Y ? S : S.slice(q)); 5395 var e; 5396 5397 if (z === null || (e = $min(_toLength(splitter.lastIndex + (SUPPORTS_Y ? 0 : q)), S.length)) === p) { 5398 q = _advanceStringIndex(S, q, unicodeMatching); 5399 } else { 5400 A.push(S.slice(p, q)); 5401 if (A.length === lim) return A; 5402 5403 for (var i = 1; i <= z.length - 1; i++) { 5404 A.push(z[i]); 5405 if (A.length === lim) return A; 5406 } 5407 5408 q = p = e; 5409 } 5410 } 5411 5412 A.push(S.slice(p)); 5413 return A; 5414 }]; 5415 }); 5416 5417 var _anInstance = function (it, Constructor, name, forbiddenField) { 5418 if (!(it instanceof Constructor) || forbiddenField !== undefined && forbiddenField in it) { 5419 throw TypeError(name + ': incorrect invocation!'); 5420 } 5421 5422 return it; 5423 }; 5424 5425 var _forOf = createCommonjsModule(function (module) { 5426 var BREAK = {}; 5427 var RETURN = {}; 5428 5429 var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) { 5430 var iterFn = ITERATOR ? function () { 5431 return iterable; 5432 } : core_getIteratorMethod(iterable); 5433 var f = _ctx(fn, that, entries ? 2 : 1); 5434 var index = 0; 5435 var length, step, iterator, result; 5436 if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!'); // fast case for arrays with default iterator 5437 5438 if (_isArrayIter(iterFn)) for (length = _toLength(iterable.length); length > index; index++) { 5439 result = entries ? f(_anObject(step = iterable[index])[0], step[1]) : f(iterable[index]); 5440 if (result === BREAK || result === RETURN) return result; 5441 } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) { 5442 result = _iterCall(iterator, f, step.value, entries); 5443 if (result === BREAK || result === RETURN) return result; 5444 } 5445 }; 5446 5447 exports.BREAK = BREAK; 5448 exports.RETURN = RETURN; 5449 }); 5450 5451 var process = _global.process; 5452 var setTask = _global.setImmediate; 5453 var clearTask = _global.clearImmediate; 5454 var MessageChannel = _global.MessageChannel; 5455 var Dispatch = _global.Dispatch; 5456 var counter = 0; 5457 var queue = {}; 5458 var ONREADYSTATECHANGE = 'onreadystatechange'; 5459 var defer, channel, port; 5460 5461 var run = function run() { 5462 var id = +this; // eslint-disable-next-line no-prototype-builtins 5463 5464 if (queue.hasOwnProperty(id)) { 5465 var fn = queue[id]; 5466 delete queue[id]; 5467 fn(); 5468 } 5469 }; 5470 5471 var listener = function listener(event) { 5472 run.call(event.data); 5473 }; // Node.js 0.9+ & IE10+ has setImmediate, otherwise: 5474 5475 5476 if (!setTask || !clearTask) { 5477 setTask = function setImmediate(fn) { 5478 var args = []; 5479 var i = 1; 5480 5481 while (arguments.length > i) { 5482 args.push(arguments[i++]); 5483 } 5484 5485 queue[++counter] = function () { 5486 // eslint-disable-next-line no-new-func 5487 _invoke(typeof fn == 'function' ? fn : Function(fn), args); 5488 }; 5489 5490 defer(counter); 5491 return counter; 5492 }; 5493 5494 clearTask = function clearImmediate(id) { 5495 delete queue[id]; 5496 }; // Node.js 0.8- 5497 5498 5499 if (_cof(process) == 'process') { 5500 defer = function defer(id) { 5501 process.nextTick(_ctx(run, id, 1)); 5502 }; // Sphere (JS game engine) Dispatch API 5503 5504 } else if (Dispatch && Dispatch.now) { 5505 defer = function defer(id) { 5506 Dispatch.now(_ctx(run, id, 1)); 5507 }; // Browsers with MessageChannel, includes WebWorkers 5508 5509 } else if (MessageChannel) { 5510 channel = new MessageChannel(); 5511 port = channel.port2; 5512 channel.port1.onmessage = listener; 5513 defer = _ctx(port.postMessage, port, 1); // Browsers with postMessage, skip WebWorkers 5514 // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' 5515 } else if (_global.addEventListener && typeof postMessage == 'function' && !_global.importScripts) { 5516 defer = function defer(id) { 5517 _global.postMessage(id + '', '*'); 5518 }; 5519 5520 _global.addEventListener('message', listener, false); // IE8- 5521 } else if (ONREADYSTATECHANGE in _domCreate('script')) { 5522 defer = function defer(id) { 5523 _html.appendChild(_domCreate('script'))[ONREADYSTATECHANGE] = function () { 5524 _html.removeChild(this); 5525 run.call(id); 5526 }; 5527 }; // Rest old browsers 5528 5529 } else { 5530 defer = function defer(id) { 5531 setTimeout(_ctx(run, id, 1), 0); 5532 }; 5533 } 5534 } 5535 5536 var _task = { 5537 set: setTask, 5538 clear: clearTask 5539 }; 5540 5541 var macrotask = _task.set; 5542 5543 var Observer = _global.MutationObserver || _global.WebKitMutationObserver; 5544 var process$1 = _global.process; 5545 var Promise = _global.Promise; 5546 var isNode = _cof(process$1) == 'process'; 5547 5548 var _microtask = function () { 5549 var head, last, notify; 5550 5551 var flush = function flush() { 5552 var parent, fn; 5553 if (isNode && (parent = process$1.domain)) parent.exit(); 5554 5555 while (head) { 5556 fn = head.fn; 5557 head = head.next; 5558 5559 try { 5560 fn(); 5561 } catch (e) { 5562 if (head) notify();else last = undefined; 5563 throw e; 5564 } 5565 } 5566 5567 last = undefined; 5568 if (parent) parent.enter(); 5569 }; // Node.js 5570 5571 5572 if (isNode) { 5573 notify = function notify() { 5574 process$1.nextTick(flush); 5575 }; // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339 5576 5577 } else if (Observer && !(_global.navigator && _global.navigator.standalone)) { 5578 var toggle = true; 5579 var node = document.createTextNode(''); 5580 new Observer(flush).observe(node, { 5581 characterData: true 5582 }); // eslint-disable-line no-new 5583 5584 notify = function notify() { 5585 node.data = toggle = !toggle; 5586 }; // environments with maybe non-completely correct, but existent Promise 5587 5588 } else if (Promise && Promise.resolve) { 5589 // Promise.resolve without an argument throws an error in LG WebOS 2 5590 var promise = Promise.resolve(undefined); 5591 5592 notify = function notify() { 5593 promise.then(flush); 5594 }; // for other environments - macrotask based on: 5595 // - setImmediate 5596 // - MessageChannel 5597 // - window.postMessag 5598 // - onreadystatechange 5599 // - setTimeout 5600 5601 } else { 5602 notify = function notify() { 5603 // strange IE + webpack dev server bug - use .call(global) 5604 macrotask.call(_global, flush); 5605 }; 5606 } 5607 5608 return function (fn) { 5609 var task = { 5610 fn: fn, 5611 next: undefined 5612 }; 5613 if (last) last.next = task; 5614 5615 if (!head) { 5616 head = task; 5617 notify(); 5618 } 5619 5620 last = task; 5621 }; 5622 }; 5623 5624 function PromiseCapability(C) { 5625 var resolve, reject; 5626 this.promise = new C(function ($$resolve, $$reject) { 5627 if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor'); 5628 resolve = $$resolve; 5629 reject = $$reject; 5630 }); 5631 this.resolve = _aFunction(resolve); 5632 this.reject = _aFunction(reject); 5633 } 5634 5635 var f$7 = function (C) { 5636 return new PromiseCapability(C); 5637 }; 5638 5639 var _newPromiseCapability = { 5640 f: f$7 5641 }; 5642 5643 var _perform = function (exec) { 5644 try { 5645 return { 5646 e: false, 5647 v: exec() 5648 }; 5649 } catch (e) { 5650 return { 5651 e: true, 5652 v: e 5653 }; 5654 } 5655 }; 5656 5657 var navigator = _global.navigator; 5658 var _userAgent = navigator && navigator.userAgent || ''; 5659 5660 var _promiseResolve = function (C, x) { 5661 _anObject(C); 5662 if (_isObject(x) && x.constructor === C) return x; 5663 var promiseCapability = _newPromiseCapability.f(C); 5664 var resolve = promiseCapability.resolve; 5665 resolve(x); 5666 return promiseCapability.promise; 5667 }; 5668 5669 var _redefineAll = function (target, src, safe) { 5670 for (var key in src) { 5671 _redefine(target, key, src[key], safe); 5672 } 5673 5674 return target; 5675 }; 5676 5677 var task = _task.set; 5678 5679 var microtask = _microtask(); 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 var PROMISE = 'Promise'; 5690 var TypeError$1 = _global.TypeError; 5691 var process$2 = _global.process; 5692 var versions = process$2 && process$2.versions; 5693 var v8 = versions && versions.v8 || ''; 5694 var $Promise = _global[PROMISE]; 5695 var isNode$1 = _classof(process$2) == 'process'; 5696 5697 var empty = function empty() { 5698 /* empty */ 5699 }; 5700 5701 var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper; 5702 var newPromiseCapability = newGenericPromiseCapability = _newPromiseCapability.f; 5703 var USE_NATIVE$1 = !!function () { 5704 try { 5705 // correct subclassing with @@species support 5706 var promise = $Promise.resolve(1); 5707 5708 var FakePromise = (promise.constructor = {})[_wks('species')] = function (exec) { 5709 exec(empty, empty); 5710 }; // unhandled rejections tracking support, NodeJS Promise without it fails @@species test 5711 5712 5713 return (isNode$1 || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise // v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables 5714 // https://bugs.chromium.org/p/chromium/issues/detail?id=830565 5715 // we can't detect it synchronously, so just check versions 5716 && v8.indexOf('6.6') !== 0 && _userAgent.indexOf('Chrome/66') === -1; 5717 } catch (e) { 5718 /* empty */ 5719 } 5720 }(); // helpers 5721 5722 var isThenable = function isThenable(it) { 5723 var then; 5724 return _isObject(it) && typeof (then = it.then) == 'function' ? then : false; 5725 }; 5726 5727 var notify = function notify(promise, isReject) { 5728 if (promise._n) return; 5729 promise._n = true; 5730 var chain = promise._c; 5731 microtask(function () { 5732 var value = promise._v; 5733 var ok = promise._s == 1; 5734 var i = 0; 5735 5736 var run = function run(reaction) { 5737 var handler = ok ? reaction.ok : reaction.fail; 5738 var resolve = reaction.resolve; 5739 var reject = reaction.reject; 5740 var domain = reaction.domain; 5741 var result, then, exited; 5742 5743 try { 5744 if (handler) { 5745 if (!ok) { 5746 if (promise._h == 2) onHandleUnhandled(promise); 5747 promise._h = 1; 5748 } 5749 5750 if (handler === true) result = value;else { 5751 if (domain) domain.enter(); 5752 result = handler(value); // may throw 5753 5754 if (domain) { 5755 domain.exit(); 5756 exited = true; 5757 } 5758 } 5759 5760 if (result === reaction.promise) { 5761 reject(TypeError$1('Promise-chain cycle')); 5762 } else if (then = isThenable(result)) { 5763 then.call(result, resolve, reject); 5764 } else resolve(result); 5765 } else reject(value); 5766 } catch (e) { 5767 if (domain && !exited) domain.exit(); 5768 reject(e); 5769 } 5770 }; 5771 5772 while (chain.length > i) { 5773 run(chain[i++]); 5774 } // variable length - can't use forEach 5775 5776 5777 promise._c = []; 5778 promise._n = false; 5779 if (isReject && !promise._h) onUnhandled(promise); 5780 }); 5781 }; 5782 5783 var onUnhandled = function onUnhandled(promise) { 5784 task.call(_global, function () { 5785 var value = promise._v; 5786 var unhandled = isUnhandled(promise); 5787 var result, handler, console; 5788 5789 if (unhandled) { 5790 result = _perform(function () { 5791 if (isNode$1) { 5792 process$2.emit('unhandledRejection', value, promise); 5793 } else if (handler = _global.onunhandledrejection) { 5794 handler({ 5795 promise: promise, 5796 reason: value 5797 }); 5798 } else if ((console = _global.console) && console.error) { 5799 console.error('Unhandled promise rejection', value); 5800 } 5801 }); // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should 5802 5803 promise._h = isNode$1 || isUnhandled(promise) ? 2 : 1; 5804 } 5805 5806 promise._a = undefined; 5807 if (unhandled && result.e) throw result.v; 5808 }); 5809 }; 5810 5811 var isUnhandled = function isUnhandled(promise) { 5812 return promise._h !== 1 && (promise._a || promise._c).length === 0; 5813 }; 5814 5815 var onHandleUnhandled = function onHandleUnhandled(promise) { 5816 task.call(_global, function () { 5817 var handler; 5818 5819 if (isNode$1) { 5820 process$2.emit('rejectionHandled', promise); 5821 } else if (handler = _global.onrejectionhandled) { 5822 handler({ 5823 promise: promise, 5824 reason: promise._v 5825 }); 5826 } 5827 }); 5828 }; 5829 5830 var $reject = function $reject(value) { 5831 var promise = this; 5832 if (promise._d) return; 5833 promise._d = true; 5834 promise = promise._w || promise; // unwrap 5835 5836 promise._v = value; 5837 promise._s = 2; 5838 if (!promise._a) promise._a = promise._c.slice(); 5839 notify(promise, true); 5840 }; 5841 5842 var $resolve = function $resolve(value) { 5843 var promise = this; 5844 var then; 5845 if (promise._d) return; 5846 promise._d = true; 5847 promise = promise._w || promise; // unwrap 5848 5849 try { 5850 if (promise === value) throw TypeError$1("Promise can't be resolved itself"); 5851 5852 if (then = isThenable(value)) { 5853 microtask(function () { 5854 var wrapper = { 5855 _w: promise, 5856 _d: false 5857 }; // wrap 5858 5859 try { 5860 then.call(value, _ctx($resolve, wrapper, 1), _ctx($reject, wrapper, 1)); 5861 } catch (e) { 5862 $reject.call(wrapper, e); 5863 } 5864 }); 5865 } else { 5866 promise._v = value; 5867 promise._s = 1; 5868 notify(promise, false); 5869 } 5870 } catch (e) { 5871 $reject.call({ 5872 _w: promise, 5873 _d: false 5874 }, e); // wrap 5875 } 5876 }; // constructor polyfill 5877 5878 5879 if (!USE_NATIVE$1) { 5880 // 25.4.3.1 Promise(executor) 5881 $Promise = function Promise(executor) { 5882 _anInstance(this, $Promise, PROMISE, '_h'); 5883 _aFunction(executor); 5884 Internal.call(this); 5885 5886 try { 5887 executor(_ctx($resolve, this, 1), _ctx($reject, this, 1)); 5888 } catch (err) { 5889 $reject.call(this, err); 5890 } 5891 }; // eslint-disable-next-line no-unused-vars 5892 5893 5894 Internal = function Promise(executor) { 5895 this._c = []; // <- awaiting reactions 5896 5897 this._a = undefined; // <- checked in isUnhandled reactions 5898 5899 this._s = 0; // <- state 5900 5901 this._d = false; // <- done 5902 5903 this._v = undefined; // <- value 5904 5905 this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled 5906 5907 this._n = false; // <- notify 5908 }; 5909 5910 Internal.prototype = _redefineAll($Promise.prototype, { 5911 // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected) 5912 then: function then(onFulfilled, onRejected) { 5913 var reaction = newPromiseCapability(_speciesConstructor(this, $Promise)); 5914 reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true; 5915 reaction.fail = typeof onRejected == 'function' && onRejected; 5916 reaction.domain = isNode$1 ? process$2.domain : undefined; 5917 5918 this._c.push(reaction); 5919 5920 if (this._a) this._a.push(reaction); 5921 if (this._s) notify(this, false); 5922 return reaction.promise; 5923 }, 5924 // 25.4.5.1 Promise.prototype.catch(onRejected) 5925 'catch': function _catch(onRejected) { 5926 return this.then(undefined, onRejected); 5927 } 5928 }); 5929 5930 OwnPromiseCapability = function OwnPromiseCapability() { 5931 var promise = new Internal(); 5932 this.promise = promise; 5933 this.resolve = _ctx($resolve, promise, 1); 5934 this.reject = _ctx($reject, promise, 1); 5935 }; 5936 5937 _newPromiseCapability.f = newPromiseCapability = function newPromiseCapability(C) { 5938 return C === $Promise || C === Wrapper ? new OwnPromiseCapability(C) : newGenericPromiseCapability(C); 5939 }; 5940 } 5941 5942 _export(_export.G + _export.W + _export.F * !USE_NATIVE$1, { 5943 Promise: $Promise 5944 }); 5945 5946 _setToStringTag($Promise, PROMISE); 5947 5948 _setSpecies(PROMISE); 5949 5950 Wrapper = _core[PROMISE]; // statics 5951 5952 _export(_export.S + _export.F * !USE_NATIVE$1, PROMISE, { 5953 // 25.4.4.5 Promise.reject(r) 5954 reject: function reject(r) { 5955 var capability = newPromiseCapability(this); 5956 var $$reject = capability.reject; 5957 $$reject(r); 5958 return capability.promise; 5959 } 5960 }); 5961 _export(_export.S + _export.F * (_library || !USE_NATIVE$1), PROMISE, { 5962 // 25.4.4.6 Promise.resolve(x) 5963 resolve: function resolve(x) { 5964 return _promiseResolve(_library && this === Wrapper ? $Promise : this, x); 5965 } 5966 }); 5967 _export(_export.S + _export.F * !(USE_NATIVE$1 && _iterDetect(function (iter) { 5968 $Promise.all(iter)['catch'](empty); 5969 })), PROMISE, { 5970 // 25.4.4.1 Promise.all(iterable) 5971 all: function all(iterable) { 5972 var C = this; 5973 var capability = newPromiseCapability(C); 5974 var resolve = capability.resolve; 5975 var reject = capability.reject; 5976 var result = _perform(function () { 5977 var values = []; 5978 var index = 0; 5979 var remaining = 1; 5980 _forOf(iterable, false, function (promise) { 5981 var $index = index++; 5982 var alreadyCalled = false; 5983 values.push(undefined); 5984 remaining++; 5985 C.resolve(promise).then(function (value) { 5986 if (alreadyCalled) return; 5987 alreadyCalled = true; 5988 values[$index] = value; 5989 --remaining || resolve(values); 5990 }, reject); 5991 }); 5992 --remaining || resolve(values); 5993 }); 5994 if (result.e) reject(result.v); 5995 return capability.promise; 5996 }, 5997 // 25.4.4.4 Promise.race(iterable) 5998 race: function race(iterable) { 5999 var C = this; 6000 var capability = newPromiseCapability(C); 6001 var reject = capability.reject; 6002 var result = _perform(function () { 6003 _forOf(iterable, false, function (promise) { 6004 C.resolve(promise).then(capability.resolve, reject); 6005 }); 6006 }); 6007 if (result.e) reject(result.v); 6008 return capability.promise; 6009 } 6010 }); 6011 6012 var _validateCollection = function (it, TYPE) { 6013 if (!_isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!'); 6014 return it; 6015 }; 6016 6017 var dP$5 = _objectDp.f; 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 var fastKey = _meta.fastKey; 6038 6039 6040 6041 var SIZE = _descriptors ? '_s' : 'size'; 6042 6043 var getEntry = function getEntry(that, key) { 6044 // fast case 6045 var index = fastKey(key); 6046 var entry; 6047 if (index !== 'F') return that._i[index]; // frozen object case 6048 6049 for (entry = that._f; entry; entry = entry.n) { 6050 if (entry.k == key) return entry; 6051 } 6052 }; 6053 6054 var _collectionStrong = { 6055 getConstructor: function getConstructor(wrapper, NAME, IS_MAP, ADDER) { 6056 var C = wrapper(function (that, iterable) { 6057 _anInstance(that, C, NAME, '_i'); 6058 that._t = NAME; // collection type 6059 6060 that._i = _objectCreate(null); // index 6061 6062 that._f = undefined; // first entry 6063 6064 that._l = undefined; // last entry 6065 6066 that[SIZE] = 0; // size 6067 6068 if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that); 6069 }); 6070 _redefineAll(C.prototype, { 6071 // 23.1.3.1 Map.prototype.clear() 6072 // 23.2.3.2 Set.prototype.clear() 6073 clear: function clear() { 6074 for (var that = _validateCollection(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) { 6075 entry.r = true; 6076 if (entry.p) entry.p = entry.p.n = undefined; 6077 delete data[entry.i]; 6078 } 6079 6080 that._f = that._l = undefined; 6081 that[SIZE] = 0; 6082 }, 6083 // 23.1.3.3 Map.prototype.delete(key) 6084 // 23.2.3.4 Set.prototype.delete(value) 6085 'delete': function _delete(key) { 6086 var that = _validateCollection(this, NAME); 6087 var entry = getEntry(that, key); 6088 6089 if (entry) { 6090 var next = entry.n; 6091 var prev = entry.p; 6092 delete that._i[entry.i]; 6093 entry.r = true; 6094 if (prev) prev.n = next; 6095 if (next) next.p = prev; 6096 if (that._f == entry) that._f = next; 6097 if (that._l == entry) that._l = prev; 6098 that[SIZE]--; 6099 } 6100 6101 return !!entry; 6102 }, 6103 // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined) 6104 // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined) 6105 forEach: function forEach(callbackfn 6106 /* , that = undefined */ 6107 ) { 6108 _validateCollection(this, NAME); 6109 var f = _ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); 6110 var entry; 6111 6112 while (entry = entry ? entry.n : this._f) { 6113 f(entry.v, entry.k, this); // revert to the last existing entry 6114 6115 while (entry && entry.r) { 6116 entry = entry.p; 6117 } 6118 } 6119 }, 6120 // 23.1.3.7 Map.prototype.has(key) 6121 // 23.2.3.7 Set.prototype.has(value) 6122 has: function has(key) { 6123 return !!getEntry(_validateCollection(this, NAME), key); 6124 } 6125 }); 6126 if (_descriptors) dP$5(C.prototype, 'size', { 6127 get: function get() { 6128 return _validateCollection(this, NAME)[SIZE]; 6129 } 6130 }); 6131 return C; 6132 }, 6133 def: function def(that, key, value) { 6134 var entry = getEntry(that, key); 6135 var prev, index; // change existing entry 6136 6137 if (entry) { 6138 entry.v = value; // create new entry 6139 } else { 6140 that._l = entry = { 6141 i: index = fastKey(key, true), 6142 // <- index 6143 k: key, 6144 // <- key 6145 v: value, 6146 // <- value 6147 p: prev = that._l, 6148 // <- previous entry 6149 n: undefined, 6150 // <- next entry 6151 r: false // <- removed 6152 6153 }; 6154 if (!that._f) that._f = entry; 6155 if (prev) prev.n = entry; 6156 that[SIZE]++; // add to index 6157 6158 if (index !== 'F') that._i[index] = entry; 6159 } 6160 6161 return that; 6162 }, 6163 getEntry: getEntry, 6164 setStrong: function setStrong(C, NAME, IS_MAP) { 6165 // add .keys, .values, .entries, [@@iterator] 6166 // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11 6167 _iterDefine(C, NAME, function (iterated, kind) { 6168 this._t = _validateCollection(iterated, NAME); // target 6169 6170 this._k = kind; // kind 6171 6172 this._l = undefined; // previous 6173 }, function () { 6174 var that = this; 6175 var kind = that._k; 6176 var entry = that._l; // revert to the last existing entry 6177 6178 while (entry && entry.r) { 6179 entry = entry.p; 6180 } // get next entry 6181 6182 6183 if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) { 6184 // or finish the iteration 6185 that._t = undefined; 6186 return _iterStep(1); 6187 } // return step by kind 6188 6189 6190 if (kind == 'keys') return _iterStep(0, entry.k); 6191 if (kind == 'values') return _iterStep(0, entry.v); 6192 return _iterStep(0, [entry.k, entry.v]); 6193 }, IS_MAP ? 'entries' : 'values', !IS_MAP, true); // add [@@species], 23.1.2.2, 23.2.2.2 6194 6195 _setSpecies(NAME); 6196 } 6197 }; 6198 6199 var _collection = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) { 6200 var Base = _global[NAME]; 6201 var C = Base; 6202 var ADDER = IS_MAP ? 'set' : 'add'; 6203 var proto = C && C.prototype; 6204 var O = {}; 6205 6206 var fixMethod = function fixMethod(KEY) { 6207 var fn = proto[KEY]; 6208 _redefine(proto, KEY, KEY == 'delete' ? function (a) { 6209 return IS_WEAK && !_isObject(a) ? false : fn.call(this, a === 0 ? 0 : a); 6210 } : KEY == 'has' ? function has(a) { 6211 return IS_WEAK && !_isObject(a) ? false : fn.call(this, a === 0 ? 0 : a); 6212 } : KEY == 'get' ? function get(a) { 6213 return IS_WEAK && !_isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a); 6214 } : KEY == 'add' ? function add(a) { 6215 fn.call(this, a === 0 ? 0 : a); 6216 return this; 6217 } : function set(a, b) { 6218 fn.call(this, a === 0 ? 0 : a, b); 6219 return this; 6220 }); 6221 }; 6222 6223 if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !_fails(function () { 6224 new C().entries().next(); 6225 }))) { 6226 // create collection constructor 6227 C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER); 6228 _redefineAll(C.prototype, methods); 6229 _meta.NEED = true; 6230 } else { 6231 var instance = new C(); // early implementations not supports chaining 6232 6233 var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance; // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false 6234 6235 var THROWS_ON_PRIMITIVES = _fails(function () { 6236 instance.has(1); 6237 }); // most early implementations doesn't supports iterables, most modern - not close it correctly 6238 6239 var ACCEPT_ITERABLES = _iterDetect(function (iter) { 6240 new C(iter); 6241 }); // eslint-disable-line no-new 6242 // for early implementations -0 and +0 not the same 6243 6244 var BUGGY_ZERO = !IS_WEAK && _fails(function () { 6245 // V8 ~ Chromium 42- fails only with 5+ elements 6246 var $instance = new C(); 6247 var index = 5; 6248 6249 while (index--) { 6250 $instance[ADDER](index, index); 6251 } 6252 6253 return !$instance.has(-0); 6254 }); 6255 6256 if (!ACCEPT_ITERABLES) { 6257 C = wrapper(function (target, iterable) { 6258 _anInstance(target, C, NAME); 6259 var that = _inheritIfRequired(new Base(), target, C); 6260 if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that); 6261 return that; 6262 }); 6263 C.prototype = proto; 6264 proto.constructor = C; 6265 } 6266 6267 if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) { 6268 fixMethod('delete'); 6269 fixMethod('has'); 6270 IS_MAP && fixMethod('get'); 6271 } 6272 6273 if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER); // weak collections should not contains .clear method 6274 6275 if (IS_WEAK && proto.clear) delete proto.clear; 6276 } 6277 6278 _setToStringTag(C, NAME); 6279 O[NAME] = C; 6280 _export(_export.G + _export.W + _export.F * (C != Base), O); 6281 if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP); 6282 return C; 6283 }; 6284 6285 var MAP = 'Map'; // 23.1 Map Objects 6286 6287 var es6_map = _collection(MAP, function (get) { 6288 return function Map() { 6289 return get(this, arguments.length > 0 ? arguments[0] : undefined); 6290 }; 6291 }, { 6292 // 23.1.3.6 Map.prototype.get(key) 6293 get: function get(key) { 6294 var entry = _collectionStrong.getEntry(_validateCollection(this, MAP), key); 6295 return entry && entry.v; 6296 }, 6297 // 23.1.3.9 Map.prototype.set(key, value) 6298 set: function set(key, value) { 6299 return _collectionStrong.def(_validateCollection(this, MAP), key === 0 ? 0 : key, value); 6300 } 6301 }, _collectionStrong, true); 6302 6303 var SET = 'Set'; // 23.2 Set Objects 6304 6305 var es6_set = _collection(SET, function (get) { 6306 return function Set() { 6307 return get(this, arguments.length > 0 ? arguments[0] : undefined); 6308 }; 6309 }, { 6310 // 23.2.3.1 Set.prototype.add(value) 6311 add: function add(value) { 6312 return _collectionStrong.def(_validateCollection(this, SET), value = value === 0 ? 0 : value, value); 6313 } 6314 }, _collectionStrong); 6315 6316 var getWeak = _meta.getWeak; 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 var arrayFind = _arrayMethods(5); 6333 var arrayFindIndex = _arrayMethods(6); 6334 var id$1 = 0; // fallback for uncaught frozen keys 6335 6336 var uncaughtFrozenStore = function uncaughtFrozenStore(that) { 6337 return that._l || (that._l = new UncaughtFrozenStore()); 6338 }; 6339 6340 var UncaughtFrozenStore = function UncaughtFrozenStore() { 6341 this.a = []; 6342 }; 6343 6344 var findUncaughtFrozen = function findUncaughtFrozen(store, key) { 6345 return arrayFind(store.a, function (it) { 6346 return it[0] === key; 6347 }); 6348 }; 6349 6350 UncaughtFrozenStore.prototype = { 6351 get: function get(key) { 6352 var entry = findUncaughtFrozen(this, key); 6353 if (entry) return entry[1]; 6354 }, 6355 has: function has(key) { 6356 return !!findUncaughtFrozen(this, key); 6357 }, 6358 set: function set(key, value) { 6359 var entry = findUncaughtFrozen(this, key); 6360 if (entry) entry[1] = value;else this.a.push([key, value]); 6361 }, 6362 'delete': function _delete(key) { 6363 var index = arrayFindIndex(this.a, function (it) { 6364 return it[0] === key; 6365 }); 6366 if (~index) this.a.splice(index, 1); 6367 return !!~index; 6368 } 6369 }; 6370 var _collectionWeak = { 6371 getConstructor: function getConstructor(wrapper, NAME, IS_MAP, ADDER) { 6372 var C = wrapper(function (that, iterable) { 6373 _anInstance(that, C, NAME, '_i'); 6374 that._t = NAME; // collection type 6375 6376 that._i = id$1++; // collection id 6377 6378 that._l = undefined; // leak store for uncaught frozen objects 6379 6380 if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that); 6381 }); 6382 _redefineAll(C.prototype, { 6383 // 23.3.3.2 WeakMap.prototype.delete(key) 6384 // 23.4.3.3 WeakSet.prototype.delete(value) 6385 'delete': function _delete(key) { 6386 if (!_isObject(key)) return false; 6387 var data = getWeak(key); 6388 if (data === true) return uncaughtFrozenStore(_validateCollection(this, NAME))['delete'](key); 6389 return data && _has(data, this._i) && delete data[this._i]; 6390 }, 6391 // 23.3.3.4 WeakMap.prototype.has(key) 6392 // 23.4.3.4 WeakSet.prototype.has(value) 6393 has: function has(key) { 6394 if (!_isObject(key)) return false; 6395 var data = getWeak(key); 6396 if (data === true) return uncaughtFrozenStore(_validateCollection(this, NAME)).has(key); 6397 return data && _has(data, this._i); 6398 } 6399 }); 6400 return C; 6401 }, 6402 def: function def(that, key, value) { 6403 var data = getWeak(_anObject(key), true); 6404 if (data === true) uncaughtFrozenStore(that).set(key, value);else data[that._i] = value; 6405 return that; 6406 }, 6407 ufstore: uncaughtFrozenStore 6408 }; 6409 6410 var es6_weakMap = createCommonjsModule(function (module) { 6411 6412 var each = _arrayMethods(0); 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 var WEAK_MAP = 'WeakMap'; 6429 var getWeak = _meta.getWeak; 6430 var isExtensible = Object.isExtensible; 6431 var uncaughtFrozenStore = _collectionWeak.ufstore; 6432 var tmp = {}; 6433 var InternalMap; 6434 6435 var wrapper = function wrapper(get) { 6436 return function WeakMap() { 6437 return get(this, arguments.length > 0 ? arguments[0] : undefined); 6438 }; 6439 }; 6440 6441 var methods = { 6442 // 23.3.3.3 WeakMap.prototype.get(key) 6443 get: function get(key) { 6444 if (_isObject(key)) { 6445 var data = getWeak(key); 6446 if (data === true) return uncaughtFrozenStore(_validateCollection(this, WEAK_MAP)).get(key); 6447 return data ? data[this._i] : undefined; 6448 } 6449 }, 6450 // 23.3.3.5 WeakMap.prototype.set(key, value) 6451 set: function set(key, value) { 6452 return _collectionWeak.def(_validateCollection(this, WEAK_MAP), key, value); 6453 } 6454 }; // 23.3 WeakMap Objects 6455 6456 var $WeakMap = module.exports = _collection(WEAK_MAP, wrapper, methods, _collectionWeak, true, true); // IE11 WeakMap frozen keys fix 6457 6458 6459 if (_fails(function () { 6460 return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7; 6461 })) { 6462 InternalMap = _collectionWeak.getConstructor(wrapper, WEAK_MAP); 6463 _objectAssign(InternalMap.prototype, methods); 6464 _meta.NEED = true; 6465 each(['delete', 'has', 'get', 'set'], function (key) { 6466 var proto = $WeakMap.prototype; 6467 var method = proto[key]; 6468 _redefine(proto, key, function (a, b) { 6469 // store frozen objects on internal weakmap shim 6470 if (_isObject(a) && !isExtensible(a)) { 6471 if (!this._f) this._f = new InternalMap(); 6472 6473 var result = this._f[key](a, b); 6474 6475 return key == 'set' ? this : result; // store all the rest on native weakmap 6476 } 6477 6478 return method.call(this, a, b); 6479 }); 6480 }); 6481 } 6482 }); 6483 6484 var WEAK_SET = 'WeakSet'; // 23.4 WeakSet Objects 6485 6486 _collection(WEAK_SET, function (get) { 6487 return function WeakSet() { 6488 return get(this, arguments.length > 0 ? arguments[0] : undefined); 6489 }; 6490 }, { 6491 // 23.4.3.1 WeakSet.prototype.add(value) 6492 add: function add(value) { 6493 return _collectionWeak.def(_validateCollection(this, WEAK_SET), value, true); 6494 } 6495 }, _collectionWeak, false, true); 6496 6497 var TYPED = _uid('typed_array'); 6498 var VIEW = _uid('view'); 6499 var ABV = !!(_global.ArrayBuffer && _global.DataView); 6500 var CONSTR = ABV; 6501 var i$1 = 0; 6502 var l = 9; 6503 var Typed; 6504 var TypedArrayConstructors = 'Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array'.split(','); 6505 6506 while (i$1 < l) { 6507 if (Typed = _global[TypedArrayConstructors[i$1++]]) { 6508 _hide(Typed.prototype, TYPED, true); 6509 _hide(Typed.prototype, VIEW, true); 6510 } else CONSTR = false; 6511 } 6512 6513 var _typed = { 6514 ABV: ABV, 6515 CONSTR: CONSTR, 6516 TYPED: TYPED, 6517 VIEW: VIEW 6518 }; 6519 6520 // https://tc39.github.io/ecma262/#sec-toindex 6521 6522 6523 6524 6525 var _toIndex = function (it) { 6526 if (it === undefined) return 0; 6527 var number = _toInteger(it); 6528 var length = _toLength(number); 6529 if (number !== length) throw RangeError('Wrong length!'); 6530 return length; 6531 }; 6532 6533 var _typedBuffer = createCommonjsModule(function (module, exports) { 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 var gOPN = _objectGopn.f; 6558 6559 var dP = _objectDp.f; 6560 6561 6562 6563 6564 6565 var ARRAY_BUFFER = 'ArrayBuffer'; 6566 var DATA_VIEW = 'DataView'; 6567 var PROTOTYPE = 'prototype'; 6568 var WRONG_LENGTH = 'Wrong length!'; 6569 var WRONG_INDEX = 'Wrong index!'; 6570 var $ArrayBuffer = _global[ARRAY_BUFFER]; 6571 var $DataView = _global[DATA_VIEW]; 6572 var Math = _global.Math; 6573 var RangeError = _global.RangeError; // eslint-disable-next-line no-shadow-restricted-names 6574 6575 var Infinity = _global.Infinity; 6576 var BaseBuffer = $ArrayBuffer; 6577 var abs = Math.abs; 6578 var pow = Math.pow; 6579 var floor = Math.floor; 6580 var log = Math.log; 6581 var LN2 = Math.LN2; 6582 var BUFFER = 'buffer'; 6583 var BYTE_LENGTH = 'byteLength'; 6584 var BYTE_OFFSET = 'byteOffset'; 6585 var $BUFFER = _descriptors ? '_b' : BUFFER; 6586 var $LENGTH = _descriptors ? '_l' : BYTE_LENGTH; 6587 var $OFFSET = _descriptors ? '_o' : BYTE_OFFSET; // IEEE754 conversions based on https://github.com/feross/ieee754 6588 6589 function packIEEE754(value, mLen, nBytes) { 6590 var buffer = new Array(nBytes); 6591 var eLen = nBytes * 8 - mLen - 1; 6592 var eMax = (1 << eLen) - 1; 6593 var eBias = eMax >> 1; 6594 var rt = mLen === 23 ? pow(2, -24) - pow(2, -77) : 0; 6595 var i = 0; 6596 var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0; 6597 var e, m, c; 6598 value = abs(value); // eslint-disable-next-line no-self-compare 6599 6600 if (value != value || value === Infinity) { 6601 // eslint-disable-next-line no-self-compare 6602 m = value != value ? 1 : 0; 6603 e = eMax; 6604 } else { 6605 e = floor(log(value) / LN2); 6606 6607 if (value * (c = pow(2, -e)) < 1) { 6608 e--; 6609 c *= 2; 6610 } 6611 6612 if (e + eBias >= 1) { 6613 value += rt / c; 6614 } else { 6615 value += rt * pow(2, 1 - eBias); 6616 } 6617 6618 if (value * c >= 2) { 6619 e++; 6620 c /= 2; 6621 } 6622 6623 if (e + eBias >= eMax) { 6624 m = 0; 6625 e = eMax; 6626 } else if (e + eBias >= 1) { 6627 m = (value * c - 1) * pow(2, mLen); 6628 e = e + eBias; 6629 } else { 6630 m = value * pow(2, eBias - 1) * pow(2, mLen); 6631 e = 0; 6632 } 6633 } 6634 6635 for (; mLen >= 8; buffer[i++] = m & 255, m /= 256, mLen -= 8) { 6636 } 6637 6638 e = e << mLen | m; 6639 eLen += mLen; 6640 6641 for (; eLen > 0; buffer[i++] = e & 255, e /= 256, eLen -= 8) { 6642 } 6643 6644 buffer[--i] |= s * 128; 6645 return buffer; 6646 } 6647 6648 function unpackIEEE754(buffer, mLen, nBytes) { 6649 var eLen = nBytes * 8 - mLen - 1; 6650 var eMax = (1 << eLen) - 1; 6651 var eBias = eMax >> 1; 6652 var nBits = eLen - 7; 6653 var i = nBytes - 1; 6654 var s = buffer[i--]; 6655 var e = s & 127; 6656 var m; 6657 s >>= 7; 6658 6659 for (; nBits > 0; e = e * 256 + buffer[i], i--, nBits -= 8) { 6660 } 6661 6662 m = e & (1 << -nBits) - 1; 6663 e >>= -nBits; 6664 nBits += mLen; 6665 6666 for (; nBits > 0; m = m * 256 + buffer[i], i--, nBits -= 8) { 6667 } 6668 6669 if (e === 0) { 6670 e = 1 - eBias; 6671 } else if (e === eMax) { 6672 return m ? NaN : s ? -Infinity : Infinity; 6673 } else { 6674 m = m + pow(2, mLen); 6675 e = e - eBias; 6676 } 6677 6678 return (s ? -1 : 1) * m * pow(2, e - mLen); 6679 } 6680 6681 function unpackI32(bytes) { 6682 return bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0]; 6683 } 6684 6685 function packI8(it) { 6686 return [it & 0xff]; 6687 } 6688 6689 function packI16(it) { 6690 return [it & 0xff, it >> 8 & 0xff]; 6691 } 6692 6693 function packI32(it) { 6694 return [it & 0xff, it >> 8 & 0xff, it >> 16 & 0xff, it >> 24 & 0xff]; 6695 } 6696 6697 function packF64(it) { 6698 return packIEEE754(it, 52, 8); 6699 } 6700 6701 function packF32(it) { 6702 return packIEEE754(it, 23, 4); 6703 } 6704 6705 function addGetter(C, key, internal) { 6706 dP(C[PROTOTYPE], key, { 6707 get: function get() { 6708 return this[internal]; 6709 } 6710 }); 6711 } 6712 6713 function get(view, bytes, index, isLittleEndian) { 6714 var numIndex = +index; 6715 var intIndex = _toIndex(numIndex); 6716 if (intIndex + bytes > view[$LENGTH]) throw RangeError(WRONG_INDEX); 6717 var store = view[$BUFFER]._b; 6718 var start = intIndex + view[$OFFSET]; 6719 var pack = store.slice(start, start + bytes); 6720 return isLittleEndian ? pack : pack.reverse(); 6721 } 6722 6723 function set(view, bytes, index, conversion, value, isLittleEndian) { 6724 var numIndex = +index; 6725 var intIndex = _toIndex(numIndex); 6726 if (intIndex + bytes > view[$LENGTH]) throw RangeError(WRONG_INDEX); 6727 var store = view[$BUFFER]._b; 6728 var start = intIndex + view[$OFFSET]; 6729 var pack = conversion(+value); 6730 6731 for (var i = 0; i < bytes; i++) { 6732 store[start + i] = pack[isLittleEndian ? i : bytes - i - 1]; 6733 } 6734 } 6735 6736 if (!_typed.ABV) { 6737 $ArrayBuffer = function ArrayBuffer(length) { 6738 _anInstance(this, $ArrayBuffer, ARRAY_BUFFER); 6739 var byteLength = _toIndex(length); 6740 this._b = _arrayFill.call(new Array(byteLength), 0); 6741 this[$LENGTH] = byteLength; 6742 }; 6743 6744 $DataView = function DataView(buffer, byteOffset, byteLength) { 6745 _anInstance(this, $DataView, DATA_VIEW); 6746 _anInstance(buffer, $ArrayBuffer, DATA_VIEW); 6747 var bufferLength = buffer[$LENGTH]; 6748 var offset = _toInteger(byteOffset); 6749 if (offset < 0 || offset > bufferLength) throw RangeError('Wrong offset!'); 6750 byteLength = byteLength === undefined ? bufferLength - offset : _toLength(byteLength); 6751 if (offset + byteLength > bufferLength) throw RangeError(WRONG_LENGTH); 6752 this[$BUFFER] = buffer; 6753 this[$OFFSET] = offset; 6754 this[$LENGTH] = byteLength; 6755 }; 6756 6757 if (_descriptors) { 6758 addGetter($ArrayBuffer, BYTE_LENGTH, '_l'); 6759 addGetter($DataView, BUFFER, '_b'); 6760 addGetter($DataView, BYTE_LENGTH, '_l'); 6761 addGetter($DataView, BYTE_OFFSET, '_o'); 6762 } 6763 6764 _redefineAll($DataView[PROTOTYPE], { 6765 getInt8: function getInt8(byteOffset) { 6766 return get(this, 1, byteOffset)[0] << 24 >> 24; 6767 }, 6768 getUint8: function getUint8(byteOffset) { 6769 return get(this, 1, byteOffset)[0]; 6770 }, 6771 getInt16: function getInt16(byteOffset 6772 /* , littleEndian */ 6773 ) { 6774 var bytes = get(this, 2, byteOffset, arguments[1]); 6775 return (bytes[1] << 8 | bytes[0]) << 16 >> 16; 6776 }, 6777 getUint16: function getUint16(byteOffset 6778 /* , littleEndian */ 6779 ) { 6780 var bytes = get(this, 2, byteOffset, arguments[1]); 6781 return bytes[1] << 8 | bytes[0]; 6782 }, 6783 getInt32: function getInt32(byteOffset 6784 /* , littleEndian */ 6785 ) { 6786 return unpackI32(get(this, 4, byteOffset, arguments[1])); 6787 }, 6788 getUint32: function getUint32(byteOffset 6789 /* , littleEndian */ 6790 ) { 6791 return unpackI32(get(this, 4, byteOffset, arguments[1])) >>> 0; 6792 }, 6793 getFloat32: function getFloat32(byteOffset 6794 /* , littleEndian */ 6795 ) { 6796 return unpackIEEE754(get(this, 4, byteOffset, arguments[1]), 23, 4); 6797 }, 6798 getFloat64: function getFloat64(byteOffset 6799 /* , littleEndian */ 6800 ) { 6801 return unpackIEEE754(get(this, 8, byteOffset, arguments[1]), 52, 8); 6802 }, 6803 setInt8: function setInt8(byteOffset, value) { 6804 set(this, 1, byteOffset, packI8, value); 6805 }, 6806 setUint8: function setUint8(byteOffset, value) { 6807 set(this, 1, byteOffset, packI8, value); 6808 }, 6809 setInt16: function setInt16(byteOffset, value 6810 /* , littleEndian */ 6811 ) { 6812 set(this, 2, byteOffset, packI16, value, arguments[2]); 6813 }, 6814 setUint16: function setUint16(byteOffset, value 6815 /* , littleEndian */ 6816 ) { 6817 set(this, 2, byteOffset, packI16, value, arguments[2]); 6818 }, 6819 setInt32: function setInt32(byteOffset, value 6820 /* , littleEndian */ 6821 ) { 6822 set(this, 4, byteOffset, packI32, value, arguments[2]); 6823 }, 6824 setUint32: function setUint32(byteOffset, value 6825 /* , littleEndian */ 6826 ) { 6827 set(this, 4, byteOffset, packI32, value, arguments[2]); 6828 }, 6829 setFloat32: function setFloat32(byteOffset, value 6830 /* , littleEndian */ 6831 ) { 6832 set(this, 4, byteOffset, packF32, value, arguments[2]); 6833 }, 6834 setFloat64: function setFloat64(byteOffset, value 6835 /* , littleEndian */ 6836 ) { 6837 set(this, 8, byteOffset, packF64, value, arguments[2]); 6838 } 6839 }); 6840 } else { 6841 if (!_fails(function () { 6842 $ArrayBuffer(1); 6843 }) || !_fails(function () { 6844 new $ArrayBuffer(-1); // eslint-disable-line no-new 6845 }) || _fails(function () { 6846 new $ArrayBuffer(); // eslint-disable-line no-new 6847 6848 new $ArrayBuffer(1.5); // eslint-disable-line no-new 6849 6850 new $ArrayBuffer(NaN); // eslint-disable-line no-new 6851 6852 return $ArrayBuffer.name != ARRAY_BUFFER; 6853 })) { 6854 $ArrayBuffer = function ArrayBuffer(length) { 6855 _anInstance(this, $ArrayBuffer); 6856 return new BaseBuffer(_toIndex(length)); 6857 }; 6858 6859 var ArrayBufferProto = $ArrayBuffer[PROTOTYPE] = BaseBuffer[PROTOTYPE]; 6860 6861 for (var keys = gOPN(BaseBuffer), j = 0, key; keys.length > j;) { 6862 if (!((key = keys[j++]) in $ArrayBuffer)) _hide($ArrayBuffer, key, BaseBuffer[key]); 6863 } 6864 6865 ArrayBufferProto.constructor = $ArrayBuffer; 6866 } // iOS Safari 7.x bug 6867 6868 6869 var view = new $DataView(new $ArrayBuffer(2)); 6870 var $setInt8 = $DataView[PROTOTYPE].setInt8; 6871 view.setInt8(0, 2147483648); 6872 view.setInt8(1, 2147483649); 6873 if (view.getInt8(0) || !view.getInt8(1)) _redefineAll($DataView[PROTOTYPE], { 6874 setInt8: function setInt8(byteOffset, value) { 6875 $setInt8.call(this, byteOffset, value << 24 >> 24); 6876 }, 6877 setUint8: function setUint8(byteOffset, value) { 6878 $setInt8.call(this, byteOffset, value << 24 >> 24); 6879 } 6880 }, true); 6881 } 6882 6883 _setToStringTag($ArrayBuffer, ARRAY_BUFFER); 6884 _setToStringTag($DataView, DATA_VIEW); 6885 _hide($DataView[PROTOTYPE], _typed.VIEW, true); 6886 exports[ARRAY_BUFFER] = $ArrayBuffer; 6887 exports[DATA_VIEW] = $DataView; 6888 }); 6889 6890 var ArrayBuffer = _global.ArrayBuffer; 6891 6892 6893 6894 var $ArrayBuffer = _typedBuffer.ArrayBuffer; 6895 var $DataView = _typedBuffer.DataView; 6896 var $isView = _typed.ABV && ArrayBuffer.isView; 6897 var $slice = $ArrayBuffer.prototype.slice; 6898 var VIEW$1 = _typed.VIEW; 6899 var ARRAY_BUFFER = 'ArrayBuffer'; 6900 _export(_export.G + _export.W + _export.F * (ArrayBuffer !== $ArrayBuffer), { 6901 ArrayBuffer: $ArrayBuffer 6902 }); 6903 _export(_export.S + _export.F * !_typed.CONSTR, ARRAY_BUFFER, { 6904 // 24.1.3.1 ArrayBuffer.isView(arg) 6905 isView: function isView(it) { 6906 return $isView && $isView(it) || _isObject(it) && VIEW$1 in it; 6907 } 6908 }); 6909 _export(_export.P + _export.U + _export.F * _fails(function () { 6910 return !new $ArrayBuffer(2).slice(1, undefined).byteLength; 6911 }), ARRAY_BUFFER, { 6912 // 24.1.4.3 ArrayBuffer.prototype.slice(start, end) 6913 slice: function slice(start, end) { 6914 if ($slice !== undefined && end === undefined) return $slice.call(_anObject(this), start); // FF fix 6915 6916 var len = _anObject(this).byteLength; 6917 var first = _toAbsoluteIndex(start, len); 6918 var fin = _toAbsoluteIndex(end === undefined ? len : end, len); 6919 var result = new (_speciesConstructor(this, $ArrayBuffer))(_toLength(fin - first)); 6920 var viewS = new $DataView(this); 6921 var viewT = new $DataView(result); 6922 var index = 0; 6923 6924 while (first < fin) { 6925 viewT.setUint8(index++, viewS.getUint8(first++)); 6926 } 6927 6928 return result; 6929 } 6930 }); 6931 6932 _setSpecies(ARRAY_BUFFER); 6933 6934 _export(_export.G + _export.W + _export.F * !_typed.ABV, { 6935 DataView: _typedBuffer.DataView 6936 }); 6937 6938 var _typedArray = createCommonjsModule(function (module) { 6939 6940 if (_descriptors) { 6941 6942 var global = _global; 6943 6944 var fails = _fails; 6945 6946 var $export = _export; 6947 6948 var $typed = _typed; 6949 6950 var $buffer = _typedBuffer; 6951 6952 var ctx = _ctx; 6953 6954 var anInstance = _anInstance; 6955 6956 var propertyDesc = _propertyDesc; 6957 6958 var hide = _hide; 6959 6960 var redefineAll = _redefineAll; 6961 6962 var toInteger = _toInteger; 6963 6964 var toLength = _toLength; 6965 6966 var toIndex = _toIndex; 6967 6968 var toAbsoluteIndex = _toAbsoluteIndex; 6969 6970 var toPrimitive = _toPrimitive; 6971 6972 var has = _has; 6973 6974 var classof = _classof; 6975 6976 var isObject = _isObject; 6977 6978 var toObject = _toObject; 6979 6980 var isArrayIter = _isArrayIter; 6981 6982 var create = _objectCreate; 6983 6984 var getPrototypeOf = _objectGpo; 6985 6986 var gOPN = _objectGopn.f; 6987 6988 var getIterFn = core_getIteratorMethod; 6989 6990 var uid = _uid; 6991 6992 var wks = _wks; 6993 6994 var createArrayMethod = _arrayMethods; 6995 6996 var createArrayIncludes = _arrayIncludes; 6997 6998 var speciesConstructor = _speciesConstructor; 6999 7000 var ArrayIterators = es6_array_iterator; 7001 7002 var Iterators = _iterators; 7003 7004 var $iterDetect = _iterDetect; 7005 7006 var setSpecies = _setSpecies; 7007 7008 var arrayFill = _arrayFill; 7009 7010 var arrayCopyWithin = _arrayCopyWithin; 7011 7012 var $DP = _objectDp; 7013 7014 var $GOPD = _objectGopd; 7015 7016 var dP = $DP.f; 7017 var gOPD = $GOPD.f; 7018 var RangeError = global.RangeError; 7019 var TypeError = global.TypeError; 7020 var Uint8Array = global.Uint8Array; 7021 var ARRAY_BUFFER = 'ArrayBuffer'; 7022 var SHARED_BUFFER = 'Shared' + ARRAY_BUFFER; 7023 var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT'; 7024 var PROTOTYPE = 'prototype'; 7025 var ArrayProto = Array[PROTOTYPE]; 7026 var $ArrayBuffer = $buffer.ArrayBuffer; 7027 var $DataView = $buffer.DataView; 7028 var arrayForEach = createArrayMethod(0); 7029 var arrayFilter = createArrayMethod(2); 7030 var arraySome = createArrayMethod(3); 7031 var arrayEvery = createArrayMethod(4); 7032 var arrayFind = createArrayMethod(5); 7033 var arrayFindIndex = createArrayMethod(6); 7034 var arrayIncludes = createArrayIncludes(true); 7035 var arrayIndexOf = createArrayIncludes(false); 7036 var arrayValues = ArrayIterators.values; 7037 var arrayKeys = ArrayIterators.keys; 7038 var arrayEntries = ArrayIterators.entries; 7039 var arrayLastIndexOf = ArrayProto.lastIndexOf; 7040 var arrayReduce = ArrayProto.reduce; 7041 var arrayReduceRight = ArrayProto.reduceRight; 7042 var arrayJoin = ArrayProto.join; 7043 var arraySort = ArrayProto.sort; 7044 var arraySlice = ArrayProto.slice; 7045 var arrayToString = ArrayProto.toString; 7046 var arrayToLocaleString = ArrayProto.toLocaleString; 7047 var ITERATOR = wks('iterator'); 7048 var TAG = wks('toStringTag'); 7049 var TYPED_CONSTRUCTOR = uid('typed_constructor'); 7050 var DEF_CONSTRUCTOR = uid('def_constructor'); 7051 var ALL_CONSTRUCTORS = $typed.CONSTR; 7052 var TYPED_ARRAY = $typed.TYPED; 7053 var VIEW = $typed.VIEW; 7054 var WRONG_LENGTH = 'Wrong length!'; 7055 var $map = createArrayMethod(1, function (O, length) { 7056 return allocate(speciesConstructor(O, O[DEF_CONSTRUCTOR]), length); 7057 }); 7058 var LITTLE_ENDIAN = fails(function () { 7059 // eslint-disable-next-line no-undef 7060 return new Uint8Array(new Uint16Array([1]).buffer)[0] === 1; 7061 }); 7062 var FORCED_SET = !!Uint8Array && !!Uint8Array[PROTOTYPE].set && fails(function () { 7063 new Uint8Array(1).set({}); 7064 }); 7065 7066 var toOffset = function toOffset(it, BYTES) { 7067 var offset = toInteger(it); 7068 if (offset < 0 || offset % BYTES) throw RangeError('Wrong offset!'); 7069 return offset; 7070 }; 7071 7072 var validate = function validate(it) { 7073 if (isObject(it) && TYPED_ARRAY in it) return it; 7074 throw TypeError(it + ' is not a typed array!'); 7075 }; 7076 7077 var allocate = function allocate(C, length) { 7078 if (!(isObject(C) && TYPED_CONSTRUCTOR in C)) { 7079 throw TypeError('It is not a typed array constructor!'); 7080 } 7081 7082 return new C(length); 7083 }; 7084 7085 var speciesFromList = function speciesFromList(O, list) { 7086 return fromList(speciesConstructor(O, O[DEF_CONSTRUCTOR]), list); 7087 }; 7088 7089 var fromList = function fromList(C, list) { 7090 var index = 0; 7091 var length = list.length; 7092 var result = allocate(C, length); 7093 7094 while (length > index) { 7095 result[index] = list[index++]; 7096 } 7097 7098 return result; 7099 }; 7100 7101 var addGetter = function addGetter(it, key, internal) { 7102 dP(it, key, { 7103 get: function get() { 7104 return this._d[internal]; 7105 } 7106 }); 7107 }; 7108 7109 var $from = function from(source 7110 /* , mapfn, thisArg */ 7111 ) { 7112 var O = toObject(source); 7113 var aLen = arguments.length; 7114 var mapfn = aLen > 1 ? arguments[1] : undefined; 7115 var mapping = mapfn !== undefined; 7116 var iterFn = getIterFn(O); 7117 var i, length, values, result, step, iterator; 7118 7119 if (iterFn != undefined && !isArrayIter(iterFn)) { 7120 for (iterator = iterFn.call(O), values = [], i = 0; !(step = iterator.next()).done; i++) { 7121 values.push(step.value); 7122 } 7123 7124 O = values; 7125 } 7126 7127 if (mapping && aLen > 2) mapfn = ctx(mapfn, arguments[2], 2); 7128 7129 for (i = 0, length = toLength(O.length), result = allocate(this, length); length > i; i++) { 7130 result[i] = mapping ? mapfn(O[i], i) : O[i]; 7131 } 7132 7133 return result; 7134 }; 7135 7136 var $of = function of() 7137 /* ...items */ 7138 { 7139 var index = 0; 7140 var length = arguments.length; 7141 var result = allocate(this, length); 7142 7143 while (length > index) { 7144 result[index] = arguments[index++]; 7145 } 7146 7147 return result; 7148 }; // iOS Safari 6.x fails here 7149 7150 7151 var TO_LOCALE_BUG = !!Uint8Array && fails(function () { 7152 arrayToLocaleString.call(new Uint8Array(1)); 7153 }); 7154 7155 var $toLocaleString = function toLocaleString() { 7156 return arrayToLocaleString.apply(TO_LOCALE_BUG ? arraySlice.call(validate(this)) : validate(this), arguments); 7157 }; 7158 7159 var proto = { 7160 copyWithin: function copyWithin(target, start 7161 /* , end */ 7162 ) { 7163 return arrayCopyWithin.call(validate(this), target, start, arguments.length > 2 ? arguments[2] : undefined); 7164 }, 7165 every: function every(callbackfn 7166 /* , thisArg */ 7167 ) { 7168 return arrayEvery(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); 7169 }, 7170 fill: function fill(value 7171 /* , start, end */ 7172 ) { 7173 // eslint-disable-line no-unused-vars 7174 return arrayFill.apply(validate(this), arguments); 7175 }, 7176 filter: function filter(callbackfn 7177 /* , thisArg */ 7178 ) { 7179 return speciesFromList(this, arrayFilter(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined)); 7180 }, 7181 find: function find(predicate 7182 /* , thisArg */ 7183 ) { 7184 return arrayFind(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined); 7185 }, 7186 findIndex: function findIndex(predicate 7187 /* , thisArg */ 7188 ) { 7189 return arrayFindIndex(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined); 7190 }, 7191 forEach: function forEach(callbackfn 7192 /* , thisArg */ 7193 ) { 7194 arrayForEach(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); 7195 }, 7196 indexOf: function indexOf(searchElement 7197 /* , fromIndex */ 7198 ) { 7199 return arrayIndexOf(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined); 7200 }, 7201 includes: function includes(searchElement 7202 /* , fromIndex */ 7203 ) { 7204 return arrayIncludes(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined); 7205 }, 7206 join: function join(separator) { 7207 // eslint-disable-line no-unused-vars 7208 return arrayJoin.apply(validate(this), arguments); 7209 }, 7210 lastIndexOf: function lastIndexOf(searchElement 7211 /* , fromIndex */ 7212 ) { 7213 // eslint-disable-line no-unused-vars 7214 return arrayLastIndexOf.apply(validate(this), arguments); 7215 }, 7216 map: function map(mapfn 7217 /* , thisArg */ 7218 ) { 7219 return $map(validate(this), mapfn, arguments.length > 1 ? arguments[1] : undefined); 7220 }, 7221 reduce: function reduce(callbackfn 7222 /* , initialValue */ 7223 ) { 7224 // eslint-disable-line no-unused-vars 7225 return arrayReduce.apply(validate(this), arguments); 7226 }, 7227 reduceRight: function reduceRight(callbackfn 7228 /* , initialValue */ 7229 ) { 7230 // eslint-disable-line no-unused-vars 7231 return arrayReduceRight.apply(validate(this), arguments); 7232 }, 7233 reverse: function reverse() { 7234 var that = this; 7235 var length = validate(that).length; 7236 var middle = Math.floor(length / 2); 7237 var index = 0; 7238 var value; 7239 7240 while (index < middle) { 7241 value = that[index]; 7242 that[index++] = that[--length]; 7243 that[length] = value; 7244 } 7245 7246 return that; 7247 }, 7248 some: function some(callbackfn 7249 /* , thisArg */ 7250 ) { 7251 return arraySome(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); 7252 }, 7253 sort: function sort(comparefn) { 7254 return arraySort.call(validate(this), comparefn); 7255 }, 7256 subarray: function subarray(begin, end) { 7257 var O = validate(this); 7258 var length = O.length; 7259 var $begin = toAbsoluteIndex(begin, length); 7260 return new (speciesConstructor(O, O[DEF_CONSTRUCTOR]))(O.buffer, O.byteOffset + $begin * O.BYTES_PER_ELEMENT, toLength((end === undefined ? length : toAbsoluteIndex(end, length)) - $begin)); 7261 } 7262 }; 7263 7264 var $slice = function slice(start, end) { 7265 return speciesFromList(this, arraySlice.call(validate(this), start, end)); 7266 }; 7267 7268 var $set = function set(arrayLike 7269 /* , offset */ 7270 ) { 7271 validate(this); 7272 var offset = toOffset(arguments[1], 1); 7273 var length = this.length; 7274 var src = toObject(arrayLike); 7275 var len = toLength(src.length); 7276 var index = 0; 7277 if (len + offset > length) throw RangeError(WRONG_LENGTH); 7278 7279 while (index < len) { 7280 this[offset + index] = src[index++]; 7281 } 7282 }; 7283 7284 var $iterators = { 7285 entries: function entries() { 7286 return arrayEntries.call(validate(this)); 7287 }, 7288 keys: function keys() { 7289 return arrayKeys.call(validate(this)); 7290 }, 7291 values: function values() { 7292 return arrayValues.call(validate(this)); 7293 } 7294 }; 7295 7296 var isTAIndex = function isTAIndex(target, key) { 7297 return isObject(target) && target[TYPED_ARRAY] && babelHelpers.typeof(key) != 'symbol' && key in target && String(+key) == String(key); 7298 }; 7299 7300 var $getDesc = function getOwnPropertyDescriptor(target, key) { 7301 return isTAIndex(target, key = toPrimitive(key, true)) ? propertyDesc(2, target[key]) : gOPD(target, key); 7302 }; 7303 7304 var $setDesc = function defineProperty(target, key, desc) { 7305 if (isTAIndex(target, key = toPrimitive(key, true)) && isObject(desc) && has(desc, 'value') && !has(desc, 'get') && !has(desc, 'set') // TODO: add validation descriptor w/o calling accessors 7306 && !desc.configurable && (!has(desc, 'writable') || desc.writable) && (!has(desc, 'enumerable') || desc.enumerable)) { 7307 target[key] = desc.value; 7308 return target; 7309 } 7310 7311 return dP(target, key, desc); 7312 }; 7313 7314 if (!ALL_CONSTRUCTORS) { 7315 $GOPD.f = $getDesc; 7316 $DP.f = $setDesc; 7317 } 7318 7319 $export($export.S + $export.F * !ALL_CONSTRUCTORS, 'Object', { 7320 getOwnPropertyDescriptor: $getDesc, 7321 defineProperty: $setDesc 7322 }); 7323 7324 if (fails(function () { 7325 arrayToString.call({}); 7326 })) { 7327 arrayToString = arrayToLocaleString = function toString() { 7328 return arrayJoin.call(this); 7329 }; 7330 } 7331 7332 var $TypedArrayPrototype$ = redefineAll({}, proto); 7333 redefineAll($TypedArrayPrototype$, $iterators); 7334 hide($TypedArrayPrototype$, ITERATOR, $iterators.values); 7335 redefineAll($TypedArrayPrototype$, { 7336 slice: $slice, 7337 set: $set, 7338 constructor: function constructor() { 7339 /* noop */ 7340 }, 7341 toString: arrayToString, 7342 toLocaleString: $toLocaleString 7343 }); 7344 addGetter($TypedArrayPrototype$, 'buffer', 'b'); 7345 addGetter($TypedArrayPrototype$, 'byteOffset', 'o'); 7346 addGetter($TypedArrayPrototype$, 'byteLength', 'l'); 7347 addGetter($TypedArrayPrototype$, 'length', 'e'); 7348 dP($TypedArrayPrototype$, TAG, { 7349 get: function get() { 7350 return this[TYPED_ARRAY]; 7351 } 7352 }); // eslint-disable-next-line max-statements 7353 7354 module.exports = function (KEY, BYTES, wrapper, CLAMPED) { 7355 CLAMPED = !!CLAMPED; 7356 var NAME = KEY + (CLAMPED ? 'Clamped' : '') + 'Array'; 7357 var GETTER = 'get' + KEY; 7358 var SETTER = 'set' + KEY; 7359 var TypedArray = global[NAME]; 7360 var Base = TypedArray || {}; 7361 var TAC = TypedArray && getPrototypeOf(TypedArray); 7362 var FORCED = !TypedArray || !$typed.ABV; 7363 var O = {}; 7364 var TypedArrayPrototype = TypedArray && TypedArray[PROTOTYPE]; 7365 7366 var getter = function getter(that, index) { 7367 var data = that._d; 7368 return data.v[GETTER](index * BYTES + data.o, LITTLE_ENDIAN); 7369 }; 7370 7371 var setter = function setter(that, index, value) { 7372 var data = that._d; 7373 if (CLAMPED) value = (value = Math.round(value)) < 0 ? 0 : value > 0xff ? 0xff : value & 0xff; 7374 data.v[SETTER](index * BYTES + data.o, value, LITTLE_ENDIAN); 7375 }; 7376 7377 var addElement = function addElement(that, index) { 7378 dP(that, index, { 7379 get: function get() { 7380 return getter(this, index); 7381 }, 7382 set: function set(value) { 7383 return setter(this, index, value); 7384 }, 7385 enumerable: true 7386 }); 7387 }; 7388 7389 if (FORCED) { 7390 TypedArray = wrapper(function (that, data, $offset, $length) { 7391 anInstance(that, TypedArray, NAME, '_d'); 7392 var index = 0; 7393 var offset = 0; 7394 var buffer, byteLength, length, klass; 7395 7396 if (!isObject(data)) { 7397 length = toIndex(data); 7398 byteLength = length * BYTES; 7399 buffer = new $ArrayBuffer(byteLength); 7400 } else if (data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER) { 7401 buffer = data; 7402 offset = toOffset($offset, BYTES); 7403 var $len = data.byteLength; 7404 7405 if ($length === undefined) { 7406 if ($len % BYTES) throw RangeError(WRONG_LENGTH); 7407 byteLength = $len - offset; 7408 if (byteLength < 0) throw RangeError(WRONG_LENGTH); 7409 } else { 7410 byteLength = toLength($length) * BYTES; 7411 if (byteLength + offset > $len) throw RangeError(WRONG_LENGTH); 7412 } 7413 7414 length = byteLength / BYTES; 7415 } else if (TYPED_ARRAY in data) { 7416 return fromList(TypedArray, data); 7417 } else { 7418 return $from.call(TypedArray, data); 7419 } 7420 7421 hide(that, '_d', { 7422 b: buffer, 7423 o: offset, 7424 l: byteLength, 7425 e: length, 7426 v: new $DataView(buffer) 7427 }); 7428 7429 while (index < length) { 7430 addElement(that, index++); 7431 } 7432 }); 7433 TypedArrayPrototype = TypedArray[PROTOTYPE] = create($TypedArrayPrototype$); 7434 hide(TypedArrayPrototype, 'constructor', TypedArray); 7435 } else if (!fails(function () { 7436 TypedArray(1); 7437 }) || !fails(function () { 7438 new TypedArray(-1); // eslint-disable-line no-new 7439 }) || !$iterDetect(function (iter) { 7440 new TypedArray(); // eslint-disable-line no-new 7441 7442 new TypedArray(null); // eslint-disable-line no-new 7443 7444 new TypedArray(1.5); // eslint-disable-line no-new 7445 7446 new TypedArray(iter); // eslint-disable-line no-new 7447 }, true)) { 7448 TypedArray = wrapper(function (that, data, $offset, $length) { 7449 anInstance(that, TypedArray, NAME); 7450 var klass; // `ws` module bug, temporarily remove validation length for Uint8Array 7451 // https://github.com/websockets/ws/pull/645 7452 7453 if (!isObject(data)) return new Base(toIndex(data)); 7454 7455 if (data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER) { 7456 return $length !== undefined ? new Base(data, toOffset($offset, BYTES), $length) : $offset !== undefined ? new Base(data, toOffset($offset, BYTES)) : new Base(data); 7457 } 7458 7459 if (TYPED_ARRAY in data) return fromList(TypedArray, data); 7460 return $from.call(TypedArray, data); 7461 }); 7462 arrayForEach(TAC !== Function.prototype ? gOPN(Base).concat(gOPN(TAC)) : gOPN(Base), function (key) { 7463 if (!(key in TypedArray)) hide(TypedArray, key, Base[key]); 7464 }); 7465 TypedArray[PROTOTYPE] = TypedArrayPrototype; 7466 TypedArrayPrototype.constructor = TypedArray; 7467 } 7468 7469 var $nativeIterator = TypedArrayPrototype[ITERATOR]; 7470 var CORRECT_ITER_NAME = !!$nativeIterator && ($nativeIterator.name == 'values' || $nativeIterator.name == undefined); 7471 var $iterator = $iterators.values; 7472 hide(TypedArray, TYPED_CONSTRUCTOR, true); 7473 hide(TypedArrayPrototype, TYPED_ARRAY, NAME); 7474 hide(TypedArrayPrototype, VIEW, true); 7475 hide(TypedArrayPrototype, DEF_CONSTRUCTOR, TypedArray); 7476 7477 if (CLAMPED ? new TypedArray(1)[TAG] != NAME : !(TAG in TypedArrayPrototype)) { 7478 dP(TypedArrayPrototype, TAG, { 7479 get: function get() { 7480 return NAME; 7481 } 7482 }); 7483 } 7484 7485 O[NAME] = TypedArray; 7486 $export($export.G + $export.W + $export.F * (TypedArray != Base), O); 7487 $export($export.S, NAME, { 7488 BYTES_PER_ELEMENT: BYTES 7489 }); 7490 $export($export.S + $export.F * fails(function () { 7491 Base.of.call(TypedArray, 1); 7492 }), NAME, { 7493 from: $from, 7494 of: $of 7495 }); 7496 if (!(BYTES_PER_ELEMENT in TypedArrayPrototype)) hide(TypedArrayPrototype, BYTES_PER_ELEMENT, BYTES); 7497 $export($export.P, NAME, proto); 7498 setSpecies(NAME); 7499 $export($export.P + $export.F * FORCED_SET, NAME, { 7500 set: $set 7501 }); 7502 $export($export.P + $export.F * !CORRECT_ITER_NAME, NAME, $iterators); 7503 if (TypedArrayPrototype.toString != arrayToString) TypedArrayPrototype.toString = arrayToString; 7504 $export($export.P + $export.F * fails(function () { 7505 new TypedArray(1).slice(); 7506 }), NAME, { 7507 slice: $slice 7508 }); 7509 $export($export.P + $export.F * (fails(function () { 7510 return [1, 2].toLocaleString() != new TypedArray([1, 2]).toLocaleString(); 7511 }) || !fails(function () { 7512 TypedArrayPrototype.toLocaleString.call([1, 2]); 7513 })), NAME, { 7514 toLocaleString: $toLocaleString 7515 }); 7516 Iterators[NAME] = CORRECT_ITER_NAME ? $nativeIterator : $iterator; 7517 if (!CORRECT_ITER_NAME) hide(TypedArrayPrototype, ITERATOR, $iterator); 7518 }; 7519 } else module.exports = function () { 7520 /* empty */ 7521 }; 7522 }); 7523 7524 _typedArray('Int8', 1, function (init) { 7525 return function Int8Array(data, byteOffset, length) { 7526 return init(this, data, byteOffset, length); 7527 }; 7528 }); 7529 7530 _typedArray('Uint8', 1, function (init) { 7531 return function Uint8Array(data, byteOffset, length) { 7532 return init(this, data, byteOffset, length); 7533 }; 7534 }); 7535 7536 _typedArray('Uint8', 1, function (init) { 7537 return function Uint8ClampedArray(data, byteOffset, length) { 7538 return init(this, data, byteOffset, length); 7539 }; 7540 }, true); 7541 7542 _typedArray('Int16', 2, function (init) { 7543 return function Int16Array(data, byteOffset, length) { 7544 return init(this, data, byteOffset, length); 7545 }; 7546 }); 7547 7548 _typedArray('Uint16', 2, function (init) { 7549 return function Uint16Array(data, byteOffset, length) { 7550 return init(this, data, byteOffset, length); 7551 }; 7552 }); 7553 7554 _typedArray('Int32', 4, function (init) { 7555 return function Int32Array(data, byteOffset, length) { 7556 return init(this, data, byteOffset, length); 7557 }; 7558 }); 7559 7560 _typedArray('Uint32', 4, function (init) { 7561 return function Uint32Array(data, byteOffset, length) { 7562 return init(this, data, byteOffset, length); 7563 }; 7564 }); 7565 7566 _typedArray('Float32', 4, function (init) { 7567 return function Float32Array(data, byteOffset, length) { 7568 return init(this, data, byteOffset, length); 7569 }; 7570 }); 7571 7572 _typedArray('Float64', 8, function (init) { 7573 return function Float64Array(data, byteOffset, length) { 7574 return init(this, data, byteOffset, length); 7575 }; 7576 }); 7577 7578 // 26.1.1 Reflect.apply(target, thisArgument, argumentsList) 7579 7580 7581 7582 7583 7584 7585 var rApply = (_global.Reflect || {}).apply; 7586 var fApply = Function.apply; // MS Edge argumentsList argument is optional 7587 7588 _export(_export.S + _export.F * !_fails(function () { 7589 rApply(function () { 7590 /* empty */ 7591 }); 7592 }), 'Reflect', { 7593 apply: function apply(target, thisArgument, argumentsList) { 7594 var T = _aFunction(target); 7595 var L = _anObject(argumentsList); 7596 return rApply ? rApply(T, thisArgument, L) : fApply.call(T, thisArgument, L); 7597 } 7598 }); 7599 7600 // 26.1.2 Reflect.construct(target, argumentsList [, newTarget]) 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 var rConstruct = (_global.Reflect || {}).construct; // MS Edge supports only 2 arguments and argumentsList argument is optional 7616 // FF Nightly sets third argument as `new.target`, but does not create `this` from it 7617 7618 var NEW_TARGET_BUG = _fails(function () { 7619 function F() { 7620 /* empty */ 7621 } 7622 7623 return !(rConstruct(function () { 7624 /* empty */ 7625 }, [], F) instanceof F); 7626 }); 7627 var ARGS_BUG = !_fails(function () { 7628 rConstruct(function () { 7629 /* empty */ 7630 }); 7631 }); 7632 _export(_export.S + _export.F * (NEW_TARGET_BUG || ARGS_BUG), 'Reflect', { 7633 construct: function construct(Target, args 7634 /* , newTarget */ 7635 ) { 7636 _aFunction(Target); 7637 _anObject(args); 7638 var newTarget = arguments.length < 3 ? Target : _aFunction(arguments[2]); 7639 if (ARGS_BUG && !NEW_TARGET_BUG) return rConstruct(Target, args, newTarget); 7640 7641 if (Target == newTarget) { 7642 // w/o altered newTarget, optimization for 0-4 arguments 7643 switch (args.length) { 7644 case 0: 7645 return new Target(); 7646 7647 case 1: 7648 return new Target(args[0]); 7649 7650 case 2: 7651 return new Target(args[0], args[1]); 7652 7653 case 3: 7654 return new Target(args[0], args[1], args[2]); 7655 7656 case 4: 7657 return new Target(args[0], args[1], args[2], args[3]); 7658 } // w/o altered newTarget, lot of arguments case 7659 7660 7661 var $args = [null]; 7662 $args.push.apply($args, args); 7663 return new (_bind.apply(Target, $args))(); 7664 } // with altered newTarget, not support built-in constructors 7665 7666 7667 var proto = newTarget.prototype; 7668 var instance = _objectCreate(_isObject(proto) ? proto : Object.prototype); 7669 var result = Function.apply.call(Target, instance, args); 7670 return _isObject(result) ? result : instance; 7671 } 7672 }); 7673 7674 // 26.1.3 Reflect.defineProperty(target, propertyKey, attributes) 7675 7676 7677 7678 7679 7680 7681 // MS Edge has broken Reflect.defineProperty - throwing instead of returning false 7682 7683 7684 _export(_export.S + _export.F * _fails(function () { 7685 // eslint-disable-next-line no-undef 7686 Reflect.defineProperty(_objectDp.f({}, 1, { 7687 value: 1 7688 }), 1, { 7689 value: 2 7690 }); 7691 }), 'Reflect', { 7692 defineProperty: function defineProperty(target, propertyKey, attributes) { 7693 _anObject(target); 7694 propertyKey = _toPrimitive(propertyKey, true); 7695 _anObject(attributes); 7696 7697 try { 7698 _objectDp.f(target, propertyKey, attributes); 7699 return true; 7700 } catch (e) { 7701 return false; 7702 } 7703 } 7704 }); 7705 7706 // 26.1.4 Reflect.deleteProperty(target, propertyKey) 7707 7708 7709 var gOPD$3 = _objectGopd.f; 7710 7711 7712 7713 _export(_export.S, 'Reflect', { 7714 deleteProperty: function deleteProperty(target, propertyKey) { 7715 var desc = gOPD$3(_anObject(target), propertyKey); 7716 return desc && !desc.configurable ? false : delete target[propertyKey]; 7717 } 7718 }); 7719 7720 var Enumerate = function Enumerate(iterated) { 7721 this._t = _anObject(iterated); // target 7722 7723 this._i = 0; // next index 7724 7725 var keys = this._k = []; // keys 7726 7727 var key; 7728 7729 for (key in iterated) { 7730 keys.push(key); 7731 } 7732 }; 7733 7734 _iterCreate(Enumerate, 'Object', function () { 7735 var that = this; 7736 var keys = that._k; 7737 var key; 7738 7739 do { 7740 if (that._i >= keys.length) return { 7741 value: undefined, 7742 done: true 7743 }; 7744 } while (!((key = keys[that._i++]) in that._t)); 7745 7746 return { 7747 value: key, 7748 done: false 7749 }; 7750 }); 7751 7752 _export(_export.S, 'Reflect', { 7753 enumerate: function enumerate(target) { 7754 return new Enumerate(target); 7755 } 7756 }); 7757 7758 // 26.1.6 Reflect.get(target, propertyKey [, receiver]) 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 function get(target, propertyKey 7772 /* , receiver */ 7773 ) { 7774 var receiver = arguments.length < 3 ? target : arguments[2]; 7775 var desc, proto; 7776 if (_anObject(target) === receiver) return target[propertyKey]; 7777 if (desc = _objectGopd.f(target, propertyKey)) return _has(desc, 'value') ? desc.value : desc.get !== undefined ? desc.get.call(receiver) : undefined; 7778 if (_isObject(proto = _objectGpo(target))) return get(proto, propertyKey, receiver); 7779 } 7780 7781 _export(_export.S, 'Reflect', { 7782 get: get 7783 }); 7784 7785 // 26.1.7 Reflect.getOwnPropertyDescriptor(target, propertyKey) 7786 7787 7788 7789 7790 7791 7792 _export(_export.S, 'Reflect', { 7793 getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey) { 7794 return _objectGopd.f(_anObject(target), propertyKey); 7795 } 7796 }); 7797 7798 // 26.1.8 Reflect.getPrototypeOf(target) 7799 7800 7801 7802 7803 7804 7805 _export(_export.S, 'Reflect', { 7806 getPrototypeOf: function getPrototypeOf(target) { 7807 return _objectGpo(_anObject(target)); 7808 } 7809 }); 7810 7811 // 26.1.9 Reflect.has(target, propertyKey) 7812 7813 7814 _export(_export.S, 'Reflect', { 7815 has: function has(target, propertyKey) { 7816 return propertyKey in target; 7817 } 7818 }); 7819 7820 // 26.1.10 Reflect.isExtensible(target) 7821 7822 7823 7824 7825 var $isExtensible = Object.isExtensible; 7826 _export(_export.S, 'Reflect', { 7827 isExtensible: function isExtensible(target) { 7828 _anObject(target); 7829 return $isExtensible ? $isExtensible(target) : true; 7830 } 7831 }); 7832 7833 // all object keys, includes non-enumerable and symbols 7834 7835 7836 7837 7838 7839 7840 var Reflect$1 = _global.Reflect; 7841 7842 var _ownKeys = Reflect$1 && Reflect$1.ownKeys || function ownKeys(it) { 7843 var keys = _objectGopn.f(_anObject(it)); 7844 var getSymbols = _objectGops.f; 7845 return getSymbols ? keys.concat(getSymbols(it)) : keys; 7846 }; 7847 7848 // 26.1.11 Reflect.ownKeys(target) 7849 7850 7851 _export(_export.S, 'Reflect', { 7852 ownKeys: _ownKeys 7853 }); 7854 7855 // 26.1.12 Reflect.preventExtensions(target) 7856 7857 7858 7859 7860 var $preventExtensions = Object.preventExtensions; 7861 _export(_export.S, 'Reflect', { 7862 preventExtensions: function preventExtensions(target) { 7863 _anObject(target); 7864 7865 try { 7866 if ($preventExtensions) $preventExtensions(target); 7867 return true; 7868 } catch (e) { 7869 return false;
vendor: 17,344 bytes, lines 7870-8568
7870 } 7871 } 7872 }); 7873 7874 // 26.1.13 Reflect.set(target, propertyKey, V [, receiver]) 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 function set(target, propertyKey, V 7892 /* , receiver */ 7893 ) { 7894 var receiver = arguments.length < 4 ? target : arguments[3]; 7895 var ownDesc = _objectGopd.f(_anObject(target), propertyKey); 7896 var existingDescriptor, proto; 7897 7898 if (!ownDesc) { 7899 if (_isObject(proto = _objectGpo(target))) { 7900 return set(proto, propertyKey, V, receiver); 7901 } 7902 7903 ownDesc = _propertyDesc(0); 7904 } 7905 7906 if (_has(ownDesc, 'value')) { 7907 if (ownDesc.writable === false || !_isObject(receiver)) return false; 7908 7909 if (existingDescriptor = _objectGopd.f(receiver, propertyKey)) { 7910 if (existingDescriptor.get || existingDescriptor.set || existingDescriptor.writable === false) return false; 7911 existingDescriptor.value = V; 7912 _objectDp.f(receiver, propertyKey, existingDescriptor); 7913 } else _objectDp.f(receiver, propertyKey, _propertyDesc(0, V)); 7914 7915 return true; 7916 } 7917 7918 return ownDesc.set === undefined ? false : (ownDesc.set.call(receiver, V), true); 7919 } 7920 7921 _export(_export.S, 'Reflect', { 7922 set: set 7923 }); 7924 7925 // 26.1.14 Reflect.setPrototypeOf(target, proto) 7926 7927 7928 7929 7930 if (_setProto) _export(_export.S, 'Reflect', { 7931 setPrototypeOf: function setPrototypeOf(target, proto) { 7932 _setProto.check(target, proto); 7933 7934 try { 7935 _setProto.set(target, proto); 7936 return true; 7937 } catch (e) { 7938 return false; 7939 } 7940 } 7941 }); 7942 7943 var $includes = _arrayIncludes(true); 7944 7945 _export(_export.P, 'Array', { 7946 includes: function includes(el 7947 /* , fromIndex = 0 */ 7948 ) { 7949 return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined); 7950 } 7951 }); 7952 7953 _addToUnscopables('includes'); 7954 7955 var IS_CONCAT_SPREADABLE = _wks('isConcatSpreadable'); 7956 7957 function flattenIntoArray(target, original, source, sourceLen, start, depth, mapper, thisArg) { 7958 var targetIndex = start; 7959 var sourceIndex = 0; 7960 var mapFn = mapper ? _ctx(mapper, thisArg, 3) : false; 7961 var element, spreadable; 7962 7963 while (sourceIndex < sourceLen) { 7964 if (sourceIndex in source) { 7965 element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex]; 7966 spreadable = false; 7967 7968 if (_isObject(element)) { 7969 spreadable = element[IS_CONCAT_SPREADABLE]; 7970 spreadable = spreadable !== undefined ? !!spreadable : _isArray(element); 7971 } 7972 7973 if (spreadable && depth > 0) { 7974 targetIndex = flattenIntoArray(target, original, element, _toLength(element.length), targetIndex, depth - 1) - 1; 7975 } else { 7976 if (targetIndex >= 0x1fffffffffffff) throw TypeError(); 7977 target[targetIndex] = element; 7978 } 7979 7980 targetIndex++; 7981 } 7982 7983 sourceIndex++; 7984 } 7985 7986 return targetIndex; 7987 } 7988 7989 var _flattenIntoArray = flattenIntoArray; 7990 7991 _export(_export.P, 'Array', { 7992 flatMap: function flatMap(callbackfn 7993 /* , thisArg */ 7994 ) { 7995 var O = _toObject(this); 7996 var sourceLen, A; 7997 _aFunction(callbackfn); 7998 sourceLen = _toLength(O.length); 7999 A = _arraySpeciesCreate(O, 0); 8000 _flattenIntoArray(A, O, O, sourceLen, 0, 1, callbackfn, arguments[1]); 8001 return A; 8002 } 8003 }); 8004 8005 _addToUnscopables('flatMap'); 8006 8007 _export(_export.P, 'Array', { 8008 flatten: function flatten() 8009 /* depthArg = 1 */ 8010 { 8011 var depthArg = arguments[0]; 8012 var O = _toObject(this); 8013 var sourceLen = _toLength(O.length); 8014 var A = _arraySpeciesCreate(O, 0); 8015 _flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : _toInteger(depthArg)); 8016 return A; 8017 } 8018 }); 8019 8020 _addToUnscopables('flatten'); 8021 8022 var $at$2 = _stringAt(true); 8023 8024 _export(_export.P, 'String', { 8025 at: function at(pos) { 8026 return $at$2(this, pos); 8027 } 8028 }); 8029 8030 // https://github.com/tc39/proposal-string-pad-start-end 8031 8032 8033 8034 8035 8036 8037 var _stringPad = function (that, maxLength, fillString, left) { 8038 var S = String(_defined(that)); 8039 var stringLength = S.length; 8040 var fillStr = fillString === undefined ? ' ' : String(fillString); 8041 var intMaxLength = _toLength(maxLength); 8042 if (intMaxLength <= stringLength || fillStr == '') return S; 8043 var fillLen = intMaxLength - stringLength; 8044 var stringFiller = _stringRepeat.call(fillStr, Math.ceil(fillLen / fillStr.length)); 8045 if (stringFiller.length > fillLen) stringFiller = stringFiller.slice(0, fillLen); 8046 return left ? stringFiller + S : S + stringFiller; 8047 }; 8048 8049 // https://github.com/zloirock/core-js/issues/280 8050 8051 8052 _export(_export.P + _export.F * /Version\/10\.\d+(\.\d+)? Safari\//.test(_userAgent), 'String', { 8053 padStart: function padStart(maxLength 8054 /* , fillString = ' ' */ 8055 ) { 8056 return _stringPad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, true); 8057 } 8058 }); 8059 8060 // https://github.com/zloirock/core-js/issues/280 8061 8062 8063 _export(_export.P + _export.F * /Version\/10\.\d+(\.\d+)? Safari\//.test(_userAgent), 'String', { 8064 padEnd: function padEnd(maxLength 8065 /* , fillString = ' ' */ 8066 ) { 8067 return _stringPad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, false); 8068 } 8069 }); 8070 8071 _stringTrim('trimLeft', function ($trim) { 8072 return function trimLeft() { 8073 return $trim(this, 1); 8074 }; 8075 }, 'trimStart'); 8076 8077 _stringTrim('trimRight', function ($trim) { 8078 return function trimRight() { 8079 return $trim(this, 2); 8080 }; 8081 }, 'trimEnd'); 8082 8083 var RegExpProto = RegExp.prototype; 8084 8085 var $RegExpStringIterator = function $RegExpStringIterator(regexp, string) { 8086 this._r = regexp; 8087 this._s = string; 8088 }; 8089 8090 _iterCreate($RegExpStringIterator, 'RegExp String', function next() { 8091 var match = this._r.exec(this._s); 8092 8093 return { 8094 value: match, 8095 done: match === null 8096 }; 8097 }); 8098 8099 _export(_export.P, 'String', { 8100 matchAll: function matchAll(regexp) { 8101 _defined(this); 8102 if (!_isRegexp(regexp)) throw TypeError(regexp + ' is not a regexp!'); 8103 var S = String(this); 8104 var flags = 'flags' in RegExpProto ? String(regexp.flags) : _flags.call(regexp); 8105 var rx = new RegExp(regexp.source, ~flags.indexOf('g') ? flags : 'g' + flags); 8106 rx.lastIndex = _toLength(regexp.lastIndex); 8107 return new $RegExpStringIterator(rx, S); 8108 } 8109 }); 8110 8111 _wksDefine('asyncIterator'); 8112 8113 _wksDefine('observable'); 8114 8115 // https://github.com/tc39/proposal-object-getownpropertydescriptors 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 _export(_export.S, 'Object', { 8127 getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) { 8128 var O = _toIobject(object); 8129 var getDesc = _objectGopd.f; 8130 var keys = _ownKeys(O); 8131 var result = {}; 8132 var i = 0; 8133 var key, desc; 8134 8135 while (keys.length > i) { 8136 desc = getDesc(O, key = keys[i++]); 8137 if (desc !== undefined) _createProperty(result, key, desc); 8138 } 8139 8140 return result; 8141 } 8142 }); 8143 8144 var isEnum$1 = _objectPie.f; 8145 8146 var _objectToArray = function (isEntries) { 8147 return function (it) { 8148 var O = _toIobject(it); 8149 var keys = _objectKeys(O); 8150 var length = keys.length; 8151 var i = 0; 8152 var result = []; 8153 var key; 8154 8155 while (length > i) { 8156 if (isEnum$1.call(O, key = keys[i++])) { 8157 result.push(isEntries ? [key, O[key]] : O[key]); 8158 } 8159 } 8160 8161 return result; 8162 }; 8163 }; 8164 8165 // https://github.com/tc39/proposal-object-values-entries 8166 8167 8168 var $values = _objectToArray(false); 8169 8170 _export(_export.S, 'Object', { 8171 values: function values(it) { 8172 return $values(it); 8173 } 8174 }); 8175 8176 // https://github.com/tc39/proposal-object-values-entries 8177 8178 8179 var $entries = _objectToArray(true); 8180 8181 _export(_export.S, 'Object', { 8182 entries: function entries(it) { 8183 return $entries(it); 8184 } 8185 }); 8186 8187 var _objectForcedPam = !_fails(function () { 8188 var K = Math.random(); // In FF throws only define methods 8189 // eslint-disable-next-line no-undef, no-useless-call 8190 8191 __defineSetter__.call(null, K, function () { 8192 /* empty */ 8193 }); 8194 8195 delete _global[K]; 8196 }); 8197 8198 // B.2.2.2 Object.prototype.__defineGetter__(P, getter) 8199 8200 8201 _descriptors && _export(_export.P + _objectForcedPam, 'Object', { 8202 __defineGetter__: function __defineGetter__(P, getter) { 8203 _objectDp.f(_toObject(this), P, { 8204 get: _aFunction(getter), 8205 enumerable: true, 8206 configurable: true 8207 }); 8208 } 8209 }); 8210 8211 // B.2.2.3 Object.prototype.__defineSetter__(P, setter) 8212 8213 8214 _descriptors && _export(_export.P + _objectForcedPam, 'Object', { 8215 __defineSetter__: function __defineSetter__(P, setter) { 8216 _objectDp.f(_toObject(this), P, { 8217 set: _aFunction(setter), 8218 enumerable: true, 8219 configurable: true 8220 }); 8221 } 8222 }); 8223 8224 var getOwnPropertyDescriptor = _objectGopd.f; // B.2.2.4 Object.prototype.__lookupGetter__(P) 8225 8226 8227 _descriptors && _export(_export.P + _objectForcedPam, 'Object', { 8228 __lookupGetter__: function __lookupGetter__(P) { 8229 var O = _toObject(this); 8230 var K = _toPrimitive(P, true); 8231 var D; 8232 8233 do { 8234 if (D = getOwnPropertyDescriptor(O, K)) return D.get; 8235 } while (O = _objectGpo(O)); 8236 } 8237 }); 8238 8239 var getOwnPropertyDescriptor$1 = _objectGopd.f; // B.2.2.5 Object.prototype.__lookupSetter__(P) 8240 8241 8242 _descriptors && _export(_export.P + _objectForcedPam, 'Object', { 8243 __lookupSetter__: function __lookupSetter__(P) { 8244 var O = _toObject(this); 8245 var K = _toPrimitive(P, true); 8246 var D; 8247 8248 do { 8249 if (D = getOwnPropertyDescriptor$1(O, K)) return D.set; 8250 } while (O = _objectGpo(O)); 8251 } 8252 }); 8253 8254 var _arrayFromIterable = function (iter, ITERATOR) { 8255 var result = []; 8256 _forOf(iter, false, result.push, result, ITERATOR); 8257 return result; 8258 }; 8259 8260 // https://github.com/DavidBruant/Map-Set.prototype.toJSON 8261 8262 8263 8264 8265 var _collectionToJson = function (NAME) { 8266 return function toJSON() { 8267 if (_classof(this) != NAME) throw TypeError(NAME + "#toJSON isn't generic"); 8268 return _arrayFromIterable(this); 8269 }; 8270 }; 8271 8272 // https://github.com/DavidBruant/Map-Set.prototype.toJSON 8273 8274 8275 _export(_export.P + _export.R, 'Map', { 8276 toJSON: _collectionToJson('Map') 8277 }); 8278 8279 // https://github.com/DavidBruant/Map-Set.prototype.toJSON 8280 8281 8282 _export(_export.P + _export.R, 'Set', { 8283 toJSON: _collectionToJson('Set') 8284 }); 8285 8286 var _setCollectionOf = function (COLLECTION) { 8287 _export(_export.S, COLLECTION, { 8288 of: function of() { 8289 var length = arguments.length; 8290 var A = new Array(length); 8291 8292 while (length--) { 8293 A[length] = arguments[length]; 8294 } 8295 8296 return new this(A); 8297 } 8298 }); 8299 }; 8300 8301 // https://tc39.github.io/proposal-setmap-offrom/#sec-map.of 8302 _setCollectionOf('Map'); 8303 8304 // https://tc39.github.io/proposal-setmap-offrom/#sec-set.of 8305 _setCollectionOf('Set'); 8306 8307 // https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.of 8308 _setCollectionOf('WeakMap'); 8309 8310 // https://tc39.github.io/proposal-setmap-offrom/#sec-weakset.of 8311 _setCollectionOf('WeakSet'); 8312 8313 var _setCollectionFrom = function (COLLECTION) { 8314 _export(_export.S, COLLECTION, { 8315 from: function from(source 8316 /* , mapFn, thisArg */ 8317 ) { 8318 var mapFn = arguments[1]; 8319 var mapping, A, n, cb; 8320 _aFunction(this); 8321 mapping = mapFn !== undefined; 8322 if (mapping) _aFunction(mapFn); 8323 if (source == undefined) return new this(); 8324 A = []; 8325 8326 if (mapping) { 8327 n = 0; 8328 cb = _ctx(mapFn, arguments[2], 2); 8329 _forOf(source, false, function (nextItem) { 8330 A.push(cb(nextItem, n++)); 8331 }); 8332 } else { 8333 _forOf(source, false, A.push, A); 8334 } 8335 8336 return new this(A); 8337 } 8338 }); 8339 }; 8340 8341 // https://tc39.github.io/proposal-setmap-offrom/#sec-map.from 8342 _setCollectionFrom('Map'); 8343 8344 // https://tc39.github.io/proposal-setmap-offrom/#sec-set.from 8345 _setCollectionFrom('Set'); 8346 8347 // https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.from 8348 _setCollectionFrom('WeakMap'); 8349 8350 // https://tc39.github.io/proposal-setmap-offrom/#sec-weakset.from 8351 _setCollectionFrom('WeakSet'); 8352 8353 // https://github.com/tc39/proposal-global 8354 8355 8356 _export(_export.G, { 8357 global: _global 8358 }); 8359 8360 // https://github.com/tc39/proposal-global 8361 8362 8363 _export(_export.S, 'System', { 8364 global: _global 8365 }); 8366 8367 // https://github.com/ljharb/proposal-is-error 8368 8369 8370 8371 8372 _export(_export.S, 'Error', { 8373 isError: function isError(it) { 8374 return _cof(it) === 'Error'; 8375 } 8376 }); 8377 8378 // https://rwaldron.github.io/proposal-math-extensions/ 8379 8380 8381 _export(_export.S, 'Math', { 8382 clamp: function clamp(x, lower, upper) { 8383 return Math.min(upper, Math.max(lower, x)); 8384 } 8385 }); 8386 8387 // https://rwaldron.github.io/proposal-math-extensions/ 8388 8389 8390 _export(_export.S, 'Math', { 8391 DEG_PER_RAD: Math.PI / 180 8392 }); 8393 8394 // https://rwaldron.github.io/proposal-math-extensions/ 8395 8396 8397 var RAD_PER_DEG = 180 / Math.PI; 8398 _export(_export.S, 'Math', { 8399 degrees: function degrees(radians) { 8400 return radians * RAD_PER_DEG; 8401 } 8402 }); 8403 8404 // https://rwaldron.github.io/proposal-math-extensions/ 8405 var _mathScale = Math.scale || function scale(x, inLow, inHigh, outLow, outHigh) { 8406 if (arguments.length === 0 // eslint-disable-next-line no-self-compare 8407 || x != x // eslint-disable-next-line no-self-compare 8408 || inLow != inLow // eslint-disable-next-line no-self-compare 8409 || inHigh != inHigh // eslint-disable-next-line no-self-compare 8410 || outLow != outLow // eslint-disable-next-line no-self-compare 8411 || outHigh != outHigh) return NaN; 8412 if (x === Infinity || x === -Infinity) return x; 8413 return (x - inLow) * (outHigh - outLow) / (inHigh - inLow) + outLow; 8414 }; 8415 8416 // https://rwaldron.github.io/proposal-math-extensions/ 8417 8418 8419 8420 8421 8422 8423 _export(_export.S, 'Math', { 8424 fscale: function fscale(x, inLow, inHigh, outLow, outHigh) { 8425 return _mathFround(_mathScale(x, inLow, inHigh, outLow, outHigh)); 8426 } 8427 }); 8428 8429 // https://gist.github.com/BrendanEich/4294d5c212a6d2254703 8430 8431 8432 _export(_export.S, 'Math', { 8433 iaddh: function iaddh(x0, x1, y0, y1) { 8434 var $x0 = x0 >>> 0; 8435 var $x1 = x1 >>> 0; 8436 var $y0 = y0 >>> 0; 8437 return $x1 + (y1 >>> 0) + (($x0 & $y0 | ($x0 | $y0) & ~($x0 + $y0 >>> 0)) >>> 31) | 0; 8438 } 8439 }); 8440 8441 // https://gist.github.com/BrendanEich/4294d5c212a6d2254703 8442 8443 8444 _export(_export.S, 'Math', { 8445 isubh: function isubh(x0, x1, y0, y1) { 8446 var $x0 = x0 >>> 0; 8447 var $x1 = x1 >>> 0; 8448 var $y0 = y0 >>> 0; 8449 return $x1 - (y1 >>> 0) - ((~$x0 & $y0 | ~($x0 ^ $y0) & $x0 - $y0 >>> 0) >>> 31) | 0; 8450 } 8451 }); 8452 8453 // https://gist.github.com/BrendanEich/4294d5c212a6d2254703 8454 8455 8456 _export(_export.S, 'Math', { 8457 imulh: function imulh(u, v) { 8458 var UINT16 = 0xffff; 8459 var $u = +u; 8460 var $v = +v; 8461 var u0 = $u & UINT16; 8462 var v0 = $v & UINT16; 8463 var u1 = $u >> 16; 8464 var v1 = $v >> 16; 8465 var t = (u1 * v0 >>> 0) + (u0 * v0 >>> 16); 8466 return u1 * v1 + (t >> 16) + ((u0 * v1 >>> 0) + (t & UINT16) >> 16); 8467 } 8468 }); 8469 8470 // https://rwaldron.github.io/proposal-math-extensions/ 8471 8472 8473 _export(_export.S, 'Math', { 8474 RAD_PER_DEG: 180 / Math.PI 8475 }); 8476 8477 // https://rwaldron.github.io/proposal-math-extensions/ 8478 8479 8480 var DEG_PER_RAD = Math.PI / 180; 8481 _export(_export.S, 'Math', { 8482 radians: function radians(degrees) { 8483 return degrees * DEG_PER_RAD; 8484 } 8485 }); 8486 8487 // https://rwaldron.github.io/proposal-math-extensions/ 8488 8489 8490 _export(_export.S, 'Math', { 8491 scale: _mathScale 8492 }); 8493 8494 // https://gist.github.com/BrendanEich/4294d5c212a6d2254703 8495 8496 8497 _export(_export.S, 'Math', { 8498 umulh: function umulh(u, v) { 8499 var UINT16 = 0xffff; 8500 var $u = +u; 8501 var $v = +v; 8502 var u0 = $u & UINT16; 8503 var v0 = $v & UINT16; 8504 var u1 = $u >>> 16; 8505 var v1 = $v >>> 16; 8506 var t = (u1 * v0 >>> 0) + (u0 * v0 >>> 16); 8507 return u1 * v1 + (t >>> 16) + ((u0 * v1 >>> 0) + (t & UINT16) >>> 16); 8508 } 8509 }); 8510 8511 // http://jfbastien.github.io/papers/Math.signbit.html 8512 8513 8514 _export(_export.S, 'Math', { 8515 signbit: function signbit(x) { 8516 // eslint-disable-next-line no-self-compare 8517 return (x = +x) != x ? x : x == 0 ? 1 / x == Infinity : x > 0; 8518 } 8519 }); 8520 8521 _export(_export.S, 'Promise', { 8522 'try': function _try(callbackfn) { 8523 var promiseCapability = _newPromiseCapability.f(this); 8524 var result = _perform(callbackfn); 8525 (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v); 8526 return promiseCapability.promise; 8527 } 8528 }); 8529 8530 var shared$1 = _shared('metadata'); 8531 8532 var store = shared$1.store || (shared$1.store = new (es6_weakMap)()); 8533 8534 var getOrCreateMetadataMap = function getOrCreateMetadataMap(target, targetKey, create) { 8535 var targetMetadata = store.get(target); 8536 8537 if (!targetMetadata) { 8538 if (!create) return undefined; 8539 store.set(target, targetMetadata = new es6_map()); 8540 } 8541 8542 var keyMetadata = targetMetadata.get(targetKey); 8543 8544 if (!keyMetadata) { 8545 if (!create) return undefined; 8546 targetMetadata.set(targetKey, keyMetadata = new es6_map()); 8547 } 8548 8549 return keyMetadata; 8550 }; 8551 8552 var ordinaryHasOwnMetadata = function ordinaryHasOwnMetadata(MetadataKey, O, P) { 8553 var metadataMap = getOrCreateMetadataMap(O, P, false); 8554 return metadataMap === undefined ? false : metadataMap.has(MetadataKey); 8555 }; 8556 8557 var ordinaryGetOwnMetadata = function ordinaryGetOwnMetadata(MetadataKey, O, P) { 8558 var metadataMap = getOrCreateMetadataMap(O, P, false); 8559 return metadataMap === undefined ? undefined : metadataMap.get(MetadataKey); 8560 }; 8561 8562 var ordinaryDefineOwnMetadata = function ordinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) { 8563 getOrCreateMetadataMap(O, P, true).set(MetadataKey, MetadataValue); 8564 }; 8565 8566 var ordinaryOwnMetadataKeys = function ordinaryOwnMetadataKeys(target, targetKey) { 8567 var metadataMap = getOrCreateMetadataMap(target, targetKey, false); 8568 var keys = [];
vendor: 13,228 bytes, lines 8569-9049
8569 if (metadataMap) metadataMap.forEach(function (_, key) { 8570 keys.push(key); 8571 }); 8572 return keys; 8573 }; 8574 8575 var toMetaKey = function toMetaKey(it) { 8576 return it === undefined || babelHelpers.typeof(it) == 'symbol' ? it : String(it); 8577 }; 8578 8579 var exp$3 = function exp(O) { 8580 _export(_export.S, 'Reflect', O); 8581 }; 8582 8583 var _metadata = { 8584 store: store, 8585 map: getOrCreateMetadataMap, 8586 has: ordinaryHasOwnMetadata, 8587 get: ordinaryGetOwnMetadata, 8588 set: ordinaryDefineOwnMetadata, 8589 keys: ordinaryOwnMetadataKeys, 8590 key: toMetaKey, 8591 exp: exp$3 8592 }; 8593 8594 var toMetaKey$1 = _metadata.key; 8595 var ordinaryDefineOwnMetadata$1 = _metadata.set; 8596 _metadata.exp({ 8597 defineMetadata: function defineMetadata(metadataKey, metadataValue, target, targetKey) { 8598 ordinaryDefineOwnMetadata$1(metadataKey, metadataValue, _anObject(target), toMetaKey$1(targetKey)); 8599 } 8600 }); 8601 8602 var toMetaKey$2 = _metadata.key; 8603 var getOrCreateMetadataMap$1 = _metadata.map; 8604 var store$1 = _metadata.store; 8605 _metadata.exp({ 8606 deleteMetadata: function deleteMetadata(metadataKey, target 8607 /* , targetKey */ 8608 ) { 8609 var targetKey = arguments.length < 3 ? undefined : toMetaKey$2(arguments[2]); 8610 var metadataMap = getOrCreateMetadataMap$1(_anObject(target), targetKey, false); 8611 if (metadataMap === undefined || !metadataMap['delete'](metadataKey)) return false; 8612 if (metadataMap.size) return true; 8613 var targetMetadata = store$1.get(target); 8614 targetMetadata['delete'](targetKey); 8615 return !!targetMetadata.size || store$1['delete'](target); 8616 } 8617 }); 8618 8619 var ordinaryHasOwnMetadata$1 = _metadata.has; 8620 var ordinaryGetOwnMetadata$1 = _metadata.get; 8621 var toMetaKey$3 = _metadata.key; 8622 8623 var ordinaryGetMetadata = function ordinaryGetMetadata(MetadataKey, O, P) { 8624 var hasOwn = ordinaryHasOwnMetadata$1(MetadataKey, O, P); 8625 if (hasOwn) return ordinaryGetOwnMetadata$1(MetadataKey, O, P); 8626 var parent = _objectGpo(O); 8627 return parent !== null ? ordinaryGetMetadata(MetadataKey, parent, P) : undefined; 8628 }; 8629 8630 _metadata.exp({ 8631 getMetadata: function getMetadata(metadataKey, target 8632 /* , targetKey */ 8633 ) { 8634 return ordinaryGetMetadata(metadataKey, _anObject(target), arguments.length < 3 ? undefined : toMetaKey$3(arguments[2])); 8635 } 8636 }); 8637 8638 var ordinaryOwnMetadataKeys$1 = _metadata.keys; 8639 var toMetaKey$4 = _metadata.key; 8640 8641 var ordinaryMetadataKeys = function ordinaryMetadataKeys(O, P) { 8642 var oKeys = ordinaryOwnMetadataKeys$1(O, P); 8643 var parent = _objectGpo(O); 8644 if (parent === null) return oKeys; 8645 var pKeys = ordinaryMetadataKeys(parent, P); 8646 return pKeys.length ? oKeys.length ? _arrayFromIterable(new es6_set(oKeys.concat(pKeys))) : pKeys : oKeys; 8647 }; 8648 8649 _metadata.exp({ 8650 getMetadataKeys: function getMetadataKeys(target 8651 /* , targetKey */ 8652 ) { 8653 return ordinaryMetadataKeys(_anObject(target), arguments.length < 2 ? undefined : toMetaKey$4(arguments[1])); 8654 } 8655 }); 8656 8657 var ordinaryGetOwnMetadata$2 = _metadata.get; 8658 var toMetaKey$5 = _metadata.key; 8659 _metadata.exp({ 8660 getOwnMetadata: function getOwnMetadata(metadataKey, target 8661 /* , targetKey */ 8662 ) { 8663 return ordinaryGetOwnMetadata$2(metadataKey, _anObject(target), arguments.length < 3 ? undefined : toMetaKey$5(arguments[2])); 8664 } 8665 }); 8666 8667 var ordinaryOwnMetadataKeys$2 = _metadata.keys; 8668 var toMetaKey$6 = _metadata.key; 8669 _metadata.exp({ 8670 getOwnMetadataKeys: function getOwnMetadataKeys(target 8671 /* , targetKey */ 8672 ) { 8673 return ordinaryOwnMetadataKeys$2(_anObject(target), arguments.length < 2 ? undefined : toMetaKey$6(arguments[1])); 8674 } 8675 }); 8676 8677 var ordinaryHasOwnMetadata$2 = _metadata.has; 8678 var toMetaKey$7 = _metadata.key; 8679 8680 var ordinaryHasMetadata = function ordinaryHasMetadata(MetadataKey, O, P) { 8681 var hasOwn = ordinaryHasOwnMetadata$2(MetadataKey, O, P); 8682 if (hasOwn) return true; 8683 var parent = _objectGpo(O); 8684 return parent !== null ? ordinaryHasMetadata(MetadataKey, parent, P) : false; 8685 }; 8686 8687 _metadata.exp({ 8688 hasMetadata: function hasMetadata(metadataKey, target 8689 /* , targetKey */ 8690 ) { 8691 return ordinaryHasMetadata(metadataKey, _anObject(target), arguments.length < 3 ? undefined : toMetaKey$7(arguments[2])); 8692 } 8693 }); 8694 8695 var ordinaryHasOwnMetadata$3 = _metadata.has; 8696 var toMetaKey$8 = _metadata.key; 8697 _metadata.exp({ 8698 hasOwnMetadata: function hasOwnMetadata(metadataKey, target 8699 /* , targetKey */ 8700 ) { 8701 return ordinaryHasOwnMetadata$3(metadataKey, _anObject(target), arguments.length < 3 ? undefined : toMetaKey$8(arguments[2])); 8702 } 8703 }); 8704 8705 var toMetaKey$9 = _metadata.key; 8706 var ordinaryDefineOwnMetadata$2 = _metadata.set; 8707 _metadata.exp({ 8708 metadata: function metadata(metadataKey, metadataValue) { 8709 return function decorator(target, targetKey) { 8710 ordinaryDefineOwnMetadata$2(metadataKey, metadataValue, (targetKey !== undefined ? _anObject : _aFunction)(target), toMetaKey$9(targetKey)); 8711 }; 8712 } 8713 }); 8714 8715 // https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-09/sept-25.md#510-globalasap-for-enqueuing-a-microtask 8716 8717 8718 var microtask$1 = _microtask(); 8719 8720 var process$3 = _global.process; 8721 8722 var isNode$2 = _cof(process$3) == 'process'; 8723 _export(_export.G, { 8724 asap: function asap(fn) { 8725 var domain = isNode$2 && process$3.domain; 8726 microtask$1(domain ? domain.bind(fn) : fn); 8727 } 8728 }); 8729 8730 var microtask$2 = _microtask(); 8731 8732 var OBSERVABLE = _wks('observable'); 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 var RETURN = _forOf.RETURN; 8747 8748 var getMethod = function getMethod(fn) { 8749 return fn == null ? undefined : _aFunction(fn); 8750 }; 8751 8752 var cleanupSubscription = function cleanupSubscription(subscription) { 8753 var cleanup = subscription._c; 8754 8755 if (cleanup) { 8756 subscription._c = undefined; 8757 cleanup(); 8758 } 8759 }; 8760 8761 var subscriptionClosed = function subscriptionClosed(subscription) { 8762 return subscription._o === undefined; 8763 }; 8764 8765 var closeSubscription = function closeSubscription(subscription) { 8766 if (!subscriptionClosed(subscription)) { 8767 subscription._o = undefined; 8768 cleanupSubscription(subscription); 8769 } 8770 }; 8771 8772 var Subscription = function Subscription(observer, subscriber) { 8773 _anObject(observer); 8774 this._c = undefined; 8775 this._o = observer; 8776 observer = new SubscriptionObserver(this); 8777 8778 try { 8779 var cleanup = subscriber(observer); 8780 var subscription = cleanup; 8781 8782 if (cleanup != null) { 8783 if (typeof cleanup.unsubscribe === 'function') cleanup = function cleanup() { 8784 subscription.unsubscribe(); 8785 };else _aFunction(cleanup); 8786 this._c = cleanup; 8787 } 8788 } catch (e) { 8789 observer.error(e); 8790 return; 8791 } 8792 8793 if (subscriptionClosed(this)) cleanupSubscription(this); 8794 }; 8795 8796 Subscription.prototype = _redefineAll({}, { 8797 unsubscribe: function unsubscribe() { 8798 closeSubscription(this); 8799 } 8800 }); 8801 8802 var SubscriptionObserver = function SubscriptionObserver(subscription) { 8803 this._s = subscription; 8804 }; 8805 8806 SubscriptionObserver.prototype = _redefineAll({}, { 8807 next: function next(value) { 8808 var subscription = this._s; 8809 8810 if (!subscriptionClosed(subscription)) { 8811 var observer = subscription._o; 8812 8813 try { 8814 var m = getMethod(observer.next); 8815 if (m) return m.call(observer, value); 8816 } catch (e) { 8817 try { 8818 closeSubscription(subscription); 8819 } finally { 8820 throw e; 8821 } 8822 } 8823 } 8824 }, 8825 error: function error(value) { 8826 var subscription = this._s; 8827 if (subscriptionClosed(subscription)) throw value; 8828 var observer = subscription._o; 8829 subscription._o = undefined; 8830 8831 try { 8832 var m = getMethod(observer.error); 8833 if (!m) throw value; 8834 value = m.call(observer, value); 8835 } catch (e) { 8836 try { 8837 cleanupSubscription(subscription); 8838 } finally { 8839 throw e; 8840 } 8841 } 8842 8843 cleanupSubscription(subscription); 8844 return value; 8845 }, 8846 complete: function complete(value) { 8847 var subscription = this._s; 8848 8849 if (!subscriptionClosed(subscription)) { 8850 var observer = subscription._o; 8851 subscription._o = undefined; 8852 8853 try { 8854 var m = getMethod(observer.complete); 8855 value = m ? m.call(observer, value) : undefined; 8856 } catch (e) { 8857 try { 8858 cleanupSubscription(subscription); 8859 } finally { 8860 throw e; 8861 } 8862 } 8863 8864 cleanupSubscription(subscription); 8865 return value; 8866 } 8867 } 8868 }); 8869 8870 var $Observable = function Observable(subscriber) { 8871 _anInstance(this, $Observable, 'Observable', '_f')._f = _aFunction(subscriber); 8872 }; 8873 8874 _redefineAll($Observable.prototype, { 8875 subscribe: function subscribe(observer) { 8876 return new Subscription(observer, this._f); 8877 }, 8878 forEach: function forEach(fn) { 8879 var that = this; 8880 return new (_core.Promise || _global.Promise)(function (resolve, reject) { 8881 _aFunction(fn); 8882 var subscription = that.subscribe({ 8883 next: function next(value) { 8884 try { 8885 return fn(value); 8886 } catch (e) { 8887 reject(e); 8888 subscription.unsubscribe(); 8889 } 8890 }, 8891 error: reject, 8892 complete: resolve 8893 }); 8894 }); 8895 } 8896 }); 8897 _redefineAll($Observable, { 8898 from: function from(x) { 8899 var C = typeof this === 'function' ? this : $Observable; 8900 var method = getMethod(_anObject(x)[OBSERVABLE]); 8901 8902 if (method) { 8903 var observable = _anObject(method.call(x)); 8904 return observable.constructor === C ? observable : new C(function (observer) { 8905 return observable.subscribe(observer); 8906 }); 8907 } 8908 8909 return new C(function (observer) { 8910 var done = false; 8911 microtask$2(function () { 8912 if (!done) { 8913 try { 8914 if (_forOf(x, false, function (it) { 8915 observer.next(it); 8916 if (done) return RETURN; 8917 }) === RETURN) return; 8918 } catch (e) { 8919 if (done) throw e; 8920 observer.error(e); 8921 return; 8922 } 8923 8924 observer.complete(); 8925 } 8926 }); 8927 return function () { 8928 done = true; 8929 }; 8930 }); 8931 }, 8932 of: function of() { 8933 for (var i = 0, l = arguments.length, items = new Array(l); i < l;) { 8934 items[i] = arguments[i++]; 8935 } 8936 8937 return new (typeof this === 'function' ? this : $Observable)(function (observer) { 8938 var done = false; 8939 microtask$2(function () { 8940 if (!done) { 8941 for (var j = 0; j < items.length; ++j) { 8942 observer.next(items[j]); 8943 if (done) return; 8944 } 8945 8946 observer.complete(); 8947 } 8948 }); 8949 return function () { 8950 done = true; 8951 }; 8952 }); 8953 } 8954 }); 8955 _hide($Observable.prototype, OBSERVABLE, function () { 8956 return this; 8957 }); 8958 _export(_export.G, { 8959 Observable: $Observable 8960 }); 8961 8962 _setSpecies('Observable'); 8963 8964 // ie9- setTimeout & setInterval additional parameters fix 8965 8966 8967 8968 8969 8970 8971 var slice = [].slice; 8972 var MSIE = /MSIE .\./.test(_userAgent); // <- dirty ie9- check 8973 8974 var wrap$1 = function wrap(set) { 8975 return function (fn, time 8976 /* , ...args */ 8977 ) { 8978 var boundArgs = arguments.length > 2; 8979 var args = boundArgs ? slice.call(arguments, 2) : false; 8980 return set(boundArgs ? function () { 8981 // eslint-disable-next-line no-new-func 8982 (typeof fn == 'function' ? fn : Function(fn)).apply(this, args); 8983 } : fn, time); 8984 }; 8985 }; 8986 8987 _export(_export.G + _export.B + _export.F * MSIE, { 8988 setTimeout: wrap$1(_global.setTimeout), 8989 setInterval: wrap$1(_global.setInterval) 8990 }); 8991 8992 _export(_export.G + _export.B, { 8993 setImmediate: _task.set, 8994 clearImmediate: _task.clear 8995 }); 8996 8997 var ITERATOR$4 = _wks('iterator'); 8998 var TO_STRING_TAG = _wks('toStringTag'); 8999 var ArrayValues = _iterators.Array; 9000 var DOMIterables = { 9001 CSSRuleList: true, 9002 // TODO: Not spec compliant, should be false. 9003 CSSStyleDeclaration: false, 9004 CSSValueList: false, 9005 ClientRectList: false, 9006 DOMRectList: false, 9007 DOMStringList: false, 9008 DOMTokenList: true, 9009 DataTransferItemList: false, 9010 FileList: false, 9011 HTMLAllCollection: false, 9012 HTMLCollection: false, 9013 HTMLFormElement: false, 9014 HTMLSelectElement: false, 9015 MediaList: true, 9016 // TODO: Not spec compliant, should be false. 9017 MimeTypeArray: false, 9018 NamedNodeMap: false, 9019 NodeList: true, 9020 PaintRequestList: false, 9021 Plugin: false, 9022 PluginArray: false, 9023 SVGLengthList: false, 9024 SVGNumberList: false, 9025 SVGPathSegList: false, 9026 SVGPointList: false, 9027 SVGStringList: false, 9028 SVGTransformList: false, 9029 SourceBufferList: false, 9030 StyleSheetList: true, 9031 // TODO: Not spec compliant, should be false. 9032 TextTrackCueList: false, 9033 TextTrackList: false, 9034 TouchList: false 9035 }; 9036 9037 for (var collections = _objectKeys(DOMIterables), i$2 = 0; i$2 < collections.length; i$2++) { 9038 var NAME$1 = collections[i$2]; 9039 var explicit = DOMIterables[NAME$1]; 9040 var Collection = _global[NAME$1]; 9041 var proto$3 = Collection && Collection.prototype; 9042 var key$1; 9043 9044 if (proto$3) { 9045 if (!proto$3[ITERATOR$4]) _hide(proto$3, ITERATOR$4, ArrayValues); 9046 if (!proto$3[TO_STRING_TAG]) _hide(proto$3, TO_STRING_TAG, NAME$1); 9047 _iterators[NAME$1] = ArrayValues; 9048 if (explicit) for (key$1 in es6_array_iterator) { 9049 if (!proto$3[key$1]) _redefine(proto$3, key$1, es6_array_iterator[key$
90491], true); 9050 } 9051 } 9052 } 9053 9054 if (window._main_core_polyfill) { 9055 console.warn('main.core.polyfill is loaded more than once on this page'); 9056 } 9057 9058 window._main_core_polyfill = true; 9059 9060}((this.window = this.window || {}))); 9061 9062 9063 9064/** 9065 * Element.prototype.matches polyfill 9066 */ 9067;(function(element) { 9068 'use strict'; 9069 9070 if (!element.matches && element.matchesSelector) 9071 { 9072 element.matches = element.matchesSelector; 9073 } 9074 9075 if (!element.matches) 9076 { 9077 element.matches = function(selector) { 9078 var matches = document.querySelectorAll(selector); 9079 var self = this; 9080 9081 return Array.prototype.some.call(matches, function(e) { 9082 return e === self; 9083 }); 9084 }; 9085 } 9086 9087})(Element.prototype); 9088 9089;(function() { 9090 'use strict'; 9091 9092 if (!Element.prototype.closest) 9093 { 9094 /** 9095 * Finds closest parent element by selector 9096 * @param {string} selector 9097 * @return {HTMLElement|Element|Node} 9098 */ 9099 Object.defineProperty(Element.prototype, 'closest', { 9100 enumerable: false, 9101 value: function(selector) { 9102 var node = this; 9103 9104 while (node) 9105 { 9106 if (node.matches(selector)) 9107 { 9108 return node; 9109 } 9110 9111 node = node.parentElement; 9112 } 9113 9114 return null; 9115 }, 9116 }); 9117 } 9118})(); 9119 9120(function (exports) { 9121 'use strict'; 9122 9123 if (!window.DOMRect || typeof DOMRect.prototype.toJSON !== 'function' || typeof DOMRect.fromRect !== 'function') { 9124 window.DOMRect = 9125 /*#__PURE__*/ 9126 function () { 9127 function DOMRect(x, y, width, height) { 9128 babelHelpers.classCallCheck(this, DOMRect); 9129 this.x = x || 0; 9130 this.y = y || 0; 9131 this.width = width || 0; 9132 this.height = height || 0; 9133 } 9134 9135 babelHelpers.createClass(DOMRect, [{ 9136 key: "toJSON", 9137 value: function toJSON() { 9138 return { 9139 top: this.top, 9140 left: this.left, 9141 right: this.right, 9142 bottom: this.bottom, 9143 width: this.width, 9144 height: this.height, 9145 x: this.x, 9146 y: this.y 9147 }; 9148 } 9149 }, { 9150 key: "top", 9151 get: function get() { 9152 return this.y; 9153 } 9154 }, { 9155 key: "left", 9156 get: function get() { 9157 return this.x; 9158 } 9159 }, { 9160 key: "right", 9161 get: function get() { 9162 return this.x + this.width; 9163 } 9164 }, { 9165 key: "bottom", 9166 get: function get() { 9167 return this.y + this.height; 9168 } 9169 }], [{ 9170 key: "fromRect", 9171 value: function fromRect(otherRect) { 9172 return new DOMRect(otherRect.x, otherRect.y, otherRect.width, otherRect.height); 9173 } 9174 }]); 9175 return DOMRect; 9176 }(); 9177 } 9178 9179}((this.window = this.window || {}))); 9180 9181 9182 9183 9184(function (exports) { 9185 'use strict'; 9186 9187 var bxTmp = window.BX; 9188 9189 window.BX = function (node) { 9190 if (window.BX.type.isNotEmptyString(node)) { 9191 return document.getElementById(node); 9192 } 9193 9194 if (window.BX.type.isDomNode(node)) { 9195 return node; 9196 } 9197 9198 if (window.BX.type.isFunction(node)) { 9199 return window.BX.ready(node); 9200 } 9201 9202 return null; 9203 }; 9204 9205 if (bxTmp) {
9206 Object.keys(bxTmp).forEach(function (key) { 9207 window.BX[key] = bxTmp[key]; 9208 }); 9209 } 9210 9211 exports = window.BX; 9212 9213 /** 9214 * Gets object.toString result 9215 * @param value 9216 * @return {string} 9217 */ 9218 function getTag(value) { 9219 return Object.prototype.toString.call(value); 9220 } 9221 9222 var objectCtorString = Function.prototype.toString.call(Object); 9223 /** 9224 * @memberOf BX 9225 */ 9226 9227 var Type = /*#__PURE__*/function () { 9228 function Type() { 9229 babelHelpers.classCallCheck(this, Type); 9230 } 9231 9232 babelHelpers.createClass(Type, null, [{ 9233 key: "isString", 9234 9235 /** 9236 * Checks that value is string 9237 * @param value 9238 * @return {boolean} 9239 */ 9240 value: function isString(value) { 9241 return typeof value === 'string'; 9242 } 9243 /** 9244 * Returns true if a value is not empty string 9245 * @param value 9246 * @returns {boolean} 9247 */ 9248 9249 }, { 9250 key: "isStringFilled", 9251 value: function isStringFilled(value) { 9252 return this.isString(value) && value !== ''; 9253 } 9254 /** 9255 * Checks that value is function 9256 * @param value 9257 * @return {boolean} 9258 */ 9259 9260 }, { 9261 key: "isFunction", 9262 value: function isFunction(value) { 9263 return typeof value === 'function'; 9264 } 9265 /** 9266 * Checks that value is object 9267 * @param value 9268 * @return {boolean} 9269 */ 9270 9271 }, { 9272 key: "isObject", 9273 value: function isObject(value) { 9274 return !!value && (babelHelpers.typeof(value) === 'object' || typeof value === 'function'); 9275 } 9276 /** 9277 * Checks that value is object like 9278 * @param value 9279 * @return {boolean} 9280 */ 9281 9282 }, { 9283 key: "isObjectLike", 9284 value: function isObjectLike(value) { 9285 return !!value && babelHelpers.typeof(value) === 'object'; 9286 } 9287 /** 9288 * Checks that value is plain object 9289 * @param value 9290 * @return {boolean} 9291 */ 9292 9293 }, { 9294 key: "isPlainObject", 9295 value: function isPlainObject(value) { 9296 if (!Type.isObjectLike(value) || getTag(value) !== '[object Object]') { 9297 return false; 9298 } 9299 9300 var proto = Object.getPrototypeOf(value); 9301 9302 if (proto === null) { 9303 return true; 9304 } 9305 9306 var ctor = proto.hasOwnProperty('constructor') && proto.constructor; 9307 return typeof ctor === 'function' && Function.prototype.toString.call(ctor) === objectCtorString; 9308 } 9309 /** 9310 * Checks that value is boolean 9311 * @param value 9312 * @return {boolean} 9313 */ 9314 9315 }, { 9316 key: "isBoolean", 9317 value: function isBoolean(value) { 9318 return value === true || value === false; 9319 } 9320 /** 9321 * Checks that value is number 9322 * @param value 9323 * @return {boolean} 9324 */ 9325 9326 }, { 9327 key: "isNumber", 9328 value: function isNumber(value) { 9329 return !Number.isNaN(value) && typeof value === 'number'; 9330 } 9331 /** 9332 * Checks that value is integer 9333 * @param value 9334 * @return {boolean} 9335 */ 9336 9337 }, { 9338 key: "isInteger", 9339 value: function isInteger(value) { 9340 return Type.isNumber(value) && value % 1 === 0; 9341 } 9342 /** 9343 * Checks that value is float 9344 * @param value 9345 * @return {boolean} 9346 */ 9347 9348 }, { 9349 key: "isFloat", 9350 value: function isFloat(value) { 9351 return Type.isNumber(value) && !Type.isInteger(value); 9352 } 9353 /** 9354 * Checks that value is nil 9355 * @param value 9356 * @return {boolean} 9357 */ 9358 9359 }, { 9360 key: "isNil", 9361 value: function isNil(value) { 9362 return value === null || value === undefined; 9363 } 9364 /** 9365 * Checks that value is array 9366 * @param value 9367 * @return {boolean} 9368 */ 9369 9370 }, { 9371 key: "isArray", 9372 value: function isArray(value) { 9373 return !Type.isNil(value) && Array.isArray(value); 9374 } 9375 /** 9376 * Returns true if a value is an array and it has at least one element 9377 * @param value 9378 * @returns {boolean} 9379 */ 9380 9381 }, { 9382 key: "isArrayFilled", 9383 value: function isArrayFilled(value) { 9384 return this.isArray(value) && value.length > 0; 9385 } 9386 /** 9387 * Checks that value is array like 9388 * @param value 9389 * @return {boolean} 9390 */ 9391 9392 }, { 9393 key: "isArrayLike", 9394 value: function isArrayLike(value) { 9395 return !Type.isNil(value) && !Type.isFunction(value) && value.length > -1 && value.length <= Number.MAX_SAFE_INTEGER; 9396 } 9397 /** 9398 * Checks that value is Date 9399 * @param value 9400 * @return {boolean} 9401 */ 9402 9403 }, { 9404 key: "isDate", 9405 value: function isDate(value) { 9406 return Type.isObjectLike(value) && getTag(value) === '[object Date]'; 9407 } 9408 /** 9409 * Checks that is DOM node 9410 * @param value 9411 * @return {boolean} 9412 */ 9413 9414 }, { 9415 key: "isDomNode", 9416 value: function isDomNode(value) { 9417 return Type.isObjectLike(value) && !Type.isPlainObject(value) && 'nodeType' in value; 9418 } 9419 /** 9420 * Checks that value is element node 9421 * @param value 9422 * @return {boolean} 9423 */ 9424 9425 }, { 9426 key: "isElementNode", 9427 value: function isElementNode(value) { 9428 return Type.isDomNode(value) && value.nodeType === Node.ELEMENT_NODE; 9429 } 9430 /** 9431 * Checks that value is text node 9432 * @param value 9433 * @return {boolean} 9434 */ 9435 9436 }, { 9437 key: "isTextNode", 9438 value: function isTextNode(value) { 9439 return Type.isDomNode(value) && value.nodeType === Node.TEXT_NODE; 9440 } 9441 /** 9442 * Checks that value is Map 9443 * @param value 9444 * @return {boolean} 9445 */ 9446 9447 }, { 9448 key: "isMap", 9449 value: function isMap(value) { 9450 return Type.isObjectLike(value) && getTag(value) === '[object Map]'; 9451 } 9452 /** 9453 * Checks that value is Set 9454 * @param value 9455 * @return {boolean} 9456 */ 9457 9458 }, { 9459 key: "isSet", 9460 value: function isSet(value) { 9461 return Type.isObjectLike(value) && getTag(value) === '[object Set]'; 9462 } 9463 /** 9464 * Checks that value is WeakMap 9465 * @param value 9466 * @return {boolean} 9467 */ 9468 9469 }, { 9470 key: "isWeakMap", 9471 value: function isWeakMap(value) { 9472 return Type.isObjectLike(value) && getTag(value) === '[object WeakMap]'; 9473 } 9474 /** 9475 * Checks that value is WeakSet 9476 * @param value 9477 * @return {boolean} 9478 */ 9479 9480 }, { 9481 key: "isWeakSet", 9482 value: function isWeakSet(value) { 9483 return Type.isObjectLike(value) && getTag(value) === '[object WeakSet]'; 9484 } 9485 /** 9486 * Checks that value is prototype 9487 * @param value 9488 * @return {boolean} 9489 */ 9490 9491 }, { 9492 key: "isPrototype", 9493 value: function isPrototype(value) { 9494 return (typeof (value && value.constructor) === 'function' && value.constructor.prototype || Object.prototype) === value; 9495 } 9496 /** 9497 * Checks that value is regexp 9498 * @param value 9499 * @return {boolean} 9500 */ 9501 9502 }, { 9503 key: "isRegExp", 9504 value: function isRegExp(value) { 9505 return Type.isObjectLike(value) && getTag(value) === '[object RegExp]'; 9506 } 9507 /** 9508 * Checks that value is null 9509 * @param value 9510 * @return {boolean} 9511 */ 9512 9513 }, { 9514 key: "isNull", 9515 value: function isNull(value) { 9516 return value === null; 9517 } 9518 /** 9519 * Checks that value is undefined 9520 * @param value 9521 * @return {boolean} 9522 */ 9523 9524 }, { 9525 key: "isUndefined", 9526 value: function isUndefined(value) { 9527 return typeof value === 'undefined'; 9528 } 9529 /** 9530 * Checks that value is ArrayBuffer 9531 * @param value 9532 * @return {boolean} 9533 */ 9534 9535 }, { 9536 key: "isArrayBuffer", 9537 value: function isArrayBuffer(value) { 9538 return Type.isObjectLike(value) && getTag(value) === '[object ArrayBuffer]'; 9539 } 9540 /** 9541 * Checks that value is typed array 9542 * @param value 9543 * @return {boolean} 9544 */ 9545 9546 }, { 9547 key: "isTypedArray", 9548 value: function isTypedArray(value) { 9549 var regExpTypedTag = /^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)]$/; 9550 return Type.isObjectLike(value) && regExpTypedTag.test(getTag(value)); 9551 } 9552 /** 9553 * Checks that value is Blob 9554 * @param value 9555 * @return {boolean} 9556 */ 9557 9558 }, { 9559 key: "isBlob", 9560 value: function isBlob(value) { 9561 return Type.isObjectLike(value) && Type.isNumber(value.size) && Type.isString(value.type) && Type.isFunction(value.slice); 9562 } 9563 /** 9564 * Checks that value is File 9565 * @param value 9566 * @return {boolean} 9567 */ 9568 9569 }, { 9570 key: "isFile", 9571 value: function isFile(value) { 9572 return Type.isBlob(value) && Type.isString(value.name) && (Type.isNumber(value.lastModified) || Type.isObjectLike(value.lastModifiedDate)); 9573 } 9574 /** 9575 * Checks that value is FormData 9576 * @param value 9577 * @return {boolean} 9578 */ 9579 9580 }, { 9581 key: "isFormData", 9582 value: function isFormData(value) { 9583 return value instanceof FormData; 9584 } 9585 }]); 9586 return Type; 9587 }(); 9588 9589 /** 9590 * @memberOf BX 9591 */ 9592 9593 var Reflection = /*#__PURE__*/function () { 9594 function Reflection() { 9595 babelHelpers.classCallCheck(this, Reflection); 9596 } 9597 9598 babelHelpers.createClass(Reflection, null, [{ 9599 key: "getClass", 9600 9601 /** 9602 * Gets link to function by function name 9603 * @param className 9604 * @return {?Function} 9605 */ 9606 value: function getClass(className) { 9607 if (Type.isString(className) && !!className) { 9608 var classFn = null; 9609 var currentNamespace = window; 9610 var namespaces = className.split('.'); 9611 9612 for (var i = 0; i < namespaces.length; i += 1) { 9613 var namespace = namespaces[i]; 9614 9615 if (!currentNamespace[namespace]) { 9616 return null; 9617 } 9618 9619 currentNamespace = currentNamespace[namespace]; 9620 classFn = currentNamespace; 9621 } 9622 9623 return classFn; 9624 } 9625 9626 if (Type.isFunction(className)) { 9627 return className; 9628 } 9629 9630 return null; 9631 } 9632 /** 9633 * Creates a namespace or returns a link to a previously created one 9634 * @param {String} namespaceName 9635 * @return {Object<string, any> | Function | null} 9636 */ 9637 9638 }, { 9639 key: "namespace", 9640 value: function namespace(namespaceName) { 9641 var parts = namespaceName.split('.'); 9642 var parent = window.BX; 9643 9644 if (parts[0] === 'BX') { 9645 parts = parts.slice(1); 9646 } 9647 9648 for (var i = 0; i < parts.length; i += 1) { 9649 if (Type.isUndefined(parent[parts[i]])) { 9650 parent[parts[i]] = {}; 9651 } 9652 9653 parent = parent[parts[i]]; 9654 } 9655 9656 return parent; 9657 } 9658 }]); 9659 return Reflection; 9660 }(); 9661 9662 var reEscape = /[&<>'"]/g; 9663 var reUnescape = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g; 9664 var escapeEntities = { 9665 '&': '&', 9666 '<': '<', 9667 '>': '>', 9668 "'": ''', 9669 '"': '"' 9670 }; 9671 var unescapeEntities = { 9672 '&': '&', 9673 '&': '&', 9674 '<': '<', 9675 '<': '<', 9676 '>': '>', 9677 '>': '>', 9678 ''': "'", 9679 ''': "'", 9680 '"': '"', 9681 '"': '"' 9682 }; 9683 /** 9684 * @memberOf BX 9685 */ 9686 9687 var Text = /*#__PURE__*/function () { 9688 function Text() { 9689 babelHelpers.classCallCheck(this, Text); 9690 } 9691 9692 babelHelpers.createClass(Text, null, [{ 9693 key: "encode", 9694 9695 /** 9696 * Encodes all unsafe entities 9697 * @param {string} value 9698 * @return {string} 9699 */ 9700 value: function encode(value) { 9701 if (Type.isString(value)) { 9702 return value.replace(reEscape, function (item) { 9703 return escapeEntities[item]; 9704 }); 9705 } 9706 9707 return value; 9708 } 9709 /** 9710 * Decodes all encoded entities 9711 * @param {string} value 9712 * @return {string} 9713 */ 9714 9715 }, { 9716 key: "decode", 9717 value: function decode(value) { 9718 if (Type.isString(value)) { 9719 return value.replace(reUnescape, function (item) { 9720 return unescapeEntities[item]; 9721 }); 9722 } 9723 9724 return value; 9725 } 9726 }, { 9727 key: "getRandom", 9728 value: function getRandom() { 9729 var length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 8; 9730 // eslint-disable-next-line 9731 return babelHelpers.toConsumableArray(Array(length)).map(function () { 9732 return (~~(Math.random() * 36)).toString(36); 9733 }).join(''); 9734 } 9735 }, { 9736 key: "toNumber", 9737 value: function toNumber(value) { 9738 var parsedValue = Number.parseFloat(value); 9739 9740 if (Type.isNumber(parsedValue)) { 9741 return parsedValue; 9742 } 9743 9744 return 0; 9745 } 9746 }, { 9747 key: "toInteger", 9748 value: function toInteger(value) { 9749 return Text.toNumber(Number.parseInt(value, 10)); 9750 } 9751 }, { 9752 key: "toBoolean", 9753 value: function toBoolean(value) { 9754 var trueValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; 9755 var transformedValue = Type.isString(value) ? value.toLowerCase() : value; 9756 return ['true', 'y', '1', 1, true].concat(babelHelpers.toConsumableArray(trueValues)).includes(transformedValue); 9757 } 9758 }, { 9759 key: "toCamelCase", 9760 value: function toCamelCase(str) { 9761 if (!Type.isStringFilled(str)) { 9762 return str; 9763 } 9764 9765 var regex = /[-_\s]+(.)?/g; 9766 9767 if (!regex.test(str)) { 9768 return str.match(/^[A-Z]+$/) ? str.toLowerCase() : str[0].toLowerCase() + str.slice(1); 9769 } 9770 9771 str = str.toLowerCase(); 9772 str = str.replace(regex, function (match, letter) { 9773 return letter ? letter.toUpperCase() : ''; 9774 }); 9775 return str[0].toLowerCase() + str.substr(1); 9776 } 9777 }, { 9778 key: "toPascalCase", 9779 value: function toPascalCase(str) { 9780 if (!Type.isStringFilled(str)) { 9781 return str; 9782 } 9783 9784 return this.capitalize(this.toCamelCase(str)); 9785 } 9786 }, { 9787 key: "toKebabCase", 9788 value: function toKebabCase(str) { 9789 if (!Type.isStringFilled(str)) { 9790 return str; 9791 } 9792 9793 var matches = str.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g); 9794 9795 if (!matches) { 9796 return str; 9797 } 9798 9799 return matches.map(function (x) { 9800 return x.toLowerCase(); 9801 }).join('-'); 9802 } 9803 }, { 9804 key: "capitalize", 9805 value: function capitalize(str) { 9806 if (!Type.isStringFilled(str)) { 9807 return str; 9808 } 9809 9810 return str[0].toUpperCase() + str.substr(1); 9811 } 9812 }]); 9813 return Text; 9814 }(); 9815 9816 var aliases = { 9817 mousewheel: ['DOMMouseScroll'], 9818 bxchange: ['change', 'cut', 'paste', 'drop', 'keyup'], 9819 animationend: ['animationend', 'oAnimationEnd', 'webkitAnimationEnd', 'MSAnimationEnd'], 9820 transitionend: ['webkitTransitionEnd', 'otransitionend', 'oTransitionEnd', 'msTransitionEnd', 'transitionend'], 9821 fullscreenchange: ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange', 'MSFullscreenChange'], 9822 fullscreenerror: ['fullscreenerror', 'webkitfullscreenerror', 'mozfullscreenerror', 'MSFullscreenError'] 9823 }; 9824 9825 var Registry = /*#__PURE__*/function () { 9826 function Registry() { 9827 babelHelpers.classCallCheck(this, Registry); 9828 babelHelpers.defineProperty(this, "registry", new WeakMap()); 9829 } 9830 9831 babelHelpers.createClass(Registry, [{ 9832 key: "set", 9833 value: function set(target, event, listener) { 9834 var events = this.get(target); 9835 9836 if (!Type.isSet(events[event])) { 9837 events[event] = new Set(); 9838 } 9839 9840 events[event].add(listener); 9841 this.registry.set(target, events); 9842 } 9843 }, { 9844 key: "get", 9845 value: function get(target) { 9846 return this.registry.get(target) || {}; 9847 } 9848 }, { 9849 key: "has", 9850 value: function has(target, event, listener) { 9851 if (event && listener) { 9852 return this.registry.has(target) && this.registry.get(target)[event].has(listener); 9853 } 9854 9855 return this.registry.has(target); 9856 } 9857 }, { 9858 key: "delete", 9859 value: function _delete(target, event, listener) { 9860 if (!Type.isDomNode(target)) { 9861 return; 9862 } 9863 9864 if (Type.isString(event) && Type.isFunction(listener)) { 9865 var events = this.registry.get(target); 9866 9867 if (Type.isPlainObject(events) && Type.isSet(events[event])) { 9868 events[event].delete(listener); 9869 } 9870 9871 return; 9872 } 9873 9874 if (Type.isString(event)) { 9875 var _events = this.registry.get(target); 9876 9877 if (Type.isPlainObject(_events) && Type.isSet(_events[event
9877])) { 9878 _events[event] = new Set(); 9879 } 9880 9881 return; 9882 } 9883 9884 this.registry.delete(target); 9885 } 9886 }]); 9887 return Registry; 9888 }(); 9889 var registry = new Registry(); 9890 9891 function isOptionSupported(name) { 9892 var isSupported = false; 9893 9894 try { 9895 var options = Object.defineProperty({}, name, { 9896 get: function get() { 9897 isSupported = true; 9898 return undefined; 9899 } 9900 }); 9901 window.addEventListener('test', null, options); 9902 } // eslint-disable-next-line 9903 catch (err) {} 9904 9905 return isSupported; 9906 } 9907 9908 function fetchSupportedListenerOptions(options) { 9909 if (!Type.isPlainObject(options)) { 9910 return options; 9911 } 9912 9913 return Object.keys(options).reduce(function (acc, name) { 9914 if (isOptionSupported(name)) { 9915 acc[name] = options[name]; 9916 } 9917 9918 return acc; 9919 }, {}); 9920 } 9921 9922 function bind(target, eventName, handler, options) { 9923 if (!Type.isObject(target) || !Type.isFunction(target.addEventListener)) { 9924 return; 9925 } 9926 9927 var listenerOptions = fetchSupportedListenerOptions(options); 9928 9929 if (eventName in aliases) { 9930 aliases[eventName].forEach(function (key) { 9931 target.addEventListener(key, handler, listenerOptions); 9932 registry.set(target, eventName, handler); 9933 }); 9934 return; 9935 } 9936 9937 target.addEventListener(eventName, handler, listenerOptions); 9938 registry.set(target, eventName, handler); 9939 } 9940 9941 function unbind(target, eventName, handler, options) { 9942 if (!Type.isObject(target) || !Type.isFunction(target.removeEventListener)) { 9943 return; 9944 } 9945 9946 var listenerOptions = fetchSupportedListenerOptions(options); 9947 9948 if (eventName in aliases) { 9949 aliases[eventName].forEach(function (key) { 9950 target.removeEventListener(key, handler, listenerOptions); 9951 registry.delete(target, key, handler); 9952 }); 9953 return; 9954 } 9955 9956 target.removeEventListener(eventName, handler, listenerOptions); 9957 registry.delete(target, eventName, handler); 9958 } 9959 9960 function unbindAll(target, eventName) { 9961 var events = registry.get(target); 9962 Object.keys(events).forEach(function (currentEvent) { 9963 events[currentEvent].forEach(function (handler) { 9964 if (!Type.isString(eventName) || eventName === currentEvent) { 9965 unbind(target, currentEvent, handler); 9966 } 9967 }); 9968 }); 9969 } 9970 9971 function bindOnce(target, eventName, handler, options) { 9972 var once = function once() { 9973 unbind(target, eventName, once, options); 9974 handler.apply(void 0, arguments); 9975 }; 9976 9977 bind(target, eventName, once, options); 9978 } 9979 9980 var debugState = true; 9981 function enableDebug() { 9982 debugState = true; 9983 } 9984 function disableDebug() { 9985 debugState = false; 9986 } 9987 function isDebugEnabled() { 9988 return debugState; 9989 } 9990 function debug() { 9991 if (isDebugEnabled() && Type.isObject(window.console)) { 9992 if (Type.isFunction(window.console.log)) { 9993 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 9994 args[_key] = arguments[_key]; 9995 } 9996 9997 window.console.log('BX.debug: ', args.length > 0 ? args : args[0]); 9998 9999 if (args[0] instanceof Error && args[0].stack) { 10000 window.console.log('BX.debug error stack trace', args[0].stack); 10001 } 10002 } 10003 10004 if (Type.isFunction(window.console.trace)) { 10005 // eslint-disable-next-line 10006 console.trace(); 10007 } 10008 } 10009 } 10010 10011 function fetchExtensionSettings(html) { 10012 if (Type.isStringFilled(html)) { 10013 var scripts = html.match(/<script type="extension\/settings" \b[^>]*>([\s\S]*?)<\/script>/g); 10014 10015 if (Type.isArrayFilled(scripts)) { 10016 return scripts.map(function (script) { 10017 var _script$match = script.match(/data-extension="(.[a-z0-9_.-]+)"/), 10018 _script$match2 = babelHelpers.slicedToArray(_script$match, 2), 10019 extension = _script$match2[1]; 10020 10021 return { 10022 extension: extension, 10023 script: script 10024 }; 10025 }); 10026 } 10027 } 10028 10029 return []; 10030 } 10031 10032 var Extension = /*#__PURE__*/function () { 10033 function Extension(options) { 10034 babelHelpers.classCallCheck(this, Extension); 10035 this.config = options.config || {}; 10036 this.name = options.extension; 10037 this.state = 'scheduled'; // eslint-disable-next-line 10038 10039 var result = BX.processHTML(options.html || ''); 10040 this.inlineScripts = result.SCRIPT.reduce(inlineScripts, []); 10041 this.externalScripts = result.SCRIPT.reduce(externalScripts, []); 10042 this.externalStyles = result.STYLE.reduce(externalStyles, []); 10043 this.settingsScripts = fetchExtensionSettings(result.HTML); 10044 } 10045 10046 babelHelpers.createClass(Extension, [{ 10047 key: "load", 10048 value: function load() { 10049 var _this = this; 10050 10051 if (this.state === 'error') { 10052 this.loadPromise = this.loadPromise || Promise.resolve(this); 10053 console.warn('Extension', this.name, 'not found'); 10054 } 10055 10056 if (!this.loadPromise && this.state) { 10057 this.state = 'load';
10058 this.settingsScripts.forEach(function (entry) { 10059 var isLoaded = !!document.querySelector("script[data-extension=\"".concat(entry.extension, "\"]")); 10060 10061 if (!isLoaded) { 10062 document.body.insertAdjacentHTML('beforeend', entry.script); 10063 } 10064 }); 10065 this.inlineScripts.forEach(BX.evalGlobal); 10066 this.loadPromise = Promise.all([loadAll(this.externalScripts), loadAll(this.externalStyles)]).then(function () { 10067 _this.state = 'loaded'; 10068 10069 if (Type.isPlainObject(_this.config) && _this.config.namespace) { 10070 return Reflection.getClass(_this.config.namespace); 10071 } 10072 10073 return window; 10074 }); 10075 } 10076 10077 return this.loadPromise; 10078 } 10079 }]); 10080 return Extension; 10081 }(); 10082 10083 var initialized = {}; 10084 var ajaxController = 'main.bitrix.main.controller.loadext.getextensions'; 10085 10086 function makeIterable(value) { 10087 return Type.isArray(value) ? value : [value]; 10088 } 10089 function isInitialized(extension) { 10090 return extension in initialized; 10091 } 10092 function getInitialized(extension) { 10093 return initialized[extension]; 10094 } 10095 function isAllInitialized(extensions) { 10096 return extensions.every(isInitialized); 10097 } 10098 function loadExtensions(extensions) { 10099 return Promise.all(extensions.map(function (item) { 10100 return item.load(); 10101 })); 10102 } 10103 function mergeExports(exports) { 10104 return exports.reduce(function (acc, currentExports) { 10105 if (Type.isObject(currentExports)) { 10106 return babelHelpers.objectSpread({}, currentExports); 10107 } 10108 10109 return currentExports; 10110 }, {}); 10111 } 10112 function inlineScripts(acc, item) { 10113 if (item.isInternal) { 10114 acc.push(item.JS); 10115 } 10116 10117 return acc; 10118 } 10119 function externalScripts(acc, item) { 10120 if (!item.isInternal) { 10121 acc.push(item.JS); 10122 } 10123 10124 return acc; 10125 } 10126 function externalStyles(acc, item) { 10127 if (Type.isString(item) && item !== '') { 10128 acc.push(item); 10129 } 10130 10131 return acc; 10132 } 10133 function request(options) { 10134 return new Promise(function (resolve) { 10135 // eslint-disable-next-line 10136 BX.ajax.runAction(ajaxController, { 10137 data: options 10138 }).then(resolve); 10139 }); 10140 } 10141 function prepareExtensions(response) { 10142 if (response.status !== 'success') { 10143 response.errors.map(console.warn); 10144 return []; 10145 } 10146 10147 return response.data.map(function (item) { 10148 var initializedExtension = getInitialized(item.extension); 10149 10150 if (initializedExtension) { 10151 return initializedExtension; 10152 } 10153 10154 initialized[item.extension] = new Extension(item); 10155 return initialized[item.extension]; 10156 }); 10157 } 10158 function loadAll(items) { 10159 var itemsList = makeIterable(items); 10160 10161 if (!itemsList.length) { 10162 return Promise.resolve(); 10163 } 10164 10165 return new Promise(function (resolve) { 10166 // eslint-disable-next-line 10167 BX.load(itemsList, resolve); 10168 }); 10169 } 10170 10171 /** 10172 * Loads extensions asynchronously 10173 * @param {string|Array<string>} extension 10174 * @return {Promise<Array<Extension>>} 10175 */ 10176 function loadExtension(extension) { 10177 var extensions = makeIterable(extension); 10178 var isAllInitialized$$1 = isAllInitialized(extensions); 10179 10180 if (isAllInitialized$$1) { 10181 var initializedExtensions = extensions.map(getInitialized); 10182 return loadExtensions(initializedExtensions).then(mergeExports); 10183 } 10184 10185 return request({ 10186 extension: extensions 10187 }).then(prepareExtensions).then(loadExtensions).then(mergeExports); 10188 } 10189 10190 var cloneableTags = ['[object Object]', '[object Array]', '[object RegExp]', '[object Arguments]', '[object Date]', '[object Error]', '[object Map]', '[object Set]', '[object ArrayBuffer]', '[object DataView]', '[object Float32Array]', '[object Float64Array]', '[object Int8Array]', '[object Int16Array]', '[object Int32Array]', '[object Uint8Array]', '[object Uint16Array]', '[object Uint32Array]', '[object Uint8ClampedArray]']; 10191 10192 function isCloneable(value) { 10193 var isCloneableValue = Type.isObjectLike(value) && cloneableTags.includes(getTag(value)); 10194 return isCloneableValue || Type.isDomNode(value); 10195 } 10196 10197 function internalClone(value, map) { 10198 if (map.has(value)) { 10199 return map.get(value); 10200 } 10201 10202 if (isCloneable(value)) { 10203 if (Type.isArray(value)) { 10204 var cloned = Array.from(value); 10205 map.set(value, cloned); 10206 value.forEach(function (item, index) { 10207 cloned[index] = internalClone(item, map); 10208 }); 10209 return map.get(value); 10210 } 10211 10212 if (Type.isDomNode(value)) { 10213 return value.cloneNode(true); 10214 } 10215 10216 if (Type.isMap(value)) { 10217 var _result = new Map(); 10218 10219 map.set(value, _result); 10220 value.forEach(function (item, key) { 10221 _result.set(internalClone(key, map), internalClone(item, map)); 10222 }); 10223 return _result; 10224 } 10225 10226 if (Type.isSet(value)) { 10227 var _result2 = new Set(); 10228 10229 map.set(value, _result2); 10230 value.forEach(function (item) { 10231 _result2.add(internalClone(item, map)); 10232 }); 10233 return _result2; 10234 } 10235 10236 if (Type.isDate(value)) { 10237 return new Date(value); 10238 } 10239 10240 if (Type.isRegExp(value)) { 10241 var regExpFlags = /\w*$/; 10242 var flags = regExpFlags.exec(value); 10243 10244 var _result3 = new RegExp(value.source); 10245 10246 if (flags && Type.isArray(flags)) { 10247 _result3 = new RegExp(value.source, flags[0]); 10248 } 10249 10250 _result3.lastIndex = value.lastIndex; 10251 return _result3; 10252 } 10253 10254 var proto = Object.getPrototypeOf(value); 10255 var result = Object.assign(Object.create(proto), value); 10256 map.set(value, result); 10257 Object.keys(value).forEach(function (key) { 10258 result[key] = internalClone(value[key], map); 10259 }); 10260 return result; 10261 } 10262 10263 return value; 10264 }
10265 /** 10266 * Clones any cloneable object 10267 * @param value 10268 * @return {*} 10269 */ 10270 10271 function clone(value) { 10272 return internalClone(value, new WeakMap()); 10273 } 10274 10275 function merge(current, target) { 10276 return Object.entries(target).reduce(function (acc, _ref) { 10277 var _ref2 = babelHelpers.slicedToArray(_ref, 2), 10278 key = _ref2[0], 10279 value = _ref2[1]; 10280 10281 if (!Type.isDomNode(acc[key]) && Type.isObjectLike(acc[key]) && Type.isObjectLike(value)) { 10282 acc[key] = merge(acc[key], value); 10283 return acc; 10284 } 10285 10286 acc[key] = value; 10287 return acc; 10288 }, current); 10289 } 10290 10291 function createComparator(fields) { 10292 var orders = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; 10293 return function (a, b) { 10294 var field = fields[0]; 10295 var order = orders[0] || 'asc'; 10296 10297 if (Type.isUndefined(field)) { 10298 return 0; 10299 } 10300 10301 var valueA = a[field]; 10302 var valueB = b[field]; 10303 10304 if (Type.isString(valueA) && Type.isString(valueB)) { 10305 valueA = valueA.toLowerCase(); 10306 valueB = valueB.toLowerCase(); 10307 } 10308 10309 if (valueA < valueB) { 10310 return order === 'asc' ? -1 : 1; 10311 } 10312 10313 if (valueA > valueB) { 10314 return order === 'asc' ? 1 : -1; 10315 } 10316 10317 return createComparator(fields.slice(1), orders.slice(1))(a, b); 10318 }; 10319 } 10320 10321 /** 10322 * @memberOf BX 10323 */ 10324 10325 var Runtime = /*#__PURE__*/function () { 10326 function Runtime() { 10327 babelHelpers.classCallCheck(this, Runtime); 10328 } 10329 10330 babelHelpers.createClass(Runtime, null, [{ 10331 key: "debounce", 10332 value: function debounce(func) { 10333 var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; 10334 var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 10335 var timeoutId; 10336 return function debounced() { 10337 var _this = this; 10338 10339 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 10340 args[_key] = arguments[_key]; 10341 } 10342 10343 if (Type.isNumber(timeoutId)) { 10344 clearTimeout(timeoutId); 10345 } 10346 10347 timeoutId = setTimeout(function () { 10348 func.apply(context || _this, args); 10349 }, wait); 10350 }; 10351 } 10352 }, { 10353 key: "throttle", 10354 value: function throttle(func) { 10355 var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; 10356 var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 10357 var timer = 0; 10358 var invoke; 10359 return function wrapper() { 10360 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 10361 args[_key2] = arguments[_key2]; 10362 } 10363 10364 invoke = true; 10365 10366 if (!timer) { 10367 var q = function q() { 10368 if (invoke) { 10369 func.apply(context || this, args); 10370 invoke = false; 10371 timer = setTimeout(q, wait); 10372 } else { 10373 timer = null; 10374 } 10375 }; 10376 10377 q(); 10378 } 10379 }; 10380 } 10381 }, { 10382 key: "html", 10383 value: function html(node, _html) { 10384 var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; 10385 10386 if (Type.isNil(_html) && Type.isDomNode(node)) { 10387 return node.innerHTML; 10388 } // eslint-disable-next-line 10389 10390 10391 var parsedHtml = BX.processHTML(_html); 10392 var externalCss = parsedHtml.STYLE.reduce(externalStyles, []); 10393 var externalJs = parsedHtml.SCRIPT.reduce(externalScripts, []); 10394 var inlineJs = parsedHtml.SCRIPT.reduce(inlineScripts, []); 10395 10396 if (Type.isDomNode(node)) { 10397 if (params.htmlFirst || !externalJs.length && !externalCss.length) { 10398 if (params.useAdjacentHTML) { 10399 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 10400 } else { 10401 node.innerHTML = parsedHtml.HTML; 10402 } 10403 } 10404 } 10405 10406 return Promise.all([loadAll(externalJs), loadAll(externalCss)]).then(function () { 10407 if (Type.isDomNode(node) && (externalJs.length > 0 || externalCss.length > 0)) { 10408 if (params.useAdjacentHTML) { 10409 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 10410 } else { 10411 node.innerHTML = parsedHtml.HTML; 10412 } 10413 } // eslint-disable-next-line 10414 10415
10416 inlineJs.forEach(function (script) { 10417 return BX.evalGlobal(script); 10418 }); 10419 10420 if (Type.isFunction(params.callback)) { 10421 params.callback(); 10422 } 10423 }); 10424 } 10425 /** 10426 * Merges objects or arrays 10427 * @param targets 10428 * @return {any} 10429 */ 10430 10431 }, { 10432 key: "merge", 10433 value: function merge$$1() { 10434 for (var _len3 = arguments.length, targets = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { 10435 targets[_key3] = arguments[_key3]; 10436 } 10437 10438 if (Type.isArray(targets[0])) { 10439 targets.unshift([]); 10440 } else if (Type.isObject(targets[0])) { 10441 targets.unshift({}); 10442 } 10443 10444 return targets.reduce(function (acc, item) { 10445 return merge(acc, item); 10446 }, targets[0]); 10447 } 10448 }, { 10449 key: "orderBy", 10450 value: function orderBy(collection) { 10451 var fields = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; 10452 var orders = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; 10453 var comparator = createComparator(fields, orders); 10454 return Object.values(collection).sort(comparator); 10455 } 10456 }, { 10457 key: "destroy", 10458 value: function destroy(target) { 10459 var errorMessage = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Object is destroyed'; 10460 10461 if (Type.isObject(target)) { 10462 var onPropertyAccess = function onPropertyAccess() { 10463 throw new Error(errorMessage); 10464 }; 10465 10466 var ownProperties = Object.keys(target); 10467 10468 var prototypeProperties = function () { 10469 var targetPrototype = Object.getPrototypeOf(target); 10470 10471 if (Type.isObject(targetPrototype)) { 10472 return Object.getOwnPropertyNames(targetPrototype); 10473 } 10474 10475 return []; 10476 }(); 10477 10478 var uniquePropertiesList = babelHelpers.toConsumableArray(new Set([].concat(babelHelpers.toConsumableArray(ownProperties), babelHelpers.toConsumableArray(prototypeProperties)))); 10479 uniquePropertiesList.filter(function (name) { 10480 var descriptor = Object.getOwnPropertyDescriptor(target, name); 10481 return !/__(.+)__/.test(name) && (!Type.isObject(descriptor) || descriptor.configurable === true); 10482 }
10482).forEach(function (name) { 10483 Object.defineProperty(target, name, { 10484 get: onPropertyAccess, 10485 set: onPropertyAccess, 10486 configurable: false 10487 }); 10488 }); 10489 Object.setPrototypeOf(target, null); 10490 } 10491 } 10492 }]); 10493 return Runtime; 10494 }(); 10495 10496 babelHelpers.defineProperty(Runtime, "debug", debug); 10497 babelHelpers.defineProperty(Runtime, "loadExtension", loadExtension); 10498 babelHelpers.defineProperty(Runtime, "clone", clone); 10499 10500 var _isError = Symbol.for('BX.BaseError.isError'); 10501 /** 10502 * @memberOf BX 10503 */ 10504 10505 10506 var BaseError = /*#__PURE__*/function () { 10507 function BaseError(message, code, customData) { 10508 babelHelpers.classCallCheck(this, BaseError); 10509 this[_isError] = true; 10510 this.message = ''; 10511 this.code = null; 10512 this.customData = null; 10513 this.setMessage(message); 10514 this.setCode(code); 10515 this.setCustomData(customData); 10516 } 10517 /** 10518 * Returns a brief description of the error 10519 * @returns {string} 10520 */ 10521 10522 10523 babelHelpers.createClass(BaseError, [{ 10524 key: "getMessage", 10525 value: function getMessage() { 10526 return this.message; 10527 } 10528 /** 10529 * Sets a message of the error 10530 * @param {string} message 10531 * @returns {this} 10532 */ 10533 10534 }, { 10535 key: "setMessage", 10536 value: function setMessage(message) { 10537 if (Type.isString(message)) { 10538 this.message = message; 10539 } 10540 10541 return this; 10542 } 10543 /** 10544 * Returns a code of the error 10545 * @returns {?string} 10546 */ 10547 10548 }, { 10549 key: "getCode", 10550 value: function getCode() { 10551 return this.code; 10552 } 10553 /** 10554 * Sets a code of the error 10555 * @param {string} code 10556 * @returns {this} 10557 */ 10558 10559 }, { 10560 key: "setCode", 10561 value: function setCode(code) { 10562 if (Type.isStringFilled(code) || code === null) { 10563 this.code = code; 10564 } 10565 10566 return this; 10567 } 10568 /** 10569 * Returns custom data of the error 10570 * @returns {null|*} 10571 */ 10572 10573 }, { 10574 key: "getCustomData", 10575 value: function getCustomData() { 10576 return this.customData; 10577 } 10578 /** 10579 * Sets custom data of the error 10580 * @returns {this} 10581 */ 10582 10583 }, { 10584 key: "setCustomData", 10585 value: function setCustomData(customData) { 10586 if (!Type.isUndefined(customData)) { 10587 this.customData = customData; 10588 } 10589 10590 return this; 10591 } 10592 }, { 10593 key: "toString", 10594 value: function toString() { 10595 var code = this.getCode(); 10596 var message = this.getMessage(); 10597 10598 if (!Type.isStringFilled(code) && !Type.isStringFilled(message)) { 10599 return ''; 10600 } else if (!Type.isStringFilled(code)) { 10601 return "Error: ".concat(message); 10602 } else if (!Type.isStringFilled(message)) { 10603 return code; 10604 } else { 10605 return "".concat(code, ": ").concat(message); 10606 } 10607 } 10608 /** 10609 * Returns true if the object is an instance of BaseError 10610 * @param error 10611 * @returns {boolean} 10612 */ 10613 10614 }], [{ 10615 key: "isError", 10616 value: function isError(error) { 10617 return Type.isObject(error) && error[_isError] === true; 10618 } 10619 }]); 10620 return BaseError; 10621 }(); 10622 10623 /** 10624 * Implements base event object interface 10625 */ 10626 10627 var BaseEvent = /*#__PURE__*/function () { 10628 function BaseEvent() { 10629 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { 10630 data: {} 10631 }; 10632 babelHelpers.classCallCheck(this, BaseEvent); 10633 this.type = ''; 10634 this.data = null; 10635 this.target = null; 10636 this.compatData = null; 10637 this.defaultPrevented = false; 10638 this.immediatePropagationStopped = false; 10639 this.errors = []; 10640 this.setData(options.data); 10641 this.setCompatData(options.compatData); 10642 } 10643 10644 babelHelpers.createClass(BaseEvent, [{ 10645 key: "getType", 10646 10647 /** 10648 * Returns the name of the event 10649 * @returns {string} 10650 */ 10651 value: function getType() { 10652 return this.type; 10653 } 10654 /** 10655 * 10656 * @param {string} type 10657 */ 10658 10659 }, { 10660 key: "setType", 10661 value: function setType(type) { 10662 if (Type.isStringFilled(type)) { 10663 this.type = type; 10664 } 10665 10666 return this; 10667 } 10668 /** 10669 * Returns an event data 10670 */ 10671 10672 }, { 10673 key: "getData", 10674 value: function getData() { 10675 return this.data; 10676 } 10677 /** 10678 * Sets an event data 10679 * @param data 10680 */ 10681 10682 }, { 10683 key: "setData", 10684 value: function setData(data) { 10685 if (!Type.isUndefined(data)) { 10686 this.data = data; 10687 } 10688 10689 return this; 10690 } 10691 /** 10692 * Returns arguments for BX.addCustomEvent handlers (deprecated). 10693 * @returns {array | null} 10694 */ 10695 10696 }, { 10697 key: "getCompatData", 10698 value: function getCompatData() { 10699 return this.compatData; 10700 } 10701 /** 10702 * Sets arguments for BX.addCustomEvent handlers (deprecated) 10703 * @param data 10704 */ 10705 10706 }, { 10707 key: "setCompatData", 10708 value: function setCompatData(data) { 10709 if (Type.isArrayLike(data)) { 10710 this.compatData = data; 10711 } 10712 10713 return this; 10714 } 10715 /** 10716 * Sets a event target 10717 * @param target 10718 */ 10719 10720 }, { 10721 key: "setTarget", 10722 value: function setTarget(target) { 10723 this.target = target; 10724 return this; 10725 } 10726 /** 10727 * Returns a event target 10728 */ 10729 10730 }, { 10731 key: "getTarget", 10732 value: function getTarget() { 10733 return this.target; 10734 } 10735 /** 10736 * Returns an array of event errors 10737 * @returns {[]} 10738 */ 10739 10740 }, { 10741 key: "getErrors", 10742 value: function getErrors() { 10743 return this.errors; 10744 } 10745 /** 10746 * Adds an error of the event. 10747 * Event listeners can prevent emitter's default action and set the reason of this behavior. 10748 * @param error 10749 */ 10750 10751 }, { 10752 key: "setError", 10753 value: function setError(error) { 10754 if (BaseError.isError(error)) { 10755 this.errors.push(error); 10756 } 10757 } 10758 /** 10759 * Prevents default action 10760 */ 10761 10762 }, { 10763 key: "preventDefault", 10764 value: function preventDefault() { 10765 this.defaultPrevented = true; 10766 } 10767 /** 10768 * Checks that is default action prevented 10769 * @return {boolean} 10770 */ 10771 10772 }, { 10773 key: "isDefaultPrevented", 10774 value: function isDefaultPrevented() { 10775 return this.defaultPrevented; 10776 } 10777 /** 10778 * Stops event immediate propagation 10779 */ 10780 10781 }, { 10782 key: "stopImmediatePropagation", 10783 value: function stopImmediatePropagation() { 10784 this.immediatePropagationStopped = true; 10785 } 10786 /** 10787 * Checks that is immediate propagation stopped 10788 * @return {boolean} 10789 */ 10790 10791 }, { 10792 key: "isImmediatePropagationStopped", 10793 value: function isImmediatePropagationStopped() { 10794 return this.immediatePropagationStopped; 10795 } 10796 }], [{ 10797 key: "create", 10798 value: function create(options) { 10799 return new this(options); 10800 } 10801 }]); 10802 return BaseEvent; 10803 }(); 10804 10805 var EventStore = /*#__PURE__*/function () { 10806 function EventStore() { 10807 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 10808 babelHelpers.classCallCheck(this, EventStore); 10809 this.defaultMaxListeners = Type.isNumber(options.defaultMaxListeners) ? options.defaultMaxListeners : 10; 10810 this.eventStore = new WeakMap(); 10811 } 10812 10813 babelHelpers.createClass(EventStore, [{ 10814 key: "add", 10815 value: function add(target) { 10816 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 10817 var record = this.getRecordScheme(); 10818 10819 if (Type.isNumber(options.maxListeners)) { 10820 record.maxListeners = options.maxListeners; 10821 } 10822 10823 this.eventStore.set(target, record); 10824 return record; 10825 } 10826 }, { 10827 key: "get", 10828 value: function get(target) { 10829 return this.eventStore.get(target); 10830 } 10831 }, { 10832 key: "getOrAdd", 10833 value: function getOrAdd(target) { 10834 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 10835 return this.get(target) || this.add(target, options); 10836 } 10837 }, { 10838 key: "delete", 10839 value: function _delete(context) { 10840 this.eventStore.delete(context); 10841 } 10842 }, { 10843 key: "getRecordScheme", 10844 value: function getRecordScheme() { 10845 return { 10846 eventsMap: new Map(), 10847 onceMap: new Map(), 10848 maxListeners: this.getDefaultMaxListeners(), 10849 eventsMaxListeners: new Map() 10850 }; 10851 } 10852 }, { 10853 key: "getDefaultMaxListeners", 10854 value: function getDefaultMaxListeners() { 10855 return this.defaultMaxListeners; 10856 } 10857 }]); 10858 return EventStore; 10859 }(); 10860 10861 var WarningStore = /*#__PURE__*/function () {
10862 function WarningStore() { 10863 babelHelpers.classCallCheck(this, WarningStore); 10864 this.warnings = new Map(); 10865 this.printDelayed = Runtime.debounce(this.print.bind(this), 500); 10866 } 10867 10868 babelHelpers.createClass(WarningStore, [{ 10869 key: "add", 10870 value: function add(target, eventName, listeners) { 10871 var contextWarnings = this.warnings.get(target); 10872 10873 if (!contextWarnings) { 10874 contextWarnings = Object.create(null); 10875 this.warnings.set(target, contextWarnings); 10876 } 10877 10878 if (!contextWarnings[eventName]) { 10879 contextWarnings[eventName] = {}; 10880 } 10881 10882 contextWarnings[eventName].size = listeners.size; 10883 10884 if (!Type.isArray(contextWarnings[eventName].errors)) { 10885 contextWarnings[eventName].errors = []; 10886 } 10887 10888 contextWarnings[eventName].errors.push(new Error()); 10889 } 10890 }, { 10891 key: "print", 10892 value: function print() { 10893 this.warnings.forEach(function (warnings) { 10894 for (var eventName in warnings) { 10895 console.groupCollapsed('Possible BX.Event.EventEmitter memory leak detected. ' + warnings[eventName].size + ' "' + eventName + '" listeners added. ' + 'Use emitter.setMaxListeners() to increase limit.'); 10896 console.dir(warnings[eventName].errors); 10897 console.groupEnd(); 10898 } 10899 }); 10900 this.clear(); 10901 } 10902 }, { 10903 key: "clear", 10904 value: function clear() { 10905 this.warnings.clear(); 10906 } 10907 }, { 10908 key: "printDelayed", 10909 value: function printDelayed() {} 10910 }]); 10911 return WarningStore; 10912 }(); 10913 10914 var eventStore = new EventStore({ 10915 defaultMaxListeners: 10 10916 }); 10917 var warningStore = new WarningStore(); 10918 var aliasStore = new Map(); 10919 var globalTarget = { 10920 GLOBAL_TARGET: 'GLOBAL_TARGET' // this key only for debugging purposes 10921 10922 }; 10923 eventStore.add(globalTarget, { 10924 maxListeners: 25 10925 }); 10926 var isEmitterProperty = Symbol.for('BX.Event.EventEmitter.isEmitter'); 10927 var namespaceProperty = Symbol('namespaceProperty'); 10928 var targetProperty = Symbol('targetProperty'); 10929 10930 var EventEmitter = /*#__PURE__*/function () { 10931 /** @private */ 10932 function EventEmitter() { 10933 babelHelpers.classCallCheck(this, EventEmitter); 10934 this[targetProperty] = null; 10935 this[namespaceProperty] = null; 10936 this[isEmitterProperty] = true; 10937 var target = this; 10938 10939 if (Object.getPrototypeOf(this) === EventEmitter.prototype && arguments.length > 0) //new EventEmitter(obj) case 10940 { 10941 if (!Type.isObject(arguments.length <= 0 ? undefined : arguments[0])) { 10942 throw new TypeError("The \"target\" argument must be an object."); 10943 } 10944 10945 target = arguments.length <= 0 ? undefined : arguments[0]; 10946 this.setEventNamespace(arguments.length <= 1 ? undefined : arguments[1]); 10947 } 10948 10949 this[targetProperty] = target; 10950 } 10951 /** 10952 * Makes a target observable 10953 * @param {object} target 10954 * @param {string} namespace 10955 */ 10956 10957 10958 babelHelpers.createClass(EventEmitter, [{ 10959 key: "setEventNamespace", 10960 value: function setEventNamespace(namespace) { 10961 if (Type.isStringFilled(namespace)) { 10962 this[namespaceProperty] = namespace; 10963 } 10964 } 10965 }, { 10966 key: "getEventNamespace", 10967 value: function getEventNamespace() { 10968 return this[namespaceProperty]; 10969 } 10970 /** 10971 * Subscribes listener on specified global event 10972 * @param {object} target 10973 * @param {string} eventName 10974 * @param {Function<BaseEvent>} listener 10975 * @param {object} options 10976 */ 10977 10978 }, { 10979 key: "subscribe", 10980 10981 /** 10982 * Subscribes a listener on a specified event 10983 * @param {string} eventName 10984 * @param {Function<BaseEvent>} listener 10985 * @return {this} 10986 */ 10987 value: function subscribe(eventName, listener) { 10988 EventEmitter.subscribe(this, eventName, listener); 10989 return this; 10990 } 10991 /** 10992 * 10993 * @param {object} options 10994 * @param {object} [aliases] 10995 * @param {boolean} [compatMode=false] 10996 */ 10997 10998 }, { 10999 key: "subscribeFromOptions", 11000 value: function subscribeFromOptions(options, aliases, compatMode) { 11001 var _this = this; 11002 11003 if (!Type.isPlainObject(options)) { 11004 return; 11005 } 11006 11007 aliases = Type.isPlainObject(aliases) ? EventEmitter.normalizeAliases(aliases) : {};
11008 Object.keys(options).forEach(function (eventName) { 11009 var listener = options[eventName]; 11010 11011 if (!Type.isFunction(listener)) { 11012 throw new TypeError("The \"listener\" argument must be of type Function. Received type ".concat(babelHelpers.typeof(listener), ".")); 11013 } 11014 11015 eventName = EventEmitter.normalizeEventName(eventName); 11016 11017 if (aliases[eventName]) { 11018 var actualName = aliases[eventName].eventName; 11019 EventEmitter.subscribe(_this, actualName, listener, { 11020 compatMode: compatMode !== false 11021 }); 11022 } else { 11023 EventEmitter.subscribe(_this, eventName, listener, { 11024 compatMode: compatMode === true 11025 }); 11026 } 11027 }); 11028 } 11029 /** 11030 * Subscribes a listener that is called at 11031 * most once for a specified event. 11032 * @param {object} target 11033 * @param {string} eventName 11034 * @param {Function<BaseEvent>} listener 11035 */ 11036 11037 }, { 11038 key: "subscribeOnce", 11039 11040 /** 11041 * Subscribes a listener that is called at most once for a specified event. 11042 * @param {string} eventName 11043 * @param {Function<BaseEvent>} listener 11044 * @return {this} 11045 */ 11046 value: function subscribeOnce(eventName, listener) { 11047 EventEmitter.subscribeOnce(this, eventName, listener); 11048 return this; 11049 } 11050 /** 11051 * Unsubscribes an event listener 11052 * @param {object} target 11053 * @param {string} eventName 11054 * @param {Function<BaseEvent>} listener 11055 * @param options 11056 */ 11057 11058 }, { 11059 key: "unsubscribe", 11060 11061 /** 11062 * Unsubscribes an event listener 11063 * @param {string} eventName 11064 * @param {Function<BaseEvent>} listener 11065 * @return {this} 11066 */ 11067 value: function unsubscribe(eventName, listener) { 11068 EventEmitter.unsubscribe(this, eventName, listener); 11069 return this; 11070 } 11071 /** 11072 * Unsubscribes all event listeners 11073 * @param {object} target 11074 * @param {string} eventName 11075 * @param options 11076 */ 11077 11078 }, { 11079 key: "unsubscribeAll", 11080 11081 /** 11082 * Unsubscribes all event listeners 11083 * @param {string} [eventName] 11084 */ 11085 value: function unsubscribeAll(eventName) { 11086 EventEmitter.unsubscribeAll(this, eventName); 11087 } 11088 /** 11089 * 11090 * @param {object} target 11091 * @param {string} eventName 11092 * @param {BaseEvent | any} event 11093 * @param {object} options 11094 * @returns {Array} 11095 */ 11096 11097 }, { 11098 key: "emit", 11099 11100 /** 11101 * Emits specified event with specified event object 11102 * @param {string} eventName 11103 * @param {BaseEvent | any} event 11104 * @return {this} 11105 */ 11106 value: function emit(eventName, event) { 11107 if (this.getEventNamespace() === null) { 11108 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 11109 } 11110 11111 EventEmitter.emit(this, eventName, event); 11112 return this; 11113 } 11114 /** 11115 * Emits global event and returns a promise that is resolved when 11116 * all promise returned from event handlers are resolved, 11117 * or rejected when at least one of the returned promise is rejected. 11118 * Importantly. You can return any value from synchronous handlers, not just promise 11119 * @param {object} target 11120 * @param {string} eventName 11121 * @param {BaseEvent | any} event 11122 * @return {Promise<Array>} 11123 */ 11124 11125 }, { 11126 key: "emitAsync", 11127 11128 /** 11129 * Emits event and returns a promise that is resolved when 11130 * all promise returned from event handlers are resolved, 11131 * or rejected when at least one of the returned promise is rejected. 11132 * Importantly. You can return any value from synchronous handlers, not just promise 11133 * @param {string} eventName 11134 * @param {BaseEvent|any} event 11135 * @return {Promise<Array>} 11136 */ 11137 value: function emitAsync(eventName, event) { 11138 if (this.getEventNamespace() === null) { 11139 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 11140 } 11141 11142 return EventEmitter.emitAsync(this, eventName, event); 11143 } 11144 /** 11145 * @private 11146 * @param {object} target 11147 * @param {string} eventName 11148 * @param {BaseEvent|any} event 11149 * @returns {BaseEvent} 11150 */ 11151 11152 }, { 11153 key: "setMaxListeners", 11154 11155 /** 11156 * Sets max events listeners count 11157 * this.setMaxListeners(10) - sets the default value for all events
11158 * this.setMaxListeners("onClose", 10) sets the value for onClose event 11159 * @return {this} 11160 * @param args 11161 */ 11162 value: function setMaxListeners() { 11163 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 11164 args[_key] = arguments[_key]; 11165 } 11166 11167 EventEmitter.setMaxListeners.apply(EventEmitter, [this].concat(args)); 11168 return this; 11169 } 11170 /** 11171 * Returns max event listeners count 11172 * @param {object} target 11173 * @param {string} [eventName] 11174 * @returns {number} 11175 */ 11176 11177 }, { 11178 key: "getMaxListeners", 11179 11180 /** 11181 * Returns max event listeners count 11182 * @param {string} [eventName] 11183 * @returns {number} 11184 */ 11185 value: function getMaxListeners(eventName) { 11186 return EventEmitter.getMaxListeners(this, eventName); 11187 } 11188 /** 11189 * Adds or subtracts max listeners count 11190 * Event.EventEmitter.addMaxListeners() - adds one max listener for all events of global target 11191 * Event.EventEmitter.addMaxListeners(3) - adds three max listeners for all events of global target 11192 * Event.EventEmitter.addMaxListeners(-1) - subtracts one max listener for all events of global target 11193 * Event.EventEmitter.addMaxListeners('onClose') - adds one max listener for onClose event of global target 11194 * Event.EventEmitter.addMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 11195 * Event.EventEmitter.addMaxListeners('onClose', -1) - subtracts one max listener for onClose event of global target 11196 * 11197 * Event.EventEmitter.addMaxListeners(obj) - adds one max listener for all events of 'obj' target 11198 * Event.EventEmitter.addMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 11199 * Event.EventEmitter.addMaxListeners(obj, -1) - subtracts one max listener for all events of 'obj' target 11200 * Event.EventEmitter.addMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 11201 * Event.EventEmitter.addMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 11202 * Event.EventEmitter.addMaxListeners(obj, 'onClose', -1) - subtracts one max listener for onClose event of 'obj' target 11203 * @param args 11204 * @returns {number} 11205 */ 11206 11207 }, { 11208 key: "incrementMaxListeners", 11209 11210 /** 11211 * Increases max listeners count 11212 * this.incrementMaxListeners() - adds one max listener for all events 11213 * this.incrementMaxListeners(3) - adds three max listeners for all events 11214 * this.incrementMaxListeners('onClose') - adds one max listener for onClose event 11215 * this.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event 11216 */ 11217 value: function incrementMaxListeners() { 11218 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 11219 args[_key2] = arguments[_key2]; 11220 } 11221 11222 return EventEmitter.incrementMaxListeners.apply(EventEmitter, [this].concat(args)); 11223 } 11224 /** 11225 * Decreases max listeners count 11226 * 11227 * Event.EventEmitter.decrementMaxListeners() - subtracts one max listener for all events of global target 11228 * Event.EventEmitter.decrementMaxListeners(3) - subtracts three max listeners for all events of global target 11229 * Event.EventEmitter.decrementMaxListeners('onClose') - subtracts one max listener for onClose event of global target 11230 * Event.EventEmitter.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event of global target 11231 * 11232 * Event.EventEmitter.decrementMaxListeners(obj) - subtracts one max listener for all events of 'obj' target 11233 * Event.EventEmitter.decrementMaxListeners(obj, 3) - subtracts three max listeners for all events of 'obj' target 11234 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose') - subtracts one max listener for onClose event of 'obj' target 11235 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose', 2) - subtracts two max listeners for onClose event of 'obj' target 11236 */ 11237 11238 }, { 11239 key: "decrementMaxListeners", 11240 11241 /** 11242 * Increases max listeners count 11243 * this.decrementMaxListeners() - subtracts one max listener for all events 11244 * this.decrementMaxListeners(3) - subtracts three max listeners for all events 11245 * this.decrementMaxListeners('onClose') - subtracts one max listener for onClose event 11246 * this.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event 11247 */ 11248 value: function decrementMaxListeners() { 11249 for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { 11250 args[_key3] = arguments[_key3]; 11251 } 11252 11253 return EventEmitter.decrementMaxListeners.apply(EventEmitter, [this].concat(args)); 11254 } 11255 /** 11256 * @private 11257 * @param {Array} args 11258 * @returns Array 11259 */ 11260 11261 }, { 11262 key: "getListeners", 11263 11264 /** 11265 * Gets listeners list for specified event 11266 * @param {string} eventName 11267 */ 11268 value: function getListeners(eventName) { 11269 return EventEmitter.getListeners(this, eventName); 11270 } 11271 /** 11272 * Returns a full event name with namespace 11273 * @param {string} eventName 11274 * @returns {string} 11275 */ 11276 11277 }, { 11278 key: "getFullEventName", 11279 value: function getFullEventName(eventName) { 11280 if (!Type.isStringFilled(eventName)) { 11281 throw new TypeError("The \"eventName\" argument must be a string."); 11282 } 11283 11284 return EventEmitter.makeFullEventName(this.getEventNamespace(), eventName); 11285 } 11286 /** 11287 * Registers aliases (old event names for BX.onCustomEvent) 11288 * @param aliases 11289 */ 11290 11291 }], [{ 11292 key: "makeObservable", 11293 value: function makeObservable(target, namespace) { 11294 if (!Type.isObject(target)) { 11295 throw new TypeError('The "target" argument must be an object.'); 11296 } 11297 11298 if (!Type.isStringFilled(namespace)) { 11299 throw new TypeError('The "namespace" must be an non-empty string.'); 11300 } 11301 11302 if (EventEmitter.isEventEmitter(target)) { 11303 throw new TypeError('The "target" is an event emitter already.'); 11304 } 11305 11306 var targetProto = Object.getPrototypeOf(target); 11307 var emitter = new EventEmitter(); 11308 emitter.setEventNamespace(namespace); 11309 Object.setPrototypeOf(emitter, targetProto); 11310 Object.setPrototypeOf(target, emitter); 11311 Object.getOwnPropertyNames(EventEmitter.prototype).forEach(function (method) {
11312 if (['constructor'].includes(method)) { 11313 return; 11314 } 11315 11316 emitter[method] = function () { 11317 for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { 11318 args[_key4] = arguments[_key4]; 11319 } 11320 11321 return EventEmitter.prototype[method].apply(target, args); 11322 }; 11323 }); 11324 } 11325 }, { 11326 key: "subscribe", 11327 value: function subscribe(target, eventName, listener, options) { 11328 if (Type.isString(target)) { 11329 options = listener; 11330 listener = eventName; 11331 eventName = target; 11332 target = this.GLOBAL_TARGET; 11333 } 11334 11335 if (!Type.isObject(target)) { 11336 throw new TypeError("The \"target\" argument must be an object."); 11337 } 11338 11339 eventName = this.normalizeEventName(eventName); 11340 11341 if (!Type.isStringFilled(eventName)) { 11342 throw new TypeError("The \"eventName\" argument must be a string."); 11343 } 11344 11345 if (!Type.isFunction(listener)) { 11346 throw new TypeError("The \"listener\" argument must be of type Function. Received type ".concat(babelHelpers.typeof(listener), ".")); 11347 } 11348 11349 options = Type.isPlainObject(options) ? options : {}; 11350 var fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 11351 11352 var _eventStore$getOrAdd = eventStore.getOrAdd(target), 11353 eventsMap = _eventStore$getOrAdd.eventsMap, 11354 onceMap = _eventStore$getOrAdd.onceMap; 11355 11356 var onceListeners = onceMap.get(fullEventName); 11357 var listeners = eventsMap.get(fullEventName); 11358 11359 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 11360 console.error("You cannot subscribe the same \"".concat(fullEventName, "\" event listener twice.")); 11361 } else { 11362 if (listeners) { 11363 listeners.set(listener, { 11364 listener: listener, 11365 options: options, 11366 sort: this.getNextSequenceValue() 11367 }); 11368 } else { 11369 listeners = new Map([[listener, { 11370 listener: listener, 11371 options: options, 11372 sort: this.getNextSequenceValue() 11373 }]]); 11374 eventsMap.set(fullEventName, listeners); 11375 } 11376 } 11377 11378 var maxListeners = this.getMaxListeners(target, eventName); 11379 11380 if (listeners.size > maxListeners) { 11381 warningStore.add(target, fullEventName, listeners); 11382 warningStore.printDelayed(); 11383 } 11384 } 11385 }, { 11386 key: "subscribeOnce", 11387 value: function subscribeOnce(target, eventName, listener) { 11388 var _this2 = this; 11389 11390 if (Type.isString(target)) { 11391 listener = eventName; 11392 eventName = target; 11393 target = this.GLOBAL_TARGET;
11394 } 11395 11396 if (!Type.isObject(target)) { 11397 throw new TypeError("The \"target\" argument must be an object."); 11398 } 11399 11400 eventName = this.normalizeEventName(eventName); 11401 11402 if (!Type.isStringFilled(eventName)) { 11403 throw new TypeError("The \"eventName\" argument must be a string."); 11404 } 11405 11406 if (!Type.isFunction(listener)) { 11407 throw new TypeError("The \"listener\" argument must be of type Function. Received type ".concat(babelHelpers.typeof(listener), ".")); 11408 } 11409 11410 var fullEventName = this.resolveEventName(eventName, target); 11411 11412 var _eventStore$getOrAdd2 = eventStore.getOrAdd(target), 11413 eventsMap = _eventStore$getOrAdd2.eventsMap, 11414 onceMap = _eventStore$getOrAdd2.onceMap; 11415 11416 var listeners = eventsMap.get(fullEventName); 11417 var onceListeners = onceMap.get(fullEventName); 11418 11419 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 11420 console.error("You cannot subscribe the same \"".concat(fullEventName, "\" event listener twice.")); 11421 } else { 11422 var once = function once() { 11423 _this2.unsubscribe(target, eventName, once); 11424 11425 onceListeners.delete(listener); 11426 listener.apply(void 0, arguments); 11427 }; 11428 11429 if (onceListeners) { 11430 onceListeners.set(listener, once); 11431 } else { 11432 onceListeners = new Map([[listener, once]]); 11433 onceMap.set(fullEventName, onceListeners); 11434 } 11435 11436 this.subscribe(target, eventName, once); 11437 } 11438 } 11439 }, { 11440 key: "unsubscribe", 11441 value: function unsubscribe(target, eventName, listener, options) { 11442 if (Type.isString(target)) { 11443 listener = eventName; 11444 eventName = target; 11445 target = this.GLOBAL_TARGET;
11446 } 11447 11448 eventName = this.normalizeEventName(eventName); 11449 11450 if (!Type.isStringFilled(eventName)) { 11451 throw new TypeError("The \"eventName\" argument must be a string."); 11452 } 11453 11454 if (!Type.isFunction(listener)) { 11455 throw new TypeError("The \"listener\" argument must be of type Function. Received type ".concat(typeof event === "undefined" ? "undefined" : babelHelpers.typeof(event), ".")); 11456 } 11457 11458 options = Type.isPlainObject(options) ? options : {}; 11459 var fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 11460 var targetInfo = eventStore.get(target); 11461 var listeners = targetInfo && targetInfo.eventsMap.get(fullEventName); 11462 var onceListeners = targetInfo && targetInfo.onceMap.get(fullEventName); 11463 11464 if (listeners) { 11465 listeners.delete(listener); 11466 } 11467 11468 if (onceListeners) { 11469 var once = onceListeners.get(listener); 11470 11471 if (once) { 11472 onceListeners.delete(listener); 11473 listeners.delete(once); 11474 } 11475 } 11476 } 11477 }, { 11478 key: "unsubscribeAll", 11479 value: function unsubscribeAll(target, eventName, options) { 11480 if (Type.isString(target)) { 11481 eventName = target; 11482 target = this.GLOBAL_TARGET;
11483 } 11484 11485 if (Type.isStringFilled(eventName)) { 11486 var targetInfo = eventStore.get(target); 11487 11488 if (targetInfo) { 11489 options = Type.isPlainObject(options) ? options : {}; 11490 var fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 11491 targetInfo.eventsMap.delete(fullEventName); 11492 targetInfo.onceMap.delete(fullEventName); 11493 } 11494 } else if (Type.isNil(eventName)) { 11495 if (target === this.GLOBAL_TARGET) { 11496 console.error('You cannot unsubscribe all global listeners.'); 11497 } else { 11498 eventStore.delete(target); 11499 } 11500 } 11501 } 11502 }, { 11503 key: "emit", 11504 value: function emit(target, eventName, event, options) { 11505 if (Type.isString(target)) { 11506 options = event; 11507 event = eventName; 11508 eventName = target; 11509 target = this.GLOBAL_TARGET; 11510 } 11511 11512 if (!Type.isObject(target)) { 11513 throw new TypeError("The \"target\" argument must be an object."); 11514 } 11515 11516 eventName = this.normalizeEventName(eventName); 11517 11518 if (!Type.isStringFilled(eventName)) { 11519 throw new TypeError("The \"eventName\" argument must be a string."); 11520 } 11521 11522 options = Type.isPlainObject(options) ? options : {}; 11523 var fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 11524 var globalEvents = eventStore.get(this.GLOBAL_TARGET); 11525 var globalListeners = globalEvents && globalEvents.eventsMap.get(fullEventName) || new Map(); 11526 var targetListeners = new Set(); 11527 11528 if (target !== this.GLOBAL_TARGET) { 11529 var targetEvents = eventStore.get(target); 11530 targetListeners = targetEvents && targetEvents.eventsMap.get(fullEventName) || new Map(); 11531 } 11532 11533 var listeners = [].concat(babelHelpers.toConsumableArray(globalListeners.values()), babelHelpers.toConsumableArray(targetListeners.values())); 11534 listeners.sort(function (a, b) { 11535 return a.sort - b.sort; 11536 }); 11537 var preparedEvent = this.prepareEvent(target, fullEventName, event); 11538 var result = []; 11539 11540 for (var i = 0; i < listeners.length; i++) { 11541 if (preparedEvent.isImmediatePropagationStopped()) { 11542 break; 11543 } 11544 11545 var _listeners$i = listeners[i], 11546 listener = _listeners$i.listener, 11547 listenerOptions = _listeners$i.options; //A previous listener could remove a current listener. 11548 11549 if (globalListeners.has(listener) || targetListeners.has(listener)) { 11550 var listenerResult = void 0; 11551 11552 if (listenerOptions.compatMode) { 11553 var params = []; 11554 var compatData = preparedEvent.getCompatData(); 11555 11556 if (compatData !== null) { 11557 params = options.cloneData === true ? Runtime.clone(compatData) : compatData; 11558 } else { 11559 params = [preparedEvent]; 11560 } 11561 11562 var context = Type.isUndefined(options.thisArg) ? target : options.thisArg; 11563 listenerResult = listener.apply(context, params); 11564 } else { 11565 listenerResult = Type.isUndefined(options.thisArg) ? listener(preparedEvent) : listener.call(options.thisArg, preparedEvent); 11566 } 11567 11568 result.push(listenerResult); 11569 } 11570 } 11571 11572 return result; 11573 } 11574 }, { 11575 key: "emitAsync", 11576 value: function emitAsync(target, eventName, event) { 11577 if (Type.isString(target)) { 11578 event = eventName; 11579 eventName = target; 11580 target = this.GLOBAL_TARGET;
11581 } 11582 11583 return Promise.all(this.emit(target, eventName, event)); 11584 } 11585 }, { 11586 key: "prepareEvent", 11587 value: function prepareEvent(target, eventName, event) { 11588 var preparedEvent = event; 11589 11590 if (!(event instanceof BaseEvent)) { 11591 preparedEvent = new BaseEvent(); 11592 preparedEvent.setData(event); 11593 } 11594 11595 preparedEvent.setTarget(this.isEventEmitter(target) ? target[targetProperty] : target); 11596 preparedEvent.setType(eventName); 11597 return preparedEvent; 11598 } 11599 /** 11600 * @private 11601 * @returns {number} 11602 */ 11603 11604 }, { 11605 key: "getNextSequenceValue", 11606 value: function getNextSequenceValue() { 11607 return this.sequenceValue++; 11608 } 11609 /** 11610 * Sets max global events listeners count 11611 * Event.EventEmitter.setMaxListeners(10) - sets the default value for all events (global target) 11612 * Event.EventEmitter.setMaxListeners("onClose", 10) - sets the value for onClose event (global target) 11613 * Event.EventEmitter.setMaxListeners(obj, 10) - sets the default value for all events (obj target) 11614 * Event.EventEmitter.setMaxListeners(obj, "onClose", 10); - sets the value for onClose event (obj target) 11615 * @return {void} 11616 * @param args 11617 */ 11618 11619 }, { 11620 key: "setMaxListeners", 11621 value: function setMaxListeners() { 11622 var target = this.GLOBAL_TARGET;
11623 var eventName = null; 11624 var count = undefined; 11625 11626 for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { 11627 args[_key5] = arguments[_key5]; 11628 } 11629 11630 if (args.length === 1) { 11631 count = args[0]; 11632 } else if (args.length === 2) { 11633 if (Type.isString(args[0])) { 11634 eventName = args[0]; 11635 count = args[1]; 11636 } else { 11637 target = args[0]; 11638 count = args[1]; 11639 } 11640 } else if (args.length >= 3) { 11641 target = args[0]; 11642 eventName = args[1]; 11643 count = args[2]; 11644 } 11645 11646 if (!Type.isObject(target)) { 11647 throw new TypeError("The \"target\" argument must be an object."); 11648 } 11649 11650 if (eventName !== null && !Type.isStringFilled(eventName)) { 11651 throw new TypeError("The \"eventName\" argument must be a string."); 11652 } 11653 11654 if (!Type.isNumber(count) || count < 0) { 11655 throw new TypeError("The value of \"count\" is out of range. It must be a non-negative number. Received ".concat(count, ".")); 11656 } 11657 11658 var targetInfo = eventStore.getOrAdd(target); 11659 11660 if (Type.isStringFilled(eventName)) { 11661 var fullEventName = this.resolveEventName(eventName, target); 11662 targetInfo.eventsMaxListeners.set(fullEventName, count); 11663 } else { 11664 targetInfo.maxListeners = count; 11665 } 11666 } 11667 }, { 11668 key: "getMaxListeners", 11669 value: function getMaxListeners(target, eventName) { 11670 if (Type.isString(target)) { 11671 eventName = target; 11672 target = this.GLOBAL_TARGET;
11673 } else if (Type.isNil(target)) { 11674 target = this.GLOBAL_TARGET; 11675 } 11676 11677 if (!Type.isObject(target)) { 11678 throw new TypeError("The \"target\" argument must be an object."); 11679 } 11680 11681 var targetInfo = eventStore.get(target); 11682 11683 if (targetInfo) { 11684 var maxListeners = targetInfo.maxListeners; 11685 11686 if (Type.isStringFilled(eventName)) { 11687 var fullEventName = this.resolveEventName(eventName, target); 11688 maxListeners = targetInfo.eventsMaxListeners.get(fullEventName) || maxListeners; 11689 } 11690 11691 return maxListeners; 11692 } 11693 11694 return this.DEFAULT_MAX_LISTENERS; 11695 } 11696 }, { 11697 key: "addMaxListeners", 11698 value: function addMaxListeners() { 11699 var _this$destructMaxList = this.destructMaxListenersArgs.apply(this, arguments), 11700 _this$destructMaxList2 = babelHelpers.slicedToArray(_this$destructMaxList, 3), 11701 target = _this$destructMaxList2[0], 11702 eventName = _this$destructMaxList2[1], 11703 increment = _this$destructMaxList2[2]; 11704 11705 var maxListeners = Math.max(this.getMaxListeners(target, eventName) + increment, 0); 11706 11707 if (Type.isStringFilled(eventName)) { 11708 EventEmitter.setMaxListeners(target, eventName, maxListeners); 11709 } else { 11710 EventEmitter.setMaxListeners(target, maxListeners); 11711 } 11712 11713 return maxListeners; 11714 } 11715 /** 11716 * Increases max listeners count 11717 * 11718 * Event.EventEmitter.incrementMaxListeners() - adds one max listener for all events of global target 11719 * Event.EventEmitter.incrementMaxListeners(3) - adds three max listeners for all events of global target 11720 * Event.EventEmitter.incrementMaxListeners('onClose') - adds one max listener for onClose event of global target 11721 * Event.EventEmitter.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 11722 * 11723 * Event.EventEmitter.incrementMaxListeners(obj) - adds one max listener for all events of 'obj' target 11724 * Event.EventEmitter.incrementMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 11725 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 11726 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 11727 */ 11728 11729 }, { 11730 key: "incrementMaxListeners", 11731 value: function incrementMaxListeners() { 11732 var _this$destructMaxList3 = this.destructMaxListenersArgs.apply(this, arguments), 11733 _this$destructMaxList4 = babelHelpers.slicedToArray(_this$destructMaxList3, 3), 11734 target = _this$destructMaxList4[0], 11735 eventName = _this$destructMaxList4[1], 11736 increment = _this$destructMaxList4[2]; 11737 11738 return this.addMaxListeners(target, eventName, Math.abs(increment)); 11739 } 11740 }, { 11741 key: "decrementMaxListeners", 11742 value: function decrementMaxListeners() { 11743 var _this$destructMaxList5 = this.destructMaxListenersArgs.apply(this, arguments), 11744 _this$destructMaxList6 = babelHelpers.slicedToArray(_this$destructMaxList5, 3), 11745 target = _this$destructMaxList6[0], 11746 eventName = _this$destructMaxList6[1], 11747 increment = _this$destructMaxList6[2]; 11748 11749 return this.addMaxListeners(target, eventName, -Math.abs(increment)); 11750 } 11751 }, { 11752 key: "destructMaxListenersArgs", 11753 value: function destructMaxListenersArgs() { 11754 var eventName = null; 11755 var increment = 1; 11756 var target = this.GLOBAL_TARGET;
11757 11758 for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { 11759 args[_key6] = arguments[_key6]; 11760 } 11761 11762 if (args.length === 1) { 11763 if (Type.isNumber(args[0])) { 11764 increment = args[0]; 11765 } else if (Type.isString(args[0])) { 11766 eventName = args[0]; 11767 } else { 11768 target = args[0]; 11769 } 11770 } else if (args.length === 2) { 11771 if (Type.isString(args[0])) { 11772 eventName = args[0]; 11773 increment = args[1]; 11774 } else if (Type.isString(args[1])) { 11775 target = args[0]; 11776 eventName = args[1]; 11777 } else { 11778 target = args[0]; 11779 increment = args[1]; 11780 } 11781 } else if (args.length >= 3) { 11782 target = args[0]; 11783 eventName = args[1]; 11784 increment = args[2]; 11785 } 11786 11787 if (!Type.isObject(target)) { 11788 throw new TypeError("The \"target\" argument must be an object."); 11789 } 11790 11791 if (eventName !== null && !Type.isStringFilled(eventName)) { 11792 throw new TypeError("The \"eventName\" argument must be a string."); 11793 } 11794 11795 if (!Type.isNumber(increment)) { 11796 throw new TypeError("The value of \"increment\" must be a number."); 11797 } 11798 11799 return [target, eventName, increment]; 11800 } 11801 /** 11802 * Gets listeners list for a specified event 11803 * @param {object} target 11804 * @param {string} eventName 11805 */ 11806 11807 }, { 11808 key: "getListeners", 11809 value: function getListeners(target, eventName) { 11810 if (Type.isString(target)) { 11811 eventName = target; 11812 target = this.GLOBAL_TARGET;
11813 } 11814 11815 if (!Type.isObject(target)) { 11816 throw new TypeError("The \"target\" argument must be an object."); 11817 } 11818 11819 eventName = this.normalizeEventName(eventName); 11820 11821 if (!Type.isStringFilled(eventName)) { 11822 throw new TypeError("The \"eventName\" argument must be a string."); 11823 } 11824 11825 var targetInfo = eventStore.get(target); 11826 11827 if (!targetInfo) { 11828 return new Map(); 11829 } 11830 11831 var fullEventName = this.resolveEventName(eventName, target); 11832 return targetInfo.eventsMap.get(fullEventName) || new Map(); 11833 } 11834 }, { 11835 key: "registerAliases", 11836 value: function registerAliases(aliases) { 11837 aliases = this.normalizeAliases(aliases); 11838 Object.keys(aliases).forEach(function (alias) { 11839 aliasStore.set(alias, { 11840 eventName: aliases[alias].eventName, 11841 namespace: aliases[alias].namespace 11842 }); 11843 }); 11844 EventEmitter.mergeEventAliases(aliases); 11845 } 11846 /** 11847 * @private 11848 * @param aliases 11849 */ 11850 11851 }, { 11852 key: "normalizeAliases", 11853 value: function normalizeAliases(aliases) { 11854 if (!Type.isPlainObject(aliases)) { 11855 throw new TypeError("The \"aliases\" argument must be an object."); 11856 } 11857 11858 var result = Object.create(null); 11859 11860 for (var _alias in aliases) { 11861 if (!Type.isStringFilled(_alias)) { 11862 throw new TypeError("The alias must be an non-empty string."); 11863 } 11864 11865 var options = aliases[_alias]; 11866 11867 if (!options || !Type.isStringFilled(options.eventName) || !Type.isStringFilled(options.namespace)) { 11868 throw new TypeError("The alias options must set the \"eventName\" and the \"namespace\"."); 11869 } 11870 11871 _alias = this.normalizeEventName(_alias); 11872 result[_alias] = { 11873 eventName: options.eventName, 11874 namespace: options.namespace 11875 }; 11876 } 11877 11878 return result; 11879 } 11880 /** 11881 * @private 11882 */ 11883 11884 }, { 11885 key: "mergeEventAliases", 11886 value: function mergeEventAliases(aliases) { 11887 var _this3 = this; 11888 11889 var globalEvents = eventStore.get(this.GLOBAL_TARGET); 11890 11891 if (!globalEvents) { 11892 return; 11893 } 11894 11895 Object.keys(aliases).forEach(function (alias) { 11896 var options = aliases[alias]; 11897 alias = _this3.normalizeEventName(alias); 11898 11899 var fullEventName = _this3.makeFullEventName(options.namespace, options.eventName); 11900 11901 var aliasListeners = globalEvents.eventsMap.get(alias); 11902 11903 if (aliasListeners) { 11904 var listeners = globalEvents.eventsMap.get(fullEventName) || new Map(); 11905 globalEvents.eventsMap.set(fullEventName, new Map([].concat(babelHelpers.toConsumableArray(listeners), babelHelpers.toConsumableArray(aliasListeners)))); 11906 globalEvents.eventsMap.delete(alias); 11907 } 11908 11909 var aliasOnceListeners = globalEvents.onceMap.get(alias); 11910 11911 if (aliasOnceListeners) { 11912 var onceListeners = globalEvents.onceMap.get(fullEventName) || new Map(); 11913 globalEvents.onceMap.set(fullEventName, new Map([].concat(babelHelpers.toConsumableArray(onceListeners), babelHelpers.toConsumableArray(aliasOnceListeners)))); 11914 globalEvents.onceMap.delete(alias); 11915 } 11916 11917 var aliasMaxListeners = globalEvents.eventsMaxListeners.get(alias); 11918 11919 if (aliasMaxListeners) { 11920 var eventMaxListeners = globalEvents.eventsMaxListeners.get(fullEventName) || 0; 11921 globalEvents.eventsMaxListeners.set(fullEventName, Math.max(eventMaxListeners, aliasMaxListeners)); 11922 globalEvents.eventsMaxListeners.delete(alias); 11923 } 11924 }); 11925 } 11926 /** 11927 * Returns true if the target is an instance of Event.EventEmitter 11928 * @param {object} target 11929 * @returns {boolean} 11930 */ 11931 11932 }, { 11933 key: "isEventEmitter", 11934 value: function isEventEmitter(target) { 11935 return Type.isObject(target) && target[isEmitterProperty] === true; 11936 } 11937 /** 11938 * @private 11939 * @param {string} eventName 11940 * @returns {string} 11941 */ 11942 11943 }, { 11944 key: "normalizeEventName", 11945 value: function normalizeEventName(eventName) { 11946 if (!Type.isStringFilled(eventName)) { 11947 return ''; 11948 } 11949 11950 return eventName.toLowerCase(); 11951 } 11952 /** 11953 * @private 11954 * @param eventName 11955 * @param target 11956 * @param useGlobalNaming 11957 * @returns {string} 11958 */ 11959 11960 }, { 11961 key: "resolveEventName", 11962 value: function resolveEventName(eventName, target) { 11963 var useGlobalNaming = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
11964 eventName = this.normalizeEventName(eventName); 11965 11966 if (!Type.isStringFilled(eventName)) { 11967 return ''; 11968 } 11969 11970 if (this.isEventEmitter(target) && useGlobalNaming !== true) { 11971 if (target.getEventNamespace() !== null && eventName.includes('.')) { 11972 console.warn("Possible the wrong event name \"".concat(eventName, "\".")); 11973 } 11974 11975 eventName = target.getFullEventName(eventName); 11976 } else if (aliasStore.has(eventName)) { 11977 var _aliasStore$get = aliasStore.get(eventName), 11978 namespace = _aliasStore$get.namespace, 11979 actualEventName = _aliasStore$get.eventName; 11980 11981 eventName = this.makeFullEventName(namespace, actualEventName); 11982 } 11983 11984 return eventName; 11985 } 11986 /** 11987 * @private 11988 * @param {string} namespace 11989 * @param {string} eventName 11990 * @returns {string} 11991 */ 11992 11993 }, { 11994 key: "makeFullEventName", 11995 value: function makeFullEventName(namespace, eventName) { 11996 var fullName = Type.isStringFilled(namespace) ? "".concat(namespace, ":").concat(eventName) : eventName; 11997 return Type.isStringFilled(fullName) ? fullName.toLowerCase() : ''; 11998 } 11999 }]); 12000 return EventEmitter; 12001 }(); 12002 12003 babelHelpers.defineProperty(EventEmitter, "GLOBAL_TARGET", globalTarget); 12004 babelHelpers.defineProperty(EventEmitter, "DEFAULT_MAX_LISTENERS", eventStore.getDefaultMaxListeners()); 12005 babelHelpers.defineProperty(EventEmitter, "sequenceValue", 1); 12006 12007 var stack = []; 12008 /** 12009 * For compatibility only 12010 * @type {boolean} 12011 */ 12012 // eslint-disable-next-line 12013 12014 exports.isReady = false; 12015 function ready(handler) { 12016 switch (document.readyState) { 12017 case 'loading': 12018 stack.push(handler); 12019 break; 12020 12021 case 'interactive': 12022 case 'complete': 12023 if (Type.isFunction(handler)) { 12024 handler(); 12025 } 12026 12027 exports.isReady = true; 12028 break; 12029 12030 default: 12031 break; 12032 } 12033 } 12034 document.addEventListener('readystatechange', function () { 12035 if (!exports.isReady) { 12036 stack.forEach(ready); 12037 stack = []; 12038 } 12039 }); 12040 12041 /** 12042 * @memberOf BX 12043 */ 12044 12045 var Event = function Event() { 12046 babelHelpers.classCallCheck(this, Event); 12047 }; 12048 12049 babelHelpers.defineProperty(Event, "bind", bind); 12050 babelHelpers.defineProperty(Event, "bindOnce", bindOnce); 12051 babelHelpers.defineProperty(Event, "unbind", unbind); 12052 babelHelpers.defineProperty(Event, "unbindAll", unbindAll); 12053 babelHelpers.defineProperty(Event, "ready", ready); 12054 babelHelpers.defineProperty(Event, "EventEmitter", EventEmitter); 12055 babelHelpers.defineProperty(Event, "BaseEvent", BaseEvent); 12056 12057 function encodeAttributeValue(value) { 12058 if (Type.isPlainObject(value) || Type.isArray(value)) { 12059 return JSON.stringify(value); 12060 } 12061 12062 return Text.encode(Text.decode(value)); 12063 } 12064 12065 function decodeAttributeValue(value) { 12066 if (Type.isString(value)) { 12067 var decodedValue = Text.decode(value); 12068 var result; 12069 12070 try { 12071 result = JSON.parse(decodedValue); 12072 } catch (e) { 12073 result = decodedValue; 12074 } 12075 12076 if (result === decodedValue) { 12077 if (/^[\d.]+[.]?\d+$/.test(result)) { 12078 return Number(result); 12079 } 12080 } 12081 12082 if (result === 'true' || result === 'false') { 12083 return Boolean(result); 12084 } 12085 12086 return result; 12087 } 12088 12089 return value; 12090 } 12091 12092 function getPageScroll() { 12093 var _document = document, 12094 documentElement = _document.documentElement, 12095 body = _document.body; 12096 var scrollTop = Math.max(window.pageYOffset || 0, documentElement ? documentElement.scrollTop : 0, body ? body.scrollTop : 0); 12097 var scrollLeft = Math.max(window.pageXOffset || 0, documentElement ? documentElement.scrollLeft : 0, body ? body.scrollLeft : 0); 12098 return { 12099 scrollTop: scrollTop, 12100 scrollLeft: scrollLeft 12101 }; 12102 } 12103 12104 /** 12105 * @memberOf BX 12106 */ 12107 12108 var Dom = /*#__PURE__*/function () { 12109 function Dom() { 12110 babelHelpers.classCallCheck(this, Dom); 12111 } 12112 12113 babelHelpers.createClass(Dom, null, [{ 12114 key: "replace", 12115 12116 /** 12117 * Replaces old html element to new html element 12118 * @param oldElement 12119 * @param newElement 12120 */ 12121 value: function replace(oldElement, newElement) { 12122 if (Type.isDomNode(oldElement) && Type.isDomNode(newElement)) { 12123 if (Type.isDomNode(oldElement.parentNode)) { 12124 oldElement.parentNode.replaceChild(newElement, oldElement); 12125 } 12126 } 12127 } 12128 /** 12129 * Removes element 12130 * @param element 12131 */ 12132 12133 }, { 12134 key: "remove", 12135 value: function remove(element) { 12136 if (Type.isDomNode(element) && Type.isDomNode(element.parentNode)) { 12137 element.parentNode.removeChild(element); 12138 } 12139 } 12140 /** 12141 * Cleans element 12142 * @param element 12143 */ 12144 12145 }, { 12146 key: "clean", 12147 value: function clean(element) { 12148 if (Type.isDomNode(element)) { 12149 while (element.childNodes.length > 0) { 12150 element.removeChild(element.firstChild); 12151 } 12152 12153 return; 12154 } 12155 12156 if (Type.isString(element)) { 12157 Dom.clean(document.getElementById(element)); 12158 } 12159 } 12160 /** 12161 * Inserts element before target element 12162 * @param current 12163 * @param target 12164 */ 12165 12166 }, { 12167 key: "insertBefore", 12168 value: function insertBefore(current, target) { 12169 if (Type.isDomNode(current) && Type.isDomNode(target)) { 12170 if (Type.isDomNode(target.parentNode)) { 12171 target.parentNode.insertBefore(current, target); 12172 } 12173 } 12174 } 12175 /** 12176 * Inserts element after target element 12177 * @param current 12178 * @param target 12179 */ 12180 12181 }, { 12182 key: "insertAfter", 12183 value: function insertAfter(current, target) { 12184 if (Type.isDomNode(current) && Type.isDomNode(target)) { 12185 if (Type.isDomNode(target.parentNode)) { 12186 var parent = target.parentNode; 12187 12188 if (Type.isDomNode(target.nextSibling)) { 12189 parent.insertBefore(current, target.nextSibling); 12190 return; 12191 } 12192 12193 parent.appendChild(current); 12194 } 12195 } 12196 } 12197 /** 12198 * Appends element to target element 12199 * @param current 12200 * @param target 12201 */ 12202 12203 }, { 12204 key: "append", 12205 value: function append(current, target) { 12206 if (Type.isDomNode(current) && Type.isDomNode(target)) { 12207 target.appendChild(current); 12208 } 12209 } 12210 /** 12211 * Prepends element to target element 12212 * @param current 12213 * @param target 12214 */ 12215 12216 }, {
12217 key: "prepend", 12218 value: function prepend(current, target) { 12219 if (Type.isDomNode(current) && Type.isDomNode(target)) { 12220 if (Type.isDomNode(target.firstChild)) { 12221 target.insertBefore(current, target.firstChild); 12222 return; 12223 } 12224 12225 Dom.append(current, target); 12226 } 12227 } 12228 /** 12229 * Checks that element contains class name or class names 12230 * @param element 12231 * @param className 12232 * @return {Boolean} 12233 */ 12234 12235 }, { 12236 key: "hasClass", 12237 value: function hasClass(element, className) { 12238 if (Type.isElementNode(element)) { 12239 if (Type.isString(className)) { 12240 var preparedClassName = className.trim(); 12241 12242 if (preparedClassName.length > 0) { 12243 if (preparedClassName.includes(' ')) { 12244 return preparedClassName.split(' ').every(function (name) { 12245 return Dom.hasClass(element, name); 12246 }); 12247 } 12248 12249 if ('classList' in element) { 12250 return element.classList.contains(preparedClassName); 12251 } 12252 12253 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 12254 return element.getAttribute('class').split(' ').some(function (name) { 12255 return name === preparedClassName; 12256 }); 12257 } 12258 } 12259 } 12260 12261 if (Type.isArray(className) && className.length > 0) { 12262 return className.every(function (name) { 12263 return Dom.hasClass(element, name); 12264 }); 12265 } 12266 } 12267 12268 return false; 12269 } 12270 /** 12271 * Adds class name 12272 * @param element 12273 * @param className 12274 */ 12275 12276 }, { 12277 key: "addClass", 12278 value: function addClass(element, className) { 12279 if (Type.isElementNode(element)) { 12280 if (Type.isString(className)) { 12281 var preparedClassName = className.trim(); 12282 12283 if (preparedClassName.length > 0) { 12284 if (preparedClassName.includes(' ')) { 12285 Dom.addClass(element, preparedClassName.split(' ')); 12286 return; 12287 } 12288 12289 if ('classList' in element) { 12290 element.classList.add(preparedClassName); 12291 return; 12292 } 12293 12294 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 12295 if (element.className.baseVal === '') { 12296 element.className.baseVal = preparedClassName; 12297 return; 12298 } 12299 12300 var names = element.className.baseVal.split(' '); 12301 12302 if (!names.includes(preparedClassName)) { 12303 names.push(preparedClassName); 12304 element.className.baseVal = names.join(' ').trim(); 12305 return; 12306 } 12307 } 12308 12309 return; 12310 } 12311 } 12312 12313 if (Type.isArray(className)) { 12314 className.forEach(function (name) { 12315 return Dom.addClass(element, name); 12316 }); 12317 } 12318 } 12319 } 12320 /** 12321 * Removes class name 12322 * @param element 12323 * @param className 12324 */ 12325 12326 }, { 12327 key: "removeClass", 12328 value: function removeClass(element, className) { 12329 if (Type.isElementNode(element)) { 12330 if (Type.isString(className)) { 12331 var preparedClassName = className.trim(); 12332 12333 if (preparedClassName.length > 0) { 12334 if (preparedClassName.includes(' ')) { 12335 Dom.removeClass(element, preparedClassName.split(' ')); 12336 return; 12337 } 12338 12339 if ('classList' in element) { 12340 element.classList.remove(preparedClassName); 12341 return; 12342 } 12343 12344 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 12345 var names = element.className.baseVal.split(' ').filter(function (name) { 12346 return name !== preparedClassName; 12347 }); 12348 element.className.baseVal = names.join(' '); 12349 return; 12350 } 12351 } 12352 } 12353 12354 if (Type.isArray(className)) { 12355 className.forEach(function (name) { 12356 return Dom.removeClass(element, name); 12357 }); 12358 } 12359 } 12360 } 12361 /**
12362 * Toggles class name 12363 * @param element 12364 * @param className 12365 */ 12366 12367 }, { 12368 key: "toggleClass", 12369 value: function toggleClass(element, className) { 12370 if (Type.isElementNode(element)) { 12371 if (Type.isString(className)) { 12372 var preparedClassName = className.trim(); 12373 12374 if (preparedClassName.length > 0) { 12375 if (preparedClassName.includes(' ')) { 12376 Dom.toggleClass(element, preparedClassName.split(' ')); 12377 return; 12378 } 12379 12380 element.classList.toggle(preparedClassName); 12381 return; 12382 } 12383 } 12384 12385 if (Type.isArray(className)) { 12386 className.forEach(function (name) { 12387 return Dom.toggleClass(element, name); 12388 }); 12389 } 12390 } 12391 } 12392 /** 12393 * Styles element 12394 */ 12395 12396 }, { 12397 key: "style", 12398 value: function style(element, prop, value) { 12399 if (Type.isElementNode(element)) { 12400 if (Type.isNull(prop)) { 12401 element.removeAttribute('style'); 12402 return element; 12403 } 12404 12405 if (Type.isPlainObject(prop)) { 12406 Object.entries(prop).forEach(function (item) { 12407 var _item = babelHelpers.slicedToArray(item, 2), 12408 currentKey = _item[0], 12409 currentValue = _item[1]; 12410 12411 Dom.style(element, currentKey, currentValue); 12412 }); 12413 return element; 12414 } 12415 12416 if (Type.isString(prop)) { 12417 if (Type.isUndefined(value) && element.nodeType !== Node.DOCUMENT_NODE) { 12418 var computedStyle = getComputedStyle(element); 12419 12420 if (prop in computedStyle) { 12421 return computedStyle[prop]; 12422 } 12423 12424 return computedStyle.getPropertyValue(prop); 12425 } 12426 12427 if (Type.isNull(value) || value === '' || value === 'null') { 12428 // eslint-disable-next-line 12429 element.style[prop] = ''; 12430 return element; 12431 } 12432 12433 if (Type.isString(value) || Type.isNumber(value)) { 12434 // eslint-disable-next-line 12435 element.style[prop] = value; 12436 return element; 12437 } 12438 } 12439 } 12440 12441 return null; 12442 } 12443 /** 12444 * Adjusts element 12445 * @param target 12446 * @param data 12447 * @return {*} 12448 */ 12449 12450 }, { 12451 key: "adjust", 12452 value: function adjust(target) { 12453 var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 12454 12455 if (!target.nodeType) { 12456 return null; 12457 } 12458 12459 var element = target; 12460 12461 if (target.nodeType === Node.DOCUMENT_NODE) { 12462 element = target.body; 12463 } 12464 12465 if (Type.isPlainObject(data)) { 12466 if (Type.isPlainObject(data.attrs)) { 12467 Object.keys(data.attrs).forEach(function (key) { 12468 if (key === 'class' || key.toLowerCase() === 'classname') { 12469 element.className = data.attrs[key]; 12470 return; 12471 } // eslint-disable-next-line 12472 12473 12474 if (data.attrs[key] == '') { 12475 element.removeAttribute(key); 12476 return; 12477 } 12478 12479 element.setAttribute(key, data.attrs[key]); 12480 }); 12481 } 12482 12483 if (Type.isPlainObject(data.style)) { 12484 Dom.style(element, data.style); 12485 } 12486 12487 if (Type.isPlainObject(data.props)) { 12488 Object.keys(data.props).forEach(function (key) { 12489 element[key] = data.props[key]; 12490 }); 12491 } 12492 12493 if (Type.isPlainObject(data.events)) { 12494 Object.keys(data.events).forEach(function (key) { 12495 Event.bind(element, key, data.events[key]); 12496 }); 12497 } 12498 12499 if (Type.isPlainObject(data.dataset)) { 12500 Object.keys(data.dataset).forEach(function (key) { 12501 element.dataset[key] = data.dataset[key]; 12502 }); 12503 } 12504 12505 if (Type.isString(data.children)) { 12506 data.children = [data.children]; 12507 } 12508 12509 if (Type.isArray(data.children) && data.children.length > 0) {
12510 data.children.forEach(function (item) { 12511 if (Type.isDomNode(item)) { 12512 Dom.append(item, element); 12513 } 12514 12515 if (Type.isString(item)) { 12516 element.innerHTML += item; 12517 } 12518 }); 12519 return element; 12520 } 12521 12522 if ('text' in data && !Type.isNil(data.text)) { 12523 element.innerText = data.text; 12524 return element; 12525 } 12526 12527 if ('html' in data && !Type.isNil(data.html)) { 12528 element.innerHTML = data.html; 12529 } 12530 } 12531 12532 return element; 12533 } 12534 /** 12535 * Creates element 12536 * @param tag 12537 * @param data 12538 * @param context 12539 * @return {HTMLElement|HTMLBodyElement} 12540 */ 12541 12542 }, { 12543 key: "create", 12544 value: function create(tag) { 12545 var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 12546 var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : document; 12547 var tagName = tag; 12548 var options = data; 12549 12550 if (Type.isObjectLike(tag)) { 12551 options = tag; 12552 tagName = tag.tag; 12553 } 12554 12555 return Dom.adjust(context.createElement(tagName), options); 12556 } 12557 /** 12558 * Shows element 12559 * @param element 12560 */ 12561 12562 }, { 12563 key: "show", 12564 value: function show(element) { 12565 if (Type.isDomNode(element)) { 12566 // eslint-disable-next-line 12567 element.hidden = false; 12568 } 12569 } 12570 /** 12571 * Hides element 12572 * @param element 12573 */ 12574 12575 }, { 12576 key: "hide", 12577 value: function hide(element) { 12578 if (Type.isDomNode(element)) { 12579 // eslint-disable-next-line 12580 element.hidden = true; 12581 } 12582 } 12583 /** 12584 * Checks that element is shown 12585 * @param element 12586 * @return {*|boolean} 12587 */ 12588 12589 }, { 12590 key: "isShown", 12591 value: function isShown(element) { 12592 return Type.isDomNode(element) && !element.hidden && element.style.getPropertyValue('display') !== 'none'; 12593 } 12594 /** 12595 * Toggles element visibility 12596 * @param element 12597 */ 12598 12599 }, { 12600 key: "toggle", 12601 value: function toggle(element) { 12602 if (Type.isDomNode(element)) { 12603 if (Dom.isShown(element)) { 12604 Dom.hide(element); 12605 } else { 12606 Dom.show(element); 12607 } 12608 } 12609 } 12610 /** 12611 * Gets element position relative page 12612 * @param {HTMLElement} element 12613 * @return {DOMRect} 12614 */ 12615 12616 }, { 12617 key: "getPosition", 12618 value: function getPosition(element) { 12619 if (Type.isDomNode(element)) { 12620 var elementRect = element.getBoundingClientRect(); 12621 12622 var _getPageScroll = getPageScroll(), 12623 scrollLeft = _getPageScroll.scrollLeft, 12624 scrollTop = _getPageScroll.scrollTop; 12625 12626 return new DOMRect(elementRect.left + scrollLeft, elementRect.top + scrollTop, elementRect.width, elementRect.height); 12627 } 12628 12629 return new DOMRect(); 12630 } 12631 /** 12632 * Gets element position relative specified element position 12633 * @param {HTMLElement} element 12634 * @param {HTMLElement} relationElement 12635 * @return {DOMRect} 12636 */ 12637 12638 }, { 12639 key: "getRelativePosition", 12640 value: function getRelativePosition(element, relationElement) { 12641 if (Type.isDomNode(element) && Type.isDomNode(relationElement)) { 12642 var elementPosition = Dom.getPosition(element); 12643 var relationElementPosition = Dom.getPosition(relationElement); 12644 return new DOMRect(elementPosition.left - relationElementPosition.left, elementPosition.top - relationElementPosition.top, elementPosition.width, elementPosition.height); 12645 } 12646 12647 return new DOMRect(); 12648 } 12649 }, { 12650 key: "attr", 12651 value: function attr(element, _attr, value) { 12652 if (Type.isElementNode(element)) { 12653 if (Type.isString(_attr)) { 12654 if (!Type.isNil(value)) { 12655 return element.setAttribute(_attr, encodeAttributeValue(value)); 12656 } 12657 12658 if (Type.isNull(value)) { 12659 return element.removeAttribute(_attr); 12660 } 12661 12662 return decodeAttributeValue(element.getAttribute(_attr)); 12663 } 12664 12665 if (Type.isPlainObject(_attr)) { 12666 return Object.entries(_attr).forEach(function (_ref) { 12667 var _ref2 = babelHelpers.slicedToArray(_ref, 2), 12668 attrKey = _ref2[0], 12669 attrValue = _ref2[1]; 12670 12671 Dom.attr(element, attrKey, attrValue); 12672 }); 12673 } 12674 } 12675 12676 return null; 12677 } 12678 }]); 12679 return Dom; 12680 }(); 12681 12682 var UA = navigator.userAgent.toLowerCase(); 12683 /** 12684 * @memberOf BX 12685 */ 12686 12687 var Browser = /*#__PURE__*/function () { 12688 function Browser() { 12689 babelHelpers.classCallCheck(this, Browser); 12690 } 12691 12692 babelHelpers.createClass(Browser, null, [{ 12693 key: "isOpera", 12694 value: function isOpera() { 12695 return UA.includes('opera'); 12696 } 12697 }, { 12698 key: "isIE", 12699 value: function isIE() { 12700 return 'attachEvent' in document && !Browser.isOpera(); 12701 } 12702 }, { 12703 key: "isIE6", 12704 value: function isIE6() { 12705 return UA.includes('msie 6'); 12706 } 12707 }, { 12708 key: "isIE7", 12709 value: function isIE7() { 12710 return UA.includes('msie 7'); 12711 } 12712 }, { 12713 key: "isIE8", 12714 value: function isIE8() { 12715 return UA.includes('msie 8'); 12716 } 12717 }, { 12718 key: "isIE9", 12719 value: function isIE9() { 12720 return 'documentMode' in document && document.documentMode >= 9; 12721 } 12722 }, { 12723 key: "isIE10", 12724 value: function isIE10() { 12725 return 'documentMode' in document && document.documentMode >= 10; 12726 } 12727 }, { 12728 key: "isSafari", 12729 value: function isSafari() { 12730 return UA.includes('webkit'); 12731 } 12732 }, { 12733 key: "isFirefox", 12734 value: function isFirefox() { 12735 return UA.includes('firefox'); 12736 } 12737 }, { 12738 key: "isChrome", 12739 value: function isChrome() { 12740 return UA.includes('chrome'); 12741 } 12742 }, { 12743 key: "detectIEVersion", 12744 value: function detectIEVersion() { 12745 if (Browser.isOpera() || Browser.isSafari() || Browser.isFirefox() || Browser.isChrome()) { 12746 return -1; 12747 } 12748 12749 var rv = -1; 12750 12751 if (!!window.MSStream && !window.ActiveXObject && 'ActiveXObject' in window) { 12752 rv = 11; 12753 } else if (Browser.isIE10()) { 12754 rv = 10; 12755 } else if (Browser.isIE9()) { 12756 rv = 9; 12757 } else if (Browser.isIE()) { 12758 rv = 8; 12759 } 12760 12761 if (rv === -1 || rv === 8) { 12762 if (navigator.appName === 'Microsoft Internet Explorer') { 12763 var re = new RegExp('MSIE ([0-9]+[.0-9]*)'); 12764 var res = navigator.userAgent.match(re); 12765 12766 if (Type.isArrayLike(res) && res.length > 0) { 12767 rv = parseFloat(res[1]); 12768 } 12769 } 12770 12771 if (navigator.appName === 'Netscape') { 12772 // Alternative check for IE 11 12773 rv = 11; 12774 12775 var _re = new RegExp('Trident/.*rv:([0-9]+[.0-9]*)'); 12776 12777 if (_re.exec(navigator.userAgent) != null) { 12778 var _res = navigator.userAgent.match(_re); 12779 12780 if (Type.isArrayLike(_res) && _res.length > 0) { 12781 rv = parseFloat(_res[1]); 12782 } 12783 } 12784 } 12785 } 12786 12787 return rv; 12788 } 12789 }, { 12790 key: "isIE11", 12791 value: function isIE11() { 12792 return Browser.detectIEVersion() >= 11; 12793 } 12794 }, { 12795 key: "isMac", 12796 value: function isMac() { 12797 return UA.includes('macintosh'); 12798 } 12799 }, { 12800 key: "isWin", 12801 value: function isWin() { 12802 return UA.includes('windows'); 12803 } 12804 }, { 12805 key: "isLinux", 12806 value: function isLinux() { 12807 return UA.includes('linux') && !Browser.isAndroid(); 12808 } 12809 }, { 12810 key: "isAndroid", 12811 value: function isAndroid() { 12812 return UA.includes('android'); 12813 } 12814 }, { 12815 key: "isIPad", 12816 value: function isIPad() { 12817 return UA.includes('ipad;') || this.isMac() && this.isTouchDevice(); 12818 } 12819 }, { 12820 key: "isIPhone", 12821 value: function isIPhone() { 12822 return UA.includes('iphone;'); 12823 } 12824 }, { 12825 key: "isIOS", 12826 value: function isIOS() { 12827 return Browser.isIPad() || Browser.isIPhone(); 12828 } 12829 }, { 12830 key: "isMobile", 12831 value: function isMobile() { 12832 return Browser.isIPhone() || Browser.isIPad() || Browser.isAndroid() || UA.includes('mobile') || UA.includes('touch'); 12833 } 12834 }, { 12835 key: "isRetina", 12836 value: function isRetina() { 12837 return window.devicePixelRatio && window.devicePixelRatio >= 2; 12838 } 12839 }, { 12840 key: "isTouchDevice", 12841 value: function isTouchDevice() { 12842 return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; 12843 } 12844 }, { 12845 key: "isDoctype", 12846 value: function isDoctype(target) { 12847 var doc = target || document; 12848 12849 if (doc.compatMode) { 12850 return doc.compatMode === 'CSS1Compat'; 12851 } 12852 12853 return doc.documentElement && doc.documentElement.clientHeight; 12854 } 12855 }, { 12856 key: "isLocalStorageSupported", 12857 value: function isLocalStorageSupported() { 12858 try { 12859 localStorage.setItem('test', 'test'); 12860 localStorage.removeItem('test'); 12861 return true; 12862 } catch (e) { 12863 return false;
12864 } 12865 } 12866 }, { 12867 key: "addGlobalClass", 12868 value: function addGlobalClass() { 12869 var globalClass = 'bx-core'; 12870 12871 if (Dom.hasClass(document.documentElement, globalClass)) { 12872 return; 12873 } 12874 12875 if (Browser.isIOS()) { 12876 globalClass += ' bx-ios'; 12877 } else if (Browser.isMac()) { 12878 globalClass += ' bx-mac'; 12879 } else if (Browser.isAndroid()) { 12880 globalClass += ' bx-android'; 12881 } 12882 12883 globalClass += Browser.isMobile() ? ' bx-touch' : ' bx-no-touch'; 12884 globalClass += Browser.isRetina() ? ' bx-retina' : ' bx-no-retina'; 12885 var ieVersion = -1; 12886 12887 if (/AppleWebKit/.test(navigator.userAgent)) { 12888 globalClass += ' bx-chrome'; 12889 } else if (Browser.detectIEVersion() > 0) { 12890 ieVersion = Browser.detectIEVersion(); 12891 globalClass += " bx-ie bx-ie".concat(ieVersion); 12892 12893 if (ieVersion > 7 && ieVersion < 10 && !Browser.isDoctype()) { 12894 globalClass += ' bx-quirks'; 12895 } 12896 } else if (/Opera/.test(navigator.userAgent)) { 12897 globalClass += ' bx-opera'; 12898 } else if (/Gecko/.test(navigator.userAgent)) { 12899 globalClass += ' bx-firefox'; 12900 } 12901 12902 Dom.addClass(document.documentElement, globalClass); 12903 } 12904 }, { 12905 key: "detectAndroidVersion", 12906 value: function detectAndroidVersion() { 12907 var re = new RegExp('Android ([0-9]+[.0-9]*)'); 12908 12909 if (re.exec(navigator.userAgent) != null) { 12910 var res = navigator.userAgent.match(re); 12911 12912 if (Type.isArrayLike(res) && res.length > 0) { 12913 return parseFloat(res[1]); 12914 } 12915 } 12916 12917 return 0; 12918 } 12919 }, { 12920 key: "isPropertySupported", 12921 value: function isPropertySupported(jsProperty, returnCSSName) { 12922 if (jsProperty === '') { 12923 return false; 12924 } 12925 12926 function getCssName(propertyName) { 12927 return propertyName.replace(/([A-Z])/g, function () { 12928 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 12929 args[_key] = arguments[_key]; 12930 } 12931 12932 return "-".concat(args[1].toLowerCase()); 12933 }); 12934 } 12935 12936 function getJsName(cssName) { 12937 var reg = /(\\-([a-z]))/g; 12938 12939 if (reg.test(cssName)) { 12940 return cssName.replace(reg, function () { 12941 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 12942 args[_key2] = arguments[_key2]; 12943 } 12944 12945 return args[2].toUpperCase(); 12946 }); 12947 } 12948 12949 return cssName; 12950 } 12951 12952 var property = jsProperty.includes('-') ? getJsName(jsProperty) : jsProperty; 12953 var bReturnCSSName = !!returnCSSName; 12954 var ucProperty = property.charAt(0).toUpperCase() + property.slice(1); 12955 var props = ['Webkit', 'Moz', 'O', 'ms'].join("".concat(ucProperty, " ")); 12956 var properties = "".concat(property, " ").concat(props, " ").concat(ucProperty).split(' '); 12957 var obj = document.body || document.documentElement; 12958 12959 for (var i = 0; i < properties.length; i += 1) { 12960 var prop = properties[i]; 12961 12962 if (obj && 'style' in obj && prop in obj.style) { 12963 var lowerProp = prop.substr(0, prop.length - property.length).toLowerCase(); 12964 var prefix = prop === property ? '' : "-".concat(lowerProp, "-"); 12965 return bReturnCSSName ? prefix + getCssName(property) : prop; 12966 } 12967 } 12968 12969 return false; 12970 } 12971 }, { 12972 key: "addGlobalFeatures", 12973 value: function addGlobalFeatures(features) { 12974 if (!Type.isArray(features)) { 12975 return; 12976 } 12977 12978 var classNames = []; 12979 12980 for (var i = 0; i < features.length; i += 1) { 12981 var support = !!Browser.isPropertySupported(features[i]); 12982 classNames.push("bx-".concat(support ? '' : 'no-').concat(features[i].toLowerCase())); 12983 } 12984 12985 Dom.addClass(document.documentElement, classNames.join(' ')); 12986 } 12987 }]); 12988 return Browser; 12989 }(); 12990 12991 var Cookie = /*#__PURE__*/function () { 12992 function Cookie() { 12993 babelHelpers.classCallCheck(this, Cookie); 12994 } 12995 12996 babelHelpers.createClass(Cookie, null, [{ 12997 key: "getList", 12998 12999 /** 13000 * Gets cookies list for current domain 13001 * @return {object} 13002 */ 13003 value: function getList() { 13004 return document.cookie.split(';').map(function (item) { 13005 return item.split('='); 13006 }).map(function (item) { 13007 return item.map(function (subItem) { 13008 return subItem.trim(); 13009 }); 13010 }).reduce(function (acc, item) { 13011 var _item = babelHelpers.slicedToArray(item, 2), 13012 key = _item[0], 13013 value = _item[1]; 13014 13015 acc[decodeURIComponent(key)] = decodeURIComponent(value); 13016 return acc; 13017 }, {}); 13018 } 13019 /** 13020 * Gets cookie value 13021 * @param {string} name 13022 * @return {*} 13023 */ 13024 13025 }, { 13026 key: "get", 13027 value: function get(name) { 13028 var cookiesList = Cookie.getList(); 13029 13030 if (name in cookiesList) { 13031 return cookiesList[name]; 13032 } 13033 13034 return undefined; 13035 } 13036 /** 13037 * Sets cookie 13038 * @param {string} name 13039 * @param {*} value 13040 * @param {object} [options] 13041 */ 13042 13043 }, { 13044 key: "set", 13045 value: function set(name, value) { 13046 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; 13047 var attributes = babelHelpers.objectSpread({ 13048 expires: '' 13049 }, options); 13050 13051 if (Type.isNumber(attributes.expires)) { 13052 var now = +new Date(); 13053 var days = attributes.expires; 13054 var dayInMs = 864e+5; 13055 attributes.expires = new Date(now + days * dayInMs); 13056 } 13057 13058 if (Type.isDate(attributes.expires)) { 13059 attributes.expires = attributes.expires.toUTCString(); 13060 } 13061 13062 var safeName = decodeURIComponent(String(name)).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape); 13063 var safeValue = encodeURIComponent(String(value)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent); 13064 var stringifiedAttributes = Object.keys(attributes).reduce(function (acc, key) { 13065 var attributeValue = attributes[key]; 13066 13067 if (!attributeValue) { 13068 return acc; 13069 } 13070 13071 if (attributeValue === true) { 13072 return "".concat(acc, "; ").concat(key); 13073 } 13074 /** 13075 * Considers RFC 6265 section 5.2: 13076 * ... 13077 * 3. If the remaining unparsed-attributes contains a %x3B (';') 13078 * character: 13079 * Consume the characters of the unparsed-attributes up to, 13080 * not including, the first %x3B (';') character. 13081 */ 13082 13083 13084 return "".concat(acc, "; ").concat(key, "=").concat(attributeValue.split(';')[0]); 13085 }, ''); 13086 document.cookie = "".concat(safeName, "=").concat(safeValue).concat(stringifiedAttributes); 13087 } 13088 /** 13089 * Removes cookie 13090 * @param {string} name 13091 * @param {object} [options] 13092 */ 13093 13094 }, { 13095 key: "remove", 13096 value: function remove(name) { 13097 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 13098 Cookie.set(name, '', babelHelpers.objectSpread({}, options, { 13099 expires: -1 13100 })); 13101 } 13102 }]); 13103 return Cookie; 13104 }(); 13105 13106 function objectToFormData(source) { 13107 var formData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new FormData(); 13108 var pre = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 13109 13110 if (Type.isUndefined(source)) { 13111 return formData; 13112 } 13113 13114 if (Type.isNull(source)) { 13115 formData.append(pre, ''); 13116 } else if (Type.isArray(source)) { 13117 if (!source.length) { 13118 var _key = "".concat(pre, "[]"); 13119 13120 formData.append(_key, ''); 13121 } else { 13122 source.forEach(function (value, index) { 13123 var key = "".concat(pre, "[").concat(index, "]"); 13124 objectToFormData(value, formData, key); 13125 }); 13126 } 13127 } else if (Type.isDate(source)) { 13128 formData.append(pre, source.toISOString()); 13129 } else if (Type.isObject(source) && !Type.isFile(source) && !Type.isBlob(source)) { 13130 Object.keys(source).forEach(function (property) { 13131 var value = source[property]; 13132 var preparedProperty = property; 13133 13134 if (Type.isArray(value)) { 13135 while (property.length > 2 && property.lastIndexOf('[]') === property.length - 2) { 13136 preparedProperty = property.substring(0, property.length - 2); 13137 } 13138 } 13139 13140 var key = pre ? "".concat(pre, "[").concat(preparedProperty, "]") : preparedProperty; 13141 objectToFormData(value, formData, key); 13142 }); 13143 } else { 13144 formData.append(pre, source); 13145 } 13146 13147 return formData; 13148 } 13149 13150 var Data = /*#__PURE__*/function () { 13151 function Data() { 13152 babelHelpers.classCallCheck(this, Data); 13153 } 13154 13155 babelHelpers.createClass(Data, null, [{ 13156 key: "convertObjectToFormData", 13157 13158 /** 13159 * Converts object to FormData 13160 * @param source 13161 * @return {FormData} 13162 */ 13163 value: function convertObjectToFormData(source) { 13164 return objectToFormData(source); 13165 } 13166 }]); 13167 return Data; 13168 }(); 13169 13170 /** 13171 * @memberOf BX 13172 */ 13173 13174 var Http = function Http() { 13175 babelHelpers.classCallCheck(this, Http); 13176 }; 13177 13178 babelHelpers.defineProperty(Http, "Cookie", Cookie); 13179 babelHelpers.defineProperty(Http, "Data", Data); 13180 13181 function message(value) { 13182 if (Type.isString(value)) { 13183 if (Type.isNil(message[value])) { 13184 // eslint-disable-next-line 13185 EventEmitter.emit('onBXMessageNotFound', new BaseEvent({ 13186 compatData: [value] 13187 })); 13188 13189 if (Type.isNil(message[value])) { 13190 Runtime.debug("message undefined: ".concat(value)); 13191 message[value] = ''; 13192 } 13193 } 13194 } 13195 13196 if (Type.isPlainObject(value)) { 13197 Object.keys(value).forEach(function (key) { 13198 message[key] = value[key]; 13199 }); 13200 } 13201 13202 return message[value]; 13203 } 13204 13205 if (!Type.isNil(window.BX) && Type.isFunction(window.BX.message)) { 13206 Object.keys(window.BX.message).forEach(function (key) { 13207 message(babelHelpers.defineProperty({}, key, window.BX.message[key])); 13208 }); 13209 } 13210 13211 /** 13212 * Implements interface for works with language messages 13213 * @memberOf BX 13214 */ 13215 13216 var Loc = /*#__PURE__*/function () { 13217 function Loc() { 13218 babelHelpers.classCallCheck(this, Loc); 13219 } 13220 13221 babelHelpers.createClass(Loc, null, [{ 13222 key: "getMessage", 13223 13224 /** 13225 * Gets message by id 13226 * @param {string} messageId 13227 * @param {object} replacements 13228 * @return {?string} 13229 */
13230 value: function getMessage(messageId) { 13231 var replacements = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 13232 var mess = message(messageId); 13233 13234 if (Type.isString(mess) && Type.isPlainObject(replacements)) { 13235 Object.keys(replacements).forEach(function (replacement) { 13236 var globalRegexp = new RegExp(replacement, 'gi'); 13237 mess = mess.replace(globalRegexp, function () { 13238 return Type.isNil(replacements[replacement]) ? '' : String(replacements[replacement]); 13239 }); 13240 }); 13241 } 13242 13243 return mess; 13244 } 13245 }, { 13246 key: "hasMessage", 13247 value: function hasMessage(messageId) { 13248 return Type.isString(messageId) && !Type.isNil(message[messageId]); 13249 } 13250 /** 13251 * Sets message or messages 13252 * @param {string | Object<string, string>} id 13253 * @param {string} [value] 13254 */ 13255 13256 }, { 13257 key: "setMessage", 13258 value: function setMessage(id, value) { 13259 if (Type.isString(id) && Type.isString(value)) { 13260 message(babelHelpers.defineProperty({}, id, value)); 13261 } 13262 13263 if (Type.isObject(id)) { 13264 message(id); 13265 } 13266 } 13267 /** 13268 * Gets plural message by id and number 13269 * @param {string} messageId 13270 * @param {number} value 13271 * @param {object} [replacements] 13272 * @return {?string} 13273 */ 13274 13275 }, { 13276 key: "getMessagePlural", 13277 value: function getMessagePlural(messageId, value) { 13278 var replacements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 13279 var result = ''; 13280 13281 if (Type.isNumber(value)) { 13282 if (this.hasMessage("".concat(messageId, "_PLURAL_").concat(this.getPluralForm(value)))) { 13283 result = this.getMessage("".concat(messageId, "_PLURAL_").concat(this.getPluralForm(value)), replacements); 13284 } else { 13285 result = this.getMessage("".concat(messageId, "_PLURAL_1"), replacements); 13286 } 13287 } else { 13288 result = this.getMessage(messageId, replacements); 13289 } 13290 13291 return result; 13292 } 13293 /** 13294 * Gets language plural form id by number 13295 * see http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html 13296 * @param {number} value 13297 * @param {string} [languageId] 13298 * @return {?number} 13299 */ 13300 13301 }, { 13302 key: "getPluralForm", 13303 value: function getPluralForm(value, languageId) { 13304 var pluralForm; 13305 13306 if (!Type.isStringFilled(languageId)) { 13307 languageId = message('LANGUAGE_ID'); 13308 } 13309 13310 if (value < 0) { 13311 value = -1 * value; 13312 } 13313 13314 switch (languageId) { 13315 case 'ar': 13316 pluralForm = value !== 1 ? 1 : 0; 13317 /* 13318 if (value === 0) 13319 { 13320 pluralForm = 0; 13321 } 13322 else if (value === 1) 13323 { 13324 pluralForm = 1; 13325 } 13326 else if (value === 2) 13327 { 13328 pluralForm = 2; 13329 } 13330 else if ( 13331 value % 100 >= 3 13332 && value % 100 <= 10 13333 ) 13334 { 13335 pluralForm = 3; 13336 } 13337 else if (value % 100 >= 11) 13338 { 13339 pluralForm = 4; 13340 } 13341 else 13342 { 13343 pluralForm = 5; 13344 } 13345 */ 13346 13347 break; 13348 13349 case 'br': 13350 case 'fr': 13351 case 'tr': 13352 pluralForm = value > 1 ? 1 : 0; 13353 break; 13354 13355 case 'de': 13356 case 'en': 13357 case 'hi': 13358 case 'it': 13359 case 'la': 13360 pluralForm = value !== 1 ? 1 : 0; 13361 break; 13362 13363 case 'ru': 13364 case 'ua': 13365 if (value % 10 === 1 && value % 100 !== 11) { 13366 pluralForm = 0; 13367 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 13368 pluralForm = 1; 13369 } else { 13370 pluralForm = 2; 13371 } 13372 13373 break; 13374 13375 case 'pl': 13376 if (value === 1) { 13377 pluralForm = 0; 13378 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 13379 pluralForm = 1; 13380 } else { 13381 pluralForm = 2; 13382 } 13383 13384 break; 13385 13386 case 'id': 13387 case 'ja': 13388 case 'ms': 13389 case 'sc': 13390 case 'tc': 13391 case 'th': 13392 case 'vn': 13393 pluralForm = 0; 13394 break; 13395 13396 default: 13397 pluralForm = 1; 13398 break; 13399 } 13400 13401 return pluralForm; 13402 } 13403 }]); 13404 return Loc; 13405 }(); 13406 13407 var handlers = new Map(); 13408 var children = new Map(); 13409 13410 var getUid = function () { 13411 var incremental = 0; 13412 return function () { 13413 incremental += 1; 13414 return incremental; 13415 }; 13416 }(); 13417 13418 function bindAll(element, handlersMap) {
13419 handlersMap.forEach(function (handler, key) { 13420 var currentElement = element.querySelector("[".concat(key, "]")); 13421 13422 if (currentElement) { 13423 currentElement.removeAttribute(key); 13424 var event = key.replace(/-(.*)/, ''); 13425 Event.bind(currentElement, event, handler); 13426 handlers.delete(key); 13427 } 13428 }); 13429 } 13430 13431 function replaceChild(element, childrenMap) { 13432 childrenMap.forEach(function (item, id) { 13433 var currentElement = element.getElementById(id); 13434 13435 if (currentElement) { 13436 Dom.replace(currentElement, item); 13437 children.delete(id); 13438 } 13439 }); 13440 } 13441 13442 function render(sections) { 13443 var eventAttrRe = /[ |\t]on(\w+)="$/; 13444 var uselessSymbolsRe = /[\r\n\t]/g; 13445 13446 for (var _len = arguments.length, substitutions = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 13447 substitutions[_key - 1] = arguments[_key]; 13448 } 13449 13450 var html = substitutions.reduce(function (acc, item, index) { 13451 var preparedAcc = acc; // Process event handlers 13452 13453 var matches = acc.match(eventAttrRe); 13454 13455 if (matches && Type.isFunction(item)) { 13456 var eventName = matches[1].replace(/=['|"]/, ''); 13457 var attrName = "".concat(eventName, "-").concat(getUid()); 13458 var attribute = "".concat(attrName, "=\""); 13459 preparedAcc = preparedAcc.replace(eventAttrRe, " ".concat(attribute)); 13460 handlers.set(attrName, item); 13461 preparedAcc += sections[index + 1].replace(uselessSymbolsRe, ' ').replace(/ +/g, ' '); 13462 return preparedAcc; 13463 } // Process element 13464 13465 13466 if (Type.isDomNode(item)) { 13467 var childKey = "tmp___".concat(getUid()); 13468 children.set(childKey, item); 13469 preparedAcc += "<span id=\"".concat(childKey, "\"> </span>"); 13470 preparedAcc += sections[index + 1]; 13471 return preparedAcc; 13472 } // Process array 13473 13474 13475 if (Type.isArray(item)) { 13476 babelHelpers.toConsumableArray(item).forEach(function (currentElement) { 13477 if (Type.isDomNode(currentElement)) { 13478 var _childKey = "tmp___".concat(getUid()); 13479 13480 children.set(_childKey, currentElement); 13481 preparedAcc += "<span id=\"".concat(_childKey, "\"> </span>"); 13482 } 13483 }); 13484 preparedAcc += sections[index + 1]; 13485 return preparedAcc; 13486 } 13487 13488 return preparedAcc + item + sections[index + 1]; 13489 }, sections[0]); 13490 var lowercaseHtml = html.trim().toLowerCase(); 13491 13492 if (lowercaseHtml.startsWith('<!doctype') || lowercaseHtml.startsWith('<html')) { 13493 var doc = document.implementation.createHTMLDocument(''); 13494 doc.documentElement.innerHTML = html; 13495 replaceChild(doc, children); 13496 bindAll(doc, handlers); 13497 handlers.clear(); 13498 return doc; 13499 } 13500 13501 var parser = new DOMParser(); 13502 var parsedDocument = parser.parseFromString(html, 'text/html'); 13503 replaceChild(parsedDocument, children); 13504 bindAll(parsedDocument, handlers); 13505 13506 if (parsedDocument.head.children.length && parsedDocument.body.children.length) { 13507 return parsedDocument; 13508 } 13509 13510 if (parsedDocument.body.children.length === 1) { 13511 var _parsedDocument$body$ = babelHelpers.slicedToArray(parsedDocument.body.children, 1), 13512 el = _parsedDocument$body$[0]; 13513 13514 Dom.remove(el); 13515 return el; 13516 } 13517 13518 if (parsedDocument.body.children.length > 1) { 13519 return babelHelpers.toConsumableArray(parsedDocument.body.children).map(function (item) { 13520 Dom.remove(item); 13521 return item; 13522 }); 13523 } 13524 13525 if (parsedDocument.body.children.length === 0) { 13526 if (parsedDocument.head.children.length === 1) { 13527 var _parsedDocument$head$ = babelHelpers.slicedToArray(parsedDocument.head.children, 1), 13528 _el = _parsedDocument$head$[0]; 13529 13530 Dom.remove(_el); 13531 return _el; 13532 } 13533 13534 if (parsedDocument.head.children.length > 1) { 13535 return babelHelpers.toConsumableArray(parsedDocument.head.children).map(function (item) { 13536 Dom.remove(item); 13537 return item; 13538 }); 13539 } 13540 } 13541 13542 return false; 13543 } 13544 13545 function parseProps(sections) { 13546 for (var _len = arguments.length, substitutions = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 13547 substitutions[_key - 1] = arguments[_key]; 13548 } 13549 13550 return substitutions.reduce(function (acc, item, index) { 13551 var nextSectionIndex = index + 1; 13552 13553 if (!Type.isPlainObject(item) && !Type.isArray(item)) { 13554 return acc + item + sections[nextSectionIndex]; 13555 } 13556 13557 return "".concat(acc, "__s").concat(index).concat(sections[nextSectionIndex]); 13558 }, sections[0]).replace(/[\r\t]/gm, '').split(';\n').map(function (item) { 13559 return item.replace(/\n/, ''); 13560 }).reduce(function (acc, item) { 13561 if (item !== '') { 13562 var matches = item.match(/^[\w-. ]+:/); 13563 var splitted = item.split(/^[\w-. ]+:/); 13564 13565 var _key2 = matches[0].replace(':', '').trim(); 13566 13567 var value = splitted[1].trim(); 13568 var substitutionPlaceholderExp = /^__s\d+/; 13569 13570 if (substitutionPlaceholderExp.test(value)) { 13571 acc[_key2] = substitutions[value.replace('__s', '')]; 13572 return acc; 13573 } 13574 13575 acc[_key2] = value; 13576 } 13577 13578 return acc; 13579 }, {}); 13580 } 13581 /** 13582 * @memberOf BX 13583 */ 13584 13585 13586 var Tag = /*#__PURE__*/function () { 13587 function Tag() { 13588 babelHelpers.classCallCheck(this, Tag); 13589 } 13590 13591 babelHelpers.createClass(Tag, null, [{ 13592 key: "safe", 13593 13594 /** 13595 * Encodes all substitutions 13596 * @param sections 13597 * @param substitutions 13598 * @return {string} 13599 */ 13600 value: function safe(sections) { 13601 for (var _len2 = arguments.length, substitutions = new Array(_len2 > 1 ? _len2 - 1 : 0), _key3 = 1; _key3 < _len2; _key3++) { 13602 substitutions[_key3 - 1] = arguments[_key3]; 13603 } 13604 13605 return substitutions.reduce(function (acc, item, index) { 13606 return acc + Text.encode(item) + sections[index + 1]; 13607 }, sections[0]); 13608 } 13609 /** 13610 * Decodes all substitutions 13611 * @param sections 13612 * @param substitutions 13613 * @return {string} 13614 */ 13615 13616 }, { 13617 key: "unsafe", 13618 value: function unsafe(sections) { 13619 for (var _len3 = arguments.length, substitutions = new Array(_len3 > 1 ? _len3 - 1 : 0), _key4 = 1; _key4 < _len3; _key4++) { 13620 substitutions[_key4 - 1] = arguments[_key4]; 13621 } 13622 13623 return substitutions.reduce(function (acc, item, index) { 13624 return acc + Text.decode(item) + sections[index + 1]; 13625 }, sections[0]); 13626 } 13627 /** 13628 * Adds styles to specified element 13629 * @param {HTMLElement} element 13630 * @return {Function} 13631 */ 13632 13633 }, { 13634 key: "style", 13635 value: function style(element) { 13636 if (!Type.isDomNode(element)) { 13637 throw new Error('element is not HTMLElement'); 13638 } 13639 13640 return function styleTagHandler() { 13641 Dom.style(element, parseProps.apply(void 0, arguments)); 13642 }; 13643 } 13644 /** 13645 * Replace all messages identifiers to real messages 13646 * @param sections 13647 * @param substitutions 13648 * @return {string} 13649 */ 13650 13651 }, { 13652 key: "message", 13653 value: function message(sections) { 13654 for (var _len4 = arguments.length, substitutions = new Array(_len4 > 1 ? _len4 - 1 : 0), _key5 = 1; _key5 < _len4; _key5++) { 13655 substitutions[_key5 - 1] = arguments[_key5]; 13656 } 13657 13658 return substitutions.reduce(function (acc, item, index) { 13659 return acc + Loc.getMessage(item) + sections[index + 1]; 13660 }, sections[0]); 13661 } 13662 }, { 13663 key: "attrs", 13664 13665 /** 13666 * Adds attributes to specified element 13667 * @param element 13668 * @return {Function} 13669 */ 13670 value: function attrs(element) { 13671 if (!Type.isDomNode(element)) { 13672 throw new Error('element is not HTMLElement'); 13673 } 13674 13675 return function attrsTagHandler() { 13676 Dom.attr(element, parseProps.apply(void 0, arguments)); 13677 }; 13678 } 13679 }]); 13680 return Tag; 13681 }(); 13682 13683 babelHelpers.defineProperty(Tag, "render", render); 13684 babelHelpers.defineProperty(Tag, "attr", Tag.attrs); 13685 13686 function getParser(format) { 13687 switch (format) {
13688 case 'index': 13689 return function (sourceKey, value, accumulator) { 13690 var result = /\[(\w*)\]$/.exec(sourceKey); 13691 var key = sourceKey.replace(/\[\w*\]$/, ''); 13692 13693 if (Type.isNil(result)) { 13694 accumulator[key] = value; 13695 return; 13696 } 13697 13698 if (Type.isUndefined(accumulator[key])) { 13699 accumulator[key] = {}; 13700 } 13701 13702 accumulator[key][result[1]] = value; 13703 }; 13704 13705 case 'bracket': 13706 return function (sourceKey, value, accumulator) { 13707 var result = /(\[\])$/.exec(sourceKey); 13708 var key = sourceKey.replace(/\[\]$/, ''); 13709 13710 if (Type.isNil(result)) { 13711 accumulator[key] = value; 13712 return; 13713 } 13714 13715 if (Type.isUndefined(accumulator[key])) { 13716 accumulator[key] = [value]; 13717 return; 13718 } 13719 13720 accumulator[key] = [].concat(accumulator[key], value); 13721 }; 13722 13723 default: 13724 return function (sourceKey, value, accumulator) { 13725 var key = sourceKey.replace(/\[\]$/, ''); 13726 accumulator[key] = value; 13727 }; 13728 } 13729 } 13730 13731 function getKeyFormat(key) { 13732 if (/^\w+\[([\w]+)\]$/.test(key)) { 13733 return 'index'; 13734 } 13735 13736 if (/^\w+\[\]$/.test(key)) { 13737 return 'bracket'; 13738 } 13739 13740 return 'default'; 13741 } 13742 13743 function parseQuery(input) { 13744 if (!Type.isString(input)) { 13745 return {}; 13746 } 13747 13748 var url = input.trim().replace(/^[?#&]/, ''); 13749 13750 if (!url) { 13751 return {}; 13752 } 13753 13754 return url.split('&').reduce(function (acc, param) { 13755 var _param$replace$split = param.replace(/\+/g, ' ').split('='), 13756 _param$replace$split2 = babelHelpers.slicedToArray(_param$replace$split, 2), 13757 key = _param$replace$split2[0], 13758 value = _param$replace$split2[1]; 13759 13760 var keyFormat = getKeyFormat(key); 13761 var formatter = getParser(keyFormat); 13762 formatter(key, value, acc); 13763 return acc; 13764 }, {}); 13765 } 13766 13767 var urlExp = /^((\w+):)?(\/\/((\w+)?(:(\w+))?@)?([^\/\?:]+)(:(\d+))?)?(\/?([^\/\?#][^\?#]*)?)?(\?([^#]+))?(#(\w*))?/; 13768 function parseUrl(url) { 13769 var result = url.match(urlExp); 13770 13771 if (Type.isArray(result)) { 13772 var queryParams = parseQuery(result[14]); 13773 return { 13774 useShort: /^\/\//.test(url), 13775 href: result[0] || '', 13776 schema: result[2] || '', 13777 host: result[8] || '', 13778 port: result[10] || '', 13779 path: result[11] || '', 13780 query: result[14] || '', 13781 queryParams: queryParams, 13782 hash: result[16] || '', 13783 username: result[5] || '', 13784 password: result[7] || '', 13785 origin: result[8] || '' 13786 }; 13787 } 13788 13789 return {}; 13790 } 13791 13792 function buildQueryString() { 13793 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 13794 var queryString = Object.keys(params).reduce(function (acc, key) { 13795 if (Type.isArray(params[key])) { 13796 params[key].forEach(function (paramValue) { 13797 acc.push("".concat(key, "[]=").concat(paramValue)); 13798 }, ''); 13799 } 13800 13801 if (Type.isPlainObject(params[key])) { 13802 Object.keys(params[key]).forEach(function (paramIndex) { 13803 acc.push("".concat(key, "[").concat(paramIndex, "]=").concat(params[key][paramIndex])); 13804 }, ''); 13805 } 13806 13807 if (!Type.isObject(params[key]) && !Type.isArray(params[key])) { 13808 acc.push("".concat(key, "=").concat(params[key])); 13809 } 13810 13811 return acc; 13812 }, []).join('&'); 13813 13814 if (queryString.length > 0) { 13815 return "?".concat(queryString); 13816 } 13817 13818 return queryString; 13819 } 13820 13821 function prepareParamValue(value) { 13822 if (Type.isArray(value)) { 13823 return value.map(function (item) { 13824 return String(item); 13825 }); 13826 } 13827 13828 if (Type.isPlainObject(value)) { 13829 return babelHelpers.objectSpread({}, value); 13830 } 13831 13832 return String(value); 13833 } 13834 13835 var map = new WeakMap(); 13836 /** 13837 * Implements interface for works with URI 13838 * @memberOf BX 13839 */ 13840 13841 var Uri = /*#__PURE__*/function () { 13842 babelHelpers.createClass(Uri, null, [{ 13843 key: "addParam", 13844 value: function addParam(url) { 13845 var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 13846 return new Uri(url).setQueryParams(params).toString(); 13847 } 13848 }, { 13849 key: "removeParam", 13850 value: function removeParam(url, params) { 13851 var _Uri; 13852 13853 var removableParams = Type.isArray(params) ? params : [params]; 13854 return (_Uri = new Uri(url)).removeQueryParam.apply(_Uri, babelHelpers.toConsumableArray(removableParams)).toString(); 13855 } 13856 }]); 13857 13858 function Uri() { 13859 var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; 13860 babelHelpers.classCallCheck(this, Uri); 13861 map.set(this, parseUrl(url)); 13862 } 13863 /** 13864 * Gets schema 13865 * @return {?string} 13866 */ 13867 13868 13869 babelHelpers.createClass(Uri, [{ 13870 key: "getSchema", 13871 value: function getSchema() { 13872 return map.get(this).schema; 13873 } 13874 /** 13875 * Sets schema 13876 * @param {string} schema 13877 * @return {Uri} 13878 */ 13879 13880 }, { 13881 key: "setSchema", 13882 value: function setSchema(schema) { 13883 map.get(this).schema = String(schema); 13884 return this; 13885 } 13886 /** 13887 * Gets host 13888 * @return {?string} 13889 */ 13890 13891 }, { 13892 key: "getHost", 13893 value: function getHost() { 13894 return map.get(this).host; 13895 } 13896 /** 13897 * Sets host 13898 * @param {string} host 13899 * @return {Uri} 13900 */ 13901 13902 }, { 13903 key: "setHost", 13904 value: function setHost(host) { 13905 map.get(this).host = String(host); 13906 return this; 13907 } 13908 /** 13909 * Gets port 13910 * @return {?string} 13911 */ 13912 13913 }, { 13914 key: "getPort", 13915 value: function getPort() { 13916 return map.get(this).port; 13917 } 13918 /** 13919 * Sets port 13920 * @param {String | Number} port 13921 * @return {Uri} 13922 */ 13923 13924 }, { 13925 key: "setPort", 13926 value: function setPort(port) { 13927 map.get(this).port = String(port); 13928 return this; 13929 } 13930 /** 13931 * Gets path 13932 * @return {?string} 13933 */ 13934 13935 }, { 13936 key: "getPath", 13937 value: function getPath() { 13938 return map.get(this).path; 13939 } 13940 /** 13941 * Sets path 13942 * @param {string} path 13943 * @return {Uri} 13944 */ 13945 13946 }, { 13947 key: "setPath", 13948 value: function setPath(path) { 13949 if (!/^\//.test(path)) { 13950 map.get(this).path = "/".concat(String(path)); 13951 return this; 13952 } 13953 13954 map.get(this).path = String(path); 13955 return this; 13956 } 13957 /** 13958 * Gets query 13959 * @return {?string} 13960 */ 13961 13962 }, { 13963 key: "getQuery", 13964 value: function getQuery() { 13965 return buildQueryString(map.get(this).queryParams); 13966 } 13967 /** 13968 * Gets query param value by name 13969 * @param {string} key 13970 * @return {?string} 13971 */ 13972 13973 }, { 13974 key: "getQueryParam", 13975 value: function getQueryParam(key) { 13976 var params = this.getQueryParams(); 13977 13978 if (key in params) { 13979 return params[key]; 13980 } 13981 13982 return null; 13983 } 13984 /** 13985 * Sets query param 13986 * @param {string} key 13987 * @param [value] 13988 * @return {Uri} 13989 */ 13990 13991 }, { 13992 key: "setQueryParam", 13993 value: function setQueryParam(key) { 13994 var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; 13995 map.get(this).queryParams[key] = prepareParamValue(value); 13996 return this; 13997 } 13998 /** 13999 * Gets query params 14000 * @return {Object<string, any>} 14001 */ 14002 14003 }, { 14004 key: "getQueryParams", 14005 value: function getQueryParams() { 14006 return babelHelpers.objectSpread({}, map.get(this).queryParams); 14007 } 14008 /** 14009 * Sets query params 14010 * @param {Object<string, any>} params 14011 * @return {Uri} 14012 */ 14013 14014 }, { 14015 key: "setQueryParams", 14016 value: function setQueryParams() { 14017 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
14018 var currentParams = this.getQueryParams(); 14019 var newParams = babelHelpers.objectSpread({}, currentParams, params); 14020 Object.keys(newParams).forEach(function (key) { 14021 newParams[key] = prepareParamValue(newParams[key]); 14022 }); 14023 map.get(this).queryParams = newParams; 14024 return this; 14025 } 14026 /** 14027 * Removes query params by name 14028 * @param keys 14029 * @return {Uri} 14030 */ 14031 14032 }, { 14033 key: "removeQueryParam", 14034 value: function removeQueryParam() { 14035 var currentParams = babelHelpers.objectSpread({}, map.get(this).queryParams); 14036 14037 for (var _len = arguments.length, keys = new Array(_len), _key = 0; _key < _len; _key++) { 14038 keys[_key] = arguments[_key]; 14039 } 14040 14041 keys.forEach(function (key) { 14042 if (key in currentParams) { 14043 delete currentParams[key]; 14044 } 14045 }); 14046 map.get(this).queryParams = currentParams; 14047 return this; 14048 } 14049 /** 14050 * Gets fragment 14051 * @return {?string} 14052 */ 14053 14054 }, { 14055 key: "getFragment", 14056 value: function getFragment() { 14057 return map.get(this).hash; 14058 } 14059 /** 14060 * Sets fragment 14061 * @param {string} hash 14062 * @return {Uri} 14063 */ 14064 14065 }, { 14066 key: "setFragment", 14067 value: function setFragment(hash) { 14068 map.get(this).hash = String(hash); 14069 return this; 14070 } 14071 /** 14072 * Serializes URI 14073 * @return {Object} 14074 */ 14075 14076 }, { 14077 key: "serialize", 14078 value: function serialize() { 14079 var serialized = babelHelpers.objectSpread({}, map.get(this)); 14080 serialized.href = this.toString(); 14081 return serialized; 14082 } 14083 /** 14084 * Gets URI string 14085 * @return {string} 14086 */ 14087 14088 }, { 14089 key: "toString", 14090 value: function toString() { 14091 var data = babelHelpers.objectSpread({}, map.get(this)); 14092 var protocol = data.schema ? "".concat(data.schema, "://") : ''; 14093 14094 if (data.useShort) { 14095 protocol = '//'; 14096 } 14097 14098 var port = function () { 14099 if (Type.isString(data.port) && !['', '80'].includes(data.port)) { 14100 return ":".concat(data.port); 14101 } 14102 14103 return ''; 14104 }(); 14105 14106 var host = this.getHost(); 14107 var path = this.getPath(); 14108 var query = buildQueryString(data.queryParams); 14109 var hash = data.hash ? "#".concat(data.hash) : ''; 14110 return "".concat(host ? protocol : '').concat(host).concat(host ? port : '').concat(path).concat(query).concat(hash); 14111 } 14112 }]); 14113 return Uri; 14114 }(); 14115 14116 /** 14117 * @memberOf BX 14118 */ 14119 var Validation = /*#__PURE__*/function () { 14120 function Validation() { 14121 babelHelpers.classCallCheck(this, Validation); 14122 } 14123 14124 babelHelpers.createClass(Validation, null, [{ 14125 key: "isEmail", 14126 14127 /** 14128 * Checks that value is valid email 14129 * @param value 14130 * @return {boolean} 14131 */ 14132 value: function isEmail(value) { 14133 var exp = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/; 14134 return exp.test(String(value).toLowerCase()); 14135 } 14136 }]); 14137 return Validation; 14138 }(); 14139 14140 var BaseCache = /*#__PURE__*/function () { 14141 function BaseCache() { 14142 babelHelpers.classCallCheck(this, BaseCache); 14143 babelHelpers.defineProperty(this, "storage", new Map()); 14144 } 14145 14146 babelHelpers.createClass(BaseCache, [{ 14147 key: "get", 14148 14149 /** 14150 * Gets cached value or default value 14151 */ 14152 value: function get(key, defaultValue) { 14153 if (!this.storage.has(key)) { 14154 if (Type.isFunction(defaultValue)) { 14155 return defaultValue(); 14156 } 14157 14158 if (!Type.isUndefined(defaultValue)) { 14159 return defaultValue; 14160 } 14161 } 14162 14163 return this.storage.get(key); 14164 } 14165 /** 14166 * Sets cache entry 14167 */ 14168 14169 }, { 14170 key: "set", 14171 value: function set(key, value) { 14172 this.storage.set(key, value); 14173 } 14174 /** 14175 * Deletes cache entry 14176 */ 14177 14178 }, { 14179 key: "delete", 14180 value: function _delete(key) { 14181 this.storage.delete(key); 14182 } 14183 /** 14184 * Checks that storage contains entry with specified key 14185 */ 14186 14187 }, { 14188 key: "has", 14189 value: function has(key) { 14190 return this.storage.has(key); 14191 } 14192 /** 14193 * Gets cached value if exists, 14194 */ 14195 14196 }, { 14197 key: "remember", 14198 value: function remember(key, defaultValue) { 14199 if (!this.storage.has(key)) { 14200 if (Type.isFunction(defaultValue)) { 14201 this.storage.set(key, defaultValue()); 14202 } else if (!Type.isUndefined(defaultValue)) { 14203 this.storage.set(key, defaultValue); 14204 } 14205 } 14206 14207 return this.storage.get(key); 14208 } 14209 /** 14210 * Gets storage size 14211 */ 14212 14213 }, { 14214 key: "size", 14215 value: function size() { 14216 return this.storage.size; 14217 } 14218 /** 14219 * Gets storage keys 14220 */ 14221 14222 }, { 14223 key: "keys", 14224 value: function keys() { 14225 return babelHelpers.toConsumableArray(this.storage.keys()); 14226 } 14227 /** 14228 * Gets storage values 14229 */ 14230 14231 }, { 14232 key: "values", 14233 value: function values() { 14234 return babelHelpers.toConsumableArray(this.storage.values()); 14235 } 14236 }]); 14237 return BaseCache; 14238 }(); 14239 14240 var MemoryCache = /*#__PURE__*/function (_BaseCache) { 14241 babelHelpers.inherits(MemoryCache, _BaseCache); 14242 14243 function MemoryCache() { 14244 var _babelHelpers$getProt; 14245 14246 var _this; 14247 14248 babelHelpers.classCallCheck(this, MemoryCache); 14249 14250 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 14251 args[_key] = arguments[_key]; 14252 } 14253 14254 _this = babelHelpers.possibleConstructorReturn(this, (_babelHelpers$getProt = babelHelpers.getPrototypeOf(MemoryCache)).call.apply(_babelHelpers$getProt, [this].concat(args))); 14255 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new Map()); 14256 return _this; 14257 } 14258 14259 return MemoryCache; 14260 }(BaseCache); 14261 14262 var LsStorage = /*#__PURE__*/function () { 14263 function LsStorage() { 14264 babelHelpers.classCallCheck(this, LsStorage); 14265 babelHelpers.defineProperty(this, "stackKey", 'BX.Cache.Storage.LsStorage.stack'); 14266 babelHelpers.defineProperty(this, "stack", null); 14267 } 14268 14269 babelHelpers.createClass(LsStorage, [{ 14270 key: "getStack", 14271 14272 /** 14273 * @private 14274 */ 14275 value: function getStack() { 14276 if (Type.isPlainObject(this.stack)) { 14277 return this.stack; 14278 } 14279 14280 var stack = localStorage.getItem(this.stackKey); 14281 14282 if (Type.isString(stack) && stack !== '') { 14283 var parsedStack = JSON.parse(stack); 14284 14285 if (Type.isPlainObject(parsedStack)) { 14286 this.stack = parsedStack; 14287 return this.stack; 14288 } 14289 } 14290 14291 this.stack = {}; 14292 return this.stack; 14293 } 14294 /** 14295 * @private 14296 */ 14297 14298 }, { 14299 key: "saveStack", 14300 value: function saveStack() { 14301 if (Type.isPlainObject(this.stack)) { 14302 var preparedStack = JSON.stringify(this.stack); 14303 localStorage.setItem(this.stackKey, preparedStack); 14304 } 14305 } 14306 }, { 14307 key: "get", 14308 value: function get(key) {
14309 var stack = this.getStack(); 14310 return stack[key]; 14311 } 14312 }, { 14313 key: "set", 14314 value: function set(key, value) { 14315 var stack = this.getStack(); 14316 stack[key] = value; 14317 this.saveStack(); 14318 } 14319 }, { 14320 key: "delete", 14321 value: function _delete(key) { 14322 var stack = this.getStack(); 14323 14324 if (key in stack) { 14325 delete stack[key]; 14326 } 14327 } 14328 }, { 14329 key: "has", 14330 value: function has(key) { 14331 var stack = this.getStack(); 14332 return key in stack; 14333 } 14334 }, { 14335 key: "keys", 14336 value: function keys() { 14337 var stack = this.getStack(); 14338 return Object.keys(stack); 14339 } 14340 }, { 14341 key: "values", 14342 value: function values() { 14343 var stack = this.getStack(); 14344 return Object.values(stack); 14345 } 14346 }, { 14347 key: "size", 14348 get: function get() { 14349 var stack = this.getStack(); 14350 return Object.keys(stack).length; 14351 } 14352 }]); 14353 return LsStorage; 14354 }(); 14355 14356 var LocalStorageCache = /*#__PURE__*/function (_BaseCache) { 14357 babelHelpers.inherits(LocalStorageCache, _BaseCache); 14358 14359 function LocalStorageCache() { 14360 var _babelHelpers$getProt; 14361 14362 var _this; 14363 14364 babelHelpers.classCallCheck(this, LocalStorageCache); 14365 14366 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 14367 args[_key] = arguments[_key]; 14368 } 14369 14370 _this = babelHelpers.possibleConstructorReturn(this, (_babelHelpers$getProt = babelHelpers.getPrototypeOf(LocalStorageCache)).call.apply(_babelHelpers$getProt, [this].concat(args))); 14371 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new LsStorage()); 14372 return _this; 14373 } 14374 14375 return LocalStorageCache; 14376 }(BaseCache); 14377 14378 /** 14379 * @memberOf BX 14380 */ 14381 14382 var Cache = function Cache() { 14383 babelHelpers.classCallCheck(this, Cache); 14384 }; 14385 14386 babelHelpers.defineProperty(Cache, "MemoryCache", MemoryCache); 14387 babelHelpers.defineProperty(Cache, "LocalStorageCache", LocalStorageCache); 14388 14389 function convertPath(path) { 14390 if (Type.isStringFilled(path)) { 14391 return path.split('.').reduce(function (acc, item) { 14392 item.split(/\[['"]?(.+?)['"]?\]/g).forEach(function (key) { 14393 if (Type.isStringFilled(key)) { 14394 acc.push(key); 14395 } 14396 }); 14397 return acc; 14398 }, []); 14399 } 14400 14401 return []; 14402 } 14403 14404 var SettingsCollection = /*#__PURE__*/function () { 14405 function SettingsCollection() { 14406 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 14407 babelHelpers.classCallCheck(this, SettingsCollection); 14408 14409 if (Type.isPlainObject(options)) { 14410 Object.assign(this, options); 14411 } 14412 } 14413 14414 babelHelpers.createClass(SettingsCollection, [{ 14415 key: "get", 14416 value: function get(path) { 14417 var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 14418 var convertedPath = convertPath(path); 14419 return convertedPath.reduce(function (acc, key) { 14420 if (!Type.isNil(acc) && acc !== defaultValue) { 14421 if (!Type.isUndefined(acc[key])) { 14422 return acc[key]; 14423 } 14424 14425 return defaultValue; 14426 } 14427 14428 return acc; 14429 }, this); 14430 } 14431 }]); 14432 return SettingsCollection; 14433 }(); 14434 14435 function deepFreeze(target) { 14436 if (Type.isObject(target)) { 14437 Object.values(target).forEach(function (value) { 14438 deepFreeze(value); 14439 }); 14440 return Object.freeze(target); 14441 } 14442 14443 return target; 14444 } 14445 14446 var settingsStorage = new Map(); 14447 14448 var Extension$1 = /*#__PURE__*/function () { 14449 function Extension() { 14450 babelHelpers.classCallCheck(this, Extension); 14451 } 14452 14453 babelHelpers.createClass(Extension, null, [{ 14454 key: "getSettings", 14455 value: function getSettings(extensionName) { 14456 if (Type.isStringFilled(extensionName)) { 14457 if (settingsStorage.has(extensionName)) { 14458 return settingsStorage.get(extensionName); 14459 } 14460 14461 var settingsScriptNode = document.querySelector("script[data-extension=\"".concat(extensionName, "\"]")); 14462 14463 if (Type.isDomNode(settingsScriptNode)) { 14464 var decodedSettings = function () { 14465 try { 14466 return new SettingsCollection(JSON.parse(settingsScriptNode.innerHTML)); 14467 } catch (error) { 14468 return new SettingsCollection(); 14469 } 14470 }(); 14471 14472 var frozenSettings = deepFreeze(decodedSettings); 14473 settingsStorage.set(extensionName, frozenSettings); 14474 return frozenSettings; 14475 } 14476 } 14477 14478 return deepFreeze(new SettingsCollection()); 14479 } 14480 }]); 14481 return Extension; 14482 }(); 14483 14484 var _Symbol$iterator; 14485 14486 function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 14487 14488 var _searchIndexToInsert = new WeakSet(); 14489 14490 _Symbol$iterator = Symbol.iterator; 14491 14492 var OrderedArray = /*#__PURE__*/function () { 14493 function OrderedArray() { 14494 var comparator = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 14495 babelHelpers.classCallCheck(this, OrderedArray); 14496 14497 _searchIndexToInsert.add(this); 14498 14499 babelHelpers.defineProperty(this, "comparator", null); 14500 babelHelpers.defineProperty(this, "items", []); 14501 this.comparator = Type.isFunction(comparator) ? comparator : null; 14502 } 14503 14504 babelHelpers.createClass(OrderedArray, [{ 14505 key: "add", 14506 value: function add(item) { 14507 var index = -1; 14508 14509 if (this.comparator) { 14510 index = _classPrivateMethodGet(this, _searchIndexToInsert, _searchIndexToInsert2).call(this, item); 14511 this.items.splice(index, 0, item); 14512 } else { 14513 this.items.push(item); 14514 } 14515 14516 return index; 14517 } 14518 }, { 14519 key: "has", 14520 value: function has(item) { 14521 return this.items.includes(item); 14522 } 14523 }, { 14524 key: "getIndex", 14525 value: function getIndex(item) { 14526 return this.items.indexOf(item); 14527 } 14528 }, { 14529 key: "getByIndex", 14530 value: function getByIndex(index) { 14531 if (Type.isNumber(index) && index >= 0) { 14532 var item = this.items[index]; 14533 return Type.isUndefined(item) ? null : item; 14534 } 14535 14536 return null; 14537 } 14538 }, { 14539 key: "getFirst", 14540 value: function getFirst() { 14541 var first = this.items[0]; 14542 return Type.isUndefined(first) ? null : first; 14543 } 14544 }, { 14545 key: "getLast", 14546 value: function getLast() { 14547 var last = this.items[this.count() - 1]; 14548 return Type.isUndefined(last) ? null : last; 14549 } 14550 }, { 14551 key: "count", 14552 value: function count() { 14553 return this.items.length; 14554 } 14555 }, { 14556 key: "delete", 14557 value: function _delete(item) { 14558 var index = this.getIndex(item); 14559 14560 if (index !== -1) { 14561 this.items.splice(index, 1); 14562 return true; 14563 } 14564 14565 return false;
14566 } 14567 }, { 14568 key: "clear", 14569 value: function clear() { 14570 this.items = []; 14571 } 14572 }, { 14573 key: _Symbol$iterator, 14574 value: function value() { 14575 return this.items[Symbol.iterator](); 14576 } 14577 }, { 14578 key: "forEach", 14579 value: function forEach(callbackfn, thisArg) { 14580 return this.items.forEach(callbackfn, thisArg); 14581 } 14582 }, { 14583 key: "getAll", 14584 value: function getAll() { 14585 return this.items; 14586 } 14587 }, { 14588 key: "getComparator", 14589 value: function getComparator() { 14590 return this.comparator; 14591 } 14592 }, { 14593 key: "sort", 14594 value: function sort() { 14595 var _this = this; 14596 14597 var comparator = this.getComparator(); 14598 14599 if (comparator === null) { 14600 return; 14601 } 14602 /* 14603 Simple implementation 14604 this.items.sort((item1, item2) => { 14605 return comparator(item1, item2); 14606 }); 14607 */ 14608 // For stable sorting https://v8.dev/features/stable-sort 14609 14610 14611 var length = this.items.length; 14612 var indexes = new Array(length); 14613 14614 for (var i = 0; i < length; i++) { 14615 indexes[i] = i; 14616 } // If the comparator returns zero, use the original indexes 14617 14618 14619 indexes.sort(function (index1, index2) { 14620 return comparator(_this.items[index1], _this.items[index2]) || index1 - index2; 14621 }); 14622 14623 for (var _i = 0; _i < length; _i++) { 14624 indexes[_i] = this.items[indexes[_i]]; 14625 } 14626 14627 for (var _i2 = 0; _i2 < length; _i2++) { 14628 this.items[_i2] = indexes[_i2]; 14629 } 14630 } 14631 }]); 14632 return OrderedArray; 14633 }(); 14634 14635 var _searchIndexToInsert2 = function _searchIndexToInsert2(value) { 14636 var low = 0; 14637 var high = this.items.length; 14638 14639 while (low < high) { 14640 var mid = Math.floor((low + high) / 2); 14641 14642 if (this.comparator(this.items[mid], value) >= 0) { 14643 high = mid; 14644 } else { 14645 low = mid + 1; 14646 } 14647 } 14648 14649 return low; 14650 }; 14651 14652 var ZIndexComponent = /*#__PURE__*/function (_EventEmitter) { 14653 babelHelpers.inherits(ZIndexComponent, _EventEmitter); 14654 14655 function ZIndexComponent(element) { 14656 var _this; 14657 14658 var componentOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 14659 babelHelpers.classCallCheck(this, ZIndexComponent); 14660 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(ZIndexComponent).call(this)); 14661 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "sort", 0); 14662 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "alwaysOnTop", false); 14663 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "zIndex", 0); 14664 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "element", null); 14665 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlay", null); 14666 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlayGap", -5); 14667 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "stack", null); 14668 14669 _this.setEventNamespace('BX.Main.ZIndexManager.Component'); 14670 14671 if (!Type.isElementNode(element)) { 14672 throw new Error('ZIndexManager.Component: The argument \'element\' must be a DOM element.'); 14673 } 14674 14675 _this.element = element; 14676 var options = Type.isPlainObject(componentOptions) ? componentOptions : {}; 14677 14678 _this.setAlwaysOnTop(options.alwaysOnTop); 14679 14680 _this.setOverlay(options.overlay); 14681 14682 _this.setOverlayGap(options.overlayGap); 14683 14684 _this.subscribeFromOptions(options.events); 14685 14686 return _this; 14687 } 14688 14689 babelHelpers.createClass(ZIndexComponent, [{ 14690 key: "getSort", 14691 value: function getSort() { 14692 return this.sort; 14693 } 14694 /** 14695 * @internal 14696 * @param sort 14697 */ 14698 14699 }, { 14700 key: "setSort", 14701 value: function setSort(sort) { 14702 if (Type.isNumber(sort)) { 14703 this.sort = sort; 14704 } 14705 } 14706 /** 14707 * @internal 14708 * @param stack 14709 */ 14710 14711 }, { 14712 key: "setStack", 14713 value: function setStack(stack) { 14714 this.stack = stack; 14715 } 14716 }, { 14717 key: "getStack", 14718 value: function getStack() { 14719 return this.stack; 14720 } 14721 }, { 14722 key: "getZIndex", 14723 value: function getZIndex() { 14724 return this.zIndex; 14725 } 14726 /** 14727 * @internal 14728 */ 14729 14730 }, { 14731 key: "setZIndex", 14732 value: function setZIndex(zIndex) { 14733 var changed = this.getZIndex() !== zIndex; 14734 this.getElement().style.setProperty('z-index', zIndex, 'important'); 14735 this.zIndex = zIndex; 14736 14737 if (this.getOverlay() !== null) { 14738 this.getOverlay().style.setProperty('z-index', zIndex + this.getOverlayGap(), 'important'); 14739 } 14740 14741 if (changed) {
14742 this.emit('onZIndexChange', { 14743 component: this 14744 }); 14745 } 14746 } 14747 }, { 14748 key: "getAlwaysOnTop", 14749 value: function getAlwaysOnTop() { 14750 return this.alwaysOnTop; 14751 } 14752 }, { 14753 key: "setAlwaysOnTop", 14754 value: function setAlwaysOnTop(value) { 14755 if (Type.isNumber(value) || Type.isBoolean(value)) { 14756 this.alwaysOnTop = value; 14757 } 14758 } 14759 }, { 14760 key: "getElement", 14761 value: function getElement() { 14762 return this.element; 14763 } 14764 }, { 14765 key: "setOverlay", 14766 value: function setOverlay(overlay, gap) { 14767 if (Type.isElementNode(overlay) || overlay === null) { 14768 this.overlay = overlay; 14769 this.setOverlayGap(gap); 14770 14771 if (this.getStack()) { 14772 this.getStack().sort(); 14773 } 14774 } 14775 } 14776 }, { 14777 key: "getOverlay", 14778 value: function getOverlay() { 14779 return this.overlay; 14780 } 14781 }, { 14782 key: "setOverlayGap", 14783 value: function setOverlayGap(gap) { 14784 if (Type.isNumber(gap)) { 14785 this.overlayGap = gap; 14786 } 14787 } 14788 }, { 14789 key: "getOverlayGap", 14790 value: function getOverlayGap() { 14791 return this.overlayGap; 14792 } 14793 }]); 14794 return ZIndexComponent; 14795 }(EventEmitter); 14796 14797 var ZIndexStack = /*#__PURE__*/function () { 14798 function ZIndexStack(container) { 14799 babelHelpers.classCallCheck(this, ZIndexStack); 14800 babelHelpers.defineProperty(this, "container", null); 14801 babelHelpers.defineProperty(this, "components", null); 14802 babelHelpers.defineProperty(this, "elements", new WeakMap()); 14803 babelHelpers.defineProperty(this, "baseIndex", 1000); 14804 babelHelpers.defineProperty(this, "baseStep", 50); 14805 babelHelpers.defineProperty(this, "sortCount", 0); 14806 14807 if (!Type.isDomNode(container)) { 14808 throw new Error('ZIndexManager.Stack: The \'container\' argument must be a DOM element.'); 14809 } 14810 14811 this.container = container; 14812 14813 var comparator = function comparator(componentA, componentB) { 14814 var result = (componentA.getAlwaysOnTop() || 0) - (componentB.getAlwaysOnTop() || 0); 14815 14816 if (!result) { 14817 result = componentA.getSort() - componentB.getSort(); 14818 } 14819 14820 return result; 14821 }; 14822 14823 this.components = new OrderedArray(comparator); 14824 } 14825 14826 babelHelpers.createClass(ZIndexStack, [{ 14827 key: "getBaseIndex", 14828 value: function getBaseIndex() { 14829 return this.baseIndex; 14830 } 14831 }, { 14832 key: "setBaseIndex", 14833 value: function setBaseIndex(index) { 14834 if (Type.isNumber(index) && index >= 0) { 14835 this.baseIndex = index; 14836 this.sort(); 14837 } 14838 } 14839 }, { 14840 key: "setBaseStep", 14841 value: function setBaseStep(step) { 14842 if (Type.isNumber(step) && step > 0) { 14843 this.baseStep = step; 14844 this.sort(); 14845 } 14846 } 14847 }, { 14848 key: "getBaseStep", 14849 value: function getBaseStep() { 14850 return this.baseStep; 14851 } 14852 }, { 14853 key: "register", 14854 value: function register(element) { 14855 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 14856 14857 if (this.getComponent(element)) { 14858 console.warn('ZIndexManager: You cannot register the element twice.', element); 14859 return this.getComponent(element); 14860 } 14861 14862 var component = new ZIndexComponent(element, options); 14863 component.setStack(this); 14864 component.setSort(++this.sortCount); 14865 this.elements.set(element, component); 14866 this.components.add(component); 14867 this.sort(); 14868 return component; 14869 } 14870 }, { 14871 key: "unregister", 14872 value: function unregister(element) { 14873 var component = this.elements.get(element); 14874 this.components.delete(component); 14875 this.elements.delete(element); 14876 this.sort(); 14877 } 14878 }, { 14879 key: "getComponent", 14880 value: function getComponent(element) { 14881 return this.elements.get(element) || null; 14882 } 14883 }, { 14884 key: "getComponents", 14885 value: function getComponents() { 14886 return this.components.getAll(); 14887 } 14888 }, { 14889 key: "getMaxZIndex", 14890 value: function getMaxZIndex() { 14891 var last = this.components.getLast(); 14892 return last ? last.getZIndex() : this.baseIndex; 14893 } 14894 }, { 14895 key: "sort", 14896 value: function sort() { 14897 var _this = this; 14898 14899 this.components.sort(); 14900 var zIndex = this.baseIndex;
14901 this.components.forEach(function (component) { 14902 component.setZIndex(zIndex); 14903 zIndex += _this.baseStep; 14904 }); 14905 } 14906 }, { 14907 key: "bringToFront", 14908 value: function bringToFront(element) { 14909 var component = this.getComponent(element); 14910 14911 if (!component) { 14912 console.error('ZIndexManager: element was not found in the stack.', element); 14913 return null; 14914 } 14915 14916 component.setSort(++this.sortCount); 14917 this.sort(); 14918 return component; 14919 } 14920 }]); 14921 return ZIndexStack; 14922 }(); 14923 14924 function _classStaticPrivateMethodGet(receiver, classConstructor, method) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } return method; } 14925 14926 /** 14927 * @memberof BX 14928 */ 14929 var ZIndexManager = /*#__PURE__*/function () { 14930 function ZIndexManager() { 14931 babelHelpers.classCallCheck(this, ZIndexManager); 14932 } 14933 14934 babelHelpers.createClass(ZIndexManager, null, [{ 14935 key: "register", 14936 value: function register(element) { 14937 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 14938 14939 var parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 14940 14941 if (!parentNode) { 14942 return null; 14943 } 14944 14945 var stack = this.getOrAddStack(parentNode); 14946 return stack.register(element, options); 14947 } 14948 }, { 14949 key: "unregister", 14950 value: function unregister(element) { 14951 var parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 14952 14953 var stack = this.getStack(parentNode); 14954 14955 if (stack) { 14956 stack.unregister(element); 14957 } 14958 } 14959 }, { 14960 key: "addStack", 14961 value: function addStack(container) { 14962 var stack = new ZIndexStack(container); 14963 this.stacks.set(container, stack); 14964 return stack; 14965 } 14966 }, { 14967 key: "getStack", 14968 value: function getStack(container) { 14969 return this.stacks.get(container) || null; 14970 } 14971 }, { 14972 key: "getOrAddStack", 14973 value: function getOrAddStack(container) { 14974 return this.getStack(container) || this.addStack(container); 14975 } 14976 }, { 14977 key: "getComponent", 14978 value: function getComponent(element) { 14979 var parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element, true); 14980 14981 if (!parentNode) { 14982 return null; 14983 } 14984 14985 var stack = this.getStack(parentNode); 14986 return stack ? stack.getComponent(element) : null; 14987 } 14988 }, { 14989 key: "bringToFront", 14990 value: function bringToFront(element) { 14991 var parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 14992 14993 var stack = this.getStack(parentNode); 14994 14995 if (stack) { 14996 return stack.bringToFront(element); 14997 } 14998 14999 return null; 15000 } 15001 }]); 15002 return ZIndexManager; 15003 }(); 15004 15005 var _getParentNode = function _getParentNode(element) { 15006 var suppressWarnings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 15007 15008 if (!Type.isElementNode(element)) { 15009 if (!suppressWarnings) { 15010 console.error('ZIndexManager: The argument \'element\' must be a DOM element.', element); 15011 } 15012 15013 return null; 15014 } else if (!Type.isElementNode(element.parentNode)) { 15015 if (!suppressWarnings) { 15016 console.error('ZIndexManager: The \'element\' doesn\'t have a parent node.', element); 15017 } 15018 15019 return null; 15020 } 15021 15022 return element.parentNode; 15023 }; 15024 15025 babelHelpers.defineProperty(ZIndexManager, "stacks", new WeakMap()); 15026 15027 var collections = { 15028 OrderedArray: OrderedArray 15029 }; 15030 15031 function getElement(element) { 15032 if (Type.isString(element)) { 15033 return document.getElementById(element); 15034 } 15035 15036 return element; 15037 } 15038 15039 function getWindow(element) { 15040 if (Type.isElementNode(element)) { 15041 return element.ownerDocument.parentWindow || element.ownerDocument.defaultView || window; 15042 } 15043 15044 if (Type.isDomNode(element)) { 15045 return element.parentWindow || element.defaultView || window; 15046 } 15047 15048 return window; 15049 } 15050 15051 /* eslint-disable prefer-rest-params */ 15052 15053 var getClass = Reflection.getClass, 15054 namespace = Reflection.namespace; 15055 var message$1 = message; 15056 /** 15057 * @memberOf BX 15058 */ 15059 15060 var replace = Dom.replace, 15061 remove = Dom.remove, 15062 clean = Dom.clean, 15063 insertBefore = Dom.insertBefore, 15064 insertAfter = Dom.insertAfter, 15065 append = Dom.append, 15066 prepend = Dom.prepend, 15067 style = Dom.style, 15068 adjust = Dom.adjust, 15069 create = Dom.create, 15070 isShown = Dom.isShown; 15071 var addClass = function addClass() { 15072 Dom.addClass.apply(Dom, babelHelpers.toConsumableArray(Runtime.merge([], Array.from(arguments), [getElement(arguments[0])]))); 15073 }; 15074 var removeClass = function removeClass() { 15075 Dom.removeClass.apply(Dom, babelHelpers.toConsumableArray(Runtime.merge(Array.from(arguments), [getElement(arguments[0])]))); 15076 }; 15077 var hasClass = function hasClass() { 15078 return Dom.hasClass.apply(Dom, babelHelpers.toConsumableArray(Runtime.merge(Array.from(arguments), [getElement(arguments[0])]))); 15079 }; 15080 var toggleClass = function toggleClass() { 15081 Dom.toggleClass.apply(Dom, babelHelpers.toConsumableArray(Runtime.merge(Array.from(arguments), [getElement(arguments[0])]))); 15082 }; 15083 var cleanNode = function cleanNode(element) { 15084 var removeElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
15085 var currentElement = getElement(element); 15086 15087 if (Type.isDomNode(currentElement)) { 15088 Dom.clean(currentElement); 15089 15090 if (removeElement) { 15091 Dom.remove(currentElement); 15092 return currentElement; 15093 } 15094 } 15095 15096 return currentElement; 15097 }; 15098 var getCookie = Http.Cookie.get; 15099 var setCookie = function setCookie(name, value) { 15100 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; 15101 var attributes = babelHelpers.objectSpread({}, options); 15102 15103 if (Type.isNumber(attributes.expires)) { 15104 attributes.expires /= 3600 * 24; 15105 } 15106 15107 Http.Cookie.set(name, value, attributes); 15108 }; 15109 var bind$1 = Event.bind, 15110 unbind$1 = Event.unbind, 15111 unbindAll$1 = Event.unbindAll, 15112 bindOnce$1 = Event.bindOnce, 15113 ready$1 = Event.ready; 15114 var debugEnableFlag = debugState, 15115 debugStatus = isDebugEnabled, 15116 debug$1 = debug; 15117 var debugEnable = function debugEnable(value) { 15118 if (value) { 15119 enableDebug(); 15120 } else { 15121 disableDebug(); 15122 } 15123 }; 15124 var clone$1 = Runtime.clone, 15125 loadExt = Runtime.loadExtension, 15126 debounce = Runtime.debounce, 15127 throttle = Runtime.throttle, 15128 html = Runtime.html; // BX.type 15129 var type = babelHelpers.objectSpread({}, Object.getOwnPropertyNames(Type).filter(function (key) { 15130 return !['name', 'length', 'prototype', 'caller', 'arguments'].includes(key); 15131 }).reduce(function (acc, key) { 15132 acc[key] = Type[key]; 15133 return acc; 15134 }, {}), { 15135 isNotEmptyString: function isNotEmptyString(value) { 15136 return Type.isString(value) && value !== ''; 15137 }, 15138 isNotEmptyObject: function isNotEmptyObject(value) { 15139 return Type.isObjectLike(value) && Object.keys(value).length > 0; 15140 }, 15141 isMapKey: Type.isObject, 15142 stringToInt: function stringToInt(value) { 15143 var parsed = parseInt(value); 15144 return !Number.isNaN(parsed) ? parsed : 0; 15145 } 15146 }); // BX.browser 15147 15148 var browser = { 15149 IsOpera: Browser.isOpera, 15150 IsIE: Browser.isIE, 15151 IsIE6: Browser.isIE6, 15152 IsIE7: Browser.isIE7, 15153 IsIE8: Browser.isIE8, 15154 IsIE9: Browser.isIE9, 15155 IsIE10: Browser.isIE10, 15156 IsIE11: Browser.isIE11, 15157 IsSafari: Browser.isSafari, 15158 IsFirefox: Browser.isFirefox, 15159 IsChrome: Browser.isChrome, 15160 DetectIeVersion: Browser.detectIEVersion, 15161 IsMac: Browser.isMac, 15162 IsAndroid: Browser.isAndroid, 15163 isIPad: Browser.isIPad, 15164 isIPhone: Browser.isIPhone, 15165 IsIOS: Browser.isIOS, 15166 IsMobile: Browser.isMobile, 15167 isRetina: Browser.isRetina, 15168 IsDoctype: Browser.isDoctype, 15169 SupportLocalStorage: Browser.isLocalStorageSupported, 15170 addGlobalClass: Browser.addGlobalClass, 15171 DetectAndroidVersion: Browser.detectAndroidVersion, 15172 isPropertySupported: Browser.isPropertySupported, 15173 addGlobalFeatures: Browser.addGlobalFeatures 15174 }; // eslint-disable-next-line 15175 15176 var ajax = window.BX ? window.BX.ajax : function () {}; 15177 function GetWindowScrollSize() { 15178 var doc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document; 15179 return { 15180 scrollWidth: doc.documentElement.scrollWidth, 15181 scrollHeight: doc.documentElement.scrollHeight 15182 }; 15183 } 15184 function GetWindowScrollPos() { 15185 var doc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document; 15186 var win = getWindow(doc); 15187 return { 15188 scrollLeft: win.pageXOffset, 15189 scrollTop: win.pageYOffset 15190 }; 15191 } 15192 function GetWindowInnerSize() { 15193 var doc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document; 15194 var win = getWindow(doc); 15195 return { 15196 innerWidth: win.innerWidth, 15197 innerHeight: win.innerHeight 15198 }; 15199 } 15200 function GetWindowSize() { 15201 var doc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document; 15202 return babelHelpers.objectSpread({}, GetWindowInnerSize(doc), GetWindowScrollPos(doc), GetWindowScrollSize(doc)); 15203 } 15204 function GetContext(node) { 15205 return getWindow(node); 15206 } 15207 function pos(element) { 15208 var relative = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 15209 15210 if (!element) { 15211 return new DOMRect().toJSON(); 15212 } 15213 15214 if (element.ownerDocument === document && !relative) { 15215 var clientRect = element.getBoundingClientRect(); 15216 var root = document.documentElement; 15217 var _document = document, 15218 body = _document.body; 15219 return { 15220 top: Math.round(clientRect.top + (root.scrollTop || body.scrollTop)), 15221 left: Math.round(clientRect.left + (root.scrollLeft || body.scrollLeft)), 15222 width: Math.round(clientRect.right - clientRect.left), 15223 height: Math.round(clientRect.bottom - clientRect.top), 15224 right: Math.round(clientRect.right + (root.scrollLeft || body.scrollLeft)), 15225 bottom: Math.round(clientRect.bottom + (root.scrollTop || body.scrollTop)) 15226 }; 15227 } 15228 15229 var x = 0; 15230 var y = 0; 15231 var w = element.offsetWidth; 15232 var h = element.offsetHeight; 15233 var first = true; // eslint-disable-next-line no-param-reassign 15234 15235 for (; element != null; element = element.offsetParent) { 15236 if (!first && relative && BX.is_relative(element)) { 15237 break; 15238 } 15239 15240 x += element.offsetLeft; 15241 y += element.offsetTop; 15242 15243 if (first) { 15244 first = false; // eslint-disable-next-line no-continue 15245 15246 continue; 15247 } 15248 15249 x += Text.toNumber(Dom.style(element, 'border-left-width')); 15250 y += Text.toNumber(Dom.style(element, 'border-top-width')); 15251 } 15252 15253 return new DOMRect(x, y, w, h).toJSON(); 15254 } 15255 function addCustomEvent(eventObject, eventName, eventHandler) { 15256 if (Type.isString(eventObject)) { 15257 eventHandler = eventName; 15258 eventName = eventObject; 15259 eventObject = EventEmitter.GLOBAL_TARGET;
15260 } 15261 15262 if (eventObject === window) { 15263 eventObject = EventEmitter.GLOBAL_TARGET; 15264 } 15265 15266 if (!Type.isObject(eventObject)) { 15267 console.error('The "eventObject" argument must be an object. Received type ' + babelHelpers.typeof(eventObject) + '.'); 15268 return; 15269 } 15270 15271 if (!Type.isStringFilled(eventName)) { 15272 console.error('The "eventName" argument must be a string.'); 15273 return; 15274 } 15275 15276 if (!Type.isFunction(eventHandler)) { 15277 console.error('The "eventHandler" argument must be a function. Received type ' + babelHelpers.typeof(eventHandler) + '.'); 15278 return; 15279 } 15280 15281 eventName = eventName.toLowerCase(); 15282 EventEmitter.subscribe(eventObject, eventName, eventHandler, { 15283 compatMode: true, 15284 useGlobalNaming: true 15285 }); 15286 } 15287 function onCustomEvent(eventObject, eventName, eventParams, secureParams) { 15288 if (Type.isString(eventObject)) { 15289 secureParams = eventParams; 15290 eventParams = eventName; 15291 eventName = eventObject; 15292 eventObject = EventEmitter.GLOBAL_TARGET; 15293 } 15294 15295 if (!Type.isObject(eventObject) || eventObject === window) { 15296 eventObject = EventEmitter.GLOBAL_TARGET;
15297 } 15298 15299 if (!eventParams) { 15300 eventParams = []; 15301 } 15302 15303 eventName = eventName.toLowerCase(); 15304 var event = new BaseEvent(); 15305 event.setData(eventParams); 15306 event.setCompatData(eventParams); 15307 EventEmitter.emit(eventObject, eventName, event, { 15308 cloneData: secureParams === true, 15309 useGlobalNaming: true 15310 }); 15311 } 15312 function removeCustomEvent(eventObject, eventName, eventHandler) { 15313 if (Type.isString(eventObject)) { 15314 eventHandler = eventName; 15315 eventName = eventObject; 15316 eventObject = EventEmitter.GLOBAL_TARGET; 15317 } 15318 15319 if (!Type.isFunction(eventHandler)) { 15320 console.error('The "eventHandler" argument must be a function. Received type ' + babelHelpers.typeof(eventHandler) + '.'); 15321 return; 15322 } 15323 15324 if (eventObject === window) { 15325 eventObject = EventEmitter.GLOBAL_TARGET; 15326 } 15327 15328 eventName = eventName.toLowerCase(); 15329 EventEmitter.unsubscribe(eventObject, eventName, eventHandler, { 15330 useGlobalNaming: true 15331 }); 15332 } 15333 function removeAllCustomEvents(eventObject, eventName) { 15334 if (Type.isString(eventObject)) { 15335 eventName = eventObject; 15336 eventObject = EventEmitter.GLOBAL_TARGET;
15337 } 15338 15339 if (eventObject === window) { 15340 eventObject = EventEmitter.GLOBAL_TARGET; 15341 } 15342 15343 eventName = eventName.toLowerCase(); 15344 EventEmitter.unsubscribeAll(eventObject, eventName, { 15345 useGlobalNaming: true 15346 }); 15347 } 15348 15349 if (global && global.window && global.window.BX) { 15350 Object.assign(global.window.BX, exports); 15351 } 15352 15353 exports.Type = Type; 15354 exports.Reflection = Reflection; 15355 exports.Text = Text; 15356 exports.Dom = Dom; 15357 exports.Browser = Browser; 15358 exports.Event = Event; 15359 exports.Http = Http; 15360 exports.Runtime = Runtime; 15361 exports.Loc = Loc; 15362 exports.Tag = Tag; 15363 exports.Uri = Uri; 15364 exports.Validation = Validation; 15365 exports.Cache = Cache; 15366 exports.BaseError = BaseError; 15367 exports.Extension = Extension$1; 15368 exports.ZIndexManager = ZIndexManager; 15369 exports.Collections = collections; 15370 exports.getClass = getClass; 15371 exports.namespace = namespace; 15372 exports.message = message$1; 15373 exports.replace = replace; 15374 exports.remove = remove; 15375 exports.clean = clean; 15376 exports.insertBefore = insertBefore; 15377 exports.insertAfter = insertAfter; 15378 exports.append = append; 15379 exports.prepend = prepend; 15380 exports.style = style; 15381 exports.adjust = adjust; 15382 exports.create = create; 15383 exports.isShown = isShown; 15384 exports.addClass = addClass; 15385 exports.removeClass = removeClass; 15386 exports.hasClass = hasClass; 15387 exports.toggleClass = toggleClass; 15388 exports.cleanNode = cleanNode; 15389 exports.getCookie = getCookie; 15390 exports.setCookie = setCookie; 15391 exports.bind = bind$1; 15392 exports.unbind = unbind$1; 15393 exports.unbindAll = unbindAll$1; 15394 exports.bindOnce = bindOnce$1; 15395 exports.ready = ready$1; 15396 exports.debugEnableFlag = debugEnableFlag; 15397 exports.debugStatus = debugStatus; 15398 exports.debug = debug$1; 15399 exports.debugEnable = debugEnable; 15400 exports.clone = clone$1; 15401 exports.loadExt = loadExt; 15402 exports.debounce = debounce; 15403 exports.throttle = throttle; 15404 exports.html = html; 15405 exports.type = type; 15406 exports.browser = browser; 15407 exports.ajax = ajax; 15408 exports.GetWindowScrollSize = GetWindowScrollSize; 15409 exports.GetWindowScrollPos = GetWindowScrollPos; 15410 exports.GetWindowInnerSize = GetWindowInnerSize; 15411 exports.GetWindowSize = GetWindowSize; 15412 exports.GetContext = GetContext; 15413 exports.pos = pos; 15414 exports.addCustomEvent = addCustomEvent; 15415 exports.onCustomEvent = onCustomEvent; 15416 exports.removeCustomEvent = removeCustomEvent; 15417 exports.removeAllCustomEvents = removeAllCustomEvents; 15418 15419}((this.BX = this.BX || {}))); 15420 15421 15422 15423(function(BX) { 15424 /* list of registered proxy functions */ 15425 var proxyList = new WeakMap(); 15426 var deferList = new WeakMap(); 15427 15428 /* List of denied event handlers */ 15429 var deniedEvents = []; 15430 15431 /* list of registered custom events */ 15432 var customEvents = new WeakMap(); 15433 var customEventsCnt = 0; 15434 15435 /* list of external garbage collectors */ 15436 var garbageCollectors = []; 15437 15438 /* list of loaded CSS files */ 15439 var cssList = []; 15440 var cssInit = false; 15441 15442 /* list of loaded JS files */ 15443 var jsList = []; 15444 var jsInit = false; 15445 15446 var eventTypes = { 15447 click: 'MouseEvent', 15448 dblclick: 'MouseEvent', 15449 mousedown: 'MouseEvent', 15450 mousemove: 'MouseEvent', 15451 mouseout: 'MouseEvent', 15452 mouseover: 'MouseEvent', 15453 mouseup: 'MouseEvent', 15454 focus: 'MouseEvent', 15455 blur: 'MouseEvent' 15456 }; 15457 15458 var lastWait = []; 15459 15460 var CHECK_FORM_ELEMENTS = {tagName: /^INPUT|SELECT|TEXTAREA|BUTTON$/i}; 15461 15462 var PRELOADING = 1; 15463 var PRELOADED = 2; 15464 var LOADING = 3; 15465 var LOADED = 4; 15466 var assets = {}; 15467 var isAsync = null; 15468 15469 BX.MSLEFT = 1; 15470 BX.MSMIDDLE = 2; 15471 BX.MSRIGHT = 4; 15472 15473 BX.AM_PM_UPPER = 1; 15474 BX.AM_PM_LOWER = 2; 15475 BX.AM_PM_NONE = false; 15476 15477 BX.ext = function(ob) 15478 { 15479 for (var i in ob) 15480 { 15481 if(ob.hasOwnProperty(i)) 15482 { 15483 this[i] = ob[i]; 15484 } 15485 } 15486 }; 15487 15488 var r = { 15489 script: /<script([^>]*)>/ig, 15490 script_end: /<\/script>/ig, 15491 script_src: /src=["\']([^"\']+)["\']/i, 15492 script_type: /type=["\']([^"\']+)["\']/i, 15493 space: /\s+/, 15494 ltrim: /^[\s\r\n]+/g, 15495 rtrim: /[\s\r\n]+$/g, 15496 style: /<link.*?(rel="stylesheet"|type="text\/css")[^>]*>/i, 15497 style_href: /href=["\']([^"\']+)["\']/i 15498 }; 15499 15500 BX.processHTML = function(data, scriptsRunFirst) 15501 { 15502 var matchScript, matchStyle, matchSrc, matchHref, matchType, scripts = [], styles = []; 15503 var textIndexes = []; 15504 var lastIndex = r.script.lastIndex = r.script_end.lastIndex = 0; 15505 15506 while ((matchScript = r.script.exec(data)) !== null) 15507 { 15508 r.script_end.lastIndex = r.script.lastIndex; 15509 var matchScriptEnd = r.script_end.exec(data); 15510 if (matchScriptEnd === null) 15511 { 15512 break; 15513 } 15514 15515 // skip script tags of special types 15516 var skipTag = false;
15517 if ((matchType = matchScript[1].match(r.script_type)) !== null) 15518 { 15519 if( 15520 matchType[1] == 'text/html' 15521 || matchType[1] == 'text/template' 15522 || matchType[1] == 'extension/settings' 15523 ) 15524 { 15525 skipTag = true; 15526 } 15527 } 15528 15529 if(skipTag) 15530 { 15531 textIndexes.push([lastIndex, r.script_end.lastIndex - lastIndex]); 15532 } 15533 else 15534 { 15535 textIndexes.push([lastIndex, matchScript.index - lastIndex]); 15536 15537 var bRunFirst = scriptsRunFirst || (matchScript[1].indexOf('bxrunfirst') != '-1'); 15538 15539 if ((matchSrc = matchScript[1].match(r.script_src)) !== null) 15540 { 15541 scripts.push({"bRunFirst": bRunFirst, "isInternal": false, "JS": matchSrc[1]}); 15542 } 15543 else 15544 { 15545 var start = matchScript.index + matchScript[0].length; 15546 var js = data.substr(start, matchScriptEnd.index-start); 15547 15548 scripts.push({"bRunFirst": bRunFirst, "isInternal": true, "JS": js}); 15549 } 15550 } 15551 15552 lastIndex = matchScriptEnd.index + 9; 15553 r.script.lastIndex = lastIndex; 15554 } 15555 15556 textIndexes.push([lastIndex, lastIndex === 0 ? data.length : data.length - lastIndex]); 15557 var pureData = ""; 15558 for (var i = 0, length = textIndexes.length; i < length; i++) 15559 { 15560 if (BX.type.isString(data) && BX.type.isFunction(data.substr)) 15561 { 15562 pureData += data.substr(textIndexes[i][0], textIndexes[i][1]); 15563 } 15564 } 15565 15566 while ((matchStyle = pureData.match(r.style)) !== null) 15567 { 15568 if ((matchHref = matchStyle[0].match(r.style_href)) !== null && matchStyle[0].indexOf('media="') < 0) 15569 { 15570 styles.push(matchHref[1]); 15571 } 15572 15573 pureData = pureData.replace(matchStyle[0], ''); 15574 } 15575 15576 return {'HTML': pureData, 'SCRIPT': scripts, 'STYLE': styles}; 15577 }; 15578 15579 /* OO emulation utility */ 15580 BX.extend = function(child, parent) 15581 { 15582 var f = function() {}; 15583 f.prototype = parent.prototype; 15584 15585 child.prototype = new f(); 15586 child.prototype.constructor = child; 15587 15588 child.superclass = parent.prototype; 15589 child.prototype.superclass = parent.prototype; 15590 if(parent.prototype.constructor == Object.prototype.constructor) 15591 { 15592 parent.prototype.constructor = parent; 15593 } 15594 }; 15595 15596 BX.is_subclass_of = function(ob, parent_class) 15597 { 15598 if (ob instanceof parent_class) 15599 return true; 15600 15601 if (parent_class.superclass) 15602 return BX.is_subclass_of(ob, parent_class.superclass); 15603 15604 return false; 15605 }; 15606 15607 BX.clearNodeCache = function() 15608 { 15609 return false; 15610 }; 15611 15612 BX.bitrix_sessid = function() {return BX.message("bitrix_sessid"); }; 15613 15614 /** 15615 * Creates document fragment with child nodes. 15616 * 15617 * @param {Node[]} nodes 15618 * @return {DocumentFragment} 15619 */ 15620 BX.createFragment = function(nodes) 15621 { 15622 var fragment = document.createDocumentFragment(); 15623 15624 if(!BX.type.isArray(nodes)) 15625 { 15626 return fragment; 15627 } 15628 for(var i = 0; i < nodes.length; i++) 15629 { 15630 fragment.appendChild(nodes[i]); 15631 } 15632 15633 return fragment; 15634 }; 15635 15636 /** 15637 * @deprecated 15638 * @use BX.style 15639 * @param element 15640 * @param opacity 15641 */ 15642 BX.setOpacity = function(element, opacity) 15643 { 15644 var opacityValue = parseFloat(opacity); 15645 15646 if (!isNaN(opacityValue) && BX.type.isDomNode(element)) 15647 { 15648 opacityValue = opacityValue < 1 ? opacityValue : opacityValue / 100; 15649 BX.style(element, 'opacity', opacityValue); 15650 } 15651 }; 15652 15653 /** 15654 * @deprecated 15655 * @param el 15656 * @return {*} 15657 */ 15658 BX.hoverEvents = function(el) 15659 { 15660 if (el) 15661 return BX.adjust(el, {events: BX.hoverEvents()}); 15662 else 15663 return {mouseover: BX.hoverEventsHover, mouseout: BX.hoverEventsHout}; 15664 }; 15665 15666 /** 15667 * @deprecated 15668 */ 15669 BX.hoverEventsHover = function(){BX.addClass(this,'bx-hover');this.BXHOVER=true;}; 15670 /** 15671 * @deprecated 15672 */ 15673 BX.hoverEventsHout = function(){BX.removeClass(this,'bx-hover');this.BXHOVER=false;}; 15674 15675 /** 15676 * @deprecated 15677 */ 15678 BX.focusEvents = function(el) 15679 { 15680 if (el) 15681 return BX.adjust(el, {events: BX.focusEvents()}); 15682 else 15683 return {mouseover: BX.focusEventsFocus, mouseout: BX.focusEventsBlur}; 15684 }; 15685 15686 /** 15687 * @deprecated 15688 */ 15689 BX.focusEventsFocus = function(){BX.addClass(this,'bx-focus');this.BXFOCUS=true;}; 15690 /** 15691 * @deprecated 15692 */ 15693 BX.focusEventsBlur = function(){BX.removeClass(this,'bx-focus');this.BXFOCUS=false;}; 15694 15695 BX.setUnselectable = function(node) 15696 { 15697 BX.style(node, { 15698 'userSelect': 'none', 15699 'MozUserSelect': 'none', 15700 'WebkitUserSelect': 'none', 15701 'KhtmlUserSelect': 'none', 15702 }); 15703 node.setAttribute('unSelectable', 'on'); 15704 }; 15705 15706 BX.setSelectable = function(node) 15707 { 15708 BX.style(node, { 15709 'userSelect': null, 15710 'MozUserSelect': null, 15711 'WebkitUserSelect': null, 15712 'KhtmlUserSelect': null, 15713 }); 15714 node.removeAttribute('unSelectable'); 15715 }; 15716 15717 BX.styleIEPropertyName = function(name) 15718 { 15719 if (name == 'float') 15720 name = BX.browser.IsIE() ? 'styleFloat' : 'cssFloat'; 15721 else 15722 { 15723 var res = BX.browser.isPropertySupported(name); 15724 if (res) 15725 { 15726 name = res; 15727 } 15728 else 15729 {
15730 var reg = /(\-([a-z]){1})/g; 15731 if (reg.test(name)) 15732 { 15733 name = name.replace(reg, function () {return arguments[2].toUpperCase();}); 15734 } 15735 } 15736 } 15737 return name; 15738 }; 15739 15740 BX.focus = function(el) 15741 { 15742 try 15743 { 15744 el.focus(); 15745 return true; 15746 } 15747 catch (e) 15748 { 15749 return false; 15750 } 15751 }; 15752 15753 BX.firstChild = function(el) 15754 { 15755 return BX.type.isDomNode(el) ? el.firstElementChild : null; 15756 }; 15757 15758 BX.lastChild = function(el) 15759 { 15760 return BX.type.isDomNode(el) ? el.lastElementChild : null; 15761 }; 15762 15763 BX.previousSibling = function(el) 15764 { 15765 return BX.type.isDomNode(el) ? el.previousElementSibling : null; 15766 }; 15767 15768 BX.nextSibling = function(el) 15769 { 15770 return BX.type.isDomNode(el) ? el.nextElementSibling : null; 15771 }; 15772 15773 /* 15774 params: { 15775 obj : html node 15776 className : className value 15777 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 15778 } 15779 15780 Search all nodes with className 15781 */ 15782 /** 15783 * @deprecated 15784 * @use .querySelectorAll 15785 * @param obj 15786 * @param className 15787 * @param recursive 15788 * @return {*} 15789 */ 15790 BX.findChildrenByClassName = function(obj, className, recursive) 15791 { 15792 if(!obj || !obj.childNodes) return null; 15793 15794 var result = []; 15795 if (typeof(obj.getElementsByClassName) == 'undefined') 15796 { 15797 recursive = recursive !== false; 15798 result = BX.findChildren(obj, {className : className}, recursive); 15799 } 15800 else 15801 { 15802 var col = obj.getElementsByClassName(className); 15803 for (i=0,l=col.length;i<l;i++) 15804 { 15805 result[i] = col[i]; 15806 } 15807 } 15808 return result; 15809 }; 15810 15811 /* 15812 params: { 15813 obj : html node 15814 className : className value 15815 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 15816 } 15817 15818 Search first node with className 15819 */ 15820 /** 15821 * @deprecated 15822 * @use .querySelector 15823 * @param obj 15824 * @param className 15825 * @param recursive 15826 * @return {*} 15827 */ 15828 BX.findChildByClassName = function(obj, className, recursive) 15829 { 15830 if(!obj || !obj.childNodes) return null; 15831 15832 var result = null; 15833 if (typeof(obj.getElementsByClassName) == 'undefined') 15834 { 15835 recursive = recursive !== false; 15836 result = BX.findChild(obj, {className : className}, recursive); 15837 } 15838 else 15839 { 15840 var col = obj.getElementsByClassName(className); 15841 if (col && typeof(col[0]) != 'undefined') 15842 { 15843 result = col[0]; 15844 } 15845 else 15846 { 15847 result = null; 15848 } 15849 } 15850 return result; 15851 }; 15852 15853 /* 15854 params: { 15855 tagName|tag : 'tagName', 15856 className|class : 'className', 15857 attribute : {attribute : value, attribute : value} | attribute | [attribute, attribute....], 15858 property : {prop: value, prop: value} | prop | [prop, prop] 15859 } 15860 15861 all values can be RegExps or strings 15862 */ 15863 /** 15864 * @deprecated 15865 * @use .querySelectorAll 15866 * @param obj 15867 * @param params 15868 * @param recursive 15869 * @return {*|Node} 15870 */ 15871 BX.findChildren = function(obj, params, recursive) 15872 { 15873 return BX.findChild(obj, params, recursive, true); 15874 }; 15875 15876 /** 15877 * @deprecated 15878 * @use .querySelectorAll 15879 * @param obj 15880 * @param params 15881 * @param recursive 15882 * @param get_all 15883 * @return {*} 15884 */ 15885 BX.findChild = function(obj, params, recursive, get_all) 15886 { 15887 if(!obj || !obj.childNodes) return null; 15888 15889 recursive = !!recursive; get_all = !!get_all; 15890 15891 var n = obj.childNodes.length, result = []; 15892 15893 for (var j=0; j<n; j++) 15894 { 15895 var child = obj.childNodes[j]; 15896 15897 if (_checkNode(child, params)) 15898 { 15899 if (get_all) 15900 result.push(child); 15901 else 15902 return child; 15903 } 15904 15905 if(recursive == true) 15906 { 15907 var res = BX.findChild(child, params, recursive, get_all); 15908 if (res) 15909 { 15910 if (get_all) 15911 result = BX.util.array_merge(result, res); 15912 else 15913 return res; 15914 } 15915 } 15916 } 15917 15918 if (get_all || result.length > 0) 15919 return result; 15920 else 15921 return null; 15922 }; 15923 15924 /** 15925 * @deprecated 15926 * @use .closest() 15927 * @param obj 15928 * @param params 15929 * @param maxParent 15930 * @return {*} 15931 */ 15932 BX.findParent = function(obj, params, maxParent) 15933 { 15934 if(!obj) 15935 return null; 15936 15937 var o = obj; 15938 while(o.parentNode) 15939 { 15940 var parent = o.parentNode; 15941 15942 if (_checkNode(parent, params)) 15943 return parent; 15944 15945 o = parent; 15946 15947 if (!!maxParent &&
15948 (BX.type.isFunction(maxParent) 15949 || typeof maxParent == 'object')) 15950 { 15951 if (BX.type.isElementNode(maxParent)) 15952 { 15953 if (o == maxParent) 15954 break; 15955 } 15956 else 15957 { 15958 if (_checkNode(o, maxParent)) 15959 break; 15960 } 15961 } 15962 } 15963 return null; 15964 }; 15965 15966 /** 15967 * @deprecated 15968 * @use .querySelector 15969 * @param obj 15970 * @param params 15971 * @return {*} 15972 */ 15973 BX.findNextSibling = function(obj, params) 15974 { 15975 if(!obj) 15976 return null; 15977 var o = obj; 15978 while(o.nextSibling) 15979 { 15980 var sibling = o.nextSibling; 15981 if (_checkNode(sibling, params)) 15982 return sibling; 15983 o = sibling; 15984 } 15985 return null; 15986 }; 15987 15988 /** 15989 * @deprecated 15990 * @use .querySelector 15991 * @param obj 15992 * @param params 15993 * @return {*} 15994 */ 15995 BX.findPreviousSibling = function(obj, params) 15996 { 15997 if(!obj) 15998 return null; 15999 16000 var o = obj; 16001 while(o.previousSibling) 16002 { 16003 var sibling = o.previousSibling; 16004 if(_checkNode(sibling, params)) 16005 return sibling; 16006 o = sibling; 16007 } 16008 return null; 16009 }; 16010 16011 BX.checkNode = function(obj, params) 16012 { 16013 return _checkNode(obj, params); 16014 }; 16015 16016 /** 16017 * @deprecated 16018 * @use .querySelectorAll 16019 * @param form 16020 * @return {Array} 16021 */ 16022 BX.findFormElements = function(form) 16023 { 16024 if (BX.type.isString(form)) 16025 form = document.forms[form]||BX(form); 16026 16027 var res = []; 16028 16029 if (BX.type.isElementNode(form)) 16030 { 16031 if (form.tagName.toUpperCase() == 'FORM') 16032 { 16033 res = form.elements; 16034 } 16035 else 16036 { 16037 res = BX.findChildren(form, CHECK_FORM_ELEMENTS, true); 16038 } 16039 } 16040 16041 return res; 16042 }; 16043 16044 /** 16045 * @deprecated 16046 * @use .contains() 16047 * @param whichNode 16048 * @param forNode 16049 * @return {boolean} 16050 */ 16051 BX.isParentForNode = function(whichNode, forNode) 16052 { 16053 if (BX.type.isDomNode(whichNode) && BX.type.isDomNode(forNode)) 16054 { 16055 return whichNode.contains(forNode); 16056 } 16057 16058 return false; 16059 }; 16060 16061 BX.getCaretPosition = function(node) 16062 { 16063 var pos = 0; 16064 16065 if(node.selectionStart || node.selectionStart == 0) 16066 { 16067 pos = node.selectionStart; 16068 } 16069 else if(document.selection) 16070 { 16071 node.focus(); 16072 var selection = document.selection.createRange(); 16073 selection.moveStart('character', -node.value.length); 16074 pos = selection.text.length; 16075 } 16076 16077 return (pos); 16078 }; 16079 16080 BX.setCaretPosition = function(node, pos) 16081 { 16082 if(!BX.isNodeInDom(node) || BX.isNodeHidden(node) || node.disabled) 16083 { 16084 return; 16085 } 16086 16087 if(node.setSelectionRange) 16088 { 16089 node.focus(); 16090 node.setSelectionRange(pos, pos); 16091 } 16092 else if(node.createTextRange) 16093 { 16094 var range = node.createTextRange(); 16095 range.collapse(true); 16096 range.moveEnd('character', pos); 16097 range.moveStart('character', pos); 16098 range.select(); 16099 } 16100 }; 16101 16102 // access private. use BX.mergeEx instead. 16103 // todo: refactor BX.merge, make it work through BX.mergeEx 16104 BX.merge = function(){ 16105 var arg = Array.prototype.slice.call(arguments); 16106 16107 if(arg.length < 2) 16108 return {}; 16109 16110 var result = arg.shift(); 16111 16112 for(var i = 0; i < arg.length; i++) 16113 { 16114 for(var k in arg[i]){ 16115 16116 if(typeof arg[i] == 'undefined' || arg[i] == null) 16117 continue; 16118 16119 if(arg[i].hasOwnProperty(k)){ 16120 16121 if(typeof arg[i][k] == 'undefined' || arg[i][k] == null) 16122 continue; 16123 16124 if(typeof arg[i][k] == 'object' && !BX.type.isDomNode(arg[i][k]) && (typeof arg[i][k]['isUIWidget'] == 'undefined')){ 16125 16126 // go deeper 16127 16128 var isArray = 'length' in arg[i][k]; 16129 16130 if(typeof result[k] != 'object') 16131 result[k] = isArray ? [] : {}; 16132 16133 if(isArray) 16134 BX.util.array_merge(result[k], arg[i][k]); 16135 else 16136 BX.merge(result[k], arg[i][k]); 16137 16138 }else 16139 result[k] = arg[i][k]; 16140 } 16141 } 16142 } 16143 16144 return result; 16145 }; 16146 16147 BX.mergeEx = function() 16148 { 16149 var arg = Array.prototype.slice.call(arguments); 16150 if(arg.length < 2) 16151 { 16152 return {}; 16153 } 16154 16155 var result = arg.shift(); 16156 for (var i = 0; i < arg.length; i++) 16157 { 16158 for (var k in arg[i]) 16159 { 16160 if (typeof arg[i] == "undefined" || arg[i] == null || !arg[i].hasOwnProperty(k)) 16161 { 16162 continue; 16163 } 16164 16165 if (BX.type.isPlainObject(arg[i][k]) && BX.type.isPlainObject(result[k])) 16166 { 16167 BX.mergeEx(result[k], arg[i][k]); 16168 } 16169 else 16170 { 16171 result[k] = BX.type.isPlainObject(arg[i][k]) ? BX.clone(arg[i][k]) : arg[i][k]; 16172 } 16173 } 16174 } 16175 16176 return result; 16177 }; 16178 16179 BX.getEventButton = function(e) 16180 { 16181 e = e || window.event; 16182 16183 var flags = 0; 16184 16185 if (typeof e.which != 'undefined') 16186 { 16187 switch (e.which) 16188 { 16189 case 1: flags = flags|BX.MSLEFT; break; 16190 case 2: flags = flags|BX.MSMIDDLE; break; 16191 case 3: flags = flags|BX.MSRIGHT; break; 16192 } 16193 } 16194 else if (typeof e.button != 'undefined') 16195 { 16196 flags = event.button; 16197 } 16198 16199 return flags || BX.MSLEFT; 16200 }; 16201 16202 var captured_events = null, _bind = null; 16203 BX.CaptureEvents = function(el_c, evname_c) 16204 { 16205 if (_bind) 16206 return; 16207 16208 _bind = BX.bind; 16209 captured_events = []; 16210 16211 BX.bind = function(el, evname, func) 16212 { 16213 if (el === el_c && evname === evname_c) 16214 captured_events.push(func); 16215 16216 _bind.apply(this, arguments); 16217 } 16218 }; 16219 16220 BX.CaptureEventsGet = function() 16221 { 16222 if (_bind) 16223 { 16224 BX.bind = _bind; 16225 16226 var captured = captured_events; 16227 16228 _bind = null; 16229 captured_events = null; 16230 return captured; 16231 } 16232 return null; 16233 }; 16234 16235 // Don't even try to use it for submit event! 16236 BX.fireEvent = function(ob,ev) 16237 { 16238 var result = false, e = null; 16239 if (BX.type.isDomNode(ob)) 16240 { 16241 result = true; 16242 if (document.createEventObject) 16243 { 16244 // IE 16245 if (eventTypes[ev] != 'MouseEvent') 16246 { 16247 e = document.createEventObject(); 16248 e.type = ev; 16249 result = ob.fireEvent('on' + ev, e); 16250 } 16251 16252 if (ob[ev]) 16253 { 16254 ob[ev](); 16255 } 16256 } 16257 else 16258 {
16259 // non-IE 16260 e = null; 16261 16262 switch (eventTypes[ev]) 16263 { 16264 case 'MouseEvent': 16265 e = document.createEvent('MouseEvent'); 16266 try 16267 { 16268 e.initMouseEvent(ev, true, true, top, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 16269 } 16270 catch (initException) 16271 { 16272 e.initMouseEvent(ev, true, true, window, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 16273 } 16274 16275 break; 16276 default: 16277 e = document.createEvent('Event'); 16278 e.initEvent(ev, true, true); 16279 } 16280 16281 result = ob.dispatchEvent(e); 16282 } 16283 } 16284 16285 return result; 16286 }; 16287 16288 BX.getWheelData = function(e) 16289 { 16290 e = e || window.event; 16291 e.wheelData = e.detail ? e.detail * -1 : e.wheelDelta / 40; 16292 return e.wheelData; 16293 }; 16294 16295 BX.proxy_context = null; 16296 16297 BX.delegate = function (func, thisObject) 16298 { 16299 if (!func || !thisObject) 16300 return func; 16301 16302 return function() { 16303 var cur = BX.proxy_context; 16304 BX.proxy_context = this; 16305 var res = func.apply(thisObject, arguments); 16306 BX.proxy_context = cur; 16307 return res; 16308 } 16309 }; 16310 16311 BX.delegateLater = function (func_name, thisObject, contextObject) 16312 { 16313 return function() 16314 { 16315 if (thisObject[func_name]) 16316 { 16317 var cur = BX.proxy_context; 16318 BX.proxy_context = this; 16319 var res = thisObject[func_name].apply(contextObject||thisObject, arguments); 16320 BX.proxy_context = cur; 16321 return res; 16322 } 16323 return null; 16324 } 16325 }; 16326 16327 BX.proxy = function(func, thisObject) 16328 { 16329 return getObjectDelegate(func, thisObject, proxyList); 16330 }; 16331 16332 BX.defer = function(func, thisObject) 16333 { 16334 if (!!thisObject) 16335 return BX.defer_proxy(func, thisObject); 16336 else 16337 return function() { 16338 var arg = arguments; 16339 setTimeout(function(){func.apply(this,arg)}, 10); 16340 }; 16341 }; 16342 16343 BX.defer_proxy = function(func, thisObject) 16344 { 16345 return getObjectDelegate(func, thisObject, deferList, BX.defer); 16346 }; 16347 16348 /** 16349 * 16350 * @private 16351 */ 16352 function getObjectDelegate(func, thisObject, collection, decorator) 16353 { 16354 if (!BX.type.isFunction(func) || !BX.type.isMapKey(thisObject)) 16355 { 16356 return func; 16357 } 16358 16359 var objectDelegates = collection.get(thisObject); 16360 if (!objectDelegates) 16361 { 16362 objectDelegates = new WeakMap(); 16363 collection.set(thisObject, objectDelegates); 16364 } 16365 16366 var delegate = objectDelegates.get(func); 16367 if (!delegate) 16368 { 16369 delegate = decorator ? decorator(BX.delegate(func, thisObject)) : BX.delegate(func, thisObject); 16370 objectDelegates.set(func, delegate); 16371 } 16372 16373 return delegate; 16374 } 16375 16376 BX.once = function(el, evname, func) 16377 { 16378 var fn = function() 16379 { 16380 BX.unbind(el, evname, fn); 16381 func.apply(this, arguments); 16382 }; 16383 16384 return fn; 16385 }; 16386 16387 BX.bindDelegate = function (elem, eventName, isTarget, handler) 16388 { 16389 var h = BX.delegateEvent(isTarget, handler); 16390 BX.bind(elem, eventName, h); 16391 return h; 16392 }; 16393 16394 BX.delegateEvent = function(isTarget, handler) 16395 { 16396 return function(e) 16397 { 16398 e = e || window.event; 16399 var target = e.target || e.srcElement; 16400 16401 while (target != this) 16402 { 16403 if (_checkNode(target, isTarget)) 16404 { 16405 return handler.call(target, e); 16406 } 16407 if (target && target.parentNode) 16408 target = target.parentNode; 16409 else 16410 break; 16411 } 16412 return null; 16413 } 16414 }; 16415 16416 BX.False = function() {return false;}; 16417 BX.DoNothing = function() {}; 16418 16419 // TODO: also check event handlers set via BX.bind() 16420 BX.denyEvent = function(el, ev) 16421 { 16422 deniedEvents.push([el, ev, el['on' + ev]]); 16423 el['on' + ev] = BX.DoNothing; 16424 }; 16425 16426 BX.allowEvent = function(el, ev) 16427 { 16428 for(var i=0, len=deniedEvents.length; i<len; i++) 16429 { 16430 if (deniedEvents[i][0] == el && deniedEvents[i][1] == ev) 16431 { 16432 el['on' + ev] = deniedEvents[i][2]; 16433 BX.util.deleteFromArray(deniedEvents, i); 16434 return; 16435 } 16436 } 16437 }; 16438 16439 BX.fixEventPageXY = function(event) 16440 { 16441 BX.fixEventPageX(event); 16442 BX.fixEventPageY(event); 16443 return event; 16444 }; 16445 16446 BX.fixEventPageX = function(event) 16447 { 16448 if (event.pageX == null && event.clientX != null) 16449 { 16450 event.pageX = 16451 event.clientX + 16452 (document.documentElement && document.documentElement.scrollLeft || document.body && document.body.scrollLeft || 0) - 16453 (document.documentElement.clientLeft || 0); 16454 } 16455 16456 return event; 16457 }; 16458 16459 BX.fixEventPageY = function(event) 16460 { 16461 if (event.pageY == null && event.clientY != null) 16462 { 16463 event.pageY = 16464 event.clientY + 16465 (document.documentElement && document.documentElement.scrollTop || document.body && document.body.scrollTop || 0) - 16466 (document.documentElement.clientTop || 0); 16467 } 16468 16469 return event; 16470 }; 16471 16472 /** 16473 * @deprecated 16474 * @see e.preventDefault() 16475 */ 16476 BX.PreventDefault = function(e) 16477 { 16478 if(!e) e = window.event; 16479 if(e.stopPropagation) 16480 { 16481 e.preventDefault(); 16482 e.stopPropagation(); 16483 } 16484 else 16485 { 16486 e.cancelBubble = true; 16487 e.returnValue = false;
16488 } 16489 return false; 16490 }; 16491 16492 /** 16493 * @deprecated 16494 * @see e.preventDefault(); 16495 * 16496 * @param e 16497 * @return {boolean} 16498 */ 16499 BX.eventReturnFalse = function(e) 16500 { 16501 e=e||window.event; 16502 if (e && e.preventDefault) e.preventDefault(); 16503 else e.returnValue = false; 16504 return false; 16505 }; 16506 16507 /** 16508 * @deprecated 16509 * @see e.stopPropagation() 16510 * @param e 16511 */ 16512 BX.eventCancelBubble = function(e) 16513 { 16514 e=e||window.event; 16515 if(e && e.stopPropagation) 16516 e.stopPropagation(); 16517 else 16518 e.cancelBubble = true; 16519 }; 16520 16521 BX.bindDebouncedChange = function(node, fn, fnInstant, timeout, ctx) 16522 { 16523 ctx = ctx || window; 16524 timeout = timeout || 300; 16525 16526 var dataTag = 'bx-dc-previous-value'; 16527 BX.data(node, dataTag, node.value); 16528 16529 var act = function(fn, val){ 16530 16531 var pVal = BX.data(node, dataTag); 16532 16533 if(typeof pVal == 'undefined' || pVal != val){ 16534 if(typeof ctx != 'object') 16535 fn(val); 16536 else 16537 fn.apply(ctx, [val]); 16538 } 16539 }; 16540 16541 var actD = BX.debounce(function(){ 16542 var val = node.value; 16543 act(fn, val); 16544 BX.data(node, dataTag, val); 16545 }, timeout); 16546 16547 BX.bind(node, 'keyup', actD); 16548 BX.bind(node, 'change', actD); 16549 BX.bind(node, 'input', actD); 16550 16551 if(BX.type.isFunction(fnInstant)){ 16552 16553 var actI = function(){ 16554 act(fnInstant, node.value); 16555 }; 16556 16557 BX.bind(node, 'keyup', actI); 16558 BX.bind(node, 'change', actI); 16559 BX.bind(node, 'input', actI); 16560 } 16561 }; 16562 16563 BX.parseJSON = function(data, context) 16564 { 16565 var result = null; 16566 if (BX.type.isNotEmptyString(data)) 16567 { 16568 try { 16569 if (data.indexOf("\n") >= 0) 16570 eval('result = ' + data); 16571 else 16572 result = (new Function("return " + data))(); 16573 } catch(e) { 16574 BX.onCustomEvent(context, 'onParseJSONFailure', [data, context]) 16575 } 16576 } 16577 else if(BX.type.isPlainObject(data)) 16578 { 16579 return data; 16580 } 16581 16582 return result; 16583 }; 16584 16585 BX.submit = function(obForm, action_name, action_value, onAfterSubmit) 16586 { 16587 action_name = action_name || 'save'; 16588 if (!obForm['BXFormSubmit_' + action_name]) 16589 { 16590 obForm['BXFormSubmit_' + action_name] = obForm.appendChild(BX.create('INPUT', { 16591 'props': { 16592 'type': 'submit', 16593 'name': action_name, 16594 'value': action_value || 'Y' 16595 }, 16596 'style': { 16597 'display': 'none' 16598 } 16599 })); 16600 } 16601 16602 if (obForm.sessid) 16603 obForm.sessid.value = BX.bitrix_sessid(); 16604 16605 setTimeout(BX.delegate(function() {BX.fireEvent(this, 'click'); if (onAfterSubmit) onAfterSubmit();}, obForm['BXFormSubmit_' + action_name]), 10); 16606 }; 16607 16608 BX.show = function(ob, displayType) 16609 { 16610 if (ob.BXDISPLAY || !_checkDisplay(ob, displayType)) 16611 { 16612 ob.style.display = ob.BXDISPLAY; 16613 } 16614 }; 16615 16616 BX.hide = function(ob, displayType) 16617 { 16618 if (!ob.BXDISPLAY) 16619 _checkDisplay(ob, displayType); 16620 16621 ob.style.display = 'none'; 16622 }; 16623 16624 BX.toggle = function(ob, values) 16625 { 16626 if (!values && BX.type.isElementNode(ob)) 16627 { 16628 var bShow = true; 16629 if (ob.BXDISPLAY) 16630 bShow = !_checkDisplay(ob); 16631 else 16632 bShow = ob.style.display == 'none'; 16633 16634 if (bShow) 16635 BX.show(ob); 16636 else 16637 BX.hide(ob); 16638 } 16639 else if (BX.type.isArray(values)) 16640 { 16641 for (var i=0,len=values.length; i<len; i++) 16642 { 16643 if (ob == values[i]) 16644 { 16645 ob = values[i==len-1 ? 0 : i+1]; 16646 break; 16647 } 16648 } 16649 if (i==len) 16650 ob = values[0]; 16651 } 16652 16653 return ob; 16654 }; 16655 16656 function _checkDisplay(ob, displayType) 16657 { 16658 if (typeof displayType != 'undefined') 16659 ob.BXDISPLAY = displayType; 16660 16661 var d = ob.style.display || BX.style(ob, 'display'); 16662 if (d != 'none') 16663 { 16664 ob.BXDISPLAY = ob.BXDISPLAY || d; 16665 return true; 16666 } 16667 else 16668 { 16669 ob.BXDISPLAY = ob.BXDISPLAY || 'block'; 16670 return false; 16671 } 16672 } 16673 16674 /* some useful util functions */ 16675 16676 BX.util = { 16677 /** 16678 * @deprecated 16679 * @use [].filter(value => !BX.Type.isNil(value)) 16680 * @param ar 16681 * @return {*} 16682 */ 16683 array_values: function(ar) 16684 { 16685 if (!BX.type.isArray(ar)) 16686 return BX.util._array_values_ob(ar); 16687 var arv = []; 16688 for(var i=0,l=ar.length;i<l;i++) 16689 if (ar[i] !== null && typeof ar[i] != 'undefined') 16690 arv.push(ar[i]); 16691 return arv; 16692 }, 16693 16694 /** 16695 * @deprecated 16696 * @use Object.values([]).filter(value => !BX.Type.isNil(value)) 16697 * @param ar 16698 * @return {Array} 16699 * @private 16700 */ 16701 _array_values_ob: function(ar) 16702 { 16703 var arv = []; 16704 for(var i in ar) 16705 if (ar[i] !== null && typeof ar[i] != 'undefined') 16706 arv.push(ar[i]); 16707 return arv; 16708 }, 16709 16710 /** 16711 * @deprecated 16712 * @use 16713 * @param ar 16714 * @return {*} 16715 */ 16716 array_keys: function(ar) 16717 { 16718 if (!BX.type.isArray(ar)) 16719 return BX.util._array_keys_ob(ar); 16720 var arv = []; 16721 for(var i=0,l=ar.length;i<l;i++) 16722 if (ar[i] !== null && typeof ar[i] != 'undefined') 16723 arv.push(i); 16724 return arv; 16725 }, 16726 16727 _array_keys_ob: function(ar) 16728 { 16729 var arv = []; 16730 for(var i in ar) 16731 if (ar[i] !== null && typeof ar[i] != 'undefined') 16732 arv.push(i); 16733 return arv; 16734 }, 16735 16736 object_keys: function(obj) 16737 { 16738 var arv = []; 16739 for(var k in obj) 16740 { 16741 if(obj.hasOwnProperty(k)) 16742 { 16743 arv.push(k); 16744 } 16745 } 16746 return arv; 16747 }, 16748 16749 /** 16750 * @deprecated 16751 * @use firstArr.concat(secondArr); 16752 * @param first 16753 * @param second 16754 * @return {*[]} 16755 */ 16756 array_merge: function(first, second) 16757 { 16758 if (!BX.type.isArray(first)) first = []; 16759 if (!BX.type.isArray(second)) second = []; 16760 16761 var i = first.length, j = 0; 16762 16763 if (typeof second.length === "number") 16764 { 16765 for (var l = second.length; j < l; j++) 16766 { 16767 first[i++] = second[j]; 16768 } 16769 } 16770 else 16771 {
16772 while (second[j] !== undefined) 16773 { 16774 first[i++] = second[j++]; 16775 } 16776 } 16777 16778 first.length = i; 16779 16780 return first; 16781 }, 16782 16783 array_flip: function (object) 16784 { 16785 var newObject = {}; 16786 16787 for (var key in object) 16788 { 16789 newObject[object[key]] = key; 16790 } 16791 16792 return newObject; 16793 }, 16794 16795 array_diff: function(ar1, ar2, hash) 16796 { 16797 hash = BX.type.isFunction(hash) ? hash : null; 16798 var i, length, v, h, map = {}, result = []; 16799 for(i = 0, length = ar2.length; i < length; i++) 16800 { 16801 v = ar2[i]; 16802 h = hash ? hash(v) : v; 16803 map[h] = true; 16804 } 16805 16806 for(i = 0, length = ar1.length; i < length; i++) 16807 { 16808 v = ar1[i]; 16809 h = hash ? hash(v) : v; 16810 if(typeof(map[h]) === "undefined") 16811 { 16812 result.push(v); 16813 } 16814 } 16815 return result; 16816 }, 16817 16818 /** 16819 * @deprecated 16820 * @use Set 16821 */ 16822 array_unique: function(ar) 16823 { 16824 var i=0,j,len=ar.length; 16825 if(len<2) return ar; 16826 16827 for (; i<len-1;i++) 16828 { 16829 for (j=i+1; j<len;j++) 16830 { 16831 if (ar[i]==ar[j]) 16832 { 16833 ar.splice(j--,1); len--; 16834 } 16835 } 16836 } 16837 16838 return ar; 16839 }, 16840 16841 /** 16842 * @deprecated 16843 * @use myArr.includes(needle) 16844 */ 16845 in_array: function(needle, haystack) 16846 { 16847 for(var i=0; i<haystack.length; i++) 16848 { 16849 if(haystack[i] == needle) 16850 return true; 16851 } 16852 return false; 16853 }, 16854 16855 /** 16856 * @deprecated 16857 * @use myArr.findIndex(item => item === needle); 16858 */ 16859 array_search: function(needle, haystack) 16860 { 16861 for(var i=0; i<haystack.length; i++) 16862 { 16863 if(haystack[i] == needle) 16864 return i; 16865 } 16866 return -1; 16867 }, 16868 16869 object_search_key: function(needle, haystack) 16870 { 16871 if (typeof haystack[needle] != 'undefined') 16872 return haystack[needle]; 16873 16874 for(var i in haystack) 16875 { 16876 if (typeof haystack[i] == "object") 16877 { 16878 var result = BX.util.object_search_key(needle, haystack[i]); 16879 if (result !== false) 16880 return result; 16881 } 16882 } 16883 return false; 16884 }, 16885 16886 trim: function(s) 16887 { 16888 if (BX.type.isString(s)) 16889 { 16890 return s.trim(); 16891 } 16892 16893 return s; 16894 }, 16895 16896 urlencode: function(s){return encodeURIComponent(s);}, 16897 16898 // it may also be useful. via sVD. 16899 deleteFromArray: function(ar, ind) {return ar.slice(0, ind).concat(ar.slice(ind + 1));}, 16900 insertIntoArray: function(ar, ind, el) {return ar.slice(0, ind).concat([el]).concat(ar.slice(ind));}, 16901 16902 htmlspecialchars: function(str) 16903 { 16904 return BX.Text.encode(str); 16905 }, 16906 16907 htmlspecialcharsback: function(str) 16908 { 16909 return BX.Text.decode(str); 16910 }, 16911 16912 // Quote regular expression characters plus an optional character 16913 preg_quote: function(str, delimiter) 16914 { 16915 if(!str.replace) 16916 return str; 16917 return str.replace(new RegExp('[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + (delimiter || '') + '-]', 'g'), '\\$&'); 16918 }, 16919 16920 jsencode: function(str) 16921 { 16922 if (!str || !str.replace) 16923 return str; 16924 16925 var escapes = 16926 [ 16927 { c: "\\\\", r: "\\\\" }, // should be first 16928 { c: "\\t", r: "\\t" }, 16929 { c: "\\n", r: "\\n" }, 16930 { c: "\\r", r: "\\r" }, 16931 { c: "\"", r: "\\\"" }, 16932 { c: "'", r: "\\'" }, 16933 { c: "<", r: "\\x3C" }, 16934 { c: ">", r: "\\x3E" }, 16935 { c: "\\u2028", r: "\\u2028" }, 16936 { c: "\\u2029", r: "\\u2029" } 16937 ]; 16938 for (var i = 0; i < escapes.length; i++) 16939 str = str.replace(new RegExp(escapes[i].c, 'g'), escapes[i].r); 16940 return str; 16941 }, 16942 16943 getCssName: function(jsName) 16944 { 16945 if (!BX.type.isNotEmptyString(jsName)) 16946 { 16947 return ""; 16948 } 16949 16950 return jsName.replace(/[A-Z]/g, function(match) { 16951 return "-" + match.toLowerCase(); 16952 }); 16953 }, 16954 16955 getJsName: function(cssName) 16956 { 16957 var regex = /\-([a-z]){1}/g; 16958 if (regex.test(cssName)) 16959 { 16960 return cssName.replace(regex, function(match, letter) { 16961 return letter.toUpperCase(); 16962 }); 16963 } 16964 16965 return cssName; 16966 }, 16967 16968 nl2br: function(str) 16969 { 16970 if (!str || !str.replace) 16971 return str; 16972 16973 return str.replace(/([^>])\n/g, '$1<br/>'); 16974 }, 16975 16976 /** 16977 * @deprecated 16978 * @use .padStart() / .padEnd() 16979 * @param input 16980 * @param pad_length 16981 * @param pad_string 16982 * @param pad_type 16983 * @return {*} 16984 */ 16985 str_pad: function(input, pad_length, pad_string, pad_type) 16986 { 16987 pad_string = pad_string || ' '; 16988 pad_type = pad_type || 'right'; 16989 input = input.toString(); 16990 16991 if (pad_type === 'left') 16992 { 16993 return BX.util.str_pad_left(input, pad_length, pad_string); 16994 } 16995 16996 return BX.util.str_pad_right(input, pad_length, pad_string); 16997 }, 16998 16999 str_pad_left: function(input, pad_length, pad_string) 17000 { 17001 return input.toString().padStart(pad_length, pad_string); 17002 }, 17003 17004 str_pad_right: function(input, pad_length, pad_string) 17005 { 17006 return input.toString().padEnd(pad_length, pad_string); 17007 }, 17008 17009 strip_tags: function(str) 17010 { 17011 return str.split(/<[^>]+>/g).join(''); 17012 }, 17013 17014 strip_php_tags: function(str) 17015 { 17016 return str.replace(/<\?(.|[\r\n])*?\?>/g, ''); 17017 }, 17018 17019 popup: function(url, width, height) 17020 { 17021 var w, h; 17022 if(BX.browser.IsOpera()) 17023 { 17024 w = document.body.offsetWidth; 17025 h = document.body.offsetHeight; 17026 } 17027 else 17028 {
17029 w = screen.width; 17030 h = screen.height; 17031 } 17032 return window.open(url, '', 'status=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+',top='+Math.floor((h - height)/2-14)+',left='+Math.floor((w - width)/2-5)); 17033 }, 17034 17035 shuffle: function(array) 17036 { 17037 var temporaryValue, randomIndex; 17038 var currentIndex = array.length; 17039 17040 while (0 !== currentIndex) 17041 { 17042 randomIndex = Math.floor(Math.random() * currentIndex); 17043 currentIndex -= 1; 17044 17045 temporaryValue = array[currentIndex]; 17046 array[currentIndex] = array[randomIndex]; 17047 array[randomIndex] = temporaryValue; 17048 } 17049 17050 return array; 17051 }, 17052 17053 // BX.util.objectSort(object, sortBy, sortDir) - Sort object by property 17054 // function params: 1 - object for sort, 2 - sort by property, 3 - sort direction (asc/desc) 17055 // return: sort array [[objectElement], [objectElement]] in sortDir direction 17056 17057 // example: BX.util.objectSort({'L1': {'name': 'Last'}, 'F1': {'name': 'First'}}, 'name', 'asc'); 17058 // return: [{'name' : 'First'}, {'name' : 'Last'}] 17059 objectSort: function(object, sortBy, sortDir) 17060 { 17061 sortDir = sortDir == 'asc'? 'asc': 'desc'; 17062 17063 var arItems = [], i; 17064 for (i in object) 17065 { 17066 if (object.hasOwnProperty(i) && object[i][sortBy]) 17067 { 17068 arItems.push([i, object[i][sortBy]]); 17069 } 17070 } 17071 17072 if (sortDir == 'asc') 17073 { 17074 arItems.sort(function(i, ii) { 17075 var s1, s2; 17076 if (BX.type.isDate(i[1])) 17077 { 17078 s1 = i[1].getTime(); 17079 } 17080 else if (!isNaN(i[1])) 17081 { 17082 s1 = parseInt(i[1]); 17083 } 17084 else 17085 { 17086 s1 = i[1].toString().toLowerCase(); 17087 } 17088 17089 if (BX.type.isDate(ii[1])) 17090 { 17091 s2 = ii[1].getTime(); 17092 } 17093 else if (!isNaN(ii[1])) 17094 { 17095 s2 = parseInt(ii[1]); 17096 } 17097 else 17098 { 17099 s2 = ii[1].toString().toLowerCase(); 17100 } 17101 17102 if (s1 > s2) 17103 return 1; 17104 else if (s1 < s2) 17105 return -1; 17106 else 17107 return 0; 17108 }); 17109 } 17110 else 17111 { 17112 arItems.sort(function(i, ii) { 17113 var s1, s2; 17114 if (BX.type.isDate(i[1])) 17115 { 17116 s1 = i[1].getTime(); 17117 } 17118 else if (!isNaN(i[1])) 17119 { 17120 s1 = parseInt(i[1]); 17121 } 17122 else 17123 { 17124 s1 = i[1].toString().toLowerCase(); 17125 } 17126 17127 if (BX.type.isDate(ii[1])) 17128 { 17129 s2 = ii[1].getTime(); 17130 } 17131 else if (!isNaN(ii[1])) 17132 { 17133 s2 = parseInt(ii[1]); 17134 } 17135 else 17136 { 17137 s2 = ii[1].toString().toLowerCase(); 17138 } 17139 17140 if (s1 < s2) 17141 return 1; 17142 else if (s1 > s2) 17143 return -1; 17144 else 17145 return 0; 17146 }); 17147 } 17148 17149 var arReturnArray = Array(); 17150 for (i = 0; i < arItems.length; i++) 17151 { 17152 arReturnArray.push(object[arItems[i][0]]); 17153 } 17154 17155 return arReturnArray; 17156 }, 17157 17158 objectMerge: function() 17159 { 17160 return BX.mergeEx.apply(window, arguments); 17161 }, 17162 17163 objectClone : function(object) 17164 { 17165 return BX.clone(object, true); 17166 }, 17167 17168 // #fdf9e5 => {r=253, g=249, b=229} 17169 hex2rgb: function(color) 17170 { 17171 var rgb = color.replace(/[# ]/g,"").replace(/^(.)(.)(.)$/,'$1$1$2$2$3$3').match(/.{2}/g); 17172 for (var i=0; i<3; i++) 17173 { 17174 rgb[i] = parseInt(rgb[i], 16); 17175 } 17176 return {'r':rgb[0],'g':rgb[1],'b':rgb[2]}; 17177 }, 17178 17179 /** 17180 * @deprecated 17181 * @use BX.Uri 17182 * @param url 17183 * @param param 17184 * @return {string} 17185 */ 17186 remove_url_param: function(url, param) 17187 { 17188 return BX.Uri.removeParam(url, param); 17189 }, 17190 17191 /* 17192 {'param1': 'value1', 'param2': 'value2'} 17193 */ 17194 /** 17195 * @deprecated 17196 * @use BX.Uri 17197 * @param url 17198 * @param params 17199 * @return {string} 17200 */ 17201 add_url_param: function(url, params) 17202 { 17203 var preparedParams = Object.entries(params).reduce(function(acc, item) { 17204 acc[item[0]] = BX.type.isArray(item[1]) ? item[1].join() : item[1]; 17205 return acc; 17206 }, {}); 17207 17208 return BX.Uri.addParam(url, preparedParams); 17209 }, 17210 17211 /* 17212 {'param1': 'value1', 'param2': 'value2'} 17213 */ 17214 buildQueryString: function(params) 17215 { 17216 var result = ''; 17217 for (var key in params) 17218 { 17219 var value = params[key]; 17220 if(BX.type.isArray(value)) 17221 { 17222 value.forEach(function(valueElement, index) 17223 { 17224 result += encodeURIComponent(key + "[" + index + "]") + "=" + encodeURIComponent(valueElement) + "&"; 17225 }); 17226 } 17227 else 17228 { 17229 result += encodeURIComponent(key) + "=" + encodeURIComponent(value) + "&"; 17230 } 17231 } 17232 17233 if(result.length > 0) 17234 { 17235 result = result.substr(0, result.length - 1); 17236 } 17237 return result; 17238 }, 17239 17240 even: function(digit) 17241 { 17242 return (parseInt(digit) % 2 == 0); 17243 }, 17244 17245 hashCode: function(str) 17246 { 17247 if(!BX.type.isNotEmptyString(str)) 17248 { 17249 return 0; 17250 } 17251 17252 var hash = 0; 17253 for (var i = 0; i < str.length; i++) 17254 { 17255 var c = str.charCodeAt(i); 17256 hash = ((hash << 5) - hash) + c; 17257 hash = hash & hash; 17258 } 17259 return hash; 17260 }, 17261 17262 getRandomString: function (length) 17263 { 17264 return BX.Text.getRandom(length); 17265 }, 17266 17267 number_format: function(number, decimals, dec_point, thousands_sep) 17268 { 17269 var i, j, kw, kd, km, sign = ''; 17270 decimals = Math.abs(decimals); 17271 if (isNaN(decimals) || decimals < 0) 17272 { 17273 decimals = 2; 17274 } 17275 dec_point = dec_point || ','; 17276 if (typeof thousands_sep === 'undefined') 17277 thousands_sep = '.'; 17278 17279 number = (+number || 0).toFixed(decimals); 17280 if (number < 0) 17281 { 17282 sign = '-'; 17283 number = -number; 17284 } 17285 17286 i = parseInt(number, 10) + ''; 17287 j = (i.length > 3 ? i.length % 3 : 0); 17288 17289 km = (j ? i.substr(0, j) + thousands_sep : ''); 17290 kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep); 17291 kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, '0').slice(2) : ''); 17292 17293 return sign + km + kw + kd; 17294 }, 17295 17296 getExtension: function (url) 17297 { 17298 url = url || ""; 17299 var items = url.split("?")[0].split("."); 17300 return items[items.length-1].toLowerCase(); 17301 }, 17302 addObjectToForm: function(object, form, prefix) 17303 { 17304 if(!BX.type.isString(prefix)) 17305 { 17306 prefix = ""; 17307 } 17308 17309 for(var key in object) 17310 { 17311 if(!object.hasOwnProperty(key)) 17312 { 17313 continue; 17314 } 17315 17316 var value = object[key]; 17317 var name = prefix !== "" ? (prefix + "[" + key + "]") : key; 17318 if(BX.type.isArray(value)) 17319 { 17320 var obj = {}; 17321 for(var i = 0; i < value.length; i++) 17322 { 17323 obj[i] = value[i]; 17324 } 17325 17326 BX.util.addObjectToForm(obj, form, name); 17327 } 17328 else if(BX.type.isPlainObject(value)) 17329 { 17330 BX.util.addObjectToForm(value, form, name); 17331 } 17332 else 17333 { 17334 value = BX.type.isFunction(value.toString) ? value.toString() : ""; 17335 if(value !== "") 17336 { 17337 form.appendChild(BX.create("INPUT", { attrs: { type: "hidden", name: name, value: value } })); 17338 } 17339 } 17340 } 17341 }, 17342 17343 observe: function(object, enable) 17344 {
17345 console.error('BX.util.observe: function is no longer supported by browser.'); 17346 return false; 17347 }, 17348 17349 escapeRegExp: function(str) 17350 { 17351 return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); 17352 } 17353 }; 17354 17355 BX.validation = { 17356 checkIfEmail: function(s) 17357 { 17358 var atom = "[=a-z0-9_+~'!$&*^`|#%/?{}-]"; 17359 return (new RegExp('^\\s*'+atom+'+(\\.'+atom+'+)*@([a-z0-9-]+\\.)+[a-z0-9-]{2,20}\\s*$', 'i')).test(s); 17360 }, 17361 checkIfPhone: function(s) 17362 { 17363 var regexp = new RegExp( 17364 typeof(BX.PhoneNumber) === "undefined" 17365 ? BX.PhoneNumber.getValidNumberPattern() 17366 : '^\\s*\\+?\s*[0-9(-)\\s]+\\s*$', 17367 'i' 17368 ); 17369 return regexp.test(s); 17370 } 17371 }; 17372 17373 BX.prop = 17374 { 17375 get: function(object, key, defaultValue) 17376 { 17377 return object && object.hasOwnProperty(key) ? object[key] : defaultValue; 17378 }, 17379 getObject: function(object, key, defaultValue) 17380 { 17381 return object && BX.type.isPlainObject(object[key]) ? object[key] : defaultValue; 17382 }, 17383 getElementNode: function(object, key, defaultValue) 17384 { 17385 return object && BX.type.isElementNode(object[key]) ? object[key] : defaultValue; 17386 }, 17387 getArray: function(object, key, defaultValue) 17388 { 17389 return object && BX.type.isArray(object[key]) ? object[key] : defaultValue; 17390 }, 17391 getFunction: function(object, key, defaultValue) 17392 { 17393 return object && BX.type.isFunction(object[key]) ? object[key] : defaultValue; 17394 }, 17395 getNumber: function(object, key, defaultValue) 17396 { 17397 if(!(object && object.hasOwnProperty(key))) 17398 { 17399 return defaultValue; 17400 } 17401 17402 var value = object[key]; 17403 if(BX.type.isNumber(value)) 17404 { 17405 return value; 17406 } 17407 17408 value = parseFloat(value); 17409 return !isNaN(value) ? value : defaultValue; 17410 }, 17411 getInteger: function(object, key, defaultValue) 17412 { 17413 if(!(object && object.hasOwnProperty(key))) 17414 { 17415 return defaultValue; 17416 } 17417 17418 var value = object[key]; 17419 if(BX.type.isNumber(value)) 17420 { 17421 return value; 17422 } 17423 17424 value = parseInt(value); 17425 return !isNaN(value) ? value : defaultValue; 17426 }, 17427 getBoolean: function(object, key, defaultValue) 17428 { 17429 if(!(object && object.hasOwnProperty(key))) 17430 { 17431 return defaultValue; 17432 } 17433 17434 var value = object[key]; 17435 return (BX.type.isBoolean(value) 17436 ? value 17437 : (BX.type.isString(value) ? (value.toLowerCase() === "true") : !!value) 17438 ); 17439 }, 17440 getString: function(object, key, defaultValue) 17441 { 17442 if(!(object && object.hasOwnProperty(key))) 17443 { 17444 return defaultValue; 17445 } 17446 17447 var value = object[key]; 17448 return BX.type.isString(value) ? value : (value ? value.toString() : ''); 17449 }, 17450 extractDate: function(datetime) 17451 { 17452 if(!BX.type.isDate(datetime)) 17453 { 17454 datetime = new Date(); 17455 } 17456 17457 datetime.setHours(0); 17458 datetime.setMinutes(0); 17459 datetime.setSeconds(0); 17460 datetime.setMilliseconds(0); 17461 17462 return datetime; 17463 } 17464 }; 17465 17466 BX.isNodeInDom = function(node, doc) 17467 { 17468 return node === (doc || document) ? true : 17469 (node.parentNode ? BX.isNodeInDom(node.parentNode) : false); 17470 }; 17471 17472 BX.isNodeHidden = function(node) 17473 { 17474 if (node === document) 17475 return false; 17476 else if (BX.style(node, 'display') == 'none') 17477 return true; 17478 else 17479 return (node.parentNode ? BX.isNodeHidden(node.parentNode) : true); 17480 }; 17481 17482 BX.evalPack = function(code) 17483 { 17484 while (code.length > 0) 17485 { 17486 var c = code.shift(); 17487 17488 if (c.TYPE == 'SCRIPT_EXT' || c.TYPE == 'SCRIPT_SRC') 17489 { 17490 BX.loadScript(c.DATA, function() {BX.evalPack(code)}); 17491 return; 17492 } 17493 else if (c.TYPE == 'SCRIPT') 17494 { 17495 BX.evalGlobal(c.DATA); 17496 } 17497 } 17498 }; 17499 17500 BX.evalGlobal = function(data) 17501 { 17502 if (data) 17503 { 17504 var head = document.getElementsByTagName("head")[0] || document.documentElement, 17505 script = document.createElement("script"); 17506 17507 script.type = "text/javascript"; 17508 17509 if (!BX.browser.IsIE()) 17510 { 17511 script.appendChild(document.createTextNode(data)); 17512 } 17513 else 17514 { 17515 script.text = data; 17516 } 17517 17518 head.insertBefore(script, head.firstChild); 17519 head.removeChild(script); 17520 } 17521 }; 17522 17523 BX.garbage = function(call, thisObject) 17524 { 17525 garbageCollectors.push({callback: call, context: thisObject}); 17526 }; 17527 17528 BX.GetDocElement = function (pDoc) 17529 { 17530 pDoc = pDoc || document; 17531 return (BX.browser.IsDoctype(pDoc) ? pDoc.documentElement : pDoc.body); 17532 }; 17533 17534 BX.scrollTop = function(node, val){ 17535 if(typeof val != 'undefined'){ 17536 17537 if(node == window){ 17538 throw new Error('scrollTop() for window is not implemented'); 17539 }else 17540 node.scrollTop = parseInt(val); 17541 17542 }else{ 17543 17544 if(node == window) 17545 return BX.GetWindowScrollPos().scrollTop; 17546 17547 return node.scrollTop; 17548 } 17549 }; 17550 17551 BX.scrollLeft = function(node, val){ 17552 if(typeof val != 'undefined'){ 17553 17554 if(node == window){ 17555 throw new Error('scrollLeft() for window is not implemented'); 17556 }else 17557 node.scrollLeft = parseInt(val); 17558 17559 }else{ 17560 17561 if(node == window) 17562 return BX.GetWindowScrollPos().scrollLeft; 17563 17564 return node.scrollLeft; 17565 } 17566 }; 17567 17568 BX.hide_object = function(ob) 17569 { 17570 ob = BX(ob); 17571 ob.style.position = 'absolute'; 17572 ob.style.top = '-1000px'; 17573 ob.style.left = '-1000px'; 17574 ob.style.height = '10px'; 17575 ob.style.width = '10px'; 17576 }; 17577 17578 BX.is_relative = function(el) 17579 { 17580 var p = BX.style(el, 'position'); 17581 return p == 'relative' || p == 'absolute'; 17582 }; 17583 17584 BX.is_float = function(el) 17585 { 17586 var p = BX.style(el, 'float'); 17587 return p == 'right' || p == 'left'; 17588 }; 17589 17590 BX.is_fixed = function(el) 17591 { 17592 var p = BX.style(el, 'position'); 17593 return p == 'fixed'; 17594 }; 17595 17596 BX.width = function(node, val){ 17597 if(typeof val != 'undefined') 17598 BX.style(node, 'width', parseInt(val)+'px'); 17599 else{ 17600 17601 if(node == window) 17602 return window.innerWidth; 17603 17604 //return parseInt(BX.style(node, 'width')); 17605 return BX.pos(node).width; 17606 } 17607 }; 17608 17609 BX.height = function(node, val){ 17610 if(typeof val != 'undefined') 17611 BX.style(node, 'height', parseInt(val)+'px'); 17612 else{ 17613 17614 if(node == window) 17615 return window.innerHeight; 17616 17617 //return parseInt(BX.style(node, 'height')); 17618 return BX.pos(node).height; 17619 } 17620 }; 17621 17622 BX.align = function(pos, w, h, type) 17623 { 17624 if (type) 17625 type = type.toLowerCase(); 17626 else 17627 type = ''; 17628 17629 var pDoc = document; 17630 if (BX.type.isElementNode(pos)) 17631 { 17632 pDoc = pos.ownerDocument; 17633 pos = BX.pos(pos); 17634 } 17635 17636 var x = pos["left"], y = pos["bottom"]; 17637 17638 var scroll = BX.GetWindowScrollPos(pDoc); 17639 var size = BX.GetWindowInnerSize(pDoc); 17640 17641 if((size.innerWidth + scroll.scrollLeft) - (pos["left"] + w) < 0) 17642 { 17643 if(pos["right"] - w >= 0 ) 17644 x = pos["right"] - w; 17645 else 17646 x = scroll.scrollLeft; 17647 } 17648
17649 if(((size.innerHeight + scroll.scrollTop) - (pos["bottom"] + h) < 0) || ~type.indexOf('top')) 17650 { 17651 if(pos["top"] - h >= 0 || ~type.indexOf('top')) 17652 y = pos["top"] - h; 17653 else 17654 y = scroll.scrollTop; 17655 } 17656 17657 return {'left':x, 'top':y}; 17658 }; 17659 17660 BX.scrollToNode = function(node) 17661 { 17662 var obNode = BX(node); 17663 17664 if (obNode.scrollIntoView) 17665 obNode.scrollIntoView(true); 17666 else 17667 { 17668 var arNodePos = BX.pos(obNode); 17669 window.scrollTo(arNodePos.left, arNodePos.top); 17670 } 17671 }; 17672 17673 /* non-xhr loadings */ 17674 BX.showWait = function(node, msg) 17675 { 17676 node = BX(node) || document.body || document.documentElement; 17677 msg = msg || BX.message('JS_CORE_LOADING'); 17678 17679 var container_id = node.id || Math.random(); 17680 17681 var obMsg = node.bxmsg = document.body.appendChild(BX.create('DIV', { 17682 props: { 17683 id: 'wait_' + container_id 17684 }, 17685 style: { 17686 background: 'url("/bitrix/js/main/core/images/wait.gif") no-repeat scroll 10px center #fcf7d1', 17687 border: '1px solid #E1B52D', 17688 color: 'black', 17689 fontFamily: 'Verdana,Arial,sans-serif', 17690 fontSize: '11px', 17691 padding: '10px 30px 10px 37px', 17692 position: 'absolute', 17693 textAlign:'center' 17694 }, 17695 text: msg 17696 })); 17697 17698 BX.ZIndexManager.register(obMsg); 17699 BX.ZIndexManager.bringToFront(obMsg); 17700 17701 setTimeout(BX.delegate(_adjustWait, node), 10); 17702 17703 lastWait[lastWait.length] = obMsg; 17704 return obMsg; 17705 }; 17706 17707 BX.closeWait = function(node, obMsg) 17708 { 17709 if(node && !obMsg) 17710 obMsg = node.bxmsg; 17711 if(node && !obMsg && BX.hasClass(node, 'bx-core-waitwindow')) 17712 obMsg = node; 17713 if(node && !obMsg) 17714 obMsg = BX('wait_' + node.id); 17715 if(!obMsg) 17716 obMsg = lastWait.pop(); 17717 17718 if (obMsg && obMsg.parentNode) 17719 { 17720 for (var i=0,len=lastWait.length;i<len;i++) 17721 { 17722 if (obMsg == lastWait[i]) 17723 { 17724 lastWait = BX.util.deleteFromArray(lastWait, i); 17725 break; 17726 } 17727 } 17728 17729 BX.ZIndexManager.unregister(obMsg); 17730 obMsg.parentNode.removeChild(obMsg); 17731 if (node) node.bxmsg = null; 17732 BX.cleanNode(obMsg, true); 17733 } 17734 }; 17735 17736 BX.setJSList = function(scripts) 17737 { 17738 if (BX.type.isArray(scripts)) 17739 { 17740 scripts = scripts.map(function(script) { 17741 return normalizeUrl(script) 17742 }); 17743 17744 jsList = jsList.concat(scripts); 17745 } 17746 }; 17747 17748 BX.getJSList = function() 17749 { 17750 initJsList(); 17751 return jsList; 17752 }; 17753 17754 BX.setCSSList = function(cssFiles) 17755 { 17756 if (BX.type.isArray(cssFiles)) 17757 { 17758 cssFiles = cssFiles.map(function(cssFile) { 17759 return normalizeUrl(cssFile); 17760 }); 17761 17762 cssList = cssList.concat(cssFiles); 17763 } 17764 }; 17765 17766 BX.getCSSList = function() 17767 { 17768 initCssList(); 17769 return cssList; 17770 }; 17771 17772 BX.getJSPath = function(js) 17773 { 17774 return js.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 17775 }; 17776 17777 BX.getCSSPath = function(css) 17778 { 17779 return css.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 17780 }; 17781 17782 BX.getCDNPath = function(path) 17783 { 17784 return path; 17785 }; 17786 17787 BX.loadScript = function(script, callback, doc) 17788 { 17789 if (BX.type.isString(script)) 17790 { 17791 script = [script]; 17792 } 17793 17794 return BX.load(script, callback, doc); 17795 }; 17796 17797 BX.loadCSS = function(css, doc, win) 17798 { 17799 if (BX.type.isString(css)) 17800 { 17801 css = [css]; 17802 } 17803 17804 if (BX.type.isArray(css)) 17805 { 17806 css = css.map(function(url) { 17807 return { url: url, ext: "css" } 17808 }); 17809 17810 BX.load(css, null, doc); 17811 } 17812 }; 17813 17814 BX.load = function(items, callback, doc) 17815 { 17816 if (!BX.isReady) 17817 { 17818 var _args = arguments; 17819 BX.ready(function() { 17820 BX.load.apply(this, _args); 17821 }); 17822 return null; 17823 } 17824 17825 doc = doc || document; 17826 if (isAsync === null) 17827 { 17828 isAsync = "async" in doc.createElement("script") || "MozAppearance" in doc.documentElement.style || window.opera; 17829 } 17830 17831 return isAsync ? loadAsync(items, callback, doc) : loadAsyncEmulation(items, callback, doc); 17832 }; 17833 17834 BX.convert = 17835 { 17836 toNumber: function(value) 17837 { 17838 if(BX.type.isNumber(value)) 17839 { 17840 return value; 17841 } 17842 17843 value = Number(value); 17844 return !isNaN(value) ? value : 0; 17845 }, 17846 nodeListToArray: function(nodes) 17847 { 17848 try 17849 { 17850 return (Array.prototype.slice.call(nodes, 0)); 17851 } 17852 catch (ex) 17853 { 17854 var ary = []; 17855 for(var i = 0, l = nodes.length; i < l; i++) 17856 { 17857 ary.push(nodes[i]); 17858 } 17859 return ary; 17860 } 17861 } 17862 }; 17863 17864 function loadAsync(items, callback, doc) 17865 { 17866 if (!BX.type.isArray(items)) 17867 { 17868 return; 17869 } 17870 17871 function allLoaded(items) 17872 { 17873 items = items || assets; 17874 for (var name in items) 17875 { 17876 if (items.hasOwnProperty(name) && items[name].state !== LOADED) 17877 { 17878 return false;
17879 } 17880 } 17881 17882 return true; 17883 } 17884 17885 if (!BX.type.isFunction(callback)) 17886 { 17887 callback = null; 17888 } 17889 17890 var itemSet = {}, item, i; 17891 for (i = 0; i < items.length; i++) 17892 { 17893 item = items[i]; 17894 item = getAsset(item); 17895 itemSet[item.name] = item; 17896 } 17897 17898 var callbackWasCalled = false; 17899 if (items.length > 0) 17900 { 17901 for (i = 0; i < items.length; i++) 17902 { 17903 item = items[i]; 17904 item = getAsset(item); 17905 load(item, function () { 17906 if (allLoaded(itemSet)) 17907 { 17908 if (!callbackWasCalled) 17909 { 17910 callback && callback(); 17911 callbackWasCalled = true; 17912 } 17913 17914 } 17915 }, doc); 17916 } 17917 } 17918 else 17919 { 17920 if (typeof callback === 'function') 17921 { 17922 callback(); 17923 callbackWasCalled = true; 17924 } 17925 } 17926 } 17927 17928 function loadAsyncEmulation(items, callback, doc) 17929 { 17930 function onPreload(asset) 17931 { 17932 asset.state = PRELOADED; 17933 if (BX.type.isArray(asset.onpreload) && asset.onpreload) 17934 { 17935 for (var i = 0; i < asset.onpreload.length; i++) 17936 { 17937 asset.onpreload[i].call(); 17938 } 17939 } 17940 } 17941 17942 function preLoad(asset) 17943 { 17944 if (asset.state === undefined) 17945 { 17946 asset.state = PRELOADING; 17947 asset.onpreload = []; 17948 17949 loadAsset( 17950 { url: asset.url, type: "cache", ext: asset.ext}, 17951 function () { onPreload(asset); }, 17952 doc 17953 ); 17954 } 17955 } 17956 17957 if (!BX.type.isArray(items)) 17958 { 17959 return; 17960 } 17961 17962 if (!BX.type.isFunction(callback)) 17963 { 17964 callback = null; 17965 } 17966 17967 var rest = [].slice.call(items, 1); 17968 for (var i = 0; i < rest.length; i++) 17969 { 17970 preLoad(getAsset(rest[i])); 17971 } 17972 17973 load(getAsset(items[0]), items.length === 1 ? callback : function () { 17974 loadAsyncEmulation.apply(null, [rest, callback, doc]); 17975 }, doc); 17976 } 17977 17978 function load(asset, callback, doc) 17979 { 17980 callback = callback || BX.DoNothing; 17981 17982 if (asset.state === LOADED) 17983 { 17984 callback(); 17985 return; 17986 } 17987 17988 if (asset.state === PRELOADING) 17989 { 17990 asset.onpreload.push(function () { 17991 load(asset, callback, doc); 17992 }); 17993 return; 17994 } 17995 17996 asset.state = LOADING; 17997 17998 loadAsset( 17999 asset, 18000 function () { 18001 asset.state = LOADED; 18002 callback(); 18003 }, 18004 doc 18005 ); 18006 } 18007 18008 function loadAsset(asset, callback, doc) 18009 { 18010 callback = callback || BX.DoNothing; 18011 18012 function error(event) 18013 { 18014 ele.onload = ele.onreadystatechange = ele.onerror = null; 18015 callback(); 18016 } 18017 18018 function process(event) 18019 { 18020 event = event || window.event; 18021 if (event.type === "load" || (/loaded|complete/.test(ele.readyState) && (!doc.documentMode || doc.documentMode < 9))) 18022 { 18023 window.clearTimeout(asset.errorTimeout); 18024 window.clearTimeout(asset.cssTimeout); 18025 ele.onload = ele.onreadystatechange = ele.onerror = null; 18026 callback(); 18027 } 18028 } 18029 18030 function isCssLoaded() 18031 { 18032 if (asset.state !== LOADED && asset.cssRetries <= 20) 18033 { 18034 for (var i = 0, l = doc.styleSheets.length; i < l; i++) 18035 { 18036 if (doc.styleSheets[i].href === ele.href) 18037 { 18038 process({"type": "load"}); 18039 return; 18040 } 18041 } 18042 18043 asset.cssRetries++; 18044 asset.cssTimeout = window.setTimeout(isCssLoaded, 250); 18045 } 18046 } 18047 18048 var ele; 18049 var ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 18050 18051 if (ext === "css") 18052 { 18053 ele = doc.createElement("link"); 18054 ele.type = "text/" + (asset.type || "css"); 18055 ele.rel = "stylesheet"; 18056 ele.href = asset.url; 18057 18058 asset.cssRetries = 0; 18059 asset.cssTimeout = window.setTimeout(isCssLoaded, 500); 18060 } 18061 else 18062 { 18063 ele = doc.createElement("script"); 18064 ele.type = "text/" + (asset.type || "javascript"); 18065 ele.src = asset.url; 18066 } 18067 18068 ele.onload = ele.onreadystatechange = process; 18069 ele.onerror = error; 18070 18071 ele.async = false; 18072 ele.defer = false; 18073 18074 asset.errorTimeout = window.setTimeout(function () { 18075 error({type: "timeout"}); 18076 }, 7000); 18077 18078 if (ext === "css") 18079 { 18080 cssList.push(normalizeMinUrl(normalizeUrl(asset.url))); 18081 } 18082 else 18083 { 18084 jsList.push(normalizeMinUrl(normalizeUrl(asset.url))); 18085 } 18086 18087 var templateLink = null; 18088 var head = doc.head || doc.getElementsByTagName("head")[0]; 18089 if (ext === "css" && (templateLink = getTemplateLink(head)) !== null) 18090 { 18091 templateLink.parentNode.insertBefore(ele, templateLink); 18092 } 18093 else 18094 { 18095 head.insertBefore(ele, head.lastChild); 18096 } 18097 } 18098 18099 function getAsset(item) 18100 { 18101 var asset = {}; 18102 if (typeof item === "object") 18103 { 18104 asset = item; 18105 asset.name = asset.name ? asset.name : BX.util.hashCode(item.url); 18106 } 18107 else 18108 { 18109 asset = { name: BX.util.hashCode(item), url : item }; 18110 } 18111 18112 var ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 18113 if ((ext === "css" && isCssLoaded(asset.url)) || isScriptLoaded(asset.url)) 18114 { 18115 asset.state = LOADED; 18116 } 18117 18118 var existing = assets[asset.name]; 18119 if (existing && existing.url === asset.url) 18120 { 18121 return existing; 18122 } 18123 18124 assets[asset.name] = asset; 18125 return asset; 18126 } 18127 18128 function normalizeUrl(url) 18129 { 18130 if (!BX.type.isNotEmptyString(url)) 18131 { 18132 return ""; 18133 } 18134 18135 url = BX.getJSPath(url); 18136 url = url.replace(/\?[0-9]*$/, ""); 18137 18138 return url; 18139 } 18140 18141 function normalizeMinUrl(url) 18142 { 18143 if (!BX.type.isNotEmptyString(url)) 18144 { 18145 return ""; 18146 } 18147 18148 var minPos = url.indexOf(".min"); 18149 return minPos >= 0 ? url.substr(0, minPos) + url.substr(minPos + 4) : url; 18150 } 18151 18152 function isCssLoaded(fileSrc) 18153 { 18154 initCssList(); 18155 18156 fileSrc = normalizeUrl(fileSrc); 18157 var fileSrcMin = normalizeMinUrl(fileSrc); 18158 18159 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, cssList)) || BX.util.in_array(fileSrc, cssList); 18160 } 18161 18162 function initCssList() 18163 { 18164 if(!cssInit) 18165 { 18166 var linksCol = document.getElementsByTagName('link'); 18167 18168 if(!!linksCol && linksCol.length > 0) 18169 { 18170 for(var i = 0; i < linksCol.length; i++) 18171 { 18172 var href = linksCol[i].getAttribute('href'); 18173 if (BX.type.isNotEmptyString(href)) 18174 { 18175 href = normalizeMinUrl(normalizeUrl(href)); 18176 cssList.push(href); 18177 } 18178 } 18179 } 18180 cssInit = true; 18181 } 18182 } 18183 18184 function getTemplateLink(head) 18185 { 18186 var findLink = function(tag) 18187 { 18188 var links = head.getElementsByTagName(tag); 18189 for (var i = 0, length = links.length; i < length; i++) 18190 { 18191 var templateStyle = links[i].getAttribute("data-template-style"); 18192 if (BX.type.isNotEmptyString(templateStyle) && templateStyle == "true") 18193 { 18194 return links[i]; 18195 } 18196 } 18197 18198 return null; 18199 }; 18200 18201 var link = findLink("link"); 18202 if (link === null) 18203 { 18204 link = findLink("style"); 18205 } 18206 18207 return link; 18208 } 18209 18210 function isScriptLoaded(fileSrc) 18211 { 18212 initJsList(); 18213 18214 fileSrc = normalizeUrl(fileSrc); 18215 var fileSrcMin = normalizeMinUrl(fileSrc); 18216 18217 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, jsList)) || BX.util.in_array(fileSrc, jsList); 18218 } 18219 18220 function initJsList() 18221 { 18222 if(!jsInit) 18223 { 18224 var scriptCol = document.getElementsByTagName('script'); 18225 18226 if(!!scriptCol && scriptCol.length > 0) 18227 { 18228 for(var i=0; i<scriptCol.length; i++) 18229 { 18230 var src = scriptCol[i].getAttribute('src'); 18231 18232 if (BX.type.isNotEmptyString(src)) 18233 { 18234 src = normalizeMinUrl(normalizeUrl(src)); 18235 jsList.push(src); 18236 } 18237 } 18238 } 18239 jsInit = true; 18240 } 18241 } 18242 18243 function reloadInternal(back_url, bAddClearCache) 18244 { 18245 if (back_url === true) 18246 { 18247 bAddClearCache = true; 18248 back_url = null; 18249 } 18250 18251 var topWindow = (function() { 18252 if (BX.PageObject && BX.PageObject.getRootWindow) 18253 { 18254 return BX.PageObject.getRootWindow(); 18255 } 18256 18257 return window.top; 18258 })(); 18259 var new_href = back_url || topWindow.location.href; 18260 18261 var hashpos = new_href.indexOf('#'), hash = ''; 18262 18263 if (hashpos != -1) 18264 { 18265 hash = new_href.substr(hashpos); 18266 new_href = new_href.substr(0, hashpos); 18267 } 18268 18269 if (bAddClearCache && new_href.indexOf('clear_cache=Y') < 0) 18270 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + 'clear_cache=Y'; 18271 18272 if (hash) 18273 { 18274 // hack for clearing cache in ajax mode components with history emulation 18275 if (bAddClearCache && (hash.substr(0, 5) == 'view/' || hash.substr(0, 6) == '#view/') && hash.indexOf('clear_cache%3DY') < 0) 18276 hash += (hash.indexOf('%3F') == -1 ? '%3F' : '%26') + 'clear_cache%3DY'; 18277 18278 new_href = new_href.replace(/(\?|\&)_r=[\d]*/, ''); 18279 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + '_r='+Math.round(Math.random()*10000) + hash; 18280 } 18281 18282 topWindow.location.href = new_href; 18283 } 18284 18285 BX.reload = function(back_url, bAddClearCache) 18286 { 18287 if (window !== window.top) 18288 { 18289 BX.Runtime 18290 .loadExtension('main.pageobject') 18291 .then(function() { 18292 reloadInternal(back_url, bAddClearCache); 18293 }); 18294 } 18295 else 18296 { 18297 reloadInternal(back_url, bAddClearCache); 18298 } 18299 }; 18300 18301 BX.clearCache = function() 18302 { 18303 BX.showWait(); 18304 BX.reload(true); 18305 }; 18306 18307 BX.template = function(tpl, callback, bKillTpl) 18308 { 18309 BX.ready(function() { 18310 _processTpl(BX(tpl), callback, bKillTpl); 18311 }); 18312 }; 18313 18314 BX.isAmPmMode = function(returnConst) 18315 { 18316 if (returnConst === true) 18317 { 18318 return BX.message.AMPM_MODE; 18319 } 18320 return BX.message.AMPM_MODE !== false; 18321 }; 18322 18323 BX.formatDate = function(date, format) 18324 { 18325 date = date || new Date(); 18326 18327 var bTime = date.getHours() || date.getMinutes() || date.getSeconds(), 18328 str = !!format 18329 ? format : 18330 (bTime ? BX.message('FORMAT_DATETIME') : BX.message('FORMAT_DATE') 18331 ); 18332 18333 return str.replace(/YYYY/ig, date.getFullYear()) 18334 .replace(/MMMM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 18335 .replace(/MM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 18336 .replace(/DD/ig, BX.util.str_pad_left(date.getDate().toString(), 2, '0')) 18337 .replace(/HH/ig, BX.util.str_pad_left(date.getHours().toString(), 2, '0')) 18338 .replace(/MI/ig, BX.util.str_pad_left(date.getMinutes().toString(), 2, '0')) 18339 .replace(/SS/ig, BX.util.str_pad_left(date.getSeconds().toString(), 2, '0')); 18340 }; 18341 BX.formatName = function(user, template, login) 18342 { 18343 user = user || {}; 18344 template = (template || ''); 18345 var replacement = { 18346 TITLE : (user["TITLE"] || ''), 18347 NAME : (user["NAME"] || ''),
18348 LAST_NAME : (user["LAST_NAME"] || ''), 18349 SECOND_NAME : (user["SECOND_NAME"] || ''), 18350 LOGIN : (user["LOGIN"] || ''), 18351 NAME_SHORT : user["NAME"] ? user["NAME"].substr(0, 1) + '.' : '', 18352 LAST_NAME_SHORT : user["LAST_NAME"] ? user["LAST_NAME"].substr(0, 1) + '.' : '', 18353 SECOND_NAME_SHORT : user["SECOND_NAME"] ? user["SECOND_NAME"].substr(0, 1) + '.' : '', 18354 EMAIL : (user["EMAIL"] || ''), 18355 ID : (user["ID"] || ''), 18356 NOBR : "", 18357 '/NOBR' : "" 18358 }, result = template; 18359 for (var ii in replacement) 18360 { 18361 if (replacement.hasOwnProperty(ii)) 18362 { 18363 result = result.replace("#" + ii+ "#", replacement[ii]) 18364 } 18365 } 18366 result = result.replace(/([\s]+)/gi, " ").trim(); 18367 if (result == "") 18368 { 18369 result = (login == "Y" ? replacement["LOGIN"] : ""); 18370 result = (result == "" ? "Noname" : result); 18371 } 18372 return result; 18373 }; 18374 18375 BX.getNumMonth = function(month) 18376 { 18377 var wordMonthCut = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; 18378 var wordMonth = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']; 18379 18380 var q = month.toUpperCase(); 18381 for (i = 1; i <= 12; i++) 18382 { 18383 if (q == BX.message('MON_'+i).toUpperCase() || q == BX.message('MONTH_'+i).toUpperCase() || q == wordMonthCut[i-1].toUpperCase() || q == wordMonth[i-1].toUpperCase()) 18384 { 18385 return i; 18386 } 18387 } 18388 return month; 18389 }; 18390 18391 BX.parseDate = function(str, bUTC, formatDate, formatDatetime) 18392 { 18393 if (BX.type.isNotEmptyString(str)) 18394 { 18395 if (!formatDate) 18396 formatDate = BX.message('FORMAT_DATE'); 18397 if (!formatDatetime) 18398 formatDatetime = BX.message('FORMAT_DATETIME'); 18399 18400 var regMonths = ''; 18401 for (i = 1; i <= 12; i++) 18402 { 18403 regMonths = regMonths + '|' + BX.message('MON_'+i); 18404 } 18405
18406 var expr = new RegExp('([0-9]+|[a-z]+' + regMonths + ')', 'ig'); 18407 var aDate = str.match(expr), 18408 aFormat = formatDate.match(/(DD|MI|MMMM|MM|M|YYYY)/ig), 18409 i, cnt, 18410 aDateArgs=[], aFormatArgs=[], 18411 aResult={}; 18412 18413 if (!aDate) 18414 return null; 18415 18416 if(aDate.length > aFormat.length) 18417 { 18418 aFormat = formatDatetime.match(/(DD|MI|MMMM|MM|M|YYYY|HH|H|SS|TT|T|GG|G)/ig); 18419 } 18420 18421 for(i = 0, cnt = aDate.length; i < cnt; i++) 18422 { 18423 if(BX.util.trim(aDate[i]) != '') 18424 { 18425 aDateArgs[aDateArgs.length] = aDate[i]; 18426 } 18427 } 18428 18429 for(i = 0, cnt = aFormat.length; i < cnt; i++) 18430 { 18431 if(BX.util.trim(aFormat[i]) != '') 18432 { 18433 aFormatArgs[aFormatArgs.length] = aFormat[i]; 18434 } 18435 } 18436 18437 18438 var m = BX.util.array_search('MMMM', aFormatArgs); 18439 if (m > 0) 18440 { 18441 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 18442 aFormatArgs[m] = "MM"; 18443 } 18444 else 18445 { 18446 m = BX.util.array_search('M', aFormatArgs); 18447 if (m > 0) 18448 { 18449 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 18450 aFormatArgs[m] = "MM"; 18451 } 18452 } 18453 18454 for(i = 0, cnt = aFormatArgs.length; i < cnt; i++) 18455 { 18456 var k = aFormatArgs[i].toUpperCase(); 18457 aResult[k] = k == 'T' || k == 'TT' ? aDateArgs[i] : parseInt(aDateArgs[i], 10); 18458 } 18459 18460 if(aResult['DD'] > 0 && aResult['MM'] > 0 && aResult['YYYY'] > 0) 18461 { 18462 var d = new Date(); 18463 18464 if(bUTC) 18465 { 18466 d.setUTCDate(1); 18467 d.setUTCFullYear(aResult['YYYY']); 18468 d.setUTCMonth(aResult['MM'] - 1); 18469 d.setUTCDate(aResult['DD']); 18470 d.setUTCHours(0, 0, 0, 0); 18471 } 18472 else 18473 { 18474 d.setDate(1); 18475 d.setFullYear(aResult['YYYY']); 18476 d.setMonth(aResult['MM'] - 1); 18477 d.setDate(aResult['DD']); 18478 d.setHours(0, 0, 0, 0); 18479 } 18480 18481 if( 18482 (!isNaN(aResult['HH']) || !isNaN(aResult['GG']) || !isNaN(aResult['H']) || !isNaN(aResult['G'])) 18483 && !isNaN(aResult['MI']) 18484 ) 18485 { 18486 if (!isNaN(aResult['H']) || !isNaN(aResult['G'])) 18487 { 18488 var bPM = (aResult['T']||aResult['TT']||'am').toUpperCase()=='PM'; 18489 var h = parseInt(aResult['H']||aResult['G']||0, 10); 18490 if(bPM) 18491 { 18492 aResult['HH'] = h + (h == 12 ? 0 : 12); 18493 } 18494 else 18495 { 18496 aResult['HH'] = h < 12 ? h : 0; 18497 } 18498 } 18499 else 18500 { 18501 aResult['HH'] = parseInt(aResult['HH']||aResult['GG']||0, 10); 18502 } 18503 18504 if (isNaN(aResult['SS'])) 18505 aResult['SS'] = 0; 18506 18507 if(bUTC) 18508 { 18509 d.setUTCHours(aResult['HH'], aResult['MI'], aResult['SS']); 18510 } 18511 else 18512 { 18513 d.setHours(aResult['HH'], aResult['MI'], aResult['SS']); 18514 } 18515 } 18516 18517 return d; 18518 } 18519 } 18520 18521 return null; 18522 }; 18523 18524 BX.selectUtils = 18525 { 18526 addNewOption: function(oSelect, opt_value, opt_name, do_sort, check_unique) 18527 { 18528 oSelect = BX(oSelect); 18529 if(oSelect) 18530 { 18531 var n = oSelect.length; 18532 if(check_unique !== false) 18533 { 18534 for(var i=0;i<n;i++) 18535 { 18536 if(oSelect[i].value==opt_value) 18537 { 18538 return; 18539 } 18540 } 18541 } 18542 18543 oSelect.options[n] = new Option(opt_name, opt_value, false, false); 18544 } 18545 18546 if(do_sort === true) 18547 { 18548 this.sortSelect(oSelect); 18549 } 18550 }, 18551 18552 deleteOption: function(oSelect, opt_value) 18553 { 18554 oSelect = BX(oSelect); 18555 if(oSelect) 18556 { 18557 for(var i=0;i<oSelect.length;i++) 18558 { 18559 if(oSelect[i].value==opt_value) 18560 { 18561 oSelect.remove(i); 18562 break; 18563 } 18564 } 18565 } 18566 }, 18567 18568 deleteSelectedOptions: function(oSelect) 18569 { 18570 oSelect = BX(oSelect); 18571 if(oSelect) 18572 { 18573 var i=0; 18574 while(i<oSelect.length) 18575 { 18576 if(oSelect[i].selected) 18577 { 18578 oSelect[i].selected=false; 18579 oSelect.remove(i); 18580 } 18581 else 18582 { 18583 i++; 18584 } 18585 } 18586 } 18587 }, 18588 18589 deleteAllOptions: function(oSelect) 18590 { 18591 oSelect = BX(oSelect); 18592 if(oSelect) 18593 { 18594 for(var i=oSelect.length-1; i>=0; i--) 18595 { 18596 oSelect.remove(i); 18597 } 18598 } 18599 }, 18600 18601 optionCompare: function(record1, record2) 18602 { 18603 var value1 = record1.optText.toLowerCase(); 18604 var value2 = record2.optText.toLowerCase(); 18605 if (value1 > value2) return(1); 18606 if (value1 < value2) return(-1); 18607 return(0); 18608 }, 18609 18610 sortSelect: function(oSelect) 18611 { 18612 oSelect = BX(oSelect); 18613 if(oSelect) 18614 { 18615 var myOptions = []; 18616 var n = oSelect.options.length; 18617 var i; 18618 for (i=0;i<n;i++) 18619 { 18620 myOptions[i] = { 18621 optText:oSelect[i].text, 18622 optValue:oSelect[i].value 18623 }; 18624 } 18625 myOptions.sort(this.optionCompare); 18626 oSelect.length=0; 18627 n = myOptions.length; 18628 for(i=0;i<n;i++) 18629 { 18630 oSelect[i] = new Option(myOptions[i].optText, myOptions[i].optValue, false, false); 18631 } 18632 } 18633 }, 18634 18635 selectAllOptions: function(oSelect) 18636 { 18637 oSelect = BX(oSelect); 18638 if(oSelect) 18639 { 18640 var n = oSelect.length; 18641 for(var i=0;i<n;i++) 18642 { 18643 oSelect[i].selected=true; 18644 } 18645 } 18646 }, 18647 18648 selectOption: function(oSelect, opt_value) 18649 { 18650 oSelect = BX(oSelect); 18651 if(oSelect) 18652 { 18653 var n = oSelect.length; 18654 for(var i=0;i<n;i++) 18655 { 18656 oSelect[i].selected = (oSelect[i].value == opt_value); 18657 } 18658 } 18659 }, 18660 18661 addSelectedOptions: function(oSelect, to_select_id, check_unique, do_sort) 18662 { 18663 oSelect = BX(oSelect); 18664 if(!oSelect) 18665 return; 18666 var n = oSelect.length; 18667 for(var i=0; i<n; i++) 18668 if(oSelect[i].selected) 18669 this.addNewOption(to_select_id, oSelect[i].value, oSelect[i].text, do_sort, check_unique); 18670 }, 18671 18672 moveOptionsUp: function(oSelect) 18673 { 18674 oSelect = BX(oSelect); 18675 if(!oSelect) 18676 return; 18677 var n = oSelect.length; 18678 for(var i=0; i<n; i++) 18679 { 18680 if(oSelect[i].selected && i>0 && oSelect[i-1].selected == false) 18681 { 18682 var option = new Option(oSelect[i].text, oSelect[i].value); 18683 oSelect[i] = new Option(oSelect[i-1].text, oSelect[i-1].value); 18684 oSelect[i].selected = false;
18685 oSelect[i-1] = option; 18686 oSelect[i-1].selected = true; 18687 } 18688 } 18689 }, 18690 18691 moveOptionsDown: function(oSelect) 18692 { 18693 oSelect = BX(oSelect); 18694 if(!oSelect) 18695 return; 18696 var n = oSelect.length; 18697 for(var i=n-1; i>=0; i--) 18698 { 18699 if(oSelect[i].selected && i<n-1 && oSelect[i+1].selected == false) 18700 { 18701 var option = new Option(oSelect[i].text, oSelect[i].value); 18702 oSelect[i] = new Option(oSelect[i+1].text, oSelect[i+1].value); 18703 oSelect[i].selected = false; 18704 oSelect[i+1] = option; 18705 oSelect[i+1].selected = true; 18706 } 18707 } 18708 } 18709 }; 18710 18711 BX.getEventTarget = function(e) 18712 { 18713 if(e.target) 18714 { 18715 return e.target; 18716 } 18717 else if(e.srcElement) 18718 { 18719 return e.srcElement; 18720 } 18721 return null; 18722 }; 18723 18724 /******* HINT ***************/ 18725// if function has 2 params - the 2nd one is hint html. otherwise hint_html is third and hint_title - 2nd; 18726// '<div onmouseover="BX.hint(this, 'This is <b>Hint</b>')"'>; 18727// BX.hint(el, 'This is <b>Hint</b>') - this won't work, use constructor 18728 BX.hint = function(el, hint_title, hint_html, hint_id) 18729 { 18730 if (null == hint_html) 18731 { 18732 hint_html = hint_title; 18733 hint_title = ''; 18734 } 18735 18736 if (null == el.BXHINT) 18737 { 18738 el.BXHINT = new BX.CHint({ 18739 parent: el, hint: hint_html, title: hint_title, id: hint_id 18740 }); 18741 el.BXHINT.Show(); 18742 } 18743 }; 18744 18745 BX.hint_replace = function(el, hint_title, hint_html) 18746 { 18747 if (null == hint_html) 18748 { 18749 hint_html = hint_title; 18750 hint_title = ''; 18751 } 18752 18753 if (!el || !el.parentNode || !hint_html) 18754 return null; 18755 18756 var obHint = new BX.CHint({ 18757 hint: hint_html, 18758 title: hint_title 18759 }); 18760 18761 obHint.CreateParent(); 18762 18763 el.parentNode.insertBefore(obHint.PARENT, el); 18764 el.parentNode.removeChild(el); 18765 18766 obHint.PARENT.style.marginLeft = '5px'; 18767 18768 return el; 18769 }; 18770 18771 BX.CHint = function(params) 18772 { 18773 if (BX.CHint.cssLoaded === false) 18774 { 18775 BX.load(['/bitrix/js/main/core/css/core_hint.css']); 18776 BX.CHint.cssLoaded = true; 18777 } 18778 18779 this.PARENT = BX(params.parent); 18780 18781 this.HINT = params.hint; 18782 this.HINT_TITLE = params.title; 18783 18784 this.PARAMS = {}; 18785 for (var i in this.defaultSettings) 18786 { 18787 if (null == params[i]) 18788 this.PARAMS[i] = this.defaultSettings[i]; 18789 else 18790 this.PARAMS[i] = params[i]; 18791 } 18792 18793 if (null != params.id) 18794 this.ID = params.id; 18795 18796 this.timer = null; 18797 this.bInited = false; 18798 this.msover = true; 18799 18800 if (this.PARAMS.showOnce) 18801 { 18802 this.__show(); 18803 this.msover = false; 18804 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 18805 } 18806 else if (this.PARENT) 18807 { 18808 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 18809 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 18810 } 18811 }; 18812 18813 BX.CHint.cssLoaded = false; 18814 18815 BX.CHint.openHints = new Set(); 18816 18817 BX.CHint.globalDisabled = false; 18818 18819 BX.CHint.handleMenuOpen = function() { 18820 BX.CHint.globalDisabled = true; 18821 18822 BX.CHint.openHints.forEach(function(hint) { 18823 hint.__hide_immediately(); 18824 }); 18825 }; 18826 18827 BX.CHint.handleMenuClose = function() { 18828 BX.CHint.globalDisabled = false; 18829 }; 18830 18831 BX.addCustomEvent('onMenuOpen', BX.CHint.handleMenuOpen); 18832 BX.addCustomEvent('onMenuClose', BX.CHint.handleMenuClose); 18833 18834 BX.CHint.prototype.defaultSettings = { 18835 show_timeout: 1000, 18836 hide_timeout: 500, 18837 dx: 2, 18838 showOnce: false, 18839 preventHide: true, 18840 min_width: 250 18841 }; 18842 18843 BX.CHint.prototype.CreateParent = function(element, params) 18844 { 18845 if (this.PARENT) 18846 { 18847 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 18848 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 18849 } 18850 18851 if (!params) params = {}; 18852 var type = 'icon'; 18853 18854 if (params.type && (params.type == "link" || params.type == "icon")) 18855 type = params.type; 18856 18857 if (element) 18858 type = "element"; 18859 18860 if (type == "icon") 18861 { 18862 element = BX.create('IMG', { 18863 props: { 18864 src: params.iconSrc 18865 ? params.iconSrc 18866 : "/bitrix/js/main/core/images/hint.gif" 18867 } 18868 }); 18869 } 18870 else if (type == "link") 18871 { 18872 element = BX.create("A", { 18873 props: {href: 'javascript:void(0)'}, 18874 html: '[?]' 18875 }); 18876 } 18877 18878 this.PARENT = element; 18879 18880 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 18881 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 18882 18883 return this.PARENT; 18884 }; 18885 18886 BX.CHint.prototype.Show = function() 18887 { 18888 this.msover = true; 18889 18890 if (null != this.timer) 18891 clearTimeout(this.timer); 18892 18893 this.timer = setTimeout(BX.proxy(this.__show, this), this.PARAMS.show_timeout); 18894 }; 18895 18896 BX.CHint.prototype.Hide = function() 18897 { 18898 this.msover = false;
18899 18900 if (null != this.timer) 18901 clearTimeout(this.timer); 18902 18903 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 18904 }; 18905 18906 BX.CHint.prototype.__show = function() 18907 { 18908 if (!this.msover || this.disabled || BX.CHint.globalDisabled) return; 18909 if (!this.bInited) this.Init(); 18910 18911 if (this.prepareAdjustPos()) 18912 { 18913 this.DIV.style.display = 'block'; 18914 BX.ZIndexManager.bringToFront(this.DIV); 18915 18916 this.adjustPos(); 18917 18918 BX.CHint.openHints.add(this); 18919 18920 BX.bind(window, 'scroll', BX.proxy(this.__onscroll, this)); 18921 18922 if (this.PARAMS.showOnce) 18923 { 18924 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 18925 } 18926 } 18927 }; 18928 18929 BX.CHint.prototype.__onscroll = function() 18930 { 18931 if (!BX.admin || !BX.admin.panel || !BX.admin.panel.isFixed()) return; 18932 18933 if (this.scrollTimer) clearTimeout(this.scrollTimer); 18934 18935 this.DIV.style.display = 'none'; 18936 this.scrollTimer = setTimeout(BX.proxy(this.Reopen, this), this.PARAMS.show_timeout); 18937 }; 18938 18939 BX.CHint.prototype.Reopen = function() 18940 { 18941 if (null != this.timer) clearTimeout(this.timer); 18942 this.timer = setTimeout(BX.proxy(this.__show, this), 50); 18943 }; 18944 18945 BX.CHint.prototype.__hide = function() 18946 { 18947 if (this.msover) return; 18948 if (!this.bInited) return; 18949 18950 BX.unbind(window, 'scroll', BX.proxy(this.Reopen, this)); 18951 18952 BX.CHint.openHints.delete(this); 18953 18954 if (this.PARAMS.showOnce) 18955 { 18956 this.Destroy(); 18957 } 18958 else 18959 { 18960 this.DIV.style.display = 'none'; 18961 } 18962 }; 18963 18964 BX.CHint.prototype.__hide_immediately = function() 18965 { 18966 this.msover = false; 18967 this.__hide(); 18968 }; 18969 18970 BX.CHint.prototype.Init = function() 18971 { 18972 this.DIV = document.body.appendChild(BX.create('DIV', { 18973 props: {className: 'bx-panel-tooltip'}, 18974 style: { 18975 display: 'none', 18976 position: 'absolute', 18977 visibility: 'hidden' 18978 }, 18979 children: [ 18980 (this.CONTENT = BX.create('DIV', { 18981 props: {className: 'bx-panel-tooltip-content'}, 18982 children: [ 18983 BX.create('DIV', { 18984 props: {className: 'bx-panel-tooltip-underlay'}, 18985 children: [ 18986 BX.create('DIV', {props: {className: 'bx-panel-tooltip-underlay-bg'}}) 18987 ] 18988 }) 18989 ] 18990 })) 18991 ] 18992 })); 18993 18994 BX.ZIndexManager.register(this.DIV); 18995 18996 if (this.ID) 18997 { 18998 this.CONTENT.insertBefore(BX.create('A', { 18999 attrs: {href: 'javascript:void(0)'}, 19000 props: {className: 'bx-panel-tooltip-close'}, 19001 events: {click: BX.delegate(this.Close, this)} 19002 }), this.CONTENT.firstChild); 19003 } 19004 19005 if (this.HINT_TITLE) 19006 { 19007 this.CONTENT.appendChild( 19008 BX.create('DIV', { 19009 props: {className: 'bx-panel-tooltip-title'}, 19010 text: this.HINT_TITLE 19011 }) 19012 ); 19013 } 19014 19015 if (this.HINT) 19016 { 19017 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 19018 } 19019 19020 if (this.PARAMS.preventHide) 19021 { 19022 BX.bind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 19023 BX.bind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 19024 } 19025 19026 this.bInited = true; 19027 }; 19028 19029 BX.CHint.prototype.setContent = function(content) 19030 { 19031 this.HINT = content; 19032 19033 if (this.CONTENT_TEXT) 19034 this.CONTENT_TEXT.innerHTML = this.HINT; 19035 else 19036 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 19037 }; 19038 19039 BX.CHint.prototype.prepareAdjustPos = function() 19040 { 19041 this._wnd = {scrollPos: BX.GetWindowScrollPos(),scrollSize:BX.GetWindowScrollSize()}; 19042 return BX.style(this.PARENT, 'display') != 'none'; 19043 }; 19044 19045 BX.CHint.prototype.getAdjustPos = function() 19046 { 19047 var res = {}, pos = BX.pos(this.PARENT), min_top = 0; 19048 19049 res.top = pos.bottom + this.PARAMS.dx; 19050 19051 if (BX.admin && BX.admin.panel.DIV) 19052 { 19053 min_top = BX.admin.panel.DIV.offsetHeight + this.PARAMS.dx; 19054 19055 if (BX.admin.panel.isFixed()) 19056 { 19057 min_top += this._wnd.scrollPos.scrollTop; 19058 } 19059 } 19060 19061 if (res.top < min_top) 19062 res.top = min_top; 19063 else 19064 { 19065 if (res.top + this.DIV.offsetHeight > this._wnd.scrollSize.scrollHeight) 19066 res.top = pos.top - this.PARAMS.dx - this.DIV.offsetHeight; 19067 } 19068 19069 res.left = pos.left; 19070 if (pos.left < this.PARAMS.dx) 19071 pos.left = this.PARAMS.dx; 19072 else 19073 { 19074 var floatWidth = this.DIV.offsetWidth; 19075 19076 var max_left = this._wnd.scrollSize.scrollWidth - floatWidth - this.PARAMS.dx; 19077 19078 if (res.left > max_left) 19079 res.left = max_left; 19080 } 19081 19082 return res; 19083 }; 19084 19085 BX.CHint.prototype.adjustWidth = function() 19086 { 19087 if (this.bWidthAdjusted) return; 19088 19089 var w = this.DIV.offsetWidth, h = this.DIV.offsetHeight; 19090 19091 if (w > this.PARAMS.min_width) 19092 w = Math.round(Math.sqrt(1.618*w*h)); 19093 19094 if (w < this.PARAMS.min_width) 19095 w = this.PARAMS.min_width; 19096 19097 this.DIV.style.width = w + "px"; 19098 19099 if (this._adjustWidthInt) 19100 clearInterval(this._adjustWidthInt); 19101 this._adjustWidthInt = setInterval(BX.delegate(this._adjustWidthInterval, this), 5); 19102 19103 this.bWidthAdjusted = true; 19104 }; 19105 19106 BX.CHint.prototype._adjustWidthInterval = function() 19107 { 19108 if (!this.DIV || this.DIV.style.display == 'none') 19109 clearInterval(this._adjustWidthInt); 19110 19111 var
19112 dW = 20, 19113 maxWidth = 1500, 19114 w = this.DIV.offsetWidth, 19115 w1 = this.CONTENT_TEXT.offsetWidth; 19116 19117 if (w > 0 && w1 > 0 && w - w1 < dW && w < maxWidth) 19118 { 19119 this.DIV.style.width = (w + dW) + "px"; 19120 return; 19121 } 19122 19123 clearInterval(this._adjustWidthInt); 19124 }; 19125 19126 BX.CHint.prototype.adjustPos = function() 19127 { 19128 this.adjustWidth(); 19129 19130 var pos = this.getAdjustPos(); 19131 19132 this.DIV.style.top = pos.top + 'px'; 19133 this.DIV.style.left = pos.left + 'px'; 19134 }; 19135 19136 BX.CHint.prototype.Close = function() 19137 { 19138 if (this.ID && BX.WindowManager) 19139 BX.WindowManager.saveWindowOptions(this.ID, {display: 'off'}); 19140 this.__hide_immediately(); 19141 this.Destroy(); 19142 }; 19143 19144 BX.CHint.prototype.Destroy = function() 19145 { 19146 if (this.PARENT) 19147 { 19148 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 19149 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 19150 } 19151 19152 if (this.DIV) 19153 { 19154 BX.unbind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 19155 BX.unbind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 19156 19157 BX.ZIndexManager.unregister(this.DIV); 19158 19159 BX.cleanNode(this.DIV, true); 19160 } 19161 }; 19162 19163 BX.CHint.prototype.enable = function(){this.disabled = false;}; 19164 BX.CHint.prototype.disable = function(){this.__hide_immediately(); this.disabled = true;}; 19165 19166 19167 function _adjustWait() 19168 { 19169 if (!this.bxmsg) return; 19170 19171 var arContainerPos = BX.pos(this), 19172 div_top = arContainerPos.top; 19173 19174 if (div_top < BX.GetDocElement().scrollTop) 19175 div_top = BX.GetDocElement().scrollTop + 5; 19176 19177 this.bxmsg.style.top = (div_top + 5) + 'px'; 19178 19179 if (this == BX.GetDocElement()) 19180 { 19181 this.bxmsg.style.right = '5px'; 19182 } 19183 else 19184 { 19185 this.bxmsg.style.left = (arContainerPos.right - this.bxmsg.offsetWidth - 5) + 'px'; 19186 } 19187 } 19188 19189 function _processTpl(tplNode, cb, bKillTpl) 19190 { 19191 if (tplNode) 19192 { 19193 if (bKillTpl) 19194 tplNode.parentNode.removeChild(tplNode); 19195 19196 var res = {}, nodes = BX.findChildren(tplNode, {attribute: 'data-role'}, true); 19197 19198 for (var i = 0, l = nodes.length; i < l; i++) 19199 { 19200 res[nodes[i].getAttribute('data-role')] = nodes[i]; 19201 } 19202 19203 cb.apply(tplNode, [res]); 19204 } 19205 } 19206 19207 function _checkNode(obj, params) 19208 { 19209 params = params || {}; 19210 19211 if (BX.type.isFunction(params)) 19212 return params.call(window, obj); 19213 19214 if (!params.allowTextNodes && !BX.type.isElementNode(obj)) 19215 return false; 19216 var i,j,len; 19217 for (i in params) 19218 { 19219 if(params.hasOwnProperty(i)) 19220 { 19221 switch(i) 19222 { 19223 case 'tag': 19224 case 'tagName': 19225 if (BX.type.isString(params[i])) 19226 { 19227 if (obj.tagName.toUpperCase() != params[i].toUpperCase()) 19228 return false; 19229 } 19230 else if (params[i] instanceof RegExp) 19231 { 19232 if (!params[i].test(obj.tagName)) 19233 return false; 19234 } 19235 break; 19236 19237 case 'class': 19238 case 'className': 19239 if (BX.type.isString(params[i])) 19240 { 19241 if (!BX.hasClass(obj, params[i])) 19242 return false; 19243 } 19244 else if (params[i] instanceof RegExp) 19245 { 19246 if (!BX.type.isString(obj.className) || !params[i].test(obj.className)) 19247 return false; 19248 } 19249 break; 19250 19251 case 'attr': 19252 case 'attrs': 19253 case 'attribute': 19254 if (BX.type.isString(params[i])) 19255 { 19256 if (!obj.getAttribute(params[i])) 19257 return false; 19258 } 19259 else if (BX.type.isArray(params[i])) 19260 { 19261 for (j = 0, len = params[i].length; j < len; j++) 19262 { 19263 if (params[i] && !obj.getAttribute(params[i])) 19264 return false; 19265 } 19266 } 19267 else 19268 { 19269 for (j in params[i]) 19270 { 19271 if(params[i].hasOwnProperty(j)) 19272 { 19273 var q = obj.getAttribute(j); 19274 if (params[i][j] instanceof RegExp) 19275 { 19276 if (!BX.type.isString(q) || !params[i][j].test(q)) 19277 { 19278 return false; 19279 } 19280 } 19281 else 19282 { 19283 if (q != '' + params[i][j]) 19284 { 19285 return false; 19286 } 19287 } 19288 } 19289 } 19290 } 19291 break; 19292 19293 case 'property': 19294 case 'props': 19295 if (BX.type.isString(params[i])) 19296 { 19297 if (!obj[params[i]]) 19298 return false; 19299 } 19300 else if (BX.type.isArray(params[i])) 19301 { 19302 for (j = 0, len = params[i].length; j < len; j++) 19303 { 19304 if (params[i] && !obj[params[i]]) 19305 return false;
19306 } 19307 } 19308 else 19309 { 19310 for (j in params[i]) 19311 { 19312 if (BX.type.isString(params[i][j])) 19313 { 19314 if (obj[j] != params[i][j]) 19315 return false; 19316 } 19317 else if (params[i][j] instanceof RegExp) 19318 { 19319 if (!BX.type.isString(obj[j]) || !params[i][j].test(obj[j])) 19320 return false; 19321 } 19322 } 19323 } 19324 break; 19325 19326 case 'callback': 19327 return params[i](obj); 19328 } 19329 } 19330 } 19331 19332 return true; 19333 } 19334 19335 /* garbage collector */ 19336 function Trash() 19337 { 19338 var i,len; 19339 19340 for (i = 0, len = garbageCollectors.length; i<len; i++) 19341 { 19342 try { 19343 garbageCollectors[i].callback.apply(garbageCollectors[i].context || window); 19344 delete garbageCollectors[i]; 19345 garbageCollectors[i] = null; 19346 } catch (e) {} 19347 } 19348 } 19349 19350 if(window.attachEvent) // IE 19351 window.attachEvent("onunload", Trash); 19352 else if(window.addEventListener) // Gecko / W3C 19353 window.addEventListener('unload', Trash, false); 19354 else 19355 window.onunload = Trash; 19356 /* \garbage collector */ 19357 19358// set empty ready handler 19359 BX(BX.DoNothing); 19360 window.BX = BX; 19361 19362 BX.browser.addGlobalClass(); 19363 19364 /* data storage */ 19365 BX.data = function(node, key, value) 19366 { 19367 if(typeof node == 'undefined') 19368 return undefined; 19369 19370 if(typeof key == 'undefined') 19371 return undefined; 19372 19373 if(typeof value != 'undefined') 19374 { 19375 // write to manager 19376 dataStorage.set(node, key, value); 19377 } 19378 else 19379 { 19380 var data; 19381 19382 // from manager 19383 if((data = dataStorage.get(node, key)) != undefined) 19384 { 19385 return data; 19386 } 19387 else 19388 { 19389 // from attribute data-* 19390 if('getAttribute' in node) 19391 { 19392 data = node.getAttribute('data-'+key.toString()); 19393 if(data === null) 19394 { 19395 return undefined; 19396 } 19397 return data; 19398 } 19399 } 19400 19401 return undefined; 19402 } 19403 }; 19404 19405 BX.DataStorage = function() 19406 { 19407 19408 this.keyOffset = 1; 19409 this.data = {}; 19410 this.uniqueTag = 'BX-'+Math.random(); 19411 19412 this.resolve = function(owner, create){ 19413 if(typeof owner[this.uniqueTag] == 'undefined') 19414 if(create) 19415 { 19416 try 19417 { 19418 Object.defineProperty(owner, this.uniqueTag, { 19419 value: this.keyOffset++ 19420 }); 19421 } 19422 catch(e) 19423 { 19424 owner[this.uniqueTag] = this.keyOffset++; 19425 } 19426 } 19427 else 19428 return undefined; 19429 19430 return owner[this.uniqueTag]; 19431 }; 19432 this.get = function(owner, key){ 19433 if((owner != document && !BX.type.isElementNode(owner)) || typeof key == 'undefined') 19434 return undefined; 19435 19436 owner = this.resolve(owner, false); 19437 19438 if(typeof owner == 'undefined' || typeof this.data[owner] == 'undefined') 19439 return undefined; 19440 19441 return this.data[owner][key]; 19442 }; 19443 this.set = function(owner, key, value){ 19444 19445 if((owner != document && !BX.type.isElementNode(owner)) || typeof value == 'undefined') 19446 return; 19447 19448 var o = this.resolve(owner, true); 19449 19450 if(typeof this.data[o] == 'undefined') 19451 this.data[o] = {}; 19452 19453 this.data[o][key] = value; 19454 }; 19455 }; 19456 19457// some internal variables for new logic 19458 var dataStorage = new BX.DataStorage(); // manager which BX.data() uses to keep data 19459})(window.BX); 19460 19461;(function(window) 19462{ 19463 /****************** ATTENTION ******************************* 19464 * Please do not use Bitrix CoreJS in this class. 19465 * This class can be called on page without Bitrix Framework 19466 *************************************************************/ 19467 19468 if (!window.BX) 19469 { 19470 window.BX = {}; 19471 } 19472 19473 var BX = window.BX; 19474 19475 BX.Promise = function(fn, ctx) // fn is future-reserved 19476 { 19477 this.state = null; 19478 this.value = null; 19479 this.reason = null; 19480 this.next = null; 19481 this.ctx = ctx || this; 19482 19483 this.onFulfilled = []; 19484 this.onRejected = []; 19485 }; 19486 BX.Promise.prototype.fulfill = function(value) 19487 { 19488 this.checkState(); 19489 19490 this.value = value; 19491 this.state = true; 19492 this.execute(); 19493 }; 19494 BX.Promise.prototype.reject = function(reason) 19495 { 19496 this.checkState(); 19497 19498 this.reason = reason; 19499 this.state = false; 19500 this.execute(); 19501 }; 19502 BX.Promise.prototype.then = function(onFulfilled, onRejected) 19503 { 19504 if(typeof (onFulfilled) == "function" || onFulfilled instanceof Function) 19505 { 19506 this.onFulfilled.push(onFulfilled); 19507 } 19508 if(typeof (onRejected) == "function" || onRejected instanceof Function) 19509 { 19510 this.onRejected.push(onRejected); 19511 } 19512 19513 if(this.next === null) 19514 { 19515 this.next = new BX.Promise(null, this.ctx); 19516 } 19517 19518 if(this.state !== null) // if promise was already resolved, execute immediately 19519 { 19520 this.execute(); 19521 } 19522 19523 return this.next; 19524 }; 19525 19526 BX.Promise.prototype.catch = function(onRejected) 19527 { 19528 if(typeof (onRejected) == "function" || onRejected instanceof Function) 19529 { 19530 this.onRejected.push(onRejected); 19531 } 19532 19533 if(this.next === null) 19534 { 19535 this.next = new BX.Promise(null, this.ctx); 19536 } 19537 19538 if(this.state !== null) // if promise was already resolved, execute immediately 19539 { 19540 this.execute(); 19541 } 19542 19543 return this.next; 19544 }; 19545 19546 BX.Promise.prototype.setAutoResolve = function(way, ms) 19547 { 19548 this.timer = setTimeout(function(){ 19549 if(this.state === null) 19550 { 19551 this[way ? 'fulfill' : 'reject'](); 19552 } 19553 }.bind(this), ms || 15); 19554 };
19555 BX.Promise.prototype.cancelAutoResolve = function() 19556 { 19557 clearTimeout(this.timer); 19558 }; 19559 /** 19560 * Resolve function. This function allows promise chaining, like ..then().then()... 19561 * Typical usage: 19562 * 19563 * var p = new Promise(); 19564 * 19565 * p.then(function(value){ 19566 * return someValue; // next promise in the chain will be fulfilled with someValue 19567 * }).then(function(value){ 19568 * 19569 * var p1 = new Promise(); 19570 * *** some async code here, that eventually resolves p1 *** 19571 * 19572 * return p1; // chain will resume when p1 resolved (fulfilled or rejected) 19573 * }).then(function(value){ 19574 * 19575 * // you can also do 19576 * var e = new Error(); 19577 * throw e; 19578 * // it will cause next promise to be rejected with e 19579 * 19580 * return someOtherValue; 19581 * }).then(function(value){ 19582 * ... 19583 * }, function(reason){ 19584 * // promise was rejected with reason 19585 * })...; 19586 * 19587 * p.fulfill('let`s start this chain'); 19588 * 19589 * @param x 19590 */ 19591 BX.Promise.prototype.resolve = function(x) 19592 { 19593 var this_ = this; 19594 19595 if(this === x) 19596 { 19597 this.reject(new TypeError('Promise cannot fulfill or reject itself')); // avoid recursion 19598 } 19599 // allow "pausing" promise chaining until promise x is fulfilled or rejected 19600 else if(x && x.toString() === "[object BX.Promise]") 19601 { 19602 x.then(function(value){ 19603 this_.fulfill(value); 19604 }, function(reason){ 19605 this_.reject(reason); 19606 }); 19607 } 19608 else // auto-fulfill this promise 19609 { 19610 this.fulfill(x); 19611 } 19612 }; 19613 19614 BX.Promise.prototype.toString = function() 19615 { 19616 return "[object BX.Promise]"; 19617 }; 19618 19619 BX.Promise.prototype.execute = function() 19620 { 19621 if(this.state === null) 19622 { 19623 //then() must not be called before BX.Promise resolve() happens 19624 return; 19625 } 19626 19627 var value = undefined; 19628 var reason = undefined; 19629 var x = undefined; 19630 var k; 19631 if(this.state === true) // promise was fulfill()-ed 19632 { 19633 if(this.onFulfilled.length) 19634 { 19635 try 19636 { 19637 for(k = 0; k < this.onFulfilled.length; k++) 19638 {
19639 x = this.onFulfilled[k].apply(this.ctx, [this.value]); 19640 if(typeof x != 'undefined') 19641 { 19642 value = x; 19643 } 19644 } 19645 } 19646 catch(e) 19647 { 19648 if('console' in window) 19649 { 19650 console.dir(e); 19651 } 19652 19653 if (typeof BX.debug !== 'undefined') 19654 { 19655 BX.debug(e); 19656 } 19657 19658 reason = e; // reject next 19659 } 19660 } 19661 else 19662 { 19663 value = this.value; // resolve next 19664 } 19665 } 19666 else if(this.state === false) // promise was reject()-ed 19667 { 19668 if(this.onRejected.length) 19669 { 19670 try 19671 { 19672 for(k = 0; k < this.onRejected.length; k++) 19673 { 19674 x = this.onRejected[k].apply(this.ctx, [this.reason]); 19675 if(typeof x != 'undefined') 19676 { 19677 value = x; 19678 } 19679 } 19680 } 19681 catch(e) 19682 { 19683 if('console' in window) 19684 { 19685 console.dir(e); 19686 } 19687 19688 if (typeof BX.debug !== 'undefined') 19689 { 19690 BX.debug(e); 19691 } 19692 19693 reason = e; // reject next 19694 } 19695 } 19696 else 19697 { 19698 reason = this.reason; // reject next 19699 } 19700 } 19701 19702 if(this.next !== null) 19703 { 19704 if(typeof reason != 'undefined') 19705 { 19706 this.next.reject(reason); 19707 } 19708 else if(typeof value != 'undefined') 19709 { 19710 this.next.resolve(value); 19711 } 19712 } 19713 }; 19714 BX.Promise.prototype.checkState = function() 19715 { 19716 if(this.state !== null) 19717 { 19718 throw new Error('You can not do fulfill() or reject() multiple times'); 19719 } 19720 }; 19721})(window); 19722 19723 19724 19725;(function(window){ 19726 19727if (window.BX.ajax) 19728 return; 19729 19730var 19731 BX = window.BX, 19732 19733 tempDefaultConfig = {}, 19734 defaultConfig = { 19735 method: 'GET', // request method: GET|POST 19736 dataType: 'html', // type of data loading: html|json|script 19737 timeout: 0, // request timeout in seconds. 0 for browser-default 19738 async: true, // whether request is asynchronous or not 19739 processData: true, // any data processing is disabled if false, only callback call 19740 scriptsRunFirst: false, // whether to run _all_ found scripts before onsuccess call. script tag can have an attribute "bxrunfirst" to turn this flag on only for itself 19741 emulateOnload: true, 19742 skipAuthCheck: false, // whether to check authorization failure (SHOUD be set to true for CORS requests) 19743 start: true, // send request immediately (if false, request can be started manually via XMLHttpRequest object returned) 19744 cache: true, // whether NOT to add random addition to URL 19745 preparePost: true, // whether set Content-Type x-www-form-urlencoded in POST 19746 headers: false, // add additional headers, example: [{'name': 'If-Modified-Since', 'value': 'Wed, 15 Aug 2012 08:59:08 GMT'}, {'name': 'If-None-Match', 'value': '0'}] 19747 lsTimeout: 30, //local storage data TTL. useless without lsId. 19748 lsForce: false //wheter to force query instead of using localStorage data. useless without lsId. 19749/* 19750other parameters: 19751 url: url to get/post 19752 data: data to post 19753 onsuccess: successful request callback. BX.proxy may be used. 19754 onfailure: request failure callback. BX.proxy may be used. 19755 onprogress: request progress callback. BX.proxy may be used. 19756 19757 lsId: local storage id - for constantly updating queries which can communicate via localStorage. core_ls.js needed 19758 19759any of the default parameters can be overridden. defaults can be changed by BX.ajax.Setup() - for all further requests! 19760*/ 19761 }, 19762 ajax_session = null, 19763 loadedScripts = {}, 19764 loadedScriptsQueue = [], 19765 r = { 19766 'url_utf': /[^\034-\254]+/g, 19767 'script_self': /\/bitrix\/js\/main\/core\/core(_ajax)*.js$/i, 19768 'script_self_window': /\/bitrix\/js\/main\/core\/core_window.js$/i, 19769 'script_self_admin': /\/bitrix\/js\/main\/core\/core_admin.js$/i, 19770 'script_onload': /window.onload/g 19771 }; 19772 19773// low-level method 19774BX.ajax = function(config) 19775{ 19776 var status, data; 19777
19778 if (!config || !config.url || !BX.type.isString(config.url)) 19779 { 19780 return false; 19781 } 19782 19783 for (var i in tempDefaultConfig) 19784 if (typeof (config[i]) == "undefined") config[i] = tempDefaultConfig[i]; 19785 19786 tempDefaultConfig = {}; 19787 19788 for (i in defaultConfig) 19789 if (typeof (config[i]) == "undefined") config[i] = defaultConfig[i]; 19790 19791 config.method = config.method.toUpperCase(); 19792 19793 if (!BX.localStorage) 19794 config.lsId = null; 19795 19796 if (BX.browser.IsIE()) 19797 { 19798 var result = r.url_utf.exec(config.url); 19799 if (result) 19800 { 19801 do 19802 { 19803 config.url = config.url.replace(result, BX.util.urlencode(result)); 19804 result = r.url_utf.exec(config.url); 19805 } while (result); 19806 } 19807 } 19808 19809 if(config.dataType == 'json') 19810 config.emulateOnload = false; 19811 19812 if (!config.cache && config.method == 'GET') 19813 config.url = BX.ajax._uncache(config.url); 19814 19815 if (config.method == 'POST') 19816 { 19817 if (config.preparePost) 19818 { 19819 config.data = BX.ajax.prepareData(config.data); 19820 } 19821 else if (getLastContentTypeHeader(config.headers) === 'application/json') 19822 { 19823 config.data = JSON.stringify(config.data); 19824 } 19825 } 19826 19827 var bXHR = true; 19828 if (config.lsId && !config.lsForce) 19829 { 19830 var v = BX.localStorage.get('ajax-' + config.lsId); 19831 if (v !== null) 19832 { 19833 bXHR = false; 19834 19835 var lsHandler = function(lsData) { 19836 if (lsData.key == 'ajax-' + config.lsId && lsData.value != 'BXAJAXWAIT') 19837 { 19838 var data = lsData.value, 19839 bRemove = !!lsData.oldValue && data == null; 19840 if (!bRemove) 19841 BX.ajax.__run(config, data); 19842 else if (config.onfailure) 19843 config.onfailure("timeout"); 19844 19845 BX.removeCustomEvent('onLocalStorageChange', lsHandler); 19846 } 19847 }; 19848 19849 if (v == 'BXAJAXWAIT') 19850 { 19851 BX.addCustomEvent('onLocalStorageChange', lsHandler); 19852 } 19853 else 19854 { 19855 setTimeout(function() {lsHandler({key: 'ajax-' + config.lsId, value: v})}, 10); 19856 } 19857 } 19858 } 19859 19860 if (bXHR) 19861 { 19862 config.xhr = BX.ajax.xhr(); 19863 if (!config.xhr) return; 19864 19865 if (config.lsId) 19866 { 19867 BX.localStorage.set('ajax-' + config.lsId, 'BXAJAXWAIT', config.lsTimeout); 19868 } 19869 19870 if (BX.Type.isFunction(config.onprogress)) 19871 { 19872 BX.bind(config.xhr, 'progress', config.onprogress); 19873 } 19874 19875 if (BX.Type.isFunction(config.onprogressupload) && config.xhr.upload) 19876 { 19877 BX.bind(config.xhr.upload, 'progress', config.onprogressupload); 19878 } 19879 19880 config.xhr.open(config.method, config.url, config.async); 19881 19882 if (!config.skipBxHeader && !BX.ajax.isCrossDomain(config.url)) 19883 { 19884 config.xhr.setRequestHeader('Bx-ajax', 'true'); 19885 } 19886 19887 if (config.method == 'POST' && config.preparePost) 19888 { 19889 config.xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 19890 } 19891 if (typeof(config.headers) == "object") 19892 { 19893 for (i = 0; i < config.headers.length; i++) 19894 config.xhr.setRequestHeader(config.headers[i].name, config.headers[i].value); 19895 } 19896 19897 var bRequestCompleted = false; 19898 var onreadystatechange = config.xhr.onreadystatechange = function(additional) 19899 { 19900 if (bRequestCompleted) 19901 return; 19902 19903 if (additional === 'timeout') 19904 { 19905 if (config.onfailure) 19906 { 19907 config.onfailure('timeout', '', config); 19908 } 19909 19910 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['timeout', '', config]); 19911 19912 config.xhr.onreadystatechange = BX.DoNothing; 19913 config.xhr.abort(); 19914 19915 if (config.async) 19916 { 19917 config.xhr = null; 19918 } 19919 } 19920 else 19921 { 19922 if (config.xhr.readyState == 4 || additional == 'run') 19923 { 19924 status = BX.ajax.xhrSuccess(config.xhr) ? "success" : "error"; 19925 bRequestCompleted = true; 19926 config.xhr.onreadystatechange = BX.DoNothing; 19927 19928 if (status == 'success') 19929 { 19930 var authHeader = (!!config.skipAuthCheck || BX.ajax.isCrossDomain(config.url)) 19931 ? false 19932 : config.xhr.getResponseHeader('X-Bitrix-Ajax-Status'); 19933 19934 if(!!authHeader && authHeader == 'Authorize') 19935 { 19936 if (config.onfailure) 19937 { 19938 config.onfailure('auth', config.xhr.status, config); 19939 } 19940 19941 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['auth', config.xhr.status, config]); 19942 } 19943 else 19944 { 19945 var data = config.xhr.responseText; 19946 19947 if (config.lsId) 19948 { 19949 BX.localStorage.set('ajax-' + config.lsId, data, config.lsTimeout); 19950 } 19951 19952 BX.ajax.__run(config, data); 19953 } 19954 } 19955 else 19956 { 19957 if (config.onfailure) 19958 { 19959 config.onfailure('status', config.xhr.status, config); 19960 } 19961 19962 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['status', config.xhr.status, config]); 19963 } 19964 19965 if (config.async) 19966 { 19967 config.xhr = null; 19968 } 19969 } 19970 } 19971 }; 19972 19973 if (config.async && config.timeout > 0) 19974 { 19975 setTimeout(function() { 19976 if (config.xhr && !bRequestCompleted) 19977 { 19978 onreadystatechange("timeout"); 19979 } 19980 }, config.timeout * 1000); 19981 } 19982 19983 if (config.start) 19984 {
19985 config.xhr.send(config.data); 19986 19987 if (!config.async) 19988 { 19989 onreadystatechange('run'); 19990 } 19991 } 19992 19993 return config.xhr; 19994 } 19995}; 19996 19997BX.ajax.xhr = function() 19998{ 19999 if (window.XMLHttpRequest) 20000 { 20001 try {return new XMLHttpRequest();} catch(e){} 20002 } 20003 else if (window.ActiveXObject) 20004 { 20005 try { return new window.ActiveXObject("Msxml2.XMLHTTP.6.0"); } 20006 catch(e) {} 20007 try { return new window.ActiveXObject("Msxml2.XMLHTTP.3.0"); } 20008 catch(e) {} 20009 try { return new window.ActiveXObject("Msxml2.XMLHTTP"); } 20010 catch(e) {} 20011 try { return new window.ActiveXObject("Microsoft.XMLHTTP"); } 20012 catch(e) {} 20013 throw new Error("This browser does not support XMLHttpRequest."); 20014 } 20015 20016 return null; 20017}; 20018 20019BX.ajax.isCrossDomain = function(url, location) 20020{ 20021 location = location || window.location; 20022 20023 //Relative URL gets a current protocol 20024 if (url.indexOf("//") === 0) 20025 { 20026 url = location.protocol + url; 20027 } 20028 20029 //Fast check 20030 if (url.indexOf("http") !== 0) 20031 { 20032 return false; 20033 } 20034 20035 var link = window.document.createElement("a"); 20036 link.href = url; 20037 20038 return link.protocol !== location.protocol || 20039 link.hostname !== location.hostname || 20040 BX.ajax.getHostPort(link.protocol, link.host) !== BX.ajax.getHostPort(location.protocol, location.host); 20041}; 20042 20043BX.ajax.getHostPort = function(protocol, host) 20044{ 20045 var match = /:(\d+)$/.exec(host); 20046 if (match) 20047 { 20048 return match[1]; 20049 } 20050 else 20051 { 20052 if (protocol === "http:") 20053 { 20054 return "80"; 20055 } 20056 else if (protocol === "https:") 20057 { 20058 return "443"; 20059 } 20060 } 20061 20062 return ""; 20063}; 20064 20065BX.ajax.__prepareOnload = function(scripts) 20066{ 20067 if (scripts.length > 0) 20068 { 20069 BX.ajax['onload_' + ajax_session] = null; 20070 20071 for (var i=0,len=scripts.length;i<len;i++) 20072 { 20073 if (scripts[i].isInternal) 20074 { 20075 scripts[i].JS = scripts[i].JS.replace(r.script_onload, 'BX.aja
20075x.onload_' + ajax_session); 20076 } 20077 } 20078 } 20079 20080 BX.CaptureEventsGet(); 20081 BX.CaptureEvents(window, 'load'); 20082}; 20083 20084BX.ajax.__runOnload = function() 20085{ 20086 if (null != BX.ajax['onload_' + ajax_session]) 20087 { 20088 BX.ajax['onload_' + ajax_session].apply(window); 20089 BX.ajax['onload_' + ajax_session] = null; 20090 } 20091 20092 var h = BX.CaptureEventsGet(); 20093 20094 if (h) 20095 { 20096 for (var i=0; i<h.length; i++) 20097 h[i].apply(window); 20098 } 20099}; 20100 20101BX.ajax.__run = function(config, data) 20102{ 20103 if (!config.processData) 20104 { 20105 if (config.onsuccess) 20106 { 20107 config.onsuccess(data); 20108 } 20109 20110 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [data, config]); 20111 } 20112 else 20113 { 20114 data = BX.ajax.processRequestData(data, config); 20115 } 20116}; 20117 20118 20119BX.ajax._onParseJSONFailure = function(data) 20120{ 20121 this.jsonFailure = true; 20122 this.jsonResponse = data; 20123 this.jsonProactive = /^\[WAF\]/.test(data); 20124}; 20125 20126BX.ajax.processRequestData = function(data, config) 20127{ 20128 var result, scripts = [], styles = []; 20129 switch (config.dataType.toUpperCase()) 20130 { 20131 case 'JSON': 20132 20133 var context = config.xhr || {}; 20134 BX.addCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 20135 result = BX.parseJSON(data, context); 20136 BX.removeCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 20137 20138 if(!!result && BX.type.isArray(result['bxjs'])) 20139 { 20140 for(var i = 0; i < result['bxjs'].length; i++) 20141 { 20142 if(BX.type.isNotEmptyString(result['bxjs'][i])) 20143 { 20144 scripts.push({ 20145 "isInternal": false, 20146 "JS": result['bxjs'][i], 20147 "bRunFirst": config.scriptsRunFirst 20148 }); 20149 } 20150 else 20151 { 20152 scripts.push(result['bxjs'][i]) 20153 } 20154 } 20155 } 20156 20157 if(!!result && BX.type.isArray(result['bxcss'])) 20158 { 20159 styles = result['bxcss']; 20160 } 20161 20162 break; 20163 case 'SCRIPT': 20164 scripts.push({"isInternal": true, "JS": data, "bRunFirst": config.scriptsRunFirst}); 20165 result = data; 20166 break; 20167 20168 default: // HTML 20169 var ob = BX.processHTML(data, config.scriptsRunFirst); 20170 result = ob.HTML; scripts = ob.SCRIPT; styles = ob.STYLE; 20171 break; 20172 } 20173 20174 var bSessionCreated = false; 20175 if (null == ajax_session) 20176 { 20177 ajax_session = parseInt(Math.random() * 1000000); 20178 bSessionCreated = true; 20179 } 20180 20181 if (styles.length > 0) 20182 BX.loadCSS(styles); 20183 20184 if (config.emulateOnload) 20185 BX.ajax.__prepareOnload(scripts); 20186 20187 var cb = BX.DoNothing; 20188 if(config.emulateOnload || bSessionCreated) 20189 { 20190 cb = BX.defer(function() 20191 { 20192 if (config.emulateOnload) 20193 BX.ajax.__runOnload(); 20194 if (bSessionCreated) 20195 ajax_session = null; 20196 BX.onCustomEvent(config.xhr, 'onAjaxSuccessFinish', [config]); 20197 }); 20198 } 20199 20200 try 20201 { 20202 if (!!config.jsonFailure) 20203 { 20204 throw {type: 'json_failure', data: config.jsonResponse, bProactive: config.jsonProactive}; 20205 } 20206 20207 config.scripts = scripts; 20208 20209 BX.ajax.processScripts(config.scripts, true); 20210 20211 if (config.onsuccess) 20212 { 20213 config.onsuccess(result); 20214 } 20215 20216 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [result, config]); 20217 20218 BX.ajax.processScripts(config.scripts, false, cb); 20219 } 20220 catch (e) 20221 { 20222 if (config.onfailure) 20223 config.onfailure("processing", e); 20224 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['processing', e, config]); 20225 } 20226}; 20227 20228BX.ajax.processScripts = function(scripts, bRunFirst, cb) 20229{ 20230 var scriptsExt = [], scriptsInt = ''; 20231 20232 cb = cb || BX.DoNothing; 20233 20234 for (var i = 0, length = scripts.length; i < length; i++) 20235 { 20236 if (typeof bRunFirst != 'undefined' && bRunFirst != !!scripts[i].bRunFirst) 20237 continue; 20238 20239 if (scripts[i].isInternal) 20240 scriptsInt += ';' + scripts[i].JS; 20241 else 20242 scriptsExt.push(scripts[i].JS); 20243 } 20244 20245 scriptsExt = BX.util.array_unique(scriptsExt); 20246 var inlineScripts = scriptsInt.length > 0 ? function() { BX.evalGlobal(scriptsInt); } : BX.DoNothing; 20247 20248 if (scriptsExt.length > 0) 20249 { 20250 BX.load(scriptsExt, function() { 20251 inlineScripts(); 20252 cb(); 20253 }); 20254 } 20255 else 20256 { 20257 inlineScripts(); 20258 cb(); 20259 } 20260}; 20261 20262// TODO: extend this function to use with any data objects or forms 20263BX.ajax.prepareData = function(arData, prefix) 20264{ 20265 var data = ''; 20266 if (BX.type.isString(arData)) 20267 data = arData; 20268 else if (null != arData) 20269 { 20270 for(var i in arData) 20271 { 20272 if (arData.hasOwnProperty(i)) 20273 { 20274 if (data.length > 0) 20275 data += '&'; 20276 var name = BX.util.urlencode(i); 20277 if(prefix)
20278 name = prefix + '[' + name + ']'; 20279 if(typeof arData[i] == 'object') 20280 data += BX.ajax.prepareData(arData[i], name); 20281 else 20282 data += name + '=' + BX.util.urlencode(arData[i]); 20283 } 20284 } 20285 } 20286 return data; 20287}; 20288 20289BX.ajax.xhrSuccess = function(xhr) 20290{ 20291 return (xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || xhr.status === 1223 || xhr.status === 0; 20292}; 20293 20294BX.ajax.Setup = function(config, bTemp) 20295{ 20296 bTemp = !!bTemp; 20297 20298 for (var i in config) 20299 { 20300 if (bTemp) 20301 tempDefaultConfig[i] = config[i]; 20302 else 20303 defaultConfig[i] = config[i]; 20304 } 20305}; 20306 20307BX.ajax.replaceLocalStorageValue = function(lsId, data, ttl) 20308{ 20309 if (!!BX.localStorage) 20310 BX.localStorage.set('ajax-' + lsId, data, ttl); 20311}; 20312 20313 20314BX.ajax._uncache = function(url) 20315{ 20316 return url + ((url.indexOf('?') !== -1 ? "&" : "?") + '_=' + (new Date()).getTime()); 20317}; 20318 20319/* simple interface */ 20320BX.ajax.get = function(url, data, callback) 20321{ 20322 if (BX.type.isFunction(data)) 20323 { 20324 callback = data; 20325 data = ''; 20326 } 20327 20328 data = BX.ajax.prepareData(data); 20329 20330 if (data) 20331 { 20332 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 20333 data = ''; 20334 } 20335 20336 return BX.ajax({ 20337 'method': 'GET', 20338 'dataType': 'html', 20339 'url': url, 20340 'data': '', 20341 'onsuccess': callback 20342 }); 20343}; 20344 20345BX.ajax.getCaptcha = function(callback) 20346{ 20347 return BX.ajax.loadJSON('/bitrix/tools/ajax_captcha.php', callback); 20348}; 20349 20350BX.ajax.insertToNode = function(url, node) 20351{ 20352 node = BX(node); 20353 if (!!node) 20354 { 20355 var eventArgs = { cancel: false }; 20356 BX.onCustomEvent('onAjaxInsertToNode', [{ url: url, node: node, eventArgs: eventArgs }]); 20357 if(eventArgs.cancel === true) 20358 { 20359 return; 20360 } 20361 20362 var show = null; 20363 if (!tempDefaultConfig.denyShowWait) 20364 { 20365 show = BX.showWait(node); 20366 delete tempDefaultConfig.denyShowWait; 20367 } 20368 20369 return BX.ajax.get(url, function(data) { 20370 node.innerHTML = data; 20371 BX.closeWait(node, show); 20372 }); 20373 } 20374}; 20375 20376BX.ajax.post = function(url, data, callback) 20377{ 20378 data = BX.ajax.prepareData(data); 20379 20380 return BX.ajax({ 20381 'method': 'POST', 20382 'dataType': 'html', 20383 'url': url, 20384 'data': data, 20385 'onsuccess': callback 20386 }); 20387}; 20388 20389/** 20390 * BX.ajax with BX.Promise 20391 * 20392 * @param config 20393 * @returns {BX.Promise|false} 20394 */ 20395BX.ajax.promise = function(config) 20396{ 20397 var result = new BX.Promise(); 20398 20399 config.onsuccess = function(data) 20400 { 20401 result.fulfill(data); 20402 }; 20403 config.onfailure = function(reason, httpStatus, config) 20404 { 20405 result.reject({ 20406 reason: reason, 20407 data: httpStatus, 20408 ajaxConfig: config, 20409 xhr: config.xhr 20410 }); 20411 }; 20412 20413 var xhr = BX.ajax(config); 20414 if (xhr) 20415 { 20416 if (typeof config.onrequeststart === 'function') 20417 { 20418 config.onrequeststart(xhr); 20419 } 20420 } 20421 else 20422 { 20423 result.reject({ 20424 reason: "init", 20425 data: false 20426 }); 20427 } 20428 20429 return result; 20430}; 20431 20432/* load and execute external file script with onload emulation */ 20433BX.ajax.loadScriptAjax = function(script_src, callback, bPreload) 20434{ 20435 if (BX.type.isArray(script_src)) 20436 { 20437 for (var i=0,len=script_src.length;i<len;i++) 20438 { 20439 BX.ajax.loadScriptAjax(script_src[i], callback, bPreload); 20440 } 20441 } 20442 else 20443 { 20444 var script_src_test = script_src.replace(/\.js\?.*/, '.js'); 20445 20446 if (r.script_self.test(script_src_test)) return; 20447 if (r.script_self_window.test(script_src_test) && BX.CWindow) return; 20448 if (r.script_self_admin.test(script_src_test) && BX.admin) return; 20449 20450 if (typeof loadedScripts[script_src_test] == 'undefined') 20451 { 20452 if (!!bPreload) 20453 { 20454 loadedScripts[script_src_test] = ''; 20455 return BX.loadScript(script_src); 20456 } 20457 else 20458 { 20459 return BX.ajax({ 20460 url: script_src, 20461 method: 'GET', 20462 dataType: 'script', 20463 processData: true, 20464 emulateOnload: false, 20465 scriptsRunFirst: true, 20466 async: false, 20467 start: true, 20468 onsuccess: function(result) { 20469 loadedScripts[script_src_test] = result; 20470 if (callback) 20471 callback(result); 20472 } 20473 }); 20474 } 20475 } 20476 else if (callback) 20477 { 20478 callback(loadedScripts[script_src_test]); 20479 } 20480 } 20481}; 20482 20483/* non-xhr loadings */ 20484BX.ajax.loadJSON = function(url, data, callback, callback_failure) 20485{ 20486 if (BX.type.isFunction(data)) 20487 { 20488 callback_failure = callback; 20489 callback = data; 20490 data = ''; 20491 } 20492 20493 data = BX.ajax.prepareData(data); 20494 20495 if (data) 20496 { 20497 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 20498 data = ''; 20499 } 20500
20501 return BX.ajax({ 20502 'method': 'GET', 20503 'dataType': 'json', 20504 'url': url, 20505 'onsuccess': callback, 20506 'onfailure': callback_failure 20507 }); 20508}; 20509 20510var getLastContentTypeHeader = function (headers) { 20511 if (!BX.Type.isArray(headers)) 20512 { 20513 return null; 20514 } 20515 var lastHeader = headers 20516 .filter(function (header) { 20517 return header.name === 'Content-Type'; 20518 }) 20519 .pop(); 20520 20521 return lastHeader ? lastHeader.value : null; 20522}; 20523 20524var prepareAjaxGetParameters = function(config) 20525{ 20526 var getParameters = config.getParameters || {}; 20527 if (BX.type.isNotEmptyString(config.analyticsLabel)) 20528 { 20529 getParameters.analyticsLabel = config.analyticsLabel; 20530 } 20531 else if (BX.type.isNotEmptyObject(config.analyticsLabel)) 20532 { 20533 getParameters.analyticsLabel = config.analyticsLabel; 20534 } 20535 if (typeof config.mode !== 'undefined') 20536 { 20537 getParameters.mode = config.mode; 20538 } 20539 if (config.navigation) 20540 { 20541 if(config.navigation.page) 20542 { 20543 getParameters.nav = 'page-' + config.navigation.page; 20544 } 20545 if(config.navigation.size) 20546 { 20547 if(getParameters.nav) 20548 { 20549 getParameters.nav += '-'; 20550 } 20551 else 20552 { 20553 getParameters.nav = ''; 20554 } 20555 getParameters.nav += 'size-' + config.navigation.size; 20556 } 20557 } 20558 20559 return getParameters; 20560}; 20561 20562var prepareAjaxConfig = function(config) 20563{ 20564 config = BX.type.isPlainObject(config) ? config : {}; 20565 20566 config.headers = config.headers || []; 20567 config.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 20568 if (BX.message.SITE_ID) 20569 { 20570 config.headers.push({name: 'X-Bitrix-Site-Id', value: BX.message.SITE_ID}); 20571 } 20572 20573 if (typeof config.json !== 'undefined') 20574 { 20575 if (!BX.type.isPlainObject(config.json)) 20576 { 20577 throw new Error('Wrong `config.json`, plain object expected.') 20578 } 20579 20580 config.headers.push({name: 'Content-Type', value: 'application/json'}); 20581 config.data = config.json; 20582 config.preparePost = false; 20583 } 20584 else if (config.data instanceof FormData) 20585 { 20586 config.preparePost = false; 20587 if (typeof config.signedParameters !== 'undefined') 20588 { 20589 config.data.append('signedParameters', config.signedParameters); 20590 } 20591 } 20592 else if (BX.type.isPlainObject(config.data) || BX.Type.isNil(config.data)) 20593 { 20594 config.data = BX.type.isPlainObject(config.data) ? config.data : {}; 20595 if (typeof config.signedParameters !== 'undefined') 20596 { 20597 config.data.signedParameters = config.signedParameters; 20598 } 20599 } 20600 20601 if (!config.method) 20602 { 20603 config.method = 'POST' 20604 } 20605 20606 return config; 20607}; 20608 20609var buildAjaxPromiseToRestoreCsrf = function(config, withoutRestoringCsrf) 20610{ 20611 withoutRestoringCsrf = withoutRestoringCsrf || false; 20612 var originalConfig = BX.clone(config); 20613 var request = null; 20614 20615 var onrequeststart = config.onrequeststart; 20616 config.onrequeststart = function(xhr) { 20617 request = xhr; 20618 if (BX.type.isFunction(onrequeststart)) 20619 { 20620 onrequeststart(xhr); 20621 } 20622 }; 20623 var onrequeststartOrig = originalConfig.onrequeststart; 20624 originalConfig.onrequeststart = function(xhr) { 20625 request = xhr; 20626 if (BX.type.isFunction(onrequeststartOrig)) 20627 { 20628 onrequeststartOrig(xhr); 20629 } 20630 }; 20631 20632 var promise = BX.ajax.promise(config); 20633 20634 return promise.then(function(response) { 20635 if (!withoutRestoringCsrf && BX.type.isPlainObject(response) && BX.type.isArray(response.errors)) 20636 { 20637 var csrfProblem = false; 20638 response.errors.forEach(function(error) { 20639 if (error.code === 'invalid_csrf' && error.customData.csrf) 20640 { 20641 BX.message({'bitrix_sessid': error.customData.csrf}); 20642 20643 originalConfig.headers = originalConfig.headers || []; 20644 originalConfig.headers = originalConfig.headers.filter(function(header) { 20645 return header && header.name !== 'X-Bitrix-Csrf-Token'; 20646 }); 20647 originalConfig.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 20648 20649 csrfProblem = true; 20650 } 20651 }); 20652 20653 if (csrfProblem) 20654 { 20655 return buildAjaxPromiseToRestoreCsrf(originalConfig, true); 20656 } 20657 } 20658 20659 if (!BX.type.isPlainObject(response) || response.status !== 'success') 20660 { 20661 var errorPromise = new BX.Promise(); 20662 errorPromise.reject(response); 20663 20664 return errorPromise; 20665 } 20666 20667 return response; 20668 }).catch(function(data) { 20669 var ajaxReject = new BX.Promise(); 20670 20671 var originalJsonResponse; 20672 if (BX.type.isPlainObject(data) && data.xhr && data.xhr.responseText) 20673 { 20674 try 20675 { 20676 originalJsonResponse = JSON.parse(data.xhr.responseText); 20677 data = originalJsonResponse; 20678 } 20679 catch (err) 20680 {} 20681 } 20682 20683 if (BX.type.isPlainObject(data) && data.status && data.hasOwnProperty('data')) 20684 { 20685 ajaxReject.reject(data); 20686 } 20687 else 20688 { 20689 ajaxReject.reject({ 20690 status: 'error', 20691 data: { 20692 ajaxRejectData: data 20693 }, 20694 errors: [ 20695 {
20696 code: 'NETWORK_ERROR', 20697 message: 'Network error' 20698 } 20699 ] 20700 }); 20701 } 20702 20703 return ajaxReject; 20704 }).then(function(response){ 20705 20706 var assetsLoaded = new BX.Promise(); 20707 20708 var headers = request.getAllResponseHeaders().trim().split(/[\r\n]+/); 20709 var headerMap = {}; 20710 headers.forEach(function (line) { 20711 var parts = line.split(': '); 20712 var header = parts.shift().toLowerCase(); 20713 headerMap[header] = parts.join(': '); 20714 }); 20715 20716 if (!headerMap['x-process-assets']) 20717 { 20718 assetsLoaded.fulfill(response); 20719 20720 return assetsLoaded; 20721 } 20722 20723 var assets = BX.prop.getObject(BX.prop.getObject(response, "data", {}), "assets", {}); 20724 var promise = new Promise(function(resolve, reject) { 20725 var css = BX.prop.getArray(assets, "css", []); 20726 BX.load(css, function(){ 20727 BX.loadScript( 20728 BX.prop.getArray(assets, "js", []), 20729 resolve 20730 ); 20731 }); 20732 }); 20733 promise.then(function(){ 20734 var strings = BX.prop.getArray(assets, "string", []); 20735 var stringAsset = strings.join('\n'); 20736 BX.html(document.head, stringAsset, { useAdjacentHTML: true }).then(function(){ 20737 assetsLoaded.fulfill(response); 20738 }); 20739 }); 20740 20741 return assetsLoaded; 20742 }); 20743}; 20744 20745/** 20746 * 20747 * @param {string} action 20748 * @param {Object} config 20749 * @param {?string|?Object} [config.analyticsLabel] 20750 * @param {string} [config.method='POST'] 20751 * @param {Object} [config.data] 20752 * @param {?Object} [config.getParameters] 20753 * @param {?Object} [config.headers] 20754 * @param {?Object} [config.timeout] 20755 * @param {Object} [config.navigation] 20756 * @param {number} [config.navigation.page] 20757 */ 20758BX.ajax.runAction = function(action, config) 20759{ 20760 config = prepareAjaxConfig(config); 20761 var getParameters = prepareAjaxGetParameters(config); 20762 getParameters.action = action; 20763
20764 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 20765 return buildAjaxPromiseToRestoreCsrf({ 20766 method: config.method, 20767 dataType: 'json', 20768 url: url, 20769 data: config.data, 20770 timeout: config.timeout, 20771 preparePost: config.preparePost, 20772 headers: config.headers, 20773 onrequeststart: config.onrequeststart, 20774 onprogress: config.onprogress, 20775 onprogressupload: config.onprogressupload 20776 }); 20777}; 20778 20779/** 20780 * 20781 * @param {string} component 20782 * @param {string} action 20783 * @param {Object} config 20784 * @param {?string|?Object} [config.analyticsLabel] 20785 * @param {?string} [config.signedParameters] 20786 * @param {string} [config.method='POST'] 20787 * @param {string} [config.mode='ajax'] Ajax or class. 20788 * @param {Object} [config.data] 20789 * @param {?Object} [config.getParameters] 20790 * @param {?array} [config.headers] 20791 * @param {?number} [config.timeout] 20792 * @param {Object} [config.navigation] 20793 */ 20794BX.ajax.runComponentAction = function (component, action, config) 20795{ 20796 config = prepareAjaxConfig(config); 20797 config.mode = config.mode || 'ajax'; 20798 20799 var getParameters = prepareAjaxGetParameters(config); 20800 getParameters.c = component; 20801 getParameters.action = action; 20802
20803 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 20804 20805 return buildAjaxPromiseToRestoreCsrf({ 20806 method: config.method, 20807 dataType: 'json', 20808 url: url, 20809 data: config.data, 20810 timeout: config.timeout, 20811 preparePost: config.preparePost, 20812 headers: config.headers, 20813 onrequeststart: (config.onrequeststart ? config.onrequeststart : null), 20814 onprogress: config.onprogress, 20815 onprogressupload: config.onprogressupload 20816 }); 20817}; 20818 20819/* 20820arObs = [{ 20821 url: url, 20822 type: html|script|json|css, 20823 callback: function 20824}] 20825*/ 20826BX.ajax.load = function(arObs, callback) 20827{ 20828 if (!BX.type.isArray(arObs)) 20829 arObs = [arObs]; 20830 20831 var cnt = 0; 20832 20833 if (!BX.type.isFunction(callback)) 20834 callback = BX.DoNothing; 20835 20836 var handler = function(data) 20837 { 20838 if (BX.type.isFunction(this.callback)) 20839 this.callback(data); 20840 20841 if (++cnt >= len) 20842 callback(); 20843 }; 20844 20845 for (var i = 0, len = arObs.length; i<len; i++) 20846 { 20847 switch(arObs[i].type.toUpperCase()) 20848 { 20849 case 'SCRIPT': 20850 BX.loadScript([arObs[i].url], BX.proxy(handler, arObs[i])); 20851 break; 20852 case 'CSS': 20853 BX.loadCSS([arObs[i].url]); 20854 20855 if (++cnt >= len) 20856 callback(); 20857 break; 20858 case 'JSON': 20859 BX.ajax.loadJSON(arObs[i].url, BX.proxy(handler, arObs[i])); 20860 break; 20861 20862 default: 20863 BX.ajax.get(arObs[i].url, '', BX.proxy(handler, arObs[i])); 20864 break; 20865 } 20866 } 20867}; 20868 20869/* ajax form sending */ 20870BX.ajax.submit = function(obForm, callback) 20871{ 20872 if (!obForm.target) 20873 { 20874 if (null == obForm.BXFormTarget) 20875 { 20876 var frame_name = 'formTarget_' + Math.random(); 20877 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 20878 props: { 20879 name: frame_name, 20880 id: frame_name, 20881 src: 'javascript:void(0)' 20882 }, 20883 style: { 20884 display: 'none' 20885 } 20886 })); 20887 } 20888 20889 obForm.target = obForm.BXFormTarget.name; 20890 } 20891 20892 obForm.BXFormCallback = callback; 20893 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 20894 20895 BX.submit(obForm); 20896 20897 return false; 20898}; 20899 20900BX.ajax.submitComponentForm = function(obForm, container, bWait) 20901{ 20902 if (!obForm.target) 20903 { 20904 if (null == obForm.BXFormTarget) 20905 { 20906 var frame_name = 'formTarget_' + Math.random(); 20907 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 20908 props: { 20909 name: frame_name, 20910 id: frame_name, 20911 src: 'javascript:void(0)' 20912 }, 20913 style: { 20914 display: 'none' 20915 } 20916 })); 20917 } 20918 20919 obForm.target = obForm.BXFormTarget.name; 20920 } 20921 20922 if (!!bWait) 20923 var w = BX.showWait(container); 20924 20925 obForm.BXFormCallback = function(d) { 20926 if (!!bWait) 20927 BX.closeWait(w); 20928 20929 var callOnload = function(){ 20930 if(!!window.bxcompajaxframeonload) 20931 { 20932 setTimeout(function(){window.bxcompajaxframeonload();window.bxcompajaxframeonload=null;}, 10); 20933 } 20934 }; 20935 20936 BX(container).innerHTML = d; 20937 BX.onCustomEvent('onAjaxSuccess', [null,null,callOnload]); 20938 }; 20939 20940 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 20941 20942 return true; 20943}; 20944 20945// func will be executed in form context 20946BX.ajax._submit_callback = function() 20947{ 20948 //opera and IE8 triggers onload event even on empty iframe 20949 try 20950 { 20951 if(this.BXFormTarget.contentWindow.location.href.indexOf('http') != 0) 20952 return; 20953 } catch (e) { 20954 return; 20955 } 20956 20957 if (this.BXFormCallback) 20958 this.BXFormCallback.apply(this, [this.BXFormTarget.contentWindow.document.body.innerHTML]); 20959 20960 BX.unbindAll(this.BXFormTarget); 20961}; 20962 20963BX.ajax.prepareForm = function(obForm, data) 20964{ 20965 data = (!!data ? data : {}); 20966 var i, ii, el, 20967 _data = [], 20968 n = obForm.elements.length, 20969 files = 0, length = 0; 20970 if(!!obForm) 20971 { 20972 for (i = 0; i < n; i++) 20973 { 20974 el = obForm.elements[i]; 20975 if (el.disabled) 20976 continue; 20977 20978 if(!el.type) 20979 continue; 20980 20981 switch(el.type.toLowerCase()) 20982 { 20983 case 'text': 20984 case 'textarea': 20985 case 'password': 20986 case 'number': 20987 case 'hidden': 20988 case 'select-one': 20989 _data.push({name: el.name, value: el.value}); 20990 length += (el.name.length + el.value.length); 20991 break; 20992 case 'file': 20993 if (!!el.files) 20994 { 20995 for (ii = 0; ii < el.files.length; ii++) 20996 { 20997 files++; 20998 _data.push({name: el.name, value: el.files[ii], file : true}); 20999 length += el.files[ii].size; 21000 } 21001 } 21002 break; 21003 case 'radio':
21004 case 'checkbox': 21005 if(el.checked) 21006 { 21007 _data.push({name: el.name, value: el.value}); 21008 length += (el.name.length + el.value.length); 21009 } 21010 break; 21011 case 'select-multiple': 21012 for (var j = 0; j < el.options.length; j++) 21013 { 21014 if (el.options[j].selected) 21015 { 21016 _data.push({name : el.name, value : el.options[j].value}); 21017 length += (el.name.length + el.options[j].length); 21018 } 21019 } 21020 break; 21021 default: 21022 break; 21023 } 21024 } 21025 21026 i = 0; length = 0; 21027 var current = data, name, rest, pp, tmpKey; 21028 21029 while(i < _data.length) 21030 { 21031 var p = _data[i].name.indexOf('['); 21032 if (tmpKey) 21033 { 21034 current[_data[i].name] = {}; 21035 current[_data[i].name][tmpKey.replace(/\[|\]/gi, '')] = _data[i].value; 21036 current = data; 21037 tmpKey = null; 21038 i++; 21039 } 21040 else if (p == -1) 21041 { 21042 current[_data[i].name] = _data[i].value; 21043 current = data; 21044 i++; 21045 } 21046 else 21047 { 21048 name = _data[i].name.substring(0, p); 21049 rest = _data[i].name.substring(p+1); 21050 pp = rest.indexOf(']'); 21051 21052 if(pp == -1) 21053 { 21054 if (!current[name]) 21055 current[name] = []; 21056 current = data; 21057 i++; 21058 } 21059 else if(pp == 0) 21060 { 21061 if (!current[name]) 21062 current[name] = []; 21063 //No index specified - so take the next integer 21064 current = current[name]; 21065 _data[i].name = '' + current.length; 21066 if (rest.substring(pp+1).indexOf('[') === 0) 21067 tmpKey = rest.substring(0, pp) + rest.substring(pp+1); 21068 } 21069 else 21070 { 21071 if (!current[name]) 21072 current[name] = {}; 21073 //Now index name becomes and name and we go deeper into the array 21074 current = current[name]; 21075 _data[i].name = rest.substring(0, pp) + rest.substring(pp+1); 21076 } 21077 } 21078 } 21079 } 21080 return {data : data, filesCount : files, roughSize : length}; 21081}; 21082BX.ajax.submitAjax = function(obForm, config) 21083{ 21084 config = (config !== null && typeof config == "object" ? config : {}); 21085 config.url = (config["url"] || obForm.getAttribute("action")); 21086 21087 var additionalData = (config["data"] || {}); 21088 config.data = BX.ajax.prepareForm(obForm).data; 21089 for (var ii in additionalData) 21090 { 21091 if (additionalData.hasOwnProperty(ii)) 21092 { 21093 config.data[ii] = additionalData[ii]; 21094 } 21095 } 21096 21097 if (!window["FormData"]) 21098 { 21099 BX.ajax(config); 21100 } 21101 else 21102 { 21103 var isFile = function(item) 21104 { 21105 var res = Object.prototype.toString.call(item); 21106 return (res == '[object File]' || res == '[object Blob]'); 21107 }, 21108 appendToForm = function(fd, key, val) 21109 { 21110 if (!!val && typeof val == "object" && !isFile(val)) 21111 { 21112 for (var ii in val) 21113 { 21114 if (val.hasOwnProperty(ii)) 21115 { 21116 appendToForm(fd, (key == '' ? ii : key + '[' + ii + ']'), val[ii]); 21117 } 21118 } 21119 } 21120 else 21121 fd.append(key, (!!val ? val : '')); 21122 }, 21123 prepareData = function(arData) 21124 { 21125 var data = {}; 21126 if (null != arData) 21127 { 21128 if(typeof arData == 'object') 21129 { 21130 for(var i in arData) 21131 { 21132 if (arData.hasOwnProperty(i)) 21133 { 21134 var name = BX.util.urlencode(i); 21135 if(typeof arData[i] == 'object' && arData[i]["file"] !== true) 21136 data[name] = prepareData(arData[i]); 21137 else if (arData[i]["file"] === true) 21138 data[name] = arData[i]["value"]; 21139 else 21140 data[name] = BX.util.urlencode(arData[i]); 21141 } 21142 } 21143 } 21144 else 21145 data = BX.util.urlencode(arData); 21146 } 21147 return data; 21148 }, 21149 fd = new window.FormData(); 21150 21151 if (config.method !== 'POST') 21152 { 21153 config.data = BX.ajax.prepareData(config.data); 21154 if (config.data) 21155 { 21156 config.url += (config.url.indexOf('?') !== -1 ? "&" : "?") + config.data; 21157 config.data = ''; 21158 } 21159 } 21160 else 21161 { 21162 if (config.preparePost === true) 21163 config.data = prepareData(config.data); 21164 appendToForm(fd, '', config.data); 21165 config.data = fd; 21166 } 21167 21168 config.preparePost = false; 21169 config.start = false;
21170 21171 var xhr = BX.ajax(config); 21172 if (!!config["onprogress"]) 21173 xhr.upload.addEventListener( 21174 'progress', 21175 function(e){ 21176 var percent = null; 21177 if(e.lengthComputable && (e.total || e["totalSize"])) { 21178 percent = e.loaded * 100 / (e.total || e["totalSize"]); 21179 } 21180 config["onprogress"](e, percent); 21181 } 21182 ); 21183 xhr.send(fd); 21184 } 21185}; 21186 21187BX.ajax.UpdatePageData = function (arData) 21188{ 21189 if (arData.TITLE) 21190 BX.ajax.UpdatePageTitle(arData.TITLE); 21191 if (arData.WINDOW_TITLE || arData.TITLE) 21192 BX.ajax.UpdateWindowTitle(arData.WINDOW_TITLE || arData.TITLE); 21193 if (arData.NAV_CHAIN) 21194 BX.ajax.UpdatePageNavChain(arData.NAV_CHAIN); 21195 if (arData.CSS && arData.CSS.length > 0) 21196 BX.loadCSS(arData.CSS); 21197 if (arData.SCRIPTS && arData.SCRIPTS.length > 0) 21198 { 21199 var f = function(result,config,cb){ 21200 21201 if(!!config && BX.type.isArray(config.scripts)) 21202 { 21203 for(var i=0,l=arData.SCRIPTS.length;i<l;i++) 21204 { 21205 config.scripts.push({isInternal:false,JS:arData.SCRIPTS[i]}); 21206 } 21207 } 21208 else 21209 { 21210 BX.loadScript(arData.SCRIPTS,cb); 21211 } 21212 21213 BX.removeCustomEvent('onAjaxSuccess',f); 21214 }; 21215 BX.addCustomEvent('onAjaxSuccess',f); 21216 } 21217 else 21218 { 21219 var f1 = function(result,config,cb){ 21220 if(BX.type.isFunction(cb)) 21221 { 21222 cb(); 21223 } 21224 BX.removeCustomEvent('onAjaxSuccess',f1); 21225 }; 21226 BX.addCustomEvent('onAjaxSuccess', f1); 21227 } 21228}; 21229 21230BX.ajax.UpdatePageTitle = function(title) 21231{ 21232 var obTitle = BX('pagetitle'); 21233 if (obTitle) 21234 { 21235 BX.remove(obTitle.firstChild); 21236 if (!obTitle.firstChild) 21237 obTitle.appendChild(document.createTextNode(title)); 21238 else 21239 obTitle.insertBefore(document.createTextNode(title), obTitle.firstChild); 21240 } 21241}; 21242 21243BX.ajax.UpdateWindowTitle = function(title) 21244{ 21245 document.title = title; 21246}; 21247 21248BX.ajax.UpdatePageNavChain = function(nav_chain) 21249{ 21250 var obNavChain = BX('navigation'); 21251 if (obNavChain) 21252 { 21253 obNavChain.innerHTML = nav_chain; 21254 } 21255}; 21256 21257/* user options handling */ 21258BX.userOptions = { 21259 options: null, 21260 bSend: false, 21261 delay: 5000, 21262 path: '/bitrix/admin/user_options.php?' 21263}; 21264 21265BX.userOptions.setAjaxPath = function(url) 21266{ 21267 BX.userOptions.path = url.indexOf('?') == -1? url+'?': url+'&'; 21268} 21269BX.userOptions.save = function(sCategory, sName, sValName, sVal, bCommon) 21270{ 21271 if (null == BX.userOptions.options) 21272 BX.userOptions.options = {}; 21273 21274 bCommon = !!bCommon; 21275 BX.userOptions.options[sCategory+'.'+sName+'.'+sValName] = [sCategory, sName, sValName, sVal, bCommon]; 21276 21277 var sParam = BX.userOptions.__get(); 21278 if (sParam != '') 21279 document.cookie = BX.message('COOKIE_PREFIX')+"_LAST_SETTINGS=" + encodeURIComponent(sParam) + "&sessid="+BX.bitrix_sessid()+"; expires=Thu, 31 Dec " + ((new Date()).getFullYear() + 1) + " 23:59:59 GMT; path=/;"; 21280 21281 if(!BX.userOptions.bSend) 21282 { 21283 BX.userOptions.bSend = true; 21284 setTimeout(function(){BX.userOptions.send(null)}, BX.userOptions.delay); 21285 } 21286}; 21287 21288BX.userOptions.send = function(callback) 21289{ 21290 var sParam = BX.userOptions.__get(); 21291 BX.userOptions.options = null; 21292 BX.userOptions.bSend = false; 21293 21294 if (sParam != '') 21295 { 21296 document.cookie = BX.message('COOKIE_PREFIX') + "_LAST_SETTINGS=; path=/;"; 21297 BX.ajax({ 21298 'method': 'GET', 21299 'dataType': 'html', 21300 'processData': false, 21301 'cache': false, 21302 'url': BX.userOptions.path+sParam+'&sessid='+BX.bitrix_sessid(), 21303 'onsuccess': callback 21304 }); 21305 } 21306}; 21307 21308BX.userOptions.del = function(sCategory, sName, bCommon, callback) 21309{ 21310 BX.ajax.get(BX.userOptions.path+'action=delete&c='+sCategory+'&n='+sName+(bCommon == true? '&common=Y':'')+'&sessid='+BX.bitrix_sessid(), callback); 21311}; 21312 21313BX.userOptions.__get = function() 21314{ 21315 if (!BX.userOptions.options) return ''; 21316 21317 var sParam = '', n = -1, prevParam = '', aOpt, i; 21318 21319 for (i in BX.userOptions.options) 21320 { 21321 if(BX.userOptions.options.hasOwnProperty(i)) 21322 { 21323 aOpt = BX.userOptions.options[i]; 21324 21325 if (prevParam != aOpt[0]+'.'+aOpt[1]) 21326 { 21327 n++; 21328 sParam += '&p['+n+'][c]='+BX.util.urlencode(aOpt[0]); 21329 sParam += '&p['+n+'][n]='+BX.util.urlencode(aOpt[1]); 21330 if (aOpt[4] == true) 21331 sParam += '&p['+n+'][d]=Y'; 21332 prevParam = aOpt[0]+'.'+aOpt[1]; 21333 } 21334 21335 var valueName = aOpt[2]; 21336 var value = aOpt[3]; 21337 21338 if (valueName === null) 21339 { 21340 sParam += '&p['+n+'][v]='+BX.util.urlencode(value); 21341 } 21342 else 21343 {
21344 sParam += '&p['+n+'][v]['+BX.util.urlencode(valueName)+']='+BX.util.urlencode(value); 21345 } 21346 } 21347 } 21348 21349 return sParam.substr(1); 21350}; 21351 21352BX.ajax.history = { 21353 expected_hash: '', 21354 21355 obParams: null, 21356 21357 obFrame: null, 21358 obImage: null, 21359 21360 obTimer: null, 21361 21362 bInited: false, 21363 bHashCollision: false, 21364 bPushState: !!(history.pushState && BX.type.isFunction(history.pushState)), 21365 21366 startState: null, 21367 21368 init: function(obParams) 21369 { 21370 if (BX.ajax.history.bInited) 21371 return; 21372 21373 this.obParams = obParams; 21374 var obCurrentState = this.obParams.getState(); 21375 21376 if (BX.ajax.history.bPushState) 21377 { 21378 BX.ajax.history.expected_hash = window.location.pathname; 21379 if (window.location.search) 21380 BX.ajax.history.expected_hash += window.location.search; 21381 21382 BX.ajax.history.put(obCurrentState, BX.ajax.history.expected_hash, '', true); 21383 // due to some strange thing, chrome calls popstate event on page start. so we should delay it 21384 setTimeout(function(){BX.bind(window, 'popstate', BX.ajax.history.__hashListener);}, 500); 21385 } 21386 else 21387 { 21388 BX.ajax.history.expected_hash = window.location.hash; 21389 21390 if (!BX.ajax.history.expected_hash || BX.ajax.history.expected_hash == '#') 21391 BX.ajax.history.expected_hash = '__bx_no_hash__'; 21392 21393 jsAjaxHistoryContainer.put(BX.ajax.history.expected_hash, obCurrentState); 21394 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 21395 21396 if (BX.browser.IsIE()) 21397 { 21398 BX.ajax.history.obFrame = document.createElement('IFRAME'); 21399 BX.hide_object(BX.ajax.history.obFrame); 21400 21401 document.body.appendChild(BX.ajax.history.obFrame); 21402 21403 BX.ajax.history.obFrame.contentWindow.document.open(); 21404 BX.ajax.history.obFrame.contentWindow.document.write(BX.ajax.history.expected_hash); 21405 BX.ajax.history.obFrame.contentWindow.document.close(); 21406 } 21407 else if (BX.browser.IsOpera()) 21408 { 21409 BX.ajax.history.obImage = document.createElement('IMG'); 21410 BX.hide_object(BX.ajax.history.obImage); 21411 21412 document.body.appendChild(BX.ajax.history.obImage); 21413 21414 BX.ajax.history.obImage.setAttribute('src', 'javascript:location.href = \'javascript:BX.ajax.history.__hashListener();\';'); 21415 } 21416 } 21417 21418 BX.ajax.history.bInited = true; 21419 }, 21420 21421 __hashListener: function(e) 21422 { 21423 e = e || window.event || {state:false}; 21424 21425 if (BX.ajax.history.bPushState) 21426 { 21427 BX.ajax.history.obParams.setState(e.state||BX.ajax.history.startState); 21428 } 21429 else 21430 { 21431 if (BX.ajax.history.obTimer) 21432 { 21433 window.clearTimeout(BX.ajax.history.obTimer); 21434 BX.ajax.history.obTimer = null; 21435 } 21436 21437 var current_hash; 21438 if (null != BX.ajax.history.obFrame) 21439 current_hash = BX.ajax.history.obFrame.contentWindow.document.body.innerText; 21440 else 21441 current_hash = window.location.hash; 21442 21443 if (!current_hash || current_hash == '#') 21444 current_hash = '__bx_no_hash__'; 21445 21446 if (current_hash.indexOf('#') == 0) 21447 current_hash = current_hash.substring(1); 21448 21449 if (current_hash != BX.ajax.history.expected_hash) 21450 { 21451 var state = jsAjaxHistoryContainer.get(current_hash); 21452 if (state) 21453 { 21454 BX.ajax.history.obParams.setState(state); 21455 21456 BX.ajax.history.expected_hash = current_hash; 21457 if (null != BX.ajax.history.obFrame) 21458 { 21459 var __hash = current_hash == '__bx_no_hash__' ? '' : current_hash; 21460 if (window.location.hash != __hash && window.location.hash != '#' + __hash) 21461 window.location.hash = __hash; 21462 } 21463 } 21464 } 21465 21466 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 21467 } 21468 }, 21469 21470 put: function(state, new_hash, new_hash1, bStartState) 21471 { 21472 if (this.bPushState) 21473 { 21474 if(!bStartState) 21475 { 21476 history.pushState(state, '', new_hash); 21477 } 21478 else 21479 { 21480 BX.ajax.history.startState = state; 21481 } 21482 } 21483 else 21484 { 21485 if (typeof new_hash1 != 'undefined') 21486 new_hash = new_hash1; 21487 else 21488 new_hash = 'view' + new_hash; 21489 21490 jsAjaxHistoryContainer.put(new_hash, state); 21491 BX.ajax.history.expected_hash = new_hash; 21492 21493 window.location.hash = BX.util.urlencode(new_hash); 21494 21495 if (null != BX.ajax.history.obFrame) 21496 { 21497 BX.ajax.history.obFrame.contentWindow.document.open(); 21498 BX.ajax.history.obFrame.contentWindow.document.write(new_hash); 21499 BX.ajax.history.obFrame.contentWindow.document.close(); 21500 } 21501 } 21502 }, 21503 21504 checkRedirectStart: function(param_name, param_value) 21505 { 21506 var current_hash = window.location.hash; 21507 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 21508 21509 var test = current_hash.substring(0, 5); 21510 if (test == 'view/' || test == 'view%') 21511 { 21512 BX.ajax.history.bHashCollision = true;
21513 document.write('<' + 'div id="__ajax_hash_collision_' + param_value + '" style="display: none;">'); 21514 } 21515 }, 21516 21517 checkRedirectFinish: function(param_name, param_value) 21518 { 21519 document.write('</div>'); 21520 21521 var current_hash = window.location.hash; 21522 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 21523 21524 BX.ready(function () 21525 { 21526 var test = current_hash.substring(0, 5); 21527 if (test == 'view/' || test == 'view%') 21528 { 21529 var obColNode = BX('__ajax_hash_collision_' + param_value); 21530 var obNode = obColNode.firstChild; 21531 BX.cleanNode(obNode); 21532 obColNode.style.display = 'block'; 21533 21534 // IE, Opera and Chrome automatically modifies hash with urlencode, but FF doesn't ;-( 21535 if (test != 'view%') 21536 current_hash = BX.util.urlencode(current_hash); 21537 21538 current_hash += (current_hash.indexOf('%3F') == -1 ? '%3F' : '%26') + param_name + '=' + param_value; 21539 21540 var url = '/bitrix/tools/ajax_redirector.php?hash=' + current_hash; 21541 21542 BX.ajax.insertToNode(url, obNode); 21543 } 21544 }); 21545 } 21546}; 21547 21548BX.ajax.component = function(node) 21549{ 21550 this.node = node; 21551}; 21552 21553BX.ajax.component.prototype.getState = function() 21554{ 21555 var state = { 21556 'node': this.node, 21557 'title': window.document.title, 21558 'data': BX(this.node).innerHTML 21559 }; 21560 21561 var obNavChain = BX('navigation'); 21562 if (null != obNavChain) 21563 state.nav_chain = obNavChain.innerHTML; 21564 21565 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistoryGetState", [state]); 21566 21567 return state; 21568}; 21569 21570BX.ajax.component.prototype.setState = function(state) 21571{ 21572 BX(state.node).innerHTML = state.data; 21573 BX.ajax.UpdatePageTitle(state.title); 21574 21575 if (state.nav_chain) 21576 { 21577 BX.ajax.UpdatePageNavChain(state.nav_chain); 21578 } 21579 21580 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistorySetState", [state]); 21581}; 21582 21583var jsAjaxHistoryContainer = { 21584 arHistory: {}, 21585 21586 put: function(hash, state) 21587 { 21588 this.arHistory[hash] = state; 21589 }, 21590 21591 get: function(hash) 21592 { 21593 return this.arHistory[hash]; 21594 } 21595}; 21596 21597 21598BX.ajax.FormData = function() 21599{ 21600 this.elements = []; 21601 this.files = []; 21602 this.features = {}; 21603 this.isSupported(); 21604 this.log('BX FormData init'); 21605}; 21606 21607BX.ajax.FormData.isSupported = function() 21608{ 21609 var f = new BX.ajax.FormData(); 21610 var result = f.features.supported; 21611 f = null; 21612 return result; 21613}; 21614 21615BX.ajax.FormData.prototype.log = function(o) 21616{ 21617 if (false) { 21618 try { 21619 if (BX.browser.IsIE()) o = JSON.stringify(o); 21620 console.log(o); 21621 } catch(e) {} 21622 } 21623}; 21624 21625BX.ajax.FormData.prototype.isSupported = function() 21626{ 21627 var f = {}; 21628 f.fileReader = (window.FileReader && window.FileReader.prototype.readAsBinaryString); 21629 f.readFormData = f.sendFormData = !!(window.FormData); 21630 f.supported = !!(f.readFormData && f.sendFormData); 21631 this.features = f; 21632 this.log('features:'); 21633 this.log(f); 21634 21635 return f.supported; 21636}; 21637 21638BX.ajax.FormData.prototype.append = function(name, value) 21639{ 21640 if (typeof(value) === 'object') { // seems to be files element 21641 this.files.push({'name': name, 'value':value}); 21642 } else { 21643 this.elements.push({'name': name, 'value':value}); 21644 } 21645}; 21646 21647BX.ajax.FormData.prototype.send = function(url, callbackOk, callbackProgress, callbackError) 21648{ 21649 this.log('FD send'); 21650 this.xhr = BX.ajax({ 21651 'method': 'POST', 21652 'dataType': 'html', 21653 'url': url, 21654 'onsuccess': callbackOk, 21655 'onfailure': callbackError, 21656 'start': false, 21657 'preparePost':false 21658 }); 21659 21660 if (callbackProgress) 21661 { 21662 this.xhr.upload.addEventListener( 21663 'progress', 21664 function(e) { 21665 if (e.lengthComputable) 21666 callbackProgress(e.loaded / (e.total || e.totalSize)); 21667 }, 21668 false 21669 ); 21670 } 21671 21672 if (this.features.readFormData && this.features.sendFormData) 21673 { 21674 var fd = new FormData(); 21675 this.log('use browser formdata'); 21676 for (var i in this.elements) 21677 { 21678 if(this.elements.hasOwnProperty(i)) 21679 fd.append(this.elements[i].name,this.elements[i].value); 21680 } 21681 for (i in this.files) 21682 { 21683 if(this.files.hasOwnProperty(i)) 21684 fd.append(this.files[i].name, this.files[i].value); 21685 } 21686 this.xhr.send(fd); 21687 } 21688 21689 return this.xhr; 21690}; 21691 21692BX.addCustomEvent('onAjaxFailure', BX.debug); 21693})(window); 21694 21695 21696 21697(function (exports,main_core) { 21698 'use strict'; 21699 21700 var LazyLoad = { 21701 observer: null, 21702 images: {}, 21703 imageStatus: { 21704 hidden: -2, 21705 error: -1, 21706 "undefined": 0, 21707 inited: 1, 21708 loaded: 2 21709 }, 21710 imageTypes: { 21711 image: 1, 21712 background: 2 21713 },
21714 initObserver: function initObserver() { 21715 this.observer = new IntersectionObserver(this.onIntersection.bind(this), { 21716 rootMargin: '20% 0% 20% 0%', 21717 threshold: 0.10 21718 }); 21719 }, 21720 onIntersection: function onIntersection(entries) { 21721 entries.forEach(function (entry) { 21722 if (entry.isIntersecting) { 21723 this.showImage(entry.target); 21724 } 21725 }.bind(this)); 21726 }, 21727 registerImage: function registerImage(id, isImageVisibleCallback, options) { 21728 if (this.observer === null) { 21729 this.initObserver(); 21730 } 21731 21732 options = options || {}; 21733 21734 if (!main_core.Type.isStringFilled(id)) { 21735 return; 21736 } 21737 21738 if (main_core.Type.isObject(this.images[id])) { 21739 return; 21740 } 21741 21742 var element = document.getElementById(id); 21743 21744 if (!main_core.Type.isDomNode(element)) { 21745 return; 21746 } 21747 21748 this.observer.observe(element); 21749 this.images[id] = { 21750 id: id, 21751 node: null, 21752 src: null, 21753 dataSrcName: options.dataSrcName || 'src', 21754 type: null, 21755 func: main_core.Type.isFunction(isImageVisibleCallback) ? isImageVisibleCallback : null, 21756 status: this.imageStatus.undefined 21757 }; 21758 }, 21759 registerImages: function registerImages(ids, isImageVisibleCallback, options) { 21760 if (main_core.Type.isArray(ids)) { 21761 for (var i = 0, length = ids.length; i < length; i++) { 21762 this.registerImage(ids[i], isImageVisibleCallback, options); 21763 } 21764 } 21765 }, 21766 showImage: function showImage(imageNode) { 21767 var imageNodeId = imageNode.id; 21768 21769 if (!main_core.Type.isStringFilled(imageNodeId)) { 21770 return; 21771 } 21772 21773 var image = this.images[imageNodeId]; 21774 21775 if (!main_core.Type.isPlainObject(image)) { 21776 return; 21777 } 21778 21779 if (image.status == this.imageStatus.undefined) { 21780 this.initImage(image); 21781 } 21782 21783 if (image.status !== this.imageStatus.inited) { 21784 return; 21785 } 21786 21787 if (!image.node || !image.node.parentNode) { 21788 image.node = null; 21789 image.status = this.imageStatus.error; 21790 return; 21791 } 21792 21793 if (image.type == this.imageTypes.image) { 21794 image.node.src = image.src; 21795 } else { 21796 image.node.style.backgroundImage = "url('" + image.src + "')"; 21797 } 21798 21799 image.node.dataset[image.dataSrcName] = ""; 21800 image.status = this.imageStatus.loaded; 21801 }, 21802 showImages: function showImages(checkOwnVisibility) { 21803 checkOwnVisibility = checkOwnVisibility !== false; 21804 21805 for (var id in this.images) { 21806 if (!this.images.hasOwnProperty(id)) { 21807 continue; 21808 } 21809 21810 var image = this.images[id]; 21811 21812 if (image.status == this.imageStatus.undefined) { 21813 this.initImage(image); 21814 } 21815 21816 if (image.status !== this.imageStatus.inited) { 21817 continue; 21818 } 21819 21820 if (!image.node || !image.node.parentNode) { 21821 image.node = null; 21822 image.status = this.imageStatus.error; 21823 continue; 21824 } 21825 21826 var isImageVisible = true; 21827 21828 if (checkOwnVisibility && main_core.Type.isFunction(image.func)) { 21829 isImageVisible = image.func(image); 21830 } 21831 21832 if (isImageVisible === true && this.isElementVisibleOnScreen(image.node)) { 21833 if (image.type == this.imageTypes.image) { 21834 image.node.src = image.src; 21835 } else { 21836 image.node.style.backgroundImage = "url('" + image.src + "')"; 21837 } 21838 21839 image.node.dataset[image.dataSrcName] = ""; 21840 image.status = this.imageStatus.loaded; 21841 } 21842 } 21843 }, 21844 initImage: function initImage(image) { 21845 image.status = this.imageStatus.error; 21846 var node = document.getElementById(image.id); 21847 21848 if (!main_core.Type.isDomNode(node)) { 21849 return; 21850 } 21851 21852 var src = node.dataset[image.dataSrcName]; 21853 21854 if (main_core.Type.isStringFilled(src)) { 21855 image.node = node; 21856 image.src = src; 21857 image.status = this.imageStatus.inited; 21858 image.type = image.node.tagName.toLowerCase() == "img" ? this.imageTypes.image : this.imageTypes.background; 21859 } 21860 }, 21861 isElementVisibleOnScreen: function isElementVisibleOnScreen(element) { 21862 var coords = this.getElementCoords(element); 21863 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 21864 var windowBottom = windowTop + document.documentElement.clientHeight; 21865 coords.bottom = coords.top + element.offsetHeight; 21866 return coords.top > windowTop && coords.top < windowBottom || // topVisible 21867 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 21868 ; 21869 }, 21870 isElementVisibleOn2Screens: function isElementVisibleOn2Screens(element) { 21871 var windowHeight = document.documentElement.clientHeight; 21872 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 21873 var windowBottom = windowTop + windowHeight; 21874 var coords = this.getElementCoords(element); 21875 coords.bottom = coords.top + element.offsetHeight; 21876 windowTop -= windowHeight; 21877 windowBottom += windowHeight; 21878 return coords.top > windowTop && coords.top < windowBottom || // topVisible 21879 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 21880 ; 21881 }, 21882 getElementCoords: function getElementCoords(element) { 21883 var box = element.getBoundingClientRect(); 21884 return { 21885 originTop: box.top, 21886 originLeft: box.left, 21887 top: box.top + window.pageYOffset, 21888 left: box.left + window.pageXOffset 21889 }; 21890 }, 21891 onScroll: function onScroll() {}, 21892 clearImages: function clearImages() { 21893 this.images = []; 21894 } 21895 }; 21896 21897 exports.LazyLoad = LazyLoad; 21898 21899}((this.BX = this.BX || {}),BX)); 21900 21901 21902 21903(function (exports) { 21904 'use strict'; 21905 21906 var ParamBag = /*#__PURE__*/function () { 21907 function ParamBag() { 21908 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 21909 babelHelpers.classCallCheck(this, ParamBag); 21910 21911 if (!!params && babelHelpers.typeof(params) === 'object') { 21912 this.params = new Map(Object.entries(params)); 21913 } else { 21914 this.params = new Map(); 21915 } 21916 } 21917 21918 babelHelpers.createClass(ParamBag, [{ 21919 key: "getParam", 21920 value: function getParam(key) { 21921 var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 21922 21923 if (this.params.has(key)) { 21924 return this.params.get(key); 21925 } 21926 21927 return defaultValue; 21928 } 21929 }, { 21930 key: "setParam", 21931 value: function setParam(key, value) { 21932 this.params.set(key, value); 21933 } 21934 }, { 21935 key: "clear", 21936 value: function clear() { 21937 this.params.clear(); 21938 } 21939 }], [{ 21940 key: "create", 21941 value: function create() { 21942 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 21943 return new ParamBag(params); 21944 } 21945 }]); 21946 return ParamBag; 21947 }(); 21948 21949 exports.ParamBag = ParamBag; 21950 21951}((this.BX = this.BX || {}))); 21952 21953 21954 21955(function() { 21956 BX.FixFontSize = function(params) 21957 { 21958 var widthNode, computedStyles, width; 21959 21960 this.node = null; 21961 this.prevWindowSize = 0; 21962 this.prevWrapperSize = 0; 21963 this.mainWrapper = null; 21964 this.textWrapper = null; 21965 this.objList = params.objList; 21966 this.minFontSizeList = []; 21967 this.minFontSize = 0; 21968 21969 if (params.onresize) 21970 { 21971 this.prevWindowSize = window.innerWidth || document.documentElement.clientWidth; 21972 BX.bind(window, 'resize', BX.throttle(this.onResize, 350, this)); 21973 } 21974 21975 if (params.onAdaptiveResize) 21976 { 21977 widthNode = this.objList[0].scaleBy || this.objList[0].node; 21978 computedStyles = getComputedStyle(widthNode); 21979 this.prevWrapperSize = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 21980 BX.bind(window, 'resize', BX.throttle(this.onAdaptiveResize, 350, this)); 21981 } 21982 21983 this.createTestNodes(); 21984 this.decrease(); 21985 }; 21986 21987 BX.FixFontSize.prototype = 21988 { 21989 createTestNodes: function() 21990 { 21991 this.textWrapper = BX.create('div',{ 21992 style : { 21993 display : 'inline-block', 21994 whiteSpace : 'nowrap' 21995 } 21996 }); 21997 21998 this.mainWrapper = BX.create('div',{ 21999 style : { 22000 height : 0, 22001 overflow : 'hidden' 22002 }, 22003 children : [this.textWrapper] 22004 }); 22005 22006 }, 22007 insertTestNodes: function() 22008 { 22009 document.body.appendChild(this.mainWrapper); 22010 }, 22011 removeTestNodes: function() 22012 { 22013 document.body.removeChild(this.mainWrapper); 22014 }, 22015 decrease: function() 22016 { 22017 var width, 22018 fontSize, 22019 widthNode, 22020 computedStyles; 22021 22022 this.insertTestNodes(); 22023
22024 for(var i=this.objList.length-1; i>=0; i--) 22025 { 22026 widthNode = this.objList[i].scaleBy || this.objList[i].node; 22027 computedStyles = getComputedStyle(widthNode); 22028 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 22029 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 22030 22031 this.textWrapperSetStyle(this.objList[i].node); 22032 22033 if(this.textWrapperInsertText(this.objList[i].node)) 22034 { 22035 while(this.textWrapper.offsetWidth > width && fontSize > 0) 22036 { 22037 this.textWrapper.style.fontSize = --fontSize + 'px'; 22038 } 22039 22040 if(this.objList[i].smallestValue) 22041 { 22042 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 22043 22044 this.minFontSizeList.push(this.objList[i].node) 22045 } 22046 else 22047 { 22048 this.objList[i].node.style.fontSize = fontSize + 'px'; 22049 } 22050 } 22051 } 22052 22053 if(this.minFontSizeList.length > 0) 22054 this.setMinFont(); 22055 22056 this.removeTestNodes(); 22057 22058 }, 22059 increase: function() 22060 { 22061 this.insertTestNodes(); 22062 var width, 22063 fontSize, 22064 widthNode, 22065 computedStyles; 22066 22067 this.insertTestNodes(); 22068 22069 for(var i=this.objList.length-1; i>=0; i--) 22070 { 22071 widthNode = this.objList[i].scaleBy || this.objList[i].node; 22072 computedStyles = getComputedStyle(widthNode); 22073 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 22074 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 22075 22076 this.textWrapperSetStyle(this.objList[i].node); 22077 22078 if(this.textWrapperInsertText(this.objList[i].node)) 22079 { 22080 while(this.textWrapper.offsetWidth < width && fontSize < this.objList[i].maxFontSize) 22081 { 22082 this.textWrapper.style.fontSize = ++fontSize + 'px'; 22083 } 22084 22085 fontSize--; 22086 22087 if(this.objList[i].smallestValue) 22088 { 22089 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 22090 22091 this.minFontSizeList.push(this.objList[i].node) 22092 } 22093 else 22094 { 22095 this.objList[i].node.style.fontSize = fontSize + 'px'; 22096 } 22097 } 22098 } 22099 22100 if(this.minFontSizeList.length > 0) 22101 this.setMinFont(); 22102 22103 this.removeTestNodes(); 22104 }, 22105 setMinFont : function() 22106 { 22107 for(var i = this.minFontSizeList.length-1; i>=0; i--) 22108 { 22109 this.minFontSizeList[i].style.fontSize = this.minFontSize + 'px'; 22110 } 22111 22112 this.minFontSize = 0; 22113 }, 22114 onResize : function() 22115 { 22116 var width = window.innerWidth || document.documentElement.clientWidth; 22117 22118 if(this.prevWindowSize > width) 22119 this.decrease(); 22120 22121 else if (this.prevWindowSize < width) 22122 this.increase(); 22123 22124 this.prevWindowSize = width; 22125 }, 22126 onAdaptiveResize : function() 22127 { 22128 var widthNode = this.objList[0].scaleBy || this.objList[0].node, 22129 computedStyles = getComputedStyle(widthNode), 22130 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 22131 22132 if (this.prevWrapperSize > width) 22133 this.decrease(); 22134 else if (this.prevWrapperSize < width) 22135 this.increase(); 22136 22137 this.prevWrapperSize = width; 22138 }, 22139 textWrapperInsertText : function(node) 22140 { 22141 if(node.textContent){ 22142 this.textWrapper.textContent = node.textContent; 22143 return true; 22144 } 22145 else if(node.innerText) 22146 { 22147 this.textWrapper.innerText = node.innerText; 22148 return true; 22149 } 22150 else { 22151 return false; 22152 } 22153 }, 22154 textWrapperSetStyle : function(node) 22155 { 22156 this.textWrapper.style.fontFamily = getComputedStyle(node)["font-family"]; 22157 this.textWrapper.style.fontSize = getComputedStyle(node)["font-size"]; 22158 this.textWrapper.style.fontStyle = getComputedStyle(node)["font-style"]; 22159 this.textWrapper.style.fontWeight = getComputedStyle(node)["font-weight"]; 22160 this.textWrapper.style.lineHeight = getComputedStyle(node)["line-height"]; 22161 } 22162 }; 22163 22164 BX.FixFontSize.init = function(params) 22165 { 22166 return new BX.FixFontSize(params); 22167 }; 22168})(); 22169 22170})(); 22171//# sourceMappingURL=core.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.