1;(function() { 2 3 if (typeof window.BX === 'function') 4 { 5 return; 6 } 7 8/** 9 * Babel external helpers 10 * (c) 2018 Babel 11 * @license MIT 12 */ 13(function (global) { 14 var babelHelpers = global.babelHelpers = {}; 15 16 function _typeof(obj) { 17 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 18 babelHelpers.typeof = _typeof = function (obj) { 19 return typeof obj; 20 }; 21 } else { 22 babelHelpers.typeof = _typeof = function (obj) { 23 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 24 }; 25 } 26 27 return _typeof(obj); 28 } 29 30 babelHelpers.typeof = _typeof; 31 var REACT_ELEMENT_TYPE; 32 33 function _createRawReactElement(type, props, key, children) { 34 if (!REACT_ELEMENT_TYPE) { 35 REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; 36 } 37 38 var defaultProps = type && type.defaultProps; 39 var childrenLength = arguments.length - 3; 40 41 if (!props && childrenLength !== 0) { 42 props = { 43 children: void 0 44 }; 45 } 46 47 if (props && defaultProps) { 48 for (var propName in defaultProps) { 49 if (props[propName] === void 0) { 50 props[propName] = defaultProps[propName]; 51 } 52 } 53 } else if (!props) { 54 props = defaultProps || {}; 55 } 56 57 if (childrenLength === 1) { 58 props.children = children; 59 } else if (childrenLength > 1) { 60 var childArray = new Array(childrenLength); 61 62 for (var i = 0; i < childrenLength; i++) { 63 childArray[i] = arguments[i + 3]; 64 } 65 66 props.children = childArray; 67 } 68 69 return { 70 $$typeof: REACT_ELEMENT_TYPE, 71 type: type, 72 key: key === undefined ? null : '' + key, 73 ref: null, 74 props: props, 75 _owner: null 76 }; 77 } 78 79 babelHelpers.jsx = _createRawReactElement; 80 81 function _asyncIterator(iterable) { 82 var method; 83 84 if (typeof Symbol === "function") { 85 if (Symbol.asyncIterator) { 86 method = iterable[Symbol.asyncIterator]; 87 if (method != null) return method.call(iterable); 88 } 89 90 if (Symbol.iterator) { 91 method = iterable[Symbol.iterator]; 92 if (method != null) return method.call(iterable); 93 } 94 } 95 96 throw new TypeError("Object is not async iterable"); 97 } 98 99 babelHelpers.asyncIterator = _asyncIterator; 100 101 function _AwaitValue(value) { 102 this.wrapped = value; 103 } 104 105 babelHelpers.AwaitValue = _AwaitValue; 106 107 function AsyncGenerator(gen) { 108 var front, back; 109 110 function send(key, arg) { 111 return new Promise(function (resolve, reject) { 112 var request = { 113 key: key, 114 arg: arg, 115 resolve: resolve, 116 reject: reject, 117 next: null 118 }; 119 120 if (back) { 121 back = back.next = request; 122 } else { 123 front = back = request; 124 resume(key, arg); 125 } 126 }); 127 } 128 129 function resume(key, arg) { 130 try { 131 var result = gen[key](arg); 132 var value = result.value; 133 var wrappedAwait = value instanceof babelHelpers.AwaitValue; 134 Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { 135 if (wrappedAwait) { 136 resume("next", arg); 137 return; 138 } 139 140 settle(result.done ? "return" : "normal", arg); 141 }, function (err) { 142 resume("throw", err); 143 }); 144 } catch (err) { 145 settle("throw", err); 146 } 147 } 148 149 function settle(type, value) { 150 switch (type) { 151 case "return": 152 front.resolve({ 153 value: value, 154 done: true 155 }); 156 break; 157 158 case "throw": 159 front.reject(value); 160 break; 161 162 default: 163 front.resolve({ 164 value: value, 165 done: false 166 }); 167 break; 168 } 169 170 front = front.next; 171 172 if (front) { 173 resume(front.key, front.arg); 174 } else { 175 back = null; 176 } 177 } 178 179 this._invoke = send; 180 181 if (typeof gen.return !== "function") { 182 this.return = undefined; 183 } 184 } 185 186 if (typeof Symbol === "function" && Symbol.asyncIterator) { 187 AsyncGenerator.prototype[Symbol.asyncIterator] = function () { 188 return this; 189 }; 190 } 191 192 AsyncGenerator.prototype.next = function (arg) { 193 return this._invoke("next", arg); 194 }; 195 196 AsyncGenerator.prototype.throw = function (arg) { 197 return this._invoke("throw", arg); 198 }; 199 200 AsyncGenerator.prototype.return = function (arg) { 201 return this._invoke("return", arg); 202 }; 203 204 babelHelpers.AsyncGenerator = AsyncGenerator; 205 206 function _wrapAsyncGenerator(fn) { 207 return function () { 208 return new babelHelpers.AsyncGenerator(fn.apply(this, arguments)); 209 }; 210 } 211 212 babelHelpers.wrapAsyncGenerator = _wrapAsyncGenerator; 213 214 function _awaitAsyncGenerator(value) { 215 return new babelHelpers.AwaitValue(value); 216 } 217 218 babelHelpers.awaitAsyncGenerator = _awaitAsyncGenerator; 219 220 function _asyncGeneratorDelegate(inner, awaitWrap) { 221 var iter = {}, 222 waiting = false;
223 224 function pump(key, value) { 225 waiting = true; 226 value = new Promise(function (resolve) { 227 resolve(inner[key](value)); 228 }); 229 return { 230 done: false, 231 value: awaitWrap(value) 232 }; 233 } 234 235 ; 236 237 if (typeof Symbol === "function" && Symbol.iterator) { 238 iter[Symbol.iterator] = function () { 239 return this; 240 }; 241 } 242 243 iter.next = function (value) { 244 if (waiting) { 245 waiting = false; 246 return value; 247 } 248 249 return pump("next", value); 250 }; 251 252 if (typeof inner.throw === "function") { 253 iter.throw = function (value) { 254 if (waiting) { 255 waiting = false; 256 throw value; 257 } 258 259 return pump("throw", value); 260 }; 261 } 262 263 if (typeof inner.return === "function") { 264 iter.return = function (value) { 265 return pump("return", value); 266 }; 267 } 268 269 return iter; 270 } 271 272 babelHelpers.asyncGeneratorDelegate = _asyncGeneratorDelegate; 273 274 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { 275 try { 276 var info = gen[key](arg); 277 var value = info.value; 278 } catch (error) { 279 reject(error); 280 return; 281 } 282 283 if (info.done) { 284 resolve(value); 285 } else { 286 Promise.resolve(value).then(_next, _throw); 287 } 288 } 289 290 function _asyncToGenerator(fn) { 291 return function () { 292 var self = this, 293 args = arguments; 294 return new Promise(function (resolve, reject) { 295 var gen = fn.apply(self, args); 296 297 function _next(value) { 298 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); 299 } 300 301 function _throw(err) { 302 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); 303 } 304 305 _next(undefined); 306 }); 307 }; 308 } 309 310 babelHelpers.asyncToGenerator = _asyncToGenerator; 311 312 function _classCallCheck(instance, Constructor) { 313 if (!(instance instanceof Constructor)) { 314 throw new TypeError("Cannot call a class as a function"); 315 } 316 } 317 318 babelHelpers.classCallCheck = _classCallCheck; 319 320 function _defineProperties(target, props) { 321 for (var i = 0; i < props.length; i++) { 322 var descriptor = props[i]; 323 descriptor.enumerable = descriptor.enumerable || false; 324 descriptor.configurable = true; 325 if ("value" in descriptor) descriptor.writable = true; 326 Object.defineProperty(target, descriptor.key, descriptor); 327 } 328 } 329 330 function _createClass(Constructor, protoProps, staticProps) { 331 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 332 if (staticProps) _defineProperties(Constructor, staticProps); 333 return Constructor; 334 } 335 336 babelHelpers.createClass = _createClass; 337 338 function _defineEnumerableProperties(obj, descs) { 339 for (var key in descs) { 340 var desc = descs[key]; 341 desc.configurable = desc.enumerable = true; 342 if ("value" in desc) desc.writable = true; 343 Object.defineProperty(obj, key, desc); 344 } 345 346 if (Object.getOwnPropertySymbols) { 347 var objectSymbols = Object.getOwnPropertySymbols(descs); 348 349 for (var i = 0; i < objectSymbols.length; i++) { 350 var sym = objectSymbols[i]; 351 var desc = descs[sym]; 352 desc.configurable = desc.enumerable = true; 353 if ("value" in desc) desc.writable = true; 354 Object.defineProperty(obj, sym, desc); 355 } 356 } 357 358 return obj; 359 } 360 361 babelHelpers.defineEnumerableProperties = _defineEnumerableProperties; 362 363 function _defaults(obj, defaults) { 364 var keys = Object.getOwnPropertyNames(defaults); 365 366 for (var i = 0; i < keys.length; i++) { 367 var key = keys[i]; 368 var value = Object.getOwnPropertyDescriptor(defaults, key); 369 370 if (value && value.configurable && obj[key] === undefined) { 371 Object.defineProperty(obj, key, value); 372 } 373 } 374 375 return obj; 376 } 377 378 babelHelpers.defaults = _defaults; 379 380 function _defineProperty(obj, key, value) { 381 if (key in obj) { 382 Object.defineProperty(obj, key, { 383 value: value, 384 enumerable: true, 385 configurable: true, 386 writable: true 387 }); 388 } else { 389 obj[key] = value; 390 } 391 392 return obj; 393 } 394 395 babelHelpers.defineProperty = _defineProperty; 396 397 function _extends() { 398 babelHelpers.extends = _extends = Object.assign || function (target) { 399 for (var i = 1; i < arguments.length; i++) { 400 var source = arguments[i]; 401 402 for (var key in source) { 403 if (Object.prototype.hasOwnProperty.call(source, key)) { 404 target[key] = source[key]; 405 } 406 } 407 } 408 409 return target; 410 }; 411 412 return _extends.apply(this, arguments); 413 } 414 415 babelHelpers.extends = _extends; 416 417 function _objectSpread(target) { 418 for (var i = 1; i < arguments.length; i++) { 419 var source = arguments[i] != null ? arguments[i] : {}; 420 var ownKeys = Object.keys(source); 421 422 if (typeof Object.getOwnPropertySymbols === 'function') { 423 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { 424 return Object.getOwnPropertyDescriptor(source, sym).enumerable; 425 })); 426 } 427 428 ownKeys.forEach(function (key) { 429 babelHelpers.defineProperty(target, key, source[key]); 430 }); 431 } 432 433 return target; 434 } 435 436 babelHelpers.objectSpread = _objectSpread; 437 438 function _inherits(subClass, superClass) { 439 if (typeof superClass !== "function" && superClass !== null) { 440 throw new TypeError("Super expression must either be null or a function"); 441 } 442 443 subClass.prototype = Object.create(superClass && superClass.prototype, { 444 constructor: { 445 value: subClass, 446 writable: true, 447 configurable: true 448 } 449 }); 450 if (superClass) babelHelpers.setPrototypeOf(subClass, superClass); 451 } 452 453 babelHelpers.inherits = _inherits; 454 455 function _inheritsLoose(subClass, superClass) { 456 subClass.prototype = Object.create(superClass.prototype); 457 subClass.prototype.constructor = subClass; 458 subClass.__proto__ = superClass; 459 } 460 461 babelHelpers.inheritsLoose = _inheritsLoose; 462
463 function _getPrototypeOf(o) { 464 babelHelpers.getPrototypeOf = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { 465 return o.__proto__ || Object.getPrototypeOf(o); 466 }; 467 return _getPrototypeOf(o); 468 } 469 470 babelHelpers.getPrototypeOf = _getPrototypeOf; 471 472 function _setPrototypeOf(o, p) { 473 babelHelpers.setPrototypeOf = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { 474 o.__proto__ = p; 475 return o; 476 }; 477 478 return _setPrototypeOf(o, p); 479 } 480 481 babelHelpers.setPrototypeOf = _setPrototypeOf; 482 483 function isNativeReflectConstruct() { 484 if (typeof Reflect === "undefined" || !Reflect.construct) return false; 485 if (Reflect.construct.sham) return false; 486 if (typeof Proxy === "function") return true; 487 488 try { 489 Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); 490 return true; 491 } catch (e) { 492 return false; 493 } 494 } 495 496 function _construct(Parent, args, Class) { 497 if (isNativeReflectConstruct()) { 498 babelHelpers.construct = _construct = Reflect.construct; 499 } else { 500 babelHelpers.construct = _construct = function _construct(Parent, args, Class) { 501 var a = [null]; 502 a.push.apply(a, args); 503 var Constructor = Function.bind.apply(Parent, a); 504 var instance = new Constructor(); 505 if (Class) babelHelpers.setPrototypeOf(instance, Class.prototype); 506 return instance; 507 }; 508 } 509 510 return _construct.apply(null, arguments); 511 } 512 513 babelHelpers.construct = _construct; 514 515 function _isNativeFunction(fn) { 516 return Function.toString.call(fn).indexOf("[native code]") !== -1; 517 } 518 519 babelHelpers.isNativeFunction = _isNativeFunction; 520 521 function _wrapNativeSuper(Class) { 522 var _cache = typeof Map === "function" ? new Map() : undefined; 523 524 babelHelpers.wrapNativeSuper = _wrapNativeSuper = function _wrapNativeSuper(Class) { 525 if (Class === null || !babelHelpers.isNativeFunction(Class)) return Class; 526 527 if (typeof Class !== "function") { 528 throw new TypeError("Super expression must either be null or a function"); 529 } 530 531 if (typeof _cache !== "undefined") { 532 if (_cache.has(Class)) return _cache.get(Class); 533 534 _cache.set(Class, Wrapper); 535 } 536 537 function Wrapper() { 538 return babelHelpers.construct(Class, arguments, babelHelpers.getPrototypeOf(this).constructor); 539 } 540 541 Wrapper.prototype = Object.create(Class.prototype, { 542 constructor: { 543 value: Wrapper, 544 enumerable: false, 545 writable: true, 546 configurable: true 547 } 548 }); 549 return babelHelpers.setPrototypeOf(Wrapper, Class); 550 }; 551 552 return _wrapNativeSuper(Class); 553 } 554 555 babelHelpers.wrapNativeSuper = _wrapNativeSuper; 556 557 function _instanceof(left, right) { 558 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { 559 return right[Symbol.hasInstance](left); 560 } else { 561 return left instanceof right; 562 } 563 } 564 565 babelHelpers.instanceof = _instanceof; 566 567 function _interopRequireDefault(obj) { 568 return obj && obj.__esModule ? obj : { 569 default: obj 570 }; 571 } 572 573 babelHelpers.interopRequireDefault = _interopRequireDefault; 574 575 function _interopRequireWildcard(obj) { 576 if (obj && obj.__esModule) { 577 return obj; 578 } else { 579 var newObj = {}; 580 581 if (obj != null) { 582 for (var key in obj) { 583 if (Object.prototype.hasOwnProperty.call(obj, key)) { 584 var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; 585 586 if (desc.get || desc.set) { 587 Object.defineProperty(newObj, key, desc); 588 } else { 589 newObj[key] = obj[key]; 590 } 591 } 592 } 593 } 594 595 newObj.default = obj; 596 return newObj; 597 } 598 } 599 600 babelHelpers.interopRequireWildcard = _interopRequireWildcard; 601 602 function _newArrowCheck(innerThis, boundThis) { 603 if (innerThis !== boundThis) { 604 throw new TypeError("Cannot instantiate an arrow function"); 605 } 606 } 607 608 babelHelpers.newArrowCheck = _newArrowCheck; 609 610 function _objectDestructuringEmpty(obj) { 611 if (obj == null) throw new TypeError("Cannot destructure undefined"); 612 } 613 614 babelHelpers.objectDestructuringEmpty = _objectDestructuringEmpty; 615 616 function _objectWithoutPropertiesLoose(source, excluded) { 617 if (source == null) return {}; 618 var target = {}; 619 var sourceKeys = Object.keys(source); 620 var key, i; 621 622 for (i = 0; i < sourceKeys.length; i++) { 623 key = sourceKeys[i]; 624 if (excluded.indexOf(key) >= 0) continue; 625 target[key] = source[key]; 626 } 627 628 return target; 629 } 630 631 babelHelpers.objectWithoutPropertiesLoose = _objectWithoutPropertiesLoose; 632 633 function _objectWithoutProperties(source, excluded) { 634 if (source == null) return {}; 635 var target = babelHelpers.objectWithoutPropertiesLoose(source, excluded); 636 var key, i; 637 638 if (Object.getOwnPropertySymbols) { 639 var sourceSymbolKeys = Object.getOwnPropertySymbols(source); 640 641 for (i = 0; i < sourceSymbolKeys.length; i++) { 642 key = sourceSymbolKeys[i]; 643 if (excluded.indexOf(key) >= 0) continue; 644 if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; 645 target[key] = source[key]; 646 } 647 } 648 649 return target; 650 } 651 652 babelHelpers.objectWithoutProperties = _objectWithoutProperties; 653 654 function _assertThisInitialized(self) { 655 if (self === void 0) { 656 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 657 } 658 659 return self; 660 } 661 662 babelHelpers.assertThisInitialized = _assertThisInitialized; 663 664 function _possibleConstructorReturn(self, call) { 665 if (call && (typeof call === "object" || typeof call === "function")) { 666 return call; 667 } 668 669 return babelHelpers.assertThisInitialized(self); 670 } 671 672 babelHelpers.possibleConstructorReturn = _possibleConstructorReturn; 673 674 function _superPropBase(object, property) { 675 while (!Object.prototype.hasOwnProperty.call(object, property)) { 676 object = babelHelpers.getPrototypeOf(object); 677 if (object === null) break; 678 } 679 680 return object; 681 } 682 683 babelHelpers.superPropBase = _superPropBase; 684 685 function _get(target, property, receiver) { 686 if (typeof Reflect !== "undefined" && Reflect.get) { 687 babelHelpers.get = _get = Reflect.get; 688 } else { 689 babelHelpers.get = _get = function _get(target, property, receiver) { 690 var base = babelHelpers.superPropBase(target, property); 691 if (!base) return; 692 var desc = Object.getOwnPropertyDescriptor(base, property); 693 694 if (desc.get) { 695 return desc.get.call(receiver); 696 } 697 698 return desc.value; 699 }; 700 } 701 702 return _get(target, property, receiver || target); 703 } 704 705 babelHelpers.get = _get; 706 707 function set(target, property, value, receiver) { 708 if (typeof Reflect !== "undefined" && Reflect.set) { 709 set = Reflect.set; 710 } else { 711 set = function set(target, property, value, receiver) { 712 var base = babelHelpers.superPropBase(target, property); 713 var desc; 714 715 if (base) { 716 desc = Object.getOwnPropertyDescriptor(base, property); 717 718 if (desc.set) { 719 desc.set.call(receiver, value); 720 return true; 721 } else if (!desc.writable) { 722 return false;
723 } 724 } 725 726 desc = Object.getOwnPropertyDescriptor(receiver, property); 727 728 if (desc) { 729 if (!desc.writable) { 730 return false; 731 } 732 733 desc.value = value; 734 Object.defineProperty(receiver, property, desc); 735 } else { 736 babelHelpers.defineProperty(receiver, property, value); 737 } 738 739 return true; 740 }; 741 } 742 743 return set(target, property, value, receiver); 744 } 745 746 function _set(target, property, value, receiver, isStrict) { 747 var s = set(target, property, value, receiver || target); 748 749 if (!s && isStrict) { 750 throw new Error('failed to set property'); 751 } 752 753 return value; 754 } 755 756 babelHelpers.set = _set; 757 758 function _taggedTemplateLiteral(strings, raw) { 759 if (!raw) { 760 raw = strings.slice(0); 761 } 762 763 return Object.freeze(Object.defineProperties(strings, { 764 raw: { 765 value: Object.freeze(raw) 766 } 767 })); 768 } 769 770 babelHelpers.taggedTemplateLiteral = _taggedTemplateLiteral; 771 772 function _taggedTemplateLiteralLoose(strings, raw) { 773 if (!raw) { 774 raw = strings.slice(0); 775 } 776 777 strings.raw = raw; 778 return strings; 779 } 780 781 babelHelpers.taggedTemplateLiteralLoose = _taggedTemplateLiteralLoose; 782 783 function _temporalRef(val, name) { 784 if (val === babelHelpers.temporalUndefined) { 785 throw new ReferenceError(name + " is not defined - temporal dead zone"); 786 } else { 787 return val; 788 } 789 } 790 791 babelHelpers.temporalRef = _temporalRef; 792 793 function _readOnlyError(name) { 794 throw new Error("\"" + name + "\" is read-only"); 795 } 796 797 babelHelpers.readOnlyError = _readOnlyError; 798 799 function _classNameTDZError(name) { 800 throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); 801 } 802 803 babelHelpers.classNameTDZError = _classNameTDZError; 804 babelHelpers.temporalUndefined = {}; 805 806 function _slicedToArray(arr, i) { 807 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArrayLimit(arr, i) || babelHelpers.nonIterableRest(); 808 } 809 810 babelHelpers.slicedToArray = _slicedToArray; 811 812 function _slicedToArrayLoose(arr, i) { 813 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArrayLimitLoose(arr, i) || babelHelpers.nonIterableRest(); 814 } 815 816 babelHelpers.slicedToArrayLoose = _slicedToArrayLoose; 817 818 function _toArray(arr) { 819 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArray(arr) || babelHelpers.nonIterableRest(); 820 } 821 822 babelHelpers.toArray = _toArray; 823 824 function _toConsumableArray(arr) { 825 return babelHelpers.arrayWithoutHoles(arr) || babelHelpers.iterableToArray(arr) || babelHelpers.nonIterableSpread(); 826 } 827 828 babelHelpers.toConsumableArray = _toConsumableArray; 829 830 function _arrayWithoutHoles(arr) { 831 if (Array.isArray(arr)) { 832 for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; 833 834 return arr2; 835 } 836 } 837 838 babelHelpers.arrayWithoutHoles = _arrayWithoutHoles; 839 840 function _arrayWithHoles(arr) { 841 if (Array.isArray(arr)) return arr; 842 } 843 844 babelHelpers.arrayWithHoles = _arrayWithHoles; 845 846 function _iterableToArray(iter) { 847 if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); 848 } 849 850 babelHelpers.iterableToArray = _iterableToArray; 851 852 function _iterableToArrayLimit(arr, i) { 853 var _arr = []; 854 var _n = true; 855 var _d = false; 856 var _e = undefined; 857 858 try { 859 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { 860 _arr.push(_s.value); 861 862 if (i && _arr.length === i) break; 863 } 864 } catch (err) { 865 _d = true; 866 _e = err; 867 } finally { 868 try { 869 if (!_n && _i["return"] != null) _i["return"](); 870 } finally { 871 if (_d) throw _e; 872 } 873 } 874 875 return _arr; 876 } 877 878 babelHelpers.iterableToArrayLimit = _iterableToArrayLimit; 879 880 function _iterableToArrayLimitLoose(arr, i) { 881 var _arr = []; 882 883 for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { 884 _arr.push(_step.value); 885 886 if (i && _arr.length === i) break; 887 } 888 889 return _arr; 890 } 891 892 babelHelpers.iterableToArrayLimitLoose = _iterableToArrayLimitLoose; 893 894 function _nonIterableSpread() { 895 throw new TypeError("Invalid attempt to spread non-iterable instance"); 896 } 897 898 babelHelpers.nonIterableSpread = _nonIterableSpread; 899 900 function _nonIterableRest() {
901 throw new TypeError("Invalid attempt to destructure non-iterable instance"); 902 } 903 904 babelHelpers.nonIterableRest = _nonIterableRest; 905 906 function _skipFirstGeneratorNext(fn) { 907 return function () { 908 var it = fn.apply(this, arguments); 909 it.next(); 910 return it; 911 }; 912 } 913 914 babelHelpers.skipFirstGeneratorNext = _skipFirstGeneratorNext; 915 916 function _toPropertyKey(key) { 917 if (typeof key === "symbol") { 918 return key; 919 } else { 920 return String(key); 921 } 922 } 923 924 babelHelpers.toPropertyKey = _toPropertyKey; 925 926 function _initializerWarningHelper(descriptor, context) { 927 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.'); 928 } 929 930 babelHelpers.initializerWarningHelper = _initializerWarningHelper; 931 932 function _initializerDefineProperty(target, property, descriptor, context) { 933 if (!descriptor) return; 934 Object.defineProperty(target, property, { 935 enumerable: descriptor.enumerable, 936 configurable: descriptor.configurable, 937 writable: descriptor.writable, 938 value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 939 }); 940 } 941 942 babelHelpers.initializerDefineProperty = _initializerDefineProperty; 943 944 function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { 945 var desc = {}; 946 Object['ke' + 'ys'](descriptor).forEach(function (key) { 947 desc[key] = descriptor[key]; 948 }); 949 desc.enumerable = !!desc.enumerable; 950 desc.configurable = !!desc.configurable; 951 952 if ('value' in desc || desc.initializer) { 953 desc.writable = true; 954 } 955 956 desc = decorators.slice().reverse().reduce(function (desc, decorator) { 957 return decorator(target, property, desc) || desc; 958 }, desc); 959 960 if (context && desc.initializer !== void 0) { 961 desc.value = desc.initializer ? desc.initializer.call(context) : void 0; 962 desc.initializer = undefined; 963 } 964 965 if (desc.initializer === void 0) { 966 Object['define' + 'Property'](target, property, desc); 967 desc = null; 968 } 969 970 return desc; 971 } 972 973 babelHelpers.applyDecoratedDescriptor = _applyDecoratedDescriptor; 974 var id = 0; 975 976 function _classPrivateFieldKey(name) { 977 return "__private_" + id++ + "_" + name; 978 } 979 980 babelHelpers.classPrivateFieldLooseKey = _classPrivateFieldKey; 981 982 function _classPrivateFieldBase(receiver, privateKey) { 983 if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { 984 throw new TypeError("attempted to use private field on non-instance"); 985 } 986 987 return receiver; 988 } 989 990 babelHelpers.classPrivateFieldLooseBase = _classPrivateFieldBase; 991 992 function _classPrivateFieldGet(receiver, privateMap) { 993 if (!privateMap.has(receiver)) { 994 throw new TypeError("attempted to get private field on non-instance"); 995 } 996 997 return privateMap.get(receiver).value; 998 } 999 1000 babelHelpers.classPrivateFieldGet = _classPrivateFieldGet; 1001 1002 function _classPrivateFieldSet(receiver, privateMap, value) { 1003 if (!privateMap.has(receiver)) { 1004 throw new TypeError("attempted to set private field on non-instance"); 1005 } 1006 1007 var descriptor = privateMap.get(receiver); 1008 1009 if (!descriptor.writable) { 1010 throw new TypeError("attempted to set read only private field"); 1011 } 1012 1013 descriptor.value = value; 1014 return value; 1015 } 1016 1017 babelHelpers.classPrivateFieldSet = _classPrivateFieldSet; 1018})(typeof global === "undefined" ? window : global); 1019 1020/** 1021 * Copyright (c) 2014-present, Facebook, Inc. 1022 * 1023 * This source code is licensed under the MIT license found in the 1024 * LICENSE file in the root directory of this source tree. 1025 */ 1026 1027!(function(global) { 1028 "use strict"; 1029 1030 var Op = Object.prototype; 1031 var hasOwn = Op.hasOwnProperty; 1032 var undefined; // More compressible than void 0. 1033 var $Symbol = typeof Symbol === "function" ? Symbol : {}; 1034 var iteratorSymbol = $Symbol.iterator || "@@iterator"; 1035 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; 1036 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; 1037 1038 // Define the runtime globally (as expected by generated code) as either 1039 // module.exports (if we're in a module) or a new, empty object. 1040 var runtime = global.regeneratorRuntime = {}; 1041 1042 function wrap(innerFn, outerFn, self, tryLocsList) { 1043 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. 1044 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; 1045 var generator = Object.create(protoGenerator.prototype); 1046 var context = new Context(tryLocsList || []); 1047 1048 // The ._invoke method unifies the implementations of the .next, 1049 // .throw, and .return methods. 1050 generator._invoke = makeInvokeMethod(innerFn, self, context); 1051 1052 return generator; 1053 } 1054 runtime.wrap = wrap; 1055 1056 // Try/catch helper to minimize deoptimizations. Returns a completion 1057 // record like context.tryEntries[i].completion. This interface could
vendor: 10,591 bytes, lines 1058-1351
1058 // have been (and was previously) designed to take a closure to be 1059 // invoked without arguments, but in all the cases we care about we 1060 // already have an existing method we want to call, so there's no need 1061 // to create a new function object. We can even get away with assuming 1062 // the method takes exactly one argument, since that happens to be true 1063 // in every case, so we don't have to touch the arguments object. The 1064 // only additional allocation required is the completion record, which 1065 // has a stable shape and so hopefully should be cheap to allocate. 1066 function tryCatch(fn, obj, arg) { 1067 try { 1068 return { type: "normal", arg: fn.call(obj, arg) }; 1069 } catch (err) { 1070 return { type: "throw", arg: err }; 1071 } 1072 } 1073 1074 var GenStateSuspendedStart = "suspendedStart"; 1075 var GenStateSuspendedYield = "suspendedYield"; 1076 var GenStateExecuting = "executing"; 1077 var GenStateCompleted = "completed"; 1078 1079 // Returning this object from the innerFn has the same effect as 1080 // breaking out of the dispatch switch statement. 1081 var ContinueSentinel = {}; 1082 1083 // Dummy constructor functions that we use as the .constructor and 1084 // .constructor.prototype properties for functions that return Generator 1085 // objects. For full spec compliance, you may wish to configure your 1086 // minifier not to mangle the names of these two functions. 1087 function Generator() {} 1088 function GeneratorFunction() {} 1089 function GeneratorFunctionPrototype() {} 1090 1091 // This is a polyfill for %IteratorPrototype% for environments that 1092 // don't natively support it. 1093 var IteratorPrototype = {}; 1094 IteratorPrototype[iteratorSymbol] = function () { 1095 return this; 1096 }; 1097 1098 var getProto = Object.getPrototypeOf; 1099 var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); 1100 if (NativeIteratorPrototype && 1101 NativeIteratorPrototype !== Op && 1102 hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { 1103 // This environment has a native %IteratorPrototype%; use it instead 1104 // of the polyfill. 1105 IteratorPrototype = NativeIteratorPrototype; 1106 } 1107 1108 var Gp = GeneratorFunctionPrototype.prototype = 1109 Generator.prototype = Object.create(IteratorPrototype); 1110 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; 1111 GeneratorFunctionPrototype.constructor = GeneratorFunction; 1112 GeneratorFunctionPrototype[toStringTagSymbol] = 1113 GeneratorFunction.displayName = "GeneratorFunction"; 1114 1115 // Helper for defining the .next, .throw, and .return methods of the 1116 // Iterator interface in terms of a single ._invoke method. 1117 function defineIteratorMethods(prototype) { 1118 ["next", "throw", "return"].forEach(function(method) { 1119 prototype[method] = function(arg) { 1120 return this._invoke(method, arg); 1121 }; 1122 }); 1123 } 1124 1125 runtime.isGeneratorFunction = function(genFun) { 1126 var ctor = typeof genFun === "function" && genFun.constructor; 1127 return ctor 1128 ? ctor === GeneratorFunction || 1129 // For the native GeneratorFunction constructor, the best we can 1130 // do is to check its .name property. 1131 (ctor.displayName || ctor.name) === "GeneratorFunction" 1132 : false; 1133 }; 1134 1135 runtime.mark = function(genFun) { 1136 if (Object.setPrototypeOf) { 1137 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); 1138 } else { 1139 genFun.__proto__ = GeneratorFunctionPrototype; 1140 if (!(toStringTagSymbol in genFun)) { 1141 genFun[toStringTagSymbol] = "GeneratorFunction"; 1142 } 1143 } 1144 genFun.prototype = Object.create(Gp); 1145 return genFun; 1146 }; 1147 1148 // Within the body of any async function, `await x` is transformed to 1149 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test 1150 // `hasOwn.call(value, "__await")` to determine if the yielded value is 1151 // meant to be awaited. 1152 runtime.awrap = function(arg) { 1153 return { __await: arg }; 1154 }; 1155 1156 function AsyncIterator(generator) { 1157 function invoke(method, arg, resolve, reject) { 1158 var record = tryCatch(generator[method], generator, arg); 1159 if (record.type === "throw") { 1160 reject(record.arg); 1161 } else { 1162 var result = record.arg; 1163 var value = result.value; 1164 if (value && 1165 typeof value === "object" && 1166 hasOwn.call(value, "__await")) { 1167 return Promise.resolve(value.__await).then(function(value) { 1168 invoke("next", value, resolve, reject); 1169 }, function(err) { 1170 invoke("throw", err, resolve, reject); 1171 }); 1172 } 1173 1174 return Promise.resolve(value).then(function(unwrapped) { 1175 // When a yielded Promise is resolved, its final value becomes 1176 // the .value of the Promise<{value,done}> result for the 1177 // current iteration. If the Promise is rejected, however, the 1178 // result for this iteration will be rejected with the same 1179 // reason. Note that rejections of yielded Promises are not 1180 // thrown back into the generator function, as is the case 1181 // when an awaited Promise is rejected. This difference in 1182 // behavior between yield and await is important, because it 1183 // allows the consumer to decide what to do with the yielded 1184 // rejection (swallow it and continue, manually .throw it back 1185 // into the generator, abandon iteration, whatever). With 1186 // await, by contrast, there is no opportunity to examine the 1187 // rejection reason outside the generator function, so the 1188 // only option is to throw it from the await expression, and 1189 // let the generator function handle the exception. 1190 result.value = unwrapped; 1191 resolve(result); 1192 }, reject); 1193 } 1194 } 1195 1196 var previousPromise; 1197 1198 function enqueue(method, arg) { 1199 function callInvokeWithMethodAndArg() { 1200 return new Promise(function(resolve, reject) { 1201 invoke(method, arg, resolve, reject); 1202 }); 1203 } 1204 1205 return previousPromise = 1206 // If enqueue has been called before, then we want to wait until 1207 // all previous Promises have been resolved before calling invoke, 1208 // so that results are always delivered in the correct order. If 1209 // enqueue has not been called before, then it is important to 1210 // call invoke immediately, without waiting on a callback to fire, 1211 // so that the async generator function has the opportunity to do 1212 // any necessary setup in a predictable way. This predictability 1213 // is why the Promise constructor synchronously invokes its 1214 // executor callback, and why async functions synchronously 1215 // execute code before the first await. Since we implement simple 1216 // async functions in terms of async generators, it is especially 1217 // important to get this right, even though it requires care. 1218 previousPromise ? previousPromise.then( 1219 callInvokeWithMethodAndArg, 1220 // Avoid propagating failures to Promises returned by later 1221 // invocations of the iterator. 1222 callInvokeWithMethodAndArg 1223 ) : callInvokeWithMethodAndArg(); 1224 } 1225 1226 // Define the unified helper method that is used to implement .next, 1227 // .throw, and .return (see defineIteratorMethods). 1228 this._invoke = enqueue; 1229 } 1230 1231 defineIteratorMethods(AsyncIterator.prototype); 1232 AsyncIterator.prototype[asyncIteratorSymbol] = function () { 1233 return this; 1234 }; 1235 runtime.AsyncIterator = AsyncIterator; 1236 1237 // Note that simple async functions are implemented on top of 1238 // AsyncIterator objects; they just return a Promise for the value of 1239 // the final result produced by the iterator. 1240 runtime.async = function(innerFn, outerFn, self, tryLocsList) { 1241 var iter = new AsyncIterator( 1242 wrap(innerFn, outerFn, self, tryLocsList) 1243 ); 1244 1245 return runtime.isGeneratorFunction(outerFn) 1246 ? iter // If outerFn is a generator, return the full iterator. 1247 : iter.next().then(function(result) { 1248 return result.done ? result.value : iter.next(); 1249 }); 1250 }; 1251 1252 function makeInvokeMethod(innerFn, self, context) { 1253 var state = GenStateSuspendedStart; 1254 1255 return function invoke(method, arg) { 1256 if (state === GenStateExecuting) { 1257 throw new Error("Generator is already running"); 1258 } 1259 1260 if (state === GenStateCompleted) { 1261 if (method === "throw") { 1262 throw arg; 1263 } 1264 1265 // Be forgiving, per 25.3.3.3.3 of the spec: 1266 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume 1267 return doneResult(); 1268 } 1269 1270 context.method = method; 1271 context.arg = arg; 1272 1273 while (true) { 1274 var delegate = context.delegate; 1275 if (delegate) { 1276 var delegateResult = maybeInvokeDelegate(delegate, context); 1277 if (delegateResult) { 1278 if (delegateResult === ContinueSentinel) continue; 1279 return delegateResult; 1280 } 1281 } 1282 1283 if (context.method === "next") { 1284 // Setting context._sent for legacy support of Babel's 1285 // function.sent implementation. 1286 context.sent = context._sent = context.arg; 1287 1288 } else if (context.method === "throw") { 1289 if (state === GenStateSuspendedStart) { 1290 state = GenStateCompleted; 1291 throw context.arg; 1292 } 1293 1294 context.dispatchException(context.arg); 1295 1296 } else if (context.method === "return") { 1297 context.abrupt("return", context.arg); 1298 } 1299 1300 state = GenStateExecuting; 1301 1302 var record = tryCatch(innerFn, self, context); 1303 if (record.type === "normal") { 1304 // If an exception is thrown from innerFn, we leave state === 1305 // GenStateExecuting and loop back for another invocation. 1306 state = context.done 1307 ? GenStateCompleted 1308 : GenStateSuspendedYield; 1309 1310 if (record.arg === ContinueSentinel) { 1311 continue; 1312 } 1313 1314 return { 1315 value: record.arg, 1316 done: context.done 1317 }; 1318 1319 } else if (record.type === "throw") { 1320 state = GenStateCompleted; 1321 // Dispatch the exception by looping back around to the 1322 // context.dispatchException(context.arg) call above. 1323 context.method = "throw"; 1324 context.arg = record.arg; 1325 } 1326 } 1327 }; 1328 } 1329 1330 // Call delegate.iterator[context.method](context.arg) and handle the 1331 // result, either by returning a { value, done } result from the 1332 // delegate iterator, or by modifying context.method and context.arg, 1333 // setting context.delegate to null, and returning the ContinueSentinel. 1334 function maybeInvokeDelegate(delegate, context) { 1335 var method = delegate.iterator[context.method]; 1336 if (method === undefined) { 1337 // A .throw or .return when the delegate iterator has no .throw 1338 // method always terminates the yield* loop. 1339 context.delegate = null; 1340 1341 if (context.method === "throw") { 1342 if (delegate.iterator.return) { 1343 // If the delegate iterator has a return method, give it a 1344 // chance to clean up. 1345 context.method = "return"; 1346 context.arg = undefined; 1347 maybeInvokeDelegate(delegate, context); 1348 1349 if (context.method === "throw") { 1350 // If maybeInvokeDelegate(context) changed context.method from 1351 // "return" to "throw", let that override the TypeError below.
vendor: 4,172 bytes, lines 1352-1505
1352 return ContinueSentinel; 1353 } 1354 } 1355 1356 context.method = "throw"; 1357 context.arg = new TypeError( 1358 "The iterator does not provide a 'throw' method"); 1359 } 1360 1361 return ContinueSentinel; 1362 } 1363 1364 var record = tryCatch(method, delegate.iterator, context.arg); 1365 1366 if (record.type === "throw") { 1367 context.method = "throw"; 1368 context.arg = record.arg; 1369 context.delegate = null; 1370 return ContinueSentinel; 1371 } 1372 1373 var info = record.arg; 1374 1375 if (! info) { 1376 context.method = "throw"; 1377 context.arg = new TypeError("iterator result is not an object"); 1378 context.delegate = null; 1379 return ContinueSentinel; 1380 } 1381 1382 if (info.done) { 1383 // Assign the result of the finished delegate to the temporary 1384 // variable specified by delegate.resultName (see delegateYield). 1385 context[delegate.resultName] = info.value; 1386 1387 // Resume execution at the desired location (see delegateYield). 1388 context.next = delegate.nextLoc; 1389 1390 // If context.method was "throw" but the delegate handled the 1391 // exception, let the outer generator proceed normally. If 1392 // context.method was "next", forget context.arg since it has been 1393 // "consumed" by the delegate iterator. If context.method was 1394 // "return", allow the original .return call to continue in the 1395 // outer generator. 1396 if (context.method !== "return") { 1397 context.method = "next"; 1398 context.arg = undefined; 1399 } 1400 1401 } else { 1402 // Re-yield the result returned by the delegate method. 1403 return info; 1404 } 1405 1406 // The delegate iterator is finished, so forget it and continue with 1407 // the outer generator. 1408 context.delegate = null; 1409 return ContinueSentinel; 1410 } 1411 1412 // Define Generator.prototype.{next,throw,return} in terms of the 1413 // unified ._invoke helper method. 1414 defineIteratorMethods(Gp); 1415 1416 Gp[toStringTagSymbol] = "Generator"; 1417 1418 // A Generator should always return itself as the iterator object when the 1419 // @@iterator function is called on it. Some browsers' implementations of the 1420 // iterator prototype chain incorrectly implement this, causing the Generator 1421 // object to not be returned from this call. This ensures that doesn't happen. 1422 // See https://github.com/facebook/regenerator/issues/274 for more details. 1423 Gp[iteratorSymbol] = function() { 1424 return this; 1425 }; 1426 1427 Gp.toString = function() { 1428 return "[object Generator]"; 1429 }; 1430 1431 function pushTryEntry(locs) { 1432 var entry = { tryLoc: locs[0] }; 1433 1434 if (1 in locs) { 1435 entry.catchLoc = locs[1]; 1436 } 1437 1438 if (2 in locs) { 1439 entry.finallyLoc = locs[2]; 1440 entry.afterLoc = locs[3]; 1441 } 1442 1443 this.tryEntries.push(entry); 1444 } 1445 1446 function resetTryEntry(entry) { 1447 var record = entry.completion || {}; 1448 record.type = "normal"; 1449 delete record.arg; 1450 entry.completion = record; 1451 } 1452 1453 function Context(tryLocsList) { 1454 // The root entry object (effectively a try statement without a catch 1455 // or a finally block) gives us a place to store values thrown from 1456 // locations where there is no enclosing try statement. 1457 this.tryEntries = [{ tryLoc: "root" }]; 1458 tryLocsList.forEach(pushTryEntry, this); 1459 this.reset(true); 1460 } 1461 1462 runtime.keys = function(object) { 1463 var keys = []; 1464 for (var key in object) { 1465 keys.push(key); 1466 } 1467 keys.reverse(); 1468 1469 // Rather than returning an object with a next method, we keep 1470 // things simple and return the next function itself. 1471 return function next() { 1472 while (keys.length) { 1473 var key = keys.pop(); 1474 if (key in object) { 1475 next.value = key; 1476 next.done = false; 1477 return next; 1478 } 1479 } 1480 1481 // To avoid creating an additional object, we just hang the .value 1482 // and .done properties off the next function object itself. This 1483 // also ensures that the minifier will not anonymize the function. 1484 next.done = true; 1485 return next; 1486 }; 1487 }; 1488 1489 function values(iterable) { 1490 if (iterable) { 1491 var iteratorMethod = iterable[iteratorSymbol]; 1492 if (iteratorMethod) { 1493 return iteratorMethod.call(iterable); 1494 } 1495 1496 if (typeof iterable.next === "function") { 1497 return iterable; 1498 } 1499 1500 if (!isNaN(iterable.length)) { 1501 var i = -1, next = function next() { 1502 while (++i < iterable.length) { 1503 if (hasOwn.call(iterable, i)) { 1504 next.value = iterable[i]; 1505 next.done = false;
1506 return next; 1507 } 1508 } 1509 1510 next.value = undefined; 1511 next.done = true; 1512 1513 return next; 1514 }; 1515 1516 return next.next = next; 1517 } 1518 } 1519 1520 // Return an iterator with no values. 1521 return { next: doneResult }; 1522 } 1523 runtime.values = values; 1524 1525 function doneResult() { 1526 return { value: undefined, done: true }; 1527 } 1528 1529 Context.prototype = { 1530 constructor: Context, 1531 1532 reset: function(skipTempReset) { 1533 this.prev = 0; 1534 this.next = 0; 1535 // Resetting context._sent for legacy support of Babel's 1536 // function.sent implementation. 1537 this.sent = this._sent = undefined; 1538 this.done = false; 1539 this.delegate = null; 1540 1541 this.method = "next"; 1542 this.arg = undefined; 1543 1544 this.tryEntries.forEach(resetTryEntry); 1545 1546 if (!skipTempReset) { 1547 for (var name in this) { 1548 // Not sure about the optimal order of these conditions: 1549 if (name.charAt(0) === "t" && 1550 hasOwn.call(this, name) && 1551 !isNaN(+name.slice(1))) { 1552 this[name] = undefined; 1553 } 1554 } 1555 } 1556 }, 1557 1558 stop: function() { 1559 this.done = true; 1560 1561 var rootEntry = this.tryEntries[0]; 1562 var rootRecord = rootEntry.completion; 1563 if (rootRecord.type === "throw") { 1564 throw rootRecord.arg; 1565 } 1566 1567 return this.rval; 1568 }, 1569 1570 dispatchException: function(exception) { 1571 if (this.done) { 1572 throw exception; 1573 } 1574 1575 var context = this; 1576 function handle(loc, caught) { 1577 record.type = "throw"; 1578 record.arg = exception; 1579 context.next = loc; 1580 1581 if (caught) { 1582 // If the dispatched exception was caught by a catch block, 1583 // then let that catch block handle the exception normally. 1584 context.method = "next"; 1585 context.arg = undefined; 1586 } 1587 1588 return !! caught; 1589 } 1590 1591 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1592 var entry = this.tryEntries[i]; 1593 var record = entry.completion; 1594 1595 if (entry.tryLoc === "root") { 1596 // Exception thrown outside of any try block that could handle 1597 // it, so set the completion value of the entire function to 1598 // throw the exception. 1599 return handle("end"); 1600 } 1601 1602 if (entry.tryLoc <= this.prev) { 1603 var hasCatch = hasOwn.call(entry, "catchLoc"); 1604 var hasFinally = hasOwn.call(entry, "finallyLoc"); 1605 1606 if (hasCatch && hasFinally) { 1607 if (this.prev < entry.catchLoc) { 1608 return handle(entry.catchLoc, true); 1609 } else if (this.prev < entry.finallyLoc) { 1610 return handle(entry.finallyLoc); 1611 } 1612 1613 } else if (hasCatch) { 1614 if (this.prev < entry.catchLoc) { 1615 return handle(entry.catchLoc, true); 1616 } 1617 1618 } else if (hasFinally) { 1619 if (this.prev < entry.finallyLoc) { 1620 return handle(entry.finallyLoc); 1621 } 1622 1623 } else { 1624 throw new Error("try statement without catch or finally"); 1625 } 1626 } 1627 } 1628 }, 1629 1630 abrupt: function(type, arg) { 1631 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1632 var entry = this.tryEntries[i]; 1633 if (entry.tryLoc <= this.prev && 1634 hasOwn.call(entry, "finallyLoc") && 1635 this.prev < entry.finallyLoc) { 1636 var finallyEntry = entry; 1637 break; 1638 } 1639 } 1640 1641 if (finallyEntry && 1642 (type === "break" || 1643 type === "continue") && 1644 finallyEntry.tryLoc <= arg && 1645 arg <= finallyEntry.finallyLoc) { 1646 // Ignore the finally entry if control is not jumping to a 1647 // location outside the try/catch block. 1648 finallyEntry = null; 1649 } 1650 1651 var record = finallyEntry ? finallyEntry.completion : {}; 1652 record.type = type; 1653 record.arg = arg; 1654 1655 if (finallyEntry) { 1656 this.method = "next"; 1657 this.next = finallyEntry.finallyLoc; 1658 return ContinueSentinel; 1659 } 1660 1661 return this.complete(record); 1662 }, 1663 1664 complete: function(record, afterLoc) { 1665 if (record.type === "throw") { 1666 throw record.arg; 1667 } 1668 1669 if (record.type === "break" || 1670 record.type === "continue") { 1671 this.next = record.arg; 1672 } else if (record.type === "return") { 1673 this.rval = this.arg = record.arg; 1674 this.method = "return"; 1675 this.next = "end"; 1676 } else if (record.type === "normal" && afterLoc) { 1677 this.next = afterLoc; 1678 } 1679 1680 return ContinueSentinel; 1681 }, 1682 1683 finish: function(finallyLoc) { 1684 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1685 var entry = this.tryEntries[i]; 1686 if (entry.finallyLoc === finallyLoc) { 1687 this.complete(entry.completion, entry.afterLoc); 1688 resetTryEntry(entry); 1689 return ContinueSentinel; 1690 } 1691 } 1692 }, 1693 1694 "catch": function(tryLoc) { 1695 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1696 var entry = this.tryEntries[i]; 1697 if (entry.tryLoc === tryLoc) { 1698 var record = entry.completion; 1699 if (record.type === "throw") { 1700 var thrown = record.arg; 1701 resetTryEntry(entry); 1702 } 1703 return thrown; 1704 } 1705 } 1706 1707 // The context.catch method must only be called with a location 1708 // argument that corresponds to a known catch block. 1709 throw new Error("illegal catch attempt"); 1710 }, 1711 1712 delegateYield: function(iterable, resultName, nextLoc) { 1713 this.delegate = { 1714 iterator: values(iterable), 1715 resultName: resultName, 1716 nextLoc: nextLoc 1717 }; 1718 1719 if (this.method === "next") { 1720 // Deliberately forget the last sent value so that we don't 1721 // accidentally pass it on to the delegate. 1722 this.arg = undefined; 1723 } 1724 1725 return ContinueSentinel; 1726 } 1727 }; 1728})( 1729 // In sloppy mode, unbound `this` refers to the global object, fallback to 1730 // Function constructor if we're in global strict mode. That is sadly a form 1731 // of indirect eval which violates Content Security Policy. 1732 (function() { return this })() || Function("return this")() 1733); 1734 1735(function (exports) { 1736 'use strict'; 1737 1738 var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; 1739 function createCommonjsModule(fn, module) { 1740 return module = { 1741 exports: {} 1742 }, fn(module, module.exports), module.exports; 1743 } 1744 1745 var check = function (it) { 1746 return it && it.Math == Math && it; 1747 }; // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 1748 1749 1750 var global_1 = // eslint-disable-next-line es/no-global-this -- safe 1751 check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || // eslint-disable-next-line no-restricted-globals -- safe 1752 check(typeof self == 'object' && self) || check(typeof commonjsGlobal == 'object' && commonjsGlobal) || // eslint-disable-next-line no-new-func -- fallback 1753 function () { 1754 return this; 1755 }() || Function('return this')(); 1756 1757 var fails = function (exec) { 1758 try { 1759 return !!exec(); 1760 } catch (error) { 1761 return true; 1762 } 1763 }; 1764 1765 // Detect IE8's incomplete defineProperty implementation 1766 1767 1768 var descriptors = !fails(function () { 1769 // eslint-disable-next-line es/no-object-defineproperty -- required for testing 1770 return Object.defineProperty({}, 1, { 1771 get: function () { 1772 return 7; 1773 } 1774 })[1] != 7; 1775 }); 1776 1777 var call = Function.prototype.call; 1778 var functionCall = call.bind ? call.bind(call) : function () { 1779 return call.apply(call, arguments); 1780 }; 1781 1782 var $propertyIsEnumerable = {}.propertyIsEnumerable; // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 1783 1784 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; // Nashorn ~ JDK8 bug 1785 1786 var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1787 1: 2 1788 }, 1); // `Object.prototype.propertyIsEnumerable` method implementation 1789 // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable 1790 1791 var f = NASHORN_BUG ? function propertyIsEnumerable(V) { 1792 var descriptor = getOwnPropertyDescriptor(this, V); 1793 return !!descriptor && descriptor.enumerable; 1794 } : $propertyIsEnumerable; 1795 1796 var objectPropertyIsEnumerable = { 1797 f: f 1798 }; 1799 1800 var createPropertyDescriptor = function (bitmap, value) { 1801 return { 1802 enumerable: !(bitmap & 1), 1803 configurable: !(bitmap & 2), 1804 writable: !(bitmap & 4), 1805 value: value 1806 }; 1807 }; 1808 1809 var FunctionPrototype = Function.prototype; 1810 var bind = FunctionPrototype.bind; 1811 var call$1 = FunctionPrototype.call; 1812 var callBind = bind && bind.bind(call$1); 1813 var functionUncurryThis = bind ? function (fn) {
1814 return fn && callBind(call$1, fn); 1815 } : function (fn) { 1816 return fn && function () { 1817 return call$1.apply(fn, arguments); 1818 }; 1819 }; 1820 1821 var toString = functionUncurryThis({}.toString); 1822 var stringSlice = functionUncurryThis(''.slice); 1823 1824 var classofRaw = function (it) { 1825 return stringSlice(toString(it), 8, -1); 1826 }; 1827 1828 var Object$1 = global_1.Object; 1829 var split = functionUncurryThis(''.split); // fallback for non-array-like ES3 and non-enumerable old V8 strings 1830 1831 var indexedObject = fails(function () { 1832 // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346 1833 // eslint-disable-next-line no-prototype-builtins -- safe 1834 return !Object$1('z').propertyIsEnumerable(0); 1835 }) ? function (it) { 1836 return classofRaw(it) == 'String' ? split(it, '') : Object$1(it); 1837 } : Object$1; 1838 1839 var TypeError$1 = global_1.TypeError; // `RequireObjectCoercible` abstract operation 1840 // https://tc39.es/ecma262/#sec-requireobjectcoercible 1841 1842 var requireObjectCoercible = function (it) { 1843 if (it == undefined) throw TypeError$1("Can't call method on " + it); 1844 return it; 1845 }; 1846 1847 // toObject with fallback for non-array-like ES3 strings 1848 1849 1850 1851 1852 var toIndexedObject = function (it) { 1853 return indexedObject(requireObjectCoercible(it)); 1854 }; 1855 1856 // `IsCallable` abstract operation 1857 // https://tc39.es/ecma262/#sec-iscallable 1858 var isCallable = function (argument) { 1859 return typeof argument == 'function'; 1860 }; 1861 1862 var isObject = function (it) { 1863 return typeof it == 'object' ? it !== null : isCallable(it); 1864 }; 1865 1866 var aFunction = function (argument) { 1867 return isCallable(argument) ? argument : undefined; 1868 }; 1869 1870 var getBuiltIn = function (namespace, method) { 1871 return arguments.length < 2 ? aFunction(global_1[namespace]) : global_1[namespace] && global_1[namespace][method]; 1872 }; 1873 1874 var objectIsPrototypeOf = functionUncurryThis({}.isPrototypeOf); 1875 1876 var engineUserAgent = getBuiltIn('navigator', 'userAgent') || ''; 1877 1878 var process = global_1.process; 1879 var Deno = global_1.Deno; 1880 var versions = process && process.versions || Deno && Deno.version; 1881 var v8 = versions && versions.v8; 1882 var match, version; 1883 1884 if (v8) { 1885 match = v8.split('.'); // in old Chrome, versions of V8 isn't V8 = Chrome / 10 1886 // but their correct versions are not interesting for us 1887 1888 version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]); 1889 } // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0` 1890 // so check `userAgent` even if `.v8` exists, but 0 1891 1892 1893 if (!version && engineUserAgent) { 1894 match = engineUserAgent.match(/Edge\/(\d+)/); 1895 1896 if (!match || match[1] >= 74) { 1897 match = engineUserAgent.match(/Chrome\/(\d+)/); 1898 if (match) version = +match[1]; 1899 } 1900 } 1901 1902 var engineV8Version = version; 1903 1904 /* eslint-disable es/no-symbol -- required for testing */ 1905 1906 1907 // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing 1908 1909 1910 var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () { 1911 var symbol = Symbol(); // Chrome 38 Symbol has incorrect toString conversion 1912 // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances 1913 1914 return !String(symbol) || !(Object(symbol) instanceof Symbol) || // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances 1915 !Symbol.sham && engineV8Version && engineV8Version < 41; 1916 }); 1917 1918 /* eslint-disable es/no-symbol -- required for testing */ 1919 1920 1921 var useSymbolAsUid = nativeSymbol && !Symbol.sham && typeof Symbol.iterator == 'symbol'; 1922 1923 var Object$2 = global_1.Object; 1924 var isSymbol = useSymbolAsUid ? function (it) { 1925 return typeof it == 'symbol'; 1926 } : function (it) { 1927 var $Symbol = getBuiltIn('Symbol'); 1928 return isCallable($Symbol) && objectIsPrototypeOf($Symbol.prototype, Object$2(it)); 1929 }; 1930 1931 var String$1 = global_1.String; 1932 1933 var tryToString = function (argument) { 1934 try { 1935 return String$1(argument); 1936 } catch (error) { 1937 return 'Object'; 1938 } 1939 }; 1940 1941 var TypeError$2 = global_1.TypeError; // `Assert: IsCallable(argument) is true` 1942 1943 var aCallable = function (argument) { 1944 if (isCallable(argument)) return argument; 1945 throw TypeError$2(tryToString(argument) + ' is not a function'); 1946 }; 1947 1948 // `GetMethod` abstract operation 1949 // https://tc39.es/ecma262/#sec-getmethod 1950 1951 1952 var getMethod = function (V, P) { 1953 var func = V[P]; 1954 return func == null ? undefined : aCallable(func); 1955 }; 1956 1957 var TypeError$3 = global_1.TypeError; // `OrdinaryToPrimitive` abstract operation 1958 // https://tc39.es/ecma262/#sec-ordinarytoprimitive 1959 1960 var ordinaryToPrimitive = function (input, pref) { 1961 var fn, val; 1962 if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val; 1963 if (isCallable(fn = input.valueOf) && !isObject(val = functionCall(fn, input))) return val; 1964 if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val; 1965 throw TypeError$3("Can't convert object to primitive value"); 1966 }; 1967 1968 var isPure = false;
1969 1970 // eslint-disable-next-line es/no-object-defineproperty -- safe 1971 1972 1973 var defineProperty = Object.defineProperty; 1974 1975 var setGlobal = function (key, value) { 1976 try { 1977 defineProperty(global_1, key, { 1978 value: value, 1979 configurable: true, 1980 writable: true 1981 }); 1982 } catch (error) { 1983 global_1[key] = value; 1984 } 1985 1986 return value; 1987 }; 1988 1989 var SHARED = '__core-js_shared__'; 1990 var store = global_1[SHARED] || setGlobal(SHARED, {}); 1991 var sharedStore = store; 1992 1993 var shared = createCommonjsModule(function (module) { 1994 (module.exports = function (key, value) { 1995 return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {}); 1996 })('versions', []).push({ 1997 version: '3.19.2', 1998 mode: 'global', 1999 copyright: '(c) 2021 Denis Pushkarev (zloirock.ru)' 2000 }); 2001 }); 2002 2003 var Object$3 = global_1.Object; // `ToObject` abstract operation 2004 // https://tc39.es/ecma262/#sec-toobject 2005 2006 var toObject = function (argument) { 2007 return Object$3(requireObjectCoercible(argument)); 2008 }; 2009 2010 var hasOwnProperty = functionUncurryThis({}.hasOwnProperty); // `HasOwnProperty` abstract operation 2011 // https://tc39.es/ecma262/#sec-hasownproperty 2012 2013 var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) { 2014 return hasOwnProperty(toObject(it), key); 2015 }; 2016 2017 var id = 0; 2018 var postfix = Math.random(); 2019 var toString$1 = functionUncurryThis(1.0.toString); 2020 2021 var uid = function (key) { 2022 return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$1(++id + postfix, 36); 2023 }; 2024 2025 var WellKnownSymbolsStore = shared('wks'); 2026 var Symbol$1 = global_1.Symbol; 2027 var symbolFor = Symbol$1 && Symbol$1['for']; 2028 var createWellKnownSymbol = useSymbolAsUid ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid; 2029 2030 var wellKnownSymbol = function (name) { 2031 if (!hasOwnProperty_1(WellKnownSymbolsStore, name) || !(nativeSymbol || typeof WellKnownSymbolsStore[name] == 'string')) { 2032 var description = 'Symbol.' + name; 2033 2034 if (nativeSymbol && hasOwnProperty_1(Symbol$1, name)) { 2035 WellKnownSymbolsStore[name] = Symbol$1[name]; 2036 } else if (useSymbolAsUid && symbolFor) { 2037 WellKnownSymbolsStore[name] = symbolFor(description); 2038 } else { 2039 WellKnownSymbolsStore[name] = createWellKnownSymbol(description); 2040 } 2041 } 2042 2043 return WellKnownSymbolsStore[name]; 2044 }; 2045 2046 var TypeError$4 = global_1.TypeError; 2047 var TO_PRIMITIVE = wellKnownSymbol('toPrimitive'); // `ToPrimitive` abstract operation 2048 // https://tc39.es/ecma262/#sec-toprimitive 2049 2050 var toPrimitive = function (input, pref) { 2051 if (!isObject(input) || isSymbol(input)) return input; 2052 var exoticToPrim = getMethod(input, TO_PRIMITIVE); 2053 var result; 2054 2055 if (exoticToPrim) { 2056 if (pref === undefined) pref = 'default'; 2057 result = functionCall(exoticToPrim, input, pref); 2058 if (!isObject(result) || isSymbol(result)) return result; 2059 throw TypeError$4("Can't convert object to primitive value"); 2060 } 2061 2062 if (pref === undefined) pref = 'number'; 2063 return ordinaryToPrimitive(input, pref); 2064 }; 2065 2066 // `ToPropertyKey` abstract operation 2067 // https://tc39.es/ecma262/#sec-topropertykey 2068 2069 2070 var toPropertyKey = function (argument) { 2071 var key = toPrimitive(argument, 'string'); 2072 return isSymbol(key) ? key : key + ''; 2073 }; 2074 2075 var document$1 = global_1.document; // typeof document.createElement is 'object' in old IE 2076 2077 var EXISTS = isObject(document$1) && isObject(document$1.createElement); 2078 2079 var documentCreateElement = function (it) { 2080 return EXISTS ? document$1.createElement(it) : {}; 2081 }; 2082 2083 // Thank's IE8 for his funny defineProperty 2084 2085 2086 var ie8DomDefine = !descriptors && !fails(function () { 2087 // eslint-disable-next-line es/no-object-defineproperty -- requied for testing 2088 return Object.defineProperty(documentCreateElement('div'), 'a', { 2089 get: function () { 2090 return 7; 2091 } 2092 }).a != 7; 2093 }); 2094 2095 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2096 2097 2098 var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; // `Object.getOwnPropertyDescriptor` method 2099 // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor 2100 2101 var f$1 = descriptors ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) { 2102 O = toIndexedObject(O); 2103 P = toPropertyKey(P); 2104 if (ie8DomDefine) try { 2105 return $getOwnPropertyDescriptor(O, P); 2106 } catch (error) { 2107 /* empty */ 2108 } 2109 if (hasOwnProperty_1(O, P)) return createPropertyDescriptor(!functionCall(objectPropertyIsEnumerable.f, O, P), O[P]); 2110 }; 2111 2112 var objectGetOwnPropertyDescriptor = { 2113 f: f$1 2114 }; 2115 2116 var String$2 = global_1.String; 2117 var TypeError$5 = global_1.TypeError; // `Assert: Type(argument) is Object` 2118 2119 var anObject = function (argument) { 2120 if (isObject(argument)) return argument; 2121 throw TypeError$5(String$2(argument) + ' is not an object'); 2122 }; 2123 2124 var TypeError$6 = global_1.TypeError; // eslint-disable-next-line es/no-object-defineproperty -- safe 2125 2126 var $defineProperty = Object.defineProperty; // `Object.defineProperty` method 2127 // https://tc39.es/ecma262/#sec-object.defineproperty 2128 2129 var f$2 = descriptors ? $defineProperty : function defineProperty(O, P, Attributes) { 2130 anObject(O); 2131 P = toPropertyKey(P); 2132 anObject(Attributes); 2133 if (ie8DomDefine) try { 2134 return $defineProperty(O, P, Attributes); 2135 } catch (error) { 2136 /* empty */ 2137 } 2138 if ('get' in Attributes || 'set' in Attributes) throw TypeError$6('Accessors not supported'); 2139 if ('value' in Attributes) O[P] = Attributes.value; 2140 return O; 2141 }; 2142 2143 var objectDefineProperty = { 2144 f: f$2 2145 }; 2146 2147 var createNonEnumerableProperty = descriptors ? function (object, key, value) { 2148 return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value)); 2149 } : function (object, key, value) { 2150 object[key] = value; 2151 return object; 2152 }; 2153 2154 var functionToString = functionUncurryThis(Function.toString); // this helper broken in `[email protected]`, so we can't use `shared` helper 2155 2156 if (!isCallable(sharedStore.inspectSource)) { 2157 sharedStore.inspectSource = function (it) { 2158 return functionToString(it); 2159 }; 2160 } 2161 2162 var inspectSource = sharedStore.inspectSource; 2163 2164 var WeakMap = global_1.WeakMap; 2165 var nativeWeakMap = isCallable(WeakMap) && /native code/.test(inspectSource(WeakMap)); 2166 2167 var keys = shared('keys'); 2168 2169 var sharedKey = function (key) { 2170 return keys[key] || (keys[key] = uid(key)); 2171 }; 2172 2173 var hiddenKeys = {}; 2174 2175 var OBJECT_ALREADY_INITIALIZED = 'Object already initialized'; 2176 var TypeError$7 = global_1.TypeError; 2177 var WeakMap$1 = global_1.WeakMap; 2178 var set, get, has; 2179 2180 var enforce = function (it) { 2181 return has(it) ? get(it) : set(it, {}); 2182 }; 2183 2184 var getterFor = function (TYPE) { 2185 return function (it) { 2186 var state; 2187 2188 if (!isObject(it) || (state = get(it)).type !== TYPE) { 2189 throw TypeError$7('Incompatible receiver, ' + TYPE + ' required'); 2190 } 2191 2192 return state; 2193 }; 2194 }; 2195 2196 if (nativeWeakMap || sharedStore.state) { 2197 var store$1 = sharedStore.state || (sharedStore.state = new WeakMap$1()); 2198 var wmget = functionUncurryThis(store$1.get); 2199 var wmhas = functionUncurryThis(store$1.has); 2200 var wmset = functionUncurryThis(store$1.set); 2201 2202 set = function (it, metadata) { 2203 if (wmhas(store$1, it)) throw new TypeError$7(OBJECT_ALREADY_INITIALIZED); 2204 metadata.facade = it; 2205 wmset(store$1, it, metadata); 2206 return metadata; 2207 }; 2208 2209 get = function (it) { 2210 return wmget(store$1, it) || {}; 2211 }; 2212 2213 has = function (it) { 2214 return wmhas(store$1, it); 2215 }; 2216 } else { 2217 var STATE = sharedKey('state'); 2218 hiddenKeys[STATE] = true; 2219 2220 set = function (it, metadata) { 2221 if (hasOwnProperty_1(it, STATE)) throw new TypeError$7(OBJECT_ALREADY_INITIALIZED); 2222 metadata.facade = it; 2223 createNonEnumerableProperty(it, STATE, metadata); 2224 return metadata; 2225 }; 2226 2227 get = function (it) { 2228 return hasOwnProperty_1(it, STATE) ? it[STATE] : {}; 2229 }; 2230 2231 has = function (it) { 2232 return hasOwnProperty_1(it, STATE); 2233 }; 2234 } 2235 2236 var internalState = { 2237 set: set, 2238 get: get, 2239 has: has, 2240 enforce: enforce, 2241 getterFor: getterFor 2242 }; 2243 2244 var FunctionPrototype$1 = Function.prototype; // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2245 2246 var getDescriptor = descriptors && Object.getOwnPropertyDescriptor; 2247 var EXISTS$1 = hasOwnProperty_1(FunctionPrototype$1, 'name'); // additional protection from minified / mangled / dropped function names 2248 2249 var PROPER = EXISTS$1 && function something() { 2250 /* empty */ 2251 }.name === 'something'; 2252 2253 var CONFIGURABLE = EXISTS$1 && (!descriptors || descriptors && getDescriptor(FunctionPrototype$1, 'name').configurable); 2254 var functionName = { 2255 EXISTS: EXISTS$1, 2256 PROPER: PROPER, 2257 CONFIGURABLE: CONFIGURABLE 2258 }; 2259 2260 var redefine = createCommonjsModule(function (module) { 2261 var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE; 2262 2263 var getInternalState = internalState.get; 2264 var enforceInternalState = internalState.enforce;
vendor: 4,394 bytes, lines 2265-2393
2265 var TEMPLATE = String(String).split('String'); 2266 (module.exports = function (O, key, value, options) { 2267 var unsafe = options ? !!options.unsafe : false; 2268 var simple = options ? !!options.enumerable : false; 2269 var noTargetGet = options ? !!options.noTargetGet : false; 2270 var name = options && options.name !== undefined ? options.name : key; 2271 var state; 2272 2273 if (isCallable(value)) { 2274 if (String(name).slice(0, 7) === 'Symbol(') { 2275 name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']'; 2276 } 2277 2278 if (!hasOwnProperty_1(value, 'name') || CONFIGURABLE_FUNCTION_NAME && value.name !== name) { 2279 createNonEnumerableProperty(value, 'name', name); 2280 } 2281 2282 state = enforceInternalState(value); 2283 2284 if (!state.source) { 2285 state.source = TEMPLATE.join(typeof name == 'string' ? name : ''); 2286 } 2287 } 2288 2289 if (O === global_1) { 2290 if (simple) O[key] = value;else setGlobal(key, value); 2291 return; 2292 } else if (!unsafe) { 2293 delete O[key]; 2294 } else if (!noTargetGet && O[key]) { 2295 simple = true; 2296 } 2297 2298 if (simple) O[key] = value;else createNonEnumerableProperty(O, key, value); // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative 2299 })(Function.prototype, 'toString', function toString() { 2300 return isCallable(this) && getInternalState(this).source || inspectSource(this); 2301 }); 2302 }); 2303 2304 var ceil = Math.ceil; 2305 var floor = Math.floor; // `ToIntegerOrInfinity` abstract operation 2306 // https://tc39.es/ecma262/#sec-tointegerorinfinity 2307 2308 var toIntegerOrInfinity = function (argument) { 2309 var number = +argument; // eslint-disable-next-line no-self-compare -- safe 2310 2311 return number !== number || number === 0 ? 0 : (number > 0 ? floor : ceil)(number); 2312 }; 2313 2314 var max = Math.max; 2315 var min = Math.min; // Helper for a popular repeating case of the spec: 2316 // Let integer be ? ToInteger(index). 2317 // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length). 2318 2319 var toAbsoluteIndex = function (index, length) { 2320 var integer = toIntegerOrInfinity(index); 2321 return integer < 0 ? max(integer + length, 0) : min(integer, length); 2322 }; 2323 2324 var min$1 = Math.min; // `ToLength` abstract operation 2325 // https://tc39.es/ecma262/#sec-tolength 2326 2327 var toLength = function (argument) { 2328 return argument > 0 ? min$1(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 2329 }; 2330 2331 // `LengthOfArrayLike` abstract operation 2332 // https://tc39.es/ecma262/#sec-lengthofarraylike 2333 2334 2335 var lengthOfArrayLike = function (obj) { 2336 return toLength(obj.length); 2337 }; 2338 2339 // `Array.prototype.{ indexOf, includes }` methods implementation 2340 2341 2342 var createMethod = function (IS_INCLUDES) { 2343 return function ($this, el, fromIndex) { 2344 var O = toIndexedObject($this); 2345 var length = lengthOfArrayLike(O); 2346 var index = toAbsoluteIndex(fromIndex, length); 2347 var value; // Array#includes uses SameValueZero equality algorithm 2348 // eslint-disable-next-line no-self-compare -- NaN check 2349 2350 if (IS_INCLUDES && el != el) while (length > index) { 2351 value = O[index++]; // eslint-disable-next-line no-self-compare -- NaN check 2352 2353 if (value != value) return true; // Array#indexOf ignores holes, Array#includes - not 2354 } else for (; length > index; index++) { 2355 if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0; 2356 } 2357 return !IS_INCLUDES && -1; 2358 }; 2359 }; 2360 2361 var arrayIncludes = { 2362 // `Array.prototype.includes` method 2363 // https://tc39.es/ecma262/#sec-array.prototype.includes 2364 includes: createMethod(true), 2365 // `Array.prototype.indexOf` method 2366 // https://tc39.es/ecma262/#sec-array.prototype.indexof 2367 indexOf: createMethod(false) 2368 }; 2369 2370 var indexOf = arrayIncludes.indexOf; 2371 2372 2373 2374 var push = functionUncurryThis([].push); 2375 2376 var objectKeysInternal = function (object, names) { 2377 var O = toIndexedObject(object); 2378 var i = 0; 2379 var result = []; 2380 var key; 2381 2382 for (key in O) !hasOwnProperty_1(hiddenKeys, key) && hasOwnProperty_1(O, key) && push(result, key); // Don't enum bug & hidden keys 2383 2384 2385 while (names.length > i) if (hasOwnProperty_1(O, key = names[i++])) { 2386 ~indexOf(result, key) || push(result, key); 2387 } 2388 2389 return result; 2390 }; 2391 2392 // IE8- don't enum bug keys 2393 var enumBugKeys = ['constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleStr
2393ing', 'toString', 'valueOf']; 2394 2395 var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype'); // `Object.getOwnPropertyNames` method 2396 // https://tc39.es/ecma262/#sec-object.getownpropertynames 2397 // eslint-disable-next-line es/no-object-getownpropertynames -- safe 2398 2399 var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { 2400 return objectKeysInternal(O, hiddenKeys$1); 2401 }; 2402 2403 var objectGetOwnPropertyNames = { 2404 f: f$3 2405 }; 2406 2407 // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe 2408 var f$4 = Object.getOwnPropertySymbols; 2409 2410 var objectGetOwnPropertySymbols = { 2411 f: f$4 2412 }; 2413 2414 var concat = functionUncurryThis([].concat); // all object keys, includes non-enumerable and symbols 2415 2416 var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) { 2417 var keys = objectGetOwnPropertyNames.f(anObject(it)); 2418 var getOwnPropertySymbols = objectGetOwnPropertySymbols.f; 2419 return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys; 2420 }; 2421 2422 var copyConstructorProperties = function (target, source) { 2423 var keys = ownKeys(source); 2424 var defineProperty = objectDefineProperty.f; 2425 var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; 2426 2427 for (var i = 0; i < keys.length; i++) { 2428 var key = keys[i]; 2429 if (!hasOwnProperty_1(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key)); 2430 } 2431 }; 2432 2433 var replacement = /#|\.prototype\./; 2434 2435 var isForced = function (feature, detection) { 2436 var value = data[normalize(feature)]; 2437 return value == POLYFILL ? true : value == NATIVE ? false : isCallable(detection) ? fails(detection) : !!detection; 2438 }; 2439 2440 var normalize = isForced.normalize = function (string) { 2441 return String(string).replace(replacement, '.').toLowerCase(); 2442 }; 2443 2444 var data = isForced.data = {}; 2445 var NATIVE = isForced.NATIVE = 'N'; 2446 var POLYFILL = isForced.POLYFILL = 'P'; 2447 var isForced_1 = isForced; 2448 2449 var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f; 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 /* 2461 options.target - name of the target object 2462 options.global - target is the global object 2463 options.stat - export as static methods of target 2464 options.proto - export as prototype methods of target 2465 options.real - real prototype method for the `pure` version 2466 options.forced - export even if the native feature is available 2467 options.bind - bind methods to the target, required for the `pure` version 2468 options.wrap - wrap constructors to preventing global pollution, required for the `pure` version 2469 options.unsafe - use the simple assignment of property instead of delete + defineProperty 2470 options.sham - add a flag to not completely full polyfills 2471 options.enumerable - export as enumerable property 2472 options.noTargetGet - prevent calling a getter on target 2473 options.name - the .name of the function if it does not match the key 2474 */ 2475 2476 2477 var _export = function (options, source) { 2478 var TARGET = options.target; 2479 var GLOBAL = options.global; 2480 var STATIC = options.stat; 2481 var FORCED, target, key, targetProperty, sourceProperty, descriptor; 2482 2483 if (GLOBAL) { 2484 target = global_1; 2485 } else if (STATIC) { 2486 target = global_1[TARGET] || setGlobal(TARGET, {}); 2487 } else { 2488 target = (global_1[TARGET] || {}).prototype; 2489 } 2490 2491 if (target) for (key in source) { 2492 sourceProperty = source[key]; 2493 2494 if (options.noTargetGet) { 2495 descriptor = getOwnPropertyDescriptor$1(target, key); 2496 targetProperty = descriptor && descriptor.value; 2497 } else targetProperty = target[key]; 2498 2499 FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); // contained in target 2500 2501 if (!FORCED && targetProperty !== undefined) { 2502 if (typeof sourceProperty == typeof targetProperty) continue; 2503 copyConstructorProperties(sourceProperty, targetProperty); 2504 } // add a flag to not completely full polyfills 2505 2506 2507 if (options.sham || targetProperty && targetProperty.sham) { 2508 createNonEnumerableProperty(sourceProperty, 'sham', true); 2509 } // extend global 2510 2511 2512 redefine(target, key, sourceProperty, options); 2513 } 2514 }; 2515 2516 var correctPrototypeGetter = !fails(function () { 2517 function F() { 2518 /* empty */ 2519 } 2520 2521 F.prototype.constructor = null; // eslint-disable-next-line es/no-object-getprototypeof -- required for testing 2522 2523 return Object.getPrototypeOf(new F()) !== F.prototype; 2524 }); 2525 2526 var IE_PROTO = sharedKey('IE_PROTO'); 2527 var Object$4 = global_1.Object; 2528 var ObjectPrototype = Object$4.prototype; // `Object.getPrototypeOf` method 2529 // https://tc39.es/ecma262/#sec-object.getprototypeof 2530 2531 var objectGetPrototypeOf = correctPrototypeGetter ? Object$4.getPrototypeOf : function (O) { 2532 var object = toObject(O); 2533 if (hasOwnProperty_1(object, IE_PROTO)) return object[IE_PROTO]; 2534 var constructor = object.constructor; 2535 2536 if (isCallable(constructor) && object instanceof constructor) { 2537 return constructor.prototype; 2538 } 2539
2540 return object instanceof Object$4 ? ObjectPrototype : null; 2541 }; 2542 2543 var String$3 = global_1.String; 2544 var TypeError$8 = global_1.TypeError; 2545 2546 var aPossiblePrototype = function (argument) { 2547 if (typeof argument == 'object' || isCallable(argument)) return argument; 2548 throw TypeError$8("Can't set " + String$3(argument) + ' as a prototype'); 2549 }; 2550 2551 /* eslint-disable no-proto -- safe */ 2552 2553 2554 2555 2556 // `Object.setPrototypeOf` method 2557 // https://tc39.es/ecma262/#sec-object.setprototypeof 2558 // Works with __proto__ only. Old v8 can't work with null proto objects. 2559 // eslint-disable-next-line es/no-object-setprototypeof -- safe 2560 2561 2562 var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () { 2563 var CORRECT_SETTER = false; 2564 var test = {}; 2565 var setter; 2566 2567 try { 2568 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2569 setter = functionUncurryThis(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set); 2570 setter(test, []); 2571 CORRECT_SETTER = test instanceof Array; 2572 } catch (error) { 2573 /* empty */ 2574 } 2575 2576 return function setPrototypeOf(O, proto) { 2577 anObject(O); 2578 aPossiblePrototype(proto); 2579 if (CORRECT_SETTER) setter(O, proto);else O.__proto__ = proto; 2580 return O; 2581 }; 2582 }() : undefined); 2583 2584 // `Object.keys` method 2585 // https://tc39.es/ecma262/#sec-object.keys 2586 // eslint-disable-next-line es/no-object-keys -- safe 2587 2588 2589 var objectKeys = Object.keys || function keys(O) { 2590 return objectKeysInternal(O, enumBugKeys); 2591 }; 2592 2593 // `Object.defineProperties` method 2594 // https://tc39.es/ecma262/#sec-object.defineproperties 2595 // eslint-disable-next-line es/no-object-defineproperties -- safe 2596 2597 2598 var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) { 2599 anObject(O); 2600 var props = toIndexedObject(Properties); 2601 var keys = objectKeys(Properties); 2602 var length = keys.length; 2603 var index = 0; 2604 var key; 2605 2606 while (length > index) objectDefineProperty.f(O, key = keys[index++], props[key]); 2607 2608 return O; 2609 }; 2610 2611 var html = getBuiltIn('document', 'documentElement'); 2612 2613 /* global ActiveXObject -- old IE, WSH */ 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 var GT = '>'; 2629 var LT = '<'; 2630 var PROTOTYPE = 'prototype'; 2631 var SCRIPT = 'script'; 2632 var IE_PROTO$1 = sharedKey('IE_PROTO'); 2633 2634 var EmptyConstructor = function () { 2635 /* empty */ 2636 }; 2637 2638 var scriptTag = function (content) { 2639 return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT; 2640 }; // Create object with fake `null` prototype: use ActiveX Object with cleared prototype 2641 2642 2643 var NullProtoObjectViaActiveX = function (activeXDocument) { 2644 activeXDocument.write(scriptTag('')); 2645 activeXDocument.close(); 2646 var temp = activeXDocument.parentWindow.Object; 2647 activeXDocument = null; // avoid memory leak 2648 2649 return temp; 2650 }; // Create object with fake `null` prototype: use iframe Object with cleared prototype 2651 2652 2653 var NullProtoObjectViaIFrame = function () { 2654 // Thrash, waste and sodomy: IE GC bug 2655 var iframe = documentCreateElement('iframe'); 2656 var JS = 'java' + SCRIPT + ':'; 2657 var iframeDocument; 2658 iframe.style.display = 'none'; 2659 html.appendChild(iframe); // https://github.com/zloirock/core-js/issues/475 2660 2661 iframe.src = String(JS); 2662 iframeDocument = iframe.contentWindow.document; 2663 iframeDocument.open(); 2664 iframeDocument.write(scriptTag('document.F=Object')); 2665 iframeDocument.close(); 2666 return iframeDocument.F; 2667 }; // Check for document.domain and active x support 2668 // No need to use active x approach when document.domain is not set 2669 // see https://github.com/es-shims/es5-shim/issues/150 2670 // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346 2671 // avoid IE GC bug 2672 2673 2674 var activeXDocument; 2675 2676 var NullProtoObject = function () { 2677 try { 2678 activeXDocument = new ActiveXObject('htmlfile'); 2679 } catch (error) { 2680 /* ignore */ 2681 } 2682 2683 NullProtoObject = typeof document != 'undefined' ? document.domain && activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) // old IE 2684 : NullProtoObjectViaIFrame() : NullProtoObjectViaActiveX(activeXDocument); // WSH 2685 2686 var length = enumBugKeys.length; 2687 2688 while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]]; 2689 2690 return NullProtoObject(); 2691 }; 2692 2693 hiddenKeys[IE_PROTO$1] = true; // `Object.create` method 2694 // https://tc39.es/ecma262/#sec-object.create 2695 2696 var objectCreate = Object.create || function create(O, Properties) { 2697 var result; 2698 2699 if (O !== null) { 2700 EmptyConstructor[PROTOTYPE] = anObject(O); 2701 result = new EmptyConstructor(); 2702 EmptyConstructor[PROTOTYPE] = null; // add "__proto__" for Object.getPrototypeOf polyfill 2703 2704 result[IE_PROTO$1] = O; 2705 } else result = NullProtoObject(); 2706 2707 return Properties === undefined ? result : objectDefineProperties(result, Properties); 2708 }; 2709 2710 var createProperty = function (object, key, value) { 2711 var propertyKey = toPropertyKey(key); 2712 if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value));else object[propertyKey] = value; 2713 }; 2714 2715 var Array$1 = global_1.Array; 2716 var max$1 = Math.max; 2717 2718 var arraySliceSimple = function (O, start, end) { 2719 var length = lengthOfArrayLike(O); 2720 var k = toAbsoluteIndex(start, length); 2721 var fin = toAbsoluteIndex(end === undefined ? length : end, length); 2722 var result = Array$1(max$1(fin - k, 0)); 2723 2724 for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]); 2725 2726 result.length = n; 2727 return result; 2728 }; 2729 2730 var replace = functionUncurryThis(''.replace); 2731 var split$1 = functionUncurryThis(''.split); 2732 var join = functionUncurryThis([].join); 2733 2734 var TEST = function (arg) { 2735 return String(Error(arg).stack); 2736 }('zxcasd'); 2737 2738 var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/; 2739 var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST); 2740 var IS_FIREFOX_OR_SAFARI_STACK = /@[^\n]*\n/.test(TEST) && !/zxcasd/.test(TEST); 2741 2742 var clearErrorStack = function (stack, dropEntries) { 2743 if (typeof stack != 'string') return stack; 2744 2745 if (IS_V8_OR_CHAKRA_STACK) { 2746 while (dropEntries--) stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, ''); 2747 }
2747 else if (IS_FIREFOX_OR_SAFARI_STACK) { 2748 return join(arraySliceSimple(split$1(stack, '\n'), dropEntries), '\n'); 2749 } 2750 2751 return stack; 2752 }; 2753 2754 // `InstallErrorCause` abstract operation 2755 // https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause 2756 2757 2758 var installErrorCause = function (O, options) { 2759 if (isObject(options) && 'cause' in options) { 2760 createNonEnumerableProperty(O, 'cause', options.cause); 2761 } 2762 }; 2763 2764 var bind$1 = functionUncurryThis(functionUncurryThis.bind); // optional / simple context binding 2765 2766 var functionBindContext = function (fn, that) { 2767 aCallable(fn); 2768 return that === undefined ? fn : bind$1 ? bind$1(fn, that) : function () 2769 /* ...args */ 2770 { 2771 return fn.apply(that, arguments); 2772 }; 2773 }; 2774 2775 var iterators = {}; 2776 2777 var ITERATOR = wellKnownSymbol('iterator'); 2778 var ArrayPrototype = Array.prototype; // check on default Array iterator 2779 2780 var isArrayIteratorMethod = function (it) { 2781 return it !== undefined && (iterators.Array === it || ArrayPrototype[ITERATOR] === it); 2782 }; 2783 2784 var TO_STRING_TAG = wellKnownSymbol('toStringTag'); 2785 var test = {}; 2786 test[TO_STRING_TAG] = 'z'; 2787 var toStringTagSupport = String(test) === '[object z]'; 2788 2789 var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag'); 2790 var Object$5 = global_1.Object; // ES3 wrong here 2791 2792 var CORRECT_ARGUMENTS = classofRaw(function () { 2793 return arguments; 2794 }()) == 'Arguments'; // fallback for IE11 Script Access Denied error 2795 2796 var tryGet = function (it, key) { 2797 try { 2798 return it[key]; 2799 } catch (error) { 2800 /* empty */ 2801 } 2802 }; // getting tag from ES6+ `Object.prototype.toString` 2803 2804 2805 var classof = toStringTagSupport ? classofRaw : function (it) { 2806 var O, tag, result; 2807 return it === undefined ? 'Undefined' : it === null ? 'Null' // @@toStringTag case 2808 : typeof (tag = tryGet(O = Object$5(it), TO_STRING_TAG$1)) == 'string' ? tag // builtinTag case 2809 : CORRECT_ARGUMENTS ? classofRaw(O) // ES3 arguments fallback 2810 : (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result; 2811 }; 2812 2813 var ITERATOR$1 = wellKnownSymbol('iterator'); 2814 2815 var getIteratorMethod = function (it) { 2816 if (it != undefined) return getMethod(it, ITERATOR$1) || getMethod(it, '@@iterator') || iterators[classof(it)]; 2817 }; 2818 2819 var TypeError$9 = global_1.TypeError; 2820 2821 var getIterator = function (argument, usingIterator) { 2822 var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator; 2823 if (aCallable(iteratorMethod)) return anObject(functionCall(iteratorMethod, argument)); 2824 throw TypeError$9(tryToString(argument) + ' is not iterable'); 2825 }; 2826 2827 var iteratorClose = function (iterator, kind, value) { 2828 var innerResult, innerError; 2829 anObject(iterator); 2830 2831 try { 2832 innerResult = getMethod(iterator, 'return'); 2833 2834 if (!innerResult) { 2835 if (kind === 'throw') throw value; 2836 return value; 2837 } 2838 2839 innerResult = functionCall(innerResult, iterator); 2840 } catch (error) { 2841 innerError = true; 2842 innerResult = error; 2843 } 2844 2845 if (kind === 'throw') throw value; 2846 if (innerError) throw innerResult; 2847 anObject(innerResult); 2848 return value; 2849 }; 2850 2851 var TypeError$a = global_1.TypeError; 2852 2853 var Result = function (stopped, result) { 2854 this.stopped = stopped; 2855 this.result = result; 2856 }; 2857 2858 var ResultPrototype = Result.prototype; 2859 2860 var iterate = function (iterable, unboundFunction, options) { 2861 var that = options && options.that; 2862 var AS_ENTRIES = !!(options && options.AS_ENTRIES); 2863 var IS_ITERATOR = !!(options && options.IS_ITERATOR); 2864 var INTERRUPTED = !!(options && options.INTERRUPTED); 2865 var fn = functionBindContext(unboundFunction, that); 2866 var iterator, iterFn, index, length, result, next, step; 2867 2868 var stop = function (condition) { 2869 if (iterator) iteratorClose(iterator, 'normal', condition); 2870 return new Result(true, condition); 2871 }; 2872 2873 var callFn = function (value) { 2874 if (AS_ENTRIES) { 2875 anObject(value); 2876 return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]); 2877 } 2878 2879 return INTERRUPTED ? fn(value, stop) : fn(value); 2880 }; 2881 2882 if (IS_ITERATOR) { 2883 iterator = iterable; 2884 } else { 2885 iterFn = getIteratorMethod(iterable); 2886 if (!iterFn) throw TypeError$a(tryToString(iterable) + ' is not iterable'); // optimisation for array iterators 2887 2888 if (isArrayIteratorMethod(iterFn)) { 2889 for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) { 2890 result = callFn(iterable[index]); 2891 if (result && objectIsPrototypeOf(ResultPrototype, result)) return result; 2892 } 2893 2894 return new Result(false); 2895 } 2896 2897 iterator = getIterator(iterable, iterFn); 2898 } 2899 2900 next = iterator.next; 2901 2902 while (!(step = functionCall(next, iterator)).done) { 2903 try { 2904 result = callFn(step.value); 2905 } catch (error) { 2906 iteratorClose(iterator, 'throw', error); 2907 } 2908 2909 if (typeof result == 'object' && result && objectIsPrototypeOf(ResultPrototype, result)) return result; 2910 } 2911 2912 return new Result(false); 2913 }; 2914 2915 var String$4 = global_1.String; 2916 2917 var toString_1 = function (argument) { 2918 if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string'); 2919 return String$4(argument); 2920 }; 2921 2922 var normalizeStringArgument = function (argument, $default) { 2923 return argument === undefined ? arguments.length < 2 ? '' : $default : toString_1(argument); 2924 }; 2925 2926 var errorStackInstallable = !fails(function () { 2927 var error = Error('a'); 2928 if (!('stack' in error)) return true; // eslint-disable-next-line es/no-object-defineproperty -- safe 2929 2930 Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7)); 2931 return error.stack !== 7; 2932 }); 2933 2934 var TO_STRING_TAG$2 = wellKnownSymbol('toStringTag'); 2935 var Error$1 = global_1.Error; 2936 var push$1 = [].push; 2937 2938 var $AggregateError = function AggregateError(errors, message 2939 /* , options */ 2940 ) { 2941 var options = arguments.length > 2 ? arguments[2] : undefined; 2942 var isInstance = objectIsPrototypeOf(AggregateErrorPrototype, this); 2943 var that; 2944 2945 if (objectSetPrototypeOf) { 2946 that = objectSetPrototypeOf(new Error$1(undefined), isInstance ? objectGetPrototypeOf(this) : AggregateErrorPrototype); 2947 } else { 2948 that = isInstance ? this : objectCreate(AggregateErrorPrototype); 2949 createNonEnumerableProperty(that, TO_STRING_TAG$2, 'Error'); 2950 } 2951 2952 createNonEnumerableProperty(that, 'message', normalizeStringArgument(message, '')); 2953 if (errorStackInstallable) createNonEnumerableProperty(that, 'stack', clearErrorStack(that.stack, 1)); 2954 installErrorCause(that, options); 2955 var errorsArray = []; 2956 iterate(errors, push$1, { 2957 that: errorsArray 2958 }); 2959 createNonEnumerableProperty(that, 'errors', errorsArray); 2960 return that; 2961 }; 2962 2963 if (objectSetPrototypeOf) objectSetPrototypeOf($AggregateError, Error$1);else copyConstructorProperties($AggregateError, Error$1); 2964 var AggregateErrorPrototype = $AggregateError.prototype = objectCreate(Error$1.prototype, { 2965 constructor: createPropertyDescriptor(1, $AggregateError), 2966 message: createPropertyDescriptor(1, ''), 2967 name: createPropertyDescriptor(1, 'AggregateError') 2968 }); // `AggregateError` constructor 2969 // https://tc39.es/ecma262/#sec-aggregate-error-constructor 2970 2971 _export({ 2972 global: true 2973 }, { 2974 AggregateError: $AggregateError 2975 }); 2976 2977 var UNSCOPABLES = wellKnownSymbol('unscopables'); 2978 var ArrayPrototype$1 = Array.prototype; // Array.prototype[@@unscopables] 2979 // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 2980 2981 if (ArrayPrototype$1[UNSCOPABLES] == undefined) { 2982 objectDefineProperty.f(ArrayPrototype$1, UNSCOPABLES, { 2983 configurable: true, 2984 value: objectCreate(null) 2985 }); 2986 } // add a key to Array.prototype[@@unscopables] 2987 2988 2989 var addToUnscopables = function (key) { 2990 ArrayPrototype$1[UNSCOPABLES][key] = true; 2991 }; 2992 2993 // `Array.prototype.at` method 2994 // https://github.com/tc39/proposal-relative-indexing-method 2995 2996 2997 _export({ 2998 target: 'Array', 2999 proto: true 3000 }, { 3001 at: function at(index) { 3002 var O = toObject(this); 3003 var len = lengthOfArrayLike(O); 3004 var relativeIndex = toIntegerOrInfinity(index); 3005 var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; 3006 return k < 0 || k >= len ? undefined : O[k]; 3007 } 3008 }); 3009 addToUnscopables('at'); 3010 3011 // `IsArray` abstract operation 3012 // https://tc39.es/ecma262/#sec-isarray 3013 // eslint-disable-next-line es/no-array-isarray -- safe 3014 3015 3016 var isArray = Array.isArray || function isArray(argument) { 3017 return classofRaw(argument) == 'Array'; 3018 }; 3019 3020 var un$Reverse = functionUncurryThis([].reverse); 3021 var test$1 = [1, 2]; // `Array.prototype.reverse` method 3022 // https://tc39.es/ecma262/#sec-array.prototype.reverse 3023 // fix for Safari 12.0 bug 3024 // https://bugs.webkit.org/show_bug.cgi?id=188794 3025 3026 _export({ 3027 target: 'Array', 3028 proto: true, 3029 forced: String(test$1) === String(test$1.reverse()) 3030 }, { 3031 reverse: function reverse() { 3032 // eslint-disable-next-line no-self-assign -- dirty hack 3033 if (isArray(this)) this.length = this.length; 3034 return un$Reverse(this); 3035 } 3036 }); 3037 3038 // eslint-disable-next-line es/no-typed-arrays -- safe 3039 var arrayBufferNative = typeof ArrayBuffer != 'undefined' && typeof DataView != 'undefined'; 3040 3041 var redefineAll = function (target, src, options) { 3042 for (var key in src) redefine(target, key, src[key], options); 3043 3044 return target; 3045 }; 3046 3047 var TypeError$b = global_1.TypeError; 3048 3049 var anInstance = function (it, Prototype) { 3050 if (objectIsPrototypeOf(Prototype, it)) return it; 3051 throw TypeError$b('Incorrect invocation'); 3052 }; 3053 3054 var RangeError = global_1.RangeError; // `ToIndex` abstract operation 3055 // https://tc39.es/ecma262/#sec-toindex 3056 3057 var toIndex = function (it) { 3058 if (it === undefined) return 0; 3059 var number = toIntegerOrInfinity(it); 3060 var length = toLength(number); 3061 if (number !== length) throw RangeError('Wrong length or index'); 3062 return length; 3063 }; 3064 3065 // IEEE754 conversions based on https://github.com/feross/ieee754 3066 3067 3068 var Array$2 = global_1.Array; 3069 var abs = Math.abs; 3070 var pow = Math.pow; 3071 var floor$1 = Math.floor; 3072 var log = Math.log; 3073 var LN2 = Math.LN2; 3074 3075 var pack = function (number, mantissaLength, bytes) { 3076 var buffer = Array$2(bytes); 3077 var exponentLength = bytes * 8 - mantissaLength - 1; 3078 var eMax = (1 << exponentLength) - 1; 3079 var eBias = eMax >> 1; 3080 var rt = mantissaLength === 23 ? pow(2, -24) - pow(2, -77) : 0; 3081 var sign = number < 0 || number === 0 && 1 / number < 0 ? 1 : 0; 3082 var index = 0; 3083 var exponent, mantissa, c; 3084 number = abs(number); // eslint-disable-next-line no-self-compare -- NaN check 3085 3086 if (number != number || number === Infinity) { 3087 // eslint-disable-next-line no-self-compare -- NaN check 3088 mantissa = number != number ? 1 : 0; 3089 exponent = eMax; 3090 } else { 3091 exponent = floor$1(log(number) / LN2); 3092 c = pow(2, -exponent); 3093 3094 if (number * c < 1) { 3095 exponent--; 3096 c *= 2; 3097 } 3098 3099 if (exponent + eBias >= 1) { 3100 number += rt / c; 3101 } else { 3102 number += rt * pow(2, 1 - eBias); 3103 } 3104 3105 if (number * c >= 2) { 3106 exponent++; 3107 c /= 2; 3108 } 3109 3110 if (exponent + eBias >= eMax) { 3111 mantissa = 0; 3112 exponent = eMax; 3113 } else if (exponent + eBias >= 1) { 3114 mantissa = (number * c - 1) * pow(2, mantissaLength); 3115 exponent = exponent + eBias; 3116 } else { 3117 mantissa = number * pow(2, eBias - 1) * pow(2, mantissaLength); 3118 exponent = 0; 3119 } 3120 } 3121 3122 while (mantissaLength >= 8) { 3123 buffer[index++] = mantissa & 255; 3124 mantissa /= 256; 3125 mantissaLength -= 8; 3126 } 3127 3128 exponent = exponent << mantissaLength | mantissa; 3129 exponentLength += mantissaLength; 3130 3131 while (exponentLength > 0) { 3132 buffer[index++] = exponent & 255; 3133 exponent /= 256; 3134 exponentLength -= 8; 3135 } 3136 3137 buffer[--index] |= sign * 128; 3138 return buffer; 3139 }; 3140 3141 var unpack = function (buffer, mantissaLength) { 3142 var bytes = buffer.length; 3143 var exponentLength = bytes * 8 - mantissaLength - 1; 3144 var eMax = (1 << exponentLength) - 1; 3145 var eBias = eMax >> 1;
vendor: 6,238 bytes, lines 3146-3360
3146 var nBits = exponentLength - 7; 3147 var index = bytes - 1; 3148 var sign = buffer[index--]; 3149 var exponent = sign & 127; 3150 var mantissa; 3151 sign >>= 7; 3152 3153 while (nBits > 0) { 3154 exponent = exponent * 256 + buffer[index--]; 3155 nBits -= 8; 3156 } 3157 3158 mantissa = exponent & (1 << -nBits) - 1; 3159 exponent >>= -nBits; 3160 nBits += mantissaLength; 3161 3162 while (nBits > 0) { 3163 mantissa = mantissa * 256 + buffer[index--]; 3164 nBits -= 8; 3165 } 3166 3167 if (exponent === 0) { 3168 exponent = 1 - eBias; 3169 } else if (exponent === eMax) { 3170 return mantissa ? NaN : sign ? -Infinity : Infinity; 3171 } else { 3172 mantissa = mantissa + pow(2, mantissaLength); 3173 exponent = exponent - eBias; 3174 } 3175 3176 return (sign ? -1 : 1) * mantissa * pow(2, exponent - mantissaLength); 3177 }; 3178 3179 var ieee754 = { 3180 pack: pack, 3181 unpack: unpack 3182 }; 3183 3184 // `Array.prototype.fill` method implementation 3185 // https://tc39.es/ecma262/#sec-array.prototype.fill 3186 3187 3188 var arrayFill = function fill(value 3189 /* , start = 0, end = @length */ 3190 ) { 3191 var O = toObject(this); 3192 var length = lengthOfArrayLike(O); 3193 var argumentsLength = arguments.length; 3194 var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length); 3195 var end = argumentsLength > 2 ? arguments[2] : undefined; 3196 var endPos = end === undefined ? length : toAbsoluteIndex(end, length); 3197 3198 while (endPos > index) O[index++] = value; 3199 3200 return O; 3201 }; 3202 3203 var defineProperty$1 = objectDefineProperty.f; 3204 3205 3206 3207 3208 3209 var TO_STRING_TAG$3 = wellKnownSymbol('toStringTag'); 3210 3211 var setToStringTag = function (it, TAG, STATIC) { 3212 if (it && !hasOwnProperty_1(it = STATIC ? it : it.prototype, TO_STRING_TAG$3)) { 3213 defineProperty$1(it, TO_STRING_TAG$3, { 3214 configurable: true, 3215 value: TAG 3216 }); 3217 } 3218 }; 3219 3220 var getOwnPropertyNames = objectGetOwnPropertyNames.f; 3221 3222 var defineProperty$2 = objectDefineProperty.f; 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 var PROPER_FUNCTION_NAME = functionName.PROPER; 3233 var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE; 3234 var getInternalState = internalState.get; 3235 var setInternalState = internalState.set; 3236 var ARRAY_BUFFER = 'ArrayBuffer'; 3237 var DATA_VIEW = 'DataView'; 3238 var PROTOTYPE$1 = 'prototype'; 3239 var WRONG_LENGTH = 'Wrong length'; 3240 var WRONG_INDEX = 'Wrong index'; 3241 var NativeArrayBuffer = global_1[ARRAY_BUFFER]; 3242 var $ArrayBuffer = NativeArrayBuffer; 3243 var ArrayBufferPrototype = $ArrayBuffer && $ArrayBuffer[PROTOTYPE$1]; 3244 var $DataView = global_1[DATA_VIEW]; 3245 var DataViewPrototype = $DataView && $DataView[PROTOTYPE$1]; 3246 var ObjectPrototype$1 = Object.prototype; 3247 var Array$3 = global_1.Array; 3248 var RangeError$1 = global_1.RangeError; 3249 var fill = functionUncurryThis(arrayFill); 3250 var reverse = functionUncurryThis([].reverse); 3251 var packIEEE754 = ieee754.pack; 3252 var unpackIEEE754 = ieee754.unpack; 3253 3254 var packInt8 = function (number) { 3255 return [number & 0xFF]; 3256 }; 3257 3258 var packInt16 = function (number) { 3259 return [number & 0xFF, number >> 8 & 0xFF]; 3260 }; 3261 3262 var packInt32 = function (number) { 3263 return [number & 0xFF, number >> 8 & 0xFF, number >> 16 & 0xFF, number >> 24 & 0xFF]; 3264 }; 3265 3266 var unpackInt32 = function (buffer) { 3267 return buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0]; 3268 }; 3269 3270 var packFloat32 = function (number) { 3271 return packIEEE754(number, 23, 4); 3272 }; 3273 3274 var packFloat64 = function (number) { 3275 return packIEEE754(number, 52, 8); 3276 }; 3277 3278 var addGetter = function (Constructor, key) { 3279 defineProperty$2(Constructor[PROTOTYPE$1], key, { 3280 get: function () { 3281 return getInternalState(this)[key]; 3282 } 3283 }); 3284 }; 3285 3286 var get$1 = function (view, count, index, isLittleEndian) { 3287 var intIndex = toIndex(index); 3288 var store = getInternalState(view); 3289 if (intIndex + count > store.byteLength) throw RangeError$1(WRONG_INDEX); 3290 var bytes = getInternalState(store.buffer).bytes; 3291 var start = intIndex + store.byteOffset; 3292 var pack = arraySliceSimple(bytes, start, start + count); 3293 return isLittleEndian ? pack : reverse(pack); 3294 }; 3295 3296 var set$1 = function (view, count, index, conversion, value, isLittleEndian) { 3297 var intIndex = toIndex(index); 3298 var store = getInternalState(view); 3299 if (intIndex + count > store.byteLength) throw RangeError$1(WRONG_INDEX); 3300 var bytes = getInternalState(store.buffer).bytes; 3301 var start = intIndex + store.byteOffset; 3302 var pack = conversion(+value); 3303 3304 for (var i = 0; i < count; i++) bytes[start + i] = pack[isLittleEndian ? i : count - i - 1]; 3305 }; 3306 3307 if (!arrayBufferNative) { 3308 $ArrayBuffer = function ArrayBuffer(length) { 3309 anInstance(this, ArrayBufferPrototype); 3310 var byteLength = toIndex(length); 3311 setInternalState(this, { 3312 bytes: fill(Array$3(byteLength), 0), 3313 byteLength: byteLength 3314 }); 3315 if (!descriptors) this.byteLength = byteLength; 3316 }; 3317 3318 ArrayBufferPrototype = $ArrayBuffer[PROTOTYPE$1]; 3319 3320 $DataView = function DataView(buffer, byteOffset, byteLength) { 3321 anInstance(this, DataViewPrototype); 3322 anInstance(buffer, ArrayBufferPrototype); 3323 var bufferLength = getInternalState(buffer).byteLength; 3324 var offset = toIntegerOrInfinity(byteOffset); 3325 if (offset < 0 || offset > bufferLength) throw RangeError$1('Wrong offset'); 3326 byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength); 3327 if (offset + byteLength > bufferLength) throw RangeError$1(WRONG_LENGTH); 3328 setInternalState(this, { 3329 buffer: buffer, 3330 byteLength: byteLength, 3331 byteOffset: offset 3332 }); 3333 3334 if (!descriptors) { 3335 this.buffer = buffer; 3336 this.byteLength = byteLength; 3337 this.byteOffset = offset; 3338 } 3339 }; 3340 3341 DataViewPrototype = $DataView[PROTOTYPE$1]; 3342 3343 if (descriptors) { 3344 addGetter($ArrayBuffer, 'byteLength'); 3345 addGetter($DataView, 'buffer'); 3346 addGetter($DataView, 'byteLength'); 3347 addGetter($DataView, 'byteOffset'); 3348 } 3349 3350 redefineAll(DataViewPrototype, { 3351 getInt8: function getInt8(byteOffset) { 3352 return get$1(this, 1, byteOffset)[0] << 24 >> 24; 3353 }, 3354 getUint8: function getUint8(byteOffset) { 3355 return get$1(this, 1, byteOffset)[0]; 3356 }, 3357 getInt16: function getInt16(byteOffset 3358 /* , littleEndian */ 3359 ) { 3360 var bytes = get$1(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined);
vendor: 5,073 bytes, lines 3361-3499
3361 return (bytes[1] << 8 | bytes[0]) << 16 >> 16; 3362 }, 3363 getUint16: function getUint16(byteOffset 3364 /* , littleEndian */ 3365 ) { 3366 var bytes = get$1(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined); 3367 return bytes[1] << 8 | bytes[0]; 3368 }, 3369 getInt32: function getInt32(byteOffset 3370 /* , littleEndian */ 3371 ) { 3372 return unpackInt32(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)); 3373 }, 3374 getUint32: function getUint32(byteOffset 3375 /* , littleEndian */ 3376 ) { 3377 return unpackInt32(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)) >>> 0; 3378 }, 3379 getFloat32: function getFloat32(byteOffset 3380 /* , littleEndian */ 3381 ) { 3382 return unpackIEEE754(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 23); 3383 }, 3384 getFloat64: function getFloat64(byteOffset 3385 /* , littleEndian */ 3386 ) { 3387 return unpackIEEE754(get$1(this, 8, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 52); 3388 }, 3389 setInt8: function setInt8(byteOffset, value) { 3390 set$1(this, 1, byteOffset, packInt8, value); 3391 }, 3392 setUint8: function setUint8(byteOffset, value) { 3393 set$1(this, 1, byteOffset, packInt8, value); 3394 }, 3395 setInt16: function setInt16(byteOffset, value 3396 /* , littleEndian */ 3397 ) { 3398 set$1(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined); 3399 }, 3400 setUint16: function setUint16(byteOffset, value 3401 /* , littleEndian */ 3402 ) { 3403 set$1(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined); 3404 }, 3405 setInt32: function setInt32(byteOffset, value 3406 /* , littleEndian */ 3407 ) { 3408 set$1(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined); 3409 }, 3410 setUint32: function setUint32(byteOffset, value 3411 /* , littleEndian */ 3412 ) { 3413 set$1(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined); 3414 }, 3415 setFloat32: function setFloat32(byteOffset, value 3416 /* , littleEndian */ 3417 ) { 3418 set$1(this, 4, byteOffset, packFloat32, value, arguments.length > 2 ? arguments[2] : undefined); 3419 }, 3420 setFloat64: function setFloat64(byteOffset, value 3421 /* , littleEndian */ 3422 ) { 3423 set$1(this, 8, byteOffset, packFloat64, value, arguments.length > 2 ? arguments[2] : undefined); 3424 } 3425 }); 3426 } else { 3427 var INCORRECT_ARRAY_BUFFER_NAME = PROPER_FUNCTION_NAME && NativeArrayBuffer.name !== ARRAY_BUFFER; 3428 /* eslint-disable no-new -- required for testing */ 3429 3430 if (!fails(function () { 3431 NativeArrayBuffer(1); 3432 }) || !fails(function () { 3433 new NativeArrayBuffer(-1); 3434 }) || fails(function () { 3435 new NativeArrayBuffer(); 3436 new NativeArrayBuffer(1.5); 3437 new NativeArrayBuffer(NaN); 3438 return INCORRECT_ARRAY_BUFFER_NAME && !CONFIGURABLE_FUNCTION_NAME; 3439 })) { 3440 /* eslint-enable no-new -- required for testing */ 3441 $ArrayBuffer = function ArrayBuffer(length) { 3442 anInstance(this, ArrayBufferPrototype); 3443 return new NativeArrayBuffer(toIndex(length)); 3444 }; 3445 3446 $ArrayBuffer[PROTOTYPE$1] = ArrayBufferPrototype; 3447 3448 for (var keys$1 = getOwnPropertyNames(NativeArrayBuffer), j = 0, key; keys$1.length > j;) { 3449 if (!((key = keys$1[j++]) in $ArrayBuffer)) { 3450 createNonEnumerableProperty($ArrayBuffer, key, NativeArrayBuffer[key]); 3451 } 3452 } 3453 3454 ArrayBufferPrototype.constructor = $ArrayBuffer; 3455 } else if (INCORRECT_ARRAY_BUFFER_NAME && CONFIGURABLE_FUNCTION_NAME) { 3456 createNonEnumerableProperty(NativeArrayBuffer, 'name', ARRAY_BUFFER); 3457 } // WebKit bug - the same parent prototype for typed arrays and data view 3458 3459 3460 if (objectSetPrototypeOf && objectGetPrototypeOf(DataViewPrototype) !== ObjectPrototype$1) { 3461 objectSetPrototypeOf(DataViewPrototype, ObjectPrototype$1); 3462 } // iOS Safari 7.x bug 3463 3464 3465 var testView = new $DataView(new $ArrayBuffer(2)); 3466 var $setInt8 = functionUncurryThis(DataViewPrototype.setInt8); 3467 testView.setInt8(0, 2147483648); 3468 testView.setInt8(1, 2147483649); 3469 if (testView.getInt8(0) || !testView.getInt8(1)) redefineAll(DataViewPrototype, { 3470 setInt8: function setInt8(byteOffset, value) { 3471 $setInt8(this, byteOffset, value << 24 >> 24); 3472 }, 3473 setUint8: function setUint8(byteOffset, value) { 3474 $setInt8(this, byteOffset, value << 24 >> 24); 3475 } 3476 }, { 3477 unsafe: true 3478 }); 3479 } 3480 3481 setToStringTag($ArrayBuffer, ARRAY_BUFFER); 3482 setToStringTag($DataView, DATA_VIEW); 3483 var arrayBuffer = { 3484 ArrayBuffer: $ArrayBuffer, 3485 DataView: $DataView 3486 }; 3487 3488 var noop = function () { 3489 /* empty */ 3490 }; 3491 3492 var empty = []; 3493 var construct = getBuiltIn('Reflect', 'construct'); 3494 var constructorRegExp = /^\s*(?:class|function)\b/; 3495 var exec = functionUncurryThis(constructorRegExp.exec); 3496 var INCORRECT_TO_STRING = !constructorRegExp.exec(noop); 3497 3498 var isConstructorModern = function (argument) { 3499 if (!isCallable(argument)) return false;
3500 3501 try { 3502 construct(noop, empty, argument); 3503 return true; 3504 } catch (error) { 3505 return false; 3506 } 3507 }; 3508 3509 var isConstructorLegacy = function (argument) { 3510 if (!isCallable(argument)) return false; 3511 3512 switch (classof(argument)) { 3513 case 'AsyncFunction': 3514 case 'GeneratorFunction': 3515 case 'AsyncGeneratorFunction': 3516 return false; 3517 // we can't check .prototype since constructors produced by .bind haven't it 3518 } 3519 3520 return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument)); 3521 }; // `IsConstructor` abstract operation 3522 // https://tc39.es/ecma262/#sec-isconstructor 3523 3524 3525 var isConstructor = !construct || fails(function () { 3526 var called; 3527 return isConstructorModern(isConstructorModern.call) || !isConstructorModern(Object) || !isConstructorModern(function () { 3528 called = true; 3529 }) || called; 3530 }) ? isConstructorLegacy : isConstructorModern; 3531 3532 var TypeError$c = global_1.TypeError; // `Assert: IsConstructor(argument) is true` 3533 3534 var aConstructor = function (argument) { 3535 if (isConstructor(argument)) return argument; 3536 throw TypeError$c(tryToString(argument) + ' is not a constructor'); 3537 }; 3538 3539 var SPECIES = wellKnownSymbol('species'); // `SpeciesConstructor` abstract operation 3540 // https://tc39.es/ecma262/#sec-speciesconstructor 3541 3542 var speciesConstructor = function (O, defaultConstructor) { 3543 var C = anObject(O).constructor; 3544 var S; 3545 return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aConstructor(S); 3546 }; 3547 3548 var ArrayBuffer$1 = arrayBuffer.ArrayBuffer; 3549 var DataView$1 = arrayBuffer.DataView; 3550 var DataViewPrototype$1 = DataView$1.prototype; 3551 var un$ArrayBufferSlice = functionUncurryThis(ArrayBuffer$1.prototype.slice); 3552 var getUint8 = functionUncurryThis(DataViewPrototype$1.getUint8); 3553 var setUint8 = functionUncurryThis(DataViewPrototype$1.setUint8); 3554 var INCORRECT_SLICE = fails(function () { 3555 return !new ArrayBuffer$1(2).slice(1, undefined).byteLength; 3556 }); // `ArrayBuffer.prototype.slice` method 3557 // https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice 3558 3559 _export({ 3560 target: 'ArrayBuffer', 3561 proto: true, 3562 unsafe: true, 3563 forced: INCORRECT_SLICE 3564 }, { 3565 slice: function slice(start, end) { 3566 if (un$ArrayBufferSlice && end === undefined) { 3567 return un$ArrayBufferSlice(anObject(this), start); // FF fix 3568 } 3569 3570 var length = anObject(this).byteLength; 3571 var first = toAbsoluteIndex(start, length); 3572 var fin = toAbsoluteIndex(end === undefined ? length : end, length); 3573 var result = new (speciesConstructor(this, ArrayBuffer$1))(toLength(fin - first)); 3574 var viewSource = new DataView$1(this); 3575 var viewTarget = new DataView$1(result); 3576 var index = 0; 3577 3578 while (first < fin) { 3579 setUint8(viewTarget, index++, getUint8(viewSource, first++)); 3580 } 3581 3582 return result; 3583 } 3584 }); 3585 3586 // `Object.fromEntries` method 3587 // https://github.com/tc39/proposal-object-from-entries 3588 3589 3590 _export({ 3591 target: 'Object', 3592 stat: true 3593 }, { 3594 fromEntries: function fromEntries(iterable) { 3595 var obj = {}; 3596 iterate(iterable, function (k, v) { 3597 createProperty(obj, k, v); 3598 }, { 3599 AS_ENTRIES: true 3600 }); 3601 return obj; 3602 } 3603 }); 3604 3605 // `Object.hasOwn` method 3606 // https://github.com/tc39/proposal-accessible-object-hasownproperty 3607 3608 3609 _export({ 3610 target: 'Object', 3611 stat: true 3612 }, { 3613 hasOwn: hasOwnProperty_1 3614 }); 3615 3616 var PromiseCapability = function (C) { 3617 var resolve, reject; 3618 this.promise = new C(function ($$resolve, $$reject) { 3619 if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor'); 3620 resolve = $$resolve; 3621 reject = $$reject; 3622 }); 3623 this.resolve = aCallable(resolve); 3624 this.reject = aCallable(reject); 3625 }; // `NewPromiseCapability` abstract operation 3626 // https://tc39.es/ecma262/#sec-newpromisecapability 3627 3628 3629 var f$5 = function (C) { 3630 return new PromiseCapability(C); 3631 }; 3632 3633 var newPromiseCapability = { 3634 f: f$5 3635 }; 3636 3637 var perform = function (exec) { 3638 try { 3639 return { 3640 error: false, 3641 value: exec() 3642 }; 3643 } catch (error) { 3644 return { 3645 error: true, 3646 value: error 3647 }; 3648 } 3649 }; 3650 3651 // `Promise.allSettled` method 3652 // https://tc39.es/ecma262/#sec-promise.allsettled 3653 3654 3655 _export({ 3656 target: 'Promise', 3657 stat: true 3658 }, { 3659 allSettled: function allSettled(iterable) { 3660 var C = this; 3661 var capability = newPromiseCapability.f(C); 3662 var resolve = capability.resolve; 3663 var reject = capability.reject; 3664 var result = perform(function () { 3665 var promiseResolve = aCallable(C.resolve); 3666 var values = []; 3667 var counter = 0; 3668 var remaining = 1; 3669 iterate(iterable, function (promise) { 3670 var index = counter++; 3671 var alreadyCalled = false;
vendor: 2,994 bytes, lines 3672-3771
3672 remaining++; 3673 functionCall(promiseResolve, C, promise).then(function (value) { 3674 if (alreadyCalled) return; 3675 alreadyCalled = true; 3676 values[index] = { 3677 status: 'fulfilled', 3678 value: value 3679 }; 3680 --remaining || resolve(values); 3681 }, function (error) { 3682 if (alreadyCalled) return; 3683 alreadyCalled = true; 3684 values[index] = { 3685 status: 'rejected', 3686 reason: error 3687 }; 3688 --remaining || resolve(values); 3689 }); 3690 }); 3691 --remaining || resolve(values); 3692 }); 3693 if (result.error) reject(result.value); 3694 return capability.promise; 3695 } 3696 }); 3697 3698 var PROMISE_ANY_ERROR = 'No one promise resolved'; // `Promise.any` method 3699 // https://tc39.es/ecma262/#sec-promise.any 3700 3701 _export({ 3702 target: 'Promise', 3703 stat: true 3704 }, { 3705 any: function any(iterable) { 3706 var C = this; 3707 var AggregateError = getBuiltIn('AggregateError'); 3708 var capability = newPromiseCapability.f(C); 3709 var resolve = capability.resolve; 3710 var reject = capability.reject; 3711 var result = perform(function () { 3712 var promiseResolve = aCallable(C.resolve); 3713 var errors = []; 3714 var counter = 0; 3715 var remaining = 1; 3716 var alreadyResolved = false; 3717 iterate(iterable, function (promise) { 3718 var index = counter++; 3719 var alreadyRejected = false; 3720 remaining++; 3721 functionCall(promiseResolve, C, promise).then(function (value) { 3722 if (alreadyRejected || alreadyResolved) return; 3723 alreadyResolved = true; 3724 resolve(value); 3725 }, function (error) { 3726 if (alreadyRejected || alreadyResolved) return; 3727 alreadyRejected = true; 3728 errors[index] = error; 3729 --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR)); 3730 }); 3731 }); 3732 --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR)); 3733 }); 3734 if (result.error) reject(result.value); 3735 return capability.promise; 3736 } 3737 }); 3738 3739 var nativePromiseConstructor = global_1.Promise; 3740 3741 var promiseResolve = function (C, x) { 3742 anObject(C); 3743 if (isObject(x) && x.constructor === C) return x; 3744 var promiseCapability = newPromiseCapability.f(C); 3745 var resolve = promiseCapability.resolve; 3746 resolve(x); 3747 return promiseCapability.promise; 3748 }; 3749 3750 // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829 3751 3752 3753 var NON_GENERIC = !!nativePromiseConstructor && fails(function () { 3754 nativePromiseConstructor.prototype['finally'].call({ 3755 then: function () { 3756 /* empty */ 3757 } 3758 }, function () { 3759 /* empty */ 3760 }); 3761 }); // `Promise.prototype.finally` method 3762 // https://tc39.es/ecma262/#sec-promise.prototype.finally 3763 3764 _export({ 3765 target: 'Promise', 3766 proto: true, 3767 real: true, 3768 forced: NON_GENERIC 3769 }, { 3770 'finally': function (onFinally) { 3771 var C = speciesConstructor(this, getBuiltIn('Promise'));
3772 var isFunction = isCallable(onFinally); 3773 return this.then(isFunction ? function (x) { 3774 return promiseResolve(C, onFinally()).then(function () { 3775 return x; 3776 }); 3777 } : onFinally, isFunction ? function (e) { 3778 return promiseResolve(C, onFinally()).then(function () { 3779 throw e; 3780 }); 3781 } : onFinally); 3782 } 3783 }); // makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then` 3784 3785 if (!isPure && isCallable(nativePromiseConstructor)) { 3786 var method = getBuiltIn('Promise').prototype['finally']; 3787 3788 if (nativePromiseConstructor.prototype['finally'] !== method) { 3789 redefine(nativePromiseConstructor.prototype, 'finally', method, { 3790 unsafe: true 3791 }); 3792 } 3793 } 3794 3795 var ITERATOR$2 = wellKnownSymbol('iterator'); 3796 var BUGGY_SAFARI_ITERATORS = false; // `%IteratorPrototype%` object 3797 // https://tc39.es/ecma262/#sec-%iteratorprototype%-object 3798 3799 var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator; 3800 /* eslint-disable es/no-array-prototype-keys -- safe */ 3801 3802 if ([].keys) { 3803 arrayIterator = [].keys(); // Safari 8 has buggy iterators w/o `next` 3804 3805 if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;else { 3806 PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator)); 3807 if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype; 3808 } 3809 } 3810 3811 var NEW_ITERATOR_PROTOTYPE = IteratorPrototype == undefined || fails(function () { 3812 var test = {}; // FF44- legacy iterators case 3813 3814 return IteratorPrototype[ITERATOR$2].call(test) !== test; 3815 }); 3816 if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {}; // `%IteratorPrototype%[@@iterator]()` method 3817 // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator 3818 3819 if (!isCallable(IteratorPrototype[ITERATOR$2])) { 3820 redefine(IteratorPrototype, ITERATOR$2, function () { 3821 return this; 3822 }); 3823 } 3824 3825 var iteratorsCore = { 3826 IteratorPrototype: IteratorPrototype, 3827 BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS 3828 }; 3829 3830 var IteratorPrototype$1 = iteratorsCore.IteratorPrototype; 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 var returnThis = function () { 3841 return this; 3842 }; 3843 3844 var createIteratorConstructor = function (IteratorConstructor, NAME, next) { 3845 var TO_STRING_TAG = NAME + ' Iterator'; 3846 IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, { 3847 next: createPropertyDescriptor(1, next) 3848 }); 3849 setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true); 3850 iterators[TO_STRING_TAG] = returnThis; 3851 return IteratorConstructor; 3852 }; 3853 3854 var MATCH = wellKnownSymbol('match'); // `IsRegExp` abstract operation 3855 // https://tc39.es/ecma262/#sec-isregexp 3856 3857 var isRegexp = function (it) { 3858 var isRegExp; 3859 return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classofRaw(it) == 'RegExp'); 3860 }; 3861 3862 // `RegExp.prototype.flags` getter implementation 3863 // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags 3864 3865 3866 var regexpFlags = function () { 3867 var that = anObject(this); 3868 var result = ''; 3869 if (that.global) result += 'g'; 3870 if (that.ignoreCase) result += 'i'; 3871 if (that.multiline) result += 'm'; 3872 if (that.dotAll) result += 's'; 3873 if (that.unicode) result += 'u'; 3874 if (that.sticky) result += 'y'; 3875 return result; 3876 }; 3877 3878 var charAt = functionUncurryThis(''.charAt); 3879 var charCodeAt = functionUncurryThis(''.charCodeAt); 3880 var stringSlice$1 = functionUncurryThis(''.slice); 3881 3882 var createMethod$1 = function (CONVERT_TO_STRING) { 3883 return function ($this, pos) { 3884 var S = toString_1(requireObjectCoercible($this)); 3885 var position = toIntegerOrInfinity(pos); 3886 var size = S.length; 3887 var first, second; 3888 if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined; 3889 first = charCodeAt(S, position); 3890 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; 3891 }; 3892 }; 3893 3894 var stringMultibyte = { 3895 // `String.prototype.codePointAt` method 3896 // https://tc39.es/ecma262/#sec-string.prototype.codepointat 3897 codeAt: createMethod$1(false), 3898 // `String.prototype.at` method 3899 // https://github.com/mathiasbynens/String.prototype.at 3900 charAt: createMethod$1(true) 3901 }; 3902 3903 var charAt$1 = stringMultibyte.charAt; // `AdvanceStringIndex` abstract operation 3904 // https://tc39.es/ecma262/#sec-advancestringindex 3905 3906 3907 var advanceStringIndex = function (S, index, unicode) { 3908 return index + (unicode ? charAt$1(S, index).length : 1); 3909 }; 3910 3911 // babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError 3912 3913 3914 var $RegExp = global_1.RegExp; 3915 var UNSUPPORTED_Y = fails(function () { 3916 var re = $RegExp('a', 'y'); 3917 re.lastIndex = 2; 3918 return re.exec('abcd') != null; 3919 }); // UC Browser bug 3920 // https://github.com/zloirock/core-js/issues/1008 3921 3922 var MISSED_STICKY = UNSUPPORTED_Y || fails(function () { 3923 return !$RegExp('a', 'y').sticky; 3924 }); 3925 var BROKEN_CARET = UNSUPPORTED_Y || fails(function () { 3926 // https://bugzilla.mozilla.org/show_bug.cgi?id=773687 3927 var re = $RegExp('^r', 'gy'); 3928 re.lastIndex = 2; 3929 return re.exec('str') != null; 3930 }); 3931 var regexpStickyHelpers = { 3932 BROKEN_CARET: BROKEN_CARET, 3933 MISSED_STICKY: MISSED_STICKY, 3934 UNSUPPORTED_Y: UNSUPPORTED_Y 3935 }; 3936 3937 // babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError 3938 3939 3940 var $RegExp$1 = global_1.RegExp; 3941 var regexpUnsupportedDotAll = fails(function () { 3942 var re = $RegExp$1('.', 's'); 3943 return !(re.dotAll && re.exec('\n') && re.flags === 's'); 3944 }); 3945 3946 // babel-minify and Closure Compiler transpiles RegExp('(?<a>b)', 'g') -> /(?<a>b)/g and it causes SyntaxError 3947 3948 3949 var $RegExp$2 = global_1.RegExp; 3950 var regexpUnsupportedNcg = fails(function () {
vendor: 5,743 bytes, lines 3951-4184
3951 var re = $RegExp$2('(?<a>b)', 'g'); 3952 return re.exec('b').groups.a !== 'b' || 'b'.replace(re, '$<a>c') !== 'bc'; 3953 }); 3954 3955 /* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */ 3956 3957 /* eslint-disable regexp/no-useless-quantifier -- testing */ 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 var getInternalState$1 = internalState.get; 3974 3975 3976 3977 3978 3979 var nativeReplace = shared('native-string-replace', String.prototype.replace); 3980 var nativeExec = RegExp.prototype.exec; 3981 var patchedExec = nativeExec; 3982 var charAt$2 = functionUncurryThis(''.charAt); 3983 var indexOf$1 = functionUncurryThis(''.indexOf); 3984 var replace$1 = functionUncurryThis(''.replace); 3985 var stringSlice$2 = functionUncurryThis(''.slice); 3986 3987 var UPDATES_LAST_INDEX_WRONG = function () { 3988 var re1 = /a/; 3989 var re2 = /b*/g; 3990 functionCall(nativeExec, re1, 'a'); 3991 functionCall(nativeExec, re2, 'a'); 3992 return re1.lastIndex !== 0 || re2.lastIndex !== 0; 3993 }(); 3994 3995 var UNSUPPORTED_Y$1 = regexpStickyHelpers.BROKEN_CARET; // nonparticipating capturing group, copied from es5-shim's String#split patch. 3996 3997 var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; 3998 var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$1 || regexpUnsupportedDotAll || regexpUnsupportedNcg; 3999 4000 if (PATCH) { 4001 patchedExec = function exec(string) { 4002 var re = this; 4003 var state = getInternalState$1(re); 4004 var str = toString_1(string); 4005 var raw = state.raw; 4006 var result, reCopy, lastIndex, match, i, object, group; 4007 4008 if (raw) { 4009 raw.lastIndex = re.lastIndex; 4010 result = functionCall(patchedExec, raw, str); 4011 re.lastIndex = raw.lastIndex; 4012 return result; 4013 } 4014 4015 var groups = state.groups; 4016 var sticky = UNSUPPORTED_Y$1 && re.sticky; 4017 var flags = functionCall(regexpFlags, re); 4018 var source = re.source; 4019 var charsAdded = 0; 4020 var strCopy = str; 4021 4022 if (sticky) { 4023 flags = replace$1(flags, 'y', ''); 4024 4025 if (indexOf$1(flags, 'g') === -1) { 4026 flags += 'g'; 4027 } 4028 4029 strCopy = stringSlice$2(str, re.lastIndex); // Support anchored sticky behavior. 4030 4031 if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$2(str, re.lastIndex - 1) !== '\n')) { 4032 source = '(?: ' + source + ')'; 4033 strCopy = ' ' + strCopy; 4034 charsAdded++; 4035 } // ^(? + rx + ) is needed, in combination with some str slicing, to 4036 // simulate the 'y' flag. 4037 4038 4039 reCopy = new RegExp('^(?:' + source + ')', flags); 4040 } 4041 4042 if (NPCG_INCLUDED) { 4043 reCopy = new RegExp('^' + source + '$(?!\\s)', flags); 4044 } 4045 4046 if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex; 4047 match = functionCall(nativeExec, sticky ? reCopy : re, strCopy); 4048 4049 if (sticky) { 4050 if (match) { 4051 match.input = stringSlice$2(match.input, charsAdded); 4052 match[0] = stringSlice$2(match[0], charsAdded); 4053 match.index = re.lastIndex; 4054 re.lastIndex += match[0].length; 4055 } else re.lastIndex = 0; 4056 } else if (UPDATES_LAST_INDEX_WRONG && match) { 4057 re.lastIndex = re.global ? match.index + match[0].length : lastIndex; 4058 } 4059 4060 if (NPCG_INCLUDED && match && match.length > 1) { 4061 // Fix browsers whose `exec` methods don't consistently return `undefined` 4062 // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/ 4063 functionCall(nativeReplace, match[0], reCopy, function () { 4064 for (i = 1; i < arguments.length - 2; i++) { 4065 if (arguments[i] === undefined) match[i] = undefined; 4066 } 4067 }); 4068 } 4069 4070 if (match && groups) { 4071 match.groups = object = objectCreate(null); 4072 4073 for (i = 0; i < groups.length; i++) { 4074 group = groups[i]; 4075 object[group[0]] = match[group[1]]; 4076 } 4077 } 4078 4079 return match; 4080 }; 4081 } 4082 4083 var regexpExec = patchedExec; 4084 4085 var TypeError$d = global_1.TypeError; // `RegExpExec` abstract operation 4086 // https://tc39.es/ecma262/#sec-regexpexec 4087 4088 var regexpExecAbstract = function (R, S) { 4089 var exec = R.exec; 4090 4091 if (isCallable(exec)) { 4092 var result = functionCall(exec, R, S); 4093 if (result !== null) anObject(result); 4094 return result; 4095 } 4096 4097 if (classofRaw(R) === 'RegExp') return functionCall(regexpExec, R, S); 4098 throw TypeError$d('RegExp#exec called on incompatible receiver'); 4099 }; 4100 4101 /* eslint-disable es/no-string-prototype-matchall -- safe */ 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 var MATCH_ALL = wellKnownSymbol('matchAll'); 4148 var REGEXP_STRING = 'RegExp String'; 4149 var REGEXP_STRING_ITERATOR = REGEXP_STRING + ' Iterator'; 4150 var setInternalState$1 = internalState.set; 4151 var getInternalState$2 = internalState.getterFor(REGEXP_STRING_ITERATOR); 4152 var RegExpPrototype = RegExp.prototype; 4153 var TypeError$e = global_1.TypeError; 4154 var getFlags = functionUncurryThis(regexpFlags); 4155 var stringIndexOf = functionUncurryThis(''.indexOf); 4156 var un$MatchAll = functionUncurryThis(''.matchAll); 4157 var WORKS_WITH_NON_GLOBAL_REGEX = !!un$MatchAll && !fails(function () { 4158 un$MatchAll('a', /./); 4159 }); 4160 var $RegExpStringIterator = createIteratorConstructor(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$2(this); 4171 if (state.done) return { 4172 value: undefined, 4173 done: true 4174 }; 4175 var R = state.regexp; 4176 var S = state.string; 4177 var match = regexpExecAbstract(R, S); 4178 if (match === null) return { 4179 value: undefined, 4180 done: state.done = true 4181 }; 4182 4183 if (state.global) { 4184 if (toString_1(match[0]) === '') R.lastIndex = advanceStringIndex(S, toLe
4184ngth(R.lastIndex), state.unicode); 4185 return { 4186 value: match, 4187 done: false 4188 }; 4189 } 4190 4191 state.done = true; 4192 return { 4193 value: match, 4194 done: false 4195 }; 4196 }); 4197 4198 var $matchAll = function (string) { 4199 var R = anObject(this); 4200 var S = toString_1(string); 4201 var C, flagsValue, flags, matcher, $global, fullUnicode; 4202 C = speciesConstructor(R, RegExp); 4203 flagsValue = R.flags; 4204 4205 if (flagsValue === undefined && objectIsPrototypeOf(RegExpPrototype, R) && !('flags' in RegExpPrototype)) { 4206 flagsValue = getFlags(R); 4207 } 4208 4209 flags = flagsValue === undefined ? '' : toString_1(flagsValue); 4210 matcher = new C(C === RegExp ? R.source : R, flags); 4211 $global = !!~stringIndexOf(flags, 'g'); 4212 fullUnicode = !!~stringIndexOf(flags, 'u'); 4213 matcher.lastIndex = toLength(R.lastIndex); 4214 return new $RegExpStringIterator(matcher, S, $global, fullUnicode); 4215 }; // `String.prototype.matchAll` method 4216 // https://tc39.es/ecma262/#sec-string.prototype.matchall 4217 4218 4219 _export({ 4220 target: 'String', 4221 proto: true, 4222 forced: WORKS_WITH_NON_GLOBAL_REGEX 4223 }, { 4224 matchAll: function matchAll(regexp) { 4225 var O = requireObjectCoercible(this); 4226 var flags, S, matcher, rx; 4227 4228 if (regexp != null) { 4229 if (isRegexp(regexp)) { 4230 flags = toString_1(requireObjectCoercible('flags' in RegExpPrototype ? regexp.flags : getFlags(regexp))); 4231 if (!~stringIndexOf(flags, 'g')) throw TypeError$e('`.matchAll` does not allow non-global regexes'); 4232 } 4233 4234 if (WORKS_WITH_NON_GLOBAL_REGEX) return un$MatchAll(O, regexp); 4235 matcher = getMethod(regexp, MATCH_ALL); 4236 if (matcher === undefined && isPure && classofRaw(regexp) == 'RegExp') matcher = $matchAll; 4237 if (matcher) return functionCall(matcher, regexp, O); 4238 } else if (WORKS_WITH_NON_GLOBAL_REGEX) return un$MatchAll(O, regexp); 4239 4240 S = toString_1(O); 4241 rx = new RegExp(regexp, 'g'); 4242 return isPure ? functionCall($matchAll, rx, S) : rx[MATCH_ALL](S); 4243 } 4244 }); 4245 isPure || MATCH_ALL in RegExpPrototype || redefine(RegExpPrototype, MATCH_ALL, $matchAll); 4246 4247 var floor$2 = Math.floor; 4248 var charAt$3 = functionUncurryThis(''.charAt); 4249 var replace$2 = functionUncurryThis(''.replace); 4250 var stringSlice$3 = functionUncurryThis(''.slice); 4251 var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g; 4252 var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g; // `GetSubstitution` abstract operation 4253 // https://tc39.es/ecma262/#sec-getsubstitution 4254 4255 var getSubstitution = function (matched, str, position, captures, namedCaptures, replacement) { 4256 var tailPos = position + matched.length; 4257 var m = captures.length; 4258 var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED; 4259 4260 if (namedCaptures !== undefined) { 4261 namedCaptures = toObject(namedCaptures); 4262 symbols = SUBSTITUTION_SYMBOLS; 4263 } 4264 4265 return replace$2(replacement, symbols, function (match, ch) { 4266 var capture; 4267 4268 switch (charAt$3(ch, 0)) { 4269 case '$': 4270 return '$'; 4271 4272 case '&': 4273 return matched; 4274 4275 case '`': 4276 return stringSlice$3(str, 0, position); 4277 4278 case "'": 4279 return stringSlice$3(str, tailPos); 4280 4281 case '<': 4282 capture = namedCaptures[stringSlice$3(ch, 1, -1)]; 4283 break; 4284 4285 default: 4286 // \d\d? 4287 var n = +ch; 4288 if (n === 0) return match; 4289 4290 if (n > m) { 4291 var f = floor$2(n / 10); 4292 if (f === 0) return match; 4293 if (f <= m) return captures[f - 1] === undefined ? charAt$3(ch, 1) : captures[f - 1] + charAt$3(ch, 1); 4294 return match; 4295 } 4296 4297 capture = captures[n - 1]; 4298 } 4299 4300 return capture === undefined ? '' : capture; 4301 }); 4302 }; 4303 4304 var REPLACE = wellKnownSymbol('replace'); 4305 var RegExpPrototype$1 = RegExp.prototype; 4306 var TypeError$f = global_1.TypeError; 4307 var getFlags$1 = functionUncurryThis(regexpFlags); 4308 var indexOf$2 = functionUncurryThis(''.indexOf); 4309 var replace$3 = functionUncurryThis(''.replace); 4310 var stringSlice$4 = functionUncurryThis(''.slice); 4311 var max$2 = Math.max; 4312 4313 var stringIndexOf$1 = function (string, searchValue, fromIndex) { 4314 if (fromIndex > string.length) return -1; 4315 if (searchValue === '') return fromIndex; 4316 return indexOf$2(string, searchValue, fromIndex); 4317 }; // `String.prototype.replaceAll` method 4318 // https://tc39.es/ecma262/#sec-string.prototype.replaceall 4319 4320 4321 _export({ 4322 target: 'String', 4323 proto: true 4324 }, { 4325 replaceAll: function replaceAll(searchValue, replaceValue) { 4326 var O = requireObjectCoercible(this); 4327 var IS_REG_EXP, flags, replacer, string, searchString, functionalReplace, searchLength, advanceBy, replacement; 4328 var position = 0; 4329 var endOfLastMatch = 0; 4330 var result = ''; 4331 4332 if (searchValue != null) { 4333 IS_REG_EXP = isRegexp(searchValue); 4334 4335 if (IS_REG_EXP) { 4336 flags = toString_1(requireObjectCoercible('flags' in RegExpPrototype$1 ? searchValue.flags : getFlags$1(searchValue))); 4337 if (!~indexOf$2(flags, 'g')) throw TypeError$f('`.replaceAll` does not allow non-global regexes'); 4338 } 4339 4340 replacer = getMethod(searchValue, REPLACE); 4341 4342 if (replacer) { 4343 return functionCall(replacer, searchValue, O, replaceValue); 4344 } else if (isPure && IS_REG_EXP) { 4345 return replace$3(toString_1(O), searchValue, replaceValue); 4346 } 4347 } 4348 4349 string = toString_1(O); 4350 searchString = toString_1(searchValue); 4351 functionalReplace = isCallable(replaceValue); 4352 if (!functionalReplace) replaceValue = toString_1(replaceValue); 4353 searchLength = searchString.length; 4354 advanceBy = max$2(1, searchLength); 4355 position = stringIndexOf$1(string, searchString, 0); 4356 4357 while (position !== -1) { 4358 replacement = functionalReplace ? toString_1(replaceValue(searchString, position, string)) : getSubstitution(searchString, string, position, [], undefined, replaceValue); 4359 result += stringSlice$4(string, endOfLastMatch, position) + replacement; 4360 endOfLastMatch = position + searchLength; 4361 position = stringIndexOf$1(string, searchString, position + advanceBy); 4362 } 4363 4364 if (endOfLastMatch < string.length) { 4365 result += stringSlice$4(string, endOfLastMatch); 4366 } 4367 4368 return result; 4369 } 4370 }); 4371 4372 var ITERATOR$3 = wellKnownSymbol('iterator'); 4373 var SAFE_CLOSING = false;
vendor: 4,474 bytes, lines 4374-4517
4374 4375 var checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) { 4376 if (!SKIP_CLOSING && !SAFE_CLOSING) return false; 4377 var ITERATION_SUPPORT = false; 4378 4379 try { 4380 var object = {}; 4381 4382 object[ITERATOR$3] = function () { 4383 return { 4384 next: function () { 4385 return { 4386 done: ITERATION_SUPPORT = true 4387 }; 4388 } 4389 }; 4390 }; 4391 4392 exec(object); 4393 } catch (error) { 4394 /* empty */ 4395 } 4396 4397 return ITERATION_SUPPORT; 4398 }; 4399 4400 var defineProperty$3 = objectDefineProperty.f; 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 var Int8Array = global_1.Int8Array; 4413 var Int8ArrayPrototype = Int8Array && Int8Array.prototype; 4414 var Uint8ClampedArray = global_1.Uint8ClampedArray; 4415 var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype; 4416 var TypedArray = Int8Array && objectGetPrototypeOf(Int8Array); 4417 var TypedArrayPrototype = Int8ArrayPrototype && objectGetPrototypeOf(Int8ArrayPrototype); 4418 var ObjectPrototype$2 = Object.prototype; 4419 var TypeError$g = global_1.TypeError; 4420 var TO_STRING_TAG$4 = wellKnownSymbol('toStringTag'); 4421 var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG'); 4422 var TYPED_ARRAY_CONSTRUCTOR = uid('TYPED_ARRAY_CONSTRUCTOR'); // Fixing native typed arrays in Opera Presto crashes the browser, see #595 4423 4424 var NATIVE_ARRAY_BUFFER_VIEWS = arrayBufferNative && !!objectSetPrototypeOf && classof(global_1.opera) !== 'Opera'; 4425 var TYPED_ARRAY_TAG_REQIRED = false; 4426 var NAME, Constructor, Prototype; 4427 var TypedArrayConstructorsList = { 4428 Int8Array: 1, 4429 Uint8Array: 1, 4430 Uint8ClampedArray: 1, 4431 Int16Array: 2, 4432 Uint16Array: 2, 4433 Int32Array: 4, 4434 Uint32Array: 4, 4435 Float32Array: 4, 4436 Float64Array: 8 4437 }; 4438 var BigIntArrayConstructorsList = { 4439 BigInt64Array: 8, 4440 BigUint64Array: 8 4441 }; 4442 4443 var isView = function isView(it) { 4444 if (!isObject(it)) return false; 4445 var klass = classof(it); 4446 return klass === 'DataView' || hasOwnProperty_1(TypedArrayConstructorsList, klass) || hasOwnProperty_1(BigIntArrayConstructorsList, klass); 4447 }; 4448 4449 var isTypedArray = function (it) { 4450 if (!isObject(it)) return false; 4451 var klass = classof(it); 4452 return hasOwnProperty_1(TypedArrayConstructorsList, klass) || hasOwnProperty_1(BigIntArrayConstructorsList, klass); 4453 }; 4454 4455 var aTypedArray = function (it) { 4456 if (isTypedArray(it)) return it; 4457 throw TypeError$g('Target is not a typed array'); 4458 }; 4459 4460 var aTypedArrayConstructor = function (C) { 4461 if (isCallable(C) && (!objectSetPrototypeOf || objectIsPrototypeOf(TypedArray, C))) return C; 4462 throw TypeError$g(tryToString(C) + ' is not a typed array constructor'); 4463 }; 4464 4465 var exportTypedArrayMethod = function (KEY, property, forced) { 4466 if (!descriptors) return; 4467 if (forced) for (var ARRAY in TypedArrayConstructorsList) { 4468 var TypedArrayConstructor = global_1[ARRAY]; 4469 if (TypedArrayConstructor && hasOwnProperty_1(TypedArrayConstructor.prototype, KEY)) try { 4470 delete TypedArrayConstructor.prototype[KEY]; 4471 } catch (error) { 4472 /* empty */ 4473 } 4474 } 4475 4476 if (!TypedArrayPrototype[KEY] || forced) { 4477 redefine(TypedArrayPrototype, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property); 4478 } 4479 }; 4480 4481 var exportTypedArrayStaticMethod = function (KEY, property, forced) { 4482 var ARRAY, TypedArrayConstructor; 4483 if (!descriptors) return; 4484 4485 if (objectSetPrototypeOf) { 4486 if (forced) for (ARRAY in TypedArrayConstructorsList) { 4487 TypedArrayConstructor = global_1[ARRAY]; 4488 if (TypedArrayConstructor && hasOwnProperty_1(TypedArrayConstructor, KEY)) try { 4489 delete TypedArrayConstructor[KEY]; 4490 } catch (error) { 4491 /* empty */ 4492 } 4493 } 4494 4495 if (!TypedArray[KEY] || forced) { 4496 // V8 ~ Chrome 49-50 `%TypedArray%` methods are non-writable non-configurable 4497 try { 4498 return redefine(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && TypedArray[KEY] || property); 4499 } catch (error) { 4500 /* empty */ 4501 } 4502 } else return; 4503 } 4504 4505 for (ARRAY in TypedArrayConstructorsList) { 4506 TypedArrayConstructor = global_1[ARRAY]; 4507 4508 if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) { 4509 redefine(TypedArrayConstructor, KEY, property); 4510 } 4511 } 4512 }; 4513 4514 for (NAME in TypedArrayConstructorsList) { 4515 Constructor = global_1[NAME]; 4516 Prototype = Constructor && Constructor.prototype; 4517 if (Prototype) createNonEnumerableProperty(Prototype, TYPED_ARRAY_CONSTRUCTOR, Constructor);else NATIVE_ARRAY_BUFFER_VIEWS = false;
vendor: 5,622 bytes, lines 4518-4690
4518 } 4519 4520 for (NAME in BigIntArrayConstructorsList) { 4521 Constructor = global_1[NAME]; 4522 Prototype = Constructor && Constructor.prototype; 4523 if (Prototype) createNonEnumerableProperty(Prototype, TYPED_ARRAY_CONSTRUCTOR, Constructor); 4524 } // WebKit bug - typed arrays constructors prototype is Object.prototype 4525 4526 4527 if (!NATIVE_ARRAY_BUFFER_VIEWS || !isCallable(TypedArray) || TypedArray === Function.prototype) { 4528 // eslint-disable-next-line no-shadow -- safe 4529 TypedArray = function TypedArray() { 4530 throw TypeError$g('Incorrect invocation'); 4531 }; 4532 4533 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { 4534 if (global_1[NAME]) objectSetPrototypeOf(global_1[NAME], TypedArray); 4535 } 4536 } 4537 4538 if (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype$2) { 4539 TypedArrayPrototype = TypedArray.prototype; 4540 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { 4541 if (global_1[NAME]) objectSetPrototypeOf(global_1[NAME].prototype, TypedArrayPrototype); 4542 } 4543 } // WebKit bug - one more object in Uint8ClampedArray prototype chain 4544 4545 4546 if (NATIVE_ARRAY_BUFFER_VIEWS && objectGetPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) { 4547 objectSetPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype); 4548 } 4549 4550 if (descriptors && !hasOwnProperty_1(TypedArrayPrototype, TO_STRING_TAG$4)) { 4551 TYPED_ARRAY_TAG_REQIRED = true; 4552 defineProperty$3(TypedArrayPrototype, TO_STRING_TAG$4, { 4553 get: function () { 4554 return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined; 4555 } 4556 }); 4557 4558 for (NAME in TypedArrayConstructorsList) if (global_1[NAME]) { 4559 createNonEnumerableProperty(global_1[NAME], TYPED_ARRAY_TAG, NAME); 4560 } 4561 } 4562 4563 var arrayBufferViewCore = { 4564 NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS, 4565 TYPED_ARRAY_CONSTRUCTOR: TYPED_ARRAY_CONSTRUCTOR, 4566 TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQIRED && TYPED_ARRAY_TAG, 4567 aTypedArray: aTypedArray, 4568 aTypedArrayConstructor: aTypedArrayConstructor, 4569 exportTypedArrayMethod: exportTypedArrayMethod, 4570 exportTypedArrayStaticMethod: exportTypedArrayStaticMethod, 4571 isView: isView, 4572 isTypedArray: isTypedArray, 4573 TypedArray: TypedArray, 4574 TypedArrayPrototype: TypedArrayPrototype 4575 }; 4576 4577 /* eslint-disable no-new -- required for testing */ 4578 4579 4580 4581 4582 4583 4584 var NATIVE_ARRAY_BUFFER_VIEWS$1 = arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; 4585 4586 var ArrayBuffer$2 = global_1.ArrayBuffer; 4587 var Int8Array$1 = global_1.Int8Array; 4588 var typedArrayConstructorsRequireWrappers = !NATIVE_ARRAY_BUFFER_VIEWS$1 || !fails(function () { 4589 Int8Array$1(1); 4590 }) || !fails(function () { 4591 new Int8Array$1(-1); 4592 }) || !checkCorrectnessOfIteration(function (iterable) { 4593 new Int8Array$1(); 4594 new Int8Array$1(null); 4595 new Int8Array$1(1.5); 4596 new Int8Array$1(iterable); 4597 }, true) || fails(function () { 4598 // Safari (11+) bug - a reason why even Safari 13 should load a typed array polyfill 4599 return new Int8Array$1(new ArrayBuffer$2(2), 1, undefined).length !== 1; 4600 }); 4601 4602 var floor$3 = Math.floor; // `IsIntegralNumber` abstract operation 4603 // https://tc39.es/ecma262/#sec-isintegralnumber 4604 // eslint-disable-next-line es/no-number-isinteger -- safe 4605 4606 var isIntegralNumber = Number.isInteger || function isInteger(it) { 4607 return !isObject(it) && isFinite(it) && floor$3(it) === it; 4608 }; 4609 4610 var RangeError$2 = global_1.RangeError; 4611 4612 var toPositiveInteger = function (it) { 4613 var result = toIntegerOrInfinity(it); 4614 if (result < 0) throw RangeError$2("The argument can't be less than 0"); 4615 return result; 4616 }; 4617 4618 var RangeError$3 = global_1.RangeError; 4619 4620 var toOffset = function (it, BYTES) { 4621 var offset = toPositiveInteger(it); 4622 if (offset % BYTES) throw RangeError$3('Wrong offset'); 4623 return offset; 4624 }; 4625 4626 var aTypedArrayConstructor$1 = arrayBufferViewCore.aTypedArrayConstructor; 4627 4628 var typedArrayFrom = function from(source 4629 /* , mapfn, thisArg */ 4630 ) { 4631 var C = aConstructor(this); 4632 var O = toObject(source); 4633 var argumentsLength = arguments.length; 4634 var mapfn = argumentsLength > 1 ? arguments[1] : undefined; 4635 var mapping = mapfn !== undefined; 4636 var iteratorMethod = getIteratorMethod(O); 4637 var i, length, result, step, iterator, next; 4638 4639 if (iteratorMethod && !isArrayIteratorMethod(iteratorMethod)) { 4640 iterator = getIterator(O, iteratorMethod); 4641 next = iterator.next; 4642 O = []; 4643 4644 while (!(step = functionCall(next, iterator)).done) { 4645 O.push(step.value); 4646 } 4647 } 4648 4649 if (mapping && argumentsLength > 2) { 4650 mapfn = functionBindContext(mapfn, arguments[2]); 4651 } 4652 4653 length = lengthOfArrayLike(O); 4654 result = new (aTypedArrayConstructor$1(C))(length); 4655 4656 for (i = 0; length > i; i++) { 4657 result[i] = mapping ? mapfn(O[i], i) : O[i]; 4658 } 4659 4660 return result; 4661 }; 4662 4663 var SPECIES$1 = wellKnownSymbol('species'); 4664 var Array$4 = global_1.Array; // a part of `ArraySpeciesCreate` abstract operation 4665 // https://tc39.es/ecma262/#sec-arrayspeciescreate 4666 4667 var arraySpeciesConstructor = function (originalArray) { 4668 var C; 4669 4670 if (isArray(originalArray)) { 4671 C = originalArray.constructor; // cross-realm fallback 4672 4673 if (isConstructor(C) && (C === Array$4 || isArray(C.prototype))) C = undefined;else if (isObject(C)) { 4674 C = C[SPECIES$1]; 4675 if (C === null) C = undefined; 4676 } 4677 } 4678 4679 return C === undefined ? Array$4 : C; 4680 }; 4681 4682 // `ArraySpeciesCreate` abstract operation 4683 // https://tc39.es/ecma262/#sec-arrayspeciescreate 4684 4685 4686 var arraySpeciesCreate = function (originalArray, length) { 4687 return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length); 4688 }; 4689 4690 var push$2 = functionUncurryThis([].push);
4690 // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation 4691 4692 var createMethod$2 = function (TYPE) { 4693 var IS_MAP = TYPE == 1; 4694 var IS_FILTER = TYPE == 2; 4695 var IS_SOME = TYPE == 3; 4696 var IS_EVERY = TYPE == 4; 4697 var IS_FIND_INDEX = TYPE == 6; 4698 var IS_FILTER_REJECT = TYPE == 7; 4699 var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; 4700 return function ($this, callbackfn, that, specificCreate) { 4701 var O = toObject($this); 4702 var self = indexedObject(O); 4703 var boundFunction = functionBindContext(callbackfn, that); 4704 var length = lengthOfArrayLike(self); 4705 var index = 0; 4706 var create = specificCreate || arraySpeciesCreate; 4707 var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined; 4708 var value, result; 4709 4710 for (; length > index; index++) if (NO_HOLES || index in self) { 4711 value = self[index]; 4712 result = boundFunction(value, index, O); 4713 4714 if (TYPE) { 4715 if (IS_MAP) target[index] = result; // map 4716 else if (result) switch (TYPE) { 4717 case 3: 4718 return true; 4719 // some 4720 4721 case 5: 4722 return value; 4723 // find 4724 4725 case 6: 4726 return index; 4727 // findIndex 4728 4729 case 2: 4730 push$2(target, value); 4731 // filter 4732 } else switch (TYPE) { 4733 case 4: 4734 return false; 4735 // every 4736 4737 case 7: 4738 push$2(target, value); 4739 // filterReject 4740 } 4741 } 4742 } 4743 4744 return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target; 4745 }; 4746 }; 4747 4748 var arrayIteration = { 4749 // `Array.prototype.forEach` method 4750 // https://tc39.es/ecma262/#sec-array.prototype.foreach 4751 forEach: createMethod$2(0), 4752 // `Array.prototype.map` method 4753 // https://tc39.es/ecma262/#sec-array.prototype.map 4754 map: createMethod$2(1), 4755 // `Array.prototype.filter` method 4756 // https://tc39.es/ecma262/#sec-array.prototype.filter 4757 filter: createMethod$2(2), 4758 // `Array.prototype.some` method 4759 // https://tc39.es/ecma262/#sec-array.prototype.some 4760 some: createMethod$2(3), 4761 // `Array.prototype.every` method 4762 // https://tc39.es/ecma262/#sec-array.prototype.every 4763 every: createMethod$2(4), 4764 // `Array.prototype.find` method 4765 // https://tc39.es/ecma262/#sec-array.prototype.find 4766 find: createMethod$2(5), 4767 // `Array.prototype.findIndex` method 4768 // https://tc39.es/ecma262/#sec-array.prototype.findIndex 4769 findIndex: createMethod$2(6), 4770 // `Array.prototype.filterReject` method 4771 // https://github.com/tc39/proposal-array-filtering 4772 filterReject: createMethod$2(7) 4773 }; 4774 4775 var SPECIES$2 = wellKnownSymbol('species'); 4776 4777 var setSpecies = function (CONSTRUCTOR_NAME) { 4778 var Constructor = getBuiltIn(CONSTRUCTOR_NAME); 4779 var defineProperty = objectDefineProperty.f; 4780 4781 if (descriptors && Constructor && !Constructor[SPECIES$2]) { 4782 defineProperty(Constructor, SPECIES$2, { 4783 configurable: true, 4784 get: function () { 4785 return this; 4786 } 4787 }); 4788 } 4789 }; 4790 4791 // makes subclassing work correct for wrapped built-ins 4792 4793 4794 var inheritIfRequired = function ($this, dummy, Wrapper) { 4795 var NewTarget, NewTargetPrototype; 4796 if ( // it can work only with native `setPrototypeOf` 4797 objectSetPrototypeOf && // we haven't completely correct pre-ES6 way for getting `new.target`, so use this 4798 isCallable(NewTarget = dummy.constructor) && NewTarget !== Wrapper && isObject(NewTargetPrototype = NewTarget.prototype) && NewTargetPrototype !== Wrapper.prototype) objectSetPrototypeOf($this, NewTargetPrototype); 4799 return $this; 4800 }; 4801 4802 var typedArrayConstructor = createCommonjsModule(function (module) { 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 var getOwnPropertyNames = objectGetOwnPropertyNames.f; 4849 4850 4851
vendor: 7,113 bytes, lines 4852-5034
4852 var forEach = arrayIteration.forEach; 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 var getInternalState = internalState.get; 4865 var setInternalState = internalState.set; 4866 var nativeDefineProperty = objectDefineProperty.f; 4867 var nativeGetOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; 4868 var round = Math.round; 4869 var RangeError = global_1.RangeError; 4870 var ArrayBuffer = arrayBuffer.ArrayBuffer; 4871 var ArrayBufferPrototype = ArrayBuffer.prototype; 4872 var DataView = arrayBuffer.DataView; 4873 var NATIVE_ARRAY_BUFFER_VIEWS = arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; 4874 var TYPED_ARRAY_CONSTRUCTOR = arrayBufferViewCore.TYPED_ARRAY_CONSTRUCTOR; 4875 var TYPED_ARRAY_TAG = arrayBufferViewCore.TYPED_ARRAY_TAG; 4876 var TypedArray = arrayBufferViewCore.TypedArray; 4877 var TypedArrayPrototype = arrayBufferViewCore.TypedArrayPrototype; 4878 var aTypedArrayConstructor = arrayBufferViewCore.aTypedArrayConstructor; 4879 var isTypedArray = arrayBufferViewCore.isTypedArray; 4880 var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT'; 4881 var WRONG_LENGTH = 'Wrong length'; 4882 4883 var fromList = function (C, list) { 4884 aTypedArrayConstructor(C); 4885 var index = 0; 4886 var length = list.length; 4887 var result = new C(length); 4888 4889 while (length > index) result[index] = list[index++]; 4890 4891 return result; 4892 }; 4893 4894 var addGetter = function (it, key) { 4895 nativeDefineProperty(it, key, { 4896 get: function () { 4897 return getInternalState(this)[key]; 4898 } 4899 }); 4900 }; 4901 4902 var isArrayBuffer = function (it) { 4903 var klass; 4904 return objectIsPrototypeOf(ArrayBufferPrototype, it) || (klass = classof(it)) == 'ArrayBuffer' || klass == 'SharedArrayBuffer'; 4905 }; 4906 4907 var isTypedArrayIndex = function (target, key) { 4908 return isTypedArray(target) && !isSymbol(key) && key in target && isIntegralNumber(+key) && key >= 0; 4909 }; 4910 4911 var wrappedGetOwnPropertyDescriptor = function getOwnPropertyDescriptor(target, key) { 4912 key = toPropertyKey(key); 4913 return isTypedArrayIndex(target, key) ? createPropertyDescriptor(2, target[key]) : nativeGetOwnPropertyDescriptor(target, key); 4914 }; 4915 4916 var wrappedDefineProperty = function defineProperty(target, key, descriptor) { 4917 key = toPropertyKey(key); 4918 4919 if (isTypedArrayIndex(target, key) && isObject(descriptor) && hasOwnProperty_1(descriptor, 'value') && !hasOwnProperty_1(descriptor, 'get') && !hasOwnProperty_1(descriptor, 'set') // TODO: add validation descriptor w/o calling accessors 4920 && !descriptor.configurable && (!hasOwnProperty_1(descriptor, 'writable') || descriptor.writable) && (!hasOwnProperty_1(descriptor, 'enumerable') || descriptor.enumerable)) { 4921 target[key] = descriptor.value; 4922 return target; 4923 } 4924 4925 return nativeDefineProperty(target, key, descriptor); 4926 }; 4927 4928 if (descriptors) { 4929 if (!NATIVE_ARRAY_BUFFER_VIEWS) { 4930 objectGetOwnPropertyDescriptor.f = wrappedGetOwnPropertyDescriptor; 4931 objectDefineProperty.f = wrappedDefineProperty; 4932 addGetter(TypedArrayPrototype, 'buffer'); 4933 addGetter(TypedArrayPrototype, 'byteOffset'); 4934 addGetter(TypedArrayPrototype, 'byteLength'); 4935 addGetter(TypedArrayPrototype, 'length'); 4936 } 4937 4938 _export({ 4939 target: 'Object', 4940 stat: true, 4941 forced: !NATIVE_ARRAY_BUFFER_VIEWS 4942 }, { 4943 getOwnPropertyDescriptor: wrappedGetOwnPropertyDescriptor, 4944 defineProperty: wrappedDefineProperty 4945 }); 4946 4947 module.exports = function (TYPE, wrapper, CLAMPED) { 4948 var BYTES = TYPE.match(/\d+$/)[0] / 8; 4949 var CONSTRUCTOR_NAME = TYPE + (CLAMPED ? 'Clamped' : '') + 'Array'; 4950 var GETTER = 'get' + TYPE; 4951 var SETTER = 'set' + TYPE; 4952 var NativeTypedArrayConstructor = global_1[CONSTRUCTOR_NAME]; 4953 var TypedArrayConstructor = NativeTypedArrayConstructor; 4954 var TypedArrayConstructorPrototype = TypedArrayConstructor && TypedArrayConstructor.prototype; 4955 var exported = {}; 4956 4957 var getter = function (that, index) { 4958 var data = getInternalState(that); 4959 return data.view[GETTER](index * BYTES + data.byteOffset, true); 4960 }; 4961 4962 var setter = function (that, index, value) { 4963 var data = getInternalState(that); 4964 if (CLAMPED) value = (value = round(value)) < 0 ? 0 : value > 0xFF ? 0xFF : value & 0xFF; 4965 data.view[SETTER](index * BYTES + data.byteOffset, value, true); 4966 }; 4967 4968 var addElement = function (that, index) { 4969 nativeDefineProperty(that, index, { 4970 get: function () { 4971 return getter(this, index); 4972 }, 4973 set: function (value) { 4974 return setter(this, index, value); 4975 }, 4976 enumerable: true 4977 }); 4978 }; 4979 4980 if (!NATIVE_ARRAY_BUFFER_VIEWS) { 4981 TypedArrayConstructor = wrapper(function (that, data, offset, $length) { 4982 anInstance(that, TypedArrayConstructorPrototype); 4983 var index = 0; 4984 var byteOffset = 0; 4985 var buffer, byteLength, length; 4986 4987 if (!isObject(data)) { 4988 length = toIndex(data); 4989 byteLength = length * BYTES; 4990 buffer = new ArrayBuffer(byteLength); 4991 } else if (isArrayBuffer(data)) { 4992 buffer = data; 4993 byteOffset = toOffset(offset, BYTES); 4994 var $len = data.byteLength; 4995 4996 if ($length === undefined) { 4997 if ($len % BYTES) throw RangeError(WRONG_LENGTH); 4998 byteLength = $len - byteOffset; 4999 if (byteLength < 0) throw RangeError(WRONG_LENGTH); 5000 } else { 5001 byteLength = toLength($length) * BYTES; 5002 if (byteLength + byteOffset > $len) throw RangeError(WRONG_LENGTH); 5003 } 5004 5005 length = byteLength / BYTES; 5006 } else if (isTypedArray(data)) { 5007 return fromList(TypedArrayConstructor, data); 5008 } else { 5009 return functionCall(typedArrayFrom, TypedArrayConstructor, data); 5010 } 5011 5012 setInternalState(that, { 5013 buffer: buffer, 5014 byteOffset: byteOffset, 5015 byteLength: byteLength, 5016 length: length, 5017 view: new DataView(buffer) 5018 }); 5019 5020 while (index < length) addElement(that, index++); 5021 }); 5022 if (objectSetPrototypeOf) objectSetPrototypeOf(TypedArrayConstructor, TypedArray); 5023 TypedArrayConstructorPrototype = TypedArrayConstructor.prototype = objectCreate(TypedArrayPrototype); 5024 } else if (typedArrayConstructorsRequireWrappers) { 5025 TypedArrayConstructor = wrapper(function (dummy, data, typedArrayOffset, $length) { 5026 anInstance(dummy, TypedArrayConstructorPrototype); 5027 return inheritIfRequired(function () { 5028 if (!isObject(data)) return new NativeTypedArrayConstructor(toIndex(data)); 5029 if (isArrayBuffer(data)) return $length !== undefined ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES), $length) : typedArrayOffset !== undefined ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES)) : new NativeTypedArrayConstructor(data); 5030 if (isTypedArray(data)) return fromList(TypedArrayConstructor, data); 5031 return functionCall(typedArrayFrom, TypedArrayConstructor, data); 5032 }(), dummy, TypedArrayConstructor); 5033 }); 5034 if (objectSetPrototypeOf) objectSetPrototypeOf(TypedArrayConstructor, TypedArray);
5035 forEach(getOwnPropertyNames(NativeTypedArrayConstructor), function (key) { 5036 if (!(key in TypedArrayConstructor)) { 5037 createNonEnumerableProperty(TypedArrayConstructor, key, NativeTypedArrayConstructor[key]); 5038 } 5039 }); 5040 TypedArrayConstructor.prototype = TypedArrayConstructorPrototype; 5041 } 5042 5043 if (TypedArrayConstructorPrototype.constructor !== TypedArrayConstructor) { 5044 createNonEnumerableProperty(TypedArrayConstructorPrototype, 'constructor', TypedArrayConstructor); 5045 } 5046 5047 createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_CONSTRUCTOR, TypedArrayConstructor); 5048 5049 if (TYPED_ARRAY_TAG) { 5050 createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_TAG, CONSTRUCTOR_NAME); 5051 } 5052 5053 exported[CONSTRUCTOR_NAME] = TypedArrayConstructor; 5054 _export({ 5055 global: true, 5056 forced: TypedArrayConstructor != NativeTypedArrayConstructor, 5057 sham: !NATIVE_ARRAY_BUFFER_VIEWS 5058 }, exported); 5059 5060 if (!(BYTES_PER_ELEMENT in TypedArrayConstructor)) { 5061 createNonEnumerableProperty(TypedArrayConstructor, BYTES_PER_ELEMENT, BYTES); 5062 } 5063 5064 if (!(BYTES_PER_ELEMENT in TypedArrayConstructorPrototype)) { 5065 createNonEnumerableProperty(TypedArrayConstructorPrototype, BYTES_PER_ELEMENT, BYTES); 5066 } 5067 5068 setSpecies(CONSTRUCTOR_NAME); 5069 }; 5070 } else module.exports = function () { 5071 /* empty */ 5072 }; 5073 }); 5074 5075 // `Float32Array` constructor 5076 // https://tc39.es/ecma262/#sec-typedarray-objects 5077 5078 5079 typedArrayConstructor('Float32', function (init) { 5080 return function Float32Array(data, byteOffset, length) { 5081 return init(this, data, byteOffset, length); 5082 }; 5083 }); 5084 5085 // `Float64Array` constructor 5086 // https://tc39.es/ecma262/#sec-typedarray-objects 5087 5088 5089 typedArrayConstructor('Float64', function (init) { 5090 return function Float64Array(data, byteOffset, length) { 5091 return init(this, data, byteOffset, length); 5092 }; 5093 }); 5094 5095 // `Int8Array` constructor 5096 // https://tc39.es/ecma262/#sec-typedarray-objects 5097 5098 5099 typedArrayConstructor('Int8', function (init) { 5100 return function Int8Array(data, byteOffset, length) { 5101 return init(this, data, byteOffset, length); 5102 }; 5103 }); 5104 5105 // `Int16Array` constructor 5106 // https://tc39.es/ecma262/#sec-typedarray-objects 5107 5108 5109 typedArrayConstructor('Int16', function (init) { 5110 return function Int16Array(data, byteOffset, length) { 5111 return init(this, data, byteOffset, length); 5112 }; 5113 }); 5114 5115 // `Int32Array` constructor 5116 // https://tc39.es/ecma262/#sec-typedarray-objects 5117 5118 5119 typedArrayConstructor('Int32', function (init) { 5120 return function Int32Array(data, byteOffset, length) { 5121 return init(this, data, byteOffset, length); 5122 }; 5123 }); 5124 5125 // `Uint8Array` constructor 5126 // https://tc39.es/ecma262/#sec-typedarray-objects 5127 5128 5129 typedArrayConstructor('Uint8', function (init) { 5130 return function Uint8Array(data, byteOffset, length) { 5131 return init(this, data, byteOffset, length); 5132 }; 5133 }); 5134 5135 // `Uint8ClampedArray` constructor 5136 // https://tc39.es/ecma262/#sec-typedarray-objects 5137 5138 5139 typedArrayConstructor('Uint8', function (init) { 5140 return function Uint8ClampedArray(data, byteOffset, length) { 5141 return init(this, data, byteOffset, length); 5142 }; 5143 }, true); 5144 5145 // `Uint16Array` constructor 5146 // https://tc39.es/ecma262/#sec-typedarray-objects 5147 5148 5149 typedArrayConstructor('Uint16', function (init) { 5150 return function Uint16Array(data, byteOffset, length) { 5151 return init(this, data, byteOffset, length); 5152 }; 5153 }); 5154 5155 // `Uint32Array` constructor 5156 // https://tc39.es/ecma262/#sec-typedarray-objects 5157 5158 5159 typedArrayConstructor('Uint32', function (init) { 5160 return function Uint32Array(data, byteOffset, length) { 5161 return init(this, data, byteOffset, length); 5162 }; 5163 }); 5164 5165 var aTypedArray$1 = arrayBufferViewCore.aTypedArray; 5166 var exportTypedArrayMethod$1 = arrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.at` method 5167 // https://github.com/tc39/proposal-relative-indexing-method 5168 5169 exportTypedArrayMethod$1('at', function at(index) { 5170 var O = aTypedArray$1(this); 5171 var len = lengthOfArrayLike(O); 5172 var relativeIndex = toIntegerOrInfinity(index); 5173 var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; 5174 return k < 0 || k >= len ? undefined : O[k]; 5175 }); 5176 5177 var exportTypedArrayStaticMethod$1 = arrayBufferViewCore.exportTypedArrayStaticMethod; 5178 5179 // `%TypedArray%.from` method 5180 // https://tc39.es/ecma262/#sec-%typedarray%.from 5181 5182 5183 exportTypedArrayStaticMethod$1('from', typedArrayFrom, typedArrayConstructorsRequireWrappers); 5184 5185 var aTypedArrayConstructor$2 = arrayBufferViewCore.aTypedArrayConstructor; 5186 var exportTypedArrayStaticMethod$2 = arrayBufferViewCore.exportTypedArrayStaticMethod; // `%TypedArray%.of` method 5187 // https://tc39.es/ecma262/#sec-%typedarray%.of 5188 5189 exportTypedArrayStaticMethod$2('of', function of() 5190 /* ...items */ 5191 { 5192 var index = 0; 5193 var length = arguments.length; 5194 var result = new (aTypedArrayConstructor$2(this))(length); 5195 5196 while (length > index) result[index] = arguments[index++]; 5197 5198 return result; 5199 }, typedArrayConstructorsRequireWrappers); 5200 5201 var floor$4 = Math.floor; 5202 5203 var mergeSort = function (array, comparefn) { 5204 var length = array.length; 5205 var middle = floor$4(length / 2); 5206 return length < 8 ? insertionSort(array, comparefn) : merge(array, mergeSort(arraySliceSimple(array, 0, middle), comparefn), mergeSort(arraySliceSimple(array, middle), comparefn), comparefn); 5207 }; 5208 5209 var insertionSort = function (array, comparefn) { 5210 var length = array.length; 5211 var i = 1; 5212 var element, j; 5213 5214 while (i < length) { 5215 j = i; 5216 element = array[i]; 5217 5218 while (j && comparefn(array[j - 1], element) > 0) { 5219 array[j] = array[--j]; 5220 } 5221 5222 if (j !== i++) array[j] = element; 5223 } 5224 5225 return array; 5226 }; 5227 5228 var merge = function (array, left, right, comparefn) { 5229 var llength = left.length; 5230 var rlength = right.length; 5231 var lindex = 0; 5232 var rindex = 0; 5233 5234 while (lindex < llength || rindex < rlength) { 5235 array[lindex + rindex] = lindex < llength && rindex < rlength ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++] : lindex < llength ? left[lindex++] : right[rindex++]; 5236 } 5237 5238 return array; 5239 }; 5240 5241 var arraySort = mergeSort; 5242 5243 var firefox = engineUserAgent.match(/firefox\/(\d+)/i); 5244 var engineFfVersion = !!firefox && +firefox[1]; 5245 5246 var engineIsIeOrEdge = /MSIE|Trident/.test(engineUserAgent); 5247
vendor: 4,612 bytes, lines 5248-5392
5248 var webkit = engineUserAgent.match(/AppleWebKit\/(\d+)\./); 5249 var engineWebkitVersion = !!webkit && +webkit[1]; 5250 5251 var Array$5 = global_1.Array; 5252 var aTypedArray$2 = arrayBufferViewCore.aTypedArray; 5253 var exportTypedArrayMethod$2 = arrayBufferViewCore.exportTypedArrayMethod; 5254 var Uint16Array = global_1.Uint16Array; 5255 var un$Sort = Uint16Array && functionUncurryThis(Uint16Array.prototype.sort); // WebKit 5256 5257 var ACCEPT_INCORRECT_ARGUMENTS = !!un$Sort && !(fails(function () { 5258 un$Sort(new Uint16Array(2), null); 5259 }) && fails(function () { 5260 un$Sort(new Uint16Array(2), {}); 5261 })); 5262 var STABLE_SORT = !!un$Sort && !fails(function () { 5263 // feature detection can be too slow, so check engines versions 5264 if (engineV8Version) return engineV8Version < 74; 5265 if (engineFfVersion) return engineFfVersion < 67; 5266 if (engineIsIeOrEdge) return true; 5267 if (engineWebkitVersion) return engineWebkitVersion < 602; 5268 var array = new Uint16Array(516); 5269 var expected = Array$5(516); 5270 var index, mod; 5271 5272 for (index = 0; index < 516; index++) { 5273 mod = index % 4; 5274 array[index] = 515 - index; 5275 expected[index] = index - 2 * mod + 3; 5276 } 5277 5278 un$Sort(array, function (a, b) { 5279 return (a / 4 | 0) - (b / 4 | 0); 5280 }); 5281 5282 for (index = 0; index < 516; index++) { 5283 if (array[index] !== expected[index]) return true; 5284 } 5285 }); 5286 5287 var getSortCompare = function (comparefn) { 5288 return function (x, y) { 5289 if (comparefn !== undefined) return +comparefn(x, y) || 0; // eslint-disable-next-line no-self-compare -- NaN check 5290 5291 if (y !== y) return -1; // eslint-disable-next-line no-self-compare -- NaN check 5292 5293 if (x !== x) return 1; 5294 if (x === 0 && y === 0) return 1 / x > 0 && 1 / y < 0 ? 1 : -1; 5295 return x > y; 5296 }; 5297 }; // `%TypedArray%.prototype.sort` method 5298 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.sort 5299 5300 5301 exportTypedArrayMethod$2('sort', function sort(comparefn) { 5302 if (comparefn !== undefined) aCallable(comparefn); 5303 if (STABLE_SORT) return un$Sort(this, comparefn); 5304 return arraySort(aTypedArray$2(this), getSortCompare(comparefn)); 5305 }, !STABLE_SORT || ACCEPT_INCORRECT_ARGUMENTS); 5306 5307 // iterable DOM collections 5308 // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods 5309 var domIterables = { 5310 CSSRuleList: 0, 5311 CSSStyleDeclaration: 0, 5312 CSSValueList: 0, 5313 ClientRectList: 0, 5314 DOMRectList: 0, 5315 DOMStringList: 0, 5316 DOMTokenList: 1, 5317 DataTransferItemList: 0, 5318 FileList: 0, 5319 HTMLAllCollection: 0, 5320 HTMLCollection: 0, 5321 HTMLFormElement: 0, 5322 HTMLSelectElement: 0, 5323 MediaList: 0, 5324 MimeTypeArray: 0, 5325 NamedNodeMap: 0, 5326 NodeList: 1, 5327 PaintRequestList: 0, 5328 Plugin: 0, 5329 PluginArray: 0, 5330 SVGLengthList: 0, 5331 SVGNumberList: 0, 5332 SVGPathSegList: 0, 5333 SVGPointList: 0, 5334 SVGStringList: 0, 5335 SVGTransformList: 0, 5336 SourceBufferList: 0, 5337 StyleSheetList: 0, 5338 TextTrackCueList: 0, 5339 TextTrackList: 0, 5340 TouchList: 0 5341 }; 5342 5343 // in old WebKit versions, `element.classList` is not an instance of global `DOMTokenList` 5344 5345 5346 var classList = documentCreateElement('span').classList; 5347 var DOMTokenListPrototype = classList && classList.constructor && classList.constructor.prototype; 5348 var domTokenListPrototype = DOMTokenListPrototype === Object.prototype ? undefined : DOMTokenListPrototype; 5349 5350 var PROPER_FUNCTION_NAME$1 = functionName.PROPER; 5351 var CONFIGURABLE_FUNCTION_NAME$1 = functionName.CONFIGURABLE; 5352 var IteratorPrototype$2 = iteratorsCore.IteratorPrototype; 5353 var BUGGY_SAFARI_ITERATORS$1 = iteratorsCore.BUGGY_SAFARI_ITERATORS; 5354 var ITERATOR$4 = wellKnownSymbol('iterator'); 5355 var KEYS = 'keys'; 5356 var VALUES = 'values'; 5357 var ENTRIES = 'entries'; 5358 5359 var returnThis$1 = function () { 5360 return this; 5361 }; 5362 5363 var defineIterator = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) { 5364 createIteratorConstructor(IteratorConstructor, NAME, next); 5365 5366 var getIterationMethod = function (KIND) { 5367 if (KIND === DEFAULT && defaultIterator) return defaultIterator; 5368 if (!BUGGY_SAFARI_ITERATORS$1 && KIND in IterablePrototype) return IterablePrototype[KIND]; 5369 5370 switch (KIND) { 5371 case KEYS: 5372 return function keys() { 5373 return new IteratorConstructor(this, KIND); 5374 }; 5375 5376 case VALUES: 5377 return function values() { 5378 return new IteratorConstructor(this, KIND); 5379 }; 5380 5381 case ENTRIES: 5382 return function entries() { 5383 return new IteratorConstructor(this, KIND); 5384 }; 5385 } 5386 5387 return function () { 5388 return new IteratorConstructor(this); 5389 }; 5390 }; 5391 5392 var TO_STRING_TAG = NAME + ' Iterator';
5393 var INCORRECT_VALUES_NAME = false; 5394 var IterablePrototype = Iterable.prototype; 5395 var nativeIterator = IterablePrototype[ITERATOR$4] || IterablePrototype['@@iterator'] || DEFAULT && IterablePrototype[DEFAULT]; 5396 var defaultIterator = !BUGGY_SAFARI_ITERATORS$1 && nativeIterator || getIterationMethod(DEFAULT); 5397 var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator; 5398 var CurrentIteratorPrototype, methods, KEY; // fix native 5399 5400 if (anyNativeIterator) { 5401 CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable())); 5402 5403 if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) { 5404 if (objectGetPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype$2) { 5405 if (objectSetPrototypeOf) { 5406 objectSetPrototypeOf(CurrentIteratorPrototype, IteratorPrototype$2); 5407 } else if (!isCallable(CurrentIteratorPrototype[ITERATOR$4])) { 5408 redefine(CurrentIteratorPrototype, ITERATOR$4, returnThis$1); 5409 } 5410 } // Set @@toStringTag to native iterators 5411 5412 5413 setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true); 5414 } 5415 } // fix Array.prototype.{ values, @@iterator }.name in V8 / FF 5416 5417 5418 if (PROPER_FUNCTION_NAME$1 && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) { 5419 if (CONFIGURABLE_FUNCTION_NAME$1) { 5420 createNonEnumerableProperty(IterablePrototype, 'name', VALUES); 5421 } else { 5422 INCORRECT_VALUES_NAME = true; 5423 5424 defaultIterator = function values() { 5425 return functionCall(nativeIterator, this); 5426 }; 5427 } 5428 } // export additional methods 5429 5430 5431 if (DEFAULT) { 5432 methods = { 5433 values: getIterationMethod(VALUES), 5434 keys: IS_SET ? defaultIterator : getIterationMethod(KEYS), 5435 entries: getIterationMethod(ENTRIES) 5436 }; 5437 if (FORCED) for (KEY in methods) { 5438 if (BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) { 5439 redefine(IterablePrototype, KEY, methods[KEY]); 5440 } 5441 } else _export({ 5442 target: NAME, 5443 proto: true, 5444 forced: BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME 5445 }, methods); 5446 } // define iterator 5447 5448 5449 if (IterablePrototype[ITERATOR$4] !== defaultIterator) { 5450 redefine(IterablePrototype, ITERATOR$4, defaultIterator, { 5451 name: DEFAULT 5452 }); 5453 } 5454 5455 iterators[NAME] = defaultIterator; 5456 return methods; 5457 }; 5458 5459 var ARRAY_ITERATOR = 'Array Iterator'; 5460 var setInternalState$2 = internalState.set; 5461 var getInternalState$3 = internalState.getterFor(ARRAY_ITERATOR); // `Array.prototype.entries` method 5462 // https://tc39.es/ecma262/#sec-array.prototype.entries 5463 // `Array.prototype.keys` method 5464 // https://tc39.es/ecma262/#sec-array.prototype.keys 5465 // `Array.prototype.values` method 5466 // https://tc39.es/ecma262/#sec-array.prototype.values 5467 // `Array.prototype[@@iterator]` method 5468 // https://tc39.es/ecma262/#sec-array.prototype-@@iterator 5469 // `CreateArrayIterator` internal method 5470 // https://tc39.es/ecma262/#sec-createarrayiterator 5471 5472 var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind) { 5473 setInternalState$2(this, { 5474 type: ARRAY_ITERATOR, 5475 target: toIndexedObject(iterated), 5476 // target 5477 index: 0, 5478 // next index 5479 kind: kind // kind 5480 5481 }); // `%ArrayIteratorPrototype%.next` method 5482 // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next 5483 }, function () { 5484 var state = getInternalState$3(this); 5485 var target = state.target; 5486 var kind = state.kind; 5487 var index = state.index++; 5488 5489 if (!target || index >= target.length) { 5490 state.target = undefined; 5491 return { 5492 value: undefined, 5493 done: true 5494 }; 5495 } 5496 5497 if (kind == 'keys') return { 5498 value: index, 5499 done: false 5500 }; 5501 if (kind == 'values') return { 5502 value: target[index], 5503 done: false 5504 }; 5505 return { 5506 value: [index, target[index]], 5507 done: false 5508 }; 5509 }, 'values'); // argumentsList[@@iterator] is %ArrayProto_values% 5510 // https://tc39.es/ecma262/#sec-createunmappedargumentsobject 5511 // https://tc39.es/ecma262/#sec-createmappedargumentsobject 5512 5513 iterators.Arguments = iterators.Array; // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 5514 5515 addToUnscopables('keys'); 5516 addToUnscopables('values'); 5517 addToUnscopables('entries'); 5518 5519 var ITERATOR$5 = wellKnownSymbol('iterator'); 5520 var TO_STRING_TAG$5 = wellKnownSymbol('toStringTag'); 5521 var ArrayValues = es_array_iterator.values; 5522 5523 var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) { 5524 if (CollectionPrototype) { 5525 // some Chrome versions have non-configurable methods on DOMTokenList 5526 if (CollectionPrototype[ITERATOR$5] !== ArrayValues) try { 5527 createNonEnumerableProperty(CollectionPrototype, ITERATOR$5, ArrayValues); 5528 } catch (error) { 5529 CollectionPrototype[ITERATOR$5] = ArrayValues; 5530 } 5531 5532 if (!CollectionPrototype[TO_STRING_TAG$5]) { 5533 createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG$5, COLLECTION_NAME); 5534 } 5535 5536 if (domIterables[COLLECTION_NAME]) for (var METHOD_NAME in es_array_iterator) { 5537 // some Chrome versions have non-configurable methods on DOMTokenList 5538 if (CollectionPrototype[METHOD_NAME] !== es_array_iterator[METHOD_NAME]) try { 5539 createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, es_array_iterator[METHOD_NAME]); 5540 } catch (error) { 5541 CollectionPrototype[METHOD_NAME] = es_array_iterator[METHOD_NAME]; 5542 } 5543 } 5544 } 5545 }; 5546 5547 for (var COLLECTION_NAME in domIterables) { 5548 handlePrototype(global_1[COLLECTION_NAME] && global_1[COLLECTION_NAME].prototype, COLLECTION_NAME); 5549 } 5550 5551 handlePrototype(domTokenListPrototype, 'DOMTokenList'); 5552 5553 var FunctionPrototype$2 = Function.prototype; 5554 var apply = FunctionPrototype$2.apply; 5555 var bind$2 = FunctionPrototype$2.bind; 5556 var call$2 = FunctionPrototype$2.call; // eslint-disable-next-line es/no-reflect -- safe 5557 5558 var functionApply = typeof Reflect == 'object' && Reflect.apply || (bind$2 ? call$2.bind(apply) : function () { 5559 return call$2.apply(apply, arguments); 5560 }); 5561 5562 var arraySlice = functionUncurryThis([].slice); 5563 5564 var engineIsIos = /(?:ipad|iphone|ipod).*applewebkit/i.test(engineUserAgent); 5565 5566 var engineIsNode = classofRaw(global_1.process) == 'process'; 5567 5568 var set$2 = global_1.setImmediate; 5569 var clear = global_1.clearImmediate; 5570 var process$1 = global_1.process; 5571 var Dispatch = global_1.Dispatch; 5572 var Function$1 = global_1.Function; 5573 var MessageChannel = global_1.MessageChannel; 5574 var String$5 = global_1.String; 5575 var counter = 0; 5576 var queue = {}; 5577 var ONREADYSTATECHANGE = 'onreadystatechange'; 5578 var location, defer, channel, port; 5579 5580 try { 5581 // Deno throws a ReferenceError on `location` access without `--location` flag 5582 location = global_1.location; 5583 } catch (error) { 5584 /* empty */ 5585 } 5586 5587 var run = function (id) { 5588 if (hasOwnProperty_1(queue, id)) { 5589 var fn = queue[id]; 5590 delete queue[id]; 5591 fn(); 5592 } 5593 }; 5594 5595 var runner = function (id) { 5596 return function () { 5597 run(id); 5598 }; 5599 }; 5600 5601 var listener = function (event) { 5602 run(event.data); 5603 }; 5604 5605 var post = function (id) { 5606 // old engines have not location.origin 5607 global_1.postMessage(String$5(id), location.protocol + '//' + location.host); 5608 }; // Node.js 0.9+ & IE10+ has setImmediate, otherwise: 5609 5610 5611 if (!set$2 || !clear) { 5612 set$2 = function setImmediate(fn) { 5613 var args = arraySlice(arguments, 1); 5614 5615 queue[++counter] = function () { 5616 functionApply(isCallable(fn) ? fn : Function$1(fn), undefined, args); 5617 }; 5618 5619 defer(counter); 5620 return counter; 5621 }; 5622 5623 clear = function clearImmediate(id) { 5624 delete queue[id]; 5625 }; // Node.js 0.8- 5626 5627 5628 if (engineIsNode) { 5629 defer = function (id) { 5630 process$1.nextTick(runner(id)); 5631 }; // Sphere (JS game engine) Dispatch API 5632 5633 } else if (Dispatch && Dispatch.now) { 5634 defer = function (id) { 5635 Dispatch.now(runner(id)); 5636 }; // Browsers with MessageChannel, includes WebWorkers 5637 // except iOS - https://github.com/zloirock/core-js/issues/624 5638 5639 } else if (MessageChannel && !engineIsIos) { 5640 channel = new MessageChannel(); 5641 port = channel.port2; 5642 channel.port1.onmessage = listener; 5643 defer = functionBindContext(port.postMessage, port); // Browsers with postMessage, skip WebWorkers 5644 // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' 5645 } else if (global_1.addEventListener && isCallable(global_1.postMessage) && !global_1.importScripts && location && location.protocol !== 'file:' && !fails(post)) { 5646 defer = post; 5647 global_1.addEventListener('message', listener, false); // IE8- 5648 } else if (ONREADYSTATECHANGE in documentCreateElement('script')) { 5649 defer = function (id) { 5650 html.appendChild(documentCreateElement('script'))[ONREADYSTATECHANGE] = function () { 5651 html.removeChild(this); 5652 run(id); 5653 }; 5654 }; // Rest old browsers 5655 5656 } else { 5657 defer = function (id) { 5658 setTimeout(runner(id), 0); 5659 }; 5660 } 5661 } 5662 5663 var task = { 5664 set: set$2, 5665 clear: clear 5666 }; 5667 5668 var FORCED = !global_1.setImmediate || !global_1.clearImmediate; // http://w3c.github.io/setImmediate/ 5669 5670 _export({ 5671 global: true, 5672 bind: true, 5673 enumerable: true, 5674 forced: FORCED 5675 }, { 5676 // `setImmediate` method 5677 // http://w3c.github.io/setImmediate/#si-setImmediate 5678 setImmediate: task.set, 5679 // `clearImmediate` method 5680 // http://w3c.github.io/setImmediate/#si-clearImmediate 5681 clearImmediate: task.clear 5682 }); 5683 5684 var engineIsIosPebble = /ipad|iphone|ipod/i.test(engineUserAgent) && global_1.Pebble !== undefined; 5685 5686 var engineIsWebosWebkit = /web0s(?!.*chrome)/i.test(engineUserAgent); 5687 5688 var getOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f; 5689 5690 var macrotask = task.set; 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 var MutationObserver = global_1.MutationObserver || global_1.WebKitMutationObserver; 5701 var document$2 = global_1.document; 5702 var process$2 = global_1.process; 5703 var Promise = global_1.Promise; // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask` 5704 5705 var queueMicrotaskDescriptor = getOwnPropertyDescriptor$2(global_1, 'queueMicrotask'); 5706 var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value; 5707 var flush, head, last, notify, toggle, node, promise, then; // modern engines have queueMicrotask method 5708 5709 if (!queueMicrotask) { 5710 flush = function () { 5711 var parent, fn; 5712 if (engineIsNode && (parent = process$2.domain)) parent.exit(); 5713 5714 while (head) { 5715 fn = head.fn; 5716 head = head.next; 5717 5718 try { 5719 fn(); 5720 } catch (error) { 5721 if (head) notify();else last = undefined; 5722 throw error; 5723 } 5724 } 5725 5726 last = undefined; 5727 if (parent) parent.enter(); 5728 }; // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339 5729 // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898 5730 5731 5732 if (!engineIsIos && !engineIsNode && !engineIsWebosWebkit && MutationObserver && document$2) { 5733 toggle = true; 5734 node = document$2.createTextNode(''); 5735 new MutationObserver(flush).observe(node, { 5736 characterData: true 5737 }); 5738 5739 notify = function () { 5740 node.data = toggle = !toggle; 5741 }; // environments with maybe non-completely correct, but existent Promise 5742 5743 } else if (!engineIsIosPebble && Promise && Promise.resolve) { 5744 // Promise.resolve without an argument throws an error in LG WebOS 2 5745 promise = Promise.resolve(undefined); // workaround of WebKit ~ iOS Safari 10.1 bug 5746 5747 promise.constructor = Promise; 5748 then = functionBindContext(promise.then, promise); 5749 5750 notify = function () { 5751 then(flush); 5752 }; // Node.js without promises 5753 5754 } else if (engineIsNode) { 5755 notify = function () { 5756 process$2.nextTick(flush); 5757 }; // for other environments - macrotask based on: 5758 // - setImmediate 5759 // - MessageChannel 5760 // - window.postMessag 5761 // - onreadystatechange 5762 // - setTimeout 5763 5764 } else { 5765 // strange IE + webpack dev server bug - use .bind(global) 5766 macrotask = functionBindContext(macrotask, global_1); 5767 5768 notify = function () { 5769 macrotask(flush); 5770 }; 5771 } 5772 } 5773 5774 var microtask = queueMicrotask || function (fn) { 5775 var task$$1 = { 5776 fn: fn, 5777 next: undefined 5778 }; 5779 if (last) last.next = task$$1; 5780 5781 if (!head) { 5782 head = task$$1; 5783 notify(); 5784 } 5785 5786 last = task$$1; 5787 }; 5788 5789 var process$3 = global_1.process; // `queueMicrotask` method 5790 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask 5791 5792 _export({ 5793 global: true, 5794 enumerable: true, 5795 noTargetGet: true 5796 }, { 5797 queueMicrotask: function queueMicrotask(fn) { 5798 var domain = engineIsNode && process$3.domain; 5799 microtask(domain ? domain.bind(fn) : fn); 5800 } 5801 }); 5802 5803 // File generated automatically. Don't modify it. 5804 5805}((this.window = this.window || {}))); 5806 5807 5808 5809if (window._main_polyfill_core) 5810{ 5811 console.warn('main.polyfill.core is loaded more than once on this page'); 5812} 5813 5814window._main_polyfill_core = true; 5815 5816 5817(function (exports) { 5818 'use strict'; 5819 5820 var bxTmp = window.BX; 5821 5822 window.BX = function (node) { 5823 if (window.BX.type.isNotEmptyString(node)) { 5824 return document.getElementById(node); 5825 } 5826 5827 if (window.BX.type.isDomNode(node)) { 5828 return node; 5829 } 5830 5831 if (window.BX.type.isFunction(node)) { 5832 return window.BX.ready(node); 5833 } 5834 5835 return null; 5836 }; 5837 5838 if (bxTmp) {
5839 Object.keys(bxTmp).forEach(key => { 5840 window.BX[key] = bxTmp[key]; 5841 }); 5842 } 5843 5844 exports = window.BX; 5845 5846 /** 5847 * Gets object.toString result 5848 * @param value 5849 * @return {string} 5850 */ 5851 function getTag(value) { 5852 return Object.prototype.toString.call(value); 5853 } 5854 5855 const objectCtorString = Function.prototype.toString.call(Object); 5856 /** 5857 * @memberOf BX 5858 */ 5859 5860 let Type = /*#__PURE__*/function () { 5861 function Type() { 5862 babelHelpers.classCallCheck(this, Type); 5863 } 5864 5865 babelHelpers.createClass(Type, null, [{ 5866 key: "isString", 5867 5868 /** 5869 * Checks that value is string 5870 * @param value 5871 * @return {boolean} 5872 */ 5873 value: function isString(value) { 5874 return typeof value === 'string'; 5875 } 5876 /** 5877 * Returns true if a value is not empty string 5878 * @param value 5879 * @returns {boolean} 5880 */ 5881 5882 }, { 5883 key: "isStringFilled", 5884 value: function isStringFilled(value) { 5885 return this.isString(value) && value !== ''; 5886 } 5887 /** 5888 * Checks that value is function 5889 * @param value 5890 * @return {boolean} 5891 */ 5892 5893 }, { 5894 key: "isFunction", 5895 value: function isFunction(value) { 5896 return typeof value === 'function'; 5897 } 5898 /** 5899 * Checks that value is object 5900 * @param value 5901 * @return {boolean} 5902 */ 5903 5904 }, { 5905 key: "isObject", 5906 value: function isObject(value) { 5907 return !!value && (typeof value === 'object' || typeof value === 'function'); 5908 } 5909 /** 5910 * Checks that value is object like 5911 * @param value 5912 * @return {boolean} 5913 */ 5914 5915 }, { 5916 key: "isObjectLike", 5917 value: function isObjectLike(value) { 5918 return !!value && typeof value === 'object'; 5919 } 5920 /** 5921 * Checks that value is plain object 5922 * @param value 5923 * @return {boolean} 5924 */ 5925 5926 }, { 5927 key: "isPlainObject", 5928 value: function isPlainObject(value) { 5929 if (!Type.isObjectLike(value) || getTag(value) !== '[object Object]') { 5930 return false; 5931 } 5932 5933 const proto = Object.getPrototypeOf(value); 5934 5935 if (proto === null) { 5936 return true; 5937 } 5938 5939 const ctor = proto.hasOwnProperty('constructor') && proto.constructor; 5940 return typeof ctor === 'function' && Function.prototype.toString.call(ctor) === objectCtorString; 5941 } 5942 /** 5943 * Checks that value is boolean 5944 * @param value 5945 * @return {boolean} 5946 */ 5947 5948 }, { 5949 key: "isBoolean", 5950 value: function isBoolean(value) { 5951 return value === true || value === false; 5952 } 5953 /** 5954 * Checks that value is number 5955 * @param value 5956 * @return {boolean} 5957 */ 5958 5959 }, { 5960 key: "isNumber", 5961 value: function isNumber(value) { 5962 return !Number.isNaN(value) && typeof value === 'number'; 5963 } 5964 /** 5965 * Checks that value is integer 5966 * @param value 5967 * @return {boolean} 5968 */ 5969 5970 }, { 5971 key: "isInteger", 5972 value: function isInteger(value) { 5973 return Type.isNumber(value) && value % 1 === 0; 5974 } 5975 /** 5976 * Checks that value is float 5977 * @param value 5978 * @return {boolean} 5979 */ 5980 5981 }, { 5982 key: "isFloat", 5983 value: function isFloat(value) { 5984 return Type.isNumber(value) && !Type.isInteger(value); 5985 } 5986 /** 5987 * Checks that value is nil 5988 * @param value 5989 * @return {boolean} 5990 */ 5991 5992 }, { 5993 key: "isNil", 5994 value: function isNil(value) { 5995 return value === null || value === undefined; 5996 } 5997 /** 5998 * Checks that value is array 5999 * @param value 6000 * @return {boolean} 6001 */ 6002 6003 }, { 6004 key: "isArray", 6005 value: function isArray(value) { 6006 return !Type.isNil(value) && Array.isArray(value); 6007 } 6008 /** 6009 * Returns true if a value is an array and it has at least one element 6010 * @param value 6011 * @returns {boolean} 6012 */ 6013 6014 }, { 6015 key: "isArrayFilled", 6016 value: function isArrayFilled(value) { 6017 return this.isArray(value) && value.length > 0; 6018 } 6019 /** 6020 * Checks that value is array like 6021 * @param value 6022 * @return {boolean} 6023 */ 6024 6025 }, { 6026 key: "isArrayLike", 6027 value: function isArrayLike(value) { 6028 return !Type.isNil(value) && !Type.isFunction(value) && value.length > -1 && value.length <= Number.MAX_SAFE_INTEGER; 6029 } 6030 /** 6031 * Checks that value is Date 6032 * @param value 6033 * @return {boolean} 6034 */ 6035 6036 }, { 6037 key: "isDate", 6038 value: function isDate(value) { 6039 return Type.isObjectLike(value) && getTag(value) === '[object Date]'; 6040 } 6041 /** 6042 * Checks that is DOM node 6043 * @param value 6044 * @return {boolean} 6045 */ 6046 6047 }, { 6048 key: "isDomNode", 6049 value: function isDomNode(value) { 6050 return Type.isObjectLike(value) && !Type.isPlainObject(value) && 'nodeType' in value; 6051 } 6052 /** 6053 * Checks that value is element node 6054 * @param value 6055 * @return {boolean} 6056 */ 6057 6058 }, { 6059 key: "isElementNode", 6060 value: function isElementNode(value) { 6061 return Type.isDomNode(value) && value.nodeType === Node.ELEMENT_NODE; 6062 } 6063 /** 6064 * Checks that value is text node 6065 * @param value 6066 * @return {boolean} 6067 */ 6068 6069 }, { 6070 key: "isTextNode", 6071 value: function isTextNode(value) { 6072 return Type.isDomNode(value) && value.nodeType === Node.TEXT_NODE; 6073 } 6074 /** 6075 * Checks that value is Map 6076 * @param value 6077 * @return {boolean} 6078 */ 6079 6080 }, { 6081 key: "isMap", 6082 value: function isMap(value) { 6083 return Type.isObjectLike(value) && getTag(value) === '[object Map]'; 6084 } 6085 /** 6086 * Checks that value is Set 6087 * @param value 6088 * @return {boolean} 6089 */ 6090 6091 }, { 6092 key: "isSet", 6093 value: function isSet(value) { 6094 return Type.isObjectLike(value) && getTag(value) === '[object Set]'; 6095 } 6096 /** 6097 * Checks that value is WeakMap 6098 * @param value 6099 * @return {boolean} 6100 */ 6101 6102 }, { 6103 key: "isWeakMap", 6104 value: function isWeakMap(value) { 6105 return Type.isObjectLike(value) && getTag(value) === '[object WeakMap]'; 6106 } 6107 /** 6108 * Checks that value is WeakSet 6109 * @param value 6110 * @return {boolean} 6111 */ 6112 6113 }, { 6114 key: "isWeakSet", 6115 value: function isWeakSet(value) { 6116 return Type.isObjectLike(value) && getTag(value) === '[object WeakSet]'; 6117 } 6118 /** 6119 * Checks that value is prototype 6120 * @param value 6121 * @return {boolean} 6122 */ 6123 6124 }, { 6125 key: "isPrototype", 6126 value: function isPrototype(value) { 6127 return (typeof (value && value.constructor) === 'function' && value.constructor.prototype || Object.prototype) === value; 6128 } 6129 /** 6130 * Checks that value is regexp 6131 * @param value 6132 * @return {boolean} 6133 */ 6134 6135 }, { 6136 key: "isRegExp", 6137 value: function isRegExp(value) { 6138 return Type.isObjectLike(value) && getTag(value) === '[object RegExp]'; 6139 } 6140 /** 6141 * Checks that value is null 6142 * @param value 6143 * @return {boolean} 6144 */ 6145 6146 }, { 6147 key: "isNull", 6148 value: function isNull(value) { 6149 return value === null; 6150 } 6151 /** 6152 * Checks that value is undefined 6153 * @param value 6154 * @return {boolean} 6155 */ 6156 6157 }, { 6158 key: "isUndefined", 6159 value: function isUndefined(value) { 6160 return typeof value === 'undefined'; 6161 } 6162 /** 6163 * Checks that value is ArrayBuffer 6164 * @param value 6165 * @return {boolean} 6166 */ 6167 6168 }, { 6169 key: "isArrayBuffer", 6170 value: function isArrayBuffer(value) { 6171 return Type.isObjectLike(value) && getTag(value) === '[object ArrayBuffer]'; 6172 } 6173 /** 6174 * Checks that value is typed array 6175 * @param value 6176 * @return {boolean} 6177 */ 6178 6179 }, { 6180 key: "isTypedArray", 6181 value: function isTypedArray(value) { 6182 const regExpTypedTag = /^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)]$/; 6183 return Type.isObjectLike(value) && regExpTypedTag.test(getTag(value)); 6184 } 6185 /** 6186 * Checks that value is Blob 6187 * @param value 6188 * @return {boolean} 6189 */ 6190 6191 }, { 6192 key: "isBlob", 6193 value: function isBlob(value) { 6194 return Type.isObjectLike(value) && Type.isNumber(value.size) && Type.isString(value.type) && Type.isFunction(value.slice); 6195 } 6196 /** 6197 * Checks that value is File 6198 * @param value 6199 * @return {boolean} 6200 */ 6201 6202 }, { 6203 key: "isFile", 6204 value: function isFile(value) { 6205 return Type.isBlob(value) && Type.isString(value.name) && (Type.isNumber(value.lastModified) || Type.isObjectLike(value.lastModifiedDate)); 6206 } 6207 /** 6208 * Checks that value is FormData 6209 * @param value 6210 * @return {boolean} 6211 */ 6212 6213 }, { 6214 key: "isFormData", 6215 value: function isFormData(value) { 6216 return value instanceof FormData; 6217 } 6218 }]); 6219 return Type; 6220 }(); 6221 6222 /** 6223 * @memberOf BX 6224 */ 6225 6226 let Reflection = /*#__PURE__*/function () { 6227 function Reflection() { 6228 babelHelpers.classCallCheck(this, Reflection); 6229 } 6230 6231 babelHelpers.createClass(Reflection, null, [{ 6232 key: "getClass", 6233 6234 /** 6235 * Gets link to function by function name 6236 * @param className 6237 * @return {?Function} 6238 */ 6239 value: function getClass(className) { 6240 if (Type.isString(className) && !!className) { 6241 let classFn = null; 6242 let currentNamespace = window; 6243 const namespaces = className.split('.'); 6244 6245 for (let i = 0; i < namespaces.length; i += 1) { 6246 const namespace = namespaces[i]; 6247 6248 if (!currentNamespace[namespace]) { 6249 return null; 6250 } 6251 6252 currentNamespace = currentNamespace[namespace]; 6253 classFn = currentNamespace; 6254 } 6255 6256 return classFn; 6257 } 6258 6259 if (Type.isFunction(className)) { 6260 return className; 6261 } 6262 6263 return null; 6264 } 6265 /** 6266 * Creates a namespace or returns a link to a previously created one 6267 * @param {String} namespaceName 6268 * @return {Object<string, any> | Function | null} 6269 */ 6270 6271 }, { 6272 key: "namespace", 6273 value: function namespace(namespaceName) { 6274 let parts = namespaceName.split('.'); 6275 let parent = window.BX; 6276 6277 if (parts[0] === 'BX') { 6278 parts = parts.slice(1); 6279 } 6280 6281 for (let i = 0; i < parts.length; i += 1) { 6282 if (Type.isUndefined(parent[parts[i]])) { 6283 parent[parts[i]] = {}; 6284 } 6285 6286 parent = parent[parts[i]]; 6287 } 6288 6289 return parent; 6290 } 6291 }]); 6292 return Reflection; 6293 }(); 6294 6295 const reEscape = /[&<>'"]/g; 6296 const reUnescape = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g; 6297 const escapeEntities = { 6298 '&': '&', 6299 '<': '<', 6300 '>': '>', 6301 "'": ''', 6302 '"': '"' 6303 }; 6304 const unescapeEntities = { 6305 '&': '&', 6306 '&': '&', 6307 '<': '<', 6308 '<': '<', 6309 '>': '>', 6310 '>': '>', 6311 ''': "'", 6312 ''': "'", 6313 '"': '"', 6314 '"': '"' 6315 }; 6316 /** 6317 * @memberOf BX 6318 */ 6319 6320 let Text = /*#__PURE__*/function () { 6321 function Text() { 6322 babelHelpers.classCallCheck(this, Text); 6323 } 6324 6325 babelHelpers.createClass(Text, null, [{ 6326 key: "encode", 6327 6328 /** 6329 * Encodes all unsafe entities 6330 * @param {string} value 6331 * @return {string} 6332 */ 6333 value: function encode(value) { 6334 if (Type.isString(value)) { 6335 return value.replace(reEscape, item => escapeEntities[item]); 6336 } 6337 6338 return value; 6339 } 6340 /** 6341 * Decodes all encoded entities 6342 * @param {string} value 6343 * @return {string} 6344 */ 6345 6346 }, { 6347 key: "decode", 6348 value: function decode(value) { 6349 if (Type.isString(value)) { 6350 return value.replace(reUnescape, item => unescapeEntities[item]); 6351 } 6352 6353 return value; 6354 } 6355 }, { 6356 key: "getRandom", 6357 value: function getRandom(length = 8) { 6358 // eslint-disable-next-line 6359 return [...Array(length)].map(() => (~~(Math.random() * 36)).toString(36)).join(''); 6360 } 6361 }, { 6362 key: "toNumber", 6363 value: function toNumber(value) { 6364 const parsedValue = Number.parseFloat(value); 6365 6366 if (Type.isNumber(parsedValue)) { 6367 return parsedValue; 6368 } 6369 6370 return 0; 6371 } 6372 }, { 6373 key: "toInteger", 6374 value: function toInteger(value) { 6375 return Text.toNumber(Number.parseInt(value, 10)); 6376 } 6377 }, { 6378 key: "toBoolean", 6379 value: function toBoolean(value, trueValues = []) { 6380 const transformedValue = Type.isString(value) ? value.toLowerCase() : value; 6381 return ['true', 'y', '1', 1, true, ...trueValues].includes(transformedValue); 6382 } 6383 }, { 6384 key: "toCamelCase", 6385 value: function toCamelCase(str) { 6386 if (!Type.isStringFilled(str)) { 6387 return str; 6388 } 6389 6390 const regex = /[-_\s]+(.)?/g; 6391 6392 if (!regex.test(str)) { 6393 return str.match(/^[A-Z]+$/) ? str.toLowerCase() : str[0].toLowerCase() + str.slice(1); 6394 } 6395 6396 str = str.toLowerCase(); 6397 str = str.replace(regex, function (match, letter) { 6398 return letter ? letter.toUpperCase() : ''; 6399 }); 6400 return str[0].toLowerCase() + str.substr(1); 6401 } 6402 }, { 6403 key: "toPascalCase", 6404 value: function toPascalCase(str) { 6405 if (!Type.isStringFilled(str)) { 6406 return str; 6407 } 6408 6409 return this.capitalize(this.toCamelCase(str)); 6410 } 6411 }, { 6412 key: "toKebabCase", 6413 value: function toKebabCase(str) { 6414 if (!Type.isStringFilled(str)) { 6415 return str; 6416 } 6417 6418 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); 6419 6420 if (!matches) { 6421 return str; 6422 } 6423 6424 return matches.map(x => x.toLowerCase()).join('-'); 6425 } 6426 }, { 6427 key: "capitalize", 6428 value: function capitalize(str) { 6429 if (!Type.isStringFilled(str)) { 6430 return str; 6431 } 6432 6433 return str[0].toUpperCase() + str.substr(1); 6434 } 6435 }]); 6436 return Text; 6437 }(); 6438 6439 const aliases = { 6440 mousewheel: ['DOMMouseScroll'], 6441 bxchange: ['change', 'cut', 'paste', 'drop', 'keyup'], 6442 animationend: ['animationend', 'oAnimationEnd', 'webkitAnimationEnd', 'MSAnimationEnd'], 6443 transitionend: ['webkitTransitionEnd', 'otransitionend', 'oTransitionEnd', 'msTransitionEnd', 'transitionend'], 6444 fullscreenchange: ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange', 'MSFullscreenChange'], 6445 fullscreenerror: ['fullscreenerror', 'webkitfullscreenerror', 'mozfullscreenerror', 'MSFullscreenError'] 6446 }; 6447 6448 let Registry = /*#__PURE__*/function () { 6449 function Registry() { 6450 babelHelpers.classCallCheck(this, Registry); 6451 babelHelpers.defineProperty(this, "registry", new WeakMap()); 6452 } 6453 6454 babelHelpers.createClass(Registry, [{ 6455 key: "set", 6456 value: function set(target, event, listener) { 6457 const events = this.get(target); 6458 6459 if (!Type.isSet(events[event])) { 6460 events[event] = new Set(); 6461 } 6462 6463 events[event].add(listener); 6464 this.registry.set(target, events); 6465 } 6466 }, { 6467 key: "get", 6468 value: function get(target) { 6469 return this.registry.get(target) || {}; 6470 } 6471 }, { 6472 key: "has", 6473 value: function has(target, event, listener) { 6474 if (event && listener) { 6475 return this.registry.has(target) && this.registry.get(target)[event].has(listener); 6476 } 6477 6478 return this.registry.has(target); 6479 } 6480 }, { 6481 key: "delete", 6482 value: function _delete(target, event, listener) { 6483 if (!Type.isDomNode(target)) { 6484 return; 6485 } 6486 6487 if (Type.isString(event) && Type.isFunction(listener)) { 6488 const events = this.registry.get(target); 6489 6490 if (Type.isPlainObject(events) && Type.isSet(events[event])) { 6491 events[event].delete(listener); 6492 } 6493 6494 return; 6495 } 6496 6497 if (Type.isString(event)) { 6498 const events = this.registry.get(target); 6499 6500 if (Type.isPlainObject(events) && Type.isSet(events[event])) { 6501 events[event] = new Set(); 6502 } 6503 6504 return; 6505 } 6506 6507 this.registry.delete(target); 6508 } 6509 }]); 6510 return Registry; 6511 }(); 6512 var registry = new Registry(); 6513 6514 function isOptionSupported(name) { 6515 let isSupported = false;
6516 6517 try { 6518 const options = Object.defineProperty({}, name, { 6519 get() { 6520 isSupported = true; 6521 return undefined; 6522 } 6523 6524 }); 6525 window.addEventListener('test', null, options); 6526 } // eslint-disable-next-line 6527 catch (err) {} 6528 6529 return isSupported; 6530 } 6531 6532 function fetchSupportedListenerOptions(options) { 6533 if (!Type.isPlainObject(options)) { 6534 return options; 6535 } 6536 6537 return Object.keys(options).reduce((acc, name) => { 6538 if (isOptionSupported(name)) { 6539 acc[name] = options[name]; 6540 } 6541 6542 return acc; 6543 }, {}); 6544 } 6545 6546 function bind(target, eventName, handler, options) { 6547 if (!Type.isObject(target) || !Type.isFunction(target.addEventListener)) { 6548 return; 6549 } 6550 6551 const listenerOptions = fetchSupportedListenerOptions(options); 6552 6553 if (eventName in aliases) { 6554 aliases[eventName].forEach(key => { 6555 target.addEventListener(key, handler, listenerOptions); 6556 registry.set(target, eventName, handler); 6557 }); 6558 return; 6559 } 6560 6561 target.addEventListener(eventName, handler, listenerOptions); 6562 registry.set(target, eventName, handler); 6563 } 6564 6565 function unbind(target, eventName, handler, options) { 6566 if (!Type.isObject(target) || !Type.isFunction(target.removeEventListener)) { 6567 return; 6568 } 6569 6570 const listenerOptions = fetchSupportedListenerOptions(options); 6571 6572 if (eventName in aliases) { 6573 aliases[eventName].forEach(key => { 6574 target.removeEventListener(key, handler, listenerOptions); 6575 registry.delete(target, key, handler); 6576 }); 6577 return; 6578 } 6579 6580 target.removeEventListener(eventName, handler, listenerOptions); 6581 registry.delete(target, eventName, handler); 6582 } 6583 6584 function unbindAll(target, eventName) { 6585 const events = registry.get(target); 6586 Object.keys(events).forEach(currentEvent => { 6587 events[currentEvent].forEach(handler => { 6588 if (!Type.isString(eventName) || eventName === currentEvent) { 6589 unbind(target, currentEvent, handler); 6590 } 6591 }); 6592 }); 6593 } 6594 6595 function bindOnce(target, eventName, handler, options) { 6596 const once = function once(...args) { 6597 unbind(target, eventName, once, options); 6598 handler(...args); 6599 }; 6600 6601 bind(target, eventName, once, options); 6602 } 6603 6604 let debugState = true; 6605 function enableDebug() { 6606 debugState = true; 6607 } 6608 function disableDebug() { 6609 debugState = false; 6610 } 6611 function isDebugEnabled() { 6612 return debugState; 6613 } 6614 function debug(...args) { 6615 if (isDebugEnabled() && Type.isObject(window.console)) { 6616 if (Type.isFunction(window.console.log)) { 6617 window.console.log('BX.debug: ', args.length > 0 ? args : args[0]); 6618 6619 if (args[0] instanceof Error && args[0].stack) { 6620 window.console.log('BX.debug error stack trace', args[0].stack); 6621 } 6622 } 6623 6624 if (Type.isFunction(window.console.trace)) { 6625 // eslint-disable-next-line 6626 console.trace(); 6627 } 6628 } 6629 } 6630 6631 var debugNs = /*#__PURE__*/Object.freeze({ 6632 get debugState () { return debugState; }, 6633 enableDebug: enableDebug, 6634 disableDebug: disableDebug, 6635 isDebugEnabled: isDebugEnabled, 6636 default: debug 6637 }); 6638 6639 function fetchExtensionSettings(html) { 6640 if (Type.isStringFilled(html)) { 6641 const scripts = html.match(/<script type="extension\/settings" \b[^>]*>([\s\S]*?)<\/script>/g); 6642 6643 if (Type.isArrayFilled(scripts)) { 6644 return scripts.map(script => { 6645 const [, extension] = script.match(/data-extension="(.[a-z0-9_.-]+)"/); 6646 return { 6647 extension, 6648 script 6649 }; 6650 }); 6651 } 6652 } 6653 6654 return []; 6655 } 6656 6657 let Extension = /*#__PURE__*/function () { 6658 function Extension(options) { 6659 babelHelpers.classCallCheck(this, Extension); 6660 this.config = options.config || {}; 6661 this.name = options.extension; 6662 this.state = 'scheduled'; // eslint-disable-next-line 6663 6664 const result = BX.processHTML(options.html || ''); 6665 this.inlineScripts = result.SCRIPT.reduce(inlineScripts, []); 6666 this.externalScripts = result.SCRIPT.reduce(externalScripts, []); 6667 this.externalStyles = result.STYLE.reduce(externalStyles, []); 6668 this.settingsScripts = fetchExtensionSettings(result.HTML); 6669 } 6670 6671 babelHelpers.createClass(Extension, [{ 6672 key: "load", 6673 value: function load() { 6674 if (this.state === 'error') { 6675 this.loadPromise = this.loadPromise || Promise.resolve(this); 6676 console.warn('Extension', this.name, 'not found'); 6677 } 6678 6679 if (!this.loadPromise && this.state) { 6680 this.state = 'load';
6681 this.settingsScripts.forEach(entry => { 6682 const isLoaded = !!document.querySelector(`script[data-extension="${entry.extension}"]`); 6683 6684 if (!isLoaded) { 6685 document.body.insertAdjacentHTML('beforeend', entry.script); 6686 } 6687 }); 6688 this.inlineScripts.forEach(BX.evalGlobal); 6689 this.loadPromise = Promise.all([loadAll(this.externalScripts), loadAll(this.externalStyles)]).then(() => { 6690 this.state = 'loaded'; 6691 6692 if (Type.isPlainObject(this.config) && this.config.namespace) { 6693 return Reflection.getClass(this.config.namespace); 6694 } 6695 6696 return window; 6697 }); 6698 } 6699 6700 return this.loadPromise; 6701 } 6702 }]); 6703 return Extension; 6704 }(); 6705 6706 const initialized = {}; 6707 const ajaxController = 'main.bitrix.main.controller.loadext.getextensions'; 6708 6709 function makeIterable(value) { 6710 return Type.isArray(value) ? value : [value]; 6711 } 6712 function isInitialized(extension) { 6713 return extension in initialized; 6714 } 6715 function getInitialized(extension) { 6716 return initialized[extension]; 6717 } 6718 function isAllInitialized(extensions) { 6719 return extensions.every(isInitialized); 6720 } 6721 function loadExtensions(extensions) { 6722 return Promise.all(extensions.map(item => item.load())); 6723 } 6724 function mergeExports(exports) { 6725 return exports.reduce((acc, currentExports) => { 6726 if (Type.isObject(currentExports)) { 6727 return { ...currentExports 6728 }; 6729 } 6730 6731 return currentExports; 6732 }, {}); 6733 } 6734 function inlineScripts(acc, item) { 6735 if (item.isInternal) { 6736 acc.push(item.JS); 6737 } 6738 6739 return acc; 6740 } 6741 function externalScripts(acc, item) { 6742 if (!item.isInternal) { 6743 acc.push(item.JS); 6744 } 6745 6746 return acc; 6747 } 6748 function externalStyles(acc, item) { 6749 if (Type.isString(item) && item !== '') { 6750 acc.push(item); 6751 } 6752 6753 return acc; 6754 } 6755 function request(options) { 6756 return new Promise(resolve => { 6757 // eslint-disable-next-line 6758 BX.ajax.runAction(ajaxController, { 6759 data: options 6760 }).then(resolve); 6761 }); 6762 } 6763 function prepareExtensions(response) { 6764 if (response.status !== 'success') { 6765 response.errors.map(console.warn); 6766 return []; 6767 } 6768 6769 return response.data.map(item => { 6770 const initializedExtension = getInitialized(item.extension); 6771 6772 if (initializedExtension) { 6773 return initializedExtension; 6774 } 6775 6776 initialized[item.extension] = new Extension(item); 6777 return initialized[item.extension]; 6778 }); 6779 } 6780 function loadAll(items) { 6781 const itemsList = makeIterable(items); 6782 6783 if (!itemsList.length) { 6784 return Promise.resolve(); 6785 } 6786 6787 return new Promise(resolve => { 6788 // eslint-disable-next-line 6789 BX.load(itemsList, resolve); 6790 }); 6791 } 6792 6793 /** 6794 * Loads extensions asynchronously 6795 * @param {string|Array<string>} extension 6796 * @return {Promise<Array<Extension>>} 6797 */ 6798 function loadExtension(extension) { 6799 const extensions = makeIterable(extension); 6800 const isAllInitialized$$1 = isAllInitialized(extensions); 6801 6802 if (isAllInitialized$$1) { 6803 const initializedExtensions = extensions.map(getInitialized); 6804 return loadExtensions(initializedExtensions).then(mergeExports); 6805 } 6806 6807 return request({ 6808 extension: extensions 6809 }).then(prepareExtensions).then(loadExtensions).then(mergeExports); 6810 } 6811 6812 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]']; 6813 6814 function isCloneable(value) { 6815 const isCloneableValue = Type.isObjectLike(value) && cloneableTags.includes(getTag(value)); 6816 return isCloneableValue || Type.isDomNode(value); 6817 } 6818 6819 function internalClone(value, map) { 6820 if (map.has(value)) { 6821 return map.get(value); 6822 } 6823 6824 if (isCloneable(value)) { 6825 if (Type.isArray(value)) { 6826 const cloned = Array.from(value); 6827 map.set(value, cloned); 6828 value.forEach((item, index) => { 6829 cloned[index] = internalClone(item, map); 6830 }); 6831 return map.get(value); 6832 } 6833 6834 if (Type.isDomNode(value)) { 6835 return value.cloneNode(true); 6836 } 6837 6838 if (Type.isMap(value)) { 6839 const result = new Map(); 6840 map.set(value, result); 6841 value.forEach((item, key) => { 6842 result.set(internalClone(key, map), internalClone(item, map)); 6843 }); 6844 return result; 6845 } 6846 6847 if (Type.isSet(value)) { 6848 const result = new Set(); 6849 map.set(value, result); 6850 value.forEach(item => { 6851 result.add(internalClone(item, map)); 6852 }); 6853 return result; 6854 } 6855 6856 if (Type.isDate(value)) { 6857 return new Date(value); 6858 } 6859 6860 if (Type.isRegExp(value)) { 6861 const regExpFlags = /\w*$/; 6862 const flags = regExpFlags.exec(value); 6863 let result = new RegExp(value.source); 6864 6865 if (flags && Type.isArray(flags)) { 6866 result = new RegExp(value.source, flags[0]); 6867 } 6868 6869 result.lastIndex = value.lastIndex; 6870 return result; 6871 } 6872 6873 const proto = Object.getPrototypeOf(value); 6874 const result = Object.assign(Object.create(proto), value); 6875 map.set(value, result); 6876 Object.keys(value).forEach(key => { 6877 result[key] = internalClone(value[key], map); 6878 }); 6879 return result; 6880 } 6881 6882 return value; 6883 }
6884 /** 6885 * Clones any cloneable object 6886 * @param value 6887 * @return {*} 6888 */ 6889 6890 function clone(value) { 6891 return internalClone(value, new WeakMap()); 6892 } 6893 6894 function merge(current, target) { 6895 return Object.entries(target).reduce((acc, [key, value]) => { 6896 if (!Type.isDomNode(acc[key]) && Type.isObjectLike(acc[key]) && Type.isObjectLike(value)) { 6897 acc[key] = merge(acc[key], value); 6898 return acc; 6899 } 6900 6901 acc[key] = value; 6902 return acc; 6903 }, current); 6904 } 6905 6906 function createComparator(fields, orders = []) { 6907 return (a, b) => { 6908 const field = fields[0]; 6909 const order = orders[0] || 'asc'; 6910 6911 if (Type.isUndefined(field)) { 6912 return 0; 6913 } 6914 6915 let valueA = a[field]; 6916 let valueB = b[field]; 6917 6918 if (Type.isString(valueA) && Type.isString(valueB)) { 6919 valueA = valueA.toLowerCase(); 6920 valueB = valueB.toLowerCase(); 6921 } 6922 6923 if (valueA < valueB) { 6924 return order === 'asc' ? -1 : 1; 6925 } 6926 6927 if (valueA > valueB) { 6928 return order === 'asc' ? 1 : -1; 6929 } 6930 6931 return createComparator(fields.slice(1), orders.slice(1))(a, b); 6932 }; 6933 } 6934 6935 /** 6936 * @memberOf BX 6937 */ 6938 6939 let Runtime = /*#__PURE__*/function () { 6940 function Runtime() { 6941 babelHelpers.classCallCheck(this, Runtime); 6942 } 6943 6944 babelHelpers.createClass(Runtime, null, [{ 6945 key: "debounce", 6946 value: function debounce(func, wait = 0, context = null) { 6947 let timeoutId; 6948 return function debounced(...args) { 6949 if (Type.isNumber(timeoutId)) { 6950 clearTimeout(timeoutId); 6951 } 6952 6953 timeoutId = setTimeout(() => { 6954 func.apply(context || this, args); 6955 }, wait); 6956 }; 6957 } 6958 }, { 6959 key: "throttle", 6960 value: function throttle(func, wait = 0, context = null) { 6961 let timer = 0; 6962 let invoke; 6963 return function wrapper(...args) { 6964 invoke = true; 6965 6966 if (!timer) { 6967 const q = function q() { 6968 if (invoke) { 6969 func.apply(context || this, args); 6970 invoke = false; 6971 timer = setTimeout(q, wait); 6972 } else { 6973 timer = null; 6974 } 6975 }; 6976 6977 q(); 6978 } 6979 }; 6980 } 6981 }, { 6982 key: "html", 6983 value: function html(node, _html, params = {}) { 6984 if (Type.isNil(_html) && Type.isDomNode(node)) { 6985 return node.innerHTML; 6986 } // eslint-disable-next-line 6987 6988 6989 const parsedHtml = BX.processHTML(_html); 6990 const externalCss = parsedHtml.STYLE.reduce(externalStyles, []); 6991 const externalJs = parsedHtml.SCRIPT.reduce(externalScripts, []); 6992 const inlineJs = parsedHtml.SCRIPT.reduce(inlineScripts, []); 6993 6994 if (Type.isDomNode(node)) { 6995 if (params.htmlFirst || !externalJs.length && !externalCss.length) { 6996 if (params.useAdjacentHTML) { 6997 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 6998 } else { 6999 node.innerHTML = parsedHtml.HTML; 7000 } 7001 } 7002 } 7003 7004 return Promise.all([loadAll(externalJs), loadAll(externalCss)]).then(() => { 7005 if (Type.isDomNode(node) && (externalJs.length > 0 || externalCss.length > 0)) { 7006 if (params.useAdjacentHTML) { 7007 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 7008 } else { 7009 node.innerHTML = parsedHtml.HTML; 7010 } 7011 } // eslint-disable-next-line 7012 7013 7014 inlineJs.forEach(script => BX.evalGlobal(script)); 7015 7016 if (Type.isFunction(params.callback)) { 7017 params.callback(); 7018 } 7019 }); 7020 } 7021 /** 7022 * Merges objects or arrays 7023 * @param targets 7024 * @return {any} 7025 */ 7026 7027 }, { 7028 key: "merge", 7029 value: function merge$$1(...targets) { 7030 if (Type.isArray(targets[0])) { 7031 targets.unshift([]); 7032 } else if (Type.isObject(targets[0])) { 7033 targets.unshift({}); 7034 } 7035 7036 return targets.reduce((acc, item) => { 7037 return merge(acc, item); 7038 }, targets[0]); 7039 } 7040 }, { 7041 key: "orderBy", 7042 value: function orderBy(collection, fields = [], orders = []) { 7043 const comparator = createComparator(fields, orders); 7044 return Object.values(collection).sort(comparator); 7045 } 7046 }, {
7047 key: "destroy", 7048 value: function destroy(target, errorMessage = 'Object is destroyed') { 7049 if (Type.isObject(target)) { 7050 const onPropertyAccess = () => { 7051 throw new Error(errorMessage); 7052 }; 7053 7054 const ownProperties = Object.keys(target); 7055 7056 const prototypeProperties = (() => { 7057 const targetPrototype = Object.getPrototypeOf(target); 7058 7059 if (Type.isObject(targetPrototype)) { 7060 return Object.getOwnPropertyNames(targetPrototype); 7061 } 7062 7063 return []; 7064 })(); 7065 7066 const uniquePropertiesList = [...new Set([...ownProperties, ...prototypeProperties])]; 7067 uniquePropertiesList.filter(name => { 7068 const descriptor = Object.getOwnPropertyDescriptor(target, name); 7069 return !/__(.+)__/.test(name) && (!Type.isObject(descriptor) || descriptor.configurable === true); 7070 }).forEach(name => { 7071 Object.defineProperty(target, name, { 7072 get: onPropertyAccess, 7073 set: onPropertyAccess, 7074 configurable: false 7075 }); 7076 }); 7077 Object.setPrototypeOf(target, null); 7078 } 7079 } 7080 }]); 7081 return Runtime; 7082 }(); 7083 7084 babelHelpers.defineProperty(Runtime, "debug", debug); 7085 babelHelpers.defineProperty(Runtime, "loadExtension", loadExtension); 7086 babelHelpers.defineProperty(Runtime, "clone", clone); 7087 7088 const _isError = Symbol.for('BX.BaseError.isError'); 7089 /** 7090 * @memberOf BX 7091 */ 7092 7093 7094 let BaseError = /*#__PURE__*/function () { 7095 function BaseError(message, code, customData) { 7096 babelHelpers.classCallCheck(this, BaseError); 7097 this[_isError] = true; 7098 this.message = ''; 7099 this.code = null; 7100 this.customData = null; 7101 this.setMessage(message); 7102 this.setCode(code); 7103 this.setCustomData(customData); 7104 } 7105 /** 7106 * Returns a brief description of the error 7107 * @returns {string} 7108 */ 7109 7110 7111 babelHelpers.createClass(BaseError, [{ 7112 key: "getMessage", 7113 value: function getMessage() { 7114 return this.message; 7115 } 7116 /** 7117 * Sets a message of the error 7118 * @param {string} message 7119 * @returns {this} 7120 */ 7121 7122 }, { 7123 key: "setMessage", 7124 value: function setMessage(message) { 7125 if (Type.isString(message)) { 7126 this.message = message; 7127 } 7128 7129 return this; 7130 } 7131 /** 7132 * Returns a code of the error 7133 * @returns {?string} 7134 */ 7135 7136 }, { 7137 key: "getCode", 7138 value: function getCode() { 7139 return this.code; 7140 } 7141 /** 7142 * Sets a code of the error 7143 * @param {string} code 7144 * @returns {this} 7145 */ 7146 7147 }, { 7148 key: "setCode", 7149 value: function setCode(code) { 7150 if (Type.isStringFilled(code) || code === null) { 7151 this.code = code; 7152 } 7153 7154 return this; 7155 } 7156 /** 7157 * Returns custom data of the error 7158 * @returns {null|*} 7159 */ 7160 7161 }, { 7162 key: "getCustomData", 7163 value: function getCustomData() { 7164 return this.customData; 7165 } 7166 /** 7167 * Sets custom data of the error 7168 * @returns {this} 7169 */ 7170 7171 }, { 7172 key: "setCustomData", 7173 value: function setCustomData(customData) { 7174 if (!Type.isUndefined(customData)) { 7175 this.customData = customData; 7176 } 7177 7178 return this; 7179 } 7180 }, { 7181 key: "toString", 7182 value: function toString() { 7183 const code = this.getCode(); 7184 const message = this.getMessage(); 7185 7186 if (!Type.isStringFilled(code) && !Type.isStringFilled(message)) { 7187 return ''; 7188 } else if (!Type.isStringFilled(code)) { 7189 return `Error: ${message}`; 7190 } else if (!Type.isStringFilled(message)) { 7191 return code; 7192 } else { 7193 return `${code}: ${message}`; 7194 } 7195 } 7196 /** 7197 * Returns true if the object is an instance of BaseError 7198 * @param error 7199 * @returns {boolean} 7200 */ 7201 7202 }], [{ 7203 key: "isError", 7204 value: function isError(error) { 7205 return Type.isObject(error) && error[_isError] === true; 7206 } 7207 }]); 7208 return BaseError; 7209 }(); 7210 7211 /** 7212 * Implements base event object interface 7213 */ 7214 7215 let BaseEvent = /*#__PURE__*/function () { 7216 function BaseEvent(options = { 7217 data: {} 7218 }) { 7219 babelHelpers.classCallCheck(this, BaseEvent); 7220 this.type = ''; 7221 this.data = null; 7222 this.target = null; 7223 this.compatData = null; 7224 this.defaultPrevented = false;
7225 this.immediatePropagationStopped = false; 7226 this.errors = []; 7227 this.setData(options.data); 7228 this.setCompatData(options.compatData); 7229 } 7230 7231 babelHelpers.createClass(BaseEvent, [{ 7232 key: "getType", 7233 7234 /** 7235 * Returns the name of the event 7236 * @returns {string} 7237 */ 7238 value: function getType() { 7239 return this.type; 7240 } 7241 /** 7242 * 7243 * @param {string} type 7244 */ 7245 7246 }, { 7247 key: "setType", 7248 value: function setType(type) { 7249 if (Type.isStringFilled(type)) { 7250 this.type = type; 7251 } 7252 7253 return this; 7254 } 7255 /** 7256 * Returns an event data 7257 */ 7258 7259 }, { 7260 key: "getData", 7261 value: function getData() { 7262 return this.data; 7263 } 7264 /** 7265 * Sets an event data 7266 * @param data 7267 */ 7268 7269 }, { 7270 key: "setData", 7271 value: function setData(data) { 7272 if (!Type.isUndefined(data)) { 7273 this.data = data; 7274 } 7275 7276 return this; 7277 } 7278 /** 7279 * Returns arguments for BX.addCustomEvent handlers (deprecated). 7280 * @returns {array | null} 7281 */ 7282 7283 }, { 7284 key: "getCompatData", 7285 value: function getCompatData() { 7286 return this.compatData; 7287 } 7288 /** 7289 * Sets arguments for BX.addCustomEvent handlers (deprecated) 7290 * @param data 7291 */ 7292 7293 }, { 7294 key: "setCompatData", 7295 value: function setCompatData(data) { 7296 if (Type.isArrayLike(data)) { 7297 this.compatData = data; 7298 } 7299 7300 return this; 7301 } 7302 /** 7303 * Sets a event target 7304 * @param target 7305 */ 7306 7307 }, { 7308 key: "setTarget", 7309 value: function setTarget(target) { 7310 this.target = target; 7311 return this; 7312 } 7313 /** 7314 * Returns a event target 7315 */ 7316 7317 }, { 7318 key: "getTarget", 7319 value: function getTarget() { 7320 return this.target; 7321 } 7322 /** 7323 * Returns an array of event errors 7324 * @returns {[]} 7325 */ 7326 7327 }, { 7328 key: "getErrors", 7329 value: function getErrors() { 7330 return this.errors; 7331 } 7332 /** 7333 * Adds an error of the event. 7334 * Event listeners can prevent emitter's default action and set the reason of this behavior. 7335 * @param error 7336 */ 7337 7338 }, { 7339 key: "setError", 7340 value: function setError(error) { 7341 if (BaseError.isError(error)) { 7342 this.errors.push(error); 7343 } 7344 } 7345 /** 7346 * Prevents default action 7347 */ 7348 7349 }, { 7350 key: "preventDefault", 7351 value: function preventDefault() { 7352 this.defaultPrevented = true; 7353 } 7354 /** 7355 * Checks that is default action prevented 7356 * @return {boolean} 7357 */ 7358 7359 }, { 7360 key: "isDefaultPrevented", 7361 value: function isDefaultPrevented() { 7362 return this.defaultPrevented; 7363 } 7364 /** 7365 * Stops event immediate propagation 7366 */ 7367 7368 }, { 7369 key: "stopImmediatePropagation", 7370 value: function stopImmediatePropagation() { 7371 this.immediatePropagationStopped = true; 7372 } 7373 /** 7374 * Checks that is immediate propagation stopped 7375 * @return {boolean} 7376 */ 7377 7378 }, { 7379 key: "isImmediatePropagationStopped", 7380 value: function isImmediatePropagationStopped() { 7381 return this.immediatePropagationStopped; 7382 } 7383 }], [{ 7384 key: "create", 7385 value: function create(options) { 7386 return new this(options); 7387 } 7388 }]); 7389 return BaseEvent; 7390 }(); 7391 7392 let EventStore = /*#__PURE__*/function () { 7393 function EventStore(options = {}) { 7394 babelHelpers.classCallCheck(this, EventStore); 7395 this.defaultMaxListeners = Type.isNumber(options.defaultMaxListeners) ? options.defaultMaxListeners : 10; 7396 this.eventStore = new WeakMap(); 7397 } 7398 7399 babelHelpers.createClass(EventStore, [{ 7400 key: "add", 7401 value: function add(target, options = {}) { 7402 const record = this.getRecordScheme(); 7403 7404 if (Type.isNumber(options.maxListeners)) { 7405 record.maxListeners = options.maxListeners; 7406 } 7407 7408 this.eventStore.set(target, record); 7409 return record; 7410 } 7411 }, { 7412 key: "get", 7413 value: function get(target) { 7414 return this.eventStore.get(target); 7415 } 7416 }, { 7417 key: "getOrAdd", 7418 value: function getOrAdd(target, options = {}) { 7419 return this.get(target) || this.add(target, options); 7420 } 7421 }, { 7422 key: "delete", 7423 value: function _delete(context) { 7424 this.eventStore.delete(context); 7425 } 7426 }, { 7427 key: "getRecordScheme", 7428 value: function getRecordScheme() { 7429 return { 7430 eventsMap: new Map(), 7431 onceMap: new Map(), 7432 maxListeners: this.getDefaultMaxListeners(), 7433 eventsMaxListeners: new Map() 7434 }; 7435 } 7436 }, { 7437 key: "getDefaultMaxListeners", 7438 value: function getDefaultMaxListeners() { 7439 return this.defaultMaxListeners; 7440 } 7441 }]); 7442 return EventStore; 7443 }(); 7444 7445 let WarningStore = /*#__PURE__*/function () {
7446 function WarningStore() { 7447 babelHelpers.classCallCheck(this, WarningStore); 7448 this.warnings = new Map(); 7449 this.printDelayed = Runtime.debounce(this.print.bind(this), 500); 7450 } 7451 7452 babelHelpers.createClass(WarningStore, [{ 7453 key: "add", 7454 value: function add(target, eventName, listeners) { 7455 let contextWarnings = this.warnings.get(target); 7456 7457 if (!contextWarnings) { 7458 contextWarnings = Object.create(null); 7459 this.warnings.set(target, contextWarnings); 7460 } 7461 7462 if (!contextWarnings[eventName]) { 7463 contextWarnings[eventName] = {}; 7464 } 7465 7466 contextWarnings[eventName].size = listeners.size; 7467 7468 if (!Type.isArray(contextWarnings[eventName].errors)) { 7469 contextWarnings[eventName].errors = []; 7470 } 7471 7472 contextWarnings[eventName].errors.push(new Error()); 7473 } 7474 }, { 7475 key: "print", 7476 value: function print() { 7477 this.warnings.forEach(warnings => { 7478 for (let eventName in warnings) { 7479 console.groupCollapsed('Possible BX.Event.EventEmitter memory leak detected. ' + warnings[eventName].size + ' "' + eventName + '" listeners added. ' + 'Use emitter.setMaxListeners() to increase limit.'); 7480 console.dir(warnings[eventName].errors); 7481 console.groupEnd(); 7482 } 7483 }); 7484 this.clear(); 7485 } 7486 }, { 7487 key: "clear", 7488 value: function clear() { 7489 this.warnings.clear(); 7490 } 7491 }, { 7492 key: "printDelayed", 7493 value: function printDelayed() {} 7494 }]); 7495 return WarningStore; 7496 }(); 7497 7498 const eventStore = new EventStore({ 7499 defaultMaxListeners: 10 7500 }); 7501 const warningStore = new WarningStore(); 7502 const aliasStore = new Map(); 7503 const globalTarget = { 7504 GLOBAL_TARGET: 'GLOBAL_TARGET' // this key only for debugging purposes 7505 7506 }; 7507 eventStore.add(globalTarget, { 7508 maxListeners: 25 7509 }); 7510 const isEmitterProperty = Symbol.for('BX.Event.EventEmitter.isEmitter'); 7511 const namespaceProperty = Symbol('namespaceProperty'); 7512 const targetProperty = Symbol('targetProperty'); 7513 7514 let EventEmitter = /*#__PURE__*/function () { 7515 /** @private */ 7516 function EventEmitter(...args) { 7517 babelHelpers.classCallCheck(this, EventEmitter); 7518 this[targetProperty] = null; 7519 this[namespaceProperty] = null; 7520 this[isEmitterProperty] = true; 7521 let target = this; 7522 7523 if (Object.getPrototypeOf(this) === EventEmitter.prototype && args.length > 0) //new EventEmitter(obj) case 7524 { 7525 if (!Type.isObject(args[0])) { 7526 throw new TypeError(`The "target" argument must be an object.`); 7527 } 7528 7529 target = args[0]; 7530 this.setEventNamespace(args[1]); 7531 } 7532 7533 this[targetProperty] = target; 7534 } 7535 /** 7536 * Makes a target observable 7537 * @param {object} target 7538 * @param {string} namespace 7539 */ 7540 7541 7542 babelHelpers.createClass(EventEmitter, [{ 7543 key: "setEventNamespace", 7544 value: function setEventNamespace(namespace) { 7545 if (Type.isStringFilled(namespace)) { 7546 this[namespaceProperty] = namespace; 7547 } 7548 } 7549 }, { 7550 key: "getEventNamespace", 7551 value: function getEventNamespace() { 7552 return this[namespaceProperty]; 7553 } 7554 /** 7555 * Subscribes listener on specified global event 7556 * @param {object} target 7557 * @param {string} eventName 7558 * @param {Function<BaseEvent>} listener 7559 * @param {object} options 7560 */ 7561 7562 }, { 7563 key: "subscribe", 7564 7565 /** 7566 * Subscribes a listener on a specified event 7567 * @param {string} eventName 7568 * @param {Function<BaseEvent>} listener 7569 * @return {this} 7570 */ 7571 value: function subscribe(eventName, listener) { 7572 EventEmitter.subscribe(this, eventName, listener); 7573 return this; 7574 } 7575 /** 7576 * 7577 * @param {object} options 7578 * @param {object} [aliases] 7579 * @param {boolean} [compatMode=false] 7580 */ 7581 7582 }, { 7583 key: "subscribeFromOptions", 7584 value: function subscribeFromOptions(options, aliases, compatMode) { 7585 if (!Type.isPlainObject(options)) { 7586 return; 7587 } 7588 7589 aliases = Type.isPlainObject(aliases) ? EventEmitter.normalizeAliases(aliases) : {};
7590 Object.keys(options).forEach(eventName => { 7591 const listener = EventEmitter.normalizeListener(options[eventName]); 7592 eventName = EventEmitter.normalizeEventName(eventName); 7593 7594 if (aliases[eventName]) { 7595 const { 7596 eventName: actualName 7597 } = aliases[eventName]; 7598 EventEmitter.subscribe(this, actualName, listener, { 7599 compatMode: compatMode !== false 7600 }); 7601 } else { 7602 EventEmitter.subscribe(this, eventName, listener, { 7603 compatMode: compatMode === true 7604 }); 7605 } 7606 }); 7607 } 7608 /** 7609 * Subscribes a listener that is called at 7610 * most once for a specified event. 7611 * @param {object} target 7612 * @param {string} eventName 7613 * @param {Function<BaseEvent>} listener 7614 */ 7615 7616 }, { 7617 key: "subscribeOnce", 7618 7619 /** 7620 * Subscribes a listener that is called at most once for a specified event. 7621 * @param {string} eventName 7622 * @param {Function<BaseEvent>} listener 7623 * @return {this} 7624 */ 7625 value: function subscribeOnce(eventName, listener) { 7626 EventEmitter.subscribeOnce(this, eventName, listener); 7627 return this; 7628 } 7629 /** 7630 * Unsubscribes an event listener 7631 * @param {object} target 7632 * @param {string} eventName 7633 * @param {Function<BaseEvent>} listener 7634 * @param options 7635 */ 7636 7637 }, { 7638 key: "unsubscribe", 7639 7640 /** 7641 * Unsubscribes an event listener 7642 * @param {string} eventName 7643 * @param {Function<BaseEvent>} listener 7644 * @return {this} 7645 */ 7646 value: function unsubscribe(eventName, listener) { 7647 EventEmitter.unsubscribe(this, eventName, listener); 7648 return this; 7649 } 7650 /** 7651 * Unsubscribes all event listeners 7652 * @param {object} target 7653 * @param {string} eventName 7654 * @param options 7655 */ 7656 7657 }, { 7658 key: "unsubscribeAll", 7659 7660 /** 7661 * Unsubscribes all event listeners 7662 * @param {string} [eventName] 7663 */ 7664 value: function unsubscribeAll(eventName) { 7665 EventEmitter.unsubscribeAll(this, eventName); 7666 } 7667 /** 7668 * 7669 * @param {object} target 7670 * @param {string} eventName 7671 * @param {BaseEvent | any} event 7672 * @param {object} options 7673 * @returns {Array} 7674 */ 7675 7676 }, { 7677 key: "emit", 7678 7679 /** 7680 * Emits specified event with specified event object 7681 * @param {string} eventName 7682 * @param {BaseEvent | any} event 7683 * @return {this} 7684 */ 7685 value: function emit(eventName, event) { 7686 if (this.getEventNamespace() === null) { 7687 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7688 } 7689 7690 EventEmitter.emit(this, eventName, event); 7691 return this; 7692 } 7693 /** 7694 * Emits global event and returns a promise that is resolved when 7695 * all promise returned from event handlers are resolved, 7696 * or rejected when at least one of the returned promise is rejected. 7697 * Importantly. You can return any value from synchronous handlers, not just promise 7698 * @param {object} target 7699 * @param {string} eventName 7700 * @param {BaseEvent | any} event 7701 * @return {Promise<Array>} 7702 */ 7703 7704 }, { 7705 key: "emitAsync", 7706 7707 /** 7708 * Emits event and returns a promise that is resolved when 7709 * all promise returned from event handlers are resolved, 7710 * or rejected when at least one of the returned promise is rejected. 7711 * Importantly. You can return any value from synchronous handlers, not just promise 7712 * @param {string} eventName 7713 * @param {BaseEvent|any} event 7714 * @return {Promise<Array>} 7715 */ 7716 value: function emitAsync(eventName, event) { 7717 if (this.getEventNamespace() === null) { 7718 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7719 } 7720 7721 return EventEmitter.emitAsync(this, eventName, event); 7722 } 7723 /** 7724 * @private 7725 * @param {object} target 7726 * @param {string} eventName 7727 * @param {BaseEvent|any} event 7728 * @returns {BaseEvent} 7729 */ 7730 7731 }, { 7732 key: "setMaxListeners", 7733 7734 /** 7735 * Sets max events listeners count 7736 * this.setMaxListeners(10) - sets the default value for all events
7737 * this.setMaxListeners("onClose", 10) sets the value for onClose event 7738 * @return {this} 7739 * @param args 7740 */ 7741 value: function setMaxListeners(...args) { 7742 EventEmitter.setMaxListeners(this, ...args); 7743 return this; 7744 } 7745 /** 7746 * Returns max event listeners count 7747 * @param {object} target 7748 * @param {string} [eventName] 7749 * @returns {number} 7750 */ 7751 7752 }, { 7753 key: "getMaxListeners", 7754 7755 /** 7756 * Returns max event listeners count 7757 * @param {string} [eventName] 7758 * @returns {number} 7759 */ 7760 value: function getMaxListeners(eventName) { 7761 return EventEmitter.getMaxListeners(this, eventName); 7762 } 7763 /** 7764 * Adds or subtracts max listeners count 7765 * Event.EventEmitter.addMaxListeners() - adds one max listener for all events of global target 7766 * Event.EventEmitter.addMaxListeners(3) - adds three max listeners for all events of global target 7767 * Event.EventEmitter.addMaxListeners(-1) - subtracts one max listener for all events of global target 7768 * Event.EventEmitter.addMaxListeners('onClose') - adds one max listener for onClose event of global target 7769 * Event.EventEmitter.addMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 7770 * Event.EventEmitter.addMaxListeners('onClose', -1) - subtracts one max listener for onClose event of global target 7771 * 7772 * Event.EventEmitter.addMaxListeners(obj) - adds one max listener for all events of 'obj' target 7773 * Event.EventEmitter.addMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 7774 * Event.EventEmitter.addMaxListeners(obj, -1) - subtracts one max listener for all events of 'obj' target 7775 * Event.EventEmitter.addMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 7776 * Event.EventEmitter.addMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 7777 * Event.EventEmitter.addMaxListeners(obj, 'onClose', -1) - subtracts one max listener for onClose event of 'obj' target 7778 * @param args 7779 * @returns {number} 7780 */ 7781 7782 }, { 7783 key: "incrementMaxListeners", 7784 7785 /** 7786 * Increases max listeners count 7787 * this.incrementMaxListeners() - adds one max listener for all events 7788 * this.incrementMaxListeners(3) - adds three max listeners for all events 7789 * this.incrementMaxListeners('onClose') - adds one max listener for onClose event 7790 * this.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event 7791 */ 7792 value: function incrementMaxListeners(...args) { 7793 return EventEmitter.incrementMaxListeners(this, ...args); 7794 } 7795 /** 7796 * Decreases max listeners count 7797 * 7798 * Event.EventEmitter.decrementMaxListeners() - subtracts one max listener for all events of global target 7799 * Event.EventEmitter.decrementMaxListeners(3) - subtracts three max listeners for all events of global target 7800 * Event.EventEmitter.decrementMaxListeners('onClose') - subtracts one max listener for onClose event of global target 7801 * Event.EventEmitter.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event of global target 7802 * 7803 * Event.EventEmitter.decrementMaxListeners(obj) - subtracts one max listener for all events of 'obj' target 7804 * Event.EventEmitter.decrementMaxListeners(obj, 3) - subtracts three max listeners for all events of 'obj' target 7805 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose') - subtracts one max listener for onClose event of 'obj' target 7806 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose', 2) - subtracts two max listeners for onClose event of 'obj' target 7807 */ 7808 7809 }, { 7810 key: "decrementMaxListeners", 7811 7812 /** 7813 * Increases max listeners count 7814 * this.decrementMaxListeners() - subtracts one max listener for all events 7815 * this.decrementMaxListeners(3) - subtracts three max listeners for all events 7816 * this.decrementMaxListeners('onClose') - subtracts one max listener for onClose event 7817 * this.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event 7818 */ 7819 value: function decrementMaxListeners(...args) { 7820 return EventEmitter.decrementMaxListeners(this, ...args); 7821 } 7822 /** 7823 * @private 7824 * @param {Array} args 7825 * @returns Array 7826 */ 7827 7828 }, { 7829 key: "getListeners", 7830 7831 /** 7832 * Gets listeners list for specified event 7833 * @param {string} eventName 7834 */ 7835 value: function getListeners(eventName) { 7836 return EventEmitter.getListeners(this, eventName); 7837 } 7838 /** 7839 * Returns a full event name with namespace 7840 * @param {string} eventName 7841 * @returns {string} 7842 */ 7843 7844 }, { 7845 key: "getFullEventName", 7846 value: function getFullEventName(eventName) { 7847 if (!Type.isStringFilled(eventName)) { 7848 throw new TypeError(`The "eventName" argument must be a string.`); 7849 } 7850 7851 return EventEmitter.makeFullEventName(this.getEventNamespace(), eventName); 7852 } 7853 /** 7854 * Registers aliases (old event names for BX.onCustomEvent) 7855 * @param aliases 7856 */ 7857 7858 }], [{ 7859 key: "makeObservable", 7860 value: function makeObservable(target, namespace) { 7861 if (!Type.isObject(target)) { 7862 throw new TypeError('The "target" argument must be an object.'); 7863 } 7864 7865 if (!Type.isStringFilled(namespace)) { 7866 throw new TypeError('The "namespace" must be an non-empty string.'); 7867 } 7868 7869 if (EventEmitter.isEventEmitter(target)) { 7870 throw new TypeError('The "target" is an event emitter already.'); 7871 } 7872 7873 const targetProto = Object.getPrototypeOf(target); 7874 const emitter = new EventEmitter(); 7875 emitter.setEventNamespace(namespace); 7876 Object.setPrototypeOf(emitter, targetProto); 7877 Object.setPrototypeOf(target, emitter); 7878 Object.getOwnPropertyNames(EventEmitter.prototype).forEach(method => {
7879 if (['constructor'].includes(method)) { 7880 return; 7881 } 7882 7883 emitter[method] = function (...args) { 7884 return EventEmitter.prototype[method].apply(target, args); 7885 }; 7886 }); 7887 } 7888 }, { 7889 key: "subscribe", 7890 value: function subscribe(target, eventName, listener, options) { 7891 if (Type.isString(target)) { 7892 options = listener; 7893 listener = eventName; 7894 eventName = target; 7895 target = this.GLOBAL_TARGET; 7896 } 7897 7898 if (!Type.isObject(target)) { 7899 throw new TypeError(`The "target" argument must be an object.`); 7900 } 7901 7902 eventName = this.normalizeEventName(eventName); 7903 7904 if (!Type.isStringFilled(eventName)) { 7905 throw new TypeError(`The "eventName" argument must be a string.`); 7906 } 7907 7908 listener = this.normalizeListener(listener); 7909 options = Type.isPlainObject(options) ? options : {}; 7910 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7911 const { 7912 eventsMap, 7913 onceMap 7914 } = eventStore.getOrAdd(target); 7915 const onceListeners = onceMap.get(fullEventName); 7916 let listeners = eventsMap.get(fullEventName); 7917 7918 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7919 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7920 } else { 7921 if (listeners) { 7922 listeners.set(listener, { 7923 listener, 7924 options, 7925 sort: this.getNextSequenceValue() 7926 }); 7927 } else { 7928 listeners = new Map([[listener, { 7929 listener, 7930 options, 7931 sort: this.getNextSequenceValue() 7932 }]]); 7933 eventsMap.set(fullEventName, listeners); 7934 } 7935 } 7936 7937 const maxListeners = this.getMaxListeners(target, eventName); 7938 7939 if (listeners.size > maxListeners) { 7940 warningStore.add(target, fullEventName, listeners); 7941 warningStore.printDelayed(); 7942 } 7943 } 7944 }, { 7945 key: "subscribeOnce", 7946 value: function subscribeOnce(target, eventName, listener) { 7947 if (Type.isString(target)) { 7948 listener = eventName; 7949 eventName = target; 7950 target = this.GLOBAL_TARGET;
7951 } 7952 7953 if (!Type.isObject(target)) { 7954 throw new TypeError(`The "target" argument must be an object.`); 7955 } 7956 7957 eventName = this.normalizeEventName(eventName); 7958 7959 if (!Type.isStringFilled(eventName)) { 7960 throw new TypeError(`The "eventName" argument must be a string.`); 7961 } 7962 7963 listener = this.normalizeListener(listener); 7964 const fullEventName = this.resolveEventName(eventName, target); 7965 const { 7966 eventsMap, 7967 onceMap 7968 } = eventStore.getOrAdd(target); 7969 const listeners = eventsMap.get(fullEventName); 7970 let onceListeners = onceMap.get(fullEventName); 7971 7972 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7973 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7974 } else { 7975 const once = (...args) => { 7976 this.unsubscribe(target, eventName, once); 7977 onceListeners.delete(listener); 7978 listener(...args); 7979 }; 7980 7981 if (onceListeners) { 7982 onceListeners.set(listener, once); 7983 } else { 7984 onceListeners = new Map([[listener, once]]); 7985 onceMap.set(fullEventName, onceListeners); 7986 } 7987 7988 this.subscribe(target, eventName, once); 7989 } 7990 } 7991 }, { 7992 key: "unsubscribe", 7993 value: function unsubscribe(target, eventName, listener, options) { 7994 if (Type.isString(target)) { 7995 listener = eventName; 7996 eventName = target; 7997 target = this.GLOBAL_TARGET;
7998 } 7999 8000 eventName = this.normalizeEventName(eventName); 8001 8002 if (!Type.isStringFilled(eventName)) { 8003 throw new TypeError(`The "eventName" argument must be a string.`); 8004 } 8005 8006 listener = this.normalizeListener(listener); 8007 options = Type.isPlainObject(options) ? options : {}; 8008 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 8009 const targetInfo = eventStore.get(target); 8010 const listeners = targetInfo && targetInfo.eventsMap.get(fullEventName); 8011 const onceListeners = targetInfo && targetInfo.onceMap.get(fullEventName); 8012 8013 if (listeners) { 8014 listeners.delete(listener); 8015 } 8016 8017 if (onceListeners) { 8018 const once = onceListeners.get(listener); 8019 8020 if (once) { 8021 onceListeners.delete(listener); 8022 listeners.delete(once); 8023 } 8024 } 8025 } 8026 }, { 8027 key: "unsubscribeAll", 8028 value: function unsubscribeAll(target, eventName, options) { 8029 if (Type.isString(target)) { 8030 eventName = target; 8031 target = this.GLOBAL_TARGET;
8032 } 8033 8034 if (Type.isStringFilled(eventName)) { 8035 const targetInfo = eventStore.get(target); 8036 8037 if (targetInfo) { 8038 options = Type.isPlainObject(options) ? options : {}; 8039 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 8040 targetInfo.eventsMap.delete(fullEventName); 8041 targetInfo.onceMap.delete(fullEventName); 8042 } 8043 } else if (Type.isNil(eventName)) { 8044 if (target === this.GLOBAL_TARGET) { 8045 console.error('You cannot unsubscribe all global listeners.'); 8046 } else { 8047 eventStore.delete(target); 8048 } 8049 } 8050 } 8051 }, { 8052 key: "emit", 8053 value: function emit(target, eventName, event, options) { 8054 if (Type.isString(target)) { 8055 options = event; 8056 event = eventName; 8057 eventName = target; 8058 target = this.GLOBAL_TARGET; 8059 } 8060 8061 if (!Type.isObject(target)) { 8062 throw new TypeError(`The "target" argument must be an object.`); 8063 } 8064 8065 eventName = this.normalizeEventName(eventName); 8066 8067 if (!Type.isStringFilled(eventName)) { 8068 throw new TypeError(`The "eventName" argument must be a string.`); 8069 } 8070 8071 options = Type.isPlainObject(options) ? options : {}; 8072 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 8073 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 8074 const globalListeners = globalEvents && globalEvents.eventsMap.get(fullEventName) || new Map(); 8075 let targetListeners = new Set(); 8076 8077 if (target !== this.GLOBAL_TARGET) { 8078 const targetEvents = eventStore.get(target); 8079 targetListeners = targetEvents && targetEvents.eventsMap.get(fullEventName) || new Map(); 8080 } 8081 8082 const listeners = [...globalListeners.values(), ...targetListeners.values()]; 8083 listeners.sort(function (a, b) { 8084 return a.sort - b.sort; 8085 }); 8086 const preparedEvent = this.prepareEvent(target, fullEventName, event); 8087 const result = []; 8088 8089 for (let i = 0; i < listeners.length; i++) { 8090 if (preparedEvent.isImmediatePropagationStopped()) { 8091 break; 8092 } 8093 8094 const { 8095 listener, 8096 options: listenerOptions 8097 } = listeners[i]; //A previous listener could remove a current listener. 8098 8099 if (globalListeners.has(listener) || targetListeners.has(listener)) { 8100 let listenerResult; 8101 8102 if (listenerOptions.compatMode) { 8103 let params = []; 8104 const compatData = preparedEvent.getCompatData(); 8105 8106 if (compatData !== null) { 8107 params = options.cloneData === true ? Runtime.clone(compatData) : compatData; 8108 } else { 8109 params = [preparedEvent]; 8110 } 8111 8112 const context = Type.isUndefined(options.thisArg) ? target : options.thisArg; 8113 listenerResult = listener.apply(context, params); 8114 } else { 8115 listenerResult = Type.isUndefined(options.thisArg) ? listener(preparedEvent) : listener.call(options.thisArg, preparedEvent); 8116 } 8117 8118 result.push(listenerResult); 8119 } 8120 } 8121 8122 return result; 8123 } 8124 }, { 8125 key: "emitAsync", 8126 value: function emitAsync(target, eventName, event) { 8127 if (Type.isString(target)) { 8128 event = eventName; 8129 eventName = target; 8130 target = this.GLOBAL_TARGET;
8131 } 8132 8133 return Promise.all(this.emit(target, eventName, event)); 8134 } 8135 }, { 8136 key: "prepareEvent", 8137 value: function prepareEvent(target, eventName, event) { 8138 let preparedEvent = event; 8139 8140 if (!(event instanceof BaseEvent)) { 8141 preparedEvent = new BaseEvent(); 8142 preparedEvent.setData(event); 8143 } 8144 8145 preparedEvent.setTarget(this.isEventEmitter(target) ? target[targetProperty] : target); 8146 preparedEvent.setType(eventName); 8147 return preparedEvent; 8148 } 8149 /** 8150 * @private 8151 * @returns {number} 8152 */ 8153 8154 }, { 8155 key: "getNextSequenceValue", 8156 value: function getNextSequenceValue() { 8157 return this.sequenceValue++; 8158 } 8159 /** 8160 * Sets max global events listeners count 8161 * Event.EventEmitter.setMaxListeners(10) - sets the default value for all events (global target) 8162 * Event.EventEmitter.setMaxListeners("onClose", 10) - sets the value for onClose event (global target) 8163 * Event.EventEmitter.setMaxListeners(obj, 10) - sets the default value for all events (obj target) 8164 * Event.EventEmitter.setMaxListeners(obj, "onClose", 10); - sets the value for onClose event (obj target) 8165 * @return {void} 8166 * @param args 8167 */ 8168 8169 }, { 8170 key: "setMaxListeners", 8171 value: function setMaxListeners(...args) { 8172 let target = this.GLOBAL_TARGET;
8173 let eventName = null; 8174 let count = undefined; 8175 8176 if (args.length === 1) { 8177 count = args[0]; 8178 } else if (args.length === 2) { 8179 if (Type.isString(args[0])) { 8180 [eventName, count] = args; 8181 } else { 8182 [target, count] = args; 8183 } 8184 } else if (args.length >= 3) { 8185 [target, eventName, count] = args; 8186 } 8187 8188 if (!Type.isObject(target)) { 8189 throw new TypeError(`The "target" argument must be an object.`); 8190 } 8191 8192 if (eventName !== null && !Type.isStringFilled(eventName)) { 8193 throw new TypeError(`The "eventName" argument must be a string.`); 8194 } 8195 8196 if (!Type.isNumber(count) || count < 0) { 8197 throw new TypeError(`The value of "count" is out of range. It must be a non-negative number. Received ${count}.`); 8198 } 8199 8200 const targetInfo = eventStore.getOrAdd(target); 8201 8202 if (Type.isStringFilled(eventName)) { 8203 const fullEventName = this.resolveEventName(eventName, target); 8204 targetInfo.eventsMaxListeners.set(fullEventName, count); 8205 } else { 8206 targetInfo.maxListeners = count; 8207 } 8208 } 8209 }, { 8210 key: "getMaxListeners", 8211 value: function getMaxListeners(target, eventName) { 8212 if (Type.isString(target)) { 8213 eventName = target; 8214 target = this.GLOBAL_TARGET;
8215 } else if (Type.isNil(target)) { 8216 target = this.GLOBAL_TARGET; 8217 } 8218 8219 if (!Type.isObject(target)) { 8220 throw new TypeError(`The "target" argument must be an object.`); 8221 } 8222 8223 const targetInfo = eventStore.get(target); 8224 8225 if (targetInfo) { 8226 let maxListeners = targetInfo.maxListeners; 8227 8228 if (Type.isStringFilled(eventName)) { 8229 const fullEventName = this.resolveEventName(eventName, target); 8230 maxListeners = targetInfo.eventsMaxListeners.get(fullEventName) || maxListeners; 8231 } 8232 8233 return maxListeners; 8234 } 8235 8236 return this.DEFAULT_MAX_LISTENERS; 8237 } 8238 }, { 8239 key: "addMaxListeners", 8240 value: function addMaxListeners(...args) { 8241 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 8242 const maxListeners = Math.max(this.getMaxListeners(target, eventName) + increment, 0); 8243 8244 if (Type.isStringFilled(eventName)) { 8245 EventEmitter.setMaxListeners(target, eventName, maxListeners); 8246 } else { 8247 EventEmitter.setMaxListeners(target, maxListeners); 8248 } 8249 8250 return maxListeners; 8251 } 8252 /** 8253 * Increases max listeners count 8254 * 8255 * Event.EventEmitter.incrementMaxListeners() - adds one max listener for all events of global target 8256 * Event.EventEmitter.incrementMaxListeners(3) - adds three max listeners for all events of global target 8257 * Event.EventEmitter.incrementMaxListeners('onClose') - adds one max listener for onClose event of global target 8258 * Event.EventEmitter.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 8259 * 8260 * Event.EventEmitter.incrementMaxListeners(obj) - adds one max listener for all events of 'obj' target 8261 * Event.EventEmitter.incrementMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 8262 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 8263 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 8264 */ 8265 8266 }, { 8267 key: "incrementMaxListeners", 8268 value: function incrementMaxListeners(...args) { 8269 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 8270 return this.addMaxListeners(target, eventName, Math.abs(increment)); 8271 } 8272 }, { 8273 key: "decrementMaxListeners", 8274 value: function decrementMaxListeners(...args) { 8275 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 8276 return this.addMaxListeners(target, eventName, -Math.abs(increment)); 8277 } 8278 }, { 8279 key: "destructMaxListenersArgs", 8280 value: function destructMaxListenersArgs(...args) { 8281 let eventName = null; 8282 let increment = 1; 8283 let target = this.GLOBAL_TARGET;
8284 8285 if (args.length === 1) { 8286 if (Type.isNumber(args[0])) { 8287 increment = args[0]; 8288 } else if (Type.isString(args[0])) { 8289 eventName = args[0]; 8290 } else { 8291 target = args[0]; 8292 } 8293 } else if (args.length === 2) { 8294 if (Type.isString(args[0])) { 8295 [eventName, increment] = args; 8296 } else if (Type.isString(args[1])) { 8297 [target, eventName] = args; 8298 } else { 8299 [target, increment] = args; 8300 } 8301 } else if (args.length >= 3) { 8302 [target, eventName, increment] = args; 8303 } 8304 8305 if (!Type.isObject(target)) { 8306 throw new TypeError(`The "target" argument must be an object.`); 8307 } 8308 8309 if (eventName !== null && !Type.isStringFilled(eventName)) { 8310 throw new TypeError(`The "eventName" argument must be a string.`); 8311 } 8312 8313 if (!Type.isNumber(increment)) { 8314 throw new TypeError(`The value of "increment" must be a number.`); 8315 } 8316 8317 return [target, eventName, increment]; 8318 } 8319 /** 8320 * Gets listeners list for a specified event 8321 * @param {object} target 8322 * @param {string} eventName 8323 */ 8324 8325 }, { 8326 key: "getListeners", 8327 value: function getListeners(target, eventName) { 8328 if (Type.isString(target)) { 8329 eventName = target; 8330 target = this.GLOBAL_TARGET;
8331 } 8332 8333 if (!Type.isObject(target)) { 8334 throw new TypeError(`The "target" argument must be an object.`); 8335 } 8336 8337 eventName = this.normalizeEventName(eventName); 8338 8339 if (!Type.isStringFilled(eventName)) { 8340 throw new TypeError(`The "eventName" argument must be a string.`); 8341 } 8342 8343 const targetInfo = eventStore.get(target); 8344 8345 if (!targetInfo) { 8346 return new Map(); 8347 } 8348 8349 const fullEventName = this.resolveEventName(eventName, target); 8350 return targetInfo.eventsMap.get(fullEventName) || new Map(); 8351 } 8352 }, { 8353 key: "registerAliases", 8354 value: function registerAliases(aliases) { 8355 aliases = this.normalizeAliases(aliases); 8356 Object.keys(aliases).forEach(alias => { 8357 aliasStore.set(alias, { 8358 eventName: aliases[alias].eventName, 8359 namespace: aliases[alias].namespace 8360 }); 8361 }); 8362 EventEmitter.mergeEventAliases(aliases); 8363 } 8364 /** 8365 * @private 8366 * @param aliases 8367 */ 8368 8369 }, { 8370 key: "normalizeAliases", 8371 value: function normalizeAliases(aliases) { 8372 if (!Type.isPlainObject(aliases)) { 8373 throw new TypeError(`The "aliases" argument must be an object.`); 8374 } 8375 8376 const result = Object.create(null); 8377 8378 for (let alias in aliases) { 8379 if (!Type.isStringFilled(alias)) { 8380 throw new TypeError(`The alias must be an non-empty string.`); 8381 } 8382 8383 const options = aliases[alias]; 8384 8385 if (!options || !Type.isStringFilled(options.eventName) || !Type.isStringFilled(options.namespace)) { 8386 throw new TypeError(`The alias options must set the "eventName" and the "namespace".`); 8387 } 8388 8389 alias = this.normalizeEventName(alias); 8390 result[alias] = { 8391 eventName: options.eventName, 8392 namespace: options.namespace 8393 }; 8394 } 8395 8396 return result; 8397 } 8398 /** 8399 * @private 8400 */ 8401 8402 }, { 8403 key: "mergeEventAliases", 8404 value: function mergeEventAliases(aliases) { 8405 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 8406 8407 if (!globalEvents) { 8408 return; 8409 } 8410 8411 Object.keys(aliases).forEach(alias => { 8412 const options = aliases[alias]; 8413 alias = this.normalizeEventName(alias); 8414 const fullEventName = this.makeFullEventName(options.namespace, options.eventName); 8415 const aliasListeners = globalEvents.eventsMap.get(alias); 8416 8417 if (aliasListeners) { 8418 const listeners = globalEvents.eventsMap.get(fullEventName) || new Map(); 8419 globalEvents.eventsMap.set(fullEventName, new Map([...listeners, ...aliasListeners])); 8420 globalEvents.eventsMap.delete(alias); 8421 } 8422 8423 const aliasOnceListeners = globalEvents.onceMap.get(alias); 8424 8425 if (aliasOnceListeners) { 8426 const onceListeners = globalEvents.onceMap.get(fullEventName) || new Map(); 8427 globalEvents.onceMap.set(fullEventName, new Map([...onceListeners, ...aliasOnceListeners])); 8428 globalEvents.onceMap.delete(alias); 8429 } 8430 8431 const aliasMaxListeners = globalEvents.eventsMaxListeners.get(alias); 8432 8433 if (aliasMaxListeners) { 8434 const eventMaxListeners = globalEvents.eventsMaxListeners.get(fullEventName) || 0; 8435 globalEvents.eventsMaxListeners.set(fullEventName, Math.max(eventMaxListeners, aliasMaxListeners)); 8436 globalEvents.eventsMaxListeners.delete(alias); 8437 } 8438 }); 8439 } 8440 /** 8441 * Returns true if the target is an instance of Event.EventEmitter 8442 * @param {object} target 8443 * @returns {boolean} 8444 */ 8445 8446 }, { 8447 key: "isEventEmitter", 8448 value: function isEventEmitter(target) { 8449 return Type.isObject(target) && target[isEmitterProperty] === true; 8450 } 8451 /** 8452 * @private 8453 * @param {string} eventName 8454 * @returns {string} 8455 */ 8456 8457 }, { 8458 key: "normalizeEventName", 8459 value: function normalizeEventName(eventName) { 8460 if (!Type.isStringFilled(eventName)) { 8461 return ''; 8462 } 8463 8464 return eventName.toLowerCase(); 8465 } 8466 /** 8467 * @private 8468 */ 8469 8470 }, { 8471 key: "normalizeListener", 8472 value: function normalizeListener(listener) { 8473 if (Type.isString(listener)) { 8474 listener = Reflection.getClass(listener); 8475 } 8476 8477 if (!Type.isFunction(listener)) { 8478 throw new TypeError(`The "listener" argument must be of type Function. Received type ${typeof listener}.`); 8479 } 8480 8481 return listener; 8482 } 8483 /** 8484 * @private 8485 * @param eventName 8486 * @param target 8487 * @param useGlobalNaming 8488 * @returns {string} 8489 */ 8490 8491 }, { 8492 key: "resolveEventName", 8493 value: function resolveEventName(eventName, target, useGlobalNaming = false) { 8494 eventName = this.normalizeEventName(eventName); 8495 8496 if (!Type.isStringFilled(eventName)) { 8497 return ''; 8498 } 8499 8500 if (this.isEventEmitter(target) && useGlobalNaming !== true) { 8501 if (target.getEventNamespace() !== null && eventName.includes('.')) { 8502 console.warn(`Possible the wrong event name "${eventName}".`); 8503 } 8504 8505 eventName = target.getFullEventName(eventName); 8506 } else if (aliasStore.has(eventName)) { 8507 const { 8508 namespace, 8509 eventName: actualEventName 8510 } = aliasStore.get(eventName); 8511 eventName = this.makeFullEventName(namespace, actualEventName); 8512 } 8513 8514 return eventName; 8515 } 8516 /** 8517 * @private 8518 * @param {string} namespace 8519 * @param {string} eventName 8520 * @returns {string} 8521 */ 8522 8523 }, { 8524 key: "makeFullEventName", 8525 value: function makeFullEventName(namespace, eventName) { 8526 const fullName = Type.isStringFilled(namespace) ? `${namespace}:${eventName}` : eventName; 8527 return Type.isStringFilled(fullName) ? fullName.toLowerCase() : ''; 8528 } 8529 }]); 8530 return EventEmitter; 8531 }(); 8532 8533 babelHelpers.defineProperty(EventEmitter, "GLOBAL_TARGET", globalTarget); 8534 babelHelpers.defineProperty(EventEmitter, "DEFAULT_MAX_LISTENERS", eventStore.getDefaultMaxListeners()); 8535 babelHelpers.defineProperty(EventEmitter, "sequenceValue", 1); 8536 8537 let stack = []; 8538 /** 8539 * For compatibility only 8540 * @type {boolean} 8541 */ 8542 // eslint-disable-next-line 8543 8544 exports.isReady = false;
8545 function ready(handler) { 8546 switch (document.readyState) { 8547 case 'loading': 8548 stack.push(handler); 8549 break; 8550 8551 case 'interactive': 8552 case 'complete': 8553 if (Type.isFunction(handler)) { 8554 handler(); 8555 } 8556 8557 exports.isReady = true; 8558 break; 8559 8560 default: 8561 break; 8562 } 8563 } 8564 document.addEventListener('readystatechange', () => { 8565 if (!exports.isReady) { 8566 stack.forEach(ready); 8567 stack = []; 8568 } 8569 }); 8570 8571 /** 8572 * @memberOf BX 8573 */ 8574 8575 let Event = function Event() { 8576 babelHelpers.classCallCheck(this, Event); 8577 }; 8578 8579 babelHelpers.defineProperty(Event, "bind", bind); 8580 babelHelpers.defineProperty(Event, "bindOnce", bindOnce); 8581 babelHelpers.defineProperty(Event, "unbind", unbind); 8582 babelHelpers.defineProperty(Event, "unbindAll", unbindAll); 8583 babelHelpers.defineProperty(Event, "ready", ready); 8584 babelHelpers.defineProperty(Event, "EventEmitter", EventEmitter); 8585 babelHelpers.defineProperty(Event, "BaseEvent", BaseEvent); 8586 8587 function encodeAttributeValue(value) { 8588 if (Type.isPlainObject(value) || Type.isArray(value)) { 8589 return JSON.stringify(value); 8590 } 8591 8592 return Text.encode(Text.decode(value)); 8593 } 8594 8595 function decodeAttributeValue(value) { 8596 if (Type.isString(value)) { 8597 const decodedValue = Text.decode(value); 8598 let result; 8599 8600 try { 8601 result = JSON.parse(decodedValue); 8602 } catch (e) { 8603 result = decodedValue; 8604 } 8605 8606 if (result === decodedValue) { 8607 if (/^[\d.]+[.]?\d+$/.test(result)) { 8608 return Number(result); 8609 } 8610 } 8611 8612 if (result === 'true' || result === 'false') { 8613 return Boolean(result); 8614 } 8615 8616 return result; 8617 } 8618 8619 return value; 8620 } 8621 8622 function getPageScroll() { 8623 const { 8624 documentElement, 8625 body 8626 } = document; 8627 const scrollTop = Math.max(window.pageYOffset || 0, documentElement ? documentElement.scrollTop : 0, body ? body.scrollTop : 0); 8628 const scrollLeft = Math.max(window.pageXOffset || 0, documentElement ? documentElement.scrollLeft : 0, body ? body.scrollLeft : 0); 8629 return { 8630 scrollTop, 8631 scrollLeft 8632 }; 8633 } 8634 8635 /** 8636 * @memberOf BX 8637 */ 8638 8639 let Dom = /*#__PURE__*/function () { 8640 function Dom() { 8641 babelHelpers.classCallCheck(this, Dom); 8642 } 8643 8644 babelHelpers.createClass(Dom, null, [{ 8645 key: "replace", 8646 8647 /** 8648 * Replaces old html element to new html element 8649 * @param oldElement 8650 * @param newElement 8651 */ 8652 value: function replace(oldElement, newElement) { 8653 if (Type.isDomNode(oldElement) && Type.isDomNode(newElement)) { 8654 if (Type.isDomNode(oldElement.parentNode)) { 8655 oldElement.parentNode.replaceChild(newElement, oldElement); 8656 } 8657 } 8658 } 8659 /** 8660 * Removes element 8661 * @param element 8662 */ 8663 8664 }, { 8665 key: "remove", 8666 value: function remove(element) { 8667 if (Type.isDomNode(element) && Type.isDomNode(element.parentNode)) { 8668 element.parentNode.removeChild(element); 8669 } 8670 } 8671 /** 8672 * Cleans element 8673 * @param element 8674 */ 8675 8676 }, { 8677 key: "clean", 8678 value: function clean(element) { 8679 if (Type.isDomNode(element)) { 8680 while (element.childNodes.length > 0) { 8681 element.removeChild(element.firstChild); 8682 } 8683 8684 return; 8685 } 8686 8687 if (Type.isString(element)) { 8688 Dom.clean(document.getElementById(element)); 8689 } 8690 } 8691 /** 8692 * Inserts element before target element 8693 * @param current 8694 * @param target 8695 */ 8696 8697 }, { 8698 key: "insertBefore", 8699 value: function insertBefore(current, target) { 8700 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8701 if (Type.isDomNode(target.parentNode)) { 8702 target.parentNode.insertBefore(current, target); 8703 } 8704 } 8705 } 8706 /** 8707 * Inserts element after target element 8708 * @param current 8709 * @param target 8710 */ 8711 8712 }, { 8713 key: "insertAfter", 8714 value: function insertAfter(current, target) { 8715 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8716 if (Type.isDomNode(target.parentNode)) { 8717 const parent = target.parentNode; 8718 8719 if (Type.isDomNode(target.nextSibling)) { 8720 parent.insertBefore(current, target.nextSibling); 8721 return; 8722 } 8723 8724 parent.appendChild(current); 8725 } 8726 } 8727 } 8728 /** 8729 * Appends element to target element 8730 * @param current 8731 * @param target 8732 */ 8733 8734 }, { 8735 key: "append", 8736 value: function append(current, target) { 8737 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8738 target.appendChild(current); 8739 } 8740 } 8741 /** 8742 * Prepends element to target element 8743 * @param current 8744 * @param target 8745 */ 8746 8747 }, {
8748 key: "prepend", 8749 value: function prepend(current, target) { 8750 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8751 if (Type.isDomNode(target.firstChild)) { 8752 target.insertBefore(current, target.firstChild); 8753 return; 8754 } 8755 8756 Dom.append(current, target); 8757 } 8758 } 8759 /** 8760 * Checks that element contains class name or class names 8761 * @param element 8762 * @param className 8763 * @return {Boolean} 8764 */ 8765 8766 }, { 8767 key: "hasClass", 8768 value: function hasClass(element, className) { 8769 if (Type.isElementNode(element)) { 8770 if (Type.isString(className)) { 8771 const preparedClassName = className.trim(); 8772 8773 if (preparedClassName.length > 0) { 8774 if (preparedClassName.includes(' ')) { 8775 return preparedClassName.split(' ').every(name => Dom.hasClass(element, name)); 8776 } 8777 8778 if ('classList' in element) { 8779 return element.classList.contains(preparedClassName); 8780 } 8781 8782 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8783 return element.getAttribute('class').split(' ').some(name => name === preparedClassName); 8784 } 8785 } 8786 } 8787 8788 if (Type.isArray(className) && className.length > 0) { 8789 return className.every(name => Dom.hasClass(element, name)); 8790 } 8791 } 8792 8793 return false; 8794 } 8795 /** 8796 * Adds class name 8797 * @param element 8798 * @param className 8799 */ 8800 8801 }, { 8802 key: "addClass", 8803 value: function addClass(element, className) { 8804 if (Type.isElementNode(element)) { 8805 if (Type.isString(className)) { 8806 const preparedClassName = className.trim(); 8807 8808 if (preparedClassName.length > 0) { 8809 if (preparedClassName.includes(' ')) { 8810 Dom.addClass(element, preparedClassName.split(' ')); 8811 return; 8812 } 8813 8814 if ('classList' in element) { 8815 element.classList.add(preparedClassName); 8816 return; 8817 } 8818 8819 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8820 if (element.className.baseVal === '') { 8821 element.className.baseVal = preparedClassName; 8822 return; 8823 } 8824 8825 const names = element.className.baseVal.split(' '); 8826 8827 if (!names.includes(preparedClassName)) { 8828 names.push(preparedClassName); 8829 element.className.baseVal = names.join(' ').trim(); 8830 return; 8831 } 8832 } 8833 8834 return; 8835 } 8836 } 8837 8838 if (Type.isArray(className)) { 8839 className.forEach(name => Dom.addClass(element, name)); 8840 } 8841 } 8842 } 8843 /** 8844 * Removes class name 8845 * @param element 8846 * @param className 8847 */ 8848 8849 }, { 8850 key: "removeClass", 8851 value: function removeClass(element, className) { 8852 if (Type.isElementNode(element)) { 8853 if (Type.isString(className)) { 8854 const preparedClassName = className.trim(); 8855 8856 if (preparedClassName.length > 0) { 8857 if (preparedClassName.includes(' ')) { 8858 Dom.removeClass(element, preparedClassName.split(' ')); 8859 return; 8860 } 8861 8862 if ('classList' in element) { 8863 element.classList.remove(preparedClassName); 8864 return; 8865 } 8866 8867 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8868 const names = element.className.baseVal.split(' ').filter(name => name !== preparedClassName); 8869 element.className.baseVal = names.join(' '); 8870 return; 8871 } 8872 } 8873 } 8874 8875 if (Type.isArray(className)) { 8876 className.forEach(name => Dom.removeClass(element, name)); 8877 } 8878 } 8879 } 8880 /** 8881 * Toggles class name 8882 * @param element 8883 * @param className 8884 */ 8885 8886 }, { 8887 key: "toggleClass", 8888 value: function toggleClass(element, className) { 8889 if (Type.isElementNode(element)) { 8890 if (Type.isString(className)) { 8891 const preparedClassName = className.trim(); 8892 8893 if (preparedClassName.length > 0) { 8894 if (preparedClassName.includes(' ')) { 8895 Dom.toggleClass(element, preparedClassName.split(' ')); 8896 return; 8897 } 8898 8899 element.classList.toggle(preparedClassName); 8900 return; 8901 } 8902 } 8903 8904 if (Type.isArray(className)) { 8905 className.forEach(name => Dom.toggleClass(element, name)); 8906 } 8907 } 8908 } 8909 /** 8910 * Styles element 8911 */ 8912 8913 }, { 8914 key: "style", 8915 value: function style(element, prop, value) { 8916 if (Type.isElementNode(element)) { 8917 if (Type.isNull(prop)) { 8918 element.removeAttribute('style'); 8919 return element; 8920 } 8921 8922 if (Type.isPlainObject(prop)) {
8923 Object.entries(prop).forEach(item => { 8924 const [currentKey, currentValue] = item; 8925 Dom.style(element, currentKey, currentValue); 8926 }); 8927 return element; 8928 } 8929 8930 if (Type.isString(prop)) { 8931 if (Type.isUndefined(value) && element.nodeType !== Node.DOCUMENT_NODE) { 8932 const computedStyle = getComputedStyle(element); 8933 8934 if (prop in computedStyle) { 8935 return computedStyle[prop]; 8936 } 8937 8938 return computedStyle.getPropertyValue(prop); 8939 } 8940 8941 if (Type.isNull(value) || value === '' || value === 'null') { 8942 if (String(prop).startsWith('--')) { 8943 // eslint-disable-next-line 8944 element.style.removeProperty(prop); 8945 return element; 8946 } // eslint-disable-next-line 8947 8948 8949 element.style[prop] = ''; 8950 return element; 8951 } 8952 8953 if (Type.isString(value) || Type.isNumber(value)) { 8954 if (String(prop).startsWith('--')) { 8955 // eslint-disable-next-line 8956 element.style.setProperty(prop, value); 8957 return element; 8958 } // eslint-disable-next-line 8959 8960 8961 element.style[prop] = value; 8962 return element; 8963 } 8964 } 8965 } 8966 8967 return null; 8968 } 8969 /** 8970 * Adjusts element 8971 * @param target 8972 * @param data 8973 * @return {*} 8974 */ 8975 8976 }, { 8977 key: "adjust", 8978 value: function adjust(target, data = {}) { 8979 if (!target.nodeType) { 8980 return null; 8981 } 8982 8983 let element = target; 8984 8985 if (target.nodeType === Node.DOCUMENT_NODE) { 8986 element = target.body; 8987 } 8988 8989 if (Type.isPlainObject(data)) { 8990 if (Type.isPlainObject(data.attrs)) { 8991 Object.keys(data.attrs).forEach(key => { 8992 if (key === 'class' || key.toLowerCase() === 'classname') { 8993 element.className = data.attrs[key]; 8994 return; 8995 } // eslint-disable-next-line 8996 8997 8998 if (data.attrs[key] == '') { 8999 element.removeAttribute(key); 9000 return; 9001 } 9002 9003 element.setAttribute(key, data.attrs[key]); 9004 }); 9005 } 9006 9007 if (Type.isPlainObject(data.style)) { 9008 Dom.style(element, data.style); 9009 } 9010 9011 if (Type.isPlainObject(data.props)) { 9012 Object.keys(data.props).forEach(key => { 9013 element[key] = data.props[key]; 9014 }); 9015 } 9016 9017 if (Type.isPlainObject(data.events)) { 9018 Object.keys(data.events).forEach(key => { 9019 Event.bind(element, key, data.events[key]); 9020 }); 9021 } 9022 9023 if (Type.isPlainObject(data.dataset)) { 9024 Object.keys(data.dataset).forEach(key => { 9025 element.dataset[key] = data.dataset[key]; 9026 }); 9027 } 9028 9029 if (Type.isString(data.children)) { 9030 data.children = [data.children]; 9031 } 9032 9033 if (Type.isArray(data.children) && data.children.length > 0) { 9034 data.children.forEach(item => { 9035 if (Type.isDomNode(item)) { 9036 Dom.append(item, element); 9037 } 9038 9039 if (Type.isString(item)) { 9040 element.insertAdjacentHTML('beforeend', item); 9041 } 9042 }); 9043 return element; 9044 } 9045 9046 if ('text' in data && !Type.isNil(data.text)) { 9047 element.innerText = data.text; 9048 return element; 9049 } 9050 9051 if ('html' in data && !Type.isNil(data.html)) { 9052 element.innerHTML = data.html; 9053 } 9054 } 9055 9056 return element; 9057 } 9058 /** 9059 * Creates element 9060 * @param tag 9061 * @param data 9062 * @param context 9063 * @return {HTMLElement|HTMLBodyElement} 9064 */ 9065 9066 }, { 9067 key: "create", 9068 value: function create(tag, data = {}, context = document) { 9069 let tagName = tag; 9070 let options = data; 9071 9072 if (Type.isObjectLike(tag)) { 9073 options = tag; 9074 tagName = tag.tag; 9075 } 9076 9077 return Dom.adjust(context.createElement(tagName), options); 9078 } 9079 /** 9080 * Shows element 9081 * @param element 9082 */ 9083 9084 }, { 9085 key: "show", 9086 value: function show(element) { 9087 if (Type.isDomNode(element)) { 9088 // eslint-disable-next-line 9089 element.hidden = false;
9090 } 9091 } 9092 /** 9093 * Hides element 9094 * @param element 9095 */ 9096 9097 }, { 9098 key: "hide", 9099 value: function hide(element) { 9100 if (Type.isDomNode(element)) { 9101 // eslint-disable-next-line 9102 element.hidden = true; 9103 } 9104 } 9105 /** 9106 * Checks that element is shown 9107 * @param element 9108 * @return {*|boolean} 9109 */ 9110 9111 }, { 9112 key: "isShown", 9113 value: function isShown(element) { 9114 return Type.isDomNode(element) && !element.hidden && element.style.getPropertyValue('display') !== 'none'; 9115 } 9116 /** 9117 * Toggles element visibility 9118 * @param element 9119 */ 9120 9121 }, { 9122 key: "toggle", 9123 value: function toggle(element) { 9124 if (Type.isDomNode(element)) { 9125 if (Dom.isShown(element)) { 9126 Dom.hide(element); 9127 } else { 9128 Dom.show(element); 9129 } 9130 } 9131 } 9132 /** 9133 * Gets element position relative page 9134 * @param {HTMLElement} element 9135 * @return {DOMRect} 9136 */ 9137 9138 }, { 9139 key: "getPosition", 9140 value: function getPosition(element) { 9141 if (Type.isDomNode(element)) { 9142 const elementRect = element.getBoundingClientRect(); 9143 const { 9144 scrollLeft, 9145 scrollTop 9146 } = getPageScroll(); 9147 return new DOMRect(elementRect.left + scrollLeft, elementRect.top + scrollTop, elementRect.width, elementRect.height); 9148 } 9149 9150 return new DOMRect(); 9151 } 9152 /** 9153 * Gets element position relative specified element position 9154 * @param {HTMLElement} element 9155 * @param {HTMLElement} relationElement 9156 * @return {DOMRect} 9157 */ 9158 9159 }, { 9160 key: "getRelativePosition", 9161 value: function getRelativePosition(element, relationElement) { 9162 if (Type.isDomNode(element) && Type.isDomNode(relationElement)) { 9163 const elementPosition = Dom.getPosition(element); 9164 const relationElementPosition = Dom.getPosition(relationElement); 9165 return new DOMRect(elementPosition.left - relationElementPosition.left, elementPosition.top - relationElementPosition.top, elementPosition.width, elementPosition.height); 9166 } 9167 9168 return new DOMRect(); 9169 } 9170 }, { 9171 key: "attr", 9172 value: function attr(element, _attr, value) { 9173 if (Type.isElementNode(element)) { 9174 if (Type.isString(_attr)) { 9175 if (!Type.isNil(value)) { 9176 return element.setAttribute(_attr, encodeAttributeValue(value)); 9177 } 9178 9179 if (Type.isNull(value)) { 9180 return element.removeAttribute(_attr); 9181 } 9182 9183 return decodeAttributeValue(element.getAttribute(_attr)); 9184 } 9185 9186 if (Type.isPlainObject(_attr)) { 9187 return Object.entries(_attr).forEach(([attrKey, attrValue]) => { 9188 Dom.attr(element, attrKey, attrValue); 9189 }); 9190 } 9191 } 9192 9193 return null; 9194 } 9195 }]); 9196 return Dom; 9197 }(); 9198 9199 const UA = navigator.userAgent.toLowerCase(); 9200 /** 9201 * @memberOf BX 9202 */ 9203 9204 let Browser = /*#__PURE__*/function () { 9205 function Browser() { 9206 babelHelpers.classCallCheck(this, Browser); 9207 } 9208 9209 babelHelpers.createClass(Browser, null, [{ 9210 key: "isOpera", 9211 value: function isOpera() { 9212 return UA.includes('opera'); 9213 } 9214 }, { 9215 key: "isIE", 9216 value: function isIE() { 9217 return 'attachEvent' in document && !Browser.isOpera(); 9218 } 9219 }, { 9220 key: "isIE6", 9221 value: function isIE6() { 9222 return UA.includes('msie 6'); 9223 } 9224 }, { 9225 key: "isIE7", 9226 value: function isIE7() { 9227 return UA.includes('msie 7'); 9228 } 9229 }, { 9230 key: "isIE8", 9231 value: function isIE8() { 9232 return UA.includes('msie 8'); 9233 } 9234 }, { 9235 key: "isIE9", 9236 value: function isIE9() { 9237 return 'documentMode' in document && document.documentMode >= 9; 9238 } 9239 }, { 9240 key: "isIE10", 9241 value: function isIE10() { 9242 return 'documentMode' in document && document.documentMode >= 10; 9243 } 9244 }, { 9245 key: "isSafari", 9246 value: function isSafari() { 9247 return UA.includes('webkit'); 9248 } 9249 }, { 9250 key: "isFirefox", 9251 value: function isFirefox() { 9252 return UA.includes('firefox'); 9253 } 9254 }, { 9255 key: "isChrome", 9256 value: function isChrome() { 9257 return UA.includes('chrome'); 9258 } 9259 }, { 9260 key: "detectIEVersion", 9261 value: function detectIEVersion() { 9262 if (Browser.isOpera() || Browser.isSafari() || Browser.isFirefox() || Browser.isChrome()) { 9263 return -1; 9264 } 9265 9266 let rv = -1; 9267 9268 if (!!window.MSStream && !window.ActiveXObject && 'ActiveXObject' in window) { 9269 rv = 11; 9270 } else if (Browser.isIE10()) { 9271 rv = 10; 9272 } else if (Browser.isIE9()) { 9273 rv = 9; 9274 } else if (Browser.isIE()) { 9275 rv = 8; 9276 } 9277 9278 if (rv === -1 || rv === 8) { 9279 if (navigator.appName === 'Microsoft Internet Explorer') { 9280 const re = new RegExp('MSIE ([0-9]+[.0-9]*)'); 9281 const res = navigator.userAgent.match(re); 9282 9283 if (Type.isArrayLike(res) && res.length > 0) { 9284 rv = parseFloat(res[1]); 9285 } 9286 } 9287 9288 if (navigator.appName === 'Netscape') { 9289 // Alternative check for IE 11 9290 rv = 11; 9291 const re = new RegExp('Trident/.*rv:([0-9]+[.0-9]*)'); 9292 9293 if (re.exec(navigator.userAgent) != null) { 9294 const res = navigator.userAgent.match(re); 9295 9296 if (Type.isArrayLike(res) && res.length > 0) { 9297 rv = parseFloat(res[1]); 9298 } 9299 } 9300 } 9301 } 9302 9303 return rv; 9304 } 9305 }, { 9306 key: "isIE11", 9307 value: function isIE11() { 9308 return Browser.detectIEVersion() >= 11; 9309 } 9310 }, { 9311 key: "isMac", 9312 value: function isMac() { 9313 return UA.includes('macintosh'); 9314 } 9315 }, { 9316 key: "isWin", 9317 value: function isWin() { 9318 return UA.includes('windows'); 9319 } 9320 }, { 9321 key: "isLinux", 9322 value: function isLinux() { 9323 return UA.includes('linux') && !Browser.isAndroid(); 9324 } 9325 }, { 9326 key: "isAndroid", 9327 value: function isAndroid() { 9328 return UA.includes('android'); 9329 } 9330 }, { 9331 key: "isIPad", 9332 value: function isIPad() { 9333 return UA.includes('ipad;') || this.isMac() && this.isTouchDevice(); 9334 } 9335 }, { 9336 key: "isIPhone", 9337 value: function isIPhone() { 9338 return UA.includes('iphone;'); 9339 } 9340 }, { 9341 key: "isIOS", 9342 value: function isIOS() { 9343 return Browser.isIPad() || Browser.isIPhone(); 9344 } 9345 }, { 9346 key: "isMobile", 9347 value: function isMobile() { 9348 return Browser.isIPhone() || Browser.isIPad() || Browser.isAndroid() || UA.includes('mobile') || UA.includes('touch'); 9349 } 9350 }, { 9351 key: "isRetina", 9352 value: function isRetina() { 9353 return window.devicePixelRatio && window.devicePixelRatio >= 2; 9354 } 9355 }, { 9356 key: "isTouchDevice", 9357 value: function isTouchDevice() { 9358 return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; 9359 } 9360 }, { 9361 key: "isDoctype", 9362 value: function isDoctype(target) { 9363 const doc = target || document; 9364 9365 if (doc.compatMode) { 9366 return doc.compatMode === 'CSS1Compat'; 9367 } 9368 9369 return doc.documentElement && doc.documentElement.clientHeight; 9370 } 9371 }, { 9372 key: "isLocalStorageSupported", 9373 value: function isLocalStorageSupported() { 9374 try { 9375 localStorage.setItem('test', 'test'); 9376 localStorage.removeItem('test'); 9377 return true; 9378 } catch (e) { 9379 return false;
9380 } 9381 } 9382 }, { 9383 key: "addGlobalClass", 9384 value: function addGlobalClass(target) { 9385 let globalClass = 'bx-core'; 9386 target = Type.isElementNode(target) ? target : document.documentElement; 9387 9388 if (Dom.hasClass(target, globalClass)) { 9389 return; 9390 } 9391 9392 if (Browser.isIOS()) { 9393 globalClass += ' bx-ios'; 9394 } else if (Browser.isWin()) { 9395 globalClass += ' bx-win'; 9396 } else if (Browser.isMac()) { 9397 globalClass += ' bx-mac'; 9398 } else if (Browser.isLinux()) { 9399 globalClass += ' bx-linux'; 9400 } else if (Browser.isAndroid()) { 9401 globalClass += ' bx-android'; 9402 } 9403 9404 globalClass += Browser.isMobile() ? ' bx-touch' : ' bx-no-touch'; 9405 globalClass += Browser.isRetina() ? ' bx-retina' : ' bx-no-retina'; 9406 let ieVersion = -1; 9407 9408 if (/AppleWebKit/.test(navigator.userAgent)) { 9409 globalClass += ' bx-chrome'; 9410 } else if (Browser.detectIEVersion() > 0) { 9411 ieVersion = Browser.detectIEVersion(); 9412 globalClass += ` bx-ie bx-ie${ieVersion}`; 9413 9414 if (ieVersion > 7 && ieVersion < 10 && !Browser.isDoctype()) { 9415 globalClass += ' bx-quirks'; 9416 } 9417 } else if (/Opera/.test(navigator.userAgent)) { 9418 globalClass += ' bx-opera'; 9419 } else if (/Gecko/.test(navigator.userAgent)) { 9420 globalClass += ' bx-firefox'; 9421 } 9422 9423 Dom.addClass(target, globalClass); 9424 } 9425 }, { 9426 key: "detectAndroidVersion", 9427 value: function detectAndroidVersion() { 9428 const re = new RegExp('Android ([0-9]+[.0-9]*)'); 9429 9430 if (re.exec(navigator.userAgent) != null) { 9431 const res = navigator.userAgent.match(re); 9432 9433 if (Type.isArrayLike(res) && res.length > 0) { 9434 return parseFloat(res[1]); 9435 } 9436 } 9437 9438 return 0; 9439 } 9440 }, { 9441 key: "isPropertySupported", 9442 value: function isPropertySupported(jsProperty, returnCSSName) { 9443 if (jsProperty === '') { 9444 return false; 9445 } 9446 9447 function getCssName(propertyName) { 9448 return propertyName.replace(/([A-Z])/g, (...args) => `-${args[1].toLowerCase()}`); 9449 } 9450 9451 function getJsName(cssName) { 9452 const reg = /(\\-([a-z]))/g; 9453 9454 if (reg.test(cssName)) { 9455 return cssName.replace(reg, (...args) => args[2].toUpperCase()); 9456 } 9457 9458 return cssName; 9459 } 9460 9461 const property = jsProperty.includes('-') ? getJsName(jsProperty) : jsProperty; 9462 const bReturnCSSName = !!returnCSSName; 9463 const ucProperty = property.charAt(0).toUpperCase() + property.slice(1); 9464 const props = ['Webkit', 'Moz', 'O', 'ms'].join(`${ucProperty} `); 9465 const properties = `${property} ${props} ${ucProperty}`.split(' '); 9466 const obj = document.body || document.documentElement; 9467 9468 for (let i = 0; i < properties.length; i += 1) { 9469 const prop = properties[i]; 9470 9471 if (obj && 'style' in obj && prop in obj.style) { 9472 const lowerProp = prop.substr(0, prop.length - property.length).toLowerCase(); 9473 const prefix = prop === property ? '' : `-${lowerProp}-`; 9474 return bReturnCSSName ? prefix + getCssName(property) : prop; 9475 } 9476 } 9477 9478 return false; 9479 } 9480 }, { 9481 key: "addGlobalFeatures", 9482 value: function addGlobalFeatures(features) { 9483 if (!Type.isArray(features)) { 9484 return; 9485 } 9486 9487 const classNames = []; 9488 9489 for (let i = 0; i < features.length; i += 1) { 9490 const support = !!Browser.isPropertySupported(features[i]); 9491 classNames.push(`bx-${support ? '' : 'no-'}${features[i].toLowerCase()}`); 9492 } 9493 9494 Dom.addClass(document.documentElement, classNames.join(' ')); 9495 } 9496 }]); 9497 return Browser; 9498 }(); 9499 9500 let Cookie = /*#__PURE__*/function () { 9501 function Cookie() { 9502 babelHelpers.classCallCheck(this, Cookie); 9503 } 9504 9505 babelHelpers.createClass(Cookie, null, [{ 9506 key: "getList", 9507 9508 /** 9509 * Gets cookies list for current domain 9510 * @return {object} 9511 */ 9512 value: function getList() { 9513 return document.cookie.split(';').map(item => item.split('=')).map(item => item.map(subItem => subItem.trim())).reduce((acc, item) => { 9514 const [key, value] = item; 9515 acc[decodeURIComponent(key)] = decodeURIComponent(value); 9516 return acc; 9517 }, {}); 9518 } 9519 /** 9520 * Gets cookie value 9521 * @param {string} name 9522 * @return {*} 9523 */ 9524 9525 }, { 9526 key: "get", 9527 value: function get(name) { 9528 const cookiesList = Cookie.getList(); 9529 9530 if (name in cookiesList) { 9531 return cookiesList[name]; 9532 } 9533 9534 return undefined; 9535 } 9536 /** 9537 * Sets cookie 9538 * @param {string} name 9539 * @param {*} value 9540 * @param {object} [options] 9541 */ 9542 9543 }, { 9544 key: "set", 9545 value: function set(name, value, options = {}) { 9546 const attributes = { 9547 expires: '', 9548 ...options 9549 }; 9550 9551 if (Type.isNumber(attributes.expires)) { 9552 const now = +new Date(); 9553 const days = attributes.expires; 9554 const dayInMs = 864e+5; 9555 attributes.expires = new Date(now + days * dayInMs); 9556 } 9557 9558 if (Type.isDate(attributes.expires)) { 9559 attributes.expires = attributes.expires.toUTCString(); 9560 } 9561 9562 const safeName = decodeURIComponent(String(name)).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape); 9563 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); 9564 const stringifiedAttributes = Object.keys(attributes).reduce((acc, key) => { 9565 const attributeValue = attributes[key]; 9566 9567 if (!attributeValue) { 9568 return acc; 9569 } 9570 9571 if (attributeValue === true) { 9572 return `${acc}; ${key}`; 9573 } 9574 /** 9575 * Considers RFC 6265 section 5.2: 9576 * ... 9577 * 3. If the remaining unparsed-attributes contains a %x3B (';') 9578 * character: 9579 * Consume the characters of the unparsed-attributes up to, 9580 * not including, the first %x3B (';') character. 9581 */ 9582 9583 9584 return `${acc}; ${key}=${attributeValue.split(';')[0]}`; 9585 }, ''); 9586 document.cookie = `${safeName}=${safeValue}${stringifiedAttributes}`; 9587 } 9588 /** 9589 * Removes cookie 9590 * @param {string} name 9591 * @param {object} [options] 9592 */ 9593 9594 }, { 9595 key: "remove", 9596 value: function remove(name, options = {}) { 9597 Cookie.set(name, '', { ...options, 9598 expires: -1 9599 }); 9600 } 9601 }]); 9602 return Cookie; 9603 }(); 9604 9605 function objectToFormData(source, formData = new FormData(), pre = null) { 9606 if (Type.isUndefined(source)) { 9607 return formData; 9608 } 9609 9610 if (Type.isNull(source)) { 9611 formData.append(pre, ''); 9612 } else if (Type.isArray(source)) { 9613 if (!source.length) {
9614 const key = `${pre}[]`; 9615 formData.append(key, ''); 9616 } else { 9617 source.forEach((value, index) => { 9618 const key = `${pre}[${index}]`; 9619 objectToFormData(value, formData, key); 9620 }); 9621 } 9622 } else if (Type.isDate(source)) { 9623 formData.append(pre, source.toISOString()); 9624 } else if (Type.isObject(source) && !Type.isFile(source) && !Type.isBlob(source)) { 9625 Object.keys(source).forEach(property => { 9626 const value = source[property]; 9627 let preparedProperty = property; 9628 9629 if (Type.isArray(value)) { 9630 while (property.length > 2 && property.lastIndexOf('[]') === property.length - 2) { 9631 preparedProperty = property.substring(0, property.length - 2); 9632 } 9633 } 9634 9635 const key = pre ? `${pre}[${preparedProperty}]` : preparedProperty; 9636 objectToFormData(value, formData, key); 9637 }); 9638 } else { 9639 formData.append(pre, source); 9640 } 9641 9642 return formData; 9643 } 9644 9645 let Data = /*#__PURE__*/function () { 9646 function Data() { 9647 babelHelpers.classCallCheck(this, Data); 9648 } 9649 9650 babelHelpers.createClass(Data, null, [{ 9651 key: "convertObjectToFormData", 9652 9653 /** 9654 * Converts object to FormData 9655 * @param source 9656 * @return {FormData} 9657 */ 9658 value: function convertObjectToFormData(source) { 9659 return objectToFormData(source); 9660 } 9661 }]); 9662 return Data; 9663 }(); 9664 9665 /** 9666 * @memberOf BX 9667 */ 9668 9669 let Http = function Http() { 9670 babelHelpers.classCallCheck(this, Http); 9671 }; 9672 9673 babelHelpers.defineProperty(Http, "Cookie", Cookie); 9674 babelHelpers.defineProperty(Http, "Data", Data); 9675 9676 function message(value) { 9677 if (Type.isString(value)) { 9678 if (Type.isNil(message[value])) { 9679 // eslint-disable-next-line 9680 EventEmitter.emit('onBXMessageNotFound', new BaseEvent({ 9681 compatData: [value] 9682 })); 9683 9684 if (Type.isNil(message[value])) { 9685 Runtime.debug(`message undefined: ${value}`); 9686 message[value] = ''; 9687 } 9688 } 9689 } 9690 9691 if (Type.isPlainObject(value)) { 9692 Object.keys(value).forEach(key => { 9693 message[key] = value[key]; 9694 }); 9695 } 9696 9697 return message[value]; 9698 } 9699 9700 if (!Type.isNil(window.BX) && Type.isFunction(window.BX.message)) { 9701 Object.keys(window.BX.message).forEach(key => { 9702 message({ 9703 [key]: window.BX.message[key] 9704 }); 9705 }); 9706 } 9707 9708 /** 9709 * Implements interface for works with language messages 9710 * @memberOf BX 9711 */ 9712 9713 let Loc = /*#__PURE__*/function () { 9714 function Loc() { 9715 babelHelpers.classCallCheck(this, Loc); 9716 } 9717 9718 babelHelpers.createClass(Loc, null, [{ 9719 key: "getMessage", 9720 9721 /** 9722 * Gets message by id 9723 * @param {string} messageId 9724 * @param {object} replacements 9725 * @return {?string} 9726 */ 9727 value: function getMessage(messageId, replacements = null) { 9728 let mess = message(messageId); 9729 9730 if (Type.isString(mess) && Type.isPlainObject(replacements)) { 9731 Object.keys(replacements).forEach(replacement => { 9732 const globalRegexp = new RegExp(replacement, 'gi'); 9733 mess = mess.replace(globalRegexp, () => { 9734 return Type.isNil(replacements[replacement]) ? '' : String(replacements[replacement]); 9735 }); 9736 }); 9737 } 9738 9739 return mess; 9740 } 9741 }, { 9742 key: "hasMessage", 9743 value: function hasMessage(messageId) { 9744 return Type.isString(messageId) && !Type.isNil(message[messageId]); 9745 } 9746 /** 9747 * Sets message or messages 9748 * @param {string | Object<string, string>} id 9749 * @param {string} [value] 9750 */ 9751 9752 }, { 9753 key: "setMessage", 9754 value: function setMessage(id, value) { 9755 if (Type.isString(id) && Type.isString(value)) { 9756 message({ 9757 [id]: value 9758 }); 9759 } 9760 9761 if (Type.isObject(id)) { 9762 message(id); 9763 } 9764 } 9765 /** 9766 * Gets plural message by id and number 9767 * @param {string} messageId 9768 * @param {number} value 9769 * @param {object} [replacements] 9770 * @return {?string} 9771 */ 9772 9773 }, { 9774 key: "getMessagePlural", 9775 value: function getMessagePlural(messageId, value, replacements = null) { 9776 let result = ''; 9777 9778 if (Type.isNumber(value)) { 9779 if (this.hasMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`)) { 9780 result = this.getMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`, replacements); 9781 } else { 9782 result = this.getMessage(`${messageId}_PLURAL_1`, replacements); 9783 } 9784 } else { 9785 result = this.getMessage(messageId, replacements); 9786 } 9787 9788 return result; 9789 } 9790 /** 9791 * Gets language plural form id by number 9792 * see http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html 9793 * @param {number} value 9794 * @param {string} [languageId] 9795 * @return {?number} 9796 */ 9797 9798 }, { 9799 key: "getPluralForm", 9800 value: function getPluralForm(value, languageId) { 9801 let pluralForm; 9802 9803 if (!Type.isStringFilled(languageId)) { 9804 languageId = message('LANGUAGE_ID'); 9805 } 9806 9807 if (value < 0) { 9808 value = -1 * value; 9809 } 9810 9811 switch (languageId) { 9812 case 'ar': 9813 pluralForm = value !== 1 ? 1 : 0; 9814 /* 9815 if (value === 0) 9816 { 9817 pluralForm = 0; 9818 } 9819 else if (value === 1) 9820 { 9821 pluralForm = 1; 9822 } 9823 else if (value === 2) 9824 { 9825 pluralForm = 2; 9826 } 9827 else if ( 9828 value % 100 >= 3 9829 && value % 100 <= 10 9830 ) 9831 { 9832 pluralForm = 3; 9833 } 9834 else if (value % 100 >= 11) 9835 { 9836 pluralForm = 4; 9837 } 9838 else 9839 { 9840 pluralForm = 5; 9841 } 9842 */ 9843 9844 break; 9845 9846 case 'br': 9847 case 'fr': 9848 case 'tr': 9849 pluralForm = value > 1 ? 1 : 0; 9850 break; 9851 9852 case 'de': 9853 case 'en': 9854 case 'hi': 9855 case 'it': 9856 case 'la': 9857 pluralForm = value !== 1 ? 1 : 0; 9858 break; 9859 9860 case 'ru': 9861 case 'ua': 9862 if (value % 10 === 1 && value % 100 !== 11) { 9863 pluralForm = 0; 9864 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9865 pluralForm = 1; 9866 } else { 9867 pluralForm = 2; 9868 } 9869 9870 break; 9871 9872 case 'pl': 9873 if (value === 1) { 9874 pluralForm = 0; 9875 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9876 pluralForm = 1; 9877 } else { 9878 pluralForm = 2; 9879 } 9880 9881 break; 9882 9883 case 'id': 9884 case 'ja': 9885 case 'ms': 9886 case 'sc': 9887 case 'tc': 9888 case 'th': 9889 case 'vn': 9890 pluralForm = 0; 9891 break; 9892 9893 default: 9894 pluralForm = 1; 9895 break; 9896 } 9897 9898 return pluralForm; 9899 } 9900 }]); 9901 return Loc; 9902 }(); 9903 9904 const voidElements = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr']; 9905 function isVoidElement(element) { 9906 return voidElements.includes(element); 9907 } 9908 9909 const matchers = { 9910 tag: /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>|{{uid[0-9]+}}/g, 9911 comment: /<!--(?!<!)[^\[>].*?-->/g, 9912 tagName: /<\/?([^\s]+?)[/\s>]/, 9913 attributes: /\s([\w\-_:.]+)\s?\n?=\s?\n?"([^"]+)?"|\s([\w\-_:.]+)\s?\n?=\s?\n?'([^']+)?'|\s([\w\-_:.]+)/gs, 9914 placeholder: /{{uid[0-9]+}}/g 9915 }; 9916 9917 function parseTag(tag) { 9918 const tagResult = { 9919 type: 'tag', 9920 name: '', 9921 svg: false, 9922 attrs: {}, 9923 children: [], 9924 voidElement: false 9925 }; 9926 9927 if (tag.startsWith('<!--')) { 9928 const endIndex = tag.indexOf('-->'); 9929 const openTagLength = '<!--'.length; 9930 return { 9931 type: 'comment', 9932 content: endIndex !== -1 ? tag.slice(openTagLength, endIndex) : '' 9933 }; 9934 } 9935
9936 const tagNameMatch = tag.match(matchers.tagName); 9937 9938 if (Type.isArrayFilled(tagNameMatch)) { 9939 const [, tagName] = tagNameMatch; 9940 tagResult.name = tagName; 9941 tagResult.svg = tagName === 'svg'; 9942 tagResult.voidElement = isVoidElement(tagName) || tag.trim().endsWith('/>'); 9943 } 9944 9945 const reg = new RegExp(matchers.attributes); 9946 9947 for (;;) { 9948 const result = reg.exec(tag); 9949 9950 if (!Type.isNil(result)) { 9951 // Attributes with double quotes 9952 const [, attrName, attrValue] = result; 9953 9954 if (!Type.isNil(attrName)) { 9955 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9956 } else { 9957 // Attributes with single quotes 9958 const [,,, attrName, attrValue] = result; 9959 9960 if (!Type.isNil(attrName)) { 9961 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9962 } else { 9963 // Attributes without value 9964 const [,,,,, attrName] = result; 9965 tagResult.attrs[attrName] = ''; 9966 } 9967 } 9968 } else { 9969 break; 9970 } 9971 } 9972 9973 return tagResult; 9974 } 9975 9976 function parseText(input) { 9977 const preparedText = input.replace(/[\n\r\t]$/, ''); 9978 const placeholders = preparedText.match(matchers.placeholder); 9979 return preparedText.split(matchers.placeholder).reduce((acc, item, index) => { 9980 if (Type.isStringFilled(item)) { 9981 acc.push(...item.split(/\n/).reduce((textAcc, text) => { 9982 const preparedItemText = text.replace(/[\t\r]/g, ''); 9983 9984 if (Type.isStringFilled(preparedItemText)) { 9985 textAcc.push({ 9986 type: 'text', 9987 content: preparedItemText 9988 }); 9989 } 9990 9991 return textAcc; 9992 }, [])); 9993 } 9994 9995 if (placeholders && placeholders[index]) { 9996 acc.push({ 9997 type: 'placeholder', 9998 uid: parseInt(placeholders[index].replace(/{{uid|}}/, '')) 9999 }); 10000 } 10001 10002 return acc; 10003 }, []); 10004 } 10005 10006 function parse(html, substitutions) { 10007 const result = []; 10008 10009 if (html.indexOf('<') !== 0 && !html.startsWith('{{')) { 10010 const end = html.indexOf('<'); 10011 result.push(...parseText(end === -1 ? html : html.slice(0, end))); 10012 } 10013 10014 const commentsContent = []; 10015 let commentIndex = -1; 10016 html = html.replace(matchers.comment, tag => { 10017 commentIndex += 1; 10018 commentsContent.push(tag.replace(/^<!--|-->$/g, '')); 10019 return `<!--{{cUid${commentIndex}}}-->`; 10020 }); 10021 const arr = []; 10022 let level = -1; 10023 let current; 10024 html.replace(matchers.tag, (tag, index) => { 10025 const start = index + tag.length; 10026 const nextChar = html.charAt(start); 10027 let parent; 10028 10029 if (tag.startsWith('<!--')) { 10030 const comment = parseTag(tag, substitutions); 10031 comment.content = commentsContent[tag.replace(/<!--{{cUid|}}-->/g, '')]; 10032 10033 if (level < 0) { 10034 result.push(comment); 10035 return result; 10036 } 10037 10038 parent = arr[level]; 10039 parent.children.push(comment); 10040 return result; 10041 } 10042 10043 if (tag.startsWith('{{')) { 10044 const [placeholder] = parseText(tag); 10045 10046 if (level < 0) { 10047 result.push(placeholder); 10048 return result; 10049 } 10050 10051 parent = arr[level]; 10052 parent.children.push(placeholder); 10053 return result; 10054 } 10055 10056 if (!tag.startsWith('</')) { 10057 level++; 10058 current = parseTag(tag, substitutions); 10059 10060 if (!current.voidElement && nextChar && nextChar !== '<') { 10061 current.children.push(...parseText(html.slice(start, html.indexOf('<', start)))); 10062 } 10063 10064 if (level === 0) { 10065 result.push(current); 10066 } 10067 10068 parent = arr[level - 1]; 10069 10070 if (parent) { 10071 if (!current.svg) { 10072 current.svg = parent.svg; 10073 } 10074 10075 parent.children.push(current); 10076 } 10077 10078 arr[level] = current; 10079 } 10080 10081 if (tag.startsWith('</') || current.voidElement) { 10082 if (level > -1 && (current.voidElement || current.name === tag.slice(2, -1))) { 10083 level--; 10084 current = level === -1 ? result : arr[level]; 10085 } 10086 10087 if (nextChar && nextChar !== '<') { 10088 parent = level === -1 ? result : arr[level].children; 10089 const end = html.indexOf('<', start); 10090 const content = html.slice(start, end === -1 ? undefined : end); 10091 10092 if (end >
10092 -1 && level + parent.length >= 0 || content !== ' ') { 10093 parent.push(...parseText(content)); 10094 } 10095 } 10096 } 10097 }); 10098 return result; 10099 } 10100 10101 const appendElement = (current, target) => { 10102 if (Type.isDomNode(current) && Type.isDomNode(target)) { 10103 if (target.nodeName !== 'TEMPLATE') { 10104 Dom.append(current, target); 10105 } else { 10106 // eslint-disable-next-line bitrix-rules/no-native-dom-methods 10107 target.content.append(current); 10108 } 10109 } 10110 }; 10111 10112 function renderNode(options) { 10113 const { 10114 node, 10115 parentElement, 10116 substitutions 10117 } = options; 10118 10119 if (node.type === 'tag') { 10120 const element = (() => { 10121 if (node.svg) { 10122 return document.createElementNS('http://www.w3.org/2000/svg', node.name); 10123 } 10124 10125 return document.createElement(node.name); 10126 })(); 10127 10128 Object.entries(node.attrs).forEach(([key, value]) => { 10129 if (key.startsWith('on') && new RegExp(matchers.placeholder).test(value)) { 10130 const substitution = substitutions[parseInt(value.replace(/{{uid|}}/, '')) - 1]; 10131 10132 if (Type.isFunction(substitution)) { 10133 const bindFunctionName = key.endsWith('once') ? 'bindOnce' : 'bind'; 10134 Event[bindFunctionName](element, key.replace(/^on|once$/g, ''), substitution); 10135 } else { 10136 element.setAttribute(key, substitution); 10137 } 10138 } else { 10139 if (new RegExp(matchers.placeholder).test(value)) { 10140 const preparedValue = value.split(/{{|}}/).reduce((acc, item) => { 10141 if (item.startsWith('uid')) { 10142 const substitution = substitutions[parseInt(item.replace('uid', '')) - 1]; 10143 return `${acc}${substitution}`; 10144 } 10145 10146 return `${acc}${item}`; 10147 }, ''); 10148 element.setAttribute(key, preparedValue); 10149 } else { 10150 element.setAttribute(key, Text.decode(value)); 10151 } 10152 } 10153 }); 10154 node.children.forEach(childNode => { 10155 const result = renderNode({ 10156 node: childNode, 10157 parentElement: element, 10158 substitutions 10159 }); 10160 10161 if (Type.isArray(result)) { 10162 result.forEach(subChildElement => { 10163 appendElement(subChildElement, element); 10164 }); 10165 } else { 10166 appendElement(result, element); 10167 } 10168 }); 10169 return element; 10170 } 10171 10172 if (node.type === 'comment') { 10173 return document.createComment(node.content); 10174 } 10175 10176 if (node.type === 'text') { 10177 if (parentElement) { 10178 if (parentElement.nodeName !== 'TEMPLATE') { 10179 parentElement.insertAdjacentHTML('beforeend', node.content); 10180 } else { 10181 parentElement.content.append(node.content); 10182 } 10183 10184 return; 10185 } 10186 10187 return document.createTextNode(node.content); 10188 } 10189 10190 if (node.type === 'placeholder') { 10191 return substitutions[node.uid - 1]; 10192 } 10193 } 10194 10195 function render(sections, ...substitutions) { 10196 const html = sections.reduce((acc, item, index) => { 10197 if (index > 0) { 10198 const substitution = substitutions[index - 1]; 10199 10200 if (Type.isString(substitution) || Type.isNumber(substitution)) { 10201 return `${acc}${substitution}${item}`; 10202 } 10203 10204 return `${acc}{{uid${index}}}${item}`; 10205 } 10206 10207 return acc; 10208 }, sections[0]).replace(/^[\r\n\t\s]+/gm, '').replace(/>[\n]+/g, '>').replace(/[}][\n]+/g, '}'); 10209 const ast = parse(html); 10210 10211 if (ast.length === 1) { 10212 return renderNode({ 10213 node: ast[0], 10214 substitutions 10215 }); 10216 } 10217 10218 if (ast.length > 1) { 10219 return ast.map(node => { 10220 return renderNode({ 10221 node, 10222 substitutions 10223 }); 10224 }); 10225 } 10226 10227 return false; 10228 } 10229 10230 function parseProps(sections, ...substitutions) { 10231 return substitutions.reduce((acc, item, index) => { 10232 const nextSectionIndex = index + 1; 10233 10234 if (!Type.isPlainObject(item) && !Type.isArray(item)) { 10235 return acc + item + sections[nextSectionIndex]; 10236 } 10237 10238 return `${acc}__s${index}${sections[nextSectionIndex]}`; 10239 }, sections[0]).replace(/[\r\t]/gm, '').split(';\n').map(item => item.replace(/\n/, '')).reduce((acc, item) => { 10240 if (item !== '') { 10241 const matches = item.match(/^[\w-. ]+:/); 10242 const splitted = item.split(/^[\w-. ]+:/);
10243 const key = matches[0].replace(':', '').trim(); 10244 const value = splitted[1].trim(); 10245 const substitutionPlaceholderExp = /^__s\d+/; 10246 10247 if (substitutionPlaceholderExp.test(value)) { 10248 acc[key] = substitutions[value.replace('__s', '')]; 10249 return acc; 10250 } 10251 10252 acc[key] = value; 10253 } 10254 10255 return acc; 10256 }, {}); 10257 } 10258 /** 10259 * @memberOf BX 10260 */ 10261 10262 10263 let Tag = /*#__PURE__*/function () { 10264 function Tag() { 10265 babelHelpers.classCallCheck(this, Tag); 10266 } 10267 10268 babelHelpers.createClass(Tag, null, [{ 10269 key: "safe", 10270 10271 /** 10272 * Encodes all substitutions 10273 * @param sections 10274 * @param substitutions 10275 * @return {string} 10276 */ 10277 value: function safe(sections, ...substitutions) { 10278 return substitutions.reduce((acc, item, index) => acc + Text.encode(item) + sections[index + 1], sections[0]); 10279 } 10280 /** 10281 * Decodes all substitutions 10282 * @param sections 10283 * @param substitutions 10284 * @return {string} 10285 */ 10286 10287 }, { 10288 key: "unsafe", 10289 value: function unsafe(sections, ...substitutions) { 10290 return substitutions.reduce((acc, item, index) => acc + Text.decode(item) + sections[index + 1], sections[0]); 10291 } 10292 /** 10293 * Adds styles to specified element 10294 * @param {HTMLElement} element 10295 * @return {Function} 10296 */ 10297 10298 }, { 10299 key: "style", 10300 value: function style(element) { 10301 if (!Type.isDomNode(element)) { 10302 throw new Error('element is not HTMLElement'); 10303 } 10304 10305 return function styleTagHandler(...args) { 10306 Dom.style(element, parseProps(...args)); 10307 }; 10308 } 10309 /** 10310 * Replace all messages identifiers to real messages 10311 * @param sections 10312 * @param substitutions 10313 * @return {string} 10314 */ 10315 10316 }, { 10317 key: "message", 10318 value: function message(sections, ...substitutions) { 10319 return substitutions.reduce((acc, item, index) => acc + Loc.getMessage(item) + sections[index + 1], sections[0]); 10320 } 10321 }, { 10322 key: "attrs", 10323 10324 /** 10325 * Adds attributes to specified element 10326 * @param element 10327 * @return {Function} 10328 */ 10329 value: function attrs(element) { 10330 if (!Type.isDomNode(element)) { 10331 throw new Error('element is not HTMLElement'); 10332 } 10333 10334 return function attrsTagHandler(...args) { 10335 Dom.attr(element, parseProps(...args)); 10336 }; 10337 } 10338 }]); 10339 return Tag; 10340 }(); 10341 10342 babelHelpers.defineProperty(Tag, "render", render); 10343 babelHelpers.defineProperty(Tag, "attr", Tag.attrs); 10344 10345 function getParser(format) { 10346 switch (format) { 10347 case 'index': 10348 return (sourceKey, value, accumulator) => { 10349 const result = /\[(\w*)\]$/.exec(sourceKey); 10350 const key = sourceKey.replace(/\[\w*\]$/, ''); 10351 10352 if (Type.isNil(result)) { 10353 accumulator[key] = value; 10354 return; 10355 } 10356 10357 if (Type.isUndefined(accumulator[key])) { 10358 accumulator[key] = {}; 10359 } 10360 10361 accumulator[key][result[1]] = value; 10362 }; 10363 10364 case 'bracket': 10365 return (sourceKey, value, accumulator) => { 10366 const result = /(\[\])$/.exec(sourceKey); 10367 const key = sourceKey.replace(/\[\]$/, ''); 10368 10369 if (Type.isNil(result)) { 10370 accumulator[key] = value; 10371 return; 10372 } 10373 10374 if (Type.isUndefined(accumulator[key])) { 10375 accumulator[key] = [value]; 10376 return; 10377 } 10378 10379 accumulator[key] = [].concat(accumulator[key], value); 10380 }; 10381 10382 default: 10383 return (sourceKey, value, accumulator) => { 10384 const key = sourceKey.replace(/\[\]$/, ''); 10385 accumulator[key] = value; 10386 }; 10387 } 10388 } 10389 10390 function getKeyFormat(key) { 10391 if (/^\w+\[([\w]+)\]$/.test(key)) { 10392 return 'index'; 10393 } 10394 10395 if (/^\w+\[\]$/.test(key)) { 10396 return 'bracket'; 10397 } 10398 10399 return 'default'; 10400 } 10401 10402 function parseQuery(input) { 10403 if (!Type.isString(input)) { 10404 return {}; 10405 } 10406 10407 const url = input.trim().replace(/^[?#&]/, ''); 10408 10409 if (!url) { 10410 return {}; 10411 } 10412 10413 return url.split('&').reduce((acc, param) => { 10414 const [key, value] = param.replace(/\+/g, ' ').split('=');
10415 const keyFormat = getKeyFormat(key); 10416 const formatter = getParser(keyFormat); 10417 formatter(key, value, acc); 10418 return acc; 10419 }, {}); 10420 } 10421 10422 const urlExp = /^((\w+):)?(\/\/((\w+)?(:(\w+))?@)?([^\/\?:]+)(:(\d+))?)?(\/?([^\/\?#][^\?#]*)?)?(\?([^#]+))?(#(\w*))?/; 10423 function parseUrl(url) { 10424 const result = url.match(urlExp); 10425 10426 if (Type.isArray(result)) { 10427 const queryParams = parseQuery(result[14]); 10428 return { 10429 useShort: /^\/\//.test(url), 10430 href: result[0] || '', 10431 schema: result[2] || '', 10432 host: result[8] || '', 10433 port: result[10] || '', 10434 path: result[11] || '', 10435 query: result[14] || '', 10436 queryParams, 10437 hash: result[16] || '', 10438 username: result[5] || '', 10439 password: result[7] || '', 10440 origin: result[8] || '' 10441 }; 10442 } 10443 10444 return {}; 10445 } 10446 10447 function buildQueryString(params = {}) { 10448 const queryString = Object.keys(params).reduce((acc, key) => { 10449 if (Type.isArray(params[key])) { 10450 params[key].forEach(paramValue => { 10451 acc.push(`${key}[]=${paramValue}`); 10452 }, ''); 10453 } 10454 10455 if (Type.isPlainObject(params[key])) { 10456 Object.keys(params[key]).forEach(paramIndex => { 10457 acc.push(`${key}[${paramIndex}]=${params[key][paramIndex]}`); 10458 }, ''); 10459 } 10460 10461 if (!Type.isObject(params[key]) && !Type.isArray(params[key])) { 10462 acc.push(`${key}=${params[key]}`); 10463 } 10464 10465 return acc; 10466 }, []).join('&'); 10467 10468 if (queryString.length > 0) { 10469 return `?${queryString}`; 10470 } 10471 10472 return queryString; 10473 } 10474 10475 function prepareParamValue(value) { 10476 if (Type.isArray(value)) { 10477 return value.map(item => String(item)); 10478 } 10479 10480 if (Type.isPlainObject(value)) { 10481 return { ...value 10482 }; 10483 } 10484 10485 return String(value); 10486 } 10487 10488 const map = new WeakMap(); 10489 /** 10490 * Implements interface for works with URI 10491 * @memberOf BX 10492 */ 10493 10494 let Uri = /*#__PURE__*/function () { 10495 babelHelpers.createClass(Uri, null, [{ 10496 key: "addParam", 10497 value: function addParam(url, params = {}) { 10498 return new Uri(url).setQueryParams(params).toString(); 10499 } 10500 }, { 10501 key: "removeParam", 10502 value: function removeParam(url, params) { 10503 const removableParams = Type.isArray(params) ? params : [params]; 10504 return new Uri(url).removeQueryParam(...removableParams).toString(); 10505 } 10506 }]); 10507 10508 function Uri(url = '') { 10509 babelHelpers.classCallCheck(this, Uri); 10510 map.set(this, parseUrl(url)); 10511 } 10512 /** 10513 * Gets schema 10514 * @return {?string} 10515 */ 10516 10517 10518 babelHelpers.createClass(Uri, [{ 10519 key: "getSchema", 10520 value: function getSchema() { 10521 return map.get(this).schema; 10522 } 10523 /** 10524 * Sets schema 10525 * @param {string} schema 10526 * @return {Uri} 10527 */ 10528 10529 }, { 10530 key: "setSchema", 10531 value: function setSchema(schema) { 10532 map.get(this).schema = String(schema); 10533 return this; 10534 } 10535 /** 10536 * Gets host 10537 * @return {?string} 10538 */ 10539 10540 }, { 10541 key: "getHost", 10542 value: function getHost() { 10543 return map.get(this).host; 10544 } 10545 /** 10546 * Sets host 10547 * @param {string} host 10548 * @return {Uri} 10549 */ 10550 10551 }, { 10552 key: "setHost", 10553 value: function setHost(host) { 10554 map.get(this).host = String(host); 10555 return this; 10556 } 10557 /** 10558 * Gets port 10559 * @return {?string} 10560 */ 10561 10562 }, { 10563 key: "getPort", 10564 value: function getPort() { 10565 return map.get(this).port; 10566 } 10567 /** 10568 * Sets port 10569 * @param {String | Number} port 10570 * @return {Uri} 10571 */ 10572 10573 }, { 10574 key: "setPort", 10575 value: function setPort(port) { 10576 map.get(this).port = String(port); 10577 return this; 10578 } 10579 /** 10580 * Gets path 10581 * @return {?string} 10582 */ 10583 10584 }, { 10585 key: "getPath", 10586 value: function getPath() { 10587 return map.get(this).path; 10588 } 10589 /** 10590 * Sets path 10591 * @param {string} path 10592 * @return {Uri} 10593 */ 10594 10595 }, { 10596 key: "setPath", 10597 value: function setPath(path) { 10598 if (!/^\//.test(path)) { 10599 map.get(this).path = `/${String(path)}`; 10600 return this; 10601 } 10602 10603 map.get(this).path = String(path); 10604 return this; 10605 } 10606 /** 10607 * Gets query 10608 * @return {?string} 10609 */ 10610 10611 }, { 10612 key: "getQuery", 10613 value: function getQuery() { 10614 return buildQueryString(map.get(this).queryParams); 10615 } 10616 /** 10617 * Gets query param value by name 10618 * @param {string} key 10619 * @return {?string} 10620 */ 10621 10622 }, { 10623 key: "getQueryParam", 10624 value: function getQueryParam(key) { 10625 const params = this.getQueryParams(); 10626 10627 if (key in params) { 10628 return params[key]; 10629 } 10630 10631 return null; 10632 } 10633 /** 10634 * Sets query param 10635 * @param {string} key 10636 * @param [value] 10637 * @return {Uri} 10638 */ 10639 10640 }, { 10641 key: "setQueryParam", 10642 value: function setQueryParam(key, value = '') { 10643 map.get(this).queryParams[key] = prepareParamValue(value); 10644 return this; 10645 } 10646 /** 10647 * Gets query params 10648 * @return {Object<string, any>} 10649 */ 10650 10651 }, { 10652 key: "getQueryParams", 10653 value: function getQueryParams() { 10654 return { ...map.get(this).queryParams 10655 }; 10656 } 10657 /** 10658 * Sets query params 10659 * @param {Object<string, any>} params 10660 * @return {Uri} 10661 */ 10662 10663 }, { 10664 key: "setQueryParams", 10665 value: function setQueryParams(params = {}) {
10666 const currentParams = this.getQueryParams(); 10667 const newParams = { ...currentParams, 10668 ...params 10669 }; 10670 Object.keys(newParams).forEach(key => { 10671 newParams[key] = prepareParamValue(newParams[key]); 10672 }); 10673 map.get(this).queryParams = newParams; 10674 return this; 10675 } 10676 /** 10677 * Removes query params by name 10678 * @param keys 10679 * @return {Uri} 10680 */ 10681 10682 }, { 10683 key: "removeQueryParam", 10684 value: function removeQueryParam(...keys) { 10685 const currentParams = { ...map.get(this).queryParams 10686 }; 10687 keys.forEach(key => { 10688 if (key in currentParams) { 10689 delete currentParams[key]; 10690 } 10691 }); 10692 map.get(this).queryParams = currentParams; 10693 return this; 10694 } 10695 /** 10696 * Gets fragment 10697 * @return {?string} 10698 */ 10699 10700 }, { 10701 key: "getFragment", 10702 value: function getFragment() { 10703 return map.get(this).hash; 10704 } 10705 /** 10706 * Sets fragment 10707 * @param {string} hash 10708 * @return {Uri} 10709 */ 10710 10711 }, { 10712 key: "setFragment", 10713 value: function setFragment(hash) { 10714 map.get(this).hash = String(hash); 10715 return this; 10716 } 10717 /** 10718 * Serializes URI 10719 * @return {Object} 10720 */ 10721 10722 }, { 10723 key: "serialize", 10724 value: function serialize() { 10725 const serialized = { ...map.get(this) 10726 }; 10727 serialized.href = this.toString(); 10728 return serialized; 10729 } 10730 /** 10731 * Gets URI string 10732 * @return {string} 10733 */ 10734 10735 }, { 10736 key: "toString", 10737 value: function toString() { 10738 const data = { ...map.get(this) 10739 }; 10740 let protocol = data.schema ? `${data.schema}://` : ''; 10741 10742 if (data.useShort) { 10743 protocol = '//'; 10744 } 10745 10746 const port = (() => { 10747 if (Type.isString(data.port) && !['', '80'].includes(data.port)) { 10748 return `:${data.port}`; 10749 } 10750 10751 return ''; 10752 })(); 10753 10754 const host = this.getHost(); 10755 const path = this.getPath(); 10756 const query = buildQueryString(data.queryParams); 10757 const hash = data.hash ? `#${data.hash}` : ''; 10758 return `${host ? protocol : ''}${host}${host ? port : ''}${path}${query}${hash}`; 10759 } 10760 }]); 10761 return Uri; 10762 }(); 10763 10764 /** 10765 * @memberOf BX 10766 */ 10767 let Validation = /*#__PURE__*/function () { 10768 function Validation() { 10769 babelHelpers.classCallCheck(this, Validation); 10770 } 10771 10772 babelHelpers.createClass(Validation, null, [{ 10773 key: "isEmail", 10774 10775 /** 10776 * Checks that value is valid email 10777 * @param value 10778 * @return {boolean} 10779 */ 10780 value: function isEmail(value) { 10781 const exp = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/; 10782 return exp.test(String(value).toLowerCase()); 10783 } 10784 }]); 10785 return Validation; 10786 }(); 10787 10788 let BaseCache = /*#__PURE__*/function () { 10789 function BaseCache() { 10790 babelHelpers.classCallCheck(this, BaseCache); 10791 babelHelpers.defineProperty(this, "storage", new Map()); 10792 } 10793 10794 babelHelpers.createClass(BaseCache, [{ 10795 key: "get", 10796 10797 /** 10798 * Gets cached value or default value 10799 */ 10800 value: function get(key, defaultValue) { 10801 if (!this.storage.has(key)) { 10802 if (Type.isFunction(defaultValue)) { 10803 return defaultValue(); 10804 } 10805 10806 if (!Type.isUndefined(defaultValue)) { 10807 return defaultValue; 10808 } 10809 } 10810 10811 return this.storage.get(key); 10812 } 10813 /** 10814 * Sets cache entry 10815 */ 10816 10817 }, { 10818 key: "set", 10819 value: function set(key, value) { 10820 this.storage.set(key, value); 10821 } 10822 /** 10823 * Deletes cache entry 10824 */ 10825 10826 }, { 10827 key: "delete", 10828 value: function _delete(key) { 10829 this.storage.delete(key); 10830 } 10831 /** 10832 * Checks that storage contains entry with specified key 10833 */ 10834 10835 }, { 10836 key: "has", 10837 value: function has(key) { 10838 return this.storage.has(key); 10839 } 10840 /** 10841 * Gets cached value if exists, 10842 */ 10843 10844 }, { 10845 key: "remember", 10846 value: function remember(key, defaultValue) { 10847 if (!this.storage.has(key)) { 10848 if (Type.isFunction(defaultValue)) { 10849 this.storage.set(key, defaultValue()); 10850 } else if (!Type.isUndefined(defaultValue)) { 10851 this.storage.set(key, defaultValue); 10852 } 10853 } 10854 10855 return this.storage.get(key); 10856 } 10857 /** 10858 * Gets storage size 10859 */ 10860 10861 }, { 10862 key: "size", 10863 value: function size() { 10864 return this.storage.size; 10865 } 10866 /** 10867 * Gets storage keys 10868 */ 10869 10870 }, { 10871 key: "keys", 10872 value: function keys() { 10873 return [...this.storage.keys()]; 10874 } 10875 /** 10876 * Gets storage values 10877 */ 10878 10879 }, { 10880 key: "values", 10881 value: function values() { 10882 return [...this.storage.values()]; 10883 } 10884 }]); 10885 return BaseCache; 10886 }(); 10887 10888 let MemoryCache = /*#__PURE__*/function (_BaseCache) { 10889 babelHelpers.inherits(MemoryCache, _BaseCache); 10890 10891 function MemoryCache(...args) { 10892 var _this; 10893 10894 babelHelpers.classCallCheck(this, MemoryCache); 10895 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(MemoryCache).call(this, ...args)); 10896 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new Map()); 10897 return _this; 10898 } 10899 10900 return MemoryCache; 10901 }(BaseCache); 10902 10903 let LsStorage = /*#__PURE__*/function () { 10904 function LsStorage() { 10905 babelHelpers.classCallCheck(this, LsStorage); 10906 babelHelpers.defineProperty(this, "stackKey", 'BX.Cache.Storage.LsStorage.stack'); 10907 babelHelpers.defineProperty(this, "stack", null); 10908 } 10909 10910 babelHelpers.createClass(LsStorage, [{ 10911 key: "getStack", 10912 10913 /** 10914 * @private 10915 */ 10916 value: function getStack() { 10917 if (Type.isPlainObject(this.stack)) { 10918 return this.stack; 10919 } 10920 10921 const stack = localStorage.getItem(this.stackKey); 10922 10923 if (Type.isString(stack) && stack !== '') { 10924 const parsedStack = JSON.parse(stack); 10925 10926 if (Type.isPlainObject(parsedStack)) { 10927 this.stack = parsedStack; 10928 return this.stack; 10929 } 10930 } 10931 10932 this.stack = {}; 10933 return this.stack; 10934 } 10935 /** 10936 * @private 10937 */ 10938 10939 }, { 10940 key: "saveStack", 10941 value: function saveStack() { 10942 if (Type.isPlainObject(this.stack)) { 10943 const preparedStack = JSON.stringify(this.stack); 10944 localStorage.setItem(this.stackKey, preparedStack); 10945 } 10946 } 10947 }, { 10948 key: "get", 10949 value: function get(key) {
10950 const stack = this.getStack(); 10951 return stack[key]; 10952 } 10953 }, { 10954 key: "set", 10955 value: function set(key, value) { 10956 const stack = this.getStack(); 10957 stack[key] = value; 10958 this.saveStack(); 10959 } 10960 }, { 10961 key: "delete", 10962 value: function _delete(key) { 10963 const stack = this.getStack(); 10964 10965 if (key in stack) { 10966 delete stack[key]; 10967 } 10968 } 10969 }, { 10970 key: "has", 10971 value: function has(key) { 10972 const stack = this.getStack(); 10973 return key in stack; 10974 } 10975 }, { 10976 key: "keys", 10977 value: function keys() { 10978 const stack = this.getStack(); 10979 return Object.keys(stack); 10980 } 10981 }, { 10982 key: "values", 10983 value: function values() { 10984 const stack = this.getStack(); 10985 return Object.values(stack); 10986 } 10987 }, { 10988 key: "size", 10989 get: function () { 10990 const stack = this.getStack(); 10991 return Object.keys(stack).length; 10992 } 10993 }]); 10994 return LsStorage; 10995 }(); 10996 10997 let LocalStorageCache = /*#__PURE__*/function (_BaseCache) { 10998 babelHelpers.inherits(LocalStorageCache, _BaseCache); 10999 11000 function LocalStorageCache(...args) { 11001 var _this; 11002 11003 babelHelpers.classCallCheck(this, LocalStorageCache); 11004 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(LocalStorageCache).call(this, ...args)); 11005 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new LsStorage()); 11006 return _this; 11007 } 11008 11009 return LocalStorageCache; 11010 }(BaseCache); 11011 11012 /** 11013 * @memberOf BX 11014 */ 11015 11016 let Cache = function Cache() { 11017 babelHelpers.classCallCheck(this, Cache); 11018 }; 11019 11020 babelHelpers.defineProperty(Cache, "MemoryCache", MemoryCache); 11021 babelHelpers.defineProperty(Cache, "LocalStorageCache", LocalStorageCache); 11022 11023 function convertPath(path) { 11024 if (Type.isStringFilled(path)) { 11025 return path.split('.').reduce((acc, item) => { 11026 item.split(/\[['"]?(.+?)['"]?\]/g).forEach(key => { 11027 if (Type.isStringFilled(key)) { 11028 acc.push(key); 11029 } 11030 }); 11031 return acc; 11032 }, []); 11033 } 11034 11035 return []; 11036 } 11037 11038 let SettingsCollection = /*#__PURE__*/function () { 11039 function SettingsCollection(options = {}) { 11040 babelHelpers.classCallCheck(this, SettingsCollection); 11041 11042 if (Type.isPlainObject(options)) { 11043 Object.assign(this, options); 11044 } 11045 } 11046 11047 babelHelpers.createClass(SettingsCollection, [{ 11048 key: "get", 11049 value: function get(path, defaultValue = null) { 11050 const convertedPath = convertPath(path); 11051 return convertedPath.reduce((acc, key) => { 11052 if (!Type.isNil(acc) && acc !== defaultValue) { 11053 if (!Type.isUndefined(acc[key])) { 11054 return acc[key]; 11055 } 11056 11057 return defaultValue; 11058 } 11059 11060 return acc; 11061 }, this); 11062 } 11063 }]); 11064 return SettingsCollection; 11065 }(); 11066 11067 function deepFreeze(target) { 11068 if (Type.isObject(target)) { 11069 Object.values(target).forEach(value => { 11070 deepFreeze(value); 11071 }); 11072 return Object.freeze(target); 11073 } 11074 11075 return target; 11076 } 11077 11078 const settingsStorage = new Map(); 11079 11080 let Extension$1 = /*#__PURE__*/function () { 11081 function Extension() { 11082 babelHelpers.classCallCheck(this, Extension); 11083 } 11084 11085 babelHelpers.createClass(Extension, null, [{ 11086 key: "getSettings", 11087 value: function getSettings(extensionName) { 11088 if (Type.isStringFilled(extensionName)) { 11089 if (settingsStorage.has(extensionName)) { 11090 return settingsStorage.get(extensionName); 11091 } 11092 11093 const settingsScriptNode = document.querySelector(`script[data-extension="${extensionName}"]`); 11094 11095 if (Type.isDomNode(settingsScriptNode)) { 11096 const decodedSettings = (() => { 11097 try { 11098 return new SettingsCollection(JSON.parse(settingsScriptNode.innerHTML)); 11099 } catch (error) { 11100 return new SettingsCollection(); 11101 } 11102 })(); 11103 11104 const frozenSettings = deepFreeze(decodedSettings); 11105 settingsStorage.set(extensionName, frozenSettings); 11106 return frozenSettings; 11107 } 11108 } 11109 11110 return deepFreeze(new SettingsCollection()); 11111 } 11112 }]); 11113 return Extension; 11114 }(); 11115 11116 let _Symbol$iterator; 11117 11118 function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); } 11119 11120 function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 11121 11122 function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 11123 11124 var _searchIndexToInsert = /*#__PURE__*/new WeakSet(); 11125 11126 _Symbol$iterator = Symbol.iterator; 11127 11128 let OrderedArray = /*#__PURE__*/function () { 11129 function OrderedArray(comparator = null) { 11130 babelHelpers.classCallCheck(this, OrderedArray); 11131 11132 _classPrivateMethodInitSpec(this, _searchIndexToInsert); 11133 11134 babelHelpers.defineProperty(this, "comparator", null); 11135 babelHelpers.defineProperty(this, "items", []); 11136 this.comparator = Type.isFunction(comparator) ? comparator : null; 11137 } 11138 11139 babelHelpers.createClass(OrderedArray, [{ 11140 key: "add", 11141 value: function add(item) { 11142 let index = -1; 11143 11144 if (this.comparator) { 11145 index = _classPrivateMethodGet(this, _searchIndexToInsert, _searchIndexToInsert2).call(this, item); 11146 this.items.splice(index, 0, item); 11147 } else { 11148 this.items.push(item); 11149 } 11150 11151 return index; 11152 } 11153 }, { 11154 key: "has", 11155 value: function has(item) { 11156 return this.items.includes(item); 11157 } 11158 }, { 11159 key: "getIndex", 11160 value: function getIndex(item) { 11161 return this.items.indexOf(item); 11162 } 11163 }, { 11164 key: "getByIndex", 11165 value: function getByIndex(index) { 11166 if (Type.isNumber(index) && index >= 0) { 11167 const item = this.items[index]; 11168 return Type.isUndefined(item) ? null : item; 11169 } 11170 11171 return null; 11172 } 11173 }, { 11174 key: "getFirst", 11175 value: function getFirst() { 11176 const first = this.items[0]; 11177 return Type.isUndefined(first) ? null : first; 11178 } 11179 }, { 11180 key: "getLast", 11181 value: function getLast() { 11182 const last = this.items[this.count() - 1]; 11183 return Type.isUndefined(last) ? null : last; 11184 } 11185 }, { 11186 key: "count", 11187 value: function count() { 11188 return this.items.length; 11189 } 11190 }, { 11191 key: "delete", 11192 value: function _delete(item) { 11193 const index = this.getIndex(item); 11194 11195 if (index !== -1) { 11196 this.items.splice(index, 1); 11197 return true; 11198 } 11199 11200 return false;
11201 } 11202 }, { 11203 key: "clear", 11204 value: function clear() { 11205 this.items = []; 11206 } 11207 }, { 11208 key: _Symbol$iterator, 11209 value: function () { 11210 return this.items[Symbol.iterator](); 11211 } 11212 }, { 11213 key: "forEach", 11214 value: function forEach(callbackfn, thisArg) { 11215 return this.items.forEach(callbackfn, thisArg); 11216 } 11217 }, { 11218 key: "getAll", 11219 value: function getAll() { 11220 return this.items; 11221 } 11222 }, { 11223 key: "getComparator", 11224 value: function getComparator() { 11225 return this.comparator; 11226 } 11227 }, { 11228 key: "sort", 11229 value: function sort() { 11230 const comparator = this.getComparator(); 11231 11232 if (comparator === null) { 11233 return; 11234 } 11235 /* 11236 Simple implementation 11237 this.items.sort((item1, item2) => { 11238 return comparator(item1, item2); 11239 }); 11240 */ 11241 // For stable sorting https://v8.dev/features/stable-sort 11242 11243 11244 const length = this.items.length; 11245 const indexes = new Array(length); 11246 11247 for (let i = 0; i < length; i++) { 11248 indexes[i] = i; 11249 } // If the comparator returns zero, use the original indexes 11250 11251 11252 indexes.sort((index1, index2) => { 11253 return comparator(this.items[index1], this.items[index2]) || index1 - index2; 11254 }); 11255 11256 for (let i = 0; i < length; i++) { 11257 indexes[i] = this.items[indexes[i]]; 11258 } 11259 11260 for (let i = 0; i < length; i++) { 11261 this.items[i] = indexes[i]; 11262 } 11263 } 11264 }]); 11265 return OrderedArray; 11266 }(); 11267 11268 function _searchIndexToInsert2(value) { 11269 let low = 0; 11270 let high = this.items.length; 11271 11272 while (low < high) { 11273 const mid = Math.floor((low + high) / 2); 11274 11275 if (this.comparator(this.items[mid], value) >= 0) { 11276 high = mid; 11277 } else { 11278 low = mid + 1; 11279 } 11280 } 11281 11282 return low; 11283 } 11284 11285 let ZIndexComponent = /*#__PURE__*/function (_EventEmitter) { 11286 babelHelpers.inherits(ZIndexComponent, _EventEmitter); 11287 11288 function ZIndexComponent(element, componentOptions = {}) { 11289 var _this; 11290 11291 babelHelpers.classCallCheck(this, ZIndexComponent); 11292 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(ZIndexComponent).call(this)); 11293 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "sort", 0); 11294 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "alwaysOnTop", false); 11295 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "zIndex", 0); 11296 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "element", null); 11297 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlay", null); 11298 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlayGap", -5); 11299 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "stack", null); 11300 11301 _this.setEventNamespace('BX.Main.ZIndexManager.Component'); 11302 11303 if (!Type.isElementNode(element)) { 11304 throw new Error('ZIndexManager.Component: The argument \'element\' must be a DOM element.'); 11305 } 11306 11307 _this.element = element; 11308 const options = Type.isPlainObject(componentOptions) ? componentOptions : {}; 11309 11310 _this.setAlwaysOnTop(options.alwaysOnTop); 11311 11312 _this.setOverlay(options.overlay); 11313 11314 _this.setOverlayGap(options.overlayGap); 11315 11316 _this.subscribeFromOptions(options.events); 11317 11318 return _this; 11319 } 11320 11321 babelHelpers.createClass(ZIndexComponent, [{ 11322 key: "getSort", 11323 value: function getSort() { 11324 return this.sort; 11325 } 11326 /** 11327 * @internal 11328 * @param sort 11329 */ 11330 11331 }, { 11332 key: "setSort", 11333 value: function setSort(sort) { 11334 if (Type.isNumber(sort)) { 11335 this.sort = sort; 11336 } 11337 } 11338 /** 11339 * @internal 11340 * @param stack 11341 */ 11342 11343 }, { 11344 key: "setStack", 11345 value: function setStack(stack) { 11346 this.stack = stack; 11347 } 11348 }, { 11349 key: "getStack", 11350 value: function getStack() { 11351 return this.stack; 11352 } 11353 }, { 11354 key: "getZIndex", 11355 value: function getZIndex() { 11356 return this.zIndex; 11357 } 11358 /** 11359 * @internal 11360 */ 11361 11362 }, { 11363 key: "setZIndex", 11364 value: function setZIndex(zIndex) { 11365 const changed = this.getZIndex() !== zIndex; 11366 this.getElement().style.setProperty('z-index', zIndex, 'important'); 11367 this.zIndex = zIndex; 11368 11369 if (this.getOverlay() !== null) { 11370 this.getOverlay().style.setProperty('z-index', zIndex + this.getOverlayGap(), 'important'); 11371 } 11372 11373 if (changed) {
11374 this.emit('onZIndexChange', { 11375 component: this 11376 }); 11377 } 11378 } 11379 }, { 11380 key: "getAlwaysOnTop", 11381 value: function getAlwaysOnTop() { 11382 return this.alwaysOnTop; 11383 } 11384 }, { 11385 key: "setAlwaysOnTop", 11386 value: function setAlwaysOnTop(value) { 11387 if (Type.isNumber(value) || Type.isBoolean(value)) { 11388 this.alwaysOnTop = value; 11389 } 11390 } 11391 }, { 11392 key: "getElement", 11393 value: function getElement() { 11394 return this.element; 11395 } 11396 }, { 11397 key: "setOverlay", 11398 value: function setOverlay(overlay, gap) { 11399 if (Type.isElementNode(overlay) || overlay === null) { 11400 this.overlay = overlay; 11401 this.setOverlayGap(gap); 11402 11403 if (this.getStack()) { 11404 this.getStack().sort(); 11405 } 11406 } 11407 } 11408 }, { 11409 key: "getOverlay", 11410 value: function getOverlay() { 11411 return this.overlay; 11412 } 11413 }, { 11414 key: "setOverlayGap", 11415 value: function setOverlayGap(gap) { 11416 if (Type.isNumber(gap)) { 11417 this.overlayGap = gap; 11418 } 11419 } 11420 }, { 11421 key: "getOverlayGap", 11422 value: function getOverlayGap() { 11423 return this.overlayGap; 11424 } 11425 }]); 11426 return ZIndexComponent; 11427 }(EventEmitter); 11428 11429 let ZIndexStack = /*#__PURE__*/function () { 11430 function ZIndexStack(container) { 11431 babelHelpers.classCallCheck(this, ZIndexStack); 11432 babelHelpers.defineProperty(this, "container", null); 11433 babelHelpers.defineProperty(this, "components", null); 11434 babelHelpers.defineProperty(this, "elements", new WeakMap()); 11435 babelHelpers.defineProperty(this, "baseIndex", 1000); 11436 babelHelpers.defineProperty(this, "baseStep", 50); 11437 babelHelpers.defineProperty(this, "sortCount", 0); 11438 11439 if (!Type.isDomNode(container)) { 11440 throw new Error('ZIndexManager.Stack: The \'container\' argument must be a DOM element.'); 11441 } 11442 11443 this.container = container; 11444 11445 const comparator = (componentA, componentB) => { 11446 let result = (componentA.getAlwaysOnTop() || 0) - (componentB.getAlwaysOnTop() || 0); 11447 11448 if (!result) { 11449 result = componentA.getSort() - componentB.getSort(); 11450 } 11451 11452 return result; 11453 }; 11454 11455 this.components = new OrderedArray(comparator); 11456 } 11457 11458 babelHelpers.createClass(ZIndexStack, [{ 11459 key: "getBaseIndex", 11460 value: function getBaseIndex() { 11461 return this.baseIndex; 11462 } 11463 }, { 11464 key: "setBaseIndex", 11465 value: function setBaseIndex(index) { 11466 if (Type.isNumber(index) && index >= 0) { 11467 this.baseIndex = index; 11468 this.sort(); 11469 } 11470 } 11471 }, { 11472 key: "setBaseStep", 11473 value: function setBaseStep(step) { 11474 if (Type.isNumber(step) && step > 0) { 11475 this.baseStep = step; 11476 this.sort(); 11477 } 11478 } 11479 }, { 11480 key: "getBaseStep", 11481 value: function getBaseStep() { 11482 return this.baseStep; 11483 } 11484 }, { 11485 key: "register", 11486 value: function register(element, options = {}) { 11487 if (this.getComponent(element)) { 11488 console.warn('ZIndexManager: You cannot register the element twice.', element); 11489 return this.getComponent(element); 11490 } 11491 11492 const component = new ZIndexComponent(element, options); 11493 component.setStack(this); 11494 component.setSort(++this.sortCount); 11495 this.elements.set(element, component); 11496 this.components.add(component); 11497 this.sort(); 11498 return component; 11499 } 11500 }, { 11501 key: "unregister", 11502 value: function unregister(element) { 11503 const component = this.elements.get(element); 11504 this.components.delete(component); 11505 this.elements.delete(element); 11506 this.sort(); 11507 } 11508 }, { 11509 key: "getComponent", 11510 value: function getComponent(element) { 11511 return this.elements.get(element) || null; 11512 } 11513 }, { 11514 key: "getComponents", 11515 value: function getComponents() { 11516 return this.components.getAll(); 11517 } 11518 }, { 11519 key: "getMaxZIndex", 11520 value: function getMaxZIndex() { 11521 const last = this.components.getLast(); 11522 return last ? last.getZIndex() : this.baseIndex; 11523 } 11524 }, { 11525 key: "sort", 11526 value: function sort() { 11527 this.components.sort(); 11528 let zIndex = this.baseIndex;
11529 this.components.forEach(component => { 11530 component.setZIndex(zIndex); 11531 zIndex += this.baseStep; 11532 }); 11533 } 11534 }, { 11535 key: "bringToFront", 11536 value: function bringToFront(element) { 11537 const component = this.getComponent(element); 11538 11539 if (!component) { 11540 console.error('ZIndexManager: element was not found in the stack.', element); 11541 return null; 11542 } 11543 11544 component.setSort(++this.sortCount); 11545 this.sort(); 11546 return component; 11547 } 11548 }]); 11549 return ZIndexStack; 11550 }(); 11551 11552 function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; } 11553 11554 function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } } 11555 11556 /** 11557 * @memberof BX 11558 */ 11559 let ZIndexManager = /*#__PURE__*/function () { 11560 function ZIndexManager() { 11561 babelHelpers.classCallCheck(this, ZIndexManager); 11562 } 11563 11564 babelHelpers.createClass(ZIndexManager, null, [{ 11565 key: "register", 11566 value: function register(element, options = {}) { 11567 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 11568 11569 if (!parentNode) { 11570 return null; 11571 } 11572 11573 const stack = this.getOrAddStack(parentNode); 11574 return stack.register(element, options); 11575 } 11576 }, { 11577 key: "unregister", 11578 value: function unregister(element) { 11579 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 11580 11581 const stack = this.getStack(parentNode); 11582 11583 if (stack) { 11584 stack.unregister(element); 11585 } 11586 } 11587 }, { 11588 key: "addStack", 11589 value: function addStack(container) { 11590 const stack = new ZIndexStack(container); 11591 this.stacks.set(container, stack); 11592 return stack; 11593 } 11594 }, { 11595 key: "getStack", 11596 value: function getStack(container) { 11597 return this.stacks.get(container) || null; 11598 } 11599 }, { 11600 key: "getOrAddStack", 11601 value: function getOrAddStack(container) { 11602 return this.getStack(container) || this.addStack(container); 11603 } 11604 }, { 11605 key: "getComponent", 11606 value: function getComponent(element) { 11607 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element, true); 11608 11609 if (!parentNode) { 11610 return null; 11611 } 11612 11613 const stack = this.getStack(parentNode); 11614 return stack ? stack.getComponent(element) : null; 11615 } 11616 }, { 11617 key: "bringToFront", 11618 value: function bringToFront(element) { 11619 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 11620 11621 const stack = this.getStack(parentNode); 11622 11623 if (stack) { 11624 return stack.bringToFront(element); 11625 } 11626 11627 return null; 11628 } 11629 }]); 11630 return ZIndexManager; 11631 }(); 11632 11633 function _getParentNode(element, suppressWarnings = false) { 11634 if (!Type.isElementNode(element)) { 11635 if (!suppressWarnings) { 11636 console.error('ZIndexManager: The argument \'element\' must be a DOM element.', element); 11637 } 11638 11639 return null; 11640 } else if (!Type.isElementNode(element.parentNode)) { 11641 if (!suppressWarnings) { 11642 console.error('ZIndexManager: The \'element\' doesn\'t have a parent node.', element); 11643 } 11644 11645 return null; 11646 } 11647 11648 return element.parentNode; 11649 } 11650 11651 babelHelpers.defineProperty(ZIndexManager, "stacks", new WeakMap()); 11652 11653 var collections = { 11654 OrderedArray 11655 }; 11656 11657 function getElement(element) { 11658 if (Type.isString(element)) { 11659 return document.getElementById(element); 11660 } 11661 11662 return element; 11663 } 11664 11665 function getWindow(element) { 11666 if (Type.isElementNode(element)) { 11667 return element.ownerDocument.parentWindow || element.ownerDocument.defaultView || window; 11668 } 11669 11670 if (Type.isDomNode(element)) { 11671 return element.parentWindow || element.defaultView || window; 11672 } 11673 11674 return window; 11675 } 11676 11677 /* eslint-disable prefer-rest-params */ 11678 11679 const { 11680 getClass, 11681 namespace 11682 } = Reflection; 11683 const message$1 = message; 11684 /** 11685 * @memberOf BX 11686 */ 11687 11688 const { 11689 replace, 11690 remove, 11691 clean, 11692 insertBefore, 11693 insertAfter, 11694 append, 11695 prepend, 11696 style, 11697 adjust, 11698 create, 11699 isShown 11700 } = Dom; 11701 const addClass = function addClass() { 11702 Dom.addClass(...Runtime.merge([], Array.from(arguments), [getElement(arguments[0])])); 11703 }; 11704 const removeClass = function removeClass() { 11705 Dom.removeClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11706 }; 11707 const hasClass = function hasClass() { 11708 return Dom.hasClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11709 }; 11710 const toggleClass = function toggleClass() { 11711 Dom.toggleClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11712 }; 11713 const cleanNode = (element, removeElement = false) => { 11714 const currentElement = getElement(element); 11715 11716 if (Type.isDomNode(currentElement)) { 11717 Dom.clean(currentElement); 11718 11719 if (removeElement) { 11720 Dom.remove(currentElement); 11721 return currentElement; 11722 } 11723 } 11724 11725 return currentElement; 11726 }; 11727 const getCookie = Http.Cookie.get;
11728 const setCookie = (name, value, options = {}) => { 11729 const attributes = { ...options 11730 }; 11731 11732 if (Type.isNumber(attributes.expires)) { 11733 attributes.expires /= 3600 * 24; 11734 } 11735 11736 Http.Cookie.set(name, value, attributes); 11737 }; 11738 const { 11739 bind: bind$1, 11740 unbind: unbind$1, 11741 unbindAll: unbindAll$1, 11742 bindOnce: bindOnce$1, 11743 ready: ready$1 11744 } = Event; 11745 const { 11746 debugState: debugEnableFlag, 11747 isDebugEnabled: debugStatus, 11748 default: debug$1 11749 } = debugNs; 11750 const debugEnable = value => { 11751 if (value) { 11752 enableDebug(); 11753 } else { 11754 disableDebug(); 11755 } 11756 }; 11757 const { 11758 clone: clone$1, 11759 loadExtension: loadExt, 11760 debounce, 11761 throttle, 11762 html 11763 } = Runtime; // BX.type 11764 11765 const type = { ...Object.getOwnPropertyNames(Type).filter(key => !['name', 'length', 'prototype', 'caller', 'arguments'].includes(key)).reduce((acc, key) => { 11766 acc[key] = Type[key]; 11767 return acc; 11768 }, {}), 11769 isNotEmptyString: value => Type.isString(value) && value !== '', 11770 isNotEmptyObject: value => Type.isObjectLike(value) && Object.keys(value).length > 0, 11771 isMapKey: Type.isObject, 11772 stringToInt: value => { 11773 const parsed = parseInt(value); 11774 return !Number.isNaN(parsed) ? parsed : 0; 11775 } 11776 }; // BX.browser 11777 11778 const browser = { 11779 IsOpera: Browser.isOpera, 11780 IsIE: Browser.isIE, 11781 IsIE6: Browser.isIE6, 11782 IsIE7: Browser.isIE7, 11783 IsIE8: Browser.isIE8, 11784 IsIE9: Browser.isIE9, 11785 IsIE10: Browser.isIE10, 11786 IsIE11: Browser.isIE11, 11787 IsSafari: Browser.isSafari, 11788 IsFirefox: Browser.isFirefox, 11789 IsChrome: Browser.isChrome, 11790 DetectIeVersion: Browser.detectIEVersion, 11791 IsMac: Browser.isMac, 11792 IsAndroid: Browser.isAndroid, 11793 isIPad: Browser.isIPad, 11794 isIPhone: Browser.isIPhone, 11795 IsIOS: Browser.isIOS, 11796 IsMobile: Browser.isMobile, 11797 isRetina: Browser.isRetina, 11798 IsDoctype: Browser.isDoctype, 11799 SupportLocalStorage: Browser.isLocalStorageSupported, 11800 addGlobalClass: Browser.addGlobalClass, 11801 DetectAndroidVersion: Browser.detectAndroidVersion, 11802 isPropertySupported: Browser.isPropertySupported, 11803 addGlobalFeatures: Browser.addGlobalFeatures 11804 }; // eslint-disable-next-line 11805 11806 const ajax = window.BX ? window.BX.ajax : () => {}; 11807 function GetWindowScrollSize(doc = document) { 11808 return { 11809 scrollWidth: doc.documentElement.scrollWidth, 11810 scrollHeight: doc.documentElement.scrollHeight 11811 }; 11812 } 11813 function GetWindowScrollPos(doc = document) { 11814 const win = getWindow(doc); 11815 return { 11816 scrollLeft: win.pageXOffset, 11817 scrollTop: win.pageYOffset 11818 }; 11819 } 11820 function GetWindowInnerSize(doc = document) { 11821 const win = getWindow(doc); 11822 return { 11823 innerWidth: win.innerWidth, 11824 innerHeight: win.innerHeight 11825 }; 11826 } 11827 function GetWindowSize(doc = document) { 11828 return { ...GetWindowInnerSize(doc), 11829 ...GetWindowScrollPos(doc), 11830 ...GetWindowScrollSize(doc) 11831 }; 11832 } 11833 function GetContext(node) { 11834 return getWindow(node); 11835 } 11836 function pos(element, relative = false) { 11837 if (!element) { 11838 return new DOMRect().toJSON(); 11839 } 11840 11841 if (element.ownerDocument === document && !relative) { 11842 const clientRect = element.getBoundingClientRect(); 11843 const root = document.documentElement; 11844 const { 11845 body 11846 } = document; 11847 return { 11848 top: Math.round(clientRect.top + (root.scrollTop || body.scrollTop)), 11849 left: Math.round(clientRect.left + (root.scrollLeft || body.scrollLeft)), 11850 width: Math.round(clientRect.right - clientRect.left), 11851 height: Math.round(clientRect.bottom - clientRect.top), 11852 right: Math.round(clientRect.right + (root.scrollLeft || body.scrollLeft)), 11853 bottom: Math.round(clientRect.bottom + (root.scrollTop || body.scrollTop)) 11854 }; 11855 } 11856 11857 let x = 0; 11858 let y = 0; 11859 const w = element.offsetWidth; 11860 const h = element.offsetHeight; 11861 let first = true; // eslint-disable-next-line no-param-reassign 11862 11863 for (; element != null; element = element.offsetParent) { 11864 if (!first && relative && BX.is_relative(element)) { 11865 break; 11866 } 11867 11868 x += element.offsetLeft; 11869 y += element.offsetTop; 11870 11871 if (first) { 11872 first = false; // eslint-disable-next-line no-continue 11873 11874 continue; 11875 } 11876 11877 x += Text.toNumber(Dom.style(element, 'border-left-width')); 11878 y += Text.toNumber(Dom.style(element, 'border-top-width')); 11879 } 11880 11881 return new DOMRect(x, y, w, h).toJSON(); 11882 } 11883 function addCustomEvent(eventObject, eventName, eventHandler) { 11884 if (Type.isString(eventObject)) { 11885 eventHandler = eventName; 11886 eventName = eventObject; 11887 eventObject = EventEmitter.GLOBAL_TARGET;
11888 } 11889 11890 if (eventObject === window) { 11891 eventObject = EventEmitter.GLOBAL_TARGET; 11892 } 11893 11894 if (!Type.isObject(eventObject)) { 11895 console.error('The "eventObject" argument must be an object. Received type ' + typeof eventObject + '.'); 11896 return; 11897 } 11898 11899 if (!Type.isStringFilled(eventName)) { 11900 console.error('The "eventName" argument must be a string.'); 11901 return; 11902 } 11903 11904 if (!Type.isFunction(eventHandler)) { 11905 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11906 return; 11907 } 11908 11909 eventName = eventName.toLowerCase(); 11910 EventEmitter.subscribe(eventObject, eventName, eventHandler, { 11911 compatMode: true, 11912 useGlobalNaming: true 11913 }); 11914 } 11915 function onCustomEvent(eventObject, eventName, eventParams, secureParams) { 11916 if (Type.isString(eventObject)) { 11917 secureParams = eventParams; 11918 eventParams = eventName; 11919 eventName = eventObject; 11920 eventObject = EventEmitter.GLOBAL_TARGET; 11921 } 11922 11923 if (!Type.isObject(eventObject) || eventObject === window) { 11924 eventObject = EventEmitter.GLOBAL_TARGET;
11925 } 11926 11927 if (!eventParams) { 11928 eventParams = []; 11929 } 11930 11931 eventName = eventName.toLowerCase(); 11932 const event = new BaseEvent(); 11933 event.setData(eventParams); 11934 event.setCompatData(eventParams); 11935 EventEmitter.emit(eventObject, eventName, event, { 11936 cloneData: secureParams === true, 11937 useGlobalNaming: true 11938 }); 11939 } 11940 function removeCustomEvent(eventObject, eventName, eventHandler) { 11941 if (Type.isString(eventObject)) { 11942 eventHandler = eventName; 11943 eventName = eventObject; 11944 eventObject = EventEmitter.GLOBAL_TARGET; 11945 } 11946 11947 if (!Type.isFunction(eventHandler)) { 11948 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11949 return; 11950 } 11951 11952 if (eventObject === window) { 11953 eventObject = EventEmitter.GLOBAL_TARGET; 11954 } 11955 11956 eventName = eventName.toLowerCase(); 11957 EventEmitter.unsubscribe(eventObject, eventName, eventHandler, { 11958 useGlobalNaming: true 11959 }); 11960 } 11961 function removeAllCustomEvents(eventObject, eventName) { 11962 if (Type.isString(eventObject)) { 11963 eventName = eventObject; 11964 eventObject = EventEmitter.GLOBAL_TARGET;
11965 } 11966 11967 if (eventObject === window) { 11968 eventObject = EventEmitter.GLOBAL_TARGET; 11969 } 11970 11971 eventName = eventName.toLowerCase(); 11972 EventEmitter.unsubscribeAll(eventObject, eventName, { 11973 useGlobalNaming: true 11974 }); 11975 } 11976 11977 if (typeof global === 'object' && global.window && global.window.BX) { 11978 Object.assign(global.window.BX, exports); 11979 } 11980 11981 exports.Type = Type; 11982 exports.Reflection = Reflection; 11983 exports.Text = Text; 11984 exports.Dom = Dom; 11985 exports.Browser = Browser; 11986 exports.Event = Event; 11987 exports.Http = Http; 11988 exports.Runtime = Runtime; 11989 exports.Loc = Loc; 11990 exports.Tag = Tag; 11991 exports.Uri = Uri; 11992 exports.Validation = Validation; 11993 exports.Cache = Cache; 11994 exports.BaseError = BaseError; 11995 exports.Extension = Extension$1; 11996 exports.ZIndexManager = ZIndexManager; 11997 exports.Collections = collections; 11998 exports.getClass = getClass; 11999 exports.namespace = namespace; 12000 exports.message = message$1; 12001 exports.replace = replace; 12002 exports.remove = remove; 12003 exports.clean = clean; 12004 exports.insertBefore = insertBefore; 12005 exports.insertAfter = insertAfter; 12006 exports.append = append; 12007 exports.prepend = prepend; 12008 exports.style = style; 12009 exports.adjust = adjust; 12010 exports.create = create; 12011 exports.isShown = isShown; 12012 exports.addClass = addClass; 12013 exports.removeClass = removeClass; 12014 exports.hasClass = hasClass; 12015 exports.toggleClass = toggleClass; 12016 exports.cleanNode = cleanNode; 12017 exports.getCookie = getCookie; 12018 exports.setCookie = setCookie; 12019 exports.bind = bind$1; 12020 exports.unbind = unbind$1; 12021 exports.unbindAll = unbindAll$1; 12022 exports.bindOnce = bindOnce$1; 12023 exports.ready = ready$1; 12024 exports.debugEnableFlag = debugEnableFlag; 12025 exports.debugStatus = debugStatus; 12026 exports.debug = debug$1; 12027 exports.debugEnable = debugEnable; 12028 exports.clone = clone$1; 12029 exports.loadExt = loadExt; 12030 exports.debounce = debounce; 12031 exports.throttle = throttle; 12032 exports.html = html; 12033 exports.type = type; 12034 exports.browser = browser; 12035 exports.ajax = ajax; 12036 exports.GetWindowScrollSize = GetWindowScrollSize; 12037 exports.GetWindowScrollPos = GetWindowScrollPos; 12038 exports.GetWindowInnerSize = GetWindowInnerSize; 12039 exports.GetWindowSize = GetWindowSize; 12040 exports.GetContext = GetContext; 12041 exports.pos = pos; 12042 exports.addCustomEvent = addCustomEvent; 12043 exports.onCustomEvent = onCustomEvent; 12044 exports.removeCustomEvent = removeCustomEvent; 12045 exports.removeAllCustomEvents = removeAllCustomEvents; 12046 12047}((this.BX = this.BX || {}))); 12048 12049 12050 12051(function(BX) { 12052 /* list of registered proxy functions */ 12053 var proxyList = new WeakMap(); 12054 var deferList = new WeakMap(); 12055 12056 /* List of denied event handlers */ 12057 var deniedEvents = []; 12058 12059 /* list of registered custom events */ 12060 var customEvents = new WeakMap(); 12061 var customEventsCnt = 0; 12062 12063 /* list of external garbage collectors */ 12064 var garbageCollectors = []; 12065 12066 /* list of loaded CSS files */ 12067 var cssList = []; 12068 var cssInit = false; 12069 12070 /* list of loaded JS files */ 12071 var jsList = []; 12072 var jsInit = false; 12073 12074 var eventTypes = { 12075 click: 'MouseEvent', 12076 dblclick: 'MouseEvent', 12077 mousedown: 'MouseEvent', 12078 mousemove: 'MouseEvent', 12079 mouseout: 'MouseEvent', 12080 mouseover: 'MouseEvent', 12081 mouseup: 'MouseEvent', 12082 focus: 'MouseEvent', 12083 blur: 'MouseEvent' 12084 }; 12085 12086 var lastWait = []; 12087 12088 var CHECK_FORM_ELEMENTS = {tagName: /^INPUT|SELECT|TEXTAREA|BUTTON$/i}; 12089 12090 var PRELOADING = 1; 12091 var PRELOADED = 2; 12092 var LOADING = 3; 12093 var LOADED = 4; 12094 var assets = {}; 12095 var isAsync = null; 12096 12097 BX.MSLEFT = 1; 12098 BX.MSMIDDLE = 2; 12099 BX.MSRIGHT = 4; 12100 12101 BX.AM_PM_UPPER = 1; 12102 BX.AM_PM_LOWER = 2; 12103 BX.AM_PM_NONE = false; 12104 12105 BX.ext = function(ob) 12106 { 12107 for (var i in ob) 12108 { 12109 if(ob.hasOwnProperty(i)) 12110 { 12111 this[i] = ob[i]; 12112 } 12113 } 12114 }; 12115 12116 var r = { 12117 script: /<script([^>]*)>/ig, 12118 script_end: /<\/script>/ig, 12119 script_src: /src=["\']([^"\']+)["\']/i, 12120 script_type: /type=["\']([^"\']+)["\']/i, 12121 space: /\s+/, 12122 ltrim: /^[\s\r\n]+/g, 12123 rtrim: /[\s\r\n]+$/g, 12124 style: /<link.*?(rel="stylesheet"|type="text\/css")[^>]*>/i, 12125 style_href: /href=["\']([^"\']+)["\']/i 12126 }; 12127 12128 BX.processHTML = function(data, scriptsRunFirst) 12129 { 12130 var matchScript, matchStyle, matchSrc, matchHref, matchType, scripts = [], styles = []; 12131 var textIndexes = []; 12132 var lastIndex = r.script.lastIndex = r.script_end.lastIndex = 0; 12133 12134 while ((matchScript = r.script.exec(data)) !== null) 12135 { 12136 r.script_end.lastIndex = r.script.lastIndex; 12137 var matchScriptEnd = r.script_end.exec(data); 12138 if (matchScriptEnd === null) 12139 { 12140 break; 12141 } 12142 12143 // skip script tags of special types 12144 var skipTag = false;
12145 if ((matchType = matchScript[1].match(r.script_type)) !== null) 12146 { 12147 if( 12148 matchType[1] == 'text/html' 12149 || matchType[1] == 'text/template' 12150 || matchType[1] == 'extension/settings' 12151 ) 12152 { 12153 skipTag = true; 12154 } 12155 } 12156 12157 if(skipTag) 12158 { 12159 textIndexes.push([lastIndex, r.script_end.lastIndex - lastIndex]); 12160 } 12161 else 12162 { 12163 textIndexes.push([lastIndex, matchScript.index - lastIndex]); 12164 12165 var bRunFirst = scriptsRunFirst || (matchScript[1].indexOf('bxrunfirst') != '-1'); 12166 12167 if ((matchSrc = matchScript[1].match(r.script_src)) !== null) 12168 { 12169 scripts.push({"bRunFirst": bRunFirst, "isInternal": false, "JS": matchSrc[1]}); 12170 } 12171 else 12172 { 12173 var start = matchScript.index + matchScript[0].length; 12174 var js = data.substr(start, matchScriptEnd.index-start); 12175 12176 scripts.push({"bRunFirst": bRunFirst, "isInternal": true, "JS": js}); 12177 } 12178 } 12179 12180 lastIndex = matchScriptEnd.index + 9; 12181 r.script.lastIndex = lastIndex; 12182 } 12183 12184 textIndexes.push([lastIndex, lastIndex === 0 ? data.length : data.length - lastIndex]); 12185 var pureData = ""; 12186 for (var i = 0, length = textIndexes.length; i < length; i++) 12187 { 12188 if (BX.type.isString(data) && BX.type.isFunction(data.substr)) 12189 { 12190 pureData += data.substr(textIndexes[i][0], textIndexes[i][1]); 12191 } 12192 } 12193 12194 while ((matchStyle = pureData.match(r.style)) !== null) 12195 { 12196 if ((matchHref = matchStyle[0].match(r.style_href)) !== null && matchStyle[0].indexOf('media="') < 0) 12197 { 12198 styles.push(matchHref[1]); 12199 } 12200 12201 pureData = pureData.replace(matchStyle[0], ''); 12202 } 12203 12204 return {'HTML': pureData, 'SCRIPT': scripts, 'STYLE': styles}; 12205 }; 12206 12207 /* OO emulation utility */ 12208 BX.extend = function(child, parent) 12209 { 12210 var f = function() {}; 12211 f.prototype = parent.prototype; 12212 12213 child.prototype = new f(); 12214 child.prototype.constructor = child; 12215 12216 child.superclass = parent.prototype; 12217 child.prototype.superclass = parent.prototype; 12218 if(parent.prototype.constructor == Object.prototype.constructor) 12219 { 12220 parent.prototype.constructor = parent; 12221 } 12222 }; 12223 12224 BX.is_subclass_of = function(ob, parent_class) 12225 { 12226 if (ob instanceof parent_class) 12227 return true; 12228 12229 if (parent_class.superclass) 12230 return BX.is_subclass_of(ob, parent_class.superclass); 12231 12232 return false; 12233 }; 12234 12235 BX.clearNodeCache = function() 12236 { 12237 return false; 12238 }; 12239 12240 BX.bitrix_sessid = function() {return BX.message("bitrix_sessid"); }; 12241 12242 /** 12243 * Creates document fragment with child nodes. 12244 * 12245 * @param {Node[]} nodes 12246 * @return {DocumentFragment} 12247 */ 12248 BX.createFragment = function(nodes) 12249 { 12250 var fragment = document.createDocumentFragment(); 12251 12252 if(!BX.type.isArray(nodes)) 12253 { 12254 return fragment; 12255 } 12256 for(var i = 0; i < nodes.length; i++) 12257 { 12258 fragment.appendChild(nodes[i]); 12259 } 12260 12261 return fragment; 12262 }; 12263 12264 /** 12265 * @deprecated 12266 * @use BX.style 12267 * @param element 12268 * @param opacity 12269 */ 12270 BX.setOpacity = function(element, opacity) 12271 { 12272 var opacityValue = parseFloat(opacity); 12273 12274 if (!isNaN(opacityValue) && BX.type.isDomNode(element)) 12275 { 12276 opacityValue = opacityValue < 1 ? opacityValue : opacityValue / 100; 12277 BX.style(element, 'opacity', opacityValue); 12278 } 12279 }; 12280 12281 /** 12282 * @deprecated 12283 * @param el 12284 * @return {*} 12285 */ 12286 BX.hoverEvents = function(el) 12287 { 12288 if (el) 12289 return BX.adjust(el, {events: BX.hoverEvents()}); 12290 else 12291 return {mouseover: BX.hoverEventsHover, mouseout: BX.hoverEventsHout}; 12292 }; 12293 12294 /** 12295 * @deprecated 12296 */ 12297 BX.hoverEventsHover = function(){BX.addClass(this,'bx-hover');this.BXHOVER=true;}; 12298 /** 12299 * @deprecated 12300 */ 12301 BX.hoverEventsHout = function(){BX.removeClass(this,'bx-hover');this.BXHOVER=false;}; 12302 12303 /** 12304 * @deprecated 12305 */ 12306 BX.focusEvents = function(el) 12307 { 12308 if (el) 12309 return BX.adjust(el, {events: BX.focusEvents()}); 12310 else 12311 return {mouseover: BX.focusEventsFocus, mouseout: BX.focusEventsBlur}; 12312 }; 12313 12314 /** 12315 * @deprecated 12316 */ 12317 BX.focusEventsFocus = function(){BX.addClass(this,'bx-focus');this.BXFOCUS=true;}; 12318 /** 12319 * @deprecated 12320 */ 12321 BX.focusEventsBlur = function(){BX.removeClass(this,'bx-focus');this.BXFOCUS=false;}; 12322 12323 BX.setUnselectable = function(node) 12324 { 12325 BX.style(node, { 12326 'userSelect': 'none', 12327 'MozUserSelect': 'none', 12328 'WebkitUserSelect': 'none', 12329 'KhtmlUserSelect': 'none', 12330 }); 12331 node.setAttribute('unSelectable', 'on'); 12332 }; 12333 12334 BX.setSelectable = function(node) 12335 { 12336 BX.style(node, { 12337 'userSelect': null, 12338 'MozUserSelect': null, 12339 'WebkitUserSelect': null, 12340 'KhtmlUserSelect': null, 12341 }); 12342 node.removeAttribute('unSelectable'); 12343 }; 12344 12345 BX.styleIEPropertyName = function(name) 12346 { 12347 if (name == 'float') 12348 name = BX.browser.IsIE() ? 'styleFloat' : 'cssFloat'; 12349 else 12350 { 12351 var res = BX.browser.isPropertySupported(name); 12352 if (res) 12353 { 12354 name = res; 12355 } 12356 else 12357 {
12358 var reg = /(\-([a-z]){1})/g; 12359 if (reg.test(name)) 12360 { 12361 name = name.replace(reg, function () {return arguments[2].toUpperCase();}); 12362 } 12363 } 12364 } 12365 return name; 12366 }; 12367 12368 BX.focus = function(el) 12369 { 12370 try 12371 { 12372 el.focus(); 12373 return true; 12374 } 12375 catch (e) 12376 { 12377 return false; 12378 } 12379 }; 12380 12381 BX.firstChild = function(el) 12382 { 12383 return BX.type.isDomNode(el) ? el.firstElementChild : null; 12384 }; 12385 12386 BX.lastChild = function(el) 12387 { 12388 return BX.type.isDomNode(el) ? el.lastElementChild : null; 12389 }; 12390 12391 BX.previousSibling = function(el) 12392 { 12393 return BX.type.isDomNode(el) ? el.previousElementSibling : null; 12394 }; 12395 12396 BX.nextSibling = function(el) 12397 { 12398 return BX.type.isDomNode(el) ? el.nextElementSibling : null; 12399 }; 12400 12401 /* 12402 params: { 12403 obj : html node 12404 className : className value 12405 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 12406 } 12407 12408 Search all nodes with className 12409 */ 12410 /** 12411 * @deprecated 12412 * @use .querySelectorAll 12413 * @param obj 12414 * @param className 12415 * @param recursive 12416 * @return {*} 12417 */ 12418 BX.findChildrenByClassName = function(obj, className, recursive) 12419 { 12420 if(!obj || !obj.childNodes) return null; 12421 12422 var result = []; 12423 if (typeof(obj.getElementsByClassName) == 'undefined') 12424 { 12425 recursive = recursive !== false; 12426 result = BX.findChildren(obj, {className : className}, recursive); 12427 } 12428 else 12429 { 12430 var col = obj.getElementsByClassName(className); 12431 for (i=0,l=col.length;i<l;i++) 12432 { 12433 result[i] = col[i]; 12434 } 12435 } 12436 return result; 12437 }; 12438 12439 /* 12440 params: { 12441 obj : html node 12442 className : className value 12443 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 12444 } 12445 12446 Search first node with className 12447 */ 12448 /** 12449 * @deprecated 12450 * @use .querySelector 12451 * @param obj 12452 * @param className 12453 * @param recursive 12454 * @return {*} 12455 */ 12456 BX.findChildByClassName = function(obj, className, recursive) 12457 { 12458 if(!obj || !obj.childNodes) return null; 12459 12460 var result = null; 12461 if (typeof(obj.getElementsByClassName) == 'undefined') 12462 { 12463 recursive = recursive !== false; 12464 result = BX.findChild(obj, {className : className}, recursive); 12465 } 12466 else 12467 { 12468 var col = obj.getElementsByClassName(className); 12469 if (col && typeof(col[0]) != 'undefined') 12470 { 12471 result = col[0]; 12472 } 12473 else 12474 { 12475 result = null; 12476 } 12477 } 12478 return result; 12479 }; 12480 12481 /* 12482 params: { 12483 tagName|tag : 'tagName', 12484 className|class : 'className', 12485 attribute : {attribute : value, attribute : value} | attribute | [attribute, attribute....], 12486 property : {prop: value, prop: value} | prop | [prop, prop] 12487 } 12488 12489 all values can be RegExps or strings 12490 */ 12491 /** 12492 * @deprecated 12493 * @use .querySelectorAll 12494 * @param obj 12495 * @param params 12496 * @param recursive 12497 * @return {*|Node} 12498 */ 12499 BX.findChildren = function(obj, params, recursive) 12500 { 12501 return BX.findChild(obj, params, recursive, true); 12502 }; 12503 12504 /** 12505 * @deprecated 12506 * @use .querySelectorAll 12507 * @param obj 12508 * @param params 12509 * @param recursive 12510 * @param get_all 12511 * @return {*} 12512 */ 12513 BX.findChild = function(obj, params, recursive, get_all) 12514 { 12515 if(!obj || !obj.childNodes) return null; 12516 12517 recursive = !!recursive; get_all = !!get_all; 12518 12519 var n = obj.childNodes.length, result = []; 12520 12521 for (var j=0; j<n; j++) 12522 { 12523 var child = obj.childNodes[j]; 12524 12525 if (_checkNode(child, params)) 12526 { 12527 if (get_all) 12528 result.push(child); 12529 else 12530 return child; 12531 } 12532 12533 if(recursive == true) 12534 { 12535 var res = BX.findChild(child, params, recursive, get_all); 12536 if (res) 12537 { 12538 if (get_all) 12539 result = BX.util.array_merge(result, res); 12540 else 12541 return res; 12542 } 12543 } 12544 } 12545 12546 if (get_all || result.length > 0) 12547 return result; 12548 else 12549 return null; 12550 }; 12551 12552 /** 12553 * @deprecated 12554 * @use .closest() 12555 * @param obj 12556 * @param params 12557 * @param maxParent 12558 * @return {*} 12559 */ 12560 BX.findParent = function(obj, params, maxParent) 12561 { 12562 if(!obj) 12563 return null; 12564 12565 var o = obj; 12566 while(o.parentNode) 12567 { 12568 var parent = o.parentNode; 12569 12570 if (_checkNode(parent, params)) 12571 return parent; 12572 12573 o = parent; 12574 12575 if (!!maxParent &&
12576 (BX.type.isFunction(maxParent) 12577 || typeof maxParent == 'object')) 12578 { 12579 if (BX.type.isElementNode(maxParent)) 12580 { 12581 if (o == maxParent) 12582 break; 12583 } 12584 else 12585 { 12586 if (_checkNode(o, maxParent)) 12587 break; 12588 } 12589 } 12590 } 12591 return null; 12592 }; 12593 12594 /** 12595 * @deprecated 12596 * @use .querySelector 12597 * @param obj 12598 * @param params 12599 * @return {*} 12600 */ 12601 BX.findNextSibling = function(obj, params) 12602 { 12603 if(!obj) 12604 return null; 12605 var o = obj; 12606 while(o.nextSibling) 12607 { 12608 var sibling = o.nextSibling; 12609 if (_checkNode(sibling, params)) 12610 return sibling; 12611 o = sibling; 12612 } 12613 return null; 12614 }; 12615 12616 /** 12617 * @deprecated 12618 * @use .querySelector 12619 * @param obj 12620 * @param params 12621 * @return {*} 12622 */ 12623 BX.findPreviousSibling = function(obj, params) 12624 { 12625 if(!obj) 12626 return null; 12627 12628 var o = obj; 12629 while(o.previousSibling) 12630 { 12631 var sibling = o.previousSibling; 12632 if(_checkNode(sibling, params)) 12633 return sibling; 12634 o = sibling; 12635 } 12636 return null; 12637 }; 12638 12639 BX.checkNode = function(obj, params) 12640 { 12641 return _checkNode(obj, params); 12642 }; 12643 12644 /** 12645 * @deprecated 12646 * @use .querySelectorAll 12647 * @param form 12648 * @return {Array} 12649 */ 12650 BX.findFormElements = function(form) 12651 { 12652 if (BX.type.isString(form)) 12653 form = document.forms[form]||BX(form); 12654 12655 var res = []; 12656 12657 if (BX.type.isElementNode(form)) 12658 { 12659 if (form.tagName.toUpperCase() == 'FORM') 12660 { 12661 res = form.elements; 12662 } 12663 else 12664 { 12665 res = BX.findChildren(form, CHECK_FORM_ELEMENTS, true); 12666 } 12667 } 12668 12669 return res; 12670 }; 12671 12672 /** 12673 * @deprecated 12674 * @use .contains() 12675 * @param whichNode 12676 * @param forNode 12677 * @return {boolean} 12678 */ 12679 BX.isParentForNode = function(whichNode, forNode) 12680 { 12681 if (BX.type.isDomNode(whichNode) && BX.type.isDomNode(forNode)) 12682 { 12683 return whichNode.contains(forNode); 12684 } 12685 12686 return false; 12687 }; 12688 12689 BX.getCaretPosition = function(node) 12690 { 12691 var pos = 0; 12692 12693 if(node.selectionStart || node.selectionStart == 0) 12694 { 12695 pos = node.selectionStart; 12696 } 12697 else if(document.selection) 12698 { 12699 node.focus(); 12700 var selection = document.selection.createRange(); 12701 selection.moveStart('character', -node.value.length); 12702 pos = selection.text.length; 12703 } 12704 12705 return (pos); 12706 }; 12707 12708 BX.setCaretPosition = function(node, pos) 12709 { 12710 if(!BX.isNodeInDom(node) || BX.isNodeHidden(node) || node.disabled) 12711 { 12712 return; 12713 } 12714 12715 if(node.setSelectionRange) 12716 { 12717 node.focus(); 12718 node.setSelectionRange(pos, pos); 12719 } 12720 else if(node.createTextRange) 12721 { 12722 var range = node.createTextRange(); 12723 range.collapse(true); 12724 range.moveEnd('character', pos); 12725 range.moveStart('character', pos); 12726 range.select(); 12727 } 12728 }; 12729 12730 // access private. use BX.mergeEx instead. 12731 // todo: refactor BX.merge, make it work through BX.mergeEx 12732 BX.merge = function(){ 12733 var arg = Array.prototype.slice.call(arguments); 12734 12735 if(arg.length < 2) 12736 return {}; 12737 12738 var result = arg.shift(); 12739 12740 for(var i = 0; i < arg.length; i++) 12741 { 12742 for(var k in arg[i]){ 12743 12744 if(typeof arg[i] == 'undefined' || arg[i] == null) 12745 continue; 12746 12747 if(arg[i].hasOwnProperty(k)){ 12748 12749 if(typeof arg[i][k] == 'undefined' || arg[i][k] == null) 12750 continue; 12751 12752 if(typeof arg[i][k] == 'object' && !BX.type.isDomNode(arg[i][k]) && (typeof arg[i][k]['isUIWidget'] == 'undefined')){ 12753 12754 // go deeper 12755 12756 var isArray = 'length' in arg[i][k]; 12757 12758 if(typeof result[k] != 'object') 12759 result[k] = isArray ? [] : {}; 12760 12761 if(isArray) 12762 BX.util.array_merge(result[k], arg[i][k]); 12763 else 12764 BX.merge(result[k], arg[i][k]); 12765 12766 }else 12767 result[k] = arg[i][k]; 12768 } 12769 } 12770 } 12771 12772 return result; 12773 }; 12774 12775 BX.mergeEx = function() 12776 { 12777 var arg = Array.prototype.slice.call(arguments); 12778 if(arg.length < 2) 12779 { 12780 return {}; 12781 } 12782 12783 var result = arg.shift(); 12784 for (var i = 0; i < arg.length; i++) 12785 { 12786 for (var k in arg[i]) 12787 { 12788 if (typeof arg[i] == "undefined" || arg[i] == null || !arg[i].hasOwnProperty(k)) 12789 { 12790 continue; 12791 } 12792 12793 if (BX.type.isPlainObject(arg[i][k]) && BX.type.isPlainObject(result[k])) 12794 { 12795 BX.mergeEx(result[k], arg[i][k]); 12796 } 12797 else 12798 { 12799 result[k] = BX.type.isPlainObject(arg[i][k]) ? BX.clone(arg[i][k]) : arg[i][k]; 12800 } 12801 } 12802 } 12803 12804 return result; 12805 }; 12806 12807 BX.getEventButton = function(e) 12808 { 12809 e = e || window.event; 12810 12811 var flags = 0; 12812 12813 if (typeof e.which != 'undefined') 12814 { 12815 switch (e.which) 12816 { 12817 case 1: flags = flags|BX.MSLEFT; break; 12818 case 2: flags = flags|BX.MSMIDDLE; break; 12819 case 3: flags = flags|BX.MSRIGHT; break; 12820 } 12821 } 12822 else if (typeof e.button != 'undefined') 12823 { 12824 flags = event.button; 12825 } 12826 12827 return flags || BX.MSLEFT; 12828 }; 12829 12830 var captured_events = null, _bind = null; 12831 BX.CaptureEvents = function(el_c, evname_c) 12832 { 12833 if (_bind) 12834 return; 12835 12836 _bind = BX.bind; 12837 captured_events = []; 12838 12839 BX.bind = function(el, evname, func) 12840 { 12841 if (el === el_c && evname === evname_c) 12842 captured_events.push(func); 12843 12844 _bind.apply(this, arguments); 12845 } 12846 }; 12847 12848 BX.CaptureEventsGet = function() 12849 { 12850 if (_bind) 12851 { 12852 BX.bind = _bind; 12853 12854 var captured = captured_events; 12855 12856 _bind = null; 12857 captured_events = null; 12858 return captured; 12859 } 12860 return null; 12861 }; 12862 12863 // Don't even try to use it for submit event! 12864 BX.fireEvent = function(ob,ev) 12865 { 12866 var result = false, e = null; 12867 if (BX.type.isDomNode(ob)) 12868 { 12869 result = true; 12870 if (document.createEventObject) 12871 { 12872 // IE 12873 if (eventTypes[ev] != 'MouseEvent') 12874 { 12875 e = document.createEventObject(); 12876 e.type = ev; 12877 result = ob.fireEvent('on' + ev, e); 12878 } 12879 12880 if (ob[ev]) 12881 { 12882 ob[ev](); 12883 } 12884 } 12885 else 12886 {
12887 // non-IE 12888 e = null; 12889 12890 switch (eventTypes[ev]) 12891 { 12892 case 'MouseEvent': 12893 e = document.createEvent('MouseEvent'); 12894 try 12895 { 12896 e.initMouseEvent(ev, true, true, top, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12897 } 12898 catch (initException) 12899 { 12900 e.initMouseEvent(ev, true, true, window, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12901 } 12902 12903 break; 12904 default: 12905 e = document.createEvent('Event'); 12906 e.initEvent(ev, true, true); 12907 } 12908 12909 result = ob.dispatchEvent(e); 12910 } 12911 } 12912 12913 return result; 12914 }; 12915 12916 BX.getWheelData = function(e) 12917 { 12918 e = e || window.event; 12919 e.wheelData = e.detail ? e.detail * -1 : e.wheelDelta / 40; 12920 return e.wheelData; 12921 }; 12922 12923 BX.proxy_context = null; 12924 12925 BX.delegate = function (func, thisObject) 12926 { 12927 if (!func || !thisObject) 12928 return func; 12929 12930 return function() { 12931 var cur = BX.proxy_context; 12932 BX.proxy_context = this; 12933 var res = func.apply(thisObject, arguments); 12934 BX.proxy_context = cur; 12935 return res; 12936 } 12937 }; 12938 12939 BX.delegateLater = function (func_name, thisObject, contextObject) 12940 { 12941 return function() 12942 { 12943 if (thisObject[func_name]) 12944 { 12945 var cur = BX.proxy_context; 12946 BX.proxy_context = this; 12947 var res = thisObject[func_name].apply(contextObject||thisObject, arguments); 12948 BX.proxy_context = cur; 12949 return res; 12950 } 12951 return null; 12952 } 12953 }; 12954 12955 BX.proxy = function(func, thisObject) 12956 { 12957 return getObjectDelegate(func, thisObject, proxyList); 12958 }; 12959 12960 BX.defer = function(func, thisObject) 12961 { 12962 if (!!thisObject) 12963 return BX.defer_proxy(func, thisObject); 12964 else 12965 return function() { 12966 var arg = arguments; 12967 setTimeout(function(){func.apply(this,arg)}, 10); 12968 }; 12969 }; 12970 12971 BX.defer_proxy = function(func, thisObject) 12972 { 12973 return getObjectDelegate(func, thisObject, deferList, BX.defer); 12974 }; 12975 12976 /** 12977 * 12978 * @private 12979 */ 12980 function getObjectDelegate(func, thisObject, collection, decorator) 12981 { 12982 if (!BX.type.isFunction(func) || !BX.type.isMapKey(thisObject)) 12983 { 12984 return func; 12985 } 12986 12987 var objectDelegates = collection.get(thisObject); 12988 if (!objectDelegates) 12989 { 12990 objectDelegates = new WeakMap(); 12991 collection.set(thisObject, objectDelegates); 12992 } 12993 12994 var delegate = objectDelegates.get(func); 12995 if (!delegate) 12996 { 12997 delegate = decorator ? decorator(BX.delegate(func, thisObject)) : BX.delegate(func, thisObject); 12998 objectDelegates.set(func, delegate); 12999 } 13000 13001 return delegate; 13002 } 13003 13004 BX.once = function(el, evname, func) 13005 { 13006 var fn = function() 13007 { 13008 BX.unbind(el, evname, fn); 13009 func.apply(this, arguments); 13010 }; 13011 13012 return fn; 13013 }; 13014 13015 BX.bindDelegate = function (elem, eventName, isTarget, handler) 13016 { 13017 var h = BX.delegateEvent(isTarget, handler); 13018 BX.bind(elem, eventName, h); 13019 return h; 13020 }; 13021 13022 BX.delegateEvent = function(isTarget, handler) 13023 { 13024 return function(e) 13025 { 13026 e = e || window.event; 13027 var target = e.target || e.srcElement; 13028 13029 while (target != this) 13030 { 13031 if (_checkNode(target, isTarget)) 13032 { 13033 return handler.call(target, e); 13034 } 13035 if (target && target.parentNode) 13036 target = target.parentNode; 13037 else 13038 break; 13039 } 13040 return null; 13041 } 13042 }; 13043 13044 BX.False = function() {return false;}; 13045 BX.DoNothing = function() {}; 13046 13047 // TODO: also check event handlers set via BX.bind() 13048 BX.denyEvent = function(el, ev) 13049 { 13050 deniedEvents.push([el, ev, el['on' + ev]]); 13051 el['on' + ev] = BX.DoNothing; 13052 }; 13053 13054 BX.allowEvent = function(el, ev) 13055 { 13056 for(var i=0, len=deniedEvents.length; i<len; i++) 13057 { 13058 if (deniedEvents[i][0] == el && deniedEvents[i][1] == ev) 13059 { 13060 el['on' + ev] = deniedEvents[i][2]; 13061 BX.util.deleteFromArray(deniedEvents, i); 13062 return; 13063 } 13064 } 13065 }; 13066 13067 BX.fixEventPageXY = function(event) 13068 { 13069 BX.fixEventPageX(event); 13070 BX.fixEventPageY(event); 13071 return event; 13072 }; 13073 13074 BX.fixEventPageX = function(event) 13075 { 13076 if (event.pageX == null && event.clientX != null) 13077 { 13078 event.pageX = 13079 event.clientX + 13080 (document.documentElement && document.documentElement.scrollLeft || document.body && document.body.scrollLeft || 0) - 13081 (document.documentElement.clientLeft || 0); 13082 } 13083 13084 return event; 13085 }; 13086 13087 BX.fixEventPageY = function(event) 13088 { 13089 if (event.pageY == null && event.clientY != null) 13090 { 13091 event.pageY = 13092 event.clientY + 13093 (document.documentElement && document.documentElement.scrollTop || document.body && document.body.scrollTop || 0) - 13094 (document.documentElement.clientTop || 0); 13095 } 13096 13097 return event; 13098 }; 13099 13100 /** 13101 * @deprecated 13102 * @see e.preventDefault() 13103 */ 13104 BX.PreventDefault = function(e) 13105 { 13106 if(!e) e = window.event; 13107 if(e.stopPropagation) 13108 { 13109 e.preventDefault(); 13110 e.stopPropagation(); 13111 } 13112 else 13113 { 13114 e.cancelBubble = true; 13115 e.returnValue = false;
13116 } 13117 return false; 13118 }; 13119 13120 /** 13121 * @deprecated 13122 * @see e.preventDefault(); 13123 * 13124 * @param e 13125 * @return {boolean} 13126 */ 13127 BX.eventReturnFalse = function(e) 13128 { 13129 e=e||window.event; 13130 if (e && e.preventDefault) e.preventDefault(); 13131 else e.returnValue = false; 13132 return false; 13133 }; 13134 13135 /** 13136 * @deprecated 13137 * @see e.stopPropagation() 13138 * @param e 13139 */ 13140 BX.eventCancelBubble = function(e) 13141 { 13142 e=e||window.event; 13143 if(e && e.stopPropagation) 13144 e.stopPropagation(); 13145 else 13146 e.cancelBubble = true; 13147 }; 13148 13149 BX.bindDebouncedChange = function(node, fn, fnInstant, timeout, ctx) 13150 { 13151 ctx = ctx || window; 13152 timeout = timeout || 300; 13153 13154 var dataTag = 'bx-dc-previous-value'; 13155 BX.data(node, dataTag, node.value); 13156 13157 var act = function(fn, val){ 13158 13159 var pVal = BX.data(node, dataTag); 13160 13161 if(typeof pVal == 'undefined' || pVal != val){ 13162 if(typeof ctx != 'object') 13163 fn(val); 13164 else 13165 fn.apply(ctx, [val]); 13166 } 13167 }; 13168 13169 var actD = BX.debounce(function(){ 13170 var val = node.value; 13171 act(fn, val); 13172 BX.data(node, dataTag, val); 13173 }, timeout); 13174 13175 BX.bind(node, 'keyup', actD); 13176 BX.bind(node, 'change', actD); 13177 BX.bind(node, 'input', actD); 13178 13179 if(BX.type.isFunction(fnInstant)){ 13180 13181 var actI = function(){ 13182 act(fnInstant, node.value); 13183 }; 13184 13185 BX.bind(node, 'keyup', actI); 13186 BX.bind(node, 'change', actI); 13187 BX.bind(node, 'input', actI); 13188 } 13189 }; 13190 13191 BX.parseJSON = function(data, context) 13192 { 13193 var result = null; 13194 if (BX.type.isNotEmptyString(data)) 13195 { 13196 try { 13197 if (data.indexOf("\n") >= 0) 13198 eval('result = ' + data); 13199 else 13200 result = (new Function("return " + data))(); 13201 } catch(e) { 13202 BX.onCustomEvent(context, 'onParseJSONFailure', [data, context]) 13203 } 13204 } 13205 else if(BX.type.isPlainObject(data)) 13206 { 13207 return data; 13208 } 13209 13210 return result; 13211 }; 13212 13213 BX.submit = function(obForm, action_name, action_value, onAfterSubmit) 13214 { 13215 action_name = action_name || 'save'; 13216 if (!obForm['BXFormSubmit_' + action_name]) 13217 { 13218 obForm['BXFormSubmit_' + action_name] = obForm.appendChild(BX.create('INPUT', { 13219 'props': { 13220 'type': 'submit', 13221 'name': action_name, 13222 'value': action_value || 'Y' 13223 }, 13224 'style': { 13225 'display': 'none' 13226 } 13227 })); 13228 } 13229 13230 if (obForm.sessid) 13231 obForm.sessid.value = BX.bitrix_sessid(); 13232 13233 setTimeout(BX.delegate(function() {BX.fireEvent(this, 'click'); if (onAfterSubmit) onAfterSubmit();}, obForm['BXFormSubmit_' + action_name]), 10); 13234 }; 13235 13236 BX.show = function(ob, displayType) 13237 { 13238 if (ob.BXDISPLAY || !_checkDisplay(ob, displayType)) 13239 { 13240 ob.style.display = ob.BXDISPLAY; 13241 } 13242 }; 13243 13244 BX.hide = function(ob, displayType) 13245 { 13246 if (!ob.BXDISPLAY) 13247 _checkDisplay(ob, displayType); 13248 13249 ob.style.display = 'none'; 13250 }; 13251 13252 BX.toggle = function(ob, values) 13253 { 13254 if (!values && BX.type.isElementNode(ob)) 13255 { 13256 var bShow = true; 13257 if (ob.BXDISPLAY) 13258 bShow = !_checkDisplay(ob); 13259 else 13260 bShow = ob.style.display == 'none'; 13261 13262 if (bShow) 13263 BX.show(ob); 13264 else 13265 BX.hide(ob); 13266 } 13267 else if (BX.type.isArray(values)) 13268 { 13269 for (var i=0,len=values.length; i<len; i++) 13270 { 13271 if (ob == values[i]) 13272 { 13273 ob = values[i==len-1 ? 0 : i+1]; 13274 break; 13275 } 13276 } 13277 if (i==len) 13278 ob = values[0]; 13279 } 13280 13281 return ob; 13282 }; 13283 13284 function _checkDisplay(ob, displayType) 13285 { 13286 if (typeof displayType != 'undefined') 13287 ob.BXDISPLAY = displayType; 13288 13289 var d = ob.style.display || BX.style(ob, 'display'); 13290 if (d != 'none') 13291 { 13292 ob.BXDISPLAY = ob.BXDISPLAY || d; 13293 return true; 13294 } 13295 else 13296 { 13297 ob.BXDISPLAY = ob.BXDISPLAY || 'block'; 13298 return false; 13299 } 13300 } 13301 13302 /* some useful util functions */ 13303 13304 BX.util = { 13305 /** 13306 * @deprecated 13307 * @use [].filter(value => !BX.Type.isNil(value)) 13308 * @param ar 13309 * @return {*} 13310 */ 13311 array_values: function(ar) 13312 { 13313 if (!BX.type.isArray(ar)) 13314 return BX.util._array_values_ob(ar); 13315 var arv = []; 13316 for(var i=0,l=ar.length;i<l;i++) 13317 if (ar[i] !== null && typeof ar[i] != 'undefined') 13318 arv.push(ar[i]); 13319 return arv; 13320 }, 13321 13322 /** 13323 * @deprecated 13324 * @use Object.values([]).filter(value => !BX.Type.isNil(value)) 13325 * @param ar 13326 * @return {Array} 13327 * @private 13328 */ 13329 _array_values_ob: function(ar) 13330 { 13331 var arv = []; 13332 for(var i in ar) 13333 if (ar[i] !== null && typeof ar[i] != 'undefined') 13334 arv.push(ar[i]); 13335 return arv; 13336 }, 13337 13338 /** 13339 * @deprecated 13340 * @use 13341 * @param ar 13342 * @return {*} 13343 */ 13344 array_keys: function(ar) 13345 { 13346 if (!BX.type.isArray(ar)) 13347 return BX.util._array_keys_ob(ar); 13348 var arv = []; 13349 for(var i=0,l=ar.length;i<l;i++) 13350 if (ar[i] !== null && typeof ar[i] != 'undefined') 13351 arv.push(i); 13352 return arv; 13353 }, 13354 13355 _array_keys_ob: function(ar) 13356 { 13357 var arv = []; 13358 for(var i in ar) 13359 if (ar[i] !== null && typeof ar[i] != 'undefined') 13360 arv.push(i); 13361 return arv; 13362 }, 13363 13364 object_keys: function(obj) 13365 { 13366 var arv = []; 13367 for(var k in obj) 13368 { 13369 if(obj.hasOwnProperty(k)) 13370 { 13371 arv.push(k); 13372 } 13373 } 13374 return arv; 13375 }, 13376 13377 /** 13378 * @deprecated 13379 * @use firstArr.concat(secondArr); 13380 * @param first 13381 * @param second 13382 * @return {*[]} 13383 */ 13384 array_merge: function(first, second) 13385 { 13386 if (!BX.type.isArray(first)) first = []; 13387 if (!BX.type.isArray(second)) second = []; 13388 13389 var i = first.length, j = 0; 13390 13391 if (typeof second.length === "number") 13392 { 13393 for (var l = second.length; j < l; j++) 13394 { 13395 first[i++] = second[j]; 13396 } 13397 } 13398 else 13399 {
13400 while (second[j] !== undefined) 13401 { 13402 first[i++] = second[j++]; 13403 } 13404 } 13405 13406 first.length = i; 13407 13408 return first; 13409 }, 13410 13411 array_flip: function (object) 13412 { 13413 var newObject = {}; 13414 13415 for (var key in object) 13416 { 13417 newObject[object[key]] = key; 13418 } 13419 13420 return newObject; 13421 }, 13422 13423 array_diff: function(ar1, ar2, hash) 13424 { 13425 hash = BX.type.isFunction(hash) ? hash : null; 13426 var i, length, v, h, map = {}, result = []; 13427 for(i = 0, length = ar2.length; i < length; i++) 13428 { 13429 v = ar2[i]; 13430 h = hash ? hash(v) : v; 13431 map[h] = true; 13432 } 13433 13434 for(i = 0, length = ar1.length; i < length; i++) 13435 { 13436 v = ar1[i]; 13437 h = hash ? hash(v) : v; 13438 if(typeof(map[h]) === "undefined") 13439 { 13440 result.push(v); 13441 } 13442 } 13443 return result; 13444 }, 13445 13446 /** 13447 * @deprecated 13448 * @use Set 13449 */ 13450 array_unique: function(ar) 13451 { 13452 var i=0,j,len=ar.length; 13453 if(len<2) return ar; 13454 13455 for (; i<len-1;i++) 13456 { 13457 for (j=i+1; j<len;j++) 13458 { 13459 if (ar[i]==ar[j]) 13460 { 13461 ar.splice(j--,1); len--; 13462 } 13463 } 13464 } 13465 13466 return ar; 13467 }, 13468 13469 /** 13470 * @deprecated 13471 * @use myArr.includes(needle) 13472 */ 13473 in_array: function(needle, haystack) 13474 { 13475 for(var i=0; i<haystack.length; i++) 13476 { 13477 if(haystack[i] == needle) 13478 return true; 13479 } 13480 return false; 13481 }, 13482 13483 /** 13484 * @deprecated 13485 * @use myArr.findIndex(item => item === needle); 13486 */ 13487 array_search: function(needle, haystack) 13488 { 13489 for(var i=0; i<haystack.length; i++) 13490 { 13491 if(haystack[i] == needle) 13492 return i; 13493 } 13494 return -1; 13495 }, 13496 13497 object_search_key: function(needle, haystack) 13498 { 13499 if (typeof haystack[needle] != 'undefined') 13500 return haystack[needle]; 13501 13502 for(var i in haystack) 13503 { 13504 if (typeof haystack[i] == "object") 13505 { 13506 var result = BX.util.object_search_key(needle, haystack[i]); 13507 if (result !== false) 13508 return result; 13509 } 13510 } 13511 return false; 13512 }, 13513 13514 trim: function(s) 13515 { 13516 if (BX.type.isString(s)) 13517 { 13518 return s.trim(); 13519 } 13520 13521 return s; 13522 }, 13523 13524 urlencode: function(s){return encodeURIComponent(s);}, 13525 13526 // it may also be useful. via sVD. 13527 deleteFromArray: function(ar, ind) {return ar.slice(0, ind).concat(ar.slice(ind + 1));}, 13528 insertIntoArray: function(ar, ind, el) {return ar.slice(0, ind).concat([el]).concat(ar.slice(ind));}, 13529 13530 htmlspecialchars: function(str) 13531 { 13532 return BX.Text.encode(str); 13533 }, 13534 13535 htmlspecialcharsback: function(str) 13536 { 13537 return BX.Text.decode(str); 13538 }, 13539 13540 // Quote regular expression characters plus an optional character 13541 preg_quote: function(str, delimiter) 13542 { 13543 if(!str.replace) 13544 return str; 13545 return str.replace(new RegExp('[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + (delimiter || '') + '-]', 'g'), '\\$&'); 13546 }, 13547 13548 jsencode: function(str) 13549 { 13550 if (!str || !str.replace) 13551 return str; 13552 13553 var escapes = 13554 [ 13555 { c: "\\\\", r: "\\\\" }, // should be first 13556 { c: "\\t", r: "\\t" }, 13557 { c: "\\n", r: "\\n" }, 13558 { c: "\\r", r: "\\r" }, 13559 { c: "\"", r: "\\\"" }, 13560 { c: "'", r: "\\'" }, 13561 { c: "<", r: "\\x3C" }, 13562 { c: ">", r: "\\x3E" }, 13563 { c: "\\u2028", r: "\\u2028" }, 13564 { c: "\\u2029", r: "\\u2029" } 13565 ]; 13566 for (var i = 0; i < escapes.length; i++) 13567 str = str.replace(new RegExp(escapes[i].c, 'g'), escapes[i].r); 13568 return str; 13569 }, 13570 13571 getCssName: function(jsName) 13572 { 13573 if (!BX.type.isNotEmptyString(jsName)) 13574 { 13575 return ""; 13576 } 13577 13578 return jsName.replace(/[A-Z]/g, function(match) { 13579 return "-" + match.toLowerCase(); 13580 }); 13581 }, 13582 13583 getJsName: function(cssName) 13584 { 13585 var regex = /\-([a-z]){1}/g; 13586 if (regex.test(cssName)) 13587 { 13588 return cssName.replace(regex, function(match, letter) { 13589 return letter.toUpperCase(); 13590 }); 13591 } 13592 13593 return cssName; 13594 }, 13595 13596 nl2br: function(str) 13597 { 13598 if (!str || !str.replace) 13599 return str; 13600 13601 return str.replace(/([^>])\n/g, '$1<br/>'); 13602 }, 13603 13604 /** 13605 * @deprecated 13606 * @use .padStart() / .padEnd() 13607 * @param input 13608 * @param pad_length 13609 * @param pad_string 13610 * @param pad_type 13611 * @return {*} 13612 */ 13613 str_pad: function(input, pad_length, pad_string, pad_type) 13614 { 13615 pad_string = pad_string || ' '; 13616 pad_type = pad_type || 'right'; 13617 input = input.toString(); 13618 13619 if (pad_type === 'left') 13620 { 13621 return BX.util.str_pad_left(input, pad_length, pad_string); 13622 } 13623 13624 return BX.util.str_pad_right(input, pad_length, pad_string); 13625 }, 13626 13627 str_pad_left: function(input, pad_length, pad_string) 13628 { 13629 return input.toString().padStart(pad_length, pad_string); 13630 }, 13631 13632 str_pad_right: function(input, pad_length, pad_string) 13633 { 13634 return input.toString().padEnd(pad_length, pad_string); 13635 }, 13636 13637 strip_tags: function(str) 13638 { 13639 return str.split(/<[^>]+>/g).join(''); 13640 }, 13641 13642 strip_php_tags: function(str) 13643 { 13644 return str.replace(/<\?(.|[\r\n])*?\?>/g, ''); 13645 }, 13646 13647 popup: function(url, width, height) 13648 { 13649 var w, h; 13650 if(BX.browser.IsOpera()) 13651 { 13652 w = document.body.offsetWidth; 13653 h = document.body.offsetHeight; 13654 } 13655 else 13656 {
13657 w = screen.width; 13658 h = screen.height; 13659 } 13660 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)); 13661 }, 13662 13663 shuffle: function(array) 13664 { 13665 var temporaryValue, randomIndex; 13666 var currentIndex = array.length; 13667 13668 while (0 !== currentIndex) 13669 { 13670 randomIndex = Math.floor(Math.random() * currentIndex); 13671 currentIndex -= 1; 13672 13673 temporaryValue = array[currentIndex]; 13674 array[currentIndex] = array[randomIndex]; 13675 array[randomIndex] = temporaryValue; 13676 } 13677 13678 return array; 13679 }, 13680 13681 // BX.util.objectSort(object, sortBy, sortDir) - Sort object by property 13682 // function params: 1 - object for sort, 2 - sort by property, 3 - sort direction (asc/desc) 13683 // return: sort array [[objectElement], [objectElement]] in sortDir direction 13684 13685 // example: BX.util.objectSort({'L1': {'name': 'Last'}, 'F1': {'name': 'First'}}, 'name', 'asc'); 13686 // return: [{'name' : 'First'}, {'name' : 'Last'}] 13687 objectSort: function(object, sortBy, sortDir) 13688 { 13689 sortDir = sortDir == 'asc'? 'asc': 'desc'; 13690 13691 var arItems = [], i; 13692 for (i in object) 13693 { 13694 if (object.hasOwnProperty(i) && object[i][sortBy]) 13695 { 13696 arItems.push([i, object[i][sortBy]]); 13697 } 13698 } 13699 13700 if (sortDir == 'asc') 13701 { 13702 arItems.sort(function(i, ii) { 13703 var s1, s2; 13704 if (BX.type.isDate(i[1])) 13705 { 13706 s1 = i[1].getTime(); 13707 } 13708 else if (!isNaN(i[1])) 13709 { 13710 s1 = parseInt(i[1]); 13711 } 13712 else 13713 { 13714 s1 = i[1].toString().toLowerCase(); 13715 } 13716 13717 if (BX.type.isDate(ii[1])) 13718 { 13719 s2 = ii[1].getTime(); 13720 } 13721 else if (!isNaN(ii[1])) 13722 { 13723 s2 = parseInt(ii[1]); 13724 } 13725 else 13726 { 13727 s2 = ii[1].toString().toLowerCase(); 13728 } 13729 13730 if (s1 > s2) 13731 return 1; 13732 else if (s1 < s2) 13733 return -1; 13734 else 13735 return 0; 13736 }); 13737 } 13738 else 13739 { 13740 arItems.sort(function(i, ii) { 13741 var s1, s2; 13742 if (BX.type.isDate(i[1])) 13743 { 13744 s1 = i[1].getTime(); 13745 } 13746 else if (!isNaN(i[1])) 13747 { 13748 s1 = parseInt(i[1]); 13749 } 13750 else 13751 { 13752 s1 = i[1].toString().toLowerCase(); 13753 } 13754 13755 if (BX.type.isDate(ii[1])) 13756 { 13757 s2 = ii[1].getTime(); 13758 } 13759 else if (!isNaN(ii[1])) 13760 { 13761 s2 = parseInt(ii[1]); 13762 } 13763 else 13764 { 13765 s2 = ii[1].toString().toLowerCase(); 13766 } 13767 13768 if (s1 < s2) 13769 return 1; 13770 else if (s1 > s2) 13771 return -1; 13772 else 13773 return 0; 13774 }); 13775 } 13776 13777 var arReturnArray = Array(); 13778 for (i = 0; i < arItems.length; i++) 13779 { 13780 arReturnArray.push(object[arItems[i][0]]); 13781 } 13782 13783 return arReturnArray; 13784 }, 13785 13786 objectMerge: function() 13787 { 13788 return BX.mergeEx.apply(window, arguments); 13789 }, 13790 13791 objectClone : function(object) 13792 { 13793 return BX.clone(object, true); 13794 }, 13795 13796 // #fdf9e5 => {r=253, g=249, b=229} 13797 hex2rgb: function(color) 13798 { 13799 var rgb = color.replace(/[# ]/g,"").replace(/^(.)(.)(.)$/,'$1$1$2$2$3$3').match(/.{2}/g); 13800 for (var i=0; i<3; i++) 13801 { 13802 rgb[i] = parseInt(rgb[i], 16); 13803 } 13804 return {'r':rgb[0],'g':rgb[1],'b':rgb[2]}; 13805 }, 13806 13807 /** 13808 * @deprecated 13809 * @use BX.Uri 13810 * @param url 13811 * @param param 13812 * @return {string} 13813 */ 13814 remove_url_param: function(url, param) 13815 { 13816 return BX.Uri.removeParam(url, param); 13817 }, 13818 13819 /* 13820 {'param1': 'value1', 'param2': 'value2'} 13821 */ 13822 /** 13823 * @deprecated 13824 * @use BX.Uri 13825 * @param url 13826 * @param params 13827 * @return {string} 13828 */ 13829 add_url_param: function(url, params) 13830 { 13831 var preparedParams = Object.entries(params).reduce(function(acc, item) { 13832 acc[item[0]] = BX.type.isArray(item[1]) ? item[1].join() : item[1]; 13833 return acc; 13834 }, {}); 13835 13836 return BX.Uri.addParam(url, preparedParams); 13837 }, 13838 13839 /* 13840 {'param1': 'value1', 'param2': 'value2'} 13841 */ 13842 buildQueryString: function(params) 13843 { 13844 var result = ''; 13845 for (var key in params) 13846 { 13847 var value = params[key]; 13848 if(BX.type.isArray(value)) 13849 { 13850 value.forEach(function(valueElement, index) 13851 { 13852 result += encodeURIComponent(key + "[" + index + "]") + "=" + encodeURIComponent(valueElement) + "&"; 13853 }); 13854 } 13855 else 13856 { 13857 result += encodeURIComponent(key) + "=" + encodeURIComponent(value) + "&"; 13858 } 13859 } 13860 13861 if(result.length > 0) 13862 { 13863 result = result.substr(0, result.length - 1); 13864 } 13865 return result; 13866 }, 13867 13868 even: function(digit) 13869 { 13870 return (parseInt(digit) % 2 == 0); 13871 }, 13872 13873 hashCode: function(str) 13874 { 13875 if(!BX.type.isNotEmptyString(str)) 13876 { 13877 return 0; 13878 } 13879 13880 var hash = 0; 13881 for (var i = 0; i < str.length; i++) 13882 { 13883 var c = str.charCodeAt(i); 13884 hash = ((hash << 5) - hash) + c; 13885 hash = hash & hash; 13886 } 13887 return hash; 13888 }, 13889 13890 getRandomString: function (length) 13891 { 13892 return BX.Text.getRandom(length); 13893 }, 13894 13895 number_format: function(number, decimals, dec_point, thousands_sep) 13896 { 13897 var i, j, kw, kd, km, sign = ''; 13898 decimals = Math.abs(decimals); 13899 if (isNaN(decimals) || decimals < 0) 13900 { 13901 decimals = 2; 13902 } 13903 dec_point = dec_point || ','; 13904 if (typeof thousands_sep === 'undefined') 13905 thousands_sep = '.'; 13906 13907 number = (+number || 0).toFixed(decimals); 13908 if (number < 0) 13909 { 13910 sign = '-'; 13911 number = -number; 13912 } 13913 13914 i = parseInt(number, 10) + ''; 13915 j = (i.length > 3 ? i.length % 3 : 0); 13916 13917 km = (j ? i.substr(0, j) + thousands_sep : ''); 13918 kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep); 13919 kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, '0').slice(2) : ''); 13920 13921 return sign + km + kw + kd; 13922 }, 13923 13924 getExtension: function (url) 13925 { 13926 url = url || ""; 13927 var items = url.split("?")[0].split("."); 13928 return items[items.length-1].toLowerCase(); 13929 }, 13930 addObjectToForm: function(object, form, prefix) 13931 { 13932 if(!BX.type.isString(prefix)) 13933 { 13934 prefix = ""; 13935 } 13936 13937 for(var key in object) 13938 { 13939 if(!object.hasOwnProperty(key)) 13940 { 13941 continue; 13942 } 13943 13944 var value = object[key]; 13945 var name = prefix !== "" ? (prefix + "[" + key + "]") : key; 13946 if(BX.type.isArray(value)) 13947 { 13948 var obj = {}; 13949 for(var i = 0; i < value.length; i++) 13950 { 13951 obj[i] = value[i]; 13952 } 13953 13954 BX.util.addObjectToForm(obj, form, name); 13955 } 13956 else if(BX.type.isPlainObject(value)) 13957 { 13958 BX.util.addObjectToForm(value, form, name); 13959 } 13960 else 13961 { 13962 value = BX.type.isFunction(value.toString) ? value.toString() : ""; 13963 if(value !== "") 13964 { 13965 form.appendChild(BX.create("INPUT", { attrs: { type: "hidden", name: name, value: value } })); 13966 } 13967 } 13968 } 13969 }, 13970 13971 observe: function(object, enable) 13972 {
13973 console.error('BX.util.observe: function is no longer supported by browser.'); 13974 return false; 13975 }, 13976 13977 escapeRegExp: function(str) 13978 { 13979 return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); 13980 } 13981 }; 13982 13983 BX.validation = { 13984 checkIfEmail: function(s) 13985 { 13986 var atom = "[=a-z0-9_+~'!$&*^`|#%/?{}-]"; 13987 return (new RegExp('^\\s*'+atom+'+(\\.'+atom+'+)*@([a-z0-9-]+\\.)+[a-z0-9-]{2,20}\\s*$', 'i')).test(s); 13988 }, 13989 checkIfPhone: function(s) 13990 { 13991 var regexp = new RegExp( 13992 typeof(BX.PhoneNumber) === "undefined" 13993 ? BX.PhoneNumber.getValidNumberPattern() 13994 : '^\\s*\\+?\s*[0-9(-)\\s]+\\s*$', 13995 'i' 13996 ); 13997 return regexp.test(s); 13998 } 13999 }; 14000 14001 BX.prop = 14002 { 14003 get: function(object, key, defaultValue) 14004 { 14005 return object && object.hasOwnProperty(key) ? object[key] : defaultValue; 14006 }, 14007 getObject: function(object, key, defaultValue) 14008 { 14009 return object && BX.type.isPlainObject(object[key]) ? object[key] : defaultValue; 14010 }, 14011 getElementNode: function(object, key, defaultValue) 14012 { 14013 return object && BX.type.isElementNode(object[key]) ? object[key] : defaultValue; 14014 }, 14015 getArray: function(object, key, defaultValue) 14016 { 14017 return object && BX.type.isArray(object[key]) ? object[key] : defaultValue; 14018 }, 14019 getFunction: function(object, key, defaultValue) 14020 { 14021 return object && BX.type.isFunction(object[key]) ? object[key] : defaultValue; 14022 }, 14023 getNumber: function(object, key, defaultValue) 14024 { 14025 if(!(object && object.hasOwnProperty(key))) 14026 { 14027 return defaultValue; 14028 } 14029 14030 var value = object[key]; 14031 if(BX.type.isNumber(value)) 14032 { 14033 return value; 14034 } 14035 14036 value = parseFloat(value); 14037 return !isNaN(value) ? value : defaultValue; 14038 }, 14039 getInteger: function(object, key, defaultValue) 14040 { 14041 if(!(object && object.hasOwnProperty(key))) 14042 { 14043 return defaultValue; 14044 } 14045 14046 var value = object[key]; 14047 if(BX.type.isNumber(value)) 14048 { 14049 return value; 14050 } 14051 14052 value = parseInt(value); 14053 return !isNaN(value) ? value : defaultValue; 14054 }, 14055 getBoolean: function(object, key, defaultValue) 14056 { 14057 if(!(object && object.hasOwnProperty(key))) 14058 { 14059 return defaultValue; 14060 } 14061 14062 var value = object[key]; 14063 return (BX.type.isBoolean(value) 14064 ? value 14065 : (BX.type.isString(value) ? (value.toLowerCase() === "true") : !!value) 14066 ); 14067 }, 14068 getString: function(object, key, defaultValue) 14069 { 14070 if(!(object && object.hasOwnProperty(key))) 14071 { 14072 return defaultValue; 14073 } 14074 14075 var value = object[key]; 14076 return BX.type.isString(value) ? value : (value ? value.toString() : ''); 14077 }, 14078 extractDate: function(datetime) 14079 { 14080 if(!BX.type.isDate(datetime)) 14081 { 14082 datetime = new Date(); 14083 } 14084 14085 datetime.setHours(0); 14086 datetime.setMinutes(0); 14087 datetime.setSeconds(0); 14088 datetime.setMilliseconds(0); 14089 14090 return datetime; 14091 } 14092 }; 14093 14094 BX.isNodeInDom = function(node, doc) 14095 { 14096 return node === (doc || document) ? true : 14097 (node.parentNode ? BX.isNodeInDom(node.parentNode) : false); 14098 }; 14099 14100 BX.isNodeHidden = function(node) 14101 { 14102 if (node === document) 14103 return false; 14104 else if (BX.style(node, 'display') == 'none') 14105 return true; 14106 else 14107 return (node.parentNode ? BX.isNodeHidden(node.parentNode) : true); 14108 }; 14109 14110 BX.evalPack = function(code) 14111 { 14112 while (code.length > 0) 14113 { 14114 var c = code.shift(); 14115 14116 if (c.TYPE == 'SCRIPT_EXT' || c.TYPE == 'SCRIPT_SRC') 14117 { 14118 BX.loadScript(c.DATA, function() {BX.evalPack(code)}); 14119 return; 14120 } 14121 else if (c.TYPE == 'SCRIPT') 14122 { 14123 BX.evalGlobal(c.DATA); 14124 } 14125 } 14126 }; 14127 14128 BX.evalGlobal = function(data) 14129 { 14130 if (data) 14131 { 14132 var head = document.getElementsByTagName("head")[0] || document.documentElement, 14133 script = document.createElement("script"); 14134 14135 script.type = "text/javascript"; 14136 14137 if (!BX.browser.IsIE()) 14138 { 14139 script.appendChild(document.createTextNode(data)); 14140 } 14141 else 14142 { 14143 script.text = data; 14144 } 14145 14146 head.insertBefore(script, head.firstChild); 14147 head.removeChild(script); 14148 } 14149 }; 14150 14151 BX.garbage = function(call, thisObject) 14152 { 14153 garbageCollectors.push({callback: call, context: thisObject}); 14154 }; 14155 14156 BX.GetDocElement = function (pDoc) 14157 { 14158 pDoc = pDoc || document; 14159 return (BX.browser.IsDoctype(pDoc) ? pDoc.documentElement : pDoc.body); 14160 }; 14161 14162 BX.scrollTop = function(node, val){ 14163 if(typeof val != 'undefined'){ 14164 14165 if(node == window){ 14166 throw new Error('scrollTop() for window is not implemented'); 14167 }else 14168 node.scrollTop = parseInt(val); 14169 14170 }else{ 14171 14172 if(node == window) 14173 return BX.GetWindowScrollPos().scrollTop; 14174 14175 return node.scrollTop; 14176 } 14177 }; 14178 14179 BX.scrollLeft = function(node, val){ 14180 if(typeof val != 'undefined'){ 14181 14182 if(node == window){ 14183 throw new Error('scrollLeft() for window is not implemented'); 14184 }else 14185 node.scrollLeft = parseInt(val); 14186 14187 }else{ 14188 14189 if(node == window) 14190 return BX.GetWindowScrollPos().scrollLeft; 14191 14192 return node.scrollLeft; 14193 } 14194 }; 14195 14196 BX.hide_object = function(ob) 14197 { 14198 ob = BX(ob); 14199 ob.style.position = 'absolute'; 14200 ob.style.top = '-1000px'; 14201 ob.style.left = '-1000px'; 14202 ob.style.height = '10px'; 14203 ob.style.width = '10px'; 14204 }; 14205 14206 BX.is_relative = function(el) 14207 { 14208 var p = BX.style(el, 'position'); 14209 return p == 'relative' || p == 'absolute'; 14210 }; 14211 14212 BX.is_float = function(el) 14213 { 14214 var p = BX.style(el, 'float'); 14215 return p == 'right' || p == 'left'; 14216 }; 14217 14218 BX.is_fixed = function(el) 14219 { 14220 var p = BX.style(el, 'position'); 14221 return p == 'fixed'; 14222 }; 14223 14224 BX.width = function(node, val){ 14225 if(typeof val != 'undefined') 14226 BX.style(node, 'width', parseInt(val)+'px'); 14227 else{ 14228 14229 if(node == window) 14230 return window.innerWidth; 14231 14232 //return parseInt(BX.style(node, 'width')); 14233 return BX.pos(node).width; 14234 } 14235 }; 14236 14237 BX.height = function(node, val){ 14238 if(typeof val != 'undefined') 14239 BX.style(node, 'height', parseInt(val)+'px'); 14240 else{ 14241 14242 if(node == window) 14243 return window.innerHeight; 14244 14245 //return parseInt(BX.style(node, 'height')); 14246 return BX.pos(node).height; 14247 } 14248 }; 14249 14250 BX.align = function(pos, w, h, type) 14251 { 14252 if (type) 14253 type = type.toLowerCase(); 14254 else 14255 type = ''; 14256 14257 var pDoc = document; 14258 if (BX.type.isElementNode(pos)) 14259 { 14260 pDoc = pos.ownerDocument; 14261 pos = BX.pos(pos); 14262 } 14263 14264 var x = pos["left"], y = pos["bottom"]; 14265 14266 var scroll = BX.GetWindowScrollPos(pDoc); 14267 var size = BX.GetWindowInnerSize(pDoc); 14268 14269 if((size.innerWidth + scroll.scrollLeft) - (pos["left"] + w) < 0) 14270 { 14271 if(pos["right"] - w >= 0 ) 14272 x = pos["right"] - w; 14273 else 14274 x = scroll.scrollLeft; 14275 } 14276
14277 if(((size.innerHeight + scroll.scrollTop) - (pos["bottom"] + h) < 0) || ~type.indexOf('top')) 14278 { 14279 if(pos["top"] - h >= 0 || ~type.indexOf('top')) 14280 y = pos["top"] - h; 14281 else 14282 y = scroll.scrollTop; 14283 } 14284 14285 return {'left':x, 'top':y}; 14286 }; 14287 14288 BX.scrollToNode = function(node) 14289 { 14290 var obNode = BX(node); 14291 14292 if (obNode.scrollIntoView) 14293 obNode.scrollIntoView(true); 14294 else 14295 { 14296 var arNodePos = BX.pos(obNode); 14297 window.scrollTo(arNodePos.left, arNodePos.top); 14298 } 14299 }; 14300 14301 /* non-xhr loadings */ 14302 BX.showWait = function(node, msg) 14303 { 14304 node = BX(node) || document.body || document.documentElement; 14305 msg = msg || BX.message('JS_CORE_LOADING'); 14306 14307 var container_id = node.id || Math.random(); 14308 14309 var obMsg = node.bxmsg = document.body.appendChild(BX.create('DIV', { 14310 props: { 14311 id: 'wait_' + container_id 14312 }, 14313 style: { 14314 background: 'url("/bitrix/js/main/core/images/wait.gif") no-repeat scroll 10px center #fcf7d1', 14315 border: '1px solid #E1B52D', 14316 color: 'black', 14317 fontFamily: 'Verdana,Arial,sans-serif', 14318 fontSize: '11px', 14319 padding: '10px 30px 10px 37px', 14320 position: 'absolute', 14321 textAlign:'center' 14322 }, 14323 text: msg 14324 })); 14325 14326 BX.ZIndexManager.register(obMsg); 14327 BX.ZIndexManager.bringToFront(obMsg); 14328 14329 setTimeout(BX.delegate(_adjustWait, node), 10); 14330 14331 lastWait[lastWait.length] = obMsg; 14332 return obMsg; 14333 }; 14334 14335 BX.closeWait = function(node, obMsg) 14336 { 14337 if(node && !obMsg) 14338 obMsg = node.bxmsg; 14339 if(node && !obMsg && BX.hasClass(node, 'bx-core-waitwindow')) 14340 obMsg = node; 14341 if(node && !obMsg) 14342 obMsg = BX('wait_' + node.id); 14343 if(!obMsg) 14344 obMsg = lastWait.pop(); 14345 14346 if (obMsg && obMsg.parentNode) 14347 { 14348 for (var i=0,len=lastWait.length;i<len;i++) 14349 { 14350 if (obMsg == lastWait[i]) 14351 { 14352 lastWait = BX.util.deleteFromArray(lastWait, i); 14353 break; 14354 } 14355 } 14356 14357 BX.ZIndexManager.unregister(obMsg); 14358 obMsg.parentNode.removeChild(obMsg); 14359 if (node) node.bxmsg = null; 14360 BX.cleanNode(obMsg, true); 14361 } 14362 }; 14363 14364 BX.setJSList = function(scripts) 14365 { 14366 if (BX.type.isArray(scripts)) 14367 { 14368 scripts = scripts.map(function(script) { 14369 return normalizeUrl(script) 14370 }); 14371 14372 jsList = jsList.concat(scripts); 14373 } 14374 }; 14375 14376 BX.getJSList = function() 14377 { 14378 initJsList(); 14379 return jsList; 14380 }; 14381 14382 BX.setCSSList = function(cssFiles) 14383 { 14384 if (BX.type.isArray(cssFiles)) 14385 { 14386 cssFiles = cssFiles.map(function(cssFile) { 14387 return normalizeUrl(cssFile); 14388 }); 14389 14390 cssList = cssList.concat(cssFiles); 14391 } 14392 }; 14393 14394 BX.getCSSList = function() 14395 { 14396 initCssList(); 14397 return cssList; 14398 }; 14399 14400 BX.getJSPath = function(js) 14401 { 14402 return js.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 14403 }; 14404 14405 BX.getCSSPath = function(css) 14406 { 14407 return css.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 14408 }; 14409 14410 BX.getCDNPath = function(path) 14411 { 14412 return path; 14413 }; 14414 14415 BX.loadScript = function(script, callback, doc) 14416 { 14417 if (BX.type.isString(script)) 14418 { 14419 script = [script]; 14420 } 14421 14422 return BX.load(script, callback, doc); 14423 }; 14424 14425 BX.loadCSS = function(css, doc, win) 14426 { 14427 if (BX.type.isString(css)) 14428 { 14429 css = [css]; 14430 } 14431 14432 if (BX.type.isArray(css)) 14433 { 14434 css = css.map(function(url) { 14435 return { url: url, ext: "css" } 14436 }); 14437 14438 BX.load(css, null, doc); 14439 } 14440 }; 14441 14442 BX.load = function(items, callback, doc) 14443 { 14444 if (!BX.isReady) 14445 { 14446 var _args = arguments; 14447 BX.ready(function() { 14448 BX.load.apply(this, _args); 14449 }); 14450 return null; 14451 } 14452 14453 doc = doc || document; 14454 if (isAsync === null) 14455 { 14456 isAsync = "async" in doc.createElement("script") || "MozAppearance" in doc.documentElement.style || window.opera; 14457 } 14458 14459 return isAsync ? loadAsync(items, callback, doc) : loadAsyncEmulation(items, callback, doc); 14460 }; 14461 14462 BX.convert = 14463 { 14464 toNumber: function(value) 14465 { 14466 if(BX.type.isNumber(value)) 14467 { 14468 return value; 14469 } 14470 14471 value = Number(value); 14472 return !isNaN(value) ? value : 0; 14473 }, 14474 nodeListToArray: function(nodes) 14475 { 14476 try 14477 { 14478 return (Array.prototype.slice.call(nodes, 0)); 14479 } 14480 catch (ex) 14481 { 14482 var ary = []; 14483 for(var i = 0, l = nodes.length; i < l; i++) 14484 { 14485 ary.push(nodes[i]); 14486 } 14487 return ary; 14488 } 14489 } 14490 }; 14491 14492 function loadAsync(items, callback, doc) 14493 { 14494 if (!BX.type.isArray(items)) 14495 { 14496 return; 14497 } 14498 14499 function allLoaded(items) 14500 { 14501 items = items || assets; 14502 for (var name in items) 14503 { 14504 if (items.hasOwnProperty(name) && items[name].state !== LOADED) 14505 { 14506 return false;
14507 } 14508 } 14509 14510 return true; 14511 } 14512 14513 if (!BX.type.isFunction(callback)) 14514 { 14515 callback = null; 14516 } 14517 14518 var itemSet = {}, item, i; 14519 for (i = 0; i < items.length; i++) 14520 { 14521 item = items[i]; 14522 item = getAsset(item); 14523 itemSet[item.name] = item; 14524 } 14525 14526 var callbackWasCalled = false; 14527 if (items.length > 0) 14528 { 14529 for (i = 0; i < items.length; i++) 14530 { 14531 item = items[i]; 14532 item = getAsset(item); 14533 load(item, function () { 14534 if (allLoaded(itemSet)) 14535 { 14536 if (!callbackWasCalled) 14537 { 14538 callback && callback(); 14539 callbackWasCalled = true; 14540 } 14541 14542 } 14543 }, doc); 14544 } 14545 } 14546 else 14547 { 14548 if (typeof callback === 'function') 14549 { 14550 callback(); 14551 callbackWasCalled = true; 14552 } 14553 } 14554 } 14555 14556 function loadAsyncEmulation(items, callback, doc) 14557 { 14558 function onPreload(asset) 14559 { 14560 asset.state = PRELOADED; 14561 if (BX.type.isArray(asset.onpreload) && asset.onpreload) 14562 { 14563 for (var i = 0; i < asset.onpreload.length; i++) 14564 { 14565 asset.onpreload[i].call(); 14566 } 14567 } 14568 } 14569 14570 function preLoad(asset) 14571 { 14572 if (asset.state === undefined) 14573 { 14574 asset.state = PRELOADING; 14575 asset.onpreload = []; 14576 14577 loadAsset( 14578 { url: asset.url, type: "cache", ext: asset.ext}, 14579 function () { onPreload(asset); }, 14580 doc 14581 ); 14582 } 14583 } 14584 14585 if (!BX.type.isArray(items)) 14586 { 14587 return; 14588 } 14589 14590 if (!BX.type.isFunction(callback)) 14591 { 14592 callback = null; 14593 } 14594 14595 var rest = [].slice.call(items, 1); 14596 for (var i = 0; i < rest.length; i++) 14597 { 14598 preLoad(getAsset(rest[i])); 14599 } 14600 14601 load(getAsset(items[0]), items.length === 1 ? callback : function () { 14602 loadAsyncEmulation.apply(null, [rest, callback, doc]); 14603 }, doc); 14604 } 14605 14606 function load(asset, callback, doc) 14607 { 14608 callback = callback || BX.DoNothing; 14609 14610 if (asset.state === LOADED) 14611 { 14612 callback(); 14613 return; 14614 } 14615 14616 if (asset.state === PRELOADING) 14617 { 14618 asset.onpreload.push(function () { 14619 load(asset, callback, doc); 14620 }); 14621 return; 14622 } 14623 14624 asset.state = LOADING; 14625 14626 loadAsset( 14627 asset, 14628 function () { 14629 asset.state = LOADED; 14630 callback(); 14631 }, 14632 doc 14633 ); 14634 } 14635 14636 function loadAsset(asset, callback, doc) 14637 { 14638 callback = callback || BX.DoNothing; 14639 14640 function error(event) 14641 { 14642 ele.onload = ele.onreadystatechange = ele.onerror = null; 14643 callback(); 14644 } 14645 14646 function process(event) 14647 { 14648 event = event || window.event; 14649 if (event.type === "load" || (/loaded|complete/.test(ele.readyState) && (!doc.documentMode || doc.documentMode < 9))) 14650 { 14651 window.clearTimeout(asset.errorTimeout); 14652 window.clearTimeout(asset.cssTimeout); 14653 ele.onload = ele.onreadystatechange = ele.onerror = null; 14654 callback(); 14655 } 14656 } 14657 14658 function isCssLoaded() 14659 { 14660 if (asset.state !== LOADED && asset.cssRetries <= 20) 14661 { 14662 for (var i = 0, l = doc.styleSheets.length; i < l; i++) 14663 { 14664 if (doc.styleSheets[i].href === ele.href) 14665 { 14666 process({"type": "load"}); 14667 return; 14668 } 14669 } 14670 14671 asset.cssRetries++; 14672 asset.cssTimeout = window.setTimeout(isCssLoaded, 250); 14673 } 14674 } 14675 14676 var ele; 14677 var ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 14678 14679 if (ext === "css") 14680 { 14681 ele = doc.createElement("link"); 14682 ele.type = "text/" + (asset.type || "css"); 14683 ele.rel = "stylesheet"; 14684 ele.href = asset.url; 14685 14686 asset.cssRetries = 0; 14687 asset.cssTimeout = window.setTimeout(isCssLoaded, 500); 14688 } 14689 else 14690 { 14691 ele = doc.createElement("script"); 14692 ele.type = "text/" + (asset.type || "javascript"); 14693 ele.src = asset.url; 14694 } 14695 14696 ele.onload = ele.onreadystatechange = process; 14697 ele.onerror = error; 14698 14699 ele.async = false; 14700 ele.defer = false; 14701 14702 asset.errorTimeout = window.setTimeout(function () { 14703 error({type: "timeout"}); 14704 }, 7000); 14705 14706 if (ext === "css") 14707 { 14708 cssList.push(normalizeMinUrl(normalizeUrl(asset.url))); 14709 } 14710 else 14711 { 14712 jsList.push(normalizeMinUrl(normalizeUrl(asset.url))); 14713 } 14714 14715 var templateLink = null; 14716 var head = doc.head || doc.getElementsByTagName("head")[0]; 14717 if (ext === "css" && (templateLink = getTemplateLink(head)) !== null) 14718 { 14719 templateLink.parentNode.insertBefore(ele, templateLink); 14720 } 14721 else 14722 { 14723 head.insertBefore(ele, head.lastChild); 14724 } 14725 } 14726 14727 function getAsset(item) 14728 { 14729 var asset = {}; 14730 if (typeof item === "object") 14731 { 14732 asset = item; 14733 asset.name = asset.name ? asset.name : BX.util.hashCode(item.url); 14734 } 14735 else 14736 { 14737 asset = { name: BX.util.hashCode(item), url : item }; 14738 } 14739 14740 var ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 14741 if ((ext === "css" && isCssLoaded(asset.url)) || isScriptLoaded(asset.url)) 14742 { 14743 asset.state = LOADED; 14744 } 14745 14746 var existing = assets[asset.name]; 14747 if (existing && existing.url === asset.url) 14748 { 14749 return existing; 14750 } 14751 14752 assets[asset.name] = asset; 14753 return asset; 14754 } 14755 14756 function normalizeUrl(url) 14757 { 14758 if (!BX.type.isNotEmptyString(url)) 14759 { 14760 return ""; 14761 } 14762 14763 url = BX.getJSPath(url); 14764 url = url.replace(/\?[0-9]*$/, ""); 14765 14766 return url; 14767 } 14768 14769 function normalizeMinUrl(url) 14770 { 14771 if (!BX.type.isNotEmptyString(url)) 14772 { 14773 return ""; 14774 } 14775 14776 var minPos = url.indexOf(".min"); 14777 return minPos >= 0 ? url.substr(0, minPos) + url.substr(minPos + 4) : url; 14778 } 14779 14780 function isCssLoaded(fileSrc) 14781 { 14782 initCssList(); 14783 14784 fileSrc = normalizeUrl(fileSrc); 14785 var fileSrcMin = normalizeMinUrl(fileSrc); 14786 14787 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, cssList)) || BX.util.in_array(fileSrc, cssList); 14788 } 14789 14790 function initCssList() 14791 { 14792 if(!cssInit) 14793 { 14794 var linksCol = document.getElementsByTagName('link'); 14795 14796 if(!!linksCol && linksCol.length > 0) 14797 { 14798 for(var i = 0; i < linksCol.length; i++) 14799 { 14800 var href = linksCol[i].getAttribute('href'); 14801 if (BX.type.isNotEmptyString(href)) 14802 { 14803 href = normalizeMinUrl(normalizeUrl(href)); 14804 cssList.push(href); 14805 } 14806 } 14807 } 14808 cssInit = true; 14809 } 14810 } 14811 14812 function getTemplateLink(head) 14813 { 14814 var findLink = function(tag) 14815 { 14816 var links = head.getElementsByTagName(tag); 14817 for (var i = 0, length = links.length; i < length; i++) 14818 { 14819 var templateStyle = links[i].getAttribute("data-template-style"); 14820 if (BX.type.isNotEmptyString(templateStyle) && templateStyle == "true") 14821 { 14822 return links[i]; 14823 } 14824 } 14825 14826 return null; 14827 }; 14828 14829 var link = findLink("link"); 14830 if (link === null) 14831 { 14832 link = findLink("style"); 14833 } 14834 14835 return link; 14836 } 14837 14838 function isScriptLoaded(fileSrc) 14839 { 14840 initJsList(); 14841 14842 fileSrc = normalizeUrl(fileSrc); 14843 var fileSrcMin = normalizeMinUrl(fileSrc); 14844 14845 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, jsList)) || BX.util.in_array(fileSrc, jsList); 14846 } 14847 14848 function initJsList() 14849 { 14850 if(!jsInit) 14851 { 14852 var scriptCol = document.getElementsByTagName('script'); 14853 14854 if(!!scriptCol && scriptCol.length > 0) 14855 { 14856 for(var i=0; i<scriptCol.length; i++) 14857 { 14858 var src = scriptCol[i].getAttribute('src'); 14859 14860 if (BX.type.isNotEmptyString(src)) 14861 { 14862 src = normalizeMinUrl(normalizeUrl(src)); 14863 jsList.push(src); 14864 } 14865 } 14866 } 14867 jsInit = true; 14868 } 14869 } 14870 14871 function reloadInternal(back_url, bAddClearCache) 14872 { 14873 if (back_url === true) 14874 { 14875 bAddClearCache = true; 14876 back_url = null; 14877 } 14878 14879 var topWindow = (function() { 14880 if (BX.PageObject && BX.PageObject.getRootWindow) 14881 { 14882 return BX.PageObject.getRootWindow(); 14883 } 14884 14885 return window.top; 14886 })(); 14887 var new_href = back_url || topWindow.location.href; 14888 14889 var hashpos = new_href.indexOf('#'), hash = ''; 14890 14891 if (hashpos != -1) 14892 { 14893 hash = new_href.substr(hashpos); 14894 new_href = new_href.substr(0, hashpos); 14895 } 14896 14897 if (bAddClearCache && new_href.indexOf('clear_cache=Y') < 0) 14898 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + 'clear_cache=Y'; 14899 14900 if (hash) 14901 { 14902 // hack for clearing cache in ajax mode components with history emulation 14903 if (bAddClearCache && (hash.substr(0, 5) == 'view/' || hash.substr(0, 6) == '#view/') && hash.indexOf('clear_cache%3DY') < 0) 14904 hash += (hash.indexOf('%3F') == -1 ? '%3F' : '%26') + 'clear_cache%3DY'; 14905 14906 new_href = new_href.replace(/(\?|\&)_r=[\d]*/, ''); 14907 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + '_r='+Math.round(Math.random()*10000) + hash; 14908 } 14909 14910 topWindow.location.href = new_href; 14911 } 14912 14913 BX.reload = function(back_url, bAddClearCache) 14914 { 14915 if (window !== window.top) 14916 { 14917 BX.Runtime 14918 .loadExtension('main.pageobject') 14919 .then(function() { 14920 reloadInternal(back_url, bAddClearCache); 14921 }); 14922 } 14923 else 14924 { 14925 reloadInternal(back_url, bAddClearCache); 14926 } 14927 }; 14928 14929 BX.clearCache = function() 14930 { 14931 BX.showWait(); 14932 BX.reload(true); 14933 }; 14934 14935 BX.template = function(tpl, callback, bKillTpl) 14936 { 14937 BX.ready(function() { 14938 _processTpl(BX(tpl), callback, bKillTpl); 14939 }); 14940 }; 14941 14942 BX.isAmPmMode = function(returnConst) 14943 { 14944 if (returnConst === true) 14945 { 14946 return BX.message.AMPM_MODE; 14947 } 14948 return BX.message.AMPM_MODE !== false; 14949 }; 14950 14951 BX.formatDate = function(date, format) 14952 { 14953 date = date || new Date(); 14954 14955 var bTime = date.getHours() || date.getMinutes() || date.getSeconds(), 14956 str = !!format 14957 ? format : 14958 (bTime ? BX.message('FORMAT_DATETIME') : BX.message('FORMAT_DATE') 14959 ); 14960 14961 return str.replace(/YYYY/ig, date.getFullYear()) 14962 .replace(/MMMM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14963 .replace(/MM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14964 .replace(/DD/ig, BX.util.str_pad_left(date.getDate().toString(), 2, '0')) 14965 .replace(/HH/ig, BX.util.str_pad_left(date.getHours().toString(), 2, '0')) 14966 .replace(/MI/ig, BX.util.str_pad_left(date.getMinutes().toString(), 2, '0')) 14967 .replace(/SS/ig, BX.util.str_pad_left(date.getSeconds().toString(), 2, '0')); 14968 }; 14969 BX.formatName = function(user, template, login) 14970 { 14971 user = user || {}; 14972 template = (template || ''); 14973 var replacement = { 14974 TITLE : (user["TITLE"] || ''), 14975 NAME : (user["NAME"] || ''),
14976 LAST_NAME : (user["LAST_NAME"] || ''), 14977 SECOND_NAME : (user["SECOND_NAME"] || ''), 14978 LOGIN : (user["LOGIN"] || ''), 14979 NAME_SHORT : user["NAME"] ? user["NAME"].substr(0, 1) + '.' : '', 14980 LAST_NAME_SHORT : user["LAST_NAME"] ? user["LAST_NAME"].substr(0, 1) + '.' : '', 14981 SECOND_NAME_SHORT : user["SECOND_NAME"] ? user["SECOND_NAME"].substr(0, 1) + '.' : '', 14982 EMAIL : (user["EMAIL"] || ''), 14983 ID : (user["ID"] || ''), 14984 NOBR : "", 14985 '/NOBR' : "" 14986 }, result = template; 14987 for (var ii in replacement) 14988 { 14989 if (replacement.hasOwnProperty(ii)) 14990 { 14991 result = result.replace("#" + ii+ "#", replacement[ii]) 14992 } 14993 } 14994 result = result.replace(/([\s]+)/gi, " ").trim(); 14995 if (result == "") 14996 { 14997 result = (login == "Y" ? replacement["LOGIN"] : ""); 14998 result = (result == "" ? "Noname" : result); 14999 } 15000 return result; 15001 }; 15002 15003 BX.getNumMonth = function(month) 15004 { 15005 var wordMonthCut = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; 15006 var wordMonth = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']; 15007 15008 var q = month.toUpperCase(); 15009 for (i = 1; i <= 12; i++) 15010 { 15011 if (q == BX.message('MON_'+i).toUpperCase() || q == BX.message('MONTH_'+i).toUpperCase() || q == wordMonthCut[i-1].toUpperCase() || q == wordMonth[i-1].toUpperCase()) 15012 { 15013 return i; 15014 } 15015 } 15016 return month; 15017 }; 15018 15019 BX.parseDate = function(str, bUTC, formatDate, formatDatetime) 15020 { 15021 if (BX.type.isNotEmptyString(str)) 15022 { 15023 if (!formatDate) 15024 formatDate = BX.message('FORMAT_DATE'); 15025 if (!formatDatetime) 15026 formatDatetime = BX.message('FORMAT_DATETIME'); 15027 15028 var regMonths = ''; 15029 for (i = 1; i <= 12; i++) 15030 { 15031 regMonths = regMonths + '|' + BX.message('MON_'+i); 15032 } 15033
15034 var expr = new RegExp('([0-9]+|[a-z]+' + regMonths + ')', 'ig'); 15035 var aDate = str.match(expr), 15036 aFormat = formatDate.match(/(DD|MI|MMMM|MM|M|YYYY)/ig), 15037 i, cnt, 15038 aDateArgs=[], aFormatArgs=[], 15039 aResult={}; 15040 15041 if (!aDate) 15042 return null; 15043 15044 if(aDate.length > aFormat.length) 15045 { 15046 aFormat = formatDatetime.match(/(DD|MI|MMMM|MM|M|YYYY|HH|H|SS|TT|T|GG|G)/ig); 15047 } 15048 15049 for(i = 0, cnt = aDate.length; i < cnt; i++) 15050 { 15051 if(BX.util.trim(aDate[i]) != '') 15052 { 15053 aDateArgs[aDateArgs.length] = aDate[i]; 15054 } 15055 } 15056 15057 for(i = 0, cnt = aFormat.length; i < cnt; i++) 15058 { 15059 if(BX.util.trim(aFormat[i]) != '') 15060 { 15061 aFormatArgs[aFormatArgs.length] = aFormat[i]; 15062 } 15063 } 15064 15065 15066 var m = BX.util.array_search('MMMM', aFormatArgs); 15067 if (m > 0) 15068 { 15069 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 15070 aFormatArgs[m] = "MM"; 15071 } 15072 else 15073 { 15074 m = BX.util.array_search('M', aFormatArgs); 15075 if (m > 0) 15076 { 15077 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 15078 aFormatArgs[m] = "MM"; 15079 } 15080 } 15081 15082 for(i = 0, cnt = aFormatArgs.length; i < cnt; i++) 15083 { 15084 var k = aFormatArgs[i].toUpperCase(); 15085 aResult[k] = k == 'T' || k == 'TT' ? aDateArgs[i] : parseInt(aDateArgs[i], 10); 15086 } 15087 15088 if(aResult['DD'] > 0 && aResult['MM'] > 0 && aResult['YYYY'] > 0) 15089 { 15090 var d = new Date(); 15091 15092 if(bUTC) 15093 { 15094 d.setUTCDate(1); 15095 d.setUTCFullYear(aResult['YYYY']); 15096 d.setUTCMonth(aResult['MM'] - 1); 15097 d.setUTCDate(aResult['DD']); 15098 d.setUTCHours(0, 0, 0, 0); 15099 } 15100 else 15101 { 15102 d.setDate(1); 15103 d.setFullYear(aResult['YYYY']); 15104 d.setMonth(aResult['MM'] - 1); 15105 d.setDate(aResult['DD']); 15106 d.setHours(0, 0, 0, 0); 15107 } 15108 15109 if( 15110 (!isNaN(aResult['HH']) || !isNaN(aResult['GG']) || !isNaN(aResult['H']) || !isNaN(aResult['G'])) 15111 && !isNaN(aResult['MI']) 15112 ) 15113 { 15114 if (!isNaN(aResult['H']) || !isNaN(aResult['G'])) 15115 { 15116 var bPM = (aResult['T']||aResult['TT']||'am').toUpperCase()=='PM'; 15117 var h = parseInt(aResult['H']||aResult['G']||0, 10); 15118 if(bPM) 15119 { 15120 aResult['HH'] = h + (h == 12 ? 0 : 12); 15121 } 15122 else 15123 { 15124 aResult['HH'] = h < 12 ? h : 0; 15125 } 15126 } 15127 else 15128 { 15129 aResult['HH'] = parseInt(aResult['HH']||aResult['GG']||0, 10); 15130 } 15131 15132 if (isNaN(aResult['SS'])) 15133 aResult['SS'] = 0; 15134 15135 if(bUTC) 15136 { 15137 d.setUTCHours(aResult['HH'], aResult['MI'], aResult['SS']); 15138 } 15139 else 15140 { 15141 d.setHours(aResult['HH'], aResult['MI'], aResult['SS']); 15142 } 15143 } 15144 15145 return d; 15146 } 15147 } 15148 15149 return null; 15150 }; 15151 15152 BX.selectUtils = 15153 { 15154 addNewOption: function(oSelect, opt_value, opt_name, do_sort, check_unique) 15155 { 15156 oSelect = BX(oSelect); 15157 if(oSelect) 15158 { 15159 var n = oSelect.length; 15160 if(check_unique !== false) 15161 { 15162 for(var i=0;i<n;i++) 15163 { 15164 if(oSelect[i].value==opt_value) 15165 { 15166 return; 15167 } 15168 } 15169 } 15170 15171 oSelect.options[n] = new Option(opt_name, opt_value, false, false); 15172 } 15173 15174 if(do_sort === true) 15175 { 15176 this.sortSelect(oSelect); 15177 } 15178 }, 15179 15180 deleteOption: function(oSelect, opt_value) 15181 { 15182 oSelect = BX(oSelect); 15183 if(oSelect) 15184 { 15185 for(var i=0;i<oSelect.length;i++) 15186 { 15187 if(oSelect[i].value==opt_value) 15188 { 15189 oSelect.remove(i); 15190 break; 15191 } 15192 } 15193 } 15194 }, 15195 15196 deleteSelectedOptions: function(oSelect) 15197 { 15198 oSelect = BX(oSelect); 15199 if(oSelect) 15200 { 15201 var i=0; 15202 while(i<oSelect.length) 15203 { 15204 if(oSelect[i].selected) 15205 { 15206 oSelect[i].selected=false; 15207 oSelect.remove(i); 15208 } 15209 else 15210 { 15211 i++; 15212 } 15213 } 15214 } 15215 }, 15216 15217 deleteAllOptions: function(oSelect) 15218 { 15219 oSelect = BX(oSelect); 15220 if(oSelect) 15221 { 15222 for(var i=oSelect.length-1; i>=0; i--) 15223 { 15224 oSelect.remove(i); 15225 } 15226 } 15227 }, 15228 15229 optionCompare: function(record1, record2) 15230 { 15231 var value1 = record1.optText.toLowerCase(); 15232 var value2 = record2.optText.toLowerCase(); 15233 if (value1 > value2) return(1); 15234 if (value1 < value2) return(-1); 15235 return(0); 15236 }, 15237 15238 sortSelect: function(oSelect) 15239 { 15240 oSelect = BX(oSelect); 15241 if(oSelect) 15242 { 15243 var myOptions = []; 15244 var n = oSelect.options.length; 15245 var i; 15246 for (i=0;i<n;i++) 15247 { 15248 myOptions[i] = { 15249 optText:oSelect[i].text, 15250 optValue:oSelect[i].value 15251 }; 15252 } 15253 myOptions.sort(this.optionCompare); 15254 oSelect.length=0; 15255 n = myOptions.length; 15256 for(i=0;i<n;i++) 15257 { 15258 oSelect[i] = new Option(myOptions[i].optText, myOptions[i].optValue, false, false); 15259 } 15260 } 15261 }, 15262 15263 selectAllOptions: function(oSelect) 15264 { 15265 oSelect = BX(oSelect); 15266 if(oSelect) 15267 { 15268 var n = oSelect.length; 15269 for(var i=0;i<n;i++) 15270 { 15271 oSelect[i].selected=true; 15272 } 15273 } 15274 }, 15275 15276 selectOption: function(oSelect, opt_value) 15277 { 15278 oSelect = BX(oSelect); 15279 if(oSelect) 15280 { 15281 var n = oSelect.length; 15282 for(var i=0;i<n;i++) 15283 { 15284 oSelect[i].selected = (oSelect[i].value == opt_value); 15285 } 15286 } 15287 }, 15288 15289 addSelectedOptions: function(oSelect, to_select_id, check_unique, do_sort) 15290 { 15291 oSelect = BX(oSelect); 15292 if(!oSelect) 15293 return; 15294 var n = oSelect.length; 15295 for(var i=0; i<n; i++) 15296 if(oSelect[i].selected) 15297 this.addNewOption(to_select_id, oSelect[i].value, oSelect[i].text, do_sort, check_unique); 15298 }, 15299 15300 moveOptionsUp: function(oSelect) 15301 { 15302 oSelect = BX(oSelect); 15303 if(!oSelect) 15304 return; 15305 var n = oSelect.length; 15306 for(var i=0; i<n; i++) 15307 { 15308 if(oSelect[i].selected && i>0 && oSelect[i-1].selected == false) 15309 { 15310 var option = new Option(oSelect[i].text, oSelect[i].value); 15311 oSelect[i] = new Option(oSelect[i-1].text, oSelect[i-1].value); 15312 oSelect[i].selected = false;
15313 oSelect[i-1] = option; 15314 oSelect[i-1].selected = true; 15315 } 15316 } 15317 }, 15318 15319 moveOptionsDown: function(oSelect) 15320 { 15321 oSelect = BX(oSelect); 15322 if(!oSelect) 15323 return; 15324 var n = oSelect.length; 15325 for(var i=n-1; i>=0; i--) 15326 { 15327 if(oSelect[i].selected && i<n-1 && oSelect[i+1].selected == false) 15328 { 15329 var option = new Option(oSelect[i].text, oSelect[i].value); 15330 oSelect[i] = new Option(oSelect[i+1].text, oSelect[i+1].value); 15331 oSelect[i].selected = false; 15332 oSelect[i+1] = option; 15333 oSelect[i+1].selected = true; 15334 } 15335 } 15336 } 15337 }; 15338 15339 BX.getEventTarget = function(e) 15340 { 15341 if(e.target) 15342 { 15343 return e.target; 15344 } 15345 else if(e.srcElement) 15346 { 15347 return e.srcElement; 15348 } 15349 return null; 15350 }; 15351 15352 /******* HINT ***************/ 15353// if function has 2 params - the 2nd one is hint html. otherwise hint_html is third and hint_title - 2nd; 15354// '<div onmouseover="BX.hint(this, 'This is <b>Hint</b>')"'>; 15355// BX.hint(el, 'This is <b>Hint</b>') - this won't work, use constructor 15356 BX.hint = function(el, hint_title, hint_html, hint_id) 15357 { 15358 if (null == hint_html) 15359 { 15360 hint_html = hint_title; 15361 hint_title = ''; 15362 } 15363 15364 if (null == el.BXHINT) 15365 { 15366 el.BXHINT = new BX.CHint({ 15367 parent: el, hint: hint_html, title: hint_title, id: hint_id 15368 }); 15369 el.BXHINT.Show(); 15370 } 15371 }; 15372 15373 BX.hint_replace = function(el, hint_title, hint_html) 15374 { 15375 if (null == hint_html) 15376 { 15377 hint_html = hint_title; 15378 hint_title = ''; 15379 } 15380 15381 if (!el || !el.parentNode || !hint_html) 15382 return null; 15383 15384 var obHint = new BX.CHint({ 15385 hint: hint_html, 15386 title: hint_title 15387 }); 15388 15389 obHint.CreateParent(); 15390 15391 el.parentNode.insertBefore(obHint.PARENT, el); 15392 el.parentNode.removeChild(el); 15393 15394 obHint.PARENT.style.marginLeft = '5px'; 15395 15396 return el; 15397 }; 15398 15399 BX.CHint = function(params) 15400 { 15401 if (BX.CHint.cssLoaded === false) 15402 { 15403 BX.load(['/bitrix/js/main/core/css/core_hint.css']); 15404 BX.CHint.cssLoaded = true; 15405 } 15406 15407 this.PARENT = BX(params.parent); 15408 15409 this.HINT = params.hint; 15410 this.HINT_TITLE = params.title; 15411 15412 this.PARAMS = {}; 15413 for (var i in this.defaultSettings) 15414 { 15415 if (null == params[i]) 15416 this.PARAMS[i] = this.defaultSettings[i]; 15417 else 15418 this.PARAMS[i] = params[i]; 15419 } 15420 15421 if (null != params.id) 15422 this.ID = params.id; 15423 15424 this.timer = null; 15425 this.bInited = false; 15426 this.msover = true; 15427 15428 if (this.PARAMS.showOnce) 15429 { 15430 this.__show(); 15431 this.msover = false; 15432 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 15433 } 15434 else if (this.PARENT) 15435 { 15436 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 15437 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 15438 } 15439 }; 15440 15441 BX.CHint.cssLoaded = false; 15442 15443 BX.CHint.openHints = new Set(); 15444 15445 BX.CHint.globalDisabled = false; 15446 15447 BX.CHint.handleMenuOpen = function() { 15448 BX.CHint.globalDisabled = true; 15449 15450 BX.CHint.openHints.forEach(function(hint) { 15451 hint.__hide_immediately(); 15452 }); 15453 }; 15454 15455 BX.CHint.handleMenuClose = function() { 15456 BX.CHint.globalDisabled = false; 15457 }; 15458 15459 BX.addCustomEvent('onMenuOpen', BX.CHint.handleMenuOpen); 15460 BX.addCustomEvent('onMenuClose', BX.CHint.handleMenuClose); 15461 15462 BX.CHint.prototype.defaultSettings = { 15463 show_timeout: 1000, 15464 hide_timeout: 500, 15465 dx: 2, 15466 showOnce: false, 15467 preventHide: true, 15468 min_width: 250 15469 }; 15470 15471 BX.CHint.prototype.CreateParent = function(element, params) 15472 { 15473 if (this.PARENT) 15474 { 15475 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 15476 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 15477 } 15478 15479 if (!params) params = {}; 15480 var type = 'icon'; 15481 15482 if (params.type && (params.type == "link" || params.type == "icon")) 15483 type = params.type; 15484 15485 if (element) 15486 type = "element"; 15487 15488 if (type == "icon") 15489 { 15490 element = BX.create('IMG', { 15491 props: { 15492 src: params.iconSrc 15493 ? params.iconSrc 15494 : "/bitrix/js/main/core/images/hint.gif" 15495 } 15496 }); 15497 } 15498 else if (type == "link") 15499 { 15500 element = BX.create("A", { 15501 props: {href: 'javascript:void(0)'}, 15502 html: '[?]' 15503 }); 15504 } 15505 15506 this.PARENT = element; 15507 15508 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 15509 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 15510 15511 return this.PARENT; 15512 }; 15513 15514 BX.CHint.prototype.Show = function() 15515 { 15516 this.msover = true; 15517 15518 if (null != this.timer) 15519 clearTimeout(this.timer); 15520 15521 this.timer = setTimeout(BX.proxy(this.__show, this), this.PARAMS.show_timeout); 15522 }; 15523 15524 BX.CHint.prototype.Hide = function() 15525 { 15526 this.msover = false;
15527 15528 if (null != this.timer) 15529 clearTimeout(this.timer); 15530 15531 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 15532 }; 15533 15534 BX.CHint.prototype.__show = function() 15535 { 15536 if (!this.msover || this.disabled || BX.CHint.globalDisabled) return; 15537 if (!this.bInited) this.Init(); 15538 15539 if (this.prepareAdjustPos()) 15540 { 15541 this.DIV.style.display = 'block'; 15542 BX.ZIndexManager.bringToFront(this.DIV); 15543 15544 this.adjustPos(); 15545 15546 BX.CHint.openHints.add(this); 15547 15548 BX.bind(window, 'scroll', BX.proxy(this.__onscroll, this)); 15549 15550 if (this.PARAMS.showOnce) 15551 { 15552 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 15553 } 15554 } 15555 }; 15556 15557 BX.CHint.prototype.__onscroll = function() 15558 { 15559 if (!BX.admin || !BX.admin.panel || !BX.admin.panel.isFixed()) return; 15560 15561 if (this.scrollTimer) clearTimeout(this.scrollTimer); 15562 15563 this.DIV.style.display = 'none'; 15564 this.scrollTimer = setTimeout(BX.proxy(this.Reopen, this), this.PARAMS.show_timeout); 15565 }; 15566 15567 BX.CHint.prototype.Reopen = function() 15568 { 15569 if (null != this.timer) clearTimeout(this.timer); 15570 this.timer = setTimeout(BX.proxy(this.__show, this), 50); 15571 }; 15572 15573 BX.CHint.prototype.__hide = function() 15574 { 15575 if (this.msover) return; 15576 if (!this.bInited) return; 15577 15578 BX.unbind(window, 'scroll', BX.proxy(this.Reopen, this)); 15579 15580 BX.CHint.openHints.delete(this); 15581 15582 if (this.PARAMS.showOnce) 15583 { 15584 this.Destroy(); 15585 } 15586 else 15587 { 15588 this.DIV.style.display = 'none'; 15589 } 15590 }; 15591 15592 BX.CHint.prototype.__hide_immediately = function() 15593 { 15594 this.msover = false; 15595 this.__hide(); 15596 }; 15597 15598 BX.CHint.prototype.Init = function() 15599 { 15600 this.DIV = document.body.appendChild(BX.create('DIV', { 15601 props: {className: 'bx-panel-tooltip'}, 15602 style: { 15603 display: 'none', 15604 position: 'absolute', 15605 visibility: 'hidden' 15606 }, 15607 children: [ 15608 (this.CONTENT = BX.create('DIV', { 15609 props: {className: 'bx-panel-tooltip-content'}, 15610 children: [ 15611 BX.create('DIV', { 15612 props: {className: 'bx-panel-tooltip-underlay'}, 15613 children: [ 15614 BX.create('DIV', {props: {className: 'bx-panel-tooltip-underlay-bg'}}) 15615 ] 15616 }) 15617 ] 15618 })) 15619 ] 15620 })); 15621 15622 BX.ZIndexManager.register(this.DIV); 15623 15624 if (this.ID) 15625 { 15626 this.CONTENT.insertBefore(BX.create('A', { 15627 attrs: {href: 'javascript:void(0)'}, 15628 props: {className: 'bx-panel-tooltip-close'}, 15629 events: {click: BX.delegate(this.Close, this)} 15630 }), this.CONTENT.firstChild); 15631 } 15632 15633 if (this.HINT_TITLE) 15634 { 15635 this.CONTENT.appendChild( 15636 BX.create('DIV', { 15637 props: {className: 'bx-panel-tooltip-title'}, 15638 text: this.HINT_TITLE 15639 }) 15640 ); 15641 } 15642 15643 if (this.HINT) 15644 { 15645 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 15646 } 15647 15648 if (this.PARAMS.preventHide) 15649 { 15650 BX.bind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 15651 BX.bind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 15652 } 15653 15654 this.bInited = true; 15655 }; 15656 15657 BX.CHint.prototype.setContent = function(content) 15658 { 15659 this.HINT = content; 15660 15661 if (this.CONTENT_TEXT) 15662 this.CONTENT_TEXT.innerHTML = this.HINT; 15663 else 15664 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 15665 }; 15666 15667 BX.CHint.prototype.prepareAdjustPos = function() 15668 { 15669 this._wnd = {scrollPos: BX.GetWindowScrollPos(),scrollSize:BX.GetWindowScrollSize()}; 15670 return BX.style(this.PARENT, 'display') != 'none'; 15671 }; 15672 15673 BX.CHint.prototype.getAdjustPos = function() 15674 { 15675 var res = {}, pos = BX.pos(this.PARENT), min_top = 0; 15676 15677 res.top = pos.bottom + this.PARAMS.dx; 15678 15679 if (BX.admin && BX.admin.panel.DIV) 15680 { 15681 min_top = BX.admin.panel.DIV.offsetHeight + this.PARAMS.dx; 15682 15683 if (BX.admin.panel.isFixed()) 15684 { 15685 min_top += this._wnd.scrollPos.scrollTop; 15686 } 15687 } 15688 15689 if (res.top < min_top) 15690 res.top = min_top; 15691 else 15692 { 15693 if (res.top + this.DIV.offsetHeight > this._wnd.scrollSize.scrollHeight) 15694 res.top = pos.top - this.PARAMS.dx - this.DIV.offsetHeight; 15695 } 15696 15697 res.left = pos.left; 15698 if (pos.left < this.PARAMS.dx) 15699 pos.left = this.PARAMS.dx; 15700 else 15701 { 15702 var floatWidth = this.DIV.offsetWidth; 15703 15704 var max_left = this._wnd.scrollSize.scrollWidth - floatWidth - this.PARAMS.dx; 15705 15706 if (res.left > max_left) 15707 res.left = max_left; 15708 } 15709 15710 return res; 15711 }; 15712 15713 BX.CHint.prototype.adjustWidth = function() 15714 { 15715 if (this.bWidthAdjusted) return; 15716 15717 var w = this.DIV.offsetWidth, h = this.DIV.offsetHeight; 15718 15719 if (w > this.PARAMS.min_width) 15720 w = Math.round(Math.sqrt(1.618*w*h)); 15721 15722 if (w < this.PARAMS.min_width) 15723 w = this.PARAMS.min_width; 15724 15725 this.DIV.style.width = w + "px"; 15726 15727 if (this._adjustWidthInt) 15728 clearInterval(this._adjustWidthInt); 15729 this._adjustWidthInt = setInterval(BX.delegate(this._adjustWidthInterval, this), 5); 15730 15731 this.bWidthAdjusted = true; 15732 }; 15733 15734 BX.CHint.prototype._adjustWidthInterval = function() 15735 { 15736 if (!this.DIV || this.DIV.style.display == 'none') 15737 clearInterval(this._adjustWidthInt); 15738 15739 var
15740 dW = 20, 15741 maxWidth = 1500, 15742 w = this.DIV.offsetWidth, 15743 w1 = this.CONTENT_TEXT.offsetWidth; 15744 15745 if (w > 0 && w1 > 0 && w - w1 < dW && w < maxWidth) 15746 { 15747 this.DIV.style.width = (w + dW) + "px"; 15748 return; 15749 } 15750 15751 clearInterval(this._adjustWidthInt); 15752 }; 15753 15754 BX.CHint.prototype.adjustPos = function() 15755 { 15756 this.adjustWidth(); 15757 15758 var pos = this.getAdjustPos(); 15759 15760 this.DIV.style.top = pos.top + 'px'; 15761 this.DIV.style.left = pos.left + 'px'; 15762 }; 15763 15764 BX.CHint.prototype.Close = function() 15765 { 15766 if (this.ID && BX.WindowManager) 15767 BX.WindowManager.saveWindowOptions(this.ID, {display: 'off'}); 15768 this.__hide_immediately(); 15769 this.Destroy(); 15770 }; 15771 15772 BX.CHint.prototype.Destroy = function() 15773 { 15774 if (this.PARENT) 15775 { 15776 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 15777 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 15778 } 15779 15780 if (this.DIV) 15781 { 15782 BX.unbind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 15783 BX.unbind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 15784 15785 BX.ZIndexManager.unregister(this.DIV); 15786 15787 BX.cleanNode(this.DIV, true); 15788 } 15789 }; 15790 15791 BX.CHint.prototype.enable = function(){this.disabled = false;}; 15792 BX.CHint.prototype.disable = function(){this.__hide_immediately(); this.disabled = true;}; 15793 15794 15795 function _adjustWait() 15796 { 15797 if (!this.bxmsg) return; 15798 15799 var arContainerPos = BX.pos(this), 15800 div_top = arContainerPos.top; 15801 15802 if (div_top < BX.GetDocElement().scrollTop) 15803 div_top = BX.GetDocElement().scrollTop + 5; 15804 15805 this.bxmsg.style.top = (div_top + 5) + 'px'; 15806 15807 if (this == BX.GetDocElement()) 15808 { 15809 this.bxmsg.style.right = '5px'; 15810 } 15811 else 15812 { 15813 this.bxmsg.style.left = (arContainerPos.right - this.bxmsg.offsetWidth - 5) + 'px'; 15814 } 15815 } 15816 15817 function _processTpl(tplNode, cb, bKillTpl) 15818 { 15819 if (tplNode) 15820 { 15821 if (bKillTpl) 15822 tplNode.parentNode.removeChild(tplNode); 15823 15824 var res = {}, nodes = BX.findChildren(tplNode, {attribute: 'data-role'}, true); 15825 15826 for (var i = 0, l = nodes.length; i < l; i++) 15827 { 15828 res[nodes[i].getAttribute('data-role')] = nodes[i]; 15829 } 15830 15831 cb.apply(tplNode, [res]); 15832 } 15833 } 15834 15835 function _checkNode(obj, params) 15836 { 15837 params = params || {}; 15838 15839 if (BX.type.isFunction(params)) 15840 return params.call(window, obj); 15841 15842 if (!params.allowTextNodes && !BX.type.isElementNode(obj)) 15843 return false; 15844 var i,j,len; 15845 for (i in params) 15846 { 15847 if(params.hasOwnProperty(i)) 15848 { 15849 switch(i) 15850 { 15851 case 'tag': 15852 case 'tagName': 15853 if (BX.type.isString(params[i])) 15854 { 15855 if (obj.tagName.toUpperCase() != params[i].toUpperCase()) 15856 return false; 15857 } 15858 else if (params[i] instanceof RegExp) 15859 { 15860 if (!params[i].test(obj.tagName)) 15861 return false; 15862 } 15863 break; 15864 15865 case 'class': 15866 case 'className': 15867 if (BX.type.isString(params[i])) 15868 { 15869 if (!BX.hasClass(obj, params[i])) 15870 return false; 15871 } 15872 else if (params[i] instanceof RegExp) 15873 { 15874 if (!BX.type.isString(obj.className) || !params[i].test(obj.className)) 15875 return false; 15876 } 15877 break; 15878 15879 case 'attr': 15880 case 'attrs': 15881 case 'attribute': 15882 if (BX.type.isString(params[i])) 15883 { 15884 if (!obj.getAttribute(params[i])) 15885 return false; 15886 } 15887 else if (BX.type.isArray(params[i])) 15888 { 15889 for (j = 0, len = params[i].length; j < len; j++) 15890 { 15891 if (params[i] && !obj.getAttribute(params[i])) 15892 return false; 15893 } 15894 } 15895 else 15896 { 15897 for (j in params[i]) 15898 { 15899 if(params[i].hasOwnProperty(j)) 15900 { 15901 var q = obj.getAttribute(j); 15902 if (params[i][j] instanceof RegExp) 15903 { 15904 if (!BX.type.isString(q) || !params[i][j].test(q)) 15905 { 15906 return false; 15907 } 15908 } 15909 else 15910 { 15911 if (q != '' + params[i][j]) 15912 { 15913 return false; 15914 } 15915 } 15916 } 15917 } 15918 } 15919 break; 15920 15921 case 'property': 15922 case 'props': 15923 if (BX.type.isString(params[i])) 15924 { 15925 if (!obj[params[i]]) 15926 return false; 15927 } 15928 else if (BX.type.isArray(params[i])) 15929 { 15930 for (j = 0, len = params[i].length; j < len; j++) 15931 { 15932 if (params[i] && !obj[params[i]]) 15933 return false;
15934 } 15935 } 15936 else 15937 { 15938 for (j in params[i]) 15939 { 15940 if (BX.type.isString(params[i][j])) 15941 { 15942 if (obj[j] != params[i][j]) 15943 return false; 15944 } 15945 else if (params[i][j] instanceof RegExp) 15946 { 15947 if (!BX.type.isString(obj[j]) || !params[i][j].test(obj[j])) 15948 return false; 15949 } 15950 } 15951 } 15952 break; 15953 15954 case 'callback': 15955 return params[i](obj); 15956 } 15957 } 15958 } 15959 15960 return true; 15961 } 15962 15963 /* garbage collector */ 15964 function Trash() 15965 { 15966 var i,len; 15967 15968 for (i = 0, len = garbageCollectors.length; i<len; i++) 15969 { 15970 try { 15971 garbageCollectors[i].callback.apply(garbageCollectors[i].context || window); 15972 delete garbageCollectors[i]; 15973 garbageCollectors[i] = null; 15974 } catch (e) {} 15975 } 15976 } 15977 15978 if(window.attachEvent) // IE 15979 window.attachEvent("onunload", Trash); 15980 else if(window.addEventListener) // Gecko / W3C 15981 window.addEventListener('unload', Trash, false); 15982 else 15983 window.onunload = Trash; 15984 /* \garbage collector */ 15985 15986// set empty ready handler 15987 BX(BX.DoNothing); 15988 window.BX = BX; 15989 15990 BX.browser.addGlobalClass(); 15991 15992 /* data storage */ 15993 BX.data = function(node, key, value) 15994 { 15995 if(typeof node == 'undefined') 15996 return undefined; 15997 15998 if(typeof key == 'undefined') 15999 return undefined; 16000 16001 if(typeof value != 'undefined') 16002 { 16003 // write to manager 16004 dataStorage.set(node, key, value); 16005 } 16006 else 16007 { 16008 var data; 16009 16010 // from manager 16011 if((data = dataStorage.get(node, key)) != undefined) 16012 { 16013 return data; 16014 } 16015 else 16016 { 16017 // from attribute data-* 16018 if('getAttribute' in node) 16019 { 16020 data = node.getAttribute('data-'+key.toString()); 16021 if(data === null) 16022 { 16023 return undefined; 16024 } 16025 return data; 16026 } 16027 } 16028 16029 return undefined; 16030 } 16031 }; 16032 16033 BX.DataStorage = function() 16034 { 16035 16036 this.keyOffset = 1; 16037 this.data = {}; 16038 this.uniqueTag = 'BX-'+Math.random(); 16039 16040 this.resolve = function(owner, create){ 16041 if(typeof owner[this.uniqueTag] == 'undefined') 16042 if(create) 16043 { 16044 try 16045 { 16046 Object.defineProperty(owner, this.uniqueTag, { 16047 value: this.keyOffset++ 16048 }); 16049 } 16050 catch(e) 16051 { 16052 owner[this.uniqueTag] = this.keyOffset++; 16053 } 16054 } 16055 else 16056 return undefined; 16057 16058 return owner[this.uniqueTag]; 16059 }; 16060 this.get = function(owner, key){ 16061 if((owner != document && !BX.type.isElementNode(owner)) || typeof key == 'undefined') 16062 return undefined; 16063 16064 owner = this.resolve(owner, false); 16065 16066 if(typeof owner == 'undefined' || typeof this.data[owner] == 'undefined') 16067 return undefined; 16068 16069 return this.data[owner][key]; 16070 }; 16071 this.set = function(owner, key, value){ 16072 16073 if((owner != document && !BX.type.isElementNode(owner)) || typeof value == 'undefined') 16074 return; 16075 16076 var o = this.resolve(owner, true); 16077 16078 if(typeof this.data[o] == 'undefined') 16079 this.data[o] = {}; 16080 16081 this.data[o][key] = value; 16082 }; 16083 }; 16084 16085// some internal variables for new logic 16086 var dataStorage = new BX.DataStorage(); // manager which BX.data() uses to keep data 16087})(window.BX); 16088 16089;(function(window) 16090{ 16091 /****************** ATTENTION ******************************* 16092 * Please do not use Bitrix CoreJS in this class. 16093 * This class can be called on page without Bitrix Framework 16094 *************************************************************/ 16095 16096 if (!window.BX) 16097 { 16098 window.BX = {}; 16099 } 16100 16101 var BX = window.BX; 16102 16103 BX.Promise = function(fn, ctx) // fn is future-reserved 16104 { 16105 this.state = null; 16106 this.value = null; 16107 this.reason = null; 16108 this.next = null; 16109 this.ctx = ctx || this; 16110 16111 this.onFulfilled = []; 16112 this.onRejected = []; 16113 }; 16114 BX.Promise.prototype.fulfill = function(value) 16115 { 16116 this.checkState(); 16117 16118 this.value = value; 16119 this.state = true; 16120 this.execute(); 16121 }; 16122 BX.Promise.prototype.reject = function(reason) 16123 { 16124 this.checkState(); 16125 16126 this.reason = reason; 16127 this.state = false; 16128 this.execute(); 16129 }; 16130 BX.Promise.prototype.then = function(onFulfilled, onRejected) 16131 { 16132 if(typeof (onFulfilled) == "function" || onFulfilled instanceof Function) 16133 { 16134 this.onFulfilled.push(onFulfilled); 16135 } 16136 if(typeof (onRejected) == "function" || onRejected instanceof Function) 16137 { 16138 this.onRejected.push(onRejected); 16139 } 16140 16141 if(this.next === null) 16142 { 16143 this.next = new BX.Promise(null, this.ctx); 16144 } 16145 16146 if(this.state !== null) // if promise was already resolved, execute immediately 16147 { 16148 this.execute(); 16149 } 16150 16151 return this.next; 16152 }; 16153 16154 BX.Promise.prototype.catch = function(onRejected) 16155 { 16156 if(typeof (onRejected) == "function" || onRejected instanceof Function) 16157 { 16158 this.onRejected.push(onRejected); 16159 } 16160 16161 if(this.next === null) 16162 { 16163 this.next = new BX.Promise(null, this.ctx); 16164 } 16165 16166 if(this.state !== null) // if promise was already resolved, execute immediately 16167 { 16168 this.execute(); 16169 } 16170 16171 return this.next; 16172 }; 16173 16174 BX.Promise.prototype.setAutoResolve = function(way, ms) 16175 { 16176 this.timer = setTimeout(function(){ 16177 if(this.state === null) 16178 { 16179 this[way ? 'fulfill' : 'reject'](); 16180 } 16181 }.bind(this), ms || 15); 16182 };
16183 BX.Promise.prototype.cancelAutoResolve = function() 16184 { 16185 clearTimeout(this.timer); 16186 }; 16187 /** 16188 * Resolve function. This function allows promise chaining, like ..then().then()... 16189 * Typical usage: 16190 * 16191 * var p = new Promise(); 16192 * 16193 * p.then(function(value){ 16194 * return someValue; // next promise in the chain will be fulfilled with someValue 16195 * }).then(function(value){ 16196 * 16197 * var p1 = new Promise(); 16198 * *** some async code here, that eventually resolves p1 *** 16199 * 16200 * return p1; // chain will resume when p1 resolved (fulfilled or rejected) 16201 * }).then(function(value){ 16202 * 16203 * // you can also do 16204 * var e = new Error(); 16205 * throw e; 16206 * // it will cause next promise to be rejected with e 16207 * 16208 * return someOtherValue; 16209 * }).then(function(value){ 16210 * ... 16211 * }, function(reason){ 16212 * // promise was rejected with reason 16213 * })...; 16214 * 16215 * p.fulfill('let`s start this chain'); 16216 * 16217 * @param x 16218 */ 16219 BX.Promise.prototype.resolve = function(x) 16220 { 16221 var this_ = this; 16222 16223 if(this === x) 16224 { 16225 this.reject(new TypeError('Promise cannot fulfill or reject itself')); // avoid recursion 16226 } 16227 // allow "pausing" promise chaining until promise x is fulfilled or rejected 16228 else if(x && x.toString() === "[object BX.Promise]") 16229 { 16230 x.then(function(value){ 16231 this_.fulfill(value); 16232 }, function(reason){ 16233 this_.reject(reason); 16234 }); 16235 } 16236 else // auto-fulfill this promise 16237 { 16238 this.fulfill(x); 16239 } 16240 }; 16241 16242 BX.Promise.prototype.toString = function() 16243 { 16244 return "[object BX.Promise]"; 16245 }; 16246 16247 BX.Promise.prototype.execute = function() 16248 { 16249 if(this.state === null) 16250 { 16251 //then() must not be called before BX.Promise resolve() happens 16252 return; 16253 } 16254 16255 var value = undefined; 16256 var reason = undefined; 16257 var x = undefined; 16258 var k; 16259 if(this.state === true) // promise was fulfill()-ed 16260 { 16261 if(this.onFulfilled.length) 16262 { 16263 try 16264 { 16265 for(k = 0; k < this.onFulfilled.length; k++) 16266 {
16267 x = this.onFulfilled[k].apply(this.ctx, [this.value]); 16268 if(typeof x != 'undefined') 16269 { 16270 value = x; 16271 } 16272 } 16273 } 16274 catch(e) 16275 { 16276 if('console' in window) 16277 { 16278 console.dir(e); 16279 } 16280 16281 if (typeof BX.debug !== 'undefined') 16282 { 16283 BX.debug(e); 16284 } 16285 16286 reason = e; // reject next 16287 } 16288 } 16289 else 16290 { 16291 value = this.value; // resolve next 16292 } 16293 } 16294 else if(this.state === false) // promise was reject()-ed 16295 { 16296 if(this.onRejected.length) 16297 { 16298 try 16299 { 16300 for(k = 0; k < this.onRejected.length; k++) 16301 { 16302 x = this.onRejected[k].apply(this.ctx, [this.reason]); 16303 if(typeof x != 'undefined') 16304 { 16305 value = x; 16306 } 16307 } 16308 } 16309 catch(e) 16310 { 16311 if('console' in window) 16312 { 16313 console.dir(e); 16314 } 16315 16316 if (typeof BX.debug !== 'undefined') 16317 { 16318 BX.debug(e); 16319 } 16320 16321 reason = e; // reject next 16322 } 16323 } 16324 else 16325 { 16326 reason = this.reason; // reject next 16327 } 16328 } 16329 16330 if(this.next !== null) 16331 { 16332 if(typeof reason != 'undefined') 16333 { 16334 this.next.reject(reason); 16335 } 16336 else if(typeof value != 'undefined') 16337 { 16338 this.next.resolve(value); 16339 } 16340 } 16341 }; 16342 BX.Promise.prototype.checkState = function() 16343 { 16344 if(this.state !== null) 16345 { 16346 throw new Error('You can not do fulfill() or reject() multiple times'); 16347 } 16348 }; 16349})(window); 16350 16351 16352 16353;(function(window){ 16354 16355if (window.BX.ajax) 16356 return; 16357 16358var 16359 BX = window.BX, 16360 16361 tempDefaultConfig = {}, 16362 defaultConfig = { 16363 method: 'GET', // request method: GET|POST 16364 dataType: 'html', // type of data loading: html|json|script 16365 timeout: 0, // request timeout in seconds. 0 for browser-default 16366 async: true, // whether request is asynchronous or not 16367 processData: true, // any data processing is disabled if false, only callback call 16368 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 16369 emulateOnload: true, 16370 skipAuthCheck: false, // whether to check authorization failure (SHOUD be set to true for CORS requests) 16371 start: true, // send request immediately (if false, request can be started manually via XMLHttpRequest object returned) 16372 cache: true, // whether NOT to add random addition to URL 16373 preparePost: true, // whether set Content-Type x-www-form-urlencoded in POST 16374 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'}] 16375 lsTimeout: 30, //local storage data TTL. useless without lsId. 16376 lsForce: false //wheter to force query instead of using localStorage data. useless without lsId. 16377/* 16378other parameters: 16379 url: url to get/post 16380 data: data to post 16381 onsuccess: successful request callback. BX.proxy may be used. 16382 onfailure: request failure callback. BX.proxy may be used. 16383 onprogress: request progress callback. BX.proxy may be used. 16384 16385 lsId: local storage id - for constantly updating queries which can communicate via localStorage. core_ls.js needed 16386 16387any of the default parameters can be overridden. defaults can be changed by BX.ajax.Setup() - for all further requests! 16388*/ 16389 }, 16390 loadedScripts = {}, 16391 loadedScriptsQueue = [], 16392 r = { 16393 'url_utf': /[^\034-\254]+/g, 16394 'script_self': /\/bitrix\/js\/main\/core\/core(_ajax)*.js$/i, 16395 'script_self_window': /\/bitrix\/js\/main\/core\/core_window.js$/i, 16396 'script_self_admin': /\/bitrix\/js\/main\/core\/core_admin.js$/i, 16397 'script_onload': /window.onload/g 16398 }; 16399 16400// low-level method 16401BX.ajax = function(config) 16402{ 16403 var status, data; 16404
16405 if (!config || !config.url || !BX.type.isString(config.url)) 16406 { 16407 return false; 16408 } 16409 16410 for (var i in tempDefaultConfig) 16411 if (typeof (config[i]) == "undefined") config[i] = tempDefaultConfig[i]; 16412 16413 tempDefaultConfig = {}; 16414 16415 for (i in defaultConfig) 16416 if (typeof (config[i]) == "undefined") config[i] = defaultConfig[i]; 16417 16418 config.method = config.method.toUpperCase(); 16419 16420 if (!BX.localStorage) 16421 config.lsId = null; 16422 16423 if (BX.browser.IsIE()) 16424 { 16425 var result = r.url_utf.exec(config.url); 16426 if (result) 16427 { 16428 do 16429 { 16430 config.url = config.url.replace(result, BX.util.urlencode(result)); 16431 result = r.url_utf.exec(config.url); 16432 } while (result); 16433 } 16434 } 16435 16436 if(config.dataType == 'json') 16437 config.emulateOnload = false; 16438 16439 if (!config.cache && config.method == 'GET') 16440 config.url = BX.ajax._uncache(config.url); 16441 16442 if (config.method == 'POST') 16443 { 16444 if (config.preparePost) 16445 { 16446 config.data = BX.ajax.prepareData(config.data); 16447 } 16448 else if (getLastContentTypeHeader(config.headers) === 'application/json') 16449 { 16450 config.data = JSON.stringify(config.data); 16451 } 16452 } 16453 16454 var bXHR = true; 16455 if (config.lsId && !config.lsForce) 16456 { 16457 var v = BX.localStorage.get('ajax-' + config.lsId); 16458 if (v !== null) 16459 { 16460 bXHR = false; 16461 16462 var lsHandler = function(lsData) { 16463 if (lsData.key == 'ajax-' + config.lsId && lsData.value != 'BXAJAXWAIT') 16464 { 16465 var data = lsData.value, 16466 bRemove = !!lsData.oldValue && data == null; 16467 if (!bRemove) 16468 BX.ajax.__run(config, data); 16469 else if (config.onfailure) 16470 config.onfailure("timeout"); 16471 16472 BX.removeCustomEvent('onLocalStorageChange', lsHandler); 16473 } 16474 }; 16475 16476 if (v == 'BXAJAXWAIT') 16477 { 16478 BX.addCustomEvent('onLocalStorageChange', lsHandler); 16479 } 16480 else 16481 { 16482 setTimeout(function() {lsHandler({key: 'ajax-' + config.lsId, value: v})}, 10); 16483 } 16484 } 16485 } 16486 16487 if (bXHR) 16488 { 16489 config.xhr = BX.ajax.xhr(); 16490 if (!config.xhr) return; 16491 16492 if (config.lsId) 16493 { 16494 BX.localStorage.set('ajax-' + config.lsId, 'BXAJAXWAIT', config.lsTimeout); 16495 } 16496 16497 if (BX.Type.isFunction(config.onprogress)) 16498 { 16499 BX.bind(config.xhr, 'progress', config.onprogress); 16500 } 16501 16502 if (BX.Type.isFunction(config.onprogressupload) && config.xhr.upload) 16503 { 16504 BX.bind(config.xhr.upload, 'progress', config.onprogressupload); 16505 } 16506 16507 config.xhr.open(config.method, config.url, config.async); 16508 16509 if (!config.skipBxHeader && !BX.ajax.isCrossDomain(config.url)) 16510 { 16511 config.xhr.setRequestHeader('Bx-ajax', 'true'); 16512 } 16513 16514 if (config.method == 'POST' && config.preparePost) 16515 { 16516 config.xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 16517 } 16518 if (typeof(config.headers) == "object") 16519 { 16520 for (i = 0; i < config.headers.length; i++) 16521 config.xhr.setRequestHeader(config.headers[i].name, config.headers[i].value); 16522 } 16523 16524 var bRequestCompleted = false; 16525 var onreadystatechange = config.xhr.onreadystatechange = function(additional) 16526 { 16527 if (bRequestCompleted) 16528 return; 16529 16530 if (additional === 'timeout') 16531 { 16532 if (config.onfailure) 16533 { 16534 config.onfailure('timeout', '', config); 16535 } 16536 16537 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['timeout', '', config]); 16538 16539 config.xhr.onreadystatechange = BX.DoNothing; 16540 config.xhr.abort(); 16541 16542 if (config.async) 16543 { 16544 config.xhr = null; 16545 } 16546 } 16547 else 16548 { 16549 if (config.xhr.readyState == 4 || additional == 'run') 16550 { 16551 status = BX.ajax.xhrSuccess(config.xhr) ? "success" : "error"; 16552 bRequestCompleted = true; 16553 config.xhr.onreadystatechange = BX.DoNothing; 16554 16555 if (status == 'success') 16556 { 16557 var authHeader = (!!config.skipAuthCheck || BX.ajax.isCrossDomain(config.url)) 16558 ? false 16559 : config.xhr.getResponseHeader('X-Bitrix-Ajax-Status'); 16560 16561 if(!!authHeader && authHeader == 'Authorize') 16562 { 16563 if (config.onfailure) 16564 { 16565 config.onfailure('auth', config.xhr.status, config); 16566 } 16567 16568 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['auth', config.xhr.status, config]); 16569 } 16570 else 16571 { 16572 var data = config.xhr.responseText; 16573 16574 if (config.lsId) 16575 { 16576 BX.localStorage.set('ajax-' + config.lsId, data, config.lsTimeout); 16577 } 16578 16579 BX.ajax.__run(config, data); 16580 } 16581 } 16582 else 16583 { 16584 if (config.onfailure) 16585 { 16586 config.onfailure('status', config.xhr.status, config); 16587 } 16588 16589 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['status', config.xhr.status, config]); 16590 } 16591 16592 if (config.async) 16593 { 16594 config.xhr = null; 16595 } 16596 } 16597 } 16598 }; 16599 16600 if (config.async && config.timeout > 0) 16601 { 16602 setTimeout(function() { 16603 if (config.xhr && !bRequestCompleted) 16604 { 16605 onreadystatechange("timeout"); 16606 } 16607 }, config.timeout * 1000); 16608 } 16609 16610 if (config.start) 16611 {
16612 config.xhr.send(config.data); 16613 16614 if (!config.async) 16615 { 16616 onreadystatechange('run'); 16617 } 16618 } 16619 16620 return config.xhr; 16621 } 16622}; 16623 16624BX.ajax.xhr = function() 16625{ 16626 if (window.XMLHttpRequest) 16627 { 16628 try {return new XMLHttpRequest();} catch(e){} 16629 } 16630 else if (window.ActiveXObject) 16631 { 16632 try { return new window.ActiveXObject("Msxml2.XMLHTTP.6.0"); } 16633 catch(e) {} 16634 try { return new window.ActiveXObject("Msxml2.XMLHTTP.3.0"); } 16635 catch(e) {} 16636 try { return new window.ActiveXObject("Msxml2.XMLHTTP"); } 16637 catch(e) {} 16638 try { return new window.ActiveXObject("Microsoft.XMLHTTP"); } 16639 catch(e) {} 16640 throw new Error("This browser does not support XMLHttpRequest."); 16641 } 16642 16643 return null; 16644}; 16645 16646BX.ajax.isCrossDomain = function(url, location) 16647{ 16648 location = location || window.location; 16649 16650 //Relative URL gets a current protocol 16651 if (url.indexOf("//") === 0) 16652 { 16653 url = location.protocol + url; 16654 } 16655 16656 //Fast check 16657 if (url.indexOf("http") !== 0) 16658 { 16659 return false; 16660 } 16661 16662 var link = window.document.createElement("a"); 16663 link.href = url; 16664 16665 return link.protocol !== location.protocol || 16666 link.hostname !== location.hostname || 16667 BX.ajax.getHostPort(link.protocol, link.host) !== BX.ajax.getHostPort(location.protocol, location.host); 16668}; 16669 16670BX.ajax.getHostPort = function(protocol, host) 16671{ 16672 var match = /:(\d+)$/.exec(host); 16673 if (match) 16674 { 16675 return match[1]; 16676 } 16677 else 16678 { 16679 if (protocol === "http:") 16680 { 16681 return "80"; 16682 } 16683 else if (protocol === "https:") 16684 { 16685 return "443"; 16686 } 16687 } 16688 16689 return ""; 16690}; 16691 16692BX.ajax.__prepareOnload = function(scripts, ajax_session) 16693{ 16694 if (scripts.length > 0) 16695 { 16696 BX.ajax['onload_' + ajax_session] = null; 16697 16698 for (var i=0,len=scripts.length;i<len;i++) 16699 { 16700 if (scripts[i].isInternal) 16701 { 16702 scripts[i].JS = scripts[i].JS.replace(r.script_onload, 'BX.aja
16702x.onload_' + ajax_session); 16703 } 16704 } 16705 } 16706 16707 BX.CaptureEventsGet(); 16708 BX.CaptureEvents(window, 'load'); 16709}; 16710 16711BX.ajax.__runOnload = function(ajax_session) 16712{ 16713 if (null != BX.ajax['onload_' + ajax_session]) 16714 { 16715 BX.ajax['onload_' + ajax_session].apply(window); 16716 BX.ajax['onload_' + ajax_session] = null; 16717 } 16718 16719 var h = BX.CaptureEventsGet(); 16720 16721 if (h) 16722 { 16723 for (var i=0; i<h.length; i++) 16724 h[i].apply(window); 16725 } 16726}; 16727 16728BX.ajax.__run = function(config, data) 16729{ 16730 if (!config.processData) 16731 { 16732 if (config.onsuccess) 16733 { 16734 config.onsuccess(data); 16735 } 16736 16737 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [data, config]); 16738 } 16739 else 16740 { 16741 data = BX.ajax.processRequestData(data, config); 16742 } 16743}; 16744 16745 16746BX.ajax._onParseJSONFailure = function(data) 16747{ 16748 this.jsonFailure = true; 16749 this.jsonResponse = data; 16750 this.jsonProactive = /^\[WAF\]/.test(data); 16751}; 16752 16753BX.ajax.processRequestData = function(data, config) 16754{ 16755 var result, scripts = [], styles = []; 16756 switch (config.dataType.toUpperCase()) 16757 { 16758 case 'JSON': 16759 16760 var context = config.xhr || {}; 16761 BX.addCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 16762 result = BX.parseJSON(data, context); 16763 BX.removeCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 16764 16765 if(!!result && BX.type.isArray(result['bxjs'])) 16766 { 16767 for(var i = 0; i < result['bxjs'].length; i++) 16768 { 16769 if(BX.type.isNotEmptyString(result['bxjs'][i])) 16770 { 16771 scripts.push({ 16772 "isInternal": false, 16773 "JS": result['bxjs'][i], 16774 "bRunFirst": config.scriptsRunFirst 16775 }); 16776 } 16777 else 16778 { 16779 scripts.push(result['bxjs'][i]) 16780 } 16781 } 16782 } 16783 16784 if(!!result && BX.type.isArray(result['bxcss'])) 16785 { 16786 styles = result['bxcss']; 16787 } 16788 16789 break; 16790 case 'SCRIPT': 16791 scripts.push({"isInternal": true, "JS": data, "bRunFirst": config.scriptsRunFirst}); 16792 result = data; 16793 break; 16794 16795 default: // HTML 16796 var ob = BX.processHTML(data, config.scriptsRunFirst); 16797 result = ob.HTML; scripts = ob.SCRIPT; styles = ob.STYLE; 16798 break; 16799 } 16800 16801 if (styles.length > 0) 16802 { 16803 BX.loadCSS(styles); 16804 } 16805 16806 let ajax_session = null; 16807 if (config.emulateOnload) 16808 { 16809 ajax_session = parseInt(Math.random() * 1000000); 16810 BX.ajax.__prepareOnload(scripts, ajax_session); 16811 } 16812 16813 const cb = BX.defer(function() 16814 { 16815 if (config.emulateOnload) 16816 { 16817 BX.ajax.__runOnload(ajax_session); 16818 } 16819 16820 BX.onCustomEvent(config.xhr, 'onAjaxSuccessFinish', [config]); 16821 }); 16822 16823 try 16824 { 16825 if (!!config.jsonFailure) 16826 { 16827 throw {type: 'json_failure', data: config.jsonResponse, bProactive: config.jsonProactive}; 16828 } 16829 16830 config.scripts = scripts; 16831 16832 BX.ajax.processScripts(config.scripts, true); 16833 16834 if (config.onsuccess) 16835 { 16836 config.onsuccess(result); 16837 } 16838 16839 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [result, config]); 16840 16841 BX.ajax.processScripts(config.scripts, false, cb); 16842 } 16843 catch (e) 16844 { 16845 if (config.onfailure) 16846 config.onfailure("processing", e); 16847 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['processing', e, config]); 16848 } 16849}; 16850 16851BX.ajax.processScripts = function(scripts, bRunFirst, cb) 16852{ 16853 var scriptsExt = [], scriptsInt = ''; 16854 16855 cb = cb || BX.DoNothing; 16856 16857 for (var i = 0, length = scripts.length; i < length; i++) 16858 { 16859 if (typeof bRunFirst != 'undefined' && bRunFirst != !!scripts[i].bRunFirst) 16860 continue; 16861 16862 if (scripts[i].isInternal) 16863 scriptsInt += ';' + scripts[i].JS; 16864 else 16865 scriptsExt.push(scripts[i].JS); 16866 } 16867 16868 scriptsExt = BX.util.array_unique(scriptsExt); 16869 var inlineScripts = scriptsInt.length > 0 ? function() { BX.evalGlobal(scriptsInt); } : BX.DoNothing; 16870 16871 if (scriptsExt.length > 0) 16872 { 16873 BX.load(scriptsExt, function() { 16874 inlineScripts(); 16875 cb(); 16876 }); 16877 } 16878 else 16879 { 16880 inlineScripts(); 16881 cb(); 16882 } 16883}; 16884 16885// TODO: extend this function to use with any data objects or forms 16886BX.ajax.prepareData = function(arData, prefix) 16887{ 16888 var data = ''; 16889 if (BX.type.isString(arData)) 16890 data = arData; 16891 else if (null != arData) 16892 { 16893 for(var i in arData) 16894 { 16895 if (arData.hasOwnProperty(i)) 16896 { 16897 if (data.length > 0) 16898 data += '&'; 16899 var name = BX.util.urlencode(i); 16900 if(prefix) 16901 name = prefix + '[' + name + ']'; 16902 if(typeof arData[i] == 'object') 16903 data += BX.ajax.prepareData(arData[i], name); 16904 else 16905 data += name + '=' + BX.util.urlencode(arData[i]); 16906 } 16907 } 16908 } 16909 return data; 16910}; 16911 16912BX.ajax.xhrSuccess = function(xhr) 16913{ 16914 return (xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || xhr.status === 1223 || xhr.status === 0; 16915}; 16916 16917BX.ajax.Setup = function(config, bTemp) 16918{ 16919 bTemp = !!bTemp; 16920 16921 for (var i in config) 16922 { 16923 if (bTemp) 16924 tempDefaultConfig[i] = config[i]; 16925 else 16926 defaultConfig[i] = config[i]; 16927 } 16928}; 16929 16930BX.ajax.replaceLocalStorageValue = function(lsId, data, ttl) 16931{ 16932 if (!!BX.localStorage) 16933 BX.localStorage.set('ajax-' + lsId, data, ttl); 16934}; 16935 16936 16937BX.ajax._uncache = function(url) 16938{ 16939 return url + ((url.indexOf('?') !== -1 ? "&" : "?") + '_=' + (new Date()).getTime()); 16940}; 16941 16942/* simple interface */ 16943BX.ajax.get = function(url, data, callback) 16944{ 16945 if (BX.type.isFunction(data)) 16946 { 16947 callback = data; 16948 data = ''; 16949 } 16950
16951 data = BX.ajax.prepareData(data); 16952 16953 if (data) 16954 { 16955 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 16956 data = ''; 16957 } 16958 16959 return BX.ajax({ 16960 'method': 'GET', 16961 'dataType': 'html', 16962 'url': url, 16963 'data': '', 16964 'onsuccess': callback 16965 }); 16966}; 16967 16968BX.ajax.getCaptcha = function(callback) 16969{ 16970 return BX.ajax.loadJSON('/bitrix/tools/ajax_captcha.php', callback); 16971}; 16972 16973BX.ajax.insertToNode = function(url, node) 16974{ 16975 node = BX(node); 16976 if (!!node) 16977 { 16978 var eventArgs = { cancel: false }; 16979 BX.onCustomEvent('onAjaxInsertToNode', [{ url: url, node: node, eventArgs: eventArgs }]); 16980 if(eventArgs.cancel === true) 16981 { 16982 return; 16983 } 16984 16985 var show = null; 16986 if (!tempDefaultConfig.denyShowWait) 16987 { 16988 show = BX.showWait(node); 16989 delete tempDefaultConfig.denyShowWait; 16990 } 16991 16992 return BX.ajax.get(url, function(data) { 16993 node.innerHTML = data; 16994 BX.closeWait(node, show); 16995 }); 16996 } 16997}; 16998 16999BX.ajax.post = function(url, data, callback) 17000{ 17001 data = BX.ajax.prepareData(data); 17002 17003 return BX.ajax({ 17004 'method': 'POST', 17005 'dataType': 'html', 17006 'url': url, 17007 'data': data, 17008 'onsuccess': callback 17009 }); 17010}; 17011 17012/** 17013 * BX.ajax with BX.Promise 17014 * 17015 * @param config 17016 * @returns {BX.Promise|false} 17017 */ 17018BX.ajax.promise = function(config) 17019{ 17020 var result = new BX.Promise(); 17021 17022 config.onsuccess = function(data) 17023 { 17024 result.fulfill(data); 17025 }; 17026 config.onfailure = function(reason, httpStatus, config) 17027 { 17028 result.reject({ 17029 reason: reason, 17030 data: httpStatus, 17031 ajaxConfig: config, 17032 xhr: config.xhr 17033 }); 17034 }; 17035 17036 var xhr = BX.ajax(config); 17037 if (xhr) 17038 { 17039 if (typeof config.onrequeststart === 'function') 17040 { 17041 config.onrequeststart(xhr); 17042 } 17043 } 17044 else 17045 { 17046 result.reject({ 17047 reason: "init", 17048 data: false 17049 }); 17050 } 17051 17052 return result; 17053}; 17054 17055/* load and execute external file script with onload emulation */ 17056BX.ajax.loadScriptAjax = function(script_src, callback, bPreload) 17057{ 17058 if (BX.type.isArray(script_src)) 17059 { 17060 for (var i=0,len=script_src.length;i<len;i++) 17061 { 17062 BX.ajax.loadScriptAjax(script_src[i], callback, bPreload); 17063 } 17064 } 17065 else 17066 { 17067 var script_src_test = script_src.replace(/\.js\?.*/, '.js'); 17068 17069 if (r.script_self.test(script_src_test)) return; 17070 if (r.script_self_window.test(script_src_test) && BX.CWindow) return; 17071 if (r.script_self_admin.test(script_src_test) && BX.admin) return; 17072 17073 if (typeof loadedScripts[script_src_test] == 'undefined') 17074 { 17075 if (!!bPreload) 17076 { 17077 loadedScripts[script_src_test] = ''; 17078 return BX.loadScript(script_src); 17079 } 17080 else 17081 { 17082 return BX.ajax({ 17083 url: script_src, 17084 method: 'GET', 17085 dataType: 'script', 17086 processData: true, 17087 emulateOnload: false, 17088 scriptsRunFirst: true, 17089 async: false, 17090 start: true, 17091 onsuccess: function(result) { 17092 loadedScripts[script_src_test] = result; 17093 if (callback) 17094 callback(result); 17095 } 17096 }); 17097 } 17098 } 17099 else if (callback) 17100 { 17101 callback(loadedScripts[script_src_test]); 17102 } 17103 } 17104}; 17105 17106/* non-xhr loadings */ 17107BX.ajax.loadJSON = function(url, data, callback, callback_failure) 17108{ 17109 if (BX.type.isFunction(data)) 17110 { 17111 callback_failure = callback; 17112 callback = data; 17113 data = ''; 17114 } 17115 17116 data = BX.ajax.prepareData(data); 17117 17118 if (data) 17119 { 17120 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 17121 data = ''; 17122 } 17123 17124 return BX.ajax({ 17125 'method': 'GET', 17126 'dataType': 'json', 17127 'url': url, 17128 'onsuccess': callback, 17129 'onfailure': callback_failure 17130 }); 17131}; 17132 17133var getLastContentTypeHeader = function (headers) { 17134 if (!BX.Type.isArray(headers)) 17135 { 17136 return null; 17137 } 17138 var lastHeader = headers 17139 .filter(function (header) { 17140 return header.name === 'Content-Type'; 17141 }) 17142 .pop(); 17143 17144 return lastHeader ? lastHeader.value : null; 17145}; 17146 17147var prepareAjaxGetParameters = function(config) 17148{ 17149 var getParameters = config.getParameters || {}; 17150 if (BX.type.isNotEmptyString(config.analyticsLabel)) 17151 { 17152 getParameters.analyticsLabel = config.analyticsLabel; 17153 } 17154 else if (BX.type.isNotEmptyObject(config.analyticsLabel)) 17155 { 17156 getParameters.analyticsLabel = config.analyticsLabel; 17157 } 17158 if (typeof config.mode !== 'undefined') 17159 { 17160 getParameters.mode = config.mode; 17161 } 17162 if (config.navigation) 17163 { 17164 if(config.navigation.page) 17165 { 17166 getParameters.nav = 'page-' + config.navigation.page; 17167 } 17168 if(config.navigation.size) 17169 { 17170 if(getParameters.nav) 17171 { 17172 getParameters.nav += '-'; 17173 } 17174 else 17175 {
17176 getParameters.nav = ''; 17177 } 17178 getParameters.nav += 'size-' + config.navigation.size; 17179 } 17180 } 17181 17182 return getParameters; 17183}; 17184 17185var prepareAjaxConfig = function(config) 17186{ 17187 config = BX.type.isPlainObject(config) ? config : {}; 17188 17189 config.headers = config.headers || []; 17190 config.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 17191 if (BX.message.SITE_ID) 17192 { 17193 config.headers.push({name: 'X-Bitrix-Site-Id', value: BX.message.SITE_ID}); 17194 } 17195 17196 if (typeof config.json !== 'undefined') 17197 { 17198 if (!BX.type.isPlainObject(config.json)) 17199 { 17200 throw new Error('Wrong `config.json`, plain object expected.') 17201 } 17202 17203 config.headers.push({name: 'Content-Type', value: 'application/json'}); 17204 config.data = config.json; 17205 config.preparePost = false; 17206 } 17207 else if (config.data instanceof FormData) 17208 { 17209 config.preparePost = false; 17210 if (typeof config.signedParameters !== 'undefined') 17211 { 17212 config.data.append('signedParameters', config.signedParameters); 17213 } 17214 } 17215 else if (BX.type.isPlainObject(config.data) || BX.Type.isNil(config.data)) 17216 { 17217 config.data = BX.type.isPlainObject(config.data) ? config.data : {}; 17218 if (typeof config.signedParameters !== 'undefined') 17219 { 17220 config.data.signedParameters = config.signedParameters; 17221 } 17222 } 17223 17224 if (!config.method) 17225 { 17226 config.method = 'POST' 17227 } 17228 17229 return config; 17230}; 17231 17232var buildAjaxPromiseToRestoreCsrf = function(config, withoutRestoringCsrf) 17233{ 17234 withoutRestoringCsrf = withoutRestoringCsrf || false; 17235 var originalConfig = BX.clone(config); 17236 var request = null; 17237 17238 var onrequeststart = config.onrequeststart; 17239 config.onrequeststart = function(xhr) { 17240 request = xhr; 17241 if (BX.type.isFunction(onrequeststart)) 17242 { 17243 onrequeststart(xhr); 17244 } 17245 }; 17246 var onrequeststartOrig = originalConfig.onrequeststart; 17247 originalConfig.onrequeststart = function(xhr) { 17248 request = xhr; 17249 if (BX.type.isFunction(onrequeststartOrig)) 17250 { 17251 onrequeststartOrig(xhr); 17252 } 17253 }; 17254 17255 var promise = BX.ajax.promise(config); 17256 17257 return promise.then(function(response) { 17258 if (!withoutRestoringCsrf && BX.type.isPlainObject(response) && BX.type.isArray(response.errors)) 17259 { 17260 var csrfProblem = false; 17261 response.errors.forEach(function(error) { 17262 if (error.code === 'invalid_csrf' && error.customData.csrf) 17263 { 17264 BX.message({'bitrix_sessid': error.customData.csrf}); 17265 17266 originalConfig.headers = originalConfig.headers || []; 17267 originalConfig.headers = originalConfig.headers.filter(function(header) { 17268 return header && header.name !== 'X-Bitrix-Csrf-Token'; 17269 }); 17270 originalConfig.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 17271 17272 csrfProblem = true; 17273 } 17274 }); 17275 17276 if (csrfProblem) 17277 { 17278 return buildAjaxPromiseToRestoreCsrf(originalConfig, true); 17279 } 17280 } 17281 17282 if (!BX.type.isPlainObject(response) || response.status !== 'success') 17283 { 17284 var errorPromise = new BX.Promise(); 17285 errorPromise.reject(response); 17286 17287 return errorPromise; 17288 } 17289 17290 return response; 17291 }).catch(function(data) { 17292 var ajaxReject = new BX.Promise(); 17293 17294 var originalJsonResponse; 17295 if (BX.type.isPlainObject(data) && data.xhr && data.xhr.responseText) 17296 { 17297 try 17298 { 17299 originalJsonResponse = JSON.parse(data.xhr.responseText); 17300 data = originalJsonResponse; 17301 } 17302 catch (err) 17303 {} 17304 } 17305 17306 if (BX.type.isPlainObject(data) && data.status && data.hasOwnProperty('data')) 17307 { 17308 ajaxReject.reject(data); 17309 } 17310 else 17311 { 17312 ajaxReject.reject({ 17313 status: 'error', 17314 data: { 17315 ajaxRejectData: data 17316 }, 17317 errors: [ 17318 { 17319 code: 'NETWORK_ERROR', 17320 message: 'Network error' 17321 } 17322 ] 17323 }); 17324 } 17325 17326 return ajaxReject; 17327 }).then(function(response){ 17328 17329 var assetsLoaded = new BX.Promise(); 17330 17331 var headers = request.getAllResponseHeaders().trim().split(/[\r\n]+/); 17332 var headerMap = {}; 17333 headers.forEach(function (line) { 17334 var parts = line.split(': '); 17335 var header = parts.shift().toLowerCase(); 17336 headerMap[header] = parts.join(': '); 17337 }); 17338 17339 if (!headerMap['x-process-assets']) 17340 { 17341 assetsLoaded.fulfill(response); 17342 17343 return assetsLoaded; 17344 } 17345 17346 var assets = BX.prop.getObject(BX.prop.getObject(response, "data", {}), "assets", {}); 17347 var promise = new Promise(function(resolve, reject) { 17348 var css = BX.prop.getArray(assets, "css", []); 17349 BX.load(css, function(){ 17350 BX.loadScript( 17351 BX.prop.getArray(assets, "js", []), 17352 resolve 17353 ); 17354 }); 17355 }); 17356 promise.then(function(){ 17357 var strings = BX.prop.getArray(assets, "string", []); 17358 var stringAsset = strings.join('\n'); 17359 BX.html(document.head, stringAsset, { useAdjacentHTML: true }).then(function(){ 17360 assetsLoaded.fulfill(response); 17361 }); 17362 }); 17363 17364 return assetsLoaded; 17365 }); 17366}; 17367 17368/** 17369 * 17370 * @param {string} action 17371 * @param {Object} config 17372 * @param {?string|?Object} [config.analyticsLabel] 17373 * @param {string} [config.method='POST'] 17374 * @param {Object} [config.data] 17375 * @param {?Object} [config.getParameters] 17376 * @param {?Object} [config.headers] 17377 * @param {?Object} [config.timeout] 17378 * @param {Object} [config.navigation] 17379 * @param {number} [config.navigation.page] 17380 */ 17381BX.ajax.runAction = function(action, config) 17382{ 17383 config = prepareAjaxConfig(config); 17384 var getParameters = prepareAjaxGetParameters(config); 17385 getParameters.action = action; 17386
17387 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 17388 return buildAjaxPromiseToRestoreCsrf({ 17389 method: config.method, 17390 dataType: 'json', 17391 url: url, 17392 data: config.data, 17393 timeout: config.timeout, 17394 preparePost: config.preparePost, 17395 headers: config.headers, 17396 onrequeststart: config.onrequeststart, 17397 onprogress: config.onprogress, 17398 onprogressupload: config.onprogressupload 17399 }); 17400}; 17401 17402/** 17403 * 17404 * @param {string} component 17405 * @param {string} action 17406 * @param {Object} config 17407 * @param {?string|?Object} [config.analyticsLabel] 17408 * @param {?string} [config.signedParameters] 17409 * @param {string} [config.method='POST'] 17410 * @param {string} [config.mode='ajax'] Ajax or class. 17411 * @param {Object} [config.data] 17412 * @param {?Object} [config.getParameters] 17413 * @param {?array} [config.headers] 17414 * @param {?number} [config.timeout] 17415 * @param {Object} [config.navigation] 17416 */ 17417BX.ajax.runComponentAction = function (component, action, config) 17418{ 17419 config = prepareAjaxConfig(config); 17420 config.mode = config.mode || 'ajax'; 17421 17422 var getParameters = prepareAjaxGetParameters(config); 17423 getParameters.c = component; 17424 getParameters.action = action; 17425
17426 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 17427 17428 return buildAjaxPromiseToRestoreCsrf({ 17429 method: config.method, 17430 dataType: 'json', 17431 url: url, 17432 data: config.data, 17433 timeout: config.timeout, 17434 preparePost: config.preparePost, 17435 headers: config.headers, 17436 onrequeststart: (config.onrequeststart ? config.onrequeststart : null), 17437 onprogress: config.onprogress, 17438 onprogressupload: config.onprogressupload 17439 }); 17440}; 17441 17442/* 17443arObs = [{ 17444 url: url, 17445 type: html|script|json|css, 17446 callback: function 17447}] 17448*/ 17449BX.ajax.load = function(arObs, callback) 17450{ 17451 if (!BX.type.isArray(arObs)) 17452 arObs = [arObs]; 17453 17454 var cnt = 0; 17455 17456 if (!BX.type.isFunction(callback)) 17457 callback = BX.DoNothing; 17458 17459 var handler = function(data) 17460 { 17461 if (BX.type.isFunction(this.callback)) 17462 this.callback(data); 17463 17464 if (++cnt >= len) 17465 callback(); 17466 }; 17467 17468 for (var i = 0, len = arObs.length; i<len; i++) 17469 { 17470 switch(arObs[i].type.toUpperCase()) 17471 { 17472 case 'SCRIPT': 17473 BX.loadScript([arObs[i].url], BX.proxy(handler, arObs[i])); 17474 break; 17475 case 'CSS': 17476 BX.loadCSS([arObs[i].url]); 17477 17478 if (++cnt >= len) 17479 callback(); 17480 break; 17481 case 'JSON': 17482 BX.ajax.loadJSON(arObs[i].url, BX.proxy(handler, arObs[i])); 17483 break; 17484 17485 default: 17486 BX.ajax.get(arObs[i].url, '', BX.proxy(handler, arObs[i])); 17487 break; 17488 } 17489 } 17490}; 17491 17492/* ajax form sending */ 17493BX.ajax.submit = function(obForm, callback) 17494{ 17495 if (!obForm.target) 17496 { 17497 if (null == obForm.BXFormTarget) 17498 { 17499 var frame_name = 'formTarget_' + Math.random(); 17500 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 17501 props: { 17502 name: frame_name, 17503 id: frame_name, 17504 src: 'javascript:void(0)' 17505 }, 17506 style: { 17507 display: 'none' 17508 } 17509 })); 17510 } 17511 17512 obForm.target = obForm.BXFormTarget.name; 17513 } 17514 17515 obForm.BXFormCallback = callback; 17516 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 17517 17518 BX.submit(obForm); 17519 17520 return false; 17521}; 17522 17523BX.ajax.submitComponentForm = function(obForm, container, bWait) 17524{ 17525 if (!obForm.target) 17526 { 17527 if (null == obForm.BXFormTarget) 17528 { 17529 var frame_name = 'formTarget_' + Math.random(); 17530 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 17531 props: { 17532 name: frame_name, 17533 id: frame_name, 17534 src: 'javascript:void(0)' 17535 }, 17536 style: { 17537 display: 'none' 17538 } 17539 })); 17540 } 17541 17542 obForm.target = obForm.BXFormTarget.name; 17543 } 17544 17545 if (!!bWait) 17546 var w = BX.showWait(container); 17547 17548 obForm.BXFormCallback = function(d) { 17549 if (!!bWait) 17550 BX.closeWait(w); 17551 17552 var callOnload = function(){ 17553 if(!!window.bxcompajaxframeonload) 17554 { 17555 setTimeout(function(){window.bxcompajaxframeonload();window.bxcompajaxframeonload=null;}, 10); 17556 } 17557 }; 17558 17559 BX(container).innerHTML = d; 17560 BX.onCustomEvent('onAjaxSuccess', [null,null,callOnload]); 17561 }; 17562 17563 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 17564 17565 return true; 17566}; 17567 17568// func will be executed in form context 17569BX.ajax._submit_callback = function() 17570{ 17571 //opera and IE8 triggers onload event even on empty iframe 17572 try 17573 { 17574 if(this.BXFormTarget.contentWindow.location.href.indexOf('http') != 0) 17575 return; 17576 } catch (e) { 17577 return; 17578 } 17579 17580 if (this.BXFormCallback) 17581 this.BXFormCallback.apply(this, [this.BXFormTarget.contentWindow.document.body.innerHTML]); 17582 17583 BX.unbindAll(this.BXFormTarget); 17584}; 17585 17586BX.ajax.prepareForm = function(obForm, data) 17587{ 17588 data = (!!data ? data : {}); 17589 var i, ii, el, 17590 _data = [], 17591 n = obForm.elements.length, 17592 files = 0, length = 0; 17593 if(!!obForm) 17594 { 17595 for (i = 0; i < n; i++) 17596 { 17597 el = obForm.elements[i]; 17598 if (el.disabled) 17599 continue; 17600 17601 if(!el.type) 17602 continue; 17603 17604 switch(el.type.toLowerCase()) 17605 { 17606 case 'text': 17607 case 'textarea': 17608 case 'password': 17609 case 'number': 17610 case 'hidden': 17611 case 'select-one': 17612 _data.push({name: el.name, value: el.value}); 17613 length += (el.name.length + el.value.length); 17614 break; 17615 case 'file': 17616 if (!!el.files) 17617 { 17618 for (ii = 0; ii < el.files.length; ii++) 17619 { 17620 files++; 17621 _data.push({name: el.name, value: el.files[ii], file : true}); 17622 length += el.files[ii].size; 17623 } 17624 } 17625 break; 17626 case 'radio':
17627 case 'checkbox': 17628 if(el.checked) 17629 { 17630 _data.push({name: el.name, value: el.value}); 17631 length += (el.name.length + el.value.length); 17632 } 17633 break; 17634 case 'select-multiple': 17635 for (var j = 0; j < el.options.length; j++) 17636 { 17637 if (el.options[j].selected) 17638 { 17639 _data.push({name : el.name, value : el.options[j].value}); 17640 length += (el.name.length + el.options[j].length); 17641 } 17642 } 17643 break; 17644 default: 17645 break; 17646 } 17647 } 17648 17649 i = 0; length = 0; 17650 var current = data, name, rest, pp, tmpKey; 17651 17652 while(i < _data.length) 17653 { 17654 var p = _data[i].name.indexOf('['); 17655 if (tmpKey) 17656 { 17657 current[_data[i].name] = {}; 17658 current[_data[i].name][tmpKey.replace(/\[|\]/gi, '')] = _data[i].value; 17659 current = data; 17660 tmpKey = null; 17661 i++; 17662 } 17663 else if (p == -1) 17664 { 17665 current[_data[i].name] = _data[i].value; 17666 current = data; 17667 i++; 17668 } 17669 else 17670 { 17671 name = _data[i].name.substring(0, p); 17672 rest = _data[i].name.substring(p+1); 17673 pp = rest.indexOf(']'); 17674 17675 if(pp == -1) 17676 { 17677 if (!current[name]) 17678 current[name] = []; 17679 current = data; 17680 i++; 17681 } 17682 else if(pp == 0) 17683 { 17684 if (!current[name]) 17685 current[name] = []; 17686 //No index specified - so take the next integer 17687 current = current[name]; 17688 _data[i].name = '' + current.length; 17689 if (rest.substring(pp+1).indexOf('[') === 0) 17690 tmpKey = rest.substring(0, pp) + rest.substring(pp+1); 17691 } 17692 else 17693 { 17694 if (!current[name]) 17695 current[name] = {}; 17696 //Now index name becomes and name and we go deeper into the array 17697 current = current[name]; 17698 _data[i].name = rest.substring(0, pp) + rest.substring(pp+1); 17699 } 17700 } 17701 } 17702 } 17703 return {data : data, filesCount : files, roughSize : length}; 17704}; 17705BX.ajax.submitAjax = function(obForm, config) 17706{ 17707 config = (config !== null && typeof config == "object" ? config : {}); 17708 config.url = (config["url"] || obForm.getAttribute("action")); 17709 17710 var additionalData = (config["data"] || {}); 17711 config.data = BX.ajax.prepareForm(obForm).data; 17712 for (var ii in additionalData) 17713 { 17714 if (additionalData.hasOwnProperty(ii)) 17715 { 17716 config.data[ii] = additionalData[ii]; 17717 } 17718 } 17719 17720 if (!window["FormData"]) 17721 { 17722 BX.ajax(config); 17723 } 17724 else 17725 { 17726 var isFile = function(item) 17727 { 17728 var res = Object.prototype.toString.call(item); 17729 return (res == '[object File]' || res == '[object Blob]'); 17730 }, 17731 appendToForm = function(fd, key, val) 17732 { 17733 if (!!val && typeof val == "object" && !isFile(val)) 17734 { 17735 for (var ii in val) 17736 { 17737 if (val.hasOwnProperty(ii)) 17738 { 17739 appendToForm(fd, (key == '' ? ii : key + '[' + ii + ']'), val[ii]); 17740 } 17741 } 17742 } 17743 else 17744 fd.append(key, (!!val ? val : '')); 17745 }, 17746 prepareData = function(arData) 17747 { 17748 var data = {}; 17749 if (null != arData) 17750 { 17751 if(typeof arData == 'object') 17752 { 17753 for(var i in arData) 17754 { 17755 if (arData.hasOwnProperty(i)) 17756 { 17757 var name = BX.util.urlencode(i); 17758 if(typeof arData[i] == 'object' && arData[i]["file"] !== true) 17759 data[name] = prepareData(arData[i]); 17760 else if (arData[i]["file"] === true) 17761 data[name] = arData[i]["value"]; 17762 else 17763 data[name] = BX.util.urlencode(arData[i]); 17764 } 17765 } 17766 } 17767 else 17768 data = BX.util.urlencode(arData); 17769 } 17770 return data; 17771 }, 17772 fd = new window.FormData(); 17773 17774 if (config.method !== 'POST') 17775 { 17776 config.data = BX.ajax.prepareData(config.data); 17777 if (config.data) 17778 { 17779 config.url += (config.url.indexOf('?') !== -1 ? "&" : "?") + config.data; 17780 config.data = ''; 17781 } 17782 } 17783 else 17784 { 17785 if (config.preparePost === true) 17786 config.data = prepareData(config.data); 17787 appendToForm(fd, '', config.data); 17788 config.data = fd; 17789 } 17790 17791 config.preparePost = false; 17792 config.start = false;
17793 17794 var xhr = BX.ajax(config); 17795 if (!!config["onprogress"]) 17796 xhr.upload.addEventListener( 17797 'progress', 17798 function(e){ 17799 var percent = null; 17800 if(e.lengthComputable && (e.total || e["totalSize"])) { 17801 percent = e.loaded * 100 / (e.total || e["totalSize"]); 17802 } 17803 config["onprogress"](e, percent); 17804 } 17805 ); 17806 xhr.send(fd); 17807 } 17808}; 17809 17810BX.ajax.UpdatePageData = function (arData) 17811{ 17812 if (arData.TITLE) 17813 BX.ajax.UpdatePageTitle(arData.TITLE); 17814 if (arData.WINDOW_TITLE || arData.TITLE) 17815 BX.ajax.UpdateWindowTitle(arData.WINDOW_TITLE || arData.TITLE); 17816 if (arData.NAV_CHAIN) 17817 BX.ajax.UpdatePageNavChain(arData.NAV_CHAIN); 17818 if (arData.CSS && arData.CSS.length > 0) 17819 BX.loadCSS(arData.CSS); 17820 if (arData.SCRIPTS && arData.SCRIPTS.length > 0) 17821 { 17822 var f = function(result,config,cb){ 17823 17824 if(!!config && BX.type.isArray(config.scripts)) 17825 { 17826 for(var i=0,l=arData.SCRIPTS.length;i<l;i++) 17827 { 17828 config.scripts.push({isInternal:false,JS:arData.SCRIPTS[i]}); 17829 } 17830 } 17831 else 17832 { 17833 BX.loadScript(arData.SCRIPTS,cb); 17834 } 17835 17836 BX.removeCustomEvent('onAjaxSuccess',f); 17837 }; 17838 BX.addCustomEvent('onAjaxSuccess',f); 17839 } 17840 else 17841 { 17842 var f1 = function(result,config,cb){ 17843 if(BX.type.isFunction(cb)) 17844 { 17845 cb(); 17846 } 17847 BX.removeCustomEvent('onAjaxSuccess',f1); 17848 }; 17849 BX.addCustomEvent('onAjaxSuccess', f1); 17850 } 17851}; 17852 17853BX.ajax.UpdatePageTitle = function(title) 17854{ 17855 var obTitle = BX('pagetitle'); 17856 if (obTitle) 17857 { 17858 BX.remove(obTitle.firstChild); 17859 if (!obTitle.firstChild) 17860 obTitle.appendChild(document.createTextNode(title)); 17861 else 17862 obTitle.insertBefore(document.createTextNode(title), obTitle.firstChild); 17863 } 17864}; 17865 17866BX.ajax.UpdateWindowTitle = function(title) 17867{ 17868 document.title = title; 17869}; 17870 17871BX.ajax.UpdatePageNavChain = function(nav_chain) 17872{ 17873 var obNavChain = BX('navigation'); 17874 if (obNavChain) 17875 { 17876 obNavChain.innerHTML = nav_chain; 17877 } 17878}; 17879 17880/* user options handling */ 17881BX.userOptions = { 17882 options: null, 17883 bSend: false, 17884 delay: 5000, 17885 path: '/bitrix/admin/user_options.php?' 17886}; 17887 17888BX.userOptions.setAjaxPath = function(url) 17889{ 17890 BX.userOptions.path = url.indexOf('?') == -1? url+'?': url+'&'; 17891} 17892BX.userOptions.save = function(sCategory, sName, sValName, sVal, bCommon) 17893{ 17894 if (null == BX.userOptions.options) 17895 BX.userOptions.options = {}; 17896 17897 bCommon = !!bCommon; 17898 BX.userOptions.options[sCategory+'.'+sName+'.'+sValName] = [sCategory, sName, sValName, sVal, bCommon]; 17899 17900 var sParam = BX.userOptions.__get(); 17901 if (sParam != '') 17902 document.cookie = BX.message('COOKIE_PREFIX')+"_LAST_SETTINGS=" + encodeURIComponent(sParam) + "&sessid="+BX.bitrix_sessid()+"; expires=Thu, 31 Dec " + ((new Date()).getFullYear() + 1) + " 23:59:59 GMT; path=/;"; 17903 17904 if(!BX.userOptions.bSend) 17905 { 17906 BX.userOptions.bSend = true; 17907 setTimeout(function(){BX.userOptions.send(null)}, BX.userOptions.delay); 17908 } 17909}; 17910 17911BX.userOptions.send = function(callback) 17912{ 17913 var sParam = BX.userOptions.__get(); 17914 BX.userOptions.options = null; 17915 BX.userOptions.bSend = false; 17916 17917 if (sParam != '') 17918 { 17919 document.cookie = BX.message('COOKIE_PREFIX') + "_LAST_SETTINGS=; path=/;"; 17920 BX.ajax({ 17921 'method': 'GET', 17922 'dataType': 'html', 17923 'processData': false, 17924 'cache': false, 17925 'url': BX.userOptions.path+sParam+'&sessid='+BX.bitrix_sessid(), 17926 'onsuccess': callback 17927 }); 17928 } 17929}; 17930 17931BX.userOptions.del = function(sCategory, sName, bCommon, callback) 17932{ 17933 BX.ajax.get(BX.userOptions.path+'action=delete&c='+sCategory+'&n='+sName+(bCommon == true? '&common=Y':'')+'&sessid='+BX.bitrix_sessid(), callback); 17934}; 17935 17936BX.userOptions.__get = function() 17937{ 17938 if (!BX.userOptions.options) return ''; 17939 17940 var sParam = '', n = -1, prevParam = '', aOpt, i; 17941 17942 for (i in BX.userOptions.options) 17943 { 17944 if(BX.userOptions.options.hasOwnProperty(i)) 17945 { 17946 aOpt = BX.userOptions.options[i]; 17947 17948 if (prevParam != aOpt[0]+'.'+aOpt[1]) 17949 { 17950 n++; 17951 sParam += '&p['+n+'][c]='+BX.util.urlencode(aOpt[0]); 17952 sParam += '&p['+n+'][n]='+BX.util.urlencode(aOpt[1]); 17953 if (aOpt[4] == true) 17954 sParam += '&p['+n+'][d]=Y'; 17955 prevParam = aOpt[0]+'.'+aOpt[1]; 17956 } 17957 17958 var valueName = aOpt[2]; 17959 var value = aOpt[3]; 17960 17961 if (valueName === null) 17962 { 17963 sParam += '&p['+n+'][v]='+BX.util.urlencode(value); 17964 } 17965 else 17966 {
17967 sParam += '&p['+n+'][v]['+BX.util.urlencode(valueName)+']='+BX.util.urlencode(value); 17968 } 17969 } 17970 } 17971 17972 return sParam.substr(1); 17973}; 17974 17975BX.ajax.history = { 17976 expected_hash: '', 17977 17978 obParams: null, 17979 17980 obFrame: null, 17981 obImage: null, 17982 17983 obTimer: null, 17984 17985 bInited: false, 17986 bHashCollision: false, 17987 bPushState: !!(history.pushState && BX.type.isFunction(history.pushState)), 17988 17989 startState: null, 17990 17991 init: function(obParams) 17992 { 17993 if (BX.ajax.history.bInited) 17994 return; 17995 17996 this.obParams = obParams; 17997 var obCurrentState = this.obParams.getState(); 17998 17999 if (BX.ajax.history.bPushState) 18000 { 18001 BX.ajax.history.expected_hash = window.location.pathname; 18002 if (window.location.search) 18003 BX.ajax.history.expected_hash += window.location.search; 18004 18005 BX.ajax.history.put(obCurrentState, BX.ajax.history.expected_hash, '', true); 18006 // due to some strange thing, chrome calls popstate event on page start. so we should delay it 18007 setTimeout(function(){BX.bind(window, 'popstate', BX.ajax.history.__hashListener);}, 500); 18008 } 18009 else 18010 { 18011 BX.ajax.history.expected_hash = window.location.hash; 18012 18013 if (!BX.ajax.history.expected_hash || BX.ajax.history.expected_hash == '#') 18014 BX.ajax.history.expected_hash = '__bx_no_hash__'; 18015 18016 jsAjaxHistoryContainer.put(BX.ajax.history.expected_hash, obCurrentState); 18017 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 18018 18019 if (BX.browser.IsIE()) 18020 { 18021 BX.ajax.history.obFrame = document.createElement('IFRAME'); 18022 BX.hide_object(BX.ajax.history.obFrame); 18023 18024 document.body.appendChild(BX.ajax.history.obFrame); 18025 18026 BX.ajax.history.obFrame.contentWindow.document.open(); 18027 BX.ajax.history.obFrame.contentWindow.document.write(BX.ajax.history.expected_hash); 18028 BX.ajax.history.obFrame.contentWindow.document.close(); 18029 } 18030 else if (BX.browser.IsOpera()) 18031 { 18032 BX.ajax.history.obImage = document.createElement('IMG'); 18033 BX.hide_object(BX.ajax.history.obImage); 18034 18035 document.body.appendChild(BX.ajax.history.obImage); 18036 18037 BX.ajax.history.obImage.setAttribute('src', 'javascript:location.href = \'javascript:BX.ajax.history.__hashListener();\';'); 18038 } 18039 } 18040 18041 BX.ajax.history.bInited = true; 18042 }, 18043 18044 __hashListener: function(e) 18045 { 18046 e = e || window.event || {state:false}; 18047 18048 if (BX.ajax.history.bPushState) 18049 { 18050 BX.ajax.history.obParams.setState(e.state||BX.ajax.history.startState); 18051 } 18052 else 18053 { 18054 if (BX.ajax.history.obTimer) 18055 { 18056 window.clearTimeout(BX.ajax.history.obTimer); 18057 BX.ajax.history.obTimer = null; 18058 } 18059 18060 var current_hash; 18061 if (null != BX.ajax.history.obFrame) 18062 current_hash = BX.ajax.history.obFrame.contentWindow.document.body.innerText; 18063 else 18064 current_hash = window.location.hash; 18065 18066 if (!current_hash || current_hash == '#') 18067 current_hash = '__bx_no_hash__'; 18068 18069 if (current_hash.indexOf('#') == 0) 18070 current_hash = current_hash.substring(1); 18071 18072 if (current_hash != BX.ajax.history.expected_hash) 18073 { 18074 var state = jsAjaxHistoryContainer.get(current_hash); 18075 if (state) 18076 { 18077 BX.ajax.history.obParams.setState(state); 18078 18079 BX.ajax.history.expected_hash = current_hash; 18080 if (null != BX.ajax.history.obFrame) 18081 { 18082 var __hash = current_hash == '__bx_no_hash__' ? '' : current_hash; 18083 if (window.location.hash != __hash && window.location.hash != '#' + __hash) 18084 window.location.hash = __hash; 18085 } 18086 } 18087 } 18088 18089 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 18090 } 18091 }, 18092 18093 put: function(state, new_hash, new_hash1, bStartState) 18094 { 18095 if (this.bPushState) 18096 { 18097 if(!bStartState) 18098 { 18099 history.pushState(state, '', new_hash); 18100 } 18101 else 18102 { 18103 BX.ajax.history.startState = state; 18104 } 18105 } 18106 else 18107 { 18108 if (typeof new_hash1 != 'undefined') 18109 new_hash = new_hash1; 18110 else 18111 new_hash = 'view' + new_hash; 18112 18113 jsAjaxHistoryContainer.put(new_hash, state); 18114 BX.ajax.history.expected_hash = new_hash; 18115 18116 window.location.hash = BX.util.urlencode(new_hash); 18117 18118 if (null != BX.ajax.history.obFrame) 18119 { 18120 BX.ajax.history.obFrame.contentWindow.document.open(); 18121 BX.ajax.history.obFrame.contentWindow.document.write(new_hash); 18122 BX.ajax.history.obFrame.contentWindow.document.close(); 18123 } 18124 } 18125 }, 18126 18127 checkRedirectStart: function(param_name, param_value) 18128 { 18129 var current_hash = window.location.hash; 18130 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 18131 18132 var test = current_hash.substring(0, 5); 18133 if (test == 'view/' || test == 'view%') 18134 { 18135 BX.ajax.history.bHashCollision = true;
18136 document.write('<' + 'div id="__ajax_hash_collision_' + param_value + '" style="display: none;">'); 18137 } 18138 }, 18139 18140 checkRedirectFinish: function(param_name, param_value) 18141 { 18142 document.write('</div>'); 18143 18144 var current_hash = window.location.hash; 18145 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 18146 18147 BX.ready(function () 18148 { 18149 var test = current_hash.substring(0, 5); 18150 if (test == 'view/' || test == 'view%') 18151 { 18152 var obColNode = BX('__ajax_hash_collision_' + param_value); 18153 var obNode = obColNode.firstChild; 18154 BX.cleanNode(obNode); 18155 obColNode.style.display = 'block'; 18156 18157 // IE, Opera and Chrome automatically modifies hash with urlencode, but FF doesn't ;-( 18158 if (test != 'view%') 18159 current_hash = BX.util.urlencode(current_hash); 18160 18161 current_hash += (current_hash.indexOf('%3F') == -1 ? '%3F' : '%26') + param_name + '=' + param_value; 18162 18163 var url = '/bitrix/tools/ajax_redirector.php?hash=' + current_hash; 18164 18165 BX.ajax.insertToNode(url, obNode); 18166 } 18167 }); 18168 } 18169}; 18170 18171BX.ajax.component = function(node) 18172{ 18173 this.node = node; 18174}; 18175 18176BX.ajax.component.prototype.getState = function() 18177{ 18178 var state = { 18179 'node': this.node, 18180 'title': window.document.title, 18181 'data': BX(this.node).innerHTML 18182 }; 18183 18184 var obNavChain = BX('navigation'); 18185 if (null != obNavChain) 18186 state.nav_chain = obNavChain.innerHTML; 18187 18188 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistoryGetState", [state]); 18189 18190 return state; 18191}; 18192 18193BX.ajax.component.prototype.setState = function(state) 18194{ 18195 BX(state.node).innerHTML = state.data; 18196 BX.ajax.UpdatePageTitle(state.title); 18197 18198 if (state.nav_chain) 18199 { 18200 BX.ajax.UpdatePageNavChain(state.nav_chain); 18201 } 18202 18203 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistorySetState", [state]); 18204}; 18205 18206var jsAjaxHistoryContainer = { 18207 arHistory: {}, 18208 18209 put: function(hash, state) 18210 { 18211 this.arHistory[hash] = state; 18212 }, 18213 18214 get: function(hash) 18215 { 18216 return this.arHistory[hash]; 18217 } 18218}; 18219 18220 18221BX.ajax.FormData = function() 18222{ 18223 this.elements = []; 18224 this.files = []; 18225 this.features = {}; 18226 this.isSupported(); 18227 this.log('BX FormData init'); 18228}; 18229 18230BX.ajax.FormData.isSupported = function() 18231{ 18232 var f = new BX.ajax.FormData(); 18233 var result = f.features.supported; 18234 f = null; 18235 return result; 18236}; 18237 18238BX.ajax.FormData.prototype.log = function(o) 18239{ 18240 if (false) { 18241 try { 18242 if (BX.browser.IsIE()) o = JSON.stringify(o); 18243 console.log(o); 18244 } catch(e) {} 18245 } 18246}; 18247 18248BX.ajax.FormData.prototype.isSupported = function() 18249{ 18250 var f = {}; 18251 f.fileReader = (window.FileReader && window.FileReader.prototype.readAsBinaryString); 18252 f.readFormData = f.sendFormData = !!(window.FormData); 18253 f.supported = !!(f.readFormData && f.sendFormData); 18254 this.features = f; 18255 this.log('features:'); 18256 this.log(f); 18257 18258 return f.supported; 18259}; 18260 18261BX.ajax.FormData.prototype.append = function(name, value) 18262{ 18263 if (typeof(value) === 'object') { // seems to be files element 18264 this.files.push({'name': name, 'value':value}); 18265 } else { 18266 this.elements.push({'name': name, 'value':value}); 18267 } 18268}; 18269 18270BX.ajax.FormData.prototype.send = function(url, callbackOk, callbackProgress, callbackError) 18271{ 18272 this.log('FD send'); 18273 this.xhr = BX.ajax({ 18274 'method': 'POST', 18275 'dataType': 'html', 18276 'url': url, 18277 'onsuccess': callbackOk, 18278 'onfailure': callbackError, 18279 'start': false, 18280 'preparePost':false 18281 }); 18282 18283 if (callbackProgress) 18284 { 18285 this.xhr.upload.addEventListener( 18286 'progress', 18287 function(e) { 18288 if (e.lengthComputable) 18289 callbackProgress(e.loaded / (e.total || e.totalSize)); 18290 }, 18291 false 18292 ); 18293 } 18294 18295 if (this.features.readFormData && this.features.sendFormData) 18296 { 18297 var fd = new FormData(); 18298 this.log('use browser formdata'); 18299 for (var i in this.elements) 18300 { 18301 if(this.elements.hasOwnProperty(i)) 18302 fd.append(this.elements[i].name,this.elements[i].value); 18303 } 18304 for (i in this.files) 18305 { 18306 if(this.files.hasOwnProperty(i)) 18307 fd.append(this.files[i].name, this.files[i].value); 18308 } 18309 this.xhr.send(fd); 18310 } 18311 18312 return this.xhr; 18313}; 18314 18315BX.addCustomEvent('onAjaxFailure', BX.debug); 18316})(window); 18317 18318 18319 18320(function (exports,main_core) { 18321 'use strict'; 18322 18323 var LazyLoad = { 18324 observer: null, 18325 images: {}, 18326 imageStatus: { 18327 hidden: -2, 18328 error: -1, 18329 "undefined": 0, 18330 inited: 1, 18331 loaded: 2 18332 }, 18333 imageTypes: { 18334 image: 1, 18335 background: 2 18336 },
18337 initObserver: function initObserver() { 18338 this.observer = new IntersectionObserver(this.onIntersection.bind(this), { 18339 rootMargin: '20% 0% 20% 0%', 18340 threshold: 0.10 18341 }); 18342 }, 18343 onIntersection: function onIntersection(entries) { 18344 entries.forEach(function (entry) { 18345 if (entry.isIntersecting) { 18346 this.showImage(entry.target); 18347 } 18348 }.bind(this)); 18349 }, 18350 registerImage: function registerImage(id, isImageVisibleCallback, options) { 18351 if (this.observer === null) { 18352 this.initObserver(); 18353 } 18354 18355 options = options || {}; 18356 18357 if (!main_core.Type.isStringFilled(id)) { 18358 return; 18359 } 18360 18361 if (main_core.Type.isObject(this.images[id])) { 18362 return; 18363 } 18364 18365 var element = document.getElementById(id); 18366 18367 if (!main_core.Type.isDomNode(element)) { 18368 return; 18369 } 18370 18371 this.observer.observe(element); 18372 this.images[id] = { 18373 id: id, 18374 node: null, 18375 src: null, 18376 dataSrcName: options.dataSrcName || 'src', 18377 type: null, 18378 func: main_core.Type.isFunction(isImageVisibleCallback) ? isImageVisibleCallback : null, 18379 status: this.imageStatus.undefined 18380 }; 18381 }, 18382 registerImages: function registerImages(ids, isImageVisibleCallback, options) { 18383 if (main_core.Type.isArray(ids)) { 18384 for (var i = 0, length = ids.length; i < length; i++) { 18385 this.registerImage(ids[i], isImageVisibleCallback, options); 18386 } 18387 } 18388 }, 18389 showImage: function showImage(imageNode) { 18390 var imageNodeId = imageNode.id; 18391 18392 if (!main_core.Type.isStringFilled(imageNodeId)) { 18393 return; 18394 } 18395 18396 var image = this.images[imageNodeId]; 18397 18398 if (!main_core.Type.isPlainObject(image)) { 18399 return; 18400 } 18401 18402 if (image.status == this.imageStatus.undefined) { 18403 this.initImage(image); 18404 } 18405 18406 if (image.status !== this.imageStatus.inited) { 18407 return; 18408 } 18409 18410 if (!image.node || !image.node.parentNode) { 18411 image.node = null; 18412 image.status = this.imageStatus.error; 18413 return; 18414 } 18415 18416 if (image.type == this.imageTypes.image) { 18417 image.node.src = image.src; 18418 } else { 18419 image.node.style.backgroundImage = "url('" + image.src + "')"; 18420 } 18421 18422 image.node.dataset[image.dataSrcName] = ""; 18423 image.status = this.imageStatus.loaded; 18424 }, 18425 showImages: function showImages(checkOwnVisibility) { 18426 checkOwnVisibility = checkOwnVisibility !== false; 18427 18428 for (var id in this.images) { 18429 if (!this.images.hasOwnProperty(id)) { 18430 continue; 18431 } 18432 18433 var image = this.images[id]; 18434 18435 if (image.status == this.imageStatus.undefined) { 18436 this.initImage(image); 18437 } 18438 18439 if (image.status !== this.imageStatus.inited) { 18440 continue; 18441 } 18442 18443 if (!image.node || !image.node.parentNode) { 18444 image.node = null; 18445 image.status = this.imageStatus.error; 18446 continue; 18447 } 18448 18449 var isImageVisible = true; 18450 18451 if (checkOwnVisibility && main_core.Type.isFunction(image.func)) { 18452 isImageVisible = image.func(image); 18453 } 18454 18455 if (isImageVisible === true && this.isElementVisibleOnScreen(image.node)) { 18456 if (image.type == this.imageTypes.image) { 18457 image.node.src = image.src; 18458 } else { 18459 image.node.style.backgroundImage = "url('" + image.src + "')"; 18460 } 18461 18462 image.node.dataset[image.dataSrcName] = ""; 18463 image.status = this.imageStatus.loaded; 18464 } 18465 } 18466 }, 18467 initImage: function initImage(image) { 18468 image.status = this.imageStatus.error; 18469 var node = document.getElementById(image.id); 18470 18471 if (!main_core.Type.isDomNode(node)) { 18472 return; 18473 } 18474 18475 var src = node.dataset[image.dataSrcName]; 18476 18477 if (main_core.Type.isStringFilled(src)) { 18478 image.node = node; 18479 image.src = src; 18480 image.status = this.imageStatus.inited; 18481 image.type = image.node.tagName.toLowerCase() == "img" ? this.imageTypes.image : this.imageTypes.background; 18482 } 18483 }, 18484 isElementVisibleOnScreen: function isElementVisibleOnScreen(element) { 18485 var coords = this.getElementCoords(element); 18486 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 18487 var windowBottom = windowTop + document.documentElement.clientHeight; 18488 coords.bottom = coords.top + element.offsetHeight; 18489 return coords.top > windowTop && coords.top < windowBottom || // topVisible 18490 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 18491 ; 18492 }, 18493 isElementVisibleOn2Screens: function isElementVisibleOn2Screens(element) { 18494 var windowHeight = document.documentElement.clientHeight; 18495 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 18496 var windowBottom = windowTop + windowHeight; 18497 var coords = this.getElementCoords(element); 18498 coords.bottom = coords.top + element.offsetHeight; 18499 windowTop -= windowHeight; 18500 windowBottom += windowHeight; 18501 return coords.top > windowTop && coords.top < windowBottom || // topVisible 18502 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 18503 ; 18504 }, 18505 getElementCoords: function getElementCoords(element) { 18506 var box = element.getBoundingClientRect(); 18507 return { 18508 originTop: box.top, 18509 originLeft: box.left, 18510 top: box.top + window.pageYOffset, 18511 left: box.left + window.pageXOffset 18512 }; 18513 }, 18514 onScroll: function onScroll() {}, 18515 clearImages: function clearImages() { 18516 this.images = []; 18517 } 18518 }; 18519 18520 exports.LazyLoad = LazyLoad; 18521 18522}((this.BX = this.BX || {}),BX)); 18523 18524 18525 18526(function (exports) { 18527 'use strict'; 18528 18529 var ParamBag = /*#__PURE__*/function () { 18530 function ParamBag() { 18531 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 18532 babelHelpers.classCallCheck(this, ParamBag); 18533 18534 if (!!params && babelHelpers.typeof(params) === 'object') { 18535 this.params = new Map(Object.entries(params)); 18536 } else { 18537 this.params = new Map(); 18538 } 18539 } 18540 18541 babelHelpers.createClass(ParamBag, [{ 18542 key: "getParam", 18543 value: function getParam(key) { 18544 var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 18545 18546 if (this.params.has(key)) { 18547 return this.params.get(key); 18548 } 18549 18550 return defaultValue; 18551 } 18552 }, { 18553 key: "setParam", 18554 value: function setParam(key, value) { 18555 this.params.set(key, value); 18556 } 18557 }, { 18558 key: "clear", 18559 value: function clear() { 18560 this.params.clear(); 18561 } 18562 }], [{ 18563 key: "create", 18564 value: function create() { 18565 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 18566 return new ParamBag(params); 18567 } 18568 }]); 18569 return ParamBag; 18570 }(); 18571 18572 exports.ParamBag = ParamBag; 18573 18574}((this.BX = this.BX || {}))); 18575 18576 18577 18578(function() { 18579 BX.FixFontSize = function(params) 18580 { 18581 var widthNode, computedStyles, width; 18582 18583 this.node = null; 18584 this.prevWindowSize = 0; 18585 this.prevWrapperSize = 0; 18586 this.mainWrapper = null; 18587 this.textWrapper = null; 18588 this.objList = params.objList; 18589 this.minFontSizeList = []; 18590 this.minFontSize = 0; 18591 18592 if (params.onresize) 18593 { 18594 this.prevWindowSize = window.innerWidth || document.documentElement.clientWidth; 18595 BX.bind(window, 'resize', BX.throttle(this.onResize, 350, this)); 18596 } 18597 18598 if (params.onAdaptiveResize) 18599 { 18600 widthNode = this.objList[0].scaleBy || this.objList[0].node; 18601 computedStyles = getComputedStyle(widthNode); 18602 this.prevWrapperSize = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18603 BX.bind(window, 'resize', BX.throttle(this.onAdaptiveResize, 350, this)); 18604 } 18605 18606 this.createTestNodes(); 18607 this.decrease(); 18608 }; 18609 18610 BX.FixFontSize.prototype = 18611 { 18612 createTestNodes: function() 18613 { 18614 this.textWrapper = BX.create('div',{ 18615 style : { 18616 display : 'inline-block', 18617 whiteSpace : 'nowrap' 18618 } 18619 }); 18620 18621 this.mainWrapper = BX.create('div',{ 18622 style : { 18623 height : 0, 18624 overflow : 'hidden' 18625 }, 18626 children : [this.textWrapper] 18627 }); 18628 18629 }, 18630 insertTestNodes: function() 18631 { 18632 document.body.appendChild(this.mainWrapper); 18633 }, 18634 removeTestNodes: function() 18635 { 18636 document.body.removeChild(this.mainWrapper); 18637 }, 18638 decrease: function() 18639 { 18640 var width, 18641 fontSize, 18642 widthNode, 18643 computedStyles; 18644 18645 this.insertTestNodes(); 18646
18647 for(var i=this.objList.length-1; i>=0; i--) 18648 { 18649 widthNode = this.objList[i].scaleBy || this.objList[i].node; 18650 computedStyles = getComputedStyle(widthNode); 18651 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18652 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 18653 18654 this.textWrapperSetStyle(this.objList[i].node); 18655 18656 if(this.textWrapperInsertText(this.objList[i].node)) 18657 { 18658 while(this.textWrapper.offsetWidth > width && fontSize > 0) 18659 { 18660 this.textWrapper.style.fontSize = --fontSize + 'px'; 18661 } 18662 18663 if(this.objList[i].smallestValue) 18664 { 18665 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 18666 18667 this.minFontSizeList.push(this.objList[i].node) 18668 } 18669 else 18670 { 18671 this.objList[i].node.style.fontSize = fontSize + 'px'; 18672 } 18673 } 18674 } 18675 18676 if(this.minFontSizeList.length > 0) 18677 this.setMinFont(); 18678 18679 this.removeTestNodes(); 18680 18681 }, 18682 increase: function() 18683 { 18684 this.insertTestNodes(); 18685 var width, 18686 fontSize, 18687 widthNode, 18688 computedStyles; 18689 18690 this.insertTestNodes(); 18691 18692 for(var i=this.objList.length-1; i>=0; i--) 18693 { 18694 widthNode = this.objList[i].scaleBy || this.objList[i].node; 18695 computedStyles = getComputedStyle(widthNode); 18696 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18697 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 18698 18699 this.textWrapperSetStyle(this.objList[i].node); 18700 18701 if(this.textWrapperInsertText(this.objList[i].node)) 18702 { 18703 while(this.textWrapper.offsetWidth < width && fontSize < this.objList[i].maxFontSize) 18704 { 18705 this.textWrapper.style.fontSize = ++fontSize + 'px'; 18706 } 18707 18708 fontSize--; 18709 18710 if(this.objList[i].smallestValue) 18711 { 18712 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 18713 18714 this.minFontSizeList.push(this.objList[i].node) 18715 } 18716 else 18717 { 18718 this.objList[i].node.style.fontSize = fontSize + 'px'; 18719 } 18720 } 18721 } 18722 18723 if(this.minFontSizeList.length > 0) 18724 this.setMinFont(); 18725 18726 this.removeTestNodes(); 18727 }, 18728 setMinFont : function() 18729 { 18730 for(var i = this.minFontSizeList.length-1; i>=0; i--) 18731 { 18732 this.minFontSizeList[i].style.fontSize = this.minFontSize + 'px'; 18733 } 18734 18735 this.minFontSize = 0; 18736 }, 18737 onResize : function() 18738 { 18739 var width = window.innerWidth || document.documentElement.clientWidth; 18740 18741 if(this.prevWindowSize > width) 18742 this.decrease(); 18743 18744 else if (this.prevWindowSize < width) 18745 this.increase(); 18746 18747 this.prevWindowSize = width; 18748 }, 18749 onAdaptiveResize : function() 18750 { 18751 var widthNode = this.objList[0].scaleBy || this.objList[0].node, 18752 computedStyles = getComputedStyle(widthNode), 18753 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18754 18755 if (this.prevWrapperSize > width) 18756 this.decrease(); 18757 else if (this.prevWrapperSize < width) 18758 this.increase(); 18759 18760 this.prevWrapperSize = width; 18761 }, 18762 textWrapperInsertText : function(node) 18763 { 18764 if(node.textContent){ 18765 this.textWrapper.textContent = node.textContent; 18766 return true; 18767 } 18768 else if(node.innerText) 18769 { 18770 this.textWrapper.innerText = node.innerText; 18771 return true; 18772 } 18773 else { 18774 return false; 18775 } 18776 }, 18777 textWrapperSetStyle : function(node) 18778 { 18779 this.textWrapper.style.fontFamily = getComputedStyle(node)["font-family"]; 18780 this.textWrapper.style.fontSize = getComputedStyle(node)["font-size"]; 18781 this.textWrapper.style.fontStyle = getComputedStyle(node)["font-style"]; 18782 this.textWrapper.style.fontWeight = getComputedStyle(node)["font-weight"]; 18783 this.textWrapper.style.lineHeight = getComputedStyle(node)["line-height"]; 18784 } 18785 }; 18786 18787 BX.FixFontSize.init = function(params) 18788 { 18789 return new BX.FixFontSize(params); 18790 }; 18791})(); 18792 18793})(); 18794//# 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.