1/* eslint-disable */ 2;(function() { 3 4 if (typeof window.BX === 'function') 5 { 6 return; 7 } 8 9/** 10 * Babel external helpers 11 * (c) 2018 Babel 12 * @license MIT 13 */ 14(function (global) { 15 var babelHelpers = global.babelHelpers = {}; 16 17 function _typeof(obj) { 18 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 19 babelHelpers.typeof = _typeof = function (obj) { 20 return typeof obj; 21 }; 22 } else { 23 babelHelpers.typeof = _typeof = function (obj) { 24 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 25 }; 26 } 27 28 return _typeof(obj); 29 } 30 31 babelHelpers.typeof = _typeof; 32 var REACT_ELEMENT_TYPE; 33 34 function _createRawReactElement(type, props, key, children) { 35 if (!REACT_ELEMENT_TYPE) { 36 REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; 37 } 38 39 var defaultProps = type && type.defaultProps; 40 var childrenLength = arguments.length - 3; 41 42 if (!props && childrenLength !== 0) { 43 props = { 44 children: void 0 45 }; 46 } 47 48 if (props && defaultProps) { 49 for (var propName in defaultProps) { 50 if (props[propName] === void 0) { 51 props[propName] = defaultProps[propName]; 52 } 53 } 54 } else if (!props) { 55 props = defaultProps || {}; 56 } 57 58 if (childrenLength === 1) { 59 props.children = children; 60 } else if (childrenLength > 1) { 61 var childArray = new Array(childrenLength); 62 63 for (var i = 0; i < childrenLength; i++) { 64 childArray[i] = arguments[i + 3]; 65 } 66 67 props.children = childArray; 68 } 69 70 return { 71 $$typeof: REACT_ELEMENT_TYPE, 72 type: type, 73 key: key === undefined ? null : '' + key, 74 ref: null, 75 props: props, 76 _owner: null 77 }; 78 } 79 80 babelHelpers.jsx = _createRawReactElement; 81 82 function _asyncIterator(iterable) { 83 var method; 84 85 if (typeof Symbol === "function") { 86 if (Symbol.asyncIterator) { 87 method = iterable[Symbol.asyncIterator]; 88 if (method != null) return method.call(iterable); 89 } 90 91 if (Symbol.iterator) { 92 method = iterable[Symbol.iterator]; 93 if (method != null) return method.call(iterable); 94 } 95 } 96 97 throw new TypeError("Object is not async iterable"); 98 } 99 100 babelHelpers.asyncIterator = _asyncIterator; 101 102 function _AwaitValue(value) { 103 this.wrapped = value; 104 } 105 106 babelHelpers.AwaitValue = _AwaitValue; 107 108 function AsyncGenerator(gen) { 109 var front, back; 110 111 function send(key, arg) { 112 return new Promise(function (resolve, reject) { 113 var request = { 114 key: key, 115 arg: arg, 116 resolve: resolve, 117 reject: reject, 118 next: null 119 }; 120 121 if (back) { 122 back = back.next = request; 123 } else { 124 front = back = request; 125 resume(key, arg); 126 } 127 }); 128 } 129 130 function resume(key, arg) { 131 try { 132 var result = gen[key](arg); 133 var value = result.value; 134 var wrappedAwait = value instanceof babelHelpers.AwaitValue; 135 Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { 136 if (wrappedAwait) { 137 resume("next", arg); 138 return; 139 } 140 141 settle(result.done ? "return" : "normal", arg); 142 }, function (err) { 143 resume("throw", err); 144 }); 145 } catch (err) { 146 settle("throw", err); 147 } 148 } 149 150 function settle(type, value) { 151 switch (type) { 152 case "return": 153 front.resolve({ 154 value: value, 155 done: true 156 }); 157 break; 158 159 case "throw": 160 front.reject(value); 161 break; 162 163 default: 164 front.resolve({ 165 value: value, 166 done: false 167 }); 168 break; 169 } 170 171 front = front.next; 172 173 if (front) { 174 resume(front.key, front.arg); 175 } else { 176 back = null; 177 } 178 } 179 180 this._invoke = send; 181 182 if (typeof gen.return !== "function") { 183 this.return = undefined; 184 } 185 } 186 187 if (typeof Symbol === "function" && Symbol.asyncIterator) { 188 AsyncGenerator.prototype[Symbol.asyncIterator] = function () { 189 return this; 190 }; 191 } 192 193 AsyncGenerator.prototype.next = function (arg) { 194 return this._invoke("next", arg); 195 }; 196 197 AsyncGenerator.prototype.throw = function (arg) { 198 return this._invoke("throw", arg); 199 }; 200 201 AsyncGenerator.prototype.return = function (arg) { 202 return this._invoke("return", arg); 203 }; 204 205 babelHelpers.AsyncGenerator = AsyncGenerator; 206 207 function _wrapAsyncGenerator(fn) { 208 return function () { 209 return new babelHelpers.AsyncGenerator(fn.apply(this, arguments)); 210 }; 211 } 212 213 babelHelpers.wrapAsyncGenerator = _wrapAsyncGenerator; 214 215 function _awaitAsyncGenerator(value) { 216 return new babelHelpers.AwaitValue(value); 217 } 218 219 babelHelpers.awaitAsyncGenerator = _awaitAsyncGenerator; 220 221 function _asyncGeneratorDelegate(inner, awaitWrap) { 222 var iter = {}, 223 waiting = false;
224 225 function pump(key, value) { 226 waiting = true; 227 value = new Promise(function (resolve) { 228 resolve(inner[key](value)); 229 }); 230 return { 231 done: false, 232 value: awaitWrap(value) 233 }; 234 } 235 236 ; 237 238 if (typeof Symbol === "function" && Symbol.iterator) { 239 iter[Symbol.iterator] = function () { 240 return this; 241 }; 242 } 243 244 iter.next = function (value) { 245 if (waiting) { 246 waiting = false; 247 return value; 248 } 249 250 return pump("next", value); 251 }; 252 253 if (typeof inner.throw === "function") { 254 iter.throw = function (value) { 255 if (waiting) { 256 waiting = false; 257 throw value; 258 } 259 260 return pump("throw", value); 261 }; 262 } 263 264 if (typeof inner.return === "function") { 265 iter.return = function (value) { 266 return pump("return", value); 267 }; 268 } 269 270 return iter; 271 } 272 273 babelHelpers.asyncGeneratorDelegate = _asyncGeneratorDelegate; 274 275 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { 276 try { 277 var info = gen[key](arg); 278 var value = info.value; 279 } catch (error) { 280 reject(error); 281 return; 282 } 283 284 if (info.done) { 285 resolve(value); 286 } else { 287 Promise.resolve(value).then(_next, _throw); 288 } 289 } 290 291 function _asyncToGenerator(fn) { 292 return function () { 293 var self = this, 294 args = arguments; 295 return new Promise(function (resolve, reject) { 296 var gen = fn.apply(self, args); 297 298 function _next(value) { 299 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); 300 } 301 302 function _throw(err) { 303 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); 304 } 305 306 _next(undefined); 307 }); 308 }; 309 } 310 311 babelHelpers.asyncToGenerator = _asyncToGenerator; 312 313 function _classCallCheck(instance, Constructor) { 314 if (!(instance instanceof Constructor)) { 315 throw new TypeError("Cannot call a class as a function"); 316 } 317 } 318 319 babelHelpers.classCallCheck = _classCallCheck; 320 321 function _defineProperties(target, props) { 322 for (var i = 0; i < props.length; i++) { 323 var descriptor = props[i]; 324 descriptor.enumerable = descriptor.enumerable || false; 325 descriptor.configurable = true; 326 if ("value" in descriptor) descriptor.writable = true; 327 Object.defineProperty(target, descriptor.key, descriptor); 328 } 329 } 330 331 function _createClass(Constructor, protoProps, staticProps) { 332 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 333 if (staticProps) _defineProperties(Constructor, staticProps); 334 return Constructor; 335 } 336 337 babelHelpers.createClass = _createClass; 338 339 function _defineEnumerableProperties(obj, descs) { 340 for (var key in descs) { 341 var desc = descs[key]; 342 desc.configurable = desc.enumerable = true; 343 if ("value" in desc) desc.writable = true; 344 Object.defineProperty(obj, key, desc); 345 } 346 347 if (Object.getOwnPropertySymbols) { 348 var objectSymbols = Object.getOwnPropertySymbols(descs); 349 350 for (var i = 0; i < objectSymbols.length; i++) { 351 var sym = objectSymbols[i]; 352 var desc = descs[sym]; 353 desc.configurable = desc.enumerable = true; 354 if ("value" in desc) desc.writable = true; 355 Object.defineProperty(obj, sym, desc); 356 } 357 } 358 359 return obj; 360 } 361 362 babelHelpers.defineEnumerableProperties = _defineEnumerableProperties; 363 364 function _defaults(obj, defaults) { 365 var keys = Object.getOwnPropertyNames(defaults); 366 367 for (var i = 0; i < keys.length; i++) { 368 var key = keys[i]; 369 var value = Object.getOwnPropertyDescriptor(defaults, key); 370 371 if (value && value.configurable && obj[key] === undefined) { 372 Object.defineProperty(obj, key, value); 373 } 374 } 375 376 return obj; 377 } 378 379 babelHelpers.defaults = _defaults; 380 381 function _defineProperty(obj, key, value) { 382 if (key in obj) { 383 Object.defineProperty(obj, key, { 384 value: value, 385 enumerable: true, 386 configurable: true, 387 writable: true 388 }); 389 } else { 390 obj[key] = value; 391 } 392 393 return obj; 394 } 395 396 babelHelpers.defineProperty = _defineProperty; 397 398 function _extends() { 399 babelHelpers.extends = _extends = Object.assign || function (target) { 400 for (var i = 1; i < arguments.length; i++) { 401 var source = arguments[i]; 402 403 for (var key in source) { 404 if (Object.prototype.hasOwnProperty.call(source, key)) { 405 target[key] = source[key]; 406 } 407 } 408 } 409 410 return target; 411 }; 412 413 return _extends.apply(this, arguments); 414 } 415 416 babelHelpers.extends = _extends; 417 418 function _objectSpread(target) { 419 for (var i = 1; i < arguments.length; i++) { 420 var source = arguments[i] != null ? arguments[i] : {}; 421 var ownKeys = Object.keys(source); 422 423 if (typeof Object.getOwnPropertySymbols === 'function') { 424 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { 425 return Object.getOwnPropertyDescriptor(source, sym).enumerable; 426 })); 427 } 428 429 ownKeys.forEach(function (key) { 430 babelHelpers.defineProperty(target, key, source[key]); 431 }); 432 } 433 434 return target; 435 } 436 437 babelHelpers.objectSpread = _objectSpread; 438 439 function _inherits(subClass, superClass) { 440 if (typeof superClass !== "function" && superClass !== null) { 441 throw new TypeError("Super expression must either be null or a function"); 442 } 443 444 subClass.prototype = Object.create(superClass && superClass.prototype, { 445 constructor: { 446 value: subClass, 447 writable: true, 448 configurable: true 449 } 450 }); 451 if (superClass) babelHelpers.setPrototypeOf(subClass, superClass); 452 } 453 454 babelHelpers.inherits = _inherits; 455 456 function _inheritsLoose(subClass, superClass) { 457 subClass.prototype = Object.create(superClass.prototype); 458 subClass.prototype.constructor = subClass; 459 subClass.__proto__ = superClass; 460 } 461 462 babelHelpers.inheritsLoose = _inheritsLoose; 463
464 function _getPrototypeOf(o) { 465 babelHelpers.getPrototypeOf = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { 466 return o.__proto__ || Object.getPrototypeOf(o); 467 }; 468 return _getPrototypeOf(o); 469 } 470 471 babelHelpers.getPrototypeOf = _getPrototypeOf; 472 473 function _setPrototypeOf(o, p) { 474 babelHelpers.setPrototypeOf = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { 475 o.__proto__ = p; 476 return o; 477 }; 478 479 return _setPrototypeOf(o, p); 480 } 481 482 babelHelpers.setPrototypeOf = _setPrototypeOf; 483 484 function isNativeReflectConstruct() { 485 if (typeof Reflect === "undefined" || !Reflect.construct) return false; 486 if (Reflect.construct.sham) return false; 487 if (typeof Proxy === "function") return true; 488 489 try { 490 Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); 491 return true; 492 } catch (e) { 493 return false; 494 } 495 } 496 497 function _construct(Parent, args, Class) { 498 if (isNativeReflectConstruct()) { 499 babelHelpers.construct = _construct = Reflect.construct; 500 } else { 501 babelHelpers.construct = _construct = function _construct(Parent, args, Class) { 502 var a = [null]; 503 a.push.apply(a, args); 504 var Constructor = Function.bind.apply(Parent, a); 505 var instance = new Constructor(); 506 if (Class) babelHelpers.setPrototypeOf(instance, Class.prototype); 507 return instance; 508 }; 509 } 510 511 return _construct.apply(null, arguments); 512 } 513 514 babelHelpers.construct = _construct; 515 516 function _isNativeFunction(fn) { 517 return Function.toString.call(fn).indexOf("[native code]") !== -1; 518 } 519 520 babelHelpers.isNativeFunction = _isNativeFunction; 521 522 function _wrapNativeSuper(Class) { 523 var _cache = typeof Map === "function" ? new Map() : undefined; 524 525 babelHelpers.wrapNativeSuper = _wrapNativeSuper = function _wrapNativeSuper(Class) { 526 if (Class === null || !babelHelpers.isNativeFunction(Class)) return Class; 527 528 if (typeof Class !== "function") { 529 throw new TypeError("Super expression must either be null or a function"); 530 } 531 532 if (typeof _cache !== "undefined") { 533 if (_cache.has(Class)) return _cache.get(Class); 534 535 _cache.set(Class, Wrapper); 536 } 537 538 function Wrapper() { 539 return babelHelpers.construct(Class, arguments, babelHelpers.getPrototypeOf(this).constructor); 540 } 541 542 Wrapper.prototype = Object.create(Class.prototype, { 543 constructor: { 544 value: Wrapper, 545 enumerable: false, 546 writable: true, 547 configurable: true 548 } 549 }); 550 return babelHelpers.setPrototypeOf(Wrapper, Class); 551 }; 552 553 return _wrapNativeSuper(Class); 554 } 555 556 babelHelpers.wrapNativeSuper = _wrapNativeSuper; 557 558 function _instanceof(left, right) { 559 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { 560 return right[Symbol.hasInstance](left); 561 } else { 562 return left instanceof right; 563 } 564 } 565 566 babelHelpers.instanceof = _instanceof; 567 568 function _interopRequireDefault(obj) { 569 return obj && obj.__esModule ? obj : { 570 default: obj 571 }; 572 } 573 574 babelHelpers.interopRequireDefault = _interopRequireDefault; 575 576 function _interopRequireWildcard(obj) { 577 if (obj && obj.__esModule) { 578 return obj; 579 } else { 580 var newObj = {}; 581 582 if (obj != null) { 583 for (var key in obj) { 584 if (Object.prototype.hasOwnProperty.call(obj, key)) { 585 var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; 586 587 if (desc.get || desc.set) { 588 Object.defineProperty(newObj, key, desc); 589 } else { 590 newObj[key] = obj[key]; 591 } 592 } 593 } 594 } 595 596 newObj.default = obj; 597 return newObj; 598 } 599 } 600 601 babelHelpers.interopRequireWildcard = _interopRequireWildcard; 602 603 function _newArrowCheck(innerThis, boundThis) { 604 if (innerThis !== boundThis) { 605 throw new TypeError("Cannot instantiate an arrow function"); 606 } 607 } 608 609 babelHelpers.newArrowCheck = _newArrowCheck; 610 611 function _objectDestructuringEmpty(obj) { 612 if (obj == null) throw new TypeError("Cannot destructure undefined"); 613 } 614 615 babelHelpers.objectDestructuringEmpty = _objectDestructuringEmpty; 616 617 function _objectWithoutPropertiesLoose(source, excluded) { 618 if (source == null) return {}; 619 var target = {}; 620 var sourceKeys = Object.keys(source); 621 var key, i; 622 623 for (i = 0; i < sourceKeys.length; i++) { 624 key = sourceKeys[i]; 625 if (excluded.indexOf(key) >= 0) continue; 626 target[key] = source[key]; 627 } 628 629 return target; 630 } 631 632 babelHelpers.objectWithoutPropertiesLoose = _objectWithoutPropertiesLoose; 633 634 function _objectWithoutProperties(source, excluded) { 635 if (source == null) return {}; 636 var target = babelHelpers.objectWithoutPropertiesLoose(source, excluded); 637 var key, i; 638 639 if (Object.getOwnPropertySymbols) { 640 var sourceSymbolKeys = Object.getOwnPropertySymbols(source); 641 642 for (i = 0; i < sourceSymbolKeys.length; i++) { 643 key = sourceSymbolKeys[i]; 644 if (excluded.indexOf(key) >= 0) continue; 645 if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; 646 target[key] = source[key]; 647 } 648 } 649 650 return target; 651 } 652 653 babelHelpers.objectWithoutProperties = _objectWithoutProperties; 654 655 function _assertThisInitialized(self) { 656 if (self === void 0) { 657 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 658 } 659 660 return self; 661 } 662 663 babelHelpers.assertThisInitialized = _assertThisInitialized; 664 665 function _possibleConstructorReturn(self, call) { 666 if (call && (typeof call === "object" || typeof call === "function")) { 667 return call; 668 } 669 670 return babelHelpers.assertThisInitialized(self); 671 } 672 673 babelHelpers.possibleConstructorReturn = _possibleConstructorReturn; 674 675 function _superPropBase(object, property) { 676 while (!Object.prototype.hasOwnProperty.call(object, property)) { 677 object = babelHelpers.getPrototypeOf(object); 678 if (object === null) break; 679 } 680 681 return object; 682 } 683 684 babelHelpers.superPropBase = _superPropBase; 685 686 function _get(target, property, receiver) { 687 if (typeof Reflect !== "undefined" && Reflect.get) { 688 babelHelpers.get = _get = Reflect.get; 689 } else { 690 babelHelpers.get = _get = function _get(target, property, receiver) { 691 var base = babelHelpers.superPropBase(target, property); 692 if (!base) return; 693 var desc = Object.getOwnPropertyDescriptor(base, property); 694 695 if (desc.get) { 696 return desc.get.call(receiver); 697 } 698 699 return desc.value; 700 }; 701 } 702 703 return _get(target, property, receiver || target); 704 } 705 706 babelHelpers.get = _get; 707 708 function set(target, property, value, receiver) { 709 if (typeof Reflect !== "undefined" && Reflect.set) { 710 set = Reflect.set; 711 } else { 712 set = function set(target, property, value, receiver) { 713 var base = babelHelpers.superPropBase(target, property); 714 var desc; 715 716 if (base) { 717 desc = Object.getOwnPropertyDescriptor(base, property); 718 719 if (desc.set) { 720 desc.set.call(receiver, value); 721 return true; 722 } else if (!desc.writable) { 723 return false;
724 } 725 } 726 727 desc = Object.getOwnPropertyDescriptor(receiver, property); 728 729 if (desc) { 730 if (!desc.writable) { 731 return false; 732 } 733 734 desc.value = value; 735 Object.defineProperty(receiver, property, desc); 736 } else { 737 babelHelpers.defineProperty(receiver, property, value); 738 } 739 740 return true; 741 }; 742 } 743 744 return set(target, property, value, receiver); 745 } 746 747 function _set(target, property, value, receiver, isStrict) { 748 var s = set(target, property, value, receiver || target); 749 750 if (!s && isStrict) { 751 throw new Error('failed to set property'); 752 } 753 754 return value; 755 } 756 757 babelHelpers.set = _set; 758 759 function _taggedTemplateLiteral(strings, raw) { 760 if (!raw) { 761 raw = strings.slice(0); 762 } 763 764 return Object.freeze(Object.defineProperties(strings, { 765 raw: { 766 value: Object.freeze(raw) 767 } 768 })); 769 } 770 771 babelHelpers.taggedTemplateLiteral = _taggedTemplateLiteral; 772 773 function _taggedTemplateLiteralLoose(strings, raw) { 774 if (!raw) { 775 raw = strings.slice(0); 776 } 777 778 strings.raw = raw; 779 return strings; 780 } 781 782 babelHelpers.taggedTemplateLiteralLoose = _taggedTemplateLiteralLoose; 783 784 function _temporalRef(val, name) { 785 if (val === babelHelpers.temporalUndefined) { 786 throw new ReferenceError(name + " is not defined - temporal dead zone"); 787 } else { 788 return val; 789 } 790 } 791 792 babelHelpers.temporalRef = _temporalRef; 793 794 function _readOnlyError(name) { 795 throw new Error("\"" + name + "\" is read-only"); 796 } 797 798 babelHelpers.readOnlyError = _readOnlyError; 799 800 function _classNameTDZError(name) { 801 throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); 802 } 803 804 babelHelpers.classNameTDZError = _classNameTDZError; 805 babelHelpers.temporalUndefined = {}; 806 807 function _slicedToArray(arr, i) { 808 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArrayLimit(arr, i) || babelHelpers.nonIterableRest(); 809 } 810 811 babelHelpers.slicedToArray = _slicedToArray; 812 813 function _slicedToArrayLoose(arr, i) { 814 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArrayLimitLoose(arr, i) || babelHelpers.nonIterableRest(); 815 } 816 817 babelHelpers.slicedToArrayLoose = _slicedToArrayLoose; 818 819 function _toArray(arr) { 820 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArray(arr) || babelHelpers.nonIterableRest(); 821 } 822 823 babelHelpers.toArray = _toArray; 824 825 function _toConsumableArray(arr) { 826 return babelHelpers.arrayWithoutHoles(arr) || babelHelpers.iterableToArray(arr) || babelHelpers.nonIterableSpread(); 827 } 828 829 babelHelpers.toConsumableArray = _toConsumableArray; 830 831 function _arrayWithoutHoles(arr) { 832 if (Array.isArray(arr)) { 833 for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; 834 835 return arr2; 836 } 837 } 838 839 babelHelpers.arrayWithoutHoles = _arrayWithoutHoles; 840 841 function _arrayWithHoles(arr) { 842 if (Array.isArray(arr)) return arr; 843 } 844 845 babelHelpers.arrayWithHoles = _arrayWithHoles; 846 847 function _iterableToArray(iter) { 848 if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); 849 } 850 851 babelHelpers.iterableToArray = _iterableToArray; 852 853 function _iterableToArrayLimit(arr, i) { 854 var _arr = []; 855 var _n = true; 856 var _d = false; 857 var _e = undefined; 858 859 try { 860 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { 861 _arr.push(_s.value); 862 863 if (i && _arr.length === i) break; 864 } 865 } catch (err) { 866 _d = true; 867 _e = err; 868 } finally { 869 try { 870 if (!_n && _i["return"] != null) _i["return"](); 871 } finally { 872 if (_d) throw _e; 873 } 874 } 875 876 return _arr; 877 } 878 879 babelHelpers.iterableToArrayLimit = _iterableToArrayLimit; 880 881 function _iterableToArrayLimitLoose(arr, i) { 882 var _arr = []; 883 884 for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { 885 _arr.push(_step.value); 886 887 if (i && _arr.length === i) break; 888 } 889 890 return _arr; 891 } 892 893 babelHelpers.iterableToArrayLimitLoose = _iterableToArrayLimitLoose; 894 895 function _nonIterableSpread() { 896 throw new TypeError("Invalid attempt to spread non-iterable instance"); 897 } 898 899 babelHelpers.nonIterableSpread = _nonIterableSpread; 900 901 function _nonIterableRest() {
902 throw new TypeError("Invalid attempt to destructure non-iterable instance"); 903 } 904 905 babelHelpers.nonIterableRest = _nonIterableRest; 906 907 function _skipFirstGeneratorNext(fn) { 908 return function () { 909 var it = fn.apply(this, arguments); 910 it.next(); 911 return it; 912 }; 913 } 914 915 babelHelpers.skipFirstGeneratorNext = _skipFirstGeneratorNext; 916 917 function _toPropertyKey(key) { 918 if (typeof key === "symbol") { 919 return key; 920 } else { 921 return String(key); 922 } 923 } 924 925 babelHelpers.toPropertyKey = _toPropertyKey; 926 927 function _initializerWarningHelper(descriptor, context) { 928 throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and set to use loose mode. ' + 'To use proposal-class-properties in spec mode with decorators, wait for ' + 'the next major version of decorators in stage 2.'); 929 } 930 931 babelHelpers.initializerWarningHelper = _initializerWarningHelper; 932 933 function _initializerDefineProperty(target, property, descriptor, context) { 934 if (!descriptor) return; 935 Object.defineProperty(target, property, { 936 enumerable: descriptor.enumerable, 937 configurable: descriptor.configurable, 938 writable: descriptor.writable, 939 value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 940 }); 941 } 942 943 babelHelpers.initializerDefineProperty = _initializerDefineProperty; 944 945 function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { 946 var desc = {}; 947 Object['ke' + 'ys'](descriptor).forEach(function (key) { 948 desc[key] = descriptor[key]; 949 }); 950 desc.enumerable = !!desc.enumerable; 951 desc.configurable = !!desc.configurable; 952 953 if ('value' in desc || desc.initializer) { 954 desc.writable = true; 955 } 956 957 desc = decorators.slice().reverse().reduce(function (desc, decorator) { 958 return decorator(target, property, desc) || desc; 959 }, desc); 960 961 if (context && desc.initializer !== void 0) { 962 desc.value = desc.initializer ? desc.initializer.call(context) : void 0; 963 desc.initializer = undefined; 964 } 965 966 if (desc.initializer === void 0) { 967 Object['define' + 'Property'](target, property, desc); 968 desc = null; 969 } 970 971 return desc; 972 } 973 974 babelHelpers.applyDecoratedDescriptor = _applyDecoratedDescriptor; 975 var id = 0; 976 977 function _classPrivateFieldKey(name) { 978 return "__private_" + id++ + "_" + name; 979 } 980 981 babelHelpers.classPrivateFieldLooseKey = _classPrivateFieldKey; 982 983 function _classPrivateFieldBase(receiver, privateKey) { 984 if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { 985 throw new TypeError("attempted to use private field on non-instance"); 986 } 987 988 return receiver; 989 } 990 991 babelHelpers.classPrivateFieldLooseBase = _classPrivateFieldBase; 992 993 function _classPrivateFieldGet(receiver, privateMap) { 994 if (!privateMap.has(receiver)) { 995 throw new TypeError("attempted to get private field on non-instance"); 996 } 997 998 return privateMap.get(receiver).value; 999 } 1000 1001 babelHelpers.classPrivateFieldGet = _classPrivateFieldGet; 1002 1003 function _classPrivateFieldSet(receiver, privateMap, value) { 1004 if (!privateMap.has(receiver)) { 1005 throw new TypeError("attempted to set private field on non-instance"); 1006 } 1007 1008 var descriptor = privateMap.get(receiver); 1009 1010 if (!descriptor.writable) { 1011 throw new TypeError("attempted to set read only private field"); 1012 } 1013 1014 descriptor.value = value; 1015 return value; 1016 } 1017 1018 babelHelpers.classPrivateFieldSet = _classPrivateFieldSet; 1019})(typeof global === "undefined" ? window : global); 1020 1021/** 1022 * Copyright (c) 2014-present, Facebook, Inc. 1023 * 1024 * This source code is licensed under the MIT license found in the 1025 * LICENSE file in the root directory of this source tree. 1026 */ 1027 1028!(function(global) { 1029 "use strict"; 1030 1031 var Op = Object.prototype; 1032 var hasOwn = Op.hasOwnProperty; 1033 var undefined; // More compressible than void 0. 1034 var $Symbol = typeof Symbol === "function" ? Symbol : {}; 1035 var iteratorSymbol = $Symbol.iterator || "@@iterator"; 1036 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; 1037 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; 1038 1039 // Define the runtime globally (as expected by generated code) as either 1040 // module.exports (if we're in a module) or a new, empty object. 1041 var runtime = global.regeneratorRuntime = {}; 1042 1043 function wrap(innerFn, outerFn, self, tryLocsList) { 1044 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. 1045 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; 1046 var generator = Object.create(protoGenerator.prototype); 1047 var context = new Context(tryLocsList || []); 1048 1049 // The ._invoke method unifies the implementations of the .next, 1050 // .throw, and .return methods. 1051 generator._invoke = makeInvokeMethod(innerFn, self, context); 1052 1053 return generator; 1054 } 1055 runtime.wrap = wrap; 1056 1057 // Try/catch helper to minimize deoptimizations. Returns a completion 1058 // record like context.tryEntries[i].completion. This interface could
vendor: 10,591 bytes, lines 1059-1352
1059 // have been (and was previously) designed to take a closure to be 1060 // invoked without arguments, but in all the cases we care about we 1061 // already have an existing method we want to call, so there's no need 1062 // to create a new function object. We can even get away with assuming 1063 // the method takes exactly one argument, since that happens to be true 1064 // in every case, so we don't have to touch the arguments object. The 1065 // only additional allocation required is the completion record, which 1066 // has a stable shape and so hopefully should be cheap to allocate. 1067 function tryCatch(fn, obj, arg) { 1068 try { 1069 return { type: "normal", arg: fn.call(obj, arg) }; 1070 } catch (err) { 1071 return { type: "throw", arg: err }; 1072 } 1073 } 1074 1075 var GenStateSuspendedStart = "suspendedStart"; 1076 var GenStateSuspendedYield = "suspendedYield"; 1077 var GenStateExecuting = "executing"; 1078 var GenStateCompleted = "completed"; 1079 1080 // Returning this object from the innerFn has the same effect as 1081 // breaking out of the dispatch switch statement. 1082 var ContinueSentinel = {}; 1083 1084 // Dummy constructor functions that we use as the .constructor and 1085 // .constructor.prototype properties for functions that return Generator 1086 // objects. For full spec compliance, you may wish to configure your 1087 // minifier not to mangle the names of these two functions. 1088 function Generator() {} 1089 function GeneratorFunction() {} 1090 function GeneratorFunctionPrototype() {} 1091 1092 // This is a polyfill for %IteratorPrototype% for environments that 1093 // don't natively support it. 1094 var IteratorPrototype = {}; 1095 IteratorPrototype[iteratorSymbol] = function () { 1096 return this; 1097 }; 1098 1099 var getProto = Object.getPrototypeOf; 1100 var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); 1101 if (NativeIteratorPrototype && 1102 NativeIteratorPrototype !== Op && 1103 hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { 1104 // This environment has a native %IteratorPrototype%; use it instead 1105 // of the polyfill. 1106 IteratorPrototype = NativeIteratorPrototype; 1107 } 1108 1109 var Gp = GeneratorFunctionPrototype.prototype = 1110 Generator.prototype = Object.create(IteratorPrototype); 1111 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; 1112 GeneratorFunctionPrototype.constructor = GeneratorFunction; 1113 GeneratorFunctionPrototype[toStringTagSymbol] = 1114 GeneratorFunction.displayName = "GeneratorFunction"; 1115 1116 // Helper for defining the .next, .throw, and .return methods of the 1117 // Iterator interface in terms of a single ._invoke method. 1118 function defineIteratorMethods(prototype) { 1119 ["next", "throw", "return"].forEach(function(method) { 1120 prototype[method] = function(arg) { 1121 return this._invoke(method, arg); 1122 }; 1123 }); 1124 } 1125 1126 runtime.isGeneratorFunction = function(genFun) { 1127 var ctor = typeof genFun === "function" && genFun.constructor; 1128 return ctor 1129 ? ctor === GeneratorFunction || 1130 // For the native GeneratorFunction constructor, the best we can 1131 // do is to check its .name property. 1132 (ctor.displayName || ctor.name) === "GeneratorFunction" 1133 : false; 1134 }; 1135 1136 runtime.mark = function(genFun) { 1137 if (Object.setPrototypeOf) { 1138 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); 1139 } else { 1140 genFun.__proto__ = GeneratorFunctionPrototype; 1141 if (!(toStringTagSymbol in genFun)) { 1142 genFun[toStringTagSymbol] = "GeneratorFunction"; 1143 } 1144 } 1145 genFun.prototype = Object.create(Gp); 1146 return genFun; 1147 }; 1148 1149 // Within the body of any async function, `await x` is transformed to 1150 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test 1151 // `hasOwn.call(value, "__await")` to determine if the yielded value is 1152 // meant to be awaited. 1153 runtime.awrap = function(arg) { 1154 return { __await: arg }; 1155 }; 1156 1157 function AsyncIterator(generator) { 1158 function invoke(method, arg, resolve, reject) { 1159 var record = tryCatch(generator[method], generator, arg); 1160 if (record.type === "throw") { 1161 reject(record.arg); 1162 } else { 1163 var result = record.arg; 1164 var value = result.value; 1165 if (value && 1166 typeof value === "object" && 1167 hasOwn.call(value, "__await")) { 1168 return Promise.resolve(value.__await).then(function(value) { 1169 invoke("next", value, resolve, reject); 1170 }, function(err) { 1171 invoke("throw", err, resolve, reject); 1172 }); 1173 } 1174 1175 return Promise.resolve(value).then(function(unwrapped) { 1176 // When a yielded Promise is resolved, its final value becomes 1177 // the .value of the Promise<{value,done}> result for the 1178 // current iteration. If the Promise is rejected, however, the 1179 // result for this iteration will be rejected with the same 1180 // reason. Note that rejections of yielded Promises are not 1181 // thrown back into the generator function, as is the case 1182 // when an awaited Promise is rejected. This difference in 1183 // behavior between yield and await is important, because it 1184 // allows the consumer to decide what to do with the yielded 1185 // rejection (swallow it and continue, manually .throw it back 1186 // into the generator, abandon iteration, whatever). With 1187 // await, by contrast, there is no opportunity to examine the 1188 // rejection reason outside the generator function, so the 1189 // only option is to throw it from the await expression, and 1190 // let the generator function handle the exception. 1191 result.value = unwrapped; 1192 resolve(result); 1193 }, reject); 1194 } 1195 } 1196 1197 var previousPromise; 1198 1199 function enqueue(method, arg) { 1200 function callInvokeWithMethodAndArg() { 1201 return new Promise(function(resolve, reject) { 1202 invoke(method, arg, resolve, reject); 1203 }); 1204 } 1205 1206 return previousPromise = 1207 // If enqueue has been called before, then we want to wait until 1208 // all previous Promises have been resolved before calling invoke, 1209 // so that results are always delivered in the correct order. If 1210 // enqueue has not been called before, then it is important to 1211 // call invoke immediately, without waiting on a callback to fire, 1212 // so that the async generator function has the opportunity to do 1213 // any necessary setup in a predictable way. This predictability 1214 // is why the Promise constructor synchronously invokes its 1215 // executor callback, and why async functions synchronously 1216 // execute code before the first await. Since we implement simple 1217 // async functions in terms of async generators, it is especially 1218 // important to get this right, even though it requires care. 1219 previousPromise ? previousPromise.then( 1220 callInvokeWithMethodAndArg, 1221 // Avoid propagating failures to Promises returned by later 1222 // invocations of the iterator. 1223 callInvokeWithMethodAndArg 1224 ) : callInvokeWithMethodAndArg(); 1225 } 1226 1227 // Define the unified helper method that is used to implement .next, 1228 // .throw, and .return (see defineIteratorMethods). 1229 this._invoke = enqueue; 1230 } 1231 1232 defineIteratorMethods(AsyncIterator.prototype); 1233 AsyncIterator.prototype[asyncIteratorSymbol] = function () { 1234 return this; 1235 }; 1236 runtime.AsyncIterator = AsyncIterator; 1237 1238 // Note that simple async functions are implemented on top of 1239 // AsyncIterator objects; they just return a Promise for the value of 1240 // the final result produced by the iterator. 1241 runtime.async = function(innerFn, outerFn, self, tryLocsList) { 1242 var iter = new AsyncIterator( 1243 wrap(innerFn, outerFn, self, tryLocsList) 1244 ); 1245 1246 return runtime.isGeneratorFunction(outerFn) 1247 ? iter // If outerFn is a generator, return the full iterator. 1248 : iter.next().then(function(result) { 1249 return result.done ? result.value : iter.next(); 1250 }); 1251 }; 1252 1253 function makeInvokeMethod(innerFn, self, context) { 1254 var state = GenStateSuspendedStart; 1255 1256 return function invoke(method, arg) { 1257 if (state === GenStateExecuting) { 1258 throw new Error("Generator is already running"); 1259 } 1260 1261 if (state === GenStateCompleted) { 1262 if (method === "throw") { 1263 throw arg; 1264 } 1265 1266 // Be forgiving, per 25.3.3.3.3 of the spec: 1267 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume 1268 return doneResult(); 1269 } 1270 1271 context.method = method; 1272 context.arg = arg; 1273 1274 while (true) { 1275 var delegate = context.delegate; 1276 if (delegate) { 1277 var delegateResult = maybeInvokeDelegate(delegate, context); 1278 if (delegateResult) { 1279 if (delegateResult === ContinueSentinel) continue; 1280 return delegateResult; 1281 } 1282 } 1283 1284 if (context.method === "next") { 1285 // Setting context._sent for legacy support of Babel's 1286 // function.sent implementation. 1287 context.sent = context._sent = context.arg; 1288 1289 } else if (context.method === "throw") { 1290 if (state === GenStateSuspendedStart) { 1291 state = GenStateCompleted; 1292 throw context.arg; 1293 } 1294 1295 context.dispatchException(context.arg); 1296 1297 } else if (context.method === "return") { 1298 context.abrupt("return", context.arg); 1299 } 1300 1301 state = GenStateExecuting; 1302 1303 var record = tryCatch(innerFn, self, context); 1304 if (record.type === "normal") { 1305 // If an exception is thrown from innerFn, we leave state === 1306 // GenStateExecuting and loop back for another invocation. 1307 state = context.done 1308 ? GenStateCompleted 1309 : GenStateSuspendedYield; 1310 1311 if (record.arg === ContinueSentinel) { 1312 continue; 1313 } 1314 1315 return { 1316 value: record.arg, 1317 done: context.done 1318 }; 1319 1320 } else if (record.type === "throw") { 1321 state = GenStateCompleted; 1322 // Dispatch the exception by looping back around to the 1323 // context.dispatchException(context.arg) call above. 1324 context.method = "throw"; 1325 context.arg = record.arg; 1326 } 1327 } 1328 }; 1329 } 1330 1331 // Call delegate.iterator[context.method](context.arg) and handle the 1332 // result, either by returning a { value, done } result from the 1333 // delegate iterator, or by modifying context.method and context.arg, 1334 // setting context.delegate to null, and returning the ContinueSentinel. 1335 function maybeInvokeDelegate(delegate, context) { 1336 var method = delegate.iterator[context.method]; 1337 if (method === undefined) { 1338 // A .throw or .return when the delegate iterator has no .throw 1339 // method always terminates the yield* loop. 1340 context.delegate = null; 1341 1342 if (context.method === "throw") { 1343 if (delegate.iterator.return) { 1344 // If the delegate iterator has a return method, give it a 1345 // chance to clean up. 1346 context.method = "return"; 1347 context.arg = undefined; 1348 maybeInvokeDelegate(delegate, context); 1349 1350 if (context.method === "throw") { 1351 // If maybeInvokeDelegate(context) changed context.method from 1352 // "return" to "throw", let that override the TypeError below.
vendor: 4,172 bytes, lines 1353-1506
1353 return ContinueSentinel; 1354 } 1355 } 1356 1357 context.method = "throw"; 1358 context.arg = new TypeError( 1359 "The iterator does not provide a 'throw' method"); 1360 } 1361 1362 return ContinueSentinel; 1363 } 1364 1365 var record = tryCatch(method, delegate.iterator, context.arg); 1366 1367 if (record.type === "throw") { 1368 context.method = "throw"; 1369 context.arg = record.arg; 1370 context.delegate = null; 1371 return ContinueSentinel; 1372 } 1373 1374 var info = record.arg; 1375 1376 if (! info) { 1377 context.method = "throw"; 1378 context.arg = new TypeError("iterator result is not an object"); 1379 context.delegate = null; 1380 return ContinueSentinel; 1381 } 1382 1383 if (info.done) { 1384 // Assign the result of the finished delegate to the temporary 1385 // variable specified by delegate.resultName (see delegateYield). 1386 context[delegate.resultName] = info.value; 1387 1388 // Resume execution at the desired location (see delegateYield). 1389 context.next = delegate.nextLoc; 1390 1391 // If context.method was "throw" but the delegate handled the 1392 // exception, let the outer generator proceed normally. If 1393 // context.method was "next", forget context.arg since it has been 1394 // "consumed" by the delegate iterator. If context.method was 1395 // "return", allow the original .return call to continue in the 1396 // outer generator. 1397 if (context.method !== "return") { 1398 context.method = "next"; 1399 context.arg = undefined; 1400 } 1401 1402 } else { 1403 // Re-yield the result returned by the delegate method. 1404 return info; 1405 } 1406 1407 // The delegate iterator is finished, so forget it and continue with 1408 // the outer generator. 1409 context.delegate = null; 1410 return ContinueSentinel; 1411 } 1412 1413 // Define Generator.prototype.{next,throw,return} in terms of the 1414 // unified ._invoke helper method. 1415 defineIteratorMethods(Gp); 1416 1417 Gp[toStringTagSymbol] = "Generator"; 1418 1419 // A Generator should always return itself as the iterator object when the 1420 // @@iterator function is called on it. Some browsers' implementations of the 1421 // iterator prototype chain incorrectly implement this, causing the Generator 1422 // object to not be returned from this call. This ensures that doesn't happen. 1423 // See https://github.com/facebook/regenerator/issues/274 for more details. 1424 Gp[iteratorSymbol] = function() { 1425 return this; 1426 }; 1427 1428 Gp.toString = function() { 1429 return "[object Generator]"; 1430 }; 1431 1432 function pushTryEntry(locs) { 1433 var entry = { tryLoc: locs[0] }; 1434 1435 if (1 in locs) { 1436 entry.catchLoc = locs[1]; 1437 } 1438 1439 if (2 in locs) { 1440 entry.finallyLoc = locs[2]; 1441 entry.afterLoc = locs[3]; 1442 } 1443 1444 this.tryEntries.push(entry); 1445 } 1446 1447 function resetTryEntry(entry) { 1448 var record = entry.completion || {}; 1449 record.type = "normal"; 1450 delete record.arg; 1451 entry.completion = record; 1452 } 1453 1454 function Context(tryLocsList) { 1455 // The root entry object (effectively a try statement without a catch 1456 // or a finally block) gives us a place to store values thrown from 1457 // locations where there is no enclosing try statement. 1458 this.tryEntries = [{ tryLoc: "root" }]; 1459 tryLocsList.forEach(pushTryEntry, this); 1460 this.reset(true); 1461 } 1462 1463 runtime.keys = function(object) { 1464 var keys = []; 1465 for (var key in object) { 1466 keys.push(key); 1467 } 1468 keys.reverse(); 1469 1470 // Rather than returning an object with a next method, we keep 1471 // things simple and return the next function itself. 1472 return function next() { 1473 while (keys.length) { 1474 var key = keys.pop(); 1475 if (key in object) { 1476 next.value = key; 1477 next.done = false; 1478 return next; 1479 } 1480 } 1481 1482 // To avoid creating an additional object, we just hang the .value 1483 // and .done properties off the next function object itself. This 1484 // also ensures that the minifier will not anonymize the function. 1485 next.done = true; 1486 return next; 1487 }; 1488 }; 1489 1490 function values(iterable) { 1491 if (iterable) { 1492 var iteratorMethod = iterable[iteratorSymbol]; 1493 if (iteratorMethod) { 1494 return iteratorMethod.call(iterable); 1495 } 1496 1497 if (typeof iterable.next === "function") { 1498 return iterable; 1499 } 1500 1501 if (!isNaN(iterable.length)) { 1502 var i = -1, next = function next() { 1503 while (++i < iterable.length) { 1504 if (hasOwn.call(iterable, i)) { 1505 next.value = iterable[i]; 1506 next.done = false;
1507 return next; 1508 } 1509 } 1510 1511 next.value = undefined; 1512 next.done = true; 1513 1514 return next; 1515 }; 1516 1517 return next.next = next; 1518 } 1519 } 1520 1521 // Return an iterator with no values. 1522 return { next: doneResult }; 1523 } 1524 runtime.values = values; 1525 1526 function doneResult() { 1527 return { value: undefined, done: true }; 1528 } 1529 1530 Context.prototype = { 1531 constructor: Context, 1532 1533 reset: function(skipTempReset) { 1534 this.prev = 0; 1535 this.next = 0; 1536 // Resetting context._sent for legacy support of Babel's 1537 // function.sent implementation. 1538 this.sent = this._sent = undefined; 1539 this.done = false; 1540 this.delegate = null; 1541 1542 this.method = "next"; 1543 this.arg = undefined; 1544 1545 this.tryEntries.forEach(resetTryEntry); 1546 1547 if (!skipTempReset) { 1548 for (var name in this) { 1549 // Not sure about the optimal order of these conditions: 1550 if (name.charAt(0) === "t" && 1551 hasOwn.call(this, name) && 1552 !isNaN(+name.slice(1))) { 1553 this[name] = undefined; 1554 } 1555 } 1556 } 1557 }, 1558 1559 stop: function() { 1560 this.done = true; 1561 1562 var rootEntry = this.tryEntries[0]; 1563 var rootRecord = rootEntry.completion; 1564 if (rootRecord.type === "throw") { 1565 throw rootRecord.arg; 1566 } 1567 1568 return this.rval; 1569 }, 1570 1571 dispatchException: function(exception) { 1572 if (this.done) { 1573 throw exception; 1574 } 1575 1576 var context = this; 1577 function handle(loc, caught) { 1578 record.type = "throw"; 1579 record.arg = exception; 1580 context.next = loc; 1581 1582 if (caught) { 1583 // If the dispatched exception was caught by a catch block, 1584 // then let that catch block handle the exception normally. 1585 context.method = "next"; 1586 context.arg = undefined; 1587 } 1588 1589 return !! caught; 1590 } 1591 1592 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1593 var entry = this.tryEntries[i]; 1594 var record = entry.completion; 1595 1596 if (entry.tryLoc === "root") { 1597 // Exception thrown outside of any try block that could handle 1598 // it, so set the completion value of the entire function to 1599 // throw the exception. 1600 return handle("end"); 1601 } 1602 1603 if (entry.tryLoc <= this.prev) { 1604 var hasCatch = hasOwn.call(entry, "catchLoc"); 1605 var hasFinally = hasOwn.call(entry, "finallyLoc"); 1606 1607 if (hasCatch && hasFinally) { 1608 if (this.prev < entry.catchLoc) { 1609 return handle(entry.catchLoc, true); 1610 } else if (this.prev < entry.finallyLoc) { 1611 return handle(entry.finallyLoc); 1612 } 1613 1614 } else if (hasCatch) { 1615 if (this.prev < entry.catchLoc) { 1616 return handle(entry.catchLoc, true); 1617 } 1618 1619 } else if (hasFinally) { 1620 if (this.prev < entry.finallyLoc) { 1621 return handle(entry.finallyLoc); 1622 } 1623 1624 } else { 1625 throw new Error("try statement without catch or finally"); 1626 } 1627 } 1628 } 1629 }, 1630 1631 abrupt: function(type, arg) { 1632 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1633 var entry = this.tryEntries[i]; 1634 if (entry.tryLoc <= this.prev && 1635 hasOwn.call(entry, "finallyLoc") && 1636 this.prev < entry.finallyLoc) { 1637 var finallyEntry = entry; 1638 break; 1639 } 1640 } 1641 1642 if (finallyEntry && 1643 (type === "break" || 1644 type === "continue") && 1645 finallyEntry.tryLoc <= arg && 1646 arg <= finallyEntry.finallyLoc) { 1647 // Ignore the finally entry if control is not jumping to a 1648 // location outside the try/catch block. 1649 finallyEntry = null; 1650 } 1651 1652 var record = finallyEntry ? finallyEntry.completion : {}; 1653 record.type = type; 1654 record.arg = arg; 1655 1656 if (finallyEntry) { 1657 this.method = "next"; 1658 this.next = finallyEntry.finallyLoc; 1659 return ContinueSentinel; 1660 } 1661 1662 return this.complete(record); 1663 }, 1664 1665 complete: function(record, afterLoc) { 1666 if (record.type === "throw") { 1667 throw record.arg; 1668 } 1669 1670 if (record.type === "break" || 1671 record.type === "continue") { 1672 this.next = record.arg; 1673 } else if (record.type === "return") { 1674 this.rval = this.arg = record.arg; 1675 this.method = "return"; 1676 this.next = "end"; 1677 } else if (record.type === "normal" && afterLoc) { 1678 this.next = afterLoc; 1679 } 1680 1681 return ContinueSentinel; 1682 }, 1683 1684 finish: function(finallyLoc) { 1685 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1686 var entry = this.tryEntries[i]; 1687 if (entry.finallyLoc === finallyLoc) { 1688 this.complete(entry.completion, entry.afterLoc); 1689 resetTryEntry(entry); 1690 return ContinueSentinel; 1691 } 1692 } 1693 }, 1694 1695 "catch": function(tryLoc) { 1696 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1697 var entry = this.tryEntries[i]; 1698 if (entry.tryLoc === tryLoc) { 1699 var record = entry.completion; 1700 if (record.type === "throw") { 1701 var thrown = record.arg; 1702 resetTryEntry(entry); 1703 } 1704 return thrown; 1705 } 1706 } 1707 1708 // The context.catch method must only be called with a location 1709 // argument that corresponds to a known catch block. 1710 throw new Error("illegal catch attempt"); 1711 }, 1712 1713 delegateYield: function(iterable, resultName, nextLoc) { 1714 this.delegate = { 1715 iterator: values(iterable), 1716 resultName: resultName, 1717 nextLoc: nextLoc 1718 }; 1719 1720 if (this.method === "next") { 1721 // Deliberately forget the last sent value so that we don't 1722 // accidentally pass it on to the delegate. 1723 this.arg = undefined; 1724 } 1725 1726 return ContinueSentinel; 1727 } 1728 }; 1729})( 1730 // In sloppy mode, unbound `this` refers to the global object, fallback to 1731 // Function constructor if we're in global strict mode. That is sadly a form 1732 // of indirect eval which violates Content Security Policy. 1733 (function() { return this })() || Function("return this")() 1734); 1735 1736(function (exports) { 1737 'use strict'; 1738 1739 var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; 1740 function createCommonjsModule(fn, module) { 1741 return module = { 1742 exports: {} 1743 }, fn(module, module.exports), module.exports; 1744 } 1745 1746 var check = function (it) { 1747 return it && it.Math == Math && it; 1748 }; // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 1749 1750 1751 var global_1 = // eslint-disable-next-line es/no-global-this -- safe 1752 check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || // eslint-disable-next-line no-restricted-globals -- safe 1753 check(typeof self == 'object' && self) || check(typeof commonjsGlobal == 'object' && commonjsGlobal) || // eslint-disable-next-line no-new-func -- fallback 1754 function () { 1755 return this; 1756 }() || Function('return this')(); 1757 1758 var fails = function (exec) { 1759 try { 1760 return !!exec(); 1761 } catch (error) { 1762 return true; 1763 } 1764 }; 1765 1766 // Detect IE8's incomplete defineProperty implementation 1767 1768 1769 var descriptors = !fails(function () { 1770 // eslint-disable-next-line es/no-object-defineproperty -- required for testing 1771 return Object.defineProperty({}, 1, { 1772 get: function () { 1773 return 7; 1774 } 1775 })[1] != 7; 1776 }); 1777 1778 var call = Function.prototype.call; 1779 var functionCall = call.bind ? call.bind(call) : function () { 1780 return call.apply(call, arguments); 1781 }; 1782 1783 var $propertyIsEnumerable = {}.propertyIsEnumerable; // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 1784 1785 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; // Nashorn ~ JDK8 bug 1786 1787 var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1788 1: 2 1789 }, 1); // `Object.prototype.propertyIsEnumerable` method implementation 1790 // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable 1791 1792 var f = NASHORN_BUG ? function propertyIsEnumerable(V) { 1793 var descriptor = getOwnPropertyDescriptor(this, V); 1794 return !!descriptor && descriptor.enumerable; 1795 } : $propertyIsEnumerable; 1796 1797 var objectPropertyIsEnumerable = { 1798 f: f 1799 }; 1800 1801 var createPropertyDescriptor = function (bitmap, value) { 1802 return { 1803 enumerable: !(bitmap & 1), 1804 configurable: !(bitmap & 2), 1805 writable: !(bitmap & 4), 1806 value: value 1807 }; 1808 }; 1809 1810 var FunctionPrototype = Function.prototype; 1811 var bind = FunctionPrototype.bind; 1812 var call$1 = FunctionPrototype.call; 1813 var callBind = bind && bind.bind(call$1); 1814 var functionUncurryThis = bind ? function (fn) {
1815 return fn && callBind(call$1, fn); 1816 } : function (fn) { 1817 return fn && function () { 1818 return call$1.apply(fn, arguments); 1819 }; 1820 }; 1821 1822 var toString = functionUncurryThis({}.toString); 1823 var stringSlice = functionUncurryThis(''.slice); 1824 1825 var classofRaw = function (it) { 1826 return stringSlice(toString(it), 8, -1); 1827 }; 1828 1829 var Object$1 = global_1.Object; 1830 var split = functionUncurryThis(''.split); // fallback for non-array-like ES3 and non-enumerable old V8 strings 1831 1832 var indexedObject = fails(function () { 1833 // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346 1834 // eslint-disable-next-line no-prototype-builtins -- safe 1835 return !Object$1('z').propertyIsEnumerable(0); 1836 }) ? function (it) { 1837 return classofRaw(it) == 'String' ? split(it, '') : Object$1(it); 1838 } : Object$1; 1839 1840 var TypeError$1 = global_1.TypeError; // `RequireObjectCoercible` abstract operation 1841 // https://tc39.es/ecma262/#sec-requireobjectcoercible 1842 1843 var requireObjectCoercible = function (it) { 1844 if (it == undefined) throw TypeError$1("Can't call method on " + it); 1845 return it; 1846 }; 1847 1848 // toObject with fallback for non-array-like ES3 strings 1849 1850 1851 1852 1853 var toIndexedObject = function (it) { 1854 return indexedObject(requireObjectCoercible(it)); 1855 }; 1856 1857 // `IsCallable` abstract operation 1858 // https://tc39.es/ecma262/#sec-iscallable 1859 var isCallable = function (argument) { 1860 return typeof argument == 'function'; 1861 }; 1862 1863 var isObject = function (it) { 1864 return typeof it == 'object' ? it !== null : isCallable(it); 1865 }; 1866 1867 var aFunction = function (argument) { 1868 return isCallable(argument) ? argument : undefined; 1869 }; 1870 1871 var getBuiltIn = function (namespace, method) { 1872 return arguments.length < 2 ? aFunction(global_1[namespace]) : global_1[namespace] && global_1[namespace][method]; 1873 }; 1874 1875 var objectIsPrototypeOf = functionUncurryThis({}.isPrototypeOf); 1876 1877 var engineUserAgent = getBuiltIn('navigator', 'userAgent') || ''; 1878 1879 var process = global_1.process; 1880 var Deno = global_1.Deno; 1881 var versions = process && process.versions || Deno && Deno.version; 1882 var v8 = versions && versions.v8; 1883 var match, version; 1884 1885 if (v8) { 1886 match = v8.split('.'); // in old Chrome, versions of V8 isn't V8 = Chrome / 10 1887 // but their correct versions are not interesting for us 1888 1889 version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]); 1890 } // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0` 1891 // so check `userAgent` even if `.v8` exists, but 0 1892 1893 1894 if (!version && engineUserAgent) { 1895 match = engineUserAgent.match(/Edge\/(\d+)/); 1896 1897 if (!match || match[1] >= 74) { 1898 match = engineUserAgent.match(/Chrome\/(\d+)/); 1899 if (match) version = +match[1]; 1900 } 1901 } 1902 1903 var engineV8Version = version; 1904 1905 /* eslint-disable es/no-symbol -- required for testing */ 1906 1907 1908 // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing 1909 1910 1911 var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () { 1912 var symbol = Symbol(); // Chrome 38 Symbol has incorrect toString conversion 1913 // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances 1914 1915 return !String(symbol) || !(Object(symbol) instanceof Symbol) || // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances 1916 !Symbol.sham && engineV8Version && engineV8Version < 41; 1917 }); 1918 1919 /* eslint-disable es/no-symbol -- required for testing */ 1920 1921 1922 var useSymbolAsUid = nativeSymbol && !Symbol.sham && typeof Symbol.iterator == 'symbol'; 1923 1924 var Object$2 = global_1.Object; 1925 var isSymbol = useSymbolAsUid ? function (it) { 1926 return typeof it == 'symbol'; 1927 } : function (it) { 1928 var $Symbol = getBuiltIn('Symbol'); 1929 return isCallable($Symbol) && objectIsPrototypeOf($Symbol.prototype, Object$2(it)); 1930 }; 1931 1932 var String$1 = global_1.String; 1933 1934 var tryToString = function (argument) { 1935 try { 1936 return String$1(argument); 1937 } catch (error) { 1938 return 'Object'; 1939 } 1940 }; 1941 1942 var TypeError$2 = global_1.TypeError; // `Assert: IsCallable(argument) is true` 1943 1944 var aCallable = function (argument) { 1945 if (isCallable(argument)) return argument; 1946 throw TypeError$2(tryToString(argument) + ' is not a function'); 1947 }; 1948 1949 // `GetMethod` abstract operation 1950 // https://tc39.es/ecma262/#sec-getmethod 1951 1952 1953 var getMethod = function (V, P) { 1954 var func = V[P]; 1955 return func == null ? undefined : aCallable(func); 1956 }; 1957 1958 var TypeError$3 = global_1.TypeError; // `OrdinaryToPrimitive` abstract operation 1959 // https://tc39.es/ecma262/#sec-ordinarytoprimitive 1960 1961 var ordinaryToPrimitive = function (input, pref) { 1962 var fn, val; 1963 if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val; 1964 if (isCallable(fn = input.valueOf) && !isObject(val = functionCall(fn, input))) return val; 1965 if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val; 1966 throw TypeError$3("Can't convert object to primitive value"); 1967 }; 1968 1969 var isPure = false;
1970 1971 // eslint-disable-next-line es/no-object-defineproperty -- safe 1972 1973 1974 var defineProperty = Object.defineProperty; 1975 1976 var setGlobal = function (key, value) { 1977 try { 1978 defineProperty(global_1, key, { 1979 value: value, 1980 configurable: true, 1981 writable: true 1982 }); 1983 } catch (error) { 1984 global_1[key] = value; 1985 } 1986 1987 return value; 1988 }; 1989 1990 var SHARED = '__core-js_shared__'; 1991 var store = global_1[SHARED] || setGlobal(SHARED, {}); 1992 var sharedStore = store; 1993 1994 var shared = createCommonjsModule(function (module) { 1995 (module.exports = function (key, value) { 1996 return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {}); 1997 })('versions', []).push({ 1998 version: '3.19.2', 1999 mode: 'global', 2000 copyright: '(c) 2021 Denis Pushkarev (zloirock.ru)' 2001 }); 2002 }); 2003 2004 var Object$3 = global_1.Object; // `ToObject` abstract operation 2005 // https://tc39.es/ecma262/#sec-toobject 2006 2007 var toObject = function (argument) { 2008 return Object$3(requireObjectCoercible(argument)); 2009 }; 2010 2011 var hasOwnProperty = functionUncurryThis({}.hasOwnProperty); // `HasOwnProperty` abstract operation 2012 // https://tc39.es/ecma262/#sec-hasownproperty 2013 2014 var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) { 2015 return hasOwnProperty(toObject(it), key); 2016 }; 2017 2018 var id = 0; 2019 var postfix = Math.random(); 2020 var toString$1 = functionUncurryThis(1.0.toString); 2021 2022 var uid = function (key) { 2023 return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$1(++id + postfix, 36); 2024 }; 2025 2026 var WellKnownSymbolsStore = shared('wks'); 2027 var Symbol$1 = global_1.Symbol; 2028 var symbolFor = Symbol$1 && Symbol$1['for']; 2029 var createWellKnownSymbol = useSymbolAsUid ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid; 2030 2031 var wellKnownSymbol = function (name) { 2032 if (!hasOwnProperty_1(WellKnownSymbolsStore, name) || !(nativeSymbol || typeof WellKnownSymbolsStore[name] == 'string')) { 2033 var description = 'Symbol.' + name; 2034 2035 if (nativeSymbol && hasOwnProperty_1(Symbol$1, name)) { 2036 WellKnownSymbolsStore[name] = Symbol$1[name]; 2037 } else if (useSymbolAsUid && symbolFor) { 2038 WellKnownSymbolsStore[name] = symbolFor(description); 2039 } else { 2040 WellKnownSymbolsStore[name] = createWellKnownSymbol(description); 2041 } 2042 } 2043 2044 return WellKnownSymbolsStore[name]; 2045 }; 2046 2047 var TypeError$4 = global_1.TypeError; 2048 var TO_PRIMITIVE = wellKnownSymbol('toPrimitive'); // `ToPrimitive` abstract operation 2049 // https://tc39.es/ecma262/#sec-toprimitive 2050 2051 var toPrimitive = function (input, pref) { 2052 if (!isObject(input) || isSymbol(input)) return input; 2053 var exoticToPrim = getMethod(input, TO_PRIMITIVE); 2054 var result; 2055 2056 if (exoticToPrim) { 2057 if (pref === undefined) pref = 'default'; 2058 result = functionCall(exoticToPrim, input, pref); 2059 if (!isObject(result) || isSymbol(result)) return result; 2060 throw TypeError$4("Can't convert object to primitive value"); 2061 } 2062 2063 if (pref === undefined) pref = 'number'; 2064 return ordinaryToPrimitive(input, pref); 2065 }; 2066 2067 // `ToPropertyKey` abstract operation 2068 // https://tc39.es/ecma262/#sec-topropertykey 2069 2070 2071 var toPropertyKey = function (argument) { 2072 var key = toPrimitive(argument, 'string'); 2073 return isSymbol(key) ? key : key + ''; 2074 }; 2075 2076 var document$1 = global_1.document; // typeof document.createElement is 'object' in old IE 2077 2078 var EXISTS = isObject(document$1) && isObject(document$1.createElement); 2079 2080 var documentCreateElement = function (it) { 2081 return EXISTS ? document$1.createElement(it) : {}; 2082 }; 2083 2084 // Thank's IE8 for his funny defineProperty 2085 2086 2087 var ie8DomDefine = !descriptors && !fails(function () { 2088 // eslint-disable-next-line es/no-object-defineproperty -- requied for testing 2089 return Object.defineProperty(documentCreateElement('div'), 'a', { 2090 get: function () { 2091 return 7; 2092 } 2093 }).a != 7; 2094 }); 2095 2096 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2097 2098 2099 var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; // `Object.getOwnPropertyDescriptor` method 2100 // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor 2101 2102 var f$1 = descriptors ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) { 2103 O = toIndexedObject(O); 2104 P = toPropertyKey(P); 2105 if (ie8DomDefine) try { 2106 return $getOwnPropertyDescriptor(O, P); 2107 } catch (error) { 2108 /* empty */ 2109 } 2110 if (hasOwnProperty_1(O, P)) return createPropertyDescriptor(!functionCall(objectPropertyIsEnumerable.f, O, P), O[P]); 2111 }; 2112 2113 var objectGetOwnPropertyDescriptor = { 2114 f: f$1 2115 }; 2116 2117 var String$2 = global_1.String; 2118 var TypeError$5 = global_1.TypeError; // `Assert: Type(argument) is Object` 2119 2120 var anObject = function (argument) { 2121 if (isObject(argument)) return argument; 2122 throw TypeError$5(String$2(argument) + ' is not an object'); 2123 }; 2124 2125 var TypeError$6 = global_1.TypeError; // eslint-disable-next-line es/no-object-defineproperty -- safe 2126 2127 var $defineProperty = Object.defineProperty; // `Object.defineProperty` method 2128 // https://tc39.es/ecma262/#sec-object.defineproperty 2129 2130 var f$2 = descriptors ? $defineProperty : function defineProperty(O, P, Attributes) { 2131 anObject(O); 2132 P = toPropertyKey(P); 2133 anObject(Attributes); 2134 if (ie8DomDefine) try { 2135 return $defineProperty(O, P, Attributes); 2136 } catch (error) { 2137 /* empty */ 2138 } 2139 if ('get' in Attributes || 'set' in Attributes) throw TypeError$6('Accessors not supported'); 2140 if ('value' in Attributes) O[P] = Attributes.value; 2141 return O; 2142 }; 2143 2144 var objectDefineProperty = { 2145 f: f$2 2146 }; 2147 2148 var createNonEnumerableProperty = descriptors ? function (object, key, value) { 2149 return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value)); 2150 } : function (object, key, value) { 2151 object[key] = value; 2152 return object; 2153 }; 2154 2155 var functionToString = functionUncurryThis(Function.toString); // this helper broken in `[email protected]`, so we can't use `shared` helper 2156 2157 if (!isCallable(sharedStore.inspectSource)) { 2158 sharedStore.inspectSource = function (it) { 2159 return functionToString(it); 2160 }; 2161 } 2162 2163 var inspectSource = sharedStore.inspectSource; 2164 2165 var WeakMap = global_1.WeakMap; 2166 var nativeWeakMap = isCallable(WeakMap) && /native code/.test(inspectSource(WeakMap)); 2167 2168 var keys = shared('keys'); 2169 2170 var sharedKey = function (key) { 2171 return keys[key] || (keys[key] = uid(key)); 2172 }; 2173 2174 var hiddenKeys = {}; 2175 2176 var OBJECT_ALREADY_INITIALIZED = 'Object already initialized'; 2177 var TypeError$7 = global_1.TypeError; 2178 var WeakMap$1 = global_1.WeakMap; 2179 var set, get, has; 2180 2181 var enforce = function (it) { 2182 return has(it) ? get(it) : set(it, {}); 2183 }; 2184 2185 var getterFor = function (TYPE) { 2186 return function (it) { 2187 var state; 2188 2189 if (!isObject(it) || (state = get(it)).type !== TYPE) { 2190 throw TypeError$7('Incompatible receiver, ' + TYPE + ' required'); 2191 } 2192 2193 return state; 2194 }; 2195 }; 2196 2197 if (nativeWeakMap || sharedStore.state) { 2198 var store$1 = sharedStore.state || (sharedStore.state = new WeakMap$1()); 2199 var wmget = functionUncurryThis(store$1.get); 2200 var wmhas = functionUncurryThis(store$1.has); 2201 var wmset = functionUncurryThis(store$1.set); 2202 2203 set = function (it, metadata) { 2204 if (wmhas(store$1, it)) throw new TypeError$7(OBJECT_ALREADY_INITIALIZED); 2205 metadata.facade = it; 2206 wmset(store$1, it, metadata); 2207 return metadata; 2208 }; 2209 2210 get = function (it) { 2211 return wmget(store$1, it) || {}; 2212 }; 2213 2214 has = function (it) { 2215 return wmhas(store$1, it); 2216 }; 2217 } else { 2218 var STATE = sharedKey('state'); 2219 hiddenKeys[STATE] = true; 2220 2221 set = function (it, metadata) { 2222 if (hasOwnProperty_1(it, STATE)) throw new TypeError$7(OBJECT_ALREADY_INITIALIZED); 2223 metadata.facade = it; 2224 createNonEnumerableProperty(it, STATE, metadata); 2225 return metadata; 2226 }; 2227 2228 get = function (it) { 2229 return hasOwnProperty_1(it, STATE) ? it[STATE] : {}; 2230 }; 2231 2232 has = function (it) { 2233 return hasOwnProperty_1(it, STATE); 2234 }; 2235 } 2236 2237 var internalState = { 2238 set: set, 2239 get: get, 2240 has: has, 2241 enforce: enforce, 2242 getterFor: getterFor 2243 }; 2244 2245 var FunctionPrototype$1 = Function.prototype; // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2246 2247 var getDescriptor = descriptors && Object.getOwnPropertyDescriptor; 2248 var EXISTS$1 = hasOwnProperty_1(FunctionPrototype$1, 'name'); // additional protection from minified / mangled / dropped function names 2249 2250 var PROPER = EXISTS$1 && function something() { 2251 /* empty */ 2252 }.name === 'something'; 2253 2254 var CONFIGURABLE = EXISTS$1 && (!descriptors || descriptors && getDescriptor(FunctionPrototype$1, 'name').configurable); 2255 var functionName = { 2256 EXISTS: EXISTS$1, 2257 PROPER: PROPER, 2258 CONFIGURABLE: CONFIGURABLE 2259 }; 2260 2261 var redefine = createCommonjsModule(function (module) { 2262 var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE; 2263 2264 var getInternalState = internalState.get; 2265 var enforceInternalState = internalState.enforce;
vendor: 4,394 bytes, lines 2266-2394
2266 var TEMPLATE = String(String).split('String'); 2267 (module.exports = function (O, key, value, options) { 2268 var unsafe = options ? !!options.unsafe : false; 2269 var simple = options ? !!options.enumerable : false; 2270 var noTargetGet = options ? !!options.noTargetGet : false; 2271 var name = options && options.name !== undefined ? options.name : key; 2272 var state; 2273 2274 if (isCallable(value)) { 2275 if (String(name).slice(0, 7) === 'Symbol(') { 2276 name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']'; 2277 } 2278 2279 if (!hasOwnProperty_1(value, 'name') || CONFIGURABLE_FUNCTION_NAME && value.name !== name) { 2280 createNonEnumerableProperty(value, 'name', name); 2281 } 2282 2283 state = enforceInternalState(value); 2284 2285 if (!state.source) { 2286 state.source = TEMPLATE.join(typeof name == 'string' ? name : ''); 2287 } 2288 } 2289 2290 if (O === global_1) { 2291 if (simple) O[key] = value;else setGlobal(key, value); 2292 return; 2293 } else if (!unsafe) { 2294 delete O[key]; 2295 } else if (!noTargetGet && O[key]) { 2296 simple = true; 2297 } 2298 2299 if (simple) O[key] = value;else createNonEnumerableProperty(O, key, value); // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative 2300 })(Function.prototype, 'toString', function toString() { 2301 return isCallable(this) && getInternalState(this).source || inspectSource(this); 2302 }); 2303 }); 2304 2305 var ceil = Math.ceil; 2306 var floor = Math.floor; // `ToIntegerOrInfinity` abstract operation 2307 // https://tc39.es/ecma262/#sec-tointegerorinfinity 2308 2309 var toIntegerOrInfinity = function (argument) { 2310 var number = +argument; // eslint-disable-next-line no-self-compare -- safe 2311 2312 return number !== number || number === 0 ? 0 : (number > 0 ? floor : ceil)(number); 2313 }; 2314 2315 var max = Math.max; 2316 var min = Math.min; // Helper for a popular repeating case of the spec: 2317 // Let integer be ? ToInteger(index). 2318 // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length). 2319 2320 var toAbsoluteIndex = function (index, length) { 2321 var integer = toIntegerOrInfinity(index); 2322 return integer < 0 ? max(integer + length, 0) : min(integer, length); 2323 }; 2324 2325 var min$1 = Math.min; // `ToLength` abstract operation 2326 // https://tc39.es/ecma262/#sec-tolength 2327 2328 var toLength = function (argument) { 2329 return argument > 0 ? min$1(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 2330 }; 2331 2332 // `LengthOfArrayLike` abstract operation 2333 // https://tc39.es/ecma262/#sec-lengthofarraylike 2334 2335 2336 var lengthOfArrayLike = function (obj) { 2337 return toLength(obj.length); 2338 }; 2339 2340 // `Array.prototype.{ indexOf, includes }` methods implementation 2341 2342 2343 var createMethod = function (IS_INCLUDES) { 2344 return function ($this, el, fromIndex) { 2345 var O = toIndexedObject($this); 2346 var length = lengthOfArrayLike(O); 2347 var index = toAbsoluteIndex(fromIndex, length); 2348 var value; // Array#includes uses SameValueZero equality algorithm 2349 // eslint-disable-next-line no-self-compare -- NaN check 2350 2351 if (IS_INCLUDES && el != el) while (length > index) { 2352 value = O[index++]; // eslint-disable-next-line no-self-compare -- NaN check 2353 2354 if (value != value) return true; // Array#indexOf ignores holes, Array#includes - not 2355 } else for (; length > index; index++) { 2356 if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0; 2357 } 2358 return !IS_INCLUDES && -1; 2359 }; 2360 }; 2361 2362 var arrayIncludes = { 2363 // `Array.prototype.includes` method 2364 // https://tc39.es/ecma262/#sec-array.prototype.includes 2365 includes: createMethod(true), 2366 // `Array.prototype.indexOf` method 2367 // https://tc39.es/ecma262/#sec-array.prototype.indexof 2368 indexOf: createMethod(false) 2369 }; 2370 2371 var indexOf = arrayIncludes.indexOf; 2372 2373 2374 2375 var push = functionUncurryThis([].push); 2376 2377 var objectKeysInternal = function (object, names) { 2378 var O = toIndexedObject(object); 2379 var i = 0; 2380 var result = []; 2381 var key; 2382 2383 for (key in O) !hasOwnProperty_1(hiddenKeys, key) && hasOwnProperty_1(O, key) && push(result, key); // Don't enum bug & hidden keys 2384 2385 2386 while (names.length > i) if (hasOwnProperty_1(O, key = names[i++])) { 2387 ~indexOf(result, key) || push(result, key); 2388 } 2389 2390 return result; 2391 }; 2392 2393 // IE8- don't enum bug keys 2394 var enumBugKeys = ['constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleStr
2394ing', 'toString', 'valueOf']; 2395 2396 var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype'); // `Object.getOwnPropertyNames` method 2397 // https://tc39.es/ecma262/#sec-object.getownpropertynames 2398 // eslint-disable-next-line es/no-object-getownpropertynames -- safe 2399 2400 var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { 2401 return objectKeysInternal(O, hiddenKeys$1); 2402 }; 2403 2404 var objectGetOwnPropertyNames = { 2405 f: f$3 2406 }; 2407 2408 // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe 2409 var f$4 = Object.getOwnPropertySymbols; 2410 2411 var objectGetOwnPropertySymbols = { 2412 f: f$4 2413 }; 2414 2415 var concat = functionUncurryThis([].concat); // all object keys, includes non-enumerable and symbols 2416 2417 var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) { 2418 var keys = objectGetOwnPropertyNames.f(anObject(it)); 2419 var getOwnPropertySymbols = objectGetOwnPropertySymbols.f; 2420 return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys; 2421 }; 2422 2423 var copyConstructorProperties = function (target, source) { 2424 var keys = ownKeys(source); 2425 var defineProperty = objectDefineProperty.f; 2426 var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; 2427 2428 for (var i = 0; i < keys.length; i++) { 2429 var key = keys[i]; 2430 if (!hasOwnProperty_1(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key)); 2431 } 2432 }; 2433 2434 var replacement = /#|\.prototype\./; 2435 2436 var isForced = function (feature, detection) { 2437 var value = data[normalize(feature)]; 2438 return value == POLYFILL ? true : value == NATIVE ? false : isCallable(detection) ? fails(detection) : !!detection; 2439 }; 2440 2441 var normalize = isForced.normalize = function (string) { 2442 return String(string).replace(replacement, '.').toLowerCase(); 2443 }; 2444 2445 var data = isForced.data = {}; 2446 var NATIVE = isForced.NATIVE = 'N'; 2447 var POLYFILL = isForced.POLYFILL = 'P'; 2448 var isForced_1 = isForced; 2449 2450 var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f; 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 /* 2462 options.target - name of the target object 2463 options.global - target is the global object 2464 options.stat - export as static methods of target 2465 options.proto - export as prototype methods of target 2466 options.real - real prototype method for the `pure` version 2467 options.forced - export even if the native feature is available 2468 options.bind - bind methods to the target, required for the `pure` version 2469 options.wrap - wrap constructors to preventing global pollution, required for the `pure` version 2470 options.unsafe - use the simple assignment of property instead of delete + defineProperty 2471 options.sham - add a flag to not completely full polyfills 2472 options.enumerable - export as enumerable property 2473 options.noTargetGet - prevent calling a getter on target 2474 options.name - the .name of the function if it does not match the key 2475 */ 2476 2477 2478 var _export = function (options, source) { 2479 var TARGET = options.target; 2480 var GLOBAL = options.global; 2481 var STATIC = options.stat; 2482 var FORCED, target, key, targetProperty, sourceProperty, descriptor; 2483 2484 if (GLOBAL) { 2485 target = global_1; 2486 } else if (STATIC) { 2487 target = global_1[TARGET] || setGlobal(TARGET, {}); 2488 } else { 2489 target = (global_1[TARGET] || {}).prototype; 2490 } 2491 2492 if (target) for (key in source) { 2493 sourceProperty = source[key]; 2494 2495 if (options.noTargetGet) { 2496 descriptor = getOwnPropertyDescriptor$1(target, key); 2497 targetProperty = descriptor && descriptor.value; 2498 } else targetProperty = target[key]; 2499 2500 FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); // contained in target 2501 2502 if (!FORCED && targetProperty !== undefined) { 2503 if (typeof sourceProperty == typeof targetProperty) continue; 2504 copyConstructorProperties(sourceProperty, targetProperty); 2505 } // add a flag to not completely full polyfills 2506 2507 2508 if (options.sham || targetProperty && targetProperty.sham) { 2509 createNonEnumerableProperty(sourceProperty, 'sham', true); 2510 } // extend global 2511 2512 2513 redefine(target, key, sourceProperty, options); 2514 } 2515 }; 2516 2517 var correctPrototypeGetter = !fails(function () { 2518 function F() { 2519 /* empty */ 2520 } 2521 2522 F.prototype.constructor = null; // eslint-disable-next-line es/no-object-getprototypeof -- required for testing 2523 2524 return Object.getPrototypeOf(new F()) !== F.prototype; 2525 }); 2526 2527 var IE_PROTO = sharedKey('IE_PROTO'); 2528 var Object$4 = global_1.Object; 2529 var ObjectPrototype = Object$4.prototype; // `Object.getPrototypeOf` method 2530 // https://tc39.es/ecma262/#sec-object.getprototypeof 2531 2532 var objectGetPrototypeOf = correctPrototypeGetter ? Object$4.getPrototypeOf : function (O) { 2533 var object = toObject(O); 2534 if (hasOwnProperty_1(object, IE_PROTO)) return object[IE_PROTO]; 2535 var constructor = object.constructor; 2536 2537 if (isCallable(constructor) && object instanceof constructor) { 2538 return constructor.prototype; 2539 } 2540
2541 return object instanceof Object$4 ? ObjectPrototype : null; 2542 }; 2543 2544 var String$3 = global_1.String; 2545 var TypeError$8 = global_1.TypeError; 2546 2547 var aPossiblePrototype = function (argument) { 2548 if (typeof argument == 'object' || isCallable(argument)) return argument; 2549 throw TypeError$8("Can't set " + String$3(argument) + ' as a prototype'); 2550 }; 2551 2552 /* eslint-disable no-proto -- safe */ 2553 2554 2555 2556 2557 // `Object.setPrototypeOf` method 2558 // https://tc39.es/ecma262/#sec-object.setprototypeof 2559 // Works with __proto__ only. Old v8 can't work with null proto objects. 2560 // eslint-disable-next-line es/no-object-setprototypeof -- safe 2561 2562 2563 var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () { 2564 var CORRECT_SETTER = false; 2565 var test = {}; 2566 var setter; 2567 2568 try { 2569 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2570 setter = functionUncurryThis(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set); 2571 setter(test, []); 2572 CORRECT_SETTER = test instanceof Array; 2573 } catch (error) { 2574 /* empty */ 2575 } 2576 2577 return function setPrototypeOf(O, proto) { 2578 anObject(O); 2579 aPossiblePrototype(proto); 2580 if (CORRECT_SETTER) setter(O, proto);else O.__proto__ = proto; 2581 return O; 2582 }; 2583 }() : undefined); 2584 2585 // `Object.keys` method 2586 // https://tc39.es/ecma262/#sec-object.keys 2587 // eslint-disable-next-line es/no-object-keys -- safe 2588 2589 2590 var objectKeys = Object.keys || function keys(O) { 2591 return objectKeysInternal(O, enumBugKeys); 2592 }; 2593 2594 // `Object.defineProperties` method 2595 // https://tc39.es/ecma262/#sec-object.defineproperties 2596 // eslint-disable-next-line es/no-object-defineproperties -- safe 2597 2598 2599 var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) { 2600 anObject(O); 2601 var props = toIndexedObject(Properties); 2602 var keys = objectKeys(Properties); 2603 var length = keys.length; 2604 var index = 0; 2605 var key; 2606 2607 while (length > index) objectDefineProperty.f(O, key = keys[index++], props[key]); 2608 2609 return O; 2610 }; 2611 2612 var html = getBuiltIn('document', 'documentElement'); 2613 2614 /* global ActiveXObject -- old IE, WSH */ 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 var GT = '>'; 2630 var LT = '<'; 2631 var PROTOTYPE = 'prototype'; 2632 var SCRIPT = 'script'; 2633 var IE_PROTO$1 = sharedKey('IE_PROTO'); 2634 2635 var EmptyConstructor = function () { 2636 /* empty */ 2637 }; 2638 2639 var scriptTag = function (content) { 2640 return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT; 2641 }; // Create object with fake `null` prototype: use ActiveX Object with cleared prototype 2642 2643 2644 var NullProtoObjectViaActiveX = function (activeXDocument) { 2645 activeXDocument.write(scriptTag('')); 2646 activeXDocument.close(); 2647 var temp = activeXDocument.parentWindow.Object; 2648 activeXDocument = null; // avoid memory leak 2649 2650 return temp; 2651 }; // Create object with fake `null` prototype: use iframe Object with cleared prototype 2652 2653 2654 var NullProtoObjectViaIFrame = function () { 2655 // Thrash, waste and sodomy: IE GC bug 2656 var iframe = documentCreateElement('iframe'); 2657 var JS = 'java' + SCRIPT + ':'; 2658 var iframeDocument; 2659 iframe.style.display = 'none'; 2660 html.appendChild(iframe); // https://github.com/zloirock/core-js/issues/475 2661 2662 iframe.src = String(JS); 2663 iframeDocument = iframe.contentWindow.document; 2664 iframeDocument.open(); 2665 iframeDocument.write(scriptTag('document.F=Object')); 2666 iframeDocument.close(); 2667 return iframeDocument.F; 2668 }; // Check for document.domain and active x support 2669 // No need to use active x approach when document.domain is not set 2670 // see https://github.com/es-shims/es5-shim/issues/150 2671 // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346 2672 // avoid IE GC bug 2673 2674 2675 var activeXDocument; 2676 2677 var NullProtoObject = function () { 2678 try { 2679 activeXDocument = new ActiveXObject('htmlfile'); 2680 } catch (error) { 2681 /* ignore */ 2682 } 2683 2684 NullProtoObject = typeof document != 'undefined' ? document.domain && activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) // old IE 2685 : NullProtoObjectViaIFrame() : NullProtoObjectViaActiveX(activeXDocument); // WSH 2686 2687 var length = enumBugKeys.length; 2688 2689 while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]]; 2690 2691 return NullProtoObject(); 2692 }; 2693 2694 hiddenKeys[IE_PROTO$1] = true; // `Object.create` method 2695 // https://tc39.es/ecma262/#sec-object.create 2696 2697 var objectCreate = Object.create || function create(O, Properties) { 2698 var result; 2699 2700 if (O !== null) { 2701 EmptyConstructor[PROTOTYPE] = anObject(O); 2702 result = new EmptyConstructor(); 2703 EmptyConstructor[PROTOTYPE] = null; // add "__proto__" for Object.getPrototypeOf polyfill 2704 2705 result[IE_PROTO$1] = O; 2706 } else result = NullProtoObject(); 2707 2708 return Properties === undefined ? result : objectDefineProperties(result, Properties); 2709 }; 2710 2711 var createProperty = function (object, key, value) { 2712 var propertyKey = toPropertyKey(key); 2713 if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value));else object[propertyKey] = value; 2714 }; 2715 2716 var Array$1 = global_1.Array; 2717 var max$1 = Math.max; 2718 2719 var arraySliceSimple = function (O, start, end) { 2720 var length = lengthOfArrayLike(O); 2721 var k = toAbsoluteIndex(start, length); 2722 var fin = toAbsoluteIndex(end === undefined ? length : end, length); 2723 var result = Array$1(max$1(fin - k, 0)); 2724 2725 for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]); 2726 2727 result.length = n; 2728 return result; 2729 }; 2730 2731 var replace = functionUncurryThis(''.replace); 2732 var split$1 = functionUncurryThis(''.split); 2733 var join = functionUncurryThis([].join); 2734 2735 var TEST = function (arg) { 2736 return String(Error(arg).stack); 2737 }('zxcasd'); 2738 2739 var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/; 2740 var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST); 2741 var IS_FIREFOX_OR_SAFARI_STACK = /@[^\n]*\n/.test(TEST) && !/zxcasd/.test(TEST); 2742 2743 var clearErrorStack = function (stack, dropEntries) { 2744 if (typeof stack != 'string') return stack; 2745 2746 if (IS_V8_OR_CHAKRA_STACK) { 2747 while (dropEntries--) stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, ''); 2748 }
2748 else if (IS_FIREFOX_OR_SAFARI_STACK) { 2749 return join(arraySliceSimple(split$1(stack, '\n'), dropEntries), '\n'); 2750 } 2751 2752 return stack; 2753 }; 2754 2755 // `InstallErrorCause` abstract operation 2756 // https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause 2757 2758 2759 var installErrorCause = function (O, options) { 2760 if (isObject(options) && 'cause' in options) { 2761 createNonEnumerableProperty(O, 'cause', options.cause); 2762 } 2763 }; 2764 2765 var bind$1 = functionUncurryThis(functionUncurryThis.bind); // optional / simple context binding 2766 2767 var functionBindContext = function (fn, that) { 2768 aCallable(fn); 2769 return that === undefined ? fn : bind$1 ? bind$1(fn, that) : function () 2770 /* ...args */ 2771 { 2772 return fn.apply(that, arguments); 2773 }; 2774 }; 2775 2776 var iterators = {}; 2777 2778 var ITERATOR = wellKnownSymbol('iterator'); 2779 var ArrayPrototype = Array.prototype; // check on default Array iterator 2780 2781 var isArrayIteratorMethod = function (it) { 2782 return it !== undefined && (iterators.Array === it || ArrayPrototype[ITERATOR] === it); 2783 }; 2784 2785 var TO_STRING_TAG = wellKnownSymbol('toStringTag'); 2786 var test = {}; 2787 test[TO_STRING_TAG] = 'z'; 2788 var toStringTagSupport = String(test) === '[object z]'; 2789 2790 var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag'); 2791 var Object$5 = global_1.Object; // ES3 wrong here 2792 2793 var CORRECT_ARGUMENTS = classofRaw(function () { 2794 return arguments; 2795 }()) == 'Arguments'; // fallback for IE11 Script Access Denied error 2796 2797 var tryGet = function (it, key) { 2798 try { 2799 return it[key]; 2800 } catch (error) { 2801 /* empty */ 2802 } 2803 }; // getting tag from ES6+ `Object.prototype.toString` 2804 2805 2806 var classof = toStringTagSupport ? classofRaw : function (it) { 2807 var O, tag, result; 2808 return it === undefined ? 'Undefined' : it === null ? 'Null' // @@toStringTag case 2809 : typeof (tag = tryGet(O = Object$5(it), TO_STRING_TAG$1)) == 'string' ? tag // builtinTag case 2810 : CORRECT_ARGUMENTS ? classofRaw(O) // ES3 arguments fallback 2811 : (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result; 2812 }; 2813 2814 var ITERATOR$1 = wellKnownSymbol('iterator'); 2815 2816 var getIteratorMethod = function (it) { 2817 if (it != undefined) return getMethod(it, ITERATOR$1) || getMethod(it, '@@iterator') || iterators[classof(it)]; 2818 }; 2819 2820 var TypeError$9 = global_1.TypeError; 2821 2822 var getIterator = function (argument, usingIterator) { 2823 var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator; 2824 if (aCallable(iteratorMethod)) return anObject(functionCall(iteratorMethod, argument)); 2825 throw TypeError$9(tryToString(argument) + ' is not iterable'); 2826 }; 2827 2828 var iteratorClose = function (iterator, kind, value) { 2829 var innerResult, innerError; 2830 anObject(iterator); 2831 2832 try { 2833 innerResult = getMethod(iterator, 'return'); 2834 2835 if (!innerResult) { 2836 if (kind === 'throw') throw value; 2837 return value; 2838 } 2839 2840 innerResult = functionCall(innerResult, iterator); 2841 } catch (error) { 2842 innerError = true; 2843 innerResult = error; 2844 } 2845 2846 if (kind === 'throw') throw value; 2847 if (innerError) throw innerResult; 2848 anObject(innerResult); 2849 return value; 2850 }; 2851 2852 var TypeError$a = global_1.TypeError; 2853 2854 var Result = function (stopped, result) { 2855 this.stopped = stopped; 2856 this.result = result; 2857 }; 2858 2859 var ResultPrototype = Result.prototype; 2860 2861 var iterate = function (iterable, unboundFunction, options) { 2862 var that = options && options.that; 2863 var AS_ENTRIES = !!(options && options.AS_ENTRIES); 2864 var IS_ITERATOR = !!(options && options.IS_ITERATOR); 2865 var INTERRUPTED = !!(options && options.INTERRUPTED); 2866 var fn = functionBindContext(unboundFunction, that); 2867 var iterator, iterFn, index, length, result, next, step; 2868 2869 var stop = function (condition) { 2870 if (iterator) iteratorClose(iterator, 'normal', condition); 2871 return new Result(true, condition); 2872 }; 2873 2874 var callFn = function (value) { 2875 if (AS_ENTRIES) { 2876 anObject(value); 2877 return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]); 2878 } 2879 2880 return INTERRUPTED ? fn(value, stop) : fn(value); 2881 }; 2882 2883 if (IS_ITERATOR) { 2884 iterator = iterable; 2885 } else { 2886 iterFn = getIteratorMethod(iterable); 2887 if (!iterFn) throw TypeError$a(tryToString(iterable) + ' is not iterable'); // optimisation for array iterators 2888 2889 if (isArrayIteratorMethod(iterFn)) { 2890 for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) { 2891 result = callFn(iterable[index]); 2892 if (result && objectIsPrototypeOf(ResultPrototype, result)) return result; 2893 } 2894 2895 return new Result(false); 2896 } 2897 2898 iterator = getIterator(iterable, iterFn); 2899 } 2900 2901 next = iterator.next; 2902 2903 while (!(step = functionCall(next, iterator)).done) { 2904 try { 2905 result = callFn(step.value); 2906 } catch (error) { 2907 iteratorClose(iterator, 'throw', error); 2908 } 2909 2910 if (typeof result == 'object' && result && objectIsPrototypeOf(ResultPrototype, result)) return result; 2911 } 2912 2913 return new Result(false); 2914 }; 2915 2916 var String$4 = global_1.String; 2917 2918 var toString_1 = function (argument) { 2919 if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string'); 2920 return String$4(argument); 2921 }; 2922 2923 var normalizeStringArgument = function (argument, $default) { 2924 return argument === undefined ? arguments.length < 2 ? '' : $default : toString_1(argument); 2925 }; 2926 2927 var errorStackInstallable = !fails(function () { 2928 var error = Error('a'); 2929 if (!('stack' in error)) return true; // eslint-disable-next-line es/no-object-defineproperty -- safe 2930 2931 Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7)); 2932 return error.stack !== 7; 2933 }); 2934 2935 var TO_STRING_TAG$2 = wellKnownSymbol('toStringTag'); 2936 var Error$1 = global_1.Error; 2937 var push$1 = [].push; 2938 2939 var $AggregateError = function AggregateError(errors, message 2940 /* , options */ 2941 ) { 2942 var options = arguments.length > 2 ? arguments[2] : undefined; 2943 var isInstance = objectIsPrototypeOf(AggregateErrorPrototype, this); 2944 var that; 2945 2946 if (objectSetPrototypeOf) { 2947 that = objectSetPrototypeOf(new Error$1(undefined), isInstance ? objectGetPrototypeOf(this) : AggregateErrorPrototype); 2948 } else { 2949 that = isInstance ? this : objectCreate(AggregateErrorPrototype); 2950 createNonEnumerableProperty(that, TO_STRING_TAG$2, 'Error'); 2951 } 2952 2953 createNonEnumerableProperty(that, 'message', normalizeStringArgument(message, '')); 2954 if (errorStackInstallable) createNonEnumerableProperty(that, 'stack', clearErrorStack(that.stack, 1)); 2955 installErrorCause(that, options); 2956 var errorsArray = []; 2957 iterate(errors, push$1, { 2958 that: errorsArray 2959 }); 2960 createNonEnumerableProperty(that, 'errors', errorsArray); 2961 return that; 2962 }; 2963 2964 if (objectSetPrototypeOf) objectSetPrototypeOf($AggregateError, Error$1);else copyConstructorProperties($AggregateError, Error$1); 2965 var AggregateErrorPrototype = $AggregateError.prototype = objectCreate(Error$1.prototype, { 2966 constructor: createPropertyDescriptor(1, $AggregateError), 2967 message: createPropertyDescriptor(1, ''), 2968 name: createPropertyDescriptor(1, 'AggregateError') 2969 }); // `AggregateError` constructor 2970 // https://tc39.es/ecma262/#sec-aggregate-error-constructor 2971 2972 _export({ 2973 global: true 2974 }, { 2975 AggregateError: $AggregateError 2976 }); 2977 2978 var UNSCOPABLES = wellKnownSymbol('unscopables'); 2979 var ArrayPrototype$1 = Array.prototype; // Array.prototype[@@unscopables] 2980 // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 2981 2982 if (ArrayPrototype$1[UNSCOPABLES] == undefined) { 2983 objectDefineProperty.f(ArrayPrototype$1, UNSCOPABLES, { 2984 configurable: true, 2985 value: objectCreate(null) 2986 }); 2987 } // add a key to Array.prototype[@@unscopables] 2988 2989 2990 var addToUnscopables = function (key) { 2991 ArrayPrototype$1[UNSCOPABLES][key] = true; 2992 }; 2993 2994 // `Array.prototype.at` method 2995 // https://github.com/tc39/proposal-relative-indexing-method 2996 2997 2998 _export({ 2999 target: 'Array', 3000 proto: true 3001 }, { 3002 at: function at(index) { 3003 var O = toObject(this); 3004 var len = lengthOfArrayLike(O); 3005 var relativeIndex = toIntegerOrInfinity(index); 3006 var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; 3007 return k < 0 || k >= len ? undefined : O[k]; 3008 } 3009 }); 3010 addToUnscopables('at'); 3011 3012 // `IsArray` abstract operation 3013 // https://tc39.es/ecma262/#sec-isarray 3014 // eslint-disable-next-line es/no-array-isarray -- safe 3015 3016 3017 var isArray = Array.isArray || function isArray(argument) { 3018 return classofRaw(argument) == 'Array'; 3019 }; 3020 3021 var un$Reverse = functionUncurryThis([].reverse); 3022 var test$1 = [1, 2]; // `Array.prototype.reverse` method 3023 // https://tc39.es/ecma262/#sec-array.prototype.reverse 3024 // fix for Safari 12.0 bug 3025 // https://bugs.webkit.org/show_bug.cgi?id=188794 3026 3027 _export({ 3028 target: 'Array', 3029 proto: true, 3030 forced: String(test$1) === String(test$1.reverse()) 3031 }, { 3032 reverse: function reverse() { 3033 // eslint-disable-next-line no-self-assign -- dirty hack 3034 if (isArray(this)) this.length = this.length; 3035 return un$Reverse(this); 3036 } 3037 }); 3038 3039 // eslint-disable-next-line es/no-typed-arrays -- safe 3040 var arrayBufferNative = typeof ArrayBuffer != 'undefined' && typeof DataView != 'undefined'; 3041 3042 var redefineAll = function (target, src, options) { 3043 for (var key in src) redefine(target, key, src[key], options); 3044 3045 return target; 3046 }; 3047 3048 var TypeError$b = global_1.TypeError; 3049 3050 var anInstance = function (it, Prototype) { 3051 if (objectIsPrototypeOf(Prototype, it)) return it; 3052 throw TypeError$b('Incorrect invocation'); 3053 }; 3054 3055 var RangeError = global_1.RangeError; // `ToIndex` abstract operation 3056 // https://tc39.es/ecma262/#sec-toindex 3057 3058 var toIndex = function (it) { 3059 if (it === undefined) return 0; 3060 var number = toIntegerOrInfinity(it); 3061 var length = toLength(number); 3062 if (number !== length) throw RangeError('Wrong length or index'); 3063 return length; 3064 }; 3065 3066 // IEEE754 conversions based on https://github.com/feross/ieee754 3067 3068 3069 var Array$2 = global_1.Array; 3070 var abs = Math.abs; 3071 var pow = Math.pow; 3072 var floor$1 = Math.floor; 3073 var log = Math.log; 3074 var LN2 = Math.LN2; 3075 3076 var pack = function (number, mantissaLength, bytes) { 3077 var buffer = Array$2(bytes); 3078 var exponentLength = bytes * 8 - mantissaLength - 1; 3079 var eMax = (1 << exponentLength) - 1; 3080 var eBias = eMax >> 1; 3081 var rt = mantissaLength === 23 ? pow(2, -24) - pow(2, -77) : 0; 3082 var sign = number < 0 || number === 0 && 1 / number < 0 ? 1 : 0; 3083 var index = 0; 3084 var exponent, mantissa, c; 3085 number = abs(number); // eslint-disable-next-line no-self-compare -- NaN check 3086 3087 if (number != number || number === Infinity) { 3088 // eslint-disable-next-line no-self-compare -- NaN check 3089 mantissa = number != number ? 1 : 0; 3090 exponent = eMax; 3091 } else { 3092 exponent = floor$1(log(number) / LN2); 3093 c = pow(2, -exponent); 3094 3095 if (number * c < 1) { 3096 exponent--; 3097 c *= 2; 3098 } 3099 3100 if (exponent + eBias >= 1) { 3101 number += rt / c; 3102 } else { 3103 number += rt * pow(2, 1 - eBias); 3104 } 3105 3106 if (number * c >= 2) { 3107 exponent++; 3108 c /= 2; 3109 } 3110 3111 if (exponent + eBias >= eMax) { 3112 mantissa = 0; 3113 exponent = eMax; 3114 } else if (exponent + eBias >= 1) { 3115 mantissa = (number * c - 1) * pow(2, mantissaLength); 3116 exponent = exponent + eBias; 3117 } else { 3118 mantissa = number * pow(2, eBias - 1) * pow(2, mantissaLength); 3119 exponent = 0; 3120 } 3121 } 3122 3123 while (mantissaLength >= 8) { 3124 buffer[index++] = mantissa & 255; 3125 mantissa /= 256; 3126 mantissaLength -= 8; 3127 } 3128 3129 exponent = exponent << mantissaLength | mantissa; 3130 exponentLength += mantissaLength; 3131 3132 while (exponentLength > 0) { 3133 buffer[index++] = exponent & 255; 3134 exponent /= 256; 3135 exponentLength -= 8; 3136 } 3137 3138 buffer[--index] |= sign * 128; 3139 return buffer; 3140 }; 3141 3142 var unpack = function (buffer, mantissaLength) { 3143 var bytes = buffer.length; 3144 var exponentLength = bytes * 8 - mantissaLength - 1; 3145 var eMax = (1 << exponentLength) - 1; 3146 var eBias = eMax >> 1;
vendor: 6,238 bytes, lines 3147-3361
3147 var nBits = exponentLength - 7; 3148 var index = bytes - 1; 3149 var sign = buffer[index--]; 3150 var exponent = sign & 127; 3151 var mantissa; 3152 sign >>= 7; 3153 3154 while (nBits > 0) { 3155 exponent = exponent * 256 + buffer[index--]; 3156 nBits -= 8; 3157 } 3158 3159 mantissa = exponent & (1 << -nBits) - 1; 3160 exponent >>= -nBits; 3161 nBits += mantissaLength; 3162 3163 while (nBits > 0) { 3164 mantissa = mantissa * 256 + buffer[index--]; 3165 nBits -= 8; 3166 } 3167 3168 if (exponent === 0) { 3169 exponent = 1 - eBias; 3170 } else if (exponent === eMax) { 3171 return mantissa ? NaN : sign ? -Infinity : Infinity; 3172 } else { 3173 mantissa = mantissa + pow(2, mantissaLength); 3174 exponent = exponent - eBias; 3175 } 3176 3177 return (sign ? -1 : 1) * mantissa * pow(2, exponent - mantissaLength); 3178 }; 3179 3180 var ieee754 = { 3181 pack: pack, 3182 unpack: unpack 3183 }; 3184 3185 // `Array.prototype.fill` method implementation 3186 // https://tc39.es/ecma262/#sec-array.prototype.fill 3187 3188 3189 var arrayFill = function fill(value 3190 /* , start = 0, end = @length */ 3191 ) { 3192 var O = toObject(this); 3193 var length = lengthOfArrayLike(O); 3194 var argumentsLength = arguments.length; 3195 var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length); 3196 var end = argumentsLength > 2 ? arguments[2] : undefined; 3197 var endPos = end === undefined ? length : toAbsoluteIndex(end, length); 3198 3199 while (endPos > index) O[index++] = value; 3200 3201 return O; 3202 }; 3203 3204 var defineProperty$1 = objectDefineProperty.f; 3205 3206 3207 3208 3209 3210 var TO_STRING_TAG$3 = wellKnownSymbol('toStringTag'); 3211 3212 var setToStringTag = function (it, TAG, STATIC) { 3213 if (it && !hasOwnProperty_1(it = STATIC ? it : it.prototype, TO_STRING_TAG$3)) { 3214 defineProperty$1(it, TO_STRING_TAG$3, { 3215 configurable: true, 3216 value: TAG 3217 }); 3218 } 3219 }; 3220 3221 var getOwnPropertyNames = objectGetOwnPropertyNames.f; 3222 3223 var defineProperty$2 = objectDefineProperty.f; 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 var PROPER_FUNCTION_NAME = functionName.PROPER; 3234 var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE; 3235 var getInternalState = internalState.get; 3236 var setInternalState = internalState.set; 3237 var ARRAY_BUFFER = 'ArrayBuffer'; 3238 var DATA_VIEW = 'DataView'; 3239 var PROTOTYPE$1 = 'prototype'; 3240 var WRONG_LENGTH = 'Wrong length'; 3241 var WRONG_INDEX = 'Wrong index'; 3242 var NativeArrayBuffer = global_1[ARRAY_BUFFER]; 3243 var $ArrayBuffer = NativeArrayBuffer; 3244 var ArrayBufferPrototype = $ArrayBuffer && $ArrayBuffer[PROTOTYPE$1]; 3245 var $DataView = global_1[DATA_VIEW]; 3246 var DataViewPrototype = $DataView && $DataView[PROTOTYPE$1]; 3247 var ObjectPrototype$1 = Object.prototype; 3248 var Array$3 = global_1.Array; 3249 var RangeError$1 = global_1.RangeError; 3250 var fill = functionUncurryThis(arrayFill); 3251 var reverse = functionUncurryThis([].reverse); 3252 var packIEEE754 = ieee754.pack; 3253 var unpackIEEE754 = ieee754.unpack; 3254 3255 var packInt8 = function (number) { 3256 return [number & 0xFF]; 3257 }; 3258 3259 var packInt16 = function (number) { 3260 return [number & 0xFF, number >> 8 & 0xFF]; 3261 }; 3262 3263 var packInt32 = function (number) { 3264 return [number & 0xFF, number >> 8 & 0xFF, number >> 16 & 0xFF, number >> 24 & 0xFF]; 3265 }; 3266 3267 var unpackInt32 = function (buffer) { 3268 return buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0]; 3269 }; 3270 3271 var packFloat32 = function (number) { 3272 return packIEEE754(number, 23, 4); 3273 }; 3274 3275 var packFloat64 = function (number) { 3276 return packIEEE754(number, 52, 8); 3277 }; 3278 3279 var addGetter = function (Constructor, key) { 3280 defineProperty$2(Constructor[PROTOTYPE$1], key, { 3281 get: function () { 3282 return getInternalState(this)[key]; 3283 } 3284 }); 3285 }; 3286 3287 var get$1 = function (view, count, index, isLittleEndian) { 3288 var intIndex = toIndex(index); 3289 var store = getInternalState(view); 3290 if (intIndex + count > store.byteLength) throw RangeError$1(WRONG_INDEX); 3291 var bytes = getInternalState(store.buffer).bytes; 3292 var start = intIndex + store.byteOffset; 3293 var pack = arraySliceSimple(bytes, start, start + count); 3294 return isLittleEndian ? pack : reverse(pack); 3295 }; 3296 3297 var set$1 = function (view, count, index, conversion, value, isLittleEndian) { 3298 var intIndex = toIndex(index); 3299 var store = getInternalState(view); 3300 if (intIndex + count > store.byteLength) throw RangeError$1(WRONG_INDEX); 3301 var bytes = getInternalState(store.buffer).bytes; 3302 var start = intIndex + store.byteOffset; 3303 var pack = conversion(+value); 3304 3305 for (var i = 0; i < count; i++) bytes[start + i] = pack[isLittleEndian ? i : count - i - 1]; 3306 }; 3307 3308 if (!arrayBufferNative) { 3309 $ArrayBuffer = function ArrayBuffer(length) { 3310 anInstance(this, ArrayBufferPrototype); 3311 var byteLength = toIndex(length); 3312 setInternalState(this, { 3313 bytes: fill(Array$3(byteLength), 0), 3314 byteLength: byteLength 3315 }); 3316 if (!descriptors) this.byteLength = byteLength; 3317 }; 3318 3319 ArrayBufferPrototype = $ArrayBuffer[PROTOTYPE$1]; 3320 3321 $DataView = function DataView(buffer, byteOffset, byteLength) { 3322 anInstance(this, DataViewPrototype); 3323 anInstance(buffer, ArrayBufferPrototype); 3324 var bufferLength = getInternalState(buffer).byteLength; 3325 var offset = toIntegerOrInfinity(byteOffset); 3326 if (offset < 0 || offset > bufferLength) throw RangeError$1('Wrong offset'); 3327 byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength); 3328 if (offset + byteLength > bufferLength) throw RangeError$1(WRONG_LENGTH); 3329 setInternalState(this, { 3330 buffer: buffer, 3331 byteLength: byteLength, 3332 byteOffset: offset 3333 }); 3334 3335 if (!descriptors) { 3336 this.buffer = buffer; 3337 this.byteLength = byteLength; 3338 this.byteOffset = offset; 3339 } 3340 }; 3341 3342 DataViewPrototype = $DataView[PROTOTYPE$1]; 3343 3344 if (descriptors) { 3345 addGetter($ArrayBuffer, 'byteLength'); 3346 addGetter($DataView, 'buffer'); 3347 addGetter($DataView, 'byteLength'); 3348 addGetter($DataView, 'byteOffset'); 3349 } 3350 3351 redefineAll(DataViewPrototype, { 3352 getInt8: function getInt8(byteOffset) { 3353 return get$1(this, 1, byteOffset)[0] << 24 >> 24; 3354 }, 3355 getUint8: function getUint8(byteOffset) { 3356 return get$1(this, 1, byteOffset)[0]; 3357 }, 3358 getInt16: function getInt16(byteOffset 3359 /* , littleEndian */ 3360 ) { 3361 var bytes = get$1(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined);
vendor: 5,073 bytes, lines 3362-3500
3362 return (bytes[1] << 8 | bytes[0]) << 16 >> 16; 3363 }, 3364 getUint16: function getUint16(byteOffset 3365 /* , littleEndian */ 3366 ) { 3367 var bytes = get$1(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined); 3368 return bytes[1] << 8 | bytes[0]; 3369 }, 3370 getInt32: function getInt32(byteOffset 3371 /* , littleEndian */ 3372 ) { 3373 return unpackInt32(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)); 3374 }, 3375 getUint32: function getUint32(byteOffset 3376 /* , littleEndian */ 3377 ) { 3378 return unpackInt32(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)) >>> 0; 3379 }, 3380 getFloat32: function getFloat32(byteOffset 3381 /* , littleEndian */ 3382 ) { 3383 return unpackIEEE754(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 23); 3384 }, 3385 getFloat64: function getFloat64(byteOffset 3386 /* , littleEndian */ 3387 ) { 3388 return unpackIEEE754(get$1(this, 8, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 52); 3389 }, 3390 setInt8: function setInt8(byteOffset, value) { 3391 set$1(this, 1, byteOffset, packInt8, value); 3392 }, 3393 setUint8: function setUint8(byteOffset, value) { 3394 set$1(this, 1, byteOffset, packInt8, value); 3395 }, 3396 setInt16: function setInt16(byteOffset, value 3397 /* , littleEndian */ 3398 ) { 3399 set$1(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined); 3400 }, 3401 setUint16: function setUint16(byteOffset, value 3402 /* , littleEndian */ 3403 ) { 3404 set$1(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined); 3405 }, 3406 setInt32: function setInt32(byteOffset, value 3407 /* , littleEndian */ 3408 ) { 3409 set$1(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined); 3410 }, 3411 setUint32: function setUint32(byteOffset, value 3412 /* , littleEndian */ 3413 ) { 3414 set$1(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined); 3415 }, 3416 setFloat32: function setFloat32(byteOffset, value 3417 /* , littleEndian */ 3418 ) { 3419 set$1(this, 4, byteOffset, packFloat32, value, arguments.length > 2 ? arguments[2] : undefined); 3420 }, 3421 setFloat64: function setFloat64(byteOffset, value 3422 /* , littleEndian */ 3423 ) { 3424 set$1(this, 8, byteOffset, packFloat64, value, arguments.length > 2 ? arguments[2] : undefined); 3425 } 3426 }); 3427 } else { 3428 var INCORRECT_ARRAY_BUFFER_NAME = PROPER_FUNCTION_NAME && NativeArrayBuffer.name !== ARRAY_BUFFER; 3429 /* eslint-disable no-new -- required for testing */ 3430 3431 if (!fails(function () { 3432 NativeArrayBuffer(1); 3433 }) || !fails(function () { 3434 new NativeArrayBuffer(-1); 3435 }) || fails(function () { 3436 new NativeArrayBuffer(); 3437 new NativeArrayBuffer(1.5); 3438 new NativeArrayBuffer(NaN); 3439 return INCORRECT_ARRAY_BUFFER_NAME && !CONFIGURABLE_FUNCTION_NAME; 3440 })) { 3441 /* eslint-enable no-new -- required for testing */ 3442 $ArrayBuffer = function ArrayBuffer(length) { 3443 anInstance(this, ArrayBufferPrototype); 3444 return new NativeArrayBuffer(toIndex(length)); 3445 }; 3446 3447 $ArrayBuffer[PROTOTYPE$1] = ArrayBufferPrototype; 3448 3449 for (var keys$1 = getOwnPropertyNames(NativeArrayBuffer), j = 0, key; keys$1.length > j;) { 3450 if (!((key = keys$1[j++]) in $ArrayBuffer)) { 3451 createNonEnumerableProperty($ArrayBuffer, key, NativeArrayBuffer[key]); 3452 } 3453 } 3454 3455 ArrayBufferPrototype.constructor = $ArrayBuffer; 3456 } else if (INCORRECT_ARRAY_BUFFER_NAME && CONFIGURABLE_FUNCTION_NAME) { 3457 createNonEnumerableProperty(NativeArrayBuffer, 'name', ARRAY_BUFFER); 3458 } // WebKit bug - the same parent prototype for typed arrays and data view 3459 3460 3461 if (objectSetPrototypeOf && objectGetPrototypeOf(DataViewPrototype) !== ObjectPrototype$1) { 3462 objectSetPrototypeOf(DataViewPrototype, ObjectPrototype$1); 3463 } // iOS Safari 7.x bug 3464 3465 3466 var testView = new $DataView(new $ArrayBuffer(2)); 3467 var $setInt8 = functionUncurryThis(DataViewPrototype.setInt8); 3468 testView.setInt8(0, 2147483648); 3469 testView.setInt8(1, 2147483649); 3470 if (testView.getInt8(0) || !testView.getInt8(1)) redefineAll(DataViewPrototype, { 3471 setInt8: function setInt8(byteOffset, value) { 3472 $setInt8(this, byteOffset, value << 24 >> 24); 3473 }, 3474 setUint8: function setUint8(byteOffset, value) { 3475 $setInt8(this, byteOffset, value << 24 >> 24); 3476 } 3477 }, { 3478 unsafe: true 3479 }); 3480 } 3481 3482 setToStringTag($ArrayBuffer, ARRAY_BUFFER); 3483 setToStringTag($DataView, DATA_VIEW); 3484 var arrayBuffer = { 3485 ArrayBuffer: $ArrayBuffer, 3486 DataView: $DataView 3487 }; 3488 3489 var noop = function () { 3490 /* empty */ 3491 }; 3492 3493 var empty = []; 3494 var construct = getBuiltIn('Reflect', 'construct'); 3495 var constructorRegExp = /^\s*(?:class|function)\b/; 3496 var exec = functionUncurryThis(constructorRegExp.exec); 3497 var INCORRECT_TO_STRING = !constructorRegExp.exec(noop); 3498 3499 var isConstructorModern = function (argument) { 3500 if (!isCallable(argument)) return false;
3501 3502 try { 3503 construct(noop, empty, argument); 3504 return true; 3505 } catch (error) { 3506 return false; 3507 } 3508 }; 3509 3510 var isConstructorLegacy = function (argument) { 3511 if (!isCallable(argument)) return false; 3512 3513 switch (classof(argument)) { 3514 case 'AsyncFunction': 3515 case 'GeneratorFunction': 3516 case 'AsyncGeneratorFunction': 3517 return false; 3518 // we can't check .prototype since constructors produced by .bind haven't it 3519 } 3520 3521 return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument)); 3522 }; // `IsConstructor` abstract operation 3523 // https://tc39.es/ecma262/#sec-isconstructor 3524 3525 3526 var isConstructor = !construct || fails(function () { 3527 var called; 3528 return isConstructorModern(isConstructorModern.call) || !isConstructorModern(Object) || !isConstructorModern(function () { 3529 called = true; 3530 }) || called; 3531 }) ? isConstructorLegacy : isConstructorModern; 3532 3533 var TypeError$c = global_1.TypeError; // `Assert: IsConstructor(argument) is true` 3534 3535 var aConstructor = function (argument) { 3536 if (isConstructor(argument)) return argument; 3537 throw TypeError$c(tryToString(argument) + ' is not a constructor'); 3538 }; 3539 3540 var SPECIES = wellKnownSymbol('species'); // `SpeciesConstructor` abstract operation 3541 // https://tc39.es/ecma262/#sec-speciesconstructor 3542 3543 var speciesConstructor = function (O, defaultConstructor) { 3544 var C = anObject(O).constructor; 3545 var S; 3546 return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aConstructor(S); 3547 }; 3548 3549 var ArrayBuffer$1 = arrayBuffer.ArrayBuffer; 3550 var DataView$1 = arrayBuffer.DataView; 3551 var DataViewPrototype$1 = DataView$1.prototype; 3552 var un$ArrayBufferSlice = functionUncurryThis(ArrayBuffer$1.prototype.slice); 3553 var getUint8 = functionUncurryThis(DataViewPrototype$1.getUint8); 3554 var setUint8 = functionUncurryThis(DataViewPrototype$1.setUint8); 3555 var INCORRECT_SLICE = fails(function () { 3556 return !new ArrayBuffer$1(2).slice(1, undefined).byteLength; 3557 }); // `ArrayBuffer.prototype.slice` method 3558 // https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice 3559 3560 _export({ 3561 target: 'ArrayBuffer', 3562 proto: true, 3563 unsafe: true, 3564 forced: INCORRECT_SLICE 3565 }, { 3566 slice: function slice(start, end) { 3567 if (un$ArrayBufferSlice && end === undefined) { 3568 return un$ArrayBufferSlice(anObject(this), start); // FF fix 3569 } 3570 3571 var length = anObject(this).byteLength; 3572 var first = toAbsoluteIndex(start, length); 3573 var fin = toAbsoluteIndex(end === undefined ? length : end, length); 3574 var result = new (speciesConstructor(this, ArrayBuffer$1))(toLength(fin - first)); 3575 var viewSource = new DataView$1(this); 3576 var viewTarget = new DataView$1(result); 3577 var index = 0; 3578 3579 while (first < fin) { 3580 setUint8(viewTarget, index++, getUint8(viewSource, first++)); 3581 } 3582 3583 return result; 3584 } 3585 }); 3586 3587 // `Object.fromEntries` method 3588 // https://github.com/tc39/proposal-object-from-entries 3589 3590 3591 _export({ 3592 target: 'Object', 3593 stat: true 3594 }, { 3595 fromEntries: function fromEntries(iterable) { 3596 var obj = {}; 3597 iterate(iterable, function (k, v) { 3598 createProperty(obj, k, v); 3599 }, { 3600 AS_ENTRIES: true 3601 }); 3602 return obj; 3603 } 3604 }); 3605 3606 // `Object.hasOwn` method 3607 // https://github.com/tc39/proposal-accessible-object-hasownproperty 3608 3609 3610 _export({ 3611 target: 'Object', 3612 stat: true 3613 }, { 3614 hasOwn: hasOwnProperty_1 3615 }); 3616 3617 var PromiseCapability = function (C) { 3618 var resolve, reject; 3619 this.promise = new C(function ($$resolve, $$reject) { 3620 if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor'); 3621 resolve = $$resolve; 3622 reject = $$reject; 3623 }); 3624 this.resolve = aCallable(resolve); 3625 this.reject = aCallable(reject); 3626 }; // `NewPromiseCapability` abstract operation 3627 // https://tc39.es/ecma262/#sec-newpromisecapability 3628 3629 3630 var f$5 = function (C) { 3631 return new PromiseCapability(C); 3632 }; 3633 3634 var newPromiseCapability = { 3635 f: f$5 3636 }; 3637 3638 var perform = function (exec) { 3639 try { 3640 return { 3641 error: false, 3642 value: exec() 3643 }; 3644 } catch (error) { 3645 return { 3646 error: true, 3647 value: error 3648 }; 3649 } 3650 }; 3651 3652 // `Promise.allSettled` method 3653 // https://tc39.es/ecma262/#sec-promise.allsettled 3654 3655 3656 _export({ 3657 target: 'Promise', 3658 stat: true 3659 }, { 3660 allSettled: function allSettled(iterable) { 3661 var C = this; 3662 var capability = newPromiseCapability.f(C); 3663 var resolve = capability.resolve; 3664 var reject = capability.reject; 3665 var result = perform(function () { 3666 var promiseResolve = aCallable(C.resolve); 3667 var values = []; 3668 var counter = 0; 3669 var remaining = 1; 3670 iterate(iterable, function (promise) { 3671 var index = counter++; 3672 var alreadyCalled = false;
vendor: 2,994 bytes, lines 3673-3772
3673 remaining++; 3674 functionCall(promiseResolve, C, promise).then(function (value) { 3675 if (alreadyCalled) return; 3676 alreadyCalled = true; 3677 values[index] = { 3678 status: 'fulfilled', 3679 value: value 3680 }; 3681 --remaining || resolve(values); 3682 }, function (error) { 3683 if (alreadyCalled) return; 3684 alreadyCalled = true; 3685 values[index] = { 3686 status: 'rejected', 3687 reason: error 3688 }; 3689 --remaining || resolve(values); 3690 }); 3691 }); 3692 --remaining || resolve(values); 3693 }); 3694 if (result.error) reject(result.value); 3695 return capability.promise; 3696 } 3697 }); 3698 3699 var PROMISE_ANY_ERROR = 'No one promise resolved'; // `Promise.any` method 3700 // https://tc39.es/ecma262/#sec-promise.any 3701 3702 _export({ 3703 target: 'Promise', 3704 stat: true 3705 }, { 3706 any: function any(iterable) { 3707 var C = this; 3708 var AggregateError = getBuiltIn('AggregateError'); 3709 var capability = newPromiseCapability.f(C); 3710 var resolve = capability.resolve; 3711 var reject = capability.reject; 3712 var result = perform(function () { 3713 var promiseResolve = aCallable(C.resolve); 3714 var errors = []; 3715 var counter = 0; 3716 var remaining = 1; 3717 var alreadyResolved = false; 3718 iterate(iterable, function (promise) { 3719 var index = counter++; 3720 var alreadyRejected = false; 3721 remaining++; 3722 functionCall(promiseResolve, C, promise).then(function (value) { 3723 if (alreadyRejected || alreadyResolved) return; 3724 alreadyResolved = true; 3725 resolve(value); 3726 }, function (error) { 3727 if (alreadyRejected || alreadyResolved) return; 3728 alreadyRejected = true; 3729 errors[index] = error; 3730 --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR)); 3731 }); 3732 }); 3733 --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR)); 3734 }); 3735 if (result.error) reject(result.value); 3736 return capability.promise; 3737 } 3738 }); 3739 3740 var nativePromiseConstructor = global_1.Promise; 3741 3742 var promiseResolve = function (C, x) { 3743 anObject(C); 3744 if (isObject(x) && x.constructor === C) return x; 3745 var promiseCapability = newPromiseCapability.f(C); 3746 var resolve = promiseCapability.resolve; 3747 resolve(x); 3748 return promiseCapability.promise; 3749 }; 3750 3751 // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829 3752 3753 3754 var NON_GENERIC = !!nativePromiseConstructor && fails(function () { 3755 nativePromiseConstructor.prototype['finally'].call({ 3756 then: function () { 3757 /* empty */ 3758 } 3759 }, function () { 3760 /* empty */ 3761 }); 3762 }); // `Promise.prototype.finally` method 3763 // https://tc39.es/ecma262/#sec-promise.prototype.finally 3764 3765 _export({ 3766 target: 'Promise', 3767 proto: true, 3768 real: true, 3769 forced: NON_GENERIC 3770 }, { 3771 'finally': function (onFinally) { 3772 var C = speciesConstructor(this, getBuiltIn('Promise'));
3773 var isFunction = isCallable(onFinally); 3774 return this.then(isFunction ? function (x) { 3775 return promiseResolve(C, onFinally()).then(function () { 3776 return x; 3777 }); 3778 } : onFinally, isFunction ? function (e) { 3779 return promiseResolve(C, onFinally()).then(function () { 3780 throw e; 3781 }); 3782 } : onFinally); 3783 } 3784 }); // makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then` 3785 3786 if (!isPure && isCallable(nativePromiseConstructor)) { 3787 var method = getBuiltIn('Promise').prototype['finally']; 3788 3789 if (nativePromiseConstructor.prototype['finally'] !== method) { 3790 redefine(nativePromiseConstructor.prototype, 'finally', method, { 3791 unsafe: true 3792 }); 3793 } 3794 } 3795 3796 var ITERATOR$2 = wellKnownSymbol('iterator'); 3797 var BUGGY_SAFARI_ITERATORS = false; // `%IteratorPrototype%` object 3798 // https://tc39.es/ecma262/#sec-%iteratorprototype%-object 3799 3800 var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator; 3801 /* eslint-disable es/no-array-prototype-keys -- safe */ 3802 3803 if ([].keys) { 3804 arrayIterator = [].keys(); // Safari 8 has buggy iterators w/o `next` 3805 3806 if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;else { 3807 PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator)); 3808 if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype; 3809 } 3810 } 3811 3812 var NEW_ITERATOR_PROTOTYPE = IteratorPrototype == undefined || fails(function () { 3813 var test = {}; // FF44- legacy iterators case 3814 3815 return IteratorPrototype[ITERATOR$2].call(test) !== test; 3816 }); 3817 if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {}; // `%IteratorPrototype%[@@iterator]()` method 3818 // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator 3819 3820 if (!isCallable(IteratorPrototype[ITERATOR$2])) { 3821 redefine(IteratorPrototype, ITERATOR$2, function () { 3822 return this; 3823 }); 3824 } 3825 3826 var iteratorsCore = { 3827 IteratorPrototype: IteratorPrototype, 3828 BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS 3829 }; 3830 3831 var IteratorPrototype$1 = iteratorsCore.IteratorPrototype; 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 var returnThis = function () { 3842 return this; 3843 }; 3844 3845 var createIteratorConstructor = function (IteratorConstructor, NAME, next) { 3846 var TO_STRING_TAG = NAME + ' Iterator'; 3847 IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, { 3848 next: createPropertyDescriptor(1, next) 3849 }); 3850 setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true); 3851 iterators[TO_STRING_TAG] = returnThis; 3852 return IteratorConstructor; 3853 }; 3854 3855 var MATCH = wellKnownSymbol('match'); // `IsRegExp` abstract operation 3856 // https://tc39.es/ecma262/#sec-isregexp 3857 3858 var isRegexp = function (it) { 3859 var isRegExp; 3860 return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classofRaw(it) == 'RegExp'); 3861 }; 3862 3863 // `RegExp.prototype.flags` getter implementation 3864 // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags 3865 3866 3867 var regexpFlags = function () { 3868 var that = anObject(this); 3869 var result = ''; 3870 if (that.global) result += 'g'; 3871 if (that.ignoreCase) result += 'i'; 3872 if (that.multiline) result += 'm'; 3873 if (that.dotAll) result += 's'; 3874 if (that.unicode) result += 'u'; 3875 if (that.sticky) result += 'y'; 3876 return result; 3877 }; 3878 3879 var charAt = functionUncurryThis(''.charAt); 3880 var charCodeAt = functionUncurryThis(''.charCodeAt); 3881 var stringSlice$1 = functionUncurryThis(''.slice); 3882 3883 var createMethod$1 = function (CONVERT_TO_STRING) { 3884 return function ($this, pos) { 3885 var S = toString_1(requireObjectCoercible($this)); 3886 var position = toIntegerOrInfinity(pos); 3887 var size = S.length; 3888 var first, second; 3889 if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined; 3890 first = charCodeAt(S, position); 3891 return first < 0xD800 || first > 0xDBFF || position + 1 === size || (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF ? CONVERT_TO_STRING ? charAt(S, position) : first : CONVERT_TO_STRING ? stringSlice$1(S, position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000; 3892 }; 3893 }; 3894 3895 var stringMultibyte = { 3896 // `String.prototype.codePointAt` method 3897 // https://tc39.es/ecma262/#sec-string.prototype.codepointat 3898 codeAt: createMethod$1(false), 3899 // `String.prototype.at` method 3900 // https://github.com/mathiasbynens/String.prototype.at 3901 charAt: createMethod$1(true) 3902 }; 3903 3904 var charAt$1 = stringMultibyte.charAt; // `AdvanceStringIndex` abstract operation 3905 // https://tc39.es/ecma262/#sec-advancestringindex 3906 3907 3908 var advanceStringIndex = function (S, index, unicode) { 3909 return index + (unicode ? charAt$1(S, index).length : 1); 3910 }; 3911 3912 // babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError 3913 3914 3915 var $RegExp = global_1.RegExp; 3916 var UNSUPPORTED_Y = fails(function () { 3917 var re = $RegExp('a', 'y'); 3918 re.lastIndex = 2; 3919 return re.exec('abcd') != null; 3920 }); // UC Browser bug 3921 // https://github.com/zloirock/core-js/issues/1008 3922 3923 var MISSED_STICKY = UNSUPPORTED_Y || fails(function () { 3924 return !$RegExp('a', 'y').sticky; 3925 }); 3926 var BROKEN_CARET = UNSUPPORTED_Y || fails(function () { 3927 // https://bugzilla.mozilla.org/show_bug.cgi?id=773687 3928 var re = $RegExp('^r', 'gy'); 3929 re.lastIndex = 2; 3930 return re.exec('str') != null; 3931 }); 3932 var regexpStickyHelpers = { 3933 BROKEN_CARET: BROKEN_CARET, 3934 MISSED_STICKY: MISSED_STICKY, 3935 UNSUPPORTED_Y: UNSUPPORTED_Y 3936 }; 3937 3938 // babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError 3939 3940 3941 var $RegExp$1 = global_1.RegExp; 3942 var regexpUnsupportedDotAll = fails(function () { 3943 var re = $RegExp$1('.', 's'); 3944 return !(re.dotAll && re.exec('\n') && re.flags === 's'); 3945 }); 3946 3947 // babel-minify and Closure Compiler transpiles RegExp('(?<a>b)', 'g') -> /(?<a>b)/g and it causes SyntaxError 3948 3949 3950 var $RegExp$2 = global_1.RegExp; 3951 var regexpUnsupportedNcg = fails(function () {
vendor: 5,743 bytes, lines 3952-4185
3952 var re = $RegExp$2('(?<a>b)', 'g'); 3953 return re.exec('b').groups.a !== 'b' || 'b'.replace(re, '$<a>c') !== 'bc'; 3954 }); 3955 3956 /* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */ 3957 3958 /* eslint-disable regexp/no-useless-quantifier -- testing */ 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 var getInternalState$1 = internalState.get; 3975 3976 3977 3978 3979 3980 var nativeReplace = shared('native-string-replace', String.prototype.replace); 3981 var nativeExec = RegExp.prototype.exec; 3982 var patchedExec = nativeExec; 3983 var charAt$2 = functionUncurryThis(''.charAt); 3984 var indexOf$1 = functionUncurryThis(''.indexOf); 3985 var replace$1 = functionUncurryThis(''.replace); 3986 var stringSlice$2 = functionUncurryThis(''.slice); 3987 3988 var UPDATES_LAST_INDEX_WRONG = function () { 3989 var re1 = /a/; 3990 var re2 = /b*/g; 3991 functionCall(nativeExec, re1, 'a'); 3992 functionCall(nativeExec, re2, 'a'); 3993 return re1.lastIndex !== 0 || re2.lastIndex !== 0; 3994 }(); 3995 3996 var UNSUPPORTED_Y$1 = regexpStickyHelpers.BROKEN_CARET; // nonparticipating capturing group, copied from es5-shim's String#split patch. 3997 3998 var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; 3999 var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$1 || regexpUnsupportedDotAll || regexpUnsupportedNcg; 4000 4001 if (PATCH) { 4002 patchedExec = function exec(string) { 4003 var re = this; 4004 var state = getInternalState$1(re); 4005 var str = toString_1(string); 4006 var raw = state.raw; 4007 var result, reCopy, lastIndex, match, i, object, group; 4008 4009 if (raw) { 4010 raw.lastIndex = re.lastIndex; 4011 result = functionCall(patchedExec, raw, str); 4012 re.lastIndex = raw.lastIndex; 4013 return result; 4014 } 4015 4016 var groups = state.groups; 4017 var sticky = UNSUPPORTED_Y$1 && re.sticky; 4018 var flags = functionCall(regexpFlags, re); 4019 var source = re.source; 4020 var charsAdded = 0; 4021 var strCopy = str; 4022 4023 if (sticky) { 4024 flags = replace$1(flags, 'y', ''); 4025 4026 if (indexOf$1(flags, 'g') === -1) { 4027 flags += 'g'; 4028 } 4029 4030 strCopy = stringSlice$2(str, re.lastIndex); // Support anchored sticky behavior. 4031 4032 if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$2(str, re.lastIndex - 1) !== '\n')) { 4033 source = '(?: ' + source + ')'; 4034 strCopy = ' ' + strCopy; 4035 charsAdded++; 4036 } // ^(? + rx + ) is needed, in combination with some str slicing, to 4037 // simulate the 'y' flag. 4038 4039 4040 reCopy = new RegExp('^(?:' + source + ')', flags); 4041 } 4042 4043 if (NPCG_INCLUDED) { 4044 reCopy = new RegExp('^' + source + '$(?!\\s)', flags); 4045 } 4046 4047 if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex; 4048 match = functionCall(nativeExec, sticky ? reCopy : re, strCopy); 4049 4050 if (sticky) { 4051 if (match) { 4052 match.input = stringSlice$2(match.input, charsAdded); 4053 match[0] = stringSlice$2(match[0], charsAdded); 4054 match.index = re.lastIndex; 4055 re.lastIndex += match[0].length; 4056 } else re.lastIndex = 0; 4057 } else if (UPDATES_LAST_INDEX_WRONG && match) { 4058 re.lastIndex = re.global ? match.index + match[0].length : lastIndex; 4059 } 4060 4061 if (NPCG_INCLUDED && match && match.length > 1) { 4062 // Fix browsers whose `exec` methods don't consistently return `undefined` 4063 // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/ 4064 functionCall(nativeReplace, match[0], reCopy, function () { 4065 for (i = 1; i < arguments.length - 2; i++) { 4066 if (arguments[i] === undefined) match[i] = undefined; 4067 } 4068 }); 4069 } 4070 4071 if (match && groups) { 4072 match.groups = object = objectCreate(null); 4073 4074 for (i = 0; i < groups.length; i++) { 4075 group = groups[i]; 4076 object[group[0]] = match[group[1]]; 4077 } 4078 } 4079 4080 return match; 4081 }; 4082 } 4083 4084 var regexpExec = patchedExec; 4085 4086 var TypeError$d = global_1.TypeError; // `RegExpExec` abstract operation 4087 // https://tc39.es/ecma262/#sec-regexpexec 4088 4089 var regexpExecAbstract = function (R, S) { 4090 var exec = R.exec; 4091 4092 if (isCallable(exec)) { 4093 var result = functionCall(exec, R, S); 4094 if (result !== null) anObject(result); 4095 return result; 4096 } 4097 4098 if (classofRaw(R) === 'RegExp') return functionCall(regexpExec, R, S); 4099 throw TypeError$d('RegExp#exec called on incompatible receiver'); 4100 }; 4101 4102 /* eslint-disable es/no-string-prototype-matchall -- safe */ 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 var MATCH_ALL = wellKnownSymbol('matchAll'); 4149 var REGEXP_STRING = 'RegExp String'; 4150 var REGEXP_STRING_ITERATOR = REGEXP_STRING + ' Iterator'; 4151 var setInternalState$1 = internalState.set; 4152 var getInternalState$2 = internalState.getterFor(REGEXP_STRING_ITERATOR); 4153 var RegExpPrototype = RegExp.prototype; 4154 var TypeError$e = global_1.TypeError; 4155 var getFlags = functionUncurryThis(regexpFlags); 4156 var stringIndexOf = functionUncurryThis(''.indexOf); 4157 var un$MatchAll = functionUncurryThis(''.matchAll); 4158 var WORKS_WITH_NON_GLOBAL_REGEX = !!un$MatchAll && !fails(function () { 4159 un$MatchAll('a', /./); 4160 }); 4161 var $RegExpStringIterator = createIteratorConstructor(function RegExpStringIterator(regexp, string, $global, fullUnicode) { 4162 setInternalState$1(this, { 4163 type: REGEXP_STRING_ITERATOR, 4164 regexp: regexp, 4165 string: string, 4166 global: $global, 4167 unicode: fullUnicode, 4168 done: false 4169 }); 4170 }, REGEXP_STRING, function next() { 4171 var state = getInternalState$2(this); 4172 if (state.done) return { 4173 value: undefined, 4174 done: true 4175 }; 4176 var R = state.regexp; 4177 var S = state.string; 4178 var match = regexpExecAbstract(R, S); 4179 if (match === null) return { 4180 value: undefined, 4181 done: state.done = true 4182 }; 4183 4184 if (state.global) { 4185 if (toString_1(match[0]) === '') R.lastIndex = advanceStringIndex(S, toLe
4185ngth(R.lastIndex), state.unicode); 4186 return { 4187 value: match, 4188 done: false 4189 }; 4190 } 4191 4192 state.done = true; 4193 return { 4194 value: match, 4195 done: false 4196 }; 4197 }); 4198 4199 var $matchAll = function (string) { 4200 var R = anObject(this); 4201 var S = toString_1(string); 4202 var C, flagsValue, flags, matcher, $global, fullUnicode; 4203 C = speciesConstructor(R, RegExp); 4204 flagsValue = R.flags; 4205 4206 if (flagsValue === undefined && objectIsPrototypeOf(RegExpPrototype, R) && !('flags' in RegExpPrototype)) { 4207 flagsValue = getFlags(R); 4208 } 4209 4210 flags = flagsValue === undefined ? '' : toString_1(flagsValue); 4211 matcher = new C(C === RegExp ? R.source : R, flags); 4212 $global = !!~stringIndexOf(flags, 'g'); 4213 fullUnicode = !!~stringIndexOf(flags, 'u'); 4214 matcher.lastIndex = toLength(R.lastIndex); 4215 return new $RegExpStringIterator(matcher, S, $global, fullUnicode); 4216 }; // `String.prototype.matchAll` method 4217 // https://tc39.es/ecma262/#sec-string.prototype.matchall 4218 4219 4220 _export({ 4221 target: 'String', 4222 proto: true, 4223 forced: WORKS_WITH_NON_GLOBAL_REGEX 4224 }, { 4225 matchAll: function matchAll(regexp) { 4226 var O = requireObjectCoercible(this); 4227 var flags, S, matcher, rx; 4228 4229 if (regexp != null) { 4230 if (isRegexp(regexp)) { 4231 flags = toString_1(requireObjectCoercible('flags' in RegExpPrototype ? regexp.flags : getFlags(regexp))); 4232 if (!~stringIndexOf(flags, 'g')) throw TypeError$e('`.matchAll` does not allow non-global regexes'); 4233 } 4234 4235 if (WORKS_WITH_NON_GLOBAL_REGEX) return un$MatchAll(O, regexp); 4236 matcher = getMethod(regexp, MATCH_ALL); 4237 if (matcher === undefined && isPure && classofRaw(regexp) == 'RegExp') matcher = $matchAll; 4238 if (matcher) return functionCall(matcher, regexp, O); 4239 } else if (WORKS_WITH_NON_GLOBAL_REGEX) return un$MatchAll(O, regexp); 4240 4241 S = toString_1(O); 4242 rx = new RegExp(regexp, 'g'); 4243 return isPure ? functionCall($matchAll, rx, S) : rx[MATCH_ALL](S); 4244 } 4245 }); 4246 isPure || MATCH_ALL in RegExpPrototype || redefine(RegExpPrototype, MATCH_ALL, $matchAll); 4247 4248 var floor$2 = Math.floor; 4249 var charAt$3 = functionUncurryThis(''.charAt); 4250 var replace$2 = functionUncurryThis(''.replace); 4251 var stringSlice$3 = functionUncurryThis(''.slice); 4252 var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g; 4253 var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g; // `GetSubstitution` abstract operation 4254 // https://tc39.es/ecma262/#sec-getsubstitution 4255 4256 var getSubstitution = function (matched, str, position, captures, namedCaptures, replacement) { 4257 var tailPos = position + matched.length; 4258 var m = captures.length; 4259 var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED; 4260 4261 if (namedCaptures !== undefined) { 4262 namedCaptures = toObject(namedCaptures); 4263 symbols = SUBSTITUTION_SYMBOLS; 4264 } 4265 4266 return replace$2(replacement, symbols, function (match, ch) { 4267 var capture; 4268 4269 switch (charAt$3(ch, 0)) { 4270 case '$': 4271 return '$'; 4272 4273 case '&': 4274 return matched; 4275 4276 case '`': 4277 return stringSlice$3(str, 0, position); 4278 4279 case "'": 4280 return stringSlice$3(str, tailPos); 4281 4282 case '<': 4283 capture = namedCaptures[stringSlice$3(ch, 1, -1)]; 4284 break; 4285 4286 default: 4287 // \d\d? 4288 var n = +ch; 4289 if (n === 0) return match; 4290 4291 if (n > m) { 4292 var f = floor$2(n / 10); 4293 if (f === 0) return match; 4294 if (f <= m) return captures[f - 1] === undefined ? charAt$3(ch, 1) : captures[f - 1] + charAt$3(ch, 1); 4295 return match; 4296 } 4297 4298 capture = captures[n - 1]; 4299 } 4300 4301 return capture === undefined ? '' : capture; 4302 }); 4303 }; 4304 4305 var REPLACE = wellKnownSymbol('replace'); 4306 var RegExpPrototype$1 = RegExp.prototype; 4307 var TypeError$f = global_1.TypeError; 4308 var getFlags$1 = functionUncurryThis(regexpFlags); 4309 var indexOf$2 = functionUncurryThis(''.indexOf); 4310 var replace$3 = functionUncurryThis(''.replace); 4311 var stringSlice$4 = functionUncurryThis(''.slice); 4312 var max$2 = Math.max; 4313 4314 var stringIndexOf$1 = function (string, searchValue, fromIndex) { 4315 if (fromIndex > string.length) return -1; 4316 if (searchValue === '') return fromIndex; 4317 return indexOf$2(string, searchValue, fromIndex); 4318 }; // `String.prototype.replaceAll` method 4319 // https://tc39.es/ecma262/#sec-string.prototype.replaceall 4320 4321 4322 _export({ 4323 target: 'String', 4324 proto: true 4325 }, { 4326 replaceAll: function replaceAll(searchValue, replaceValue) { 4327 var O = requireObjectCoercible(this); 4328 var IS_REG_EXP, flags, replacer, string, searchString, functionalReplace, searchLength, advanceBy, replacement; 4329 var position = 0; 4330 var endOfLastMatch = 0; 4331 var result = ''; 4332 4333 if (searchValue != null) { 4334 IS_REG_EXP = isRegexp(searchValue); 4335 4336 if (IS_REG_EXP) { 4337 flags = toString_1(requireObjectCoercible('flags' in RegExpPrototype$1 ? searchValue.flags : getFlags$1(searchValue))); 4338 if (!~indexOf$2(flags, 'g')) throw TypeError$f('`.replaceAll` does not allow non-global regexes'); 4339 } 4340 4341 replacer = getMethod(searchValue, REPLACE); 4342 4343 if (replacer) { 4344 return functionCall(replacer, searchValue, O, replaceValue); 4345 } else if (isPure && IS_REG_EXP) { 4346 return replace$3(toString_1(O), searchValue, replaceValue); 4347 } 4348 } 4349 4350 string = toString_1(O); 4351 searchString = toString_1(searchValue); 4352 functionalReplace = isCallable(replaceValue); 4353 if (!functionalReplace) replaceValue = toString_1(replaceValue); 4354 searchLength = searchString.length; 4355 advanceBy = max$2(1, searchLength); 4356 position = stringIndexOf$1(string, searchString, 0); 4357 4358 while (position !== -1) { 4359 replacement = functionalReplace ? toString_1(replaceValue(searchString, position, string)) : getSubstitution(searchString, string, position, [], undefined, replaceValue); 4360 result += stringSlice$4(string, endOfLastMatch, position) + replacement; 4361 endOfLastMatch = position + searchLength; 4362 position = stringIndexOf$1(string, searchString, position + advanceBy); 4363 } 4364 4365 if (endOfLastMatch < string.length) { 4366 result += stringSlice$4(string, endOfLastMatch); 4367 } 4368 4369 return result; 4370 } 4371 }); 4372 4373 var ITERATOR$3 = wellKnownSymbol('iterator'); 4374 var SAFE_CLOSING = false;
vendor: 4,474 bytes, lines 4375-4518
4375 4376 var checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) { 4377 if (!SKIP_CLOSING && !SAFE_CLOSING) return false; 4378 var ITERATION_SUPPORT = false; 4379 4380 try { 4381 var object = {}; 4382 4383 object[ITERATOR$3] = function () { 4384 return { 4385 next: function () { 4386 return { 4387 done: ITERATION_SUPPORT = true 4388 }; 4389 } 4390 }; 4391 }; 4392 4393 exec(object); 4394 } catch (error) { 4395 /* empty */ 4396 } 4397 4398 return ITERATION_SUPPORT; 4399 }; 4400 4401 var defineProperty$3 = objectDefineProperty.f; 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 var Int8Array = global_1.Int8Array; 4414 var Int8ArrayPrototype = Int8Array && Int8Array.prototype; 4415 var Uint8ClampedArray = global_1.Uint8ClampedArray; 4416 var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype; 4417 var TypedArray = Int8Array && objectGetPrototypeOf(Int8Array); 4418 var TypedArrayPrototype = Int8ArrayPrototype && objectGetPrototypeOf(Int8ArrayPrototype); 4419 var ObjectPrototype$2 = Object.prototype; 4420 var TypeError$g = global_1.TypeError; 4421 var TO_STRING_TAG$4 = wellKnownSymbol('toStringTag'); 4422 var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG'); 4423 var TYPED_ARRAY_CONSTRUCTOR = uid('TYPED_ARRAY_CONSTRUCTOR'); // Fixing native typed arrays in Opera Presto crashes the browser, see #595 4424 4425 var NATIVE_ARRAY_BUFFER_VIEWS = arrayBufferNative && !!objectSetPrototypeOf && classof(global_1.opera) !== 'Opera'; 4426 var TYPED_ARRAY_TAG_REQIRED = false; 4427 var NAME, Constructor, Prototype; 4428 var TypedArrayConstructorsList = { 4429 Int8Array: 1, 4430 Uint8Array: 1, 4431 Uint8ClampedArray: 1, 4432 Int16Array: 2, 4433 Uint16Array: 2, 4434 Int32Array: 4, 4435 Uint32Array: 4, 4436 Float32Array: 4, 4437 Float64Array: 8 4438 }; 4439 var BigIntArrayConstructorsList = { 4440 BigInt64Array: 8, 4441 BigUint64Array: 8 4442 }; 4443 4444 var isView = function isView(it) { 4445 if (!isObject(it)) return false; 4446 var klass = classof(it); 4447 return klass === 'DataView' || hasOwnProperty_1(TypedArrayConstructorsList, klass) || hasOwnProperty_1(BigIntArrayConstructorsList, klass); 4448 }; 4449 4450 var isTypedArray = function (it) { 4451 if (!isObject(it)) return false; 4452 var klass = classof(it); 4453 return hasOwnProperty_1(TypedArrayConstructorsList, klass) || hasOwnProperty_1(BigIntArrayConstructorsList, klass); 4454 }; 4455 4456 var aTypedArray = function (it) { 4457 if (isTypedArray(it)) return it; 4458 throw TypeError$g('Target is not a typed array'); 4459 }; 4460 4461 var aTypedArrayConstructor = function (C) { 4462 if (isCallable(C) && (!objectSetPrototypeOf || objectIsPrototypeOf(TypedArray, C))) return C; 4463 throw TypeError$g(tryToString(C) + ' is not a typed array constructor'); 4464 }; 4465 4466 var exportTypedArrayMethod = function (KEY, property, forced) { 4467 if (!descriptors) return; 4468 if (forced) for (var ARRAY in TypedArrayConstructorsList) { 4469 var TypedArrayConstructor = global_1[ARRAY]; 4470 if (TypedArrayConstructor && hasOwnProperty_1(TypedArrayConstructor.prototype, KEY)) try { 4471 delete TypedArrayConstructor.prototype[KEY]; 4472 } catch (error) { 4473 /* empty */ 4474 } 4475 } 4476 4477 if (!TypedArrayPrototype[KEY] || forced) { 4478 redefine(TypedArrayPrototype, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property); 4479 } 4480 }; 4481 4482 var exportTypedArrayStaticMethod = function (KEY, property, forced) { 4483 var ARRAY, TypedArrayConstructor; 4484 if (!descriptors) return; 4485 4486 if (objectSetPrototypeOf) { 4487 if (forced) for (ARRAY in TypedArrayConstructorsList) { 4488 TypedArrayConstructor = global_1[ARRAY]; 4489 if (TypedArrayConstructor && hasOwnProperty_1(TypedArrayConstructor, KEY)) try { 4490 delete TypedArrayConstructor[KEY]; 4491 } catch (error) { 4492 /* empty */ 4493 } 4494 } 4495 4496 if (!TypedArray[KEY] || forced) { 4497 // V8 ~ Chrome 49-50 `%TypedArray%` methods are non-writable non-configurable 4498 try { 4499 return redefine(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && TypedArray[KEY] || property); 4500 } catch (error) { 4501 /* empty */ 4502 } 4503 } else return; 4504 } 4505 4506 for (ARRAY in TypedArrayConstructorsList) { 4507 TypedArrayConstructor = global_1[ARRAY]; 4508 4509 if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) { 4510 redefine(TypedArrayConstructor, KEY, property); 4511 } 4512 } 4513 }; 4514 4515 for (NAME in TypedArrayConstructorsList) { 4516 Constructor = global_1[NAME]; 4517 Prototype = Constructor && Constructor.prototype; 4518 if (Prototype) createNonEnumerableProperty(Prototype, TYPED_ARRAY_CONSTRUCTOR, Constructor);else NATIVE_ARRAY_BUFFER_VIEWS = false;
vendor: 5,622 bytes, lines 4519-4691
4519 } 4520 4521 for (NAME in BigIntArrayConstructorsList) { 4522 Constructor = global_1[NAME]; 4523 Prototype = Constructor && Constructor.prototype; 4524 if (Prototype) createNonEnumerableProperty(Prototype, TYPED_ARRAY_CONSTRUCTOR, Constructor); 4525 } // WebKit bug - typed arrays constructors prototype is Object.prototype 4526 4527 4528 if (!NATIVE_ARRAY_BUFFER_VIEWS || !isCallable(TypedArray) || TypedArray === Function.prototype) { 4529 // eslint-disable-next-line no-shadow -- safe 4530 TypedArray = function TypedArray() { 4531 throw TypeError$g('Incorrect invocation'); 4532 }; 4533 4534 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { 4535 if (global_1[NAME]) objectSetPrototypeOf(global_1[NAME], TypedArray); 4536 } 4537 } 4538 4539 if (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype$2) { 4540 TypedArrayPrototype = TypedArray.prototype; 4541 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { 4542 if (global_1[NAME]) objectSetPrototypeOf(global_1[NAME].prototype, TypedArrayPrototype); 4543 } 4544 } // WebKit bug - one more object in Uint8ClampedArray prototype chain 4545 4546 4547 if (NATIVE_ARRAY_BUFFER_VIEWS && objectGetPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) { 4548 objectSetPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype); 4549 } 4550 4551 if (descriptors && !hasOwnProperty_1(TypedArrayPrototype, TO_STRING_TAG$4)) { 4552 TYPED_ARRAY_TAG_REQIRED = true; 4553 defineProperty$3(TypedArrayPrototype, TO_STRING_TAG$4, { 4554 get: function () { 4555 return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined; 4556 } 4557 }); 4558 4559 for (NAME in TypedArrayConstructorsList) if (global_1[NAME]) { 4560 createNonEnumerableProperty(global_1[NAME], TYPED_ARRAY_TAG, NAME); 4561 } 4562 } 4563 4564 var arrayBufferViewCore = { 4565 NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS, 4566 TYPED_ARRAY_CONSTRUCTOR: TYPED_ARRAY_CONSTRUCTOR, 4567 TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQIRED && TYPED_ARRAY_TAG, 4568 aTypedArray: aTypedArray, 4569 aTypedArrayConstructor: aTypedArrayConstructor, 4570 exportTypedArrayMethod: exportTypedArrayMethod, 4571 exportTypedArrayStaticMethod: exportTypedArrayStaticMethod, 4572 isView: isView, 4573 isTypedArray: isTypedArray, 4574 TypedArray: TypedArray, 4575 TypedArrayPrototype: TypedArrayPrototype 4576 }; 4577 4578 /* eslint-disable no-new -- required for testing */ 4579 4580 4581 4582 4583 4584 4585 var NATIVE_ARRAY_BUFFER_VIEWS$1 = arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; 4586 4587 var ArrayBuffer$2 = global_1.ArrayBuffer; 4588 var Int8Array$1 = global_1.Int8Array; 4589 var typedArrayConstructorsRequireWrappers = !NATIVE_ARRAY_BUFFER_VIEWS$1 || !fails(function () { 4590 Int8Array$1(1); 4591 }) || !fails(function () { 4592 new Int8Array$1(-1); 4593 }) || !checkCorrectnessOfIteration(function (iterable) { 4594 new Int8Array$1(); 4595 new Int8Array$1(null); 4596 new Int8Array$1(1.5); 4597 new Int8Array$1(iterable); 4598 }, true) || fails(function () { 4599 // Safari (11+) bug - a reason why even Safari 13 should load a typed array polyfill 4600 return new Int8Array$1(new ArrayBuffer$2(2), 1, undefined).length !== 1; 4601 }); 4602 4603 var floor$3 = Math.floor; // `IsIntegralNumber` abstract operation 4604 // https://tc39.es/ecma262/#sec-isintegralnumber 4605 // eslint-disable-next-line es/no-number-isinteger -- safe 4606 4607 var isIntegralNumber = Number.isInteger || function isInteger(it) { 4608 return !isObject(it) && isFinite(it) && floor$3(it) === it; 4609 }; 4610 4611 var RangeError$2 = global_1.RangeError; 4612 4613 var toPositiveInteger = function (it) { 4614 var result = toIntegerOrInfinity(it); 4615 if (result < 0) throw RangeError$2("The argument can't be less than 0"); 4616 return result; 4617 }; 4618 4619 var RangeError$3 = global_1.RangeError; 4620 4621 var toOffset = function (it, BYTES) { 4622 var offset = toPositiveInteger(it); 4623 if (offset % BYTES) throw RangeError$3('Wrong offset'); 4624 return offset; 4625 }; 4626 4627 var aTypedArrayConstructor$1 = arrayBufferViewCore.aTypedArrayConstructor; 4628 4629 var typedArrayFrom = function from(source 4630 /* , mapfn, thisArg */ 4631 ) { 4632 var C = aConstructor(this); 4633 var O = toObject(source); 4634 var argumentsLength = arguments.length; 4635 var mapfn = argumentsLength > 1 ? arguments[1] : undefined; 4636 var mapping = mapfn !== undefined; 4637 var iteratorMethod = getIteratorMethod(O); 4638 var i, length, result, step, iterator, next; 4639 4640 if (iteratorMethod && !isArrayIteratorMethod(iteratorMethod)) { 4641 iterator = getIterator(O, iteratorMethod); 4642 next = iterator.next; 4643 O = []; 4644 4645 while (!(step = functionCall(next, iterator)).done) { 4646 O.push(step.value); 4647 } 4648 } 4649 4650 if (mapping && argumentsLength > 2) { 4651 mapfn = functionBindContext(mapfn, arguments[2]); 4652 } 4653 4654 length = lengthOfArrayLike(O); 4655 result = new (aTypedArrayConstructor$1(C))(length); 4656 4657 for (i = 0; length > i; i++) { 4658 result[i] = mapping ? mapfn(O[i], i) : O[i]; 4659 } 4660 4661 return result; 4662 }; 4663 4664 var SPECIES$1 = wellKnownSymbol('species'); 4665 var Array$4 = global_1.Array; // a part of `ArraySpeciesCreate` abstract operation 4666 // https://tc39.es/ecma262/#sec-arrayspeciescreate 4667 4668 var arraySpeciesConstructor = function (originalArray) { 4669 var C; 4670 4671 if (isArray(originalArray)) { 4672 C = originalArray.constructor; // cross-realm fallback 4673 4674 if (isConstructor(C) && (C === Array$4 || isArray(C.prototype))) C = undefined;else if (isObject(C)) { 4675 C = C[SPECIES$1]; 4676 if (C === null) C = undefined; 4677 } 4678 } 4679 4680 return C === undefined ? Array$4 : C; 4681 }; 4682 4683 // `ArraySpeciesCreate` abstract operation 4684 // https://tc39.es/ecma262/#sec-arrayspeciescreate 4685 4686 4687 var arraySpeciesCreate = function (originalArray, length) { 4688 return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length); 4689 }; 4690 4691 var push$2 = functionUncurryThis([].push);
4691 // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation 4692 4693 var createMethod$2 = function (TYPE) { 4694 var IS_MAP = TYPE == 1; 4695 var IS_FILTER = TYPE == 2; 4696 var IS_SOME = TYPE == 3; 4697 var IS_EVERY = TYPE == 4; 4698 var IS_FIND_INDEX = TYPE == 6; 4699 var IS_FILTER_REJECT = TYPE == 7; 4700 var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; 4701 return function ($this, callbackfn, that, specificCreate) { 4702 var O = toObject($this); 4703 var self = indexedObject(O); 4704 var boundFunction = functionBindContext(callbackfn, that); 4705 var length = lengthOfArrayLike(self); 4706 var index = 0; 4707 var create = specificCreate || arraySpeciesCreate; 4708 var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined; 4709 var value, result; 4710 4711 for (; length > index; index++) if (NO_HOLES || index in self) { 4712 value = self[index]; 4713 result = boundFunction(value, index, O); 4714 4715 if (TYPE) { 4716 if (IS_MAP) target[index] = result; // map 4717 else if (result) switch (TYPE) { 4718 case 3: 4719 return true; 4720 // some 4721 4722 case 5: 4723 return value; 4724 // find 4725 4726 case 6: 4727 return index; 4728 // findIndex 4729 4730 case 2: 4731 push$2(target, value); 4732 // filter 4733 } else switch (TYPE) { 4734 case 4: 4735 return false; 4736 // every 4737 4738 case 7: 4739 push$2(target, value); 4740 // filterReject 4741 } 4742 } 4743 } 4744 4745 return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target; 4746 }; 4747 }; 4748 4749 var arrayIteration = { 4750 // `Array.prototype.forEach` method 4751 // https://tc39.es/ecma262/#sec-array.prototype.foreach 4752 forEach: createMethod$2(0), 4753 // `Array.prototype.map` method 4754 // https://tc39.es/ecma262/#sec-array.prototype.map 4755 map: createMethod$2(1), 4756 // `Array.prototype.filter` method 4757 // https://tc39.es/ecma262/#sec-array.prototype.filter 4758 filter: createMethod$2(2), 4759 // `Array.prototype.some` method 4760 // https://tc39.es/ecma262/#sec-array.prototype.some 4761 some: createMethod$2(3), 4762 // `Array.prototype.every` method 4763 // https://tc39.es/ecma262/#sec-array.prototype.every 4764 every: createMethod$2(4), 4765 // `Array.prototype.find` method 4766 // https://tc39.es/ecma262/#sec-array.prototype.find 4767 find: createMethod$2(5), 4768 // `Array.prototype.findIndex` method 4769 // https://tc39.es/ecma262/#sec-array.prototype.findIndex 4770 findIndex: createMethod$2(6), 4771 // `Array.prototype.filterReject` method 4772 // https://github.com/tc39/proposal-array-filtering 4773 filterReject: createMethod$2(7) 4774 }; 4775 4776 var SPECIES$2 = wellKnownSymbol('species'); 4777 4778 var setSpecies = function (CONSTRUCTOR_NAME) { 4779 var Constructor = getBuiltIn(CONSTRUCTOR_NAME); 4780 var defineProperty = objectDefineProperty.f; 4781 4782 if (descriptors && Constructor && !Constructor[SPECIES$2]) { 4783 defineProperty(Constructor, SPECIES$2, { 4784 configurable: true, 4785 get: function () { 4786 return this; 4787 } 4788 }); 4789 } 4790 }; 4791 4792 // makes subclassing work correct for wrapped built-ins 4793 4794 4795 var inheritIfRequired = function ($this, dummy, Wrapper) { 4796 var NewTarget, NewTargetPrototype; 4797 if ( // it can work only with native `setPrototypeOf` 4798 objectSetPrototypeOf && // we haven't completely correct pre-ES6 way for getting `new.target`, so use this 4799 isCallable(NewTarget = dummy.constructor) && NewTarget !== Wrapper && isObject(NewTargetPrototype = NewTarget.prototype) && NewTargetPrototype !== Wrapper.prototype) objectSetPrototypeOf($this, NewTargetPrototype); 4800 return $this; 4801 }; 4802 4803 var typedArrayConstructor = createCommonjsModule(function (module) { 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 var getOwnPropertyNames = objectGetOwnPropertyNames.f; 4850 4851 4852
vendor: 7,113 bytes, lines 4853-5035
4853 var forEach = arrayIteration.forEach; 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 var getInternalState = internalState.get; 4866 var setInternalState = internalState.set; 4867 var nativeDefineProperty = objectDefineProperty.f; 4868 var nativeGetOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; 4869 var round = Math.round; 4870 var RangeError = global_1.RangeError; 4871 var ArrayBuffer = arrayBuffer.ArrayBuffer; 4872 var ArrayBufferPrototype = ArrayBuffer.prototype; 4873 var DataView = arrayBuffer.DataView; 4874 var NATIVE_ARRAY_BUFFER_VIEWS = arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; 4875 var TYPED_ARRAY_CONSTRUCTOR = arrayBufferViewCore.TYPED_ARRAY_CONSTRUCTOR; 4876 var TYPED_ARRAY_TAG = arrayBufferViewCore.TYPED_ARRAY_TAG; 4877 var TypedArray = arrayBufferViewCore.TypedArray; 4878 var TypedArrayPrototype = arrayBufferViewCore.TypedArrayPrototype; 4879 var aTypedArrayConstructor = arrayBufferViewCore.aTypedArrayConstructor; 4880 var isTypedArray = arrayBufferViewCore.isTypedArray; 4881 var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT'; 4882 var WRONG_LENGTH = 'Wrong length'; 4883 4884 var fromList = function (C, list) { 4885 aTypedArrayConstructor(C); 4886 var index = 0; 4887 var length = list.length; 4888 var result = new C(length); 4889 4890 while (length > index) result[index] = list[index++]; 4891 4892 return result; 4893 }; 4894 4895 var addGetter = function (it, key) { 4896 nativeDefineProperty(it, key, { 4897 get: function () { 4898 return getInternalState(this)[key]; 4899 } 4900 }); 4901 }; 4902 4903 var isArrayBuffer = function (it) { 4904 var klass; 4905 return objectIsPrototypeOf(ArrayBufferPrototype, it) || (klass = classof(it)) == 'ArrayBuffer' || klass == 'SharedArrayBuffer'; 4906 }; 4907 4908 var isTypedArrayIndex = function (target, key) { 4909 return isTypedArray(target) && !isSymbol(key) && key in target && isIntegralNumber(+key) && key >= 0; 4910 }; 4911 4912 var wrappedGetOwnPropertyDescriptor = function getOwnPropertyDescriptor(target, key) { 4913 key = toPropertyKey(key); 4914 return isTypedArrayIndex(target, key) ? createPropertyDescriptor(2, target[key]) : nativeGetOwnPropertyDescriptor(target, key); 4915 }; 4916 4917 var wrappedDefineProperty = function defineProperty(target, key, descriptor) { 4918 key = toPropertyKey(key); 4919 4920 if (isTypedArrayIndex(target, key) && isObject(descriptor) && hasOwnProperty_1(descriptor, 'value') && !hasOwnProperty_1(descriptor, 'get') && !hasOwnProperty_1(descriptor, 'set') // TODO: add validation descriptor w/o calling accessors 4921 && !descriptor.configurable && (!hasOwnProperty_1(descriptor, 'writable') || descriptor.writable) && (!hasOwnProperty_1(descriptor, 'enumerable') || descriptor.enumerable)) { 4922 target[key] = descriptor.value; 4923 return target; 4924 } 4925 4926 return nativeDefineProperty(target, key, descriptor); 4927 }; 4928 4929 if (descriptors) { 4930 if (!NATIVE_ARRAY_BUFFER_VIEWS) { 4931 objectGetOwnPropertyDescriptor.f = wrappedGetOwnPropertyDescriptor; 4932 objectDefineProperty.f = wrappedDefineProperty; 4933 addGetter(TypedArrayPrototype, 'buffer'); 4934 addGetter(TypedArrayPrototype, 'byteOffset'); 4935 addGetter(TypedArrayPrototype, 'byteLength'); 4936 addGetter(TypedArrayPrototype, 'length'); 4937 } 4938 4939 _export({ 4940 target: 'Object', 4941 stat: true, 4942 forced: !NATIVE_ARRAY_BUFFER_VIEWS 4943 }, { 4944 getOwnPropertyDescriptor: wrappedGetOwnPropertyDescriptor, 4945 defineProperty: wrappedDefineProperty 4946 }); 4947 4948 module.exports = function (TYPE, wrapper, CLAMPED) { 4949 var BYTES = TYPE.match(/\d+$/)[0] / 8; 4950 var CONSTRUCTOR_NAME = TYPE + (CLAMPED ? 'Clamped' : '') + 'Array'; 4951 var GETTER = 'get' + TYPE; 4952 var SETTER = 'set' + TYPE; 4953 var NativeTypedArrayConstructor = global_1[CONSTRUCTOR_NAME]; 4954 var TypedArrayConstructor = NativeTypedArrayConstructor; 4955 var TypedArrayConstructorPrototype = TypedArrayConstructor && TypedArrayConstructor.prototype; 4956 var exported = {}; 4957 4958 var getter = function (that, index) { 4959 var data = getInternalState(that); 4960 return data.view[GETTER](index * BYTES + data.byteOffset, true); 4961 }; 4962 4963 var setter = function (that, index, value) { 4964 var data = getInternalState(that); 4965 if (CLAMPED) value = (value = round(value)) < 0 ? 0 : value > 0xFF ? 0xFF : value & 0xFF; 4966 data.view[SETTER](index * BYTES + data.byteOffset, value, true); 4967 }; 4968 4969 var addElement = function (that, index) { 4970 nativeDefineProperty(that, index, { 4971 get: function () { 4972 return getter(this, index); 4973 }, 4974 set: function (value) { 4975 return setter(this, index, value); 4976 }, 4977 enumerable: true 4978 }); 4979 }; 4980 4981 if (!NATIVE_ARRAY_BUFFER_VIEWS) { 4982 TypedArrayConstructor = wrapper(function (that, data, offset, $length) { 4983 anInstance(that, TypedArrayConstructorPrototype); 4984 var index = 0; 4985 var byteOffset = 0; 4986 var buffer, byteLength, length; 4987 4988 if (!isObject(data)) { 4989 length = toIndex(data); 4990 byteLength = length * BYTES; 4991 buffer = new ArrayBuffer(byteLength); 4992 } else if (isArrayBuffer(data)) { 4993 buffer = data; 4994 byteOffset = toOffset(offset, BYTES); 4995 var $len = data.byteLength; 4996 4997 if ($length === undefined) { 4998 if ($len % BYTES) throw RangeError(WRONG_LENGTH); 4999 byteLength = $len - byteOffset; 5000 if (byteLength < 0) throw RangeError(WRONG_LENGTH); 5001 } else { 5002 byteLength = toLength($length) * BYTES; 5003 if (byteLength + byteOffset > $len) throw RangeError(WRONG_LENGTH); 5004 } 5005 5006 length = byteLength / BYTES; 5007 } else if (isTypedArray(data)) { 5008 return fromList(TypedArrayConstructor, data); 5009 } else { 5010 return functionCall(typedArrayFrom, TypedArrayConstructor, data); 5011 } 5012 5013 setInternalState(that, { 5014 buffer: buffer, 5015 byteOffset: byteOffset, 5016 byteLength: byteLength, 5017 length: length, 5018 view: new DataView(buffer) 5019 }); 5020 5021 while (index < length) addElement(that, index++); 5022 }); 5023 if (objectSetPrototypeOf) objectSetPrototypeOf(TypedArrayConstructor, TypedArray); 5024 TypedArrayConstructorPrototype = TypedArrayConstructor.prototype = objectCreate(TypedArrayPrototype); 5025 } else if (typedArrayConstructorsRequireWrappers) { 5026 TypedArrayConstructor = wrapper(function (dummy, data, typedArrayOffset, $length) { 5027 anInstance(dummy, TypedArrayConstructorPrototype); 5028 return inheritIfRequired(function () { 5029 if (!isObject(data)) return new NativeTypedArrayConstructor(toIndex(data)); 5030 if (isArrayBuffer(data)) return $length !== undefined ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES), $length) : typedArrayOffset !== undefined ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES)) : new NativeTypedArrayConstructor(data); 5031 if (isTypedArray(data)) return fromList(TypedArrayConstructor, data); 5032 return functionCall(typedArrayFrom, TypedArrayConstructor, data); 5033 }(), dummy, TypedArrayConstructor); 5034 }); 5035 if (objectSetPrototypeOf) objectSetPrototypeOf(TypedArrayConstructor, TypedArray);
5036 forEach(getOwnPropertyNames(NativeTypedArrayConstructor), function (key) { 5037 if (!(key in TypedArrayConstructor)) { 5038 createNonEnumerableProperty(TypedArrayConstructor, key, NativeTypedArrayConstructor[key]); 5039 } 5040 }); 5041 TypedArrayConstructor.prototype = TypedArrayConstructorPrototype; 5042 } 5043 5044 if (TypedArrayConstructorPrototype.constructor !== TypedArrayConstructor) { 5045 createNonEnumerableProperty(TypedArrayConstructorPrototype, 'constructor', TypedArrayConstructor); 5046 } 5047 5048 createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_CONSTRUCTOR, TypedArrayConstructor); 5049 5050 if (TYPED_ARRAY_TAG) { 5051 createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_TAG, CONSTRUCTOR_NAME); 5052 } 5053 5054 exported[CONSTRUCTOR_NAME] = TypedArrayConstructor; 5055 _export({ 5056 global: true, 5057 forced: TypedArrayConstructor != NativeTypedArrayConstructor, 5058 sham: !NATIVE_ARRAY_BUFFER_VIEWS 5059 }, exported); 5060 5061 if (!(BYTES_PER_ELEMENT in TypedArrayConstructor)) { 5062 createNonEnumerableProperty(TypedArrayConstructor, BYTES_PER_ELEMENT, BYTES); 5063 } 5064 5065 if (!(BYTES_PER_ELEMENT in TypedArrayConstructorPrototype)) { 5066 createNonEnumerableProperty(TypedArrayConstructorPrototype, BYTES_PER_ELEMENT, BYTES); 5067 } 5068 5069 setSpecies(CONSTRUCTOR_NAME); 5070 }; 5071 } else module.exports = function () { 5072 /* empty */ 5073 }; 5074 }); 5075 5076 // `Float32Array` constructor 5077 // https://tc39.es/ecma262/#sec-typedarray-objects 5078 5079 5080 typedArrayConstructor('Float32', function (init) { 5081 return function Float32Array(data, byteOffset, length) { 5082 return init(this, data, byteOffset, length); 5083 }; 5084 }); 5085 5086 // `Float64Array` constructor 5087 // https://tc39.es/ecma262/#sec-typedarray-objects 5088 5089 5090 typedArrayConstructor('Float64', function (init) { 5091 return function Float64Array(data, byteOffset, length) { 5092 return init(this, data, byteOffset, length); 5093 }; 5094 }); 5095 5096 // `Int8Array` constructor 5097 // https://tc39.es/ecma262/#sec-typedarray-objects 5098 5099 5100 typedArrayConstructor('Int8', function (init) { 5101 return function Int8Array(data, byteOffset, length) { 5102 return init(this, data, byteOffset, length); 5103 }; 5104 }); 5105 5106 // `Int16Array` constructor 5107 // https://tc39.es/ecma262/#sec-typedarray-objects 5108 5109 5110 typedArrayConstructor('Int16', function (init) { 5111 return function Int16Array(data, byteOffset, length) { 5112 return init(this, data, byteOffset, length); 5113 }; 5114 }); 5115 5116 // `Int32Array` constructor 5117 // https://tc39.es/ecma262/#sec-typedarray-objects 5118 5119 5120 typedArrayConstructor('Int32', function (init) { 5121 return function Int32Array(data, byteOffset, length) { 5122 return init(this, data, byteOffset, length); 5123 }; 5124 }); 5125 5126 // `Uint8Array` constructor 5127 // https://tc39.es/ecma262/#sec-typedarray-objects 5128 5129 5130 typedArrayConstructor('Uint8', function (init) { 5131 return function Uint8Array(data, byteOffset, length) { 5132 return init(this, data, byteOffset, length); 5133 }; 5134 }); 5135 5136 // `Uint8ClampedArray` constructor 5137 // https://tc39.es/ecma262/#sec-typedarray-objects 5138 5139 5140 typedArrayConstructor('Uint8', function (init) { 5141 return function Uint8ClampedArray(data, byteOffset, length) { 5142 return init(this, data, byteOffset, length); 5143 }; 5144 }, true); 5145 5146 // `Uint16Array` constructor 5147 // https://tc39.es/ecma262/#sec-typedarray-objects 5148 5149 5150 typedArrayConstructor('Uint16', function (init) { 5151 return function Uint16Array(data, byteOffset, length) { 5152 return init(this, data, byteOffset, length); 5153 }; 5154 }); 5155 5156 // `Uint32Array` constructor 5157 // https://tc39.es/ecma262/#sec-typedarray-objects 5158 5159 5160 typedArrayConstructor('Uint32', function (init) { 5161 return function Uint32Array(data, byteOffset, length) { 5162 return init(this, data, byteOffset, length); 5163 }; 5164 }); 5165 5166 var aTypedArray$1 = arrayBufferViewCore.aTypedArray; 5167 var exportTypedArrayMethod$1 = arrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.at` method 5168 // https://github.com/tc39/proposal-relative-indexing-method 5169 5170 exportTypedArrayMethod$1('at', function at(index) { 5171 var O = aTypedArray$1(this); 5172 var len = lengthOfArrayLike(O); 5173 var relativeIndex = toIntegerOrInfinity(index); 5174 var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; 5175 return k < 0 || k >= len ? undefined : O[k]; 5176 }); 5177 5178 var exportTypedArrayStaticMethod$1 = arrayBufferViewCore.exportTypedArrayStaticMethod; 5179 5180 // `%TypedArray%.from` method 5181 // https://tc39.es/ecma262/#sec-%typedarray%.from 5182 5183 5184 exportTypedArrayStaticMethod$1('from', typedArrayFrom, typedArrayConstructorsRequireWrappers); 5185 5186 var aTypedArrayConstructor$2 = arrayBufferViewCore.aTypedArrayConstructor; 5187 var exportTypedArrayStaticMethod$2 = arrayBufferViewCore.exportTypedArrayStaticMethod; // `%TypedArray%.of` method 5188 // https://tc39.es/ecma262/#sec-%typedarray%.of 5189 5190 exportTypedArrayStaticMethod$2('of', function of() 5191 /* ...items */ 5192 { 5193 var index = 0; 5194 var length = arguments.length; 5195 var result = new (aTypedArrayConstructor$2(this))(length); 5196 5197 while (length > index) result[index] = arguments[index++]; 5198 5199 return result; 5200 }, typedArrayConstructorsRequireWrappers); 5201 5202 var floor$4 = Math.floor; 5203 5204 var mergeSort = function (array, comparefn) { 5205 var length = array.length; 5206 var middle = floor$4(length / 2); 5207 return length < 8 ? insertionSort(array, comparefn) : merge(array, mergeSort(arraySliceSimple(array, 0, middle), comparefn), mergeSort(arraySliceSimple(array, middle), comparefn), comparefn); 5208 }; 5209 5210 var insertionSort = function (array, comparefn) { 5211 var length = array.length; 5212 var i = 1; 5213 var element, j; 5214 5215 while (i < length) { 5216 j = i; 5217 element = array[i]; 5218 5219 while (j && comparefn(array[j - 1], element) > 0) { 5220 array[j] = array[--j]; 5221 } 5222 5223 if (j !== i++) array[j] = element; 5224 } 5225 5226 return array; 5227 }; 5228 5229 var merge = function (array, left, right, comparefn) { 5230 var llength = left.length; 5231 var rlength = right.length; 5232 var lindex = 0; 5233 var rindex = 0; 5234 5235 while (lindex < llength || rindex < rlength) { 5236 array[lindex + rindex] = lindex < llength && rindex < rlength ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++] : lindex < llength ? left[lindex++] : right[rindex++]; 5237 } 5238 5239 return array; 5240 }; 5241 5242 var arraySort = mergeSort; 5243 5244 var firefox = engineUserAgent.match(/firefox\/(\d+)/i); 5245 var engineFfVersion = !!firefox && +firefox[1]; 5246 5247 var engineIsIeOrEdge = /MSIE|Trident/.test(engineUserAgent); 5248
vendor: 4,612 bytes, lines 5249-5393
5249 var webkit = engineUserAgent.match(/AppleWebKit\/(\d+)\./); 5250 var engineWebkitVersion = !!webkit && +webkit[1]; 5251 5252 var Array$5 = global_1.Array; 5253 var aTypedArray$2 = arrayBufferViewCore.aTypedArray; 5254 var exportTypedArrayMethod$2 = arrayBufferViewCore.exportTypedArrayMethod; 5255 var Uint16Array = global_1.Uint16Array; 5256 var un$Sort = Uint16Array && functionUncurryThis(Uint16Array.prototype.sort); // WebKit 5257 5258 var ACCEPT_INCORRECT_ARGUMENTS = !!un$Sort && !(fails(function () { 5259 un$Sort(new Uint16Array(2), null); 5260 }) && fails(function () { 5261 un$Sort(new Uint16Array(2), {}); 5262 })); 5263 var STABLE_SORT = !!un$Sort && !fails(function () { 5264 // feature detection can be too slow, so check engines versions 5265 if (engineV8Version) return engineV8Version < 74; 5266 if (engineFfVersion) return engineFfVersion < 67; 5267 if (engineIsIeOrEdge) return true; 5268 if (engineWebkitVersion) return engineWebkitVersion < 602; 5269 var array = new Uint16Array(516); 5270 var expected = Array$5(516); 5271 var index, mod; 5272 5273 for (index = 0; index < 516; index++) { 5274 mod = index % 4; 5275 array[index] = 515 - index; 5276 expected[index] = index - 2 * mod + 3; 5277 } 5278 5279 un$Sort(array, function (a, b) { 5280 return (a / 4 | 0) - (b / 4 | 0); 5281 }); 5282 5283 for (index = 0; index < 516; index++) { 5284 if (array[index] !== expected[index]) return true; 5285 } 5286 }); 5287 5288 var getSortCompare = function (comparefn) { 5289 return function (x, y) { 5290 if (comparefn !== undefined) return +comparefn(x, y) || 0; // eslint-disable-next-line no-self-compare -- NaN check 5291 5292 if (y !== y) return -1; // eslint-disable-next-line no-self-compare -- NaN check 5293 5294 if (x !== x) return 1; 5295 if (x === 0 && y === 0) return 1 / x > 0 && 1 / y < 0 ? 1 : -1; 5296 return x > y; 5297 }; 5298 }; // `%TypedArray%.prototype.sort` method 5299 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.sort 5300 5301 5302 exportTypedArrayMethod$2('sort', function sort(comparefn) { 5303 if (comparefn !== undefined) aCallable(comparefn); 5304 if (STABLE_SORT) return un$Sort(this, comparefn); 5305 return arraySort(aTypedArray$2(this), getSortCompare(comparefn)); 5306 }, !STABLE_SORT || ACCEPT_INCORRECT_ARGUMENTS); 5307 5308 // iterable DOM collections 5309 // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods 5310 var domIterables = { 5311 CSSRuleList: 0, 5312 CSSStyleDeclaration: 0, 5313 CSSValueList: 0, 5314 ClientRectList: 0, 5315 DOMRectList: 0, 5316 DOMStringList: 0, 5317 DOMTokenList: 1, 5318 DataTransferItemList: 0, 5319 FileList: 0, 5320 HTMLAllCollection: 0, 5321 HTMLCollection: 0, 5322 HTMLFormElement: 0, 5323 HTMLSelectElement: 0, 5324 MediaList: 0, 5325 MimeTypeArray: 0, 5326 NamedNodeMap: 0, 5327 NodeList: 1, 5328 PaintRequestList: 0, 5329 Plugin: 0, 5330 PluginArray: 0, 5331 SVGLengthList: 0, 5332 SVGNumberList: 0, 5333 SVGPathSegList: 0, 5334 SVGPointList: 0, 5335 SVGStringList: 0, 5336 SVGTransformList: 0, 5337 SourceBufferList: 0, 5338 StyleSheetList: 0, 5339 TextTrackCueList: 0, 5340 TextTrackList: 0, 5341 TouchList: 0 5342 }; 5343 5344 // in old WebKit versions, `element.classList` is not an instance of global `DOMTokenList` 5345 5346 5347 var classList = documentCreateElement('span').classList; 5348 var DOMTokenListPrototype = classList && classList.constructor && classList.constructor.prototype; 5349 var domTokenListPrototype = DOMTokenListPrototype === Object.prototype ? undefined : DOMTokenListPrototype; 5350 5351 var PROPER_FUNCTION_NAME$1 = functionName.PROPER; 5352 var CONFIGURABLE_FUNCTION_NAME$1 = functionName.CONFIGURABLE; 5353 var IteratorPrototype$2 = iteratorsCore.IteratorPrototype; 5354 var BUGGY_SAFARI_ITERATORS$1 = iteratorsCore.BUGGY_SAFARI_ITERATORS; 5355 var ITERATOR$4 = wellKnownSymbol('iterator'); 5356 var KEYS = 'keys'; 5357 var VALUES = 'values'; 5358 var ENTRIES = 'entries'; 5359 5360 var returnThis$1 = function () { 5361 return this; 5362 }; 5363 5364 var defineIterator = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) { 5365 createIteratorConstructor(IteratorConstructor, NAME, next); 5366 5367 var getIterationMethod = function (KIND) { 5368 if (KIND === DEFAULT && defaultIterator) return defaultIterator; 5369 if (!BUGGY_SAFARI_ITERATORS$1 && KIND in IterablePrototype) return IterablePrototype[KIND]; 5370 5371 switch (KIND) { 5372 case KEYS: 5373 return function keys() { 5374 return new IteratorConstructor(this, KIND); 5375 }; 5376 5377 case VALUES: 5378 return function values() { 5379 return new IteratorConstructor(this, KIND); 5380 }; 5381 5382 case ENTRIES: 5383 return function entries() { 5384 return new IteratorConstructor(this, KIND); 5385 }; 5386 } 5387 5388 return function () { 5389 return new IteratorConstructor(this); 5390 }; 5391 }; 5392 5393 var TO_STRING_TAG = NAME + ' Iterator';
5394 var INCORRECT_VALUES_NAME = false; 5395 var IterablePrototype = Iterable.prototype; 5396 var nativeIterator = IterablePrototype[ITERATOR$4] || IterablePrototype['@@iterator'] || DEFAULT && IterablePrototype[DEFAULT]; 5397 var defaultIterator = !BUGGY_SAFARI_ITERATORS$1 && nativeIterator || getIterationMethod(DEFAULT); 5398 var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator; 5399 var CurrentIteratorPrototype, methods, KEY; // fix native 5400 5401 if (anyNativeIterator) { 5402 CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable())); 5403 5404 if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) { 5405 if (objectGetPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype$2) { 5406 if (objectSetPrototypeOf) { 5407 objectSetPrototypeOf(CurrentIteratorPrototype, IteratorPrototype$2); 5408 } else if (!isCallable(CurrentIteratorPrototype[ITERATOR$4])) { 5409 redefine(CurrentIteratorPrototype, ITERATOR$4, returnThis$1); 5410 } 5411 } // Set @@toStringTag to native iterators 5412 5413 5414 setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true); 5415 } 5416 } // fix Array.prototype.{ values, @@iterator }.name in V8 / FF 5417 5418 5419 if (PROPER_FUNCTION_NAME$1 && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) { 5420 if (CONFIGURABLE_FUNCTION_NAME$1) { 5421 createNonEnumerableProperty(IterablePrototype, 'name', VALUES); 5422 } else { 5423 INCORRECT_VALUES_NAME = true; 5424 5425 defaultIterator = function values() { 5426 return functionCall(nativeIterator, this); 5427 }; 5428 } 5429 } // export additional methods 5430 5431 5432 if (DEFAULT) { 5433 methods = { 5434 values: getIterationMethod(VALUES), 5435 keys: IS_SET ? defaultIterator : getIterationMethod(KEYS), 5436 entries: getIterationMethod(ENTRIES) 5437 }; 5438 if (FORCED) for (KEY in methods) { 5439 if (BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) { 5440 redefine(IterablePrototype, KEY, methods[KEY]); 5441 } 5442 } else _export({ 5443 target: NAME, 5444 proto: true, 5445 forced: BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME 5446 }, methods); 5447 } // define iterator 5448 5449 5450 if (IterablePrototype[ITERATOR$4] !== defaultIterator) { 5451 redefine(IterablePrototype, ITERATOR$4, defaultIterator, { 5452 name: DEFAULT 5453 }); 5454 } 5455 5456 iterators[NAME] = defaultIterator; 5457 return methods; 5458 }; 5459 5460 var ARRAY_ITERATOR = 'Array Iterator'; 5461 var setInternalState$2 = internalState.set; 5462 var getInternalState$3 = internalState.getterFor(ARRAY_ITERATOR); // `Array.prototype.entries` method 5463 // https://tc39.es/ecma262/#sec-array.prototype.entries 5464 // `Array.prototype.keys` method 5465 // https://tc39.es/ecma262/#sec-array.prototype.keys 5466 // `Array.prototype.values` method 5467 // https://tc39.es/ecma262/#sec-array.prototype.values 5468 // `Array.prototype[@@iterator]` method 5469 // https://tc39.es/ecma262/#sec-array.prototype-@@iterator 5470 // `CreateArrayIterator` internal method 5471 // https://tc39.es/ecma262/#sec-createarrayiterator 5472 5473 var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind) { 5474 setInternalState$2(this, { 5475 type: ARRAY_ITERATOR, 5476 target: toIndexedObject(iterated), 5477 // target 5478 index: 0, 5479 // next index 5480 kind: kind // kind 5481 5482 }); // `%ArrayIteratorPrototype%.next` method 5483 // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next 5484 }, function () { 5485 var state = getInternalState$3(this); 5486 var target = state.target; 5487 var kind = state.kind; 5488 var index = state.index++; 5489 5490 if (!target || index >= target.length) { 5491 state.target = undefined; 5492 return { 5493 value: undefined, 5494 done: true 5495 }; 5496 } 5497 5498 if (kind == 'keys') return { 5499 value: index, 5500 done: false 5501 }; 5502 if (kind == 'values') return { 5503 value: target[index], 5504 done: false 5505 }; 5506 return { 5507 value: [index, target[index]], 5508 done: false 5509 }; 5510 }, 'values'); // argumentsList[@@iterator] is %ArrayProto_values% 5511 // https://tc39.es/ecma262/#sec-createunmappedargumentsobject 5512 // https://tc39.es/ecma262/#sec-createmappedargumentsobject 5513 5514 iterators.Arguments = iterators.Array; // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 5515 5516 addToUnscopables('keys'); 5517 addToUnscopables('values'); 5518 addToUnscopables('entries'); 5519 5520 var ITERATOR$5 = wellKnownSymbol('iterator'); 5521 var TO_STRING_TAG$5 = wellKnownSymbol('toStringTag'); 5522 var ArrayValues = es_array_iterator.values; 5523 5524 var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) { 5525 if (CollectionPrototype) { 5526 // some Chrome versions have non-configurable methods on DOMTokenList 5527 if (CollectionPrototype[ITERATOR$5] !== ArrayValues) try { 5528 createNonEnumerableProperty(CollectionPrototype, ITERATOR$5, ArrayValues); 5529 } catch (error) { 5530 CollectionPrototype[ITERATOR$5] = ArrayValues; 5531 } 5532 5533 if (!CollectionPrototype[TO_STRING_TAG$5]) { 5534 createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG$5, COLLECTION_NAME); 5535 } 5536 5537 if (domIterables[COLLECTION_NAME]) for (var METHOD_NAME in es_array_iterator) { 5538 // some Chrome versions have non-configurable methods on DOMTokenList 5539 if (CollectionPrototype[METHOD_NAME] !== es_array_iterator[METHOD_NAME]) try { 5540 createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, es_array_iterator[METHOD_NAME]); 5541 } catch (error) { 5542 CollectionPrototype[METHOD_NAME] = es_array_iterator[METHOD_NAME]; 5543 } 5544 } 5545 } 5546 }; 5547 5548 for (var COLLECTION_NAME in domIterables) { 5549 handlePrototype(global_1[COLLECTION_NAME] && global_1[COLLECTION_NAME].prototype, COLLECTION_NAME); 5550 } 5551 5552 handlePrototype(domTokenListPrototype, 'DOMTokenList'); 5553 5554 var FunctionPrototype$2 = Function.prototype; 5555 var apply = FunctionPrototype$2.apply; 5556 var bind$2 = FunctionPrototype$2.bind; 5557 var call$2 = FunctionPrototype$2.call; // eslint-disable-next-line es/no-reflect -- safe 5558 5559 var functionApply = typeof Reflect == 'object' && Reflect.apply || (bind$2 ? call$2.bind(apply) : function () { 5560 return call$2.apply(apply, arguments); 5561 }); 5562 5563 var arraySlice = functionUncurryThis([].slice); 5564 5565 var engineIsIos = /(?:ipad|iphone|ipod).*applewebkit/i.test(engineUserAgent); 5566 5567 var engineIsNode = classofRaw(global_1.process) == 'process'; 5568 5569 var set$2 = global_1.setImmediate; 5570 var clear = global_1.clearImmediate; 5571 var process$1 = global_1.process; 5572 var Dispatch = global_1.Dispatch; 5573 var Function$1 = global_1.Function; 5574 var MessageChannel = global_1.MessageChannel; 5575 var String$5 = global_1.String; 5576 var counter = 0; 5577 var queue = {}; 5578 var ONREADYSTATECHANGE = 'onreadystatechange'; 5579 var location, defer, channel, port; 5580 5581 try { 5582 // Deno throws a ReferenceError on `location` access without `--location` flag 5583 location = global_1.location; 5584 } catch (error) { 5585 /* empty */ 5586 } 5587 5588 var run = function (id) { 5589 if (hasOwnProperty_1(queue, id)) { 5590 var fn = queue[id]; 5591 delete queue[id]; 5592 fn(); 5593 } 5594 }; 5595 5596 var runner = function (id) { 5597 return function () { 5598 run(id); 5599 }; 5600 }; 5601 5602 var listener = function (event) { 5603 run(event.data); 5604 }; 5605 5606 var post = function (id) { 5607 // old engines have not location.origin 5608 global_1.postMessage(String$5(id), location.protocol + '//' + location.host); 5609 }; // Node.js 0.9+ & IE10+ has setImmediate, otherwise: 5610 5611 5612 if (!set$2 || !clear) { 5613 set$2 = function setImmediate(fn) { 5614 var args = arraySlice(arguments, 1); 5615 5616 queue[++counter] = function () { 5617 functionApply(isCallable(fn) ? fn : Function$1(fn), undefined, args); 5618 }; 5619 5620 defer(counter); 5621 return counter; 5622 }; 5623 5624 clear = function clearImmediate(id) { 5625 delete queue[id]; 5626 }; // Node.js 0.8- 5627 5628 5629 if (engineIsNode) { 5630 defer = function (id) { 5631 process$1.nextTick(runner(id)); 5632 }; // Sphere (JS game engine) Dispatch API 5633 5634 } else if (Dispatch && Dispatch.now) { 5635 defer = function (id) { 5636 Dispatch.now(runner(id)); 5637 }; // Browsers with MessageChannel, includes WebWorkers 5638 // except iOS - https://github.com/zloirock/core-js/issues/624 5639 5640 } else if (MessageChannel && !engineIsIos) { 5641 channel = new MessageChannel(); 5642 port = channel.port2; 5643 channel.port1.onmessage = listener; 5644 defer = functionBindContext(port.postMessage, port); // Browsers with postMessage, skip WebWorkers 5645 // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' 5646 } else if (global_1.addEventListener && isCallable(global_1.postMessage) && !global_1.importScripts && location && location.protocol !== 'file:' && !fails(post)) { 5647 defer = post; 5648 global_1.addEventListener('message', listener, false); // IE8- 5649 } else if (ONREADYSTATECHANGE in documentCreateElement('script')) { 5650 defer = function (id) { 5651 html.appendChild(documentCreateElement('script'))[ONREADYSTATECHANGE] = function () { 5652 html.removeChild(this); 5653 run(id); 5654 }; 5655 }; // Rest old browsers 5656 5657 } else { 5658 defer = function (id) { 5659 setTimeout(runner(id), 0); 5660 }; 5661 } 5662 } 5663 5664 var task = { 5665 set: set$2, 5666 clear: clear 5667 }; 5668 5669 var FORCED = !global_1.setImmediate || !global_1.clearImmediate; // http://w3c.github.io/setImmediate/ 5670 5671 _export({ 5672 global: true, 5673 bind: true, 5674 enumerable: true, 5675 forced: FORCED 5676 }, { 5677 // `setImmediate` method 5678 // http://w3c.github.io/setImmediate/#si-setImmediate 5679 setImmediate: task.set, 5680 // `clearImmediate` method 5681 // http://w3c.github.io/setImmediate/#si-clearImmediate 5682 clearImmediate: task.clear 5683 }); 5684 5685 var engineIsIosPebble = /ipad|iphone|ipod/i.test(engineUserAgent) && global_1.Pebble !== undefined; 5686 5687 var engineIsWebosWebkit = /web0s(?!.*chrome)/i.test(engineUserAgent); 5688 5689 var getOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f; 5690 5691 var macrotask = task.set; 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 var MutationObserver = global_1.MutationObserver || global_1.WebKitMutationObserver; 5702 var document$2 = global_1.document; 5703 var process$2 = global_1.process; 5704 var Promise = global_1.Promise; // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask` 5705 5706 var queueMicrotaskDescriptor = getOwnPropertyDescriptor$2(global_1, 'queueMicrotask'); 5707 var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value; 5708 var flush, head, last, notify, toggle, node, promise, then; // modern engines have queueMicrotask method 5709 5710 if (!queueMicrotask) { 5711 flush = function () { 5712 var parent, fn; 5713 if (engineIsNode && (parent = process$2.domain)) parent.exit(); 5714 5715 while (head) { 5716 fn = head.fn; 5717 head = head.next; 5718 5719 try { 5720 fn(); 5721 } catch (error) { 5722 if (head) notify();else last = undefined; 5723 throw error; 5724 } 5725 } 5726 5727 last = undefined; 5728 if (parent) parent.enter(); 5729 }; // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339 5730 // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898 5731 5732 5733 if (!engineIsIos && !engineIsNode && !engineIsWebosWebkit && MutationObserver && document$2) { 5734 toggle = true; 5735 node = document$2.createTextNode(''); 5736 new MutationObserver(flush).observe(node, { 5737 characterData: true 5738 }); 5739 5740 notify = function () { 5741 node.data = toggle = !toggle; 5742 }; // environments with maybe non-completely correct, but existent Promise 5743 5744 } else if (!engineIsIosPebble && Promise && Promise.resolve) { 5745 // Promise.resolve without an argument throws an error in LG WebOS 2 5746 promise = Promise.resolve(undefined); // workaround of WebKit ~ iOS Safari 10.1 bug 5747 5748 promise.constructor = Promise; 5749 then = functionBindContext(promise.then, promise); 5750 5751 notify = function () { 5752 then(flush); 5753 }; // Node.js without promises 5754 5755 } else if (engineIsNode) { 5756 notify = function () { 5757 process$2.nextTick(flush); 5758 }; // for other environments - macrotask based on: 5759 // - setImmediate 5760 // - MessageChannel 5761 // - window.postMessag 5762 // - onreadystatechange 5763 // - setTimeout 5764 5765 } else { 5766 // strange IE + webpack dev server bug - use .bind(global) 5767 macrotask = functionBindContext(macrotask, global_1); 5768 5769 notify = function () { 5770 macrotask(flush); 5771 }; 5772 } 5773 } 5774 5775 var microtask = queueMicrotask || function (fn) { 5776 var task$$1 = { 5777 fn: fn, 5778 next: undefined 5779 }; 5780 if (last) last.next = task$$1; 5781 5782 if (!head) { 5783 head = task$$1; 5784 notify(); 5785 } 5786 5787 last = task$$1; 5788 }; 5789 5790 var process$3 = global_1.process; // `queueMicrotask` method 5791 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask 5792 5793 _export({ 5794 global: true, 5795 enumerable: true, 5796 noTargetGet: true 5797 }, { 5798 queueMicrotask: function queueMicrotask(fn) { 5799 var domain = engineIsNode && process$3.domain; 5800 microtask(domain ? domain.bind(fn) : fn); 5801 } 5802 }); 5803 5804 // File generated automatically. Don't modify it. 5805 5806}((this.window = this.window || {}))); 5807 5808 5809 5810if (window._main_polyfill_core) 5811{ 5812 console.warn('main.polyfill.core is loaded more than once on this page'); 5813} 5814 5815window._main_polyfill_core = true; 5816 5817 5818(function (exports) { 5819 'use strict'; 5820 5821 var bxTmp = window.BX; 5822 window.BX = function (node) { 5823 if (window.BX.type.isNotEmptyString(node)) { 5824 return document.getElementById(node); 5825 } 5826 if (window.BX.type.isDomNode(node)) { 5827 return node; 5828 } 5829 if (window.BX.type.isFunction(node)) { 5830 return window.BX.ready(node); 5831 } 5832 return null; 5833 }; 5834 if (bxTmp) {
5835 Object.keys(bxTmp).forEach(key => { 5836 window.BX[key] = bxTmp[key]; 5837 }); 5838 } 5839 exports = window.BX; 5840 5841 /** 5842 * Gets object.toString result 5843 * @param value 5844 * @return {string} 5845 */ 5846 function getTag(value) { 5847 return Object.prototype.toString.call(value); 5848 } 5849 5850 const objectCtorString = Function.prototype.toString.call(Object); 5851 5852 /** 5853 * @memberOf BX 5854 */ 5855 let Type = /*#__PURE__*/function () { 5856 function Type() { 5857 babelHelpers.classCallCheck(this, Type); 5858 } 5859 babelHelpers.createClass(Type, null, [{ 5860 key: "isString", 5861 /** 5862 * Checks that value is string 5863 * @param value 5864 * @return {boolean} 5865 */ 5866 value: function isString(value) { 5867 return typeof value === 'string'; 5868 } 5869 /** 5870 * Returns true if a value is not empty string 5871 * @param value 5872 * @returns {boolean} 5873 */ 5874 }, { 5875 key: "isStringFilled", 5876 value: function isStringFilled(value) { 5877 return 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.isPlainObject(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.isPlainObject(options)) { 7418 return; 7419 } 7420 aliases = Type.isPlainObject(aliases) ? EventEmitter.normalizeAliases(aliases) : {};
7421 Object.keys(options).forEach(eventName => { 7422 const listener = EventEmitter.normalizeListener(options[eventName]); 7423 eventName = EventEmitter.normalizeEventName(eventName); 7424 if (aliases[eventName]) { 7425 const { 7426 eventName: actualName 7427 } = aliases[eventName]; 7428 EventEmitter.subscribe(this, actualName, listener, { 7429 compatMode: compatMode !== false 7430 }); 7431 } else { 7432 EventEmitter.subscribe(this, eventName, listener, { 7433 compatMode: compatMode === true 7434 }); 7435 } 7436 }); 7437 } 7438 /** 7439 * Subscribes a listener that is called at 7440 * most once for a specified event. 7441 * @param {object} target 7442 * @param {string} eventName 7443 * @param {Function<BaseEvent>} listener 7444 */ 7445 }, { 7446 key: "subscribeOnce", 7447 /** 7448 * Subscribes a listener that is called at most once for a specified event. 7449 * @param {string} eventName 7450 * @param {Function<BaseEvent>} listener 7451 * @return {this} 7452 */ 7453 value: function subscribeOnce(eventName, listener) { 7454 EventEmitter.subscribeOnce(this, eventName, listener); 7455 return this; 7456 } 7457 /** 7458 * Unsubscribes an event listener 7459 * @param {object} target 7460 * @param {string} eventName 7461 * @param {Function<BaseEvent>} listener 7462 * @param options 7463 */ 7464 }, { 7465 key: "unsubscribe", 7466 /** 7467 * Unsubscribes an event listener 7468 * @param {string} eventName 7469 * @param {Function<BaseEvent>} listener 7470 * @return {this} 7471 */ 7472 value: function unsubscribe(eventName, listener) { 7473 EventEmitter.unsubscribe(this, eventName, listener); 7474 return this; 7475 } 7476 /** 7477 * Unsubscribes all event listeners 7478 * @param {object} target 7479 * @param {string} eventName 7480 * @param options 7481 */ 7482 }, { 7483 key: "unsubscribeAll", 7484 /** 7485 * Unsubscribes all event listeners 7486 * @param {string} [eventName] 7487 */ 7488 value: function unsubscribeAll(eventName) { 7489 EventEmitter.unsubscribeAll(this, eventName); 7490 } 7491 /** 7492 * 7493 * @param {object} target 7494 * @param {string} eventName 7495 * @param {BaseEvent | any} event 7496 * @param {object} options 7497 * @returns {Array} 7498 */ 7499 }, { 7500 key: "emit", 7501 /** 7502 * Emits specified event with specified event object 7503 * @param {string} eventName 7504 * @param {BaseEvent | any} event 7505 * @return {this} 7506 */ 7507 value: function emit(eventName, event) { 7508 if (this.getEventNamespace() === null) { 7509 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7510 } 7511 EventEmitter.emit(this, eventName, event); 7512 return this; 7513 } 7514 /** 7515 * Emits global event and returns a promise that is resolved when 7516 * all promise returned from event handlers are resolved, 7517 * or rejected when at least one of the returned promise is rejected. 7518 * Importantly. You can return any value from synchronous handlers, not just promise 7519 * @param {object} target 7520 * @param {string} eventName 7521 * @param {BaseEvent | any} event 7522 * @return {Promise<Array>} 7523 */ 7524 }, { 7525 key: "emitAsync", 7526 /** 7527 * Emits event and returns a promise that is resolved when 7528 * all promise returned from event handlers are resolved, 7529 * or rejected when at least one of the returned promise is rejected. 7530 * Importantly. You can return any value from synchronous handlers, not just promise 7531 * @param {string} eventName 7532 * @param {BaseEvent|any} event 7533 * @return {Promise<Array>} 7534 */ 7535 value: function emitAsync(eventName, event) { 7536 if (this.getEventNamespace() === null) { 7537 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7538 } 7539 return EventEmitter.emitAsync(this, eventName, event); 7540 } 7541 /** 7542 * @private 7543 * @param {object} target 7544 * @param {string} eventName 7545 * @param {BaseEvent|any} event 7546 * @returns {BaseEvent} 7547 */ 7548 }, { 7549 key: "setMaxListeners", 7550 /** 7551 * Sets max events listeners count 7552 * this.setMaxListeners(10) - sets the default value for all events
7553 * this.setMaxListeners("onClose", 10) sets the value for onClose event 7554 * @return {this} 7555 * @param args 7556 */ 7557 value: function setMaxListeners(...args) { 7558 EventEmitter.setMaxListeners(this, ...args); 7559 return this; 7560 } 7561 /** 7562 * Returns max event listeners count 7563 * @param {object} target 7564 * @param {string} [eventName] 7565 * @returns {number} 7566 */ 7567 }, { 7568 key: "getMaxListeners", 7569 /** 7570 * Returns max event listeners count 7571 * @param {string} [eventName] 7572 * @returns {number} 7573 */ 7574 value: function getMaxListeners(eventName) { 7575 return EventEmitter.getMaxListeners(this, eventName); 7576 } 7577 /** 7578 * Adds or subtracts max listeners count 7579 * Event.EventEmitter.addMaxListeners() - adds one max listener for all events of global target 7580 * Event.EventEmitter.addMaxListeners(3) - adds three max listeners for all events of global target 7581 * Event.EventEmitter.addMaxListeners(-1) - subtracts one max listener for all events of global target 7582 * Event.EventEmitter.addMaxListeners('onClose') - adds one max listener for onClose event of global target 7583 * Event.EventEmitter.addMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 7584 * Event.EventEmitter.addMaxListeners('onClose', -1) - subtracts one max listener for onClose event of global target 7585 * 7586 * Event.EventEmitter.addMaxListeners(obj) - adds one max listener for all events of 'obj' target 7587 * Event.EventEmitter.addMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 7588 * Event.EventEmitter.addMaxListeners(obj, -1) - subtracts one max listener for all events of 'obj' target 7589 * Event.EventEmitter.addMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 7590 * Event.EventEmitter.addMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 7591 * Event.EventEmitter.addMaxListeners(obj, 'onClose', -1) - subtracts one max listener for onClose event of 'obj' target 7592 * @param args 7593 * @returns {number} 7594 */ 7595 }, { 7596 key: "incrementMaxListeners", 7597 /** 7598 * Increases max listeners count 7599 * this.incrementMaxListeners() - adds one max listener for all events 7600 * this.incrementMaxListeners(3) - adds three max listeners for all events 7601 * this.incrementMaxListeners('onClose') - adds one max listener for onClose event 7602 * this.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event 7603 */ 7604 value: function incrementMaxListeners(...args) { 7605 return EventEmitter.incrementMaxListeners(this, ...args); 7606 } 7607 /** 7608 * Decreases max listeners count 7609 * 7610 * Event.EventEmitter.decrementMaxListeners() - subtracts one max listener for all events of global target 7611 * Event.EventEmitter.decrementMaxListeners(3) - subtracts three max listeners for all events of global target 7612 * Event.EventEmitter.decrementMaxListeners('onClose') - subtracts one max listener for onClose event of global target 7613 * Event.EventEmitter.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event of global target 7614 * 7615 * Event.EventEmitter.decrementMaxListeners(obj) - subtracts one max listener for all events of 'obj' target 7616 * Event.EventEmitter.decrementMaxListeners(obj, 3) - subtracts three max listeners for all events of 'obj' target 7617 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose') - subtracts one max listener for onClose event of 'obj' target 7618 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose', 2) - subtracts two max listeners for onClose event of 'obj' target 7619 */ 7620 }, { 7621 key: "decrementMaxListeners", 7622 /** 7623 * Increases max listeners count 7624 * this.decrementMaxListeners() - subtracts one max listener for all events 7625 * this.decrementMaxListeners(3) - subtracts three max listeners for all events 7626 * this.decrementMaxListeners('onClose') - subtracts one max listener for onClose event 7627 * this.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event 7628 */ 7629 value: function decrementMaxListeners(...args) { 7630 return EventEmitter.decrementMaxListeners(this, ...args); 7631 } 7632 /** 7633 * @private 7634 * @param {Array} args 7635 * @returns Array 7636 */ 7637 }, { 7638 key: "getListeners", 7639 /** 7640 * Gets listeners list for specified event 7641 * @param {string} eventName 7642 */ 7643 value: function getListeners(eventName) { 7644 return EventEmitter.getListeners(this, eventName); 7645 } 7646 /** 7647 * Returns a full event name with namespace 7648 * @param {string} eventName 7649 * @returns {string} 7650 */ 7651 }, { 7652 key: "getFullEventName", 7653 value: function getFullEventName(eventName) { 7654 if (!Type.isStringFilled(eventName)) { 7655 throw new TypeError(`The "eventName" argument must be a string.`); 7656 } 7657 return EventEmitter.makeFullEventName(this.getEventNamespace(), eventName); 7658 } 7659 /** 7660 * Registers aliases (old event names for BX.onCustomEvent) 7661 * @param aliases 7662 */ 7663 }], [{ 7664 key: "makeObservable", 7665 value: function makeObservable(target, namespace) { 7666 if (!Type.isObject(target)) { 7667 throw new TypeError('The "target" argument must be an object.'); 7668 } 7669 if (!Type.isStringFilled(namespace)) { 7670 throw new TypeError('The "namespace" must be an non-empty string.'); 7671 } 7672 if (EventEmitter.isEventEmitter(target)) { 7673 throw new TypeError('The "target" is an event emitter already.'); 7674 } 7675 const targetProto = Object.getPrototypeOf(target); 7676 const emitter = new EventEmitter(); 7677 emitter.setEventNamespace(namespace); 7678 Object.setPrototypeOf(emitter, targetProto); 7679 Object.setPrototypeOf(target, emitter); 7680 Object.getOwnPropertyNames(EventEmitter.prototype).forEach(method => {
7681 if (['constructor'].includes(method)) { 7682 return; 7683 } 7684 emitter[method] = function (...args) { 7685 return EventEmitter.prototype[method].apply(target, args); 7686 }; 7687 }); 7688 } 7689 }, { 7690 key: "subscribe", 7691 value: function subscribe(target, eventName, listener, options) { 7692 if (Type.isString(target)) { 7693 options = listener; 7694 listener = eventName; 7695 eventName = target; 7696 target = this.GLOBAL_TARGET; 7697 } 7698 if (!Type.isObject(target)) { 7699 throw new TypeError(`The "target" argument must be an object.`); 7700 } 7701 eventName = this.normalizeEventName(eventName); 7702 if (!Type.isStringFilled(eventName)) { 7703 throw new TypeError(`The "eventName" argument must be a string.`); 7704 } 7705 listener = this.normalizeListener(listener); 7706 options = Type.isPlainObject(options) ? options : {}; 7707 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7708 const { 7709 eventsMap, 7710 onceMap 7711 } = eventStore.getOrAdd(target); 7712 const onceListeners = onceMap.get(fullEventName); 7713 let listeners = eventsMap.get(fullEventName); 7714 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7715 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7716 } else { 7717 if (listeners) { 7718 listeners.set(listener, { 7719 listener, 7720 options, 7721 sort: this.getNextSequenceValue() 7722 }); 7723 } else { 7724 listeners = new Map([[listener, { 7725 listener, 7726 options, 7727 sort: this.getNextSequenceValue() 7728 }]]); 7729 eventsMap.set(fullEventName, listeners); 7730 } 7731 } 7732 const maxListeners = this.getMaxListeners(target, eventName); 7733 if (listeners.size > maxListeners) { 7734 warningStore.add(target, fullEventName, listeners); 7735 warningStore.printDelayed(); 7736 } 7737 } 7738 }, { 7739 key: "subscribeOnce", 7740 value: function subscribeOnce(target, eventName, listener) { 7741 if (Type.isString(target)) { 7742 listener = eventName; 7743 eventName = target; 7744 target = this.GLOBAL_TARGET;
7745 } 7746 if (!Type.isObject(target)) { 7747 throw new TypeError(`The "target" argument must be an object.`); 7748 } 7749 eventName = this.normalizeEventName(eventName); 7750 if (!Type.isStringFilled(eventName)) { 7751 throw new TypeError(`The "eventName" argument must be a string.`); 7752 } 7753 listener = this.normalizeListener(listener); 7754 const fullEventName = this.resolveEventName(eventName, target); 7755 const { 7756 eventsMap, 7757 onceMap 7758 } = eventStore.getOrAdd(target); 7759 const listeners = eventsMap.get(fullEventName); 7760 let onceListeners = onceMap.get(fullEventName); 7761 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7762 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7763 } else { 7764 const once = (...args) => { 7765 this.unsubscribe(target, eventName, once); 7766 onceListeners.delete(listener); 7767 listener(...args); 7768 }; 7769 if (onceListeners) { 7770 onceListeners.set(listener, once); 7771 } else { 7772 onceListeners = new Map([[listener, once]]); 7773 onceMap.set(fullEventName, onceListeners); 7774 } 7775 this.subscribe(target, eventName, once); 7776 } 7777 } 7778 }, { 7779 key: "unsubscribe", 7780 value: function unsubscribe(target, eventName, listener, options) { 7781 if (Type.isString(target)) { 7782 listener = eventName; 7783 eventName = target; 7784 target = this.GLOBAL_TARGET;
7785 } 7786 eventName = this.normalizeEventName(eventName); 7787 if (!Type.isStringFilled(eventName)) { 7788 throw new TypeError(`The "eventName" argument must be a string.`); 7789 } 7790 listener = this.normalizeListener(listener); 7791 options = Type.isPlainObject(options) ? options : {}; 7792 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7793 const targetInfo = eventStore.get(target); 7794 const listeners = targetInfo && targetInfo.eventsMap.get(fullEventName); 7795 const onceListeners = targetInfo && targetInfo.onceMap.get(fullEventName); 7796 if (listeners) { 7797 listeners.delete(listener); 7798 } 7799 if (onceListeners) { 7800 const once = onceListeners.get(listener); 7801 if (once) { 7802 onceListeners.delete(listener); 7803 listeners.delete(once); 7804 } 7805 } 7806 } 7807 }, { 7808 key: "unsubscribeAll", 7809 value: function unsubscribeAll(target, eventName, options) { 7810 if (Type.isString(target)) { 7811 eventName = target; 7812 target = this.GLOBAL_TARGET;
7813 } 7814 if (Type.isStringFilled(eventName)) { 7815 const targetInfo = eventStore.get(target); 7816 if (targetInfo) { 7817 options = Type.isPlainObject(options) ? options : {}; 7818 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7819 targetInfo.eventsMap.delete(fullEventName); 7820 targetInfo.onceMap.delete(fullEventName); 7821 } 7822 } else if (Type.isNil(eventName)) { 7823 if (target === this.GLOBAL_TARGET) { 7824 console.error('You cannot unsubscribe all global listeners.'); 7825 } else { 7826 eventStore.delete(target); 7827 } 7828 } 7829 } 7830 }, { 7831 key: "emit", 7832 value: function emit(target, eventName, event, options) { 7833 if (Type.isString(target)) { 7834 options = event; 7835 event = eventName; 7836 eventName = target; 7837 target = this.GLOBAL_TARGET; 7838 } 7839 if (!Type.isObject(target)) { 7840 throw new TypeError(`The "target" argument must be an object.`); 7841 } 7842 eventName = this.normalizeEventName(eventName); 7843 if (!Type.isStringFilled(eventName)) { 7844 throw new TypeError(`The "eventName" argument must be a string.`); 7845 } 7846 options = Type.isPlainObject(options) ? options : {}; 7847 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7848 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 7849 const globalListeners = globalEvents && globalEvents.eventsMap.get(fullEventName) || new Map(); 7850 let targetListeners = new Set(); 7851 if (target !== this.GLOBAL_TARGET) { 7852 const targetEvents = eventStore.get(target); 7853 targetListeners = targetEvents && targetEvents.eventsMap.get(fullEventName) || new Map(); 7854 } 7855 const listeners = [...globalListeners.values(), ...targetListeners.values()]; 7856 listeners.sort(function (a, b) { 7857 return a.sort - b.sort; 7858 }); 7859 const preparedEvent = this.prepareEvent(target, fullEventName, event); 7860 const result = []; 7861 for (let i = 0; i < listeners.length; i++) { 7862 if (preparedEvent.isImmediatePropagationStopped()) { 7863 break; 7864 } 7865 const { 7866 listener, 7867 options: listenerOptions 7868 } = listeners[i]; 7869 7870 //A previous listener could remove a current listener. 7871 if (globalListeners.has(listener) || targetListeners.has(listener)) { 7872 let listenerResult; 7873 if (listenerOptions.compatMode) { 7874 let params = []; 7875 const compatData = preparedEvent.getCompatData(); 7876 if (compatData !== null) { 7877 params = options.cloneData === true ? Runtime.clone(compatData) : compatData; 7878 } else { 7879 params = [preparedEvent]; 7880 } 7881 const context = Type.isUndefined(options.thisArg) ? target : options.thisArg; 7882 listenerResult = listener.apply(context, params); 7883 } else { 7884 listenerResult = Type.isUndefined(options.thisArg) ? listener(preparedEvent) : listener.call(options.thisArg, preparedEvent); 7885 } 7886 result.push(listenerResult); 7887 } 7888 } 7889 return result; 7890 } 7891 }, { 7892 key: "emitAsync", 7893 value: function emitAsync(target, eventName, event) { 7894 if (Type.isString(target)) { 7895 event = eventName; 7896 eventName = target; 7897 target = this.GLOBAL_TARGET;
7898 } 7899 return Promise.all(this.emit(target, eventName, event)); 7900 } 7901 }, { 7902 key: "prepareEvent", 7903 value: function prepareEvent(target, eventName, event) { 7904 let preparedEvent = event; 7905 if (!(event instanceof BaseEvent)) { 7906 preparedEvent = new BaseEvent(); 7907 preparedEvent.setData(event); 7908 } 7909 preparedEvent.setTarget(this.isEventEmitter(target) ? target[targetProperty] : target); 7910 preparedEvent.setType(eventName); 7911 return preparedEvent; 7912 } 7913 /** 7914 * @private 7915 * @returns {number} 7916 */ 7917 }, { 7918 key: "getNextSequenceValue", 7919 value: function getNextSequenceValue() { 7920 return this.sequenceValue++; 7921 } 7922 /** 7923 * Sets max global events listeners count 7924 * Event.EventEmitter.setMaxListeners(10) - sets the default value for all events (global target) 7925 * Event.EventEmitter.setMaxListeners("onClose", 10) - sets the value for onClose event (global target) 7926 * Event.EventEmitter.setMaxListeners(obj, 10) - sets the default value for all events (obj target) 7927 * Event.EventEmitter.setMaxListeners(obj, "onClose", 10); - sets the value for onClose event (obj target) 7928 * @return {void} 7929 * @param args 7930 */ 7931 }, { 7932 key: "setMaxListeners", 7933 value: function setMaxListeners(...args) { 7934 let target = this.GLOBAL_TARGET;
7935 let eventName = null; 7936 let count = undefined; 7937 if (args.length === 1) { 7938 count = args[0]; 7939 } else if (args.length === 2) { 7940 if (Type.isString(args[0])) { 7941 [eventName, count] = args; 7942 } else { 7943 [target, count] = args; 7944 } 7945 } else if (args.length >= 3) { 7946 [target, eventName, count] = args; 7947 } 7948 if (!Type.isObject(target)) { 7949 throw new TypeError(`The "target" argument must be an object.`); 7950 } 7951 if (eventName !== null && !Type.isStringFilled(eventName)) { 7952 throw new TypeError(`The "eventName" argument must be a string.`); 7953 } 7954 if (!Type.isNumber(count) || count < 0) { 7955 throw new TypeError(`The value of "count" is out of range. It must be a non-negative number. Received ${count}.`); 7956 } 7957 const targetInfo = eventStore.getOrAdd(target); 7958 if (Type.isStringFilled(eventName)) { 7959 const fullEventName = this.resolveEventName(eventName, target); 7960 targetInfo.eventsMaxListeners.set(fullEventName, count); 7961 } else { 7962 targetInfo.maxListeners = count; 7963 } 7964 } 7965 }, { 7966 key: "getMaxListeners", 7967 value: function getMaxListeners(target, eventName) { 7968 if (Type.isString(target)) { 7969 eventName = target; 7970 target = this.GLOBAL_TARGET;
7971 } else if (Type.isNil(target)) { 7972 target = this.GLOBAL_TARGET; 7973 } 7974 if (!Type.isObject(target)) { 7975 throw new TypeError(`The "target" argument must be an object.`); 7976 } 7977 const targetInfo = eventStore.get(target); 7978 if (targetInfo) { 7979 let maxListeners = targetInfo.maxListeners; 7980 if (Type.isStringFilled(eventName)) { 7981 const fullEventName = this.resolveEventName(eventName, target); 7982 maxListeners = targetInfo.eventsMaxListeners.get(fullEventName) || maxListeners; 7983 } 7984 return maxListeners; 7985 } 7986 return this.DEFAULT_MAX_LISTENERS; 7987 } 7988 }, { 7989 key: "addMaxListeners", 7990 value: function addMaxListeners(...args) { 7991 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 7992 const maxListeners = Math.max(this.getMaxListeners(target, eventName) + increment, 0); 7993 if (Type.isStringFilled(eventName)) { 7994 EventEmitter.setMaxListeners(target, eventName, maxListeners); 7995 } else { 7996 EventEmitter.setMaxListeners(target, maxListeners); 7997 } 7998 return maxListeners; 7999 } 8000 /** 8001 * Increases max listeners count 8002 * 8003 * Event.EventEmitter.incrementMaxListeners() - adds one max listener for all events of global target 8004 * Event.EventEmitter.incrementMaxListeners(3) - adds three max listeners for all events of global target 8005 * Event.EventEmitter.incrementMaxListeners('onClose') - adds one max listener for onClose event of global target 8006 * Event.EventEmitter.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 8007 * 8008 * Event.EventEmitter.incrementMaxListeners(obj) - adds one max listener for all events of 'obj' target 8009 * Event.EventEmitter.incrementMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 8010 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 8011 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 8012 */ 8013 }, { 8014 key: "incrementMaxListeners", 8015 value: function incrementMaxListeners(...args) { 8016 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 8017 return this.addMaxListeners(target, eventName, Math.abs(increment)); 8018 } 8019 }, { 8020 key: "decrementMaxListeners", 8021 value: function decrementMaxListeners(...args) { 8022 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 8023 return this.addMaxListeners(target, eventName, -Math.abs(increment)); 8024 } 8025 }, { 8026 key: "destructMaxListenersArgs", 8027 value: function destructMaxListenersArgs(...args) { 8028 let eventName = null; 8029 let increment = 1; 8030 let target = this.GLOBAL_TARGET;
8031 if (args.length === 1) { 8032 if (Type.isNumber(args[0])) { 8033 increment = args[0]; 8034 } else if (Type.isString(args[0])) { 8035 eventName = args[0]; 8036 } else { 8037 target = args[0]; 8038 } 8039 } else if (args.length === 2) { 8040 if (Type.isString(args[0])) { 8041 [eventName, increment] = args; 8042 } else if (Type.isString(args[1])) { 8043 [target, eventName] = args; 8044 } else { 8045 [target, increment] = args; 8046 } 8047 } else if (args.length >= 3) { 8048 [target, eventName, increment] = args; 8049 } 8050 if (!Type.isObject(target)) { 8051 throw new TypeError(`The "target" argument must be an object.`); 8052 } 8053 if (eventName !== null && !Type.isStringFilled(eventName)) { 8054 throw new TypeError(`The "eventName" argument must be a string.`); 8055 } 8056 if (!Type.isNumber(increment)) { 8057 throw new TypeError(`The value of "increment" must be a number.`); 8058 } 8059 return [target, eventName, increment]; 8060 } 8061 /** 8062 * Gets listeners list for a specified event 8063 * @param {object} target 8064 * @param {string} eventName 8065 */ 8066 }, { 8067 key: "getListeners", 8068 value: function getListeners(target, eventName) { 8069 if (Type.isString(target)) { 8070 eventName = target; 8071 target = this.GLOBAL_TARGET;
8072 } 8073 if (!Type.isObject(target)) { 8074 throw new TypeError(`The "target" argument must be an object.`); 8075 } 8076 eventName = this.normalizeEventName(eventName); 8077 if (!Type.isStringFilled(eventName)) { 8078 throw new TypeError(`The "eventName" argument must be a string.`); 8079 } 8080 const targetInfo = eventStore.get(target); 8081 if (!targetInfo) { 8082 return new Map(); 8083 } 8084 const fullEventName = this.resolveEventName(eventName, target); 8085 return targetInfo.eventsMap.get(fullEventName) || new Map(); 8086 } 8087 }, { 8088 key: "registerAliases", 8089 value: function registerAliases(aliases) { 8090 aliases = this.normalizeAliases(aliases); 8091 Object.keys(aliases).forEach(alias => { 8092 aliasStore.set(alias, { 8093 eventName: aliases[alias].eventName, 8094 namespace: aliases[alias].namespace 8095 }); 8096 }); 8097 EventEmitter.mergeEventAliases(aliases); 8098 } 8099 /** 8100 * @private 8101 * @param aliases 8102 */ 8103 }, { 8104 key: "normalizeAliases", 8105 value: function normalizeAliases(aliases) { 8106 if (!Type.isPlainObject(aliases)) { 8107 throw new TypeError(`The "aliases" argument must be an object.`); 8108 } 8109 const result = Object.create(null); 8110 for (let alias in aliases) { 8111 if (!Type.isStringFilled(alias)) { 8112 throw new TypeError(`The alias must be an non-empty string.`); 8113 } 8114 const options = aliases[alias]; 8115 if (!options || !Type.isStringFilled(options.eventName) || !Type.isStringFilled(options.namespace)) { 8116 throw new TypeError(`The alias options must set the "eventName" and the "namespace".`); 8117 } 8118 alias = this.normalizeEventName(alias); 8119 result[alias] = { 8120 eventName: options.eventName, 8121 namespace: options.namespace 8122 }; 8123 } 8124 return result; 8125 } 8126 /** 8127 * @private 8128 */ 8129 }, { 8130 key: "mergeEventAliases", 8131 value: function mergeEventAliases(aliases) { 8132 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 8133 if (!globalEvents) { 8134 return; 8135 } 8136 Object.keys(aliases).forEach(alias => { 8137 const options = aliases[alias]; 8138 alias = this.normalizeEventName(alias); 8139 const fullEventName = this.makeFullEventName(options.namespace, options.eventName); 8140 const aliasListeners = globalEvents.eventsMap.get(alias); 8141 if (aliasListeners) { 8142 const listeners = globalEvents.eventsMap.get(fullEventName) || new Map(); 8143 globalEvents.eventsMap.set(fullEventName, new Map([...listeners, ...aliasListeners])); 8144 globalEvents.eventsMap.delete(alias); 8145 } 8146 const aliasOnceListeners = globalEvents.onceMap.get(alias); 8147 if (aliasOnceListeners) { 8148 const onceListeners = globalEvents.onceMap.get(fullEventName) || new Map(); 8149 globalEvents.onceMap.set(fullEventName, new Map([...onceListeners, ...aliasOnceListeners])); 8150 globalEvents.onceMap.delete(alias); 8151 } 8152 const aliasMaxListeners = globalEvents.eventsMaxListeners.get(alias); 8153 if (aliasMaxListeners) { 8154 const eventMaxListeners = globalEvents.eventsMaxListeners.get(fullEventName) || 0; 8155 globalEvents.eventsMaxListeners.set(fullEventName, Math.max(eventMaxListeners, aliasMaxListeners)); 8156 globalEvents.eventsMaxListeners.delete(alias); 8157 } 8158 }); 8159 } 8160 /** 8161 * Returns true if the target is an instance of Event.EventEmitter 8162 * @param {object} target 8163 * @returns {boolean} 8164 */ 8165 }, { 8166 key: "isEventEmitter", 8167 value: function isEventEmitter(target) { 8168 return Type.isObject(target) && target[isEmitterProperty] === true; 8169 } 8170 /** 8171 * @private 8172 * @param {string} eventName 8173 * @returns {string} 8174 */ 8175 }, { 8176 key: "normalizeEventName", 8177 value: function normalizeEventName(eventName) { 8178 if (!Type.isStringFilled(eventName)) { 8179 return ''; 8180 } 8181 return eventName.toLowerCase(); 8182 } 8183 /** 8184 * @private 8185 */ 8186 }, { 8187 key: "normalizeListener", 8188 value: function normalizeListener(listener) { 8189 if (Type.isString(listener)) { 8190 listener = Reflection.getClass(listener); 8191 } 8192 if (!Type.isFunction(listener)) { 8193 throw new TypeError(`The "listener" argument must be of type Function. Received type ${typeof listener}.`); 8194 } 8195 return listener; 8196 } 8197 /** 8198 * @private 8199 * @param eventName 8200 * @param target 8201 * @param useGlobalNaming 8202 * @returns {string} 8203 */ 8204 }, { 8205 key: "resolveEventName", 8206 value: function resolveEventName(eventName, target, useGlobalNaming = false) { 8207 eventName = this.normalizeEventName(eventName); 8208 if (!Type.isStringFilled(eventName)) { 8209 return ''; 8210 } 8211 if (this.isEventEmitter(target) && useGlobalNaming !== true) { 8212 if (target.getEventNamespace() !== null && eventName.includes('.')) { 8213 console.warn(`Possible the wrong event name "${eventName}".`); 8214 } 8215 eventName = target.getFullEventName(eventName); 8216 } else if (aliasStore.has(eventName)) { 8217 const { 8218 namespace, 8219 eventName: actualEventName 8220 } = aliasStore.get(eventName); 8221 eventName = this.makeFullEventName(namespace, actualEventName); 8222 } 8223 return eventName; 8224 } 8225 /** 8226 * @private 8227 * @param {string} namespace 8228 * @param {string} eventName 8229 * @returns {string} 8230 */ 8231 }, { 8232 key: "makeFullEventName", 8233 value: function makeFullEventName(namespace, eventName) { 8234 const fullName = Type.isStringFilled(namespace) ? `${namespace}:${eventName}` : eventName; 8235 return Type.isStringFilled(fullName) ? fullName.toLowerCase() : ''; 8236 } 8237 }]); 8238 return EventEmitter; 8239 }(); 8240 babelHelpers.defineProperty(EventEmitter, "GLOBAL_TARGET", globalTarget); 8241 babelHelpers.defineProperty(EventEmitter, "DEFAULT_MAX_LISTENERS", eventStore.getDefaultMaxListeners()); 8242 babelHelpers.defineProperty(EventEmitter, "sequenceValue", 1); 8243 8244 let stack = []; 8245 /** 8246 * For compatibility only 8247 * @type {boolean} 8248 */ 8249 // eslint-disable-next-line 8250 exports.isReady = false;
8251 function ready(handler) { 8252 if (!Type.isFunction(handler)) { 8253 return; 8254 } 8255 if (exports.isReady) { 8256 handler(); 8257 } else { 8258 stack.push(handler); 8259 } 8260 } 8261 bindOnce(document, 'DOMContentLoaded', () => { 8262 exports.isReady = true; 8263 stack.forEach(handler => { 8264 handler(); 8265 }); 8266 stack = []; 8267 }); 8268 8269 /** 8270 * @memberOf BX 8271 */ 8272 let Event = function Event() { 8273 babelHelpers.classCallCheck(this, Event); 8274 }; 8275 babelHelpers.defineProperty(Event, "bind", bind); 8276 babelHelpers.defineProperty(Event, "bindOnce", bindOnce); 8277 babelHelpers.defineProperty(Event, "unbind", unbind); 8278 babelHelpers.defineProperty(Event, "unbindAll", unbindAll); 8279 babelHelpers.defineProperty(Event, "ready", ready); 8280 babelHelpers.defineProperty(Event, "EventEmitter", EventEmitter); 8281 babelHelpers.defineProperty(Event, "BaseEvent", BaseEvent); 8282 8283 function encodeAttributeValue(value) { 8284 if (Type.isPlainObject(value) || Type.isArray(value)) { 8285 return JSON.stringify(value); 8286 } 8287 return Text.encode(Text.decode(value)); 8288 } 8289 8290 function decodeAttributeValue(value) { 8291 if (Type.isString(value)) { 8292 const decodedValue = Text.decode(value); 8293 let result; 8294 try { 8295 result = JSON.parse(decodedValue); 8296 } catch (e) { 8297 result = decodedValue; 8298 } 8299 if (result === decodedValue) { 8300 if (/^[\d.]+[.]?\d+$/.test(result)) { 8301 return Number(result); 8302 } 8303 } 8304 if (result === 'true' || result === 'false') { 8305 return Boolean(result); 8306 } 8307 return result; 8308 } 8309 return value; 8310 } 8311 8312 function getPageScroll() { 8313 const { 8314 documentElement, 8315 body 8316 } = document; 8317 const scrollTop = Math.max(window.pageYOffset || 0, documentElement ? documentElement.scrollTop : 0, body ? body.scrollTop : 0); 8318 const scrollLeft = Math.max(window.pageXOffset || 0, documentElement ? documentElement.scrollLeft : 0, body ? body.scrollLeft : 0); 8319 return { 8320 scrollTop, 8321 scrollLeft 8322 }; 8323 } 8324 8325 /** 8326 * @memberOf BX 8327 */ 8328 let Dom = /*#__PURE__*/function () { 8329 function Dom() { 8330 babelHelpers.classCallCheck(this, Dom); 8331 } 8332 babelHelpers.createClass(Dom, null, [{ 8333 key: "replace", 8334 /** 8335 * Replaces old html element to new html element 8336 * @param oldElement 8337 * @param newElement 8338 */ 8339 value: function replace(oldElement, newElement) { 8340 if (Type.isDomNode(oldElement) && Type.isDomNode(newElement)) { 8341 if (Type.isDomNode(oldElement.parentNode)) { 8342 oldElement.parentNode.replaceChild(newElement, oldElement); 8343 } 8344 } 8345 } 8346 /** 8347 * Removes element 8348 * @param element 8349 */ 8350 }, { 8351 key: "remove", 8352 value: function remove(element) { 8353 if (Type.isDomNode(element) && Type.isDomNode(element.parentNode)) { 8354 element.parentNode.removeChild(element); 8355 } 8356 } 8357 /** 8358 * Cleans element 8359 * @param element 8360 */ 8361 }, { 8362 key: "clean", 8363 value: function clean(element) { 8364 if (Type.isDomNode(element)) { 8365 while (element.childNodes.length > 0) { 8366 element.removeChild(element.firstChild); 8367 } 8368 return; 8369 } 8370 if (Type.isString(element)) { 8371 Dom.clean(document.getElementById(element)); 8372 } 8373 } 8374 /** 8375 * Inserts element before target element 8376 * @param current 8377 * @param target 8378 */ 8379 }, { 8380 key: "insertBefore", 8381 value: function insertBefore(current, target) { 8382 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8383 if (Type.isDomNode(target.parentNode)) { 8384 target.parentNode.insertBefore(current, target); 8385 } 8386 } 8387 } 8388 /** 8389 * Inserts element after target element 8390 * @param current 8391 * @param target 8392 */ 8393 }, { 8394 key: "insertAfter", 8395 value: function insertAfter(current, target) { 8396 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8397 if (Type.isDomNode(target.parentNode)) { 8398 const parent = target.parentNode; 8399 if (Type.isDomNode(target.nextSibling)) { 8400 parent.insertBefore(current, target.nextSibling); 8401 return; 8402 } 8403 parent.appendChild(current); 8404 } 8405 } 8406 } 8407 /** 8408 * Appends element to target element 8409 * @param current 8410 * @param target 8411 */ 8412 }, { 8413 key: "append", 8414 value: function append(current, target) { 8415 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8416 target.appendChild(current); 8417 } 8418 } 8419 /** 8420 * Prepends element to target element 8421 * @param current 8422 * @param target 8423 */ 8424 }, {
8425 key: "prepend", 8426 value: function prepend(current, target) { 8427 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8428 if (Type.isDomNode(target.firstChild)) { 8429 target.insertBefore(current, target.firstChild); 8430 return; 8431 } 8432 Dom.append(current, target); 8433 } 8434 } 8435 /** 8436 * Checks that element contains class name or class names 8437 * @param element 8438 * @param className 8439 * @return {Boolean} 8440 */ 8441 }, { 8442 key: "hasClass", 8443 value: function hasClass(element, className) { 8444 if (Type.isElementNode(element)) { 8445 if (Type.isString(className)) { 8446 const preparedClassName = className.trim(); 8447 if (preparedClassName.length > 0) { 8448 if (preparedClassName.includes(' ')) { 8449 return preparedClassName.split(' ').every(name => Dom.hasClass(element, name)); 8450 } 8451 if ('classList' in element) { 8452 return element.classList.contains(preparedClassName); 8453 } 8454 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8455 return element.getAttribute('class').split(' ').some(name => name === preparedClassName); 8456 } 8457 } 8458 } 8459 if (Type.isArray(className) && className.length > 0) { 8460 return className.every(name => Dom.hasClass(element, name)); 8461 } 8462 } 8463 return false; 8464 } 8465 /** 8466 * Adds class name 8467 * @param element 8468 * @param className 8469 */ 8470 }, { 8471 key: "addClass", 8472 value: function addClass(element, className) { 8473 if (Type.isElementNode(element)) { 8474 if (Type.isString(className)) { 8475 const preparedClassName = className.trim(); 8476 if (preparedClassName.length > 0) { 8477 if (preparedClassName.includes(' ')) { 8478 Dom.addClass(element, preparedClassName.split(' ')); 8479 return; 8480 } 8481 if ('classList' in element) { 8482 element.classList.add(preparedClassName); 8483 return; 8484 } 8485 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8486 if (element.className.baseVal === '') { 8487 element.className.baseVal = preparedClassName; 8488 return; 8489 } 8490 const names = element.className.baseVal.split(' '); 8491 if (!names.includes(preparedClassName)) { 8492 names.push(preparedClassName); 8493 element.className.baseVal = names.join(' ').trim(); 8494 return; 8495 } 8496 } 8497 return; 8498 } 8499 } 8500 if (Type.isArray(className)) { 8501 className.forEach(name => Dom.addClass(element, name)); 8502 } 8503 } 8504 } 8505 /** 8506 * Removes class name 8507 * @param element 8508 * @param className 8509 */ 8510 }, { 8511 key: "removeClass", 8512 value: function removeClass(element, className) { 8513 if (Type.isElementNode(element)) { 8514 if (Type.isString(className)) { 8515 const preparedClassName = className.trim(); 8516 if (preparedClassName.length > 0) { 8517 if (preparedClassName.includes(' ')) { 8518 Dom.removeClass(element, preparedClassName.split(' ')); 8519 return; 8520 } 8521 if ('classList' in element) { 8522 element.classList.remove(preparedClassName); 8523 return; 8524 } 8525 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8526 const names = element.className.baseVal.split(' ').filter(name => name !== preparedClassName); 8527 element.className.baseVal = names.join(' '); 8528 return; 8529 } 8530 } 8531 } 8532 if (Type.isArray(className)) { 8533 className.forEach(name => Dom.removeClass(element, name)); 8534 } 8535 } 8536 } 8537 /** 8538 * Toggles class name 8539 * @param element 8540 * @param className 8541 */ 8542 }, { 8543 key: "toggleClass", 8544 value: function toggleClass(element, className) { 8545 if (Type.isElementNode(element)) { 8546 if (Type.isString(className)) { 8547 const preparedClassName = className.trim(); 8548 if (preparedClassName.length > 0) { 8549 if (preparedClassName.includes(' ')) { 8550 Dom.toggleClass(element, preparedClassName.split(' ')); 8551 return; 8552 } 8553 element.classList.toggle(preparedClassName); 8554 return; 8555 } 8556 } 8557 if (Type.isArray(className)) { 8558 className.forEach(name => Dom.toggleClass(element, name)); 8559 } 8560 } 8561 } 8562 /** 8563 * Styles element 8564 */ 8565 }, { 8566 key: "style", 8567 value: function style(element, prop, value) { 8568 if (Type.isElementNode(element)) { 8569 if (Type.isNull(prop)) { 8570 element.removeAttribute('style'); 8571 return element; 8572 } 8573 if (Type.isPlainObject(prop)) {
8574 Object.entries(prop).forEach(item => { 8575 const [currentKey, currentValue] = item; 8576 Dom.style(element, currentKey, currentValue); 8577 }); 8578 return element; 8579 } 8580 if (Type.isString(prop)) { 8581 if (Type.isUndefined(value) && element.nodeType !== Node.DOCUMENT_NODE) { 8582 const computedStyle = getComputedStyle(element); 8583 if (prop in computedStyle) { 8584 return computedStyle[prop]; 8585 } 8586 return computedStyle.getPropertyValue(prop); 8587 } 8588 if (Type.isNull(value) || value === '' || value === 'null') { 8589 if (String(prop).startsWith('--')) { 8590 // eslint-disable-next-line 8591 element.style.removeProperty(prop); 8592 return element; 8593 } 8594 8595 // eslint-disable-next-line 8596 element.style[prop] = ''; 8597 return element; 8598 } 8599 if (Type.isString(value) || Type.isNumber(value)) { 8600 if (String(prop).startsWith('--')) { 8601 // eslint-disable-next-line 8602 element.style.setProperty(prop, value); 8603 return element; 8604 } 8605 8606 // eslint-disable-next-line 8607 element.style[prop] = value; 8608 return element; 8609 } 8610 } 8611 } 8612 return null; 8613 } 8614 /** 8615 * Adjusts element 8616 * @param target 8617 * @param data 8618 * @return {*} 8619 */ 8620 }, { 8621 key: "adjust", 8622 value: function adjust(target, data = {}) { 8623 if (!target.nodeType) { 8624 return null; 8625 } 8626 let element = target; 8627 if (target.nodeType === Node.DOCUMENT_NODE) { 8628 element = target.body; 8629 } 8630 if (Type.isPlainObject(data)) { 8631 if (Type.isPlainObject(data.attrs)) { 8632 Object.keys(data.attrs).forEach(key => { 8633 if (key === 'class' || key.toLowerCase() === 'classname') { 8634 element.className = data.attrs[key]; 8635 return; 8636 } 8637 8638 // eslint-disable-next-line 8639 if (data.attrs[key] == '') { 8640 element.removeAttribute(key); 8641 return; 8642 } 8643 element.setAttribute(key, data.attrs[key]); 8644 }); 8645 } 8646 if (Type.isPlainObject(data.style)) { 8647 Dom.style(element, data.style); 8648 } 8649 if (Type.isPlainObject(data.props)) { 8650 Object.keys(data.props).forEach(key => { 8651 element[key] = data.props[key]; 8652 }); 8653 } 8654 if (Type.isPlainObject(data.events)) { 8655 Object.keys(data.events).forEach(key => { 8656 Event.bind(element, key, data.events[key]); 8657 }); 8658 } 8659 if (Type.isPlainObject(data.dataset)) { 8660 Object.keys(data.dataset).forEach(key => { 8661 element.dataset[key] = data.dataset[key]; 8662 }); 8663 } 8664 if (Type.isString(data.children)) { 8665 data.children = [data.children]; 8666 } 8667 if (Type.isArray(data.children) && data.children.length > 0) { 8668 data.children.forEach(item => { 8669 if (Type.isDomNode(item)) { 8670 Dom.append(item, element); 8671 } 8672 if (Type.isString(item)) { 8673 element.insertAdjacentHTML('beforeend', item); 8674 } 8675 }); 8676 return element; 8677 } 8678 if ('text' in data && !Type.isNil(data.text)) { 8679 element.innerText = data.text; 8680 return element; 8681 } 8682 if ('html' in data && !Type.isNil(data.html)) { 8683 element.innerHTML = data.html; 8684 } 8685 } 8686 return element; 8687 } 8688 /** 8689 * Creates element 8690 * @param tag 8691 * @param data 8692 * @param context 8693 * @return {HTMLElement|HTMLBodyElement} 8694 */ 8695 }, { 8696 key: "create", 8697 value: function create(tag, data = {}, context = document) { 8698 let tagName = tag; 8699 let options = data; 8700 if (Type.isObjectLike(tag)) { 8701 options = tag; 8702 tagName = tag.tag; 8703 } 8704 return Dom.adjust(context.createElement(tagName), options); 8705 } 8706 /** 8707 * Shows element 8708 * @param element 8709 */ 8710 }, { 8711 key: "show", 8712 value: function show(element) { 8713 if (Type.isDomNode(element)) { 8714 // eslint-disable-next-line 8715 element.hidden = false;
8716 } 8717 } 8718 /** 8719 * Hides element 8720 * @param element 8721 */ 8722 }, { 8723 key: "hide", 8724 value: function hide(element) { 8725 if (Type.isDomNode(element)) { 8726 // eslint-disable-next-line 8727 element.hidden = true; 8728 } 8729 } 8730 /** 8731 * Checks that element is shown 8732 * @param element 8733 * @return {*|boolean} 8734 */ 8735 }, { 8736 key: "isShown", 8737 value: function isShown(element) { 8738 return Type.isDomNode(element) && !element.hidden && element.style.getPropertyValue('display') !== 'none'; 8739 } 8740 /** 8741 * Toggles element visibility 8742 * @param element 8743 */ 8744 }, { 8745 key: "toggle", 8746 value: function toggle(element) { 8747 if (Type.isDomNode(element)) { 8748 if (Dom.isShown(element)) { 8749 Dom.hide(element); 8750 } else { 8751 Dom.show(element); 8752 } 8753 } 8754 } 8755 /** 8756 * Gets element position relative page 8757 * @param {HTMLElement} element 8758 * @return {DOMRect} 8759 */ 8760 }, { 8761 key: "getPosition", 8762 value: function getPosition(element) { 8763 if (Type.isDomNode(element)) { 8764 const elementRect = element.getBoundingClientRect(); 8765 const { 8766 scrollLeft, 8767 scrollTop 8768 } = getPageScroll(); 8769 return new DOMRect(elementRect.left + scrollLeft, elementRect.top + scrollTop, elementRect.width, elementRect.height); 8770 } 8771 return new DOMRect(); 8772 } 8773 /** 8774 * Gets element position relative specified element position 8775 * @param {HTMLElement} element 8776 * @param {HTMLElement} relationElement 8777 * @return {DOMRect} 8778 */ 8779 }, { 8780 key: "getRelativePosition", 8781 value: function getRelativePosition(element, relationElement) { 8782 if (Type.isDomNode(element) && Type.isDomNode(relationElement)) { 8783 const elementPosition = Dom.getPosition(element); 8784 const relationElementPosition = Dom.getPosition(relationElement); 8785 return new DOMRect(elementPosition.left - relationElementPosition.left, elementPosition.top - relationElementPosition.top, elementPosition.width, elementPosition.height); 8786 } 8787 return new DOMRect(); 8788 } 8789 }, { 8790 key: "attr", 8791 value: function attr(element, _attr, value) { 8792 if (Type.isElementNode(element)) { 8793 if (Type.isString(_attr)) { 8794 if (!Type.isNil(value)) { 8795 return element.setAttribute(_attr, encodeAttributeValue(value)); 8796 } 8797 if (Type.isNull(value)) { 8798 return element.removeAttribute(_attr); 8799 } 8800 return decodeAttributeValue(element.getAttribute(_attr)); 8801 } 8802 if (Type.isPlainObject(_attr)) { 8803 return Object.entries(_attr).forEach(([attrKey, attrValue]) => { 8804 Dom.attr(element, attrKey, attrValue); 8805 }); 8806 } 8807 } 8808 return null; 8809 } 8810 }]); 8811 return Dom; 8812 }(); 8813 8814 const UA = navigator.userAgent.toLowerCase(); 8815 8816 /** 8817 * @memberOf BX 8818 */ 8819 let Browser = /*#__PURE__*/function () { 8820 function Browser() { 8821 babelHelpers.classCallCheck(this, Browser); 8822 } 8823 babelHelpers.createClass(Browser, null, [{ 8824 key: "isOpera", 8825 value: function isOpera() { 8826 return UA.includes('opera'); 8827 } 8828 }, { 8829 key: "isIE", 8830 value: function isIE() { 8831 return 'attachEvent' in document && !Browser.isOpera(); 8832 } 8833 }, { 8834 key: "isIE6", 8835 value: function isIE6() { 8836 return UA.includes('msie 6'); 8837 } 8838 }, { 8839 key: "isIE7", 8840 value: function isIE7() { 8841 return UA.includes('msie 7'); 8842 } 8843 }, { 8844 key: "isIE8", 8845 value: function isIE8() { 8846 return UA.includes('msie 8'); 8847 } 8848 }, { 8849 key: "isIE9", 8850 value: function isIE9() { 8851 return 'documentMode' in document && document.documentMode >= 9; 8852 } 8853 }, { 8854 key: "isIE10", 8855 value: function isIE10() { 8856 return 'documentMode' in document && document.documentMode >= 10; 8857 } 8858 }, { 8859 key: "isSafari", 8860 value: function isSafari() { 8861 return UA.includes('safari') && !UA.includes('chrome'); 8862 } 8863 }, { 8864 key: "isFirefox", 8865 value: function isFirefox() { 8866 return UA.includes('firefox'); 8867 } 8868 }, { 8869 key: "isChrome", 8870 value: function isChrome() { 8871 return UA.includes('chrome'); 8872 } 8873 }, { 8874 key: "detectIEVersion", 8875 value: function detectIEVersion() { 8876 if (Browser.isOpera() || Browser.isSafari() || Browser.isFirefox() || Browser.isChrome()) { 8877 return -1; 8878 } 8879 let rv = -1; 8880 if (!!window.MSStream && !window.ActiveXObject && 'ActiveXObject' in window) { 8881 rv = 11; 8882 } else if (Browser.isIE10()) { 8883 rv = 10; 8884 } else if (Browser.isIE9()) { 8885 rv = 9; 8886 } else if (Browser.isIE()) { 8887 rv = 8; 8888 } 8889 if (rv === -1 || rv === 8) { 8890 if (navigator.appName === 'Microsoft Internet Explorer') { 8891 const re = new RegExp('MSIE ([0-9]+[.0-9]*)'); 8892 const res = navigator.userAgent.match(re); 8893 if (Type.isArrayLike(res) && res.length > 0) { 8894 rv = parseFloat(res[1]); 8895 } 8896 } 8897 if (navigator.appName === 'Netscape') { 8898 // Alternative check for IE 11 8899 rv = 11; 8900 const re = new RegExp('Trident/.*rv:([0-9]+[.0-9]*)'); 8901 if (re.exec(navigator.userAgent) != null) { 8902 const res = navigator.userAgent.match(re); 8903 if (Type.isArrayLike(res) && res.length > 0) { 8904 rv = parseFloat(res[1]); 8905 } 8906 } 8907 } 8908 } 8909 return rv; 8910 } 8911 }, { 8912 key: "isIE11", 8913 value: function isIE11() { 8914 return Browser.detectIEVersion() >= 11; 8915 } 8916 }, { 8917 key: "isMac", 8918 value: function isMac() { 8919 return UA.includes('macintosh'); 8920 } 8921 }, { 8922 key: "isWin", 8923 value: function isWin() { 8924 return UA.includes('windows'); 8925 } 8926 }, { 8927 key: "isLinux", 8928 value: function isLinux() { 8929 return UA.includes('linux') && !Browser.isAndroid(); 8930 } 8931 }, { 8932 key: "isAndroid", 8933 value: function isAndroid() { 8934 return UA.includes('android'); 8935 } 8936 }, { 8937 key: "isIPad", 8938 value: function isIPad() { 8939 return UA.includes('ipad;') || this.isMac() && this.isTouchDevice(); 8940 } 8941 }, { 8942 key: "isIPhone", 8943 value: function isIPhone() { 8944 return UA.includes('iphone;'); 8945 } 8946 }, { 8947 key: "isIOS", 8948 value: function isIOS() { 8949 return Browser.isIPad() || Browser.isIPhone(); 8950 } 8951 }, { 8952 key: "isMobile", 8953 value: function isMobile() { 8954 return Browser.isIPhone() || Browser.isIPad() || Browser.isAndroid() || UA.includes('mobile') || UA.includes('touch'); 8955 } 8956 }, { 8957 key: "isRetina", 8958 value: function isRetina() { 8959 return window.devicePixelRatio && window.devicePixelRatio >= 2; 8960 } 8961 }, { 8962 key: "isTouchDevice", 8963 value: function isTouchDevice() { 8964 return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; 8965 } 8966 }, { 8967 key: "isDoctype", 8968 value: function isDoctype(target) { 8969 const doc = target || document; 8970 if (doc.compatMode) { 8971 return doc.compatMode === 'CSS1Compat'; 8972 } 8973 return doc.documentElement && doc.documentElement.clientHeight; 8974 } 8975 }, { 8976 key: "isLocalStorageSupported", 8977 value: function isLocalStorageSupported() { 8978 try { 8979 localStorage.setItem('test', 'test'); 8980 localStorage.removeItem('test'); 8981 return true; 8982 } catch (e) { 8983 return false;
8984 } 8985 } 8986 }, { 8987 key: "addGlobalClass", 8988 value: function addGlobalClass(target) { 8989 let globalClass = 'bx-core'; 8990 target = Type.isElementNode(target) ? target : document.documentElement; 8991 if (Dom.hasClass(target, globalClass)) { 8992 return; 8993 } 8994 if (Browser.isIOS()) { 8995 globalClass += ' bx-ios'; 8996 } else if (Browser.isWin()) { 8997 globalClass += ' bx-win'; 8998 } else if (Browser.isMac()) { 8999 globalClass += ' bx-mac'; 9000 } else if (Browser.isLinux()) { 9001 globalClass += ' bx-linux'; 9002 } else if (Browser.isAndroid()) { 9003 globalClass += ' bx-android'; 9004 } 9005 globalClass += Browser.isMobile() ? ' bx-touch' : ' bx-no-touch'; 9006 globalClass += Browser.isRetina() ? ' bx-retina' : ' bx-no-retina'; 9007 if (/AppleWebKit/.test(navigator.userAgent)) { 9008 globalClass += ' bx-chrome'; 9009 } else if (/Opera/.test(navigator.userAgent)) { 9010 globalClass += ' bx-opera'; 9011 } else if (Browser.isFirefox()) { 9012 globalClass += ' bx-firefox'; 9013 } 9014 Dom.addClass(target, globalClass); 9015 } 9016 }, { 9017 key: "detectAndroidVersion", 9018 value: function detectAndroidVersion() { 9019 const re = new RegExp('Android ([0-9]+[.0-9]*)'); 9020 if (re.exec(navigator.userAgent) != null) { 9021 const res = navigator.userAgent.match(re); 9022 if (Type.isArrayLike(res) && res.length > 0) { 9023 return parseFloat(res[1]); 9024 } 9025 } 9026 return 0; 9027 } 9028 }, { 9029 key: "isPropertySupported", 9030 value: function isPropertySupported(jsProperty, returnCSSName) { 9031 if (jsProperty === '') { 9032 return false; 9033 } 9034 function getCssName(propertyName) { 9035 return propertyName.replace(/([A-Z])/g, (...args) => `-${args[1].toLowerCase()}`); 9036 } 9037 function getJsName(cssName) { 9038 const reg = /(\\-([a-z]))/g; 9039 if (reg.test(cssName)) { 9040 return cssName.replace(reg, (...args) => args[2].toUpperCase()); 9041 } 9042 return cssName; 9043 } 9044 const property = jsProperty.includes('-') ? getJsName(jsProperty) : jsProperty; 9045 const bReturnCSSName = !!returnCSSName; 9046 const ucProperty = property.charAt(0).toUpperCase() + property.slice(1); 9047 const props = ['Webkit', 'Moz', 'O', 'ms'].join(`${ucProperty} `); 9048 const properties = `${property} ${props} ${ucProperty}`.split(' '); 9049 const obj = document.body || document.documentElement; 9050 for (let i = 0; i < properties.length; i += 1) { 9051 const prop = properties[i]; 9052 if (obj && 'style' in obj && prop in obj.style) { 9053 const lowerProp = prop.substr(0, prop.length - property.length).toLowerCase(); 9054 const prefix = prop === property ? '' : `-${lowerProp}-`; 9055 return bReturnCSSName ? prefix + getCssName(property) : prop; 9056 } 9057 } 9058 return false; 9059 } 9060 }, { 9061 key: "addGlobalFeatures", 9062 value: function addGlobalFeatures(features) { 9063 if (!Type.isArray(features)) { 9064 return; 9065 } 9066 const classNames = []; 9067 for (let i = 0; i < features.length; i += 1) { 9068 const support = !!Browser.isPropertySupported(features[i]); 9069 classNames.push(`bx-${support ? '' : 'no-'}${features[i].toLowerCase()}`); 9070 } 9071 Dom.addClass(document.documentElement, classNames.join(' ')); 9072 } 9073 }]); 9074 return Browser; 9075 }(); 9076 9077 let Cookie = /*#__PURE__*/function () { 9078 function Cookie() { 9079 babelHelpers.classCallCheck(this, Cookie); 9080 } 9081 babelHelpers.createClass(Cookie, null, [{ 9082 key: "getList", 9083 /** 9084 * Gets cookies list for current domain 9085 * @return {object} 9086 */ 9087 value: function getList() { 9088 return document.cookie.split(';').map(item => item.split('=')).map(item => item.map(subItem => subItem.trim())).reduce((acc, item) => { 9089 const [key, value] = item; 9090 acc[decodeURIComponent(key)] = decodeURIComponent(value); 9091 return acc; 9092 }, {}); 9093 } 9094 /** 9095 * Gets cookie value 9096 * @param {string} name 9097 * @return {*} 9098 */ 9099 }, { 9100 key: "get", 9101 value: function get(name) { 9102 const cookiesList = Cookie.getList(); 9103 if (name in cookiesList) { 9104 return cookiesList[name]; 9105 } 9106 return undefined; 9107 } 9108 /** 9109 * Sets cookie 9110 * @param {string} name 9111 * @param {*} value 9112 * @param {object} [options] 9113 */ 9114 }, { 9115 key: "set", 9116 value: function set(name, value, options = {}) { 9117 const attributes = { 9118 expires: '', 9119 ...options 9120 }; 9121 if (Type.isNumber(attributes.expires)) { 9122 const now = +new Date(); 9123 const days = attributes.expires; 9124 const dayInMs = 864e+5; 9125 attributes.expires = new Date(now + days * dayInMs); 9126 } 9127 if (Type.isDate(attributes.expires)) { 9128 attributes.expires = attributes.expires.toUTCString(); 9129 } 9130 const safeName = decodeURIComponent(String(name)).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape); 9131 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); 9132 const stringifiedAttributes = Object.keys(attributes).reduce((acc, key) => { 9133 const attributeValue = attributes[key]; 9134 if (!attributeValue) { 9135 return acc; 9136 } 9137 if (attributeValue === true) { 9138 return `${acc}; ${key}`; 9139 } 9140 9141 /** 9142 * Considers RFC 6265 section 5.2: 9143 * ... 9144 * 3. If the remaining unparsed-attributes contains a %x3B (';') 9145 * character: 9146 * Consume the characters of the unparsed-attributes up to, 9147 * not including, the first %x3B (';') character. 9148 */ 9149 return `${acc}; ${key}=${attributeValue.split(';')[0]}`; 9150 }, ''); 9151 document.cookie = `${safeName}=${safeValue}${stringifiedAttributes}`; 9152 } 9153 /** 9154 * Removes cookie 9155 * @param {string} name 9156 * @param {object} [options] 9157 */ 9158 }, { 9159 key: "remove", 9160 value: function remove(name, options = {}) { 9161 Cookie.set(name, '', { 9162 ...options, 9163 expires: -1 9164 }); 9165 } 9166 }]); 9167 return Cookie; 9168 }(); 9169 9170 function objectToFormData(source, formData = new FormData(), pre = null) { 9171 if (Type.isUndefined(source)) { 9172 return formData; 9173 } 9174 if (Type.isNull(source)) { 9175 formData.append(pre, ''); 9176 } else if (Type.isArray(source)) { 9177 if (!source.length) {
9178 const key = `${pre}[]`; 9179 formData.append(key, ''); 9180 } else { 9181 source.forEach((value, index) => { 9182 const key = `${pre}[${index}]`; 9183 objectToFormData(value, formData, key); 9184 }); 9185 } 9186 } else if (Type.isDate(source)) { 9187 formData.append(pre, source.toISOString()); 9188 } else if (Type.isObject(source) && !Type.isFile(source) && !Type.isBlob(source)) { 9189 Object.keys(source).forEach(property => { 9190 const value = source[property]; 9191 let preparedProperty = property; 9192 if (Type.isArray(value)) { 9193 while (preparedProperty.length > 2 && preparedProperty.lastIndexOf('[]') === preparedProperty.length - 2) { 9194 preparedProperty = preparedProperty.substring(0, preparedProperty.length - 2); 9195 } 9196 } 9197 const key = pre ? `${pre}[${preparedProperty}]` : preparedProperty; 9198 objectToFormData(value, formData, key); 9199 }); 9200 } else { 9201 formData.append(pre, source); 9202 } 9203 return formData; 9204 } 9205 9206 let Data = /*#__PURE__*/function () { 9207 function Data() { 9208 babelHelpers.classCallCheck(this, Data); 9209 } 9210 babelHelpers.createClass(Data, null, [{ 9211 key: "convertObjectToFormData", 9212 /** 9213 * Converts object to FormData 9214 * @param source 9215 * @return {FormData} 9216 */ 9217 value: function convertObjectToFormData(source) { 9218 return objectToFormData(source); 9219 } 9220 }]); 9221 return Data; 9222 }(); 9223 9224 /** 9225 * @memberOf BX 9226 */ 9227 let Http = function Http() { 9228 babelHelpers.classCallCheck(this, Http); 9229 }; 9230 babelHelpers.defineProperty(Http, "Cookie", Cookie); 9231 babelHelpers.defineProperty(Http, "Data", Data); 9232 9233 function message(value) { 9234 if (Type.isString(value)) { 9235 if (Type.isNil(message[value])) { 9236 // eslint-disable-next-line 9237 EventEmitter.emit('onBXMessageNotFound', new BaseEvent({ 9238 compatData: [value] 9239 })); 9240 if (Type.isNil(message[value])) { 9241 Runtime.debug(`message undefined: ${value}`); 9242 message[value] = ''; 9243 } 9244 } 9245 } 9246 if (Type.isPlainObject(value)) { 9247 Object.keys(value).forEach(key => { 9248 message[key] = value[key]; 9249 }); 9250 } 9251 return message[value]; 9252 } 9253 if (!Type.isNil(window.BX) && Type.isFunction(window.BX.message)) { 9254 Object.keys(window.BX.message).forEach(key => { 9255 message({ 9256 [key]: window.BX.message[key] 9257 }); 9258 }); 9259 } 9260 9261 /** 9262 * Implements interface for works with language messages 9263 * @memberOf BX 9264 */ 9265 let Loc = /*#__PURE__*/function () { 9266 function Loc() { 9267 babelHelpers.classCallCheck(this, Loc); 9268 } 9269 babelHelpers.createClass(Loc, null, [{ 9270 key: "getMessage", 9271 /** 9272 * Gets message by id 9273 * @param {string} messageId 9274 * @param {object} replacements 9275 * @return {?string} 9276 */ 9277 value: function getMessage(messageId, replacements = null) { 9278 let mess = message(messageId); 9279 if (Type.isString(mess) && Type.isPlainObject(replacements)) { 9280 const escape = str => String(str).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&'); 9281 Object.keys(replacements).forEach(replacement => { 9282 const globalRegexp = new RegExp(escape(replacement), 'gi'); 9283 mess = mess.replace(globalRegexp, () => { 9284 return Type.isNil(replacements[replacement]) ? '' : String(replacements[replacement]); 9285 }); 9286 }); 9287 } 9288 return mess; 9289 } 9290 }, { 9291 key: "hasMessage", 9292 value: function hasMessage(messageId) { 9293 return Type.isString(messageId) && !Type.isNil(message[messageId]); 9294 } 9295 /** 9296 * Sets message or messages 9297 * @param {string | Object<string, string>} id 9298 * @param {string} [value] 9299 */ 9300 }, { 9301 key: "setMessage", 9302 value: function setMessage(id, value) { 9303 if (Type.isString(id) && Type.isString(value)) { 9304 message({ 9305 [id]: value 9306 }); 9307 } 9308 if (Type.isObject(id)) { 9309 message(id); 9310 } 9311 } 9312 /** 9313 * Gets plural message by id and number 9314 * @param {string} messageId 9315 * @param {number} value 9316 * @param {object} [replacements] 9317 * @return {?string} 9318 */ 9319 }, { 9320 key: "getMessagePlural",
9321 value: function getMessagePlural(messageId, value, replacements = null) { 9322 let result = ''; 9323 if (Type.isNumber(value)) { 9324 if (this.hasMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`)) { 9325 result = this.getMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`, replacements); 9326 } else { 9327 result = this.getMessage(`${messageId}_PLURAL_1`, replacements); 9328 } 9329 } else { 9330 result = this.getMessage(messageId, replacements); 9331 } 9332 return result; 9333 } 9334 /** 9335 * Gets language plural form id by number 9336 * see http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html 9337 * @param {number} value 9338 * @param {string} [languageId] 9339 * @return {?number} 9340 */ 9341 }, { 9342 key: "getPluralForm", 9343 value: function getPluralForm(value, languageId) { 9344 let pluralForm; 9345 if (!Type.isStringFilled(languageId)) { 9346 languageId = message('LANGUAGE_ID'); 9347 } 9348 if (value < 0) { 9349 value = -1 * value; 9350 } 9351 switch (languageId) { 9352 case 'ar': 9353 pluralForm = value !== 1 ? 1 : 0; 9354 /* 9355 if (value === 0) 9356 { 9357 pluralForm = 0; 9358 } 9359 else if (value === 1) 9360 { 9361 pluralForm = 1; 9362 } 9363 else if (value === 2) 9364 { 9365 pluralForm = 2; 9366 } 9367 else if ( 9368 value % 100 >= 3 9369 && value % 100 <= 10 9370 ) 9371 { 9372 pluralForm = 3; 9373 } 9374 else if (value % 100 >= 11) 9375 { 9376 pluralForm = 4; 9377 } 9378 else 9379 { 9380 pluralForm = 5; 9381 } 9382 */ 9383 break; 9384 case 'br': 9385 case 'fr': 9386 case 'tr': 9387 pluralForm = value > 1 ? 1 : 0; 9388 break; 9389 case 'de': 9390 case 'en': 9391 case 'hi': 9392 case 'it': 9393 case 'la': 9394 pluralForm = value !== 1 ? 1 : 0; 9395 break; 9396 case 'ru': 9397 case 'ua': 9398 if (value % 10 === 1 && value % 100 !== 11) { 9399 pluralForm = 0; 9400 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9401 pluralForm = 1; 9402 } else { 9403 pluralForm = 2; 9404 } 9405 break; 9406 case 'pl': 9407 if (value === 1) { 9408 pluralForm = 0; 9409 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9410 pluralForm = 1; 9411 } else { 9412 pluralForm = 2; 9413 } 9414 break; 9415 case 'id': 9416 case 'ja': 9417 case 'ms': 9418 case 'sc': 9419 case 'tc': 9420 case 'th': 9421 case 'vn': 9422 pluralForm = 0; 9423 break; 9424 default: 9425 pluralForm = 1; 9426 break; 9427 } 9428 return pluralForm; 9429 } 9430 }]); 9431 return Loc; 9432 }(); 9433 9434 const voidElements = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr']; 9435 function isVoidElement(element) { 9436 return voidElements.includes(element); 9437 } 9438 9439 const matchers = { 9440 tag: /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>|{{uid[0-9]+}}/g, 9441 comment: /<!--(?!<!)[^\[>].*?-->/g, 9442 tagName: /<\/?([^\s]+?)[/\s>]/, 9443 attributes: /\s([\w\-_:.]+)\s?\n?=\s?\n?"([^"]+)?"|\s([\w\-_:.]+)\s?\n?=\s?\n?'([^']+)?'|\s([\w\-_:.]+)/gs, 9444 placeholder: /{{uid[0-9]+}}/g 9445 }; 9446 9447 function parseTag(tag) { 9448 const tagResult = { 9449 type: 'tag', 9450 name: '', 9451 svg: false, 9452 attrs: {}, 9453 children: [], 9454 voidElement: false 9455 }; 9456 if (tag.startsWith('<!--')) { 9457 const endIndex = tag.indexOf('-->'); 9458 const openTagLength = '<!--'.length; 9459 return { 9460 type: 'comment', 9461 content: endIndex !== -1 ? tag.slice(openTagLength, endIndex) : '' 9462 }; 9463 } 9464 const tagNameMatch = tag.match(matchers.tagName); 9465 if (Type.isArrayFilled(tagNameMatch)) { 9466 const [, tagName] = tagNameMatch; 9467 tagResult.name = tagName; 9468 tagResult.svg = tagName === 'svg'; 9469 tagResult.voidElement = isVoidElement(tagName) || tag.trim().endsWith('/>'); 9470 } 9471 const reg = new RegExp(matchers.attributes); 9472 for (;;) { 9473 const result = reg.exec(tag); 9474 if (!Type.isNil(result)) { 9475 // Attributes with double quotes 9476 const [, attrName, attrValue] = result; 9477 if (!Type.isNil(attrName)) { 9478 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9479 } else { 9480 // Attributes with single quotes 9481 const [,,, attrName, attrValue] = result; 9482 if (!Type.isNil(attrName)) { 9483 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9484 } else { 9485 // Attributes without value 9486 const [,,,,, attrName] = result; 9487 tagResult.attrs[attrName] = ''; 9488 } 9489 } 9490 } else { 9491 break; 9492 } 9493 } 9494 return tagResult; 9495 } 9496 9497 function parseText(input) { 9498 const preparedText = input.replace(/[\n\r\t]$/, ''); 9499 const placeholders = preparedText.match(matchers.placeholder); 9500 return preparedText.split(matchers.placeholder).reduce((acc, item, index) => { 9501 if (Type.isStringFilled(item)) { 9502 acc.push(...item.split(/\n/).reduce((textAcc, text) => { 9503 const preparedItemText = text.replace(/[\t\r]/g, ''); 9504 if (Type.isStringFilled(preparedItemText)) { 9505 textAcc.push({ 9506 type: 'text', 9507 content: preparedItemText 9508 }); 9509 } 9510 return textAcc; 9511 }, [])); 9512 } 9513 if (placeholders && placeholders[index]) { 9514 acc.push({ 9515 type: 'placeholder', 9516 uid: parseInt(placeholders[index].replace(/{{uid|}}/, '')) 9517 }); 9518 } 9519 return acc; 9520 }, []); 9521 } 9522 9523 function parse(html, substitutions) { 9524 const result = []; 9525 if (html.indexOf('<') !== 0 && !html.startsWith('{{')) { 9526 const end = html.indexOf('<'); 9527 result.push(...parseText(end === -1 ? html : html.slice(0, end))); 9528 } 9529 const commentsContent = []; 9530 let commentIndex = -1; 9531 html = html.replace(matchers.comment, tag => { 9532 commentIndex += 1; 9533 commentsContent.push(tag.replace(/^<!--|-->$/g, '')); 9534 return `<!--{{cUid${commentIndex}}}-->`; 9535 }); 9536 const arr = []; 9537 let level = -1; 9538 let current; 9539 html.replace(matchers.tag, (tag, index) => { 9540 const start = index + tag.length; 9541 const nextChar = html.charAt(start); 9542 let parent; 9543 if (tag.startsWith('<!--')) { 9544 const comment = parseTag(tag, substitutions); 9545 comment.content = commentsContent[tag.replace(/<!--{{cUid|}}-->/g, '')]; 9546 if (level < 0) { 9547 result.push(comment); 9548 return result; 9549 } 9550 parent = arr[level]; 9551 parent.children.push(comment); 9552 return result; 9553 } 9554 if (tag.startsWith('{{')) { 9555 const [placeholder] = parseText(tag); 9556 if (level < 0) { 9557 result.push(placeholder); 9558 return result; 9559 } 9560 parent = arr[level]; 9561 parent.children.push(placeholder); 9562 return result; 9563 } 9564 if (!tag.startsWith('</')) { 9565 level++; 9566 current = parseTag(tag, substitutions); 9567 if (!current.voidElement && nextChar && nextChar !== '<') { 9568 current.children.push(...parseText(html.slice(start, html.indexOf('<', start)))); 9569 } 9570 if (level === 0) { 9571 result.push(current); 9572 } 9573 parent = arr[level - 1]; 9574 if (parent) { 9575 if (!current.svg) { 9576 current.svg = parent.svg; 9577 } 9578 parent.children.push(current); 9579 } 9580 arr[level] = current; 9581 } 9582 if (tag.startsWith('</') || current.voidElement) { 9583 if (level > -1 && (current.voidElement || current.name === tag.slice(2, -1))) { 9584 level--; 9585 current = level === -1 ? result : arr[level]; 9586 } 9587 if (nextChar && nextChar !== '<') { 9588 parent = level === -1 ? result : arr[level].children; 9589 const end = html.indexOf('<', start); 9590 const content = html.slice(start, end === -1 ? undefined : end); 9591 if (end >
9591 -1 && level + parent.length >= 0 || content !== ' ') { 9592 parent.push(...parseText(content)); 9593 } 9594 } 9595 } 9596 }); 9597 return result; 9598 } 9599 9600 const appendElement = (current, target) => { 9601 if (Type.isDomNode(current) && Type.isDomNode(target)) { 9602 if (target.nodeName !== 'TEMPLATE') { 9603 Dom.append(current, target); 9604 } else { 9605 // eslint-disable-next-line bitrix-rules/no-native-dom-methods 9606 target.content.append(current); 9607 } 9608 } 9609 }; 9610 function renderNode(options) { 9611 const { 9612 node, 9613 parentElement, 9614 substitutions, 9615 refs = [] 9616 } = options; 9617 if (node.type === 'tag') { 9618 const element = (() => { 9619 if (node.svg) { 9620 return document.createElementNS('http://www.w3.org/2000/svg', node.name); 9621 } 9622 return document.createElement(node.name); 9623 })(); 9624 if (Object.hasOwn(node.attrs, 'ref')) { 9625 refs.push([node.attrs.ref, element]); 9626 delete node.attrs.ref; 9627 } 9628 Object.entries(node.attrs).forEach(([key, value]) => { 9629 if (key.startsWith('on') && new RegExp(matchers.placeholder).test(value)) { 9630 const substitution = substitutions[parseInt(value.replace(/{{uid|}}/, '')) - 1]; 9631 if (Type.isFunction(substitution)) { 9632 const bindFunctionName = key.endsWith('once') ? 'bindOnce' : 'bind'; 9633 Event[bindFunctionName](element, key.replace(/^on|once$/g, ''), substitution); 9634 } else { 9635 element.setAttribute(key, substitution); 9636 } 9637 } else { 9638 if (new RegExp(matchers.placeholder).test(value)) { 9639 const preparedValue = value.split(/{{|}}/).reduce((acc, item) => { 9640 if (item.startsWith('uid')) { 9641 const substitution = substitutions[parseInt(item.replace('uid', '')) - 1]; 9642 return `${acc}${substitution}`; 9643 } 9644 return `${acc}${item}`; 9645 }, ''); 9646 element.setAttribute(key, preparedValue); 9647 } else { 9648 element.setAttribute(key, Text.decode(value)); 9649 } 9650 } 9651 }); 9652 node.children.forEach(childNode => { 9653 const result = renderNode({ 9654 node: childNode, 9655 parentElement: element, 9656 substitutions, 9657 refs 9658 }); 9659 if (Type.isArray(result)) { 9660 result.forEach(subChildElement => { 9661 appendElement(subChildElement, element); 9662 }); 9663 } else { 9664 appendElement(result, element); 9665 } 9666 }); 9667 return element; 9668 } 9669 if (node.type === 'comment') { 9670 return document.createComment(node.content); 9671 } 9672 if (node.type === 'text') { 9673 if (parentElement) { 9674 if (parentElement.nodeName !== 'TEMPLATE') { 9675 parentElement.insertAdjacentHTML('beforeend', node.content); 9676 } else { 9677 parentElement.content.append(node.content); 9678 } 9679 return; 9680 } 9681 return document.createTextNode(node.content); 9682 } 9683 if (node.type === 'placeholder') { 9684 return substitutions[node.uid - 1]; 9685 } 9686 } 9687 9688 function render(sections, ...substitutions) { 9689 const html = sections.reduce((acc, item, index) => { 9690 if (index > 0) { 9691 const substitution = substitutions[index - 1]; 9692 if (Type.isString(substitution) || Type.isNumber(substitution)) { 9693 return `${acc}${substitution}${item}`; 9694 } 9695 return `${acc}{{uid${index}}}${item}`; 9696 } 9697 return acc; 9698 }, sections[0]).replace(/^[\r\n\t\s]+/gm, '').replace(/>[\n]+/g, '>').replace(/[}][\n]+/g, '}'); 9699 const ast = parse(html); 9700 if (ast.length === 1) { 9701 const refs = []; 9702 const renderedNode = renderNode({ 9703 node: ast[0], 9704 substitutions, 9705 refs 9706 }); 9707 if (Type.isArrayFilled(refs)) { 9708 return Object.fromEntries([['root', renderedNode], ...refs]); 9709 } 9710 return renderedNode; 9711 } 9712 if (ast.length > 1) { 9713 const refs = []; 9714 const renderedNodes = ast.map(node => { 9715 return renderNode({ 9716 node, 9717 substitutions, 9718 refs 9719 }); 9720 }); 9721 if (Type.isArrayFilled(refs)) { 9722 return Object.fromEntries([['root', renderedNodes], ...refs]); 9723 } 9724 return renderedNodes; 9725 } 9726 return false;
9727 } 9728 9729 function parseProps(sections, ...substitutions) { 9730 return substitutions.reduce((acc, item, index) => { 9731 const nextSectionIndex = index + 1; 9732 if (!Type.isPlainObject(item) && !Type.isArray(item)) { 9733 return acc + item + sections[nextSectionIndex]; 9734 } 9735 return `${acc}__s${index}${sections[nextSectionIndex]}`; 9736 }, sections[0]).replace(/[\r\t]/gm, '').split(';\n').map(item => item.replace(/\n/, '')).reduce((acc, item) => { 9737 if (item !== '') { 9738 const matches = item.match(/^[\w-. ]+:/); 9739 const splitted = item.split(/^[\w-. ]+:/); 9740 const key = matches[0].replace(':', '').trim(); 9741 const value = splitted[1].trim(); 9742 const substitutionPlaceholderExp = /^__s\d+/; 9743 if (substitutionPlaceholderExp.test(value)) { 9744 acc[key] = substitutions[value.replace('__s', '')]; 9745 return acc; 9746 } 9747 acc[key] = value; 9748 } 9749 return acc; 9750 }, {}); 9751 } 9752 9753 /** 9754 * @memberOf BX 9755 */ 9756 let Tag = /*#__PURE__*/function () { 9757 function Tag() { 9758 babelHelpers.classCallCheck(this, Tag); 9759 } 9760 babelHelpers.createClass(Tag, null, [{ 9761 key: "safe", 9762 /** 9763 * Encodes all substitutions 9764 * @param sections 9765 * @param substitutions 9766 * @return {string} 9767 */ 9768 value: function safe(sections, ...substitutions) { 9769 return substitutions.reduce((acc, item, index) => acc + Text.encode(item) + sections[index + 1], sections[0]); 9770 } 9771 /** 9772 * Decodes all substitutions 9773 * @param sections 9774 * @param substitutions 9775 * @return {string} 9776 */ 9777 }, { 9778 key: "unsafe", 9779 value: function unsafe(sections, ...substitutions) { 9780 return substitutions.reduce((acc, item, index) => acc + Text.decode(item) + sections[index + 1], sections[0]); 9781 } 9782 /** 9783 * Adds styles to specified element 9784 * @param {HTMLElement} element 9785 * @return {Function} 9786 */ 9787 }, { 9788 key: "style", 9789 value: function style(element) { 9790 if (!Type.isDomNode(element)) { 9791 throw new Error('element is not HTMLElement'); 9792 } 9793 return function styleTagHandler(...args) { 9794 Dom.style(element, parseProps(...args)); 9795 }; 9796 } 9797 /** 9798 * Replace all messages identifiers to real messages 9799 * @param sections 9800 * @param substitutions 9801 * @return {string} 9802 */ 9803 }, { 9804 key: "message", 9805 value: function message(sections, ...substitutions) { 9806 return substitutions.reduce((acc, item, index) => acc + Loc.getMessage(item) + sections[index + 1], sections[0]); 9807 } 9808 }, { 9809 key: "attrs", 9810 /** 9811 * Adds attributes to specified element 9812 * @param element 9813 * @return {Function} 9814 */ 9815 value: function attrs(element) { 9816 if (!Type.isDomNode(element)) { 9817 throw new Error('element is not HTMLElement'); 9818 } 9819 return function attrsTagHandler(...args) { 9820 Dom.attr(element, parseProps(...args)); 9821 }; 9822 } 9823 }]); 9824 return Tag; 9825 }(); 9826 babelHelpers.defineProperty(Tag, "render", render); 9827 babelHelpers.defineProperty(Tag, "attr", Tag.attrs); 9828 9829 function getParser(format) { 9830 switch (format) { 9831 case 'index': 9832 return (sourceKey, value, accumulator) => { 9833 const result = /\[(\w*)\]$/.exec(sourceKey); 9834 const key = sourceKey.replace(/\[\w*\]$/, ''); 9835 if (Type.isNil(result)) { 9836 accumulator[key] = value; 9837 return; 9838 } 9839 if (Type.isUndefined(accumulator[key])) { 9840 accumulator[key] = {}; 9841 } 9842 accumulator[key][result[1]] = value; 9843 }; 9844 case 'bracket': 9845 return (sourceKey, value, accumulator) => { 9846 const result = /(\[\])$/.exec(sourceKey); 9847 const key = sourceKey.replace(/\[\]$/, ''); 9848 if (Type.isNil(result)) { 9849 accumulator[key] = value; 9850 return; 9851 } 9852 if (Type.isUndefined(accumulator[key])) { 9853 accumulator[key] = [value]; 9854 return; 9855 } 9856 accumulator[key] = [].concat(accumulator[key], value); 9857 }; 9858 default: 9859 return (sourceKey, value, accumulator) => {
9860 const key = sourceKey.replace(/\[\]$/, ''); 9861 accumulator[key] = value; 9862 }; 9863 } 9864 } 9865 function getKeyFormat(key) { 9866 if (/^\w+\[([\w]+)\]$/.test(key)) { 9867 return 'index'; 9868 } 9869 if (/^\w+\[\]$/.test(key)) { 9870 return 'bracket'; 9871 } 9872 return 'default'; 9873 } 9874 function isAllowedKey(key) { 9875 return !String(key).startsWith('__proto__'); 9876 } 9877 function parseQuery(input) { 9878 if (!Type.isString(input)) { 9879 return {}; 9880 } 9881 const url = input.trim().replace(/^[?#&]/, ''); 9882 if (!url) { 9883 return {}; 9884 } 9885 return { 9886 ...url.split('&').reduce((acc, param) => { 9887 const [key, value] = param.replace(/\+/g, ' ').split('='); 9888 if (isAllowedKey(key)) { 9889 const keyFormat = getKeyFormat(key); 9890 const formatter = getParser(keyFormat); 9891 formatter(key, value, acc); 9892 } 9893 return acc; 9894 }, Object.create(null)) 9895 }; 9896 } 9897 const urlExp = /^((\w+):)?(\/\/((\w+)?(:(\w+))?@)?([^\/\?:]+)(:(\d+))?)?(\/?([^\/\?#][^\?#]*)?)?(\?([^#]+))?(#(\w*))?/; 9898 function parseUrl(url) { 9899 const result = url.match(urlExp); 9900 if (Type.isArray(result)) { 9901 const queryParams = parseQuery(result[14]); 9902 return { 9903 useShort: /^\/\//.test(url), 9904 href: result[0] || '', 9905 schema: result[2] || '', 9906 host: result[8] || '', 9907 port: result[10] || '', 9908 path: result[11] || '', 9909 query: result[14] || '', 9910 queryParams, 9911 hash: result[16] || '', 9912 username: result[5] || '', 9913 password: result[7] || '', 9914 origin: result[8] || '' 9915 }; 9916 } 9917 return {}; 9918 } 9919 9920 function buildQueryString(params = {}) { 9921 const queryString = Object.keys(params).reduce((acc, key) => { 9922 if (Type.isArray(params[key])) { 9923 params[key].forEach(paramValue => { 9924 acc.push(`${key}[]=${paramValue}`); 9925 }, ''); 9926 } 9927 if (Type.isPlainObject(params[key])) { 9928 Object.keys(params[key]).forEach(paramIndex => { 9929 acc.push(`${key}[${paramIndex}]=${params[key][paramIndex]}`); 9930 }, ''); 9931 } 9932 if (!Type.isObject(params[key]) && !Type.isArray(params[key])) { 9933 acc.push(`${key}=${params[key]}`); 9934 } 9935 return acc; 9936 }, []).join('&'); 9937 if (queryString.length > 0) { 9938 return `?${queryString}`; 9939 } 9940 return queryString; 9941 } 9942 9943 function prepareParamValue(value) { 9944 if (Type.isArray(value)) { 9945 return value.map(item => String(item)); 9946 } 9947 if (Type.isPlainObject(value)) { 9948 return { 9949 ...value 9950 }; 9951 } 9952 return String(value); 9953 } 9954 9955 const map = new WeakMap(); 9956 9957 /** 9958 * Implements interface for works with URI 9959 * @memberOf BX 9960 */ 9961 let Uri = /*#__PURE__*/function () { 9962 babelHelpers.createClass(Uri, null, [{ 9963 key: "addParam", 9964 value: function addParam(url, params = {}) { 9965 return new Uri(url).setQueryParams(params).toString(); 9966 } 9967 }, { 9968 key: "removeParam", 9969 value: function removeParam(url, params) { 9970 const removableParams = Type.isArray(params) ? params : [params]; 9971 return new Uri(url).removeQueryParam(...removableParams).toString(); 9972 } 9973 }]); 9974 function Uri(url = '') { 9975 babelHelpers.classCallCheck(this, Uri); 9976 map.set(this, parseUrl(url)); 9977 } 9978 9979 /** 9980 * Gets schema 9981 * @return {?string} 9982 */ 9983 babelHelpers.createClass(Uri, [{ 9984 key: "getSchema", 9985 value: function getSchema() { 9986 return map.get(this).schema; 9987 } 9988 /** 9989 * Sets schema 9990 * @param {string} schema 9991 * @return {Uri} 9992 */ 9993 }, { 9994 key: "setSchema", 9995 value: function setSchema(schema) { 9996 map.get(this).schema = String(schema); 9997 return this; 9998 } 9999 /** 10000 * Gets host 10001 * @return {?string} 10002 */ 10003 }, { 10004 key: "getHost", 10005 value: function getHost() { 10006 return map.get(this).host; 10007 } 10008 /** 10009 * Sets host 10010 * @param {string} host 10011 * @return {Uri} 10012 */ 10013 }, { 10014 key: "setHost", 10015 value: function setHost(host) { 10016 map.get(this).host = String(host); 10017 return this; 10018 } 10019 /** 10020 * Gets port 10021 * @return {?string} 10022 */ 10023 }, { 10024 key: "getPort", 10025 value: function getPort() { 10026 return map.get(this).port; 10027 } 10028 /** 10029 * Sets port 10030 * @param {String | Number} port 10031 * @return {Uri} 10032 */ 10033 }, { 10034 key: "setPort", 10035 value: function setPort(port) { 10036 map.get(this).port = String(port); 10037 return this; 10038 } 10039 /** 10040 * Gets path 10041 * @return {?string} 10042 */ 10043 }, { 10044 key: "getPath", 10045 value: function getPath() { 10046 return map.get(this).path; 10047 } 10048 /** 10049 * Sets path 10050 * @param {string} path 10051 * @return {Uri} 10052 */ 10053 }, { 10054 key: "setPath", 10055 value: function setPath(path) { 10056 if (!/^\//.test(path)) {
10057 map.get(this).path = `/${String(path)}`; 10058 return this; 10059 } 10060 map.get(this).path = String(path); 10061 return this; 10062 } 10063 /** 10064 * Gets query 10065 * @return {?string} 10066 */ 10067 }, { 10068 key: "getQuery", 10069 value: function getQuery() { 10070 return buildQueryString(map.get(this).queryParams); 10071 } 10072 /** 10073 * Gets query param value by name 10074 * @param {string} key 10075 * @return {?string} 10076 */ 10077 }, { 10078 key: "getQueryParam", 10079 value: function getQueryParam(key) { 10080 const params = this.getQueryParams(); 10081 if (Object.hasOwn(params, key)) { 10082 return params[key]; 10083 } 10084 return null; 10085 } 10086 /** 10087 * Sets query param 10088 * @param {string} key 10089 * @param [value] 10090 * @return {Uri} 10091 */ 10092 }, { 10093 key: "setQueryParam", 10094 value: function setQueryParam(key, value = '') { 10095 map.get(this).queryParams[key] = prepareParamValue(value); 10096 return this; 10097 } 10098 /** 10099 * Gets query params 10100 * @return {Object<string, any>} 10101 */ 10102 }, { 10103 key: "getQueryParams", 10104 value: function getQueryParams() { 10105 return { 10106 ...map.get(this).queryParams 10107 }; 10108 } 10109 /** 10110 * Sets query params 10111 * @param {Object<string, any>} params 10112 * @return {Uri} 10113 */ 10114 }, { 10115 key: "setQueryParams", 10116 value: function setQueryParams(params = {}) { 10117 const currentParams = this.getQueryParams(); 10118 const newParams = { 10119 ...currentParams, 10120 ...params 10121 }; 10122 Object.keys(newParams).forEach(key => { 10123 newParams[key] = prepareParamValue(newParams[key]); 10124 }); 10125 map.get(this).queryParams = newParams; 10126 return this; 10127 } 10128 /** 10129 * Removes query params by name 10130 * @param keys 10131 * @return {Uri} 10132 */ 10133 }, { 10134 key: "removeQueryParam", 10135 value: function removeQueryParam(...keys) { 10136 const currentParams = { 10137 ...map.get(this).queryParams 10138 }; 10139 keys.forEach(key => { 10140 if (Object.hasOwn(currentParams, key)) { 10141 delete currentParams[key]; 10142 } 10143 }); 10144 map.get(this).queryParams = currentParams; 10145 return this; 10146 } 10147 /** 10148 * Gets fragment 10149 * @return {?string} 10150 */ 10151 }, { 10152 key: "getFragment", 10153 value: function getFragment() { 10154 return map.get(this).hash; 10155 } 10156 /** 10157 * Sets fragment 10158 * @param {string} hash 10159 * @return {Uri} 10160 */ 10161 }, { 10162 key: "setFragment", 10163 value: function setFragment(hash) { 10164 map.get(this).hash = String(hash); 10165 return this; 10166 } 10167 /** 10168 * Serializes URI 10169 * @return {Object} 10170 */ 10171 }, { 10172 key: "serialize", 10173 value: function serialize() { 10174 const serialized = { 10175 ...map.get(this) 10176 }; 10177 serialized.href = this.toString(); 10178 return serialized; 10179 } 10180 /** 10181 * Gets URI string 10182 * @return {string} 10183 */ 10184 }, { 10185 key: "toString", 10186 value: function toString() { 10187 const data = { 10188 ...map.get(this) 10189 }; 10190 let protocol = data.schema ? `${data.schema}://` : ''; 10191 if (data.useShort) { 10192 protocol = '//'; 10193 } 10194 const port = (() => { 10195 if (Type.isString(data.port) && !['', '80'].includes(data.port)) { 10196 return `:${data.port}`; 10197 } 10198 return ''; 10199 })(); 10200 const host = this.getHost(); 10201 const path = this.getPath(); 10202 const query = buildQueryString(data.queryParams); 10203 const hash = data.hash ? `#${data.hash}` : ''; 10204 return `${host ? protocol : ''}${host}${host ? port : ''}${path}${query}${hash}`; 10205 } 10206 }]); 10207 return Uri; 10208 }(); 10209 10210 /** 10211 * @memberOf BX 10212 */ 10213 let Validation = /*#__PURE__*/function () { 10214 function Validation() { 10215 babelHelpers.classCallCheck(this, Validation); 10216 } 10217 babelHelpers.createClass(Validation, null, [{ 10218 key: "isEmail", 10219 /** 10220 * Checks that value is valid email 10221 * @param value 10222 * @return {boolean} 10223 */ 10224 value: function isEmail(value) { 10225 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])?)*$/; 10226 return exp.test(String(value).toLowerCase()); 10227 } 10228 }]); 10229 return Validation; 10230 }(); 10231 10232 let BaseCache = /*#__PURE__*/function () { 10233 function BaseCache() { 10234 babelHelpers.classCallCheck(this, BaseCache); 10235 babelHelpers.defineProperty(this, "storage", new Map()); 10236 } 10237 babelHelpers.createClass(BaseCache, [{ 10238 key: "get", 10239 /** 10240 * Gets cached value or default value 10241 */ 10242 value: function get(key, defaultValue) { 10243 if (!this.storage.has(key)) { 10244 if (Type.isFunction(defaultValue)) { 10245 return defaultValue(); 10246 } 10247 if (!Type.isUndefined(defaultValue)) { 10248 return defaultValue; 10249 } 10250 } 10251 return this.storage.get(key); 10252 } 10253 /**
10254 * Sets cache entry 10255 */ 10256 }, { 10257 key: "set", 10258 value: function set(key, value) { 10259 this.storage.set(key, value); 10260 } 10261 /** 10262 * Deletes cache entry 10263 */ 10264 }, { 10265 key: "delete", 10266 value: function _delete(key) { 10267 this.storage.delete(key); 10268 } 10269 /** 10270 * Checks that storage contains entry with specified key 10271 */ 10272 }, { 10273 key: "has", 10274 value: function has(key) { 10275 return this.storage.has(key); 10276 } 10277 /** 10278 * Gets cached value if exists, 10279 */ 10280 }, { 10281 key: "remember", 10282 value: function remember(key, defaultValue) { 10283 if (!this.storage.has(key)) { 10284 if (Type.isFunction(defaultValue)) { 10285 this.storage.set(key, defaultValue()); 10286 } else if (!Type.isUndefined(defaultValue)) { 10287 this.storage.set(key, defaultValue); 10288 } 10289 } 10290 return this.storage.get(key); 10291 } 10292 /** 10293 * Gets storage size 10294 */ 10295 }, { 10296 key: "size", 10297 value: function size() { 10298 return this.storage.size; 10299 } 10300 /** 10301 * Gets storage keys 10302 */ 10303 }, { 10304 key: "keys", 10305 value: function keys() { 10306 return [...this.storage.keys()]; 10307 } 10308 /** 10309 * Gets storage values 10310 */ 10311 }, { 10312 key: "values", 10313 value: function values() { 10314 return [...this.storage.values()]; 10315 } 10316 }]); 10317 return BaseCache; 10318 }(); 10319 10320 let MemoryCache = /*#__PURE__*/function (_BaseCache) { 10321 babelHelpers.inherits(MemoryCache, _BaseCache); 10322 function MemoryCache(...args) { 10323 var _this; 10324 babelHelpers.classCallCheck(this, MemoryCache); 10325 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(MemoryCache).call(this, ...args)); 10326 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new Map()); 10327 return _this; 10328 } 10329 return MemoryCache; 10330 }(BaseCache); 10331 10332 let LsStorage = /*#__PURE__*/function () { 10333 function LsStorage() { 10334 babelHelpers.classCallCheck(this, LsStorage); 10335 babelHelpers.defineProperty(this, "stackKey", 'BX.Cache.Storage.LsStorage.stack'); 10336 babelHelpers.defineProperty(this, "stack", null); 10337 } 10338 babelHelpers.createClass(LsStorage, [{ 10339 key: "getStack", 10340 /** 10341 * @private 10342 */ 10343 value: function getStack() { 10344 if (Type.isPlainObject(this.stack)) { 10345 return this.stack; 10346 } 10347 const stack = localStorage.getItem(this.stackKey); 10348 if (Type.isString(stack) && stack !== '') { 10349 const parsedStack = JSON.parse(stack); 10350 if (Type.isPlainObject(parsedStack)) { 10351 this.stack = parsedStack; 10352 return this.stack; 10353 } 10354 } 10355 this.stack = {}; 10356 return this.stack; 10357 } 10358 /** 10359 * @private 10360 */ 10361 }, { 10362 key: "saveStack", 10363 value: function saveStack() { 10364 if (Type.isPlainObject(this.stack)) { 10365 const preparedStack = JSON.stringify(this.stack); 10366 localStorage.setItem(this.stackKey, preparedStack); 10367 } 10368 } 10369 }, { 10370 key: "get", 10371 value: function get(key) { 10372 const stack = this.getStack(); 10373 return stack[key]; 10374 } 10375 }, { 10376 key: "set", 10377 value: function set(key, value) { 10378 const stack = this.getStack(); 10379 stack[key] = value; 10380 this.saveStack(); 10381 } 10382 }, { 10383 key: "delete", 10384 value: function _delete(key) { 10385 const stack = this.getStack(); 10386 if (key in stack) { 10387 delete stack[key]; 10388 } 10389 } 10390 }, { 10391 key: "has", 10392 value: function has(key) { 10393 const stack = this.getStack(); 10394 return key in stack; 10395 } 10396 }, { 10397 key: "keys", 10398 value: function keys() { 10399 const stack = this.getStack(); 10400 return Object.keys(stack); 10401 } 10402 }, { 10403 key: "values", 10404 value: function values() { 10405 const stack = this.getStack(); 10406 return Object.values(stack); 10407 } 10408 }, { 10409 key: "size", 10410 get: function () { 10411 const stack = this.getStack(); 10412 return Object.keys(stack).length; 10413 } 10414 }]); 10415 return LsStorage; 10416 }(); 10417 10418 let LocalStorageCache = /*#__PURE__*/function (_BaseCache) { 10419 babelHelpers.inherits(LocalStorageCache, _BaseCache); 10420 function LocalStorageCache(...args) { 10421 var _this; 10422 babelHelpers.classCallCheck(this, LocalStorageCache); 10423 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(LocalStorageCache).call(this, ...args)); 10424 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new LsStorage()); 10425 return _this; 10426 } 10427 return LocalStorageCache; 10428 }(BaseCache); 10429 10430 /** 10431 * @memberOf BX 10432 */ 10433 let Cache = function Cache() { 10434 babelHelpers.classCallCheck(this, Cache); 10435 }; 10436 babelHelpers.defineProperty(Cache, "BaseCache", BaseCache); 10437 babelHelpers.defineProperty(Cache, "MemoryCache", MemoryCache); 10438 babelHelpers.defineProperty(Cache, "LocalStorageCache", LocalStorageCache); 10439 10440 function convertPath(path) { 10441 if (Type.isStringFilled(path)) { 10442 return path.split('.').reduce((acc, item) => { 10443 item.split(/\[['"]?(.+?)['"]?\]/g).forEach(key => { 10444 if (Type.isStringFilled(key)) { 10445 acc.push(key); 10446 } 10447 }); 10448 return acc; 10449 }, []); 10450 } 10451 return []; 10452 } 10453 10454 let SettingsCollection = /*#__PURE__*/function () { 10455 function SettingsCollection(options = {}) { 10456 babelHelpers.classCallCheck(this, SettingsCollection); 10457 if (Type.isPlainObject(options)) { 10458 Object.assign(this, options); 10459 } 10460 } 10461 babelHelpers.createClass(SettingsCollection, [{ 10462 key: "get", 10463 value: function get(path, defaultValue = null) { 10464 const convertedPath = convertPath(path); 10465 return convertedPath.reduce((acc, key) => { 10466 if (!Type.isNil(acc) && acc !== defaultValue) { 10467 if (!Type.isUndefined(acc[key])) { 10468 return acc[key]; 10469 } 10470 return defaultValue; 10471 } 10472 return acc; 10473 }, this); 10474 } 10475 }]); 10476 return SettingsCollection; 10477 }(); 10478 10479 function deepFreeze(target) { 10480 if (Type.isObject(target)) { 10481 Object.values(target).forEach(value => { 10482 deepFreeze(value); 10483 }); 10484 return Object.freeze(target); 10485 } 10486 return target; 10487 } 10488 10489 const settingsStorage = new Map(); 10490 let Extension$1 = /*#__PURE__*/function () { 10491 function Extension() { 10492 babelHelpers.classCallCheck(this, Extension); 10493 } 10494 babelHelpers.createClass(Extension, null, [{ 10495 key: "getSettings", 10496 value: function getSettings(extensionName) { 10497 if (Type.isStringFilled(extensionName)) { 10498 if (settingsStorage.has(extensionName)) { 10499 return settingsStorage.get(extensionName); 10500 } 10501 const settingsScriptNode = document.querySelector(`script[data-extension="${extensionName}"]`); 10502 if (Type.isDomNode(settingsScriptNode)) { 10503 const decodedSettings = (() => { 10504 try { 10505 return new SettingsCollection(JSON.parse(settingsScriptNode.innerHTML)); 10506 } catch (error) { 10507 return new SettingsCollection(); 10508 } 10509 })(); 10510 const frozenSettings = deepFreeze(decodedSettings); 10511 settingsStorage.set(extensionName, frozenSettings); 10512 return frozenSettings; 10513 } 10514 } 10515 return deepFreeze(new SettingsCollection()); 10516 } 10517 }]); 10518 return Extension; 10519 }(); 10520 10521 let _Symbol$iterator; 10522 function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration$1(obj, privateSet); privateSet.add(obj); } 10523 function _checkPrivateRedeclaration$1(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 10524 function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 10525 var _searchIndexToInsert = /*#__PURE__*/new WeakSet(); 10526 _Symbol$iterator = Symbol.iterator; 10527 let OrderedArray = /*#__PURE__*/function () { 10528 function OrderedArray(comparator = null) { 10529 babelHelpers.classCallCheck(this, OrderedArray); 10530 _classPrivateMethodInitSpec(this, _searchIndexToInsert); 10531 babelHelpers.defineProperty(this, "comparator", null); 10532 babelHelpers.defineProperty(this, "items", []); 10533 this.comparator = Type.isFunction(comparator) ? comparator : null; 10534 } 10535 babelHelpers.createClass(OrderedArray, [{ 10536 key: "add", 10537 value: function add(item) { 10538 let index = -1; 10539 if (this.comparator) { 10540 index = _classPrivateMethodGet(this, _searchIndexToInsert, _searchIndexToInsert2).call(this, item); 10541 this.items.splice(index, 0, item); 10542 } else { 10543 this.items.push(item); 10544 } 10545 return index; 10546 } 10547 }, { 10548 key: "has", 10549 value: function has(item) { 10550 return this.items.includes(item); 10551 } 10552 }, { 10553 key: "getIndex", 10554 value: function getIndex(item) { 10555 return this.items.indexOf(item); 10556 } 10557 }, { 10558 key: "getByIndex", 10559 value: function getByIndex(index) { 10560 if (Type.isNumber(index) && index >= 0) { 10561 const item = this.items[index]; 10562 return Type.isUndefined(item) ? null : item; 10563 } 10564 return null; 10565 } 10566 }, { 10567 key: "getFirst", 10568 value: function getFirst() { 10569 const first = this.items[0]; 10570 return Type.isUndefined(first) ? null : first; 10571 } 10572 }, { 10573 key: "getLast", 10574 value: function getLast() { 10575 const last = this.items[this.count() - 1]; 10576 return Type.isUndefined(last) ? null : last; 10577 } 10578 }, { 10579 key: "count", 10580 value: function count() { 10581 return this.items.length; 10582 } 10583 }, { 10584 key: "delete", 10585 value: function _delete(item) { 10586 const index = this.getIndex(item); 10587 if (index !== -1) { 10588 this.items.splice(index, 1); 10589 return true; 10590 } 10591 return false;
10592 } 10593 }, { 10594 key: "clear", 10595 value: function clear() { 10596 this.items = []; 10597 } 10598 }, { 10599 key: _Symbol$iterator, 10600 value: function () { 10601 return this.items[Symbol.iterator](); 10602 } 10603 }, { 10604 key: "forEach", 10605 value: function forEach(callbackfn, thisArg) { 10606 return this.items.forEach(callbackfn, thisArg); 10607 } 10608 }, { 10609 key: "getAll", 10610 value: function getAll() { 10611 return this.items; 10612 } 10613 }, { 10614 key: "getComparator", 10615 value: function getComparator() { 10616 return this.comparator; 10617 } 10618 }, { 10619 key: "sort", 10620 value: function sort() { 10621 const comparator = this.getComparator(); 10622 if (comparator === null) { 10623 return; 10624 } 10625 10626 /* 10627 Simple implementation 10628 this.items.sort((item1, item2) => { 10629 return comparator(item1, item2); 10630 }); 10631 */ 10632 10633 // For stable sorting https://v8.dev/features/stable-sort 10634 const length = this.items.length; 10635 const indexes = new Array(length); 10636 for (let i = 0; i < length; i++) { 10637 indexes[i] = i; 10638 } 10639 10640 // If the comparator returns zero, use the original indexes 10641 indexes.sort((index1, index2) => { 10642 return comparator(this.items[index1], this.items[index2]) || index1 - index2; 10643 }); 10644 for (let i = 0; i < length; i++) { 10645 indexes[i] = this.items[indexes[i]]; 10646 } 10647 for (let i = 0; i < length; i++) { 10648 this.items[i] = indexes[i]; 10649 } 10650 } 10651 }]); 10652 return OrderedArray; 10653 }(); 10654 function _searchIndexToInsert2(value) { 10655 let low = 0; 10656 let high = this.items.length; 10657 while (low < high) { 10658 const mid = Math.floor((low + high) / 2); 10659 if (this.comparator(this.items[mid], value) >= 0) { 10660 high = mid; 10661 } else { 10662 low = mid + 1; 10663 } 10664 } 10665 return low; 10666 } 10667 10668 let ZIndexComponent = /*#__PURE__*/function (_EventEmitter) { 10669 babelHelpers.inherits(ZIndexComponent, _EventEmitter); 10670 function ZIndexComponent(element, componentOptions = {}) { 10671 var _this; 10672 babelHelpers.classCallCheck(this, ZIndexComponent); 10673 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(ZIndexComponent).call(this)); 10674 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "sort", 0); 10675 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "alwaysOnTop", false); 10676 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "zIndex", 0); 10677 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "element", null); 10678 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlay", null); 10679 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlayGap", -5); 10680 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "stack", null); 10681 _this.setEventNamespace('BX.Main.ZIndexManager.Component'); 10682 if (!Type.isElementNode(element)) { 10683 throw new Error('ZIndexManager.Component: The argument \'element\' must be a DOM element.'); 10684 } 10685 _this.element = element; 10686 const options = Type.isPlainObject(componentOptions) ? componentOptions : {}; 10687 _this.setAlwaysOnTop(options.alwaysOnTop); 10688 _this.setOverlay(options.overlay); 10689 _this.setOverlayGap(options.overlayGap); 10690 _this.subscribeFromOptions(options.events); 10691 return _this; 10692 } 10693 babelHelpers.createClass(ZIndexComponent, [{ 10694 key: "getSort", 10695 value: function getSort() { 10696 return this.sort; 10697 } 10698 /** 10699 * @internal 10700 * @param sort 10701 */ 10702 }, { 10703 key: "setSort", 10704 value: function setSort(sort) { 10705 if (Type.isNumber(sort)) { 10706 this.sort = sort; 10707 } 10708 } 10709 /** 10710 * @internal 10711 * @param stack 10712 */ 10713 }, { 10714 key: "setStack", 10715 value: function setStack(stack) { 10716 this.stack = stack; 10717 } 10718 }, { 10719 key: "getStack", 10720 value: function getStack() { 10721 return this.stack; 10722 } 10723 }, { 10724 key: "getZIndex", 10725 value: function getZIndex() { 10726 return this.zIndex; 10727 } 10728 /** 10729 * @internal 10730 */ 10731 }, { 10732 key: "setZIndex", 10733 value: function setZIndex(zIndex) { 10734 const changed = this.getZIndex() !== zIndex; 10735 this.getElement().style.setProperty('z-index', zIndex, 'important'); 10736 this.zIndex = zIndex; 10737 if (this.getOverlay() !== null) { 10738 this.getOverlay().style.setProperty('z-index', zIndex + this.getOverlayGap(), 'important'); 10739 } 10740 if (changed) {
10741 this.emit('onZIndexChange', { 10742 component: this 10743 }); 10744 } 10745 } 10746 }, { 10747 key: "getAlwaysOnTop", 10748 value: function getAlwaysOnTop() { 10749 return this.alwaysOnTop; 10750 } 10751 }, { 10752 key: "setAlwaysOnTop", 10753 value: function setAlwaysOnTop(value) { 10754 if (Type.isNumber(value) || Type.isBoolean(value)) { 10755 this.alwaysOnTop = value; 10756 } 10757 } 10758 }, { 10759 key: "getElement", 10760 value: function getElement() { 10761 return this.element; 10762 } 10763 }, { 10764 key: "setOverlay", 10765 value: function setOverlay(overlay, gap) { 10766 if (Type.isElementNode(overlay) || overlay === null) { 10767 this.overlay = overlay; 10768 this.setOverlayGap(gap); 10769 if (this.getStack()) { 10770 this.getStack().sort(); 10771 } 10772 } 10773 } 10774 }, { 10775 key: "getOverlay", 10776 value: function getOverlay() { 10777 return this.overlay; 10778 } 10779 }, { 10780 key: "setOverlayGap", 10781 value: function setOverlayGap(gap) { 10782 if (Type.isNumber(gap)) { 10783 this.overlayGap = gap; 10784 } 10785 } 10786 }, { 10787 key: "getOverlayGap", 10788 value: function getOverlayGap() { 10789 return this.overlayGap; 10790 } 10791 }]); 10792 return ZIndexComponent; 10793 }(EventEmitter); 10794 10795 let ZIndexStack = /*#__PURE__*/function () { 10796 function ZIndexStack(container) { 10797 babelHelpers.classCallCheck(this, ZIndexStack); 10798 babelHelpers.defineProperty(this, "container", null); 10799 babelHelpers.defineProperty(this, "components", null); 10800 babelHelpers.defineProperty(this, "elements", new WeakMap()); 10801 babelHelpers.defineProperty(this, "baseIndex", 1000); 10802 babelHelpers.defineProperty(this, "baseStep", 50); 10803 babelHelpers.defineProperty(this, "sortCount", 0); 10804 if (!Type.isDomNode(container)) { 10805 throw new Error('ZIndexManager.Stack: The \'container\' argument must be a DOM element.'); 10806 } 10807 this.container = container; 10808 const comparator = (componentA, componentB) => { 10809 let result = (componentA.getAlwaysOnTop() || 0) - (componentB.getAlwaysOnTop() || 0); 10810 if (!result) { 10811 result = componentA.getSort() - componentB.getSort(); 10812 } 10813 return result; 10814 }; 10815 this.components = new OrderedArray(comparator); 10816 } 10817 babelHelpers.createClass(ZIndexStack, [{ 10818 key: "getBaseIndex", 10819 value: function getBaseIndex() { 10820 return this.baseIndex; 10821 } 10822 }, { 10823 key: "setBaseIndex", 10824 value: function setBaseIndex(index) { 10825 if (Type.isNumber(index) && index >= 0) { 10826 this.baseIndex = index; 10827 this.sort(); 10828 } 10829 } 10830 }, { 10831 key: "setBaseStep", 10832 value: function setBaseStep(step) { 10833 if (Type.isNumber(step) && step > 0) { 10834 this.baseStep = step; 10835 this.sort(); 10836 } 10837 } 10838 }, { 10839 key: "getBaseStep", 10840 value: function getBaseStep() { 10841 return this.baseStep; 10842 } 10843 }, { 10844 key: "register", 10845 value: function register(element, options = {}) { 10846 if (this.getComponent(element)) { 10847 console.warn('ZIndexManager: You cannot register the element twice.', element); 10848 return this.getComponent(element); 10849 } 10850 const component = new ZIndexComponent(element, options); 10851 component.setStack(this); 10852 component.setSort(++this.sortCount); 10853 this.elements.set(element, component); 10854 this.components.add(component); 10855 this.sort(); 10856 return component; 10857 } 10858 }, { 10859 key: "unregister", 10860 value: function unregister(element) { 10861 const component = this.elements.get(element); 10862 this.components.delete(component); 10863 this.elements.delete(element); 10864 this.sort(); 10865 } 10866 }, { 10867 key: "getComponent", 10868 value: function getComponent(element) { 10869 return this.elements.get(element) || null; 10870 } 10871 }, { 10872 key: "getComponents", 10873 value: function getComponents() { 10874 return this.components.getAll(); 10875 } 10876 }, { 10877 key: "getMaxZIndex", 10878 value: function getMaxZIndex() { 10879 const last = this.components.getLast(); 10880 return last ? last.getZIndex() : this.baseIndex; 10881 } 10882 }, { 10883 key: "sort", 10884 value: function sort() { 10885 this.components.sort(); 10886 let zIndex = this.baseIndex;
10887 this.components.forEach(component => { 10888 component.setZIndex(zIndex); 10889 zIndex += this.baseStep; 10890 }); 10891 } 10892 }, { 10893 key: "bringToFront", 10894 value: function bringToFront(element) { 10895 const component = this.getComponent(element); 10896 if (!component) { 10897 console.error('ZIndexManager: element was not found in the stack.', element); 10898 return null; 10899 } 10900 component.setSort(++this.sortCount); 10901 this.sort(); 10902 return component; 10903 } 10904 }]); 10905 return ZIndexStack; 10906 }(); 10907 10908 function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; } 10909 function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } } 10910 /** 10911 * @memberof BX 10912 */ 10913 let ZIndexManager = /*#__PURE__*/function () { 10914 function ZIndexManager() { 10915 babelHelpers.classCallCheck(this, ZIndexManager); 10916 } 10917 babelHelpers.createClass(ZIndexManager, null, [{ 10918 key: "register", 10919 value: function register(element, options = {}) { 10920 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10921 if (!parentNode) { 10922 return null; 10923 } 10924 const stack = this.getOrAddStack(parentNode); 10925 return stack.register(element, options); 10926 } 10927 }, { 10928 key: "unregister", 10929 value: function unregister(element) { 10930 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10931 const stack = this.getStack(parentNode); 10932 if (stack) { 10933 stack.unregister(element); 10934 } 10935 } 10936 }, { 10937 key: "addStack", 10938 value: function addStack(container) { 10939 const stack = new ZIndexStack(container); 10940 this.stacks.set(container, stack); 10941 return stack; 10942 } 10943 }, { 10944 key: "getStack", 10945 value: function getStack(container) { 10946 return this.stacks.get(container) || null; 10947 } 10948 }, { 10949 key: "getOrAddStack", 10950 value: function getOrAddStack(container) { 10951 return this.getStack(container) || this.addStack(container); 10952 } 10953 }, { 10954 key: "getComponent", 10955 value: function getComponent(element) { 10956 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element, true); 10957 if (!parentNode) { 10958 return null; 10959 } 10960 const stack = this.getStack(parentNode); 10961 return stack ? stack.getComponent(element) : null; 10962 } 10963 }, { 10964 key: "bringToFront", 10965 value: function bringToFront(element) { 10966 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10967 const stack = this.getStack(parentNode); 10968 if (stack) { 10969 return stack.bringToFront(element); 10970 } 10971 return null; 10972 } 10973 }]); 10974 return ZIndexManager; 10975 }(); 10976 function _getParentNode(element, suppressWarnings = false) { 10977 if (!Type.isElementNode(element)) { 10978 if (!suppressWarnings) { 10979 console.error('ZIndexManager: The argument \'element\' must be a DOM element.', element); 10980 } 10981 return null; 10982 } else if (!Type.isElementNode(element.parentNode)) { 10983 if (!suppressWarnings) { 10984 console.error('ZIndexManager: The \'element\' doesn\'t have a parent node.', element); 10985 } 10986 return null; 10987 } 10988 return element.parentNode; 10989 } 10990 babelHelpers.defineProperty(ZIndexManager, "stacks", new WeakMap()); 10991 10992 var collections = { 10993 OrderedArray, 10994 SettingsCollection 10995 }; 10996 10997 function getElement(element) { 10998 if (Type.isString(element)) { 10999 return document.getElementById(element); 11000 } 11001 return element; 11002 } 11003 11004 function getWindow(element) { 11005 if (Type.isElementNode(element)) { 11006 return element.ownerDocument.parentWindow || element.ownerDocument.defaultView || window; 11007 } 11008 if (Type.isDomNode(element)) { 11009 return element.parentWindow || element.defaultView || window; 11010 } 11011 return window; 11012 } 11013 11014 /* eslint-disable prefer-rest-params */ 11015 11016 // BX.* 11017 const { 11018 getClass, 11019 namespace 11020 } = Reflection; 11021 const message$1 = message; 11022 11023 /** 11024 * @memberOf BX 11025 */ 11026 const { 11027 replace, 11028 remove, 11029 clean, 11030 insertBefore, 11031 insertAfter, 11032 append, 11033 prepend, 11034 style, 11035 adjust, 11036 create, 11037 isShown 11038 } = Dom; 11039 const addClass = function addClass() { 11040 Dom.addClass(...Runtime.merge([], Array.from(arguments), [getElement(arguments[0])])); 11041 }; 11042 const removeClass = function removeClass() { 11043 Dom.removeClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11044 }; 11045 const hasClass = function hasClass() { 11046 return Dom.hasClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11047 }; 11048 const toggleClass = function toggleClass() { 11049 Dom.toggleClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11050 }; 11051 const cleanNode = (element, removeElement = false) => { 11052 const currentElement = getElement(element); 11053 if (Type.isDomNode(currentElement)) { 11054 Dom.clean(currentElement); 11055 if (removeElement) { 11056 Dom.remove(currentElement); 11057 return currentElement; 11058 } 11059 } 11060 return currentElement; 11061 }; 11062 const getCookie = Http.Cookie.get;
11063 const setCookie = (name, value, options = {}) => { 11064 const attributes = { 11065 ...options 11066 }; 11067 if (Type.isNumber(attributes.expires)) { 11068 attributes.expires /= 3600 * 24; 11069 } 11070 Http.Cookie.set(name, value, attributes); 11071 }; 11072 const { 11073 bind: bind$1, 11074 unbind: unbind$1, 11075 unbindAll: unbindAll$1, 11076 bindOnce: bindOnce$1, 11077 ready: ready$1 11078 } = Event; 11079 const { 11080 debugState: debugEnableFlag, 11081 isDebugEnabled: debugStatus, 11082 default: debug$1 11083 } = debugNs; 11084 const debugEnable = value => { 11085 if (value) { 11086 enableDebug(); 11087 } else { 11088 disableDebug(); 11089 } 11090 }; 11091 const { 11092 clone: clone$1, 11093 loadExtension: loadExt, 11094 debounce, 11095 throttle, 11096 html 11097 } = Runtime; 11098 11099 // BX.type 11100 const type = { 11101 ...Object.getOwnPropertyNames(Type).filter(key => !['name', 'length', 'prototype', 'caller', 'arguments'].includes(key)).reduce((acc, key) => { 11102 acc[key] = Type[key]; 11103 return acc; 11104 }, {}), 11105 isNotEmptyString: value => Type.isString(value) && value !== '', 11106 isNotEmptyObject: value => Type.isObjectLike(value) && Object.keys(value).length > 0, 11107 isMapKey: Type.isObject, 11108 stringToInt: value => { 11109 const parsed = parseInt(value); 11110 return !Number.isNaN(parsed) ? parsed : 0; 11111 } 11112 }; 11113 11114 // BX.browser 11115 const browser = { 11116 IsOpera: Browser.isOpera, 11117 IsIE: Browser.isIE, 11118 IsIE6: Browser.isIE6, 11119 IsIE7: Browser.isIE7, 11120 IsIE8: Browser.isIE8, 11121 IsIE9: Browser.isIE9, 11122 IsIE10: Browser.isIE10, 11123 IsIE11: Browser.isIE11, 11124 IsSafari: Browser.isSafari, 11125 IsFirefox: Browser.isFirefox, 11126 IsChrome: Browser.isChrome, 11127 DetectIeVersion: Browser.detectIEVersion, 11128 IsMac: Browser.isMac, 11129 IsAndroid: Browser.isAndroid, 11130 isIPad: Browser.isIPad, 11131 isIPhone: Browser.isIPhone, 11132 IsIOS: Browser.isIOS, 11133 IsMobile: Browser.isMobile, 11134 isRetina: Browser.isRetina, 11135 IsDoctype: Browser.isDoctype, 11136 SupportLocalStorage: Browser.isLocalStorageSupported, 11137 addGlobalClass: Browser.addGlobalClass, 11138 DetectAndroidVersion: Browser.detectAndroidVersion, 11139 isPropertySupported: Browser.isPropertySupported, 11140 addGlobalFeatures: Browser.addGlobalFeatures 11141 }; 11142 11143 // eslint-disable-next-line 11144 const ajax = window.BX ? window.BX.ajax : () => {}; 11145 function GetWindowScrollSize(doc = document) { 11146 return { 11147 scrollWidth: doc.documentElement.scrollWidth, 11148 scrollHeight: doc.documentElement.scrollHeight 11149 }; 11150 } 11151 function GetWindowScrollPos(doc = document) { 11152 const win = getWindow(doc); 11153 return { 11154 scrollLeft: win.pageXOffset, 11155 scrollTop: win.pageYOffset 11156 }; 11157 } 11158 function GetWindowInnerSize(doc = document) { 11159 const win = getWindow(doc); 11160 return { 11161 innerWidth: win.innerWidth, 11162 innerHeight: win.innerHeight 11163 }; 11164 } 11165 function GetWindowSize(doc = document) { 11166 return { 11167 ...GetWindowInnerSize(doc), 11168 ...GetWindowScrollPos(doc), 11169 ...GetWindowScrollSize(doc) 11170 }; 11171 } 11172 function GetContext(node) { 11173 return getWindow(node); 11174 } 11175 function pos(element, relative = false) { 11176 if (!element) { 11177 return new DOMRect().toJSON(); 11178 } 11179 if (element.ownerDocument === document && !relative) { 11180 const clientRect = element.getBoundingClientRect(); 11181 const root = document.documentElement; 11182 const { 11183 body 11184 } = document; 11185 return { 11186 top: Math.round(clientRect.top + (root.scrollTop || body.scrollTop)), 11187 left: Math.round(clientRect.left + (root.scrollLeft || body.scrollLeft)), 11188 width: Math.round(clientRect.right - clientRect.left), 11189 height: Math.round(clientRect.bottom - clientRect.top), 11190 right: Math.round(clientRect.right + (root.scrollLeft || body.scrollLeft)), 11191 bottom: Math.round(clientRect.bottom + (root.scrollTop || body.scrollTop)) 11192 }; 11193 } 11194 let x = 0; 11195 let y = 0; 11196 const w = element.offsetWidth; 11197 const h = element.offsetHeight; 11198 let first = true; 11199 11200 // eslint-disable-next-line no-param-reassign 11201 for (; element != null; element = element.offsetParent) { 11202 if (!first && relative && BX.is_relative(element)) { 11203 break; 11204 } 11205 x += element.offsetLeft; 11206 y += element.offsetTop; 11207 if (first) { 11208 first = false; 11209 // eslint-disable-next-line no-continue 11210 continue; 11211 } 11212 x += Text.toNumber(Dom.style(element, 'border-left-width')); 11213 y += Text.toNumber(Dom.style(element, 'border-top-width')); 11214 } 11215 return new DOMRect(x, y, w, h).toJSON(); 11216 } 11217 function addCustomEvent(eventObject, eventName, eventHandler) { 11218 if (Type.isString(eventObject)) { 11219 eventHandler = eventName; 11220 eventName = eventObject; 11221 eventObject = EventEmitter.GLOBAL_TARGET;
11222 } 11223 if (eventObject === window) { 11224 eventObject = EventEmitter.GLOBAL_TARGET; 11225 } 11226 if (!Type.isObject(eventObject)) { 11227 console.error('The "eventObject" argument must be an object. Received type ' + typeof eventObject + '.'); 11228 return; 11229 } 11230 if (!Type.isStringFilled(eventName)) { 11231 console.error('The "eventName" argument must be a string.'); 11232 return; 11233 } 11234 if (!Type.isFunction(eventHandler)) { 11235 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11236 return; 11237 } 11238 eventName = eventName.toLowerCase(); 11239 EventEmitter.subscribe(eventObject, eventName, eventHandler, { 11240 compatMode: true, 11241 useGlobalNaming: true 11242 }); 11243 } 11244 function onCustomEvent(eventObject, eventName, eventParams, secureParams) { 11245 if (Type.isString(eventObject)) { 11246 secureParams = eventParams; 11247 eventParams = eventName; 11248 eventName = eventObject; 11249 eventObject = EventEmitter.GLOBAL_TARGET; 11250 } 11251 if (!Type.isObject(eventObject) || eventObject === window) { 11252 eventObject = EventEmitter.GLOBAL_TARGET;
11253 } 11254 if (!eventParams) { 11255 eventParams = []; 11256 } 11257 eventName = eventName.toLowerCase(); 11258 const event = new BaseEvent(); 11259 event.setData(eventParams); 11260 event.setCompatData(eventParams); 11261 EventEmitter.emit(eventObject, eventName, event, { 11262 cloneData: secureParams === true, 11263 useGlobalNaming: true 11264 }); 11265 } 11266 function removeCustomEvent(eventObject, eventName, eventHandler) { 11267 if (Type.isString(eventObject)) { 11268 eventHandler = eventName; 11269 eventName = eventObject; 11270 eventObject = EventEmitter.GLOBAL_TARGET; 11271 } 11272 if (!Type.isFunction(eventHandler)) { 11273 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11274 return; 11275 } 11276 if (eventObject === window) { 11277 eventObject = EventEmitter.GLOBAL_TARGET; 11278 } 11279 eventName = eventName.toLowerCase(); 11280 EventEmitter.unsubscribe(eventObject, eventName, eventHandler, { 11281 useGlobalNaming: true 11282 }); 11283 } 11284 function removeAllCustomEvents(eventObject, eventName) { 11285 if (Type.isString(eventObject)) { 11286 eventName = eventObject; 11287 eventObject = EventEmitter.GLOBAL_TARGET;
11288 } 11289 if (eventObject === window) { 11290 eventObject = EventEmitter.GLOBAL_TARGET; 11291 } 11292 eventName = eventName.toLowerCase(); 11293 EventEmitter.unsubscribeAll(eventObject, eventName, { 11294 useGlobalNaming: true 11295 }); 11296 } 11297 11298 if (typeof global === 'object' && global.window && global.window.BX) { 11299 Object.assign(global.window.BX, exports); 11300 } 11301 11302 exports.Type = Type; 11303 exports.Reflection = Reflection; 11304 exports.Text = Text; 11305 exports.Dom = Dom; 11306 exports.Browser = Browser; 11307 exports.Event = Event; 11308 exports.Http = Http; 11309 exports.Runtime = Runtime; 11310 exports.Loc = Loc; 11311 exports.Tag = Tag; 11312 exports.Uri = Uri; 11313 exports.Validation = Validation; 11314 exports.Cache = Cache; 11315 exports.BaseError = BaseError; 11316 exports.Extension = Extension$1; 11317 exports.ZIndexManager = ZIndexManager; 11318 exports.Collections = collections; 11319 exports.getClass = getClass; 11320 exports.namespace = namespace; 11321 exports.message = message$1; 11322 exports.replace = replace; 11323 exports.remove = remove; 11324 exports.clean = clean; 11325 exports.insertBefore = insertBefore; 11326 exports.insertAfter = insertAfter; 11327 exports.append = append; 11328 exports.prepend = prepend; 11329 exports.style = style; 11330 exports.adjust = adjust; 11331 exports.create = create; 11332 exports.isShown = isShown; 11333 exports.addClass = addClass; 11334 exports.removeClass = removeClass; 11335 exports.hasClass = hasClass; 11336 exports.toggleClass = toggleClass; 11337 exports.cleanNode = cleanNode; 11338 exports.getCookie = getCookie; 11339 exports.setCookie = setCookie; 11340 exports.bind = bind$1; 11341 exports.unbind = unbind$1; 11342 exports.unbindAll = unbindAll$1; 11343 exports.bindOnce = bindOnce$1; 11344 exports.ready = ready$1; 11345 exports.debugEnableFlag = debugEnableFlag; 11346 exports.debugStatus = debugStatus; 11347 exports.debug = debug$1; 11348 exports.debugEnable = debugEnable; 11349 exports.clone = clone$1; 11350 exports.loadExt = loadExt; 11351 exports.debounce = debounce; 11352 exports.throttle = throttle; 11353 exports.html = html; 11354 exports.type = type; 11355 exports.browser = browser; 11356 exports.ajax = ajax; 11357 exports.GetWindowScrollSize = GetWindowScrollSize; 11358 exports.GetWindowScrollPos = GetWindowScrollPos; 11359 exports.GetWindowInnerSize = GetWindowInnerSize; 11360 exports.GetWindowSize = GetWindowSize; 11361 exports.GetContext = GetContext; 11362 exports.pos = pos; 11363 exports.addCustomEvent = addCustomEvent; 11364 exports.onCustomEvent = onCustomEvent; 11365 exports.removeCustomEvent = removeCustomEvent; 11366 exports.removeAllCustomEvents = removeAllCustomEvents; 11367 11368}((this.BX = this.BX || {}))); 11369 11370 11371 11372(function(BX) { 11373 /* list of registered proxy functions */ 11374 var proxyList = new WeakMap(); 11375 var deferList = new WeakMap(); 11376 11377 /* List of denied event handlers */ 11378 var deniedEvents = []; 11379 11380 /* list of registered custom events */ 11381 var customEvents = new WeakMap(); 11382 var customEventsCnt = 0; 11383 11384 /* list of external garbage collectors */ 11385 var garbageCollectors = []; 11386 11387 /* list of loaded CSS files */ 11388 var cssList = []; 11389 var cssInit = false; 11390 11391 /* list of loaded JS files */ 11392 var jsList = []; 11393 var jsInit = false; 11394 11395 var eventTypes = { 11396 click: 'MouseEvent', 11397 dblclick: 'MouseEvent', 11398 mousedown: 'MouseEvent', 11399 mousemove: 'MouseEvent', 11400 mouseout: 'MouseEvent', 11401 mouseover: 'MouseEvent', 11402 mouseup: 'MouseEvent', 11403 focus: 'MouseEvent', 11404 blur: 'MouseEvent' 11405 }; 11406 11407 var lastWait = []; 11408 11409 var CHECK_FORM_ELEMENTS = {tagName: /^INPUT|SELECT|TEXTAREA|BUTTON$/i}; 11410 11411 BX.MSLEFT = 1; 11412 BX.MSMIDDLE = 2; 11413 BX.MSRIGHT = 4; 11414 11415 BX.AM_PM_UPPER = 1; 11416 BX.AM_PM_LOWER = 2; 11417 BX.AM_PM_NONE = false; 11418 11419 BX.ext = function(ob) 11420 { 11421 for (var i in ob) 11422 { 11423 if(ob.hasOwnProperty(i)) 11424 { 11425 this[i] = ob[i]; 11426 } 11427 } 11428 }; 11429 11430 var r = { 11431 script: /<script([^>]*)>/ig, 11432 script_end: /<\/script>/ig, 11433 script_src: /src=["\']([^"\']+)["\']/i, 11434 script_type: /type=["\']([^"\']+)["\']/i, 11435 space: /\s+/, 11436 ltrim: /^[\s\r\n]+/g, 11437 rtrim: /[\s\r\n]+$/g, 11438 style: /<link.*?(rel="stylesheet"|type="text\/css")[^>]*>/i, 11439 style_href: /href=["\']([^"\']+)["\']/i 11440 }; 11441 11442 BX.processHTML = function(data, scriptsRunFirst) 11443 { 11444 var matchScript, matchStyle, matchSrc, matchHref, matchType, scripts = [], styles = []; 11445 var textIndexes = []; 11446 var lastIndex = r.script.lastIndex = r.script_end.lastIndex = 0; 11447 11448 while ((matchScript = r.script.exec(data)) !== null) 11449 { 11450 r.script_end.lastIndex = r.script.lastIndex; 11451 var matchScriptEnd = r.script_end.exec(data); 11452 if (matchScriptEnd === null) 11453 { 11454 break; 11455 } 11456 11457 // skip script tags of special types 11458 var skipTag = false;
11459 if ((matchType = matchScript[1].match(r.script_type)) !== null) 11460 { 11461 if( 11462 matchType[1] == 'text/html' 11463 || matchType[1] == 'text/template' 11464 || matchType[1] == 'extension/settings' 11465 ) 11466 { 11467 skipTag = true; 11468 } 11469 } 11470 11471 if(skipTag) 11472 { 11473 textIndexes.push([lastIndex, r.script_end.lastIndex - lastIndex]); 11474 } 11475 else 11476 { 11477 textIndexes.push([lastIndex, matchScript.index - lastIndex]); 11478 11479 var bRunFirst = scriptsRunFirst || (matchScript[1].indexOf('bxrunfirst') != '-1'); 11480 11481 if ((matchSrc = matchScript[1].match(r.script_src)) !== null) 11482 { 11483 scripts.push({"bRunFirst": bRunFirst, "isInternal": false, "JS": matchSrc[1]}); 11484 } 11485 else 11486 { 11487 var start = matchScript.index + matchScript[0].length; 11488 var js = data.substr(start, matchScriptEnd.index-start); 11489 11490 scripts.push({"bRunFirst": bRunFirst, "isInternal": true, "JS": js}); 11491 } 11492 } 11493 11494 lastIndex = matchScriptEnd.index + 9; 11495 r.script.lastIndex = lastIndex; 11496 } 11497 11498 textIndexes.push([lastIndex, lastIndex === 0 ? data.length : data.length - lastIndex]); 11499 var pureData = ""; 11500 for (var i = 0, length = textIndexes.length; i < length; i++) 11501 { 11502 if (BX.type.isString(data) && BX.type.isFunction(data.substr)) 11503 { 11504 pureData += data.substr(textIndexes[i][0], textIndexes[i][1]); 11505 } 11506 } 11507 11508 while ((matchStyle = pureData.match(r.style)) !== null) 11509 { 11510 if ((matchHref = matchStyle[0].match(r.style_href)) !== null && matchStyle[0].indexOf('media="') < 0) 11511 { 11512 styles.push(matchHref[1]); 11513 } 11514 11515 pureData = pureData.replace(matchStyle[0], ''); 11516 } 11517 11518 return {'HTML': pureData, 'SCRIPT': scripts, 'STYLE': styles}; 11519 }; 11520 11521 /* OO emulation utility */ 11522 BX.extend = function(child, parent) 11523 { 11524 var f = function() {}; 11525 f.prototype = parent.prototype; 11526 11527 child.prototype = new f(); 11528 child.prototype.constructor = child; 11529 11530 child.superclass = parent.prototype; 11531 child.prototype.superclass = parent.prototype; 11532 if(parent.prototype.constructor == Object.prototype.constructor) 11533 { 11534 parent.prototype.constructor = parent; 11535 } 11536 }; 11537 11538 BX.is_subclass_of = function(ob, parent_class) 11539 { 11540 if (ob instanceof parent_class) 11541 return true; 11542 11543 if (parent_class.superclass) 11544 return BX.is_subclass_of(ob, parent_class.superclass); 11545 11546 return false; 11547 }; 11548 11549 BX.clearNodeCache = function() 11550 { 11551 return false; 11552 }; 11553 11554 BX.bitrix_sessid = function() {return BX.message("bitrix_sessid"); }; 11555 11556 /** 11557 * Creates document fragment with child nodes. 11558 * 11559 * @param {Node[]} nodes 11560 * @return {DocumentFragment} 11561 */ 11562 BX.createFragment = function(nodes) 11563 { 11564 var fragment = document.createDocumentFragment(); 11565 11566 if(!BX.type.isArray(nodes)) 11567 { 11568 return fragment; 11569 } 11570 for(var i = 0; i < nodes.length; i++) 11571 { 11572 fragment.appendChild(nodes[i]); 11573 } 11574 11575 return fragment; 11576 }; 11577 11578 /** 11579 * @deprecated 11580 * @use BX.style 11581 * @param element 11582 * @param opacity 11583 */ 11584 BX.setOpacity = function(element, opacity) 11585 { 11586 var opacityValue = parseFloat(opacity); 11587 11588 if (!isNaN(opacityValue) && BX.type.isDomNode(element)) 11589 { 11590 opacityValue = opacityValue < 1 ? opacityValue : opacityValue / 100; 11591 BX.style(element, 'opacity', opacityValue); 11592 } 11593 }; 11594 11595 /** 11596 * @deprecated 11597 * @param el 11598 * @return {*} 11599 */ 11600 BX.hoverEvents = function(el) 11601 { 11602 if (el) 11603 return BX.adjust(el, {events: BX.hoverEvents()}); 11604 else 11605 return {mouseover: BX.hoverEventsHover, mouseout: BX.hoverEventsHout}; 11606 }; 11607 11608 /** 11609 * @deprecated 11610 */ 11611 BX.hoverEventsHover = function(){BX.addClass(this,'bx-hover');this.BXHOVER=true;}; 11612 /** 11613 * @deprecated 11614 */ 11615 BX.hoverEventsHout = function(){BX.removeClass(this,'bx-hover');this.BXHOVER=false;}; 11616 11617 /** 11618 * @deprecated 11619 */ 11620 BX.focusEvents = function(el) 11621 { 11622 if (el) 11623 return BX.adjust(el, {events: BX.focusEvents()}); 11624 else 11625 return {mouseover: BX.focusEventsFocus, mouseout: BX.focusEventsBlur}; 11626 }; 11627 11628 /** 11629 * @deprecated 11630 */ 11631 BX.focusEventsFocus = function(){BX.addClass(this,'bx-focus');this.BXFOCUS=true;}; 11632 /** 11633 * @deprecated 11634 */ 11635 BX.focusEventsBlur = function(){BX.removeClass(this,'bx-focus');this.BXFOCUS=false;}; 11636 11637 BX.setUnselectable = function(node) 11638 { 11639 BX.style(node, { 11640 'userSelect': 'none', 11641 'MozUserSelect': 'none', 11642 'WebkitUserSelect': 'none', 11643 'KhtmlUserSelect': 'none', 11644 }); 11645 node.setAttribute('unSelectable', 'on'); 11646 }; 11647 11648 BX.setSelectable = function(node) 11649 { 11650 BX.style(node, { 11651 'userSelect': null, 11652 'MozUserSelect': null, 11653 'WebkitUserSelect': null, 11654 'KhtmlUserSelect': null, 11655 }); 11656 node.removeAttribute('unSelectable'); 11657 }; 11658 11659 BX.styleIEPropertyName = function(name) 11660 { 11661 if (name == 'float') 11662 name = BX.browser.IsIE() ? 'styleFloat' : 'cssFloat'; 11663 else 11664 { 11665 var res = BX.browser.isPropertySupported(name); 11666 if (res) 11667 { 11668 name = res; 11669 } 11670 else 11671 {
11672 var reg = /(\-([a-z]){1})/g; 11673 if (reg.test(name)) 11674 { 11675 name = name.replace(reg, function () {return arguments[2].toUpperCase();}); 11676 } 11677 } 11678 } 11679 return name; 11680 }; 11681 11682 BX.focus = function(el) 11683 { 11684 try 11685 { 11686 el.focus(); 11687 return true; 11688 } 11689 catch (e) 11690 { 11691 return false; 11692 } 11693 }; 11694 11695 BX.firstChild = function(el) 11696 { 11697 return BX.type.isDomNode(el) ? el.firstElementChild : null; 11698 }; 11699 11700 BX.lastChild = function(el) 11701 { 11702 return BX.type.isDomNode(el) ? el.lastElementChild : null; 11703 }; 11704 11705 BX.previousSibling = function(el) 11706 { 11707 return BX.type.isDomNode(el) ? el.previousElementSibling : null; 11708 }; 11709 11710 BX.nextSibling = function(el) 11711 { 11712 return BX.type.isDomNode(el) ? el.nextElementSibling : null; 11713 }; 11714 11715 /* 11716 params: { 11717 obj : html node 11718 className : className value 11719 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 11720 } 11721 11722 Search all nodes with className 11723 */ 11724 /** 11725 * @deprecated 11726 * @use .querySelectorAll 11727 * @param obj 11728 * @param className 11729 * @param recursive 11730 * @return {*} 11731 */ 11732 BX.findChildrenByClassName = function(obj, className, recursive) 11733 { 11734 if(!obj || !obj.childNodes) return null; 11735 11736 var result = []; 11737 if (typeof(obj.getElementsByClassName) == 'undefined') 11738 { 11739 recursive = recursive !== false; 11740 result = BX.findChildren(obj, {className : className}, recursive); 11741 } 11742 else 11743 { 11744 var col = obj.getElementsByClassName(className); 11745 for (i=0,l=col.length;i<l;i++) 11746 { 11747 result[i] = col[i]; 11748 } 11749 } 11750 return result; 11751 }; 11752 11753 /* 11754 params: { 11755 obj : html node 11756 className : className value 11757 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 11758 } 11759 11760 Search first node with className 11761 */ 11762 /** 11763 * @deprecated 11764 * @use .querySelector 11765 * @param obj 11766 * @param className 11767 * @param recursive 11768 * @return {*} 11769 */ 11770 BX.findChildByClassName = function(obj, className, recursive) 11771 { 11772 if(!obj || !obj.childNodes) return null; 11773 11774 var result = null; 11775 if (typeof(obj.getElementsByClassName) == 'undefined') 11776 { 11777 recursive = recursive !== false; 11778 result = BX.findChild(obj, {className : className}, recursive); 11779 } 11780 else 11781 { 11782 var col = obj.getElementsByClassName(className); 11783 if (col && typeof(col[0]) != 'undefined') 11784 { 11785 result = col[0]; 11786 } 11787 else 11788 { 11789 result = null; 11790 } 11791 } 11792 return result; 11793 }; 11794 11795 /* 11796 params: { 11797 tagName|tag : 'tagName', 11798 className|class : 'className', 11799 attribute : {attribute : value, attribute : value} | attribute | [attribute, attribute....], 11800 property : {prop: value, prop: value} | prop | [prop, prop] 11801 } 11802 11803 all values can be RegExps or strings 11804 */ 11805 /** 11806 * @deprecated 11807 * @use .querySelectorAll 11808 * @param obj 11809 * @param params 11810 * @param recursive 11811 * @return {*|Node} 11812 */ 11813 BX.findChildren = function(obj, params, recursive) 11814 { 11815 return BX.findChild(obj, params, recursive, true); 11816 }; 11817 11818 /** 11819 * @deprecated 11820 * @use .querySelectorAll 11821 * @param obj 11822 * @param params 11823 * @param recursive 11824 * @param get_all 11825 * @return {*} 11826 */ 11827 BX.findChild = function(obj, params, recursive, get_all) 11828 { 11829 if(!obj || !obj.childNodes) return null; 11830 11831 recursive = !!recursive; get_all = !!get_all; 11832 11833 var n = obj.childNodes.length, result = []; 11834 11835 for (var j=0; j<n; j++) 11836 { 11837 var child = obj.childNodes[j]; 11838 11839 if (_checkNode(child, params)) 11840 { 11841 if (get_all) 11842 result.push(child); 11843 else 11844 return child; 11845 } 11846 11847 if(recursive == true) 11848 { 11849 var res = BX.findChild(child, params, recursive, get_all); 11850 if (res) 11851 { 11852 if (get_all) 11853 result = BX.util.array_merge(result, res); 11854 else 11855 return res; 11856 } 11857 } 11858 } 11859 11860 if (get_all || result.length > 0) 11861 return result; 11862 else 11863 return null; 11864 }; 11865 11866 /** 11867 * @deprecated 11868 * @use .closest() 11869 * @param obj 11870 * @param params 11871 * @param maxParent 11872 * @return {*} 11873 */ 11874 BX.findParent = function(obj, params, maxParent) 11875 { 11876 if(!obj) 11877 return null; 11878 11879 var o = obj; 11880 while(o.parentNode) 11881 { 11882 var parent = o.parentNode; 11883 11884 if (_checkNode(parent, params)) 11885 return parent; 11886 11887 o = parent; 11888 11889 if (!!maxParent &&
11890 (BX.type.isFunction(maxParent) 11891 || typeof maxParent == 'object')) 11892 { 11893 if (BX.type.isElementNode(maxParent)) 11894 { 11895 if (o == maxParent) 11896 break; 11897 } 11898 else 11899 { 11900 if (_checkNode(o, maxParent)) 11901 break; 11902 } 11903 } 11904 } 11905 return null; 11906 }; 11907 11908 /** 11909 * @deprecated 11910 * @use .querySelector 11911 * @param obj 11912 * @param params 11913 * @return {*} 11914 */ 11915 BX.findNextSibling = function(obj, params) 11916 { 11917 if(!obj) 11918 return null; 11919 var o = obj; 11920 while(o.nextSibling) 11921 { 11922 var sibling = o.nextSibling; 11923 if (_checkNode(sibling, params)) 11924 return sibling; 11925 o = sibling; 11926 } 11927 return null; 11928 }; 11929 11930 /** 11931 * @deprecated 11932 * @use .querySelector 11933 * @param obj 11934 * @param params 11935 * @return {*} 11936 */ 11937 BX.findPreviousSibling = function(obj, params) 11938 { 11939 if(!obj) 11940 return null; 11941 11942 var o = obj; 11943 while(o.previousSibling) 11944 { 11945 var sibling = o.previousSibling; 11946 if(_checkNode(sibling, params)) 11947 return sibling; 11948 o = sibling; 11949 } 11950 return null; 11951 }; 11952 11953 BX.checkNode = function(obj, params) 11954 { 11955 return _checkNode(obj, params); 11956 }; 11957 11958 /** 11959 * @deprecated 11960 * @use .querySelectorAll 11961 * @param form 11962 * @return {Array} 11963 */ 11964 BX.findFormElements = function(form) 11965 { 11966 if (BX.type.isString(form)) 11967 form = document.forms[form]||BX(form); 11968 11969 var res = []; 11970 11971 if (BX.type.isElementNode(form)) 11972 { 11973 if (form.tagName.toUpperCase() == 'FORM') 11974 { 11975 res = form.elements; 11976 } 11977 else 11978 { 11979 res = BX.findChildren(form, CHECK_FORM_ELEMENTS, true); 11980 } 11981 } 11982 11983 return res; 11984 }; 11985 11986 /** 11987 * @deprecated 11988 * @use .contains() 11989 * @param whichNode 11990 * @param forNode 11991 * @return {boolean} 11992 */ 11993 BX.isParentForNode = function(whichNode, forNode) 11994 { 11995 if (BX.type.isDomNode(whichNode) && BX.type.isDomNode(forNode)) 11996 { 11997 return whichNode.contains(forNode); 11998 } 11999 12000 return false; 12001 }; 12002 12003 BX.getCaretPosition = function(node) 12004 { 12005 var pos = 0; 12006 12007 if(node.selectionStart || node.selectionStart == 0) 12008 { 12009 pos = node.selectionStart; 12010 } 12011 else if(document.selection) 12012 { 12013 node.focus(); 12014 var selection = document.selection.createRange(); 12015 selection.moveStart('character', -node.value.length); 12016 pos = selection.text.length; 12017 } 12018 12019 return (pos); 12020 }; 12021 12022 BX.setCaretPosition = function(node, pos) 12023 { 12024 if(!BX.isNodeInDom(node) || BX.isNodeHidden(node) || node.disabled) 12025 { 12026 return; 12027 } 12028 12029 if(node.setSelectionRange) 12030 { 12031 node.focus(); 12032 node.setSelectionRange(pos, pos); 12033 } 12034 else if(node.createTextRange) 12035 { 12036 var range = node.createTextRange(); 12037 range.collapse(true); 12038 range.moveEnd('character', pos); 12039 range.moveStart('character', pos); 12040 range.select(); 12041 } 12042 }; 12043 12044 // access private. use BX.mergeEx instead. 12045 // todo: refactor BX.merge, make it work through BX.mergeEx 12046 BX.merge = function(){ 12047 var arg = Array.prototype.slice.call(arguments); 12048 12049 if(arg.length < 2) 12050 return {}; 12051 12052 var result = arg.shift(); 12053 12054 for(var i = 0; i < arg.length; i++) 12055 { 12056 for(var k in arg[i]){ 12057 12058 if(typeof arg[i] == 'undefined' || arg[i] == null) 12059 continue; 12060 12061 if(arg[i].hasOwnProperty(k)){ 12062 12063 if(typeof arg[i][k] == 'undefined' || arg[i][k] == null) 12064 continue; 12065 12066 if(typeof arg[i][k] == 'object' && !BX.type.isDomNode(arg[i][k]) && (typeof arg[i][k]['isUIWidget'] == 'undefined')){ 12067 12068 // go deeper 12069 12070 var isArray = 'length' in arg[i][k]; 12071 12072 if(typeof result[k] != 'object') 12073 result[k] = isArray ? [] : {}; 12074 12075 if(isArray) 12076 BX.util.array_merge(result[k], arg[i][k]); 12077 else 12078 BX.merge(result[k], arg[i][k]); 12079 12080 }else 12081 result[k] = arg[i][k]; 12082 } 12083 } 12084 } 12085 12086 return result; 12087 }; 12088 12089 BX.mergeEx = function() 12090 { 12091 var arg = Array.prototype.slice.call(arguments); 12092 if(arg.length < 2) 12093 { 12094 return {}; 12095 } 12096 12097 var result = arg.shift(); 12098 for (var i = 0; i < arg.length; i++) 12099 { 12100 for (var k in arg[i]) 12101 { 12102 if (typeof arg[i] == "undefined" || arg[i] == null || !arg[i].hasOwnProperty(k)) 12103 { 12104 continue; 12105 } 12106 12107 if (BX.type.isPlainObject(arg[i][k]) && BX.type.isPlainObject(result[k])) 12108 { 12109 BX.mergeEx(result[k], arg[i][k]); 12110 } 12111 else 12112 { 12113 result[k] = BX.type.isPlainObject(arg[i][k]) ? BX.clone(arg[i][k]) : arg[i][k]; 12114 } 12115 } 12116 } 12117 12118 return result; 12119 }; 12120 12121 BX.getEventButton = function(e) 12122 { 12123 e = e || window.event; 12124 12125 var flags = 0; 12126 12127 if (typeof e.which != 'undefined') 12128 { 12129 switch (e.which) 12130 { 12131 case 1: flags = flags|BX.MSLEFT; break; 12132 case 2: flags = flags|BX.MSMIDDLE; break; 12133 case 3: flags = flags|BX.MSRIGHT; break; 12134 } 12135 } 12136 else if (typeof e.button != 'undefined') 12137 { 12138 flags = event.button; 12139 } 12140 12141 return flags || BX.MSLEFT; 12142 }; 12143 12144 var captured_events = null, _bind = null; 12145 BX.CaptureEvents = function(el_c, evname_c) 12146 { 12147 if (_bind) 12148 return; 12149 12150 _bind = BX.bind; 12151 captured_events = []; 12152 12153 BX.bind = function(el, evname, func) 12154 { 12155 if (el === el_c && evname === evname_c) 12156 captured_events.push(func); 12157 12158 _bind.apply(this, arguments); 12159 } 12160 }; 12161 12162 BX.CaptureEventsGet = function() 12163 { 12164 if (_bind) 12165 { 12166 BX.bind = _bind; 12167 12168 var captured = captured_events; 12169 12170 _bind = null; 12171 captured_events = null; 12172 return captured; 12173 } 12174 return null; 12175 }; 12176 12177 // Don't even try to use it for submit event! 12178 BX.fireEvent = function(ob,ev) 12179 { 12180 var result = false, e = null; 12181 if (BX.type.isDomNode(ob)) 12182 { 12183 result = true; 12184 if (document.createEventObject) 12185 { 12186 // IE 12187 if (eventTypes[ev] != 'MouseEvent') 12188 { 12189 e = document.createEventObject(); 12190 e.type = ev; 12191 result = ob.fireEvent('on' + ev, e); 12192 } 12193 12194 if (ob[ev]) 12195 { 12196 ob[ev](); 12197 } 12198 } 12199 else 12200 {
12201 // non-IE 12202 e = null; 12203 12204 switch (eventTypes[ev]) 12205 { 12206 case 'MouseEvent': 12207 e = document.createEvent('MouseEvent'); 12208 try 12209 { 12210 e.initMouseEvent(ev, true, true, top, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12211 } 12212 catch (initException) 12213 { 12214 e.initMouseEvent(ev, true, true, window, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12215 } 12216 12217 break; 12218 default: 12219 e = document.createEvent('Event'); 12220 e.initEvent(ev, true, true); 12221 } 12222 12223 result = ob.dispatchEvent(e); 12224 } 12225 } 12226 12227 return result; 12228 }; 12229 12230 BX.getWheelData = function(e) 12231 { 12232 e = e || window.event; 12233 e.wheelData = e.detail ? e.detail * -1 : e.wheelDelta / 40; 12234 return e.wheelData; 12235 }; 12236 12237 BX.proxy_context = null; 12238 12239 BX.delegate = function (func, thisObject) 12240 { 12241 if (!func || !thisObject) 12242 return func; 12243 12244 return function() { 12245 var cur = BX.proxy_context; 12246 BX.proxy_context = this; 12247 var res = func.apply(thisObject, arguments); 12248 BX.proxy_context = cur; 12249 return res; 12250 } 12251 }; 12252 12253 BX.delegateLater = function (func_name, thisObject, contextObject) 12254 { 12255 return function() 12256 { 12257 if (thisObject[func_name]) 12258 { 12259 var cur = BX.proxy_context; 12260 BX.proxy_context = this; 12261 var res = thisObject[func_name].apply(contextObject||thisObject, arguments); 12262 BX.proxy_context = cur; 12263 return res; 12264 } 12265 return null; 12266 } 12267 }; 12268 12269 BX.proxy = function(func, thisObject) 12270 { 12271 return getObjectDelegate(func, thisObject, proxyList); 12272 }; 12273 12274 BX.defer = function(func, thisObject) 12275 { 12276 if (!!thisObject) 12277 return BX.defer_proxy(func, thisObject); 12278 else 12279 return function() { 12280 var arg = arguments; 12281 setTimeout(function(){func.apply(this,arg)}, 10); 12282 }; 12283 }; 12284 12285 BX.defer_proxy = function(func, thisObject) 12286 { 12287 return getObjectDelegate(func, thisObject, deferList, BX.defer); 12288 }; 12289 12290 /** 12291 * 12292 * @private 12293 */ 12294 function getObjectDelegate(func, thisObject, collection, decorator) 12295 { 12296 if (!BX.type.isFunction(func) || !BX.type.isMapKey(thisObject)) 12297 { 12298 return func; 12299 } 12300 12301 var objectDelegates = collection.get(thisObject); 12302 if (!objectDelegates) 12303 { 12304 objectDelegates = new WeakMap(); 12305 collection.set(thisObject, objectDelegates); 12306 } 12307 12308 var delegate = objectDelegates.get(func); 12309 if (!delegate) 12310 { 12311 delegate = decorator ? decorator(BX.delegate(func, thisObject)) : BX.delegate(func, thisObject); 12312 objectDelegates.set(func, delegate); 12313 } 12314 12315 return delegate; 12316 } 12317 12318 BX.once = function(el, evname, func) 12319 { 12320 var fn = function() 12321 { 12322 BX.unbind(el, evname, fn); 12323 func.apply(this, arguments); 12324 }; 12325 12326 return fn; 12327 }; 12328 12329 BX.bindDelegate = function (elem, eventName, isTarget, handler) 12330 { 12331 var h = BX.delegateEvent(isTarget, handler); 12332 BX.bind(elem, eventName, h); 12333 return h; 12334 }; 12335 12336 BX.delegateEvent = function(isTarget, handler) 12337 { 12338 return function(e) 12339 { 12340 e = e || window.event; 12341 var target = e.target || e.srcElement; 12342 12343 while (target != this) 12344 { 12345 if (_checkNode(target, isTarget)) 12346 { 12347 return handler.call(target, e); 12348 } 12349 if (target && target.parentNode) 12350 target = target.parentNode; 12351 else 12352 break; 12353 } 12354 return null; 12355 } 12356 }; 12357 12358 BX.False = function() {return false;}; 12359 BX.DoNothing = function() {}; 12360 12361 // TODO: also check event handlers set via BX.bind() 12362 BX.denyEvent = function(el, ev) 12363 { 12364 deniedEvents.push([el, ev, el['on' + ev]]); 12365 el['on' + ev] = BX.DoNothing; 12366 }; 12367 12368 BX.allowEvent = function(el, ev) 12369 { 12370 for(var i=0, len=deniedEvents.length; i<len; i++) 12371 { 12372 if (deniedEvents[i][0] == el && deniedEvents[i][1] == ev) 12373 { 12374 el['on' + ev] = deniedEvents[i][2]; 12375 BX.util.deleteFromArray(deniedEvents, i); 12376 return; 12377 } 12378 } 12379 }; 12380 12381 BX.fixEventPageXY = function(event) 12382 { 12383 BX.fixEventPageX(event); 12384 BX.fixEventPageY(event); 12385 return event; 12386 }; 12387 12388 BX.fixEventPageX = function(event) 12389 { 12390 if (event.pageX == null && event.clientX != null) 12391 { 12392 event.pageX = 12393 event.clientX + 12394 (document.documentElement && document.documentElement.scrollLeft || document.body && document.body.scrollLeft || 0) - 12395 (document.documentElement.clientLeft || 0); 12396 } 12397 12398 return event; 12399 }; 12400 12401 BX.fixEventPageY = function(event) 12402 { 12403 if (event.pageY == null && event.clientY != null) 12404 { 12405 event.pageY = 12406 event.clientY + 12407 (document.documentElement && document.documentElement.scrollTop || document.body && document.body.scrollTop || 0) - 12408 (document.documentElement.clientTop || 0); 12409 } 12410 12411 return event; 12412 }; 12413 12414 /** 12415 * @deprecated 12416 * @see e.preventDefault() 12417 */ 12418 BX.PreventDefault = function(e) 12419 { 12420 if(!e) e = window.event; 12421 if(e.stopPropagation) 12422 { 12423 e.preventDefault(); 12424 e.stopPropagation(); 12425 } 12426 else 12427 { 12428 e.cancelBubble = true; 12429 e.returnValue = false;
12430 } 12431 return false; 12432 }; 12433 12434 /** 12435 * @deprecated 12436 * @see e.preventDefault(); 12437 * 12438 * @param e 12439 * @return {boolean} 12440 */ 12441 BX.eventReturnFalse = function(e) 12442 { 12443 e=e||window.event; 12444 if (e && e.preventDefault) e.preventDefault(); 12445 else e.returnValue = false; 12446 return false; 12447 }; 12448 12449 /** 12450 * @deprecated 12451 * @see e.stopPropagation() 12452 * @param e 12453 */ 12454 BX.eventCancelBubble = function(e) 12455 { 12456 e=e||window.event; 12457 if(e && e.stopPropagation) 12458 e.stopPropagation(); 12459 else 12460 e.cancelBubble = true; 12461 }; 12462 12463 BX.bindDebouncedChange = function(node, fn, fnInstant, timeout, ctx) 12464 { 12465 ctx = ctx || window; 12466 timeout = timeout || 300; 12467 12468 var dataTag = 'bx-dc-previous-value'; 12469 BX.data(node, dataTag, node.value); 12470 12471 var act = function(fn, val){ 12472 12473 var pVal = BX.data(node, dataTag); 12474 12475 if(typeof pVal == 'undefined' || pVal != val){ 12476 if(typeof ctx != 'object') 12477 fn(val); 12478 else 12479 fn.apply(ctx, [val]); 12480 } 12481 }; 12482 12483 var actD = BX.debounce(function(){ 12484 var val = node.value; 12485 act(fn, val); 12486 BX.data(node, dataTag, val); 12487 }, timeout); 12488 12489 BX.bind(node, 'keyup', actD); 12490 BX.bind(node, 'change', actD); 12491 BX.bind(node, 'input', actD); 12492 12493 if(BX.type.isFunction(fnInstant)){ 12494 12495 var actI = function(){ 12496 act(fnInstant, node.value); 12497 }; 12498 12499 BX.bind(node, 'keyup', actI); 12500 BX.bind(node, 'change', actI); 12501 BX.bind(node, 'input', actI); 12502 } 12503 }; 12504 12505 BX.parseJSON = function(data, context) 12506 { 12507 var result = null; 12508 if (BX.type.isNotEmptyString(data)) 12509 { 12510 try { 12511 if (data.indexOf("\n") >= 0) 12512 eval('result = ' + data); 12513 else 12514 result = (new Function("return " + data))(); 12515 } catch(e) { 12516 BX.onCustomEvent(context, 'onParseJSONFailure', [data, context]) 12517 } 12518 } 12519 else if(BX.type.isPlainObject(data)) 12520 { 12521 return data; 12522 } 12523 12524 return result; 12525 }; 12526 12527 BX.submit = function(obForm, action_name, action_value, onAfterSubmit) 12528 { 12529 action_name = action_name || 'save'; 12530 if (!obForm['BXFormSubmit_' + action_name]) 12531 { 12532 obForm['BXFormSubmit_' + action_name] = obForm.appendChild(BX.create('INPUT', { 12533 'props': { 12534 'type': 'submit', 12535 'name': action_name, 12536 'value': action_value || 'Y' 12537 }, 12538 'style': { 12539 'display': 'none' 12540 } 12541 })); 12542 } 12543 12544 if (obForm.sessid) 12545 obForm.sessid.value = BX.bitrix_sessid(); 12546 12547 setTimeout(BX.delegate(function() {BX.fireEvent(this, 'click'); if (onAfterSubmit) onAfterSubmit();}, obForm['BXFormSubmit_' + action_name]), 10); 12548 }; 12549 12550 BX.show = function(ob, displayType) 12551 { 12552 if (ob.BXDISPLAY || !_checkDisplay(ob, displayType)) 12553 { 12554 ob.style.display = ob.BXDISPLAY; 12555 } 12556 }; 12557 12558 BX.hide = function(ob, displayType) 12559 { 12560 if (!ob.BXDISPLAY) 12561 _checkDisplay(ob, displayType); 12562 12563 ob.style.display = 'none'; 12564 }; 12565 12566 BX.toggle = function(ob, values) 12567 { 12568 if (!values && BX.type.isElementNode(ob)) 12569 { 12570 var bShow = true; 12571 if (ob.BXDISPLAY) 12572 bShow = !_checkDisplay(ob); 12573 else 12574 bShow = ob.style.display == 'none'; 12575 12576 if (bShow) 12577 BX.show(ob); 12578 else 12579 BX.hide(ob); 12580 } 12581 else if (BX.type.isArray(values)) 12582 { 12583 for (var i=0,len=values.length; i<len; i++) 12584 { 12585 if (ob == values[i]) 12586 { 12587 ob = values[i==len-1 ? 0 : i+1]; 12588 break; 12589 } 12590 } 12591 if (i==len) 12592 ob = values[0]; 12593 } 12594 12595 return ob; 12596 }; 12597 12598 function _checkDisplay(ob, displayType) 12599 { 12600 if (typeof displayType != 'undefined') 12601 ob.BXDISPLAY = displayType; 12602 12603 var d = ob.style.display || BX.style(ob, 'display'); 12604 if (d != 'none') 12605 { 12606 ob.BXDISPLAY = ob.BXDISPLAY || d; 12607 return true; 12608 } 12609 else 12610 { 12611 ob.BXDISPLAY = ob.BXDISPLAY || 'block'; 12612 return false; 12613 } 12614 } 12615 12616 /* some useful util functions */ 12617 12618 BX.util = { 12619 /** 12620 * @deprecated 12621 * @use [].filter(value => !BX.Type.isNil(value)) 12622 * @param ar 12623 * @return {*} 12624 */ 12625 array_values: function(ar) 12626 { 12627 if (!BX.type.isArray(ar)) 12628 return BX.util._array_values_ob(ar); 12629 var arv = []; 12630 for(var i=0,l=ar.length;i<l;i++) 12631 if (ar[i] !== null && typeof ar[i] != 'undefined') 12632 arv.push(ar[i]); 12633 return arv; 12634 }, 12635 12636 /** 12637 * @deprecated 12638 * @use Object.values([]).filter(value => !BX.Type.isNil(value)) 12639 * @param ar 12640 * @return {Array} 12641 * @private 12642 */ 12643 _array_values_ob: function(ar) 12644 { 12645 var arv = []; 12646 for(var i in ar) 12647 if (ar[i] !== null && typeof ar[i] != 'undefined') 12648 arv.push(ar[i]); 12649 return arv; 12650 }, 12651 12652 /** 12653 * @deprecated 12654 * @use 12655 * @param ar 12656 * @return {*} 12657 */ 12658 array_keys: function(ar) 12659 { 12660 if (!BX.type.isArray(ar)) 12661 return BX.util._array_keys_ob(ar); 12662 var arv = []; 12663 for(var i=0,l=ar.length;i<l;i++) 12664 if (ar[i] !== null && typeof ar[i] != 'undefined') 12665 arv.push(i); 12666 return arv; 12667 }, 12668 12669 _array_keys_ob: function(ar) 12670 { 12671 var arv = []; 12672 for(var i in ar) 12673 if (ar[i] !== null && typeof ar[i] != 'undefined') 12674 arv.push(i); 12675 return arv; 12676 }, 12677 12678 object_keys: function(obj) 12679 { 12680 var arv = []; 12681 for(var k in obj) 12682 { 12683 if(obj.hasOwnProperty(k)) 12684 { 12685 arv.push(k); 12686 } 12687 } 12688 return arv; 12689 }, 12690 12691 /** 12692 * @deprecated 12693 * @use firstArr.concat(secondArr); 12694 * @param first 12695 * @param second 12696 * @return {*[]} 12697 */ 12698 array_merge: function(first, second) 12699 { 12700 if (!BX.type.isArray(first)) first = []; 12701 if (!BX.type.isArray(second)) second = []; 12702 12703 var i = first.length, j = 0; 12704 12705 if (typeof second.length === "number") 12706 { 12707 for (var l = second.length; j < l; j++) 12708 { 12709 first[i++] = second[j]; 12710 } 12711 } 12712 else 12713 {
12714 while (second[j] !== undefined) 12715 { 12716 first[i++] = second[j++]; 12717 } 12718 } 12719 12720 first.length = i; 12721 12722 return first; 12723 }, 12724 12725 array_flip: function (object) 12726 { 12727 var newObject = {}; 12728 12729 for (var key in object) 12730 { 12731 newObject[object[key]] = key; 12732 } 12733 12734 return newObject; 12735 }, 12736 12737 array_diff: function(ar1, ar2, hash) 12738 { 12739 hash = BX.type.isFunction(hash) ? hash : null; 12740 var i, length, v, h, map = {}, result = []; 12741 for(i = 0, length = ar2.length; i < length; i++) 12742 { 12743 v = ar2[i]; 12744 h = hash ? hash(v) : v; 12745 map[h] = true; 12746 } 12747 12748 for(i = 0, length = ar1.length; i < length; i++) 12749 { 12750 v = ar1[i]; 12751 h = hash ? hash(v) : v; 12752 if(typeof(map[h]) === "undefined") 12753 { 12754 result.push(v); 12755 } 12756 } 12757 return result; 12758 }, 12759 12760 /** 12761 * @deprecated 12762 * @use Set 12763 */ 12764 array_unique: function(ar) 12765 { 12766 var i=0,j,len=ar.length; 12767 if(len<2) return ar; 12768 12769 for (; i<len-1;i++) 12770 { 12771 for (j=i+1; j<len;j++) 12772 { 12773 if (ar[i]==ar[j]) 12774 { 12775 ar.splice(j--,1); len--; 12776 } 12777 } 12778 } 12779 12780 return ar; 12781 }, 12782 12783 /** 12784 * @deprecated 12785 * @use myArr.includes(needle) 12786 */ 12787 in_array: function(needle, haystack) 12788 { 12789 for(var i=0; i<haystack.length; i++) 12790 { 12791 if(haystack[i] == needle) 12792 return true; 12793 } 12794 return false; 12795 }, 12796 12797 /** 12798 * @deprecated 12799 * @use myArr.findIndex(item => item === needle); 12800 */ 12801 array_search: function(needle, haystack) 12802 { 12803 for(var i=0; i<haystack.length; i++) 12804 { 12805 if(haystack[i] == needle) 12806 return i; 12807 } 12808 return -1; 12809 }, 12810 12811 object_search_key: function(needle, haystack) 12812 { 12813 if (typeof haystack[needle] != 'undefined') 12814 return haystack[needle]; 12815 12816 for(var i in haystack) 12817 { 12818 if (typeof haystack[i] == "object") 12819 { 12820 var result = BX.util.object_search_key(needle, haystack[i]); 12821 if (result !== false) 12822 return result; 12823 } 12824 } 12825 return false; 12826 }, 12827 12828 trim: function(s) 12829 { 12830 if (BX.type.isString(s)) 12831 { 12832 return s.trim(); 12833 } 12834 12835 return s; 12836 }, 12837 12838 urlencode: function(s){return encodeURIComponent(s);}, 12839 12840 // it may also be useful. via sVD. 12841 deleteFromArray: function(ar, ind) {return ar.slice(0, ind).concat(ar.slice(ind + 1));}, 12842 insertIntoArray: function(ar, ind, el) {return ar.slice(0, ind).concat([el]).concat(ar.slice(ind));}, 12843 12844 htmlspecialchars: function(str) 12845 { 12846 return BX.Text.encode(str); 12847 }, 12848 12849 htmlspecialcharsback: function(str) 12850 { 12851 return BX.Text.decode(str); 12852 }, 12853 12854 // Quote regular expression characters plus an optional character 12855 preg_quote: function(str, delimiter) 12856 { 12857 if(!str.replace) 12858 return str; 12859 return str.replace(new RegExp('[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + (delimiter || '') + '-]', 'g'), '\\$&'); 12860 }, 12861 12862 jsencode: function(str) 12863 { 12864 if (!str || !str.replace) 12865 return str; 12866 12867 var escapes = 12868 [ 12869 { c: "\\\\", r: "\\\\" }, // should be first 12870 { c: "\\t", r: "\\t" }, 12871 { c: "\\n", r: "\\n" }, 12872 { c: "\\r", r: "\\r" }, 12873 { c: "\"", r: "\\\"" }, 12874 { c: "'", r: "\\'" }, 12875 { c: "<", r: "\\x3C" }, 12876 { c: ">", r: "\\x3E" }, 12877 { c: "\\u2028", r: "\\u2028" }, 12878 { c: "\\u2029", r: "\\u2029" } 12879 ]; 12880 for (var i = 0; i < escapes.length; i++) 12881 str = str.replace(new RegExp(escapes[i].c, 'g'), escapes[i].r); 12882 return str; 12883 }, 12884 12885 getCssName: function(jsName) 12886 { 12887 if (!BX.type.isNotEmptyString(jsName)) 12888 { 12889 return ""; 12890 } 12891 12892 return jsName.replace(/[A-Z]/g, function(match) { 12893 return "-" + match.toLowerCase(); 12894 }); 12895 }, 12896 12897 getJsName: function(cssName) 12898 { 12899 var regex = /\-([a-z]){1}/g; 12900 if (regex.test(cssName)) 12901 { 12902 return cssName.replace(regex, function(match, letter) { 12903 return letter.toUpperCase(); 12904 }); 12905 } 12906 12907 return cssName; 12908 }, 12909 12910 nl2br: function(str) 12911 { 12912 if (!str || !str.replace) 12913 return str; 12914 12915 return str.replace(/([^>])\n/g, '$1<br/>'); 12916 }, 12917 12918 /** 12919 * @deprecated 12920 * @use .padStart() / .padEnd() 12921 * @param input 12922 * @param pad_length 12923 * @param pad_string 12924 * @param pad_type 12925 * @return {*} 12926 */ 12927 str_pad: function(input, pad_length, pad_string, pad_type) 12928 { 12929 pad_string = pad_string || ' '; 12930 pad_type = pad_type || 'right'; 12931 input = input.toString(); 12932 12933 if (pad_type === 'left') 12934 { 12935 return BX.util.str_pad_left(input, pad_length, pad_string); 12936 } 12937 12938 return BX.util.str_pad_right(input, pad_length, pad_string); 12939 }, 12940 12941 str_pad_left: function(input, pad_length, pad_string) 12942 { 12943 return input.toString().padStart(pad_length, pad_string); 12944 }, 12945 12946 str_pad_right: function(input, pad_length, pad_string) 12947 { 12948 return input.toString().padEnd(pad_length, pad_string); 12949 }, 12950 12951 strip_tags: function(str) 12952 { 12953 return str.split(/<[^>]+>/g).join(''); 12954 }, 12955 12956 strip_php_tags: function(str) 12957 { 12958 return str.replace(/<\?(.|[\r\n])*?\?>/g, ''); 12959 }, 12960 12961 popup: function(url, width, height) 12962 { 12963 var w, h; 12964 if(BX.browser.IsOpera()) 12965 { 12966 w = document.body.offsetWidth; 12967 h = document.body.offsetHeight; 12968 } 12969 else 12970 {
12971 w = screen.width; 12972 h = screen.height; 12973 } 12974 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)); 12975 }, 12976 12977 shuffle: function(array) 12978 { 12979 var temporaryValue, randomIndex; 12980 var currentIndex = array.length; 12981 12982 while (0 !== currentIndex) 12983 { 12984 randomIndex = Math.floor(Math.random() * currentIndex); 12985 currentIndex -= 1; 12986 12987 temporaryValue = array[currentIndex]; 12988 array[currentIndex] = array[randomIndex]; 12989 array[randomIndex] = temporaryValue; 12990 } 12991 12992 return array; 12993 }, 12994 12995 // BX.util.objectSort(object, sortBy, sortDir) - Sort object by property 12996 // function params: 1 - object for sort, 2 - sort by property, 3 - sort direction (asc/desc) 12997 // return: sort array [[objectElement], [objectElement]] in sortDir direction 12998 12999 // example: BX.util.objectSort({'L1': {'name': 'Last'}, 'F1': {'name': 'First'}}, 'name', 'asc'); 13000 // return: [{'name' : 'First'}, {'name' : 'Last'}] 13001 objectSort: function(object, sortBy, sortDir) 13002 { 13003 sortDir = sortDir == 'asc'? 'asc': 'desc'; 13004 13005 var arItems = [], i; 13006 for (i in object) 13007 { 13008 if (object.hasOwnProperty(i) && object[i][sortBy]) 13009 { 13010 arItems.push([i, object[i][sortBy]]); 13011 } 13012 } 13013 13014 if (sortDir == 'asc') 13015 { 13016 arItems.sort(function(i, ii) { 13017 var s1, s2; 13018 if (BX.type.isDate(i[1])) 13019 { 13020 s1 = i[1].getTime(); 13021 } 13022 else if (!isNaN(i[1])) 13023 { 13024 s1 = parseInt(i[1]); 13025 } 13026 else 13027 { 13028 s1 = i[1].toString().toLowerCase(); 13029 } 13030 13031 if (BX.type.isDate(ii[1])) 13032 { 13033 s2 = ii[1].getTime(); 13034 } 13035 else if (!isNaN(ii[1])) 13036 { 13037 s2 = parseInt(ii[1]); 13038 } 13039 else 13040 { 13041 s2 = ii[1].toString().toLowerCase(); 13042 } 13043 13044 if (s1 > s2) 13045 return 1; 13046 else if (s1 < s2) 13047 return -1; 13048 else 13049 return 0; 13050 }); 13051 } 13052 else 13053 { 13054 arItems.sort(function(i, ii) { 13055 var s1, s2; 13056 if (BX.type.isDate(i[1])) 13057 { 13058 s1 = i[1].getTime(); 13059 } 13060 else if (!isNaN(i[1])) 13061 { 13062 s1 = parseInt(i[1]); 13063 } 13064 else 13065 { 13066 s1 = i[1].toString().toLowerCase(); 13067 } 13068 13069 if (BX.type.isDate(ii[1])) 13070 { 13071 s2 = ii[1].getTime(); 13072 } 13073 else if (!isNaN(ii[1])) 13074 { 13075 s2 = parseInt(ii[1]); 13076 } 13077 else 13078 { 13079 s2 = ii[1].toString().toLowerCase(); 13080 } 13081 13082 if (s1 < s2) 13083 return 1; 13084 else if (s1 > s2) 13085 return -1; 13086 else 13087 return 0; 13088 }); 13089 } 13090 13091 var arReturnArray = Array(); 13092 for (i = 0; i < arItems.length; i++) 13093 { 13094 arReturnArray.push(object[arItems[i][0]]); 13095 } 13096 13097 return arReturnArray; 13098 }, 13099 13100 objectMerge: function() 13101 { 13102 return BX.mergeEx.apply(window, arguments); 13103 }, 13104 13105 objectClone : function(object) 13106 { 13107 return BX.clone(object, true); 13108 }, 13109 13110 // #fdf9e5 => {r=253, g=249, b=229} 13111 hex2rgb: function(color) 13112 { 13113 var rgb = color.replace(/[# ]/g,"").replace(/^(.)(.)(.)$/,'$1$1$2$2$3$3').match(/.{2}/g); 13114 for (var i=0; i<3; i++) 13115 { 13116 rgb[i] = parseInt(rgb[i], 16); 13117 } 13118 return {'r':rgb[0],'g':rgb[1],'b':rgb[2]}; 13119 }, 13120 13121 /** 13122 * @deprecated 13123 * @use BX.Uri 13124 * @param url 13125 * @param param 13126 * @return {string} 13127 */ 13128 remove_url_param: function(url, param) 13129 { 13130 return BX.Uri.removeParam(url, param); 13131 }, 13132 13133 /* 13134 {'param1': 'value1', 'param2': 'value2'} 13135 */ 13136 /** 13137 * @deprecated 13138 * @use BX.Uri 13139 * @param url 13140 * @param params 13141 * @return {string} 13142 */ 13143 add_url_param: function(url, params) 13144 { 13145 var preparedParams = Object.entries(params).reduce(function(acc, item) { 13146 acc[item[0]] = BX.type.isArray(item[1]) ? item[1].join() : item[1]; 13147 return acc; 13148 }, {}); 13149 13150 return BX.Uri.addParam(url, preparedParams); 13151 }, 13152 13153 /* 13154 {'param1': 'value1', 'param2': 'value2'} 13155 */ 13156 buildQueryString: function(params) 13157 { 13158 var result = ''; 13159 for (var key in params) 13160 { 13161 var value = params[key]; 13162 if(BX.type.isArray(value)) 13163 { 13164 value.forEach(function(valueElement, index) 13165 { 13166 result += encodeURIComponent(key + "[" + index + "]") + "=" + encodeURIComponent(valueElement) + "&"; 13167 }); 13168 } 13169 else 13170 { 13171 result += encodeURIComponent(key) + "=" + encodeURIComponent(value) + "&"; 13172 } 13173 } 13174 13175 if(result.length > 0) 13176 { 13177 result = result.substr(0, result.length - 1); 13178 } 13179 return result; 13180 }, 13181 13182 even: function(digit) 13183 { 13184 return (parseInt(digit) % 2 == 0); 13185 }, 13186 13187 hashCode: function(str) 13188 { 13189 if(!BX.type.isNotEmptyString(str)) 13190 { 13191 return 0; 13192 } 13193 13194 var hash = 0; 13195 for (var i = 0; i < str.length; i++) 13196 { 13197 var c = str.charCodeAt(i); 13198 hash = ((hash << 5) - hash) + c; 13199 hash = hash & hash; 13200 } 13201 return hash; 13202 }, 13203 13204 getRandomString: function (length) 13205 { 13206 return BX.Text.getRandom(length); 13207 }, 13208 13209 number_format: function(number, decimals, dec_point, thousands_sep) 13210 { 13211 var i, j, kw, kd, km, sign = ''; 13212 decimals = Math.abs(decimals); 13213 if (isNaN(decimals) || decimals < 0) 13214 { 13215 decimals = 2; 13216 } 13217 dec_point = dec_point || ','; 13218 if (typeof thousands_sep === 'undefined') 13219 thousands_sep = '.'; 13220 13221 number = (+number || 0).toFixed(decimals); 13222 if (number < 0) 13223 { 13224 sign = '-'; 13225 number = -number; 13226 } 13227 13228 i = parseInt(number, 10) + ''; 13229 j = (i.length > 3 ? i.length % 3 : 0); 13230 13231 km = (j ? i.substr(0, j) + thousands_sep : ''); 13232 kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep); 13233 kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, '0').slice(2) : ''); 13234 13235 return sign + km + kw + kd; 13236 }, 13237 13238 getExtension: function (url) 13239 { 13240 url = url || ""; 13241 var items = url.split("?")[0].split("."); 13242 return items[items.length-1].toLowerCase(); 13243 }, 13244 addObjectToForm: function(object, form, prefix) 13245 { 13246 if(!BX.type.isString(prefix)) 13247 { 13248 prefix = ""; 13249 } 13250 13251 for(var key in object) 13252 { 13253 if(!object.hasOwnProperty(key)) 13254 { 13255 continue; 13256 } 13257 13258 var value = object[key]; 13259 var name = prefix !== "" ? (prefix + "[" + key + "]") : key; 13260 if(BX.type.isArray(value)) 13261 { 13262 var obj = {}; 13263 for(var i = 0; i < value.length; i++) 13264 { 13265 obj[i] = value[i]; 13266 } 13267 13268 BX.util.addObjectToForm(obj, form, name); 13269 } 13270 else if(BX.type.isPlainObject(value)) 13271 { 13272 BX.util.addObjectToForm(value, form, name); 13273 } 13274 else 13275 { 13276 value = BX.type.isFunction(value.toString) ? value.toString() : ""; 13277 if(value !== "") 13278 { 13279 form.appendChild(BX.create("INPUT", { attrs: { type: "hidden", name: name, value: value } })); 13280 } 13281 } 13282 } 13283 }, 13284 13285 observe: function(object, enable) 13286 {
13287 console.error('BX.util.observe: function is no longer supported by browser.'); 13288 return false; 13289 }, 13290 13291 escapeRegExp: function(str) 13292 { 13293 return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); 13294 } 13295 }; 13296 13297 BX.validation = { 13298 checkIfEmail: function(s) 13299 { 13300 var atom = "[=a-z0-9_+~'!$&*^`|#%/?{}-]"; 13301 return (new RegExp('^\\s*'+atom+'+(\\.'+atom+'+)*@([a-z0-9-]+\\.)+[a-z0-9-]{2,20}\\s*$', 'i')).test(s); 13302 }, 13303 checkIfPhone: function(s) 13304 { 13305 var regexp = new RegExp( 13306 typeof(BX.PhoneNumber) === "undefined" 13307 ? BX.PhoneNumber.getValidNumberPattern() 13308 : '^\\s*\\+?\s*[0-9(-)\\s]+\\s*$', 13309 'i' 13310 ); 13311 return regexp.test(s); 13312 } 13313 }; 13314 13315 BX.prop = 13316 { 13317 get: function(object, key, defaultValue) 13318 { 13319 return object && object.hasOwnProperty(key) ? object[key] : defaultValue; 13320 }, 13321 getObject: function(object, key, defaultValue) 13322 { 13323 return object && BX.type.isPlainObject(object[key]) ? object[key] : defaultValue; 13324 }, 13325 getElementNode: function(object, key, defaultValue) 13326 { 13327 return object && BX.type.isElementNode(object[key]) ? object[key] : defaultValue; 13328 }, 13329 getArray: function(object, key, defaultValue) 13330 { 13331 return object && BX.type.isArray(object[key]) ? object[key] : defaultValue; 13332 }, 13333 getFunction: function(object, key, defaultValue) 13334 { 13335 return object && BX.type.isFunction(object[key]) ? object[key] : defaultValue; 13336 }, 13337 getNumber: function(object, key, defaultValue) 13338 { 13339 if(!(object && object.hasOwnProperty(key))) 13340 { 13341 return defaultValue; 13342 } 13343 13344 var value = object[key]; 13345 if(BX.type.isNumber(value)) 13346 { 13347 return value; 13348 } 13349 13350 value = parseFloat(value); 13351 return !isNaN(value) ? value : defaultValue; 13352 }, 13353 getInteger: function(object, key, defaultValue) 13354 { 13355 if(!(object && object.hasOwnProperty(key))) 13356 { 13357 return defaultValue; 13358 } 13359 13360 var value = object[key]; 13361 if(BX.type.isNumber(value)) 13362 { 13363 return value; 13364 } 13365 13366 value = parseInt(value); 13367 return !isNaN(value) ? value : defaultValue; 13368 }, 13369 getBoolean: function(object, key, defaultValue) 13370 { 13371 if(!(object && object.hasOwnProperty(key))) 13372 { 13373 return defaultValue; 13374 } 13375 13376 var value = object[key]; 13377 return (BX.type.isBoolean(value) 13378 ? value 13379 : (BX.type.isString(value) ? (value.toLowerCase() === "true") : !!value) 13380 ); 13381 }, 13382 getString: function(object, key, defaultValue) 13383 { 13384 if(!(object && object.hasOwnProperty(key))) 13385 { 13386 return defaultValue; 13387 } 13388 13389 var value = object[key]; 13390 return BX.type.isString(value) ? value : (value ? value.toString() : ''); 13391 }, 13392 extractDate: function(datetime) 13393 { 13394 if(!BX.type.isDate(datetime)) 13395 { 13396 datetime = new Date(); 13397 } 13398 13399 datetime.setHours(0); 13400 datetime.setMinutes(0); 13401 datetime.setSeconds(0); 13402 datetime.setMilliseconds(0); 13403 13404 return datetime; 13405 } 13406 }; 13407 13408 BX.isNodeInDom = function(node, doc) 13409 { 13410 return node === (doc || document) ? true : 13411 (node.parentNode ? BX.isNodeInDom(node.parentNode) : false); 13412 }; 13413 13414 BX.isNodeHidden = function(node) 13415 { 13416 if (node === document) 13417 return false; 13418 else if (BX.style(node, 'display') == 'none') 13419 return true; 13420 else 13421 return (node.parentNode ? BX.isNodeHidden(node.parentNode) : true); 13422 }; 13423 13424 BX.evalPack = function(code) 13425 { 13426 while (code.length > 0) 13427 { 13428 var c = code.shift(); 13429 13430 if (c.TYPE == 'SCRIPT_EXT' || c.TYPE == 'SCRIPT_SRC') 13431 { 13432 BX.loadScript(c.DATA, function() {BX.evalPack(code)}); 13433 return; 13434 } 13435 else if (c.TYPE == 'SCRIPT') 13436 { 13437 BX.evalGlobal(c.DATA); 13438 } 13439 } 13440 }; 13441 13442 BX.evalGlobal = function(data) 13443 { 13444 if (data) 13445 { 13446 var head = document.getElementsByTagName("head")[0] || document.documentElement, 13447 script = document.createElement("script"); 13448 13449 script.type = "text/javascript"; 13450 13451 if (!BX.browser.IsIE()) 13452 { 13453 script.appendChild(document.createTextNode(data)); 13454 } 13455 else 13456 { 13457 script.text = data; 13458 } 13459 13460 head.insertBefore(script, head.firstChild); 13461 head.removeChild(script); 13462 } 13463 }; 13464 13465 BX.garbage = function(call, thisObject) 13466 { 13467 garbageCollectors.push({callback: call, context: thisObject}); 13468 }; 13469 13470 BX.GetDocElement = function (pDoc) 13471 { 13472 pDoc = pDoc || document; 13473 return (BX.browser.IsDoctype(pDoc) ? pDoc.documentElement : pDoc.body); 13474 }; 13475 13476 BX.scrollTop = function(node, val){ 13477 if(typeof val != 'undefined'){ 13478 13479 if(node == window){ 13480 throw new Error('scrollTop() for window is not implemented'); 13481 }else 13482 node.scrollTop = parseInt(val); 13483 13484 }else{ 13485 13486 if(node == window) 13487 return BX.GetWindowScrollPos().scrollTop; 13488 13489 return node.scrollTop; 13490 } 13491 }; 13492 13493 BX.scrollLeft = function(node, val){ 13494 if(typeof val != 'undefined'){ 13495 13496 if(node == window){ 13497 throw new Error('scrollLeft() for window is not implemented'); 13498 }else 13499 node.scrollLeft = parseInt(val); 13500 13501 }else{ 13502 13503 if(node == window) 13504 return BX.GetWindowScrollPos().scrollLeft; 13505 13506 return node.scrollLeft; 13507 } 13508 }; 13509 13510 BX.hide_object = function(ob) 13511 { 13512 ob = BX(ob); 13513 ob.style.position = 'absolute'; 13514 ob.style.top = '-1000px'; 13515 ob.style.left = '-1000px'; 13516 ob.style.height = '10px'; 13517 ob.style.width = '10px'; 13518 }; 13519 13520 BX.is_relative = function(el) 13521 { 13522 var p = BX.style(el, 'position'); 13523 return p == 'relative' || p == 'absolute'; 13524 }; 13525 13526 BX.is_float = function(el) 13527 { 13528 var p = BX.style(el, 'float'); 13529 return p == 'right' || p == 'left'; 13530 }; 13531 13532 BX.is_fixed = function(el) 13533 { 13534 var p = BX.style(el, 'position'); 13535 return p == 'fixed'; 13536 }; 13537 13538 BX.width = function(node, val){ 13539 if(typeof val != 'undefined') 13540 BX.style(node, 'width', parseInt(val)+'px'); 13541 else{ 13542 13543 if(node == window) 13544 return window.innerWidth; 13545 13546 //return parseInt(BX.style(node, 'width')); 13547 return BX.pos(node).width; 13548 } 13549 }; 13550 13551 BX.height = function(node, val){ 13552 if(typeof val != 'undefined') 13553 BX.style(node, 'height', parseInt(val)+'px'); 13554 else{ 13555 13556 if(node == window) 13557 return window.innerHeight; 13558 13559 //return parseInt(BX.style(node, 'height')); 13560 return BX.pos(node).height; 13561 } 13562 }; 13563 13564 BX.align = function(pos, w, h, type) 13565 { 13566 if (type) 13567 type = type.toLowerCase(); 13568 else 13569 type = ''; 13570 13571 var pDoc = document; 13572 if (BX.type.isElementNode(pos)) 13573 { 13574 pDoc = pos.ownerDocument; 13575 pos = BX.pos(pos); 13576 } 13577 13578 var x = pos["left"], y = pos["bottom"]; 13579 13580 var scroll = BX.GetWindowScrollPos(pDoc); 13581 var size = BX.GetWindowInnerSize(pDoc); 13582 13583 if((size.innerWidth + scroll.scrollLeft) - (pos["left"] + w) < 0) 13584 { 13585 if(pos["right"] - w >= 0 ) 13586 x = pos["right"] - w; 13587 else 13588 x = scroll.scrollLeft; 13589 } 13590
13591 if(((size.innerHeight + scroll.scrollTop) - (pos["bottom"] + h) < 0) || ~type.indexOf('top')) 13592 { 13593 if(pos["top"] - h >= 0 || ~type.indexOf('top')) 13594 y = pos["top"] - h; 13595 else 13596 y = scroll.scrollTop; 13597 } 13598 13599 return {'left':x, 'top':y}; 13600 }; 13601 13602 BX.scrollToNode = function(node) 13603 { 13604 var obNode = BX(node); 13605 13606 if (obNode.scrollIntoView) 13607 obNode.scrollIntoView(true); 13608 else 13609 { 13610 var arNodePos = BX.pos(obNode); 13611 window.scrollTo(arNodePos.left, arNodePos.top); 13612 } 13613 }; 13614 13615 /* non-xhr loadings */ 13616 BX.showWait = function(node, msg) 13617 { 13618 node = BX(node) || document.body || document.documentElement; 13619 msg = msg || BX.message('JS_CORE_LOADING'); 13620 13621 var container_id = node.id || Math.random(); 13622 13623 var obMsg = node.bxmsg = document.body.appendChild(BX.create('DIV', { 13624 props: { 13625 id: 'wait_' + container_id 13626 }, 13627 style: { 13628 background: 'url("/bitrix/js/main/core/images/wait.gif") no-repeat scroll 10px center #fcf7d1', 13629 border: '1px solid #E1B52D', 13630 color: 'black', 13631 fontFamily: 'Verdana,Arial,sans-serif', 13632 fontSize: '11px', 13633 padding: '10px 30px 10px 37px', 13634 position: 'absolute', 13635 textAlign:'center' 13636 }, 13637 text: msg 13638 })); 13639 13640 BX.ZIndexManager.register(obMsg); 13641 BX.ZIndexManager.bringToFront(obMsg); 13642 13643 setTimeout(BX.delegate(_adjustWait, node), 10); 13644 13645 lastWait[lastWait.length] = obMsg; 13646 return obMsg; 13647 }; 13648 13649 BX.closeWait = function(node, obMsg) 13650 { 13651 if(node && !obMsg) 13652 obMsg = node.bxmsg; 13653 if(node && !obMsg && BX.hasClass(node, 'bx-core-waitwindow')) 13654 obMsg = node; 13655 if(node && !obMsg) 13656 obMsg = BX('wait_' + node.id); 13657 if(!obMsg) 13658 obMsg = lastWait.pop(); 13659 13660 if (obMsg && obMsg.parentNode) 13661 { 13662 for (var i=0,len=lastWait.length;i<len;i++) 13663 { 13664 if (obMsg == lastWait[i]) 13665 { 13666 lastWait = BX.util.deleteFromArray(lastWait, i); 13667 break; 13668 } 13669 } 13670 13671 BX.ZIndexManager.unregister(obMsg); 13672 obMsg.parentNode.removeChild(obMsg); 13673 if (node) node.bxmsg = null; 13674 BX.cleanNode(obMsg, true); 13675 } 13676 }; 13677 13678 BX.setJSList = function(scripts) 13679 { 13680 if (BX.type.isArray(scripts)) 13681 { 13682 scripts = scripts.map(function(script) { 13683 return normalizeUrl(script) 13684 }); 13685 13686 jsList = jsList.concat(scripts); 13687 } 13688 }; 13689 13690 BX.getJSList = function() 13691 { 13692 initJsList(); 13693 return jsList; 13694 }; 13695 13696 BX.setCSSList = function(cssFiles) 13697 { 13698 if (BX.type.isArray(cssFiles)) 13699 { 13700 cssFiles = cssFiles.map(function(cssFile) { 13701 return normalizeUrl(cssFile); 13702 }); 13703 13704 cssList = cssList.concat(cssFiles); 13705 } 13706 }; 13707 13708 BX.getCSSList = function() 13709 { 13710 initCssList(); 13711 return cssList; 13712 }; 13713 13714 BX.getJSPath = function(js) 13715 { 13716 return js.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 13717 }; 13718 13719 BX.getCSSPath = function(css) 13720 { 13721 return css.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 13722 }; 13723 13724 BX.getCDNPath = function(path) 13725 { 13726 return path; 13727 }; 13728 13729 BX.loadScript = function(script, callback, doc) 13730 { 13731 if (BX.type.isString(script)) 13732 { 13733 script = [script]; 13734 } 13735 13736 return BX.load(script, callback, doc); 13737 }; 13738 13739 BX.loadCSS = function(css, doc, win) 13740 { 13741 if (BX.type.isString(css)) 13742 { 13743 css = [css]; 13744 } 13745 13746 if (BX.type.isArray(css)) 13747 { 13748 css = css.map(function(url) { 13749 return { url: url, ext: "css" } 13750 }); 13751 13752 BX.load(css, null, doc); 13753 } 13754 }; 13755 13756 const LOADING = 3; 13757 const LOADED = 4; 13758 const assets = {}; 13759 const loadingAssetCallbacks = {}; 13760 13761 BX.load = function(items, callback, doc) 13762 { 13763 if (!BX.isReady) 13764 { 13765 var _args = arguments; 13766 BX.ready(function() { 13767 BX.load.apply(this, _args); 13768 }); 13769 13770 return null; 13771 } 13772 13773 doc = doc || document; 13774 13775 callback = BX.Type.isFunction(callback) ? callback : () => {}; 13776 13777 return loadAsync(items, callback, doc); 13778 }; 13779 13780 function loadAsync(items, callback, doc) 13781 { 13782 if (!BX.type.isArray(items)) 13783 { 13784 callback(); 13785 13786 return; 13787 } 13788 13789 function onLoad() 13790 { 13791 const nextAsset = queue.shift(); 13792 if (nextAsset) 13793 { 13794 load(nextAsset, onLoad, doc); 13795 } 13796 else if (allLoaded()) 13797 { 13798 callback(); 13799 } 13800 } 13801 13802 function allLoaded() 13803 { 13804 for (const name in assetMap) 13805 { 13806 if (assetMap[name].state !== LOADED) 13807 { 13808 return false; 13809 } 13810 } 13811 13812 return true; 13813 } 13814 13815 const queue = []; 13816 const assetMap = {}; 13817 items.forEach(item => { 13818 const asset = getAsset(item); 13819 if (asset && asset.state !== LOADED) 13820 { 13821 queue.push(asset); 13822 assetMap[asset.name] = asset; 13823 } 13824 }); 13825 13826 if (queue.length > 0) 13827 {
13828 const maxParallelLoads = 6; 13829 const parallelLoads = Math.min(queue.length, maxParallelLoads); 13830 const firstPackage = queue.splice(0, parallelLoads); 13831 firstPackage.forEach(asset => { 13832 load(asset, onLoad, doc); 13833 }); 13834 } 13835 else 13836 { 13837 callback(); 13838 } 13839 } 13840 13841 function load(asset, callback, doc) 13842 { 13843 callback = callback || BX.DoNothing; 13844 13845 if (asset.state === LOADED) 13846 { 13847 callback(); 13848 return; 13849 } 13850 13851 if (asset.state === LOADING) 13852 { 13853 if (!BX.Type.isArray(loadingAssetCallbacks[asset.name])) 13854 { 13855 loadingAssetCallbacks[asset.name] = []; 13856 } 13857 13858 loadingAssetCallbacks[asset.name].push(callback); 13859 13860 return; 13861 } 13862 13863 asset.state = LOADING; 13864 13865 loadAsset( 13866 asset, 13867 function () { 13868 asset.state = LOADED; 13869 callback(); 13870 if (BX.Type.isArrayFilled(loadingAssetCallbacks[asset.name])) 13871 { 13872 for (const cb of loadingAssetCallbacks[asset.name]) 13873 { 13874 cb(); 13875 } 13876 } 13877 13878 delete loadingAssetCallbacks[asset.name]; 13879 }, 13880 doc 13881 ); 13882 } 13883 13884 function loadAsset(asset, callback, doc) 13885 { 13886 callback = callback || BX.DoNothing; 13887 13888 function error(event) 13889 { 13890 window.clearTimeout(asset.errorTimeout); 13891 window.clearTimeout(asset.cssTimeout); 13892 ele.onload = ele.onreadystatechange = ele.onerror = null; 13893 callback(); 13894 } 13895 13896 function process(event) 13897 { 13898 event = event || window.event; 13899 if (event.type === "load" || (/loaded|complete/.test(ele.readyState) && (!doc.documentMode || doc.documentMode < 9))) 13900 { 13901 window.clearTimeout(asset.errorTimeout); 13902 window.clearTimeout(asset.cssTimeout); 13903 ele.onload = ele.onreadystatechange = ele.onerror = null; 13904 callback(); 13905 } 13906 } 13907 13908 function isCssLoaded() 13909 { 13910 if (asset.state !== LOADED && asset.cssRetries <= 20) 13911 { 13912 for (var i = 0, l = doc.styleSheets.length; i < l; i++) 13913 { 13914 if (doc.styleSheets[i].href === ele.href) 13915 { 13916 process({"type": "load"}); 13917 return; 13918 } 13919 } 13920 13921 asset.cssRetries++; 13922 asset.cssTimeout = window.setTimeout(isCssLoaded, 250); 13923 } 13924 } 13925 13926 let ele = null; 13927 const ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 13928 13929 if (ext === "css") 13930 { 13931 ele = doc.createElement("link"); 13932 ele.type = "text/" + (asset.type || "css"); 13933 ele.rel = "stylesheet"; 13934 ele.href = asset.url; 13935 13936 asset.cssRetries = 0; 13937 asset.cssTimeout = window.setTimeout(isCssLoaded, 500); 13938 } 13939 else 13940 { 13941 ele = doc.createElement("script"); 13942 ele.type = "text/" + (asset.type || "javascript"); 13943 ele.src = asset.url; 13944 } 13945 13946 ele.onload = ele.onreadystatechange = process; 13947 ele.onerror = error; 13948 13949 ele.async = false; 13950 ele.defer = false; 13951 13952 asset.errorTimeout = window.setTimeout(function () { 13953 error({type: "timeout"}); 13954 }, 7000); 13955 13956 if (ext === "css") 13957 { 13958 cssList.push(normalizeMinUrl(normalizeUrl(asset.url))); 13959 } 13960 else 13961 { 13962 jsList.push(normalizeMinUrl(normalizeUrl(asset.url))); 13963 } 13964 13965 let templateLink = null; 13966 const head = doc.head || doc.getElementsByTagName("head")[0]; 13967 if (ext === "css" && (templateLink = getTemplateLink(head)) !== null) 13968 { 13969 templateLink.parentNode.insertBefore(ele, templateLink); 13970 } 13971 else 13972 { 13973 head.insertBefore(ele, head.lastChild); 13974 } 13975 } 13976 13977 function getAsset(item) 13978 { 13979 var asset = {}; 13980 if (typeof item === "object") 13981 { 13982 asset = item; 13983 asset.name = asset.name ? asset.name : BX.util.hashCode(item.url); 13984 } 13985 else 13986 { 13987 asset = { name: BX.util.hashCode(item), url : item }; 13988 } 13989 13990 var ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 13991 if ((ext === "css" && isCssLoaded(asset.url)) || isScriptLoaded(asset.url)) 13992 { 13993 asset.state = LOADED; 13994 } 13995 13996 var existing = assets[asset.name]; 13997 if (existing && existing.url === asset.url) 13998 { 13999 return existing; 14000 } 14001 14002 assets[asset.name] = asset; 14003 14004 return asset; 14005 } 14006 14007 function normalizeUrl(url) 14008 { 14009 if (!BX.type.isNotEmptyString(url)) 14010 { 14011 return ""; 14012 } 14013 14014 url = BX.getJSPath(url); 14015 url = url.replace(/\?[0-9]*$/, ""); 14016 14017 return url; 14018 } 14019 14020 function normalizeMinUrl(url) 14021 { 14022 if (!BX.type.isNotEmptyString(url)) 14023 { 14024 return ""; 14025 } 14026 14027 var minPos = url.indexOf(".min"); 14028 return minPos >= 0 ? url.substr(0, minPos) + url.substr(minPos + 4) : url; 14029 } 14030 14031 function isCssLoaded(fileSrc) 14032 { 14033 initCssList(); 14034 14035 fileSrc = normalizeUrl(fileSrc); 14036 var fileSrcMin = normalizeMinUrl(fileSrc); 14037 14038 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, cssList)) || BX.util.in_array(fileSrc, cssList); 14039 } 14040 14041 function initCssList() 14042 { 14043 if(!cssInit) 14044 { 14045 var linksCol = document.getElementsByTagName('link'); 14046 14047 if(!!linksCol && linksCol.length > 0) 14048 { 14049 for(var i = 0; i < linksCol.length; i++) 14050 { 14051 var href = linksCol[i].getAttribute('href'); 14052 if (BX.type.isNotEmptyString(href)) 14053 { 14054 href = normalizeMinUrl(normalizeUrl(href)); 14055 cssList.push(href); 14056 } 14057 } 14058 } 14059 cssInit = true; 14060 } 14061 } 14062 14063 function getTemplateLink(head) 14064 { 14065 var findLink = function(tag) 14066 { 14067 var links = head.getElementsByTagName(tag); 14068 for (var i = 0, length = links.length; i < length; i++) 14069 { 14070 var templateStyle = links[i].getAttribute("data-template-style"); 14071 if (BX.type.isNotEmptyString(templateStyle) && templateStyle == "true") 14072 { 14073 return links[i]; 14074 } 14075 } 14076 14077 return null; 14078 }; 14079 14080 var link = findLink("link"); 14081 if (link === null) 14082 { 14083 link = findLink("style"); 14084 } 14085 14086 return link; 14087 } 14088 14089 function isScriptLoaded(fileSrc) 14090 { 14091 initJsList(); 14092 14093 fileSrc = normalizeUrl(fileSrc); 14094 var fileSrcMin = normalizeMinUrl(fileSrc); 14095 14096 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, jsList)) || BX.util.in_array(fileSrc, jsList); 14097 } 14098 14099 function initJsList() 14100 { 14101 if(!jsInit) 14102 { 14103 var scriptCol = document.getElementsByTagName('script'); 14104 14105 if(!!scriptCol && scriptCol.length > 0) 14106 { 14107 for(var i=0; i<scriptCol.length; i++) 14108 { 14109 var src = scriptCol[i].getAttribute('src'); 14110 14111 if (BX.type.isNotEmptyString(src)) 14112 { 14113 src = normalizeMinUrl(normalizeUrl(src)); 14114 jsList.push(src); 14115 } 14116 } 14117 } 14118 jsInit = true; 14119 } 14120 } 14121 14122 function reloadInternal(back_url, bAddClearCache) 14123 { 14124 if (back_url === true) 14125 { 14126 bAddClearCache = true; 14127 back_url = null; 14128 } 14129 14130 var topWindow = (function() { 14131 if (BX.PageObject && BX.PageObject.getRootWindow) 14132 { 14133 return BX.PageObject.getRootWindow(); 14134 } 14135 14136 return window.top; 14137 })(); 14138 var new_href = back_url || topWindow.location.href; 14139 14140 var hashpos = new_href.indexOf('#'), hash = ''; 14141 14142 if (hashpos != -1) 14143 { 14144 hash = new_href.substr(hashpos); 14145 new_href = new_href.substr(0, hashpos); 14146 } 14147 14148 if (bAddClearCache && new_href.indexOf('clear_cache=Y') < 0) 14149 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + 'clear_cache=Y'; 14150 14151 if (hash) 14152 { 14153 // hack for clearing cache in ajax mode components with history emulation 14154 if (bAddClearCache && (hash.substr(0, 5) == 'view/' || hash.substr(0, 6) == '#view/') && hash.indexOf('clear_cache%3DY') < 0) 14155 hash += (hash.indexOf('%3F') == -1 ? '%3F' : '%26') + 'clear_cache%3DY'; 14156 14157 new_href = new_href.replace(/(\?|\&)_r=[\d]*/, ''); 14158 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + '_r='+Math.round(Math.random()*10000) + hash; 14159 } 14160 14161 topWindow.location.href = new_href; 14162 } 14163 14164 BX.reload = function(back_url, bAddClearCache) 14165 { 14166 if (window !== window.top) 14167 { 14168 BX.Runtime 14169 .loadExtension('main.pageobject') 14170 .then(function() { 14171 reloadInternal(back_url, bAddClearCache); 14172 }); 14173 } 14174 else 14175 { 14176 reloadInternal(back_url, bAddClearCache); 14177 } 14178 }; 14179 14180 BX.clearCache = function() 14181 { 14182 BX.showWait(); 14183 BX.reload(true); 14184 }; 14185 14186 BX.template = function(tpl, callback, bKillTpl) 14187 { 14188 BX.ready(function() { 14189 _processTpl(BX(tpl), callback, bKillTpl); 14190 }); 14191 }; 14192 14193 BX.isAmPmMode = function(returnConst) 14194 { 14195 if (returnConst === true) 14196 { 14197 return BX.message.AMPM_MODE; 14198 } 14199 return BX.message.AMPM_MODE !== false; 14200 }; 14201 14202 BX.formatDate = function(date, format) 14203 { 14204 date = date || new Date(); 14205 14206 var bTime = date.getHours() || date.getMinutes() || date.getSeconds(), 14207 str = !!format 14208 ? format : 14209 (bTime ? BX.message('FORMAT_DATETIME') : BX.message('FORMAT_DATE') 14210 ); 14211 14212 return str.replace(/YYYY/ig, date.getFullYear()) 14213 .replace(/MMMM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14214 .replace(/MM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14215 .replace(/DD/ig, BX.util.str_pad_left(date.getDate().toString(), 2, '0')) 14216 .replace(/HH/ig, BX.util.str_pad_left(date.getHours().toString(), 2, '0')) 14217 .replace(/MI/ig, BX.util.str_pad_left(date.getMinutes().toString(), 2, '0')) 14218 .replace(/SS/ig, BX.util.str_pad_left(date.getSeconds().toString(), 2, '0')); 14219 }; 14220 BX.formatName = function(user, template, login) 14221 { 14222 user = user || {}; 14223 template = (template || ''); 14224 var replacement = { 14225 TITLE : (user["TITLE"] || ''), 14226 NAME : (user["NAME"] || ''),
14227 LAST_NAME : (user["LAST_NAME"] || ''), 14228 SECOND_NAME : (user["SECOND_NAME"] || ''), 14229 LOGIN : (user["LOGIN"] || ''), 14230 NAME_SHORT : user["NAME"] ? user["NAME"].substr(0, 1) + '.' : '', 14231 LAST_NAME_SHORT : user["LAST_NAME"] ? user["LAST_NAME"].substr(0, 1) + '.' : '', 14232 SECOND_NAME_SHORT : user["SECOND_NAME"] ? user["SECOND_NAME"].substr(0, 1) + '.' : '', 14233 EMAIL : (user["EMAIL"] || ''), 14234 ID : (user["ID"] || ''), 14235 NOBR : "", 14236 '/NOBR' : "" 14237 }, result = template; 14238 for (var ii in replacement) 14239 { 14240 if (replacement.hasOwnProperty(ii)) 14241 { 14242 result = result.replace("#" + ii+ "#", replacement[ii]) 14243 } 14244 } 14245 result = result.replace(/([\s]+)/gi, " ").trim(); 14246 if (result == "") 14247 { 14248 result = (login == "Y" ? replacement["LOGIN"] : ""); 14249 result = (result == "" ? "Noname" : result); 14250 } 14251 return result; 14252 }; 14253 14254 BX.getNumMonth = function(month) 14255 { 14256 var wordMonthCut = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; 14257 var wordMonth = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']; 14258 14259 var q = month.toUpperCase(); 14260 for (i = 1; i <= 12; i++) 14261 { 14262 if (q == BX.message('MON_'+i).toUpperCase() || q == BX.message('MONTH_'+i).toUpperCase() || q == wordMonthCut[i-1].toUpperCase() || q == wordMonth[i-1].toUpperCase()) 14263 { 14264 return i; 14265 } 14266 } 14267 return month; 14268 }; 14269 14270 BX.parseDate = function(str, bUTC, formatDate, formatDatetime) 14271 { 14272 if (BX.type.isNotEmptyString(str)) 14273 { 14274 if (!formatDate) 14275 formatDate = BX.message('FORMAT_DATE'); 14276 if (!formatDatetime) 14277 formatDatetime = BX.message('FORMAT_DATETIME'); 14278 14279 var regMonths = ''; 14280 for (i = 1; i <= 12; i++) 14281 { 14282 regMonths = regMonths + '|' + BX.message('MON_'+i); 14283 } 14284
14285 var expr = new RegExp('([0-9]+|[a-z]+' + regMonths + ')', 'ig'); 14286 var aDate = str.match(expr), 14287 aFormat = formatDate.match(/(DD|MI|MMMM|MM|M|YYYY)/ig), 14288 i, cnt, 14289 aDateArgs=[], aFormatArgs=[], 14290 aResult={}; 14291 14292 if (!aDate) 14293 return null; 14294 14295 if(aDate.length > aFormat.length) 14296 { 14297 aFormat = formatDatetime.match(/(DD|MI|MMMM|MM|M|YYYY|HH|H|SS|TT|T|GG|G)/ig); 14298 } 14299 14300 for(i = 0, cnt = aDate.length; i < cnt; i++) 14301 { 14302 if(BX.util.trim(aDate[i]) != '') 14303 { 14304 aDateArgs[aDateArgs.length] = aDate[i]; 14305 } 14306 } 14307 14308 for(i = 0, cnt = aFormat.length; i < cnt; i++) 14309 { 14310 if(BX.util.trim(aFormat[i]) != '') 14311 { 14312 aFormatArgs[aFormatArgs.length] = aFormat[i]; 14313 } 14314 } 14315 14316 14317 var m = BX.util.array_search('MMMM', aFormatArgs); 14318 if (m > 0) 14319 { 14320 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 14321 aFormatArgs[m] = "MM"; 14322 } 14323 else 14324 { 14325 m = BX.util.array_search('M', aFormatArgs); 14326 if (m > 0) 14327 { 14328 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 14329 aFormatArgs[m] = "MM"; 14330 } 14331 } 14332 14333 for(i = 0, cnt = aFormatArgs.length; i < cnt; i++) 14334 { 14335 var k = aFormatArgs[i].toUpperCase(); 14336 aResult[k] = k == 'T' || k == 'TT' ? aDateArgs[i] : parseInt(aDateArgs[i], 10); 14337 } 14338 14339 if(aResult['DD'] > 0 && aResult['MM'] > 0 && aResult['YYYY'] > 0) 14340 { 14341 var d = new Date(); 14342 14343 if(bUTC) 14344 { 14345 d.setUTCDate(1); 14346 d.setUTCFullYear(aResult['YYYY']); 14347 d.setUTCMonth(aResult['MM'] - 1); 14348 d.setUTCDate(aResult['DD']); 14349 d.setUTCHours(0, 0, 0, 0); 14350 } 14351 else 14352 { 14353 d.setDate(1); 14354 d.setFullYear(aResult['YYYY']); 14355 d.setMonth(aResult['MM'] - 1); 14356 d.setDate(aResult['DD']); 14357 d.setHours(0, 0, 0, 0); 14358 } 14359 14360 if( 14361 (!isNaN(aResult['HH']) || !isNaN(aResult['GG']) || !isNaN(aResult['H']) || !isNaN(aResult['G'])) 14362 && !isNaN(aResult['MI']) 14363 ) 14364 { 14365 if (!isNaN(aResult['H']) || !isNaN(aResult['G'])) 14366 { 14367 var bPM = (aResult['T']||aResult['TT']||'am').toUpperCase()=='PM'; 14368 var h = parseInt(aResult['H']||aResult['G']||0, 10); 14369 if(bPM) 14370 { 14371 aResult['HH'] = h + (h == 12 ? 0 : 12); 14372 } 14373 else 14374 { 14375 aResult['HH'] = h < 12 ? h : 0; 14376 } 14377 } 14378 else 14379 { 14380 aResult['HH'] = parseInt(aResult['HH']||aResult['GG']||0, 10); 14381 } 14382 14383 if (isNaN(aResult['SS'])) 14384 aResult['SS'] = 0; 14385 14386 if(bUTC) 14387 { 14388 d.setUTCHours(aResult['HH'], aResult['MI'], aResult['SS']); 14389 } 14390 else 14391 { 14392 d.setHours(aResult['HH'], aResult['MI'], aResult['SS']); 14393 } 14394 } 14395 14396 return d; 14397 } 14398 } 14399 14400 return null; 14401 }; 14402 14403 BX.selectUtils = 14404 { 14405 addNewOption: function(oSelect, opt_value, opt_name, do_sort, check_unique) 14406 { 14407 oSelect = BX(oSelect); 14408 if(oSelect) 14409 { 14410 var n = oSelect.length; 14411 if(check_unique !== false) 14412 { 14413 for(var i=0;i<n;i++) 14414 { 14415 if(oSelect[i].value==opt_value) 14416 { 14417 return; 14418 } 14419 } 14420 } 14421 14422 oSelect.options[n] = new Option(opt_name, opt_value, false, false); 14423 } 14424 14425 if(do_sort === true) 14426 { 14427 this.sortSelect(oSelect); 14428 } 14429 }, 14430 14431 deleteOption: function(oSelect, opt_value) 14432 { 14433 oSelect = BX(oSelect); 14434 if(oSelect) 14435 { 14436 for(var i=0;i<oSelect.length;i++) 14437 { 14438 if(oSelect[i].value==opt_value) 14439 { 14440 oSelect.remove(i); 14441 break; 14442 } 14443 } 14444 } 14445 }, 14446 14447 deleteSelectedOptions: function(oSelect) 14448 { 14449 oSelect = BX(oSelect); 14450 if(oSelect) 14451 { 14452 var i=0; 14453 while(i<oSelect.length) 14454 { 14455 if(oSelect[i].selected) 14456 { 14457 oSelect[i].selected=false; 14458 oSelect.remove(i); 14459 } 14460 else 14461 { 14462 i++; 14463 } 14464 } 14465 } 14466 }, 14467 14468 deleteAllOptions: function(oSelect) 14469 { 14470 oSelect = BX(oSelect); 14471 if(oSelect) 14472 { 14473 for(var i=oSelect.length-1; i>=0; i--) 14474 { 14475 oSelect.remove(i); 14476 } 14477 } 14478 }, 14479 14480 optionCompare: function(record1, record2) 14481 { 14482 var value1 = record1.optText.toLowerCase(); 14483 var value2 = record2.optText.toLowerCase(); 14484 if (value1 > value2) return(1); 14485 if (value1 < value2) return(-1); 14486 return(0); 14487 }, 14488 14489 sortSelect: function(oSelect) 14490 { 14491 oSelect = BX(oSelect); 14492 if(oSelect) 14493 { 14494 var myOptions = []; 14495 var n = oSelect.options.length; 14496 var i; 14497 for (i=0;i<n;i++) 14498 { 14499 myOptions[i] = { 14500 optText:oSelect[i].text, 14501 optValue:oSelect[i].value 14502 }; 14503 } 14504 myOptions.sort(this.optionCompare); 14505 oSelect.length=0; 14506 n = myOptions.length; 14507 for(i=0;i<n;i++) 14508 { 14509 oSelect[i] = new Option(myOptions[i].optText, myOptions[i].optValue, false, false); 14510 } 14511 } 14512 }, 14513 14514 selectAllOptions: function(oSelect) 14515 { 14516 oSelect = BX(oSelect); 14517 if(oSelect) 14518 { 14519 var n = oSelect.length; 14520 for(var i=0;i<n;i++) 14521 { 14522 oSelect[i].selected=true; 14523 } 14524 } 14525 }, 14526 14527 selectOption: function(oSelect, opt_value) 14528 { 14529 oSelect = BX(oSelect); 14530 if(oSelect) 14531 { 14532 var n = oSelect.length; 14533 for(var i=0;i<n;i++) 14534 { 14535 oSelect[i].selected = (oSelect[i].value == opt_value); 14536 } 14537 } 14538 }, 14539 14540 addSelectedOptions: function(oSelect, to_select_id, check_unique, do_sort) 14541 { 14542 oSelect = BX(oSelect); 14543 if(!oSelect) 14544 return; 14545 var n = oSelect.length; 14546 for(var i=0; i<n; i++) 14547 if(oSelect[i].selected) 14548 this.addNewOption(to_select_id, oSelect[i].value, oSelect[i].text, do_sort, check_unique); 14549 }, 14550 14551 moveOptionsUp: function(oSelect) 14552 { 14553 oSelect = BX(oSelect); 14554 if(!oSelect) 14555 return; 14556 var n = oSelect.length; 14557 for(var i=0; i<n; i++) 14558 { 14559 if(oSelect[i].selected && i>0 && oSelect[i-1].selected == false) 14560 { 14561 var option = new Option(oSelect[i].text, oSelect[i].value); 14562 oSelect[i] = new Option(oSelect[i-1].text, oSelect[i-1].value); 14563 oSelect[i].selected = false;
14564 oSelect[i-1] = option; 14565 oSelect[i-1].selected = true; 14566 } 14567 } 14568 }, 14569 14570 moveOptionsDown: function(oSelect) 14571 { 14572 oSelect = BX(oSelect); 14573 if(!oSelect) 14574 return; 14575 var n = oSelect.length; 14576 for(var i=n-1; i>=0; i--) 14577 { 14578 if(oSelect[i].selected && i<n-1 && oSelect[i+1].selected == false) 14579 { 14580 var option = new Option(oSelect[i].text, oSelect[i].value); 14581 oSelect[i] = new Option(oSelect[i+1].text, oSelect[i+1].value); 14582 oSelect[i].selected = false; 14583 oSelect[i+1] = option; 14584 oSelect[i+1].selected = true; 14585 } 14586 } 14587 } 14588 }; 14589 14590 BX.getEventTarget = function(e) 14591 { 14592 if(e.target) 14593 { 14594 return e.target; 14595 } 14596 else if(e.srcElement) 14597 { 14598 return e.srcElement; 14599 } 14600 return null; 14601 }; 14602 14603 BX.convert = { 14604 toNumber: function(value) 14605 { 14606 if(BX.type.isNumber(value)) 14607 { 14608 return value; 14609 } 14610 14611 value = Number(value); 14612 return !isNaN(value) ? value : 0; 14613 }, 14614 nodeListToArray: function(nodes) 14615 { 14616 try 14617 { 14618 return (Array.prototype.slice.call(nodes, 0)); 14619 } 14620 catch (ex) 14621 { 14622 var ary = []; 14623 for(var i = 0, l = nodes.length; i < l; i++) 14624 { 14625 ary.push(nodes[i]); 14626 } 14627 return ary; 14628 } 14629 } 14630 }; 14631 14632 /******* HINT ***************/ 14633// if function has 2 params - the 2nd one is hint html. otherwise hint_html is third and hint_title - 2nd; 14634// '<div onmouseover="BX.hint(this, 'This is <b>Hint</b>')"'>; 14635// BX.hint(el, 'This is <b>Hint</b>') - this won't work, use constructor 14636 BX.hint = function(el, hint_title, hint_html, hint_id) 14637 { 14638 if (null == hint_html) 14639 { 14640 hint_html = hint_title; 14641 hint_title = ''; 14642 } 14643 14644 if (null == el.BXHINT) 14645 { 14646 el.BXHINT = new BX.CHint({ 14647 parent: el, hint: hint_html, title: hint_title, id: hint_id 14648 }); 14649 el.BXHINT.Show(); 14650 } 14651 }; 14652 14653 BX.hint_replace = function(el, hint_title, hint_html) 14654 { 14655 if (null == hint_html) 14656 { 14657 hint_html = hint_title; 14658 hint_title = ''; 14659 } 14660 14661 if (!el || !el.parentNode || !hint_html) 14662 return null; 14663 14664 var obHint = new BX.CHint({ 14665 hint: hint_html, 14666 title: hint_title 14667 }); 14668 14669 obHint.CreateParent(); 14670 14671 el.parentNode.insertBefore(obHint.PARENT, el); 14672 el.parentNode.removeChild(el); 14673 14674 obHint.PARENT.style.marginLeft = '5px'; 14675 14676 return el; 14677 }; 14678 14679 BX.CHint = function(params) 14680 { 14681 if (BX.CHint.cssLoaded === false) 14682 { 14683 BX.load(['/bitrix/js/main/core/css/core_hint.css']); 14684 BX.CHint.cssLoaded = true; 14685 } 14686 14687 this.PARENT = BX(params.parent); 14688 14689 this.HINT = params.hint; 14690 this.HINT_TITLE = params.title; 14691 14692 this.PARAMS = {}; 14693 for (var i in this.defaultSettings) 14694 { 14695 if (null == params[i]) 14696 this.PARAMS[i] = this.defaultSettings[i]; 14697 else 14698 this.PARAMS[i] = params[i]; 14699 } 14700 14701 if (null != params.id) 14702 this.ID = params.id; 14703 14704 this.timer = null; 14705 this.bInited = false; 14706 this.msover = true; 14707 14708 if (this.PARAMS.showOnce) 14709 { 14710 this.__show(); 14711 this.msover = false; 14712 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14713 } 14714 else if (this.PARENT) 14715 { 14716 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14717 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14718 } 14719 }; 14720 14721 BX.CHint.cssLoaded = false; 14722 14723 BX.CHint.openHints = new Set(); 14724 14725 BX.CHint.globalDisabled = false; 14726 14727 BX.CHint.handleMenuOpen = function() { 14728 BX.CHint.globalDisabled = true; 14729 14730 BX.CHint.openHints.forEach(function(hint) { 14731 hint.__hide_immediately(); 14732 }); 14733 }; 14734 14735 BX.CHint.handleMenuClose = function() { 14736 BX.CHint.globalDisabled = false; 14737 }; 14738 14739 BX.addCustomEvent('onMenuOpen', BX.CHint.handleMenuOpen); 14740 BX.addCustomEvent('onMenuClose', BX.CHint.handleMenuClose); 14741 14742 BX.CHint.prototype.defaultSettings = { 14743 show_timeout: 1000, 14744 hide_timeout: 500, 14745 dx: 2, 14746 showOnce: false, 14747 preventHide: true, 14748 min_width: 250 14749 }; 14750 14751 BX.CHint.prototype.CreateParent = function(element, params) 14752 { 14753 if (this.PARENT) 14754 { 14755 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14756 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14757 } 14758 14759 if (!params) params = {}; 14760 var type = 'icon'; 14761 14762 if (params.type && (params.type == "link" || params.type == "icon")) 14763 type = params.type; 14764 14765 if (element) 14766 type = "element";
14767 14768 if (type == "icon") 14769 { 14770 element = BX.create('IMG', { 14771 props: { 14772 src: params.iconSrc 14773 ? params.iconSrc 14774 : "/bitrix/js/main/core/images/hint.gif" 14775 } 14776 }); 14777 } 14778 else if (type == "link") 14779 { 14780 element = BX.create("A", { 14781 props: {href: 'javascript:void(0)'}, 14782 html: '[?]' 14783 }); 14784 } 14785 14786 this.PARENT = element; 14787 14788 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14789 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14790 14791 return this.PARENT; 14792 }; 14793 14794 BX.CHint.prototype.Show = function() 14795 { 14796 this.msover = true; 14797 14798 if (null != this.timer) 14799 clearTimeout(this.timer); 14800 14801 this.timer = setTimeout(BX.proxy(this.__show, this), this.PARAMS.show_timeout); 14802 }; 14803 14804 BX.CHint.prototype.Hide = function() 14805 { 14806 this.msover = false; 14807 14808 if (null != this.timer) 14809 clearTimeout(this.timer); 14810 14811 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14812 }; 14813 14814 BX.CHint.prototype.__show = function() 14815 { 14816 if (!this.msover || this.disabled || BX.CHint.globalDisabled) return; 14817 if (!this.bInited) this.Init(); 14818 14819 if (this.prepareAdjustPos()) 14820 { 14821 this.DIV.style.display = 'block'; 14822 BX.ZIndexManager.bringToFront(this.DIV); 14823 14824 this.adjustPos(); 14825 14826 BX.CHint.openHints.add(this); 14827 14828 BX.bind(window, 'scroll', BX.proxy(this.__onscroll, this)); 14829 14830 if (this.PARAMS.showOnce) 14831 { 14832 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14833 } 14834 } 14835 }; 14836 14837 BX.CHint.prototype.__onscroll = function() 14838 { 14839 if (!BX.admin || !BX.admin.panel || !BX.admin.panel.isFixed()) return; 14840 14841 if (this.scrollTimer) clearTimeout(this.scrollTimer); 14842 14843 this.DIV.style.display = 'none'; 14844 this.scrollTimer = setTimeout(BX.proxy(this.Reopen, this), this.PARAMS.show_timeout); 14845 }; 14846 14847 BX.CHint.prototype.Reopen = function() 14848 { 14849 if (null != this.timer) clearTimeout(this.timer); 14850 this.timer = setTimeout(BX.proxy(this.__show, this), 50); 14851 }; 14852 14853 BX.CHint.prototype.__hide = function() 14854 { 14855 if (this.msover) return; 14856 if (!this.bInited) return; 14857 14858 BX.unbind(window, 'scroll', BX.proxy(this.Reopen, this)); 14859 14860 BX.CHint.openHints.delete(this); 14861 14862 if (this.PARAMS.showOnce) 14863 { 14864 this.Destroy(); 14865 } 14866 else 14867 { 14868 this.DIV.style.display = 'none'; 14869 } 14870 }; 14871 14872 BX.CHint.prototype.__hide_immediately = function() 14873 { 14874 this.msover = false; 14875 this.__hide(); 14876 }; 14877 14878 BX.CHint.prototype.Init = function() 14879 { 14880 this.DIV = document.body.appendChild(BX.create('DIV', { 14881 props: {className: 'bx-panel-tooltip'}, 14882 style: { 14883 display: 'none', 14884 position: 'absolute', 14885 visibility: 'hidden' 14886 }, 14887 children: [ 14888 (this.CONTENT = BX.create('DIV', { 14889 props: {className: 'bx-panel-tooltip-content'}, 14890 children: [ 14891 BX.create('DIV', { 14892 props: {className: 'bx-panel-tooltip-underlay'}, 14893 children: [ 14894 BX.create('DIV', {props: {className: 'bx-panel-tooltip-underlay-bg'}}) 14895 ] 14896 }) 14897 ] 14898 })) 14899 ] 14900 })); 14901 14902 BX.ZIndexManager.register(this.DIV); 14903 14904 if (this.ID) 14905 { 14906 this.CONTENT.insertBefore(BX.create('A', { 14907 attrs: {href: 'javascript:void(0)'}, 14908 props: {className: 'bx-panel-tooltip-close'}, 14909 events: {click: BX.delegate(this.Close, this)} 14910 }), this.CONTENT.firstChild); 14911 } 14912 14913 if (this.HINT_TITLE) 14914 { 14915 this.CONTENT.appendChild( 14916 BX.create('DIV', { 14917 props: {className: 'bx-panel-tooltip-title'}, 14918 text: this.HINT_TITLE 14919 }) 14920 ); 14921 } 14922 14923 if (this.HINT) 14924 { 14925 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 14926 } 14927 14928 if (this.PARAMS.preventHide) 14929 { 14930 BX.bind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 14931 BX.bind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 14932 } 14933 14934 this.bInited = true; 14935 }; 14936 14937 BX.CHint.prototype.setContent = function(content) 14938 { 14939 this.HINT = content; 14940 14941 if (this.CONTENT_TEXT) 14942 this.CONTENT_TEXT.innerHTML = this.HINT; 14943 else 14944 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 14945 }; 14946 14947 BX.CHint.prototype.prepareAdjustPos = function() 14948 { 14949 this._wnd = {scrollPos: BX.GetWindowScrollPos(),scrollSize:BX.GetWindowScrollSize()}; 14950 return BX.style(this.PARENT, 'display') != 'none'; 14951 }; 14952 14953 BX.CHint.prototype.getAdjustPos = function() 14954 { 14955 var res = {}, pos = BX.pos(this.PARENT), min_top = 0; 14956 14957 res.top = pos.bottom + this.PARAMS.dx; 14958 14959 if (BX.admin && BX.admin.panel.DIV) 14960 { 14961 min_top = BX.admin.panel.DIV.offsetHeight + this.PARAMS.dx; 14962 14963 if (BX.admin.panel.isFixed()) 14964 { 14965 min_top += this._wnd.scrollPos.scrollTop; 14966 } 14967 } 14968 14969 if (res.top < min_top) 14970 res.top = min_top; 14971 else 14972 { 14973 if (res.top + this.DIV.offsetHeight > this._wnd.scrollSize.scrollHeight) 14974 res.top = pos.top - this.PARAMS.dx - this.DIV.offsetHeight; 14975 } 14976 14977 res.left = pos.left; 14978 if (pos.left < this.PARAMS.dx) 14979 pos.left = this.PARAMS.dx; 14980 else 14981 { 14982 var floatWidth = this.DIV.offsetWidth; 14983 14984 var max_left = this._wnd.scrollSize.scrollWidth - floatWidth - this.PARAMS.dx; 14985 14986 if (res.left > max_left) 14987 res.left = max_left; 14988 } 14989 14990 return res; 14991 }; 14992 14993 BX.CHint.prototype.adjustWidth = function() 14994 { 14995 if (this.bWidthAdjusted) return; 14996 14997 var w = this.DIV.offsetWidth, h = this.DIV.offsetHeight; 14998 14999 if (w > this.PARAMS.min_width) 15000 w = Math.round(Math.sqrt(1.618*w*h)); 15001 15002 if (w < this.PARAMS.min_width) 15003 w = this.PARAMS.min_width; 15004 15005 this.DIV.style.width = w + "px"; 15006 15007 if (this._adjustWidthInt) 15008 clearInterval(this._adjustWidthInt); 15009 this._adjustWidthInt = setInterval(BX.delegate(this._adjustWidthInterval, this), 5); 15010 15011 this.bWidthAdjusted = true; 15012 }; 15013 15014 BX.CHint.prototype._adjustWidthInterval = function() 15015 { 15016 if (!this.DIV || this.DIV.style.display == 'none') 15017 clearInterval(this._adjustWidthInt); 15018 15019 var
15020 dW = 20, 15021 maxWidth = 1500, 15022 w = this.DIV.offsetWidth, 15023 w1 = this.CONTENT_TEXT.offsetWidth; 15024 15025 if (w > 0 && w1 > 0 && w - w1 < dW && w < maxWidth) 15026 { 15027 this.DIV.style.width = (w + dW) + "px"; 15028 return; 15029 } 15030 15031 clearInterval(this._adjustWidthInt); 15032 }; 15033 15034 BX.CHint.prototype.adjustPos = function() 15035 { 15036 this.adjustWidth(); 15037 15038 var pos = this.getAdjustPos(); 15039 15040 this.DIV.style.top = pos.top + 'px'; 15041 this.DIV.style.left = pos.left + 'px'; 15042 }; 15043 15044 BX.CHint.prototype.Close = function() 15045 { 15046 if (this.ID && BX.WindowManager) 15047 BX.WindowManager.saveWindowOptions(this.ID, {display: 'off'}); 15048 this.__hide_immediately(); 15049 this.Destroy(); 15050 }; 15051 15052 BX.CHint.prototype.Destroy = function() 15053 { 15054 if (this.PARENT) 15055 { 15056 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 15057 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 15058 } 15059 15060 if (this.DIV) 15061 { 15062 BX.unbind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 15063 BX.unbind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 15064 15065 BX.ZIndexManager.unregister(this.DIV); 15066 15067 BX.cleanNode(this.DIV, true); 15068 } 15069 }; 15070 15071 BX.CHint.prototype.enable = function(){this.disabled = false;}; 15072 BX.CHint.prototype.disable = function(){this.__hide_immediately(); this.disabled = true;}; 15073 15074 15075 function _adjustWait() 15076 { 15077 if (!this.bxmsg) return; 15078 15079 var arContainerPos = BX.pos(this), 15080 div_top = arContainerPos.top; 15081 15082 if (div_top < BX.GetDocElement().scrollTop) 15083 div_top = BX.GetDocElement().scrollTop + 5; 15084 15085 this.bxmsg.style.top = (div_top + 5) + 'px'; 15086 15087 if (this == BX.GetDocElement()) 15088 { 15089 this.bxmsg.style.right = '5px'; 15090 } 15091 else 15092 { 15093 this.bxmsg.style.left = (arContainerPos.right - this.bxmsg.offsetWidth - 5) + 'px'; 15094 } 15095 } 15096 15097 function _processTpl(tplNode, cb, bKillTpl) 15098 { 15099 if (tplNode) 15100 { 15101 if (bKillTpl) 15102 tplNode.parentNode.removeChild(tplNode); 15103 15104 var res = {}, nodes = BX.findChildren(tplNode, {attribute: 'data-role'}, true); 15105 15106 for (var i = 0, l = nodes.length; i < l; i++) 15107 { 15108 res[nodes[i].getAttribute('data-role')] = nodes[i]; 15109 } 15110 15111 cb.apply(tplNode, [res]); 15112 } 15113 } 15114 15115 function _checkNode(obj, params) 15116 { 15117 params = params || {}; 15118 15119 if (BX.type.isFunction(params)) 15120 return params.call(window, obj); 15121 15122 if (!params.allowTextNodes && !BX.type.isElementNode(obj)) 15123 return false; 15124 var i,j,len; 15125 for (i in params) 15126 { 15127 if(params.hasOwnProperty(i)) 15128 { 15129 switch(i) 15130 { 15131 case 'tag': 15132 case 'tagName': 15133 if (BX.type.isString(params[i])) 15134 { 15135 if (obj.tagName.toUpperCase() != params[i].toUpperCase()) 15136 return false; 15137 } 15138 else if (params[i] instanceof RegExp) 15139 { 15140 if (!params[i].test(obj.tagName)) 15141 return false; 15142 } 15143 break; 15144 15145 case 'class': 15146 case 'className': 15147 if (BX.type.isString(params[i])) 15148 { 15149 if (!BX.hasClass(obj, params[i])) 15150 return false; 15151 } 15152 else if (params[i] instanceof RegExp) 15153 { 15154 if (!BX.type.isString(obj.className) || !params[i].test(obj.className)) 15155 return false; 15156 } 15157 break; 15158 15159 case 'attr': 15160 case 'attrs': 15161 case 'attribute': 15162 if (BX.type.isString(params[i])) 15163 { 15164 if (!obj.getAttribute(params[i])) 15165 return false; 15166 } 15167 else if (BX.type.isArray(params[i])) 15168 { 15169 for (j = 0, len = params[i].length; j < len; j++) 15170 { 15171 if (params[i] && !obj.getAttribute(params[i])) 15172 return false; 15173 } 15174 } 15175 else 15176 { 15177 for (j in params[i]) 15178 { 15179 if(params[i].hasOwnProperty(j)) 15180 { 15181 var q = obj.getAttribute(j); 15182 if (params[i][j] instanceof RegExp) 15183 { 15184 if (!BX.type.isString(q) || !params[i][j].test(q)) 15185 { 15186 return false; 15187 } 15188 } 15189 else 15190 { 15191 if (q != '' + params[i][j]) 15192 { 15193 return false; 15194 } 15195 } 15196 } 15197 } 15198 } 15199 break; 15200 15201 case 'property': 15202 case 'props': 15203 if (BX.type.isString(params[i])) 15204 { 15205 if (!obj[params[i]]) 15206 return false; 15207 } 15208 else if (BX.type.isArray(params[i])) 15209 { 15210 for (j = 0, len = params[i].length; j < len; j++) 15211 { 15212 if (params[i] && !obj[params[i]]) 15213 return false;
15214 } 15215 } 15216 else 15217 { 15218 for (j in params[i]) 15219 { 15220 if (BX.type.isString(params[i][j])) 15221 { 15222 if (obj[j] != params[i][j]) 15223 return false; 15224 } 15225 else if (params[i][j] instanceof RegExp) 15226 { 15227 if (!BX.type.isString(obj[j]) || !params[i][j].test(obj[j])) 15228 return false; 15229 } 15230 } 15231 } 15232 break; 15233 15234 case 'callback': 15235 return params[i](obj); 15236 } 15237 } 15238 } 15239 15240 return true; 15241 } 15242 15243 /* garbage collector */ 15244 function Trash() 15245 { 15246 var i,len; 15247 15248 for (i = 0, len = garbageCollectors.length; i<len; i++) 15249 { 15250 try { 15251 garbageCollectors[i].callback.apply(garbageCollectors[i].context || window); 15252 delete garbageCollectors[i]; 15253 garbageCollectors[i] = null; 15254 } catch (e) {} 15255 } 15256 } 15257 15258 if(window.attachEvent) // IE 15259 window.attachEvent("onunload", Trash); 15260 else if(window.addEventListener) // Gecko / W3C 15261 window.addEventListener('unload', Trash, false); 15262 else 15263 window.onunload = Trash; 15264 /* \garbage collector */ 15265 15266// set empty ready handler 15267 BX(BX.DoNothing); 15268 window.BX = BX; 15269 15270 BX.browser.addGlobalClass(); 15271 15272 /* data storage */ 15273 BX.data = function(node, key, value) 15274 { 15275 if(typeof node == 'undefined') 15276 return undefined; 15277 15278 if(typeof key == 'undefined') 15279 return undefined; 15280 15281 if(typeof value != 'undefined') 15282 { 15283 // write to manager 15284 dataStorage.set(node, key, value); 15285 } 15286 else 15287 { 15288 var data; 15289 15290 // from manager 15291 if((data = dataStorage.get(node, key)) != undefined) 15292 { 15293 return data; 15294 } 15295 else 15296 { 15297 // from attribute data-* 15298 if('getAttribute' in node) 15299 { 15300 data = node.getAttribute('data-'+key.toString()); 15301 if(data === null) 15302 { 15303 return undefined; 15304 } 15305 return data; 15306 } 15307 } 15308 15309 return undefined; 15310 } 15311 }; 15312 15313 BX.DataStorage = function() 15314 { 15315 15316 this.keyOffset = 1; 15317 this.data = {}; 15318 this.uniqueTag = 'BX-'+Math.random(); 15319 15320 this.resolve = function(owner, create){ 15321 if(typeof owner[this.uniqueTag] == 'undefined') 15322 if(create) 15323 { 15324 try 15325 { 15326 Object.defineProperty(owner, this.uniqueTag, { 15327 value: this.keyOffset++ 15328 }); 15329 } 15330 catch(e) 15331 { 15332 owner[this.uniqueTag] = this.keyOffset++; 15333 } 15334 } 15335 else 15336 return undefined; 15337 15338 return owner[this.uniqueTag]; 15339 }; 15340 this.get = function(owner, key){ 15341 if((owner != document && !BX.type.isElementNode(owner)) || typeof key == 'undefined') 15342 return undefined; 15343 15344 owner = this.resolve(owner, false); 15345 15346 if(typeof owner == 'undefined' || typeof this.data[owner] == 'undefined') 15347 return undefined; 15348 15349 return this.data[owner][key]; 15350 }; 15351 this.set = function(owner, key, value){ 15352 15353 if((owner != document && !BX.type.isElementNode(owner)) || typeof value == 'undefined') 15354 return; 15355 15356 var o = this.resolve(owner, true); 15357 15358 if(typeof this.data[o] == 'undefined') 15359 this.data[o] = {}; 15360 15361 this.data[o][key] = value; 15362 }; 15363 }; 15364 15365// some internal variables for new logic 15366 var dataStorage = new BX.DataStorage(); // manager which BX.data() uses to keep data 15367})(window.BX); 15368 15369 15370;(function(window) 15371{ 15372 /****************** ATTENTION ******************************* 15373 * Please do not use Bitrix CoreJS in this class. 15374 * This class can be called on page without Bitrix Framework 15375 *************************************************************/ 15376 15377 if (!window.BX) 15378 { 15379 window.BX = {}; 15380 } 15381 15382 var BX = window.BX; 15383 15384 BX.Promise = function(fn, ctx) // fn is future-reserved 15385 { 15386 this.state = null; 15387 this.value = null; 15388 this.reason = null; 15389 this.next = null; 15390 this.ctx = ctx || this; 15391 15392 this.onFulfilled = []; 15393 this.onRejected = []; 15394 }; 15395 BX.Promise.prototype.fulfill = function(value) 15396 { 15397 this.checkState(); 15398 15399 this.value = value; 15400 this.state = true; 15401 this.execute(); 15402 }; 15403 BX.Promise.prototype.reject = function(reason) 15404 { 15405 this.checkState(); 15406 15407 this.reason = reason; 15408 this.state = false; 15409 this.execute(); 15410 }; 15411 BX.Promise.prototype.then = function(onFulfilled, onRejected) 15412 { 15413 if(typeof (onFulfilled) == "function" || onFulfilled instanceof Function) 15414 { 15415 this.onFulfilled.push(onFulfilled); 15416 } 15417 if(typeof (onRejected) == "function" || onRejected instanceof Function) 15418 { 15419 this.onRejected.push(onRejected); 15420 } 15421 15422 if(this.next === null) 15423 { 15424 this.next = new BX.Promise(null, this.ctx); 15425 } 15426 15427 if(this.state !== null) // if promise was already resolved, execute immediately 15428 { 15429 this.execute(); 15430 } 15431 15432 return this.next; 15433 }; 15434 15435 BX.Promise.prototype.catch = function(onRejected) 15436 { 15437 if(typeof (onRejected) == "function" || onRejected instanceof Function) 15438 { 15439 this.onRejected.push(onRejected); 15440 } 15441 15442 if(this.next === null) 15443 { 15444 this.next = new BX.Promise(null, this.ctx); 15445 } 15446 15447 if(this.state !== null) // if promise was already resolved, execute immediately 15448 { 15449 this.execute(); 15450 } 15451 15452 return this.next; 15453 }; 15454 15455 BX.Promise.prototype.setAutoResolve = function(way, ms) 15456 { 15457 this.timer = setTimeout(function(){ 15458 if(this.state === null) 15459 { 15460 this[way ? 'fulfill' : 'reject'](); 15461 } 15462 }.bind(this), ms || 15); 15463 };
15464 BX.Promise.prototype.cancelAutoResolve = function() 15465 { 15466 clearTimeout(this.timer); 15467 }; 15468 /** 15469 * Resolve function. This function allows promise chaining, like ..then().then()... 15470 * Typical usage: 15471 * 15472 * var p = new Promise(); 15473 * 15474 * p.then(function(value){ 15475 * return someValue; // next promise in the chain will be fulfilled with someValue 15476 * }).then(function(value){ 15477 * 15478 * var p1 = new Promise(); 15479 * *** some async code here, that eventually resolves p1 *** 15480 * 15481 * return p1; // chain will resume when p1 resolved (fulfilled or rejected) 15482 * }).then(function(value){ 15483 * 15484 * // you can also do 15485 * var e = new Error(); 15486 * throw e; 15487 * // it will cause next promise to be rejected with e 15488 * 15489 * return someOtherValue; 15490 * }).then(function(value){ 15491 * ... 15492 * }, function(reason){ 15493 * // promise was rejected with reason 15494 * })...; 15495 * 15496 * p.fulfill('let`s start this chain'); 15497 * 15498 * @param x 15499 */ 15500 BX.Promise.prototype.resolve = function(x) 15501 { 15502 var this_ = this; 15503 15504 if(this === x) 15505 { 15506 this.reject(new TypeError('Promise cannot fulfill or reject itself')); // avoid recursion 15507 } 15508 // allow "pausing" promise chaining until promise x is fulfilled or rejected 15509 else if(x && x.toString() === "[object BX.Promise]") 15510 { 15511 x.then(function(value){ 15512 this_.fulfill(value); 15513 }, function(reason){ 15514 this_.reject(reason); 15515 }); 15516 } 15517 else // auto-fulfill this promise 15518 { 15519 this.fulfill(x); 15520 } 15521 }; 15522 15523 BX.Promise.prototype.toString = function() 15524 { 15525 return "[object BX.Promise]"; 15526 }; 15527 15528 BX.Promise.prototype.execute = function() 15529 { 15530 if(this.state === null) 15531 { 15532 //then() must not be called before BX.Promise resolve() happens 15533 return; 15534 } 15535 15536 var value = undefined; 15537 var reason = undefined; 15538 var x = undefined; 15539 var k; 15540 if(this.state === true) // promise was fulfill()-ed 15541 { 15542 if(this.onFulfilled.length) 15543 { 15544 try 15545 { 15546 for(k = 0; k < this.onFulfilled.length; k++) 15547 {
15548 x = this.onFulfilled[k].apply(this.ctx, [this.value]); 15549 if(typeof x != 'undefined') 15550 { 15551 value = x; 15552 } 15553 } 15554 } 15555 catch(e) 15556 { 15557 if('console' in window) 15558 { 15559 console.dir(e); 15560 } 15561 15562 if (typeof BX.debug !== 'undefined') 15563 { 15564 BX.debug(e); 15565 } 15566 15567 reason = e; // reject next 15568 } 15569 } 15570 else 15571 { 15572 value = this.value; // resolve next 15573 } 15574 } 15575 else if(this.state === false) // promise was reject()-ed 15576 { 15577 if(this.onRejected.length) 15578 { 15579 try 15580 { 15581 for(k = 0; k < this.onRejected.length; k++) 15582 { 15583 x = this.onRejected[k].apply(this.ctx, [this.reason]); 15584 if(typeof x != 'undefined') 15585 { 15586 value = x; 15587 } 15588 } 15589 } 15590 catch(e) 15591 { 15592 if('console' in window) 15593 { 15594 console.dir(e); 15595 } 15596 15597 if (typeof BX.debug !== 'undefined') 15598 { 15599 BX.debug(e); 15600 } 15601 15602 reason = e; // reject next 15603 } 15604 } 15605 else 15606 { 15607 reason = this.reason; // reject next 15608 } 15609 } 15610 15611 if(this.next !== null) 15612 { 15613 if(typeof reason != 'undefined') 15614 { 15615 this.next.reject(reason); 15616 } 15617 else if(typeof value != 'undefined') 15618 { 15619 this.next.resolve(value); 15620 } 15621 } 15622 }; 15623 BX.Promise.prototype.checkState = function() 15624 { 15625 if(this.state !== null) 15626 { 15627 throw new Error('You can not do fulfill() or reject() multiple times'); 15628 } 15629 }; 15630})(window); 15631 15632 15633 15634;(function(window){ 15635 15636if (window.BX.ajax) 15637 return; 15638 15639var 15640 BX = window.BX, 15641 15642 tempDefaultConfig = {}, 15643 defaultConfig = { 15644 method: 'GET', // request method: GET|POST 15645 dataType: 'html', // type of data loading: html|json|script 15646 timeout: 0, // request timeout in seconds. 0 for browser-default 15647 async: true, // whether request is asynchronous or not 15648 processData: true, // any data processing is disabled if false, only callback call 15649 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 15650 emulateOnload: true, 15651 skipAuthCheck: false, // whether to check authorization failure (SHOUD be set to true for CORS requests) 15652 start: true, // send request immediately (if false, request can be started manually via XMLHttpRequest object returned) 15653 cache: true, // whether NOT to add random addition to URL 15654 preparePost: true, // whether set Content-Type x-www-form-urlencoded in POST 15655 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'}] 15656 lsTimeout: 30, //local storage data TTL. useless without lsId. 15657 lsForce: false //wheter to force query instead of using localStorage data. useless without lsId. 15658/* 15659other parameters: 15660 url: url to get/post 15661 data: data to post 15662 onsuccess: successful request callback. BX.proxy may be used. 15663 onfailure: request failure callback. BX.proxy may be used. 15664 onprogress: request progress callback. BX.proxy may be used. 15665 15666 lsId: local storage id - for constantly updating queries which can communicate via localStorage. core_ls.js needed 15667 15668any of the default parameters can be overridden. defaults can be changed by BX.ajax.Setup() - for all further requests! 15669*/ 15670 }, 15671 loadedScripts = {}, 15672 loadedScriptsQueue = [], 15673 r = { 15674 'url_utf': /[^\034-\254]+/g, 15675 'script_self': /\/bitrix\/js\/main\/core\/core(_ajax)*.js$/i, 15676 'script_self_window': /\/bitrix\/js\/main\/core\/core_window.js$/i, 15677 'script_self_admin': /\/bitrix\/js\/main\/core\/core_admin.js$/i, 15678 'script_onload': /window.onload/g 15679 }; 15680 15681// low-level method 15682BX.ajax = function(config) 15683{ 15684 var status, data; 15685
15686 if (!config || !config.url || !BX.type.isString(config.url)) 15687 { 15688 return false; 15689 } 15690 15691 for (var i in tempDefaultConfig) 15692 if (typeof (config[i]) == "undefined") config[i] = tempDefaultConfig[i]; 15693 15694 tempDefaultConfig = {}; 15695 15696 for (i in defaultConfig) 15697 if (typeof (config[i]) == "undefined") config[i] = defaultConfig[i]; 15698 15699 config.method = config.method.toUpperCase(); 15700 15701 if (!BX.localStorage) 15702 config.lsId = null; 15703 15704 if (BX.browser.IsIE()) 15705 { 15706 var result = r.url_utf.exec(config.url); 15707 if (result) 15708 { 15709 do 15710 { 15711 config.url = config.url.replace(result, BX.util.urlencode(result)); 15712 result = r.url_utf.exec(config.url); 15713 } while (result); 15714 } 15715 } 15716 15717 if(config.dataType == 'json') 15718 config.emulateOnload = false; 15719 15720 if (!config.cache && config.method == 'GET') 15721 config.url = BX.ajax._uncache(config.url); 15722 15723 if (config.method == 'POST') 15724 { 15725 if (config.preparePost) 15726 { 15727 config.data = BX.ajax.prepareData(config.data); 15728 } 15729 else if (getLastContentTypeHeader(config.headers) === 'application/json') 15730 { 15731 const isJson = ( 15732 BX.Type.isPlainObject(config.data) 15733 || BX.Type.isString(config.data) 15734 || BX.Type.isNumber(config.data) 15735 || BX.Type.isBoolean(config.data) 15736 || BX.Type.isArray(config.data) 15737 ); 15738 15739 if (isJson) 15740 { 15741 config.data = JSON.stringify(config.data); 15742 } 15743 } 15744 } 15745 15746 var bXHR = true; 15747 if (config.lsId && !config.lsForce) 15748 { 15749 var v = BX.localStorage.get('ajax-' + config.lsId); 15750 if (v !== null) 15751 { 15752 bXHR = false; 15753 15754 var lsHandler = function(lsData) { 15755 if (lsData.key == 'ajax-' + config.lsId && lsData.value != 'BXAJAXWAIT') 15756 { 15757 var data = lsData.value, 15758 bRemove = !!lsData.oldValue && data == null; 15759 if (!bRemove) 15760 BX.ajax.__run(config, data); 15761 else if (config.onfailure) 15762 config.onfailure("timeout"); 15763 15764 BX.removeCustomEvent('onLocalStorageChange', lsHandler); 15765 } 15766 }; 15767 15768 if (v == 'BXAJAXWAIT') 15769 { 15770 BX.addCustomEvent('onLocalStorageChange', lsHandler); 15771 } 15772 else 15773 { 15774 setTimeout(function() {lsHandler({key: 'ajax-' + config.lsId, value: v})}, 10); 15775 } 15776 } 15777 } 15778 15779 if (bXHR) 15780 { 15781 config.xhr = BX.ajax.xhr(); 15782 if (!config.xhr) return; 15783 15784 if (config.lsId) 15785 { 15786 BX.localStorage.set('ajax-' + config.lsId, 'BXAJAXWAIT', config.lsTimeout); 15787 } 15788 15789 if (BX.Type.isFunction(config.onprogress)) 15790 { 15791 BX.bind(config.xhr, 'progress', config.onprogress); 15792 } 15793 15794 if (BX.Type.isFunction(config.onprogressupload) && config.xhr.upload) 15795 { 15796 BX.bind(config.xhr.upload, 'progress', config.onprogressupload); 15797 } 15798 15799 config.xhr.open(config.method, config.url, config.async); 15800 15801 if (!config.skipBxHeader && !BX.ajax.isCrossDomain(config.url)) 15802 { 15803 config.xhr.setRequestHeader('Bx-ajax', 'true'); 15804 } 15805 15806 if (config.method == 'POST' && config.preparePost) 15807 { 15808 config.xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 15809 } 15810 if (typeof(config.headers) == "object") 15811 { 15812 for (i = 0; i < config.headers.length; i++) 15813 config.xhr.setRequestHeader(config.headers[i].name, config.headers[i].value); 15814 } 15815 15816 var bRequestCompleted = false; 15817 var onreadystatechange = config.xhr.onreadystatechange = function(additional) 15818 { 15819 if (bRequestCompleted) 15820 return; 15821 15822 if (additional === 'timeout') 15823 { 15824 if (config.onfailure) 15825 { 15826 config.onfailure('timeout', '', config); 15827 } 15828 15829 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['timeout', '', config]); 15830 15831 config.xhr.onreadystatechange = BX.DoNothing; 15832 config.xhr.abort(); 15833 15834 if (config.async) 15835 { 15836 config.xhr = null; 15837 } 15838 } 15839 else 15840 { 15841 if (config.xhr.readyState == 4 || additional == 'run') 15842 { 15843 status = BX.ajax.xhrSuccess(config.xhr) ? "success" : "error"; 15844 bRequestCompleted = true; 15845 config.xhr.onreadystatechange = BX.DoNothing; 15846 15847 if (status == 'success') 15848 { 15849 var authHeader = (!!config.skipAuthCheck || BX.ajax.isCrossDomain(config.url)) 15850 ? false 15851 : config.xhr.getResponseHeader('X-Bitrix-Ajax-Status'); 15852 15853 if(!!authHeader && authHeader == 'Authorize') 15854 { 15855 if (config.onfailure) 15856 { 15857 config.onfailure('auth', config.xhr.status, config); 15858 } 15859 15860 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['auth', config.xhr.status, config]); 15861 } 15862 else 15863 { 15864 var data = config.xhr.responseText; 15865 15866 if (config.lsId) 15867 { 15868 BX.localStorage.set('ajax-' + config.lsId, data, config.lsTimeout); 15869 } 15870 15871 BX.ajax.__run(config, data); 15872 } 15873 } 15874 else 15875 { 15876 if (config.onfailure) 15877 { 15878 config.onfailure('status', config.xhr.status, config); 15879 } 15880 15881 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['status', config.xhr.status, config]); 15882 } 15883 15884 if (config.async) 15885 { 15886 config.xhr = null; 15887 } 15888 } 15889 } 15890 }; 15891 15892 if (config.async && config.timeout > 0) 15893 { 15894 setTimeout(function() { 15895 if (config.xhr && !bRequestCompleted) 15896 { 15897 onreadystatechange("timeout"); 15898 } 15899 }, config.timeout * 1000); 15900 } 15901 15902 if (config.start) 15903 {
15904 config.xhr.send(config.data); 15905 15906 if (!config.async) 15907 { 15908 onreadystatechange('run'); 15909 } 15910 } 15911 15912 return config.xhr; 15913 } 15914}; 15915 15916BX.ajax.xhr = function() 15917{ 15918 if (window.XMLHttpRequest) 15919 { 15920 try {return new XMLHttpRequest();} catch(e){} 15921 } 15922 else if (window.ActiveXObject) 15923 { 15924 try { return new window.ActiveXObject("Msxml2.XMLHTTP.6.0"); } 15925 catch(e) {} 15926 try { return new window.ActiveXObject("Msxml2.XMLHTTP.3.0"); } 15927 catch(e) {} 15928 try { return new window.ActiveXObject("Msxml2.XMLHTTP"); } 15929 catch(e) {} 15930 try { return new window.ActiveXObject("Microsoft.XMLHTTP"); } 15931 catch(e) {} 15932 throw new Error("This browser does not support XMLHttpRequest."); 15933 } 15934 15935 return null; 15936}; 15937 15938BX.ajax.isCrossDomain = function(url, location) 15939{ 15940 location = location || window.location; 15941 15942 //Relative URL gets a current protocol 15943 if (url.indexOf("//") === 0) 15944 { 15945 url = location.protocol + url; 15946 } 15947 15948 //Fast check 15949 if (url.indexOf("http") !== 0) 15950 { 15951 return false; 15952 } 15953 15954 var link = window.document.createElement("a"); 15955 link.href = url; 15956 15957 return link.protocol !== location.protocol || 15958 link.hostname !== location.hostname || 15959 BX.ajax.getHostPort(link.protocol, link.host) !== BX.ajax.getHostPort(location.protocol, location.host); 15960}; 15961 15962BX.ajax.getHostPort = function(protocol, host) 15963{ 15964 var match = /:(\d+)$/.exec(host); 15965 if (match) 15966 { 15967 return match[1]; 15968 } 15969 else 15970 { 15971 if (protocol === "http:") 15972 { 15973 return "80"; 15974 } 15975 else if (protocol === "https:") 15976 { 15977 return "443"; 15978 } 15979 } 15980 15981 return ""; 15982}; 15983 15984BX.ajax.__prepareOnload = function(scripts, ajax_session) 15985{ 15986 if (scripts.length > 0) 15987 { 15988 BX.ajax['onload_' + ajax_session] = null; 15989 15990 for (var i=0,len=scripts.length;i<len;i++) 15991 { 15992 if (scripts[i].isInternal) 15993 { 15994 scripts[i].JS = scripts[i].JS.replace(r.script_onload, 'BX.aja
15994x.onload_' + ajax_session); 15995 } 15996 } 15997 } 15998 15999 BX.CaptureEventsGet(); 16000 BX.CaptureEvents(window, 'load'); 16001}; 16002 16003BX.ajax.__runOnload = function(ajax_session) 16004{ 16005 if (null != BX.ajax['onload_' + ajax_session]) 16006 { 16007 BX.ajax['onload_' + ajax_session].apply(window); 16008 BX.ajax['onload_' + ajax_session] = null; 16009 } 16010 16011 var h = BX.CaptureEventsGet(); 16012 16013 if (h) 16014 { 16015 for (var i=0; i<h.length; i++) 16016 h[i].apply(window); 16017 } 16018}; 16019 16020BX.ajax.__run = function(config, data) 16021{ 16022 if (!config.processData) 16023 { 16024 if (config.onsuccess) 16025 { 16026 config.onsuccess(data); 16027 } 16028 16029 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [data, config]); 16030 } 16031 else 16032 { 16033 data = BX.ajax.processRequestData(data, config); 16034 } 16035}; 16036 16037 16038BX.ajax._onParseJSONFailure = function(data) 16039{ 16040 this.jsonFailure = true; 16041 this.jsonResponse = data; 16042 this.jsonProactive = /^\[WAF\]/.test(data); 16043}; 16044 16045BX.ajax.processRequestData = function(data, config) 16046{ 16047 var result, scripts = [], styles = []; 16048 switch (config.dataType.toUpperCase()) 16049 { 16050 case 'JSON': 16051 16052 var context = config.xhr || {}; 16053 BX.addCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 16054 result = BX.parseJSON(data, context); 16055 BX.removeCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 16056 16057 if(!!result && BX.type.isArray(result['bxjs'])) 16058 { 16059 for(var i = 0; i < result['bxjs'].length; i++) 16060 { 16061 if(BX.type.isNotEmptyString(result['bxjs'][i])) 16062 { 16063 scripts.push({ 16064 "isInternal": false, 16065 "JS": result['bxjs'][i], 16066 "bRunFirst": config.scriptsRunFirst 16067 }); 16068 } 16069 else 16070 { 16071 scripts.push(result['bxjs'][i]) 16072 } 16073 } 16074 } 16075 16076 if(!!result && BX.type.isArray(result['bxcss'])) 16077 { 16078 styles = result['bxcss']; 16079 } 16080 16081 break; 16082 case 'SCRIPT': 16083 scripts.push({"isInternal": true, "JS": data, "bRunFirst": config.scriptsRunFirst}); 16084 result = data; 16085 break; 16086 16087 default: // HTML 16088 var ob = BX.processHTML(data, config.scriptsRunFirst); 16089 result = ob.HTML; scripts = ob.SCRIPT; styles = ob.STYLE; 16090 break; 16091 } 16092 16093 if (styles.length > 0) 16094 { 16095 BX.loadCSS(styles); 16096 } 16097 16098 let ajax_session = null; 16099 if (config.emulateOnload) 16100 { 16101 ajax_session = parseInt(Math.random() * 1000000); 16102 BX.ajax.__prepareOnload(scripts, ajax_session); 16103 } 16104 16105 const cb = BX.defer(function() 16106 { 16107 if (config.emulateOnload) 16108 { 16109 BX.ajax.__runOnload(ajax_session); 16110 } 16111 16112 BX.onCustomEvent(config.xhr, 'onAjaxSuccessFinish', [config]); 16113 }); 16114 16115 try 16116 { 16117 if (!!config.jsonFailure) 16118 { 16119 throw {type: 'json_failure', data: config.jsonResponse, bProactive: config.jsonProactive}; 16120 } 16121 16122 config.scripts = scripts; 16123 16124 BX.ajax.processScripts(config.scripts, true); 16125 16126 if (config.onsuccess) 16127 { 16128 config.onsuccess(result); 16129 } 16130 16131 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [result, config]); 16132 16133 BX.ajax.processScripts(config.scripts, false, cb); 16134 } 16135 catch (e) 16136 { 16137 if (config.onfailure) 16138 config.onfailure("processing", e); 16139 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['processing', e, config]); 16140 } 16141}; 16142 16143BX.ajax.processScripts = function(scripts, bRunFirst, cb) 16144{ 16145 var scriptsExt = [], scriptsInt = ''; 16146 16147 cb = cb || BX.DoNothing; 16148 16149 for (var i = 0, length = scripts.length; i < length; i++) 16150 { 16151 if (typeof bRunFirst != 'undefined' && bRunFirst != !!scripts[i].bRunFirst) 16152 continue; 16153 16154 if (scripts[i].isInternal) 16155 scriptsInt += ';' + scripts[i].JS; 16156 else 16157 scriptsExt.push(scripts[i].JS); 16158 } 16159 16160 scriptsExt = BX.util.array_unique(scriptsExt); 16161 var inlineScripts = scriptsInt.length > 0 ? function() { BX.evalGlobal(scriptsInt); } : BX.DoNothing; 16162 16163 if (scriptsExt.length > 0) 16164 { 16165 BX.load(scriptsExt, function() { 16166 inlineScripts(); 16167 cb(); 16168 }); 16169 } 16170 else 16171 { 16172 inlineScripts(); 16173 cb(); 16174 } 16175}; 16176 16177// TODO: extend this function to use with any data objects or forms 16178BX.ajax.prepareData = function(arData, prefix) 16179{ 16180 var data = ''; 16181 if (BX.type.isString(arData)) 16182 data = arData; 16183 else if (null != arData) 16184 { 16185 for(var i in arData) 16186 { 16187 if (arData.hasOwnProperty(i)) 16188 { 16189 if (data.length > 0) 16190 data += '&'; 16191 var name = BX.util.urlencode(i); 16192 if(prefix) 16193 name = prefix + '[' + name + ']'; 16194 if(typeof arData[i] == 'object') 16195 data += BX.ajax.prepareData(arData[i], name); 16196 else 16197 data += name + '=' + BX.util.urlencode(arData[i]); 16198 } 16199 } 16200 } 16201 return data; 16202}; 16203 16204BX.ajax.xhrSuccess = function(xhr) 16205{ 16206 return (xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || xhr.status === 1223 || xhr.status === 0; 16207}; 16208 16209BX.ajax.Setup = function(config, bTemp) 16210{ 16211 bTemp = !!bTemp; 16212 16213 for (var i in config) 16214 { 16215 if (bTemp) 16216 tempDefaultConfig[i] = config[i]; 16217 else 16218 defaultConfig[i] = config[i]; 16219 } 16220}; 16221 16222BX.ajax.replaceLocalStorageValue = function(lsId, data, ttl) 16223{ 16224 if (!!BX.localStorage) 16225 BX.localStorage.set('ajax-' + lsId, data, ttl); 16226}; 16227 16228 16229BX.ajax._uncache = function(url) 16230{ 16231 return url + ((url.indexOf('?') !== -1 ? "&" : "?") + '_=' + (new Date()).getTime()); 16232}; 16233 16234/* simple interface */ 16235BX.ajax.get = function(url, data, callback) 16236{ 16237 if (BX.type.isFunction(data)) 16238 { 16239 callback = data; 16240 data = ''; 16241 } 16242
16243 data = BX.ajax.prepareData(data); 16244 16245 if (data) 16246 { 16247 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 16248 data = ''; 16249 } 16250 16251 return BX.ajax({ 16252 'method': 'GET', 16253 'dataType': 'html', 16254 'url': url, 16255 'data': '', 16256 'onsuccess': callback 16257 }); 16258}; 16259 16260BX.ajax.getCaptcha = function(callback) 16261{ 16262 return BX.ajax.loadJSON('/bitrix/tools/ajax_captcha.php', callback); 16263}; 16264 16265BX.ajax.insertToNode = function(url, node) 16266{ 16267 node = BX(node); 16268 if (!!node) 16269 { 16270 var eventArgs = { cancel: false }; 16271 BX.onCustomEvent('onAjaxInsertToNode', [{ url: url, node: node, eventArgs: eventArgs }]); 16272 if(eventArgs.cancel === true) 16273 { 16274 return; 16275 } 16276 16277 var show = null; 16278 if (!tempDefaultConfig.denyShowWait) 16279 { 16280 show = BX.showWait(node); 16281 delete tempDefaultConfig.denyShowWait; 16282 } 16283 16284 return BX.ajax.get(url, function(data) { 16285 node.innerHTML = data; 16286 BX.closeWait(node, show); 16287 }); 16288 } 16289}; 16290 16291BX.ajax.post = function(url, data, callback) 16292{ 16293 data = BX.ajax.prepareData(data); 16294 16295 return BX.ajax({ 16296 'method': 'POST', 16297 'dataType': 'html', 16298 'url': url, 16299 'data': data, 16300 'onsuccess': callback 16301 }); 16302}; 16303 16304/** 16305 * BX.ajax with BX.Promise 16306 * 16307 * @param config 16308 * @returns {BX.Promise|false} 16309 */ 16310BX.ajax.promise = function(config) 16311{ 16312 var result = new BX.Promise(); 16313 16314 config.onsuccess = function(data) 16315 { 16316 result.fulfill(data); 16317 }; 16318 config.onfailure = function(reason, httpStatus, config) 16319 { 16320 result.reject({ 16321 reason: reason, 16322 data: httpStatus, 16323 ajaxConfig: config, 16324 xhr: config.xhr 16325 }); 16326 }; 16327 16328 var xhr = BX.ajax(config); 16329 if (xhr) 16330 { 16331 if (typeof config.onrequeststart === 'function') 16332 { 16333 config.onrequeststart(xhr); 16334 } 16335 } 16336 else 16337 { 16338 result.reject({ 16339 reason: "init", 16340 data: false 16341 }); 16342 } 16343 16344 return result; 16345}; 16346 16347/* load and execute external file script with onload emulation */ 16348BX.ajax.loadScriptAjax = function(script_src, callback, bPreload) 16349{ 16350 if (BX.type.isArray(script_src)) 16351 { 16352 for (var i=0,len=script_src.length;i<len;i++) 16353 { 16354 BX.ajax.loadScriptAjax(script_src[i], callback, bPreload); 16355 } 16356 } 16357 else 16358 { 16359 var script_src_test = script_src.replace(/\.js\?.*/, '.js'); 16360 16361 if (r.script_self.test(script_src_test)) return; 16362 if (r.script_self_window.test(script_src_test) && BX.CWindow) return; 16363 if (r.script_self_admin.test(script_src_test) && BX.admin) return; 16364 16365 if (typeof loadedScripts[script_src_test] == 'undefined') 16366 { 16367 if (!!bPreload) 16368 { 16369 loadedScripts[script_src_test] = ''; 16370 return BX.loadScript(script_src); 16371 } 16372 else 16373 { 16374 return BX.ajax({ 16375 url: script_src, 16376 method: 'GET', 16377 dataType: 'script', 16378 processData: true, 16379 emulateOnload: false, 16380 scriptsRunFirst: true, 16381 async: false, 16382 start: true, 16383 onsuccess: function(result) { 16384 loadedScripts[script_src_test] = result; 16385 if (callback) 16386 callback(result); 16387 } 16388 }); 16389 } 16390 } 16391 else if (callback) 16392 { 16393 callback(loadedScripts[script_src_test]); 16394 } 16395 } 16396}; 16397 16398/* non-xhr loadings */ 16399BX.ajax.loadJSON = function(url, data, callback, callback_failure) 16400{ 16401 if (BX.type.isFunction(data)) 16402 { 16403 callback_failure = callback; 16404 callback = data; 16405 data = ''; 16406 } 16407 16408 data = BX.ajax.prepareData(data); 16409 16410 if (data) 16411 { 16412 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 16413 data = ''; 16414 } 16415 16416 return BX.ajax({ 16417 'method': 'GET', 16418 'dataType': 'json', 16419 'url': url, 16420 'onsuccess': callback, 16421 'onfailure': callback_failure 16422 }); 16423}; 16424 16425var getLastContentTypeHeader = function (headers) { 16426 if (!BX.Type.isArray(headers)) 16427 { 16428 return null; 16429 } 16430 var lastHeader = headers 16431 .filter(function (header) { 16432 return header.name === 'Content-Type'; 16433 }) 16434 .pop(); 16435 16436 return lastHeader ? lastHeader.value : null; 16437}; 16438 16439/** 16440 * @see isValidAnalyticsData in ui.analytics 16441* */ 16442const isValidAnalyticsData = function (analytics) 16443{ 16444 if (!BX.Type.isPlainObject(analytics)) 16445 { 16446 console.error('BX.ajax: {analytics} must be an object.'); 16447 16448 return false; 16449 } 16450 16451 const requiredFields = ['event', 'tool', 'category']; 16452 for (const field of requiredFields) 16453 { 16454 if (!BX.Type.isStringFilled(analytics[field])) 16455 { 16456 console.error(`BX.ajax: The "${field}" property in the "analytics" object must be a non-empty string.`); 16457 16458 return false;
16459 } 16460 } 16461 16462 const additionalFields = ['p1', 'p2', 'p3', 'p4', 'p5']; 16463 for (const field of additionalFields) 16464 { 16465 const value = analytics[field]; 16466 if (!BX.Type.isStringFilled(value)) 16467 { 16468 continue; 16469 } 16470 16471 if (value.split('_').length > 2) 16472 { 16473 console.error(`BX.ajax: The "${field}" property (${value}) in the "analytics" object must be a string containing a single underscore.`); 16474 16475 return false; 16476 } 16477 } 16478 16479 return true; 16480}; 16481 16482const processAnalyticsDataToGetParameters = function(config) 16483{ 16484 const getParameters = {}; 16485 if (BX.Type.isStringFilled(config.analyticsLabel) || BX.Type.isPlainObject(config.analyticsLabel)) 16486 { 16487 getParameters.analyticsLabel = config.analyticsLabel; 16488 } 16489 16490 if (BX.Type.isPlainObject(config.analytics)) 16491 { 16492 if (config.analyticsLabel) 16493 { 16494 delete getParameters.analyticsLabel; 16495 console.error('BX.ajax: Only {analytics} or {analyticsLabel} should be used. If both are present, {analyticsLabel} will be ignored.'); 16496 } 16497 16498 if (isValidAnalyticsData(config.analytics)) 16499 { 16500 getParameters.st = config.analytics; 16501 } 16502 else 16503 { 16504 console.error('BX.ajax: {analytics} is invalid and is skipped.'); 16505 } 16506 } 16507 16508 return getParameters; 16509}; 16510 16511const prepareAjaxGetParameters = function(config) 16512{ 16513 let getParameters = config.getParameters || {}; 16514 getParameters = { ...getParameters, ...processAnalyticsDataToGetParameters(config) }; 16515 16516 if (typeof config.mode !== 'undefined') 16517 { 16518 getParameters.mode = config.mode; 16519 } 16520 if (config.navigation) 16521 { 16522 if (config.navigation.page) 16523 { 16524 getParameters.nav = 'page-' + config.navigation.page; 16525 } 16526 if (config.navigation.size) 16527 { 16528 if (getParameters.nav) 16529 { 16530 getParameters.nav += '-'; 16531 } 16532 else 16533 { 16534 getParameters.nav = ''; 16535 } 16536 getParameters.nav += 'size-' + config.navigation.size; 16537 } 16538 } 16539 16540 return getParameters; 16541}; 16542 16543var prepareAjaxConfig = function(config) 16544{ 16545 config = BX.type.isPlainObject(config) ? config : {}; 16546 16547 config.headers = config.headers || []; 16548 config.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 16549 if (BX.message.SITE_ID) 16550 { 16551 config.headers.push({name: 'X-Bitrix-Site-Id', value: BX.message.SITE_ID}); 16552 } 16553 16554 if (typeof config.json !== 'undefined') 16555 { 16556 if (!BX.type.isPlainObject(config.json)) 16557 { 16558 throw new Error('Wrong `config.json`, plain object expected.') 16559 } 16560 16561 config.headers.push({name: 'Content-Type', value: 'application/json'}); 16562 config.data = config.json; 16563 config.preparePost = false; 16564 } 16565 else if (config.data instanceof FormData) 16566 { 16567 config.preparePost = false; 16568 if (typeof config.signedParameters !== 'undefined') 16569 { 16570 config.data.append('signedParameters', config.signedParameters); 16571 } 16572 } 16573 else if (BX.type.isPlainObject(config.data) || BX.Type.isNil(config.data)) 16574 { 16575 config.data = BX.type.isPlainObject(config.data) ? config.data : {}; 16576 if (typeof config.signedParameters !== 'undefined') 16577 { 16578 config.data.signedParameters = config.signedParameters; 16579 } 16580 } 16581 16582 if (!config.method) 16583 { 16584 config.method = 'POST' 16585 } 16586 16587 return config; 16588}; 16589 16590var buildAjaxPromiseToRestoreCsrf = function(config, withoutRestoringCsrf) 16591{ 16592 withoutRestoringCsrf = withoutRestoringCsrf || false; 16593 var originalConfig = BX.clone(config); 16594 var request = null; 16595 16596 var onrequeststart = config.onrequeststart; 16597 config.onrequeststart = function(xhr) { 16598 request = xhr; 16599 if (BX.type.isFunction(onrequeststart)) 16600 { 16601 onrequeststart(xhr); 16602 } 16603 }; 16604 var onrequeststartOrig = originalConfig.onrequeststart; 16605 originalConfig.onrequeststart = function(xhr) { 16606 request = xhr; 16607 if (BX.type.isFunction(onrequeststartOrig)) 16608 { 16609 onrequeststartOrig(xhr); 16610 } 16611 }; 16612 16613 var promise = BX.ajax.promise(config); 16614 16615 return promise.then(function(response) { 16616 if (!withoutRestoringCsrf && BX.type.isPlainObject(response) && BX.type.isArray(response.errors)) 16617 { 16618 var csrfProblem = false; 16619 response.errors.forEach(function(error) { 16620 if (error.code === 'invalid_csrf' && error.customData.csrf) 16621 { 16622 BX.message({'bitrix_sessid': error.customData.csrf}); 16623 16624 originalConfig.headers = originalConfig.headers || []; 16625 originalConfig.headers = originalConfig.headers.filter(function(header) {
16626 return header && header.name !== 'X-Bitrix-Csrf-Token'; 16627 }); 16628 originalConfig.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 16629 16630 csrfProblem = true; 16631 } 16632 }); 16633 16634 if (csrfProblem) 16635 { 16636 return buildAjaxPromiseToRestoreCsrf(originalConfig, true); 16637 } 16638 } 16639 16640 if (!BX.type.isPlainObject(response) || response.status !== 'success') 16641 { 16642 var errorPromise = new BX.Promise(); 16643 errorPromise.reject(response); 16644 16645 return errorPromise; 16646 } 16647 16648 return response; 16649 }).catch(function(data) { 16650 var ajaxReject = new BX.Promise(); 16651 16652 var originalJsonResponse; 16653 if (BX.type.isPlainObject(data) && data.xhr && data.xhr.responseText) 16654 { 16655 try 16656 { 16657 originalJsonResponse = JSON.parse(data.xhr.responseText); 16658 data = originalJsonResponse; 16659 } 16660 catch (err) 16661 {} 16662 } 16663 16664 if (BX.type.isPlainObject(data) && data.status && data.hasOwnProperty('data')) 16665 { 16666 ajaxReject.reject(data); 16667 } 16668 else 16669 { 16670 ajaxReject.reject({ 16671 status: 'error', 16672 data: { 16673 ajaxRejectData: data 16674 }, 16675 errors: [ 16676 { 16677 code: 'NETWORK_ERROR', 16678 message: 'Network error' 16679 } 16680 ] 16681 }); 16682 } 16683 16684 return ajaxReject; 16685 }).then(function(response){ 16686 16687 var assetsLoaded = new BX.Promise(); 16688 16689 var headers = request.getAllResponseHeaders().trim().split(/[\r\n]+/); 16690 var headerMap = {}; 16691 headers.forEach(function (line) { 16692 var parts = line.split(': '); 16693 var header = parts.shift().toLowerCase(); 16694 headerMap[header] = parts.join(': '); 16695 }); 16696 16697 if (!headerMap['x-process-assets']) 16698 { 16699 assetsLoaded.fulfill(response); 16700 16701 return assetsLoaded; 16702 } 16703 16704 var assets = BX.prop.getObject(BX.prop.getObject(response, "data", {}), "assets", {}); 16705 16706 var inlineScripts = []; 16707 if (BX.Type.isArrayFilled(assets.string)) 16708 { 16709 assets.string 16710 .reduce(function(acc, item) { 16711 if (String(item).length > 0 && !acc.includes(item)) 16712 { 16713 acc.push(item); 16714 } 16715 16716 return acc; 16717 }, []) 16718 .forEach(function(item) { 16719 if (String(item).startsWith('<script type="extension/settings"')) 16720 { 16721 BX.html(document.head, item, { useAdjacentHTML: true }); 16722 } 16723 else 16724 { 16725 inlineScripts.push(item); 16726 } 16727 }); 16728 } 16729 16730 var promise = new Promise(function(resolve, reject) { 16731 var css = BX.prop.getArray(assets, "css", []); 16732 BX.load(css, function(){ 16733 BX.loadScript( 16734 BX.prop.getArray(assets, "js", []), 16735 resolve 16736 ); 16737 }); 16738 }); 16739 16740 promise.then(function(){ 16741 var stringAsset = inlineScripts.join('\n'); 16742 BX.html(document.head, stringAsset, { useAdjacentHTML: true }).then(function(){ 16743 assetsLoaded.fulfill(response); 16744 }); 16745 }); 16746 16747 return assetsLoaded; 16748 }); 16749}; 16750 16751/** 16752 * 16753 * @param {string} action 16754 * @param {Object} config 16755 * @param {?string|?Object} [config.analyticsLabel] 16756 * @param {?Object} [config.analytics] 16757 * @param {string} [config.analytics.event] 16758 * @param {string} [config.analytics.tool] 16759 * @param {string} [config.analytics.category] 16760 * @param {?string} [config.analytics.c_section] 16761 * @param {?string} [config.analytics.c_sub_section] 16762 * @param {?string} [config.analytics.c_element] 16763 * @param {?string} [config.analytics.type] 16764 * @param {?string} [config.analytics.p1] 16765 * @param {?string} [config.analytics.p2] 16766 * @param {?string} [config.analytics.p3] 16767 * @param {?string} [config.analytics.p4] 16768 * @param {?string} [config.analytics.p5] 16769 * @param {?('success' | 'error' | 'attempt' | 'cancel')} [config.analytics.status] 16770 * @param {string} [config.method='POST'] 16771 * @param {Object} [config.data] 16772 * @param {?Object} [config.getParameters] 16773 * @param {?Object} [config.headers] 16774 * @param {?Object} [config.timeout] 16775 * @param {Object} [config.navigation] 16776 * @param {number} [config.navigation.page] 16777 */ 16778BX.ajax.runAction = function(action, config) 16779{ 16780 config = prepareAjaxConfig(config); 16781 var getParameters = prepareAjaxGetParameters(config); 16782 getParameters.action = action; 16783
16784 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 16785 return buildAjaxPromiseToRestoreCsrf({ 16786 method: config.method, 16787 dataType: 'json', 16788 url: url, 16789 data: config.data, 16790 timeout: config.timeout, 16791 preparePost: config.preparePost, 16792 headers: config.headers, 16793 onrequeststart: config.onrequeststart, 16794 onprogress: config.onprogress, 16795 onprogressupload: config.onprogressupload 16796 }); 16797}; 16798 16799/** 16800 * 16801 * @param {string} component 16802 * @param {string} action 16803 * @param {Object} config 16804 * @param {?string|?Object} [config.analyticsLabel] 16805 * @param {?Object} [config.analytics] 16806 * @param {string} [config.analytics.event] 16807 * @param {string} [config.analytics.tool] 16808 * @param {string} [config.analytics.category] 16809 * @param {?string} [config.analytics.c_section] 16810 * @param {?string} [config.analytics.c_sub_section] 16811 * @param {?string} [config.analytics.c_element] 16812 * @param {?string} [config.analytics.type] 16813 * @param {?string} [config.analytics.p1] 16814 * @param {?string} [config.analytics.p2] 16815 * @param {?string} [config.analytics.p3] 16816 * @param {?string} [config.analytics.p4] 16817 * @param {?string} [config.analytics.p5] 16818 * @param {?string} [config.signedParameters] 16819 * @param {string} [config.method='POST'] 16820 * @param {string} [config.mode='ajax'] Ajax or class. 16821 * @param {Object} [config.data] 16822 * @param {?Object} [config.getParameters] 16823 * @param {?array} [config.headers] 16824 * @param {?number} [config.timeout] 16825 * @param {Object} [config.navigation] 16826 */ 16827BX.ajax.runComponentAction = function (component, action, config) 16828{ 16829 config = prepareAjaxConfig(config); 16830 config.mode = config.mode || 'ajax'; 16831 16832 var getParameters = prepareAjaxGetParameters(config); 16833 getParameters.c = component; 16834 getParameters.action = action; 16835
16836 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 16837 16838 return buildAjaxPromiseToRestoreCsrf({ 16839 method: config.method, 16840 dataType: 'json', 16841 url: url, 16842 data: config.data, 16843 timeout: config.timeout, 16844 preparePost: config.preparePost, 16845 headers: config.headers, 16846 onrequeststart: (config.onrequeststart ? config.onrequeststart : null), 16847 onprogress: config.onprogress, 16848 onprogressupload: config.onprogressupload 16849 }); 16850}; 16851 16852/* 16853arObs = [{ 16854 url: url, 16855 type: html|script|json|css, 16856 callback: function 16857}] 16858*/ 16859BX.ajax.load = function(arObs, callback) 16860{ 16861 if (!BX.type.isArray(arObs)) 16862 arObs = [arObs]; 16863 16864 var cnt = 0; 16865 16866 if (!BX.type.isFunction(callback)) 16867 callback = BX.DoNothing; 16868 16869 var handler = function(data) 16870 { 16871 if (BX.type.isFunction(this.callback)) 16872 this.callback(data); 16873 16874 if (++cnt >= len) 16875 callback(); 16876 }; 16877 16878 for (var i = 0, len = arObs.length; i<len; i++) 16879 { 16880 switch(arObs[i].type.toUpperCase()) 16881 { 16882 case 'SCRIPT': 16883 BX.loadScript([arObs[i].url], BX.proxy(handler, arObs[i])); 16884 break; 16885 case 'CSS': 16886 BX.loadCSS([arObs[i].url]); 16887 16888 if (++cnt >= len) 16889 callback(); 16890 break; 16891 case 'JSON': 16892 BX.ajax.loadJSON(arObs[i].url, BX.proxy(handler, arObs[i])); 16893 break; 16894 16895 default: 16896 BX.ajax.get(arObs[i].url, '', BX.proxy(handler, arObs[i])); 16897 break; 16898 } 16899 } 16900}; 16901 16902/* ajax form sending */ 16903BX.ajax.submit = function(obForm, callback) 16904{ 16905 if (!obForm.target) 16906 { 16907 if (null == obForm.BXFormTarget) 16908 { 16909 var frame_name = 'formTarget_' + Math.random(); 16910 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 16911 props: { 16912 name: frame_name, 16913 id: frame_name, 16914 src: 'javascript:void(0)' 16915 }, 16916 style: { 16917 display: 'none' 16918 } 16919 })); 16920 } 16921 16922 obForm.target = obForm.BXFormTarget.name; 16923 } 16924 16925 obForm.BXFormCallback = callback; 16926 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 16927 16928 BX.submit(obForm); 16929 16930 return false; 16931}; 16932 16933BX.ajax.submitComponentForm = function(obForm, container, bWait) 16934{ 16935 if (!obForm.target) 16936 { 16937 if (null == obForm.BXFormTarget) 16938 { 16939 var frame_name = 'formTarget_' + Math.random(); 16940 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 16941 props: { 16942 name: frame_name, 16943 id: frame_name, 16944 src: 'javascript:void(0)' 16945 }, 16946 style: { 16947 display: 'none' 16948 } 16949 })); 16950 } 16951 16952 obForm.target = obForm.BXFormTarget.name; 16953 } 16954 16955 if (!!bWait) 16956 var w = BX.showWait(container); 16957 16958 obForm.BXFormCallback = function(d) { 16959 if (!!bWait) 16960 BX.closeWait(w); 16961 16962 var callOnload = function(){ 16963 if(!!window.bxcompajaxframeonload) 16964 { 16965 setTimeout(function(){window.bxcompajaxframeonload();window.bxcompajaxframeonload=null;}, 10); 16966 } 16967 }; 16968 16969 BX(container).innerHTML = d; 16970 BX.onCustomEvent('onAjaxSuccess', [null,null,callOnload]); 16971 }; 16972 16973 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 16974 16975 return true; 16976}; 16977 16978// func will be executed in form context 16979BX.ajax._submit_callback = function() 16980{ 16981 //opera and IE8 triggers onload event even on empty iframe 16982 try 16983 { 16984 if(this.BXFormTarget.contentWindow.location.href.indexOf('http') != 0) 16985 return; 16986 } catch (e) { 16987 return; 16988 } 16989 16990 if (this.BXFormCallback) 16991 this.BXFormCallback.apply(this, [this.BXFormTarget.contentWindow.document.body.innerHTML]); 16992 16993 BX.unbindAll(this.BXFormTarget); 16994}; 16995 16996BX.ajax.prepareForm = function(obForm, data) 16997{ 16998 data = (!!data ? data : {}); 16999 var i, ii, el, 17000 _data = [], 17001 n = obForm.elements.length, 17002 files = 0, length = 0; 17003 if(!!obForm) 17004 { 17005 for (i = 0; i < n; i++) 17006 { 17007 el = obForm.elements[i]; 17008 if (el.disabled) 17009 continue; 17010 17011 if(!el.type) 17012 continue; 17013 17014 switch(el.type.toLowerCase()) 17015 { 17016 case 'text': 17017 case 'textarea': 17018 case 'password': 17019 case 'number': 17020 case 'hidden': 17021 case 'select-one': 17022 _data.push({name: el.name, value: el.value}); 17023 length += (el.name.length + el.value.length); 17024 break; 17025 case 'file': 17026 if (!!el.files) 17027 { 17028 for (ii = 0; ii < el.files.length; ii++) 17029 { 17030 files++; 17031 _data.push({name: el.name, value: el.files[ii], file : true}); 17032 length += el.files[ii].size; 17033 } 17034 } 17035 break; 17036 case 'radio':
17037 case 'checkbox': 17038 if(el.checked) 17039 { 17040 _data.push({name: el.name, value: el.value}); 17041 length += (el.name.length + el.value.length); 17042 } 17043 break; 17044 case 'select-multiple': 17045 for (var j = 0; j < el.options.length; j++) 17046 { 17047 if (el.options[j].selected) 17048 { 17049 _data.push({name : el.name, value : el.options[j].value}); 17050 length += (el.name.length + el.options[j].length); 17051 } 17052 } 17053 break; 17054 default: 17055 break; 17056 } 17057 } 17058 17059 i = 0; length = 0; 17060 var current = data, name, rest, pp, tmpKey; 17061 17062 while(i < _data.length) 17063 { 17064 var p = _data[i].name.indexOf('['); 17065 if (tmpKey) 17066 { 17067 current[_data[i].name] = {}; 17068 current[_data[i].name][tmpKey.replace(/\[|\]/gi, '')] = _data[i].value; 17069 current = data; 17070 tmpKey = null; 17071 i++; 17072 } 17073 else if (p == -1) 17074 { 17075 current[_data[i].name] = _data[i].value; 17076 current = data; 17077 i++; 17078 } 17079 else 17080 { 17081 name = _data[i].name.substring(0, p); 17082 rest = _data[i].name.substring(p+1); 17083 pp = rest.indexOf(']'); 17084 17085 if(pp == -1) 17086 { 17087 if (!current[name]) 17088 current[name] = []; 17089 current = data; 17090 i++; 17091 } 17092 else if(pp == 0) 17093 { 17094 if (!current[name]) 17095 current[name] = []; 17096 //No index specified - so take the next integer 17097 current = current[name]; 17098 _data[i].name = '' + current.length; 17099 if (rest.substring(pp+1).indexOf('[') === 0) 17100 tmpKey = rest.substring(0, pp) + rest.substring(pp+1); 17101 } 17102 else 17103 { 17104 if (!current[name]) 17105 current[name] = {}; 17106 //Now index name becomes and name and we go deeper into the array 17107 current = current[name]; 17108 _data[i].name = rest.substring(0, pp) + rest.substring(pp+1); 17109 } 17110 } 17111 } 17112 } 17113 return {data : data, filesCount : files, roughSize : length}; 17114}; 17115BX.ajax.submitAjax = function(obForm, config) 17116{ 17117 config = (config !== null && typeof config == "object" ? config : {}); 17118 config.url = (config["url"] || obForm.getAttribute("action")); 17119 17120 var additionalData = (config["data"] || {}); 17121 config.data = BX.ajax.prepareForm(obForm).data; 17122 for (var ii in additionalData) 17123 { 17124 if (additionalData.hasOwnProperty(ii)) 17125 { 17126 config.data[ii] = additionalData[ii]; 17127 } 17128 } 17129 17130 if (!window["FormData"]) 17131 { 17132 BX.ajax(config); 17133 } 17134 else 17135 { 17136 var isFile = function(item) 17137 { 17138 var res = Object.prototype.toString.call(item); 17139 return (res == '[object File]' || res == '[object Blob]'); 17140 }, 17141 appendToForm = function(fd, key, val) 17142 { 17143 if (!!val && typeof val == "object" && !isFile(val)) 17144 { 17145 for (var ii in val) 17146 { 17147 if (val.hasOwnProperty(ii)) 17148 { 17149 appendToForm(fd, (key == '' ? ii : key + '[' + ii + ']'), val[ii]); 17150 } 17151 } 17152 } 17153 else 17154 fd.append(key, (!!val ? val : '')); 17155 }, 17156 prepareData = function(arData) 17157 { 17158 var data = {}; 17159 if (null != arData) 17160 { 17161 if(typeof arData == 'object') 17162 { 17163 for(var i in arData) 17164 { 17165 if (arData.hasOwnProperty(i)) 17166 { 17167 var name = BX.util.urlencode(i); 17168 if(typeof arData[i] == 'object' && arData[i]["file"] !== true) 17169 data[name] = prepareData(arData[i]); 17170 else if (arData[i]["file"] === true) 17171 data[name] = arData[i]["value"]; 17172 else 17173 data[name] = BX.util.urlencode(arData[i]); 17174 } 17175 } 17176 } 17177 else 17178 data = BX.util.urlencode(arData); 17179 } 17180 return data; 17181 }, 17182 fd = new window.FormData(); 17183 17184 if (config.method !== 'POST') 17185 { 17186 config.data = BX.ajax.prepareData(config.data); 17187 if (config.data) 17188 { 17189 config.url += (config.url.indexOf('?') !== -1 ? "&" : "?") + config.data; 17190 config.data = ''; 17191 } 17192 } 17193 else 17194 { 17195 if (config.preparePost === true) 17196 config.data = prepareData(config.data); 17197 appendToForm(fd, '', config.data); 17198 config.data = fd; 17199 } 17200 17201 config.preparePost = false; 17202 config.start = false;
17203 17204 var xhr = BX.ajax(config); 17205 if (!!config["onprogress"]) 17206 xhr.upload.addEventListener( 17207 'progress', 17208 function(e){ 17209 var percent = null; 17210 if(e.lengthComputable && (e.total || e["totalSize"])) { 17211 percent = e.loaded * 100 / (e.total || e["totalSize"]); 17212 } 17213 config["onprogress"](e, percent); 17214 } 17215 ); 17216 xhr.send(fd); 17217 } 17218}; 17219 17220BX.ajax.UpdatePageData = function (arData) 17221{ 17222 if (arData.TITLE) 17223 BX.ajax.UpdatePageTitle(arData.TITLE); 17224 if (arData.WINDOW_TITLE || arData.TITLE) 17225 BX.ajax.UpdateWindowTitle(arData.WINDOW_TITLE || arData.TITLE); 17226 if (arData.NAV_CHAIN) 17227 BX.ajax.UpdatePageNavChain(arData.NAV_CHAIN); 17228 if (arData.CSS && arData.CSS.length > 0) 17229 BX.loadCSS(arData.CSS); 17230 if (arData.SCRIPTS && arData.SCRIPTS.length > 0) 17231 { 17232 var f = function(result,config,cb){ 17233 17234 if(!!config && BX.type.isArray(config.scripts)) 17235 { 17236 for(var i=0,l=arData.SCRIPTS.length;i<l;i++) 17237 { 17238 config.scripts.push({isInternal:false,JS:arData.SCRIPTS[i]}); 17239 } 17240 } 17241 else 17242 { 17243 BX.loadScript(arData.SCRIPTS,cb); 17244 } 17245 17246 BX.removeCustomEvent('onAjaxSuccess',f); 17247 }; 17248 BX.addCustomEvent('onAjaxSuccess',f); 17249 } 17250 else 17251 { 17252 var f1 = function(result,config,cb){ 17253 if(BX.type.isFunction(cb)) 17254 { 17255 cb(); 17256 } 17257 BX.removeCustomEvent('onAjaxSuccess',f1); 17258 }; 17259 BX.addCustomEvent('onAjaxSuccess', f1); 17260 } 17261}; 17262 17263BX.ajax.UpdatePageTitle = function(title) 17264{ 17265 var obTitle = BX('pagetitle'); 17266 if (obTitle) 17267 { 17268 BX.remove(obTitle.firstChild); 17269 if (!obTitle.firstChild) 17270 obTitle.appendChild(document.createTextNode(title)); 17271 else 17272 obTitle.insertBefore(document.createTextNode(title), obTitle.firstChild); 17273 } 17274}; 17275 17276BX.ajax.UpdateWindowTitle = function(title) 17277{ 17278 document.title = title; 17279}; 17280 17281BX.ajax.UpdatePageNavChain = function(nav_chain) 17282{ 17283 var obNavChain = BX('navigation'); 17284 if (obNavChain) 17285 { 17286 obNavChain.innerHTML = nav_chain; 17287 } 17288}; 17289 17290/* user options handling */ 17291BX.userOptions = { 17292 options: null, 17293 bSend: false, 17294 delay: 5000, 17295 path: '/bitrix/admin/user_options.php?' 17296}; 17297 17298BX.userOptions.setAjaxPath = function(url) 17299{ 17300 // eslint-disable-next-line no-console 17301 console.warn('BX.userOptions.setAjaxPath is deprecated. There is no way to change ajax path.'); 17302}; 17303BX.userOptions.save = function(category, name, valueName, value, common) 17304{ 17305 if (BX.userOptions.options === null) 17306 { 17307 BX.userOptions.options = {}; 17308 } 17309 17310 common = Boolean(common); 17311 BX.userOptions.options[`${category}.${name}.${valueName}`] = [category, name, valueName, value, common]; 17312 17313 const stringPackedValue = BX.userOptions.__get(); 17314 if (stringPackedValue) 17315 { 17316 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=/;`; 17317 } 17318 17319 if (!BX.userOptions.bSend) 17320 { 17321 BX.userOptions.bSend = true; 17322 setTimeout(() => { 17323 BX.userOptions.send(null); 17324 }, BX.userOptions.delay); 17325 } 17326}; 17327 17328BX.userOptions.send = function(callback) 17329{ 17330 const values = BX.userOptions.__get_values({ backwardCompatibility: true}); 17331 17332 BX.userOptions.options = null; 17333 BX.userOptions.bSend = false; 17334 17335 if (values) 17336 { 17337 document.cookie = `${BX.message('COOKIE_PREFIX')}_LAST_SETTINGS=; path=/;`; 17338 17339 BX.ajax.runAction( 17340 'main.userOption.saveOptions', 17341 { 17342 json: { 17343 newValues: values, 17344 }, 17345 }, 17346 ).then((response) => { 17347 if (BX.type.isFunction(callback)) 17348 { 17349 callback(response); 17350 } 17351 }); 17352 } 17353}; 17354 17355BX.userOptions.del = function(category, name, common, callback) 17356{ 17357 BX.ajax.runAction( 17358 'main.userOption.deleteOption', 17359 { 17360 json: { 17361 category, 17362 name, 17363 common, 17364 }, 17365 }, 17366 ).then((response) => { 17367 if (BX.type.isFunction(callback)) 17368 { 17369 callback(response); 17370 } 17371 }); 17372}; 17373 17374BX.userOptions.__get_values = function({ backwardCompatibility }) 17375{ 17376 if (!BX.userOptions || !BX.Type.isPlainObject(BX.userOptions.options)) 17377 { 17378 return null; 17379 } 17380 17381 const CATEGORY = 0; 17382 const NAME = 1; 17383 const VALUE_NAME = 2; 17384 const VALUE = 3; 17385 const IS_DEFAULT = 4; 17386 17387 const packedValues = { p: [] }; 17388 let currentIndex = -1; 17389 let previousOptionIdentifier = ''; 17390 17391 Object.entries(BX.userOptions.options).forEach(([key, userOption]) => { 17392 const category = userOption[CATEGORY]; 17393 const name = userOption[NAME]; 17394 const currentOptionIdentifier = `${category}.${name}`; 17395 17396 if (previousOptionIdentifier !== currentOptionIdentifier) 17397 { 17398 currentIndex++; 17399 packedValues.p.push({ 17400 c: category, 17401 n: name, 17402 v: {}, 17403 }); 17404 if (userOption[IS_DEFAULT] === true) 17405 { 17406 packedValues.p[currentIndex].d = 'Y'; 17407 } 17408 previousOptionIdentifier = currentOptionIdentifier; 17409 } 17410 17411 if (userOption[VALUE_NAME] === null) 17412 { 17413 packedValues.p[currentIndex].v = userOption[VALUE]; 17414 } 17415 else 17416 { 17417 let data = userOption[VALUE]; 17418 if (backwardCompatibility && Array.isArray(userOption[VALUE])) 17419 { 17420 data = userOption[VALUE].join(','); 17421 } 17422 packedValues.p[currentIndex].v[userOption[VALUE_NAME]] = data; 17423 } 17424 }); 17425 17426 return packedValues.p.length > 0 ? packedValues.p : null; 17427}; 17428 17429/** 17430 * @deprecated Use instead BX.userOptions.__get_values. 17431 * */ 17432BX.userOptions.__get = function() 17433{ 17434 if (!BX.userOptions.options) return ''; 17435 17436 var sParam = '', n = -1, prevParam = '', aOpt, i; 17437 17438 for (i in BX.userOptions.options) 17439 { 17440 if(BX.userOptions.options.hasOwnProperty(i)) 17441 { 17442 aOpt = BX.userOptions.options[i]; 17443 17444 if (prevParam != aOpt[0]+'.'+aOpt[1]) 17445 { 17446 n++; 17447 sParam += '&p['+n+'][c]='+BX.util.urlencode(aOpt[0]); 17448 sParam += '&p['+n+'][n]='+BX.util.urlencode(aOpt[1]); 17449 if (aOpt[4] == true) 17450 sParam += '&p['+n+'][d]=Y'; 17451 prevParam = aOpt[0]+'.'+aOpt[1]; 17452 } 17453 17454 var valueName = aOpt[2]; 17455 var value = aOpt[3]; 17456 17457 if (valueName === null) 17458 { 17459 sParam += '&p['+n+'][v]='+BX.util.urlencode(value); 17460 } 17461 else 17462 {
17463 sParam += '&p['+n+'][v]['+BX.util.urlencode(valueName)+']='+BX.util.urlencode(value); 17464 } 17465 } 17466 } 17467 17468 return sParam.substr(1); 17469}; 17470 17471BX.ajax.history = { 17472 expected_hash: '', 17473 17474 obParams: null, 17475 17476 obFrame: null, 17477 obImage: null, 17478 17479 obTimer: null, 17480 17481 bInited: false, 17482 bHashCollision: false, 17483 bPushState: !!(history.pushState && BX.type.isFunction(history.pushState)), 17484 17485 startState: null, 17486 17487 init: function(obParams) 17488 { 17489 if (BX.ajax.history.bInited) 17490 return; 17491 17492 this.obParams = obParams; 17493 var obCurrentState = this.obParams.getState(); 17494 17495 if (BX.ajax.history.bPushState) 17496 { 17497 BX.ajax.history.expected_hash = window.location.pathname; 17498 if (window.location.search) 17499 BX.ajax.history.expected_hash += window.location.search; 17500 17501 BX.ajax.history.put(obCurrentState, BX.ajax.history.expected_hash, '', true); 17502 // due to some strange thing, chrome calls popstate event on page start. so we should delay it 17503 setTimeout(function(){BX.bind(window, 'popstate', BX.ajax.history.__hashListener);}, 500); 17504 } 17505 else 17506 { 17507 BX.ajax.history.expected_hash = window.location.hash; 17508 17509 if (!BX.ajax.history.expected_hash || BX.ajax.history.expected_hash == '#') 17510 BX.ajax.history.expected_hash = '__bx_no_hash__'; 17511 17512 jsAjaxHistoryContainer.put(BX.ajax.history.expected_hash, obCurrentState); 17513 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 17514 17515 if (BX.browser.IsIE()) 17516 { 17517 BX.ajax.history.obFrame = document.createElement('IFRAME'); 17518 BX.hide_object(BX.ajax.history.obFrame); 17519 17520 document.body.appendChild(BX.ajax.history.obFrame); 17521 17522 BX.ajax.history.obFrame.contentWindow.document.open(); 17523 BX.ajax.history.obFrame.contentWindow.document.write(BX.ajax.history.expected_hash); 17524 BX.ajax.history.obFrame.contentWindow.document.close(); 17525 } 17526 else if (BX.browser.IsOpera()) 17527 { 17528 BX.ajax.history.obImage = document.createElement('IMG'); 17529 BX.hide_object(BX.ajax.history.obImage); 17530 17531 document.body.appendChild(BX.ajax.history.obImage); 17532 17533 BX.ajax.history.obImage.setAttribute('src', 'javascript:location.href = \'javascript:BX.ajax.history.__hashListener();\';'); 17534 } 17535 } 17536 17537 BX.ajax.history.bInited = true; 17538 }, 17539 17540 __hashListener: function(e) 17541 { 17542 e = e || window.event || {state:false}; 17543 17544 if (BX.ajax.history.bPushState) 17545 { 17546 BX.ajax.history.obParams.setState(e.state||BX.ajax.history.startState); 17547 } 17548 else 17549 { 17550 if (BX.ajax.history.obTimer) 17551 { 17552 window.clearTimeout(BX.ajax.history.obTimer); 17553 BX.ajax.history.obTimer = null; 17554 } 17555 17556 var current_hash; 17557 if (null != BX.ajax.history.obFrame) 17558 current_hash = BX.ajax.history.obFrame.contentWindow.document.body.innerText; 17559 else 17560 current_hash = window.location.hash; 17561 17562 if (!current_hash || current_hash == '#') 17563 current_hash = '__bx_no_hash__'; 17564 17565 if (current_hash.indexOf('#') == 0) 17566 current_hash = current_hash.substring(1); 17567 17568 if (current_hash != BX.ajax.history.expected_hash) 17569 { 17570 var state = jsAjaxHistoryContainer.get(current_hash); 17571 if (state) 17572 { 17573 BX.ajax.history.obParams.setState(state); 17574 17575 BX.ajax.history.expected_hash = current_hash; 17576 if (null != BX.ajax.history.obFrame) 17577 { 17578 var __hash = current_hash == '__bx_no_hash__' ? '' : current_hash; 17579 if (window.location.hash != __hash && window.location.hash != '#' + __hash) 17580 window.location.hash = __hash; 17581 } 17582 } 17583 } 17584 17585 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 17586 } 17587 }, 17588 17589 put: function(state, new_hash, new_hash1, bStartState) 17590 { 17591 if (this.bPushState) 17592 { 17593 if(!bStartState) 17594 { 17595 history.pushState(state, '', new_hash); 17596 } 17597 else 17598 { 17599 BX.ajax.history.startState = state; 17600 } 17601 } 17602 else 17603 { 17604 if (typeof new_hash1 != 'undefined') 17605 new_hash = new_hash1; 17606 else 17607 new_hash = 'view' + new_hash; 17608 17609 jsAjaxHistoryContainer.put(new_hash, state); 17610 BX.ajax.history.expected_hash = new_hash; 17611 17612 window.location.hash = BX.util.urlencode(new_hash); 17613 17614 if (null != BX.ajax.history.obFrame) 17615 { 17616 BX.ajax.history.obFrame.contentWindow.document.open(); 17617 BX.ajax.history.obFrame.contentWindow.document.write(new_hash); 17618 BX.ajax.history.obFrame.contentWindow.document.close(); 17619 } 17620 } 17621 }, 17622 17623 checkRedirectStart: function(param_name, param_value) 17624 { 17625 var current_hash = window.location.hash; 17626 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 17627 17628 var test = current_hash.substring(0, 5); 17629 if (test == 'view/' || test == 'view%') 17630 { 17631 BX.ajax.history.bHashCollision = true;
17632 document.write('<' + 'div id="__ajax_hash_collision_' + param_value + '" style="display: none;">'); 17633 } 17634 }, 17635 17636 checkRedirectFinish: function(param_name, param_value) 17637 { 17638 document.write('</div>'); 17639 17640 var current_hash = window.location.hash; 17641 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 17642 17643 BX.ready(function () 17644 { 17645 var test = current_hash.substring(0, 5); 17646 if (test == 'view/' || test == 'view%') 17647 { 17648 var obColNode = BX('__ajax_hash_collision_' + param_value); 17649 var obNode = obColNode.firstChild; 17650 BX.cleanNode(obNode); 17651 obColNode.style.display = 'block'; 17652 17653 // IE, Opera and Chrome automatically modifies hash with urlencode, but FF doesn't ;-( 17654 if (test != 'view%') 17655 current_hash = BX.util.urlencode(current_hash); 17656 17657 current_hash += (current_hash.indexOf('%3F') == -1 ? '%3F' : '%26') + param_name + '=' + param_value; 17658 17659 var url = '/bitrix/tools/ajax_redirector.php?hash=' + current_hash; 17660 17661 BX.ajax.insertToNode(url, obNode); 17662 } 17663 }); 17664 } 17665}; 17666 17667BX.ajax.component = function(node) 17668{ 17669 this.node = node; 17670}; 17671 17672BX.ajax.component.prototype.getState = function() 17673{ 17674 var state = { 17675 'node': this.node, 17676 'title': window.document.title, 17677 'data': BX(this.node).innerHTML 17678 }; 17679 17680 var obNavChain = BX('navigation'); 17681 if (null != obNavChain) 17682 state.nav_chain = obNavChain.innerHTML; 17683 17684 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistoryGetState", [state]); 17685 17686 return state; 17687}; 17688 17689BX.ajax.component.prototype.setState = function(state) 17690{ 17691 BX(state.node).innerHTML = state.data; 17692 BX.ajax.UpdatePageTitle(state.title); 17693 17694 if (state.nav_chain) 17695 { 17696 BX.ajax.UpdatePageNavChain(state.nav_chain); 17697 } 17698 17699 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistorySetState", [state]); 17700}; 17701 17702var jsAjaxHistoryContainer = { 17703 arHistory: {}, 17704 17705 put: function(hash, state) 17706 { 17707 this.arHistory[hash] = state; 17708 }, 17709 17710 get: function(hash) 17711 { 17712 return this.arHistory[hash]; 17713 } 17714}; 17715 17716 17717BX.ajax.FormData = function() 17718{ 17719 this.elements = []; 17720 this.files = []; 17721 this.features = {}; 17722 this.isSupported(); 17723 this.log('BX FormData init'); 17724}; 17725 17726BX.ajax.FormData.isSupported = function() 17727{ 17728 var f = new BX.ajax.FormData(); 17729 var result = f.features.supported; 17730 f = null; 17731 return result; 17732}; 17733 17734BX.ajax.FormData.prototype.log = function(o) 17735{ 17736 if (false) { 17737 try { 17738 if (BX.browser.IsIE()) o = JSON.stringify(o); 17739 console.log(o); 17740 } catch(e) {} 17741 } 17742}; 17743 17744BX.ajax.FormData.prototype.isSupported = function() 17745{ 17746 var f = {}; 17747 f.fileReader = (window.FileReader && window.FileReader.prototype.readAsBinaryString); 17748 f.readFormData = f.sendFormData = !!(window.FormData); 17749 f.supported = !!(f.readFormData && f.sendFormData); 17750 this.features = f; 17751 this.log('features:'); 17752 this.log(f); 17753 17754 return f.supported; 17755}; 17756 17757BX.ajax.FormData.prototype.append = function(name, value) 17758{ 17759 if (typeof(value) === 'object') { // seems to be files element 17760 this.files.push({'name': name, 'value':value}); 17761 } else { 17762 this.elements.push({'name': name, 'value':value}); 17763 } 17764}; 17765 17766BX.ajax.FormData.prototype.send = function(url, callbackOk, callbackProgress, callbackError) 17767{ 17768 this.log('FD send'); 17769 this.xhr = BX.ajax({ 17770 'method': 'POST', 17771 'dataType': 'html', 17772 'url': url, 17773 'onsuccess': callbackOk, 17774 'onfailure': callbackError, 17775 'start': false, 17776 'preparePost':false 17777 }); 17778 17779 if (callbackProgress) 17780 { 17781 this.xhr.upload.addEventListener( 17782 'progress', 17783 function(e) { 17784 if (e.lengthComputable) 17785 callbackProgress(e.loaded / (e.total || e.totalSize)); 17786 }, 17787 false 17788 ); 17789 } 17790 17791 if (this.features.readFormData && this.features.sendFormData) 17792 { 17793 var fd = new FormData(); 17794 this.log('use browser formdata'); 17795 for (var i in this.elements) 17796 { 17797 if(this.elements.hasOwnProperty(i)) 17798 fd.append(this.elements[i].name,this.elements[i].value); 17799 } 17800 for (i in this.files) 17801 { 17802 if(this.files.hasOwnProperty(i)) 17803 fd.append(this.files[i].name, this.files[i].value); 17804 } 17805 this.xhr.send(fd); 17806 } 17807 17808 return this.xhr; 17809}; 17810 17811BX.addCustomEvent('onAjaxFailure', BX.debug); 17812})(window); 17813 17814 17815(function (exports,main_core) { 17816 'use strict'; 17817 17818 var LazyLoad = { 17819 observer: null, 17820 images: {}, 17821 imageStatus: { 17822 hidden: -2, 17823 error: -1, 17824 "undefined": 0, 17825 inited: 1, 17826 loaded: 2 17827 }, 17828 imageTypes: { 17829 image: 1, 17830 background: 2 17831 },
17832 initObserver: function initObserver() { 17833 this.observer = new IntersectionObserver(this.onIntersection.bind(this), { 17834 rootMargin: '20% 0% 20% 0%', 17835 threshold: 0.10 17836 }); 17837 }, 17838 onIntersection: function onIntersection(entries) { 17839 entries.forEach(function (entry) { 17840 if (entry.isIntersecting) { 17841 this.showImage(entry.target); 17842 } 17843 }.bind(this)); 17844 }, 17845 registerImage: function registerImage(id, isImageVisibleCallback, options) { 17846 if (this.observer === null) { 17847 this.initObserver(); 17848 } 17849 17850 options = options || {}; 17851 17852 if (!main_core.Type.isStringFilled(id)) { 17853 return; 17854 } 17855 17856 if (main_core.Type.isObject(this.images[id])) { 17857 return; 17858 } 17859 17860 var element = document.getElementById(id); 17861 17862 if (!main_core.Type.isDomNode(element)) { 17863 return; 17864 } 17865 17866 this.observer.observe(element); 17867 this.images[id] = { 17868 id: id, 17869 node: null, 17870 src: null, 17871 dataSrcName: options.dataSrcName || 'src', 17872 type: null, 17873 func: main_core.Type.isFunction(isImageVisibleCallback) ? isImageVisibleCallback : null, 17874 status: this.imageStatus.undefined 17875 }; 17876 }, 17877 registerImages: function registerImages(ids, isImageVisibleCallback, options) { 17878 if (main_core.Type.isArray(ids)) { 17879 for (var i = 0, length = ids.length; i < length; i++) { 17880 this.registerImage(ids[i], isImageVisibleCallback, options); 17881 } 17882 } 17883 }, 17884 showImage: function showImage(imageNode) { 17885 var imageNodeId = imageNode.id; 17886 17887 if (!main_core.Type.isStringFilled(imageNodeId)) { 17888 return; 17889 } 17890 17891 var image = this.images[imageNodeId]; 17892 17893 if (!main_core.Type.isPlainObject(image)) { 17894 return; 17895 } 17896 17897 if (image.status == this.imageStatus.undefined) { 17898 this.initImage(image); 17899 } 17900 17901 if (image.status !== this.imageStatus.inited) { 17902 return; 17903 } 17904 17905 if (!image.node || !image.node.parentNode) { 17906 image.node = null; 17907 image.status = this.imageStatus.error; 17908 return; 17909 } 17910 17911 if (image.type == this.imageTypes.image) { 17912 image.node.src = image.src; 17913 } else { 17914 image.node.style.backgroundImage = "url('" + image.src + "')"; 17915 } 17916 17917 image.node.dataset[image.dataSrcName] = ""; 17918 image.status = this.imageStatus.loaded; 17919 }, 17920 showImages: function showImages(checkOwnVisibility) { 17921 checkOwnVisibility = checkOwnVisibility !== false; 17922 17923 for (var id in this.images) { 17924 if (!this.images.hasOwnProperty(id)) { 17925 continue; 17926 } 17927 17928 var image = this.images[id]; 17929 17930 if (image.status == this.imageStatus.undefined) { 17931 this.initImage(image); 17932 } 17933 17934 if (image.status !== this.imageStatus.inited) { 17935 continue; 17936 } 17937 17938 if (!image.node || !image.node.parentNode) { 17939 image.node = null; 17940 image.status = this.imageStatus.error; 17941 continue; 17942 } 17943 17944 var isImageVisible = true; 17945 17946 if (checkOwnVisibility && main_core.Type.isFunction(image.func)) { 17947 isImageVisible = image.func(image); 17948 } 17949 17950 if (isImageVisible === true && this.isElementVisibleOnScreen(image.node)) { 17951 if (image.type == this.imageTypes.image) { 17952 image.node.src = image.src; 17953 } else { 17954 image.node.style.backgroundImage = "url('" + image.src + "')"; 17955 } 17956 17957 image.node.dataset[image.dataSrcName] = ""; 17958 image.status = this.imageStatus.loaded; 17959 } 17960 } 17961 }, 17962 initImage: function initImage(image) { 17963 image.status = this.imageStatus.error; 17964 var node = document.getElementById(image.id); 17965 17966 if (!main_core.Type.isDomNode(node)) { 17967 return; 17968 } 17969 17970 var src = node.dataset[image.dataSrcName]; 17971 17972 if (main_core.Type.isStringFilled(src)) { 17973 image.node = node; 17974 image.src = src; 17975 image.status = this.imageStatus.inited; 17976 image.type = image.node.tagName.toLowerCase() == "img" ? this.imageTypes.image : this.imageTypes.background; 17977 } 17978 }, 17979 isElementVisibleOnScreen: function isElementVisibleOnScreen(element) { 17980 var coords = this.getElementCoords(element); 17981 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 17982 var windowBottom = windowTop + document.documentElement.clientHeight; 17983 coords.bottom = coords.top + element.offsetHeight; 17984 return coords.top > windowTop && coords.top < windowBottom || // topVisible 17985 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 17986 ; 17987 }, 17988 isElementVisibleOn2Screens: function isElementVisibleOn2Screens(element) { 17989 var windowHeight = document.documentElement.clientHeight; 17990 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 17991 var windowBottom = windowTop + windowHeight; 17992 var coords = this.getElementCoords(element); 17993 coords.bottom = coords.top + element.offsetHeight; 17994 windowTop -= windowHeight; 17995 windowBottom += windowHeight; 17996 return coords.top > windowTop && coords.top < windowBottom || // topVisible 17997 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 17998 ; 17999 }, 18000 getElementCoords: function getElementCoords(element) { 18001 var box = element.getBoundingClientRect(); 18002 return { 18003 originTop: box.top, 18004 originLeft: box.left, 18005 top: box.top + window.pageYOffset, 18006 left: box.left + window.pageXOffset 18007 }; 18008 }, 18009 onScroll: function onScroll() {}, 18010 clearImages: function clearImages() { 18011 this.images = []; 18012 } 18013 }; 18014 18015 exports.LazyLoad = LazyLoad; 18016 18017}((this.BX = this.BX || {}),BX)); 18018 18019 18020 18021(function (exports) { 18022 'use strict'; 18023 18024 var ParamBag = /*#__PURE__*/function () { 18025 function ParamBag() { 18026 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 18027 babelHelpers.classCallCheck(this, ParamBag); 18028 18029 if (!!params && babelHelpers.typeof(params) === 'object') { 18030 this.params = new Map(Object.entries(params)); 18031 } else { 18032 this.params = new Map(); 18033 } 18034 } 18035 18036 babelHelpers.createClass(ParamBag, [{ 18037 key: "getParam", 18038 value: function getParam(key) { 18039 var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 18040 18041 if (this.params.has(key)) { 18042 return this.params.get(key); 18043 } 18044 18045 return defaultValue; 18046 } 18047 }, { 18048 key: "setParam", 18049 value: function setParam(key, value) { 18050 this.params.set(key, value); 18051 } 18052 }, { 18053 key: "clear", 18054 value: function clear() { 18055 this.params.clear(); 18056 } 18057 }], [{ 18058 key: "create", 18059 value: function create() { 18060 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 18061 return new ParamBag(params); 18062 } 18063 }]); 18064 return ParamBag; 18065 }(); 18066 18067 exports.ParamBag = ParamBag; 18068 18069}((this.BX = this.BX || {}))); 18070 18071 18072 18073(function() { 18074 BX.FixFontSize = function(params) 18075 { 18076 var widthNode, computedStyles, width; 18077 18078 this.node = null; 18079 this.prevWindowSize = 0; 18080 this.prevWrapperSize = 0; 18081 this.mainWrapper = null; 18082 this.textWrapper = null; 18083 this.objList = params.objList; 18084 this.minFontSizeList = []; 18085 this.minFontSize = 0; 18086 18087 if (params.onresize) 18088 { 18089 this.prevWindowSize = window.innerWidth || document.documentElement.clientWidth; 18090 BX.bind(window, 'resize', BX.throttle(this.onResize, 350, this)); 18091 } 18092 18093 if (params.onAdaptiveResize) 18094 { 18095 widthNode = this.objList[0].scaleBy || this.objList[0].node; 18096 computedStyles = getComputedStyle(widthNode); 18097 this.prevWrapperSize = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18098 BX.bind(window, 'resize', BX.throttle(this.onAdaptiveResize, 350, this)); 18099 } 18100 18101 this.createTestNodes(); 18102 this.decrease(); 18103 }; 18104 18105 BX.FixFontSize.prototype = 18106 { 18107 createTestNodes: function() 18108 { 18109 this.textWrapper = BX.create('div',{ 18110 style : { 18111 display : 'inline-block', 18112 whiteSpace : 'nowrap' 18113 } 18114 }); 18115 18116 this.mainWrapper = BX.create('div',{ 18117 style : { 18118 height : 0, 18119 overflow : 'hidden' 18120 }, 18121 children : [this.textWrapper] 18122 }); 18123 18124 }, 18125 insertTestNodes: function() 18126 { 18127 document.body.appendChild(this.mainWrapper); 18128 }, 18129 removeTestNodes: function() 18130 { 18131 document.body.removeChild(this.mainWrapper); 18132 }, 18133 decrease: function() 18134 { 18135 var width, 18136 fontSize, 18137 widthNode, 18138 computedStyles; 18139 18140 this.insertTestNodes(); 18141
18142 for(var i=this.objList.length-1; i>=0; i--) 18143 { 18144 widthNode = this.objList[i].scaleBy || this.objList[i].node; 18145 computedStyles = getComputedStyle(widthNode); 18146 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18147 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 18148 18149 this.textWrapperSetStyle(this.objList[i].node); 18150 18151 if(this.textWrapperInsertText(this.objList[i].node)) 18152 { 18153 while(this.textWrapper.offsetWidth > width && fontSize > 0) 18154 { 18155 this.textWrapper.style.fontSize = --fontSize + 'px'; 18156 } 18157 18158 if(this.objList[i].smallestValue) 18159 { 18160 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 18161 18162 this.minFontSizeList.push(this.objList[i].node) 18163 } 18164 else 18165 { 18166 this.objList[i].node.style.fontSize = fontSize + 'px'; 18167 } 18168 } 18169 } 18170 18171 if(this.minFontSizeList.length > 0) 18172 this.setMinFont(); 18173 18174 this.removeTestNodes(); 18175 18176 }, 18177 increase: function() 18178 { 18179 this.insertTestNodes(); 18180 var width, 18181 fontSize, 18182 widthNode, 18183 computedStyles; 18184 18185 this.insertTestNodes(); 18186 18187 for(var i=this.objList.length-1; i>=0; i--) 18188 { 18189 widthNode = this.objList[i].scaleBy || this.objList[i].node; 18190 computedStyles = getComputedStyle(widthNode); 18191 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18192 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 18193 18194 this.textWrapperSetStyle(this.objList[i].node); 18195 18196 if(this.textWrapperInsertText(this.objList[i].node)) 18197 { 18198 while(this.textWrapper.offsetWidth < width && fontSize < this.objList[i].maxFontSize) 18199 { 18200 this.textWrapper.style.fontSize = ++fontSize + 'px'; 18201 } 18202 18203 fontSize--; 18204 18205 if(this.objList[i].smallestValue) 18206 { 18207 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 18208 18209 this.minFontSizeList.push(this.objList[i].node) 18210 } 18211 else 18212 { 18213 this.objList[i].node.style.fontSize = fontSize + 'px'; 18214 } 18215 } 18216 } 18217 18218 if(this.minFontSizeList.length > 0) 18219 this.setMinFont(); 18220 18221 this.removeTestNodes(); 18222 }, 18223 setMinFont : function() 18224 { 18225 for(var i = this.minFontSizeList.length-1; i>=0; i--) 18226 { 18227 this.minFontSizeList[i].style.fontSize = this.minFontSize + 'px'; 18228 } 18229 18230 this.minFontSize = 0; 18231 }, 18232 onResize : function() 18233 { 18234 var width = window.innerWidth || document.documentElement.clientWidth; 18235 18236 if(this.prevWindowSize > width) 18237 this.decrease(); 18238 18239 else if (this.prevWindowSize < width) 18240 this.increase(); 18241 18242 this.prevWindowSize = width; 18243 }, 18244 onAdaptiveResize : function() 18245 { 18246 var widthNode = this.objList[0].scaleBy || this.objList[0].node, 18247 computedStyles = getComputedStyle(widthNode), 18248 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18249 18250 if (this.prevWrapperSize > width) 18251 this.decrease(); 18252 else if (this.prevWrapperSize < width) 18253 this.increase(); 18254 18255 this.prevWrapperSize = width; 18256 }, 18257 textWrapperInsertText : function(node) 18258 { 18259 if(node.textContent){ 18260 this.textWrapper.textContent = node.textContent; 18261 return true; 18262 } 18263 else if(node.innerText) 18264 { 18265 this.textWrapper.innerText = node.innerText; 18266 return true; 18267 } 18268 else { 18269 return false; 18270 } 18271 }, 18272 textWrapperSetStyle : function(node) 18273 { 18274 this.textWrapper.style.fontFamily = getComputedStyle(node)["font-family"]; 18275 this.textWrapper.style.fontSize = getComputedStyle(node)["font-size"]; 18276 this.textWrapper.style.fontStyle = getComputedStyle(node)["font-style"]; 18277 this.textWrapper.style.fontWeight = getComputedStyle(node)["font-weight"]; 18278 this.textWrapper.style.lineHeight = getComputedStyle(node)["line-height"]; 18279 } 18280 }; 18281 18282 BX.FixFontSize.init = function(params) 18283 { 18284 return new BX.FixFontSize(params); 18285 }; 18286})(); 18287 18288})(); 18289//# 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.