1/* eslint-disable */ 2;(function() { 3 4 if (typeof window.BX === 'function') 5 { 6 return; 7 } 8 9/** 10 * Babel external helpers 11 * (c) 2018 Babel 12 * @license MIT 13 */ 14(function (global) { 15 var babelHelpers = global.babelHelpers = {}; 16 17 function _typeof(obj) { 18 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 19 babelHelpers.typeof = _typeof = function (obj) { 20 return typeof obj; 21 }; 22 } else { 23 babelHelpers.typeof = _typeof = function (obj) { 24 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 25 }; 26 } 27 28 return _typeof(obj); 29 } 30 31 babelHelpers.typeof = _typeof; 32 var REACT_ELEMENT_TYPE; 33 34 function _createRawReactElement(type, props, key, children) { 35 if (!REACT_ELEMENT_TYPE) { 36 REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; 37 } 38 39 var defaultProps = type && type.defaultProps; 40 var childrenLength = arguments.length - 3; 41 42 if (!props && childrenLength !== 0) { 43 props = { 44 children: void 0 45 }; 46 } 47 48 if (props && defaultProps) { 49 for (var propName in defaultProps) { 50 if (props[propName] === void 0) { 51 props[propName] = defaultProps[propName]; 52 } 53 } 54 } else if (!props) { 55 props = defaultProps || {}; 56 } 57 58 if (childrenLength === 1) { 59 props.children = children; 60 } else if (childrenLength > 1) { 61 var childArray = new Array(childrenLength); 62 63 for (var i = 0; i < childrenLength; i++) { 64 childArray[i] = arguments[i + 3]; 65 } 66 67 props.children = childArray; 68 } 69 70 return { 71 $$typeof: REACT_ELEMENT_TYPE, 72 type: type, 73 key: key === undefined ? null : '' + key, 74 ref: null, 75 props: props, 76 _owner: null 77 }; 78 } 79 80 babelHelpers.jsx = _createRawReactElement; 81 82 function _asyncIterator(iterable) { 83 var method; 84 85 if (typeof Symbol === "function") { 86 if (Symbol.asyncIterator) { 87 method = iterable[Symbol.asyncIterator]; 88 if (method != null) return method.call(iterable); 89 } 90 91 if (Symbol.iterator) { 92 method = iterable[Symbol.iterator]; 93 if (method != null) return method.call(iterable); 94 } 95 } 96 97 throw new TypeError("Object is not async iterable"); 98 } 99 100 babelHelpers.asyncIterator = _asyncIterator; 101 102 function _AwaitValue(value) { 103 this.wrapped = value; 104 } 105 106 babelHelpers.AwaitValue = _AwaitValue; 107 108 function AsyncGenerator(gen) { 109 var front, back; 110 111 function send(key, arg) { 112 return new Promise(function (resolve, reject) { 113 var request = { 114 key: key, 115 arg: arg, 116 resolve: resolve, 117 reject: reject, 118 next: null 119 }; 120 121 if (back) { 122 back = back.next = request; 123 } else { 124 front = back = request; 125 resume(key, arg); 126 } 127 }); 128 } 129 130 function resume(key, arg) { 131 try { 132 var result = gen[key](arg); 133 var value = result.value; 134 var wrappedAwait = value instanceof babelHelpers.AwaitValue; 135 Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { 136 if (wrappedAwait) { 137 resume("next", arg); 138 return; 139 } 140 141 settle(result.done ? "return" : "normal", arg); 142 }, function (err) { 143 resume("throw", err); 144 }); 145 } catch (err) { 146 settle("throw", err); 147 } 148 } 149 150 function settle(type, value) { 151 switch (type) { 152 case "return": 153 front.resolve({ 154 value: value, 155 done: true 156 }); 157 break; 158 159 case "throw": 160 front.reject(value); 161 break; 162 163 default: 164 front.resolve({ 165 value: value, 166 done: false 167 }); 168 break; 169 } 170 171 front = front.next; 172 173 if (front) { 174 resume(front.key, front.arg); 175 } else { 176 back = null; 177 } 178 } 179 180 this._invoke = send; 181 182 if (typeof gen.return !== "function") { 183 this.return = undefined; 184 } 185 } 186 187 if (typeof Symbol === "function" && Symbol.asyncIterator) { 188 AsyncGenerator.prototype[Symbol.asyncIterator] = function () { 189 return this; 190 }; 191 } 192 193 AsyncGenerator.prototype.next = function (arg) { 194 return this._invoke("next", arg); 195 }; 196 197 AsyncGenerator.prototype.throw = function (arg) { 198 return this._invoke("throw", arg); 199 }; 200 201 AsyncGenerator.prototype.return = function (arg) { 202 return this._invoke("return", arg); 203 }; 204 205 babelHelpers.AsyncGenerator = AsyncGenerator; 206 207 function _wrapAsyncGenerator(fn) { 208 return function () { 209 return new babelHelpers.AsyncGenerator(fn.apply(this, arguments)); 210 }; 211 } 212 213 babelHelpers.wrapAsyncGenerator = _wrapAsyncGenerator; 214 215 function _awaitAsyncGenerator(value) { 216 return new babelHelpers.AwaitValue(value); 217 } 218 219 babelHelpers.awaitAsyncGenerator = _awaitAsyncGenerator; 220 221 function _asyncGeneratorDelegate(inner, awaitWrap) { 222 var iter = {}, 223 waiting = false;
224 225 function pump(key, value) { 226 waiting = true; 227 value = new Promise(function (resolve) { 228 resolve(inner[key](value)); 229 }); 230 return { 231 done: false, 232 value: awaitWrap(value) 233 }; 234 } 235 236 ; 237 238 if (typeof Symbol === "function" && Symbol.iterator) { 239 iter[Symbol.iterator] = function () { 240 return this; 241 }; 242 } 243 244 iter.next = function (value) { 245 if (waiting) { 246 waiting = false; 247 return value; 248 } 249 250 return pump("next", value); 251 }; 252 253 if (typeof inner.throw === "function") { 254 iter.throw = function (value) { 255 if (waiting) { 256 waiting = false; 257 throw value; 258 } 259 260 return pump("throw", value); 261 }; 262 } 263 264 if (typeof inner.return === "function") { 265 iter.return = function (value) { 266 return pump("return", value); 267 }; 268 } 269 270 return iter; 271 } 272 273 babelHelpers.asyncGeneratorDelegate = _asyncGeneratorDelegate; 274 275 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { 276 try { 277 var info = gen[key](arg); 278 var value = info.value; 279 } catch (error) { 280 reject(error); 281 return; 282 } 283 284 if (info.done) { 285 resolve(value); 286 } else { 287 Promise.resolve(value).then(_next, _throw); 288 } 289 } 290 291 function _asyncToGenerator(fn) { 292 return function () { 293 var self = this, 294 args = arguments; 295 return new Promise(function (resolve, reject) { 296 var gen = fn.apply(self, args); 297 298 function _next(value) { 299 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); 300 } 301 302 function _throw(err) { 303 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); 304 } 305 306 _next(undefined); 307 }); 308 }; 309 } 310 311 babelHelpers.asyncToGenerator = _asyncToGenerator; 312 313 function _classCallCheck(instance, Constructor) { 314 if (!(instance instanceof Constructor)) { 315 throw new TypeError("Cannot call a class as a function"); 316 } 317 } 318 319 babelHelpers.classCallCheck = _classCallCheck; 320 321 function _defineProperties(target, props) { 322 for (var i = 0; i < props.length; i++) { 323 var descriptor = props[i]; 324 descriptor.enumerable = descriptor.enumerable || false; 325 descriptor.configurable = true; 326 if ("value" in descriptor) descriptor.writable = true; 327 Object.defineProperty(target, descriptor.key, descriptor); 328 } 329 } 330 331 function _createClass(Constructor, protoProps, staticProps) { 332 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 333 if (staticProps) _defineProperties(Constructor, staticProps); 334 return Constructor; 335 } 336 337 babelHelpers.createClass = _createClass; 338 339 function _defineEnumerableProperties(obj, descs) { 340 for (var key in descs) { 341 var desc = descs[key]; 342 desc.configurable = desc.enumerable = true; 343 if ("value" in desc) desc.writable = true; 344 Object.defineProperty(obj, key, desc); 345 } 346 347 if (Object.getOwnPropertySymbols) { 348 var objectSymbols = Object.getOwnPropertySymbols(descs); 349 350 for (var i = 0; i < objectSymbols.length; i++) { 351 var sym = objectSymbols[i]; 352 var desc = descs[sym]; 353 desc.configurable = desc.enumerable = true; 354 if ("value" in desc) desc.writable = true; 355 Object.defineProperty(obj, sym, desc); 356 } 357 } 358 359 return obj; 360 } 361 362 babelHelpers.defineEnumerableProperties = _defineEnumerableProperties; 363 364 function _defaults(obj, defaults) { 365 var keys = Object.getOwnPropertyNames(defaults); 366 367 for (var i = 0; i < keys.length; i++) { 368 var key = keys[i]; 369 var value = Object.getOwnPropertyDescriptor(defaults, key); 370 371 if (value && value.configurable && obj[key] === undefined) { 372 Object.defineProperty(obj, key, value); 373 } 374 } 375 376 return obj; 377 } 378 379 babelHelpers.defaults = _defaults; 380 381 function _defineProperty(obj, key, value) { 382 if (key in obj) { 383 Object.defineProperty(obj, key, { 384 value: value, 385 enumerable: true, 386 configurable: true, 387 writable: true 388 }); 389 } else { 390 obj[key] = value; 391 } 392 393 return obj; 394 } 395 396 babelHelpers.defineProperty = _defineProperty; 397 398 function _extends() { 399 babelHelpers.extends = _extends = Object.assign || function (target) { 400 for (var i = 1; i < arguments.length; i++) { 401 var source = arguments[i]; 402 403 for (var key in source) { 404 if (Object.prototype.hasOwnProperty.call(source, key)) { 405 target[key] = source[key]; 406 } 407 } 408 } 409 410 return target; 411 }; 412 413 return _extends.apply(this, arguments); 414 } 415 416 babelHelpers.extends = _extends; 417 418 function _objectSpread(target) { 419 for (var i = 1; i < arguments.length; i++) { 420 var source = arguments[i] != null ? arguments[i] : {}; 421 var ownKeys = Object.keys(source); 422 423 if (typeof Object.getOwnPropertySymbols === 'function') { 424 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { 425 return Object.getOwnPropertyDescriptor(source, sym).enumerable; 426 })); 427 } 428 429 ownKeys.forEach(function (key) { 430 babelHelpers.defineProperty(target, key, source[key]); 431 }); 432 } 433 434 return target; 435 } 436 437 babelHelpers.objectSpread = _objectSpread; 438 439 function _inherits(subClass, superClass) { 440 if (typeof superClass !== "function" && superClass !== null) { 441 throw new TypeError("Super expression must either be null or a function"); 442 } 443 444 subClass.prototype = Object.create(superClass && superClass.prototype, { 445 constructor: { 446 value: subClass, 447 writable: true, 448 configurable: true 449 } 450 }); 451 if (superClass) babelHelpers.setPrototypeOf(subClass, superClass); 452 } 453 454 babelHelpers.inherits = _inherits; 455 456 function _inheritsLoose(subClass, superClass) { 457 subClass.prototype = Object.create(superClass.prototype); 458 subClass.prototype.constructor = subClass; 459 subClass.__proto__ = superClass; 460 } 461 462 babelHelpers.inheritsLoose = _inheritsLoose; 463
464 function _getPrototypeOf(o) { 465 babelHelpers.getPrototypeOf = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { 466 return o.__proto__ || Object.getPrototypeOf(o); 467 }; 468 return _getPrototypeOf(o); 469 } 470 471 babelHelpers.getPrototypeOf = _getPrototypeOf; 472 473 function _setPrototypeOf(o, p) { 474 babelHelpers.setPrototypeOf = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { 475 o.__proto__ = p; 476 return o; 477 }; 478 479 return _setPrototypeOf(o, p); 480 } 481 482 babelHelpers.setPrototypeOf = _setPrototypeOf; 483 484 function isNativeReflectConstruct() { 485 if (typeof Reflect === "undefined" || !Reflect.construct) return false; 486 if (Reflect.construct.sham) return false; 487 if (typeof Proxy === "function") return true; 488 489 try { 490 Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); 491 return true; 492 } catch (e) { 493 return false; 494 } 495 } 496 497 function _construct(Parent, args, Class) { 498 if (isNativeReflectConstruct()) { 499 babelHelpers.construct = _construct = Reflect.construct; 500 } else { 501 babelHelpers.construct = _construct = function _construct(Parent, args, Class) { 502 var a = [null]; 503 a.push.apply(a, args); 504 var Constructor = Function.bind.apply(Parent, a); 505 var instance = new Constructor(); 506 if (Class) babelHelpers.setPrototypeOf(instance, Class.prototype); 507 return instance; 508 }; 509 } 510 511 return _construct.apply(null, arguments); 512 } 513 514 babelHelpers.construct = _construct; 515 516 function _isNativeFunction(fn) { 517 return Function.toString.call(fn).indexOf("[native code]") !== -1; 518 } 519 520 babelHelpers.isNativeFunction = _isNativeFunction; 521 522 function _wrapNativeSuper(Class) { 523 var _cache = typeof Map === "function" ? new Map() : undefined; 524 525 babelHelpers.wrapNativeSuper = _wrapNativeSuper = function _wrapNativeSuper(Class) { 526 if (Class === null || !babelHelpers.isNativeFunction(Class)) return Class; 527 528 if (typeof Class !== "function") { 529 throw new TypeError("Super expression must either be null or a function"); 530 } 531 532 if (typeof _cache !== "undefined") { 533 if (_cache.has(Class)) return _cache.get(Class); 534 535 _cache.set(Class, Wrapper); 536 } 537 538 function Wrapper() { 539 return babelHelpers.construct(Class, arguments, babelHelpers.getPrototypeOf(this).constructor); 540 } 541 542 Wrapper.prototype = Object.create(Class.prototype, { 543 constructor: { 544 value: Wrapper, 545 enumerable: false, 546 writable: true, 547 configurable: true 548 } 549 }); 550 return babelHelpers.setPrototypeOf(Wrapper, Class); 551 }; 552 553 return _wrapNativeSuper(Class); 554 } 555 556 babelHelpers.wrapNativeSuper = _wrapNativeSuper; 557 558 function _instanceof(left, right) { 559 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { 560 return right[Symbol.hasInstance](left); 561 } else { 562 return left instanceof right; 563 } 564 } 565 566 babelHelpers.instanceof = _instanceof; 567 568 function _interopRequireDefault(obj) { 569 return obj && obj.__esModule ? obj : { 570 default: obj 571 }; 572 } 573 574 babelHelpers.interopRequireDefault = _interopRequireDefault; 575 576 function _interopRequireWildcard(obj) { 577 if (obj && obj.__esModule) { 578 return obj; 579 } else { 580 var newObj = {}; 581 582 if (obj != null) { 583 for (var key in obj) { 584 if (Object.prototype.hasOwnProperty.call(obj, key)) { 585 var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; 586 587 if (desc.get || desc.set) { 588 Object.defineProperty(newObj, key, desc); 589 } else { 590 newObj[key] = obj[key]; 591 } 592 } 593 } 594 } 595 596 newObj.default = obj; 597 return newObj; 598 } 599 } 600 601 babelHelpers.interopRequireWildcard = _interopRequireWildcard; 602 603 function _newArrowCheck(innerThis, boundThis) { 604 if (innerThis !== boundThis) { 605 throw new TypeError("Cannot instantiate an arrow function"); 606 } 607 } 608 609 babelHelpers.newArrowCheck = _newArrowCheck; 610 611 function _objectDestructuringEmpty(obj) { 612 if (obj == null) throw new TypeError("Cannot destructure undefined"); 613 } 614 615 babelHelpers.objectDestructuringEmpty = _objectDestructuringEmpty; 616 617 function _objectWithoutPropertiesLoose(source, excluded) { 618 if (source == null) return {}; 619 var target = {}; 620 var sourceKeys = Object.keys(source); 621 var key, i; 622 623 for (i = 0; i < sourceKeys.length; i++) { 624 key = sourceKeys[i]; 625 if (excluded.indexOf(key) >= 0) continue; 626 target[key] = source[key]; 627 } 628 629 return target; 630 } 631 632 babelHelpers.objectWithoutPropertiesLoose = _objectWithoutPropertiesLoose; 633 634 function _objectWithoutProperties(source, excluded) { 635 if (source == null) return {}; 636 var target = babelHelpers.objectWithoutPropertiesLoose(source, excluded); 637 var key, i; 638 639 if (Object.getOwnPropertySymbols) { 640 var sourceSymbolKeys = Object.getOwnPropertySymbols(source); 641 642 for (i = 0; i < sourceSymbolKeys.length; i++) { 643 key = sourceSymbolKeys[i]; 644 if (excluded.indexOf(key) >= 0) continue; 645 if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; 646 target[key] = source[key]; 647 } 648 } 649 650 return target; 651 } 652 653 babelHelpers.objectWithoutProperties = _objectWithoutProperties; 654 655 function _assertThisInitialized(self) { 656 if (self === void 0) { 657 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 658 } 659 660 return self; 661 } 662 663 babelHelpers.assertThisInitialized = _assertThisInitialized; 664 665 function _possibleConstructorReturn(self, call) { 666 if (call && (typeof call === "object" || typeof call === "function")) { 667 return call; 668 } 669 670 return babelHelpers.assertThisInitialized(self); 671 } 672 673 babelHelpers.possibleConstructorReturn = _possibleConstructorReturn; 674 675 function _superPropBase(object, property) { 676 while (!Object.prototype.hasOwnProperty.call(object, property)) { 677 object = babelHelpers.getPrototypeOf(object); 678 if (object === null) break; 679 } 680 681 return object; 682 } 683 684 babelHelpers.superPropBase = _superPropBase; 685 686 function _get(target, property, receiver) { 687 if (typeof Reflect !== "undefined" && Reflect.get) { 688 babelHelpers.get = _get = Reflect.get; 689 } else { 690 babelHelpers.get = _get = function _get(target, property, receiver) { 691 var base = babelHelpers.superPropBase(target, property); 692 if (!base) return; 693 var desc = Object.getOwnPropertyDescriptor(base, property); 694 695 if (desc.get) { 696 return desc.get.call(receiver); 697 } 698 699 return desc.value; 700 }; 701 } 702 703 return _get(target, property, receiver || target); 704 } 705 706 babelHelpers.get = _get; 707 708 function set(target, property, value, receiver) { 709 if (typeof Reflect !== "undefined" && Reflect.set) { 710 set = Reflect.set; 711 } else { 712 set = function set(target, property, value, receiver) { 713 var base = babelHelpers.superPropBase(target, property); 714 var desc; 715 716 if (base) { 717 desc = Object.getOwnPropertyDescriptor(base, property); 718 719 if (desc.set) { 720 desc.set.call(receiver, value); 721 return true; 722 } else if (!desc.writable) { 723 return false;
724 } 725 } 726 727 desc = Object.getOwnPropertyDescriptor(receiver, property); 728 729 if (desc) { 730 if (!desc.writable) { 731 return false; 732 } 733 734 desc.value = value; 735 Object.defineProperty(receiver, property, desc); 736 } else { 737 babelHelpers.defineProperty(receiver, property, value); 738 } 739 740 return true; 741 }; 742 } 743 744 return set(target, property, value, receiver); 745 } 746 747 function _set(target, property, value, receiver, isStrict) { 748 var s = set(target, property, value, receiver || target); 749 750 if (!s && isStrict) { 751 throw new Error('failed to set property'); 752 } 753 754 return value; 755 } 756 757 babelHelpers.set = _set; 758 759 function _taggedTemplateLiteral(strings, raw) { 760 if (!raw) { 761 raw = strings.slice(0); 762 } 763 764 return Object.freeze(Object.defineProperties(strings, { 765 raw: { 766 value: Object.freeze(raw) 767 } 768 })); 769 } 770 771 babelHelpers.taggedTemplateLiteral = _taggedTemplateLiteral; 772 773 function _taggedTemplateLiteralLoose(strings, raw) { 774 if (!raw) { 775 raw = strings.slice(0); 776 } 777 778 strings.raw = raw; 779 return strings; 780 } 781 782 babelHelpers.taggedTemplateLiteralLoose = _taggedTemplateLiteralLoose; 783 784 function _temporalRef(val, name) { 785 if (val === babelHelpers.temporalUndefined) { 786 throw new ReferenceError(name + " is not defined - temporal dead zone"); 787 } else { 788 return val; 789 } 790 } 791 792 babelHelpers.temporalRef = _temporalRef; 793 794 function _readOnlyError(name) { 795 throw new Error("\"" + name + "\" is read-only"); 796 } 797 798 babelHelpers.readOnlyError = _readOnlyError; 799 800 function _classNameTDZError(name) { 801 throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); 802 } 803 804 babelHelpers.classNameTDZError = _classNameTDZError; 805 babelHelpers.temporalUndefined = {}; 806 807 function _slicedToArray(arr, i) { 808 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArrayLimit(arr, i) || babelHelpers.nonIterableRest(); 809 } 810 811 babelHelpers.slicedToArray = _slicedToArray; 812 813 function _slicedToArrayLoose(arr, i) { 814 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArrayLimitLoose(arr, i) || babelHelpers.nonIterableRest(); 815 } 816 817 babelHelpers.slicedToArrayLoose = _slicedToArrayLoose; 818 819 function _toArray(arr) { 820 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArray(arr) || babelHelpers.nonIterableRest(); 821 } 822 823 babelHelpers.toArray = _toArray; 824 825 function _toConsumableArray(arr) { 826 return babelHelpers.arrayWithoutHoles(arr) || babelHelpers.iterableToArray(arr) || babelHelpers.nonIterableSpread(); 827 } 828 829 babelHelpers.toConsumableArray = _toConsumableArray; 830 831 function _arrayWithoutHoles(arr) { 832 if (Array.isArray(arr)) { 833 for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; 834 835 return arr2; 836 } 837 } 838 839 babelHelpers.arrayWithoutHoles = _arrayWithoutHoles; 840 841 function _arrayWithHoles(arr) { 842 if (Array.isArray(arr)) return arr; 843 } 844 845 babelHelpers.arrayWithHoles = _arrayWithHoles; 846 847 function _iterableToArray(iter) { 848 if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); 849 } 850 851 babelHelpers.iterableToArray = _iterableToArray; 852 853 function _iterableToArrayLimit(arr, i) { 854 var _arr = []; 855 var _n = true; 856 var _d = false; 857 var _e = undefined; 858 859 try { 860 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { 861 _arr.push(_s.value); 862 863 if (i && _arr.length === i) break; 864 } 865 } catch (err) { 866 _d = true; 867 _e = err; 868 } finally { 869 try { 870 if (!_n && _i["return"] != null) _i["return"](); 871 } finally { 872 if (_d) throw _e; 873 } 874 } 875 876 return _arr; 877 } 878 879 babelHelpers.iterableToArrayLimit = _iterableToArrayLimit; 880 881 function _iterableToArrayLimitLoose(arr, i) { 882 var _arr = []; 883 884 for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { 885 _arr.push(_step.value); 886 887 if (i && _arr.length === i) break; 888 } 889 890 return _arr; 891 } 892 893 babelHelpers.iterableToArrayLimitLoose = _iterableToArrayLimitLoose; 894 895 function _nonIterableSpread() { 896 throw new TypeError("Invalid attempt to spread non-iterable instance"); 897 } 898 899 babelHelpers.nonIterableSpread = _nonIterableSpread; 900 901 function _nonIterableRest() {
902 throw new TypeError("Invalid attempt to destructure non-iterable instance"); 903 } 904 905 babelHelpers.nonIterableRest = _nonIterableRest; 906 907 function _skipFirstGeneratorNext(fn) { 908 return function () { 909 var it = fn.apply(this, arguments); 910 it.next(); 911 return it; 912 }; 913 } 914 915 babelHelpers.skipFirstGeneratorNext = _skipFirstGeneratorNext; 916 917 function _toPropertyKey(key) { 918 if (typeof key === "symbol") { 919 return key; 920 } else { 921 return String(key); 922 } 923 } 924 925 babelHelpers.toPropertyKey = _toPropertyKey; 926 927 function _initializerWarningHelper(descriptor, context) { 928 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.'); 929 } 930 931 babelHelpers.initializerWarningHelper = _initializerWarningHelper; 932 933 function _initializerDefineProperty(target, property, descriptor, context) { 934 if (!descriptor) return; 935 Object.defineProperty(target, property, { 936 enumerable: descriptor.enumerable, 937 configurable: descriptor.configurable, 938 writable: descriptor.writable, 939 value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 940 }); 941 } 942 943 babelHelpers.initializerDefineProperty = _initializerDefineProperty; 944 945 function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { 946 var desc = {}; 947 Object['ke' + 'ys'](descriptor).forEach(function (key) { 948 desc[key] = descriptor[key]; 949 }); 950 desc.enumerable = !!desc.enumerable; 951 desc.configurable = !!desc.configurable; 952 953 if ('value' in desc || desc.initializer) { 954 desc.writable = true; 955 } 956 957 desc = decorators.slice().reverse().reduce(function (desc, decorator) { 958 return decorator(target, property, desc) || desc; 959 }, desc); 960 961 if (context && desc.initializer !== void 0) { 962 desc.value = desc.initializer ? desc.initializer.call(context) : void 0; 963 desc.initializer = undefined; 964 } 965 966 if (desc.initializer === void 0) { 967 Object['define' + 'Property'](target, property, desc); 968 desc = null; 969 } 970 971 return desc; 972 } 973 974 babelHelpers.applyDecoratedDescriptor = _applyDecoratedDescriptor; 975 var id = 0; 976 977 function _classPrivateFieldKey(name) { 978 return "__private_" + id++ + "_" + name; 979 } 980 981 babelHelpers.classPrivateFieldLooseKey = _classPrivateFieldKey; 982 983 function _classPrivateFieldBase(receiver, privateKey) { 984 if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { 985 throw new TypeError("attempted to use private field on non-instance"); 986 } 987 988 return receiver; 989 } 990 991 babelHelpers.classPrivateFieldLooseBase = _classPrivateFieldBase; 992 993 function _classPrivateFieldGet(receiver, privateMap) { 994 if (!privateMap.has(receiver)) { 995 throw new TypeError("attempted to get private field on non-instance"); 996 } 997 998 return privateMap.get(receiver).value; 999 } 1000 1001 babelHelpers.classPrivateFieldGet = _classPrivateFieldGet; 1002 1003 function _classPrivateFieldSet(receiver, privateMap, value) { 1004 if (!privateMap.has(receiver)) { 1005 throw new TypeError("attempted to set private field on non-instance"); 1006 } 1007 1008 var descriptor = privateMap.get(receiver); 1009 1010 if (!descriptor.writable) { 1011 throw new TypeError("attempted to set read only private field"); 1012 } 1013 1014 descriptor.value = value; 1015 return value; 1016 } 1017 1018 babelHelpers.classPrivateFieldSet = _classPrivateFieldSet; 1019})(typeof global === "undefined" ? window : global); 1020 1021/** 1022 * Copyright (c) 2014-present, Facebook, Inc. 1023 * 1024 * This source code is licensed under the MIT license found in the 1025 * LICENSE file in the root directory of this source tree. 1026 */ 1027 1028!(function(global) { 1029 "use strict"; 1030 1031 var Op = Object.prototype; 1032 var hasOwn = Op.hasOwnProperty; 1033 var undefined; // More compressible than void 0. 1034 var $Symbol = typeof Symbol === "function" ? Symbol : {}; 1035 var iteratorSymbol = $Symbol.iterator || "@@iterator"; 1036 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; 1037 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; 1038 1039 // Define the runtime globally (as expected by generated code) as either 1040 // module.exports (if we're in a module) or a new, empty object. 1041 var runtime = global.regeneratorRuntime = {}; 1042 1043 function wrap(innerFn, outerFn, self, tryLocsList) { 1044 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. 1045 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; 1046 var generator = Object.create(protoGenerator.prototype); 1047 var context = new Context(tryLocsList || []); 1048 1049 // The ._invoke method unifies the implementations of the .next, 1050 // .throw, and .return methods. 1051 generator._invoke = makeInvokeMethod(innerFn, self, context); 1052 1053 return generator; 1054 } 1055 runtime.wrap = wrap; 1056 1057 // Try/catch helper to minimize deoptimizations. Returns a completion 1058 // record like context.tryEntries[i].completion. This interface could
vendor: 10,591 bytes, lines 1059-1352
1059 // have been (and was previously) designed to take a closure to be 1060 // invoked without arguments, but in all the cases we care about we 1061 // already have an existing method we want to call, so there's no need 1062 // to create a new function object. We can even get away with assuming 1063 // the method takes exactly one argument, since that happens to be true 1064 // in every case, so we don't have to touch the arguments object. The 1065 // only additional allocation required is the completion record, which 1066 // has a stable shape and so hopefully should be cheap to allocate. 1067 function tryCatch(fn, obj, arg) { 1068 try { 1069 return { type: "normal", arg: fn.call(obj, arg) }; 1070 } catch (err) { 1071 return { type: "throw", arg: err }; 1072 } 1073 } 1074 1075 var GenStateSuspendedStart = "suspendedStart"; 1076 var GenStateSuspendedYield = "suspendedYield"; 1077 var GenStateExecuting = "executing"; 1078 var GenStateCompleted = "completed"; 1079 1080 // Returning this object from the innerFn has the same effect as 1081 // breaking out of the dispatch switch statement. 1082 var ContinueSentinel = {}; 1083 1084 // Dummy constructor functions that we use as the .constructor and 1085 // .constructor.prototype properties for functions that return Generator 1086 // objects. For full spec compliance, you may wish to configure your 1087 // minifier not to mangle the names of these two functions. 1088 function Generator() {} 1089 function GeneratorFunction() {} 1090 function GeneratorFunctionPrototype() {} 1091 1092 // This is a polyfill for %IteratorPrototype% for environments that 1093 // don't natively support it. 1094 var IteratorPrototype = {}; 1095 IteratorPrototype[iteratorSymbol] = function () { 1096 return this; 1097 }; 1098 1099 var getProto = Object.getPrototypeOf; 1100 var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); 1101 if (NativeIteratorPrototype && 1102 NativeIteratorPrototype !== Op && 1103 hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { 1104 // This environment has a native %IteratorPrototype%; use it instead 1105 // of the polyfill. 1106 IteratorPrototype = NativeIteratorPrototype; 1107 } 1108 1109 var Gp = GeneratorFunctionPrototype.prototype = 1110 Generator.prototype = Object.create(IteratorPrototype); 1111 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; 1112 GeneratorFunctionPrototype.constructor = GeneratorFunction; 1113 GeneratorFunctionPrototype[toStringTagSymbol] = 1114 GeneratorFunction.displayName = "GeneratorFunction"; 1115 1116 // Helper for defining the .next, .throw, and .return methods of the 1117 // Iterator interface in terms of a single ._invoke method. 1118 function defineIteratorMethods(prototype) { 1119 ["next", "throw", "return"].forEach(function(method) { 1120 prototype[method] = function(arg) { 1121 return this._invoke(method, arg); 1122 }; 1123 }); 1124 } 1125 1126 runtime.isGeneratorFunction = function(genFun) { 1127 var ctor = typeof genFun === "function" && genFun.constructor; 1128 return ctor 1129 ? ctor === GeneratorFunction || 1130 // For the native GeneratorFunction constructor, the best we can 1131 // do is to check its .name property. 1132 (ctor.displayName || ctor.name) === "GeneratorFunction" 1133 : false; 1134 }; 1135 1136 runtime.mark = function(genFun) { 1137 if (Object.setPrototypeOf) { 1138 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); 1139 } else { 1140 genFun.__proto__ = GeneratorFunctionPrototype; 1141 if (!(toStringTagSymbol in genFun)) { 1142 genFun[toStringTagSymbol] = "GeneratorFunction"; 1143 } 1144 } 1145 genFun.prototype = Object.create(Gp); 1146 return genFun; 1147 }; 1148 1149 // Within the body of any async function, `await x` is transformed to 1150 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test 1151 // `hasOwn.call(value, "__await")` to determine if the yielded value is 1152 // meant to be awaited. 1153 runtime.awrap = function(arg) { 1154 return { __await: arg }; 1155 }; 1156 1157 function AsyncIterator(generator) { 1158 function invoke(method, arg, resolve, reject) { 1159 var record = tryCatch(generator[method], generator, arg); 1160 if (record.type === "throw") { 1161 reject(record.arg); 1162 } else { 1163 var result = record.arg; 1164 var value = result.value; 1165 if (value && 1166 typeof value === "object" && 1167 hasOwn.call(value, "__await")) { 1168 return Promise.resolve(value.__await).then(function(value) { 1169 invoke("next", value, resolve, reject); 1170 }, function(err) { 1171 invoke("throw", err, resolve, reject); 1172 }); 1173 } 1174 1175 return Promise.resolve(value).then(function(unwrapped) { 1176 // When a yielded Promise is resolved, its final value becomes 1177 // the .value of the Promise<{value,done}> result for the 1178 // current iteration. If the Promise is rejected, however, the 1179 // result for this iteration will be rejected with the same 1180 // reason. Note that rejections of yielded Promises are not 1181 // thrown back into the generator function, as is the case 1182 // when an awaited Promise is rejected. This difference in 1183 // behavior between yield and await is important, because it 1184 // allows the consumer to decide what to do with the yielded 1185 // rejection (swallow it and continue, manually .throw it back 1186 // into the generator, abandon iteration, whatever). With 1187 // await, by contrast, there is no opportunity to examine the 1188 // rejection reason outside the generator function, so the 1189 // only option is to throw it from the await expression, and 1190 // let the generator function handle the exception. 1191 result.value = unwrapped; 1192 resolve(result); 1193 }, reject); 1194 } 1195 } 1196 1197 var previousPromise; 1198 1199 function enqueue(method, arg) { 1200 function callInvokeWithMethodAndArg() { 1201 return new Promise(function(resolve, reject) { 1202 invoke(method, arg, resolve, reject); 1203 }); 1204 } 1205 1206 return previousPromise = 1207 // If enqueue has been called before, then we want to wait until 1208 // all previous Promises have been resolved before calling invoke, 1209 // so that results are always delivered in the correct order. If 1210 // enqueue has not been called before, then it is important to 1211 // call invoke immediately, without waiting on a callback to fire, 1212 // so that the async generator function has the opportunity to do 1213 // any necessary setup in a predictable way. This predictability 1214 // is why the Promise constructor synchronously invokes its 1215 // executor callback, and why async functions synchronously 1216 // execute code before the first await. Since we implement simple 1217 // async functions in terms of async generators, it is especially 1218 // important to get this right, even though it requires care. 1219 previousPromise ? previousPromise.then( 1220 callInvokeWithMethodAndArg, 1221 // Avoid propagating failures to Promises returned by later 1222 // invocations of the iterator. 1223 callInvokeWithMethodAndArg 1224 ) : callInvokeWithMethodAndArg(); 1225 } 1226 1227 // Define the unified helper method that is used to implement .next, 1228 // .throw, and .return (see defineIteratorMethods). 1229 this._invoke = enqueue; 1230 } 1231 1232 defineIteratorMethods(AsyncIterator.prototype); 1233 AsyncIterator.prototype[asyncIteratorSymbol] = function () { 1234 return this; 1235 }; 1236 runtime.AsyncIterator = AsyncIterator; 1237 1238 // Note that simple async functions are implemented on top of 1239 // AsyncIterator objects; they just return a Promise for the value of 1240 // the final result produced by the iterator. 1241 runtime.async = function(innerFn, outerFn, self, tryLocsList) { 1242 var iter = new AsyncIterator( 1243 wrap(innerFn, outerFn, self, tryLocsList) 1244 ); 1245 1246 return runtime.isGeneratorFunction(outerFn) 1247 ? iter // If outerFn is a generator, return the full iterator. 1248 : iter.next().then(function(result) { 1249 return result.done ? result.value : iter.next(); 1250 }); 1251 }; 1252 1253 function makeInvokeMethod(innerFn, self, context) { 1254 var state = GenStateSuspendedStart; 1255 1256 return function invoke(method, arg) { 1257 if (state === GenStateExecuting) { 1258 throw new Error("Generator is already running"); 1259 } 1260 1261 if (state === GenStateCompleted) { 1262 if (method === "throw") { 1263 throw arg; 1264 } 1265 1266 // Be forgiving, per 25.3.3.3.3 of the spec: 1267 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume 1268 return doneResult(); 1269 } 1270 1271 context.method = method; 1272 context.arg = arg; 1273 1274 while (true) { 1275 var delegate = context.delegate; 1276 if (delegate) { 1277 var delegateResult = maybeInvokeDelegate(delegate, context); 1278 if (delegateResult) { 1279 if (delegateResult === ContinueSentinel) continue; 1280 return delegateResult; 1281 } 1282 } 1283 1284 if (context.method === "next") { 1285 // Setting context._sent for legacy support of Babel's 1286 // function.sent implementation. 1287 context.sent = context._sent = context.arg; 1288 1289 } else if (context.method === "throw") { 1290 if (state === GenStateSuspendedStart) { 1291 state = GenStateCompleted; 1292 throw context.arg; 1293 } 1294 1295 context.dispatchException(context.arg); 1296 1297 } else if (context.method === "return") { 1298 context.abrupt("return", context.arg); 1299 } 1300 1301 state = GenStateExecuting; 1302 1303 var record = tryCatch(innerFn, self, context); 1304 if (record.type === "normal") { 1305 // If an exception is thrown from innerFn, we leave state === 1306 // GenStateExecuting and loop back for another invocation. 1307 state = context.done 1308 ? GenStateCompleted 1309 : GenStateSuspendedYield; 1310 1311 if (record.arg === ContinueSentinel) { 1312 continue; 1313 } 1314 1315 return { 1316 value: record.arg, 1317 done: context.done 1318 }; 1319 1320 } else if (record.type === "throw") { 1321 state = GenStateCompleted; 1322 // Dispatch the exception by looping back around to the 1323 // context.dispatchException(context.arg) call above. 1324 context.method = "throw"; 1325 context.arg = record.arg; 1326 } 1327 } 1328 }; 1329 } 1330 1331 // Call delegate.iterator[context.method](context.arg) and handle the 1332 // result, either by returning a { value, done } result from the 1333 // delegate iterator, or by modifying context.method and context.arg, 1334 // setting context.delegate to null, and returning the ContinueSentinel. 1335 function maybeInvokeDelegate(delegate, context) { 1336 var method = delegate.iterator[context.method]; 1337 if (method === undefined) { 1338 // A .throw or .return when the delegate iterator has no .throw 1339 // method always terminates the yield* loop. 1340 context.delegate = null; 1341 1342 if (context.method === "throw") { 1343 if (delegate.iterator.return) { 1344 // If the delegate iterator has a return method, give it a 1345 // chance to clean up. 1346 context.method = "return"; 1347 context.arg = undefined; 1348 maybeInvokeDelegate(delegate, context); 1349 1350 if (context.method === "throw") { 1351 // If maybeInvokeDelegate(context) changed context.method from 1352 // "return" to "throw", let that override the TypeError below.
vendor: 4,172 bytes, lines 1353-1506
1353 return ContinueSentinel; 1354 } 1355 } 1356 1357 context.method = "throw"; 1358 context.arg = new TypeError( 1359 "The iterator does not provide a 'throw' method"); 1360 } 1361 1362 return ContinueSentinel; 1363 } 1364 1365 var record = tryCatch(method, delegate.iterator, context.arg); 1366 1367 if (record.type === "throw") { 1368 context.method = "throw"; 1369 context.arg = record.arg; 1370 context.delegate = null; 1371 return ContinueSentinel; 1372 } 1373 1374 var info = record.arg; 1375 1376 if (! info) { 1377 context.method = "throw"; 1378 context.arg = new TypeError("iterator result is not an object"); 1379 context.delegate = null; 1380 return ContinueSentinel; 1381 } 1382 1383 if (info.done) { 1384 // Assign the result of the finished delegate to the temporary 1385 // variable specified by delegate.resultName (see delegateYield). 1386 context[delegate.resultName] = info.value; 1387 1388 // Resume execution at the desired location (see delegateYield). 1389 context.next = delegate.nextLoc; 1390 1391 // If context.method was "throw" but the delegate handled the 1392 // exception, let the outer generator proceed normally. If 1393 // context.method was "next", forget context.arg since it has been 1394 // "consumed" by the delegate iterator. If context.method was 1395 // "return", allow the original .return call to continue in the 1396 // outer generator. 1397 if (context.method !== "return") { 1398 context.method = "next"; 1399 context.arg = undefined; 1400 } 1401 1402 } else { 1403 // Re-yield the result returned by the delegate method. 1404 return info; 1405 } 1406 1407 // The delegate iterator is finished, so forget it and continue with 1408 // the outer generator. 1409 context.delegate = null; 1410 return ContinueSentinel; 1411 } 1412 1413 // Define Generator.prototype.{next,throw,return} in terms of the 1414 // unified ._invoke helper method. 1415 defineIteratorMethods(Gp); 1416 1417 Gp[toStringTagSymbol] = "Generator"; 1418 1419 // A Generator should always return itself as the iterator object when the 1420 // @@iterator function is called on it. Some browsers' implementations of the 1421 // iterator prototype chain incorrectly implement this, causing the Generator 1422 // object to not be returned from this call. This ensures that doesn't happen. 1423 // See https://github.com/facebook/regenerator/issues/274 for more details. 1424 Gp[iteratorSymbol] = function() { 1425 return this; 1426 }; 1427 1428 Gp.toString = function() { 1429 return "[object Generator]"; 1430 }; 1431 1432 function pushTryEntry(locs) { 1433 var entry = { tryLoc: locs[0] }; 1434 1435 if (1 in locs) { 1436 entry.catchLoc = locs[1]; 1437 } 1438 1439 if (2 in locs) { 1440 entry.finallyLoc = locs[2]; 1441 entry.afterLoc = locs[3]; 1442 } 1443 1444 this.tryEntries.push(entry); 1445 } 1446 1447 function resetTryEntry(entry) { 1448 var record = entry.completion || {}; 1449 record.type = "normal"; 1450 delete record.arg; 1451 entry.completion = record; 1452 } 1453 1454 function Context(tryLocsList) { 1455 // The root entry object (effectively a try statement without a catch 1456 // or a finally block) gives us a place to store values thrown from 1457 // locations where there is no enclosing try statement. 1458 this.tryEntries = [{ tryLoc: "root" }]; 1459 tryLocsList.forEach(pushTryEntry, this); 1460 this.reset(true); 1461 } 1462 1463 runtime.keys = function(object) { 1464 var keys = []; 1465 for (var key in object) { 1466 keys.push(key); 1467 } 1468 keys.reverse(); 1469 1470 // Rather than returning an object with a next method, we keep 1471 // things simple and return the next function itself. 1472 return function next() { 1473 while (keys.length) { 1474 var key = keys.pop(); 1475 if (key in object) { 1476 next.value = key; 1477 next.done = false; 1478 return next; 1479 } 1480 } 1481 1482 // To avoid creating an additional object, we just hang the .value 1483 // and .done properties off the next function object itself. This 1484 // also ensures that the minifier will not anonymize the function. 1485 next.done = true; 1486 return next; 1487 }; 1488 }; 1489 1490 function values(iterable) { 1491 if (iterable) { 1492 var iteratorMethod = iterable[iteratorSymbol]; 1493 if (iteratorMethod) { 1494 return iteratorMethod.call(iterable); 1495 } 1496 1497 if (typeof iterable.next === "function") { 1498 return iterable; 1499 } 1500 1501 if (!isNaN(iterable.length)) { 1502 var i = -1, next = function next() { 1503 while (++i < iterable.length) { 1504 if (hasOwn.call(iterable, i)) { 1505 next.value = iterable[i]; 1506 next.done = false;
1507 return next; 1508 } 1509 } 1510 1511 next.value = undefined; 1512 next.done = true; 1513 1514 return next; 1515 }; 1516 1517 return next.next = next; 1518 } 1519 } 1520 1521 // Return an iterator with no values. 1522 return { next: doneResult }; 1523 } 1524 runtime.values = values; 1525 1526 function doneResult() { 1527 return { value: undefined, done: true }; 1528 } 1529 1530 Context.prototype = { 1531 constructor: Context, 1532 1533 reset: function(skipTempReset) { 1534 this.prev = 0; 1535 this.next = 0; 1536 // Resetting context._sent for legacy support of Babel's 1537 // function.sent implementation. 1538 this.sent = this._sent = undefined; 1539 this.done = false; 1540 this.delegate = null; 1541 1542 this.method = "next"; 1543 this.arg = undefined; 1544 1545 this.tryEntries.forEach(resetTryEntry); 1546 1547 if (!skipTempReset) { 1548 for (var name in this) { 1549 // Not sure about the optimal order of these conditions: 1550 if (name.charAt(0) === "t" && 1551 hasOwn.call(this, name) && 1552 !isNaN(+name.slice(1))) { 1553 this[name] = undefined; 1554 } 1555 } 1556 } 1557 }, 1558 1559 stop: function() { 1560 this.done = true; 1561 1562 var rootEntry = this.tryEntries[0]; 1563 var rootRecord = rootEntry.completion; 1564 if (rootRecord.type === "throw") { 1565 throw rootRecord.arg; 1566 } 1567 1568 return this.rval; 1569 }, 1570 1571 dispatchException: function(exception) { 1572 if (this.done) { 1573 throw exception; 1574 } 1575 1576 var context = this; 1577 function handle(loc, caught) { 1578 record.type = "throw"; 1579 record.arg = exception; 1580 context.next = loc; 1581 1582 if (caught) { 1583 // If the dispatched exception was caught by a catch block, 1584 // then let that catch block handle the exception normally. 1585 context.method = "next"; 1586 context.arg = undefined; 1587 } 1588 1589 return !! caught; 1590 } 1591 1592 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1593 var entry = this.tryEntries[i]; 1594 var record = entry.completion; 1595 1596 if (entry.tryLoc === "root") { 1597 // Exception thrown outside of any try block that could handle 1598 // it, so set the completion value of the entire function to 1599 // throw the exception. 1600 return handle("end"); 1601 } 1602 1603 if (entry.tryLoc <= this.prev) { 1604 var hasCatch = hasOwn.call(entry, "catchLoc"); 1605 var hasFinally = hasOwn.call(entry, "finallyLoc"); 1606 1607 if (hasCatch && hasFinally) { 1608 if (this.prev < entry.catchLoc) { 1609 return handle(entry.catchLoc, true); 1610 } else if (this.prev < entry.finallyLoc) { 1611 return handle(entry.finallyLoc); 1612 } 1613 1614 } else if (hasCatch) { 1615 if (this.prev < entry.catchLoc) { 1616 return handle(entry.catchLoc, true); 1617 } 1618 1619 } else if (hasFinally) { 1620 if (this.prev < entry.finallyLoc) { 1621 return handle(entry.finallyLoc); 1622 } 1623 1624 } else { 1625 throw new Error("try statement without catch or finally"); 1626 } 1627 } 1628 } 1629 }, 1630 1631 abrupt: function(type, arg) { 1632 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1633 var entry = this.tryEntries[i]; 1634 if (entry.tryLoc <= this.prev && 1635 hasOwn.call(entry, "finallyLoc") && 1636 this.prev < entry.finallyLoc) { 1637 var finallyEntry = entry; 1638 break; 1639 } 1640 } 1641 1642 if (finallyEntry && 1643 (type === "break" || 1644 type === "continue") && 1645 finallyEntry.tryLoc <= arg && 1646 arg <= finallyEntry.finallyLoc) { 1647 // Ignore the finally entry if control is not jumping to a 1648 // location outside the try/catch block. 1649 finallyEntry = null; 1650 } 1651 1652 var record = finallyEntry ? finallyEntry.completion : {}; 1653 record.type = type; 1654 record.arg = arg; 1655 1656 if (finallyEntry) { 1657 this.method = "next"; 1658 this.next = finallyEntry.finallyLoc; 1659 return ContinueSentinel; 1660 } 1661 1662 return this.complete(record); 1663 }, 1664 1665 complete: function(record, afterLoc) { 1666 if (record.type === "throw") { 1667 throw record.arg; 1668 } 1669 1670 if (record.type === "break" || 1671 record.type === "continue") { 1672 this.next = record.arg; 1673 } else if (record.type === "return") { 1674 this.rval = this.arg = record.arg; 1675 this.method = "return"; 1676 this.next = "end"; 1677 } else if (record.type === "normal" && afterLoc) { 1678 this.next = afterLoc; 1679 } 1680 1681 return ContinueSentinel; 1682 }, 1683 1684 finish: function(finallyLoc) { 1685 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1686 var entry = this.tryEntries[i]; 1687 if (entry.finallyLoc === finallyLoc) { 1688 this.complete(entry.completion, entry.afterLoc); 1689 resetTryEntry(entry); 1690 return ContinueSentinel; 1691 } 1692 } 1693 }, 1694 1695 "catch": function(tryLoc) { 1696 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1697 var entry = this.tryEntries[i]; 1698 if (entry.tryLoc === tryLoc) { 1699 var record = entry.completion; 1700 if (record.type === "throw") { 1701 var thrown = record.arg; 1702 resetTryEntry(entry); 1703 } 1704 return thrown; 1705 } 1706 } 1707 1708 // The context.catch method must only be called with a location 1709 // argument that corresponds to a known catch block. 1710 throw new Error("illegal catch attempt"); 1711 }, 1712 1713 delegateYield: function(iterable, resultName, nextLoc) { 1714 this.delegate = { 1715 iterator: values(iterable), 1716 resultName: resultName, 1717 nextLoc: nextLoc 1718 }; 1719 1720 if (this.method === "next") { 1721 // Deliberately forget the last sent value so that we don't 1722 // accidentally pass it on to the delegate. 1723 this.arg = undefined; 1724 } 1725 1726 return ContinueSentinel; 1727 } 1728 }; 1729})( 1730 // In sloppy mode, unbound `this` refers to the global object, fallback to 1731 // Function constructor if we're in global strict mode. That is sadly a form 1732 // of indirect eval which violates Content Security Policy. 1733 (function() { return this })() || Function("return this")() 1734); 1735 1736(function (exports) { 1737 'use strict'; 1738 1739 var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; 1740 function createCommonjsModule(fn, module) { 1741 return module = { 1742 exports: {} 1743 }, fn(module, module.exports), module.exports; 1744 } 1745 1746 var check = function (it) { 1747 return it && it.Math == Math && it; 1748 }; // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 1749 1750 1751 var global_1 = // eslint-disable-next-line es/no-global-this -- safe 1752 check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || // eslint-disable-next-line no-restricted-globals -- safe 1753 check(typeof self == 'object' && self) || check(typeof commonjsGlobal == 'object' && commonjsGlobal) || // eslint-disable-next-line no-new-func -- fallback 1754 function () { 1755 return this; 1756 }() || Function('return this')(); 1757 1758 var fails = function (exec) { 1759 try { 1760 return !!exec(); 1761 } catch (error) { 1762 return true; 1763 } 1764 }; 1765 1766 // Detect IE8's incomplete defineProperty implementation 1767 1768 1769 var descriptors = !fails(function () { 1770 // eslint-disable-next-line es/no-object-defineproperty -- required for testing 1771 return Object.defineProperty({}, 1, { 1772 get: function () { 1773 return 7; 1774 } 1775 })[1] != 7; 1776 }); 1777 1778 var call = Function.prototype.call; 1779 var functionCall = call.bind ? call.bind(call) : function () { 1780 return call.apply(call, arguments); 1781 }; 1782 1783 var $propertyIsEnumerable = {}.propertyIsEnumerable; // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 1784 1785 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; // Nashorn ~ JDK8 bug 1786 1787 var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1788 1: 2 1789 }, 1); // `Object.prototype.propertyIsEnumerable` method implementation 1790 // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable 1791 1792 var f = NASHORN_BUG ? function propertyIsEnumerable(V) { 1793 var descriptor = getOwnPropertyDescriptor(this, V); 1794 return !!descriptor && descriptor.enumerable; 1795 } : $propertyIsEnumerable; 1796 1797 var objectPropertyIsEnumerable = { 1798 f: f 1799 }; 1800 1801 var createPropertyDescriptor = function (bitmap, value) { 1802 return { 1803 enumerable: !(bitmap & 1), 1804 configurable: !(bitmap & 2), 1805 writable: !(bitmap & 4), 1806 value: value 1807 }; 1808 }; 1809 1810 var FunctionPrototype = Function.prototype; 1811 var bind = FunctionPrototype.bind; 1812 var call$1 = FunctionPrototype.call; 1813 var callBind = bind && bind.bind(call$1); 1814 var functionUncurryThis = bind ? function (fn) {
1815 return fn && callBind(call$1, fn); 1816 } : function (fn) { 1817 return fn && function () { 1818 return call$1.apply(fn, arguments); 1819 }; 1820 }; 1821 1822 var toString = functionUncurryThis({}.toString); 1823 var stringSlice = functionUncurryThis(''.slice); 1824 1825 var classofRaw = function (it) { 1826 return stringSlice(toString(it), 8, -1); 1827 }; 1828 1829 var Object$1 = global_1.Object; 1830 var split = functionUncurryThis(''.split); // fallback for non-array-like ES3 and non-enumerable old V8 strings 1831 1832 var indexedObject = fails(function () { 1833 // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346 1834 // eslint-disable-next-line no-prototype-builtins -- safe 1835 return !Object$1('z').propertyIsEnumerable(0); 1836 }) ? function (it) { 1837 return classofRaw(it) == 'String' ? split(it, '') : Object$1(it); 1838 } : Object$1; 1839 1840 var TypeError$1 = global_1.TypeError; // `RequireObjectCoercible` abstract operation 1841 // https://tc39.es/ecma262/#sec-requireobjectcoercible 1842 1843 var requireObjectCoercible = function (it) { 1844 if (it == undefined) throw TypeError$1("Can't call method on " + it); 1845 return it; 1846 }; 1847 1848 // toObject with fallback for non-array-like ES3 strings 1849 1850 1851 1852 1853 var toIndexedObject = function (it) { 1854 return indexedObject(requireObjectCoercible(it)); 1855 }; 1856 1857 // `IsCallable` abstract operation 1858 // https://tc39.es/ecma262/#sec-iscallable 1859 var isCallable = function (argument) { 1860 return typeof argument == 'function'; 1861 }; 1862 1863 var isObject = function (it) { 1864 return typeof it == 'object' ? it !== null : isCallable(it); 1865 }; 1866 1867 var aFunction = function (argument) { 1868 return isCallable(argument) ? argument : undefined; 1869 }; 1870 1871 var getBuiltIn = function (namespace, method) { 1872 return arguments.length < 2 ? aFunction(global_1[namespace]) : global_1[namespace] && global_1[namespace][method]; 1873 }; 1874 1875 var objectIsPrototypeOf = functionUncurryThis({}.isPrototypeOf); 1876 1877 var engineUserAgent = getBuiltIn('navigator', 'userAgent') || ''; 1878 1879 var process = global_1.process; 1880 var Deno = global_1.Deno; 1881 var versions = process && process.versions || Deno && Deno.version; 1882 var v8 = versions && versions.v8; 1883 var match, version; 1884 1885 if (v8) { 1886 match = v8.split('.'); // in old Chrome, versions of V8 isn't V8 = Chrome / 10 1887 // but their correct versions are not interesting for us 1888 1889 version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]); 1890 } // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0` 1891 // so check `userAgent` even if `.v8` exists, but 0 1892 1893 1894 if (!version && engineUserAgent) { 1895 match = engineUserAgent.match(/Edge\/(\d+)/); 1896 1897 if (!match || match[1] >= 74) { 1898 match = engineUserAgent.match(/Chrome\/(\d+)/); 1899 if (match) version = +match[1]; 1900 } 1901 } 1902 1903 var engineV8Version = version; 1904 1905 /* eslint-disable es/no-symbol -- required for testing */ 1906 1907 1908 // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing 1909 1910 1911 var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () { 1912 var symbol = Symbol(); // Chrome 38 Symbol has incorrect toString conversion 1913 // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances 1914 1915 return !String(symbol) || !(Object(symbol) instanceof Symbol) || // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances 1916 !Symbol.sham && engineV8Version && engineV8Version < 41; 1917 }); 1918 1919 /* eslint-disable es/no-symbol -- required for testing */ 1920 1921 1922 var useSymbolAsUid = nativeSymbol && !Symbol.sham && typeof Symbol.iterator == 'symbol'; 1923 1924 var Object$2 = global_1.Object; 1925 var isSymbol = useSymbolAsUid ? function (it) { 1926 return typeof it == 'symbol'; 1927 } : function (it) { 1928 var $Symbol = getBuiltIn('Symbol'); 1929 return isCallable($Symbol) && objectIsPrototypeOf($Symbol.prototype, Object$2(it)); 1930 }; 1931 1932 var String$1 = global_1.String; 1933 1934 var tryToString = function (argument) { 1935 try { 1936 return String$1(argument); 1937 } catch (error) { 1938 return 'Object'; 1939 } 1940 }; 1941 1942 var TypeError$2 = global_1.TypeError; // `Assert: IsCallable(argument) is true` 1943 1944 var aCallable = function (argument) { 1945 if (isCallable(argument)) return argument; 1946 throw TypeError$2(tryToString(argument) + ' is not a function'); 1947 }; 1948 1949 // `GetMethod` abstract operation 1950 // https://tc39.es/ecma262/#sec-getmethod 1951 1952 1953 var getMethod = function (V, P) { 1954 var func = V[P]; 1955 return func == null ? undefined : aCallable(func); 1956 }; 1957 1958 var TypeError$3 = global_1.TypeError; // `OrdinaryToPrimitive` abstract operation 1959 // https://tc39.es/ecma262/#sec-ordinarytoprimitive 1960 1961 var ordinaryToPrimitive = function (input, pref) { 1962 var fn, val; 1963 if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val; 1964 if (isCallable(fn = input.valueOf) && !isObject(val = functionCall(fn, input))) return val; 1965 if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val; 1966 throw TypeError$3("Can't convert object to primitive value"); 1967 }; 1968 1969 var isPure = false;
1970 1971 // eslint-disable-next-line es/no-object-defineproperty -- safe 1972 1973 1974 var defineProperty = Object.defineProperty; 1975 1976 var setGlobal = function (key, value) { 1977 try { 1978 defineProperty(global_1, key, { 1979 value: value, 1980 configurable: true, 1981 writable: true 1982 }); 1983 } catch (error) { 1984 global_1[key] = value; 1985 } 1986 1987 return value; 1988 }; 1989 1990 var SHARED = '__core-js_shared__'; 1991 var store = global_1[SHARED] || setGlobal(SHARED, {}); 1992 var sharedStore = store; 1993 1994 var shared = createCommonjsModule(function (module) { 1995 (module.exports = function (key, value) { 1996 return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {}); 1997 })('versions', []).push({ 1998 version: '3.19.2', 1999 mode: 'global', 2000 copyright: '(c) 2021 Denis Pushkarev (zloirock.ru)' 2001 }); 2002 }); 2003 2004 var Object$3 = global_1.Object; // `ToObject` abstract operation 2005 // https://tc39.es/ecma262/#sec-toobject 2006 2007 var toObject = function (argument) { 2008 return Object$3(requireObjectCoercible(argument)); 2009 }; 2010 2011 var hasOwnProperty = functionUncurryThis({}.hasOwnProperty); // `HasOwnProperty` abstract operation 2012 // https://tc39.es/ecma262/#sec-hasownproperty 2013 2014 var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) { 2015 return hasOwnProperty(toObject(it), key); 2016 }; 2017 2018 var id = 0; 2019 var postfix = Math.random(); 2020 var toString$1 = functionUncurryThis(1.0.toString); 2021 2022 var uid = function (key) { 2023 return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$1(++id + postfix, 36); 2024 }; 2025 2026 var WellKnownSymbolsStore = shared('wks'); 2027 var Symbol$1 = global_1.Symbol; 2028 var symbolFor = Symbol$1 && Symbol$1['for']; 2029 var createWellKnownSymbol = useSymbolAsUid ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid; 2030 2031 var wellKnownSymbol = function (name) { 2032 if (!hasOwnProperty_1(WellKnownSymbolsStore, name) || !(nativeSymbol || typeof WellKnownSymbolsStore[name] == 'string')) { 2033 var description = 'Symbol.' + name; 2034 2035 if (nativeSymbol && hasOwnProperty_1(Symbol$1, name)) { 2036 WellKnownSymbolsStore[name] = Symbol$1[name]; 2037 } else if (useSymbolAsUid && symbolFor) { 2038 WellKnownSymbolsStore[name] = symbolFor(description); 2039 } else { 2040 WellKnownSymbolsStore[name] = createWellKnownSymbol(description); 2041 } 2042 } 2043 2044 return WellKnownSymbolsStore[name]; 2045 }; 2046 2047 var TypeError$4 = global_1.TypeError; 2048 var TO_PRIMITIVE = wellKnownSymbol('toPrimitive'); // `ToPrimitive` abstract operation 2049 // https://tc39.es/ecma262/#sec-toprimitive 2050 2051 var toPrimitive = function (input, pref) { 2052 if (!isObject(input) || isSymbol(input)) return input; 2053 var exoticToPrim = getMethod(input, TO_PRIMITIVE); 2054 var result; 2055 2056 if (exoticToPrim) { 2057 if (pref === undefined) pref = 'default'; 2058 result = functionCall(exoticToPrim, input, pref); 2059 if (!isObject(result) || isSymbol(result)) return result; 2060 throw TypeError$4("Can't convert object to primitive value"); 2061 } 2062 2063 if (pref === undefined) pref = 'number'; 2064 return ordinaryToPrimitive(input, pref); 2065 }; 2066 2067 // `ToPropertyKey` abstract operation 2068 // https://tc39.es/ecma262/#sec-topropertykey 2069 2070 2071 var toPropertyKey = function (argument) { 2072 var key = toPrimitive(argument, 'string'); 2073 return isSymbol(key) ? key : key + ''; 2074 }; 2075 2076 var document$1 = global_1.document; // typeof document.createElement is 'object' in old IE 2077 2078 var EXISTS = isObject(document$1) && isObject(document$1.createElement); 2079 2080 var documentCreateElement = function (it) { 2081 return EXISTS ? document$1.createElement(it) : {}; 2082 }; 2083 2084 // Thank's IE8 for his funny defineProperty 2085 2086 2087 var ie8DomDefine = !descriptors && !fails(function () { 2088 // eslint-disable-next-line es/no-object-defineproperty -- requied for testing 2089 return Object.defineProperty(documentCreateElement('div'), 'a', { 2090 get: function () { 2091 return 7; 2092 } 2093 }).a != 7; 2094 }); 2095 2096 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2097 2098 2099 var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; // `Object.getOwnPropertyDescriptor` method 2100 // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor 2101 2102 var f$1 = descriptors ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) { 2103 O = toIndexedObject(O); 2104 P = toPropertyKey(P); 2105 if (ie8DomDefine) try { 2106 return $getOwnPropertyDescriptor(O, P); 2107 } catch (error) { 2108 /* empty */ 2109 } 2110 if (hasOwnProperty_1(O, P)) return createPropertyDescriptor(!functionCall(objectPropertyIsEnumerable.f, O, P), O[P]); 2111 }; 2112 2113 var objectGetOwnPropertyDescriptor = { 2114 f: f$1 2115 }; 2116 2117 var String$2 = global_1.String; 2118 var TypeError$5 = global_1.TypeError; // `Assert: Type(argument) is Object` 2119 2120 var anObject = function (argument) { 2121 if (isObject(argument)) return argument; 2122 throw TypeError$5(String$2(argument) + ' is not an object'); 2123 }; 2124 2125 var TypeError$6 = global_1.TypeError; // eslint-disable-next-line es/no-object-defineproperty -- safe 2126 2127 var $defineProperty = Object.defineProperty; // `Object.defineProperty` method 2128 // https://tc39.es/ecma262/#sec-object.defineproperty 2129 2130 var f$2 = descriptors ? $defineProperty : function defineProperty(O, P, Attributes) { 2131 anObject(O); 2132 P = toPropertyKey(P); 2133 anObject(Attributes); 2134 if (ie8DomDefine) try { 2135 return $defineProperty(O, P, Attributes); 2136 } catch (error) { 2137 /* empty */ 2138 } 2139 if ('get' in Attributes || 'set' in Attributes) throw TypeError$6('Accessors not supported'); 2140 if ('value' in Attributes) O[P] = Attributes.value; 2141 return O; 2142 }; 2143 2144 var objectDefineProperty = { 2145 f: f$2 2146 }; 2147 2148 var createNonEnumerableProperty = descriptors ? function (object, key, value) { 2149 return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value)); 2150 } : function (object, key, value) { 2151 object[key] = value; 2152 return object; 2153 }; 2154 2155 var functionToString = functionUncurryThis(Function.toString); // this helper broken in `[email protected]`, so we can't use `shared` helper 2156 2157 if (!isCallable(sharedStore.inspectSource)) { 2158 sharedStore.inspectSource = function (it) { 2159 return functionToString(it); 2160 }; 2161 } 2162 2163 var inspectSource = sharedStore.inspectSource; 2164 2165 var WeakMap = global_1.WeakMap; 2166 var nativeWeakMap = isCallable(WeakMap) && /native code/.test(inspectSource(WeakMap)); 2167 2168 var keys = shared('keys'); 2169 2170 var sharedKey = function (key) { 2171 return keys[key] || (keys[key] = uid(key)); 2172 }; 2173 2174 var hiddenKeys = {}; 2175 2176 var OBJECT_ALREADY_INITIALIZED = 'Object already initialized'; 2177 var TypeError$7 = global_1.TypeError; 2178 var WeakMap$1 = global_1.WeakMap; 2179 var set, get, has; 2180 2181 var enforce = function (it) { 2182 return has(it) ? get(it) : set(it, {}); 2183 }; 2184 2185 var getterFor = function (TYPE) { 2186 return function (it) { 2187 var state; 2188 2189 if (!isObject(it) || (state = get(it)).type !== TYPE) { 2190 throw TypeError$7('Incompatible receiver, ' + TYPE + ' required'); 2191 } 2192 2193 return state; 2194 }; 2195 }; 2196 2197 if (nativeWeakMap || sharedStore.state) { 2198 var store$1 = sharedStore.state || (sharedStore.state = new WeakMap$1()); 2199 var wmget = functionUncurryThis(store$1.get); 2200 var wmhas = functionUncurryThis(store$1.has); 2201 var wmset = functionUncurryThis(store$1.set); 2202 2203 set = function (it, metadata) { 2204 if (wmhas(store$1, it)) throw new TypeError$7(OBJECT_ALREADY_INITIALIZED); 2205 metadata.facade = it; 2206 wmset(store$1, it, metadata); 2207 return metadata; 2208 }; 2209 2210 get = function (it) { 2211 return wmget(store$1, it) || {}; 2212 }; 2213 2214 has = function (it) { 2215 return wmhas(store$1, it); 2216 }; 2217 } else { 2218 var STATE = sharedKey('state'); 2219 hiddenKeys[STATE] = true; 2220 2221 set = function (it, metadata) { 2222 if (hasOwnProperty_1(it, STATE)) throw new TypeError$7(OBJECT_ALREADY_INITIALIZED); 2223 metadata.facade = it; 2224 createNonEnumerableProperty(it, STATE, metadata); 2225 return metadata; 2226 }; 2227 2228 get = function (it) { 2229 return hasOwnProperty_1(it, STATE) ? it[STATE] : {}; 2230 }; 2231 2232 has = function (it) { 2233 return hasOwnProperty_1(it, STATE); 2234 }; 2235 } 2236 2237 var internalState = { 2238 set: set, 2239 get: get, 2240 has: has, 2241 enforce: enforce, 2242 getterFor: getterFor 2243 }; 2244 2245 var FunctionPrototype$1 = Function.prototype; // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2246 2247 var getDescriptor = descriptors && Object.getOwnPropertyDescriptor; 2248 var EXISTS$1 = hasOwnProperty_1(FunctionPrototype$1, 'name'); // additional protection from minified / mangled / dropped function names 2249 2250 var PROPER = EXISTS$1 && function something() { 2251 /* empty */ 2252 }.name === 'something'; 2253 2254 var CONFIGURABLE = EXISTS$1 && (!descriptors || descriptors && getDescriptor(FunctionPrototype$1, 'name').configurable); 2255 var functionName = { 2256 EXISTS: EXISTS$1, 2257 PROPER: PROPER, 2258 CONFIGURABLE: CONFIGURABLE 2259 }; 2260 2261 var redefine = createCommonjsModule(function (module) { 2262 var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE; 2263 2264 var getInternalState = internalState.get; 2265 var enforceInternalState = internalState.enforce;
vendor: 4,394 bytes, lines 2266-2394
2266 var TEMPLATE = String(String).split('String'); 2267 (module.exports = function (O, key, value, options) { 2268 var unsafe = options ? !!options.unsafe : false; 2269 var simple = options ? !!options.enumerable : false; 2270 var noTargetGet = options ? !!options.noTargetGet : false; 2271 var name = options && options.name !== undefined ? options.name : key; 2272 var state; 2273 2274 if (isCallable(value)) { 2275 if (String(name).slice(0, 7) === 'Symbol(') { 2276 name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']'; 2277 } 2278 2279 if (!hasOwnProperty_1(value, 'name') || CONFIGURABLE_FUNCTION_NAME && value.name !== name) { 2280 createNonEnumerableProperty(value, 'name', name); 2281 } 2282 2283 state = enforceInternalState(value); 2284 2285 if (!state.source) { 2286 state.source = TEMPLATE.join(typeof name == 'string' ? name : ''); 2287 } 2288 } 2289 2290 if (O === global_1) { 2291 if (simple) O[key] = value;else setGlobal(key, value); 2292 return; 2293 } else if (!unsafe) { 2294 delete O[key]; 2295 } else if (!noTargetGet && O[key]) { 2296 simple = true; 2297 } 2298 2299 if (simple) O[key] = value;else createNonEnumerableProperty(O, key, value); // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative 2300 })(Function.prototype, 'toString', function toString() { 2301 return isCallable(this) && getInternalState(this).source || inspectSource(this); 2302 }); 2303 }); 2304 2305 var ceil = Math.ceil; 2306 var floor = Math.floor; // `ToIntegerOrInfinity` abstract operation 2307 // https://tc39.es/ecma262/#sec-tointegerorinfinity 2308 2309 var toIntegerOrInfinity = function (argument) { 2310 var number = +argument; // eslint-disable-next-line no-self-compare -- safe 2311 2312 return number !== number || number === 0 ? 0 : (number > 0 ? floor : ceil)(number); 2313 }; 2314 2315 var max = Math.max; 2316 var min = Math.min; // Helper for a popular repeating case of the spec: 2317 // Let integer be ? ToInteger(index). 2318 // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length). 2319 2320 var toAbsoluteIndex = function (index, length) { 2321 var integer = toIntegerOrInfinity(index); 2322 return integer < 0 ? max(integer + length, 0) : min(integer, length); 2323 }; 2324 2325 var min$1 = Math.min; // `ToLength` abstract operation 2326 // https://tc39.es/ecma262/#sec-tolength 2327 2328 var toLength = function (argument) { 2329 return argument > 0 ? min$1(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 2330 }; 2331 2332 // `LengthOfArrayLike` abstract operation 2333 // https://tc39.es/ecma262/#sec-lengthofarraylike 2334 2335 2336 var lengthOfArrayLike = function (obj) { 2337 return toLength(obj.length); 2338 }; 2339 2340 // `Array.prototype.{ indexOf, includes }` methods implementation 2341 2342 2343 var createMethod = function (IS_INCLUDES) { 2344 return function ($this, el, fromIndex) { 2345 var O = toIndexedObject($this); 2346 var length = lengthOfArrayLike(O); 2347 var index = toAbsoluteIndex(fromIndex, length); 2348 var value; // Array#includes uses SameValueZero equality algorithm 2349 // eslint-disable-next-line no-self-compare -- NaN check 2350 2351 if (IS_INCLUDES && el != el) while (length > index) { 2352 value = O[index++]; // eslint-disable-next-line no-self-compare -- NaN check 2353 2354 if (value != value) return true; // Array#indexOf ignores holes, Array#includes - not 2355 } else for (; length > index; index++) { 2356 if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0; 2357 } 2358 return !IS_INCLUDES && -1; 2359 }; 2360 }; 2361 2362 var arrayIncludes = { 2363 // `Array.prototype.includes` method 2364 // https://tc39.es/ecma262/#sec-array.prototype.includes 2365 includes: createMethod(true), 2366 // `Array.prototype.indexOf` method 2367 // https://tc39.es/ecma262/#sec-array.prototype.indexof 2368 indexOf: createMethod(false) 2369 }; 2370 2371 var indexOf = arrayIncludes.indexOf; 2372 2373 2374 2375 var push = functionUncurryThis([].push); 2376 2377 var objectKeysInternal = function (object, names) { 2378 var O = toIndexedObject(object); 2379 var i = 0; 2380 var result = []; 2381 var key; 2382 2383 for (key in O) !hasOwnProperty_1(hiddenKeys, key) && hasOwnProperty_1(O, key) && push(result, key); // Don't enum bug & hidden keys 2384 2385 2386 while (names.length > i) if (hasOwnProperty_1(O, key = names[i++])) { 2387 ~indexOf(result, key) || push(result, key); 2388 } 2389 2390 return result; 2391 }; 2392 2393 // IE8- don't enum bug keys 2394 var enumBugKeys = ['constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleStr
2394ing', 'toString', 'valueOf']; 2395 2396 var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype'); // `Object.getOwnPropertyNames` method 2397 // https://tc39.es/ecma262/#sec-object.getownpropertynames 2398 // eslint-disable-next-line es/no-object-getownpropertynames -- safe 2399 2400 var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { 2401 return objectKeysInternal(O, hiddenKeys$1); 2402 }; 2403 2404 var objectGetOwnPropertyNames = { 2405 f: f$3 2406 }; 2407 2408 // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe 2409 var f$4 = Object.getOwnPropertySymbols; 2410 2411 var objectGetOwnPropertySymbols = { 2412 f: f$4 2413 }; 2414 2415 var concat = functionUncurryThis([].concat); // all object keys, includes non-enumerable and symbols 2416 2417 var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) { 2418 var keys = objectGetOwnPropertyNames.f(anObject(it)); 2419 var getOwnPropertySymbols = objectGetOwnPropertySymbols.f; 2420 return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys; 2421 }; 2422 2423 var copyConstructorProperties = function (target, source) { 2424 var keys = ownKeys(source); 2425 var defineProperty = objectDefineProperty.f; 2426 var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; 2427 2428 for (var i = 0; i < keys.length; i++) { 2429 var key = keys[i]; 2430 if (!hasOwnProperty_1(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key)); 2431 } 2432 }; 2433 2434 var replacement = /#|\.prototype\./; 2435 2436 var isForced = function (feature, detection) { 2437 var value = data[normalize(feature)]; 2438 return value == POLYFILL ? true : value == NATIVE ? false : isCallable(detection) ? fails(detection) : !!detection; 2439 }; 2440 2441 var normalize = isForced.normalize = function (string) { 2442 return String(string).replace(replacement, '.').toLowerCase(); 2443 }; 2444 2445 var data = isForced.data = {}; 2446 var NATIVE = isForced.NATIVE = 'N'; 2447 var POLYFILL = isForced.POLYFILL = 'P'; 2448 var isForced_1 = isForced; 2449 2450 var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f; 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 /* 2462 options.target - name of the target object 2463 options.global - target is the global object 2464 options.stat - export as static methods of target 2465 options.proto - export as prototype methods of target 2466 options.real - real prototype method for the `pure` version 2467 options.forced - export even if the native feature is available 2468 options.bind - bind methods to the target, required for the `pure` version 2469 options.wrap - wrap constructors to preventing global pollution, required for the `pure` version 2470 options.unsafe - use the simple assignment of property instead of delete + defineProperty 2471 options.sham - add a flag to not completely full polyfills 2472 options.enumerable - export as enumerable property 2473 options.noTargetGet - prevent calling a getter on target 2474 options.name - the .name of the function if it does not match the key 2475 */ 2476 2477 2478 var _export = function (options, source) { 2479 var TARGET = options.target; 2480 var GLOBAL = options.global; 2481 var STATIC = options.stat; 2482 var FORCED, target, key, targetProperty, sourceProperty, descriptor; 2483 2484 if (GLOBAL) { 2485 target = global_1; 2486 } else if (STATIC) { 2487 target = global_1[TARGET] || setGlobal(TARGET, {}); 2488 } else { 2489 target = (global_1[TARGET] || {}).prototype; 2490 } 2491 2492 if (target) for (key in source) { 2493 sourceProperty = source[key]; 2494 2495 if (options.noTargetGet) { 2496 descriptor = getOwnPropertyDescriptor$1(target, key); 2497 targetProperty = descriptor && descriptor.value; 2498 } else targetProperty = target[key]; 2499 2500 FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); // contained in target 2501 2502 if (!FORCED && targetProperty !== undefined) { 2503 if (typeof sourceProperty == typeof targetProperty) continue; 2504 copyConstructorProperties(sourceProperty, targetProperty); 2505 } // add a flag to not completely full polyfills 2506 2507 2508 if (options.sham || targetProperty && targetProperty.sham) { 2509 createNonEnumerableProperty(sourceProperty, 'sham', true); 2510 } // extend global 2511 2512 2513 redefine(target, key, sourceProperty, options); 2514 } 2515 }; 2516 2517 var correctPrototypeGetter = !fails(function () { 2518 function F() { 2519 /* empty */ 2520 } 2521 2522 F.prototype.constructor = null; // eslint-disable-next-line es/no-object-getprototypeof -- required for testing 2523 2524 return Object.getPrototypeOf(new F()) !== F.prototype; 2525 }); 2526 2527 var IE_PROTO = sharedKey('IE_PROTO'); 2528 var Object$4 = global_1.Object; 2529 var ObjectPrototype = Object$4.prototype; // `Object.getPrototypeOf` method 2530 // https://tc39.es/ecma262/#sec-object.getprototypeof 2531 2532 var objectGetPrototypeOf = correctPrototypeGetter ? Object$4.getPrototypeOf : function (O) { 2533 var object = toObject(O); 2534 if (hasOwnProperty_1(object, IE_PROTO)) return object[IE_PROTO]; 2535 var constructor = object.constructor; 2536 2537 if (isCallable(constructor) && object instanceof constructor) { 2538 return constructor.prototype; 2539 } 2540
2541 return object instanceof Object$4 ? ObjectPrototype : null; 2542 }; 2543 2544 var String$3 = global_1.String; 2545 var TypeError$8 = global_1.TypeError; 2546 2547 var aPossiblePrototype = function (argument) { 2548 if (typeof argument == 'object' || isCallable(argument)) return argument; 2549 throw TypeError$8("Can't set " + String$3(argument) + ' as a prototype'); 2550 }; 2551 2552 /* eslint-disable no-proto -- safe */ 2553 2554 2555 2556 2557 // `Object.setPrototypeOf` method 2558 // https://tc39.es/ecma262/#sec-object.setprototypeof 2559 // Works with __proto__ only. Old v8 can't work with null proto objects. 2560 // eslint-disable-next-line es/no-object-setprototypeof -- safe 2561 2562 2563 var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () { 2564 var CORRECT_SETTER = false; 2565 var test = {}; 2566 var setter; 2567 2568 try { 2569 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2570 setter = functionUncurryThis(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set); 2571 setter(test, []); 2572 CORRECT_SETTER = test instanceof Array; 2573 } catch (error) { 2574 /* empty */ 2575 } 2576 2577 return function setPrototypeOf(O, proto) { 2578 anObject(O); 2579 aPossiblePrototype(proto); 2580 if (CORRECT_SETTER) setter(O, proto);else O.__proto__ = proto; 2581 return O; 2582 }; 2583 }() : undefined); 2584 2585 // `Object.keys` method 2586 // https://tc39.es/ecma262/#sec-object.keys 2587 // eslint-disable-next-line es/no-object-keys -- safe 2588 2589 2590 var objectKeys = Object.keys || function keys(O) { 2591 return objectKeysInternal(O, enumBugKeys); 2592 }; 2593 2594 // `Object.defineProperties` method 2595 // https://tc39.es/ecma262/#sec-object.defineproperties 2596 // eslint-disable-next-line es/no-object-defineproperties -- safe 2597 2598 2599 var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) { 2600 anObject(O); 2601 var props = toIndexedObject(Properties); 2602 var keys = objectKeys(Properties); 2603 var length = keys.length; 2604 var index = 0; 2605 var key; 2606 2607 while (length > index) objectDefineProperty.f(O, key = keys[index++], props[key]); 2608 2609 return O; 2610 }; 2611 2612 var html = getBuiltIn('document', 'documentElement'); 2613 2614 /* global ActiveXObject -- old IE, WSH */ 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 var GT = '>'; 2630 var LT = '<'; 2631 var PROTOTYPE = 'prototype'; 2632 var SCRIPT = 'script'; 2633 var IE_PROTO$1 = sharedKey('IE_PROTO'); 2634 2635 var EmptyConstructor = function () { 2636 /* empty */ 2637 }; 2638 2639 var scriptTag = function (content) { 2640 return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT; 2641 }; // Create object with fake `null` prototype: use ActiveX Object with cleared prototype 2642 2643 2644 var NullProtoObjectViaActiveX = function (activeXDocument) { 2645 activeXDocument.write(scriptTag('')); 2646 activeXDocument.close(); 2647 var temp = activeXDocument.parentWindow.Object; 2648 activeXDocument = null; // avoid memory leak 2649 2650 return temp; 2651 }; // Create object with fake `null` prototype: use iframe Object with cleared prototype 2652 2653 2654 var NullProtoObjectViaIFrame = function () { 2655 // Thrash, waste and sodomy: IE GC bug 2656 var iframe = documentCreateElement('iframe'); 2657 var JS = 'java' + SCRIPT + ':'; 2658 var iframeDocument; 2659 iframe.style.display = 'none'; 2660 html.appendChild(iframe); // https://github.com/zloirock/core-js/issues/475 2661 2662 iframe.src = String(JS); 2663 iframeDocument = iframe.contentWindow.document; 2664 iframeDocument.open(); 2665 iframeDocument.write(scriptTag('document.F=Object')); 2666 iframeDocument.close(); 2667 return iframeDocument.F; 2668 }; // Check for document.domain and active x support 2669 // No need to use active x approach when document.domain is not set 2670 // see https://github.com/es-shims/es5-shim/issues/150 2671 // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346 2672 // avoid IE GC bug 2673 2674 2675 var activeXDocument; 2676 2677 var NullProtoObject = function () { 2678 try { 2679 activeXDocument = new ActiveXObject('htmlfile'); 2680 } catch (error) { 2681 /* ignore */ 2682 } 2683 2684 NullProtoObject = typeof document != 'undefined' ? document.domain && activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) // old IE 2685 : NullProtoObjectViaIFrame() : NullProtoObjectViaActiveX(activeXDocument); // WSH 2686 2687 var length = enumBugKeys.length; 2688 2689 while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]]; 2690 2691 return NullProtoObject(); 2692 }; 2693 2694 hiddenKeys[IE_PROTO$1] = true; // `Object.create` method 2695 // https://tc39.es/ecma262/#sec-object.create 2696 2697 var objectCreate = Object.create || function create(O, Properties) { 2698 var result; 2699 2700 if (O !== null) { 2701 EmptyConstructor[PROTOTYPE] = anObject(O); 2702 result = new EmptyConstructor(); 2703 EmptyConstructor[PROTOTYPE] = null; // add "__proto__" for Object.getPrototypeOf polyfill 2704 2705 result[IE_PROTO$1] = O; 2706 } else result = NullProtoObject(); 2707 2708 return Properties === undefined ? result : objectDefineProperties(result, Properties); 2709 }; 2710 2711 var createProperty = function (object, key, value) { 2712 var propertyKey = toPropertyKey(key); 2713 if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value));else object[propertyKey] = value; 2714 }; 2715 2716 var Array$1 = global_1.Array; 2717 var max$1 = Math.max; 2718 2719 var arraySliceSimple = function (O, start, end) { 2720 var length = lengthOfArrayLike(O); 2721 var k = toAbsoluteIndex(start, length); 2722 var fin = toAbsoluteIndex(end === undefined ? length : end, length); 2723 var result = Array$1(max$1(fin - k, 0)); 2724 2725 for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]); 2726 2727 result.length = n; 2728 return result; 2729 }; 2730 2731 var replace = functionUncurryThis(''.replace); 2732 var split$1 = functionUncurryThis(''.split); 2733 var join = functionUncurryThis([].join); 2734 2735 var TEST = function (arg) { 2736 return String(Error(arg).stack); 2737 }('zxcasd'); 2738 2739 var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/; 2740 var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST); 2741 var IS_FIREFOX_OR_SAFARI_STACK = /@[^\n]*\n/.test(TEST) && !/zxcasd/.test(TEST); 2742 2743 var clearErrorStack = function (stack, dropEntries) { 2744 if (typeof stack != 'string') return stack; 2745 2746 if (IS_V8_OR_CHAKRA_STACK) { 2747 while (dropEntries--) stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, ''); 2748 }
2748 else if (IS_FIREFOX_OR_SAFARI_STACK) { 2749 return join(arraySliceSimple(split$1(stack, '\n'), dropEntries), '\n'); 2750 } 2751 2752 return stack; 2753 }; 2754 2755 // `InstallErrorCause` abstract operation 2756 // https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause 2757 2758 2759 var installErrorCause = function (O, options) { 2760 if (isObject(options) && 'cause' in options) { 2761 createNonEnumerableProperty(O, 'cause', options.cause); 2762 } 2763 }; 2764 2765 var bind$1 = functionUncurryThis(functionUncurryThis.bind); // optional / simple context binding 2766 2767 var functionBindContext = function (fn, that) { 2768 aCallable(fn); 2769 return that === undefined ? fn : bind$1 ? bind$1(fn, that) : function () 2770 /* ...args */ 2771 { 2772 return fn.apply(that, arguments); 2773 }; 2774 }; 2775 2776 var iterators = {}; 2777 2778 var ITERATOR = wellKnownSymbol('iterator'); 2779 var ArrayPrototype = Array.prototype; // check on default Array iterator 2780 2781 var isArrayIteratorMethod = function (it) { 2782 return it !== undefined && (iterators.Array === it || ArrayPrototype[ITERATOR] === it); 2783 }; 2784 2785 var TO_STRING_TAG = wellKnownSymbol('toStringTag'); 2786 var test = {}; 2787 test[TO_STRING_TAG] = 'z'; 2788 var toStringTagSupport = String(test) === '[object z]'; 2789 2790 var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag'); 2791 var Object$5 = global_1.Object; // ES3 wrong here 2792 2793 var CORRECT_ARGUMENTS = classofRaw(function () { 2794 return arguments; 2795 }()) == 'Arguments'; // fallback for IE11 Script Access Denied error 2796 2797 var tryGet = function (it, key) { 2798 try { 2799 return it[key]; 2800 } catch (error) { 2801 /* empty */ 2802 } 2803 }; // getting tag from ES6+ `Object.prototype.toString` 2804 2805 2806 var classof = toStringTagSupport ? classofRaw : function (it) { 2807 var O, tag, result; 2808 return it === undefined ? 'Undefined' : it === null ? 'Null' // @@toStringTag case 2809 : typeof (tag = tryGet(O = Object$5(it), TO_STRING_TAG$1)) == 'string' ? tag // builtinTag case 2810 : CORRECT_ARGUMENTS ? classofRaw(O) // ES3 arguments fallback 2811 : (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result; 2812 }; 2813 2814 var ITERATOR$1 = wellKnownSymbol('iterator'); 2815 2816 var getIteratorMethod = function (it) { 2817 if (it != undefined) return getMethod(it, ITERATOR$1) || getMethod(it, '@@iterator') || iterators[classof(it)]; 2818 }; 2819 2820 var TypeError$9 = global_1.TypeError; 2821 2822 var getIterator = function (argument, usingIterator) { 2823 var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator; 2824 if (aCallable(iteratorMethod)) return anObject(functionCall(iteratorMethod, argument)); 2825 throw TypeError$9(tryToString(argument) + ' is not iterable'); 2826 }; 2827 2828 var iteratorClose = function (iterator, kind, value) { 2829 var innerResult, innerError; 2830 anObject(iterator); 2831 2832 try { 2833 innerResult = getMethod(iterator, 'return'); 2834 2835 if (!innerResult) { 2836 if (kind === 'throw') throw value; 2837 return value; 2838 } 2839 2840 innerResult = functionCall(innerResult, iterator); 2841 } catch (error) { 2842 innerError = true; 2843 innerResult = error; 2844 } 2845 2846 if (kind === 'throw') throw value; 2847 if (innerError) throw innerResult; 2848 anObject(innerResult); 2849 return value; 2850 }; 2851 2852 var TypeError$a = global_1.TypeError; 2853 2854 var Result = function (stopped, result) { 2855 this.stopped = stopped; 2856 this.result = result; 2857 }; 2858 2859 var ResultPrototype = Result.prototype; 2860 2861 var iterate = function (iterable, unboundFunction, options) { 2862 var that = options && options.that; 2863 var AS_ENTRIES = !!(options && options.AS_ENTRIES); 2864 var IS_ITERATOR = !!(options && options.IS_ITERATOR); 2865 var INTERRUPTED = !!(options && options.INTERRUPTED); 2866 var fn = functionBindContext(unboundFunction, that); 2867 var iterator, iterFn, index, length, result, next, step; 2868 2869 var stop = function (condition) { 2870 if (iterator) iteratorClose(iterator, 'normal', condition); 2871 return new Result(true, condition); 2872 }; 2873 2874 var callFn = function (value) { 2875 if (AS_ENTRIES) { 2876 anObject(value); 2877 return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]); 2878 } 2879 2880 return INTERRUPTED ? fn(value, stop) : fn(value); 2881 }; 2882 2883 if (IS_ITERATOR) { 2884 iterator = iterable; 2885 } else { 2886 iterFn = getIteratorMethod(iterable); 2887 if (!iterFn) throw TypeError$a(tryToString(iterable) + ' is not iterable'); // optimisation for array iterators 2888 2889 if (isArrayIteratorMethod(iterFn)) { 2890 for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) { 2891 result = callFn(iterable[index]); 2892 if (result && objectIsPrototypeOf(ResultPrototype, result)) return result; 2893 } 2894 2895 return new Result(false); 2896 } 2897 2898 iterator = getIterator(iterable, iterFn); 2899 } 2900 2901 next = iterator.next; 2902 2903 while (!(step = functionCall(next, iterator)).done) { 2904 try { 2905 result = callFn(step.value); 2906 } catch (error) { 2907 iteratorClose(iterator, 'throw', error); 2908 } 2909 2910 if (typeof result == 'object' && result && objectIsPrototypeOf(ResultPrototype, result)) return result; 2911 } 2912 2913 return new Result(false); 2914 }; 2915 2916 var String$4 = global_1.String; 2917 2918 var toString_1 = function (argument) { 2919 if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string'); 2920 return String$4(argument); 2921 }; 2922 2923 var normalizeStringArgument = function (argument, $default) { 2924 return argument === undefined ? arguments.length < 2 ? '' : $default : toString_1(argument); 2925 }; 2926 2927 var errorStackInstallable = !fails(function () { 2928 var error = Error('a'); 2929 if (!('stack' in error)) return true; // eslint-disable-next-line es/no-object-defineproperty -- safe 2930 2931 Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7)); 2932 return error.stack !== 7; 2933 }); 2934 2935 var TO_STRING_TAG$2 = wellKnownSymbol('toStringTag'); 2936 var Error$1 = global_1.Error; 2937 var push$1 = [].push; 2938 2939 var $AggregateError = function AggregateError(errors, message 2940 /* , options */ 2941 ) { 2942 var options = arguments.length > 2 ? arguments[2] : undefined; 2943 var isInstance = objectIsPrototypeOf(AggregateErrorPrototype, this); 2944 var that; 2945 2946 if (objectSetPrototypeOf) { 2947 that = objectSetPrototypeOf(new Error$1(undefined), isInstance ? objectGetPrototypeOf(this) : AggregateErrorPrototype); 2948 } else { 2949 that = isInstance ? this : objectCreate(AggregateErrorPrototype); 2950 createNonEnumerableProperty(that, TO_STRING_TAG$2, 'Error'); 2951 } 2952 2953 createNonEnumerableProperty(that, 'message', normalizeStringArgument(message, '')); 2954 if (errorStackInstallable) createNonEnumerableProperty(that, 'stack', clearErrorStack(that.stack, 1)); 2955 installErrorCause(that, options); 2956 var errorsArray = []; 2957 iterate(errors, push$1, { 2958 that: errorsArray 2959 }); 2960 createNonEnumerableProperty(that, 'errors', errorsArray); 2961 return that; 2962 }; 2963 2964 if (objectSetPrototypeOf) objectSetPrototypeOf($AggregateError, Error$1);else copyConstructorProperties($AggregateError, Error$1); 2965 var AggregateErrorPrototype = $AggregateError.prototype = objectCreate(Error$1.prototype, { 2966 constructor: createPropertyDescriptor(1, $AggregateError), 2967 message: createPropertyDescriptor(1, ''), 2968 name: createPropertyDescriptor(1, 'AggregateError') 2969 }); // `AggregateError` constructor 2970 // https://tc39.es/ecma262/#sec-aggregate-error-constructor 2971 2972 _export({ 2973 global: true 2974 }, { 2975 AggregateError: $AggregateError 2976 }); 2977 2978 var UNSCOPABLES = wellKnownSymbol('unscopables'); 2979 var ArrayPrototype$1 = Array.prototype; // Array.prototype[@@unscopables] 2980 // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 2981 2982 if (ArrayPrototype$1[UNSCOPABLES] == undefined) { 2983 objectDefineProperty.f(ArrayPrototype$1, UNSCOPABLES, { 2984 configurable: true, 2985 value: objectCreate(null) 2986 }); 2987 } // add a key to Array.prototype[@@unscopables] 2988 2989 2990 var addToUnscopables = function (key) { 2991 ArrayPrototype$1[UNSCOPABLES][key] = true; 2992 }; 2993 2994 // `Array.prototype.at` method 2995 // https://github.com/tc39/proposal-relative-indexing-method 2996 2997 2998 _export({ 2999 target: 'Array', 3000 proto: true 3001 }, { 3002 at: function at(index) { 3003 var O = toObject(this); 3004 var len = lengthOfArrayLike(O); 3005 var relativeIndex = toIntegerOrInfinity(index); 3006 var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; 3007 return k < 0 || k >= len ? undefined : O[k]; 3008 } 3009 }); 3010 addToUnscopables('at'); 3011 3012 // `IsArray` abstract operation 3013 // https://tc39.es/ecma262/#sec-isarray 3014 // eslint-disable-next-line es/no-array-isarray -- safe 3015 3016 3017 var isArray = Array.isArray || function isArray(argument) { 3018 return classofRaw(argument) == 'Array'; 3019 }; 3020 3021 var un$Reverse = functionUncurryThis([].reverse); 3022 var test$1 = [1, 2]; // `Array.prototype.reverse` method 3023 // https://tc39.es/ecma262/#sec-array.prototype.reverse 3024 // fix for Safari 12.0 bug 3025 // https://bugs.webkit.org/show_bug.cgi?id=188794 3026 3027 _export({ 3028 target: 'Array', 3029 proto: true, 3030 forced: String(test$1) === String(test$1.reverse()) 3031 }, { 3032 reverse: function reverse() { 3033 // eslint-disable-next-line no-self-assign -- dirty hack 3034 if (isArray(this)) this.length = this.length; 3035 return un$Reverse(this); 3036 } 3037 }); 3038 3039 // eslint-disable-next-line es/no-typed-arrays -- safe 3040 var arrayBufferNative = typeof ArrayBuffer != 'undefined' && typeof DataView != 'undefined'; 3041 3042 var redefineAll = function (target, src, options) { 3043 for (var key in src) redefine(target, key, src[key], options); 3044 3045 return target; 3046 }; 3047 3048 var TypeError$b = global_1.TypeError; 3049 3050 var anInstance = function (it, Prototype) { 3051 if (objectIsPrototypeOf(Prototype, it)) return it; 3052 throw TypeError$b('Incorrect invocation'); 3053 }; 3054 3055 var RangeError = global_1.RangeError; // `ToIndex` abstract operation 3056 // https://tc39.es/ecma262/#sec-toindex 3057 3058 var toIndex = function (it) { 3059 if (it === undefined) return 0; 3060 var number = toIntegerOrInfinity(it); 3061 var length = toLength(number); 3062 if (number !== length) throw RangeError('Wrong length or index'); 3063 return length; 3064 }; 3065 3066 // IEEE754 conversions based on https://github.com/feross/ieee754 3067 3068 3069 var Array$2 = global_1.Array; 3070 var abs = Math.abs; 3071 var pow = Math.pow; 3072 var floor$1 = Math.floor; 3073 var log = Math.log; 3074 var LN2 = Math.LN2; 3075 3076 var pack = function (number, mantissaLength, bytes) { 3077 var buffer = Array$2(bytes); 3078 var exponentLength = bytes * 8 - mantissaLength - 1; 3079 var eMax = (1 << exponentLength) - 1; 3080 var eBias = eMax >> 1; 3081 var rt = mantissaLength === 23 ? pow(2, -24) - pow(2, -77) : 0; 3082 var sign = number < 0 || number === 0 && 1 / number < 0 ? 1 : 0; 3083 var index = 0; 3084 var exponent, mantissa, c; 3085 number = abs(number); // eslint-disable-next-line no-self-compare -- NaN check 3086 3087 if (number != number || number === Infinity) { 3088 // eslint-disable-next-line no-self-compare -- NaN check 3089 mantissa = number != number ? 1 : 0; 3090 exponent = eMax; 3091 } else { 3092 exponent = floor$1(log(number) / LN2); 3093 c = pow(2, -exponent); 3094 3095 if (number * c < 1) { 3096 exponent--; 3097 c *= 2; 3098 } 3099 3100 if (exponent + eBias >= 1) { 3101 number += rt / c; 3102 } else { 3103 number += rt * pow(2, 1 - eBias); 3104 } 3105 3106 if (number * c >= 2) { 3107 exponent++; 3108 c /= 2; 3109 } 3110 3111 if (exponent + eBias >= eMax) { 3112 mantissa = 0; 3113 exponent = eMax; 3114 } else if (exponent + eBias >= 1) { 3115 mantissa = (number * c - 1) * pow(2, mantissaLength); 3116 exponent = exponent + eBias; 3117 } else { 3118 mantissa = number * pow(2, eBias - 1) * pow(2, mantissaLength); 3119 exponent = 0; 3120 } 3121 } 3122 3123 while (mantissaLength >= 8) { 3124 buffer[index++] = mantissa & 255; 3125 mantissa /= 256; 3126 mantissaLength -= 8; 3127 } 3128 3129 exponent = exponent << mantissaLength | mantissa; 3130 exponentLength += mantissaLength; 3131 3132 while (exponentLength > 0) { 3133 buffer[index++] = exponent & 255; 3134 exponent /= 256; 3135 exponentLength -= 8; 3136 } 3137 3138 buffer[--index] |= sign * 128; 3139 return buffer; 3140 }; 3141 3142 var unpack = function (buffer, mantissaLength) { 3143 var bytes = buffer.length; 3144 var exponentLength = bytes * 8 - mantissaLength - 1; 3145 var eMax = (1 << exponentLength) - 1; 3146 var eBias = eMax >> 1;
vendor: 6,238 bytes, lines 3147-3361
3147 var nBits = exponentLength - 7; 3148 var index = bytes - 1; 3149 var sign = buffer[index--]; 3150 var exponent = sign & 127; 3151 var mantissa; 3152 sign >>= 7; 3153 3154 while (nBits > 0) { 3155 exponent = exponent * 256 + buffer[index--]; 3156 nBits -= 8; 3157 } 3158 3159 mantissa = exponent & (1 << -nBits) - 1; 3160 exponent >>= -nBits; 3161 nBits += mantissaLength; 3162 3163 while (nBits > 0) { 3164 mantissa = mantissa * 256 + buffer[index--]; 3165 nBits -= 8; 3166 } 3167 3168 if (exponent === 0) { 3169 exponent = 1 - eBias; 3170 } else if (exponent === eMax) { 3171 return mantissa ? NaN : sign ? -Infinity : Infinity; 3172 } else { 3173 mantissa = mantissa + pow(2, mantissaLength); 3174 exponent = exponent - eBias; 3175 } 3176 3177 return (sign ? -1 : 1) * mantissa * pow(2, exponent - mantissaLength); 3178 }; 3179 3180 var ieee754 = { 3181 pack: pack, 3182 unpack: unpack 3183 }; 3184 3185 // `Array.prototype.fill` method implementation 3186 // https://tc39.es/ecma262/#sec-array.prototype.fill 3187 3188 3189 var arrayFill = function fill(value 3190 /* , start = 0, end = @length */ 3191 ) { 3192 var O = toObject(this); 3193 var length = lengthOfArrayLike(O); 3194 var argumentsLength = arguments.length; 3195 var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length); 3196 var end = argumentsLength > 2 ? arguments[2] : undefined; 3197 var endPos = end === undefined ? length : toAbsoluteIndex(end, length); 3198 3199 while (endPos > index) O[index++] = value; 3200 3201 return O; 3202 }; 3203 3204 var defineProperty$1 = objectDefineProperty.f; 3205 3206 3207 3208 3209 3210 var TO_STRING_TAG$3 = wellKnownSymbol('toStringTag'); 3211 3212 var setToStringTag = function (it, TAG, STATIC) { 3213 if (it && !hasOwnProperty_1(it = STATIC ? it : it.prototype, TO_STRING_TAG$3)) { 3214 defineProperty$1(it, TO_STRING_TAG$3, { 3215 configurable: true, 3216 value: TAG 3217 }); 3218 } 3219 }; 3220 3221 var getOwnPropertyNames = objectGetOwnPropertyNames.f; 3222 3223 var defineProperty$2 = objectDefineProperty.f; 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 var PROPER_FUNCTION_NAME = functionName.PROPER; 3234 var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE; 3235 var getInternalState = internalState.get; 3236 var setInternalState = internalState.set; 3237 var ARRAY_BUFFER = 'ArrayBuffer'; 3238 var DATA_VIEW = 'DataView'; 3239 var PROTOTYPE$1 = 'prototype'; 3240 var WRONG_LENGTH = 'Wrong length'; 3241 var WRONG_INDEX = 'Wrong index'; 3242 var NativeArrayBuffer = global_1[ARRAY_BUFFER]; 3243 var $ArrayBuffer = NativeArrayBuffer; 3244 var ArrayBufferPrototype = $ArrayBuffer && $ArrayBuffer[PROTOTYPE$1]; 3245 var $DataView = global_1[DATA_VIEW]; 3246 var DataViewPrototype = $DataView && $DataView[PROTOTYPE$1]; 3247 var ObjectPrototype$1 = Object.prototype; 3248 var Array$3 = global_1.Array; 3249 var RangeError$1 = global_1.RangeError; 3250 var fill = functionUncurryThis(arrayFill); 3251 var reverse = functionUncurryThis([].reverse); 3252 var packIEEE754 = ieee754.pack; 3253 var unpackIEEE754 = ieee754.unpack; 3254 3255 var packInt8 = function (number) { 3256 return [number & 0xFF]; 3257 }; 3258 3259 var packInt16 = function (number) { 3260 return [number & 0xFF, number >> 8 & 0xFF]; 3261 }; 3262 3263 var packInt32 = function (number) { 3264 return [number & 0xFF, number >> 8 & 0xFF, number >> 16 & 0xFF, number >> 24 & 0xFF]; 3265 }; 3266 3267 var unpackInt32 = function (buffer) { 3268 return buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0]; 3269 }; 3270 3271 var packFloat32 = function (number) { 3272 return packIEEE754(number, 23, 4); 3273 }; 3274 3275 var packFloat64 = function (number) { 3276 return packIEEE754(number, 52, 8); 3277 }; 3278 3279 var addGetter = function (Constructor, key) { 3280 defineProperty$2(Constructor[PROTOTYPE$1], key, { 3281 get: function () { 3282 return getInternalState(this)[key]; 3283 } 3284 }); 3285 }; 3286 3287 var get$1 = function (view, count, index, isLittleEndian) { 3288 var intIndex = toIndex(index); 3289 var store = getInternalState(view); 3290 if (intIndex + count > store.byteLength) throw RangeError$1(WRONG_INDEX); 3291 var bytes = getInternalState(store.buffer).bytes; 3292 var start = intIndex + store.byteOffset; 3293 var pack = arraySliceSimple(bytes, start, start + count); 3294 return isLittleEndian ? pack : reverse(pack); 3295 }; 3296 3297 var set$1 = function (view, count, index, conversion, value, isLittleEndian) { 3298 var intIndex = toIndex(index); 3299 var store = getInternalState(view); 3300 if (intIndex + count > store.byteLength) throw RangeError$1(WRONG_INDEX); 3301 var bytes = getInternalState(store.buffer).bytes; 3302 var start = intIndex + store.byteOffset; 3303 var pack = conversion(+value); 3304 3305 for (var i = 0; i < count; i++) bytes[start + i] = pack[isLittleEndian ? i : count - i - 1]; 3306 }; 3307 3308 if (!arrayBufferNative) { 3309 $ArrayBuffer = function ArrayBuffer(length) { 3310 anInstance(this, ArrayBufferPrototype); 3311 var byteLength = toIndex(length); 3312 setInternalState(this, { 3313 bytes: fill(Array$3(byteLength), 0), 3314 byteLength: byteLength 3315 }); 3316 if (!descriptors) this.byteLength = byteLength; 3317 }; 3318 3319 ArrayBufferPrototype = $ArrayBuffer[PROTOTYPE$1]; 3320 3321 $DataView = function DataView(buffer, byteOffset, byteLength) { 3322 anInstance(this, DataViewPrototype); 3323 anInstance(buffer, ArrayBufferPrototype); 3324 var bufferLength = getInternalState(buffer).byteLength; 3325 var offset = toIntegerOrInfinity(byteOffset); 3326 if (offset < 0 || offset > bufferLength) throw RangeError$1('Wrong offset'); 3327 byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength); 3328 if (offset + byteLength > bufferLength) throw RangeError$1(WRONG_LENGTH); 3329 setInternalState(this, { 3330 buffer: buffer, 3331 byteLength: byteLength, 3332 byteOffset: offset 3333 }); 3334 3335 if (!descriptors) { 3336 this.buffer = buffer; 3337 this.byteLength = byteLength; 3338 this.byteOffset = offset; 3339 } 3340 }; 3341 3342 DataViewPrototype = $DataView[PROTOTYPE$1]; 3343 3344 if (descriptors) { 3345 addGetter($ArrayBuffer, 'byteLength'); 3346 addGetter($DataView, 'buffer'); 3347 addGetter($DataView, 'byteLength'); 3348 addGetter($DataView, 'byteOffset'); 3349 } 3350 3351 redefineAll(DataViewPrototype, { 3352 getInt8: function getInt8(byteOffset) { 3353 return get$1(this, 1, byteOffset)[0] << 24 >> 24; 3354 }, 3355 getUint8: function getUint8(byteOffset) { 3356 return get$1(this, 1, byteOffset)[0]; 3357 }, 3358 getInt16: function getInt16(byteOffset 3359 /* , littleEndian */ 3360 ) { 3361 var bytes = get$1(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined);
vendor: 5,073 bytes, lines 3362-3500
3362 return (bytes[1] << 8 | bytes[0]) << 16 >> 16; 3363 }, 3364 getUint16: function getUint16(byteOffset 3365 /* , littleEndian */ 3366 ) { 3367 var bytes = get$1(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined); 3368 return bytes[1] << 8 | bytes[0]; 3369 }, 3370 getInt32: function getInt32(byteOffset 3371 /* , littleEndian */ 3372 ) { 3373 return unpackInt32(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)); 3374 }, 3375 getUint32: function getUint32(byteOffset 3376 /* , littleEndian */ 3377 ) { 3378 return unpackInt32(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)) >>> 0; 3379 }, 3380 getFloat32: function getFloat32(byteOffset 3381 /* , littleEndian */ 3382 ) { 3383 return unpackIEEE754(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 23); 3384 }, 3385 getFloat64: function getFloat64(byteOffset 3386 /* , littleEndian */ 3387 ) { 3388 return unpackIEEE754(get$1(this, 8, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 52); 3389 }, 3390 setInt8: function setInt8(byteOffset, value) { 3391 set$1(this, 1, byteOffset, packInt8, value); 3392 }, 3393 setUint8: function setUint8(byteOffset, value) { 3394 set$1(this, 1, byteOffset, packInt8, value); 3395 }, 3396 setInt16: function setInt16(byteOffset, value 3397 /* , littleEndian */ 3398 ) { 3399 set$1(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined); 3400 }, 3401 setUint16: function setUint16(byteOffset, value 3402 /* , littleEndian */ 3403 ) { 3404 set$1(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined); 3405 }, 3406 setInt32: function setInt32(byteOffset, value 3407 /* , littleEndian */ 3408 ) { 3409 set$1(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined); 3410 }, 3411 setUint32: function setUint32(byteOffset, value 3412 /* , littleEndian */ 3413 ) { 3414 set$1(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined); 3415 }, 3416 setFloat32: function setFloat32(byteOffset, value 3417 /* , littleEndian */ 3418 ) { 3419 set$1(this, 4, byteOffset, packFloat32, value, arguments.length > 2 ? arguments[2] : undefined); 3420 }, 3421 setFloat64: function setFloat64(byteOffset, value 3422 /* , littleEndian */ 3423 ) { 3424 set$1(this, 8, byteOffset, packFloat64, value, arguments.length > 2 ? arguments[2] : undefined); 3425 } 3426 }); 3427 } else { 3428 var INCORRECT_ARRAY_BUFFER_NAME = PROPER_FUNCTION_NAME && NativeArrayBuffer.name !== ARRAY_BUFFER; 3429 /* eslint-disable no-new -- required for testing */ 3430 3431 if (!fails(function () { 3432 NativeArrayBuffer(1); 3433 }) || !fails(function () { 3434 new NativeArrayBuffer(-1); 3435 }) || fails(function () { 3436 new NativeArrayBuffer(); 3437 new NativeArrayBuffer(1.5); 3438 new NativeArrayBuffer(NaN); 3439 return INCORRECT_ARRAY_BUFFER_NAME && !CONFIGURABLE_FUNCTION_NAME; 3440 })) { 3441 /* eslint-enable no-new -- required for testing */ 3442 $ArrayBuffer = function ArrayBuffer(length) { 3443 anInstance(this, ArrayBufferPrototype); 3444 return new NativeArrayBuffer(toIndex(length)); 3445 }; 3446 3447 $ArrayBuffer[PROTOTYPE$1] = ArrayBufferPrototype; 3448 3449 for (var keys$1 = getOwnPropertyNames(NativeArrayBuffer), j = 0, key; keys$1.length > j;) { 3450 if (!((key = keys$1[j++]) in $ArrayBuffer)) { 3451 createNonEnumerableProperty($ArrayBuffer, key, NativeArrayBuffer[key]); 3452 } 3453 } 3454 3455 ArrayBufferPrototype.constructor = $ArrayBuffer; 3456 } else if (INCORRECT_ARRAY_BUFFER_NAME && CONFIGURABLE_FUNCTION_NAME) { 3457 createNonEnumerableProperty(NativeArrayBuffer, 'name', ARRAY_BUFFER); 3458 } // WebKit bug - the same parent prototype for typed arrays and data view 3459 3460 3461 if (objectSetPrototypeOf && objectGetPrototypeOf(DataViewPrototype) !== ObjectPrototype$1) { 3462 objectSetPrototypeOf(DataViewPrototype, ObjectPrototype$1); 3463 } // iOS Safari 7.x bug 3464 3465 3466 var testView = new $DataView(new $ArrayBuffer(2)); 3467 var $setInt8 = functionUncurryThis(DataViewPrototype.setInt8); 3468 testView.setInt8(0, 2147483648); 3469 testView.setInt8(1, 2147483649); 3470 if (testView.getInt8(0) || !testView.getInt8(1)) redefineAll(DataViewPrototype, { 3471 setInt8: function setInt8(byteOffset, value) { 3472 $setInt8(this, byteOffset, value << 24 >> 24); 3473 }, 3474 setUint8: function setUint8(byteOffset, value) { 3475 $setInt8(this, byteOffset, value << 24 >> 24); 3476 } 3477 }, { 3478 unsafe: true 3479 }); 3480 } 3481 3482 setToStringTag($ArrayBuffer, ARRAY_BUFFER); 3483 setToStringTag($DataView, DATA_VIEW); 3484 var arrayBuffer = { 3485 ArrayBuffer: $ArrayBuffer, 3486 DataView: $DataView 3487 }; 3488 3489 var noop = function () { 3490 /* empty */ 3491 }; 3492 3493 var empty = []; 3494 var construct = getBuiltIn('Reflect', 'construct'); 3495 var constructorRegExp = /^\s*(?:class|function)\b/; 3496 var exec = functionUncurryThis(constructorRegExp.exec); 3497 var INCORRECT_TO_STRING = !constructorRegExp.exec(noop); 3498 3499 var isConstructorModern = function (argument) { 3500 if (!isCallable(argument)) return false;
3501 3502 try { 3503 construct(noop, empty, argument); 3504 return true; 3505 } catch (error) { 3506 return false; 3507 } 3508 }; 3509 3510 var isConstructorLegacy = function (argument) { 3511 if (!isCallable(argument)) return false; 3512 3513 switch (classof(argument)) { 3514 case 'AsyncFunction': 3515 case 'GeneratorFunction': 3516 case 'AsyncGeneratorFunction': 3517 return false; 3518 // we can't check .prototype since constructors produced by .bind haven't it 3519 } 3520 3521 return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument)); 3522 }; // `IsConstructor` abstract operation 3523 // https://tc39.es/ecma262/#sec-isconstructor 3524 3525 3526 var isConstructor = !construct || fails(function () { 3527 var called; 3528 return isConstructorModern(isConstructorModern.call) || !isConstructorModern(Object) || !isConstructorModern(function () { 3529 called = true; 3530 }) || called; 3531 }) ? isConstructorLegacy : isConstructorModern; 3532 3533 var TypeError$c = global_1.TypeError; // `Assert: IsConstructor(argument) is true` 3534 3535 var aConstructor = function (argument) { 3536 if (isConstructor(argument)) return argument; 3537 throw TypeError$c(tryToString(argument) + ' is not a constructor'); 3538 }; 3539 3540 var SPECIES = wellKnownSymbol('species'); // `SpeciesConstructor` abstract operation 3541 // https://tc39.es/ecma262/#sec-speciesconstructor 3542 3543 var speciesConstructor = function (O, defaultConstructor) { 3544 var C = anObject(O).constructor; 3545 var S; 3546 return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aConstructor(S); 3547 }; 3548 3549 var ArrayBuffer$1 = arrayBuffer.ArrayBuffer; 3550 var DataView$1 = arrayBuffer.DataView; 3551 var DataViewPrototype$1 = DataView$1.prototype; 3552 var un$ArrayBufferSlice = functionUncurryThis(ArrayBuffer$1.prototype.slice); 3553 var getUint8 = functionUncurryThis(DataViewPrototype$1.getUint8); 3554 var setUint8 = functionUncurryThis(DataViewPrototype$1.setUint8); 3555 var INCORRECT_SLICE = fails(function () { 3556 return !new ArrayBuffer$1(2).slice(1, undefined).byteLength; 3557 }); // `ArrayBuffer.prototype.slice` method 3558 // https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice 3559 3560 _export({ 3561 target: 'ArrayBuffer', 3562 proto: true, 3563 unsafe: true, 3564 forced: INCORRECT_SLICE 3565 }, { 3566 slice: function slice(start, end) { 3567 if (un$ArrayBufferSlice && end === undefined) { 3568 return un$ArrayBufferSlice(anObject(this), start); // FF fix 3569 } 3570 3571 var length = anObject(this).byteLength; 3572 var first = toAbsoluteIndex(start, length); 3573 var fin = toAbsoluteIndex(end === undefined ? length : end, length); 3574 var result = new (speciesConstructor(this, ArrayBuffer$1))(toLength(fin - first)); 3575 var viewSource = new DataView$1(this); 3576 var viewTarget = new DataView$1(result); 3577 var index = 0; 3578 3579 while (first < fin) { 3580 setUint8(viewTarget, index++, getUint8(viewSource, first++)); 3581 } 3582 3583 return result; 3584 } 3585 }); 3586 3587 // `Object.fromEntries` method 3588 // https://github.com/tc39/proposal-object-from-entries 3589 3590 3591 _export({ 3592 target: 'Object', 3593 stat: true 3594 }, { 3595 fromEntries: function fromEntries(iterable) { 3596 var obj = {}; 3597 iterate(iterable, function (k, v) { 3598 createProperty(obj, k, v); 3599 }, { 3600 AS_ENTRIES: true 3601 }); 3602 return obj; 3603 } 3604 }); 3605 3606 // `Object.hasOwn` method 3607 // https://github.com/tc39/proposal-accessible-object-hasownproperty 3608 3609 3610 _export({ 3611 target: 'Object', 3612 stat: true 3613 }, { 3614 hasOwn: hasOwnProperty_1 3615 }); 3616 3617 var PromiseCapability = function (C) { 3618 var resolve, reject; 3619 this.promise = new C(function ($$resolve, $$reject) { 3620 if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor'); 3621 resolve = $$resolve; 3622 reject = $$reject; 3623 }); 3624 this.resolve = aCallable(resolve); 3625 this.reject = aCallable(reject); 3626 }; // `NewPromiseCapability` abstract operation 3627 // https://tc39.es/ecma262/#sec-newpromisecapability 3628 3629 3630 var f$5 = function (C) { 3631 return new PromiseCapability(C); 3632 }; 3633 3634 var newPromiseCapability = { 3635 f: f$5 3636 }; 3637 3638 var perform = function (exec) { 3639 try { 3640 return { 3641 error: false, 3642 value: exec() 3643 }; 3644 } catch (error) { 3645 return { 3646 error: true, 3647 value: error 3648 }; 3649 } 3650 }; 3651 3652 // `Promise.allSettled` method 3653 // https://tc39.es/ecma262/#sec-promise.allsettled 3654 3655 3656 _export({ 3657 target: 'Promise', 3658 stat: true 3659 }, { 3660 allSettled: function allSettled(iterable) { 3661 var C = this; 3662 var capability = newPromiseCapability.f(C); 3663 var resolve = capability.resolve; 3664 var reject = capability.reject; 3665 var result = perform(function () { 3666 var promiseResolve = aCallable(C.resolve); 3667 var values = []; 3668 var counter = 0; 3669 var remaining = 1; 3670 iterate(iterable, function (promise) { 3671 var index = counter++; 3672 var alreadyCalled = false;
vendor: 2,994 bytes, lines 3673-3772
3673 remaining++; 3674 functionCall(promiseResolve, C, promise).then(function (value) { 3675 if (alreadyCalled) return; 3676 alreadyCalled = true; 3677 values[index] = { 3678 status: 'fulfilled', 3679 value: value 3680 }; 3681 --remaining || resolve(values); 3682 }, function (error) { 3683 if (alreadyCalled) return; 3684 alreadyCalled = true; 3685 values[index] = { 3686 status: 'rejected', 3687 reason: error 3688 }; 3689 --remaining || resolve(values); 3690 }); 3691 }); 3692 --remaining || resolve(values); 3693 }); 3694 if (result.error) reject(result.value); 3695 return capability.promise; 3696 } 3697 }); 3698 3699 var PROMISE_ANY_ERROR = 'No one promise resolved'; // `Promise.any` method 3700 // https://tc39.es/ecma262/#sec-promise.any 3701 3702 _export({ 3703 target: 'Promise', 3704 stat: true 3705 }, { 3706 any: function any(iterable) { 3707 var C = this; 3708 var AggregateError = getBuiltIn('AggregateError'); 3709 var capability = newPromiseCapability.f(C); 3710 var resolve = capability.resolve; 3711 var reject = capability.reject; 3712 var result = perform(function () { 3713 var promiseResolve = aCallable(C.resolve); 3714 var errors = []; 3715 var counter = 0; 3716 var remaining = 1; 3717 var alreadyResolved = false; 3718 iterate(iterable, function (promise) { 3719 var index = counter++; 3720 var alreadyRejected = false; 3721 remaining++; 3722 functionCall(promiseResolve, C, promise).then(function (value) { 3723 if (alreadyRejected || alreadyResolved) return; 3724 alreadyResolved = true; 3725 resolve(value); 3726 }, function (error) { 3727 if (alreadyRejected || alreadyResolved) return; 3728 alreadyRejected = true; 3729 errors[index] = error; 3730 --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR)); 3731 }); 3732 }); 3733 --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR)); 3734 }); 3735 if (result.error) reject(result.value); 3736 return capability.promise; 3737 } 3738 }); 3739 3740 var nativePromiseConstructor = global_1.Promise; 3741 3742 var promiseResolve = function (C, x) { 3743 anObject(C); 3744 if (isObject(x) && x.constructor === C) return x; 3745 var promiseCapability = newPromiseCapability.f(C); 3746 var resolve = promiseCapability.resolve; 3747 resolve(x); 3748 return promiseCapability.promise; 3749 }; 3750 3751 // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829 3752 3753 3754 var NON_GENERIC = !!nativePromiseConstructor && fails(function () { 3755 nativePromiseConstructor.prototype['finally'].call({ 3756 then: function () { 3757 /* empty */ 3758 } 3759 }, function () { 3760 /* empty */ 3761 }); 3762 }); // `Promise.prototype.finally` method 3763 // https://tc39.es/ecma262/#sec-promise.prototype.finally 3764 3765 _export({ 3766 target: 'Promise', 3767 proto: true, 3768 real: true, 3769 forced: NON_GENERIC 3770 }, { 3771 'finally': function (onFinally) { 3772 var C = speciesConstructor(this, getBuiltIn('Promise'));
3773 var isFunction = isCallable(onFinally); 3774 return this.then(isFunction ? function (x) { 3775 return promiseResolve(C, onFinally()).then(function () { 3776 return x; 3777 }); 3778 } : onFinally, isFunction ? function (e) { 3779 return promiseResolve(C, onFinally()).then(function () { 3780 throw e; 3781 }); 3782 } : onFinally); 3783 } 3784 }); // makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then` 3785 3786 if (!isPure && isCallable(nativePromiseConstructor)) { 3787 var method = getBuiltIn('Promise').prototype['finally']; 3788 3789 if (nativePromiseConstructor.prototype['finally'] !== method) { 3790 redefine(nativePromiseConstructor.prototype, 'finally', method, { 3791 unsafe: true 3792 }); 3793 } 3794 } 3795 3796 var ITERATOR$2 = wellKnownSymbol('iterator'); 3797 var BUGGY_SAFARI_ITERATORS = false; // `%IteratorPrototype%` object 3798 // https://tc39.es/ecma262/#sec-%iteratorprototype%-object 3799 3800 var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator; 3801 /* eslint-disable es/no-array-prototype-keys -- safe */ 3802 3803 if ([].keys) { 3804 arrayIterator = [].keys(); // Safari 8 has buggy iterators w/o `next` 3805 3806 if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;else { 3807 PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator)); 3808 if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype; 3809 } 3810 } 3811 3812 var NEW_ITERATOR_PROTOTYPE = IteratorPrototype == undefined || fails(function () { 3813 var test = {}; // FF44- legacy iterators case 3814 3815 return IteratorPrototype[ITERATOR$2].call(test) !== test; 3816 }); 3817 if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {}; // `%IteratorPrototype%[@@iterator]()` method 3818 // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator 3819 3820 if (!isCallable(IteratorPrototype[ITERATOR$2])) { 3821 redefine(IteratorPrototype, ITERATOR$2, function () { 3822 return this; 3823 }); 3824 } 3825 3826 var iteratorsCore = { 3827 IteratorPrototype: IteratorPrototype, 3828 BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS 3829 }; 3830 3831 var IteratorPrototype$1 = iteratorsCore.IteratorPrototype; 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 var returnThis = function () { 3842 return this; 3843 }; 3844 3845 var createIteratorConstructor = function (IteratorConstructor, NAME, next) { 3846 var TO_STRING_TAG = NAME + ' Iterator'; 3847 IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, { 3848 next: createPropertyDescriptor(1, next) 3849 }); 3850 setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true); 3851 iterators[TO_STRING_TAG] = returnThis; 3852 return IteratorConstructor; 3853 }; 3854 3855 var MATCH = wellKnownSymbol('match'); // `IsRegExp` abstract operation 3856 // https://tc39.es/ecma262/#sec-isregexp 3857 3858 var isRegexp = function (it) { 3859 var isRegExp; 3860 return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classofRaw(it) == 'RegExp'); 3861 }; 3862 3863 // `RegExp.prototype.flags` getter implementation 3864 // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags 3865 3866 3867 var regexpFlags = function () { 3868 var that = anObject(this); 3869 var result = ''; 3870 if (that.global) result += 'g'; 3871 if (that.ignoreCase) result += 'i'; 3872 if (that.multiline) result += 'm'; 3873 if (that.dotAll) result += 's'; 3874 if (that.unicode) result += 'u'; 3875 if (that.sticky) result += 'y'; 3876 return result; 3877 }; 3878 3879 var charAt = functionUncurryThis(''.charAt); 3880 var charCodeAt = functionUncurryThis(''.charCodeAt); 3881 var stringSlice$1 = functionUncurryThis(''.slice); 3882 3883 var createMethod$1 = function (CONVERT_TO_STRING) { 3884 return function ($this, pos) { 3885 var S = toString_1(requireObjectCoercible($this)); 3886 var position = toIntegerOrInfinity(pos); 3887 var size = S.length; 3888 var first, second; 3889 if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined; 3890 first = charCodeAt(S, position); 3891 return first < 0xD800 || first > 0xDBFF || position + 1 === size || (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF ? CONVERT_TO_STRING ? charAt(S, position) : first : CONVERT_TO_STRING ? stringSlice$1(S, position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000; 3892 }; 3893 }; 3894 3895 var stringMultibyte = { 3896 // `String.prototype.codePointAt` method 3897 // https://tc39.es/ecma262/#sec-string.prototype.codepointat 3898 codeAt: createMethod$1(false), 3899 // `String.prototype.at` method 3900 // https://github.com/mathiasbynens/String.prototype.at 3901 charAt: createMethod$1(true) 3902 }; 3903 3904 var charAt$1 = stringMultibyte.charAt; // `AdvanceStringIndex` abstract operation 3905 // https://tc39.es/ecma262/#sec-advancestringindex 3906 3907 3908 var advanceStringIndex = function (S, index, unicode) { 3909 return index + (unicode ? charAt$1(S, index).length : 1); 3910 }; 3911 3912 // babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError 3913 3914 3915 var $RegExp = global_1.RegExp; 3916 var UNSUPPORTED_Y = fails(function () { 3917 var re = $RegExp('a', 'y'); 3918 re.lastIndex = 2; 3919 return re.exec('abcd') != null; 3920 }); // UC Browser bug 3921 // https://github.com/zloirock/core-js/issues/1008 3922 3923 var MISSED_STICKY = UNSUPPORTED_Y || fails(function () { 3924 return !$RegExp('a', 'y').sticky; 3925 }); 3926 var BROKEN_CARET = UNSUPPORTED_Y || fails(function () { 3927 // https://bugzilla.mozilla.org/show_bug.cgi?id=773687 3928 var re = $RegExp('^r', 'gy'); 3929 re.lastIndex = 2; 3930 return re.exec('str') != null; 3931 }); 3932 var regexpStickyHelpers = { 3933 BROKEN_CARET: BROKEN_CARET, 3934 MISSED_STICKY: MISSED_STICKY, 3935 UNSUPPORTED_Y: UNSUPPORTED_Y 3936 }; 3937 3938 // babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError 3939 3940 3941 var $RegExp$1 = global_1.RegExp; 3942 var regexpUnsupportedDotAll = fails(function () { 3943 var re = $RegExp$1('.', 's'); 3944 return !(re.dotAll && re.exec('\n') && re.flags === 's'); 3945 }); 3946 3947 // babel-minify and Closure Compiler transpiles RegExp('(?<a>b)', 'g') -> /(?<a>b)/g and it causes SyntaxError 3948 3949 3950 var $RegExp$2 = global_1.RegExp; 3951 var regexpUnsupportedNcg = fails(function () {
vendor: 5,743 bytes, lines 3952-4185
3952 var re = $RegExp$2('(?<a>b)', 'g'); 3953 return re.exec('b').groups.a !== 'b' || 'b'.replace(re, '$<a>c') !== 'bc'; 3954 }); 3955 3956 /* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */ 3957 3958 /* eslint-disable regexp/no-useless-quantifier -- testing */ 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 var getInternalState$1 = internalState.get; 3975 3976 3977 3978 3979 3980 var nativeReplace = shared('native-string-replace', String.prototype.replace); 3981 var nativeExec = RegExp.prototype.exec; 3982 var patchedExec = nativeExec; 3983 var charAt$2 = functionUncurryThis(''.charAt); 3984 var indexOf$1 = functionUncurryThis(''.indexOf); 3985 var replace$1 = functionUncurryThis(''.replace); 3986 var stringSlice$2 = functionUncurryThis(''.slice); 3987 3988 var UPDATES_LAST_INDEX_WRONG = function () { 3989 var re1 = /a/; 3990 var re2 = /b*/g; 3991 functionCall(nativeExec, re1, 'a'); 3992 functionCall(nativeExec, re2, 'a'); 3993 return re1.lastIndex !== 0 || re2.lastIndex !== 0; 3994 }(); 3995 3996 var UNSUPPORTED_Y$1 = regexpStickyHelpers.BROKEN_CARET; // nonparticipating capturing group, copied from es5-shim's String#split patch. 3997 3998 var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; 3999 var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$1 || regexpUnsupportedDotAll || regexpUnsupportedNcg; 4000 4001 if (PATCH) { 4002 patchedExec = function exec(string) { 4003 var re = this; 4004 var state = getInternalState$1(re); 4005 var str = toString_1(string); 4006 var raw = state.raw; 4007 var result, reCopy, lastIndex, match, i, object, group; 4008 4009 if (raw) { 4010 raw.lastIndex = re.lastIndex; 4011 result = functionCall(patchedExec, raw, str); 4012 re.lastIndex = raw.lastIndex; 4013 return result; 4014 } 4015 4016 var groups = state.groups; 4017 var sticky = UNSUPPORTED_Y$1 && re.sticky; 4018 var flags = functionCall(regexpFlags, re); 4019 var source = re.source; 4020 var charsAdded = 0; 4021 var strCopy = str; 4022 4023 if (sticky) { 4024 flags = replace$1(flags, 'y', ''); 4025 4026 if (indexOf$1(flags, 'g') === -1) { 4027 flags += 'g'; 4028 } 4029 4030 strCopy = stringSlice$2(str, re.lastIndex); // Support anchored sticky behavior. 4031 4032 if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$2(str, re.lastIndex - 1) !== '\n')) { 4033 source = '(?: ' + source + ')'; 4034 strCopy = ' ' + strCopy; 4035 charsAdded++; 4036 } // ^(? + rx + ) is needed, in combination with some str slicing, to 4037 // simulate the 'y' flag. 4038 4039 4040 reCopy = new RegExp('^(?:' + source + ')', flags); 4041 } 4042 4043 if (NPCG_INCLUDED) { 4044 reCopy = new RegExp('^' + source + '$(?!\\s)', flags); 4045 } 4046 4047 if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex; 4048 match = functionCall(nativeExec, sticky ? reCopy : re, strCopy); 4049 4050 if (sticky) { 4051 if (match) { 4052 match.input = stringSlice$2(match.input, charsAdded); 4053 match[0] = stringSlice$2(match[0], charsAdded); 4054 match.index = re.lastIndex; 4055 re.lastIndex += match[0].length; 4056 } else re.lastIndex = 0; 4057 } else if (UPDATES_LAST_INDEX_WRONG && match) { 4058 re.lastIndex = re.global ? match.index + match[0].length : lastIndex; 4059 } 4060 4061 if (NPCG_INCLUDED && match && match.length > 1) { 4062 // Fix browsers whose `exec` methods don't consistently return `undefined` 4063 // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/ 4064 functionCall(nativeReplace, match[0], reCopy, function () { 4065 for (i = 1; i < arguments.length - 2; i++) { 4066 if (arguments[i] === undefined) match[i] = undefined; 4067 } 4068 }); 4069 } 4070 4071 if (match && groups) { 4072 match.groups = object = objectCreate(null); 4073 4074 for (i = 0; i < groups.length; i++) { 4075 group = groups[i]; 4076 object[group[0]] = match[group[1]]; 4077 } 4078 } 4079 4080 return match; 4081 }; 4082 } 4083 4084 var regexpExec = patchedExec; 4085 4086 var TypeError$d = global_1.TypeError; // `RegExpExec` abstract operation 4087 // https://tc39.es/ecma262/#sec-regexpexec 4088 4089 var regexpExecAbstract = function (R, S) { 4090 var exec = R.exec; 4091 4092 if (isCallable(exec)) { 4093 var result = functionCall(exec, R, S); 4094 if (result !== null) anObject(result); 4095 return result; 4096 } 4097 4098 if (classofRaw(R) === 'RegExp') return functionCall(regexpExec, R, S); 4099 throw TypeError$d('RegExp#exec called on incompatible receiver'); 4100 }; 4101 4102 /* eslint-disable es/no-string-prototype-matchall -- safe */ 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 var MATCH_ALL = wellKnownSymbol('matchAll'); 4149 var REGEXP_STRING = 'RegExp String'; 4150 var REGEXP_STRING_ITERATOR = REGEXP_STRING + ' Iterator'; 4151 var setInternalState$1 = internalState.set; 4152 var getInternalState$2 = internalState.getterFor(REGEXP_STRING_ITERATOR); 4153 var RegExpPrototype = RegExp.prototype; 4154 var TypeError$e = global_1.TypeError; 4155 var getFlags = functionUncurryThis(regexpFlags); 4156 var stringIndexOf = functionUncurryThis(''.indexOf); 4157 var un$MatchAll = functionUncurryThis(''.matchAll); 4158 var WORKS_WITH_NON_GLOBAL_REGEX = !!un$MatchAll && !fails(function () { 4159 un$MatchAll('a', /./); 4160 }); 4161 var $RegExpStringIterator = createIteratorConstructor(function RegExpStringIterator(regexp, string, $global, fullUnicode) { 4162 setInternalState$1(this, { 4163 type: REGEXP_STRING_ITERATOR, 4164 regexp: regexp, 4165 string: string, 4166 global: $global, 4167 unicode: fullUnicode, 4168 done: false 4169 }); 4170 }, REGEXP_STRING, function next() { 4171 var state = getInternalState$2(this); 4172 if (state.done) return { 4173 value: undefined, 4174 done: true 4175 }; 4176 var R = state.regexp; 4177 var S = state.string; 4178 var match = regexpExecAbstract(R, S); 4179 if (match === null) return { 4180 value: undefined, 4181 done: state.done = true 4182 }; 4183 4184 if (state.global) { 4185 if (toString_1(match[0]) === '') R.lastIndex = advanceStringIndex(S, toLe
4185ngth(R.lastIndex), state.unicode); 4186 return { 4187 value: match, 4188 done: false 4189 }; 4190 } 4191 4192 state.done = true; 4193 return { 4194 value: match, 4195 done: false 4196 }; 4197 }); 4198 4199 var $matchAll = function (string) { 4200 var R = anObject(this); 4201 var S = toString_1(string); 4202 var C, flagsValue, flags, matcher, $global, fullUnicode; 4203 C = speciesConstructor(R, RegExp); 4204 flagsValue = R.flags; 4205 4206 if (flagsValue === undefined && objectIsPrototypeOf(RegExpPrototype, R) && !('flags' in RegExpPrototype)) { 4207 flagsValue = getFlags(R); 4208 } 4209 4210 flags = flagsValue === undefined ? '' : toString_1(flagsValue); 4211 matcher = new C(C === RegExp ? R.source : R, flags); 4212 $global = !!~stringIndexOf(flags, 'g'); 4213 fullUnicode = !!~stringIndexOf(flags, 'u'); 4214 matcher.lastIndex = toLength(R.lastIndex); 4215 return new $RegExpStringIterator(matcher, S, $global, fullUnicode); 4216 }; // `String.prototype.matchAll` method 4217 // https://tc39.es/ecma262/#sec-string.prototype.matchall 4218 4219 4220 _export({ 4221 target: 'String', 4222 proto: true, 4223 forced: WORKS_WITH_NON_GLOBAL_REGEX 4224 }, { 4225 matchAll: function matchAll(regexp) { 4226 var O = requireObjectCoercible(this); 4227 var flags, S, matcher, rx; 4228 4229 if (regexp != null) { 4230 if (isRegexp(regexp)) { 4231 flags = toString_1(requireObjectCoercible('flags' in RegExpPrototype ? regexp.flags : getFlags(regexp))); 4232 if (!~stringIndexOf(flags, 'g')) throw TypeError$e('`.matchAll` does not allow non-global regexes'); 4233 } 4234 4235 if (WORKS_WITH_NON_GLOBAL_REGEX) return un$MatchAll(O, regexp); 4236 matcher = getMethod(regexp, MATCH_ALL); 4237 if (matcher === undefined && isPure && classofRaw(regexp) == 'RegExp') matcher = $matchAll; 4238 if (matcher) return functionCall(matcher, regexp, O); 4239 } else if (WORKS_WITH_NON_GLOBAL_REGEX) return un$MatchAll(O, regexp); 4240 4241 S = toString_1(O); 4242 rx = new RegExp(regexp, 'g'); 4243 return isPure ? functionCall($matchAll, rx, S) : rx[MATCH_ALL](S); 4244 } 4245 }); 4246 isPure || MATCH_ALL in RegExpPrototype || redefine(RegExpPrototype, MATCH_ALL, $matchAll); 4247 4248 var floor$2 = Math.floor; 4249 var charAt$3 = functionUncurryThis(''.charAt); 4250 var replace$2 = functionUncurryThis(''.replace); 4251 var stringSlice$3 = functionUncurryThis(''.slice); 4252 var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g; 4253 var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g; // `GetSubstitution` abstract operation 4254 // https://tc39.es/ecma262/#sec-getsubstitution 4255 4256 var getSubstitution = function (matched, str, position, captures, namedCaptures, replacement) { 4257 var tailPos = position + matched.length; 4258 var m = captures.length; 4259 var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED; 4260 4261 if (namedCaptures !== undefined) { 4262 namedCaptures = toObject(namedCaptures); 4263 symbols = SUBSTITUTION_SYMBOLS; 4264 } 4265 4266 return replace$2(replacement, symbols, function (match, ch) { 4267 var capture; 4268 4269 switch (charAt$3(ch, 0)) { 4270 case '$': 4271 return '$'; 4272 4273 case '&': 4274 return matched; 4275 4276 case '`': 4277 return stringSlice$3(str, 0, position); 4278 4279 case "'": 4280 return stringSlice$3(str, tailPos); 4281 4282 case '<': 4283 capture = namedCaptures[stringSlice$3(ch, 1, -1)]; 4284 break; 4285 4286 default: 4287 // \d\d? 4288 var n = +ch; 4289 if (n === 0) return match; 4290 4291 if (n > m) { 4292 var f = floor$2(n / 10); 4293 if (f === 0) return match; 4294 if (f <= m) return captures[f - 1] === undefined ? charAt$3(ch, 1) : captures[f - 1] + charAt$3(ch, 1); 4295 return match; 4296 } 4297 4298 capture = captures[n - 1]; 4299 } 4300 4301 return capture === undefined ? '' : capture; 4302 }); 4303 }; 4304 4305 var REPLACE = wellKnownSymbol('replace'); 4306 var RegExpPrototype$1 = RegExp.prototype; 4307 var TypeError$f = global_1.TypeError; 4308 var getFlags$1 = functionUncurryThis(regexpFlags); 4309 var indexOf$2 = functionUncurryThis(''.indexOf); 4310 var replace$3 = functionUncurryThis(''.replace); 4311 var stringSlice$4 = functionUncurryThis(''.slice); 4312 var max$2 = Math.max; 4313 4314 var stringIndexOf$1 = function (string, searchValue, fromIndex) { 4315 if (fromIndex > string.length) return -1; 4316 if (searchValue === '') return fromIndex; 4317 return indexOf$2(string, searchValue, fromIndex); 4318 }; // `String.prototype.replaceAll` method 4319 // https://tc39.es/ecma262/#sec-string.prototype.replaceall 4320 4321 4322 _export({ 4323 target: 'String', 4324 proto: true 4325 }, { 4326 replaceAll: function replaceAll(searchValue, replaceValue) { 4327 var O = requireObjectCoercible(this); 4328 var IS_REG_EXP, flags, replacer, string, searchString, functionalReplace, searchLength, advanceBy, replacement; 4329 var position = 0; 4330 var endOfLastMatch = 0; 4331 var result = ''; 4332 4333 if (searchValue != null) { 4334 IS_REG_EXP = isRegexp(searchValue); 4335 4336 if (IS_REG_EXP) { 4337 flags = toString_1(requireObjectCoercible('flags' in RegExpPrototype$1 ? searchValue.flags : getFlags$1(searchValue))); 4338 if (!~indexOf$2(flags, 'g')) throw TypeError$f('`.replaceAll` does not allow non-global regexes'); 4339 } 4340 4341 replacer = getMethod(searchValue, REPLACE); 4342 4343 if (replacer) { 4344 return functionCall(replacer, searchValue, O, replaceValue); 4345 } else if (isPure && IS_REG_EXP) { 4346 return replace$3(toString_1(O), searchValue, replaceValue); 4347 } 4348 } 4349 4350 string = toString_1(O); 4351 searchString = toString_1(searchValue); 4352 functionalReplace = isCallable(replaceValue); 4353 if (!functionalReplace) replaceValue = toString_1(replaceValue); 4354 searchLength = searchString.length; 4355 advanceBy = max$2(1, searchLength); 4356 position = stringIndexOf$1(string, searchString, 0); 4357 4358 while (position !== -1) { 4359 replacement = functionalReplace ? toString_1(replaceValue(searchString, position, string)) : getSubstitution(searchString, string, position, [], undefined, replaceValue); 4360 result += stringSlice$4(string, endOfLastMatch, position) + replacement; 4361 endOfLastMatch = position + searchLength; 4362 position = stringIndexOf$1(string, searchString, position + advanceBy); 4363 } 4364 4365 if (endOfLastMatch < string.length) { 4366 result += stringSlice$4(string, endOfLastMatch); 4367 } 4368 4369 return result; 4370 } 4371 }); 4372 4373 var ITERATOR$3 = wellKnownSymbol('iterator'); 4374 var SAFE_CLOSING = false;
vendor: 4,474 bytes, lines 4375-4518
4375 4376 var checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) { 4377 if (!SKIP_CLOSING && !SAFE_CLOSING) return false; 4378 var ITERATION_SUPPORT = false; 4379 4380 try { 4381 var object = {}; 4382 4383 object[ITERATOR$3] = function () { 4384 return { 4385 next: function () { 4386 return { 4387 done: ITERATION_SUPPORT = true 4388 }; 4389 } 4390 }; 4391 }; 4392 4393 exec(object); 4394 } catch (error) { 4395 /* empty */ 4396 } 4397 4398 return ITERATION_SUPPORT; 4399 }; 4400 4401 var defineProperty$3 = objectDefineProperty.f; 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 var Int8Array = global_1.Int8Array; 4414 var Int8ArrayPrototype = Int8Array && Int8Array.prototype; 4415 var Uint8ClampedArray = global_1.Uint8ClampedArray; 4416 var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype; 4417 var TypedArray = Int8Array && objectGetPrototypeOf(Int8Array); 4418 var TypedArrayPrototype = Int8ArrayPrototype && objectGetPrototypeOf(Int8ArrayPrototype); 4419 var ObjectPrototype$2 = Object.prototype; 4420 var TypeError$g = global_1.TypeError; 4421 var TO_STRING_TAG$4 = wellKnownSymbol('toStringTag'); 4422 var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG'); 4423 var TYPED_ARRAY_CONSTRUCTOR = uid('TYPED_ARRAY_CONSTRUCTOR'); // Fixing native typed arrays in Opera Presto crashes the browser, see #595 4424 4425 var NATIVE_ARRAY_BUFFER_VIEWS = arrayBufferNative && !!objectSetPrototypeOf && classof(global_1.opera) !== 'Opera'; 4426 var TYPED_ARRAY_TAG_REQIRED = false; 4427 var NAME, Constructor, Prototype; 4428 var TypedArrayConstructorsList = { 4429 Int8Array: 1, 4430 Uint8Array: 1, 4431 Uint8ClampedArray: 1, 4432 Int16Array: 2, 4433 Uint16Array: 2, 4434 Int32Array: 4, 4435 Uint32Array: 4, 4436 Float32Array: 4, 4437 Float64Array: 8 4438 }; 4439 var BigIntArrayConstructorsList = { 4440 BigInt64Array: 8, 4441 BigUint64Array: 8 4442 }; 4443 4444 var isView = function isView(it) { 4445 if (!isObject(it)) return false; 4446 var klass = classof(it); 4447 return klass === 'DataView' || hasOwnProperty_1(TypedArrayConstructorsList, klass) || hasOwnProperty_1(BigIntArrayConstructorsList, klass); 4448 }; 4449 4450 var isTypedArray = function (it) { 4451 if (!isObject(it)) return false; 4452 var klass = classof(it); 4453 return hasOwnProperty_1(TypedArrayConstructorsList, klass) || hasOwnProperty_1(BigIntArrayConstructorsList, klass); 4454 }; 4455 4456 var aTypedArray = function (it) { 4457 if (isTypedArray(it)) return it; 4458 throw TypeError$g('Target is not a typed array'); 4459 }; 4460 4461 var aTypedArrayConstructor = function (C) { 4462 if (isCallable(C) && (!objectSetPrototypeOf || objectIsPrototypeOf(TypedArray, C))) return C; 4463 throw TypeError$g(tryToString(C) + ' is not a typed array constructor'); 4464 }; 4465 4466 var exportTypedArrayMethod = function (KEY, property, forced) { 4467 if (!descriptors) return; 4468 if (forced) for (var ARRAY in TypedArrayConstructorsList) { 4469 var TypedArrayConstructor = global_1[ARRAY]; 4470 if (TypedArrayConstructor && hasOwnProperty_1(TypedArrayConstructor.prototype, KEY)) try { 4471 delete TypedArrayConstructor.prototype[KEY]; 4472 } catch (error) { 4473 /* empty */ 4474 } 4475 } 4476 4477 if (!TypedArrayPrototype[KEY] || forced) { 4478 redefine(TypedArrayPrototype, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property); 4479 } 4480 }; 4481 4482 var exportTypedArrayStaticMethod = function (KEY, property, forced) { 4483 var ARRAY, TypedArrayConstructor; 4484 if (!descriptors) return; 4485 4486 if (objectSetPrototypeOf) { 4487 if (forced) for (ARRAY in TypedArrayConstructorsList) { 4488 TypedArrayConstructor = global_1[ARRAY]; 4489 if (TypedArrayConstructor && hasOwnProperty_1(TypedArrayConstructor, KEY)) try { 4490 delete TypedArrayConstructor[KEY]; 4491 } catch (error) { 4492 /* empty */ 4493 } 4494 } 4495 4496 if (!TypedArray[KEY] || forced) { 4497 // V8 ~ Chrome 49-50 `%TypedArray%` methods are non-writable non-configurable 4498 try { 4499 return redefine(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && TypedArray[KEY] || property); 4500 } catch (error) { 4501 /* empty */ 4502 } 4503 } else return; 4504 } 4505 4506 for (ARRAY in TypedArrayConstructorsList) { 4507 TypedArrayConstructor = global_1[ARRAY]; 4508 4509 if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) { 4510 redefine(TypedArrayConstructor, KEY, property); 4511 } 4512 } 4513 }; 4514 4515 for (NAME in TypedArrayConstructorsList) { 4516 Constructor = global_1[NAME]; 4517 Prototype = Constructor && Constructor.prototype; 4518 if (Prototype) createNonEnumerableProperty(Prototype, TYPED_ARRAY_CONSTRUCTOR, Constructor);else NATIVE_ARRAY_BUFFER_VIEWS = false;
vendor: 5,622 bytes, lines 4519-4691
4519 } 4520 4521 for (NAME in BigIntArrayConstructorsList) { 4522 Constructor = global_1[NAME]; 4523 Prototype = Constructor && Constructor.prototype; 4524 if (Prototype) createNonEnumerableProperty(Prototype, TYPED_ARRAY_CONSTRUCTOR, Constructor); 4525 } // WebKit bug - typed arrays constructors prototype is Object.prototype 4526 4527 4528 if (!NATIVE_ARRAY_BUFFER_VIEWS || !isCallable(TypedArray) || TypedArray === Function.prototype) { 4529 // eslint-disable-next-line no-shadow -- safe 4530 TypedArray = function TypedArray() { 4531 throw TypeError$g('Incorrect invocation'); 4532 }; 4533 4534 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { 4535 if (global_1[NAME]) objectSetPrototypeOf(global_1[NAME], TypedArray); 4536 } 4537 } 4538 4539 if (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype$2) { 4540 TypedArrayPrototype = TypedArray.prototype; 4541 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { 4542 if (global_1[NAME]) objectSetPrototypeOf(global_1[NAME].prototype, TypedArrayPrototype); 4543 } 4544 } // WebKit bug - one more object in Uint8ClampedArray prototype chain 4545 4546 4547 if (NATIVE_ARRAY_BUFFER_VIEWS && objectGetPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) { 4548 objectSetPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype); 4549 } 4550 4551 if (descriptors && !hasOwnProperty_1(TypedArrayPrototype, TO_STRING_TAG$4)) { 4552 TYPED_ARRAY_TAG_REQIRED = true; 4553 defineProperty$3(TypedArrayPrototype, TO_STRING_TAG$4, { 4554 get: function () { 4555 return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined; 4556 } 4557 }); 4558 4559 for (NAME in TypedArrayConstructorsList) if (global_1[NAME]) { 4560 createNonEnumerableProperty(global_1[NAME], TYPED_ARRAY_TAG, NAME); 4561 } 4562 } 4563 4564 var arrayBufferViewCore = { 4565 NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS, 4566 TYPED_ARRAY_CONSTRUCTOR: TYPED_ARRAY_CONSTRUCTOR, 4567 TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQIRED && TYPED_ARRAY_TAG, 4568 aTypedArray: aTypedArray, 4569 aTypedArrayConstructor: aTypedArrayConstructor, 4570 exportTypedArrayMethod: exportTypedArrayMethod, 4571 exportTypedArrayStaticMethod: exportTypedArrayStaticMethod, 4572 isView: isView, 4573 isTypedArray: isTypedArray, 4574 TypedArray: TypedArray, 4575 TypedArrayPrototype: TypedArrayPrototype 4576 }; 4577 4578 /* eslint-disable no-new -- required for testing */ 4579 4580 4581 4582 4583 4584 4585 var NATIVE_ARRAY_BUFFER_VIEWS$1 = arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; 4586 4587 var ArrayBuffer$2 = global_1.ArrayBuffer; 4588 var Int8Array$1 = global_1.Int8Array; 4589 var typedArrayConstructorsRequireWrappers = !NATIVE_ARRAY_BUFFER_VIEWS$1 || !fails(function () { 4590 Int8Array$1(1); 4591 }) || !fails(function () { 4592 new Int8Array$1(-1); 4593 }) || !checkCorrectnessOfIteration(function (iterable) { 4594 new Int8Array$1(); 4595 new Int8Array$1(null); 4596 new Int8Array$1(1.5); 4597 new Int8Array$1(iterable); 4598 }, true) || fails(function () { 4599 // Safari (11+) bug - a reason why even Safari 13 should load a typed array polyfill 4600 return new Int8Array$1(new ArrayBuffer$2(2), 1, undefined).length !== 1; 4601 }); 4602 4603 var floor$3 = Math.floor; // `IsIntegralNumber` abstract operation 4604 // https://tc39.es/ecma262/#sec-isintegralnumber 4605 // eslint-disable-next-line es/no-number-isinteger -- safe 4606 4607 var isIntegralNumber = Number.isInteger || function isInteger(it) { 4608 return !isObject(it) && isFinite(it) && floor$3(it) === it; 4609 }; 4610 4611 var RangeError$2 = global_1.RangeError; 4612 4613 var toPositiveInteger = function (it) { 4614 var result = toIntegerOrInfinity(it); 4615 if (result < 0) throw RangeError$2("The argument can't be less than 0"); 4616 return result; 4617 }; 4618 4619 var RangeError$3 = global_1.RangeError; 4620 4621 var toOffset = function (it, BYTES) { 4622 var offset = toPositiveInteger(it); 4623 if (offset % BYTES) throw RangeError$3('Wrong offset'); 4624 return offset; 4625 }; 4626 4627 var aTypedArrayConstructor$1 = arrayBufferViewCore.aTypedArrayConstructor; 4628 4629 var typedArrayFrom = function from(source 4630 /* , mapfn, thisArg */ 4631 ) { 4632 var C = aConstructor(this); 4633 var O = toObject(source); 4634 var argumentsLength = arguments.length; 4635 var mapfn = argumentsLength > 1 ? arguments[1] : undefined; 4636 var mapping = mapfn !== undefined; 4637 var iteratorMethod = getIteratorMethod(O); 4638 var i, length, result, step, iterator, next; 4639 4640 if (iteratorMethod && !isArrayIteratorMethod(iteratorMethod)) { 4641 iterator = getIterator(O, iteratorMethod); 4642 next = iterator.next; 4643 O = []; 4644 4645 while (!(step = functionCall(next, iterator)).done) { 4646 O.push(step.value); 4647 } 4648 } 4649 4650 if (mapping && argumentsLength > 2) { 4651 mapfn = functionBindContext(mapfn, arguments[2]); 4652 } 4653 4654 length = lengthOfArrayLike(O); 4655 result = new (aTypedArrayConstructor$1(C))(length); 4656 4657 for (i = 0; length > i; i++) { 4658 result[i] = mapping ? mapfn(O[i], i) : O[i]; 4659 } 4660 4661 return result; 4662 }; 4663 4664 var SPECIES$1 = wellKnownSymbol('species'); 4665 var Array$4 = global_1.Array; // a part of `ArraySpeciesCreate` abstract operation 4666 // https://tc39.es/ecma262/#sec-arrayspeciescreate 4667 4668 var arraySpeciesConstructor = function (originalArray) { 4669 var C; 4670 4671 if (isArray(originalArray)) { 4672 C = originalArray.constructor; // cross-realm fallback 4673 4674 if (isConstructor(C) && (C === Array$4 || isArray(C.prototype))) C = undefined;else if (isObject(C)) { 4675 C = C[SPECIES$1]; 4676 if (C === null) C = undefined; 4677 } 4678 } 4679 4680 return C === undefined ? Array$4 : C; 4681 }; 4682 4683 // `ArraySpeciesCreate` abstract operation 4684 // https://tc39.es/ecma262/#sec-arrayspeciescreate 4685 4686 4687 var arraySpeciesCreate = function (originalArray, length) { 4688 return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length); 4689 }; 4690 4691 var push$2 = functionUncurryThis([].push);
4691 // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation 4692 4693 var createMethod$2 = function (TYPE) { 4694 var IS_MAP = TYPE == 1; 4695 var IS_FILTER = TYPE == 2; 4696 var IS_SOME = TYPE == 3; 4697 var IS_EVERY = TYPE == 4; 4698 var IS_FIND_INDEX = TYPE == 6; 4699 var IS_FILTER_REJECT = TYPE == 7; 4700 var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; 4701 return function ($this, callbackfn, that, specificCreate) { 4702 var O = toObject($this); 4703 var self = indexedObject(O); 4704 var boundFunction = functionBindContext(callbackfn, that); 4705 var length = lengthOfArrayLike(self); 4706 var index = 0; 4707 var create = specificCreate || arraySpeciesCreate; 4708 var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined; 4709 var value, result; 4710 4711 for (; length > index; index++) if (NO_HOLES || index in self) { 4712 value = self[index]; 4713 result = boundFunction(value, index, O); 4714 4715 if (TYPE) { 4716 if (IS_MAP) target[index] = result; // map 4717 else if (result) switch (TYPE) { 4718 case 3: 4719 return true; 4720 // some 4721 4722 case 5: 4723 return value; 4724 // find 4725 4726 case 6: 4727 return index; 4728 // findIndex 4729 4730 case 2: 4731 push$2(target, value); 4732 // filter 4733 } else switch (TYPE) { 4734 case 4: 4735 return false; 4736 // every 4737 4738 case 7: 4739 push$2(target, value); 4740 // filterReject 4741 } 4742 } 4743 } 4744 4745 return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target; 4746 }; 4747 }; 4748 4749 var arrayIteration = { 4750 // `Array.prototype.forEach` method 4751 // https://tc39.es/ecma262/#sec-array.prototype.foreach 4752 forEach: createMethod$2(0), 4753 // `Array.prototype.map` method 4754 // https://tc39.es/ecma262/#sec-array.prototype.map 4755 map: createMethod$2(1), 4756 // `Array.prototype.filter` method 4757 // https://tc39.es/ecma262/#sec-array.prototype.filter 4758 filter: createMethod$2(2), 4759 // `Array.prototype.some` method 4760 // https://tc39.es/ecma262/#sec-array.prototype.some 4761 some: createMethod$2(3), 4762 // `Array.prototype.every` method 4763 // https://tc39.es/ecma262/#sec-array.prototype.every 4764 every: createMethod$2(4), 4765 // `Array.prototype.find` method 4766 // https://tc39.es/ecma262/#sec-array.prototype.find 4767 find: createMethod$2(5), 4768 // `Array.prototype.findIndex` method 4769 // https://tc39.es/ecma262/#sec-array.prototype.findIndex 4770 findIndex: createMethod$2(6), 4771 // `Array.prototype.filterReject` method 4772 // https://github.com/tc39/proposal-array-filtering 4773 filterReject: createMethod$2(7) 4774 }; 4775 4776 var SPECIES$2 = wellKnownSymbol('species'); 4777 4778 var setSpecies = function (CONSTRUCTOR_NAME) { 4779 var Constructor = getBuiltIn(CONSTRUCTOR_NAME); 4780 var defineProperty = objectDefineProperty.f; 4781 4782 if (descriptors && Constructor && !Constructor[SPECIES$2]) { 4783 defineProperty(Constructor, SPECIES$2, { 4784 configurable: true, 4785 get: function () { 4786 return this; 4787 } 4788 }); 4789 } 4790 }; 4791 4792 // makes subclassing work correct for wrapped built-ins 4793 4794 4795 var inheritIfRequired = function ($this, dummy, Wrapper) { 4796 var NewTarget, NewTargetPrototype; 4797 if ( // it can work only with native `setPrototypeOf` 4798 objectSetPrototypeOf && // we haven't completely correct pre-ES6 way for getting `new.target`, so use this 4799 isCallable(NewTarget = dummy.constructor) && NewTarget !== Wrapper && isObject(NewTargetPrototype = NewTarget.prototype) && NewTargetPrototype !== Wrapper.prototype) objectSetPrototypeOf($this, NewTargetPrototype); 4800 return $this; 4801 }; 4802 4803 var typedArrayConstructor = createCommonjsModule(function (module) { 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 var getOwnPropertyNames = objectGetOwnPropertyNames.f; 4850 4851 4852
vendor: 7,113 bytes, lines 4853-5035
4853 var forEach = arrayIteration.forEach; 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 var getInternalState = internalState.get; 4866 var setInternalState = internalState.set; 4867 var nativeDefineProperty = objectDefineProperty.f; 4868 var nativeGetOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; 4869 var round = Math.round; 4870 var RangeError = global_1.RangeError; 4871 var ArrayBuffer = arrayBuffer.ArrayBuffer; 4872 var ArrayBufferPrototype = ArrayBuffer.prototype; 4873 var DataView = arrayBuffer.DataView; 4874 var NATIVE_ARRAY_BUFFER_VIEWS = arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; 4875 var TYPED_ARRAY_CONSTRUCTOR = arrayBufferViewCore.TYPED_ARRAY_CONSTRUCTOR; 4876 var TYPED_ARRAY_TAG = arrayBufferViewCore.TYPED_ARRAY_TAG; 4877 var TypedArray = arrayBufferViewCore.TypedArray; 4878 var TypedArrayPrototype = arrayBufferViewCore.TypedArrayPrototype; 4879 var aTypedArrayConstructor = arrayBufferViewCore.aTypedArrayConstructor; 4880 var isTypedArray = arrayBufferViewCore.isTypedArray; 4881 var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT'; 4882 var WRONG_LENGTH = 'Wrong length'; 4883 4884 var fromList = function (C, list) { 4885 aTypedArrayConstructor(C); 4886 var index = 0; 4887 var length = list.length; 4888 var result = new C(length); 4889 4890 while (length > index) result[index] = list[index++]; 4891 4892 return result; 4893 }; 4894 4895 var addGetter = function (it, key) { 4896 nativeDefineProperty(it, key, { 4897 get: function () { 4898 return getInternalState(this)[key]; 4899 } 4900 }); 4901 }; 4902 4903 var isArrayBuffer = function (it) { 4904 var klass; 4905 return objectIsPrototypeOf(ArrayBufferPrototype, it) || (klass = classof(it)) == 'ArrayBuffer' || klass == 'SharedArrayBuffer'; 4906 }; 4907 4908 var isTypedArrayIndex = function (target, key) { 4909 return isTypedArray(target) && !isSymbol(key) && key in target && isIntegralNumber(+key) && key >= 0; 4910 }; 4911 4912 var wrappedGetOwnPropertyDescriptor = function getOwnPropertyDescriptor(target, key) { 4913 key = toPropertyKey(key); 4914 return isTypedArrayIndex(target, key) ? createPropertyDescriptor(2, target[key]) : nativeGetOwnPropertyDescriptor(target, key); 4915 }; 4916 4917 var wrappedDefineProperty = function defineProperty(target, key, descriptor) { 4918 key = toPropertyKey(key); 4919 4920 if (isTypedArrayIndex(target, key) && isObject(descriptor) && hasOwnProperty_1(descriptor, 'value') && !hasOwnProperty_1(descriptor, 'get') && !hasOwnProperty_1(descriptor, 'set') // TODO: add validation descriptor w/o calling accessors 4921 && !descriptor.configurable && (!hasOwnProperty_1(descriptor, 'writable') || descriptor.writable) && (!hasOwnProperty_1(descriptor, 'enumerable') || descriptor.enumerable)) { 4922 target[key] = descriptor.value; 4923 return target; 4924 } 4925 4926 return nativeDefineProperty(target, key, descriptor); 4927 }; 4928 4929 if (descriptors) { 4930 if (!NATIVE_ARRAY_BUFFER_VIEWS) { 4931 objectGetOwnPropertyDescriptor.f = wrappedGetOwnPropertyDescriptor; 4932 objectDefineProperty.f = wrappedDefineProperty; 4933 addGetter(TypedArrayPrototype, 'buffer'); 4934 addGetter(TypedArrayPrototype, 'byteOffset'); 4935 addGetter(TypedArrayPrototype, 'byteLength'); 4936 addGetter(TypedArrayPrototype, 'length'); 4937 } 4938 4939 _export({ 4940 target: 'Object', 4941 stat: true, 4942 forced: !NATIVE_ARRAY_BUFFER_VIEWS 4943 }, { 4944 getOwnPropertyDescriptor: wrappedGetOwnPropertyDescriptor, 4945 defineProperty: wrappedDefineProperty 4946 }); 4947 4948 module.exports = function (TYPE, wrapper, CLAMPED) { 4949 var BYTES = TYPE.match(/\d+$/)[0] / 8; 4950 var CONSTRUCTOR_NAME = TYPE + (CLAMPED ? 'Clamped' : '') + 'Array'; 4951 var GETTER = 'get' + TYPE; 4952 var SETTER = 'set' + TYPE; 4953 var NativeTypedArrayConstructor = global_1[CONSTRUCTOR_NAME]; 4954 var TypedArrayConstructor = NativeTypedArrayConstructor; 4955 var TypedArrayConstructorPrototype = TypedArrayConstructor && TypedArrayConstructor.prototype; 4956 var exported = {}; 4957 4958 var getter = function (that, index) { 4959 var data = getInternalState(that); 4960 return data.view[GETTER](index * BYTES + data.byteOffset, true); 4961 }; 4962 4963 var setter = function (that, index, value) { 4964 var data = getInternalState(that); 4965 if (CLAMPED) value = (value = round(value)) < 0 ? 0 : value > 0xFF ? 0xFF : value & 0xFF; 4966 data.view[SETTER](index * BYTES + data.byteOffset, value, true); 4967 }; 4968 4969 var addElement = function (that, index) { 4970 nativeDefineProperty(that, index, { 4971 get: function () { 4972 return getter(this, index); 4973 }, 4974 set: function (value) { 4975 return setter(this, index, value); 4976 }, 4977 enumerable: true 4978 }); 4979 }; 4980 4981 if (!NATIVE_ARRAY_BUFFER_VIEWS) { 4982 TypedArrayConstructor = wrapper(function (that, data, offset, $length) { 4983 anInstance(that, TypedArrayConstructorPrototype); 4984 var index = 0; 4985 var byteOffset = 0; 4986 var buffer, byteLength, length; 4987 4988 if (!isObject(data)) { 4989 length = toIndex(data); 4990 byteLength = length * BYTES; 4991 buffer = new ArrayBuffer(byteLength); 4992 } else if (isArrayBuffer(data)) { 4993 buffer = data; 4994 byteOffset = toOffset(offset, BYTES); 4995 var $len = data.byteLength; 4996 4997 if ($length === undefined) { 4998 if ($len % BYTES) throw RangeError(WRONG_LENGTH); 4999 byteLength = $len - byteOffset; 5000 if (byteLength < 0) throw RangeError(WRONG_LENGTH); 5001 } else { 5002 byteLength = toLength($length) * BYTES; 5003 if (byteLength + byteOffset > $len) throw RangeError(WRONG_LENGTH); 5004 } 5005 5006 length = byteLength / BYTES; 5007 } else if (isTypedArray(data)) { 5008 return fromList(TypedArrayConstructor, data); 5009 } else { 5010 return functionCall(typedArrayFrom, TypedArrayConstructor, data); 5011 } 5012 5013 setInternalState(that, { 5014 buffer: buffer, 5015 byteOffset: byteOffset, 5016 byteLength: byteLength, 5017 length: length, 5018 view: new DataView(buffer) 5019 }); 5020 5021 while (index < length) addElement(that, index++); 5022 }); 5023 if (objectSetPrototypeOf) objectSetPrototypeOf(TypedArrayConstructor, TypedArray); 5024 TypedArrayConstructorPrototype = TypedArrayConstructor.prototype = objectCreate(TypedArrayPrototype); 5025 } else if (typedArrayConstructorsRequireWrappers) { 5026 TypedArrayConstructor = wrapper(function (dummy, data, typedArrayOffset, $length) { 5027 anInstance(dummy, TypedArrayConstructorPrototype); 5028 return inheritIfRequired(function () { 5029 if (!isObject(data)) return new NativeTypedArrayConstructor(toIndex(data)); 5030 if (isArrayBuffer(data)) return $length !== undefined ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES), $length) : typedArrayOffset !== undefined ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES)) : new NativeTypedArrayConstructor(data); 5031 if (isTypedArray(data)) return fromList(TypedArrayConstructor, data); 5032 return functionCall(typedArrayFrom, TypedArrayConstructor, data); 5033 }(), dummy, TypedArrayConstructor); 5034 }); 5035 if (objectSetPrototypeOf) objectSetPrototypeOf(TypedArrayConstructor, TypedArray);
5036 forEach(getOwnPropertyNames(NativeTypedArrayConstructor), function (key) { 5037 if (!(key in TypedArrayConstructor)) { 5038 createNonEnumerableProperty(TypedArrayConstructor, key, NativeTypedArrayConstructor[key]); 5039 } 5040 }); 5041 TypedArrayConstructor.prototype = TypedArrayConstructorPrototype; 5042 } 5043 5044 if (TypedArrayConstructorPrototype.constructor !== TypedArrayConstructor) { 5045 createNonEnumerableProperty(TypedArrayConstructorPrototype, 'constructor', TypedArrayConstructor); 5046 } 5047 5048 createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_CONSTRUCTOR, TypedArrayConstructor); 5049 5050 if (TYPED_ARRAY_TAG) { 5051 createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_TAG, CONSTRUCTOR_NAME); 5052 } 5053 5054 exported[CONSTRUCTOR_NAME] = TypedArrayConstructor; 5055 _export({ 5056 global: true, 5057 forced: TypedArrayConstructor != NativeTypedArrayConstructor, 5058 sham: !NATIVE_ARRAY_BUFFER_VIEWS 5059 }, exported); 5060 5061 if (!(BYTES_PER_ELEMENT in TypedArrayConstructor)) { 5062 createNonEnumerableProperty(TypedArrayConstructor, BYTES_PER_ELEMENT, BYTES); 5063 } 5064 5065 if (!(BYTES_PER_ELEMENT in TypedArrayConstructorPrototype)) { 5066 createNonEnumerableProperty(TypedArrayConstructorPrototype, BYTES_PER_ELEMENT, BYTES); 5067 } 5068 5069 setSpecies(CONSTRUCTOR_NAME); 5070 }; 5071 } else module.exports = function () { 5072 /* empty */ 5073 }; 5074 }); 5075 5076 // `Float32Array` constructor 5077 // https://tc39.es/ecma262/#sec-typedarray-objects 5078 5079 5080 typedArrayConstructor('Float32', function (init) { 5081 return function Float32Array(data, byteOffset, length) { 5082 return init(this, data, byteOffset, length); 5083 }; 5084 }); 5085 5086 // `Float64Array` constructor 5087 // https://tc39.es/ecma262/#sec-typedarray-objects 5088 5089 5090 typedArrayConstructor('Float64', function (init) { 5091 return function Float64Array(data, byteOffset, length) { 5092 return init(this, data, byteOffset, length); 5093 }; 5094 }); 5095 5096 // `Int8Array` constructor 5097 // https://tc39.es/ecma262/#sec-typedarray-objects 5098 5099 5100 typedArrayConstructor('Int8', function (init) { 5101 return function Int8Array(data, byteOffset, length) { 5102 return init(this, data, byteOffset, length); 5103 }; 5104 }); 5105 5106 // `Int16Array` constructor 5107 // https://tc39.es/ecma262/#sec-typedarray-objects 5108 5109 5110 typedArrayConstructor('Int16', function (init) { 5111 return function Int16Array(data, byteOffset, length) { 5112 return init(this, data, byteOffset, length); 5113 }; 5114 }); 5115 5116 // `Int32Array` constructor 5117 // https://tc39.es/ecma262/#sec-typedarray-objects 5118 5119 5120 typedArrayConstructor('Int32', function (init) { 5121 return function Int32Array(data, byteOffset, length) { 5122 return init(this, data, byteOffset, length); 5123 }; 5124 }); 5125 5126 // `Uint8Array` constructor 5127 // https://tc39.es/ecma262/#sec-typedarray-objects 5128 5129 5130 typedArrayConstructor('Uint8', function (init) { 5131 return function Uint8Array(data, byteOffset, length) { 5132 return init(this, data, byteOffset, length); 5133 }; 5134 }); 5135 5136 // `Uint8ClampedArray` constructor 5137 // https://tc39.es/ecma262/#sec-typedarray-objects 5138 5139 5140 typedArrayConstructor('Uint8', function (init) { 5141 return function Uint8ClampedArray(data, byteOffset, length) { 5142 return init(this, data, byteOffset, length); 5143 }; 5144 }, true); 5145 5146 // `Uint16Array` constructor 5147 // https://tc39.es/ecma262/#sec-typedarray-objects 5148 5149 5150 typedArrayConstructor('Uint16', function (init) { 5151 return function Uint16Array(data, byteOffset, length) { 5152 return init(this, data, byteOffset, length); 5153 }; 5154 }); 5155 5156 // `Uint32Array` constructor 5157 // https://tc39.es/ecma262/#sec-typedarray-objects 5158 5159 5160 typedArrayConstructor('Uint32', function (init) { 5161 return function Uint32Array(data, byteOffset, length) { 5162 return init(this, data, byteOffset, length); 5163 }; 5164 }); 5165 5166 var aTypedArray$1 = arrayBufferViewCore.aTypedArray; 5167 var exportTypedArrayMethod$1 = arrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.at` method 5168 // https://github.com/tc39/proposal-relative-indexing-method 5169 5170 exportTypedArrayMethod$1('at', function at(index) { 5171 var O = aTypedArray$1(this); 5172 var len = lengthOfArrayLike(O); 5173 var relativeIndex = toIntegerOrInfinity(index); 5174 var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; 5175 return k < 0 || k >= len ? undefined : O[k]; 5176 }); 5177 5178 var exportTypedArrayStaticMethod$1 = arrayBufferViewCore.exportTypedArrayStaticMethod; 5179 5180 // `%TypedArray%.from` method 5181 // https://tc39.es/ecma262/#sec-%typedarray%.from 5182 5183 5184 exportTypedArrayStaticMethod$1('from', typedArrayFrom, typedArrayConstructorsRequireWrappers); 5185 5186 var aTypedArrayConstructor$2 = arrayBufferViewCore.aTypedArrayConstructor; 5187 var exportTypedArrayStaticMethod$2 = arrayBufferViewCore.exportTypedArrayStaticMethod; // `%TypedArray%.of` method 5188 // https://tc39.es/ecma262/#sec-%typedarray%.of 5189 5190 exportTypedArrayStaticMethod$2('of', function of() 5191 /* ...items */ 5192 { 5193 var index = 0; 5194 var length = arguments.length; 5195 var result = new (aTypedArrayConstructor$2(this))(length); 5196 5197 while (length > index) result[index] = arguments[index++]; 5198 5199 return result; 5200 }, typedArrayConstructorsRequireWrappers); 5201 5202 var floor$4 = Math.floor; 5203 5204 var mergeSort = function (array, comparefn) { 5205 var length = array.length; 5206 var middle = floor$4(length / 2); 5207 return length < 8 ? insertionSort(array, comparefn) : merge(array, mergeSort(arraySliceSimple(array, 0, middle), comparefn), mergeSort(arraySliceSimple(array, middle), comparefn), comparefn); 5208 }; 5209 5210 var insertionSort = function (array, comparefn) { 5211 var length = array.length; 5212 var i = 1; 5213 var element, j; 5214 5215 while (i < length) { 5216 j = i; 5217 element = array[i]; 5218 5219 while (j && comparefn(array[j - 1], element) > 0) { 5220 array[j] = array[--j]; 5221 } 5222 5223 if (j !== i++) array[j] = element; 5224 } 5225 5226 return array; 5227 }; 5228 5229 var merge = function (array, left, right, comparefn) { 5230 var llength = left.length; 5231 var rlength = right.length; 5232 var lindex = 0; 5233 var rindex = 0; 5234 5235 while (lindex < llength || rindex < rlength) { 5236 array[lindex + rindex] = lindex < llength && rindex < rlength ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++] : lindex < llength ? left[lindex++] : right[rindex++]; 5237 } 5238 5239 return array; 5240 }; 5241 5242 var arraySort = mergeSort; 5243 5244 var firefox = engineUserAgent.match(/firefox\/(\d+)/i); 5245 var engineFfVersion = !!firefox && +firefox[1]; 5246 5247 var engineIsIeOrEdge = /MSIE|Trident/.test(engineUserAgent); 5248
vendor: 4,612 bytes, lines 5249-5393
5249 var webkit = engineUserAgent.match(/AppleWebKit\/(\d+)\./); 5250 var engineWebkitVersion = !!webkit && +webkit[1]; 5251 5252 var Array$5 = global_1.Array; 5253 var aTypedArray$2 = arrayBufferViewCore.aTypedArray; 5254 var exportTypedArrayMethod$2 = arrayBufferViewCore.exportTypedArrayMethod; 5255 var Uint16Array = global_1.Uint16Array; 5256 var un$Sort = Uint16Array && functionUncurryThis(Uint16Array.prototype.sort); // WebKit 5257 5258 var ACCEPT_INCORRECT_ARGUMENTS = !!un$Sort && !(fails(function () { 5259 un$Sort(new Uint16Array(2), null); 5260 }) && fails(function () { 5261 un$Sort(new Uint16Array(2), {}); 5262 })); 5263 var STABLE_SORT = !!un$Sort && !fails(function () { 5264 // feature detection can be too slow, so check engines versions 5265 if (engineV8Version) return engineV8Version < 74; 5266 if (engineFfVersion) return engineFfVersion < 67; 5267 if (engineIsIeOrEdge) return true; 5268 if (engineWebkitVersion) return engineWebkitVersion < 602; 5269 var array = new Uint16Array(516); 5270 var expected = Array$5(516); 5271 var index, mod; 5272 5273 for (index = 0; index < 516; index++) { 5274 mod = index % 4; 5275 array[index] = 515 - index; 5276 expected[index] = index - 2 * mod + 3; 5277 } 5278 5279 un$Sort(array, function (a, b) { 5280 return (a / 4 | 0) - (b / 4 | 0); 5281 }); 5282 5283 for (index = 0; index < 516; index++) { 5284 if (array[index] !== expected[index]) return true; 5285 } 5286 }); 5287 5288 var getSortCompare = function (comparefn) { 5289 return function (x, y) { 5290 if (comparefn !== undefined) return +comparefn(x, y) || 0; // eslint-disable-next-line no-self-compare -- NaN check 5291 5292 if (y !== y) return -1; // eslint-disable-next-line no-self-compare -- NaN check 5293 5294 if (x !== x) return 1; 5295 if (x === 0 && y === 0) return 1 / x > 0 && 1 / y < 0 ? 1 : -1; 5296 return x > y; 5297 }; 5298 }; // `%TypedArray%.prototype.sort` method 5299 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.sort 5300 5301 5302 exportTypedArrayMethod$2('sort', function sort(comparefn) { 5303 if (comparefn !== undefined) aCallable(comparefn); 5304 if (STABLE_SORT) return un$Sort(this, comparefn); 5305 return arraySort(aTypedArray$2(this), getSortCompare(comparefn)); 5306 }, !STABLE_SORT || ACCEPT_INCORRECT_ARGUMENTS); 5307 5308 // iterable DOM collections 5309 // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods 5310 var domIterables = { 5311 CSSRuleList: 0, 5312 CSSStyleDeclaration: 0, 5313 CSSValueList: 0, 5314 ClientRectList: 0, 5315 DOMRectList: 0, 5316 DOMStringList: 0, 5317 DOMTokenList: 1, 5318 DataTransferItemList: 0, 5319 FileList: 0, 5320 HTMLAllCollection: 0, 5321 HTMLCollection: 0, 5322 HTMLFormElement: 0, 5323 HTMLSelectElement: 0, 5324 MediaList: 0, 5325 MimeTypeArray: 0, 5326 NamedNodeMap: 0, 5327 NodeList: 1, 5328 PaintRequestList: 0, 5329 Plugin: 0, 5330 PluginArray: 0, 5331 SVGLengthList: 0, 5332 SVGNumberList: 0, 5333 SVGPathSegList: 0, 5334 SVGPointList: 0, 5335 SVGStringList: 0, 5336 SVGTransformList: 0, 5337 SourceBufferList: 0, 5338 StyleSheetList: 0, 5339 TextTrackCueList: 0, 5340 TextTrackList: 0, 5341 TouchList: 0 5342 }; 5343 5344 // in old WebKit versions, `element.classList` is not an instance of global `DOMTokenList` 5345 5346 5347 var classList = documentCreateElement('span').classList; 5348 var DOMTokenListPrototype = classList && classList.constructor && classList.constructor.prototype; 5349 var domTokenListPrototype = DOMTokenListPrototype === Object.prototype ? undefined : DOMTokenListPrototype; 5350 5351 var PROPER_FUNCTION_NAME$1 = functionName.PROPER; 5352 var CONFIGURABLE_FUNCTION_NAME$1 = functionName.CONFIGURABLE; 5353 var IteratorPrototype$2 = iteratorsCore.IteratorPrototype; 5354 var BUGGY_SAFARI_ITERATORS$1 = iteratorsCore.BUGGY_SAFARI_ITERATORS; 5355 var ITERATOR$4 = wellKnownSymbol('iterator'); 5356 var KEYS = 'keys'; 5357 var VALUES = 'values'; 5358 var ENTRIES = 'entries'; 5359 5360 var returnThis$1 = function () { 5361 return this; 5362 }; 5363 5364 var defineIterator = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) { 5365 createIteratorConstructor(IteratorConstructor, NAME, next); 5366 5367 var getIterationMethod = function (KIND) { 5368 if (KIND === DEFAULT && defaultIterator) return defaultIterator; 5369 if (!BUGGY_SAFARI_ITERATORS$1 && KIND in IterablePrototype) return IterablePrototype[KIND]; 5370 5371 switch (KIND) { 5372 case KEYS: 5373 return function keys() { 5374 return new IteratorConstructor(this, KIND); 5375 }; 5376 5377 case VALUES: 5378 return function values() { 5379 return new IteratorConstructor(this, KIND); 5380 }; 5381 5382 case ENTRIES: 5383 return function entries() { 5384 return new IteratorConstructor(this, KIND); 5385 }; 5386 } 5387 5388 return function () { 5389 return new IteratorConstructor(this); 5390 }; 5391 }; 5392 5393 var TO_STRING_TAG = NAME + ' Iterator';
5394 var INCORRECT_VALUES_NAME = false; 5395 var IterablePrototype = Iterable.prototype; 5396 var nativeIterator = IterablePrototype[ITERATOR$4] || IterablePrototype['@@iterator'] || DEFAULT && IterablePrototype[DEFAULT]; 5397 var defaultIterator = !BUGGY_SAFARI_ITERATORS$1 && nativeIterator || getIterationMethod(DEFAULT); 5398 var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator; 5399 var CurrentIteratorPrototype, methods, KEY; // fix native 5400 5401 if (anyNativeIterator) { 5402 CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable())); 5403 5404 if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) { 5405 if (objectGetPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype$2) { 5406 if (objectSetPrototypeOf) { 5407 objectSetPrototypeOf(CurrentIteratorPrototype, IteratorPrototype$2); 5408 } else if (!isCallable(CurrentIteratorPrototype[ITERATOR$4])) { 5409 redefine(CurrentIteratorPrototype, ITERATOR$4, returnThis$1); 5410 } 5411 } // Set @@toStringTag to native iterators 5412 5413 5414 setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true); 5415 } 5416 } // fix Array.prototype.{ values, @@iterator }.name in V8 / FF 5417 5418 5419 if (PROPER_FUNCTION_NAME$1 && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) { 5420 if (CONFIGURABLE_FUNCTION_NAME$1) { 5421 createNonEnumerableProperty(IterablePrototype, 'name', VALUES); 5422 } else { 5423 INCORRECT_VALUES_NAME = true; 5424 5425 defaultIterator = function values() { 5426 return functionCall(nativeIterator, this); 5427 }; 5428 } 5429 } // export additional methods 5430 5431 5432 if (DEFAULT) { 5433 methods = { 5434 values: getIterationMethod(VALUES), 5435 keys: IS_SET ? defaultIterator : getIterationMethod(KEYS), 5436 entries: getIterationMethod(ENTRIES) 5437 }; 5438 if (FORCED) for (KEY in methods) { 5439 if (BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) { 5440 redefine(IterablePrototype, KEY, methods[KEY]); 5441 } 5442 } else _export({ 5443 target: NAME, 5444 proto: true, 5445 forced: BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME 5446 }, methods); 5447 } // define iterator 5448 5449 5450 if (IterablePrototype[ITERATOR$4] !== defaultIterator) { 5451 redefine(IterablePrototype, ITERATOR$4, defaultIterator, { 5452 name: DEFAULT 5453 }); 5454 } 5455 5456 iterators[NAME] = defaultIterator; 5457 return methods; 5458 }; 5459 5460 var ARRAY_ITERATOR = 'Array Iterator'; 5461 var setInternalState$2 = internalState.set; 5462 var getInternalState$3 = internalState.getterFor(ARRAY_ITERATOR); // `Array.prototype.entries` method 5463 // https://tc39.es/ecma262/#sec-array.prototype.entries 5464 // `Array.prototype.keys` method 5465 // https://tc39.es/ecma262/#sec-array.prototype.keys 5466 // `Array.prototype.values` method 5467 // https://tc39.es/ecma262/#sec-array.prototype.values 5468 // `Array.prototype[@@iterator]` method 5469 // https://tc39.es/ecma262/#sec-array.prototype-@@iterator 5470 // `CreateArrayIterator` internal method 5471 // https://tc39.es/ecma262/#sec-createarrayiterator 5472 5473 var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind) { 5474 setInternalState$2(this, { 5475 type: ARRAY_ITERATOR, 5476 target: toIndexedObject(iterated), 5477 // target 5478 index: 0, 5479 // next index 5480 kind: kind // kind 5481 5482 }); // `%ArrayIteratorPrototype%.next` method 5483 // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next 5484 }, function () { 5485 var state = getInternalState$3(this); 5486 var target = state.target; 5487 var kind = state.kind; 5488 var index = state.index++; 5489 5490 if (!target || index >= target.length) { 5491 state.target = undefined; 5492 return { 5493 value: undefined, 5494 done: true 5495 }; 5496 } 5497 5498 if (kind == 'keys') return { 5499 value: index, 5500 done: false 5501 }; 5502 if (kind == 'values') return { 5503 value: target[index], 5504 done: false 5505 }; 5506 return { 5507 value: [index, target[index]], 5508 done: false 5509 }; 5510 }, 'values'); // argumentsList[@@iterator] is %ArrayProto_values% 5511 // https://tc39.es/ecma262/#sec-createunmappedargumentsobject 5512 // https://tc39.es/ecma262/#sec-createmappedargumentsobject 5513 5514 iterators.Arguments = iterators.Array; // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 5515 5516 addToUnscopables('keys'); 5517 addToUnscopables('values'); 5518 addToUnscopables('entries'); 5519 5520 var ITERATOR$5 = wellKnownSymbol('iterator'); 5521 var TO_STRING_TAG$5 = wellKnownSymbol('toStringTag'); 5522 var ArrayValues = es_array_iterator.values; 5523 5524 var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) { 5525 if (CollectionPrototype) { 5526 // some Chrome versions have non-configurable methods on DOMTokenList 5527 if (CollectionPrototype[ITERATOR$5] !== ArrayValues) try { 5528 createNonEnumerableProperty(CollectionPrototype, ITERATOR$5, ArrayValues); 5529 } catch (error) { 5530 CollectionPrototype[ITERATOR$5] = ArrayValues; 5531 } 5532 5533 if (!CollectionPrototype[TO_STRING_TAG$5]) { 5534 createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG$5, COLLECTION_NAME); 5535 } 5536 5537 if (domIterables[COLLECTION_NAME]) for (var METHOD_NAME in es_array_iterator) { 5538 // some Chrome versions have non-configurable methods on DOMTokenList 5539 if (CollectionPrototype[METHOD_NAME] !== es_array_iterator[METHOD_NAME]) try { 5540 createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, es_array_iterator[METHOD_NAME]); 5541 } catch (error) { 5542 CollectionPrototype[METHOD_NAME] = es_array_iterator[METHOD_NAME]; 5543 } 5544 } 5545 } 5546 }; 5547 5548 for (var COLLECTION_NAME in domIterables) { 5549 handlePrototype(global_1[COLLECTION_NAME] && global_1[COLLECTION_NAME].prototype, COLLECTION_NAME); 5550 } 5551 5552 handlePrototype(domTokenListPrototype, 'DOMTokenList'); 5553 5554 var FunctionPrototype$2 = Function.prototype; 5555 var apply = FunctionPrototype$2.apply; 5556 var bind$2 = FunctionPrototype$2.bind; 5557 var call$2 = FunctionPrototype$2.call; // eslint-disable-next-line es/no-reflect -- safe 5558 5559 var functionApply = typeof Reflect == 'object' && Reflect.apply || (bind$2 ? call$2.bind(apply) : function () { 5560 return call$2.apply(apply, arguments); 5561 }); 5562 5563 var arraySlice = functionUncurryThis([].slice); 5564 5565 var engineIsIos = /(?:ipad|iphone|ipod).*applewebkit/i.test(engineUserAgent); 5566 5567 var engineIsNode = classofRaw(global_1.process) == 'process'; 5568 5569 var set$2 = global_1.setImmediate; 5570 var clear = global_1.clearImmediate; 5571 var process$1 = global_1.process; 5572 var Dispatch = global_1.Dispatch; 5573 var Function$1 = global_1.Function; 5574 var MessageChannel = global_1.MessageChannel; 5575 var String$5 = global_1.String; 5576 var counter = 0; 5577 var queue = {}; 5578 var ONREADYSTATECHANGE = 'onreadystatechange'; 5579 var location, defer, channel, port; 5580 5581 try { 5582 // Deno throws a ReferenceError on `location` access without `--location` flag 5583 location = global_1.location; 5584 } catch (error) { 5585 /* empty */ 5586 } 5587 5588 var run = function (id) { 5589 if (hasOwnProperty_1(queue, id)) { 5590 var fn = queue[id]; 5591 delete queue[id]; 5592 fn(); 5593 } 5594 }; 5595 5596 var runner = function (id) { 5597 return function () { 5598 run(id); 5599 }; 5600 }; 5601 5602 var listener = function (event) { 5603 run(event.data); 5604 }; 5605 5606 var post = function (id) { 5607 // old engines have not location.origin 5608 global_1.postMessage(String$5(id), location.protocol + '//' + location.host); 5609 }; // Node.js 0.9+ & IE10+ has setImmediate, otherwise: 5610 5611 5612 if (!set$2 || !clear) { 5613 set$2 = function setImmediate(fn) { 5614 var args = arraySlice(arguments, 1); 5615 5616 queue[++counter] = function () { 5617 functionApply(isCallable(fn) ? fn : Function$1(fn), undefined, args); 5618 }; 5619 5620 defer(counter); 5621 return counter; 5622 }; 5623 5624 clear = function clearImmediate(id) { 5625 delete queue[id]; 5626 }; // Node.js 0.8- 5627 5628 5629 if (engineIsNode) { 5630 defer = function (id) { 5631 process$1.nextTick(runner(id)); 5632 }; // Sphere (JS game engine) Dispatch API 5633 5634 } else if (Dispatch && Dispatch.now) { 5635 defer = function (id) { 5636 Dispatch.now(runner(id)); 5637 }; // Browsers with MessageChannel, includes WebWorkers 5638 // except iOS - https://github.com/zloirock/core-js/issues/624 5639 5640 } else if (MessageChannel && !engineIsIos) { 5641 channel = new MessageChannel(); 5642 port = channel.port2; 5643 channel.port1.onmessage = listener; 5644 defer = functionBindContext(port.postMessage, port); // Browsers with postMessage, skip WebWorkers 5645 // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' 5646 } else if (global_1.addEventListener && isCallable(global_1.postMessage) && !global_1.importScripts && location && location.protocol !== 'file:' && !fails(post)) { 5647 defer = post; 5648 global_1.addEventListener('message', listener, false); // IE8- 5649 } else if (ONREADYSTATECHANGE in documentCreateElement('script')) { 5650 defer = function (id) { 5651 html.appendChild(documentCreateElement('script'))[ONREADYSTATECHANGE] = function () { 5652 html.removeChild(this); 5653 run(id); 5654 }; 5655 }; // Rest old browsers 5656 5657 } else { 5658 defer = function (id) { 5659 setTimeout(runner(id), 0); 5660 }; 5661 } 5662 } 5663 5664 var task = { 5665 set: set$2, 5666 clear: clear 5667 }; 5668 5669 var FORCED = !global_1.setImmediate || !global_1.clearImmediate; // http://w3c.github.io/setImmediate/ 5670 5671 _export({ 5672 global: true, 5673 bind: true, 5674 enumerable: true, 5675 forced: FORCED 5676 }, { 5677 // `setImmediate` method 5678 // http://w3c.github.io/setImmediate/#si-setImmediate 5679 setImmediate: task.set, 5680 // `clearImmediate` method 5681 // http://w3c.github.io/setImmediate/#si-clearImmediate 5682 clearImmediate: task.clear 5683 }); 5684 5685 var engineIsIosPebble = /ipad|iphone|ipod/i.test(engineUserAgent) && global_1.Pebble !== undefined; 5686 5687 var engineIsWebosWebkit = /web0s(?!.*chrome)/i.test(engineUserAgent); 5688 5689 var getOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f; 5690 5691 var macrotask = task.set; 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 var MutationObserver = global_1.MutationObserver || global_1.WebKitMutationObserver; 5702 var document$2 = global_1.document; 5703 var process$2 = global_1.process; 5704 var Promise = global_1.Promise; // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask` 5705 5706 var queueMicrotaskDescriptor = getOwnPropertyDescriptor$2(global_1, 'queueMicrotask'); 5707 var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value; 5708 var flush, head, last, notify, toggle, node, promise, then; // modern engines have queueMicrotask method 5709 5710 if (!queueMicrotask) { 5711 flush = function () { 5712 var parent, fn; 5713 if (engineIsNode && (parent = process$2.domain)) parent.exit(); 5714 5715 while (head) { 5716 fn = head.fn; 5717 head = head.next; 5718 5719 try { 5720 fn(); 5721 } catch (error) { 5722 if (head) notify();else last = undefined; 5723 throw error; 5724 } 5725 } 5726 5727 last = undefined; 5728 if (parent) parent.enter(); 5729 }; // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339 5730 // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898 5731 5732 5733 if (!engineIsIos && !engineIsNode && !engineIsWebosWebkit && MutationObserver && document$2) { 5734 toggle = true; 5735 node = document$2.createTextNode(''); 5736 new MutationObserver(flush).observe(node, { 5737 characterData: true 5738 }); 5739 5740 notify = function () { 5741 node.data = toggle = !toggle; 5742 }; // environments with maybe non-completely correct, but existent Promise 5743 5744 } else if (!engineIsIosPebble && Promise && Promise.resolve) { 5745 // Promise.resolve without an argument throws an error in LG WebOS 2 5746 promise = Promise.resolve(undefined); // workaround of WebKit ~ iOS Safari 10.1 bug 5747 5748 promise.constructor = Promise; 5749 then = functionBindContext(promise.then, promise); 5750 5751 notify = function () { 5752 then(flush); 5753 }; // Node.js without promises 5754 5755 } else if (engineIsNode) { 5756 notify = function () { 5757 process$2.nextTick(flush); 5758 }; // for other environments - macrotask based on: 5759 // - setImmediate 5760 // - MessageChannel 5761 // - window.postMessag 5762 // - onreadystatechange 5763 // - setTimeout 5764 5765 } else { 5766 // strange IE + webpack dev server bug - use .bind(global) 5767 macrotask = functionBindContext(macrotask, global_1); 5768 5769 notify = function () { 5770 macrotask(flush); 5771 }; 5772 } 5773 } 5774 5775 var microtask = queueMicrotask || function (fn) { 5776 var task$$1 = { 5777 fn: fn, 5778 next: undefined 5779 }; 5780 if (last) last.next = task$$1; 5781 5782 if (!head) { 5783 head = task$$1; 5784 notify(); 5785 } 5786 5787 last = task$$1; 5788 }; 5789 5790 var process$3 = global_1.process; // `queueMicrotask` method 5791 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask 5792 5793 _export({ 5794 global: true, 5795 enumerable: true, 5796 noTargetGet: true 5797 }, { 5798 queueMicrotask: function queueMicrotask(fn) { 5799 var domain = engineIsNode && process$3.domain; 5800 microtask(domain ? domain.bind(fn) : fn); 5801 } 5802 }); 5803 5804 // File generated automatically. Don't modify it. 5805 5806}((this.window = this.window || {}))); 5807 5808 5809 5810if (window._main_polyfill_core) 5811{ 5812 console.warn('main.polyfill.core is loaded more than once on this page'); 5813} 5814 5815window._main_polyfill_core = true; 5816 5817 5818(function (exports) { 5819 'use strict'; 5820 5821 var bxTmp = window.BX; 5822 window.BX = function (node) { 5823 if (window.BX.type.isNotEmptyString(node)) { 5824 return document.getElementById(node); 5825 } 5826 if (window.BX.type.isDomNode(node)) { 5827 return node; 5828 } 5829 if (window.BX.type.isFunction(node)) { 5830 return window.BX.ready(node); 5831 } 5832 return null; 5833 }; 5834 if (bxTmp) {
5835 Object.keys(bxTmp).forEach(key => { 5836 window.BX[key] = bxTmp[key]; 5837 }); 5838 } 5839 exports = window.BX; 5840 5841 /** 5842 * Gets object.toString result 5843 * @param value 5844 * @return {string} 5845 */ 5846 function getTag(value) { 5847 return Object.prototype.toString.call(value); 5848 } 5849 5850 const objectCtorString = Function.prototype.toString.call(Object); 5851 5852 /** 5853 * @memberOf BX 5854 */ 5855 let Type = /*#__PURE__*/function () { 5856 function Type() { 5857 babelHelpers.classCallCheck(this, Type); 5858 } 5859 babelHelpers.createClass(Type, null, [{ 5860 key: "isString", 5861 /** 5862 * Checks that value is string 5863 * @param value 5864 * @return {boolean} 5865 */ 5866 value: function isString(value) { 5867 return typeof value === 'string'; 5868 } 5869 /** 5870 * Returns true if a value is not empty string 5871 * @param value 5872 * @returns {boolean} 5873 */ 5874 }, { 5875 key: "isStringFilled", 5876 value: function isStringFilled(value) { 5877 return this.isString(value) && value !== ''; 5878 } 5879 /** 5880 * Checks that value is function 5881 * @param value 5882 * @return {boolean} 5883 */ 5884 }, { 5885 key: "isFunction", 5886 value: function isFunction(value) { 5887 return typeof value === 'function'; 5888 } 5889 /** 5890 * Checks that value is object 5891 * @param value 5892 * @return {boolean} 5893 */ 5894 }, { 5895 key: "isObject", 5896 value: function isObject(value) { 5897 return !!value && (typeof value === 'object' || typeof value === 'function'); 5898 } 5899 /** 5900 * Checks that value is object like 5901 * @param value 5902 * @return {boolean} 5903 */ 5904 }, { 5905 key: "isObjectLike", 5906 value: function isObjectLike(value) { 5907 return !!value && typeof value === 'object'; 5908 } 5909 /** 5910 * Checks that value is plain object 5911 * @param value 5912 * @return {boolean} 5913 */ 5914 }, { 5915 key: "isPlainObject", 5916 value: function isPlainObject(value) { 5917 if (!Type.isObjectLike(value) || getTag(value) !== '[object Object]') { 5918 return false; 5919 } 5920 const proto = Object.getPrototypeOf(value); 5921 if (proto === null) { 5922 return true; 5923 } 5924 const ctor = proto.hasOwnProperty('constructor') && proto.constructor; 5925 return typeof ctor === 'function' && Function.prototype.toString.call(ctor) === objectCtorString; 5926 } 5927 /** 5928 * Checks that value is boolean 5929 * @param value 5930 * @return {boolean} 5931 */ 5932 }, { 5933 key: "isBoolean", 5934 value: function isBoolean(value) { 5935 return value === true || value === false; 5936 } 5937 /** 5938 * Checks that value is number 5939 * @param value 5940 * @return {boolean} 5941 */ 5942 }, { 5943 key: "isNumber", 5944 value: function isNumber(value) { 5945 return !Number.isNaN(value) && typeof value === 'number'; 5946 } 5947 /** 5948 * Checks that value is integer 5949 * @param value 5950 * @return {boolean} 5951 */ 5952 }, { 5953 key: "isInteger", 5954 value: function isInteger(value) { 5955 return Type.isNumber(value) && value % 1 === 0; 5956 } 5957 /** 5958 * Checks that value is float 5959 * @param value 5960 * @return {boolean} 5961 */ 5962 }, { 5963 key: "isFloat", 5964 value: function isFloat(value) { 5965 return Type.isNumber(value) && !Type.isInteger(value); 5966 } 5967 /** 5968 * Checks that value is nil 5969 * @param value 5970 * @return {boolean} 5971 */ 5972 }, { 5973 key: "isNil", 5974 value: function isNil(value) { 5975 return value === null || value === undefined; 5976 } 5977 /** 5978 * Checks that value is array 5979 * @param value 5980 * @return {boolean} 5981 */ 5982 }, { 5983 key: "isArray", 5984 value: function isArray(value) { 5985 return !Type.isNil(value) && Array.isArray(value); 5986 } 5987 /** 5988 * Returns true if a value is an array and it has at least one element 5989 * @param value 5990 * @returns {boolean} 5991 */ 5992 }, { 5993 key: "isArrayFilled", 5994 value: function isArrayFilled(value) { 5995 return this.isArray(value) && value.length > 0; 5996 } 5997 /** 5998 * Checks that value is array like 5999 * @param value 6000 * @return {boolean} 6001 */ 6002 }, { 6003 key: "isArrayLike", 6004 value: function isArrayLike(value) { 6005 return !Type.isNil(value) && !Type.isFunction(value) && value.length > -1 && value.length <= Number.MAX_SAFE_INTEGER; 6006 } 6007 /** 6008 * Checks that value is Date 6009 * @param value 6010 * @return {boolean} 6011 */ 6012 }, { 6013 key: "isDate", 6014 value: function isDate(value) { 6015 return Type.isObjectLike(value) && getTag(value) === '[object Date]'; 6016 } 6017 /** 6018 * Checks that is DOM node 6019 * @param value 6020 * @return {boolean} 6021 */ 6022 }, { 6023 key: "isDomNode", 6024 value: function isDomNode(value) { 6025 return Type.isObjectLike(value) && !Type.isPlainObject(value) && 'nodeType' in value; 6026 } 6027 /** 6028 * Checks that value is element node 6029 * @param value 6030 * @return {boolean} 6031 */ 6032 }, { 6033 key: "isElementNode", 6034 value: function isElementNode(value) { 6035 return Type.isDomNode(value) && value.nodeType === Node.ELEMENT_NODE; 6036 } 6037 /** 6038 * Checks that value is text node 6039 * @param value 6040 * @return {boolean} 6041 */ 6042 }, { 6043 key: "isTextNode", 6044 value: function isTextNode(value) { 6045 return Type.isDomNode(value) && value.nodeType === Node.TEXT_NODE; 6046 } 6047 /** 6048 * Checks that value is Map 6049 * @param value 6050 * @return {boolean} 6051 */ 6052 }, { 6053 key: "isMap", 6054 value: function isMap(value) { 6055 return Type.isObjectLike(value) && getTag(value) === '[object Map]'; 6056 } 6057 /** 6058 * Checks that value is Set 6059 * @param value 6060 * @return {boolean} 6061 */ 6062 }, { 6063 key: "isSet", 6064 value: function isSet(value) { 6065 return Type.isObjectLike(value) && getTag(value) === '[object Set]'; 6066 } 6067 /** 6068 * Checks that value is WeakMap 6069 * @param value 6070 * @return {boolean} 6071 */ 6072 }, { 6073 key: "isWeakMap", 6074 value: function isWeakMap(value) { 6075 return Type.isObjectLike(value) && getTag(value) === '[object WeakMap]'; 6076 } 6077 /** 6078 * Checks that value is WeakSet 6079 * @param value 6080 * @return {boolean} 6081 */ 6082 }, { 6083 key: "isWeakSet", 6084 value: function isWeakSet(value) { 6085 return Type.isObjectLike(value) && getTag(value) === '[object WeakSet]'; 6086 } 6087 /** 6088 * Checks that value is prototype 6089 * @param value 6090 * @return {boolean} 6091 */ 6092 }, { 6093 key: "isPrototype", 6094 value: function isPrototype(value) { 6095 return (typeof (value && value.constructor) === 'function' && value.constructor.prototype || Object.prototype) === value; 6096 } 6097 /** 6098 * Checks that value is regexp 6099 * @param value 6100 * @return {boolean} 6101 */ 6102 }, { 6103 key: "isRegExp", 6104 value: function isRegExp(value) { 6105 return Type.isObjectLike(value) && getTag(value) === '[object RegExp]'; 6106 } 6107 /** 6108 * Checks that value is null 6109 * @param value 6110 * @return {boolean} 6111 */ 6112 }, { 6113 key: "isNull", 6114 value: function isNull(value) { 6115 return value === null; 6116 } 6117 /** 6118 * Checks that value is undefined 6119 * @param value 6120 * @return {boolean} 6121 */ 6122 }, { 6123 key: "isUndefined", 6124 value: function isUndefined(value) { 6125 return typeof value === 'undefined'; 6126 } 6127 /** 6128 * Checks that value is ArrayBuffer 6129 * @param value 6130 * @return {boolean} 6131 */ 6132 }, { 6133 key: "isArrayBuffer", 6134 value: function isArrayBuffer(value) { 6135 return Type.isObjectLike(value) && getTag(value) === '[object ArrayBuffer]'; 6136 } 6137 /** 6138 * Checks that value is typed array 6139 * @param value 6140 * @return {boolean} 6141 */ 6142 }, { 6143 key: "isTypedArray", 6144 value: function isTypedArray(value) { 6145 const regExpTypedTag = /^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)]$/; 6146 return Type.isObjectLike(value) && regExpTypedTag.test(getTag(value)); 6147 } 6148 /** 6149 * Checks that value is Blob 6150 * @param value 6151 * @return {boolean} 6152 */ 6153 }, { 6154 key: "isBlob", 6155 value: function isBlob(value) { 6156 return Type.isObjectLike(value) && Type.isNumber(value.size) && Type.isString(value.type) && Type.isFunction(value.slice); 6157 } 6158 /** 6159 * Checks that value is File 6160 * @param value 6161 * @return {boolean} 6162 */ 6163 }, { 6164 key: "isFile", 6165 value: function isFile(value) { 6166 return Type.isBlob(value) && Type.isString(value.name) && (Type.isNumber(value.lastModified) || Type.isObjectLike(value.lastModifiedDate)); 6167 } 6168 /** 6169 * Checks that value is FormData 6170 * @param value 6171 * @return {boolean} 6172 */ 6173 }, { 6174 key: "isFormData", 6175 value: function isFormData(value) { 6176 return value instanceof FormData; 6177 } 6178 }]); 6179 return Type; 6180 }(); 6181 6182 /** 6183 * @memberOf BX 6184 */ 6185 let Reflection = /*#__PURE__*/function () { 6186 function Reflection() { 6187 babelHelpers.classCallCheck(this, Reflection); 6188 } 6189 babelHelpers.createClass(Reflection, null, [{ 6190 key: "getClass", 6191 /** 6192 * Gets link to function by function name 6193 * @param className 6194 * @return {?Function} 6195 */ 6196 value: function getClass(className) { 6197 if (Type.isString(className) && !!className) { 6198 let classFn = null; 6199 let currentNamespace = window; 6200 const namespaces = className.split('.'); 6201 for (let i = 0; i < namespaces.length; i += 1) { 6202 const namespace = namespaces[i]; 6203 if (!currentNamespace[namespace]) { 6204 return null; 6205 } 6206 currentNamespace = currentNamespace[namespace]; 6207 classFn = currentNamespace; 6208 } 6209 return classFn; 6210 } 6211 if (Type.isFunction(className)) { 6212 return className; 6213 } 6214 return null; 6215 } 6216 /** 6217 * Creates a namespace or returns a link to a previously created one 6218 * @param {String} namespaceName 6219 * @return {Object<string, any> | Function | null} 6220 */ 6221 }, { 6222 key: "namespace", 6223 value: function namespace(namespaceName) { 6224 let parts = namespaceName.split('.'); 6225 let parent = window.BX; 6226 if (parts[0] === 'BX') { 6227 parts = parts.slice(1); 6228 } 6229 for (let i = 0; i < parts.length; i += 1) { 6230 if (Type.isUndefined(parent[parts[i]])) { 6231 parent[parts[i]] = {}; 6232 } 6233 parent = parent[parts[i]]; 6234 } 6235 return parent; 6236 } 6237 }]); 6238 return Reflection; 6239 }(); 6240 6241 const reEscape = /[&<>'"]/g; 6242 const reUnescape = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g; 6243 const escapeEntities = { 6244 '&': '&', 6245 '<': '<', 6246 '>': '>', 6247 "'": ''', 6248 '"': '"' 6249 }; 6250 const unescapeEntities = { 6251 '&': '&', 6252 '&': '&', 6253 '<': '<', 6254 '<': '<', 6255 '>': '>', 6256 '>': '>', 6257 ''': "'", 6258 ''': "'", 6259 '"': '"', 6260 '"': '"' 6261 }; 6262 6263 /** 6264 * @memberOf BX 6265 */ 6266 let Text = /*#__PURE__*/function () { 6267 function Text() { 6268 babelHelpers.classCallCheck(this, Text); 6269 } 6270 babelHelpers.createClass(Text, null, [{ 6271 key: "encode", 6272 /** 6273 * Encodes all unsafe entities 6274 * @param {string} value 6275 * @return {string} 6276 */ 6277 value: function encode(value) { 6278 if (Type.isString(value)) { 6279 return value.replace(reEscape, item => escapeEntities[item]); 6280 } 6281 return value; 6282 } 6283 /** 6284 * Decodes all encoded entities 6285 * @param {string} value 6286 * @return {string} 6287 */ 6288 }, { 6289 key: "decode", 6290 value: function decode(value) { 6291 if (Type.isString(value)) { 6292 return value.replace(reUnescape, item => unescapeEntities[item]); 6293 } 6294 return value; 6295 } 6296 }, { 6297 key: "getRandom", 6298 value: function getRandom(length = 8) { 6299 // eslint-disable-next-line 6300 return [...Array(length)].map(() => (~~(Math.random() * 36)).toString(36)).join(''); 6301 } 6302 }, { 6303 key: "toNumber", 6304 value: function toNumber(value) { 6305 const parsedValue = Number.parseFloat(value); 6306 if (Type.isNumber(parsedValue)) { 6307 return parsedValue; 6308 } 6309 return 0; 6310 } 6311 }, { 6312 key: "toInteger", 6313 value: function toInteger(value) { 6314 return Text.toNumber(Number.parseInt(value, 10)); 6315 } 6316 }, { 6317 key: "toBoolean", 6318 value: function toBoolean(value, trueValues = []) { 6319 const transformedValue = Type.isString(value) ? value.toLowerCase() : value; 6320 return ['true', 'y', '1', 1, true, ...trueValues].includes(transformedValue); 6321 } 6322 }, { 6323 key: "toCamelCase", 6324 value: function toCamelCase(str) { 6325 if (!Type.isStringFilled(str)) { 6326 return str; 6327 } 6328 const regex = /[-_\s]+(.)?/g; 6329 if (!regex.test(str)) { 6330 return str.match(/^[A-Z]+$/) ? str.toLowerCase() : str[0].toLowerCase() + str.slice(1); 6331 } 6332 str = str.toLowerCase(); 6333 str = str.replace(regex, function (match, letter) { 6334 return letter ? letter.toUpperCase() : ''; 6335 }); 6336 return str[0].toLowerCase() + str.substr(1); 6337 } 6338 }, { 6339 key: "toPascalCase", 6340 value: function toPascalCase(str) { 6341 if (!Type.isStringFilled(str)) { 6342 return str; 6343 } 6344 return this.capitalize(this.toCamelCase(str)); 6345 } 6346 }, { 6347 key: "toKebabCase", 6348 value: function toKebabCase(str) { 6349 if (!Type.isStringFilled(str)) { 6350 return str; 6351 } 6352 const matches = str.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g); 6353 if (!matches) { 6354 return str; 6355 } 6356 return matches.map(x => x.toLowerCase()).join('-'); 6357 } 6358 }, { 6359 key: "capitalize", 6360 value: function capitalize(str) { 6361 if (!Type.isStringFilled(str)) { 6362 return str; 6363 } 6364 return str[0].toUpperCase() + str.substr(1); 6365 } 6366 }]); 6367 return Text; 6368 }(); 6369 6370 const aliases = { 6371 mousewheel: ['DOMMouseScroll'], 6372 bxchange: ['change', 'cut', 'paste', 'drop', 'keyup'], 6373 animationend: ['animationend', 'oAnimationEnd', 'webkitAnimationEnd', 'MSAnimationEnd'], 6374 transitionend: ['webkitTransitionEnd', 'otransitionend', 'oTransitionEnd', 'msTransitionEnd', 'transitionend'], 6375 fullscreenchange: ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange', 'MSFullscreenChange'], 6376 fullscreenerror: ['fullscreenerror', 'webkitfullscreenerror', 'mozfullscreenerror', 'MSFullscreenError'] 6377 }; 6378 6379 let Registry = /*#__PURE__*/function () { 6380 function Registry() { 6381 babelHelpers.classCallCheck(this, Registry); 6382 babelHelpers.defineProperty(this, "registry", new WeakMap()); 6383 } 6384 babelHelpers.createClass(Registry, [{ 6385 key: "set", 6386 value: function set(target, event, listener) { 6387 const events = this.get(target); 6388 if (!Type.isSet(events[event])) { 6389 events[event] = new Set(); 6390 } 6391 events[event].add(listener); 6392 this.registry.set(target, events); 6393 } 6394 }, { 6395 key: "get", 6396 value: function get(target) { 6397 return this.registry.get(target) || {}; 6398 } 6399 }, { 6400 key: "has", 6401 value: function has(target, event, listener) { 6402 if (event && listener) { 6403 return this.registry.has(target) && this.registry.get(target)[event].has(listener); 6404 } 6405 return this.registry.has(target); 6406 } 6407 }, { 6408 key: "delete", 6409 value: function _delete(target, event, listener) { 6410 if (!Type.isDomNode(target)) { 6411 return; 6412 } 6413 if (Type.isString(event) && Type.isFunction(listener)) { 6414 const events = this.registry.get(target); 6415 if (Type.isPlainObject(events) && Type.isSet(events[event])) { 6416 events[event].delete(listener); 6417 } 6418 return; 6419 } 6420 if (Type.isString(event)) { 6421 const events = this.registry.get(target); 6422 if (Type.isPlainObject(events) && Type.isSet(events[event])) { 6423 events[event] = new Set(); 6424 } 6425 return; 6426 } 6427 this.registry.delete(target); 6428 } 6429 }]); 6430 return Registry; 6431 }(); 6432 var registry = new Registry(); 6433 6434 function isOptionSupported(name) { 6435 let isSupported = false;
6436 try { 6437 const options = Object.defineProperty({}, name, { 6438 get() { 6439 isSupported = true; 6440 return undefined; 6441 } 6442 }); 6443 window.addEventListener('test', null, options); 6444 } 6445 // eslint-disable-next-line 6446 catch (err) {} 6447 return isSupported; 6448 } 6449 function fetchSupportedListenerOptions(options) { 6450 if (!Type.isPlainObject(options)) { 6451 return options; 6452 } 6453 return Object.keys(options).reduce((acc, name) => { 6454 if (isOptionSupported(name)) { 6455 acc[name] = options[name]; 6456 } 6457 return acc; 6458 }, {}); 6459 } 6460 6461 function bind(target, eventName, handler, options) { 6462 if (!Type.isObject(target) || !Type.isFunction(target.addEventListener)) { 6463 return; 6464 } 6465 const listenerOptions = fetchSupportedListenerOptions(options); 6466 if (eventName in aliases) { 6467 aliases[eventName].forEach(key => { 6468 target.addEventListener(key, handler, listenerOptions); 6469 registry.set(target, eventName, handler); 6470 }); 6471 return; 6472 } 6473 target.addEventListener(eventName, handler, listenerOptions); 6474 registry.set(target, eventName, handler); 6475 } 6476 6477 function unbind(target, eventName, handler, options) { 6478 if (!Type.isObject(target) || !Type.isFunction(target.removeEventListener)) { 6479 return; 6480 } 6481 const listenerOptions = fetchSupportedListenerOptions(options); 6482 if (eventName in aliases) { 6483 aliases[eventName].forEach(key => { 6484 target.removeEventListener(key, handler, listenerOptions); 6485 registry.delete(target, key, handler); 6486 }); 6487 return; 6488 } 6489 target.removeEventListener(eventName, handler, listenerOptions); 6490 registry.delete(target, eventName, handler); 6491 } 6492 6493 function unbindAll(target, eventName) { 6494 const events = registry.get(target); 6495 Object.keys(events).forEach(currentEvent => { 6496 events[currentEvent].forEach(handler => { 6497 if (!Type.isString(eventName) || eventName === currentEvent) { 6498 unbind(target, currentEvent, handler); 6499 } 6500 }); 6501 }); 6502 } 6503 6504 function bindOnce(target, eventName, handler, options) { 6505 const once = function once(...args) { 6506 unbind(target, eventName, once, options); 6507 handler(...args); 6508 }; 6509 bind(target, eventName, once, options); 6510 } 6511 6512 // eslint-disable-next-line 6513 let debugState = true; 6514 function enableDebug() { 6515 debugState = true; 6516 } 6517 function disableDebug() { 6518 debugState = false; 6519 } 6520 function isDebugEnabled() { 6521 return debugState; 6522 } 6523 function debug(...args) { 6524 if (isDebugEnabled() && Type.isObject(window.console)) { 6525 if (Type.isFunction(window.console.log)) { 6526 window.console.log('BX.debug: ', args.length > 0 ? args : args[0]); 6527 if (args[0] instanceof Error && args[0].stack) { 6528 window.console.log('BX.debug error stack trace', args[0].stack); 6529 } 6530 } 6531 if (Type.isFunction(window.console.trace)) { 6532 // eslint-disable-next-line 6533 console.trace(); 6534 } 6535 } 6536 } 6537 6538 var debugNs = /*#__PURE__*/Object.freeze({ 6539 get debugState () { return debugState; }, 6540 enableDebug: enableDebug, 6541 disableDebug: disableDebug, 6542 isDebugEnabled: isDebugEnabled, 6543 default: debug 6544 }); 6545 6546 function fetchExtensionSettings(html) { 6547 if (Type.isStringFilled(html)) { 6548 const scripts = html.match(/<script type="extension\/settings" \b[^>]*>([\s\S]*?)<\/script>/g); 6549 if (Type.isArrayFilled(scripts)) { 6550 return scripts.map(script => { 6551 const [, extension] = script.match(/data-extension="(.[a-z0-9_.-]+)"/); 6552 return { 6553 extension, 6554 script 6555 }; 6556 }); 6557 } 6558 } 6559 return []; 6560 } 6561 6562 let Extension = /*#__PURE__*/function () { 6563 function Extension(options) { 6564 babelHelpers.classCallCheck(this, Extension); 6565 this.config = options.config || {}; 6566 this.name = options.extension; 6567 this.state = 'scheduled'; 6568 6569 // eslint-disable-next-line 6570 const result = BX.processHTML(options.html || ''); 6571 this.inlineScripts = result.SCRIPT.reduce(inlineScripts, []); 6572 this.externalScripts = result.SCRIPT.reduce(externalScripts, []); 6573 this.externalStyles = result.STYLE.reduce(externalStyles, []); 6574 this.settingsScripts = fetchExtensionSettings(result.HTML); 6575 } 6576 babelHelpers.createClass(Extension, [{ 6577 key: "load", 6578 value: function load() { 6579 if (this.state === 'error') { 6580 this.loadPromise = this.loadPromise || Promise.resolve(this); 6581 console.warn('Extension', this.name, 'not found'); 6582 } 6583 if (!this.loadPromise && this.state) { 6584 this.state = 'load';
6585 this.settingsScripts.forEach(entry => { 6586 const isLoaded = !!document.querySelector(`script[data-extension="${entry.extension}"]`); 6587 if (!isLoaded) { 6588 document.body.insertAdjacentHTML('beforeend', entry.script); 6589 } 6590 }); 6591 this.inlineScripts.forEach(BX.evalGlobal); 6592 this.loadPromise = Promise.all([loadAll(this.externalScripts), loadAll(this.externalStyles)]).then(() => { 6593 this.state = 'loaded'; 6594 if (Type.isPlainObject(this.config) && this.config.namespace) { 6595 return Reflection.getClass(this.config.namespace); 6596 } 6597 return window; 6598 }); 6599 } 6600 return this.loadPromise; 6601 } 6602 }]); 6603 return Extension; 6604 }(); 6605 6606 const initialized = {}; 6607 const ajaxController = 'main.bitrix.main.controller.loadext.getextensions'; 6608 6609 function makeIterable(value) { 6610 return Type.isArray(value) ? value : [value]; 6611 } 6612 function isInitialized(extension) { 6613 return extension in initialized; 6614 } 6615 function getInitialized(extension) { 6616 return initialized[extension]; 6617 } 6618 function isAllInitialized(extensions) { 6619 return extensions.every(isInitialized); 6620 } 6621 function loadExtensions(extensions) { 6622 return Promise.all(extensions.map(item => item.load())); 6623 } 6624 function mergeExports(exports) { 6625 return exports.reduce((acc, currentExports) => { 6626 if (Type.isObject(currentExports)) { 6627 return { 6628 ...currentExports 6629 }; 6630 } 6631 return currentExports; 6632 }, {}); 6633 } 6634 function inlineScripts(acc, item) { 6635 if (item.isInternal) { 6636 acc.push(item.JS); 6637 } 6638 return acc; 6639 } 6640 function externalScripts(acc, item) { 6641 if (!item.isInternal) { 6642 acc.push(item.JS); 6643 } 6644 return acc; 6645 } 6646 function externalStyles(acc, item) { 6647 if (Type.isString(item) && item !== '') { 6648 acc.push(item); 6649 } 6650 return acc; 6651 } 6652 function request(options) { 6653 return new Promise(resolve => { 6654 // eslint-disable-next-line 6655 BX.ajax.runAction(ajaxController, { 6656 data: options 6657 }).then(resolve); 6658 }); 6659 } 6660 function prepareExtensions(response) { 6661 if (response.status !== 'success') { 6662 response.errors.map(console.warn); 6663 return []; 6664 } 6665 return response.data.map(item => { 6666 const initializedExtension = getInitialized(item.extension); 6667 if (initializedExtension) { 6668 return initializedExtension; 6669 } 6670 initialized[item.extension] = new Extension(item); 6671 return initialized[item.extension]; 6672 }); 6673 } 6674 function loadAll(items) { 6675 const itemsList = makeIterable(items); 6676 if (!itemsList.length) { 6677 return Promise.resolve(); 6678 } 6679 return new Promise(resolve => { 6680 // eslint-disable-next-line 6681 BX.load(itemsList, resolve); 6682 }); 6683 } 6684 6685 /** 6686 * Loads extensions asynchronously 6687 * @param {string|Array<string>} extension 6688 * @return {Promise<Array<Extension>>} 6689 */ 6690 function loadExtension(extension) { 6691 const extensions = makeIterable(extension); 6692 const isAllInitialized$$1 = isAllInitialized(extensions); 6693 if (isAllInitialized$$1) { 6694 const initializedExtensions = extensions.map(getInitialized); 6695 return loadExtensions(initializedExtensions).then(mergeExports); 6696 } 6697 return request({ 6698 extension: extensions 6699 }).then(prepareExtensions).then(loadExtensions).then(mergeExports); 6700 } 6701 6702 const 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]']; 6703 function isCloneable(value) { 6704 const isCloneableValue = Type.isObjectLike(value) && cloneableTags.includes(getTag(value)); 6705 return isCloneableValue || Type.isDomNode(value); 6706 } 6707 function internalClone(value, map) { 6708 if (map.has(value)) { 6709 return map.get(value); 6710 } 6711 if (isCloneable(value)) { 6712 if (Type.isArray(value)) { 6713 const cloned = Array.from(value); 6714 map.set(value, cloned); 6715 value.forEach((item, index) => { 6716 cloned[index] = internalClone(item, map); 6717 }); 6718 return map.get(value); 6719 } 6720 if (Type.isDomNode(value)) { 6721 return value.cloneNode(true); 6722 } 6723 if (Type.isMap(value)) { 6724 const result = new Map(); 6725 map.set(value, result); 6726 value.forEach((item, key) => { 6727 result.set(internalClone(key, map), internalClone(item, map)); 6728 }); 6729 return result; 6730 } 6731 if (Type.isSet(value)) { 6732 const result = new Set(); 6733 map.set(value, result); 6734 value.forEach(item => { 6735 result.add(internalClone(item, map)); 6736 }); 6737 return result; 6738 } 6739 if (Type.isDate(value)) { 6740 return new Date(value); 6741 } 6742 if (Type.isRegExp(value)) { 6743 const regExpFlags = /\w*$/; 6744 const flags = regExpFlags.exec(value); 6745 let result = new RegExp(value.source); 6746 if (flags && Type.isArray(flags)) { 6747 result = new RegExp(value.source, flags[0]); 6748 } 6749 result.lastIndex = value.lastIndex; 6750 return result; 6751 } 6752 const proto = Object.getPrototypeOf(value); 6753 const result = Object.assign(Object.create(proto), value); 6754 map.set(value, result); 6755 Object.keys(value).forEach(key => { 6756 result[key] = internalClone(value[key], map); 6757 }); 6758 return result; 6759 } 6760 return value; 6761 } 6762 6763 /** 6764 * Clones any cloneable object 6765 * @param value 6766 * @return {*} 6767 */ 6768 function clone(value) { 6769 return internalClone(value, new WeakMap()); 6770 } 6771 6772 function merge(current, target) { 6773 return Object.entries(target).reduce((acc, [key, value]) => { 6774 if (!Type.isDomNode(acc[key]) && Type.isObjectLike(acc[key]) && Type.isObjectLike(value)) { 6775 acc[key] = merge(acc[key], value); 6776 return acc; 6777 } 6778 acc[key] = value; 6779 return acc; 6780 }, current); 6781 } 6782 6783 function createComparator(fields, orders = []) { 6784 return (a, b) => { 6785 const field = fields[0]; 6786 const order = orders[0] || 'asc'; 6787 if (Type.isUndefined(field)) { 6788 return 0; 6789 } 6790 let valueA = a[field]; 6791 let valueB = b[field]; 6792 if (Type.isString(valueA) && Type.isString(valueB)) { 6793 valueA = valueA.toLowerCase(); 6794 valueB = valueB.toLowerCase(); 6795 } 6796 if (valueA < valueB) { 6797 return order === 'asc' ? -1 : 1; 6798 } 6799 if (valueA > valueB) { 6800 return order === 'asc' ? 1 : -1; 6801 } 6802 return createComparator(fields.slice(1), orders.slice(1))(a, b); 6803 }; 6804 } 6805 6806 /** 6807 * @memberOf BX 6808 */ 6809 let Runtime = /*#__PURE__*/function () { 6810 function Runtime() { 6811 babelHelpers.classCallCheck(this, Runtime); 6812 } 6813 babelHelpers.createClass(Runtime, null, [{ 6814 key: "debounce", 6815 value: function debounce(func, wait = 0, context = null) { 6816 let timeoutId; 6817 return function debounced(...args) { 6818 if (Type.isNumber(timeoutId)) { 6819 clearTimeout(timeoutId); 6820 } 6821 timeoutId = setTimeout(() => { 6822 func.apply(context || this, args); 6823 }, wait); 6824 }; 6825 } 6826 }, { 6827 key: "throttle", 6828 value: function throttle(func, wait = 0, context = null) { 6829 let timer = 0; 6830 let invoke; 6831 return function wrapper(...args) { 6832 invoke = true; 6833 if (!timer) { 6834 const q = function q() { 6835 if (invoke) { 6836 func.apply(context || this, args); 6837 invoke = false;
6838 timer = setTimeout(q, wait); 6839 } else { 6840 timer = null; 6841 } 6842 }; 6843 q(); 6844 } 6845 }; 6846 } 6847 }, { 6848 key: "html", 6849 value: function html(node, _html, params = {}) { 6850 if (Type.isNil(_html) && Type.isDomNode(node)) { 6851 return node.innerHTML; 6852 } 6853 6854 // eslint-disable-next-line 6855 const parsedHtml = BX.processHTML(_html); 6856 const externalCss = parsedHtml.STYLE.reduce(externalStyles, []); 6857 const externalJs = parsedHtml.SCRIPT.reduce(externalScripts, []); 6858 const inlineJs = parsedHtml.SCRIPT.reduce(inlineScripts, []); 6859 if (Type.isDomNode(node)) { 6860 if (params.htmlFirst || !externalJs.length && !externalCss.length) { 6861 if (params.useAdjacentHTML) { 6862 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 6863 } else { 6864 node.innerHTML = parsedHtml.HTML; 6865 } 6866 } 6867 } 6868 return Promise.all([loadAll(externalJs), loadAll(externalCss)]).then(() => { 6869 if (Type.isDomNode(node) && (externalJs.length > 0 || externalCss.length > 0)) { 6870 if (params.useAdjacentHTML) { 6871 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 6872 } else { 6873 node.innerHTML = parsedHtml.HTML; 6874 } 6875 } 6876 6877 // eslint-disable-next-line 6878 inlineJs.forEach(script => BX.evalGlobal(script)); 6879 if (Type.isFunction(params.callback)) { 6880 params.callback(); 6881 } 6882 }); 6883 } 6884 /** 6885 * Merges objects or arrays 6886 * @param targets 6887 * @return {any} 6888 */ 6889 }, { 6890 key: "merge", 6891 value: function merge$$1(...targets) { 6892 if (Type.isArray(targets[0])) { 6893 targets.unshift([]); 6894 } else if (Type.isObject(targets[0])) { 6895 targets.unshift({}); 6896 } 6897 return targets.reduce((acc, item) => { 6898 return merge(acc, item); 6899 }, targets[0]); 6900 } 6901 }, { 6902 key: "orderBy", 6903 value: function orderBy(collection, fields = [], orders = []) { 6904 const comparator = createComparator(fields, orders); 6905 return Object.values(collection).sort(comparator); 6906 } 6907 }, { 6908 key: "destroy", 6909 value: function destroy(target, errorMessage = 'Object is destroyed') { 6910 if (Type.isObject(target)) { 6911 const onPropertyAccess = () => { 6912 throw new Error(errorMessage); 6913 }; 6914 const ownProperties = Object.keys(target); 6915 const prototypeProperties = (() => { 6916 const targetPrototype = Object.getPrototypeOf(target); 6917 if (Type.isObject(targetPrototype)) { 6918 return Object.getOwnPropertyNames(targetPrototype); 6919 } 6920 return []; 6921 })(); 6922 const uniquePropertiesList = [...new Set([...ownProperties, ...prototypeProperties])]; 6923 uniquePropertiesList.filter(name => { 6924 const descriptor = Object.getOwnPropertyDescriptor(target, name); 6925 return !/__(.+)__/.test(name) && (!Type.isObject(descriptor) || descriptor.configurable === true); 6926 }
6926).forEach(name => { 6927 Object.defineProperty(target, name, { 6928 get: onPropertyAccess, 6929 set: onPropertyAccess, 6930 configurable: false 6931 }); 6932 }); 6933 Object.setPrototypeOf(target, null); 6934 } 6935 } 6936 }]); 6937 return Runtime; 6938 }(); 6939 babelHelpers.defineProperty(Runtime, "debug", debug); 6940 babelHelpers.defineProperty(Runtime, "loadExtension", loadExtension); 6941 babelHelpers.defineProperty(Runtime, "clone", clone); 6942 6943 const _isError = Symbol.for('BX.BaseError.isError'); 6944 6945 /** 6946 * @memberOf BX 6947 */ 6948 let BaseError = /*#__PURE__*/function () { 6949 function BaseError(message, code, customData) { 6950 babelHelpers.classCallCheck(this, BaseError); 6951 this[_isError] = true; 6952 this.message = ''; 6953 this.code = null; 6954 this.customData = null; 6955 this.setMessage(message); 6956 this.setCode(code); 6957 this.setCustomData(customData); 6958 } 6959 6960 /** 6961 * Returns a brief description of the error 6962 * @returns {string} 6963 */ 6964 babelHelpers.createClass(BaseError, [{ 6965 key: "getMessage", 6966 value: function getMessage() { 6967 return this.message; 6968 } 6969 /** 6970 * Sets a message of the error 6971 * @param {string} message 6972 * @returns {this} 6973 */ 6974 }, { 6975 key: "setMessage", 6976 value: function setMessage(message) { 6977 if (Type.isString(message)) { 6978 this.message = message; 6979 } 6980 return this; 6981 } 6982 /** 6983 * Returns a code of the error 6984 * @returns {?string} 6985 */ 6986 }, { 6987 key: "getCode", 6988 value: function getCode() { 6989 return this.code; 6990 } 6991 /** 6992 * Sets a code of the error 6993 * @param {string} code 6994 * @returns {this} 6995 */ 6996 }, { 6997 key: "setCode", 6998 value: function setCode(code) { 6999 if (Type.isStringFilled(code) || code === null) { 7000 this.code = code; 7001 } 7002 return this; 7003 } 7004 /** 7005 * Returns custom data of the error 7006 * @returns {null|*} 7007 */ 7008 }, { 7009 key: "getCustomData", 7010 value: function getCustomData() { 7011 return this.customData; 7012 } 7013 /** 7014 * Sets custom data of the error 7015 * @returns {this} 7016 */ 7017 }, { 7018 key: "setCustomData", 7019 value: function setCustomData(customData) { 7020 if (!Type.isUndefined(customData)) { 7021 this.customData = customData; 7022 } 7023 return this; 7024 } 7025 }, { 7026 key: "toString", 7027 value: function toString() { 7028 const code = this.getCode(); 7029 const message = this.getMessage(); 7030 if (!Type.isStringFilled(code) && !Type.isStringFilled(message)) { 7031 return ''; 7032 } else if (!Type.isStringFilled(code)) { 7033 return `Error: ${message}`; 7034 } else if (!Type.isStringFilled(message)) { 7035 return code; 7036 } else { 7037 return `${code}: ${message}`; 7038 } 7039 } 7040 /** 7041 * Returns true if the object is an instance of BaseError 7042 * @param error 7043 * @returns {boolean} 7044 */ 7045 }], [{ 7046 key: "isError", 7047 value: function isError(error) { 7048 return Type.isObject(error) && error[_isError] === true; 7049 } 7050 }]); 7051 return BaseError; 7052 }(); 7053 7054 /** 7055 * Implements base event object interface 7056 */ 7057 let BaseEvent = /*#__PURE__*/function () { 7058 function BaseEvent(options = { 7059 data: {} 7060 }) { 7061 babelHelpers.classCallCheck(this, BaseEvent); 7062 this.type = ''; 7063 this.data = null; 7064 this.target = null; 7065 this.compatData = null; 7066 this.defaultPrevented = false; 7067 this.immediatePropagationStopped = false; 7068 this.errors = []; 7069 this.setData(options.data); 7070 this.setCompatData(options.compatData); 7071 } 7072 babelHelpers.createClass(BaseEvent, [{ 7073 key: "getType", 7074 /** 7075 * Returns the name of the event 7076 * @returns {string} 7077 */ 7078 value: function getType() { 7079 return this.type; 7080 } 7081 /** 7082 * 7083 * @param {string} type 7084 */ 7085 }, { 7086 key: "setType", 7087 value: function setType(type) { 7088 if (Type.isStringFilled(type)) { 7089 this.type = type; 7090 } 7091 return this; 7092 } 7093 /** 7094 * Returns an event data 7095 */ 7096 }, { 7097 key: "getData", 7098 value: function getData() { 7099 return this.data; 7100 } 7101 /** 7102 * Sets an event data 7103 * @param data 7104 */ 7105 }, { 7106 key: "setData", 7107 value: function setData(data) { 7108 if (!Type.isUndefined(data)) { 7109 this.data = data; 7110 } 7111 return this; 7112 } 7113 /** 7114 * Returns arguments for BX.addCustomEvent handlers (deprecated). 7115 * @returns {array | null} 7116 */ 7117 }, { 7118 key: "getCompatData", 7119 value: function getCompatData() { 7120 return this.compatData; 7121 } 7122 /** 7123 * Sets arguments for BX.addCustomEvent handlers (deprecated) 7124 * @param data 7125 */ 7126 }, { 7127 key: "setCompatData", 7128 value: function setCompatData(data) { 7129 if (Type.isArrayLike(data)) { 7130 this.compatData = data; 7131 } 7132 return this; 7133 } 7134 /** 7135 * Sets a event target 7136 * @param target 7137 */ 7138 }, { 7139 key: "setTarget", 7140 value: function setTarget(target) { 7141 this.target = target; 7142 return this; 7143 } 7144 /** 7145 * Returns a event target 7146 */ 7147 }, { 7148 key: "getTarget", 7149 value: function getTarget() { 7150 return this.target; 7151 } 7152 /** 7153 * Returns an array of event errors 7154 * @returns {[]} 7155 */ 7156 }, { 7157 key: "getErrors", 7158 value: function getErrors() { 7159 return this.errors; 7160 } 7161 /** 7162 * Adds an error of the event. 7163 * Event listeners can prevent emitter's default action and set the reason of this behavior. 7164 * @param error 7165 */ 7166 }, { 7167 key: "setError", 7168 value: function setError(error) { 7169 if (BaseError.isError(error)) { 7170 this.errors.push(error); 7171 } 7172 } 7173 /** 7174 * Prevents default action 7175 */ 7176 }, { 7177 key: "preventDefault", 7178 value: function preventDefault() { 7179 this.defaultPrevented = true; 7180 } 7181 /** 7182 * Checks that is default action prevented 7183 * @return {boolean} 7184 */ 7185 }, { 7186 key: "isDefaultPrevented", 7187 value: function isDefaultPrevented() { 7188 return this.defaultPrevented; 7189 } 7190 /** 7191 * Stops event immediate propagation 7192 */ 7193 }, { 7194 key: "stopImmediatePropagation", 7195 value: function stopImmediatePropagation() { 7196 this.immediatePropagationStopped = true; 7197 } 7198 /** 7199 * Checks that is immediate propagation stopped 7200 * @return {boolean} 7201 */ 7202 }, { 7203 key: "isImmediatePropagationStopped", 7204 value: function isImmediatePropagationStopped() { 7205 return this.immediatePropagationStopped; 7206 } 7207 }], [{ 7208 key: "create", 7209 value: function create(options) { 7210 return new this(options); 7211 } 7212 }]); 7213 return BaseEvent; 7214 }(); 7215 7216 let EventStore = /*#__PURE__*/function () { 7217 function EventStore(options = {}) { 7218 babelHelpers.classCallCheck(this, EventStore); 7219 this.defaultMaxListeners = Type.isNumber(options.defaultMaxListeners) ? options.defaultMaxListeners : 10; 7220 this.eventStore = new WeakMap(); 7221 } 7222 babelHelpers.createClass(EventStore, [{ 7223 key: "add", 7224 value: function add(target, options = {}) { 7225 const record = this.getRecordScheme(); 7226 if (Type.isNumber(options.maxListeners)) { 7227 record.maxListeners = options.maxListeners; 7228 } 7229 this.eventStore.set(target, record); 7230 return record; 7231 } 7232 }, { 7233 key: "get", 7234 value: function get(target) { 7235 return this.eventStore.get(target); 7236 } 7237 }, { 7238 key: "getOrAdd", 7239 value: function getOrAdd(target, options = {}) { 7240 return this.get(target) || this.add(target, options); 7241 } 7242 }, { 7243 key: "delete", 7244 value: function _delete(context) { 7245 this.eventStore.delete(context); 7246 } 7247 }, { 7248 key: "getRecordScheme", 7249 value: function getRecordScheme() { 7250 return { 7251 eventsMap: new Map(), 7252 onceMap: new Map(), 7253 maxListeners: this.getDefaultMaxListeners(), 7254 eventsMaxListeners: new Map() 7255 }; 7256 } 7257 }, { 7258 key: "getDefaultMaxListeners", 7259 value: function getDefaultMaxListeners() { 7260 return this.defaultMaxListeners; 7261 } 7262 }]); 7263 return EventStore; 7264 }(); 7265 7266 let WarningStore = /*#__PURE__*/function () {
7267 function WarningStore() { 7268 babelHelpers.classCallCheck(this, WarningStore); 7269 this.warnings = new Map(); 7270 this.printDelayed = Runtime.debounce(this.print.bind(this), 500); 7271 } 7272 babelHelpers.createClass(WarningStore, [{ 7273 key: "add", 7274 value: function add(target, eventName, listeners) { 7275 let contextWarnings = this.warnings.get(target); 7276 if (!contextWarnings) { 7277 contextWarnings = Object.create(null); 7278 this.warnings.set(target, contextWarnings); 7279 } 7280 if (!contextWarnings[eventName]) { 7281 contextWarnings[eventName] = {}; 7282 } 7283 contextWarnings[eventName].size = listeners.size; 7284 if (!Type.isArray(contextWarnings[eventName].errors)) { 7285 contextWarnings[eventName].errors = []; 7286 } 7287 contextWarnings[eventName].errors.push(new Error()); 7288 } 7289 }, { 7290 key: "print", 7291 value: function print() { 7292 this.warnings.forEach(warnings => { 7293 for (let eventName in warnings) { 7294 console.groupCollapsed('Possible BX.Event.EventEmitter memory leak detected. ' + warnings[eventName].size + ' "' + eventName + '" listeners added. ' + 'Use emitter.setMaxListeners() to increase limit.'); 7295 console.dir(warnings[eventName].errors); 7296 console.groupEnd(); 7297 } 7298 }); 7299 this.clear(); 7300 } 7301 }, { 7302 key: "clear", 7303 value: function clear() { 7304 this.warnings.clear(); 7305 } 7306 }, { 7307 key: "printDelayed", 7308 value: function printDelayed() {} 7309 }]); 7310 return WarningStore; 7311 }(); 7312 7313 const eventStore = new EventStore({ 7314 defaultMaxListeners: 10 7315 }); 7316 const warningStore = new WarningStore(); 7317 const aliasStore = new Map(); 7318 const globalTarget = { 7319 GLOBAL_TARGET: 'GLOBAL_TARGET' // this key only for debugging purposes 7320 }; 7321 7322 eventStore.add(globalTarget, { 7323 maxListeners: 25 7324 }); 7325 const isEmitterProperty = Symbol.for('BX.Event.EventEmitter.isEmitter'); 7326 const namespaceProperty = Symbol('namespaceProperty'); 7327 const targetProperty = Symbol('targetProperty'); 7328 let EventEmitter = /*#__PURE__*/function () { 7329 /** @private */ 7330 7331 function EventEmitter(...args) { 7332 babelHelpers.classCallCheck(this, EventEmitter); 7333 this[targetProperty] = null; 7334 this[namespaceProperty] = null; 7335 this[isEmitterProperty] = true; 7336 let target = this; 7337 if (Object.getPrototypeOf(this) === EventEmitter.prototype && args.length > 0) 7338 //new EventEmitter(obj) case 7339 { 7340 if (!Type.isObject(args[0])) { 7341 throw new TypeError(`The "target" argument must be an object.`); 7342 } 7343 target = args[0]; 7344 this.setEventNamespace(args[1]); 7345 } 7346 this[targetProperty] = target; 7347 } 7348 7349 /** 7350 * Makes a target observable 7351 * @param {object} target 7352 * @param {string} namespace 7353 */ 7354 babelHelpers.createClass(EventEmitter, [{ 7355 key: "setEventNamespace", 7356 value: function setEventNamespace(namespace) { 7357 if (Type.isStringFilled(namespace)) { 7358 this[namespaceProperty] = namespace; 7359 } 7360 } 7361 }, { 7362 key: "getEventNamespace", 7363 value: function getEventNamespace() { 7364 return this[namespaceProperty]; 7365 } 7366 /** 7367 * Subscribes listener on specified global event 7368 * @param {object} target 7369 * @param {string} eventName 7370 * @param {Function<BaseEvent>} listener 7371 * @param {object} options 7372 */ 7373 }, { 7374 key: "subscribe", 7375 /** 7376 * Subscribes a listener on a specified event 7377 * @param {string} eventName 7378 * @param {Function<BaseEvent>} listener 7379 * @return {this} 7380 */ 7381 value: function subscribe(eventName, listener) { 7382 EventEmitter.subscribe(this, eventName, listener); 7383 return this; 7384 } 7385 /** 7386 * 7387 * @param {object} options 7388 * @param {object} [aliases] 7389 * @param {boolean} [compatMode=false] 7390 */ 7391 }, { 7392 key: "subscribeFromOptions", 7393 value: function subscribeFromOptions(options, aliases, compatMode) { 7394 if (!Type.isPlainObject(options)) { 7395 return; 7396 } 7397 aliases = Type.isPlainObject(aliases) ? EventEmitter.normalizeAliases(aliases) : {};
7398 Object.keys(options).forEach(eventName => { 7399 const listener = EventEmitter.normalizeListener(options[eventName]); 7400 eventName = EventEmitter.normalizeEventName(eventName); 7401 if (aliases[eventName]) { 7402 const { 7403 eventName: actualName 7404 } = aliases[eventName]; 7405 EventEmitter.subscribe(this, actualName, listener, { 7406 compatMode: compatMode !== false 7407 }); 7408 } else { 7409 EventEmitter.subscribe(this, eventName, listener, { 7410 compatMode: compatMode === true 7411 }); 7412 } 7413 }); 7414 } 7415 /** 7416 * Subscribes a listener that is called at 7417 * most once for a specified event. 7418 * @param {object} target 7419 * @param {string} eventName 7420 * @param {Function<BaseEvent>} listener 7421 */ 7422 }, { 7423 key: "subscribeOnce", 7424 /** 7425 * Subscribes a listener that is called at most once for a specified event. 7426 * @param {string} eventName 7427 * @param {Function<BaseEvent>} listener 7428 * @return {this} 7429 */ 7430 value: function subscribeOnce(eventName, listener) { 7431 EventEmitter.subscribeOnce(this, eventName, listener); 7432 return this; 7433 } 7434 /** 7435 * Unsubscribes an event listener 7436 * @param {object} target 7437 * @param {string} eventName 7438 * @param {Function<BaseEvent>} listener 7439 * @param options 7440 */ 7441 }, { 7442 key: "unsubscribe", 7443 /** 7444 * Unsubscribes an event listener 7445 * @param {string} eventName 7446 * @param {Function<BaseEvent>} listener 7447 * @return {this} 7448 */ 7449 value: function unsubscribe(eventName, listener) { 7450 EventEmitter.unsubscribe(this, eventName, listener); 7451 return this; 7452 } 7453 /** 7454 * Unsubscribes all event listeners 7455 * @param {object} target 7456 * @param {string} eventName 7457 * @param options 7458 */ 7459 }, { 7460 key: "unsubscribeAll", 7461 /** 7462 * Unsubscribes all event listeners 7463 * @param {string} [eventName] 7464 */ 7465 value: function unsubscribeAll(eventName) { 7466 EventEmitter.unsubscribeAll(this, eventName); 7467 } 7468 /** 7469 * 7470 * @param {object} target 7471 * @param {string} eventName 7472 * @param {BaseEvent | any} event 7473 * @param {object} options 7474 * @returns {Array} 7475 */ 7476 }, { 7477 key: "emit", 7478 /** 7479 * Emits specified event with specified event object 7480 * @param {string} eventName 7481 * @param {BaseEvent | any} event 7482 * @return {this} 7483 */ 7484 value: function emit(eventName, event) { 7485 if (this.getEventNamespace() === null) { 7486 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7487 } 7488 EventEmitter.emit(this, eventName, event); 7489 return this; 7490 } 7491 /** 7492 * Emits global event and returns a promise that is resolved when 7493 * all promise returned from event handlers are resolved, 7494 * or rejected when at least one of the returned promise is rejected. 7495 * Importantly. You can return any value from synchronous handlers, not just promise 7496 * @param {object} target 7497 * @param {string} eventName 7498 * @param {BaseEvent | any} event 7499 * @return {Promise<Array>} 7500 */ 7501 }, { 7502 key: "emitAsync", 7503 /** 7504 * Emits event and returns a promise that is resolved when 7505 * all promise returned from event handlers are resolved, 7506 * or rejected when at least one of the returned promise is rejected. 7507 * Importantly. You can return any value from synchronous handlers, not just promise 7508 * @param {string} eventName 7509 * @param {BaseEvent|any} event 7510 * @return {Promise<Array>} 7511 */ 7512 value: function emitAsync(eventName, event) { 7513 if (this.getEventNamespace() === null) { 7514 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7515 } 7516 return EventEmitter.emitAsync(this, eventName, event); 7517 } 7518 /** 7519 * @private 7520 * @param {object} target 7521 * @param {string} eventName 7522 * @param {BaseEvent|any} event 7523 * @returns {BaseEvent} 7524 */ 7525 }, { 7526 key: "setMaxListeners", 7527 /** 7528 * Sets max events listeners count 7529 * this.setMaxListeners(10) - sets the default value for all events
7530 * this.setMaxListeners("onClose", 10) sets the value for onClose event 7531 * @return {this} 7532 * @param args 7533 */ 7534 value: function setMaxListeners(...args) { 7535 EventEmitter.setMaxListeners(this, ...args); 7536 return this; 7537 } 7538 /** 7539 * Returns max event listeners count 7540 * @param {object} target 7541 * @param {string} [eventName] 7542 * @returns {number} 7543 */ 7544 }, { 7545 key: "getMaxListeners", 7546 /** 7547 * Returns max event listeners count 7548 * @param {string} [eventName] 7549 * @returns {number} 7550 */ 7551 value: function getMaxListeners(eventName) { 7552 return EventEmitter.getMaxListeners(this, eventName); 7553 } 7554 /** 7555 * Adds or subtracts max listeners count 7556 * Event.EventEmitter.addMaxListeners() - adds one max listener for all events of global target 7557 * Event.EventEmitter.addMaxListeners(3) - adds three max listeners for all events of global target 7558 * Event.EventEmitter.addMaxListeners(-1) - subtracts one max listener for all events of global target 7559 * Event.EventEmitter.addMaxListeners('onClose') - adds one max listener for onClose event of global target 7560 * Event.EventEmitter.addMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 7561 * Event.EventEmitter.addMaxListeners('onClose', -1) - subtracts one max listener for onClose event of global target 7562 * 7563 * Event.EventEmitter.addMaxListeners(obj) - adds one max listener for all events of 'obj' target 7564 * Event.EventEmitter.addMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 7565 * Event.EventEmitter.addMaxListeners(obj, -1) - subtracts one max listener for all events of 'obj' target 7566 * Event.EventEmitter.addMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 7567 * Event.EventEmitter.addMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 7568 * Event.EventEmitter.addMaxListeners(obj, 'onClose', -1) - subtracts one max listener for onClose event of 'obj' target 7569 * @param args 7570 * @returns {number} 7571 */ 7572 }, { 7573 key: "incrementMaxListeners", 7574 /** 7575 * Increases max listeners count 7576 * this.incrementMaxListeners() - adds one max listener for all events 7577 * this.incrementMaxListeners(3) - adds three max listeners for all events 7578 * this.incrementMaxListeners('onClose') - adds one max listener for onClose event 7579 * this.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event 7580 */ 7581 value: function incrementMaxListeners(...args) { 7582 return EventEmitter.incrementMaxListeners(this, ...args); 7583 } 7584 /** 7585 * Decreases max listeners count 7586 * 7587 * Event.EventEmitter.decrementMaxListeners() - subtracts one max listener for all events of global target 7588 * Event.EventEmitter.decrementMaxListeners(3) - subtracts three max listeners for all events of global target 7589 * Event.EventEmitter.decrementMaxListeners('onClose') - subtracts one max listener for onClose event of global target 7590 * Event.EventEmitter.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event of global target 7591 * 7592 * Event.EventEmitter.decrementMaxListeners(obj) - subtracts one max listener for all events of 'obj' target 7593 * Event.EventEmitter.decrementMaxListeners(obj, 3) - subtracts three max listeners for all events of 'obj' target 7594 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose') - subtracts one max listener for onClose event of 'obj' target 7595 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose', 2) - subtracts two max listeners for onClose event of 'obj' target 7596 */ 7597 }, { 7598 key: "decrementMaxListeners", 7599 /** 7600 * Increases max listeners count 7601 * this.decrementMaxListeners() - subtracts one max listener for all events 7602 * this.decrementMaxListeners(3) - subtracts three max listeners for all events 7603 * this.decrementMaxListeners('onClose') - subtracts one max listener for onClose event 7604 * this.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event 7605 */ 7606 value: function decrementMaxListeners(...args) { 7607 return EventEmitter.decrementMaxListeners(this, ...args); 7608 } 7609 /** 7610 * @private 7611 * @param {Array} args 7612 * @returns Array 7613 */ 7614 }, { 7615 key: "getListeners", 7616 /** 7617 * Gets listeners list for specified event 7618 * @param {string} eventName 7619 */ 7620 value: function getListeners(eventName) { 7621 return EventEmitter.getListeners(this, eventName); 7622 } 7623 /** 7624 * Returns a full event name with namespace 7625 * @param {string} eventName 7626 * @returns {string} 7627 */ 7628 }, { 7629 key: "getFullEventName", 7630 value: function getFullEventName(eventName) { 7631 if (!Type.isStringFilled(eventName)) { 7632 throw new TypeError(`The "eventName" argument must be a string.`); 7633 } 7634 return EventEmitter.makeFullEventName(this.getEventNamespace(), eventName); 7635 } 7636 /** 7637 * Registers aliases (old event names for BX.onCustomEvent) 7638 * @param aliases 7639 */ 7640 }], [{ 7641 key: "makeObservable", 7642 value: function makeObservable(target, namespace) { 7643 if (!Type.isObject(target)) { 7644 throw new TypeError('The "target" argument must be an object.'); 7645 } 7646 if (!Type.isStringFilled(namespace)) { 7647 throw new TypeError('The "namespace" must be an non-empty string.'); 7648 } 7649 if (EventEmitter.isEventEmitter(target)) { 7650 throw new TypeError('The "target" is an event emitter already.'); 7651 } 7652 const targetProto = Object.getPrototypeOf(target); 7653 const emitter = new EventEmitter(); 7654 emitter.setEventNamespace(namespace); 7655 Object.setPrototypeOf(emitter, targetProto); 7656 Object.setPrototypeOf(target, emitter); 7657 Object.getOwnPropertyNames(EventEmitter.prototype).forEach(method => {
7658 if (['constructor'].includes(method)) { 7659 return; 7660 } 7661 emitter[method] = function (...args) { 7662 return EventEmitter.prototype[method].apply(target, args); 7663 }; 7664 }); 7665 } 7666 }, { 7667 key: "subscribe", 7668 value: function subscribe(target, eventName, listener, options) { 7669 if (Type.isString(target)) { 7670 options = listener; 7671 listener = eventName; 7672 eventName = target; 7673 target = this.GLOBAL_TARGET; 7674 } 7675 if (!Type.isObject(target)) { 7676 throw new TypeError(`The "target" argument must be an object.`); 7677 } 7678 eventName = this.normalizeEventName(eventName); 7679 if (!Type.isStringFilled(eventName)) { 7680 throw new TypeError(`The "eventName" argument must be a string.`); 7681 } 7682 listener = this.normalizeListener(listener); 7683 options = Type.isPlainObject(options) ? options : {}; 7684 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7685 const { 7686 eventsMap, 7687 onceMap 7688 } = eventStore.getOrAdd(target); 7689 const onceListeners = onceMap.get(fullEventName); 7690 let listeners = eventsMap.get(fullEventName); 7691 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7692 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7693 } else { 7694 if (listeners) { 7695 listeners.set(listener, { 7696 listener, 7697 options, 7698 sort: this.getNextSequenceValue() 7699 }); 7700 } else { 7701 listeners = new Map([[listener, { 7702 listener, 7703 options, 7704 sort: this.getNextSequenceValue() 7705 }]]); 7706 eventsMap.set(fullEventName, listeners); 7707 } 7708 } 7709 const maxListeners = this.getMaxListeners(target, eventName); 7710 if (listeners.size > maxListeners) { 7711 warningStore.add(target, fullEventName, listeners); 7712 warningStore.printDelayed(); 7713 } 7714 } 7715 }, { 7716 key: "subscribeOnce", 7717 value: function subscribeOnce(target, eventName, listener) { 7718 if (Type.isString(target)) { 7719 listener = eventName; 7720 eventName = target; 7721 target = this.GLOBAL_TARGET;
7722 } 7723 if (!Type.isObject(target)) { 7724 throw new TypeError(`The "target" argument must be an object.`); 7725 } 7726 eventName = this.normalizeEventName(eventName); 7727 if (!Type.isStringFilled(eventName)) { 7728 throw new TypeError(`The "eventName" argument must be a string.`); 7729 } 7730 listener = this.normalizeListener(listener); 7731 const fullEventName = this.resolveEventName(eventName, target); 7732 const { 7733 eventsMap, 7734 onceMap 7735 } = eventStore.getOrAdd(target); 7736 const listeners = eventsMap.get(fullEventName); 7737 let onceListeners = onceMap.get(fullEventName); 7738 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7739 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7740 } else { 7741 const once = (...args) => { 7742 this.unsubscribe(target, eventName, once); 7743 onceListeners.delete(listener); 7744 listener(...args); 7745 }; 7746 if (onceListeners) { 7747 onceListeners.set(listener, once); 7748 } else { 7749 onceListeners = new Map([[listener, once]]); 7750 onceMap.set(fullEventName, onceListeners); 7751 } 7752 this.subscribe(target, eventName, once); 7753 } 7754 } 7755 }, { 7756 key: "unsubscribe", 7757 value: function unsubscribe(target, eventName, listener, options) { 7758 if (Type.isString(target)) { 7759 listener = eventName; 7760 eventName = target; 7761 target = this.GLOBAL_TARGET;
7762 } 7763 eventName = this.normalizeEventName(eventName); 7764 if (!Type.isStringFilled(eventName)) { 7765 throw new TypeError(`The "eventName" argument must be a string.`); 7766 } 7767 listener = this.normalizeListener(listener); 7768 options = Type.isPlainObject(options) ? options : {}; 7769 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7770 const targetInfo = eventStore.get(target); 7771 const listeners = targetInfo && targetInfo.eventsMap.get(fullEventName); 7772 const onceListeners = targetInfo && targetInfo.onceMap.get(fullEventName); 7773 if (listeners) { 7774 listeners.delete(listener); 7775 } 7776 if (onceListeners) { 7777 const once = onceListeners.get(listener); 7778 if (once) { 7779 onceListeners.delete(listener); 7780 listeners.delete(once); 7781 } 7782 } 7783 } 7784 }, { 7785 key: "unsubscribeAll", 7786 value: function unsubscribeAll(target, eventName, options) { 7787 if (Type.isString(target)) { 7788 eventName = target; 7789 target = this.GLOBAL_TARGET;
7790 } 7791 if (Type.isStringFilled(eventName)) { 7792 const targetInfo = eventStore.get(target); 7793 if (targetInfo) { 7794 options = Type.isPlainObject(options) ? options : {}; 7795 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7796 targetInfo.eventsMap.delete(fullEventName); 7797 targetInfo.onceMap.delete(fullEventName); 7798 } 7799 } else if (Type.isNil(eventName)) { 7800 if (target === this.GLOBAL_TARGET) { 7801 console.error('You cannot unsubscribe all global listeners.'); 7802 } else { 7803 eventStore.delete(target); 7804 } 7805 } 7806 } 7807 }, { 7808 key: "emit", 7809 value: function emit(target, eventName, event, options) { 7810 if (Type.isString(target)) { 7811 options = event; 7812 event = eventName; 7813 eventName = target; 7814 target = this.GLOBAL_TARGET; 7815 } 7816 if (!Type.isObject(target)) { 7817 throw new TypeError(`The "target" argument must be an object.`); 7818 } 7819 eventName = this.normalizeEventName(eventName); 7820 if (!Type.isStringFilled(eventName)) { 7821 throw new TypeError(`The "eventName" argument must be a string.`); 7822 } 7823 options = Type.isPlainObject(options) ? options : {}; 7824 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7825 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 7826 const globalListeners = globalEvents && globalEvents.eventsMap.get(fullEventName) || new Map(); 7827 let targetListeners = new Set(); 7828 if (target !== this.GLOBAL_TARGET) { 7829 const targetEvents = eventStore.get(target); 7830 targetListeners = targetEvents && targetEvents.eventsMap.get(fullEventName) || new Map(); 7831 } 7832 const listeners = [...globalListeners.values(), ...targetListeners.values()]; 7833 listeners.sort(function (a, b) { 7834 return a.sort - b.sort; 7835 }); 7836 const preparedEvent = this.prepareEvent(target, fullEventName, event); 7837 const result = []; 7838 for (let i = 0; i < listeners.length; i++) { 7839 if (preparedEvent.isImmediatePropagationStopped()) { 7840 break; 7841 } 7842 const { 7843 listener, 7844 options: listenerOptions 7845 } = listeners[i]; 7846 7847 //A previous listener could remove a current listener. 7848 if (globalListeners.has(listener) || targetListeners.has(listener)) { 7849 let listenerResult; 7850 if (listenerOptions.compatMode) { 7851 let params = []; 7852 const compatData = preparedEvent.getCompatData(); 7853 if (compatData !== null) { 7854 params = options.cloneData === true ? Runtime.clone(compatData) : compatData; 7855 } else { 7856 params = [preparedEvent]; 7857 } 7858 const context = Type.isUndefined(options.thisArg) ? target : options.thisArg; 7859 listenerResult = listener.apply(context, params); 7860 } else { 7861 listenerResult = Type.isUndefined(options.thisArg) ? listener(preparedEvent) : listener.call(options.thisArg, preparedEvent); 7862 } 7863 result.push(listenerResult); 7864 } 7865 } 7866 return result; 7867 } 7868 }, { 7869 key: "emitAsync", 7870 value: function emitAsync(target, eventName, event) { 7871 if (Type.isString(target)) { 7872 event = eventName; 7873 eventName = target; 7874 target = this.GLOBAL_TARGET;
7875 } 7876 return Promise.all(this.emit(target, eventName, event)); 7877 } 7878 }, { 7879 key: "prepareEvent", 7880 value: function prepareEvent(target, eventName, event) { 7881 let preparedEvent = event; 7882 if (!(event instanceof BaseEvent)) { 7883 preparedEvent = new BaseEvent(); 7884 preparedEvent.setData(event); 7885 } 7886 preparedEvent.setTarget(this.isEventEmitter(target) ? target[targetProperty] : target); 7887 preparedEvent.setType(eventName); 7888 return preparedEvent; 7889 } 7890 /** 7891 * @private 7892 * @returns {number} 7893 */ 7894 }, { 7895 key: "getNextSequenceValue", 7896 value: function getNextSequenceValue() { 7897 return this.sequenceValue++; 7898 } 7899 /** 7900 * Sets max global events listeners count 7901 * Event.EventEmitter.setMaxListeners(10) - sets the default value for all events (global target) 7902 * Event.EventEmitter.setMaxListeners("onClose", 10) - sets the value for onClose event (global target) 7903 * Event.EventEmitter.setMaxListeners(obj, 10) - sets the default value for all events (obj target) 7904 * Event.EventEmitter.setMaxListeners(obj, "onClose", 10); - sets the value for onClose event (obj target) 7905 * @return {void} 7906 * @param args 7907 */ 7908 }, { 7909 key: "setMaxListeners", 7910 value: function setMaxListeners(...args) { 7911 let target = this.GLOBAL_TARGET;
7912 let eventName = null; 7913 let count = undefined; 7914 if (args.length === 1) { 7915 count = args[0]; 7916 } else if (args.length === 2) { 7917 if (Type.isString(args[0])) { 7918 [eventName, count] = args; 7919 } else { 7920 [target, count] = args; 7921 } 7922 } else if (args.length >= 3) { 7923 [target, eventName, count] = args; 7924 } 7925 if (!Type.isObject(target)) { 7926 throw new TypeError(`The "target" argument must be an object.`); 7927 } 7928 if (eventName !== null && !Type.isStringFilled(eventName)) { 7929 throw new TypeError(`The "eventName" argument must be a string.`); 7930 } 7931 if (!Type.isNumber(count) || count < 0) { 7932 throw new TypeError(`The value of "count" is out of range. It must be a non-negative number. Received ${count}.`); 7933 } 7934 const targetInfo = eventStore.getOrAdd(target); 7935 if (Type.isStringFilled(eventName)) { 7936 const fullEventName = this.resolveEventName(eventName, target); 7937 targetInfo.eventsMaxListeners.set(fullEventName, count); 7938 } else { 7939 targetInfo.maxListeners = count; 7940 } 7941 } 7942 }, { 7943 key: "getMaxListeners", 7944 value: function getMaxListeners(target, eventName) { 7945 if (Type.isString(target)) { 7946 eventName = target; 7947 target = this.GLOBAL_TARGET;
7948 } else if (Type.isNil(target)) { 7949 target = this.GLOBAL_TARGET; 7950 } 7951 if (!Type.isObject(target)) { 7952 throw new TypeError(`The "target" argument must be an object.`); 7953 } 7954 const targetInfo = eventStore.get(target); 7955 if (targetInfo) { 7956 let maxListeners = targetInfo.maxListeners; 7957 if (Type.isStringFilled(eventName)) { 7958 const fullEventName = this.resolveEventName(eventName, target); 7959 maxListeners = targetInfo.eventsMaxListeners.get(fullEventName) || maxListeners; 7960 } 7961 return maxListeners; 7962 } 7963 return this.DEFAULT_MAX_LISTENERS; 7964 } 7965 }, { 7966 key: "addMaxListeners", 7967 value: function addMaxListeners(...args) { 7968 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 7969 const maxListeners = Math.max(this.getMaxListeners(target, eventName) + increment, 0); 7970 if (Type.isStringFilled(eventName)) { 7971 EventEmitter.setMaxListeners(target, eventName, maxListeners); 7972 } else { 7973 EventEmitter.setMaxListeners(target, maxListeners); 7974 } 7975 return maxListeners; 7976 } 7977 /** 7978 * Increases max listeners count 7979 * 7980 * Event.EventEmitter.incrementMaxListeners() - adds one max listener for all events of global target 7981 * Event.EventEmitter.incrementMaxListeners(3) - adds three max listeners for all events of global target 7982 * Event.EventEmitter.incrementMaxListeners('onClose') - adds one max listener for onClose event of global target 7983 * Event.EventEmitter.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 7984 * 7985 * Event.EventEmitter.incrementMaxListeners(obj) - adds one max listener for all events of 'obj' target 7986 * Event.EventEmitter.incrementMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 7987 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 7988 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 7989 */ 7990 }, { 7991 key: "incrementMaxListeners", 7992 value: function incrementMaxListeners(...args) { 7993 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 7994 return this.addMaxListeners(target, eventName, Math.abs(increment)); 7995 } 7996 }, { 7997 key: "decrementMaxListeners", 7998 value: function decrementMaxListeners(...args) { 7999 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 8000 return this.addMaxListeners(target, eventName, -Math.abs(increment)); 8001 } 8002 }, { 8003 key: "destructMaxListenersArgs", 8004 value: function destructMaxListenersArgs(...args) { 8005 let eventName = null; 8006 let increment = 1; 8007 let target = this.GLOBAL_TARGET;
8008 if (args.length === 1) { 8009 if (Type.isNumber(args[0])) { 8010 increment = args[0]; 8011 } else if (Type.isString(args[0])) { 8012 eventName = args[0]; 8013 } else { 8014 target = args[0]; 8015 } 8016 } else if (args.length === 2) { 8017 if (Type.isString(args[0])) { 8018 [eventName, increment] = args; 8019 } else if (Type.isString(args[1])) { 8020 [target, eventName] = args; 8021 } else { 8022 [target, increment] = args; 8023 } 8024 } else if (args.length >= 3) { 8025 [target, eventName, increment] = args; 8026 } 8027 if (!Type.isObject(target)) { 8028 throw new TypeError(`The "target" argument must be an object.`); 8029 } 8030 if (eventName !== null && !Type.isStringFilled(eventName)) { 8031 throw new TypeError(`The "eventName" argument must be a string.`); 8032 } 8033 if (!Type.isNumber(increment)) { 8034 throw new TypeError(`The value of "increment" must be a number.`); 8035 } 8036 return [target, eventName, increment]; 8037 } 8038 /** 8039 * Gets listeners list for a specified event 8040 * @param {object} target 8041 * @param {string} eventName 8042 */ 8043 }, { 8044 key: "getListeners", 8045 value: function getListeners(target, eventName) { 8046 if (Type.isString(target)) { 8047 eventName = target; 8048 target = this.GLOBAL_TARGET;
8049 } 8050 if (!Type.isObject(target)) { 8051 throw new TypeError(`The "target" argument must be an object.`); 8052 } 8053 eventName = this.normalizeEventName(eventName); 8054 if (!Type.isStringFilled(eventName)) { 8055 throw new TypeError(`The "eventName" argument must be a string.`); 8056 } 8057 const targetInfo = eventStore.get(target); 8058 if (!targetInfo) { 8059 return new Map(); 8060 } 8061 const fullEventName = this.resolveEventName(eventName, target); 8062 return targetInfo.eventsMap.get(fullEventName) || new Map(); 8063 } 8064 }, { 8065 key: "registerAliases", 8066 value: function registerAliases(aliases) { 8067 aliases = this.normalizeAliases(aliases); 8068 Object.keys(aliases).forEach(alias => { 8069 aliasStore.set(alias, { 8070 eventName: aliases[alias].eventName, 8071 namespace: aliases[alias].namespace 8072 }); 8073 }); 8074 EventEmitter.mergeEventAliases(aliases); 8075 } 8076 /** 8077 * @private 8078 * @param aliases 8079 */ 8080 }, { 8081 key: "normalizeAliases", 8082 value: function normalizeAliases(aliases) { 8083 if (!Type.isPlainObject(aliases)) { 8084 throw new TypeError(`The "aliases" argument must be an object.`); 8085 } 8086 const result = Object.create(null); 8087 for (let alias in aliases) { 8088 if (!Type.isStringFilled(alias)) { 8089 throw new TypeError(`The alias must be an non-empty string.`); 8090 } 8091 const options = aliases[alias]; 8092 if (!options || !Type.isStringFilled(options.eventName) || !Type.isStringFilled(options.namespace)) { 8093 throw new TypeError(`The alias options must set the "eventName" and the "namespace".`); 8094 } 8095 alias = this.normalizeEventName(alias); 8096 result[alias] = { 8097 eventName: options.eventName, 8098 namespace: options.namespace 8099 }; 8100 } 8101 return result; 8102 } 8103 /** 8104 * @private 8105 */ 8106 }, { 8107 key: "mergeEventAliases", 8108 value: function mergeEventAliases(aliases) { 8109 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 8110 if (!globalEvents) { 8111 return; 8112 } 8113 Object.keys(aliases).forEach(alias => { 8114 const options = aliases[alias]; 8115 alias = this.normalizeEventName(alias); 8116 const fullEventName = this.makeFullEventName(options.namespace, options.eventName); 8117 const aliasListeners = globalEvents.eventsMap.get(alias); 8118 if (aliasListeners) { 8119 const listeners = globalEvents.eventsMap.get(fullEventName) || new Map(); 8120 globalEvents.eventsMap.set(fullEventName, new Map([...listeners, ...aliasListeners])); 8121 globalEvents.eventsMap.delete(alias); 8122 } 8123 const aliasOnceListeners = globalEvents.onceMap.get(alias); 8124 if (aliasOnceListeners) { 8125 const onceListeners = globalEvents.onceMap.get(fullEventName) || new Map(); 8126 globalEvents.onceMap.set(fullEventName, new Map([...onceListeners, ...aliasOnceListeners])); 8127 globalEvents.onceMap.delete(alias); 8128 } 8129 const aliasMaxListeners = globalEvents.eventsMaxListeners.get(alias); 8130 if (aliasMaxListeners) { 8131 const eventMaxListeners = globalEvents.eventsMaxListeners.get(fullEventName) || 0; 8132 globalEvents.eventsMaxListeners.set(fullEventName, Math.max(eventMaxListeners, aliasMaxListeners)); 8133 globalEvents.eventsMaxListeners.delete(alias); 8134 } 8135 }); 8136 } 8137 /** 8138 * Returns true if the target is an instance of Event.EventEmitter 8139 * @param {object} target 8140 * @returns {boolean} 8141 */ 8142 }, { 8143 key: "isEventEmitter", 8144 value: function isEventEmitter(target) { 8145 return Type.isObject(target) && target[isEmitterProperty] === true; 8146 } 8147 /** 8148 * @private 8149 * @param {string} eventName 8150 * @returns {string} 8151 */ 8152 }, { 8153 key: "normalizeEventName", 8154 value: function normalizeEventName(eventName) { 8155 if (!Type.isStringFilled(eventName)) { 8156 return ''; 8157 } 8158 return eventName.toLowerCase(); 8159 } 8160 /** 8161 * @private 8162 */ 8163 }, { 8164 key: "normalizeListener", 8165 value: function normalizeListener(listener) { 8166 if (Type.isString(listener)) { 8167 listener = Reflection.getClass(listener); 8168 } 8169 if (!Type.isFunction(listener)) { 8170 throw new TypeError(`The "listener" argument must be of type Function. Received type ${typeof listener}.`); 8171 } 8172 return listener; 8173 } 8174 /** 8175 * @private 8176 * @param eventName 8177 * @param target 8178 * @param useGlobalNaming 8179 * @returns {string} 8180 */ 8181 }, { 8182 key: "resolveEventName", 8183 value: function resolveEventName(eventName, target, useGlobalNaming = false) { 8184 eventName = this.normalizeEventName(eventName); 8185 if (!Type.isStringFilled(eventName)) { 8186 return ''; 8187 } 8188 if (this.isEventEmitter(target) && useGlobalNaming !== true) { 8189 if (target.getEventNamespace() !== null && eventName.includes('.')) { 8190 console.warn(`Possible the wrong event name "${eventName}".`); 8191 } 8192 eventName = target.getFullEventName(eventName); 8193 } else if (aliasStore.has(eventName)) { 8194 const { 8195 namespace, 8196 eventName: actualEventName 8197 } = aliasStore.get(eventName); 8198 eventName = this.makeFullEventName(namespace, actualEventName); 8199 } 8200 return eventName; 8201 } 8202 /** 8203 * @private 8204 * @param {string} namespace 8205 * @param {string} eventName 8206 * @returns {string} 8207 */ 8208 }, { 8209 key: "makeFullEventName", 8210 value: function makeFullEventName(namespace, eventName) { 8211 const fullName = Type.isStringFilled(namespace) ? `${namespace}:${eventName}` : eventName; 8212 return Type.isStringFilled(fullName) ? fullName.toLowerCase() : ''; 8213 } 8214 }]); 8215 return EventEmitter; 8216 }(); 8217 babelHelpers.defineProperty(EventEmitter, "GLOBAL_TARGET", globalTarget); 8218 babelHelpers.defineProperty(EventEmitter, "DEFAULT_MAX_LISTENERS", eventStore.getDefaultMaxListeners()); 8219 babelHelpers.defineProperty(EventEmitter, "sequenceValue", 1); 8220 8221 let stack = []; 8222 /** 8223 * For compatibility only 8224 * @type {boolean} 8225 */ 8226 // eslint-disable-next-line 8227 exports.isReady = false;
8228 function ready(handler) { 8229 switch (document.readyState) { 8230 case 'loading': 8231 stack.push(handler); 8232 break; 8233 case 'interactive': 8234 case 'complete': 8235 if (Type.isFunction(handler)) { 8236 handler(); 8237 } 8238 exports.isReady = true; 8239 break; 8240 default: 8241 break; 8242 } 8243 } 8244 document.addEventListener('readystatechange', () => { 8245 if (!exports.isReady) { 8246 stack.forEach(ready); 8247 stack = []; 8248 } 8249 }); 8250 8251 /** 8252 * @memberOf BX 8253 */ 8254 let Event = function Event() { 8255 babelHelpers.classCallCheck(this, Event); 8256 }; 8257 babelHelpers.defineProperty(Event, "bind", bind); 8258 babelHelpers.defineProperty(Event, "bindOnce", bindOnce); 8259 babelHelpers.defineProperty(Event, "unbind", unbind); 8260 babelHelpers.defineProperty(Event, "unbindAll", unbindAll); 8261 babelHelpers.defineProperty(Event, "ready", ready); 8262 babelHelpers.defineProperty(Event, "EventEmitter", EventEmitter); 8263 babelHelpers.defineProperty(Event, "BaseEvent", BaseEvent); 8264 8265 function encodeAttributeValue(value) { 8266 if (Type.isPlainObject(value) || Type.isArray(value)) { 8267 return JSON.stringify(value); 8268 } 8269 return Text.encode(Text.decode(value)); 8270 } 8271 8272 function decodeAttributeValue(value) { 8273 if (Type.isString(value)) { 8274 const decodedValue = Text.decode(value); 8275 let result; 8276 try { 8277 result = JSON.parse(decodedValue); 8278 } catch (e) { 8279 result = decodedValue; 8280 } 8281 if (result === decodedValue) { 8282 if (/^[\d.]+[.]?\d+$/.test(result)) { 8283 return Number(result); 8284 } 8285 } 8286 if (result === 'true' || result === 'false') { 8287 return Boolean(result); 8288 } 8289 return result; 8290 } 8291 return value; 8292 } 8293 8294 function getPageScroll() { 8295 const { 8296 documentElement, 8297 body 8298 } = document; 8299 const scrollTop = Math.max(window.pageYOffset || 0, documentElement ? documentElement.scrollTop : 0, body ? body.scrollTop : 0); 8300 const scrollLeft = Math.max(window.pageXOffset || 0, documentElement ? documentElement.scrollLeft : 0, body ? body.scrollLeft : 0); 8301 return { 8302 scrollTop, 8303 scrollLeft 8304 }; 8305 } 8306 8307 /** 8308 * @memberOf BX 8309 */ 8310 let Dom = /*#__PURE__*/function () { 8311 function Dom() { 8312 babelHelpers.classCallCheck(this, Dom); 8313 } 8314 babelHelpers.createClass(Dom, null, [{ 8315 key: "replace", 8316 /** 8317 * Replaces old html element to new html element 8318 * @param oldElement 8319 * @param newElement 8320 */ 8321 value: function replace(oldElement, newElement) { 8322 if (Type.isDomNode(oldElement) && Type.isDomNode(newElement)) { 8323 if (Type.isDomNode(oldElement.parentNode)) { 8324 oldElement.parentNode.replaceChild(newElement, oldElement); 8325 } 8326 } 8327 } 8328 /** 8329 * Removes element 8330 * @param element 8331 */ 8332 }, { 8333 key: "remove", 8334 value: function remove(element) { 8335 if (Type.isDomNode(element) && Type.isDomNode(element.parentNode)) { 8336 element.parentNode.removeChild(element); 8337 } 8338 } 8339 /** 8340 * Cleans element 8341 * @param element 8342 */ 8343 }, { 8344 key: "clean", 8345 value: function clean(element) { 8346 if (Type.isDomNode(element)) { 8347 while (element.childNodes.length > 0) { 8348 element.removeChild(element.firstChild); 8349 } 8350 return; 8351 } 8352 if (Type.isString(element)) { 8353 Dom.clean(document.getElementById(element)); 8354 } 8355 } 8356 /** 8357 * Inserts element before target element 8358 * @param current 8359 * @param target 8360 */ 8361 }, { 8362 key: "insertBefore", 8363 value: function insertBefore(current, target) { 8364 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8365 if (Type.isDomNode(target.parentNode)) { 8366 target.parentNode.insertBefore(current, target); 8367 } 8368 } 8369 } 8370 /** 8371 * Inserts element after target element 8372 * @param current 8373 * @param target 8374 */ 8375 }, { 8376 key: "insertAfter", 8377 value: function insertAfter(current, target) { 8378 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8379 if (Type.isDomNode(target.parentNode)) { 8380 const parent = target.parentNode; 8381 if (Type.isDomNode(target.nextSibling)) { 8382 parent.insertBefore(current, target.nextSibling); 8383 return; 8384 } 8385 parent.appendChild(current); 8386 } 8387 } 8388 } 8389 /** 8390 * Appends element to target element 8391 * @param current 8392 * @param target 8393 */ 8394 }, { 8395 key: "append", 8396 value: function append(current, target) { 8397 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8398 target.appendChild(current); 8399 } 8400 } 8401 /** 8402 * Prepends element to target element 8403 * @param current 8404 * @param target 8405 */ 8406 }, {
8407 key: "prepend", 8408 value: function prepend(current, target) { 8409 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8410 if (Type.isDomNode(target.firstChild)) { 8411 target.insertBefore(current, target.firstChild); 8412 return; 8413 } 8414 Dom.append(current, target); 8415 } 8416 } 8417 /** 8418 * Checks that element contains class name or class names 8419 * @param element 8420 * @param className 8421 * @return {Boolean} 8422 */ 8423 }, { 8424 key: "hasClass", 8425 value: function hasClass(element, className) { 8426 if (Type.isElementNode(element)) { 8427 if (Type.isString(className)) { 8428 const preparedClassName = className.trim(); 8429 if (preparedClassName.length > 0) { 8430 if (preparedClassName.includes(' ')) { 8431 return preparedClassName.split(' ').every(name => Dom.hasClass(element, name)); 8432 } 8433 if ('classList' in element) { 8434 return element.classList.contains(preparedClassName); 8435 } 8436 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8437 return element.getAttribute('class').split(' ').some(name => name === preparedClassName); 8438 } 8439 } 8440 } 8441 if (Type.isArray(className) && className.length > 0) { 8442 return className.every(name => Dom.hasClass(element, name)); 8443 } 8444 } 8445 return false; 8446 } 8447 /** 8448 * Adds class name 8449 * @param element 8450 * @param className 8451 */ 8452 }, { 8453 key: "addClass", 8454 value: function addClass(element, className) { 8455 if (Type.isElementNode(element)) { 8456 if (Type.isString(className)) { 8457 const preparedClassName = className.trim(); 8458 if (preparedClassName.length > 0) { 8459 if (preparedClassName.includes(' ')) { 8460 Dom.addClass(element, preparedClassName.split(' ')); 8461 return; 8462 } 8463 if ('classList' in element) { 8464 element.classList.add(preparedClassName); 8465 return; 8466 } 8467 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8468 if (element.className.baseVal === '') { 8469 element.className.baseVal = preparedClassName; 8470 return; 8471 } 8472 const names = element.className.baseVal.split(' '); 8473 if (!names.includes(preparedClassName)) { 8474 names.push(preparedClassName); 8475 element.className.baseVal = names.join(' ').trim(); 8476 return; 8477 } 8478 } 8479 return; 8480 } 8481 } 8482 if (Type.isArray(className)) { 8483 className.forEach(name => Dom.addClass(element, name)); 8484 } 8485 } 8486 } 8487 /** 8488 * Removes class name 8489 * @param element 8490 * @param className 8491 */ 8492 }, { 8493 key: "removeClass", 8494 value: function removeClass(element, className) { 8495 if (Type.isElementNode(element)) { 8496 if (Type.isString(className)) { 8497 const preparedClassName = className.trim(); 8498 if (preparedClassName.length > 0) { 8499 if (preparedClassName.includes(' ')) { 8500 Dom.removeClass(element, preparedClassName.split(' ')); 8501 return; 8502 } 8503 if ('classList' in element) { 8504 element.classList.remove(preparedClassName); 8505 return; 8506 } 8507 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8508 const names = element.className.baseVal.split(' ').filter(name => name !== preparedClassName); 8509 element.className.baseVal = names.join(' '); 8510 return; 8511 } 8512 } 8513 } 8514 if (Type.isArray(className)) { 8515 className.forEach(name => Dom.removeClass(element, name)); 8516 } 8517 } 8518 } 8519 /** 8520 * Toggles class name 8521 * @param element 8522 * @param className 8523 */ 8524 }, { 8525 key: "toggleClass", 8526 value: function toggleClass(element, className) { 8527 if (Type.isElementNode(element)) { 8528 if (Type.isString(className)) { 8529 const preparedClassName = className.trim(); 8530 if (preparedClassName.length > 0) { 8531 if (preparedClassName.includes(' ')) { 8532 Dom.toggleClass(element, preparedClassName.split(' ')); 8533 return; 8534 } 8535 element.classList.toggle(preparedClassName); 8536 return; 8537 } 8538 } 8539 if (Type.isArray(className)) { 8540 className.forEach(name => Dom.toggleClass(element, name)); 8541 } 8542 } 8543 } 8544 /** 8545 * Styles element 8546 */ 8547 }, { 8548 key: "style", 8549 value: function style(element, prop, value) { 8550 if (Type.isElementNode(element)) { 8551 if (Type.isNull(prop)) { 8552 element.removeAttribute('style'); 8553 return element; 8554 } 8555 if (Type.isPlainObject(prop)) {
8556 Object.entries(prop).forEach(item => { 8557 const [currentKey, currentValue] = item; 8558 Dom.style(element, currentKey, currentValue); 8559 }); 8560 return element; 8561 } 8562 if (Type.isString(prop)) { 8563 if (Type.isUndefined(value) && element.nodeType !== Node.DOCUMENT_NODE) { 8564 const computedStyle = getComputedStyle(element); 8565 if (prop in computedStyle) { 8566 return computedStyle[prop]; 8567 } 8568 return computedStyle.getPropertyValue(prop); 8569 } 8570 if (Type.isNull(value) || value === '' || value === 'null') { 8571 if (String(prop).startsWith('--')) { 8572 // eslint-disable-next-line 8573 element.style.removeProperty(prop); 8574 return element; 8575 } 8576 8577 // eslint-disable-next-line 8578 element.style[prop] = ''; 8579 return element; 8580 } 8581 if (Type.isString(value) || Type.isNumber(value)) { 8582 if (String(prop).startsWith('--')) { 8583 // eslint-disable-next-line 8584 element.style.setProperty(prop, value); 8585 return element; 8586 } 8587 8588 // eslint-disable-next-line 8589 element.style[prop] = value; 8590 return element; 8591 } 8592 } 8593 } 8594 return null; 8595 } 8596 /** 8597 * Adjusts element 8598 * @param target 8599 * @param data 8600 * @return {*} 8601 */ 8602 }, { 8603 key: "adjust", 8604 value: function adjust(target, data = {}) { 8605 if (!target.nodeType) { 8606 return null; 8607 } 8608 let element = target; 8609 if (target.nodeType === Node.DOCUMENT_NODE) { 8610 element = target.body; 8611 } 8612 if (Type.isPlainObject(data)) { 8613 if (Type.isPlainObject(data.attrs)) { 8614 Object.keys(data.attrs).forEach(key => { 8615 if (key === 'class' || key.toLowerCase() === 'classname') { 8616 element.className = data.attrs[key]; 8617 return; 8618 } 8619 8620 // eslint-disable-next-line 8621 if (data.attrs[key] == '') { 8622 element.removeAttribute(key); 8623 return; 8624 } 8625 element.setAttribute(key, data.attrs[key]); 8626 }); 8627 } 8628 if (Type.isPlainObject(data.style)) { 8629 Dom.style(element, data.style); 8630 } 8631 if (Type.isPlainObject(data.props)) { 8632 Object.keys(data.props).forEach(key => { 8633 element[key] = data.props[key]; 8634 }); 8635 } 8636 if (Type.isPlainObject(data.events)) { 8637 Object.keys(data.events).forEach(key => { 8638 Event.bind(element, key, data.events[key]); 8639 }); 8640 } 8641 if (Type.isPlainObject(data.dataset)) { 8642 Object.keys(data.dataset).forEach(key => { 8643 element.dataset[key] = data.dataset[key]; 8644 }); 8645 } 8646 if (Type.isString(data.children)) { 8647 data.children = [data.children]; 8648 } 8649 if (Type.isArray(data.children) && data.children.length > 0) { 8650 data.children.forEach(item => { 8651 if (Type.isDomNode(item)) { 8652 Dom.append(item, element); 8653 } 8654 if (Type.isString(item)) { 8655 element.insertAdjacentHTML('beforeend', item); 8656 } 8657 }); 8658 return element; 8659 } 8660 if ('text' in data && !Type.isNil(data.text)) { 8661 element.innerText = data.text; 8662 return element; 8663 } 8664 if ('html' in data && !Type.isNil(data.html)) { 8665 element.innerHTML = data.html; 8666 } 8667 } 8668 return element; 8669 } 8670 /** 8671 * Creates element 8672 * @param tag 8673 * @param data 8674 * @param context 8675 * @return {HTMLElement|HTMLBodyElement} 8676 */ 8677 }, { 8678 key: "create", 8679 value: function create(tag, data = {}, context = document) { 8680 let tagName = tag; 8681 let options = data; 8682 if (Type.isObjectLike(tag)) { 8683 options = tag; 8684 tagName = tag.tag; 8685 } 8686 return Dom.adjust(context.createElement(tagName), options); 8687 } 8688 /** 8689 * Shows element 8690 * @param element 8691 */ 8692 }, { 8693 key: "show", 8694 value: function show(element) { 8695 if (Type.isDomNode(element)) { 8696 // eslint-disable-next-line 8697 element.hidden = false;
8698 } 8699 } 8700 /** 8701 * Hides element 8702 * @param element 8703 */ 8704 }, { 8705 key: "hide", 8706 value: function hide(element) { 8707 if (Type.isDomNode(element)) { 8708 // eslint-disable-next-line 8709 element.hidden = true; 8710 } 8711 } 8712 /** 8713 * Checks that element is shown 8714 * @param element 8715 * @return {*|boolean} 8716 */ 8717 }, { 8718 key: "isShown", 8719 value: function isShown(element) { 8720 return Type.isDomNode(element) && !element.hidden && element.style.getPropertyValue('display') !== 'none'; 8721 } 8722 /** 8723 * Toggles element visibility 8724 * @param element 8725 */ 8726 }, { 8727 key: "toggle", 8728 value: function toggle(element) { 8729 if (Type.isDomNode(element)) { 8730 if (Dom.isShown(element)) { 8731 Dom.hide(element); 8732 } else { 8733 Dom.show(element); 8734 } 8735 } 8736 } 8737 /** 8738 * Gets element position relative page 8739 * @param {HTMLElement} element 8740 * @return {DOMRect} 8741 */ 8742 }, { 8743 key: "getPosition", 8744 value: function getPosition(element) { 8745 if (Type.isDomNode(element)) { 8746 const elementRect = element.getBoundingClientRect(); 8747 const { 8748 scrollLeft, 8749 scrollTop 8750 } = getPageScroll(); 8751 return new DOMRect(elementRect.left + scrollLeft, elementRect.top + scrollTop, elementRect.width, elementRect.height); 8752 } 8753 return new DOMRect(); 8754 } 8755 /** 8756 * Gets element position relative specified element position 8757 * @param {HTMLElement} element 8758 * @param {HTMLElement} relationElement 8759 * @return {DOMRect} 8760 */ 8761 }, { 8762 key: "getRelativePosition", 8763 value: function getRelativePosition(element, relationElement) { 8764 if (Type.isDomNode(element) && Type.isDomNode(relationElement)) { 8765 const elementPosition = Dom.getPosition(element); 8766 const relationElementPosition = Dom.getPosition(relationElement); 8767 return new DOMRect(elementPosition.left - relationElementPosition.left, elementPosition.top - relationElementPosition.top, elementPosition.width, elementPosition.height); 8768 } 8769 return new DOMRect(); 8770 } 8771 }, { 8772 key: "attr", 8773 value: function attr(element, _attr, value) { 8774 if (Type.isElementNode(element)) { 8775 if (Type.isString(_attr)) { 8776 if (!Type.isNil(value)) { 8777 return element.setAttribute(_attr, encodeAttributeValue(value)); 8778 } 8779 if (Type.isNull(value)) { 8780 return element.removeAttribute(_attr); 8781 } 8782 return decodeAttributeValue(element.getAttribute(_attr)); 8783 } 8784 if (Type.isPlainObject(_attr)) { 8785 return Object.entries(_attr).forEach(([attrKey, attrValue]) => { 8786 Dom.attr(element, attrKey, attrValue); 8787 }); 8788 } 8789 } 8790 return null; 8791 } 8792 }]); 8793 return Dom; 8794 }(); 8795 8796 const UA = navigator.userAgent.toLowerCase(); 8797 8798 /** 8799 * @memberOf BX 8800 */ 8801 let Browser = /*#__PURE__*/function () { 8802 function Browser() { 8803 babelHelpers.classCallCheck(this, Browser); 8804 } 8805 babelHelpers.createClass(Browser, null, [{ 8806 key: "isOpera", 8807 value: function isOpera() { 8808 return UA.includes('opera'); 8809 } 8810 }, { 8811 key: "isIE", 8812 value: function isIE() { 8813 return 'attachEvent' in document && !Browser.isOpera(); 8814 } 8815 }, { 8816 key: "isIE6", 8817 value: function isIE6() { 8818 return UA.includes('msie 6'); 8819 } 8820 }, { 8821 key: "isIE7", 8822 value: function isIE7() { 8823 return UA.includes('msie 7'); 8824 } 8825 }, { 8826 key: "isIE8", 8827 value: function isIE8() { 8828 return UA.includes('msie 8'); 8829 } 8830 }, { 8831 key: "isIE9", 8832 value: function isIE9() { 8833 return 'documentMode' in document && document.documentMode >= 9; 8834 } 8835 }, { 8836 key: "isIE10", 8837 value: function isIE10() { 8838 return 'documentMode' in document && document.documentMode >= 10; 8839 } 8840 }, { 8841 key: "isSafari", 8842 value: function isSafari() { 8843 return UA.includes('safari') && !UA.includes('chrome'); 8844 } 8845 }, { 8846 key: "isFirefox", 8847 value: function isFirefox() { 8848 return UA.includes('firefox'); 8849 } 8850 }, { 8851 key: "isChrome", 8852 value: function isChrome() { 8853 return UA.includes('chrome'); 8854 } 8855 }, { 8856 key: "detectIEVersion", 8857 value: function detectIEVersion() { 8858 if (Browser.isOpera() || Browser.isSafari() || Browser.isFirefox() || Browser.isChrome()) { 8859 return -1; 8860 } 8861 let rv = -1; 8862 if (!!window.MSStream && !window.ActiveXObject && 'ActiveXObject' in window) { 8863 rv = 11; 8864 } else if (Browser.isIE10()) { 8865 rv = 10; 8866 } else if (Browser.isIE9()) { 8867 rv = 9; 8868 } else if (Browser.isIE()) { 8869 rv = 8; 8870 } 8871 if (rv === -1 || rv === 8) { 8872 if (navigator.appName === 'Microsoft Internet Explorer') { 8873 const re = new RegExp('MSIE ([0-9]+[.0-9]*)'); 8874 const res = navigator.userAgent.match(re); 8875 if (Type.isArrayLike(res) && res.length > 0) { 8876 rv = parseFloat(res[1]); 8877 } 8878 } 8879 if (navigator.appName === 'Netscape') { 8880 // Alternative check for IE 11 8881 rv = 11; 8882 const re = new RegExp('Trident/.*rv:([0-9]+[.0-9]*)'); 8883 if (re.exec(navigator.userAgent) != null) { 8884 const res = navigator.userAgent.match(re); 8885 if (Type.isArrayLike(res) && res.length > 0) { 8886 rv = parseFloat(res[1]); 8887 } 8888 } 8889 } 8890 } 8891 return rv; 8892 } 8893 }, { 8894 key: "isIE11", 8895 value: function isIE11() { 8896 return Browser.detectIEVersion() >= 11; 8897 } 8898 }, { 8899 key: "isMac", 8900 value: function isMac() { 8901 return UA.includes('macintosh'); 8902 } 8903 }, { 8904 key: "isWin", 8905 value: function isWin() { 8906 return UA.includes('windows'); 8907 } 8908 }, { 8909 key: "isLinux", 8910 value: function isLinux() { 8911 return UA.includes('linux') && !Browser.isAndroid(); 8912 } 8913 }, { 8914 key: "isAndroid", 8915 value: function isAndroid() { 8916 return UA.includes('android'); 8917 } 8918 }, { 8919 key: "isIPad", 8920 value: function isIPad() { 8921 return UA.includes('ipad;') || this.isMac() && this.isTouchDevice(); 8922 } 8923 }, { 8924 key: "isIPhone", 8925 value: function isIPhone() { 8926 return UA.includes('iphone;'); 8927 } 8928 }, { 8929 key: "isIOS", 8930 value: function isIOS() { 8931 return Browser.isIPad() || Browser.isIPhone(); 8932 } 8933 }, { 8934 key: "isMobile", 8935 value: function isMobile() { 8936 return Browser.isIPhone() || Browser.isIPad() || Browser.isAndroid() || UA.includes('mobile') || UA.includes('touch'); 8937 } 8938 }, { 8939 key: "isRetina", 8940 value: function isRetina() { 8941 return window.devicePixelRatio && window.devicePixelRatio >= 2; 8942 } 8943 }, { 8944 key: "isTouchDevice", 8945 value: function isTouchDevice() { 8946 return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; 8947 } 8948 }, { 8949 key: "isDoctype", 8950 value: function isDoctype(target) { 8951 const doc = target || document; 8952 if (doc.compatMode) { 8953 return doc.compatMode === 'CSS1Compat'; 8954 } 8955 return doc.documentElement && doc.documentElement.clientHeight; 8956 } 8957 }, { 8958 key: "isLocalStorageSupported", 8959 value: function isLocalStorageSupported() { 8960 try { 8961 localStorage.setItem('test', 'test'); 8962 localStorage.removeItem('test'); 8963 return true; 8964 } catch (e) { 8965 return false;
8966 } 8967 } 8968 }, { 8969 key: "addGlobalClass", 8970 value: function addGlobalClass(target) { 8971 let globalClass = 'bx-core'; 8972 target = Type.isElementNode(target) ? target : document.documentElement; 8973 if (Dom.hasClass(target, globalClass)) { 8974 return; 8975 } 8976 if (Browser.isIOS()) { 8977 globalClass += ' bx-ios'; 8978 } else if (Browser.isWin()) { 8979 globalClass += ' bx-win'; 8980 } else if (Browser.isMac()) { 8981 globalClass += ' bx-mac'; 8982 } else if (Browser.isLinux()) { 8983 globalClass += ' bx-linux'; 8984 } else if (Browser.isAndroid()) { 8985 globalClass += ' bx-android'; 8986 } 8987 globalClass += Browser.isMobile() ? ' bx-touch' : ' bx-no-touch'; 8988 globalClass += Browser.isRetina() ? ' bx-retina' : ' bx-no-retina'; 8989 if (/AppleWebKit/.test(navigator.userAgent)) { 8990 globalClass += ' bx-chrome'; 8991 } else if (/Opera/.test(navigator.userAgent)) { 8992 globalClass += ' bx-opera'; 8993 } else if (Browser.isFirefox()) { 8994 globalClass += ' bx-firefox'; 8995 } 8996 Dom.addClass(target, globalClass); 8997 } 8998 }, { 8999 key: "detectAndroidVersion", 9000 value: function detectAndroidVersion() { 9001 const re = new RegExp('Android ([0-9]+[.0-9]*)'); 9002 if (re.exec(navigator.userAgent) != null) { 9003 const res = navigator.userAgent.match(re); 9004 if (Type.isArrayLike(res) && res.length > 0) { 9005 return parseFloat(res[1]); 9006 } 9007 } 9008 return 0; 9009 } 9010 }, { 9011 key: "isPropertySupported", 9012 value: function isPropertySupported(jsProperty, returnCSSName) { 9013 if (jsProperty === '') { 9014 return false; 9015 } 9016 function getCssName(propertyName) { 9017 return propertyName.replace(/([A-Z])/g, (...args) => `-${args[1].toLowerCase()}`); 9018 } 9019 function getJsName(cssName) { 9020 const reg = /(\\-([a-z]))/g; 9021 if (reg.test(cssName)) { 9022 return cssName.replace(reg, (...args) => args[2].toUpperCase()); 9023 } 9024 return cssName; 9025 } 9026 const property = jsProperty.includes('-') ? getJsName(jsProperty) : jsProperty; 9027 const bReturnCSSName = !!returnCSSName; 9028 const ucProperty = property.charAt(0).toUpperCase() + property.slice(1); 9029 const props = ['Webkit', 'Moz', 'O', 'ms'].join(`${ucProperty} `); 9030 const properties = `${property} ${props} ${ucProperty}`.split(' '); 9031 const obj = document.body || document.documentElement; 9032 for (let i = 0; i < properties.length; i += 1) { 9033 const prop = properties[i]; 9034 if (obj && 'style' in obj && prop in obj.style) { 9035 const lowerProp = prop.substr(0, prop.length - property.length).toLowerCase(); 9036 const prefix = prop === property ? '' : `-${lowerProp}-`; 9037 return bReturnCSSName ? prefix + getCssName(property) : prop; 9038 } 9039 } 9040 return false; 9041 } 9042 }, { 9043 key: "addGlobalFeatures", 9044 value: function addGlobalFeatures(features) { 9045 if (!Type.isArray(features)) { 9046 return; 9047 } 9048 const classNames = []; 9049 for (let i = 0; i < features.length; i += 1) { 9050 const support = !!Browser.isPropertySupported(features[i]); 9051 classNames.push(`bx-${support ? '' : 'no-'}${features[i].toLowerCase()}`); 9052 } 9053 Dom.addClass(document.documentElement, classNames.join(' ')); 9054 } 9055 }]); 9056 return Browser; 9057 }(); 9058 9059 let Cookie = /*#__PURE__*/function () { 9060 function Cookie() { 9061 babelHelpers.classCallCheck(this, Cookie); 9062 } 9063 babelHelpers.createClass(Cookie, null, [{ 9064 key: "getList", 9065 /** 9066 * Gets cookies list for current domain 9067 * @return {object} 9068 */ 9069 value: function getList() { 9070 return document.cookie.split(';').map(item => item.split('=')).map(item => item.map(subItem => subItem.trim())).reduce((acc, item) => { 9071 const [key, value] = item; 9072 acc[decodeURIComponent(key)] = decodeURIComponent(value); 9073 return acc; 9074 }, {}); 9075 } 9076 /** 9077 * Gets cookie value 9078 * @param {string} name 9079 * @return {*} 9080 */ 9081 }, { 9082 key: "get", 9083 value: function get(name) { 9084 const cookiesList = Cookie.getList(); 9085 if (name in cookiesList) { 9086 return cookiesList[name]; 9087 } 9088 return undefined; 9089 } 9090 /** 9091 * Sets cookie 9092 * @param {string} name 9093 * @param {*} value 9094 * @param {object} [options] 9095 */ 9096 }, { 9097 key: "set", 9098 value: function set(name, value, options = {}) { 9099 const attributes = { 9100 expires: '', 9101 ...options 9102 }; 9103 if (Type.isNumber(attributes.expires)) { 9104 const now = +new Date(); 9105 const days = attributes.expires; 9106 const dayInMs = 864e+5; 9107 attributes.expires = new Date(now + days * dayInMs); 9108 } 9109 if (Type.isDate(attributes.expires)) { 9110 attributes.expires = attributes.expires.toUTCString(); 9111 } 9112 const safeName = decodeURIComponent(String(name)).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape); 9113 const 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); 9114 const stringifiedAttributes = Object.keys(attributes).reduce((acc, key) => { 9115 const attributeValue = attributes[key]; 9116 if (!attributeValue) { 9117 return acc; 9118 } 9119 if (attributeValue === true) { 9120 return `${acc}; ${key}`; 9121 } 9122 9123 /** 9124 * Considers RFC 6265 section 5.2: 9125 * ... 9126 * 3. If the remaining unparsed-attributes contains a %x3B (';') 9127 * character: 9128 * Consume the characters of the unparsed-attributes up to, 9129 * not including, the first %x3B (';') character. 9130 */ 9131 return `${acc}; ${key}=${attributeValue.split(';')[0]}`; 9132 }, ''); 9133 document.cookie = `${safeName}=${safeValue}${stringifiedAttributes}`; 9134 } 9135 /** 9136 * Removes cookie 9137 * @param {string} name 9138 * @param {object} [options] 9139 */ 9140 }, { 9141 key: "remove", 9142 value: function remove(name, options = {}) { 9143 Cookie.set(name, '', { 9144 ...options, 9145 expires: -1 9146 }); 9147 } 9148 }]); 9149 return Cookie; 9150 }(); 9151 9152 function objectToFormData(source, formData = new FormData(), pre = null) { 9153 if (Type.isUndefined(source)) { 9154 return formData; 9155 } 9156 if (Type.isNull(source)) { 9157 formData.append(pre, ''); 9158 } else if (Type.isArray(source)) { 9159 if (!source.length) {
9160 const key = `${pre}[]`; 9161 formData.append(key, ''); 9162 } else { 9163 source.forEach((value, index) => { 9164 const key = `${pre}[${index}]`; 9165 objectToFormData(value, formData, key); 9166 }); 9167 } 9168 } else if (Type.isDate(source)) { 9169 formData.append(pre, source.toISOString()); 9170 } else if (Type.isObject(source) && !Type.isFile(source) && !Type.isBlob(source)) { 9171 Object.keys(source).forEach(property => { 9172 const value = source[property]; 9173 let preparedProperty = property; 9174 if (Type.isArray(value)) { 9175 while (preparedProperty.length > 2 && preparedProperty.lastIndexOf('[]') === preparedProperty.length - 2) { 9176 preparedProperty = preparedProperty.substring(0, preparedProperty.length - 2); 9177 } 9178 } 9179 const key = pre ? `${pre}[${preparedProperty}]` : preparedProperty; 9180 objectToFormData(value, formData, key); 9181 }); 9182 } else { 9183 formData.append(pre, source); 9184 } 9185 return formData; 9186 } 9187 9188 let Data = /*#__PURE__*/function () { 9189 function Data() { 9190 babelHelpers.classCallCheck(this, Data); 9191 } 9192 babelHelpers.createClass(Data, null, [{ 9193 key: "convertObjectToFormData", 9194 /** 9195 * Converts object to FormData 9196 * @param source 9197 * @return {FormData} 9198 */ 9199 value: function convertObjectToFormData(source) { 9200 return objectToFormData(source); 9201 } 9202 }]); 9203 return Data; 9204 }(); 9205 9206 /** 9207 * @memberOf BX 9208 */ 9209 let Http = function Http() { 9210 babelHelpers.classCallCheck(this, Http); 9211 }; 9212 babelHelpers.defineProperty(Http, "Cookie", Cookie); 9213 babelHelpers.defineProperty(Http, "Data", Data); 9214 9215 function message(value) { 9216 if (Type.isString(value)) { 9217 if (Type.isNil(message[value])) { 9218 // eslint-disable-next-line 9219 EventEmitter.emit('onBXMessageNotFound', new BaseEvent({ 9220 compatData: [value] 9221 })); 9222 if (Type.isNil(message[value])) { 9223 Runtime.debug(`message undefined: ${value}`); 9224 message[value] = ''; 9225 } 9226 } 9227 } 9228 if (Type.isPlainObject(value)) { 9229 Object.keys(value).forEach(key => { 9230 message[key] = value[key]; 9231 }); 9232 } 9233 return message[value]; 9234 } 9235 if (!Type.isNil(window.BX) && Type.isFunction(window.BX.message)) { 9236 Object.keys(window.BX.message).forEach(key => { 9237 message({ 9238 [key]: window.BX.message[key] 9239 }); 9240 }); 9241 } 9242 9243 /** 9244 * Implements interface for works with language messages 9245 * @memberOf BX 9246 */ 9247 let Loc = /*#__PURE__*/function () { 9248 function Loc() { 9249 babelHelpers.classCallCheck(this, Loc); 9250 } 9251 babelHelpers.createClass(Loc, null, [{ 9252 key: "getMessage", 9253 /** 9254 * Gets message by id 9255 * @param {string} messageId 9256 * @param {object} replacements 9257 * @return {?string} 9258 */ 9259 value: function getMessage(messageId, replacements = null) { 9260 let mess = message(messageId); 9261 if (Type.isString(mess) && Type.isPlainObject(replacements)) { 9262 const escape = str => String(str).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&'); 9263 Object.keys(replacements).forEach(replacement => { 9264 const globalRegexp = new RegExp(escape(replacement), 'gi'); 9265 mess = mess.replace(globalRegexp, () => { 9266 return Type.isNil(replacements[replacement]) ? '' : String(replacements[replacement]); 9267 }); 9268 }); 9269 } 9270 return mess; 9271 } 9272 }, { 9273 key: "hasMessage", 9274 value: function hasMessage(messageId) { 9275 return Type.isString(messageId) && !Type.isNil(message[messageId]); 9276 } 9277 /** 9278 * Sets message or messages 9279 * @param {string | Object<string, string>} id 9280 * @param {string} [value] 9281 */ 9282 }, { 9283 key: "setMessage", 9284 value: function setMessage(id, value) { 9285 if (Type.isString(id) && Type.isString(value)) { 9286 message({ 9287 [id]: value 9288 }); 9289 } 9290 if (Type.isObject(id)) { 9291 message(id); 9292 } 9293 } 9294 /** 9295 * Gets plural message by id and number 9296 * @param {string} messageId 9297 * @param {number} value 9298 * @param {object} [replacements] 9299 * @return {?string} 9300 */ 9301 }, { 9302 key: "getMessagePlural",
9303 value: function getMessagePlural(messageId, value, replacements = null) { 9304 let result = ''; 9305 if (Type.isNumber(value)) { 9306 if (this.hasMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`)) { 9307 result = this.getMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`, replacements); 9308 } else { 9309 result = this.getMessage(`${messageId}_PLURAL_1`, replacements); 9310 } 9311 } else { 9312 result = this.getMessage(messageId, replacements); 9313 } 9314 return result; 9315 } 9316 /** 9317 * Gets language plural form id by number 9318 * see http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html 9319 * @param {number} value 9320 * @param {string} [languageId] 9321 * @return {?number} 9322 */ 9323 }, { 9324 key: "getPluralForm", 9325 value: function getPluralForm(value, languageId) { 9326 let pluralForm; 9327 if (!Type.isStringFilled(languageId)) { 9328 languageId = message('LANGUAGE_ID'); 9329 } 9330 if (value < 0) { 9331 value = -1 * value; 9332 } 9333 switch (languageId) { 9334 case 'ar': 9335 pluralForm = value !== 1 ? 1 : 0; 9336 /* 9337 if (value === 0) 9338 { 9339 pluralForm = 0; 9340 } 9341 else if (value === 1) 9342 { 9343 pluralForm = 1; 9344 } 9345 else if (value === 2) 9346 { 9347 pluralForm = 2; 9348 } 9349 else if ( 9350 value % 100 >= 3 9351 && value % 100 <= 10 9352 ) 9353 { 9354 pluralForm = 3; 9355 } 9356 else if (value % 100 >= 11) 9357 { 9358 pluralForm = 4; 9359 } 9360 else 9361 { 9362 pluralForm = 5; 9363 } 9364 */ 9365 break; 9366 case 'br': 9367 case 'fr': 9368 case 'tr': 9369 pluralForm = value > 1 ? 1 : 0; 9370 break; 9371 case 'de': 9372 case 'en': 9373 case 'hi': 9374 case 'it': 9375 case 'la': 9376 pluralForm = value !== 1 ? 1 : 0; 9377 break; 9378 case 'ru': 9379 case 'ua': 9380 if (value % 10 === 1 && value % 100 !== 11) { 9381 pluralForm = 0; 9382 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9383 pluralForm = 1; 9384 } else { 9385 pluralForm = 2; 9386 } 9387 break; 9388 case 'pl': 9389 if (value === 1) { 9390 pluralForm = 0; 9391 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9392 pluralForm = 1; 9393 } else { 9394 pluralForm = 2; 9395 } 9396 break; 9397 case 'id': 9398 case 'ja': 9399 case 'ms': 9400 case 'sc': 9401 case 'tc': 9402 case 'th': 9403 case 'vn': 9404 pluralForm = 0; 9405 break; 9406 default: 9407 pluralForm = 1; 9408 break; 9409 } 9410 return pluralForm; 9411 } 9412 }]); 9413 return Loc; 9414 }(); 9415 9416 const voidElements = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr']; 9417 function isVoidElement(element) { 9418 return voidElements.includes(element); 9419 } 9420 9421 const matchers = { 9422 tag: /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>|{{uid[0-9]+}}/g, 9423 comment: /<!--(?!<!)[^\[>].*?-->/g, 9424 tagName: /<\/?([^\s]+?)[/\s>]/, 9425 attributes: /\s([\w\-_:.]+)\s?\n?=\s?\n?"([^"]+)?"|\s([\w\-_:.]+)\s?\n?=\s?\n?'([^']+)?'|\s([\w\-_:.]+)/gs, 9426 placeholder: /{{uid[0-9]+}}/g 9427 }; 9428 9429 function parseTag(tag) { 9430 const tagResult = { 9431 type: 'tag', 9432 name: '', 9433 svg: false, 9434 attrs: {}, 9435 children: [], 9436 voidElement: false 9437 }; 9438 if (tag.startsWith('<!--')) { 9439 const endIndex = tag.indexOf('-->'); 9440 const openTagLength = '<!--'.length; 9441 return { 9442 type: 'comment', 9443 content: endIndex !== -1 ? tag.slice(openTagLength, endIndex) : '' 9444 }; 9445 } 9446 const tagNameMatch = tag.match(matchers.tagName); 9447 if (Type.isArrayFilled(tagNameMatch)) { 9448 const [, tagName] = tagNameMatch; 9449 tagResult.name = tagName; 9450 tagResult.svg = tagName === 'svg'; 9451 tagResult.voidElement = isVoidElement(tagName) || tag.trim().endsWith('/>'); 9452 } 9453 const reg = new RegExp(matchers.attributes); 9454 for (;;) { 9455 const result = reg.exec(tag); 9456 if (!Type.isNil(result)) { 9457 // Attributes with double quotes 9458 const [, attrName, attrValue] = result; 9459 if (!Type.isNil(attrName)) { 9460 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9461 } else { 9462 // Attributes with single quotes 9463 const [,,, attrName, attrValue] = result; 9464 if (!Type.isNil(attrName)) { 9465 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9466 } else { 9467 // Attributes without value 9468 const [,,,,, attrName] = result; 9469 tagResult.attrs[attrName] = ''; 9470 } 9471 } 9472 } else { 9473 break; 9474 } 9475 } 9476 return tagResult; 9477 } 9478 9479 function parseText(input) { 9480 const preparedText = input.replace(/[\n\r\t]$/, ''); 9481 const placeholders = preparedText.match(matchers.placeholder); 9482 return preparedText.split(matchers.placeholder).reduce((acc, item, index) => { 9483 if (Type.isStringFilled(item)) { 9484 acc.push(...item.split(/\n/).reduce((textAcc, text) => { 9485 const preparedItemText = text.replace(/[\t\r]/g, ''); 9486 if (Type.isStringFilled(preparedItemText)) { 9487 textAcc.push({ 9488 type: 'text', 9489 content: preparedItemText 9490 }); 9491 } 9492 return textAcc; 9493 }, [])); 9494 } 9495 if (placeholders && placeholders[index]) { 9496 acc.push({ 9497 type: 'placeholder', 9498 uid: parseInt(placeholders[index].replace(/{{uid|}}/, '')) 9499 }); 9500 } 9501 return acc; 9502 }, []); 9503 } 9504 9505 function parse(html, substitutions) { 9506 const result = []; 9507 if (html.indexOf('<') !== 0 && !html.startsWith('{{')) { 9508 const end = html.indexOf('<'); 9509 result.push(...parseText(end === -1 ? html : html.slice(0, end))); 9510 } 9511 const commentsContent = []; 9512 let commentIndex = -1; 9513 html = html.replace(matchers.comment, tag => { 9514 commentIndex += 1; 9515 commentsContent.push(tag.replace(/^<!--|-->$/g, '')); 9516 return `<!--{{cUid${commentIndex}}}-->`; 9517 }); 9518 const arr = []; 9519 let level = -1; 9520 let current; 9521 html.replace(matchers.tag, (tag, index) => { 9522 const start = index + tag.length; 9523 const nextChar = html.charAt(start); 9524 let parent; 9525 if (tag.startsWith('<!--')) { 9526 const comment = parseTag(tag, substitutions); 9527 comment.content = commentsContent[tag.replace(/<!--{{cUid|}}-->/g, '')]; 9528 if (level < 0) { 9529 result.push(comment); 9530 return result; 9531 } 9532 parent = arr[level]; 9533 parent.children.push(comment); 9534 return result; 9535 } 9536 if (tag.startsWith('{{')) { 9537 const [placeholder] = parseText(tag); 9538 if (level < 0) { 9539 result.push(placeholder); 9540 return result; 9541 } 9542 parent = arr[level]; 9543 parent.children.push(placeholder); 9544 return result; 9545 } 9546 if (!tag.startsWith('</')) { 9547 level++; 9548 current = parseTag(tag, substitutions); 9549 if (!current.voidElement && nextChar && nextChar !== '<') { 9550 current.children.push(...parseText(html.slice(start, html.indexOf('<', start)))); 9551 } 9552 if (level === 0) { 9553 result.push(current); 9554 } 9555 parent = arr[level - 1]; 9556 if (parent) { 9557 if (!current.svg) { 9558 current.svg = parent.svg; 9559 } 9560 parent.children.push(current); 9561 } 9562 arr[level] = current; 9563 } 9564 if (tag.startsWith('</') || current.voidElement) { 9565 if (level > -1 && (current.voidElement || current.name === tag.slice(2, -1))) { 9566 level--; 9567 current = level === -1 ? result : arr[level]; 9568 } 9569 if (nextChar && nextChar !== '<') { 9570 parent = level === -1 ? result : arr[level].children; 9571 const end = html.indexOf('<', start); 9572 const content = html.slice(start, end === -1 ? undefined : end); 9573 if (end >
9573 -1 && level + parent.length >= 0 || content !== ' ') { 9574 parent.push(...parseText(content)); 9575 } 9576 } 9577 } 9578 }); 9579 return result; 9580 } 9581 9582 const appendElement = (current, target) => { 9583 if (Type.isDomNode(current) && Type.isDomNode(target)) { 9584 if (target.nodeName !== 'TEMPLATE') { 9585 Dom.append(current, target); 9586 } else { 9587 // eslint-disable-next-line bitrix-rules/no-native-dom-methods 9588 target.content.append(current); 9589 } 9590 } 9591 }; 9592 function renderNode(options) { 9593 const { 9594 node, 9595 parentElement, 9596 substitutions, 9597 refs = [] 9598 } = options; 9599 if (node.type === 'tag') { 9600 const element = (() => { 9601 if (node.svg) { 9602 return document.createElementNS('http://www.w3.org/2000/svg', node.name); 9603 } 9604 return document.createElement(node.name); 9605 })(); 9606 if (Object.hasOwn(node.attrs, 'ref')) { 9607 refs.push([node.attrs.ref, element]); 9608 delete node.attrs.ref; 9609 } 9610 Object.entries(node.attrs).forEach(([key, value]) => { 9611 if (key.startsWith('on') && new RegExp(matchers.placeholder).test(value)) { 9612 const substitution = substitutions[parseInt(value.replace(/{{uid|}}/, '')) - 1]; 9613 if (Type.isFunction(substitution)) { 9614 const bindFunctionName = key.endsWith('once') ? 'bindOnce' : 'bind'; 9615 Event[bindFunctionName](element, key.replace(/^on|once$/g, ''), substitution); 9616 } else { 9617 element.setAttribute(key, substitution); 9618 } 9619 } else { 9620 if (new RegExp(matchers.placeholder).test(value)) { 9621 const preparedValue = value.split(/{{|}}/).reduce((acc, item) => { 9622 if (item.startsWith('uid')) { 9623 const substitution = substitutions[parseInt(item.replace('uid', '')) - 1]; 9624 return `${acc}${substitution}`; 9625 } 9626 return `${acc}${item}`; 9627 }, ''); 9628 element.setAttribute(key, preparedValue); 9629 } else { 9630 element.setAttribute(key, Text.decode(value)); 9631 } 9632 } 9633 }); 9634 node.children.forEach(childNode => { 9635 const result = renderNode({ 9636 node: childNode, 9637 parentElement: element, 9638 substitutions, 9639 refs 9640 }); 9641 if (Type.isArray(result)) { 9642 result.forEach(subChildElement => { 9643 appendElement(subChildElement, element); 9644 }); 9645 } else { 9646 appendElement(result, element); 9647 } 9648 }); 9649 return element; 9650 } 9651 if (node.type === 'comment') { 9652 return document.createComment(node.content); 9653 } 9654 if (node.type === 'text') { 9655 if (parentElement) { 9656 if (parentElement.nodeName !== 'TEMPLATE') { 9657 parentElement.insertAdjacentHTML('beforeend', node.content); 9658 } else { 9659 parentElement.content.append(node.content); 9660 } 9661 return; 9662 } 9663 return document.createTextNode(node.content); 9664 } 9665 if (node.type === 'placeholder') { 9666 return substitutions[node.uid - 1]; 9667 } 9668 } 9669 9670 function render(sections, ...substitutions) { 9671 const html = sections.reduce((acc, item, index) => { 9672 if (index > 0) { 9673 const substitution = substitutions[index - 1]; 9674 if (Type.isString(substitution) || Type.isNumber(substitution)) { 9675 return `${acc}${substitution}${item}`; 9676 } 9677 return `${acc}{{uid${index}}}${item}`; 9678 } 9679 return acc; 9680 }, sections[0]).replace(/^[\r\n\t\s]+/gm, '').replace(/>[\n]+/g, '>').replace(/[}][\n]+/g, '}'); 9681 const ast = parse(html); 9682 if (ast.length === 1) { 9683 const refs = []; 9684 const renderedNode = renderNode({ 9685 node: ast[0], 9686 substitutions, 9687 refs 9688 }); 9689 if (Type.isArrayFilled(refs)) { 9690 return Object.fromEntries([['root', renderedNode], ...refs]); 9691 } 9692 return renderedNode; 9693 } 9694 if (ast.length > 1) { 9695 const refs = []; 9696 const renderedNodes = ast.map(node => { 9697 return renderNode({ 9698 node, 9699 substitutions, 9700 refs 9701 }); 9702 }); 9703 if (Type.isArrayFilled(refs)) { 9704 return Object.fromEntries([['root', renderedNodes], ...refs]); 9705 } 9706 return renderedNodes; 9707 } 9708 return false;
9709 } 9710 9711 function parseProps(sections, ...substitutions) { 9712 return substitutions.reduce((acc, item, index) => { 9713 const nextSectionIndex = index + 1; 9714 if (!Type.isPlainObject(item) && !Type.isArray(item)) { 9715 return acc + item + sections[nextSectionIndex]; 9716 } 9717 return `${acc}__s${index}${sections[nextSectionIndex]}`; 9718 }, sections[0]).replace(/[\r\t]/gm, '').split(';\n').map(item => item.replace(/\n/, '')).reduce((acc, item) => { 9719 if (item !== '') { 9720 const matches = item.match(/^[\w-. ]+:/); 9721 const splitted = item.split(/^[\w-. ]+:/); 9722 const key = matches[0].replace(':', '').trim(); 9723 const value = splitted[1].trim(); 9724 const substitutionPlaceholderExp = /^__s\d+/; 9725 if (substitutionPlaceholderExp.test(value)) { 9726 acc[key] = substitutions[value.replace('__s', '')]; 9727 return acc; 9728 } 9729 acc[key] = value; 9730 } 9731 return acc; 9732 }, {}); 9733 } 9734 9735 /** 9736 * @memberOf BX 9737 */ 9738 let Tag = /*#__PURE__*/function () { 9739 function Tag() { 9740 babelHelpers.classCallCheck(this, Tag); 9741 } 9742 babelHelpers.createClass(Tag, null, [{ 9743 key: "safe", 9744 /** 9745 * Encodes all substitutions 9746 * @param sections 9747 * @param substitutions 9748 * @return {string} 9749 */ 9750 value: function safe(sections, ...substitutions) { 9751 return substitutions.reduce((acc, item, index) => acc + Text.encode(item) + sections[index + 1], sections[0]); 9752 } 9753 /** 9754 * Decodes all substitutions 9755 * @param sections 9756 * @param substitutions 9757 * @return {string} 9758 */ 9759 }, { 9760 key: "unsafe", 9761 value: function unsafe(sections, ...substitutions) { 9762 return substitutions.reduce((acc, item, index) => acc + Text.decode(item) + sections[index + 1], sections[0]); 9763 } 9764 /** 9765 * Adds styles to specified element 9766 * @param {HTMLElement} element 9767 * @return {Function} 9768 */ 9769 }, { 9770 key: "style", 9771 value: function style(element) { 9772 if (!Type.isDomNode(element)) { 9773 throw new Error('element is not HTMLElement'); 9774 } 9775 return function styleTagHandler(...args) { 9776 Dom.style(element, parseProps(...args)); 9777 }; 9778 } 9779 /** 9780 * Replace all messages identifiers to real messages 9781 * @param sections 9782 * @param substitutions 9783 * @return {string} 9784 */ 9785 }, { 9786 key: "message", 9787 value: function message(sections, ...substitutions) { 9788 return substitutions.reduce((acc, item, index) => acc + Loc.getMessage(item) + sections[index + 1], sections[0]); 9789 } 9790 }, { 9791 key: "attrs", 9792 /** 9793 * Adds attributes to specified element 9794 * @param element 9795 * @return {Function} 9796 */ 9797 value: function attrs(element) { 9798 if (!Type.isDomNode(element)) { 9799 throw new Error('element is not HTMLElement'); 9800 } 9801 return function attrsTagHandler(...args) { 9802 Dom.attr(element, parseProps(...args)); 9803 }; 9804 } 9805 }]); 9806 return Tag; 9807 }(); 9808 babelHelpers.defineProperty(Tag, "render", render); 9809 babelHelpers.defineProperty(Tag, "attr", Tag.attrs); 9810 9811 function getParser(format) { 9812 switch (format) { 9813 case 'index': 9814 return (sourceKey, value, accumulator) => { 9815 const result = /\[(\w*)\]$/.exec(sourceKey); 9816 const key = sourceKey.replace(/\[\w*\]$/, ''); 9817 if (Type.isNil(result)) { 9818 accumulator[key] = value; 9819 return; 9820 } 9821 if (Type.isUndefined(accumulator[key])) { 9822 accumulator[key] = {}; 9823 } 9824 accumulator[key][result[1]] = value; 9825 }; 9826 case 'bracket': 9827 return (sourceKey, value, accumulator) => { 9828 const result = /(\[\])$/.exec(sourceKey); 9829 const key = sourceKey.replace(/\[\]$/, ''); 9830 if (Type.isNil(result)) { 9831 accumulator[key] = value; 9832 return; 9833 } 9834 if (Type.isUndefined(accumulator[key])) { 9835 accumulator[key] = [value]; 9836 return; 9837 } 9838 accumulator[key] = [].concat(accumulator[key], value); 9839 }; 9840 default: 9841 return (sourceKey, value, accumulator) => {
9842 const key = sourceKey.replace(/\[\]$/, ''); 9843 accumulator[key] = value; 9844 }; 9845 } 9846 } 9847 function getKeyFormat(key) { 9848 if (/^\w+\[([\w]+)\]$/.test(key)) { 9849 return 'index'; 9850 } 9851 if (/^\w+\[\]$/.test(key)) { 9852 return 'bracket'; 9853 } 9854 return 'default'; 9855 } 9856 function isAllowedKey(key) { 9857 return !String(key).startsWith('__proto__'); 9858 } 9859 function parseQuery(input) { 9860 if (!Type.isString(input)) { 9861 return {}; 9862 } 9863 const url = input.trim().replace(/^[?#&]/, ''); 9864 if (!url) { 9865 return {}; 9866 } 9867 return { 9868 ...url.split('&').reduce((acc, param) => { 9869 const [key, value] = param.replace(/\+/g, ' ').split('='); 9870 if (isAllowedKey(key)) { 9871 const keyFormat = getKeyFormat(key); 9872 const formatter = getParser(keyFormat); 9873 formatter(key, value, acc); 9874 } 9875 return acc; 9876 }, Object.create(null)) 9877 }; 9878 } 9879 const urlExp = /^((\w+):)?(\/\/((\w+)?(:(\w+))?@)?([^\/\?:]+)(:(\d+))?)?(\/?([^\/\?#][^\?#]*)?)?(\?([^#]+))?(#(\w*))?/; 9880 function parseUrl(url) { 9881 const result = url.match(urlExp); 9882 if (Type.isArray(result)) { 9883 const queryParams = parseQuery(result[14]); 9884 return { 9885 useShort: /^\/\//.test(url), 9886 href: result[0] || '', 9887 schema: result[2] || '', 9888 host: result[8] || '', 9889 port: result[10] || '', 9890 path: result[11] || '', 9891 query: result[14] || '', 9892 queryParams, 9893 hash: result[16] || '', 9894 username: result[5] || '', 9895 password: result[7] || '', 9896 origin: result[8] || '' 9897 }; 9898 } 9899 return {}; 9900 } 9901 9902 function buildQueryString(params = {}) { 9903 const queryString = Object.keys(params).reduce((acc, key) => { 9904 if (Type.isArray(params[key])) { 9905 params[key].forEach(paramValue => { 9906 acc.push(`${key}[]=${paramValue}`); 9907 }, ''); 9908 } 9909 if (Type.isPlainObject(params[key])) { 9910 Object.keys(params[key]).forEach(paramIndex => { 9911 acc.push(`${key}[${paramIndex}]=${params[key][paramIndex]}`); 9912 }, ''); 9913 } 9914 if (!Type.isObject(params[key]) && !Type.isArray(params[key])) { 9915 acc.push(`${key}=${params[key]}`); 9916 } 9917 return acc; 9918 }, []).join('&'); 9919 if (queryString.length > 0) { 9920 return `?${queryString}`; 9921 } 9922 return queryString; 9923 } 9924 9925 function prepareParamValue(value) { 9926 if (Type.isArray(value)) { 9927 return value.map(item => String(item)); 9928 } 9929 if (Type.isPlainObject(value)) { 9930 return { 9931 ...value 9932 }; 9933 } 9934 return String(value); 9935 } 9936 9937 const map = new WeakMap(); 9938 9939 /** 9940 * Implements interface for works with URI 9941 * @memberOf BX 9942 */ 9943 let Uri = /*#__PURE__*/function () { 9944 babelHelpers.createClass(Uri, null, [{ 9945 key: "addParam", 9946 value: function addParam(url, params = {}) { 9947 return new Uri(url).setQueryParams(params).toString(); 9948 } 9949 }, { 9950 key: "removeParam", 9951 value: function removeParam(url, params) { 9952 const removableParams = Type.isArray(params) ? params : [params]; 9953 return new Uri(url).removeQueryParam(...removableParams).toString(); 9954 } 9955 }]); 9956 function Uri(url = '') { 9957 babelHelpers.classCallCheck(this, Uri); 9958 map.set(this, parseUrl(url)); 9959 } 9960 9961 /** 9962 * Gets schema 9963 * @return {?string} 9964 */ 9965 babelHelpers.createClass(Uri, [{ 9966 key: "getSchema", 9967 value: function getSchema() { 9968 return map.get(this).schema; 9969 } 9970 /** 9971 * Sets schema 9972 * @param {string} schema 9973 * @return {Uri} 9974 */ 9975 }, { 9976 key: "setSchema", 9977 value: function setSchema(schema) { 9978 map.get(this).schema = String(schema); 9979 return this; 9980 } 9981 /** 9982 * Gets host 9983 * @return {?string} 9984 */ 9985 }, { 9986 key: "getHost", 9987 value: function getHost() { 9988 return map.get(this).host; 9989 } 9990 /** 9991 * Sets host 9992 * @param {string} host 9993 * @return {Uri} 9994 */ 9995 }, { 9996 key: "setHost", 9997 value: function setHost(host) { 9998 map.get(this).host = String(host); 9999 return this; 10000 } 10001 /** 10002 * Gets port 10003 * @return {?string} 10004 */ 10005 }, { 10006 key: "getPort", 10007 value: function getPort() { 10008 return map.get(this).port; 10009 } 10010 /** 10011 * Sets port 10012 * @param {String | Number} port 10013 * @return {Uri} 10014 */ 10015 }, { 10016 key: "setPort", 10017 value: function setPort(port) { 10018 map.get(this).port = String(port); 10019 return this; 10020 } 10021 /** 10022 * Gets path 10023 * @return {?string} 10024 */ 10025 }, { 10026 key: "getPath", 10027 value: function getPath() { 10028 return map.get(this).path; 10029 } 10030 /** 10031 * Sets path 10032 * @param {string} path 10033 * @return {Uri} 10034 */ 10035 }, { 10036 key: "setPath", 10037 value: function setPath(path) { 10038 if (!/^\//.test(path)) {
10039 map.get(this).path = `/${String(path)}`; 10040 return this; 10041 } 10042 map.get(this).path = String(path); 10043 return this; 10044 } 10045 /** 10046 * Gets query 10047 * @return {?string} 10048 */ 10049 }, { 10050 key: "getQuery", 10051 value: function getQuery() { 10052 return buildQueryString(map.get(this).queryParams); 10053 } 10054 /** 10055 * Gets query param value by name 10056 * @param {string} key 10057 * @return {?string} 10058 */ 10059 }, { 10060 key: "getQueryParam", 10061 value: function getQueryParam(key) { 10062 const params = this.getQueryParams(); 10063 if (Object.hasOwn(params, key)) { 10064 return params[key]; 10065 } 10066 return null; 10067 } 10068 /** 10069 * Sets query param 10070 * @param {string} key 10071 * @param [value] 10072 * @return {Uri} 10073 */ 10074 }, { 10075 key: "setQueryParam", 10076 value: function setQueryParam(key, value = '') { 10077 map.get(this).queryParams[key] = prepareParamValue(value); 10078 return this; 10079 } 10080 /** 10081 * Gets query params 10082 * @return {Object<string, any>} 10083 */ 10084 }, { 10085 key: "getQueryParams", 10086 value: function getQueryParams() { 10087 return { 10088 ...map.get(this).queryParams 10089 }; 10090 } 10091 /** 10092 * Sets query params 10093 * @param {Object<string, any>} params 10094 * @return {Uri} 10095 */ 10096 }, { 10097 key: "setQueryParams", 10098 value: function setQueryParams(params = {}) { 10099 const currentParams = this.getQueryParams(); 10100 const newParams = { 10101 ...currentParams, 10102 ...params 10103 }; 10104 Object.keys(newParams).forEach(key => { 10105 newParams[key] = prepareParamValue(newParams[key]); 10106 }); 10107 map.get(this).queryParams = newParams; 10108 return this; 10109 } 10110 /** 10111 * Removes query params by name 10112 * @param keys 10113 * @return {Uri} 10114 */ 10115 }, { 10116 key: "removeQueryParam", 10117 value: function removeQueryParam(...keys) { 10118 const currentParams = { 10119 ...map.get(this).queryParams 10120 }; 10121 keys.forEach(key => { 10122 if (Object.hasOwn(currentParams, key)) { 10123 delete currentParams[key]; 10124 } 10125 }); 10126 map.get(this).queryParams = currentParams; 10127 return this; 10128 } 10129 /** 10130 * Gets fragment 10131 * @return {?string} 10132 */ 10133 }, { 10134 key: "getFragment", 10135 value: function getFragment() { 10136 return map.get(this).hash; 10137 } 10138 /** 10139 * Sets fragment 10140 * @param {string} hash 10141 * @return {Uri} 10142 */ 10143 }, { 10144 key: "setFragment", 10145 value: function setFragment(hash) { 10146 map.get(this).hash = String(hash); 10147 return this; 10148 } 10149 /** 10150 * Serializes URI 10151 * @return {Object} 10152 */ 10153 }, { 10154 key: "serialize", 10155 value: function serialize() { 10156 const serialized = { 10157 ...map.get(this) 10158 }; 10159 serialized.href = this.toString(); 10160 return serialized; 10161 } 10162 /** 10163 * Gets URI string 10164 * @return {string} 10165 */ 10166 }, { 10167 key: "toString", 10168 value: function toString() { 10169 const data = { 10170 ...map.get(this) 10171 }; 10172 let protocol = data.schema ? `${data.schema}://` : ''; 10173 if (data.useShort) { 10174 protocol = '//'; 10175 } 10176 const port = (() => { 10177 if (Type.isString(data.port) && !['', '80'].includes(data.port)) { 10178 return `:${data.port}`; 10179 } 10180 return ''; 10181 })(); 10182 const host = this.getHost(); 10183 const path = this.getPath(); 10184 const query = buildQueryString(data.queryParams); 10185 const hash = data.hash ? `#${data.hash}` : ''; 10186 return `${host ? protocol : ''}${host}${host ? port : ''}${path}${query}${hash}`; 10187 } 10188 }]); 10189 return Uri; 10190 }(); 10191 10192 /** 10193 * @memberOf BX 10194 */ 10195 let Validation = /*#__PURE__*/function () { 10196 function Validation() { 10197 babelHelpers.classCallCheck(this, Validation); 10198 } 10199 babelHelpers.createClass(Validation, null, [{ 10200 key: "isEmail", 10201 /** 10202 * Checks that value is valid email 10203 * @param value 10204 * @return {boolean} 10205 */ 10206 value: function isEmail(value) { 10207 const 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])?)*$/; 10208 return exp.test(String(value).toLowerCase()); 10209 } 10210 }]); 10211 return Validation; 10212 }(); 10213 10214 let BaseCache = /*#__PURE__*/function () { 10215 function BaseCache() { 10216 babelHelpers.classCallCheck(this, BaseCache); 10217 babelHelpers.defineProperty(this, "storage", new Map()); 10218 } 10219 babelHelpers.createClass(BaseCache, [{ 10220 key: "get", 10221 /** 10222 * Gets cached value or default value 10223 */ 10224 value: function get(key, defaultValue) { 10225 if (!this.storage.has(key)) { 10226 if (Type.isFunction(defaultValue)) { 10227 return defaultValue(); 10228 } 10229 if (!Type.isUndefined(defaultValue)) { 10230 return defaultValue; 10231 } 10232 } 10233 return this.storage.get(key); 10234 } 10235 /**
10236 * Sets cache entry 10237 */ 10238 }, { 10239 key: "set", 10240 value: function set(key, value) { 10241 this.storage.set(key, value); 10242 } 10243 /** 10244 * Deletes cache entry 10245 */ 10246 }, { 10247 key: "delete", 10248 value: function _delete(key) { 10249 this.storage.delete(key); 10250 } 10251 /** 10252 * Checks that storage contains entry with specified key 10253 */ 10254 }, { 10255 key: "has", 10256 value: function has(key) { 10257 return this.storage.has(key); 10258 } 10259 /** 10260 * Gets cached value if exists, 10261 */ 10262 }, { 10263 key: "remember", 10264 value: function remember(key, defaultValue) { 10265 if (!this.storage.has(key)) { 10266 if (Type.isFunction(defaultValue)) { 10267 this.storage.set(key, defaultValue()); 10268 } else if (!Type.isUndefined(defaultValue)) { 10269 this.storage.set(key, defaultValue); 10270 } 10271 } 10272 return this.storage.get(key); 10273 } 10274 /** 10275 * Gets storage size 10276 */ 10277 }, { 10278 key: "size", 10279 value: function size() { 10280 return this.storage.size; 10281 } 10282 /** 10283 * Gets storage keys 10284 */ 10285 }, { 10286 key: "keys", 10287 value: function keys() { 10288 return [...this.storage.keys()]; 10289 } 10290 /** 10291 * Gets storage values 10292 */ 10293 }, { 10294 key: "values", 10295 value: function values() { 10296 return [...this.storage.values()]; 10297 } 10298 }]); 10299 return BaseCache; 10300 }(); 10301 10302 let MemoryCache = /*#__PURE__*/function (_BaseCache) { 10303 babelHelpers.inherits(MemoryCache, _BaseCache); 10304 function MemoryCache(...args) { 10305 var _this; 10306 babelHelpers.classCallCheck(this, MemoryCache); 10307 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(MemoryCache).call(this, ...args)); 10308 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new Map()); 10309 return _this; 10310 } 10311 return MemoryCache; 10312 }(BaseCache); 10313 10314 let LsStorage = /*#__PURE__*/function () { 10315 function LsStorage() { 10316 babelHelpers.classCallCheck(this, LsStorage); 10317 babelHelpers.defineProperty(this, "stackKey", 'BX.Cache.Storage.LsStorage.stack'); 10318 babelHelpers.defineProperty(this, "stack", null); 10319 } 10320 babelHelpers.createClass(LsStorage, [{ 10321 key: "getStack", 10322 /** 10323 * @private 10324 */ 10325 value: function getStack() { 10326 if (Type.isPlainObject(this.stack)) { 10327 return this.stack; 10328 } 10329 const stack = localStorage.getItem(this.stackKey); 10330 if (Type.isString(stack) && stack !== '') { 10331 const parsedStack = JSON.parse(stack); 10332 if (Type.isPlainObject(parsedStack)) { 10333 this.stack = parsedStack; 10334 return this.stack; 10335 } 10336 } 10337 this.stack = {}; 10338 return this.stack; 10339 } 10340 /** 10341 * @private 10342 */ 10343 }, { 10344 key: "saveStack", 10345 value: function saveStack() { 10346 if (Type.isPlainObject(this.stack)) { 10347 const preparedStack = JSON.stringify(this.stack); 10348 localStorage.setItem(this.stackKey, preparedStack); 10349 } 10350 } 10351 }, { 10352 key: "get", 10353 value: function get(key) { 10354 const stack = this.getStack(); 10355 return stack[key]; 10356 } 10357 }, { 10358 key: "set", 10359 value: function set(key, value) { 10360 const stack = this.getStack(); 10361 stack[key] = value; 10362 this.saveStack(); 10363 } 10364 }, { 10365 key: "delete", 10366 value: function _delete(key) { 10367 const stack = this.getStack(); 10368 if (key in stack) { 10369 delete stack[key]; 10370 } 10371 } 10372 }, { 10373 key: "has", 10374 value: function has(key) { 10375 const stack = this.getStack(); 10376 return key in stack; 10377 } 10378 }, { 10379 key: "keys", 10380 value: function keys() { 10381 const stack = this.getStack(); 10382 return Object.keys(stack); 10383 } 10384 }, { 10385 key: "values", 10386 value: function values() { 10387 const stack = this.getStack(); 10388 return Object.values(stack); 10389 } 10390 }, { 10391 key: "size", 10392 get: function () { 10393 const stack = this.getStack(); 10394 return Object.keys(stack).length; 10395 } 10396 }]); 10397 return LsStorage; 10398 }(); 10399 10400 let LocalStorageCache = /*#__PURE__*/function (_BaseCache) { 10401 babelHelpers.inherits(LocalStorageCache, _BaseCache); 10402 function LocalStorageCache(...args) { 10403 var _this; 10404 babelHelpers.classCallCheck(this, LocalStorageCache); 10405 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(LocalStorageCache).call(this, ...args)); 10406 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new LsStorage()); 10407 return _this; 10408 } 10409 return LocalStorageCache; 10410 }(BaseCache); 10411 10412 /** 10413 * @memberOf BX 10414 */ 10415 let Cache = function Cache() { 10416 babelHelpers.classCallCheck(this, Cache); 10417 }; 10418 babelHelpers.defineProperty(Cache, "MemoryCache", MemoryCache); 10419 babelHelpers.defineProperty(Cache, "LocalStorageCache", LocalStorageCache); 10420 10421 function convertPath(path) { 10422 if (Type.isStringFilled(path)) { 10423 return path.split('.').reduce((acc, item) => { 10424 item.split(/\[['"]?(.+?)['"]?\]/g).forEach(key => { 10425 if (Type.isStringFilled(key)) { 10426 acc.push(key); 10427 } 10428 }); 10429 return acc; 10430 }, []); 10431 } 10432 return []; 10433 } 10434 10435 let SettingsCollection = /*#__PURE__*/function () { 10436 function SettingsCollection(options = {}) { 10437 babelHelpers.classCallCheck(this, SettingsCollection); 10438 if (Type.isPlainObject(options)) { 10439 Object.assign(this, options); 10440 } 10441 } 10442 babelHelpers.createClass(SettingsCollection, [{ 10443 key: "get", 10444 value: function get(path, defaultValue = null) { 10445 const convertedPath = convertPath(path); 10446 return convertedPath.reduce((acc, key) => { 10447 if (!Type.isNil(acc) && acc !== defaultValue) { 10448 if (!Type.isUndefined(acc[key])) { 10449 return acc[key]; 10450 } 10451 return defaultValue; 10452 } 10453 return acc; 10454 }, this); 10455 } 10456 }]); 10457 return SettingsCollection; 10458 }(); 10459 10460 function deepFreeze(target) { 10461 if (Type.isObject(target)) { 10462 Object.values(target).forEach(value => { 10463 deepFreeze(value); 10464 }); 10465 return Object.freeze(target); 10466 } 10467 return target; 10468 } 10469 10470 const settingsStorage = new Map(); 10471 let Extension$1 = /*#__PURE__*/function () { 10472 function Extension() { 10473 babelHelpers.classCallCheck(this, Extension); 10474 } 10475 babelHelpers.createClass(Extension, null, [{ 10476 key: "getSettings", 10477 value: function getSettings(extensionName) { 10478 if (Type.isStringFilled(extensionName)) { 10479 if (settingsStorage.has(extensionName)) { 10480 return settingsStorage.get(extensionName); 10481 } 10482 const settingsScriptNode = document.querySelector(`script[data-extension="${extensionName}"]`); 10483 if (Type.isDomNode(settingsScriptNode)) { 10484 const decodedSettings = (() => { 10485 try { 10486 return new SettingsCollection(JSON.parse(settingsScriptNode.innerHTML)); 10487 } catch (error) { 10488 return new SettingsCollection(); 10489 } 10490 })(); 10491 const frozenSettings = deepFreeze(decodedSettings); 10492 settingsStorage.set(extensionName, frozenSettings); 10493 return frozenSettings; 10494 } 10495 } 10496 return deepFreeze(new SettingsCollection()); 10497 } 10498 }]); 10499 return Extension; 10500 }(); 10501 10502 let _Symbol$iterator; 10503 function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); } 10504 function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 10505 function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 10506 var _searchIndexToInsert = /*#__PURE__*/new WeakSet(); 10507 _Symbol$iterator = Symbol.iterator; 10508 let OrderedArray = /*#__PURE__*/function () { 10509 function OrderedArray(comparator = null) { 10510 babelHelpers.classCallCheck(this, OrderedArray); 10511 _classPrivateMethodInitSpec(this, _searchIndexToInsert); 10512 babelHelpers.defineProperty(this, "comparator", null); 10513 babelHelpers.defineProperty(this, "items", []); 10514 this.comparator = Type.isFunction(comparator) ? comparator : null; 10515 } 10516 babelHelpers.createClass(OrderedArray, [{ 10517 key: "add", 10518 value: function add(item) { 10519 let index = -1; 10520 if (this.comparator) { 10521 index = _classPrivateMethodGet(this, _searchIndexToInsert, _searchIndexToInsert2).call(this, item); 10522 this.items.splice(index, 0, item); 10523 } else { 10524 this.items.push(item); 10525 } 10526 return index; 10527 } 10528 }, { 10529 key: "has", 10530 value: function has(item) { 10531 return this.items.includes(item); 10532 } 10533 }, { 10534 key: "getIndex", 10535 value: function getIndex(item) { 10536 return this.items.indexOf(item); 10537 } 10538 }, { 10539 key: "getByIndex", 10540 value: function getByIndex(index) { 10541 if (Type.isNumber(index) && index >= 0) { 10542 const item = this.items[index]; 10543 return Type.isUndefined(item) ? null : item; 10544 } 10545 return null; 10546 } 10547 }, { 10548 key: "getFirst", 10549 value: function getFirst() { 10550 const first = this.items[0]; 10551 return Type.isUndefined(first) ? null : first; 10552 } 10553 }, { 10554 key: "getLast", 10555 value: function getLast() { 10556 const last = this.items[this.count() - 1]; 10557 return Type.isUndefined(last) ? null : last; 10558 } 10559 }, { 10560 key: "count", 10561 value: function count() { 10562 return this.items.length; 10563 } 10564 }, { 10565 key: "delete", 10566 value: function _delete(item) { 10567 const index = this.getIndex(item); 10568 if (index !== -1) { 10569 this.items.splice(index, 1); 10570 return true; 10571 } 10572 return false;
10573 } 10574 }, { 10575 key: "clear", 10576 value: function clear() { 10577 this.items = []; 10578 } 10579 }, { 10580 key: _Symbol$iterator, 10581 value: function () { 10582 return this.items[Symbol.iterator](); 10583 } 10584 }, { 10585 key: "forEach", 10586 value: function forEach(callbackfn, thisArg) { 10587 return this.items.forEach(callbackfn, thisArg); 10588 } 10589 }, { 10590 key: "getAll", 10591 value: function getAll() { 10592 return this.items; 10593 } 10594 }, { 10595 key: "getComparator", 10596 value: function getComparator() { 10597 return this.comparator; 10598 } 10599 }, { 10600 key: "sort", 10601 value: function sort() { 10602 const comparator = this.getComparator(); 10603 if (comparator === null) { 10604 return; 10605 } 10606 10607 /* 10608 Simple implementation 10609 this.items.sort((item1, item2) => { 10610 return comparator(item1, item2); 10611 }); 10612 */ 10613 10614 // For stable sorting https://v8.dev/features/stable-sort 10615 const length = this.items.length; 10616 const indexes = new Array(length); 10617 for (let i = 0; i < length; i++) { 10618 indexes[i] = i; 10619 } 10620 10621 // If the comparator returns zero, use the original indexes 10622 indexes.sort((index1, index2) => { 10623 return comparator(this.items[index1], this.items[index2]) || index1 - index2; 10624 }); 10625 for (let i = 0; i < length; i++) { 10626 indexes[i] = this.items[indexes[i]]; 10627 } 10628 for (let i = 0; i < length; i++) { 10629 this.items[i] = indexes[i]; 10630 } 10631 } 10632 }]); 10633 return OrderedArray; 10634 }(); 10635 function _searchIndexToInsert2(value) { 10636 let low = 0; 10637 let high = this.items.length; 10638 while (low < high) { 10639 const mid = Math.floor((low + high) / 2); 10640 if (this.comparator(this.items[mid], value) >= 0) { 10641 high = mid; 10642 } else { 10643 low = mid + 1; 10644 } 10645 } 10646 return low; 10647 } 10648 10649 let ZIndexComponent = /*#__PURE__*/function (_EventEmitter) { 10650 babelHelpers.inherits(ZIndexComponent, _EventEmitter); 10651 function ZIndexComponent(element, componentOptions = {}) { 10652 var _this; 10653 babelHelpers.classCallCheck(this, ZIndexComponent); 10654 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(ZIndexComponent).call(this)); 10655 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "sort", 0); 10656 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "alwaysOnTop", false); 10657 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "zIndex", 0); 10658 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "element", null); 10659 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlay", null); 10660 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlayGap", -5); 10661 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "stack", null); 10662 _this.setEventNamespace('BX.Main.ZIndexManager.Component'); 10663 if (!Type.isElementNode(element)) { 10664 throw new Error('ZIndexManager.Component: The argument \'element\' must be a DOM element.'); 10665 } 10666 _this.element = element; 10667 const options = Type.isPlainObject(componentOptions) ? componentOptions : {}; 10668 _this.setAlwaysOnTop(options.alwaysOnTop); 10669 _this.setOverlay(options.overlay); 10670 _this.setOverlayGap(options.overlayGap); 10671 _this.subscribeFromOptions(options.events); 10672 return _this; 10673 } 10674 babelHelpers.createClass(ZIndexComponent, [{ 10675 key: "getSort", 10676 value: function getSort() { 10677 return this.sort; 10678 } 10679 /** 10680 * @internal 10681 * @param sort 10682 */ 10683 }, { 10684 key: "setSort", 10685 value: function setSort(sort) { 10686 if (Type.isNumber(sort)) { 10687 this.sort = sort; 10688 } 10689 } 10690 /** 10691 * @internal 10692 * @param stack 10693 */ 10694 }, { 10695 key: "setStack", 10696 value: function setStack(stack) { 10697 this.stack = stack; 10698 } 10699 }, { 10700 key: "getStack", 10701 value: function getStack() { 10702 return this.stack; 10703 } 10704 }, { 10705 key: "getZIndex", 10706 value: function getZIndex() { 10707 return this.zIndex; 10708 } 10709 /** 10710 * @internal 10711 */ 10712 }, { 10713 key: "setZIndex", 10714 value: function setZIndex(zIndex) { 10715 const changed = this.getZIndex() !== zIndex; 10716 this.getElement().style.setProperty('z-index', zIndex, 'important'); 10717 this.zIndex = zIndex; 10718 if (this.getOverlay() !== null) { 10719 this.getOverlay().style.setProperty('z-index', zIndex + this.getOverlayGap(), 'important'); 10720 } 10721 if (changed) {
10722 this.emit('onZIndexChange', { 10723 component: this 10724 }); 10725 } 10726 } 10727 }, { 10728 key: "getAlwaysOnTop", 10729 value: function getAlwaysOnTop() { 10730 return this.alwaysOnTop; 10731 } 10732 }, { 10733 key: "setAlwaysOnTop", 10734 value: function setAlwaysOnTop(value) { 10735 if (Type.isNumber(value) || Type.isBoolean(value)) { 10736 this.alwaysOnTop = value; 10737 } 10738 } 10739 }, { 10740 key: "getElement", 10741 value: function getElement() { 10742 return this.element; 10743 } 10744 }, { 10745 key: "setOverlay", 10746 value: function setOverlay(overlay, gap) { 10747 if (Type.isElementNode(overlay) || overlay === null) { 10748 this.overlay = overlay; 10749 this.setOverlayGap(gap); 10750 if (this.getStack()) { 10751 this.getStack().sort(); 10752 } 10753 } 10754 } 10755 }, { 10756 key: "getOverlay", 10757 value: function getOverlay() { 10758 return this.overlay; 10759 } 10760 }, { 10761 key: "setOverlayGap", 10762 value: function setOverlayGap(gap) { 10763 if (Type.isNumber(gap)) { 10764 this.overlayGap = gap; 10765 } 10766 } 10767 }, { 10768 key: "getOverlayGap", 10769 value: function getOverlayGap() { 10770 return this.overlayGap; 10771 } 10772 }]); 10773 return ZIndexComponent; 10774 }(EventEmitter); 10775 10776 let ZIndexStack = /*#__PURE__*/function () { 10777 function ZIndexStack(container) { 10778 babelHelpers.classCallCheck(this, ZIndexStack); 10779 babelHelpers.defineProperty(this, "container", null); 10780 babelHelpers.defineProperty(this, "components", null); 10781 babelHelpers.defineProperty(this, "elements", new WeakMap()); 10782 babelHelpers.defineProperty(this, "baseIndex", 1000); 10783 babelHelpers.defineProperty(this, "baseStep", 50); 10784 babelHelpers.defineProperty(this, "sortCount", 0); 10785 if (!Type.isDomNode(container)) { 10786 throw new Error('ZIndexManager.Stack: The \'container\' argument must be a DOM element.'); 10787 } 10788 this.container = container; 10789 const comparator = (componentA, componentB) => { 10790 let result = (componentA.getAlwaysOnTop() || 0) - (componentB.getAlwaysOnTop() || 0); 10791 if (!result) { 10792 result = componentA.getSort() - componentB.getSort(); 10793 } 10794 return result; 10795 }; 10796 this.components = new OrderedArray(comparator); 10797 } 10798 babelHelpers.createClass(ZIndexStack, [{ 10799 key: "getBaseIndex", 10800 value: function getBaseIndex() { 10801 return this.baseIndex; 10802 } 10803 }, { 10804 key: "setBaseIndex", 10805 value: function setBaseIndex(index) { 10806 if (Type.isNumber(index) && index >= 0) { 10807 this.baseIndex = index; 10808 this.sort(); 10809 } 10810 } 10811 }, { 10812 key: "setBaseStep", 10813 value: function setBaseStep(step) { 10814 if (Type.isNumber(step) && step > 0) { 10815 this.baseStep = step; 10816 this.sort(); 10817 } 10818 } 10819 }, { 10820 key: "getBaseStep", 10821 value: function getBaseStep() { 10822 return this.baseStep; 10823 } 10824 }, { 10825 key: "register", 10826 value: function register(element, options = {}) { 10827 if (this.getComponent(element)) { 10828 console.warn('ZIndexManager: You cannot register the element twice.', element); 10829 return this.getComponent(element); 10830 } 10831 const component = new ZIndexComponent(element, options); 10832 component.setStack(this); 10833 component.setSort(++this.sortCount); 10834 this.elements.set(element, component); 10835 this.components.add(component); 10836 this.sort(); 10837 return component; 10838 } 10839 }, { 10840 key: "unregister", 10841 value: function unregister(element) { 10842 const component = this.elements.get(element); 10843 this.components.delete(component); 10844 this.elements.delete(element); 10845 this.sort(); 10846 } 10847 }, { 10848 key: "getComponent", 10849 value: function getComponent(element) { 10850 return this.elements.get(element) || null; 10851 } 10852 }, { 10853 key: "getComponents", 10854 value: function getComponents() { 10855 return this.components.getAll(); 10856 } 10857 }, { 10858 key: "getMaxZIndex", 10859 value: function getMaxZIndex() { 10860 const last = this.components.getLast(); 10861 return last ? last.getZIndex() : this.baseIndex; 10862 } 10863 }, { 10864 key: "sort", 10865 value: function sort() { 10866 this.components.sort(); 10867 let zIndex = this.baseIndex;
10868 this.components.forEach(component => { 10869 component.setZIndex(zIndex); 10870 zIndex += this.baseStep; 10871 }); 10872 } 10873 }, { 10874 key: "bringToFront", 10875 value: function bringToFront(element) { 10876 const component = this.getComponent(element); 10877 if (!component) { 10878 console.error('ZIndexManager: element was not found in the stack.', element); 10879 return null; 10880 } 10881 component.setSort(++this.sortCount); 10882 this.sort(); 10883 return component; 10884 } 10885 }]); 10886 return ZIndexStack; 10887 }(); 10888 10889 function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; } 10890 function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } } 10891 /** 10892 * @memberof BX 10893 */ 10894 let ZIndexManager = /*#__PURE__*/function () { 10895 function ZIndexManager() { 10896 babelHelpers.classCallCheck(this, ZIndexManager); 10897 } 10898 babelHelpers.createClass(ZIndexManager, null, [{ 10899 key: "register", 10900 value: function register(element, options = {}) { 10901 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10902 if (!parentNode) { 10903 return null; 10904 } 10905 const stack = this.getOrAddStack(parentNode); 10906 return stack.register(element, options); 10907 } 10908 }, { 10909 key: "unregister", 10910 value: function unregister(element) { 10911 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10912 const stack = this.getStack(parentNode); 10913 if (stack) { 10914 stack.unregister(element); 10915 } 10916 } 10917 }, { 10918 key: "addStack", 10919 value: function addStack(container) { 10920 const stack = new ZIndexStack(container); 10921 this.stacks.set(container, stack); 10922 return stack; 10923 } 10924 }, { 10925 key: "getStack", 10926 value: function getStack(container) { 10927 return this.stacks.get(container) || null; 10928 } 10929 }, { 10930 key: "getOrAddStack", 10931 value: function getOrAddStack(container) { 10932 return this.getStack(container) || this.addStack(container); 10933 } 10934 }, { 10935 key: "getComponent", 10936 value: function getComponent(element) { 10937 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element, true); 10938 if (!parentNode) { 10939 return null; 10940 } 10941 const stack = this.getStack(parentNode); 10942 return stack ? stack.getComponent(element) : null; 10943 } 10944 }, { 10945 key: "bringToFront", 10946 value: function bringToFront(element) { 10947 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10948 const stack = this.getStack(parentNode); 10949 if (stack) { 10950 return stack.bringToFront(element); 10951 } 10952 return null; 10953 } 10954 }]); 10955 return ZIndexManager; 10956 }(); 10957 function _getParentNode(element, suppressWarnings = false) { 10958 if (!Type.isElementNode(element)) { 10959 if (!suppressWarnings) { 10960 console.error('ZIndexManager: The argument \'element\' must be a DOM element.', element); 10961 } 10962 return null; 10963 } else if (!Type.isElementNode(element.parentNode)) { 10964 if (!suppressWarnings) { 10965 console.error('ZIndexManager: The \'element\' doesn\'t have a parent node.', element); 10966 } 10967 return null; 10968 } 10969 return element.parentNode; 10970 } 10971 babelHelpers.defineProperty(ZIndexManager, "stacks", new WeakMap()); 10972 10973 var collections = { 10974 OrderedArray, 10975 SettingsCollection 10976 }; 10977 10978 function getElement(element) { 10979 if (Type.isString(element)) { 10980 return document.getElementById(element); 10981 } 10982 return element; 10983 } 10984 10985 function getWindow(element) { 10986 if (Type.isElementNode(element)) { 10987 return element.ownerDocument.parentWindow || element.ownerDocument.defaultView || window; 10988 } 10989 if (Type.isDomNode(element)) { 10990 return element.parentWindow || element.defaultView || window; 10991 } 10992 return window; 10993 } 10994 10995 /* eslint-disable prefer-rest-params */ 10996 10997 // BX.* 10998 const { 10999 getClass, 11000 namespace 11001 } = Reflection; 11002 const message$1 = message; 11003 11004 /** 11005 * @memberOf BX 11006 */ 11007 const { 11008 replace, 11009 remove, 11010 clean, 11011 insertBefore, 11012 insertAfter, 11013 append, 11014 prepend, 11015 style, 11016 adjust, 11017 create, 11018 isShown 11019 } = Dom; 11020 const addClass = function addClass() { 11021 Dom.addClass(...Runtime.merge([], Array.from(arguments), [getElement(arguments[0])])); 11022 }; 11023 const removeClass = function removeClass() { 11024 Dom.removeClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11025 }; 11026 const hasClass = function hasClass() { 11027 return Dom.hasClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11028 }; 11029 const toggleClass = function toggleClass() { 11030 Dom.toggleClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11031 }; 11032 const cleanNode = (element, removeElement = false) => { 11033 const currentElement = getElement(element); 11034 if (Type.isDomNode(currentElement)) { 11035 Dom.clean(currentElement); 11036 if (removeElement) { 11037 Dom.remove(currentElement); 11038 return currentElement; 11039 } 11040 } 11041 return currentElement; 11042 }; 11043 const getCookie = Http.Cookie.get;
11044 const setCookie = (name, value, options = {}) => { 11045 const attributes = { 11046 ...options 11047 }; 11048 if (Type.isNumber(attributes.expires)) { 11049 attributes.expires /= 3600 * 24; 11050 } 11051 Http.Cookie.set(name, value, attributes); 11052 }; 11053 const { 11054 bind: bind$1, 11055 unbind: unbind$1, 11056 unbindAll: unbindAll$1, 11057 bindOnce: bindOnce$1, 11058 ready: ready$1 11059 } = Event; 11060 const { 11061 debugState: debugEnableFlag, 11062 isDebugEnabled: debugStatus, 11063 default: debug$1 11064 } = debugNs; 11065 const debugEnable = value => { 11066 if (value) { 11067 enableDebug(); 11068 } else { 11069 disableDebug(); 11070 } 11071 }; 11072 const { 11073 clone: clone$1, 11074 loadExtension: loadExt, 11075 debounce, 11076 throttle, 11077 html 11078 } = Runtime; 11079 11080 // BX.type 11081 const type = { 11082 ...Object.getOwnPropertyNames(Type).filter(key => !['name', 'length', 'prototype', 'caller', 'arguments'].includes(key)).reduce((acc, key) => { 11083 acc[key] = Type[key]; 11084 return acc; 11085 }, {}), 11086 isNotEmptyString: value => Type.isString(value) && value !== '', 11087 isNotEmptyObject: value => Type.isObjectLike(value) && Object.keys(value).length > 0, 11088 isMapKey: Type.isObject, 11089 stringToInt: value => { 11090 const parsed = parseInt(value); 11091 return !Number.isNaN(parsed) ? parsed : 0; 11092 } 11093 }; 11094 11095 // BX.browser 11096 const browser = { 11097 IsOpera: Browser.isOpera, 11098 IsIE: Browser.isIE, 11099 IsIE6: Browser.isIE6, 11100 IsIE7: Browser.isIE7, 11101 IsIE8: Browser.isIE8, 11102 IsIE9: Browser.isIE9, 11103 IsIE10: Browser.isIE10, 11104 IsIE11: Browser.isIE11, 11105 IsSafari: Browser.isSafari, 11106 IsFirefox: Browser.isFirefox, 11107 IsChrome: Browser.isChrome, 11108 DetectIeVersion: Browser.detectIEVersion, 11109 IsMac: Browser.isMac, 11110 IsAndroid: Browser.isAndroid, 11111 isIPad: Browser.isIPad, 11112 isIPhone: Browser.isIPhone, 11113 IsIOS: Browser.isIOS, 11114 IsMobile: Browser.isMobile, 11115 isRetina: Browser.isRetina, 11116 IsDoctype: Browser.isDoctype, 11117 SupportLocalStorage: Browser.isLocalStorageSupported, 11118 addGlobalClass: Browser.addGlobalClass, 11119 DetectAndroidVersion: Browser.detectAndroidVersion, 11120 isPropertySupported: Browser.isPropertySupported, 11121 addGlobalFeatures: Browser.addGlobalFeatures 11122 }; 11123 11124 // eslint-disable-next-line 11125 const ajax = window.BX ? window.BX.ajax : () => {}; 11126 function GetWindowScrollSize(doc = document) { 11127 return { 11128 scrollWidth: doc.documentElement.scrollWidth, 11129 scrollHeight: doc.documentElement.scrollHeight 11130 }; 11131 } 11132 function GetWindowScrollPos(doc = document) { 11133 const win = getWindow(doc); 11134 return { 11135 scrollLeft: win.pageXOffset, 11136 scrollTop: win.pageYOffset 11137 }; 11138 } 11139 function GetWindowInnerSize(doc = document) { 11140 const win = getWindow(doc); 11141 return { 11142 innerWidth: win.innerWidth, 11143 innerHeight: win.innerHeight 11144 }; 11145 } 11146 function GetWindowSize(doc = document) { 11147 return { 11148 ...GetWindowInnerSize(doc), 11149 ...GetWindowScrollPos(doc), 11150 ...GetWindowScrollSize(doc) 11151 }; 11152 } 11153 function GetContext(node) { 11154 return getWindow(node); 11155 } 11156 function pos(element, relative = false) { 11157 if (!element) { 11158 return new DOMRect().toJSON(); 11159 } 11160 if (element.ownerDocument === document && !relative) { 11161 const clientRect = element.getBoundingClientRect(); 11162 const root = document.documentElement; 11163 const { 11164 body 11165 } = document; 11166 return { 11167 top: Math.round(clientRect.top + (root.scrollTop || body.scrollTop)), 11168 left: Math.round(clientRect.left + (root.scrollLeft || body.scrollLeft)), 11169 width: Math.round(clientRect.right - clientRect.left), 11170 height: Math.round(clientRect.bottom - clientRect.top), 11171 right: Math.round(clientRect.right + (root.scrollLeft || body.scrollLeft)), 11172 bottom: Math.round(clientRect.bottom + (root.scrollTop || body.scrollTop)) 11173 }; 11174 } 11175 let x = 0; 11176 let y = 0; 11177 const w = element.offsetWidth; 11178 const h = element.offsetHeight; 11179 let first = true; 11180 11181 // eslint-disable-next-line no-param-reassign 11182 for (; element != null; element = element.offsetParent) { 11183 if (!first && relative && BX.is_relative(element)) { 11184 break; 11185 } 11186 x += element.offsetLeft; 11187 y += element.offsetTop; 11188 if (first) { 11189 first = false; 11190 // eslint-disable-next-line no-continue 11191 continue; 11192 } 11193 x += Text.toNumber(Dom.style(element, 'border-left-width')); 11194 y += Text.toNumber(Dom.style(element, 'border-top-width')); 11195 } 11196 return new DOMRect(x, y, w, h).toJSON(); 11197 } 11198 function addCustomEvent(eventObject, eventName, eventHandler) { 11199 if (Type.isString(eventObject)) { 11200 eventHandler = eventName; 11201 eventName = eventObject; 11202 eventObject = EventEmitter.GLOBAL_TARGET;
11203 } 11204 if (eventObject === window) { 11205 eventObject = EventEmitter.GLOBAL_TARGET; 11206 } 11207 if (!Type.isObject(eventObject)) { 11208 console.error('The "eventObject" argument must be an object. Received type ' + typeof eventObject + '.'); 11209 return; 11210 } 11211 if (!Type.isStringFilled(eventName)) { 11212 console.error('The "eventName" argument must be a string.'); 11213 return; 11214 } 11215 if (!Type.isFunction(eventHandler)) { 11216 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11217 return; 11218 } 11219 eventName = eventName.toLowerCase(); 11220 EventEmitter.subscribe(eventObject, eventName, eventHandler, { 11221 compatMode: true, 11222 useGlobalNaming: true 11223 }); 11224 } 11225 function onCustomEvent(eventObject, eventName, eventParams, secureParams) { 11226 if (Type.isString(eventObject)) { 11227 secureParams = eventParams; 11228 eventParams = eventName; 11229 eventName = eventObject; 11230 eventObject = EventEmitter.GLOBAL_TARGET; 11231 } 11232 if (!Type.isObject(eventObject) || eventObject === window) { 11233 eventObject = EventEmitter.GLOBAL_TARGET;
11234 } 11235 if (!eventParams) { 11236 eventParams = []; 11237 } 11238 eventName = eventName.toLowerCase(); 11239 const event = new BaseEvent(); 11240 event.setData(eventParams); 11241 event.setCompatData(eventParams); 11242 EventEmitter.emit(eventObject, eventName, event, { 11243 cloneData: secureParams === true, 11244 useGlobalNaming: true 11245 }); 11246 } 11247 function removeCustomEvent(eventObject, eventName, eventHandler) { 11248 if (Type.isString(eventObject)) { 11249 eventHandler = eventName; 11250 eventName = eventObject; 11251 eventObject = EventEmitter.GLOBAL_TARGET; 11252 } 11253 if (!Type.isFunction(eventHandler)) { 11254 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11255 return; 11256 } 11257 if (eventObject === window) { 11258 eventObject = EventEmitter.GLOBAL_TARGET; 11259 } 11260 eventName = eventName.toLowerCase(); 11261 EventEmitter.unsubscribe(eventObject, eventName, eventHandler, { 11262 useGlobalNaming: true 11263 }); 11264 } 11265 function removeAllCustomEvents(eventObject, eventName) { 11266 if (Type.isString(eventObject)) { 11267 eventName = eventObject; 11268 eventObject = EventEmitter.GLOBAL_TARGET;
11269 } 11270 if (eventObject === window) { 11271 eventObject = EventEmitter.GLOBAL_TARGET; 11272 } 11273 eventName = eventName.toLowerCase(); 11274 EventEmitter.unsubscribeAll(eventObject, eventName, { 11275 useGlobalNaming: true 11276 }); 11277 } 11278 11279 if (typeof global === 'object' && global.window && global.window.BX) { 11280 Object.assign(global.window.BX, exports); 11281 } 11282 11283 exports.Type = Type; 11284 exports.Reflection = Reflection; 11285 exports.Text = Text; 11286 exports.Dom = Dom; 11287 exports.Browser = Browser; 11288 exports.Event = Event; 11289 exports.Http = Http; 11290 exports.Runtime = Runtime; 11291 exports.Loc = Loc; 11292 exports.Tag = Tag; 11293 exports.Uri = Uri; 11294 exports.Validation = Validation; 11295 exports.Cache = Cache; 11296 exports.BaseError = BaseError; 11297 exports.Extension = Extension$1; 11298 exports.ZIndexManager = ZIndexManager; 11299 exports.Collections = collections; 11300 exports.getClass = getClass; 11301 exports.namespace = namespace; 11302 exports.message = message$1; 11303 exports.replace = replace; 11304 exports.remove = remove; 11305 exports.clean = clean; 11306 exports.insertBefore = insertBefore; 11307 exports.insertAfter = insertAfter; 11308 exports.append = append; 11309 exports.prepend = prepend; 11310 exports.style = style; 11311 exports.adjust = adjust; 11312 exports.create = create; 11313 exports.isShown = isShown; 11314 exports.addClass = addClass; 11315 exports.removeClass = removeClass; 11316 exports.hasClass = hasClass; 11317 exports.toggleClass = toggleClass; 11318 exports.cleanNode = cleanNode; 11319 exports.getCookie = getCookie; 11320 exports.setCookie = setCookie; 11321 exports.bind = bind$1; 11322 exports.unbind = unbind$1; 11323 exports.unbindAll = unbindAll$1; 11324 exports.bindOnce = bindOnce$1; 11325 exports.ready = ready$1; 11326 exports.debugEnableFlag = debugEnableFlag; 11327 exports.debugStatus = debugStatus; 11328 exports.debug = debug$1; 11329 exports.debugEnable = debugEnable; 11330 exports.clone = clone$1; 11331 exports.loadExt = loadExt; 11332 exports.debounce = debounce; 11333 exports.throttle = throttle; 11334 exports.html = html; 11335 exports.type = type; 11336 exports.browser = browser; 11337 exports.ajax = ajax; 11338 exports.GetWindowScrollSize = GetWindowScrollSize; 11339 exports.GetWindowScrollPos = GetWindowScrollPos; 11340 exports.GetWindowInnerSize = GetWindowInnerSize; 11341 exports.GetWindowSize = GetWindowSize; 11342 exports.GetContext = GetContext; 11343 exports.pos = pos; 11344 exports.addCustomEvent = addCustomEvent; 11345 exports.onCustomEvent = onCustomEvent; 11346 exports.removeCustomEvent = removeCustomEvent; 11347 exports.removeAllCustomEvents = removeAllCustomEvents; 11348 11349}((this.BX = this.BX || {}))); 11350 11351 11352 11353(function(BX) { 11354 /* list of registered proxy functions */ 11355 var proxyList = new WeakMap(); 11356 var deferList = new WeakMap(); 11357 11358 /* List of denied event handlers */ 11359 var deniedEvents = []; 11360 11361 /* list of registered custom events */ 11362 var customEvents = new WeakMap(); 11363 var customEventsCnt = 0; 11364 11365 /* list of external garbage collectors */ 11366 var garbageCollectors = []; 11367 11368 /* list of loaded CSS files */ 11369 var cssList = []; 11370 var cssInit = false; 11371 11372 /* list of loaded JS files */ 11373 var jsList = []; 11374 var jsInit = false; 11375 11376 var eventTypes = { 11377 click: 'MouseEvent', 11378 dblclick: 'MouseEvent', 11379 mousedown: 'MouseEvent', 11380 mousemove: 'MouseEvent', 11381 mouseout: 'MouseEvent', 11382 mouseover: 'MouseEvent', 11383 mouseup: 'MouseEvent', 11384 focus: 'MouseEvent', 11385 blur: 'MouseEvent' 11386 }; 11387 11388 var lastWait = []; 11389 11390 var CHECK_FORM_ELEMENTS = {tagName: /^INPUT|SELECT|TEXTAREA|BUTTON$/i}; 11391 11392 BX.MSLEFT = 1; 11393 BX.MSMIDDLE = 2; 11394 BX.MSRIGHT = 4; 11395 11396 BX.AM_PM_UPPER = 1; 11397 BX.AM_PM_LOWER = 2; 11398 BX.AM_PM_NONE = false; 11399 11400 BX.ext = function(ob) 11401 { 11402 for (var i in ob) 11403 { 11404 if(ob.hasOwnProperty(i)) 11405 { 11406 this[i] = ob[i]; 11407 } 11408 } 11409 }; 11410 11411 var r = { 11412 script: /<script([^>]*)>/ig, 11413 script_end: /<\/script>/ig, 11414 script_src: /src=["\']([^"\']+)["\']/i, 11415 script_type: /type=["\']([^"\']+)["\']/i, 11416 space: /\s+/, 11417 ltrim: /^[\s\r\n]+/g, 11418 rtrim: /[\s\r\n]+$/g, 11419 style: /<link.*?(rel="stylesheet"|type="text\/css")[^>]*>/i, 11420 style_href: /href=["\']([^"\']+)["\']/i 11421 }; 11422 11423 BX.processHTML = function(data, scriptsRunFirst) 11424 { 11425 var matchScript, matchStyle, matchSrc, matchHref, matchType, scripts = [], styles = []; 11426 var textIndexes = []; 11427 var lastIndex = r.script.lastIndex = r.script_end.lastIndex = 0; 11428 11429 while ((matchScript = r.script.exec(data)) !== null) 11430 { 11431 r.script_end.lastIndex = r.script.lastIndex; 11432 var matchScriptEnd = r.script_end.exec(data); 11433 if (matchScriptEnd === null) 11434 { 11435 break; 11436 } 11437 11438 // skip script tags of special types 11439 var skipTag = false;
11440 if ((matchType = matchScript[1].match(r.script_type)) !== null) 11441 { 11442 if( 11443 matchType[1] == 'text/html' 11444 || matchType[1] == 'text/template' 11445 || matchType[1] == 'extension/settings' 11446 ) 11447 { 11448 skipTag = true; 11449 } 11450 } 11451 11452 if(skipTag) 11453 { 11454 textIndexes.push([lastIndex, r.script_end.lastIndex - lastIndex]); 11455 } 11456 else 11457 { 11458 textIndexes.push([lastIndex, matchScript.index - lastIndex]); 11459 11460 var bRunFirst = scriptsRunFirst || (matchScript[1].indexOf('bxrunfirst') != '-1'); 11461 11462 if ((matchSrc = matchScript[1].match(r.script_src)) !== null) 11463 { 11464 scripts.push({"bRunFirst": bRunFirst, "isInternal": false, "JS": matchSrc[1]}); 11465 } 11466 else 11467 { 11468 var start = matchScript.index + matchScript[0].length; 11469 var js = data.substr(start, matchScriptEnd.index-start); 11470 11471 scripts.push({"bRunFirst": bRunFirst, "isInternal": true, "JS": js}); 11472 } 11473 } 11474 11475 lastIndex = matchScriptEnd.index + 9; 11476 r.script.lastIndex = lastIndex; 11477 } 11478 11479 textIndexes.push([lastIndex, lastIndex === 0 ? data.length : data.length - lastIndex]); 11480 var pureData = ""; 11481 for (var i = 0, length = textIndexes.length; i < length; i++) 11482 { 11483 if (BX.type.isString(data) && BX.type.isFunction(data.substr)) 11484 { 11485 pureData += data.substr(textIndexes[i][0], textIndexes[i][1]); 11486 } 11487 } 11488 11489 while ((matchStyle = pureData.match(r.style)) !== null) 11490 { 11491 if ((matchHref = matchStyle[0].match(r.style_href)) !== null && matchStyle[0].indexOf('media="') < 0) 11492 { 11493 styles.push(matchHref[1]); 11494 } 11495 11496 pureData = pureData.replace(matchStyle[0], ''); 11497 } 11498 11499 return {'HTML': pureData, 'SCRIPT': scripts, 'STYLE': styles}; 11500 }; 11501 11502 /* OO emulation utility */ 11503 BX.extend = function(child, parent) 11504 { 11505 var f = function() {}; 11506 f.prototype = parent.prototype; 11507 11508 child.prototype = new f(); 11509 child.prototype.constructor = child; 11510 11511 child.superclass = parent.prototype; 11512 child.prototype.superclass = parent.prototype; 11513 if(parent.prototype.constructor == Object.prototype.constructor) 11514 { 11515 parent.prototype.constructor = parent; 11516 } 11517 }; 11518 11519 BX.is_subclass_of = function(ob, parent_class) 11520 { 11521 if (ob instanceof parent_class) 11522 return true; 11523 11524 if (parent_class.superclass) 11525 return BX.is_subclass_of(ob, parent_class.superclass); 11526 11527 return false; 11528 }; 11529 11530 BX.clearNodeCache = function() 11531 { 11532 return false; 11533 }; 11534 11535 BX.bitrix_sessid = function() {return BX.message("bitrix_sessid"); }; 11536 11537 /** 11538 * Creates document fragment with child nodes. 11539 * 11540 * @param {Node[]} nodes 11541 * @return {DocumentFragment} 11542 */ 11543 BX.createFragment = function(nodes) 11544 { 11545 var fragment = document.createDocumentFragment(); 11546 11547 if(!BX.type.isArray(nodes)) 11548 { 11549 return fragment; 11550 } 11551 for(var i = 0; i < nodes.length; i++) 11552 { 11553 fragment.appendChild(nodes[i]); 11554 } 11555 11556 return fragment; 11557 }; 11558 11559 /** 11560 * @deprecated 11561 * @use BX.style 11562 * @param element 11563 * @param opacity 11564 */ 11565 BX.setOpacity = function(element, opacity) 11566 { 11567 var opacityValue = parseFloat(opacity); 11568 11569 if (!isNaN(opacityValue) && BX.type.isDomNode(element)) 11570 { 11571 opacityValue = opacityValue < 1 ? opacityValue : opacityValue / 100; 11572 BX.style(element, 'opacity', opacityValue); 11573 } 11574 }; 11575 11576 /** 11577 * @deprecated 11578 * @param el 11579 * @return {*} 11580 */ 11581 BX.hoverEvents = function(el) 11582 { 11583 if (el) 11584 return BX.adjust(el, {events: BX.hoverEvents()}); 11585 else 11586 return {mouseover: BX.hoverEventsHover, mouseout: BX.hoverEventsHout}; 11587 }; 11588 11589 /** 11590 * @deprecated 11591 */ 11592 BX.hoverEventsHover = function(){BX.addClass(this,'bx-hover');this.BXHOVER=true;}; 11593 /** 11594 * @deprecated 11595 */ 11596 BX.hoverEventsHout = function(){BX.removeClass(this,'bx-hover');this.BXHOVER=false;}; 11597 11598 /** 11599 * @deprecated 11600 */ 11601 BX.focusEvents = function(el) 11602 { 11603 if (el) 11604 return BX.adjust(el, {events: BX.focusEvents()}); 11605 else 11606 return {mouseover: BX.focusEventsFocus, mouseout: BX.focusEventsBlur}; 11607 }; 11608 11609 /** 11610 * @deprecated 11611 */ 11612 BX.focusEventsFocus = function(){BX.addClass(this,'bx-focus');this.BXFOCUS=true;}; 11613 /** 11614 * @deprecated 11615 */ 11616 BX.focusEventsBlur = function(){BX.removeClass(this,'bx-focus');this.BXFOCUS=false;}; 11617 11618 BX.setUnselectable = function(node) 11619 { 11620 BX.style(node, { 11621 'userSelect': 'none', 11622 'MozUserSelect': 'none', 11623 'WebkitUserSelect': 'none', 11624 'KhtmlUserSelect': 'none', 11625 }); 11626 node.setAttribute('unSelectable', 'on'); 11627 }; 11628 11629 BX.setSelectable = function(node) 11630 { 11631 BX.style(node, { 11632 'userSelect': null, 11633 'MozUserSelect': null, 11634 'WebkitUserSelect': null, 11635 'KhtmlUserSelect': null, 11636 }); 11637 node.removeAttribute('unSelectable'); 11638 }; 11639 11640 BX.styleIEPropertyName = function(name) 11641 { 11642 if (name == 'float') 11643 name = BX.browser.IsIE() ? 'styleFloat' : 'cssFloat'; 11644 else 11645 { 11646 var res = BX.browser.isPropertySupported(name); 11647 if (res) 11648 { 11649 name = res; 11650 } 11651 else 11652 {
11653 var reg = /(\-([a-z]){1})/g; 11654 if (reg.test(name)) 11655 { 11656 name = name.replace(reg, function () {return arguments[2].toUpperCase();}); 11657 } 11658 } 11659 } 11660 return name; 11661 }; 11662 11663 BX.focus = function(el) 11664 { 11665 try 11666 { 11667 el.focus(); 11668 return true; 11669 } 11670 catch (e) 11671 { 11672 return false; 11673 } 11674 }; 11675 11676 BX.firstChild = function(el) 11677 { 11678 return BX.type.isDomNode(el) ? el.firstElementChild : null; 11679 }; 11680 11681 BX.lastChild = function(el) 11682 { 11683 return BX.type.isDomNode(el) ? el.lastElementChild : null; 11684 }; 11685 11686 BX.previousSibling = function(el) 11687 { 11688 return BX.type.isDomNode(el) ? el.previousElementSibling : null; 11689 }; 11690 11691 BX.nextSibling = function(el) 11692 { 11693 return BX.type.isDomNode(el) ? el.nextElementSibling : null; 11694 }; 11695 11696 /* 11697 params: { 11698 obj : html node 11699 className : className value 11700 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 11701 } 11702 11703 Search all nodes with className 11704 */ 11705 /** 11706 * @deprecated 11707 * @use .querySelectorAll 11708 * @param obj 11709 * @param className 11710 * @param recursive 11711 * @return {*} 11712 */ 11713 BX.findChildrenByClassName = function(obj, className, recursive) 11714 { 11715 if(!obj || !obj.childNodes) return null; 11716 11717 var result = []; 11718 if (typeof(obj.getElementsByClassName) == 'undefined') 11719 { 11720 recursive = recursive !== false; 11721 result = BX.findChildren(obj, {className : className}, recursive); 11722 } 11723 else 11724 { 11725 var col = obj.getElementsByClassName(className); 11726 for (i=0,l=col.length;i<l;i++) 11727 { 11728 result[i] = col[i]; 11729 } 11730 } 11731 return result; 11732 }; 11733 11734 /* 11735 params: { 11736 obj : html node 11737 className : className value 11738 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 11739 } 11740 11741 Search first node with className 11742 */ 11743 /** 11744 * @deprecated 11745 * @use .querySelector 11746 * @param obj 11747 * @param className 11748 * @param recursive 11749 * @return {*} 11750 */ 11751 BX.findChildByClassName = function(obj, className, recursive) 11752 { 11753 if(!obj || !obj.childNodes) return null; 11754 11755 var result = null; 11756 if (typeof(obj.getElementsByClassName) == 'undefined') 11757 { 11758 recursive = recursive !== false; 11759 result = BX.findChild(obj, {className : className}, recursive); 11760 } 11761 else 11762 { 11763 var col = obj.getElementsByClassName(className); 11764 if (col && typeof(col[0]) != 'undefined') 11765 { 11766 result = col[0]; 11767 } 11768 else 11769 { 11770 result = null; 11771 } 11772 } 11773 return result; 11774 }; 11775 11776 /* 11777 params: { 11778 tagName|tag : 'tagName', 11779 className|class : 'className', 11780 attribute : {attribute : value, attribute : value} | attribute | [attribute, attribute....], 11781 property : {prop: value, prop: value} | prop | [prop, prop] 11782 } 11783 11784 all values can be RegExps or strings 11785 */ 11786 /** 11787 * @deprecated 11788 * @use .querySelectorAll 11789 * @param obj 11790 * @param params 11791 * @param recursive 11792 * @return {*|Node} 11793 */ 11794 BX.findChildren = function(obj, params, recursive) 11795 { 11796 return BX.findChild(obj, params, recursive, true); 11797 }; 11798 11799 /** 11800 * @deprecated 11801 * @use .querySelectorAll 11802 * @param obj 11803 * @param params 11804 * @param recursive 11805 * @param get_all 11806 * @return {*} 11807 */ 11808 BX.findChild = function(obj, params, recursive, get_all) 11809 { 11810 if(!obj || !obj.childNodes) return null; 11811 11812 recursive = !!recursive; get_all = !!get_all; 11813 11814 var n = obj.childNodes.length, result = []; 11815 11816 for (var j=0; j<n; j++) 11817 { 11818 var child = obj.childNodes[j]; 11819 11820 if (_checkNode(child, params)) 11821 { 11822 if (get_all) 11823 result.push(child); 11824 else 11825 return child; 11826 } 11827 11828 if(recursive == true) 11829 { 11830 var res = BX.findChild(child, params, recursive, get_all); 11831 if (res) 11832 { 11833 if (get_all) 11834 result = BX.util.array_merge(result, res); 11835 else 11836 return res; 11837 } 11838 } 11839 } 11840 11841 if (get_all || result.length > 0) 11842 return result; 11843 else 11844 return null; 11845 }; 11846 11847 /** 11848 * @deprecated 11849 * @use .closest() 11850 * @param obj 11851 * @param params 11852 * @param maxParent 11853 * @return {*} 11854 */ 11855 BX.findParent = function(obj, params, maxParent) 11856 { 11857 if(!obj) 11858 return null; 11859 11860 var o = obj; 11861 while(o.parentNode) 11862 { 11863 var parent = o.parentNode; 11864 11865 if (_checkNode(parent, params)) 11866 return parent; 11867 11868 o = parent; 11869 11870 if (!!maxParent &&
11871 (BX.type.isFunction(maxParent) 11872 || typeof maxParent == 'object')) 11873 { 11874 if (BX.type.isElementNode(maxParent)) 11875 { 11876 if (o == maxParent) 11877 break; 11878 } 11879 else 11880 { 11881 if (_checkNode(o, maxParent)) 11882 break; 11883 } 11884 } 11885 } 11886 return null; 11887 }; 11888 11889 /** 11890 * @deprecated 11891 * @use .querySelector 11892 * @param obj 11893 * @param params 11894 * @return {*} 11895 */ 11896 BX.findNextSibling = function(obj, params) 11897 { 11898 if(!obj) 11899 return null; 11900 var o = obj; 11901 while(o.nextSibling) 11902 { 11903 var sibling = o.nextSibling; 11904 if (_checkNode(sibling, params)) 11905 return sibling; 11906 o = sibling; 11907 } 11908 return null; 11909 }; 11910 11911 /** 11912 * @deprecated 11913 * @use .querySelector 11914 * @param obj 11915 * @param params 11916 * @return {*} 11917 */ 11918 BX.findPreviousSibling = function(obj, params) 11919 { 11920 if(!obj) 11921 return null; 11922 11923 var o = obj; 11924 while(o.previousSibling) 11925 { 11926 var sibling = o.previousSibling; 11927 if(_checkNode(sibling, params)) 11928 return sibling; 11929 o = sibling; 11930 } 11931 return null; 11932 }; 11933 11934 BX.checkNode = function(obj, params) 11935 { 11936 return _checkNode(obj, params); 11937 }; 11938 11939 /** 11940 * @deprecated 11941 * @use .querySelectorAll 11942 * @param form 11943 * @return {Array} 11944 */ 11945 BX.findFormElements = function(form) 11946 { 11947 if (BX.type.isString(form)) 11948 form = document.forms[form]||BX(form); 11949 11950 var res = []; 11951 11952 if (BX.type.isElementNode(form)) 11953 { 11954 if (form.tagName.toUpperCase() == 'FORM') 11955 { 11956 res = form.elements; 11957 } 11958 else 11959 { 11960 res = BX.findChildren(form, CHECK_FORM_ELEMENTS, true); 11961 } 11962 } 11963 11964 return res; 11965 }; 11966 11967 /** 11968 * @deprecated 11969 * @use .contains() 11970 * @param whichNode 11971 * @param forNode 11972 * @return {boolean} 11973 */ 11974 BX.isParentForNode = function(whichNode, forNode) 11975 { 11976 if (BX.type.isDomNode(whichNode) && BX.type.isDomNode(forNode)) 11977 { 11978 return whichNode.contains(forNode); 11979 } 11980 11981 return false; 11982 }; 11983 11984 BX.getCaretPosition = function(node) 11985 { 11986 var pos = 0; 11987 11988 if(node.selectionStart || node.selectionStart == 0) 11989 { 11990 pos = node.selectionStart; 11991 } 11992 else if(document.selection) 11993 { 11994 node.focus(); 11995 var selection = document.selection.createRange(); 11996 selection.moveStart('character', -node.value.length); 11997 pos = selection.text.length; 11998 } 11999 12000 return (pos); 12001 }; 12002 12003 BX.setCaretPosition = function(node, pos) 12004 { 12005 if(!BX.isNodeInDom(node) || BX.isNodeHidden(node) || node.disabled) 12006 { 12007 return; 12008 } 12009 12010 if(node.setSelectionRange) 12011 { 12012 node.focus(); 12013 node.setSelectionRange(pos, pos); 12014 } 12015 else if(node.createTextRange) 12016 { 12017 var range = node.createTextRange(); 12018 range.collapse(true); 12019 range.moveEnd('character', pos); 12020 range.moveStart('character', pos); 12021 range.select(); 12022 } 12023 }; 12024 12025 // access private. use BX.mergeEx instead. 12026 // todo: refactor BX.merge, make it work through BX.mergeEx 12027 BX.merge = function(){ 12028 var arg = Array.prototype.slice.call(arguments); 12029 12030 if(arg.length < 2) 12031 return {}; 12032 12033 var result = arg.shift(); 12034 12035 for(var i = 0; i < arg.length; i++) 12036 { 12037 for(var k in arg[i]){ 12038 12039 if(typeof arg[i] == 'undefined' || arg[i] == null) 12040 continue; 12041 12042 if(arg[i].hasOwnProperty(k)){ 12043 12044 if(typeof arg[i][k] == 'undefined' || arg[i][k] == null) 12045 continue; 12046 12047 if(typeof arg[i][k] == 'object' && !BX.type.isDomNode(arg[i][k]) && (typeof arg[i][k]['isUIWidget'] == 'undefined')){ 12048 12049 // go deeper 12050 12051 var isArray = 'length' in arg[i][k]; 12052 12053 if(typeof result[k] != 'object') 12054 result[k] = isArray ? [] : {}; 12055 12056 if(isArray) 12057 BX.util.array_merge(result[k], arg[i][k]); 12058 else 12059 BX.merge(result[k], arg[i][k]); 12060 12061 }else 12062 result[k] = arg[i][k]; 12063 } 12064 } 12065 } 12066 12067 return result; 12068 }; 12069 12070 BX.mergeEx = function() 12071 { 12072 var arg = Array.prototype.slice.call(arguments); 12073 if(arg.length < 2) 12074 { 12075 return {}; 12076 } 12077 12078 var result = arg.shift(); 12079 for (var i = 0; i < arg.length; i++) 12080 { 12081 for (var k in arg[i]) 12082 { 12083 if (typeof arg[i] == "undefined" || arg[i] == null || !arg[i].hasOwnProperty(k)) 12084 { 12085 continue; 12086 } 12087 12088 if (BX.type.isPlainObject(arg[i][k]) && BX.type.isPlainObject(result[k])) 12089 { 12090 BX.mergeEx(result[k], arg[i][k]); 12091 } 12092 else 12093 { 12094 result[k] = BX.type.isPlainObject(arg[i][k]) ? BX.clone(arg[i][k]) : arg[i][k]; 12095 } 12096 } 12097 } 12098 12099 return result; 12100 }; 12101 12102 BX.getEventButton = function(e) 12103 { 12104 e = e || window.event; 12105 12106 var flags = 0; 12107 12108 if (typeof e.which != 'undefined') 12109 { 12110 switch (e.which) 12111 { 12112 case 1: flags = flags|BX.MSLEFT; break; 12113 case 2: flags = flags|BX.MSMIDDLE; break; 12114 case 3: flags = flags|BX.MSRIGHT; break; 12115 } 12116 } 12117 else if (typeof e.button != 'undefined') 12118 { 12119 flags = event.button; 12120 } 12121 12122 return flags || BX.MSLEFT; 12123 }; 12124 12125 var captured_events = null, _bind = null; 12126 BX.CaptureEvents = function(el_c, evname_c) 12127 { 12128 if (_bind) 12129 return; 12130 12131 _bind = BX.bind; 12132 captured_events = []; 12133 12134 BX.bind = function(el, evname, func) 12135 { 12136 if (el === el_c && evname === evname_c) 12137 captured_events.push(func); 12138 12139 _bind.apply(this, arguments); 12140 } 12141 }; 12142 12143 BX.CaptureEventsGet = function() 12144 { 12145 if (_bind) 12146 { 12147 BX.bind = _bind; 12148 12149 var captured = captured_events; 12150 12151 _bind = null; 12152 captured_events = null; 12153 return captured; 12154 } 12155 return null; 12156 }; 12157 12158 // Don't even try to use it for submit event! 12159 BX.fireEvent = function(ob,ev) 12160 { 12161 var result = false, e = null; 12162 if (BX.type.isDomNode(ob)) 12163 { 12164 result = true; 12165 if (document.createEventObject) 12166 { 12167 // IE 12168 if (eventTypes[ev] != 'MouseEvent') 12169 { 12170 e = document.createEventObject(); 12171 e.type = ev; 12172 result = ob.fireEvent('on' + ev, e); 12173 } 12174 12175 if (ob[ev]) 12176 { 12177 ob[ev](); 12178 } 12179 } 12180 else 12181 {
12182 // non-IE 12183 e = null; 12184 12185 switch (eventTypes[ev]) 12186 { 12187 case 'MouseEvent': 12188 e = document.createEvent('MouseEvent'); 12189 try 12190 { 12191 e.initMouseEvent(ev, true, true, top, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12192 } 12193 catch (initException) 12194 { 12195 e.initMouseEvent(ev, true, true, window, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12196 } 12197 12198 break; 12199 default: 12200 e = document.createEvent('Event'); 12201 e.initEvent(ev, true, true); 12202 } 12203 12204 result = ob.dispatchEvent(e); 12205 } 12206 } 12207 12208 return result; 12209 }; 12210 12211 BX.getWheelData = function(e) 12212 { 12213 e = e || window.event; 12214 e.wheelData = e.detail ? e.detail * -1 : e.wheelDelta / 40; 12215 return e.wheelData; 12216 }; 12217 12218 BX.proxy_context = null; 12219 12220 BX.delegate = function (func, thisObject) 12221 { 12222 if (!func || !thisObject) 12223 return func; 12224 12225 return function() { 12226 var cur = BX.proxy_context; 12227 BX.proxy_context = this; 12228 var res = func.apply(thisObject, arguments); 12229 BX.proxy_context = cur; 12230 return res; 12231 } 12232 }; 12233 12234 BX.delegateLater = function (func_name, thisObject, contextObject) 12235 { 12236 return function() 12237 { 12238 if (thisObject[func_name]) 12239 { 12240 var cur = BX.proxy_context; 12241 BX.proxy_context = this; 12242 var res = thisObject[func_name].apply(contextObject||thisObject, arguments); 12243 BX.proxy_context = cur; 12244 return res; 12245 } 12246 return null; 12247 } 12248 }; 12249 12250 BX.proxy = function(func, thisObject) 12251 { 12252 return getObjectDelegate(func, thisObject, proxyList); 12253 }; 12254 12255 BX.defer = function(func, thisObject) 12256 { 12257 if (!!thisObject) 12258 return BX.defer_proxy(func, thisObject); 12259 else 12260 return function() { 12261 var arg = arguments; 12262 setTimeout(function(){func.apply(this,arg)}, 10); 12263 }; 12264 }; 12265 12266 BX.defer_proxy = function(func, thisObject) 12267 { 12268 return getObjectDelegate(func, thisObject, deferList, BX.defer); 12269 }; 12270 12271 /** 12272 * 12273 * @private 12274 */ 12275 function getObjectDelegate(func, thisObject, collection, decorator) 12276 { 12277 if (!BX.type.isFunction(func) || !BX.type.isMapKey(thisObject)) 12278 { 12279 return func; 12280 } 12281 12282 var objectDelegates = collection.get(thisObject); 12283 if (!objectDelegates) 12284 { 12285 objectDelegates = new WeakMap(); 12286 collection.set(thisObject, objectDelegates); 12287 } 12288 12289 var delegate = objectDelegates.get(func); 12290 if (!delegate) 12291 { 12292 delegate = decorator ? decorator(BX.delegate(func, thisObject)) : BX.delegate(func, thisObject); 12293 objectDelegates.set(func, delegate); 12294 } 12295 12296 return delegate; 12297 } 12298 12299 BX.once = function(el, evname, func) 12300 { 12301 var fn = function() 12302 { 12303 BX.unbind(el, evname, fn); 12304 func.apply(this, arguments); 12305 }; 12306 12307 return fn; 12308 }; 12309 12310 BX.bindDelegate = function (elem, eventName, isTarget, handler) 12311 { 12312 var h = BX.delegateEvent(isTarget, handler); 12313 BX.bind(elem, eventName, h); 12314 return h; 12315 }; 12316 12317 BX.delegateEvent = function(isTarget, handler) 12318 { 12319 return function(e) 12320 { 12321 e = e || window.event; 12322 var target = e.target || e.srcElement; 12323 12324 while (target != this) 12325 { 12326 if (_checkNode(target, isTarget)) 12327 { 12328 return handler.call(target, e); 12329 } 12330 if (target && target.parentNode) 12331 target = target.parentNode; 12332 else 12333 break; 12334 } 12335 return null; 12336 } 12337 }; 12338 12339 BX.False = function() {return false;}; 12340 BX.DoNothing = function() {}; 12341 12342 // TODO: also check event handlers set via BX.bind() 12343 BX.denyEvent = function(el, ev) 12344 { 12345 deniedEvents.push([el, ev, el['on' + ev]]); 12346 el['on' + ev] = BX.DoNothing; 12347 }; 12348 12349 BX.allowEvent = function(el, ev) 12350 { 12351 for(var i=0, len=deniedEvents.length; i<len; i++) 12352 { 12353 if (deniedEvents[i][0] == el && deniedEvents[i][1] == ev) 12354 { 12355 el['on' + ev] = deniedEvents[i][2]; 12356 BX.util.deleteFromArray(deniedEvents, i); 12357 return; 12358 } 12359 } 12360 }; 12361 12362 BX.fixEventPageXY = function(event) 12363 { 12364 BX.fixEventPageX(event); 12365 BX.fixEventPageY(event); 12366 return event; 12367 }; 12368 12369 BX.fixEventPageX = function(event) 12370 { 12371 if (event.pageX == null && event.clientX != null) 12372 { 12373 event.pageX = 12374 event.clientX + 12375 (document.documentElement && document.documentElement.scrollLeft || document.body && document.body.scrollLeft || 0) - 12376 (document.documentElement.clientLeft || 0); 12377 } 12378 12379 return event; 12380 }; 12381 12382 BX.fixEventPageY = function(event) 12383 { 12384 if (event.pageY == null && event.clientY != null) 12385 { 12386 event.pageY = 12387 event.clientY + 12388 (document.documentElement && document.documentElement.scrollTop || document.body && document.body.scrollTop || 0) - 12389 (document.documentElement.clientTop || 0); 12390 } 12391 12392 return event; 12393 }; 12394 12395 /** 12396 * @deprecated 12397 * @see e.preventDefault() 12398 */ 12399 BX.PreventDefault = function(e) 12400 { 12401 if(!e) e = window.event; 12402 if(e.stopPropagation) 12403 { 12404 e.preventDefault(); 12405 e.stopPropagation(); 12406 } 12407 else 12408 { 12409 e.cancelBubble = true; 12410 e.returnValue = false;
12411 } 12412 return false; 12413 }; 12414 12415 /** 12416 * @deprecated 12417 * @see e.preventDefault(); 12418 * 12419 * @param e 12420 * @return {boolean} 12421 */ 12422 BX.eventReturnFalse = function(e) 12423 { 12424 e=e||window.event; 12425 if (e && e.preventDefault) e.preventDefault(); 12426 else e.returnValue = false; 12427 return false; 12428 }; 12429 12430 /** 12431 * @deprecated 12432 * @see e.stopPropagation() 12433 * @param e 12434 */ 12435 BX.eventCancelBubble = function(e) 12436 { 12437 e=e||window.event; 12438 if(e && e.stopPropagation) 12439 e.stopPropagation(); 12440 else 12441 e.cancelBubble = true; 12442 }; 12443 12444 BX.bindDebouncedChange = function(node, fn, fnInstant, timeout, ctx) 12445 { 12446 ctx = ctx || window; 12447 timeout = timeout || 300; 12448 12449 var dataTag = 'bx-dc-previous-value'; 12450 BX.data(node, dataTag, node.value); 12451 12452 var act = function(fn, val){ 12453 12454 var pVal = BX.data(node, dataTag); 12455 12456 if(typeof pVal == 'undefined' || pVal != val){ 12457 if(typeof ctx != 'object') 12458 fn(val); 12459 else 12460 fn.apply(ctx, [val]); 12461 } 12462 }; 12463 12464 var actD = BX.debounce(function(){ 12465 var val = node.value; 12466 act(fn, val); 12467 BX.data(node, dataTag, val); 12468 }, timeout); 12469 12470 BX.bind(node, 'keyup', actD); 12471 BX.bind(node, 'change', actD); 12472 BX.bind(node, 'input', actD); 12473 12474 if(BX.type.isFunction(fnInstant)){ 12475 12476 var actI = function(){ 12477 act(fnInstant, node.value); 12478 }; 12479 12480 BX.bind(node, 'keyup', actI); 12481 BX.bind(node, 'change', actI); 12482 BX.bind(node, 'input', actI); 12483 } 12484 }; 12485 12486 BX.parseJSON = function(data, context) 12487 { 12488 var result = null; 12489 if (BX.type.isNotEmptyString(data)) 12490 { 12491 try { 12492 if (data.indexOf("\n") >= 0) 12493 eval('result = ' + data); 12494 else 12495 result = (new Function("return " + data))(); 12496 } catch(e) { 12497 BX.onCustomEvent(context, 'onParseJSONFailure', [data, context]) 12498 } 12499 } 12500 else if(BX.type.isPlainObject(data)) 12501 { 12502 return data; 12503 } 12504 12505 return result; 12506 }; 12507 12508 BX.submit = function(obForm, action_name, action_value, onAfterSubmit) 12509 { 12510 action_name = action_name || 'save'; 12511 if (!obForm['BXFormSubmit_' + action_name]) 12512 { 12513 obForm['BXFormSubmit_' + action_name] = obForm.appendChild(BX.create('INPUT', { 12514 'props': { 12515 'type': 'submit', 12516 'name': action_name, 12517 'value': action_value || 'Y' 12518 }, 12519 'style': { 12520 'display': 'none' 12521 } 12522 })); 12523 } 12524 12525 if (obForm.sessid) 12526 obForm.sessid.value = BX.bitrix_sessid(); 12527 12528 setTimeout(BX.delegate(function() {BX.fireEvent(this, 'click'); if (onAfterSubmit) onAfterSubmit();}, obForm['BXFormSubmit_' + action_name]), 10); 12529 }; 12530 12531 BX.show = function(ob, displayType) 12532 { 12533 if (ob.BXDISPLAY || !_checkDisplay(ob, displayType)) 12534 { 12535 ob.style.display = ob.BXDISPLAY; 12536 } 12537 }; 12538 12539 BX.hide = function(ob, displayType) 12540 { 12541 if (!ob.BXDISPLAY) 12542 _checkDisplay(ob, displayType); 12543 12544 ob.style.display = 'none'; 12545 }; 12546 12547 BX.toggle = function(ob, values) 12548 { 12549 if (!values && BX.type.isElementNode(ob)) 12550 { 12551 var bShow = true; 12552 if (ob.BXDISPLAY) 12553 bShow = !_checkDisplay(ob); 12554 else 12555 bShow = ob.style.display == 'none'; 12556 12557 if (bShow) 12558 BX.show(ob); 12559 else 12560 BX.hide(ob); 12561 } 12562 else if (BX.type.isArray(values)) 12563 { 12564 for (var i=0,len=values.length; i<len; i++) 12565 { 12566 if (ob == values[i]) 12567 { 12568 ob = values[i==len-1 ? 0 : i+1]; 12569 break; 12570 } 12571 } 12572 if (i==len) 12573 ob = values[0]; 12574 } 12575 12576 return ob; 12577 }; 12578 12579 function _checkDisplay(ob, displayType) 12580 { 12581 if (typeof displayType != 'undefined') 12582 ob.BXDISPLAY = displayType; 12583 12584 var d = ob.style.display || BX.style(ob, 'display'); 12585 if (d != 'none') 12586 { 12587 ob.BXDISPLAY = ob.BXDISPLAY || d; 12588 return true; 12589 } 12590 else 12591 { 12592 ob.BXDISPLAY = ob.BXDISPLAY || 'block'; 12593 return false; 12594 } 12595 } 12596 12597 /* some useful util functions */ 12598 12599 BX.util = { 12600 /** 12601 * @deprecated 12602 * @use [].filter(value => !BX.Type.isNil(value)) 12603 * @param ar 12604 * @return {*} 12605 */ 12606 array_values: function(ar) 12607 { 12608 if (!BX.type.isArray(ar)) 12609 return BX.util._array_values_ob(ar); 12610 var arv = []; 12611 for(var i=0,l=ar.length;i<l;i++) 12612 if (ar[i] !== null && typeof ar[i] != 'undefined') 12613 arv.push(ar[i]); 12614 return arv; 12615 }, 12616 12617 /** 12618 * @deprecated 12619 * @use Object.values([]).filter(value => !BX.Type.isNil(value)) 12620 * @param ar 12621 * @return {Array} 12622 * @private 12623 */ 12624 _array_values_ob: function(ar) 12625 { 12626 var arv = []; 12627 for(var i in ar) 12628 if (ar[i] !== null && typeof ar[i] != 'undefined') 12629 arv.push(ar[i]); 12630 return arv; 12631 }, 12632 12633 /** 12634 * @deprecated 12635 * @use 12636 * @param ar 12637 * @return {*} 12638 */ 12639 array_keys: function(ar) 12640 { 12641 if (!BX.type.isArray(ar)) 12642 return BX.util._array_keys_ob(ar); 12643 var arv = []; 12644 for(var i=0,l=ar.length;i<l;i++) 12645 if (ar[i] !== null && typeof ar[i] != 'undefined') 12646 arv.push(i); 12647 return arv; 12648 }, 12649 12650 _array_keys_ob: function(ar) 12651 { 12652 var arv = []; 12653 for(var i in ar) 12654 if (ar[i] !== null && typeof ar[i] != 'undefined') 12655 arv.push(i); 12656 return arv; 12657 }, 12658 12659 object_keys: function(obj) 12660 { 12661 var arv = []; 12662 for(var k in obj) 12663 { 12664 if(obj.hasOwnProperty(k)) 12665 { 12666 arv.push(k); 12667 } 12668 } 12669 return arv; 12670 }, 12671 12672 /** 12673 * @deprecated 12674 * @use firstArr.concat(secondArr); 12675 * @param first 12676 * @param second 12677 * @return {*[]} 12678 */ 12679 array_merge: function(first, second) 12680 { 12681 if (!BX.type.isArray(first)) first = []; 12682 if (!BX.type.isArray(second)) second = []; 12683 12684 var i = first.length, j = 0; 12685 12686 if (typeof second.length === "number") 12687 { 12688 for (var l = second.length; j < l; j++) 12689 { 12690 first[i++] = second[j]; 12691 } 12692 } 12693 else 12694 {
12695 while (second[j] !== undefined) 12696 { 12697 first[i++] = second[j++]; 12698 } 12699 } 12700 12701 first.length = i; 12702 12703 return first; 12704 }, 12705 12706 array_flip: function (object) 12707 { 12708 var newObject = {}; 12709 12710 for (var key in object) 12711 { 12712 newObject[object[key]] = key; 12713 } 12714 12715 return newObject; 12716 }, 12717 12718 array_diff: function(ar1, ar2, hash) 12719 { 12720 hash = BX.type.isFunction(hash) ? hash : null; 12721 var i, length, v, h, map = {}, result = []; 12722 for(i = 0, length = ar2.length; i < length; i++) 12723 { 12724 v = ar2[i]; 12725 h = hash ? hash(v) : v; 12726 map[h] = true; 12727 } 12728 12729 for(i = 0, length = ar1.length; i < length; i++) 12730 { 12731 v = ar1[i]; 12732 h = hash ? hash(v) : v; 12733 if(typeof(map[h]) === "undefined") 12734 { 12735 result.push(v); 12736 } 12737 } 12738 return result; 12739 }, 12740 12741 /** 12742 * @deprecated 12743 * @use Set 12744 */ 12745 array_unique: function(ar) 12746 { 12747 var i=0,j,len=ar.length; 12748 if(len<2) return ar; 12749 12750 for (; i<len-1;i++) 12751 { 12752 for (j=i+1; j<len;j++) 12753 { 12754 if (ar[i]==ar[j]) 12755 { 12756 ar.splice(j--,1); len--; 12757 } 12758 } 12759 } 12760 12761 return ar; 12762 }, 12763 12764 /** 12765 * @deprecated 12766 * @use myArr.includes(needle) 12767 */ 12768 in_array: function(needle, haystack) 12769 { 12770 for(var i=0; i<haystack.length; i++) 12771 { 12772 if(haystack[i] == needle) 12773 return true; 12774 } 12775 return false; 12776 }, 12777 12778 /** 12779 * @deprecated 12780 * @use myArr.findIndex(item => item === needle); 12781 */ 12782 array_search: function(needle, haystack) 12783 { 12784 for(var i=0; i<haystack.length; i++) 12785 { 12786 if(haystack[i] == needle) 12787 return i; 12788 } 12789 return -1; 12790 }, 12791 12792 object_search_key: function(needle, haystack) 12793 { 12794 if (typeof haystack[needle] != 'undefined') 12795 return haystack[needle]; 12796 12797 for(var i in haystack) 12798 { 12799 if (typeof haystack[i] == "object") 12800 { 12801 var result = BX.util.object_search_key(needle, haystack[i]); 12802 if (result !== false) 12803 return result; 12804 } 12805 } 12806 return false; 12807 }, 12808 12809 trim: function(s) 12810 { 12811 if (BX.type.isString(s)) 12812 { 12813 return s.trim(); 12814 } 12815 12816 return s; 12817 }, 12818 12819 urlencode: function(s){return encodeURIComponent(s);}, 12820 12821 // it may also be useful. via sVD. 12822 deleteFromArray: function(ar, ind) {return ar.slice(0, ind).concat(ar.slice(ind + 1));}, 12823 insertIntoArray: function(ar, ind, el) {return ar.slice(0, ind).concat([el]).concat(ar.slice(ind));}, 12824 12825 htmlspecialchars: function(str) 12826 { 12827 return BX.Text.encode(str); 12828 }, 12829 12830 htmlspecialcharsback: function(str) 12831 { 12832 return BX.Text.decode(str); 12833 }, 12834 12835 // Quote regular expression characters plus an optional character 12836 preg_quote: function(str, delimiter) 12837 { 12838 if(!str.replace) 12839 return str; 12840 return str.replace(new RegExp('[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + (delimiter || '') + '-]', 'g'), '\\$&'); 12841 }, 12842 12843 jsencode: function(str) 12844 { 12845 if (!str || !str.replace) 12846 return str; 12847 12848 var escapes = 12849 [ 12850 { c: "\\\\", r: "\\\\" }, // should be first 12851 { c: "\\t", r: "\\t" }, 12852 { c: "\\n", r: "\\n" }, 12853 { c: "\\r", r: "\\r" }, 12854 { c: "\"", r: "\\\"" }, 12855 { c: "'", r: "\\'" }, 12856 { c: "<", r: "\\x3C" }, 12857 { c: ">", r: "\\x3E" }, 12858 { c: "\\u2028", r: "\\u2028" }, 12859 { c: "\\u2029", r: "\\u2029" } 12860 ]; 12861 for (var i = 0; i < escapes.length; i++) 12862 str = str.replace(new RegExp(escapes[i].c, 'g'), escapes[i].r); 12863 return str; 12864 }, 12865 12866 getCssName: function(jsName) 12867 { 12868 if (!BX.type.isNotEmptyString(jsName)) 12869 { 12870 return ""; 12871 } 12872 12873 return jsName.replace(/[A-Z]/g, function(match) { 12874 return "-" + match.toLowerCase(); 12875 }); 12876 }, 12877 12878 getJsName: function(cssName) 12879 { 12880 var regex = /\-([a-z]){1}/g; 12881 if (regex.test(cssName)) 12882 { 12883 return cssName.replace(regex, function(match, letter) { 12884 return letter.toUpperCase(); 12885 }); 12886 } 12887 12888 return cssName; 12889 }, 12890 12891 nl2br: function(str) 12892 { 12893 if (!str || !str.replace) 12894 return str; 12895 12896 return str.replace(/([^>])\n/g, '$1<br/>'); 12897 }, 12898 12899 /** 12900 * @deprecated 12901 * @use .padStart() / .padEnd() 12902 * @param input 12903 * @param pad_length 12904 * @param pad_string 12905 * @param pad_type 12906 * @return {*} 12907 */ 12908 str_pad: function(input, pad_length, pad_string, pad_type) 12909 { 12910 pad_string = pad_string || ' '; 12911 pad_type = pad_type || 'right'; 12912 input = input.toString(); 12913 12914 if (pad_type === 'left') 12915 { 12916 return BX.util.str_pad_left(input, pad_length, pad_string); 12917 } 12918 12919 return BX.util.str_pad_right(input, pad_length, pad_string); 12920 }, 12921 12922 str_pad_left: function(input, pad_length, pad_string) 12923 { 12924 return input.toString().padStart(pad_length, pad_string); 12925 }, 12926 12927 str_pad_right: function(input, pad_length, pad_string) 12928 { 12929 return input.toString().padEnd(pad_length, pad_string); 12930 }, 12931 12932 strip_tags: function(str) 12933 { 12934 return str.split(/<[^>]+>/g).join(''); 12935 }, 12936 12937 strip_php_tags: function(str) 12938 { 12939 return str.replace(/<\?(.|[\r\n])*?\?>/g, ''); 12940 }, 12941 12942 popup: function(url, width, height) 12943 { 12944 var w, h; 12945 if(BX.browser.IsOpera()) 12946 { 12947 w = document.body.offsetWidth; 12948 h = document.body.offsetHeight; 12949 } 12950 else 12951 {
12952 w = screen.width; 12953 h = screen.height; 12954 } 12955 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)); 12956 }, 12957 12958 shuffle: function(array) 12959 { 12960 var temporaryValue, randomIndex; 12961 var currentIndex = array.length; 12962 12963 while (0 !== currentIndex) 12964 { 12965 randomIndex = Math.floor(Math.random() * currentIndex); 12966 currentIndex -= 1; 12967 12968 temporaryValue = array[currentIndex]; 12969 array[currentIndex] = array[randomIndex]; 12970 array[randomIndex] = temporaryValue; 12971 } 12972 12973 return array; 12974 }, 12975 12976 // BX.util.objectSort(object, sortBy, sortDir) - Sort object by property 12977 // function params: 1 - object for sort, 2 - sort by property, 3 - sort direction (asc/desc) 12978 // return: sort array [[objectElement], [objectElement]] in sortDir direction 12979 12980 // example: BX.util.objectSort({'L1': {'name': 'Last'}, 'F1': {'name': 'First'}}, 'name', 'asc'); 12981 // return: [{'name' : 'First'}, {'name' : 'Last'}] 12982 objectSort: function(object, sortBy, sortDir) 12983 { 12984 sortDir = sortDir == 'asc'? 'asc': 'desc'; 12985 12986 var arItems = [], i; 12987 for (i in object) 12988 { 12989 if (object.hasOwnProperty(i) && object[i][sortBy]) 12990 { 12991 arItems.push([i, object[i][sortBy]]); 12992 } 12993 } 12994 12995 if (sortDir == 'asc') 12996 { 12997 arItems.sort(function(i, ii) { 12998 var s1, s2; 12999 if (BX.type.isDate(i[1])) 13000 { 13001 s1 = i[1].getTime(); 13002 } 13003 else if (!isNaN(i[1])) 13004 { 13005 s1 = parseInt(i[1]); 13006 } 13007 else 13008 { 13009 s1 = i[1].toString().toLowerCase(); 13010 } 13011 13012 if (BX.type.isDate(ii[1])) 13013 { 13014 s2 = ii[1].getTime(); 13015 } 13016 else if (!isNaN(ii[1])) 13017 { 13018 s2 = parseInt(ii[1]); 13019 } 13020 else 13021 { 13022 s2 = ii[1].toString().toLowerCase(); 13023 } 13024 13025 if (s1 > s2) 13026 return 1; 13027 else if (s1 < s2) 13028 return -1; 13029 else 13030 return 0; 13031 }); 13032 } 13033 else 13034 { 13035 arItems.sort(function(i, ii) { 13036 var s1, s2; 13037 if (BX.type.isDate(i[1])) 13038 { 13039 s1 = i[1].getTime(); 13040 } 13041 else if (!isNaN(i[1])) 13042 { 13043 s1 = parseInt(i[1]); 13044 } 13045 else 13046 { 13047 s1 = i[1].toString().toLowerCase(); 13048 } 13049 13050 if (BX.type.isDate(ii[1])) 13051 { 13052 s2 = ii[1].getTime(); 13053 } 13054 else if (!isNaN(ii[1])) 13055 { 13056 s2 = parseInt(ii[1]); 13057 } 13058 else 13059 { 13060 s2 = ii[1].toString().toLowerCase(); 13061 } 13062 13063 if (s1 < s2) 13064 return 1; 13065 else if (s1 > s2) 13066 return -1; 13067 else 13068 return 0; 13069 }); 13070 } 13071 13072 var arReturnArray = Array(); 13073 for (i = 0; i < arItems.length; i++) 13074 { 13075 arReturnArray.push(object[arItems[i][0]]); 13076 } 13077 13078 return arReturnArray; 13079 }, 13080 13081 objectMerge: function() 13082 { 13083 return BX.mergeEx.apply(window, arguments); 13084 }, 13085 13086 objectClone : function(object) 13087 { 13088 return BX.clone(object, true); 13089 }, 13090 13091 // #fdf9e5 => {r=253, g=249, b=229} 13092 hex2rgb: function(color) 13093 { 13094 var rgb = color.replace(/[# ]/g,"").replace(/^(.)(.)(.)$/,'$1$1$2$2$3$3').match(/.{2}/g); 13095 for (var i=0; i<3; i++) 13096 { 13097 rgb[i] = parseInt(rgb[i], 16); 13098 } 13099 return {'r':rgb[0],'g':rgb[1],'b':rgb[2]}; 13100 }, 13101 13102 /** 13103 * @deprecated 13104 * @use BX.Uri 13105 * @param url 13106 * @param param 13107 * @return {string} 13108 */ 13109 remove_url_param: function(url, param) 13110 { 13111 return BX.Uri.removeParam(url, param); 13112 }, 13113 13114 /* 13115 {'param1': 'value1', 'param2': 'value2'} 13116 */ 13117 /** 13118 * @deprecated 13119 * @use BX.Uri 13120 * @param url 13121 * @param params 13122 * @return {string} 13123 */ 13124 add_url_param: function(url, params) 13125 { 13126 var preparedParams = Object.entries(params).reduce(function(acc, item) { 13127 acc[item[0]] = BX.type.isArray(item[1]) ? item[1].join() : item[1]; 13128 return acc; 13129 }, {}); 13130 13131 return BX.Uri.addParam(url, preparedParams); 13132 }, 13133 13134 /* 13135 {'param1': 'value1', 'param2': 'value2'} 13136 */ 13137 buildQueryString: function(params) 13138 { 13139 var result = ''; 13140 for (var key in params) 13141 { 13142 var value = params[key]; 13143 if(BX.type.isArray(value)) 13144 { 13145 value.forEach(function(valueElement, index) 13146 { 13147 result += encodeURIComponent(key + "[" + index + "]") + "=" + encodeURIComponent(valueElement) + "&"; 13148 }); 13149 } 13150 else 13151 { 13152 result += encodeURIComponent(key) + "=" + encodeURIComponent(value) + "&"; 13153 } 13154 } 13155 13156 if(result.length > 0) 13157 { 13158 result = result.substr(0, result.length - 1); 13159 } 13160 return result; 13161 }, 13162 13163 even: function(digit) 13164 { 13165 return (parseInt(digit) % 2 == 0); 13166 }, 13167 13168 hashCode: function(str) 13169 { 13170 if(!BX.type.isNotEmptyString(str)) 13171 { 13172 return 0; 13173 } 13174 13175 var hash = 0; 13176 for (var i = 0; i < str.length; i++) 13177 { 13178 var c = str.charCodeAt(i); 13179 hash = ((hash << 5) - hash) + c; 13180 hash = hash & hash; 13181 } 13182 return hash; 13183 }, 13184 13185 getRandomString: function (length) 13186 { 13187 return BX.Text.getRandom(length); 13188 }, 13189 13190 number_format: function(number, decimals, dec_point, thousands_sep) 13191 { 13192 var i, j, kw, kd, km, sign = ''; 13193 decimals = Math.abs(decimals); 13194 if (isNaN(decimals) || decimals < 0) 13195 { 13196 decimals = 2; 13197 } 13198 dec_point = dec_point || ','; 13199 if (typeof thousands_sep === 'undefined') 13200 thousands_sep = '.'; 13201 13202 number = (+number || 0).toFixed(decimals); 13203 if (number < 0) 13204 { 13205 sign = '-'; 13206 number = -number; 13207 } 13208 13209 i = parseInt(number, 10) + ''; 13210 j = (i.length > 3 ? i.length % 3 : 0); 13211 13212 km = (j ? i.substr(0, j) + thousands_sep : ''); 13213 kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep); 13214 kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, '0').slice(2) : ''); 13215 13216 return sign + km + kw + kd; 13217 }, 13218 13219 getExtension: function (url) 13220 { 13221 url = url || ""; 13222 var items = url.split("?")[0].split("."); 13223 return items[items.length-1].toLowerCase(); 13224 }, 13225 addObjectToForm: function(object, form, prefix) 13226 { 13227 if(!BX.type.isString(prefix)) 13228 { 13229 prefix = ""; 13230 } 13231 13232 for(var key in object) 13233 { 13234 if(!object.hasOwnProperty(key)) 13235 { 13236 continue; 13237 } 13238 13239 var value = object[key]; 13240 var name = prefix !== "" ? (prefix + "[" + key + "]") : key; 13241 if(BX.type.isArray(value)) 13242 { 13243 var obj = {}; 13244 for(var i = 0; i < value.length; i++) 13245 { 13246 obj[i] = value[i]; 13247 } 13248 13249 BX.util.addObjectToForm(obj, form, name); 13250 } 13251 else if(BX.type.isPlainObject(value)) 13252 { 13253 BX.util.addObjectToForm(value, form, name); 13254 } 13255 else 13256 { 13257 value = BX.type.isFunction(value.toString) ? value.toString() : ""; 13258 if(value !== "") 13259 { 13260 form.appendChild(BX.create("INPUT", { attrs: { type: "hidden", name: name, value: value } })); 13261 } 13262 } 13263 } 13264 }, 13265 13266 observe: function(object, enable) 13267 {
13268 console.error('BX.util.observe: function is no longer supported by browser.'); 13269 return false; 13270 }, 13271 13272 escapeRegExp: function(str) 13273 { 13274 return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); 13275 } 13276 }; 13277 13278 BX.validation = { 13279 checkIfEmail: function(s) 13280 { 13281 var atom = "[=a-z0-9_+~'!$&*^`|#%/?{}-]"; 13282 return (new RegExp('^\\s*'+atom+'+(\\.'+atom+'+)*@([a-z0-9-]+\\.)+[a-z0-9-]{2,20}\\s*$', 'i')).test(s); 13283 }, 13284 checkIfPhone: function(s) 13285 { 13286 var regexp = new RegExp( 13287 typeof(BX.PhoneNumber) === "undefined" 13288 ? BX.PhoneNumber.getValidNumberPattern() 13289 : '^\\s*\\+?\s*[0-9(-)\\s]+\\s*$', 13290 'i' 13291 ); 13292 return regexp.test(s); 13293 } 13294 }; 13295 13296 BX.prop = 13297 { 13298 get: function(object, key, defaultValue) 13299 { 13300 return object && object.hasOwnProperty(key) ? object[key] : defaultValue; 13301 }, 13302 getObject: function(object, key, defaultValue) 13303 { 13304 return object && BX.type.isPlainObject(object[key]) ? object[key] : defaultValue; 13305 }, 13306 getElementNode: function(object, key, defaultValue) 13307 { 13308 return object && BX.type.isElementNode(object[key]) ? object[key] : defaultValue; 13309 }, 13310 getArray: function(object, key, defaultValue) 13311 { 13312 return object && BX.type.isArray(object[key]) ? object[key] : defaultValue; 13313 }, 13314 getFunction: function(object, key, defaultValue) 13315 { 13316 return object && BX.type.isFunction(object[key]) ? object[key] : defaultValue; 13317 }, 13318 getNumber: function(object, key, defaultValue) 13319 { 13320 if(!(object && object.hasOwnProperty(key))) 13321 { 13322 return defaultValue; 13323 } 13324 13325 var value = object[key]; 13326 if(BX.type.isNumber(value)) 13327 { 13328 return value; 13329 } 13330 13331 value = parseFloat(value); 13332 return !isNaN(value) ? value : defaultValue; 13333 }, 13334 getInteger: function(object, key, defaultValue) 13335 { 13336 if(!(object && object.hasOwnProperty(key))) 13337 { 13338 return defaultValue; 13339 } 13340 13341 var value = object[key]; 13342 if(BX.type.isNumber(value)) 13343 { 13344 return value; 13345 } 13346 13347 value = parseInt(value); 13348 return !isNaN(value) ? value : defaultValue; 13349 }, 13350 getBoolean: function(object, key, defaultValue) 13351 { 13352 if(!(object && object.hasOwnProperty(key))) 13353 { 13354 return defaultValue; 13355 } 13356 13357 var value = object[key]; 13358 return (BX.type.isBoolean(value) 13359 ? value 13360 : (BX.type.isString(value) ? (value.toLowerCase() === "true") : !!value) 13361 ); 13362 }, 13363 getString: function(object, key, defaultValue) 13364 { 13365 if(!(object && object.hasOwnProperty(key))) 13366 { 13367 return defaultValue; 13368 } 13369 13370 var value = object[key]; 13371 return BX.type.isString(value) ? value : (value ? value.toString() : ''); 13372 }, 13373 extractDate: function(datetime) 13374 { 13375 if(!BX.type.isDate(datetime)) 13376 { 13377 datetime = new Date(); 13378 } 13379 13380 datetime.setHours(0); 13381 datetime.setMinutes(0); 13382 datetime.setSeconds(0); 13383 datetime.setMilliseconds(0); 13384 13385 return datetime; 13386 } 13387 }; 13388 13389 BX.isNodeInDom = function(node, doc) 13390 { 13391 return node === (doc || document) ? true : 13392 (node.parentNode ? BX.isNodeInDom(node.parentNode) : false); 13393 }; 13394 13395 BX.isNodeHidden = function(node) 13396 { 13397 if (node === document) 13398 return false; 13399 else if (BX.style(node, 'display') == 'none') 13400 return true; 13401 else 13402 return (node.parentNode ? BX.isNodeHidden(node.parentNode) : true); 13403 }; 13404 13405 BX.evalPack = function(code) 13406 { 13407 while (code.length > 0) 13408 { 13409 var c = code.shift(); 13410 13411 if (c.TYPE == 'SCRIPT_EXT' || c.TYPE == 'SCRIPT_SRC') 13412 { 13413 BX.loadScript(c.DATA, function() {BX.evalPack(code)}); 13414 return; 13415 } 13416 else if (c.TYPE == 'SCRIPT') 13417 { 13418 BX.evalGlobal(c.DATA); 13419 } 13420 } 13421 }; 13422 13423 BX.evalGlobal = function(data) 13424 { 13425 if (data) 13426 { 13427 var head = document.getElementsByTagName("head")[0] || document.documentElement, 13428 script = document.createElement("script"); 13429 13430 script.type = "text/javascript"; 13431 13432 if (!BX.browser.IsIE()) 13433 { 13434 script.appendChild(document.createTextNode(data)); 13435 } 13436 else 13437 { 13438 script.text = data; 13439 } 13440 13441 head.insertBefore(script, head.firstChild); 13442 head.removeChild(script); 13443 } 13444 }; 13445 13446 BX.garbage = function(call, thisObject) 13447 { 13448 garbageCollectors.push({callback: call, context: thisObject}); 13449 }; 13450 13451 BX.GetDocElement = function (pDoc) 13452 { 13453 pDoc = pDoc || document; 13454 return (BX.browser.IsDoctype(pDoc) ? pDoc.documentElement : pDoc.body); 13455 }; 13456 13457 BX.scrollTop = function(node, val){ 13458 if(typeof val != 'undefined'){ 13459 13460 if(node == window){ 13461 throw new Error('scrollTop() for window is not implemented'); 13462 }else 13463 node.scrollTop = parseInt(val); 13464 13465 }else{ 13466 13467 if(node == window) 13468 return BX.GetWindowScrollPos().scrollTop; 13469 13470 return node.scrollTop; 13471 } 13472 }; 13473 13474 BX.scrollLeft = function(node, val){ 13475 if(typeof val != 'undefined'){ 13476 13477 if(node == window){ 13478 throw new Error('scrollLeft() for window is not implemented'); 13479 }else 13480 node.scrollLeft = parseInt(val); 13481 13482 }else{ 13483 13484 if(node == window) 13485 return BX.GetWindowScrollPos().scrollLeft; 13486 13487 return node.scrollLeft; 13488 } 13489 }; 13490 13491 BX.hide_object = function(ob) 13492 { 13493 ob = BX(ob); 13494 ob.style.position = 'absolute'; 13495 ob.style.top = '-1000px'; 13496 ob.style.left = '-1000px'; 13497 ob.style.height = '10px'; 13498 ob.style.width = '10px'; 13499 }; 13500 13501 BX.is_relative = function(el) 13502 { 13503 var p = BX.style(el, 'position'); 13504 return p == 'relative' || p == 'absolute'; 13505 }; 13506 13507 BX.is_float = function(el) 13508 { 13509 var p = BX.style(el, 'float'); 13510 return p == 'right' || p == 'left'; 13511 }; 13512 13513 BX.is_fixed = function(el) 13514 { 13515 var p = BX.style(el, 'position'); 13516 return p == 'fixed'; 13517 }; 13518 13519 BX.width = function(node, val){ 13520 if(typeof val != 'undefined') 13521 BX.style(node, 'width', parseInt(val)+'px'); 13522 else{ 13523 13524 if(node == window) 13525 return window.innerWidth; 13526 13527 //return parseInt(BX.style(node, 'width')); 13528 return BX.pos(node).width; 13529 } 13530 }; 13531 13532 BX.height = function(node, val){ 13533 if(typeof val != 'undefined') 13534 BX.style(node, 'height', parseInt(val)+'px'); 13535 else{ 13536 13537 if(node == window) 13538 return window.innerHeight; 13539 13540 //return parseInt(BX.style(node, 'height')); 13541 return BX.pos(node).height; 13542 } 13543 }; 13544 13545 BX.align = function(pos, w, h, type) 13546 { 13547 if (type) 13548 type = type.toLowerCase(); 13549 else 13550 type = ''; 13551 13552 var pDoc = document; 13553 if (BX.type.isElementNode(pos)) 13554 { 13555 pDoc = pos.ownerDocument; 13556 pos = BX.pos(pos); 13557 } 13558 13559 var x = pos["left"], y = pos["bottom"]; 13560 13561 var scroll = BX.GetWindowScrollPos(pDoc); 13562 var size = BX.GetWindowInnerSize(pDoc); 13563 13564 if((size.innerWidth + scroll.scrollLeft) - (pos["left"] + w) < 0) 13565 { 13566 if(pos["right"] - w >= 0 ) 13567 x = pos["right"] - w; 13568 else 13569 x = scroll.scrollLeft; 13570 } 13571
13572 if(((size.innerHeight + scroll.scrollTop) - (pos["bottom"] + h) < 0) || ~type.indexOf('top')) 13573 { 13574 if(pos["top"] - h >= 0 || ~type.indexOf('top')) 13575 y = pos["top"] - h; 13576 else 13577 y = scroll.scrollTop; 13578 } 13579 13580 return {'left':x, 'top':y}; 13581 }; 13582 13583 BX.scrollToNode = function(node) 13584 { 13585 var obNode = BX(node); 13586 13587 if (obNode.scrollIntoView) 13588 obNode.scrollIntoView(true); 13589 else 13590 { 13591 var arNodePos = BX.pos(obNode); 13592 window.scrollTo(arNodePos.left, arNodePos.top); 13593 } 13594 }; 13595 13596 /* non-xhr loadings */ 13597 BX.showWait = function(node, msg) 13598 { 13599 node = BX(node) || document.body || document.documentElement; 13600 msg = msg || BX.message('JS_CORE_LOADING'); 13601 13602 var container_id = node.id || Math.random(); 13603 13604 var obMsg = node.bxmsg = document.body.appendChild(BX.create('DIV', { 13605 props: { 13606 id: 'wait_' + container_id 13607 }, 13608 style: { 13609 background: 'url("/bitrix/js/main/core/images/wait.gif") no-repeat scroll 10px center #fcf7d1', 13610 border: '1px solid #E1B52D', 13611 color: 'black', 13612 fontFamily: 'Verdana,Arial,sans-serif', 13613 fontSize: '11px', 13614 padding: '10px 30px 10px 37px', 13615 position: 'absolute', 13616 textAlign:'center' 13617 }, 13618 text: msg 13619 })); 13620 13621 BX.ZIndexManager.register(obMsg); 13622 BX.ZIndexManager.bringToFront(obMsg); 13623 13624 setTimeout(BX.delegate(_adjustWait, node), 10); 13625 13626 lastWait[lastWait.length] = obMsg; 13627 return obMsg; 13628 }; 13629 13630 BX.closeWait = function(node, obMsg) 13631 { 13632 if(node && !obMsg) 13633 obMsg = node.bxmsg; 13634 if(node && !obMsg && BX.hasClass(node, 'bx-core-waitwindow')) 13635 obMsg = node; 13636 if(node && !obMsg) 13637 obMsg = BX('wait_' + node.id); 13638 if(!obMsg) 13639 obMsg = lastWait.pop(); 13640 13641 if (obMsg && obMsg.parentNode) 13642 { 13643 for (var i=0,len=lastWait.length;i<len;i++) 13644 { 13645 if (obMsg == lastWait[i]) 13646 { 13647 lastWait = BX.util.deleteFromArray(lastWait, i); 13648 break; 13649 } 13650 } 13651 13652 BX.ZIndexManager.unregister(obMsg); 13653 obMsg.parentNode.removeChild(obMsg); 13654 if (node) node.bxmsg = null; 13655 BX.cleanNode(obMsg, true); 13656 } 13657 }; 13658 13659 BX.setJSList = function(scripts) 13660 { 13661 if (BX.type.isArray(scripts)) 13662 { 13663 scripts = scripts.map(function(script) { 13664 return normalizeUrl(script) 13665 }); 13666 13667 jsList = jsList.concat(scripts); 13668 } 13669 }; 13670 13671 BX.getJSList = function() 13672 { 13673 initJsList(); 13674 return jsList; 13675 }; 13676 13677 BX.setCSSList = function(cssFiles) 13678 { 13679 if (BX.type.isArray(cssFiles)) 13680 { 13681 cssFiles = cssFiles.map(function(cssFile) { 13682 return normalizeUrl(cssFile); 13683 }); 13684 13685 cssList = cssList.concat(cssFiles); 13686 } 13687 }; 13688 13689 BX.getCSSList = function() 13690 { 13691 initCssList(); 13692 return cssList; 13693 }; 13694 13695 BX.getJSPath = function(js) 13696 { 13697 return js.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 13698 }; 13699 13700 BX.getCSSPath = function(css) 13701 { 13702 return css.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 13703 }; 13704 13705 BX.getCDNPath = function(path) 13706 { 13707 return path; 13708 }; 13709 13710 BX.loadScript = function(script, callback, doc) 13711 { 13712 if (BX.type.isString(script)) 13713 { 13714 script = [script]; 13715 } 13716 13717 return BX.load(script, callback, doc); 13718 }; 13719 13720 BX.loadCSS = function(css, doc, win) 13721 { 13722 if (BX.type.isString(css)) 13723 { 13724 css = [css]; 13725 } 13726 13727 if (BX.type.isArray(css)) 13728 { 13729 css = css.map(function(url) { 13730 return { url: url, ext: "css" } 13731 }); 13732 13733 BX.load(css, null, doc); 13734 } 13735 }; 13736 13737 const LOADING = 3; 13738 const LOADED = 4; 13739 const assets = {}; 13740 13741 BX.load = function(items, callback, doc) 13742 { 13743 if (!BX.isReady) 13744 { 13745 var _args = arguments; 13746 BX.ready(function() { 13747 BX.load.apply(this, _args); 13748 }); 13749 13750 return null; 13751 } 13752 13753 doc = doc || document; 13754 13755 callback = BX.Type.isFunction(callback) ? callback : () => {}; 13756 13757 return loadAsync(items, callback, doc); 13758 }; 13759 13760 function loadAsync(items, callback, doc) 13761 { 13762 if (!BX.type.isArray(items)) 13763 { 13764 callback(); 13765 13766 return; 13767 } 13768 13769 function onLoad() 13770 { 13771 const nextAsset = queue.shift(); 13772 if (nextAsset) 13773 { 13774 load(nextAsset, onLoad, doc); 13775 } 13776 else if (allLoaded()) 13777 { 13778 callback(); 13779 } 13780 } 13781 13782 function allLoaded() 13783 { 13784 for (const name in assetMap) 13785 { 13786 if (assetMap[name].state !== LOADED) 13787 { 13788 return false; 13789 } 13790 } 13791 13792 return true; 13793 } 13794 13795 const queue = []; 13796 const assetMap = {}; 13797 items.forEach(item => { 13798 const asset = getAsset(item); 13799 if (asset && asset.state !== LOADED) 13800 { 13801 queue.push(asset); 13802 assetMap[asset.name] = asset; 13803 } 13804 }); 13805 13806 if (queue.length > 0) 13807 {
13808 const maxParallelLoads = 6; 13809 const parallelLoads = Math.min(queue.length, maxParallelLoads); 13810 const firstPackage = queue.splice(0, parallelLoads); 13811 firstPackage.forEach(asset => { 13812 load(asset, onLoad, doc); 13813 }); 13814 } 13815 else 13816 { 13817 callback(); 13818 } 13819 } 13820 13821 function load(asset, callback, doc) 13822 { 13823 callback = callback || BX.DoNothing; 13824 13825 if (asset.state === LOADED) 13826 { 13827 callback(); 13828 return; 13829 } 13830 13831 asset.state = LOADING; 13832 13833 loadAsset( 13834 asset, 13835 function () { 13836 asset.state = LOADED; 13837 callback(); 13838 }, 13839 doc 13840 ); 13841 } 13842 13843 function loadAsset(asset, callback, doc) 13844 { 13845 callback = callback || BX.DoNothing; 13846 13847 function error(event) 13848 { 13849 ele.onload = ele.onreadystatechange = ele.onerror = null; 13850 callback(); 13851 } 13852 13853 function process(event) 13854 { 13855 event = event || window.event; 13856 if (event.type === "load" || (/loaded|complete/.test(ele.readyState) && (!doc.documentMode || doc.documentMode < 9))) 13857 { 13858 window.clearTimeout(asset.errorTimeout); 13859 window.clearTimeout(asset.cssTimeout); 13860 ele.onload = ele.onreadystatechange = ele.onerror = null; 13861 callback(); 13862 } 13863 } 13864 13865 function isCssLoaded() 13866 { 13867 if (asset.state !== LOADED && asset.cssRetries <= 20) 13868 { 13869 for (var i = 0, l = doc.styleSheets.length; i < l; i++) 13870 { 13871 if (doc.styleSheets[i].href === ele.href) 13872 { 13873 process({"type": "load"}); 13874 return; 13875 } 13876 } 13877 13878 asset.cssRetries++; 13879 asset.cssTimeout = window.setTimeout(isCssLoaded, 250); 13880 } 13881 } 13882 13883 let ele = null; 13884 const ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 13885 13886 if (ext === "css") 13887 { 13888 ele = doc.createElement("link"); 13889 ele.type = "text/" + (asset.type || "css"); 13890 ele.rel = "stylesheet"; 13891 ele.href = asset.url; 13892 13893 asset.cssRetries = 0; 13894 asset.cssTimeout = window.setTimeout(isCssLoaded, 500); 13895 } 13896 else 13897 { 13898 ele = doc.createElement("script"); 13899 ele.type = "text/" + (asset.type || "javascript"); 13900 ele.src = asset.url; 13901 } 13902 13903 ele.onload = ele.onreadystatechange = process; 13904 ele.onerror = error; 13905 13906 ele.async = false; 13907 ele.defer = false; 13908 13909 asset.errorTimeout = window.setTimeout(function () { 13910 error({type: "timeout"}); 13911 }, 7000); 13912 13913 if (ext === "css") 13914 { 13915 cssList.push(normalizeMinUrl(normalizeUrl(asset.url))); 13916 } 13917 else 13918 { 13919 jsList.push(normalizeMinUrl(normalizeUrl(asset.url))); 13920 } 13921 13922 let templateLink = null; 13923 const head = doc.head || doc.getElementsByTagName("head")[0]; 13924 if (ext === "css" && (templateLink = getTemplateLink(head)) !== null) 13925 { 13926 templateLink.parentNode.insertBefore(ele, templateLink); 13927 } 13928 else 13929 { 13930 head.insertBefore(ele, head.lastChild); 13931 } 13932 } 13933 13934 function getAsset(item) 13935 { 13936 var asset = {}; 13937 if (typeof item === "object") 13938 { 13939 asset = item; 13940 asset.name = asset.name ? asset.name : BX.util.hashCode(item.url); 13941 } 13942 else 13943 { 13944 asset = { name: BX.util.hashCode(item), url : item }; 13945 } 13946 13947 var ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 13948 if ((ext === "css" && isCssLoaded(asset.url)) || isScriptLoaded(asset.url)) 13949 { 13950 asset.state = LOADED; 13951 } 13952 13953 var existing = assets[asset.name]; 13954 if (existing && existing.url === asset.url) 13955 { 13956 return existing; 13957 } 13958 13959 assets[asset.name] = asset; 13960 13961 return asset; 13962 } 13963 13964 function normalizeUrl(url) 13965 { 13966 if (!BX.type.isNotEmptyString(url)) 13967 { 13968 return ""; 13969 } 13970 13971 url = BX.getJSPath(url); 13972 url = url.replace(/\?[0-9]*$/, ""); 13973 13974 return url; 13975 } 13976 13977 function normalizeMinUrl(url) 13978 { 13979 if (!BX.type.isNotEmptyString(url)) 13980 { 13981 return ""; 13982 } 13983 13984 var minPos = url.indexOf(".min"); 13985 return minPos >= 0 ? url.substr(0, minPos) + url.substr(minPos + 4) : url; 13986 } 13987 13988 function isCssLoaded(fileSrc) 13989 { 13990 initCssList(); 13991 13992 fileSrc = normalizeUrl(fileSrc); 13993 var fileSrcMin = normalizeMinUrl(fileSrc); 13994 13995 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, cssList)) || BX.util.in_array(fileSrc, cssList); 13996 } 13997 13998 function initCssList() 13999 { 14000 if(!cssInit) 14001 { 14002 var linksCol = document.getElementsByTagName('link'); 14003 14004 if(!!linksCol && linksCol.length > 0) 14005 { 14006 for(var i = 0; i < linksCol.length; i++) 14007 { 14008 var href = linksCol[i].getAttribute('href'); 14009 if (BX.type.isNotEmptyString(href)) 14010 { 14011 href = normalizeMinUrl(normalizeUrl(href)); 14012 cssList.push(href); 14013 } 14014 } 14015 } 14016 cssInit = true; 14017 } 14018 } 14019 14020 function getTemplateLink(head) 14021 { 14022 var findLink = function(tag) 14023 { 14024 var links = head.getElementsByTagName(tag); 14025 for (var i = 0, length = links.length; i < length; i++) 14026 { 14027 var templateStyle = links[i].getAttribute("data-template-style"); 14028 if (BX.type.isNotEmptyString(templateStyle) && templateStyle == "true") 14029 { 14030 return links[i]; 14031 } 14032 } 14033 14034 return null; 14035 }; 14036 14037 var link = findLink("link"); 14038 if (link === null) 14039 { 14040 link = findLink("style"); 14041 } 14042 14043 return link; 14044 } 14045 14046 function isScriptLoaded(fileSrc) 14047 { 14048 initJsList(); 14049 14050 fileSrc = normalizeUrl(fileSrc); 14051 var fileSrcMin = normalizeMinUrl(fileSrc); 14052 14053 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, jsList)) || BX.util.in_array(fileSrc, jsList); 14054 } 14055 14056 function initJsList() 14057 { 14058 if(!jsInit) 14059 { 14060 var scriptCol = document.getElementsByTagName('script'); 14061 14062 if(!!scriptCol && scriptCol.length > 0) 14063 { 14064 for(var i=0; i<scriptCol.length; i++) 14065 { 14066 var src = scriptCol[i].getAttribute('src'); 14067 14068 if (BX.type.isNotEmptyString(src)) 14069 { 14070 src = normalizeMinUrl(normalizeUrl(src)); 14071 jsList.push(src); 14072 } 14073 } 14074 } 14075 jsInit = true; 14076 } 14077 } 14078 14079 function reloadInternal(back_url, bAddClearCache) 14080 { 14081 if (back_url === true) 14082 { 14083 bAddClearCache = true; 14084 back_url = null; 14085 } 14086 14087 var topWindow = (function() { 14088 if (BX.PageObject && BX.PageObject.getRootWindow) 14089 { 14090 return BX.PageObject.getRootWindow(); 14091 } 14092 14093 return window.top; 14094 })(); 14095 var new_href = back_url || topWindow.location.href; 14096 14097 var hashpos = new_href.indexOf('#'), hash = ''; 14098 14099 if (hashpos != -1) 14100 { 14101 hash = new_href.substr(hashpos); 14102 new_href = new_href.substr(0, hashpos); 14103 } 14104 14105 if (bAddClearCache && new_href.indexOf('clear_cache=Y') < 0) 14106 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + 'clear_cache=Y'; 14107 14108 if (hash) 14109 { 14110 // hack for clearing cache in ajax mode components with history emulation 14111 if (bAddClearCache && (hash.substr(0, 5) == 'view/' || hash.substr(0, 6) == '#view/') && hash.indexOf('clear_cache%3DY') < 0) 14112 hash += (hash.indexOf('%3F') == -1 ? '%3F' : '%26') + 'clear_cache%3DY'; 14113 14114 new_href = new_href.replace(/(\?|\&)_r=[\d]*/, ''); 14115 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + '_r='+Math.round(Math.random()*10000) + hash; 14116 } 14117 14118 topWindow.location.href = new_href; 14119 } 14120 14121 BX.reload = function(back_url, bAddClearCache) 14122 { 14123 if (window !== window.top) 14124 { 14125 BX.Runtime 14126 .loadExtension('main.pageobject') 14127 .then(function() { 14128 reloadInternal(back_url, bAddClearCache); 14129 }); 14130 } 14131 else 14132 { 14133 reloadInternal(back_url, bAddClearCache); 14134 } 14135 }; 14136 14137 BX.clearCache = function() 14138 { 14139 BX.showWait(); 14140 BX.reload(true); 14141 }; 14142 14143 BX.template = function(tpl, callback, bKillTpl) 14144 { 14145 BX.ready(function() { 14146 _processTpl(BX(tpl), callback, bKillTpl); 14147 }); 14148 }; 14149 14150 BX.isAmPmMode = function(returnConst) 14151 { 14152 if (returnConst === true) 14153 { 14154 return BX.message.AMPM_MODE; 14155 } 14156 return BX.message.AMPM_MODE !== false; 14157 }; 14158 14159 BX.formatDate = function(date, format) 14160 { 14161 date = date || new Date(); 14162 14163 var bTime = date.getHours() || date.getMinutes() || date.getSeconds(), 14164 str = !!format 14165 ? format : 14166 (bTime ? BX.message('FORMAT_DATETIME') : BX.message('FORMAT_DATE') 14167 ); 14168 14169 return str.replace(/YYYY/ig, date.getFullYear()) 14170 .replace(/MMMM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14171 .replace(/MM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14172 .replace(/DD/ig, BX.util.str_pad_left(date.getDate().toString(), 2, '0')) 14173 .replace(/HH/ig, BX.util.str_pad_left(date.getHours().toString(), 2, '0')) 14174 .replace(/MI/ig, BX.util.str_pad_left(date.getMinutes().toString(), 2, '0')) 14175 .replace(/SS/ig, BX.util.str_pad_left(date.getSeconds().toString(), 2, '0')); 14176 }; 14177 BX.formatName = function(user, template, login) 14178 { 14179 user = user || {}; 14180 template = (template || ''); 14181 var replacement = { 14182 TITLE : (user["TITLE"] || ''), 14183 NAME : (user["NAME"] || ''),
14184 LAST_NAME : (user["LAST_NAME"] || ''), 14185 SECOND_NAME : (user["SECOND_NAME"] || ''), 14186 LOGIN : (user["LOGIN"] || ''), 14187 NAME_SHORT : user["NAME"] ? user["NAME"].substr(0, 1) + '.' : '', 14188 LAST_NAME_SHORT : user["LAST_NAME"] ? user["LAST_NAME"].substr(0, 1) + '.' : '', 14189 SECOND_NAME_SHORT : user["SECOND_NAME"] ? user["SECOND_NAME"].substr(0, 1) + '.' : '', 14190 EMAIL : (user["EMAIL"] || ''), 14191 ID : (user["ID"] || ''), 14192 NOBR : "", 14193 '/NOBR' : "" 14194 }, result = template; 14195 for (var ii in replacement) 14196 { 14197 if (replacement.hasOwnProperty(ii)) 14198 { 14199 result = result.replace("#" + ii+ "#", replacement[ii]) 14200 } 14201 } 14202 result = result.replace(/([\s]+)/gi, " ").trim(); 14203 if (result == "") 14204 { 14205 result = (login == "Y" ? replacement["LOGIN"] : ""); 14206 result = (result == "" ? "Noname" : result); 14207 } 14208 return result; 14209 }; 14210 14211 BX.getNumMonth = function(month) 14212 { 14213 var wordMonthCut = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; 14214 var wordMonth = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']; 14215 14216 var q = month.toUpperCase(); 14217 for (i = 1; i <= 12; i++) 14218 { 14219 if (q == BX.message('MON_'+i).toUpperCase() || q == BX.message('MONTH_'+i).toUpperCase() || q == wordMonthCut[i-1].toUpperCase() || q == wordMonth[i-1].toUpperCase()) 14220 { 14221 return i; 14222 } 14223 } 14224 return month; 14225 }; 14226 14227 BX.parseDate = function(str, bUTC, formatDate, formatDatetime) 14228 { 14229 if (BX.type.isNotEmptyString(str)) 14230 { 14231 if (!formatDate) 14232 formatDate = BX.message('FORMAT_DATE'); 14233 if (!formatDatetime) 14234 formatDatetime = BX.message('FORMAT_DATETIME'); 14235 14236 var regMonths = ''; 14237 for (i = 1; i <= 12; i++) 14238 { 14239 regMonths = regMonths + '|' + BX.message('MON_'+i); 14240 } 14241
14242 var expr = new RegExp('([0-9]+|[a-z]+' + regMonths + ')', 'ig'); 14243 var aDate = str.match(expr), 14244 aFormat = formatDate.match(/(DD|MI|MMMM|MM|M|YYYY)/ig), 14245 i, cnt, 14246 aDateArgs=[], aFormatArgs=[], 14247 aResult={}; 14248 14249 if (!aDate) 14250 return null; 14251 14252 if(aDate.length > aFormat.length) 14253 { 14254 aFormat = formatDatetime.match(/(DD|MI|MMMM|MM|M|YYYY|HH|H|SS|TT|T|GG|G)/ig); 14255 } 14256 14257 for(i = 0, cnt = aDate.length; i < cnt; i++) 14258 { 14259 if(BX.util.trim(aDate[i]) != '') 14260 { 14261 aDateArgs[aDateArgs.length] = aDate[i]; 14262 } 14263 } 14264 14265 for(i = 0, cnt = aFormat.length; i < cnt; i++) 14266 { 14267 if(BX.util.trim(aFormat[i]) != '') 14268 { 14269 aFormatArgs[aFormatArgs.length] = aFormat[i]; 14270 } 14271 } 14272 14273 14274 var m = BX.util.array_search('MMMM', aFormatArgs); 14275 if (m > 0) 14276 { 14277 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 14278 aFormatArgs[m] = "MM"; 14279 } 14280 else 14281 { 14282 m = BX.util.array_search('M', aFormatArgs); 14283 if (m > 0) 14284 { 14285 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 14286 aFormatArgs[m] = "MM"; 14287 } 14288 } 14289 14290 for(i = 0, cnt = aFormatArgs.length; i < cnt; i++) 14291 { 14292 var k = aFormatArgs[i].toUpperCase(); 14293 aResult[k] = k == 'T' || k == 'TT' ? aDateArgs[i] : parseInt(aDateArgs[i], 10); 14294 } 14295 14296 if(aResult['DD'] > 0 && aResult['MM'] > 0 && aResult['YYYY'] > 0) 14297 { 14298 var d = new Date(); 14299 14300 if(bUTC) 14301 { 14302 d.setUTCDate(1); 14303 d.setUTCFullYear(aResult['YYYY']); 14304 d.setUTCMonth(aResult['MM'] - 1); 14305 d.setUTCDate(aResult['DD']); 14306 d.setUTCHours(0, 0, 0, 0); 14307 } 14308 else 14309 { 14310 d.setDate(1); 14311 d.setFullYear(aResult['YYYY']); 14312 d.setMonth(aResult['MM'] - 1); 14313 d.setDate(aResult['DD']); 14314 d.setHours(0, 0, 0, 0); 14315 } 14316 14317 if( 14318 (!isNaN(aResult['HH']) || !isNaN(aResult['GG']) || !isNaN(aResult['H']) || !isNaN(aResult['G'])) 14319 && !isNaN(aResult['MI']) 14320 ) 14321 { 14322 if (!isNaN(aResult['H']) || !isNaN(aResult['G'])) 14323 { 14324 var bPM = (aResult['T']||aResult['TT']||'am').toUpperCase()=='PM'; 14325 var h = parseInt(aResult['H']||aResult['G']||0, 10); 14326 if(bPM) 14327 { 14328 aResult['HH'] = h + (h == 12 ? 0 : 12); 14329 } 14330 else 14331 { 14332 aResult['HH'] = h < 12 ? h : 0; 14333 } 14334 } 14335 else 14336 { 14337 aResult['HH'] = parseInt(aResult['HH']||aResult['GG']||0, 10); 14338 } 14339 14340 if (isNaN(aResult['SS'])) 14341 aResult['SS'] = 0; 14342 14343 if(bUTC) 14344 { 14345 d.setUTCHours(aResult['HH'], aResult['MI'], aResult['SS']); 14346 } 14347 else 14348 { 14349 d.setHours(aResult['HH'], aResult['MI'], aResult['SS']); 14350 } 14351 } 14352 14353 return d; 14354 } 14355 } 14356 14357 return null; 14358 }; 14359 14360 BX.selectUtils = 14361 { 14362 addNewOption: function(oSelect, opt_value, opt_name, do_sort, check_unique) 14363 { 14364 oSelect = BX(oSelect); 14365 if(oSelect) 14366 { 14367 var n = oSelect.length; 14368 if(check_unique !== false) 14369 { 14370 for(var i=0;i<n;i++) 14371 { 14372 if(oSelect[i].value==opt_value) 14373 { 14374 return; 14375 } 14376 } 14377 } 14378 14379 oSelect.options[n] = new Option(opt_name, opt_value, false, false); 14380 } 14381 14382 if(do_sort === true) 14383 { 14384 this.sortSelect(oSelect); 14385 } 14386 }, 14387 14388 deleteOption: function(oSelect, opt_value) 14389 { 14390 oSelect = BX(oSelect); 14391 if(oSelect) 14392 { 14393 for(var i=0;i<oSelect.length;i++) 14394 { 14395 if(oSelect[i].value==opt_value) 14396 { 14397 oSelect.remove(i); 14398 break; 14399 } 14400 } 14401 } 14402 }, 14403 14404 deleteSelectedOptions: function(oSelect) 14405 { 14406 oSelect = BX(oSelect); 14407 if(oSelect) 14408 { 14409 var i=0; 14410 while(i<oSelect.length) 14411 { 14412 if(oSelect[i].selected) 14413 { 14414 oSelect[i].selected=false; 14415 oSelect.remove(i); 14416 } 14417 else 14418 { 14419 i++; 14420 } 14421 } 14422 } 14423 }, 14424 14425 deleteAllOptions: function(oSelect) 14426 { 14427 oSelect = BX(oSelect); 14428 if(oSelect) 14429 { 14430 for(var i=oSelect.length-1; i>=0; i--) 14431 { 14432 oSelect.remove(i); 14433 } 14434 } 14435 }, 14436 14437 optionCompare: function(record1, record2) 14438 { 14439 var value1 = record1.optText.toLowerCase(); 14440 var value2 = record2.optText.toLowerCase(); 14441 if (value1 > value2) return(1); 14442 if (value1 < value2) return(-1); 14443 return(0); 14444 }, 14445 14446 sortSelect: function(oSelect) 14447 { 14448 oSelect = BX(oSelect); 14449 if(oSelect) 14450 { 14451 var myOptions = []; 14452 var n = oSelect.options.length; 14453 var i; 14454 for (i=0;i<n;i++) 14455 { 14456 myOptions[i] = { 14457 optText:oSelect[i].text, 14458 optValue:oSelect[i].value 14459 }; 14460 } 14461 myOptions.sort(this.optionCompare); 14462 oSelect.length=0; 14463 n = myOptions.length; 14464 for(i=0;i<n;i++) 14465 { 14466 oSelect[i] = new Option(myOptions[i].optText, myOptions[i].optValue, false, false); 14467 } 14468 } 14469 }, 14470 14471 selectAllOptions: function(oSelect) 14472 { 14473 oSelect = BX(oSelect); 14474 if(oSelect) 14475 { 14476 var n = oSelect.length; 14477 for(var i=0;i<n;i++) 14478 { 14479 oSelect[i].selected=true; 14480 } 14481 } 14482 }, 14483 14484 selectOption: function(oSelect, opt_value) 14485 { 14486 oSelect = BX(oSelect); 14487 if(oSelect) 14488 { 14489 var n = oSelect.length; 14490 for(var i=0;i<n;i++) 14491 { 14492 oSelect[i].selected = (oSelect[i].value == opt_value); 14493 } 14494 } 14495 }, 14496 14497 addSelectedOptions: function(oSelect, to_select_id, check_unique, do_sort) 14498 { 14499 oSelect = BX(oSelect); 14500 if(!oSelect) 14501 return; 14502 var n = oSelect.length; 14503 for(var i=0; i<n; i++) 14504 if(oSelect[i].selected) 14505 this.addNewOption(to_select_id, oSelect[i].value, oSelect[i].text, do_sort, check_unique); 14506 }, 14507 14508 moveOptionsUp: function(oSelect) 14509 { 14510 oSelect = BX(oSelect); 14511 if(!oSelect) 14512 return; 14513 var n = oSelect.length; 14514 for(var i=0; i<n; i++) 14515 { 14516 if(oSelect[i].selected && i>0 && oSelect[i-1].selected == false) 14517 { 14518 var option = new Option(oSelect[i].text, oSelect[i].value); 14519 oSelect[i] = new Option(oSelect[i-1].text, oSelect[i-1].value); 14520 oSelect[i].selected = false;
14521 oSelect[i-1] = option; 14522 oSelect[i-1].selected = true; 14523 } 14524 } 14525 }, 14526 14527 moveOptionsDown: function(oSelect) 14528 { 14529 oSelect = BX(oSelect); 14530 if(!oSelect) 14531 return; 14532 var n = oSelect.length; 14533 for(var i=n-1; i>=0; i--) 14534 { 14535 if(oSelect[i].selected && i<n-1 && oSelect[i+1].selected == false) 14536 { 14537 var option = new Option(oSelect[i].text, oSelect[i].value); 14538 oSelect[i] = new Option(oSelect[i+1].text, oSelect[i+1].value); 14539 oSelect[i].selected = false; 14540 oSelect[i+1] = option; 14541 oSelect[i+1].selected = true; 14542 } 14543 } 14544 } 14545 }; 14546 14547 BX.getEventTarget = function(e) 14548 { 14549 if(e.target) 14550 { 14551 return e.target; 14552 } 14553 else if(e.srcElement) 14554 { 14555 return e.srcElement; 14556 } 14557 return null; 14558 }; 14559 14560 BX.convert = { 14561 toNumber: function(value) 14562 { 14563 if(BX.type.isNumber(value)) 14564 { 14565 return value; 14566 } 14567 14568 value = Number(value); 14569 return !isNaN(value) ? value : 0; 14570 }, 14571 nodeListToArray: function(nodes) 14572 { 14573 try 14574 { 14575 return (Array.prototype.slice.call(nodes, 0)); 14576 } 14577 catch (ex) 14578 { 14579 var ary = []; 14580 for(var i = 0, l = nodes.length; i < l; i++) 14581 { 14582 ary.push(nodes[i]); 14583 } 14584 return ary; 14585 } 14586 } 14587 }; 14588 14589 /******* HINT ***************/ 14590// if function has 2 params - the 2nd one is hint html. otherwise hint_html is third and hint_title - 2nd; 14591// '<div onmouseover="BX.hint(this, 'This is <b>Hint</b>')"'>; 14592// BX.hint(el, 'This is <b>Hint</b>') - this won't work, use constructor 14593 BX.hint = function(el, hint_title, hint_html, hint_id) 14594 { 14595 if (null == hint_html) 14596 { 14597 hint_html = hint_title; 14598 hint_title = ''; 14599 } 14600 14601 if (null == el.BXHINT) 14602 { 14603 el.BXHINT = new BX.CHint({ 14604 parent: el, hint: hint_html, title: hint_title, id: hint_id 14605 }); 14606 el.BXHINT.Show(); 14607 } 14608 }; 14609 14610 BX.hint_replace = function(el, hint_title, hint_html) 14611 { 14612 if (null == hint_html) 14613 { 14614 hint_html = hint_title; 14615 hint_title = ''; 14616 } 14617 14618 if (!el || !el.parentNode || !hint_html) 14619 return null; 14620 14621 var obHint = new BX.CHint({ 14622 hint: hint_html, 14623 title: hint_title 14624 }); 14625 14626 obHint.CreateParent(); 14627 14628 el.parentNode.insertBefore(obHint.PARENT, el); 14629 el.parentNode.removeChild(el); 14630 14631 obHint.PARENT.style.marginLeft = '5px'; 14632 14633 return el; 14634 }; 14635 14636 BX.CHint = function(params) 14637 { 14638 if (BX.CHint.cssLoaded === false) 14639 { 14640 BX.load(['/bitrix/js/main/core/css/core_hint.css']); 14641 BX.CHint.cssLoaded = true; 14642 } 14643 14644 this.PARENT = BX(params.parent); 14645 14646 this.HINT = params.hint; 14647 this.HINT_TITLE = params.title; 14648 14649 this.PARAMS = {}; 14650 for (var i in this.defaultSettings) 14651 { 14652 if (null == params[i]) 14653 this.PARAMS[i] = this.defaultSettings[i]; 14654 else 14655 this.PARAMS[i] = params[i]; 14656 } 14657 14658 if (null != params.id) 14659 this.ID = params.id; 14660 14661 this.timer = null; 14662 this.bInited = false; 14663 this.msover = true; 14664 14665 if (this.PARAMS.showOnce) 14666 { 14667 this.__show(); 14668 this.msover = false; 14669 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14670 } 14671 else if (this.PARENT) 14672 { 14673 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14674 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14675 } 14676 }; 14677 14678 BX.CHint.cssLoaded = false; 14679 14680 BX.CHint.openHints = new Set(); 14681 14682 BX.CHint.globalDisabled = false; 14683 14684 BX.CHint.handleMenuOpen = function() { 14685 BX.CHint.globalDisabled = true; 14686 14687 BX.CHint.openHints.forEach(function(hint) { 14688 hint.__hide_immediately(); 14689 }); 14690 }; 14691 14692 BX.CHint.handleMenuClose = function() { 14693 BX.CHint.globalDisabled = false; 14694 }; 14695 14696 BX.addCustomEvent('onMenuOpen', BX.CHint.handleMenuOpen); 14697 BX.addCustomEvent('onMenuClose', BX.CHint.handleMenuClose); 14698 14699 BX.CHint.prototype.defaultSettings = { 14700 show_timeout: 1000, 14701 hide_timeout: 500, 14702 dx: 2, 14703 showOnce: false, 14704 preventHide: true, 14705 min_width: 250 14706 }; 14707 14708 BX.CHint.prototype.CreateParent = function(element, params) 14709 { 14710 if (this.PARENT) 14711 { 14712 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14713 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14714 } 14715 14716 if (!params) params = {}; 14717 var type = 'icon'; 14718 14719 if (params.type && (params.type == "link" || params.type == "icon")) 14720 type = params.type; 14721 14722 if (element) 14723 type = "element";
14724 14725 if (type == "icon") 14726 { 14727 element = BX.create('IMG', { 14728 props: { 14729 src: params.iconSrc 14730 ? params.iconSrc 14731 : "/bitrix/js/main/core/images/hint.gif" 14732 } 14733 }); 14734 } 14735 else if (type == "link") 14736 { 14737 element = BX.create("A", { 14738 props: {href: 'javascript:void(0)'}, 14739 html: '[?]' 14740 }); 14741 } 14742 14743 this.PARENT = element; 14744 14745 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14746 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14747 14748 return this.PARENT; 14749 }; 14750 14751 BX.CHint.prototype.Show = function() 14752 { 14753 this.msover = true; 14754 14755 if (null != this.timer) 14756 clearTimeout(this.timer); 14757 14758 this.timer = setTimeout(BX.proxy(this.__show, this), this.PARAMS.show_timeout); 14759 }; 14760 14761 BX.CHint.prototype.Hide = function() 14762 { 14763 this.msover = false; 14764 14765 if (null != this.timer) 14766 clearTimeout(this.timer); 14767 14768 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14769 }; 14770 14771 BX.CHint.prototype.__show = function() 14772 { 14773 if (!this.msover || this.disabled || BX.CHint.globalDisabled) return; 14774 if (!this.bInited) this.Init(); 14775 14776 if (this.prepareAdjustPos()) 14777 { 14778 this.DIV.style.display = 'block'; 14779 BX.ZIndexManager.bringToFront(this.DIV); 14780 14781 this.adjustPos(); 14782 14783 BX.CHint.openHints.add(this); 14784 14785 BX.bind(window, 'scroll', BX.proxy(this.__onscroll, this)); 14786 14787 if (this.PARAMS.showOnce) 14788 { 14789 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14790 } 14791 } 14792 }; 14793 14794 BX.CHint.prototype.__onscroll = function() 14795 { 14796 if (!BX.admin || !BX.admin.panel || !BX.admin.panel.isFixed()) return; 14797 14798 if (this.scrollTimer) clearTimeout(this.scrollTimer); 14799 14800 this.DIV.style.display = 'none'; 14801 this.scrollTimer = setTimeout(BX.proxy(this.Reopen, this), this.PARAMS.show_timeout); 14802 }; 14803 14804 BX.CHint.prototype.Reopen = function() 14805 { 14806 if (null != this.timer) clearTimeout(this.timer); 14807 this.timer = setTimeout(BX.proxy(this.__show, this), 50); 14808 }; 14809 14810 BX.CHint.prototype.__hide = function() 14811 { 14812 if (this.msover) return; 14813 if (!this.bInited) return; 14814 14815 BX.unbind(window, 'scroll', BX.proxy(this.Reopen, this)); 14816 14817 BX.CHint.openHints.delete(this); 14818 14819 if (this.PARAMS.showOnce) 14820 { 14821 this.Destroy(); 14822 } 14823 else 14824 { 14825 this.DIV.style.display = 'none'; 14826 } 14827 }; 14828 14829 BX.CHint.prototype.__hide_immediately = function() 14830 { 14831 this.msover = false; 14832 this.__hide(); 14833 }; 14834 14835 BX.CHint.prototype.Init = function() 14836 { 14837 this.DIV = document.body.appendChild(BX.create('DIV', { 14838 props: {className: 'bx-panel-tooltip'}, 14839 style: { 14840 display: 'none', 14841 position: 'absolute', 14842 visibility: 'hidden' 14843 }, 14844 children: [ 14845 (this.CONTENT = BX.create('DIV', { 14846 props: {className: 'bx-panel-tooltip-content'}, 14847 children: [ 14848 BX.create('DIV', { 14849 props: {className: 'bx-panel-tooltip-underlay'}, 14850 children: [ 14851 BX.create('DIV', {props: {className: 'bx-panel-tooltip-underlay-bg'}}) 14852 ] 14853 }) 14854 ] 14855 })) 14856 ] 14857 })); 14858 14859 BX.ZIndexManager.register(this.DIV); 14860 14861 if (this.ID) 14862 { 14863 this.CONTENT.insertBefore(BX.create('A', { 14864 attrs: {href: 'javascript:void(0)'}, 14865 props: {className: 'bx-panel-tooltip-close'}, 14866 events: {click: BX.delegate(this.Close, this)} 14867 }), this.CONTENT.firstChild); 14868 } 14869 14870 if (this.HINT_TITLE) 14871 { 14872 this.CONTENT.appendChild( 14873 BX.create('DIV', { 14874 props: {className: 'bx-panel-tooltip-title'}, 14875 text: this.HINT_TITLE 14876 }) 14877 ); 14878 } 14879 14880 if (this.HINT) 14881 { 14882 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 14883 } 14884 14885 if (this.PARAMS.preventHide) 14886 { 14887 BX.bind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 14888 BX.bind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 14889 } 14890 14891 this.bInited = true; 14892 }; 14893 14894 BX.CHint.prototype.setContent = function(content) 14895 { 14896 this.HINT = content; 14897 14898 if (this.CONTENT_TEXT) 14899 this.CONTENT_TEXT.innerHTML = this.HINT; 14900 else 14901 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 14902 }; 14903 14904 BX.CHint.prototype.prepareAdjustPos = function() 14905 { 14906 this._wnd = {scrollPos: BX.GetWindowScrollPos(),scrollSize:BX.GetWindowScrollSize()}; 14907 return BX.style(this.PARENT, 'display') != 'none'; 14908 }; 14909 14910 BX.CHint.prototype.getAdjustPos = function() 14911 { 14912 var res = {}, pos = BX.pos(this.PARENT), min_top = 0; 14913 14914 res.top = pos.bottom + this.PARAMS.dx; 14915 14916 if (BX.admin && BX.admin.panel.DIV) 14917 { 14918 min_top = BX.admin.panel.DIV.offsetHeight + this.PARAMS.dx; 14919 14920 if (BX.admin.panel.isFixed()) 14921 { 14922 min_top += this._wnd.scrollPos.scrollTop; 14923 } 14924 } 14925 14926 if (res.top < min_top) 14927 res.top = min_top; 14928 else 14929 { 14930 if (res.top + this.DIV.offsetHeight > this._wnd.scrollSize.scrollHeight) 14931 res.top = pos.top - this.PARAMS.dx - this.DIV.offsetHeight; 14932 } 14933 14934 res.left = pos.left; 14935 if (pos.left < this.PARAMS.dx) 14936 pos.left = this.PARAMS.dx; 14937 else 14938 { 14939 var floatWidth = this.DIV.offsetWidth; 14940 14941 var max_left = this._wnd.scrollSize.scrollWidth - floatWidth - this.PARAMS.dx; 14942 14943 if (res.left > max_left) 14944 res.left = max_left; 14945 } 14946 14947 return res; 14948 }; 14949 14950 BX.CHint.prototype.adjustWidth = function() 14951 { 14952 if (this.bWidthAdjusted) return; 14953 14954 var w = this.DIV.offsetWidth, h = this.DIV.offsetHeight; 14955 14956 if (w > this.PARAMS.min_width) 14957 w = Math.round(Math.sqrt(1.618*w*h)); 14958 14959 if (w < this.PARAMS.min_width) 14960 w = this.PARAMS.min_width; 14961 14962 this.DIV.style.width = w + "px"; 14963 14964 if (this._adjustWidthInt) 14965 clearInterval(this._adjustWidthInt); 14966 this._adjustWidthInt = setInterval(BX.delegate(this._adjustWidthInterval, this), 5); 14967 14968 this.bWidthAdjusted = true; 14969 }; 14970 14971 BX.CHint.prototype._adjustWidthInterval = function() 14972 { 14973 if (!this.DIV || this.DIV.style.display == 'none') 14974 clearInterval(this._adjustWidthInt); 14975 14976 var
14977 dW = 20, 14978 maxWidth = 1500, 14979 w = this.DIV.offsetWidth, 14980 w1 = this.CONTENT_TEXT.offsetWidth; 14981 14982 if (w > 0 && w1 > 0 && w - w1 < dW && w < maxWidth) 14983 { 14984 this.DIV.style.width = (w + dW) + "px"; 14985 return; 14986 } 14987 14988 clearInterval(this._adjustWidthInt); 14989 }; 14990 14991 BX.CHint.prototype.adjustPos = function() 14992 { 14993 this.adjustWidth(); 14994 14995 var pos = this.getAdjustPos(); 14996 14997 this.DIV.style.top = pos.top + 'px'; 14998 this.DIV.style.left = pos.left + 'px'; 14999 }; 15000 15001 BX.CHint.prototype.Close = function() 15002 { 15003 if (this.ID && BX.WindowManager) 15004 BX.WindowManager.saveWindowOptions(this.ID, {display: 'off'}); 15005 this.__hide_immediately(); 15006 this.Destroy(); 15007 }; 15008 15009 BX.CHint.prototype.Destroy = function() 15010 { 15011 if (this.PARENT) 15012 { 15013 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 15014 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 15015 } 15016 15017 if (this.DIV) 15018 { 15019 BX.unbind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 15020 BX.unbind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 15021 15022 BX.ZIndexManager.unregister(this.DIV); 15023 15024 BX.cleanNode(this.DIV, true); 15025 } 15026 }; 15027 15028 BX.CHint.prototype.enable = function(){this.disabled = false;}; 15029 BX.CHint.prototype.disable = function(){this.__hide_immediately(); this.disabled = true;}; 15030 15031 15032 function _adjustWait() 15033 { 15034 if (!this.bxmsg) return; 15035 15036 var arContainerPos = BX.pos(this), 15037 div_top = arContainerPos.top; 15038 15039 if (div_top < BX.GetDocElement().scrollTop) 15040 div_top = BX.GetDocElement().scrollTop + 5; 15041 15042 this.bxmsg.style.top = (div_top + 5) + 'px'; 15043 15044 if (this == BX.GetDocElement()) 15045 { 15046 this.bxmsg.style.right = '5px'; 15047 } 15048 else 15049 { 15050 this.bxmsg.style.left = (arContainerPos.right - this.bxmsg.offsetWidth - 5) + 'px'; 15051 } 15052 } 15053 15054 function _processTpl(tplNode, cb, bKillTpl) 15055 { 15056 if (tplNode) 15057 { 15058 if (bKillTpl) 15059 tplNode.parentNode.removeChild(tplNode); 15060 15061 var res = {}, nodes = BX.findChildren(tplNode, {attribute: 'data-role'}, true); 15062 15063 for (var i = 0, l = nodes.length; i < l; i++) 15064 { 15065 res[nodes[i].getAttribute('data-role')] = nodes[i]; 15066 } 15067 15068 cb.apply(tplNode, [res]); 15069 } 15070 } 15071 15072 function _checkNode(obj, params) 15073 { 15074 params = params || {}; 15075 15076 if (BX.type.isFunction(params)) 15077 return params.call(window, obj); 15078 15079 if (!params.allowTextNodes && !BX.type.isElementNode(obj)) 15080 return false; 15081 var i,j,len; 15082 for (i in params) 15083 { 15084 if(params.hasOwnProperty(i)) 15085 { 15086 switch(i) 15087 { 15088 case 'tag': 15089 case 'tagName': 15090 if (BX.type.isString(params[i])) 15091 { 15092 if (obj.tagName.toUpperCase() != params[i].toUpperCase()) 15093 return false; 15094 } 15095 else if (params[i] instanceof RegExp) 15096 { 15097 if (!params[i].test(obj.tagName)) 15098 return false; 15099 } 15100 break; 15101 15102 case 'class': 15103 case 'className': 15104 if (BX.type.isString(params[i])) 15105 { 15106 if (!BX.hasClass(obj, params[i])) 15107 return false; 15108 } 15109 else if (params[i] instanceof RegExp) 15110 { 15111 if (!BX.type.isString(obj.className) || !params[i].test(obj.className)) 15112 return false; 15113 } 15114 break; 15115 15116 case 'attr': 15117 case 'attrs': 15118 case 'attribute': 15119 if (BX.type.isString(params[i])) 15120 { 15121 if (!obj.getAttribute(params[i])) 15122 return false; 15123 } 15124 else if (BX.type.isArray(params[i])) 15125 { 15126 for (j = 0, len = params[i].length; j < len; j++) 15127 { 15128 if (params[i] && !obj.getAttribute(params[i])) 15129 return false; 15130 } 15131 } 15132 else 15133 { 15134 for (j in params[i]) 15135 { 15136 if(params[i].hasOwnProperty(j)) 15137 { 15138 var q = obj.getAttribute(j); 15139 if (params[i][j] instanceof RegExp) 15140 { 15141 if (!BX.type.isString(q) || !params[i][j].test(q)) 15142 { 15143 return false; 15144 } 15145 } 15146 else 15147 { 15148 if (q != '' + params[i][j]) 15149 { 15150 return false; 15151 } 15152 } 15153 } 15154 } 15155 } 15156 break; 15157 15158 case 'property': 15159 case 'props': 15160 if (BX.type.isString(params[i])) 15161 { 15162 if (!obj[params[i]]) 15163 return false; 15164 } 15165 else if (BX.type.isArray(params[i])) 15166 { 15167 for (j = 0, len = params[i].length; j < len; j++) 15168 { 15169 if (params[i] && !obj[params[i]]) 15170 return false;
15171 } 15172 } 15173 else 15174 { 15175 for (j in params[i]) 15176 { 15177 if (BX.type.isString(params[i][j])) 15178 { 15179 if (obj[j] != params[i][j]) 15180 return false; 15181 } 15182 else if (params[i][j] instanceof RegExp) 15183 { 15184 if (!BX.type.isString(obj[j]) || !params[i][j].test(obj[j])) 15185 return false; 15186 } 15187 } 15188 } 15189 break; 15190 15191 case 'callback': 15192 return params[i](obj); 15193 } 15194 } 15195 } 15196 15197 return true; 15198 } 15199 15200 /* garbage collector */ 15201 function Trash() 15202 { 15203 var i,len; 15204 15205 for (i = 0, len = garbageCollectors.length; i<len; i++) 15206 { 15207 try { 15208 garbageCollectors[i].callback.apply(garbageCollectors[i].context || window); 15209 delete garbageCollectors[i]; 15210 garbageCollectors[i] = null; 15211 } catch (e) {} 15212 } 15213 } 15214 15215 if(window.attachEvent) // IE 15216 window.attachEvent("onunload", Trash); 15217 else if(window.addEventListener) // Gecko / W3C 15218 window.addEventListener('unload', Trash, false); 15219 else 15220 window.onunload = Trash; 15221 /* \garbage collector */ 15222 15223// set empty ready handler 15224 BX(BX.DoNothing); 15225 window.BX = BX; 15226 15227 BX.browser.addGlobalClass(); 15228 15229 /* data storage */ 15230 BX.data = function(node, key, value) 15231 { 15232 if(typeof node == 'undefined') 15233 return undefined; 15234 15235 if(typeof key == 'undefined') 15236 return undefined; 15237 15238 if(typeof value != 'undefined') 15239 { 15240 // write to manager 15241 dataStorage.set(node, key, value); 15242 } 15243 else 15244 { 15245 var data; 15246 15247 // from manager 15248 if((data = dataStorage.get(node, key)) != undefined) 15249 { 15250 return data; 15251 } 15252 else 15253 { 15254 // from attribute data-* 15255 if('getAttribute' in node) 15256 { 15257 data = node.getAttribute('data-'+key.toString()); 15258 if(data === null) 15259 { 15260 return undefined; 15261 } 15262 return data; 15263 } 15264 } 15265 15266 return undefined; 15267 } 15268 }; 15269 15270 BX.DataStorage = function() 15271 { 15272 15273 this.keyOffset = 1; 15274 this.data = {}; 15275 this.uniqueTag = 'BX-'+Math.random(); 15276 15277 this.resolve = function(owner, create){ 15278 if(typeof owner[this.uniqueTag] == 'undefined') 15279 if(create) 15280 { 15281 try 15282 { 15283 Object.defineProperty(owner, this.uniqueTag, { 15284 value: this.keyOffset++ 15285 }); 15286 } 15287 catch(e) 15288 { 15289 owner[this.uniqueTag] = this.keyOffset++; 15290 } 15291 } 15292 else 15293 return undefined; 15294 15295 return owner[this.uniqueTag]; 15296 }; 15297 this.get = function(owner, key){ 15298 if((owner != document && !BX.type.isElementNode(owner)) || typeof key == 'undefined') 15299 return undefined; 15300 15301 owner = this.resolve(owner, false); 15302 15303 if(typeof owner == 'undefined' || typeof this.data[owner] == 'undefined') 15304 return undefined; 15305 15306 return this.data[owner][key]; 15307 }; 15308 this.set = function(owner, key, value){ 15309 15310 if((owner != document && !BX.type.isElementNode(owner)) || typeof value == 'undefined') 15311 return; 15312 15313 var o = this.resolve(owner, true); 15314 15315 if(typeof this.data[o] == 'undefined') 15316 this.data[o] = {}; 15317 15318 this.data[o][key] = value; 15319 }; 15320 }; 15321 15322// some internal variables for new logic 15323 var dataStorage = new BX.DataStorage(); // manager which BX.data() uses to keep data 15324})(window.BX); 15325 15326;(function(window) 15327{ 15328 /****************** ATTENTION ******************************* 15329 * Please do not use Bitrix CoreJS in this class. 15330 * This class can be called on page without Bitrix Framework 15331 *************************************************************/ 15332 15333 if (!window.BX) 15334 { 15335 window.BX = {}; 15336 } 15337 15338 var BX = window.BX; 15339 15340 BX.Promise = function(fn, ctx) // fn is future-reserved 15341 { 15342 this.state = null; 15343 this.value = null; 15344 this.reason = null; 15345 this.next = null; 15346 this.ctx = ctx || this; 15347 15348 this.onFulfilled = []; 15349 this.onRejected = []; 15350 }; 15351 BX.Promise.prototype.fulfill = function(value) 15352 { 15353 this.checkState(); 15354 15355 this.value = value; 15356 this.state = true; 15357 this.execute(); 15358 }; 15359 BX.Promise.prototype.reject = function(reason) 15360 { 15361 this.checkState(); 15362 15363 this.reason = reason; 15364 this.state = false; 15365 this.execute(); 15366 }; 15367 BX.Promise.prototype.then = function(onFulfilled, onRejected) 15368 { 15369 if(typeof (onFulfilled) == "function" || onFulfilled instanceof Function) 15370 { 15371 this.onFulfilled.push(onFulfilled); 15372 } 15373 if(typeof (onRejected) == "function" || onRejected instanceof Function) 15374 { 15375 this.onRejected.push(onRejected); 15376 } 15377 15378 if(this.next === null) 15379 { 15380 this.next = new BX.Promise(null, this.ctx); 15381 } 15382 15383 if(this.state !== null) // if promise was already resolved, execute immediately 15384 { 15385 this.execute(); 15386 } 15387 15388 return this.next; 15389 }; 15390 15391 BX.Promise.prototype.catch = function(onRejected) 15392 { 15393 if(typeof (onRejected) == "function" || onRejected instanceof Function) 15394 { 15395 this.onRejected.push(onRejected); 15396 } 15397 15398 if(this.next === null) 15399 { 15400 this.next = new BX.Promise(null, this.ctx); 15401 } 15402 15403 if(this.state !== null) // if promise was already resolved, execute immediately 15404 { 15405 this.execute(); 15406 } 15407 15408 return this.next; 15409 }; 15410 15411 BX.Promise.prototype.setAutoResolve = function(way, ms) 15412 { 15413 this.timer = setTimeout(function(){ 15414 if(this.state === null) 15415 { 15416 this[way ? 'fulfill' : 'reject'](); 15417 } 15418 }.bind(this), ms || 15); 15419 };
15420 BX.Promise.prototype.cancelAutoResolve = function() 15421 { 15422 clearTimeout(this.timer); 15423 }; 15424 /** 15425 * Resolve function. This function allows promise chaining, like ..then().then()... 15426 * Typical usage: 15427 * 15428 * var p = new Promise(); 15429 * 15430 * p.then(function(value){ 15431 * return someValue; // next promise in the chain will be fulfilled with someValue 15432 * }).then(function(value){ 15433 * 15434 * var p1 = new Promise(); 15435 * *** some async code here, that eventually resolves p1 *** 15436 * 15437 * return p1; // chain will resume when p1 resolved (fulfilled or rejected) 15438 * }).then(function(value){ 15439 * 15440 * // you can also do 15441 * var e = new Error(); 15442 * throw e; 15443 * // it will cause next promise to be rejected with e 15444 * 15445 * return someOtherValue; 15446 * }).then(function(value){ 15447 * ... 15448 * }, function(reason){ 15449 * // promise was rejected with reason 15450 * })...; 15451 * 15452 * p.fulfill('let`s start this chain'); 15453 * 15454 * @param x 15455 */ 15456 BX.Promise.prototype.resolve = function(x) 15457 { 15458 var this_ = this; 15459 15460 if(this === x) 15461 { 15462 this.reject(new TypeError('Promise cannot fulfill or reject itself')); // avoid recursion 15463 } 15464 // allow "pausing" promise chaining until promise x is fulfilled or rejected 15465 else if(x && x.toString() === "[object BX.Promise]") 15466 { 15467 x.then(function(value){ 15468 this_.fulfill(value); 15469 }, function(reason){ 15470 this_.reject(reason); 15471 }); 15472 } 15473 else // auto-fulfill this promise 15474 { 15475 this.fulfill(x); 15476 } 15477 }; 15478 15479 BX.Promise.prototype.toString = function() 15480 { 15481 return "[object BX.Promise]"; 15482 }; 15483 15484 BX.Promise.prototype.execute = function() 15485 { 15486 if(this.state === null) 15487 { 15488 //then() must not be called before BX.Promise resolve() happens 15489 return; 15490 } 15491 15492 var value = undefined; 15493 var reason = undefined; 15494 var x = undefined; 15495 var k; 15496 if(this.state === true) // promise was fulfill()-ed 15497 { 15498 if(this.onFulfilled.length) 15499 { 15500 try 15501 { 15502 for(k = 0; k < this.onFulfilled.length; k++) 15503 {
15504 x = this.onFulfilled[k].apply(this.ctx, [this.value]); 15505 if(typeof x != 'undefined') 15506 { 15507 value = x; 15508 } 15509 } 15510 } 15511 catch(e) 15512 { 15513 if('console' in window) 15514 { 15515 console.dir(e); 15516 } 15517 15518 if (typeof BX.debug !== 'undefined') 15519 { 15520 BX.debug(e); 15521 } 15522 15523 reason = e; // reject next 15524 } 15525 } 15526 else 15527 { 15528 value = this.value; // resolve next 15529 } 15530 } 15531 else if(this.state === false) // promise was reject()-ed 15532 { 15533 if(this.onRejected.length) 15534 { 15535 try 15536 { 15537 for(k = 0; k < this.onRejected.length; k++) 15538 { 15539 x = this.onRejected[k].apply(this.ctx, [this.reason]); 15540 if(typeof x != 'undefined') 15541 { 15542 value = x; 15543 } 15544 } 15545 } 15546 catch(e) 15547 { 15548 if('console' in window) 15549 { 15550 console.dir(e); 15551 } 15552 15553 if (typeof BX.debug !== 'undefined') 15554 { 15555 BX.debug(e); 15556 } 15557 15558 reason = e; // reject next 15559 } 15560 } 15561 else 15562 { 15563 reason = this.reason; // reject next 15564 } 15565 } 15566 15567 if(this.next !== null) 15568 { 15569 if(typeof reason != 'undefined') 15570 { 15571 this.next.reject(reason); 15572 } 15573 else if(typeof value != 'undefined') 15574 { 15575 this.next.resolve(value); 15576 } 15577 } 15578 }; 15579 BX.Promise.prototype.checkState = function() 15580 { 15581 if(this.state !== null) 15582 { 15583 throw new Error('You can not do fulfill() or reject() multiple times'); 15584 } 15585 }; 15586})(window); 15587 15588 15589 15590;(function(window){ 15591 15592if (window.BX.ajax) 15593 return; 15594 15595var 15596 BX = window.BX, 15597 15598 tempDefaultConfig = {}, 15599 defaultConfig = { 15600 method: 'GET', // request method: GET|POST 15601 dataType: 'html', // type of data loading: html|json|script 15602 timeout: 0, // request timeout in seconds. 0 for browser-default 15603 async: true, // whether request is asynchronous or not 15604 processData: true, // any data processing is disabled if false, only callback call 15605 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 15606 emulateOnload: true, 15607 skipAuthCheck: false, // whether to check authorization failure (SHOUD be set to true for CORS requests) 15608 start: true, // send request immediately (if false, request can be started manually via XMLHttpRequest object returned) 15609 cache: true, // whether NOT to add random addition to URL 15610 preparePost: true, // whether set Content-Type x-www-form-urlencoded in POST 15611 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'}] 15612 lsTimeout: 30, //local storage data TTL. useless without lsId. 15613 lsForce: false //wheter to force query instead of using localStorage data. useless without lsId. 15614/* 15615other parameters: 15616 url: url to get/post 15617 data: data to post 15618 onsuccess: successful request callback. BX.proxy may be used. 15619 onfailure: request failure callback. BX.proxy may be used. 15620 onprogress: request progress callback. BX.proxy may be used. 15621 15622 lsId: local storage id - for constantly updating queries which can communicate via localStorage. core_ls.js needed 15623 15624any of the default parameters can be overridden. defaults can be changed by BX.ajax.Setup() - for all further requests! 15625*/ 15626 }, 15627 loadedScripts = {}, 15628 loadedScriptsQueue = [], 15629 r = { 15630 'url_utf': /[^\034-\254]+/g, 15631 'script_self': /\/bitrix\/js\/main\/core\/core(_ajax)*.js$/i, 15632 'script_self_window': /\/bitrix\/js\/main\/core\/core_window.js$/i, 15633 'script_self_admin': /\/bitrix\/js\/main\/core\/core_admin.js$/i, 15634 'script_onload': /window.onload/g 15635 }; 15636 15637// low-level method 15638BX.ajax = function(config) 15639{ 15640 var status, data; 15641
15642 if (!config || !config.url || !BX.type.isString(config.url)) 15643 { 15644 return false; 15645 } 15646 15647 for (var i in tempDefaultConfig) 15648 if (typeof (config[i]) == "undefined") config[i] = tempDefaultConfig[i]; 15649 15650 tempDefaultConfig = {}; 15651 15652 for (i in defaultConfig) 15653 if (typeof (config[i]) == "undefined") config[i] = defaultConfig[i]; 15654 15655 config.method = config.method.toUpperCase(); 15656 15657 if (!BX.localStorage) 15658 config.lsId = null; 15659 15660 if (BX.browser.IsIE()) 15661 { 15662 var result = r.url_utf.exec(config.url); 15663 if (result) 15664 { 15665 do 15666 { 15667 config.url = config.url.replace(result, BX.util.urlencode(result)); 15668 result = r.url_utf.exec(config.url); 15669 } while (result); 15670 } 15671 } 15672 15673 if(config.dataType == 'json') 15674 config.emulateOnload = false; 15675 15676 if (!config.cache && config.method == 'GET') 15677 config.url = BX.ajax._uncache(config.url); 15678 15679 if (config.method == 'POST') 15680 { 15681 if (config.preparePost) 15682 { 15683 config.data = BX.ajax.prepareData(config.data); 15684 } 15685 else if (getLastContentTypeHeader(config.headers) === 'application/json') 15686 { 15687 const isJson = ( 15688 BX.Type.isPlainObject(config.data) 15689 || BX.Type.isString(config.data) 15690 || BX.Type.isNumber(config.data) 15691 || BX.Type.isBoolean(config.data) 15692 || BX.Type.isArray(config.data) 15693 ); 15694 15695 if (isJson) 15696 { 15697 config.data = JSON.stringify(config.data); 15698 } 15699 } 15700 } 15701 15702 var bXHR = true; 15703 if (config.lsId && !config.lsForce) 15704 { 15705 var v = BX.localStorage.get('ajax-' + config.lsId); 15706 if (v !== null) 15707 { 15708 bXHR = false; 15709 15710 var lsHandler = function(lsData) { 15711 if (lsData.key == 'ajax-' + config.lsId && lsData.value != 'BXAJAXWAIT') 15712 { 15713 var data = lsData.value, 15714 bRemove = !!lsData.oldValue && data == null; 15715 if (!bRemove) 15716 BX.ajax.__run(config, data); 15717 else if (config.onfailure) 15718 config.onfailure("timeout"); 15719 15720 BX.removeCustomEvent('onLocalStorageChange', lsHandler); 15721 } 15722 }; 15723 15724 if (v == 'BXAJAXWAIT') 15725 { 15726 BX.addCustomEvent('onLocalStorageChange', lsHandler); 15727 } 15728 else 15729 { 15730 setTimeout(function() {lsHandler({key: 'ajax-' + config.lsId, value: v})}, 10); 15731 } 15732 } 15733 } 15734 15735 if (bXHR) 15736 { 15737 config.xhr = BX.ajax.xhr(); 15738 if (!config.xhr) return; 15739 15740 if (config.lsId) 15741 { 15742 BX.localStorage.set('ajax-' + config.lsId, 'BXAJAXWAIT', config.lsTimeout); 15743 } 15744 15745 if (BX.Type.isFunction(config.onprogress)) 15746 { 15747 BX.bind(config.xhr, 'progress', config.onprogress); 15748 } 15749 15750 if (BX.Type.isFunction(config.onprogressupload) && config.xhr.upload) 15751 { 15752 BX.bind(config.xhr.upload, 'progress', config.onprogressupload); 15753 } 15754 15755 config.xhr.open(config.method, config.url, config.async); 15756 15757 if (!config.skipBxHeader && !BX.ajax.isCrossDomain(config.url)) 15758 { 15759 config.xhr.setRequestHeader('Bx-ajax', 'true'); 15760 } 15761 15762 if (config.method == 'POST' && config.preparePost) 15763 { 15764 config.xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 15765 } 15766 if (typeof(config.headers) == "object") 15767 { 15768 for (i = 0; i < config.headers.length; i++) 15769 config.xhr.setRequestHeader(config.headers[i].name, config.headers[i].value); 15770 } 15771 15772 var bRequestCompleted = false; 15773 var onreadystatechange = config.xhr.onreadystatechange = function(additional) 15774 { 15775 if (bRequestCompleted) 15776 return; 15777 15778 if (additional === 'timeout') 15779 { 15780 if (config.onfailure) 15781 { 15782 config.onfailure('timeout', '', config); 15783 } 15784 15785 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['timeout', '', config]); 15786 15787 config.xhr.onreadystatechange = BX.DoNothing; 15788 config.xhr.abort(); 15789 15790 if (config.async) 15791 { 15792 config.xhr = null; 15793 } 15794 } 15795 else 15796 { 15797 if (config.xhr.readyState == 4 || additional == 'run') 15798 { 15799 status = BX.ajax.xhrSuccess(config.xhr) ? "success" : "error"; 15800 bRequestCompleted = true; 15801 config.xhr.onreadystatechange = BX.DoNothing; 15802 15803 if (status == 'success') 15804 { 15805 var authHeader = (!!config.skipAuthCheck || BX.ajax.isCrossDomain(config.url)) 15806 ? false 15807 : config.xhr.getResponseHeader('X-Bitrix-Ajax-Status'); 15808 15809 if(!!authHeader && authHeader == 'Authorize') 15810 { 15811 if (config.onfailure) 15812 { 15813 config.onfailure('auth', config.xhr.status, config); 15814 } 15815 15816 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['auth', config.xhr.status, config]); 15817 } 15818 else 15819 { 15820 var data = config.xhr.responseText; 15821 15822 if (config.lsId) 15823 { 15824 BX.localStorage.set('ajax-' + config.lsId, data, config.lsTimeout); 15825 } 15826 15827 BX.ajax.__run(config, data); 15828 } 15829 } 15830 else 15831 { 15832 if (config.onfailure) 15833 { 15834 config.onfailure('status', config.xhr.status, config); 15835 } 15836 15837 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['status', config.xhr.status, config]); 15838 } 15839 15840 if (config.async) 15841 { 15842 config.xhr = null; 15843 } 15844 } 15845 } 15846 }; 15847 15848 if (config.async && config.timeout > 0) 15849 { 15850 setTimeout(function() { 15851 if (config.xhr && !bRequestCompleted) 15852 { 15853 onreadystatechange("timeout"); 15854 } 15855 }, config.timeout * 1000); 15856 } 15857 15858 if (config.start) 15859 {
15860 config.xhr.send(config.data); 15861 15862 if (!config.async) 15863 { 15864 onreadystatechange('run'); 15865 } 15866 } 15867 15868 return config.xhr; 15869 } 15870}; 15871 15872BX.ajax.xhr = function() 15873{ 15874 if (window.XMLHttpRequest) 15875 { 15876 try {return new XMLHttpRequest();} catch(e){} 15877 } 15878 else if (window.ActiveXObject) 15879 { 15880 try { return new window.ActiveXObject("Msxml2.XMLHTTP.6.0"); } 15881 catch(e) {} 15882 try { return new window.ActiveXObject("Msxml2.XMLHTTP.3.0"); } 15883 catch(e) {} 15884 try { return new window.ActiveXObject("Msxml2.XMLHTTP"); } 15885 catch(e) {} 15886 try { return new window.ActiveXObject("Microsoft.XMLHTTP"); } 15887 catch(e) {} 15888 throw new Error("This browser does not support XMLHttpRequest."); 15889 } 15890 15891 return null; 15892}; 15893 15894BX.ajax.isCrossDomain = function(url, location) 15895{ 15896 location = location || window.location; 15897 15898 //Relative URL gets a current protocol 15899 if (url.indexOf("//") === 0) 15900 { 15901 url = location.protocol + url; 15902 } 15903 15904 //Fast check 15905 if (url.indexOf("http") !== 0) 15906 { 15907 return false; 15908 } 15909 15910 var link = window.document.createElement("a"); 15911 link.href = url; 15912 15913 return link.protocol !== location.protocol || 15914 link.hostname !== location.hostname || 15915 BX.ajax.getHostPort(link.protocol, link.host) !== BX.ajax.getHostPort(location.protocol, location.host); 15916}; 15917 15918BX.ajax.getHostPort = function(protocol, host) 15919{ 15920 var match = /:(\d+)$/.exec(host); 15921 if (match) 15922 { 15923 return match[1]; 15924 } 15925 else 15926 { 15927 if (protocol === "http:") 15928 { 15929 return "80"; 15930 } 15931 else if (protocol === "https:") 15932 { 15933 return "443"; 15934 } 15935 } 15936 15937 return ""; 15938}; 15939 15940BX.ajax.__prepareOnload = function(scripts, ajax_session) 15941{ 15942 if (scripts.length > 0) 15943 { 15944 BX.ajax['onload_' + ajax_session] = null; 15945 15946 for (var i=0,len=scripts.length;i<len;i++) 15947 { 15948 if (scripts[i].isInternal) 15949 { 15950 scripts[i].JS = scripts[i].JS.replace(r.script_onload, 'BX.aja
15950x.onload_' + ajax_session); 15951 } 15952 } 15953 } 15954 15955 BX.CaptureEventsGet(); 15956 BX.CaptureEvents(window, 'load'); 15957}; 15958 15959BX.ajax.__runOnload = function(ajax_session) 15960{ 15961 if (null != BX.ajax['onload_' + ajax_session]) 15962 { 15963 BX.ajax['onload_' + ajax_session].apply(window); 15964 BX.ajax['onload_' + ajax_session] = null; 15965 } 15966 15967 var h = BX.CaptureEventsGet(); 15968 15969 if (h) 15970 { 15971 for (var i=0; i<h.length; i++) 15972 h[i].apply(window); 15973 } 15974}; 15975 15976BX.ajax.__run = function(config, data) 15977{ 15978 if (!config.processData) 15979 { 15980 if (config.onsuccess) 15981 { 15982 config.onsuccess(data); 15983 } 15984 15985 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [data, config]); 15986 } 15987 else 15988 { 15989 data = BX.ajax.processRequestData(data, config); 15990 } 15991}; 15992 15993 15994BX.ajax._onParseJSONFailure = function(data) 15995{ 15996 this.jsonFailure = true; 15997 this.jsonResponse = data; 15998 this.jsonProactive = /^\[WAF\]/.test(data); 15999}; 16000 16001BX.ajax.processRequestData = function(data, config) 16002{ 16003 var result, scripts = [], styles = []; 16004 switch (config.dataType.toUpperCase()) 16005 { 16006 case 'JSON': 16007 16008 var context = config.xhr || {}; 16009 BX.addCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 16010 result = BX.parseJSON(data, context); 16011 BX.removeCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 16012 16013 if(!!result && BX.type.isArray(result['bxjs'])) 16014 { 16015 for(var i = 0; i < result['bxjs'].length; i++) 16016 { 16017 if(BX.type.isNotEmptyString(result['bxjs'][i])) 16018 { 16019 scripts.push({ 16020 "isInternal": false, 16021 "JS": result['bxjs'][i], 16022 "bRunFirst": config.scriptsRunFirst 16023 }); 16024 } 16025 else 16026 { 16027 scripts.push(result['bxjs'][i]) 16028 } 16029 } 16030 } 16031 16032 if(!!result && BX.type.isArray(result['bxcss'])) 16033 { 16034 styles = result['bxcss']; 16035 } 16036 16037 break; 16038 case 'SCRIPT': 16039 scripts.push({"isInternal": true, "JS": data, "bRunFirst": config.scriptsRunFirst}); 16040 result = data; 16041 break; 16042 16043 default: // HTML 16044 var ob = BX.processHTML(data, config.scriptsRunFirst); 16045 result = ob.HTML; scripts = ob.SCRIPT; styles = ob.STYLE; 16046 break; 16047 } 16048 16049 if (styles.length > 0) 16050 { 16051 BX.loadCSS(styles); 16052 } 16053 16054 let ajax_session = null; 16055 if (config.emulateOnload) 16056 { 16057 ajax_session = parseInt(Math.random() * 1000000); 16058 BX.ajax.__prepareOnload(scripts, ajax_session); 16059 } 16060 16061 const cb = BX.defer(function() 16062 { 16063 if (config.emulateOnload) 16064 { 16065 BX.ajax.__runOnload(ajax_session); 16066 } 16067 16068 BX.onCustomEvent(config.xhr, 'onAjaxSuccessFinish', [config]); 16069 }); 16070 16071 try 16072 { 16073 if (!!config.jsonFailure) 16074 { 16075 throw {type: 'json_failure', data: config.jsonResponse, bProactive: config.jsonProactive}; 16076 } 16077 16078 config.scripts = scripts; 16079 16080 BX.ajax.processScripts(config.scripts, true); 16081 16082 if (config.onsuccess) 16083 { 16084 config.onsuccess(result); 16085 } 16086 16087 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [result, config]); 16088 16089 BX.ajax.processScripts(config.scripts, false, cb); 16090 } 16091 catch (e) 16092 { 16093 if (config.onfailure) 16094 config.onfailure("processing", e); 16095 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['processing', e, config]); 16096 } 16097}; 16098 16099BX.ajax.processScripts = function(scripts, bRunFirst, cb) 16100{ 16101 var scriptsExt = [], scriptsInt = ''; 16102 16103 cb = cb || BX.DoNothing; 16104 16105 for (var i = 0, length = scripts.length; i < length; i++) 16106 { 16107 if (typeof bRunFirst != 'undefined' && bRunFirst != !!scripts[i].bRunFirst) 16108 continue; 16109 16110 if (scripts[i].isInternal) 16111 scriptsInt += ';' + scripts[i].JS; 16112 else 16113 scriptsExt.push(scripts[i].JS); 16114 } 16115 16116 scriptsExt = BX.util.array_unique(scriptsExt); 16117 var inlineScripts = scriptsInt.length > 0 ? function() { BX.evalGlobal(scriptsInt); } : BX.DoNothing; 16118 16119 if (scriptsExt.length > 0) 16120 { 16121 BX.load(scriptsExt, function() { 16122 inlineScripts(); 16123 cb(); 16124 }); 16125 } 16126 else 16127 { 16128 inlineScripts(); 16129 cb(); 16130 } 16131}; 16132 16133// TODO: extend this function to use with any data objects or forms 16134BX.ajax.prepareData = function(arData, prefix) 16135{ 16136 var data = ''; 16137 if (BX.type.isString(arData)) 16138 data = arData; 16139 else if (null != arData) 16140 { 16141 for(var i in arData) 16142 { 16143 if (arData.hasOwnProperty(i)) 16144 { 16145 if (data.length > 0) 16146 data += '&'; 16147 var name = BX.util.urlencode(i); 16148 if(prefix) 16149 name = prefix + '[' + name + ']'; 16150 if(typeof arData[i] == 'object') 16151 data += BX.ajax.prepareData(arData[i], name); 16152 else 16153 data += name + '=' + BX.util.urlencode(arData[i]); 16154 } 16155 } 16156 } 16157 return data; 16158}; 16159 16160BX.ajax.xhrSuccess = function(xhr) 16161{ 16162 return (xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || xhr.status === 1223 || xhr.status === 0; 16163}; 16164 16165BX.ajax.Setup = function(config, bTemp) 16166{ 16167 bTemp = !!bTemp; 16168 16169 for (var i in config) 16170 { 16171 if (bTemp) 16172 tempDefaultConfig[i] = config[i]; 16173 else 16174 defaultConfig[i] = config[i]; 16175 } 16176}; 16177 16178BX.ajax.replaceLocalStorageValue = function(lsId, data, ttl) 16179{ 16180 if (!!BX.localStorage) 16181 BX.localStorage.set('ajax-' + lsId, data, ttl); 16182}; 16183 16184 16185BX.ajax._uncache = function(url) 16186{ 16187 return url + ((url.indexOf('?') !== -1 ? "&" : "?") + '_=' + (new Date()).getTime()); 16188}; 16189 16190/* simple interface */ 16191BX.ajax.get = function(url, data, callback) 16192{ 16193 if (BX.type.isFunction(data)) 16194 { 16195 callback = data; 16196 data = ''; 16197 } 16198
16199 data = BX.ajax.prepareData(data); 16200 16201 if (data) 16202 { 16203 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 16204 data = ''; 16205 } 16206 16207 return BX.ajax({ 16208 'method': 'GET', 16209 'dataType': 'html', 16210 'url': url, 16211 'data': '', 16212 'onsuccess': callback 16213 }); 16214}; 16215 16216BX.ajax.getCaptcha = function(callback) 16217{ 16218 return BX.ajax.loadJSON('/bitrix/tools/ajax_captcha.php', callback); 16219}; 16220 16221BX.ajax.insertToNode = function(url, node) 16222{ 16223 node = BX(node); 16224 if (!!node) 16225 { 16226 var eventArgs = { cancel: false }; 16227 BX.onCustomEvent('onAjaxInsertToNode', [{ url: url, node: node, eventArgs: eventArgs }]); 16228 if(eventArgs.cancel === true) 16229 { 16230 return; 16231 } 16232 16233 var show = null; 16234 if (!tempDefaultConfig.denyShowWait) 16235 { 16236 show = BX.showWait(node); 16237 delete tempDefaultConfig.denyShowWait; 16238 } 16239 16240 return BX.ajax.get(url, function(data) { 16241 node.innerHTML = data; 16242 BX.closeWait(node, show); 16243 }); 16244 } 16245}; 16246 16247BX.ajax.post = function(url, data, callback) 16248{ 16249 data = BX.ajax.prepareData(data); 16250 16251 return BX.ajax({ 16252 'method': 'POST', 16253 'dataType': 'html', 16254 'url': url, 16255 'data': data, 16256 'onsuccess': callback 16257 }); 16258}; 16259 16260/** 16261 * BX.ajax with BX.Promise 16262 * 16263 * @param config 16264 * @returns {BX.Promise|false} 16265 */ 16266BX.ajax.promise = function(config) 16267{ 16268 var result = new BX.Promise(); 16269 16270 config.onsuccess = function(data) 16271 { 16272 result.fulfill(data); 16273 }; 16274 config.onfailure = function(reason, httpStatus, config) 16275 { 16276 result.reject({ 16277 reason: reason, 16278 data: httpStatus, 16279 ajaxConfig: config, 16280 xhr: config.xhr 16281 }); 16282 }; 16283 16284 var xhr = BX.ajax(config); 16285 if (xhr) 16286 { 16287 if (typeof config.onrequeststart === 'function') 16288 { 16289 config.onrequeststart(xhr); 16290 } 16291 } 16292 else 16293 { 16294 result.reject({ 16295 reason: "init", 16296 data: false 16297 }); 16298 } 16299 16300 return result; 16301}; 16302 16303/* load and execute external file script with onload emulation */ 16304BX.ajax.loadScriptAjax = function(script_src, callback, bPreload) 16305{ 16306 if (BX.type.isArray(script_src)) 16307 { 16308 for (var i=0,len=script_src.length;i<len;i++) 16309 { 16310 BX.ajax.loadScriptAjax(script_src[i], callback, bPreload); 16311 } 16312 } 16313 else 16314 { 16315 var script_src_test = script_src.replace(/\.js\?.*/, '.js'); 16316 16317 if (r.script_self.test(script_src_test)) return; 16318 if (r.script_self_window.test(script_src_test) && BX.CWindow) return; 16319 if (r.script_self_admin.test(script_src_test) && BX.admin) return; 16320 16321 if (typeof loadedScripts[script_src_test] == 'undefined') 16322 { 16323 if (!!bPreload) 16324 { 16325 loadedScripts[script_src_test] = ''; 16326 return BX.loadScript(script_src); 16327 } 16328 else 16329 { 16330 return BX.ajax({ 16331 url: script_src, 16332 method: 'GET', 16333 dataType: 'script', 16334 processData: true, 16335 emulateOnload: false, 16336 scriptsRunFirst: true, 16337 async: false, 16338 start: true, 16339 onsuccess: function(result) { 16340 loadedScripts[script_src_test] = result; 16341 if (callback) 16342 callback(result); 16343 } 16344 }); 16345 } 16346 } 16347 else if (callback) 16348 { 16349 callback(loadedScripts[script_src_test]); 16350 } 16351 } 16352}; 16353 16354/* non-xhr loadings */ 16355BX.ajax.loadJSON = function(url, data, callback, callback_failure) 16356{ 16357 if (BX.type.isFunction(data)) 16358 { 16359 callback_failure = callback; 16360 callback = data; 16361 data = ''; 16362 } 16363 16364 data = BX.ajax.prepareData(data); 16365 16366 if (data) 16367 { 16368 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 16369 data = ''; 16370 } 16371 16372 return BX.ajax({ 16373 'method': 'GET', 16374 'dataType': 'json', 16375 'url': url, 16376 'onsuccess': callback, 16377 'onfailure': callback_failure 16378 }); 16379}; 16380 16381var getLastContentTypeHeader = function (headers) { 16382 if (!BX.Type.isArray(headers)) 16383 { 16384 return null; 16385 } 16386 var lastHeader = headers 16387 .filter(function (header) { 16388 return header.name === 'Content-Type'; 16389 }) 16390 .pop(); 16391 16392 return lastHeader ? lastHeader.value : null; 16393}; 16394 16395/** 16396 * @see isValidAnalyticsData in ui.analytics 16397* */ 16398const isValidAnalyticsData = function (analytics) 16399{ 16400 if (!BX.Type.isPlainObject(analytics)) 16401 { 16402 console.error('BX.ajax: {analytics} must be an object.'); 16403 16404 return false; 16405 } 16406 16407 const requiredFields = ['event', 'tool', 'category']; 16408 for (const field of requiredFields) 16409 { 16410 if (!BX.Type.isStringFilled(analytics[field])) 16411 { 16412 console.error(`BX.ajax: The "${field}" property in the "analytics" object must be a non-empty string.`); 16413 16414 return false;
16415 } 16416 } 16417 16418 const additionalFields = ['p1', 'p2', 'p3', 'p4', 'p5']; 16419 for (const field of additionalFields) 16420 { 16421 const value = analytics[field]; 16422 if (!BX.Type.isStringFilled(value)) 16423 { 16424 continue; 16425 } 16426 16427 if (value.split('_').length > 2) 16428 { 16429 console.error(`BX.ajax: The "${field}" property (${value}) in the "analytics" object must be a string containing a single underscore.`); 16430 16431 return false; 16432 } 16433 } 16434 16435 return true; 16436}; 16437 16438const processAnalyticsDataToGetParameters = function(config) 16439{ 16440 const getParameters = {}; 16441 if (BX.Type.isStringFilled(config.analyticsLabel) || BX.Type.isPlainObject(config.analyticsLabel)) 16442 { 16443 getParameters.analyticsLabel = config.analyticsLabel; 16444 } 16445 16446 if (BX.Type.isPlainObject(config.analytics)) 16447 { 16448 if (config.analyticsLabel) 16449 { 16450 delete getParameters.analyticsLabel; 16451 console.error('BX.ajax: Only {analytics} or {analyticsLabel} should be used. If both are present, {analyticsLabel} will be ignored.'); 16452 } 16453 16454 if (isValidAnalyticsData(config.analytics)) 16455 { 16456 getParameters.st = config.analytics; 16457 } 16458 else 16459 { 16460 console.error('BX.ajax: {analytics} is invalid and is skipped.'); 16461 } 16462 } 16463 16464 return getParameters; 16465}; 16466 16467const prepareAjaxGetParameters = function(config) 16468{ 16469 let getParameters = config.getParameters || {}; 16470 getParameters = { ...getParameters, ...processAnalyticsDataToGetParameters(config) }; 16471 16472 if (typeof config.mode !== 'undefined') 16473 { 16474 getParameters.mode = config.mode; 16475 } 16476 if (config.navigation) 16477 { 16478 if (config.navigation.page) 16479 { 16480 getParameters.nav = 'page-' + config.navigation.page; 16481 } 16482 if (config.navigation.size) 16483 { 16484 if (getParameters.nav) 16485 { 16486 getParameters.nav += '-'; 16487 } 16488 else 16489 { 16490 getParameters.nav = ''; 16491 } 16492 getParameters.nav += 'size-' + config.navigation.size; 16493 } 16494 } 16495 16496 return getParameters; 16497}; 16498 16499var prepareAjaxConfig = function(config) 16500{ 16501 config = BX.type.isPlainObject(config) ? config : {}; 16502 16503 config.headers = config.headers || []; 16504 config.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 16505 if (BX.message.SITE_ID) 16506 { 16507 config.headers.push({name: 'X-Bitrix-Site-Id', value: BX.message.SITE_ID}); 16508 } 16509 16510 if (typeof config.json !== 'undefined') 16511 { 16512 if (!BX.type.isPlainObject(config.json)) 16513 { 16514 throw new Error('Wrong `config.json`, plain object expected.') 16515 } 16516 16517 config.headers.push({name: 'Content-Type', value: 'application/json'}); 16518 config.data = config.json; 16519 config.preparePost = false; 16520 } 16521 else if (config.data instanceof FormData) 16522 { 16523 config.preparePost = false; 16524 if (typeof config.signedParameters !== 'undefined') 16525 { 16526 config.data.append('signedParameters', config.signedParameters); 16527 } 16528 } 16529 else if (BX.type.isPlainObject(config.data) || BX.Type.isNil(config.data)) 16530 { 16531 config.data = BX.type.isPlainObject(config.data) ? config.data : {}; 16532 if (typeof config.signedParameters !== 'undefined') 16533 { 16534 config.data.signedParameters = config.signedParameters; 16535 } 16536 } 16537 16538 if (!config.method) 16539 { 16540 config.method = 'POST' 16541 } 16542 16543 return config; 16544}; 16545 16546var buildAjaxPromiseToRestoreCsrf = function(config, withoutRestoringCsrf) 16547{ 16548 withoutRestoringCsrf = withoutRestoringCsrf || false; 16549 var originalConfig = BX.clone(config); 16550 var request = null; 16551 16552 var onrequeststart = config.onrequeststart; 16553 config.onrequeststart = function(xhr) { 16554 request = xhr; 16555 if (BX.type.isFunction(onrequeststart)) 16556 { 16557 onrequeststart(xhr); 16558 } 16559 }; 16560 var onrequeststartOrig = originalConfig.onrequeststart; 16561 originalConfig.onrequeststart = function(xhr) { 16562 request = xhr; 16563 if (BX.type.isFunction(onrequeststartOrig)) 16564 { 16565 onrequeststartOrig(xhr); 16566 } 16567 }; 16568 16569 var promise = BX.ajax.promise(config); 16570 16571 return promise.then(function(response) { 16572 if (!withoutRestoringCsrf && BX.type.isPlainObject(response) && BX.type.isArray(response.errors)) 16573 { 16574 var csrfProblem = false; 16575 response.errors.forEach(function(error) { 16576 if (error.code === 'invalid_csrf' && error.customData.csrf) 16577 { 16578 BX.message({'bitrix_sessid': error.customData.csrf}); 16579 16580 originalConfig.headers = originalConfig.headers || []; 16581 originalConfig.headers = originalConfig.headers.filter(function(header) {
16582 return header && header.name !== 'X-Bitrix-Csrf-Token'; 16583 }); 16584 originalConfig.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 16585 16586 csrfProblem = true; 16587 } 16588 }); 16589 16590 if (csrfProblem) 16591 { 16592 return buildAjaxPromiseToRestoreCsrf(originalConfig, true); 16593 } 16594 } 16595 16596 if (!BX.type.isPlainObject(response) || response.status !== 'success') 16597 { 16598 var errorPromise = new BX.Promise(); 16599 errorPromise.reject(response); 16600 16601 return errorPromise; 16602 } 16603 16604 return response; 16605 }).catch(function(data) { 16606 var ajaxReject = new BX.Promise(); 16607 16608 var originalJsonResponse; 16609 if (BX.type.isPlainObject(data) && data.xhr && data.xhr.responseText) 16610 { 16611 try 16612 { 16613 originalJsonResponse = JSON.parse(data.xhr.responseText); 16614 data = originalJsonResponse; 16615 } 16616 catch (err) 16617 {} 16618 } 16619 16620 if (BX.type.isPlainObject(data) && data.status && data.hasOwnProperty('data')) 16621 { 16622 ajaxReject.reject(data); 16623 } 16624 else 16625 { 16626 ajaxReject.reject({ 16627 status: 'error', 16628 data: { 16629 ajaxRejectData: data 16630 }, 16631 errors: [ 16632 { 16633 code: 'NETWORK_ERROR', 16634 message: 'Network error' 16635 } 16636 ] 16637 }); 16638 } 16639 16640 return ajaxReject; 16641 }).then(function(response){ 16642 16643 var assetsLoaded = new BX.Promise(); 16644 16645 var headers = request.getAllResponseHeaders().trim().split(/[\r\n]+/); 16646 var headerMap = {}; 16647 headers.forEach(function (line) { 16648 var parts = line.split(': '); 16649 var header = parts.shift().toLowerCase(); 16650 headerMap[header] = parts.join(': '); 16651 }); 16652 16653 if (!headerMap['x-process-assets']) 16654 { 16655 assetsLoaded.fulfill(response); 16656 16657 return assetsLoaded; 16658 } 16659 16660 var assets = BX.prop.getObject(BX.prop.getObject(response, "data", {}), "assets", {}); 16661 var promise = new Promise(function(resolve, reject) { 16662 var css = BX.prop.getArray(assets, "css", []); 16663 BX.load(css, function(){ 16664 BX.loadScript( 16665 BX.prop.getArray(assets, "js", []), 16666 resolve 16667 ); 16668 }); 16669 }); 16670 promise.then(function(){ 16671 var strings = BX.prop.getArray(assets, "string", []); 16672 var stringAsset = strings.join('\n'); 16673 BX.html(document.head, stringAsset, { useAdjacentHTML: true }).then(function(){ 16674 assetsLoaded.fulfill(response); 16675 }); 16676 }); 16677 16678 return assetsLoaded; 16679 }); 16680}; 16681 16682/** 16683 * 16684 * @param {string} action 16685 * @param {Object} config 16686 * @param {?string|?Object} [config.analyticsLabel] 16687 * @param {?Object} [config.analytics] 16688 * @param {string} [config.analytics.event] 16689 * @param {string} [config.analytics.tool] 16690 * @param {string} [config.analytics.category] 16691 * @param {?string} [config.analytics.c_section] 16692 * @param {?string} [config.analytics.c_sub_section] 16693 * @param {?string} [config.analytics.c_element] 16694 * @param {?string} [config.analytics.type] 16695 * @param {?string} [config.analytics.p1] 16696 * @param {?string} [config.analytics.p2] 16697 * @param {?string} [config.analytics.p3] 16698 * @param {?string} [config.analytics.p4] 16699 * @param {?string} [config.analytics.p5] 16700 * @param {string} [config.method='POST'] 16701 * @param {Object} [config.data] 16702 * @param {?Object} [config.getParameters] 16703 * @param {?Object} [config.headers] 16704 * @param {?Object} [config.timeout] 16705 * @param {Object} [config.navigation] 16706 * @param {number} [config.navigation.page] 16707 */ 16708BX.ajax.runAction = function(action, config) 16709{ 16710 config = prepareAjaxConfig(config); 16711 var getParameters = prepareAjaxGetParameters(config); 16712 getParameters.action = action; 16713
16714 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 16715 return buildAjaxPromiseToRestoreCsrf({ 16716 method: config.method, 16717 dataType: 'json', 16718 url: url, 16719 data: config.data, 16720 timeout: config.timeout, 16721 preparePost: config.preparePost, 16722 headers: config.headers, 16723 onrequeststart: config.onrequeststart, 16724 onprogress: config.onprogress, 16725 onprogressupload: config.onprogressupload 16726 }); 16727}; 16728 16729/** 16730 * 16731 * @param {string} component 16732 * @param {string} action 16733 * @param {Object} config 16734 * @param {?string|?Object} [config.analyticsLabel] 16735 * @param {?Object} [config.analytics] 16736 * @param {string} [config.analytics.event] 16737 * @param {string} [config.analytics.tool] 16738 * @param {string} [config.analytics.category] 16739 * @param {?string} [config.analytics.c_section] 16740 * @param {?string} [config.analytics.c_sub_section] 16741 * @param {?string} [config.analytics.c_element] 16742 * @param {?string} [config.analytics.type] 16743 * @param {?string} [config.analytics.p1] 16744 * @param {?string} [config.analytics.p2] 16745 * @param {?string} [config.analytics.p3] 16746 * @param {?string} [config.analytics.p4] 16747 * @param {?string} [config.analytics.p5] 16748 * @param {?string} [config.signedParameters] 16749 * @param {string} [config.method='POST'] 16750 * @param {string} [config.mode='ajax'] Ajax or class. 16751 * @param {Object} [config.data] 16752 * @param {?Object} [config.getParameters] 16753 * @param {?array} [config.headers] 16754 * @param {?number} [config.timeout] 16755 * @param {Object} [config.navigation] 16756 */ 16757BX.ajax.runComponentAction = function (component, action, config) 16758{ 16759 config = prepareAjaxConfig(config); 16760 config.mode = config.mode || 'ajax'; 16761 16762 var getParameters = prepareAjaxGetParameters(config); 16763 getParameters.c = component; 16764 getParameters.action = action; 16765
16766 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 16767 16768 return buildAjaxPromiseToRestoreCsrf({ 16769 method: config.method, 16770 dataType: 'json', 16771 url: url, 16772 data: config.data, 16773 timeout: config.timeout, 16774 preparePost: config.preparePost, 16775 headers: config.headers, 16776 onrequeststart: (config.onrequeststart ? config.onrequeststart : null), 16777 onprogress: config.onprogress, 16778 onprogressupload: config.onprogressupload 16779 }); 16780}; 16781 16782/* 16783arObs = [{ 16784 url: url, 16785 type: html|script|json|css, 16786 callback: function 16787}] 16788*/ 16789BX.ajax.load = function(arObs, callback) 16790{ 16791 if (!BX.type.isArray(arObs)) 16792 arObs = [arObs]; 16793 16794 var cnt = 0; 16795 16796 if (!BX.type.isFunction(callback)) 16797 callback = BX.DoNothing; 16798 16799 var handler = function(data) 16800 { 16801 if (BX.type.isFunction(this.callback)) 16802 this.callback(data); 16803 16804 if (++cnt >= len) 16805 callback(); 16806 }; 16807 16808 for (var i = 0, len = arObs.length; i<len; i++) 16809 { 16810 switch(arObs[i].type.toUpperCase()) 16811 { 16812 case 'SCRIPT': 16813 BX.loadScript([arObs[i].url], BX.proxy(handler, arObs[i])); 16814 break; 16815 case 'CSS': 16816 BX.loadCSS([arObs[i].url]); 16817 16818 if (++cnt >= len) 16819 callback(); 16820 break; 16821 case 'JSON': 16822 BX.ajax.loadJSON(arObs[i].url, BX.proxy(handler, arObs[i])); 16823 break; 16824 16825 default: 16826 BX.ajax.get(arObs[i].url, '', BX.proxy(handler, arObs[i])); 16827 break; 16828 } 16829 } 16830}; 16831 16832/* ajax form sending */ 16833BX.ajax.submit = function(obForm, callback) 16834{ 16835 if (!obForm.target) 16836 { 16837 if (null == obForm.BXFormTarget) 16838 { 16839 var frame_name = 'formTarget_' + Math.random(); 16840 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 16841 props: { 16842 name: frame_name, 16843 id: frame_name, 16844 src: 'javascript:void(0)' 16845 }, 16846 style: { 16847 display: 'none' 16848 } 16849 })); 16850 } 16851 16852 obForm.target = obForm.BXFormTarget.name; 16853 } 16854 16855 obForm.BXFormCallback = callback; 16856 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 16857 16858 BX.submit(obForm); 16859 16860 return false; 16861}; 16862 16863BX.ajax.submitComponentForm = function(obForm, container, bWait) 16864{ 16865 if (!obForm.target) 16866 { 16867 if (null == obForm.BXFormTarget) 16868 { 16869 var frame_name = 'formTarget_' + Math.random(); 16870 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 16871 props: { 16872 name: frame_name, 16873 id: frame_name, 16874 src: 'javascript:void(0)' 16875 }, 16876 style: { 16877 display: 'none' 16878 } 16879 })); 16880 } 16881 16882 obForm.target = obForm.BXFormTarget.name; 16883 } 16884 16885 if (!!bWait) 16886 var w = BX.showWait(container); 16887 16888 obForm.BXFormCallback = function(d) { 16889 if (!!bWait) 16890 BX.closeWait(w); 16891 16892 var callOnload = function(){ 16893 if(!!window.bxcompajaxframeonload) 16894 { 16895 setTimeout(function(){window.bxcompajaxframeonload();window.bxcompajaxframeonload=null;}, 10); 16896 } 16897 }; 16898 16899 BX(container).innerHTML = d; 16900 BX.onCustomEvent('onAjaxSuccess', [null,null,callOnload]); 16901 }; 16902 16903 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 16904 16905 return true; 16906}; 16907 16908// func will be executed in form context 16909BX.ajax._submit_callback = function() 16910{ 16911 //opera and IE8 triggers onload event even on empty iframe 16912 try 16913 { 16914 if(this.BXFormTarget.contentWindow.location.href.indexOf('http') != 0) 16915 return; 16916 } catch (e) { 16917 return; 16918 } 16919 16920 if (this.BXFormCallback) 16921 this.BXFormCallback.apply(this, [this.BXFormTarget.contentWindow.document.body.innerHTML]); 16922 16923 BX.unbindAll(this.BXFormTarget); 16924}; 16925 16926BX.ajax.prepareForm = function(obForm, data) 16927{ 16928 data = (!!data ? data : {}); 16929 var i, ii, el, 16930 _data = [], 16931 n = obForm.elements.length, 16932 files = 0, length = 0; 16933 if(!!obForm) 16934 { 16935 for (i = 0; i < n; i++) 16936 { 16937 el = obForm.elements[i]; 16938 if (el.disabled) 16939 continue; 16940 16941 if(!el.type) 16942 continue; 16943 16944 switch(el.type.toLowerCase()) 16945 { 16946 case 'text': 16947 case 'textarea': 16948 case 'password': 16949 case 'number': 16950 case 'hidden': 16951 case 'select-one': 16952 _data.push({name: el.name, value: el.value}); 16953 length += (el.name.length + el.value.length); 16954 break; 16955 case 'file': 16956 if (!!el.files) 16957 { 16958 for (ii = 0; ii < el.files.length; ii++) 16959 { 16960 files++; 16961 _data.push({name: el.name, value: el.files[ii], file : true}); 16962 length += el.files[ii].size; 16963 } 16964 } 16965 break; 16966 case 'radio':
16967 case 'checkbox': 16968 if(el.checked) 16969 { 16970 _data.push({name: el.name, value: el.value}); 16971 length += (el.name.length + el.value.length); 16972 } 16973 break; 16974 case 'select-multiple': 16975 for (var j = 0; j < el.options.length; j++) 16976 { 16977 if (el.options[j].selected) 16978 { 16979 _data.push({name : el.name, value : el.options[j].value}); 16980 length += (el.name.length + el.options[j].length); 16981 } 16982 } 16983 break; 16984 default: 16985 break; 16986 } 16987 } 16988 16989 i = 0; length = 0; 16990 var current = data, name, rest, pp, tmpKey; 16991 16992 while(i < _data.length) 16993 { 16994 var p = _data[i].name.indexOf('['); 16995 if (tmpKey) 16996 { 16997 current[_data[i].name] = {}; 16998 current[_data[i].name][tmpKey.replace(/\[|\]/gi, '')] = _data[i].value; 16999 current = data; 17000 tmpKey = null; 17001 i++; 17002 } 17003 else if (p == -1) 17004 { 17005 current[_data[i].name] = _data[i].value; 17006 current = data; 17007 i++; 17008 } 17009 else 17010 { 17011 name = _data[i].name.substring(0, p); 17012 rest = _data[i].name.substring(p+1); 17013 pp = rest.indexOf(']'); 17014 17015 if(pp == -1) 17016 { 17017 if (!current[name]) 17018 current[name] = []; 17019 current = data; 17020 i++; 17021 } 17022 else if(pp == 0) 17023 { 17024 if (!current[name]) 17025 current[name] = []; 17026 //No index specified - so take the next integer 17027 current = current[name]; 17028 _data[i].name = '' + current.length; 17029 if (rest.substring(pp+1).indexOf('[') === 0) 17030 tmpKey = rest.substring(0, pp) + rest.substring(pp+1); 17031 } 17032 else 17033 { 17034 if (!current[name]) 17035 current[name] = {}; 17036 //Now index name becomes and name and we go deeper into the array 17037 current = current[name]; 17038 _data[i].name = rest.substring(0, pp) + rest.substring(pp+1); 17039 } 17040 } 17041 } 17042 } 17043 return {data : data, filesCount : files, roughSize : length}; 17044}; 17045BX.ajax.submitAjax = function(obForm, config) 17046{ 17047 config = (config !== null && typeof config == "object" ? config : {}); 17048 config.url = (config["url"] || obForm.getAttribute("action")); 17049 17050 var additionalData = (config["data"] || {}); 17051 config.data = BX.ajax.prepareForm(obForm).data; 17052 for (var ii in additionalData) 17053 { 17054 if (additionalData.hasOwnProperty(ii)) 17055 { 17056 config.data[ii] = additionalData[ii]; 17057 } 17058 } 17059 17060 if (!window["FormData"]) 17061 { 17062 BX.ajax(config); 17063 } 17064 else 17065 { 17066 var isFile = function(item) 17067 { 17068 var res = Object.prototype.toString.call(item); 17069 return (res == '[object File]' || res == '[object Blob]'); 17070 }, 17071 appendToForm = function(fd, key, val) 17072 { 17073 if (!!val && typeof val == "object" && !isFile(val)) 17074 { 17075 for (var ii in val) 17076 { 17077 if (val.hasOwnProperty(ii)) 17078 { 17079 appendToForm(fd, (key == '' ? ii : key + '[' + ii + ']'), val[ii]); 17080 } 17081 } 17082 } 17083 else 17084 fd.append(key, (!!val ? val : '')); 17085 }, 17086 prepareData = function(arData) 17087 { 17088 var data = {}; 17089 if (null != arData) 17090 { 17091 if(typeof arData == 'object') 17092 { 17093 for(var i in arData) 17094 { 17095 if (arData.hasOwnProperty(i)) 17096 { 17097 var name = BX.util.urlencode(i); 17098 if(typeof arData[i] == 'object' && arData[i]["file"] !== true) 17099 data[name] = prepareData(arData[i]); 17100 else if (arData[i]["file"] === true) 17101 data[name] = arData[i]["value"]; 17102 else 17103 data[name] = BX.util.urlencode(arData[i]); 17104 } 17105 } 17106 } 17107 else 17108 data = BX.util.urlencode(arData); 17109 } 17110 return data; 17111 }, 17112 fd = new window.FormData(); 17113 17114 if (config.method !== 'POST') 17115 { 17116 config.data = BX.ajax.prepareData(config.data); 17117 if (config.data) 17118 { 17119 config.url += (config.url.indexOf('?') !== -1 ? "&" : "?") + config.data; 17120 config.data = ''; 17121 } 17122 } 17123 else 17124 { 17125 if (config.preparePost === true) 17126 config.data = prepareData(config.data); 17127 appendToForm(fd, '', config.data); 17128 config.data = fd; 17129 } 17130 17131 config.preparePost = false; 17132 config.start = false;
17133 17134 var xhr = BX.ajax(config); 17135 if (!!config["onprogress"]) 17136 xhr.upload.addEventListener( 17137 'progress', 17138 function(e){ 17139 var percent = null; 17140 if(e.lengthComputable && (e.total || e["totalSize"])) { 17141 percent = e.loaded * 100 / (e.total || e["totalSize"]); 17142 } 17143 config["onprogress"](e, percent); 17144 } 17145 ); 17146 xhr.send(fd); 17147 } 17148}; 17149 17150BX.ajax.UpdatePageData = function (arData) 17151{ 17152 if (arData.TITLE) 17153 BX.ajax.UpdatePageTitle(arData.TITLE); 17154 if (arData.WINDOW_TITLE || arData.TITLE) 17155 BX.ajax.UpdateWindowTitle(arData.WINDOW_TITLE || arData.TITLE); 17156 if (arData.NAV_CHAIN) 17157 BX.ajax.UpdatePageNavChain(arData.NAV_CHAIN); 17158 if (arData.CSS && arData.CSS.length > 0) 17159 BX.loadCSS(arData.CSS); 17160 if (arData.SCRIPTS && arData.SCRIPTS.length > 0) 17161 { 17162 var f = function(result,config,cb){ 17163 17164 if(!!config && BX.type.isArray(config.scripts)) 17165 { 17166 for(var i=0,l=arData.SCRIPTS.length;i<l;i++) 17167 { 17168 config.scripts.push({isInternal:false,JS:arData.SCRIPTS[i]}); 17169 } 17170 } 17171 else 17172 { 17173 BX.loadScript(arData.SCRIPTS,cb); 17174 } 17175 17176 BX.removeCustomEvent('onAjaxSuccess',f); 17177 }; 17178 BX.addCustomEvent('onAjaxSuccess',f); 17179 } 17180 else 17181 { 17182 var f1 = function(result,config,cb){ 17183 if(BX.type.isFunction(cb)) 17184 { 17185 cb(); 17186 } 17187 BX.removeCustomEvent('onAjaxSuccess',f1); 17188 }; 17189 BX.addCustomEvent('onAjaxSuccess', f1); 17190 } 17191}; 17192 17193BX.ajax.UpdatePageTitle = function(title) 17194{ 17195 var obTitle = BX('pagetitle'); 17196 if (obTitle) 17197 { 17198 BX.remove(obTitle.firstChild); 17199 if (!obTitle.firstChild) 17200 obTitle.appendChild(document.createTextNode(title)); 17201 else 17202 obTitle.insertBefore(document.createTextNode(title), obTitle.firstChild); 17203 } 17204}; 17205 17206BX.ajax.UpdateWindowTitle = function(title) 17207{ 17208 document.title = title; 17209}; 17210 17211BX.ajax.UpdatePageNavChain = function(nav_chain) 17212{ 17213 var obNavChain = BX('navigation'); 17214 if (obNavChain) 17215 { 17216 obNavChain.innerHTML = nav_chain; 17217 } 17218}; 17219 17220/* user options handling */ 17221BX.userOptions = { 17222 options: null, 17223 bSend: false, 17224 delay: 5000, 17225 path: '/bitrix/admin/user_options.php?' 17226}; 17227 17228BX.userOptions.setAjaxPath = function(url) 17229{ 17230 BX.userOptions.path = url.indexOf('?') == -1? url+'?': url+'&'; 17231} 17232BX.userOptions.save = function(sCategory, sName, sValName, sVal, bCommon) 17233{ 17234 if (null == BX.userOptions.options) 17235 BX.userOptions.options = {}; 17236 17237 bCommon = !!bCommon; 17238 BX.userOptions.options[sCategory+'.'+sName+'.'+sValName] = [sCategory, sName, sValName, sVal, bCommon]; 17239 17240 var sParam = BX.userOptions.__get(); 17241 if (sParam != '') 17242 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=/;"; 17243 17244 if(!BX.userOptions.bSend) 17245 { 17246 BX.userOptions.bSend = true; 17247 setTimeout(function(){BX.userOptions.send(null)}, BX.userOptions.delay); 17248 } 17249}; 17250 17251BX.userOptions.send = function(callback) 17252{ 17253 var sParam = BX.userOptions.__get(); 17254 BX.userOptions.options = null; 17255 BX.userOptions.bSend = false; 17256 17257 if (sParam != '') 17258 { 17259 document.cookie = BX.message('COOKIE_PREFIX') + "_LAST_SETTINGS=; path=/;"; 17260 BX.ajax({ 17261 'method': 'GET', 17262 'dataType': 'html', 17263 'processData': false, 17264 'cache': false, 17265 'url': BX.userOptions.path+sParam+'&sessid='+BX.bitrix_sessid(), 17266 'onsuccess': callback 17267 }); 17268 } 17269}; 17270 17271BX.userOptions.del = function(sCategory, sName, bCommon, callback) 17272{ 17273 BX.ajax.get(BX.userOptions.path+'action=delete&c='+sCategory+'&n='+sName+(bCommon == true? '&common=Y':'')+'&sessid='+BX.bitrix_sessid(), callback); 17274}; 17275 17276BX.userOptions.__get = function() 17277{ 17278 if (!BX.userOptions.options) return ''; 17279 17280 var sParam = '', n = -1, prevParam = '', aOpt, i; 17281 17282 for (i in BX.userOptions.options) 17283 { 17284 if(BX.userOptions.options.hasOwnProperty(i)) 17285 { 17286 aOpt = BX.userOptions.options[i]; 17287 17288 if (prevParam != aOpt[0]+'.'+aOpt[1]) 17289 { 17290 n++; 17291 sParam += '&p['+n+'][c]='+BX.util.urlencode(aOpt[0]); 17292 sParam += '&p['+n+'][n]='+BX.util.urlencode(aOpt[1]); 17293 if (aOpt[4] == true) 17294 sParam += '&p['+n+'][d]=Y'; 17295 prevParam = aOpt[0]+'.'+aOpt[1]; 17296 } 17297 17298 var valueName = aOpt[2]; 17299 var value = aOpt[3]; 17300 17301 if (valueName === null) 17302 { 17303 sParam += '&p['+n+'][v]='+BX.util.urlencode(value); 17304 } 17305 else 17306 {
17307 sParam += '&p['+n+'][v]['+BX.util.urlencode(valueName)+']='+BX.util.urlencode(value); 17308 } 17309 } 17310 } 17311 17312 return sParam.substr(1); 17313}; 17314 17315BX.ajax.history = { 17316 expected_hash: '', 17317 17318 obParams: null, 17319 17320 obFrame: null, 17321 obImage: null, 17322 17323 obTimer: null, 17324 17325 bInited: false, 17326 bHashCollision: false, 17327 bPushState: !!(history.pushState && BX.type.isFunction(history.pushState)), 17328 17329 startState: null, 17330 17331 init: function(obParams) 17332 { 17333 if (BX.ajax.history.bInited) 17334 return; 17335 17336 this.obParams = obParams; 17337 var obCurrentState = this.obParams.getState(); 17338 17339 if (BX.ajax.history.bPushState) 17340 { 17341 BX.ajax.history.expected_hash = window.location.pathname; 17342 if (window.location.search) 17343 BX.ajax.history.expected_hash += window.location.search; 17344 17345 BX.ajax.history.put(obCurrentState, BX.ajax.history.expected_hash, '', true); 17346 // due to some strange thing, chrome calls popstate event on page start. so we should delay it 17347 setTimeout(function(){BX.bind(window, 'popstate', BX.ajax.history.__hashListener);}, 500); 17348 } 17349 else 17350 { 17351 BX.ajax.history.expected_hash = window.location.hash; 17352 17353 if (!BX.ajax.history.expected_hash || BX.ajax.history.expected_hash == '#') 17354 BX.ajax.history.expected_hash = '__bx_no_hash__'; 17355 17356 jsAjaxHistoryContainer.put(BX.ajax.history.expected_hash, obCurrentState); 17357 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 17358 17359 if (BX.browser.IsIE()) 17360 { 17361 BX.ajax.history.obFrame = document.createElement('IFRAME'); 17362 BX.hide_object(BX.ajax.history.obFrame); 17363 17364 document.body.appendChild(BX.ajax.history.obFrame); 17365 17366 BX.ajax.history.obFrame.contentWindow.document.open(); 17367 BX.ajax.history.obFrame.contentWindow.document.write(BX.ajax.history.expected_hash); 17368 BX.ajax.history.obFrame.contentWindow.document.close(); 17369 } 17370 else if (BX.browser.IsOpera()) 17371 { 17372 BX.ajax.history.obImage = document.createElement('IMG'); 17373 BX.hide_object(BX.ajax.history.obImage); 17374 17375 document.body.appendChild(BX.ajax.history.obImage); 17376 17377 BX.ajax.history.obImage.setAttribute('src', 'javascript:location.href = \'javascript:BX.ajax.history.__hashListener();\';'); 17378 } 17379 } 17380 17381 BX.ajax.history.bInited = true; 17382 }, 17383 17384 __hashListener: function(e) 17385 { 17386 e = e || window.event || {state:false}; 17387 17388 if (BX.ajax.history.bPushState) 17389 { 17390 BX.ajax.history.obParams.setState(e.state||BX.ajax.history.startState); 17391 } 17392 else 17393 { 17394 if (BX.ajax.history.obTimer) 17395 { 17396 window.clearTimeout(BX.ajax.history.obTimer); 17397 BX.ajax.history.obTimer = null; 17398 } 17399 17400 var current_hash; 17401 if (null != BX.ajax.history.obFrame) 17402 current_hash = BX.ajax.history.obFrame.contentWindow.document.body.innerText; 17403 else 17404 current_hash = window.location.hash; 17405 17406 if (!current_hash || current_hash == '#') 17407 current_hash = '__bx_no_hash__'; 17408 17409 if (current_hash.indexOf('#') == 0) 17410 current_hash = current_hash.substring(1); 17411 17412 if (current_hash != BX.ajax.history.expected_hash) 17413 { 17414 var state = jsAjaxHistoryContainer.get(current_hash); 17415 if (state) 17416 { 17417 BX.ajax.history.obParams.setState(state); 17418 17419 BX.ajax.history.expected_hash = current_hash; 17420 if (null != BX.ajax.history.obFrame) 17421 { 17422 var __hash = current_hash == '__bx_no_hash__' ? '' : current_hash; 17423 if (window.location.hash != __hash && window.location.hash != '#' + __hash) 17424 window.location.hash = __hash; 17425 } 17426 } 17427 } 17428 17429 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 17430 } 17431 }, 17432 17433 put: function(state, new_hash, new_hash1, bStartState) 17434 { 17435 if (this.bPushState) 17436 { 17437 if(!bStartState) 17438 { 17439 history.pushState(state, '', new_hash); 17440 } 17441 else 17442 { 17443 BX.ajax.history.startState = state; 17444 } 17445 } 17446 else 17447 { 17448 if (typeof new_hash1 != 'undefined') 17449 new_hash = new_hash1; 17450 else 17451 new_hash = 'view' + new_hash; 17452 17453 jsAjaxHistoryContainer.put(new_hash, state); 17454 BX.ajax.history.expected_hash = new_hash; 17455 17456 window.location.hash = BX.util.urlencode(new_hash); 17457 17458 if (null != BX.ajax.history.obFrame) 17459 { 17460 BX.ajax.history.obFrame.contentWindow.document.open(); 17461 BX.ajax.history.obFrame.contentWindow.document.write(new_hash); 17462 BX.ajax.history.obFrame.contentWindow.document.close(); 17463 } 17464 } 17465 }, 17466 17467 checkRedirectStart: function(param_name, param_value) 17468 { 17469 var current_hash = window.location.hash; 17470 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 17471 17472 var test = current_hash.substring(0, 5); 17473 if (test == 'view/' || test == 'view%') 17474 { 17475 BX.ajax.history.bHashCollision = true;
17476 document.write('<' + 'div id="__ajax_hash_collision_' + param_value + '" style="display: none;">'); 17477 } 17478 }, 17479 17480 checkRedirectFinish: function(param_name, param_value) 17481 { 17482 document.write('</div>'); 17483 17484 var current_hash = window.location.hash; 17485 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 17486 17487 BX.ready(function () 17488 { 17489 var test = current_hash.substring(0, 5); 17490 if (test == 'view/' || test == 'view%') 17491 { 17492 var obColNode = BX('__ajax_hash_collision_' + param_value); 17493 var obNode = obColNode.firstChild; 17494 BX.cleanNode(obNode); 17495 obColNode.style.display = 'block'; 17496 17497 // IE, Opera and Chrome automatically modifies hash with urlencode, but FF doesn't ;-( 17498 if (test != 'view%') 17499 current_hash = BX.util.urlencode(current_hash); 17500 17501 current_hash += (current_hash.indexOf('%3F') == -1 ? '%3F' : '%26') + param_name + '=' + param_value; 17502 17503 var url = '/bitrix/tools/ajax_redirector.php?hash=' + current_hash; 17504 17505 BX.ajax.insertToNode(url, obNode); 17506 } 17507 }); 17508 } 17509}; 17510 17511BX.ajax.component = function(node) 17512{ 17513 this.node = node; 17514}; 17515 17516BX.ajax.component.prototype.getState = function() 17517{ 17518 var state = { 17519 'node': this.node, 17520 'title': window.document.title, 17521 'data': BX(this.node).innerHTML 17522 }; 17523 17524 var obNavChain = BX('navigation'); 17525 if (null != obNavChain) 17526 state.nav_chain = obNavChain.innerHTML; 17527 17528 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistoryGetState", [state]); 17529 17530 return state; 17531}; 17532 17533BX.ajax.component.prototype.setState = function(state) 17534{ 17535 BX(state.node).innerHTML = state.data; 17536 BX.ajax.UpdatePageTitle(state.title); 17537 17538 if (state.nav_chain) 17539 { 17540 BX.ajax.UpdatePageNavChain(state.nav_chain); 17541 } 17542 17543 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistorySetState", [state]); 17544}; 17545 17546var jsAjaxHistoryContainer = { 17547 arHistory: {}, 17548 17549 put: function(hash, state) 17550 { 17551 this.arHistory[hash] = state; 17552 }, 17553 17554 get: function(hash) 17555 { 17556 return this.arHistory[hash]; 17557 } 17558}; 17559 17560 17561BX.ajax.FormData = function() 17562{ 17563 this.elements = []; 17564 this.files = []; 17565 this.features = {}; 17566 this.isSupported(); 17567 this.log('BX FormData init'); 17568}; 17569 17570BX.ajax.FormData.isSupported = function() 17571{ 17572 var f = new BX.ajax.FormData(); 17573 var result = f.features.supported; 17574 f = null; 17575 return result; 17576}; 17577 17578BX.ajax.FormData.prototype.log = function(o) 17579{ 17580 if (false) { 17581 try { 17582 if (BX.browser.IsIE()) o = JSON.stringify(o); 17583 console.log(o); 17584 } catch(e) {} 17585 } 17586}; 17587 17588BX.ajax.FormData.prototype.isSupported = function() 17589{ 17590 var f = {}; 17591 f.fileReader = (window.FileReader && window.FileReader.prototype.readAsBinaryString); 17592 f.readFormData = f.sendFormData = !!(window.FormData); 17593 f.supported = !!(f.readFormData && f.sendFormData); 17594 this.features = f; 17595 this.log('features:'); 17596 this.log(f); 17597 17598 return f.supported; 17599}; 17600 17601BX.ajax.FormData.prototype.append = function(name, value) 17602{ 17603 if (typeof(value) === 'object') { // seems to be files element 17604 this.files.push({'name': name, 'value':value}); 17605 } else { 17606 this.elements.push({'name': name, 'value':value}); 17607 } 17608}; 17609 17610BX.ajax.FormData.prototype.send = function(url, callbackOk, callbackProgress, callbackError) 17611{ 17612 this.log('FD send'); 17613 this.xhr = BX.ajax({ 17614 'method': 'POST', 17615 'dataType': 'html', 17616 'url': url, 17617 'onsuccess': callbackOk, 17618 'onfailure': callbackError, 17619 'start': false, 17620 'preparePost':false 17621 }); 17622 17623 if (callbackProgress) 17624 { 17625 this.xhr.upload.addEventListener( 17626 'progress', 17627 function(e) { 17628 if (e.lengthComputable) 17629 callbackProgress(e.loaded / (e.total || e.totalSize)); 17630 }, 17631 false 17632 ); 17633 } 17634 17635 if (this.features.readFormData && this.features.sendFormData) 17636 { 17637 var fd = new FormData(); 17638 this.log('use browser formdata'); 17639 for (var i in this.elements) 17640 { 17641 if(this.elements.hasOwnProperty(i)) 17642 fd.append(this.elements[i].name,this.elements[i].value); 17643 } 17644 for (i in this.files) 17645 { 17646 if(this.files.hasOwnProperty(i)) 17647 fd.append(this.files[i].name, this.files[i].value); 17648 } 17649 this.xhr.send(fd); 17650 } 17651 17652 return this.xhr; 17653}; 17654 17655BX.addCustomEvent('onAjaxFailure', BX.debug); 17656})(window); 17657 17658 17659(function (exports,main_core) { 17660 'use strict'; 17661 17662 var LazyLoad = { 17663 observer: null, 17664 images: {}, 17665 imageStatus: { 17666 hidden: -2, 17667 error: -1, 17668 "undefined": 0, 17669 inited: 1, 17670 loaded: 2 17671 }, 17672 imageTypes: { 17673 image: 1, 17674 background: 2 17675 },
17676 initObserver: function initObserver() { 17677 this.observer = new IntersectionObserver(this.onIntersection.bind(this), { 17678 rootMargin: '20% 0% 20% 0%', 17679 threshold: 0.10 17680 }); 17681 }, 17682 onIntersection: function onIntersection(entries) { 17683 entries.forEach(function (entry) { 17684 if (entry.isIntersecting) { 17685 this.showImage(entry.target); 17686 } 17687 }.bind(this)); 17688 }, 17689 registerImage: function registerImage(id, isImageVisibleCallback, options) { 17690 if (this.observer === null) { 17691 this.initObserver(); 17692 } 17693 17694 options = options || {}; 17695 17696 if (!main_core.Type.isStringFilled(id)) { 17697 return; 17698 } 17699 17700 if (main_core.Type.isObject(this.images[id])) { 17701 return; 17702 } 17703 17704 var element = document.getElementById(id); 17705 17706 if (!main_core.Type.isDomNode(element)) { 17707 return; 17708 } 17709 17710 this.observer.observe(element); 17711 this.images[id] = { 17712 id: id, 17713 node: null, 17714 src: null, 17715 dataSrcName: options.dataSrcName || 'src', 17716 type: null, 17717 func: main_core.Type.isFunction(isImageVisibleCallback) ? isImageVisibleCallback : null, 17718 status: this.imageStatus.undefined 17719 }; 17720 }, 17721 registerImages: function registerImages(ids, isImageVisibleCallback, options) { 17722 if (main_core.Type.isArray(ids)) { 17723 for (var i = 0, length = ids.length; i < length; i++) { 17724 this.registerImage(ids[i], isImageVisibleCallback, options); 17725 } 17726 } 17727 }, 17728 showImage: function showImage(imageNode) { 17729 var imageNodeId = imageNode.id; 17730 17731 if (!main_core.Type.isStringFilled(imageNodeId)) { 17732 return; 17733 } 17734 17735 var image = this.images[imageNodeId]; 17736 17737 if (!main_core.Type.isPlainObject(image)) { 17738 return; 17739 } 17740 17741 if (image.status == this.imageStatus.undefined) { 17742 this.initImage(image); 17743 } 17744 17745 if (image.status !== this.imageStatus.inited) { 17746 return; 17747 } 17748 17749 if (!image.node || !image.node.parentNode) { 17750 image.node = null; 17751 image.status = this.imageStatus.error; 17752 return; 17753 } 17754 17755 if (image.type == this.imageTypes.image) { 17756 image.node.src = image.src; 17757 } else { 17758 image.node.style.backgroundImage = "url('" + image.src + "')"; 17759 } 17760 17761 image.node.dataset[image.dataSrcName] = ""; 17762 image.status = this.imageStatus.loaded; 17763 }, 17764 showImages: function showImages(checkOwnVisibility) { 17765 checkOwnVisibility = checkOwnVisibility !== false; 17766 17767 for (var id in this.images) { 17768 if (!this.images.hasOwnProperty(id)) { 17769 continue; 17770 } 17771 17772 var image = this.images[id]; 17773 17774 if (image.status == this.imageStatus.undefined) { 17775 this.initImage(image); 17776 } 17777 17778 if (image.status !== this.imageStatus.inited) { 17779 continue; 17780 } 17781 17782 if (!image.node || !image.node.parentNode) { 17783 image.node = null; 17784 image.status = this.imageStatus.error; 17785 continue; 17786 } 17787 17788 var isImageVisible = true; 17789 17790 if (checkOwnVisibility && main_core.Type.isFunction(image.func)) { 17791 isImageVisible = image.func(image); 17792 } 17793 17794 if (isImageVisible === true && this.isElementVisibleOnScreen(image.node)) { 17795 if (image.type == this.imageTypes.image) { 17796 image.node.src = image.src; 17797 } else { 17798 image.node.style.backgroundImage = "url('" + image.src + "')"; 17799 } 17800 17801 image.node.dataset[image.dataSrcName] = ""; 17802 image.status = this.imageStatus.loaded; 17803 } 17804 } 17805 }, 17806 initImage: function initImage(image) { 17807 image.status = this.imageStatus.error; 17808 var node = document.getElementById(image.id); 17809 17810 if (!main_core.Type.isDomNode(node)) { 17811 return; 17812 } 17813 17814 var src = node.dataset[image.dataSrcName]; 17815 17816 if (main_core.Type.isStringFilled(src)) { 17817 image.node = node; 17818 image.src = src; 17819 image.status = this.imageStatus.inited; 17820 image.type = image.node.tagName.toLowerCase() == "img" ? this.imageTypes.image : this.imageTypes.background; 17821 } 17822 }, 17823 isElementVisibleOnScreen: function isElementVisibleOnScreen(element) { 17824 var coords = this.getElementCoords(element); 17825 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 17826 var windowBottom = windowTop + document.documentElement.clientHeight; 17827 coords.bottom = coords.top + element.offsetHeight; 17828 return coords.top > windowTop && coords.top < windowBottom || // topVisible 17829 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 17830 ; 17831 }, 17832 isElementVisibleOn2Screens: function isElementVisibleOn2Screens(element) { 17833 var windowHeight = document.documentElement.clientHeight; 17834 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 17835 var windowBottom = windowTop + windowHeight; 17836 var coords = this.getElementCoords(element); 17837 coords.bottom = coords.top + element.offsetHeight; 17838 windowTop -= windowHeight; 17839 windowBottom += windowHeight; 17840 return coords.top > windowTop && coords.top < windowBottom || // topVisible 17841 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 17842 ; 17843 }, 17844 getElementCoords: function getElementCoords(element) { 17845 var box = element.getBoundingClientRect(); 17846 return { 17847 originTop: box.top, 17848 originLeft: box.left, 17849 top: box.top + window.pageYOffset, 17850 left: box.left + window.pageXOffset 17851 }; 17852 }, 17853 onScroll: function onScroll() {}, 17854 clearImages: function clearImages() { 17855 this.images = []; 17856 } 17857 }; 17858 17859 exports.LazyLoad = LazyLoad; 17860 17861}((this.BX = this.BX || {}),BX)); 17862 17863 17864 17865(function (exports) { 17866 'use strict'; 17867 17868 var ParamBag = /*#__PURE__*/function () { 17869 function ParamBag() { 17870 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 17871 babelHelpers.classCallCheck(this, ParamBag); 17872 17873 if (!!params && babelHelpers.typeof(params) === 'object') { 17874 this.params = new Map(Object.entries(params)); 17875 } else { 17876 this.params = new Map(); 17877 } 17878 } 17879 17880 babelHelpers.createClass(ParamBag, [{ 17881 key: "getParam", 17882 value: function getParam(key) { 17883 var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 17884 17885 if (this.params.has(key)) { 17886 return this.params.get(key); 17887 } 17888 17889 return defaultValue; 17890 } 17891 }, { 17892 key: "setParam", 17893 value: function setParam(key, value) { 17894 this.params.set(key, value); 17895 } 17896 }, { 17897 key: "clear", 17898 value: function clear() { 17899 this.params.clear(); 17900 } 17901 }], [{ 17902 key: "create", 17903 value: function create() { 17904 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 17905 return new ParamBag(params); 17906 } 17907 }]); 17908 return ParamBag; 17909 }(); 17910 17911 exports.ParamBag = ParamBag; 17912 17913}((this.BX = this.BX || {}))); 17914 17915 17916 17917(function() { 17918 BX.FixFontSize = function(params) 17919 { 17920 var widthNode, computedStyles, width; 17921 17922 this.node = null; 17923 this.prevWindowSize = 0; 17924 this.prevWrapperSize = 0; 17925 this.mainWrapper = null; 17926 this.textWrapper = null; 17927 this.objList = params.objList; 17928 this.minFontSizeList = []; 17929 this.minFontSize = 0; 17930 17931 if (params.onresize) 17932 { 17933 this.prevWindowSize = window.innerWidth || document.documentElement.clientWidth; 17934 BX.bind(window, 'resize', BX.throttle(this.onResize, 350, this)); 17935 } 17936 17937 if (params.onAdaptiveResize) 17938 { 17939 widthNode = this.objList[0].scaleBy || this.objList[0].node; 17940 computedStyles = getComputedStyle(widthNode); 17941 this.prevWrapperSize = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 17942 BX.bind(window, 'resize', BX.throttle(this.onAdaptiveResize, 350, this)); 17943 } 17944 17945 this.createTestNodes(); 17946 this.decrease(); 17947 }; 17948 17949 BX.FixFontSize.prototype = 17950 { 17951 createTestNodes: function() 17952 { 17953 this.textWrapper = BX.create('div',{ 17954 style : { 17955 display : 'inline-block', 17956 whiteSpace : 'nowrap' 17957 } 17958 }); 17959 17960 this.mainWrapper = BX.create('div',{ 17961 style : { 17962 height : 0, 17963 overflow : 'hidden' 17964 }, 17965 children : [this.textWrapper] 17966 }); 17967 17968 }, 17969 insertTestNodes: function() 17970 { 17971 document.body.appendChild(this.mainWrapper); 17972 }, 17973 removeTestNodes: function() 17974 { 17975 document.body.removeChild(this.mainWrapper); 17976 }, 17977 decrease: function() 17978 { 17979 var width, 17980 fontSize, 17981 widthNode, 17982 computedStyles; 17983 17984 this.insertTestNodes(); 17985
17986 for(var i=this.objList.length-1; i>=0; i--) 17987 { 17988 widthNode = this.objList[i].scaleBy || this.objList[i].node; 17989 computedStyles = getComputedStyle(widthNode); 17990 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 17991 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 17992 17993 this.textWrapperSetStyle(this.objList[i].node); 17994 17995 if(this.textWrapperInsertText(this.objList[i].node)) 17996 { 17997 while(this.textWrapper.offsetWidth > width && fontSize > 0) 17998 { 17999 this.textWrapper.style.fontSize = --fontSize + 'px'; 18000 } 18001 18002 if(this.objList[i].smallestValue) 18003 { 18004 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 18005 18006 this.minFontSizeList.push(this.objList[i].node) 18007 } 18008 else 18009 { 18010 this.objList[i].node.style.fontSize = fontSize + 'px'; 18011 } 18012 } 18013 } 18014 18015 if(this.minFontSizeList.length > 0) 18016 this.setMinFont(); 18017 18018 this.removeTestNodes(); 18019 18020 }, 18021 increase: function() 18022 { 18023 this.insertTestNodes(); 18024 var width, 18025 fontSize, 18026 widthNode, 18027 computedStyles; 18028 18029 this.insertTestNodes(); 18030 18031 for(var i=this.objList.length-1; i>=0; i--) 18032 { 18033 widthNode = this.objList[i].scaleBy || this.objList[i].node; 18034 computedStyles = getComputedStyle(widthNode); 18035 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18036 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 18037 18038 this.textWrapperSetStyle(this.objList[i].node); 18039 18040 if(this.textWrapperInsertText(this.objList[i].node)) 18041 { 18042 while(this.textWrapper.offsetWidth < width && fontSize < this.objList[i].maxFontSize) 18043 { 18044 this.textWrapper.style.fontSize = ++fontSize + 'px'; 18045 } 18046 18047 fontSize--; 18048 18049 if(this.objList[i].smallestValue) 18050 { 18051 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 18052 18053 this.minFontSizeList.push(this.objList[i].node) 18054 } 18055 else 18056 { 18057 this.objList[i].node.style.fontSize = fontSize + 'px'; 18058 } 18059 } 18060 } 18061 18062 if(this.minFontSizeList.length > 0) 18063 this.setMinFont(); 18064 18065 this.removeTestNodes(); 18066 }, 18067 setMinFont : function() 18068 { 18069 for(var i = this.minFontSizeList.length-1; i>=0; i--) 18070 { 18071 this.minFontSizeList[i].style.fontSize = this.minFontSize + 'px'; 18072 } 18073 18074 this.minFontSize = 0; 18075 }, 18076 onResize : function() 18077 { 18078 var width = window.innerWidth || document.documentElement.clientWidth; 18079 18080 if(this.prevWindowSize > width) 18081 this.decrease(); 18082 18083 else if (this.prevWindowSize < width) 18084 this.increase(); 18085 18086 this.prevWindowSize = width; 18087 }, 18088 onAdaptiveResize : function() 18089 { 18090 var widthNode = this.objList[0].scaleBy || this.objList[0].node, 18091 computedStyles = getComputedStyle(widthNode), 18092 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18093 18094 if (this.prevWrapperSize > width) 18095 this.decrease(); 18096 else if (this.prevWrapperSize < width) 18097 this.increase(); 18098 18099 this.prevWrapperSize = width; 18100 }, 18101 textWrapperInsertText : function(node) 18102 { 18103 if(node.textContent){ 18104 this.textWrapper.textContent = node.textContent; 18105 return true; 18106 } 18107 else if(node.innerText) 18108 { 18109 this.textWrapper.innerText = node.innerText; 18110 return true; 18111 } 18112 else { 18113 return false; 18114 } 18115 }, 18116 textWrapperSetStyle : function(node) 18117 { 18118 this.textWrapper.style.fontFamily = getComputedStyle(node)["font-family"]; 18119 this.textWrapper.style.fontSize = getComputedStyle(node)["font-size"]; 18120 this.textWrapper.style.fontStyle = getComputedStyle(node)["font-style"]; 18121 this.textWrapper.style.fontWeight = getComputedStyle(node)["font-weight"]; 18122 this.textWrapper.style.lineHeight = getComputedStyle(node)["line-height"]; 18123 } 18124 }; 18125 18126 BX.FixFontSize.init = function(params) 18127 { 18128 return new BX.FixFontSize(params); 18129 }; 18130})(); 18131 18132})(); 18133//# 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.