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;
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 }
vendor: 12,022 bytes, lines 2748-3146
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;
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);
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;
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 Type.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 Type.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 const extensionsStorage = new Map(); 6547 6548 const ajaxController = 'main.bitrix.main.controller.loadext.getextensions'; 6549 function loadAssets(options) { 6550 return new Promise(resolve => { 6551 // eslint-disable-next-line 6552 BX.ajax.runAction(ajaxController, { 6553 data: options 6554 }).then(resolve); 6555 }); 6556 } 6557 6558 function fetchInlineScripts(acc, item) { 6559 if (item.isInternal) { 6560 acc.push(item.JS); 6561 } 6562 return acc; 6563 } 6564 function fetchExternalScripts(acc, item) { 6565 if (!item.isInternal) { 6566 acc.push(item.JS); 6567 } 6568 return acc; 6569 } 6570 function fetchExternalStyles(acc, item) { 6571 if (Type.isString(item) && item !== '') { 6572 acc.push(item); 6573 } 6574 return acc; 6575 } 6576 function fetchExtensionSettings(html) { 6577 if (Type.isStringFilled(html)) { 6578 const scripts = html.match(/<script type="extension\/settings" \b[^>]*>([\s\S]*?)<\/script>/g); 6579 if (Type.isArrayFilled(scripts)) { 6580 return scripts.map(script => { 6581 const [, extension] = script.match(/data-extension="(.[a-z0-9_.-]+)"/); 6582 return { 6583 extension, 6584 script 6585 }; 6586 }); 6587 } 6588 } 6589 return []; 6590 } 6591 function loadAll(items) { 6592 const itemsList = Type.isArray(items) ? items : [items]; 6593 if (!itemsList.length) { 6594 return Promise.resolve(); 6595 } 6596 return new Promise(resolve => { 6597 // eslint-disable-next-line 6598 BX.load(itemsList, resolve); 6599 }); 6600 } 6601 6602 function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); } 6603 function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 6604 const defaultOptions = { 6605 loaded: false 6606 }; 6607 var _state = /*#__PURE__*/new WeakMap(); 6608 var _name = /*#__PURE__*/new WeakMap(); 6609 var _namespace = /*#__PURE__*/new WeakMap(); 6610 var _promise = /*#__PURE__*/new WeakMap(); 6611 let Extension = /*#__PURE__*/function () { 6612 function Extension(options) { 6613 babelHelpers.classCallCheck(this, Extension); 6614 _classPrivateFieldInitSpec(this, _state, { 6615 writable: true, 6616 value: Extension.State.LOADING 6617 }); 6618 _classPrivateFieldInitSpec(this, _name, { 6619 writable: true, 6620 value: '' 6621 }); 6622 _classPrivateFieldInitSpec(this, _namespace, { 6623 writable: true, 6624 value: '' 6625 }); 6626 _classPrivateFieldInitSpec(this, _promise, { 6627 writable: true, 6628 value: null 6629 }); 6630 const preparedOptions = { 6631 ...defaultOptions, 6632 ...options 6633 }; 6634 babelHelpers.classPrivateFieldSet(this, _name, preparedOptions.name); 6635 babelHelpers.classPrivateFieldSet(this, _namespace, Type.isStringFilled(preparedOptions.namespace) ? preparedOptions.namespace : 'window'); 6636 if (preparedOptions.loaded) { 6637 babelHelpers.classPrivateFieldSet(this, _state, Extension.State.LOADED); 6638 } 6639 } 6640 babelHelpers.createClass(Extension, [{ 6641 key: "load", 6642 value: function load() { 6643 if (babelHelpers.classPrivateFieldGet(this, _state) === Extension.State.LOADED && !babelHelpers.classPrivateFieldGet(this, _promise)) { 6644 babelHelpers.classPrivateFieldSet(this, _promise, Promise.resolve(Reflection.getClass(babelHelpers.classPrivateFieldGet(this, _namespace)))); 6645 } 6646 if (babelHelpers.classPrivateFieldGet(this, _promise)) { 6647 return babelHelpers.classPrivateFieldGet(this, _promise); 6648 } 6649 babelHelpers.classPrivateFieldSet(this, _state, Extension.State.LOADING); 6650 babelHelpers.classPrivateFieldSet(this, _promise, new Promise(resolve => { 6651 void loadAssets({ 6652 extension: [babelHelpers.classPrivateFieldGet(this, _name)] 6653 }).then(assetsResult => { 6654 if (!Type.isArrayFilled(assetsResult.data)) { 6655 resolve(window); 6656 }
6657 const extensionData = assetsResult.data.at(0); 6658 if (Type.isPlainObject(extensionData.config) && Type.isStringFilled(extensionData.config.namespace)) { 6659 babelHelpers.classPrivateFieldSet(this, _namespace, extensionData.config.namespace); 6660 } 6661 const result = BX.processHTML(extensionData.html || ''); 6662 const inlineScripts = result.SCRIPT.reduce(fetchInlineScripts, []); 6663 const externalScripts = result.SCRIPT.reduce(fetchExternalScripts, []); 6664 const externalStyles = result.STYLE.reduce(fetchExternalStyles, []); 6665 const settingsScripts = fetchExtensionSettings(result.HTML); 6666 settingsScripts.forEach(entry => { 6667 document.body.insertAdjacentHTML('beforeend', entry.script); 6668 }); 6669 inlineScripts.forEach(script => { 6670 BX.evalGlobal(script); 6671 }); 6672 void Promise.all([loadAll(externalScripts), loadAll(externalStyles)]).then(() => { 6673 babelHelpers.classPrivateFieldSet(this, _state, Extension.State.LOADED); 6674 if (babelHelpers.classPrivateFieldGet(this, _namespace)) { 6675 return Reflection.getClass(babelHelpers.classPrivateFieldGet(this, _namespace)); 6676 } 6677 return window; 6678 }).then(exports => { 6679 resolve(exports); 6680 }); 6681 }); 6682 })); 6683 return babelHelpers.classPrivateFieldGet(this, _promise); 6684 } 6685 }]); 6686 return Extension; 6687 }(); 6688 babelHelpers.defineProperty(Extension, "State", { 6689 LOADED: 'LOADED', 6690 LOADING: 'LOADING' 6691 }); 6692 6693 async function loadExtension(...extensionName) { 6694 const extensionNames = extensionName.flat(); 6695 const result = extensionNames.map(name => { 6696 if (extensionsStorage.has(name)) { 6697 return extensionsStorage.get(name).load(); 6698 } 6699 const extension = new Extension({ 6700 name 6701 }); 6702 extensionsStorage.set(name, extension); 6703 return extension.load(); 6704 }); 6705 return Promise.all(result).then(exports => { 6706 return exports.reduce((acc, currentExports) => { 6707 if (Type.isObject(currentExports)) { 6708 return { 6709 ...acc, 6710 ...currentExports 6711 }; 6712 } 6713 return acc; 6714 }, {}); 6715 }); 6716 } 6717 6718 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]']; 6719 function isCloneable(value) { 6720 const isCloneableValue = Type.isObjectLike(value) && cloneableTags.includes(getTag(value)); 6721 return isCloneableValue || Type.isDomNode(value); 6722 } 6723 function internalClone(value, map) { 6724 if (map.has(value)) { 6725 return map.get(value); 6726 } 6727 if (isCloneable(value)) { 6728 if (Type.isArray(value)) { 6729 const cloned = Array.from(value); 6730 map.set(value, cloned); 6731 value.forEach((item, index) => { 6732 cloned[index] = internalClone(item, map); 6733 }); 6734 return map.get(value); 6735 } 6736 if (Type.isDomNode(value)) { 6737 return value.cloneNode(true); 6738 } 6739 if (Type.isMap(value)) { 6740 const result = new Map(); 6741 map.set(value, result); 6742 value.forEach((item, key) => { 6743 result.set(internalClone(key, map), internalClone(item, map)); 6744 }); 6745 return result; 6746 } 6747 if (Type.isSet(value)) { 6748 const result = new Set(); 6749 map.set(value, result); 6750 value.forEach(item => { 6751 result.add(internalClone(item, map)); 6752 }); 6753 return result; 6754 } 6755 if (Type.isDate(value)) { 6756 return new Date(value); 6757 } 6758 if (Type.isRegExp(value)) { 6759 const regExpFlags = /\w*$/; 6760 const flags = regExpFlags.exec(value); 6761 let result = new RegExp(value.source); 6762 if (flags && Type.isArray(flags)) { 6763 result = new RegExp(value.source, flags[0]); 6764 } 6765 result.lastIndex = value.lastIndex; 6766 return result; 6767 } 6768 const proto = Object.getPrototypeOf(value); 6769 const result = Object.assign(Object.create(proto), value); 6770 map.set(value, result); 6771 Object.keys(value).forEach(key => { 6772 result[key] = internalClone(value[key], map); 6773 }); 6774 return result; 6775 } 6776 return value; 6777 } 6778 6779 /** 6780 * Clones any cloneable object 6781 * @param value 6782 * @return {*} 6783 */ 6784 function clone(value) { 6785 return internalClone(value, new WeakMap()); 6786 } 6787 6788 function merge(current, target) { 6789 return Object.entries(target).reduce((acc, [key, value]) => { 6790 if (!Type.isDomNode(acc[key]) && Type.isObjectLike(acc[key]) && Type.isObjectLike(value)) { 6791 acc[key] = merge(acc[key], value); 6792 return acc; 6793 } 6794 acc[key] = value; 6795 return acc; 6796 }, current); 6797 } 6798 6799 function createComparator(fields, orders = []) { 6800 return (a, b) => { 6801 const field = fields[0]; 6802 const order = orders[0] || 'asc'; 6803 if (Type.isUndefined(field)) { 6804 return 0; 6805 } 6806 let valueA = a[field]; 6807 let valueB = b[field]; 6808 if (Type.isString(valueA) && Type.isString(valueB)) { 6809 valueA = valueA.toLowerCase(); 6810 valueB = valueB.toLowerCase(); 6811 } 6812 if (valueA < valueB) { 6813 return order === 'asc' ? -1 : 1; 6814 } 6815 if (valueA > valueB) { 6816 return order === 'asc' ? 1 : -1; 6817 } 6818 return createComparator(fields.slice(1), orders.slice(1))(a, b); 6819 }; 6820 } 6821 6822 function registerExtension(options) { 6823 if (!extensionsStorage.has(options.name)) { 6824 extensionsStorage.set(options.name, new Extension(options)); 6825 } 6826 } 6827
6828 /** 6829 * @memberOf BX 6830 */ 6831 let Runtime = /*#__PURE__*/function () { 6832 function Runtime() { 6833 babelHelpers.classCallCheck(this, Runtime); 6834 } 6835 babelHelpers.createClass(Runtime, null, [{ 6836 key: "debounce", 6837 value: function debounce(func, wait = 0, context = null) { 6838 let timeoutId; 6839 return function debounced(...args) { 6840 if (Type.isNumber(timeoutId)) { 6841 clearTimeout(timeoutId); 6842 } 6843 timeoutId = setTimeout(() => { 6844 func.apply(context || this, args); 6845 }, wait); 6846 }; 6847 } 6848 }, { 6849 key: "throttle", 6850 value: function throttle(func, wait = 0, context = null) { 6851 let timer = 0; 6852 let invoke; 6853 return function wrapper(...args) { 6854 invoke = true; 6855 if (!timer) { 6856 const q = function q() { 6857 if (invoke) { 6858 func.apply(context || this, args); 6859 invoke = false; 6860 timer = setTimeout(q, wait); 6861 } else { 6862 timer = null; 6863 } 6864 }; 6865 q(); 6866 } 6867 }; 6868 } 6869 }, { 6870 key: "html", 6871 value: function html(node, _html, params = {}) { 6872 if (Type.isNil(_html) && Type.isDomNode(node)) { 6873 return node.innerHTML; 6874 } 6875 6876 // eslint-disable-next-line 6877 const parsedHtml = BX.processHTML(_html); 6878 const externalCss = parsedHtml.STYLE.reduce(fetchExternalStyles, []); 6879 const externalJs = parsedHtml.SCRIPT.reduce(fetchExternalScripts, []); 6880 const inlineJs = parsedHtml.SCRIPT.reduce(fetchInlineScripts, []); 6881 if (Type.isDomNode(node)) { 6882 if (params.htmlFirst || !externalJs.length && !externalCss.length) { 6883 if (params.useAdjacentHTML) { 6884 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 6885 } else { 6886 node.innerHTML = parsedHtml.HTML; 6887 } 6888 } 6889 } 6890 return Promise.all([loadAll(externalJs), loadAll(externalCss)]).then(() => { 6891 if (Type.isDomNode(node) && (externalJs.length > 0 || externalCss.length > 0)) { 6892 if (params.useAdjacentHTML) { 6893 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 6894 } else { 6895 node.innerHTML = parsedHtml.HTML; 6896 } 6897 } 6898 6899 // eslint-disable-next-line 6900 inlineJs.forEach(script => BX.evalGlobal(script)); 6901 if (Type.isFunction(params.callback)) { 6902 params.callback(); 6903 } 6904 }); 6905 } 6906 /** 6907 * Merges objects or arrays 6908 * @param targets 6909 * @return {any} 6910 */ 6911 }, { 6912 key: "merge", 6913 value: function merge$$1(...targets) { 6914 if (Type.isArray(targets[0])) { 6915 targets.unshift([]); 6916 } else if (Type.isObject(targets[0])) { 6917 targets.unshift({}); 6918 } 6919 return targets.reduce((acc, item) => { 6920 return merge(acc, item); 6921 }, targets[0]); 6922 } 6923 }, { 6924 key: "orderBy", 6925 value: function orderBy(collection, fields = [], orders = []) { 6926 const comparator = createComparator(fields, orders); 6927 return Object.values(collection).sort(comparator); 6928 } 6929 }, { 6930 key: "destroy", 6931 value: function destroy(target, errorMessage = 'Object is destroyed') { 6932 if (Type.isObject(target)) { 6933 const onPropertyAccess = () => { 6934 throw new Error(errorMessage); 6935 }; 6936 const ownProperties = Object.keys(target); 6937 const prototypeProperties = (() => { 6938 const targetPrototype = Object.getPrototypeOf(target); 6939 if (Type.isObject(targetPrototype)) { 6940 return Object.getOwnPropertyNames(targetPrototype); 6941 } 6942 return []; 6943 })(); 6944 const uniquePropertiesList = [...new Set([...ownProperties, ...prototypeProperties])]; 6945 uniquePropertiesList.filter(name => { 6946 const descriptor = Object.getOwnPropertyDescriptor(target, name); 6947 return !/__(.+)__/.test(name) && (!Type.isObject(descriptor) || descriptor.configurable === true); 6948 }
6948).forEach(name => { 6949 Object.defineProperty(target, name, { 6950 get: onPropertyAccess, 6951 set: onPropertyAccess, 6952 configurable: false 6953 }); 6954 }); 6955 Object.setPrototypeOf(target, null); 6956 } 6957 } 6958 }]); 6959 return Runtime; 6960 }(); 6961 babelHelpers.defineProperty(Runtime, "debug", debug); 6962 babelHelpers.defineProperty(Runtime, "loadExtension", loadExtension); 6963 babelHelpers.defineProperty(Runtime, "registerExtension", registerExtension); 6964 babelHelpers.defineProperty(Runtime, "clone", clone); 6965 6966 const _isError = Symbol.for('BX.BaseError.isError'); 6967 6968 /** 6969 * @memberOf BX 6970 */ 6971 let BaseError = /*#__PURE__*/function () { 6972 function BaseError(message, code, customData) { 6973 babelHelpers.classCallCheck(this, BaseError); 6974 this[_isError] = true; 6975 this.message = ''; 6976 this.code = null; 6977 this.customData = null; 6978 this.setMessage(message); 6979 this.setCode(code); 6980 this.setCustomData(customData); 6981 } 6982 6983 /** 6984 * Returns a brief description of the error 6985 * @returns {string} 6986 */ 6987 babelHelpers.createClass(BaseError, [{ 6988 key: "getMessage", 6989 value: function getMessage() { 6990 return this.message; 6991 } 6992 /** 6993 * Sets a message of the error 6994 * @param {string} message 6995 * @returns {this} 6996 */ 6997 }, { 6998 key: "setMessage", 6999 value: function setMessage(message) { 7000 if (Type.isString(message)) { 7001 this.message = message; 7002 } 7003 return this; 7004 } 7005 /** 7006 * Returns a code of the error 7007 * @returns {?string} 7008 */ 7009 }, { 7010 key: "getCode", 7011 value: function getCode() { 7012 return this.code; 7013 } 7014 /** 7015 * Sets a code of the error 7016 * @param {string} code 7017 * @returns {this} 7018 */ 7019 }, { 7020 key: "setCode", 7021 value: function setCode(code) { 7022 if (Type.isStringFilled(code) || code === null) { 7023 this.code = code; 7024 } 7025 return this; 7026 } 7027 /** 7028 * Returns custom data of the error 7029 * @returns {null|*} 7030 */ 7031 }, { 7032 key: "getCustomData", 7033 value: function getCustomData() { 7034 return this.customData; 7035 } 7036 /** 7037 * Sets custom data of the error 7038 * @returns {this} 7039 */ 7040 }, { 7041 key: "setCustomData", 7042 value: function setCustomData(customData) { 7043 if (!Type.isUndefined(customData)) { 7044 this.customData = customData; 7045 } 7046 return this; 7047 } 7048 }, { 7049 key: "toString", 7050 value: function toString() { 7051 const code = this.getCode(); 7052 const message = this.getMessage(); 7053 if (!Type.isStringFilled(code) && !Type.isStringFilled(message)) { 7054 return ''; 7055 } else if (!Type.isStringFilled(code)) { 7056 return `Error: ${message}`; 7057 } else if (!Type.isStringFilled(message)) { 7058 return code; 7059 } else { 7060 return `${code}: ${message}`; 7061 } 7062 } 7063 /** 7064 * Returns true if the object is an instance of BaseError 7065 * @param error 7066 * @returns {boolean} 7067 */ 7068 }], [{ 7069 key: "isError", 7070 value: function isError(error) { 7071 return Type.isObject(error) && error[_isError] === true; 7072 } 7073 }]); 7074 return BaseError; 7075 }(); 7076 7077 /** 7078 * Implements base event object interface 7079 */ 7080 let BaseEvent = /*#__PURE__*/function () { 7081 function BaseEvent(options = { 7082 data: {} 7083 }) { 7084 babelHelpers.classCallCheck(this, BaseEvent); 7085 this.type = ''; 7086 this.data = null; 7087 this.target = null; 7088 this.compatData = null; 7089 this.defaultPrevented = false; 7090 this.immediatePropagationStopped = false; 7091 this.errors = []; 7092 this.setData(options.data); 7093 this.setCompatData(options.compatData); 7094 } 7095 babelHelpers.createClass(BaseEvent, [{ 7096 key: "getType", 7097 /** 7098 * Returns the name of the event 7099 * @returns {string} 7100 */ 7101 value: function getType() { 7102 return this.type; 7103 } 7104 /** 7105 * 7106 * @param {string} type 7107 */ 7108 }, { 7109 key: "setType", 7110 value: function setType(type) { 7111 if (Type.isStringFilled(type)) { 7112 this.type = type; 7113 } 7114 return this; 7115 } 7116 /** 7117 * Returns an event data 7118 */ 7119 }, { 7120 key: "getData", 7121 value: function getData() { 7122 return this.data; 7123 } 7124 /** 7125 * Sets an event data 7126 * @param data 7127 */ 7128 }, { 7129 key: "setData", 7130 value: function setData(data) { 7131 if (!Type.isUndefined(data)) { 7132 this.data = data; 7133 } 7134 return this; 7135 } 7136 /** 7137 * Returns arguments for BX.addCustomEvent handlers (deprecated). 7138 * @returns {array | null} 7139 */ 7140 }, { 7141 key: "getCompatData", 7142 value: function getCompatData() { 7143 return this.compatData; 7144 } 7145 /** 7146 * Sets arguments for BX.addCustomEvent handlers (deprecated) 7147 * @param data 7148 */ 7149 }, { 7150 key: "setCompatData", 7151 value: function setCompatData(data) { 7152 if (Type.isArrayLike(data)) { 7153 this.compatData = data; 7154 } 7155 return this; 7156 } 7157 /** 7158 * Sets a event target 7159 * @param target 7160 */ 7161 }, { 7162 key: "setTarget", 7163 value: function setTarget(target) { 7164 this.target = target; 7165 return this; 7166 } 7167 /** 7168 * Returns a event target 7169 */ 7170 }, { 7171 key: "getTarget", 7172 value: function getTarget() { 7173 return this.target; 7174 } 7175 /** 7176 * Returns an array of event errors 7177 * @returns {[]} 7178 */ 7179 }, { 7180 key: "getErrors", 7181 value: function getErrors() { 7182 return this.errors; 7183 } 7184 /** 7185 * Adds an error of the event. 7186 * Event listeners can prevent emitter's default action and set the reason of this behavior. 7187 * @param error 7188 */ 7189 }, { 7190 key: "setError", 7191 value: function setError(error) { 7192 if (BaseError.isError(error)) { 7193 this.errors.push(error); 7194 } 7195 } 7196 /** 7197 * Prevents default action 7198 */ 7199 }, { 7200 key: "preventDefault", 7201 value: function preventDefault() { 7202 this.defaultPrevented = true; 7203 } 7204 /** 7205 * Checks that is default action prevented 7206 * @return {boolean} 7207 */ 7208 }, { 7209 key: "isDefaultPrevented", 7210 value: function isDefaultPrevented() { 7211 return this.defaultPrevented; 7212 } 7213 /** 7214 * Stops event immediate propagation 7215 */ 7216 }, { 7217 key: "stopImmediatePropagation", 7218 value: function stopImmediatePropagation() { 7219 this.immediatePropagationStopped = true; 7220 } 7221 /** 7222 * Checks that is immediate propagation stopped 7223 * @return {boolean} 7224 */ 7225 }, { 7226 key: "isImmediatePropagationStopped", 7227 value: function isImmediatePropagationStopped() { 7228 return this.immediatePropagationStopped; 7229 } 7230 }], [{ 7231 key: "create", 7232 value: function create(options) { 7233 return new this(options); 7234 } 7235 }]); 7236 return BaseEvent; 7237 }(); 7238 7239 let EventStore = /*#__PURE__*/function () { 7240 function EventStore(options = {}) { 7241 babelHelpers.classCallCheck(this, EventStore); 7242 this.defaultMaxListeners = Type.isNumber(options.defaultMaxListeners) ? options.defaultMaxListeners : 10; 7243 this.eventStore = new WeakMap(); 7244 } 7245 babelHelpers.createClass(EventStore, [{ 7246 key: "add", 7247 value: function add(target, options = {}) { 7248 const record = this.getRecordScheme(); 7249 if (Type.isNumber(options.maxListeners)) { 7250 record.maxListeners = options.maxListeners; 7251 } 7252 this.eventStore.set(target, record); 7253 return record; 7254 } 7255 }, { 7256 key: "get", 7257 value: function get(target) { 7258 return this.eventStore.get(target); 7259 } 7260 }, { 7261 key: "getOrAdd", 7262 value: function getOrAdd(target, options = {}) { 7263 return this.get(target) || this.add(target, options); 7264 } 7265 }, { 7266 key: "delete", 7267 value: function _delete(context) { 7268 this.eventStore.delete(context); 7269 } 7270 }, { 7271 key: "getRecordScheme", 7272 value: function getRecordScheme() { 7273 return { 7274 eventsMap: new Map(), 7275 onceMap: new Map(), 7276 maxListeners: this.getDefaultMaxListeners(), 7277 eventsMaxListeners: new Map() 7278 }; 7279 } 7280 }, { 7281 key: "getDefaultMaxListeners", 7282 value: function getDefaultMaxListeners() { 7283 return this.defaultMaxListeners; 7284 } 7285 }]); 7286 return EventStore; 7287 }(); 7288 7289 let WarningStore = /*#__PURE__*/function () {
7290 function WarningStore() { 7291 babelHelpers.classCallCheck(this, WarningStore); 7292 this.warnings = new Map(); 7293 this.printDelayed = Runtime.debounce(this.print.bind(this), 500); 7294 } 7295 babelHelpers.createClass(WarningStore, [{ 7296 key: "add", 7297 value: function add(target, eventName, listeners) { 7298 let contextWarnings = this.warnings.get(target); 7299 if (!contextWarnings) { 7300 contextWarnings = Object.create(null); 7301 this.warnings.set(target, contextWarnings); 7302 } 7303 if (!contextWarnings[eventName]) { 7304 contextWarnings[eventName] = {}; 7305 } 7306 contextWarnings[eventName].size = listeners.size; 7307 if (!Type.isArray(contextWarnings[eventName].errors)) { 7308 contextWarnings[eventName].errors = []; 7309 } 7310 contextWarnings[eventName].errors.push(new Error()); 7311 } 7312 }, { 7313 key: "print", 7314 value: function print() { 7315 this.warnings.forEach(warnings => { 7316 for (let eventName in warnings) { 7317 console.groupCollapsed('Possible BX.Event.EventEmitter memory leak detected. ' + warnings[eventName].size + ' "' + eventName + '" listeners added. ' + 'Use emitter.setMaxListeners() to increase limit.'); 7318 console.dir(warnings[eventName].errors); 7319 console.groupEnd(); 7320 } 7321 }); 7322 this.clear(); 7323 } 7324 }, { 7325 key: "clear", 7326 value: function clear() { 7327 this.warnings.clear(); 7328 } 7329 }, { 7330 key: "printDelayed", 7331 value: function printDelayed() {} 7332 }]); 7333 return WarningStore; 7334 }(); 7335 7336 const eventStore = new EventStore({ 7337 defaultMaxListeners: 10 7338 }); 7339 const warningStore = new WarningStore(); 7340 const aliasStore = new Map(); 7341 const globalTarget = { 7342 GLOBAL_TARGET: 'GLOBAL_TARGET' // this key only for debugging purposes 7343 }; 7344 7345 eventStore.add(globalTarget, { 7346 maxListeners: 25 7347 }); 7348 const isEmitterProperty = Symbol.for('BX.Event.EventEmitter.isEmitter'); 7349 const namespaceProperty = Symbol('namespaceProperty'); 7350 const targetProperty = Symbol('targetProperty'); 7351 let EventEmitter = /*#__PURE__*/function () { 7352 /** @private */ 7353 7354 function EventEmitter(...args) { 7355 babelHelpers.classCallCheck(this, EventEmitter); 7356 this[targetProperty] = null; 7357 this[namespaceProperty] = null; 7358 this[isEmitterProperty] = true; 7359 let target = this; 7360 if (Object.getPrototypeOf(this) === EventEmitter.prototype && args.length > 0) 7361 //new EventEmitter(obj) case 7362 { 7363 if (!Type.isObject(args[0])) { 7364 throw new TypeError(`The "target" argument must be an object.`); 7365 } 7366 target = args[0]; 7367 this.setEventNamespace(args[1]); 7368 } 7369 this[targetProperty] = target; 7370 } 7371 7372 /** 7373 * Makes a target observable 7374 * @param {object} target 7375 * @param {string} namespace 7376 */ 7377 babelHelpers.createClass(EventEmitter, [{ 7378 key: "setEventNamespace", 7379 value: function setEventNamespace(namespace) { 7380 if (Type.isStringFilled(namespace)) { 7381 this[namespaceProperty] = namespace; 7382 } 7383 } 7384 }, { 7385 key: "getEventNamespace", 7386 value: function getEventNamespace() { 7387 return this[namespaceProperty]; 7388 } 7389 /** 7390 * Subscribes listener on specified global event 7391 * @param {object} target 7392 * @param {string} eventName 7393 * @param {Function<BaseEvent>} listener 7394 * @param {object} options 7395 */ 7396 }, { 7397 key: "subscribe", 7398 /** 7399 * Subscribes a listener on a specified event 7400 * @param {string} eventName 7401 * @param {Function<BaseEvent>} listener 7402 * @return {this} 7403 */ 7404 value: function subscribe(eventName, listener) { 7405 EventEmitter.subscribe(this, eventName, listener); 7406 return this; 7407 } 7408 /** 7409 * 7410 * @param {object} options 7411 * @param {object} [aliases] 7412 * @param {boolean} [compatMode=false] 7413 */ 7414 }, { 7415 key: "subscribeFromOptions", 7416 value: function subscribeFromOptions(options, aliases, compatMode) { 7417 if (Type.isArrayFilled(options)) { 7418 options.forEach(events => { 7419 this.subscribeFromOptions(events); 7420 }); 7421 return; 7422 } 7423 if (!Type.isPlainObject(options)) { 7424 return; 7425 } 7426 aliases = Type.isPlainObject(aliases) ? EventEmitter.normalizeAliases(aliases) : {};
7427 Object.keys(options).forEach(eventName => { 7428 const listener = EventEmitter.normalizeListener(options[eventName]); 7429 eventName = EventEmitter.normalizeEventName(eventName); 7430 if (aliases[eventName]) { 7431 const { 7432 eventName: actualName 7433 } = aliases[eventName]; 7434 EventEmitter.subscribe(this, actualName, listener, { 7435 compatMode: compatMode !== false 7436 }); 7437 } else { 7438 EventEmitter.subscribe(this, eventName, listener, { 7439 compatMode: compatMode === true 7440 }); 7441 } 7442 }); 7443 } 7444 /** 7445 * Subscribes a listener that is called at 7446 * most once for a specified event. 7447 * @param {object} target 7448 * @param {string} eventName 7449 * @param {Function<BaseEvent>} listener 7450 */ 7451 }, { 7452 key: "subscribeOnce", 7453 /** 7454 * Subscribes a listener that is called at most once for a specified event. 7455 * @param {string} eventName 7456 * @param {Function<BaseEvent>} listener 7457 * @return {this} 7458 */ 7459 value: function subscribeOnce(eventName, listener) { 7460 EventEmitter.subscribeOnce(this, eventName, listener); 7461 return this; 7462 } 7463 /** 7464 * Unsubscribes an event listener 7465 * @param {object} target 7466 * @param {string} eventName 7467 * @param {Function<BaseEvent>} listener 7468 * @param options 7469 */ 7470 }, { 7471 key: "unsubscribe", 7472 /** 7473 * Unsubscribes an event listener 7474 * @param {string} eventName 7475 * @param {Function<BaseEvent>} listener 7476 * @return {this} 7477 */ 7478 value: function unsubscribe(eventName, listener) { 7479 EventEmitter.unsubscribe(this, eventName, listener); 7480 return this; 7481 } 7482 /** 7483 * Unsubscribes all event listeners 7484 * @param {object} target 7485 * @param {string} eventName 7486 * @param options 7487 */ 7488 }, { 7489 key: "unsubscribeAll", 7490 /** 7491 * Unsubscribes all event listeners 7492 * @param {string} [eventName] 7493 */ 7494 value: function unsubscribeAll(eventName) { 7495 EventEmitter.unsubscribeAll(this, eventName); 7496 } 7497 /** 7498 * 7499 * @param {object} target 7500 * @param {string} eventName 7501 * @param {BaseEvent | any} event 7502 * @param {object} options 7503 * @returns {Array} 7504 */ 7505 }, { 7506 key: "emit", 7507 /** 7508 * Emits specified event with specified event object 7509 * @param {string} eventName 7510 * @param {BaseEvent | any} event 7511 * @return {this} 7512 */ 7513 value: function emit(eventName, event) { 7514 if (this.getEventNamespace() === null) { 7515 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7516 } 7517 EventEmitter.emit(this, eventName, event); 7518 return this; 7519 } 7520 /** 7521 * Emits global event and returns a promise that is resolved when 7522 * all promise returned from event handlers are resolved, 7523 * or rejected when at least one of the returned promise is rejected. 7524 * Importantly. You can return any value from synchronous handlers, not just promise 7525 * @param {object} target 7526 * @param {string} eventName 7527 * @param {BaseEvent | any} event 7528 * @return {Promise<Array>} 7529 */ 7530 }, { 7531 key: "emitAsync", 7532 /** 7533 * Emits event and returns a promise that is resolved when 7534 * all promise returned from event handlers are resolved, 7535 * or rejected when at least one of the returned promise is rejected. 7536 * Importantly. You can return any value from synchronous handlers, not just promise 7537 * @param {string} eventName 7538 * @param {BaseEvent|any} event 7539 * @return {Promise<Array>} 7540 */ 7541 value: function emitAsync(eventName, event) { 7542 if (this.getEventNamespace() === null) { 7543 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7544 } 7545 return EventEmitter.emitAsync(this, eventName, event); 7546 } 7547 /** 7548 * @private 7549 * @param {object} target 7550 * @param {string} eventName 7551 * @param {BaseEvent|any} event 7552 * @returns {BaseEvent} 7553 */ 7554 }, { 7555 key: "setMaxListeners", 7556 /** 7557 * Sets max events listeners count 7558 * this.setMaxListeners(10) - sets the default value for all events
7559 * this.setMaxListeners("onClose", 10) sets the value for onClose event 7560 * @return {this} 7561 * @param args 7562 */ 7563 value: function setMaxListeners(...args) { 7564 EventEmitter.setMaxListeners(this, ...args); 7565 return this; 7566 } 7567 /** 7568 * Returns max event listeners count 7569 * @param {object} target 7570 * @param {string} [eventName] 7571 * @returns {number} 7572 */ 7573 }, { 7574 key: "getMaxListeners", 7575 /** 7576 * Returns max event listeners count 7577 * @param {string} [eventName] 7578 * @returns {number} 7579 */ 7580 value: function getMaxListeners(eventName) { 7581 return EventEmitter.getMaxListeners(this, eventName); 7582 } 7583 /** 7584 * Adds or subtracts max listeners count 7585 * Event.EventEmitter.addMaxListeners() - adds one max listener for all events of global target 7586 * Event.EventEmitter.addMaxListeners(3) - adds three max listeners for all events of global target 7587 * Event.EventEmitter.addMaxListeners(-1) - subtracts one max listener for all events of global target 7588 * Event.EventEmitter.addMaxListeners('onClose') - adds one max listener for onClose event of global target 7589 * Event.EventEmitter.addMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 7590 * Event.EventEmitter.addMaxListeners('onClose', -1) - subtracts one max listener for onClose event of global target 7591 * 7592 * Event.EventEmitter.addMaxListeners(obj) - adds one max listener for all events of 'obj' target 7593 * Event.EventEmitter.addMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 7594 * Event.EventEmitter.addMaxListeners(obj, -1) - subtracts one max listener for all events of 'obj' target 7595 * Event.EventEmitter.addMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 7596 * Event.EventEmitter.addMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 7597 * Event.EventEmitter.addMaxListeners(obj, 'onClose', -1) - subtracts one max listener for onClose event of 'obj' target 7598 * @param args 7599 * @returns {number} 7600 */ 7601 }, { 7602 key: "incrementMaxListeners", 7603 /** 7604 * Increases max listeners count 7605 * this.incrementMaxListeners() - adds one max listener for all events 7606 * this.incrementMaxListeners(3) - adds three max listeners for all events 7607 * this.incrementMaxListeners('onClose') - adds one max listener for onClose event 7608 * this.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event 7609 */ 7610 value: function incrementMaxListeners(...args) { 7611 return EventEmitter.incrementMaxListeners(this, ...args); 7612 } 7613 /** 7614 * Decreases max listeners count 7615 * 7616 * Event.EventEmitter.decrementMaxListeners() - subtracts one max listener for all events of global target 7617 * Event.EventEmitter.decrementMaxListeners(3) - subtracts three max listeners for all events of global target 7618 * Event.EventEmitter.decrementMaxListeners('onClose') - subtracts one max listener for onClose event of global target 7619 * Event.EventEmitter.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event of global target 7620 * 7621 * Event.EventEmitter.decrementMaxListeners(obj) - subtracts one max listener for all events of 'obj' target 7622 * Event.EventEmitter.decrementMaxListeners(obj, 3) - subtracts three max listeners for all events of 'obj' target 7623 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose') - subtracts one max listener for onClose event of 'obj' target 7624 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose', 2) - subtracts two max listeners for onClose event of 'obj' target 7625 */ 7626 }, { 7627 key: "decrementMaxListeners", 7628 /** 7629 * Increases max listeners count 7630 * this.decrementMaxListeners() - subtracts one max listener for all events 7631 * this.decrementMaxListeners(3) - subtracts three max listeners for all events 7632 * this.decrementMaxListeners('onClose') - subtracts one max listener for onClose event 7633 * this.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event 7634 */ 7635 value: function decrementMaxListeners(...args) { 7636 return EventEmitter.decrementMaxListeners(this, ...args); 7637 } 7638 /** 7639 * @private 7640 * @param {Array} args 7641 * @returns Array 7642 */ 7643 }, { 7644 key: "getListeners", 7645 /** 7646 * Gets listeners list for specified event 7647 * @param {string} eventName 7648 */ 7649 value: function getListeners(eventName) { 7650 return EventEmitter.getListeners(this, eventName); 7651 } 7652 /** 7653 * Returns a full event name with namespace 7654 * @param {string} eventName 7655 * @returns {string} 7656 */ 7657 }, { 7658 key: "getFullEventName", 7659 value: function getFullEventName(eventName) { 7660 if (!Type.isStringFilled(eventName)) { 7661 throw new TypeError(`The "eventName" argument must be a string.`); 7662 } 7663 return EventEmitter.makeFullEventName(this.getEventNamespace(), eventName); 7664 } 7665 /** 7666 * Registers aliases (old event names for BX.onCustomEvent) 7667 * @param aliases 7668 */ 7669 }], [{ 7670 key: "makeObservable", 7671 value: function makeObservable(target, namespace) { 7672 if (!Type.isObject(target)) { 7673 throw new TypeError('The "target" argument must be an object.'); 7674 } 7675 if (!Type.isStringFilled(namespace)) { 7676 throw new TypeError('The "namespace" must be an non-empty string.'); 7677 } 7678 if (EventEmitter.isEventEmitter(target)) { 7679 throw new TypeError('The "target" is an event emitter already.'); 7680 } 7681 const targetProto = Object.getPrototypeOf(target); 7682 const emitter = new EventEmitter(); 7683 emitter.setEventNamespace(namespace); 7684 Object.setPrototypeOf(emitter, targetProto); 7685 Object.setPrototypeOf(target, emitter); 7686 Object.getOwnPropertyNames(EventEmitter.prototype).forEach(method => {
7687 if (['constructor'].includes(method)) { 7688 return; 7689 } 7690 emitter[method] = function (...args) { 7691 return EventEmitter.prototype[method].apply(target, args); 7692 }; 7693 }); 7694 } 7695 }, { 7696 key: "subscribe", 7697 value: function subscribe(target, eventName, listener, options) { 7698 if (Type.isString(target)) { 7699 options = listener; 7700 listener = eventName; 7701 eventName = target; 7702 target = this.GLOBAL_TARGET; 7703 } 7704 if (!Type.isObject(target)) { 7705 throw new TypeError(`The "target" argument must be an object.`); 7706 } 7707 eventName = this.normalizeEventName(eventName); 7708 if (!Type.isStringFilled(eventName)) { 7709 throw new TypeError(`The "eventName" argument must be a string.`); 7710 } 7711 listener = this.normalizeListener(listener); 7712 options = Type.isPlainObject(options) ? options : {}; 7713 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7714 const { 7715 eventsMap, 7716 onceMap 7717 } = eventStore.getOrAdd(target); 7718 const onceListeners = onceMap.get(fullEventName); 7719 let listeners = eventsMap.get(fullEventName); 7720 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7721 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7722 } else { 7723 if (listeners) { 7724 listeners.set(listener, { 7725 listener, 7726 options, 7727 sort: this.getNextSequenceValue() 7728 }); 7729 } else { 7730 listeners = new Map([[listener, { 7731 listener, 7732 options, 7733 sort: this.getNextSequenceValue() 7734 }]]); 7735 eventsMap.set(fullEventName, listeners); 7736 } 7737 } 7738 const maxListeners = this.getMaxListeners(target, eventName); 7739 if (listeners.size > maxListeners) { 7740 warningStore.add(target, fullEventName, listeners); 7741 warningStore.printDelayed(); 7742 } 7743 } 7744 }, { 7745 key: "subscribeOnce", 7746 value: function subscribeOnce(target, eventName, listener) { 7747 if (Type.isString(target)) { 7748 listener = eventName; 7749 eventName = target; 7750 target = this.GLOBAL_TARGET;
7751 } 7752 if (!Type.isObject(target)) { 7753 throw new TypeError(`The "target" argument must be an object.`); 7754 } 7755 eventName = this.normalizeEventName(eventName); 7756 if (!Type.isStringFilled(eventName)) { 7757 throw new TypeError(`The "eventName" argument must be a string.`); 7758 } 7759 listener = this.normalizeListener(listener); 7760 const fullEventName = this.resolveEventName(eventName, target); 7761 const { 7762 eventsMap, 7763 onceMap 7764 } = eventStore.getOrAdd(target); 7765 const listeners = eventsMap.get(fullEventName); 7766 let onceListeners = onceMap.get(fullEventName); 7767 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7768 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7769 } else { 7770 const once = (...args) => { 7771 this.unsubscribe(target, eventName, once); 7772 onceListeners.delete(listener); 7773 listener(...args); 7774 }; 7775 if (onceListeners) { 7776 onceListeners.set(listener, once); 7777 } else { 7778 onceListeners = new Map([[listener, once]]); 7779 onceMap.set(fullEventName, onceListeners); 7780 } 7781 this.subscribe(target, eventName, once); 7782 } 7783 } 7784 }, { 7785 key: "unsubscribe", 7786 value: function unsubscribe(target, eventName, listener, options) { 7787 if (Type.isString(target)) { 7788 listener = eventName; 7789 eventName = target; 7790 target = this.GLOBAL_TARGET;
7791 } 7792 eventName = this.normalizeEventName(eventName); 7793 if (!Type.isStringFilled(eventName)) { 7794 throw new TypeError(`The "eventName" argument must be a string.`); 7795 } 7796 listener = this.normalizeListener(listener); 7797 options = Type.isPlainObject(options) ? options : {}; 7798 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7799 const targetInfo = eventStore.get(target); 7800 const listeners = targetInfo && targetInfo.eventsMap.get(fullEventName); 7801 const onceListeners = targetInfo && targetInfo.onceMap.get(fullEventName); 7802 if (listeners) { 7803 listeners.delete(listener); 7804 } 7805 if (onceListeners) { 7806 const once = onceListeners.get(listener); 7807 if (once) { 7808 onceListeners.delete(listener); 7809 listeners.delete(once); 7810 } 7811 } 7812 } 7813 }, { 7814 key: "unsubscribeAll", 7815 value: function unsubscribeAll(target, eventName, options) { 7816 if (Type.isString(target)) { 7817 eventName = target; 7818 target = this.GLOBAL_TARGET;
7819 } 7820 if (Type.isStringFilled(eventName)) { 7821 const targetInfo = eventStore.get(target); 7822 if (targetInfo) { 7823 options = Type.isPlainObject(options) ? options : {}; 7824 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7825 targetInfo.eventsMap.delete(fullEventName); 7826 targetInfo.onceMap.delete(fullEventName); 7827 } 7828 } else if (Type.isNil(eventName)) { 7829 if (target === this.GLOBAL_TARGET) { 7830 console.error('You cannot unsubscribe all global listeners.'); 7831 } else { 7832 eventStore.delete(target); 7833 } 7834 } 7835 } 7836 }, { 7837 key: "emit", 7838 value: function emit(target, eventName, event, options) { 7839 if (Type.isString(target)) { 7840 options = event; 7841 event = eventName; 7842 eventName = target; 7843 target = this.GLOBAL_TARGET; 7844 } 7845 if (!Type.isObject(target)) { 7846 throw new TypeError(`The "target" argument must be an object.`); 7847 } 7848 eventName = this.normalizeEventName(eventName); 7849 if (!Type.isStringFilled(eventName)) { 7850 throw new TypeError(`The "eventName" argument must be a string.`); 7851 } 7852 options = Type.isPlainObject(options) ? options : {}; 7853 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7854 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 7855 const globalListeners = globalEvents && globalEvents.eventsMap.get(fullEventName) || new Map(); 7856 let targetListeners = new Set(); 7857 if (target !== this.GLOBAL_TARGET) { 7858 const targetEvents = eventStore.get(target); 7859 targetListeners = targetEvents && targetEvents.eventsMap.get(fullEventName) || new Map(); 7860 } 7861 const listeners = [...globalListeners.values(), ...targetListeners.values()]; 7862 listeners.sort(function (a, b) { 7863 return a.sort - b.sort; 7864 }); 7865 const preparedEvent = this.prepareEvent(target, fullEventName, event); 7866 const result = []; 7867 for (let i = 0; i < listeners.length; i++) { 7868 if (preparedEvent.isImmediatePropagationStopped()) { 7869 break; 7870 } 7871 const { 7872 listener, 7873 options: listenerOptions 7874 } = listeners[i]; 7875 7876 //A previous listener could remove a current listener. 7877 if (globalListeners.has(listener) || targetListeners.has(listener)) { 7878 let listenerResult; 7879 if (listenerOptions.compatMode) { 7880 let params = []; 7881 const compatData = preparedEvent.getCompatData(); 7882 if (compatData !== null) { 7883 params = options.cloneData === true ? Runtime.clone(compatData) : compatData; 7884 } else { 7885 params = [preparedEvent]; 7886 } 7887 const context = Type.isUndefined(options.thisArg) ? target : options.thisArg; 7888 listenerResult = listener.apply(context, params); 7889 } else { 7890 listenerResult = Type.isUndefined(options.thisArg) ? listener(preparedEvent) : listener.call(options.thisArg, preparedEvent); 7891 } 7892 result.push(listenerResult); 7893 } 7894 } 7895 return result; 7896 } 7897 }, { 7898 key: "emitAsync", 7899 value: function emitAsync(target, eventName, event) { 7900 if (Type.isString(target)) { 7901 event = eventName; 7902 eventName = target; 7903 target = this.GLOBAL_TARGET;
7904 } 7905 return Promise.all(this.emit(target, eventName, event)); 7906 } 7907 }, { 7908 key: "prepareEvent", 7909 value: function prepareEvent(target, eventName, event) { 7910 let preparedEvent = event; 7911 if (!(event instanceof BaseEvent)) { 7912 preparedEvent = new BaseEvent(); 7913 preparedEvent.setData(event); 7914 } 7915 preparedEvent.setTarget(this.isEventEmitter(target) ? target[targetProperty] : target); 7916 preparedEvent.setType(eventName); 7917 return preparedEvent; 7918 } 7919 /** 7920 * @private 7921 * @returns {number} 7922 */ 7923 }, { 7924 key: "getNextSequenceValue", 7925 value: function getNextSequenceValue() { 7926 return this.sequenceValue++; 7927 } 7928 /** 7929 * Sets max global events listeners count 7930 * Event.EventEmitter.setMaxListeners(10) - sets the default value for all events (global target) 7931 * Event.EventEmitter.setMaxListeners("onClose", 10) - sets the value for onClose event (global target) 7932 * Event.EventEmitter.setMaxListeners(obj, 10) - sets the default value for all events (obj target) 7933 * Event.EventEmitter.setMaxListeners(obj, "onClose", 10); - sets the value for onClose event (obj target) 7934 * @return {void} 7935 * @param args 7936 */ 7937 }, { 7938 key: "setMaxListeners", 7939 value: function setMaxListeners(...args) { 7940 let target = this.GLOBAL_TARGET;
7941 let eventName = null; 7942 let count = undefined; 7943 if (args.length === 1) { 7944 count = args[0]; 7945 } else if (args.length === 2) { 7946 if (Type.isString(args[0])) { 7947 [eventName, count] = args; 7948 } else { 7949 [target, count] = args; 7950 } 7951 } else if (args.length >= 3) { 7952 [target, eventName, count] = args; 7953 } 7954 if (!Type.isObject(target)) { 7955 throw new TypeError(`The "target" argument must be an object.`); 7956 } 7957 if (eventName !== null && !Type.isStringFilled(eventName)) { 7958 throw new TypeError(`The "eventName" argument must be a string.`); 7959 } 7960 if (!Type.isNumber(count) || count < 0) { 7961 throw new TypeError(`The value of "count" is out of range. It must be a non-negative number. Received ${count}.`); 7962 } 7963 const targetInfo = eventStore.getOrAdd(target); 7964 if (Type.isStringFilled(eventName)) { 7965 const fullEventName = this.resolveEventName(eventName, target); 7966 targetInfo.eventsMaxListeners.set(fullEventName, count); 7967 } else { 7968 targetInfo.maxListeners = count; 7969 } 7970 } 7971 }, { 7972 key: "getMaxListeners", 7973 value: function getMaxListeners(target, eventName) { 7974 if (Type.isString(target)) { 7975 eventName = target; 7976 target = this.GLOBAL_TARGET;
7977 } else if (Type.isNil(target)) { 7978 target = this.GLOBAL_TARGET; 7979 } 7980 if (!Type.isObject(target)) { 7981 throw new TypeError(`The "target" argument must be an object.`); 7982 } 7983 const targetInfo = eventStore.get(target); 7984 if (targetInfo) { 7985 let maxListeners = targetInfo.maxListeners; 7986 if (Type.isStringFilled(eventName)) { 7987 const fullEventName = this.resolveEventName(eventName, target); 7988 maxListeners = targetInfo.eventsMaxListeners.get(fullEventName) || maxListeners; 7989 } 7990 return maxListeners; 7991 } 7992 return this.DEFAULT_MAX_LISTENERS; 7993 } 7994 }, { 7995 key: "addMaxListeners", 7996 value: function addMaxListeners(...args) { 7997 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 7998 const maxListeners = Math.max(this.getMaxListeners(target, eventName) + increment, 0); 7999 if (Type.isStringFilled(eventName)) { 8000 EventEmitter.setMaxListeners(target, eventName, maxListeners); 8001 } else { 8002 EventEmitter.setMaxListeners(target, maxListeners); 8003 } 8004 return maxListeners; 8005 } 8006 /** 8007 * Increases max listeners count 8008 * 8009 * Event.EventEmitter.incrementMaxListeners() - adds one max listener for all events of global target 8010 * Event.EventEmitter.incrementMaxListeners(3) - adds three max listeners for all events of global target 8011 * Event.EventEmitter.incrementMaxListeners('onClose') - adds one max listener for onClose event of global target 8012 * Event.EventEmitter.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 8013 * 8014 * Event.EventEmitter.incrementMaxListeners(obj) - adds one max listener for all events of 'obj' target 8015 * Event.EventEmitter.incrementMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 8016 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 8017 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 8018 */ 8019 }, { 8020 key: "incrementMaxListeners", 8021 value: function incrementMaxListeners(...args) { 8022 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 8023 return this.addMaxListeners(target, eventName, Math.abs(increment)); 8024 } 8025 }, { 8026 key: "decrementMaxListeners", 8027 value: function decrementMaxListeners(...args) { 8028 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 8029 return this.addMaxListeners(target, eventName, -Math.abs(increment)); 8030 } 8031 }, { 8032 key: "destructMaxListenersArgs", 8033 value: function destructMaxListenersArgs(...args) { 8034 let eventName = null; 8035 let increment = 1; 8036 let target = this.GLOBAL_TARGET;
8037 if (args.length === 1) { 8038 if (Type.isNumber(args[0])) { 8039 increment = args[0]; 8040 } else if (Type.isString(args[0])) { 8041 eventName = args[0]; 8042 } else { 8043 target = args[0]; 8044 } 8045 } else if (args.length === 2) { 8046 if (Type.isString(args[0])) { 8047 [eventName, increment] = args; 8048 } else if (Type.isString(args[1])) { 8049 [target, eventName] = args; 8050 } else { 8051 [target, increment] = args; 8052 } 8053 } else if (args.length >= 3) { 8054 [target, eventName, increment] = args; 8055 } 8056 if (!Type.isObject(target)) { 8057 throw new TypeError(`The "target" argument must be an object.`); 8058 } 8059 if (eventName !== null && !Type.isStringFilled(eventName)) { 8060 throw new TypeError(`The "eventName" argument must be a string.`); 8061 } 8062 if (!Type.isNumber(increment)) { 8063 throw new TypeError(`The value of "increment" must be a number.`); 8064 } 8065 return [target, eventName, increment]; 8066 } 8067 /** 8068 * Gets listeners list for a specified event 8069 * @param {object} target 8070 * @param {string} eventName 8071 */ 8072 }, { 8073 key: "getListeners", 8074 value: function getListeners(target, eventName) { 8075 if (Type.isString(target)) { 8076 eventName = target; 8077 target = this.GLOBAL_TARGET;
8078 } 8079 if (!Type.isObject(target)) { 8080 throw new TypeError(`The "target" argument must be an object.`); 8081 } 8082 eventName = this.normalizeEventName(eventName); 8083 if (!Type.isStringFilled(eventName)) { 8084 throw new TypeError(`The "eventName" argument must be a string.`); 8085 } 8086 const targetInfo = eventStore.get(target); 8087 if (!targetInfo) { 8088 return new Map(); 8089 } 8090 const fullEventName = this.resolveEventName(eventName, target); 8091 return targetInfo.eventsMap.get(fullEventName) || new Map(); 8092 } 8093 }, { 8094 key: "registerAliases", 8095 value: function registerAliases(aliases) { 8096 aliases = this.normalizeAliases(aliases); 8097 Object.keys(aliases).forEach(alias => { 8098 aliasStore.set(alias, { 8099 eventName: aliases[alias].eventName, 8100 namespace: aliases[alias].namespace 8101 }); 8102 }); 8103 EventEmitter.mergeEventAliases(aliases); 8104 } 8105 /** 8106 * @private 8107 * @param aliases 8108 */ 8109 }, { 8110 key: "normalizeAliases", 8111 value: function normalizeAliases(aliases) { 8112 if (!Type.isPlainObject(aliases)) { 8113 throw new TypeError(`The "aliases" argument must be an object.`); 8114 } 8115 const result = Object.create(null); 8116 for (let alias in aliases) { 8117 if (!Type.isStringFilled(alias)) { 8118 throw new TypeError(`The alias must be an non-empty string.`); 8119 } 8120 const options = aliases[alias]; 8121 if (!options || !Type.isStringFilled(options.eventName) || !Type.isStringFilled(options.namespace)) { 8122 throw new TypeError(`The alias options must set the "eventName" and the "namespace".`); 8123 } 8124 alias = this.normalizeEventName(alias); 8125 result[alias] = { 8126 eventName: options.eventName, 8127 namespace: options.namespace 8128 }; 8129 } 8130 return result; 8131 } 8132 /** 8133 * @private 8134 */ 8135 }, { 8136 key: "mergeEventAliases", 8137 value: function mergeEventAliases(aliases) { 8138 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 8139 if (!globalEvents) { 8140 return; 8141 } 8142 Object.keys(aliases).forEach(alias => { 8143 const options = aliases[alias]; 8144 alias = this.normalizeEventName(alias); 8145 const fullEventName = this.makeFullEventName(options.namespace, options.eventName); 8146 const aliasListeners = globalEvents.eventsMap.get(alias); 8147 if (aliasListeners) { 8148 const listeners = globalEvents.eventsMap.get(fullEventName) || new Map(); 8149 globalEvents.eventsMap.set(fullEventName, new Map([...listeners, ...aliasListeners])); 8150 globalEvents.eventsMap.delete(alias); 8151 } 8152 const aliasOnceListeners = globalEvents.onceMap.get(alias); 8153 if (aliasOnceListeners) { 8154 const onceListeners = globalEvents.onceMap.get(fullEventName) || new Map(); 8155 globalEvents.onceMap.set(fullEventName, new Map([...onceListeners, ...aliasOnceListeners])); 8156 globalEvents.onceMap.delete(alias); 8157 } 8158 const aliasMaxListeners = globalEvents.eventsMaxListeners.get(alias); 8159 if (aliasMaxListeners) { 8160 const eventMaxListeners = globalEvents.eventsMaxListeners.get(fullEventName) || 0; 8161 globalEvents.eventsMaxListeners.set(fullEventName, Math.max(eventMaxListeners, aliasMaxListeners)); 8162 globalEvents.eventsMaxListeners.delete(alias); 8163 } 8164 }); 8165 } 8166 /** 8167 * Returns true if the target is an instance of Event.EventEmitter 8168 * @param {object} target 8169 * @returns {boolean} 8170 */ 8171 }, { 8172 key: "isEventEmitter", 8173 value: function isEventEmitter(target) { 8174 return Type.isObject(target) && target[isEmitterProperty] === true; 8175 } 8176 /** 8177 * @private 8178 * @param {string} eventName 8179 * @returns {string} 8180 */ 8181 }, { 8182 key: "normalizeEventName", 8183 value: function normalizeEventName(eventName) { 8184 if (!Type.isStringFilled(eventName)) { 8185 return ''; 8186 } 8187 return eventName.toLowerCase(); 8188 } 8189 /** 8190 * @private 8191 */ 8192 }, { 8193 key: "normalizeListener", 8194 value: function normalizeListener(listener) { 8195 if (Type.isString(listener)) { 8196 listener = Reflection.getClass(listener); 8197 } 8198 if (!Type.isFunction(listener)) { 8199 throw new TypeError(`The "listener" argument must be of type Function. Received type ${typeof listener}.`); 8200 } 8201 return listener; 8202 } 8203 /** 8204 * @private 8205 * @param eventName 8206 * @param target 8207 * @param useGlobalNaming 8208 * @returns {string} 8209 */ 8210 }, { 8211 key: "resolveEventName", 8212 value: function resolveEventName(eventName, target, useGlobalNaming = false) { 8213 eventName = this.normalizeEventName(eventName); 8214 if (!Type.isStringFilled(eventName)) { 8215 return ''; 8216 } 8217 if (this.isEventEmitter(target) && useGlobalNaming !== true) { 8218 if (target.getEventNamespace() !== null && eventName.includes('.')) { 8219 console.warn(`Possible the wrong event name "${eventName}".`); 8220 } 8221 eventName = target.getFullEventName(eventName); 8222 } else if (aliasStore.has(eventName)) { 8223 const { 8224 namespace, 8225 eventName: actualEventName 8226 } = aliasStore.get(eventName); 8227 eventName = this.makeFullEventName(namespace, actualEventName); 8228 } 8229 return eventName; 8230 } 8231 /** 8232 * @private 8233 * @param {string} namespace 8234 * @param {string} eventName 8235 * @returns {string} 8236 */ 8237 }, { 8238 key: "makeFullEventName", 8239 value: function makeFullEventName(namespace, eventName) { 8240 const fullName = Type.isStringFilled(namespace) ? `${namespace}:${eventName}` : eventName; 8241 return Type.isStringFilled(fullName) ? fullName.toLowerCase() : ''; 8242 } 8243 }]); 8244 return EventEmitter; 8245 }(); 8246 babelHelpers.defineProperty(EventEmitter, "GLOBAL_TARGET", globalTarget); 8247 babelHelpers.defineProperty(EventEmitter, "DEFAULT_MAX_LISTENERS", eventStore.getDefaultMaxListeners()); 8248 babelHelpers.defineProperty(EventEmitter, "sequenceValue", 1); 8249 8250 let stack = []; 8251 /** 8252 * For compatibility only 8253 * @type {boolean} 8254 */ 8255 // eslint-disable-next-line 8256 exports.isReady = false;
8257 function ready(handler) { 8258 if (!Type.isFunction(handler)) { 8259 return; 8260 } 8261 if (exports.isReady) { 8262 handler(); 8263 } else { 8264 stack.push(handler); 8265 } 8266 } 8267 bindOnce(document, 'DOMContentLoaded', () => { 8268 exports.isReady = true; 8269 stack.forEach(handler => { 8270 handler(); 8271 }); 8272 stack = []; 8273 }); 8274 8275 /** 8276 * @memberOf BX 8277 */ 8278 let Event = function Event() { 8279 babelHelpers.classCallCheck(this, Event); 8280 }; 8281 babelHelpers.defineProperty(Event, "bind", bind); 8282 babelHelpers.defineProperty(Event, "bindOnce", bindOnce); 8283 babelHelpers.defineProperty(Event, "unbind", unbind); 8284 babelHelpers.defineProperty(Event, "unbindAll", unbindAll); 8285 babelHelpers.defineProperty(Event, "ready", ready); 8286 babelHelpers.defineProperty(Event, "EventEmitter", EventEmitter); 8287 babelHelpers.defineProperty(Event, "BaseEvent", BaseEvent); 8288 8289 function encodeAttributeValue(value) { 8290 if (Type.isPlainObject(value) || Type.isArray(value)) { 8291 return JSON.stringify(value); 8292 } 8293 return Text.encode(Text.decode(value)); 8294 } 8295 8296 function decodeAttributeValue(value) { 8297 if (Type.isString(value)) { 8298 const decodedValue = Text.decode(value); 8299 let result; 8300 try { 8301 result = JSON.parse(decodedValue); 8302 } catch (e) { 8303 result = decodedValue; 8304 } 8305 if (result === decodedValue) { 8306 if (/^[\d.]+[.]?\d+$/.test(result)) { 8307 return Number(result); 8308 } 8309 } 8310 if (result === 'true' || result === 'false') { 8311 return Boolean(result); 8312 } 8313 return result; 8314 } 8315 return value; 8316 } 8317 8318 function getPageScroll() { 8319 const { 8320 documentElement, 8321 body 8322 } = document; 8323 const scrollTop = Math.max(window.pageYOffset || 0, documentElement ? documentElement.scrollTop : 0, body ? body.scrollTop : 0); 8324 const scrollLeft = Math.max(window.pageXOffset || 0, documentElement ? documentElement.scrollLeft : 0, body ? body.scrollLeft : 0); 8325 return { 8326 scrollTop, 8327 scrollLeft 8328 }; 8329 } 8330 8331 /** 8332 * @memberOf BX 8333 */ 8334 let Dom = /*#__PURE__*/function () { 8335 function Dom() { 8336 babelHelpers.classCallCheck(this, Dom); 8337 } 8338 babelHelpers.createClass(Dom, null, [{ 8339 key: "replace", 8340 /** 8341 * Replaces old html element to new html element 8342 * @param oldElement 8343 * @param newElement 8344 */ 8345 value: function replace(oldElement, newElement) { 8346 if (Type.isDomNode(oldElement) && Type.isDomNode(newElement)) { 8347 if (Type.isDomNode(oldElement.parentNode)) { 8348 oldElement.parentNode.replaceChild(newElement, oldElement); 8349 } 8350 } 8351 } 8352 /** 8353 * Removes element 8354 * @param element 8355 */ 8356 }, { 8357 key: "remove", 8358 value: function remove(element) { 8359 if (Type.isDomNode(element) && Type.isDomNode(element.parentNode)) { 8360 element.parentNode.removeChild(element); 8361 } 8362 } 8363 /** 8364 * Cleans element 8365 * @param element 8366 */ 8367 }, { 8368 key: "clean", 8369 value: function clean(element) { 8370 if (Type.isDomNode(element)) { 8371 while (element.childNodes.length > 0) { 8372 element.removeChild(element.firstChild); 8373 } 8374 return; 8375 } 8376 if (Type.isString(element)) { 8377 Dom.clean(document.getElementById(element)); 8378 } 8379 } 8380 /** 8381 * Inserts element before target element 8382 * @param current 8383 * @param target 8384 */ 8385 }, { 8386 key: "insertBefore", 8387 value: function insertBefore(current, target) { 8388 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8389 if (Type.isDomNode(target.parentNode)) { 8390 target.parentNode.insertBefore(current, target); 8391 } 8392 } 8393 } 8394 /** 8395 * Inserts element after target element 8396 * @param current 8397 * @param target 8398 */ 8399 }, { 8400 key: "insertAfter", 8401 value: function insertAfter(current, target) { 8402 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8403 if (Type.isDomNode(target.parentNode)) { 8404 const parent = target.parentNode; 8405 if (Type.isDomNode(target.nextSibling)) { 8406 parent.insertBefore(current, target.nextSibling); 8407 return; 8408 } 8409 parent.appendChild(current); 8410 } 8411 } 8412 } 8413 /** 8414 * Appends element to target element 8415 * @param current 8416 * @param target 8417 */ 8418 }, { 8419 key: "append", 8420 value: function append(current, target) { 8421 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8422 target.appendChild(current); 8423 } 8424 } 8425 /** 8426 * Prepends element to target element 8427 * @param current 8428 * @param target 8429 */ 8430 }, {
8431 key: "prepend", 8432 value: function prepend(current, target) { 8433 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8434 if (Type.isDomNode(target.firstChild)) { 8435 target.insertBefore(current, target.firstChild); 8436 return; 8437 } 8438 Dom.append(current, target); 8439 } 8440 } 8441 /** 8442 * Checks that element contains class name or class names 8443 * @param element 8444 * @param className 8445 * @return {Boolean} 8446 */ 8447 }, { 8448 key: "hasClass", 8449 value: function hasClass(element, className) { 8450 if (Type.isElementNode(element)) { 8451 if (Type.isString(className)) { 8452 const preparedClassName = className.trim(); 8453 if (preparedClassName.length > 0) { 8454 if (preparedClassName.includes(' ')) { 8455 return preparedClassName.split(' ').every(name => Dom.hasClass(element, name)); 8456 } 8457 if ('classList' in element) { 8458 return element.classList.contains(preparedClassName); 8459 } 8460 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8461 return element.getAttribute('class').split(' ').some(name => name === preparedClassName); 8462 } 8463 } 8464 } 8465 if (Type.isArray(className) && className.length > 0) { 8466 return className.every(name => Dom.hasClass(element, name)); 8467 } 8468 } 8469 return false; 8470 } 8471 /** 8472 * Adds class name 8473 * @param element 8474 * @param className 8475 */ 8476 }, { 8477 key: "addClass", 8478 value: function addClass(element, className) { 8479 if (Type.isElementNode(element)) { 8480 if (Type.isString(className)) { 8481 const preparedClassName = className.trim(); 8482 if (preparedClassName.length > 0) { 8483 if (preparedClassName.includes(' ')) { 8484 Dom.addClass(element, preparedClassName.split(' ')); 8485 return; 8486 } 8487 if ('classList' in element) { 8488 element.classList.add(preparedClassName); 8489 return; 8490 } 8491 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8492 if (element.className.baseVal === '') { 8493 element.className.baseVal = preparedClassName; 8494 return; 8495 } 8496 const names = element.className.baseVal.split(' '); 8497 if (!names.includes(preparedClassName)) { 8498 names.push(preparedClassName); 8499 element.className.baseVal = names.join(' ').trim(); 8500 return; 8501 } 8502 } 8503 return; 8504 } 8505 } 8506 if (Type.isArray(className)) { 8507 className.forEach(name => Dom.addClass(element, name)); 8508 } 8509 } 8510 } 8511 /** 8512 * Removes class name 8513 * @param element 8514 * @param className 8515 */ 8516 }, { 8517 key: "removeClass", 8518 value: function removeClass(element, className) { 8519 if (Type.isElementNode(element)) { 8520 if (Type.isString(className)) { 8521 const preparedClassName = className.trim(); 8522 if (preparedClassName.length > 0) { 8523 if (preparedClassName.includes(' ')) { 8524 Dom.removeClass(element, preparedClassName.split(' ')); 8525 return; 8526 } 8527 if ('classList' in element) { 8528 element.classList.remove(preparedClassName); 8529 return; 8530 } 8531 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8532 const names = element.className.baseVal.split(' ').filter(name => name !== preparedClassName); 8533 element.className.baseVal = names.join(' '); 8534 return; 8535 } 8536 } 8537 } 8538 if (Type.isArray(className)) { 8539 className.forEach(name => Dom.removeClass(element, name)); 8540 } 8541 } 8542 } 8543 /** 8544 * Toggles class name 8545 * @param element 8546 * @param className 8547 */ 8548 }, { 8549 key: "toggleClass", 8550 value: function toggleClass(element, className) { 8551 if (Type.isElementNode(element)) { 8552 if (Type.isString(className)) { 8553 const preparedClassName = className.trim(); 8554 if (preparedClassName.length > 0) { 8555 if (preparedClassName.includes(' ')) { 8556 Dom.toggleClass(element, preparedClassName.split(' ')); 8557 return; 8558 } 8559 element.classList.toggle(preparedClassName); 8560 return; 8561 } 8562 } 8563 if (Type.isArray(className)) { 8564 className.forEach(name => Dom.toggleClass(element, name)); 8565 } 8566 } 8567 } 8568 /** 8569 * Styles element 8570 */ 8571 }, { 8572 key: "style", 8573 value: function style(element, prop, value) { 8574 if (Type.isElementNode(element)) { 8575 if (Type.isNull(prop)) { 8576 element.removeAttribute('style'); 8577 return element; 8578 } 8579 if (Type.isPlainObject(prop)) {
8580 Object.entries(prop).forEach(item => { 8581 const [currentKey, currentValue] = item; 8582 Dom.style(element, currentKey, currentValue); 8583 }); 8584 return element; 8585 } 8586 if (Type.isString(prop)) { 8587 if (Type.isUndefined(value) && element.nodeType !== Node.DOCUMENT_NODE) { 8588 const computedStyle = getComputedStyle(element); 8589 if (prop in computedStyle) { 8590 return computedStyle[prop]; 8591 } 8592 return computedStyle.getPropertyValue(prop); 8593 } 8594 if (Type.isNull(value) || value === '' || value === 'null') { 8595 if (String(prop).startsWith('--')) { 8596 // eslint-disable-next-line 8597 element.style.removeProperty(prop); 8598 return element; 8599 } 8600 8601 // eslint-disable-next-line 8602 element.style[prop] = ''; 8603 return element; 8604 } 8605 if (Type.isString(value) || Type.isNumber(value)) { 8606 if (String(prop).startsWith('--')) { 8607 // eslint-disable-next-line 8608 element.style.setProperty(prop, value); 8609 return element; 8610 } 8611 8612 // eslint-disable-next-line 8613 element.style[prop] = value; 8614 return element; 8615 } 8616 } 8617 } 8618 return null; 8619 } 8620 /** 8621 * Adjusts element 8622 * @param target 8623 * @param data 8624 * @return {*} 8625 */ 8626 }, { 8627 key: "adjust", 8628 value: function adjust(target, data = {}) { 8629 if (!target.nodeType) { 8630 return null; 8631 } 8632 let element = target; 8633 if (target.nodeType === Node.DOCUMENT_NODE) { 8634 element = target.body; 8635 } 8636 if (Type.isPlainObject(data)) { 8637 if (Type.isPlainObject(data.attrs)) { 8638 Object.keys(data.attrs).forEach(key => { 8639 if (key === 'class' || key.toLowerCase() === 'classname') { 8640 element.className = data.attrs[key]; 8641 return; 8642 } 8643 8644 // eslint-disable-next-line 8645 if (data.attrs[key] == '') { 8646 element.removeAttribute(key); 8647 return; 8648 } 8649 element.setAttribute(key, data.attrs[key]); 8650 }); 8651 } 8652 if (Type.isPlainObject(data.style)) { 8653 Dom.style(element, data.style); 8654 } 8655 if (Type.isPlainObject(data.props)) { 8656 Object.keys(data.props).forEach(key => { 8657 element[key] = data.props[key]; 8658 }); 8659 } 8660 if (Type.isPlainObject(data.events)) { 8661 Object.keys(data.events).forEach(key => { 8662 Event.bind(element, key, data.events[key]); 8663 }); 8664 } 8665 if (Type.isPlainObject(data.dataset)) { 8666 Object.keys(data.dataset).forEach(key => { 8667 element.dataset[key] = data.dataset[key]; 8668 }); 8669 } 8670 if (Type.isString(data.children)) { 8671 data.children = [data.children]; 8672 } 8673 if (Type.isArray(data.children) && data.children.length > 0) { 8674 data.children.forEach(item => { 8675 if (Type.isDomNode(item)) { 8676 Dom.append(item, element); 8677 } 8678 if (Type.isString(item)) { 8679 element.insertAdjacentHTML('beforeend', item); 8680 } 8681 }); 8682 return element; 8683 } 8684 if ('text' in data && !Type.isNil(data.text)) { 8685 element.textContent = data.text; 8686 return element; 8687 } 8688 if ('html' in data && !Type.isNil(data.html)) { 8689 element.innerHTML = data.html; 8690 } 8691 } 8692 return element; 8693 } 8694 /** 8695 * Creates element 8696 * @param tag 8697 * @param data 8698 * @param context 8699 * @return {HTMLElement|HTMLBodyElement} 8700 */ 8701 }, { 8702 key: "create", 8703 value: function create(tag, data = {}, context = document) { 8704 let tagName = tag; 8705 let options = data; 8706 if (Type.isObjectLike(tag)) { 8707 options = tag; 8708 tagName = tag.tag; 8709 } 8710 return Dom.adjust(context.createElement(tagName), options); 8711 } 8712 /** 8713 * Shows element 8714 * @param element 8715 */ 8716 }, { 8717 key: "show", 8718 value: function show(element) { 8719 if (Type.isDomNode(element)) { 8720 // eslint-disable-next-line 8721 element.hidden = false;
8722 } 8723 } 8724 /** 8725 * Hides element 8726 * @param element 8727 */ 8728 }, { 8729 key: "hide", 8730 value: function hide(element) { 8731 if (Type.isDomNode(element)) { 8732 // eslint-disable-next-line 8733 element.hidden = true; 8734 } 8735 } 8736 /** 8737 * Checks that element is shown 8738 * @param element 8739 * @return {*|boolean} 8740 */ 8741 }, { 8742 key: "isShown", 8743 value: function isShown(element) { 8744 return Type.isDomNode(element) && !element.hidden && element.style.getPropertyValue('display') !== 'none'; 8745 } 8746 /** 8747 * Toggles element visibility 8748 * @param element 8749 */ 8750 }, { 8751 key: "toggle", 8752 value: function toggle(element) { 8753 if (Type.isDomNode(element)) { 8754 if (Dom.isShown(element)) { 8755 Dom.hide(element); 8756 } else { 8757 Dom.show(element); 8758 } 8759 } 8760 } 8761 /** 8762 * Gets element position relative page 8763 * @param {HTMLElement} element 8764 * @return {DOMRect} 8765 */ 8766 }, { 8767 key: "getPosition", 8768 value: function getPosition(element) { 8769 if (Type.isDomNode(element)) { 8770 const elementRect = element.getBoundingClientRect(); 8771 const { 8772 scrollLeft, 8773 scrollTop 8774 } = getPageScroll(); 8775 return new DOMRect(elementRect.left + scrollLeft, elementRect.top + scrollTop, elementRect.width, elementRect.height); 8776 } 8777 return new DOMRect(); 8778 } 8779 /** 8780 * Gets element position relative specified element position 8781 * @param {HTMLElement} element 8782 * @param {HTMLElement} relationElement 8783 * @return {DOMRect} 8784 */ 8785 }, { 8786 key: "getRelativePosition", 8787 value: function getRelativePosition(element, relationElement) { 8788 if (Type.isDomNode(element) && Type.isDomNode(relationElement)) { 8789 const elementPosition = Dom.getPosition(element); 8790 const relationElementPosition = Dom.getPosition(relationElement); 8791 return new DOMRect(elementPosition.left - relationElementPosition.left, elementPosition.top - relationElementPosition.top, elementPosition.width, elementPosition.height); 8792 } 8793 return new DOMRect(); 8794 } 8795 }, { 8796 key: "attr", 8797 value: function attr(element, _attr, value) { 8798 if (Type.isElementNode(element)) { 8799 if (Type.isString(_attr)) { 8800 if (!Type.isNil(value)) { 8801 return element.setAttribute(_attr, encodeAttributeValue(value)); 8802 } 8803 if (Type.isNull(value)) { 8804 return element.removeAttribute(_attr); 8805 } 8806 return decodeAttributeValue(element.getAttribute(_attr)); 8807 } 8808 if (Type.isPlainObject(_attr)) { 8809 return Object.entries(_attr).forEach(([attrKey, attrValue]) => { 8810 Dom.attr(element, attrKey, attrValue); 8811 }); 8812 } 8813 } 8814 return null; 8815 } 8816 }]); 8817 return Dom; 8818 }(); 8819 8820 const UA = navigator.userAgent.toLowerCase(); 8821 8822 /** 8823 * @memberOf BX 8824 */ 8825 let Browser = /*#__PURE__*/function () { 8826 function Browser() { 8827 babelHelpers.classCallCheck(this, Browser); 8828 } 8829 babelHelpers.createClass(Browser, null, [{ 8830 key: "isOpera", 8831 value: function isOpera() { 8832 return UA.includes('opera'); 8833 } 8834 }, { 8835 key: "isIE", 8836 value: function isIE() { 8837 return 'attachEvent' in document && !Browser.isOpera(); 8838 } 8839 }, { 8840 key: "isIE6", 8841 value: function isIE6() { 8842 return UA.includes('msie 6'); 8843 } 8844 }, { 8845 key: "isIE7", 8846 value: function isIE7() { 8847 return UA.includes('msie 7'); 8848 } 8849 }, { 8850 key: "isIE8", 8851 value: function isIE8() { 8852 return UA.includes('msie 8'); 8853 } 8854 }, { 8855 key: "isIE9", 8856 value: function isIE9() { 8857 return 'documentMode' in document && document.documentMode >= 9; 8858 } 8859 }, { 8860 key: "isIE10", 8861 value: function isIE10() { 8862 return 'documentMode' in document && document.documentMode >= 10; 8863 } 8864 }, { 8865 key: "isSafari", 8866 value: function isSafari() { 8867 return UA.includes('safari') && !UA.includes('chrome'); 8868 } 8869 }, { 8870 key: "isFirefox", 8871 value: function isFirefox() { 8872 return UA.includes('firefox'); 8873 } 8874 }, { 8875 key: "isChrome", 8876 value: function isChrome() { 8877 return UA.includes('chrome'); 8878 } 8879 }, { 8880 key: "detectIEVersion", 8881 value: function detectIEVersion() { 8882 if (Browser.isOpera() || Browser.isSafari() || Browser.isFirefox() || Browser.isChrome()) { 8883 return -1; 8884 } 8885 let rv = -1; 8886 if (!!window.MSStream && !window.ActiveXObject && 'ActiveXObject' in window) { 8887 rv = 11; 8888 } else if (Browser.isIE10()) { 8889 rv = 10; 8890 } else if (Browser.isIE9()) { 8891 rv = 9; 8892 } else if (Browser.isIE()) { 8893 rv = 8; 8894 } 8895 if (rv === -1 || rv === 8) { 8896 if (navigator.appName === 'Microsoft Internet Explorer') { 8897 const re = new RegExp('MSIE ([0-9]+[.0-9]*)'); 8898 const res = navigator.userAgent.match(re); 8899 if (Type.isArrayLike(res) && res.length > 0) { 8900 rv = parseFloat(res[1]); 8901 } 8902 } 8903 if (navigator.appName === 'Netscape') { 8904 // Alternative check for IE 11 8905 rv = 11; 8906 const re = new RegExp('Trident/.*rv:([0-9]+[.0-9]*)'); 8907 if (re.exec(navigator.userAgent) != null) { 8908 const res = navigator.userAgent.match(re); 8909 if (Type.isArrayLike(res) && res.length > 0) { 8910 rv = parseFloat(res[1]); 8911 } 8912 } 8913 } 8914 } 8915 return rv; 8916 } 8917 }, { 8918 key: "isIE11", 8919 value: function isIE11() { 8920 return Browser.detectIEVersion() >= 11; 8921 } 8922 }, { 8923 key: "isMac", 8924 value: function isMac() { 8925 return UA.includes('macintosh'); 8926 } 8927 }, { 8928 key: "isWin", 8929 value: function isWin() { 8930 return UA.includes('windows'); 8931 } 8932 }, { 8933 key: "isLinux", 8934 value: function isLinux() { 8935 return UA.includes('linux') && !Browser.isAndroid(); 8936 } 8937 }, { 8938 key: "isAndroid", 8939 value: function isAndroid() { 8940 return UA.includes('android'); 8941 } 8942 }, { 8943 key: "isIPad", 8944 value: function isIPad() { 8945 return UA.includes('ipad;') || this.isMac() && this.isTouchDevice(); 8946 } 8947 }, { 8948 key: "isIPhone", 8949 value: function isIPhone() { 8950 return UA.includes('iphone;'); 8951 } 8952 }, { 8953 key: "isIOS", 8954 value: function isIOS() { 8955 return Browser.isIPad() || Browser.isIPhone(); 8956 } 8957 }, { 8958 key: "isMobile", 8959 value: function isMobile() { 8960 return Browser.isIPhone() || Browser.isIPad() || Browser.isAndroid() || UA.includes('mobile') || UA.includes('touch'); 8961 } 8962 }, { 8963 key: "isRetina", 8964 value: function isRetina() { 8965 return window.devicePixelRatio && window.devicePixelRatio >= 2; 8966 } 8967 }, { 8968 key: "isTouchDevice", 8969 value: function isTouchDevice() { 8970 return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; 8971 } 8972 }, { 8973 key: "isDoctype", 8974 value: function isDoctype(target) { 8975 const doc = target || document; 8976 if (doc.compatMode) { 8977 return doc.compatMode === 'CSS1Compat'; 8978 } 8979 return doc.documentElement && doc.documentElement.clientHeight; 8980 } 8981 }, { 8982 key: "isLocalStorageSupported", 8983 value: function isLocalStorageSupported() { 8984 try { 8985 localStorage.setItem('test', 'test'); 8986 localStorage.removeItem('test'); 8987 return true; 8988 } catch (e) { 8989 return false;
8990 } 8991 } 8992 }, { 8993 key: "addGlobalClass", 8994 value: function addGlobalClass(target) { 8995 let globalClass = 'bx-core'; 8996 target = Type.isElementNode(target) ? target : document.documentElement; 8997 if (Dom.hasClass(target, globalClass)) { 8998 return; 8999 } 9000 if (Browser.isIOS()) { 9001 globalClass += ' bx-ios'; 9002 } else if (Browser.isWin()) { 9003 globalClass += ' bx-win'; 9004 } else if (Browser.isMac()) { 9005 globalClass += ' bx-mac'; 9006 } else if (Browser.isLinux()) { 9007 globalClass += ' bx-linux'; 9008 } else if (Browser.isAndroid()) { 9009 globalClass += ' bx-android'; 9010 } 9011 globalClass += Browser.isMobile() ? ' bx-touch' : ' bx-no-touch'; 9012 globalClass += Browser.isRetina() ? ' bx-retina' : ' bx-no-retina'; 9013 if (/AppleWebKit/.test(navigator.userAgent)) { 9014 globalClass += ' bx-chrome'; 9015 } else if (/Opera/.test(navigator.userAgent)) { 9016 globalClass += ' bx-opera'; 9017 } else if (Browser.isFirefox()) { 9018 globalClass += ' bx-firefox'; 9019 } 9020 Dom.addClass(target, globalClass); 9021 } 9022 }, { 9023 key: "detectAndroidVersion", 9024 value: function detectAndroidVersion() { 9025 const re = new RegExp('Android ([0-9]+[.0-9]*)'); 9026 if (re.exec(navigator.userAgent) != null) { 9027 const res = navigator.userAgent.match(re); 9028 if (Type.isArrayLike(res) && res.length > 0) { 9029 return parseFloat(res[1]); 9030 } 9031 } 9032 return 0; 9033 } 9034 }, { 9035 key: "isPropertySupported", 9036 value: function isPropertySupported(jsProperty, returnCSSName) { 9037 if (jsProperty === '') { 9038 return false; 9039 } 9040 function getCssName(propertyName) { 9041 return propertyName.replace(/([A-Z])/g, (...args) => `-${args[1].toLowerCase()}`); 9042 } 9043 function getJsName(cssName) { 9044 const reg = /(\\-([a-z]))/g; 9045 if (reg.test(cssName)) { 9046 return cssName.replace(reg, (...args) => args[2].toUpperCase()); 9047 } 9048 return cssName; 9049 } 9050 const property = jsProperty.includes('-') ? getJsName(jsProperty) : jsProperty; 9051 const bReturnCSSName = !!returnCSSName; 9052 const ucProperty = property.charAt(0).toUpperCase() + property.slice(1); 9053 const props = ['Webkit', 'Moz', 'O', 'ms'].join(`${ucProperty} `); 9054 const properties = `${property} ${props} ${ucProperty}`.split(' '); 9055 const obj = document.body || document.documentElement; 9056 for (let i = 0; i < properties.length; i += 1) { 9057 const prop = properties[i]; 9058 if (obj && 'style' in obj && prop in obj.style) { 9059 const lowerProp = prop.substr(0, prop.length - property.length).toLowerCase(); 9060 const prefix = prop === property ? '' : `-${lowerProp}-`; 9061 return bReturnCSSName ? prefix + getCssName(property) : prop; 9062 } 9063 } 9064 return false; 9065 } 9066 }, { 9067 key: "addGlobalFeatures", 9068 value: function addGlobalFeatures(features) { 9069 if (!Type.isArray(features)) { 9070 return; 9071 } 9072 const classNames = []; 9073 for (let i = 0; i < features.length; i += 1) { 9074 const support = !!Browser.isPropertySupported(features[i]); 9075 classNames.push(`bx-${support ? '' : 'no-'}${features[i].toLowerCase()}`); 9076 } 9077 Dom.addClass(document.documentElement, classNames.join(' ')); 9078 } 9079 }]); 9080 return Browser; 9081 }(); 9082 9083 let Cookie = /*#__PURE__*/function () { 9084 function Cookie() { 9085 babelHelpers.classCallCheck(this, Cookie); 9086 } 9087 babelHelpers.createClass(Cookie, null, [{ 9088 key: "getList", 9089 /** 9090 * Gets cookies list for current domain 9091 * @return {object} 9092 */ 9093 value: function getList() { 9094 return document.cookie.split(';').map(item => item.split('=')).map(item => item.map(subItem => subItem.trim())).reduce((acc, item) => { 9095 const [key, value] = item; 9096 acc[decodeURIComponent(key)] = decodeURIComponent(value); 9097 return acc; 9098 }, {}); 9099 } 9100 /** 9101 * Gets cookie value 9102 * @param {string} name 9103 * @return {*} 9104 */ 9105 }, { 9106 key: "get", 9107 value: function get(name) { 9108 const cookiesList = Cookie.getList(); 9109 if (name in cookiesList) { 9110 return cookiesList[name]; 9111 } 9112 return undefined; 9113 } 9114 /** 9115 * Sets cookie 9116 * @param {string} name 9117 * @param {*} value 9118 * @param {object} [options] 9119 */ 9120 }, { 9121 key: "set", 9122 value: function set(name, value, options = {}) { 9123 const attributes = { 9124 expires: '', 9125 ...options 9126 }; 9127 if (Type.isNumber(attributes.expires)) { 9128 const now = +new Date(); 9129 const days = attributes.expires; 9130 const dayInMs = 864e+5; 9131 attributes.expires = new Date(now + days * dayInMs); 9132 } 9133 if (Type.isDate(attributes.expires)) { 9134 attributes.expires = attributes.expires.toUTCString(); 9135 } 9136 const safeName = decodeURIComponent(String(name)).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape); 9137 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); 9138 const stringifiedAttributes = Object.keys(attributes).reduce((acc, key) => { 9139 const attributeValue = attributes[key]; 9140 if (!attributeValue) { 9141 return acc; 9142 } 9143 if (attributeValue === true) { 9144 return `${acc}; ${key}`; 9145 } 9146 9147 /** 9148 * Considers RFC 6265 section 5.2: 9149 * ... 9150 * 3. If the remaining unparsed-attributes contains a %x3B (';') 9151 * character: 9152 * Consume the characters of the unparsed-attributes up to, 9153 * not including, the first %x3B (';') character. 9154 */ 9155 return `${acc}; ${key}=${attributeValue.split(';')[0]}`; 9156 }, ''); 9157 document.cookie = `${safeName}=${safeValue}${stringifiedAttributes}`; 9158 } 9159 /** 9160 * Removes cookie 9161 * @param {string} name 9162 * @param {object} [options] 9163 */ 9164 }, { 9165 key: "remove", 9166 value: function remove(name, options = {}) { 9167 Cookie.set(name, '', { 9168 ...options, 9169 expires: -1 9170 }); 9171 } 9172 }]); 9173 return Cookie; 9174 }(); 9175 9176 function objectToFormData(source, formData = new FormData(), pre = null) { 9177 if (Type.isUndefined(source)) { 9178 return formData; 9179 } 9180 if (Type.isNull(source)) { 9181 formData.append(pre, ''); 9182 } else if (Type.isArray(source)) { 9183 if (!source.length) {
9184 const key = `${pre}[]`; 9185 formData.append(key, ''); 9186 } else { 9187 source.forEach((value, index) => { 9188 const key = `${pre}[${index}]`; 9189 objectToFormData(value, formData, key); 9190 }); 9191 } 9192 } else if (Type.isDate(source)) { 9193 formData.append(pre, source.toISOString()); 9194 } else if (Type.isObject(source) && !Type.isFile(source) && !Type.isBlob(source)) { 9195 Object.keys(source).forEach(property => { 9196 const value = source[property]; 9197 let preparedProperty = property; 9198 if (Type.isArray(value)) { 9199 while (preparedProperty.length > 2 && preparedProperty.lastIndexOf('[]') === preparedProperty.length - 2) { 9200 preparedProperty = preparedProperty.substring(0, preparedProperty.length - 2); 9201 } 9202 } 9203 const key = pre ? `${pre}[${preparedProperty}]` : preparedProperty; 9204 objectToFormData(value, formData, key); 9205 }); 9206 } else { 9207 formData.append(pre, source); 9208 } 9209 return formData; 9210 } 9211 9212 let Data = /*#__PURE__*/function () { 9213 function Data() { 9214 babelHelpers.classCallCheck(this, Data); 9215 } 9216 babelHelpers.createClass(Data, null, [{ 9217 key: "convertObjectToFormData", 9218 /** 9219 * Converts object to FormData 9220 * @param source 9221 * @return {FormData} 9222 */ 9223 value: function convertObjectToFormData(source) { 9224 return objectToFormData(source); 9225 } 9226 }]); 9227 return Data; 9228 }(); 9229 9230 /** 9231 * @memberOf BX 9232 */ 9233 let Http = function Http() { 9234 babelHelpers.classCallCheck(this, Http); 9235 }; 9236 babelHelpers.defineProperty(Http, "Cookie", Cookie); 9237 babelHelpers.defineProperty(Http, "Data", Data); 9238 9239 function message(value) { 9240 if (Type.isString(value)) { 9241 if (Type.isNil(message[value])) { 9242 // eslint-disable-next-line 9243 EventEmitter.emit('onBXMessageNotFound', new BaseEvent({ 9244 compatData: [value] 9245 })); 9246 if (Type.isNil(message[value])) { 9247 Runtime.debug(`message undefined: ${value}`); 9248 message[value] = ''; 9249 } 9250 } 9251 } 9252 if (Type.isPlainObject(value)) { 9253 Object.keys(value).forEach(key => { 9254 message[key] = value[key]; 9255 }); 9256 } 9257 return message[value]; 9258 } 9259 if (!Type.isNil(window.BX) && Type.isFunction(window.BX.message)) { 9260 Object.keys(window.BX.message).forEach(key => { 9261 message({ 9262 [key]: window.BX.message[key] 9263 }); 9264 }); 9265 } 9266 9267 /** 9268 * Implements interface for works with language messages 9269 * @memberOf BX 9270 */ 9271 let Loc = /*#__PURE__*/function () { 9272 function Loc() { 9273 babelHelpers.classCallCheck(this, Loc); 9274 } 9275 babelHelpers.createClass(Loc, null, [{ 9276 key: "getMessage", 9277 /** 9278 * Gets message by id 9279 * @param {string} messageId 9280 * @param {object} replacements 9281 * @return {?string} 9282 */ 9283 value: function getMessage(messageId, replacements = null) { 9284 let mess = message(messageId); 9285 if (Type.isString(mess) && Type.isPlainObject(replacements)) { 9286 const escape = str => String(str).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&'); 9287 Object.keys(replacements).forEach(replacement => { 9288 const globalRegexp = new RegExp(escape(replacement), 'gi'); 9289 mess = mess.replace(globalRegexp, () => { 9290 return Type.isNil(replacements[replacement]) ? '' : String(replacements[replacement]); 9291 }); 9292 }); 9293 } 9294 return mess; 9295 } 9296 }, { 9297 key: "hasMessage", 9298 value: function hasMessage(messageId) { 9299 return Type.isString(messageId) && !Type.isNil(message[messageId]); 9300 } 9301 /** 9302 * Sets message or messages 9303 * @param {string | Object<string, string>} id 9304 * @param {string} [value] 9305 */ 9306 }, { 9307 key: "setMessage", 9308 value: function setMessage(id, value) { 9309 if (Type.isString(id) && Type.isString(value)) { 9310 message({ 9311 [id]: value 9312 }); 9313 } 9314 if (Type.isObject(id)) { 9315 message(id); 9316 } 9317 } 9318 /** 9319 * Gets plural message by id and number 9320 * @param {string} messageId 9321 * @param {number} value 9322 * @param {object} [replacements] 9323 * @return {?string} 9324 */ 9325 }, { 9326 key: "getMessagePlural",
9327 value: function getMessagePlural(messageId, value, replacements = null) { 9328 let result = ''; 9329 if (Type.isNumber(value)) { 9330 if (this.hasMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`)) { 9331 result = this.getMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`, replacements); 9332 } else { 9333 result = this.getMessage(`${messageId}_PLURAL_1`, replacements); 9334 } 9335 } else { 9336 result = this.getMessage(messageId, replacements); 9337 } 9338 return result; 9339 } 9340 /** 9341 * Gets language plural form id by number 9342 * see http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html 9343 * @param {number} value 9344 * @param {string} [languageId] 9345 * @return {?number} 9346 */ 9347 }, { 9348 key: "getPluralForm", 9349 value: function getPluralForm(value, languageId) { 9350 let pluralForm; 9351 if (!Type.isStringFilled(languageId)) { 9352 languageId = message('LANGUAGE_ID'); 9353 } 9354 if (value < 0) { 9355 value = -1 * value; 9356 } 9357 switch (languageId) { 9358 case 'ar': 9359 pluralForm = value !== 1 ? 1 : 0; 9360 /* 9361 if (value === 0) 9362 { 9363 pluralForm = 0; 9364 } 9365 else if (value === 1) 9366 { 9367 pluralForm = 1; 9368 } 9369 else if (value === 2) 9370 { 9371 pluralForm = 2; 9372 } 9373 else if ( 9374 value % 100 >= 3 9375 && value % 100 <= 10 9376 ) 9377 { 9378 pluralForm = 3; 9379 } 9380 else if (value % 100 >= 11) 9381 { 9382 pluralForm = 4; 9383 } 9384 else 9385 { 9386 pluralForm = 5; 9387 } 9388 */ 9389 break; 9390 case 'br': 9391 case 'fr': 9392 case 'tr': 9393 pluralForm = value > 1 ? 1 : 0; 9394 break; 9395 case 'de': 9396 case 'en': 9397 case 'hi': 9398 case 'it': 9399 case 'la': 9400 pluralForm = value !== 1 ? 1 : 0; 9401 break; 9402 case 'ru': 9403 case 'ua': 9404 if (value % 10 === 1 && value % 100 !== 11) { 9405 pluralForm = 0; 9406 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9407 pluralForm = 1; 9408 } else { 9409 pluralForm = 2; 9410 } 9411 break; 9412 case 'pl': 9413 if (value === 1) { 9414 pluralForm = 0; 9415 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9416 pluralForm = 1; 9417 } else { 9418 pluralForm = 2; 9419 } 9420 break; 9421 case 'id': 9422 case 'ja': 9423 case 'ms': 9424 case 'sc': 9425 case 'tc': 9426 case 'th': 9427 case 'vn': 9428 pluralForm = 0; 9429 break; 9430 default: 9431 pluralForm = 1; 9432 break; 9433 } 9434 return pluralForm; 9435 } 9436 }]); 9437 return Loc; 9438 }(); 9439 9440 const voidElements = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr']; 9441 function isVoidElement(element) { 9442 return voidElements.includes(element); 9443 } 9444 9445 const matchers = { 9446 tag: /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>|{{uid[0-9]+}}/g, 9447 comment: /<!--(?!<!)[^\[>].*?-->/g, 9448 tagName: /<\/?([^\s]+?)[/\s>]/, 9449 attributes: /\s([\w\-_:.]+)\s?\n?=\s?\n?"([^"]+)?"|\s([\w\-_:.]+)\s?\n?=\s?\n?'([^']+)?'|\s([\w\-_:.]+)/gs, 9450 placeholder: /{{uid[0-9]+}}/g 9451 }; 9452 9453 function parseTag(tag) { 9454 const tagResult = { 9455 type: 'tag', 9456 name: '', 9457 svg: false, 9458 attrs: {}, 9459 children: [], 9460 voidElement: false 9461 }; 9462 if (tag.startsWith('<!--')) { 9463 const endIndex = tag.indexOf('-->'); 9464 const openTagLength = '<!--'.length; 9465 return { 9466 type: 'comment', 9467 content: endIndex !== -1 ? tag.slice(openTagLength, endIndex) : '' 9468 }; 9469 } 9470 const tagNameMatch = tag.match(matchers.tagName); 9471 if (Type.isArrayFilled(tagNameMatch)) { 9472 const [, tagName] = tagNameMatch; 9473 tagResult.name = tagName; 9474 tagResult.svg = tagName === 'svg'; 9475 tagResult.voidElement = isVoidElement(tagName) || tag.trim().endsWith('/>'); 9476 } 9477 const reg = new RegExp(matchers.attributes); 9478 for (;;) { 9479 const result = reg.exec(tag); 9480 if (!Type.isNil(result)) { 9481 // Attributes with double quotes 9482 const [, attrName, attrValue] = result; 9483 if (!Type.isNil(attrName)) { 9484 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9485 } else { 9486 // Attributes with single quotes 9487 const [,,, attrName, attrValue] = result; 9488 if (!Type.isNil(attrName)) { 9489 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9490 } else { 9491 // Attributes without value 9492 const [,,,,, attrName] = result; 9493 tagResult.attrs[attrName] = ''; 9494 } 9495 } 9496 } else { 9497 break; 9498 } 9499 } 9500 return tagResult; 9501 } 9502 9503 function parseText(input) { 9504 const preparedText = input.replace(/[\n\r\t]$/, ''); 9505 const placeholders = preparedText.match(matchers.placeholder); 9506 return preparedText.split(matchers.placeholder).reduce((acc, item, index) => { 9507 if (Type.isStringFilled(item)) { 9508 acc.push(...item.split(/\n/).reduce((textAcc, text) => { 9509 const preparedItemText = text.replace(/[\t\r]/g, ''); 9510 if (Type.isStringFilled(preparedItemText)) { 9511 textAcc.push({ 9512 type: 'text', 9513 content: preparedItemText 9514 }); 9515 } 9516 return textAcc; 9517 }, [])); 9518 } 9519 if (placeholders && placeholders[index]) { 9520 acc.push({ 9521 type: 'placeholder', 9522 uid: parseInt(placeholders[index].replace(/{{uid|}}/, '')) 9523 }); 9524 } 9525 return acc; 9526 }, []); 9527 } 9528 9529 function parse(html, substitutions) { 9530 const result = []; 9531 if (html.indexOf('<') !== 0 && !html.startsWith('{{')) { 9532 const end = html.indexOf('<'); 9533 result.push(...parseText(end === -1 ? html : html.slice(0, end))); 9534 } 9535 const commentsContent = []; 9536 let commentIndex = -1; 9537 html = html.replace(matchers.comment, tag => { 9538 commentIndex += 1; 9539 commentsContent.push(tag.replace(/^<!--|-->$/g, '')); 9540 return `<!--{{cUid${commentIndex}}}-->`; 9541 }); 9542 const arr = []; 9543 let level = -1; 9544 let current; 9545 html.replace(matchers.tag, (tag, index) => { 9546 const start = index + tag.length; 9547 const nextChar = html.charAt(start); 9548 let parent; 9549 if (tag.startsWith('<!--')) { 9550 const comment = parseTag(tag, substitutions); 9551 comment.content = commentsContent[tag.replace(/<!--{{cUid|}}-->/g, '')]; 9552 if (level < 0) { 9553 result.push(comment); 9554 return result; 9555 } 9556 parent = arr[level]; 9557 parent.children.push(comment); 9558 return result; 9559 } 9560 if (tag.startsWith('{{')) { 9561 const [placeholder] = parseText(tag); 9562 if (level < 0) { 9563 result.push(placeholder); 9564 return result; 9565 } 9566 parent = arr[level]; 9567 parent.children.push(placeholder); 9568 return result; 9569 } 9570 if (!tag.startsWith('</')) { 9571 level++; 9572 current = parseTag(tag, substitutions); 9573 if (!current.voidElement && nextChar && nextChar !== '<') { 9574 current.children.push(...parseText(html.slice(start, html.indexOf('<', start)))); 9575 } 9576 if (level === 0) { 9577 result.push(current); 9578 } 9579 parent = arr[level - 1]; 9580 if (parent) { 9581 if (!current.svg) { 9582 current.svg = parent.svg; 9583 } 9584 parent.children.push(current); 9585 } 9586 arr[level] = current; 9587 } 9588 if (tag.startsWith('</') || current.voidElement) { 9589 if (level > -1 && (current.voidElement || current.name === tag.slice(2, -1))) { 9590 level--; 9591 current = level === -1 ? result : arr[level]; 9592 } 9593 if (nextChar && nextChar !== '<') { 9594 parent = level === -1 ? result : arr[level].children; 9595 const end = html.indexOf('<', start); 9596 const content = html.slice(start, end === -1 ? undefined : end); 9597 if (end >
9597 -1 && level + parent.length >= 0 || content !== ' ') { 9598 parent.push(...parseText(content)); 9599 } 9600 } 9601 } 9602 }); 9603 return result; 9604 } 9605 9606 const appendElement = (current, target) => { 9607 if (Type.isDomNode(current) && Type.isDomNode(target)) { 9608 if (target.nodeName !== 'TEMPLATE') { 9609 Dom.append(current, target); 9610 } else { 9611 // eslint-disable-next-line bitrix-rules/no-native-dom-methods 9612 target.content.append(current); 9613 } 9614 } 9615 }; 9616 function renderNode(options) { 9617 const { 9618 node, 9619 parentElement, 9620 substitutions, 9621 refs = [] 9622 } = options; 9623 if (node.type === 'tag') { 9624 const element = (() => { 9625 if (node.svg) { 9626 return document.createElementNS('http://www.w3.org/2000/svg', node.name); 9627 } 9628 return document.createElement(node.name); 9629 })(); 9630 if (Object.hasOwn(node.attrs, 'ref')) { 9631 refs.push([node.attrs.ref, element]); 9632 delete node.attrs.ref; 9633 } 9634 Object.entries(node.attrs).forEach(([key, value]) => { 9635 if (key.startsWith('on') && new RegExp(matchers.placeholder).test(value)) { 9636 const substitution = substitutions[parseInt(value.replace(/{{uid|}}/, '')) - 1]; 9637 if (Type.isFunction(substitution)) { 9638 const bindFunctionName = key.endsWith('once') ? 'bindOnce' : 'bind'; 9639 Event[bindFunctionName](element, key.replace(/^on|once$/g, ''), substitution); 9640 } else { 9641 element.setAttribute(key, substitution); 9642 } 9643 } else { 9644 if (new RegExp(matchers.placeholder).test(value)) { 9645 const preparedValue = value.split(/{{|}}/).reduce((acc, item) => { 9646 if (item.startsWith('uid')) { 9647 const substitution = substitutions[parseInt(item.replace('uid', '')) - 1]; 9648 return `${acc}${substitution}`; 9649 } 9650 return `${acc}${item}`; 9651 }, ''); 9652 element.setAttribute(key, preparedValue); 9653 } else { 9654 element.setAttribute(key, Text.decode(value)); 9655 } 9656 } 9657 }); 9658 node.children.forEach(childNode => { 9659 const result = renderNode({ 9660 node: childNode, 9661 parentElement: element, 9662 substitutions, 9663 refs 9664 }); 9665 if (Type.isArray(result)) { 9666 result.forEach(subChildElement => { 9667 appendElement(subChildElement, element); 9668 }); 9669 } else { 9670 appendElement(result, element); 9671 } 9672 }); 9673 return element; 9674 } 9675 if (node.type === 'comment') { 9676 return document.createComment(node.content); 9677 } 9678 if (node.type === 'text') { 9679 if (parentElement) { 9680 if (parentElement.nodeName !== 'TEMPLATE') { 9681 parentElement.insertAdjacentHTML('beforeend', node.content); 9682 } else { 9683 parentElement.content.append(node.content); 9684 } 9685 return; 9686 } 9687 return document.createTextNode(node.content); 9688 } 9689 if (node.type === 'placeholder') { 9690 return substitutions[node.uid - 1]; 9691 } 9692 } 9693 9694 function render(sections, ...substitutions) { 9695 const html = sections.reduce((acc, item, index) => { 9696 if (index > 0) { 9697 const substitution = substitutions[index - 1]; 9698 if (Type.isString(substitution) || Type.isNumber(substitution)) { 9699 return `${acc}${substitution}${item}`; 9700 } 9701 return `${acc}{{uid${index}}}${item}`; 9702 } 9703 return acc; 9704 }, sections[0]).replace(/^[\r\n\t\s]+/gm, '').replace(/>[\n]+/g, '>').replace(/[}][\n]+/g, '}'); 9705 const ast = parse(html); 9706 if (ast.length === 1) { 9707 const refs = []; 9708 const renderedNode = renderNode({ 9709 node: ast[0], 9710 substitutions, 9711 refs 9712 }); 9713 if (Type.isArrayFilled(refs)) { 9714 return Object.fromEntries([['root', renderedNode], ...refs]); 9715 } 9716 return renderedNode; 9717 } 9718 if (ast.length > 1) { 9719 const refs = []; 9720 const renderedNodes = ast.map(node => { 9721 return renderNode({ 9722 node, 9723 substitutions, 9724 refs 9725 }); 9726 }); 9727 if (Type.isArrayFilled(refs)) { 9728 return Object.fromEntries([['root', renderedNodes], ...refs]); 9729 } 9730 return renderedNodes; 9731 } 9732 return false;
9733 } 9734 9735 function parseProps(sections, ...substitutions) { 9736 return substitutions.reduce((acc, item, index) => { 9737 const nextSectionIndex = index + 1; 9738 if (!Type.isPlainObject(item) && !Type.isArray(item)) { 9739 return acc + item + sections[nextSectionIndex]; 9740 } 9741 return `${acc}__s${index}${sections[nextSectionIndex]}`; 9742 }, sections[0]).replace(/[\r\t]/gm, '').split(';\n').map(item => item.replace(/\n/, '')).reduce((acc, item) => { 9743 if (item !== '') { 9744 const matches = item.match(/^[\w-. ]+:/); 9745 const splitted = item.split(/^[\w-. ]+:/); 9746 const key = matches[0].replace(':', '').trim(); 9747 const value = splitted[1].trim(); 9748 const substitutionPlaceholderExp = /^__s\d+/; 9749 if (substitutionPlaceholderExp.test(value)) { 9750 acc[key] = substitutions[value.replace('__s', '')]; 9751 return acc; 9752 } 9753 acc[key] = value; 9754 } 9755 return acc; 9756 }, {}); 9757 } 9758 9759 /** 9760 * @memberOf BX 9761 */ 9762 let Tag = /*#__PURE__*/function () { 9763 function Tag() { 9764 babelHelpers.classCallCheck(this, Tag); 9765 } 9766 babelHelpers.createClass(Tag, null, [{ 9767 key: "safe", 9768 /** 9769 * Encodes all substitutions 9770 * @param sections 9771 * @param substitutions 9772 * @return {string} 9773 */ 9774 value: function safe(sections, ...substitutions) { 9775 return substitutions.reduce((acc, item, index) => acc + Text.encode(item) + sections[index + 1], sections[0]); 9776 } 9777 /** 9778 * Decodes all substitutions 9779 * @param sections 9780 * @param substitutions 9781 * @return {string} 9782 */ 9783 }, { 9784 key: "unsafe", 9785 value: function unsafe(sections, ...substitutions) { 9786 return substitutions.reduce((acc, item, index) => acc + Text.decode(item) + sections[index + 1], sections[0]); 9787 } 9788 /** 9789 * Adds styles to specified element 9790 * @param {HTMLElement} element 9791 * @return {Function} 9792 */ 9793 }, { 9794 key: "style", 9795 value: function style(element) { 9796 if (!Type.isDomNode(element)) { 9797 throw new Error('element is not HTMLElement'); 9798 } 9799 return function styleTagHandler(...args) { 9800 Dom.style(element, parseProps(...args)); 9801 }; 9802 } 9803 /** 9804 * Replace all messages identifiers to real messages 9805 * @param sections 9806 * @param substitutions 9807 * @return {string} 9808 */ 9809 }, { 9810 key: "message", 9811 value: function message(sections, ...substitutions) { 9812 return substitutions.reduce((acc, item, index) => acc + Loc.getMessage(item) + sections[index + 1], sections[0]); 9813 } 9814 }, { 9815 key: "attrs", 9816 /** 9817 * Adds attributes to specified element 9818 * @param element 9819 * @return {Function} 9820 */ 9821 value: function attrs(element) { 9822 if (!Type.isDomNode(element)) { 9823 throw new Error('element is not HTMLElement'); 9824 } 9825 return function attrsTagHandler(...args) { 9826 Dom.attr(element, parseProps(...args)); 9827 }; 9828 } 9829 }]); 9830 return Tag; 9831 }(); 9832 babelHelpers.defineProperty(Tag, "render", render); 9833 babelHelpers.defineProperty(Tag, "attr", Tag.attrs); 9834 9835 function getParser(format) { 9836 switch (format) { 9837 case 'index': 9838 return (sourceKey, value, accumulator) => { 9839 const result = /\[(\w*)\]$/.exec(sourceKey); 9840 const key = sourceKey.replace(/\[\w*\]$/, ''); 9841 if (Type.isNil(result)) { 9842 accumulator[key] = value; 9843 return; 9844 } 9845 if (Type.isUndefined(accumulator[key])) { 9846 accumulator[key] = {}; 9847 } 9848 accumulator[key][result[1]] = value; 9849 }; 9850 case 'bracket': 9851 return (sourceKey, value, accumulator) => { 9852 const result = /(\[\])$/.exec(sourceKey); 9853 const key = sourceKey.replace(/\[\]$/, ''); 9854 if (Type.isNil(result)) { 9855 accumulator[key] = value; 9856 return; 9857 } 9858 if (Type.isUndefined(accumulator[key])) { 9859 accumulator[key] = [value]; 9860 return; 9861 } 9862 accumulator[key] = [].concat(accumulator[key], value); 9863 }; 9864 default: 9865 return (sourceKey, value, accumulator) => {
9866 const key = sourceKey.replace(/\[\]$/, ''); 9867 accumulator[key] = value; 9868 }; 9869 } 9870 } 9871 function getKeyFormat(key) { 9872 if (/^\w+\[([\w]+)\]$/.test(key)) { 9873 return 'index'; 9874 } 9875 if (/^\w+\[\]$/.test(key)) { 9876 return 'bracket'; 9877 } 9878 return 'default'; 9879 } 9880 function isAllowedKey(key) { 9881 return !String(key).startsWith('__proto__'); 9882 } 9883 function parseQuery(input) { 9884 if (!Type.isString(input)) { 9885 return {}; 9886 } 9887 const url = input.trim().replace(/^[?#&]/, ''); 9888 if (!url) { 9889 return {}; 9890 } 9891 return { 9892 ...url.split('&').reduce((acc, param) => { 9893 const [key, value] = param.replace(/\+/g, ' ').split('='); 9894 if (isAllowedKey(key)) { 9895 const keyFormat = getKeyFormat(key); 9896 const formatter = getParser(keyFormat); 9897 formatter(key, value, acc); 9898 } 9899 return acc; 9900 }, Object.create(null)) 9901 }; 9902 } 9903 const urlExp = /^((\w+):)?(\/\/((\w+)?(:(\w+))?@)?([^\/\?:]+)(:(\d+))?)?(\/?([^\/\?#][^\?#]*)?)?(\?([^#]+))?(#((?:[\w-?/:@.~!$&'()*+,;=]|%\w{2})*))?/; 9904 function parseUrl(url) { 9905 const result = url.match(urlExp); 9906 if (Type.isArray(result)) { 9907 const queryParams = parseQuery(result[14]); 9908 return { 9909 useShort: /^\/\//.test(url), 9910 href: result[0] || '', 9911 schema: result[2] || '', 9912 host: result[8] || '', 9913 port: result[10] || '', 9914 path: result[11] || '', 9915 query: result[14] || '', 9916 queryParams, 9917 hash: result[16] || '', 9918 username: result[5] || '', 9919 password: result[7] || '', 9920 origin: result[8] || '' 9921 }; 9922 } 9923 return {}; 9924 } 9925 9926 function buildQueryString(params = {}) { 9927 const queryString = Object.keys(params).reduce((acc, key) => { 9928 if (Type.isArray(params[key])) { 9929 params[key].forEach(paramValue => { 9930 acc.push(`${key}[]=${paramValue}`); 9931 }, ''); 9932 } 9933 if (Type.isPlainObject(params[key])) { 9934 Object.keys(params[key]).forEach(paramIndex => { 9935 acc.push(`${key}[${paramIndex}]=${params[key][paramIndex]}`); 9936 }, ''); 9937 } 9938 if (!Type.isObject(params[key]) && !Type.isArray(params[key])) { 9939 acc.push(`${key}=${params[key]}`); 9940 } 9941 return acc; 9942 }, []).join('&'); 9943 if (queryString.length > 0) { 9944 return `?${queryString}`; 9945 } 9946 return queryString; 9947 } 9948 9949 function prepareParamValue(value) { 9950 if (Type.isArray(value)) { 9951 return value.map(item => String(item)); 9952 } 9953 if (Type.isPlainObject(value)) { 9954 return { 9955 ...value 9956 }; 9957 } 9958 return String(value); 9959 } 9960 9961 const map = new WeakMap(); 9962 9963 /** 9964 * Implements interface for works with URI 9965 * @memberOf BX 9966 */ 9967 let Uri = /*#__PURE__*/function () { 9968 babelHelpers.createClass(Uri, null, [{ 9969 key: "addParam", 9970 value: function addParam(url, params = {}) { 9971 return new Uri(url).setQueryParams(params).toString(); 9972 } 9973 }, { 9974 key: "removeParam", 9975 value: function removeParam(url, params) { 9976 const removableParams = Type.isArray(params) ? params : [params]; 9977 return new Uri(url).removeQueryParam(...removableParams).toString(); 9978 } 9979 }]); 9980 function Uri(url = '') { 9981 babelHelpers.classCallCheck(this, Uri); 9982 map.set(this, parseUrl(url)); 9983 } 9984 9985 /** 9986 * Gets schema 9987 * @return {?string} 9988 */ 9989 babelHelpers.createClass(Uri, [{ 9990 key: "getSchema", 9991 value: function getSchema() { 9992 return map.get(this).schema; 9993 } 9994 /** 9995 * Sets schema 9996 * @param {string} schema 9997 * @return {Uri} 9998 */ 9999 }, { 10000 key: "setSchema", 10001 value: function setSchema(schema) { 10002 map.get(this).schema = String(schema); 10003 return this; 10004 } 10005 /** 10006 * Gets host 10007 * @return {?string} 10008 */ 10009 }, { 10010 key: "getHost", 10011 value: function getHost() { 10012 return map.get(this).host; 10013 } 10014 /** 10015 * Sets host 10016 * @param {string} host 10017 * @return {Uri} 10018 */ 10019 }, { 10020 key: "setHost", 10021 value: function setHost(host) { 10022 map.get(this).host = String(host); 10023 return this; 10024 } 10025 /** 10026 * Gets port 10027 * @return {?string} 10028 */ 10029 }, { 10030 key: "getPort", 10031 value: function getPort() { 10032 return map.get(this).port; 10033 } 10034 /** 10035 * Sets port 10036 * @param {String | Number} port 10037 * @return {Uri} 10038 */ 10039 }, { 10040 key: "setPort", 10041 value: function setPort(port) { 10042 map.get(this).port = String(port); 10043 return this; 10044 } 10045 /** 10046 * Gets path 10047 * @return {?string} 10048 */ 10049 }, { 10050 key: "getPath", 10051 value: function getPath() { 10052 return map.get(this).path; 10053 } 10054 /** 10055 * Sets path 10056 * @param {string} path 10057 * @return {Uri} 10058 */ 10059 }, { 10060 key: "setPath", 10061 value: function setPath(path) { 10062 if (!/^\//.test(path)) {
10063 map.get(this).path = `/${String(path)}`; 10064 return this; 10065 } 10066 map.get(this).path = String(path); 10067 return this; 10068 } 10069 /** 10070 * Gets query 10071 * @return {?string} 10072 */ 10073 }, { 10074 key: "getQuery", 10075 value: function getQuery() { 10076 return buildQueryString(map.get(this).queryParams); 10077 } 10078 /** 10079 * Gets query param value by name 10080 * @param {string} key 10081 * @return {?string} 10082 */ 10083 }, { 10084 key: "getQueryParam", 10085 value: function getQueryParam(key) { 10086 const params = this.getQueryParams(); 10087 if (Object.hasOwn(params, key)) { 10088 return params[key]; 10089 } 10090 return null; 10091 } 10092 /** 10093 * Sets query param 10094 * @param {string} key 10095 * @param [value] 10096 * @return {Uri} 10097 */ 10098 }, { 10099 key: "setQueryParam", 10100 value: function setQueryParam(key, value = '') { 10101 map.get(this).queryParams[key] = prepareParamValue(value); 10102 return this; 10103 } 10104 /** 10105 * Gets query params 10106 * @return {Object<string, any>} 10107 */ 10108 }, { 10109 key: "getQueryParams", 10110 value: function getQueryParams() { 10111 return { 10112 ...map.get(this).queryParams 10113 }; 10114 } 10115 /** 10116 * Sets query params 10117 * @param {Object<string, any>} params 10118 * @return {Uri} 10119 */ 10120 }, { 10121 key: "setQueryParams", 10122 value: function setQueryParams(params = {}) { 10123 const currentParams = this.getQueryParams(); 10124 const newParams = { 10125 ...currentParams, 10126 ...params 10127 }; 10128 Object.keys(newParams).forEach(key => { 10129 newParams[key] = prepareParamValue(newParams[key]); 10130 }); 10131 map.get(this).queryParams = newParams; 10132 return this; 10133 } 10134 /** 10135 * Removes query params by name 10136 * @param keys 10137 * @return {Uri} 10138 */ 10139 }, { 10140 key: "removeQueryParam", 10141 value: function removeQueryParam(...keys) { 10142 const currentParams = { 10143 ...map.get(this).queryParams 10144 }; 10145 keys.forEach(key => { 10146 if (Object.hasOwn(currentParams, key)) { 10147 delete currentParams[key]; 10148 } 10149 }); 10150 map.get(this).queryParams = currentParams; 10151 return this; 10152 } 10153 /** 10154 * Gets fragment 10155 * @return {?string} 10156 */ 10157 }, { 10158 key: "getFragment", 10159 value: function getFragment() { 10160 return map.get(this).hash; 10161 } 10162 /** 10163 * Sets fragment 10164 * @param {string} hash 10165 * @return {Uri} 10166 */ 10167 }, { 10168 key: "setFragment", 10169 value: function setFragment(hash) { 10170 map.get(this).hash = String(hash); 10171 return this; 10172 } 10173 /** 10174 * Serializes URI 10175 * @return {Object} 10176 */ 10177 }, { 10178 key: "serialize", 10179 value: function serialize() { 10180 const serialized = { 10181 ...map.get(this) 10182 }; 10183 serialized.href = this.toString(); 10184 return serialized; 10185 } 10186 /** 10187 * Gets URI string 10188 * @return {string} 10189 */ 10190 }, { 10191 key: "toString", 10192 value: function toString() { 10193 const data = { 10194 ...map.get(this) 10195 }; 10196 let protocol = data.schema ? `${data.schema}://` : ''; 10197 if (data.useShort) { 10198 protocol = '//'; 10199 } 10200 const port = (() => { 10201 if (Type.isString(data.port) && !['', '80'].includes(data.port)) { 10202 return `:${data.port}`; 10203 } 10204 return ''; 10205 })(); 10206 const host = this.getHost(); 10207 const path = this.getPath(); 10208 const query = buildQueryString(data.queryParams); 10209 const hash = data.hash ? `#${data.hash}` : ''; 10210 return `${host ? protocol : ''}${host}${host ? port : ''}${path}${query}${hash}`; 10211 } 10212 }]); 10213 return Uri; 10214 }(); 10215 10216 /** 10217 * @memberOf BX 10218 */ 10219 let Validation = /*#__PURE__*/function () { 10220 function Validation() { 10221 babelHelpers.classCallCheck(this, Validation); 10222 } 10223 babelHelpers.createClass(Validation, null, [{ 10224 key: "isEmail", 10225 /** 10226 * Checks that value is valid email 10227 * @param value 10228 * @return {boolean} 10229 */ 10230 value: function isEmail(value) { 10231 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])?)*$/; 10232 return exp.test(String(value).toLowerCase()); 10233 } 10234 }]); 10235 return Validation; 10236 }(); 10237 10238 let BaseCache = /*#__PURE__*/function () { 10239 function BaseCache() { 10240 babelHelpers.classCallCheck(this, BaseCache); 10241 babelHelpers.defineProperty(this, "storage", new Map()); 10242 } 10243 babelHelpers.createClass(BaseCache, [{ 10244 key: "get", 10245 /** 10246 * Gets cached value or default value 10247 */ 10248 value: function get(key, defaultValue) { 10249 if (!this.storage.has(key)) { 10250 if (Type.isFunction(defaultValue)) { 10251 return defaultValue(); 10252 } 10253 if (!Type.isUndefined(defaultValue)) { 10254 return defaultValue; 10255 } 10256 } 10257 return this.storage.get(key); 10258 } 10259 /**
10260 * Sets cache entry 10261 */ 10262 }, { 10263 key: "set", 10264 value: function set(key, value) { 10265 this.storage.set(key, value); 10266 } 10267 /** 10268 * Deletes cache entry 10269 */ 10270 }, { 10271 key: "delete", 10272 value: function _delete(key) { 10273 this.storage.delete(key); 10274 } 10275 /** 10276 * Checks that storage contains entry with specified key 10277 */ 10278 }, { 10279 key: "has", 10280 value: function has(key) { 10281 return this.storage.has(key); 10282 } 10283 /** 10284 * Gets cached value if exists, 10285 */ 10286 }, { 10287 key: "remember", 10288 value: function remember(key, defaultValue) { 10289 if (!this.storage.has(key)) { 10290 if (Type.isFunction(defaultValue)) { 10291 this.storage.set(key, defaultValue()); 10292 } else if (!Type.isUndefined(defaultValue)) { 10293 this.storage.set(key, defaultValue); 10294 } 10295 } 10296 return this.storage.get(key); 10297 } 10298 /** 10299 * Gets storage size 10300 */ 10301 }, { 10302 key: "size", 10303 value: function size() { 10304 return this.storage.size; 10305 } 10306 /** 10307 * Gets storage keys 10308 */ 10309 }, { 10310 key: "keys", 10311 value: function keys() { 10312 return [...this.storage.keys()]; 10313 } 10314 /** 10315 * Gets storage values 10316 */ 10317 }, { 10318 key: "values", 10319 value: function values() { 10320 return [...this.storage.values()]; 10321 } 10322 }]); 10323 return BaseCache; 10324 }(); 10325 10326 let MemoryCache = /*#__PURE__*/function (_BaseCache) { 10327 babelHelpers.inherits(MemoryCache, _BaseCache); 10328 function MemoryCache(...args) { 10329 var _this; 10330 babelHelpers.classCallCheck(this, MemoryCache); 10331 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(MemoryCache).call(this, ...args)); 10332 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new Map()); 10333 return _this; 10334 } 10335 return MemoryCache; 10336 }(BaseCache); 10337 10338 let LsStorage = /*#__PURE__*/function () { 10339 function LsStorage() { 10340 babelHelpers.classCallCheck(this, LsStorage); 10341 babelHelpers.defineProperty(this, "stackKey", 'BX.Cache.Storage.LsStorage.stack'); 10342 babelHelpers.defineProperty(this, "stack", null); 10343 } 10344 babelHelpers.createClass(LsStorage, [{ 10345 key: "getStack", 10346 /** 10347 * @private 10348 */ 10349 value: function getStack() { 10350 if (Type.isPlainObject(this.stack)) { 10351 return this.stack; 10352 } 10353 const stack = localStorage.getItem(this.stackKey); 10354 if (Type.isString(stack) && stack !== '') { 10355 const parsedStack = JSON.parse(stack); 10356 if (Type.isPlainObject(parsedStack)) { 10357 this.stack = parsedStack; 10358 return this.stack; 10359 } 10360 } 10361 this.stack = {}; 10362 return this.stack; 10363 } 10364 /** 10365 * @private 10366 */ 10367 }, { 10368 key: "saveStack", 10369 value: function saveStack() { 10370 if (Type.isPlainObject(this.stack)) { 10371 const preparedStack = JSON.stringify(this.stack); 10372 localStorage.setItem(this.stackKey, preparedStack); 10373 } 10374 } 10375 }, { 10376 key: "get", 10377 value: function get(key) { 10378 const stack = this.getStack(); 10379 return stack[key]; 10380 } 10381 }, { 10382 key: "set", 10383 value: function set(key, value) { 10384 const stack = this.getStack(); 10385 stack[key] = value; 10386 this.saveStack(); 10387 } 10388 }, { 10389 key: "delete", 10390 value: function _delete(key) { 10391 const stack = this.getStack(); 10392 if (key in stack) { 10393 delete stack[key]; 10394 } 10395 } 10396 }, { 10397 key: "has", 10398 value: function has(key) { 10399 const stack = this.getStack(); 10400 return key in stack; 10401 } 10402 }, { 10403 key: "keys", 10404 value: function keys() { 10405 const stack = this.getStack(); 10406 return Object.keys(stack); 10407 } 10408 }, { 10409 key: "values", 10410 value: function values() { 10411 const stack = this.getStack(); 10412 return Object.values(stack); 10413 } 10414 }, { 10415 key: "size", 10416 get: function () { 10417 const stack = this.getStack(); 10418 return Object.keys(stack).length; 10419 } 10420 }]); 10421 return LsStorage; 10422 }(); 10423 10424 let LocalStorageCache = /*#__PURE__*/function (_BaseCache) { 10425 babelHelpers.inherits(LocalStorageCache, _BaseCache); 10426 function LocalStorageCache(...args) { 10427 var _this; 10428 babelHelpers.classCallCheck(this, LocalStorageCache); 10429 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(LocalStorageCache).call(this, ...args)); 10430 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new LsStorage()); 10431 return _this; 10432 } 10433 return LocalStorageCache; 10434 }(BaseCache); 10435 10436 /** 10437 * @memberOf BX 10438 */ 10439 let Cache = function Cache() { 10440 babelHelpers.classCallCheck(this, Cache); 10441 }; 10442 babelHelpers.defineProperty(Cache, "BaseCache", BaseCache); 10443 babelHelpers.defineProperty(Cache, "MemoryCache", MemoryCache); 10444 babelHelpers.defineProperty(Cache, "LocalStorageCache", LocalStorageCache); 10445 10446 function convertPath(path) { 10447 if (Type.isStringFilled(path)) { 10448 return path.split('.').reduce((acc, item) => { 10449 item.split(/\[['"]?(.+?)['"]?\]/g).forEach(key => { 10450 if (Type.isStringFilled(key)) { 10451 acc.push(key); 10452 } 10453 }); 10454 return acc; 10455 }, []); 10456 } 10457 return []; 10458 } 10459 10460 let SettingsCollection = /*#__PURE__*/function () { 10461 function SettingsCollection(options = {}) { 10462 babelHelpers.classCallCheck(this, SettingsCollection); 10463 if (Type.isPlainObject(options)) { 10464 Object.assign(this, options); 10465 } 10466 } 10467 babelHelpers.createClass(SettingsCollection, [{ 10468 key: "get", 10469 value: function get(path, defaultValue = null) { 10470 const convertedPath = convertPath(path); 10471 return convertedPath.reduce((acc, key) => { 10472 if (!Type.isNil(acc) && acc !== defaultValue) { 10473 if (!Type.isUndefined(acc[key])) { 10474 return acc[key]; 10475 } 10476 return defaultValue; 10477 } 10478 return acc; 10479 }, this); 10480 } 10481 }]); 10482 return SettingsCollection; 10483 }(); 10484 10485 function deepFreeze(target) { 10486 if (Type.isObject(target)) { 10487 Object.values(target).forEach(value => { 10488 deepFreeze(value); 10489 }); 10490 return Object.freeze(target); 10491 } 10492 return target; 10493 } 10494 10495 const settingsStorage = new Map(); 10496 let Extension$1 = /*#__PURE__*/function () { 10497 function Extension() { 10498 babelHelpers.classCallCheck(this, Extension); 10499 } 10500 babelHelpers.createClass(Extension, null, [{ 10501 key: "getSettings", 10502 value: function getSettings(extensionName) { 10503 if (Type.isStringFilled(extensionName)) { 10504 if (settingsStorage.has(extensionName)) { 10505 return settingsStorage.get(extensionName); 10506 } 10507 const settingsScriptNode = document.querySelector(`script[data-extension="${extensionName}"]`); 10508 if (Type.isDomNode(settingsScriptNode)) { 10509 const decodedSettings = (() => { 10510 try { 10511 return new SettingsCollection(JSON.parse(settingsScriptNode.innerHTML)); 10512 } catch (error) { 10513 return new SettingsCollection(); 10514 } 10515 })(); 10516 const frozenSettings = deepFreeze(decodedSettings); 10517 settingsStorage.set(extensionName, frozenSettings); 10518 return frozenSettings; 10519 } 10520 } 10521 return deepFreeze(new SettingsCollection()); 10522 } 10523 }]); 10524 return Extension; 10525 }(); 10526 10527 let _Symbol$iterator; 10528 function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration$1(obj, privateSet); privateSet.add(obj); } 10529 function _checkPrivateRedeclaration$1(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 10530 function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 10531 var _searchIndexToInsert = /*#__PURE__*/new WeakSet(); 10532 _Symbol$iterator = Symbol.iterator; 10533 let OrderedArray = /*#__PURE__*/function () { 10534 function OrderedArray(comparator = null) { 10535 babelHelpers.classCallCheck(this, OrderedArray); 10536 _classPrivateMethodInitSpec(this, _searchIndexToInsert); 10537 babelHelpers.defineProperty(this, "comparator", null); 10538 babelHelpers.defineProperty(this, "items", []); 10539 this.comparator = Type.isFunction(comparator) ? comparator : null; 10540 } 10541 babelHelpers.createClass(OrderedArray, [{ 10542 key: "add", 10543 value: function add(item) { 10544 let index = -1; 10545 if (this.comparator) { 10546 index = _classPrivateMethodGet(this, _searchIndexToInsert, _searchIndexToInsert2).call(this, item); 10547 this.items.splice(index, 0, item); 10548 } else { 10549 this.items.push(item); 10550 } 10551 return index; 10552 } 10553 }, { 10554 key: "has", 10555 value: function has(item) { 10556 return this.items.includes(item); 10557 } 10558 }, { 10559 key: "getIndex", 10560 value: function getIndex(item) { 10561 return this.items.indexOf(item); 10562 } 10563 }, { 10564 key: "getByIndex", 10565 value: function getByIndex(index) { 10566 if (Type.isNumber(index) && index >= 0) { 10567 const item = this.items[index]; 10568 return Type.isUndefined(item) ? null : item; 10569 } 10570 return null; 10571 } 10572 }, { 10573 key: "getFirst", 10574 value: function getFirst() { 10575 const first = this.items[0]; 10576 return Type.isUndefined(first) ? null : first; 10577 } 10578 }, { 10579 key: "getLast", 10580 value: function getLast() { 10581 const last = this.items[this.count() - 1]; 10582 return Type.isUndefined(last) ? null : last; 10583 } 10584 }, { 10585 key: "count", 10586 value: function count() { 10587 return this.items.length; 10588 } 10589 }, { 10590 key: "delete", 10591 value: function _delete(item) { 10592 const index = this.getIndex(item); 10593 if (index !== -1) { 10594 this.items.splice(index, 1); 10595 return true; 10596 } 10597 return false;
10598 } 10599 }, { 10600 key: "clear", 10601 value: function clear() { 10602 this.items = []; 10603 } 10604 }, { 10605 key: _Symbol$iterator, 10606 value: function () { 10607 return this.items[Symbol.iterator](); 10608 } 10609 }, { 10610 key: "forEach", 10611 value: function forEach(callbackfn, thisArg) { 10612 return this.items.forEach(callbackfn, thisArg); 10613 } 10614 }, { 10615 key: "getAll", 10616 value: function getAll() { 10617 return this.items; 10618 } 10619 }, { 10620 key: "getComparator", 10621 value: function getComparator() { 10622 return this.comparator; 10623 } 10624 }, { 10625 key: "sort", 10626 value: function sort() { 10627 const comparator = this.getComparator(); 10628 if (comparator === null) { 10629 return; 10630 } 10631 10632 /* 10633 Simple implementation 10634 this.items.sort((item1, item2) => { 10635 return comparator(item1, item2); 10636 }); 10637 */ 10638 10639 // For stable sorting https://v8.dev/features/stable-sort 10640 const length = this.items.length; 10641 const indexes = new Array(length); 10642 for (let i = 0; i < length; i++) { 10643 indexes[i] = i; 10644 } 10645 10646 // If the comparator returns zero, use the original indexes 10647 indexes.sort((index1, index2) => { 10648 return comparator(this.items[index1], this.items[index2]) || index1 - index2; 10649 }); 10650 for (let i = 0; i < length; i++) { 10651 indexes[i] = this.items[indexes[i]]; 10652 } 10653 for (let i = 0; i < length; i++) { 10654 this.items[i] = indexes[i]; 10655 } 10656 } 10657 }]); 10658 return OrderedArray; 10659 }(); 10660 function _searchIndexToInsert2(value) { 10661 let low = 0; 10662 let high = this.items.length; 10663 while (low < high) { 10664 const mid = Math.floor((low + high) / 2); 10665 if (this.comparator(this.items[mid], value) >= 0) { 10666 high = mid; 10667 } else { 10668 low = mid + 1; 10669 } 10670 } 10671 return low; 10672 } 10673 10674 let ZIndexComponent = /*#__PURE__*/function (_EventEmitter) { 10675 babelHelpers.inherits(ZIndexComponent, _EventEmitter); 10676 function ZIndexComponent(element, componentOptions = {}) { 10677 var _this; 10678 babelHelpers.classCallCheck(this, ZIndexComponent); 10679 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(ZIndexComponent).call(this)); 10680 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "sort", 0); 10681 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "alwaysOnTop", false); 10682 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "zIndex", 0); 10683 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "element", null); 10684 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlay", null); 10685 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlayGap", -5); 10686 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "stack", null); 10687 _this.setEventNamespace('BX.Main.ZIndexManager.Component'); 10688 if (!Type.isElementNode(element)) { 10689 throw new Error('ZIndexManager.Component: The argument \'element\' must be a DOM element.'); 10690 } 10691 _this.element = element; 10692 const options = Type.isPlainObject(componentOptions) ? componentOptions : {}; 10693 _this.setAlwaysOnTop(options.alwaysOnTop); 10694 _this.setOverlay(options.overlay); 10695 _this.setOverlayGap(options.overlayGap); 10696 _this.subscribeFromOptions(options.events); 10697 return _this; 10698 } 10699 babelHelpers.createClass(ZIndexComponent, [{ 10700 key: "getSort", 10701 value: function getSort() { 10702 return this.sort; 10703 } 10704 /** 10705 * @internal 10706 * @param sort 10707 */ 10708 }, { 10709 key: "setSort", 10710 value: function setSort(sort) { 10711 if (Type.isNumber(sort)) { 10712 this.sort = sort; 10713 } 10714 } 10715 /** 10716 * @internal 10717 * @param stack 10718 */ 10719 }, { 10720 key: "setStack", 10721 value: function setStack(stack) { 10722 this.stack = stack; 10723 } 10724 }, { 10725 key: "getStack", 10726 value: function getStack() { 10727 return this.stack; 10728 } 10729 }, { 10730 key: "getZIndex", 10731 value: function getZIndex() { 10732 return this.zIndex; 10733 } 10734 /** 10735 * @internal 10736 */ 10737 }, { 10738 key: "setZIndex", 10739 value: function setZIndex(zIndex) { 10740 const changed = this.getZIndex() !== zIndex; 10741 this.getElement().style.setProperty('z-index', zIndex, 'important'); 10742 this.zIndex = zIndex; 10743 if (this.getOverlay() !== null) { 10744 this.getOverlay().style.setProperty('z-index', zIndex + this.getOverlayGap(), 'important'); 10745 } 10746 if (changed) {
10747 this.emit('onZIndexChange', { 10748 component: this 10749 }); 10750 } 10751 } 10752 }, { 10753 key: "getAlwaysOnTop", 10754 value: function getAlwaysOnTop() { 10755 return this.alwaysOnTop; 10756 } 10757 }, { 10758 key: "setAlwaysOnTop", 10759 value: function setAlwaysOnTop(value) { 10760 if (Type.isNumber(value) || Type.isBoolean(value)) { 10761 this.alwaysOnTop = value; 10762 } 10763 } 10764 }, { 10765 key: "getElement", 10766 value: function getElement() { 10767 return this.element; 10768 } 10769 }, { 10770 key: "setOverlay", 10771 value: function setOverlay(overlay, gap) { 10772 if (Type.isElementNode(overlay) || overlay === null) { 10773 this.overlay = overlay; 10774 this.setOverlayGap(gap); 10775 if (this.getStack()) { 10776 this.getStack().sort(); 10777 } 10778 } 10779 } 10780 }, { 10781 key: "getOverlay", 10782 value: function getOverlay() { 10783 return this.overlay; 10784 } 10785 }, { 10786 key: "setOverlayGap", 10787 value: function setOverlayGap(gap) { 10788 if (Type.isNumber(gap)) { 10789 this.overlayGap = gap; 10790 } 10791 } 10792 }, { 10793 key: "getOverlayGap", 10794 value: function getOverlayGap() { 10795 return this.overlayGap; 10796 } 10797 }]); 10798 return ZIndexComponent; 10799 }(EventEmitter); 10800 10801 let ZIndexStack = /*#__PURE__*/function () { 10802 function ZIndexStack(container) { 10803 babelHelpers.classCallCheck(this, ZIndexStack); 10804 babelHelpers.defineProperty(this, "container", null); 10805 babelHelpers.defineProperty(this, "components", null); 10806 babelHelpers.defineProperty(this, "elements", new WeakMap()); 10807 babelHelpers.defineProperty(this, "baseIndex", 1000); 10808 babelHelpers.defineProperty(this, "baseStep", 50); 10809 babelHelpers.defineProperty(this, "sortCount", 0); 10810 if (!Type.isDomNode(container)) { 10811 throw new Error('ZIndexManager.Stack: The \'container\' argument must be a DOM element.'); 10812 } 10813 this.container = container; 10814 const comparator = (componentA, componentB) => { 10815 let result = (componentA.getAlwaysOnTop() || 0) - (componentB.getAlwaysOnTop() || 0); 10816 if (!result) { 10817 result = componentA.getSort() - componentB.getSort(); 10818 } 10819 return result; 10820 }; 10821 this.components = new OrderedArray(comparator); 10822 } 10823 babelHelpers.createClass(ZIndexStack, [{ 10824 key: "getBaseIndex", 10825 value: function getBaseIndex() { 10826 return this.baseIndex; 10827 } 10828 }, { 10829 key: "setBaseIndex", 10830 value: function setBaseIndex(index) { 10831 if (Type.isNumber(index) && index >= 0) { 10832 this.baseIndex = index; 10833 this.sort(); 10834 } 10835 } 10836 }, { 10837 key: "setBaseStep", 10838 value: function setBaseStep(step) { 10839 if (Type.isNumber(step) && step > 0) { 10840 this.baseStep = step; 10841 this.sort(); 10842 } 10843 } 10844 }, { 10845 key: "getBaseStep", 10846 value: function getBaseStep() { 10847 return this.baseStep; 10848 } 10849 }, { 10850 key: "register", 10851 value: function register(element, options = {}) { 10852 if (this.getComponent(element)) { 10853 console.warn('ZIndexManager: You cannot register the element twice.', element); 10854 return this.getComponent(element); 10855 } 10856 const component = new ZIndexComponent(element, options); 10857 component.setStack(this); 10858 component.setSort(++this.sortCount); 10859 this.elements.set(element, component); 10860 this.components.add(component); 10861 this.sort(); 10862 return component; 10863 } 10864 }, { 10865 key: "unregister", 10866 value: function unregister(element) { 10867 const component = this.elements.get(element); 10868 this.components.delete(component); 10869 this.elements.delete(element); 10870 this.sort(); 10871 } 10872 }, { 10873 key: "getComponent", 10874 value: function getComponent(element) { 10875 return this.elements.get(element) || null; 10876 } 10877 }, { 10878 key: "getComponents", 10879 value: function getComponents() { 10880 return this.components.getAll(); 10881 } 10882 }, { 10883 key: "getMaxZIndex", 10884 value: function getMaxZIndex() { 10885 const last = this.components.getLast(); 10886 return last ? last.getZIndex() : this.baseIndex; 10887 } 10888 }, { 10889 key: "sort", 10890 value: function sort() { 10891 this.components.sort(); 10892 let zIndex = this.baseIndex;
10893 this.components.forEach(component => { 10894 component.setZIndex(zIndex); 10895 zIndex += this.baseStep; 10896 }); 10897 } 10898 }, { 10899 key: "bringToFront", 10900 value: function bringToFront(element) { 10901 const component = this.getComponent(element); 10902 if (!component) { 10903 console.error('ZIndexManager: element was not found in the stack.', element); 10904 return null; 10905 } 10906 component.setSort(++this.sortCount); 10907 this.sort(); 10908 return component; 10909 } 10910 }]); 10911 return ZIndexStack; 10912 }(); 10913 10914 function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; } 10915 function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } } 10916 /** 10917 * @memberof BX 10918 */ 10919 let ZIndexManager = /*#__PURE__*/function () { 10920 function ZIndexManager() { 10921 babelHelpers.classCallCheck(this, ZIndexManager); 10922 } 10923 babelHelpers.createClass(ZIndexManager, null, [{ 10924 key: "register", 10925 value: function register(element, options = {}) { 10926 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10927 if (!parentNode) { 10928 return null; 10929 } 10930 const stack = this.getOrAddStack(parentNode); 10931 return stack.register(element, options); 10932 } 10933 }, { 10934 key: "unregister", 10935 value: function unregister(element) { 10936 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10937 const stack = this.getStack(parentNode); 10938 if (stack) { 10939 stack.unregister(element); 10940 } 10941 } 10942 }, { 10943 key: "addStack", 10944 value: function addStack(container) { 10945 const stack = new ZIndexStack(container); 10946 this.stacks.set(container, stack); 10947 return stack; 10948 } 10949 }, { 10950 key: "getStack", 10951 value: function getStack(container) { 10952 return this.stacks.get(container) || null; 10953 } 10954 }, { 10955 key: "getOrAddStack", 10956 value: function getOrAddStack(container) { 10957 return this.getStack(container) || this.addStack(container); 10958 } 10959 }, { 10960 key: "getComponent", 10961 value: function getComponent(element) { 10962 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element, true); 10963 if (!parentNode) { 10964 return null; 10965 } 10966 const stack = this.getStack(parentNode); 10967 return stack ? stack.getComponent(element) : null; 10968 } 10969 }, { 10970 key: "bringToFront", 10971 value: function bringToFront(element) { 10972 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10973 const stack = this.getStack(parentNode); 10974 if (stack) { 10975 return stack.bringToFront(element); 10976 } 10977 return null; 10978 } 10979 }]); 10980 return ZIndexManager; 10981 }(); 10982 function _getParentNode(element, suppressWarnings = false) { 10983 if (!Type.isElementNode(element)) { 10984 if (!suppressWarnings) { 10985 console.error('ZIndexManager: The argument \'element\' must be a DOM element.', element); 10986 } 10987 return null; 10988 } else if (!Type.isElementNode(element.parentNode)) { 10989 if (!suppressWarnings) { 10990 console.error('ZIndexManager: The \'element\' doesn\'t have a parent node.', element); 10991 } 10992 return null; 10993 } 10994 return element.parentNode; 10995 } 10996 babelHelpers.defineProperty(ZIndexManager, "stacks", new WeakMap()); 10997 10998 function _classPrivateMethodInitSpec$1(obj, privateSet) { _checkPrivateRedeclaration$2(obj, privateSet); privateSet.add(obj); } 10999 function _classPrivateFieldInitSpec$1(obj, privateMap, value) { _checkPrivateRedeclaration$2(obj, privateMap); privateMap.set(obj, value); } 11000 function _checkPrivateRedeclaration$2(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 11001 function _classPrivateMethodGet$1(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 11002 11003 // eslint-disable-next-line @bitrix24/bitrix24-rules/no-typeof 11004 const IS_WEAK_REF_SUPPORTED = typeof WeakRef !== 'undefined'; 11005 var _refs = /*#__PURE__*/new WeakMap(); 11006 var _registry = /*#__PURE__*/new WeakMap(); 11007 var _cleanupCallback = /*#__PURE__*/new WeakSet(); 11008 let WeakRefMap = /*#__PURE__*/function () { 11009 function WeakRefMap() { 11010 babelHelpers.classCallCheck(this, WeakRefMap); 11011 _classPrivateMethodInitSpec$1(this, _cleanupCallback); 11012 _classPrivateFieldInitSpec$1(this, _refs, { 11013 writable: true, 11014 value: new Map() 11015 }); 11016 _classPrivateFieldInitSpec$1(this, _registry, { 11017 writable: true, 11018 value: null 11019 }); 11020 if (IS_WEAK_REF_SUPPORTED) { 11021 babelHelpers.classPrivateFieldSet(this, _registry, new FinalizationRegistry(_classPrivateMethodGet$1(this, _cleanupCallback, _cleanupCallback2).bind(this))); 11022 } 11023 } 11024 babelHelpers.createClass(WeakRefMap, [{ 11025 key: "clear", 11026 value: function clear() { 11027 if (!IS_WEAK_REF_SUPPORTED) { 11028 babelHelpers.classPrivateFieldGet(this, _refs).clear(); 11029 return; 11030 }
11031 babelHelpers.classPrivateFieldGet(this, _refs).forEach((ref, key) => { 11032 const value = ref === null || ref === void 0 ? void 0 : ref.deref(); 11033 if (!Type.isUndefined(value)) { 11034 babelHelpers.classPrivateFieldGet(this, _registry).unregister(value); 11035 } 11036 }); 11037 babelHelpers.classPrivateFieldGet(this, _refs).clear(); 11038 } 11039 }, { 11040 key: "delete", 11041 value: function _delete(key) { 11042 if (!IS_WEAK_REF_SUPPORTED) { 11043 return babelHelpers.classPrivateFieldGet(this, _refs).delete(key); 11044 } 11045 const value = this.get(key); 11046 if (!Type.isUndefined(value)) { 11047 babelHelpers.classPrivateFieldGet(this, _registry).unregister(value); 11048 } 11049 return babelHelpers.classPrivateFieldGet(this, _refs).delete(key); 11050 } 11051 }, { 11052 key: "get", 11053 value: function get(key) { 11054 var _babelHelpers$classPr; 11055 if (!IS_WEAK_REF_SUPPORTED) { 11056 return babelHelpers.classPrivateFieldGet(this, _refs).get(key); 11057 } 11058 return (_babelHelpers$classPr = babelHelpers.classPrivateFieldGet(this, _refs).get(key)) === null || _babelHelpers$classPr === void 0 ? void 0 : _babelHelpers$classPr.deref(); 11059 } 11060 }, { 11061 key: "has", 11062 value: function has(key) { 11063 var _babelHelpers$classPr2; 11064 if (!IS_WEAK_REF_SUPPORTED) { 11065 return babelHelpers.classPrivateFieldGet(this, _refs).has(key); 11066 } 11067 return !Type.isUndefined((_babelHelpers$classPr2 = babelHelpers.classPrivateFieldGet(this, _refs).get(key)) === null || _babelHelpers$classPr2 === void 0 ? void 0 : _babelHelpers$classPr2.deref()); 11068 } 11069 }, { 11070 key: "set", 11071 value: function set(key, value) { 11072 if (!IS_WEAK_REF_SUPPORTED) { 11073 babelHelpers.classPrivateFieldGet(this, _refs).set(key, value); 11074 return this; 11075 } 11076 babelHelpers.classPrivateFieldGet(this, _refs).set(key, new WeakRef(value)); 11077 babelHelpers.classPrivateFieldGet(this, _registry).register(value, key, value); 11078 return this; 11079 } 11080 }]); 11081 return WeakRefMap; 11082 }(); 11083 function _cleanupCallback2(key) { 11084 const ref = babelHelpers.classPrivateFieldGet(this, _refs).get(key); 11085 if (ref && !ref.deref()) { 11086 babelHelpers.classPrivateFieldGet(this, _refs).delete(key); 11087 } 11088 } 11089 11090 var collections = { 11091 OrderedArray, 11092 SettingsCollection, 11093 WeakRefMap 11094 }; 11095 11096 function getElement(element) { 11097 if (Type.isString(element)) { 11098 return document.getElementById(element); 11099 } 11100 return element; 11101 } 11102 11103 function getWindow(element) { 11104 if (Type.isElementNode(element)) { 11105 return element.ownerDocument.parentWindow || element.ownerDocument.defaultView || window; 11106 } 11107 if (Type.isDomNode(element)) { 11108 return element.parentWindow || element.defaultView || window; 11109 } 11110 return window; 11111 } 11112 11113 /* eslint-disable prefer-rest-params */ 11114 11115 // BX.* 11116 const { 11117 getClass, 11118 namespace 11119 } = Reflection; 11120 const message$1 = message; 11121 11122 /** 11123 * @memberOf BX 11124 */ 11125 const { 11126 replace, 11127 remove, 11128 clean, 11129 insertBefore, 11130 insertAfter, 11131 append, 11132 prepend, 11133 style, 11134 adjust, 11135 create, 11136 isShown 11137 } = Dom; 11138 const addClass = function addClass() { 11139 Dom.addClass(...Runtime.merge([], Array.from(arguments), [getElement(arguments[0])])); 11140 }; 11141 const removeClass = function removeClass() { 11142 Dom.removeClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11143 }; 11144 const hasClass = function hasClass() { 11145 return Dom.hasClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11146 }; 11147 const toggleClass = function toggleClass() { 11148 Dom.toggleClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11149 }; 11150 const cleanNode = (element, removeElement = false) => { 11151 const currentElement = getElement(element); 11152 if (Type.isDomNode(currentElement)) { 11153 Dom.clean(currentElement); 11154 if (removeElement) { 11155 Dom.remove(currentElement); 11156 return currentElement; 11157 } 11158 } 11159 return currentElement; 11160 }; 11161 const getCookie = Http.Cookie.get; 11162 const setCookie = (name, value, options = {}) => { 11163 const attributes = { 11164 ...options 11165 }; 11166 if (Type.isNumber(attributes.expires)) { 11167 attributes.expires /= 3600 * 24; 11168 } 11169 Http.Cookie.set(name, value, attributes); 11170 }; 11171 const { 11172 bind: bind$1, 11173 unbind: unbind$1, 11174 unbindAll: unbindAll$1, 11175 bindOnce: bindOnce$1, 11176 ready: ready$1 11177 } = Event; 11178 const { 11179 debugState: debugEnableFlag, 11180 isDebugEnabled: debugStatus, 11181 default: debug$1 11182 }
11182 = debugNs; 11183 const debugEnable = value => { 11184 if (value) { 11185 enableDebug(); 11186 } else { 11187 disableDebug(); 11188 } 11189 }; 11190 const { 11191 clone: clone$1, 11192 loadExtension: loadExt, 11193 debounce, 11194 throttle, 11195 html 11196 } = Runtime; 11197 11198 // BX.type 11199 const type = { 11200 ...Object.getOwnPropertyNames(Type).filter(key => !['name', 'length', 'prototype', 'caller', 'arguments'].includes(key)).reduce((acc, key) => { 11201 acc[key] = Type[key]; 11202 return acc; 11203 }, {}), 11204 isNotEmptyString: value => Type.isString(value) && value !== '', 11205 isNotEmptyObject: value => Type.isObjectLike(value) && Object.keys(value).length > 0, 11206 isMapKey: Type.isObject, 11207 stringToInt: value => { 11208 const parsed = parseInt(value); 11209 return !Number.isNaN(parsed) ? parsed : 0; 11210 } 11211 }; 11212 11213 // BX.browser 11214 const browser = { 11215 IsOpera: Browser.isOpera, 11216 IsIE: Browser.isIE, 11217 IsIE6: Browser.isIE6, 11218 IsIE7: Browser.isIE7, 11219 IsIE8: Browser.isIE8, 11220 IsIE9: Browser.isIE9, 11221 IsIE10: Browser.isIE10, 11222 IsIE11: Browser.isIE11, 11223 IsSafari: Browser.isSafari, 11224 IsFirefox: Browser.isFirefox, 11225 IsChrome: Browser.isChrome, 11226 DetectIeVersion: Browser.detectIEVersion, 11227 IsMac: Browser.isMac, 11228 IsAndroid: Browser.isAndroid, 11229 isIPad: Browser.isIPad, 11230 isIPhone: Browser.isIPhone, 11231 IsIOS: Browser.isIOS, 11232 IsMobile: Browser.isMobile, 11233 isRetina: Browser.isRetina, 11234 IsDoctype: Browser.isDoctype, 11235 SupportLocalStorage: Browser.isLocalStorageSupported, 11236 addGlobalClass: Browser.addGlobalClass, 11237 DetectAndroidVersion: Browser.detectAndroidVersion, 11238 isPropertySupported: Browser.isPropertySupported, 11239 addGlobalFeatures: Browser.addGlobalFeatures 11240 }; 11241 11242 // eslint-disable-next-line 11243 const ajax = window.BX ? window.BX.ajax : () => {}; 11244 function GetWindowScrollSize(doc = document) { 11245 return { 11246 scrollWidth: doc.documentElement.scrollWidth, 11247 scrollHeight: doc.documentElement.scrollHeight 11248 }; 11249 } 11250 function GetWindowScrollPos(doc = document) { 11251 const win = getWindow(doc); 11252 return { 11253 scrollLeft: win.pageXOffset, 11254 scrollTop: win.pageYOffset 11255 }; 11256 } 11257 function GetWindowInnerSize(doc = document) { 11258 const win = getWindow(doc); 11259 return { 11260 innerWidth: win.innerWidth, 11261 innerHeight: win.innerHeight 11262 }; 11263 } 11264 function GetWindowSize(doc = document) { 11265 return { 11266 ...GetWindowInnerSize(doc), 11267 ...GetWindowScrollPos(doc), 11268 ...GetWindowScrollSize(doc) 11269 }; 11270 } 11271 function GetContext(node) { 11272 return getWindow(node); 11273 } 11274 function pos(element, relative = false) { 11275 if (!element) { 11276 return new DOMRect().toJSON(); 11277 } 11278 if (element.ownerDocument === document && !relative) { 11279 const clientRect = element.getBoundingClientRect(); 11280 const root = document.documentElement; 11281 const { 11282 body 11283 } = document; 11284 return { 11285 top: Math.round(clientRect.top + (root.scrollTop || body.scrollTop)), 11286 left: Math.round(clientRect.left + (root.scrollLeft || body.scrollLeft)), 11287 width: Math.round(clientRect.right - clientRect.left), 11288 height: Math.round(clientRect.bottom - clientRect.top), 11289 right: Math.round(clientRect.right + (root.scrollLeft || body.scrollLeft)), 11290 bottom: Math.round(clientRect.bottom + (root.scrollTop || body.scrollTop)) 11291 }; 11292 } 11293 let x = 0; 11294 let y = 0; 11295 const w = element.offsetWidth; 11296 const h = element.offsetHeight; 11297 let first = true; 11298 11299 // eslint-disable-next-line no-param-reassign 11300 for (; element != null; element = element.offsetParent) { 11301 if (!first && relative && BX.is_relative(element)) { 11302 break; 11303 } 11304 x += element.offsetLeft; 11305 y += element.offsetTop; 11306 if (first) { 11307 first = false; 11308 // eslint-disable-next-line no-continue 11309 continue; 11310 } 11311 x += Text.toNumber(Dom.style(element, 'border-left-width')); 11312 y += Text.toNumber(Dom.style(element, 'border-top-width')); 11313 } 11314 return new DOMRect(x, y, w, h).toJSON(); 11315 } 11316 function addCustomEvent(eventObject, eventName, eventHandler) { 11317 if (Type.isString(eventObject)) { 11318 eventHandler = eventName; 11319 eventName = eventObject; 11320 eventObject = EventEmitter.GLOBAL_TARGET;
11321 } 11322 if (eventObject === window) { 11323 eventObject = EventEmitter.GLOBAL_TARGET; 11324 } 11325 if (!Type.isObject(eventObject)) { 11326 console.error('The "eventObject" argument must be an object. Received type ' + typeof eventObject + '.'); 11327 return; 11328 } 11329 if (!Type.isStringFilled(eventName)) { 11330 console.error('The "eventName" argument must be a string.'); 11331 return; 11332 } 11333 if (!Type.isFunction(eventHandler)) { 11334 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11335 return; 11336 } 11337 eventName = eventName.toLowerCase(); 11338 EventEmitter.subscribe(eventObject, eventName, eventHandler, { 11339 compatMode: true, 11340 useGlobalNaming: true 11341 }); 11342 } 11343 function onCustomEvent(eventObject, eventName, eventParams, secureParams) { 11344 if (Type.isString(eventObject)) { 11345 secureParams = eventParams; 11346 eventParams = eventName; 11347 eventName = eventObject; 11348 eventObject = EventEmitter.GLOBAL_TARGET; 11349 } 11350 if (!Type.isObject(eventObject) || eventObject === window) { 11351 eventObject = EventEmitter.GLOBAL_TARGET;
11352 } 11353 if (!eventParams) { 11354 eventParams = []; 11355 } 11356 eventName = eventName.toLowerCase(); 11357 const event = new BaseEvent(); 11358 event.setData(eventParams); 11359 event.setCompatData(eventParams); 11360 EventEmitter.emit(eventObject, eventName, event, { 11361 cloneData: secureParams === true, 11362 useGlobalNaming: true 11363 }); 11364 } 11365 function removeCustomEvent(eventObject, eventName, eventHandler) { 11366 if (Type.isString(eventObject)) { 11367 eventHandler = eventName; 11368 eventName = eventObject; 11369 eventObject = EventEmitter.GLOBAL_TARGET; 11370 } 11371 if (!Type.isFunction(eventHandler)) { 11372 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11373 return; 11374 } 11375 if (eventObject === window) { 11376 eventObject = EventEmitter.GLOBAL_TARGET; 11377 } 11378 eventName = eventName.toLowerCase(); 11379 EventEmitter.unsubscribe(eventObject, eventName, eventHandler, { 11380 useGlobalNaming: true 11381 }); 11382 } 11383 function removeAllCustomEvents(eventObject, eventName) { 11384 if (Type.isString(eventObject)) { 11385 eventName = eventObject; 11386 eventObject = EventEmitter.GLOBAL_TARGET;
11387 } 11388 if (eventObject === window) { 11389 eventObject = EventEmitter.GLOBAL_TARGET; 11390 } 11391 eventName = eventName.toLowerCase(); 11392 EventEmitter.unsubscribeAll(eventObject, eventName, { 11393 useGlobalNaming: true 11394 }); 11395 } 11396 11397 if (typeof global === 'object' && global.window && global.window.BX) { 11398 Object.assign(global.window.BX, exports); 11399 } 11400 11401 exports.Type = Type; 11402 exports.Reflection = Reflection; 11403 exports.Text = Text; 11404 exports.Dom = Dom; 11405 exports.Browser = Browser; 11406 exports.Event = Event; 11407 exports.Http = Http; 11408 exports.Runtime = Runtime; 11409 exports.Loc = Loc; 11410 exports.Tag = Tag; 11411 exports.Uri = Uri; 11412 exports.Validation = Validation; 11413 exports.Cache = Cache; 11414 exports.BaseError = BaseError; 11415 exports.Extension = Extension$1; 11416 exports.ZIndexManager = ZIndexManager; 11417 exports.Collections = collections; 11418 exports.getClass = getClass; 11419 exports.namespace = namespace; 11420 exports.message = message$1; 11421 exports.replace = replace; 11422 exports.remove = remove; 11423 exports.clean = clean; 11424 exports.insertBefore = insertBefore; 11425 exports.insertAfter = insertAfter; 11426 exports.append = append; 11427 exports.prepend = prepend; 11428 exports.style = style; 11429 exports.adjust = adjust; 11430 exports.create = create; 11431 exports.isShown = isShown; 11432 exports.addClass = addClass; 11433 exports.removeClass = removeClass; 11434 exports.hasClass = hasClass; 11435 exports.toggleClass = toggleClass; 11436 exports.cleanNode = cleanNode; 11437 exports.getCookie = getCookie; 11438 exports.setCookie = setCookie; 11439 exports.bind = bind$1; 11440 exports.unbind = unbind$1; 11441 exports.unbindAll = unbindAll$1; 11442 exports.bindOnce = bindOnce$1; 11443 exports.ready = ready$1; 11444 exports.debugEnableFlag = debugEnableFlag; 11445 exports.debugStatus = debugStatus; 11446 exports.debug = debug$1; 11447 exports.debugEnable = debugEnable; 11448 exports.clone = clone$1; 11449 exports.loadExt = loadExt; 11450 exports.debounce = debounce; 11451 exports.throttle = throttle; 11452 exports.html = html; 11453 exports.type = type; 11454 exports.browser = browser; 11455 exports.ajax = ajax; 11456 exports.GetWindowScrollSize = GetWindowScrollSize; 11457 exports.GetWindowScrollPos = GetWindowScrollPos; 11458 exports.GetWindowInnerSize = GetWindowInnerSize; 11459 exports.GetWindowSize = GetWindowSize; 11460 exports.GetContext = GetContext; 11461 exports.pos = pos; 11462 exports.addCustomEvent = addCustomEvent; 11463 exports.onCustomEvent = onCustomEvent; 11464 exports.removeCustomEvent = removeCustomEvent; 11465 exports.removeAllCustomEvents = removeAllCustomEvents; 11466 11467}((this.BX = this.BX || {}))); 11468 11469 11470 11471(function(BX) { 11472 /* list of registered proxy functions */ 11473 var proxyList = new WeakMap(); 11474 var deferList = new WeakMap(); 11475 11476 /* List of denied event handlers */ 11477 var deniedEvents = []; 11478 11479 /* list of registered custom events */ 11480 var customEvents = new WeakMap(); 11481 var customEventsCnt = 0; 11482 11483 /* list of external garbage collectors */ 11484 var garbageCollectors = []; 11485 11486 /* list of loaded CSS files */ 11487 var cssList = []; 11488 var cssInit = false; 11489 11490 /* list of loaded JS files */ 11491 var jsList = []; 11492 var jsInit = false; 11493 11494 var eventTypes = { 11495 click: 'MouseEvent', 11496 dblclick: 'MouseEvent', 11497 mousedown: 'MouseEvent', 11498 mousemove: 'MouseEvent', 11499 mouseout: 'MouseEvent', 11500 mouseover: 'MouseEvent', 11501 mouseup: 'MouseEvent', 11502 focus: 'MouseEvent', 11503 blur: 'MouseEvent' 11504 }; 11505 11506 var lastWait = []; 11507 11508 var CHECK_FORM_ELEMENTS = {tagName: /^INPUT|SELECT|TEXTAREA|BUTTON$/i}; 11509 11510 BX.MSLEFT = 1; 11511 BX.MSMIDDLE = 2; 11512 BX.MSRIGHT = 4; 11513 11514 BX.AM_PM_UPPER = 1; 11515 BX.AM_PM_LOWER = 2; 11516 BX.AM_PM_NONE = false; 11517 11518 BX.ext = function(ob) 11519 { 11520 for (var i in ob) 11521 { 11522 if(ob.hasOwnProperty(i)) 11523 { 11524 this[i] = ob[i]; 11525 } 11526 } 11527 }; 11528 11529 var r = { 11530 script: /<script([^>]*)>/ig, 11531 script_end: /<\/script>/ig, 11532 script_src: /src=["\']([^"\']+)["\']/i, 11533 script_type: /type=["\']([^"\']+)["\']/i, 11534 space: /\s+/, 11535 ltrim: /^[\s\r\n]+/g, 11536 rtrim: /[\s\r\n]+$/g, 11537 style: /<link.*?(rel="stylesheet"|type="text\/css")[^>]*>/i, 11538 style_href: /href=["\']([^"\']+)["\']/i 11539 }; 11540 11541 BX.processHTML = function(data, scriptsRunFirst) 11542 { 11543 var matchScript, matchStyle, matchSrc, matchHref, matchType, scripts = [], styles = []; 11544 var textIndexes = []; 11545 var lastIndex = r.script.lastIndex = r.script_end.lastIndex = 0; 11546 11547 while ((matchScript = r.script.exec(data)) !== null) 11548 { 11549 r.script_end.lastIndex = r.script.lastIndex; 11550 var matchScriptEnd = r.script_end.exec(data); 11551 if (matchScriptEnd === null) 11552 { 11553 break; 11554 } 11555 11556 // skip script tags of special types 11557 var skipTag = false;
11558 if ((matchType = matchScript[1].match(r.script_type)) !== null) 11559 { 11560 if( 11561 matchType[1] == 'text/html' 11562 || matchType[1] == 'text/template' 11563 || matchType[1] == 'extension/settings' 11564 ) 11565 { 11566 skipTag = true; 11567 } 11568 } 11569 11570 if(skipTag) 11571 { 11572 textIndexes.push([lastIndex, r.script_end.lastIndex - lastIndex]); 11573 } 11574 else 11575 { 11576 textIndexes.push([lastIndex, matchScript.index - lastIndex]); 11577 11578 var bRunFirst = scriptsRunFirst || (matchScript[1].indexOf('bxrunfirst') != '-1'); 11579 11580 if ((matchSrc = matchScript[1].match(r.script_src)) !== null) 11581 { 11582 scripts.push({"bRunFirst": bRunFirst, "isInternal": false, "JS": matchSrc[1]}); 11583 } 11584 else 11585 { 11586 var start = matchScript.index + matchScript[0].length; 11587 var js = data.substr(start, matchScriptEnd.index-start); 11588 11589 scripts.push({"bRunFirst": bRunFirst, "isInternal": true, "JS": js}); 11590 } 11591 } 11592 11593 lastIndex = matchScriptEnd.index + 9; 11594 r.script.lastIndex = lastIndex; 11595 } 11596 11597 textIndexes.push([lastIndex, lastIndex === 0 ? data.length : data.length - lastIndex]); 11598 var pureData = ""; 11599 for (var i = 0, length = textIndexes.length; i < length; i++) 11600 { 11601 if (BX.type.isString(data) && BX.type.isFunction(data.substr)) 11602 { 11603 pureData += data.substr(textIndexes[i][0], textIndexes[i][1]); 11604 } 11605 } 11606 11607 while ((matchStyle = pureData.match(r.style)) !== null) 11608 { 11609 if ((matchHref = matchStyle[0].match(r.style_href)) !== null && matchStyle[0].indexOf('media="') < 0) 11610 { 11611 styles.push(matchHref[1]); 11612 } 11613 11614 pureData = pureData.replace(matchStyle[0], ''); 11615 } 11616 11617 return {'HTML': pureData, 'SCRIPT': scripts, 'STYLE': styles}; 11618 }; 11619 11620 /* OO emulation utility */ 11621 BX.extend = function(child, parent) 11622 { 11623 var f = function() {}; 11624 f.prototype = parent.prototype; 11625 11626 child.prototype = new f(); 11627 child.prototype.constructor = child; 11628 11629 child.superclass = parent.prototype; 11630 child.prototype.superclass = parent.prototype; 11631 if(parent.prototype.constructor == Object.prototype.constructor) 11632 { 11633 parent.prototype.constructor = parent; 11634 } 11635 }; 11636 11637 BX.is_subclass_of = function(ob, parent_class) 11638 { 11639 if (ob instanceof parent_class) 11640 return true; 11641 11642 if (parent_class.superclass) 11643 return BX.is_subclass_of(ob, parent_class.superclass); 11644 11645 return false; 11646 }; 11647 11648 BX.clearNodeCache = function() 11649 { 11650 return false; 11651 }; 11652 11653 BX.bitrix_sessid = function() {return BX.message("bitrix_sessid"); }; 11654 11655 /** 11656 * Creates document fragment with child nodes. 11657 * 11658 * @param {Node[]} nodes 11659 * @return {DocumentFragment} 11660 */ 11661 BX.createFragment = function(nodes) 11662 { 11663 var fragment = document.createDocumentFragment(); 11664 11665 if(!BX.type.isArray(nodes)) 11666 { 11667 return fragment; 11668 } 11669 for(var i = 0; i < nodes.length; i++) 11670 { 11671 fragment.appendChild(nodes[i]); 11672 } 11673 11674 return fragment; 11675 }; 11676 11677 /** 11678 * @deprecated 11679 * @use BX.style 11680 * @param element 11681 * @param opacity 11682 */ 11683 BX.setOpacity = function(element, opacity) 11684 { 11685 var opacityValue = parseFloat(opacity); 11686 11687 if (!isNaN(opacityValue) && BX.type.isDomNode(element)) 11688 { 11689 opacityValue = opacityValue < 1 ? opacityValue : opacityValue / 100; 11690 BX.style(element, 'opacity', opacityValue); 11691 } 11692 }; 11693 11694 /** 11695 * @deprecated 11696 * @param el 11697 * @return {*} 11698 */ 11699 BX.hoverEvents = function(el) 11700 { 11701 if (el) 11702 return BX.adjust(el, {events: BX.hoverEvents()}); 11703 else 11704 return {mouseover: BX.hoverEventsHover, mouseout: BX.hoverEventsHout}; 11705 }; 11706 11707 /** 11708 * @deprecated 11709 */ 11710 BX.hoverEventsHover = function(){BX.addClass(this,'bx-hover');this.BXHOVER=true;}; 11711 /** 11712 * @deprecated 11713 */ 11714 BX.hoverEventsHout = function(){BX.removeClass(this,'bx-hover');this.BXHOVER=false;}; 11715 11716 /** 11717 * @deprecated 11718 */ 11719 BX.focusEvents = function(el) 11720 { 11721 if (el) 11722 return BX.adjust(el, {events: BX.focusEvents()}); 11723 else 11724 return {mouseover: BX.focusEventsFocus, mouseout: BX.focusEventsBlur}; 11725 }; 11726 11727 /** 11728 * @deprecated 11729 */ 11730 BX.focusEventsFocus = function(){BX.addClass(this,'bx-focus');this.BXFOCUS=true;}; 11731 /** 11732 * @deprecated 11733 */ 11734 BX.focusEventsBlur = function(){BX.removeClass(this,'bx-focus');this.BXFOCUS=false;}; 11735 11736 BX.setUnselectable = function(node) 11737 { 11738 BX.style(node, { 11739 'userSelect': 'none', 11740 'MozUserSelect': 'none', 11741 'WebkitUserSelect': 'none', 11742 'KhtmlUserSelect': 'none', 11743 }); 11744 node.setAttribute('unSelectable', 'on'); 11745 }; 11746 11747 BX.setSelectable = function(node) 11748 { 11749 BX.style(node, { 11750 'userSelect': null, 11751 'MozUserSelect': null, 11752 'WebkitUserSelect': null, 11753 'KhtmlUserSelect': null, 11754 }); 11755 node.removeAttribute('unSelectable'); 11756 }; 11757 11758 BX.styleIEPropertyName = function(name) 11759 { 11760 if (name == 'float') 11761 name = BX.browser.IsIE() ? 'styleFloat' : 'cssFloat'; 11762 else 11763 { 11764 var res = BX.browser.isPropertySupported(name); 11765 if (res) 11766 { 11767 name = res; 11768 } 11769 else 11770 {
11771 var reg = /(\-([a-z]){1})/g; 11772 if (reg.test(name)) 11773 { 11774 name = name.replace(reg, function () {return arguments[2].toUpperCase();}); 11775 } 11776 } 11777 } 11778 return name; 11779 }; 11780 11781 BX.focus = function(el) 11782 { 11783 try 11784 { 11785 el.focus(); 11786 return true; 11787 } 11788 catch (e) 11789 { 11790 return false; 11791 } 11792 }; 11793 11794 BX.firstChild = function(el) 11795 { 11796 return BX.type.isDomNode(el) ? el.firstElementChild : null; 11797 }; 11798 11799 BX.lastChild = function(el) 11800 { 11801 return BX.type.isDomNode(el) ? el.lastElementChild : null; 11802 }; 11803 11804 BX.previousSibling = function(el) 11805 { 11806 return BX.type.isDomNode(el) ? el.previousElementSibling : null; 11807 }; 11808 11809 BX.nextSibling = function(el) 11810 { 11811 return BX.type.isDomNode(el) ? el.nextElementSibling : null; 11812 }; 11813 11814 /* 11815 params: { 11816 obj : html node 11817 className : className value 11818 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 11819 } 11820 11821 Search all nodes with className 11822 */ 11823 /** 11824 * @deprecated 11825 * @use .querySelectorAll 11826 * @param obj 11827 * @param className 11828 * @param recursive 11829 * @return {*} 11830 */ 11831 BX.findChildrenByClassName = function(obj, className, recursive) 11832 { 11833 if(!obj || !obj.childNodes) return null; 11834 11835 var result = []; 11836 if (typeof(obj.getElementsByClassName) == 'undefined') 11837 { 11838 recursive = recursive !== false; 11839 result = BX.findChildren(obj, {className : className}, recursive); 11840 } 11841 else 11842 { 11843 var col = obj.getElementsByClassName(className); 11844 for (i=0,l=col.length;i<l;i++) 11845 { 11846 result[i] = col[i]; 11847 } 11848 } 11849 return result; 11850 }; 11851 11852 /* 11853 params: { 11854 obj : html node 11855 className : className value 11856 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 11857 } 11858 11859 Search first node with className 11860 */ 11861 /** 11862 * @deprecated 11863 * @use .querySelector 11864 * @param obj 11865 * @param className 11866 * @param recursive 11867 * @return {*} 11868 */ 11869 BX.findChildByClassName = function(obj, className, recursive) 11870 { 11871 if(!obj || !obj.childNodes) return null; 11872 11873 var result = null; 11874 if (typeof(obj.getElementsByClassName) == 'undefined') 11875 { 11876 recursive = recursive !== false; 11877 result = BX.findChild(obj, {className : className}, recursive); 11878 } 11879 else 11880 { 11881 var col = obj.getElementsByClassName(className); 11882 if (col && typeof(col[0]) != 'undefined') 11883 { 11884 result = col[0]; 11885 } 11886 else 11887 { 11888 result = null; 11889 } 11890 } 11891 return result; 11892 }; 11893 11894 /* 11895 params: { 11896 tagName|tag : 'tagName', 11897 className|class : 'className', 11898 attribute : {attribute : value, attribute : value} | attribute | [attribute, attribute....], 11899 property : {prop: value, prop: value} | prop | [prop, prop] 11900 } 11901 11902 all values can be RegExps or strings 11903 */ 11904 /** 11905 * @deprecated 11906 * @use .querySelectorAll 11907 * @param obj 11908 * @param params 11909 * @param recursive 11910 * @return {*|Node} 11911 */ 11912 BX.findChildren = function(obj, params, recursive) 11913 { 11914 return BX.findChild(obj, params, recursive, true); 11915 }; 11916 11917 /** 11918 * @deprecated 11919 * @use .querySelectorAll 11920 * @param obj 11921 * @param params 11922 * @param recursive 11923 * @param get_all 11924 * @return {*} 11925 */ 11926 BX.findChild = function(obj, params, recursive, get_all) 11927 { 11928 if(!obj || !obj.childNodes) return null; 11929 11930 recursive = !!recursive; get_all = !!get_all; 11931 11932 var n = obj.childNodes.length, result = []; 11933 11934 for (var j=0; j<n; j++) 11935 { 11936 var child = obj.childNodes[j]; 11937 11938 if (_checkNode(child, params)) 11939 { 11940 if (get_all) 11941 result.push(child); 11942 else 11943 return child; 11944 } 11945 11946 if(recursive == true) 11947 { 11948 var res = BX.findChild(child, params, recursive, get_all); 11949 if (res) 11950 { 11951 if (get_all) 11952 result = BX.util.array_merge(result, res); 11953 else 11954 return res; 11955 } 11956 } 11957 } 11958 11959 if (get_all || result.length > 0) 11960 return result; 11961 else 11962 return null; 11963 }; 11964 11965 /** 11966 * @deprecated 11967 * @use .closest() 11968 * @param obj 11969 * @param params 11970 * @param maxParent 11971 * @return {*} 11972 */ 11973 BX.findParent = function(obj, params, maxParent) 11974 { 11975 if(!obj) 11976 return null; 11977 11978 var o = obj; 11979 while(o.parentNode) 11980 { 11981 var parent = o.parentNode; 11982 11983 if (_checkNode(parent, params)) 11984 return parent; 11985 11986 o = parent; 11987 11988 if (!!maxParent &&
11989 (BX.type.isFunction(maxParent) 11990 || typeof maxParent == 'object')) 11991 { 11992 if (BX.type.isElementNode(maxParent)) 11993 { 11994 if (o == maxParent) 11995 break; 11996 } 11997 else 11998 { 11999 if (_checkNode(o, maxParent)) 12000 break; 12001 } 12002 } 12003 } 12004 return null; 12005 }; 12006 12007 /** 12008 * @deprecated 12009 * @use .querySelector 12010 * @param obj 12011 * @param params 12012 * @return {*} 12013 */ 12014 BX.findNextSibling = function(obj, params) 12015 { 12016 if(!obj) 12017 return null; 12018 var o = obj; 12019 while(o.nextSibling) 12020 { 12021 var sibling = o.nextSibling; 12022 if (_checkNode(sibling, params)) 12023 return sibling; 12024 o = sibling; 12025 } 12026 return null; 12027 }; 12028 12029 /** 12030 * @deprecated 12031 * @use .querySelector 12032 * @param obj 12033 * @param params 12034 * @return {*} 12035 */ 12036 BX.findPreviousSibling = function(obj, params) 12037 { 12038 if(!obj) 12039 return null; 12040 12041 var o = obj; 12042 while(o.previousSibling) 12043 { 12044 var sibling = o.previousSibling; 12045 if(_checkNode(sibling, params)) 12046 return sibling; 12047 o = sibling; 12048 } 12049 return null; 12050 }; 12051 12052 BX.checkNode = function(obj, params) 12053 { 12054 return _checkNode(obj, params); 12055 }; 12056 12057 /** 12058 * @deprecated 12059 * @use .querySelectorAll 12060 * @param form 12061 * @return {Array} 12062 */ 12063 BX.findFormElements = function(form) 12064 { 12065 if (BX.type.isString(form)) 12066 form = document.forms[form]||BX(form); 12067 12068 var res = []; 12069 12070 if (BX.type.isElementNode(form)) 12071 { 12072 if (form.tagName.toUpperCase() == 'FORM') 12073 { 12074 res = form.elements; 12075 } 12076 else 12077 { 12078 res = BX.findChildren(form, CHECK_FORM_ELEMENTS, true); 12079 } 12080 } 12081 12082 return res; 12083 }; 12084 12085 /** 12086 * @deprecated 12087 * @use .contains() 12088 * @param whichNode 12089 * @param forNode 12090 * @return {boolean} 12091 */ 12092 BX.isParentForNode = function(whichNode, forNode) 12093 { 12094 if (BX.type.isDomNode(whichNode) && BX.type.isDomNode(forNode)) 12095 { 12096 return whichNode.contains(forNode); 12097 } 12098 12099 return false; 12100 }; 12101 12102 BX.getCaretPosition = function(node) 12103 { 12104 var pos = 0; 12105 12106 if(node.selectionStart || node.selectionStart == 0) 12107 { 12108 pos = node.selectionStart; 12109 } 12110 else if(document.selection) 12111 { 12112 node.focus(); 12113 var selection = document.selection.createRange(); 12114 selection.moveStart('character', -node.value.length); 12115 pos = selection.text.length; 12116 } 12117 12118 return (pos); 12119 }; 12120 12121 BX.setCaretPosition = function(node, pos) 12122 { 12123 if(!BX.isNodeInDom(node) || BX.isNodeHidden(node) || node.disabled) 12124 { 12125 return; 12126 } 12127 12128 if(node.setSelectionRange) 12129 { 12130 node.focus(); 12131 node.setSelectionRange(pos, pos); 12132 } 12133 else if(node.createTextRange) 12134 { 12135 var range = node.createTextRange(); 12136 range.collapse(true); 12137 range.moveEnd('character', pos); 12138 range.moveStart('character', pos); 12139 range.select(); 12140 } 12141 }; 12142 12143 // access private. use BX.mergeEx instead. 12144 // todo: refactor BX.merge, make it work through BX.mergeEx 12145 BX.merge = function(){ 12146 var arg = Array.prototype.slice.call(arguments); 12147 12148 if(arg.length < 2) 12149 return {}; 12150 12151 var result = arg.shift(); 12152 12153 for(var i = 0; i < arg.length; i++) 12154 { 12155 for(var k in arg[i]){ 12156 12157 if(typeof arg[i] == 'undefined' || arg[i] == null) 12158 continue; 12159 12160 if(arg[i].hasOwnProperty(k)){ 12161 12162 if(typeof arg[i][k] == 'undefined' || arg[i][k] == null) 12163 continue; 12164 12165 if(typeof arg[i][k] == 'object' && !BX.type.isDomNode(arg[i][k]) && (typeof arg[i][k]['isUIWidget'] == 'undefined')){ 12166 12167 // go deeper 12168 12169 var isArray = 'length' in arg[i][k]; 12170 12171 if(typeof result[k] != 'object') 12172 result[k] = isArray ? [] : {}; 12173 12174 if(isArray) 12175 BX.util.array_merge(result[k], arg[i][k]); 12176 else 12177 BX.merge(result[k], arg[i][k]); 12178 12179 }else 12180 result[k] = arg[i][k]; 12181 } 12182 } 12183 } 12184 12185 return result; 12186 }; 12187 12188 BX.mergeEx = function() 12189 { 12190 var arg = Array.prototype.slice.call(arguments); 12191 if(arg.length < 2) 12192 { 12193 return {}; 12194 } 12195 12196 var result = arg.shift(); 12197 for (var i = 0; i < arg.length; i++) 12198 { 12199 for (var k in arg[i]) 12200 { 12201 if (typeof arg[i] == "undefined" || arg[i] == null || !arg[i].hasOwnProperty(k)) 12202 { 12203 continue; 12204 } 12205 12206 if (BX.type.isPlainObject(arg[i][k]) && BX.type.isPlainObject(result[k])) 12207 { 12208 BX.mergeEx(result[k], arg[i][k]); 12209 } 12210 else 12211 { 12212 result[k] = BX.type.isPlainObject(arg[i][k]) ? BX.clone(arg[i][k]) : arg[i][k]; 12213 } 12214 } 12215 } 12216 12217 return result; 12218 }; 12219 12220 BX.getEventButton = function(e) 12221 { 12222 e = e || window.event; 12223 12224 var flags = 0; 12225 12226 if (typeof e.which != 'undefined') 12227 { 12228 switch (e.which) 12229 { 12230 case 1: flags = flags|BX.MSLEFT; break; 12231 case 2: flags = flags|BX.MSMIDDLE; break; 12232 case 3: flags = flags|BX.MSRIGHT; break; 12233 } 12234 } 12235 else if (typeof e.button != 'undefined') 12236 { 12237 flags = event.button; 12238 } 12239 12240 return flags || BX.MSLEFT; 12241 }; 12242 12243 var captured_events = null, _bind = null; 12244 BX.CaptureEvents = function(el_c, evname_c) 12245 { 12246 if (_bind) 12247 return; 12248 12249 _bind = BX.bind; 12250 captured_events = []; 12251 12252 BX.bind = function(el, evname, func) 12253 { 12254 if (el === el_c && evname === evname_c) 12255 captured_events.push(func); 12256 12257 _bind.apply(this, arguments); 12258 } 12259 }; 12260 12261 BX.CaptureEventsGet = function() 12262 { 12263 if (_bind) 12264 { 12265 BX.bind = _bind; 12266 12267 var captured = captured_events; 12268 12269 _bind = null; 12270 captured_events = null; 12271 return captured; 12272 } 12273 return null; 12274 }; 12275 12276 // Don't even try to use it for submit event! 12277 BX.fireEvent = function(ob,ev) 12278 { 12279 var result = false, e = null; 12280 if (BX.type.isDomNode(ob)) 12281 { 12282 result = true; 12283 if (document.createEventObject) 12284 { 12285 // IE 12286 if (eventTypes[ev] != 'MouseEvent') 12287 { 12288 e = document.createEventObject(); 12289 e.type = ev; 12290 result = ob.fireEvent('on' + ev, e); 12291 } 12292 12293 if (ob[ev]) 12294 { 12295 ob[ev](); 12296 } 12297 } 12298 else 12299 {
12300 // non-IE 12301 e = null; 12302 12303 switch (eventTypes[ev]) 12304 { 12305 case 'MouseEvent': 12306 e = document.createEvent('MouseEvent'); 12307 try 12308 { 12309 e.initMouseEvent(ev, true, true, top, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12310 } 12311 catch (initException) 12312 { 12313 e.initMouseEvent(ev, true, true, window, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12314 } 12315 12316 break; 12317 default: 12318 e = document.createEvent('Event'); 12319 e.initEvent(ev, true, true); 12320 } 12321 12322 result = ob.dispatchEvent(e); 12323 } 12324 } 12325 12326 return result; 12327 }; 12328 12329 BX.getWheelData = function(e) 12330 { 12331 e = e || window.event; 12332 e.wheelData = e.detail ? e.detail * -1 : e.wheelDelta / 40; 12333 return e.wheelData; 12334 }; 12335 12336 BX.proxy_context = null; 12337 12338 BX.delegate = function (func, thisObject) 12339 { 12340 if (!func || !thisObject) 12341 return func; 12342 12343 return function() { 12344 var cur = BX.proxy_context; 12345 BX.proxy_context = this; 12346 var res = func.apply(thisObject, arguments); 12347 BX.proxy_context = cur; 12348 return res; 12349 } 12350 }; 12351 12352 BX.delegateLater = function (func_name, thisObject, contextObject) 12353 { 12354 return function() 12355 { 12356 if (thisObject[func_name]) 12357 { 12358 var cur = BX.proxy_context; 12359 BX.proxy_context = this; 12360 var res = thisObject[func_name].apply(contextObject||thisObject, arguments); 12361 BX.proxy_context = cur; 12362 return res; 12363 } 12364 return null; 12365 } 12366 }; 12367 12368 BX.proxy = function(func, thisObject) 12369 { 12370 return getObjectDelegate(func, thisObject, proxyList); 12371 }; 12372 12373 BX.defer = function(func, thisObject) 12374 { 12375 if (!!thisObject) 12376 return BX.defer_proxy(func, thisObject); 12377 else 12378 return function() { 12379 var arg = arguments; 12380 setTimeout(function(){func.apply(this,arg)}, 10); 12381 }; 12382 }; 12383 12384 BX.defer_proxy = function(func, thisObject) 12385 { 12386 return getObjectDelegate(func, thisObject, deferList, BX.defer); 12387 }; 12388 12389 /** 12390 * 12391 * @private 12392 */ 12393 function getObjectDelegate(func, thisObject, collection, decorator) 12394 { 12395 if (!BX.type.isFunction(func) || !BX.type.isMapKey(thisObject)) 12396 { 12397 return func; 12398 } 12399 12400 var objectDelegates = collection.get(thisObject); 12401 if (!objectDelegates) 12402 { 12403 objectDelegates = new WeakMap(); 12404 collection.set(thisObject, objectDelegates); 12405 } 12406 12407 var delegate = objectDelegates.get(func); 12408 if (!delegate) 12409 { 12410 delegate = decorator ? decorator(BX.delegate(func, thisObject)) : BX.delegate(func, thisObject); 12411 objectDelegates.set(func, delegate); 12412 } 12413 12414 return delegate; 12415 } 12416 12417 BX.once = function(el, evname, func) 12418 { 12419 var fn = function() 12420 { 12421 BX.unbind(el, evname, fn); 12422 func.apply(this, arguments); 12423 }; 12424 12425 return fn; 12426 }; 12427 12428 BX.bindDelegate = function (elem, eventName, isTarget, handler) 12429 { 12430 var h = BX.delegateEvent(isTarget, handler); 12431 BX.bind(elem, eventName, h); 12432 return h; 12433 }; 12434 12435 BX.delegateEvent = function(isTarget, handler) 12436 { 12437 return function(e) 12438 { 12439 e = e || window.event; 12440 var target = e.target || e.srcElement; 12441 12442 while (target != this) 12443 { 12444 if (_checkNode(target, isTarget)) 12445 { 12446 return handler.call(target, e); 12447 } 12448 if (target && target.parentNode) 12449 target = target.parentNode; 12450 else 12451 break; 12452 } 12453 return null; 12454 } 12455 }; 12456 12457 BX.False = function() {return false;}; 12458 BX.DoNothing = function() {}; 12459 12460 // TODO: also check event handlers set via BX.bind() 12461 BX.denyEvent = function(el, ev) 12462 { 12463 deniedEvents.push([el, ev, el['on' + ev]]); 12464 el['on' + ev] = BX.DoNothing; 12465 }; 12466 12467 BX.allowEvent = function(el, ev) 12468 { 12469 for(var i=0, len=deniedEvents.length; i<len; i++) 12470 { 12471 if (deniedEvents[i][0] == el && deniedEvents[i][1] == ev) 12472 { 12473 el['on' + ev] = deniedEvents[i][2]; 12474 BX.util.deleteFromArray(deniedEvents, i); 12475 return; 12476 } 12477 } 12478 }; 12479 12480 BX.fixEventPageXY = function(event) 12481 { 12482 BX.fixEventPageX(event); 12483 BX.fixEventPageY(event); 12484 return event; 12485 }; 12486 12487 BX.fixEventPageX = function(event) 12488 { 12489 if (event.pageX == null && event.clientX != null) 12490 { 12491 event.pageX = 12492 event.clientX + 12493 (document.documentElement && document.documentElement.scrollLeft || document.body && document.body.scrollLeft || 0) - 12494 (document.documentElement.clientLeft || 0); 12495 } 12496 12497 return event; 12498 }; 12499 12500 BX.fixEventPageY = function(event) 12501 { 12502 if (event.pageY == null && event.clientY != null) 12503 { 12504 event.pageY = 12505 event.clientY + 12506 (document.documentElement && document.documentElement.scrollTop || document.body && document.body.scrollTop || 0) - 12507 (document.documentElement.clientTop || 0); 12508 } 12509 12510 return event; 12511 }; 12512 12513 /** 12514 * @deprecated 12515 * @see e.preventDefault() 12516 */ 12517 BX.PreventDefault = function(e) 12518 { 12519 if(!e) e = window.event; 12520 if(e.stopPropagation) 12521 { 12522 e.preventDefault(); 12523 e.stopPropagation(); 12524 } 12525 else 12526 { 12527 e.cancelBubble = true; 12528 e.returnValue = false;
12529 } 12530 return false; 12531 }; 12532 12533 /** 12534 * @deprecated 12535 * @see e.preventDefault(); 12536 * 12537 * @param e 12538 * @return {boolean} 12539 */ 12540 BX.eventReturnFalse = function(e) 12541 { 12542 e=e||window.event; 12543 if (e && e.preventDefault) e.preventDefault(); 12544 else e.returnValue = false; 12545 return false; 12546 }; 12547 12548 /** 12549 * @deprecated 12550 * @see e.stopPropagation() 12551 * @param e 12552 */ 12553 BX.eventCancelBubble = function(e) 12554 { 12555 e=e||window.event; 12556 if(e && e.stopPropagation) 12557 e.stopPropagation(); 12558 else 12559 e.cancelBubble = true; 12560 }; 12561 12562 BX.bindDebouncedChange = function(node, fn, fnInstant, timeout, ctx) 12563 { 12564 ctx = ctx || window; 12565 timeout = timeout || 300; 12566 12567 var dataTag = 'bx-dc-previous-value'; 12568 BX.data(node, dataTag, node.value); 12569 12570 var act = function(fn, val){ 12571 12572 var pVal = BX.data(node, dataTag); 12573 12574 if(typeof pVal == 'undefined' || pVal != val){ 12575 if(typeof ctx != 'object') 12576 fn(val); 12577 else 12578 fn.apply(ctx, [val]); 12579 } 12580 }; 12581 12582 var actD = BX.debounce(function(){ 12583 var val = node.value; 12584 act(fn, val); 12585 BX.data(node, dataTag, val); 12586 }, timeout); 12587 12588 BX.bind(node, 'keyup', actD); 12589 BX.bind(node, 'change', actD); 12590 BX.bind(node, 'input', actD); 12591 12592 if(BX.type.isFunction(fnInstant)){ 12593 12594 var actI = function(){ 12595 act(fnInstant, node.value); 12596 }; 12597 12598 BX.bind(node, 'keyup', actI); 12599 BX.bind(node, 'change', actI); 12600 BX.bind(node, 'input', actI); 12601 } 12602 }; 12603 12604 BX.parseJSON = function(data, context) 12605 { 12606 var result = null; 12607 if (BX.type.isNotEmptyString(data)) 12608 { 12609 try { 12610 if (data.indexOf("\n") >= 0) 12611 eval('result = ' + data); 12612 else 12613 result = (new Function("return " + data))(); 12614 } catch(e) { 12615 BX.onCustomEvent(context, 'onParseJSONFailure', [data, context]) 12616 } 12617 } 12618 else if(BX.type.isPlainObject(data)) 12619 { 12620 return data; 12621 } 12622 12623 return result; 12624 }; 12625 12626 BX.submit = function(obForm, action_name, action_value, onAfterSubmit) 12627 { 12628 action_name = action_name || 'save'; 12629 if (!obForm['BXFormSubmit_' + action_name]) 12630 { 12631 obForm['BXFormSubmit_' + action_name] = obForm.appendChild(BX.create('INPUT', { 12632 'props': { 12633 'type': 'submit', 12634 'name': action_name, 12635 'value': action_value || 'Y' 12636 }, 12637 'style': { 12638 'display': 'none' 12639 } 12640 })); 12641 } 12642 12643 if (obForm.sessid) 12644 obForm.sessid.value = BX.bitrix_sessid(); 12645 12646 setTimeout(BX.delegate(function() {BX.fireEvent(this, 'click'); if (onAfterSubmit) onAfterSubmit();}, obForm['BXFormSubmit_' + action_name]), 10); 12647 }; 12648 12649 BX.show = function(ob, displayType) 12650 { 12651 if (ob.BXDISPLAY || !_checkDisplay(ob, displayType)) 12652 { 12653 ob.style.display = ob.BXDISPLAY; 12654 } 12655 }; 12656 12657 BX.hide = function(ob, displayType) 12658 { 12659 if (!ob.BXDISPLAY) 12660 _checkDisplay(ob, displayType); 12661 12662 ob.style.display = 'none'; 12663 }; 12664 12665 BX.toggle = function(ob, values) 12666 { 12667 if (!values && BX.type.isElementNode(ob)) 12668 { 12669 var bShow = true; 12670 if (ob.BXDISPLAY) 12671 bShow = !_checkDisplay(ob); 12672 else 12673 bShow = ob.style.display == 'none'; 12674 12675 if (bShow) 12676 BX.show(ob); 12677 else 12678 BX.hide(ob); 12679 } 12680 else if (BX.type.isArray(values)) 12681 { 12682 for (var i=0,len=values.length; i<len; i++) 12683 { 12684 if (ob == values[i]) 12685 { 12686 ob = values[i==len-1 ? 0 : i+1]; 12687 break; 12688 } 12689 } 12690 if (i==len) 12691 ob = values[0]; 12692 } 12693 12694 return ob; 12695 }; 12696 12697 function _checkDisplay(ob, displayType) 12698 { 12699 if (typeof displayType != 'undefined') 12700 ob.BXDISPLAY = displayType; 12701 12702 var d = ob.style.display || BX.style(ob, 'display'); 12703 if (d != 'none') 12704 { 12705 ob.BXDISPLAY = ob.BXDISPLAY || d; 12706 return true; 12707 } 12708 else 12709 { 12710 ob.BXDISPLAY = ob.BXDISPLAY || 'block'; 12711 return false; 12712 } 12713 } 12714 12715 /* some useful util functions */ 12716 12717 BX.util = { 12718 /** 12719 * @deprecated 12720 * @use [].filter(value => !BX.Type.isNil(value)) 12721 * @param ar 12722 * @return {*} 12723 */ 12724 array_values: function(ar) 12725 { 12726 if (!BX.type.isArray(ar)) 12727 return BX.util._array_values_ob(ar); 12728 var arv = []; 12729 for(var i=0,l=ar.length;i<l;i++) 12730 if (ar[i] !== null && typeof ar[i] != 'undefined') 12731 arv.push(ar[i]); 12732 return arv; 12733 }, 12734 12735 /** 12736 * @deprecated 12737 * @use Object.values([]).filter(value => !BX.Type.isNil(value)) 12738 * @param ar 12739 * @return {Array} 12740 * @private 12741 */ 12742 _array_values_ob: function(ar) 12743 { 12744 var arv = []; 12745 for(var i in ar) 12746 if (ar[i] !== null && typeof ar[i] != 'undefined') 12747 arv.push(ar[i]); 12748 return arv; 12749 }, 12750 12751 /** 12752 * @deprecated 12753 * @use 12754 * @param ar 12755 * @return {*} 12756 */ 12757 array_keys: function(ar) 12758 { 12759 if (!BX.type.isArray(ar)) 12760 return BX.util._array_keys_ob(ar); 12761 var arv = []; 12762 for(var i=0,l=ar.length;i<l;i++) 12763 if (ar[i] !== null && typeof ar[i] != 'undefined') 12764 arv.push(i); 12765 return arv; 12766 }, 12767 12768 _array_keys_ob: function(ar) 12769 { 12770 var arv = []; 12771 for(var i in ar) 12772 if (ar[i] !== null && typeof ar[i] != 'undefined') 12773 arv.push(i); 12774 return arv; 12775 }, 12776 12777 object_keys: function(obj) 12778 { 12779 var arv = []; 12780 for(var k in obj) 12781 { 12782 if(obj.hasOwnProperty(k)) 12783 { 12784 arv.push(k); 12785 } 12786 } 12787 return arv; 12788 }, 12789 12790 /** 12791 * @deprecated 12792 * @use firstArr.concat(secondArr); 12793 * @param first 12794 * @param second 12795 * @return {*[]} 12796 */ 12797 array_merge: function(first, second) 12798 { 12799 if (!BX.type.isArray(first)) first = []; 12800 if (!BX.type.isArray(second)) second = []; 12801 12802 var i = first.length, j = 0; 12803 12804 if (typeof second.length === "number") 12805 { 12806 for (var l = second.length; j < l; j++) 12807 { 12808 first[i++] = second[j]; 12809 } 12810 } 12811 else 12812 {
12813 while (second[j] !== undefined) 12814 { 12815 first[i++] = second[j++]; 12816 } 12817 } 12818 12819 first.length = i; 12820 12821 return first; 12822 }, 12823 12824 array_flip: function (object) 12825 { 12826 var newObject = {}; 12827 12828 for (var key in object) 12829 { 12830 newObject[object[key]] = key; 12831 } 12832 12833 return newObject; 12834 }, 12835 12836 array_diff: function(ar1, ar2, hash) 12837 { 12838 hash = BX.type.isFunction(hash) ? hash : null; 12839 var i, length, v, h, map = {}, result = []; 12840 for(i = 0, length = ar2.length; i < length; i++) 12841 { 12842 v = ar2[i]; 12843 h = hash ? hash(v) : v; 12844 map[h] = true; 12845 } 12846 12847 for(i = 0, length = ar1.length; i < length; i++) 12848 { 12849 v = ar1[i]; 12850 h = hash ? hash(v) : v; 12851 if(typeof(map[h]) === "undefined") 12852 { 12853 result.push(v); 12854 } 12855 } 12856 return result; 12857 }, 12858 12859 /** 12860 * @deprecated 12861 * @use Set 12862 */ 12863 array_unique: function(ar) 12864 { 12865 var i=0,j,len=ar.length; 12866 if(len<2) return ar; 12867 12868 for (; i<len-1;i++) 12869 { 12870 for (j=i+1; j<len;j++) 12871 { 12872 if (ar[i]==ar[j]) 12873 { 12874 ar.splice(j--,1); len--; 12875 } 12876 } 12877 } 12878 12879 return ar; 12880 }, 12881 12882 /** 12883 * @deprecated 12884 * @use myArr.includes(needle) 12885 */ 12886 in_array: function(needle, haystack) 12887 { 12888 for(var i=0; i<haystack.length; i++) 12889 { 12890 if(haystack[i] == needle) 12891 return true; 12892 } 12893 return false; 12894 }, 12895 12896 /** 12897 * @deprecated 12898 * @use myArr.findIndex(item => item === needle); 12899 */ 12900 array_search: function(needle, haystack) 12901 { 12902 for(var i=0; i<haystack.length; i++) 12903 { 12904 if(haystack[i] == needle) 12905 return i; 12906 } 12907 return -1; 12908 }, 12909 12910 object_search_key: function(needle, haystack) 12911 { 12912 if (typeof haystack[needle] != 'undefined') 12913 return haystack[needle]; 12914 12915 for(var i in haystack) 12916 { 12917 if (typeof haystack[i] == "object") 12918 { 12919 var result = BX.util.object_search_key(needle, haystack[i]); 12920 if (result !== false) 12921 return result; 12922 } 12923 } 12924 return false; 12925 }, 12926 12927 trim: function(s) 12928 { 12929 if (BX.type.isString(s)) 12930 { 12931 return s.trim(); 12932 } 12933 12934 return s; 12935 }, 12936 12937 urlencode: function(s){return encodeURIComponent(s);}, 12938 12939 // it may also be useful. via sVD. 12940 deleteFromArray: function(ar, ind) {return ar.slice(0, ind).concat(ar.slice(ind + 1));}, 12941 insertIntoArray: function(ar, ind, el) {return ar.slice(0, ind).concat([el]).concat(ar.slice(ind));}, 12942 12943 htmlspecialchars: function(str) 12944 { 12945 return BX.Text.encode(str); 12946 }, 12947 12948 htmlspecialcharsback: function(str) 12949 { 12950 return BX.Text.decode(str); 12951 }, 12952 12953 // Quote regular expression characters plus an optional character 12954 preg_quote: function(str, delimiter) 12955 { 12956 if(!str.replace) 12957 return str; 12958 return str.replace(new RegExp('[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + (delimiter || '') + '-]', 'g'), '\\$&'); 12959 }, 12960 12961 jsencode: function(str) 12962 { 12963 if (!str || !str.replace) 12964 return str; 12965 12966 var escapes = 12967 [ 12968 { c: "\\\\", r: "\\\\" }, // should be first 12969 { c: "\\t", r: "\\t" }, 12970 { c: "\\n", r: "\\n" }, 12971 { c: "\\r", r: "\\r" }, 12972 { c: "\"", r: "\\\"" }, 12973 { c: "'", r: "\\'" }, 12974 { c: "<", r: "\\x3C" }, 12975 { c: ">", r: "\\x3E" }, 12976 { c: "\\u2028", r: "\\u2028" }, 12977 { c: "\\u2029", r: "\\u2029" } 12978 ]; 12979 for (var i = 0; i < escapes.length; i++) 12980 str = str.replace(new RegExp(escapes[i].c, 'g'), escapes[i].r); 12981 return str; 12982 }, 12983 12984 getCssName: function(jsName) 12985 { 12986 if (!BX.type.isNotEmptyString(jsName)) 12987 { 12988 return ""; 12989 } 12990 12991 return jsName.replace(/[A-Z]/g, function(match) { 12992 return "-" + match.toLowerCase(); 12993 }); 12994 }, 12995 12996 getJsName: function(cssName) 12997 { 12998 var regex = /\-([a-z]){1}/g; 12999 if (regex.test(cssName)) 13000 { 13001 return cssName.replace(regex, function(match, letter) { 13002 return letter.toUpperCase(); 13003 }); 13004 } 13005 13006 return cssName; 13007 }, 13008 13009 nl2br: function(str) 13010 { 13011 if (!str || !str.replace) 13012 return str; 13013 13014 return str.replace(/([^>])\n/g, '$1<br/>'); 13015 }, 13016 13017 /** 13018 * @deprecated 13019 * @use .padStart() / .padEnd() 13020 * @param input 13021 * @param pad_length 13022 * @param pad_string 13023 * @param pad_type 13024 * @return {*} 13025 */ 13026 str_pad: function(input, pad_length, pad_string, pad_type) 13027 { 13028 pad_string = pad_string || ' '; 13029 pad_type = pad_type || 'right'; 13030 input = input.toString(); 13031 13032 if (pad_type === 'left') 13033 { 13034 return BX.util.str_pad_left(input, pad_length, pad_string); 13035 } 13036 13037 return BX.util.str_pad_right(input, pad_length, pad_string); 13038 }, 13039 13040 str_pad_left: function(input, pad_length, pad_string) 13041 { 13042 return input.toString().padStart(pad_length, pad_string); 13043 }, 13044 13045 str_pad_right: function(input, pad_length, pad_string) 13046 { 13047 return input.toString().padEnd(pad_length, pad_string); 13048 }, 13049 13050 strip_tags: function(str) 13051 { 13052 return str.split(/<[^>]+>/g).join(''); 13053 }, 13054 13055 strip_php_tags: function(str) 13056 { 13057 return str.replace(/<\?(.|[\r\n])*?\?>/g, ''); 13058 }, 13059 13060 popup: function(url, width, height) 13061 { 13062 var w, h; 13063 if(BX.browser.IsOpera()) 13064 { 13065 w = document.body.offsetWidth; 13066 h = document.body.offsetHeight; 13067 } 13068 else 13069 {
13070 w = screen.width; 13071 h = screen.height; 13072 } 13073 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)); 13074 }, 13075 13076 shuffle: function(array) 13077 { 13078 var temporaryValue, randomIndex; 13079 var currentIndex = array.length; 13080 13081 while (0 !== currentIndex) 13082 { 13083 randomIndex = Math.floor(Math.random() * currentIndex); 13084 currentIndex -= 1; 13085 13086 temporaryValue = array[currentIndex]; 13087 array[currentIndex] = array[randomIndex]; 13088 array[randomIndex] = temporaryValue; 13089 } 13090 13091 return array; 13092 }, 13093 13094 // BX.util.objectSort(object, sortBy, sortDir) - Sort object by property 13095 // function params: 1 - object for sort, 2 - sort by property, 3 - sort direction (asc/desc) 13096 // return: sort array [[objectElement], [objectElement]] in sortDir direction 13097 13098 // example: BX.util.objectSort({'L1': {'name': 'Last'}, 'F1': {'name': 'First'}}, 'name', 'asc'); 13099 // return: [{'name' : 'First'}, {'name' : 'Last'}] 13100 objectSort: function(object, sortBy, sortDir) 13101 { 13102 sortDir = sortDir == 'asc'? 'asc': 'desc'; 13103 13104 var arItems = [], i; 13105 for (i in object) 13106 { 13107 if (object.hasOwnProperty(i) && object[i][sortBy]) 13108 { 13109 arItems.push([i, object[i][sortBy]]); 13110 } 13111 } 13112 13113 if (sortDir == 'asc') 13114 { 13115 arItems.sort(function(i, ii) { 13116 var s1, s2; 13117 if (BX.type.isDate(i[1])) 13118 { 13119 s1 = i[1].getTime(); 13120 } 13121 else if (!isNaN(i[1])) 13122 { 13123 s1 = parseInt(i[1]); 13124 } 13125 else 13126 { 13127 s1 = i[1].toString().toLowerCase(); 13128 } 13129 13130 if (BX.type.isDate(ii[1])) 13131 { 13132 s2 = ii[1].getTime(); 13133 } 13134 else if (!isNaN(ii[1])) 13135 { 13136 s2 = parseInt(ii[1]); 13137 } 13138 else 13139 { 13140 s2 = ii[1].toString().toLowerCase(); 13141 } 13142 13143 if (s1 > s2) 13144 return 1; 13145 else if (s1 < s2) 13146 return -1; 13147 else 13148 return 0; 13149 }); 13150 } 13151 else 13152 { 13153 arItems.sort(function(i, ii) { 13154 var s1, s2; 13155 if (BX.type.isDate(i[1])) 13156 { 13157 s1 = i[1].getTime(); 13158 } 13159 else if (!isNaN(i[1])) 13160 { 13161 s1 = parseInt(i[1]); 13162 } 13163 else 13164 { 13165 s1 = i[1].toString().toLowerCase(); 13166 } 13167 13168 if (BX.type.isDate(ii[1])) 13169 { 13170 s2 = ii[1].getTime(); 13171 } 13172 else if (!isNaN(ii[1])) 13173 { 13174 s2 = parseInt(ii[1]); 13175 } 13176 else 13177 { 13178 s2 = ii[1].toString().toLowerCase(); 13179 } 13180 13181 if (s1 < s2) 13182 return 1; 13183 else if (s1 > s2) 13184 return -1; 13185 else 13186 return 0; 13187 }); 13188 } 13189 13190 var arReturnArray = Array(); 13191 for (i = 0; i < arItems.length; i++) 13192 { 13193 arReturnArray.push(object[arItems[i][0]]); 13194 } 13195 13196 return arReturnArray; 13197 }, 13198 13199 objectMerge: function() 13200 { 13201 return BX.mergeEx.apply(window, arguments); 13202 }, 13203 13204 objectClone : function(object) 13205 { 13206 return BX.clone(object, true); 13207 }, 13208 13209 // #fdf9e5 => {r=253, g=249, b=229} 13210 hex2rgb: function(color) 13211 { 13212 var rgb = color.replace(/[# ]/g,"").replace(/^(.)(.)(.)$/,'$1$1$2$2$3$3').match(/.{2}/g); 13213 for (var i=0; i<3; i++) 13214 { 13215 rgb[i] = parseInt(rgb[i], 16); 13216 } 13217 return {'r':rgb[0],'g':rgb[1],'b':rgb[2]}; 13218 }, 13219 13220 /** 13221 * @deprecated 13222 * @use BX.Uri 13223 * @param url 13224 * @param param 13225 * @return {string} 13226 */ 13227 remove_url_param: function(url, param) 13228 { 13229 return BX.Uri.removeParam(url, param); 13230 }, 13231 13232 /* 13233 {'param1': 'value1', 'param2': 'value2'} 13234 */ 13235 /** 13236 * @deprecated 13237 * @use BX.Uri 13238 * @param url 13239 * @param params 13240 * @return {string} 13241 */ 13242 add_url_param: function(url, params) 13243 { 13244 var preparedParams = Object.entries(params).reduce(function(acc, item) { 13245 acc[item[0]] = BX.type.isArray(item[1]) ? item[1].join() : item[1]; 13246 return acc; 13247 }, {}); 13248 13249 return BX.Uri.addParam(url, preparedParams); 13250 }, 13251 13252 /* 13253 {'param1': 'value1', 'param2': 'value2'} 13254 */ 13255 buildQueryString: function(params) 13256 { 13257 var result = ''; 13258 for (var key in params) 13259 { 13260 var value = params[key]; 13261 if(BX.type.isArray(value)) 13262 { 13263 value.forEach(function(valueElement, index) 13264 { 13265 result += encodeURIComponent(key + "[" + index + "]") + "=" + encodeURIComponent(valueElement) + "&"; 13266 }); 13267 } 13268 else 13269 { 13270 result += encodeURIComponent(key) + "=" + encodeURIComponent(value) + "&"; 13271 } 13272 } 13273 13274 if(result.length > 0) 13275 { 13276 result = result.substr(0, result.length - 1); 13277 } 13278 return result; 13279 }, 13280 13281 even: function(digit) 13282 { 13283 return (parseInt(digit) % 2 == 0); 13284 }, 13285 13286 hashCode: function(str) 13287 { 13288 if(!BX.type.isNotEmptyString(str)) 13289 { 13290 return 0; 13291 } 13292 13293 var hash = 0; 13294 for (var i = 0; i < str.length; i++) 13295 { 13296 var c = str.charCodeAt(i); 13297 hash = ((hash << 5) - hash) + c; 13298 hash = hash & hash; 13299 } 13300 return hash; 13301 }, 13302 13303 getRandomString: function (length) 13304 { 13305 return BX.Text.getRandom(length); 13306 }, 13307 13308 number_format: function(number, decimals, dec_point, thousands_sep) 13309 { 13310 var i, j, kw, kd, km, sign = ''; 13311 decimals = Math.abs(decimals); 13312 if (isNaN(decimals) || decimals < 0) 13313 { 13314 decimals = 2; 13315 } 13316 dec_point = dec_point || ','; 13317 if (typeof thousands_sep === 'undefined') 13318 thousands_sep = '.'; 13319 13320 number = (+number || 0).toFixed(decimals); 13321 if (number < 0) 13322 { 13323 sign = '-'; 13324 number = -number; 13325 } 13326 13327 i = parseInt(number, 10) + ''; 13328 j = (i.length > 3 ? i.length % 3 : 0); 13329 13330 km = (j ? i.substr(0, j) + thousands_sep : ''); 13331 kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep); 13332 kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, '0').slice(2) : ''); 13333 13334 return sign + km + kw + kd; 13335 }, 13336 13337 getExtension: function (url) 13338 { 13339 url = url || ""; 13340 var items = url.split("?")[0].split("."); 13341 return items[items.length-1].toLowerCase(); 13342 }, 13343 addObjectToForm: function(object, form, prefix) 13344 { 13345 if(!BX.type.isString(prefix)) 13346 { 13347 prefix = ""; 13348 } 13349 13350 for(var key in object) 13351 { 13352 if(!object.hasOwnProperty(key)) 13353 { 13354 continue; 13355 } 13356 13357 var value = object[key]; 13358 var name = prefix !== "" ? (prefix + "[" + key + "]") : key; 13359 if(BX.type.isArray(value)) 13360 { 13361 var obj = {}; 13362 for(var i = 0; i < value.length; i++) 13363 { 13364 obj[i] = value[i]; 13365 } 13366 13367 BX.util.addObjectToForm(obj, form, name); 13368 } 13369 else if(BX.type.isPlainObject(value)) 13370 { 13371 BX.util.addObjectToForm(value, form, name); 13372 } 13373 else 13374 { 13375 value = BX.type.isFunction(value.toString) ? value.toString() : ""; 13376 if(value !== "") 13377 { 13378 form.appendChild(BX.create("INPUT", { attrs: { type: "hidden", name: name, value: value } })); 13379 } 13380 } 13381 } 13382 }, 13383 13384 observe: function(object, enable) 13385 {
13386 console.error('BX.util.observe: function is no longer supported by browser.'); 13387 return false; 13388 }, 13389 13390 escapeRegExp: function(str) 13391 { 13392 return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); 13393 } 13394 }; 13395 13396 BX.validation = { 13397 checkIfEmail: function(s) 13398 { 13399 var atom = "[=a-z0-9_+~'!$&*^`|#%/?{}-]"; 13400 return (new RegExp('^\\s*'+atom+'+(\\.'+atom+'+)*@([a-z0-9-]+\\.)+[a-z0-9-]{2,20}\\s*$', 'i')).test(s); 13401 }, 13402 checkIfPhone: function(s) 13403 { 13404 var regexp = new RegExp( 13405 typeof(BX.PhoneNumber) === "undefined" 13406 ? BX.PhoneNumber.getValidNumberPattern() 13407 : '^\\s*\\+?\s*[0-9(-)\\s]+\\s*$', 13408 'i' 13409 ); 13410 return regexp.test(s); 13411 } 13412 }; 13413 13414 BX.prop = 13415 { 13416 get: function(object, key, defaultValue) 13417 { 13418 return object && object.hasOwnProperty(key) ? object[key] : defaultValue; 13419 }, 13420 getObject: function(object, key, defaultValue) 13421 { 13422 return object && BX.type.isPlainObject(object[key]) ? object[key] : defaultValue; 13423 }, 13424 getElementNode: function(object, key, defaultValue) 13425 { 13426 return object && BX.type.isElementNode(object[key]) ? object[key] : defaultValue; 13427 }, 13428 getArray: function(object, key, defaultValue) 13429 { 13430 return object && BX.type.isArray(object[key]) ? object[key] : defaultValue; 13431 }, 13432 getFunction: function(object, key, defaultValue) 13433 { 13434 return object && BX.type.isFunction(object[key]) ? object[key] : defaultValue; 13435 }, 13436 getNumber: function(object, key, defaultValue) 13437 { 13438 if(!(object && object.hasOwnProperty(key))) 13439 { 13440 return defaultValue; 13441 } 13442 13443 var value = object[key]; 13444 if(BX.type.isNumber(value)) 13445 { 13446 return value; 13447 } 13448 13449 value = parseFloat(value); 13450 return !isNaN(value) ? value : defaultValue; 13451 }, 13452 getInteger: function(object, key, defaultValue) 13453 { 13454 if(!(object && object.hasOwnProperty(key))) 13455 { 13456 return defaultValue; 13457 } 13458 13459 var value = object[key]; 13460 if(BX.type.isNumber(value)) 13461 { 13462 return value; 13463 } 13464 13465 value = parseInt(value); 13466 return !isNaN(value) ? value : defaultValue; 13467 }, 13468 getBoolean: function(object, key, defaultValue) 13469 { 13470 if(!(object && object.hasOwnProperty(key))) 13471 { 13472 return defaultValue; 13473 } 13474 13475 var value = object[key]; 13476 return (BX.type.isBoolean(value) 13477 ? value 13478 : (BX.type.isString(value) ? (value.toLowerCase() === "true") : !!value) 13479 ); 13480 }, 13481 getString: function(object, key, defaultValue) 13482 { 13483 if(!(object && object.hasOwnProperty(key))) 13484 { 13485 return defaultValue; 13486 } 13487 13488 var value = object[key]; 13489 return BX.type.isString(value) ? value : (value ? value.toString() : ''); 13490 }, 13491 extractDate: function(datetime) 13492 { 13493 if(!BX.type.isDate(datetime)) 13494 { 13495 datetime = new Date(); 13496 } 13497 13498 datetime.setHours(0); 13499 datetime.setMinutes(0); 13500 datetime.setSeconds(0); 13501 datetime.setMilliseconds(0); 13502 13503 return datetime; 13504 } 13505 }; 13506 13507 BX.isNodeInDom = function(node, doc) 13508 { 13509 return node === (doc || document) ? true : 13510 (node.parentNode ? BX.isNodeInDom(node.parentNode) : false); 13511 }; 13512 13513 BX.isNodeHidden = function(node) 13514 { 13515 if (node === document) 13516 return false; 13517 else if (BX.style(node, 'display') == 'none') 13518 return true; 13519 else 13520 return (node.parentNode ? BX.isNodeHidden(node.parentNode) : true); 13521 }; 13522 13523 BX.evalPack = function(code) 13524 { 13525 while (code.length > 0) 13526 { 13527 var c = code.shift(); 13528 13529 if (c.TYPE == 'SCRIPT_EXT' || c.TYPE == 'SCRIPT_SRC') 13530 { 13531 BX.loadScript(c.DATA, function() {BX.evalPack(code)}); 13532 return; 13533 } 13534 else if (c.TYPE == 'SCRIPT') 13535 { 13536 BX.evalGlobal(c.DATA); 13537 } 13538 } 13539 }; 13540 13541 BX.evalGlobal = function(data) 13542 { 13543 if (data) 13544 { 13545 var head = document.getElementsByTagName("head")[0] || document.documentElement, 13546 script = document.createElement("script"); 13547 13548 script.type = "text/javascript"; 13549 13550 if (!BX.browser.IsIE()) 13551 { 13552 script.appendChild(document.createTextNode(data)); 13553 } 13554 else 13555 { 13556 script.text = data; 13557 } 13558 13559 head.insertBefore(script, head.firstChild); 13560 head.removeChild(script); 13561 } 13562 }; 13563 13564 BX.garbage = function(call, thisObject) 13565 { 13566 garbageCollectors.push({callback: call, context: thisObject}); 13567 }; 13568 13569 BX.GetDocElement = function (pDoc) 13570 { 13571 pDoc = pDoc || document; 13572 return (BX.browser.IsDoctype(pDoc) ? pDoc.documentElement : pDoc.body); 13573 }; 13574 13575 BX.scrollTop = function(node, val){ 13576 if(typeof val != 'undefined'){ 13577 13578 if(node == window){ 13579 throw new Error('scrollTop() for window is not implemented'); 13580 }else 13581 node.scrollTop = parseInt(val); 13582 13583 }else{ 13584 13585 if(node == window) 13586 return BX.GetWindowScrollPos().scrollTop; 13587 13588 return node.scrollTop; 13589 } 13590 }; 13591 13592 BX.scrollLeft = function(node, val){ 13593 if(typeof val != 'undefined'){ 13594 13595 if(node == window){ 13596 throw new Error('scrollLeft() for window is not implemented'); 13597 }else 13598 node.scrollLeft = parseInt(val); 13599 13600 }else{ 13601 13602 if(node == window) 13603 return BX.GetWindowScrollPos().scrollLeft; 13604 13605 return node.scrollLeft; 13606 } 13607 }; 13608 13609 BX.hide_object = function(ob) 13610 { 13611 ob = BX(ob); 13612 ob.style.position = 'absolute'; 13613 ob.style.top = '-1000px'; 13614 ob.style.left = '-1000px'; 13615 ob.style.height = '10px'; 13616 ob.style.width = '10px'; 13617 }; 13618 13619 BX.is_relative = function(el) 13620 { 13621 var p = BX.style(el, 'position'); 13622 return p == 'relative' || p == 'absolute'; 13623 }; 13624 13625 BX.is_float = function(el) 13626 { 13627 var p = BX.style(el, 'float'); 13628 return p == 'right' || p == 'left'; 13629 }; 13630 13631 BX.is_fixed = function(el) 13632 { 13633 var p = BX.style(el, 'position'); 13634 return p == 'fixed'; 13635 }; 13636 13637 BX.width = function(node, val){ 13638 if(typeof val != 'undefined') 13639 BX.style(node, 'width', parseInt(val)+'px'); 13640 else{ 13641 13642 if(node == window) 13643 return window.innerWidth; 13644 13645 //return parseInt(BX.style(node, 'width')); 13646 return BX.pos(node).width; 13647 } 13648 }; 13649 13650 BX.height = function(node, val){ 13651 if(typeof val != 'undefined') 13652 BX.style(node, 'height', parseInt(val)+'px'); 13653 else{ 13654 13655 if(node == window) 13656 return window.innerHeight; 13657 13658 //return parseInt(BX.style(node, 'height')); 13659 return BX.pos(node).height; 13660 } 13661 }; 13662 13663 BX.align = function(pos, w, h, type) 13664 { 13665 if (type) 13666 type = type.toLowerCase(); 13667 else 13668 type = ''; 13669 13670 var pDoc = document; 13671 if (BX.type.isElementNode(pos)) 13672 { 13673 pDoc = pos.ownerDocument; 13674 pos = BX.pos(pos); 13675 } 13676 13677 var x = pos["left"], y = pos["bottom"]; 13678 13679 var scroll = BX.GetWindowScrollPos(pDoc); 13680 var size = BX.GetWindowInnerSize(pDoc); 13681 13682 if((size.innerWidth + scroll.scrollLeft) - (pos["left"] + w) < 0) 13683 { 13684 if(pos["right"] - w >= 0 ) 13685 x = pos["right"] - w; 13686 else 13687 x = scroll.scrollLeft; 13688 } 13689
13690 if(((size.innerHeight + scroll.scrollTop) - (pos["bottom"] + h) < 0) || ~type.indexOf('top')) 13691 { 13692 if(pos["top"] - h >= 0 || ~type.indexOf('top')) 13693 y = pos["top"] - h; 13694 else 13695 y = scroll.scrollTop; 13696 } 13697 13698 return {'left':x, 'top':y}; 13699 }; 13700 13701 BX.scrollToNode = function(node) 13702 { 13703 var obNode = BX(node); 13704 13705 if (obNode.scrollIntoView) 13706 obNode.scrollIntoView(true); 13707 else 13708 { 13709 var arNodePos = BX.pos(obNode); 13710 window.scrollTo(arNodePos.left, arNodePos.top); 13711 } 13712 }; 13713 13714 /* non-xhr loadings */ 13715 BX.showWait = function(node, msg) 13716 { 13717 node = BX(node) || document.body || document.documentElement; 13718 msg = msg || BX.message('JS_CORE_LOADING'); 13719 13720 var container_id = node.id || Math.random(); 13721 13722 var obMsg = node.bxmsg = document.body.appendChild(BX.create('DIV', { 13723 props: { 13724 id: 'wait_' + container_id 13725 }, 13726 style: { 13727 background: 'url("/bitrix/js/main/core/images/wait.gif") no-repeat scroll 10px center #fcf7d1', 13728 border: '1px solid #E1B52D', 13729 color: 'black', 13730 fontFamily: 'Verdana,Arial,sans-serif', 13731 fontSize: '11px', 13732 padding: '10px 30px 10px 37px', 13733 position: 'absolute', 13734 textAlign:'center' 13735 }, 13736 text: msg 13737 })); 13738 13739 BX.ZIndexManager.register(obMsg); 13740 BX.ZIndexManager.bringToFront(obMsg); 13741 13742 setTimeout(BX.delegate(_adjustWait, node), 10); 13743 13744 lastWait[lastWait.length] = obMsg; 13745 return obMsg; 13746 }; 13747 13748 BX.closeWait = function(node, obMsg) 13749 { 13750 if(node && !obMsg) 13751 obMsg = node.bxmsg; 13752 if(node && !obMsg && BX.hasClass(node, 'bx-core-waitwindow')) 13753 obMsg = node; 13754 if(node && !obMsg) 13755 obMsg = BX('wait_' + node.id); 13756 if(!obMsg) 13757 obMsg = lastWait.pop(); 13758 13759 if (obMsg && obMsg.parentNode) 13760 { 13761 for (var i=0,len=lastWait.length;i<len;i++) 13762 { 13763 if (obMsg == lastWait[i]) 13764 { 13765 lastWait = BX.util.deleteFromArray(lastWait, i); 13766 break; 13767 } 13768 } 13769 13770 BX.ZIndexManager.unregister(obMsg); 13771 obMsg.parentNode.removeChild(obMsg); 13772 if (node) node.bxmsg = null; 13773 BX.cleanNode(obMsg, true); 13774 } 13775 }; 13776 13777 BX.setJSList = function(scripts) 13778 { 13779 if (BX.type.isArray(scripts)) 13780 { 13781 scripts = scripts.map(function(script) { 13782 return normalizeUrl(script) 13783 }); 13784 13785 jsList = jsList.concat(scripts); 13786 } 13787 }; 13788 13789 BX.getJSList = function() 13790 { 13791 initJsList(); 13792 return jsList; 13793 }; 13794 13795 BX.setCSSList = function(cssFiles) 13796 { 13797 if (BX.type.isArray(cssFiles)) 13798 { 13799 cssFiles = cssFiles.map(function(cssFile) { 13800 return normalizeUrl(cssFile); 13801 }); 13802 13803 cssList = cssList.concat(cssFiles); 13804 } 13805 }; 13806 13807 BX.getCSSList = function() 13808 { 13809 initCssList(); 13810 return cssList; 13811 }; 13812 13813 BX.getJSPath = function(js) 13814 { 13815 return js.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 13816 }; 13817 13818 BX.getCSSPath = function(css) 13819 { 13820 return css.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 13821 }; 13822 13823 BX.getCDNPath = function(path) 13824 { 13825 return path; 13826 }; 13827 13828 BX.loadScript = function(script, callback, doc) 13829 { 13830 if (BX.type.isString(script)) 13831 { 13832 script = [script]; 13833 } 13834 13835 return BX.load(script, callback, doc); 13836 }; 13837 13838 BX.loadCSS = function(css, doc, win) 13839 { 13840 if (BX.type.isString(css)) 13841 { 13842 css = [css]; 13843 } 13844 13845 if (BX.type.isArray(css)) 13846 { 13847 css = css.map(function(url) { 13848 return { url: url, ext: "css" } 13849 }); 13850 13851 BX.load(css, null, doc); 13852 } 13853 }; 13854 13855 const LOADING = 3; 13856 const LOADED = 4; 13857 const assets = {}; 13858 const loadingAssetCallbacks = {}; 13859 13860 BX.load = function(items, callback, doc) 13861 { 13862 if (!BX.isReady) 13863 { 13864 var _args = arguments; 13865 BX.ready(function() { 13866 BX.load.apply(this, _args); 13867 }); 13868 13869 return null; 13870 } 13871 13872 doc = doc || document; 13873 13874 callback = BX.Type.isFunction(callback) ? callback : () => {}; 13875 13876 return loadAsync(items, callback, doc); 13877 }; 13878 13879 function loadAsync(items, callback, doc) 13880 { 13881 if (!BX.type.isArray(items)) 13882 { 13883 callback(); 13884 13885 return; 13886 } 13887 13888 function onLoad() 13889 { 13890 const nextAsset = queue.shift(); 13891 if (nextAsset) 13892 { 13893 load(nextAsset, onLoad, doc); 13894 } 13895 else if (allLoaded()) 13896 { 13897 callback(); 13898 } 13899 } 13900 13901 function allLoaded() 13902 { 13903 for (const name in assetMap) 13904 { 13905 if (assetMap[name].state !== LOADED) 13906 { 13907 return false; 13908 } 13909 } 13910 13911 return true; 13912 } 13913 13914 const queue = []; 13915 const assetMap = {}; 13916 items.forEach(item => { 13917 const asset = getAsset(item); 13918 if (asset && asset.state !== LOADED) 13919 { 13920 queue.push(asset); 13921 assetMap[asset.name] = asset; 13922 } 13923 }); 13924 13925 if (queue.length > 0) 13926 {
13927 const maxParallelLoads = 6; 13928 const parallelLoads = Math.min(queue.length, maxParallelLoads); 13929 const firstPackage = queue.splice(0, parallelLoads); 13930 firstPackage.forEach(asset => { 13931 load(asset, onLoad, doc); 13932 }); 13933 } 13934 else 13935 { 13936 callback(); 13937 } 13938 } 13939 13940 function load(asset, callback, doc) 13941 { 13942 callback = callback || BX.DoNothing; 13943 13944 if (asset.state === LOADED) 13945 { 13946 callback(); 13947 return; 13948 } 13949 13950 if (asset.state === LOADING) 13951 { 13952 if (!BX.Type.isArray(loadingAssetCallbacks[asset.name])) 13953 { 13954 loadingAssetCallbacks[asset.name] = []; 13955 } 13956 13957 loadingAssetCallbacks[asset.name].push(callback); 13958 13959 return; 13960 } 13961 13962 asset.state = LOADING; 13963 13964 loadAsset( 13965 asset, 13966 function () { 13967 asset.state = LOADED; 13968 callback(); 13969 if (BX.Type.isArrayFilled(loadingAssetCallbacks[asset.name])) 13970 { 13971 for (const cb of loadingAssetCallbacks[asset.name]) 13972 { 13973 cb(); 13974 } 13975 } 13976 13977 delete loadingAssetCallbacks[asset.name]; 13978 }, 13979 doc 13980 ); 13981 } 13982 13983 function loadAsset(asset, callback, doc) 13984 { 13985 callback = callback || BX.DoNothing; 13986 13987 function error(event) 13988 { 13989 window.clearTimeout(asset.errorTimeout); 13990 window.clearTimeout(asset.cssTimeout); 13991 ele.onload = ele.onreadystatechange = ele.onerror = null; 13992 callback(); 13993 } 13994 13995 function process(event) 13996 { 13997 event = event || window.event; 13998 if (event.type === "load" || (/loaded|complete/.test(ele.readyState) && (!doc.documentMode || doc.documentMode < 9))) 13999 { 14000 window.clearTimeout(asset.errorTimeout); 14001 window.clearTimeout(asset.cssTimeout); 14002 ele.onload = ele.onreadystatechange = ele.onerror = null; 14003 callback(); 14004 } 14005 } 14006 14007 function isCssLoaded() 14008 { 14009 if (asset.state !== LOADED && asset.cssRetries <= 20) 14010 { 14011 for (var i = 0, l = doc.styleSheets.length; i < l; i++) 14012 { 14013 if (doc.styleSheets[i].href === ele.href) 14014 { 14015 process({"type": "load"}); 14016 return; 14017 } 14018 } 14019 14020 asset.cssRetries++; 14021 asset.cssTimeout = window.setTimeout(isCssLoaded, 250); 14022 } 14023 } 14024 14025 let ele = null; 14026 const ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 14027 14028 if (ext === "css") 14029 { 14030 ele = doc.createElement("link"); 14031 ele.type = "text/" + (asset.type || "css"); 14032 ele.rel = "stylesheet"; 14033 ele.href = asset.url; 14034 14035 asset.cssRetries = 0; 14036 asset.cssTimeout = window.setTimeout(isCssLoaded, 500); 14037 } 14038 else 14039 { 14040 ele = doc.createElement("script"); 14041 ele.type = "text/" + (asset.type || "javascript"); 14042 ele.src = asset.url; 14043 } 14044 14045 ele.onload = ele.onreadystatechange = process; 14046 ele.onerror = error; 14047 14048 ele.async = false; 14049 ele.defer = false; 14050 14051 asset.errorTimeout = window.setTimeout(function () { 14052 error({type: "timeout"}); 14053 }, 7000); 14054 14055 if (ext === "css") 14056 { 14057 cssList.push(normalizeMinUrl(normalizeUrl(asset.url))); 14058 } 14059 else 14060 { 14061 jsList.push(normalizeMinUrl(normalizeUrl(asset.url))); 14062 } 14063 14064 let templateLink = null; 14065 const head = doc.head || doc.getElementsByTagName("head")[0]; 14066 if (ext === "css" && (templateLink = getTemplateLink(head)) !== null) 14067 { 14068 templateLink.parentNode.insertBefore(ele, templateLink); 14069 } 14070 else 14071 { 14072 head.insertBefore(ele, head.lastChild); 14073 } 14074 } 14075 14076 function getAsset(item) 14077 { 14078 var asset = {}; 14079 if (typeof item === "object") 14080 { 14081 asset = item; 14082 asset.name = asset.name ? asset.name : BX.util.hashCode(item.url); 14083 } 14084 else 14085 { 14086 asset = { name: BX.util.hashCode(item), url : item }; 14087 } 14088 14089 var ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 14090 if ((ext === "css" && isCssLoaded(asset.url)) || isScriptLoaded(asset.url)) 14091 { 14092 asset.state = LOADED; 14093 } 14094 14095 var existing = assets[asset.name]; 14096 if (existing && existing.url === asset.url) 14097 { 14098 return existing; 14099 } 14100 14101 assets[asset.name] = asset; 14102 14103 return asset; 14104 } 14105 14106 function normalizeUrl(url) 14107 { 14108 if (!BX.type.isNotEmptyString(url)) 14109 { 14110 return ""; 14111 } 14112 14113 url = BX.getJSPath(url); 14114 url = url.replace(/\?[0-9]*$/, ""); 14115 14116 return url; 14117 } 14118 14119 function normalizeMinUrl(url) 14120 { 14121 if (!BX.type.isNotEmptyString(url)) 14122 { 14123 return ""; 14124 } 14125 14126 var minPos = url.indexOf(".min"); 14127 return minPos >= 0 ? url.substr(0, minPos) + url.substr(minPos + 4) : url; 14128 } 14129 14130 function isCssLoaded(fileSrc) 14131 { 14132 initCssList(); 14133 14134 fileSrc = normalizeUrl(fileSrc); 14135 var fileSrcMin = normalizeMinUrl(fileSrc); 14136 14137 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, cssList)) || BX.util.in_array(fileSrc, cssList); 14138 } 14139 14140 function initCssList() 14141 { 14142 if(!cssInit) 14143 { 14144 var linksCol = document.getElementsByTagName('link'); 14145 14146 if(!!linksCol && linksCol.length > 0) 14147 { 14148 for(var i = 0; i < linksCol.length; i++) 14149 { 14150 var href = linksCol[i].getAttribute('href'); 14151 if (BX.type.isNotEmptyString(href)) 14152 { 14153 href = normalizeMinUrl(normalizeUrl(href)); 14154 cssList.push(href); 14155 } 14156 } 14157 } 14158 cssInit = true; 14159 } 14160 } 14161 14162 function getTemplateLink(head) 14163 { 14164 var findLink = function(tag) 14165 { 14166 var links = head.getElementsByTagName(tag); 14167 for (var i = 0, length = links.length; i < length; i++) 14168 { 14169 var templateStyle = links[i].getAttribute("data-template-style"); 14170 if (BX.type.isNotEmptyString(templateStyle) && templateStyle == "true") 14171 { 14172 return links[i]; 14173 } 14174 } 14175 14176 return null; 14177 }; 14178 14179 var link = findLink("link"); 14180 if (link === null) 14181 { 14182 link = findLink("style"); 14183 } 14184 14185 return link; 14186 } 14187 14188 function isScriptLoaded(fileSrc) 14189 { 14190 initJsList(); 14191 14192 fileSrc = normalizeUrl(fileSrc); 14193 var fileSrcMin = normalizeMinUrl(fileSrc); 14194 14195 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, jsList)) || BX.util.in_array(fileSrc, jsList); 14196 } 14197 14198 function initJsList() 14199 { 14200 if(!jsInit) 14201 { 14202 var scriptCol = document.getElementsByTagName('script'); 14203 14204 if(!!scriptCol && scriptCol.length > 0) 14205 { 14206 for(var i=0; i<scriptCol.length; i++) 14207 { 14208 var src = scriptCol[i].getAttribute('src'); 14209 14210 if (BX.type.isNotEmptyString(src)) 14211 { 14212 src = normalizeMinUrl(normalizeUrl(src)); 14213 jsList.push(src); 14214 } 14215 } 14216 } 14217 jsInit = true; 14218 } 14219 } 14220 14221 function reloadInternal(back_url, bAddClearCache) 14222 { 14223 if (back_url === true) 14224 { 14225 bAddClearCache = true; 14226 back_url = null; 14227 } 14228 14229 var topWindow = (function() { 14230 if (BX.PageObject && BX.PageObject.getRootWindow) 14231 { 14232 return BX.PageObject.getRootWindow(); 14233 } 14234 14235 return window.top; 14236 })(); 14237 var new_href = back_url || topWindow.location.href; 14238 14239 var hashpos = new_href.indexOf('#'), hash = ''; 14240 14241 if (hashpos != -1) 14242 { 14243 hash = new_href.substr(hashpos); 14244 new_href = new_href.substr(0, hashpos); 14245 } 14246 14247 if (bAddClearCache && new_href.indexOf('clear_cache=Y') < 0) 14248 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + 'clear_cache=Y'; 14249 14250 if (hash) 14251 { 14252 // hack for clearing cache in ajax mode components with history emulation 14253 if (bAddClearCache && (hash.substr(0, 5) == 'view/' || hash.substr(0, 6) == '#view/') && hash.indexOf('clear_cache%3DY') < 0) 14254 hash += (hash.indexOf('%3F') == -1 ? '%3F' : '%26') + 'clear_cache%3DY'; 14255 14256 new_href = new_href.replace(/(\?|\&)_r=[\d]*/, ''); 14257 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + '_r='+Math.round(Math.random()*10000) + hash; 14258 } 14259 14260 topWindow.location.href = new_href; 14261 } 14262 14263 BX.reload = function(back_url, bAddClearCache) 14264 { 14265 if (window !== window.top) 14266 { 14267 BX.Runtime 14268 .loadExtension('main.pageobject') 14269 .then(function() { 14270 reloadInternal(back_url, bAddClearCache); 14271 }); 14272 } 14273 else 14274 { 14275 reloadInternal(back_url, bAddClearCache); 14276 } 14277 }; 14278 14279 BX.clearCache = function() 14280 { 14281 BX.showWait(); 14282 BX.reload(true); 14283 }; 14284 14285 BX.template = function(tpl, callback, bKillTpl) 14286 { 14287 BX.ready(function() { 14288 _processTpl(BX(tpl), callback, bKillTpl); 14289 }); 14290 }; 14291 14292 BX.isAmPmMode = function(returnConst) 14293 { 14294 if (returnConst === true) 14295 { 14296 return BX.message.AMPM_MODE; 14297 } 14298 return BX.message.AMPM_MODE !== false; 14299 }; 14300 14301 BX.formatDate = function(date, format) 14302 { 14303 date = date || new Date(); 14304 14305 var bTime = date.getHours() || date.getMinutes() || date.getSeconds(), 14306 str = !!format 14307 ? format : 14308 (bTime ? BX.message('FORMAT_DATETIME') : BX.message('FORMAT_DATE') 14309 ); 14310 14311 return str.replace(/YYYY/ig, date.getFullYear()) 14312 .replace(/MMMM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14313 .replace(/MM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14314 .replace(/DD/ig, BX.util.str_pad_left(date.getDate().toString(), 2, '0')) 14315 .replace(/HH/ig, BX.util.str_pad_left(date.getHours().toString(), 2, '0')) 14316 .replace(/MI/ig, BX.util.str_pad_left(date.getMinutes().toString(), 2, '0')) 14317 .replace(/SS/ig, BX.util.str_pad_left(date.getSeconds().toString(), 2, '0')); 14318 }; 14319 BX.formatName = function(user, template, login) 14320 { 14321 user = user || {}; 14322 template = (template || ''); 14323 var replacement = { 14324 TITLE : (user["TITLE"] || ''), 14325 NAME : (user["NAME"] || ''),
14326 LAST_NAME : (user["LAST_NAME"] || ''), 14327 SECOND_NAME : (user["SECOND_NAME"] || ''), 14328 LOGIN : (user["LOGIN"] || ''), 14329 NAME_SHORT : user["NAME"] ? user["NAME"].substr(0, 1) + '.' : '', 14330 LAST_NAME_SHORT : user["LAST_NAME"] ? user["LAST_NAME"].substr(0, 1) + '.' : '', 14331 SECOND_NAME_SHORT : user["SECOND_NAME"] ? user["SECOND_NAME"].substr(0, 1) + '.' : '', 14332 EMAIL : (user["EMAIL"] || ''), 14333 ID : (user["ID"] || ''), 14334 NOBR : "", 14335 '/NOBR' : "" 14336 }, result = template; 14337 for (var ii in replacement) 14338 { 14339 if (replacement.hasOwnProperty(ii)) 14340 { 14341 result = result.replace("#" + ii+ "#", replacement[ii]) 14342 } 14343 } 14344 result = result.replace(/([\s]+)/gi, " ").trim(); 14345 if (result == "") 14346 { 14347 result = (login == "Y" ? replacement["LOGIN"] : ""); 14348 result = (result == "" ? "Noname" : result); 14349 } 14350 return result; 14351 }; 14352 14353 BX.getNumMonth = function(month) 14354 { 14355 var wordMonthCut = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; 14356 var wordMonth = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']; 14357 14358 var q = month.toUpperCase(); 14359 for (i = 1; i <= 12; i++) 14360 { 14361 if (q == BX.message('MON_'+i).toUpperCase() || q == BX.message('MONTH_'+i).toUpperCase() || q == wordMonthCut[i-1].toUpperCase() || q == wordMonth[i-1].toUpperCase()) 14362 { 14363 return i; 14364 } 14365 } 14366 return month; 14367 }; 14368 14369 BX.parseDate = function(str, bUTC, formatDate, formatDatetime) 14370 { 14371 if (BX.type.isNotEmptyString(str)) 14372 { 14373 if (!formatDate) 14374 formatDate = BX.message('FORMAT_DATE'); 14375 if (!formatDatetime) 14376 formatDatetime = BX.message('FORMAT_DATETIME'); 14377 14378 var regMonths = ''; 14379 for (i = 1; i <= 12; i++) 14380 { 14381 regMonths = regMonths + '|' + BX.message('MON_'+i); 14382 } 14383
14384 var expr = new RegExp('([0-9]+|[a-z]+' + regMonths + ')', 'ig'); 14385 var aDate = str.match(expr), 14386 aFormat = formatDate.match(/(DD|MI|MMMM|MM|M|YYYY)/ig), 14387 i, cnt, 14388 aDateArgs=[], aFormatArgs=[], 14389 aResult={}; 14390 14391 if (!aDate) 14392 return null; 14393 14394 if(aDate.length > aFormat.length) 14395 { 14396 aFormat = formatDatetime.match(/(DD|MI|MMMM|MM|M|YYYY|HH|H|SS|TT|T|GG|G)/ig); 14397 } 14398 14399 for(i = 0, cnt = aDate.length; i < cnt; i++) 14400 { 14401 if(BX.util.trim(aDate[i]) != '') 14402 { 14403 aDateArgs[aDateArgs.length] = aDate[i]; 14404 } 14405 } 14406 14407 for(i = 0, cnt = aFormat.length; i < cnt; i++) 14408 { 14409 if(BX.util.trim(aFormat[i]) != '') 14410 { 14411 aFormatArgs[aFormatArgs.length] = aFormat[i]; 14412 } 14413 } 14414 14415 14416 var m = BX.util.array_search('MMMM', aFormatArgs); 14417 if (m > 0) 14418 { 14419 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 14420 aFormatArgs[m] = "MM"; 14421 } 14422 else 14423 { 14424 m = BX.util.array_search('M', aFormatArgs); 14425 if (m > 0) 14426 { 14427 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 14428 aFormatArgs[m] = "MM"; 14429 } 14430 } 14431 14432 for(i = 0, cnt = aFormatArgs.length; i < cnt; i++) 14433 { 14434 var k = aFormatArgs[i].toUpperCase(); 14435 aResult[k] = k == 'T' || k == 'TT' ? aDateArgs[i] : parseInt(aDateArgs[i], 10); 14436 } 14437 14438 if(aResult['DD'] > 0 && aResult['MM'] > 0 && aResult['YYYY'] > 0) 14439 { 14440 var d = new Date(); 14441 14442 if(bUTC) 14443 { 14444 d.setUTCDate(1); 14445 d.setUTCFullYear(aResult['YYYY']); 14446 d.setUTCMonth(aResult['MM'] - 1); 14447 d.setUTCDate(aResult['DD']); 14448 d.setUTCHours(0, 0, 0, 0); 14449 } 14450 else 14451 { 14452 d.setDate(1); 14453 d.setFullYear(aResult['YYYY']); 14454 d.setMonth(aResult['MM'] - 1); 14455 d.setDate(aResult['DD']); 14456 d.setHours(0, 0, 0, 0); 14457 } 14458 14459 if( 14460 (!isNaN(aResult['HH']) || !isNaN(aResult['GG']) || !isNaN(aResult['H']) || !isNaN(aResult['G'])) 14461 && !isNaN(aResult['MI']) 14462 ) 14463 { 14464 if (!isNaN(aResult['H']) || !isNaN(aResult['G'])) 14465 { 14466 var bPM = (aResult['T']||aResult['TT']||'am').toUpperCase()=='PM'; 14467 var h = parseInt(aResult['H']||aResult['G']||0, 10); 14468 if(bPM) 14469 { 14470 aResult['HH'] = h + (h == 12 ? 0 : 12); 14471 } 14472 else 14473 { 14474 aResult['HH'] = h < 12 ? h : 0; 14475 } 14476 } 14477 else 14478 { 14479 aResult['HH'] = parseInt(aResult['HH']||aResult['GG']||0, 10); 14480 } 14481 14482 if (isNaN(aResult['SS'])) 14483 aResult['SS'] = 0; 14484 14485 if(bUTC) 14486 { 14487 d.setUTCHours(aResult['HH'], aResult['MI'], aResult['SS']); 14488 } 14489 else 14490 { 14491 d.setHours(aResult['HH'], aResult['MI'], aResult['SS']); 14492 } 14493 } 14494 14495 return d; 14496 } 14497 } 14498 14499 return null; 14500 }; 14501 14502 BX.selectUtils = 14503 { 14504 addNewOption: function(oSelect, opt_value, opt_name, do_sort, check_unique) 14505 { 14506 oSelect = BX(oSelect); 14507 if(oSelect) 14508 { 14509 var n = oSelect.length; 14510 if(check_unique !== false) 14511 { 14512 for(var i=0;i<n;i++) 14513 { 14514 if(oSelect[i].value==opt_value) 14515 { 14516 return; 14517 } 14518 } 14519 } 14520 14521 oSelect.options[n] = new Option(opt_name, opt_value, false, false); 14522 } 14523 14524 if(do_sort === true) 14525 { 14526 this.sortSelect(oSelect); 14527 } 14528 }, 14529 14530 deleteOption: function(oSelect, opt_value) 14531 { 14532 oSelect = BX(oSelect); 14533 if(oSelect) 14534 { 14535 for(var i=0;i<oSelect.length;i++) 14536 { 14537 if(oSelect[i].value==opt_value) 14538 { 14539 oSelect.remove(i); 14540 break; 14541 } 14542 } 14543 } 14544 }, 14545 14546 deleteSelectedOptions: function(oSelect) 14547 { 14548 oSelect = BX(oSelect); 14549 if(oSelect) 14550 { 14551 var i=0; 14552 while(i<oSelect.length) 14553 { 14554 if(oSelect[i].selected) 14555 { 14556 oSelect[i].selected=false; 14557 oSelect.remove(i); 14558 } 14559 else 14560 { 14561 i++; 14562 } 14563 } 14564 } 14565 }, 14566 14567 deleteAllOptions: function(oSelect) 14568 { 14569 oSelect = BX(oSelect); 14570 if(oSelect) 14571 { 14572 for(var i=oSelect.length-1; i>=0; i--) 14573 { 14574 oSelect.remove(i); 14575 } 14576 } 14577 }, 14578 14579 optionCompare: function(record1, record2) 14580 { 14581 var value1 = record1.optText.toLowerCase(); 14582 var value2 = record2.optText.toLowerCase(); 14583 if (value1 > value2) return(1); 14584 if (value1 < value2) return(-1); 14585 return(0); 14586 }, 14587 14588 sortSelect: function(oSelect) 14589 { 14590 oSelect = BX(oSelect); 14591 if(oSelect) 14592 { 14593 var myOptions = []; 14594 var n = oSelect.options.length; 14595 var i; 14596 for (i=0;i<n;i++) 14597 { 14598 myOptions[i] = { 14599 optText:oSelect[i].text, 14600 optValue:oSelect[i].value 14601 }; 14602 } 14603 myOptions.sort(this.optionCompare); 14604 oSelect.length=0; 14605 n = myOptions.length; 14606 for(i=0;i<n;i++) 14607 { 14608 oSelect[i] = new Option(myOptions[i].optText, myOptions[i].optValue, false, false); 14609 } 14610 } 14611 }, 14612 14613 selectAllOptions: function(oSelect) 14614 { 14615 oSelect = BX(oSelect); 14616 if(oSelect) 14617 { 14618 var n = oSelect.length; 14619 for(var i=0;i<n;i++) 14620 { 14621 oSelect[i].selected=true; 14622 } 14623 } 14624 }, 14625 14626 selectOption: function(oSelect, opt_value) 14627 { 14628 oSelect = BX(oSelect); 14629 if(oSelect) 14630 { 14631 var n = oSelect.length; 14632 for(var i=0;i<n;i++) 14633 { 14634 oSelect[i].selected = (oSelect[i].value == opt_value); 14635 } 14636 } 14637 }, 14638 14639 addSelectedOptions: function(oSelect, to_select_id, check_unique, do_sort) 14640 { 14641 oSelect = BX(oSelect); 14642 if(!oSelect) 14643 return; 14644 var n = oSelect.length; 14645 for(var i=0; i<n; i++) 14646 if(oSelect[i].selected) 14647 this.addNewOption(to_select_id, oSelect[i].value, oSelect[i].text, do_sort, check_unique); 14648 }, 14649 14650 moveOptionsUp: function(oSelect) 14651 { 14652 oSelect = BX(oSelect); 14653 if(!oSelect) 14654 return; 14655 var n = oSelect.length; 14656 for(var i=0; i<n; i++) 14657 { 14658 if(oSelect[i].selected && i>0 && oSelect[i-1].selected == false) 14659 { 14660 var option = new Option(oSelect[i].text, oSelect[i].value); 14661 oSelect[i] = new Option(oSelect[i-1].text, oSelect[i-1].value); 14662 oSelect[i].selected = false;
14663 oSelect[i-1] = option; 14664 oSelect[i-1].selected = true; 14665 } 14666 } 14667 }, 14668 14669 moveOptionsDown: function(oSelect) 14670 { 14671 oSelect = BX(oSelect); 14672 if(!oSelect) 14673 return; 14674 var n = oSelect.length; 14675 for(var i=n-1; i>=0; i--) 14676 { 14677 if(oSelect[i].selected && i<n-1 && oSelect[i+1].selected == false) 14678 { 14679 var option = new Option(oSelect[i].text, oSelect[i].value); 14680 oSelect[i] = new Option(oSelect[i+1].text, oSelect[i+1].value); 14681 oSelect[i].selected = false; 14682 oSelect[i+1] = option; 14683 oSelect[i+1].selected = true; 14684 } 14685 } 14686 } 14687 }; 14688 14689 BX.getEventTarget = function(e) 14690 { 14691 if(e.target) 14692 { 14693 return e.target; 14694 } 14695 else if(e.srcElement) 14696 { 14697 return e.srcElement; 14698 } 14699 return null; 14700 }; 14701 14702 BX.convert = { 14703 toNumber: function(value) 14704 { 14705 if(BX.type.isNumber(value)) 14706 { 14707 return value; 14708 } 14709 14710 value = Number(value); 14711 return !isNaN(value) ? value : 0; 14712 }, 14713 nodeListToArray: function(nodes) 14714 { 14715 try 14716 { 14717 return (Array.prototype.slice.call(nodes, 0)); 14718 } 14719 catch (ex) 14720 { 14721 var ary = []; 14722 for(var i = 0, l = nodes.length; i < l; i++) 14723 { 14724 ary.push(nodes[i]); 14725 } 14726 return ary; 14727 } 14728 } 14729 }; 14730 14731 /******* HINT ***************/ 14732// if function has 2 params - the 2nd one is hint html. otherwise hint_html is third and hint_title - 2nd; 14733// '<div onmouseover="BX.hint(this, 'This is <b>Hint</b>')"'>; 14734// BX.hint(el, 'This is <b>Hint</b>') - this won't work, use constructor 14735 BX.hint = function(el, hint_title, hint_html, hint_id) 14736 { 14737 if (null == hint_html) 14738 { 14739 hint_html = hint_title; 14740 hint_title = ''; 14741 } 14742 14743 if (null == el.BXHINT) 14744 { 14745 el.BXHINT = new BX.CHint({ 14746 parent: el, hint: hint_html, title: hint_title, id: hint_id 14747 }); 14748 el.BXHINT.Show(); 14749 } 14750 }; 14751 14752 BX.hint_replace = function(el, hint_title, hint_html) 14753 { 14754 if (null == hint_html) 14755 { 14756 hint_html = hint_title; 14757 hint_title = ''; 14758 } 14759 14760 if (!el || !el.parentNode || !hint_html) 14761 return null; 14762 14763 var obHint = new BX.CHint({ 14764 hint: hint_html, 14765 title: hint_title 14766 }); 14767 14768 obHint.CreateParent(); 14769 14770 el.parentNode.insertBefore(obHint.PARENT, el); 14771 el.parentNode.removeChild(el); 14772 14773 obHint.PARENT.style.marginLeft = '5px'; 14774 14775 return el; 14776 }; 14777 14778 BX.CHint = function(params) 14779 { 14780 if (BX.CHint.cssLoaded === false) 14781 { 14782 BX.load(['/bitrix/js/main/core/css/core_hint.css']); 14783 BX.CHint.cssLoaded = true; 14784 } 14785 14786 this.PARENT = BX(params.parent); 14787 14788 this.HINT = params.hint; 14789 this.HINT_TITLE = params.title; 14790 14791 this.PARAMS = {}; 14792 for (var i in this.defaultSettings) 14793 { 14794 if (null == params[i]) 14795 this.PARAMS[i] = this.defaultSettings[i]; 14796 else 14797 this.PARAMS[i] = params[i]; 14798 } 14799 14800 if (null != params.id) 14801 this.ID = params.id; 14802 14803 this.timer = null; 14804 this.bInited = false; 14805 this.msover = true; 14806 14807 if (this.PARAMS.showOnce) 14808 { 14809 this.__show(); 14810 this.msover = false; 14811 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14812 } 14813 else if (this.PARENT) 14814 { 14815 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14816 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14817 } 14818 }; 14819 14820 BX.CHint.cssLoaded = false; 14821 14822 BX.CHint.openHints = new Set(); 14823 14824 BX.CHint.globalDisabled = false; 14825 14826 BX.CHint.handleMenuOpen = function() { 14827 BX.CHint.globalDisabled = true; 14828 14829 BX.CHint.openHints.forEach(function(hint) { 14830 hint.__hide_immediately(); 14831 }); 14832 }; 14833 14834 BX.CHint.handleMenuClose = function() { 14835 BX.CHint.globalDisabled = false; 14836 }; 14837 14838 BX.addCustomEvent('onMenuOpen', BX.CHint.handleMenuOpen); 14839 BX.addCustomEvent('onMenuClose', BX.CHint.handleMenuClose); 14840 14841 BX.CHint.prototype.defaultSettings = { 14842 show_timeout: 1000, 14843 hide_timeout: 500, 14844 dx: 2, 14845 showOnce: false, 14846 preventHide: true, 14847 min_width: 250 14848 }; 14849 14850 BX.CHint.prototype.CreateParent = function(element, params) 14851 { 14852 if (this.PARENT) 14853 { 14854 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14855 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14856 } 14857 14858 if (!params) params = {}; 14859 var type = 'icon'; 14860 14861 if (params.type && (params.type == "link" || params.type == "icon")) 14862 type = params.type; 14863 14864 if (element) 14865 type = "element";
14866 14867 if (type == "icon") 14868 { 14869 element = BX.create('IMG', { 14870 props: { 14871 src: params.iconSrc 14872 ? params.iconSrc 14873 : "/bitrix/js/main/core/images/hint.gif" 14874 } 14875 }); 14876 } 14877 else if (type == "link") 14878 { 14879 element = BX.create("A", { 14880 props: {href: 'javascript:void(0)'}, 14881 html: '[?]' 14882 }); 14883 } 14884 14885 this.PARENT = element; 14886 14887 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14888 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14889 14890 return this.PARENT; 14891 }; 14892 14893 BX.CHint.prototype.Show = function() 14894 { 14895 this.msover = true; 14896 14897 if (null != this.timer) 14898 clearTimeout(this.timer); 14899 14900 this.timer = setTimeout(BX.proxy(this.__show, this), this.PARAMS.show_timeout); 14901 }; 14902 14903 BX.CHint.prototype.Hide = function() 14904 { 14905 this.msover = false; 14906 14907 if (null != this.timer) 14908 clearTimeout(this.timer); 14909 14910 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14911 }; 14912 14913 BX.CHint.prototype.__show = function() 14914 { 14915 if (!this.msover || this.disabled || BX.CHint.globalDisabled) return; 14916 if (!this.bInited) this.Init(); 14917 14918 if (this.prepareAdjustPos()) 14919 { 14920 this.DIV.style.display = 'block'; 14921 BX.ZIndexManager.bringToFront(this.DIV); 14922 14923 this.adjustPos(); 14924 14925 BX.CHint.openHints.add(this); 14926 14927 BX.bind(window, 'scroll', BX.proxy(this.__onscroll, this)); 14928 14929 if (this.PARAMS.showOnce) 14930 { 14931 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14932 } 14933 } 14934 }; 14935 14936 BX.CHint.prototype.__onscroll = function() 14937 { 14938 if (!BX.admin || !BX.admin.panel || !BX.admin.panel.isFixed()) return; 14939 14940 if (this.scrollTimer) clearTimeout(this.scrollTimer); 14941 14942 this.DIV.style.display = 'none'; 14943 this.scrollTimer = setTimeout(BX.proxy(this.Reopen, this), this.PARAMS.show_timeout); 14944 }; 14945 14946 BX.CHint.prototype.Reopen = function() 14947 { 14948 if (null != this.timer) clearTimeout(this.timer); 14949 this.timer = setTimeout(BX.proxy(this.__show, this), 50); 14950 }; 14951 14952 BX.CHint.prototype.__hide = function() 14953 { 14954 if (this.msover) return; 14955 if (!this.bInited) return; 14956 14957 BX.unbind(window, 'scroll', BX.proxy(this.Reopen, this)); 14958 14959 BX.CHint.openHints.delete(this); 14960 14961 if (this.PARAMS.showOnce) 14962 { 14963 this.Destroy(); 14964 } 14965 else 14966 { 14967 this.DIV.style.display = 'none'; 14968 } 14969 }; 14970 14971 BX.CHint.prototype.__hide_immediately = function() 14972 { 14973 this.msover = false; 14974 this.__hide(); 14975 }; 14976 14977 BX.CHint.prototype.Init = function() 14978 { 14979 this.DIV = document.body.appendChild(BX.create('DIV', { 14980 props: {className: 'bx-panel-tooltip'}, 14981 style: { 14982 display: 'none', 14983 position: 'absolute', 14984 visibility: 'hidden' 14985 }, 14986 children: [ 14987 (this.CONTENT = BX.create('DIV', { 14988 props: {className: 'bx-panel-tooltip-content'}, 14989 children: [ 14990 BX.create('DIV', { 14991 props: {className: 'bx-panel-tooltip-underlay'}, 14992 children: [ 14993 BX.create('DIV', {props: {className: 'bx-panel-tooltip-underlay-bg'}}) 14994 ] 14995 }) 14996 ] 14997 })) 14998 ] 14999 })); 15000 15001 BX.ZIndexManager.register(this.DIV); 15002 15003 if (this.ID) 15004 { 15005 this.CONTENT.insertBefore(BX.create('A', { 15006 attrs: {href: 'javascript:void(0)'}, 15007 props: {className: 'bx-panel-tooltip-close'}, 15008 events: {click: BX.delegate(this.Close, this)} 15009 }), this.CONTENT.firstChild); 15010 } 15011 15012 if (this.HINT_TITLE) 15013 { 15014 this.CONTENT.appendChild( 15015 BX.create('DIV', { 15016 props: {className: 'bx-panel-tooltip-title'}, 15017 text: this.HINT_TITLE 15018 }) 15019 ); 15020 } 15021 15022 if (this.HINT) 15023 { 15024 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 15025 } 15026 15027 if (this.PARAMS.preventHide) 15028 { 15029 BX.bind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 15030 BX.bind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 15031 } 15032 15033 this.bInited = true; 15034 }; 15035 15036 BX.CHint.prototype.setContent = function(content) 15037 { 15038 this.HINT = content; 15039 15040 if (this.CONTENT_TEXT) 15041 this.CONTENT_TEXT.innerHTML = this.HINT; 15042 else 15043 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 15044 }; 15045 15046 BX.CHint.prototype.prepareAdjustPos = function() 15047 { 15048 this._wnd = {scrollPos: BX.GetWindowScrollPos(),scrollSize:BX.GetWindowScrollSize()}; 15049 return BX.style(this.PARENT, 'display') != 'none'; 15050 }; 15051 15052 BX.CHint.prototype.getAdjustPos = function() 15053 { 15054 var res = {}, pos = BX.pos(this.PARENT), min_top = 0; 15055 15056 res.top = pos.bottom + this.PARAMS.dx; 15057 15058 if (BX.admin && BX.admin.panel.DIV) 15059 { 15060 min_top = BX.admin.panel.DIV.offsetHeight + this.PARAMS.dx; 15061 15062 if (BX.admin.panel.isFixed()) 15063 { 15064 min_top += this._wnd.scrollPos.scrollTop; 15065 } 15066 } 15067 15068 if (res.top < min_top) 15069 res.top = min_top; 15070 else 15071 { 15072 if (res.top + this.DIV.offsetHeight > this._wnd.scrollSize.scrollHeight) 15073 res.top = pos.top - this.PARAMS.dx - this.DIV.offsetHeight; 15074 } 15075 15076 res.left = pos.left; 15077 if (pos.left < this.PARAMS.dx) 15078 pos.left = this.PARAMS.dx; 15079 else 15080 { 15081 var floatWidth = this.DIV.offsetWidth; 15082 15083 var max_left = this._wnd.scrollSize.scrollWidth - floatWidth - this.PARAMS.dx; 15084 15085 if (res.left > max_left) 15086 res.left = max_left; 15087 } 15088 15089 return res; 15090 }; 15091 15092 BX.CHint.prototype.adjustWidth = function() 15093 { 15094 if (this.bWidthAdjusted) return; 15095 15096 var w = this.DIV.offsetWidth, h = this.DIV.offsetHeight; 15097 15098 if (w > this.PARAMS.min_width) 15099 w = Math.round(Math.sqrt(1.618*w*h)); 15100 15101 if (w < this.PARAMS.min_width) 15102 w = this.PARAMS.min_width; 15103 15104 this.DIV.style.width = w + "px"; 15105 15106 if (this._adjustWidthInt) 15107 clearInterval(this._adjustWidthInt); 15108 this._adjustWidthInt = setInterval(BX.delegate(this._adjustWidthInterval, this), 5); 15109 15110 this.bWidthAdjusted = true; 15111 }; 15112 15113 BX.CHint.prototype._adjustWidthInterval = function() 15114 { 15115 if (!this.DIV || this.DIV.style.display == 'none') 15116 clearInterval(this._adjustWidthInt); 15117 15118 var
15119 dW = 20, 15120 maxWidth = 1500, 15121 w = this.DIV.offsetWidth, 15122 w1 = this.CONTENT_TEXT.offsetWidth; 15123 15124 if (w > 0 && w1 > 0 && w - w1 < dW && w < maxWidth) 15125 { 15126 this.DIV.style.width = (w + dW) + "px"; 15127 return; 15128 } 15129 15130 clearInterval(this._adjustWidthInt); 15131 }; 15132 15133 BX.CHint.prototype.adjustPos = function() 15134 { 15135 this.adjustWidth(); 15136 15137 var pos = this.getAdjustPos(); 15138 15139 this.DIV.style.top = pos.top + 'px'; 15140 this.DIV.style.left = pos.left + 'px'; 15141 }; 15142 15143 BX.CHint.prototype.Close = function() 15144 { 15145 if (this.ID && BX.WindowManager) 15146 BX.WindowManager.saveWindowOptions(this.ID, {display: 'off'}); 15147 this.__hide_immediately(); 15148 this.Destroy(); 15149 }; 15150 15151 BX.CHint.prototype.Destroy = function() 15152 { 15153 if (this.PARENT) 15154 { 15155 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 15156 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 15157 } 15158 15159 if (this.DIV) 15160 { 15161 BX.unbind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 15162 BX.unbind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 15163 15164 BX.ZIndexManager.unregister(this.DIV); 15165 15166 BX.cleanNode(this.DIV, true); 15167 } 15168 }; 15169 15170 BX.CHint.prototype.enable = function(){this.disabled = false;}; 15171 BX.CHint.prototype.disable = function(){this.__hide_immediately(); this.disabled = true;}; 15172 15173 15174 function _adjustWait() 15175 { 15176 if (!this.bxmsg) return; 15177 15178 var arContainerPos = BX.pos(this), 15179 div_top = arContainerPos.top; 15180 15181 if (div_top < BX.GetDocElement().scrollTop) 15182 div_top = BX.GetDocElement().scrollTop + 5; 15183 15184 this.bxmsg.style.top = (div_top + 5) + 'px'; 15185 15186 if (this == BX.GetDocElement()) 15187 { 15188 this.bxmsg.style.right = '5px'; 15189 } 15190 else 15191 { 15192 this.bxmsg.style.left = (arContainerPos.right - this.bxmsg.offsetWidth - 5) + 'px'; 15193 } 15194 } 15195 15196 function _processTpl(tplNode, cb, bKillTpl) 15197 { 15198 if (tplNode) 15199 { 15200 if (bKillTpl) 15201 tplNode.parentNode.removeChild(tplNode); 15202 15203 var res = {}, nodes = BX.findChildren(tplNode, {attribute: 'data-role'}, true); 15204 15205 for (var i = 0, l = nodes.length; i < l; i++) 15206 { 15207 res[nodes[i].getAttribute('data-role')] = nodes[i]; 15208 } 15209 15210 cb.apply(tplNode, [res]); 15211 } 15212 } 15213 15214 function _checkNode(obj, params) 15215 { 15216 params = params || {}; 15217 15218 if (BX.type.isFunction(params)) 15219 return params.call(window, obj); 15220 15221 if (!params.allowTextNodes && !BX.type.isElementNode(obj)) 15222 return false; 15223 var i,j,len; 15224 for (i in params) 15225 { 15226 if(params.hasOwnProperty(i)) 15227 { 15228 switch(i) 15229 { 15230 case 'tag': 15231 case 'tagName': 15232 if (BX.type.isString(params[i])) 15233 { 15234 if (obj.tagName.toUpperCase() != params[i].toUpperCase()) 15235 return false; 15236 } 15237 else if (params[i] instanceof RegExp) 15238 { 15239 if (!params[i].test(obj.tagName)) 15240 return false; 15241 } 15242 break; 15243 15244 case 'class': 15245 case 'className': 15246 if (BX.type.isString(params[i])) 15247 { 15248 if (!BX.hasClass(obj, params[i])) 15249 return false; 15250 } 15251 else if (params[i] instanceof RegExp) 15252 { 15253 if (!BX.type.isString(obj.className) || !params[i].test(obj.className)) 15254 return false; 15255 } 15256 break; 15257 15258 case 'attr': 15259 case 'attrs': 15260 case 'attribute': 15261 if (BX.type.isString(params[i])) 15262 { 15263 if (!obj.getAttribute(params[i])) 15264 return false; 15265 } 15266 else if (BX.type.isArray(params[i])) 15267 { 15268 for (j = 0, len = params[i].length; j < len; j++) 15269 { 15270 if (params[i] && !obj.getAttribute(params[i])) 15271 return false; 15272 } 15273 } 15274 else 15275 { 15276 for (j in params[i]) 15277 { 15278 if(params[i].hasOwnProperty(j)) 15279 { 15280 var q = obj.getAttribute(j); 15281 if (params[i][j] instanceof RegExp) 15282 { 15283 if (!BX.type.isString(q) || !params[i][j].test(q)) 15284 { 15285 return false; 15286 } 15287 } 15288 else 15289 { 15290 if (q != '' + params[i][j]) 15291 { 15292 return false; 15293 } 15294 } 15295 } 15296 } 15297 } 15298 break; 15299 15300 case 'property': 15301 case 'props': 15302 if (BX.type.isString(params[i])) 15303 { 15304 if (!obj[params[i]]) 15305 return false; 15306 } 15307 else if (BX.type.isArray(params[i])) 15308 { 15309 for (j = 0, len = params[i].length; j < len; j++) 15310 { 15311 if (params[i] && !obj[params[i]]) 15312 return false;
15313 } 15314 } 15315 else 15316 { 15317 for (j in params[i]) 15318 { 15319 if (BX.type.isString(params[i][j])) 15320 { 15321 if (obj[j] != params[i][j]) 15322 return false; 15323 } 15324 else if (params[i][j] instanceof RegExp) 15325 { 15326 if (!BX.type.isString(obj[j]) || !params[i][j].test(obj[j])) 15327 return false; 15328 } 15329 } 15330 } 15331 break; 15332 15333 case 'callback': 15334 return params[i](obj); 15335 } 15336 } 15337 } 15338 15339 return true; 15340 } 15341 15342 window.addEventListener('pagehide', () => { 15343 garbageCollectors.forEach(({ callback, context = window }) => { 15344 try 15345 { 15346 callback.apply(context); 15347 } catch (err) {} 15348 }); 15349 }); 15350 15351 // set empty ready handler 15352 BX(BX.DoNothing); 15353 window.BX = BX; 15354 15355 BX.browser.addGlobalClass(); 15356 15357 /* data storage */ 15358 BX.data = function(node, key, value) 15359 { 15360 if(typeof node == 'undefined') 15361 return undefined; 15362 15363 if(typeof key == 'undefined') 15364 return undefined; 15365 15366 if(typeof value != 'undefined') 15367 { 15368 // write to manager 15369 dataStorage.set(node, key, value); 15370 } 15371 else 15372 { 15373 var data; 15374 15375 // from manager 15376 if((data = dataStorage.get(node, key)) != undefined) 15377 { 15378 return data; 15379 } 15380 else 15381 { 15382 // from attribute data-* 15383 if('getAttribute' in node) 15384 { 15385 data = node.getAttribute('data-'+key.toString()); 15386 if(data === null) 15387 { 15388 return undefined; 15389 } 15390 return data; 15391 } 15392 } 15393 15394 return undefined; 15395 } 15396 }; 15397 15398 BX.DataStorage = function() 15399 { 15400 15401 this.keyOffset = 1; 15402 this.data = {}; 15403 this.uniqueTag = 'BX-'+Math.random(); 15404 15405 this.resolve = function(owner, create){ 15406 if(typeof owner[this.uniqueTag] == 'undefined') 15407 if(create) 15408 { 15409 try 15410 { 15411 Object.defineProperty(owner, this.uniqueTag, { 15412 value: this.keyOffset++ 15413 }); 15414 } 15415 catch(e) 15416 { 15417 owner[this.uniqueTag] = this.keyOffset++; 15418 } 15419 } 15420 else 15421 return undefined; 15422 15423 return owner[this.uniqueTag]; 15424 }; 15425 this.get = function(owner, key){ 15426 if((owner != document && !BX.type.isElementNode(owner)) || typeof key == 'undefined') 15427 return undefined; 15428 15429 owner = this.resolve(owner, false); 15430 15431 if(typeof owner == 'undefined' || typeof this.data[owner] == 'undefined') 15432 return undefined; 15433 15434 return this.data[owner][key]; 15435 }; 15436 this.set = function(owner, key, value){ 15437 15438 if((owner != document && !BX.type.isElementNode(owner)) || typeof value == 'undefined') 15439 return; 15440 15441 var o = this.resolve(owner, true); 15442 15443 if(typeof this.data[o] == 'undefined') 15444 this.data[o] = {}; 15445 15446 this.data[o][key] = value; 15447 }; 15448 }; 15449 15450// some internal variables for new logic 15451 var dataStorage = new BX.DataStorage(); // manager which BX.data() uses to keep data 15452})(window.BX); 15453 15454 15455;(function(window) 15456{ 15457 /****************** ATTENTION ******************************* 15458 * Please do not use Bitrix CoreJS in this class. 15459 * This class can be called on page without Bitrix Framework 15460 *************************************************************/ 15461 15462 if (!window.BX) 15463 { 15464 window.BX = {}; 15465 } 15466 15467 var BX = window.BX; 15468 15469 BX.Promise = function(fn, ctx) // fn is future-reserved 15470 { 15471 this.state = null; 15472 this.value = null; 15473 this.reason = null; 15474 this.next = null; 15475 this.ctx = ctx || this; 15476 15477 this.onFulfilled = []; 15478 this.onRejected = []; 15479 }; 15480 BX.Promise.prototype.fulfill = function(value) 15481 { 15482 this.checkState(); 15483 15484 this.value = value; 15485 this.state = true; 15486 this.execute(); 15487 }; 15488 BX.Promise.prototype.reject = function(reason) 15489 { 15490 this.checkState(); 15491 15492 this.reason = reason; 15493 this.state = false; 15494 this.execute(); 15495 }; 15496 BX.Promise.prototype.then = function(onFulfilled, onRejected) 15497 { 15498 if(typeof (onFulfilled) == "function" || onFulfilled instanceof Function) 15499 { 15500 this.onFulfilled.push(onFulfilled); 15501 } 15502 if(typeof (onRejected) == "function" || onRejected instanceof Function) 15503 { 15504 this.onRejected.push(onRejected); 15505 } 15506 15507 if(this.next === null) 15508 { 15509 this.next = new BX.Promise(null, this.ctx); 15510 } 15511 15512 if(this.state !== null) // if promise was already resolved, execute immediately 15513 { 15514 this.execute(); 15515 } 15516 15517 return this.next; 15518 }; 15519 15520 BX.Promise.prototype.catch = function(onRejected) 15521 { 15522 if(typeof (onRejected) == "function" || onRejected instanceof Function) 15523 { 15524 this.onRejected.push(onRejected); 15525 } 15526 15527 if(this.next === null) 15528 { 15529 this.next = new BX.Promise(null, this.ctx); 15530 } 15531 15532 if(this.state !== null) // if promise was already resolved, execute immediately 15533 { 15534 this.execute(); 15535 } 15536 15537 return this.next; 15538 }; 15539 15540 BX.Promise.prototype.setAutoResolve = function(way, ms) 15541 { 15542 this.timer = setTimeout(function(){ 15543 if(this.state === null) 15544 { 15545 this[way ? 'fulfill' : 'reject'](); 15546 } 15547 }.bind(this), ms || 15); 15548 };
15549 BX.Promise.prototype.cancelAutoResolve = function() 15550 { 15551 clearTimeout(this.timer); 15552 }; 15553 /** 15554 * Resolve function. This function allows promise chaining, like ..then().then()... 15555 * Typical usage: 15556 * 15557 * var p = new Promise(); 15558 * 15559 * p.then(function(value){ 15560 * return someValue; // next promise in the chain will be fulfilled with someValue 15561 * }).then(function(value){ 15562 * 15563 * var p1 = new Promise(); 15564 * *** some async code here, that eventually resolves p1 *** 15565 * 15566 * return p1; // chain will resume when p1 resolved (fulfilled or rejected) 15567 * }).then(function(value){ 15568 * 15569 * // you can also do 15570 * var e = new Error(); 15571 * throw e; 15572 * // it will cause next promise to be rejected with e 15573 * 15574 * return someOtherValue; 15575 * }).then(function(value){ 15576 * ... 15577 * }, function(reason){ 15578 * // promise was rejected with reason 15579 * })...; 15580 * 15581 * p.fulfill('let`s start this chain'); 15582 * 15583 * @param x 15584 */ 15585 BX.Promise.prototype.resolve = function(x) 15586 { 15587 var this_ = this; 15588 15589 if(this === x) 15590 { 15591 this.reject(new TypeError('Promise cannot fulfill or reject itself')); // avoid recursion 15592 } 15593 // allow "pausing" promise chaining until promise x is fulfilled or rejected 15594 else if(x && x.toString() === "[object BX.Promise]") 15595 { 15596 x.then(function(value){ 15597 this_.fulfill(value); 15598 }, function(reason){ 15599 this_.reject(reason); 15600 }); 15601 } 15602 else // auto-fulfill this promise 15603 { 15604 this.fulfill(x); 15605 } 15606 }; 15607 15608 BX.Promise.prototype.toString = function() 15609 { 15610 return "[object BX.Promise]"; 15611 }; 15612 15613 BX.Promise.prototype.execute = function() 15614 { 15615 if(this.state === null) 15616 { 15617 //then() must not be called before BX.Promise resolve() happens 15618 return; 15619 } 15620 15621 var value = undefined; 15622 var reason = undefined; 15623 var x = undefined; 15624 var k; 15625 if(this.state === true) // promise was fulfill()-ed 15626 { 15627 if(this.onFulfilled.length) 15628 { 15629 try 15630 { 15631 for(k = 0; k < this.onFulfilled.length; k++) 15632 {
15633 x = this.onFulfilled[k].apply(this.ctx, [this.value]); 15634 if(typeof x != 'undefined') 15635 { 15636 value = x; 15637 } 15638 } 15639 } 15640 catch(e) 15641 { 15642 if('console' in window) 15643 { 15644 console.dir(e); 15645 } 15646 15647 if (typeof BX.debug !== 'undefined') 15648 { 15649 BX.debug(e); 15650 } 15651 15652 reason = e; // reject next 15653 } 15654 } 15655 else 15656 { 15657 value = this.value; // resolve next 15658 } 15659 } 15660 else if(this.state === false) // promise was reject()-ed 15661 { 15662 if(this.onRejected.length) 15663 { 15664 try 15665 { 15666 for(k = 0; k < this.onRejected.length; k++) 15667 { 15668 x = this.onRejected[k].apply(this.ctx, [this.reason]); 15669 if(typeof x != 'undefined') 15670 { 15671 value = x; 15672 } 15673 } 15674 } 15675 catch(e) 15676 { 15677 if('console' in window) 15678 { 15679 console.dir(e); 15680 } 15681 15682 if (typeof BX.debug !== 'undefined') 15683 { 15684 BX.debug(e); 15685 } 15686 15687 reason = e; // reject next 15688 } 15689 } 15690 else 15691 { 15692 reason = this.reason; // reject next 15693 } 15694 } 15695 15696 if(this.next !== null) 15697 { 15698 if(typeof reason != 'undefined') 15699 { 15700 this.next.reject(reason); 15701 } 15702 else if(typeof value != 'undefined') 15703 { 15704 this.next.resolve(value); 15705 } 15706 } 15707 }; 15708 BX.Promise.prototype.checkState = function() 15709 { 15710 if(this.state !== null) 15711 { 15712 throw new Error('You can not do fulfill() or reject() multiple times'); 15713 } 15714 }; 15715})(window); 15716 15717 15718 15719;(function(window){ 15720 15721if (window.BX.ajax) 15722 return; 15723 15724var 15725 BX = window.BX, 15726 15727 tempDefaultConfig = {}, 15728 defaultConfig = { 15729 method: 'GET', // request method: GET|POST 15730 dataType: 'html', // type of data loading: html|json|script 15731 timeout: 0, // request timeout in seconds. 0 for browser-default 15732 async: true, // whether request is asynchronous or not 15733 processData: true, // any data processing is disabled if false, only callback call 15734 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 15735 emulateOnload: true, 15736 skipAuthCheck: false, // whether to check authorization failure (SHOUD be set to true for CORS requests) 15737 start: true, // send request immediately (if false, request can be started manually via XMLHttpRequest object returned) 15738 cache: true, // whether NOT to add random addition to URL 15739 preparePost: true, // whether set Content-Type x-www-form-urlencoded in POST 15740 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'}] 15741 lsTimeout: 30, //local storage data TTL. useless without lsId. 15742 lsForce: false //wheter to force query instead of using localStorage data. useless without lsId. 15743/* 15744other parameters: 15745 url: url to get/post 15746 data: data to post 15747 onsuccess: successful request callback. BX.proxy may be used. 15748 onfailure: request failure callback. BX.proxy may be used. 15749 onprogress: request progress callback. BX.proxy may be used. 15750 15751 lsId: local storage id - for constantly updating queries which can communicate via localStorage. core_ls.js needed 15752 15753any of the default parameters can be overridden. defaults can be changed by BX.ajax.Setup() - for all further requests! 15754*/ 15755 }, 15756 loadedScripts = {}, 15757 loadedScriptsQueue = [], 15758 r = { 15759 'url_utf': /[^\034-\254]+/g, 15760 'script_self': /\/bitrix\/js\/main\/core\/core(_ajax)*.js$/i, 15761 'script_self_window': /\/bitrix\/js\/main\/core\/core_window.js$/i, 15762 'script_self_admin': /\/bitrix\/js\/main\/core\/core_admin.js$/i, 15763 'script_onload': /window.onload/g 15764 }; 15765 15766// low-level method 15767BX.ajax = function(config) 15768{ 15769 var status, data; 15770
15771 if (!config || !config.url || !BX.type.isString(config.url)) 15772 { 15773 return false; 15774 } 15775 15776 for (var i in tempDefaultConfig) 15777 if (typeof (config[i]) == "undefined") config[i] = tempDefaultConfig[i]; 15778 15779 tempDefaultConfig = {}; 15780 15781 for (i in defaultConfig) 15782 if (typeof (config[i]) == "undefined") config[i] = defaultConfig[i]; 15783 15784 config.method = config.method.toUpperCase(); 15785 15786 if (!BX.localStorage) 15787 config.lsId = null; 15788 15789 if (BX.browser.IsIE()) 15790 { 15791 var result = r.url_utf.exec(config.url); 15792 if (result) 15793 { 15794 do 15795 { 15796 config.url = config.url.replace(result, BX.util.urlencode(result)); 15797 result = r.url_utf.exec(config.url); 15798 } while (result); 15799 } 15800 } 15801 15802 if(config.dataType == 'json') 15803 config.emulateOnload = false; 15804 15805 if (!config.cache && config.method == 'GET') 15806 config.url = BX.ajax._uncache(config.url); 15807 15808 if (config.method == 'POST') 15809 { 15810 if (config.preparePost) 15811 { 15812 config.data = BX.ajax.prepareData(config.data); 15813 } 15814 else if (getLastContentTypeHeader(config.headers) === 'application/json') 15815 { 15816 const isJson = ( 15817 BX.Type.isPlainObject(config.data) 15818 || BX.Type.isString(config.data) 15819 || BX.Type.isNumber(config.data) 15820 || BX.Type.isBoolean(config.data) 15821 || BX.Type.isArray(config.data) 15822 ); 15823 15824 if (isJson) 15825 { 15826 config.data = JSON.stringify(config.data); 15827 } 15828 } 15829 } 15830 15831 var bXHR = true; 15832 if (config.lsId && !config.lsForce) 15833 { 15834 var v = BX.localStorage.get('ajax-' + config.lsId); 15835 if (v !== null) 15836 { 15837 bXHR = false; 15838 15839 var lsHandler = function(lsData) { 15840 if (lsData.key == 'ajax-' + config.lsId && lsData.value != 'BXAJAXWAIT') 15841 { 15842 var data = lsData.value, 15843 bRemove = !!lsData.oldValue && data == null; 15844 if (!bRemove) 15845 BX.ajax.__run(config, data); 15846 else if (config.onfailure) 15847 config.onfailure("timeout"); 15848 15849 BX.removeCustomEvent('onLocalStorageChange', lsHandler); 15850 } 15851 }; 15852 15853 if (v == 'BXAJAXWAIT') 15854 { 15855 BX.addCustomEvent('onLocalStorageChange', lsHandler); 15856 } 15857 else 15858 { 15859 setTimeout(function() {lsHandler({key: 'ajax-' + config.lsId, value: v})}, 10); 15860 } 15861 } 15862 } 15863 15864 if (bXHR) 15865 { 15866 config.xhr = BX.ajax.xhr(); 15867 if (!config.xhr) return; 15868 15869 if (config.lsId) 15870 { 15871 BX.localStorage.set('ajax-' + config.lsId, 'BXAJAXWAIT', config.lsTimeout); 15872 } 15873 15874 if (BX.Type.isFunction(config.onprogress)) 15875 { 15876 BX.bind(config.xhr, 'progress', config.onprogress); 15877 } 15878 15879 if (BX.Type.isFunction(config.onprogressupload) && config.xhr.upload) 15880 { 15881 BX.bind(config.xhr.upload, 'progress', config.onprogressupload); 15882 } 15883 15884 config.xhr.open(config.method, config.url, config.async); 15885 15886 if (!config.skipBxHeader && !BX.ajax.isCrossDomain(config.url)) 15887 { 15888 config.xhr.setRequestHeader('Bx-ajax', 'true'); 15889 } 15890 15891 if (config.method == 'POST' && config.preparePost) 15892 { 15893 config.xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 15894 } 15895 if (typeof(config.headers) == "object") 15896 { 15897 for (i = 0; i < config.headers.length; i++) 15898 config.xhr.setRequestHeader(config.headers[i].name, config.headers[i].value); 15899 } 15900 15901 var bRequestCompleted = false; 15902 var onreadystatechange = config.xhr.onreadystatechange = function(additional) 15903 { 15904 if (bRequestCompleted) 15905 return; 15906 15907 if (additional === 'timeout') 15908 { 15909 if (config.onfailure) 15910 { 15911 config.onfailure('timeout', '', config); 15912 } 15913 15914 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['timeout', '', config]); 15915 15916 config.xhr.onreadystatechange = BX.DoNothing; 15917 config.xhr.abort(); 15918 15919 if (config.async) 15920 { 15921 config.xhr = null; 15922 } 15923 } 15924 else 15925 { 15926 if (config.xhr.readyState == 4 || additional == 'run') 15927 { 15928 status = BX.ajax.xhrSuccess(config.xhr) ? "success" : "error"; 15929 bRequestCompleted = true; 15930 config.xhr.onreadystatechange = BX.DoNothing; 15931 15932 if (status == 'success') 15933 { 15934 var authHeader = (!!config.skipAuthCheck || BX.ajax.isCrossDomain(config.url)) 15935 ? false 15936 : config.xhr.getResponseHeader('X-Bitrix-Ajax-Status'); 15937 15938 if(!!authHeader && authHeader == 'Authorize') 15939 { 15940 if (config.onfailure) 15941 { 15942 config.onfailure('auth', config.xhr.status, config); 15943 } 15944 15945 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['auth', config.xhr.status, config]); 15946 } 15947 else 15948 { 15949 var data = config.xhr.responseText; 15950 15951 if (config.lsId) 15952 { 15953 BX.localStorage.set('ajax-' + config.lsId, data, config.lsTimeout); 15954 } 15955 15956 BX.ajax.__run(config, data); 15957 } 15958 } 15959 else 15960 { 15961 if (config.onfailure) 15962 { 15963 config.onfailure('status', config.xhr.status, config); 15964 } 15965 15966 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['status', config.xhr.status, config]); 15967 } 15968 15969 if (config.async) 15970 { 15971 config.xhr = null; 15972 } 15973 } 15974 } 15975 }; 15976 15977 if (config.async && config.timeout > 0) 15978 { 15979 setTimeout(function() { 15980 if (config.xhr && !bRequestCompleted) 15981 { 15982 onreadystatechange("timeout"); 15983 } 15984 }, config.timeout * 1000); 15985 } 15986 15987 if (config.start) 15988 {
15989 config.xhr.send(config.data); 15990 15991 if (!config.async) 15992 { 15993 onreadystatechange('run'); 15994 } 15995 } 15996 15997 return config.xhr; 15998 } 15999}; 16000 16001BX.ajax.xhr = function() 16002{ 16003 if (window.XMLHttpRequest) 16004 { 16005 try {return new XMLHttpRequest();} catch(e){} 16006 } 16007 else if (window.ActiveXObject) 16008 { 16009 try { return new window.ActiveXObject("Msxml2.XMLHTTP.6.0"); } 16010 catch(e) {} 16011 try { return new window.ActiveXObject("Msxml2.XMLHTTP.3.0"); } 16012 catch(e) {} 16013 try { return new window.ActiveXObject("Msxml2.XMLHTTP"); } 16014 catch(e) {} 16015 try { return new window.ActiveXObject("Microsoft.XMLHTTP"); } 16016 catch(e) {} 16017 throw new Error("This browser does not support XMLHttpRequest."); 16018 } 16019 16020 return null; 16021}; 16022 16023BX.ajax.isCrossDomain = function(url, location) 16024{ 16025 location = location || window.location; 16026 16027 //Relative URL gets a current protocol 16028 if (url.indexOf("//") === 0) 16029 { 16030 url = location.protocol + url; 16031 } 16032 16033 //Fast check 16034 if (url.indexOf("http") !== 0) 16035 { 16036 return false; 16037 } 16038 16039 var link = window.document.createElement("a"); 16040 link.href = url; 16041 16042 return link.protocol !== location.protocol || 16043 link.hostname !== location.hostname || 16044 BX.ajax.getHostPort(link.protocol, link.host) !== BX.ajax.getHostPort(location.protocol, location.host); 16045}; 16046 16047BX.ajax.getHostPort = function(protocol, host) 16048{ 16049 var match = /:(\d+)$/.exec(host); 16050 if (match) 16051 { 16052 return match[1]; 16053 } 16054 else 16055 { 16056 if (protocol === "http:") 16057 { 16058 return "80"; 16059 } 16060 else if (protocol === "https:") 16061 { 16062 return "443"; 16063 } 16064 } 16065 16066 return ""; 16067}; 16068 16069BX.ajax.__prepareOnload = function(scripts, ajax_session) 16070{ 16071 if (scripts.length > 0) 16072 { 16073 BX.ajax['onload_' + ajax_session] = null; 16074 16075 for (var i=0,len=scripts.length;i<len;i++) 16076 { 16077 if (scripts[i].isInternal) 16078 { 16079 scripts[i].JS = scripts[i].JS.replace(r.script_onload, 'BX.aja
16079x.onload_' + ajax_session); 16080 } 16081 } 16082 } 16083 16084 BX.CaptureEventsGet(); 16085 BX.CaptureEvents(window, 'load'); 16086}; 16087 16088BX.ajax.__runOnload = function(ajax_session) 16089{ 16090 if (null != BX.ajax['onload_' + ajax_session]) 16091 { 16092 BX.ajax['onload_' + ajax_session].apply(window); 16093 BX.ajax['onload_' + ajax_session] = null; 16094 } 16095 16096 var h = BX.CaptureEventsGet(); 16097 16098 if (h) 16099 { 16100 for (var i=0; i<h.length; i++) 16101 h[i].apply(window); 16102 } 16103}; 16104 16105BX.ajax.__run = function(config, data) 16106{ 16107 if (!config.processData) 16108 { 16109 if (config.onsuccess) 16110 { 16111 config.onsuccess(data); 16112 } 16113 16114 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [data, config]); 16115 } 16116 else 16117 { 16118 data = BX.ajax.processRequestData(data, config); 16119 } 16120}; 16121 16122 16123BX.ajax._onParseJSONFailure = function(data) 16124{ 16125 this.jsonFailure = true; 16126 this.jsonResponse = data; 16127 this.jsonProactive = /^\[WAF\]/.test(data); 16128}; 16129 16130BX.ajax.processRequestData = function(data, config) 16131{ 16132 var result, scripts = [], styles = []; 16133 switch (config.dataType.toUpperCase()) 16134 { 16135 case 'JSON': 16136 16137 var context = config.xhr || {}; 16138 BX.addCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 16139 result = BX.parseJSON(data, context); 16140 BX.removeCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 16141 16142 if(!!result && BX.type.isArray(result['bxjs'])) 16143 { 16144 for(var i = 0; i < result['bxjs'].length; i++) 16145 { 16146 if(BX.type.isNotEmptyString(result['bxjs'][i])) 16147 { 16148 scripts.push({ 16149 "isInternal": false, 16150 "JS": result['bxjs'][i], 16151 "bRunFirst": config.scriptsRunFirst 16152 }); 16153 } 16154 else 16155 { 16156 scripts.push(result['bxjs'][i]) 16157 } 16158 } 16159 } 16160 16161 if(!!result && BX.type.isArray(result['bxcss'])) 16162 { 16163 styles = result['bxcss']; 16164 } 16165 16166 break; 16167 case 'SCRIPT': 16168 scripts.push({"isInternal": true, "JS": data, "bRunFirst": config.scriptsRunFirst}); 16169 result = data; 16170 break; 16171 16172 default: // HTML 16173 var ob = BX.processHTML(data, config.scriptsRunFirst); 16174 result = ob.HTML; scripts = ob.SCRIPT; styles = ob.STYLE; 16175 break; 16176 } 16177 16178 if (styles.length > 0) 16179 { 16180 BX.loadCSS(styles); 16181 } 16182 16183 let ajax_session = null; 16184 if (config.emulateOnload) 16185 { 16186 ajax_session = parseInt(Math.random() * 1000000); 16187 BX.ajax.__prepareOnload(scripts, ajax_session); 16188 } 16189 16190 const cb = BX.defer(function() 16191 { 16192 if (config.emulateOnload) 16193 { 16194 BX.ajax.__runOnload(ajax_session); 16195 } 16196 16197 BX.onCustomEvent(config.xhr, 'onAjaxSuccessFinish', [config]); 16198 }); 16199 16200 try 16201 { 16202 if (!!config.jsonFailure) 16203 { 16204 throw {type: 'json_failure', data: config.jsonResponse, bProactive: config.jsonProactive}; 16205 } 16206 16207 config.scripts = scripts; 16208 16209 BX.ajax.processScripts(config.scripts, true); 16210 16211 if (config.onsuccess) 16212 { 16213 config.onsuccess(result); 16214 } 16215 16216 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [result, config]); 16217 16218 BX.ajax.processScripts(config.scripts, false, cb); 16219 } 16220 catch (e) 16221 { 16222 if (config.onfailure) 16223 config.onfailure("processing", e); 16224 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['processing', e, config]); 16225 } 16226}; 16227 16228BX.ajax.processScripts = function(scripts, bRunFirst, cb) 16229{ 16230 var scriptsExt = [], scriptsInt = ''; 16231 16232 cb = cb || BX.DoNothing; 16233 16234 for (var i = 0, length = scripts.length; i < length; i++) 16235 { 16236 if (typeof bRunFirst != 'undefined' && bRunFirst != !!scripts[i].bRunFirst) 16237 continue; 16238 16239 if (scripts[i].isInternal) 16240 scriptsInt += ';' + scripts[i].JS; 16241 else 16242 scriptsExt.push(scripts[i].JS); 16243 } 16244 16245 scriptsExt = BX.util.array_unique(scriptsExt); 16246 var inlineScripts = scriptsInt.length > 0 ? function() { BX.evalGlobal(scriptsInt); } : BX.DoNothing; 16247 16248 if (scriptsExt.length > 0) 16249 { 16250 BX.load(scriptsExt, function() { 16251 inlineScripts(); 16252 cb(); 16253 }); 16254 } 16255 else 16256 { 16257 inlineScripts(); 16258 cb(); 16259 } 16260}; 16261 16262// TODO: extend this function to use with any data objects or forms 16263BX.ajax.prepareData = function(arData, prefix) 16264{ 16265 var data = ''; 16266 if (BX.type.isString(arData)) 16267 data = arData; 16268 else if (null != arData) 16269 { 16270 for(var i in arData) 16271 { 16272 if (arData.hasOwnProperty(i)) 16273 { 16274 if (data.length > 0) 16275 data += '&'; 16276 var name = BX.util.urlencode(i); 16277 if(prefix) 16278 name = prefix + '[' + name + ']'; 16279 if(typeof arData[i] == 'object') 16280 data += BX.ajax.prepareData(arData[i], name); 16281 else 16282 data += name + '=' + BX.util.urlencode(arData[i]); 16283 } 16284 } 16285 } 16286 return data; 16287}; 16288 16289BX.ajax.xhrSuccess = function(xhr) 16290{ 16291 return (xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || xhr.status === 1223 || xhr.status === 0; 16292}; 16293 16294BX.ajax.Setup = function(config, bTemp) 16295{ 16296 bTemp = !!bTemp; 16297 16298 for (var i in config) 16299 { 16300 if (bTemp) 16301 tempDefaultConfig[i] = config[i]; 16302 else 16303 defaultConfig[i] = config[i]; 16304 } 16305}; 16306 16307BX.ajax.replaceLocalStorageValue = function(lsId, data, ttl) 16308{ 16309 if (!!BX.localStorage) 16310 BX.localStorage.set('ajax-' + lsId, data, ttl); 16311}; 16312 16313 16314BX.ajax._uncache = function(url) 16315{ 16316 return url + ((url.indexOf('?') !== -1 ? "&" : "?") + '_=' + (new Date()).getTime()); 16317}; 16318 16319/* simple interface */ 16320BX.ajax.get = function(url, data, callback) 16321{ 16322 if (BX.type.isFunction(data)) 16323 { 16324 callback = data; 16325 data = ''; 16326 } 16327
16328 data = BX.ajax.prepareData(data); 16329 16330 if (data) 16331 { 16332 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 16333 data = ''; 16334 } 16335 16336 return BX.ajax({ 16337 'method': 'GET', 16338 'dataType': 'html', 16339 'url': url, 16340 'data': '', 16341 'onsuccess': callback 16342 }); 16343}; 16344 16345BX.ajax.getCaptcha = function(callback) 16346{ 16347 return BX.ajax.loadJSON('/bitrix/tools/ajax_captcha.php', callback); 16348}; 16349 16350BX.ajax.insertToNode = function(url, node) 16351{ 16352 node = BX(node); 16353 if (!!node) 16354 { 16355 var eventArgs = { cancel: false }; 16356 BX.onCustomEvent('onAjaxInsertToNode', [{ url: url, node: node, eventArgs: eventArgs }]); 16357 if(eventArgs.cancel === true) 16358 { 16359 return; 16360 } 16361 16362 var show = null; 16363 if (!tempDefaultConfig.denyShowWait) 16364 { 16365 show = BX.showWait(node); 16366 delete tempDefaultConfig.denyShowWait; 16367 } 16368 16369 return BX.ajax.get(url, function(data) { 16370 node.innerHTML = data; 16371 BX.closeWait(node, show); 16372 }); 16373 } 16374}; 16375 16376BX.ajax.post = function(url, data, callback) 16377{ 16378 data = BX.ajax.prepareData(data); 16379 16380 return BX.ajax({ 16381 'method': 'POST', 16382 'dataType': 'html', 16383 'url': url, 16384 'data': data, 16385 'onsuccess': callback 16386 }); 16387}; 16388 16389/** 16390 * BX.ajax with BX.Promise 16391 * 16392 * @param config 16393 * @returns {BX.Promise|false} 16394 */ 16395BX.ajax.promise = function(config) 16396{ 16397 var result = new BX.Promise(); 16398 16399 config.onsuccess = function(data) 16400 { 16401 result.fulfill(data); 16402 }; 16403 config.onfailure = function(reason, httpStatus, config) 16404 { 16405 result.reject({ 16406 reason: reason, 16407 data: httpStatus, 16408 ajaxConfig: config, 16409 xhr: config.xhr 16410 }); 16411 }; 16412 16413 var xhr = BX.ajax(config); 16414 if (xhr) 16415 { 16416 if (typeof config.onrequeststart === 'function') 16417 { 16418 config.onrequeststart(xhr); 16419 } 16420 } 16421 else 16422 { 16423 result.reject({ 16424 reason: "init", 16425 data: false 16426 }); 16427 } 16428 16429 return result; 16430}; 16431 16432/* load and execute external file script with onload emulation */ 16433BX.ajax.loadScriptAjax = function(script_src, callback, bPreload) 16434{ 16435 if (BX.type.isArray(script_src)) 16436 { 16437 for (var i=0,len=script_src.length;i<len;i++) 16438 { 16439 BX.ajax.loadScriptAjax(script_src[i], callback, bPreload); 16440 } 16441 } 16442 else 16443 { 16444 var script_src_test = script_src.replace(/\.js\?.*/, '.js'); 16445 16446 if (r.script_self.test(script_src_test)) return; 16447 if (r.script_self_window.test(script_src_test) && BX.CWindow) return; 16448 if (r.script_self_admin.test(script_src_test) && BX.admin) return; 16449 16450 if (typeof loadedScripts[script_src_test] == 'undefined') 16451 { 16452 if (!!bPreload) 16453 { 16454 loadedScripts[script_src_test] = ''; 16455 return BX.loadScript(script_src); 16456 } 16457 else 16458 { 16459 return BX.ajax({ 16460 url: script_src, 16461 method: 'GET', 16462 dataType: 'script', 16463 processData: true, 16464 emulateOnload: false, 16465 scriptsRunFirst: true, 16466 async: false, 16467 start: true, 16468 onsuccess: function(result) { 16469 loadedScripts[script_src_test] = result; 16470 if (callback) 16471 callback(result); 16472 } 16473 }); 16474 } 16475 } 16476 else if (callback) 16477 { 16478 callback(loadedScripts[script_src_test]); 16479 } 16480 } 16481}; 16482 16483/* non-xhr loadings */ 16484BX.ajax.loadJSON = function(url, data, callback, callback_failure) 16485{ 16486 if (BX.type.isFunction(data)) 16487 { 16488 callback_failure = callback; 16489 callback = data; 16490 data = ''; 16491 } 16492 16493 data = BX.ajax.prepareData(data); 16494 16495 if (data) 16496 { 16497 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 16498 data = ''; 16499 } 16500 16501 return BX.ajax({ 16502 'method': 'GET', 16503 'dataType': 'json', 16504 'url': url, 16505 'onsuccess': callback, 16506 'onfailure': callback_failure 16507 }); 16508}; 16509 16510var getLastContentTypeHeader = function (headers) { 16511 if (!BX.Type.isArray(headers)) 16512 { 16513 return null; 16514 } 16515 var lastHeader = headers 16516 .filter(function (header) { 16517 return header.name === 'Content-Type'; 16518 }) 16519 .pop(); 16520 16521 return lastHeader ? lastHeader.value : null; 16522}; 16523 16524/** 16525 * @see isValidAnalyticsData in ui.analytics 16526* */ 16527const isValidAnalyticsData = function (analytics) 16528{ 16529 if (!BX.Type.isPlainObject(analytics)) 16530 { 16531 console.error('BX.ajax: {analytics} must be an object.'); 16532 16533 return false; 16534 } 16535 16536 const requiredFields = ['event', 'tool', 'category']; 16537 for (const field of requiredFields) 16538 { 16539 if (!BX.Type.isStringFilled(analytics[field])) 16540 { 16541 console.error(`BX.ajax: The "${field}" property in the "analytics" object must be a non-empty string.`); 16542 16543 return false;
16544 } 16545 } 16546 16547 const additionalFields = ['p1', 'p2', 'p3', 'p4', 'p5']; 16548 for (const field of additionalFields) 16549 { 16550 const value = analytics[field]; 16551 if (!BX.Type.isStringFilled(value)) 16552 { 16553 continue; 16554 } 16555 16556 if (value.split('_').length > 2) 16557 { 16558 console.error(`BX.ajax: The "${field}" property (${value}) in the "analytics" object must be a string containing a single underscore.`); 16559 16560 return false; 16561 } 16562 } 16563 16564 return true; 16565}; 16566 16567const processAnalyticsDataToGetParameters = function(config) 16568{ 16569 const getParameters = {}; 16570 if (BX.Type.isStringFilled(config.analyticsLabel) || BX.Type.isPlainObject(config.analyticsLabel)) 16571 { 16572 getParameters.analyticsLabel = config.analyticsLabel; 16573 } 16574 16575 if (BX.Type.isPlainObject(config.analytics)) 16576 { 16577 if (config.analyticsLabel) 16578 { 16579 delete getParameters.analyticsLabel; 16580 console.error('BX.ajax: Only {analytics} or {analyticsLabel} should be used. If both are present, {analyticsLabel} will be ignored.'); 16581 } 16582 16583 if (isValidAnalyticsData(config.analytics)) 16584 { 16585 getParameters.st = config.analytics; 16586 } 16587 else 16588 { 16589 console.error('BX.ajax: {analytics} is invalid and is skipped.'); 16590 } 16591 } 16592 16593 return getParameters; 16594}; 16595 16596const prepareAjaxGetParameters = function(config) 16597{ 16598 let getParameters = config.getParameters || {}; 16599 getParameters = { ...getParameters, ...processAnalyticsDataToGetParameters(config) }; 16600 16601 if (typeof config.mode !== 'undefined') 16602 { 16603 getParameters.mode = config.mode; 16604 } 16605 if (config.navigation) 16606 { 16607 if (config.navigation.page) 16608 { 16609 getParameters.nav = 'page-' + config.navigation.page; 16610 } 16611 if (config.navigation.size) 16612 { 16613 if (getParameters.nav) 16614 { 16615 getParameters.nav += '-'; 16616 } 16617 else 16618 { 16619 getParameters.nav = ''; 16620 } 16621 getParameters.nav += 'size-' + config.navigation.size; 16622 } 16623 } 16624 16625 return getParameters; 16626}; 16627 16628var prepareAjaxConfig = function(config) 16629{ 16630 config = BX.type.isPlainObject(config) ? config : {}; 16631 16632 config.headers = config.headers || []; 16633 config.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 16634 if (BX.message.SITE_ID) 16635 { 16636 config.headers.push({name: 'X-Bitrix-Site-Id', value: BX.message.SITE_ID}); 16637 } 16638 16639 if (typeof config.json !== 'undefined') 16640 { 16641 if (!BX.type.isPlainObject(config.json)) 16642 { 16643 throw new Error('Wrong `config.json`, plain object expected.') 16644 } 16645 16646 config.headers.push({name: 'Content-Type', value: 'application/json'}); 16647 config.data = config.json; 16648 config.preparePost = false; 16649 } 16650 else if (config.data instanceof FormData) 16651 { 16652 config.preparePost = false; 16653 if (typeof config.signedParameters !== 'undefined') 16654 { 16655 config.data.append('signedParameters', config.signedParameters); 16656 } 16657 } 16658 else if (BX.type.isPlainObject(config.data) || BX.Type.isNil(config.data)) 16659 { 16660 config.data = BX.type.isPlainObject(config.data) ? config.data : {}; 16661 if (typeof config.signedParameters !== 'undefined') 16662 { 16663 config.data.signedParameters = config.signedParameters; 16664 } 16665 } 16666 16667 if (!config.method) 16668 { 16669 config.method = 'POST' 16670 } 16671 16672 return config; 16673}; 16674 16675var buildAjaxPromiseToRestoreCsrf = function(config, withoutRestoringCsrf) 16676{ 16677 withoutRestoringCsrf = withoutRestoringCsrf || false; 16678 var originalConfig = BX.clone(config); 16679 var request = null; 16680 16681 var onrequeststart = config.onrequeststart; 16682 config.onrequeststart = function(xhr) { 16683 request = xhr; 16684 if (BX.type.isFunction(onrequeststart)) 16685 { 16686 onrequeststart(xhr); 16687 } 16688 }; 16689 var onrequeststartOrig = originalConfig.onrequeststart; 16690 originalConfig.onrequeststart = function(xhr) { 16691 request = xhr; 16692 if (BX.type.isFunction(onrequeststartOrig)) 16693 { 16694 onrequeststartOrig(xhr); 16695 } 16696 }; 16697 16698 var promise = BX.ajax.promise(config); 16699 16700 return promise.then(function(response) { 16701 if (!withoutRestoringCsrf && BX.type.isPlainObject(response) && BX.type.isArray(response.errors)) 16702 { 16703 var csrfProblem = false; 16704 response.errors.forEach(function(error) { 16705 if (error.code === 'invalid_csrf' && error.customData.csrf) 16706 { 16707 BX.message({'bitrix_sessid': error.customData.csrf}); 16708 16709 originalConfig.headers = originalConfig.headers || []; 16710 originalConfig.headers = originalConfig.headers.filter(function(header) {
16711 return header && header.name !== 'X-Bitrix-Csrf-Token'; 16712 }); 16713 originalConfig.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 16714 16715 csrfProblem = true; 16716 } 16717 }); 16718 16719 if (csrfProblem) 16720 { 16721 return buildAjaxPromiseToRestoreCsrf(originalConfig, true); 16722 } 16723 } 16724 16725 if (!BX.type.isPlainObject(response) || response.status !== 'success') 16726 { 16727 var errorPromise = new BX.Promise(); 16728 errorPromise.reject(response); 16729 16730 return errorPromise; 16731 } 16732 16733 return response; 16734 }).catch(function(data) { 16735 var ajaxReject = new BX.Promise(); 16736 16737 var originalJsonResponse; 16738 if (BX.type.isPlainObject(data) && data.xhr && data.xhr.responseText) 16739 { 16740 try 16741 { 16742 originalJsonResponse = JSON.parse(data.xhr.responseText); 16743 data = originalJsonResponse; 16744 } 16745 catch (err) 16746 {} 16747 } 16748 16749 if (BX.type.isPlainObject(data) && data.status && data.hasOwnProperty('data')) 16750 { 16751 ajaxReject.reject(data); 16752 } 16753 else 16754 { 16755 ajaxReject.reject({ 16756 status: 'error', 16757 data: { 16758 ajaxRejectData: data 16759 }, 16760 errors: [ 16761 { 16762 code: 'NETWORK_ERROR', 16763 message: 'Network error' 16764 } 16765 ] 16766 }); 16767 } 16768 16769 return ajaxReject; 16770 }).then(function(response){ 16771 16772 var assetsLoaded = new BX.Promise(); 16773 16774 var headers = request.getAllResponseHeaders().trim().split(/[\r\n]+/); 16775 var headerMap = {}; 16776 headers.forEach(function (line) { 16777 var parts = line.split(': '); 16778 var header = parts.shift().toLowerCase(); 16779 headerMap[header] = parts.join(': '); 16780 }); 16781 16782 if (!headerMap['x-process-assets']) 16783 { 16784 assetsLoaded.fulfill(response); 16785 16786 return assetsLoaded; 16787 } 16788 16789 var assets = BX.prop.getObject(BX.prop.getObject(response, "data", {}), "assets", {}); 16790 16791 var inlineScripts = []; 16792 if (BX.Type.isArrayFilled(assets.string)) 16793 { 16794 assets.string 16795 .reduce(function(acc, item) { 16796 if (String(item).length > 0 && !acc.includes(item)) 16797 { 16798 acc.push(item); 16799 } 16800 16801 return acc; 16802 }, []) 16803 .forEach(function(item) { 16804 if (String(item).startsWith('<script type="extension/settings"')) 16805 { 16806 BX.html(document.head, item, { useAdjacentHTML: true }); 16807 } 16808 else 16809 { 16810 inlineScripts.push(item); 16811 } 16812 }); 16813 } 16814 16815 var promise = new Promise(function(resolve, reject) { 16816 var css = BX.prop.getArray(assets, "css", []); 16817 BX.load(css, function(){ 16818 BX.loadScript( 16819 BX.prop.getArray(assets, "js", []), 16820 resolve 16821 ); 16822 }); 16823 }); 16824 16825 promise.then(function(){ 16826 var stringAsset = inlineScripts.join('\n'); 16827 BX.html(document.head, stringAsset, { useAdjacentHTML: true }).then(function(){ 16828 assetsLoaded.fulfill(response); 16829 }); 16830 }); 16831 16832 return assetsLoaded; 16833 }); 16834}; 16835 16836/** 16837 * 16838 * @param {string} action 16839 * @param {Object} config 16840 * @param {?string|?Object} [config.analyticsLabel] 16841 * @param {?Object} [config.analytics] 16842 * @param {string} [config.analytics.event] 16843 * @param {string} [config.analytics.tool] 16844 * @param {string} [config.analytics.category] 16845 * @param {?string} [config.analytics.c_section] 16846 * @param {?string} [config.analytics.c_sub_section] 16847 * @param {?string} [config.analytics.c_element] 16848 * @param {?string} [config.analytics.type] 16849 * @param {?string} [config.analytics.p1] 16850 * @param {?string} [config.analytics.p2] 16851 * @param {?string} [config.analytics.p3] 16852 * @param {?string} [config.analytics.p4] 16853 * @param {?string} [config.analytics.p5] 16854 * @param {?('success' | 'error' | 'attempt' | 'cancel')} [config.analytics.status] 16855 * @param {string} [config.method='POST'] 16856 * @param {Object} [config.data] 16857 * @param {?Object} [config.getParameters] 16858 * @param {?Object} [config.headers] 16859 * @param {?Object} [config.timeout] 16860 * @param {Object} [config.navigation] 16861 * @param {number} [config.navigation.page] 16862 */ 16863BX.ajax.runAction = function(action, config) 16864{ 16865 config = prepareAjaxConfig(config); 16866 var getParameters = prepareAjaxGetParameters(config); 16867 getParameters.action = action; 16868
16869 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 16870 return buildAjaxPromiseToRestoreCsrf({ 16871 method: config.method, 16872 dataType: 'json', 16873 url: url, 16874 data: config.data, 16875 timeout: config.timeout, 16876 preparePost: config.preparePost, 16877 headers: config.headers, 16878 onrequeststart: config.onrequeststart, 16879 onprogress: config.onprogress, 16880 onprogressupload: config.onprogressupload 16881 }); 16882}; 16883 16884/** 16885 * 16886 * @param {string} component 16887 * @param {string} action 16888 * @param {Object} config 16889 * @param {?string|?Object} [config.analyticsLabel] 16890 * @param {?Object} [config.analytics] 16891 * @param {string} [config.analytics.event] 16892 * @param {string} [config.analytics.tool] 16893 * @param {string} [config.analytics.category] 16894 * @param {?string} [config.analytics.c_section] 16895 * @param {?string} [config.analytics.c_sub_section] 16896 * @param {?string} [config.analytics.c_element] 16897 * @param {?string} [config.analytics.type] 16898 * @param {?string} [config.analytics.p1] 16899 * @param {?string} [config.analytics.p2] 16900 * @param {?string} [config.analytics.p3] 16901 * @param {?string} [config.analytics.p4] 16902 * @param {?string} [config.analytics.p5] 16903 * @param {?string} [config.signedParameters] 16904 * @param {string} [config.method='POST'] 16905 * @param {string} [config.mode='ajax'] Ajax or class. 16906 * @param {Object} [config.data] 16907 * @param {?Object} [config.getParameters] 16908 * @param {?array} [config.headers] 16909 * @param {?number} [config.timeout] 16910 * @param {Object} [config.navigation] 16911 */ 16912BX.ajax.runComponentAction = function (component, action, config) 16913{ 16914 config = prepareAjaxConfig(config); 16915 config.mode = config.mode || 'ajax'; 16916 16917 var getParameters = prepareAjaxGetParameters(config); 16918 getParameters.c = component; 16919 getParameters.action = action; 16920
16921 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 16922 16923 return buildAjaxPromiseToRestoreCsrf({ 16924 method: config.method, 16925 dataType: 'json', 16926 url: url, 16927 data: config.data, 16928 timeout: config.timeout, 16929 preparePost: config.preparePost, 16930 headers: config.headers, 16931 onrequeststart: (config.onrequeststart ? config.onrequeststart : null), 16932 onprogress: config.onprogress, 16933 onprogressupload: config.onprogressupload 16934 }); 16935}; 16936 16937/* 16938arObs = [{ 16939 url: url, 16940 type: html|script|json|css, 16941 callback: function 16942}] 16943*/ 16944BX.ajax.load = function(arObs, callback) 16945{ 16946 if (!BX.type.isArray(arObs)) 16947 arObs = [arObs]; 16948 16949 var cnt = 0; 16950 16951 if (!BX.type.isFunction(callback)) 16952 callback = BX.DoNothing; 16953 16954 var handler = function(data) 16955 { 16956 if (BX.type.isFunction(this.callback)) 16957 this.callback(data); 16958 16959 if (++cnt >= len) 16960 callback(); 16961 }; 16962 16963 for (var i = 0, len = arObs.length; i<len; i++) 16964 { 16965 switch(arObs[i].type.toUpperCase()) 16966 { 16967 case 'SCRIPT': 16968 BX.loadScript([arObs[i].url], BX.proxy(handler, arObs[i])); 16969 break; 16970 case 'CSS': 16971 BX.loadCSS([arObs[i].url]); 16972 16973 if (++cnt >= len) 16974 callback(); 16975 break; 16976 case 'JSON': 16977 BX.ajax.loadJSON(arObs[i].url, BX.proxy(handler, arObs[i])); 16978 break; 16979 16980 default: 16981 BX.ajax.get(arObs[i].url, '', BX.proxy(handler, arObs[i])); 16982 break; 16983 } 16984 } 16985}; 16986 16987/* ajax form sending */ 16988BX.ajax.submit = function(obForm, callback) 16989{ 16990 if (!obForm.target) 16991 { 16992 if (null == obForm.BXFormTarget) 16993 { 16994 var frame_name = 'formTarget_' + Math.random(); 16995 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 16996 props: { 16997 name: frame_name, 16998 id: frame_name, 16999 src: 'javascript:void(0)' 17000 }, 17001 style: { 17002 display: 'none' 17003 } 17004 })); 17005 } 17006 17007 obForm.target = obForm.BXFormTarget.name; 17008 } 17009 17010 obForm.BXFormCallback = callback; 17011 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 17012 17013 BX.submit(obForm); 17014 17015 return false; 17016}; 17017 17018BX.ajax.submitComponentForm = function(obForm, container, bWait) 17019{ 17020 if (!obForm.target) 17021 { 17022 if (null == obForm.BXFormTarget) 17023 { 17024 var frame_name = 'formTarget_' + Math.random(); 17025 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 17026 props: { 17027 name: frame_name, 17028 id: frame_name, 17029 src: 'javascript:void(0)' 17030 }, 17031 style: { 17032 display: 'none' 17033 } 17034 })); 17035 } 17036 17037 obForm.target = obForm.BXFormTarget.name; 17038 } 17039 17040 if (!!bWait) 17041 var w = BX.showWait(container); 17042 17043 obForm.BXFormCallback = function(d) { 17044 if (!!bWait) 17045 BX.closeWait(w); 17046 17047 var callOnload = function(){ 17048 if(!!window.bxcompajaxframeonload) 17049 { 17050 setTimeout(function(){window.bxcompajaxframeonload();window.bxcompajaxframeonload=null;}, 10); 17051 } 17052 }; 17053 17054 BX(container).innerHTML = d; 17055 BX.onCustomEvent('onAjaxSuccess', [null,null,callOnload]); 17056 }; 17057 17058 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 17059 17060 return true; 17061}; 17062 17063// func will be executed in form context 17064BX.ajax._submit_callback = function() 17065{ 17066 //opera and IE8 triggers onload event even on empty iframe 17067 try 17068 { 17069 if(this.BXFormTarget.contentWindow.location.href.indexOf('http') != 0) 17070 return; 17071 } catch (e) { 17072 return; 17073 } 17074 17075 if (this.BXFormCallback) 17076 this.BXFormCallback.apply(this, [this.BXFormTarget.contentWindow.document.body.innerHTML]); 17077 17078 BX.unbindAll(this.BXFormTarget); 17079}; 17080 17081BX.ajax.prepareForm = function(obForm, data) 17082{ 17083 data = (!!data ? data : {}); 17084 var i, ii, el, 17085 _data = [], 17086 n = obForm.elements.length, 17087 files = 0, length = 0; 17088 if(!!obForm) 17089 { 17090 for (i = 0; i < n; i++) 17091 { 17092 el = obForm.elements[i]; 17093 if (el.disabled) 17094 continue; 17095 17096 if(!el.type) 17097 continue; 17098 17099 switch(el.type.toLowerCase()) 17100 { 17101 case 'text': 17102 case 'textarea': 17103 case 'password': 17104 case 'number': 17105 case 'hidden': 17106 case 'select-one': 17107 _data.push({name: el.name, value: el.value}); 17108 length += (el.name.length + el.value.length); 17109 break; 17110 case 'file': 17111 if (!!el.files) 17112 { 17113 for (ii = 0; ii < el.files.length; ii++) 17114 { 17115 files++; 17116 _data.push({name: el.name, value: el.files[ii], file : true}); 17117 length += el.files[ii].size; 17118 } 17119 } 17120 break; 17121 case 'radio':
17122 case 'checkbox': 17123 if(el.checked) 17124 { 17125 _data.push({name: el.name, value: el.value}); 17126 length += (el.name.length + el.value.length); 17127 } 17128 break; 17129 case 'select-multiple': 17130 for (var j = 0; j < el.options.length; j++) 17131 { 17132 if (el.options[j].selected) 17133 { 17134 _data.push({name : el.name, value : el.options[j].value}); 17135 length += (el.name.length + el.options[j].length); 17136 } 17137 } 17138 break; 17139 default: 17140 break; 17141 } 17142 } 17143 17144 i = 0; length = 0; 17145 var current = data, name, rest, pp, tmpKey; 17146 17147 while(i < _data.length) 17148 { 17149 var p = _data[i].name.indexOf('['); 17150 if (tmpKey) 17151 { 17152 current[_data[i].name] = {}; 17153 current[_data[i].name][tmpKey.replace(/\[|\]/gi, '')] = _data[i].value; 17154 current = data; 17155 tmpKey = null; 17156 i++; 17157 } 17158 else if (p == -1) 17159 { 17160 current[_data[i].name] = _data[i].value; 17161 current = data; 17162 i++; 17163 } 17164 else 17165 { 17166 name = _data[i].name.substring(0, p); 17167 rest = _data[i].name.substring(p+1); 17168 pp = rest.indexOf(']'); 17169 17170 if(pp == -1) 17171 { 17172 if (!current[name]) 17173 current[name] = []; 17174 current = data; 17175 i++; 17176 } 17177 else if(pp == 0) 17178 { 17179 if (!current[name]) 17180 current[name] = []; 17181 //No index specified - so take the next integer 17182 current = current[name]; 17183 _data[i].name = '' + current.length; 17184 if (rest.substring(pp+1).indexOf('[') === 0) 17185 tmpKey = rest.substring(0, pp) + rest.substring(pp+1); 17186 } 17187 else 17188 { 17189 if (!current[name]) 17190 current[name] = {}; 17191 //Now index name becomes and name and we go deeper into the array 17192 current = current[name]; 17193 _data[i].name = rest.substring(0, pp) + rest.substring(pp+1); 17194 } 17195 } 17196 } 17197 } 17198 return {data : data, filesCount : files, roughSize : length}; 17199}; 17200BX.ajax.submitAjax = function(obForm, config) 17201{ 17202 config = (config !== null && typeof config == "object" ? config : {}); 17203 config.url = (config["url"] || obForm.getAttribute("action")); 17204 17205 var additionalData = (config["data"] || {}); 17206 config.data = BX.ajax.prepareForm(obForm).data; 17207 for (var ii in additionalData) 17208 { 17209 if (additionalData.hasOwnProperty(ii)) 17210 { 17211 config.data[ii] = additionalData[ii]; 17212 } 17213 } 17214 17215 if (!window["FormData"]) 17216 { 17217 BX.ajax(config); 17218 } 17219 else 17220 { 17221 var isFile = function(item) 17222 { 17223 var res = Object.prototype.toString.call(item); 17224 return (res == '[object File]' || res == '[object Blob]'); 17225 }, 17226 appendToForm = function(fd, key, val) 17227 { 17228 if (!!val && typeof val == "object" && !isFile(val)) 17229 { 17230 for (var ii in val) 17231 { 17232 if (val.hasOwnProperty(ii)) 17233 { 17234 appendToForm(fd, (key == '' ? ii : key + '[' + ii + ']'), val[ii]); 17235 } 17236 } 17237 } 17238 else 17239 fd.append(key, (!!val ? val : '')); 17240 }, 17241 prepareData = function(arData) 17242 { 17243 var data = {}; 17244 if (null != arData) 17245 { 17246 if(typeof arData == 'object') 17247 { 17248 for(var i in arData) 17249 { 17250 if (arData.hasOwnProperty(i)) 17251 { 17252 var name = BX.util.urlencode(i); 17253 if(typeof arData[i] == 'object' && arData[i]["file"] !== true) 17254 data[name] = prepareData(arData[i]); 17255 else if (arData[i]["file"] === true) 17256 data[name] = arData[i]["value"]; 17257 else 17258 data[name] = BX.util.urlencode(arData[i]); 17259 } 17260 } 17261 } 17262 else 17263 data = BX.util.urlencode(arData); 17264 } 17265 return data; 17266 }, 17267 fd = new window.FormData(); 17268 17269 if (config.method !== 'POST') 17270 { 17271 config.data = BX.ajax.prepareData(config.data); 17272 if (config.data) 17273 { 17274 config.url += (config.url.indexOf('?') !== -1 ? "&" : "?") + config.data; 17275 config.data = ''; 17276 } 17277 } 17278 else 17279 { 17280 if (config.preparePost === true) 17281 config.data = prepareData(config.data); 17282 appendToForm(fd, '', config.data); 17283 config.data = fd; 17284 } 17285 17286 config.preparePost = false; 17287 config.start = false;
17288 17289 var xhr = BX.ajax(config); 17290 if (!!config["onprogress"]) 17291 xhr.upload.addEventListener( 17292 'progress', 17293 function(e){ 17294 var percent = null; 17295 if(e.lengthComputable && (e.total || e["totalSize"])) { 17296 percent = e.loaded * 100 / (e.total || e["totalSize"]); 17297 } 17298 config["onprogress"](e, percent); 17299 } 17300 ); 17301 xhr.send(fd); 17302 } 17303}; 17304 17305BX.ajax.UpdatePageData = function (arData) 17306{ 17307 if (arData.TITLE) 17308 BX.ajax.UpdatePageTitle(arData.TITLE); 17309 if (arData.WINDOW_TITLE || arData.TITLE) 17310 BX.ajax.UpdateWindowTitle(arData.WINDOW_TITLE || arData.TITLE); 17311 if (arData.NAV_CHAIN) 17312 BX.ajax.UpdatePageNavChain(arData.NAV_CHAIN); 17313 if (arData.CSS && arData.CSS.length > 0) 17314 BX.loadCSS(arData.CSS); 17315 if (arData.SCRIPTS && arData.SCRIPTS.length > 0) 17316 { 17317 var f = function(result,config,cb){ 17318 17319 if(!!config && BX.type.isArray(config.scripts)) 17320 { 17321 for(var i=0,l=arData.SCRIPTS.length;i<l;i++) 17322 { 17323 config.scripts.push({isInternal:false,JS:arData.SCRIPTS[i]}); 17324 } 17325 } 17326 else 17327 { 17328 BX.loadScript(arData.SCRIPTS,cb); 17329 } 17330 17331 BX.removeCustomEvent('onAjaxSuccess',f); 17332 }; 17333 BX.addCustomEvent('onAjaxSuccess',f); 17334 } 17335 else 17336 { 17337 var f1 = function(result,config,cb){ 17338 if(BX.type.isFunction(cb)) 17339 { 17340 cb(); 17341 } 17342 BX.removeCustomEvent('onAjaxSuccess',f1); 17343 }; 17344 BX.addCustomEvent('onAjaxSuccess', f1); 17345 } 17346}; 17347 17348BX.ajax.UpdatePageTitle = function(title) 17349{ 17350 var obTitle = BX('pagetitle'); 17351 if (obTitle) 17352 { 17353 BX.remove(obTitle.firstChild); 17354 if (!obTitle.firstChild) 17355 obTitle.appendChild(document.createTextNode(title)); 17356 else 17357 obTitle.insertBefore(document.createTextNode(title), obTitle.firstChild); 17358 } 17359}; 17360 17361BX.ajax.UpdateWindowTitle = function(title) 17362{ 17363 document.title = title; 17364}; 17365 17366BX.ajax.UpdatePageNavChain = function(nav_chain) 17367{ 17368 var obNavChain = BX('navigation'); 17369 if (obNavChain) 17370 { 17371 obNavChain.innerHTML = nav_chain; 17372 } 17373}; 17374 17375/* user options handling */ 17376BX.userOptions = { 17377 options: null, 17378 bSend: false, 17379 delay: 5000, 17380 path: '/bitrix/admin/user_options.php?' 17381}; 17382 17383BX.userOptions.setAjaxPath = function(url) 17384{ 17385 // eslint-disable-next-line no-console 17386 console.warn('BX.userOptions.setAjaxPath is deprecated. There is no way to change ajax path.'); 17387}; 17388BX.userOptions.save = function(category, name, valueName, value, common) 17389{ 17390 if (BX.userOptions.options === null) 17391 { 17392 BX.userOptions.options = {}; 17393 } 17394 17395 common = Boolean(common); 17396 BX.userOptions.options[`${category}.${name}.${valueName}`] = [category, name, valueName, value, common]; 17397 17398 const stringPackedValue = BX.userOptions.__get(); 17399 if (stringPackedValue) 17400 { 17401 document.cookie = `${BX.message('COOKIE_PREFIX')}_LAST_SETTINGS=${encodeURIComponent(stringPackedValue)}&sessid=${BX.bitrix_sessid()}; expires=Thu, 31 Dec ${(new Date()).getFullYear() + 1} 23:59:59 GMT; path=/;`; 17402 } 17403 17404 if (!BX.userOptions.bSend) 17405 { 17406 BX.userOptions.bSend = true; 17407 setTimeout(() => { 17408 BX.userOptions.send(null); 17409 }, BX.userOptions.delay); 17410 } 17411}; 17412 17413BX.userOptions.send = function(callback) 17414{ 17415 const values = BX.userOptions.__get_values({ backwardCompatibility: true}); 17416 17417 BX.userOptions.options = null; 17418 BX.userOptions.bSend = false; 17419 17420 if (values) 17421 { 17422 document.cookie = `${BX.message('COOKIE_PREFIX')}_LAST_SETTINGS=; path=/;`; 17423 17424 BX.ajax.runAction( 17425 'main.userOption.saveOptions', 17426 { 17427 json: { 17428 newValues: values, 17429 }, 17430 }, 17431 ).then((response) => { 17432 if (BX.type.isFunction(callback)) 17433 { 17434 callback(response); 17435 } 17436 }); 17437 } 17438}; 17439 17440BX.userOptions.del = function(category, name, common, callback) 17441{ 17442 BX.ajax.runAction( 17443 'main.userOption.deleteOption', 17444 { 17445 json: { 17446 category, 17447 name, 17448 common, 17449 }, 17450 }, 17451 ).then((response) => { 17452 if (BX.type.isFunction(callback)) 17453 { 17454 callback(response); 17455 } 17456 }); 17457}; 17458 17459BX.userOptions.__get_values = function({ backwardCompatibility }) 17460{ 17461 if (!BX.userOptions || !BX.Type.isPlainObject(BX.userOptions.options)) 17462 { 17463 return null; 17464 } 17465 17466 const CATEGORY = 0; 17467 const NAME = 1; 17468 const VALUE_NAME = 2; 17469 const VALUE = 3; 17470 const IS_DEFAULT = 4; 17471 17472 const packedValues = { p: [] }; 17473 let currentIndex = -1; 17474 let previousOptionIdentifier = ''; 17475 17476 Object.entries(BX.userOptions.options).forEach(([key, userOption]) => { 17477 const category = userOption[CATEGORY]; 17478 const name = userOption[NAME]; 17479 const currentOptionIdentifier = `${category}.${name}`; 17480 17481 if (previousOptionIdentifier !== currentOptionIdentifier) 17482 { 17483 currentIndex++; 17484 packedValues.p.push({ 17485 c: category, 17486 n: name, 17487 v: {}, 17488 }); 17489 if (userOption[IS_DEFAULT] === true) 17490 { 17491 packedValues.p[currentIndex].d = 'Y'; 17492 } 17493 previousOptionIdentifier = currentOptionIdentifier; 17494 } 17495 17496 if (userOption[VALUE_NAME] === null) 17497 { 17498 packedValues.p[currentIndex].v = userOption[VALUE]; 17499 } 17500 else 17501 { 17502 let data = userOption[VALUE]; 17503 if (backwardCompatibility && Array.isArray(userOption[VALUE])) 17504 { 17505 data = userOption[VALUE].join(','); 17506 } 17507 packedValues.p[currentIndex].v[userOption[VALUE_NAME]] = data; 17508 } 17509 }); 17510 17511 return packedValues.p.length > 0 ? packedValues.p : null; 17512}; 17513 17514/** 17515 * @deprecated Use instead BX.userOptions.__get_values. 17516 * */ 17517BX.userOptions.__get = function() 17518{ 17519 if (!BX.userOptions.options) return ''; 17520 17521 var sParam = '', n = -1, prevParam = '', aOpt, i; 17522 17523 for (i in BX.userOptions.options) 17524 { 17525 if(BX.userOptions.options.hasOwnProperty(i)) 17526 { 17527 aOpt = BX.userOptions.options[i]; 17528 17529 if (prevParam != aOpt[0]+'.'+aOpt[1]) 17530 { 17531 n++; 17532 sParam += '&p['+n+'][c]='+BX.util.urlencode(aOpt[0]); 17533 sParam += '&p['+n+'][n]='+BX.util.urlencode(aOpt[1]); 17534 if (aOpt[4] == true) 17535 sParam += '&p['+n+'][d]=Y'; 17536 prevParam = aOpt[0]+'.'+aOpt[1]; 17537 } 17538 17539 var valueName = aOpt[2]; 17540 var value = aOpt[3]; 17541 17542 if (valueName === null) 17543 { 17544 sParam += '&p['+n+'][v]='+BX.util.urlencode(value); 17545 } 17546 else 17547 {
17548 sParam += '&p['+n+'][v]['+BX.util.urlencode(valueName)+']='+BX.util.urlencode(value); 17549 } 17550 } 17551 } 17552 17553 return sParam.substr(1); 17554}; 17555 17556BX.ajax.history = { 17557 expected_hash: '', 17558 17559 obParams: null, 17560 17561 obFrame: null, 17562 obImage: null, 17563 17564 obTimer: null, 17565 17566 bInited: false, 17567 bHashCollision: false, 17568 bPushState: !!(history.pushState && BX.type.isFunction(history.pushState)), 17569 17570 startState: null, 17571 17572 init: function(obParams) 17573 { 17574 if (BX.ajax.history.bInited) 17575 return; 17576 17577 this.obParams = obParams; 17578 var obCurrentState = this.obParams.getState(); 17579 17580 if (BX.ajax.history.bPushState) 17581 { 17582 BX.ajax.history.expected_hash = window.location.pathname; 17583 if (window.location.search) 17584 BX.ajax.history.expected_hash += window.location.search; 17585 17586 BX.ajax.history.put(obCurrentState, BX.ajax.history.expected_hash, '', true); 17587 // due to some strange thing, chrome calls popstate event on page start. so we should delay it 17588 setTimeout(function(){BX.bind(window, 'popstate', BX.ajax.history.__hashListener);}, 500); 17589 } 17590 else 17591 { 17592 BX.ajax.history.expected_hash = window.location.hash; 17593 17594 if (!BX.ajax.history.expected_hash || BX.ajax.history.expected_hash == '#') 17595 BX.ajax.history.expected_hash = '__bx_no_hash__'; 17596 17597 jsAjaxHistoryContainer.put(BX.ajax.history.expected_hash, obCurrentState); 17598 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 17599 17600 if (BX.browser.IsIE()) 17601 { 17602 BX.ajax.history.obFrame = document.createElement('IFRAME'); 17603 BX.hide_object(BX.ajax.history.obFrame); 17604 17605 document.body.appendChild(BX.ajax.history.obFrame); 17606 17607 BX.ajax.history.obFrame.contentWindow.document.open(); 17608 BX.ajax.history.obFrame.contentWindow.document.write(BX.ajax.history.expected_hash); 17609 BX.ajax.history.obFrame.contentWindow.document.close(); 17610 } 17611 else if (BX.browser.IsOpera()) 17612 { 17613 BX.ajax.history.obImage = document.createElement('IMG'); 17614 BX.hide_object(BX.ajax.history.obImage); 17615 17616 document.body.appendChild(BX.ajax.history.obImage); 17617 17618 BX.ajax.history.obImage.setAttribute('src', 'javascript:location.href = \'javascript:BX.ajax.history.__hashListener();\';'); 17619 } 17620 } 17621 17622 BX.ajax.history.bInited = true; 17623 }, 17624 17625 __hashListener: function(e) 17626 { 17627 e = e || window.event || {state:false}; 17628 17629 if (BX.ajax.history.bPushState) 17630 { 17631 BX.ajax.history.obParams.setState(e.state||BX.ajax.history.startState); 17632 } 17633 else 17634 { 17635 if (BX.ajax.history.obTimer) 17636 { 17637 window.clearTimeout(BX.ajax.history.obTimer); 17638 BX.ajax.history.obTimer = null; 17639 } 17640 17641 var current_hash; 17642 if (null != BX.ajax.history.obFrame) 17643 current_hash = BX.ajax.history.obFrame.contentWindow.document.body.innerText; 17644 else 17645 current_hash = window.location.hash; 17646 17647 if (!current_hash || current_hash == '#') 17648 current_hash = '__bx_no_hash__'; 17649 17650 if (current_hash.indexOf('#') == 0) 17651 current_hash = current_hash.substring(1); 17652 17653 if (current_hash != BX.ajax.history.expected_hash) 17654 { 17655 var state = jsAjaxHistoryContainer.get(current_hash); 17656 if (state) 17657 { 17658 BX.ajax.history.obParams.setState(state); 17659 17660 BX.ajax.history.expected_hash = current_hash; 17661 if (null != BX.ajax.history.obFrame) 17662 { 17663 var __hash = current_hash == '__bx_no_hash__' ? '' : current_hash; 17664 if (window.location.hash != __hash && window.location.hash != '#' + __hash) 17665 window.location.hash = __hash; 17666 } 17667 } 17668 } 17669 17670 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 17671 } 17672 }, 17673 17674 put: function(state, new_hash, new_hash1, bStartState) 17675 { 17676 if (this.bPushState) 17677 { 17678 if(!bStartState) 17679 { 17680 history.pushState(state, '', new_hash); 17681 } 17682 else 17683 { 17684 BX.ajax.history.startState = state; 17685 } 17686 } 17687 else 17688 { 17689 if (typeof new_hash1 != 'undefined') 17690 new_hash = new_hash1; 17691 else 17692 new_hash = 'view' + new_hash; 17693 17694 jsAjaxHistoryContainer.put(new_hash, state); 17695 BX.ajax.history.expected_hash = new_hash; 17696 17697 window.location.hash = BX.util.urlencode(new_hash); 17698 17699 if (null != BX.ajax.history.obFrame) 17700 { 17701 BX.ajax.history.obFrame.contentWindow.document.open(); 17702 BX.ajax.history.obFrame.contentWindow.document.write(new_hash); 17703 BX.ajax.history.obFrame.contentWindow.document.close(); 17704 } 17705 } 17706 }, 17707 17708 checkRedirectStart: function(param_name, param_value) 17709 { 17710 var current_hash = window.location.hash; 17711 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 17712 17713 var test = current_hash.substring(0, 5); 17714 if (test == 'view/' || test == 'view%') 17715 { 17716 BX.ajax.history.bHashCollision = true;
17717 document.write('<' + 'div id="__ajax_hash_collision_' + param_value + '" style="display: none;">'); 17718 } 17719 }, 17720 17721 checkRedirectFinish: function(param_name, param_value) 17722 { 17723 document.write('</div>'); 17724 17725 var current_hash = window.location.hash; 17726 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 17727 17728 BX.ready(function () 17729 { 17730 var test = current_hash.substring(0, 5); 17731 if (test == 'view/' || test == 'view%') 17732 { 17733 var obColNode = BX('__ajax_hash_collision_' + param_value); 17734 var obNode = obColNode.firstChild; 17735 BX.cleanNode(obNode); 17736 obColNode.style.display = 'block'; 17737 17738 // IE, Opera and Chrome automatically modifies hash with urlencode, but FF doesn't ;-( 17739 if (test != 'view%') 17740 current_hash = BX.util.urlencode(current_hash); 17741 17742 current_hash += (current_hash.indexOf('%3F') == -1 ? '%3F' : '%26') + param_name + '=' + param_value; 17743 17744 var url = '/bitrix/tools/ajax_redirector.php?hash=' + current_hash; 17745 17746 BX.ajax.insertToNode(url, obNode); 17747 } 17748 }); 17749 } 17750}; 17751 17752BX.ajax.component = function(node) 17753{ 17754 this.node = node; 17755}; 17756 17757BX.ajax.component.prototype.getState = function() 17758{ 17759 var state = { 17760 'node': this.node, 17761 'title': window.document.title, 17762 'data': BX(this.node).innerHTML 17763 }; 17764 17765 var obNavChain = BX('navigation'); 17766 if (null != obNavChain) 17767 state.nav_chain = obNavChain.innerHTML; 17768 17769 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistoryGetState", [state]); 17770 17771 return state; 17772}; 17773 17774BX.ajax.component.prototype.setState = function(state) 17775{ 17776 BX(state.node).innerHTML = state.data; 17777 BX.ajax.UpdatePageTitle(state.title); 17778 17779 if (state.nav_chain) 17780 { 17781 BX.ajax.UpdatePageNavChain(state.nav_chain); 17782 } 17783 17784 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistorySetState", [state]); 17785}; 17786 17787var jsAjaxHistoryContainer = { 17788 arHistory: {}, 17789 17790 put: function(hash, state) 17791 { 17792 this.arHistory[hash] = state; 17793 }, 17794 17795 get: function(hash) 17796 { 17797 return this.arHistory[hash]; 17798 } 17799}; 17800 17801 17802BX.ajax.FormData = function() 17803{ 17804 this.elements = []; 17805 this.files = []; 17806 this.features = {}; 17807 this.isSupported(); 17808 this.log('BX FormData init'); 17809}; 17810 17811BX.ajax.FormData.isSupported = function() 17812{ 17813 var f = new BX.ajax.FormData(); 17814 var result = f.features.supported; 17815 f = null; 17816 return result; 17817}; 17818 17819BX.ajax.FormData.prototype.log = function(o) 17820{ 17821 if (false) { 17822 try { 17823 if (BX.browser.IsIE()) o = JSON.stringify(o); 17824 console.log(o); 17825 } catch(e) {} 17826 } 17827}; 17828 17829BX.ajax.FormData.prototype.isSupported = function() 17830{ 17831 var f = {}; 17832 f.fileReader = (window.FileReader && window.FileReader.prototype.readAsBinaryString); 17833 f.readFormData = f.sendFormData = !!(window.FormData); 17834 f.supported = !!(f.readFormData && f.sendFormData); 17835 this.features = f; 17836 this.log('features:'); 17837 this.log(f); 17838 17839 return f.supported; 17840}; 17841 17842BX.ajax.FormData.prototype.append = function(name, value) 17843{ 17844 if (typeof(value) === 'object') { // seems to be files element 17845 this.files.push({'name': name, 'value':value}); 17846 } else { 17847 this.elements.push({'name': name, 'value':value}); 17848 } 17849}; 17850 17851BX.ajax.FormData.prototype.send = function(url, callbackOk, callbackProgress, callbackError) 17852{ 17853 this.log('FD send'); 17854 this.xhr = BX.ajax({ 17855 'method': 'POST', 17856 'dataType': 'html', 17857 'url': url, 17858 'onsuccess': callbackOk, 17859 'onfailure': callbackError, 17860 'start': false, 17861 'preparePost':false 17862 }); 17863 17864 if (callbackProgress) 17865 { 17866 this.xhr.upload.addEventListener( 17867 'progress', 17868 function(e) { 17869 if (e.lengthComputable) 17870 callbackProgress(e.loaded / (e.total || e.totalSize)); 17871 }, 17872 false 17873 ); 17874 } 17875 17876 if (this.features.readFormData && this.features.sendFormData) 17877 { 17878 var fd = new FormData(); 17879 this.log('use browser formdata'); 17880 for (var i in this.elements) 17881 { 17882 if(this.elements.hasOwnProperty(i)) 17883 fd.append(this.elements[i].name,this.elements[i].value); 17884 } 17885 for (i in this.files) 17886 { 17887 if(this.files.hasOwnProperty(i)) 17888 fd.append(this.files[i].name, this.files[i].value); 17889 } 17890 this.xhr.send(fd); 17891 } 17892 17893 return this.xhr; 17894}; 17895 17896BX.addCustomEvent('onAjaxFailure', BX.debug); 17897})(window); 17898 17899 17900(function (exports,main_core) { 17901 'use strict'; 17902 17903 var LazyLoad = { 17904 observer: null, 17905 images: {}, 17906 imageStatus: { 17907 hidden: -2, 17908 error: -1, 17909 "undefined": 0, 17910 inited: 1, 17911 loaded: 2 17912 }, 17913 imageTypes: { 17914 image: 1, 17915 background: 2 17916 },
17917 initObserver: function initObserver() { 17918 this.observer = new IntersectionObserver(this.onIntersection.bind(this), { 17919 rootMargin: '20% 0% 20% 0%', 17920 threshold: 0.10 17921 }); 17922 }, 17923 onIntersection: function onIntersection(entries) { 17924 entries.forEach(function (entry) { 17925 if (entry.isIntersecting) { 17926 this.showImage(entry.target); 17927 } 17928 }.bind(this)); 17929 }, 17930 registerImage: function registerImage(id, isImageVisibleCallback, options) { 17931 if (this.observer === null) { 17932 this.initObserver(); 17933 } 17934 17935 options = options || {}; 17936 17937 if (!main_core.Type.isStringFilled(id)) { 17938 return; 17939 } 17940 17941 if (main_core.Type.isObject(this.images[id])) { 17942 return; 17943 } 17944 17945 var element = document.getElementById(id); 17946 17947 if (!main_core.Type.isDomNode(element)) { 17948 return; 17949 } 17950 17951 this.observer.observe(element); 17952 this.images[id] = { 17953 id: id, 17954 node: null, 17955 src: null, 17956 dataSrcName: options.dataSrcName || 'src', 17957 type: null, 17958 func: main_core.Type.isFunction(isImageVisibleCallback) ? isImageVisibleCallback : null, 17959 status: this.imageStatus.undefined 17960 }; 17961 }, 17962 registerImages: function registerImages(ids, isImageVisibleCallback, options) { 17963 if (main_core.Type.isArray(ids)) { 17964 for (var i = 0, length = ids.length; i < length; i++) { 17965 this.registerImage(ids[i], isImageVisibleCallback, options); 17966 } 17967 } 17968 }, 17969 showImage: function showImage(imageNode) { 17970 var imageNodeId = imageNode.id; 17971 17972 if (!main_core.Type.isStringFilled(imageNodeId)) { 17973 return; 17974 } 17975 17976 var image = this.images[imageNodeId]; 17977 17978 if (!main_core.Type.isPlainObject(image)) { 17979 return; 17980 } 17981 17982 if (image.status == this.imageStatus.undefined) { 17983 this.initImage(image); 17984 } 17985 17986 if (image.status !== this.imageStatus.inited) { 17987 return; 17988 } 17989 17990 if (!image.node || !image.node.parentNode) { 17991 image.node = null; 17992 image.status = this.imageStatus.error; 17993 return; 17994 } 17995 17996 if (image.type == this.imageTypes.image) { 17997 image.node.src = image.src; 17998 } else { 17999 image.node.style.backgroundImage = "url('" + image.src + "')"; 18000 } 18001 18002 image.node.dataset[image.dataSrcName] = ""; 18003 image.status = this.imageStatus.loaded; 18004 }, 18005 showImages: function showImages(checkOwnVisibility) { 18006 checkOwnVisibility = checkOwnVisibility !== false; 18007 18008 for (var id in this.images) { 18009 if (!this.images.hasOwnProperty(id)) { 18010 continue; 18011 } 18012 18013 var image = this.images[id]; 18014 18015 if (image.status == this.imageStatus.undefined) { 18016 this.initImage(image); 18017 } 18018 18019 if (image.status !== this.imageStatus.inited) { 18020 continue; 18021 } 18022 18023 if (!image.node || !image.node.parentNode) { 18024 image.node = null; 18025 image.status = this.imageStatus.error; 18026 continue; 18027 } 18028 18029 var isImageVisible = true; 18030 18031 if (checkOwnVisibility && main_core.Type.isFunction(image.func)) { 18032 isImageVisible = image.func(image); 18033 } 18034 18035 if (isImageVisible === true && this.isElementVisibleOnScreen(image.node)) { 18036 if (image.type == this.imageTypes.image) { 18037 image.node.src = image.src; 18038 } else { 18039 image.node.style.backgroundImage = "url('" + image.src + "')"; 18040 } 18041 18042 image.node.dataset[image.dataSrcName] = ""; 18043 image.status = this.imageStatus.loaded; 18044 } 18045 } 18046 }, 18047 initImage: function initImage(image) { 18048 image.status = this.imageStatus.error; 18049 var node = document.getElementById(image.id); 18050 18051 if (!main_core.Type.isDomNode(node)) { 18052 return; 18053 } 18054 18055 var src = node.dataset[image.dataSrcName]; 18056 18057 if (main_core.Type.isStringFilled(src)) { 18058 image.node = node; 18059 image.src = src; 18060 image.status = this.imageStatus.inited; 18061 image.type = image.node.tagName.toLowerCase() == "img" ? this.imageTypes.image : this.imageTypes.background; 18062 } 18063 }, 18064 isElementVisibleOnScreen: function isElementVisibleOnScreen(element) { 18065 var coords = this.getElementCoords(element); 18066 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 18067 var windowBottom = windowTop + document.documentElement.clientHeight; 18068 coords.bottom = coords.top + element.offsetHeight; 18069 return coords.top > windowTop && coords.top < windowBottom || // topVisible 18070 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 18071 ; 18072 }, 18073 isElementVisibleOn2Screens: function isElementVisibleOn2Screens(element) { 18074 var windowHeight = document.documentElement.clientHeight; 18075 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 18076 var windowBottom = windowTop + windowHeight; 18077 var coords = this.getElementCoords(element); 18078 coords.bottom = coords.top + element.offsetHeight; 18079 windowTop -= windowHeight; 18080 windowBottom += windowHeight; 18081 return coords.top > windowTop && coords.top < windowBottom || // topVisible 18082 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 18083 ; 18084 }, 18085 getElementCoords: function getElementCoords(element) { 18086 var box = element.getBoundingClientRect(); 18087 return { 18088 originTop: box.top, 18089 originLeft: box.left, 18090 top: box.top + window.pageYOffset, 18091 left: box.left + window.pageXOffset 18092 }; 18093 }, 18094 onScroll: function onScroll() {}, 18095 clearImages: function clearImages() { 18096 this.images = []; 18097 } 18098 }; 18099 18100 exports.LazyLoad = LazyLoad; 18101 18102}((this.BX = this.BX || {}),BX)); 18103 18104 18105 18106(function (exports) { 18107 'use strict'; 18108 18109 var ParamBag = /*#__PURE__*/function () { 18110 function ParamBag() { 18111 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 18112 babelHelpers.classCallCheck(this, ParamBag); 18113 18114 if (!!params && babelHelpers.typeof(params) === 'object') { 18115 this.params = new Map(Object.entries(params)); 18116 } else { 18117 this.params = new Map(); 18118 } 18119 } 18120 18121 babelHelpers.createClass(ParamBag, [{ 18122 key: "getParam", 18123 value: function getParam(key) { 18124 var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 18125 18126 if (this.params.has(key)) { 18127 return this.params.get(key); 18128 } 18129 18130 return defaultValue; 18131 } 18132 }, { 18133 key: "setParam", 18134 value: function setParam(key, value) { 18135 this.params.set(key, value); 18136 } 18137 }, { 18138 key: "clear", 18139 value: function clear() { 18140 this.params.clear(); 18141 } 18142 }], [{ 18143 key: "create", 18144 value: function create() { 18145 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 18146 return new ParamBag(params); 18147 } 18148 }]); 18149 return ParamBag; 18150 }(); 18151 18152 exports.ParamBag = ParamBag; 18153 18154}((this.BX = this.BX || {}))); 18155 18156 18157 18158(function() { 18159 BX.FixFontSize = function(params) 18160 { 18161 var widthNode, computedStyles, width; 18162 18163 this.node = null; 18164 this.prevWindowSize = 0; 18165 this.prevWrapperSize = 0; 18166 this.mainWrapper = null; 18167 this.textWrapper = null; 18168 this.objList = params.objList; 18169 this.minFontSizeList = []; 18170 this.minFontSize = 0; 18171 18172 if (params.onresize) 18173 { 18174 this.prevWindowSize = window.innerWidth || document.documentElement.clientWidth; 18175 BX.bind(window, 'resize', BX.throttle(this.onResize, 350, this)); 18176 } 18177 18178 if (params.onAdaptiveResize) 18179 { 18180 widthNode = this.objList[0].scaleBy || this.objList[0].node; 18181 computedStyles = getComputedStyle(widthNode); 18182 this.prevWrapperSize = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18183 BX.bind(window, 'resize', BX.throttle(this.onAdaptiveResize, 350, this)); 18184 } 18185 18186 this.createTestNodes(); 18187 this.decrease(); 18188 }; 18189 18190 BX.FixFontSize.prototype = 18191 { 18192 createTestNodes: function() 18193 { 18194 this.textWrapper = BX.create('div',{ 18195 style : { 18196 display : 'inline-block', 18197 whiteSpace : 'nowrap' 18198 } 18199 }); 18200 18201 this.mainWrapper = BX.create('div',{ 18202 style : { 18203 height : 0, 18204 overflow : 'hidden' 18205 }, 18206 children : [this.textWrapper] 18207 }); 18208 18209 }, 18210 insertTestNodes: function() 18211 { 18212 document.body.appendChild(this.mainWrapper); 18213 }, 18214 removeTestNodes: function() 18215 { 18216 document.body.removeChild(this.mainWrapper); 18217 }, 18218 decrease: function() 18219 { 18220 var width, 18221 fontSize, 18222 widthNode, 18223 computedStyles; 18224 18225 this.insertTestNodes(); 18226
18227 for(var i=this.objList.length-1; i>=0; i--) 18228 { 18229 widthNode = this.objList[i].scaleBy || this.objList[i].node; 18230 computedStyles = getComputedStyle(widthNode); 18231 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18232 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 18233 18234 this.textWrapperSetStyle(this.objList[i].node); 18235 18236 if(this.textWrapperInsertText(this.objList[i].node)) 18237 { 18238 while(this.textWrapper.offsetWidth > width && fontSize > 0) 18239 { 18240 this.textWrapper.style.fontSize = --fontSize + 'px'; 18241 } 18242 18243 if(this.objList[i].smallestValue) 18244 { 18245 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 18246 18247 this.minFontSizeList.push(this.objList[i].node) 18248 } 18249 else 18250 { 18251 this.objList[i].node.style.fontSize = fontSize + 'px'; 18252 } 18253 } 18254 } 18255 18256 if(this.minFontSizeList.length > 0) 18257 this.setMinFont(); 18258 18259 this.removeTestNodes(); 18260 18261 }, 18262 increase: function() 18263 { 18264 this.insertTestNodes(); 18265 var width, 18266 fontSize, 18267 widthNode, 18268 computedStyles; 18269 18270 this.insertTestNodes(); 18271 18272 for(var i=this.objList.length-1; i>=0; i--) 18273 { 18274 widthNode = this.objList[i].scaleBy || this.objList[i].node; 18275 computedStyles = getComputedStyle(widthNode); 18276 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18277 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 18278 18279 this.textWrapperSetStyle(this.objList[i].node); 18280 18281 if(this.textWrapperInsertText(this.objList[i].node)) 18282 { 18283 while(this.textWrapper.offsetWidth < width && fontSize < this.objList[i].maxFontSize) 18284 { 18285 this.textWrapper.style.fontSize = ++fontSize + 'px'; 18286 } 18287 18288 fontSize--; 18289 18290 if(this.objList[i].smallestValue) 18291 { 18292 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 18293 18294 this.minFontSizeList.push(this.objList[i].node) 18295 } 18296 else 18297 { 18298 this.objList[i].node.style.fontSize = fontSize + 'px'; 18299 } 18300 } 18301 } 18302 18303 if(this.minFontSizeList.length > 0) 18304 this.setMinFont(); 18305 18306 this.removeTestNodes(); 18307 }, 18308 setMinFont : function() 18309 { 18310 for(var i = this.minFontSizeList.length-1; i>=0; i--) 18311 { 18312 this.minFontSizeList[i].style.fontSize = this.minFontSize + 'px'; 18313 } 18314 18315 this.minFontSize = 0; 18316 }, 18317 onResize : function() 18318 { 18319 var width = window.innerWidth || document.documentElement.clientWidth; 18320 18321 if(this.prevWindowSize > width) 18322 this.decrease(); 18323 18324 else if (this.prevWindowSize < width) 18325 this.increase(); 18326 18327 this.prevWindowSize = width; 18328 }, 18329 onAdaptiveResize : function() 18330 { 18331 var widthNode = this.objList[0].scaleBy || this.objList[0].node, 18332 computedStyles = getComputedStyle(widthNode), 18333 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18334 18335 if (this.prevWrapperSize > width) 18336 this.decrease(); 18337 else if (this.prevWrapperSize < width) 18338 this.increase(); 18339 18340 this.prevWrapperSize = width; 18341 }, 18342 textWrapperInsertText : function(node) 18343 { 18344 if(node.textContent){ 18345 this.textWrapper.textContent = node.textContent; 18346 return true; 18347 } 18348 else if(node.innerText) 18349 { 18350 this.textWrapper.innerText = node.innerText; 18351 return true; 18352 } 18353 else { 18354 return false; 18355 } 18356 }, 18357 textWrapperSetStyle : function(node) 18358 { 18359 this.textWrapper.style.fontFamily = getComputedStyle(node)["font-family"]; 18360 this.textWrapper.style.fontSize = getComputedStyle(node)["font-size"]; 18361 this.textWrapper.style.fontStyle = getComputedStyle(node)["font-style"]; 18362 this.textWrapper.style.fontWeight = getComputedStyle(node)["font-weight"]; 18363 this.textWrapper.style.lineHeight = getComputedStyle(node)["line-height"]; 18364 } 18365 }; 18366 18367 BX.FixFontSize.init = function(params) 18368 { 18369 return new BX.FixFontSize(params); 18370 }; 18371})(); 18372 18373})(); 18374//# 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.