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 }; 1749 1750 // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 1751 var globalThis_1 = 1752 // eslint-disable-next-line es/no-global-this -- safe 1753 check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || 1754 // eslint-disable-next-line no-restricted-globals -- safe 1755 check(typeof self == 'object' && self) || check(typeof commonjsGlobal == 'object' && commonjsGlobal) || check(typeof commonjsGlobal == 'object' && commonjsGlobal) || 1756 // eslint-disable-next-line no-new-func -- fallback 1757 function () { 1758 return this; 1759 }() || Function('return this')(); 1760 1761 var fails = function (exec) { 1762 try { 1763 return !!exec(); 1764 } catch (error) { 1765 return true; 1766 } 1767 }; 1768 1769 // Detect IE8's incomplete defineProperty implementation 1770 var descriptors = !fails(function () { 1771 // eslint-disable-next-line es/no-object-defineproperty -- required for testing 1772 return Object.defineProperty({}, 1, { 1773 get: function () { 1774 return 7; 1775 } 1776 })[1] !== 7; 1777 }); 1778 1779 var functionBindNative = !fails(function () { 1780 // eslint-disable-next-line es/no-function-prototype-bind -- safe 1781 var test = function () {/* empty */}.bind(); 1782 // eslint-disable-next-line no-prototype-builtins -- safe 1783 return typeof test != 'function' || test.hasOwnProperty('prototype'); 1784 }); 1785 1786 var call = Function.prototype.call; 1787 // eslint-disable-next-line es/no-function-prototype-bind -- safe 1788 var functionCall = functionBindNative ? call.bind(call) : function () { 1789 return call.apply(call, arguments); 1790 }; 1791 1792 var $propertyIsEnumerable = {}.propertyIsEnumerable; 1793 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 1794 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; 1795 1796 // Nashorn ~ JDK8 bug 1797 var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1798 1: 2 1799 }, 1); 1800 1801 // `Object.prototype.propertyIsEnumerable` method implementation 1802 // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable 1803 var f = NASHORN_BUG ? function propertyIsEnumerable(V) { 1804 var descriptor = getOwnPropertyDescriptor(this, V); 1805 return !!descriptor && descriptor.enumerable; 1806 } : $propertyIsEnumerable; 1807 1808 var objectPropertyIsEnumerable = { 1809 f: f 1810 }; 1811 1812 var createPropertyDescriptor = function (bitmap, value) { 1813 return { 1814 enumerable: !(bitmap & 1), 1815 configurable: !(bitmap & 2), 1816 writable: !(bitmap & 4), 1817 value: value 1818 }; 1819 }; 1820 1821 var FunctionPrototype = Function.prototype; 1822 var call$1 = FunctionPrototype.call; 1823 // eslint-disable-next-line es/no-function-prototype-bind -- safe 1824 var uncurryThisWithBind = functionBindNative && FunctionPrototype.bind.bind(call$1, call$1); 1825 var functionUncurryThis = functionBindNative ? uncurryThisWithBind : function (fn) { 1826 return function () { 1827 return call$1.apply(fn, arguments); 1828 }; 1829 }; 1830 1831 var toString = functionUncurryThis({}.toString); 1832 var stringSlice = functionUncurryThis(''.slice); 1833 var classofRaw = function (it) { 1834 return stringSlice(toString(it), 8, -1); 1835 }; 1836 1837 var $Object = Object; 1838 var split = functionUncurryThis(''.split); 1839 1840 // fallback for non-array-like ES3 and non-enumerable old V8 strings 1841 var indexedObject = fails(function () { 1842 // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346 1843 // eslint-disable-next-line no-prototype-builtins -- safe 1844 return !$Object('z').propertyIsEnumerable(0); 1845 }) ? function (it) { 1846 return classofRaw(it) === 'String' ? split(it, '') : $Object(it); 1847 } : $Object; 1848 1849 // we can't use just `it == null` since of `document.all` special case
vendor: 58,422 bytes, lines 1850-3460
1850 // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec 1851 var isNullOrUndefined = function (it) { 1852 return it === null || it === undefined; 1853 }; 1854 1855 var $TypeError = TypeError; 1856 1857 // `RequireObjectCoercible` abstract operation 1858 // https://tc39.es/ecma262/#sec-requireobjectcoercible 1859 var requireObjectCoercible = function (it) { 1860 if (isNullOrUndefined(it)) throw new $TypeError("Can't call method on " + it); 1861 return it; 1862 }; 1863 1864 // toObject with fallback for non-array-like ES3 strings 1865 1866 1867 var toIndexedObject = function (it) { 1868 return indexedObject(requireObjectCoercible(it)); 1869 }; 1870 1871 // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot 1872 var documentAll = typeof document == 'object' && document.all; 1873 1874 // `IsCallable` abstract operation 1875 // https://tc39.es/ecma262/#sec-iscallable 1876 // eslint-disable-next-line unicorn/no-typeof-undefined -- required for testing 1877 var isCallable = typeof documentAll == 'undefined' && documentAll !== undefined ? function (argument) { 1878 return typeof argument == 'function' || argument === documentAll; 1879 } : function (argument) { 1880 return typeof argument == 'function'; 1881 }; 1882 1883 var isObject = function (it) { 1884 return typeof it == 'object' ? it !== null : isCallable(it); 1885 }; 1886 1887 var aFunction = function (argument) { 1888 return isCallable(argument) ? argument : undefined; 1889 }; 1890 var getBuiltIn = function (namespace, method) { 1891 return arguments.length < 2 ? aFunction(globalThis_1[namespace]) : globalThis_1[namespace] && globalThis_1[namespace][method]; 1892 }; 1893 1894 var objectIsPrototypeOf = functionUncurryThis({}.isPrototypeOf); 1895 1896 var navigator = globalThis_1.navigator; 1897 var userAgent = navigator && navigator.userAgent; 1898 var environmentUserAgent = userAgent ? String(userAgent) : ''; 1899 1900 var process = globalThis_1.process; 1901 var Deno$1 = globalThis_1.Deno; 1902 var versions = process && process.versions || Deno$1 && Deno$1.version; 1903 var v8 = versions && versions.v8; 1904 var match, version; 1905 if (v8) { 1906 match = v8.split('.'); 1907 // in old Chrome, versions of V8 isn't V8 = Chrome / 10 1908 // but their correct versions are not interesting for us 1909 version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]); 1910 } 1911 1912 // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0` 1913 // so check `userAgent` even if `.v8` exists, but 0 1914 if (!version && environmentUserAgent) { 1915 match = environmentUserAgent.match(/Edge\/(\d+)/); 1916 if (!match || match[1] >= 74) { 1917 match = environmentUserAgent.match(/Chrome\/(\d+)/); 1918 if (match) version = +match[1]; 1919 } 1920 } 1921 var environmentV8Version = version; 1922 1923 /* eslint-disable es/no-symbol -- required for testing */ 1924 1925 1926 1927 var $String = globalThis_1.String; 1928 1929 // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing 1930 var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails(function () { 1931 var symbol = Symbol('symbol detection'); 1932 // Chrome 38 Symbol has incorrect toString conversion 1933 // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances 1934 // nb: Do not call `String` directly to avoid this being optimized out to `symbol+''` which will, 1935 // of course, fail. 1936 return !$String(symbol) || !(Object(symbol) instanceof Symbol) || 1937 // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances 1938 !Symbol.sham && environmentV8Version && environmentV8Version < 41; 1939 }); 1940 1941 /* eslint-disable es/no-symbol -- required for testing */ 1942 1943 var useSymbolAsUid = symbolConstructorDetection && !Symbol.sham && typeof Symbol.iterator == 'symbol'; 1944 1945 var $Object$1 = Object; 1946 var isSymbol = useSymbolAsUid ? function (it) { 1947 return typeof it == 'symbol'; 1948 } : function (it) { 1949 var $Symbol = getBuiltIn('Symbol'); 1950 return isCallable($Symbol) && objectIsPrototypeOf($Symbol.prototype, $Object$1(it)); 1951 }; 1952 1953 var $String$1 = String; 1954 var tryToString = function (argument) { 1955 try { 1956 return $String$1(argument); 1957 } catch (error) { 1958 return 'Object'; 1959 } 1960 }; 1961 1962 var $TypeError$1 = TypeError; 1963 1964 // `Assert: IsCallable(argument) is true` 1965 var aCallable = function (argument) { 1966 if (isCallable(argument)) return argument; 1967 throw new $TypeError$1(tryToString(argument) + ' is not a function'); 1968 }; 1969 1970 // `GetMethod` abstract operation 1971 // https://tc39.es/ecma262/#sec-getmethod 1972 var getMethod = function (V, P) { 1973 var func = V[P]; 1974 return isNullOrUndefined(func) ? undefined : aCallable(func); 1975 }; 1976 1977 var $TypeError$2 = TypeError; 1978 1979 // `OrdinaryToPrimitive` abstract operation 1980 // https://tc39.es/ecma262/#sec-ordinarytoprimitive 1981 var ordinaryToPrimitive = function (input, pref) { 1982 var fn, val; 1983 if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val; 1984 if (isCallable(fn = input.valueOf) && !isObject(val = functionCall(fn, input))) return val; 1985 if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val; 1986 throw new $TypeError$2("Can't convert object to primitive value"); 1987 }; 1988 1989 var isPure = false; 1990 1991 // eslint-disable-next-line es/no-object-defineproperty -- safe 1992 var defineProperty = Object.defineProperty; 1993 var defineGlobalProperty = function (key, value) { 1994 try { 1995 defineProperty(globalThis_1, key, { 1996 value: value, 1997 configurable: true, 1998 writable: true 1999 }); 2000 } catch (error) { 2001 globalThis_1[key] = value; 2002 } 2003 return value; 2004 }; 2005 2006 var sharedStore = createCommonjsModule(function (module) { 2007 2008 2009 2010 2011 var SHARED = '__core-js_shared__'; 2012 var store = module.exports = globalThis_1[SHARED] || defineGlobalProperty(SHARED, {}); 2013 (store.versions || (store.versions = [])).push({ 2014 version: '3.41.0', 2015 mode: 'global', 2016 copyright: '© 2014-2025 Denis Pushkarev (zloirock.ru)', 2017 license: 'https://github.com/zloirock/core-js/blob/v3.41.0/LICENSE', 2018 source: 'https://github.com/zloirock/core-js' 2019 }); 2020 }); 2021 2022 var shared = createCommonjsModule(function (module) { 2023 (module.exports = function (key, value) { 2024 return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {}); 2025 })('versions', []).push({ 2026 version: '3.19.2', 2027 mode: 'global', 2028 copyright: '(c) 2021 Denis Pushkarev (zloirock.ru)' 2029 }); 2030 }); 2031 2032 var $Object$2 = Object; 2033 2034 // `ToObject` abstract operation 2035 // https://tc39.es/ecma262/#sec-toobject 2036 var toObject = function (argument) { 2037 return $Object$2(requireObjectCoercible(argument)); 2038 }; 2039 2040 var hasOwnProperty = functionUncurryThis({}.hasOwnProperty); 2041 2042 // `HasOwnProperty` abstract operation 2043 // https://tc39.es/ecma262/#sec-hasownproperty 2044 // eslint-disable-next-line es/no-object-hasown -- safe 2045 var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) { 2046 return hasOwnProperty(toObject(it), key); 2047 }; 2048 2049 var id = 0; 2050 var postfix = Math.random(); 2051 var toString$1 = functionUncurryThis(1.0.toString); 2052 var uid = function (key) { 2053 return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$1(++id + postfix, 36); 2054 }; 2055 2056 var Symbol$1 = globalThis_1.Symbol; 2057 var WellKnownSymbolsStore = shared('wks'); 2058 var createWellKnownSymbol = useSymbolAsUid ? Symbol$1['for'] || Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid; 2059 var wellKnownSymbol = function (name) { 2060 if (!hasOwnProperty_1(WellKnownSymbolsStore, name)) { 2061 WellKnownSymbolsStore[name] = symbolConstructorDetection && hasOwnProperty_1(Symbol$1, name) ? Symbol$1[name] : createWellKnownSymbol('Symbol.' + name); 2062 } 2063 return WellKnownSymbolsStore[name]; 2064 }; 2065 2066 var $TypeError$3 = TypeError; 2067 var TO_PRIMITIVE = wellKnownSymbol('toPrimitive'); 2068 2069 // `ToPrimitive` abstract operation 2070 // https://tc39.es/ecma262/#sec-toprimitive 2071 var toPrimitive = function (input, pref) { 2072 if (!isObject(input) || isSymbol(input)) return input; 2073 var exoticToPrim = getMethod(input, TO_PRIMITIVE); 2074 var result; 2075 if (exoticToPrim) { 2076 if (pref === undefined) pref = 'default'; 2077 result = functionCall(exoticToPrim, input, pref); 2078 if (!isObject(result) || isSymbol(result)) return result; 2079 throw new $TypeError$3("Can't convert object to primitive value"); 2080 } 2081 if (pref === undefined) pref = 'number'; 2082 return ordinaryToPrimitive(input, pref); 2083 }; 2084 2085 // `ToPropertyKey` abstract operation 2086 // https://tc39.es/ecma262/#sec-topropertykey 2087 var toPropertyKey = function (argument) { 2088 var key = toPrimitive(argument, 'string'); 2089 return isSymbol(key) ? key : key + ''; 2090 }; 2091 2092 var document$1 = globalThis_1.document; 2093 // typeof document.createElement is 'object' in old IE 2094 var EXISTS = isObject(document$1) && isObject(document$1.createElement); 2095 var documentCreateElement = function (it) { 2096 return EXISTS ? document$1.createElement(it) : {}; 2097 }; 2098 2099 // Thanks to IE8 for its funny defineProperty 2100 var ie8DomDefine = !descriptors && !fails(function () { 2101 // eslint-disable-next-line es/no-object-defineproperty -- required for testing 2102 return Object.defineProperty(documentCreateElement('div'), 'a', { 2103 get: function () { 2104 return 7; 2105 } 2106 }).a !== 7; 2107 }); 2108 2109 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2110 var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; 2111 2112 // `Object.getOwnPropertyDescriptor` method 2113 // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor 2114 var f$1 = descriptors ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) { 2115 O = toIndexedObject(O); 2116 P = toPropertyKey(P); 2117 if (ie8DomDefine) try { 2118 return $getOwnPropertyDescriptor(O, P); 2119 } catch (error) {/* empty */} 2120 if (hasOwnProperty_1(O, P)) return createPropertyDescriptor(!functionCall(objectPropertyIsEnumerable.f, O, P), O[P]); 2121 }; 2122 2123 var objectGetOwnPropertyDescriptor = { 2124 f: f$1 2125 }; 2126 2127 // V8 ~ Chrome 36- 2128 // https://bugs.chromium.org/p/v8/issues/detail?id=3334 2129 var v8PrototypeDefineBug = descriptors && fails(function () { 2130 // eslint-disable-next-line es/no-object-defineproperty -- required for testing 2131 return Object.defineProperty(function () {/* empty */}, 'prototype', { 2132 value: 42, 2133 writable: false 2134 }).prototype !== 42; 2135 }); 2136 2137 var $String$2 = String; 2138 var $TypeError$4 = TypeError; 2139 2140 // `Assert: Type(argument) is Object` 2141 var anObject = function (argument) { 2142 if (isObject(argument)) return argument; 2143 throw new $TypeError$4($String$2(argument) + ' is not an object'); 2144 }; 2145 2146 var $TypeError$5 = TypeError; 2147 // eslint-disable-next-line es/no-object-defineproperty -- safe 2148 var $defineProperty = Object.defineProperty; 2149 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2150 var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor; 2151 var ENUMERABLE = 'enumerable'; 2152 var CONFIGURABLE = 'configurable'; 2153 var WRITABLE = 'writable'; 2154 2155 // `Object.defineProperty` method 2156 // https://tc39.es/ecma262/#sec-object.defineproperty 2157 var f$2 = descriptors ? v8PrototypeDefineBug ? function defineProperty(O, P, Attributes) { 2158 anObject(O); 2159 P = toPropertyKey(P); 2160 anObject(Attributes); 2161 if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) { 2162 var current = $getOwnPropertyDescriptor$1(O, P); 2163 if (current && current[WRITABLE]) { 2164 O[P] = Attributes.value; 2165 Attributes = { 2166 configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE], 2167 enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE], 2168 writable: false 2169 }; 2170 } 2171 } 2172 return $defineProperty(O, P, Attributes); 2173 } : $defineProperty : function defineProperty(O, P, Attributes) { 2174 anObject(O); 2175 P = toPropertyKey(P); 2176 anObject(Attributes); 2177 if (ie8DomDefine) try { 2178 return $defineProperty(O, P, Attributes); 2179 } catch (error) {/* empty */} 2180 if ('get' in Attributes || 'set' in Attributes) throw new $TypeError$5('Accessors not supported'); 2181 if ('value' in Attributes) O[P] = Attributes.value; 2182 return O; 2183 }; 2184 2185 var objectDefineProperty = { 2186 f: f$2 2187 }; 2188 2189 var createNonEnumerableProperty = descriptors ? function (object, key, value) { 2190 return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value)); 2191 } : function (object, key, value) { 2192 object[key] = value; 2193 return object; 2194 }; 2195 2196 var FunctionPrototype$1 = Function.prototype; 2197 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2198 var getDescriptor = descriptors && Object.getOwnPropertyDescriptor; 2199 var EXISTS$1 = hasOwnProperty_1(FunctionPrototype$1, 'name'); 2200 // additional protection from minified / mangled / dropped function names 2201 var PROPER = EXISTS$1 && function something() {/* empty */}.name === 'something'; 2202 var CONFIGURABLE$1 = EXISTS$1 && (!descriptors || descriptors && getDescriptor(FunctionPrototype$1, 'name').configurable); 2203 var functionName = { 2204 EXISTS: EXISTS$1, 2205 PROPER: PROPER, 2206 CONFIGURABLE: CONFIGURABLE$1 2207 }; 2208 2209 var functionToString = functionUncurryThis(Function.toString); 2210 2211 // this helper broken in `[email protected]`, so we can't use `shared` helper 2212 if (!isCallable(sharedStore.inspectSource)) { 2213 sharedStore.inspectSource = function (it) { 2214 return functionToString(it); 2215 }; 2216 } 2217 var inspectSource = sharedStore.inspectSource; 2218 2219 var WeakMap = globalThis_1.WeakMap; 2220 var weakMapBasicDetection = isCallable(WeakMap) && /native code/.test(String(WeakMap)); 2221 2222 var keys = shared('keys'); 2223 var sharedKey = function (key) { 2224 return keys[key] || (keys[key] = uid(key)); 2225 }; 2226 2227 var hiddenKeys = {}; 2228 2229 var OBJECT_ALREADY_INITIALIZED = 'Object already initialized'; 2230 var TypeError$1 = globalThis_1.TypeError; 2231 var WeakMap$1 = globalThis_1.WeakMap; 2232 var set, get, has; 2233 var enforce = function (it) { 2234 return has(it) ? get(it) : set(it, {}); 2235 }; 2236 var getterFor = function (TYPE) { 2237 return function (it) { 2238 var state; 2239 if (!isObject(it) || (state = get(it)).type !== TYPE) { 2240 throw new TypeError$1('Incompatible receiver, ' + TYPE + ' required'); 2241 } 2242 return state; 2243 }; 2244 }; 2245 if (weakMapBasicDetection || sharedStore.state) { 2246 var store = sharedStore.state || (sharedStore.state = new WeakMap$1()); 2247 /* eslint-disable no-self-assign -- prototype methods protection */ 2248 store.get = store.get; 2249 store.has = store.has; 2250 store.set = store.set; 2251 /* eslint-enable no-self-assign -- prototype methods protection */ 2252 set = function (it, metadata) { 2253 if (store.has(it)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED); 2254 metadata.facade = it; 2255 store.set(it, metadata); 2256 return metadata; 2257 }; 2258 get = function (it) { 2259 return store.get(it) || {}; 2260 }; 2261 has = function (it) { 2262 return store.has(it); 2263 }; 2264 } else { 2265 var STATE = sharedKey('state'); 2266 hiddenKeys[STATE] = true; 2267 set = function (it, metadata) { 2268 if (hasOwnProperty_1(it, STATE)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED); 2269 metadata.facade = it; 2270 createNonEnumerableProperty(it, STATE, metadata); 2271 return metadata; 2272 }; 2273 get = function (it) { 2274 return hasOwnProperty_1(it, STATE) ? it[STATE] : {}; 2275 }; 2276 has = function (it) { 2277 return hasOwnProperty_1(it, STATE); 2278 }; 2279 } 2280 var internalState = { 2281 set: set, 2282 get: get, 2283 has: has, 2284 enforce: enforce, 2285 getterFor: getterFor 2286 }; 2287 2288 var makeBuiltIn_1 = createCommonjsModule(function (module) { 2289 2290 2291 2292 2293 2294 2295 var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE; 2296 2297 2298 var enforceInternalState = internalState.enforce; 2299 var getInternalState = internalState.get; 2300 var $String = String; 2301 // eslint-disable-next-line es/no-object-defineproperty -- safe 2302 var defineProperty = Object.defineProperty; 2303 var stringSlice = functionUncurryThis(''.slice); 2304 var replace = functionUncurryThis(''.replace); 2305 var join = functionUncurryThis([].join); 2306 var CONFIGURABLE_LENGTH = descriptors && !fails(function () { 2307 return defineProperty(function () {/* empty */}, 'length', { 2308 value: 8 2309 }).length !== 8; 2310 }); 2311 var TEMPLATE = String(String).split('String'); 2312 var makeBuiltIn = module.exports = function (value, name, options) { 2313 if (stringSlice($String(name), 0, 7) === 'Symbol(') { 2314 name = '[' + replace($String(name), /^Symbol\(([^)]*)\).*$/, '$1') + ']'; 2315 } 2316 if (options && options.getter) name = 'get ' + name; 2317 if (options && options.setter) name = 'set ' + name; 2318 if (!hasOwnProperty_1(value, 'name') || CONFIGURABLE_FUNCTION_NAME && value.name !== name) { 2319 if (descriptors) defineProperty(value, 'name', { 2320 value: name, 2321 configurable: true 2322 });else value.name = name; 2323 } 2324 if (CONFIGURABLE_LENGTH && options && hasOwnProperty_1(options, 'arity') && value.length !== options.arity) { 2325 defineProperty(value, 'length', { 2326 value: options.arity 2327 }); 2328 } 2329 try { 2330 if (options && hasOwnProperty_1(options, 'constructor') && options.constructor) { 2331 if (descriptors) defineProperty(value, 'prototype', { 2332 writable: false 2333 }); 2334 // in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable 2335 } else if (value.prototype) value.prototype = undefined; 2336 } catch (error) {/* empty */} 2337 var state = enforceInternalState(value); 2338 if (!hasOwnProperty_1(state, 'source')) { 2339 state.source = join(TEMPLATE, typeof name == 'string' ? name : ''); 2340 } 2341 return value; 2342 }; 2343 2344 // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative 2345 // eslint-disable-next-line no-extend-native -- required 2346 Function.prototype.toString = makeBuiltIn(function toString() { 2347 return isCallable(this) && getInternalState(this).source || inspectSource(this); 2348 }, 'toString'); 2349 }); 2350 2351 var defineBuiltIn = function (O, key, value, options) { 2352 if (!options) options = {}; 2353 var simple = options.enumerable; 2354 var name = options.name !== undefined ? options.name : key; 2355 if (isCallable(value)) makeBuiltIn_1(value, name, options); 2356 if (options.global) { 2357 if (simple) O[key] = value;else defineGlobalProperty(key, value); 2358 } else { 2359 try { 2360 if (!options.unsafe) delete O[key];else if (O[key]) simple = true; 2361 } catch (error) {/* empty */} 2362 if (simple) O[key] = value;else objectDefineProperty.f(O, key, { 2363 value: value, 2364 enumerable: false, 2365 configurable: !options.nonConfigurable, 2366 writable: !options.nonWritable 2367 }); 2368 } 2369 return O; 2370 }; 2371 2372 var ceil = Math.ceil; 2373 var floor = Math.floor; 2374 2375 // `Math.trunc` method 2376 // https://tc39.es/ecma262/#sec-math.trunc 2377 // eslint-disable-next-line es/no-math-trunc -- safe 2378 var mathTrunc = Math.trunc || function trunc(x) { 2379 var n = +x; 2380 return (n > 0 ? floor : ceil)(n); 2381 }; 2382 2383 // `ToIntegerOrInfinity` abstract operation 2384 // https://tc39.es/ecma262/#sec-tointegerorinfinity 2385 var toIntegerOrInfinity = function (argument) { 2386 var number = +argument; 2387 // eslint-disable-next-line no-self-compare -- NaN check 2388 return number !== number || number === 0 ? 0 : mathTrunc(number); 2389 }; 2390 2391 var max = Math.max; 2392 var min = Math.min; 2393 2394 // Helper for a popular repeating case of the spec: 2395 // Let integer be ? ToInteger(index). 2396 // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length). 2397 var toAbsoluteIndex = function (index, length) { 2398 var integer = toIntegerOrInfinity(index); 2399 return integer < 0 ? max(integer + length, 0) : min(integer, length); 2400 }; 2401 2402 var min$1 = Math.min; 2403 2404 // `ToLength` abstract operation 2405 // https://tc39.es/ecma262/#sec-tolength 2406 var toLength = function (argument) { 2407 var len = toIntegerOrInfinity(argument); 2408 return len > 0 ? min$1(len, 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 2409 }; 2410 2411 // `LengthOfArrayLike` abstract operation 2412 // https://tc39.es/ecma262/#sec-lengthofarraylike 2413 var lengthOfArrayLike = function (obj) { 2414 return toLength(obj.length); 2415 }; 2416 2417 // `Array.prototype.{ indexOf, includes }` methods implementation 2418 var createMethod = function (IS_INCLUDES) { 2419 return function ($this, el, fromIndex) { 2420 var O = toIndexedObject($this); 2421 var length = lengthOfArrayLike(O); 2422 if (length === 0) return !IS_INCLUDES && -1; 2423 var index = toAbsoluteIndex(fromIndex, length); 2424 var value; 2425 // Array#includes uses SameValueZero equality algorithm 2426 // eslint-disable-next-line no-self-compare -- NaN check 2427 if (IS_INCLUDES && el !== el) while (length > index) { 2428 value = O[index++]; 2429 // eslint-disable-next-line no-self-compare -- NaN check 2430 if (value !== value) return true; 2431 // Array#indexOf ignores holes, Array#includes - not 2432 } else for (; length > index; index++) { 2433 if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0; 2434 } 2435 return !IS_INCLUDES && -1; 2436 }; 2437 }; 2438 var arrayIncludes = { 2439 // `Array.prototype.includes` method 2440 // https://tc39.es/ecma262/#sec-array.prototype.includes 2441 includes: createMethod(true), 2442 // `Array.prototype.indexOf` method 2443 // https://tc39.es/ecma262/#sec-array.prototype.indexof 2444 indexOf: createMethod(false) 2445 }; 2446 2447 var indexOf = arrayIncludes.indexOf; 2448 2449 var push = functionUncurryThis([].push); 2450 var objectKeysInternal = function (object, names) { 2451 var O = toIndexedObject(object); 2452 var i = 0; 2453 var result = []; 2454 var key; 2455 for (key in O) !hasOwnProperty_1(hiddenKeys, key) && hasOwnProperty_1(O, key) && push(result, key); 2456 // Don't enum bug & hidden keys 2457 while (names.length > i) if (hasOwnProperty_1(O, key = names[i++])) { 2458 ~indexOf(result, key) || push(result, key); 2459 } 2460 return result; 2461 }; 2462 2463 // IE8- don't enum bug keys 2464 var enumBugKeys = ['constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf']; 2465 2466 var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype'); 2467 2468 // `Object.getOwnPropertyNames` method 2469 // https://tc39.es/ecma262/#sec-object.getownpropertynames 2470 // eslint-disable-next-line es/no-object-getownpropertynames -- safe 2471 var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { 2472 return objectKeysInternal(O, hiddenKeys$1); 2473 }; 2474 2475 var objectGetOwnPropertyNames = { 2476 f: f$3 2477 }; 2478 2479 // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe 2480 var f$4 = Object.getOwnPropertySymbols; 2481 2482 var objectGetOwnPropertySymbols = { 2483 f: f$4 2484 }; 2485 2486 var concat = functionUncurryThis([].concat); 2487 2488 // all object keys, includes non-enumerable and symbols 2489 var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) { 2490 var keys = objectGetOwnPropertyNames.f(anObject(it)); 2491 var getOwnPropertySymbols = objectGetOwnPropertySymbols.f; 2492 return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys; 2493 }; 2494 2495 var copyConstructorProperties = function (target, source, exceptions) { 2496 var keys = ownKeys(source); 2497 var defineProperty = objectDefineProperty.f; 2498 var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; 2499 for (var i = 0; i < keys.length; i++) { 2500 var key = keys[i]; 2501 if (!hasOwnProperty_1(target, key) && !(exceptions && hasOwnProperty_1(exceptions, key))) { 2502 defineProperty(target, key, getOwnPropertyDescriptor(source, key)); 2503 } 2504 } 2505 }; 2506 2507 var replacement = /#|\.prototype\./; 2508 var isForced = function (feature, detection) { 2509 var value = data[normalize(feature)]; 2510 return value === POLYFILL ? true : value === NATIVE ? false : isCallable(detection) ? fails(detection) : !!detection; 2511 }; 2512 var normalize = isForced.normalize = function (string) { 2513 return String(string).replace(replacement, '.').toLowerCase(); 2514 }; 2515 var data = isForced.data = {}; 2516 var NATIVE = isForced.NATIVE = 'N'; 2517 var POLYFILL = isForced.POLYFILL = 'P'; 2518 var isForced_1 = isForced; 2519 2520 var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f; 2521 2522 2523 2524 2525 2526 2527 /* 2528 options.target - name of the target object 2529 options.global - target is the global object 2530 options.stat - export as static methods of target 2531 options.proto - export as prototype methods of target 2532 options.real - real prototype method for the `pure` version 2533 options.forced - export even if the native feature is available 2534 options.bind - bind methods to the target, required for the `pure` version 2535 options.wrap - wrap constructors to preventing global pollution, required for the `pure` version 2536 options.unsafe - use the simple assignment of property instead of delete + defineProperty 2537 options.sham - add a flag to not completely full polyfills 2538 options.enumerable - export as enumerable property 2539 options.dontCallGetSet - prevent calling a getter on target 2540 options.name - the .name of the function if it does not match the key 2541 */ 2542 var _export = function (options, source) { 2543 var TARGET = options.target; 2544 var GLOBAL = options.global; 2545 var STATIC = options.stat; 2546 var FORCED, target, key, targetProperty, sourceProperty, descriptor; 2547 if (GLOBAL) { 2548 target = globalThis_1; 2549 } else if (STATIC) { 2550 target = globalThis_1[TARGET] || defineGlobalProperty(TARGET, {}); 2551 } else { 2552 target = globalThis_1[TARGET] && globalThis_1[TARGET].prototype; 2553 } 2554 if (target) for (key in source) { 2555 sourceProperty = source[key]; 2556 if (options.dontCallGetSet) { 2557 descriptor = getOwnPropertyDescriptor$1(target, key); 2558 targetProperty = descriptor && descriptor.value; 2559 } else targetProperty = target[key]; 2560 FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); 2561 // contained in target 2562 if (!FORCED && targetProperty !== undefined) { 2563 if (typeof sourceProperty == typeof targetProperty) continue; 2564 copyConstructorProperties(sourceProperty, targetProperty); 2565 } 2566 // add a flag to not completely full polyfills 2567 if (options.sham || targetProperty && targetProperty.sham) { 2568 createNonEnumerableProperty(sourceProperty, 'sham', true); 2569 } 2570 defineBuiltIn(target, key, sourceProperty, options); 2571 } 2572 }; 2573 2574 var correctPrototypeGetter = !fails(function () { 2575 function F() {/* empty */} 2576 F.prototype.constructor = null; 2577 // eslint-disable-next-line es/no-object-getprototypeof -- required for testing 2578 return Object.getPrototypeOf(new F()) !== F.prototype; 2579 }); 2580 2581 var IE_PROTO = sharedKey('IE_PROTO'); 2582 var $Object$3 = Object; 2583 var ObjectPrototype = $Object$3.prototype; 2584 2585 // `Object.getPrototypeOf` method 2586 // https://tc39.es/ecma262/#sec-object.getprototypeof 2587 // eslint-disable-next-line es/no-object-getprototypeof -- safe 2588 var objectGetPrototypeOf = correctPrototypeGetter ? $Object$3.getPrototypeOf : function (O) { 2589 var object = toObject(O); 2590 if (hasOwnProperty_1(object, IE_PROTO)) return object[IE_PROTO]; 2591 var constructor = object.constructor; 2592 if (isCallable(constructor) && object instanceof constructor) { 2593 return constructor.prototype; 2594 } 2595 return object instanceof $Object$3 ? ObjectPrototype : null; 2596 }; 2597 2598 var functionUncurryThisAccessor = function (object, key, method) { 2599 try { 2600 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2601 return functionUncurryThis(aCallable(Object.getOwnPropertyDescriptor(object, key)[method])); 2602 } catch (error) {/* empty */} 2603 }; 2604 2605 var isPossiblePrototype = function (argument) { 2606 return isObject(argument) || argument === null; 2607 }; 2608 2609 var $String$3 = String; 2610 var $TypeError$6 = TypeError; 2611 var aPossiblePrototype = function (argument) { 2612 if (isPossiblePrototype(argument)) return argument; 2613 throw new $TypeError$6("Can't set " + $String$3(argument) + ' as a prototype'); 2614 }; 2615 2616 /* eslint-disable no-proto -- safe */ 2617 2618 2619 2620 2621 2622 // `Object.setPrototypeOf` method 2623 // https://tc39.es/ecma262/#sec-object.setprototypeof 2624 // Works with __proto__ only. Old v8 can't work with null proto objects. 2625 // eslint-disable-next-line es/no-object-setprototypeof -- safe 2626 var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () { 2627 var CORRECT_SETTER = false; 2628 var test = {}; 2629 var setter; 2630 try { 2631 setter = functionUncurryThisAccessor(Object.prototype, '__proto__', 'set'); 2632 setter(test, []); 2633 CORRECT_SETTER = test instanceof Array; 2634 } catch (error) {/* empty */} 2635 return function setPrototypeOf(O, proto) { 2636 requireObjectCoercible(O); 2637 aPossiblePrototype(proto); 2638 if (!isObject(O)) return O; 2639 if (CORRECT_SETTER) setter(O, proto);else O.__proto__ = proto; 2640 return O; 2641 }; 2642 }() : undefined); 2643 2644 // `Object.keys` method 2645 // https://tc39.es/ecma262/#sec-object.keys 2646 // eslint-disable-next-line es/no-object-keys -- safe 2647 var objectKeys = Object.keys || function keys(O) { 2648 return objectKeysInternal(O, enumBugKeys); 2649 }; 2650 2651 // `Object.defineProperties` method 2652 // https://tc39.es/ecma262/#sec-object.defineproperties 2653 // eslint-disable-next-line es/no-object-defineproperties -- safe 2654 var f$5 = descriptors && !v8PrototypeDefineBug ? Object.defineProperties : function defineProperties(O, Properties) { 2655 anObject(O); 2656 var props = toIndexedObject(Properties); 2657 var keys = objectKeys(Properties); 2658 var length = keys.length; 2659 var index = 0; 2660 var key; 2661 while (length > index) objectDefineProperty.f(O, key = keys[index++], props[key]); 2662 return O; 2663 }; 2664 2665 var objectDefineProperties = { 2666 f: f$5 2667 }; 2668 2669 var html = getBuiltIn('document', 'documentElement'); 2670 2671 /* global ActiveXObject -- old IE, WSH */ 2672 2673 2674 2675 2676 2677 2678 2679 var GT = '>'; 2680 var LT = '<'; 2681 var PROTOTYPE = 'prototype'; 2682 var SCRIPT = 'script'; 2683 var IE_PROTO$1 = sharedKey('IE_PROTO'); 2684 var EmptyConstructor = function () {/* empty */}; 2685 var scriptTag = function (content) { 2686 return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT; 2687 }; 2688 2689 // Create object with fake `null` prototype: use ActiveX Object with cleared prototype 2690 var NullProtoObjectViaActiveX = function (activeXDocument) { 2691 activeXDocument.write(scriptTag('')); 2692 activeXDocument.close(); 2693 var temp = activeXDocument.parentWindow.Object; 2694 // eslint-disable-next-line no-useless-assignment -- avoid memory leak 2695 activeXDocument = null; 2696 return temp; 2697 }; 2698 2699 // Create object with fake `null` prototype: use iframe Object with cleared prototype 2700 var NullProtoObjectViaIFrame = function () { 2701 // Thrash, waste and sodomy: IE GC bug 2702 var iframe = documentCreateElement('iframe'); 2703 var JS = 'java' + SCRIPT + ':'; 2704 var iframeDocument; 2705 iframe.style.display = 'none'; 2706 html.appendChild(iframe); 2707 // https://github.com/zloirock/core-js/issues/475 2708 iframe.src = String(JS); 2709 iframeDocument = iframe.contentWindow.document; 2710 iframeDocument.open(); 2711 iframeDocument.write(scriptTag('document.F=Object')); 2712 iframeDocument.close(); 2713 return iframeDocument.F; 2714 }; 2715 2716 // Check for document.domain and active x support 2717 // No need to use active x approach when document.domain is not set 2718 // see https://github.com/es-shims/es5-shim/issues/150 2719 // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346 2720 // avoid IE GC bug 2721 var activeXDocument; 2722 var NullProtoObject = function () { 2723 try { 2724 activeXDocument = new ActiveXObject('htmlfile'); 2725 } catch (error) {/* ignore */} 2726 NullProtoObject = typeof document != 'undefined' ? document.domain && activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) // old IE 2727 : NullProtoObjectViaIFrame() : NullProtoObjectViaActiveX(activeXDocument); // WSH 2728 var length = enumBugKeys.length; 2729 while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]]; 2730 return NullProtoObject(); 2731 }; 2732 hiddenKeys[IE_PROTO$1] = true; 2733 2734 // `Object.create` method 2735 // https://tc39.es/ecma262/#sec-object.create 2736 // eslint-disable-next-line es/no-object-create -- safe 2737 var objectCreate = Object.create || function create(O, Properties) { 2738 var result; 2739 if (O !== null) { 2740 EmptyConstructor[PROTOTYPE] = anObject(O); 2741 result = new EmptyConstructor(); 2742 EmptyConstructor[PROTOTYPE] = null; 2743 // add "__proto__" for Object.getPrototypeOf polyfill 2744 result[IE_PROTO$1] = O; 2745 } else result = NullProtoObject(); 2746 return Properties === undefined ? result : objectDefineProperties.f(result, Properties); 2747 }; 2748 2749 // `InstallErrorCause` abstract operation 2750 // https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause 2751 var installErrorCause = function (O, options) { 2752 if (isObject(options) && 'cause' in options) { 2753 createNonEnumerableProperty(O, 'cause', options.cause); 2754 } 2755 }; 2756 2757 var $Error = Error; 2758 var replace = functionUncurryThis(''.replace); 2759 var TEST = function (arg) { 2760 return String(new $Error(arg).stack); 2761 }('zxcasd'); 2762 // eslint-disable-next-line redos/no-vulnerable, sonarjs/slow-regex -- safe 2763 var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/; 2764 var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST); 2765 var errorStackClear = function (stack, dropEntries) { 2766 if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string' && !$Error.prepareStackTrace) { 2767 while (dropEntries--) stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, ''); 2768 } 2769 return stack; 2770 }; 2771 2772 var errorStackInstallable = !fails(function () { 2773 var error = new Error('a'); 2774 if (!('stack' in error)) return true; 2775 // eslint-disable-next-line es/no-object-defineproperty -- safe 2776 Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7)); 2777 return error.stack !== 7; 2778 }); 2779 2780 // non-standard V8 2781 var captureStackTrace = Error.captureStackTrace; 2782 var errorStackInstall = function (error, C, stack, dropEntries) { 2783 if (errorStackInstallable) { 2784 if (captureStackTrace) captureStackTrace(error, C);else createNonEnumerableProperty(error, 'stack', errorStackClear(stack, dropEntries)); 2785 } 2786 }; 2787 2788 var functionUncurryThisClause = function (fn) { 2789 // Nashorn bug: 2790 // https://github.com/zloirock/core-js/issues/1128 2791 // https://github.com/zloirock/core-js/issues/1130 2792 if (classofRaw(fn) === 'Function') return functionUncurryThis(fn); 2793 }; 2794 2795 var bind = functionUncurryThisClause(functionUncurryThisClause.bind); 2796 2797 // optional / simple context binding 2798 var functionBindContext = function (fn, that) { 2799 aCallable(fn); 2800 return that === undefined ? fn : functionBindNative ? bind(fn, that) : function /* ...args */ 2801 () { 2802 return fn.apply(that, arguments); 2803 }; 2804 }; 2805 2806 var iterators = {}; 2807 2808 var ITERATOR = wellKnownSymbol('iterator'); 2809 var ArrayPrototype = Array.prototype; 2810 2811 // check on default Array iterator 2812 var isArrayIteratorMethod = function (it) { 2813 return it !== undefined && (iterators.Array === it || ArrayPrototype[ITERATOR] === it); 2814 }; 2815 2816 var TO_STRING_TAG = wellKnownSymbol('toStringTag'); 2817 var test = {}; 2818 test[TO_STRING_TAG] = 'z'; 2819 var toStringTagSupport = String(test) === '[object z]'; 2820 2821 var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag'); 2822 var $Object$4 = Object; 2823 2824 // ES3 wrong here 2825 var CORRECT_ARGUMENTS = classofRaw(function () { 2826 return arguments; 2827 }()) === 'Arguments'; 2828 2829 // fallback for IE11 Script Access Denied error 2830 var tryGet = function (it, key) { 2831 try { 2832 return it[key]; 2833 } catch (error) {/* empty */} 2834 }; 2835 2836 // getting tag from ES6+ `Object.prototype.toString` 2837 var classof = toStringTagSupport ? classofRaw : function (it) { 2838 var O, tag, result; 2839 return it === undefined ? 'Undefined' : it === null ? 'Null' 2840 // @@toStringTag case 2841 : typeof (tag = tryGet(O = $Object$4(it), TO_STRING_TAG$1)) == 'string' ? tag 2842 // builtinTag case 2843 : CORRECT_ARGUMENTS ? classofRaw(O) 2844 // ES3 arguments fallback 2845 : (result = classofRaw(O)) === 'Object' && isCallable(O.callee) ? 'Arguments' : result; 2846 }; 2847 2848 var ITERATOR$1 = wellKnownSymbol('iterator'); 2849 var getIteratorMethod = function (it) { 2850 if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR$1) || getMethod(it, '@@iterator') || iterators[classof(it)]; 2851 }; 2852 2853 var $TypeError$7 = TypeError; 2854 var getIterator = function (argument, usingIterator) { 2855 var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator; 2856 if (aCallable(iteratorMethod)) return anObject(functionCall(iteratorMethod, argument)); 2857 throw new $TypeError$7(tryToString(argument) + ' is not iterable'); 2858 }; 2859 2860 var iteratorClose = function (iterator, kind, value) { 2861 var innerResult, innerError; 2862 anObject(iterator); 2863 try { 2864 innerResult = getMethod(iterator, 'return'); 2865 if (!innerResult) { 2866 if (kind === 'throw') throw value; 2867 return value; 2868 } 2869 innerResult = functionCall(innerResult, iterator); 2870 } catch (error) { 2871 innerError = true; 2872 innerResult = error; 2873 } 2874 if (kind === 'throw') throw value; 2875 if (innerError) throw innerResult; 2876 anObject(innerResult); 2877 return value; 2878 }; 2879 2880 var $TypeError$8 = TypeError; 2881 var Result = function (stopped, result) { 2882 this.stopped = stopped; 2883 this.result = result; 2884 }; 2885 var ResultPrototype = Result.prototype; 2886 var iterate = function (iterable, unboundFunction, options) { 2887 var that = options && options.that; 2888 var AS_ENTRIES = !!(options && options.AS_ENTRIES); 2889 var IS_RECORD = !!(options && options.IS_RECORD); 2890 var IS_ITERATOR = !!(options && options.IS_ITERATOR); 2891 var INTERRUPTED = !!(options && options.INTERRUPTED); 2892 var fn = functionBindContext(unboundFunction, that); 2893 var iterator, iterFn, index, length, result, next, step; 2894 var stop = function (condition) { 2895 if (iterator) iteratorClose(iterator, 'normal', condition); 2896 return new Result(true, condition); 2897 }; 2898 var callFn = function (value) { 2899 if (AS_ENTRIES) { 2900 anObject(value); 2901 return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]); 2902 } 2903 return INTERRUPTED ? fn(value, stop) : fn(value); 2904 }; 2905 if (IS_RECORD) { 2906 iterator = iterable.iterator; 2907 } else if (IS_ITERATOR) { 2908 iterator = iterable; 2909 } else { 2910 iterFn = getIteratorMethod(iterable); 2911 if (!iterFn) throw new $TypeError$8(tryToString(iterable) + ' is not iterable'); 2912 // optimisation for array iterators 2913 if (isArrayIteratorMethod(iterFn)) { 2914 for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) { 2915 result = callFn(iterable[index]); 2916 if (result && objectIsPrototypeOf(ResultPrototype, result)) return result; 2917 } 2918 return new Result(false); 2919 } 2920 iterator = getIterator(iterable, iterFn); 2921 } 2922 next = IS_RECORD ? iterable.next : iterator.next; 2923 while (!(step = functionCall(next, iterator)).done) { 2924 try { 2925 result = callFn(step.value); 2926 } catch (error) { 2927 iteratorClose(iterator, 'throw', error); 2928 } 2929 if (typeof result == 'object' && result && objectIsPrototypeOf(ResultPrototype, result)) return result; 2930 } 2931 return new Result(false); 2932 }; 2933 2934 var $String$4 = String; 2935 var toString_1 = function (argument) { 2936 if (classof(argument) === 'Symbol') throw new TypeError('Cannot convert a Symbol value to a string'); 2937 return $String$4(argument); 2938 }; 2939 2940 var normalizeStringArgument = function (argument, $default) { 2941 return argument === undefined ? arguments.length < 2 ? '' : $default : toString_1(argument); 2942 }; 2943 2944 var TO_STRING_TAG$2 = wellKnownSymbol('toStringTag'); 2945 var $Error$1 = Error; 2946 var push$1 = [].push; 2947 var $AggregateError = function AggregateError(errors, message /* , options */) { 2948 var isInstance = objectIsPrototypeOf(AggregateErrorPrototype, this); 2949 var that; 2950 if (objectSetPrototypeOf) { 2951 that = objectSetPrototypeOf(new $Error$1(), isInstance ? objectGetPrototypeOf(this) : AggregateErrorPrototype); 2952 } else { 2953 that = isInstance ? this : objectCreate(AggregateErrorPrototype); 2954 createNonEnumerableProperty(that, TO_STRING_TAG$2, 'Error'); 2955 } 2956 if (message !== undefined) createNonEnumerableProperty(that, 'message', normalizeStringArgument(message)); 2957 errorStackInstall(that, $AggregateError, that.stack, 1); 2958 if (arguments.length > 2) installErrorCause(that, arguments[2]); 2959 var errorsArray = []; 2960 iterate(errors, push$1, { 2961 that: errorsArray 2962 }); 2963 createNonEnumerableProperty(that, 'errors', errorsArray); 2964 return that; 2965 }; 2966 if (objectSetPrototypeOf) objectSetPrototypeOf($AggregateError, $Error$1);else copyConstructorProperties($AggregateError, $Error$1, { 2967 name: true 2968 }); 2969 var AggregateErrorPrototype = $AggregateError.prototype = objectCreate($Error$1.prototype, { 2970 constructor: createPropertyDescriptor(1, $AggregateError), 2971 message: createPropertyDescriptor(1, ''), 2972 name: createPropertyDescriptor(1, 'AggregateError') 2973 }); 2974 2975 // `AggregateError` constructor 2976 // https://tc39.es/ecma262/#sec-aggregate-error-constructor 2977 _export({ 2978 global: true, 2979 constructor: true, 2980 arity: 2 2981 }, { 2982 AggregateError: $AggregateError 2983 }); 2984 2985 var defineProperty$1 = objectDefineProperty.f; 2986 var UNSCOPABLES = wellKnownSymbol('unscopables'); 2987 var ArrayPrototype$1 = Array.prototype; 2988 2989 // Array.prototype[@@unscopables] 2990 // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 2991 if (ArrayPrototype$1[UNSCOPABLES] === undefined) { 2992 defineProperty$1(ArrayPrototype$1, UNSCOPABLES, { 2993 configurable: true, 2994 value: objectCreate(null) 2995 }); 2996 } 2997 2998 // add a key to Array.prototype[@@unscopables] 2999 var addToUnscopables = function (key) { 3000 ArrayPrototype$1[UNSCOPABLES][key] = true; 3001 }; 3002 3003 // `Array.prototype.at` method 3004 // https://tc39.es/ecma262/#sec-array.prototype.at 3005 _export({ 3006 target: 'Array', 3007 proto: true 3008 }, { 3009 at: function at(index) { 3010 var O = toObject(this); 3011 var len = lengthOfArrayLike(O); 3012 var relativeIndex = toIntegerOrInfinity(index); 3013 var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; 3014 return k < 0 || k >= len ? undefined : O[k]; 3015 } 3016 }); 3017 addToUnscopables('at'); 3018 3019 // eslint-disable-next-line es/no-typed-arrays -- safe 3020 var arrayBufferBasicDetection = typeof ArrayBuffer != 'undefined' && typeof DataView != 'undefined'; 3021 3022 var defineBuiltInAccessor = function (target, name, descriptor) { 3023 if (descriptor.get) makeBuiltIn_1(descriptor.get, name, { 3024 getter: true 3025 }); 3026 if (descriptor.set) makeBuiltIn_1(descriptor.set, name, { 3027 setter: true 3028 }); 3029 return objectDefineProperty.f(target, name, descriptor); 3030 }; 3031 3032 var defineBuiltIns = function (target, src, options) { 3033 for (var key in src) defineBuiltIn(target, key, src[key], options); 3034 return target; 3035 }; 3036 3037 var $TypeError$9 = TypeError; 3038 var anInstance = function (it, Prototype) { 3039 if (objectIsPrototypeOf(Prototype, it)) return it; 3040 throw new $TypeError$9('Incorrect invocation'); 3041 }; 3042 3043 var $RangeError = RangeError; 3044 3045 // `ToIndex` abstract operation 3046 // https://tc39.es/ecma262/#sec-toindex 3047 var toIndex = function (it) { 3048 if (it === undefined) return 0; 3049 var number = toIntegerOrInfinity(it); 3050 var length = toLength(number); 3051 if (number !== length) throw new $RangeError('Wrong length or index'); 3052 return length; 3053 }; 3054 3055 // `Math.sign` method implementation 3056 // https://tc39.es/ecma262/#sec-math.sign 3057 // eslint-disable-next-line es/no-math-sign -- safe 3058 var mathSign = Math.sign || function sign(x) { 3059 var n = +x; 3060 // eslint-disable-next-line no-self-compare -- NaN check 3061 return n === 0 || n !== n ? n : n < 0 ? -1 : 1; 3062 }; 3063 3064 var EPSILON = 2.220446049250313e-16; // Number.EPSILON 3065 var INVERSE_EPSILON = 1 / EPSILON; 3066 var mathRoundTiesToEven = function (n) { 3067 return n + INVERSE_EPSILON - INVERSE_EPSILON; 3068 }; 3069 3070 var abs = Math.abs; 3071 var EPSILON$1 = 2.220446049250313e-16; // Number.EPSILON 3072 3073 var mathFloatRound = function (x, FLOAT_EPSILON, FLOAT_MAX_VALUE, FLOAT_MIN_VALUE) { 3074 var n = +x; 3075 var absolute = abs(n); 3076 var s = mathSign(n); 3077 if (absolute < FLOAT_MIN_VALUE) return s * mathRoundTiesToEven(absolute / FLOAT_MIN_VALUE / FLOAT_EPSILON) * FLOAT_MIN_VALUE * FLOAT_EPSILON; 3078 var a = (1 + FLOAT_EPSILON / EPSILON$1) * absolute; 3079 var result = a - (a - absolute); 3080 // eslint-disable-next-line no-self-compare -- NaN check 3081 if (result > FLOAT_MAX_VALUE || result !== result) return s * Infinity; 3082 return s * result; 3083 }; 3084 3085 var FLOAT32_EPSILON = 1.1920928955078125e-7; // 2 ** -23; 3086 var FLOAT32_MAX_VALUE = 3.4028234663852886e+38; // 2 ** 128 - 2 ** 104 3087 var FLOAT32_MIN_VALUE = 1.1754943508222875e-38; // 2 ** -126; 3088 3089 // `Math.fround` method implementation 3090 // https://tc39.es/ecma262/#sec-math.fround 3091 // eslint-disable-next-line es/no-math-fround -- safe 3092 var mathFround = Math.fround || function fround(x) { 3093 return mathFloatRound(x, FLOAT32_EPSILON, FLOAT32_MAX_VALUE, FLOAT32_MIN_VALUE); 3094 }; 3095 3096 // IEEE754 conversions based on https://github.com/feross/ieee754 3097 var $Array = Array; 3098 var abs$1 = Math.abs; 3099 var pow = Math.pow; 3100 var floor$1 = Math.floor; 3101 var log = Math.log; 3102 var LN2 = Math.LN2; 3103 var pack = function (number, mantissaLength, bytes) { 3104 var buffer = $Array(bytes); 3105 var exponentLength = bytes * 8 - mantissaLength - 1; 3106 var eMax = (1 << exponentLength) - 1; 3107 var eBias = eMax >> 1; 3108 var rt = mantissaLength === 23 ? pow(2, -24) - pow(2, -77) : 0; 3109 var sign = number < 0 || number === 0 && 1 / number < 0 ? 1 : 0; 3110 var index = 0; 3111 var exponent, mantissa, c; 3112 number = abs$1(number); 3113 // eslint-disable-next-line no-self-compare -- NaN check 3114 if (number !== number || number === Infinity) { 3115 // eslint-disable-next-line no-self-compare -- NaN check 3116 mantissa = number !== number ? 1 : 0; 3117 exponent = eMax; 3118 } else { 3119 exponent = floor$1(log(number) / LN2); 3120 c = pow(2, -exponent); 3121 if (number * c < 1) { 3122 exponent--; 3123 c *= 2; 3124 } 3125 if (exponent + eBias >= 1) { 3126 number += rt / c; 3127 } else { 3128 number += rt * pow(2, 1 - eBias); 3129 } 3130 if (number * c >= 2) { 3131 exponent++; 3132 c /= 2; 3133 } 3134 if (exponent + eBias >= eMax) { 3135 mantissa = 0; 3136 exponent = eMax; 3137 } else if (exponent + eBias >= 1) { 3138 mantissa = (number * c - 1) * pow(2, mantissaLength); 3139 exponent += eBias; 3140 } else { 3141 mantissa = number * pow(2, eBias - 1) * pow(2, mantissaLength); 3142 exponent = 0; 3143 } 3144 } 3145 while (mantissaLength >= 8) { 3146 buffer[index++] = mantissa & 255; 3147 mantissa /= 256; 3148 mantissaLength -= 8; 3149 } 3150 exponent = exponent << mantissaLength | mantissa; 3151 exponentLength += mantissaLength; 3152 while (exponentLength > 0) { 3153 buffer[index++] = exponent & 255; 3154 exponent /= 256; 3155 exponentLength -= 8; 3156 } 3157 buffer[index - 1] |= sign * 128; 3158 return buffer; 3159 }; 3160 var unpack = function (buffer, mantissaLength) { 3161 var bytes = buffer.length; 3162 var exponentLength = bytes * 8 - mantissaLength - 1; 3163 var eMax = (1 << exponentLength) - 1; 3164 var eBias = eMax >> 1; 3165 var nBits = exponentLength - 7; 3166 var index = bytes - 1; 3167 var sign = buffer[index--]; 3168 var exponent = sign & 127; 3169 var mantissa; 3170 sign >>= 7; 3171 while (nBits > 0) { 3172 exponent = exponent * 256 + buffer[index--]; 3173 nBits -= 8; 3174 } 3175 mantissa = exponent & (1 << -nBits) - 1; 3176 exponent >>= -nBits; 3177 nBits += mantissaLength; 3178 while (nBits > 0) { 3179 mantissa = mantissa * 256 + buffer[index--]; 3180 nBits -= 8; 3181 } 3182 if (exponent === 0) { 3183 exponent = 1 - eBias; 3184 } else if (exponent === eMax) { 3185 return mantissa ? NaN : sign ? -Infinity : Infinity; 3186 } else { 3187 mantissa += pow(2, mantissaLength); 3188 exponent -= eBias; 3189 } 3190 return (sign ? -1 : 1) * mantissa * pow(2, exponent - mantissaLength); 3191 }; 3192 var ieee754 = { 3193 pack: pack, 3194 unpack: unpack 3195 }; 3196 3197 // `Array.prototype.fill` method implementation 3198 // https://tc39.es/ecma262/#sec-array.prototype.fill 3199 var arrayFill = function fill(value /* , start = 0, end = @length */) { 3200 var O = toObject(this); 3201 var length = lengthOfArrayLike(O); 3202 var argumentsLength = arguments.length; 3203 var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length); 3204 var end = argumentsLength > 2 ? arguments[2] : undefined; 3205 var endPos = end === undefined ? length : toAbsoluteIndex(end, length); 3206 while (endPos > index) O[index++] = value; 3207 return O; 3208 }; 3209 3210 var arraySlice = functionUncurryThis([].slice); 3211 3212 // makes subclassing work correct for wrapped built-ins 3213 var inheritIfRequired = function ($this, dummy, Wrapper) { 3214 var NewTarget, NewTargetPrototype; 3215 if ( 3216 // it can work only with native `setPrototypeOf` 3217 objectSetPrototypeOf && 3218 // we haven't completely correct pre-ES6 way for getting `new.target`, so use this 3219 isCallable(NewTarget = dummy.constructor) && NewTarget !== Wrapper && isObject(NewTargetPrototype = NewTarget.prototype) && NewTargetPrototype !== Wrapper.prototype) objectSetPrototypeOf($this, NewTargetPrototype); 3220 return $this; 3221 }; 3222 3223 var defineProperty$2 = objectDefineProperty.f; 3224 3225 3226 var TO_STRING_TAG$3 = wellKnownSymbol('toStringTag'); 3227 var setToStringTag = function (target, TAG, STATIC) { 3228 if (target && !STATIC) target = target.prototype; 3229 if (target && !hasOwnProperty_1(target, TO_STRING_TAG$3)) { 3230 defineProperty$2(target, TO_STRING_TAG$3, { 3231 configurable: true, 3232 value: TAG 3233 }); 3234 } 3235 }; 3236 3237 var PROPER_FUNCTION_NAME = functionName.PROPER; 3238 var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE; 3239 var ARRAY_BUFFER = 'ArrayBuffer'; 3240 var DATA_VIEW = 'DataView'; 3241 var PROTOTYPE$1 = 'prototype'; 3242 var WRONG_LENGTH = 'Wrong length'; 3243 var WRONG_INDEX = 'Wrong index'; 3244 var getInternalArrayBufferState = internalState.getterFor(ARRAY_BUFFER); 3245 var getInternalDataViewState = internalState.getterFor(DATA_VIEW); 3246 var setInternalState = internalState.set; 3247 var NativeArrayBuffer = globalThis_1[ARRAY_BUFFER]; 3248 var $ArrayBuffer = NativeArrayBuffer; 3249 var ArrayBufferPrototype = $ArrayBuffer && $ArrayBuffer[PROTOTYPE$1]; 3250 var $DataView = globalThis_1[DATA_VIEW]; 3251 var DataViewPrototype = $DataView && $DataView[PROTOTYPE$1]; 3252 var ObjectPrototype$1 = Object.prototype; 3253 var Array$1 = globalThis_1.Array; 3254 var RangeError$1 = globalThis_1.RangeError; 3255 var fill = functionUncurryThis(arrayFill); 3256 var reverse = functionUncurryThis([].reverse); 3257 var packIEEE754 = ieee754.pack; 3258 var unpackIEEE754 = ieee754.unpack; 3259 var packInt8 = function (number) { 3260 return [number & 0xFF]; 3261 }; 3262 var packInt16 = function (number) { 3263 return [number & 0xFF, number >> 8 & 0xFF]; 3264 }; 3265 var packInt32 = function (number) { 3266 return [number & 0xFF, number >> 8 & 0xFF, number >> 16 & 0xFF, number >> 24 & 0xFF]; 3267 }; 3268 var unpackInt32 = function (buffer) { 3269 return buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0]; 3270 }; 3271 var packFloat32 = function (number) { 3272 return packIEEE754(mathFround(number), 23, 4); 3273 }; 3274 var packFloat64 = function (number) { 3275 return packIEEE754(number, 52, 8); 3276 }; 3277 var addGetter = function (Constructor, key, getInternalState) { 3278 defineBuiltInAccessor(Constructor[PROTOTYPE$1], key, { 3279 configurable: true, 3280 get: function () { 3281 return getInternalState(this)[key]; 3282 } 3283 }); 3284 }; 3285 var get$1 = function (view, count, index, isLittleEndian) { 3286 var store = getInternalDataViewState(view); 3287 var intIndex = toIndex(index); 3288 var boolIsLittleEndian = !!isLittleEndian; 3289 if (intIndex + count > store.byteLength) throw new RangeError$1(WRONG_INDEX); 3290 var bytes = store.bytes; 3291 var start = intIndex + store.byteOffset; 3292 var pack = arraySlice(bytes, start, start + count); 3293 return boolIsLittleEndian ? pack : reverse(pack); 3294 }; 3295 var set$1 = function (view, count, index, conversion, value, isLittleEndian) { 3296 var store = getInternalDataViewState(view); 3297 var intIndex = toIndex(index); 3298 var pack = conversion(+value); 3299 var boolIsLittleEndian = !!isLittleEndian; 3300 if (intIndex + count > store.byteLength) throw new RangeError$1(WRONG_INDEX); 3301 var bytes = store.bytes; 3302 var start = intIndex + store.byteOffset; 3303 for (var i = 0; i < count; i++) bytes[start + i] = pack[boolIsLittleEndian ? i : count - i - 1]; 3304 }; 3305 if (!arrayBufferBasicDetection) { 3306 $ArrayBuffer = function ArrayBuffer(length) { 3307 anInstance(this, ArrayBufferPrototype); 3308 var byteLength = toIndex(length); 3309 setInternalState(this, { 3310 type: ARRAY_BUFFER, 3311 bytes: fill(Array$1(byteLength), 0), 3312 byteLength: byteLength 3313 }); 3314 if (!descriptors) { 3315 this.byteLength = byteLength; 3316 this.detached = false; 3317 } 3318 }; 3319 ArrayBufferPrototype = $ArrayBuffer[PROTOTYPE$1]; 3320 $DataView = function DataView(buffer, byteOffset, byteLength) { 3321 anInstance(this, DataViewPrototype); 3322 anInstance(buffer, ArrayBufferPrototype); 3323 var bufferState = getInternalArrayBufferState(buffer); 3324 var bufferLength = bufferState.byteLength; 3325 var offset = toIntegerOrInfinity(byteOffset); 3326 if (offset < 0 || offset > bufferLength) throw new RangeError$1('Wrong offset'); 3327 byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength); 3328 if (offset + byteLength > bufferLength) throw new RangeError$1(WRONG_LENGTH); 3329 setInternalState(this, { 3330 type: DATA_VIEW, 3331 buffer: buffer, 3332 byteLength: byteLength, 3333 byteOffset: offset, 3334 bytes: bufferState.bytes 3335 }); 3336 if (!descriptors) { 3337 this.buffer = buffer; 3338 this.byteLength = byteLength; 3339 this.byteOffset = offset; 3340 } 3341 }; 3342 DataViewPrototype = $DataView[PROTOTYPE$1]; 3343 if (descriptors) { 3344 addGetter($ArrayBuffer, 'byteLength', getInternalArrayBufferState); 3345 addGetter($DataView, 'buffer', getInternalDataViewState); 3346 addGetter($DataView, 'byteLength', getInternalDataViewState); 3347 addGetter($DataView, 'byteOffset', getInternalDataViewState); 3348 } 3349 defineBuiltIns(DataViewPrototype, { 3350 getInt8: function getInt8(byteOffset) { 3351 return get$1(this, 1, byteOffset)[0] << 24 >> 24; 3352 }, 3353 getUint8: function getUint8(byteOffset) { 3354 return get$1(this, 1, byteOffset)[0]; 3355 }, 3356 getInt16: function getInt16(byteOffset /* , littleEndian */) { 3357 var bytes = get$1(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : false); 3358 return (bytes[1] << 8 | bytes[0]) << 16 >> 16; 3359 }, 3360 getUint16: function getUint16(byteOffset /* , littleEndian */) { 3361 var bytes = get$1(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : false); 3362 return bytes[1] << 8 | bytes[0]; 3363 }, 3364 getInt32: function getInt32(byteOffset /* , littleEndian */) { 3365 return unpackInt32(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : false)); 3366 }, 3367 getUint32: function getUint32(byteOffset /* , littleEndian */) { 3368 return unpackInt32(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : false)) >>> 0; 3369 }, 3370 getFloat32: function getFloat32(byteOffset /* , littleEndian */) { 3371 return unpackIEEE754(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : false), 23); 3372 }, 3373 getFloat64: function getFloat64(byteOffset /* , littleEndian */) { 3374 return unpackIEEE754(get$1(this, 8, byteOffset, arguments.length > 1 ? arguments[1] : false), 52); 3375 }, 3376 setInt8: function setInt8(byteOffset, value) { 3377 set$1(this, 1, byteOffset, packInt8, value); 3378 }, 3379 setUint8: function setUint8(byteOffset, value) { 3380 set$1(this, 1, byteOffset, packInt8, value); 3381 }, 3382 setInt16: function setInt16(byteOffset, value /* , littleEndian */) { 3383 set$1(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : false); 3384 }, 3385 setUint16: function setUint16(byteOffset, value /* , littleEndian */) { 3386 set$1(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : false); 3387 }, 3388 setInt32: function setInt32(byteOffset, value /* , littleEndian */) { 3389 set$1(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : false); 3390 }, 3391 setUint32: function setUint32(byteOffset, value /* , littleEndian */) { 3392 set$1(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : false); 3393 }, 3394 setFloat32: function setFloat32(byteOffset, value /* , littleEndian */) { 3395 set$1(this, 4, byteOffset, packFloat32, value, arguments.length > 2 ? arguments[2] : false); 3396 }, 3397 setFloat64: function setFloat64(byteOffset, value /* , littleEndian */) { 3398 set$1(this, 8, byteOffset, packFloat64, value, arguments.length > 2 ? arguments[2] : false); 3399 } 3400 }); 3401 } else { 3402 var INCORRECT_ARRAY_BUFFER_NAME = PROPER_FUNCTION_NAME && NativeArrayBuffer.name !== ARRAY_BUFFER; 3403 /* eslint-disable no-new, sonarjs/inconsistent-function-call -- required for testing */ 3404 if (!fails(function () { 3405 NativeArrayBuffer(1); 3406 }) || !fails(function () { 3407 new NativeArrayBuffer(-1); 3408 }) || fails(function () { 3409 new NativeArrayBuffer(); 3410 new NativeArrayBuffer(1.5); 3411 new NativeArrayBuffer(NaN); 3412 return NativeArrayBuffer.length !== 1 || INCORRECT_ARRAY_BUFFER_NAME && !CONFIGURABLE_FUNCTION_NAME; 3413 })) { 3414 /* eslint-enable no-new, sonarjs/inconsistent-function-call -- required for testing */ 3415 $ArrayBuffer = function ArrayBuffer(length) { 3416 anInstance(this, ArrayBufferPrototype); 3417 return inheritIfRequired(new NativeArrayBuffer(toIndex(length)), this, $ArrayBuffer); 3418 }; 3419 $ArrayBuffer[PROTOTYPE$1] = ArrayBufferPrototype; 3420 ArrayBufferPrototype.constructor = $ArrayBuffer; 3421 copyConstructorProperties($ArrayBuffer, NativeArrayBuffer); 3422 } else if (INCORRECT_ARRAY_BUFFER_NAME && CONFIGURABLE_FUNCTION_NAME) { 3423 createNonEnumerableProperty(NativeArrayBuffer, 'name', ARRAY_BUFFER); 3424 } 3425 3426 // WebKit bug - the same parent prototype for typed arrays and data view 3427 if (objectSetPrototypeOf && objectGetPrototypeOf(DataViewPrototype) !== ObjectPrototype$1) { 3428 objectSetPrototypeOf(DataViewPrototype, ObjectPrototype$1); 3429 } 3430 3431 // iOS Safari 7.x bug 3432 var testView = new $DataView(new $ArrayBuffer(2)); 3433 var $setInt8 = functionUncurryThis(DataViewPrototype.setInt8); 3434 testView.setInt8(0, 2147483648); 3435 testView.setInt8(1, 2147483649); 3436 if (testView.getInt8(0) || !testView.getInt8(1)) defineBuiltIns(DataViewPrototype, { 3437 setInt8: function setInt8(byteOffset, value) { 3438 $setInt8(this, byteOffset, value << 24 >> 24); 3439 }, 3440 setUint8: function setUint8(byteOffset, value) { 3441 $setInt8(this, byteOffset, value << 24 >> 24); 3442 } 3443 }, { 3444 unsafe: true 3445 }); 3446 } 3447 setToStringTag($ArrayBuffer, ARRAY_BUFFER); 3448 setToStringTag($DataView, DATA_VIEW); 3449 var arrayBuffer = { 3450 ArrayBuffer: $ArrayBuffer, 3451 DataView: $DataView 3452 }; 3453 3454 var ArrayBuffer$1 = arrayBuffer.ArrayBuffer; 3455 var DataView$1 = arrayBuffer.DataView; 3456 var DataViewPrototype$1 = DataView$1.prototype; 3457 var nativeArrayBufferSlice = functionUncurryThisClause(ArrayBuffer$1.prototype.slice); 3458 var getUint8 = functionUncurryThisClause(DataViewPrototype$1.getUint8); 3459 var setUint8 = functionUncurryThisClause(DataViewPrototype$1.setUint8); 3460 var INCORRECT_SLICE = fails(function () {
3461 return !new ArrayBuffer$1(2).slice(1, undefined).byteLength; 3462 }); 3463 3464 // `ArrayBuffer.prototype.slice` method 3465 // https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice 3466 _export({ 3467 target: 'ArrayBuffer', 3468 proto: true, 3469 unsafe: true, 3470 forced: INCORRECT_SLICE 3471 }, { 3472 slice: function slice(start, end) { 3473 if (nativeArrayBufferSlice && end === undefined) { 3474 return nativeArrayBufferSlice(anObject(this), start); // FF fix 3475 } 3476 3477 var length = anObject(this).byteLength; 3478 var first = toAbsoluteIndex(start, length); 3479 var fin = toAbsoluteIndex(end === undefined ? length : end, length); 3480 var result = new ArrayBuffer$1(toLength(fin - first)); 3481 var viewSource = new DataView$1(this); 3482 var viewTarget = new DataView$1(result); 3483 var index = 0; 3484 while (first < fin) { 3485 setUint8(viewTarget, index++, getUint8(viewSource, first++)); 3486 } 3487 return result; 3488 } 3489 }); 3490 3491 var createProperty = function (object, key, value) { 3492 if (descriptors) objectDefineProperty.f(object, key, createPropertyDescriptor(0, value));else object[key] = value; 3493 }; 3494 3495 // `Object.fromEntries` method 3496 // https://tc39.es/ecma262/#sec-object.fromentries 3497 _export({ 3498 target: 'Object', 3499 stat: true 3500 }, { 3501 fromEntries: function fromEntries(iterable) { 3502 var obj = {}; 3503 iterate(iterable, function (k, v) { 3504 createProperty(obj, k, v); 3505 }, { 3506 AS_ENTRIES: true 3507 }); 3508 return obj; 3509 } 3510 }); 3511 3512 // `Object.hasOwn` method 3513 // https://tc39.es/ecma262/#sec-object.hasown 3514 _export({ 3515 target: 'Object', 3516 stat: true 3517 }, { 3518 hasOwn: hasOwnProperty_1 3519 }); 3520 3521 var $TypeError$a = TypeError; 3522 var PromiseCapability = function (C) { 3523 var resolve, reject; 3524 this.promise = new C(function ($$resolve, $$reject) { 3525 if (resolve !== undefined || reject !== undefined) throw new $TypeError$a('Bad Promise constructor'); 3526 resolve = $$resolve; 3527 reject = $$reject; 3528 }); 3529 this.resolve = aCallable(resolve); 3530 this.reject = aCallable(reject); 3531 }; 3532 3533 // `NewPromiseCapability` abstract operation 3534 // https://tc39.es/ecma262/#sec-newpromisecapability 3535 var f$6 = function (C) { 3536 return new PromiseCapability(C); 3537 }; 3538 3539 var newPromiseCapability = { 3540 f: f$6 3541 }; 3542 3543 var perform = function (exec) { 3544 try { 3545 return { 3546 error: false, 3547 value: exec() 3548 }; 3549 } catch (error) { 3550 return { 3551 error: true, 3552 value: error 3553 }; 3554 } 3555 }; 3556 3557 var promiseNativeConstructor = globalThis_1.Promise; 3558 3559 var ITERATOR$2 = wellKnownSymbol('iterator'); 3560 var SAFE_CLOSING = false; 3561 var checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) { 3562 try { 3563 if (!SKIP_CLOSING && !SAFE_CLOSING) return false; 3564 } catch (error) { 3565 return false; 3566 } // workaround of old WebKit + `eval` bug 3567 var ITERATION_SUPPORT = false; 3568 try { 3569 var object = {}; 3570 object[ITERATOR$2] = function () { 3571 return { 3572 next: function () { 3573 return { 3574 done: ITERATION_SUPPORT = true 3575 }; 3576 } 3577 }; 3578 }; 3579 exec(object); 3580 } catch (error) {/* empty */} 3581 return ITERATION_SUPPORT; 3582 }; 3583 3584 /* global Bun, Deno -- detection */ 3585 3586 3587 3588 var userAgentStartsWith = function (string) { 3589 return environmentUserAgent.slice(0, string.length) === string; 3590 }; 3591 var environment = function () { 3592 if (userAgentStartsWith('Bun/')) return 'BUN'; 3593 if (userAgentStartsWith('Cloudflare-Workers')) return 'CLOUDFLARE'; 3594 if (userAgentStartsWith('Deno/')) return 'DENO'; 3595 if (userAgentStartsWith('Node.js/')) return 'NODE'; 3596 if (globalThis_1.Bun && typeof Bun.version == 'string') return 'BUN'; 3597 if (globalThis_1.Deno && typeof Deno.version == 'object') return 'DENO'; 3598 if (classofRaw(globalThis_1.process) === 'process') return 'NODE'; 3599 if (globalThis_1.window && globalThis_1.document) return 'BROWSER'; 3600 return 'REST'; 3601 }(); 3602 3603 var NativePromisePrototype = promiseNativeConstructor && promiseNativeConstructor.prototype; 3604 var SPECIES = wellKnownSymbol('species'); 3605 var SUBCLASSING = false; 3606 var NATIVE_PROMISE_REJECTION_EVENT = isCallable(globalThis_1.PromiseRejectionEvent); 3607 var FORCED_PROMISE_CONSTRUCTOR = isForced_1('Promise', function () { 3608 var PROMISE_CONSTRUCTOR_SOURCE = inspectSource(promiseNativeConstructor); 3609 var GLOBAL_CORE_JS_PROMISE = PROMISE_CONSTRUCTOR_SOURCE !== String(promiseNativeConstructor); 3610 // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables 3611 // https://bugs.chromium.org/p/chromium/issues/detail?id=830565 3612 // We can't detect it synchronously, so just check versions 3613 if (!GLOBAL_CORE_JS_PROMISE && environmentV8Version === 66) return true; 3614 // We can't use @@species feature detection in V8 since it causes 3615 // deoptimization and performance degradation 3616 // https://github.com/zloirock/core-js/issues/679 3617 if (!environmentV8Version || environmentV8Version < 51 || !/native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) { 3618 // Detect correctness of subclassing with @@species support 3619 var promise = new promiseNativeConstructor(function (resolve) { 3620 resolve(1); 3621 }); 3622 var FakePromise = function (exec) { 3623 exec(function () {/* empty */}, function () {/* empty */}); 3624 }; 3625 var constructor = promise.constructor = {}; 3626 constructor[SPECIES] = FakePromise; 3627 SUBCLASSING = promise.then(function () {/* empty */}) instanceof FakePromise; 3628 if (!SUBCLASSING) return true; 3629 // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test 3630 } 3631 return !GLOBAL_CORE_JS_PROMISE && (environment === 'BROWSER' || environment === 'DENO') && !NATIVE_PROMISE_REJECTION_EVENT; 3632 }); 3633 var promiseConstructorDetection = { 3634 CONSTRUCTOR: FORCED_PROMISE_CONSTRUCTOR, 3635 REJECTION_EVENT: NATIVE_PROMISE_REJECTION_EVENT, 3636 SUBCLASSING: SUBCLASSING 3637 }; 3638 3639 var FORCED_PROMISE_CONSTRUCTOR$1 = promiseConstructorDetection.CONSTRUCTOR; 3640 var promiseStaticsIncorrectIteration = FORCED_PROMISE_CONSTRUCTOR$1 || !checkCorrectnessOfIteration(function (iterable) { 3641 promiseNativeConstructor.all(iterable).then(undefined, function () {/* empty */}); 3642 }); 3643 3644 // `Promise.allSettled` method 3645 // https://tc39.es/ecma262/#sec-promise.allsettled 3646 _export({ 3647 target: 'Promise', 3648 stat: true, 3649 forced: promiseStaticsIncorrectIteration 3650 }, { 3651 allSettled: function allSettled(iterable) { 3652 var C = this; 3653 var capability = newPromiseCapability.f(C); 3654 var resolve = capability.resolve; 3655 var reject = capability.reject; 3656 var result = perform(function () { 3657 var promiseResolve = aCallable(C.resolve); 3658 var values = []; 3659 var counter = 0; 3660 var remaining = 1; 3661 iterate(iterable, function (promise) { 3662 var index = counter++; 3663 var alreadyCalled = false;
vendor: 17,489 bytes, lines 3664-4180
3664 remaining++; 3665 functionCall(promiseResolve, C, promise).then(function (value) { 3666 if (alreadyCalled) return; 3667 alreadyCalled = true; 3668 values[index] = { 3669 status: 'fulfilled', 3670 value: value 3671 }; 3672 --remaining || resolve(values); 3673 }, function (error) { 3674 if (alreadyCalled) return; 3675 alreadyCalled = true; 3676 values[index] = { 3677 status: 'rejected', 3678 reason: error 3679 }; 3680 --remaining || resolve(values); 3681 }); 3682 }); 3683 --remaining || resolve(values); 3684 }); 3685 if (result.error) reject(result.value); 3686 return capability.promise; 3687 } 3688 }); 3689 3690 var PROMISE_ANY_ERROR = 'No one promise resolved'; 3691 3692 // `Promise.any` method 3693 // https://tc39.es/ecma262/#sec-promise.any 3694 _export({ 3695 target: 'Promise', 3696 stat: true, 3697 forced: promiseStaticsIncorrectIteration 3698 }, { 3699 any: function any(iterable) { 3700 var C = this; 3701 var AggregateError = getBuiltIn('AggregateError'); 3702 var capability = newPromiseCapability.f(C); 3703 var resolve = capability.resolve; 3704 var reject = capability.reject; 3705 var result = perform(function () { 3706 var promiseResolve = aCallable(C.resolve); 3707 var errors = []; 3708 var counter = 0; 3709 var remaining = 1; 3710 var alreadyResolved = false; 3711 iterate(iterable, function (promise) { 3712 var index = counter++; 3713 var alreadyRejected = false; 3714 remaining++; 3715 functionCall(promiseResolve, C, promise).then(function (value) { 3716 if (alreadyRejected || alreadyResolved) return; 3717 alreadyResolved = true; 3718 resolve(value); 3719 }, function (error) { 3720 if (alreadyRejected || alreadyResolved) return; 3721 alreadyRejected = true; 3722 errors[index] = error; 3723 --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR)); 3724 }); 3725 }); 3726 --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR)); 3727 }); 3728 if (result.error) reject(result.value); 3729 return capability.promise; 3730 } 3731 }); 3732 3733 var noop = function () {/* empty */}; 3734 var construct = getBuiltIn('Reflect', 'construct'); 3735 var constructorRegExp = /^\s*(?:class|function)\b/; 3736 var exec = functionUncurryThis(constructorRegExp.exec); 3737 var INCORRECT_TO_STRING = !constructorRegExp.test(noop); 3738 var isConstructorModern = function isConstructor(argument) { 3739 if (!isCallable(argument)) return false; 3740 try { 3741 construct(noop, [], argument); 3742 return true; 3743 } catch (error) { 3744 return false; 3745 } 3746 }; 3747 var isConstructorLegacy = function isConstructor(argument) { 3748 if (!isCallable(argument)) return false; 3749 switch (classof(argument)) { 3750 case 'AsyncFunction': 3751 case 'GeneratorFunction': 3752 case 'AsyncGeneratorFunction': 3753 return false; 3754 } 3755 try { 3756 // we can't check .prototype since constructors produced by .bind haven't it 3757 // `Function#toString` throws on some built-it function in some legacy engines 3758 // (for example, `DOMQuad` and similar in FF41-) 3759 return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument)); 3760 } catch (error) { 3761 return true; 3762 } 3763 }; 3764 isConstructorLegacy.sham = true; 3765 3766 // `IsConstructor` abstract operation 3767 // https://tc39.es/ecma262/#sec-isconstructor 3768 var isConstructor = !construct || fails(function () { 3769 var called; 3770 return isConstructorModern(isConstructorModern.call) || !isConstructorModern(Object) || !isConstructorModern(function () { 3771 called = true; 3772 }) || called; 3773 }) ? isConstructorLegacy : isConstructorModern; 3774 3775 var $TypeError$b = TypeError; 3776 3777 // `Assert: IsConstructor(argument) is true` 3778 var aConstructor = function (argument) { 3779 if (isConstructor(argument)) return argument; 3780 throw new $TypeError$b(tryToString(argument) + ' is not a constructor'); 3781 }; 3782 3783 var SPECIES$1 = wellKnownSymbol('species'); 3784 3785 // `SpeciesConstructor` abstract operation 3786 // https://tc39.es/ecma262/#sec-speciesconstructor 3787 var speciesConstructor = function (O, defaultConstructor) { 3788 var C = anObject(O).constructor; 3789 var S; 3790 return C === undefined || isNullOrUndefined(S = anObject(C)[SPECIES$1]) ? defaultConstructor : aConstructor(S); 3791 }; 3792 3793 var promiseResolve = function (C, x) { 3794 anObject(C); 3795 if (isObject(x) && x.constructor === C) return x; 3796 var promiseCapability = newPromiseCapability.f(C); 3797 var resolve = promiseCapability.resolve; 3798 resolve(x); 3799 return promiseCapability.promise; 3800 }; 3801 3802 var NativePromisePrototype$1 = promiseNativeConstructor && promiseNativeConstructor.prototype; 3803 3804 // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829 3805 var NON_GENERIC = !!promiseNativeConstructor && fails(function () { 3806 // eslint-disable-next-line unicorn/no-thenable -- required for testing 3807 NativePromisePrototype$1['finally'].call({ 3808 then: function () {/* empty */} 3809 }, function () {/* empty */}); 3810 }); 3811 3812 // `Promise.prototype.finally` method 3813 // https://tc39.es/ecma262/#sec-promise.prototype.finally 3814 _export({ 3815 target: 'Promise', 3816 proto: true, 3817 real: true, 3818 forced: NON_GENERIC 3819 }, { 3820 'finally': function (onFinally) { 3821 var C = speciesConstructor(this, getBuiltIn('Promise')); 3822 var isFunction = isCallable(onFinally); 3823 return this.then(isFunction ? function (x) { 3824 return promiseResolve(C, onFinally()).then(function () { 3825 return x; 3826 }); 3827 } : onFinally, isFunction ? function (e) { 3828 return promiseResolve(C, onFinally()).then(function () { 3829 throw e; 3830 }); 3831 } : onFinally); 3832 } 3833 }); 3834 3835 // makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then` 3836 if (!isPure && isCallable(promiseNativeConstructor)) { 3837 var method = getBuiltIn('Promise').prototype['finally']; 3838 if (NativePromisePrototype$1['finally'] !== method) { 3839 defineBuiltIn(NativePromisePrototype$1, 'finally', method, { 3840 unsafe: true 3841 }); 3842 } 3843 } 3844 3845 var ITERATOR$3 = wellKnownSymbol('iterator'); 3846 var BUGGY_SAFARI_ITERATORS = false; 3847 3848 // `%IteratorPrototype%` object 3849 // https://tc39.es/ecma262/#sec-%iteratorprototype%-object 3850 var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator; 3851 3852 /* eslint-disable es/no-array-prototype-keys -- safe */ 3853 if ([].keys) { 3854 arrayIterator = [].keys(); 3855 // Safari 8 has buggy iterators w/o `next` 3856 if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;else { 3857 PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator)); 3858 if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype; 3859 } 3860 } 3861 var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype) || fails(function () { 3862 var test = {}; 3863 // FF44- legacy iterators case 3864 return IteratorPrototype[ITERATOR$3].call(test) !== test; 3865 }); 3866 if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {}; 3867 3868 // `%IteratorPrototype%[@@iterator]()` method 3869 // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator 3870 if (!isCallable(IteratorPrototype[ITERATOR$3])) { 3871 defineBuiltIn(IteratorPrototype, ITERATOR$3, function () { 3872 return this; 3873 }); 3874 } 3875 var iteratorsCore = { 3876 IteratorPrototype: IteratorPrototype, 3877 BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS 3878 }; 3879 3880 var IteratorPrototype$1 = iteratorsCore.IteratorPrototype; 3881 3882 3883 3884 3885 var returnThis = function () { 3886 return this; 3887 }; 3888 var iteratorCreateConstructor = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) { 3889 var TO_STRING_TAG = NAME + ' Iterator'; 3890 IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, { 3891 next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) 3892 }); 3893 setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true); 3894 iterators[TO_STRING_TAG] = returnThis; 3895 return IteratorConstructor; 3896 }; 3897 3898 // `CreateIterResultObject` abstract operation 3899 // https://tc39.es/ecma262/#sec-createiterresultobject 3900 var createIterResultObject = function (value, done) { 3901 return { 3902 value: value, 3903 done: done 3904 }; 3905 }; 3906 3907 var MATCH = wellKnownSymbol('match'); 3908 3909 // `IsRegExp` abstract operation 3910 // https://tc39.es/ecma262/#sec-isregexp 3911 var isRegexp = function (it) { 3912 var isRegExp; 3913 return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classofRaw(it) === 'RegExp'); 3914 }; 3915 3916 // `RegExp.prototype.flags` getter implementation 3917 // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags 3918 var regexpFlags = function () { 3919 var that = anObject(this); 3920 var result = ''; 3921 if (that.hasIndices) result += 'd'; 3922 if (that.global) result += 'g'; 3923 if (that.ignoreCase) result += 'i'; 3924 if (that.multiline) result += 'm'; 3925 if (that.dotAll) result += 's'; 3926 if (that.unicode) result += 'u'; 3927 if (that.unicodeSets) result += 'v'; 3928 if (that.sticky) result += 'y'; 3929 return result; 3930 }; 3931 3932 var RegExpPrototype = RegExp.prototype; 3933 var regexpGetFlags = function (R) { 3934 var flags = R.flags; 3935 return flags === undefined && !('flags' in RegExpPrototype) && !hasOwnProperty_1(R, 'flags') && objectIsPrototypeOf(RegExpPrototype, R) ? functionCall(regexpFlags, R) : flags; 3936 }; 3937 3938 var charAt = functionUncurryThis(''.charAt); 3939 var charCodeAt = functionUncurryThis(''.charCodeAt); 3940 var stringSlice$1 = functionUncurryThis(''.slice); 3941 var createMethod$1 = function (CONVERT_TO_STRING) { 3942 return function ($this, pos) { 3943 var S = toString_1(requireObjectCoercible($this)); 3944 var position = toIntegerOrInfinity(pos); 3945 var size = S.length; 3946 var first, second; 3947 if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined; 3948 first = charCodeAt(S, position); 3949 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; 3950 }; 3951 }; 3952 var stringMultibyte = { 3953 // `String.prototype.codePointAt` method 3954 // https://tc39.es/ecma262/#sec-string.prototype.codepointat 3955 codeAt: createMethod$1(false), 3956 // `String.prototype.at` method 3957 // https://github.com/mathiasbynens/String.prototype.at 3958 charAt: createMethod$1(true) 3959 }; 3960 3961 var charAt$1 = stringMultibyte.charAt; 3962 3963 // `AdvanceStringIndex` abstract operation 3964 // https://tc39.es/ecma262/#sec-advancestringindex 3965 var advanceStringIndex = function (S, index, unicode) { 3966 return index + (unicode ? charAt$1(S, index).length : 1); 3967 }; 3968 3969 // babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError 3970 var $RegExp = globalThis_1.RegExp; 3971 var UNSUPPORTED_Y = fails(function () { 3972 var re = $RegExp('a', 'y'); 3973 re.lastIndex = 2; 3974 return re.exec('abcd') !== null; 3975 }); 3976 3977 // UC Browser bug 3978 // https://github.com/zloirock/core-js/issues/1008 3979 var MISSED_STICKY = UNSUPPORTED_Y || fails(function () { 3980 return !$RegExp('a', 'y').sticky; 3981 }); 3982 var BROKEN_CARET = UNSUPPORTED_Y || fails(function () { 3983 // https://bugzilla.mozilla.org/show_bug.cgi?id=773687 3984 var re = $RegExp('^r', 'gy'); 3985 re.lastIndex = 2; 3986 return re.exec('str') !== null; 3987 }); 3988 var regexpStickyHelpers = { 3989 BROKEN_CARET: BROKEN_CARET, 3990 MISSED_STICKY: MISSED_STICKY, 3991 UNSUPPORTED_Y: UNSUPPORTED_Y 3992 }; 3993 3994 // babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError 3995 var $RegExp$1 = globalThis_1.RegExp; 3996 var regexpUnsupportedDotAll = fails(function () { 3997 var re = $RegExp$1('.', 's'); 3998 return !(re.dotAll && re.test('\n') && re.flags === 's'); 3999 }); 4000 4001 // babel-minify and Closure Compiler transpiles RegExp('(?<a>b)', 'g') -> /(?<a>b)/g and it causes SyntaxError 4002 var $RegExp$2 = globalThis_1.RegExp; 4003 var regexpUnsupportedNcg = fails(function () { 4004 var re = $RegExp$2('(?<a>b)', 'g'); 4005 return re.exec('b').groups.a !== 'b' || 'b'.replace(re, '$<a>c') !== 'bc'; 4006 }); 4007 4008 /* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */ 4009 /* eslint-disable regexp/no-useless-quantifier -- testing */ 4010 4011 4012 4013 4014 4015 4016 4017 var getInternalState = internalState.get; 4018 4019 4020 var nativeReplace = shared('native-string-replace', String.prototype.replace); 4021 var nativeExec = RegExp.prototype.exec; 4022 var patchedExec = nativeExec; 4023 var charAt$2 = functionUncurryThis(''.charAt); 4024 var indexOf$1 = functionUncurryThis(''.indexOf); 4025 var replace$1 = functionUncurryThis(''.replace); 4026 var stringSlice$2 = functionUncurryThis(''.slice); 4027 var UPDATES_LAST_INDEX_WRONG = function () { 4028 var re1 = /a/; 4029 var re2 = /b*/g; 4030 functionCall(nativeExec, re1, 'a'); 4031 functionCall(nativeExec, re2, 'a'); 4032 return re1.lastIndex !== 0 || re2.lastIndex !== 0; 4033 }(); 4034 var UNSUPPORTED_Y$1 = regexpStickyHelpers.BROKEN_CARET; 4035 4036 // nonparticipating capturing group, copied from es5-shim's String#split patch. 4037 var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; 4038 var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$1 || regexpUnsupportedDotAll || regexpUnsupportedNcg; 4039 if (PATCH) { 4040 patchedExec = function exec(string) { 4041 var re = this; 4042 var state = getInternalState(re); 4043 var str = toString_1(string); 4044 var raw = state.raw; 4045 var result, reCopy, lastIndex, match, i, object, group; 4046 if (raw) { 4047 raw.lastIndex = re.lastIndex; 4048 result = functionCall(patchedExec, raw, str); 4049 re.lastIndex = raw.lastIndex; 4050 return result; 4051 } 4052 var groups = state.groups; 4053 var sticky = UNSUPPORTED_Y$1 && re.sticky; 4054 var flags = functionCall(regexpFlags, re); 4055 var source = re.source; 4056 var charsAdded = 0; 4057 var strCopy = str; 4058 if (sticky) { 4059 flags = replace$1(flags, 'y', ''); 4060 if (indexOf$1(flags, 'g') === -1) { 4061 flags += 'g'; 4062 } 4063 strCopy = stringSlice$2(str, re.lastIndex); 4064 // Support anchored sticky behavior. 4065 if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$2(str, re.lastIndex - 1) !== '\n')) { 4066 source = '(?: ' + source + ')'; 4067 strCopy = ' ' + strCopy; 4068 charsAdded++; 4069 } 4070 // ^(? + rx + ) is needed, in combination with some str slicing, to 4071 // simulate the 'y' flag. 4072 reCopy = new RegExp('^(?:' + source + ')', flags); 4073 } 4074 if (NPCG_INCLUDED) { 4075 reCopy = new RegExp('^' + source + '$(?!\\s)', flags); 4076 } 4077 if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex; 4078 match = functionCall(nativeExec, sticky ? reCopy : re, strCopy); 4079 if (sticky) { 4080 if (match) { 4081 match.input = stringSlice$2(match.input, charsAdded); 4082 match[0] = stringSlice$2(match[0], charsAdded); 4083 match.index = re.lastIndex; 4084 re.lastIndex += match[0].length; 4085 } else re.lastIndex = 0; 4086 } else if (UPDATES_LAST_INDEX_WRONG && match) { 4087 re.lastIndex = re.global ? match.index + match[0].length : lastIndex; 4088 } 4089 if (NPCG_INCLUDED && match && match.length > 1) { 4090 // Fix browsers whose `exec` methods don't consistently return `undefined` 4091 // for NPCG, like IE8. NOTE: This doesn't work for /(.?)?/ 4092 functionCall(nativeReplace, match[0], reCopy, function () { 4093 for (i = 1; i < arguments.length - 2; i++) { 4094 if (arguments[i] === undefined) match[i] = undefined; 4095 } 4096 }); 4097 } 4098 if (match && groups) { 4099 match.groups = object = objectCreate(null); 4100 for (i = 0; i < groups.length; i++) { 4101 group = groups[i]; 4102 object[group[0]] = match[group[1]]; 4103 } 4104 } 4105 return match; 4106 }; 4107 } 4108 var regexpExec = patchedExec; 4109 4110 var $TypeError$c = TypeError; 4111 4112 // `RegExpExec` abstract operation 4113 // https://tc39.es/ecma262/#sec-regexpexec 4114 var regexpExecAbstract = function (R, S) { 4115 var exec = R.exec; 4116 if (isCallable(exec)) { 4117 var result = functionCall(exec, R, S); 4118 if (result !== null) anObject(result); 4119 return result; 4120 } 4121 if (classofRaw(R) === 'RegExp') return functionCall(regexpExec, R, S); 4122 throw new $TypeError$c('RegExp#exec called on incompatible receiver'); 4123 }; 4124 4125 /* eslint-disable es/no-string-prototype-matchall -- safe */ 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$1 = internalState.getterFor(REGEXP_STRING_ITERATOR); 4153 var RegExpPrototype$1 = RegExp.prototype; 4154 var $TypeError$d = TypeError; 4155 var stringIndexOf = functionUncurryThisClause(''.indexOf); 4156 var nativeMatchAll = functionUncurryThisClause(''.matchAll); 4157 var WORKS_WITH_NON_GLOBAL_REGEX = !!nativeMatchAll && !fails(function () { 4158 nativeMatchAll('a', /./); 4159 }); 4160 var $RegExpStringIterator = iteratorCreateConstructor(function RegExpStringIterator(regexp, string, $global, fullUnicode) { 4161 setInternalState$1(this, { 4162 type: REGEXP_STRING_ITERATOR, 4163 regexp: regexp, 4164 string: string, 4165 global: $global, 4166 unicode: fullUnicode, 4167 done: false 4168 }); 4169 }, REGEXP_STRING, function next() { 4170 var state = getInternalState$1(this); 4171 if (state.done) return createIterResultObject(undefined, true); 4172 var R = state.regexp; 4173 var S = state.string; 4174 var match = regexpExecAbstract(R, S); 4175 if (match === null) { 4176 state.done = true; 4177 return createIterResultObject(undefined, true); 4178 } 4179 if (state.global) { 4180 if (toString_1(match[0]) === '') R.lastIndex = advanceStringIndex(S, toLe
vendor: 6,629 bytes, lines 4180-4337
4180ngth(R.lastIndex), state.unicode); 4181 return createIterResultObject(match, false); 4182 } 4183 state.done = true; 4184 return createIterResultObject(match, false); 4185 }); 4186 var $matchAll = function (string) { 4187 var R = anObject(this); 4188 var S = toString_1(string); 4189 var C = speciesConstructor(R, RegExp); 4190 var flags = toString_1(regexpGetFlags(R)); 4191 var matcher, $global, fullUnicode; 4192 matcher = new C(C === RegExp ? R.source : R, flags); 4193 $global = !!~stringIndexOf(flags, 'g'); 4194 fullUnicode = !!~stringIndexOf(flags, 'u'); 4195 matcher.lastIndex = toLength(R.lastIndex); 4196 return new $RegExpStringIterator(matcher, S, $global, fullUnicode); 4197 }; 4198 4199 // `String.prototype.matchAll` method 4200 // https://tc39.es/ecma262/#sec-string.prototype.matchall 4201 _export({ 4202 target: 'String', 4203 proto: true, 4204 forced: WORKS_WITH_NON_GLOBAL_REGEX 4205 }, { 4206 matchAll: function matchAll(regexp) { 4207 var O = requireObjectCoercible(this); 4208 var flags, S, matcher, rx; 4209 if (!isNullOrUndefined(regexp)) { 4210 if (isRegexp(regexp)) { 4211 flags = toString_1(requireObjectCoercible(regexpGetFlags(regexp))); 4212 if (!~stringIndexOf(flags, 'g')) throw new $TypeError$d('`.matchAll` does not allow non-global regexes'); 4213 } 4214 if (WORKS_WITH_NON_GLOBAL_REGEX) return nativeMatchAll(O, regexp); 4215 matcher = getMethod(regexp, MATCH_ALL); 4216 if (matcher === undefined && isPure && classofRaw(regexp) === 'RegExp') matcher = $matchAll; 4217 if (matcher) return functionCall(matcher, regexp, O); 4218 } else if (WORKS_WITH_NON_GLOBAL_REGEX) return nativeMatchAll(O, regexp); 4219 S = toString_1(O); 4220 rx = new RegExp(regexp, 'g'); 4221 return isPure ? functionCall($matchAll, rx, S) : rx[MATCH_ALL](S); 4222 } 4223 }); 4224 isPure || MATCH_ALL in RegExpPrototype$1 || defineBuiltIn(RegExpPrototype$1, MATCH_ALL, $matchAll); 4225 4226 var floor$2 = Math.floor; 4227 var charAt$3 = functionUncurryThis(''.charAt); 4228 var replace$2 = functionUncurryThis(''.replace); 4229 var stringSlice$3 = functionUncurryThis(''.slice); 4230 // eslint-disable-next-line redos/no-vulnerable -- safe 4231 var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g; 4232 var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g; 4233 4234 // `GetSubstitution` abstract operation 4235 // https://tc39.es/ecma262/#sec-getsubstitution 4236 var getSubstitution = function (matched, str, position, captures, namedCaptures, replacement) { 4237 var tailPos = position + matched.length; 4238 var m = captures.length; 4239 var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED; 4240 if (namedCaptures !== undefined) { 4241 namedCaptures = toObject(namedCaptures); 4242 symbols = SUBSTITUTION_SYMBOLS; 4243 } 4244 return replace$2(replacement, symbols, function (match, ch) { 4245 var capture; 4246 switch (charAt$3(ch, 0)) { 4247 case '$': 4248 return '$'; 4249 case '&': 4250 return matched; 4251 case '`': 4252 return stringSlice$3(str, 0, position); 4253 case "'": 4254 return stringSlice$3(str, tailPos); 4255 case '<': 4256 capture = namedCaptures[stringSlice$3(ch, 1, -1)]; 4257 break; 4258 default: 4259 // \d\d? 4260 var n = +ch; 4261 if (n === 0) return match; 4262 if (n > m) { 4263 var f = floor$2(n / 10); 4264 if (f === 0) return match; 4265 if (f <= m) return captures[f - 1] === undefined ? charAt$3(ch, 1) : captures[f - 1] + charAt$3(ch, 1); 4266 return match; 4267 } 4268 capture = captures[n - 1]; 4269 } 4270 return capture === undefined ? '' : capture; 4271 }); 4272 }; 4273 4274 var REPLACE = wellKnownSymbol('replace'); 4275 var $TypeError$e = TypeError; 4276 var indexOf$2 = functionUncurryThis(''.indexOf); 4277 var replace$3 = functionUncurryThis(''.replace); 4278 var stringSlice$4 = functionUncurryThis(''.slice); 4279 var max$1 = Math.max; 4280 4281 // `String.prototype.replaceAll` method 4282 // https://tc39.es/ecma262/#sec-string.prototype.replaceall 4283 _export({ 4284 target: 'String', 4285 proto: true 4286 }, { 4287 replaceAll: function replaceAll(searchValue, replaceValue) { 4288 var O = requireObjectCoercible(this); 4289 var IS_REG_EXP, flags, replacer, string, searchString, functionalReplace, searchLength, advanceBy, position, replacement; 4290 var endOfLastMatch = 0; 4291 var result = ''; 4292 if (!isNullOrUndefined(searchValue)) { 4293 IS_REG_EXP = isRegexp(searchValue); 4294 if (IS_REG_EXP) { 4295 flags = toString_1(requireObjectCoercible(regexpGetFlags(searchValue))); 4296 if (!~indexOf$2(flags, 'g')) throw new $TypeError$e('`.replaceAll` does not allow non-global regexes'); 4297 } 4298 replacer = getMethod(searchValue, REPLACE); 4299 if (replacer) return functionCall(replacer, searchValue, O, replaceValue); 4300 if (isPure && IS_REG_EXP) return replace$3(toString_1(O), searchValue, replaceValue); 4301 } 4302 string = toString_1(O); 4303 searchString = toString_1(searchValue); 4304 functionalReplace = isCallable(replaceValue); 4305 if (!functionalReplace) replaceValue = toString_1(replaceValue); 4306 searchLength = searchString.length; 4307 advanceBy = max$1(1, searchLength); 4308 position = indexOf$2(string, searchString); 4309 while (position !== -1) { 4310 replacement = functionalReplace ? toString_1(replaceValue(searchString, position, string)) : getSubstitution(searchString, string, position, [], undefined, replaceValue); 4311 result += stringSlice$4(string, endOfLastMatch, position) + replacement; 4312 endOfLastMatch = position + searchLength; 4313 position = position + advanceBy > string.length ? -1 : indexOf$2(string, searchString, position + advanceBy); 4314 } 4315 if (endOfLastMatch < string.length) { 4316 result += stringSlice$4(string, endOfLastMatch); 4317 } 4318 return result; 4319 } 4320 }); 4321 4322 var enforceInternalState = internalState.enforce; 4323 var getInternalState$2 = internalState.get; 4324 var Int8Array = globalThis_1.Int8Array; 4325 var Int8ArrayPrototype = Int8Array && Int8Array.prototype; 4326 var Uint8ClampedArray = globalThis_1.Uint8ClampedArray; 4327 var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype; 4328 var TypedArray = Int8Array && objectGetPrototypeOf(Int8Array); 4329 var TypedArrayPrototype = Int8ArrayPrototype && objectGetPrototypeOf(Int8ArrayPrototype); 4330 var ObjectPrototype$2 = Object.prototype; 4331 var TypeError$2 = globalThis_1.TypeError; 4332 var TO_STRING_TAG$4 = wellKnownSymbol('toStringTag'); 4333 var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG'); 4334 var TYPED_ARRAY_CONSTRUCTOR = 'TypedArrayConstructor'; 4335 // Fixing native typed arrays in Opera Presto crashes the browser, see #595 4336 var NATIVE_ARRAY_BUFFER_VIEWS = arrayBufferBasicDetection && !!objectSetPrototypeOf && classof(globalThis_1.opera) !== 'Opera'; 4337 var TYPED_ARRAY_TAG_REQUIRED = false;
vendor: 13,836 bytes, lines 4338-4732
4338 var NAME, Constructor, Prototype; 4339 var TypedArrayConstructorsList = { 4340 Int8Array: 1, 4341 Uint8Array: 1, 4342 Uint8ClampedArray: 1, 4343 Int16Array: 2, 4344 Uint16Array: 2, 4345 Int32Array: 4, 4346 Uint32Array: 4, 4347 Float32Array: 4, 4348 Float64Array: 8 4349 }; 4350 var BigIntArrayConstructorsList = { 4351 BigInt64Array: 8, 4352 BigUint64Array: 8 4353 }; 4354 var isView = function isView(it) { 4355 if (!isObject(it)) return false; 4356 var klass = classof(it); 4357 return klass === 'DataView' || hasOwnProperty_1(TypedArrayConstructorsList, klass) || hasOwnProperty_1(BigIntArrayConstructorsList, klass); 4358 }; 4359 var getTypedArrayConstructor = function (it) { 4360 var proto = objectGetPrototypeOf(it); 4361 if (!isObject(proto)) return; 4362 var state = getInternalState$2(proto); 4363 return state && hasOwnProperty_1(state, TYPED_ARRAY_CONSTRUCTOR) ? state[TYPED_ARRAY_CONSTRUCTOR] : getTypedArrayConstructor(proto); 4364 }; 4365 var isTypedArray = function (it) { 4366 if (!isObject(it)) return false; 4367 var klass = classof(it); 4368 return hasOwnProperty_1(TypedArrayConstructorsList, klass) || hasOwnProperty_1(BigIntArrayConstructorsList, klass); 4369 }; 4370 var aTypedArray = function (it) { 4371 if (isTypedArray(it)) return it; 4372 throw new TypeError$2('Target is not a typed array'); 4373 }; 4374 var aTypedArrayConstructor = function (C) { 4375 if (isCallable(C) && (!objectSetPrototypeOf || objectIsPrototypeOf(TypedArray, C))) return C; 4376 throw new TypeError$2(tryToString(C) + ' is not a typed array constructor'); 4377 }; 4378 var exportTypedArrayMethod = function (KEY, property, forced, options) { 4379 if (!descriptors) return; 4380 if (forced) for (var ARRAY in TypedArrayConstructorsList) { 4381 var TypedArrayConstructor = globalThis_1[ARRAY]; 4382 if (TypedArrayConstructor && hasOwnProperty_1(TypedArrayConstructor.prototype, KEY)) try { 4383 delete TypedArrayConstructor.prototype[KEY]; 4384 } catch (error) { 4385 // old WebKit bug - some methods are non-configurable 4386 try { 4387 TypedArrayConstructor.prototype[KEY] = property; 4388 } catch (error2) {/* empty */} 4389 } 4390 } 4391 if (!TypedArrayPrototype[KEY] || forced) { 4392 defineBuiltIn(TypedArrayPrototype, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property, options); 4393 } 4394 }; 4395 var exportTypedArrayStaticMethod = function (KEY, property, forced) { 4396 var ARRAY, TypedArrayConstructor; 4397 if (!descriptors) return; 4398 if (objectSetPrototypeOf) { 4399 if (forced) for (ARRAY in TypedArrayConstructorsList) { 4400 TypedArrayConstructor = globalThis_1[ARRAY]; 4401 if (TypedArrayConstructor && hasOwnProperty_1(TypedArrayConstructor, KEY)) try { 4402 delete TypedArrayConstructor[KEY]; 4403 } catch (error) {/* empty */} 4404 } 4405 if (!TypedArray[KEY] || forced) { 4406 // V8 ~ Chrome 49-50 `%TypedArray%` methods are non-writable non-configurable 4407 try { 4408 return defineBuiltIn(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && TypedArray[KEY] || property); 4409 } catch (error) {/* empty */} 4410 } else return; 4411 } 4412 for (ARRAY in TypedArrayConstructorsList) { 4413 TypedArrayConstructor = globalThis_1[ARRAY]; 4414 if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) { 4415 defineBuiltIn(TypedArrayConstructor, KEY, property); 4416 } 4417 } 4418 }; 4419 for (NAME in TypedArrayConstructorsList) { 4420 Constructor = globalThis_1[NAME]; 4421 Prototype = Constructor && Constructor.prototype; 4422 if (Prototype) enforceInternalState(Prototype)[TYPED_ARRAY_CONSTRUCTOR] = Constructor;else NATIVE_ARRAY_BUFFER_VIEWS = false; 4423 } 4424 for (NAME in BigIntArrayConstructorsList) { 4425 Constructor = globalThis_1[NAME]; 4426 Prototype = Constructor && Constructor.prototype; 4427 if (Prototype) enforceInternalState(Prototype)[TYPED_ARRAY_CONSTRUCTOR] = Constructor; 4428 } 4429 4430 // WebKit bug - typed arrays constructors prototype is Object.prototype 4431 if (!NATIVE_ARRAY_BUFFER_VIEWS || !isCallable(TypedArray) || TypedArray === Function.prototype) { 4432 // eslint-disable-next-line no-shadow -- safe 4433 TypedArray = function TypedArray() { 4434 throw new TypeError$2('Incorrect invocation'); 4435 }; 4436 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { 4437 if (globalThis_1[NAME]) objectSetPrototypeOf(globalThis_1[NAME], TypedArray); 4438 } 4439 } 4440 if (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype$2) { 4441 TypedArrayPrototype = TypedArray.prototype; 4442 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { 4443 if (globalThis_1[NAME]) objectSetPrototypeOf(globalThis_1[NAME].prototype, TypedArrayPrototype); 4444 } 4445 } 4446 4447 // WebKit bug - one more object in Uint8ClampedArray prototype chain 4448 if (NATIVE_ARRAY_BUFFER_VIEWS && objectGetPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) { 4449 objectSetPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype); 4450 } 4451 if (descriptors && !hasOwnProperty_1(TypedArrayPrototype, TO_STRING_TAG$4)) { 4452 TYPED_ARRAY_TAG_REQUIRED = true; 4453 defineBuiltInAccessor(TypedArrayPrototype, TO_STRING_TAG$4, { 4454 configurable: true, 4455 get: function () { 4456 return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined; 4457 } 4458 }); 4459 for (NAME in TypedArrayConstructorsList) if (globalThis_1[NAME]) { 4460 createNonEnumerableProperty(globalThis_1[NAME], TYPED_ARRAY_TAG, NAME); 4461 } 4462 } 4463 var arrayBufferViewCore = { 4464 NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS, 4465 TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQUIRED && TYPED_ARRAY_TAG, 4466 aTypedArray: aTypedArray, 4467 aTypedArrayConstructor: aTypedArrayConstructor, 4468 exportTypedArrayMethod: exportTypedArrayMethod, 4469 exportTypedArrayStaticMethod: exportTypedArrayStaticMethod, 4470 getTypedArrayConstructor: getTypedArrayConstructor, 4471 isView: isView, 4472 isTypedArray: isTypedArray, 4473 TypedArray: TypedArray, 4474 TypedArrayPrototype: TypedArrayPrototype 4475 }; 4476 4477 /* eslint-disable no-new, sonarjs/inconsistent-function-call -- required for testing */ 4478 4479 4480 4481 var NATIVE_ARRAY_BUFFER_VIEWS$1 = arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; 4482 var ArrayBuffer$2 = globalThis_1.ArrayBuffer; 4483 var Int8Array$1 = globalThis_1.Int8Array; 4484 var typedArrayConstructorsRequireWrappers = !NATIVE_ARRAY_BUFFER_VIEWS$1 || !fails(function () { 4485 Int8Array$1(1); 4486 }) || !fails(function () { 4487 new Int8Array$1(-1); 4488 }) || !checkCorrectnessOfIteration(function (iterable) { 4489 new Int8Array$1(); 4490 new Int8Array$1(null); 4491 new Int8Array$1(1.5); 4492 new Int8Array$1(iterable); 4493 }, true) || fails(function () { 4494 // Safari (11+) bug - a reason why even Safari 13 should load a typed array polyfill 4495 return new Int8Array$1(new ArrayBuffer$2(2), 1, undefined).length !== 1; 4496 }); 4497 4498 var floor$3 = Math.floor; 4499 4500 // `IsIntegralNumber` abstract operation 4501 // https://tc39.es/ecma262/#sec-isintegralnumber 4502 // eslint-disable-next-line es/no-number-isinteger -- safe 4503 var isIntegralNumber = Number.isInteger || function isInteger(it) { 4504 return !isObject(it) && isFinite(it) && floor$3(it) === it; 4505 }; 4506 4507 var $RangeError$1 = RangeError; 4508 var toPositiveInteger = function (it) { 4509 var result = toIntegerOrInfinity(it); 4510 if (result < 0) throw new $RangeError$1("The argument can't be less than 0"); 4511 return result; 4512 }; 4513 4514 var $RangeError$2 = RangeError; 4515 var toOffset = function (it, BYTES) { 4516 var offset = toPositiveInteger(it); 4517 if (offset % BYTES) throw new $RangeError$2('Wrong offset'); 4518 return offset; 4519 }; 4520 4521 var round = Math.round; 4522 var toUint8Clamped = function (it) { 4523 var value = round(it); 4524 return value < 0 ? 0 : value > 0xFF ? 0xFF : value & 0xFF; 4525 }; 4526 4527 var isBigIntArray = function (it) { 4528 var klass = classof(it); 4529 return klass === 'BigInt64Array' || klass === 'BigUint64Array'; 4530 }; 4531 4532 var $TypeError$f = TypeError; 4533 4534 // `ToBigInt` abstract operation 4535 // https://tc39.es/ecma262/#sec-tobigint 4536 var toBigInt = function (argument) { 4537 var prim = toPrimitive(argument, 'number'); 4538 if (typeof prim == 'number') throw new $TypeError$f("Can't convert number to bigint"); 4539 // eslint-disable-next-line es/no-bigint -- safe 4540 return BigInt(prim); 4541 }; 4542 4543 var aTypedArrayConstructor$1 = arrayBufferViewCore.aTypedArrayConstructor; 4544 4545 var typedArrayFrom = function from(source /* , mapfn, thisArg */) { 4546 var C = aConstructor(this); 4547 var O = toObject(source); 4548 var argumentsLength = arguments.length; 4549 var mapfn = argumentsLength > 1 ? arguments[1] : undefined; 4550 var mapping = mapfn !== undefined; 4551 var iteratorMethod = getIteratorMethod(O); 4552 var i, length, result, thisIsBigIntArray, value, step, iterator, next; 4553 if (iteratorMethod && !isArrayIteratorMethod(iteratorMethod)) { 4554 iterator = getIterator(O, iteratorMethod); 4555 next = iterator.next; 4556 O = []; 4557 while (!(step = functionCall(next, iterator)).done) { 4558 O.push(step.value); 4559 } 4560 } 4561 if (mapping && argumentsLength > 2) { 4562 mapfn = functionBindContext(mapfn, arguments[2]); 4563 } 4564 length = lengthOfArrayLike(O); 4565 result = new (aTypedArrayConstructor$1(C))(length); 4566 thisIsBigIntArray = isBigIntArray(result); 4567 for (i = 0; length > i; i++) { 4568 value = mapping ? mapfn(O[i], i) : O[i]; 4569 // FF30- typed arrays doesn't properly convert objects to typed array values 4570 result[i] = thisIsBigIntArray ? toBigInt(value) : +value; 4571 } 4572 return result; 4573 }; 4574 4575 // `IsArray` abstract operation 4576 // https://tc39.es/ecma262/#sec-isarray 4577 // eslint-disable-next-line es/no-array-isarray -- safe 4578 var isArray = Array.isArray || function isArray(argument) { 4579 return classofRaw(argument) === 'Array'; 4580 }; 4581 4582 var SPECIES$2 = wellKnownSymbol('species'); 4583 var $Array$1 = Array; 4584 4585 // a part of `ArraySpeciesCreate` abstract operation 4586 // https://tc39.es/ecma262/#sec-arrayspeciescreate 4587 var arraySpeciesConstructor = function (originalArray) { 4588 var C; 4589 if (isArray(originalArray)) { 4590 C = originalArray.constructor; 4591 // cross-realm fallback 4592 if (isConstructor(C) && (C === $Array$1 || isArray(C.prototype))) C = undefined;else if (isObject(C)) { 4593 C = C[SPECIES$2]; 4594 if (C === null) C = undefined; 4595 } 4596 } 4597 return C === undefined ? $Array$1 : C; 4598 }; 4599 4600 // `ArraySpeciesCreate` abstract operation 4601 // https://tc39.es/ecma262/#sec-arrayspeciescreate 4602 var arraySpeciesCreate = function (originalArray, length) { 4603 return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length); 4604 }; 4605 4606 var push$2 = functionUncurryThis([].push); 4607 4608 // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation 4609 var createMethod$2 = function (TYPE) { 4610 var IS_MAP = TYPE === 1; 4611 var IS_FILTER = TYPE === 2; 4612 var IS_SOME = TYPE === 3; 4613 var IS_EVERY = TYPE === 4; 4614 var IS_FIND_INDEX = TYPE === 6; 4615 var IS_FILTER_REJECT = TYPE === 7; 4616 var NO_HOLES = TYPE === 5 || IS_FIND_INDEX; 4617 return function ($this, callbackfn, that, specificCreate) { 4618 var O = toObject($this); 4619 var self = indexedObject(O); 4620 var length = lengthOfArrayLike(self); 4621 var boundFunction = functionBindContext(callbackfn, that); 4622 var index = 0; 4623 var create = specificCreate || arraySpeciesCreate; 4624 var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined; 4625 var value, result; 4626 for (; length > index; index++) if (NO_HOLES || index in self) { 4627 value = self[index]; 4628 result = boundFunction(value, index, O); 4629 if (TYPE) { 4630 if (IS_MAP) target[index] = result; // map 4631 else if (result) switch (TYPE) { 4632 case 3: 4633 return true; 4634 // some 4635 case 5: 4636 return value; 4637 // find 4638 case 6: 4639 return index; 4640 // findIndex 4641 case 2: 4642 push$2(target, value); 4643 // filter 4644 } else switch (TYPE) { 4645 case 4: 4646 return false; 4647 // every 4648 case 7: 4649 push$2(target, value); 4650 // filterReject 4651 } 4652 } 4653 } 4654 4655 return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target; 4656 }; 4657 }; 4658 var arrayIteration = { 4659 // `Array.prototype.forEach` method 4660 // https://tc39.es/ecma262/#sec-array.prototype.foreach 4661 forEach: createMethod$2(0), 4662 // `Array.prototype.map` method 4663 // https://tc39.es/ecma262/#sec-array.prototype.map 4664 map: createMethod$2(1), 4665 // `Array.prototype.filter` method 4666 // https://tc39.es/ecma262/#sec-array.prototype.filter 4667 filter: createMethod$2(2), 4668 // `Array.prototype.some` method 4669 // https://tc39.es/ecma262/#sec-array.prototype.some 4670 some: createMethod$2(3), 4671 // `Array.prototype.every` method 4672 // https://tc39.es/ecma262/#sec-array.prototype.every 4673 every: createMethod$2(4), 4674 // `Array.prototype.find` method 4675 // https://tc39.es/ecma262/#sec-array.prototype.find 4676 find: createMethod$2(5), 4677 // `Array.prototype.findIndex` method 4678 // https://tc39.es/ecma262/#sec-array.prototype.findIndex 4679 findIndex: createMethod$2(6), 4680 // `Array.prototype.filterReject` method 4681 // https://github.com/tc39/proposal-array-filtering 4682 filterReject: createMethod$2(7) 4683 }; 4684 4685 var SPECIES$3 = wellKnownSymbol('species'); 4686 var setSpecies = function (CONSTRUCTOR_NAME) { 4687 var Constructor = getBuiltIn(CONSTRUCTOR_NAME); 4688 if (descriptors && Constructor && !Constructor[SPECIES$3]) { 4689 defineBuiltInAccessor(Constructor, SPECIES$3, { 4690 configurable: true, 4691 get: function () { 4692 return this; 4693 } 4694 }); 4695 } 4696 }; 4697 4698 var arrayFromConstructorAndList = function (Constructor, list, $length) { 4699 var index = 0; 4700 var length = arguments.length > 2 ? $length : lengthOfArrayLike(list); 4701 var result = new Constructor(length); 4702 while (length > index) result[index] = list[index++]; 4703 return result; 4704 }; 4705 4706 var typedArrayConstructor = createCommonjsModule(function (module) { 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 var getOwnPropertyNames = objectGetOwnPropertyNames.f; 4732
vendor: 6,764 bytes, lines 4733-4880
4733 var forEach = arrayIteration.forEach; 4734 4735 4736 4737 4738 4739 4740 4741 var getInternalState = internalState.get; 4742 var setInternalState = internalState.set; 4743 var enforceInternalState = internalState.enforce; 4744 var nativeDefineProperty = objectDefineProperty.f; 4745 var nativeGetOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; 4746 var RangeError = globalThis_1.RangeError; 4747 var ArrayBuffer = arrayBuffer.ArrayBuffer; 4748 var ArrayBufferPrototype = ArrayBuffer.prototype; 4749 var DataView = arrayBuffer.DataView; 4750 var NATIVE_ARRAY_BUFFER_VIEWS = arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; 4751 var TYPED_ARRAY_TAG = arrayBufferViewCore.TYPED_ARRAY_TAG; 4752 var TypedArray = arrayBufferViewCore.TypedArray; 4753 var TypedArrayPrototype = arrayBufferViewCore.TypedArrayPrototype; 4754 var isTypedArray = arrayBufferViewCore.isTypedArray; 4755 var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT'; 4756 var WRONG_LENGTH = 'Wrong length'; 4757 var addGetter = function (it, key) { 4758 defineBuiltInAccessor(it, key, { 4759 configurable: true, 4760 get: function () { 4761 return getInternalState(this)[key]; 4762 } 4763 }); 4764 }; 4765 var isArrayBuffer = function (it) { 4766 var klass; 4767 return objectIsPrototypeOf(ArrayBufferPrototype, it) || (klass = classof(it)) === 'ArrayBuffer' || klass === 'SharedArrayBuffer'; 4768 }; 4769 var isTypedArrayIndex = function (target, key) { 4770 return isTypedArray(target) && !isSymbol(key) && key in target && isIntegralNumber(+key) && key >= 0; 4771 }; 4772 var wrappedGetOwnPropertyDescriptor = function getOwnPropertyDescriptor(target, key) { 4773 key = toPropertyKey(key); 4774 return isTypedArrayIndex(target, key) ? createPropertyDescriptor(2, target[key]) : nativeGetOwnPropertyDescriptor(target, key); 4775 }; 4776 var wrappedDefineProperty = function defineProperty(target, key, descriptor) { 4777 key = toPropertyKey(key); 4778 if (isTypedArrayIndex(target, key) && isObject(descriptor) && hasOwnProperty_1(descriptor, 'value') && !hasOwnProperty_1(descriptor, 'get') && !hasOwnProperty_1(descriptor, 'set') 4779 // TODO: add validation descriptor w/o calling accessors 4780 && !descriptor.configurable && (!hasOwnProperty_1(descriptor, 'writable') || descriptor.writable) && (!hasOwnProperty_1(descriptor, 'enumerable') || descriptor.enumerable)) { 4781 target[key] = descriptor.value; 4782 return target; 4783 } 4784 return nativeDefineProperty(target, key, descriptor); 4785 }; 4786 if (descriptors) { 4787 if (!NATIVE_ARRAY_BUFFER_VIEWS) { 4788 objectGetOwnPropertyDescriptor.f = wrappedGetOwnPropertyDescriptor; 4789 objectDefineProperty.f = wrappedDefineProperty; 4790 addGetter(TypedArrayPrototype, 'buffer'); 4791 addGetter(TypedArrayPrototype, 'byteOffset'); 4792 addGetter(TypedArrayPrototype, 'byteLength'); 4793 addGetter(TypedArrayPrototype, 'length'); 4794 } 4795 _export({ 4796 target: 'Object', 4797 stat: true, 4798 forced: !NATIVE_ARRAY_BUFFER_VIEWS 4799 }, { 4800 getOwnPropertyDescriptor: wrappedGetOwnPropertyDescriptor, 4801 defineProperty: wrappedDefineProperty 4802 }); 4803 module.exports = function (TYPE, wrapper, CLAMPED) { 4804 var BYTES = TYPE.match(/\d+/)[0] / 8; 4805 var CONSTRUCTOR_NAME = TYPE + (CLAMPED ? 'Clamped' : '') + 'Array'; 4806 var GETTER = 'get' + TYPE; 4807 var SETTER = 'set' + TYPE; 4808 var NativeTypedArrayConstructor = globalThis_1[CONSTRUCTOR_NAME]; 4809 var TypedArrayConstructor = NativeTypedArrayConstructor; 4810 var TypedArrayConstructorPrototype = TypedArrayConstructor && TypedArrayConstructor.prototype; 4811 var exported = {}; 4812 var getter = function (that, index) { 4813 var data = getInternalState(that); 4814 return data.view[GETTER](index * BYTES + data.byteOffset, true); 4815 }; 4816 var setter = function (that, index, value) { 4817 var data = getInternalState(that); 4818 data.view[SETTER](index * BYTES + data.byteOffset, CLAMPED ? toUint8Clamped(value) : value, true); 4819 }; 4820 var addElement = function (that, index) { 4821 nativeDefineProperty(that, index, { 4822 get: function () { 4823 return getter(this, index); 4824 }, 4825 set: function (value) { 4826 return setter(this, index, value); 4827 }, 4828 enumerable: true 4829 }); 4830 }; 4831 if (!NATIVE_ARRAY_BUFFER_VIEWS) { 4832 TypedArrayConstructor = wrapper(function (that, data, offset, $length) { 4833 anInstance(that, TypedArrayConstructorPrototype); 4834 var index = 0; 4835 var byteOffset = 0; 4836 var buffer, byteLength, length; 4837 if (!isObject(data)) { 4838 length = toIndex(data); 4839 byteLength = length * BYTES; 4840 buffer = new ArrayBuffer(byteLength); 4841 } else if (isArrayBuffer(data)) { 4842 buffer = data; 4843 byteOffset = toOffset(offset, BYTES); 4844 var $len = data.byteLength; 4845 if ($length === undefined) { 4846 if ($len % BYTES) throw new RangeError(WRONG_LENGTH); 4847 byteLength = $len - byteOffset; 4848 if (byteLength < 0) throw new RangeError(WRONG_LENGTH); 4849 } else { 4850 byteLength = toLength($length) * BYTES; 4851 if (byteLength + byteOffset > $len) throw new RangeError(WRONG_LENGTH); 4852 } 4853 length = byteLength / BYTES; 4854 } else if (isTypedArray(data)) { 4855 return arrayFromConstructorAndList(TypedArrayConstructor, data); 4856 } else { 4857 return functionCall(typedArrayFrom, TypedArrayConstructor, data); 4858 } 4859 setInternalState(that, { 4860 buffer: buffer, 4861 byteOffset: byteOffset, 4862 byteLength: byteLength, 4863 length: length, 4864 view: new DataView(buffer) 4865 }); 4866 while (index < length) addElement(that, index++); 4867 }); 4868 if (objectSetPrototypeOf) objectSetPrototypeOf(TypedArrayConstructor, TypedArray); 4869 TypedArrayConstructorPrototype = TypedArrayConstructor.prototype = objectCreate(TypedArrayPrototype); 4870 } else if (typedArrayConstructorsRequireWrappers) { 4871 TypedArrayConstructor = wrapper(function (dummy, data, typedArrayOffset, $length) { 4872 anInstance(dummy, TypedArrayConstructorPrototype); 4873 return inheritIfRequired(function () { 4874 if (!isObject(data)) return new NativeTypedArrayConstructor(toIndex(data)); 4875 if (isArrayBuffer(data)) return $length !== undefined ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES), $length) : typedArrayOffset !== undefined ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES)) : new NativeTypedArrayConstructor(data); 4876 if (isTypedArray(data)) return arrayFromConstructorAndList(TypedArrayConstructor, data); 4877 return functionCall(typedArrayFrom, TypedArrayConstructor, data); 4878 }(), dummy, TypedArrayConstructor); 4879 }); 4880 if (objectSetPrototypeOf) objectSetPrototypeOf(TypedArrayConstructor, TypedArray);
vendor: 10,961 bytes, lines 4881-5188
4881 forEach(getOwnPropertyNames(NativeTypedArrayConstructor), function (key) { 4882 if (!(key in TypedArrayConstructor)) { 4883 createNonEnumerableProperty(TypedArrayConstructor, key, NativeTypedArrayConstructor[key]); 4884 } 4885 }); 4886 TypedArrayConstructor.prototype = TypedArrayConstructorPrototype; 4887 } 4888 if (TypedArrayConstructorPrototype.constructor !== TypedArrayConstructor) { 4889 createNonEnumerableProperty(TypedArrayConstructorPrototype, 'constructor', TypedArrayConstructor); 4890 } 4891 enforceInternalState(TypedArrayConstructorPrototype).TypedArrayConstructor = TypedArrayConstructor; 4892 if (TYPED_ARRAY_TAG) { 4893 createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_TAG, CONSTRUCTOR_NAME); 4894 } 4895 var FORCED = TypedArrayConstructor !== NativeTypedArrayConstructor; 4896 exported[CONSTRUCTOR_NAME] = TypedArrayConstructor; 4897 _export({ 4898 global: true, 4899 constructor: true, 4900 forced: FORCED, 4901 sham: !NATIVE_ARRAY_BUFFER_VIEWS 4902 }, exported); 4903 if (!(BYTES_PER_ELEMENT in TypedArrayConstructor)) { 4904 createNonEnumerableProperty(TypedArrayConstructor, BYTES_PER_ELEMENT, BYTES); 4905 } 4906 if (!(BYTES_PER_ELEMENT in TypedArrayConstructorPrototype)) { 4907 createNonEnumerableProperty(TypedArrayConstructorPrototype, BYTES_PER_ELEMENT, BYTES); 4908 } 4909 setSpecies(CONSTRUCTOR_NAME); 4910 }; 4911 } else module.exports = function () {/* empty */}; 4912 }); 4913 4914 // `Float32Array` constructor 4915 // https://tc39.es/ecma262/#sec-typedarray-objects 4916 typedArrayConstructor('Float32', function (init) { 4917 return function Float32Array(data, byteOffset, length) { 4918 return init(this, data, byteOffset, length); 4919 }; 4920 }); 4921 4922 // `Float64Array` constructor 4923 // https://tc39.es/ecma262/#sec-typedarray-objects 4924 typedArrayConstructor('Float64', function (init) { 4925 return function Float64Array(data, byteOffset, length) { 4926 return init(this, data, byteOffset, length); 4927 }; 4928 }); 4929 4930 // `Int8Array` constructor 4931 // https://tc39.es/ecma262/#sec-typedarray-objects 4932 typedArrayConstructor('Int8', function (init) { 4933 return function Int8Array(data, byteOffset, length) { 4934 return init(this, data, byteOffset, length); 4935 }; 4936 }); 4937 4938 // `Int16Array` constructor 4939 // https://tc39.es/ecma262/#sec-typedarray-objects 4940 typedArrayConstructor('Int16', function (init) { 4941 return function Int16Array(data, byteOffset, length) { 4942 return init(this, data, byteOffset, length); 4943 }; 4944 }); 4945 4946 // `Int32Array` constructor 4947 // https://tc39.es/ecma262/#sec-typedarray-objects 4948 typedArrayConstructor('Int32', function (init) { 4949 return function Int32Array(data, byteOffset, length) { 4950 return init(this, data, byteOffset, length); 4951 }; 4952 }); 4953 4954 // `Uint8Array` constructor 4955 // https://tc39.es/ecma262/#sec-typedarray-objects 4956 typedArrayConstructor('Uint8', function (init) { 4957 return function Uint8Array(data, byteOffset, length) { 4958 return init(this, data, byteOffset, length); 4959 }; 4960 }); 4961 4962 // `Uint8ClampedArray` constructor 4963 // https://tc39.es/ecma262/#sec-typedarray-objects 4964 typedArrayConstructor('Uint8', function (init) { 4965 return function Uint8ClampedArray(data, byteOffset, length) { 4966 return init(this, data, byteOffset, length); 4967 }; 4968 }, true); 4969 4970 // `Uint16Array` constructor 4971 // https://tc39.es/ecma262/#sec-typedarray-objects 4972 typedArrayConstructor('Uint16', function (init) { 4973 return function Uint16Array(data, byteOffset, length) { 4974 return init(this, data, byteOffset, length); 4975 }; 4976 }); 4977 4978 // `Uint32Array` constructor 4979 // https://tc39.es/ecma262/#sec-typedarray-objects 4980 typedArrayConstructor('Uint32', function (init) { 4981 return function Uint32Array(data, byteOffset, length) { 4982 return init(this, data, byteOffset, length); 4983 }; 4984 }); 4985 4986 var aTypedArray$1 = arrayBufferViewCore.aTypedArray; 4987 var exportTypedArrayMethod$1 = arrayBufferViewCore.exportTypedArrayMethod; 4988 4989 // `%TypedArray%.prototype.at` method 4990 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.at 4991 exportTypedArrayMethod$1('at', function at(index) { 4992 var O = aTypedArray$1(this); 4993 var len = lengthOfArrayLike(O); 4994 var relativeIndex = toIntegerOrInfinity(index); 4995 var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; 4996 return k < 0 || k >= len ? undefined : O[k]; 4997 }); 4998 4999 var exportTypedArrayStaticMethod$1 = arrayBufferViewCore.exportTypedArrayStaticMethod; 5000 5001 5002 // `%TypedArray%.from` method 5003 // https://tc39.es/ecma262/#sec-%typedarray%.from 5004 exportTypedArrayStaticMethod$1('from', typedArrayFrom, typedArrayConstructorsRequireWrappers); 5005 5006 var aTypedArrayConstructor$2 = arrayBufferViewCore.aTypedArrayConstructor; 5007 var exportTypedArrayStaticMethod$2 = arrayBufferViewCore.exportTypedArrayStaticMethod; 5008 5009 // `%TypedArray%.of` method 5010 // https://tc39.es/ecma262/#sec-%typedarray%.of 5011 exportTypedArrayStaticMethod$2('of', function of( /* ...items */ 5012 ) { 5013 var index = 0; 5014 var length = arguments.length; 5015 var result = new (aTypedArrayConstructor$2(this))(length); 5016 while (length > index) result[index] = arguments[index++]; 5017 return result; 5018 }, typedArrayConstructorsRequireWrappers); 5019 5020 var floor$4 = Math.floor; 5021 var sort = function (array, comparefn) { 5022 var length = array.length; 5023 if (length < 8) { 5024 // insertion sort 5025 var i = 1; 5026 var element, j; 5027 while (i < length) { 5028 j = i; 5029 element = array[i]; 5030 while (j && comparefn(array[j - 1], element) > 0) { 5031 array[j] = array[--j]; 5032 } 5033 if (j !== i++) array[j] = element; 5034 } 5035 } else { 5036 // merge sort 5037 var middle = floor$4(length / 2); 5038 var left = sort(arraySlice(array, 0, middle), comparefn); 5039 var right = sort(arraySlice(array, middle), comparefn); 5040 var llength = left.length; 5041 var rlength = right.length; 5042 var lindex = 0; 5043 var rindex = 0; 5044 while (lindex < llength || rindex < rlength) { 5045 array[lindex + rindex] = lindex < llength && rindex < rlength ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++] : lindex < llength ? left[lindex++] : right[rindex++]; 5046 } 5047 } 5048 return array; 5049 }; 5050 var arraySort = sort; 5051 5052 var firefox = environmentUserAgent.match(/firefox\/(\d+)/i); 5053 var environmentFfVersion = !!firefox && +firefox[1]; 5054 5055 var environmentIsIeOrEdge = /MSIE|Trident/.test(environmentUserAgent); 5056 5057 var webkit = environmentUserAgent.match(/AppleWebKit\/(\d+)\./); 5058 var environmentWebkitVersion = !!webkit && +webkit[1]; 5059 5060 var aTypedArray$2 = arrayBufferViewCore.aTypedArray; 5061 var exportTypedArrayMethod$2 = arrayBufferViewCore.exportTypedArrayMethod; 5062 var Uint16Array = globalThis_1.Uint16Array; 5063 var nativeSort = Uint16Array && functionUncurryThisClause(Uint16Array.prototype.sort); 5064 5065 // WebKit 5066 var ACCEPT_INCORRECT_ARGUMENTS = !!nativeSort && !(fails(function () { 5067 nativeSort(new Uint16Array(2), null); 5068 }) && fails(function () { 5069 nativeSort(new Uint16Array(2), {}); 5070 })); 5071 var STABLE_SORT = !!nativeSort && !fails(function () { 5072 // feature detection can be too slow, so check engines versions 5073 if (environmentV8Version) return environmentV8Version < 74; 5074 if (environmentFfVersion) return environmentFfVersion < 67; 5075 if (environmentIsIeOrEdge) return true; 5076 if (environmentWebkitVersion) return environmentWebkitVersion < 602; 5077 var array = new Uint16Array(516); 5078 var expected = Array(516); 5079 var index, mod; 5080 for (index = 0; index < 516; index++) { 5081 mod = index % 4; 5082 array[index] = 515 - index; 5083 expected[index] = index - 2 * mod + 3; 5084 } 5085 nativeSort(array, function (a, b) { 5086 return (a / 4 | 0) - (b / 4 | 0); 5087 }); 5088 for (index = 0; index < 516; index++) { 5089 if (array[index] !== expected[index]) return true; 5090 } 5091 }); 5092 var getSortCompare = function (comparefn) { 5093 return function (x, y) { 5094 if (comparefn !== undefined) return +comparefn(x, y) || 0; 5095 // eslint-disable-next-line no-self-compare -- NaN check 5096 if (y !== y) return -1; 5097 // eslint-disable-next-line no-self-compare -- NaN check 5098 if (x !== x) return 1; 5099 if (x === 0 && y === 0) return 1 / x > 0 && 1 / y < 0 ? 1 : -1; 5100 return x > y; 5101 }; 5102 }; 5103 5104 // `%TypedArray%.prototype.sort` method 5105 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.sort 5106 exportTypedArrayMethod$2('sort', function sort(comparefn) { 5107 if (comparefn !== undefined) aCallable(comparefn); 5108 if (STABLE_SORT) return nativeSort(this, comparefn); 5109 return arraySort(aTypedArray$2(this), getSortCompare(comparefn)); 5110 }, !STABLE_SORT || ACCEPT_INCORRECT_ARGUMENTS); 5111 5112 // iterable DOM collections 5113 // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods 5114 var domIterables = { 5115 CSSRuleList: 0, 5116 CSSStyleDeclaration: 0, 5117 CSSValueList: 0, 5118 ClientRectList: 0, 5119 DOMRectList: 0, 5120 DOMStringList: 0, 5121 DOMTokenList: 1, 5122 DataTransferItemList: 0, 5123 FileList: 0, 5124 HTMLAllCollection: 0, 5125 HTMLCollection: 0, 5126 HTMLFormElement: 0, 5127 HTMLSelectElement: 0, 5128 MediaList: 0, 5129 MimeTypeArray: 0, 5130 NamedNodeMap: 0, 5131 NodeList: 1, 5132 PaintRequestList: 0, 5133 Plugin: 0, 5134 PluginArray: 0, 5135 SVGLengthList: 0, 5136 SVGNumberList: 0, 5137 SVGPathSegList: 0, 5138 SVGPointList: 0, 5139 SVGStringList: 0, 5140 SVGTransformList: 0, 5141 SourceBufferList: 0, 5142 StyleSheetList: 0, 5143 TextTrackCueList: 0, 5144 TextTrackList: 0, 5145 TouchList: 0 5146 }; 5147 5148 // in old WebKit versions, `element.classList` is not an instance of global `DOMTokenList` 5149 5150 var classList = documentCreateElement('span').classList; 5151 var DOMTokenListPrototype = classList && classList.constructor && classList.constructor.prototype; 5152 var domTokenListPrototype = DOMTokenListPrototype === Object.prototype ? undefined : DOMTokenListPrototype; 5153 5154 var PROPER_FUNCTION_NAME$1 = functionName.PROPER; 5155 var CONFIGURABLE_FUNCTION_NAME$1 = functionName.CONFIGURABLE; 5156 var IteratorPrototype$2 = iteratorsCore.IteratorPrototype; 5157 var BUGGY_SAFARI_ITERATORS$1 = iteratorsCore.BUGGY_SAFARI_ITERATORS; 5158 var ITERATOR$4 = wellKnownSymbol('iterator'); 5159 var KEYS = 'keys'; 5160 var VALUES = 'values'; 5161 var ENTRIES = 'entries'; 5162 var returnThis$1 = function () { 5163 return this; 5164 }; 5165 var iteratorDefine = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) { 5166 iteratorCreateConstructor(IteratorConstructor, NAME, next); 5167 var getIterationMethod = function (KIND) { 5168 if (KIND === DEFAULT && defaultIterator) return defaultIterator; 5169 if (!BUGGY_SAFARI_ITERATORS$1 && KIND && KIND in IterablePrototype) return IterablePrototype[KIND]; 5170 switch (KIND) { 5171 case KEYS: 5172 return function keys() { 5173 return new IteratorConstructor(this, KIND); 5174 }; 5175 case VALUES: 5176 return function values() { 5177 return new IteratorConstructor(this, KIND); 5178 }; 5179 case ENTRIES: 5180 return function entries() { 5181 return new IteratorConstructor(this, KIND); 5182 }; 5183 } 5184 return function () { 5185 return new IteratorConstructor(this); 5186 }; 5187 }; 5188 var TO_STRING_TAG = NAME + ' Iterator';
vendor: 16,324 bytes, lines 5189-5672
5189 var INCORRECT_VALUES_NAME = false; 5190 var IterablePrototype = Iterable.prototype; 5191 var nativeIterator = IterablePrototype[ITERATOR$4] || IterablePrototype['@@iterator'] || DEFAULT && IterablePrototype[DEFAULT]; 5192 var defaultIterator = !BUGGY_SAFARI_ITERATORS$1 && nativeIterator || getIterationMethod(DEFAULT); 5193 var anyNativeIterator = NAME === 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator; 5194 var CurrentIteratorPrototype, methods, KEY; 5195 5196 // fix native 5197 if (anyNativeIterator) { 5198 CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable())); 5199 if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) { 5200 if (objectGetPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype$2) { 5201 if (objectSetPrototypeOf) { 5202 objectSetPrototypeOf(CurrentIteratorPrototype, IteratorPrototype$2); 5203 } else if (!isCallable(CurrentIteratorPrototype[ITERATOR$4])) { 5204 defineBuiltIn(CurrentIteratorPrototype, ITERATOR$4, returnThis$1); 5205 } 5206 } 5207 // Set @@toStringTag to native iterators 5208 setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true); 5209 } 5210 } 5211 5212 // fix Array.prototype.{ values, @@iterator }.name in V8 / FF 5213 if (PROPER_FUNCTION_NAME$1 && DEFAULT === VALUES && nativeIterator && nativeIterator.name !== VALUES) { 5214 if (CONFIGURABLE_FUNCTION_NAME$1) { 5215 createNonEnumerableProperty(IterablePrototype, 'name', VALUES); 5216 } else { 5217 INCORRECT_VALUES_NAME = true; 5218 defaultIterator = function values() { 5219 return functionCall(nativeIterator, this); 5220 }; 5221 } 5222 } 5223 5224 // export additional methods 5225 if (DEFAULT) { 5226 methods = { 5227 values: getIterationMethod(VALUES), 5228 keys: IS_SET ? defaultIterator : getIterationMethod(KEYS), 5229 entries: getIterationMethod(ENTRIES) 5230 }; 5231 if (FORCED) for (KEY in methods) { 5232 if (BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) { 5233 defineBuiltIn(IterablePrototype, KEY, methods[KEY]); 5234 } 5235 } else _export({ 5236 target: NAME, 5237 proto: true, 5238 forced: BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME 5239 }, methods); 5240 } 5241 5242 // define iterator 5243 if (IterablePrototype[ITERATOR$4] !== defaultIterator) { 5244 defineBuiltIn(IterablePrototype, ITERATOR$4, defaultIterator, { 5245 name: DEFAULT 5246 }); 5247 } 5248 iterators[NAME] = defaultIterator; 5249 return methods; 5250 }; 5251 5252 var defineProperty$3 = objectDefineProperty.f; 5253 5254 5255 5256 5257 var ARRAY_ITERATOR = 'Array Iterator'; 5258 var setInternalState$2 = internalState.set; 5259 var getInternalState$3 = internalState.getterFor(ARRAY_ITERATOR); 5260 5261 // `Array.prototype.entries` method 5262 // https://tc39.es/ecma262/#sec-array.prototype.entries 5263 // `Array.prototype.keys` method 5264 // https://tc39.es/ecma262/#sec-array.prototype.keys 5265 // `Array.prototype.values` method 5266 // https://tc39.es/ecma262/#sec-array.prototype.values 5267 // `Array.prototype[@@iterator]` method 5268 // https://tc39.es/ecma262/#sec-array.prototype-@@iterator 5269 // `CreateArrayIterator` internal method 5270 // https://tc39.es/ecma262/#sec-createarrayiterator 5271 var es_array_iterator = iteratorDefine(Array, 'Array', function (iterated, kind) { 5272 setInternalState$2(this, { 5273 type: ARRAY_ITERATOR, 5274 target: toIndexedObject(iterated), 5275 // target 5276 index: 0, 5277 // next index 5278 kind: kind // kind 5279 }); 5280 // `%ArrayIteratorPrototype%.next` method 5281 // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next 5282 }, function () { 5283 var state = getInternalState$3(this); 5284 var target = state.target; 5285 var index = state.index++; 5286 if (!target || index >= target.length) { 5287 state.target = null; 5288 return createIterResultObject(undefined, true); 5289 } 5290 switch (state.kind) { 5291 case 'keys': 5292 return createIterResultObject(index, false); 5293 case 'values': 5294 return createIterResultObject(target[index], false); 5295 } 5296 return createIterResultObject([index, target[index]], false); 5297 }, 'values'); 5298 5299 // argumentsList[@@iterator] is %ArrayProto_values% 5300 // https://tc39.es/ecma262/#sec-createunmappedargumentsobject 5301 // https://tc39.es/ecma262/#sec-createmappedargumentsobject 5302 var values = iterators.Arguments = iterators.Array; 5303 5304 // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 5305 addToUnscopables('keys'); 5306 addToUnscopables('values'); 5307 addToUnscopables('entries'); 5308 5309 // V8 ~ Chrome 45- bug 5310 if (!isPure && descriptors && values.name !== 'values') try { 5311 defineProperty$3(values, 'name', { 5312 value: 'values' 5313 }); 5314 } catch (error) {/* empty */} 5315 5316 var ITERATOR$5 = wellKnownSymbol('iterator'); 5317 var ArrayValues = es_array_iterator.values; 5318 var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) { 5319 if (CollectionPrototype) { 5320 // some Chrome versions have non-configurable methods on DOMTokenList 5321 if (CollectionPrototype[ITERATOR$5] !== ArrayValues) try { 5322 createNonEnumerableProperty(CollectionPrototype, ITERATOR$5, ArrayValues); 5323 } catch (error) { 5324 CollectionPrototype[ITERATOR$5] = ArrayValues; 5325 } 5326 setToStringTag(CollectionPrototype, COLLECTION_NAME, true); 5327 if (domIterables[COLLECTION_NAME]) for (var METHOD_NAME in es_array_iterator) { 5328 // some Chrome versions have non-configurable methods on DOMTokenList 5329 if (CollectionPrototype[METHOD_NAME] !== es_array_iterator[METHOD_NAME]) try { 5330 createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, es_array_iterator[METHOD_NAME]); 5331 } catch (error) { 5332 CollectionPrototype[METHOD_NAME] = es_array_iterator[METHOD_NAME]; 5333 } 5334 } 5335 } 5336 }; 5337 for (var COLLECTION_NAME in domIterables) { 5338 handlePrototype(globalThis_1[COLLECTION_NAME] && globalThis_1[COLLECTION_NAME].prototype, COLLECTION_NAME); 5339 } 5340 handlePrototype(domTokenListPrototype, 'DOMTokenList'); 5341 5342 var FunctionPrototype$2 = Function.prototype; 5343 var apply = FunctionPrototype$2.apply; 5344 var call$2 = FunctionPrototype$2.call; 5345 5346 // eslint-disable-next-line es/no-function-prototype-bind, es/no-reflect -- safe 5347 var functionApply = typeof Reflect == 'object' && Reflect.apply || (functionBindNative ? call$2.bind(apply) : function () { 5348 return call$2.apply(apply, arguments); 5349 }); 5350 5351 var $TypeError$g = TypeError; 5352 var validateArgumentsLength = function (passed, required) { 5353 if (passed < required) throw new $TypeError$g('Not enough arguments'); 5354 return passed; 5355 }; 5356 5357 // eslint-disable-next-line redos/no-vulnerable -- safe 5358 var environmentIsIos = /(?:ipad|iphone|ipod).*applewebkit/i.test(environmentUserAgent); 5359 5360 var environmentIsNode = environment === 'NODE'; 5361 5362 var set$2 = globalThis_1.setImmediate; 5363 var clear = globalThis_1.clearImmediate; 5364 var process$1 = globalThis_1.process; 5365 var Dispatch = globalThis_1.Dispatch; 5366 var Function$1 = globalThis_1.Function; 5367 var MessageChannel = globalThis_1.MessageChannel; 5368 var String$1 = globalThis_1.String; 5369 var counter = 0; 5370 var queue = {}; 5371 var ONREADYSTATECHANGE = 'onreadystatechange'; 5372 var $location, defer, channel, port; 5373 fails(function () { 5374 // Deno throws a ReferenceError on `location` access without `--location` flag 5375 $location = globalThis_1.location; 5376 }); 5377 var run = function (id) { 5378 if (hasOwnProperty_1(queue, id)) { 5379 var fn = queue[id]; 5380 delete queue[id]; 5381 fn(); 5382 } 5383 }; 5384 var runner = function (id) { 5385 return function () { 5386 run(id); 5387 }; 5388 }; 5389 var eventListener = function (event) { 5390 run(event.data); 5391 }; 5392 var globalPostMessageDefer = function (id) { 5393 // old engines have not location.origin 5394 globalThis_1.postMessage(String$1(id), $location.protocol + '//' + $location.host); 5395 }; 5396 5397 // Node.js 0.9+ & IE10+ has setImmediate, otherwise: 5398 if (!set$2 || !clear) { 5399 set$2 = function setImmediate(handler) { 5400 validateArgumentsLength(arguments.length, 1); 5401 var fn = isCallable(handler) ? handler : Function$1(handler); 5402 var args = arraySlice(arguments, 1); 5403 queue[++counter] = function () { 5404 functionApply(fn, undefined, args); 5405 }; 5406 defer(counter); 5407 return counter; 5408 }; 5409 clear = function clearImmediate(id) { 5410 delete queue[id]; 5411 }; 5412 // Node.js 0.8- 5413 if (environmentIsNode) { 5414 defer = function (id) { 5415 process$1.nextTick(runner(id)); 5416 }; 5417 // Sphere (JS game engine) Dispatch API 5418 } else if (Dispatch && Dispatch.now) { 5419 defer = function (id) { 5420 Dispatch.now(runner(id)); 5421 }; 5422 // Browsers with MessageChannel, includes WebWorkers 5423 // except iOS - https://github.com/zloirock/core-js/issues/624 5424 } else if (MessageChannel && !environmentIsIos) { 5425 channel = new MessageChannel(); 5426 port = channel.port2; 5427 channel.port1.onmessage = eventListener; 5428 defer = functionBindContext(port.postMessage, port); 5429 // Browsers with postMessage, skip WebWorkers 5430 // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' 5431 } else if (globalThis_1.addEventListener && isCallable(globalThis_1.postMessage) && !globalThis_1.importScripts && $location && $location.protocol !== 'file:' && !fails(globalPostMessageDefer)) { 5432 defer = globalPostMessageDefer; 5433 globalThis_1.addEventListener('message', eventListener, false); 5434 // IE8- 5435 } else if (ONREADYSTATECHANGE in documentCreateElement('script')) { 5436 defer = function (id) { 5437 html.appendChild(documentCreateElement('script'))[ONREADYSTATECHANGE] = function () { 5438 html.removeChild(this); 5439 run(id); 5440 }; 5441 }; 5442 // Rest old browsers 5443 } else { 5444 defer = function (id) { 5445 setTimeout(runner(id), 0); 5446 }; 5447 } 5448 } 5449 var task = { 5450 set: set$2, 5451 clear: clear 5452 }; 5453 5454 var clearImmediate = task.clear; 5455 5456 // `clearImmediate` method 5457 // http://w3c.github.io/setImmediate/#si-clearImmediate 5458 _export({ 5459 global: true, 5460 bind: true, 5461 enumerable: true, 5462 forced: globalThis_1.clearImmediate !== clearImmediate 5463 }, { 5464 clearImmediate: clearImmediate 5465 }); 5466 5467 var Function$2 = globalThis_1.Function; 5468 // dirty IE9- and Bun 0.3.0- checks 5469 var WRAP = /MSIE .\./.test(environmentUserAgent) || environment === 'BUN' && function () { 5470 var version = globalThis_1.Bun.version.split('.'); 5471 return version.length < 3 || version[0] === '0' && (version[1] < 3 || version[1] === '3' && version[2] === '0'); 5472 }(); 5473 5474 // IE9- / Bun 0.3.0- setTimeout / setInterval / setImmediate additional parameters fix 5475 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers 5476 // https://github.com/oven-sh/bun/issues/1633 5477 var schedulersFix = function (scheduler, hasTimeArg) { 5478 var firstParamIndex = hasTimeArg ? 2 : 1; 5479 return WRAP ? function (handler, timeout /* , ...arguments */) { 5480 var boundArgs = validateArgumentsLength(arguments.length, 1) > firstParamIndex; 5481 var fn = isCallable(handler) ? handler : Function$2(handler); 5482 var params = boundArgs ? arraySlice(arguments, firstParamIndex) : []; 5483 var callback = boundArgs ? function () { 5484 functionApply(fn, this, params); 5485 } : fn; 5486 return hasTimeArg ? scheduler(callback, timeout) : scheduler(callback); 5487 } : scheduler; 5488 }; 5489 5490 var setTask = task.set; 5491 5492 5493 // https://github.com/oven-sh/bun/issues/1633 5494 var setImmediate = globalThis_1.setImmediate ? schedulersFix(setTask, false) : setTask; 5495 5496 // `setImmediate` method 5497 // http://w3c.github.io/setImmediate/#si-setImmediate 5498 _export({ 5499 global: true, 5500 bind: true, 5501 enumerable: true, 5502 forced: globalThis_1.setImmediate !== setImmediate 5503 }, { 5504 setImmediate: setImmediate 5505 }); 5506 5507 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 5508 var getOwnPropertyDescriptor$2 = Object.getOwnPropertyDescriptor; 5509 5510 // Avoid NodeJS experimental warning 5511 var safeGetBuiltIn = function (name) { 5512 if (!descriptors) return globalThis_1[name]; 5513 var descriptor = getOwnPropertyDescriptor$2(globalThis_1, name); 5514 return descriptor && descriptor.value; 5515 }; 5516 5517 var Queue = function () { 5518 this.head = null; 5519 this.tail = null; 5520 }; 5521 Queue.prototype = { 5522 add: function (item) { 5523 var entry = { 5524 item: item, 5525 next: null 5526 }; 5527 var tail = this.tail; 5528 if (tail) tail.next = entry;else this.head = entry; 5529 this.tail = entry; 5530 }, 5531 get: function () { 5532 var entry = this.head; 5533 if (entry) { 5534 var next = this.head = entry.next; 5535 if (next === null) this.tail = null; 5536 return entry.item; 5537 } 5538 } 5539 }; 5540 var queue$1 = Queue; 5541 5542 var environmentIsIosPebble = /ipad|iphone|ipod/i.test(environmentUserAgent) && typeof Pebble != 'undefined'; 5543 5544 var environmentIsWebosWebkit = /web0s(?!.*chrome)/i.test(environmentUserAgent); 5545 5546 var macrotask = task.set; 5547 5548 5549 5550 5551 5552 var MutationObserver = globalThis_1.MutationObserver || globalThis_1.WebKitMutationObserver; 5553 var document$2 = globalThis_1.document; 5554 var process$2 = globalThis_1.process; 5555 var Promise = globalThis_1.Promise; 5556 var microtask = safeGetBuiltIn('queueMicrotask'); 5557 var notify, toggle, node, promise, then; 5558 5559 // modern engines have queueMicrotask method 5560 if (!microtask) { 5561 var queue$2 = new queue$1(); 5562 var flush = function () { 5563 var parent, fn; 5564 if (environmentIsNode && (parent = process$2.domain)) parent.exit(); 5565 while (fn = queue$2.get()) try { 5566 fn(); 5567 } catch (error) { 5568 if (queue$2.head) notify(); 5569 throw error; 5570 } 5571 if (parent) parent.enter(); 5572 }; 5573 5574 // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339 5575 // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898 5576 if (!environmentIsIos && !environmentIsNode && !environmentIsWebosWebkit && MutationObserver && document$2) { 5577 toggle = true; 5578 node = document$2.createTextNode(''); 5579 new MutationObserver(flush).observe(node, { 5580 characterData: true 5581 }); 5582 notify = function () { 5583 node.data = toggle = !toggle; 5584 }; 5585 // environments with maybe non-completely correct, but existent Promise 5586 } else if (!environmentIsIosPebble && Promise && Promise.resolve) { 5587 // Promise.resolve without an argument throws an error in LG WebOS 2 5588 promise = Promise.resolve(undefined); 5589 // workaround of WebKit ~ iOS Safari 10.1 bug 5590 promise.constructor = Promise; 5591 then = functionBindContext(promise.then, promise); 5592 notify = function () { 5593 then(flush); 5594 }; 5595 // Node.js without promises 5596 } else if (environmentIsNode) { 5597 notify = function () { 5598 process$2.nextTick(flush); 5599 }; 5600 // for other environments - macrotask based on: 5601 // - setImmediate 5602 // - MessageChannel 5603 // - window.postMessage 5604 // - onreadystatechange 5605 // - setTimeout 5606 } else { 5607 // `webpack` dev server bug on IE global methods - use bind(fn, global) 5608 macrotask = functionBindContext(macrotask, globalThis_1); 5609 notify = function () { 5610 macrotask(flush); 5611 }; 5612 } 5613 microtask = function (fn) { 5614 if (!queue$2.head) notify(); 5615 queue$2.add(fn); 5616 }; 5617 } 5618 var microtask_1 = microtask; 5619 5620 // Bun ~ 1.0.30 bug 5621 // https://github.com/oven-sh/bun/issues/9249 5622 var WRONG_ARITY = fails(function () { 5623 // getOwnPropertyDescriptor for prevent experimental warning in Node 11 5624 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 5625 return descriptors && Object.getOwnPropertyDescriptor(globalThis_1, 'queueMicrotask').value.length !== 1; 5626 }); 5627 5628 // `queueMicrotask` method 5629 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask 5630 _export({ 5631 global: true, 5632 enumerable: true, 5633 dontCallGetSet: true, 5634 forced: WRONG_ARITY 5635 }, { 5636 queueMicrotask: function queueMicrotask(fn) { 5637 validateArgumentsLength(arguments.length, 1); 5638 microtask_1(aCallable(fn)); 5639 } 5640 }); 5641 5642 // File generated automatically. Don't modify it. 5643 5644}((this.window = this.window || {}))); 5645 5646 5647 5648if (window._main_polyfill_core) 5649{ 5650 console.warn('main.polyfill.core is loaded more than once on this page'); 5651} 5652 5653window._main_polyfill_core = true; 5654 5655 5656(function (exports) { 5657 'use strict'; 5658 5659 var bxTmp = window.BX; 5660 window.BX = function (node) { 5661 if (window.BX.type.isNotEmptyString(node)) { 5662 return document.getElementById(node); 5663 } 5664 if (window.BX.type.isDomNode(node)) { 5665 return node; 5666 } 5667 if (window.BX.type.isFunction(node)) { 5668 return window.BX.ready(node); 5669 } 5670 return null; 5671 }; 5672 if (bxTmp) {
5673 Object.keys(bxTmp).forEach(key => { 5674 window.BX[key] = bxTmp[key]; 5675 }); 5676 } 5677 exports = window.BX; 5678 5679 /** 5680 * Gets object.toString result 5681 * @param value 5682 * @return {string} 5683 */ 5684 function getTag(value) { 5685 return Object.prototype.toString.call(value); 5686 } 5687 5688 const objectCtorString = Function.prototype.toString.call(Object); 5689 5690 /** 5691 * @memberOf BX 5692 */ 5693 let Type = /*#__PURE__*/function () { 5694 function Type() { 5695 babelHelpers.classCallCheck(this, Type); 5696 } 5697 babelHelpers.createClass(Type, null, [{ 5698 key: "isString", 5699 /** 5700 * Checks that value is string 5701 * @param value 5702 * @return {boolean} 5703 */ 5704 value: function isString(value) { 5705 return typeof value === 'string'; 5706 } 5707 /** 5708 * Returns true if a value is not empty string 5709 * @param value 5710 * @returns {boolean} 5711 */ 5712 }, { 5713 key: "isStringFilled", 5714 value: function isStringFilled(value) { 5715 return Type.isString(value) && value !== ''; 5716 } 5717 /** 5718 * Checks that value is function 5719 * @param value 5720 * @return {boolean} 5721 */ 5722 }, { 5723 key: "isFunction", 5724 value: function isFunction(value) { 5725 return typeof value === 'function'; 5726 } 5727 /** 5728 * Checks that value is object 5729 * @param value 5730 * @return {boolean} 5731 */ 5732 }, { 5733 key: "isObject", 5734 value: function isObject(value) { 5735 return !!value && (typeof value === 'object' || typeof value === 'function'); 5736 } 5737 /** 5738 * Checks that value is object like 5739 * @param value 5740 * @return {boolean} 5741 */ 5742 }, { 5743 key: "isObjectLike", 5744 value: function isObjectLike(value) { 5745 return !!value && typeof value === 'object'; 5746 } 5747 /** 5748 * Checks that value is plain object 5749 * @param value 5750 * @return {boolean} 5751 */ 5752 }, { 5753 key: "isPlainObject", 5754 value: function isPlainObject(value) { 5755 if (!Type.isObjectLike(value) || getTag(value) !== '[object Object]') { 5756 return false; 5757 } 5758 const proto = Object.getPrototypeOf(value); 5759 if (proto === null) { 5760 return true; 5761 } 5762 const ctor = proto.hasOwnProperty('constructor') && proto.constructor; 5763 return typeof ctor === 'function' && Function.prototype.toString.call(ctor) === objectCtorString; 5764 } 5765 /** 5766 * Checks that value is boolean 5767 * @param value 5768 * @return {boolean} 5769 */ 5770 }, { 5771 key: "isBoolean", 5772 value: function isBoolean(value) { 5773 return value === true || value === false; 5774 } 5775 /** 5776 * Checks that value is number 5777 * @param value 5778 * @return {boolean} 5779 */ 5780 }, { 5781 key: "isNumber", 5782 value: function isNumber(value) { 5783 return !Number.isNaN(value) && typeof value === 'number'; 5784 } 5785 /** 5786 * Checks that value is integer 5787 * @param value 5788 * @return {boolean} 5789 */ 5790 }, { 5791 key: "isInteger", 5792 value: function isInteger(value) { 5793 return Type.isNumber(value) && value % 1 === 0; 5794 } 5795 /** 5796 * Checks that value is float 5797 * @param value 5798 * @return {boolean} 5799 */ 5800 }, { 5801 key: "isFloat", 5802 value: function isFloat(value) { 5803 return Type.isNumber(value) && !Type.isInteger(value); 5804 } 5805 /** 5806 * Checks that value is nil 5807 * @param value 5808 * @return {boolean} 5809 */ 5810 }, { 5811 key: "isNil", 5812 value: function isNil(value) { 5813 return value === null || value === undefined; 5814 } 5815 /** 5816 * Checks that value is array 5817 * @param value 5818 * @return {boolean} 5819 */ 5820 }, { 5821 key: "isArray", 5822 value: function isArray(value) { 5823 return !Type.isNil(value) && Array.isArray(value); 5824 } 5825 /** 5826 * Returns true if a value is an array and it has at least one element 5827 * @param value 5828 * @returns {boolean} 5829 */ 5830 }, { 5831 key: "isArrayFilled", 5832 value: function isArrayFilled(value) { 5833 return Type.isArray(value) && value.length > 0; 5834 } 5835 /** 5836 * Checks that value is array like 5837 * @param value 5838 * @return {boolean} 5839 */ 5840 }, { 5841 key: "isArrayLike", 5842 value: function isArrayLike(value) { 5843 return !Type.isNil(value) && !Type.isFunction(value) && value.length > -1 && value.length <= Number.MAX_SAFE_INTEGER; 5844 } 5845 /** 5846 * Checks that value is Date 5847 * @param value 5848 * @return {boolean} 5849 */ 5850 }, { 5851 key: "isDate", 5852 value: function isDate(value) { 5853 return Type.isObjectLike(value) && getTag(value) === '[object Date]'; 5854 } 5855 /** 5856 * Checks that is DOM node 5857 * @param value 5858 * @return {boolean} 5859 */ 5860 }, { 5861 key: "isDomNode", 5862 value: function isDomNode(value) { 5863 return Type.isObjectLike(value) && !Type.isPlainObject(value) && 'nodeType' in value; 5864 } 5865 /** 5866 * Checks that value is element node 5867 * @param value 5868 * @return {boolean} 5869 */ 5870 }, { 5871 key: "isElementNode", 5872 value: function isElementNode(value) { 5873 return Type.isDomNode(value) && value.nodeType === Node.ELEMENT_NODE; 5874 } 5875 /** 5876 * Checks that value is text node 5877 * @param value 5878 * @return {boolean} 5879 */ 5880 }, { 5881 key: "isTextNode", 5882 value: function isTextNode(value) { 5883 return Type.isDomNode(value) && value.nodeType === Node.TEXT_NODE; 5884 } 5885 /** 5886 * Checks that value is Map 5887 * @param value 5888 * @return {boolean} 5889 */ 5890 }, { 5891 key: "isMap", 5892 value: function isMap(value) { 5893 return Type.isObjectLike(value) && getTag(value) === '[object Map]'; 5894 } 5895 /** 5896 * Checks that value is Set 5897 * @param value 5898 * @return {boolean} 5899 */ 5900 }, { 5901 key: "isSet", 5902 value: function isSet(value) { 5903 return Type.isObjectLike(value) && getTag(value) === '[object Set]'; 5904 } 5905 /** 5906 * Checks that value is WeakMap 5907 * @param value 5908 * @return {boolean} 5909 */ 5910 }, { 5911 key: "isWeakMap", 5912 value: function isWeakMap(value) { 5913 return Type.isObjectLike(value) && getTag(value) === '[object WeakMap]'; 5914 } 5915 /** 5916 * Checks that value is WeakSet 5917 * @param value 5918 * @return {boolean} 5919 */ 5920 }, { 5921 key: "isWeakSet", 5922 value: function isWeakSet(value) { 5923 return Type.isObjectLike(value) && getTag(value) === '[object WeakSet]'; 5924 } 5925 /** 5926 * Checks that value is prototype 5927 * @param value 5928 * @return {boolean} 5929 */ 5930 }, { 5931 key: "isPrototype", 5932 value: function isPrototype(value) { 5933 return (typeof (value && value.constructor) === 'function' && value.constructor.prototype || Object.prototype) === value; 5934 } 5935 /** 5936 * Checks that value is regexp 5937 * @param value 5938 * @return {boolean} 5939 */ 5940 }, { 5941 key: "isRegExp", 5942 value: function isRegExp(value) { 5943 return Type.isObjectLike(value) && getTag(value) === '[object RegExp]'; 5944 } 5945 /** 5946 * Checks that value is null 5947 * @param value 5948 * @return {boolean} 5949 */ 5950 }, { 5951 key: "isNull", 5952 value: function isNull(value) { 5953 return value === null; 5954 } 5955 /** 5956 * Checks that value is undefined 5957 * @param value 5958 * @return {boolean} 5959 */ 5960 }, { 5961 key: "isUndefined", 5962 value: function isUndefined(value) { 5963 return typeof value === 'undefined'; 5964 } 5965 /** 5966 * Checks that value is ArrayBuffer 5967 * @param value 5968 * @return {boolean} 5969 */ 5970 }, { 5971 key: "isArrayBuffer", 5972 value: function isArrayBuffer(value) { 5973 return Type.isObjectLike(value) && getTag(value) === '[object ArrayBuffer]'; 5974 } 5975 /** 5976 * Checks that value is typed array 5977 * @param value 5978 * @return {boolean} 5979 */ 5980 }, { 5981 key: "isTypedArray", 5982 value: function isTypedArray(value) { 5983 const regExpTypedTag = /^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)]$/; 5984 return Type.isObjectLike(value) && regExpTypedTag.test(getTag(value)); 5985 } 5986 /** 5987 * Checks that value is Blob 5988 * @param value 5989 * @return {boolean} 5990 */ 5991 }, { 5992 key: "isBlob", 5993 value: function isBlob(value) { 5994 return Type.isObjectLike(value) && Type.isNumber(value.size) && Type.isString(value.type) && Type.isFunction(value.slice); 5995 } 5996 /** 5997 * Checks that value is File 5998 * @param value 5999 * @return {boolean} 6000 */ 6001 }, { 6002 key: "isFile", 6003 value: function isFile(value) { 6004 return Type.isBlob(value) && Type.isString(value.name) && (Type.isNumber(value.lastModified) || Type.isObjectLike(value.lastModifiedDate)); 6005 } 6006 /** 6007 * Checks that value is FormData 6008 * @param value 6009 * @return {boolean} 6010 */ 6011 }, { 6012 key: "isFormData", 6013 value: function isFormData(value) { 6014 return value instanceof FormData; 6015 } 6016 }]); 6017 return Type; 6018 }(); 6019 6020 /** 6021 * @memberOf BX 6022 */ 6023 let Reflection = /*#__PURE__*/function () { 6024 function Reflection() { 6025 babelHelpers.classCallCheck(this, Reflection); 6026 } 6027 babelHelpers.createClass(Reflection, null, [{ 6028 key: "getClass", 6029 /** 6030 * Gets link to function by function name 6031 * @param className 6032 * @return {?Function} 6033 */ 6034 value: function getClass(className) { 6035 if (Type.isString(className) && !!className) { 6036 let classFn = null; 6037 let currentNamespace = window; 6038 const namespaces = className.split('.'); 6039 for (let i = 0; i < namespaces.length; i += 1) { 6040 const namespace = namespaces[i]; 6041 if (!currentNamespace[namespace]) { 6042 return null; 6043 } 6044 currentNamespace = currentNamespace[namespace]; 6045 classFn = currentNamespace; 6046 } 6047 return classFn; 6048 } 6049 if (Type.isFunction(className)) { 6050 return className; 6051 } 6052 return null; 6053 } 6054 /** 6055 * Creates a namespace or returns a link to a previously created one 6056 * @param {String} namespaceName 6057 * @return {Object<string, any> | Function | null} 6058 */ 6059 }, { 6060 key: "namespace", 6061 value: function namespace(namespaceName) { 6062 let parts = namespaceName.split('.'); 6063 let parent = window.BX; 6064 if (parts[0] === 'BX') { 6065 parts = parts.slice(1); 6066 } 6067 for (let i = 0; i < parts.length; i += 1) { 6068 if (Type.isUndefined(parent[parts[i]])) { 6069 parent[parts[i]] = {}; 6070 } 6071 parent = parent[parts[i]]; 6072 } 6073 return parent; 6074 } 6075 }]); 6076 return Reflection; 6077 }(); 6078 6079 const reEscape = /[&<>'"]/g; 6080 const reUnescape = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g; 6081 const escapeEntities = { 6082 '&': '&', 6083 '<': '<', 6084 '>': '>', 6085 "'": ''', 6086 '"': '"' 6087 }; 6088 const unescapeEntities = { 6089 '&': '&', 6090 '&': '&', 6091 '<': '<', 6092 '<': '<', 6093 '>': '>', 6094 '>': '>', 6095 ''': "'", 6096 ''': "'", 6097 '"': '"', 6098 '"': '"' 6099 }; 6100 6101 /** 6102 * @memberOf BX 6103 */ 6104 let Text = /*#__PURE__*/function () { 6105 function Text() { 6106 babelHelpers.classCallCheck(this, Text); 6107 } 6108 babelHelpers.createClass(Text, null, [{ 6109 key: "encode", 6110 /** 6111 * Encodes all unsafe entities 6112 * @param {string} value 6113 * @return {string} 6114 */ 6115 value: function encode(value) { 6116 if (Type.isString(value)) { 6117 return value.replace(reEscape, item => escapeEntities[item]); 6118 } 6119 return value; 6120 } 6121 /** 6122 * Decodes all encoded entities 6123 * @param {string} value 6124 * @return {string} 6125 */ 6126 }, { 6127 key: "decode", 6128 value: function decode(value) { 6129 if (Type.isString(value)) { 6130 return value.replace(reUnescape, item => unescapeEntities[item]); 6131 } 6132 return value; 6133 } 6134 }, { 6135 key: "getRandom", 6136 value: function getRandom(length = 8) { 6137 // eslint-disable-next-line 6138 return [...Array(length)].map(() => (~~(Math.random() * 36)).toString(36)).join(''); 6139 } 6140 }, { 6141 key: "toNumber", 6142 value: function toNumber(value) { 6143 const parsedValue = Number.parseFloat(value); 6144 if (Type.isNumber(parsedValue)) { 6145 return parsedValue; 6146 } 6147 return 0; 6148 } 6149 }, { 6150 key: "toInteger", 6151 value: function toInteger(value) { 6152 return Text.toNumber(Number.parseInt(value, 10)); 6153 } 6154 }, { 6155 key: "toBoolean", 6156 value: function toBoolean(value, trueValues = []) { 6157 const transformedValue = Type.isString(value) ? value.toLowerCase() : value; 6158 return ['true', 'y', '1', 1, true, ...trueValues].includes(transformedValue); 6159 } 6160 }, { 6161 key: "toCamelCase", 6162 value: function toCamelCase(str) { 6163 if (!Type.isStringFilled(str)) { 6164 return str; 6165 } 6166 const regex = /[-_\s]+(.)?/g; 6167 if (!regex.test(str)) { 6168 return str.match(/^[A-Z]+$/) ? str.toLowerCase() : str[0].toLowerCase() + str.slice(1); 6169 } 6170 str = str.toLowerCase(); 6171 str = str.replace(regex, function (match, letter) { 6172 return letter ? letter.toUpperCase() : ''; 6173 }); 6174 return str[0].toLowerCase() + str.substr(1); 6175 } 6176 }, { 6177 key: "toPascalCase", 6178 value: function toPascalCase(str) { 6179 if (!Type.isStringFilled(str)) { 6180 return str; 6181 } 6182 return this.capitalize(this.toCamelCase(str)); 6183 } 6184 }, { 6185 key: "toKebabCase", 6186 value: function toKebabCase(str) { 6187 if (!Type.isStringFilled(str)) { 6188 return str; 6189 } 6190 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); 6191 if (!matches) { 6192 return str; 6193 } 6194 return matches.map(x => x.toLowerCase()).join('-'); 6195 } 6196 }, { 6197 key: "capitalize", 6198 value: function capitalize(str) { 6199 if (!Type.isStringFilled(str)) { 6200 return str; 6201 } 6202 return str[0].toUpperCase() + str.substr(1); 6203 } 6204 }]); 6205 return Text; 6206 }(); 6207 6208 const aliases = { 6209 mousewheel: ['DOMMouseScroll'], 6210 bxchange: ['change', 'cut', 'paste', 'drop', 'keyup'], 6211 animationend: ['animationend', 'oAnimationEnd', 'webkitAnimationEnd', 'MSAnimationEnd'], 6212 transitionend: ['webkitTransitionEnd', 'otransitionend', 'oTransitionEnd', 'msTransitionEnd', 'transitionend'], 6213 fullscreenchange: ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange', 'MSFullscreenChange'], 6214 fullscreenerror: ['fullscreenerror', 'webkitfullscreenerror', 'mozfullscreenerror', 'MSFullscreenError'] 6215 }; 6216 6217 let Registry = /*#__PURE__*/function () { 6218 function Registry() { 6219 babelHelpers.classCallCheck(this, Registry); 6220 babelHelpers.defineProperty(this, "registry", new WeakMap()); 6221 } 6222 babelHelpers.createClass(Registry, [{ 6223 key: "set", 6224 value: function set(target, event, listener) { 6225 const events = this.get(target); 6226 if (!Type.isSet(events[event])) { 6227 events[event] = new Set(); 6228 } 6229 events[event].add(listener); 6230 this.registry.set(target, events); 6231 } 6232 }, { 6233 key: "get", 6234 value: function get(target) { 6235 return this.registry.get(target) || {}; 6236 } 6237 }, { 6238 key: "has", 6239 value: function has(target, event, listener) { 6240 if (event && listener) { 6241 return this.registry.has(target) && this.registry.get(target)[event].has(listener); 6242 } 6243 return this.registry.has(target); 6244 } 6245 }, { 6246 key: "delete", 6247 value: function _delete(target, event, listener) { 6248 if (!Type.isDomNode(target)) { 6249 return; 6250 } 6251 if (Type.isString(event) && Type.isFunction(listener)) { 6252 const events = this.registry.get(target); 6253 if (Type.isPlainObject(events) && Type.isSet(events[event])) { 6254 events[event].delete(listener); 6255 } 6256 return; 6257 } 6258 if (Type.isString(event)) { 6259 const events = this.registry.get(target); 6260 if (Type.isPlainObject(events) && Type.isSet(events[event])) { 6261 events[event] = new Set(); 6262 } 6263 return; 6264 } 6265 this.registry.delete(target); 6266 } 6267 }]); 6268 return Registry; 6269 }(); 6270 var registry = new Registry(); 6271 6272 function isOptionSupported(name) { 6273 let isSupported = false;
6274 try { 6275 const options = Object.defineProperty({}, name, { 6276 get() { 6277 isSupported = true; 6278 return undefined; 6279 } 6280 }); 6281 window.addEventListener('test', null, options); 6282 } 6283 // eslint-disable-next-line 6284 catch (err) {} 6285 return isSupported; 6286 } 6287 function fetchSupportedListenerOptions(options) { 6288 if (!Type.isPlainObject(options)) { 6289 return options; 6290 } 6291 return Object.keys(options).reduce((acc, name) => { 6292 if (isOptionSupported(name)) { 6293 acc[name] = options[name]; 6294 } 6295 return acc; 6296 }, {}); 6297 } 6298 6299 function bind(target, eventName, handler, options) { 6300 if (!Type.isObject(target) || !Type.isFunction(target.addEventListener)) { 6301 return; 6302 } 6303 const listenerOptions = fetchSupportedListenerOptions(options); 6304 if (eventName in aliases) { 6305 aliases[eventName].forEach(key => { 6306 target.addEventListener(key, handler, listenerOptions); 6307 registry.set(target, eventName, handler); 6308 }); 6309 return; 6310 } 6311 target.addEventListener(eventName, handler, listenerOptions); 6312 registry.set(target, eventName, handler); 6313 } 6314 6315 function unbind(target, eventName, handler, options) { 6316 if (!Type.isObject(target) || !Type.isFunction(target.removeEventListener)) { 6317 return; 6318 } 6319 const listenerOptions = fetchSupportedListenerOptions(options); 6320 if (eventName in aliases) { 6321 aliases[eventName].forEach(key => { 6322 target.removeEventListener(key, handler, listenerOptions); 6323 registry.delete(target, key, handler); 6324 }); 6325 return; 6326 } 6327 target.removeEventListener(eventName, handler, listenerOptions); 6328 registry.delete(target, eventName, handler); 6329 } 6330 6331 function unbindAll(target, eventName) { 6332 const events = registry.get(target); 6333 Object.keys(events).forEach(currentEvent => { 6334 events[currentEvent].forEach(handler => { 6335 if (!Type.isString(eventName) || eventName === currentEvent) { 6336 unbind(target, currentEvent, handler); 6337 } 6338 }); 6339 }); 6340 } 6341 6342 function bindOnce(target, eventName, handler, options) { 6343 const once = function once(...args) { 6344 unbind(target, eventName, once, options); 6345 handler(...args); 6346 }; 6347 bind(target, eventName, once, options); 6348 } 6349 6350 // eslint-disable-next-line 6351 let debugState = true; 6352 function enableDebug() { 6353 debugState = true; 6354 } 6355 function disableDebug() { 6356 debugState = false; 6357 } 6358 function isDebugEnabled() { 6359 return debugState; 6360 } 6361 function debug(...args) { 6362 if (isDebugEnabled() && Type.isObject(window.console)) { 6363 if (Type.isFunction(window.console.log)) { 6364 window.console.log('BX.debug: ', args.length > 0 ? args : args[0]); 6365 if (args[0] instanceof Error && args[0].stack) { 6366 window.console.log('BX.debug error stack trace', args[0].stack); 6367 } 6368 } 6369 if (Type.isFunction(window.console.trace)) { 6370 // eslint-disable-next-line 6371 console.trace(); 6372 } 6373 } 6374 } 6375 6376 var debugNs = /*#__PURE__*/Object.freeze({ 6377 get debugState () { return debugState; }, 6378 enableDebug: enableDebug, 6379 disableDebug: disableDebug, 6380 isDebugEnabled: isDebugEnabled, 6381 default: debug 6382 }); 6383 6384 const extensionsStorage = new Map(); 6385 6386 const ajaxController = 'main.bitrix.main.controller.loadext.getextensions'; 6387 function loadAssets(options) { 6388 return new Promise((resolve, reject) => { 6389 const getParameters = { 6390 e: ((options === null || options === void 0 ? void 0 : options.extension) || []).join(',') 6391 }; 6392 BX.ajax.runAction(ajaxController, { 6393 data: options, 6394 getParameters 6395 }).then(result => { 6396 resolve(result === null || result === void 0 ? void 0 : result.data); 6397 }).catch(err => { 6398 reject(err); 6399 }); 6400 }); 6401 } 6402 6403 function fetchInlineScripts(acc, item) { 6404 if (item.isInternal) { 6405 acc.push(item.JS); 6406 } 6407 return acc; 6408 } 6409 function fetchExternalScripts(acc, item) { 6410 if (!item.isInternal) { 6411 acc.push(item.JS); 6412 } 6413 return acc; 6414 } 6415 function fetchExternalStyles(acc, item) { 6416 if (Type.isString(item) && item !== '') { 6417 acc.push(item); 6418 } 6419 return acc; 6420 } 6421 function fetchExtensionSettings(html) { 6422 if (Type.isStringFilled(html)) { 6423 const scripts = html.match(/<script type="extension\/settings" \b[^>]*>([\s\S]*?)<\/script>/g); 6424 if (Type.isArrayFilled(scripts)) { 6425 return scripts.map(script => { 6426 const [, extension] = script.match(/data-extension="(.[a-z0-9_.-]+)"/); 6427 return { 6428 extension, 6429 script 6430 }; 6431 }); 6432 } 6433 } 6434 return []; 6435 } 6436 function loadAll(items) { 6437 const itemsList = Type.isArray(items) ? items : [items]; 6438 if (!itemsList.length) { 6439 return Promise.resolve(); 6440 } 6441 return new Promise(resolve => { 6442 // eslint-disable-next-line 6443 BX.load(itemsList, resolve); 6444 }); 6445 } 6446 6447 function parseExtensionHtml(html) { 6448 const result = window.BX.processHTML(html); 6449 const inlinePreScripts = []; 6450 const inlineAfterScripts = []; 6451 result.SCRIPT.reduce((accumulator, element) => { 6452 return fetchInlineScripts(accumulator, element); 6453 }
6453, []).forEach(script => { 6454 if (script.startsWith('BX.Runtime.registerExtension')) { 6455 inlineAfterScripts.push(script); 6456 } else { 6457 inlinePreScripts.push(script); 6458 } 6459 }); 6460 return { 6461 inlinePreScripts, 6462 inlineAfterScripts, 6463 externalScripts: result.SCRIPT.reduce((accumulator, element) => { 6464 return fetchExternalScripts(accumulator, element); 6465 }, []), 6466 externalStyles: result.STYLE.reduce((accumulator, element) => { 6467 return fetchExternalStyles(accumulator, element); 6468 }, []), 6469 settingsScripts: fetchExtensionSettings(result.HTML) 6470 }; 6471 } 6472 6473 async function processExtensions(map) { 6474 const loadableExtensions = [...map.keys()]; 6475 const rawAssets = await loadAssets({ 6476 extension: loadableExtensions 6477 }); 6478 rawAssets.forEach(rawAsset => { 6479 var _rawAsset$html; 6480 const preparedHtml = (_rawAsset$html = rawAsset.html) !== null && _rawAsset$html !== void 0 ? _rawAsset$html : ''; 6481 const extensionAssets = parseExtensionHtml(preparedHtml); 6482 extensionAssets.settingsScripts.forEach(({ 6483 script 6484 }) => { 6485 document.body.insertAdjacentHTML('beforeend', script); 6486 }); 6487 extensionAssets.inlinePreScripts.forEach(script => { 6488 window.BX.evalGlobal(script); 6489 }); 6490 const loadableExtensionEntry = map.get(rawAsset.extension); 6491 void Promise.all([loadAll(extensionAssets.externalScripts), loadAll(extensionAssets.externalStyles)]).then(() => { 6492 var _rawAsset$config$name, _rawAsset$config; 6493 extensionAssets.inlineAfterScripts.forEach(script => { 6494 window.BX.evalGlobal(script); 6495 }); 6496 const namespace = (_rawAsset$config$name = rawAsset === null || rawAsset === void 0 ? void 0 : (_rawAsset$config = rawAsset.config) === null || _rawAsset$config === void 0 ? void 0 : _rawAsset$config.namespace) !== null && _rawAsset$config$name !== void 0 ? _rawAsset$config$name : 'window'; 6497 loadableExtensionEntry.resolve(namespace); 6498 }).catch(error => { 6499 loadableExtensionEntry.reject(error); 6500 }); 6501 }); 6502 } 6503 6504 const queue = new Map(); 6505 let timerId = null; 6506 async function loadExtension(...name) { 6507 if (Type.isNumber(timerId)) { 6508 clearTimeout(timerId); 6509 } 6510 const requestedNames = name.flat(); 6511 const extensionsToLoad = requestedNames.filter(extensionName => { 6512 return !extensionsStorage.has(extensionName); 6513 }); 6514 extensionsToLoad.forEach(extensionName => { 6515 let resolve = null; 6516 let reject = null; 6517 const loadableExtensionEntry = { 6518 // eslint-disable-next-line promise/param-names 6519 promise: new Promise((sourceResolve, sourceReject) => { 6520 resolve = sourceResolve; 6521 reject = sourceReject; 6522 }), 6523 resolve, 6524 reject 6525 }; 6526 extensionsStorage.set(extensionName, loadableExtensionEntry.promise); 6527 queue.set(extensionName, loadableExtensionEntry); 6528 }); 6529 timerId = setTimeout(() => { 6530 if (queue.size > 0) { 6531 void processExtensions(new Map(queue.entries())); 6532 queue.clear(); 6533 } 6534 }); 6535 const namespaces = await Promise.all(requestedNames.map(extensionName => { 6536 return extensionsStorage.get(extensionName); 6537 })); 6538 return namespaces.reduce((acc, namespace) => { 6539 return { 6540 ...acc, 6541 ...Reflection.getClass(namespace) 6542 }; 6543 }, {}); 6544 } 6545 6546 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]']; 6547 function isCloneable(value) { 6548 const isCloneableValue = Type.isObjectLike(value) && cloneableTags.includes(getTag(value)); 6549 return isCloneableValue || Type.isDomNode(value); 6550 } 6551 function internalClone(value, map) { 6552 if (map.has(value)) { 6553 return map.get(value); 6554 } 6555 if (isCloneable(value)) { 6556 if (Type.isArray(value)) { 6557 const cloned = Array.from(value); 6558 map.set(value, cloned); 6559 value.forEach((item, index) => { 6560 cloned[index] = internalClone(item, map); 6561 }); 6562 return map.get(value); 6563 } 6564 if (Type.isDomNode(value)) { 6565 return value.cloneNode(true); 6566 } 6567 if (Type.isMap(value)) { 6568 const result = new Map(); 6569 map.set(value, result); 6570 value.forEach((item, key) => { 6571 result.set(internalClone(key, map), internalClone(item, map)); 6572 }); 6573 return result; 6574 } 6575 if (Type.isSet(value)) { 6576 const result = new Set(); 6577 map.set(value, result); 6578 value.forEach(item => { 6579 result.add(internalClone(item, map)); 6580 }); 6581 return result; 6582 } 6583 if (Type.isDate(value)) { 6584 return new Date(value); 6585 } 6586 if (Type.isRegExp(value)) { 6587 const regExpFlags = /\w*$/; 6588 const flags = regExpFlags.exec(value); 6589 let result = new RegExp(value.source); 6590 if (flags && Type.isArray(flags)) { 6591 result = new RegExp(value.source, flags[0]); 6592 } 6593 result.lastIndex = value.lastIndex; 6594 return result; 6595 } 6596 const proto = Object.getPrototypeOf(value); 6597 const result = Object.assign(Object.create(proto), value); 6598 map.set(value, result); 6599 Object.keys(value).forEach(key => { 6600 result[key] = internalClone(value[key], map); 6601 }); 6602 return result; 6603 } 6604 return value; 6605 } 6606 6607 /** 6608 * Clones any cloneable object 6609 * @param value 6610 * @return {*} 6611 */ 6612 function clone(value) { 6613 return internalClone(value, new WeakMap()); 6614 } 6615 6616 function merge(current, target) { 6617 return Object.entries(target).reduce((acc, [key, value]) => { 6618 if (!Type.isDomNode(acc[key]) && Type.isObjectLike(acc[key]) && Type.isObjectLike(value)) { 6619 acc[key] = merge(acc[key], value); 6620 return acc; 6621 } 6622 acc[key] = value; 6623 return acc; 6624 }, current); 6625 } 6626 6627 function createComparator(fields, orders = []) { 6628 return (a, b) => { 6629 const field = fields[0]; 6630 const order = orders[0] || 'asc'; 6631 if (Type.isUndefined(field)) { 6632 return 0; 6633 } 6634 let valueA = a[field]; 6635 let valueB = b[field]; 6636 if (Type.isString(valueA) && Type.isString(valueB)) { 6637 valueA = valueA.toLowerCase(); 6638 valueB = valueB.toLowerCase(); 6639 } 6640 if (valueA < valueB) { 6641 return order === 'asc' ? -1 : 1; 6642 } 6643 if (valueA > valueB) { 6644 return order === 'asc' ? 1 : -1; 6645 } 6646 return createComparator(fields.slice(1), orders.slice(1))(a, b); 6647 }; 6648 } 6649 6650 function registerExtension(options) { 6651 if (!extensionsStorage.has(options.name)) { 6652 var _options$namespace; 6653 const namespace = (_options$namespace = options === null || options === void 0 ? void 0 : options.namespace) !== null && _options$namespace !== void 0 ? _options$namespace : 'window'; 6654 extensionsStorage.set(options.name, Promise.resolve(namespace)); 6655 } 6656 } 6657
6658 /** 6659 * @memberOf BX 6660 */ 6661 let Runtime = /*#__PURE__*/function () { 6662 function Runtime() { 6663 babelHelpers.classCallCheck(this, Runtime); 6664 } 6665 babelHelpers.createClass(Runtime, null, [{ 6666 key: "debounce", 6667 value: function debounce(func, wait = 0, context = null) { 6668 let timeoutId; 6669 return function debounced(...args) { 6670 if (Type.isNumber(timeoutId)) { 6671 clearTimeout(timeoutId); 6672 } 6673 timeoutId = setTimeout(() => { 6674 func.apply(context || this, args); 6675 }, wait); 6676 }; 6677 } 6678 }, { 6679 key: "throttle", 6680 value: function throttle(func, wait = 0, context = null) { 6681 let timer = 0; 6682 let invoke; 6683 return function wrapper(...args) { 6684 invoke = true; 6685 if (!timer) { 6686 const q = function q() { 6687 if (invoke) { 6688 func.apply(context || this, args); 6689 invoke = false; 6690 timer = setTimeout(q, wait); 6691 } else { 6692 timer = null; 6693 } 6694 }; 6695 q(); 6696 } 6697 }; 6698 } 6699 }, { 6700 key: "html", 6701 value: function html(node, _html, params = {}) { 6702 if (Type.isNil(_html) && Type.isDomNode(node)) { 6703 return node.innerHTML; 6704 } 6705 6706 // eslint-disable-next-line 6707 const parsedHtml = BX.processHTML(_html); 6708 const externalCss = parsedHtml.STYLE.reduce(fetchExternalStyles, []); 6709 const externalJs = parsedHtml.SCRIPT.reduce(fetchExternalScripts, []); 6710 const inlineJs = parsedHtml.SCRIPT.reduce(fetchInlineScripts, []); 6711 if (Type.isDomNode(node)) { 6712 if (params.htmlFirst || !externalJs.length && !externalCss.length) { 6713 if (params.useAdjacentHTML) { 6714 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 6715 } else { 6716 node.innerHTML = parsedHtml.HTML; 6717 } 6718 } 6719 } 6720 return Promise.all([loadAll(externalJs), loadAll(externalCss)]).then(() => { 6721 if (Type.isDomNode(node) && (externalJs.length > 0 || externalCss.length > 0)) { 6722 if (params.useAdjacentHTML) { 6723 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 6724 } else { 6725 node.innerHTML = parsedHtml.HTML; 6726 } 6727 } 6728 6729 // eslint-disable-next-line 6730 inlineJs.forEach(script => BX.evalGlobal(script)); 6731 if (Type.isFunction(params.callback)) { 6732 params.callback(); 6733 } 6734 }); 6735 } 6736 /** 6737 * Merges objects or arrays 6738 * @param targets 6739 * @return {any} 6740 */ 6741 }, { 6742 key: "merge", 6743 value: function merge$$1(...targets) { 6744 if (Type.isArray(targets[0])) { 6745 targets.unshift([]); 6746 } else if (Type.isObject(targets[0])) { 6747 targets.unshift({}); 6748 } 6749 return targets.reduce((acc, item) => { 6750 return merge(acc, item); 6751 }, targets[0]); 6752 } 6753 }, { 6754 key: "orderBy", 6755 value: function orderBy(collection, fields = [], orders = []) { 6756 const comparator = createComparator(fields, orders); 6757 return Object.values(collection).sort(comparator); 6758 } 6759 }, { 6760 key: "destroy", 6761 value: function destroy(target, errorMessage = 'Object is destroyed') { 6762 if (Type.isObject(target)) { 6763 const onPropertyAccess = () => { 6764 throw new Error(errorMessage); 6765 }; 6766 const ownProperties = Object.keys(target); 6767 const prototypeProperties = (() => { 6768 const targetPrototype = Object.getPrototypeOf(target); 6769 if (Type.isObject(targetPrototype)) { 6770 return Object.getOwnPropertyNames(targetPrototype); 6771 } 6772 return []; 6773 })(); 6774 const uniquePropertiesList = [...new Set([...ownProperties, ...prototypeProperties])]; 6775 uniquePropertiesList.filter(name => { 6776 const descriptor = Object.getOwnPropertyDescriptor(target, name); 6777 return !/__(.+)__/.test(name) && (!Type.isObject(descriptor) || descriptor.configurable === true); 6778 }
6778).forEach(name => { 6779 Object.defineProperty(target, name, { 6780 get: onPropertyAccess, 6781 set: onPropertyAccess, 6782 configurable: false 6783 }); 6784 }); 6785 Object.setPrototypeOf(target, null); 6786 } 6787 } 6788 }]); 6789 return Runtime; 6790 }(); 6791 babelHelpers.defineProperty(Runtime, "debug", debug); 6792 babelHelpers.defineProperty(Runtime, "loadExtension", loadExtension); 6793 babelHelpers.defineProperty(Runtime, "registerExtension", registerExtension); 6794 babelHelpers.defineProperty(Runtime, "clone", clone); 6795 6796 const _isError = Symbol.for('BX.BaseError.isError'); 6797 6798 /** 6799 * @memberOf BX 6800 */ 6801 let BaseError = /*#__PURE__*/function () { 6802 function BaseError(message, code, customData) { 6803 babelHelpers.classCallCheck(this, BaseError); 6804 this[_isError] = true; 6805 this.message = ''; 6806 this.code = null; 6807 this.customData = null; 6808 this.setMessage(message); 6809 this.setCode(code); 6810 this.setCustomData(customData); 6811 } 6812 6813 /** 6814 * Returns a brief description of the error 6815 * @returns {string} 6816 */ 6817 babelHelpers.createClass(BaseError, [{ 6818 key: "getMessage", 6819 value: function getMessage() { 6820 return this.message; 6821 } 6822 /** 6823 * Sets a message of the error 6824 * @param {string} message 6825 * @returns {this} 6826 */ 6827 }, { 6828 key: "setMessage", 6829 value: function setMessage(message) { 6830 if (Type.isString(message)) { 6831 this.message = message; 6832 } 6833 return this; 6834 } 6835 /** 6836 * Returns a code of the error 6837 * @returns {?string} 6838 */ 6839 }, { 6840 key: "getCode", 6841 value: function getCode() { 6842 return this.code; 6843 } 6844 /** 6845 * Sets a code of the error 6846 * @param {string} code 6847 * @returns {this} 6848 */ 6849 }, { 6850 key: "setCode", 6851 value: function setCode(code) { 6852 if (Type.isStringFilled(code) || code === null) { 6853 this.code = code; 6854 } 6855 return this; 6856 } 6857 /** 6858 * Returns custom data of the error 6859 * @returns {null|*} 6860 */ 6861 }, { 6862 key: "getCustomData", 6863 value: function getCustomData() { 6864 return this.customData; 6865 } 6866 /** 6867 * Sets custom data of the error 6868 * @returns {this} 6869 */ 6870 }, { 6871 key: "setCustomData", 6872 value: function setCustomData(customData) { 6873 if (!Type.isUndefined(customData)) { 6874 this.customData = customData; 6875 } 6876 return this; 6877 } 6878 }, { 6879 key: "toString", 6880 value: function toString() { 6881 const code = this.getCode(); 6882 const message = this.getMessage(); 6883 if (!Type.isStringFilled(code) && !Type.isStringFilled(message)) { 6884 return ''; 6885 } else if (!Type.isStringFilled(code)) { 6886 return `Error: ${message}`; 6887 } else if (!Type.isStringFilled(message)) { 6888 return code; 6889 } else { 6890 return `${code}: ${message}`; 6891 } 6892 } 6893 /** 6894 * Returns true if the object is an instance of BaseError 6895 * @param error 6896 * @returns {boolean} 6897 */ 6898 }], [{ 6899 key: "isError", 6900 value: function isError(error) { 6901 return Type.isObject(error) && error[_isError] === true; 6902 } 6903 }]); 6904 return BaseError; 6905 }(); 6906 6907 /** 6908 * Implements base event object interface 6909 */ 6910 let BaseEvent = /*#__PURE__*/function () { 6911 function BaseEvent(options = { 6912 data: {} 6913 }) { 6914 babelHelpers.classCallCheck(this, BaseEvent); 6915 this.type = ''; 6916 this.data = null; 6917 this.target = null; 6918 this.compatData = null; 6919 this.defaultPrevented = false; 6920 this.immediatePropagationStopped = false; 6921 this.errors = []; 6922 this.setData(options.data); 6923 this.setCompatData(options.compatData); 6924 } 6925 babelHelpers.createClass(BaseEvent, [{ 6926 key: "getType", 6927 /** 6928 * Returns the name of the event 6929 * @returns {string} 6930 */ 6931 value: function getType() { 6932 return this.type; 6933 } 6934 /** 6935 * 6936 * @param {string} type 6937 */ 6938 }, { 6939 key: "setType", 6940 value: function setType(type) { 6941 if (Type.isStringFilled(type)) { 6942 this.type = type; 6943 } 6944 return this; 6945 } 6946 /** 6947 * Returns an event data 6948 */ 6949 }, { 6950 key: "getData", 6951 value: function getData() { 6952 return this.data; 6953 } 6954 /** 6955 * Sets an event data 6956 * @param data 6957 */ 6958 }, { 6959 key: "setData", 6960 value: function setData(data) { 6961 if (!Type.isUndefined(data)) { 6962 this.data = data; 6963 } 6964 return this; 6965 } 6966 /** 6967 * Returns arguments for BX.addCustomEvent handlers (deprecated). 6968 * @returns {array | null} 6969 */ 6970 }, { 6971 key: "getCompatData", 6972 value: function getCompatData() { 6973 return this.compatData; 6974 } 6975 /** 6976 * Sets arguments for BX.addCustomEvent handlers (deprecated) 6977 * @param data 6978 */ 6979 }, { 6980 key: "setCompatData", 6981 value: function setCompatData(data) { 6982 if (Type.isArrayLike(data)) { 6983 this.compatData = data; 6984 } 6985 return this; 6986 } 6987 /** 6988 * Sets a event target 6989 * @param target 6990 */ 6991 }, { 6992 key: "setTarget", 6993 value: function setTarget(target) { 6994 this.target = target; 6995 return this; 6996 } 6997 /** 6998 * Returns a event target 6999 */ 7000 }, { 7001 key: "getTarget", 7002 value: function getTarget() { 7003 return this.target; 7004 } 7005 /** 7006 * Returns an array of event errors 7007 * @returns {[]} 7008 */ 7009 }, { 7010 key: "getErrors", 7011 value: function getErrors() { 7012 return this.errors; 7013 } 7014 /** 7015 * Adds an error of the event. 7016 * Event listeners can prevent emitter's default action and set the reason of this behavior. 7017 * @param error 7018 */ 7019 }, { 7020 key: "setError", 7021 value: function setError(error) { 7022 if (BaseError.isError(error)) { 7023 this.errors.push(error); 7024 } 7025 } 7026 /** 7027 * Prevents default action 7028 */ 7029 }, { 7030 key: "preventDefault", 7031 value: function preventDefault() { 7032 this.defaultPrevented = true; 7033 } 7034 /** 7035 * Checks that is default action prevented 7036 * @return {boolean} 7037 */ 7038 }, { 7039 key: "isDefaultPrevented", 7040 value: function isDefaultPrevented() { 7041 return this.defaultPrevented; 7042 } 7043 /** 7044 * Stops event immediate propagation 7045 */ 7046 }, { 7047 key: "stopImmediatePropagation", 7048 value: function stopImmediatePropagation() { 7049 this.immediatePropagationStopped = true; 7050 } 7051 /** 7052 * Checks that is immediate propagation stopped 7053 * @return {boolean} 7054 */ 7055 }, { 7056 key: "isImmediatePropagationStopped", 7057 value: function isImmediatePropagationStopped() { 7058 return this.immediatePropagationStopped; 7059 } 7060 }], [{ 7061 key: "create", 7062 value: function create(options) { 7063 return new this(options); 7064 } 7065 }]); 7066 return BaseEvent; 7067 }(); 7068 7069 let EventStore = /*#__PURE__*/function () { 7070 function EventStore(options = {}) { 7071 babelHelpers.classCallCheck(this, EventStore); 7072 this.defaultMaxListeners = Type.isNumber(options.defaultMaxListeners) ? options.defaultMaxListeners : 10; 7073 this.eventStore = new WeakMap(); 7074 } 7075 babelHelpers.createClass(EventStore, [{ 7076 key: "add", 7077 value: function add(target, options = {}) { 7078 const record = this.getRecordScheme(); 7079 if (Type.isNumber(options.maxListeners)) { 7080 record.maxListeners = options.maxListeners; 7081 } 7082 this.eventStore.set(target, record); 7083 return record; 7084 } 7085 }, { 7086 key: "get", 7087 value: function get(target) { 7088 return this.eventStore.get(target); 7089 } 7090 }, { 7091 key: "getOrAdd", 7092 value: function getOrAdd(target, options = {}) { 7093 return this.get(target) || this.add(target, options); 7094 } 7095 }, { 7096 key: "delete", 7097 value: function _delete(context) { 7098 this.eventStore.delete(context); 7099 } 7100 }, { 7101 key: "getRecordScheme", 7102 value: function getRecordScheme() { 7103 return { 7104 eventsMap: new Map(), 7105 onceMap: new Map(), 7106 maxListeners: this.getDefaultMaxListeners(), 7107 eventsMaxListeners: new Map() 7108 }; 7109 } 7110 }, { 7111 key: "getDefaultMaxListeners", 7112 value: function getDefaultMaxListeners() { 7113 return this.defaultMaxListeners; 7114 } 7115 }]); 7116 return EventStore; 7117 }(); 7118 7119 let WarningStore = /*#__PURE__*/function () {
7120 function WarningStore() { 7121 babelHelpers.classCallCheck(this, WarningStore); 7122 this.warnings = new Map(); 7123 this.printDelayed = Runtime.debounce(this.print.bind(this), 500); 7124 } 7125 babelHelpers.createClass(WarningStore, [{ 7126 key: "add", 7127 value: function add(target, eventName, listeners) { 7128 let contextWarnings = this.warnings.get(target); 7129 if (!contextWarnings) { 7130 contextWarnings = Object.create(null); 7131 this.warnings.set(target, contextWarnings); 7132 } 7133 if (!contextWarnings[eventName]) { 7134 contextWarnings[eventName] = {}; 7135 } 7136 contextWarnings[eventName].size = listeners.size; 7137 if (!Type.isArray(contextWarnings[eventName].errors)) { 7138 contextWarnings[eventName].errors = []; 7139 } 7140 contextWarnings[eventName].errors.push(new Error()); 7141 } 7142 }, { 7143 key: "print", 7144 value: function print() { 7145 this.warnings.forEach(warnings => { 7146 for (let eventName in warnings) { 7147 console.groupCollapsed('Possible BX.Event.EventEmitter memory leak detected. ' + warnings[eventName].size + ' "' + eventName + '" listeners added. ' + 'Use emitter.setMaxListeners() to increase limit.'); 7148 console.dir(warnings[eventName].errors); 7149 console.groupEnd(); 7150 } 7151 }); 7152 this.clear(); 7153 } 7154 }, { 7155 key: "clear", 7156 value: function clear() { 7157 this.warnings.clear(); 7158 } 7159 }, { 7160 key: "printDelayed", 7161 value: function printDelayed() {} 7162 }]); 7163 return WarningStore; 7164 }(); 7165 7166 const eventStore = new EventStore({ 7167 defaultMaxListeners: 10 7168 }); 7169 const warningStore = new WarningStore(); 7170 const aliasStore = new Map(); 7171 const globalTarget = { 7172 GLOBAL_TARGET: 'GLOBAL_TARGET' // this key only for debugging purposes 7173 }; 7174 7175 eventStore.add(globalTarget, { 7176 maxListeners: 25 7177 }); 7178 const isEmitterProperty = Symbol.for('BX.Event.EventEmitter.isEmitter'); 7179 const namespaceProperty = Symbol('namespaceProperty'); 7180 const targetProperty = Symbol('targetProperty'); 7181 let EventEmitter = /*#__PURE__*/function () { 7182 /** @private */ 7183 7184 function EventEmitter(...args) { 7185 babelHelpers.classCallCheck(this, EventEmitter); 7186 this[targetProperty] = null; 7187 this[namespaceProperty] = null; 7188 this[isEmitterProperty] = true; 7189 let target = this; 7190 if (Object.getPrototypeOf(this) === EventEmitter.prototype && args.length > 0) 7191 //new EventEmitter(obj) case 7192 { 7193 if (!Type.isObject(args[0])) { 7194 throw new TypeError(`The "target" argument must be an object.`); 7195 } 7196 target = args[0]; 7197 this.setEventNamespace(args[1]); 7198 } 7199 this[targetProperty] = target; 7200 } 7201 7202 /** 7203 * Makes a target observable 7204 * @param {object} target 7205 * @param {string} namespace 7206 */ 7207 babelHelpers.createClass(EventEmitter, [{ 7208 key: "setEventNamespace", 7209 value: function setEventNamespace(namespace) { 7210 if (Type.isStringFilled(namespace)) { 7211 this[namespaceProperty] = namespace; 7212 } 7213 } 7214 }, { 7215 key: "getEventNamespace", 7216 value: function getEventNamespace() { 7217 return this[namespaceProperty]; 7218 } 7219 /** 7220 * Subscribes listener on specified global event 7221 * @param {object} target 7222 * @param {string} eventName 7223 * @param {Function<BaseEvent>} listener 7224 * @param {object} options 7225 */ 7226 }, { 7227 key: "subscribe", 7228 /** 7229 * Subscribes a listener on a specified event 7230 * @param {string} eventName 7231 * @param {Function<BaseEvent>} listener 7232 * @return {this} 7233 */ 7234 value: function subscribe(eventName, listener) { 7235 EventEmitter.subscribe(this, eventName, listener); 7236 return this; 7237 } 7238 /** 7239 * 7240 * @param {object} options 7241 * @param {object} [aliases] 7242 * @param {boolean} [compatMode=false] 7243 */ 7244 }, { 7245 key: "subscribeFromOptions", 7246 value: function subscribeFromOptions(options, aliases, compatMode) { 7247 if (Type.isArrayFilled(options)) { 7248 options.forEach(events => { 7249 this.subscribeFromOptions(events); 7250 }); 7251 return; 7252 } 7253 if (!Type.isPlainObject(options)) { 7254 return; 7255 } 7256 aliases = Type.isPlainObject(aliases) ? EventEmitter.normalizeAliases(aliases) : {};
7257 Object.keys(options).forEach(eventName => { 7258 const listener = EventEmitter.normalizeListener(options[eventName]); 7259 eventName = EventEmitter.normalizeEventName(eventName); 7260 if (aliases[eventName]) { 7261 const { 7262 eventName: actualName 7263 } = aliases[eventName]; 7264 EventEmitter.subscribe(this, actualName, listener, { 7265 compatMode: compatMode !== false 7266 }); 7267 } else { 7268 EventEmitter.subscribe(this, eventName, listener, { 7269 compatMode: compatMode === true 7270 }); 7271 } 7272 }); 7273 } 7274 /** 7275 * Subscribes a listener that is called at 7276 * most once for a specified event. 7277 * @param {object} target 7278 * @param {string} eventName 7279 * @param {Function<BaseEvent>} listener 7280 */ 7281 }, { 7282 key: "subscribeOnce", 7283 /** 7284 * Subscribes a listener that is called at most once for a specified event. 7285 * @param {string} eventName 7286 * @param {Function<BaseEvent>} listener 7287 * @return {this} 7288 */ 7289 value: function subscribeOnce(eventName, listener) { 7290 EventEmitter.subscribeOnce(this, eventName, listener); 7291 return this; 7292 } 7293 /** 7294 * Unsubscribes an event listener 7295 * @param {object} target 7296 * @param {string} eventName 7297 * @param {Function<BaseEvent>} listener 7298 * @param options 7299 */ 7300 }, { 7301 key: "unsubscribe", 7302 /** 7303 * Unsubscribes an event listener 7304 * @param {string} eventName 7305 * @param {Function<BaseEvent>} listener 7306 * @return {this} 7307 */ 7308 value: function unsubscribe(eventName, listener) { 7309 EventEmitter.unsubscribe(this, eventName, listener); 7310 return this; 7311 } 7312 /** 7313 * Unsubscribes all event listeners 7314 * @param {object} target 7315 * @param {string} eventName 7316 * @param options 7317 */ 7318 }, { 7319 key: "unsubscribeAll", 7320 /** 7321 * Unsubscribes all event listeners 7322 * @param {string} [eventName] 7323 */ 7324 value: function unsubscribeAll(eventName) { 7325 EventEmitter.unsubscribeAll(this, eventName); 7326 } 7327 /** 7328 * 7329 * @param {object} target 7330 * @param {string} eventName 7331 * @param {BaseEvent | any} event 7332 * @param {object} options 7333 * @returns {Array} 7334 */ 7335 }, { 7336 key: "emit", 7337 /** 7338 * Emits specified event with specified event object 7339 * @param {string} eventName 7340 * @param {BaseEvent | any} event 7341 * @return {this} 7342 */ 7343 value: function emit(eventName, event) { 7344 if (this.getEventNamespace() === null) { 7345 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7346 } 7347 EventEmitter.emit(this, eventName, event); 7348 return this; 7349 } 7350 /** 7351 * Emits global event and returns a promise that is resolved when 7352 * all promise returned from event handlers are resolved, 7353 * or rejected when at least one of the returned promise is rejected. 7354 * Importantly. You can return any value from synchronous handlers, not just promise 7355 * @param {object} target 7356 * @param {string} eventName 7357 * @param {BaseEvent | any} event 7358 * @return {Promise<Array>} 7359 */ 7360 }, { 7361 key: "emitAsync", 7362 /** 7363 * Emits event and returns a promise that is resolved when 7364 * all promise returned from event handlers are resolved, 7365 * or rejected when at least one of the returned promise is rejected. 7366 * Importantly. You can return any value from synchronous handlers, not just promise 7367 * @param {string} eventName 7368 * @param {BaseEvent|any} event 7369 * @return {Promise<Array>} 7370 */ 7371 value: function emitAsync(eventName, event) { 7372 if (this.getEventNamespace() === null) { 7373 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7374 } 7375 return EventEmitter.emitAsync(this, eventName, event); 7376 } 7377 /** 7378 * @private 7379 * @param {object} target 7380 * @param {string} eventName 7381 * @param {BaseEvent|any} event 7382 * @returns {BaseEvent} 7383 */ 7384 }, { 7385 key: "setMaxListeners", 7386 /** 7387 * Sets max events listeners count 7388 * this.setMaxListeners(10) - sets the default value for all events
7389 * this.setMaxListeners("onClose", 10) sets the value for onClose event 7390 * @return {this} 7391 * @param args 7392 */ 7393 value: function setMaxListeners(...args) { 7394 EventEmitter.setMaxListeners(this, ...args); 7395 return this; 7396 } 7397 /** 7398 * Returns max event listeners count 7399 * @param {object} target 7400 * @param {string} [eventName] 7401 * @returns {number} 7402 */ 7403 }, { 7404 key: "getMaxListeners", 7405 /** 7406 * Returns max event listeners count 7407 * @param {string} [eventName] 7408 * @returns {number} 7409 */ 7410 value: function getMaxListeners(eventName) { 7411 return EventEmitter.getMaxListeners(this, eventName); 7412 } 7413 /** 7414 * Adds or subtracts max listeners count 7415 * Event.EventEmitter.addMaxListeners() - adds one max listener for all events of global target 7416 * Event.EventEmitter.addMaxListeners(3) - adds three max listeners for all events of global target 7417 * Event.EventEmitter.addMaxListeners(-1) - subtracts one max listener for all events of global target 7418 * Event.EventEmitter.addMaxListeners('onClose') - adds one max listener for onClose event of global target 7419 * Event.EventEmitter.addMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 7420 * Event.EventEmitter.addMaxListeners('onClose', -1) - subtracts one max listener for onClose event of global target 7421 * 7422 * Event.EventEmitter.addMaxListeners(obj) - adds one max listener for all events of 'obj' target 7423 * Event.EventEmitter.addMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 7424 * Event.EventEmitter.addMaxListeners(obj, -1) - subtracts one max listener for all events of 'obj' target 7425 * Event.EventEmitter.addMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 7426 * Event.EventEmitter.addMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 7427 * Event.EventEmitter.addMaxListeners(obj, 'onClose', -1) - subtracts one max listener for onClose event of 'obj' target 7428 * @param args 7429 * @returns {number} 7430 */ 7431 }, { 7432 key: "incrementMaxListeners", 7433 /** 7434 * Increases max listeners count 7435 * this.incrementMaxListeners() - adds one max listener for all events 7436 * this.incrementMaxListeners(3) - adds three max listeners for all events 7437 * this.incrementMaxListeners('onClose') - adds one max listener for onClose event 7438 * this.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event 7439 */ 7440 value: function incrementMaxListeners(...args) { 7441 return EventEmitter.incrementMaxListeners(this, ...args); 7442 } 7443 /** 7444 * Decreases max listeners count 7445 * 7446 * Event.EventEmitter.decrementMaxListeners() - subtracts one max listener for all events of global target 7447 * Event.EventEmitter.decrementMaxListeners(3) - subtracts three max listeners for all events of global target 7448 * Event.EventEmitter.decrementMaxListeners('onClose') - subtracts one max listener for onClose event of global target 7449 * Event.EventEmitter.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event of global target 7450 * 7451 * Event.EventEmitter.decrementMaxListeners(obj) - subtracts one max listener for all events of 'obj' target 7452 * Event.EventEmitter.decrementMaxListeners(obj, 3) - subtracts three max listeners for all events of 'obj' target 7453 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose') - subtracts one max listener for onClose event of 'obj' target 7454 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose', 2) - subtracts two max listeners for onClose event of 'obj' target 7455 */ 7456 }, { 7457 key: "decrementMaxListeners", 7458 /** 7459 * Increases max listeners count 7460 * this.decrementMaxListeners() - subtracts one max listener for all events 7461 * this.decrementMaxListeners(3) - subtracts three max listeners for all events 7462 * this.decrementMaxListeners('onClose') - subtracts one max listener for onClose event 7463 * this.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event 7464 */ 7465 value: function decrementMaxListeners(...args) { 7466 return EventEmitter.decrementMaxListeners(this, ...args); 7467 } 7468 /** 7469 * @private 7470 * @param {Array} args 7471 * @returns Array 7472 */ 7473 }, { 7474 key: "getListeners", 7475 /** 7476 * Gets listeners list for specified event 7477 * @param {string} eventName 7478 */ 7479 value: function getListeners(eventName) { 7480 return EventEmitter.getListeners(this, eventName); 7481 } 7482 /** 7483 * Returns a full event name with namespace 7484 * @param {string} eventName 7485 * @returns {string} 7486 */ 7487 }, { 7488 key: "getFullEventName", 7489 value: function getFullEventName(eventName) { 7490 if (!Type.isStringFilled(eventName)) { 7491 throw new TypeError(`The "eventName" argument must be a string.`); 7492 } 7493 return EventEmitter.makeFullEventName(this.getEventNamespace(), eventName); 7494 } 7495 /** 7496 * Registers aliases (old event names for BX.onCustomEvent) 7497 * @param aliases 7498 */ 7499 }], [{ 7500 key: "makeObservable", 7501 value: function makeObservable(target, namespace) { 7502 if (!Type.isObject(target)) { 7503 throw new TypeError('The "target" argument must be an object.'); 7504 } 7505 if (!Type.isStringFilled(namespace)) { 7506 throw new TypeError('The "namespace" must be an non-empty string.'); 7507 } 7508 if (EventEmitter.isEventEmitter(target)) { 7509 throw new TypeError('The "target" is an event emitter already.'); 7510 } 7511 const targetProto = Object.getPrototypeOf(target); 7512 const emitter = new EventEmitter(); 7513 emitter.setEventNamespace(namespace); 7514 Object.setPrototypeOf(emitter, targetProto); 7515 Object.setPrototypeOf(target, emitter); 7516 Object.getOwnPropertyNames(EventEmitter.prototype).forEach(method => {
7517 if (['constructor'].includes(method)) { 7518 return; 7519 } 7520 emitter[method] = function (...args) { 7521 return EventEmitter.prototype[method].apply(target, args); 7522 }; 7523 }); 7524 } 7525 }, { 7526 key: "subscribe", 7527 value: function subscribe(target, eventName, listener, options) { 7528 if (Type.isString(target)) { 7529 options = listener; 7530 listener = eventName; 7531 eventName = target; 7532 target = this.GLOBAL_TARGET; 7533 } 7534 if (!Type.isObject(target)) { 7535 throw new TypeError(`The "target" argument must be an object.`); 7536 } 7537 eventName = this.normalizeEventName(eventName); 7538 if (!Type.isStringFilled(eventName)) { 7539 throw new TypeError(`The "eventName" argument must be a string.`); 7540 } 7541 listener = this.normalizeListener(listener); 7542 options = Type.isPlainObject(options) ? options : {}; 7543 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7544 const { 7545 eventsMap, 7546 onceMap 7547 } = eventStore.getOrAdd(target); 7548 const onceListeners = onceMap.get(fullEventName); 7549 let listeners = eventsMap.get(fullEventName); 7550 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7551 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7552 } else { 7553 if (listeners) { 7554 listeners.set(listener, { 7555 listener, 7556 options, 7557 sort: this.getNextSequenceValue() 7558 }); 7559 } else { 7560 listeners = new Map([[listener, { 7561 listener, 7562 options, 7563 sort: this.getNextSequenceValue() 7564 }]]); 7565 eventsMap.set(fullEventName, listeners); 7566 } 7567 } 7568 const maxListeners = this.getMaxListeners(target, eventName); 7569 if (listeners.size > maxListeners) { 7570 warningStore.add(target, fullEventName, listeners); 7571 warningStore.printDelayed(); 7572 } 7573 } 7574 }, { 7575 key: "subscribeOnce", 7576 value: function subscribeOnce(target, eventName, listener) { 7577 if (Type.isString(target)) { 7578 listener = eventName; 7579 eventName = target; 7580 target = this.GLOBAL_TARGET;
7581 } 7582 if (!Type.isObject(target)) { 7583 throw new TypeError(`The "target" argument must be an object.`); 7584 } 7585 eventName = this.normalizeEventName(eventName); 7586 if (!Type.isStringFilled(eventName)) { 7587 throw new TypeError(`The "eventName" argument must be a string.`); 7588 } 7589 listener = this.normalizeListener(listener); 7590 const fullEventName = this.resolveEventName(eventName, target); 7591 const { 7592 eventsMap, 7593 onceMap 7594 } = eventStore.getOrAdd(target); 7595 const listeners = eventsMap.get(fullEventName); 7596 let onceListeners = onceMap.get(fullEventName); 7597 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7598 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7599 } else { 7600 const once = (...args) => { 7601 this.unsubscribe(target, eventName, once); 7602 onceListeners.delete(listener); 7603 listener(...args); 7604 }; 7605 if (onceListeners) { 7606 onceListeners.set(listener, once); 7607 } else { 7608 onceListeners = new Map([[listener, once]]); 7609 onceMap.set(fullEventName, onceListeners); 7610 } 7611 this.subscribe(target, eventName, once); 7612 } 7613 } 7614 }, { 7615 key: "unsubscribe", 7616 value: function unsubscribe(target, eventName, listener, options) { 7617 if (Type.isString(target)) { 7618 listener = eventName; 7619 eventName = target; 7620 target = this.GLOBAL_TARGET;
7621 } 7622 eventName = this.normalizeEventName(eventName); 7623 if (!Type.isStringFilled(eventName)) { 7624 throw new TypeError(`The "eventName" argument must be a string.`); 7625 } 7626 listener = this.normalizeListener(listener); 7627 options = Type.isPlainObject(options) ? options : {}; 7628 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7629 const targetInfo = eventStore.get(target); 7630 const listeners = targetInfo && targetInfo.eventsMap.get(fullEventName); 7631 const onceListeners = targetInfo && targetInfo.onceMap.get(fullEventName); 7632 if (listeners) { 7633 listeners.delete(listener); 7634 } 7635 if (onceListeners) { 7636 const once = onceListeners.get(listener); 7637 if (once) { 7638 onceListeners.delete(listener); 7639 listeners.delete(once); 7640 } 7641 } 7642 } 7643 }, { 7644 key: "unsubscribeAll", 7645 value: function unsubscribeAll(target, eventName, options) { 7646 if (Type.isString(target)) { 7647 eventName = target; 7648 target = this.GLOBAL_TARGET;
7649 } 7650 if (Type.isStringFilled(eventName)) { 7651 const targetInfo = eventStore.get(target); 7652 if (targetInfo) { 7653 options = Type.isPlainObject(options) ? options : {}; 7654 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7655 targetInfo.eventsMap.delete(fullEventName); 7656 targetInfo.onceMap.delete(fullEventName); 7657 } 7658 } else if (Type.isNil(eventName)) { 7659 if (target === this.GLOBAL_TARGET) { 7660 console.error('You cannot unsubscribe all global listeners.'); 7661 } else { 7662 eventStore.delete(target); 7663 } 7664 } 7665 } 7666 }, { 7667 key: "emit", 7668 value: function emit(target, eventName, event, options) { 7669 if (Type.isString(target)) { 7670 options = event; 7671 event = eventName; 7672 eventName = target; 7673 target = this.GLOBAL_TARGET; 7674 } 7675 if (!Type.isObject(target)) { 7676 throw new TypeError(`The "target" argument must be an object.`); 7677 } 7678 eventName = this.normalizeEventName(eventName); 7679 if (!Type.isStringFilled(eventName)) { 7680 throw new TypeError(`The "eventName" argument must be a string.`); 7681 } 7682 options = Type.isPlainObject(options) ? options : {}; 7683 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7684 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 7685 const globalListeners = globalEvents && globalEvents.eventsMap.get(fullEventName) || new Map(); 7686 let targetListeners = new Set(); 7687 if (target !== this.GLOBAL_TARGET) { 7688 const targetEvents = eventStore.get(target); 7689 targetListeners = targetEvents && targetEvents.eventsMap.get(fullEventName) || new Map(); 7690 } 7691 const listeners = [...globalListeners.values(), ...targetListeners.values()]; 7692 listeners.sort(function (a, b) { 7693 return a.sort - b.sort; 7694 }); 7695 const preparedEvent = this.prepareEvent(target, fullEventName, event); 7696 const result = []; 7697 for (let i = 0; i < listeners.length; i++) { 7698 if (preparedEvent.isImmediatePropagationStopped()) { 7699 break; 7700 } 7701 const { 7702 listener, 7703 options: listenerOptions 7704 } = listeners[i]; 7705 7706 //A previous listener could remove a current listener. 7707 if (globalListeners.has(listener) || targetListeners.has(listener)) { 7708 let listenerResult; 7709 if (listenerOptions.compatMode) { 7710 let params = []; 7711 const compatData = preparedEvent.getCompatData(); 7712 if (compatData !== null) { 7713 params = options.cloneData === true ? Runtime.clone(compatData) : compatData; 7714 } else { 7715 params = [preparedEvent]; 7716 } 7717 const context = Type.isUndefined(options.thisArg) ? target : options.thisArg; 7718 listenerResult = listener.apply(context, params); 7719 } else { 7720 listenerResult = Type.isUndefined(options.thisArg) ? listener(preparedEvent) : listener.call(options.thisArg, preparedEvent); 7721 } 7722 result.push(listenerResult); 7723 } 7724 } 7725 return result; 7726 } 7727 }, { 7728 key: "emitAsync", 7729 value: function emitAsync(target, eventName, event) { 7730 if (Type.isString(target)) { 7731 event = eventName; 7732 eventName = target; 7733 target = this.GLOBAL_TARGET;
7734 } 7735 return Promise.all(this.emit(target, eventName, event)); 7736 } 7737 }, { 7738 key: "prepareEvent", 7739 value: function prepareEvent(target, eventName, event) { 7740 let preparedEvent = event; 7741 if (!(event instanceof BaseEvent)) { 7742 preparedEvent = new BaseEvent(); 7743 preparedEvent.setData(event); 7744 } 7745 preparedEvent.setTarget(this.isEventEmitter(target) ? target[targetProperty] : target); 7746 preparedEvent.setType(eventName); 7747 return preparedEvent; 7748 } 7749 /** 7750 * @private 7751 * @returns {number} 7752 */ 7753 }, { 7754 key: "getNextSequenceValue", 7755 value: function getNextSequenceValue() { 7756 return this.sequenceValue++; 7757 } 7758 /** 7759 * Sets max global events listeners count 7760 * Event.EventEmitter.setMaxListeners(10) - sets the default value for all events (global target) 7761 * Event.EventEmitter.setMaxListeners("onClose", 10) - sets the value for onClose event (global target) 7762 * Event.EventEmitter.setMaxListeners(obj, 10) - sets the default value for all events (obj target) 7763 * Event.EventEmitter.setMaxListeners(obj, "onClose", 10); - sets the value for onClose event (obj target) 7764 * @return {void} 7765 * @param args 7766 */ 7767 }, { 7768 key: "setMaxListeners", 7769 value: function setMaxListeners(...args) { 7770 let target = this.GLOBAL_TARGET;
7771 let eventName = null; 7772 let count = undefined; 7773 if (args.length === 1) { 7774 count = args[0]; 7775 } else if (args.length === 2) { 7776 if (Type.isString(args[0])) { 7777 [eventName, count] = args; 7778 } else { 7779 [target, count] = args; 7780 } 7781 } else if (args.length >= 3) { 7782 [target, eventName, count] = args; 7783 } 7784 if (!Type.isObject(target)) { 7785 throw new TypeError(`The "target" argument must be an object.`); 7786 } 7787 if (eventName !== null && !Type.isStringFilled(eventName)) { 7788 throw new TypeError(`The "eventName" argument must be a string.`); 7789 } 7790 if (!Type.isNumber(count) || count < 0) { 7791 throw new TypeError(`The value of "count" is out of range. It must be a non-negative number. Received ${count}.`); 7792 } 7793 const targetInfo = eventStore.getOrAdd(target); 7794 if (Type.isStringFilled(eventName)) { 7795 const fullEventName = this.resolveEventName(eventName, target); 7796 targetInfo.eventsMaxListeners.set(fullEventName, count); 7797 } else { 7798 targetInfo.maxListeners = count; 7799 } 7800 } 7801 }, { 7802 key: "getMaxListeners", 7803 value: function getMaxListeners(target, eventName) { 7804 if (Type.isString(target)) { 7805 eventName = target; 7806 target = this.GLOBAL_TARGET;
7807 } else if (Type.isNil(target)) { 7808 target = this.GLOBAL_TARGET; 7809 } 7810 if (!Type.isObject(target)) { 7811 throw new TypeError(`The "target" argument must be an object.`); 7812 } 7813 const targetInfo = eventStore.get(target); 7814 if (targetInfo) { 7815 let maxListeners = targetInfo.maxListeners; 7816 if (Type.isStringFilled(eventName)) { 7817 const fullEventName = this.resolveEventName(eventName, target); 7818 maxListeners = targetInfo.eventsMaxListeners.get(fullEventName) || maxListeners; 7819 } 7820 return maxListeners; 7821 } 7822 return this.DEFAULT_MAX_LISTENERS; 7823 } 7824 }, { 7825 key: "addMaxListeners", 7826 value: function addMaxListeners(...args) { 7827 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 7828 const maxListeners = Math.max(this.getMaxListeners(target, eventName) + increment, 0); 7829 if (Type.isStringFilled(eventName)) { 7830 EventEmitter.setMaxListeners(target, eventName, maxListeners); 7831 } else { 7832 EventEmitter.setMaxListeners(target, maxListeners); 7833 } 7834 return maxListeners; 7835 } 7836 /** 7837 * Increases max listeners count 7838 * 7839 * Event.EventEmitter.incrementMaxListeners() - adds one max listener for all events of global target 7840 * Event.EventEmitter.incrementMaxListeners(3) - adds three max listeners for all events of global target 7841 * Event.EventEmitter.incrementMaxListeners('onClose') - adds one max listener for onClose event of global target 7842 * Event.EventEmitter.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 7843 * 7844 * Event.EventEmitter.incrementMaxListeners(obj) - adds one max listener for all events of 'obj' target 7845 * Event.EventEmitter.incrementMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 7846 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 7847 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 7848 */ 7849 }, { 7850 key: "incrementMaxListeners", 7851 value: function incrementMaxListeners(...args) { 7852 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 7853 return this.addMaxListeners(target, eventName, Math.abs(increment)); 7854 } 7855 }, { 7856 key: "decrementMaxListeners", 7857 value: function decrementMaxListeners(...args) { 7858 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 7859 return this.addMaxListeners(target, eventName, -Math.abs(increment)); 7860 } 7861 }, { 7862 key: "destructMaxListenersArgs", 7863 value: function destructMaxListenersArgs(...args) { 7864 let eventName = null; 7865 let increment = 1; 7866 let target = this.GLOBAL_TARGET;
7867 if (args.length === 1) { 7868 if (Type.isNumber(args[0])) { 7869 increment = args[0]; 7870 } else if (Type.isString(args[0])) { 7871 eventName = args[0]; 7872 } else { 7873 target = args[0]; 7874 } 7875 } else if (args.length === 2) { 7876 if (Type.isString(args[0])) { 7877 [eventName, increment] = args; 7878 } else if (Type.isString(args[1])) { 7879 [target, eventName] = args; 7880 } else { 7881 [target, increment] = args; 7882 } 7883 } else if (args.length >= 3) { 7884 [target, eventName, increment] = args; 7885 } 7886 if (!Type.isObject(target)) { 7887 throw new TypeError(`The "target" argument must be an object.`); 7888 } 7889 if (eventName !== null && !Type.isStringFilled(eventName)) { 7890 throw new TypeError(`The "eventName" argument must be a string.`); 7891 } 7892 if (!Type.isNumber(increment)) { 7893 throw new TypeError(`The value of "increment" must be a number.`); 7894 } 7895 return [target, eventName, increment]; 7896 } 7897 /** 7898 * Gets listeners list for a specified event 7899 * @param {object} target 7900 * @param {string} eventName 7901 */ 7902 }, { 7903 key: "getListeners", 7904 value: function getListeners(target, eventName) { 7905 if (Type.isString(target)) { 7906 eventName = target; 7907 target = this.GLOBAL_TARGET;
7908 } 7909 if (!Type.isObject(target)) { 7910 throw new TypeError(`The "target" argument must be an object.`); 7911 } 7912 eventName = this.normalizeEventName(eventName); 7913 if (!Type.isStringFilled(eventName)) { 7914 throw new TypeError(`The "eventName" argument must be a string.`); 7915 } 7916 const targetInfo = eventStore.get(target); 7917 if (!targetInfo) { 7918 return new Map(); 7919 } 7920 const fullEventName = this.resolveEventName(eventName, target); 7921 return targetInfo.eventsMap.get(fullEventName) || new Map(); 7922 } 7923 }, { 7924 key: "registerAliases", 7925 value: function registerAliases(aliases) { 7926 aliases = this.normalizeAliases(aliases); 7927 Object.keys(aliases).forEach(alias => { 7928 aliasStore.set(alias, { 7929 eventName: aliases[alias].eventName, 7930 namespace: aliases[alias].namespace 7931 }); 7932 }); 7933 EventEmitter.mergeEventAliases(aliases); 7934 } 7935 /** 7936 * @private 7937 * @param aliases 7938 */ 7939 }, { 7940 key: "normalizeAliases", 7941 value: function normalizeAliases(aliases) { 7942 if (!Type.isPlainObject(aliases)) { 7943 throw new TypeError(`The "aliases" argument must be an object.`); 7944 } 7945 const result = Object.create(null); 7946 for (let alias in aliases) { 7947 if (!Type.isStringFilled(alias)) { 7948 throw new TypeError(`The alias must be an non-empty string.`); 7949 } 7950 const options = aliases[alias]; 7951 if (!options || !Type.isStringFilled(options.eventName) || !Type.isStringFilled(options.namespace)) { 7952 throw new TypeError(`The alias options must set the "eventName" and the "namespace".`); 7953 } 7954 alias = this.normalizeEventName(alias); 7955 result[alias] = { 7956 eventName: options.eventName, 7957 namespace: options.namespace 7958 }; 7959 } 7960 return result; 7961 } 7962 /** 7963 * @private 7964 */ 7965 }, { 7966 key: "mergeEventAliases", 7967 value: function mergeEventAliases(aliases) { 7968 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 7969 if (!globalEvents) { 7970 return; 7971 } 7972 Object.keys(aliases).forEach(alias => { 7973 const options = aliases[alias]; 7974 alias = this.normalizeEventName(alias); 7975 const fullEventName = this.makeFullEventName(options.namespace, options.eventName); 7976 const aliasListeners = globalEvents.eventsMap.get(alias); 7977 if (aliasListeners) { 7978 const listeners = globalEvents.eventsMap.get(fullEventName) || new Map(); 7979 globalEvents.eventsMap.set(fullEventName, new Map([...listeners, ...aliasListeners])); 7980 globalEvents.eventsMap.delete(alias); 7981 } 7982 const aliasOnceListeners = globalEvents.onceMap.get(alias); 7983 if (aliasOnceListeners) { 7984 const onceListeners = globalEvents.onceMap.get(fullEventName) || new Map(); 7985 globalEvents.onceMap.set(fullEventName, new Map([...onceListeners, ...aliasOnceListeners])); 7986 globalEvents.onceMap.delete(alias); 7987 } 7988 const aliasMaxListeners = globalEvents.eventsMaxListeners.get(alias); 7989 if (aliasMaxListeners) { 7990 const eventMaxListeners = globalEvents.eventsMaxListeners.get(fullEventName) || 0; 7991 globalEvents.eventsMaxListeners.set(fullEventName, Math.max(eventMaxListeners, aliasMaxListeners)); 7992 globalEvents.eventsMaxListeners.delete(alias); 7993 } 7994 }); 7995 } 7996 /** 7997 * Returns true if the target is an instance of Event.EventEmitter 7998 * @param {object} target 7999 * @returns {boolean} 8000 */ 8001 }, { 8002 key: "isEventEmitter", 8003 value: function isEventEmitter(target) { 8004 return Type.isObject(target) && target[isEmitterProperty] === true; 8005 } 8006 /** 8007 * @private 8008 * @param {string} eventName 8009 * @returns {string} 8010 */ 8011 }, { 8012 key: "normalizeEventName", 8013 value: function normalizeEventName(eventName) { 8014 if (!Type.isStringFilled(eventName)) { 8015 return ''; 8016 } 8017 return eventName.toLowerCase(); 8018 } 8019 /** 8020 * @private 8021 */ 8022 }, { 8023 key: "normalizeListener", 8024 value: function normalizeListener(listener) { 8025 if (Type.isString(listener)) { 8026 listener = Reflection.getClass(listener); 8027 } 8028 if (!Type.isFunction(listener)) { 8029 throw new TypeError(`The "listener" argument must be of type Function. Received type ${typeof listener}.`); 8030 } 8031 return listener; 8032 } 8033 /** 8034 * @private 8035 * @param eventName 8036 * @param target 8037 * @param useGlobalNaming 8038 * @returns {string} 8039 */ 8040 }, { 8041 key: "resolveEventName", 8042 value: function resolveEventName(eventName, target, useGlobalNaming = false) { 8043 eventName = this.normalizeEventName(eventName); 8044 if (!Type.isStringFilled(eventName)) { 8045 return ''; 8046 } 8047 if (this.isEventEmitter(target) && useGlobalNaming !== true) { 8048 if (target.getEventNamespace() !== null && eventName.includes('.')) { 8049 console.warn(`Possible the wrong event name "${eventName}".`); 8050 } 8051 eventName = target.getFullEventName(eventName); 8052 } else if (aliasStore.has(eventName)) { 8053 const { 8054 namespace, 8055 eventName: actualEventName 8056 } = aliasStore.get(eventName); 8057 eventName = this.makeFullEventName(namespace, actualEventName); 8058 } 8059 return eventName; 8060 } 8061 /** 8062 * @private 8063 * @param {string} namespace 8064 * @param {string} eventName 8065 * @returns {string} 8066 */ 8067 }, { 8068 key: "makeFullEventName", 8069 value: function makeFullEventName(namespace, eventName) { 8070 const fullName = Type.isStringFilled(namespace) ? `${namespace}:${eventName}` : eventName; 8071 return Type.isStringFilled(fullName) ? fullName.toLowerCase() : ''; 8072 } 8073 }]); 8074 return EventEmitter; 8075 }(); 8076 babelHelpers.defineProperty(EventEmitter, "GLOBAL_TARGET", globalTarget); 8077 babelHelpers.defineProperty(EventEmitter, "DEFAULT_MAX_LISTENERS", eventStore.getDefaultMaxListeners()); 8078 babelHelpers.defineProperty(EventEmitter, "sequenceValue", 1); 8079 8080 let stack = []; 8081 /** 8082 * For compatibility only 8083 * @type {boolean} 8084 */ 8085 // eslint-disable-next-line 8086 exports.isReady = false;
8087 function ready(handler) { 8088 if (!Type.isFunction(handler)) { 8089 return; 8090 } 8091 if (exports.isReady) { 8092 handler(); 8093 } else { 8094 stack.push(handler); 8095 } 8096 } 8097 bindOnce(document, 'DOMContentLoaded', () => { 8098 exports.isReady = true; 8099 stack.forEach(handler => { 8100 handler(); 8101 }); 8102 stack = []; 8103 }); 8104 8105 /** 8106 * @memberOf BX 8107 */ 8108 let Event = function Event() { 8109 babelHelpers.classCallCheck(this, Event); 8110 }; 8111 babelHelpers.defineProperty(Event, "bind", bind); 8112 babelHelpers.defineProperty(Event, "bindOnce", bindOnce); 8113 babelHelpers.defineProperty(Event, "unbind", unbind); 8114 babelHelpers.defineProperty(Event, "unbindAll", unbindAll); 8115 babelHelpers.defineProperty(Event, "ready", ready); 8116 babelHelpers.defineProperty(Event, "EventEmitter", EventEmitter); 8117 babelHelpers.defineProperty(Event, "BaseEvent", BaseEvent); 8118 8119 function encodeAttributeValue(value) { 8120 if (Type.isPlainObject(value) || Type.isArray(value)) { 8121 return JSON.stringify(value); 8122 } 8123 return Text.encode(Text.decode(value)); 8124 } 8125 8126 function decodeAttributeValue(value) { 8127 if (Type.isString(value)) { 8128 const decodedValue = Text.decode(value); 8129 let result; 8130 try { 8131 result = JSON.parse(decodedValue); 8132 } catch (e) { 8133 result = decodedValue; 8134 } 8135 if (result === decodedValue) { 8136 if (/^[\d.]+[.]?\d+$/.test(result)) { 8137 return Number(result); 8138 } 8139 } 8140 if (result === 'true' || result === 'false') { 8141 return Boolean(result); 8142 } 8143 return result; 8144 } 8145 return value; 8146 } 8147 8148 function getPageScroll() { 8149 const { 8150 documentElement, 8151 body 8152 } = document; 8153 const scrollTop = Math.max(window.pageYOffset || 0, documentElement ? documentElement.scrollTop : 0, body ? body.scrollTop : 0); 8154 const scrollLeft = Math.max(window.pageXOffset || 0, documentElement ? documentElement.scrollLeft : 0, body ? body.scrollLeft : 0); 8155 return { 8156 scrollTop, 8157 scrollLeft 8158 }; 8159 } 8160 8161 /* eslint-disable @bitrix24/bitrix24-rules/no-classlist */ 8162 8163 /** 8164 * @memberOf BX 8165 */ 8166 let Dom = /*#__PURE__*/function () { 8167 function Dom() { 8168 babelHelpers.classCallCheck(this, Dom); 8169 } 8170 babelHelpers.createClass(Dom, null, [{ 8171 key: "replace", 8172 /** 8173 * Replaces old html element to new html element 8174 * @param oldElement 8175 * @param newElement 8176 */ 8177 value: function replace(oldElement, newElement) { 8178 if (Type.isDomNode(oldElement) && Type.isDomNode(newElement)) { 8179 if (Type.isDomNode(oldElement.parentNode)) { 8180 oldElement.parentNode.replaceChild(newElement, oldElement); 8181 } 8182 } 8183 } 8184 /** 8185 * Removes element 8186 * @param element 8187 */ 8188 }, { 8189 key: "remove", 8190 value: function remove(element) { 8191 if (Type.isDomNode(element) && Type.isDomNode(element.parentNode)) { 8192 element.parentNode.removeChild(element); 8193 } 8194 } 8195 /** 8196 * Cleans element 8197 * @param element 8198 */ 8199 }, { 8200 key: "clean", 8201 value: function clean(element) { 8202 if (Type.isDomNode(element)) { 8203 while (element.childNodes.length > 0) { 8204 element.removeChild(element.firstChild); 8205 } 8206 return; 8207 } 8208 if (Type.isString(element)) { 8209 Dom.clean(document.getElementById(element)); 8210 } 8211 } 8212 /** 8213 * Inserts element before target element 8214 * @param current 8215 * @param target 8216 */ 8217 }, { 8218 key: "insertBefore", 8219 value: function insertBefore(current, target) { 8220 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8221 if (Type.isDomNode(target.parentNode)) { 8222 target.parentNode.insertBefore(current, target); 8223 } 8224 } 8225 } 8226 /** 8227 * Inserts element after target element 8228 * @param current 8229 * @param target 8230 */ 8231 }, { 8232 key: "insertAfter", 8233 value: function insertAfter(current, target) { 8234 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8235 if (Type.isDomNode(target.parentNode)) { 8236 const parent = target.parentNode; 8237 if (Type.isDomNode(target.nextSibling)) { 8238 parent.insertBefore(current, target.nextSibling); 8239 return; 8240 } 8241 parent.appendChild(current); 8242 } 8243 } 8244 } 8245 /** 8246 * Appends element to target element 8247 * @param current 8248 * @param target 8249 */ 8250 }, { 8251 key: "append", 8252 value: function append(current, target) { 8253 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8254 target.appendChild(current); 8255 } 8256 } 8257 /** 8258 * Prepends element to target element 8259 * @param current 8260 * @param target 8261 */ 8262 }, {
8263 key: "prepend", 8264 value: function prepend(current, target) { 8265 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8266 if (Type.isDomNode(target.firstChild)) { 8267 target.insertBefore(current, target.firstChild); 8268 return; 8269 } 8270 Dom.append(current, target); 8271 } 8272 } 8273 /** 8274 * Checks that element contains class name or class names 8275 * @param element 8276 * @param className 8277 * @return {Boolean} 8278 */ 8279 }, { 8280 key: "hasClass", 8281 value: function hasClass(element, className) { 8282 if (Type.isElementNode(element)) { 8283 if (Type.isString(className)) { 8284 const preparedClassName = className.trim(); 8285 if (preparedClassName.length > 0) { 8286 if (preparedClassName.includes(' ')) { 8287 return preparedClassName.split(' ').every(name => Dom.hasClass(element, name)); 8288 } 8289 if ('classList' in element) { 8290 return element.classList.contains(preparedClassName); 8291 } 8292 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8293 return element.getAttribute('class').split(' ').some(name => name === preparedClassName); 8294 } 8295 } 8296 } 8297 if (Type.isArray(className) && className.length > 0) { 8298 return className.every(name => Dom.hasClass(element, name)); 8299 } 8300 } 8301 return false; 8302 } 8303 /** 8304 * Adds class name 8305 * @param element 8306 * @param className 8307 */ 8308 }, { 8309 key: "addClass", 8310 value: function addClass(element, className) { 8311 if (Type.isElementNode(element)) { 8312 if (Type.isString(className)) { 8313 const preparedClassName = className.trim(); 8314 if (preparedClassName.length > 0) { 8315 if (preparedClassName.includes(' ')) { 8316 Dom.addClass(element, preparedClassName.split(' ')); 8317 return; 8318 } 8319 if ('classList' in element) { 8320 element.classList.add(preparedClassName); 8321 return; 8322 } 8323 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8324 if (element.className.baseVal === '') { 8325 element.className.baseVal = preparedClassName; 8326 return; 8327 } 8328 const names = element.className.baseVal.split(' '); 8329 if (!names.includes(preparedClassName)) { 8330 names.push(preparedClassName); 8331 element.className.baseVal = names.join(' ').trim(); 8332 return; 8333 } 8334 } 8335 return; 8336 } 8337 } 8338 if (Type.isArray(className)) { 8339 className.forEach(name => Dom.addClass(element, name)); 8340 } 8341 } 8342 } 8343 /** 8344 * Removes class name 8345 * @param element 8346 * @param className 8347 */ 8348 }, { 8349 key: "removeClass", 8350 value: function removeClass(element, className) { 8351 if (Type.isElementNode(element)) { 8352 if (Type.isString(className)) { 8353 const preparedClassName = className.trim(); 8354 if (preparedClassName.length > 0) { 8355 if (preparedClassName.includes(' ')) { 8356 Dom.removeClass(element, preparedClassName.split(' ')); 8357 return; 8358 } 8359 if ('classList' in element) { 8360 element.classList.remove(preparedClassName); 8361 return; 8362 } 8363 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8364 const names = element.className.baseVal.split(' ').filter(name => name !== preparedClassName); 8365 element.className.baseVal = names.join(' '); 8366 return; 8367 } 8368 } 8369 } 8370 if (Type.isArray(className)) { 8371 className.forEach(name => Dom.removeClass(element, name)); 8372 } 8373 } 8374 } 8375 /** 8376 * Toggles class name 8377 */ 8378 }, { 8379 key: "toggleClass", 8380 value: function toggleClass(element, className, force) { 8381 if (!Type.isElementNode(element) || !Type.isStringFilled(className) && !Type.isArrayFilled(className)) { 8382 return; 8383 } 8384 [className].flat().flatMap(it => { 8385 var _it$trim; 8386 return it === null || it === void 0 ? void 0 : (_it$trim = it.trim) === null || _it$trim === void 0 ? void 0 : _it$trim.call(it).split(' '); 8387 }
8387).forEach(token => { 8388 if (Type.isStringFilled(token)) { 8389 element.classList.toggle(token, Type.isBoolean(force) ? force : undefined); 8390 } 8391 }); 8392 } 8393 /** 8394 * Styles element 8395 */ 8396 }, { 8397 key: "style", 8398 value: function style(element, prop, value) { 8399 if (Type.isElementNode(element)) { 8400 if (Type.isNull(prop)) { 8401 element.removeAttribute('style'); 8402 return element; 8403 } 8404 if (Type.isPlainObject(prop)) { 8405 Object.entries(prop).forEach(item => { 8406 const [currentKey, currentValue] = item; 8407 Dom.style(element, currentKey, currentValue); 8408 }); 8409 return element; 8410 } 8411 if (Type.isString(prop)) { 8412 if (Type.isUndefined(value) && element.nodeType !== Node.DOCUMENT_NODE) { 8413 const computedStyle = getComputedStyle(element); 8414 if (prop in computedStyle) { 8415 return computedStyle[prop]; 8416 } 8417 return computedStyle.getPropertyValue(prop); 8418 } 8419 if (Type.isNull(value) || value === '' || value === 'null') { 8420 if (String(prop).startsWith('--')) { 8421 // eslint-disable-next-line 8422 element.style.removeProperty(prop); 8423 return element; 8424 } 8425 8426 // eslint-disable-next-line 8427 element.style[prop] = ''; 8428 return element; 8429 } 8430 if (Type.isString(value) || Type.isNumber(value)) { 8431 if (String(prop).startsWith('--')) { 8432 // eslint-disable-next-line 8433 element.style.setProperty(prop, value); 8434 return element; 8435 } 8436 8437 // eslint-disable-next-line 8438 element.style[prop] = value; 8439 return element; 8440 } 8441 } 8442 } 8443 return null; 8444 } 8445 /** 8446 * Adjusts element 8447 * @param target 8448 * @param data 8449 * @return {*} 8450 */ 8451 }, { 8452 key: "adjust", 8453 value: function adjust(target, data = {}) { 8454 if (!target.nodeType) { 8455 return null; 8456 } 8457 let element = target; 8458 if (target.nodeType === Node.DOCUMENT_NODE) { 8459 element = target.body; 8460 } 8461 if (Type.isPlainObject(data)) { 8462 if (Type.isPlainObject(data.attrs)) { 8463 Object.keys(data.attrs).forEach(key => { 8464 if (key === 'class' || key.toLowerCase() === 'classname') { 8465 element.className = data.attrs[key]; 8466 return; 8467 } 8468 8469 // eslint-disable-next-line 8470 if (data.attrs[key] == '') { 8471 element.removeAttribute(key); 8472 return; 8473 } 8474 element.setAttribute(key, data.attrs[key]); 8475 }); 8476 } 8477 if (Type.isPlainObject(data.style)) { 8478 Dom.style(element, data.style); 8479 } 8480 if (Type.isPlainObject(data.props)) { 8481 Object.keys(data.props).forEach(key => { 8482 element[key] = data.props[key]; 8483 }); 8484 } 8485 if (Type.isPlainObject(data.events)) { 8486 Object.keys(data.events).forEach(key => { 8487 Event.bind(element, key, data.events[key]); 8488 }); 8489 } 8490 if (Type.isPlainObject(data.dataset)) { 8491 Object.keys(data.dataset).forEach(key => { 8492 element.dataset[key] = data.dataset[key]; 8493 }); 8494 } 8495 if (Type.isString(data.children)) { 8496 data.children = [data.children]; 8497 } 8498 if (Type.isArray(data.children) && data.children.length > 0) { 8499 data.children.forEach(item => { 8500 if (Type.isDomNode(item)) { 8501 Dom.append(item, element); 8502 } 8503 if (Type.isString(item)) { 8504 element.insertAdjacentHTML('beforeend', item); 8505 } 8506 }); 8507 return element; 8508 } 8509 if ('text' in data && !Type.isNil(data.text)) { 8510 element.textContent = data.text; 8511 return element; 8512 } 8513 if ('html' in data && !Type.isNil(data.html)) { 8514 element.innerHTML = data.html; 8515 } 8516 } 8517 return element; 8518 } 8519 /** 8520 * Creates element 8521 * @param tag 8522 * @param data 8523 * @param context 8524 * @return {HTMLElement|HTMLBodyElement} 8525 */ 8526 }, { 8527 key: "create", 8528 value: function create(tag, data = {}, context = document) { 8529 let tagName = tag; 8530 let options = data; 8531 if (Type.isObjectLike(tag)) { 8532 options = tag; 8533 tagName = tag.tag; 8534 } 8535 return Dom.adjust(context.createElement(tagName), options); 8536 } 8537 /** 8538 * Shows element 8539 * @param element 8540 */ 8541 }, { 8542 key: "show", 8543 value: function show(element) { 8544 if (Type.isDomNode(element)) { 8545 // eslint-disable-next-line 8546 element.hidden = false;
8547 } 8548 } 8549 /** 8550 * Hides element 8551 * @param element 8552 */ 8553 }, { 8554 key: "hide", 8555 value: function hide(element) { 8556 if (Type.isDomNode(element)) { 8557 // eslint-disable-next-line 8558 element.hidden = true; 8559 } 8560 } 8561 /** 8562 * Checks that element is shown 8563 * @param element 8564 * @return {*|boolean} 8565 */ 8566 }, { 8567 key: "isShown", 8568 value: function isShown(element) { 8569 return Type.isDomNode(element) && !element.hidden && element.style.getPropertyValue('display') !== 'none'; 8570 } 8571 /** 8572 * Toggles element visibility 8573 * @param element 8574 */ 8575 }, { 8576 key: "toggle", 8577 value: function toggle(element) { 8578 if (Type.isDomNode(element)) { 8579 if (Dom.isShown(element)) { 8580 Dom.hide(element); 8581 } else { 8582 Dom.show(element); 8583 } 8584 } 8585 } 8586 /** 8587 * Gets element position relative page 8588 * @param {HTMLElement} element 8589 * @return {DOMRect} 8590 */ 8591 }, { 8592 key: "getPosition", 8593 value: function getPosition(element) { 8594 if (Type.isDomNode(element)) { 8595 const elementRect = element.getBoundingClientRect(); 8596 const { 8597 scrollLeft, 8598 scrollTop 8599 } = getPageScroll(); 8600 return new DOMRect(elementRect.left + scrollLeft, elementRect.top + scrollTop, elementRect.width, elementRect.height); 8601 } 8602 return new DOMRect(); 8603 } 8604 /** 8605 * Gets element position relative specified element position 8606 * @param {HTMLElement} element 8607 * @param {HTMLElement} relationElement 8608 * @return {DOMRect} 8609 */ 8610 }, { 8611 key: "getRelativePosition", 8612 value: function getRelativePosition(element, relationElement) { 8613 if (Type.isDomNode(element) && Type.isDomNode(relationElement)) { 8614 const elementPosition = Dom.getPosition(element); 8615 const relationElementPosition = Dom.getPosition(relationElement); 8616 return new DOMRect(elementPosition.left - relationElementPosition.left, elementPosition.top - relationElementPosition.top, elementPosition.width, elementPosition.height); 8617 } 8618 return new DOMRect(); 8619 } 8620 }, { 8621 key: "attr", 8622 value: function attr(element, _attr, value) { 8623 if (Type.isElementNode(element)) { 8624 if (Type.isString(_attr)) { 8625 if (!Type.isNil(value)) { 8626 if (Type.isObjectLike(value)) { 8627 element.setAttribute(_attr, encodeAttributeValue(value)); 8628 } else { 8629 element.setAttribute(_attr, value); 8630 } 8631 } else if (Type.isNull(value)) { 8632 element.removeAttribute(_attr); 8633 } else { 8634 return decodeAttributeValue(element.getAttribute(_attr)); 8635 } 8636 } 8637 if (Type.isPlainObject(_attr)) { 8638 Object.entries(_attr).forEach(([attrKey, attrValue]) => { 8639 Dom.attr(element, attrKey, attrValue); 8640 }); 8641 } 8642 } 8643 return null; 8644 } 8645 }]); 8646 return Dom; 8647 }(); 8648 8649 const UA = navigator.userAgent.toLowerCase(); 8650 8651 /** 8652 * @memberOf BX 8653 */ 8654 let Browser = /*#__PURE__*/function () { 8655 function Browser() { 8656 babelHelpers.classCallCheck(this, Browser); 8657 } 8658 babelHelpers.createClass(Browser, null, [{ 8659 key: "isOpera", 8660 value: function isOpera() { 8661 return UA.includes('opera'); 8662 } 8663 }, { 8664 key: "isIE", 8665 value: function isIE() { 8666 return 'attachEvent' in document && !Browser.isOpera(); 8667 } 8668 }, { 8669 key: "isIE6", 8670 value: function isIE6() { 8671 return UA.includes('msie 6'); 8672 } 8673 }, { 8674 key: "isIE7", 8675 value: function isIE7() { 8676 return UA.includes('msie 7'); 8677 } 8678 }, { 8679 key: "isIE8", 8680 value: function isIE8() { 8681 return UA.includes('msie 8'); 8682 } 8683 }, { 8684 key: "isIE9", 8685 value: function isIE9() { 8686 return 'documentMode' in document && document.documentMode >= 9; 8687 } 8688 }, { 8689 key: "isIE10", 8690 value: function isIE10() { 8691 return 'documentMode' in document && document.documentMode >= 10; 8692 } 8693 }, { 8694 key: "isSafari", 8695 value: function isSafari() { 8696 return UA.includes('safari') && !UA.includes('chrome'); 8697 } 8698 }, { 8699 key: "isFirefox", 8700 value: function isFirefox() { 8701 return UA.includes('firefox'); 8702 } 8703 }, { 8704 key: "isChrome", 8705 value: function isChrome() { 8706 return UA.includes('chrome'); 8707 } 8708 }, { 8709 key: "detectIEVersion", 8710 value: function detectIEVersion() { 8711 if (Browser.isOpera() || Browser.isSafari() || Browser.isFirefox() || Browser.isChrome()) { 8712 return -1; 8713 } 8714 let rv = -1; 8715 if (!!window.MSStream && !window.ActiveXObject && 'ActiveXObject' in window) { 8716 rv = 11; 8717 } else if (Browser.isIE10()) { 8718 rv = 10; 8719 } else if (Browser.isIE9()) { 8720 rv = 9; 8721 } else if (Browser.isIE()) { 8722 rv = 8; 8723 } 8724 if (rv === -1 || rv === 8) { 8725 if (navigator.appName === 'Microsoft Internet Explorer') { 8726 const re = new RegExp('MSIE ([0-9]+[.0-9]*)'); 8727 const res = navigator.userAgent.match(re); 8728 if (Type.isArrayLike(res) && res.length > 0) { 8729 rv = parseFloat(res[1]); 8730 } 8731 } 8732 if (navigator.appName === 'Netscape') { 8733 // Alternative check for IE 11 8734 rv = 11; 8735 const re = new RegExp('Trident/.*rv:([0-9]+[.0-9]*)'); 8736 if (re.exec(navigator.userAgent) != null) { 8737 const res = navigator.userAgent.match(re); 8738 if (Type.isArrayLike(res) && res.length > 0) { 8739 rv = parseFloat(res[1]); 8740 } 8741 } 8742 } 8743 } 8744 return rv; 8745 } 8746 }, { 8747 key: "isIE11", 8748 value: function isIE11() { 8749 return Browser.detectIEVersion() >= 11; 8750 } 8751 }, { 8752 key: "isMac", 8753 value: function isMac() { 8754 return UA.includes('macintosh'); 8755 } 8756 }, { 8757 key: "isWin", 8758 value: function isWin() { 8759 return UA.includes('windows'); 8760 } 8761 }, { 8762 key: "isLinux", 8763 value: function isLinux() { 8764 return UA.includes('linux') && !Browser.isAndroid(); 8765 } 8766 }, { 8767 key: "isAndroid", 8768 value: function isAndroid() { 8769 return UA.includes('android'); 8770 } 8771 }, { 8772 key: "isIPad", 8773 value: function isIPad() { 8774 return UA.includes('ipad;') || this.isMac() && this.isTouchDevice(); 8775 } 8776 }, { 8777 key: "isIPhone", 8778 value: function isIPhone() { 8779 return UA.includes('iphone;'); 8780 } 8781 }, { 8782 key: "isIOS", 8783 value: function isIOS() { 8784 return Browser.isIPad() || Browser.isIPhone(); 8785 } 8786 }, { 8787 key: "isMobile", 8788 value: function isMobile() { 8789 return Browser.isIPhone() || Browser.isIPad() || Browser.isAndroid() || UA.includes('mobile') || UA.includes('touch'); 8790 } 8791 }, { 8792 key: "isRetina", 8793 value: function isRetina() { 8794 return window.devicePixelRatio && window.devicePixelRatio >= 2; 8795 } 8796 }, { 8797 key: "isTouchDevice", 8798 value: function isTouchDevice() { 8799 return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; 8800 } 8801 }, { 8802 key: "isDoctype", 8803 value: function isDoctype(target) { 8804 const doc = target || document; 8805 if (doc.compatMode) { 8806 return doc.compatMode === 'CSS1Compat'; 8807 } 8808 return doc.documentElement && doc.documentElement.clientHeight; 8809 } 8810 }, { 8811 key: "isLocalStorageSupported", 8812 value: function isLocalStorageSupported() { 8813 try { 8814 localStorage.setItem('test', 'test'); 8815 localStorage.removeItem('test'); 8816 return true; 8817 } catch (e) { 8818 return false;
8819 } 8820 } 8821 }, { 8822 key: "addGlobalClass", 8823 value: function addGlobalClass(target) { 8824 let globalClass = 'bx-core'; 8825 target = Type.isElementNode(target) ? target : document.documentElement; 8826 if (Dom.hasClass(target, globalClass)) { 8827 return; 8828 } 8829 if (Browser.isIOS()) { 8830 globalClass += ' bx-ios'; 8831 } else if (Browser.isWin()) { 8832 globalClass += ' bx-win'; 8833 } else if (Browser.isMac()) { 8834 globalClass += ' bx-mac'; 8835 } else if (Browser.isLinux()) { 8836 globalClass += ' bx-linux'; 8837 } else if (Browser.isAndroid()) { 8838 globalClass += ' bx-android'; 8839 } 8840 globalClass += Browser.isMobile() ? ' bx-touch' : ' bx-no-touch'; 8841 globalClass += Browser.isRetina() ? ' bx-retina' : ' bx-no-retina'; 8842 if (/AppleWebKit/.test(navigator.userAgent)) { 8843 globalClass += ' bx-chrome'; 8844 } else if (/Opera/.test(navigator.userAgent)) { 8845 globalClass += ' bx-opera'; 8846 } else if (Browser.isFirefox()) { 8847 globalClass += ' bx-firefox'; 8848 } 8849 Dom.addClass(target, globalClass); 8850 } 8851 }, { 8852 key: "detectAndroidVersion", 8853 value: function detectAndroidVersion() { 8854 const re = new RegExp('Android ([0-9]+[.0-9]*)'); 8855 if (re.exec(navigator.userAgent) != null) { 8856 const res = navigator.userAgent.match(re); 8857 if (Type.isArrayLike(res) && res.length > 0) { 8858 return parseFloat(res[1]); 8859 } 8860 } 8861 return 0; 8862 } 8863 }, { 8864 key: "isPropertySupported", 8865 value: function isPropertySupported(jsProperty, returnCSSName) { 8866 if (jsProperty === '') { 8867 return false; 8868 } 8869 function getCssName(propertyName) { 8870 return propertyName.replace(/([A-Z])/g, (...args) => `-${args[1].toLowerCase()}`); 8871 } 8872 function getJsName(cssName) { 8873 const reg = /(\\-([a-z]))/g; 8874 if (reg.test(cssName)) { 8875 return cssName.replace(reg, (...args) => args[2].toUpperCase()); 8876 } 8877 return cssName; 8878 } 8879 const property = jsProperty.includes('-') ? getJsName(jsProperty) : jsProperty; 8880 const bReturnCSSName = !!returnCSSName; 8881 const ucProperty = property.charAt(0).toUpperCase() + property.slice(1); 8882 const props = ['Webkit', 'Moz', 'O', 'ms'].join(`${ucProperty} `); 8883 const properties = `${property} ${props} ${ucProperty}`.split(' '); 8884 const obj = document.body || document.documentElement; 8885 for (let i = 0; i < properties.length; i += 1) { 8886 const prop = properties[i]; 8887 if (obj && 'style' in obj && prop in obj.style) { 8888 const lowerProp = prop.substr(0, prop.length - property.length).toLowerCase(); 8889 const prefix = prop === property ? '' : `-${lowerProp}-`; 8890 return bReturnCSSName ? prefix + getCssName(property) : prop; 8891 } 8892 } 8893 return false; 8894 } 8895 }, { 8896 key: "addGlobalFeatures", 8897 value: function addGlobalFeatures(features) { 8898 if (!Type.isArray(features)) { 8899 return; 8900 } 8901 const classNames = []; 8902 for (let i = 0; i < features.length; i += 1) { 8903 const support = !!Browser.isPropertySupported(features[i]); 8904 classNames.push(`bx-${support ? '' : 'no-'}${features[i].toLowerCase()}`); 8905 } 8906 Dom.addClass(document.documentElement, classNames.join(' ')); 8907 } 8908 }]); 8909 return Browser; 8910 }(); 8911 8912 let Cookie = /*#__PURE__*/function () { 8913 function Cookie() { 8914 babelHelpers.classCallCheck(this, Cookie); 8915 } 8916 babelHelpers.createClass(Cookie, null, [{ 8917 key: "getList", 8918 /** 8919 * Gets cookies list for current domain 8920 * @return {object} 8921 */ 8922 value: function getList() { 8923 return document.cookie.split(';').map(item => item.split('=')).map(item => item.map(subItem => subItem.trim())).reduce((acc, item) => { 8924 const [key, value] = item; 8925 acc[decodeURIComponent(key)] = decodeURIComponent(value); 8926 return acc; 8927 }, {}); 8928 } 8929 /** 8930 * Gets cookie value 8931 * @param {string} name 8932 * @return {*} 8933 */ 8934 }, { 8935 key: "get", 8936 value: function get(name) { 8937 const cookiesList = Cookie.getList(); 8938 if (name in cookiesList) { 8939 return cookiesList[name]; 8940 } 8941 return undefined; 8942 } 8943 /** 8944 * Sets cookie 8945 * @param {string} name 8946 * @param {*} value 8947 * @param {object} [options] 8948 */ 8949 }, { 8950 key: "set", 8951 value: function set(name, value, options = {}) { 8952 const attributes = { 8953 expires: '', 8954 ...options 8955 }; 8956 if (Type.isNumber(attributes.expires)) { 8957 const now = +new Date(); 8958 const days = attributes.expires; 8959 const dayInMs = 864e+5; 8960 attributes.expires = new Date(now + days * dayInMs); 8961 } 8962 if (Type.isDate(attributes.expires)) { 8963 attributes.expires = attributes.expires.toUTCString(); 8964 } 8965 const safeName = decodeURIComponent(String(name)).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape); 8966 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); 8967 const stringifiedAttributes = Object.keys(attributes).reduce((acc, key) => { 8968 const attributeValue = attributes[key]; 8969 if (!attributeValue) { 8970 return acc; 8971 } 8972 if (attributeValue === true) { 8973 return `${acc}; ${key}`; 8974 } 8975 8976 /** 8977 * Considers RFC 6265 section 5.2: 8978 * ... 8979 * 3. If the remaining unparsed-attributes contains a %x3B (';') 8980 * character: 8981 * Consume the characters of the unparsed-attributes up to, 8982 * not including, the first %x3B (';') character. 8983 */ 8984 return `${acc}; ${key}=${attributeValue.split(';')[0]}`; 8985 }, ''); 8986 document.cookie = `${safeName}=${safeValue}${stringifiedAttributes}`; 8987 } 8988 /** 8989 * Removes cookie 8990 * @param {string} name 8991 * @param {object} [options] 8992 */ 8993 }, { 8994 key: "remove", 8995 value: function remove(name, options = {}) { 8996 Cookie.set(name, '', { 8997 ...options, 8998 expires: -1 8999 }); 9000 } 9001 }]); 9002 return Cookie; 9003 }(); 9004 9005 function objectToFormData(source, formData = new FormData(), pre = null) { 9006 if (Type.isUndefined(source)) { 9007 return formData; 9008 } 9009 if (Type.isNull(source)) { 9010 formData.append(pre, ''); 9011 } else if (Type.isArray(source)) { 9012 if (!source.length) {
9013 const key = `${pre}[]`; 9014 formData.append(key, ''); 9015 } else { 9016 source.forEach((value, index) => { 9017 const key = `${pre}[${index}]`; 9018 objectToFormData(value, formData, key); 9019 }); 9020 } 9021 } else if (Type.isDate(source)) { 9022 formData.append(pre, source.toISOString()); 9023 } else if (Type.isObject(source) && !Type.isFile(source) && !Type.isBlob(source)) { 9024 Object.keys(source).forEach(property => { 9025 const value = source[property]; 9026 let preparedProperty = property; 9027 if (Type.isArray(value)) { 9028 while (preparedProperty.length > 2 && preparedProperty.lastIndexOf('[]') === preparedProperty.length - 2) { 9029 preparedProperty = preparedProperty.substring(0, preparedProperty.length - 2); 9030 } 9031 } 9032 const key = pre ? `${pre}[${preparedProperty}]` : preparedProperty; 9033 objectToFormData(value, formData, key); 9034 }); 9035 } else { 9036 formData.append(pre, source); 9037 } 9038 return formData; 9039 } 9040 9041 let Data = /*#__PURE__*/function () { 9042 function Data() { 9043 babelHelpers.classCallCheck(this, Data); 9044 } 9045 babelHelpers.createClass(Data, null, [{ 9046 key: "convertObjectToFormData", 9047 /** 9048 * Converts object to FormData 9049 * @param source 9050 * @return {FormData} 9051 */ 9052 value: function convertObjectToFormData(source) { 9053 return objectToFormData(source); 9054 } 9055 }]); 9056 return Data; 9057 }(); 9058 9059 /** 9060 * @memberOf BX 9061 */ 9062 let Http = function Http() { 9063 babelHelpers.classCallCheck(this, Http); 9064 }; 9065 babelHelpers.defineProperty(Http, "Cookie", Cookie); 9066 babelHelpers.defineProperty(Http, "Data", Data); 9067 9068 function message(value) { 9069 if (Type.isString(value)) { 9070 if (Type.isNil(message[value])) { 9071 // eslint-disable-next-line 9072 EventEmitter.emit('onBXMessageNotFound', new BaseEvent({ 9073 compatData: [value] 9074 })); 9075 if (Type.isNil(message[value])) { 9076 Runtime.debug(`message undefined: ${value}`); 9077 message[value] = ''; 9078 } 9079 } 9080 } 9081 if (Type.isPlainObject(value)) { 9082 Object.keys(value).forEach(key => { 9083 message[key] = value[key]; 9084 }); 9085 } 9086 return message[value]; 9087 } 9088 if (!Type.isNil(window.BX) && Type.isFunction(window.BX.message)) { 9089 Object.keys(window.BX.message).forEach(key => { 9090 message({ 9091 [key]: window.BX.message[key] 9092 }); 9093 }); 9094 } 9095 9096 /** 9097 * Implements interface for works with language messages 9098 * @memberOf BX 9099 */ 9100 let Loc = /*#__PURE__*/function () { 9101 function Loc() { 9102 babelHelpers.classCallCheck(this, Loc); 9103 } 9104 babelHelpers.createClass(Loc, null, [{ 9105 key: "getMessage", 9106 /** 9107 * Gets message by id 9108 * @param {string} messageId 9109 * @param {object} replacements 9110 * @return {?string} 9111 */ 9112 value: function getMessage(messageId, replacements = null) { 9113 let mess = message(messageId); 9114 if (Type.isString(mess) && Type.isPlainObject(replacements)) { 9115 const escape = str => String(str).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&'); 9116 Object.keys(replacements).forEach(replacement => { 9117 const globalRegexp = new RegExp(escape(replacement), 'gi'); 9118 mess = mess.replace(globalRegexp, () => { 9119 return Type.isNil(replacements[replacement]) ? '' : String(replacements[replacement]); 9120 }); 9121 }); 9122 } 9123 return mess; 9124 } 9125 }, { 9126 key: "hasMessage", 9127 value: function hasMessage(messageId) { 9128 return Type.isString(messageId) && !Type.isNil(message[messageId]); 9129 } 9130 /** 9131 * Sets message or messages 9132 * @param {string | Object<string, string>} id 9133 * @param {string} [value] 9134 */ 9135 }, { 9136 key: "setMessage", 9137 value: function setMessage(id, value) { 9138 if (Type.isString(id) && Type.isString(value)) { 9139 message({ 9140 [id]: value 9141 }); 9142 } 9143 if (Type.isObject(id)) { 9144 message(id); 9145 } 9146 } 9147 /** 9148 * Gets plural message by id and number 9149 * @param {string} messageId 9150 * @param {number} value 9151 * @param {object} [replacements] 9152 * @return {?string} 9153 */ 9154 }, { 9155 key: "getMessagePlural",
9156 value: function getMessagePlural(messageId, value, replacements = null) { 9157 let result = ''; 9158 if (Type.isNumber(value)) { 9159 if (this.hasMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`)) { 9160 result = this.getMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`, replacements); 9161 } else { 9162 result = this.getMessage(`${messageId}_PLURAL_1`, replacements); 9163 } 9164 } else { 9165 result = this.getMessage(messageId, replacements); 9166 } 9167 return result; 9168 } 9169 /** 9170 * Gets language plural form id by number 9171 * see http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html 9172 * @param {number} value 9173 * @param {string} [languageId] 9174 * @return {?number} 9175 */ 9176 }, { 9177 key: "getPluralForm", 9178 value: function getPluralForm(value, languageId) { 9179 let pluralForm; 9180 if (!Type.isStringFilled(languageId)) { 9181 languageId = message('LANGUAGE_ID'); 9182 } 9183 if (value < 0) { 9184 value = -1 * value; 9185 } 9186 switch (languageId) { 9187 case 'ar': 9188 pluralForm = value !== 1 ? 1 : 0; 9189 /* 9190 if (value === 0) 9191 { 9192 pluralForm = 0; 9193 } 9194 else if (value === 1) 9195 { 9196 pluralForm = 1; 9197 } 9198 else if (value === 2) 9199 { 9200 pluralForm = 2; 9201 } 9202 else if ( 9203 value % 100 >= 3 9204 && value % 100 <= 10 9205 ) 9206 { 9207 pluralForm = 3; 9208 } 9209 else if (value % 100 >= 11) 9210 { 9211 pluralForm = 4; 9212 } 9213 else 9214 { 9215 pluralForm = 5; 9216 } 9217 */ 9218 break; 9219 case 'br': 9220 case 'fr': 9221 case 'tr': 9222 pluralForm = value > 1 ? 1 : 0; 9223 break; 9224 case 'de': 9225 case 'en': 9226 case 'hi': 9227 case 'it': 9228 case 'la': 9229 pluralForm = value !== 1 ? 1 : 0; 9230 break; 9231 case 'ru': 9232 case 'ua': 9233 if (value % 10 === 1 && value % 100 !== 11) { 9234 pluralForm = 0; 9235 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9236 pluralForm = 1; 9237 } else { 9238 pluralForm = 2; 9239 } 9240 break; 9241 case 'pl': 9242 if (value === 1) { 9243 pluralForm = 0; 9244 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9245 pluralForm = 1; 9246 } else { 9247 pluralForm = 2; 9248 } 9249 break; 9250 case 'id': 9251 case 'ja': 9252 case 'ms': 9253 case 'sc': 9254 case 'tc': 9255 case 'th': 9256 case 'vn': 9257 pluralForm = 0; 9258 break; 9259 default: 9260 pluralForm = 1; 9261 break; 9262 } 9263 return pluralForm; 9264 } 9265 }]); 9266 return Loc; 9267 }(); 9268 9269 const voidElements = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr']; 9270 function isVoidElement(element) { 9271 return voidElements.includes(element); 9272 } 9273 9274 const matchers = { 9275 tag: /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>|{{uid[0-9]+}}/g, 9276 comment: /<!--(?!<!)[^\[>].*?-->/g, 9277 tagName: /<\/?([^\s]+?)[/\s>]/, 9278 attributes: /\s([\w\-_:.]+)\s?\n?=\s?\n?"([^"]+)?"|\s([\w\-_:.]+)\s?\n?=\s?\n?'([^']+)?'|\s([\w\-_:.]+)/gs, 9279 placeholder: /{{uid[0-9]+}}/g 9280 }; 9281 9282 function parseTag(tag) { 9283 const tagResult = { 9284 type: 'tag', 9285 name: '', 9286 svg: false, 9287 attrs: {}, 9288 children: [], 9289 voidElement: false 9290 }; 9291 if (tag.startsWith('<!--')) { 9292 const endIndex = tag.indexOf('-->'); 9293 const openTagLength = '<!--'.length; 9294 return { 9295 type: 'comment', 9296 content: endIndex !== -1 ? tag.slice(openTagLength, endIndex) : '' 9297 }; 9298 } 9299 const tagNameMatch = tag.match(matchers.tagName); 9300 if (Type.isArrayFilled(tagNameMatch)) { 9301 const [, tagName] = tagNameMatch; 9302 tagResult.name = tagName; 9303 tagResult.svg = tagName === 'svg'; 9304 tagResult.voidElement = isVoidElement(tagName) || tag.trim().endsWith('/>'); 9305 } 9306 const reg = new RegExp(matchers.attributes); 9307 for (;;) { 9308 const result = reg.exec(tag); 9309 if (!Type.isNil(result)) { 9310 // Attributes with double quotes 9311 const [, attrName, attrValue] = result; 9312 if (!Type.isNil(attrName)) { 9313 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9314 } else { 9315 // Attributes with single quotes 9316 const [,,, attrName, attrValue] = result; 9317 if (!Type.isNil(attrName)) { 9318 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9319 } else { 9320 // Attributes without value 9321 const [,,,,, attrName] = result; 9322 tagResult.attrs[attrName] = ''; 9323 } 9324 } 9325 } else { 9326 break; 9327 } 9328 } 9329 return tagResult; 9330 } 9331 9332 function parseText(input) { 9333 const preparedText = input.replace(/[\n\r\t]$/, ''); 9334 const placeholders = preparedText.match(matchers.placeholder); 9335 return preparedText.split(matchers.placeholder).reduce((acc, item, index) => { 9336 if (Type.isStringFilled(item)) { 9337 acc.push(...item.split(/\n/).reduce((textAcc, text) => { 9338 const preparedItemText = text.replace(/[\t\r]/g, ''); 9339 if (Type.isStringFilled(preparedItemText)) { 9340 textAcc.push({ 9341 type: 'text', 9342 content: preparedItemText 9343 }); 9344 } 9345 return textAcc; 9346 }, [])); 9347 } 9348 if (placeholders && placeholders[index]) { 9349 acc.push({ 9350 type: 'placeholder', 9351 uid: parseInt(placeholders[index].replace(/{{uid|}}/, '')) 9352 }); 9353 } 9354 return acc; 9355 }, []); 9356 } 9357 9358 function parse(html, substitutions) { 9359 const result = []; 9360 if (html.indexOf('<') !== 0 && !html.startsWith('{{')) { 9361 const end = html.indexOf('<'); 9362 result.push(...parseText(end === -1 ? html : html.slice(0, end))); 9363 } 9364 const commentsContent = []; 9365 let commentIndex = -1; 9366 html = html.replace(matchers.comment, tag => { 9367 commentIndex += 1; 9368 commentsContent.push(tag.replace(/^<!--|-->$/g, '')); 9369 return `<!--{{cUid${commentIndex}}}-->`; 9370 }); 9371 const arr = []; 9372 let level = -1; 9373 let current; 9374 html.replace(matchers.tag, (tag, index) => { 9375 const start = index + tag.length; 9376 const nextChar = html.charAt(start); 9377 let parent; 9378 if (tag.startsWith('<!--')) { 9379 const comment = parseTag(tag, substitutions); 9380 comment.content = commentsContent[tag.replace(/<!--{{cUid|}}-->/g, '')]; 9381 if (level < 0) { 9382 result.push(comment); 9383 return result; 9384 } 9385 parent = arr[level]; 9386 parent.children.push(comment); 9387 return result; 9388 } 9389 if (tag.startsWith('{{')) { 9390 const [placeholder] = parseText(tag); 9391 if (level < 0) { 9392 result.push(placeholder); 9393 return result; 9394 } 9395 parent = arr[level]; 9396 parent.children.push(placeholder); 9397 return result; 9398 } 9399 if (!tag.startsWith('</')) { 9400 level++; 9401 current = parseTag(tag, substitutions); 9402 if (!current.voidElement && nextChar && nextChar !== '<') { 9403 current.children.push(...parseText(html.slice(start, html.indexOf('<', start)))); 9404 } 9405 if (level === 0) { 9406 result.push(current); 9407 } 9408 parent = arr[level - 1]; 9409 if (parent) { 9410 if (!current.svg) { 9411 current.svg = parent.svg; 9412 } 9413 parent.children.push(current); 9414 } 9415 arr[level] = current; 9416 } 9417 if (tag.startsWith('</') || current.voidElement) { 9418 if (level > -1 && (current.voidElement || current.name === tag.slice(2, -1))) { 9419 level--; 9420 current = level === -1 ? result : arr[level]; 9421 } 9422 if (nextChar && nextChar !== '<') { 9423 parent = level === -1 ? result : arr[level].children; 9424 const end = html.indexOf('<', start); 9425 const content = html.slice(start, end === -1 ? undefined : end); 9426 if (end >
9426 -1 && level + parent.length >= 0 || content !== ' ') { 9427 parent.push(...parseText(content)); 9428 } 9429 } 9430 } 9431 }); 9432 return result; 9433 } 9434 9435 const appendElement = (current, target) => { 9436 if (Type.isDomNode(current) && Type.isDomNode(target)) { 9437 if (target.nodeName !== 'TEMPLATE') { 9438 Dom.append(current, target); 9439 } else { 9440 // eslint-disable-next-line bitrix-rules/no-native-dom-methods 9441 target.content.append(current); 9442 } 9443 } 9444 }; 9445 function renderNode(options) { 9446 const { 9447 node, 9448 parentElement, 9449 substitutions, 9450 refs = [] 9451 } = options; 9452 if (node.type === 'tag') { 9453 const element = (() => { 9454 if (node.svg) { 9455 return document.createElementNS('http://www.w3.org/2000/svg', node.name); 9456 } 9457 return document.createElement(node.name); 9458 })(); 9459 if (Object.hasOwn(node.attrs, 'ref')) { 9460 refs.push([node.attrs.ref, element]); 9461 delete node.attrs.ref; 9462 } 9463 Object.entries(node.attrs).forEach(([key, value]) => { 9464 if (key.startsWith('on') && new RegExp(matchers.placeholder).test(value)) { 9465 const substitution = substitutions[parseInt(value.replace(/{{uid|}}/, '')) - 1]; 9466 if (Type.isFunction(substitution)) { 9467 const bindFunctionName = key.endsWith('once') ? 'bindOnce' : 'bind'; 9468 Event[bindFunctionName](element, key.replace(/^on|once$/g, ''), substitution); 9469 } else { 9470 element.setAttribute(key, substitution); 9471 } 9472 } else { 9473 if (new RegExp(matchers.placeholder).test(value)) { 9474 const preparedValue = value.split(/{{|}}/).reduce((acc, item) => { 9475 if (item.startsWith('uid')) { 9476 const substitution = substitutions[parseInt(item.replace('uid', '')) - 1]; 9477 return `${acc}${substitution}`; 9478 } 9479 return `${acc}${item}`; 9480 }, ''); 9481 element.setAttribute(key, preparedValue); 9482 } else { 9483 element.setAttribute(key, Text.decode(value)); 9484 } 9485 } 9486 }); 9487 node.children.forEach(childNode => { 9488 const result = renderNode({ 9489 node: childNode, 9490 parentElement: element, 9491 substitutions, 9492 refs 9493 }); 9494 if (Type.isArray(result)) { 9495 result.forEach(subChildElement => { 9496 appendElement(subChildElement, element); 9497 }); 9498 } else { 9499 appendElement(result, element); 9500 } 9501 }); 9502 return element; 9503 } 9504 if (node.type === 'comment') { 9505 return document.createComment(node.content); 9506 } 9507 if (node.type === 'text') { 9508 if (parentElement) { 9509 if (parentElement.nodeName !== 'TEMPLATE') { 9510 parentElement.insertAdjacentHTML('beforeend', node.content); 9511 } else { 9512 parentElement.content.append(node.content); 9513 } 9514 return; 9515 } 9516 return document.createTextNode(node.content); 9517 } 9518 if (node.type === 'placeholder') { 9519 return substitutions[node.uid - 1]; 9520 } 9521 } 9522 9523 function render(sections, ...substitutions) { 9524 const html = sections.reduce((acc, item, index) => { 9525 if (index > 0) { 9526 const substitution = substitutions[index - 1]; 9527 if (Type.isString(substitution) || Type.isNumber(substitution)) { 9528 return `${acc}${substitution}${item}`; 9529 } 9530 return `${acc}{{uid${index}}}${item}`; 9531 } 9532 return acc; 9533 }, sections[0]).replace(/^[\r\n\t\s]+/gm, '').replace(/>[\n]+/g, '>').replace(/[}][\n]+/g, '}'); 9534 const ast = parse(html); 9535 if (ast.length === 1) { 9536 const refs = []; 9537 const renderedNode = renderNode({ 9538 node: ast[0], 9539 substitutions, 9540 refs 9541 }); 9542 if (Type.isArrayFilled(refs)) { 9543 return Object.fromEntries([['root', renderedNode], ...refs]); 9544 } 9545 return renderedNode; 9546 } 9547 if (ast.length > 1) { 9548 const refs = []; 9549 const renderedNodes = ast.map(node => { 9550 return renderNode({ 9551 node, 9552 substitutions, 9553 refs 9554 }); 9555 }); 9556 if (Type.isArrayFilled(refs)) { 9557 return Object.fromEntries([['root', renderedNodes], ...refs]); 9558 } 9559 return renderedNodes; 9560 } 9561 return false;
9562 } 9563 9564 function parseProps(sections, ...substitutions) { 9565 return substitutions.reduce((acc, item, index) => { 9566 const nextSectionIndex = index + 1; 9567 if (!Type.isPlainObject(item) && !Type.isArray(item)) { 9568 return acc + item + sections[nextSectionIndex]; 9569 } 9570 return `${acc}__s${index}${sections[nextSectionIndex]}`; 9571 }, sections[0]).replace(/[\r\t]/gm, '').split(';\n').map(item => item.replace(/\n/, '')).reduce((acc, item) => { 9572 if (item !== '') { 9573 const matches = item.match(/^[\w-. ]+:/); 9574 const splitted = item.split(/^[\w-. ]+:/); 9575 const key = matches[0].replace(':', '').trim(); 9576 const value = splitted[1].trim(); 9577 const substitutionPlaceholderExp = /^__s\d+/; 9578 if (substitutionPlaceholderExp.test(value)) { 9579 acc[key] = substitutions[value.replace('__s', '')]; 9580 return acc; 9581 } 9582 acc[key] = value; 9583 } 9584 return acc; 9585 }, {}); 9586 } 9587 9588 /** 9589 * @memberOf BX 9590 */ 9591 let Tag = /*#__PURE__*/function () { 9592 function Tag() { 9593 babelHelpers.classCallCheck(this, Tag); 9594 } 9595 babelHelpers.createClass(Tag, null, [{ 9596 key: "safe", 9597 /** 9598 * Encodes all substitutions 9599 * @param sections 9600 * @param substitutions 9601 * @return {string} 9602 */ 9603 value: function safe(sections, ...substitutions) { 9604 return substitutions.reduce((acc, item, index) => acc + Text.encode(item) + sections[index + 1], sections[0]); 9605 } 9606 /** 9607 * Decodes all substitutions 9608 * @param sections 9609 * @param substitutions 9610 * @return {string} 9611 */ 9612 }, { 9613 key: "unsafe", 9614 value: function unsafe(sections, ...substitutions) { 9615 return substitutions.reduce((acc, item, index) => acc + Text.decode(item) + sections[index + 1], sections[0]); 9616 } 9617 /** 9618 * Adds styles to specified element 9619 * @param {HTMLElement} element 9620 * @return {Function} 9621 */ 9622 }, { 9623 key: "style", 9624 value: function style(element) { 9625 if (!Type.isDomNode(element)) { 9626 throw new Error('element is not HTMLElement'); 9627 } 9628 return function styleTagHandler(...args) { 9629 Dom.style(element, parseProps(...args)); 9630 }; 9631 } 9632 /** 9633 * Replace all messages identifiers to real messages 9634 * @param sections 9635 * @param substitutions 9636 * @return {string} 9637 */ 9638 }, { 9639 key: "message", 9640 value: function message(sections, ...substitutions) { 9641 return substitutions.reduce((acc, item, index) => acc + Loc.getMessage(item) + sections[index + 1], sections[0]); 9642 } 9643 }, { 9644 key: "attrs", 9645 /** 9646 * Adds attributes to specified element 9647 * @param element 9648 * @return {Function} 9649 */ 9650 value: function attrs(element) { 9651 if (!Type.isDomNode(element)) { 9652 throw new Error('element is not HTMLElement'); 9653 } 9654 return function attrsTagHandler(...args) { 9655 Dom.attr(element, parseProps(...args)); 9656 }; 9657 } 9658 }]); 9659 return Tag; 9660 }(); 9661 babelHelpers.defineProperty(Tag, "render", render); 9662 babelHelpers.defineProperty(Tag, "attr", Tag.attrs); 9663 9664 function getParser(format) { 9665 switch (format) { 9666 case 'index': 9667 return (sourceKey, value, accumulator) => { 9668 const result = /\[(\w*)\]$/.exec(sourceKey); 9669 const key = sourceKey.replace(/\[\w*\]$/, ''); 9670 if (Type.isNil(result)) { 9671 accumulator[key] = value; 9672 return; 9673 } 9674 if (Type.isUndefined(accumulator[key])) { 9675 accumulator[key] = {}; 9676 } 9677 accumulator[key][result[1]] = value; 9678 }; 9679 case 'bracket': 9680 return (sourceKey, value, accumulator) => { 9681 const result = /(\[\])$/.exec(sourceKey); 9682 const key = sourceKey.replace(/\[\]$/, ''); 9683 if (Type.isNil(result)) { 9684 accumulator[key] = value; 9685 return; 9686 } 9687 if (Type.isUndefined(accumulator[key])) { 9688 accumulator[key] = Type.isNil(value) ? [] : [value]; 9689 return; 9690 } 9691 accumulator[key] = [].concat(accumulator[key], value); 9692 }; 9693 default: 9694 return (sourceKey, value, accumulator) => {
9695 const key = sourceKey.replace(/\[\]$/, ''); 9696 accumulator[key] = value; 9697 }; 9698 } 9699 } 9700 function getKeyFormat(key) { 9701 if (/^\w+\[([\w]+)\]$/.test(key)) { 9702 return 'index'; 9703 } 9704 if (/^\w+\[\]$/.test(key)) { 9705 return 'bracket'; 9706 } 9707 return 'default'; 9708 } 9709 function isAllowedKey(key) { 9710 return !String(key).startsWith('__proto__'); 9711 } 9712 function parseQuery(input) { 9713 if (!Type.isString(input)) { 9714 return {}; 9715 } 9716 const url = input.trim().replace(/^[?#&]/, ''); 9717 if (!url) { 9718 return {}; 9719 } 9720 return { 9721 ...url.split('&').reduce((acc, param) => { 9722 const [key, value] = param.replace(/\+/g, ' ').split('='); 9723 if (isAllowedKey(key)) { 9724 const keyFormat = getKeyFormat(key); 9725 const formatter = getParser(keyFormat); 9726 formatter(key, value, acc); 9727 } 9728 return acc; 9729 }, Object.create(null)) 9730 }; 9731 } 9732 const urlExp = /^((\w+):)?(\/\/((\w+)?(:(\w+))?@)?([^\/\?:]+)(:(\d+))?)?(\/?([^\/\?#][^\?#]*)?)?(\?([^#]+))?(#((?:[\w-?/:@.~!$&'()*+,;=]|%\w{2})*))?/; 9733 function prepareParams(params) { 9734 const paramsEntries = Object.entries(params); 9735 return paramsEntries.reduce((acc, [key, value]) => { 9736 if (Type.isNil(value)) { 9737 acc[key] = ''; 9738 } else if (Type.isPlainObject(value)) { 9739 acc[key] = prepareParams(value); 9740 } else { 9741 acc[key] = value; 9742 } 9743 return acc; 9744 }, {}); 9745 } 9746 function parseUrl(url) { 9747 const result = url.match(urlExp); 9748 if (Type.isArray(result)) { 9749 const sourceParams = parseQuery(result[14]); 9750 const preparedParams = prepareParams(sourceParams); 9751 return { 9752 useShort: /^\/\//.test(url), 9753 href: result[0] || '', 9754 schema: result[2] || '', 9755 host: result[8] || '', 9756 port: result[10] || '', 9757 path: result[11] || '', 9758 query: result[14] || '', 9759 sourceQueryParams: sourceParams, 9760 queryParams: preparedParams, 9761 hash: result[16] || '', 9762 username: result[5] || '', 9763 password: result[7] || '', 9764 origin: result[8] || '' 9765 }; 9766 } 9767 return {}; 9768 } 9769 9770 function renderParam(param, value) { 9771 if (Type.isNil(value)) { 9772 return param; 9773 } 9774 return `${param}=${value}`; 9775 } 9776 9777 function buildQueryString(params = {}) { 9778 const queryString = Object.keys(params).reduce((acc, key) => { 9779 if (Type.isArray(params[key])) { 9780 if (Type.isArrayFilled(params[key])) { 9781 params[key].forEach(paramValue => { 9782 acc.push(renderParam(`${key}[]`, paramValue)); 9783 }); 9784 } else { 9785 acc.push(renderParam(`${key}[]`, null)); 9786 } 9787 } 9788 if (Type.isPlainObject(params[key])) { 9789 Object.keys(params[key]).forEach(paramIndex => { 9790 acc.push(renderParam(`${key}[${paramIndex}]`, params[key][paramIndex])); 9791 }); 9792 } 9793 if (!Type.isObject(params[key]) && !Type.isArray(params[key])) { 9794 acc.push(renderParam(key, params[key])); 9795 } 9796 return acc; 9797 }, []).join('&'); 9798 if (queryString.length > 0) { 9799 return `?${queryString}`; 9800 } 9801 return queryString; 9802 } 9803 9804 function prepareParamValue(value) { 9805 if (Type.isArray(value)) { 9806 return value.map(item => String(item)); 9807 } 9808 if (Type.isPlainObject(value)) { 9809 return { 9810 ...value 9811 }; 9812 } 9813 return String(value); 9814 } 9815 9816 const map = new WeakMap(); 9817 9818 /** 9819 * Implements interface for works with URI 9820 * @memberOf BX 9821 */ 9822 let Uri = /*#__PURE__*/function () { 9823 babelHelpers.createClass(Uri, null, [{ 9824 key: "addParam", 9825 value: function addParam(url, params = {}) { 9826 return new Uri(url).setQueryParams(params).toString(); 9827 } 9828 }, { 9829 key: "removeParam", 9830 value: function removeParam(url, params) { 9831 const removableParams = Type.isArray(params) ? params : [params]; 9832 return new Uri(url).removeQueryParam(...removableParams).toString(); 9833 } 9834 }]); 9835 function Uri(url = '') { 9836 babelHelpers.classCallCheck(this, Uri); 9837 map.set(this, parseUrl(url)); 9838 } 9839 babelHelpers.createClass(Uri, [{ 9840 key: "getSchema", 9841 value: function getSchema() { 9842 return map.get(this).schema; 9843 } 9844 }, { 9845 key: "setSchema", 9846 value: function setSchema(schema) { 9847 map.get(this).schema = String(schema); 9848 return this; 9849 } 9850 }, { 9851 key: "getHost", 9852 value: function getHost() { 9853 return map.get(this).host; 9854 } 9855 }, { 9856 key: "setHost", 9857 value: function setHost(host) { 9858 map.get(this).host = String(host); 9859 return this; 9860 } 9861 }, { 9862 key: "getPort", 9863 value: function getPort() { 9864 return map.get(this).port; 9865 } 9866 }, { 9867 key: "setPort", 9868 value: function setPort(port) { 9869 map.get(this).port = String(port); 9870 return this; 9871 } 9872 }, { 9873 key: "getPath", 9874 value: function getPath() { 9875 return map.get(this).path; 9876 } 9877 }, { 9878 key: "setPath", 9879 value: function setPath(path) { 9880 if (!/^\//.test(path)) {
9881 map.get(this).path = `/${String(path)}`; 9882 return this; 9883 } 9884 map.get(this).path = String(path); 9885 return this; 9886 } 9887 }, { 9888 key: "getQuery", 9889 value: function getQuery() { 9890 return buildQueryString(map.get(this).queryParams); 9891 } 9892 }, { 9893 key: "getQueryParam", 9894 value: function getQueryParam(key) { 9895 const params = this.getQueryParams(); 9896 if (Object.hasOwn(params, key)) { 9897 return params[key]; 9898 } 9899 return null; 9900 } 9901 }, { 9902 key: "setQueryParam", 9903 value: function setQueryParam(key, value = '') { 9904 map.get(this).queryParams[key] = prepareParamValue(value); 9905 map.get(this).sourceQueryParams[key] = prepareParamValue(value); 9906 return this; 9907 } 9908 }, { 9909 key: "getQueryParams", 9910 value: function getQueryParams() { 9911 return { 9912 ...map.get(this).queryParams 9913 }; 9914 } 9915 }, { 9916 key: "setQueryParams", 9917 value: function setQueryParams(params = {}) { 9918 if (Type.isPlainObject(params)) { 9919 const { 9920 queryParams, 9921 sourceQueryParams 9922 } = map.get(this); 9923 Object.entries(params).forEach(([key, value]) => { 9924 const preparedValue = prepareParamValue(value); 9925 queryParams[key] = preparedValue; 9926 sourceQueryParams[key] = preparedValue; 9927 }); 9928 } 9929 return this; 9930 } 9931 }, { 9932 key: "removeQueryParam", 9933 value: function removeQueryParam(...keys) { 9934 const { 9935 queryParams, 9936 sourceQueryParams 9937 } = map.get(this); 9938 keys.forEach(key => { 9939 delete queryParams[key]; 9940 delete sourceQueryParams[key]; 9941 }); 9942 return this; 9943 } 9944 }, { 9945 key: "getFragment", 9946 value: function getFragment() { 9947 return map.get(this).hash; 9948 } 9949 }, { 9950 key: "setFragment", 9951 value: function setFragment(hash) { 9952 map.get(this).hash = String(hash); 9953 return this; 9954 } 9955 }, { 9956 key: "serialize", 9957 value: function serialize() { 9958 const serialized = { 9959 ...map.get(this) 9960 }; 9961 delete serialized.sourceQueryParams; 9962 serialized.href = this.toString(); 9963 return serialized; 9964 } 9965 }, { 9966 key: "toString", 9967 value: function toString() { 9968 const data = { 9969 ...map.get(this) 9970 }; 9971 let protocol = data.schema ? `${data.schema}://` : ''; 9972 if (data.useShort) { 9973 protocol = '//'; 9974 } 9975 const port = (() => { 9976 if (Type.isString(data.port) && !['', '80'].includes(data.port)) { 9977 return `:${data.port}`; 9978 } 9979 return ''; 9980 })(); 9981 const host = this.getHost(); 9982 const path = this.getPath(); 9983 const query = buildQueryString(data.sourceQueryParams); 9984 const hash = data.hash ? `#${data.hash}` : ''; 9985 return `${host ? protocol : ''}${host}${host ? port : ''}${path}${query}${hash}`; 9986 } 9987 }]); 9988 return Uri; 9989 }(); 9990 9991 /** 9992 * @memberOf BX 9993 */ 9994 let Validation = /*#__PURE__*/function () { 9995 function Validation() { 9996 babelHelpers.classCallCheck(this, Validation); 9997 } 9998 babelHelpers.createClass(Validation, null, [{ 9999 key: "isEmail", 10000 /** 10001 * Checks that value is valid email 10002 * @param value 10003 * @return {boolean} 10004 */ 10005 value: function isEmail(value) { 10006 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])?)*$/; 10007 return exp.test(String(value).toLowerCase()); 10008 } 10009 }]); 10010 return Validation; 10011 }(); 10012 10013 let BaseCache = /*#__PURE__*/function () { 10014 function BaseCache() { 10015 babelHelpers.classCallCheck(this, BaseCache); 10016 babelHelpers.defineProperty(this, "storage", new Map()); 10017 } 10018 babelHelpers.createClass(BaseCache, [{ 10019 key: "get", 10020 /** 10021 * Gets cached value or default value 10022 */ 10023 value: function get(key, defaultValue) { 10024 if (!this.storage.has(key)) { 10025 if (Type.isFunction(defaultValue)) { 10026 return defaultValue(); 10027 } 10028 if (!Type.isUndefined(defaultValue)) { 10029 return defaultValue; 10030 } 10031 } 10032 return this.storage.get(key); 10033 } 10034 /**
10035 * Sets cache entry 10036 */ 10037 }, { 10038 key: "set", 10039 value: function set(key, value) { 10040 this.storage.set(key, value); 10041 } 10042 /** 10043 * Deletes cache entry 10044 */ 10045 }, { 10046 key: "delete", 10047 value: function _delete(key) { 10048 this.storage.delete(key); 10049 } 10050 /** 10051 * Checks that storage contains entry with specified key 10052 */ 10053 }, { 10054 key: "has", 10055 value: function has(key) { 10056 return this.storage.has(key); 10057 } 10058 /** 10059 * Gets cached value if exists, 10060 */ 10061 }, { 10062 key: "remember", 10063 value: function remember(key, defaultValue) { 10064 if (!this.storage.has(key)) { 10065 if (Type.isFunction(defaultValue)) { 10066 this.storage.set(key, defaultValue()); 10067 } else if (!Type.isUndefined(defaultValue)) { 10068 this.storage.set(key, defaultValue); 10069 } 10070 } 10071 return this.storage.get(key); 10072 } 10073 /** 10074 * Gets storage size 10075 */ 10076 }, { 10077 key: "size", 10078 value: function size() { 10079 return this.storage.size; 10080 } 10081 /** 10082 * Gets storage keys 10083 */ 10084 }, { 10085 key: "keys", 10086 value: function keys() { 10087 return [...this.storage.keys()]; 10088 } 10089 /** 10090 * Gets storage values 10091 */ 10092 }, { 10093 key: "values", 10094 value: function values() { 10095 return [...this.storage.values()]; 10096 } 10097 }]); 10098 return BaseCache; 10099 }(); 10100 10101 let MemoryCache = /*#__PURE__*/function (_BaseCache) { 10102 babelHelpers.inherits(MemoryCache, _BaseCache); 10103 function MemoryCache(...args) { 10104 var _this; 10105 babelHelpers.classCallCheck(this, MemoryCache); 10106 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(MemoryCache).call(this, ...args)); 10107 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new Map()); 10108 return _this; 10109 } 10110 return MemoryCache; 10111 }(BaseCache); 10112 10113 let LsStorage = /*#__PURE__*/function () { 10114 function LsStorage() { 10115 babelHelpers.classCallCheck(this, LsStorage); 10116 babelHelpers.defineProperty(this, "stackKey", 'BX.Cache.Storage.LsStorage.stack'); 10117 babelHelpers.defineProperty(this, "stack", null); 10118 } 10119 babelHelpers.createClass(LsStorage, [{ 10120 key: "getStack", 10121 /** 10122 * @private 10123 */ 10124 value: function getStack() { 10125 if (Type.isPlainObject(this.stack)) { 10126 return this.stack; 10127 } 10128 const stack = localStorage.getItem(this.stackKey); 10129 if (Type.isString(stack) && stack !== '') { 10130 const parsedStack = JSON.parse(stack); 10131 if (Type.isPlainObject(parsedStack)) { 10132 this.stack = parsedStack; 10133 return this.stack; 10134 } 10135 } 10136 this.stack = {}; 10137 return this.stack; 10138 } 10139 /** 10140 * @private 10141 */ 10142 }, { 10143 key: "saveStack", 10144 value: function saveStack() { 10145 if (Type.isPlainObject(this.stack)) { 10146 const preparedStack = JSON.stringify(this.stack); 10147 localStorage.setItem(this.stackKey, preparedStack); 10148 } 10149 } 10150 }, { 10151 key: "get", 10152 value: function get(key) { 10153 const stack = this.getStack(); 10154 return stack[key]; 10155 } 10156 }, { 10157 key: "set", 10158 value: function set(key, value) { 10159 const stack = this.getStack(); 10160 stack[key] = value; 10161 this.saveStack(); 10162 } 10163 }, { 10164 key: "delete", 10165 value: function _delete(key) { 10166 const stack = this.getStack(); 10167 if (key in stack) { 10168 delete stack[key]; 10169 } 10170 } 10171 }, { 10172 key: "has", 10173 value: function has(key) { 10174 const stack = this.getStack(); 10175 return key in stack; 10176 } 10177 }, { 10178 key: "keys", 10179 value: function keys() { 10180 const stack = this.getStack(); 10181 return Object.keys(stack); 10182 } 10183 }, { 10184 key: "values", 10185 value: function values() { 10186 const stack = this.getStack(); 10187 return Object.values(stack); 10188 } 10189 }, { 10190 key: "size", 10191 get: function () { 10192 const stack = this.getStack(); 10193 return Object.keys(stack).length; 10194 } 10195 }]); 10196 return LsStorage; 10197 }(); 10198 10199 let LocalStorageCache = /*#__PURE__*/function (_BaseCache) { 10200 babelHelpers.inherits(LocalStorageCache, _BaseCache); 10201 function LocalStorageCache(...args) { 10202 var _this; 10203 babelHelpers.classCallCheck(this, LocalStorageCache); 10204 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(LocalStorageCache).call(this, ...args)); 10205 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new LsStorage()); 10206 return _this; 10207 } 10208 return LocalStorageCache; 10209 }(BaseCache); 10210 10211 /** 10212 * @memberOf BX 10213 */ 10214 let Cache = function Cache() { 10215 babelHelpers.classCallCheck(this, Cache); 10216 }; 10217 babelHelpers.defineProperty(Cache, "BaseCache", BaseCache); 10218 babelHelpers.defineProperty(Cache, "MemoryCache", MemoryCache); 10219 babelHelpers.defineProperty(Cache, "LocalStorageCache", LocalStorageCache); 10220 10221 function convertPath(path) { 10222 if (Type.isStringFilled(path)) { 10223 return path.split('.').reduce((acc, item) => { 10224 item.split(/\[['"]?(.+?)['"]?\]/g).forEach(key => { 10225 if (Type.isStringFilled(key)) { 10226 acc.push(key); 10227 } 10228 }); 10229 return acc; 10230 }, []); 10231 } 10232 return []; 10233 } 10234 10235 let SettingsCollection = /*#__PURE__*/function () { 10236 function SettingsCollection(options = {}) { 10237 babelHelpers.classCallCheck(this, SettingsCollection); 10238 if (Type.isPlainObject(options)) { 10239 Object.assign(this, options); 10240 } 10241 } 10242 babelHelpers.createClass(SettingsCollection, [{ 10243 key: "get", 10244 value: function get(path, defaultValue = null) { 10245 const convertedPath = convertPath(path); 10246 return convertedPath.reduce((acc, key) => { 10247 if (!Type.isNil(acc) && acc !== defaultValue) { 10248 if (!Type.isUndefined(acc[key])) { 10249 return acc[key]; 10250 } 10251 return defaultValue; 10252 } 10253 return acc; 10254 }, this); 10255 } 10256 }]); 10257 return SettingsCollection; 10258 }(); 10259 10260 function deepFreeze(target) { 10261 if (Type.isObject(target)) { 10262 Object.values(target).forEach(value => { 10263 deepFreeze(value); 10264 }); 10265 return Object.freeze(target); 10266 } 10267 return target; 10268 } 10269 10270 const settingsStorage = new Map(); 10271 let Extension = /*#__PURE__*/function () { 10272 function Extension() { 10273 babelHelpers.classCallCheck(this, Extension); 10274 } 10275 babelHelpers.createClass(Extension, null, [{ 10276 key: "getSettings", 10277 value: function getSettings(extensionName) { 10278 if (Type.isStringFilled(extensionName)) { 10279 if (settingsStorage.has(extensionName)) { 10280 return settingsStorage.get(extensionName); 10281 } 10282 const settingsScriptNode = document.querySelector(`script[data-extension="${extensionName}"]`); 10283 if (Type.isDomNode(settingsScriptNode)) { 10284 const decodedSettings = (() => { 10285 try { 10286 return new SettingsCollection(JSON.parse(settingsScriptNode.innerHTML)); 10287 } catch (error) { 10288 return new SettingsCollection(); 10289 } 10290 })(); 10291 const frozenSettings = deepFreeze(decodedSettings); 10292 settingsStorage.set(extensionName, frozenSettings); 10293 return frozenSettings; 10294 } 10295 } 10296 return deepFreeze(new SettingsCollection()); 10297 } 10298 }]); 10299 return Extension; 10300 }(); 10301 10302 let _Symbol$iterator; 10303 function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); } 10304 function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 10305 function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 10306 var _searchIndexToInsert = /*#__PURE__*/new WeakSet(); 10307 _Symbol$iterator = Symbol.iterator; 10308 let OrderedArray = /*#__PURE__*/function () { 10309 function OrderedArray(comparator = null) { 10310 babelHelpers.classCallCheck(this, OrderedArray); 10311 _classPrivateMethodInitSpec(this, _searchIndexToInsert); 10312 babelHelpers.defineProperty(this, "comparator", null); 10313 babelHelpers.defineProperty(this, "items", []); 10314 this.comparator = Type.isFunction(comparator) ? comparator : null; 10315 } 10316 babelHelpers.createClass(OrderedArray, [{ 10317 key: "add", 10318 value: function add(item) { 10319 let index = -1; 10320 if (this.comparator) { 10321 index = _classPrivateMethodGet(this, _searchIndexToInsert, _searchIndexToInsert2).call(this, item); 10322 this.items.splice(index, 0, item); 10323 } else { 10324 this.items.push(item); 10325 } 10326 return index; 10327 } 10328 }, { 10329 key: "has", 10330 value: function has(item) { 10331 return this.items.includes(item); 10332 } 10333 }, { 10334 key: "getIndex", 10335 value: function getIndex(item) { 10336 return this.items.indexOf(item); 10337 } 10338 }, { 10339 key: "getByIndex", 10340 value: function getByIndex(index) { 10341 if (Type.isNumber(index) && index >= 0) { 10342 const item = this.items[index]; 10343 return Type.isUndefined(item) ? null : item; 10344 } 10345 return null; 10346 } 10347 }, { 10348 key: "getFirst", 10349 value: function getFirst() { 10350 const first = this.items[0]; 10351 return Type.isUndefined(first) ? null : first; 10352 } 10353 }, { 10354 key: "getLast", 10355 value: function getLast() { 10356 const last = this.items[this.count() - 1]; 10357 return Type.isUndefined(last) ? null : last; 10358 } 10359 }, { 10360 key: "count", 10361 value: function count() { 10362 return this.items.length; 10363 } 10364 }, { 10365 key: "delete", 10366 value: function _delete(item) { 10367 const index = this.getIndex(item); 10368 if (index !== -1) { 10369 this.items.splice(index, 1); 10370 return true; 10371 } 10372 return false;
10373 } 10374 }, { 10375 key: "clear", 10376 value: function clear() { 10377 this.items = []; 10378 } 10379 }, { 10380 key: _Symbol$iterator, 10381 value: function () { 10382 return this.items[Symbol.iterator](); 10383 } 10384 }, { 10385 key: "forEach", 10386 value: function forEach(callbackfn, thisArg) { 10387 return this.items.forEach(callbackfn, thisArg); 10388 } 10389 }, { 10390 key: "getAll", 10391 value: function getAll() { 10392 return this.items; 10393 } 10394 }, { 10395 key: "getComparator", 10396 value: function getComparator() { 10397 return this.comparator; 10398 } 10399 }, { 10400 key: "sort", 10401 value: function sort() { 10402 const comparator = this.getComparator(); 10403 if (comparator === null) { 10404 return; 10405 } 10406 10407 /* 10408 Simple implementation 10409 this.items.sort((item1, item2) => { 10410 return comparator(item1, item2); 10411 }); 10412 */ 10413 10414 // For stable sorting https://v8.dev/features/stable-sort 10415 const length = this.items.length; 10416 const indexes = new Array(length); 10417 for (let i = 0; i < length; i++) { 10418 indexes[i] = i; 10419 } 10420 10421 // If the comparator returns zero, use the original indexes 10422 indexes.sort((index1, index2) => { 10423 return comparator(this.items[index1], this.items[index2]) || index1 - index2; 10424 }); 10425 for (let i = 0; i < length; i++) { 10426 indexes[i] = this.items[indexes[i]]; 10427 } 10428 for (let i = 0; i < length; i++) { 10429 this.items[i] = indexes[i]; 10430 } 10431 } 10432 }]); 10433 return OrderedArray; 10434 }(); 10435 function _searchIndexToInsert2(value) { 10436 let low = 0; 10437 let high = this.items.length; 10438 while (low < high) { 10439 const mid = Math.floor((low + high) / 2); 10440 if (this.comparator(this.items[mid], value) >= 0) { 10441 high = mid; 10442 } else { 10443 low = mid + 1; 10444 } 10445 } 10446 return low; 10447 } 10448 10449 let ZIndexComponent = /*#__PURE__*/function (_EventEmitter) { 10450 babelHelpers.inherits(ZIndexComponent, _EventEmitter); 10451 function ZIndexComponent(element, componentOptions = {}) { 10452 var _this; 10453 babelHelpers.classCallCheck(this, ZIndexComponent); 10454 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(ZIndexComponent).call(this)); 10455 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "sort", 0); 10456 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "alwaysOnTop", false); 10457 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "zIndex", 0); 10458 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "element", null); 10459 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlay", null); 10460 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlayGap", -5); 10461 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "stack", null); 10462 _this.setEventNamespace('BX.Main.ZIndexManager.Component'); 10463 if (!Type.isElementNode(element)) { 10464 throw new Error('ZIndexManager.Component: The argument \'element\' must be a DOM element.'); 10465 } 10466 _this.element = element; 10467 const options = Type.isPlainObject(componentOptions) ? componentOptions : {}; 10468 _this.setAlwaysOnTop(options.alwaysOnTop); 10469 _this.setOverlay(options.overlay); 10470 _this.setOverlayGap(options.overlayGap); 10471 _this.subscribeFromOptions(options.events); 10472 return _this; 10473 } 10474 babelHelpers.createClass(ZIndexComponent, [{ 10475 key: "getSort", 10476 value: function getSort() { 10477 return this.sort; 10478 } 10479 /** 10480 * @internal 10481 * @param sort 10482 */ 10483 }, { 10484 key: "setSort", 10485 value: function setSort(sort) { 10486 if (Type.isNumber(sort)) { 10487 this.sort = sort; 10488 } 10489 } 10490 /** 10491 * @internal 10492 * @param stack 10493 */ 10494 }, { 10495 key: "setStack", 10496 value: function setStack(stack) { 10497 this.stack = stack; 10498 } 10499 }, { 10500 key: "getStack", 10501 value: function getStack() { 10502 return this.stack; 10503 } 10504 }, { 10505 key: "getZIndex", 10506 value: function getZIndex() { 10507 return this.zIndex; 10508 } 10509 /** 10510 * @internal 10511 */ 10512 }, { 10513 key: "setZIndex", 10514 value: function setZIndex(zIndex) { 10515 const changed = this.getZIndex() !== zIndex; 10516 this.getElement().style.setProperty('z-index', zIndex, 'important'); 10517 this.zIndex = zIndex; 10518 if (this.getOverlay() !== null) { 10519 this.getOverlay().style.setProperty('z-index', zIndex + this.getOverlayGap(), 'important'); 10520 } 10521 if (changed) {
10522 this.emit('onZIndexChange', { 10523 component: this 10524 }); 10525 } 10526 } 10527 }, { 10528 key: "getAlwaysOnTop", 10529 value: function getAlwaysOnTop() { 10530 return this.alwaysOnTop; 10531 } 10532 }, { 10533 key: "setAlwaysOnTop", 10534 value: function setAlwaysOnTop(value) { 10535 if (Type.isNumber(value) || Type.isBoolean(value)) { 10536 this.alwaysOnTop = value; 10537 } 10538 } 10539 }, { 10540 key: "getElement", 10541 value: function getElement() { 10542 return this.element; 10543 } 10544 }, { 10545 key: "setOverlay", 10546 value: function setOverlay(overlay, gap) { 10547 if (Type.isElementNode(overlay) || overlay === null) { 10548 this.overlay = overlay; 10549 this.setOverlayGap(gap); 10550 if (this.getStack()) { 10551 this.getStack().sort(); 10552 } 10553 } 10554 } 10555 }, { 10556 key: "getOverlay", 10557 value: function getOverlay() { 10558 return this.overlay; 10559 } 10560 }, { 10561 key: "setOverlayGap", 10562 value: function setOverlayGap(gap) { 10563 if (Type.isNumber(gap)) { 10564 this.overlayGap = gap; 10565 } 10566 } 10567 }, { 10568 key: "getOverlayGap", 10569 value: function getOverlayGap() { 10570 return this.overlayGap; 10571 } 10572 }]); 10573 return ZIndexComponent; 10574 }(EventEmitter); 10575 10576 let ZIndexStack = /*#__PURE__*/function () { 10577 function ZIndexStack(container) { 10578 babelHelpers.classCallCheck(this, ZIndexStack); 10579 babelHelpers.defineProperty(this, "container", null); 10580 babelHelpers.defineProperty(this, "components", null); 10581 babelHelpers.defineProperty(this, "elements", new WeakMap()); 10582 babelHelpers.defineProperty(this, "baseIndex", 1000); 10583 babelHelpers.defineProperty(this, "baseStep", 50); 10584 babelHelpers.defineProperty(this, "sortCount", 0); 10585 if (!Type.isDomNode(container)) { 10586 throw new Error('ZIndexManager.Stack: The \'container\' argument must be a DOM element.'); 10587 } 10588 this.container = container; 10589 const comparator = (componentA, componentB) => { 10590 let result = (componentA.getAlwaysOnTop() || 0) - (componentB.getAlwaysOnTop() || 0); 10591 if (!result) { 10592 result = componentA.getSort() - componentB.getSort(); 10593 } 10594 return result; 10595 }; 10596 this.components = new OrderedArray(comparator); 10597 } 10598 babelHelpers.createClass(ZIndexStack, [{ 10599 key: "getBaseIndex", 10600 value: function getBaseIndex() { 10601 return this.baseIndex; 10602 } 10603 }, { 10604 key: "setBaseIndex", 10605 value: function setBaseIndex(index) { 10606 if (Type.isNumber(index) && index >= 0) { 10607 this.baseIndex = index; 10608 this.sort(); 10609 } 10610 } 10611 }, { 10612 key: "setBaseStep", 10613 value: function setBaseStep(step) { 10614 if (Type.isNumber(step) && step > 0) { 10615 this.baseStep = step; 10616 this.sort(); 10617 } 10618 } 10619 }, { 10620 key: "getBaseStep", 10621 value: function getBaseStep() { 10622 return this.baseStep; 10623 } 10624 }, { 10625 key: "register", 10626 value: function register(element, options = {}) { 10627 if (this.getComponent(element)) { 10628 console.warn('ZIndexManager: You cannot register the element twice.', element); 10629 return this.getComponent(element); 10630 } 10631 const component = new ZIndexComponent(element, options); 10632 component.setStack(this); 10633 component.setSort(++this.sortCount); 10634 this.elements.set(element, component); 10635 this.components.add(component); 10636 this.sort(); 10637 return component; 10638 } 10639 }, { 10640 key: "unregister", 10641 value: function unregister(element) { 10642 const component = this.elements.get(element); 10643 this.components.delete(component); 10644 this.elements.delete(element); 10645 this.sort(); 10646 } 10647 }, { 10648 key: "getComponent", 10649 value: function getComponent(element) { 10650 return this.elements.get(element) || null; 10651 } 10652 }, { 10653 key: "getComponents", 10654 value: function getComponents() { 10655 return this.components.getAll(); 10656 } 10657 }, { 10658 key: "getMaxZIndex", 10659 value: function getMaxZIndex() { 10660 const last = this.components.getLast(); 10661 return last ? last.getZIndex() : this.baseIndex; 10662 } 10663 }, { 10664 key: "sort", 10665 value: function sort() { 10666 this.components.sort(); 10667 let zIndex = this.baseIndex;
10668 this.components.forEach(component => { 10669 component.setZIndex(zIndex); 10670 zIndex += this.baseStep; 10671 }); 10672 } 10673 }, { 10674 key: "bringToFront", 10675 value: function bringToFront(element) { 10676 const component = this.getComponent(element); 10677 if (!component) { 10678 console.error('ZIndexManager: element was not found in the stack.', element); 10679 return null; 10680 } 10681 component.setSort(++this.sortCount); 10682 this.sort(); 10683 return component; 10684 } 10685 }]); 10686 return ZIndexStack; 10687 }(); 10688 10689 function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; } 10690 function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } } 10691 /** 10692 * @memberof BX 10693 */ 10694 let ZIndexManager = /*#__PURE__*/function () { 10695 function ZIndexManager() { 10696 babelHelpers.classCallCheck(this, ZIndexManager); 10697 } 10698 babelHelpers.createClass(ZIndexManager, null, [{ 10699 key: "register", 10700 value: function register(element, options = {}) { 10701 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10702 if (!parentNode) { 10703 return null; 10704 } 10705 const stack = this.getOrAddStack(parentNode); 10706 return stack.register(element, options); 10707 } 10708 }, { 10709 key: "unregister", 10710 value: function unregister(element) { 10711 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10712 const stack = this.getStack(parentNode); 10713 if (stack) { 10714 stack.unregister(element); 10715 } 10716 } 10717 }, { 10718 key: "addStack", 10719 value: function addStack(container) { 10720 const stack = new ZIndexStack(container); 10721 this.stacks.set(container, stack); 10722 return stack; 10723 } 10724 }, { 10725 key: "getStack", 10726 value: function getStack(container) { 10727 return this.stacks.get(container) || null; 10728 } 10729 }, { 10730 key: "getOrAddStack", 10731 value: function getOrAddStack(container) { 10732 return this.getStack(container) || this.addStack(container); 10733 } 10734 }, { 10735 key: "getComponent", 10736 value: function getComponent(element) { 10737 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element, true); 10738 if (!parentNode) { 10739 return null; 10740 } 10741 const stack = this.getStack(parentNode); 10742 return stack ? stack.getComponent(element) : null; 10743 } 10744 }, { 10745 key: "bringToFront", 10746 value: function bringToFront(element) { 10747 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10748 const stack = this.getStack(parentNode); 10749 if (stack) { 10750 return stack.bringToFront(element); 10751 } 10752 return null; 10753 } 10754 }]); 10755 return ZIndexManager; 10756 }(); 10757 function _getParentNode(element, suppressWarnings = false) { 10758 if (!Type.isElementNode(element)) { 10759 if (!suppressWarnings) { 10760 console.error('ZIndexManager: The argument \'element\' must be a DOM element.', element); 10761 } 10762 return null; 10763 } else if (!Type.isElementNode(element.parentNode)) { 10764 if (!suppressWarnings) { 10765 console.error('ZIndexManager: The \'element\' doesn\'t have a parent node.', element); 10766 } 10767 return null; 10768 } 10769 return element.parentNode; 10770 } 10771 babelHelpers.defineProperty(ZIndexManager, "stacks", new WeakMap()); 10772 10773 function _classPrivateMethodInitSpec$1(obj, privateSet) { _checkPrivateRedeclaration$1(obj, privateSet); privateSet.add(obj); } 10774 function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration$1(obj, privateMap); privateMap.set(obj, value); } 10775 function _checkPrivateRedeclaration$1(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 10776 function _classPrivateMethodGet$1(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 10777 10778 // eslint-disable-next-line @bitrix24/bitrix24-rules/no-typeof 10779 const IS_WEAK_REF_SUPPORTED = typeof WeakRef !== 'undefined'; 10780 var _refs = /*#__PURE__*/new WeakMap(); 10781 var _registry = /*#__PURE__*/new WeakMap(); 10782 var _cleanupCallback = /*#__PURE__*/new WeakSet(); 10783 let WeakRefMap = /*#__PURE__*/function () { 10784 function WeakRefMap() { 10785 babelHelpers.classCallCheck(this, WeakRefMap); 10786 _classPrivateMethodInitSpec$1(this, _cleanupCallback); 10787 _classPrivateFieldInitSpec(this, _refs, { 10788 writable: true, 10789 value: new Map() 10790 }); 10791 _classPrivateFieldInitSpec(this, _registry, { 10792 writable: true, 10793 value: null 10794 }); 10795 if (IS_WEAK_REF_SUPPORTED) { 10796 babelHelpers.classPrivateFieldSet(this, _registry, new FinalizationRegistry(_classPrivateMethodGet$1(this, _cleanupCallback, _cleanupCallback2).bind(this))); 10797 } 10798 } 10799 babelHelpers.createClass(WeakRefMap, [{ 10800 key: "clear", 10801 value: function clear() { 10802 if (!IS_WEAK_REF_SUPPORTED) { 10803 babelHelpers.classPrivateFieldGet(this, _refs).clear(); 10804 return; 10805 }
10806 babelHelpers.classPrivateFieldGet(this, _refs).forEach((ref, key) => { 10807 const value = ref === null || ref === void 0 ? void 0 : ref.deref(); 10808 if (!Type.isUndefined(value)) { 10809 babelHelpers.classPrivateFieldGet(this, _registry).unregister(value); 10810 } 10811 }); 10812 babelHelpers.classPrivateFieldGet(this, _refs).clear(); 10813 } 10814 }, { 10815 key: "delete", 10816 value: function _delete(key) { 10817 if (!IS_WEAK_REF_SUPPORTED) { 10818 return babelHelpers.classPrivateFieldGet(this, _refs).delete(key); 10819 } 10820 const value = this.get(key); 10821 if (!Type.isUndefined(value)) { 10822 babelHelpers.classPrivateFieldGet(this, _registry).unregister(value); 10823 } 10824 return babelHelpers.classPrivateFieldGet(this, _refs).delete(key); 10825 } 10826 }, { 10827 key: "get", 10828 value: function get(key) { 10829 var _babelHelpers$classPr; 10830 if (!IS_WEAK_REF_SUPPORTED) { 10831 return babelHelpers.classPrivateFieldGet(this, _refs).get(key); 10832 } 10833 return (_babelHelpers$classPr = babelHelpers.classPrivateFieldGet(this, _refs).get(key)) === null || _babelHelpers$classPr === void 0 ? void 0 : _babelHelpers$classPr.deref(); 10834 } 10835 }, { 10836 key: "has", 10837 value: function has(key) { 10838 var _babelHelpers$classPr2; 10839 if (!IS_WEAK_REF_SUPPORTED) { 10840 return babelHelpers.classPrivateFieldGet(this, _refs).has(key); 10841 } 10842 return !Type.isUndefined((_babelHelpers$classPr2 = babelHelpers.classPrivateFieldGet(this, _refs).get(key)) === null || _babelHelpers$classPr2 === void 0 ? void 0 : _babelHelpers$classPr2.deref()); 10843 } 10844 }, { 10845 key: "set", 10846 value: function set(key, value) { 10847 if (!IS_WEAK_REF_SUPPORTED) { 10848 babelHelpers.classPrivateFieldGet(this, _refs).set(key, value); 10849 return this; 10850 } 10851 babelHelpers.classPrivateFieldGet(this, _refs).set(key, new WeakRef(value)); 10852 babelHelpers.classPrivateFieldGet(this, _registry).register(value, key, value); 10853 return this; 10854 } 10855 }]); 10856 return WeakRefMap; 10857 }(); 10858 function _cleanupCallback2(key) { 10859 const ref = babelHelpers.classPrivateFieldGet(this, _refs).get(key); 10860 if (ref && !ref.deref()) { 10861 babelHelpers.classPrivateFieldGet(this, _refs).delete(key); 10862 } 10863 } 10864 10865 var collections = { 10866 OrderedArray, 10867 SettingsCollection, 10868 WeakRefMap 10869 }; 10870 10871 function getElement(element) { 10872 if (Type.isString(element)) { 10873 return document.getElementById(element); 10874 } 10875 return element; 10876 } 10877 10878 function getWindow(element) { 10879 if (Type.isElementNode(element)) { 10880 return element.ownerDocument.parentWindow || element.ownerDocument.defaultView || window; 10881 } 10882 if (Type.isDomNode(element)) { 10883 return element.parentWindow || element.defaultView || window; 10884 } 10885 return window; 10886 } 10887 10888 /* eslint-disable prefer-rest-params */ 10889 10890 // BX.* 10891 const { 10892 getClass, 10893 namespace 10894 } = Reflection; 10895 const message$1 = message; 10896 10897 /** 10898 * @memberOf BX 10899 */ 10900 const { 10901 replace, 10902 remove, 10903 clean, 10904 insertBefore, 10905 insertAfter, 10906 append, 10907 prepend, 10908 style, 10909 adjust, 10910 create, 10911 isShown 10912 } = Dom; 10913 const addClass = function addClass() { 10914 Dom.addClass(...Runtime.merge([], Array.from(arguments), [getElement(arguments[0])])); 10915 }; 10916 const removeClass = function removeClass() { 10917 Dom.removeClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 10918 }; 10919 const hasClass = function hasClass() { 10920 return Dom.hasClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 10921 }; 10922 const toggleClass = function toggleClass() { 10923 Dom.toggleClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 10924 }; 10925 const cleanNode = (element, removeElement = false) => { 10926 const currentElement = getElement(element); 10927 if (Type.isDomNode(currentElement)) { 10928 Dom.clean(currentElement); 10929 if (removeElement) { 10930 Dom.remove(currentElement); 10931 return currentElement; 10932 } 10933 } 10934 return currentElement; 10935 }; 10936 const getCookie = Http.Cookie.get; 10937 const setCookie = (name, value, options = {}) => { 10938 const attributes = { 10939 ...options 10940 }; 10941 if (Type.isNumber(attributes.expires)) { 10942 attributes.expires /= 3600 * 24; 10943 } 10944 Http.Cookie.set(name, value, attributes); 10945 }; 10946 const { 10947 bind: bind$1, 10948 unbind: unbind$1, 10949 unbindAll: unbindAll$1, 10950 bindOnce: bindOnce$1, 10951 ready: ready$1 10952 } = Event; 10953 const { 10954 debugState: debugEnableFlag, 10955 isDebugEnabled: debugStatus, 10956 default: debug$1 10957 }
10957 = debugNs; 10958 const debugEnable = value => { 10959 if (value) { 10960 enableDebug(); 10961 } else { 10962 disableDebug(); 10963 } 10964 }; 10965 const { 10966 clone: clone$1, 10967 loadExtension: loadExt, 10968 debounce, 10969 throttle, 10970 html 10971 } = Runtime; 10972 10973 // BX.type 10974 const type = { 10975 ...Object.getOwnPropertyNames(Type).filter(key => !['name', 'length', 'prototype', 'caller', 'arguments'].includes(key)).reduce((acc, key) => { 10976 acc[key] = Type[key]; 10977 return acc; 10978 }, {}), 10979 isNotEmptyString: value => Type.isString(value) && value !== '', 10980 isNotEmptyObject: value => Type.isObjectLike(value) && Object.keys(value).length > 0, 10981 isMapKey: Type.isObject, 10982 stringToInt: value => { 10983 const parsed = parseInt(value); 10984 return !Number.isNaN(parsed) ? parsed : 0; 10985 } 10986 }; 10987 10988 // BX.browser 10989 const browser = { 10990 IsOpera: Browser.isOpera, 10991 IsIE: Browser.isIE, 10992 IsIE6: Browser.isIE6, 10993 IsIE7: Browser.isIE7, 10994 IsIE8: Browser.isIE8, 10995 IsIE9: Browser.isIE9, 10996 IsIE10: Browser.isIE10, 10997 IsIE11: Browser.isIE11, 10998 IsSafari: Browser.isSafari, 10999 IsFirefox: Browser.isFirefox, 11000 IsChrome: Browser.isChrome, 11001 DetectIeVersion: Browser.detectIEVersion, 11002 IsMac: Browser.isMac, 11003 IsAndroid: Browser.isAndroid, 11004 isIPad: Browser.isIPad, 11005 isIPhone: Browser.isIPhone, 11006 IsIOS: Browser.isIOS, 11007 IsMobile: Browser.isMobile, 11008 isRetina: Browser.isRetina, 11009 IsDoctype: Browser.isDoctype, 11010 SupportLocalStorage: Browser.isLocalStorageSupported, 11011 addGlobalClass: Browser.addGlobalClass, 11012 DetectAndroidVersion: Browser.detectAndroidVersion, 11013 isPropertySupported: Browser.isPropertySupported, 11014 addGlobalFeatures: Browser.addGlobalFeatures 11015 }; 11016 11017 // eslint-disable-next-line 11018 const ajax = window.BX ? window.BX.ajax : () => {}; 11019 function GetWindowScrollSize(doc = document) { 11020 return { 11021 scrollWidth: doc.documentElement.scrollWidth, 11022 scrollHeight: doc.documentElement.scrollHeight 11023 }; 11024 } 11025 function GetWindowScrollPos(doc = document) { 11026 const win = getWindow(doc); 11027 return { 11028 scrollLeft: win.pageXOffset, 11029 scrollTop: win.pageYOffset 11030 }; 11031 } 11032 function GetWindowInnerSize(doc = document) { 11033 const win = getWindow(doc); 11034 return { 11035 innerWidth: win.innerWidth, 11036 innerHeight: win.innerHeight 11037 }; 11038 } 11039 function GetWindowSize(doc = document) { 11040 return { 11041 ...GetWindowInnerSize(doc), 11042 ...GetWindowScrollPos(doc), 11043 ...GetWindowScrollSize(doc) 11044 }; 11045 } 11046 function GetContext(node) { 11047 return getWindow(node); 11048 } 11049 function pos(element, relative = false) { 11050 if (!element) { 11051 return new DOMRect().toJSON(); 11052 } 11053 if (element.ownerDocument === document && !relative) { 11054 const clientRect = element.getBoundingClientRect(); 11055 const root = document.documentElement; 11056 const { 11057 body 11058 } = document; 11059 return { 11060 top: Math.round(clientRect.top + (root.scrollTop || body.scrollTop)), 11061 left: Math.round(clientRect.left + (root.scrollLeft || body.scrollLeft)), 11062 width: Math.round(clientRect.right - clientRect.left), 11063 height: Math.round(clientRect.bottom - clientRect.top), 11064 right: Math.round(clientRect.right + (root.scrollLeft || body.scrollLeft)), 11065 bottom: Math.round(clientRect.bottom + (root.scrollTop || body.scrollTop)) 11066 }; 11067 } 11068 let x = 0; 11069 let y = 0; 11070 const w = element.offsetWidth; 11071 const h = element.offsetHeight; 11072 let first = true; 11073 11074 // eslint-disable-next-line no-param-reassign 11075 for (; element != null; element = element.offsetParent) { 11076 if (!first && relative && BX.is_relative(element)) { 11077 break; 11078 } 11079 x += element.offsetLeft; 11080 y += element.offsetTop; 11081 if (first) { 11082 first = false; 11083 // eslint-disable-next-line no-continue 11084 continue; 11085 } 11086 x += Text.toNumber(Dom.style(element, 'border-left-width')); 11087 y += Text.toNumber(Dom.style(element, 'border-top-width')); 11088 } 11089 return new DOMRect(x, y, w, h).toJSON(); 11090 } 11091 function addCustomEvent(eventObject, eventName, eventHandler) { 11092 if (Type.isString(eventObject)) { 11093 eventHandler = eventName; 11094 eventName = eventObject; 11095 eventObject = EventEmitter.GLOBAL_TARGET;
11096 } 11097 if (eventObject === window) { 11098 eventObject = EventEmitter.GLOBAL_TARGET; 11099 } 11100 if (!Type.isObject(eventObject)) { 11101 console.error('The "eventObject" argument must be an object. Received type ' + typeof eventObject + '.'); 11102 return; 11103 } 11104 if (!Type.isStringFilled(eventName)) { 11105 console.error('The "eventName" argument must be a string.'); 11106 return; 11107 } 11108 if (!Type.isFunction(eventHandler)) { 11109 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11110 return; 11111 } 11112 eventName = eventName.toLowerCase(); 11113 EventEmitter.subscribe(eventObject, eventName, eventHandler, { 11114 compatMode: true, 11115 useGlobalNaming: true 11116 }); 11117 } 11118 function onCustomEvent(eventObject, eventName, eventParams, secureParams) { 11119 if (Type.isString(eventObject)) { 11120 secureParams = eventParams; 11121 eventParams = eventName; 11122 eventName = eventObject; 11123 eventObject = EventEmitter.GLOBAL_TARGET; 11124 } 11125 if (!Type.isObject(eventObject) || eventObject === window) { 11126 eventObject = EventEmitter.GLOBAL_TARGET;
11127 } 11128 if (!eventParams) { 11129 eventParams = []; 11130 } 11131 eventName = eventName.toLowerCase(); 11132 const event = new BaseEvent(); 11133 event.setData(eventParams); 11134 event.setCompatData(eventParams); 11135 EventEmitter.emit(eventObject, eventName, event, { 11136 cloneData: secureParams === true, 11137 useGlobalNaming: true 11138 }); 11139 } 11140 function removeCustomEvent(eventObject, eventName, eventHandler) { 11141 if (Type.isString(eventObject)) { 11142 eventHandler = eventName; 11143 eventName = eventObject; 11144 eventObject = EventEmitter.GLOBAL_TARGET; 11145 } 11146 if (!Type.isFunction(eventHandler)) { 11147 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11148 return; 11149 } 11150 if (eventObject === window) { 11151 eventObject = EventEmitter.GLOBAL_TARGET; 11152 } 11153 eventName = eventName.toLowerCase(); 11154 EventEmitter.unsubscribe(eventObject, eventName, eventHandler, { 11155 useGlobalNaming: true 11156 }); 11157 } 11158 function removeAllCustomEvents(eventObject, eventName) { 11159 if (Type.isString(eventObject)) { 11160 eventName = eventObject; 11161 eventObject = EventEmitter.GLOBAL_TARGET;
11162 } 11163 if (eventObject === window) { 11164 eventObject = EventEmitter.GLOBAL_TARGET; 11165 } 11166 eventName = eventName.toLowerCase(); 11167 EventEmitter.unsubscribeAll(eventObject, eventName, { 11168 useGlobalNaming: true 11169 }); 11170 } 11171 11172 if (typeof global === 'object' && global.window && global.window.BX) { 11173 Object.assign(global.window.BX, exports); 11174 } 11175 11176 exports.Type = Type; 11177 exports.Reflection = Reflection; 11178 exports.Text = Text; 11179 exports.Dom = Dom; 11180 exports.Browser = Browser; 11181 exports.Event = Event; 11182 exports.Http = Http; 11183 exports.Runtime = Runtime; 11184 exports.Loc = Loc; 11185 exports.Tag = Tag; 11186 exports.Uri = Uri; 11187 exports.Validation = Validation; 11188 exports.Cache = Cache; 11189 exports.BaseError = BaseError; 11190 exports.Extension = Extension; 11191 exports.ZIndexManager = ZIndexManager; 11192 exports.Collections = collections; 11193 exports.getClass = getClass; 11194 exports.namespace = namespace; 11195 exports.message = message$1; 11196 exports.replace = replace; 11197 exports.remove = remove; 11198 exports.clean = clean; 11199 exports.insertBefore = insertBefore; 11200 exports.insertAfter = insertAfter; 11201 exports.append = append; 11202 exports.prepend = prepend; 11203 exports.style = style; 11204 exports.adjust = adjust; 11205 exports.create = create; 11206 exports.isShown = isShown; 11207 exports.addClass = addClass; 11208 exports.removeClass = removeClass; 11209 exports.hasClass = hasClass; 11210 exports.toggleClass = toggleClass; 11211 exports.cleanNode = cleanNode; 11212 exports.getCookie = getCookie; 11213 exports.setCookie = setCookie; 11214 exports.bind = bind$1; 11215 exports.unbind = unbind$1; 11216 exports.unbindAll = unbindAll$1; 11217 exports.bindOnce = bindOnce$1; 11218 exports.ready = ready$1; 11219 exports.debugEnableFlag = debugEnableFlag; 11220 exports.debugStatus = debugStatus; 11221 exports.debug = debug$1; 11222 exports.debugEnable = debugEnable; 11223 exports.clone = clone$1; 11224 exports.loadExt = loadExt; 11225 exports.debounce = debounce; 11226 exports.throttle = throttle; 11227 exports.html = html; 11228 exports.type = type; 11229 exports.browser = browser; 11230 exports.ajax = ajax; 11231 exports.GetWindowScrollSize = GetWindowScrollSize; 11232 exports.GetWindowScrollPos = GetWindowScrollPos; 11233 exports.GetWindowInnerSize = GetWindowInnerSize; 11234 exports.GetWindowSize = GetWindowSize; 11235 exports.GetContext = GetContext; 11236 exports.pos = pos; 11237 exports.addCustomEvent = addCustomEvent; 11238 exports.onCustomEvent = onCustomEvent; 11239 exports.removeCustomEvent = removeCustomEvent; 11240 exports.removeAllCustomEvents = removeAllCustomEvents; 11241 11242}((this.BX = this.BX || {}))); 11243 11244 11245 11246(function(BX) { 11247 /* list of registered proxy functions */ 11248 var proxyList = new WeakMap(); 11249 var deferList = new WeakMap(); 11250 11251 /* List of denied event handlers */ 11252 var deniedEvents = []; 11253 11254 /* list of registered custom events */ 11255 var customEvents = new WeakMap(); 11256 var customEventsCnt = 0; 11257 11258 /* list of external garbage collectors */ 11259 var garbageCollectors = []; 11260 11261 /* list of loaded CSS files */ 11262 var cssList = []; 11263 var cssInit = false; 11264 11265 /* list of loaded JS files */ 11266 var jsList = []; 11267 var jsInit = false; 11268 11269 var eventTypes = { 11270 click: 'MouseEvent', 11271 dblclick: 'MouseEvent', 11272 mousedown: 'MouseEvent', 11273 mousemove: 'MouseEvent', 11274 mouseout: 'MouseEvent', 11275 mouseover: 'MouseEvent', 11276 mouseup: 'MouseEvent', 11277 focus: 'MouseEvent', 11278 blur: 'MouseEvent' 11279 }; 11280 11281 var lastWait = []; 11282 11283 var CHECK_FORM_ELEMENTS = {tagName: /^INPUT|SELECT|TEXTAREA|BUTTON$/i}; 11284 11285 BX.MSLEFT = 1; 11286 BX.MSMIDDLE = 2; 11287 BX.MSRIGHT = 4; 11288 11289 BX.AM_PM_UPPER = 1; 11290 BX.AM_PM_LOWER = 2; 11291 BX.AM_PM_NONE = false; 11292 11293 BX.ext = function(ob) 11294 { 11295 for (var i in ob) 11296 { 11297 if(ob.hasOwnProperty(i)) 11298 { 11299 this[i] = ob[i]; 11300 } 11301 } 11302 }; 11303 11304 var r = { 11305 script: /<script([^>]*)>/ig, 11306 script_end: /<\/script>/ig, 11307 script_src: /src=["\']([^"\']+)["\']/i, 11308 script_type: /type=["\']([^"\']+)["\']/i, 11309 space: /\s+/, 11310 ltrim: /^[\s\r\n]+/g, 11311 rtrim: /[\s\r\n]+$/g, 11312 style: /<link.*?(rel="stylesheet"|type="text\/css")[^>]*>/i, 11313 style_href: /href=["\']([^"\']+)["\']/i 11314 }; 11315 11316 BX.processHTML = function(data, scriptsRunFirst) 11317 { 11318 var matchScript, matchStyle, matchSrc, matchHref, matchType, scripts = [], styles = []; 11319 var textIndexes = []; 11320 var lastIndex = r.script.lastIndex = r.script_end.lastIndex = 0; 11321 11322 while ((matchScript = r.script.exec(data)) !== null) 11323 { 11324 r.script_end.lastIndex = r.script.lastIndex; 11325 var matchScriptEnd = r.script_end.exec(data); 11326 if (matchScriptEnd === null) 11327 { 11328 break; 11329 } 11330 11331 // skip script tags of special types 11332 var skipTag = false;
11333 if ((matchType = matchScript[1].match(r.script_type)) !== null) 11334 { 11335 if( 11336 matchType[1] == 'text/html' 11337 || matchType[1] == 'text/template' 11338 || matchType[1] == 'extension/settings' 11339 ) 11340 { 11341 skipTag = true; 11342 } 11343 } 11344 11345 if(skipTag) 11346 { 11347 textIndexes.push([lastIndex, r.script_end.lastIndex - lastIndex]); 11348 } 11349 else 11350 { 11351 textIndexes.push([lastIndex, matchScript.index - lastIndex]); 11352 11353 var bRunFirst = scriptsRunFirst || (matchScript[1].indexOf('bxrunfirst') != '-1'); 11354 11355 if ((matchSrc = matchScript[1].match(r.script_src)) !== null) 11356 { 11357 scripts.push({"bRunFirst": bRunFirst, "isInternal": false, "JS": matchSrc[1]}); 11358 } 11359 else 11360 { 11361 var start = matchScript.index + matchScript[0].length; 11362 var js = data.substr(start, matchScriptEnd.index-start); 11363 11364 scripts.push({"bRunFirst": bRunFirst, "isInternal": true, "JS": js}); 11365 } 11366 } 11367 11368 lastIndex = matchScriptEnd.index + 9; 11369 r.script.lastIndex = lastIndex; 11370 } 11371 11372 textIndexes.push([lastIndex, lastIndex === 0 ? data.length : data.length - lastIndex]); 11373 var pureData = ""; 11374 for (var i = 0, length = textIndexes.length; i < length; i++) 11375 { 11376 if (BX.type.isString(data) && BX.type.isFunction(data.substr)) 11377 { 11378 pureData += data.substr(textIndexes[i][0], textIndexes[i][1]); 11379 } 11380 } 11381 11382 while ((matchStyle = pureData.match(r.style)) !== null) 11383 { 11384 if ((matchHref = matchStyle[0].match(r.style_href)) !== null && matchStyle[0].indexOf('media="') < 0) 11385 { 11386 styles.push(matchHref[1]); 11387 } 11388 11389 pureData = pureData.replace(matchStyle[0], ''); 11390 } 11391 11392 return {'HTML': pureData, 'SCRIPT': scripts, 'STYLE': styles}; 11393 }; 11394 11395 /* OO emulation utility */ 11396 BX.extend = function(child, parent) 11397 { 11398 var f = function() {}; 11399 f.prototype = parent.prototype; 11400 11401 child.prototype = new f(); 11402 child.prototype.constructor = child; 11403 11404 child.superclass = parent.prototype; 11405 child.prototype.superclass = parent.prototype; 11406 if(parent.prototype.constructor == Object.prototype.constructor) 11407 { 11408 parent.prototype.constructor = parent; 11409 } 11410 }; 11411 11412 BX.is_subclass_of = function(ob, parent_class) 11413 { 11414 if (ob instanceof parent_class) 11415 return true; 11416 11417 if (parent_class.superclass) 11418 return BX.is_subclass_of(ob, parent_class.superclass); 11419 11420 return false; 11421 }; 11422 11423 BX.clearNodeCache = function() 11424 { 11425 return false; 11426 }; 11427 11428 BX.bitrix_sessid = function() {return BX.message("bitrix_sessid"); }; 11429 11430 /** 11431 * Creates document fragment with child nodes. 11432 * 11433 * @param {Node[]} nodes 11434 * @return {DocumentFragment} 11435 */ 11436 BX.createFragment = function(nodes) 11437 { 11438 var fragment = document.createDocumentFragment(); 11439 11440 if(!BX.type.isArray(nodes)) 11441 { 11442 return fragment; 11443 } 11444 for(var i = 0; i < nodes.length; i++) 11445 { 11446 fragment.appendChild(nodes[i]); 11447 } 11448 11449 return fragment; 11450 }; 11451 11452 /** 11453 * @deprecated 11454 * @use BX.style 11455 * @param element 11456 * @param opacity 11457 */ 11458 BX.setOpacity = function(element, opacity) 11459 { 11460 var opacityValue = parseFloat(opacity); 11461 11462 if (!isNaN(opacityValue) && BX.type.isDomNode(element)) 11463 { 11464 opacityValue = opacityValue < 1 ? opacityValue : opacityValue / 100; 11465 BX.style(element, 'opacity', opacityValue); 11466 } 11467 }; 11468 11469 /** 11470 * @deprecated 11471 * @param el 11472 * @return {*} 11473 */ 11474 BX.hoverEvents = function(el) 11475 { 11476 if (el) 11477 return BX.adjust(el, {events: BX.hoverEvents()}); 11478 else 11479 return {mouseover: BX.hoverEventsHover, mouseout: BX.hoverEventsHout}; 11480 }; 11481 11482 /** 11483 * @deprecated 11484 */ 11485 BX.hoverEventsHover = function(){BX.addClass(this,'bx-hover');this.BXHOVER=true;}; 11486 /** 11487 * @deprecated 11488 */ 11489 BX.hoverEventsHout = function(){BX.removeClass(this,'bx-hover');this.BXHOVER=false;}; 11490 11491 /** 11492 * @deprecated 11493 */ 11494 BX.focusEvents = function(el) 11495 { 11496 if (el) 11497 return BX.adjust(el, {events: BX.focusEvents()}); 11498 else 11499 return {mouseover: BX.focusEventsFocus, mouseout: BX.focusEventsBlur}; 11500 }; 11501 11502 /** 11503 * @deprecated 11504 */ 11505 BX.focusEventsFocus = function(){BX.addClass(this,'bx-focus');this.BXFOCUS=true;}; 11506 /** 11507 * @deprecated 11508 */ 11509 BX.focusEventsBlur = function(){BX.removeClass(this,'bx-focus');this.BXFOCUS=false;}; 11510 11511 BX.setUnselectable = function(node) 11512 { 11513 BX.style(node, { 11514 'userSelect': 'none', 11515 'MozUserSelect': 'none', 11516 'WebkitUserSelect': 'none', 11517 'KhtmlUserSelect': 'none', 11518 }); 11519 node.setAttribute('unSelectable', 'on'); 11520 }; 11521 11522 BX.setSelectable = function(node) 11523 { 11524 BX.style(node, { 11525 'userSelect': null, 11526 'MozUserSelect': null, 11527 'WebkitUserSelect': null, 11528 'KhtmlUserSelect': null, 11529 }); 11530 node.removeAttribute('unSelectable'); 11531 }; 11532 11533 BX.styleIEPropertyName = function(name) 11534 { 11535 if (name == 'float') 11536 name = BX.browser.IsIE() ? 'styleFloat' : 'cssFloat'; 11537 else 11538 { 11539 var res = BX.browser.isPropertySupported(name); 11540 if (res) 11541 { 11542 name = res; 11543 } 11544 else 11545 {
11546 var reg = /(\-([a-z]){1})/g; 11547 if (reg.test(name)) 11548 { 11549 name = name.replace(reg, function () {return arguments[2].toUpperCase();}); 11550 } 11551 } 11552 } 11553 return name; 11554 }; 11555 11556 BX.focus = function(el) 11557 { 11558 try 11559 { 11560 el.focus(); 11561 return true; 11562 } 11563 catch (e) 11564 { 11565 return false; 11566 } 11567 }; 11568 11569 BX.firstChild = function(el) 11570 { 11571 return BX.type.isDomNode(el) ? el.firstElementChild : null; 11572 }; 11573 11574 BX.lastChild = function(el) 11575 { 11576 return BX.type.isDomNode(el) ? el.lastElementChild : null; 11577 }; 11578 11579 BX.previousSibling = function(el) 11580 { 11581 return BX.type.isDomNode(el) ? el.previousElementSibling : null; 11582 }; 11583 11584 BX.nextSibling = function(el) 11585 { 11586 return BX.type.isDomNode(el) ? el.nextElementSibling : null; 11587 }; 11588 11589 /* 11590 params: { 11591 obj : html node 11592 className : className value 11593 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 11594 } 11595 11596 Search all nodes with className 11597 */ 11598 /** 11599 * @deprecated 11600 * @use .querySelectorAll 11601 * @param obj 11602 * @param className 11603 * @param recursive 11604 * @return {*} 11605 */ 11606 BX.findChildrenByClassName = function(obj, className, recursive) 11607 { 11608 if(!obj || !obj.childNodes) return null; 11609 11610 var result = []; 11611 if (typeof(obj.getElementsByClassName) == 'undefined') 11612 { 11613 recursive = recursive !== false; 11614 result = BX.findChildren(obj, {className : className}, recursive); 11615 } 11616 else 11617 { 11618 var col = obj.getElementsByClassName(className); 11619 for (i=0,l=col.length;i<l;i++) 11620 { 11621 result[i] = col[i]; 11622 } 11623 } 11624 return result; 11625 }; 11626 11627 /* 11628 params: { 11629 obj : html node 11630 className : className value 11631 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 11632 } 11633 11634 Search first node with className 11635 */ 11636 /** 11637 * @deprecated 11638 * @use .querySelector 11639 * @param obj 11640 * @param className 11641 * @param recursive 11642 * @return {*} 11643 */ 11644 BX.findChildByClassName = function(obj, className, recursive) 11645 { 11646 if(!obj || !obj.childNodes) return null; 11647 11648 var result = null; 11649 if (typeof(obj.getElementsByClassName) == 'undefined') 11650 { 11651 recursive = recursive !== false; 11652 result = BX.findChild(obj, {className : className}, recursive); 11653 } 11654 else 11655 { 11656 var col = obj.getElementsByClassName(className); 11657 if (col && typeof(col[0]) != 'undefined') 11658 { 11659 result = col[0]; 11660 } 11661 else 11662 { 11663 result = null; 11664 } 11665 } 11666 return result; 11667 }; 11668 11669 /* 11670 params: { 11671 tagName|tag : 'tagName', 11672 className|class : 'className', 11673 attribute : {attribute : value, attribute : value} | attribute | [attribute, attribute....], 11674 property : {prop: value, prop: value} | prop | [prop, prop] 11675 } 11676 11677 all values can be RegExps or strings 11678 */ 11679 /** 11680 * @deprecated 11681 * @use .querySelectorAll 11682 * @param obj 11683 * @param params 11684 * @param recursive 11685 * @return {*|Node} 11686 */ 11687 BX.findChildren = function(obj, params, recursive) 11688 { 11689 return BX.findChild(obj, params, recursive, true); 11690 }; 11691 11692 /** 11693 * @deprecated 11694 * @use .querySelectorAll 11695 * @param obj 11696 * @param params 11697 * @param recursive 11698 * @param get_all 11699 * @return {*} 11700 */ 11701 BX.findChild = function(obj, params, recursive, get_all) 11702 { 11703 if(!obj || !obj.childNodes) return null; 11704 11705 recursive = !!recursive; get_all = !!get_all; 11706 11707 var n = obj.childNodes.length, result = []; 11708 11709 for (var j=0; j<n; j++) 11710 { 11711 var child = obj.childNodes[j]; 11712 11713 if (_checkNode(child, params)) 11714 { 11715 if (get_all) 11716 result.push(child); 11717 else 11718 return child; 11719 } 11720 11721 if(recursive == true) 11722 { 11723 var res = BX.findChild(child, params, recursive, get_all); 11724 if (res) 11725 { 11726 if (get_all) 11727 result = BX.util.array_merge(result, res); 11728 else 11729 return res; 11730 } 11731 } 11732 } 11733 11734 if (get_all || result.length > 0) 11735 return result; 11736 else 11737 return null; 11738 }; 11739 11740 /** 11741 * @deprecated 11742 * @use .closest() 11743 * @param obj 11744 * @param params 11745 * @param maxParent 11746 * @return {*} 11747 */ 11748 BX.findParent = function(obj, params, maxParent) 11749 { 11750 if(!obj) 11751 return null; 11752 11753 var o = obj; 11754 while(o.parentNode) 11755 { 11756 var parent = o.parentNode; 11757 11758 if (_checkNode(parent, params)) 11759 return parent; 11760 11761 o = parent; 11762 11763 if (!!maxParent &&
11764 (BX.type.isFunction(maxParent) 11765 || typeof maxParent == 'object')) 11766 { 11767 if (BX.type.isElementNode(maxParent)) 11768 { 11769 if (o == maxParent) 11770 break; 11771 } 11772 else 11773 { 11774 if (_checkNode(o, maxParent)) 11775 break; 11776 } 11777 } 11778 } 11779 return null; 11780 }; 11781 11782 /** 11783 * @deprecated 11784 * @use .querySelector 11785 * @param obj 11786 * @param params 11787 * @return {*} 11788 */ 11789 BX.findNextSibling = function(obj, params) 11790 { 11791 if(!obj) 11792 return null; 11793 var o = obj; 11794 while(o.nextSibling) 11795 { 11796 var sibling = o.nextSibling; 11797 if (_checkNode(sibling, params)) 11798 return sibling; 11799 o = sibling; 11800 } 11801 return null; 11802 }; 11803 11804 /** 11805 * @deprecated 11806 * @use .querySelector 11807 * @param obj 11808 * @param params 11809 * @return {*} 11810 */ 11811 BX.findPreviousSibling = function(obj, params) 11812 { 11813 if(!obj) 11814 return null; 11815 11816 var o = obj; 11817 while(o.previousSibling) 11818 { 11819 var sibling = o.previousSibling; 11820 if(_checkNode(sibling, params)) 11821 return sibling; 11822 o = sibling; 11823 } 11824 return null; 11825 }; 11826 11827 BX.checkNode = function(obj, params) 11828 { 11829 return _checkNode(obj, params); 11830 }; 11831 11832 /** 11833 * @deprecated 11834 * @use .querySelectorAll 11835 * @param form 11836 * @return {Array} 11837 */ 11838 BX.findFormElements = function(form) 11839 { 11840 if (BX.type.isString(form)) 11841 form = document.forms[form]||BX(form); 11842 11843 var res = []; 11844 11845 if (BX.type.isElementNode(form)) 11846 { 11847 if (form.tagName.toUpperCase() == 'FORM') 11848 { 11849 res = form.elements; 11850 } 11851 else 11852 { 11853 res = BX.findChildren(form, CHECK_FORM_ELEMENTS, true); 11854 } 11855 } 11856 11857 return res; 11858 }; 11859 11860 /** 11861 * @deprecated 11862 * @use .contains() 11863 * @param whichNode 11864 * @param forNode 11865 * @return {boolean} 11866 */ 11867 BX.isParentForNode = function(whichNode, forNode) 11868 { 11869 if (BX.type.isDomNode(whichNode) && BX.type.isDomNode(forNode)) 11870 { 11871 return whichNode.contains(forNode); 11872 } 11873 11874 return false; 11875 }; 11876 11877 BX.getCaretPosition = function(node) 11878 { 11879 var pos = 0; 11880 11881 if(node.selectionStart || node.selectionStart == 0) 11882 { 11883 pos = node.selectionStart; 11884 } 11885 else if(document.selection) 11886 { 11887 node.focus(); 11888 var selection = document.selection.createRange(); 11889 selection.moveStart('character', -node.value.length); 11890 pos = selection.text.length; 11891 } 11892 11893 return (pos); 11894 }; 11895 11896 BX.setCaretPosition = function(node, pos) 11897 { 11898 if(!BX.isNodeInDom(node) || BX.isNodeHidden(node) || node.disabled) 11899 { 11900 return; 11901 } 11902 11903 if(node.setSelectionRange) 11904 { 11905 node.focus(); 11906 node.setSelectionRange(pos, pos); 11907 } 11908 else if(node.createTextRange) 11909 { 11910 var range = node.createTextRange(); 11911 range.collapse(true); 11912 range.moveEnd('character', pos); 11913 range.moveStart('character', pos); 11914 range.select(); 11915 } 11916 }; 11917 11918 // access private. use BX.mergeEx instead. 11919 // todo: refactor BX.merge, make it work through BX.mergeEx 11920 BX.merge = function(){ 11921 var arg = Array.prototype.slice.call(arguments); 11922 11923 if(arg.length < 2) 11924 return {}; 11925 11926 var result = arg.shift(); 11927 11928 for(var i = 0; i < arg.length; i++) 11929 { 11930 for(var k in arg[i]){ 11931 11932 if(typeof arg[i] == 'undefined' || arg[i] == null) 11933 continue; 11934 11935 if(arg[i].hasOwnProperty(k)){ 11936 11937 if(typeof arg[i][k] == 'undefined' || arg[i][k] == null) 11938 continue; 11939 11940 if(typeof arg[i][k] == 'object' && !BX.type.isDomNode(arg[i][k]) && (typeof arg[i][k]['isUIWidget'] == 'undefined')){ 11941 11942 // go deeper 11943 11944 var isArray = 'length' in arg[i][k]; 11945 11946 if(typeof result[k] != 'object') 11947 result[k] = isArray ? [] : {}; 11948 11949 if(isArray) 11950 BX.util.array_merge(result[k], arg[i][k]); 11951 else 11952 BX.merge(result[k], arg[i][k]); 11953 11954 }else 11955 result[k] = arg[i][k]; 11956 } 11957 } 11958 } 11959 11960 return result; 11961 }; 11962 11963 BX.mergeEx = function() 11964 { 11965 var arg = Array.prototype.slice.call(arguments); 11966 if(arg.length < 2) 11967 { 11968 return {}; 11969 } 11970 11971 var result = arg.shift(); 11972 for (var i = 0; i < arg.length; i++) 11973 { 11974 for (var k in arg[i]) 11975 { 11976 if (typeof arg[i] == "undefined" || arg[i] == null || !arg[i].hasOwnProperty(k)) 11977 { 11978 continue; 11979 } 11980 11981 if (BX.type.isPlainObject(arg[i][k]) && BX.type.isPlainObject(result[k])) 11982 { 11983 BX.mergeEx(result[k], arg[i][k]); 11984 } 11985 else 11986 { 11987 result[k] = BX.type.isPlainObject(arg[i][k]) ? BX.clone(arg[i][k]) : arg[i][k]; 11988 } 11989 } 11990 } 11991 11992 return result; 11993 }; 11994 11995 BX.getEventButton = function(e) 11996 { 11997 e = e || window.event; 11998 11999 var flags = 0; 12000 12001 if (typeof e.which != 'undefined') 12002 { 12003 switch (e.which) 12004 { 12005 case 1: flags = flags|BX.MSLEFT; break; 12006 case 2: flags = flags|BX.MSMIDDLE; break; 12007 case 3: flags = flags|BX.MSRIGHT; break; 12008 } 12009 } 12010 else if (typeof e.button != 'undefined') 12011 { 12012 flags = event.button; 12013 } 12014 12015 return flags || BX.MSLEFT; 12016 }; 12017 12018 var captured_events = null, _bind = null; 12019 BX.CaptureEvents = function(el_c, evname_c) 12020 { 12021 if (_bind) 12022 return; 12023 12024 _bind = BX.bind; 12025 captured_events = []; 12026 12027 BX.bind = function(el, evname, func) 12028 { 12029 if (el === el_c && evname === evname_c) 12030 captured_events.push(func); 12031 12032 _bind.apply(this, arguments); 12033 } 12034 }; 12035 12036 BX.CaptureEventsGet = function() 12037 { 12038 if (_bind) 12039 { 12040 BX.bind = _bind; 12041 12042 var captured = captured_events; 12043 12044 _bind = null; 12045 captured_events = null; 12046 return captured; 12047 } 12048 return null; 12049 }; 12050 12051 // Don't even try to use it for submit event! 12052 BX.fireEvent = function(ob,ev) 12053 { 12054 var result = false, e = null; 12055 if (BX.type.isDomNode(ob)) 12056 { 12057 result = true; 12058 if (document.createEventObject) 12059 { 12060 // IE 12061 if (eventTypes[ev] != 'MouseEvent') 12062 { 12063 e = document.createEventObject(); 12064 e.type = ev; 12065 result = ob.fireEvent('on' + ev, e); 12066 } 12067 12068 if (ob[ev]) 12069 { 12070 ob[ev](); 12071 } 12072 } 12073 else 12074 {
12075 // non-IE 12076 e = null; 12077 12078 switch (eventTypes[ev]) 12079 { 12080 case 'MouseEvent': 12081 e = document.createEvent('MouseEvent'); 12082 try 12083 { 12084 e.initMouseEvent(ev, true, true, top, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12085 } 12086 catch (initException) 12087 { 12088 e.initMouseEvent(ev, true, true, window, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12089 } 12090 12091 break; 12092 default: 12093 e = document.createEvent('Event'); 12094 e.initEvent(ev, true, true); 12095 } 12096 12097 result = ob.dispatchEvent(e); 12098 } 12099 } 12100 12101 return result; 12102 }; 12103 12104 BX.getWheelData = function(e) 12105 { 12106 e = e || window.event; 12107 e.wheelData = e.detail ? e.detail * -1 : e.wheelDelta / 40; 12108 return e.wheelData; 12109 }; 12110 12111 BX.proxy_context = null; 12112 12113 BX.delegate = function (func, thisObject) 12114 { 12115 if (!func || !thisObject) 12116 return func; 12117 12118 return function() { 12119 var cur = BX.proxy_context; 12120 BX.proxy_context = this; 12121 var res = func.apply(thisObject, arguments); 12122 BX.proxy_context = cur; 12123 return res; 12124 } 12125 }; 12126 12127 BX.delegateLater = function (func_name, thisObject, contextObject) 12128 { 12129 return function() 12130 { 12131 if (thisObject[func_name]) 12132 { 12133 var cur = BX.proxy_context; 12134 BX.proxy_context = this; 12135 var res = thisObject[func_name].apply(contextObject||thisObject, arguments); 12136 BX.proxy_context = cur; 12137 return res; 12138 } 12139 return null; 12140 } 12141 }; 12142 12143 BX.proxy = function(func, thisObject) 12144 { 12145 return getObjectDelegate(func, thisObject, proxyList); 12146 }; 12147 12148 BX.defer = function(func, thisObject) 12149 { 12150 if (!!thisObject) 12151 return BX.defer_proxy(func, thisObject); 12152 else 12153 return function() { 12154 var arg = arguments; 12155 setTimeout(function(){func.apply(this,arg)}, 10); 12156 }; 12157 }; 12158 12159 BX.defer_proxy = function(func, thisObject) 12160 { 12161 return getObjectDelegate(func, thisObject, deferList, BX.defer); 12162 }; 12163 12164 /** 12165 * 12166 * @private 12167 */ 12168 function getObjectDelegate(func, thisObject, collection, decorator) 12169 { 12170 if (!BX.type.isFunction(func) || !BX.type.isMapKey(thisObject)) 12171 { 12172 return func; 12173 } 12174 12175 var objectDelegates = collection.get(thisObject); 12176 if (!objectDelegates) 12177 { 12178 objectDelegates = new WeakMap(); 12179 collection.set(thisObject, objectDelegates); 12180 } 12181 12182 var delegate = objectDelegates.get(func); 12183 if (!delegate) 12184 { 12185 delegate = decorator ? decorator(BX.delegate(func, thisObject)) : BX.delegate(func, thisObject); 12186 objectDelegates.set(func, delegate); 12187 } 12188 12189 return delegate; 12190 } 12191 12192 BX.once = function(el, evname, func) 12193 { 12194 var fn = function() 12195 { 12196 BX.unbind(el, evname, fn); 12197 func.apply(this, arguments); 12198 }; 12199 12200 return fn; 12201 }; 12202 12203 BX.bindDelegate = function (elem, eventName, isTarget, handler) 12204 { 12205 var h = BX.delegateEvent(isTarget, handler); 12206 BX.bind(elem, eventName, h); 12207 return h; 12208 }; 12209 12210 BX.delegateEvent = function(isTarget, handler) 12211 { 12212 return function(e) 12213 { 12214 e = e || window.event; 12215 var target = e.target || e.srcElement; 12216 12217 while (target != this) 12218 { 12219 if (_checkNode(target, isTarget)) 12220 { 12221 return handler.call(target, e); 12222 } 12223 if (target && target.parentNode) 12224 target = target.parentNode; 12225 else 12226 break; 12227 } 12228 return null; 12229 } 12230 }; 12231 12232 BX.False = function() {return false;}; 12233 BX.DoNothing = function() {}; 12234 12235 // TODO: also check event handlers set via BX.bind() 12236 BX.denyEvent = function(el, ev) 12237 { 12238 deniedEvents.push([el, ev, el['on' + ev]]); 12239 el['on' + ev] = BX.DoNothing; 12240 }; 12241 12242 BX.allowEvent = function(el, ev) 12243 { 12244 for(var i=0, len=deniedEvents.length; i<len; i++) 12245 { 12246 if (deniedEvents[i][0] == el && deniedEvents[i][1] == ev) 12247 { 12248 el['on' + ev] = deniedEvents[i][2]; 12249 BX.util.deleteFromArray(deniedEvents, i); 12250 return; 12251 } 12252 } 12253 }; 12254 12255 BX.fixEventPageXY = function(event) 12256 { 12257 BX.fixEventPageX(event); 12258 BX.fixEventPageY(event); 12259 return event; 12260 }; 12261 12262 BX.fixEventPageX = function(event) 12263 { 12264 if (event.pageX == null && event.clientX != null) 12265 { 12266 event.pageX = 12267 event.clientX + 12268 (document.documentElement && document.documentElement.scrollLeft || document.body && document.body.scrollLeft || 0) - 12269 (document.documentElement.clientLeft || 0); 12270 } 12271 12272 return event; 12273 }; 12274 12275 BX.fixEventPageY = function(event) 12276 { 12277 if (event.pageY == null && event.clientY != null) 12278 { 12279 event.pageY = 12280 event.clientY + 12281 (document.documentElement && document.documentElement.scrollTop || document.body && document.body.scrollTop || 0) - 12282 (document.documentElement.clientTop || 0); 12283 } 12284 12285 return event; 12286 }; 12287 12288 /** 12289 * @deprecated 12290 * @see e.preventDefault() 12291 */ 12292 BX.PreventDefault = function(e) 12293 { 12294 if(!e) e = window.event; 12295 if(e.stopPropagation) 12296 { 12297 e.preventDefault(); 12298 e.stopPropagation(); 12299 } 12300 else 12301 { 12302 e.cancelBubble = true; 12303 e.returnValue = false;
12304 } 12305 return false; 12306 }; 12307 12308 /** 12309 * @deprecated 12310 * @see e.preventDefault(); 12311 * 12312 * @param e 12313 * @return {boolean} 12314 */ 12315 BX.eventReturnFalse = function(e) 12316 { 12317 e=e||window.event; 12318 if (e && e.preventDefault) e.preventDefault(); 12319 else e.returnValue = false; 12320 return false; 12321 }; 12322 12323 /** 12324 * @deprecated 12325 * @see e.stopPropagation() 12326 * @param e 12327 */ 12328 BX.eventCancelBubble = function(e) 12329 { 12330 e=e||window.event; 12331 if(e && e.stopPropagation) 12332 e.stopPropagation(); 12333 else 12334 e.cancelBubble = true; 12335 }; 12336 12337 BX.bindDebouncedChange = function(node, fn, fnInstant, timeout, ctx) 12338 { 12339 ctx = ctx || window; 12340 timeout = timeout || 300; 12341 12342 var dataTag = 'bx-dc-previous-value'; 12343 BX.data(node, dataTag, node.value); 12344 12345 var act = function(fn, val){ 12346 12347 var pVal = BX.data(node, dataTag); 12348 12349 if(typeof pVal == 'undefined' || pVal != val){ 12350 if(typeof ctx != 'object') 12351 fn(val); 12352 else 12353 fn.apply(ctx, [val]); 12354 } 12355 }; 12356 12357 var actD = BX.debounce(function(){ 12358 var val = node.value; 12359 act(fn, val); 12360 BX.data(node, dataTag, val); 12361 }, timeout); 12362 12363 BX.bind(node, 'keyup', actD); 12364 BX.bind(node, 'change', actD); 12365 BX.bind(node, 'input', actD); 12366 12367 if(BX.type.isFunction(fnInstant)){ 12368 12369 var actI = function(){ 12370 act(fnInstant, node.value); 12371 }; 12372 12373 BX.bind(node, 'keyup', actI); 12374 BX.bind(node, 'change', actI); 12375 BX.bind(node, 'input', actI); 12376 } 12377 }; 12378 12379 BX.parseJSON = function(data, context) 12380 { 12381 var result = null; 12382 if (BX.type.isNotEmptyString(data)) 12383 { 12384 try { 12385 if (data.indexOf("\n") >= 0) 12386 eval('result = ' + data); 12387 else 12388 result = (new Function("return " + data))(); 12389 } catch(e) { 12390 BX.onCustomEvent(context, 'onParseJSONFailure', [data, context]) 12391 } 12392 } 12393 else if(BX.type.isPlainObject(data)) 12394 { 12395 return data; 12396 } 12397 12398 return result; 12399 }; 12400 12401 BX.submit = function(obForm, action_name, action_value, onAfterSubmit) 12402 { 12403 action_name = action_name || 'save'; 12404 if (!obForm['BXFormSubmit_' + action_name]) 12405 { 12406 obForm['BXFormSubmit_' + action_name] = obForm.appendChild(BX.create('INPUT', { 12407 'props': { 12408 'type': 'submit', 12409 'name': action_name, 12410 'value': action_value || 'Y' 12411 }, 12412 'style': { 12413 'display': 'none' 12414 } 12415 })); 12416 } 12417 12418 if (obForm.sessid) 12419 obForm.sessid.value = BX.bitrix_sessid(); 12420 12421 setTimeout(BX.delegate(function() {BX.fireEvent(this, 'click'); if (onAfterSubmit) onAfterSubmit();}, obForm['BXFormSubmit_' + action_name]), 10); 12422 }; 12423 12424 BX.show = function(ob, displayType) 12425 { 12426 if (ob.BXDISPLAY || !_checkDisplay(ob, displayType)) 12427 { 12428 ob.style.display = ob.BXDISPLAY; 12429 } 12430 }; 12431 12432 BX.hide = function(ob, displayType) 12433 { 12434 if (!ob.BXDISPLAY) 12435 _checkDisplay(ob, displayType); 12436 12437 ob.style.display = 'none'; 12438 }; 12439 12440 BX.toggle = function(ob, values) 12441 { 12442 if (!values && BX.type.isElementNode(ob)) 12443 { 12444 var bShow = true; 12445 if (ob.BXDISPLAY) 12446 bShow = !_checkDisplay(ob); 12447 else 12448 bShow = ob.style.display == 'none'; 12449 12450 if (bShow) 12451 BX.show(ob); 12452 else 12453 BX.hide(ob); 12454 } 12455 else if (BX.type.isArray(values)) 12456 { 12457 for (var i=0,len=values.length; i<len; i++) 12458 { 12459 if (ob == values[i]) 12460 { 12461 ob = values[i==len-1 ? 0 : i+1]; 12462 break; 12463 } 12464 } 12465 if (i==len) 12466 ob = values[0]; 12467 } 12468 12469 return ob; 12470 }; 12471 12472 function _checkDisplay(ob, displayType) 12473 { 12474 if (typeof displayType != 'undefined') 12475 ob.BXDISPLAY = displayType; 12476 12477 var d = ob.style.display || BX.style(ob, 'display'); 12478 if (d != 'none') 12479 { 12480 ob.BXDISPLAY = ob.BXDISPLAY || d; 12481 return true; 12482 } 12483 else 12484 { 12485 ob.BXDISPLAY = ob.BXDISPLAY || 'block'; 12486 return false; 12487 } 12488 } 12489 12490 /* some useful util functions */ 12491 12492 BX.util = { 12493 /** 12494 * @deprecated 12495 * @use [].filter(value => !BX.Type.isNil(value)) 12496 * @param ar 12497 * @return {*} 12498 */ 12499 array_values: function(ar) 12500 { 12501 if (!BX.type.isArray(ar)) 12502 return BX.util._array_values_ob(ar); 12503 var arv = []; 12504 for(var i=0,l=ar.length;i<l;i++) 12505 if (ar[i] !== null && typeof ar[i] != 'undefined') 12506 arv.push(ar[i]); 12507 return arv; 12508 }, 12509 12510 /** 12511 * @deprecated 12512 * @use Object.values([]).filter(value => !BX.Type.isNil(value)) 12513 * @param ar 12514 * @return {Array} 12515 * @private 12516 */ 12517 _array_values_ob: function(ar) 12518 { 12519 var arv = []; 12520 for(var i in ar) 12521 if (ar[i] !== null && typeof ar[i] != 'undefined') 12522 arv.push(ar[i]); 12523 return arv; 12524 }, 12525 12526 /** 12527 * @deprecated 12528 * @use 12529 * @param ar 12530 * @return {*} 12531 */ 12532 array_keys: function(ar) 12533 { 12534 if (!BX.type.isArray(ar)) 12535 return BX.util._array_keys_ob(ar); 12536 var arv = []; 12537 for(var i=0,l=ar.length;i<l;i++) 12538 if (ar[i] !== null && typeof ar[i] != 'undefined') 12539 arv.push(i); 12540 return arv; 12541 }, 12542 12543 _array_keys_ob: function(ar) 12544 { 12545 var arv = []; 12546 for(var i in ar) 12547 if (ar[i] !== null && typeof ar[i] != 'undefined') 12548 arv.push(i); 12549 return arv; 12550 }, 12551 12552 object_keys: function(obj) 12553 { 12554 var arv = []; 12555 for(var k in obj) 12556 { 12557 if(obj.hasOwnProperty(k)) 12558 { 12559 arv.push(k); 12560 } 12561 } 12562 return arv; 12563 }, 12564 12565 /** 12566 * @deprecated 12567 * @use firstArr.concat(secondArr); 12568 * @param first 12569 * @param second 12570 * @return {*[]} 12571 */ 12572 array_merge: function(first, second) 12573 { 12574 if (!BX.type.isArray(first)) first = []; 12575 if (!BX.type.isArray(second)) second = []; 12576 12577 var i = first.length, j = 0; 12578 12579 if (typeof second.length === "number") 12580 { 12581 for (var l = second.length; j < l; j++) 12582 { 12583 first[i++] = second[j]; 12584 } 12585 } 12586 else 12587 {
12588 while (second[j] !== undefined) 12589 { 12590 first[i++] = second[j++]; 12591 } 12592 } 12593 12594 first.length = i; 12595 12596 return first; 12597 }, 12598 12599 array_flip: function (object) 12600 { 12601 var newObject = {}; 12602 12603 for (var key in object) 12604 { 12605 newObject[object[key]] = key; 12606 } 12607 12608 return newObject; 12609 }, 12610 12611 array_diff: function(ar1, ar2, hash) 12612 { 12613 hash = BX.type.isFunction(hash) ? hash : null; 12614 var i, length, v, h, map = {}, result = []; 12615 for(i = 0, length = ar2.length; i < length; i++) 12616 { 12617 v = ar2[i]; 12618 h = hash ? hash(v) : v; 12619 map[h] = true; 12620 } 12621 12622 for(i = 0, length = ar1.length; i < length; i++) 12623 { 12624 v = ar1[i]; 12625 h = hash ? hash(v) : v; 12626 if(typeof(map[h]) === "undefined") 12627 { 12628 result.push(v); 12629 } 12630 } 12631 return result; 12632 }, 12633 12634 /** 12635 * @deprecated 12636 * @use Set 12637 */ 12638 array_unique: function(ar) 12639 { 12640 var i=0,j,len=ar.length; 12641 if(len<2) return ar; 12642 12643 for (; i<len-1;i++) 12644 { 12645 for (j=i+1; j<len;j++) 12646 { 12647 if (ar[i]==ar[j]) 12648 { 12649 ar.splice(j--,1); len--; 12650 } 12651 } 12652 } 12653 12654 return ar; 12655 }, 12656 12657 /** 12658 * @deprecated 12659 * @use myArr.includes(needle) 12660 */ 12661 in_array: function(needle, haystack) 12662 { 12663 for(var i=0; i<haystack.length; i++) 12664 { 12665 if(haystack[i] == needle) 12666 return true; 12667 } 12668 return false; 12669 }, 12670 12671 /** 12672 * @deprecated 12673 * @use myArr.findIndex(item => item === needle); 12674 */ 12675 array_search: function(needle, haystack) 12676 { 12677 for(var i=0; i<haystack.length; i++) 12678 { 12679 if(haystack[i] == needle) 12680 return i; 12681 } 12682 return -1; 12683 }, 12684 12685 object_search_key: function(needle, haystack) 12686 { 12687 if (typeof haystack[needle] != 'undefined') 12688 return haystack[needle]; 12689 12690 for(var i in haystack) 12691 { 12692 if (typeof haystack[i] == "object") 12693 { 12694 var result = BX.util.object_search_key(needle, haystack[i]); 12695 if (result !== false) 12696 return result; 12697 } 12698 } 12699 return false; 12700 }, 12701 12702 trim: function(s) 12703 { 12704 if (BX.type.isString(s)) 12705 { 12706 return s.trim(); 12707 } 12708 12709 return s; 12710 }, 12711 12712 urlencode: function(s){return encodeURIComponent(s);}, 12713 12714 // it may also be useful. via sVD. 12715 deleteFromArray: function(ar, ind) {return ar.slice(0, ind).concat(ar.slice(ind + 1));}, 12716 insertIntoArray: function(ar, ind, el) {return ar.slice(0, ind).concat([el]).concat(ar.slice(ind));}, 12717 12718 htmlspecialchars: function(str) 12719 { 12720 return BX.Text.encode(str); 12721 }, 12722 12723 htmlspecialcharsback: function(str) 12724 { 12725 return BX.Text.decode(str); 12726 }, 12727 12728 // Quote regular expression characters plus an optional character 12729 preg_quote: function(str, delimiter) 12730 { 12731 if(!str.replace) 12732 return str; 12733 return str.replace(new RegExp('[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + (delimiter || '') + '-]', 'g'), '\\$&'); 12734 }, 12735 12736 jsencode: function(str) 12737 { 12738 if (!str || !str.replace) 12739 return str; 12740 12741 var escapes = 12742 [ 12743 { c: "\\\\", r: "\\\\" }, // should be first 12744 { c: "\\t", r: "\\t" }, 12745 { c: "\\n", r: "\\n" }, 12746 { c: "\\r", r: "\\r" }, 12747 { c: "\"", r: "\\\"" }, 12748 { c: "'", r: "\\'" }, 12749 { c: "<", r: "\\x3C" }, 12750 { c: ">", r: "\\x3E" }, 12751 { c: "\\u2028", r: "\\u2028" }, 12752 { c: "\\u2029", r: "\\u2029" } 12753 ]; 12754 for (var i = 0; i < escapes.length; i++) 12755 str = str.replace(new RegExp(escapes[i].c, 'g'), escapes[i].r); 12756 return str; 12757 }, 12758 12759 getCssName: function(jsName) 12760 { 12761 if (!BX.type.isNotEmptyString(jsName)) 12762 { 12763 return ""; 12764 } 12765 12766 return jsName.replace(/[A-Z]/g, function(match) { 12767 return "-" + match.toLowerCase(); 12768 }); 12769 }, 12770 12771 getJsName: function(cssName) 12772 { 12773 var regex = /\-([a-z]){1}/g; 12774 if (regex.test(cssName)) 12775 { 12776 return cssName.replace(regex, function(match, letter) { 12777 return letter.toUpperCase(); 12778 }); 12779 } 12780 12781 return cssName; 12782 }, 12783 12784 nl2br: function(str) 12785 { 12786 if (!str || !str.replace) 12787 return str; 12788 12789 return str.replace(/([^>])\n/g, '$1<br/>'); 12790 }, 12791 12792 /** 12793 * @deprecated 12794 * @use .padStart() / .padEnd() 12795 * @param input 12796 * @param pad_length 12797 * @param pad_string 12798 * @param pad_type 12799 * @return {*} 12800 */ 12801 str_pad: function(input, pad_length, pad_string, pad_type) 12802 { 12803 pad_string = pad_string || ' '; 12804 pad_type = pad_type || 'right'; 12805 input = input.toString(); 12806 12807 if (pad_type === 'left') 12808 { 12809 return BX.util.str_pad_left(input, pad_length, pad_string); 12810 } 12811 12812 return BX.util.str_pad_right(input, pad_length, pad_string); 12813 }, 12814 12815 str_pad_left: function(input, pad_length, pad_string) 12816 { 12817 return input.toString().padStart(pad_length, pad_string); 12818 }, 12819 12820 str_pad_right: function(input, pad_length, pad_string) 12821 { 12822 return input.toString().padEnd(pad_length, pad_string); 12823 }, 12824 12825 strip_tags: function(str) 12826 { 12827 return str.split(/<[^>]+>/g).join(''); 12828 }, 12829 12830 strip_php_tags: function(str) 12831 { 12832 return str.replace(/<\?(.|[\r\n])*?\?>/g, ''); 12833 }, 12834 12835 popup: function(url, width, height) 12836 { 12837 var w, h; 12838 if(BX.browser.IsOpera()) 12839 { 12840 w = document.body.offsetWidth; 12841 h = document.body.offsetHeight; 12842 } 12843 else 12844 {
12845 w = screen.width; 12846 h = screen.height; 12847 } 12848 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)); 12849 }, 12850 12851 shuffle: function(array) 12852 { 12853 var temporaryValue, randomIndex; 12854 var currentIndex = array.length; 12855 12856 while (0 !== currentIndex) 12857 { 12858 randomIndex = Math.floor(Math.random() * currentIndex); 12859 currentIndex -= 1; 12860 12861 temporaryValue = array[currentIndex]; 12862 array[currentIndex] = array[randomIndex]; 12863 array[randomIndex] = temporaryValue; 12864 } 12865 12866 return array; 12867 }, 12868 12869 // BX.util.objectSort(object, sortBy, sortDir) - Sort object by property 12870 // function params: 1 - object for sort, 2 - sort by property, 3 - sort direction (asc/desc) 12871 // return: sort array [[objectElement], [objectElement]] in sortDir direction 12872 12873 // example: BX.util.objectSort({'L1': {'name': 'Last'}, 'F1': {'name': 'First'}}, 'name', 'asc'); 12874 // return: [{'name' : 'First'}, {'name' : 'Last'}] 12875 objectSort: function(object, sortBy, sortDir) 12876 { 12877 sortDir = sortDir == 'asc'? 'asc': 'desc'; 12878 12879 var arItems = [], i; 12880 for (i in object) 12881 { 12882 if (object.hasOwnProperty(i) && object[i][sortBy]) 12883 { 12884 arItems.push([i, object[i][sortBy]]); 12885 } 12886 } 12887 12888 if (sortDir == 'asc') 12889 { 12890 arItems.sort(function(i, ii) { 12891 var s1, s2; 12892 if (BX.type.isDate(i[1])) 12893 { 12894 s1 = i[1].getTime(); 12895 } 12896 else if (!isNaN(i[1])) 12897 { 12898 s1 = parseInt(i[1]); 12899 } 12900 else 12901 { 12902 s1 = i[1].toString().toLowerCase(); 12903 } 12904 12905 if (BX.type.isDate(ii[1])) 12906 { 12907 s2 = ii[1].getTime(); 12908 } 12909 else if (!isNaN(ii[1])) 12910 { 12911 s2 = parseInt(ii[1]); 12912 } 12913 else 12914 { 12915 s2 = ii[1].toString().toLowerCase(); 12916 } 12917 12918 if (s1 > s2) 12919 return 1; 12920 else if (s1 < s2) 12921 return -1; 12922 else 12923 return 0; 12924 }); 12925 } 12926 else 12927 { 12928 arItems.sort(function(i, ii) { 12929 var s1, s2; 12930 if (BX.type.isDate(i[1])) 12931 { 12932 s1 = i[1].getTime(); 12933 } 12934 else if (!isNaN(i[1])) 12935 { 12936 s1 = parseInt(i[1]); 12937 } 12938 else 12939 { 12940 s1 = i[1].toString().toLowerCase(); 12941 } 12942 12943 if (BX.type.isDate(ii[1])) 12944 { 12945 s2 = ii[1].getTime(); 12946 } 12947 else if (!isNaN(ii[1])) 12948 { 12949 s2 = parseInt(ii[1]); 12950 } 12951 else 12952 { 12953 s2 = ii[1].toString().toLowerCase(); 12954 } 12955 12956 if (s1 < s2) 12957 return 1; 12958 else if (s1 > s2) 12959 return -1; 12960 else 12961 return 0; 12962 }); 12963 } 12964 12965 var arReturnArray = Array(); 12966 for (i = 0; i < arItems.length; i++) 12967 { 12968 arReturnArray.push(object[arItems[i][0]]); 12969 } 12970 12971 return arReturnArray; 12972 }, 12973 12974 objectMerge: function() 12975 { 12976 return BX.mergeEx.apply(window, arguments); 12977 }, 12978 12979 objectClone : function(object) 12980 { 12981 return BX.clone(object, true); 12982 }, 12983 12984 // #fdf9e5 => {r=253, g=249, b=229} 12985 hex2rgb: function(color) 12986 { 12987 var rgb = color.replace(/[# ]/g,"").replace(/^(.)(.)(.)$/,'$1$1$2$2$3$3').match(/.{2}/g); 12988 for (var i=0; i<3; i++) 12989 { 12990 rgb[i] = parseInt(rgb[i], 16); 12991 } 12992 return {'r':rgb[0],'g':rgb[1],'b':rgb[2]}; 12993 }, 12994 12995 /** 12996 * @deprecated 12997 * @use BX.Uri 12998 * @param url 12999 * @param param 13000 * @return {string} 13001 */ 13002 remove_url_param: function(url, param) 13003 { 13004 return BX.Uri.removeParam(url, param); 13005 }, 13006 13007 /* 13008 {'param1': 'value1', 'param2': 'value2'} 13009 */ 13010 /** 13011 * @deprecated 13012 * @use BX.Uri 13013 * @param url 13014 * @param params 13015 * @return {string} 13016 */ 13017 add_url_param: function(url, params) 13018 { 13019 var preparedParams = Object.entries(params).reduce(function(acc, item) { 13020 acc[item[0]] = BX.type.isArray(item[1]) ? item[1].join() : item[1]; 13021 return acc; 13022 }, {}); 13023 13024 return BX.Uri.addParam(url, preparedParams); 13025 }, 13026 13027 /* 13028 {'param1': 'value1', 'param2': 'value2'} 13029 */ 13030 buildQueryString: function(params) 13031 { 13032 var result = ''; 13033 for (var key in params) 13034 { 13035 var value = params[key]; 13036 if(BX.type.isArray(value)) 13037 { 13038 value.forEach(function(valueElement, index) 13039 { 13040 result += encodeURIComponent(key + "[" + index + "]") + "=" + encodeURIComponent(valueElement) + "&"; 13041 }); 13042 } 13043 else 13044 { 13045 result += encodeURIComponent(key) + "=" + encodeURIComponent(value) + "&"; 13046 } 13047 } 13048 13049 if(result.length > 0) 13050 { 13051 result = result.substr(0, result.length - 1); 13052 } 13053 return result; 13054 }, 13055 13056 even: function(digit) 13057 { 13058 return (parseInt(digit) % 2 == 0); 13059 }, 13060 13061 hashCode: function(str) 13062 { 13063 if(!BX.type.isNotEmptyString(str)) 13064 { 13065 return 0; 13066 } 13067 13068 var hash = 0; 13069 for (var i = 0; i < str.length; i++) 13070 { 13071 var c = str.charCodeAt(i); 13072 hash = ((hash << 5) - hash) + c; 13073 hash = hash & hash; 13074 } 13075 return hash; 13076 }, 13077 13078 getRandomString: function (length) 13079 { 13080 return BX.Text.getRandom(length); 13081 }, 13082 13083 number_format: function(number, decimals, dec_point, thousands_sep) 13084 { 13085 var i, j, kw, kd, km, sign = ''; 13086 decimals = Math.abs(decimals); 13087 if (isNaN(decimals) || decimals < 0) 13088 { 13089 decimals = 2; 13090 } 13091 dec_point = dec_point || ','; 13092 if (typeof thousands_sep === 'undefined') 13093 thousands_sep = '.'; 13094 13095 number = (+number || 0).toFixed(decimals); 13096 if (number < 0) 13097 { 13098 sign = '-'; 13099 number = -number; 13100 } 13101 13102 i = parseInt(number, 10) + ''; 13103 j = (i.length > 3 ? i.length % 3 : 0); 13104 13105 km = (j ? i.substr(0, j) + thousands_sep : ''); 13106 kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep); 13107 kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, '0').slice(2) : ''); 13108 13109 return sign + km + kw + kd; 13110 }, 13111 13112 getExtension: function (url) 13113 { 13114 url = url || ""; 13115 var items = url.split("?")[0].split("."); 13116 return items[items.length-1].toLowerCase(); 13117 }, 13118 addObjectToForm: function(object, form, prefix) 13119 { 13120 if(!BX.type.isString(prefix)) 13121 { 13122 prefix = ""; 13123 } 13124 13125 for(var key in object) 13126 { 13127 if(!object.hasOwnProperty(key)) 13128 { 13129 continue; 13130 } 13131 13132 var value = object[key]; 13133 var name = prefix !== "" ? (prefix + "[" + key + "]") : key; 13134 if(BX.type.isArray(value)) 13135 { 13136 var obj = {}; 13137 for(var i = 0; i < value.length; i++) 13138 { 13139 obj[i] = value[i]; 13140 } 13141 13142 BX.util.addObjectToForm(obj, form, name); 13143 } 13144 else if(BX.type.isPlainObject(value)) 13145 { 13146 BX.util.addObjectToForm(value, form, name); 13147 } 13148 else 13149 { 13150 value = BX.type.isFunction(value.toString) ? value.toString() : ""; 13151 if(value !== "") 13152 { 13153 form.appendChild(BX.create("INPUT", { attrs: { type: "hidden", name: name, value: value } })); 13154 } 13155 } 13156 } 13157 }, 13158 13159 observe: function(object, enable) 13160 {
13161 console.error('BX.util.observe: function is no longer supported by browser.'); 13162 return false; 13163 }, 13164 13165 escapeRegExp: function(str) 13166 { 13167 return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); 13168 } 13169 }; 13170 13171 BX.validation = { 13172 checkIfEmail: function(s) 13173 { 13174 var atom = "[=a-z0-9_+~'!$&*^`|#%/?{}-]"; 13175 return (new RegExp('^\\s*'+atom+'+(\\.'+atom+'+)*@([a-z0-9-]+\\.)+[a-z0-9-]{2,20}\\s*$', 'i')).test(s); 13176 }, 13177 checkIfPhone: function(s) 13178 { 13179 var regexp = new RegExp( 13180 typeof(BX.PhoneNumber) === "undefined" 13181 ? BX.PhoneNumber.getValidNumberPattern() 13182 : '^\\s*\\+?\s*[0-9(-)\\s]+\\s*$', 13183 'i' 13184 ); 13185 return regexp.test(s); 13186 } 13187 }; 13188 13189 BX.prop = 13190 { 13191 get: function(object, key, defaultValue) 13192 { 13193 return object && object.hasOwnProperty(key) ? object[key] : defaultValue; 13194 }, 13195 getObject: function(object, key, defaultValue) 13196 { 13197 return object && BX.type.isPlainObject(object[key]) ? object[key] : defaultValue; 13198 }, 13199 getElementNode: function(object, key, defaultValue) 13200 { 13201 return object && BX.type.isElementNode(object[key]) ? object[key] : defaultValue; 13202 }, 13203 getArray: function(object, key, defaultValue) 13204 { 13205 return object && BX.type.isArray(object[key]) ? object[key] : defaultValue; 13206 }, 13207 getFunction: function(object, key, defaultValue) 13208 { 13209 return object && BX.type.isFunction(object[key]) ? object[key] : defaultValue; 13210 }, 13211 getNumber: function(object, key, defaultValue) 13212 { 13213 if(!(object && object.hasOwnProperty(key))) 13214 { 13215 return defaultValue; 13216 } 13217 13218 var value = object[key]; 13219 if(BX.type.isNumber(value)) 13220 { 13221 return value; 13222 } 13223 13224 value = parseFloat(value); 13225 return !isNaN(value) ? value : defaultValue; 13226 }, 13227 getInteger: function(object, key, defaultValue) 13228 { 13229 if(!(object && object.hasOwnProperty(key))) 13230 { 13231 return defaultValue; 13232 } 13233 13234 var value = object[key]; 13235 if(BX.type.isNumber(value)) 13236 { 13237 return value; 13238 } 13239 13240 value = parseInt(value); 13241 return !isNaN(value) ? value : defaultValue; 13242 }, 13243 getBoolean: function(object, key, defaultValue) 13244 { 13245 if(!(object && object.hasOwnProperty(key))) 13246 { 13247 return defaultValue; 13248 } 13249 13250 var value = object[key]; 13251 return (BX.type.isBoolean(value) 13252 ? value 13253 : (BX.type.isString(value) ? (value.toLowerCase() === "true") : !!value) 13254 ); 13255 }, 13256 getString: function(object, key, defaultValue) 13257 { 13258 if(!(object && object.hasOwnProperty(key))) 13259 { 13260 return defaultValue; 13261 } 13262 13263 var value = object[key]; 13264 return BX.type.isString(value) ? value : (value ? value.toString() : ''); 13265 }, 13266 extractDate: function(datetime) 13267 { 13268 if(!BX.type.isDate(datetime)) 13269 { 13270 datetime = new Date(); 13271 } 13272 13273 datetime.setHours(0); 13274 datetime.setMinutes(0); 13275 datetime.setSeconds(0); 13276 datetime.setMilliseconds(0); 13277 13278 return datetime; 13279 } 13280 }; 13281 13282 BX.isNodeInDom = function(node, doc) 13283 { 13284 return node === (doc || document) ? true : 13285 (node.parentNode ? BX.isNodeInDom(node.parentNode) : false); 13286 }; 13287 13288 BX.isNodeHidden = function(node) 13289 { 13290 if (node === document) 13291 return false; 13292 else if (BX.style(node, 'display') == 'none') 13293 return true; 13294 else 13295 return (node.parentNode ? BX.isNodeHidden(node.parentNode) : true); 13296 }; 13297 13298 BX.evalPack = function(code) 13299 { 13300 while (code.length > 0) 13301 { 13302 var c = code.shift(); 13303 13304 if (c.TYPE == 'SCRIPT_EXT' || c.TYPE == 'SCRIPT_SRC') 13305 { 13306 BX.loadScript(c.DATA, function() {BX.evalPack(code)}); 13307 return; 13308 } 13309 else if (c.TYPE == 'SCRIPT') 13310 { 13311 BX.evalGlobal(c.DATA); 13312 } 13313 } 13314 }; 13315 13316 BX.evalGlobal = function(data) 13317 { 13318 if (data) 13319 { 13320 var head = document.getElementsByTagName("head")[0] || document.documentElement, 13321 script = document.createElement("script"); 13322 13323 script.type = "text/javascript"; 13324 13325 if (!BX.browser.IsIE()) 13326 { 13327 script.appendChild(document.createTextNode(data)); 13328 } 13329 else 13330 { 13331 script.text = data; 13332 } 13333 13334 head.insertBefore(script, head.firstChild); 13335 head.removeChild(script); 13336 } 13337 }; 13338 13339 BX.garbage = function(call, thisObject) 13340 { 13341 garbageCollectors.push({callback: call, context: thisObject}); 13342 }; 13343 13344 BX.GetDocElement = function (pDoc) 13345 { 13346 pDoc = pDoc || document; 13347 return (BX.browser.IsDoctype(pDoc) ? pDoc.documentElement : pDoc.body); 13348 }; 13349 13350 BX.scrollTop = function(node, val){ 13351 if(typeof val != 'undefined'){ 13352 13353 if(node == window){ 13354 throw new Error('scrollTop() for window is not implemented'); 13355 }else 13356 node.scrollTop = parseInt(val); 13357 13358 }else{ 13359 13360 if(node == window) 13361 return BX.GetWindowScrollPos().scrollTop; 13362 13363 return node.scrollTop; 13364 } 13365 }; 13366 13367 BX.scrollLeft = function(node, val){ 13368 if(typeof val != 'undefined'){ 13369 13370 if(node == window){ 13371 throw new Error('scrollLeft() for window is not implemented'); 13372 }else 13373 node.scrollLeft = parseInt(val); 13374 13375 }else{ 13376 13377 if(node == window) 13378 return BX.GetWindowScrollPos().scrollLeft; 13379 13380 return node.scrollLeft; 13381 } 13382 }; 13383 13384 BX.hide_object = function(ob) 13385 { 13386 ob = BX(ob); 13387 ob.style.position = 'absolute'; 13388 ob.style.top = '-1000px'; 13389 ob.style.left = '-1000px'; 13390 ob.style.height = '10px'; 13391 ob.style.width = '10px'; 13392 }; 13393 13394 BX.is_relative = function(el) 13395 { 13396 var p = BX.style(el, 'position'); 13397 return p == 'relative' || p == 'absolute'; 13398 }; 13399 13400 BX.is_float = function(el) 13401 { 13402 var p = BX.style(el, 'float'); 13403 return p == 'right' || p == 'left'; 13404 }; 13405 13406 BX.is_fixed = function(el) 13407 { 13408 var p = BX.style(el, 'position'); 13409 return p == 'fixed'; 13410 }; 13411 13412 BX.width = function(node, val){ 13413 if(typeof val != 'undefined') 13414 BX.style(node, 'width', parseInt(val)+'px'); 13415 else{ 13416 13417 if(node == window) 13418 return window.innerWidth; 13419 13420 //return parseInt(BX.style(node, 'width')); 13421 return BX.pos(node).width; 13422 } 13423 }; 13424 13425 BX.height = function(node, val){ 13426 if(typeof val != 'undefined') 13427 BX.style(node, 'height', parseInt(val)+'px'); 13428 else{ 13429 13430 if(node == window) 13431 return window.innerHeight; 13432 13433 //return parseInt(BX.style(node, 'height')); 13434 return BX.pos(node).height; 13435 } 13436 }; 13437 13438 BX.align = function(pos, w, h, type) 13439 { 13440 if (type) 13441 type = type.toLowerCase(); 13442 else 13443 type = ''; 13444 13445 var pDoc = document; 13446 if (BX.type.isElementNode(pos)) 13447 { 13448 pDoc = pos.ownerDocument; 13449 pos = BX.pos(pos); 13450 } 13451 13452 var x = pos["left"], y = pos["bottom"]; 13453 13454 var scroll = BX.GetWindowScrollPos(pDoc); 13455 var size = BX.GetWindowInnerSize(pDoc); 13456 13457 if((size.innerWidth + scroll.scrollLeft) - (pos["left"] + w) < 0) 13458 { 13459 if(pos["right"] - w >= 0 ) 13460 x = pos["right"] - w; 13461 else 13462 x = scroll.scrollLeft; 13463 } 13464
13465 if(((size.innerHeight + scroll.scrollTop) - (pos["bottom"] + h) < 0) || ~type.indexOf('top')) 13466 { 13467 if(pos["top"] - h >= 0 || ~type.indexOf('top')) 13468 y = pos["top"] - h; 13469 else 13470 y = scroll.scrollTop; 13471 } 13472 13473 return {'left':x, 'top':y}; 13474 }; 13475 13476 BX.scrollToNode = function(node) 13477 { 13478 var obNode = BX(node); 13479 13480 if (obNode.scrollIntoView) 13481 obNode.scrollIntoView(true); 13482 else 13483 { 13484 var arNodePos = BX.pos(obNode); 13485 window.scrollTo(arNodePos.left, arNodePos.top); 13486 } 13487 }; 13488 13489 /* non-xhr loadings */ 13490 BX.showWait = function(node, msg) 13491 { 13492 node = BX(node) || document.body || document.documentElement; 13493 msg = msg || BX.message('JS_CORE_LOADING'); 13494 13495 var container_id = node.id || Math.random(); 13496 13497 var obMsg = node.bxmsg = document.body.appendChild(BX.create('DIV', { 13498 props: { 13499 id: 'wait_' + container_id 13500 }, 13501 style: { 13502 background: 'url("/bitrix/js/main/core/images/wait.gif") no-repeat scroll 10px center #fcf7d1', 13503 border: '1px solid #E1B52D', 13504 color: 'black', 13505 fontFamily: 'Verdana,Arial,sans-serif', 13506 fontSize: '11px', 13507 padding: '10px 30px 10px 37px', 13508 position: 'absolute', 13509 textAlign:'center' 13510 }, 13511 text: msg 13512 })); 13513 13514 BX.ZIndexManager.register(obMsg); 13515 BX.ZIndexManager.bringToFront(obMsg); 13516 13517 setTimeout(BX.delegate(_adjustWait, node), 10); 13518 13519 lastWait[lastWait.length] = obMsg; 13520 return obMsg; 13521 }; 13522 13523 BX.closeWait = function(node, obMsg) 13524 { 13525 if(node && !obMsg) 13526 obMsg = node.bxmsg; 13527 if(node && !obMsg && BX.hasClass(node, 'bx-core-waitwindow')) 13528 obMsg = node; 13529 if(node && !obMsg) 13530 obMsg = BX('wait_' + node.id); 13531 if(!obMsg) 13532 obMsg = lastWait.pop(); 13533 13534 if (obMsg && obMsg.parentNode) 13535 { 13536 for (var i=0,len=lastWait.length;i<len;i++) 13537 { 13538 if (obMsg == lastWait[i]) 13539 { 13540 lastWait = BX.util.deleteFromArray(lastWait, i); 13541 break; 13542 } 13543 } 13544 13545 BX.ZIndexManager.unregister(obMsg); 13546 obMsg.parentNode.removeChild(obMsg); 13547 if (node) node.bxmsg = null; 13548 BX.cleanNode(obMsg, true); 13549 } 13550 }; 13551 13552 BX.setJSList = function(scripts) 13553 { 13554 if (BX.type.isArray(scripts)) 13555 { 13556 scripts = scripts.map(function(script) { 13557 return normalizeUrl(script) 13558 }); 13559 13560 jsList = jsList.concat(scripts); 13561 } 13562 }; 13563 13564 BX.getJSList = function() 13565 { 13566 initJsList(); 13567 return jsList; 13568 }; 13569 13570 BX.setCSSList = function(cssFiles) 13571 { 13572 if (BX.type.isArray(cssFiles)) 13573 { 13574 cssFiles = cssFiles.map(function(cssFile) { 13575 return normalizeUrl(cssFile); 13576 }); 13577 13578 cssList = cssList.concat(cssFiles); 13579 } 13580 }; 13581 13582 BX.getCSSList = function() 13583 { 13584 initCssList(); 13585 return cssList; 13586 }; 13587 13588 BX.getJSPath = function(js) 13589 { 13590 return js.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 13591 }; 13592 13593 BX.getCSSPath = function(css) 13594 { 13595 return css.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 13596 }; 13597 13598 BX.getCDNPath = function(path) 13599 { 13600 return path; 13601 }; 13602 13603 BX.loadScript = function(script, callback, doc) 13604 { 13605 if (BX.type.isString(script)) 13606 { 13607 script = [script]; 13608 } 13609 13610 return BX.load(script, callback, doc); 13611 }; 13612 13613 BX.loadCSS = function(css, doc, win) 13614 { 13615 if (BX.type.isString(css)) 13616 { 13617 css = [css]; 13618 } 13619 13620 if (BX.type.isArray(css)) 13621 { 13622 css = css.map(function(url) { 13623 return { url: url, ext: "css" } 13624 }); 13625 13626 BX.load(css, null, doc); 13627 } 13628 }; 13629 13630 const LOADING = 3; 13631 const LOADED = 4; 13632 const assets = {}; 13633 const loadingAssetCallbacks = {}; 13634 13635 BX.load = function(items, callback, doc) 13636 { 13637 if (!BX.isReady) 13638 { 13639 var _args = arguments; 13640 BX.ready(function() { 13641 BX.load.apply(this, _args); 13642 }); 13643 13644 return null; 13645 } 13646 13647 doc = doc || document; 13648 13649 callback = BX.Type.isFunction(callback) ? callback : () => {}; 13650 13651 return loadAsync(items, callback, doc); 13652 }; 13653 13654 function loadAsync(items, callback, doc) 13655 { 13656 if (!BX.type.isArray(items)) 13657 { 13658 callback(); 13659 13660 return; 13661 } 13662 13663 function onLoad() 13664 { 13665 const nextAsset = queue.shift(); 13666 if (nextAsset) 13667 { 13668 load(nextAsset, onLoad, doc); 13669 } 13670 else if (allLoaded()) 13671 { 13672 callback(); 13673 } 13674 } 13675 13676 function allLoaded() 13677 { 13678 for (const name in assetMap) 13679 { 13680 if (assetMap[name].state !== LOADED) 13681 { 13682 return false; 13683 } 13684 } 13685 13686 return true; 13687 } 13688 13689 const queue = []; 13690 const assetMap = {}; 13691 items.forEach(item => { 13692 const asset = getAsset(item); 13693 if (asset && asset.state !== LOADED) 13694 { 13695 queue.push(asset); 13696 assetMap[asset.name] = asset; 13697 } 13698 }); 13699 13700 if (queue.length > 0) 13701 {
13702 const maxParallelLoads = 6; 13703 const parallelLoads = Math.min(queue.length, maxParallelLoads); 13704 const firstPackage = queue.splice(0, parallelLoads); 13705 firstPackage.forEach(asset => { 13706 load(asset, onLoad, doc); 13707 }); 13708 } 13709 else 13710 { 13711 callback(); 13712 } 13713 } 13714 13715 function load(asset, callback, doc) 13716 { 13717 callback = callback || BX.DoNothing; 13718 13719 if (asset.state === LOADED) 13720 { 13721 callback(); 13722 return; 13723 } 13724 13725 if (asset.state === LOADING) 13726 { 13727 if (!BX.Type.isArray(loadingAssetCallbacks[asset.name])) 13728 { 13729 loadingAssetCallbacks[asset.name] = []; 13730 } 13731 13732 loadingAssetCallbacks[asset.name].push(callback); 13733 13734 return; 13735 } 13736 13737 asset.state = LOADING; 13738 13739 loadAsset( 13740 asset, 13741 function () { 13742 asset.state = LOADED; 13743 callback(); 13744 if (BX.Type.isArrayFilled(loadingAssetCallbacks[asset.name])) 13745 { 13746 for (const cb of loadingAssetCallbacks[asset.name]) 13747 { 13748 cb(); 13749 } 13750 } 13751 13752 delete loadingAssetCallbacks[asset.name]; 13753 }, 13754 doc 13755 ); 13756 } 13757 13758 function loadAsset(asset, callback, doc) 13759 { 13760 callback = callback || BX.DoNothing; 13761 13762 function error(event) 13763 { 13764 window.clearTimeout(asset.errorTimeout); 13765 window.clearTimeout(asset.cssTimeout); 13766 ele.onload = ele.onreadystatechange = ele.onerror = null; 13767 callback(); 13768 } 13769 13770 function process(event) 13771 { 13772 event = event || window.event; 13773 if (event.type === "load" || (/loaded|complete/.test(ele.readyState) && (!doc.documentMode || doc.documentMode < 9))) 13774 { 13775 window.clearTimeout(asset.errorTimeout); 13776 window.clearTimeout(asset.cssTimeout); 13777 ele.onload = ele.onreadystatechange = ele.onerror = null; 13778 callback(); 13779 } 13780 } 13781 13782 function isCssLoaded() 13783 { 13784 if (asset.state !== LOADED && asset.cssRetries <= 20) 13785 { 13786 for (var i = 0, l = doc.styleSheets.length; i < l; i++) 13787 { 13788 if (doc.styleSheets[i].href === ele.href) 13789 { 13790 process({"type": "load"}); 13791 return; 13792 } 13793 } 13794 13795 asset.cssRetries++; 13796 asset.cssTimeout = window.setTimeout(isCssLoaded, 250); 13797 } 13798 } 13799 13800 let ele = null; 13801 const ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 13802 13803 if (ext === "css") 13804 { 13805 ele = doc.createElement("link"); 13806 ele.type = "text/" + (asset.type || "css"); 13807 ele.rel = "stylesheet"; 13808 ele.href = asset.url; 13809 13810 asset.cssRetries = 0; 13811 asset.cssTimeout = window.setTimeout(isCssLoaded, 500); 13812 } 13813 else 13814 { 13815 ele = doc.createElement("script"); 13816 ele.type = "text/" + (asset.type || "javascript"); 13817 ele.src = asset.url; 13818 } 13819 13820 ele.onload = ele.onreadystatechange = process; 13821 ele.onerror = error; 13822 13823 ele.async = false; 13824 ele.defer = false; 13825 13826 asset.errorTimeout = window.setTimeout(function () { 13827 error({type: "timeout"}); 13828 }, 7000); 13829 13830 if (ext === "css") 13831 { 13832 cssList.push(normalizeMinUrl(normalizeUrl(asset.url))); 13833 } 13834 else 13835 { 13836 jsList.push(normalizeMinUrl(normalizeUrl(asset.url))); 13837 } 13838 13839 let templateLink = null; 13840 const head = doc.head || doc.getElementsByTagName("head")[0]; 13841 if (ext === "css" && (templateLink = getTemplateLink(head)) !== null) 13842 { 13843 templateLink.parentNode.insertBefore(ele, templateLink); 13844 } 13845 else 13846 { 13847 head.insertBefore(ele, head.lastChild); 13848 } 13849 } 13850 13851 function getAsset(item) 13852 { 13853 var asset = {}; 13854 if (typeof item === "object") 13855 { 13856 asset = item; 13857 asset.name = asset.name ? asset.name : BX.util.hashCode(item.url); 13858 } 13859 else 13860 { 13861 asset = { name: BX.util.hashCode(item), url : item }; 13862 } 13863 13864 var ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 13865 if ((ext === "css" && isCssLoaded(asset.url)) || isScriptLoaded(asset.url)) 13866 { 13867 asset.state = LOADED; 13868 } 13869 13870 var existing = assets[asset.name]; 13871 if (existing && existing.url === asset.url) 13872 { 13873 return existing; 13874 } 13875 13876 assets[asset.name] = asset; 13877 13878 return asset; 13879 } 13880 13881 function normalizeUrl(url) 13882 { 13883 if (!BX.type.isNotEmptyString(url)) 13884 { 13885 return ""; 13886 } 13887 13888 url = BX.getJSPath(url); 13889 url = url.replace(/\?[0-9]*$/, ""); 13890 13891 return url; 13892 } 13893 13894 function normalizeMinUrl(url) 13895 { 13896 if (!BX.type.isNotEmptyString(url)) 13897 { 13898 return ""; 13899 } 13900 13901 var minPos = url.indexOf(".min"); 13902 return minPos >= 0 ? url.substr(0, minPos) + url.substr(minPos + 4) : url; 13903 } 13904 13905 function isCssLoaded(fileSrc) 13906 { 13907 initCssList(); 13908 13909 fileSrc = normalizeUrl(fileSrc); 13910 var fileSrcMin = normalizeMinUrl(fileSrc); 13911 13912 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, cssList)) || BX.util.in_array(fileSrc, cssList); 13913 } 13914 13915 function initCssList() 13916 { 13917 if(!cssInit) 13918 { 13919 var linksCol = document.getElementsByTagName('link'); 13920 13921 if(!!linksCol && linksCol.length > 0) 13922 { 13923 for(var i = 0; i < linksCol.length; i++) 13924 { 13925 var href = linksCol[i].getAttribute('href'); 13926 if (BX.type.isNotEmptyString(href)) 13927 { 13928 href = normalizeMinUrl(normalizeUrl(href)); 13929 cssList.push(href); 13930 } 13931 } 13932 } 13933 cssInit = true; 13934 } 13935 } 13936 13937 function getTemplateLink(head) 13938 { 13939 var findLink = function(tag) 13940 { 13941 var links = head.getElementsByTagName(tag); 13942 for (var i = 0, length = links.length; i < length; i++) 13943 { 13944 var templateStyle = links[i].getAttribute("data-template-style"); 13945 if (BX.type.isNotEmptyString(templateStyle) && templateStyle == "true") 13946 { 13947 return links[i]; 13948 } 13949 } 13950 13951 return null; 13952 }; 13953 13954 var link = findLink("link"); 13955 if (link === null) 13956 { 13957 link = findLink("style"); 13958 } 13959 13960 return link; 13961 } 13962 13963 function isScriptLoaded(fileSrc) 13964 { 13965 initJsList(); 13966 13967 fileSrc = normalizeUrl(fileSrc); 13968 var fileSrcMin = normalizeMinUrl(fileSrc); 13969 13970 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, jsList)) || BX.util.in_array(fileSrc, jsList); 13971 } 13972 13973 function initJsList() 13974 { 13975 if(!jsInit) 13976 { 13977 var scriptCol = document.getElementsByTagName('script'); 13978 13979 if(!!scriptCol && scriptCol.length > 0) 13980 { 13981 for(var i=0; i<scriptCol.length; i++) 13982 { 13983 var src = scriptCol[i].getAttribute('src'); 13984 13985 if (BX.type.isNotEmptyString(src)) 13986 { 13987 src = normalizeMinUrl(normalizeUrl(src)); 13988 jsList.push(src); 13989 } 13990 } 13991 } 13992 jsInit = true; 13993 } 13994 } 13995 13996 function reloadInternal(back_url, bAddClearCache) 13997 { 13998 if (back_url === true) 13999 { 14000 bAddClearCache = true; 14001 back_url = null; 14002 } 14003 14004 var topWindow = (function() { 14005 if (BX.PageObject && BX.PageObject.getRootWindow) 14006 { 14007 return BX.PageObject.getRootWindow(); 14008 } 14009 14010 return window.top; 14011 })(); 14012 var new_href = back_url || topWindow.location.href; 14013 14014 var hashpos = new_href.indexOf('#'), hash = ''; 14015 14016 if (hashpos != -1) 14017 { 14018 hash = new_href.substr(hashpos); 14019 new_href = new_href.substr(0, hashpos); 14020 } 14021 14022 if (bAddClearCache && new_href.indexOf('clear_cache=Y') < 0) 14023 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + 'clear_cache=Y'; 14024 14025 if (hash) 14026 { 14027 // hack for clearing cache in ajax mode components with history emulation 14028 if (bAddClearCache && (hash.substr(0, 5) == 'view/' || hash.substr(0, 6) == '#view/') && hash.indexOf('clear_cache%3DY') < 0) 14029 hash += (hash.indexOf('%3F') == -1 ? '%3F' : '%26') + 'clear_cache%3DY'; 14030 14031 new_href = new_href.replace(/(\?|\&)_r=[\d]*/, ''); 14032 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + '_r='+Math.round(Math.random()*10000) + hash; 14033 } 14034 14035 topWindow.location.href = new_href; 14036 } 14037 14038 BX.reload = function(back_url, bAddClearCache) 14039 { 14040 if (window !== window.top) 14041 { 14042 BX.Runtime 14043 .loadExtension('main.pageobject') 14044 .then(function() { 14045 reloadInternal(back_url, bAddClearCache); 14046 }); 14047 } 14048 else 14049 { 14050 reloadInternal(back_url, bAddClearCache); 14051 } 14052 }; 14053 14054 BX.clearCache = function() 14055 { 14056 BX.showWait(); 14057 BX.reload(true); 14058 }; 14059 14060 BX.template = function(tpl, callback, bKillTpl) 14061 { 14062 BX.ready(function() { 14063 _processTpl(BX(tpl), callback, bKillTpl); 14064 }); 14065 }; 14066 14067 BX.isAmPmMode = function(returnConst) 14068 { 14069 if (returnConst === true) 14070 { 14071 return BX.message.AMPM_MODE; 14072 } 14073 return BX.message.AMPM_MODE !== false; 14074 }; 14075 14076 BX.formatDate = function(date, format) 14077 { 14078 date = date || new Date(); 14079 14080 var bTime = date.getHours() || date.getMinutes() || date.getSeconds(), 14081 str = !!format 14082 ? format : 14083 (bTime ? BX.message('FORMAT_DATETIME') : BX.message('FORMAT_DATE') 14084 ); 14085 14086 return str.replace(/YYYY/ig, date.getFullYear()) 14087 .replace(/MMMM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14088 .replace(/MM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14089 .replace(/DD/ig, BX.util.str_pad_left(date.getDate().toString(), 2, '0')) 14090 .replace(/HH/ig, BX.util.str_pad_left(date.getHours().toString(), 2, '0')) 14091 .replace(/MI/ig, BX.util.str_pad_left(date.getMinutes().toString(), 2, '0')) 14092 .replace(/SS/ig, BX.util.str_pad_left(date.getSeconds().toString(), 2, '0')); 14093 }; 14094 BX.formatName = function(user, template, login) 14095 { 14096 user = user || {}; 14097 template = (template || ''); 14098 var replacement = { 14099 TITLE : (user["TITLE"] || ''), 14100 NAME : (user["NAME"] || ''),
14101 LAST_NAME : (user["LAST_NAME"] || ''), 14102 SECOND_NAME : (user["SECOND_NAME"] || ''), 14103 LOGIN : (user["LOGIN"] || ''), 14104 NAME_SHORT : user["NAME"] ? user["NAME"].substr(0, 1) + '.' : '', 14105 LAST_NAME_SHORT : user["LAST_NAME"] ? user["LAST_NAME"].substr(0, 1) + '.' : '', 14106 SECOND_NAME_SHORT : user["SECOND_NAME"] ? user["SECOND_NAME"].substr(0, 1) + '.' : '', 14107 EMAIL : (user["EMAIL"] || ''), 14108 ID : (user["ID"] || ''), 14109 NOBR : "", 14110 '/NOBR' : "" 14111 }, result = template; 14112 for (var ii in replacement) 14113 { 14114 if (replacement.hasOwnProperty(ii)) 14115 { 14116 result = result.replace("#" + ii+ "#", replacement[ii]) 14117 } 14118 } 14119 result = result.replace(/([\s]+)/gi, " ").trim(); 14120 if (result == "") 14121 { 14122 result = (login == "Y" ? replacement["LOGIN"] : ""); 14123 result = (result == "" ? "Noname" : result); 14124 } 14125 return result; 14126 }; 14127 14128 BX.getNumMonth = function(month) 14129 { 14130 var wordMonthCut = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; 14131 var wordMonth = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']; 14132 14133 var q = month.toUpperCase(); 14134 for (i = 1; i <= 12; i++) 14135 { 14136 if (q == BX.message('MON_'+i).toUpperCase() || q == BX.message('MONTH_'+i).toUpperCase() || q == wordMonthCut[i-1].toUpperCase() || q == wordMonth[i-1].toUpperCase()) 14137 { 14138 return i; 14139 } 14140 } 14141 return month; 14142 }; 14143 14144 BX.parseDate = function(str, bUTC, formatDate, formatDatetime) 14145 { 14146 if (BX.type.isNotEmptyString(str)) 14147 { 14148 if (!formatDate) 14149 formatDate = BX.message('FORMAT_DATE'); 14150 if (!formatDatetime) 14151 formatDatetime = BX.message('FORMAT_DATETIME'); 14152 14153 var regMonths = ''; 14154 for (i = 1; i <= 12; i++) 14155 { 14156 regMonths = regMonths + '|' + BX.message('MON_'+i); 14157 } 14158
14159 var expr = new RegExp('([0-9]+|[a-z]+' + regMonths + ')', 'ig'); 14160 var aDate = str.match(expr), 14161 aFormat = formatDate.match(/(DD|MI|MMMM|MM|M|YYYY)/ig), 14162 i, cnt, 14163 aDateArgs=[], aFormatArgs=[], 14164 aResult={}; 14165 14166 if (!aDate) 14167 return null; 14168 14169 if(aDate.length > aFormat.length) 14170 { 14171 aFormat = formatDatetime.match(/(DD|MI|MMMM|MM|M|YYYY|HH|H|SS|TT|T|GG|G)/ig); 14172 } 14173 14174 for(i = 0, cnt = aDate.length; i < cnt; i++) 14175 { 14176 if(BX.util.trim(aDate[i]) != '') 14177 { 14178 aDateArgs[aDateArgs.length] = aDate[i]; 14179 } 14180 } 14181 14182 for(i = 0, cnt = aFormat.length; i < cnt; i++) 14183 { 14184 if(BX.util.trim(aFormat[i]) != '') 14185 { 14186 aFormatArgs[aFormatArgs.length] = aFormat[i]; 14187 } 14188 } 14189 14190 14191 var m = BX.util.array_search('MMMM', aFormatArgs); 14192 if (m > 0) 14193 { 14194 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 14195 aFormatArgs[m] = "MM"; 14196 } 14197 else 14198 { 14199 m = BX.util.array_search('M', aFormatArgs); 14200 if (m > 0) 14201 { 14202 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 14203 aFormatArgs[m] = "MM"; 14204 } 14205 } 14206 14207 for(i = 0, cnt = aFormatArgs.length; i < cnt; i++) 14208 { 14209 var k = aFormatArgs[i].toUpperCase(); 14210 aResult[k] = k == 'T' || k == 'TT' ? aDateArgs[i] : parseInt(aDateArgs[i], 10); 14211 } 14212 14213 if(aResult['DD'] > 0 && aResult['MM'] > 0 && aResult['YYYY'] > 0) 14214 { 14215 var d = new Date(); 14216 14217 if(bUTC) 14218 { 14219 d.setUTCDate(1); 14220 d.setUTCFullYear(aResult['YYYY']); 14221 d.setUTCMonth(aResult['MM'] - 1); 14222 d.setUTCDate(aResult['DD']); 14223 d.setUTCHours(0, 0, 0, 0); 14224 } 14225 else 14226 { 14227 d.setDate(1); 14228 d.setFullYear(aResult['YYYY']); 14229 d.setMonth(aResult['MM'] - 1); 14230 d.setDate(aResult['DD']); 14231 d.setHours(0, 0, 0, 0); 14232 } 14233 14234 if( 14235 (!isNaN(aResult['HH']) || !isNaN(aResult['GG']) || !isNaN(aResult['H']) || !isNaN(aResult['G'])) 14236 && !isNaN(aResult['MI']) 14237 ) 14238 { 14239 if (!isNaN(aResult['H']) || !isNaN(aResult['G'])) 14240 { 14241 var bPM = (aResult['T']||aResult['TT']||'am').toUpperCase()=='PM'; 14242 var h = parseInt(aResult['H']||aResult['G']||0, 10); 14243 if(bPM) 14244 { 14245 aResult['HH'] = h + (h == 12 ? 0 : 12); 14246 } 14247 else 14248 { 14249 aResult['HH'] = h < 12 ? h : 0; 14250 } 14251 } 14252 else 14253 { 14254 aResult['HH'] = parseInt(aResult['HH']||aResult['GG']||0, 10); 14255 } 14256 14257 if (isNaN(aResult['SS'])) 14258 aResult['SS'] = 0; 14259 14260 if(bUTC) 14261 { 14262 d.setUTCHours(aResult['HH'], aResult['MI'], aResult['SS']); 14263 } 14264 else 14265 { 14266 d.setHours(aResult['HH'], aResult['MI'], aResult['SS']); 14267 } 14268 } 14269 14270 return d; 14271 } 14272 } 14273 14274 return null; 14275 }; 14276 14277 BX.selectUtils = 14278 { 14279 addNewOption: function(oSelect, opt_value, opt_name, do_sort, check_unique) 14280 { 14281 oSelect = BX(oSelect); 14282 if(oSelect) 14283 { 14284 var n = oSelect.length; 14285 if(check_unique !== false) 14286 { 14287 for(var i=0;i<n;i++) 14288 { 14289 if(oSelect[i].value==opt_value) 14290 { 14291 return; 14292 } 14293 } 14294 } 14295 14296 oSelect.options[n] = new Option(opt_name, opt_value, false, false); 14297 } 14298 14299 if(do_sort === true) 14300 { 14301 this.sortSelect(oSelect); 14302 } 14303 }, 14304 14305 deleteOption: function(oSelect, opt_value) 14306 { 14307 oSelect = BX(oSelect); 14308 if(oSelect) 14309 { 14310 for(var i=0;i<oSelect.length;i++) 14311 { 14312 if(oSelect[i].value==opt_value) 14313 { 14314 oSelect.remove(i); 14315 break; 14316 } 14317 } 14318 } 14319 }, 14320 14321 deleteSelectedOptions: function(oSelect) 14322 { 14323 oSelect = BX(oSelect); 14324 if(oSelect) 14325 { 14326 var i=0; 14327 while(i<oSelect.length) 14328 { 14329 if(oSelect[i].selected) 14330 { 14331 oSelect[i].selected=false; 14332 oSelect.remove(i); 14333 } 14334 else 14335 { 14336 i++; 14337 } 14338 } 14339 } 14340 }, 14341 14342 deleteAllOptions: function(oSelect) 14343 { 14344 oSelect = BX(oSelect); 14345 if(oSelect) 14346 { 14347 for(var i=oSelect.length-1; i>=0; i--) 14348 { 14349 oSelect.remove(i); 14350 } 14351 } 14352 }, 14353 14354 optionCompare: function(record1, record2) 14355 { 14356 var value1 = record1.optText.toLowerCase(); 14357 var value2 = record2.optText.toLowerCase(); 14358 if (value1 > value2) return(1); 14359 if (value1 < value2) return(-1); 14360 return(0); 14361 }, 14362 14363 sortSelect: function(oSelect) 14364 { 14365 oSelect = BX(oSelect); 14366 if(oSelect) 14367 { 14368 var myOptions = []; 14369 var n = oSelect.options.length; 14370 var i; 14371 for (i=0;i<n;i++) 14372 { 14373 myOptions[i] = { 14374 optText:oSelect[i].text, 14375 optValue:oSelect[i].value 14376 }; 14377 } 14378 myOptions.sort(this.optionCompare); 14379 oSelect.length=0; 14380 n = myOptions.length; 14381 for(i=0;i<n;i++) 14382 { 14383 oSelect[i] = new Option(myOptions[i].optText, myOptions[i].optValue, false, false); 14384 } 14385 } 14386 }, 14387 14388 selectAllOptions: function(oSelect) 14389 { 14390 oSelect = BX(oSelect); 14391 if(oSelect) 14392 { 14393 var n = oSelect.length; 14394 for(var i=0;i<n;i++) 14395 { 14396 oSelect[i].selected=true; 14397 } 14398 } 14399 }, 14400 14401 selectOption: function(oSelect, opt_value) 14402 { 14403 oSelect = BX(oSelect); 14404 if(oSelect) 14405 { 14406 var n = oSelect.length; 14407 for(var i=0;i<n;i++) 14408 { 14409 oSelect[i].selected = (oSelect[i].value == opt_value); 14410 } 14411 } 14412 }, 14413 14414 addSelectedOptions: function(oSelect, to_select_id, check_unique, do_sort) 14415 { 14416 oSelect = BX(oSelect); 14417 if(!oSelect) 14418 return; 14419 var n = oSelect.length; 14420 for(var i=0; i<n; i++) 14421 if(oSelect[i].selected) 14422 this.addNewOption(to_select_id, oSelect[i].value, oSelect[i].text, do_sort, check_unique); 14423 }, 14424 14425 moveOptionsUp: function(oSelect) 14426 { 14427 oSelect = BX(oSelect); 14428 if(!oSelect) 14429 return; 14430 var n = oSelect.length; 14431 for(var i=0; i<n; i++) 14432 { 14433 if(oSelect[i].selected && i>0 && oSelect[i-1].selected == false) 14434 { 14435 var option = new Option(oSelect[i].text, oSelect[i].value); 14436 oSelect[i] = new Option(oSelect[i-1].text, oSelect[i-1].value); 14437 oSelect[i].selected = false;
14438 oSelect[i-1] = option; 14439 oSelect[i-1].selected = true; 14440 } 14441 } 14442 }, 14443 14444 moveOptionsDown: function(oSelect) 14445 { 14446 oSelect = BX(oSelect); 14447 if(!oSelect) 14448 return; 14449 var n = oSelect.length; 14450 for(var i=n-1; i>=0; i--) 14451 { 14452 if(oSelect[i].selected && i<n-1 && oSelect[i+1].selected == false) 14453 { 14454 var option = new Option(oSelect[i].text, oSelect[i].value); 14455 oSelect[i] = new Option(oSelect[i+1].text, oSelect[i+1].value); 14456 oSelect[i].selected = false; 14457 oSelect[i+1] = option; 14458 oSelect[i+1].selected = true; 14459 } 14460 } 14461 } 14462 }; 14463 14464 BX.getEventTarget = function(e) 14465 { 14466 if(e.target) 14467 { 14468 return e.target; 14469 } 14470 else if(e.srcElement) 14471 { 14472 return e.srcElement; 14473 } 14474 return null; 14475 }; 14476 14477 BX.convert = { 14478 toNumber: function(value) 14479 { 14480 if(BX.type.isNumber(value)) 14481 { 14482 return value; 14483 } 14484 14485 value = Number(value); 14486 return !isNaN(value) ? value : 0; 14487 }, 14488 nodeListToArray: function(nodes) 14489 { 14490 try 14491 { 14492 return (Array.prototype.slice.call(nodes, 0)); 14493 } 14494 catch (ex) 14495 { 14496 var ary = []; 14497 for(var i = 0, l = nodes.length; i < l; i++) 14498 { 14499 ary.push(nodes[i]); 14500 } 14501 return ary; 14502 } 14503 } 14504 }; 14505 14506 /******* HINT ***************/ 14507// if function has 2 params - the 2nd one is hint html. otherwise hint_html is third and hint_title - 2nd; 14508// '<div onmouseover="BX.hint(this, 'This is <b>Hint</b>')"'>; 14509// BX.hint(el, 'This is <b>Hint</b>') - this won't work, use constructor 14510 BX.hint = function(el, hint_title, hint_html, hint_id) 14511 { 14512 if (null == hint_html) 14513 { 14514 hint_html = hint_title; 14515 hint_title = ''; 14516 } 14517 14518 if (null == el.BXHINT) 14519 { 14520 el.BXHINT = new BX.CHint({ 14521 parent: el, hint: hint_html, title: hint_title, id: hint_id 14522 }); 14523 el.BXHINT.Show(); 14524 } 14525 }; 14526 14527 BX.hint_replace = function(el, hint_title, hint_html) 14528 { 14529 if (null == hint_html) 14530 { 14531 hint_html = hint_title; 14532 hint_title = ''; 14533 } 14534 14535 if (!el || !el.parentNode || !hint_html) 14536 return null; 14537 14538 var obHint = new BX.CHint({ 14539 hint: hint_html, 14540 title: hint_title 14541 }); 14542 14543 obHint.CreateParent(); 14544 14545 el.parentNode.insertBefore(obHint.PARENT, el); 14546 el.parentNode.removeChild(el); 14547 14548 obHint.PARENT.style.marginLeft = '5px'; 14549 14550 return el; 14551 }; 14552 14553 BX.CHint = function(params) 14554 { 14555 if (BX.CHint.cssLoaded === false) 14556 { 14557 BX.load(['/bitrix/js/main/core/css/core_hint.css']); 14558 BX.CHint.cssLoaded = true; 14559 } 14560 14561 this.PARENT = BX(params.parent); 14562 14563 this.HINT = params.hint; 14564 this.HINT_TITLE = params.title; 14565 14566 this.PARAMS = {}; 14567 for (var i in this.defaultSettings) 14568 { 14569 if (null == params[i]) 14570 this.PARAMS[i] = this.defaultSettings[i]; 14571 else 14572 this.PARAMS[i] = params[i]; 14573 } 14574 14575 if (null != params.id) 14576 this.ID = params.id; 14577 14578 this.timer = null; 14579 this.bInited = false; 14580 this.msover = true; 14581 14582 if (this.PARAMS.showOnce) 14583 { 14584 this.__show(); 14585 this.msover = false; 14586 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14587 } 14588 else if (this.PARENT) 14589 { 14590 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14591 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14592 } 14593 }; 14594 14595 BX.CHint.cssLoaded = false; 14596 14597 BX.CHint.openHints = new Set(); 14598 14599 BX.CHint.globalDisabled = false; 14600 14601 BX.CHint.handleMenuOpen = function() { 14602 BX.CHint.globalDisabled = true; 14603 14604 BX.CHint.openHints.forEach(function(hint) { 14605 hint.__hide_immediately(); 14606 }); 14607 }; 14608 14609 BX.CHint.handleMenuClose = function() { 14610 BX.CHint.globalDisabled = false; 14611 }; 14612 14613 BX.addCustomEvent('onMenuOpen', BX.CHint.handleMenuOpen); 14614 BX.addCustomEvent('onMenuClose', BX.CHint.handleMenuClose); 14615 14616 BX.CHint.prototype.defaultSettings = { 14617 show_timeout: 1000, 14618 hide_timeout: 500, 14619 dx: 2, 14620 showOnce: false, 14621 preventHide: true, 14622 min_width: 250 14623 }; 14624 14625 BX.CHint.prototype.CreateParent = function(element, params) 14626 { 14627 if (this.PARENT) 14628 { 14629 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14630 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14631 } 14632 14633 if (!params) params = {}; 14634 var type = 'icon'; 14635 14636 if (params.type && (params.type == "link" || params.type == "icon")) 14637 type = params.type; 14638 14639 if (element) 14640 type = "element";
14641 14642 if (type == "icon") 14643 { 14644 element = BX.create('IMG', { 14645 props: { 14646 src: params.iconSrc 14647 ? params.iconSrc 14648 : "/bitrix/js/main/core/images/hint.gif" 14649 } 14650 }); 14651 } 14652 else if (type == "link") 14653 { 14654 element = BX.create("A", { 14655 props: {href: 'javascript:void(0)'}, 14656 html: '[?]' 14657 }); 14658 } 14659 14660 this.PARENT = element; 14661 14662 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14663 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14664 14665 return this.PARENT; 14666 }; 14667 14668 BX.CHint.prototype.Show = function() 14669 { 14670 this.msover = true; 14671 14672 if (null != this.timer) 14673 clearTimeout(this.timer); 14674 14675 this.timer = setTimeout(BX.proxy(this.__show, this), this.PARAMS.show_timeout); 14676 }; 14677 14678 BX.CHint.prototype.Hide = function() 14679 { 14680 this.msover = false; 14681 14682 if (null != this.timer) 14683 clearTimeout(this.timer); 14684 14685 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14686 }; 14687 14688 BX.CHint.prototype.__show = function() 14689 { 14690 if (!this.msover || this.disabled || BX.CHint.globalDisabled) return; 14691 if (!this.bInited) this.Init(); 14692 14693 if (this.prepareAdjustPos()) 14694 { 14695 this.DIV.style.display = 'block'; 14696 BX.ZIndexManager.bringToFront(this.DIV); 14697 14698 this.adjustPos(); 14699 14700 BX.CHint.openHints.add(this); 14701 14702 BX.bind(window, 'scroll', BX.proxy(this.__onscroll, this)); 14703 14704 if (this.PARAMS.showOnce) 14705 { 14706 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14707 } 14708 } 14709 }; 14710 14711 BX.CHint.prototype.__onscroll = function() 14712 { 14713 if (!BX.admin || !BX.admin.panel || !BX.admin.panel.isFixed()) return; 14714 14715 if (this.scrollTimer) clearTimeout(this.scrollTimer); 14716 14717 this.DIV.style.display = 'none'; 14718 this.scrollTimer = setTimeout(BX.proxy(this.Reopen, this), this.PARAMS.show_timeout); 14719 }; 14720 14721 BX.CHint.prototype.Reopen = function() 14722 { 14723 if (null != this.timer) clearTimeout(this.timer); 14724 this.timer = setTimeout(BX.proxy(this.__show, this), 50); 14725 }; 14726 14727 BX.CHint.prototype.__hide = function() 14728 { 14729 if (this.msover) return; 14730 if (!this.bInited) return; 14731 14732 BX.unbind(window, 'scroll', BX.proxy(this.Reopen, this)); 14733 14734 BX.CHint.openHints.delete(this); 14735 14736 if (this.PARAMS.showOnce) 14737 { 14738 this.Destroy(); 14739 } 14740 else 14741 { 14742 this.DIV.style.display = 'none'; 14743 } 14744 }; 14745 14746 BX.CHint.prototype.__hide_immediately = function() 14747 { 14748 this.msover = false; 14749 this.__hide(); 14750 }; 14751 14752 BX.CHint.prototype.Init = function() 14753 { 14754 this.DIV = document.body.appendChild(BX.create('DIV', { 14755 props: {className: 'bx-panel-tooltip'}, 14756 style: { 14757 display: 'none', 14758 position: 'absolute', 14759 visibility: 'hidden' 14760 }, 14761 children: [ 14762 (this.CONTENT = BX.create('DIV', { 14763 props: {className: 'bx-panel-tooltip-content'}, 14764 children: [ 14765 BX.create('DIV', { 14766 props: {className: 'bx-panel-tooltip-underlay'}, 14767 children: [ 14768 BX.create('DIV', {props: {className: 'bx-panel-tooltip-underlay-bg'}}) 14769 ] 14770 }) 14771 ] 14772 })) 14773 ] 14774 })); 14775 14776 BX.ZIndexManager.register(this.DIV); 14777 14778 if (this.ID) 14779 { 14780 this.CONTENT.insertBefore(BX.create('A', { 14781 attrs: {href: 'javascript:void(0)'}, 14782 props: {className: 'bx-panel-tooltip-close'}, 14783 events: {click: BX.delegate(this.Close, this)} 14784 }), this.CONTENT.firstChild); 14785 } 14786 14787 if (this.HINT_TITLE) 14788 { 14789 this.CONTENT.appendChild( 14790 BX.create('DIV', { 14791 props: {className: 'bx-panel-tooltip-title'}, 14792 text: this.HINT_TITLE 14793 }) 14794 ); 14795 } 14796 14797 if (this.HINT) 14798 { 14799 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 14800 } 14801 14802 if (this.PARAMS.preventHide) 14803 { 14804 BX.bind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 14805 BX.bind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 14806 } 14807 14808 this.bInited = true; 14809 }; 14810 14811 BX.CHint.prototype.setContent = function(content) 14812 { 14813 this.HINT = content; 14814 14815 if (this.CONTENT_TEXT) 14816 this.CONTENT_TEXT.innerHTML = this.HINT; 14817 else 14818 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 14819 }; 14820 14821 BX.CHint.prototype.prepareAdjustPos = function() 14822 { 14823 this._wnd = {scrollPos: BX.GetWindowScrollPos(),scrollSize:BX.GetWindowScrollSize()}; 14824 return BX.style(this.PARENT, 'display') != 'none'; 14825 }; 14826 14827 BX.CHint.prototype.getAdjustPos = function() 14828 { 14829 var res = {}, pos = BX.pos(this.PARENT), min_top = 0; 14830 14831 res.top = pos.bottom + this.PARAMS.dx; 14832 14833 if (BX.admin && BX.admin.panel.DIV) 14834 { 14835 min_top = BX.admin.panel.DIV.offsetHeight + this.PARAMS.dx; 14836 14837 if (BX.admin.panel.isFixed()) 14838 { 14839 min_top += this._wnd.scrollPos.scrollTop; 14840 } 14841 } 14842 14843 if (res.top < min_top) 14844 res.top = min_top; 14845 else 14846 { 14847 if (res.top + this.DIV.offsetHeight > this._wnd.scrollSize.scrollHeight) 14848 res.top = pos.top - this.PARAMS.dx - this.DIV.offsetHeight; 14849 } 14850 14851 res.left = pos.left; 14852 if (pos.left < this.PARAMS.dx) 14853 pos.left = this.PARAMS.dx; 14854 else 14855 { 14856 var floatWidth = this.DIV.offsetWidth; 14857 14858 var max_left = this._wnd.scrollSize.scrollWidth - floatWidth - this.PARAMS.dx; 14859 14860 if (res.left > max_left) 14861 res.left = max_left; 14862 } 14863 14864 return res; 14865 }; 14866 14867 BX.CHint.prototype.adjustWidth = function() 14868 { 14869 if (this.bWidthAdjusted) return; 14870 14871 var w = this.DIV.offsetWidth, h = this.DIV.offsetHeight; 14872 14873 if (w > this.PARAMS.min_width) 14874 w = Math.round(Math.sqrt(1.618*w*h)); 14875 14876 if (w < this.PARAMS.min_width) 14877 w = this.PARAMS.min_width; 14878 14879 this.DIV.style.width = w + "px"; 14880 14881 if (this._adjustWidthInt) 14882 clearInterval(this._adjustWidthInt); 14883 this._adjustWidthInt = setInterval(BX.delegate(this._adjustWidthInterval, this), 5); 14884 14885 this.bWidthAdjusted = true; 14886 }; 14887 14888 BX.CHint.prototype._adjustWidthInterval = function() 14889 { 14890 if (!this.DIV || this.DIV.style.display == 'none') 14891 clearInterval(this._adjustWidthInt); 14892 14893 var
14894 dW = 20, 14895 maxWidth = 1500, 14896 w = this.DIV.offsetWidth, 14897 w1 = this.CONTENT_TEXT.offsetWidth; 14898 14899 if (w > 0 && w1 > 0 && w - w1 < dW && w < maxWidth) 14900 { 14901 this.DIV.style.width = (w + dW) + "px"; 14902 return; 14903 } 14904 14905 clearInterval(this._adjustWidthInt); 14906 }; 14907 14908 BX.CHint.prototype.adjustPos = function() 14909 { 14910 this.adjustWidth(); 14911 14912 var pos = this.getAdjustPos(); 14913 14914 this.DIV.style.top = pos.top + 'px'; 14915 this.DIV.style.left = pos.left + 'px'; 14916 }; 14917 14918 BX.CHint.prototype.Close = function() 14919 { 14920 if (this.ID && BX.WindowManager) 14921 BX.WindowManager.saveWindowOptions(this.ID, {display: 'off'}); 14922 this.__hide_immediately(); 14923 this.Destroy(); 14924 }; 14925 14926 BX.CHint.prototype.Destroy = function() 14927 { 14928 if (this.PARENT) 14929 { 14930 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14931 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14932 } 14933 14934 if (this.DIV) 14935 { 14936 BX.unbind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 14937 BX.unbind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 14938 14939 BX.ZIndexManager.unregister(this.DIV); 14940 14941 BX.cleanNode(this.DIV, true); 14942 } 14943 }; 14944 14945 BX.CHint.prototype.enable = function(){this.disabled = false;}; 14946 BX.CHint.prototype.disable = function(){this.__hide_immediately(); this.disabled = true;}; 14947 14948 14949 function _adjustWait() 14950 { 14951 if (!this.bxmsg) return; 14952 14953 var arContainerPos = BX.pos(this), 14954 div_top = arContainerPos.top; 14955 14956 if (div_top < BX.GetDocElement().scrollTop) 14957 div_top = BX.GetDocElement().scrollTop + 5; 14958 14959 this.bxmsg.style.top = (div_top + 5) + 'px'; 14960 14961 if (this == BX.GetDocElement()) 14962 { 14963 this.bxmsg.style.right = '5px'; 14964 } 14965 else 14966 { 14967 this.bxmsg.style.left = (arContainerPos.right - this.bxmsg.offsetWidth - 5) + 'px'; 14968 } 14969 } 14970 14971 function _processTpl(tplNode, cb, bKillTpl) 14972 { 14973 if (tplNode) 14974 { 14975 if (bKillTpl) 14976 tplNode.parentNode.removeChild(tplNode); 14977 14978 var res = {}, nodes = BX.findChildren(tplNode, {attribute: 'data-role'}, true); 14979 14980 for (var i = 0, l = nodes.length; i < l; i++) 14981 { 14982 res[nodes[i].getAttribute('data-role')] = nodes[i]; 14983 } 14984 14985 cb.apply(tplNode, [res]); 14986 } 14987 } 14988 14989 function _checkNode(obj, params) 14990 { 14991 params = params || {}; 14992 14993 if (BX.type.isFunction(params)) 14994 return params.call(window, obj); 14995 14996 if (!params.allowTextNodes && !BX.type.isElementNode(obj)) 14997 return false; 14998 var i,j,len; 14999 for (i in params) 15000 { 15001 if(params.hasOwnProperty(i)) 15002 { 15003 switch(i) 15004 { 15005 case 'tag': 15006 case 'tagName': 15007 if (BX.type.isString(params[i])) 15008 { 15009 if (obj.tagName.toUpperCase() != params[i].toUpperCase()) 15010 return false; 15011 } 15012 else if (params[i] instanceof RegExp) 15013 { 15014 if (!params[i].test(obj.tagName)) 15015 return false; 15016 } 15017 break; 15018 15019 case 'class': 15020 case 'className': 15021 if (BX.type.isString(params[i])) 15022 { 15023 if (!BX.hasClass(obj, params[i])) 15024 return false; 15025 } 15026 else if (params[i] instanceof RegExp) 15027 { 15028 if (!BX.type.isString(obj.className) || !params[i].test(obj.className)) 15029 return false; 15030 } 15031 break; 15032 15033 case 'attr': 15034 case 'attrs': 15035 case 'attribute': 15036 if (BX.type.isString(params[i])) 15037 { 15038 if (!obj.getAttribute(params[i])) 15039 return false; 15040 } 15041 else if (BX.type.isArray(params[i])) 15042 { 15043 for (j = 0, len = params[i].length; j < len; j++) 15044 { 15045 if (params[i] && !obj.getAttribute(params[i])) 15046 return false; 15047 } 15048 } 15049 else 15050 { 15051 for (j in params[i]) 15052 { 15053 if(params[i].hasOwnProperty(j)) 15054 { 15055 var q = obj.getAttribute(j); 15056 if (params[i][j] instanceof RegExp) 15057 { 15058 if (!BX.type.isString(q) || !params[i][j].test(q)) 15059 { 15060 return false; 15061 } 15062 } 15063 else 15064 { 15065 if (q != '' + params[i][j]) 15066 { 15067 return false; 15068 } 15069 } 15070 } 15071 } 15072 } 15073 break; 15074 15075 case 'property': 15076 case 'props': 15077 if (BX.type.isString(params[i])) 15078 { 15079 if (!obj[params[i]]) 15080 return false; 15081 } 15082 else if (BX.type.isArray(params[i])) 15083 { 15084 for (j = 0, len = params[i].length; j < len; j++) 15085 { 15086 if (params[i] && !obj[params[i]]) 15087 return false;
15088 } 15089 } 15090 else 15091 { 15092 for (j in params[i]) 15093 { 15094 if (BX.type.isString(params[i][j])) 15095 { 15096 if (obj[j] != params[i][j]) 15097 return false; 15098 } 15099 else if (params[i][j] instanceof RegExp) 15100 { 15101 if (!BX.type.isString(obj[j]) || !params[i][j].test(obj[j])) 15102 return false; 15103 } 15104 } 15105 } 15106 break; 15107 15108 case 'callback': 15109 return params[i](obj); 15110 } 15111 } 15112 } 15113 15114 return true; 15115 } 15116 15117 window.addEventListener('pagehide', () => { 15118 garbageCollectors.forEach(({ callback, context = window }) => { 15119 try 15120 { 15121 callback.apply(context); 15122 } catch (err) {} 15123 }); 15124 }); 15125 15126 // set empty ready handler 15127 BX(BX.DoNothing); 15128 window.BX = BX; 15129 15130 BX.browser.addGlobalClass(); 15131 15132 /* data storage */ 15133 BX.data = function(node, key, value) 15134 { 15135 if(typeof node == 'undefined') 15136 return undefined; 15137 15138 if(typeof key == 'undefined') 15139 return undefined; 15140 15141 if(typeof value != 'undefined') 15142 { 15143 // write to manager 15144 dataStorage.set(node, key, value); 15145 } 15146 else 15147 { 15148 var data; 15149 15150 // from manager 15151 if((data = dataStorage.get(node, key)) != undefined) 15152 { 15153 return data; 15154 } 15155 else 15156 { 15157 // from attribute data-* 15158 if('getAttribute' in node) 15159 { 15160 data = node.getAttribute('data-'+key.toString()); 15161 if(data === null) 15162 { 15163 return undefined; 15164 } 15165 return data; 15166 } 15167 } 15168 15169 return undefined; 15170 } 15171 }; 15172 15173 BX.DataStorage = function() 15174 { 15175 15176 this.keyOffset = 1; 15177 this.data = {}; 15178 this.uniqueTag = 'BX-'+Math.random(); 15179 15180 this.resolve = function(owner, create){ 15181 if(typeof owner[this.uniqueTag] == 'undefined') 15182 if(create) 15183 { 15184 try 15185 { 15186 Object.defineProperty(owner, this.uniqueTag, { 15187 value: this.keyOffset++ 15188 }); 15189 } 15190 catch(e) 15191 { 15192 owner[this.uniqueTag] = this.keyOffset++; 15193 } 15194 } 15195 else 15196 return undefined; 15197 15198 return owner[this.uniqueTag]; 15199 }; 15200 this.get = function(owner, key){ 15201 if((owner != document && !BX.type.isElementNode(owner)) || typeof key == 'undefined') 15202 return undefined; 15203 15204 owner = this.resolve(owner, false); 15205 15206 if(typeof owner == 'undefined' || typeof this.data[owner] == 'undefined') 15207 return undefined; 15208 15209 return this.data[owner][key]; 15210 }; 15211 this.set = function(owner, key, value){ 15212 15213 if((owner != document && !BX.type.isElementNode(owner)) || typeof value == 'undefined') 15214 return; 15215 15216 var o = this.resolve(owner, true); 15217 15218 if(typeof this.data[o] == 'undefined') 15219 this.data[o] = {}; 15220 15221 this.data[o][key] = value; 15222 }; 15223 }; 15224 15225// some internal variables for new logic 15226 var dataStorage = new BX.DataStorage(); // manager which BX.data() uses to keep data 15227})(window.BX); 15228 15229 15230;(function(window) 15231{ 15232 /****************** ATTENTION ******************************* 15233 * Please do not use Bitrix CoreJS in this class. 15234 * This class can be called on page without Bitrix Framework 15235 *************************************************************/ 15236 15237 if (!window.BX) 15238 { 15239 window.BX = {}; 15240 } 15241 15242 var BX = window.BX; 15243 15244 BX.Promise = function(fn, ctx) // fn is future-reserved 15245 { 15246 this.state = null; 15247 this.value = null; 15248 this.reason = null; 15249 this.next = null; 15250 this.ctx = ctx || this; 15251 15252 this.onFulfilled = []; 15253 this.onRejected = []; 15254 }; 15255 BX.Promise.prototype.fulfill = function(value) 15256 { 15257 this.checkState(); 15258 15259 this.value = value; 15260 this.state = true; 15261 this.execute(); 15262 }; 15263 BX.Promise.prototype.reject = function(reason) 15264 { 15265 this.checkState(); 15266 15267 this.reason = reason; 15268 this.state = false; 15269 this.execute(); 15270 }; 15271 BX.Promise.prototype.then = function(onFulfilled, onRejected) 15272 { 15273 if(typeof (onFulfilled) == "function" || onFulfilled instanceof Function) 15274 { 15275 this.onFulfilled.push(onFulfilled); 15276 } 15277 if(typeof (onRejected) == "function" || onRejected instanceof Function) 15278 { 15279 this.onRejected.push(onRejected); 15280 } 15281 15282 if(this.next === null) 15283 { 15284 this.next = new BX.Promise(null, this.ctx); 15285 } 15286 15287 if(this.state !== null) // if promise was already resolved, execute immediately 15288 { 15289 this.execute(); 15290 } 15291 15292 return this.next; 15293 }; 15294 15295 BX.Promise.prototype.catch = function(onRejected) 15296 { 15297 if(typeof (onRejected) == "function" || onRejected instanceof Function) 15298 { 15299 this.onRejected.push(onRejected); 15300 } 15301 15302 if(this.next === null) 15303 { 15304 this.next = new BX.Promise(null, this.ctx); 15305 } 15306 15307 if(this.state !== null) // if promise was already resolved, execute immediately 15308 { 15309 this.execute(); 15310 } 15311 15312 return this.next; 15313 }; 15314 15315 BX.Promise.prototype.setAutoResolve = function(way, ms) 15316 { 15317 this.timer = setTimeout(function(){ 15318 if(this.state === null) 15319 { 15320 this[way ? 'fulfill' : 'reject'](); 15321 } 15322 }.bind(this), ms || 15); 15323 };
15324 BX.Promise.prototype.cancelAutoResolve = function() 15325 { 15326 clearTimeout(this.timer); 15327 }; 15328 /** 15329 * Resolve function. This function allows promise chaining, like ..then().then()... 15330 * Typical usage: 15331 * 15332 * var p = new Promise(); 15333 * 15334 * p.then(function(value){ 15335 * return someValue; // next promise in the chain will be fulfilled with someValue 15336 * }).then(function(value){ 15337 * 15338 * var p1 = new Promise(); 15339 * *** some async code here, that eventually resolves p1 *** 15340 * 15341 * return p1; // chain will resume when p1 resolved (fulfilled or rejected) 15342 * }).then(function(value){ 15343 * 15344 * // you can also do 15345 * var e = new Error(); 15346 * throw e; 15347 * // it will cause next promise to be rejected with e 15348 * 15349 * return someOtherValue; 15350 * }).then(function(value){ 15351 * ... 15352 * }, function(reason){ 15353 * // promise was rejected with reason 15354 * })...; 15355 * 15356 * p.fulfill('let`s start this chain'); 15357 * 15358 * @param x 15359 */ 15360 BX.Promise.prototype.resolve = function(x) 15361 { 15362 var this_ = this; 15363 15364 if(this === x) 15365 { 15366 this.reject(new TypeError('Promise cannot fulfill or reject itself')); // avoid recursion 15367 } 15368 // allow "pausing" promise chaining until promise x is fulfilled or rejected 15369 else if(x && x.toString() === "[object BX.Promise]") 15370 { 15371 x.then(function(value){ 15372 this_.fulfill(value); 15373 }, function(reason){ 15374 this_.reject(reason); 15375 }); 15376 } 15377 else // auto-fulfill this promise 15378 { 15379 this.fulfill(x); 15380 } 15381 }; 15382 15383 BX.Promise.prototype.toString = function() 15384 { 15385 return "[object BX.Promise]"; 15386 }; 15387 15388 BX.Promise.prototype.execute = function() 15389 { 15390 if(this.state === null) 15391 { 15392 //then() must not be called before BX.Promise resolve() happens 15393 return; 15394 } 15395 15396 var value = undefined; 15397 var reason = undefined; 15398 var x = undefined; 15399 var k; 15400 if(this.state === true) // promise was fulfill()-ed 15401 { 15402 if(this.onFulfilled.length) 15403 { 15404 try 15405 { 15406 for(k = 0; k < this.onFulfilled.length; k++) 15407 {
15408 x = this.onFulfilled[k].apply(this.ctx, [this.value]); 15409 if(typeof x != 'undefined') 15410 { 15411 value = x; 15412 } 15413 } 15414 } 15415 catch(e) 15416 { 15417 if('console' in window) 15418 { 15419 console.dir(e); 15420 } 15421 15422 if (typeof BX.debug !== 'undefined') 15423 { 15424 BX.debug(e); 15425 } 15426 15427 reason = e; // reject next 15428 } 15429 } 15430 else 15431 { 15432 value = this.value; // resolve next 15433 } 15434 } 15435 else if(this.state === false) // promise was reject()-ed 15436 { 15437 if(this.onRejected.length) 15438 { 15439 try 15440 { 15441 for(k = 0; k < this.onRejected.length; k++) 15442 { 15443 x = this.onRejected[k].apply(this.ctx, [this.reason]); 15444 if(typeof x != 'undefined') 15445 { 15446 value = x; 15447 } 15448 } 15449 } 15450 catch(e) 15451 { 15452 if('console' in window) 15453 { 15454 console.dir(e); 15455 } 15456 15457 if (typeof BX.debug !== 'undefined') 15458 { 15459 BX.debug(e); 15460 } 15461 15462 reason = e; // reject next 15463 } 15464 } 15465 else 15466 { 15467 reason = this.reason; // reject next 15468 } 15469 } 15470 15471 if(this.next !== null) 15472 { 15473 if(typeof reason != 'undefined') 15474 { 15475 this.next.reject(reason); 15476 } 15477 else if(typeof value != 'undefined') 15478 { 15479 this.next.resolve(value); 15480 } 15481 } 15482 }; 15483 BX.Promise.prototype.checkState = function() 15484 { 15485 if(this.state !== null) 15486 { 15487 throw new Error('You can not do fulfill() or reject() multiple times'); 15488 } 15489 }; 15490})(window); 15491 15492 15493 15494;(function(window){ 15495 15496if (window.BX.ajax) 15497 return; 15498 15499var 15500 BX = window.BX, 15501 15502 tempDefaultConfig = {}, 15503 defaultConfig = { 15504 method: 'GET', // request method: GET|POST 15505 dataType: 'html', // type of data loading: html|json|script 15506 timeout: 0, // request timeout in seconds. 0 for browser-default 15507 async: true, // whether request is asynchronous or not 15508 processData: true, // any data processing is disabled if false, only callback call 15509 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 15510 emulateOnload: true, 15511 skipAuthCheck: false, // whether to check authorization failure (SHOUD be set to true for CORS requests) 15512 start: true, // send request immediately (if false, request can be started manually via XMLHttpRequest object returned) 15513 cache: true, // whether NOT to add random addition to URL 15514 preparePost: true, // whether set Content-Type x-www-form-urlencoded in POST 15515 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'}] 15516 lsTimeout: 30, //local storage data TTL. useless without lsId. 15517 lsForce: false //wheter to force query instead of using localStorage data. useless without lsId. 15518/* 15519other parameters: 15520 url: url to get/post 15521 data: data to post 15522 onsuccess: successful request callback. BX.proxy may be used. 15523 onfailure: request failure callback. BX.proxy may be used. 15524 onprogress: request progress callback. BX.proxy may be used. 15525 15526 lsId: local storage id - for constantly updating queries which can communicate via localStorage. core_ls.js needed 15527 15528any of the default parameters can be overridden. defaults can be changed by BX.ajax.Setup() - for all further requests! 15529*/ 15530 }, 15531 loadedScripts = {}, 15532 loadedScriptsQueue = [], 15533 r = { 15534 'url_utf': /[^\034-\254]+/g, 15535 'script_self': /\/bitrix\/js\/main\/core\/core(_ajax)*.js$/i, 15536 'script_self_window': /\/bitrix\/js\/main\/core\/core_window.js$/i, 15537 'script_self_admin': /\/bitrix\/js\/main\/core\/core_admin.js$/i, 15538 'script_onload': /window.onload/g 15539 }; 15540 15541// low-level method 15542BX.ajax = function(config) 15543{ 15544 var status, data; 15545
15546 if (!config || !config.url || !BX.type.isString(config.url)) 15547 { 15548 return false; 15549 } 15550 15551 for (var i in tempDefaultConfig) 15552 if (typeof (config[i]) == "undefined") config[i] = tempDefaultConfig[i]; 15553 15554 tempDefaultConfig = {}; 15555 15556 for (i in defaultConfig) 15557 if (typeof (config[i]) == "undefined") config[i] = defaultConfig[i]; 15558 15559 config.method = config.method.toUpperCase(); 15560 15561 if (!BX.localStorage) 15562 config.lsId = null; 15563 15564 if (BX.browser.IsIE()) 15565 { 15566 var result = r.url_utf.exec(config.url); 15567 if (result) 15568 { 15569 do 15570 { 15571 config.url = config.url.replace(result, BX.util.urlencode(result)); 15572 result = r.url_utf.exec(config.url); 15573 } while (result); 15574 } 15575 } 15576 15577 if(config.dataType == 'json') 15578 config.emulateOnload = false; 15579 15580 if (!config.cache && config.method == 'GET') 15581 config.url = BX.ajax._uncache(config.url); 15582 15583 if (config.method == 'POST') 15584 { 15585 if (config.preparePost) 15586 { 15587 config.data = BX.ajax.prepareData(config.data); 15588 } 15589 else if (getLastContentTypeHeader(config.headers) === 'application/json') 15590 { 15591 const isJson = ( 15592 BX.Type.isPlainObject(config.data) 15593 || BX.Type.isString(config.data) 15594 || BX.Type.isNumber(config.data) 15595 || BX.Type.isBoolean(config.data) 15596 || BX.Type.isArray(config.data) 15597 ); 15598 15599 if (isJson) 15600 { 15601 config.data = JSON.stringify(config.data); 15602 } 15603 } 15604 } 15605 15606 var bXHR = true; 15607 if (config.lsId && !config.lsForce) 15608 { 15609 var v = BX.localStorage.get('ajax-' + config.lsId); 15610 if (v !== null) 15611 { 15612 bXHR = false; 15613 15614 var lsHandler = function(lsData) { 15615 if (lsData.key == 'ajax-' + config.lsId && lsData.value != 'BXAJAXWAIT') 15616 { 15617 var data = lsData.value, 15618 bRemove = !!lsData.oldValue && data == null; 15619 if (!bRemove) 15620 BX.ajax.__run(config, data); 15621 else if (config.onfailure) 15622 config.onfailure("timeout"); 15623 15624 BX.removeCustomEvent('onLocalStorageChange', lsHandler); 15625 } 15626 }; 15627 15628 if (v == 'BXAJAXWAIT') 15629 { 15630 BX.addCustomEvent('onLocalStorageChange', lsHandler); 15631 } 15632 else 15633 { 15634 setTimeout(function() {lsHandler({key: 'ajax-' + config.lsId, value: v})}, 10); 15635 } 15636 } 15637 } 15638 15639 if (bXHR) 15640 { 15641 config.xhr = BX.ajax.xhr(); 15642 if (!config.xhr) return; 15643 15644 if (config.lsId) 15645 { 15646 BX.localStorage.set('ajax-' + config.lsId, 'BXAJAXWAIT', config.lsTimeout); 15647 } 15648 15649 if (BX.Type.isFunction(config.onprogress)) 15650 { 15651 BX.bind(config.xhr, 'progress', config.onprogress); 15652 } 15653 15654 if (BX.Type.isFunction(config.onprogressupload) && config.xhr.upload) 15655 { 15656 BX.bind(config.xhr.upload, 'progress', config.onprogressupload); 15657 } 15658 15659 config.xhr.open(config.method, config.url, config.async); 15660 15661 if (!config.skipBxHeader && !BX.ajax.isCrossDomain(config.url)) 15662 { 15663 config.xhr.setRequestHeader('Bx-ajax', 'true'); 15664 } 15665 15666 if (config.method == 'POST' && config.preparePost) 15667 { 15668 config.xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 15669 } 15670 if (typeof(config.headers) == "object") 15671 { 15672 for (i = 0; i < config.headers.length; i++) 15673 config.xhr.setRequestHeader(config.headers[i].name, config.headers[i].value); 15674 } 15675 15676 var bRequestCompleted = false; 15677 var onreadystatechange = config.xhr.onreadystatechange = function(additional) 15678 { 15679 if (bRequestCompleted) 15680 return; 15681 15682 if (additional === 'timeout') 15683 { 15684 if (config.onfailure) 15685 { 15686 config.onfailure('timeout', '', config); 15687 } 15688 15689 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['timeout', '', config]); 15690 15691 config.xhr.onreadystatechange = BX.DoNothing; 15692 config.xhr.abort(); 15693 15694 if (config.async) 15695 { 15696 config.xhr = null; 15697 } 15698 } 15699 else 15700 { 15701 if (config.xhr.readyState == 4 || additional == 'run') 15702 { 15703 status = BX.ajax.xhrSuccess(config.xhr) ? "success" : "error"; 15704 bRequestCompleted = true; 15705 config.xhr.onreadystatechange = BX.DoNothing; 15706 15707 if (status == 'success') 15708 { 15709 var authHeader = (!!config.skipAuthCheck || BX.ajax.isCrossDomain(config.url)) 15710 ? false 15711 : config.xhr.getResponseHeader('X-Bitrix-Ajax-Status'); 15712 15713 if(!!authHeader && authHeader == 'Authorize') 15714 { 15715 if (config.onfailure) 15716 { 15717 config.onfailure('auth', config.xhr.status, config); 15718 } 15719 15720 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['auth', config.xhr.status, config]); 15721 } 15722 else 15723 { 15724 var data = config.xhr.responseText; 15725 15726 if (config.lsId) 15727 { 15728 BX.localStorage.set('ajax-' + config.lsId, data, config.lsTimeout); 15729 } 15730 15731 BX.ajax.__run(config, data); 15732 } 15733 } 15734 else 15735 { 15736 if (config.onfailure) 15737 { 15738 config.onfailure('status', config.xhr.status, config); 15739 } 15740 15741 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['status', config.xhr.status, config]); 15742 } 15743 15744 if (config.async) 15745 { 15746 config.xhr = null; 15747 } 15748 } 15749 } 15750 }; 15751 15752 if (config.async && config.timeout > 0) 15753 { 15754 setTimeout(function() { 15755 if (config.xhr && !bRequestCompleted) 15756 { 15757 onreadystatechange("timeout"); 15758 } 15759 }, config.timeout * 1000); 15760 } 15761 15762 if (config.start) 15763 {
15764 config.xhr.send(config.data); 15765 15766 if (!config.async) 15767 { 15768 onreadystatechange('run'); 15769 } 15770 } 15771 15772 return config.xhr; 15773 } 15774}; 15775 15776BX.ajax.xhr = function() 15777{ 15778 if (window.XMLHttpRequest) 15779 { 15780 try {return new XMLHttpRequest();} catch(e){} 15781 } 15782 else if (window.ActiveXObject) 15783 { 15784 try { return new window.ActiveXObject("Msxml2.XMLHTTP.6.0"); } 15785 catch(e) {} 15786 try { return new window.ActiveXObject("Msxml2.XMLHTTP.3.0"); } 15787 catch(e) {} 15788 try { return new window.ActiveXObject("Msxml2.XMLHTTP"); } 15789 catch(e) {} 15790 try { return new window.ActiveXObject("Microsoft.XMLHTTP"); } 15791 catch(e) {} 15792 throw new Error("This browser does not support XMLHttpRequest."); 15793 } 15794 15795 return null; 15796}; 15797 15798BX.ajax.isCrossDomain = function(url, location) 15799{ 15800 location = location || window.location; 15801 15802 //Relative URL gets a current protocol 15803 if (url.indexOf("//") === 0) 15804 { 15805 url = location.protocol + url; 15806 } 15807 15808 //Fast check 15809 if (url.indexOf("http") !== 0) 15810 { 15811 return false; 15812 } 15813 15814 var link = window.document.createElement("a"); 15815 link.href = url; 15816 15817 return link.protocol !== location.protocol || 15818 link.hostname !== location.hostname || 15819 BX.ajax.getHostPort(link.protocol, link.host) !== BX.ajax.getHostPort(location.protocol, location.host); 15820}; 15821 15822BX.ajax.getHostPort = function(protocol, host) 15823{ 15824 var match = /:(\d+)$/.exec(host); 15825 if (match) 15826 { 15827 return match[1]; 15828 } 15829 else 15830 { 15831 if (protocol === "http:") 15832 { 15833 return "80"; 15834 } 15835 else if (protocol === "https:") 15836 { 15837 return "443"; 15838 } 15839 } 15840 15841 return ""; 15842}; 15843 15844BX.ajax.__prepareOnload = function(scripts, ajax_session) 15845{ 15846 if (scripts.length > 0) 15847 { 15848 BX.ajax['onload_' + ajax_session] = null; 15849 15850 for (var i=0,len=scripts.length;i<len;i++) 15851 { 15852 if (scripts[i].isInternal) 15853 { 15854 scripts[i].JS = scripts[i].JS.replace(r.script_onload, 'BX.aja
15854x.onload_' + ajax_session); 15855 } 15856 } 15857 } 15858 15859 BX.CaptureEventsGet(); 15860 BX.CaptureEvents(window, 'load'); 15861}; 15862 15863BX.ajax.__runOnload = function(ajax_session) 15864{ 15865 if (null != BX.ajax['onload_' + ajax_session]) 15866 { 15867 BX.ajax['onload_' + ajax_session].apply(window); 15868 BX.ajax['onload_' + ajax_session] = null; 15869 } 15870 15871 var h = BX.CaptureEventsGet(); 15872 15873 if (h) 15874 { 15875 for (var i=0; i<h.length; i++) 15876 h[i].apply(window); 15877 } 15878}; 15879 15880BX.ajax.__run = function(config, data) 15881{ 15882 if (!config.processData) 15883 { 15884 if (config.onsuccess) 15885 { 15886 config.onsuccess(data); 15887 } 15888 15889 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [data, config]); 15890 } 15891 else 15892 { 15893 data = BX.ajax.processRequestData(data, config); 15894 } 15895}; 15896 15897 15898BX.ajax._onParseJSONFailure = function(data) 15899{ 15900 this.jsonFailure = true; 15901 this.jsonResponse = data; 15902 this.jsonProactive = /^\[WAF\]/.test(data); 15903}; 15904 15905BX.ajax.processRequestData = function(data, config) 15906{ 15907 var result, scripts = [], styles = []; 15908 switch (config.dataType.toUpperCase()) 15909 { 15910 case 'JSON': 15911 15912 var context = config.xhr || {}; 15913 BX.addCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 15914 result = BX.parseJSON(data, context); 15915 BX.removeCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 15916 15917 if(!!result && BX.type.isArray(result['bxjs'])) 15918 { 15919 for(var i = 0; i < result['bxjs'].length; i++) 15920 { 15921 if(BX.type.isNotEmptyString(result['bxjs'][i])) 15922 { 15923 scripts.push({ 15924 "isInternal": false, 15925 "JS": result['bxjs'][i], 15926 "bRunFirst": config.scriptsRunFirst 15927 }); 15928 } 15929 else 15930 { 15931 scripts.push(result['bxjs'][i]) 15932 } 15933 } 15934 } 15935 15936 if(!!result && BX.type.isArray(result['bxcss'])) 15937 { 15938 styles = result['bxcss']; 15939 } 15940 15941 break; 15942 case 'SCRIPT': 15943 scripts.push({"isInternal": true, "JS": data, "bRunFirst": config.scriptsRunFirst}); 15944 result = data; 15945 break; 15946 15947 default: // HTML 15948 var ob = BX.processHTML(data, config.scriptsRunFirst); 15949 result = ob.HTML; scripts = ob.SCRIPT; styles = ob.STYLE; 15950 break; 15951 } 15952 15953 if (styles.length > 0) 15954 { 15955 BX.loadCSS(styles); 15956 } 15957 15958 let ajax_session = null; 15959 if (config.emulateOnload) 15960 { 15961 ajax_session = parseInt(Math.random() * 1000000); 15962 BX.ajax.__prepareOnload(scripts, ajax_session); 15963 } 15964 15965 const cb = BX.defer(function() 15966 { 15967 if (config.emulateOnload) 15968 { 15969 BX.ajax.__runOnload(ajax_session); 15970 } 15971 15972 BX.onCustomEvent(config.xhr, 'onAjaxSuccessFinish', [config]); 15973 }); 15974 15975 try 15976 { 15977 if (!!config.jsonFailure) 15978 { 15979 throw {type: 'json_failure', data: config.jsonResponse, bProactive: config.jsonProactive}; 15980 } 15981 15982 config.scripts = scripts; 15983 15984 BX.ajax.processScripts(config.scripts, true); 15985 15986 if (config.onsuccess) 15987 { 15988 config.onsuccess(result); 15989 } 15990 15991 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [result, config]); 15992 15993 BX.ajax.processScripts(config.scripts, false, cb); 15994 } 15995 catch (e) 15996 { 15997 if (config.onfailure) 15998 config.onfailure("processing", e); 15999 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['processing', e, config]); 16000 } 16001}; 16002 16003BX.ajax.processScripts = function(scripts, bRunFirst, cb) 16004{ 16005 var scriptsExt = [], scriptsInt = ''; 16006 16007 cb = cb || BX.DoNothing; 16008 16009 for (var i = 0, length = scripts.length; i < length; i++) 16010 { 16011 if (typeof bRunFirst != 'undefined' && bRunFirst != !!scripts[i].bRunFirst) 16012 continue; 16013 16014 if (scripts[i].isInternal) 16015 scriptsInt += ';' + scripts[i].JS; 16016 else 16017 scriptsExt.push(scripts[i].JS); 16018 } 16019 16020 scriptsExt = BX.util.array_unique(scriptsExt); 16021 var inlineScripts = scriptsInt.length > 0 ? function() { BX.evalGlobal(scriptsInt); } : BX.DoNothing; 16022 16023 if (scriptsExt.length > 0) 16024 { 16025 BX.load(scriptsExt, function() { 16026 inlineScripts(); 16027 cb(); 16028 }); 16029 } 16030 else 16031 { 16032 inlineScripts(); 16033 cb(); 16034 } 16035}; 16036 16037// TODO: extend this function to use with any data objects or forms 16038BX.ajax.prepareData = function(arData, prefix) 16039{ 16040 var data = ''; 16041 if (BX.type.isString(arData)) 16042 data = arData; 16043 else if (null != arData) 16044 { 16045 for(var i in arData) 16046 { 16047 if (arData.hasOwnProperty(i)) 16048 { 16049 if (data.length > 0) 16050 data += '&'; 16051 var name = BX.util.urlencode(i); 16052 if(prefix) 16053 name = prefix + '[' + name + ']'; 16054 if(typeof arData[i] == 'object') 16055 data += BX.ajax.prepareData(arData[i], name); 16056 else 16057 data += name + '=' + BX.util.urlencode(arData[i]); 16058 } 16059 } 16060 } 16061 return data; 16062}; 16063 16064BX.ajax.xhrSuccess = function(xhr) 16065{ 16066 return (xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || xhr.status === 1223 || xhr.status === 0; 16067}; 16068 16069BX.ajax.Setup = function(config, bTemp) 16070{ 16071 bTemp = !!bTemp; 16072 16073 for (var i in config) 16074 { 16075 if (bTemp) 16076 tempDefaultConfig[i] = config[i]; 16077 else 16078 defaultConfig[i] = config[i]; 16079 } 16080}; 16081 16082BX.ajax.replaceLocalStorageValue = function(lsId, data, ttl) 16083{ 16084 if (!!BX.localStorage) 16085 BX.localStorage.set('ajax-' + lsId, data, ttl); 16086}; 16087 16088 16089BX.ajax._uncache = function(url) 16090{ 16091 return url + ((url.indexOf('?') !== -1 ? "&" : "?") + '_=' + (new Date()).getTime()); 16092}; 16093 16094/* simple interface */ 16095BX.ajax.get = function(url, data, callback) 16096{ 16097 if (BX.type.isFunction(data)) 16098 { 16099 callback = data; 16100 data = ''; 16101 } 16102
16103 data = BX.ajax.prepareData(data); 16104 16105 if (data) 16106 { 16107 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 16108 data = ''; 16109 } 16110 16111 return BX.ajax({ 16112 'method': 'GET', 16113 'dataType': 'html', 16114 'url': url, 16115 'data': '', 16116 'onsuccess': callback 16117 }); 16118}; 16119 16120BX.ajax.getCaptcha = function(callback) 16121{ 16122 return BX.ajax.loadJSON('/bitrix/tools/ajax_captcha.php', callback); 16123}; 16124 16125BX.ajax.insertToNode = function(url, node) 16126{ 16127 node = BX(node); 16128 if (!!node) 16129 { 16130 var eventArgs = { cancel: false }; 16131 BX.onCustomEvent('onAjaxInsertToNode', [{ url: url, node: node, eventArgs: eventArgs }]); 16132 if(eventArgs.cancel === true) 16133 { 16134 return; 16135 } 16136 16137 var show = null; 16138 if (!tempDefaultConfig.denyShowWait) 16139 { 16140 show = BX.showWait(node); 16141 delete tempDefaultConfig.denyShowWait; 16142 } 16143 16144 return BX.ajax.get(url, function(data) { 16145 node.innerHTML = data; 16146 BX.closeWait(node, show); 16147 }); 16148 } 16149}; 16150 16151BX.ajax.post = function(url, data, callback) 16152{ 16153 data = BX.ajax.prepareData(data); 16154 16155 return BX.ajax({ 16156 'method': 'POST', 16157 'dataType': 'html', 16158 'url': url, 16159 'data': data, 16160 'onsuccess': callback 16161 }); 16162}; 16163 16164/** 16165 * BX.ajax with BX.Promise 16166 * 16167 * @param config 16168 * @returns {BX.Promise|false} 16169 */ 16170BX.ajax.promise = function(config) 16171{ 16172 var result = new BX.Promise(); 16173 16174 config.onsuccess = function(data) 16175 { 16176 result.fulfill(data); 16177 }; 16178 config.onfailure = function(reason, httpStatus, config) 16179 { 16180 result.reject({ 16181 reason: reason, 16182 data: httpStatus, 16183 ajaxConfig: config, 16184 xhr: config.xhr 16185 }); 16186 }; 16187 16188 var xhr = BX.ajax(config); 16189 if (xhr) 16190 { 16191 if (typeof config.onrequeststart === 'function') 16192 { 16193 config.onrequeststart(xhr); 16194 } 16195 } 16196 else 16197 { 16198 result.reject({ 16199 reason: "init", 16200 data: false 16201 }); 16202 } 16203 16204 return result; 16205}; 16206 16207/* load and execute external file script with onload emulation */ 16208BX.ajax.loadScriptAjax = function(script_src, callback, bPreload) 16209{ 16210 if (BX.type.isArray(script_src)) 16211 { 16212 for (var i=0,len=script_src.length;i<len;i++) 16213 { 16214 BX.ajax.loadScriptAjax(script_src[i], callback, bPreload); 16215 } 16216 } 16217 else 16218 { 16219 var script_src_test = script_src.replace(/\.js\?.*/, '.js'); 16220 16221 if (r.script_self.test(script_src_test)) return; 16222 if (r.script_self_window.test(script_src_test) && BX.CWindow) return; 16223 if (r.script_self_admin.test(script_src_test) && BX.admin) return; 16224 16225 if (typeof loadedScripts[script_src_test] == 'undefined') 16226 { 16227 if (!!bPreload) 16228 { 16229 loadedScripts[script_src_test] = ''; 16230 return BX.loadScript(script_src); 16231 } 16232 else 16233 { 16234 return BX.ajax({ 16235 url: script_src, 16236 method: 'GET', 16237 dataType: 'script', 16238 processData: true, 16239 emulateOnload: false, 16240 scriptsRunFirst: true, 16241 async: false, 16242 start: true, 16243 onsuccess: function(result) { 16244 loadedScripts[script_src_test] = result; 16245 if (callback) 16246 callback(result); 16247 } 16248 }); 16249 } 16250 } 16251 else if (callback) 16252 { 16253 callback(loadedScripts[script_src_test]); 16254 } 16255 } 16256}; 16257 16258/* non-xhr loadings */ 16259BX.ajax.loadJSON = function(url, data, callback, callback_failure) 16260{ 16261 if (BX.type.isFunction(data)) 16262 { 16263 callback_failure = callback; 16264 callback = data; 16265 data = ''; 16266 } 16267 16268 data = BX.ajax.prepareData(data); 16269 16270 if (data) 16271 { 16272 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 16273 data = ''; 16274 } 16275 16276 return BX.ajax({ 16277 'method': 'GET', 16278 'dataType': 'json', 16279 'url': url, 16280 'onsuccess': callback, 16281 'onfailure': callback_failure 16282 }); 16283}; 16284 16285var getLastContentTypeHeader = function (headers) { 16286 if (!BX.Type.isArray(headers)) 16287 { 16288 return null; 16289 } 16290 var lastHeader = headers 16291 .filter(function (header) { 16292 return header.name === 'Content-Type'; 16293 }) 16294 .pop(); 16295 16296 return lastHeader ? lastHeader.value : null; 16297}; 16298 16299/** 16300 * @see isValidAnalyticsData in ui.analytics 16301* */ 16302const isValidAnalyticsData = function (analytics) 16303{ 16304 if (!BX.Type.isPlainObject(analytics)) 16305 { 16306 console.error('BX.ajax: {analytics} must be an object.'); 16307 16308 return false; 16309 } 16310 16311 const requiredFields = ['event', 'tool', 'category']; 16312 for (const field of requiredFields) 16313 { 16314 if (!BX.Type.isStringFilled(analytics[field])) 16315 { 16316 console.error(`BX.ajax: The "${field}" property in the "analytics" object must be a non-empty string.`); 16317 16318 return false;
16319 } 16320 } 16321 16322 const additionalFields = ['p1', 'p2', 'p3', 'p4', 'p5']; 16323 for (const field of additionalFields) 16324 { 16325 const value = analytics[field]; 16326 if (!BX.Type.isStringFilled(value)) 16327 { 16328 continue; 16329 } 16330 16331 if (value.split('_').length > 2) 16332 { 16333 console.error(`BX.ajax: The "${field}" property (${value}) in the "analytics" object must be a string containing a single underscore.`); 16334 16335 return false; 16336 } 16337 } 16338 16339 return true; 16340}; 16341 16342const processAnalyticsDataToGetParameters = function(config) 16343{ 16344 const getParameters = {}; 16345 if (BX.Type.isStringFilled(config.analyticsLabel) || BX.Type.isPlainObject(config.analyticsLabel)) 16346 { 16347 getParameters.analyticsLabel = config.analyticsLabel; 16348 } 16349 16350 if (BX.Type.isPlainObject(config.analytics)) 16351 { 16352 if (config.analyticsLabel) 16353 { 16354 delete getParameters.analyticsLabel; 16355 console.error('BX.ajax: Only {analytics} or {analyticsLabel} should be used. If both are present, {analyticsLabel} will be ignored.'); 16356 } 16357 16358 if (isValidAnalyticsData(config.analytics)) 16359 { 16360 getParameters.st = config.analytics; 16361 } 16362 else 16363 { 16364 console.error('BX.ajax: {analytics} is invalid and is skipped.'); 16365 } 16366 } 16367 16368 return getParameters; 16369}; 16370 16371const prepareAjaxGetParameters = function(config) 16372{ 16373 let getParameters = config.getParameters || {}; 16374 getParameters = { ...getParameters, ...processAnalyticsDataToGetParameters(config) }; 16375 16376 if (typeof config.mode !== 'undefined') 16377 { 16378 getParameters.mode = config.mode; 16379 } 16380 if (config.navigation) 16381 { 16382 if (config.navigation.page) 16383 { 16384 getParameters.nav = 'page-' + config.navigation.page; 16385 } 16386 if (config.navigation.size) 16387 { 16388 if (getParameters.nav) 16389 { 16390 getParameters.nav += '-'; 16391 } 16392 else 16393 { 16394 getParameters.nav = ''; 16395 } 16396 getParameters.nav += 'size-' + config.navigation.size; 16397 } 16398 } 16399 16400 return getParameters; 16401}; 16402 16403var prepareAjaxConfig = function(config) 16404{ 16405 config = BX.type.isPlainObject(config) ? config : {}; 16406 16407 config.headers = config.headers || []; 16408 config.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 16409 if (BX.message.SITE_ID) 16410 { 16411 config.headers.push({name: 'X-Bitrix-Site-Id', value: BX.message.SITE_ID}); 16412 } 16413 16414 if (typeof config.json !== 'undefined') 16415 { 16416 if (!BX.type.isPlainObject(config.json)) 16417 { 16418 throw new Error('Wrong `config.json`, plain object expected.') 16419 } 16420 16421 config.headers.push({name: 'Content-Type', value: 'application/json'}); 16422 config.data = config.json; 16423 config.preparePost = false; 16424 } 16425 else if (config.data instanceof FormData) 16426 { 16427 config.preparePost = false; 16428 if (typeof config.signedParameters !== 'undefined') 16429 { 16430 config.data.append('signedParameters', config.signedParameters); 16431 } 16432 } 16433 else if (BX.type.isPlainObject(config.data) || BX.Type.isNil(config.data)) 16434 { 16435 config.data = BX.type.isPlainObject(config.data) ? config.data : {}; 16436 if (typeof config.signedParameters !== 'undefined') 16437 { 16438 config.data.signedParameters = config.signedParameters; 16439 } 16440 } 16441 16442 if (!config.method) 16443 { 16444 config.method = 'POST' 16445 } 16446 16447 return config; 16448}; 16449 16450var buildAjaxPromiseToRestoreCsrf = function(config, withoutRestoringCsrf) 16451{ 16452 withoutRestoringCsrf = withoutRestoringCsrf || false; 16453 var originalConfig = BX.clone(config); 16454 var request = null; 16455 16456 var onrequeststart = config.onrequeststart; 16457 config.onrequeststart = function(xhr) { 16458 request = xhr; 16459 if (BX.type.isFunction(onrequeststart)) 16460 { 16461 onrequeststart(xhr); 16462 } 16463 }; 16464 var onrequeststartOrig = originalConfig.onrequeststart; 16465 originalConfig.onrequeststart = function(xhr) { 16466 request = xhr; 16467 if (BX.type.isFunction(onrequeststartOrig)) 16468 { 16469 onrequeststartOrig(xhr); 16470 } 16471 }; 16472 16473 var promise = BX.ajax.promise(config); 16474 16475 return promise.then(function(response) { 16476 if (!withoutRestoringCsrf && BX.type.isPlainObject(response) && BX.type.isArray(response.errors)) 16477 { 16478 var csrfProblem = false; 16479 response.errors.forEach(function(error) { 16480 if (error.code === 'invalid_csrf' && error.customData.csrf) 16481 { 16482 BX.message({'bitrix_sessid': error.customData.csrf}); 16483 16484 originalConfig.headers = originalConfig.headers || []; 16485 originalConfig.headers = originalConfig.headers.filter(function(header) {
16486 return header && header.name !== 'X-Bitrix-Csrf-Token'; 16487 }); 16488 originalConfig.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 16489 16490 csrfProblem = true; 16491 } 16492 }); 16493 16494 if (csrfProblem) 16495 { 16496 return buildAjaxPromiseToRestoreCsrf(originalConfig, true); 16497 } 16498 } 16499 16500 if (!BX.type.isPlainObject(response) || response.status !== 'success') 16501 { 16502 var errorPromise = new BX.Promise(); 16503 errorPromise.reject(response); 16504 16505 return errorPromise; 16506 } 16507 16508 return response; 16509 }).catch(function(data) { 16510 var ajaxReject = new BX.Promise(); 16511 16512 var originalJsonResponse; 16513 if (BX.type.isPlainObject(data) && data.xhr && data.xhr.responseText) 16514 { 16515 try 16516 { 16517 originalJsonResponse = JSON.parse(data.xhr.responseText); 16518 data = originalJsonResponse; 16519 } 16520 catch (err) 16521 {} 16522 } 16523 16524 if (BX.type.isPlainObject(data) && data.status && data.hasOwnProperty('data')) 16525 { 16526 ajaxReject.reject(data); 16527 } 16528 else 16529 { 16530 ajaxReject.reject({ 16531 status: 'error', 16532 data: { 16533 ajaxRejectData: data 16534 }, 16535 errors: [ 16536 { 16537 code: 'NETWORK_ERROR', 16538 message: 'Network error' 16539 } 16540 ] 16541 }); 16542 } 16543 16544 return ajaxReject; 16545 }).then(function(response){ 16546 16547 var assetsLoaded = new BX.Promise(); 16548 16549 var headers = request.getAllResponseHeaders().trim().split(/[\r\n]+/); 16550 var headerMap = {}; 16551 headers.forEach(function (line) { 16552 var parts = line.split(': '); 16553 var header = parts.shift().toLowerCase(); 16554 headerMap[header] = parts.join(': '); 16555 }); 16556 16557 if (!headerMap['x-process-assets']) 16558 { 16559 assetsLoaded.fulfill(response); 16560 16561 return assetsLoaded; 16562 } 16563 16564 var assets = BX.prop.getObject(BX.prop.getObject(response, "data", {}), "assets", {}); 16565 16566 var inlineScripts = []; 16567 if (BX.Type.isArrayFilled(assets.string)) 16568 { 16569 assets.string 16570 .reduce(function(acc, item) { 16571 if (String(item).length > 0 && !acc.includes(item)) 16572 { 16573 acc.push(item); 16574 } 16575 16576 return acc; 16577 }, []) 16578 .forEach(function(item) { 16579 if (String(item).startsWith('<script type="extension/settings"')) 16580 { 16581 BX.html(document.head, item, { useAdjacentHTML: true }); 16582 } 16583 else 16584 { 16585 inlineScripts.push(item); 16586 } 16587 }); 16588 } 16589 16590 var promise = new Promise(function(resolve, reject) { 16591 var css = BX.prop.getArray(assets, "css", []); 16592 BX.load(css, function(){ 16593 BX.loadScript( 16594 BX.prop.getArray(assets, "js", []), 16595 resolve 16596 ); 16597 }); 16598 }); 16599 16600 promise.then(function(){ 16601 var stringAsset = inlineScripts.join('\n'); 16602 BX.html(document.head, stringAsset, { useAdjacentHTML: true }).then(function(){ 16603 assetsLoaded.fulfill(response); 16604 }); 16605 }); 16606 16607 return assetsLoaded; 16608 }); 16609}; 16610 16611/** 16612 * 16613 * @param {string} action 16614 * @param {Object} config 16615 * @param {?string|?Object} [config.analyticsLabel] 16616 * @param {?Object} [config.analytics] 16617 * @param {string} [config.analytics.event] 16618 * @param {string} [config.analytics.tool] 16619 * @param {string} [config.analytics.category] 16620 * @param {?string} [config.analytics.c_section] 16621 * @param {?string} [config.analytics.c_sub_section] 16622 * @param {?string} [config.analytics.c_element] 16623 * @param {?string} [config.analytics.type] 16624 * @param {?string} [config.analytics.p1] 16625 * @param {?string} [config.analytics.p2] 16626 * @param {?string} [config.analytics.p3] 16627 * @param {?string} [config.analytics.p4] 16628 * @param {?string} [config.analytics.p5] 16629 * @param {?('success' | 'error' | 'attempt' | 'cancel')} [config.analytics.status] 16630 * @param {string} [config.method='POST'] 16631 * @param {Object} [config.data] 16632 * @param {?Object} [config.getParameters] 16633 * @param {?Object} [config.headers] 16634 * @param {?Object} [config.timeout] 16635 * @param {Object} [config.navigation] 16636 * @param {number} [config.navigation.page] 16637 */ 16638BX.ajax.runAction = function(action, config) 16639{ 16640 config = prepareAjaxConfig(config); 16641 var getParameters = prepareAjaxGetParameters(config); 16642 getParameters.action = action; 16643
16644 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 16645 return buildAjaxPromiseToRestoreCsrf({ 16646 method: config.method, 16647 dataType: 'json', 16648 url: url, 16649 data: config.data, 16650 timeout: config.timeout, 16651 preparePost: config.preparePost, 16652 headers: config.headers, 16653 onrequeststart: config.onrequeststart, 16654 onprogress: config.onprogress, 16655 onprogressupload: config.onprogressupload 16656 }); 16657}; 16658 16659/** 16660 * 16661 * @param {string} component 16662 * @param {string} action 16663 * @param {Object} config 16664 * @param {?string|?Object} [config.analyticsLabel] 16665 * @param {?Object} [config.analytics] 16666 * @param {string} [config.analytics.event] 16667 * @param {string} [config.analytics.tool] 16668 * @param {string} [config.analytics.category] 16669 * @param {?string} [config.analytics.c_section] 16670 * @param {?string} [config.analytics.c_sub_section] 16671 * @param {?string} [config.analytics.c_element] 16672 * @param {?string} [config.analytics.type] 16673 * @param {?string} [config.analytics.p1] 16674 * @param {?string} [config.analytics.p2] 16675 * @param {?string} [config.analytics.p3] 16676 * @param {?string} [config.analytics.p4] 16677 * @param {?string} [config.analytics.p5] 16678 * @param {?string} [config.signedParameters] 16679 * @param {string} [config.method='POST'] 16680 * @param {string} [config.mode='ajax'] Ajax or class. 16681 * @param {Object} [config.data] 16682 * @param {?Object} [config.getParameters] 16683 * @param {?array} [config.headers] 16684 * @param {?number} [config.timeout] 16685 * @param {Object} [config.navigation] 16686 */ 16687BX.ajax.runComponentAction = function (component, action, config) 16688{ 16689 config = prepareAjaxConfig(config); 16690 config.mode = config.mode || 'ajax'; 16691 16692 var getParameters = prepareAjaxGetParameters(config); 16693 getParameters.c = component; 16694 getParameters.action = action; 16695
16696 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 16697 16698 return buildAjaxPromiseToRestoreCsrf({ 16699 method: config.method, 16700 dataType: 'json', 16701 url: url, 16702 data: config.data, 16703 timeout: config.timeout, 16704 preparePost: config.preparePost, 16705 headers: config.headers, 16706 onrequeststart: (config.onrequeststart ? config.onrequeststart : null), 16707 onprogress: config.onprogress, 16708 onprogressupload: config.onprogressupload 16709 }); 16710}; 16711 16712/* 16713arObs = [{ 16714 url: url, 16715 type: html|script|json|css, 16716 callback: function 16717}] 16718*/ 16719BX.ajax.load = function(arObs, callback) 16720{ 16721 if (!BX.type.isArray(arObs)) 16722 arObs = [arObs]; 16723 16724 var cnt = 0; 16725 16726 if (!BX.type.isFunction(callback)) 16727 callback = BX.DoNothing; 16728 16729 var handler = function(data) 16730 { 16731 if (BX.type.isFunction(this.callback)) 16732 this.callback(data); 16733 16734 if (++cnt >= len) 16735 callback(); 16736 }; 16737 16738 for (var i = 0, len = arObs.length; i<len; i++) 16739 { 16740 switch(arObs[i].type.toUpperCase()) 16741 { 16742 case 'SCRIPT': 16743 BX.loadScript([arObs[i].url], BX.proxy(handler, arObs[i])); 16744 break; 16745 case 'CSS': 16746 BX.loadCSS([arObs[i].url]); 16747 16748 if (++cnt >= len) 16749 callback(); 16750 break; 16751 case 'JSON': 16752 BX.ajax.loadJSON(arObs[i].url, BX.proxy(handler, arObs[i])); 16753 break; 16754 16755 default: 16756 BX.ajax.get(arObs[i].url, '', BX.proxy(handler, arObs[i])); 16757 break; 16758 } 16759 } 16760}; 16761 16762/* ajax form sending */ 16763BX.ajax.submit = function(obForm, callback) 16764{ 16765 if (!obForm.target) 16766 { 16767 if (null == obForm.BXFormTarget) 16768 { 16769 var frame_name = 'formTarget_' + Math.random(); 16770 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 16771 props: { 16772 name: frame_name, 16773 id: frame_name, 16774 src: 'javascript:void(0)' 16775 }, 16776 style: { 16777 display: 'none' 16778 } 16779 })); 16780 } 16781 16782 obForm.target = obForm.BXFormTarget.name; 16783 } 16784 16785 obForm.BXFormCallback = callback; 16786 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 16787 16788 BX.submit(obForm); 16789 16790 return false; 16791}; 16792 16793BX.ajax.submitComponentForm = function(obForm, container, bWait) 16794{ 16795 if (!obForm.target) 16796 { 16797 if (null == obForm.BXFormTarget) 16798 { 16799 var frame_name = 'formTarget_' + Math.random(); 16800 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 16801 props: { 16802 name: frame_name, 16803 id: frame_name, 16804 src: 'javascript:void(0)' 16805 }, 16806 style: { 16807 display: 'none' 16808 } 16809 })); 16810 } 16811 16812 obForm.target = obForm.BXFormTarget.name; 16813 } 16814 16815 if (!!bWait) 16816 var w = BX.showWait(container); 16817 16818 obForm.BXFormCallback = function(d) { 16819 if (!!bWait) 16820 BX.closeWait(w); 16821 16822 var callOnload = function(){ 16823 if(!!window.bxcompajaxframeonload) 16824 { 16825 setTimeout(function(){window.bxcompajaxframeonload();window.bxcompajaxframeonload=null;}, 10); 16826 } 16827 }; 16828 16829 BX(container).innerHTML = d; 16830 BX.onCustomEvent('onAjaxSuccess', [null,null,callOnload]); 16831 }; 16832 16833 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 16834 16835 return true; 16836}; 16837 16838// func will be executed in form context 16839BX.ajax._submit_callback = function() 16840{ 16841 //opera and IE8 triggers onload event even on empty iframe 16842 try 16843 { 16844 if(this.BXFormTarget.contentWindow.location.href.indexOf('http') != 0) 16845 return; 16846 } catch (e) { 16847 return; 16848 } 16849 16850 if (this.BXFormCallback) 16851 this.BXFormCallback.apply(this, [this.BXFormTarget.contentWindow.document.body.innerHTML]); 16852 16853 BX.unbindAll(this.BXFormTarget); 16854}; 16855 16856BX.ajax.prepareForm = function(obForm, data) 16857{ 16858 data = (!!data ? data : {}); 16859 var i, ii, el, 16860 _data = [], 16861 n = obForm.elements.length, 16862 files = 0, length = 0; 16863 if(!!obForm) 16864 { 16865 for (i = 0; i < n; i++) 16866 { 16867 el = obForm.elements[i]; 16868 if (el.disabled) 16869 continue; 16870 16871 if(!el.type) 16872 continue; 16873 16874 switch(el.type.toLowerCase()) 16875 { 16876 case 'text': 16877 case 'textarea': 16878 case 'password': 16879 case 'number': 16880 case 'hidden': 16881 case 'select-one': 16882 _data.push({name: el.name, value: el.value}); 16883 length += (el.name.length + el.value.length); 16884 break; 16885 case 'file': 16886 if (!!el.files) 16887 { 16888 for (ii = 0; ii < el.files.length; ii++) 16889 { 16890 files++; 16891 _data.push({name: el.name, value: el.files[ii], file : true}); 16892 length += el.files[ii].size; 16893 } 16894 } 16895 break; 16896 case 'radio':
16897 case 'checkbox': 16898 if(el.checked) 16899 { 16900 _data.push({name: el.name, value: el.value}); 16901 length += (el.name.length + el.value.length); 16902 } 16903 break; 16904 case 'select-multiple': 16905 for (var j = 0; j < el.options.length; j++) 16906 { 16907 if (el.options[j].selected) 16908 { 16909 _data.push({name : el.name, value : el.options[j].value}); 16910 length += (el.name.length + el.options[j].length); 16911 } 16912 } 16913 break; 16914 default: 16915 break; 16916 } 16917 } 16918 16919 i = 0; length = 0; 16920 var current = data, name, rest, pp, tmpKey; 16921 16922 while(i < _data.length) 16923 { 16924 var p = _data[i].name.indexOf('['); 16925 if (tmpKey) 16926 { 16927 current[_data[i].name] = {}; 16928 current[_data[i].name][tmpKey.replace(/\[|\]/gi, '')] = _data[i].value; 16929 current = data; 16930 tmpKey = null; 16931 i++; 16932 } 16933 else if (p == -1) 16934 { 16935 current[_data[i].name] = _data[i].value; 16936 current = data; 16937 i++; 16938 } 16939 else 16940 { 16941 name = _data[i].name.substring(0, p); 16942 rest = _data[i].name.substring(p+1); 16943 pp = rest.indexOf(']'); 16944 16945 if(pp == -1) 16946 { 16947 if (!current[name]) 16948 current[name] = []; 16949 current = data; 16950 i++; 16951 } 16952 else if(pp == 0) 16953 { 16954 if (!current[name]) 16955 current[name] = []; 16956 //No index specified - so take the next integer 16957 current = current[name]; 16958 _data[i].name = '' + current.length; 16959 if (rest.substring(pp+1).indexOf('[') === 0) 16960 tmpKey = rest.substring(0, pp) + rest.substring(pp+1); 16961 } 16962 else 16963 { 16964 if (!current[name]) 16965 current[name] = {}; 16966 //Now index name becomes and name and we go deeper into the array 16967 current = current[name]; 16968 _data[i].name = rest.substring(0, pp) + rest.substring(pp+1); 16969 } 16970 } 16971 } 16972 } 16973 return {data : data, filesCount : files, roughSize : length}; 16974}; 16975BX.ajax.submitAjax = function(obForm, config) 16976{ 16977 config = (config !== null && typeof config == "object" ? config : {}); 16978 config.url = (config["url"] || obForm.getAttribute("action")); 16979 16980 var additionalData = (config["data"] || {}); 16981 config.data = BX.ajax.prepareForm(obForm).data; 16982 for (var ii in additionalData) 16983 { 16984 if (additionalData.hasOwnProperty(ii)) 16985 { 16986 config.data[ii] = additionalData[ii]; 16987 } 16988 } 16989 16990 if (!window["FormData"]) 16991 { 16992 BX.ajax(config); 16993 } 16994 else 16995 { 16996 var isFile = function(item) 16997 { 16998 var res = Object.prototype.toString.call(item); 16999 return (res == '[object File]' || res == '[object Blob]'); 17000 }, 17001 appendToForm = function(fd, key, val) 17002 { 17003 if (!!val && typeof val == "object" && !isFile(val)) 17004 { 17005 for (var ii in val) 17006 { 17007 if (val.hasOwnProperty(ii)) 17008 { 17009 appendToForm(fd, (key == '' ? ii : key + '[' + ii + ']'), val[ii]); 17010 } 17011 } 17012 } 17013 else 17014 fd.append(key, (!!val ? val : '')); 17015 }, 17016 prepareData = function(arData) 17017 { 17018 var data = {}; 17019 if (null != arData) 17020 { 17021 if(typeof arData == 'object') 17022 { 17023 for(var i in arData) 17024 { 17025 if (arData.hasOwnProperty(i)) 17026 { 17027 var name = BX.util.urlencode(i); 17028 if(typeof arData[i] == 'object' && arData[i]["file"] !== true) 17029 data[name] = prepareData(arData[i]); 17030 else if (arData[i]["file"] === true) 17031 data[name] = arData[i]["value"]; 17032 else 17033 data[name] = BX.util.urlencode(arData[i]); 17034 } 17035 } 17036 } 17037 else 17038 data = BX.util.urlencode(arData); 17039 } 17040 return data; 17041 }, 17042 fd = new window.FormData(); 17043 17044 if (config.method !== 'POST') 17045 { 17046 config.data = BX.ajax.prepareData(config.data); 17047 if (config.data) 17048 { 17049 config.url += (config.url.indexOf('?') !== -1 ? "&" : "?") + config.data; 17050 config.data = ''; 17051 } 17052 } 17053 else 17054 { 17055 if (config.preparePost === true) 17056 config.data = prepareData(config.data); 17057 appendToForm(fd, '', config.data); 17058 config.data = fd; 17059 } 17060 17061 config.preparePost = false; 17062 config.start = false;
17063 17064 var xhr = BX.ajax(config); 17065 if (!!config["onprogress"]) 17066 xhr.upload.addEventListener( 17067 'progress', 17068 function(e){ 17069 var percent = null; 17070 if(e.lengthComputable && (e.total || e["totalSize"])) { 17071 percent = e.loaded * 100 / (e.total || e["totalSize"]); 17072 } 17073 config["onprogress"](e, percent); 17074 } 17075 ); 17076 xhr.send(fd); 17077 } 17078}; 17079 17080BX.ajax.UpdatePageData = function (arData) 17081{ 17082 if (arData.TITLE) 17083 BX.ajax.UpdatePageTitle(arData.TITLE); 17084 if (arData.WINDOW_TITLE || arData.TITLE) 17085 BX.ajax.UpdateWindowTitle(arData.WINDOW_TITLE || arData.TITLE); 17086 if (arData.NAV_CHAIN) 17087 BX.ajax.UpdatePageNavChain(arData.NAV_CHAIN); 17088 if (arData.CSS && arData.CSS.length > 0) 17089 BX.loadCSS(arData.CSS); 17090 if (arData.SCRIPTS && arData.SCRIPTS.length > 0) 17091 { 17092 var f = function(result,config,cb){ 17093 17094 if(!!config && BX.type.isArray(config.scripts)) 17095 { 17096 for(var i=0,l=arData.SCRIPTS.length;i<l;i++) 17097 { 17098 config.scripts.push({isInternal:false,JS:arData.SCRIPTS[i]}); 17099 } 17100 } 17101 else 17102 { 17103 BX.loadScript(arData.SCRIPTS,cb); 17104 } 17105 17106 BX.removeCustomEvent('onAjaxSuccess',f); 17107 }; 17108 BX.addCustomEvent('onAjaxSuccess',f); 17109 } 17110 else 17111 { 17112 var f1 = function(result,config,cb){ 17113 if(BX.type.isFunction(cb)) 17114 { 17115 cb(); 17116 } 17117 BX.removeCustomEvent('onAjaxSuccess',f1); 17118 }; 17119 BX.addCustomEvent('onAjaxSuccess', f1); 17120 } 17121}; 17122 17123BX.ajax.UpdatePageTitle = function(title) 17124{ 17125 var obTitle = BX('pagetitle'); 17126 if (obTitle) 17127 { 17128 BX.remove(obTitle.firstChild); 17129 if (!obTitle.firstChild) 17130 obTitle.appendChild(document.createTextNode(title)); 17131 else 17132 obTitle.insertBefore(document.createTextNode(title), obTitle.firstChild); 17133 } 17134}; 17135 17136BX.ajax.UpdateWindowTitle = function(title) 17137{ 17138 document.title = title; 17139}; 17140 17141BX.ajax.UpdatePageNavChain = function(nav_chain) 17142{ 17143 var obNavChain = BX('navigation'); 17144 if (obNavChain) 17145 { 17146 obNavChain.innerHTML = nav_chain; 17147 } 17148}; 17149 17150/* user options handling */ 17151BX.userOptions = { 17152 options: null, 17153 bSend: false, 17154 delay: 5000, 17155 path: '/bitrix/admin/user_options.php?' 17156}; 17157 17158BX.userOptions.setAjaxPath = function(url) 17159{ 17160 // eslint-disable-next-line no-console 17161 console.warn('BX.userOptions.setAjaxPath is deprecated. There is no way to change ajax path.'); 17162}; 17163BX.userOptions.save = function(category, name, valueName, value, common) 17164{ 17165 if (BX.userOptions.options === null) 17166 { 17167 BX.userOptions.options = {}; 17168 } 17169 17170 common = Boolean(common); 17171 BX.userOptions.options[`${category}.${name}.${valueName}`] = [category, name, valueName, value, common]; 17172 17173 const stringPackedValue = BX.userOptions.__get(); 17174 if (stringPackedValue) 17175 { 17176 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=/;`; 17177 } 17178 17179 if (!BX.userOptions.bSend) 17180 { 17181 BX.userOptions.bSend = true; 17182 setTimeout(() => { 17183 BX.userOptions.send(null); 17184 }, BX.userOptions.delay); 17185 } 17186}; 17187 17188BX.userOptions.send = function(callback) 17189{ 17190 const values = BX.userOptions.__get_values({ backwardCompatibility: true}); 17191 17192 BX.userOptions.options = null; 17193 BX.userOptions.bSend = false; 17194 17195 if (values) 17196 { 17197 document.cookie = `${BX.message('COOKIE_PREFIX')}_LAST_SETTINGS=; path=/;`; 17198 17199 BX.ajax.runAction( 17200 'main.userOption.saveOptions', 17201 { 17202 json: { 17203 newValues: values, 17204 }, 17205 }, 17206 ).then((response) => { 17207 if (BX.type.isFunction(callback)) 17208 { 17209 callback(response); 17210 } 17211 }); 17212 } 17213}; 17214 17215BX.userOptions.del = function(category, name, common, callback) 17216{ 17217 BX.ajax.runAction( 17218 'main.userOption.deleteOption', 17219 { 17220 json: { 17221 category, 17222 name, 17223 common, 17224 }, 17225 }, 17226 ).then((response) => { 17227 if (BX.type.isFunction(callback)) 17228 { 17229 callback(response); 17230 } 17231 }); 17232}; 17233 17234BX.userOptions.__get_values = function({ backwardCompatibility }) 17235{ 17236 if (!BX.userOptions || !BX.Type.isPlainObject(BX.userOptions.options)) 17237 { 17238 return null; 17239 } 17240 17241 const CATEGORY = 0; 17242 const NAME = 1; 17243 const VALUE_NAME = 2; 17244 const VALUE = 3; 17245 const IS_DEFAULT = 4; 17246 17247 const packedValues = { p: [] }; 17248 let currentIndex = -1; 17249 let previousOptionIdentifier = ''; 17250 17251 Object.entries(BX.userOptions.options).forEach(([key, userOption]) => { 17252 const category = userOption[CATEGORY]; 17253 const name = userOption[NAME]; 17254 const currentOptionIdentifier = `${category}.${name}`; 17255 17256 if (previousOptionIdentifier !== currentOptionIdentifier) 17257 { 17258 currentIndex++; 17259 packedValues.p.push({ 17260 c: category, 17261 n: name, 17262 v: {}, 17263 }); 17264 if (userOption[IS_DEFAULT] === true) 17265 { 17266 packedValues.p[currentIndex].d = 'Y'; 17267 } 17268 previousOptionIdentifier = currentOptionIdentifier; 17269 } 17270 17271 if (userOption[VALUE_NAME] === null) 17272 { 17273 packedValues.p[currentIndex].v = userOption[VALUE]; 17274 } 17275 else 17276 { 17277 let data = userOption[VALUE]; 17278 if (backwardCompatibility && Array.isArray(userOption[VALUE])) 17279 { 17280 data = userOption[VALUE].join(','); 17281 } 17282 packedValues.p[currentIndex].v[userOption[VALUE_NAME]] = data; 17283 } 17284 }); 17285 17286 return packedValues.p.length > 0 ? packedValues.p : null; 17287}; 17288 17289/** 17290 * @deprecated Use instead BX.userOptions.__get_values. 17291 * */ 17292BX.userOptions.__get = function() 17293{ 17294 if (!BX.userOptions.options) return ''; 17295 17296 var sParam = '', n = -1, prevParam = '', aOpt, i; 17297 17298 for (i in BX.userOptions.options) 17299 { 17300 if(BX.userOptions.options.hasOwnProperty(i)) 17301 { 17302 aOpt = BX.userOptions.options[i]; 17303 17304 if (prevParam != aOpt[0]+'.'+aOpt[1]) 17305 { 17306 n++; 17307 sParam += '&p['+n+'][c]='+BX.util.urlencode(aOpt[0]); 17308 sParam += '&p['+n+'][n]='+BX.util.urlencode(aOpt[1]); 17309 if (aOpt[4] == true) 17310 sParam += '&p['+n+'][d]=Y'; 17311 prevParam = aOpt[0]+'.'+aOpt[1]; 17312 } 17313 17314 var valueName = aOpt[2]; 17315 var value = aOpt[3]; 17316 17317 if (valueName === null) 17318 { 17319 sParam += '&p['+n+'][v]='+BX.util.urlencode(value); 17320 } 17321 else 17322 {
17323 sParam += '&p['+n+'][v]['+BX.util.urlencode(valueName)+']='+BX.util.urlencode(value); 17324 } 17325 } 17326 } 17327 17328 return sParam.substr(1); 17329}; 17330 17331BX.ajax.history = { 17332 expected_hash: '', 17333 17334 obParams: null, 17335 17336 obFrame: null, 17337 obImage: null, 17338 17339 obTimer: null, 17340 17341 bInited: false, 17342 bHashCollision: false, 17343 bPushState: !!(history.pushState && BX.type.isFunction(history.pushState)), 17344 17345 startState: null, 17346 17347 init: function(obParams) 17348 { 17349 if (BX.ajax.history.bInited) 17350 return; 17351 17352 this.obParams = obParams; 17353 var obCurrentState = this.obParams.getState(); 17354 17355 if (BX.ajax.history.bPushState) 17356 { 17357 BX.ajax.history.expected_hash = window.location.pathname; 17358 if (window.location.search) 17359 BX.ajax.history.expected_hash += window.location.search; 17360 17361 BX.ajax.history.put(obCurrentState, BX.ajax.history.expected_hash, '', true); 17362 // due to some strange thing, chrome calls popstate event on page start. so we should delay it 17363 setTimeout(function(){BX.bind(window, 'popstate', BX.ajax.history.__hashListener);}, 500); 17364 } 17365 else 17366 { 17367 BX.ajax.history.expected_hash = window.location.hash; 17368 17369 if (!BX.ajax.history.expected_hash || BX.ajax.history.expected_hash == '#') 17370 BX.ajax.history.expected_hash = '__bx_no_hash__'; 17371 17372 jsAjaxHistoryContainer.put(BX.ajax.history.expected_hash, obCurrentState); 17373 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 17374 17375 if (BX.browser.IsIE()) 17376 { 17377 BX.ajax.history.obFrame = document.createElement('IFRAME'); 17378 BX.hide_object(BX.ajax.history.obFrame); 17379 17380 document.body.appendChild(BX.ajax.history.obFrame); 17381 17382 BX.ajax.history.obFrame.contentWindow.document.open(); 17383 BX.ajax.history.obFrame.contentWindow.document.write(BX.ajax.history.expected_hash); 17384 BX.ajax.history.obFrame.contentWindow.document.close(); 17385 } 17386 else if (BX.browser.IsOpera()) 17387 { 17388 BX.ajax.history.obImage = document.createElement('IMG'); 17389 BX.hide_object(BX.ajax.history.obImage); 17390 17391 document.body.appendChild(BX.ajax.history.obImage); 17392 17393 BX.ajax.history.obImage.setAttribute('src', 'javascript:location.href = \'javascript:BX.ajax.history.__hashListener();\';'); 17394 } 17395 } 17396 17397 BX.ajax.history.bInited = true; 17398 }, 17399 17400 __hashListener: function(e) 17401 { 17402 e = e || window.event || {state:false}; 17403 17404 if (BX.ajax.history.bPushState) 17405 { 17406 BX.ajax.history.obParams.setState(e.state||BX.ajax.history.startState); 17407 } 17408 else 17409 { 17410 if (BX.ajax.history.obTimer) 17411 { 17412 window.clearTimeout(BX.ajax.history.obTimer); 17413 BX.ajax.history.obTimer = null; 17414 } 17415 17416 var current_hash; 17417 if (null != BX.ajax.history.obFrame) 17418 current_hash = BX.ajax.history.obFrame.contentWindow.document.body.innerText; 17419 else 17420 current_hash = window.location.hash; 17421 17422 if (!current_hash || current_hash == '#') 17423 current_hash = '__bx_no_hash__'; 17424 17425 if (current_hash.indexOf('#') == 0) 17426 current_hash = current_hash.substring(1); 17427 17428 if (current_hash != BX.ajax.history.expected_hash) 17429 { 17430 var state = jsAjaxHistoryContainer.get(current_hash); 17431 if (state) 17432 { 17433 BX.ajax.history.obParams.setState(state); 17434 17435 BX.ajax.history.expected_hash = current_hash; 17436 if (null != BX.ajax.history.obFrame) 17437 { 17438 var __hash = current_hash == '__bx_no_hash__' ? '' : current_hash; 17439 if (window.location.hash != __hash && window.location.hash != '#' + __hash) 17440 window.location.hash = __hash; 17441 } 17442 } 17443 } 17444 17445 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 17446 } 17447 }, 17448 17449 put: function(state, new_hash, new_hash1, bStartState) 17450 { 17451 if (this.bPushState) 17452 { 17453 if(!bStartState) 17454 { 17455 history.pushState(state, '', new_hash); 17456 } 17457 else 17458 { 17459 BX.ajax.history.startState = state; 17460 } 17461 } 17462 else 17463 { 17464 if (typeof new_hash1 != 'undefined') 17465 new_hash = new_hash1; 17466 else 17467 new_hash = 'view' + new_hash; 17468 17469 jsAjaxHistoryContainer.put(new_hash, state); 17470 BX.ajax.history.expected_hash = new_hash; 17471 17472 window.location.hash = BX.util.urlencode(new_hash); 17473 17474 if (null != BX.ajax.history.obFrame) 17475 { 17476 BX.ajax.history.obFrame.contentWindow.document.open(); 17477 BX.ajax.history.obFrame.contentWindow.document.write(new_hash); 17478 BX.ajax.history.obFrame.contentWindow.document.close(); 17479 } 17480 } 17481 }, 17482 17483 checkRedirectStart: function(param_name, param_value) 17484 { 17485 var current_hash = window.location.hash; 17486 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 17487 17488 var test = current_hash.substring(0, 5); 17489 if (test == 'view/' || test == 'view%') 17490 { 17491 BX.ajax.history.bHashCollision = true;
17492 document.write('<' + 'div id="__ajax_hash_collision_' + param_value + '" style="display: none;">'); 17493 } 17494 }, 17495 17496 checkRedirectFinish: function(param_name, param_value) 17497 { 17498 document.write('</div>'); 17499 17500 var current_hash = window.location.hash; 17501 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 17502 17503 BX.ready(function () 17504 { 17505 var test = current_hash.substring(0, 5); 17506 if (test == 'view/' || test == 'view%') 17507 { 17508 var obColNode = BX('__ajax_hash_collision_' + param_value); 17509 var obNode = obColNode.firstChild; 17510 BX.cleanNode(obNode); 17511 obColNode.style.display = 'block'; 17512 17513 // IE, Opera and Chrome automatically modifies hash with urlencode, but FF doesn't ;-( 17514 if (test != 'view%') 17515 current_hash = BX.util.urlencode(current_hash); 17516 17517 current_hash += (current_hash.indexOf('%3F') == -1 ? '%3F' : '%26') + param_name + '=' + param_value; 17518 17519 var url = '/bitrix/tools/ajax_redirector.php?hash=' + current_hash; 17520 17521 BX.ajax.insertToNode(url, obNode); 17522 } 17523 }); 17524 } 17525}; 17526 17527BX.ajax.component = function(node) 17528{ 17529 this.node = node; 17530}; 17531 17532BX.ajax.component.prototype.getState = function() 17533{ 17534 var state = { 17535 'node': this.node, 17536 'title': window.document.title, 17537 'data': BX(this.node).innerHTML 17538 }; 17539 17540 var obNavChain = BX('navigation'); 17541 if (null != obNavChain) 17542 state.nav_chain = obNavChain.innerHTML; 17543 17544 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistoryGetState", [state]); 17545 17546 return state; 17547}; 17548 17549BX.ajax.component.prototype.setState = function(state) 17550{ 17551 BX(state.node).innerHTML = state.data; 17552 BX.ajax.UpdatePageTitle(state.title); 17553 17554 if (state.nav_chain) 17555 { 17556 BX.ajax.UpdatePageNavChain(state.nav_chain); 17557 } 17558 17559 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistorySetState", [state]); 17560}; 17561 17562var jsAjaxHistoryContainer = { 17563 arHistory: {}, 17564 17565 put: function(hash, state) 17566 { 17567 this.arHistory[hash] = state; 17568 }, 17569 17570 get: function(hash) 17571 { 17572 return this.arHistory[hash]; 17573 } 17574}; 17575 17576 17577BX.ajax.FormData = function() 17578{ 17579 this.elements = []; 17580 this.files = []; 17581 this.features = {}; 17582 this.isSupported(); 17583 this.log('BX FormData init'); 17584}; 17585 17586BX.ajax.FormData.isSupported = function() 17587{ 17588 var f = new BX.ajax.FormData(); 17589 var result = f.features.supported; 17590 f = null; 17591 return result; 17592}; 17593 17594BX.ajax.FormData.prototype.log = function(o) 17595{ 17596 if (false) { 17597 try { 17598 if (BX.browser.IsIE()) o = JSON.stringify(o); 17599 console.log(o); 17600 } catch(e) {} 17601 } 17602}; 17603 17604BX.ajax.FormData.prototype.isSupported = function() 17605{ 17606 var f = {}; 17607 f.fileReader = (window.FileReader && window.FileReader.prototype.readAsBinaryString); 17608 f.readFormData = f.sendFormData = !!(window.FormData); 17609 f.supported = !!(f.readFormData && f.sendFormData); 17610 this.features = f; 17611 this.log('features:'); 17612 this.log(f); 17613 17614 return f.supported; 17615}; 17616 17617BX.ajax.FormData.prototype.append = function(name, value) 17618{ 17619 if (typeof(value) === 'object') { // seems to be files element 17620 this.files.push({'name': name, 'value':value}); 17621 } else { 17622 this.elements.push({'name': name, 'value':value}); 17623 } 17624}; 17625 17626BX.ajax.FormData.prototype.send = function(url, callbackOk, callbackProgress, callbackError) 17627{ 17628 this.log('FD send'); 17629 this.xhr = BX.ajax({ 17630 'method': 'POST', 17631 'dataType': 'html', 17632 'url': url, 17633 'onsuccess': callbackOk, 17634 'onfailure': callbackError, 17635 'start': false, 17636 'preparePost':false 17637 }); 17638 17639 if (callbackProgress) 17640 { 17641 this.xhr.upload.addEventListener( 17642 'progress', 17643 function(e) { 17644 if (e.lengthComputable) 17645 callbackProgress(e.loaded / (e.total || e.totalSize)); 17646 }, 17647 false 17648 ); 17649 } 17650 17651 if (this.features.readFormData && this.features.sendFormData) 17652 { 17653 var fd = new FormData(); 17654 this.log('use browser formdata'); 17655 for (var i in this.elements) 17656 { 17657 if(this.elements.hasOwnProperty(i)) 17658 fd.append(this.elements[i].name,this.elements[i].value); 17659 } 17660 for (i in this.files) 17661 { 17662 if(this.files.hasOwnProperty(i)) 17663 fd.append(this.files[i].name, this.files[i].value); 17664 } 17665 this.xhr.send(fd); 17666 } 17667 17668 return this.xhr; 17669}; 17670 17671BX.addCustomEvent('onAjaxFailure', BX.debug); 17672})(window); 17673 17674 17675(function (exports,main_core) { 17676 'use strict'; 17677 17678 var LazyLoad = { 17679 observer: null, 17680 images: {}, 17681 imageStatus: { 17682 hidden: -2, 17683 error: -1, 17684 "undefined": 0, 17685 inited: 1, 17686 loaded: 2 17687 }, 17688 imageTypes: { 17689 image: 1, 17690 background: 2 17691 },
17692 initObserver: function initObserver() { 17693 this.observer = new IntersectionObserver(this.onIntersection.bind(this), { 17694 rootMargin: '20% 0% 20% 0%', 17695 threshold: 0.10 17696 }); 17697 }, 17698 onIntersection: function onIntersection(entries) { 17699 entries.forEach(function (entry) { 17700 if (entry.isIntersecting) { 17701 this.showImage(entry.target); 17702 } 17703 }.bind(this)); 17704 }, 17705 registerImage: function registerImage(id, isImageVisibleCallback, options) { 17706 if (this.observer === null) { 17707 this.initObserver(); 17708 } 17709 17710 options = options || {}; 17711 17712 if (!main_core.Type.isStringFilled(id)) { 17713 return; 17714 } 17715 17716 if (main_core.Type.isObject(this.images[id])) { 17717 return; 17718 } 17719 17720 var element = document.getElementById(id); 17721 17722 if (!main_core.Type.isDomNode(element)) { 17723 return; 17724 } 17725 17726 this.observer.observe(element); 17727 this.images[id] = { 17728 id: id, 17729 node: null, 17730 src: null, 17731 dataSrcName: options.dataSrcName || 'src', 17732 type: null, 17733 func: main_core.Type.isFunction(isImageVisibleCallback) ? isImageVisibleCallback : null, 17734 status: this.imageStatus.undefined 17735 }; 17736 }, 17737 registerImages: function registerImages(ids, isImageVisibleCallback, options) { 17738 if (main_core.Type.isArray(ids)) { 17739 for (var i = 0, length = ids.length; i < length; i++) { 17740 this.registerImage(ids[i], isImageVisibleCallback, options); 17741 } 17742 } 17743 }, 17744 showImage: function showImage(imageNode) { 17745 var imageNodeId = imageNode.id; 17746 17747 if (!main_core.Type.isStringFilled(imageNodeId)) { 17748 return; 17749 } 17750 17751 var image = this.images[imageNodeId]; 17752 17753 if (!main_core.Type.isPlainObject(image)) { 17754 return; 17755 } 17756 17757 if (image.status == this.imageStatus.undefined) { 17758 this.initImage(image); 17759 } 17760 17761 if (image.status !== this.imageStatus.inited) { 17762 return; 17763 } 17764 17765 if (!image.node || !image.node.parentNode) { 17766 image.node = null; 17767 image.status = this.imageStatus.error; 17768 return; 17769 } 17770 17771 if (image.type == this.imageTypes.image) { 17772 image.node.src = image.src; 17773 } else { 17774 image.node.style.backgroundImage = "url('" + image.src + "')"; 17775 } 17776 17777 image.node.dataset[image.dataSrcName] = ""; 17778 image.status = this.imageStatus.loaded; 17779 }, 17780 showImages: function showImages(checkOwnVisibility) { 17781 checkOwnVisibility = checkOwnVisibility !== false; 17782 17783 for (var id in this.images) { 17784 if (!this.images.hasOwnProperty(id)) { 17785 continue; 17786 } 17787 17788 var image = this.images[id]; 17789 17790 if (image.status == this.imageStatus.undefined) { 17791 this.initImage(image); 17792 } 17793 17794 if (image.status !== this.imageStatus.inited) { 17795 continue; 17796 } 17797 17798 if (!image.node || !image.node.parentNode) { 17799 image.node = null; 17800 image.status = this.imageStatus.error; 17801 continue; 17802 } 17803 17804 var isImageVisible = true; 17805 17806 if (checkOwnVisibility && main_core.Type.isFunction(image.func)) { 17807 isImageVisible = image.func(image); 17808 } 17809 17810 if (isImageVisible === true && this.isElementVisibleOnScreen(image.node)) { 17811 if (image.type == this.imageTypes.image) { 17812 image.node.src = image.src; 17813 } else { 17814 image.node.style.backgroundImage = "url('" + image.src + "')"; 17815 } 17816 17817 image.node.dataset[image.dataSrcName] = ""; 17818 image.status = this.imageStatus.loaded; 17819 } 17820 } 17821 }, 17822 initImage: function initImage(image) { 17823 image.status = this.imageStatus.error; 17824 var node = document.getElementById(image.id); 17825 17826 if (!main_core.Type.isDomNode(node)) { 17827 return; 17828 } 17829 17830 var src = node.dataset[image.dataSrcName]; 17831 17832 if (main_core.Type.isStringFilled(src)) { 17833 image.node = node; 17834 image.src = src; 17835 image.status = this.imageStatus.inited; 17836 image.type = image.node.tagName.toLowerCase() == "img" ? this.imageTypes.image : this.imageTypes.background; 17837 } 17838 }, 17839 isElementVisibleOnScreen: function isElementVisibleOnScreen(element) { 17840 var coords = this.getElementCoords(element); 17841 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 17842 var windowBottom = windowTop + document.documentElement.clientHeight; 17843 coords.bottom = coords.top + element.offsetHeight; 17844 return coords.top > windowTop && coords.top < windowBottom || // topVisible 17845 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 17846 ; 17847 }, 17848 isElementVisibleOn2Screens: function isElementVisibleOn2Screens(element) { 17849 var windowHeight = document.documentElement.clientHeight; 17850 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 17851 var windowBottom = windowTop + windowHeight; 17852 var coords = this.getElementCoords(element); 17853 coords.bottom = coords.top + element.offsetHeight; 17854 windowTop -= windowHeight; 17855 windowBottom += windowHeight; 17856 return coords.top > windowTop && coords.top < windowBottom || // topVisible 17857 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 17858 ; 17859 }, 17860 getElementCoords: function getElementCoords(element) { 17861 var box = element.getBoundingClientRect(); 17862 return { 17863 originTop: box.top, 17864 originLeft: box.left, 17865 top: box.top + window.pageYOffset, 17866 left: box.left + window.pageXOffset 17867 }; 17868 }, 17869 onScroll: function onScroll() {}, 17870 clearImages: function clearImages() { 17871 this.images = []; 17872 } 17873 }; 17874 17875 exports.LazyLoad = LazyLoad; 17876 17877}((this.BX = this.BX || {}),BX)); 17878 17879 17880 17881(function (exports) { 17882 'use strict'; 17883 17884 var ParamBag = /*#__PURE__*/function () { 17885 function ParamBag() { 17886 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 17887 babelHelpers.classCallCheck(this, ParamBag); 17888 17889 if (!!params && babelHelpers.typeof(params) === 'object') { 17890 this.params = new Map(Object.entries(params)); 17891 } else { 17892 this.params = new Map(); 17893 } 17894 } 17895 17896 babelHelpers.createClass(ParamBag, [{ 17897 key: "getParam", 17898 value: function getParam(key) { 17899 var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 17900 17901 if (this.params.has(key)) { 17902 return this.params.get(key); 17903 } 17904 17905 return defaultValue; 17906 } 17907 }, { 17908 key: "setParam", 17909 value: function setParam(key, value) { 17910 this.params.set(key, value); 17911 } 17912 }, { 17913 key: "clear", 17914 value: function clear() { 17915 this.params.clear(); 17916 } 17917 }], [{ 17918 key: "create", 17919 value: function create() { 17920 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 17921 return new ParamBag(params); 17922 } 17923 }]); 17924 return ParamBag; 17925 }(); 17926 17927 exports.ParamBag = ParamBag; 17928 17929}((this.BX = this.BX || {}))); 17930 17931 17932 17933(function() { 17934 BX.FixFontSize = function(params) 17935 { 17936 var widthNode, computedStyles, width; 17937 17938 this.node = null; 17939 this.prevWindowSize = 0; 17940 this.prevWrapperSize = 0; 17941 this.mainWrapper = null; 17942 this.textWrapper = null; 17943 this.objList = params.objList; 17944 this.minFontSizeList = []; 17945 this.minFontSize = 0; 17946 17947 if (params.onresize) 17948 { 17949 this.prevWindowSize = window.innerWidth || document.documentElement.clientWidth; 17950 BX.bind(window, 'resize', BX.throttle(this.onResize, 350, this)); 17951 } 17952 17953 if (params.onAdaptiveResize) 17954 { 17955 widthNode = this.objList[0].scaleBy || this.objList[0].node; 17956 computedStyles = getComputedStyle(widthNode); 17957 this.prevWrapperSize = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 17958 BX.bind(window, 'resize', BX.throttle(this.onAdaptiveResize, 350, this)); 17959 } 17960 17961 this.createTestNodes(); 17962 this.decrease(); 17963 }; 17964 17965 BX.FixFontSize.prototype = 17966 { 17967 createTestNodes: function() 17968 { 17969 this.textWrapper = BX.create('div',{ 17970 style : { 17971 display : 'inline-block', 17972 whiteSpace : 'nowrap' 17973 } 17974 }); 17975 17976 this.mainWrapper = BX.create('div',{ 17977 style : { 17978 height : 0, 17979 overflow : 'hidden' 17980 }, 17981 children : [this.textWrapper] 17982 }); 17983 17984 }, 17985 insertTestNodes: function() 17986 { 17987 document.body.appendChild(this.mainWrapper); 17988 }, 17989 removeTestNodes: function() 17990 { 17991 document.body.removeChild(this.mainWrapper); 17992 }, 17993 decrease: function() 17994 { 17995 var width, 17996 fontSize, 17997 widthNode, 17998 computedStyles; 17999 18000 this.insertTestNodes(); 18001
18002 for(var i=this.objList.length-1; i>=0; i--) 18003 { 18004 widthNode = this.objList[i].scaleBy || this.objList[i].node; 18005 computedStyles = getComputedStyle(widthNode); 18006 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18007 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 18008 18009 this.textWrapperSetStyle(this.objList[i].node); 18010 18011 if(this.textWrapperInsertText(this.objList[i].node)) 18012 { 18013 while(this.textWrapper.offsetWidth > width && fontSize > 0) 18014 { 18015 this.textWrapper.style.fontSize = --fontSize + 'px'; 18016 } 18017 18018 if(this.objList[i].smallestValue) 18019 { 18020 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 18021 18022 this.minFontSizeList.push(this.objList[i].node) 18023 } 18024 else 18025 { 18026 this.objList[i].node.style.fontSize = fontSize + 'px'; 18027 } 18028 } 18029 } 18030 18031 if(this.minFontSizeList.length > 0) 18032 this.setMinFont(); 18033 18034 this.removeTestNodes(); 18035 18036 }, 18037 increase: function() 18038 { 18039 this.insertTestNodes(); 18040 var width, 18041 fontSize, 18042 widthNode, 18043 computedStyles; 18044 18045 this.insertTestNodes(); 18046 18047 for(var i=this.objList.length-1; i>=0; i--) 18048 { 18049 widthNode = this.objList[i].scaleBy || this.objList[i].node; 18050 computedStyles = getComputedStyle(widthNode); 18051 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18052 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 18053 18054 this.textWrapperSetStyle(this.objList[i].node); 18055 18056 if(this.textWrapperInsertText(this.objList[i].node)) 18057 { 18058 while(this.textWrapper.offsetWidth < width && fontSize < this.objList[i].maxFontSize) 18059 { 18060 this.textWrapper.style.fontSize = ++fontSize + 'px'; 18061 } 18062 18063 fontSize--; 18064 18065 if(this.objList[i].smallestValue) 18066 { 18067 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 18068 18069 this.minFontSizeList.push(this.objList[i].node) 18070 } 18071 else 18072 { 18073 this.objList[i].node.style.fontSize = fontSize + 'px'; 18074 } 18075 } 18076 } 18077 18078 if(this.minFontSizeList.length > 0) 18079 this.setMinFont(); 18080 18081 this.removeTestNodes(); 18082 }, 18083 setMinFont : function() 18084 { 18085 for(var i = this.minFontSizeList.length-1; i>=0; i--) 18086 { 18087 this.minFontSizeList[i].style.fontSize = this.minFontSize + 'px'; 18088 } 18089 18090 this.minFontSize = 0; 18091 }, 18092 onResize : function() 18093 { 18094 var width = window.innerWidth || document.documentElement.clientWidth; 18095 18096 if(this.prevWindowSize > width) 18097 this.decrease(); 18098 18099 else if (this.prevWindowSize < width) 18100 this.increase(); 18101 18102 this.prevWindowSize = width; 18103 }, 18104 onAdaptiveResize : function() 18105 { 18106 var widthNode = this.objList[0].scaleBy || this.objList[0].node, 18107 computedStyles = getComputedStyle(widthNode), 18108 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18109 18110 if (this.prevWrapperSize > width) 18111 this.decrease(); 18112 else if (this.prevWrapperSize < width) 18113 this.increase(); 18114 18115 this.prevWrapperSize = width; 18116 }, 18117 textWrapperInsertText : function(node) 18118 { 18119 if(node.textContent){ 18120 this.textWrapper.textContent = node.textContent; 18121 return true; 18122 } 18123 else if(node.innerText) 18124 { 18125 this.textWrapper.innerText = node.innerText; 18126 return true; 18127 } 18128 else { 18129 return false; 18130 } 18131 }, 18132 textWrapperSetStyle : function(node) 18133 { 18134 this.textWrapper.style.fontFamily = getComputedStyle(node)["font-family"]; 18135 this.textWrapper.style.fontSize = getComputedStyle(node)["font-size"]; 18136 this.textWrapper.style.fontStyle = getComputedStyle(node)["font-style"]; 18137 this.textWrapper.style.fontWeight = getComputedStyle(node)["font-weight"]; 18138 this.textWrapper.style.lineHeight = getComputedStyle(node)["line-height"]; 18139 } 18140 }; 18141 18142 BX.FixFontSize.init = function(params) 18143 { 18144 return new BX.FixFontSize(params); 18145 }; 18146})(); 18147 18148})(); 18149//# 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.