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