1const getWindowScroll$1 = () => ({ 2 y: 3 window.pageYOffset || 4 document.documentElement.scrollTop || 5 document.body.scrollTop, 6 x: 7 window.pageXOffset || 8 document.documentElement.scrollLeft || 9 document.body.scrollLeft, 10}); 11 12const getIsMobile = () => window.innerWidth < 768; 13const getIsTablet = () => 14 window.innerWidth > 768 && window.innerWidth <= 1024; 15const getIsDesktop = () => window.innerWidth > 1024; 16 17class Header { 18 constructor(container) { 19 if (!container) { 20 return; 21 } 22 23 this.ui = { 24 container: container, 25 body: container.querySelector(".header__body"), 26 }; 27 this.iSticky = false; 28 29 if (this.ui.container) ; 30 } 31 32 initConfig() { 33 this.config = { 34 scrollTop: 148, 35 }; 36 } 37 38 initEvents() { 39 window.addEventListener("scroll", this.onScroll.bind(this)); 40 window.addEventListener("resize", this.onResize.bind(this)); 41 } 42 43 onResize() { 44 this.hideHeader(); 45 this.initConfig(); 46 this.onScroll(); 47 } 48 49 hideHeader() { 50 this.ui.container.classList.remove("is-sticky"); 51 this.iSticky = false; 52 } 53 54 onScroll() { 55 // console.log(this.config.scrollTop); 56 const scrollY = getWindowScroll$1().y; 57 if (!this.iSticky && scrollY > this.config.scrollTop) { 58 this.ui.container.classList.add("is-sticky"); 59 this.iSticky = true; 60 } else if (this.iSticky && scrollY < this.config.scrollTop) { 61 this.ui.container.classList.remove("is-sticky"); 62 this.iSticky = false; 63 } 64 } 65} 66 67class HeaderSearch { 68 constructor(container) { 69 if (!container) { 70 return; 71 } 72 73 this.ui = { 74 container, 75 menuNav: container.querySelector(".menu__nav"), 76 formContent: container.querySelector(".header-form__content"), 77 formInput: container.querySelector(".header-form__input"), 78 buttonOpen: container.querySelector(".header-form__btn-open"), 79 // buttonClose: container.querySelector(".header-form__btn-close"), 80 }; 81 this.isOpen = false; 82 83 if (this.ui.container) { 84 this.initEvents(); 85 } 86 } 87 88 initEvents() { 89 this.ui.buttonOpen.addEventListener("click", this.openSearch.bind(this)); 90 // this.ui.buttonClose.addEventListener("click", this.closeSearch.bind(this)); 91 this.ui.formInput.addEventListener("blur", this.closeSearch.bind(this)); 92 window.addEventListener("resize", this.onResize.bind(this)); 93 } 94 95 onResize() { 96 this.setFormWidth(); 97 } 98 99 setFormWidth() { 100 const formWidth = `${this.ui.menuNav.offsetWidth + 40}px`; 101 102 if (this.isOpen && getIsDesktop()) { 103 this.ui.formContent.style.width = formWidth; 104 } 105 } 106 107 openSearch() { 108 if (!this.isOpen) { 109 this.ui.formContent.classList.add("is-open"); 110 this.ui.formInput.focus(); 111 112 if (getIsDesktop()) { 113 const formWidth = `${this.ui.menuNav.offsetWidth + 60}px`; 114 this.ui.formContent.style.width = formWidth; 115 } 116 117 this.isOpen = true; 118 } 119 } 120 121 closeSearch() { 122 if (this.isOpen) { 123 this.ui.formContent.style.width = 0; 124 this.ui.formContent.classList.remove("is-open"); 125 this.isOpen = false; 126 this.ui.formInput.value = ""; 127 } 128 } 129} 130 131class FooterAccordion { 132 constructor(container) { 133 if (!container) { 134 return; 135 } 136 137 this.ui = { 138 container: container, 139 accordions: container.querySelectorAll(".footer__item--accordion"), 140 }; 141 this.activeAccordion = -1; 142 143 try { 144 if (this.ui.container) { 145 this.initAccordion(); 146 this.initEvents(); 147 } 148 149 } catch (error) { 150 console.error(error); 151 152 } 153 } 154 155 initEvents() { 156 [].forEach.call(this.ui.accordions, (accordion) => 157 accordion.addEventListener("click", this.onClick.bind(this)) 158 ); 159 window.addEventListener("resize", this.onResize.bind(this)); 160 } 161 162 onResize() { 163 if (this.activeAccordion >= 0) { 164 this.closeAccordion( 165 this.ui.accordions[this.activeAccordion], 166 this.activeAccordion 167 ); 168 } 169 this.initAccordion(); 170 } 171 172 initAccordion() { 173 this.configs = []; 174 [].forEach.call(this.ui.accordions, (accordion) => { 175 const trigger = accordion.querySelector(".footer__title"); 176 const content = accordion.querySelector(".footer__list"); 177 // check if content exist to avoid error 178 if (!content) { 179 return; 180 } 181 this.configs.push({ 182 isOpened: false, 183 height: trigger.clientHeight, 184 deployedHeight: trigger.clientHeight + content.clientHeight, 185 }); 186 accordion.style.height = `${trigger.clientHeight}px`; 187 }); 188 } 189 190 onClick(e) { 191 const accordion = e.currentTarget; 192 const index = e.currentTarget.getAttribute("data-index"); 193 const config = index && this.configs[index] ? this.configs[index] : null; 194 195 if (!config.isOpened) { 196 if (this.activeAccordion >= 0) { 197 this.closeAccordion( 198 this.ui.accordions[this.activeAccordion], 199 this.activeAccordion 200 ); 201 } 202 this.openAccordion(accordion, index); 203 } else { 204 this.closeAccordion(accordion, index); 205 } 206 } 207 208 openAccordion(accordion, index) { 209 const config = this.configs[index]; 210 config.isOpened = true; 211 accordion.classList.add("is-opened"); 212 accordion.style.height = `${config.deployedHeight}px`; 213 this.activeAccordion = index; 214 } 215 216 closeAccordion(accordion, index) { 217 const config = this.configs[index]; 218 config.isOpened = false;
219 accordion.classList.remove("is-opened"); 220 accordion.style.height = `${config.height}px`; 221 this.activeAccordion = -1; 222 } 223} 224 225class FilterAccordion { 226 constructor(container) { 227 if (!container) { 228 return; 229 } 230 231 this.ui = { 232 container, 233 trigger: container.querySelector('[data-accordion="trigger"]'), 234 }; 235 // this.isOpen = false; 236 237 if (this.ui.container) { 238 this.initEvents(); 239 } 240 } 241 242 initEvents() { 243 this.ui.trigger.addEventListener("click", this.onToggle.bind(this)); 244 } 245 246 onToggle(e) { 247 e.preventDefault(); 248 // remove all other dropdown open but not on the current element clicked 249 // parse all open dropdown 250 const dropdown = document.querySelectorAll("li.accordion.is-open"); 251 // loop through all dropdown 252 dropdown.forEach((element) => { 253 // check if the current element is the same as the one clicked 254 if (element !== this.ui.container) { 255 // remove the class is-open 256 element.classList.remove("is-open"); 257 } 258 }); 259 260 // New method to to toggle on mobile 261 let dropdownWrapper = this.ui.container.querySelector(".filter-by__filters"); 262 263 if(dropdownWrapper) { 264 dropdownWrapper.classList.toggle("hidden"); 265 } 266 267 268 269 270 if (this.ui.container.classList.contains("is-open")) { 271 this.ui.container.classList.remove("is-open"); 272 // this.isOpen = false; 273 } else { 274 this.ui.container.classList.add("is-open"); 275 // this.isOpen = true; 276 } 277 } 278} 279 280class OrderProducts { 281 constructor(container) { 282 if (!container) { 283 return; 284 } 285 286 287 this.ui = { 288 container, 289 trigger: container.querySelector('[data-accordion="trigger"]'), 290 }; 291 this.isOpen = false; 292 // console.log("UI", this.ui); 293 294 if (this.ui.container) { 295 this.initEvents(); 296 } 297 } 298 299 initEvents() { 300 this.ui.trigger.addEventListener("click", this.onToggle.bind(this)); 301 // console.log("this.ui.container", this.ui.container.querySelectorAll("ul.accordion__content-list li")); 302 303 this.ui.container.querySelectorAll("ul.accordion__content-list > li").forEach((item) => { 304 item.addEventListener("click", this.onClickItem.bind(this)); 305 }); 306 } 307 308 onClickItem(e) { 309 e.preventDefault(); 310 // get data value 311 const filter = e.target.getAttribute("data-value"); 312 const name = e.target.textContent; 313 314 // remove all current on class on each li 315 this.ui.container.querySelectorAll("ul.accordion__content-list > li").forEach((item) => { 316 item.classList.remove("current"); 317 }); 318 319 this.ui.container.querySelector(".accordion__title-inner").textContent = name; 320 this.ui.container.setAttribute("data-sort", filter); 321 e.target.classList.add("current"); 322 this.ui.container.classList.remove("is-open"); 323 // trigger other event called onSort 324 this.ui.container.dispatchEvent(new CustomEvent("onSort", { detail: { filter } })); 325 326 } 327 328 onToggle(e) { 329 e.preventDefault(); 330 331 if (this.ui.container.classList.contains("is-open")) { 332 this.ui.container.classList.remove("is-open"); 333 // this.isOpen = false; 334 } else { 335 this.ui.container.classList.add("is-open"); 336 // this.isOpen = true; 337 } 338 } 339 340} 341 342class FilterTabs {
343 constructor(containers) { 344 if (!containers) { 345 return; 346 } 347 348 containers.forEach(container => { 349 const tab = { 350 container, 351 filters: container.querySelectorAll(".filter__item"), 352 filterButtons: container.querySelectorAll(".filter__btn"), 353 defaultFilter: container.querySelector(".filter__item--active"), 354 cards: container.querySelectorAll(".best-sellers__card-primary"), 355 viewMoreLinks: container.querySelectorAll(".best-sellers__view-more"), 356 }; 357 358 if (tab.container) { 359 this.initEvents(tab); 360 this.filterCards(tab, tab.defaultFilter); 361 this.toggleActiveLinks(tab, tab.defaultFilter); 362 } 363 }); 364 365 // this.ui = { 366 // container, 367 // filters: container.querySelectorAll(".filter__item"), 368 // filterButtons: container.querySelectorAll(".filter__btn"), 369 // defaultFilter: container.querySelector(".filter__item--active"), 370 // cards: container.querySelectorAll(".best-sellers__card-primary"), 371 // viewMoreLinks: container.querySelectorAll(".best-sellers__view-more"), 372 // }; 373 374 // if (this.ui.container) { 375 // this.initEvents(); 376 // this.filterCards(this.ui.defaultFilter); 377 // this.toggleActiveLinks(this.ui.defaultFilter); 378 // } 379 } 380 381 initEvents(tab) { 382 let self = this; 383 384 tab.filterButtons.forEach((filter) => { 385 // filter.addEventListener("click", this.onClick.bind(this)); 386 filter.addEventListener("click", function(e) { 387 const activeFilter = e.target.parentNode; 388 self.toggleActiveFilters(tab, activeFilter); 389 self.filterCards(tab, activeFilter); 390 self.toggleActiveLinks(tab, activeFilter); 391 }); 392 }); 393 } 394 395 toggleActiveFilters(tab, selectedFilter) { 396 // Convert NodeList into array 397 const filters = Array.prototype.slice.call(tab.filters); 398 399 filters.map((filter) => filter.classList.remove("filter__item--active")); 400 selectedFilter.classList.add("filter__item--active"); 401 } 402 403 filterCards(tab, activeFilter) { 404 // Convert NodeList into array 405 const cards = Array.prototype.slice.call(tab.cards); 406 407 cards.forEach((card) => { 408 card.classList.add("hidden"); 409 }); 410 411 cards 412 .filter((card) => card.dataset.public === activeFilter.dataset.public) 413 .forEach((card, index) => { 414 if (index < 6) { 415 card.classList.remove("hidden"); 416 } 417 }); 418 } 419 420 toggleActiveLinks(tab, activeFilter) { 421 // Convert NodeList into array 422 const viewMoreLinks = Array.prototype.slice.call(tab.viewMoreLinks); 423 424 viewMoreLinks.forEach((link) => { 425 link.classList.add("!hidden"); 426 }); 427 428 const activeViewMoreLink = viewMoreLinks.find( 429 (link) => link.dataset.public === activeFilter.dataset.public 430 ); 431 432 activeViewMoreLink.classList.remove("!hidden"); 433 } 434 435 onClick(e) { 436 const activeFilter = e.target.parentNode; 437 this.toggleActiveFilters(activeFilter); 438 this.filterCards(activeFilter); 439 this.toggleActiveLinks(activeFilter); 440 } 441} 442 443class FilterTabsSearch { 444 constructor(container) { 445 if (!container) { 446 return; 447 } 448 449 console.log("FilterTabsSearch initialized"); 450 451 this.ui = { 452 container, 453 filters: container.querySelectorAll(".filter__item"), 454 filterButtons: container.querySelectorAll(".filter__btn"), 455 defaultFilter: container.querySelector(".filter__item--active"), 456 resultContainers: container.querySelectorAll(".search-results__list"), 457 }; 458 459 if (this.ui.container) { 460 this.initEvents(); 461 this.toggleResultContainer(this.ui.defaultFilter); 462 } 463 } 464 465 initEvents() { 466 this.ui.filterButtons.forEach((filter) => { 467 filter.addEventListener("click", this.onClick.bind(this)); 468 }); 469 } 470 471 toggleActiveFilters(selectedFilter) { 472 // Convert NodeList into array 473 const filters = Array.prototype.slice.call(this.ui.filters); 474 475 filters.map((filter) => filter.classList.remove("filter__item--active", "border-neutral-900", "text-neutral-900")); 476 selectedFilter.classList.add("filter__item--active", "border-neutral-900", "text-neutral-900"); 477 } 478 479 toggleResultContainer(activeFilter) { 480 console.log(activeFilter.dataset.search); 481 // Convert NodeList into array 482 const resultContainers = Array.prototype.slice.call( 483 this.ui.resultContainers 484 ); 485
486 // console.log(resultContainers); 487 488 resultContainers.forEach((container) => { 489 container.classList.add("hidden"); 490 }); 491 492 resultContainers 493 .filter( 494 (container) => container.dataset.search === activeFilter.dataset.search 495 ) 496 .forEach((container) => { 497 container.classList.remove("hidden"); 498 container.classList.add("grid"); 499 }); 500 } 501 502 onClick(e) { 503 const activeFilter = e.target.parentNode; 504 this.toggleActiveFilters(activeFilter); 505 this.toggleResultContainer(activeFilter); 506 } 507} 508 509class ModalProduct { 510 constructor(container) { 511 if (!container) { 512 return; 513 } 514 515 this.ui = { 516 container, 517 closeBtn: container.querySelector(".modal__close"), 518 skipBtn: document.querySelector(".newsletter-skip"), 519 overlay: container.querySelector(".modal__overlay"), 520 triggerButtons: document.querySelectorAll("[data-modal-trigger]"), 521 htmlTag: document.body.parentNode, 522 bodyTag: document.body, 523 }; 524 525 if (this.ui.container) { 526 this.initEvents(); 527 } 528 } 529 530 initEvents() { 531 // Convert NodeList into array 532 const triggers = Array.prototype.slice.call(this.ui.triggerButtons); 533 534 triggers 535 .filter( 536 (trigger) => 537 trigger.dataset.modalTrigger === 538 this.ui.container.dataset.modalContent 539 ) 540 .forEach((trigger) => { 541 trigger.addEventListener("click", this.openModal.bind(this)); 542 }); 543 544 this.ui.closeBtn.addEventListener("click", this.closeModal.bind(this)); 545 if(this.ui.skipBtn !== null){ 546 this.ui.skipBtn.addEventListener("click", this.closeModal.bind(this)); 547 } 548 549 this.ui.overlay.addEventListener("click", this.closeModal.bind(this)); 550 } 551 552 openModal() { 553 this.ui.container.classList.add("is-active"); 554 this.ui.htmlTag.classList.add("overflow-hidden"); 555 this.ui.bodyTag.classList.add("overflow-hidden", "padding-scrollbar"); 556 } 557 558 closeModal() { 559 this.ui.container.classList.remove("is-active"); 560 this.ui.htmlTag.classList.remove("overflow-hidden"); 561 this.ui.bodyTag.classList.remove("overflow-hidden", "padding-scrollbar"); 562 } 563} 564 565const MAX_HEIGHT_MOBILE = 264; 566const MAX_HEIGHT_DESKTOP = "none"; 567 568class ViewToggle { 569 constructor(container) { 570 if (!container) { 571 return; 572 } 573 574 this.ui = { 575 container, 576 buttonToggle: container.querySelector('[data-view-toggle="trigger"]'), 577 buttonWrapper: container.querySelector( 578 '[data-view-toggle="trigger-wrapper"]' 579 ), 580 bulletListWrapper: container.querySelector( 581 '[data-view-toggle="content"]' 582 ), 583 bulletList: container.querySelector('[data-view-toggle="content-inner"]'), 584 }; 585 this.isOpen = false; 586 587 if (this.ui.container && this.ui.bulletListWrapper) { 588 this.initEvents(); 589 } 590 } 591 592 initEvents() { 593 this.displayToggleBtn(); 594 this.ui.buttonToggle.addEventListener( 595 "click", 596 this.toggleContent.bind(this) 597 ); 598 window.addEventListener("resize", this.onResize.bind(this)); 599 } 600 601 onResize() { 602 this.displayToggleBtn(); 603 } 604 605 displayToggleBtn() { 606 const isVisibleMobile = 607 (getIsMobile() || getIsTablet()) && 608 this.ui.bulletList.offsetHeight > MAX_HEIGHT_MOBILE; 609 610 if (isVisibleMobile) { 611 this.ui.buttonWrapper.classList.remove("is-hidden"); 612 } else { 613 this.ui.buttonWrapper.classList.add("is-hidden"); 614 } 615 } 616 617 toggleContent() { 618 const bulletListHeight = this.ui.bulletList.offsetHeight; 619 const initialMaxHeight = getIsDesktop() 620 ? MAX_HEIGHT_DESKTOP 621 : MAX_HEIGHT_MOBILE; 622 623 if (this.isOpen) { 624 this.ui.bulletListWrapper.style.maxHeight = `${initialMaxHeight}px`; 625 this.ui.buttonToggle.classList.remove("is-open"); 626 this.isOpen = false; 627 } else { 628 this.ui.bulletListWrapper.style.maxHeight = `${bulletListHeight}px`; 629 this.ui.buttonToggle.classList.add("is-open"); 630 this.isOpen = true; 631 } 632 } 633} 634 635class ScrollToAnchor { 636 constructor(container) { 637 if (!container) { 638 return; 639 } 640 641 this.ui = { 642 container, 643 buttons: container.querySelectorAll("[data-scroll-to]"), 644 }; 645 646 if (this.ui.container) { 647 this.initEvents(); 648 } 649 } 650 651 initEvents() { 652 // Convert NodeList into array 653 const scrollTriggers = Array.prototype.slice.call(this.ui.buttons); 654
655 scrollTriggers.forEach((trigger) => { 656 trigger.addEventListener("click", this.scrollToAnchor.bind(this)); 657 }); 658 } 659 660 scrollToAnchor(e) { 661 const trigger = e.currentTarget; 662 const anchor = trigger.getAttribute("data-scroll-to"); 663 const extraOffset = Number(trigger.getAttribute("data-scroll-offset")); 664 const destination = document.querySelector(anchor); 665 666 const offsetTop = 667 destination.getBoundingClientRect().top + 668 window.pageYOffset - 669 extraOffset; 670 671 window.scrollTo({ top: offsetTop, behavior: "smooth" }); 672 } 673 } 674 675class BackLink { 676 constructor(container) { 677 if (!container) { 678 return; 679 } 680 681 this.ui = { 682 container: container, 683 }; 684 685 if (this.ui.container) { 686 this.initEvents(); 687 } 688 } 689 690 initConfig() { 691 this.config = { 692 scrollTop: this.ui.body.offsetTop, 693 }; 694 } 695 696 initEvents() { 697 this.ui.container.addEventListener("click", this.onClick.bind(this)); 698 } 699 700 onClick(e) { 701 e.preventDefault(); 702 const homePath = e.currentTarget.getAttribute("href"); 703 const sitePath = window.location.origin; 704 const previousPath = document.referrer; 705 if (previousPath && previousPath.indexOf(sitePath) >= 0) { 706 history.go(-1); 707 } else { 708 window.location.href = homePath; 709 } 710 } 711} 712 713class Share { 714 constructor(container) { 715 if (!container) { 716 return; 717 } 718 719 this.ui = { 720 container: container, 721 links: container.querySelectorAll(".share__item"), 722 clipboard: container.querySelector(".share__clipboard"), 723 }; 724 725 if (this.ui.container) { 726 this.initEvents(); 727 } 728 } 729 730 initConfig() { 731 this.config = { 732 scrollTop: this.ui.body.offsetTop, 733 }; 734 } 735 736 initEvents() { 737 [].forEach.call(this.ui.links, (link) => { 738 link.addEventListener("click", this.onClick.bind(this)); 739 }); 740 } 741 742 onClick(e) { 743 e.preventDefault(); 744 const target = e.currentTarget; 745 const type = target.getAttribute("data-type"); 746 const url = window.location; 747 const width = 640; 748 const height = 480; 749 const title = document.title; 750 const encodedTitle = encodeURI(title); 751 752 switch (type) { 753 case "facebook": 754 this.popupCenter( 755 `https://www.facebook.com/sharer.php?u=${url}&name=${encodedTitle}`, 756 "Facebook Share", 757 width, 758 height 759 ); 760 break; 761 case "twitter": 762 this.popupCenter( 763 `https://twitter.com/intent/tweet?url=${url}&text=${encodedTitle}`, 764 "Twitter Share", 765 width, 766 height 767 ); 768 break; 769 default: 770 if (navigator && navigator.share) { 771 this.shareMobile(title, url); 772 } else { 773 this.copyToClipBoard(url); 774 } 775 break; 776 } 777 } 778 779 shareMobile(text, url) { 780 navigator.share({ 781 title: "Share this article", 782 text: text, 783 url: url, 784 }); 785 } 786 787 copyToClipBoard(str) { 788 const el = document.createElement("textarea"); 789 el.value = str; 790 el.setAttribute("readonly", ""); 791 el.style.position = "absolute"; 792 el.style.left = "-9999px"; 793 document.body.appendChild(el); 794 el.select(); 795 document.execCommand("copy"); 796 document.body.removeChild(el); 797 798 this.ui.clipboard.style.display = "block"; 799 setTimeout(() => (this.ui.clipboard.style.display = "none"), 1000); 800 } 801 802 popupCenter(url, title, w, h) { 803 // Fixes dual-screen position 804 let dualScreenLeft = 805 window.screenLeft !== undefined ? window.screenLeft : window.screenX; 806 let dualScreenTop = 807 window.screenTop !== undefined ? window.screenTop : window.screenY; 808 let width = window.innerWidth 809 ? window.innerWidth 810 : document.documentElement.clientWidth; 811 let height = window.innerHeight 812 ? window.innerHeight 813 : document.documentElement.clientHeight; 814 let left = width / 2 - w / 2 + dualScreenLeft; 815 let top = height / 2 - h / 2 + dualScreenTop; 816 let newWindow = window.open( 817 url, 818 title, 819 "scrollbars=yes, width=" + 820 w + 821 ", height=" + 822 h + 823 ", top=" + 824 top + 825 ", left=" + 826 left 827 );
828 // Puts focus on the newWindow 829 if (window.focus) { 830 newWindow.focus(); 831 } 832 } 833} 834 835class CardSocial { 836 constructor(container, ajax_url, type) { 837 if (!container) { 838 return; 839 } 840 841 this.ajax_url = ajax_url; 842 this.type = type; 843 844 this.ui = { 845 container: container, 846 img: container.querySelectorAll("figure img"), 847 }; 848 849 this.images = []; 850 this.imageList = []; 851 this.currentImagesIndex = 0; 852 853 [].forEach.call(this.ui.img, (img) => { 854 this.images.push({ 855 ui: img, 856 src: "", 857 isHidden: true, 858 isFirstLoad: true, 859 }); 860 }); 861 this.minImagesLength = this.ui.img.length; 862 this.getFlbImages(); 863 this.fetchAPIContent(); 864 } 865 866 getFlbImages() { 867 this.flbImages = this.images.map((img) => img.ui.getAttribute("src")); 868 } 869 870 fetchAPIContent() { 871 fetch(this.ajax_url, { 872 credentials: "same-origin", 873 method: "POST", 874 headers: { 875 "Content-Type": "application/x-www-form-urlencoded", 876 "Cache-Control": "no-cache", 877 }, 878 body: new URLSearchParams({ 879 action: this.type, 880 }), 881 }) 882 .then((response) => { 883 return response.json(); 884 }) 885 .then((data) => { 886 if (data.length > 0) { 887 this.imageList = []; 888 data.map((data) => { 889 const tempEl = document.createElement("div"); 890 if (data.post_content) { 891 tempEl.innerHTML = data.post_content; 892 const img = tempEl.querySelector("img"); 893 if (img && img.src) { 894 this.imageList.push({ src: img.src, isLoaded: false }); 895 } 896 } 897 }); 898 if (this.imageList.length < this.minImagesLength) { 899 const nbPostToAdd = this.minImagesLength - this.imageList.length; 900 const postsToAdd = []; 901 902 for (let i = 0; i <= nbPostToAdd; i++) { 903 const flbImage = this.flbImages[i]; 904 postsToAdd.push({ src: flbImage, isLoaded: false }); 905 } 906 this.imageList = postsToAdd.concat(this.imageList); 907 } 908 } else { 909 this.showFallBackImages(); 910 } 911 }) 912 .then(() => { 913 this.init(); 914 this.initEvents(); 915 }) 916 .catch(() => { 917 this.showFallBackImages(); 918 }); 919 } 920 921 showFallBackImages() { 922 this.images.forEach((img) => { 923 img.ui.style.opacity = 1; 924 }); 925 } 926 927 init() { 928 this.loadImages(); 929 this.setCarousel(); 930 } 931 932 setCarousel() { 933 this.interval = null; 934 clearInterval(this.interval); 935 if (this.imageList.length > this.minImagesLength) { 936 this.interval = setInterval(this.loadImages.bind(this), 6000); 937 } 938 } 939 940 initEvents() { 941 this.images.forEach((item) => { 942 item.ui.addEventListener( 943 "transitionend", 944 this.onTransitionEnd.bind(this, item) 945 ); 946 }); 947 948 window.addEventListener("resize", this.onResize.bind(this)); 949 } 950 951 loadImages() { 952 const currentImagesIndex = this.currentImagesIndex; 953 this.images.forEach((item, index) => { 954 const nextIndex = currentImagesIndex + index; 955 const realNextIndex = 956 nextIndex < this.imageList.length 957 ? nextIndex 958 : nextIndex % this.imageList.length; 959 const matchingImg = this.imageList[realNextIndex]; 960 this.currentImagesIndex = realNextIndex; 961 item.src = matchingImg.src; 962 963 if (matchingImg.isLoaded) { 964 this.handleTransition(item); 965 } else { 966 const img = document.createElement("img"); 967 img.src = item.src; 968 img.addEventListener("load", () => { 969 matchingImg.isLoaded = true; 970 this.handleTransition(item); 971 }); 972 } 973 }); 974 } 975 976 handleTransition(item) { 977 if (item.isFirstLoad) { 978 item.isFirstLoad = false; 979 this.setImage(item); 980 } else { 981 this.hideImage(item); 982 } 983 } 984 985 onTransitionEnd(item) { 986 if (item.isHidden && !item.isFirstLoad) { 987 this.setImage(item); 988 } 989 } 990 991 onResize() { 992 this.setCarousel(); 993 this.images.forEach((item) => this.setImage(item)); 994 } 995 996 hideImage(item) { 997 item.ui.style.opacity = 0; 998 item.isHidden = true; 999 } 1000 1001 setImage(item) { 1002 item.ui.src = item.src; 1003 item.ui.style.opacity = 1; 1004 item.isHidden = false;
1005 } 1006} 1007 1008var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; 1009 1010function getDefaultExportFromCjs (x) { 1011 return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
vendor: 19,923 bytes, lines 1011-1743
1011 1012} 1013 1014/** 1015 * Checks if `value` is the 1016 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) 1017 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) 1018 * 1019 * @static 1020 * @memberOf _ 1021 * @since 0.1.0 1022 * @category Lang 1023 * @param {*} value The value to check. 1024 * @returns {boolean} Returns `true` if `value` is an object, else `false`. 1025 * @example 1026 * 1027 * _.isObject({}); 1028 * // => true 1029 * 1030 * _.isObject([1, 2, 3]); 1031 * // => true 1032 * 1033 * _.isObject(_.noop); 1034 * // => true 1035 * 1036 * _.isObject(null); 1037 * // => false 1038 */ 1039 1040var isObject_1; 1041var hasRequiredIsObject; 1042 1043function requireIsObject () { 1044 if (hasRequiredIsObject) return isObject_1; 1045 hasRequiredIsObject = 1; 1046 function isObject(value) { 1047 var type = typeof value; 1048 return value != null && (type == 'object' || type == 'function'); 1049 } 1050 1051 isObject_1 = isObject; 1052 return isObject_1; 1053} 1054 1055/** Detect free variable `global` from Node.js. */ 1056 1057var _freeGlobal; 1058var hasRequired_freeGlobal; 1059 1060function require_freeGlobal () { 1061 if (hasRequired_freeGlobal) return _freeGlobal; 1062 hasRequired_freeGlobal = 1; 1063 var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; 1064 1065 _freeGlobal = freeGlobal; 1066 return _freeGlobal; 1067} 1068 1069var _root; 1070var hasRequired_root; 1071 1072function require_root () { 1073 if (hasRequired_root) return _root; 1074 hasRequired_root = 1; 1075 var freeGlobal = require_freeGlobal(); 1076 1077 /** Detect free variable `self`. */ 1078 var freeSelf = typeof self == 'object' && self && self.Object === Object && self; 1079 1080 /** Used as a reference to the global object. */ 1081 var root = freeGlobal || freeSelf || Function('return this')(); 1082 1083 _root = root; 1084 return _root; 1085} 1086 1087var now_1; 1088var hasRequiredNow; 1089 1090function requireNow () { 1091 if (hasRequiredNow) return now_1; 1092 hasRequiredNow = 1; 1093 var root = require_root(); 1094 1095 /** 1096 * Gets the timestamp of the number of milliseconds that have elapsed since 1097 * the Unix epoch (1 January 1970 00:00:00 UTC). 1098 * 1099 * @static 1100 * @memberOf _ 1101 * @since 2.4.0 1102 * @category Date 1103 * @returns {number} Returns the timestamp. 1104 * @example 1105 * 1106 * _.defer(function(stamp) { 1107 * console.log(_.now() - stamp); 1108 * }, _.now()); 1109 * // => Logs the number of milliseconds it took for the deferred invocation. 1110 */ 1111 var now = function() { 1112 return root.Date.now(); 1113 }; 1114 1115 now_1 = now; 1116 return now_1; 1117} 1118 1119/** Used to match a single whitespace character. */ 1120 1121var _trimmedEndIndex; 1122var hasRequired_trimmedEndIndex; 1123 1124function require_trimmedEndIndex () { 1125 if (hasRequired_trimmedEndIndex) return _trimmedEndIndex; 1126 hasRequired_trimmedEndIndex = 1; 1127 var reWhitespace = /\s/; 1128 1129 /** 1130 * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace 1131 * character of `string`. 1132 * 1133 * @private 1134 * @param {string} string The string to inspect. 1135 * @returns {number} Returns the index of the last non-whitespace character. 1136 */ 1137 function trimmedEndIndex(string) { 1138 var index = string.length; 1139 1140 while (index-- && reWhitespace.test(string.charAt(index))) {} 1141 return index; 1142 } 1143 1144 _trimmedEndIndex = trimmedEndIndex; 1145 return _trimmedEndIndex; 1146} 1147 1148var _baseTrim; 1149var hasRequired_baseTrim; 1150 1151function require_baseTrim () { 1152 if (hasRequired_baseTrim) return _baseTrim; 1153 hasRequired_baseTrim = 1; 1154 var trimmedEndIndex = require_trimmedEndIndex(); 1155 1156 /** Used to match leading whitespace. */ 1157 var reTrimStart = /^\s+/; 1158 1159 /** 1160 * The base implementation of `_.trim`. 1161 * 1162 * @private 1163 * @param {string} string The string to trim. 1164 * @returns {string} Returns the trimmed string. 1165 */ 1166 function baseTrim(string) { 1167 return string 1168 ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') 1169 : string; 1170 } 1171 1172 _baseTrim = baseTrim; 1173 return _baseTrim; 1174} 1175 1176var _Symbol; 1177var hasRequired_Symbol; 1178 1179function require_Symbol () { 1180 if (hasRequired_Symbol) return _Symbol; 1181 hasRequired_Symbol = 1; 1182 var root = require_root(); 1183 1184 /** Built-in value references. */ 1185 var Symbol = root.Symbol; 1186 1187 _Symbol = Symbol; 1188 return _Symbol; 1189} 1190 1191var _getRawTag; 1192var hasRequired_getRawTag; 1193 1194function require_getRawTag () { 1195 if (hasRequired_getRawTag) return _getRawTag; 1196 hasRequired_getRawTag = 1; 1197 var Symbol = require_Symbol(); 1198 1199 /** Used for built-in method references. */ 1200 var objectProto = Object.prototype; 1201 1202 /** Used to check objects for own properties. */ 1203 var hasOwnProperty = objectProto.hasOwnProperty; 1204 1205 /** 1206 * Used to resolve the 1207 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) 1208 * of values. 1209 */ 1210 var nativeObjectToString = objectProto.toString; 1211 1212 /** Built-in value references. */ 1213 var symToStringTag = Symbol ? Symbol.toStringTag : undefined; 1214 1215 /** 1216 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. 1217 * 1218 * @private 1219 * @param {*} value The value to query. 1220 * @returns {string} Returns the raw `toStringTag`. 1221 */ 1222 function getRawTag(value) { 1223 var isOwn = hasOwnProperty.call(value, symToStringTag), 1224 tag = value[symToStringTag]; 1225 1226 try { 1227 value[symToStringTag] = undefined; 1228 var unmasked = true; 1229 } catch (e) {} 1230 1231 var result = nativeObjectToString.call(value); 1232 if (unmasked) { 1233 if (isOwn) { 1234 value[symToStringTag] = tag; 1235 } else { 1236 delete value[symToStringTag]; 1237 } 1238 } 1239 return result; 1240 } 1241 1242 _getRawTag = getRawTag; 1243 return _getRawTag; 1244} 1245 1246/** Used for built-in method references. */ 1247 1248var _objectToString; 1249var hasRequired_objectToString; 1250 1251function require_objectToString () { 1252 if (hasRequired_objectToString) return _objectToString; 1253 hasRequired_objectToString = 1; 1254 var objectProto = Object.prototype; 1255 1256 /** 1257 * Used to resolve the 1258 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) 1259 * of values. 1260 */ 1261 var nativeObjectToString = objectProto.toString; 1262 1263 /** 1264 * Converts `value` to a string using `Object.prototype.toString`. 1265 * 1266 * @private 1267 * @param {*} value The value to convert. 1268 * @returns {string} Returns the converted string. 1269 */ 1270 function objectToString(value) { 1271 return nativeObjectToString.call(value); 1272 } 1273 1274 _objectToString = objectToString; 1275 return _objectToString; 1276} 1277 1278var _baseGetTag; 1279var hasRequired_baseGetTag; 1280 1281function require_baseGetTag () { 1282 if (hasRequired_baseGetTag) return _baseGetTag; 1283 hasRequired_baseGetTag = 1; 1284 var Symbol = require_Symbol(), 1285 getRawTag = require_getRawTag(), 1286 objectToString = require_objectToString(); 1287 1288 /** `Object#toString` result references. */ 1289 var nullTag = '[object Null]', 1290 undefinedTag = '[object Undefined]'; 1291 1292 /** Built-in value references. */ 1293 var symToStringTag = Symbol ? Symbol.toStringTag : undefined; 1294 1295 /** 1296 * The base implementation of `getTag` without fallbacks for buggy environments. 1297 * 1298 * @private 1299 * @param {*} value The value to query. 1300 * @returns {string} Returns the `toStringTag`. 1301 */ 1302 function baseGetTag(value) { 1303 if (value == null) { 1304 return value === undefined ? undefinedTag : nullTag; 1305 } 1306 return (symToStringTag && symToStringTag in Object(value)) 1307 ? getRawTag(value) 1308 : objectToString(value); 1309 } 1310 1311 _baseGetTag = baseGetTag; 1312 return _baseGetTag; 1313} 1314 1315/** 1316 * Checks if `value` is object-like. A value is object-like if it's not `null` 1317 * and has a `typeof` result of "object". 1318 * 1319 * @static 1320 * @memberOf _ 1321 * @since 4.0.0 1322 * @category Lang 1323 * @param {*} value The value to check. 1324 * @returns {boolean} Returns `true` if `value` is object-like, else `false`. 1325 * @example 1326 * 1327 * _.isObjectLike({}); 1328 * // => true 1329 * 1330 * _.isObjectLike([1, 2, 3]); 1331 * // => true 1332 * 1333 * _.isObjectLike(_.noop); 1334 * // => false 1335 * 1336 * _.isObjectLike(null); 1337 * // => false 1338 */ 1339 1340var isObjectLike_1; 1341var hasRequiredIsObjectLike; 1342 1343function requireIsObjectLike () { 1344 if (hasRequiredIsObjectLike) return isObjectLike_1; 1345 hasRequiredIsObjectLike = 1; 1346 function isObjectLike(value) { 1347 return value != null && typeof value == 'object'; 1348 } 1349 1350 isObjectLike_1 = isObjectLike; 1351 return isObjectLike_1; 1352} 1353 1354var isSymbol_1; 1355var hasRequiredIsSymbol; 1356 1357function requireIsSymbol () { 1358 if (hasRequiredIsSymbol) return isSymbol_1; 1359 hasRequiredIsSymbol = 1; 1360 var baseGetTag = require_baseGetTag(), 1361 isObjectLike = requireIsObjectLike(); 1362 1363 /** `Object#toString` result references. */ 1364 var symbolTag = '[object Symbol]'; 1365 1366 /** 1367 * Checks if `value` is classified as a `Symbol` primitive or object. 1368 * 1369 * @static 1370 * @memberOf _ 1371 * @since 4.0.0 1372 * @category Lang 1373 * @param {*} value The value to check. 1374 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. 1375 * @example 1376 * 1377 * _.isSymbol(Symbol.iterator); 1378 * // => true 1379 * 1380 * _.isSymbol('abc'); 1381 * // => false 1382 */ 1383 function isSymbol(value) { 1384 return typeof value == 'symbol' || 1385 (isObjectLike(value) && baseGetTag(value) == symbolTag); 1386 } 1387 1388 isSymbol_1 = isSymbol; 1389 return isSymbol_1; 1390} 1391 1392var toNumber_1; 1393var hasRequiredToNumber; 1394 1395function requireToNumber () { 1396 if (hasRequiredToNumber) return toNumber_1; 1397 hasRequiredToNumber = 1; 1398 var baseTrim = require_baseTrim(), 1399 isObject = requireIsObject(), 1400 isSymbol = requireIsSymbol(); 1401 1402 /** Used as references for various `Number` constants. */ 1403 var NAN = 0 / 0; 1404 1405 /** Used to detect bad signed hexadecimal string values. */ 1406 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; 1407 1408 /** Used to detect binary string values. */ 1409 var reIsBinary = /^0b[01]+$/i; 1410 1411 /** Used to detect octal string values. */ 1412 var reIsOctal = /^0o[0-7]+$/i; 1413 1414 /** Built-in method references without a dependency on `root`. */ 1415 var freeParseInt = parseInt; 1416 1417 /** 1418 * Converts `value` to a number. 1419 * 1420 * @static 1421 * @memberOf _ 1422 * @since 4.0.0 1423 * @category Lang 1424 * @param {*} value The value to process. 1425 * @returns {number} Returns the number. 1426 * @example 1427 * 1428 * _.toNumber(3.2); 1429 * // => 3.2 1430 * 1431 * _.toNumber(Number.MIN_VALUE); 1432 * // => 5e-324 1433 * 1434 * _.toNumber(Infinity); 1435 * // => Infinity 1436 * 1437 * _.toNumber('3.2'); 1438 * // => 3.2 1439 */ 1440 function toNumber(value) { 1441 if (typeof value == 'number') { 1442 return value; 1443 } 1444 if (isSymbol(value)) { 1445 return NAN; 1446 } 1447 if (isObject(value)) { 1448 var other = typeof value.valueOf == 'function' ? value.valueOf() : value; 1449 value = isObject(other) ? (other + '') : other; 1450 } 1451 if (typeof value != 'string') { 1452 return value === 0 ? value : +value; 1453 } 1454 value = baseTrim(value); 1455 var isBinary = reIsBinary.test(value); 1456 return (isBinary || reIsOctal.test(value)) 1457 ? freeParseInt(value.slice(2), isBinary ? 2 : 8) 1458 : (reIsBadHex.test(value) ? NAN : +value); 1459 } 1460 1461 toNumber_1 = toNumber; 1462 return toNumber_1; 1463} 1464 1465var debounce_1; 1466var hasRequiredDebounce; 1467 1468function requireDebounce () { 1469 if (hasRequiredDebounce) return debounce_1; 1470 hasRequiredDebounce = 1; 1471 var isObject = requireIsObject(), 1472 now = requireNow(), 1473 toNumber = requireToNumber(); 1474 1475 /** Error message constants. */ 1476 var FUNC_ERROR_TEXT = 'Expected a function'; 1477 1478 /* Built-in method references for those with the same name as other `lodash` methods. */ 1479 var nativeMax = Math.max, 1480 nativeMin = Math.min; 1481 1482 /** 1483 * Creates a debounced function that delays invoking `func` until after `wait` 1484 * milliseconds have elapsed since the last time the debounced function was 1485 * invoked. The debounced function comes with a `cancel` method to cancel 1486 * delayed `func` invocations and a `flush` method to immediately invoke them. 1487 * Provide `options` to indicate whether `func` should be invoked on the 1488 * leading and/or trailing edge of the `wait` timeout. The `func` is invoked 1489 * with the last arguments provided to the debounced function. Subsequent 1490 * calls to the debounced function return the result of the last `func` 1491 * invocation. 1492 * 1493 * **Note:** If `leading` and `trailing` options are `true`, `func` is 1494 * invoked on the trailing edge of the timeout only if the debounced function 1495 * is invoked more than once during the `wait` timeout. 1496 * 1497 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 1498 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 1499 * 1500 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 1501 * for details over the differences between `_.debounce` and `_.throttle`. 1502 * 1503 * @static 1504 * @memberOf _ 1505 * @since 0.1.0 1506 * @category Function 1507 * @param {Function} func The function to debounce. 1508 * @param {number} [wait=0] The number of milliseconds to delay. 1509 * @param {Object} [options={}] The options object. 1510 * @param {boolean} [options.leading=false] 1511 * Specify invoking on the leading edge of the timeout. 1512 * @param {number} [options.maxWait] 1513 * The maximum time `func` is allowed to be delayed before it's invoked. 1514 * @param {boolean} [options.trailing=true] 1515 * Specify invoking on the trailing edge of the timeout. 1516 * @returns {Function} Returns the new debounced function. 1517 * @example 1518 * 1519 * // Avoid costly calculations while the window size is in flux. 1520 * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); 1521 * 1522 * // Invoke `sendMail` when clicked, debouncing subsequent calls. 1523 * jQuery(element).on('click', _.debounce(sendMail, 300, { 1524 * 'leading': true, 1525 * 'trailing': false 1526 * })); 1527 * 1528 * // Ensure `batchLog` is invoked once after 1 second of debounced calls. 1529 * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); 1530 * var source = new EventSource('/stream'); 1531 * jQuery(source).on('message', debounced); 1532 * 1533 * // Cancel the trailing debounced invocation. 1534 * jQuery(window).on('popstate', debounced.cancel); 1535 */ 1536 function debounce(func, wait, options) { 1537 var lastArgs, 1538 lastThis, 1539 maxWait, 1540 result, 1541 timerId, 1542 lastCallTime, 1543 lastInvokeTime = 0, 1544 leading = false, 1545 maxing = false, 1546 trailing = true; 1547 1548 if (typeof func != 'function') { 1549 throw new TypeError(FUNC_ERROR_TEXT); 1550 } 1551 wait = toNumber(wait) || 0; 1552 if (isObject(options)) { 1553 leading = !!options.leading; 1554 maxing = 'maxWait' in options; 1555 maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; 1556 trailing = 'trailing' in options ? !!options.trailing : trailing; 1557 } 1558 1559 function invokeFunc(time) { 1560 var args = lastArgs, 1561 thisArg = lastThis; 1562 1563 lastArgs = lastThis = undefined; 1564 lastInvokeTime = time; 1565 result = func.apply(thisArg, args); 1566 return result; 1567 } 1568 1569 function leadingEdge(time) { 1570 // Reset any `maxWait` timer. 1571 lastInvokeTime = time; 1572 // Start the timer for the trailing edge. 1573 timerId = setTimeout(timerExpired, wait); 1574 // Invoke the leading edge. 1575 return leading ? invokeFunc(time) : result; 1576 } 1577 1578 function remainingWait(time) { 1579 var timeSinceLastCall = time - lastCallTime, 1580 timeSinceLastInvoke = time - lastInvokeTime, 1581 timeWaiting = wait - timeSinceLastCall; 1582 1583 return maxing 1584 ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) 1585 : timeWaiting; 1586 } 1587 1588 function shouldInvoke(time) { 1589 var timeSinceLastCall = time - lastCallTime, 1590 timeSinceLastInvoke = time - lastInvokeTime; 1591 1592 // Either this is the first call, activity has stopped and we're at the 1593 // trailing edge, the system time has gone backwards and we're treating 1594 // it as the trailing edge, or we've hit the `maxWait` limit. 1595 return (lastCallTime === undefined || (timeSinceLastCall >= wait) || 1596 (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); 1597 } 1598 1599 function timerExpired() { 1600 var time = now(); 1601 if (shouldInvoke(time)) { 1602 return trailingEdge(time); 1603 } 1604 // Restart the timer. 1605 timerId = setTimeout(timerExpired, remainingWait(time)); 1606 } 1607 1608 function trailingEdge(time) { 1609 timerId = undefined; 1610 1611 // Only invoke if we have `lastArgs` which means `func` has been 1612 // debounced at least once. 1613 if (trailing && lastArgs) { 1614 return invokeFunc(time); 1615 } 1616 lastArgs = lastThis = undefined; 1617 return result; 1618 } 1619 1620 function cancel() { 1621 if (timerId !== undefined) { 1622 clearTimeout(timerId); 1623 } 1624 lastInvokeTime = 0; 1625 lastArgs = lastCallTime = lastThis = timerId = undefined; 1626 } 1627 1628 function flush() { 1629 return timerId === undefined ? result : trailingEdge(now()); 1630 } 1631 1632 function debounced() { 1633 var time = now(), 1634 isInvoking = shouldInvoke(time); 1635 1636 lastArgs = arguments; 1637 lastThis = this; 1638 lastCallTime = time; 1639 1640 if (isInvoking) { 1641 if (timerId === undefined) { 1642 return leadingEdge(lastCallTime); 1643 } 1644 if (maxing) { 1645 // Handle invocations in a tight loop. 1646 clearTimeout(timerId); 1647 timerId = setTimeout(timerExpired, wait); 1648 return invokeFunc(lastCallTime); 1649 } 1650 } 1651 if (timerId === undefined) { 1652 timerId = setTimeout(timerExpired, wait); 1653 } 1654 return result; 1655 } 1656 debounced.cancel = cancel; 1657 debounced.flush = flush; 1658 return debounced; 1659 } 1660 1661 debounce_1 = debounce; 1662 return debounce_1; 1663} 1664 1665var throttle_1; 1666var hasRequiredThrottle; 1667 1668function requireThrottle () { 1669 if (hasRequiredThrottle) return throttle_1; 1670 hasRequiredThrottle = 1; 1671 var debounce = requireDebounce(), 1672 isObject = requireIsObject(); 1673 1674 /** Error message constants. */ 1675 var FUNC_ERROR_TEXT = 'Expected a function'; 1676 1677 /** 1678 * Creates a throttled function that only invokes `func` at most once per 1679 * every `wait` milliseconds. The throttled function comes with a `cancel` 1680 * method to cancel delayed `func` invocations and a `flush` method to 1681 * immediately invoke them. Provide `options` to indicate whether `func` 1682 * should be invoked on the leading and/or trailing edge of the `wait` 1683 * timeout. The `func` is invoked with the last arguments provided to the 1684 * throttled function. Subsequent calls to the throttled function return the 1685 * result of the last `func` invocation. 1686 * 1687 * **Note:** If `leading` and `trailing` options are `true`, `func` is 1688 * invoked on the trailing edge of the timeout only if the throttled function 1689 * is invoked more than once during the `wait` timeout. 1690 * 1691 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 1692 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 1693 * 1694 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 1695 * for details over the differences between `_.throttle` and `_.debounce`. 1696 * 1697 * @static 1698 * @memberOf _ 1699 * @since 0.1.0 1700 * @category Function 1701 * @param {Function} func The function to throttle. 1702 * @param {number} [wait=0] The number of milliseconds to throttle invocations to. 1703 * @param {Object} [options={}] The options object. 1704 * @param {boolean} [options.leading=true] 1705 * Specify invoking on the leading edge of the timeout. 1706 * @param {boolean} [options.trailing=true] 1707 * Specify invoking on the trailing edge of the timeout. 1708 * @returns {Function} Returns the new throttled function. 1709 * @example 1710 * 1711 * // Avoid excessively updating the position while scrolling. 1712 * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); 1713 * 1714 * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. 1715 * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); 1716 * jQuery(element).on('click', throttled); 1717 * 1718 * // Cancel the trailing throttled invocation. 1719 * jQuery(window).on('popstate', throttled.cancel); 1720 */ 1721 function throttle(func, wait, options) { 1722 var leading = true, 1723 trailing = true; 1724 1725 if (typeof func != 'function') { 1726 throw new TypeError(FUNC_ERROR_TEXT); 1727 } 1728 if (isObject(options)) { 1729 leading = 'leading' in options ? !!options.leading : leading; 1730 trailing = 'trailing' in options ? !!options.trailing : trailing; 1731 } 1732 return debounce(func, wait, { 1733 'leading': leading, 1734 'maxWait': wait, 1735 'trailing': trailing 1736 }); 1737 } 1738 1739 throttle_1 = throttle; 1740 return throttle_1; 1741} 1742 1743var throttleExports = requireThrottle();
1744const throttle = /*@__PURE__*/getDefaultExportFromCjs(throttleExports); 1745 1746class GameRecap { 1747 constructor(container) { 1748 if (!container) { 1749 return; 1750 } 1751 1752 this.ui = { 1753 container, 1754 // gameRecapStatic: document.querySelector(".hero-card__inner"), 1755 gameRecapStatic: document.querySelector(".hero-new__opacity"), 1756 gameRecapFixed: document.querySelector(".product__game-recap-fixed"), 1757 }; 1758 1759 if (this.ui.container) { 1760 this.initEvents(); 1761 } 1762 } 1763 1764 initEvents() { 1765 window.addEventListener("scroll", throttle(this.onScroll.bind(this), 100)); 1766 window.addEventListener("resize", this.onResize.bind(this)); 1767 } 1768 1769 toggleGameRecap() { 1770 if(!this.ui.gameRecapStatic || !this.ui.gameRecapFixed) { 1771 return; 1772 } 1773 var gameRecapStaticPos = this.ui.gameRecapStatic.getBoundingClientRect(); 1774 var triggerPos = gameRecapStaticPos.bottom; 1775 triggerPos <= 0 ? this.ui.gameRecapFixed.classList.add("is-active") : this.ui.gameRecapFixed.classList.remove("is-active"); 1776 } 1777 1778 onResize() { 1779 this.toggleGameRecap(); 1780 } 1781 1782 onScroll() { 1783 this.toggleGameRecap(); 1784 } 1785} 1786 1787class MenuMobile { 1788 constructor(container) { 1789 if (!container) { 1790 return; 1791 } 1792 1793 this.ui = { 1794 container, 1795 buttonOpen: document.querySelector(".menu__burger-btn"), 1796 buttonClose: container.querySelector(".menu__close"), 1797 htmlTag: document.body.parentNode, 1798 bodyTag: document.body, 1799 }; 1800 this.isOpen = false;
1801 1802 if (this.ui.container) { 1803 this.initEvents(); 1804 } 1805 } 1806 1807 initEvents() { 1808 this.ui.buttonOpen.addEventListener("click", this.onOpen.bind(this)); 1809 this.ui.buttonClose.addEventListener("click", this.onClose.bind(this)); 1810 window.addEventListener("resize", this.onResize.bind(this)); 1811 } 1812 1813 onResize() { 1814 this.closeOnDesktop(); 1815 } 1816 1817 onOpen() { 1818 if (!this.isOpen) { 1819 this.ui.container.classList.add("is-open"); 1820 this.ui.htmlTag.classList.add("overflow-hidden"); 1821 this.ui.bodyTag.classList.add("overflow-hidden"); 1822 this.isOpen = true; 1823 } 1824 } 1825 1826 onClose() { 1827 if (this.isOpen) { 1828 this.ui.container.classList.remove("is-open"); 1829 this.ui.htmlTag.classList.remove("overflow-hidden"); 1830 this.ui.bodyTag.classList.remove("overflow-hidden"); 1831 this.isOpen = false; 1832 } 1833 } 1834 1835 closeOnDesktop() { 1836 if (this.isOpen && getIsDesktop()) { 1837 this.onClose(); 1838 } 1839 } 1840} 1841 1842function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 1843 1844function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 1845 1846/*! 1847 * Splide.js 1848 * Version : 4.1.4 1849 * License : MIT 1850 * Copyright: 2022 Naotoshi Fujita 1851 */ 1852var MEDIA_PREFERS_REDUCED_MOTION = "(prefers-reduced-motion: reduce)"; 1853var CREATED = 1; 1854var MOUNTED = 2; 1855var IDLE = 3; 1856var MOVING = 4; 1857var SCROLLING = 5; 1858var DRAGGING = 6; 1859var DESTROYED = 7; 1860var STATES = { 1861 CREATED: CREATED, 1862 MOUNTED: MOUNTED, 1863 IDLE: IDLE, 1864 MOVING: MOVING, 1865 SCROLLING: SCROLLING, 1866 DRAGGING: DRAGGING, 1867 DESTROYED: DESTROYED 1868}; 1869 1870function empty$1(array) { 1871 array.length = 0; 1872} 1873 1874function slice$2(arrayLike, start, end) { 1875 return Array.prototype.slice.call(arrayLike, start, end); 1876} 1877 1878function apply$2(func) { 1879 return func.bind.apply(func, [null].concat(slice$2(arguments, 1))); 1880} 1881 1882var nextTick = setTimeout; 1883 1884var noop = function noop() {}; 1885 1886function raf$1(func) { 1887 return requestAnimationFrame(func); 1888} 1889 1890function typeOf$2(type, subject) { 1891 return typeof subject === type; 1892} 1893 1894function isObject$1(subject) { 1895 return !isNull$1(subject) && typeOf$2("object", subject); 1896} 1897 1898var isArray$2 = Array.isArray; 1899var isFunction = apply$2(typeOf$2, "function"); 1900var isString = apply$2(typeOf$2, "string"); 1901var isUndefined$1 = apply$2(typeOf$2, "undefined"); 1902 1903function isNull$1(subject) { 1904 return subject === null; 1905} 1906 1907function isHTMLElement$1(subject) { 1908 try { 1909 return subject instanceof (subject.ownerDocument.defaultView || window).HTMLElement; 1910 } catch (e) { 1911 return false; 1912 } 1913} 1914 1915function toArray$2(value) { 1916 return isArray$2(value) ? value : [value]; 1917} 1918 1919function forEach$2(values, iteratee) { 1920 toArray$2(values).forEach(iteratee); 1921} 1922 1923function includes(array, value) { 1924 return array.indexOf(value) > -1; 1925} 1926 1927function push(array, items) { 1928 array.push.apply(array, toArray$2(items)); 1929 return array; 1930} 1931 1932function toggleClass$1(elm, classes, add) { 1933 if (elm) { 1934 forEach$2(classes, function (name) { 1935 if (name) { 1936 elm.classList[add ? "add" : "remove"](name); 1937 } 1938 }); 1939 } 1940} 1941 1942function addClass(elm, classes) { 1943 toggleClass$1(elm, isString(classes) ? classes.split(" ") : classes, true); 1944} 1945 1946function append(parent, children) { 1947 forEach$2(children, parent.appendChild.bind(parent)); 1948} 1949 1950function before(nodes, ref) { 1951 forEach$2(nodes, function (node) { 1952 var parent = (ref || node).parentNode; 1953 1954 if (parent) { 1955 parent.insertBefore(node, ref); 1956 } 1957 }); 1958} 1959 1960function matches(elm, selector) { 1961 return isHTMLElement$1(elm) && (elm["msMatchesSelector"] || elm.matches).call(elm, selector); 1962} 1963 1964function children(parent, selector) { 1965 var children2 = parent ? slice$2(parent.children) : []; 1966 return selector ? children2.filter(function (child) { 1967 return matches(child, selector); 1968 }) : children2; 1969} 1970 1971function child(parent, selector) { 1972 return selector ? children(parent, selector)[0] : parent.firstElementChild; 1973} 1974 1975var ownKeys$2 = Object.keys; 1976 1977function forOwn$2(object, iteratee, right) { 1978 if (object) { 1979 (right ? ownKeys$2(object).reverse() : ownKeys$2(object)).forEac
vendor: 4,225 bytes, lines 1979-2176
1979h(function (key) { 1980 key !== "__proto__" && iteratee(object[key], key); 1981 }); 1982 } 1983 1984 return object; 1985} 1986 1987function assign$2(object) { 1988 slice$2(arguments, 1).forEach(function (source) { 1989 forOwn$2(source, function (value, key) { 1990 object[key] = source[key]; 1991 }); 1992 }); 1993 return object; 1994} 1995 1996function merge(object) { 1997 slice$2(arguments, 1).forEach(function (source) { 1998 forOwn$2(source, function (value, key) { 1999 if (isArray$2(value)) { 2000 object[key] = value.slice(); 2001 } else if (isObject$1(value)) { 2002 object[key] = merge({}, isObject$1(object[key]) ? object[key] : {}, value); 2003 } else { 2004 object[key] = value; 2005 } 2006 }); 2007 }); 2008 return object; 2009} 2010 2011function omit(object, keys) { 2012 forEach$2(keys || ownKeys$2(object), function (key) { 2013 delete object[key]; 2014 }); 2015} 2016 2017function removeAttribute$1(elms, attrs) { 2018 forEach$2(elms, function (elm) { 2019 forEach$2(attrs, function (attr) { 2020 elm && elm.removeAttribute(attr); 2021 }); 2022 }); 2023} 2024 2025function setAttribute$1(elms, attrs, value) { 2026 if (isObject$1(attrs)) { 2027 forOwn$2(attrs, function (value2, name) { 2028 setAttribute$1(elms, name, value2); 2029 }); 2030 } else { 2031 forEach$2(elms, function (elm) { 2032 isNull$1(value) || value === "" ? removeAttribute$1(elm, attrs) : elm.setAttribute(attrs, String(value)); 2033 }); 2034 } 2035} 2036 2037function create(tag, attrs, parent) { 2038 var elm = document.createElement(tag); 2039 2040 if (attrs) { 2041 isString(attrs) ? addClass(elm, attrs) : setAttribute$1(elm, attrs); 2042 } 2043 2044 parent && append(parent, elm); 2045 return elm; 2046} 2047 2048function style(elm, prop, value) { 2049 if (isUndefined$1(value)) { 2050 return getComputedStyle(elm)[prop]; 2051 } 2052 2053 if (!isNull$1(value)) { 2054 elm.style[prop] = "" + value; 2055 } 2056} 2057 2058function display(elm, display2) { 2059 style(elm, "display", display2); 2060} 2061 2062function focus(elm) { 2063 elm["setActive"] && elm["setActive"]() || elm.focus({ 2064 preventScroll: true 2065 }); 2066} 2067 2068function getAttribute(elm, attr) { 2069 return elm.getAttribute(attr); 2070} 2071 2072function hasClass(elm, className) { 2073 return elm && elm.classList.contains(className); 2074} 2075 2076function rect(target) { 2077 return target.getBoundingClientRect(); 2078} 2079 2080function remove(nodes) { 2081 forEach$2(nodes, function (node) { 2082 if (node && node.parentNode) { 2083 node.parentNode.removeChild(node); 2084 } 2085 }); 2086} 2087 2088function parseHtml(html) { 2089 return child(new DOMParser().parseFromString(html, "text/html").body); 2090} 2091 2092function prevent(e, stopPropagation) { 2093 e.preventDefault(); 2094 2095 if (stopPropagation) { 2096 e.stopPropagation(); 2097 e.stopImmediatePropagation(); 2098 } 2099} 2100 2101function query(parent, selector) { 2102 return parent && parent.querySelector(selector); 2103} 2104 2105function queryAll(parent, selector) { 2106 return selector ? slice$2(parent.querySelectorAll(selector)) : []; 2107} 2108 2109function removeClass(elm, classes) { 2110 toggleClass$1(elm, classes, false); 2111} 2112 2113function timeOf(e) { 2114 return e.timeStamp; 2115} 2116 2117function unit(value) { 2118 return isString(value) ? value : value ? value + "px" : ""; 2119} 2120 2121var PROJECT_CODE = "splide"; 2122var DATA_ATTRIBUTE = "data-" + PROJECT_CODE; 2123 2124function assert(condition, message) { 2125 if (!condition) { 2126 throw new Error("[" + PROJECT_CODE + "] " + (message || "")); 2127 } 2128} 2129 2130var min$3 = Math.min, 2131 max$2 = Math.max, 2132 floor = Math.floor, 2133 ceil = Math.ceil, 2134 abs = Math.abs; 2135 2136function approximatelyEqual(x, y, epsilon) { 2137 return abs(x - y) < epsilon; 2138} 2139 2140function between(number, x, y, exclusive) { 2141 var minimum = min$3(x, y); 2142 var maximum = max$2(x, y); 2143 return exclusive ? minimum < number && number < maximum : minimum <= number && number <= maximum; 2144} 2145 2146function clamp$1(number, x, y) { 2147 var minimum = min$3(x, y); 2148 var maximum = max$2(x, y); 2149 return min$3(max$2(minimum, number), maximum); 2150} 2151 2152function sign(x) { 2153 return +(x > 0) - +(x < 0); 2154} 2155 2156function format(string, replacements) { 2157 forEach$2(replacements, function (replacement) { 2158 string = string.replace("%s", "" + replacement); 2159 }); 2160 return string; 2161} 2162 2163function pad(number) { 2164 return number < 10 ? "0" + number : "" + number; 2165} 2166 2167var ids = {}; 2168 2169function uniqueId(prefix) { 2170 return "" + prefix + pad(ids[prefix] = (ids[prefix] || 0) + 1); 2171} 2172 2173function EventBinder$1() { 2174 var listeners = []; 2175 2176 function bind(targets, events, callback, options) {
vendor: 72,960 bytes, lines 2177-4999
2177 forEachEvent(targets, events, function (target, event, namespace) { 2178 var isEventTarget = ("addEventListener" in target); 2179 var remover = isEventTarget ? target.removeEventListener.bind(target, event, callback, options) : target["removeListener"].bind(target, callback); 2180 isEventTarget ? target.addEventListener(event, callback, options) : target["addListener"](callback); 2181 listeners.push([target, event, namespace, callback, remover]); 2182 }); 2183 } 2184 2185 function unbind(targets, events, callback) { 2186 forEachEvent(targets, events, function (target, event, namespace) { 2187 listeners = listeners.filter(function (listener) { 2188 if (listener[0] === target && listener[1] === event && listener[2] === namespace && (!callback || listener[3] === callback)) { 2189 listener[4](); 2190 return false; 2191 } 2192 2193 return true; 2194 }); 2195 }); 2196 } 2197 2198 function dispatch(target, type, detail) { 2199 var e; 2200 var bubbles = true; 2201 2202 if (typeof CustomEvent === "function") { 2203 e = new CustomEvent(type, { 2204 bubbles: bubbles, 2205 detail: detail 2206 }); 2207 } else { 2208 e = document.createEvent("CustomEvent"); 2209 e.initCustomEvent(type, bubbles, false, detail); 2210 } 2211 2212 target.dispatchEvent(e); 2213 return e; 2214 } 2215 2216 function forEachEvent(targets, events, iteratee) { 2217 forEach$2(targets, function (target) { 2218 target && forEach$2(events, function (events2) { 2219 events2.split(" ").forEach(function (eventNS) { 2220 var fragment = eventNS.split("."); 2221 iteratee(target, fragment[0], fragment[1]); 2222 }); 2223 }); 2224 }); 2225 } 2226 2227 function destroy() { 2228 listeners.forEach(function (data) { 2229 data[4](); 2230 }); 2231 empty$1(listeners); 2232 } 2233 2234 return { 2235 bind: bind, 2236 unbind: unbind, 2237 dispatch: dispatch, 2238 destroy: destroy 2239 }; 2240} 2241 2242var EVENT_MOUNTED = "mounted"; 2243var EVENT_READY = "ready"; 2244var EVENT_MOVE$1 = "move"; 2245var EVENT_MOVED$1 = "moved"; 2246var EVENT_CLICK = "click"; 2247var EVENT_ACTIVE = "active"; 2248var EVENT_INACTIVE = "inactive"; 2249var EVENT_VISIBLE = "visible"; 2250var EVENT_HIDDEN = "hidden"; 2251var EVENT_REFRESH = "refresh"; 2252var EVENT_UPDATED$1 = "updated"; 2253var EVENT_RESIZE = "resize"; 2254var EVENT_RESIZED = "resized"; 2255var EVENT_DRAG$1 = "drag"; 2256var EVENT_DRAGGING = "dragging"; 2257var EVENT_DRAGGED = "dragged"; 2258var EVENT_SCROLL$1 = "scroll"; 2259var EVENT_SCROLLED$1 = "scrolled"; 2260var EVENT_OVERFLOW = "overflow"; 2261var EVENT_DESTROY$1 = "destroy"; 2262var EVENT_ARROWS_MOUNTED = "arrows:mounted"; 2263var EVENT_ARROWS_UPDATED = "arrows:updated"; 2264var EVENT_PAGINATION_MOUNTED = "pagination:mounted"; 2265var EVENT_PAGINATION_UPDATED = "pagination:updated"; 2266var EVENT_NAVIGATION_MOUNTED = "navigation:mounted"; 2267var EVENT_AUTOPLAY_PLAY = "autoplay:play"; 2268var EVENT_AUTOPLAY_PLAYING = "autoplay:playing"; 2269var EVENT_AUTOPLAY_PAUSE = "autoplay:pause"; 2270var EVENT_LAZYLOAD_LOADED = "lazyload:loaded"; 2271var EVENT_SLIDE_KEYDOWN = "sk"; 2272var EVENT_SHIFTED = "sh"; 2273var EVENT_END_INDEX_CHANGED = "ei"; 2274 2275function EventInterface$1(Splide2) { 2276 var bus = Splide2 ? Splide2.event.bus : document.createDocumentFragment(); 2277 var binder = EventBinder$1(); 2278 2279 function on(events, callback) { 2280 binder.bind(bus, toArray$2(events).join(" "), function (e) { 2281 callback.apply(callback, isArray$2(e.detail) ? e.detail : []); 2282 }); 2283 } 2284 2285 function emit(event) { 2286 binder.dispatch(bus, event, slice$2(arguments, 1)); 2287 } 2288 2289 if (Splide2) { 2290 Splide2.event.on(EVENT_DESTROY$1, binder.destroy); 2291 } 2292 2293 return assign$2(binder, { 2294 bus: bus, 2295 on: on, 2296 off: apply$2(binder.unbind, bus), 2297 emit: emit 2298 }); 2299} 2300 2301function RequestInterval$1(interval, onInterval, onUpdate, limit) { 2302 var now = Date.now; 2303 var startTime; 2304 var rate = 0; 2305 var id; 2306 var paused = true; 2307 var count = 0; 2308 2309 function update() { 2310 if (!paused) { 2311 rate = interval ? min$3((now() - startTime) / interval, 1) : 1; 2312 onUpdate && onUpdate(rate); 2313 2314 if (rate >= 1) { 2315 onInterval(); 2316 startTime = now(); 2317 2318 if (limit && ++count >= limit) { 2319 return pause(); 2320 } 2321 } 2322 2323 id = raf$1(update); 2324 } 2325 } 2326 2327 function start(resume) { 2328 resume || cancel(); 2329 startTime = now() - (resume ? rate * interval : 0); 2330 paused = false; 2331 id = raf$1(update); 2332 } 2333 2334 function pause() { 2335 paused = true; 2336 } 2337 2338 function rewind() { 2339 startTime = now(); 2340 rate = 0; 2341 2342 if (onUpdate) { 2343 onUpdate(rate); 2344 } 2345 } 2346 2347 function cancel() { 2348 id && cancelAnimationFrame(id); 2349 rate = 0; 2350 id = 0; 2351 paused = true; 2352 } 2353 2354 function set(time) { 2355 interval = time; 2356 } 2357 2358 function isPaused() { 2359 return paused; 2360 } 2361 2362 return { 2363 start: start, 2364 rewind: rewind, 2365 pause: pause, 2366 cancel: cancel, 2367 set: set, 2368 isPaused: isPaused 2369 }; 2370} 2371 2372function State(initialState) { 2373 var state = initialState; 2374 2375 function set(value) { 2376 state = value; 2377 } 2378 2379 function is(states) { 2380 return includes(toArray$2(states), state); 2381 } 2382 2383 return { 2384 set: set, 2385 is: is 2386 }; 2387} 2388 2389function Throttle(func, duration) { 2390 var interval = RequestInterval$1(0, func, null, 1); 2391 return function () { 2392 interval.isPaused() && interval.start(); 2393 }; 2394} 2395 2396function Media(Splide2, Components2, options) { 2397 var state = Splide2.state; 2398 var breakpoints = options.breakpoints || {}; 2399 var reducedMotion = options.reducedMotion || {}; 2400 var binder = EventBinder$1(); 2401 var queries = []; 2402 2403 function setup() { 2404 var isMin = options.mediaQuery === "min"; 2405 ownKeys$2(breakpoints).sort(function (n, m) { 2406 return isMin ? +n - +m : +m - +n; 2407 }).forEach(function (key) { 2408 register(breakpoints[key], "(" + (isMin ? "min" : "max") + "-width:" + key + "px)"); 2409 }); 2410 register(reducedMotion, MEDIA_PREFERS_REDUCED_MOTION); 2411 update(); 2412 } 2413 2414 function destroy(completely) { 2415 if (completely) { 2416 binder.destroy(); 2417 } 2418 } 2419 2420 function register(options2, query) { 2421 var queryList = matchMedia(query); 2422 binder.bind(queryList, "change", update); 2423 queries.push([options2, queryList]); 2424 } 2425 2426 function update() { 2427 var destroyed = state.is(DESTROYED); 2428 var direction = options.direction; 2429 var merged = queries.reduce(function (merged2, entry) { 2430 return merge(merged2, entry[1].matches ? entry[0] : {}); 2431 }, {}); 2432 omit(options); 2433 set(merged); 2434 2435 if (options.destroy) { 2436 Splide2.destroy(options.destroy === "completely"); 2437 } else if (destroyed) { 2438 destroy(true); 2439 Splide2.mount(); 2440 } else { 2441 direction !== options.direction && Splide2.refresh(); 2442 } 2443 } 2444 2445 function reduce(enable) { 2446 if (matchMedia(MEDIA_PREFERS_REDUCED_MOTION).matches) { 2447 enable ? merge(options, reducedMotion) : omit(options, ownKeys$2(reducedMotion)); 2448 } 2449 } 2450 2451 function set(opts, base, notify) { 2452 merge(options, opts); 2453 base && merge(Object.getPrototypeOf(options), opts); 2454 2455 if (notify || !state.is(CREATED)) { 2456 Splide2.emit(EVENT_UPDATED$1, options); 2457 } 2458 } 2459 2460 return { 2461 setup: setup, 2462 destroy: destroy, 2463 reduce: reduce, 2464 set: set 2465 }; 2466} 2467 2468var ARROW = "Arrow"; 2469var ARROW_LEFT = ARROW + "Left"; 2470var ARROW_RIGHT = ARROW + "Right"; 2471var ARROW_UP = ARROW + "Up"; 2472var ARROW_DOWN = ARROW + "Down"; 2473var RTL = "rtl"; 2474var TTB = "ttb"; 2475var ORIENTATION_MAP = { 2476 width: ["height"], 2477 left: ["top", "right"], 2478 right: ["bottom", "left"], 2479 x: ["y"], 2480 X: ["Y"], 2481 Y: ["X"], 2482 ArrowLeft: [ARROW_UP, ARROW_RIGHT], 2483 ArrowRight: [ARROW_DOWN, ARROW_LEFT] 2484}; 2485 2486function Direction(Splide2, Components2, options) { 2487 function resolve(prop, axisOnly, direction) { 2488 direction = direction || options.direction; 2489 var index = direction === RTL && !axisOnly ? 1 : direction === TTB ? 0 : -1; 2490 return ORIENTATION_MAP[prop] && ORIENTATION_MAP[prop][index] || prop.replace(/width|left|right/i, function (match, offset) { 2491 var replacement = ORIENTATION_MAP[match.toLowerCase()][index] || match; 2492 return offset > 0 ? replacement.charAt(0).toUpperCase() + replacement.slice(1) : replacement; 2493 }); 2494 } 2495 2496 function orient(value) { 2497 return value * (options.direction === RTL ? 1 : -1); 2498 } 2499 2500 return { 2501 resolve: resolve, 2502 orient: orient 2503 }; 2504} 2505 2506var ROLE = "role"; 2507var TAB_INDEX = "tabindex"; 2508var DISABLED = "disabled"; 2509var ARIA_PREFIX = "aria-"; 2510var ARIA_CONTROLS = ARIA_PREFIX + "controls"; 2511var ARIA_CURRENT = ARIA_PREFIX + "current"; 2512var ARIA_SELECTED = ARIA_PREFIX + "selected"; 2513var ARIA_LABEL = ARIA_PREFIX + "label"; 2514var ARIA_LABELLEDBY = ARIA_PREFIX + "labelledby"; 2515var ARIA_HIDDEN = ARIA_PREFIX + "hidden"; 2516var ARIA_ORIENTATION = ARIA_PREFIX + "orientation"; 2517var ARIA_ROLEDESCRIPTION = ARIA_PREFIX + "roledescription"; 2518var ARIA_LIVE = ARIA_PREFIX + "live"; 2519var ARIA_BUSY = ARIA_PREFIX + "busy"; 2520var ARIA_ATOMIC = ARIA_PREFIX + "atomic"; 2521var ALL_ATTRIBUTES = [ROLE, TAB_INDEX, DISABLED, ARIA_CONTROLS, ARIA_CURRENT, ARIA_LABEL, ARIA_LABELLEDBY, ARIA_HIDDEN, ARIA_ORIENTATION, ARIA_ROLEDESCRIPTION]; 2522var CLASS_PREFIX = PROJECT_CODE + "__"; 2523var STATUS_CLASS_PREFIX = "is-"; 2524var CLASS_ROOT = PROJECT_CODE; 2525var CLASS_TRACK = CLASS_PREFIX + "track"; 2526var CLASS_LIST = CLASS_PREFIX + "list"; 2527var CLASS_SLIDE = CLASS_PREFIX + "slide"; 2528var CLASS_CLONE = CLASS_SLIDE + "--clone"; 2529var CLASS_CONTAINER = CLASS_SLIDE + "__container"; 2530var CLASS_ARROWS = CLASS_PREFIX + "arrows"; 2531var CLASS_ARROW = CLASS_PREFIX + "arrow"; 2532var CLASS_ARROW_PREV = CLASS_ARROW + "--prev"; 2533var CLASS_ARROW_NEXT = CLASS_ARROW + "--next"; 2534var CLASS_PAGINATION = CLASS_PREFIX + "pagination"; 2535var CLASS_PAGINATION_PAGE = CLASS_PAGINATION + "__page"; 2536var CLASS_PROGRESS = CLASS_PREFIX + "progress"; 2537var CLASS_PROGRESS_BAR = CLASS_PROGRESS + "__bar"; 2538var CLASS_TOGGLE = CLASS_PREFIX + "toggle"; 2539var CLASS_SPINNER = CLASS_PREFIX + "spinner"; 2540var CLASS_SR = CLASS_PREFIX + "sr"; 2541var CLASS_INITIALIZED = STATUS_CLASS_PREFIX + "initialized"; 2542var CLASS_ACTIVE$1 = STATUS_CLASS_PREFIX + "active"; 2543var CLASS_PREV = STATUS_CLASS_PREFIX + "prev"; 2544var CLASS_NEXT = STATUS_CLASS_PREFIX + "next"; 2545var CLASS_VISIBLE = STATUS_CLASS_PREFIX + "visible"; 2546var CLASS_LOADING = STATUS_CLASS_PREFIX + "loading"; 2547var CLASS_FOCUS_IN = STATUS_CLASS_PREFIX + "focus-in"; 2548var CLASS_OVERFLOW = STATUS_CLASS_PREFIX + "overflow"; 2549var STATUS_CLASSES = [CLASS_ACTIVE$1, CLASS_VISIBLE, CLASS_PREV, CLASS_NEXT, CLASS_LOADING, CLASS_FOCUS_IN, CLASS_OVERFLOW]; 2550var CLASSES = { 2551 slide: CLASS_SLIDE, 2552 clone: CLASS_CLONE, 2553 arrows: CLASS_ARROWS, 2554 arrow: CLASS_ARROW, 2555 prev: CLASS_ARROW_PREV, 2556 next: CLASS_ARROW_NEXT, 2557 pagination: CLASS_PAGINATION, 2558 page: CLASS_PAGINATION_PAGE, 2559 spinner: CLASS_SPINNER 2560}; 2561 2562function closest(from, selector) { 2563 if (isFunction(from.closest)) { 2564 return from.closest(selector); 2565 } 2566 2567 var elm = from; 2568 2569 while (elm && elm.nodeType === 1) { 2570 if (matches(elm, selector)) { 2571 break; 2572 } 2573 2574 elm = elm.parentElement; 2575 } 2576 2577 return elm; 2578} 2579 2580var FRICTION = 5; 2581var LOG_INTERVAL = 200; 2582var POINTER_DOWN_EVENTS = "touchstart mousedown"; 2583var POINTER_MOVE_EVENTS = "touchmove mousemove"; 2584var POINTER_UP_EVENTS = "touchend touchcancel mouseup click"; 2585 2586function Elements(Splide2, Components2, options) { 2587 var _EventInterface = EventInterface$1(Splide2), 2588 on = _EventInterface.on, 2589 bind = _EventInterface.bind; 2590 2591 var root = Splide2.root; 2592 var i18n = options.i18n; 2593 var elements = {}; 2594 var slides = []; 2595 var rootClasses = []; 2596 var trackClasses = []; 2597 var track; 2598 var list; 2599 var isUsingKey; 2600 2601 function setup() { 2602 collect(); 2603 init(); 2604 update(); 2605 } 2606 2607 function mount() { 2608 on(EVENT_REFRESH, destroy); 2609 on(EVENT_REFRESH, setup); 2610 on(EVENT_UPDATED$1, update); 2611 bind(document, POINTER_DOWN_EVENTS + " keydown", function (e) { 2612 isUsingKey = e.type === "keydown"; 2613 }, { 2614 capture: true 2615 }); 2616 bind(root, "focusin", function () { 2617 toggleClass$1(root, CLASS_FOCUS_IN, !!isUsingKey); 2618 }); 2619 } 2620 2621 function destroy(completely) { 2622 var attrs = ALL_ATTRIBUTES.concat("style"); 2623 empty$1(slides); 2624 removeClass(root, rootClasses); 2625 removeClass(track, trackClasses); 2626 removeAttribute$1([track, list], attrs); 2627 removeAttribute$1(root, completely ? attrs : ["style", ARIA_ROLEDESCRIPTION]); 2628 } 2629 2630 function update() { 2631 removeClass(root, rootClasses); 2632 removeClass(track, trackClasses); 2633 rootClasses = getClasses(CLASS_ROOT); 2634 trackClasses = getClasses(CLASS_TRACK); 2635 addClass(root, rootClasses); 2636 addClass(track, trackClasses); 2637 setAttribute$1(root, ARIA_LABEL, options.label); 2638 setAttribute$1(root, ARIA_LABELLEDBY, options.labelledby); 2639 } 2640 2641 function collect() { 2642 track = find("." + CLASS_TRACK); 2643 list = child(track, "." + CLASS_LIST); 2644 assert(track && list, "A track/list element is missing."); 2645 push(slides, children(list, "." + CLASS_SLIDE + ":not(." + CLASS_CLONE + ")")); 2646 forOwn$2({ 2647 arrows: CLASS_ARROWS, 2648 pagination: CLASS_PAGINATION, 2649 prev: CLASS_ARROW_PREV, 2650 next: CLASS_ARROW_NEXT, 2651 bar: CLASS_PROGRESS_BAR, 2652 toggle: CLASS_TOGGLE 2653 }, function (className, key) { 2654 elements[key] = find("." + className); 2655 }); 2656 assign$2(elements, { 2657 root: root, 2658 track: track, 2659 list: list, 2660 slides: slides 2661 }); 2662 } 2663 2664 function init() { 2665 var id = root.id || uniqueId(PROJECT_CODE); 2666 var role = options.role; 2667 root.id = id; 2668 track.id = track.id || id + "-track"; 2669 list.id = list.id || id + "-list"; 2670 2671 if (!getAttribute(root, ROLE) && root.tagName !== "SECTION" && role) { 2672 setAttribute$1(root, ROLE, role); 2673 } 2674 2675 setAttribute$1(root, ARIA_ROLEDESCRIPTION, i18n.carousel); 2676 setAttribute$1(list, ROLE, "presentation"); 2677 } 2678 2679 function find(selector) { 2680 var elm = query(root, selector); 2681 return elm && closest(elm, "." + CLASS_ROOT) === root ? elm : void 0; 2682 } 2683 2684 function getClasses(base) { 2685 return [base + "--" + options.type, base + "--" + options.direction, options.drag && base + "--draggable", options.isNavigation && base + "--nav", base === CLASS_ROOT && CLASS_ACTIVE$1]; 2686 } 2687 2688 return assign$2(elements, { 2689 setup: setup, 2690 mount: mount, 2691 destroy: destroy 2692 }); 2693} 2694 2695var SLIDE$1 = "slide"; 2696var LOOP = "loop"; 2697var FADE$1 = "fade"; 2698 2699function Slide$1(Splide2, index, slideIndex, slide) { 2700 var event = EventInterface$1(Splide2); 2701 var on = event.on, 2702 emit = event.emit, 2703 bind = event.bind; 2704 var Components = Splide2.Components, 2705 root = Splide2.root, 2706 options = Splide2.options; 2707 var isNavigation = options.isNavigation, 2708 updateOnMove = options.updateOnMove, 2709 i18n = options.i18n, 2710 pagination = options.pagination, 2711 slideFocus = options.slideFocus; 2712 var resolve = Components.Direction.resolve; 2713 var styles = getAttribute(slide, "style"); 2714 var label = getAttribute(slide, ARIA_LABEL); 2715 var isClone = slideIndex > -1; 2716 var container = child(slide, "." + CLASS_CONTAINER); 2717 var destroyed; 2718 2719 function mount() { 2720 if (!isClone) { 2721 slide.id = root.id + "-slide" + pad(index + 1); 2722 setAttribute$1(slide, ROLE, pagination ? "tabpanel" : "group"); 2723 setAttribute$1(slide, ARIA_ROLEDESCRIPTION, i18n.slide); 2724 setAttribute$1(slide, ARIA_LABEL, label || format(i18n.slideLabel, [index + 1, Splide2.length])); 2725 } 2726 2727 listen(); 2728 } 2729 2730 function listen() { 2731 bind(slide, "click", apply$2(emit, EVENT_CLICK, self)); 2732 bind(slide, "keydown", apply$2(emit, EVENT_SLIDE_KEYDOWN, self)); 2733 on([EVENT_MOVED$1, EVENT_SHIFTED, EVENT_SCROLLED$1], update); 2734 on(EVENT_NAVIGATION_MOUNTED, initNavigation); 2735 2736 if (updateOnMove) { 2737 on(EVENT_MOVE$1, onMove); 2738 } 2739 } 2740 2741 function destroy() { 2742 destroyed = true; 2743 event.destroy(); 2744 removeClass(slide, STATUS_CLASSES); 2745 removeAttribute$1(slide, ALL_ATTRIBUTES); 2746 setAttribute$1(slide, "style", styles); 2747 setAttribute$1(slide, ARIA_LABEL, label || ""); 2748 } 2749 2750 function initNavigation() { 2751 var controls = Splide2.splides.map(function (target) { 2752 var Slide2 = target.splide.Components.Slides.getAt(index); 2753 return Slide2 ? Slide2.slide.id : ""; 2754 }).join(" "); 2755 setAttribute$1(slide, ARIA_LABEL, format(i18n.slideX, (isClone ? slideIndex : index) + 1)); 2756 setAttribute$1(slide, ARIA_CONTROLS, controls); 2757 setAttribute$1(slide, ROLE, slideFocus ? "button" : ""); 2758 slideFocus && removeAttribute$1(slide, ARIA_ROLEDESCRIPTION); 2759 } 2760 2761 function onMove() { 2762 if (!destroyed) { 2763 update(); 2764 } 2765 } 2766 2767 function update() { 2768 if (!destroyed) { 2769 var curr = Splide2.index; 2770 updateActivity(); 2771 updateVisibility(); 2772 toggleClass$1(slide, CLASS_PREV, index === curr - 1); 2773 toggleClass$1(slide, CLASS_NEXT, index === curr + 1); 2774 } 2775 } 2776 2777 function updateActivity() { 2778 var active = isActive(); 2779 2780 if (active !== hasClass(slide, CLASS_ACTIVE$1)) { 2781 toggleClass$1(slide, CLASS_ACTIVE$1, active); 2782 setAttribute$1(slide, ARIA_CURRENT, isNavigation && active || ""); 2783 emit(active ? EVENT_ACTIVE : EVENT_INACTIVE, self); 2784 } 2785 } 2786 2787 function updateVisibility() { 2788 var visible = isVisible(); 2789 var hidden = !visible && (!isActive() || isClone); 2790 2791 if (!Splide2.state.is([MOVING, SCROLLING])) { 2792 setAttribute$1(slide, ARIA_HIDDEN, hidden || ""); 2793 } 2794 2795 setAttribute$1(queryAll(slide, options.focusableNodes || ""), TAB_INDEX, hidden ? -1 : ""); 2796 2797 if (slideFocus) { 2798 setAttribute$1(slide, TAB_INDEX, hidden ? -1 : 0); 2799 } 2800 2801 if (visible !== hasClass(slide, CLASS_VISIBLE)) { 2802 toggleClass$1(slide, CLASS_VISIBLE, visible); 2803 emit(visible ? EVENT_VISIBLE : EVENT_HIDDEN, self); 2804 } 2805 2806 if (!visible && document.activeElement === slide) { 2807 var Slide2 = Components.Slides.getAt(Splide2.index); 2808 Slide2 && focus(Slide2.slide); 2809 } 2810 } 2811 2812 function style$1(prop, value, useContainer) { 2813 style(useContainer && container || slide, prop, value); 2814 } 2815 2816 function isActive() { 2817 var curr = Splide2.index; 2818 return curr === index || options.cloneStatus && curr === slideIndex; 2819 } 2820 2821 function isVisible() { 2822 if (Splide2.is(FADE$1)) { 2823 return isActive(); 2824 } 2825 2826 var trackRect = rect(Components.Elements.track); 2827 var slideRect = rect(slide); 2828 var left = resolve("left", true); 2829 var right = resolve("right", true); 2830 return floor(trackRect[left]) <= ceil(slideRect[left]) && floor(slideRect[right]) <= ceil(trackRect[right]); 2831 } 2832 2833 function isWithin(from, distance) { 2834 var diff = abs(from - index); 2835 2836 if (!isClone && (options.rewind || Splide2.is(LOOP))) { 2837 diff = min$3(diff, Splide2.length - diff); 2838 } 2839 2840 return diff <= distance; 2841 } 2842 2843 var self = { 2844 index: index, 2845 slideIndex: slideIndex, 2846 slide: slide, 2847 container: container, 2848 isClone: isClone, 2849 mount: mount, 2850 destroy: destroy, 2851 update: update, 2852 style: style$1, 2853 isWithin: isWithin 2854 }; 2855 return self; 2856} 2857 2858function Slides(Splide2, Components2, options) { 2859 var _EventInterface2 = EventInterface$1(Splide2), 2860 on = _EventInterface2.on, 2861 emit = _EventInterface2.emit, 2862 bind = _EventInterface2.bind; 2863 2864 var _Components2$Elements = Components2.Elements, 2865 slides = _Components2$Elements.slides, 2866 list = _Components2$Elements.list; 2867 var Slides2 = []; 2868 2869 function mount() { 2870 init(); 2871 on(EVENT_REFRESH, destroy); 2872 on(EVENT_REFRESH, init); 2873 } 2874 2875 function init() { 2876 slides.forEach(function (slide, index) { 2877 register(slide, index, -1); 2878 }); 2879 } 2880 2881 function destroy() { 2882 forEach$1(function (Slide2) { 2883 Slide2.destroy(); 2884 }); 2885 empty$1(Slides2); 2886 } 2887 2888 function update() { 2889 forEach$1(function (Slide2) { 2890 Slide2.update(); 2891 }); 2892 } 2893 2894 function register(slide, index, slideIndex) { 2895 var object = Slide$1(Splide2, index, slideIndex, slide); 2896 object.mount(); 2897 Slides2.push(object); 2898 Slides2.sort(function (Slide1, Slide2) { 2899 return Slide1.index - Slide2.index; 2900 }); 2901 } 2902 2903 function get(excludeClones) { 2904 return excludeClones ? filter(function (Slide2) { 2905 return !Slide2.isClone; 2906 }) : Slides2; 2907 } 2908 2909 function getIn(page) { 2910 var Controller = Components2.Controller; 2911 var index = Controller.toIndex(page); 2912 var max = Controller.hasFocus() ? 1 : options.perPage; 2913 return filter(function (Slide2) { 2914 return between(Slide2.index, index, index + max - 1); 2915 }); 2916 } 2917 2918 function getAt(index) { 2919 return filter(index)[0]; 2920 } 2921 2922 function add(items, index) { 2923 forEach$2(items, function (slide) { 2924 if (isString(slide)) { 2925 slide = parseHtml(slide); 2926 } 2927 2928 if (isHTMLElement$1(slide)) { 2929 var ref = slides[index]; 2930 ref ? before(slide, ref) : append(list, slide); 2931 addClass(slide, options.classes.slide); 2932 observeImages(slide, apply$2(emit, EVENT_RESIZE)); 2933 } 2934 }); 2935 emit(EVENT_REFRESH); 2936 } 2937 2938 function remove$1(matcher) { 2939 remove(filter(matcher).map(function (Slide2) { 2940 return Slide2.slide; 2941 })); 2942 emit(EVENT_REFRESH); 2943 } 2944 2945 function forEach$1(iteratee, excludeClones) { 2946 get(excludeClones).forEach(iteratee); 2947 } 2948 2949 function filter(matcher) { 2950 return Slides2.filter(isFunction(matcher) ? matcher : function (Slide2) { 2951 return isString(matcher) ? matches(Slide2.slide, matcher) : includes(toArray$2(matcher), Slide2.index); 2952 }); 2953 } 2954 2955 function style(prop, value, useContainer) { 2956 forEach$1(function (Slide2) { 2957 Slide2.style(prop, value, useContainer); 2958 }); 2959 } 2960 2961 function observeImages(elm, callback) { 2962 var images = queryAll(elm, "img"); 2963 var length = images.length; 2964 2965 if (length) { 2966 images.forEach(function (img) { 2967 bind(img, "load error", function () { 2968 if (! --length) { 2969 callback(); 2970 } 2971 }); 2972 }); 2973 } else { 2974 callback(); 2975 } 2976 } 2977 2978 function getLength(excludeClones) { 2979 return excludeClones ? slides.length : Slides2.length; 2980 } 2981 2982 function isEnough() { 2983 return Slides2.length > options.perPage; 2984 } 2985 2986 return { 2987 mount: mount, 2988 destroy: destroy, 2989 update: update, 2990 register: register, 2991 get: get, 2992 getIn: getIn, 2993 getAt: getAt, 2994 add: add, 2995 remove: remove$1, 2996 forEach: forEach$1, 2997 filter: filter, 2998 style: style, 2999 getLength: getLength, 3000 isEnough: isEnough 3001 }; 3002} 3003 3004function Layout(Splide2, Components2, options) { 3005 var _EventInterface3 = EventInterface$1(Splide2), 3006 on = _EventInterface3.on, 3007 bind = _EventInterface3.bind, 3008 emit = _EventInterface3.emit; 3009 3010 var Slides = Components2.Slides; 3011 var resolve = Components2.Direction.resolve; 3012 var _Components2$Elements2 = Components2.Elements, 3013 root = _Components2$Elements2.root, 3014 track = _Components2$Elements2.track, 3015 list = _Components2$Elements2.list; 3016 var getAt = Slides.getAt, 3017 styleSlides = Slides.style; 3018 var vertical; 3019 var rootRect; 3020 var overflow; 3021 3022 function mount() { 3023 init(); 3024 bind(window, "resize load", Throttle(apply$2(emit, EVENT_RESIZE))); 3025 on([EVENT_UPDATED$1, EVENT_REFRESH], init); 3026 on(EVENT_RESIZE, resize); 3027 } 3028 3029 function init() { 3030 vertical = options.direction === TTB; 3031 style(root, "maxWidth", unit(options.width)); 3032 style(track, resolve("paddingLeft"), cssPadding(false)); 3033 style(track, resolve("paddingRight"), cssPadding(true)); 3034 resize(true); 3035 } 3036 3037 function resize(force) { 3038 var newRect = rect(root); 3039 3040 if (force || rootRect.width !== newRect.width || rootRect.height !== newRect.height) { 3041 style(track, "height", cssTrackHeight()); 3042 styleSlides(resolve("marginRight"), unit(options.gap)); 3043 styleSlides("width", cssSlideWidth()); 3044 styleSlides("height", cssSlideHeight(), true); 3045 rootRect = newRect; 3046 emit(EVENT_RESIZED); 3047 3048 if (overflow !== (overflow = isOverflow())) { 3049 toggleClass$1(root, CLASS_OVERFLOW, overflow); 3050 emit(EVENT_OVERFLOW, overflow); 3051 } 3052 } 3053 } 3054 3055 function cssPadding(right) { 3056 var padding = options.padding; 3057 var prop = resolve(right ? "right" : "left"); 3058 return padding && unit(padding[prop] || (isObject$1(padding) ? 0 : padding)) || "0px"; 3059 } 3060 3061 function cssTrackHeight() { 3062 var height = ""; 3063 3064 if (vertical) { 3065 height = cssHeight(); 3066 assert(height, "height or heightRatio is missing."); 3067 height = "calc(" + height + " - " + cssPadding(false) + " - " + cssPadding(true) + ")"; 3068 } 3069 3070 return height; 3071 } 3072 3073 function cssHeight() { 3074 return unit(options.height || rect(list).width * options.heightRatio); 3075 } 3076 3077 function cssSlideWidth() { 3078 return options.autoWidth ? null : unit(options.fixedWidth) || (vertical ? "" : cssSlideSize()); 3079 } 3080 3081 function cssSlideHeight() { 3082 return unit(options.fixedHeight) || (vertical ? options.autoHeight ? null : cssSlideSize() : cssHeight()); 3083 } 3084 3085 function cssSlideSize() { 3086 var gap = unit(options.gap); 3087 return "calc((100%" + (gap && " + " + gap) + ")/" + (options.perPage || 1) + (gap && " - " + gap) + ")"; 3088 } 3089 3090 function listSize() { 3091 return rect(list)[resolve("width")]; 3092 } 3093 3094 function slideSize(index, withoutGap) { 3095 var Slide = getAt(index || 0); 3096 return Slide ? rect(Slide.slide)[resolve("width")] + (withoutGap ? 0 : getGap()) : 0; 3097 } 3098 3099 function totalSize(index, withoutGap) { 3100 var Slide = getAt(index); 3101 3102 if (Slide) { 3103 var right = rect(Slide.slide)[resolve("right")]; 3104 var left = rect(list)[resolve("left")]; 3105 return abs(right - left) + (withoutGap ? 0 : getGap()); 3106 } 3107 3108 return 0; 3109 } 3110 3111 function sliderSize(withoutGap) { 3112 return totalSize(Splide2.length - 1) - totalSize(0) + slideSize(0, withoutGap); 3113 } 3114 3115 function getGap() { 3116 var Slide = getAt(0); 3117 return Slide && parseFloat(style(Slide.slide, resolve("marginRight"))) || 0; 3118 } 3119 3120 function getPadding(right) { 3121 return parseFloat(style(track, resolve("padding" + (right ? "Right" : "Left")))) || 0; 3122 } 3123 3124 function isOverflow() { 3125 return Splide2.is(FADE$1) || sliderSize(true) > listSize(); 3126 } 3127 3128 return { 3129 mount: mount, 3130 resize: resize, 3131 listSize: listSize, 3132 slideSize: slideSize, 3133 sliderSize: sliderSize, 3134 totalSize: totalSize, 3135 getPadding: getPadding, 3136 isOverflow: isOverflow 3137 }; 3138} 3139 3140var MULTIPLIER = 2; 3141 3142function Clones(Splide2, Components2, options) { 3143 var event = EventInterface$1(Splide2); 3144 var on = event.on; 3145 var Elements = Components2.Elements, 3146 Slides = Components2.Slides; 3147 var resolve = Components2.Direction.resolve; 3148 var clones = []; 3149 var cloneCount; 3150 3151 function mount() { 3152 on(EVENT_REFRESH, remount); 3153 on([EVENT_UPDATED$1, EVENT_RESIZE], observe); 3154 3155 if (cloneCount = computeCloneCount()) { 3156 generate(cloneCount); 3157 Components2.Layout.resize(true); 3158 } 3159 } 3160 3161 function remount() { 3162 destroy(); 3163 mount(); 3164 } 3165 3166 function destroy() { 3167 remove(clones); 3168 empty$1(clones); 3169 event.destroy(); 3170 } 3171 3172 function observe() { 3173 var count = computeCloneCount(); 3174 3175 if (cloneCount !== count) { 3176 if (cloneCount < count || !count) { 3177 event.emit(EVENT_REFRESH); 3178 } 3179 } 3180 } 3181 3182 function generate(count) { 3183 var slides = Slides.get().slice(); 3184 var length = slides.length; 3185 3186 if (length) { 3187 while (slides.length < count) { 3188 push(slides, slides); 3189 } 3190 3191 push(slides.slice(-count), slides.slice(0, count)).forEach(function (Slide, index) { 3192 var isHead = index < count; 3193 var clone = cloneDeep(Slide.slide, index); 3194 isHead ? before(clone, slides[0].slide) : append(Elements.list, clone); 3195 push(clones, clone); 3196 Slides.register(clone, index - count + (isHead ? 0 : length), Slide.index); 3197 }); 3198 } 3199 } 3200 3201 function cloneDeep(elm, index) { 3202 var clone = elm.cloneNode(true); 3203 addClass(clone, options.classes.clone); 3204 clone.id = Splide2.root.id + "-clone" + pad(index + 1); 3205 return clone; 3206 } 3207 3208 function computeCloneCount() { 3209 var clones2 = options.clones; 3210 3211 if (!Splide2.is(LOOP)) { 3212 clones2 = 0; 3213 } else if (isUndefined$1(clones2)) { 3214 var fixedSize = options[resolve("fixedWidth")] && Components2.Layout.slideSize(0); 3215 var fixedCount = fixedSize && ceil(rect(Elements.track)[resolve("width")] / fixedSize); 3216 clones2 = fixedCount || options[resolve("autoWidth")] && Splide2.length || options.perPage * MULTIPLIER; 3217 } 3218 3219 return clones2; 3220 } 3221 3222 return { 3223 mount: mount, 3224 destroy: destroy 3225 }; 3226} 3227 3228function Move(Splide2, Components2, options) { 3229 var _EventInterface4 = EventInterface$1(Splide2), 3230 on = _EventInterface4.on, 3231 emit = _EventInterface4.emit; 3232 3233 var set = Splide2.state.set; 3234 var _Components2$Layout = Components2.Layout, 3235 slideSize = _Components2$Layout.slideSize, 3236 getPadding = _Components2$Layout.getPadding, 3237 totalSize = _Components2$Layout.totalSize, 3238 listSize = _Components2$Layout.listSize, 3239 sliderSize = _Components2$Layout.sliderSize; 3240 var _Components2$Directio = Components2.Direction, 3241 resolve = _Components2$Directio.resolve, 3242 orient = _Components2$Directio.orient; 3243 var _Components2$Elements3 = Components2.Elements, 3244 list = _Components2$Elements3.list, 3245 track = _Components2$Elements3.track; 3246 var Transition; 3247 3248 function mount() { 3249 Transition = Components2.Transition; 3250 on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED$1, EVENT_REFRESH], reposition); 3251 } 3252 3253 function reposition() { 3254 if (!Components2.Controller.isBusy()) { 3255 Components2.Scroll.cancel(); 3256 jump(Splide2.index); 3257 Components2.Slides.update(); 3258 } 3259 } 3260 3261 function move(dest, index, prev, callback) { 3262 if (dest !== index && canShift(dest > prev)) { 3263 cancel(); 3264 translate(shift(getPosition(), dest > prev), true); 3265 } 3266 3267 set(MOVING); 3268 emit(EVENT_MOVE$1, index, prev, dest); 3269 Transition.start(index, function () { 3270 set(IDLE); 3271 emit(EVENT_MOVED$1, index, prev, dest); 3272 callback && callback(); 3273 }); 3274 } 3275 3276 function jump(index) { 3277 translate(toPosition(index, true)); 3278 } 3279 3280 function translate(position, preventLoop) { 3281 if (!Splide2.is(FADE$1)) { 3282 var destination = preventLoop ? position : loop(position); 3283 style(list, "transform", "translate" + resolve("X") + "(" + destination + "px)"); 3284 position !== destination && emit(EVENT_SHIFTED); 3285 } 3286 } 3287 3288 function loop(position) { 3289 if (Splide2.is(LOOP)) { 3290 var index = toIndex(position); 3291 var exceededMax = index > Components2.Controller.getEnd(); 3292 var exceededMin = index < 0; 3293 3294 if (exceededMin || exceededMax) { 3295 position = shift(position, exceededMax); 3296 } 3297 } 3298 3299 return position; 3300 } 3301 3302 function shift(position, backwards) { 3303 var excess = position - getLimit(backwards); 3304 var size = sliderSize(); 3305 position -= orient(size * (ceil(abs(excess) / size) || 1)) * (backwards ? 1 : -1); 3306 return position; 3307 } 3308 3309 function cancel() { 3310 translate(getPosition(), true); 3311 Transition.cancel(); 3312 } 3313 3314 function toIndex(position) { 3315 var Slides = Components2.Slides.get(); 3316 var index = 0; 3317 var minDistance = Infinity; 3318 3319 for (var i = 0; i < Slides.length; i++) { 3320 var slideIndex = Slides[i].index; 3321 var distance = abs(toPosition(slideIndex, true) - position); 3322 3323 if (distance <= minDistance) { 3324 minDistance = distance; 3325 index = slideIndex; 3326 } else { 3327 break; 3328 } 3329 } 3330 3331 return index; 3332 } 3333 3334 function toPosition(index, trimming) { 3335 var position = orient(totalSize(index - 1) - offset(index)); 3336 return trimming ? trim(position) : position; 3337 } 3338 3339 function getPosition() { 3340 var left = resolve("left"); 3341 return rect(list)[left] - rect(track)[left] + orient(getPadding(false)); 3342 } 3343 3344 function trim(position) { 3345 if (options.trimSpace && Splide2.is(SLIDE$1)) { 3346 position = clamp$1(position, 0, orient(sliderSize(true) - listSize())); 3347 } 3348 3349 return position; 3350 } 3351 3352 function offset(index) { 3353 var focus = options.focus; 3354 return focus === "center" ? (listSize() - slideSize(index, true)) / 2 : +focus * slideSize(index) || 0; 3355 } 3356 3357 function getLimit(max) { 3358 return toPosition(max ? Components2.Controller.getEnd() : 0, !!options.trimSpace); 3359 } 3360 3361 function canShift(backwards) { 3362 var shifted = orient(shift(getPosition(), backwards)); 3363 return backwards ? shifted >= 0 : shifted <= list[resolve("scrollWidth")] - rect(track)[resolve("width")]; 3364 } 3365 3366 function exceededLimit(max, position) { 3367 position = isUndefined$1(position) ? getPosition() : position; 3368 var exceededMin = max !== true && orient(position) < orient(getLimit(false)); 3369 var exceededMax = max !== false && orient(position) > orient(getLimit(true)); 3370 return exceededMin || exceededMax; 3371 } 3372 3373 return { 3374 mount: mount, 3375 move: move, 3376 jump: jump, 3377 translate: translate, 3378 shift: shift, 3379 cancel: cancel, 3380 toIndex: toIndex, 3381 toPosition: toPosition, 3382 getPosition: getPosition, 3383 getLimit: getLimit, 3384 exceededLimit: exceededLimit, 3385 reposition: reposition 3386 }; 3387} 3388 3389function Controller(Splide2, Components2, options) { 3390 var _EventInterface5 = EventInterface$1(Splide2), 3391 on = _EventInterface5.on, 3392 emit = _EventInterface5.emit; 3393 3394 var Move = Components2.Move; 3395 var getPosition = Move.getPosition, 3396 getLimit = Move.getLimit, 3397 toPosition = Move.toPosition; 3398 var _Components2$Slides = Components2.Slides, 3399 isEnough = _Components2$Slides.isEnough, 3400 getLength = _Components2$Slides.getLength; 3401 var omitEnd = options.omitEnd; 3402 var isLoop = Splide2.is(LOOP); 3403 var isSlide = Splide2.is(SLIDE$1); 3404 var getNext = apply$2(getAdjacent, false); 3405 var getPrev = apply$2(getAdjacent, true); 3406 var currIndex = options.start || 0; 3407 var endIndex; 3408 var prevIndex = currIndex; 3409 var slideCount; 3410 var perMove; 3411 var perPage; 3412 3413 function mount() { 3414 init(); 3415 on([EVENT_UPDATED$1, EVENT_REFRESH, EVENT_END_INDEX_CHANGED], init); 3416 on(EVENT_RESIZED, onResized); 3417 } 3418 3419 function init() { 3420 slideCount = getLength(true); 3421 perMove = options.perMove; 3422 perPage = options.perPage; 3423 endIndex = getEnd(); 3424 var index = clamp$1(currIndex, 0, omitEnd ? endIndex : slideCount - 1); 3425 3426 if (index !== currIndex) { 3427 currIndex = index; 3428 Move.reposition(); 3429 } 3430 } 3431 3432 function onResized() { 3433 if (endIndex !== getEnd()) { 3434 emit(EVENT_END_INDEX_CHANGED); 3435 } 3436 } 3437 3438 function go(control, allowSameIndex, callback) { 3439 if (!isBusy()) { 3440 var dest = parse(control); 3441 var index = loop(dest); 3442 3443 if (index > -1 && (allowSameIndex || index !== currIndex)) { 3444 setIndex(index); 3445 Move.move(dest, index, prevIndex, callback); 3446 } 3447 } 3448 } 3449 3450 function scroll(destination, duration, snap, callback) { 3451 Components2.Scroll.scroll(destination, duration, snap, function () { 3452 var index = loop(Move.toIndex(getPosition())); 3453 setIndex(omitEnd ? min$3(index, endIndex) : index); 3454 callback && callback(); 3455 }); 3456 } 3457 3458 function parse(control) { 3459 var index = currIndex; 3460 3461 if (isString(control)) { 3462 var _ref = control.match(/([+\-<>])(\d+)?/) || [], 3463 indicator = _ref[1], 3464 number = _ref[2]; 3465 3466 if (indicator === "+" || indicator === "-") { 3467 index = computeDestIndex(currIndex + +("" + indicator + (+number || 1)), currIndex); 3468 } else if (indicator === ">") { 3469 index = number ? toIndex(+number) : getNext(true); 3470 } else if (indicator === "<") { 3471 index = getPrev(true); 3472 } 3473 } else { 3474 index = isLoop ? control : clamp$1(control, 0, endIndex); 3475 } 3476 3477 return index; 3478 } 3479 3480 function getAdjacent(prev, destination) { 3481 var number = perMove || (hasFocus() ? 1 : perPage); 3482 var dest = computeDestIndex(currIndex + number * (prev ? -1 : 1), currIndex, !(perMove || hasFocus())); 3483 3484 if (dest === -1 && isSlide) { 3485 if (!approximatelyEqual(getPosition(), getLimit(!prev), 1)) { 3486 return prev ? 0 : endIndex; 3487 } 3488 } 3489 3490 return destination ? dest : loop(dest); 3491 } 3492 3493 function computeDestIndex(dest, from, snapPage) { 3494 if (isEnough() || hasFocus()) { 3495 var index = computeMovableDestIndex(dest); 3496 3497 if (index !== dest) { 3498 from = dest; 3499 dest = index; 3500 snapPage = false; 3501 } 3502 3503 if (dest < 0 || dest > endIndex) { 3504 if (!perMove && (between(0, dest, from, true) || between(endIndex, from, dest, true))) { 3505 dest = toIndex(toPage(dest)); 3506 } else { 3507 if (isLoop) { 3508 dest = snapPage ? dest < 0 ? -(slideCount % perPage || perPage) : slideCount : dest; 3509 } else if (options.rewind) { 3510 dest = dest < 0 ? endIndex : 0; 3511 } else { 3512 dest = -1; 3513 } 3514 } 3515 } else { 3516 if (snapPage && dest !== from) { 3517 dest = toIndex(toPage(from) + (dest < from ? -1 : 1)); 3518 } 3519 } 3520 } else { 3521 dest = -1; 3522 } 3523 3524 return dest; 3525 } 3526 3527 function computeMovableDestIndex(dest) { 3528 if (isSlide && options.trimSpace === "move" && dest !== currIndex) { 3529 var position = getPosition(); 3530 3531 while (position === toPosition(dest, true) && between(dest, 0, Splide2.length - 1, !options.rewind)) { 3532 dest < currIndex ? --dest : ++dest; 3533 } 3534 } 3535 3536 return dest; 3537 } 3538 3539 function loop(index) { 3540 return isLoop ? (index + slideCount) % slideCount || 0 : index; 3541 } 3542 3543 function getEnd() { 3544 var end = slideCount - (hasFocus() || isLoop && perMove ? 1 : perPage); 3545 3546 while (omitEnd && end-- > 0) { 3547 if (toPosition(slideCount - 1, true) !== toPosition(end, true)) { 3548 end++; 3549 break; 3550 } 3551 } 3552 3553 return clamp$1(end, 0, slideCount - 1); 3554 } 3555 3556 function toIndex(page) { 3557 return clamp$1(hasFocus() ? page : perPage * page, 0, endIndex); 3558 } 3559 3560 function toPage(index) { 3561 return hasFocus() ? min$3(index, endIndex) : floor((index >= endIndex ? slideCount - 1 : index) / perPage); 3562 } 3563 3564 function toDest(destination) { 3565 var closest = Move.toIndex(destination); 3566 return isSlide ? clamp$1(closest, 0, endIndex) : closest; 3567 } 3568 3569 function setIndex(index) { 3570 if (index !== currIndex) { 3571 prevIndex = currIndex; 3572 currIndex = index; 3573 } 3574 } 3575 3576 function getIndex(prev) { 3577 return prev ? prevIndex : currIndex; 3578 } 3579 3580 function hasFocus() { 3581 return !isUndefined$1(options.focus) || options.isNavigation; 3582 } 3583 3584 function isBusy() { 3585 return Splide2.state.is([MOVING, SCROLLING]) && !!options.waitForTransition; 3586 } 3587 3588 return { 3589 mount: mount, 3590 go: go, 3591 scroll: scroll, 3592 getNext: getNext, 3593 getPrev: getPrev, 3594 getAdjacent: getAdjacent, 3595 getEnd: getEnd, 3596 setIndex: setIndex, 3597 getIndex: getIndex, 3598 toIndex: toIndex, 3599 toPage: toPage, 3600 toDest: toDest, 3601 hasFocus: hasFocus, 3602 isBusy: isBusy 3603 }; 3604} 3605 3606var XML_NAME_SPACE = "http://www.w3.org/2000/svg"; 3607var PATH = "m15.5 0.932-4.3 4.38 14.5 14.6-14.5 14.5 4.3 4.4 14.6-14.6 4.4-4.3-4.4-4.4-14.6-14.6z"; 3608var SIZE = 40; 3609 3610function Arrows(Splide2, Components2, options) { 3611 var event = EventInterface$1(Splide2); 3612 var on = event.on, 3613 bind = event.bind, 3614 emit = event.emit; 3615 var classes = options.classes, 3616 i18n = options.i18n; 3617 var Elements = Components2.Elements, 3618 Controller = Components2.Controller; 3619 var placeholder = Elements.arrows, 3620 track = Elements.track; 3621 var wrapper = placeholder; 3622 var prev = Elements.prev; 3623 var next = Elements.next; 3624 var created; 3625 var wrapperClasses; 3626 var arrows = {}; 3627 3628 function mount() { 3629 init(); 3630 on(EVENT_UPDATED$1, remount); 3631 } 3632 3633 function remount() { 3634 destroy(); 3635 mount(); 3636 } 3637 3638 function init() { 3639 var enabled = options.arrows; 3640 3641 if (enabled && !(prev && next)) { 3642 createArrows(); 3643 } 3644 3645 if (prev && next) { 3646 assign$2(arrows, { 3647 prev: prev, 3648 next: next 3649 }); 3650 display(wrapper, enabled ? "" : "none"); 3651 addClass(wrapper, wrapperClasses = CLASS_ARROWS + "--" + options.direction); 3652 3653 if (enabled) { 3654 listen(); 3655 update(); 3656 setAttribute$1([prev, next], ARIA_CONTROLS, track.id); 3657 emit(EVENT_ARROWS_MOUNTED, prev, next); 3658 } 3659 } 3660 } 3661 3662 function destroy() { 3663 event.destroy(); 3664 removeClass(wrapper, wrapperClasses); 3665 3666 if (created) { 3667 remove(placeholder ? [prev, next] : wrapper); 3668 prev = next = null; 3669 } else { 3670 removeAttribute$1([prev, next], ALL_ATTRIBUTES); 3671 } 3672 } 3673 3674 function listen() { 3675 on([EVENT_MOUNTED, EVENT_MOVED$1, EVENT_REFRESH, EVENT_SCROLLED$1, EVENT_END_INDEX_CHANGED], update); 3676 bind(next, "click", apply$2(go, ">")); 3677 bind(prev, "click", apply$2(go, "<")); 3678 } 3679 3680 function go(control) { 3681 Controller.go(control, true); 3682 } 3683 3684 function createArrows() { 3685 wrapper = placeholder || create("div", classes.arrows); 3686 prev = createArrow(true); 3687 next = createArrow(false); 3688 created = true; 3689 append(wrapper, [prev, next]); 3690 !placeholder && before(wrapper, track); 3691 } 3692 3693 function createArrow(prev2) { 3694 var arrow = "<button class=\"" + classes.arrow + " " + (prev2 ? classes.prev : classes.next) + "\" type=\"button\"><svg xmlns=\"" + XML_NAME_SPACE + "\" viewBox=\"0 0 " + SIZE + " " + SIZE + "\" width=\"" + SIZE + "\" height=\"" + SIZE + "\" focusable=\"false\"><path d=\"" + (options.arrowPath || PATH) + "\" />"; 3695 return parseHtml(arrow); 3696 } 3697 3698 function update() { 3699 if (prev && next) { 3700 var index = Splide2.index; 3701 var prevIndex = Controller.getPrev(); 3702 var nextIndex = Controller.getNext(); 3703 var prevLabel = prevIndex > -1 && index < prevIndex ? i18n.last : i18n.prev; 3704 var nextLabel = nextIndex > -1 && index > nextIndex ? i18n.first : i18n.next; 3705 prev.disabled = prevIndex < 0; 3706 next.disabled = nextIndex < 0; 3707 setAttribute$1(prev, ARIA_LABEL, prevLabel); 3708 setAttribute$1(next, ARIA_LABEL, nextLabel); 3709 emit(EVENT_ARROWS_UPDATED, prev, next, prevIndex, nextIndex); 3710 } 3711 } 3712 3713 return { 3714 arrows: arrows, 3715 mount: mount, 3716 destroy: destroy, 3717 update: update 3718 }; 3719} 3720 3721var INTERVAL_DATA_ATTRIBUTE = DATA_ATTRIBUTE + "-interval"; 3722 3723function Autoplay(Splide2, Components2, options) { 3724 var _EventInterface6 = EventInterface$1(Splide2), 3725 on = _EventInterface6.on, 3726 bind = _EventInterface6.bind, 3727 emit = _EventInterface6.emit; 3728 3729 var interval = RequestInterval$1(options.interval, Splide2.go.bind(Splide2, ">"), onAnimationFrame); 3730 var isPaused = interval.isPaused; 3731 var Elements = Components2.Elements, 3732 _Components2$Elements4 = Components2.Elements, 3733 root = _Components2$Elements4.root, 3734 toggle = _Components2$Elements4.toggle; 3735 var autoplay = options.autoplay; 3736 var hovered; 3737 var focused; 3738 var stopped = autoplay === "pause"; 3739 3740 function mount() { 3741 if (autoplay) { 3742 listen(); 3743 toggle && setAttribute$1(toggle, ARIA_CONTROLS, Elements.track.id); 3744 stopped || play(); 3745 update(); 3746 } 3747 } 3748 3749 function listen() { 3750 if (options.pauseOnHover) { 3751 bind(root, "mouseenter mouseleave", function (e) { 3752 hovered = e.type === "mouseenter"; 3753 autoToggle(); 3754 }); 3755 } 3756 3757 if (options.pauseOnFocus) { 3758 bind(root, "focusin focusout", function (e) { 3759 focused = e.type === "focusin"; 3760 autoToggle(); 3761 }); 3762 } 3763 3764 if (toggle) { 3765 bind(toggle, "click", function () { 3766 stopped ? play() : pause(true); 3767 }); 3768 } 3769 3770 on([EVENT_MOVE$1, EVENT_SCROLL$1, EVENT_REFRESH], interval.rewind); 3771 on(EVENT_MOVE$1, onMove); 3772 } 3773 3774 function play() { 3775 if (isPaused() && Components2.Slides.isEnough()) { 3776 interval.start(!options.resetProgress); 3777 focused = hovered = stopped = false; 3778 update(); 3779 emit(EVENT_AUTOPLAY_PLAY); 3780 } 3781 } 3782 3783 function pause(stop) { 3784 if (stop === void 0) { 3785 stop = true; 3786 } 3787 3788 stopped = !!stop; 3789 update(); 3790 3791 if (!isPaused()) { 3792 interval.pause(); 3793 emit(EVENT_AUTOPLAY_PAUSE); 3794 } 3795 } 3796 3797 function autoToggle() { 3798 if (!stopped) { 3799 hovered || focused ? pause(false) : play(); 3800 } 3801 } 3802 3803 function update() { 3804 if (toggle) { 3805 toggleClass$1(toggle, CLASS_ACTIVE$1, !stopped); 3806 setAttribute$1(toggle, ARIA_LABEL, options.i18n[stopped ? "play" : "pause"]); 3807 } 3808 } 3809 3810 function onAnimationFrame(rate) { 3811 var bar = Elements.bar; 3812 bar && style(bar, "width", rate * 100 + "%"); 3813 emit(EVENT_AUTOPLAY_PLAYING, rate); 3814 } 3815 3816 function onMove(index) { 3817 var Slide = Components2.Slides.getAt(index); 3818 interval.set(Slide && +getAttribute(Slide.slide, INTERVAL_DATA_ATTRIBUTE) || options.interval); 3819 } 3820 3821 return { 3822 mount: mount, 3823 destroy: interval.cancel, 3824 play: play, 3825 pause: pause, 3826 isPaused: isPaused 3827 }; 3828} 3829 3830function Cover(Splide2, Components2, options) { 3831 var _EventInterface7 = EventInterface$1(Splide2), 3832 on = _EventInterface7.on; 3833 3834 function mount() { 3835 if (options.cover) { 3836 on(EVENT_LAZYLOAD_LOADED, apply$2(toggle, true)); 3837 on([EVENT_MOUNTED, EVENT_UPDATED$1, EVENT_REFRESH], apply$2(cover, true)); 3838 } 3839 } 3840 3841 function cover(cover2) { 3842 Components2.Slides.forEach(function (Slide) { 3843 var img = child(Slide.container || Slide.slide, "img"); 3844 3845 if (img && img.src) { 3846 toggle(cover2, img, Slide); 3847 } 3848 }); 3849 } 3850 3851 function toggle(cover2, img, Slide) { 3852 Slide.style("background", cover2 ? "center/cover no-repeat url(\"" + img.src + "\")" : "", true); 3853 display(img, cover2 ? "none" : ""); 3854 } 3855 3856 return { 3857 mount: mount, 3858 destroy: apply$2(cover, false) 3859 }; 3860} 3861 3862var BOUNCE_DIFF_THRESHOLD = 10; 3863var BOUNCE_DURATION = 600; 3864var FRICTION_FACTOR = 0.6; 3865var BASE_VELOCITY = 1.5; 3866var MIN_DURATION = 800; 3867 3868function Scroll(Splide2, Components2, options) { 3869 var _EventInterface8 = EventInterface$1(Splide2), 3870 on = _EventInterface8.on, 3871 emit = _EventInterface8.emit; 3872 3873 var set = Splide2.state.set; 3874 var Move = Components2.Move; 3875 var getPosition = Move.getPosition, 3876 getLimit = Move.getLimit, 3877 exceededLimit = Move.exceededLimit, 3878 translate = Move.translate; 3879 var isSlide = Splide2.is(SLIDE$1); 3880 var interval; 3881 var callback; 3882 var friction = 1; 3883 3884 function mount() { 3885 on(EVENT_MOVE$1, clear); 3886 on([EVENT_UPDATED$1, EVENT_REFRESH], cancel); 3887 } 3888 3889 function scroll(destination, duration, snap, onScrolled, noConstrain) { 3890 var from = getPosition(); 3891 clear(); 3892 3893 if (snap && (!isSlide || !exceededLimit())) { 3894 var size = Components2.Layout.sliderSize(); 3895 var offset = sign(destination) * size * floor(abs(destination) / size) || 0; 3896 destination = Move.toPosition(Components2.Controller.toDest(destination % size)) + offset; 3897 } 3898 3899 var noDistance = approximatelyEqual(from, destination, 1); 3900 friction = 1; 3901 duration = noDistance ? 0 : duration || max$2(abs(destination - from) / BASE_VELOCITY, MIN_DURATION); 3902 callback = onScrolled; 3903 interval = RequestInterval$1(duration, onEnd, apply$2(update, from, destination, noConstrain), 1); 3904 set(SCROLLING); 3905 emit(EVENT_SCROLL$1); 3906 interval.start(); 3907 } 3908 3909 function onEnd() { 3910 set(IDLE); 3911 callback && callback(); 3912 emit(EVENT_SCROLLED$1); 3913 } 3914 3915 function update(from, to, noConstrain, rate) { 3916 var position = getPosition(); 3917 var target = from + (to - from) * easing(rate); 3918 var diff = (target - position) * friction; 3919 translate(position + diff); 3920 3921 if (isSlide && !noConstrain && exceededLimit()) { 3922 friction *= FRICTION_FACTOR; 3923 3924 if (abs(diff) < BOUNCE_DIFF_THRESHOLD) { 3925 scroll(getLimit(exceededLimit(true)), BOUNCE_DURATION, false, callback, true); 3926 } 3927 } 3928 } 3929 3930 function clear() { 3931 if (interval) { 3932 interval.cancel(); 3933 } 3934 } 3935 3936 function cancel() { 3937 if (interval && !interval.isPaused()) { 3938 clear(); 3939 onEnd(); 3940 } 3941 } 3942 3943 function easing(t) { 3944 var easingFunc = options.easingFunc; 3945 return easingFunc ? easingFunc(t) : 1 - Math.pow(1 - t, 4); 3946 } 3947 3948 return { 3949 mount: mount, 3950 destroy: clear, 3951 scroll: scroll, 3952 cancel: cancel 3953 }; 3954} 3955 3956var SCROLL_LISTENER_OPTIONS = { 3957 passive: false, 3958 capture: true 3959}; 3960 3961function Drag(Splide2, Components2, options) { 3962 var _EventInterface9 = EventInterface$1(Splide2), 3963 on = _EventInterface9.on, 3964 emit = _EventInterface9.emit, 3965 bind = _EventInterface9.bind, 3966 unbind = _EventInterface9.unbind; 3967 3968 var state = Splide2.state; 3969 var Move = Components2.Move, 3970 Scroll = Components2.Scroll, 3971 Controller = Components2.Controller, 3972 track = Components2.Elements.track, 3973 reduce = Components2.Media.reduce; 3974 var _Components2$Directio2 = Components2.Direction, 3975 resolve = _Components2$Directio2.resolve, 3976 orient = _Components2$Directio2.orient; 3977 var getPosition = Move.getPosition, 3978 exceededLimit = Move.exceededLimit; 3979 var basePosition; 3980 var baseEvent; 3981 var prevBaseEvent; 3982 var isFree; 3983 var dragging; 3984 var exceeded = false; 3985 var clickPrevented; 3986 var disabled; 3987 var target; 3988 3989 function mount() { 3990 bind(track, POINTER_MOVE_EVENTS, noop, SCROLL_LISTENER_OPTIONS); 3991 bind(track, POINTER_UP_EVENTS, noop, SCROLL_LISTENER_OPTIONS); 3992 bind(track, POINTER_DOWN_EVENTS, onPointerDown, SCROLL_LISTENER_OPTIONS); 3993 bind(track, "click", onClick, { 3994 capture: true 3995 }); 3996 bind(track, "dragstart", prevent); 3997 on([EVENT_MOUNTED, EVENT_UPDATED$1], init); 3998 } 3999 4000 function init() { 4001 var drag = options.drag; 4002 disable(!drag); 4003 isFree = drag === "free"; 4004 } 4005 4006 function onPointerDown(e) { 4007 clickPrevented = false; 4008 4009 if (!disabled) { 4010 var isTouch = isTouchEvent(e); 4011 4012 if (isDraggable(e.target) && (isTouch || !e.button)) { 4013 if (!Controller.isBusy()) { 4014 target = isTouch ? track : window; 4015 dragging = state.is([MOVING, SCROLLING]); 4016 prevBaseEvent = null; 4017 bind(target, POINTER_MOVE_EVENTS, onPointerMove, SCROLL_LISTENER_OPTIONS); 4018 bind(target, POINTER_UP_EVENTS, onPointerUp, SCROLL_LISTENER_OPTIONS); 4019 Move.cancel(); 4020 Scroll.cancel(); 4021 save(e); 4022 } else { 4023 prevent(e, true); 4024 } 4025 } 4026 } 4027 } 4028 4029 function onPointerMove(e) { 4030 if (!state.is(DRAGGING)) { 4031 state.set(DRAGGING); 4032 emit(EVENT_DRAG$1); 4033 } 4034 4035 if (e.cancelable) { 4036 if (dragging) { 4037 Move.translate(basePosition + constrain(diffCoord(e))); 4038 var expired = diffTime(e) > LOG_INTERVAL; 4039 var hasExceeded = exceeded !== (exceeded = exceededLimit()); 4040 4041 if (expired || hasExceeded) { 4042 save(e); 4043 } 4044 4045 clickPrevented = true; 4046 emit(EVENT_DRAGGING); 4047 prevent(e); 4048 } else if (isSliderDirection(e)) { 4049 dragging = shouldStart(e); 4050 prevent(e); 4051 } 4052 } 4053 } 4054 4055 function onPointerUp(e) { 4056 if (state.is(DRAGGING)) { 4057 state.set(IDLE); 4058 emit(EVENT_DRAGGED); 4059 } 4060 4061 if (dragging) { 4062 move(e); 4063 prevent(e); 4064 } 4065 4066 unbind(target, POINTER_MOVE_EVENTS, onPointerMove); 4067 unbind(target, POINTER_UP_EVENTS, onPointerUp); 4068 dragging = false; 4069 } 4070 4071 function onClick(e) { 4072 if (!disabled && clickPrevented) { 4073 prevent(e, true); 4074 } 4075 } 4076 4077 function save(e) { 4078 prevBaseEvent = baseEvent; 4079 baseEvent = e; 4080 basePosition = getPosition(); 4081 } 4082 4083 function move(e) { 4084 var velocity = computeVelocity(e); 4085 var destination = computeDestination(velocity); 4086 var rewind = options.rewind && options.rewindByDrag; 4087 reduce(false); 4088 4089 if (isFree) { 4090 Controller.scroll(destination, 0, options.snap); 4091 } else if (Splide2.is(FADE$1)) { 4092 Controller.go(orient(sign(velocity)) < 0 ? rewind ? "<" : "-" : rewind ? ">" : "+"); 4093 } else if (Splide2.is(SLIDE$1) && exceeded && rewind) { 4094 Controller.go(exceededLimit(true) ? ">" : "<"); 4095 } else { 4096 Controller.go(Controller.toDest(destination), true); 4097 } 4098 4099 reduce(true); 4100 } 4101 4102 function shouldStart(e) { 4103 var thresholds = options.dragMinThreshold; 4104 var isObj = isObject$1(thresholds); 4105 var mouse = isObj && thresholds.mouse || 0; 4106 var touch = (isObj ? thresholds.touch : +thresholds) || 10; 4107 return abs(diffCoord(e)) > (isTouchEvent(e) ? touch : mouse); 4108 } 4109 4110 function isSliderDirection(e) { 4111 return abs(diffCoord(e)) > abs(diffCoord(e, true)); 4112 } 4113 4114 function computeVelocity(e) { 4115 if (Splide2.is(LOOP) || !exceeded) { 4116 var time = diffTime(e); 4117 4118 if (time && time < LOG_INTERVAL) { 4119 return diffCoord(e) / time; 4120 } 4121 } 4122 4123 return 0; 4124 } 4125 4126 function computeDestination(velocity) { 4127 return getPosition() + sign(velocity) * min$3(abs(velocity) * (options.flickPower || 600), isFree ? Infinity : Components2.Layout.listSize() * (options.flickMaxPages || 1)); 4128 } 4129 4130 function diffCoord(e, orthogonal) { 4131 return coordOf(e, orthogonal) - coordOf(getBaseEvent(e), orthogonal); 4132 } 4133 4134 function diffTime(e) { 4135 return timeOf(e) - timeOf(getBaseEvent(e)); 4136 } 4137 4138 function getBaseEvent(e) { 4139 return baseEvent === e && prevBaseEvent || baseEvent; 4140 } 4141 4142 function coordOf(e, orthogonal) { 4143 return (isTouchEvent(e) ? e.changedTouches[0] : e)["page" + resolve(orthogonal ? "Y" : "X")]; 4144 } 4145 4146 function constrain(diff) { 4147 return diff / (exceeded && Splide2.is(SLIDE$1) ? FRICTION : 1); 4148 } 4149 4150 function isDraggable(target2) { 4151 var noDrag = options.noDrag; 4152 return !matches(target2, "." + CLASS_PAGINATION_PAGE + ", ." + CLASS_ARROW) && (!noDrag || !matches(target2, noDrag)); 4153 } 4154 4155 function isTouchEvent(e) { 4156 return typeof TouchEvent !== "undefined" && e instanceof TouchEvent; 4157 } 4158 4159 function isDragging() { 4160 return dragging; 4161 } 4162 4163 function disable(value) { 4164 disabled = value; 4165 } 4166 4167 return { 4168 mount: mount, 4169 disable: disable, 4170 isDragging: isDragging 4171 }; 4172} 4173 4174var NORMALIZATION_MAP = { 4175 Spacebar: " ", 4176 Right: ARROW_RIGHT, 4177 Left: ARROW_LEFT, 4178 Up: ARROW_UP, 4179 Down: ARROW_DOWN 4180}; 4181 4182function normalizeKey(key) { 4183 key = isString(key) ? key : key.key; 4184 return NORMALIZATION_MAP[key] || key; 4185} 4186 4187var KEYBOARD_EVENT = "keydown"; 4188 4189function Keyboard(Splide2, Components2, options) { 4190 var _EventInterface10 = EventInterface$1(Splide2), 4191 on = _EventInterface10.on, 4192 bind = _EventInterface10.bind, 4193 unbind = _EventInterface10.unbind; 4194 4195 var root = Splide2.root; 4196 var resolve = Components2.Direction.resolve; 4197 var target; 4198 var disabled; 4199 4200 function mount() { 4201 init(); 4202 on(EVENT_UPDATED$1, destroy); 4203 on(EVENT_UPDATED$1, init); 4204 on(EVENT_MOVE$1, onMove); 4205 } 4206 4207 function init() { 4208 var keyboard = options.keyboard; 4209 4210 if (keyboard) { 4211 target = keyboard === "global" ? window : root; 4212 bind(target, KEYBOARD_EVENT, onKeydown); 4213 } 4214 } 4215 4216 function destroy() { 4217 unbind(target, KEYBOARD_EVENT); 4218 } 4219 4220 function disable(value) { 4221 disabled = value; 4222 } 4223 4224 function onMove() { 4225 var _disabled = disabled; 4226 disabled = true; 4227 nextTick(function () { 4228 disabled = _disabled; 4229 }); 4230 } 4231 4232 function onKeydown(e) { 4233 if (!disabled) { 4234 var key = normalizeKey(e); 4235 4236 if (key === resolve(ARROW_LEFT)) { 4237 Splide2.go("<"); 4238 } else if (key === resolve(ARROW_RIGHT)) { 4239 Splide2.go(">"); 4240 } 4241 } 4242 } 4243 4244 return { 4245 mount: mount, 4246 destroy: destroy, 4247 disable: disable 4248 }; 4249} 4250 4251var SRC_DATA_ATTRIBUTE = DATA_ATTRIBUTE + "-lazy"; 4252var SRCSET_DATA_ATTRIBUTE = SRC_DATA_ATTRIBUTE + "-srcset"; 4253var IMAGE_SELECTOR = "[" + SRC_DATA_ATTRIBUTE + "], [" + SRCSET_DATA_ATTRIBUTE + "]"; 4254 4255function LazyLoad(Splide2, Components2, options) { 4256 var _EventInterface11 = EventInterface$1(Splide2), 4257 on = _EventInterface11.on, 4258 off = _EventInterface11.off, 4259 bind = _EventInterface11.bind, 4260 emit = _EventInterface11.emit; 4261 4262 var isSequential = options.lazyLoad === "sequential"; 4263 var events = [EVENT_MOVED$1, EVENT_SCROLLED$1]; 4264 var entries = []; 4265 4266 function mount() { 4267 if (options.lazyLoad) { 4268 init(); 4269 on(EVENT_REFRESH, init); 4270 } 4271 } 4272 4273 function init() { 4274 empty$1(entries); 4275 register(); 4276 4277 if (isSequential) { 4278 loadNext(); 4279 } else { 4280 off(events); 4281 on(events, check); 4282 check(); 4283 } 4284 } 4285 4286 function register() { 4287 Components2.Slides.forEach(function (Slide) { 4288 queryAll(Slide.slide, IMAGE_SELECTOR).forEach(function (img) { 4289 var src = getAttribute(img, SRC_DATA_ATTRIBUTE); 4290 var srcset = getAttribute(img, SRCSET_DATA_ATTRIBUTE); 4291 4292 if (src !== img.src || srcset !== img.srcset) { 4293 var className = options.classes.spinner; 4294 var parent = img.parentElement; 4295 var spinner = child(parent, "." + className) || create("span", className, parent); 4296 entries.push([img, Slide, spinner]); 4297 img.src || display(img, "none"); 4298 } 4299 }); 4300 }); 4301 } 4302 4303 function check() { 4304 entries = entries.filter(function (data) { 4305 var distance = options.perPage * ((options.preloadPages || 1) + 1) - 1; 4306 return data[1].isWithin(Splide2.index, distance) ? load(data) : true; 4307 }); 4308 entries.length || off(events); 4309 } 4310 4311 function load(data) { 4312 var img = data[0]; 4313 addClass(data[1].slide, CLASS_LOADING); 4314 bind(img, "load error", apply$2(onLoad, data)); 4315 setAttribute$1(img, "src", getAttribute(img, SRC_DATA_ATTRIBUTE)); 4316 setAttribute$1(img, "srcset", getAttribute(img, SRCSET_DATA_ATTRIBUTE)); 4317 removeAttribute$1(img, SRC_DATA_ATTRIBUTE); 4318 removeAttribute$1(img, SRCSET_DATA_ATTRIBUTE); 4319 } 4320 4321 function onLoad(data, e) { 4322 var img = data[0], 4323 Slide = data[1]; 4324 removeClass(Slide.slide, CLASS_LOADING); 4325 4326 if (e.type !== "error") { 4327 remove(data[2]); 4328 display(img, ""); 4329 emit(EVENT_LAZYLOAD_LOADED, img, Slide); 4330 emit(EVENT_RESIZE); 4331 } 4332 4333 isSequential && loadNext(); 4334 } 4335 4336 function loadNext() { 4337 entries.length && load(entries.shift()); 4338 } 4339 4340 return { 4341 mount: mount, 4342 destroy: apply$2(empty$1, entries), 4343 check: check 4344 }; 4345} 4346 4347function Pagination(Splide2, Components2, options) { 4348 var event = EventInterface$1(Splide2); 4349 var on = event.on, 4350 emit = event.emit, 4351 bind = event.bind; 4352 var Slides = Components2.Slides, 4353 Elements = Components2.Elements, 4354 Controller = Components2.Controller; 4355 var hasFocus = Controller.hasFocus, 4356 getIndex = Controller.getIndex, 4357 go = Controller.go; 4358 var resolve = Components2.Direction.resolve; 4359 var placeholder = Elements.pagination; 4360 var items = []; 4361 var list; 4362 var paginationClasses; 4363 4364 function mount() { 4365 destroy(); 4366 on([EVENT_UPDATED$1, EVENT_REFRESH, EVENT_END_INDEX_CHANGED], mount); 4367 var enabled = options.pagination; 4368 placeholder && display(placeholder, enabled ? "" : "none"); 4369 4370 if (enabled) { 4371 on([EVENT_MOVE$1, EVENT_SCROLL$1, EVENT_SCROLLED$1], update); 4372 createPagination(); 4373 update(); 4374 emit(EVENT_PAGINATION_MOUNTED, { 4375 list: list, 4376 items: items 4377 }, getAt(Splide2.index)); 4378 } 4379 } 4380 4381 function destroy() { 4382 if (list) { 4383 remove(placeholder ? slice$2(list.children) : list); 4384 removeClass(list, paginationClasses); 4385 empty$1(items); 4386 list = null; 4387 } 4388 4389 event.destroy(); 4390 } 4391 4392 function createPagination() { 4393 var length = Splide2.length; 4394 var classes = options.classes, 4395 i18n = options.i18n, 4396 perPage = options.perPage; 4397 var max = hasFocus() ? Controller.getEnd() + 1 : ceil(length / perPage); 4398 list = placeholder || create("ul", classes.pagination, Elements.track.parentElement); 4399 addClass(list, paginationClasses = CLASS_PAGINATION + "--" + getDirection()); 4400 setAttribute$1(list, ROLE, "tablist"); 4401 setAttribute$1(list, ARIA_LABEL, i18n.select); 4402 setAttribute$1(list, ARIA_ORIENTATION, getDirection() === TTB ? "vertical" : ""); 4403 4404 for (var i = 0; i < max; i++) { 4405 var li = create("li", null, list); 4406 var button = create("button", { 4407 class: classes.page, 4408 type: "button" 4409 }, li); 4410 var controls = Slides.getIn(i).map(function (Slide) { 4411 return Slide.slide.id; 4412 }); 4413 var text = !hasFocus() && perPage > 1 ? i18n.pageX : i18n.slideX; 4414 bind(button, "click", apply$2(onClick, i)); 4415 4416 if (options.paginationKeyboard) { 4417 bind(button, "keydown", apply$2(onKeydown, i)); 4418 } 4419 4420 setAttribute$1(li, ROLE, "presentation"); 4421 setAttribute$1(button, ROLE, "tab"); 4422 setAttribute$1(button, ARIA_CONTROLS, controls.join(" ")); 4423 setAttribute$1(button, ARIA_LABEL, format(text, i + 1)); 4424 setAttribute$1(button, TAB_INDEX, -1); 4425 items.push({ 4426 li: li, 4427 button: button, 4428 page: i 4429 }); 4430 } 4431 } 4432 4433 function onClick(page) { 4434 go(">" + page, true); 4435 } 4436 4437 function onKeydown(page, e) { 4438 var length = items.length; 4439 var key = normalizeKey(e); 4440 var dir = getDirection(); 4441 var nextPage = -1; 4442 4443 if (key === resolve(ARROW_RIGHT, false, dir)) { 4444 nextPage = ++page % length; 4445 } else if (key === resolve(ARROW_LEFT, false, dir)) { 4446 nextPage = (--page + length) % length; 4447 } else if (key === "Home") { 4448 nextPage = 0; 4449 } else if (key === "End") { 4450 nextPage = length - 1; 4451 } 4452 4453 var item = items[nextPage]; 4454 4455 if (item) { 4456 focus(item.button); 4457 go(">" + nextPage); 4458 prevent(e, true); 4459 } 4460 } 4461 4462 function getDirection() { 4463 return options.paginationDirection || options.direction; 4464 } 4465 4466 function getAt(index) { 4467 return items[Controller.toPage(index)]; 4468 } 4469 4470 function update() { 4471 var prev = getAt(getIndex(true)); 4472 var curr = getAt(getIndex()); 4473 4474 if (prev) { 4475 var button = prev.button; 4476 removeClass(button, CLASS_ACTIVE$1); 4477 removeAttribute$1(button, ARIA_SELECTED); 4478 setAttribute$1(button, TAB_INDEX, -1); 4479 } 4480 4481 if (curr) { 4482 var _button = curr.button; 4483 addClass(_button, CLASS_ACTIVE$1); 4484 setAttribute$1(_button, ARIA_SELECTED, true); 4485 setAttribute$1(_button, TAB_INDEX, ""); 4486 } 4487 4488 emit(EVENT_PAGINATION_UPDATED, { 4489 list: list, 4490 items: items 4491 }, prev, curr); 4492 } 4493 4494 return { 4495 items: items, 4496 mount: mount, 4497 destroy: destroy, 4498 getAt: getAt, 4499 update: update 4500 }; 4501} 4502 4503var TRIGGER_KEYS = [" ", "Enter"]; 4504 4505function Sync(Splide2, Components2, options) { 4506 var isNavigation = options.isNavigation, 4507 slideFocus = options.slideFocus; 4508 var events = []; 4509 4510 function mount() { 4511 Splide2.splides.forEach(function (target) { 4512 if (!target.isParent) { 4513 sync(Splide2, target.splide); 4514 sync(target.splide, Splide2); 4515 } 4516 }); 4517 4518 if (isNavigation) { 4519 navigate(); 4520 } 4521 } 4522 4523 function destroy() { 4524 events.forEach(function (event) { 4525 event.destroy(); 4526 }); 4527 empty$1(events); 4528 } 4529 4530 function remount() { 4531 destroy(); 4532 mount(); 4533 } 4534 4535 function sync(splide, target) { 4536 var event = EventInterface$1(splide); 4537 event.on(EVENT_MOVE$1, function (index, prev, dest) { 4538 target.go(target.is(LOOP) ? dest : index); 4539 }); 4540 events.push(event); 4541 } 4542 4543 function navigate() { 4544 var event = EventInterface$1(Splide2); 4545 var on = event.on; 4546 on(EVENT_CLICK, onClick); 4547 on(EVENT_SLIDE_KEYDOWN, onKeydown); 4548 on([EVENT_MOUNTED, EVENT_UPDATED$1], update); 4549 events.push(event); 4550 event.emit(EVENT_NAVIGATION_MOUNTED, Splide2.splides); 4551 } 4552 4553 function update() { 4554 setAttribute$1(Components2.Elements.list, ARIA_ORIENTATION, options.direction === TTB ? "vertical" : ""); 4555 } 4556 4557 function onClick(Slide) { 4558 Splide2.go(Slide.index); 4559 } 4560 4561 function onKeydown(Slide, e) { 4562 if (includes(TRIGGER_KEYS, normalizeKey(e))) { 4563 onClick(Slide); 4564 prevent(e); 4565 } 4566 } 4567 4568 return { 4569 setup: apply$2(Components2.Media.set, { 4570 slideFocus: isUndefined$1(slideFocus) ? isNavigation : slideFocus 4571 }, true), 4572 mount: mount, 4573 destroy: destroy, 4574 remount: remount 4575 }; 4576} 4577 4578function Wheel(Splide2, Components2, options) { 4579 var _EventInterface12 = EventInterface$1(Splide2), 4580 bind = _EventInterface12.bind; 4581 4582 var lastTime = 0; 4583 4584 function mount() { 4585 if (options.wheel) { 4586 bind(Components2.Elements.track, "wheel", onWheel, SCROLL_LISTENER_OPTIONS); 4587 } 4588 } 4589 4590 function onWheel(e) { 4591 if (e.cancelable) { 4592 var deltaY = e.deltaY; 4593 var backwards = deltaY < 0; 4594 var timeStamp = timeOf(e); 4595 4596 var _min = options.wheelMinThreshold || 0; 4597 4598 var sleep = options.wheelSleep || 0; 4599 4600 if (abs(deltaY) > _min && timeStamp - lastTime > sleep) { 4601 Splide2.go(backwards ? "<" : ">"); 4602 lastTime = timeStamp; 4603 } 4604 4605 shouldPrevent(backwards) && prevent(e); 4606 } 4607 } 4608 4609 function shouldPrevent(backwards) { 4610 return !options.releaseWheel || Splide2.state.is(MOVING) || Components2.Controller.getAdjacent(backwards) !== -1; 4611 } 4612 4613 return { 4614 mount: mount 4615 }; 4616} 4617 4618var SR_REMOVAL_DELAY = 90; 4619 4620function Live(Splide2, Components2, options) { 4621 var _EventInterface13 = EventInterface$1(Splide2), 4622 on = _EventInterface13.on; 4623 4624 var track = Components2.Elements.track; 4625 var enabled = options.live && !options.isNavigation; 4626 var sr = create("span", CLASS_SR); 4627 var interval = RequestInterval$1(SR_REMOVAL_DELAY, apply$2(toggle, false)); 4628 4629 function mount() { 4630 if (enabled) { 4631 disable(!Components2.Autoplay.isPaused()); 4632 setAttribute$1(track, ARIA_ATOMIC, true); 4633 sr.textContent = "\u2026"; 4634 on(EVENT_AUTOPLAY_PLAY, apply$2(disable, true)); 4635 on(EVENT_AUTOPLAY_PAUSE, apply$2(disable, false)); 4636 on([EVENT_MOVED$1, EVENT_SCROLLED$1], apply$2(toggle, true)); 4637 } 4638 } 4639 4640 function toggle(active) { 4641 setAttribute$1(track, ARIA_BUSY, active); 4642 4643 if (active) { 4644 append(track, sr); 4645 interval.start(); 4646 } else { 4647 remove(sr); 4648 interval.cancel(); 4649 } 4650 } 4651 4652 function destroy() { 4653 removeAttribute$1(track, [ARIA_LIVE, ARIA_ATOMIC, ARIA_BUSY]); 4654 remove(sr); 4655 } 4656 4657 function disable(disabled) { 4658 if (enabled) { 4659 setAttribute$1(track, ARIA_LIVE, disabled ? "off" : "polite"); 4660 } 4661 } 4662 4663 return { 4664 mount: mount, 4665 disable: disable, 4666 destroy: destroy 4667 }; 4668} 4669 4670var ComponentConstructors = /*#__PURE__*/Object.freeze({ 4671 __proto__: null, 4672 Media: Media, 4673 Direction: Direction, 4674 Elements: Elements, 4675 Slides: Slides, 4676 Layout: Layout, 4677 Clones: Clones, 4678 Move: Move, 4679 Controller: Controller, 4680 Arrows: Arrows, 4681 Autoplay: Autoplay, 4682 Cover: Cover, 4683 Scroll: Scroll, 4684 Drag: Drag, 4685 Keyboard: Keyboard, 4686 LazyLoad: LazyLoad, 4687 Pagination: Pagination, 4688 Sync: Sync, 4689 Wheel: Wheel, 4690 Live: Live 4691}); 4692var I18N$1 = { 4693 prev: "Previous slide", 4694 next: "Next slide", 4695 first: "Go to first slide", 4696 last: "Go to last slide", 4697 slideX: "Go to slide %s", 4698 pageX: "Go to page %s", 4699 play: "Start autoplay", 4700 pause: "Pause autoplay", 4701 carousel: "carousel", 4702 slide: "slide", 4703 select: "Select a slide to show", 4704 slideLabel: "%s of %s" 4705}; 4706var DEFAULTS$1 = { 4707 type: "slide", 4708 role: "region", 4709 speed: 400, 4710 perPage: 1, 4711 cloneStatus: true, 4712 arrows: true, 4713 pagination: true, 4714 paginationKeyboard: true, 4715 interval: 5e3, 4716 pauseOnHover: true, 4717 pauseOnFocus: true, 4718 resetProgress: true, 4719 easing: "cubic-bezier(0.25, 1, 0.5, 1)", 4720 drag: true, 4721 direction: "ltr", 4722 trimSpace: true, 4723 focusableNodes: "a, button, textarea, input, select, iframe", 4724 live: true, 4725 classes: CLASSES, 4726 i18n: I18N$1, 4727 reducedMotion: { 4728 speed: 0, 4729 rewindSpeed: 0, 4730 autoplay: "pause" 4731 } 4732}; 4733 4734function Fade(Splide2, Components2, options) { 4735 var Slides = Components2.Slides; 4736 4737 function mount() { 4738 EventInterface$1(Splide2).on([EVENT_MOUNTED, EVENT_REFRESH], init); 4739 } 4740 4741 function init() { 4742 Slides.forEach(function (Slide) { 4743 Slide.style("transform", "translateX(-" + 100 * Slide.index + "%)"); 4744 }); 4745 } 4746 4747 function start(index, done) { 4748 Slides.style("transition", "opacity " + options.speed + "ms " + options.easing); 4749 nextTick(done); 4750 } 4751 4752 return { 4753 mount: mount, 4754 start: start, 4755 cancel: noop 4756 }; 4757} 4758 4759function Slide(Splide2, Components2, options) { 4760 var Move = Components2.Move, 4761 Controller = Components2.Controller, 4762 Scroll = Components2.Scroll; 4763 var list = Components2.Elements.list; 4764 var transition = apply$2(style, list, "transition"); 4765 var endCallback; 4766 4767 function mount() { 4768 EventInterface$1(Splide2).bind(list, "transitionend", function (e) { 4769 if (e.target === list && endCallback) { 4770 cancel(); 4771 endCallback(); 4772 } 4773 }); 4774 } 4775 4776 function start(index, done) { 4777 var destination = Move.toPosition(index, true); 4778 var position = Move.getPosition(); 4779 var speed = getSpeed(index); 4780 4781 if (abs(destination - position) >= 1 && speed >= 1) { 4782 if (options.useScroll) { 4783 Scroll.scroll(destination, speed, false, done); 4784 } else { 4785 transition("transform " + speed + "ms " + options.easing); 4786 Move.translate(destination, true); 4787 endCallback = done; 4788 } 4789 } else { 4790 Move.jump(index); 4791 done(); 4792 } 4793 } 4794 4795 function cancel() { 4796 transition(""); 4797 Scroll.cancel(); 4798 } 4799 4800 function getSpeed(index) { 4801 var rewindSpeed = options.rewindSpeed; 4802 4803 if (Splide2.is(SLIDE$1) && rewindSpeed) { 4804 var prev = Controller.getIndex(true); 4805 var end = Controller.getEnd(); 4806 4807 if (prev === 0 && index >= end || prev >= end && index === 0) { 4808 return rewindSpeed; 4809 } 4810 } 4811 4812 return options.speed; 4813 } 4814 4815 return { 4816 mount: mount, 4817 start: start, 4818 cancel: cancel 4819 }; 4820} 4821 4822var _Splide = /*#__PURE__*/function () { 4823 function _Splide(target, options) { 4824 this.event = EventInterface$1(); 4825 this.Components = {}; 4826 this.state = State(CREATED); 4827 this.splides = []; 4828 this._o = {}; 4829 this._E = {}; 4830 var root = isString(target) ? query(document, target) : target; 4831 assert(root, root + " is invalid."); 4832 this.root = root; 4833 options = merge({ 4834 label: getAttribute(root, ARIA_LABEL) || "", 4835 labelledby: getAttribute(root, ARIA_LABELLEDBY) || "" 4836 }, DEFAULTS$1, _Splide.defaults, options || {}); 4837 4838 try { 4839 merge(options, JSON.parse(getAttribute(root, DATA_ATTRIBUTE))); 4840 } catch (e) { 4841 assert(false, "Invalid JSON"); 4842 } 4843 4844 this._o = Object.create(merge({}, options)); 4845 } 4846 4847 var _proto = _Splide.prototype; 4848 4849 _proto.mount = function mount(Extensions, Transition) { 4850 var _this = this; 4851 4852 var state = this.state, 4853 Components2 = this.Components; 4854 assert(state.is([CREATED, DESTROYED]), "Already mounted!"); 4855 state.set(CREATED); 4856 this._C = Components2; 4857 this._T = Transition || this._T || (this.is(FADE$1) ? Fade : Slide); 4858 this._E = Extensions || this._E; 4859 var Constructors = assign$2({}, ComponentConstructors, this._E, { 4860 Transition: this._T 4861 }); 4862 forOwn$2(Constructors, function (Component, key) { 4863 var component = Component(_this, Components2, _this._o); 4864 Components2[key] = component; 4865 component.setup && component.setup(); 4866 }); 4867 forOwn$2(Components2, function (component) { 4868 component.mount && component.mount(); 4869 }); 4870 this.emit(EVENT_MOUNTED); 4871 addClass(this.root, CLASS_INITIALIZED); 4872 state.set(IDLE); 4873 this.emit(EVENT_READY); 4874 return this; 4875 }; 4876 4877 _proto.sync = function sync(splide) { 4878 this.splides.push({ 4879 splide: splide 4880 }); 4881 splide.splides.push({ 4882 splide: this, 4883 isParent: true 4884 }); 4885 4886 if (this.state.is(IDLE)) { 4887 this._C.Sync.remount(); 4888 4889 splide.Components.Sync.remount(); 4890 } 4891 4892 return this; 4893 }; 4894 4895 _proto.go = function go(control) { 4896 this._C.Controller.go(control); 4897 4898 return this; 4899 }; 4900 4901 _proto.on = function on(events, callback) { 4902 this.event.on(events, callback); 4903 return this; 4904 }; 4905 4906 _proto.off = function off(events) { 4907 this.event.off(events); 4908 return this; 4909 }; 4910 4911 _proto.emit = function emit(event) { 4912 var _this$event; 4913 4914 (_this$event = this.event).emit.apply(_this$event, [event].concat(slice$2(arguments, 1))); 4915 4916 return this; 4917 }; 4918 4919 _proto.add = function add(slides, index) { 4920 this._C.Slides.add(slides, index); 4921 4922 return this; 4923 }; 4924 4925 _proto.remove = function remove(matcher) { 4926 this._C.Slides.remove(matcher); 4927 4928 return this; 4929 }; 4930 4931 _proto.is = function is(type) { 4932 return this._o.type === type; 4933 }; 4934 4935 _proto.refresh = function refresh() { 4936 this.emit(EVENT_REFRESH); 4937 return this; 4938 }; 4939 4940 _proto.destroy = function destroy(completely) { 4941 if (completely === void 0) { 4942 completely = true; 4943 } 4944 4945 var event = this.event, 4946 state = this.state; 4947 4948 if (state.is(CREATED)) { 4949 EventInterface$1(this).on(EVENT_READY, this.destroy.bind(this, completely)); 4950 } else { 4951 forOwn$2(this._C, function (component) { 4952 component.destroy && component.destroy(completely); 4953 }, true); 4954 event.emit(EVENT_DESTROY$1); 4955 event.destroy(); 4956 completely && empty$1(this.splides); 4957 state.set(DESTROYED); 4958 } 4959 4960 return this; 4961 }; 4962 4963 _createClass(_Splide, [{ 4964 key: "options", 4965 get: function get() { 4966 return this._o; 4967 }, 4968 set: function set(options) { 4969 this._C.Media.set(options, true, true); 4970 } 4971 }, { 4972 key: "length", 4973 get: function get() { 4974 return this._C.Slides.getLength(true); 4975 } 4976 }, { 4977 key: "index", 4978 get: function get() { 4979 return this._C.Controller.getIndex(); 4980 } 4981 }]); 4982 4983 return _Splide; 4984}(); 4985 4986var Splide = _Splide; 4987Splide.defaults = {}; 4988Splide.STATES = STATES; 4989 4990class SplideThumbnailsSlider { 4991 constructor(container) { 4992 if (!container) { 4993 return; 4994 } 4995 4996 this.ui = { 4997 container, 4998 splideMainSliderSelector: container.querySelector(".splide--main"), 4999 splideThumbnailSliderSelector: container.querySelector(
5000 ".splide--thumbnails" 5001 ), 5002 }; 5003 5004 if (this.ui.container) { 5005 this.initConfig(); 5006 this.initEvents(); 5007 } 5008 } 5009 5010 initConfig() { 5011 this.config = { 5012 splideMainSlider: { 5013 rewind: true, 5014 type: "loop", 5015 arrows: false, 5016 cover: true, 5017 heightRatio: 1, 5018 pagination: false, 5019 }, 5020 splideThumbnailSlider: { 5021 rewind: true, 5022 fixedWidth: 96, 5023 fixedHeight: 96, 5024 gap: 11, 5025 isNavigation: true, 5026 cover: true, 5027 pagination: false, 5028 breakpoints: { 5029 768: { 5030 fixedWidth: 77, 5031 fixedHeight: 77, 5032 gap: 12, 5033 }, 5034 }, 5035 }, 5036 }; 5037 } 5038 5039 initEvents() { 5040 const splideMainSlider = new Splide( 5041 this.ui.splideMainSliderSelector, 5042 this.config.splideMainSlider 5043 ); 5044 const splideThumbnailSlider = new Splide( 5045 this.ui.splideThumbnailSliderSelector, 5046 this.config.splideThumbnailSlider 5047 ).mount(); 5048 5049 splideMainSlider.sync(splideThumbnailSlider).mount(); 5050 5051 // Disable video on slide change 5052 splideMainSlider.on("active", function () { 5053 document.querySelectorAll("iframe").forEach((v) => { 5054 v.contentWindow.postMessage( 5055 '{"event":"command","func":"pauseVideo","args":""}', 5056 "*" 5057 ); 5058 }); 5059 document.querySelectorAll("video").forEach((v) => { 5060 v.pause(); 5061 }); 5062 }); 5063 } 5064} 5065 5066class SplideBannerSlider { 5067 constructor(container) { 5068 if (!container) { 5069 return; 5070 } 5071 5072 this.ui = { 5073 container, 5074 splideBannerSliderSelector: container.querySelector(".splide--banner"), 5075 }; 5076 5077 if (this.ui.container) { 5078 this.initConfig(); 5079 this.initEvents(); 5080 } 5081 } 5082 5083 initConfig() { 5084 this.config = { 5085 splideBannerSlider: { 5086 // if > 1 slide then loop 5087 rewind: this.ui.splideBannerSliderSelector.querySelectorAll('.splide__slide').length > 1 ? true : false, // 'true' or 'false 5088 type: this.ui.splideBannerSliderSelector.querySelectorAll('.splide__slide').length > 1 ? 'loop' : 'slide', // 'true' or 'false 5089 autoplay: this.ui.splideBannerSliderSelector.querySelectorAll('.splide__slide').length > 1, // Uncomment to have the progressbar & comment to increase performance 5090 pauseOnHover: false, 5091 // cover: true, 5092 // fixedHeight: 400, 5093 pagination: false, 5094 drag: this.ui.splideBannerSliderSelector.querySelectorAll('.splide__slide').length > 1, // 'true' or 'false 5095 // hide arrows if there is only one slide 5096 arrows: this.ui.splideBannerSliderSelector.querySelectorAll(".splide__slide").length > 1, 5097 breakpoints: { 5098 768: { 5099 fixedHeight: 460, 5100 }, 5101 }, 5102 }, 5103 }; 5104 } 5105 5106 initEvents() { 5107 new Splide( 5108 this.ui.splideBannerSliderSelector, 5109 this.config.splideBannerSlider 5110 ).mount(); 5111 } 5112} 5113 5114/*! 5115 * @splidejs/splide-extension-auto-scroll 5116 * Version : 0.4.2 5117 * License : MIT 5118 * Copyright: 2022 Naotoshi Fujita 5119 */ 5120function empty(array) { 5121 array.length = 0; 5122} 5123 5124function slice$1(arrayLike, start, end) { 5125 return Array.prototype.slice.call(arrayLike, start, end); 5126} 5127 5128function apply$1(func) { 5129 return func.bind.apply(func, [null].concat(slice$1(arguments, 1))); 5130} 5131 5132function raf(func) { 5133 return requestAnimationFrame(func); 5134} 5135 5136function typeOf$1(type, subject) { 5137 return typeof subject === type; 5138} 5139 5140var isArray$1 = Array.isArray; 5141apply$1(typeOf$1, "function"); 5142apply$1(typeOf$1, "string");
vendor: 8,293 bytes, lines 5143-5506
5143apply$1(typeOf$1, "undefined"); 5144 5145function toArray$1(value) { 5146 return isArray$1(value) ? value : [value]; 5147} 5148 5149function forEach$1(values, iteratee) { 5150 toArray$1(values).forEach(iteratee); 5151} 5152 5153var ownKeys$1 = Object.keys; 5154 5155function forOwn$1(object, iteratee, right) { 5156 if (object) { 5157 var keys = ownKeys$1(object); 5158 keys = keys; 5159 5160 for (var i = 0; i < keys.length; i++) { 5161 var key = keys[i]; 5162 5163 if (key !== "__proto__") { 5164 if (iteratee(object[key], key) === false) { 5165 break; 5166 } 5167 } 5168 } 5169 } 5170 5171 return object; 5172} 5173 5174function assign$1(object) { 5175 slice$1(arguments, 1).forEach(function (source) { 5176 forOwn$1(source, function (value, key) { 5177 object[key] = source[key]; 5178 }); 5179 }); 5180 return object; 5181} 5182 5183var min$1 = Math.min; 5184 5185function EventBinder() { 5186 var listeners = []; 5187 5188 function bind(targets, events, callback, options) { 5189 forEachEvent(targets, events, function (target, event, namespace) { 5190 var isEventTarget = ("addEventListener" in target); 5191 var remover = isEventTarget ? target.removeEventListener.bind(target, event, callback, options) : target["removeListener"].bind(target, callback); 5192 isEventTarget ? target.addEventListener(event, callback, options) : target["addListener"](callback); 5193 listeners.push([target, event, namespace, callback, remover]); 5194 }); 5195 } 5196 5197 function unbind(targets, events, callback) { 5198 forEachEvent(targets, events, function (target, event, namespace) { 5199 listeners = listeners.filter(function (listener) { 5200 if (listener[0] === target && listener[1] === event && listener[2] === namespace && (!callback || listener[3] === callback)) { 5201 listener[4](); 5202 return false; 5203 } 5204 5205 return true; 5206 }); 5207 }); 5208 } 5209 5210 function dispatch(target, type, detail) { 5211 var e; 5212 var bubbles = true; 5213 5214 if (typeof CustomEvent === "function") { 5215 e = new CustomEvent(type, { 5216 bubbles: bubbles, 5217 detail: detail 5218 }); 5219 } else { 5220 e = document.createEvent("CustomEvent"); 5221 e.initCustomEvent(type, bubbles, false, detail); 5222 } 5223 5224 target.dispatchEvent(e); 5225 return e; 5226 } 5227 5228 function forEachEvent(targets, events, iteratee) { 5229 forEach$1(targets, function (target) { 5230 target && forEach$1(events, function (events2) { 5231 events2.split(" ").forEach(function (eventNS) { 5232 var fragment = eventNS.split("."); 5233 iteratee(target, fragment[0], fragment[1]); 5234 }); 5235 }); 5236 }); 5237 } 5238 5239 function destroy() { 5240 listeners.forEach(function (data) { 5241 data[4](); 5242 }); 5243 empty(listeners); 5244 } 5245 5246 return { 5247 bind: bind, 5248 unbind: unbind, 5249 dispatch: dispatch, 5250 destroy: destroy 5251 }; 5252} 5253var EVENT_MOVE = "move"; 5254var EVENT_MOVED = "moved"; 5255var EVENT_UPDATED = "updated"; 5256var EVENT_DRAG = "drag"; 5257var EVENT_SCROLL = "scroll"; 5258var EVENT_SCROLLED = "scrolled"; 5259var EVENT_DESTROY = "destroy"; 5260 5261function EventInterface(Splide2) { 5262 var bus = Splide2 ? Splide2.event.bus : document.createDocumentFragment(); 5263 var binder = EventBinder(); 5264 5265 function on(events, callback) { 5266 binder.bind(bus, toArray$1(events).join(" "), function (e) { 5267 callback.apply(callback, isArray$1(e.detail) ? e.detail : []); 5268 }); 5269 } 5270 5271 function emit(event) { 5272 binder.dispatch(bus, event, slice$1(arguments, 1)); 5273 } 5274 5275 if (Splide2) { 5276 Splide2.event.on(EVENT_DESTROY, binder.destroy); 5277 } 5278 5279 return assign$1(binder, { 5280 bus: bus, 5281 on: on, 5282 off: apply$1(binder.unbind, bus), 5283 emit: emit 5284 }); 5285} 5286 5287function RequestInterval(interval, onInterval, onUpdate, limit) { 5288 var now = Date.now; 5289 var startTime; 5290 var rate = 0; 5291 var id; 5292 var paused = true; 5293 5294 function update() { 5295 if (!paused) { 5296 rate = interval ? min$1((now() - startTime) / interval, 1) : 1; 5297 5298 if (rate >= 1) { 5299 onInterval(); 5300 startTime = now(); 5301 } 5302 5303 raf(update); 5304 } 5305 } 5306 5307 function start(resume) { 5308 !resume && cancel(); 5309 startTime = now() - (resume ? rate * interval : 0); 5310 paused = false; 5311 raf(update); 5312 } 5313 5314 function pause() { 5315 paused = true; 5316 } 5317 5318 function rewind() { 5319 startTime = now(); 5320 rate = 0; 5321 } 5322 5323 function cancel() { 5324 id && cancelAnimationFrame(id); 5325 rate = 0; 5326 id = 0; 5327 paused = true; 5328 } 5329 5330 function set(time) { 5331 interval = time; 5332 } 5333 5334 function isPaused() { 5335 return paused; 5336 } 5337 5338 return { 5339 start: start, 5340 rewind: rewind, 5341 pause: pause, 5342 cancel: cancel, 5343 set: set, 5344 isPaused: isPaused 5345 }; 5346} 5347var CLASS_ACTIVE = "is-active"; 5348 5349var SLIDE = "slide"; 5350var FADE = "fade"; 5351 5352function slice(arrayLike, start, end) { 5353 return Array.prototype.slice.call(arrayLike, start, end); 5354} 5355 5356function apply(func) { 5357 return func.bind(null, ...slice(arguments, 1)); 5358} 5359 5360function typeOf(type, subject) { 5361 return typeof subject === type; 5362} 5363function isObject(subject) { 5364 return !isNull(subject) && typeOf("object", subject); 5365} 5366const isArray = Array.isArray; 5367apply(typeOf, "function"); 5368apply(typeOf, "string"); 5369const isUndefined = apply(typeOf, "undefined"); 5370function isNull(subject) { 5371 return subject === null; 5372} 5373 5374function toArray(value) { 5375 return isArray(value) ? value : [value]; 5376} 5377 5378function forEach(values, iteratee) { 5379 toArray(values).forEach(iteratee); 5380} 5381 5382function toggleClass(elm, classes, add) { 5383 if (elm) { 5384 forEach(classes, (name) => { 5385 if (name) { 5386 elm.classList[add ? "add" : "remove"](name); 5387 } 5388 }); 5389 } 5390} 5391 5392const ownKeys = Object.keys; 5393 5394function forOwn(object, iteratee, right) { 5395 if (object) { 5396 let keys = ownKeys(object); 5397 keys = keys; 5398 for (let i = 0; i < keys.length; i++) { 5399 const key = keys[i]; 5400 if (key !== "__proto__") { 5401 if (iteratee(object[key], key) === false) { 5402 break; 5403 } 5404 } 5405 } 5406 } 5407 return object; 5408} 5409 5410function assign(object) { 5411 slice(arguments, 1).forEach((source) => { 5412 forOwn(source, (value, key) => { 5413 object[key] = source[key]; 5414 }); 5415 }); 5416 return object; 5417} 5418 5419function removeAttribute(elms, attrs) { 5420 forEach(elms, (elm) => { 5421 forEach(attrs, (attr) => { 5422 elm && elm.removeAttribute(attr); 5423 }); 5424 }); 5425} 5426 5427function setAttribute(elms, attrs, value) { 5428 if (isObject(attrs)) { 5429 forOwn(attrs, (value2, name) => { 5430 setAttribute(elms, name, value2); 5431 }); 5432 } else { 5433 forEach(elms, (elm) => { 5434 isNull(value) || value === "" ? removeAttribute(elm, attrs) : elm.setAttribute(attrs, String(value)); 5435 }); 5436 } 5437} 5438 5439const { min: min$2, max: max$1} = Math; 5440 5441function clamp(number, x, y) { 5442 const minimum = min$2(x, y); 5443 const maximum = max$1(x, y); 5444 return min$2(max$1(minimum, number), maximum); 5445} 5446 5447const DEFAULTS = { 5448 speed: 1, 5449 autoStart: true, 5450 pauseOnHover: true, 5451 pauseOnFocus: true 5452}; 5453 5454const I18N = { 5455 startScroll: "Start auto scroll", 5456 pauseScroll: "Pause auto scroll" 5457}; 5458 5459function AutoScroll(Splide2, Components2, options) { 5460 const { on, off, bind, unbind } = EventInterface(Splide2); 5461 const { translate, getPosition, toIndex, getLimit, exceededLimit } = Components2.Move; 5462 const { setIndex, getIndex } = Components2.Controller; 5463 const { orient } = Components2.Direction; 5464 const { toggle } = Components2.Elements; 5465 const { Live } = Components2; 5466 const { root } = Splide2; 5467 let autoScrollOptions = {}; 5468 let interval; 5469 let stopped; 5470 let hovered; 5471 let focused; 5472 let busy; 5473 let currPosition; 5474 function setup() { 5475 const { autoScroll } = options; 5476 autoScrollOptions = assign({}, DEFAULTS, isObject(autoScroll) ? autoScroll : {}); 5477 } 5478 function mount() { 5479 if (!Splide2.is(FADE)) { 5480 if (!interval && options.autoScroll !== false) { 5481 interval = RequestInterval(0, move); 5482 listen(); 5483 autoStart(); 5484 } 5485 } 5486 } 5487 function destroy() { 5488 if (interval) { 5489 interval.cancel(); 5490 interval = null; 5491 currPosition = void 0; 5492 off([EVENT_MOVE, EVENT_DRAG, EVENT_SCROLL, EVENT_MOVED, EVENT_SCROLLED]); 5493 unbind(root, "mouseenter mouseleave focusin focusout"); 5494 unbind(toggle, "click"); 5495 } 5496 } 5497 function listen() { 5498 if (autoScrollOptions.pauseOnHover) { 5499 bind(root, "mouseenter mouseleave", (e) => { 5500 hovered = e.type === "mouseenter"; 5501 autoToggle(); 5502 }); 5503 } 5504 if (autoScrollOptions.pauseOnFocus) { 5505 bind(root, "focusin focusout", (e) => { 5506 focused = e.type === "focusin";
vendor: 2,745 bytes, lines 5507-5620
5507 autoToggle(); 5508 }); 5509 } 5510 if (autoScrollOptions.useToggleButton) { 5511 bind(toggle, "click", () => { 5512 stopped ? play() : pause(); 5513 }); 5514 } 5515 on(EVENT_UPDATED, update); 5516 on([EVENT_MOVE, EVENT_DRAG, EVENT_SCROLL], () => { 5517 busy = true; 5518 pause(false); 5519 }); 5520 on([EVENT_MOVED, EVENT_SCROLLED], () => { 5521 busy = false; 5522 autoToggle(); 5523 }); 5524 } 5525 function update() { 5526 const { autoScroll } = options; 5527 if (autoScroll !== false) { 5528 autoScrollOptions = assign({}, autoScrollOptions, isObject(autoScroll) ? autoScroll : {}); 5529 mount(); 5530 } else { 5531 destroy(); 5532 } 5533 if (interval && !isUndefined(currPosition)) { 5534 translate(currPosition); 5535 } 5536 } 5537 function autoStart() { 5538 if (autoScrollOptions.autoStart) { 5539 if (document.readyState === "complete") { 5540 play(); 5541 } else { 5542 bind(window, "load", play); 5543 } 5544 } 5545 } 5546 function play() { 5547 if (isPaused()) { 5548 interval.start(true); 5549 Live.disable(true); 5550 focused = hovered = stopped = false; 5551 updateButton(); 5552 } 5553 } 5554 function pause(stop = true) { 5555 if (!stopped) { 5556 stopped = stop; 5557 updateButton(); 5558 if (!isPaused()) { 5559 interval.pause(); 5560 Live.disable(false); 5561 } 5562 } 5563 } 5564 function autoToggle() { 5565 if (!stopped) { 5566 hovered || focused || busy ? pause(false) : play(); 5567 } 5568 } 5569 function move() { 5570 const position = getPosition(); 5571 const destination = computeDestination(position); 5572 if (position !== destination) { 5573 translate(destination, getIndex() !== 0 || !exceededLimit(true)); 5574 currPosition = getPosition(); 5575 updateIndex(currPosition); 5576 } else { 5577 pause(false); 5578 if (autoScrollOptions.rewind) { 5579 Splide2.go(0); 5580 } 5581 } 5582 } 5583 function computeDestination(position) { 5584 const speed = autoScrollOptions.speed || 1; 5585 position += orient(speed); 5586 if (Splide2.is(SLIDE)) { 5587 position = clamp(position, getLimit(false), getLimit(true)); 5588 } 5589 return position; 5590 } 5591 function updateIndex(position) { 5592 const { length } = Splide2; 5593 const index = (toIndex(position) + length) % length; 5594 if (index !== getIndex()) { 5595 setIndex(index); 5596 Components2.Slides.update(); 5597 Components2.Pagination.update(); 5598 } 5599 } 5600 function updateButton() { 5601 if (toggle) { 5602 const key = stopped ? "startScroll" : "pauseScroll"; 5603 toggleClass(toggle, CLASS_ACTIVE, !stopped); 5604 setAttribute(toggle, "aria-label", options.i18n[key] || I18N[key]); 5605 } 5606 } 5607 function isPaused() { 5608 return !interval || interval.isPaused(); 5609 } 5610 return { 5611 setup, 5612 mount, 5613 destroy, 5614 play, 5615 pause, 5616 isPaused 5617 }; 5618} 5619 5620class SplideBrandsSlider {
5621 constructor(containers) { 5622 if (!containers) { 5623 return; 5624 } 5625 5626 containers.forEach(container => { 5627 const slider = { 5628 container, 5629 splideBrandsSliderSelector: container.querySelector(".splide--brands"), 5630 }; 5631 5632 if (slider.container) { 5633 let config = this.initConfig(); 5634 this.initEvents(slider, config); 5635 } 5636 }); 5637 5638 // this.ui = { 5639 // container, 5640 // splideBrandsSliderSelector: container.querySelector(".splide--brands"), 5641 // }; 5642 5643 // if (this.ui.container) { 5644 // this.initConfig(); 5645 // this.initEvents(); 5646 // } 5647 } 5648 5649 initConfig() { 5650 const config = { 5651 splideBrandsSlider: { 5652 // rewind: true, 5653 type: "loop", 5654 focus: "center", 5655 // autoplay: true, // Uncomment to have the progressbar & comment to increase performance 5656 // pauseOnHover: false, 5657 arrows: false, 5658 // fixedHeight: 150, 5659 perPage: 7, 5660 gap: 30, 5661 pagination: false, 5662 // remove drag 5663 drag: "free", 5664 autoScroll: { 5665 pauseOnHover: true, 5666 pauseOnFocus: false, 5667 speed: 0.8, 5668 }, 5669 breakpoints: { 5670 768: { 5671 perPage: 2, 5672 gap: 20, 5673 }, 5674 }, 5675 }, 5676 }; 5677 5678 return config; 5679 } 5680 5681 initEvents(slider, config) { 5682 new Splide( 5683 slider.splideBrandsSliderSelector, 5684 config.splideBrandsSlider, 5685 ).mount({ AutoScroll }); 5686 5687 // on click 5688 // sliderBrand.on("click", (slide) => { 5689 // const link = slide.slide.getAttribute("data-link"); 5690 // const target = slide.slide.getAttribute("data-target"); 5691 // if (link) { 5692 // window.open(link, target); 5693 // } 5694 // }); 5695 5696 } 5697} 5698 5699// import { forEach } from "lodash"; 5700 5701let SplideHeroSlider$1 = class SplideHeroSlider {
5702 constructor(containers) { 5703 if (!containers) { 5704 return; 5705 } 5706 5707 containers.forEach(container => { 5708 const slider = { 5709 container, 5710 splideHeroSliderSelector: container, 5711 }; 5712 5713 if (slider.container) { 5714 let config = this.initConfig(slider); 5715 this.initEvents(slider, config); 5716 } 5717 }); 5718 5719 // this.ui = { 5720 // container, 5721 // splideHeroSliderSelector: container.querySelector(".splide--hero"), 5722 // }; 5723 5724 // if (this.ui.container) { 5725 // this.initConfig(); 5726 // this.initEvents(); 5727 // } 5728 } 5729 5730 initConfig(slider) { 5731 const duration = slider.splideHeroSliderSelector.getAttribute("data-duration"); 5732 const autoplay = slider.splideHeroSliderSelector.getAttribute("data-autoplay"); 5733 // const hover = this.ui.splideHeroSliderSelector.getAttribute("data-style") == 'hover' ? true : false; 5734 const config = { 5735 splideHeroSlider: { 5736 rewind: true, 5737 type: "loop", 5738 autoplay: autoplay == "1" ? true : false, 5739 pauseOnHover: false, 5740 // duration 5741 interval: duration, 5742 // cover: true, 5743 // fixedHeight: 450, 5744 pagination: false, 5745 // lazy loading 5746 lazyLoad: "nearby", 5747 breakpoints: { 5748 768: { 5749 // remove arrows 5750 arrows: false, 5751 }, 5752 // 1024: { 5753 // fixedHeight: false, 5754 // height: false, 5755 // }, 5756 // 1339: { 5757 // fixedHeight: 400, 5758 // height: 400, 5759 // }, 5760 // 1440: { 5761 // fixedHeight: 450, 5762 // height: 450, 5763 // }, 5764 // 1919: { 5765 // fixedHeight: 500, 5766 // height: 500, 5767 // }, 5768 // 1920: { 5769 // fixedHeight: 600, 5770 // height: 600, 5771 // }, 5772 // 2560: { 5773 // fixedHeight: 700, 5774 // height: 700, 5775 // }, 5776 }, 5777 // lazyLoad: false, 5778 }, 5779 }; 5780 5781 return config; 5782 } 5783 5784 initEvents(slider, config) { 5785 new Splide( 5786 slider.splideHeroSliderSelector, 5787 config.splideHeroSlider 5788 ).mount(); 5789 } 5790}; 5791 5792// import { forEach } from "lodash"; 5793 5794class SplideHeroSlider {
5795 constructor(containers) { 5796 if (!containers) { 5797 return; 5798 } 5799 5800 containers.forEach(container => { 5801 const slider = { 5802 container, 5803 splideHeroSliderSelector: container.querySelector(".splide--hero-image"), 5804 }; 5805 5806 if (slider.container) { 5807 let config = this.initConfig(slider); 5808 this.initEvents(slider, config); 5809 } 5810 }); 5811 } 5812 5813 initConfig(slider) { 5814 const duration = slider.splideHeroSliderSelector.getAttribute("data-duration"); 5815 const autoplay = slider.splideHeroSliderSelector.getAttribute("data-autoplay"); 5816 // const hover = this.ui.splideHeroSliderSelector.getAttribute("data-style") == 'hover' ? true : false; 5817 const config = { 5818 splideHeroSlider: { 5819 rewind: true, 5820 type: "loop", 5821 autoplay: autoplay == "1" ? true : false, 5822 pauseOnHover: false, 5823 // duration 5824 interval: duration, 5825 // auto height 5826 autoHeight: true, 5827 // cover: true, 5828 // fixedHeight: 450, 5829 pagination: false, 5830 // lazy loading 5831 lazyLoad: "nearby", 5832 // breakpoints: { 5833 // 768: { 5834 // fixedHeight: false, 5835 // height: false, 5836 // }, 5837 // 1024: { 5838 // fixedHeight: false, 5839 // height: false, 5840 // }, 5841 // 1339: { 5842 // fixedHeight: 400, 5843 // height: 400, 5844 // }, 5845 // 1440: { 5846 // fixedHeight: 450, 5847 // height: 450, 5848 // }, 5849 // 1919: { 5850 // fixedHeight: 500, 5851 // height: 500, 5852 // }, 5853 // 1920: { 5854 // fixedHeight: 600, 5855 // height: 600, 5856 // }, 5857 // 2560: { 5858 // fixedHeight: 700, 5859 // height: 700, 5860 // }, 5861 // }, 5862 // lazyLoad: false, 5863 }, 5864 }; 5865 5866 return config; 5867 } 5868 5869 initEvents(slider, config) { 5870 new Splide( 5871 slider.splideHeroSliderSelector, 5872 config.splideHeroSlider 5873 ).mount(); 5874 } 5875} 5876 5877class SplideVisible4Slider { 5878 constructor(container) { 5879 if (!container) { 5880 return; 5881 } 5882 5883 this.ui = { 5884 container, 5885 splideVisible4SliderSelector: container.querySelector( 5886 ".splide--visible-4" 5887 ), 5888 }; 5889 5890 if (this.ui.container) { 5891 this.initConfig(); 5892 this.initEvents(); 5893 } 5894 } 5895 5896 initConfig() { 5897 this.config = { 5898 splideVisible4Slider: { 5899 perPage: 4, 5900 // perMove: 1, 5901 gap: 20, 5902 pagination: false, 5903 arrows: true, 5904 breakpoints: { 5905 1024: { 5906 perPage: 3, 5907 }, 5908 5909 960: { 5910 perPage: 2, 5911 }, 5912 640: { 5913 perPage: 1, 5914 }, 5915 }, 5916 }, 5917 }; 5918 } 5919 5920 initEvents() { 5921 new Splide( 5922 this.ui.splideVisible4SliderSelector, 5923 this.config.splideVisible4Slider 5924 ).mount(); 5925 } 5926} 5927 5928var lodash$1 = {exports: {}}; 5929 5930/** 5931 * @license 5932 * Lodash <https://lodash.com/> 5933 * Copyright OpenJS Foundation and other contributors <https://openjsf.org/> 5934 * Released under MIT license <https://lodash.com/license> 5935 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> 5936 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 5937 */ 5938var lodash = lodash$1.exports; 5939 5940var hasRequiredLodash; 5941 5942function requireLodash () { 5943 if (hasRequiredLodash) return lodash$1.exports; 5944 hasRequiredLodash = 1; 5945 (function (module, exports) { 5946(function() { 5947 5948 /** Used as a safe reference for `undefined` in pre-ES5 environments. */ 5949 var undefined$1; 5950 5951 /** Used as the semantic version number. */ 5952 var VERSION = '4.17.21'; 5953 5954 /** Used as the size to enable large array optimizations. */ 5955 var LARGE_ARRAY_SIZE = 200; 5956 5957 /** Error message constants. */ 5958 var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.', 5959 FUNC_ERROR_TEXT = 'Expected a function', 5960 INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable
vendor: 77,787 bytes, lines 5960-8240
5960` option passed into `_.template`'; 5961 5962 /** Used to stand-in for `undefined` hash values. */ 5963 var HASH_UNDEFINED = '__lodash_hash_undefined__'; 5964 5965 /** Used as the maximum memoize cache size. */ 5966 var MAX_MEMOIZE_SIZE = 500; 5967 5968 /** Used as the internal argument placeholder. */ 5969 var PLACEHOLDER = '__lodash_placeholder__'; 5970 5971 /** Used to compose bitmasks for cloning. */ 5972 var CLONE_DEEP_FLAG = 1, 5973 CLONE_FLAT_FLAG = 2, 5974 CLONE_SYMBOLS_FLAG = 4; 5975 5976 /** Used to compose bitmasks for value comparisons. */ 5977 var COMPARE_PARTIAL_FLAG = 1, 5978 COMPARE_UNORDERED_FLAG = 2; 5979 5980 /** Used to compose bitmasks for function metadata. */ 5981 var WRAP_BIND_FLAG = 1, 5982 WRAP_BIND_KEY_FLAG = 2, 5983 WRAP_CURRY_BOUND_FLAG = 4, 5984 WRAP_CURRY_FLAG = 8, 5985 WRAP_CURRY_RIGHT_FLAG = 16, 5986 WRAP_PARTIAL_FLAG = 32, 5987 WRAP_PARTIAL_RIGHT_FLAG = 64, 5988 WRAP_ARY_FLAG = 128, 5989 WRAP_REARG_FLAG = 256, 5990 WRAP_FLIP_FLAG = 512; 5991 5992 /** Used as default options for `_.truncate`. */ 5993 var DEFAULT_TRUNC_LENGTH = 30, 5994 DEFAULT_TRUNC_OMISSION = '...'; 5995 5996 /** Used to detect hot functions by number of calls within a span of milliseconds. */ 5997 var HOT_COUNT = 800, 5998 HOT_SPAN = 16; 5999 6000 /** Used to indicate the type of lazy iteratees. */ 6001 var LAZY_FILTER_FLAG = 1, 6002 LAZY_MAP_FLAG = 2, 6003 LAZY_WHILE_FLAG = 3; 6004 6005 /** Used as references for various `Number` constants. */ 6006 var INFINITY = 1 / 0, 6007 MAX_SAFE_INTEGER = 9007199254740991, 6008 MAX_INTEGER = 1.7976931348623157e+308, 6009 NAN = 0 / 0; 6010 6011 /** Used as references for the maximum length and index of an array. */ 6012 var MAX_ARRAY_LENGTH = 4294967295, 6013 MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, 6014 HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; 6015 6016 /** Used to associate wrap methods with their bit flags. */ 6017 var wrapFlags = [ 6018 ['ary', WRAP_ARY_FLAG], 6019 ['bind', WRAP_BIND_FLAG], 6020 ['bindKey', WRAP_BIND_KEY_FLAG], 6021 ['curry', WRAP_CURRY_FLAG], 6022 ['curryRight', WRAP_CURRY_RIGHT_FLAG], 6023 ['flip', WRAP_FLIP_FLAG], 6024 ['partial', WRAP_PARTIAL_FLAG], 6025 ['partialRight', WRAP_PARTIAL_RIGHT_FLAG], 6026 ['rearg', WRAP_REARG_FLAG] 6027 ]; 6028 6029 /** `Object#toString` result references. */ 6030 var argsTag = '[object Arguments]', 6031 arrayTag = '[object Array]', 6032 asyncTag = '[object AsyncFunction]', 6033 boolTag = '[object Boolean]', 6034 dateTag = '[object Date]', 6035 domExcTag = '[object DOMException]', 6036 errorTag = '[object Error]', 6037 funcTag = '[object Function]', 6038 genTag = '[object GeneratorFunction]', 6039 mapTag = '[object Map]', 6040 numberTag = '[object Number]', 6041 nullTag = '[object Null]', 6042 objectTag = '[object Object]', 6043 promiseTag = '[object Promise]', 6044 proxyTag = '[object Proxy]', 6045 regexpTag = '[object RegExp]', 6046 setTag = '[object Set]', 6047 stringTag = '[object String]', 6048 symbolTag = '[object Symbol]', 6049 undefinedTag = '[object Undefined]', 6050 weakMapTag = '[object WeakMap]', 6051 weakSetTag = '[object WeakSet]'; 6052 6053 var arrayBufferTag = '[object ArrayBuffer]', 6054 dataViewTag = '[object DataView]', 6055 float32Tag = '[object Float32Array]', 6056 float64Tag = '[object Float64Array]', 6057 int8Tag = '[object Int8Array]', 6058 int16Tag = '[object Int16Array]', 6059 int32Tag = '[object Int32Array]', 6060 uint8Tag = '[object Uint8Array]', 6061 uint8ClampedTag = '[object Uint8ClampedArray]', 6062 uint16Tag = '[object Uint16Array]', 6063 uint32Tag = '[object Uint32Array]'; 6064 6065 /** Used to match empty string literals in compiled template source. */ 6066 var reEmptyStringLeading = /\b__p \+= '';/g, 6067 reEmptyStringMiddle = /\b(__p \+=) '' \+/g, 6068 reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; 6069 6070 /** Used to match HTML entities and HTML characters. */ 6071 var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, 6072 reUnescapedHtml = /[&<>"']/g, 6073 reHasEscapedHtml = RegExp(reEscapedHtml.source), 6074 reHasUnescapedHtml = RegExp(reUnescapedHtml.source); 6075 6076 /** Used to match template delimiters. */ 6077 var reEscape = /<%-([\s\S]+?)%>/g, 6078 reEvaluate = /<%([\s\S]+?)%>/g, 6079 reInterpolate = /<%=([\s\S]+?)%>/g; 6080 6081 /** Used to match property names within property paths. */ 6082 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, 6083 reIsPlainProp = /^\w*$/, 6084 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; 6085 6086 /** 6087 * Used to match `RegExp` 6088 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). 6089 */ 6090 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, 6091 reHasRegExpChar = RegExp(reRegExpChar.source); 6092 6093 /** Used to match leading whitespace. */ 6094 var reTrimStart = /^\s+/; 6095 6096 /** Used to match a single whitespace character. */ 6097 var reWhitespace = /\s/; 6098 6099 /** Used to match wrap detail comments. */ 6100 var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, 6101 reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, 6102 reSplitDetails = /,? & /; 6103 6104 /** Used to match words composed of alphanumeric characters. */ 6105 var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; 6106 6107 /** 6108 * Used to validate the `validate` option in `_.template` variable. 6109 * 6110 * Forbids characters which could potentially change the meaning of the function argument definition: 6111 * - "()," (modification of function parameters) 6112 * - "=" (default value) 6113 * - "[]{}" (destructuring of function parameters) 6114 * - "/" (beginning of a comment) 6115 * - whitespace 6116 */ 6117 var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/; 6118 6119 /** Used to match backslashes in property paths. */ 6120 var reEscapeChar = /\\(\\)?/g; 6121 6122 /** 6123 * Used to match 6124 * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). 6125 */ 6126 var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; 6127 6128 /** Used to match `RegExp` flags from their coerced string values. */ 6129 var reFlags = /\w*$/; 6130 6131 /** Used to detect bad signed hexadecimal string values. */ 6132 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; 6133 6134 /** Used to detect binary string values. */ 6135 var reIsBinary = /^0b[01]+$/i; 6136 6137 /** Used to detect host constructors (Safari). */ 6138 var reIsHostCtor = /^\[object .+?Constructor\]$/; 6139 6140 /** Used to detect octal string values. */ 6141 var reIsOctal = /^0o[0-7]+$/i; 6142 6143 /** Used to detect unsigned integer values. */ 6144 var reIsUint = /^(?:0|[1-9]\d*)$/; 6145 6146 /** Used to match Latin Unicode letters (excluding mathematical operators). */ 6147 var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; 6148 6149 /** Used to ensure capturing order of template delimiters. */ 6150 var reNoMatch = /($^)/; 6151 6152 /** Used to match unescaped characters in compiled string literals. */ 6153 var reUnescapedString = /['\n\r\u2028\u2029\\]/g; 6154 6155 /** Used to compose unicode character classes. */ 6156 var rsAstralRange = '\\ud800-\\udfff', 6157 rsComboMarksRange = '\\u0300-\\u036f', 6158 reComboHalfMarksRange = '\\ufe20-\\ufe2f', 6159 rsComboSymbolsRange = '\\u20d0-\\u20ff', 6160 rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, 6161 rsDingbatRange = '\\u2700-\\u27bf', 6162 rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', 6163 rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', 6164 rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', 6165 rsPunctuationRange = '\\u2000-\\u206f', 6166 rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000', 6167 rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', 6168 rsVarRange = '\\ufe0e\\ufe0f', 6169 rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; 6170 6171 /** Used to compose unicode capture groups. */ 6172 var rsApos = "['\u2019]", 6173 rsAstral = '[' + rsAstralRange + ']', 6174 rsBreak = '[' + rsBreakRange + ']', 6175 rsCombo = '[' + rsComboRange + ']', 6176 rsDigits = '\\d+', 6177 rsDingbat = '[' + rsDingbatRange + ']', 6178 rsLower = '[' + rsLowerRange + ']', 6179 rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', 6180 rsFitz = '\\ud83c[\\udffb-\\udfff]', 6181 rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', 6182 rsNonAstral = '[^' + rsAstralRange + ']', 6183 rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', 6184 rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', 6185 rsUpper = '[' + rsUpperRange + ']', 6186 rsZWJ = '\\u200d'; 6187 6188 /** Used to compose unicode regexes. */ 6189 var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', 6190 rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', 6191 rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', 6192 rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', 6193 reOptMod = rsModifier + '?', 6194 rsOptVar = '[' + rsVarRange + ']?', 6195 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', 6196 rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])', 6197 rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])', 6198 rsSeq = rsOptVar + reOptMod + rsOptJoin, 6199 rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, 6200 rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; 6201 6202 /** Used to match apostrophes. */ 6203 var reApos = RegExp(rsApos, 'g'); 6204 6205 /** 6206 * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and 6207 * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). 6208 */ 6209 var reComboMark = RegExp(rsCombo, 'g'); 6210 6211 /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ 6212 var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); 6213 6214 /** Used to match complex or compound words. */ 6215 var reUnicodeWord = RegExp([ 6216 rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', 6217 rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', 6218 rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, 6219 rsUpper + '+' + rsOptContrUpper, 6220 rsOrdUpper, 6221 rsOrdLower, 6222 rsDigits, 6223 rsEmoji 6224 ].join('|'), 'g'); 6225 6226 /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ 6227 var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); 6228 6229 /** Used to detect strings that need a more robust regexp to match words. */ 6230 var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; 6231 6232 /** Used to assign default `context` object properties. */ 6233 var contextProps = [ 6234 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', 6235 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', 6236 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', 6237 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', 6238 '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' 6239 ]; 6240 6241 /** Used to make template sourceURLs easier to identify. */ 6242 var templateCounter = -1; 6243 6244 /** Used to identify `toStringTag` values of typed arrays. */ 6245 var typedArrayTags = {}; 6246 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = 6247 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = 6248 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = 6249 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = 6250 typedArrayTags[uint32Tag] = true; 6251 typedArrayTags[argsTag] = typedArrayTags[arrayTag] = 6252 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = 6253 typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = 6254 typedArrayTags[errorTag] = typedArrayTags[funcTag] = 6255 typedArrayTags[mapTag] = typedArrayTags[numberTag] = 6256 typedArrayTags[objectTag] = typedArrayTags[regexpTag] = 6257 typedArrayTags[setTag] = typedArrayTags[stringTag] = 6258 typedArrayTags[weakMapTag] = false; 6259 6260 /** Used to identify `toStringTag` values supported by `_.clone`. */ 6261 var cloneableTags = {}; 6262 cloneableTags[argsTag] = cloneableTags[arrayTag] = 6263 cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = 6264 cloneableTags[boolTag] = cloneableTags[dateTag] = 6265 cloneableTags[float32Tag] = cloneableTags[float64Tag] = 6266 cloneableTags[int8Tag] = cloneableTags[int16Tag] = 6267 cloneableTags[int32Tag] = cloneableTags[mapTag] = 6268 cloneableTags[numberTag] = cloneableTags[objectTag] = 6269 cloneableTags[regexpTag] = cloneableTags[setTag] = 6270 cloneableTags[stringTag] = cloneableTags[symbolTag] = 6271 cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = 6272 cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; 6273 cloneableTags[errorTag] = cloneableTags[funcTag] = 6274 cloneableTags[weakMapTag] = false; 6275 6276 /** Used to map Latin Unicode letters to basic Latin letters. */ 6277 var deburredLetters = { 6278 // Latin-1 Supplement block. 6279 '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', 6280 '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', 6281 '\xc7': 'C', '\xe7': 'c', 6282 '\xd0': 'D', '\xf0': 'd', 6283 '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', 6284 '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', 6285 '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', 6286 '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', 6287 '\xd1': 'N', '\xf1': 'n', 6288 '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', 6289 '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', 6290 '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', 6291 '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', 6292 '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', 6293 '\xc6': 'Ae', '\xe6': 'ae', 6294 '\xde': 'Th', '\xfe': 'th', 6295 '\xdf': 'ss', 6296 // Latin Extended-A block. 6297 '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', 6298 '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', 6299 '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', 6300 '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', 6301 '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', 6302 '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', 6303 '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', 6304 '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', 6305 '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', 6306 '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', 6307 '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', 6308 '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', 6309 '\u0134': 'J', '\u0135': 'j', 6310 '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', 6311 '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', 6312 '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', 6313 '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', 6314 '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', 6315 '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', 6316 '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', 6317 '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', 6318 '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', 6319 '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', 6320 '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', 6321 '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', 6322 '\u0163': 't', '\u0165': 't', '\u0167': 't', 6323 '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', 6324 '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', 6325 '\u0174': 'W', '\u0175': 'w', 6326 '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', 6327 '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', 6328 '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', 6329 '\u0132': 'IJ', '\u0133': 'ij', 6330 '\u0152': 'Oe', '\u0153': 'oe', 6331 '\u0149': "'n", '\u017f': 's' 6332 }; 6333 6334 /** Used to map characters to HTML entities. */ 6335 var htmlEscapes = { 6336 '&': '&', 6337 '<': '<', 6338 '>': '>', 6339 '"': '"', 6340 "'": ''' 6341 }; 6342 6343 /** Used to map HTML entities to characters. */ 6344 var htmlUnescapes = { 6345 '&': '&', 6346 '<': '<', 6347 '>': '>', 6348 '"': '"', 6349 ''': "'" 6350 }; 6351 6352 /** Used to escape characters for inclusion in compiled string literals. */ 6353 var stringEscapes = { 6354 '\\': '\\', 6355 "'": "'", 6356 '\n': 'n', 6357 '\r': 'r', 6358 '\u2028': 'u2028', 6359 '\u2029': 'u2029' 6360 }; 6361 6362 /** Built-in method references without a dependency on `root`. */ 6363 var freeParseFloat = parseFloat, 6364 freeParseInt = parseInt; 6365 6366 /** Detect free variable `global` from Node.js. */ 6367 var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; 6368 6369 /** Detect free variable `self`. */ 6370 var freeSelf = typeof self == 'object' && self && self.Object === Object && self; 6371 6372 /** Used as a reference to the global object. */ 6373 var root = freeGlobal || freeSelf || Function('return this')(); 6374 6375 /** Detect free variable `exports`. */ 6376 var freeExports = exports && !exports.nodeType && exports; 6377 6378 /** Detect free variable `module`. */ 6379 var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module; 6380 6381 /** Detect the popular CommonJS extension `module.exports`. */ 6382 var moduleExports = freeModule && freeModule.exports === freeExports; 6383 6384 /** Detect free variable `process` from Node.js. */ 6385 var freeProcess = moduleExports && freeGlobal.process; 6386 6387 /** Used to access faster Node.js helpers. */ 6388 var nodeUtil = (function() { 6389 try { 6390 // Use `util.types` for Node.js 10+. 6391 var types = freeModule && freeModule.require && freeModule.require('util').types; 6392 6393 if (types) { 6394 return types; 6395 } 6396 6397 // Legacy `process.binding('util')` for Node.js < 10. 6398 return freeProcess && freeProcess.binding && freeProcess.binding('util'); 6399 } catch (e) {} 6400 }()); 6401 6402 /* Node.js helper references. */ 6403 var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer, 6404 nodeIsDate = nodeUtil && nodeUtil.isDate, 6405 nodeIsMap = nodeUtil && nodeUtil.isMap, 6406 nodeIsRegExp = nodeUtil && nodeUtil.isRegExp, 6407 nodeIsSet = nodeUtil && nodeUtil.isSet, 6408 nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; 6409 6410 /*--------------------------------------------------------------------------*/ 6411 6412 /** 6413 * A faster alternative to `Function#apply`, this function invokes `func` 6414 * with the `this` binding of `thisArg` and the arguments of `args`. 6415 * 6416 * @private 6417 * @param {Function} func The function to invoke. 6418 * @param {*} thisArg The `this` binding of `func`. 6419 * @param {Array} args The arguments to invoke `func` with. 6420 * @returns {*} Returns the result of `func`. 6421 */ 6422 function apply(func, thisArg, args) { 6423 switch (args.length) { 6424 case 0: return func.call(thisArg); 6425 case 1: return func.call(thisArg, args[0]); 6426 case 2: return func.call(thisArg, args[0], args[1]); 6427 case 3: return func.call(thisArg, args[0], args[1], args[2]); 6428 } 6429 return func.apply(thisArg, args); 6430 } 6431 6432 /** 6433 * A specialized version of `baseAggregator` for arrays. 6434 * 6435 * @private 6436 * @param {Array} [array] The array to iterate over. 6437 * @param {Function} setter The function to set `accumulator` values. 6438 * @param {Function} iteratee The iteratee to transform keys. 6439 * @param {Object} accumulator The initial aggregated object. 6440 * @returns {Function} Returns `accumulator`. 6441 */ 6442 function arrayAggregator(array, setter, iteratee, accumulator) { 6443 var index = -1, 6444 length = array == null ? 0 : array.length; 6445 6446 while (++index < length) { 6447 var value = array[index]; 6448 setter(accumulator, value, iteratee(value), array); 6449 } 6450 return accumulator; 6451 } 6452 6453 /** 6454 * A specialized version of `_.forEach` for arrays without support for 6455 * iteratee shorthands. 6456 * 6457 * @private 6458 * @param {Array} [array] The array to iterate over. 6459 * @param {Function} iteratee The function invoked per iteration. 6460 * @returns {Array} Returns `array`. 6461 */ 6462 function arrayEach(array, iteratee) { 6463 var index = -1, 6464 length = array == null ? 0 : array.length; 6465 6466 while (++index < length) { 6467 if (iteratee(array[index], index, array) === false) { 6468 break; 6469 } 6470 } 6471 return array; 6472 } 6473 6474 /** 6475 * A specialized version of `_.forEachRight` for arrays without support for 6476 * iteratee shorthands. 6477 * 6478 * @private 6479 * @param {Array} [array] The array to iterate over. 6480 * @param {Function} iteratee The function invoked per iteration. 6481 * @returns {Array} Returns `array`. 6482 */ 6483 function arrayEachRight(array, iteratee) { 6484 var length = array == null ? 0 : array.length; 6485 6486 while (length--) { 6487 if (iteratee(array[length], length, array) === false) { 6488 break; 6489 } 6490 } 6491 return array; 6492 } 6493 6494 /** 6495 * A specialized version of `_.every` for arrays without support for 6496 * iteratee shorthands. 6497 * 6498 * @private 6499 * @param {Array} [array] The array to iterate over. 6500 * @param {Function} predicate The function invoked per iteration. 6501 * @returns {boolean} Returns `true` if all elements pass the predicate check, 6502 * else `false`. 6503 */ 6504 function arrayEvery(array, predicate) { 6505 var index = -1, 6506 length = array == null ? 0 : array.length; 6507 6508 while (++index < length) { 6509 if (!predicate(array[index], index, array)) { 6510 return false; 6511 } 6512 } 6513 return true; 6514 } 6515 6516 /** 6517 * A specialized version of `_.filter` for arrays without support for 6518 * iteratee shorthands. 6519 * 6520 * @private 6521 * @param {Array} [array] The array to iterate over. 6522 * @param {Function} predicate The function invoked per iteration. 6523 * @returns {Array} Returns the new filtered array. 6524 */ 6525 function arrayFilter(array, predicate) { 6526 var index = -1, 6527 length = array == null ? 0 : array.length, 6528 resIndex = 0, 6529 result = []; 6530 6531 while (++index < length) { 6532 var value = array[index]; 6533 if (predicate(value, index, array)) { 6534 result[resIndex++] = value; 6535 } 6536 } 6537 return result; 6538 } 6539 6540 /** 6541 * A specialized version of `_.includes` for arrays without support for 6542 * specifying an index to search from. 6543 * 6544 * @private 6545 * @param {Array} [array] The array to inspect. 6546 * @param {*} target The value to search for. 6547 * @returns {boolean} Returns `true` if `target` is found, else `false`. 6548 */ 6549 function arrayIncludes(array, value) { 6550 var length = array == null ? 0 : array.length; 6551 return !!length && baseIndexOf(array, value, 0) > -1; 6552 } 6553 6554 /** 6555 * This function is like `arrayIncludes` except that it accepts a comparator. 6556 * 6557 * @private 6558 * @param {Array} [array] The array to inspect. 6559 * @param {*} target The value to search for. 6560 * @param {Function} comparator The comparator invoked per element. 6561 * @returns {boolean} Returns `true` if `target` is found, else `false`. 6562 */ 6563 function arrayIncludesWith(array, value, comparator) { 6564 var index = -1, 6565 length = array == null ? 0 : array.length; 6566 6567 while (++index < length) { 6568 if (comparator(value, array[index])) { 6569 return true; 6570 } 6571 } 6572 return false; 6573 } 6574 6575 /** 6576 * A specialized version of `_.map` for arrays without support for iteratee 6577 * shorthands. 6578 * 6579 * @private 6580 * @param {Array} [array] The array to iterate over. 6581 * @param {Function} iteratee The function invoked per iteration. 6582 * @returns {Array} Returns the new mapped array. 6583 */ 6584 function arrayMap(array, iteratee) { 6585 var index = -1, 6586 length = array == null ? 0 : array.length, 6587 result = Array(length); 6588 6589 while (++index < length) { 6590 result[index] = iteratee(array[index], index, array); 6591 } 6592 return result; 6593 } 6594 6595 /** 6596 * Appends the elements of `values` to `array`. 6597 * 6598 * @private 6599 * @param {Array} array The array to modify. 6600 * @param {Array} values The values to append. 6601 * @returns {Array} Returns `array`. 6602 */ 6603 function arrayPush(array, values) { 6604 var index = -1, 6605 length = values.length, 6606 offset = array.length; 6607 6608 while (++index < length) { 6609 array[offset + index] = values[index]; 6610 } 6611 return array; 6612 } 6613 6614 /** 6615 * A specialized version of `_.reduce` for arrays without support for 6616 * iteratee shorthands. 6617 * 6618 * @private 6619 * @param {Array} [array] The array to iterate over. 6620 * @param {Function} iteratee The function invoked per iteration. 6621 * @param {*} [accumulator] The initial value. 6622 * @param {boolean} [initAccum] Specify using the first element of `array` as 6623 * the initial value. 6624 * @returns {*} Returns the accumulated value. 6625 */ 6626 function arrayReduce(array, iteratee, accumulator, initAccum) { 6627 var index = -1, 6628 length = array == null ? 0 : array.length; 6629 6630 if (initAccum && length) { 6631 accumulator = array[++index]; 6632 } 6633 while (++index < length) { 6634 accumulator = iteratee(accumulator, array[index], index, array); 6635 } 6636 return accumulator; 6637 } 6638 6639 /** 6640 * A specialized version of `_.reduceRight` for arrays without support for 6641 * iteratee shorthands. 6642 * 6643 * @private 6644 * @param {Array} [array] The array to iterate over. 6645 * @param {Function} iteratee The function invoked per iteration. 6646 * @param {*} [accumulator] The initial value. 6647 * @param {boolean} [initAccum] Specify using the last element of `array` as 6648 * the initial value. 6649 * @returns {*} Returns the accumulated value. 6650 */ 6651 function arrayReduceRight(array, iteratee, accumulator, initAccum) { 6652 var length = array == null ? 0 : array.length; 6653 if (initAccum && length) { 6654 accumulator = array[--length]; 6655 } 6656 while (length--) { 6657 accumulator = iteratee(accumulator, array[length], length, array); 6658 } 6659 return accumulator; 6660 } 6661 6662 /** 6663 * A specialized version of `_.some` for arrays without support for iteratee 6664 * shorthands. 6665 * 6666 * @private 6667 * @param {Array} [array] The array to iterate over. 6668 * @param {Function} predicate The function invoked per iteration. 6669 * @returns {boolean} Returns `true` if any element passes the predicate check, 6670 * else `false`. 6671 */ 6672 function arraySome(array, predicate) { 6673 var index = -1, 6674 length = array == null ? 0 : array.length; 6675 6676 while (++index < length) { 6677 if (predicate(array[index], index, array)) { 6678 return true; 6679 } 6680 } 6681 return false; 6682 } 6683 6684 /** 6685 * Gets the size of an ASCII `string`. 6686 * 6687 * @private 6688 * @param {string} string The string inspect. 6689 * @returns {number} Returns the string size. 6690 */ 6691 var asciiSize = baseProperty('length'); 6692 6693 /** 6694 * Converts an ASCII `string` to an array. 6695 * 6696 * @private 6697 * @param {string} string The string to convert. 6698 * @returns {Array} Returns the converted array. 6699 */ 6700 function asciiToArray(string) { 6701 return string.split(''); 6702 } 6703 6704 /** 6705 * Splits an ASCII `string` into an array of its words. 6706 * 6707 * @private 6708 * @param {string} The string to inspect. 6709 * @returns {Array} Returns the words of `string`. 6710 */ 6711 function asciiWords(string) { 6712 return string.match(reAsciiWord) || []; 6713 } 6714 6715 /** 6716 * The base implementation of methods like `_.findKey` and `_.findLastKey`, 6717 * without support for iteratee shorthands, which iterates over `collection` 6718 * using `eachFunc`. 6719 * 6720 * @private 6721 * @param {Array|Object} collection The collection to inspect. 6722 * @param {Function} predicate The function invoked per iteration. 6723 * @param {Function} eachFunc The function to iterate over `collection`. 6724 * @returns {*} Returns the found element or its key, else `undefined`. 6725 */ 6726 function baseFindKey(collection, predicate, eachFunc) { 6727 var result; 6728 eachFunc(collection, function(value, key, collection) { 6729 if (predicate(value, key, collection)) { 6730 result = key; 6731 return false; 6732 } 6733 }); 6734 return result; 6735 } 6736 6737 /** 6738 * The base implementation of `_.findIndex` and `_.findLastIndex` without 6739 * support for iteratee shorthands. 6740 * 6741 * @private 6742 * @param {Array} array The array to inspect. 6743 * @param {Function} predicate The function invoked per iteration. 6744 * @param {number} fromIndex The index to search from. 6745 * @param {boolean} [fromRight] Specify iterating from right to left. 6746 * @returns {number} Returns the index of the matched value, else `-1`. 6747 */ 6748 function baseFindIndex(array, predicate, fromIndex, fromRight) { 6749 var length = array.length, 6750 index = fromIndex + (fromRight ? 1 : -1); 6751 6752 while ((fromRight ? index-- : ++index < length)) { 6753 if (predicate(array[index], index, array)) { 6754 return index; 6755 } 6756 } 6757 return -1; 6758 } 6759 6760 /** 6761 * The base implementation of `_.indexOf` without `fromIndex` bounds checks. 6762 * 6763 * @private 6764 * @param {Array} array The array to inspect. 6765 * @param {*} value The value to search for. 6766 * @param {number} fromIndex The index to search from. 6767 * @returns {number} Returns the index of the matched value, else `-1`. 6768 */ 6769 function baseIndexOf(array, value, fromIndex) { 6770 return value === value 6771 ? strictIndexOf(array, value, fromIndex) 6772 : baseFindIndex(array, baseIsNaN, fromIndex); 6773 } 6774 6775 /** 6776 * This function is like `baseIndexOf` except that it accepts a comparator. 6777 * 6778 * @private 6779 * @param {Array} array The array to inspect. 6780 * @param {*} value The value to search for. 6781 * @param {number} fromIndex The index to search from. 6782 * @param {Function} comparator The comparator invoked per element. 6783 * @returns {number} Returns the index of the matched value, else `-1`. 6784 */ 6785 function baseIndexOfWith(array, value, fromIndex, comparator) { 6786 var index = fromIndex - 1, 6787 length = array.length; 6788 6789 while (++index < length) { 6790 if (comparator(array[index], value)) { 6791 return index; 6792 } 6793 } 6794 return -1; 6795 } 6796 6797 /** 6798 * The base implementation of `_.isNaN` without support for number objects. 6799 * 6800 * @private 6801 * @param {*} value The value to check. 6802 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 6803 */ 6804 function baseIsNaN(value) { 6805 return value !== value; 6806 } 6807 6808 /** 6809 * The base implementation of `_.mean` and `_.meanBy` without support for 6810 * iteratee shorthands. 6811 * 6812 * @private 6813 * @param {Array} array The array to iterate over. 6814 * @param {Function} iteratee The function invoked per iteration. 6815 * @returns {number} Returns the mean. 6816 */ 6817 function baseMean(array, iteratee) { 6818 var length = array == null ? 0 : array.length; 6819 return length ? (baseSum(array, iteratee) / length) : NAN; 6820 } 6821 6822 /** 6823 * The base implementation of `_.property` without support for deep paths. 6824 * 6825 * @private 6826 * @param {string} key The key of the property to get. 6827 * @returns {Function} Returns the new accessor function. 6828 */ 6829 function baseProperty(key) { 6830 return function(object) { 6831 return object == null ? undefined$1 : object[key]; 6832 }; 6833 } 6834 6835 /** 6836 * The base implementation of `_.propertyOf` without support for deep paths. 6837 * 6838 * @private 6839 * @param {Object} object The object to query. 6840 * @returns {Function} Returns the new accessor function. 6841 */ 6842 function basePropertyOf(object) { 6843 return function(key) { 6844 return object == null ? undefined$1 : object[key]; 6845 }; 6846 } 6847 6848 /** 6849 * The base implementation of `_.reduce` and `_.reduceRight`, without support 6850 * for iteratee shorthands, which iterates over `collection` using `eachFunc`. 6851 * 6852 * @private 6853 * @param {Array|Object} collection The collection to iterate over. 6854 * @param {Function} iteratee The function invoked per iteration. 6855 * @param {*} accumulator The initial value. 6856 * @param {boolean} initAccum Specify using the first or last element of 6857 * `collection` as the initial value. 6858 * @param {Function} eachFunc The function to iterate over `collection`. 6859 * @returns {*} Returns the accumulated value. 6860 */ 6861 function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { 6862 eachFunc(collection, function(value, index, collection) { 6863 accumulator = initAccum 6864 ? (initAccum = false, value) 6865 : iteratee(accumulator, value, index, collection); 6866 }); 6867 return accumulator; 6868 } 6869 6870 /** 6871 * The base implementation of `_.sortBy` which uses `comparer` to define the 6872 * sort order of `array` and replaces criteria objects with their corresponding 6873 * values. 6874 * 6875 * @private 6876 * @param {Array} array The array to sort. 6877 * @param {Function} comparer The function to define sort order. 6878 * @returns {Array} Returns `array`. 6879 */ 6880 function baseSortBy(array, comparer) { 6881 var length = array.length; 6882 6883 array.sort(comparer); 6884 while (length--) { 6885 array[length] = array[length].value; 6886 } 6887 return array; 6888 } 6889 6890 /** 6891 * The base implementation of `_.sum` and `_.sumBy` without support for 6892 * iteratee shorthands. 6893 * 6894 * @private 6895 * @param {Array} array The array to iterate over. 6896 * @param {Function} iteratee The function invoked per iteration. 6897 * @returns {number} Returns the sum. 6898 */ 6899 function baseSum(array, iteratee) { 6900 var result, 6901 index = -1, 6902 length = array.length; 6903 6904 while (++index < length) { 6905 var current = iteratee(array[index]); 6906 if (current !== undefined$1) { 6907 result = result === undefined$1 ? current : (result + current); 6908 } 6909 } 6910 return result; 6911 } 6912 6913 /** 6914 * The base implementation of `_.times` without support for iteratee shorthands 6915 * or max array length checks. 6916 * 6917 * @private 6918 * @param {number} n The number of times to invoke `iteratee`. 6919 * @param {Function} iteratee The function invoked per iteration. 6920 * @returns {Array} Returns the array of results. 6921 */ 6922 function baseTimes(n, iteratee) { 6923 var index = -1, 6924 result = Array(n); 6925 6926 while (++index < n) { 6927 result[index] = iteratee(index); 6928 } 6929 return result; 6930 } 6931 6932 /** 6933 * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array 6934 * of key-value pairs for `object` corresponding to the property names of `props`. 6935 * 6936 * @private 6937 * @param {Object} object The object to query. 6938 * @param {Array} props The property names to get values for. 6939 * @returns {Object} Returns the key-value pairs. 6940 */ 6941 function baseToPairs(object, props) { 6942 return arrayMap(props, function(key) { 6943 return [key, object[key]]; 6944 }); 6945 } 6946 6947 /** 6948 * The base implementation of `_.trim`. 6949 * 6950 * @private 6951 * @param {string} string The string to trim. 6952 * @returns {string} Returns the trimmed string. 6953 */ 6954 function baseTrim(string) { 6955 return string 6956 ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') 6957 : string; 6958 } 6959 6960 /** 6961 * The base implementation of `_.unary` without support for storing metadata. 6962 * 6963 * @private 6964 * @param {Function} func The function to cap arguments for. 6965 * @returns {Function} Returns the new capped function. 6966 */ 6967 function baseUnary(func) { 6968 return function(value) { 6969 return func(value); 6970 }; 6971 } 6972 6973 /** 6974 * The base implementation of `_.values` and `_.valuesIn` which creates an 6975 * array of `object` property values corresponding to the property names 6976 * of `props`. 6977 * 6978 * @private 6979 * @param {Object} object The object to query. 6980 * @param {Array} props The property names to get values for. 6981 * @returns {Object} Returns the array of property values. 6982 */ 6983 function baseValues(object, props) { 6984 return arrayMap(props, function(key) { 6985 return object[key]; 6986 }); 6987 } 6988 6989 /** 6990 * Checks if a `cache` value for `key` exists. 6991 * 6992 * @private 6993 * @param {Object} cache The cache to query. 6994 * @param {string} key The key of the entry to check. 6995 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 6996 */ 6997 function cacheHas(cache, key) { 6998 return cache.has(key); 6999 } 7000 7001 /** 7002 * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol 7003 * that is not found in the character symbols. 7004 * 7005 * @private 7006 * @param {Array} strSymbols The string symbols to inspect. 7007 * @param {Array} chrSymbols The character symbols to find. 7008 * @returns {number} Returns the index of the first unmatched string symbol. 7009 */ 7010 function charsStartIndex(strSymbols, chrSymbols) { 7011 var index = -1, 7012 length = strSymbols.length; 7013 7014 while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 7015 return index; 7016 } 7017 7018 /** 7019 * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol 7020 * that is not found in the character symbols. 7021 * 7022 * @private 7023 * @param {Array} strSymbols The string symbols to inspect. 7024 * @param {Array} chrSymbols The character symbols to find. 7025 * @returns {number} Returns the index of the last unmatched string symbol. 7026 */ 7027 function charsEndIndex(strSymbols, chrSymbols) { 7028 var index = strSymbols.length; 7029 7030 while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 7031 return index; 7032 } 7033 7034 /** 7035 * Gets the number of `placeholder` occurrences in `array`. 7036 * 7037 * @private 7038 * @param {Array} array The array to inspect. 7039 * @param {*} placeholder The placeholder to search for. 7040 * @returns {number} Returns the placeholder count. 7041 */ 7042 function countHolders(array, placeholder) { 7043 var length = array.length, 7044 result = 0; 7045 7046 while (length--) { 7047 if (array[length] === placeholder) { 7048 ++result; 7049 } 7050 } 7051 return result; 7052 } 7053 7054 /** 7055 * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A 7056 * letters to basic Latin letters. 7057 * 7058 * @private 7059 * @param {string} letter The matched letter to deburr. 7060 * @returns {string} Returns the deburred letter. 7061 */ 7062 var deburrLetter = basePropertyOf(deburredLetters); 7063 7064 /** 7065 * Used by `_.escape` to convert characters to HTML entities. 7066 * 7067 * @private 7068 * @param {string} chr The matched character to escape. 7069 * @returns {string} Returns the escaped character. 7070 */ 7071 var escapeHtmlChar = basePropertyOf(htmlEscapes); 7072 7073 /** 7074 * Used by `_.template` to escape characters for inclusion in compiled string literals. 7075 * 7076 * @private 7077 * @param {string} chr The matched character to escape. 7078 * @returns {string} Returns the escaped character. 7079 */ 7080 function escapeStringChar(chr) { 7081 return '\\' + stringEscapes[chr]; 7082 } 7083 7084 /** 7085 * Gets the value at `key` of `object`. 7086 * 7087 * @private 7088 * @param {Object} [object] The object to query. 7089 * @param {string} key The key of the property to get. 7090 * @returns {*} Returns the property value. 7091 */ 7092 function getValue(object, key) { 7093 return object == null ? undefined$1 : object[key]; 7094 } 7095 7096 /** 7097 * Checks if `string` contains Unicode symbols. 7098 * 7099 * @private 7100 * @param {string} string The string to inspect. 7101 * @returns {boolean} Returns `true` if a symbol is found, else `false`. 7102 */ 7103 function hasUnicode(string) { 7104 return reHasUnicode.test(string); 7105 } 7106 7107 /** 7108 * Checks if `string` contains a word composed of Unicode symbols. 7109 * 7110 * @private 7111 * @param {string} string The string to inspect. 7112 * @returns {boolean} Returns `true` if a word is found, else `false`. 7113 */ 7114 function hasUnicodeWord(string) { 7115 return reHasUnicodeWord.test(string); 7116 } 7117 7118 /** 7119 * Converts `iterator` to an array. 7120 * 7121 * @private 7122 * @param {Object} iterator The iterator to convert. 7123 * @returns {Array} Returns the converted array. 7124 */ 7125 function iteratorToArray(iterator) { 7126 var data, 7127 result = []; 7128 7129 while (!(data = iterator.next()).done) { 7130 result.push(data.value); 7131 } 7132 return result; 7133 } 7134 7135 /** 7136 * Converts `map` to its key-value pairs. 7137 * 7138 * @private 7139 * @param {Object} map The map to convert. 7140 * @returns {Array} Returns the key-value pairs. 7141 */ 7142 function mapToArray(map) { 7143 var index = -1, 7144 result = Array(map.size); 7145 7146 map.forEach(function(value, key) { 7147 result[++index] = [key, value]; 7148 }); 7149 return result; 7150 } 7151 7152 /** 7153 * Creates a unary function that invokes `func` with its argument transformed. 7154 * 7155 * @private 7156 * @param {Function} func The function to wrap. 7157 * @param {Function} transform The argument transform. 7158 * @returns {Function} Returns the new function. 7159 */ 7160 function overArg(func, transform) { 7161 return function(arg) { 7162 return func(transform(arg)); 7163 }; 7164 } 7165 7166 /** 7167 * Replaces all `placeholder` elements in `array` with an internal placeholder 7168 * and returns an array of their indexes. 7169 * 7170 * @private 7171 * @param {Array} array The array to modify. 7172 * @param {*} placeholder The placeholder to replace. 7173 * @returns {Array} Returns the new array of placeholder indexes. 7174 */ 7175 function replaceHolders(array, placeholder) { 7176 var index = -1, 7177 length = array.length, 7178 resIndex = 0, 7179 result = []; 7180 7181 while (++index < length) { 7182 var value = array[index]; 7183 if (value === placeholder || value === PLACEHOLDER) { 7184 array[index] = PLACEHOLDER; 7185 result[resIndex++] = index; 7186 } 7187 } 7188 return result; 7189 } 7190 7191 /** 7192 * Converts `set` to an array of its values. 7193 * 7194 * @private 7195 * @param {Object} set The set to convert. 7196 * @returns {Array} Returns the values. 7197 */ 7198 function setToArray(set) { 7199 var index = -1, 7200 result = Array(set.size); 7201 7202 set.forEach(function(value) { 7203 result[++index] = value; 7204 }); 7205 return result; 7206 } 7207 7208 /** 7209 * Converts `set` to its value-value pairs. 7210 * 7211 * @private 7212 * @param {Object} set The set to convert. 7213 * @returns {Array} Returns the value-value pairs. 7214 */ 7215 function setToPairs(set) { 7216 var index = -1, 7217 result = Array(set.size); 7218 7219 set.forEach(function(value) { 7220 result[++index] = [value, value]; 7221 }); 7222 return result; 7223 } 7224 7225 /** 7226 * A specialized version of `_.indexOf` which performs strict equality 7227 * comparisons of values, i.e. `===`. 7228 * 7229 * @private 7230 * @param {Array} array The array to inspect. 7231 * @param {*} value The value to search for. 7232 * @param {number} fromIndex The index to search from. 7233 * @returns {number} Returns the index of the matched value, else `-1`. 7234 */ 7235 function strictIndexOf(array, value, fromIndex) { 7236 var index = fromIndex - 1, 7237 length = array.length; 7238 7239 while (++index < length) { 7240 if (array[index] === value) { 7241 return index; 7242 } 7243 } 7244 return -1; 7245 } 7246 7247 /** 7248 * A specialized version of `_.lastIndexOf` which performs strict equality 7249 * comparisons of values, i.e. `===`. 7250 * 7251 * @private 7252 * @param {Array} array The array to inspect. 7253 * @param {*} value The value to search for. 7254 * @param {number} fromIndex The index to search from. 7255 * @returns {number} Returns the index of the matched value, else `-1`. 7256 */ 7257 function strictLastIndexOf(array, value, fromIndex) { 7258 var index = fromIndex + 1; 7259 while (index--) { 7260 if (array[index] === value) { 7261 return index; 7262 } 7263 } 7264 return index; 7265 } 7266 7267 /** 7268 * Gets the number of symbols in `string`. 7269 * 7270 * @private 7271 * @param {string} string The string to inspect. 7272 * @returns {number} Returns the string size. 7273 */ 7274 function stringSize(string) { 7275 return hasUnicode(string) 7276 ? unicodeSize(string) 7277 : asciiSize(string); 7278 } 7279 7280 /** 7281 * Converts `string` to an array. 7282 * 7283 * @private 7284 * @param {string} string The string to convert. 7285 * @returns {Array} Returns the converted array. 7286 */ 7287 function stringToArray(string) { 7288 return hasUnicode(string) 7289 ? unicodeToArray(string) 7290 : asciiToArray(string); 7291 } 7292 7293 /** 7294 * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace 7295 * character of `string`. 7296 * 7297 * @private 7298 * @param {string} string The string to inspect. 7299 * @returns {number} Returns the index of the last non-whitespace character. 7300 */ 7301 function trimmedEndIndex(string) { 7302 var index = string.length; 7303 7304 while (index-- && reWhitespace.test(string.charAt(index))) {} 7305 return index; 7306 } 7307 7308 /** 7309 * Used by `_.unescape` to convert HTML entities to characters. 7310 * 7311 * @private 7312 * @param {string} chr The matched character to unescape. 7313 * @returns {string} Returns the unescaped character. 7314 */ 7315 var unescapeHtmlChar = basePropertyOf(htmlUnescapes); 7316 7317 /** 7318 * Gets the size of a Unicode `string`. 7319 * 7320 * @private 7321 * @param {string} string The string inspect. 7322 * @returns {number} Returns the string size. 7323 */ 7324 function unicodeSize(string) { 7325 var result = reUnicode.lastIndex = 0; 7326 while (reUnicode.test(string)) { 7327 ++result; 7328 } 7329 return result; 7330 } 7331 7332 /** 7333 * Converts a Unicode `string` to an array. 7334 * 7335 * @private 7336 * @param {string} string The string to convert. 7337 * @returns {Array} Returns the converted array. 7338 */ 7339 function unicodeToArray(string) { 7340 return string.match(reUnicode) || []; 7341 } 7342 7343 /** 7344 * Splits a Unicode `string` into an array of its words. 7345 * 7346 * @private 7347 * @param {string} The string to inspect. 7348 * @returns {Array} Returns the words of `string`. 7349 */ 7350 function unicodeWords(string) { 7351 return string.match(reUnicodeWord) || []; 7352 } 7353 7354 /*--------------------------------------------------------------------------*/ 7355 7356 /** 7357 * Create a new pristine `lodash` function using the `context` object. 7358 * 7359 * @static 7360 * @memberOf _ 7361 * @since 1.1.0 7362 * @category Util 7363 * @param {Object} [context=root] The context object. 7364 * @returns {Function} Returns a new `lodash` function. 7365 * @example 7366 * 7367 * _.mixin({ 'foo': _.constant('foo') }); 7368 * 7369 * var lodash = _.runInContext(); 7370 * lodash.mixin({ 'bar': lodash.constant('bar') }); 7371 * 7372 * _.isFunction(_.foo); 7373 * // => true 7374 * _.isFunction(_.bar); 7375 * // => false 7376 * 7377 * lodash.isFunction(lodash.foo); 7378 * // => false 7379 * lodash.isFunction(lodash.bar); 7380 * // => true 7381 * 7382 * // Create a suped-up `defer` in Node.js. 7383 * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; 7384 */ 7385 var runInContext = (function runInContext(context) { 7386 context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps)); 7387 7388 /** Built-in constructor references. */ 7389 var Array = context.Array, 7390 Date = context.Date, 7391 Error = context.Error, 7392 Function = context.Function, 7393 Math = context.Math, 7394 Object = context.Object, 7395 RegExp = context.RegExp, 7396 String = context.String, 7397 TypeError = context.TypeError; 7398 7399 /** Used for built-in method references. */ 7400 var arrayProto = Array.prototype, 7401 funcProto = Function.prototype, 7402 objectProto = Object.prototype; 7403 7404 /** Used to detect overreaching core-js shims. */ 7405 var coreJsData = context['__core-js_shared__']; 7406 7407 /** Used to resolve the decompiled source of functions. */ 7408 var funcToString = funcProto.toString; 7409 7410 /** Used to check objects for own properties. */ 7411 var hasOwnProperty = objectProto.hasOwnProperty; 7412 7413 /** Used to generate unique IDs. */ 7414 var idCounter = 0; 7415 7416 /** Used to detect methods masquerading as native. */ 7417 var maskSrcKey = (function() { 7418 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); 7419 return uid ? ('Symbol(src)_1.' + uid) : ''; 7420 }()); 7421 7422 /** 7423 * Used to resolve the 7424 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) 7425 * of values. 7426 */ 7427 var nativeObjectToString = objectProto.toString; 7428 7429 /** Used to infer the `Object` constructor. */ 7430 var objectCtorString = funcToString.call(Object); 7431 7432 /** Used to restore the original `_` reference in `_.noConflict`. */ 7433 var oldDash = root._; 7434 7435 /** Used to detect if a method is native. */ 7436 var reIsNative = RegExp('^' + 7437 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') 7438 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' 7439 ); 7440 7441 /** Built-in value references. */ 7442 var Buffer = moduleExports ? context.Buffer : undefined$1, 7443 Symbol = context.Symbol, 7444 Uint8Array = context.Uint8Array, 7445 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined$1, 7446 getPrototype = overArg(Object.getPrototypeOf, Object), 7447 objectCreate = Object.create, 7448 propertyIsEnumerable = objectProto.propertyIsEnumerable, 7449 splice = arrayProto.splice, 7450 spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined$1, 7451 symIterator = Symbol ? Symbol.iterator : undefined$1, 7452 symToStringTag = Symbol ? Symbol.toStringTag : undefined$1; 7453 7454 var defineProperty = (function() { 7455 try { 7456 var func = getNative(Object, 'defineProperty'); 7457 func({}, '', {}); 7458 return func; 7459 } catch (e) {} 7460 }()); 7461 7462 /** Mocked built-ins. */ 7463 var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, 7464 ctxNow = Date && Date.now !== root.Date.now && Date.now, 7465 ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout; 7466 7467 /* Built-in method references for those with the same name as other `lodash` methods. */ 7468 var nativeCeil = Math.ceil, 7469 nativeFloor = Math.floor, 7470 nativeGetSymbols = Object.getOwnPropertySymbols, 7471 nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined$1, 7472 nativeIsFinite = context.isFinite, 7473 nativeJoin = arrayProto.join, 7474 nativeKeys = overArg(Object.keys, Object), 7475 nativeMax = Math.max, 7476 nativeMin = Math.min, 7477 nativeNow = Date.now, 7478 nativeParseInt = context.parseInt, 7479 nativeRandom = Math.random, 7480 nativeReverse = arrayProto.reverse; 7481 7482 /* Built-in method references that are verified to be native. */ 7483 var DataView = getNative(context, 'DataView'), 7484 Map = getNative(context, 'Map'), 7485 Promise = getNative(context, 'Promise'), 7486 Set = getNative(context, 'Set'), 7487 WeakMap = getNative(context, 'WeakMap'), 7488 nativeCreate = getNative(Object, 'create'); 7489 7490 /** Used to store function metadata. */ 7491 var metaMap = WeakMap && new WeakMap; 7492 7493 /** Used to lookup unminified function names. */ 7494 var realNames = {}; 7495 7496 /** Used to detect maps, sets, and weakmaps. */ 7497 var dataViewCtorString = toSource(DataView), 7498 mapCtorString = toSource(Map), 7499 promiseCtorString = toSource(Promise), 7500 setCtorString = toSource(Set), 7501 weakMapCtorString = toSource(WeakMap); 7502 7503 /** Used to convert symbols to primitives and strings. */ 7504 var symbolProto = Symbol ? Symbol.prototype : undefined$1, 7505 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined$1, 7506 symbolToString = symbolProto ? symbolProto.toString : undefined$1; 7507 7508 /*------------------------------------------------------------------------*/ 7509 7510 /** 7511 * Creates a `lodash` object which wraps `value` to enable implicit method 7512 * chain sequences. Methods that operate on and return arrays, collections, 7513 * and functions can be chained together. Methods that retrieve a single value 7514 * or may return a primitive value will automatically end the chain sequence 7515 * and return the unwrapped value. Otherwise, the value must be unwrapped 7516 * with `_#value`. 7517 * 7518 * Explicit chain sequences, which must be unwrapped with `_#value`, may be 7519 * enabled using `_.chain`. 7520 * 7521 * The execution of chained methods is lazy, that is, it's deferred until 7522 * `_#value` is implicitly or explicitly called. 7523 * 7524 * Lazy evaluation allows several methods to support shortcut fusion. 7525 * Shortcut fusion is an optimization to merge iteratee calls; this avoids 7526 * the creation of intermediate arrays and can greatly reduce the number of 7527 * iteratee executions. Sections of a chain sequence qualify for shortcut 7528 * fusion if the section is applied to an array and iteratees accept only 7529 * one argument. The heuristic for whether a section qualifies for shortcut 7530 * fusion is subject to change. 7531 * 7532 * Chaining is supported in custom builds as long as the `_#value` method is 7533 * directly or indirectly included in the build. 7534 * 7535 * In addition to lodash methods, wrappers have `Array` and `String` methods. 7536 * 7537 * The wrapper `Array` methods are: 7538 * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` 7539 * 7540 * The wrapper `String` methods are: 7541 * `replace` and `split` 7542 * 7543 * The wrapper methods that support shortcut fusion are: 7544 * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, 7545 * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, 7546 * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` 7547 * 7548 * The chainable wrapper methods are: 7549 * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, 7550 * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, 7551 * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, 7552 * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, 7553 * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, 7554 * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, 7555 * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, 7556 * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, 7557 * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, 7558 * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, 7559 * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, 7560 * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, 7561 * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, 7562 * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, 7563 * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, 7564 * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, 7565 * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, 7566 * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, 7567 * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, 7568 * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, 7569 * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, 7570 * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, 7571 * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, 7572 * `zipObject`, `zipObjectDeep`, and `zipWith` 7573 * 7574 * The wrapper methods that are **not** chainable by default are: 7575 * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, 7576 * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, 7577 * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, 7578 * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, 7579 * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`, 7580 * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, 7581 * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, 7582 * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, 7583 * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, 7584 * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, 7585 * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, 7586 * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, 7587 * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, 7588 * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, 7589 * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, 7590 * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, 7591 * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, 7592 * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, 7593 * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, 7594 * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`, 7595 * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`, 7596 * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`, 7597 * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, 7598 * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, 7599 * `upperFirst`, `value`, and `words` 7600 * 7601 * @name _ 7602 * @constructor 7603 * @category Seq 7604 * @param {*} value The value to wrap in a `lodash` instance. 7605 * @returns {Object} Returns the new `lodash` wrapper instance. 7606 * @example 7607 * 7608 * function square(n) { 7609 * return n * n; 7610 * } 7611 * 7612 * var wrapped = _([1, 2, 3]); 7613 * 7614 * // Returns an unwrapped value. 7615 * wrapped.reduce(_.add); 7616 * // => 6 7617 * 7618 * // Returns a wrapped value. 7619 * var squares = wrapped.map(square); 7620 * 7621 * _.isArray(squares); 7622 * // => false 7623 * 7624 * _.isArray(squares.value()); 7625 * // => true 7626 */ 7627 function lodash(value) { 7628 if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { 7629 if (value instanceof LodashWrapper) { 7630 return value; 7631 } 7632 if (hasOwnProperty.call(value, '__wrapped__')) { 7633 return wrapperClone(value); 7634 } 7635 } 7636 return new LodashWrapper(value); 7637 } 7638 7639 /** 7640 * The base implementation of `_.create` without support for assigning 7641 * properties to the created object. 7642 * 7643 * @private 7644 * @param {Object} proto The object to inherit from. 7645 * @returns {Object} Returns the new object. 7646 */ 7647 var baseCreate = (function() { 7648 function object() {} 7649 return function(proto) { 7650 if (!isObject(proto)) { 7651 return {}; 7652 } 7653 if (objectCreate) { 7654 return objectCreate(proto); 7655 } 7656 object.prototype = proto; 7657 var result = new object; 7658 object.prototype = undefined$1; 7659 return result; 7660 }; 7661 }()); 7662 7663 /** 7664 * The function whose prototype chain sequence wrappers inherit from. 7665 * 7666 * @private 7667 */ 7668 function baseLodash() { 7669 // No operation performed. 7670 } 7671 7672 /** 7673 * The base constructor for creating `lodash` wrapper objects. 7674 * 7675 * @private 7676 * @param {*} value The value to wrap. 7677 * @param {boolean} [chainAll] Enable explicit method chain sequences. 7678 */ 7679 function LodashWrapper(value, chainAll) { 7680 this.__wrapped__ = value; 7681 this.__actions__ = []; 7682 this.__chain__ = !!chainAll; 7683 this.__index__ = 0; 7684 this.__values__ = undefined$1; 7685 } 7686 7687 /** 7688 * By default, the template delimiters used by lodash are like those in 7689 * embedded Ruby (ERB) as well as ES2015 template strings. Change the 7690 * following template settings to use alternative delimiters. 7691 * 7692 * @static 7693 * @memberOf _ 7694 * @type {Object} 7695 */ 7696 lodash.templateSettings = { 7697 7698 /** 7699 * Used to detect `data` property values to be HTML-escaped. 7700 * 7701 * @memberOf _.templateSettings 7702 * @type {RegExp} 7703 */ 7704 'escape': reEscape, 7705 7706 /** 7707 * Used to detect code to be evaluated. 7708 * 7709 * @memberOf _.templateSettings 7710 * @type {RegExp} 7711 */ 7712 'evaluate': reEvaluate, 7713 7714 /** 7715 * Used to detect `data` property values to inject. 7716 * 7717 * @memberOf _.templateSettings 7718 * @type {RegExp} 7719 */ 7720 'interpolate': reInterpolate, 7721 7722 /** 7723 * Used to reference the data object in the template text. 7724 * 7725 * @memberOf _.templateSettings 7726 * @type {string} 7727 */ 7728 'variable': '', 7729 7730 /** 7731 * Used to import variables into the compiled template. 7732 * 7733 * @memberOf _.templateSettings 7734 * @type {Object} 7735 */ 7736 'imports': { 7737 7738 /** 7739 * A reference to the `lodash` function. 7740 * 7741 * @memberOf _.templateSettings.imports 7742 * @type {Function} 7743 */ 7744 '_': lodash 7745 } 7746 }; 7747 7748 // Ensure wrappers are instances of `baseLodash`. 7749 lodash.prototype = baseLodash.prototype; 7750 lodash.prototype.constructor = lodash; 7751 7752 LodashWrapper.prototype = baseCreate(baseLodash.prototype); 7753 LodashWrapper.prototype.constructor = LodashWrapper; 7754 7755 /*------------------------------------------------------------------------*/ 7756 7757 /** 7758 * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. 7759 * 7760 * @private 7761 * @constructor 7762 * @param {*} value The value to wrap. 7763 */ 7764 function LazyWrapper(value) { 7765 this.__wrapped__ = value; 7766 this.__actions__ = []; 7767 this.__dir__ = 1; 7768 this.__filtered__ = false; 7769 this.__iteratees__ = []; 7770 this.__takeCount__ = MAX_ARRAY_LENGTH; 7771 this.__views__ = []; 7772 } 7773 7774 /** 7775 * Creates a clone of the lazy wrapper object. 7776 * 7777 * @private 7778 * @name clone 7779 * @memberOf LazyWrapper 7780 * @returns {Object} Returns the cloned `LazyWrapper` object. 7781 */ 7782 function lazyClone() { 7783 var result = new LazyWrapper(this.__wrapped__); 7784 result.__actions__ = copyArray(this.__actions__); 7785 result.__dir__ = this.__dir__; 7786 result.__filtered__ = this.__filtered__; 7787 result.__iteratees__ = copyArray(this.__iteratees__); 7788 result.__takeCount__ = this.__takeCount__; 7789 result.__views__ = copyArray(this.__views__); 7790 return result; 7791 } 7792 7793 /** 7794 * Reverses the direction of lazy iteration. 7795 * 7796 * @private 7797 * @name reverse 7798 * @memberOf LazyWrapper 7799 * @returns {Object} Returns the new reversed `LazyWrapper` object. 7800 */ 7801 function lazyReverse() { 7802 if (this.__filtered__) { 7803 var result = new LazyWrapper(this); 7804 result.__dir__ = -1; 7805 result.__filtered__ = true; 7806 } else { 7807 result = this.clone(); 7808 result.__dir__ *= -1; 7809 } 7810 return result; 7811 } 7812 7813 /** 7814 * Extracts the unwrapped value from its lazy wrapper. 7815 * 7816 * @private 7817 * @name value 7818 * @memberOf LazyWrapper 7819 * @returns {*} Returns the unwrapped value. 7820 */ 7821 function lazyValue() { 7822 var array = this.__wrapped__.value(), 7823 dir = this.__dir__, 7824 isArr = isArray(array), 7825 isRight = dir < 0, 7826 arrLength = isArr ? array.length : 0, 7827 view = getView(0, arrLength, this.__views__), 7828 start = view.start, 7829 end = view.end, 7830 length = end - start, 7831 index = isRight ? end : (start - 1), 7832 iteratees = this.__iteratees__, 7833 iterLength = iteratees.length, 7834 resIndex = 0, 7835 takeCount = nativeMin(length, this.__takeCount__); 7836 7837 if (!isArr || (!isRight && arrLength == length && takeCount == length)) { 7838 return baseWrapperValue(array, this.__actions__); 7839 } 7840 var result = []; 7841 7842 outer: 7843 while (length-- && resIndex < takeCount) { 7844 index += dir; 7845 7846 var iterIndex = -1, 7847 value = array[index]; 7848 7849 while (++iterIndex < iterLength) { 7850 var data = iteratees[iterIndex], 7851 iteratee = data.iteratee, 7852 type = data.type, 7853 computed = iteratee(value); 7854 7855 if (type == LAZY_MAP_FLAG) { 7856 value = computed; 7857 } else if (!computed) { 7858 if (type == LAZY_FILTER_FLAG) { 7859 continue outer; 7860 } else { 7861 break outer; 7862 } 7863 } 7864 } 7865 result[resIndex++] = value; 7866 } 7867 return result; 7868 } 7869 7870 // Ensure `LazyWrapper` is an instance of `baseLodash`. 7871 LazyWrapper.prototype = baseCreate(baseLodash.prototype); 7872 LazyWrapper.prototype.constructor = LazyWrapper; 7873 7874 /*------------------------------------------------------------------------*/ 7875 7876 /** 7877 * Creates a hash object. 7878 * 7879 * @private 7880 * @constructor 7881 * @param {Array} [entries] The key-value pairs to cache. 7882 */ 7883 function Hash(entries) { 7884 var index = -1, 7885 length = entries == null ? 0 : entries.length; 7886 7887 this.clear(); 7888 while (++index < length) { 7889 var entry = entries[index]; 7890 this.set(entry[0], entry[1]); 7891 } 7892 } 7893 7894 /** 7895 * Removes all key-value entries from the hash. 7896 * 7897 * @private 7898 * @name clear 7899 * @memberOf Hash 7900 */ 7901 function hashClear() { 7902 this.__data__ = nativeCreate ? nativeCreate(null) : {}; 7903 this.size = 0; 7904 } 7905 7906 /** 7907 * Removes `key` and its value from the hash. 7908 * 7909 * @private 7910 * @name delete 7911 * @memberOf Hash 7912 * @param {Object} hash The hash to modify. 7913 * @param {string} key The key of the value to remove. 7914 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 7915 */ 7916 function hashDelete(key) { 7917 var result = this.has(key) && delete this.__data__[key]; 7918 this.size -= result ? 1 : 0; 7919 return result; 7920 } 7921 7922 /** 7923 * Gets the hash value for `key`. 7924 * 7925 * @private 7926 * @name get 7927 * @memberOf Hash 7928 * @param {string} key The key of the value to get. 7929 * @returns {*} Returns the entry value. 7930 */ 7931 function hashGet(key) { 7932 var data = this.__data__; 7933 if (nativeCreate) { 7934 var result = data[key]; 7935 return result === HASH_UNDEFINED ? undefined$1 : result; 7936 } 7937 return hasOwnProperty.call(data, key) ? data[key] : undefined$1; 7938 } 7939 7940 /** 7941 * Checks if a hash value for `key` exists. 7942 * 7943 * @private 7944 * @name has 7945 * @memberOf Hash 7946 * @param {string} key The key of the entry to check. 7947 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 7948 */ 7949 function hashHas(key) { 7950 var data = this.__data__; 7951 return nativeCreate ? (data[key] !== undefined$1) : hasOwnProperty.call(data, key); 7952 } 7953 7954 /** 7955 * Sets the hash `key` to `value`. 7956 * 7957 * @private 7958 * @name set 7959 * @memberOf Hash 7960 * @param {string} key The key of the value to set. 7961 * @param {*} value The value to set. 7962 * @returns {Object} Returns the hash instance. 7963 */ 7964 function hashSet(key, value) { 7965 var data = this.__data__; 7966 this.size += this.has(key) ? 0 : 1; 7967 data[key] = (nativeCreate && value === undefined$1) ? HASH_UNDEFINED : value; 7968 return this; 7969 } 7970 7971 // Add methods to `Hash`. 7972 Hash.prototype.clear = hashClear; 7973 Hash.prototype['delete'] = hashDelete; 7974 Hash.prototype.get = hashGet; 7975 Hash.prototype.has = hashHas; 7976 Hash.prototype.set = hashSet; 7977 7978 /*------------------------------------------------------------------------*/ 7979 7980 /** 7981 * Creates an list cache object. 7982 * 7983 * @private 7984 * @constructor 7985 * @param {Array} [entries] The key-value pairs to cache. 7986 */ 7987 function ListCache(entries) { 7988 var index = -1, 7989 length = entries == null ? 0 : entries.length; 7990 7991 this.clear(); 7992 while (++index < length) { 7993 var entry = entries[index]; 7994 this.set(entry[0], entry[1]); 7995 } 7996 } 7997 7998 /** 7999 * Removes all key-value entries from the list cache. 8000 * 8001 * @private 8002 * @name clear 8003 * @memberOf ListCache 8004 */ 8005 function listCacheClear() { 8006 this.__data__ = []; 8007 this.size = 0; 8008 } 8009 8010 /** 8011 * Removes `key` and its value from the list cache. 8012 * 8013 * @private 8014 * @name delete 8015 * @memberOf ListCache 8016 * @param {string} key The key of the value to remove. 8017 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 8018 */ 8019 function listCacheDelete(key) { 8020 var data = this.__data__, 8021 index = assocIndexOf(data, key); 8022 8023 if (index < 0) { 8024 return false; 8025 } 8026 var lastIndex = data.length - 1; 8027 if (index == lastIndex) { 8028 data.pop(); 8029 } else { 8030 splice.call(data, index, 1); 8031 } 8032 --this.size; 8033 return true; 8034 } 8035 8036 /** 8037 * Gets the list cache value for `key`. 8038 * 8039 * @private 8040 * @name get 8041 * @memberOf ListCache 8042 * @param {string} key The key of the value to get. 8043 * @returns {*} Returns the entry value. 8044 */ 8045 function listCacheGet(key) { 8046 var data = this.__data__, 8047 index = assocIndexOf(data, key); 8048 8049 return index < 0 ? undefined$1 : data[index][1]; 8050 } 8051 8052 /** 8053 * Checks if a list cache value for `key` exists. 8054 * 8055 * @private 8056 * @name has 8057 * @memberOf ListCache 8058 * @param {string} key The key of the entry to check. 8059 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 8060 */ 8061 function listCacheHas(key) { 8062 return assocIndexOf(this.__data__, key) > -1; 8063 } 8064 8065 /** 8066 * Sets the list cache `key` to `value`. 8067 * 8068 * @private 8069 * @name set 8070 * @memberOf ListCache 8071 * @param {string} key The key of the value to set. 8072 * @param {*} value The value to set. 8073 * @returns {Object} Returns the list cache instance. 8074 */ 8075 function listCacheSet(key, value) { 8076 var data = this.__data__, 8077 index = assocIndexOf(data, key); 8078 8079 if (index < 0) { 8080 ++this.size; 8081 data.push([key, value]); 8082 } else { 8083 data[index][1] = value; 8084 } 8085 return this; 8086 } 8087 8088 // Add methods to `ListCache`. 8089 ListCache.prototype.clear = listCacheClear; 8090 ListCache.prototype['delete'] = listCacheDelete; 8091 ListCache.prototype.get = listCacheGet; 8092 ListCache.prototype.has = listCacheHas; 8093 ListCache.prototype.set = listCacheSet; 8094 8095 /*------------------------------------------------------------------------*/ 8096 8097 /** 8098 * Creates a map cache object to store key-value pairs. 8099 * 8100 * @private 8101 * @constructor 8102 * @param {Array} [entries] The key-value pairs to cache. 8103 */ 8104 function MapCache(entries) { 8105 var index = -1, 8106 length = entries == null ? 0 : entries.length; 8107 8108 this.clear(); 8109 while (++index < length) { 8110 var entry = entries[index]; 8111 this.set(entry[0], entry[1]); 8112 } 8113 } 8114 8115 /** 8116 * Removes all key-value entries from the map. 8117 * 8118 * @private 8119 * @name clear 8120 * @memberOf MapCache 8121 */ 8122 function mapCacheClear() { 8123 this.size = 0; 8124 this.__data__ = { 8125 'hash': new Hash, 8126 'map': new (Map || ListCache), 8127 'string': new Hash 8128 }; 8129 } 8130 8131 /** 8132 * Removes `key` and its value from the map. 8133 * 8134 * @private 8135 * @name delete 8136 * @memberOf MapCache 8137 * @param {string} key The key of the value to remove. 8138 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 8139 */ 8140 function mapCacheDelete(key) { 8141 var result = getMapData(this, key)['delete'](key); 8142 this.size -= result ? 1 : 0; 8143 return result; 8144 } 8145 8146 /** 8147 * Gets the map value for `key`. 8148 * 8149 * @private 8150 * @name get 8151 * @memberOf MapCache 8152 * @param {string} key The key of the value to get. 8153 * @returns {*} Returns the entry value. 8154 */ 8155 function mapCacheGet(key) { 8156 return getMapData(this, key).get(key); 8157 } 8158 8159 /** 8160 * Checks if a map value for `key` exists. 8161 * 8162 * @private 8163 * @name has 8164 * @memberOf MapCache 8165 * @param {string} key The key of the entry to check. 8166 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 8167 */ 8168 function mapCacheHas(key) { 8169 return getMapData(this, key).has(key); 8170 } 8171 8172 /** 8173 * Sets the map `key` to `value`. 8174 * 8175 * @private 8176 * @name set 8177 * @memberOf MapCache 8178 * @param {string} key The key of the value to set. 8179 * @param {*} value The value to set. 8180 * @returns {Object} Returns the map cache instance. 8181 */ 8182 function mapCacheSet(key, value) { 8183 var data = getMapData(this, key), 8184 size = data.size; 8185 8186 data.set(key, value); 8187 this.size += data.size == size ? 0 : 1; 8188 return this; 8189 } 8190 8191 // Add methods to `MapCache`. 8192 MapCache.prototype.clear = mapCacheClear; 8193 MapCache.prototype['delete'] = mapCacheDelete; 8194 MapCache.prototype.get = mapCacheGet; 8195 MapCache.prototype.has = mapCacheHas; 8196 MapCache.prototype.set = mapCacheSet; 8197 8198 /*------------------------------------------------------------------------*/ 8199 8200 /** 8201 * 8202 * Creates an array cache object to store unique values. 8203 * 8204 * @private 8205 * @constructor 8206 * @param {Array} [values] The values to cache. 8207 */ 8208 function SetCache(values) { 8209 var index = -1, 8210 length = values == null ? 0 : values.length; 8211 8212 this.__data__ = new MapCache; 8213 while (++index < length) { 8214 this.add(values[index]); 8215 } 8216 } 8217 8218 /** 8219 * Adds `value` to the array cache. 8220 * 8221 * @private 8222 * @name add 8223 * @memberOf SetCache 8224 * @alias push 8225 * @param {*} value The value to cache. 8226 * @returns {Object} Returns the cache instance. 8227 */ 8228 function setCacheAdd(value) { 8229 this.__data__.set(value, HASH_UNDEFINED); 8230 return this; 8231 } 8232 8233 /** 8234 * Checks if `value` is in the array cache. 8235 * 8236 * @private 8237 * @name has 8238 * @memberOf SetCache 8239 * @param {*} value The value to search for. 8240 * @returns {
8240number
vendor: 69,099 bytes, lines 8240-10236
8240} Returns `true` if `value` is found, else `false`. 8241 */ 8242 function setCacheHas(value) { 8243 return this.__data__.has(value); 8244 } 8245 8246 // Add methods to `SetCache`. 8247 SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; 8248 SetCache.prototype.has = setCacheHas; 8249 8250 /*------------------------------------------------------------------------*/ 8251 8252 /** 8253 * Creates a stack cache object to store key-value pairs. 8254 * 8255 * @private 8256 * @constructor 8257 * @param {Array} [entries] The key-value pairs to cache. 8258 */ 8259 function Stack(entries) { 8260 var data = this.__data__ = new ListCache(entries); 8261 this.size = data.size; 8262 } 8263 8264 /** 8265 * Removes all key-value entries from the stack. 8266 * 8267 * @private 8268 * @name clear 8269 * @memberOf Stack 8270 */ 8271 function stackClear() { 8272 this.__data__ = new ListCache; 8273 this.size = 0; 8274 } 8275 8276 /** 8277 * Removes `key` and its value from the stack. 8278 * 8279 * @private 8280 * @name delete 8281 * @memberOf Stack 8282 * @param {string} key The key of the value to remove. 8283 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 8284 */ 8285 function stackDelete(key) { 8286 var data = this.__data__, 8287 result = data['delete'](key); 8288 8289 this.size = data.size; 8290 return result; 8291 } 8292 8293 /** 8294 * Gets the stack value for `key`. 8295 * 8296 * @private 8297 * @name get 8298 * @memberOf Stack 8299 * @param {string} key The key of the value to get. 8300 * @returns {*} Returns the entry value. 8301 */ 8302 function stackGet(key) { 8303 return this.__data__.get(key); 8304 } 8305 8306 /** 8307 * Checks if a stack value for `key` exists. 8308 * 8309 * @private 8310 * @name has 8311 * @memberOf Stack 8312 * @param {string} key The key of the entry to check. 8313 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 8314 */ 8315 function stackHas(key) { 8316 return this.__data__.has(key); 8317 } 8318 8319 /** 8320 * Sets the stack `key` to `value`. 8321 * 8322 * @private 8323 * @name set 8324 * @memberOf Stack 8325 * @param {string} key The key of the value to set. 8326 * @param {*} value The value to set. 8327 * @returns {Object} Returns the stack cache instance. 8328 */ 8329 function stackSet(key, value) { 8330 var data = this.__data__; 8331 if (data instanceof ListCache) { 8332 var pairs = data.__data__; 8333 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { 8334 pairs.push([key, value]); 8335 this.size = ++data.size; 8336 return this; 8337 } 8338 data = this.__data__ = new MapCache(pairs); 8339 } 8340 data.set(key, value); 8341 this.size = data.size; 8342 return this; 8343 } 8344 8345 // Add methods to `Stack`. 8346 Stack.prototype.clear = stackClear; 8347 Stack.prototype['delete'] = stackDelete; 8348 Stack.prototype.get = stackGet; 8349 Stack.prototype.has = stackHas; 8350 Stack.prototype.set = stackSet; 8351 8352 /*------------------------------------------------------------------------*/ 8353 8354 /** 8355 * Creates an array of the enumerable property names of the array-like `value`. 8356 * 8357 * @private 8358 * @param {*} value The value to query. 8359 * @param {boolean} inherited Specify returning inherited property names. 8360 * @returns {Array} Returns the array of property names. 8361 */ 8362 function arrayLikeKeys(value, inherited) { 8363 var isArr = isArray(value), 8364 isArg = !isArr && isArguments(value), 8365 isBuff = !isArr && !isArg && isBuffer(value), 8366 isType = !isArr && !isArg && !isBuff && isTypedArray(value), 8367 skipIndexes = isArr || isArg || isBuff || isType, 8368 result = skipIndexes ? baseTimes(value.length, String) : [], 8369 length = result.length; 8370 8371 for (var key in value) { 8372 if ((inherited || hasOwnProperty.call(value, key)) && 8373 !(skipIndexes && ( 8374 // Safari 9 has enumerable `arguments.length` in strict mode. 8375 key == 'length' || 8376 // Node.js 0.10 has enumerable non-index properties on buffers. 8377 (isBuff && (key == 'offset' || key == 'parent')) || 8378 // PhantomJS 2 has enumerable non-index properties on typed arrays. 8379 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || 8380 // Skip index properties. 8381 isIndex(key, length) 8382 ))) { 8383 result.push(key); 8384 } 8385 } 8386 return result; 8387 } 8388 8389 /** 8390 * A specialized version of `_.sample` for arrays. 8391 * 8392 * @private 8393 * @param {Array} array The array to sample. 8394 * @returns {*} Returns the random element. 8395 */ 8396 function arraySample(array) { 8397 var length = array.length; 8398 return length ? array[baseRandom(0, length - 1)] : undefined$1; 8399 } 8400 8401 /** 8402 * A specialized version of `_.sampleSize` for arrays. 8403 * 8404 * @private 8405 * @param {Array} array The array to sample. 8406 * @param {number} n The number of elements to sample. 8407 * @returns {Array} Returns the random elements. 8408 */ 8409 function arraySampleSize(array, n) { 8410 return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length)); 8411 } 8412 8413 /** 8414 * A specialized version of `_.shuffle` for arrays. 8415 * 8416 * @private 8417 * @param {Array} array The array to shuffle. 8418 * @returns {Array} Returns the new shuffled array. 8419 */ 8420 function arrayShuffle(array) { 8421 return shuffleSelf(copyArray(array)); 8422 } 8423 8424 /** 8425 * This function is like `assignValue` except that it doesn't assign 8426 * `undefined` values. 8427 * 8428 * @private 8429 * @param {Object} object The object to modify. 8430 * @param {string} key The key of the property to assign. 8431 * @param {*} value The value to assign. 8432 */ 8433 function assignMergeValue(object, key, value) { 8434 if ((value !== undefined$1 && !eq(object[key], value)) || 8435 (value === undefined$1 && !(key in object))) { 8436 baseAssignValue(object, key, value); 8437 } 8438 } 8439 8440 /** 8441 * Assigns `value` to `key` of `object` if the existing value is not equivalent 8442 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 8443 * for equality comparisons. 8444 * 8445 * @private 8446 * @param {Object} object The object to modify. 8447 * @param {string} key The key of the property to assign. 8448 * @param {*} value The value to assign. 8449 */ 8450 function assignValue(object, key, value) { 8451 var objValue = object[key]; 8452 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || 8453 (value === undefined$1 && !(key in object))) { 8454 baseAssignValue(object, key, value); 8455 } 8456 } 8457 8458 /** 8459 * Gets the index at which the `key` is found in `array` of key-value pairs. 8460 * 8461 * @private 8462 * @param {Array} array The array to inspect. 8463 * @param {*} key The key to search for. 8464 * @returns {number} Returns the index of the matched value, else `-1`. 8465 */ 8466 function assocIndexOf(array, key) { 8467 var length = array.length; 8468 while (length--) { 8469 if (eq(array[length][0], key)) { 8470 return length; 8471 } 8472 } 8473 return -1; 8474 } 8475 8476 /** 8477 * Aggregates elements of `collection` on `accumulator` with keys transformed 8478 * by `iteratee` and values set by `setter`. 8479 * 8480 * @private 8481 * @param {Array|Object} collection The collection to iterate over. 8482 * @param {Function} setter The function to set `accumulator` values. 8483 * @param {Function} iteratee The iteratee to transform keys. 8484 * @param {Object} accumulator The initial aggregated object. 8485 * @returns {Function} Returns `accumulator`. 8486 */ 8487 function baseAggregator(collection, setter, iteratee, accumulator) { 8488 baseEach(collection, function(value, key, collection) { 8489 setter(accumulator, value, iteratee(value), collection); 8490 }); 8491 return accumulator; 8492 } 8493 8494 /** 8495 * The base implementation of `_.assign` without support for multiple sources 8496 * or `customizer` functions. 8497 * 8498 * @private 8499 * @param {Object} object The destination object. 8500 * @param {Object} source The source object. 8501 * @returns {Object} Returns `object`. 8502 */ 8503 function baseAssign(object, source) { 8504 return object && copyObject(source, keys(source), object); 8505 } 8506 8507 /** 8508 * The base implementation of `_.assignIn` without support for multiple sources 8509 * or `customizer` functions. 8510 * 8511 * @private 8512 * @param {Object} object The destination object. 8513 * @param {Object} source The source object. 8514 * @returns {Object} Returns `object`. 8515 */ 8516 function baseAssignIn(object, source) { 8517 return object && copyObject(source, keysIn(source), object); 8518 } 8519 8520 /** 8521 * The base implementation of `assignValue` and `assignMergeValue` without 8522 * value checks. 8523 * 8524 * @private 8525 * @param {Object} object The object to modify. 8526 * @param {string} key The key of the property to assign. 8527 * @param {*} value The value to assign. 8528 */ 8529 function baseAssignValue(object, key, value) { 8530 if (key == '__proto__' && defineProperty) { 8531 defineProperty(object, key, { 8532 'configurable': true, 8533 'enumerable': true, 8534 'value': value, 8535 'writable': true 8536 }); 8537 } else { 8538 object[key] = value; 8539 } 8540 } 8541 8542 /** 8543 * The base implementation of `_.at` without support for individual paths. 8544 * 8545 * @private 8546 * @param {Object} object The object to iterate over. 8547 * @param {string[]} paths The property paths to pick. 8548 * @returns {Array} Returns the picked elements. 8549 */ 8550 function baseAt(object, paths) { 8551 var index = -1, 8552 length = paths.length, 8553 result = Array(length), 8554 skip = object == null; 8555 8556 while (++index < length) { 8557 result[index] = skip ? undefined$1 : get(object, paths[index]); 8558 } 8559 return result; 8560 } 8561 8562 /** 8563 * The base implementation of `_.clamp` which doesn't coerce arguments. 8564 * 8565 * @private 8566 * @param {number} number The number to clamp. 8567 * @param {number} [lower] The lower bound. 8568 * @param {number} upper The upper bound. 8569 * @returns {number} Returns the clamped number. 8570 */ 8571 function baseClamp(number, lower, upper) { 8572 if (number === number) { 8573 if (upper !== undefined$1) { 8574 number = number <= upper ? number : upper; 8575 } 8576 if (lower !== undefined$1) { 8577 number = number >= lower ? number : lower; 8578 } 8579 } 8580 return number; 8581 } 8582 8583 /** 8584 * The base implementation of `_.clone` and `_.cloneDeep` which tracks 8585 * traversed objects. 8586 * 8587 * @private 8588 * @param {*} value The value to clone. 8589 * @param {boolean} bitmask The bitmask flags. 8590 * 1 - Deep clone 8591 * 2 - Flatten inherited properties 8592 * 4 - Clone symbols 8593 * @param {Function} [customizer] The function to customize cloning. 8594 * @param {string} [key] The key of `value`. 8595 * @param {Object} [object] The parent object of `value`. 8596 * @param {Object} [stack] Tracks traversed objects and their clone counterparts. 8597 * @returns {*} Returns the cloned value. 8598 */ 8599 function baseClone(value, bitmask, customizer, key, object, stack) { 8600 var result, 8601 isDeep = bitmask & CLONE_DEEP_FLAG, 8602 isFlat = bitmask & CLONE_FLAT_FLAG, 8603 isFull = bitmask & CLONE_SYMBOLS_FLAG; 8604 8605 if (customizer) { 8606 result = object ? customizer(value, key, object, stack) : customizer(value); 8607 } 8608 if (result !== undefined$1) { 8609 return result; 8610 } 8611 if (!isObject(value)) { 8612 return value; 8613 } 8614 var isArr = isArray(value); 8615 if (isArr) { 8616 result = initCloneArray(value); 8617 if (!isDeep) { 8618 return copyArray(value, result); 8619 } 8620 } else { 8621 var tag = getTag(value), 8622 isFunc = tag == funcTag || tag == genTag; 8623 8624 if (isBuffer(value)) { 8625 return cloneBuffer(value, isDeep); 8626 } 8627 if (tag == objectTag || tag == argsTag || (isFunc && !object)) { 8628 result = (isFlat || isFunc) ? {} : initCloneObject(value); 8629 if (!isDeep) { 8630 return isFlat 8631 ? copySymbolsIn(value, baseAssignIn(result, value)) 8632 : copySymbols(value, baseAssign(result, value)); 8633 } 8634 } else { 8635 if (!cloneableTags[tag]) { 8636 return object ? value : {}; 8637 } 8638 result = initCloneByTag(value, tag, isDeep); 8639 } 8640 } 8641 // Check for circular references and return its corresponding clone. 8642 stack || (stack = new Stack); 8643 var stacked = stack.get(value); 8644 if (stacked) { 8645 return stacked; 8646 } 8647 stack.set(value, result); 8648 8649 if (isSet(value)) { 8650 value.forEach(function(subValue) { 8651 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); 8652 }); 8653 } else if (isMap(value)) { 8654 value.forEach(function(subValue, key) { 8655 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); 8656 }); 8657 } 8658 8659 var keysFunc = isFull 8660 ? (isFlat ? getAllKeysIn : getAllKeys) 8661 : (isFlat ? keysIn : keys); 8662 8663 var props = isArr ? undefined$1 : keysFunc(value); 8664 arrayEach(props || value, function(subValue, key) { 8665 if (props) { 8666 key = subValue; 8667 subValue = value[key]; 8668 } 8669 // Recursively populate clone (susceptible to call stack limits). 8670 assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); 8671 }); 8672 return result; 8673 } 8674 8675 /** 8676 * The base implementation of `_.conforms` which doesn't clone `source`. 8677 * 8678 * @private 8679 * @param {Object} source The object of property predicates to conform to. 8680 * @returns {Function} Returns the new spec function. 8681 */ 8682 function baseConforms(source) { 8683 var props = keys(source); 8684 return function(object) { 8685 return baseConformsTo(object, source, props); 8686 }; 8687 } 8688 8689 /** 8690 * The base implementation of `_.conformsTo` which accepts `props` to check. 8691 * 8692 * @private 8693 * @param {Object} object The object to inspect. 8694 * @param {Object} source The object of property predicates to conform to. 8695 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 8696 */ 8697 function baseConformsTo(object, source, props) { 8698 var length = props.length; 8699 if (object == null) { 8700 return !length; 8701 } 8702 object = Object(object); 8703 while (length--) { 8704 var key = props[length], 8705 predicate = source[key], 8706 value = object[key]; 8707 8708 if ((value === undefined$1 && !(key in object)) || !predicate(value)) { 8709 return false; 8710 } 8711 } 8712 return true; 8713 } 8714 8715 /** 8716 * The base implementation of `_.delay` and `_.defer` which accepts `args` 8717 * to provide to `func`. 8718 * 8719 * @private 8720 * @param {Function} func The function to delay. 8721 * @param {number} wait The number of milliseconds to delay invocation. 8722 * @param {Array} args The arguments to provide to `func`. 8723 * @returns {number|Object} Returns the timer id or timeout object. 8724 */ 8725 function baseDelay(func, wait, args) { 8726 if (typeof func != 'function') { 8727 throw new TypeError(FUNC_ERROR_TEXT); 8728 } 8729 return setTimeout(function() { func.apply(undefined$1, args); }, wait); 8730 } 8731 8732 /** 8733 * The base implementation of methods like `_.difference` without support 8734 * for excluding multiple arrays or iteratee shorthands. 8735 * 8736 * @private 8737 * @param {Array} array The array to inspect. 8738 * @param {Array} values The values to exclude. 8739 * @param {Function} [iteratee] The iteratee invoked per element. 8740 * @param {Function} [comparator] The comparator invoked per element. 8741 * @returns {Array} Returns the new array of filtered values. 8742 */ 8743 function baseDifference(array, values, iteratee, comparator) { 8744 var index = -1, 8745 includes = arrayIncludes, 8746 isCommon = true, 8747 length = array.length, 8748 result = [], 8749 valuesLength = values.length; 8750 8751 if (!length) { 8752 return result; 8753 } 8754 if (iteratee) { 8755 values = arrayMap(values, baseUnary(iteratee)); 8756 } 8757 if (comparator) { 8758 includes = arrayIncludesWith; 8759 isCommon = false; 8760 } 8761 else if (values.length >= LARGE_ARRAY_SIZE) { 8762 includes = cacheHas; 8763 isCommon = false; 8764 values = new SetCache(values); 8765 } 8766 outer: 8767 while (++index < length) { 8768 var value = array[index], 8769 computed = iteratee == null ? value : iteratee(value); 8770 8771 value = (comparator || value !== 0) ? value : 0; 8772 if (isCommon && computed === computed) { 8773 var valuesIndex = valuesLength; 8774 while (valuesIndex--) { 8775 if (values[valuesIndex] === computed) { 8776 continue outer; 8777 } 8778 } 8779 result.push(value); 8780 } 8781 else if (!includes(values, computed, comparator)) { 8782 result.push(value); 8783 } 8784 } 8785 return result; 8786 } 8787 8788 /** 8789 * The base implementation of `_.forEach` without support for iteratee shorthands. 8790 * 8791 * @private 8792 * @param {Array|Object} collection The collection to iterate over. 8793 * @param {Function} iteratee The function invoked per iteration. 8794 * @returns {Array|Object} Returns `collection`. 8795 */ 8796 var baseEach = createBaseEach(baseForOwn); 8797 8798 /** 8799 * The base implementation of `_.forEachRight` without support for iteratee shorthands. 8800 * 8801 * @private 8802 * @param {Array|Object} collection The collection to iterate over. 8803 * @param {Function} iteratee The function invoked per iteration. 8804 * @returns {Array|Object} Returns `collection`. 8805 */ 8806 var baseEachRight = createBaseEach(baseForOwnRight, true); 8807 8808 /** 8809 * The base implementation of `_.every` without support for iteratee shorthands. 8810 * 8811 * @private 8812 * @param {Array|Object} collection The collection to iterate over. 8813 * @param {Function} predicate The function invoked per iteration. 8814 * @returns {boolean} Returns `true` if all elements pass the predicate check, 8815 * else `false` 8816 */ 8817 function baseEvery(collection, predicate) { 8818 var result = true; 8819 baseEach(collection, function(value, index, collection) { 8820 result = !!predicate(value, index, collection); 8821 return result; 8822 }); 8823 return result; 8824 } 8825 8826 /** 8827 * The base implementation of methods like `_.max` and `_.min` which accepts a 8828 * `comparator` to determine the extremum value. 8829 * 8830 * @private 8831 * @param {Array} array The array to iterate over. 8832 * @param {Function} iteratee The iteratee invoked per iteration. 8833 * @param {Function} comparator The comparator used to compare values. 8834 * @returns {*} Returns the extremum value. 8835 */ 8836 function baseExtremum(array, iteratee, comparator) { 8837 var index = -1, 8838 length = array.length; 8839 8840 while (++index < length) { 8841 var value = array[index], 8842 current = iteratee(value); 8843 8844 if (current != null && (computed === undefined$1 8845 ? (current === current && !isSymbol(current)) 8846 : comparator(current, computed) 8847 )) { 8848 var computed = current, 8849 result = value; 8850 } 8851 } 8852 return result; 8853 } 8854 8855 /** 8856 * The base implementation of `_.fill` without an iteratee call guard. 8857 * 8858 * @private 8859 * @param {Array} array The array to fill. 8860 * @param {*} value The value to fill `array` with. 8861 * @param {number} [start=0] The start position. 8862 * @param {number} [end=array.length] The end position. 8863 * @returns {Array} Returns `array`. 8864 */ 8865 function baseFill(array, value, start, end) { 8866 var length = array.length; 8867 8868 start = toInteger(start); 8869 if (start < 0) { 8870 start = -start > length ? 0 : (length + start); 8871 } 8872 end = (end === undefined$1 || end > length) ? length : toInteger(end); 8873 if (end < 0) { 8874 end += length; 8875 } 8876 end = start > end ? 0 : toLength(end); 8877 while (start < end) { 8878 array[start++] = value; 8879 } 8880 return array; 8881 } 8882 8883 /** 8884 * The base implementation of `_.filter` without support for iteratee shorthands. 8885 * 8886 * @private 8887 * @param {Array|Object} collection The collection to iterate over. 8888 * @param {Function} predicate The function invoked per iteration. 8889 * @returns {Array} Returns the new filtered array. 8890 */ 8891 function baseFilter(collection, predicate) { 8892 var result = []; 8893 baseEach(collection, function(value, index, collection) { 8894 if (predicate(value, index, collection)) { 8895 result.push(value); 8896 } 8897 }); 8898 return result; 8899 } 8900 8901 /** 8902 * The base implementation of `_.flatten` with support for restricting flattening. 8903 * 8904 * @private 8905 * @param {Array} array The array to flatten. 8906 * @param {number} depth The maximum recursion depth. 8907 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. 8908 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. 8909 * @param {Array} [result=[]] The initial result value. 8910 * @returns {Array} Returns the new flattened array. 8911 */ 8912 function baseFlatten(array, depth, predicate, isStrict, result) { 8913 var index = -1, 8914 length = array.length; 8915 8916 predicate || (predicate = isFlattenable); 8917 result || (result = []); 8918 8919 while (++index < length) { 8920 var value = array[index]; 8921 if (depth > 0 && predicate(value)) { 8922 if (depth > 1) { 8923 // Recursively flatten arrays (susceptible to call stack limits). 8924 baseFlatten(value, depth - 1, predicate, isStrict, result); 8925 } else { 8926 arrayPush(result, value); 8927 } 8928 } else if (!isStrict) { 8929 result[result.length] = value; 8930 } 8931 } 8932 return result; 8933 } 8934 8935 /** 8936 * The base implementation of `baseForOwn` which iterates over `object` 8937 * properties returned by `keysFunc` and invokes `iteratee` for each property. 8938 * Iteratee functions may exit iteration early by explicitly returning `false`. 8939 * 8940 * @private 8941 * @param {Object} object The object to iterate over. 8942 * @param {Function} iteratee The function invoked per iteration. 8943 * @param {Function} keysFunc The function to get the keys of `object`. 8944 * @returns {Object} Returns `object`. 8945 */ 8946 var baseFor = createBaseFor(); 8947 8948 /** 8949 * This function is like `baseFor` except that it iterates over properties 8950 * in the opposite order. 8951 * 8952 * @private 8953 * @param {Object} object The object to iterate over. 8954 * @param {Function} iteratee The function invoked per iteration. 8955 * @param {Function} keysFunc The function to get the keys of `object`. 8956 * @returns {Object} Returns `object`. 8957 */ 8958 var baseForRight = createBaseFor(true); 8959 8960 /** 8961 * The base implementation of `_.forOwn` without support for iteratee shorthands. 8962 * 8963 * @private 8964 * @param {Object} object The object to iterate over. 8965 * @param {Function} iteratee The function invoked per iteration. 8966 * @returns {Object} Returns `object`. 8967 */ 8968 function baseForOwn(object, iteratee) { 8969 return object && baseFor(object, iteratee, keys); 8970 } 8971 8972 /** 8973 * The base implementation of `_.forOwnRight` without support for iteratee shorthands. 8974 * 8975 * @private 8976 * @param {Object} object The object to iterate over. 8977 * @param {Function} iteratee The function invoked per iteration. 8978 * @returns {Object} Returns `object`. 8979 */ 8980 function baseForOwnRight(object, iteratee) { 8981 return object && baseForRight(object, iteratee, keys); 8982 } 8983 8984 /** 8985 * The base implementation of `_.functions` which creates an array of 8986 * `object` function property names filtered from `props`. 8987 * 8988 * @private 8989 * @param {Object} object The object to inspect. 8990 * @param {Array} props The property names to filter. 8991 * @returns {Array} Returns the function names. 8992 */ 8993 function baseFunctions(object, props) { 8994 return arrayFilter(props, function(key) { 8995 return isFunction(object[key]); 8996 }); 8997 } 8998 8999 /** 9000 * The base implementation of `_.get` without support for default values. 9001 * 9002 * @private 9003 * @param {Object} object The object to query. 9004 * @param {Array|string} path The path of the property to get. 9005 * @returns {*} Returns the resolved value. 9006 */ 9007 function baseGet(object, path) { 9008 path = castPath(path, object); 9009 9010 var index = 0, 9011 length = path.length; 9012 9013 while (object != null && index < length) { 9014 object = object[toKey(path[index++])]; 9015 } 9016 return (index && index == length) ? object : undefined$1; 9017 } 9018 9019 /** 9020 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses 9021 * `keysFunc` and `symbolsFunc` to get the enumerable property names and 9022 * symbols of `object`. 9023 * 9024 * @private 9025 * @param {Object} object The object to query. 9026 * @param {Function} keysFunc The function to get the keys of `object`. 9027 * @param {Function} symbolsFunc The function to get the symbols of `object`. 9028 * @returns {Array} Returns the array of property names and symbols. 9029 */ 9030 function baseGetAllKeys(object, keysFunc, symbolsFunc) { 9031 var result = keysFunc(object); 9032 return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); 9033 } 9034 9035 /** 9036 * The base implementation of `getTag` without fallbacks for buggy environments. 9037 * 9038 * @private 9039 * @param {*} value The value to query. 9040 * @returns {string} Returns the `toStringTag`. 9041 */ 9042 function baseGetTag(value) { 9043 if (value == null) { 9044 return value === undefined$1 ? undefinedTag : nullTag; 9045 } 9046 return (symToStringTag && symToStringTag in Object(value)) 9047 ? getRawTag(value) 9048 : objectToString(value); 9049 } 9050 9051 /** 9052 * The base implementation of `_.gt` which doesn't coerce arguments. 9053 * 9054 * @private 9055 * @param {*} value The value to compare. 9056 * @param {*} other The other value to compare. 9057 * @returns {boolean} Returns `true` if `value` is greater than `other`, 9058 * else `false`. 9059 */ 9060 function baseGt(value, other) { 9061 return value > other; 9062 } 9063 9064 /** 9065 * The base implementation of `_.has` without support for deep paths. 9066 * 9067 * @private 9068 * @param {Object} [object] The object to query. 9069 * @param {Array|string} key The key to check. 9070 * @returns {boolean} Returns `true` if `key` exists, else `false`. 9071 */ 9072 function baseHas(object, key) { 9073 return object != null && hasOwnProperty.call(object, key); 9074 } 9075 9076 /** 9077 * The base implementation of `_.hasIn` without support for deep paths. 9078 * 9079 * @private 9080 * @param {Object} [object] The object to query. 9081 * @param {Array|string} key The key to check. 9082 * @returns {boolean} Returns `true` if `key` exists, else `false`. 9083 */ 9084 function baseHasIn(object, key) { 9085 return object != null && key in Object(object); 9086 } 9087 9088 /** 9089 * The base implementation of `_.inRange` which doesn't coerce arguments. 9090 * 9091 * @private 9092 * @param {number} number The number to check. 9093 * @param {number} start The start of the range. 9094 * @param {number} end The end of the range. 9095 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 9096 */ 9097 function baseInRange(number, start, end) { 9098 return number >= nativeMin(start, end) && number < nativeMax(start, end); 9099 } 9100 9101 /** 9102 * The base implementation of methods like `_.intersection`, without support 9103 * for iteratee shorthands, that accepts an array of arrays to inspect. 9104 * 9105 * @private 9106 * @param {Array} arrays The arrays to inspect. 9107 * @param {Function} [iteratee] The iteratee invoked per element. 9108 * @param {Function} [comparator] The comparator invoked per element. 9109 * @returns {Array} Returns the new array of shared values. 9110 */ 9111 function baseIntersection(arrays, iteratee, comparator) { 9112 var includes = comparator ? arrayIncludesWith : arrayIncludes, 9113 length = arrays[0].length, 9114 othLength = arrays.length, 9115 othIndex = othLength, 9116 caches = Array(othLength), 9117 maxLength = Infinity, 9118 result = []; 9119 9120 while (othIndex--) { 9121 var array = arrays[othIndex]; 9122 if (othIndex && iteratee) { 9123 array = arrayMap(array, baseUnary(iteratee)); 9124 } 9125 maxLength = nativeMin(array.length, maxLength); 9126 caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) 9127 ? new SetCache(othIndex && array) 9128 : undefined$1; 9129 } 9130 array = arrays[0]; 9131 9132 var index = -1, 9133 seen = caches[0]; 9134 9135 outer: 9136 while (++index < length && result.length < maxLength) { 9137 var value = array[index], 9138 computed = iteratee ? iteratee(value) : value; 9139 9140 value = (comparator || value !== 0) ? value : 0; 9141 if (!(seen 9142 ? cacheHas(seen, computed) 9143 : includes(result, computed, comparator) 9144 )) { 9145 othIndex = othLength; 9146 while (--othIndex) { 9147 var cache = caches[othIndex]; 9148 if (!(cache 9149 ? cacheHas(cache, computed) 9150 : includes(arrays[othIndex], computed, comparator)) 9151 ) { 9152 continue outer; 9153 } 9154 } 9155 if (seen) { 9156 seen.push(computed); 9157 } 9158 result.push(value); 9159 } 9160 } 9161 return result; 9162 } 9163 9164 /** 9165 * The base implementation of `_.invert` and `_.invertBy` which inverts 9166 * `object` with values transformed by `iteratee` and set by `setter`. 9167 * 9168 * @private 9169 * @param {Object} object The object to iterate over. 9170 * @param {Function} setter The function to set `accumulator` values. 9171 * @param {Function} iteratee The iteratee to transform values. 9172 * @param {Object} accumulator The initial inverted object. 9173 * @returns {Function} Returns `accumulator`. 9174 */ 9175 function baseInverter(object, setter, iteratee, accumulator) { 9176 baseForOwn(object, function(value, key, object) { 9177 setter(accumulator, iteratee(value), key, object); 9178 }); 9179 return accumulator; 9180 } 9181 9182 /** 9183 * The base implementation of `_.invoke` without support for individual 9184 * method arguments. 9185 * 9186 * @private 9187 * @param {Object} object The object to query. 9188 * @param {Array|string} path The path of the method to invoke. 9189 * @param {Array} args The arguments to invoke the method with. 9190 * @returns {*} Returns the result of the invoked method. 9191 */ 9192 function baseInvoke(object, path, args) { 9193 path = castPath(path, object); 9194 object = parent(object, path); 9195 var func = object == null ? object : object[toKey(last(path))]; 9196 return func == null ? undefined$1 : apply(func, object, args); 9197 } 9198 9199 /** 9200 * The base implementation of `_.isArguments`. 9201 * 9202 * @private 9203 * @param {*} value The value to check. 9204 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 9205 */ 9206 function baseIsArguments(value) { 9207 return isObjectLike(value) && baseGetTag(value) == argsTag; 9208 } 9209 9210 /** 9211 * The base implementation of `_.isArrayBuffer` without Node.js optimizations. 9212 * 9213 * @private 9214 * @param {*} value The value to check. 9215 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 9216 */ 9217 function baseIsArrayBuffer(value) { 9218 return isObjectLike(value) && baseGetTag(value) == arrayBufferTag; 9219 } 9220 9221 /** 9222 * The base implementation of `_.isDate` without Node.js optimizations. 9223 * 9224 * @private 9225 * @param {*} value The value to check. 9226 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 9227 */ 9228 function baseIsDate(value) { 9229 return isObjectLike(value) && baseGetTag(value) == dateTag; 9230 } 9231 9232 /** 9233 * The base implementation of `_.isEqual` which supports partial comparisons 9234 * and tracks traversed objects. 9235 * 9236 * @private 9237 * @param {*} value The value to compare. 9238 * @param {*} other The other value to compare. 9239 * @param {boolean} bitmask The bitmask flags. 9240 * 1 - Unordered comparison 9241 * 2 - Partial comparison 9242 * @param {Function} [customizer] The function to customize comparisons. 9243 * @param {Object} [stack] Tracks traversed `value` and `other` objects. 9244 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 9245 */ 9246 function baseIsEqual(value, other, bitmask, customizer, stack) { 9247 if (value === other) { 9248 return true; 9249 } 9250 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { 9251 return value !== value && other !== other; 9252 } 9253 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); 9254 } 9255 9256 /** 9257 * A specialized version of `baseIsEqual` for arrays and objects which performs 9258 * deep comparisons and tracks traversed objects enabling objects with circular 9259 * references to be compared. 9260 * 9261 * @private 9262 * @param {Object} object The object to compare. 9263 * @param {Object} other The other object to compare. 9264 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 9265 * @param {Function} customizer The function to customize comparisons. 9266 * @param {Function} equalFunc The function to determine equivalents of values. 9267 * @param {Object} [stack] Tracks traversed `object` and `other` objects. 9268 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 9269 */ 9270 function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { 9271 var objIsArr = isArray(object), 9272 othIsArr = isArray(other), 9273 objTag = objIsArr ? arrayTag : getTag(object), 9274 othTag = othIsArr ? arrayTag : getTag(other); 9275 9276 objTag = objTag == argsTag ? objectTag : objTag; 9277 othTag = othTag == argsTag ? objectTag : othTag; 9278 9279 var objIsObj = objTag == objectTag, 9280 othIsObj = othTag == objectTag, 9281 isSameTag = objTag == othTag; 9282 9283 if (isSameTag && isBuffer(object)) { 9284 if (!isBuffer(other)) { 9285 return false; 9286 } 9287 objIsArr = true; 9288 objIsObj = false; 9289 } 9290 if (isSameTag && !objIsObj) { 9291 stack || (stack = new Stack); 9292 return (objIsArr || isTypedArray(object)) 9293 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) 9294 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); 9295 } 9296 if (!(bitmask & COMPARE_PARTIAL_FLAG)) { 9297 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), 9298 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); 9299 9300 if (objIsWrapped || othIsWrapped) { 9301 var objUnwrapped = objIsWrapped ? object.value() : object, 9302 othUnwrapped = othIsWrapped ? other.value() : other; 9303 9304 stack || (stack = new Stack); 9305 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); 9306 } 9307 } 9308 if (!isSameTag) { 9309 return false; 9310 } 9311 stack || (stack = new Stack); 9312 return equalObjects(object, other, bitmask, customizer, equalFunc, stack); 9313 } 9314 9315 /** 9316 * The base implementation of `_.isMap` without Node.js optimizations. 9317 * 9318 * @private 9319 * @param {*} value The value to check. 9320 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 9321 */ 9322 function baseIsMap(value) { 9323 return isObjectLike(value) && getTag(value) == mapTag; 9324 } 9325 9326 /** 9327 * The base implementation of `_.isMatch` without support for iteratee shorthands. 9328 * 9329 * @private 9330 * @param {Object} object The object to inspect. 9331 * @param {Object} source The object of property values to match. 9332 * @param {Array} matchData The property names, values, and compare flags to match. 9333 * @param {Function} [customizer] The function to customize comparisons. 9334 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 9335 */ 9336 function baseIsMatch(object, source, matchData, customizer) { 9337 var index = matchData.length, 9338 length = index, 9339 noCustomizer = !customizer; 9340 9341 if (object == null) { 9342 return !length; 9343 } 9344 object = Object(object); 9345 while (index--) { 9346 var data = matchData[index]; 9347 if ((noCustomizer && data[2]) 9348 ? data[1] !== object[data[0]] 9349 : !(data[0] in object) 9350 ) { 9351 return false; 9352 } 9353 } 9354 while (++index < length) { 9355 data = matchData[index]; 9356 var key = data[0], 9357 objValue = object[key], 9358 srcValue = data[1]; 9359 9360 if (noCustomizer && data[2]) { 9361 if (objValue === undefined$1 && !(key in object)) { 9362 return false; 9363 } 9364 } else { 9365 var stack = new Stack; 9366 if (customizer) { 9367 var result = customizer(objValue, srcValue, key, object, source, stack); 9368 } 9369 if (!(result === undefined$1 9370 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) 9371 : result 9372 )) { 9373 return false; 9374 } 9375 } 9376 } 9377 return true; 9378 } 9379 9380 /** 9381 * The base implementation of `_.isNative` without bad shim checks. 9382 * 9383 * @private 9384 * @param {*} value The value to check. 9385 * @returns {boolean} Returns `true` if `value` is a native function, 9386 * else `false`. 9387 */ 9388 function baseIsNative(value) { 9389 if (!isObject(value) || isMasked(value)) { 9390 return false; 9391 } 9392 var pattern = isFunction(value) ? reIsNative : reIsHostCtor; 9393 return pattern.test(toSource(value)); 9394 } 9395 9396 /** 9397 * The base implementation of `_.isRegExp` without Node.js optimizations. 9398 * 9399 * @private 9400 * @param {*} value The value to check. 9401 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 9402 */ 9403 function baseIsRegExp(value) { 9404 return isObjectLike(value) && baseGetTag(value) == regexpTag; 9405 } 9406 9407 /** 9408 * The base implementation of `_.isSet` without Node.js optimizations. 9409 * 9410 * @private 9411 * @param {*} value The value to check. 9412 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 9413 */ 9414 function baseIsSet(value) { 9415 return isObjectLike(value) && getTag(value) == setTag; 9416 } 9417 9418 /** 9419 * The base implementation of `_.isTypedArray` without Node.js optimizations. 9420 * 9421 * @private 9422 * @param {*} value The value to check. 9423 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 9424 */ 9425 function baseIsTypedArray(value) { 9426 return isObjectLike(value) && 9427 isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; 9428 } 9429 9430 /** 9431 * The base implementation of `_.iteratee`. 9432 * 9433 * @private 9434 * @param {*} [value=_.identity] The value to convert to an iteratee. 9435 * @returns {Function} Returns the iteratee. 9436 */ 9437 function baseIteratee(value) { 9438 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. 9439 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. 9440 if (typeof value == 'function') { 9441 return value; 9442 } 9443 if (value == null) { 9444 return identity; 9445 } 9446 if (typeof value == 'object') { 9447 return isArray(value) 9448 ? baseMatchesProperty(value[0], value[1]) 9449 : baseMatches(value); 9450 } 9451 return property(value); 9452 } 9453 9454 /** 9455 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. 9456 * 9457 * @private 9458 * @param {Object} object The object to query. 9459 * @returns {Array} Returns the array of property names. 9460 */ 9461 function baseKeys(object) { 9462 if (!isPrototype(object)) { 9463 return nativeKeys(object); 9464 } 9465 var result = []; 9466 for (var key in Object(object)) { 9467 if (hasOwnProperty.call(object, key) && key != 'constructor') { 9468 result.push(key); 9469 } 9470 } 9471 return result; 9472 } 9473 9474 /** 9475 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. 9476 * 9477 * @private 9478 * @param {Object} object The object to query. 9479 * @returns {Array} Returns the array of property names. 9480 */ 9481 function baseKeysIn(object) { 9482 if (!isObject(object)) { 9483 return nativeKeysIn(object); 9484 } 9485 var isProto = isPrototype(object), 9486 result = []; 9487 9488 for (var key in object) { 9489 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { 9490 result.push(key); 9491 } 9492 } 9493 return result; 9494 } 9495 9496 /** 9497 * The base implementation of `_.lt` which doesn't coerce arguments. 9498 * 9499 * @private 9500 * @param {*} value The value to compare. 9501 * @param {*} other The other value to compare. 9502 * @returns {boolean} Returns `true` if `value` is less than `other`, 9503 * else `false`. 9504 */ 9505 function baseLt(value, other) { 9506 return value < other; 9507 } 9508 9509 /** 9510 * The base implementation of `_.map` without support for iteratee shorthands. 9511 * 9512 * @private 9513 * @param {Array|Object} collection The collection to iterate over. 9514 * @param {Function} iteratee The function invoked per iteration. 9515 * @returns {Array} Returns the new mapped array. 9516 */ 9517 function baseMap(collection, iteratee) { 9518 var index = -1, 9519 result = isArrayLike(collection) ? Array(collection.length) : []; 9520 9521 baseEach(collection, function(value, key, collection) { 9522 result[++index] = iteratee(value, key, collection); 9523 }); 9524 return result; 9525 } 9526 9527 /** 9528 * The base implementation of `_.matches` which doesn't clone `source`. 9529 * 9530 * @private 9531 * @param {Object} source The object of property values to match. 9532 * @returns {Function} Returns the new spec function. 9533 */ 9534 function baseMatches(source) { 9535 var matchData = getMatchData(source); 9536 if (matchData.length == 1 && matchData[0][2]) { 9537 return matchesStrictComparable(matchData[0][0], matchData[0][1]); 9538 } 9539 return function(object) { 9540 return object === source || baseIsMatch(object, source, matchData); 9541 }; 9542 } 9543 9544 /** 9545 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. 9546 * 9547 * @private 9548 * @param {string} path The path of the property to get. 9549 * @param {*} srcValue The value to match. 9550 * @returns {Function} Returns the new spec function. 9551 */ 9552 function baseMatchesProperty(path, srcValue) { 9553 if (isKey(path) && isStrictComparable(srcValue)) { 9554 return matchesStrictComparable(toKey(path), srcValue); 9555 } 9556 return function(object) { 9557 var objValue = get(object, path); 9558 return (objValue === undefined$1 && objValue === srcValue) 9559 ? hasIn(object, path) 9560 : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); 9561 }; 9562 } 9563 9564 /** 9565 * The base implementation of `_.merge` without support for multiple sources. 9566 * 9567 * @private 9568 * @param {Object} object The destination object. 9569 * @param {Object} source The source object. 9570 * @param {number} srcIndex The index of `source`. 9571 * @param {Function} [customizer] The function to customize merged values. 9572 * @param {Object} [stack] Tracks traversed source values and their merged 9573 * counterparts. 9574 */ 9575 function baseMerge(object, source, srcIndex, customizer, stack) { 9576 if (object === source) { 9577 return; 9578 } 9579 baseFor(source, function(srcValue, key) { 9580 stack || (stack = new Stack); 9581 if (isObject(srcValue)) { 9582 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); 9583 } 9584 else { 9585 var newValue = customizer 9586 ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) 9587 : undefined$1; 9588 9589 if (newValue === undefined$1) { 9590 newValue = srcValue; 9591 } 9592 assignMergeValue(object, key, newValue); 9593 } 9594 }, keysIn); 9595 } 9596 9597 /** 9598 * A specialized version of `baseMerge` for arrays and objects which performs 9599 * deep merges and tracks traversed objects enabling objects with circular 9600 * references to be merged. 9601 * 9602 * @private 9603 * @param {Object} object The destination object. 9604 * @param {Object} source The source object. 9605 * @param {string} key The key of the value to merge. 9606 * @param {number} srcIndex The index of `source`. 9607 * @param {Function} mergeFunc The function to merge values. 9608 * @param {Function} [customizer] The function to customize assigned values. 9609 * @param {Object} [stack] Tracks traversed source values and their merged 9610 * counterparts. 9611 */ 9612 function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { 9613 var objValue = safeGet(object, key), 9614 srcValue = safeGet(source, key), 9615 stacked = stack.get(srcValue); 9616 9617 if (stacked) { 9618 assignMergeValue(object, key, stacked); 9619 return; 9620 } 9621 var newValue = customizer 9622 ? customizer(objValue, srcValue, (key + ''), object, source, stack) 9623 : undefined$1; 9624 9625 var isCommon = newValue === undefined$1; 9626 9627 if (isCommon) { 9628 var isArr = isArray(srcValue), 9629 isBuff = !isArr && isBuffer(srcValue), 9630 isTyped = !isArr && !isBuff && isTypedArray(srcValue); 9631 9632 newValue = srcValue; 9633 if (isArr || isBuff || isTyped) { 9634 if (isArray(objValue)) { 9635 newValue = objValue; 9636 } 9637 else if (isArrayLikeObject(objValue)) { 9638 newValue = copyArray(objValue); 9639 } 9640 else if (isBuff) { 9641 isCommon = false; 9642 newValue = cloneBuffer(srcValue, true); 9643 } 9644 else if (isTyped) { 9645 isCommon = false; 9646 newValue = cloneTypedArray(srcValue, true); 9647 } 9648 else { 9649 newValue = []; 9650 } 9651 } 9652 else if (isPlainObject(srcValue) || isArguments(srcValue)) { 9653 newValue = objValue; 9654 if (isArguments(objValue)) { 9655 newValue = toPlainObject(objValue); 9656 } 9657 else if (!isObject(objValue) || isFunction(objValue)) { 9658 newValue = initCloneObject(srcValue); 9659 } 9660 } 9661 else { 9662 isCommon = false; 9663 } 9664 } 9665 if (isCommon) { 9666 // Recursively merge objects and arrays (susceptible to call stack limits). 9667 stack.set(srcValue, newValue); 9668 mergeFunc(newValue, srcValue, srcIndex, customizer, stack); 9669 stack['delete'](srcValue); 9670 } 9671 assignMergeValue(object, key, newValue); 9672 } 9673 9674 /** 9675 * The base implementation of `_.nth` which doesn't coerce arguments. 9676 * 9677 * @private 9678 * @param {Array} array The array to query. 9679 * @param {number} n The index of the element to return. 9680 * @returns {*} Returns the nth element of `array`. 9681 */ 9682 function baseNth(array, n) { 9683 var length = array.length; 9684 if (!length) { 9685 return; 9686 } 9687 n += n < 0 ? length : 0; 9688 return isIndex(n, length) ? array[n] : undefined$1; 9689 } 9690 9691 /** 9692 * The base implementation of `_.orderBy` without param guards. 9693 * 9694 * @private 9695 * @param {Array|Object} collection The collection to iterate over. 9696 * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. 9697 * @param {string[]} orders The sort orders of `iteratees`. 9698 * @returns {Array} Returns the new sorted array. 9699 */ 9700 function baseOrderBy(collection, iteratees, orders) { 9701 if (iteratees.length) { 9702 iteratees = arrayMap(iteratees, function(iteratee) { 9703 if (isArray(iteratee)) { 9704 return function(value) { 9705 return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee); 9706 } 9707 } 9708 return iteratee; 9709 }); 9710 } else { 9711 iteratees = [identity]; 9712 } 9713 9714 var index = -1; 9715 iteratees = arrayMap(iteratees, baseUnary(getIteratee())); 9716 9717 var result = baseMap(collection, function(value, key, collection) { 9718 var criteria = arrayMap(iteratees, function(iteratee) { 9719 return iteratee(value); 9720 }); 9721 return { 'criteria': criteria, 'index': ++index, 'value': value }; 9722 }); 9723 9724 return baseSortBy(result, function(object, other) { 9725 return compareMultiple(object, other, orders); 9726 }); 9727 } 9728 9729 /** 9730 * The base implementation of `_.pick` without support for individual 9731 * property identifiers. 9732 * 9733 * @private 9734 * @param {Object} object The source object. 9735 * @param {string[]} paths The property paths to pick. 9736 * @returns {Object} Returns the new object. 9737 */ 9738 function basePick(object, paths) { 9739 return basePickBy(object, paths, function(value, path) { 9740 return hasIn(object, path); 9741 }); 9742 } 9743 9744 /** 9745 * The base implementation of `_.pickBy` without support for iteratee shorthands. 9746 * 9747 * @private 9748 * @param {Object} object The source object. 9749 * @param {string[]} paths The property paths to pick. 9750 * @param {Function} predicate The function invoked per property. 9751 * @returns {Object} Returns the new object. 9752 */ 9753 function basePickBy(object, paths, predicate) { 9754 var index = -1, 9755 length = paths.length, 9756 result = {}; 9757 9758 while (++index < length) { 9759 var path = paths[index], 9760 value = baseGet(object, path); 9761 9762 if (predicate(value, path)) { 9763 baseSet(result, castPath(path, object), value); 9764 } 9765 } 9766 return result; 9767 } 9768 9769 /** 9770 * A specialized version of `baseProperty` which supports deep paths. 9771 * 9772 * @private 9773 * @param {Array|string} path The path of the property to get. 9774 * @returns {Function} Returns the new accessor function. 9775 */ 9776 function basePropertyDeep(path) { 9777 return function(object) { 9778 return baseGet(object, path); 9779 }; 9780 } 9781 9782 /** 9783 * The base implementation of `_.pullAllBy` without support for iteratee 9784 * shorthands. 9785 * 9786 * @private 9787 * @param {Array} array The array to modify. 9788 * @param {Array} values The values to remove. 9789 * @param {Function} [iteratee] The iteratee invoked per element. 9790 * @param {Function} [comparator] The comparator invoked per element. 9791 * @returns {Array} Returns `array`. 9792 */ 9793 function basePullAll(array, values, iteratee, comparator) { 9794 var indexOf = comparator ? baseIndexOfWith : baseIndexOf, 9795 index = -1, 9796 length = values.length, 9797 seen = array; 9798 9799 if (array === values) { 9800 values = copyArray(values); 9801 } 9802 if (iteratee) { 9803 seen = arrayMap(array, baseUnary(iteratee)); 9804 } 9805 while (++index < length) { 9806 var fromIndex = 0, 9807 value = values[index], 9808 computed = iteratee ? iteratee(value) : value; 9809 9810 while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { 9811 if (seen !== array) { 9812 splice.call(seen, fromIndex, 1); 9813 } 9814 splice.call(array, fromIndex, 1); 9815 } 9816 } 9817 return array; 9818 } 9819 9820 /** 9821 * The base implementation of `_.pullAt` without support for individual 9822 * indexes or capturing the removed elements. 9823 * 9824 * @private 9825 * @param {Array} array The array to modify. 9826 * @param {number[]} indexes The indexes of elements to remove. 9827 * @returns {Array} Returns `array`. 9828 */ 9829 function basePullAt(array, indexes) { 9830 var length = array ? indexes.length : 0, 9831 lastIndex = length - 1; 9832 9833 while (length--) { 9834 var index = indexes[length]; 9835 if (length == lastIndex || index !== previous) { 9836 var previous = index; 9837 if (isIndex(index)) { 9838 splice.call(array, index, 1); 9839 } else { 9840 baseUnset(array, index); 9841 } 9842 } 9843 } 9844 return array; 9845 } 9846 9847 /** 9848 * The base implementation of `_.random` without support for returning 9849 * floating-point numbers. 9850 * 9851 * @private 9852 * @param {number} lower The lower bound. 9853 * @param {number} upper The upper bound. 9854 * @returns {number} Returns the random number. 9855 */ 9856 function baseRandom(lower, upper) { 9857 return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); 9858 } 9859 9860 /** 9861 * The base implementation of `_.range` and `_.rangeRight` which doesn't 9862 * coerce arguments. 9863 * 9864 * @private 9865 * @param {number} start The start of the range. 9866 * @param {number} end The end of the range. 9867 * @param {number} step The value to increment or decrement by. 9868 * @param {boolean} [fromRight] Specify iterating from right to left. 9869 * @returns {Array} Returns the range of numbers. 9870 */ 9871 function baseRange(start, end, step, fromRight) { 9872 var index = -1, 9873 length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), 9874 result = Array(length); 9875 9876 while (length--) { 9877 result[fromRight ? length : ++index] = start; 9878 start += step; 9879 } 9880 return result; 9881 } 9882 9883 /** 9884 * The base implementation of `_.repeat` which doesn't coerce arguments. 9885 * 9886 * @private 9887 * @param {string} string The string to repeat. 9888 * @param {number} n The number of times to repeat the string. 9889 * @returns {string} Returns the repeated string. 9890 */ 9891 function baseRepeat(string, n) { 9892 var result = ''; 9893 if (!string || n < 1 || n > MAX_SAFE_INTEGER) { 9894 return result; 9895 } 9896 // Leverage the exponentiation by squaring algorithm for a faster repeat. 9897 // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. 9898 do { 9899 if (n % 2) { 9900 result += string; 9901 } 9902 n = nativeFloor(n / 2); 9903 if (n) { 9904 string += string; 9905 } 9906 } while (n); 9907 9908 return result; 9909 } 9910 9911 /** 9912 * The base implementation of `_.rest` which doesn't validate or coerce arguments. 9913 * 9914 * @private 9915 * @param {Function} func The function to apply a rest parameter to. 9916 * @param {number} [start=func.length-1] The start position of the rest parameter. 9917 * @returns {Function} Returns the new function. 9918 */ 9919 function baseRest(func, start) { 9920 return setToString(overRest(func, start, identity), func + ''); 9921 } 9922 9923 /** 9924 * The base implementation of `_.sample`. 9925 * 9926 * @private 9927 * @param {Array|Object} collection The collection to sample. 9928 * @returns {*} Returns the random element. 9929 */ 9930 function baseSample(collection) { 9931 return arraySample(values(collection)); 9932 } 9933 9934 /** 9935 * The base implementation of `_.sampleSize` without param guards. 9936 * 9937 * @private 9938 * @param {Array|Object} collection The collection to sample. 9939 * @param {number} n The number of elements to sample. 9940 * @returns {Array} Returns the random elements. 9941 */ 9942 function baseSampleSize(collection, n) { 9943 var array = values(collection); 9944 return shuffleSelf(array, baseClamp(n, 0, array.length)); 9945 } 9946 9947 /** 9948 * The base implementation of `_.set`. 9949 * 9950 * @private 9951 * @param {Object} object The object to modify. 9952 * @param {Array|string} path The path of the property to set. 9953 * @param {*} value The value to set. 9954 * @param {Function} [customizer] The function to customize path creation. 9955 * @returns {Object} Returns `object`. 9956 */ 9957 function baseSet(object, path, value, customizer) { 9958 if (!isObject(object)) { 9959 return object; 9960 } 9961 path = castPath(path, object); 9962 9963 var index = -1, 9964 length = path.length, 9965 lastIndex = length - 1, 9966 nested = object; 9967 9968 while (nested != null && ++index < length) { 9969 var key = toKey(path[index]), 9970 newValue = value; 9971 9972 if (key === '__proto__' || key === 'constructor' || key === 'prototype') { 9973 return object; 9974 } 9975 9976 if (index != lastIndex) { 9977 var objValue = nested[key]; 9978 newValue = customizer ? customizer(objValue, key, nested) : undefined$1; 9979 if (newValue === undefined$1) { 9980 newValue = isObject(objValue) 9981 ? objValue 9982 : (isIndex(path[index + 1]) ? [] : {}); 9983 } 9984 } 9985 assignValue(nested, key, newValue); 9986 nested = nested[key]; 9987 } 9988 return object; 9989 } 9990 9991 /** 9992 * The base implementation of `setData` without support for hot loop shorting. 9993 * 9994 * @private 9995 * @param {Function} func The function to associate metadata with. 9996 * @param {*} data The metadata. 9997 * @returns {Function} Returns `func`. 9998 */ 9999 var baseSetData = !metaMap ? identity : function(func, data) { 10000 metaMap.set(func, data); 10001 return func; 10002 }; 10003 10004 /** 10005 * The base implementation of `setToString` without support for hot loop shorting. 10006 * 10007 * @private 10008 * @param {Function} func The function to modify. 10009 * @param {Function} string The `toString` result. 10010 * @returns {Function} Returns `func`. 10011 */ 10012 var baseSetToString = !defineProperty ? identity : function(func, string) { 10013 return defineProperty(func, 'toString', { 10014 'configurable': true, 10015 'enumerable': false, 10016 'value': constant(string), 10017 'writable': true 10018 }); 10019 }; 10020 10021 /** 10022 * The base implementation of `_.shuffle`. 10023 * 10024 * @private 10025 * @param {Array|Object} collection The collection to shuffle. 10026 * @returns {Array} Returns the new shuffled array. 10027 */ 10028 function baseShuffle(collection) { 10029 return shuffleSelf(values(collection)); 10030 } 10031 10032 /** 10033 * The base implementation of `_.slice` without an iteratee call guard. 10034 * 10035 * @private 10036 * @param {Array} array The array to slice. 10037 * @param {number} [start=0] The start position. 10038 * @param {number} [end=array.length] The end position. 10039 * @returns {Array} Returns the slice of `array`. 10040 */ 10041 function baseSlice(array, start, end) { 10042 var index = -1, 10043 length = array.length; 10044 10045 if (start < 0) { 10046 start = -start > length ? 0 : (length + start); 10047 } 10048 end = end > length ? length : end; 10049 if (end < 0) { 10050 end += length; 10051 } 10052 length = start > end ? 0 : ((end - start) >>> 0); 10053 start >>>= 0; 10054 10055 var result = Array(length); 10056 while (++index < length) { 10057 result[index] = array[index + start]; 10058 } 10059 return result; 10060 } 10061 10062 /** 10063 * The base implementation of `_.some` without support for iteratee shorthands. 10064 * 10065 * @private 10066 * @param {Array|Object} collection The collection to iterate over. 10067 * @param {Function} predicate The function invoked per iteration. 10068 * @returns {boolean} Returns `true` if any element passes the predicate check, 10069 * else `false`. 10070 */ 10071 function baseSome(collection, predicate) { 10072 var result; 10073 10074 baseEach(collection, function(value, index, collection) { 10075 result = predicate(value, index, collection); 10076 return !result; 10077 }); 10078 return !!result; 10079 } 10080 10081 /** 10082 * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which 10083 * performs a binary search of `array` to determine the index at which `value` 10084 * should be inserted into `array` in order to maintain its sort order. 10085 * 10086 * @private 10087 * @param {Array} array The sorted array to inspect. 10088 * @param {*} value The value to evaluate. 10089 * @param {boolean} [retHighest] Specify returning the highest qualified index. 10090 * @returns {number} Returns the index at which `value` should be inserted 10091 * into `array`. 10092 */ 10093 function baseSortedIndex(array, value, retHighest) { 10094 var low = 0, 10095 high = array == null ? low : array.length; 10096 10097 if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { 10098 while (low < high) { 10099 var mid = (low + high) >>> 1, 10100 computed = array[mid]; 10101 10102 if (computed !== null && !isSymbol(computed) && 10103 (retHighest ? (computed <= value) : (computed < value))) { 10104 low = mid + 1; 10105 } else { 10106 high = mid; 10107 } 10108 } 10109 return high; 10110 } 10111 return baseSortedIndexBy(array, value, identity, retHighest); 10112 } 10113 10114 /** 10115 * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` 10116 * which invokes `iteratee` for `value` and each element of `array` to compute 10117 * their sort ranking. The iteratee is invoked with one argument; (value). 10118 * 10119 * @private 10120 * @param {Array} array The sorted array to inspect. 10121 * @param {*} value The value to evaluate. 10122 * @param {Function} iteratee The iteratee invoked per element. 10123 * @param {boolean} [retHighest] Specify returning the highest qualified index. 10124 * @returns {number} Returns the index at which `value` should be inserted 10125 * into `array`. 10126 */ 10127 function baseSortedIndexBy(array, value, iteratee, retHighest) { 10128 var low = 0, 10129 high = array == null ? 0 : array.length; 10130 if (high === 0) { 10131 return 0; 10132 } 10133 10134 value = iteratee(value); 10135 var valIsNaN = value !== value, 10136 valIsNull = value === null, 10137 valIsSymbol = isSymbol(value), 10138 valIsUndefined = value === undefined$1; 10139 10140 while (low < high) { 10141 var mid = nativeFloor((low + high) / 2), 10142 computed = iteratee(array[mid]), 10143 othIsDefined = computed !== undefined$1, 10144 othIsNull = computed === null, 10145 othIsReflexive = computed === computed, 10146 othIsSymbol = isSymbol(computed); 10147 10148 if (valIsNaN) { 10149 var setLow = retHighest || othIsReflexive; 10150 } else if (valIsUndefined) { 10151 setLow = othIsReflexive && (retHighest || othIsDefined); 10152 } else if (valIsNull) { 10153 setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); 10154 } else if (valIsSymbol) { 10155 setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol); 10156 } else if (othIsNull || othIsSymbol) { 10157 setLow = false; 10158 } else { 10159 setLow = retHighest ? (computed <= value) : (computed < value); 10160 } 10161 if (setLow) { 10162 low = mid + 1; 10163 } else { 10164 high = mid; 10165 } 10166 } 10167 return nativeMin(high, MAX_ARRAY_INDEX); 10168 } 10169 10170 /** 10171 * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without 10172 * support for iteratee shorthands. 10173 * 10174 * @private 10175 * @param {Array} array The array to inspect. 10176 * @param {Function} [iteratee] The iteratee invoked per element. 10177 * @returns {Array} Returns the new duplicate free array. 10178 */ 10179 function baseSortedUniq(array, iteratee) { 10180 var index = -1, 10181 length = array.length, 10182 resIndex = 0, 10183 result = []; 10184 10185 while (++index < length) { 10186 var value = array[index], 10187 computed = iteratee ? iteratee(value) : value; 10188 10189 if (!index || !eq(computed, seen)) { 10190 var seen = computed; 10191 result[resIndex++] = value === 0 ? 0 : value; 10192 } 10193 } 10194 return result; 10195 } 10196 10197 /** 10198 * The base implementation of `_.toNumber` which doesn't ensure correct 10199 * conversions of binary, hexadecimal, or octal string values. 10200 * 10201 * @private 10202 * @param {*} value The value to process. 10203 * @returns {number} Returns the number. 10204 */ 10205 function baseToNumber(value) { 10206 if (typeof value == 'number') { 10207 return value; 10208 } 10209 if (isSymbol(value)) { 10210 return NAN; 10211 } 10212 return +value; 10213 } 10214 10215 /** 10216 * The base implementation of `_.toString` which doesn't convert nullish 10217 * values to empty strings. 10218 * 10219 * @private 10220 * @param {*} value The value to process. 10221 * @returns {string} Returns the string. 10222 */ 10223 function baseToString(value) { 10224 // Exit early for strings to avoid a performance hit in some environments. 10225 if (typeof value == 'string') { 10226 return value; 10227 } 10228 if (isArray(value)) { 10229 // Recursively convert values (susceptible to call stack limits). 10230 return arrayMap(value, baseToString) + ''; 10231 } 10232 if (isSymbol(value)) { 10233 return symbolToString ? symbolToString.call(value) : ''; 10234 } 10235 var result = (value + ''); 10236 return (result == '0' && (1 / value) == -I
10236NFINITY) ? '-0' : result; 10237 } 10238 10239 /** 10240 * The base implementation of `_.uniqBy` without support for iteratee shorthands. 10241 * 10242 * @private 10243 * @param {Array} array The array to inspect. 10244 * @param {Function} [iteratee] The iteratee invoked per element. 10245 * @param {Function} [comparator] The comparator invoked per element. 10246 * @returns {Array} Returns the new duplicate free array. 10247 */ 10248 function baseUniq(array, iteratee, comparator) { 10249 var index = -1, 10250 includes = arrayIncludes, 10251 length = array.length, 10252 isCommon = true, 10253 result = [], 10254 seen = result; 10255 10256 if (comparator) { 10257 isCommon = false; 10258 includes = arrayIncludesWith; 10259 } 10260 else if (length >= LARGE_ARRAY_SIZE) { 10261 var set = iteratee ? null : createSet(array); 10262 if (set) { 10263 return setToArray(set); 10264 } 10265 isCommon = false;
vendor: 1,396 bytes, lines 10266-10311
10266 includes = cacheHas; 10267 seen = new SetCache; 10268 } 10269 else { 10270 seen = iteratee ? [] : result; 10271 } 10272 outer: 10273 while (++index < length) { 10274 var value = array[index], 10275 computed = iteratee ? iteratee(value) : value; 10276 10277 value = (comparator || value !== 0) ? value : 0; 10278 if (isCommon && computed === computed) { 10279 var seenIndex = seen.length; 10280 while (seenIndex--) { 10281 if (seen[seenIndex] === computed) { 10282 continue outer; 10283 } 10284 } 10285 if (iteratee) { 10286 seen.push(computed); 10287 } 10288 result.push(value); 10289 } 10290 else if (!includes(seen, computed, comparator)) { 10291 if (seen !== result) { 10292 seen.push(computed); 10293 } 10294 result.push(value); 10295 } 10296 } 10297 return result; 10298 } 10299 10300 /** 10301 * The base implementation of `_.unset`. 10302 * 10303 * @private 10304 * @param {Object} object The object to modify. 10305 * @param {Array|string} path The property path to unset. 10306 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 10307 */ 10308 function baseUnset(object, path) { 10309 path = castPath(path, object); 10310 object = parent(object, path); 10311 return object == null || delete object
vendor: 87,375 bytes, lines 10311-12759
10311[toKey(last(path))]; 10312 } 10313 10314 /** 10315 * The base implementation of `_.update`. 10316 * 10317 * @private 10318 * @param {Object} object The object to modify. 10319 * @param {Array|string} path The path of the property to update. 10320 * @param {Function} updater The function to produce the updated value. 10321 * @param {Function} [customizer] The function to customize path creation. 10322 * @returns {Object} Returns `object`. 10323 */ 10324 function baseUpdate(object, path, updater, customizer) { 10325 return baseSet(object, path, updater(baseGet(object, path)), customizer); 10326 } 10327 10328 /** 10329 * The base implementation of methods like `_.dropWhile` and `_.takeWhile` 10330 * without support for iteratee shorthands. 10331 * 10332 * @private 10333 * @param {Array} array The array to query. 10334 * @param {Function} predicate The function invoked per iteration. 10335 * @param {boolean} [isDrop] Specify dropping elements instead of taking them. 10336 * @param {boolean} [fromRight] Specify iterating from right to left. 10337 * @returns {Array} Returns the slice of `array`. 10338 */ 10339 function baseWhile(array, predicate, isDrop, fromRight) { 10340 var length = array.length, 10341 index = fromRight ? length : -1; 10342 10343 while ((fromRight ? index-- : ++index < length) && 10344 predicate(array[index], index, array)) {} 10345 10346 return isDrop 10347 ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) 10348 : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); 10349 } 10350 10351 /** 10352 * The base implementation of `wrapperValue` which returns the result of 10353 * performing a sequence of actions on the unwrapped `value`, where each 10354 * successive action is supplied the return value of the previous. 10355 * 10356 * @private 10357 * @param {*} value The unwrapped value. 10358 * @param {Array} actions Actions to perform to resolve the unwrapped value. 10359 * @returns {*} Returns the resolved value. 10360 */ 10361 function baseWrapperValue(value, actions) { 10362 var result = value; 10363 if (result instanceof LazyWrapper) { 10364 result = result.value(); 10365 } 10366 return arrayReduce(actions, function(result, action) { 10367 return action.func.apply(action.thisArg, arrayPush([result], action.args)); 10368 }, result); 10369 } 10370 10371 /** 10372 * The base implementation of methods like `_.xor`, without support for 10373 * iteratee shorthands, that accepts an array of arrays to inspect. 10374 * 10375 * @private 10376 * @param {Array} arrays The arrays to inspect. 10377 * @param {Function} [iteratee] The iteratee invoked per element. 10378 * @param {Function} [comparator] The comparator invoked per element. 10379 * @returns {Array} Returns the new array of values. 10380 */ 10381 function baseXor(arrays, iteratee, comparator) { 10382 var length = arrays.length; 10383 if (length < 2) { 10384 return length ? baseUniq(arrays[0]) : []; 10385 } 10386 var index = -1, 10387 result = Array(length); 10388 10389 while (++index < length) { 10390 var array = arrays[index], 10391 othIndex = -1; 10392 10393 while (++othIndex < length) { 10394 if (othIndex != index) { 10395 result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator); 10396 } 10397 } 10398 } 10399 return baseUniq(baseFlatten(result, 1), iteratee, comparator); 10400 } 10401 10402 /** 10403 * This base implementation of `_.zipObject` which assigns values using `assignFunc`. 10404 * 10405 * @private 10406 * @param {Array} props The property identifiers. 10407 * @param {Array} values The property values. 10408 * @param {Function} assignFunc The function to assign values. 10409 * @returns {Object} Returns the new object. 10410 */ 10411 function baseZipObject(props, values, assignFunc) { 10412 var index = -1, 10413 length = props.length, 10414 valsLength = values.length, 10415 result = {}; 10416 10417 while (++index < length) { 10418 var value = index < valsLength ? values[index] : undefined$1; 10419 assignFunc(result, props[index], value); 10420 } 10421 return result; 10422 } 10423 10424 /** 10425 * Casts `value` to an empty array if it's not an array like object. 10426 * 10427 * @private 10428 * @param {*} value The value to inspect. 10429 * @returns {Array|Object} Returns the cast array-like object. 10430 */ 10431 function castArrayLikeObject(value) { 10432 return isArrayLikeObject(value) ? value : []; 10433 } 10434 10435 /** 10436 * Casts `value` to `identity` if it's not a function. 10437 * 10438 * @private 10439 * @param {*} value The value to inspect. 10440 * @returns {Function} Returns cast function. 10441 */ 10442 function castFunction(value) { 10443 return typeof value == 'function' ? value : identity; 10444 } 10445 10446 /** 10447 * Casts `value` to a path array if it's not one. 10448 * 10449 * @private 10450 * @param {*} value The value to inspect. 10451 * @param {Object} [object] The object to query keys on. 10452 * @returns {Array} Returns the cast property path array. 10453 */ 10454 function castPath(value, object) { 10455 if (isArray(value)) { 10456 return value; 10457 } 10458 return isKey(value, object) ? [value] : stringToPath(toString(value)); 10459 } 10460 10461 /** 10462 * A `baseRest` alias which can be replaced with `identity` by module 10463 * replacement plugins. 10464 * 10465 * @private 10466 * @type {Function} 10467 * @param {Function} func The function to apply a rest parameter to. 10468 * @returns {Function} Returns the new function. 10469 */ 10470 var castRest = baseRest; 10471 10472 /** 10473 * Casts `array` to a slice if it's needed. 10474 * 10475 * @private 10476 * @param {Array} array The array to inspect. 10477 * @param {number} start The start position. 10478 * @param {number} [end=array.length] The end position. 10479 * @returns {Array} Returns the cast slice. 10480 */ 10481 function castSlice(array, start, end) { 10482 var length = array.length; 10483 end = end === undefined$1 ? length : end; 10484 return (!start && end >= length) ? array : baseSlice(array, start, end); 10485 } 10486 10487 /** 10488 * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout). 10489 * 10490 * @private 10491 * @param {number|Object} id The timer id or timeout object of the timer to clear. 10492 */ 10493 var clearTimeout = ctxClearTimeout || function(id) { 10494 return root.clearTimeout(id); 10495 }; 10496 10497 /** 10498 * Creates a clone of `buffer`. 10499 * 10500 * @private 10501 * @param {Buffer} buffer The buffer to clone. 10502 * @param {boolean} [isDeep] Specify a deep clone. 10503 * @returns {Buffer} Returns the cloned buffer. 10504 */ 10505 function cloneBuffer(buffer, isDeep) { 10506 if (isDeep) { 10507 return buffer.slice(); 10508 } 10509 var length = buffer.length, 10510 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); 10511 10512 buffer.copy(result); 10513 return result; 10514 } 10515 10516 /** 10517 * Creates a clone of `arrayBuffer`. 10518 * 10519 * @private 10520 * @param {ArrayBuffer} arrayBuffer The array buffer to clone. 10521 * @returns {ArrayBuffer} Returns the cloned array buffer. 10522 */ 10523 function cloneArrayBuffer(arrayBuffer) { 10524 var result = new arrayBuffer.constructor(arrayBuffer.byteLength); 10525 new Uint8Array(result).set(new Uint8Array(arrayBuffer)); 10526 return result; 10527 } 10528 10529 /** 10530 * Creates a clone of `dataView`. 10531 * 10532 * @private 10533 * @param {Object} dataView The data view to clone. 10534 * @param {boolean} [isDeep] Specify a deep clone. 10535 * @returns {Object} Returns the cloned data view. 10536 */ 10537 function cloneDataView(dataView, isDeep) { 10538 var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; 10539 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); 10540 } 10541 10542 /** 10543 * Creates a clone of `regexp`. 10544 * 10545 * @private 10546 * @param {Object} regexp The regexp to clone. 10547 * @returns {Object} Returns the cloned regexp. 10548 */ 10549 function cloneRegExp(regexp) { 10550 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); 10551 result.lastIndex = regexp.lastIndex; 10552 return result; 10553 } 10554 10555 /** 10556 * Creates a clone of the `symbol` object. 10557 * 10558 * @private 10559 * @param {Object} symbol The symbol object to clone. 10560 * @returns {Object} Returns the cloned symbol object. 10561 */ 10562 function cloneSymbol(symbol) { 10563 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; 10564 } 10565 10566 /** 10567 * Creates a clone of `typedArray`. 10568 * 10569 * @private 10570 * @param {Object} typedArray The typed array to clone. 10571 * @param {boolean} [isDeep] Specify a deep clone. 10572 * @returns {Object} Returns the cloned typed array. 10573 */ 10574 function cloneTypedArray(typedArray, isDeep) { 10575 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; 10576 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); 10577 } 10578 10579 /** 10580 * Compares values to sort them in ascending order. 10581 * 10582 * @private 10583 * @param {*} value The value to compare. 10584 * @param {*} other The other value to compare. 10585 * @returns {number} Returns the sort order indicator for `value`. 10586 */ 10587 function compareAscending(value, other) { 10588 if (value !== other) { 10589 var valIsDefined = value !== undefined$1, 10590 valIsNull = value === null, 10591 valIsReflexive = value === value, 10592 valIsSymbol = isSymbol(value); 10593 10594 var othIsDefined = other !== undefined$1, 10595 othIsNull = other === null, 10596 othIsReflexive = other === other, 10597 othIsSymbol = isSymbol(other); 10598 10599 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || 10600 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || 10601 (valIsNull && othIsDefined && othIsReflexive) || 10602 (!valIsDefined && othIsReflexive) || 10603 !valIsReflexive) { 10604 return 1; 10605 } 10606 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || 10607 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || 10608 (othIsNull && valIsDefined && valIsReflexive) || 10609 (!othIsDefined && valIsReflexive) || 10610 !othIsReflexive) { 10611 return -1; 10612 } 10613 } 10614 return 0; 10615 } 10616 10617 /** 10618 * Used by `_.orderBy` to compare multiple properties of a value to another 10619 * and stable sort them. 10620 * 10621 * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, 10622 * specify an order of "desc" for descending or "asc" for ascending sort order 10623 * of corresponding values. 10624 * 10625 * @private 10626 * @param {Object} object The object to compare. 10627 * @param {Object} other The other object to compare. 10628 * @param {boolean[]|string[]} orders The order to sort by for each property. 10629 * @returns {number} Returns the sort order indicator for `object`. 10630 */ 10631 function compareMultiple(object, other, orders) { 10632 var index = -1, 10633 objCriteria = object.criteria, 10634 othCriteria = other.criteria, 10635 length = objCriteria.length, 10636 ordersLength = orders.length; 10637 10638 while (++index < length) { 10639 var result = compareAscending(objCriteria[index], othCriteria[index]); 10640 if (result) { 10641 if (index >= ordersLength) { 10642 return result; 10643 } 10644 var order = orders[index]; 10645 return result * (order == 'desc' ? -1 : 1); 10646 } 10647 } 10648 // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications 10649 // that causes it, under certain circumstances, to provide the same value for 10650 // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 10651 // for more details. 10652 // 10653 // This also ensures a stable sort in V8 and other engines. 10654 // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. 10655 return object.index - other.index; 10656 } 10657 10658 /** 10659 * Creates an array that is the composition of partially applied arguments, 10660 * placeholders, and provided arguments into a single array of arguments. 10661 * 10662 * @private 10663 * @param {Array} args The provided arguments. 10664 * @param {Array} partials The arguments to prepend to those provided. 10665 * @param {Array} holders The `partials` placeholder indexes. 10666 * @params {boolean} [isCurried] Specify composing for a curried function. 10667 * @returns {Array} Returns the new array of composed arguments. 10668 */ 10669 function composeArgs(args, partials, holders, isCurried) { 10670 var argsIndex = -1, 10671 argsLength = args.length, 10672 holdersLength = holders.length, 10673 leftIndex = -1, 10674 leftLength = partials.length, 10675 rangeLength = nativeMax(argsLength - holdersLength, 0), 10676 result = Array(leftLength + rangeLength), 10677 isUncurried = !isCurried; 10678 10679 while (++leftIndex < leftLength) { 10680 result[leftIndex] = partials[leftIndex]; 10681 } 10682 while (++argsIndex < holdersLength) { 10683 if (isUncurried || argsIndex < argsLength) { 10684 result[holders[argsIndex]] = args[argsIndex]; 10685 } 10686 } 10687 while (rangeLength--) { 10688 result[leftIndex++] = args[argsIndex++]; 10689 } 10690 return result; 10691 } 10692 10693 /** 10694 * This function is like `composeArgs` except that the arguments composition 10695 * is tailored for `_.partialRight`. 10696 * 10697 * @private 10698 * @param {Array} args The provided arguments. 10699 * @param {Array} partials The arguments to append to those provided. 10700 * @param {Array} holders The `partials` placeholder indexes. 10701 * @params {boolean} [isCurried] Specify composing for a curried function. 10702 * @returns {Array} Returns the new array of composed arguments. 10703 */ 10704 function composeArgsRight(args, partials, holders, isCurried) { 10705 var argsIndex = -1, 10706 argsLength = args.length, 10707 holdersIndex = -1, 10708 holdersLength = holders.length, 10709 rightIndex = -1, 10710 rightLength = partials.length, 10711 rangeLength = nativeMax(argsLength - holdersLength, 0), 10712 result = Array(rangeLength + rightLength), 10713 isUncurried = !isCurried; 10714 10715 while (++argsIndex < rangeLength) { 10716 result[argsIndex] = args[argsIndex]; 10717 } 10718 var offset = argsIndex; 10719 while (++rightIndex < rightLength) { 10720 result[offset + rightIndex] = partials[rightIndex]; 10721 } 10722 while (++holdersIndex < holdersLength) { 10723 if (isUncurried || argsIndex < argsLength) { 10724 result[offset + holders[holdersIndex]] = args[argsIndex++]; 10725 } 10726 } 10727 return result; 10728 } 10729 10730 /** 10731 * Copies the values of `source` to `array`. 10732 * 10733 * @private 10734 * @param {Array} source The array to copy values from. 10735 * @param {Array} [array=[]] The array to copy values to. 10736 * @returns {Array} Returns `array`. 10737 */ 10738 function copyArray(source, array) { 10739 var index = -1, 10740 length = source.length; 10741 10742 array || (array = Array(length)); 10743 while (++index < length) { 10744 array[index] = source[index]; 10745 } 10746 return array; 10747 } 10748 10749 /** 10750 * Copies properties of `source` to `object`. 10751 * 10752 * @private 10753 * @param {Object} source The object to copy properties from. 10754 * @param {Array} props The property identifiers to copy. 10755 * @param {Object} [object={}] The object to copy properties to. 10756 * @param {Function} [customizer] The function to customize copied values. 10757 * @returns {Object} Returns `object`. 10758 */ 10759 function copyObject(source, props, object, customizer) { 10760 var isNew = !object; 10761 object || (object = {}); 10762 10763 var index = -1, 10764 length = props.length; 10765 10766 while (++index < length) { 10767 var key = props[index]; 10768 10769 var newValue = customizer 10770 ? customizer(object[key], source[key], key, object, source) 10771 : undefined$1; 10772 10773 if (newValue === undefined$1) { 10774 newValue = source[key]; 10775 } 10776 if (isNew) { 10777 baseAssignValue(object, key, newValue); 10778 } else { 10779 assignValue(object, key, newValue); 10780 } 10781 } 10782 return object; 10783 } 10784 10785 /** 10786 * Copies own symbols of `source` to `object`. 10787 * 10788 * @private 10789 * @param {Object} source The object to copy symbols from. 10790 * @param {Object} [object={}] The object to copy symbols to. 10791 * @returns {Object} Returns `object`. 10792 */ 10793 function copySymbols(source, object) { 10794 return copyObject(source, getSymbols(source), object); 10795 } 10796 10797 /** 10798 * Copies own and inherited symbols of `source` to `object`. 10799 * 10800 * @private 10801 * @param {Object} source The object to copy symbols from. 10802 * @param {Object} [object={}] The object to copy symbols to. 10803 * @returns {Object} Returns `object`. 10804 */ 10805 function copySymbolsIn(source, object) { 10806 return copyObject(source, getSymbolsIn(source), object); 10807 } 10808 10809 /** 10810 * Creates a function like `_.groupBy`. 10811 * 10812 * @private 10813 * @param {Function} setter The function to set accumulator values. 10814 * @param {Function} [initializer] The accumulator object initializer. 10815 * @returns {Function} Returns the new aggregator function. 10816 */ 10817 function createAggregator(setter, initializer) { 10818 return function(collection, iteratee) { 10819 var func = isArray(collection) ? arrayAggregator : baseAggregator, 10820 accumulator = initializer ? initializer() : {}; 10821 10822 return func(collection, setter, getIteratee(iteratee, 2), accumulator); 10823 }; 10824 } 10825 10826 /** 10827 * Creates a function like `_.assign`. 10828 * 10829 * @private 10830 * @param {Function} assigner The function to assign values. 10831 * @returns {Function} Returns the new assigner function. 10832 */ 10833 function createAssigner(assigner) { 10834 return baseRest(function(object, sources) { 10835 var index = -1, 10836 length = sources.length, 10837 customizer = length > 1 ? sources[length - 1] : undefined$1, 10838 guard = length > 2 ? sources[2] : undefined$1; 10839 10840 customizer = (assigner.length > 3 && typeof customizer == 'function') 10841 ? (length--, customizer) 10842 : undefined$1; 10843 10844 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 10845 customizer = length < 3 ? undefined$1 : customizer; 10846 length = 1; 10847 } 10848 object = Object(object); 10849 while (++index < length) { 10850 var source = sources[index]; 10851 if (source) { 10852 assigner(object, source, index, customizer); 10853 } 10854 } 10855 return object; 10856 }); 10857 } 10858 10859 /** 10860 * Creates a `baseEach` or `baseEachRight` function. 10861 * 10862 * @private 10863 * @param {Function} eachFunc The function to iterate over a collection. 10864 * @param {boolean} [fromRight] Specify iterating from right to left. 10865 * @returns {Function} Returns the new base function. 10866 */ 10867 function createBaseEach(eachFunc, fromRight) { 10868 return function(collection, iteratee) { 10869 if (collection == null) { 10870 return collection; 10871 } 10872 if (!isArrayLike(collection)) { 10873 return eachFunc(collection, iteratee); 10874 } 10875 var length = collection.length, 10876 index = fromRight ? length : -1, 10877 iterable = Object(collection); 10878 10879 while ((fromRight ? index-- : ++index < length)) { 10880 if (iteratee(iterable[index], index, iterable) === false) { 10881 break; 10882 } 10883 } 10884 return collection; 10885 }; 10886 } 10887 10888 /** 10889 * Creates a base function for methods like `_.forIn` and `_.forOwn`. 10890 * 10891 * @private 10892 * @param {boolean} [fromRight] Specify iterating from right to left. 10893 * @returns {Function} Returns the new base function. 10894 */ 10895 function createBaseFor(fromRight) { 10896 return function(object, iteratee, keysFunc) { 10897 var index = -1, 10898 iterable = Object(object), 10899 props = keysFunc(object), 10900 length = props.length; 10901 10902 while (length--) { 10903 var key = props[fromRight ? length : ++index]; 10904 if (iteratee(iterable[key], key, iterable) === false) { 10905 break; 10906 } 10907 } 10908 return object; 10909 }; 10910 } 10911 10912 /** 10913 * Creates a function that wraps `func` to invoke it with the optional `this` 10914 * binding of `thisArg`. 10915 * 10916 * @private 10917 * @param {Function} func The function to wrap. 10918 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 10919 * @param {*} [thisArg] The `this` binding of `func`. 10920 * @returns {Function} Returns the new wrapped function. 10921 */ 10922 function createBind(func, bitmask, thisArg) { 10923 var isBind = bitmask & WRAP_BIND_FLAG, 10924 Ctor = createCtor(func); 10925 10926 function wrapper() { 10927 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 10928 return fn.apply(isBind ? thisArg : this, arguments); 10929 } 10930 return wrapper; 10931 } 10932 10933 /** 10934 * Creates a function like `_.lowerFirst`. 10935 * 10936 * @private 10937 * @param {string} methodName The name of the `String` case method to use. 10938 * @returns {Function} Returns the new case function. 10939 */ 10940 function createCaseFirst(methodName) { 10941 return function(string) { 10942 string = toString(string); 10943 10944 var strSymbols = hasUnicode(string) 10945 ? stringToArray(string) 10946 : undefined$1; 10947 10948 var chr = strSymbols 10949 ? strSymbols[0] 10950 : string.charAt(0); 10951 10952 var trailing = strSymbols 10953 ? castSlice(strSymbols, 1).join('') 10954 : string.slice(1); 10955 10956 return chr[methodName]() + trailing; 10957 }; 10958 } 10959 10960 /** 10961 * Creates a function like `_.camelCase`. 10962 * 10963 * @private 10964 * @param {Function} callback The function to combine each word. 10965 * @returns {Function} Returns the new compounder function. 10966 */ 10967 function createCompounder(callback) { 10968 return function(string) { 10969 return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); 10970 }; 10971 } 10972 10973 /** 10974 * Creates a function that produces an instance of `Ctor` regardless of 10975 * whether it was invoked as part of a `new` expression or by `call` or `apply`. 10976 * 10977 * @private 10978 * @param {Function} Ctor The constructor to wrap. 10979 * @returns {Function} Returns the new wrapped function. 10980 */ 10981 function createCtor(Ctor) { 10982 return function() { 10983 // Use a `switch` statement to work with class constructors. See 10984 // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist 10985 // for more details. 10986 var args = arguments; 10987 switch (args.length) { 10988 case 0: return new Ctor; 10989 case 1: return new Ctor(args[0]); 10990 case 2: return new Ctor(args[0], args[1]); 10991 case 3: return new Ctor(args[0], args[1], args[2]); 10992 case 4: return new Ctor(args[0], args[1], args[2], args[3]); 10993 case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); 10994 case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); 10995 case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); 10996 } 10997 var thisBinding = baseCreate(Ctor.prototype), 10998 result = Ctor.apply(thisBinding, args); 10999 11000 // Mimic the constructor's `return` behavior. 11001 // See https://es5.github.io/#x13.2.2 for more details. 11002 return isObject(result) ? result : thisBinding; 11003 }; 11004 } 11005 11006 /** 11007 * Creates a function that wraps `func` to enable currying. 11008 * 11009 * @private 11010 * @param {Function} func The function to wrap. 11011 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 11012 * @param {number} arity The arity of `func`. 11013 * @returns {Function} Returns the new wrapped function. 11014 */ 11015 function createCurry(func, bitmask, arity) { 11016 var Ctor = createCtor(func); 11017 11018 function wrapper() { 11019 var length = arguments.length, 11020 args = Array(length), 11021 index = length, 11022 placeholder = getHolder(wrapper); 11023 11024 while (index--) { 11025 args[index] = arguments[index]; 11026 } 11027 var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) 11028 ? [] 11029 : replaceHolders(args, placeholder); 11030 11031 length -= holders.length; 11032 if (length < arity) { 11033 return createRecurry( 11034 func, bitmask, createHybrid, wrapper.placeholder, undefined$1, 11035 args, holders, undefined$1, undefined$1, arity - length); 11036 } 11037 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 11038 return apply(fn, this, args); 11039 } 11040 return wrapper; 11041 } 11042 11043 /** 11044 * Creates a `_.find` or `_.findLast` function. 11045 * 11046 * @private 11047 * @param {Function} findIndexFunc The function to find the collection index. 11048 * @returns {Function} Returns the new find function. 11049 */ 11050 function createFind(findIndexFunc) { 11051 return function(collection, predicate, fromIndex) { 11052 var iterable = Object(collection); 11053 if (!isArrayLike(collection)) { 11054 var iteratee = getIteratee(predicate, 3); 11055 collection = keys(collection); 11056 predicate = function(key) { return iteratee(iterable[key], key, iterable); }; 11057 } 11058 var index = findIndexFunc(collection, predicate, fromIndex); 11059 return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined$1; 11060 }; 11061 } 11062 11063 /** 11064 * Creates a `_.flow` or `_.flowRight` function. 11065 * 11066 * @private 11067 * @param {boolean} [fromRight] Specify iterating from right to left. 11068 * @returns {Function} Returns the new flow function. 11069 */ 11070 function createFlow(fromRight) { 11071 return flatRest(function(funcs) { 11072 var length = funcs.length, 11073 index = length, 11074 prereq = LodashWrapper.prototype.thru; 11075 11076 if (fromRight) { 11077 funcs.reverse(); 11078 } 11079 while (index--) { 11080 var func = funcs[index]; 11081 if (typeof func != 'function') { 11082 throw new TypeError(FUNC_ERROR_TEXT); 11083 } 11084 if (prereq && !wrapper && getFuncName(func) == 'wrapper') { 11085 var wrapper = new LodashWrapper([], true); 11086 } 11087 } 11088 index = wrapper ? index : length; 11089 while (++index < length) { 11090 func = funcs[index]; 11091 11092 var funcName = getFuncName(func), 11093 data = funcName == 'wrapper' ? getData(func) : undefined$1; 11094 11095 if (data && isLaziable(data[0]) && 11096 data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) && 11097 !data[4].length && data[9] == 1 11098 ) { 11099 wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); 11100 } else { 11101 wrapper = (func.length == 1 && isLaziable(func)) 11102 ? wrapper[funcName]() 11103 : wrapper.thru(func); 11104 } 11105 } 11106 return function() { 11107 var args = arguments, 11108 value = args[0]; 11109 11110 if (wrapper && args.length == 1 && isArray(value)) { 11111 return wrapper.plant(value).value(); 11112 } 11113 var index = 0, 11114 result = length ? funcs[index].apply(this, args) : value; 11115 11116 while (++index < length) { 11117 result = funcs[index].call(this, result); 11118 } 11119 return result; 11120 }; 11121 }); 11122 } 11123 11124 /** 11125 * Creates a function that wraps `func` to invoke it with optional `this` 11126 * binding of `thisArg`, partial application, and currying. 11127 * 11128 * @private 11129 * @param {Function|string} func The function or method name to wrap. 11130 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 11131 * @param {*} [thisArg] The `this` binding of `func`. 11132 * @param {Array} [partials] The arguments to prepend to those provided to 11133 * the new function. 11134 * @param {Array} [holders] The `partials` placeholder indexes. 11135 * @param {Array} [partialsRight] The arguments to append to those provided 11136 * to the new function. 11137 * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. 11138 * @param {Array} [argPos] The argument positions of the new function. 11139 * @param {number} [ary] The arity cap of `func`. 11140 * @param {number} [arity] The arity of `func`. 11141 * @returns {Function} Returns the new wrapped function. 11142 */ 11143 function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { 11144 var isAry = bitmask & WRAP_ARY_FLAG, 11145 isBind = bitmask & WRAP_BIND_FLAG, 11146 isBindKey = bitmask & WRAP_BIND_KEY_FLAG, 11147 isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), 11148 isFlip = bitmask & WRAP_FLIP_FLAG, 11149 Ctor = isBindKey ? undefined$1 : createCtor(func); 11150 11151 function wrapper() { 11152 var length = arguments.length, 11153 args = Array(length), 11154 index = length; 11155 11156 while (index--) { 11157 args[index] = arguments[index]; 11158 } 11159 if (isCurried) { 11160 var placeholder = getHolder(wrapper), 11161 holdersCount = countHolders(args, placeholder); 11162 } 11163 if (partials) { 11164 args = composeArgs(args, partials, holders, isCurried); 11165 } 11166 if (partialsRight) { 11167 args = composeArgsRight(args, partialsRight, holdersRight, isCurried); 11168 } 11169 length -= holdersCount; 11170 if (isCurried && length < arity) { 11171 var newHolders = replaceHolders(args, placeholder); 11172 return createRecurry( 11173 func, bitmask, createHybrid, wrapper.placeholder, thisArg, 11174 args, newHolders, argPos, ary, arity - length 11175 ); 11176 } 11177 var thisBinding = isBind ? thisArg : this, 11178 fn = isBindKey ? thisBinding[func] : func; 11179 11180 length = args.length; 11181 if (argPos) { 11182 args = reorder(args, argPos); 11183 } else if (isFlip && length > 1) { 11184 args.reverse(); 11185 } 11186 if (isAry && ary < length) { 11187 args.length = ary; 11188 } 11189 if (this && this !== root && this instanceof wrapper) { 11190 fn = Ctor || createCtor(fn); 11191 } 11192 return fn.apply(thisBinding, args); 11193 } 11194 return wrapper; 11195 } 11196 11197 /** 11198 * Creates a function like `_.invertBy`. 11199 * 11200 * @private 11201 * @param {Function} setter The function to set accumulator values. 11202 * @param {Function} toIteratee The function to resolve iteratees. 11203 * @returns {Function} Returns the new inverter function. 11204 */ 11205 function createInverter(setter, toIteratee) { 11206 return function(object, iteratee) { 11207 return baseInverter(object, setter, toIteratee(iteratee), {}); 11208 }; 11209 } 11210 11211 /** 11212 * Creates a function that performs a mathematical operation on two values. 11213 * 11214 * @private 11215 * @param {Function} operator The function to perform the operation. 11216 * @param {number} [defaultValue] The value used for `undefined` arguments. 11217 * @returns {Function} Returns the new mathematical operation function. 11218 */ 11219 function createMathOperation(operator, defaultValue) { 11220 return function(value, other) { 11221 var result; 11222 if (value === undefined$1 && other === undefined$1) { 11223 return defaultValue; 11224 } 11225 if (value !== undefined$1) { 11226 result = value; 11227 } 11228 if (other !== undefined$1) { 11229 if (result === undefined$1) { 11230 return other; 11231 } 11232 if (typeof value == 'string' || typeof other == 'string') { 11233 value = baseToString(value); 11234 other = baseToString(other); 11235 } else { 11236 value = baseToNumber(value); 11237 other = baseToNumber(other); 11238 } 11239 result = operator(value, other); 11240 } 11241 return result; 11242 }; 11243 } 11244 11245 /** 11246 * Creates a function like `_.over`. 11247 * 11248 * @private 11249 * @param {Function} arrayFunc The function to iterate over iteratees. 11250 * @returns {Function} Returns the new over function. 11251 */ 11252 function createOver(arrayFunc) { 11253 return flatRest(function(iteratees) { 11254 iteratees = arrayMap(iteratees, baseUnary(getIteratee())); 11255 return baseRest(function(args) { 11256 var thisArg = this; 11257 return arrayFunc(iteratees, function(iteratee) { 11258 return apply(iteratee, thisArg, args); 11259 }); 11260 }); 11261 }); 11262 } 11263 11264 /** 11265 * Creates the padding for `string` based on `length`. The `chars` string 11266 * is truncated if the number of characters exceeds `length`. 11267 * 11268 * @private 11269 * @param {number} length The padding length. 11270 * @param {string} [chars=' '] The string used as padding. 11271 * @returns {string} Returns the padding for `string`. 11272 */ 11273 function createPadding(length, chars) { 11274 chars = chars === undefined$1 ? ' ' : baseToString(chars); 11275 11276 var charsLength = chars.length; 11277 if (charsLength < 2) { 11278 return charsLength ? baseRepeat(chars, length) : chars; 11279 } 11280 var result = baseRepeat(chars, nativeCeil(length / stringSize(chars))); 11281 return hasUnicode(chars) 11282 ? castSlice(stringToArray(result), 0, length).join('') 11283 : result.slice(0, length); 11284 } 11285 11286 /** 11287 * Creates a function that wraps `func` to invoke it with the `this` binding 11288 * of `thisArg` and `partials` prepended to the arguments it receives. 11289 * 11290 * @private 11291 * @param {Function} func The function to wrap. 11292 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 11293 * @param {*} thisArg The `this` binding of `func`. 11294 * @param {Array} partials The arguments to prepend to those provided to 11295 * the new function. 11296 * @returns {Function} Returns the new wrapped function. 11297 */ 11298 function createPartial(func, bitmask, thisArg, partials) { 11299 var isBind = bitmask & WRAP_BIND_FLAG, 11300 Ctor = createCtor(func); 11301 11302 function wrapper() { 11303 var argsIndex = -1, 11304 argsLength = arguments.length, 11305 leftIndex = -1, 11306 leftLength = partials.length, 11307 args = Array(leftLength + argsLength), 11308 fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 11309 11310 while (++leftIndex < leftLength) { 11311 args[leftIndex] = partials[leftIndex]; 11312 } 11313 while (argsLength--) { 11314 args[leftIndex++] = arguments[++argsIndex]; 11315 } 11316 return apply(fn, isBind ? thisArg : this, args); 11317 } 11318 return wrapper; 11319 } 11320 11321 /** 11322 * Creates a `_.range` or `_.rangeRight` function. 11323 * 11324 * @private 11325 * @param {boolean} [fromRight] Specify iterating from right to left. 11326 * @returns {Function} Returns the new range function. 11327 */ 11328 function createRange(fromRight) { 11329 return function(start, end, step) { 11330 if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { 11331 end = step = undefined$1; 11332 } 11333 // Ensure the sign of `-0` is preserved. 11334 start = toFinite(start); 11335 if (end === undefined$1) { 11336 end = start; 11337 start = 0; 11338 } else { 11339 end = toFinite(end); 11340 } 11341 step = step === undefined$1 ? (start < end ? 1 : -1) : toFinite(step); 11342 return baseRange(start, end, step, fromRight); 11343 }; 11344 } 11345 11346 /** 11347 * Creates a function that performs a relational operation on two values. 11348 * 11349 * @private 11350 * @param {Function} operator The function to perform the operation. 11351 * @returns {Function} Returns the new relational operation function. 11352 */ 11353 function createRelationalOperation(operator) { 11354 return function(value, other) { 11355 if (!(typeof value == 'string' && typeof other == 'string')) { 11356 value = toNumber(value); 11357 other = toNumber(other); 11358 } 11359 return operator(value, other); 11360 }; 11361 } 11362 11363 /** 11364 * Creates a function that wraps `func` to continue currying. 11365 * 11366 * @private 11367 * @param {Function} func The function to wrap. 11368 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 11369 * @param {Function} wrapFunc The function to create the `func` wrapper. 11370 * @param {*} placeholder The placeholder value. 11371 * @param {*} [thisArg] The `this` binding of `func`. 11372 * @param {Array} [partials] The arguments to prepend to those provided to 11373 * the new function. 11374 * @param {Array} [holders] The `partials` placeholder indexes. 11375 * @param {Array} [argPos] The argument positions of the new function. 11376 * @param {number} [ary] The arity cap of `func`. 11377 * @param {number} [arity] The arity of `func`. 11378 * @returns {Function} Returns the new wrapped function. 11379 */ 11380 function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { 11381 var isCurry = bitmask & WRAP_CURRY_FLAG, 11382 newHolders = isCurry ? holders : undefined$1, 11383 newHoldersRight = isCurry ? undefined$1 : holders, 11384 newPartials = isCurry ? partials : undefined$1, 11385 newPartialsRight = isCurry ? undefined$1 : partials; 11386 11387 bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG); 11388 bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG); 11389 11390 if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) { 11391 bitmask &= -4; 11392 } 11393 var newData = [ 11394 func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, 11395 newHoldersRight, argPos, ary, arity 11396 ]; 11397 11398 var result = wrapFunc.apply(undefined$1, newData); 11399 if (isLaziable(func)) { 11400 setData(result, newData); 11401 } 11402 result.placeholder = placeholder; 11403 return setWrapToString(result, func, bitmask); 11404 } 11405 11406 /** 11407 * Creates a function like `_.round`. 11408 * 11409 * @private 11410 * @param {string} methodName The name of the `Math` method to use when rounding. 11411 * @returns {Function} Returns the new round function. 11412 */ 11413 function createRound(methodName) { 11414 var func = Math[methodName]; 11415 return function(number, precision) { 11416 number = toNumber(number); 11417 precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); 11418 if (precision && nativeIsFinite(number)) { 11419 // Shift with exponential notation to avoid floating-point issues. 11420 // See [MDN](https://mdn.io/round#Examples) for more details. 11421 var pair = (toString(number) + 'e').split('e'), 11422 value = func(pair[0] + 'e' + (+pair[1] + precision)); 11423 11424 pair = (toString(value) + 'e').split('e'); 11425 return +(pair[0] + 'e' + (+pair[1] - precision)); 11426 } 11427 return func(number); 11428 }; 11429 } 11430 11431 /** 11432 * Creates a set object of `values`. 11433 * 11434 * @private 11435 * @param {Array} values The values to add to the set. 11436 * @returns {Object} Returns the new set. 11437 */ 11438 var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { 11439 return new Set(values); 11440 }; 11441 11442 /** 11443 * Creates a `_.toPairs` or `_.toPairsIn` function. 11444 * 11445 * @private 11446 * @param {Function} keysFunc The function to get the keys of a given object. 11447 * @returns {Function} Returns the new pairs function. 11448 */ 11449 function createToPairs(keysFunc) { 11450 return function(object) { 11451 var tag = getTag(object); 11452 if (tag == mapTag) { 11453 return mapToArray(object); 11454 } 11455 if (tag == setTag) { 11456 return setToPairs(object); 11457 } 11458 return baseToPairs(object, keysFunc(object)); 11459 }; 11460 } 11461 11462 /** 11463 * Creates a function that either curries or invokes `func` with optional 11464 * `this` binding and partially applied arguments. 11465 * 11466 * @private 11467 * @param {Function|string} func The function or method name to wrap. 11468 * @param {number} bitmask The bitmask flags. 11469 * 1 - `_.bind` 11470 * 2 - `_.bindKey` 11471 * 4 - `_.curry` or `_.curryRight` of a bound function 11472 * 8 - `_.curry` 11473 * 16 - `_.curryRight` 11474 * 32 - `_.partial` 11475 * 64 - `_.partialRight` 11476 * 128 - `_.rearg` 11477 * 256 - `_.ary` 11478 * 512 - `_.flip` 11479 * @param {*} [thisArg] The `this` binding of `func`. 11480 * @param {Array} [partials] The arguments to be partially applied. 11481 * @param {Array} [holders] The `partials` placeholder indexes. 11482 * @param {Array} [argPos] The argument positions of the new function. 11483 * @param {number} [ary] The arity cap of `func`. 11484 * @param {number} [arity] The arity of `func`. 11485 * @returns {Function} Returns the new wrapped function. 11486 */ 11487 function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { 11488 var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; 11489 if (!isBindKey && typeof func != 'function') { 11490 throw new TypeError(FUNC_ERROR_TEXT); 11491 } 11492 var length = partials ? partials.length : 0; 11493 if (!length) { 11494 bitmask &= -97; 11495 partials = holders = undefined$1; 11496 } 11497 ary = ary === undefined$1 ? ary : nativeMax(toInteger(ary), 0); 11498 arity = arity === undefined$1 ? arity : toInteger(arity); 11499 length -= holders ? holders.length : 0; 11500 11501 if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { 11502 var partialsRight = partials, 11503 holdersRight = holders; 11504 11505 partials = holders = undefined$1; 11506 } 11507 var data = isBindKey ? undefined$1 : getData(func); 11508 11509 var newData = [ 11510 func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, 11511 argPos, ary, arity 11512 ]; 11513 11514 if (data) { 11515 mergeData(newData, data); 11516 } 11517 func = newData[0]; 11518 bitmask = newData[1]; 11519 thisArg = newData[2]; 11520 partials = newData[3]; 11521 holders = newData[4]; 11522 arity = newData[9] = newData[9] === undefined$1 11523 ? (isBindKey ? 0 : func.length) 11524 : nativeMax(newData[9] - length, 0); 11525 11526 if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { 11527 bitmask &= -25; 11528 } 11529 if (!bitmask || bitmask == WRAP_BIND_FLAG) { 11530 var result = createBind(func, bitmask, thisArg); 11531 } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) { 11532 result = createCurry(func, bitmask, arity); 11533 } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) { 11534 result = createPartial(func, bitmask, thisArg, partials); 11535 } else { 11536 result = createHybrid.apply(undefined$1, newData); 11537 } 11538 var setter = data ? baseSetData : setData; 11539 return setWrapToString(setter(result, newData), func, bitmask); 11540 } 11541 11542 /** 11543 * Used by `_.defaults` to customize its `_.assignIn` use to assign properties 11544 * of source objects to the destination object for all destination properties 11545 * that resolve to `undefined`. 11546 * 11547 * @private 11548 * @param {*} objValue The destination value. 11549 * @param {*} srcValue The source value. 11550 * @param {string} key The key of the property to assign. 11551 * @param {Object} object The parent object of `objValue`. 11552 * @returns {*} Returns the value to assign. 11553 */ 11554 function customDefaultsAssignIn(objValue, srcValue, key, object) { 11555 if (objValue === undefined$1 || 11556 (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { 11557 return srcValue; 11558 } 11559 return objValue; 11560 } 11561 11562 /** 11563 * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source 11564 * objects into destination objects that are passed thru. 11565 * 11566 * @private 11567 * @param {*} objValue The destination value. 11568 * @param {*} srcValue The source value. 11569 * @param {string} key The key of the property to merge. 11570 * @param {Object} object The parent object of `objValue`. 11571 * @param {Object} source The parent object of `srcValue`. 11572 * @param {Object} [stack] Tracks traversed source values and their merged 11573 * counterparts. 11574 * @returns {*} Returns the value to assign. 11575 */ 11576 function customDefaultsMerge(objValue, srcValue, key, object, source, stack) { 11577 if (isObject(objValue) && isObject(srcValue)) { 11578 // Recursively merge objects and arrays (susceptible to call stack limits). 11579 stack.set(srcValue, objValue); 11580 baseMerge(objValue, srcValue, undefined$1, customDefaultsMerge, stack); 11581 stack['delete'](srcValue); 11582 } 11583 return objValue; 11584 } 11585 11586 /** 11587 * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain 11588 * objects. 11589 * 11590 * @private 11591 * @param {*} value The value to inspect. 11592 * @param {string} key The key of the property to inspect. 11593 * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`. 11594 */ 11595 function customOmitClone(value) { 11596 return isPlainObject(value) ? undefined$1 : value; 11597 } 11598 11599 /** 11600 * A specialized version of `baseIsEqualDeep` for arrays with support for 11601 * partial deep comparisons. 11602 * 11603 * @private 11604 * @param {Array} array The array to compare. 11605 * @param {Array} other The other array to compare. 11606 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 11607 * @param {Function} customizer The function to customize comparisons. 11608 * @param {Function} equalFunc The function to determine equivalents of values. 11609 * @param {Object} stack Tracks traversed `array` and `other` objects. 11610 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. 11611 */ 11612 function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { 11613 var isPartial = bitmask & COMPARE_PARTIAL_FLAG, 11614 arrLength = array.length, 11615 othLength = other.length; 11616 11617 if (arrLength != othLength && !(isPartial && othLength > arrLength)) { 11618 return false; 11619 } 11620 // Check that cyclic values are equal. 11621 var arrStacked = stack.get(array); 11622 var othStacked = stack.get(other); 11623 if (arrStacked && othStacked) { 11624 return arrStacked == other && othStacked == array; 11625 } 11626 var index = -1, 11627 result = true, 11628 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined$1; 11629 11630 stack.set(array, other); 11631 stack.set(other, array); 11632 11633 // Ignore non-index properties. 11634 while (++index < arrLength) { 11635 var arrValue = array[index], 11636 othValue = other[index]; 11637 11638 if (customizer) { 11639 var compared = isPartial 11640 ? customizer(othValue, arrValue, index, other, array, stack) 11641 : customizer(arrValue, othValue, index, array, other, stack); 11642 } 11643 if (compared !== undefined$1) { 11644 if (compared) { 11645 continue; 11646 } 11647 result = false; 11648 break; 11649 } 11650 // Recursively compare arrays (susceptible to call stack limits). 11651 if (seen) { 11652 if (!arraySome(other, function(othValue, othIndex) { 11653 if (!cacheHas(seen, othIndex) && 11654 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { 11655 return seen.push(othIndex); 11656 } 11657 })) { 11658 result = false; 11659 break; 11660 } 11661 } else if (!( 11662 arrValue === othValue || 11663 equalFunc(arrValue, othValue, bitmask, customizer, stack) 11664 )) { 11665 result = false; 11666 break; 11667 } 11668 } 11669 stack['delete'](array); 11670 stack['delete'](other); 11671 return result; 11672 } 11673 11674 /** 11675 * A specialized version of `baseIsEqualDeep` for comparing objects of 11676 * the same `toStringTag`. 11677 * 11678 * **Note:** This function only supports comparing values with tags of 11679 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. 11680 * 11681 * @private 11682 * @param {Object} object The object to compare. 11683 * @param {Object} other The other object to compare. 11684 * @param {string} tag The `toStringTag` of the objects to compare. 11685 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 11686 * @param {Function} customizer The function to customize comparisons. 11687 * @param {Function} equalFunc The function to determine equivalents of values. 11688 * @param {Object} stack Tracks traversed `object` and `other` objects. 11689 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 11690 */ 11691 function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { 11692 switch (tag) { 11693 case dataViewTag: 11694 if ((object.byteLength != other.byteLength) || 11695 (object.byteOffset != other.byteOffset)) { 11696 return false; 11697 } 11698 object = object.buffer; 11699 other = other.buffer; 11700 11701 case arrayBufferTag: 11702 if ((object.byteLength != other.byteLength) || 11703 !equalFunc(new Uint8Array(object), new Uint8Array(other))) { 11704 return false; 11705 } 11706 return true; 11707 11708 case boolTag: 11709 case dateTag: 11710 case numberTag: 11711 // Coerce booleans to `1` or `0` and dates to milliseconds. 11712 // Invalid dates are coerced to `NaN`. 11713 return eq(+object, +other); 11714 11715 case errorTag: 11716 return object.name == other.name && object.message == other.message; 11717 11718 case regexpTag: 11719 case stringTag: 11720 // Coerce regexes to strings and treat strings, primitives and objects, 11721 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring 11722 // for more details. 11723 return object == (other + ''); 11724 11725 case mapTag: 11726 var convert = mapToArray; 11727 11728 case setTag: 11729 var isPartial = bitmask & COMPARE_PARTIAL_FLAG; 11730 convert || (convert = setToArray); 11731 11732 if (object.size != other.size && !isPartial) { 11733 return false; 11734 } 11735 // Assume cyclic values are equal. 11736 var stacked = stack.get(object); 11737 if (stacked) { 11738 return stacked == other; 11739 } 11740 bitmask |= COMPARE_UNORDERED_FLAG; 11741 11742 // Recursively compare objects (susceptible to call stack limits). 11743 stack.set(object, other); 11744 var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); 11745 stack['delete'](object); 11746 return result; 11747 11748 case symbolTag: 11749 if (symbolValueOf) { 11750 return symbolValueOf.call(object) == symbolValueOf.call(other); 11751 } 11752 } 11753 return false; 11754 } 11755 11756 /** 11757 * A specialized version of `baseIsEqualDeep` for objects with support for 11758 * partial deep comparisons. 11759 * 11760 * @private 11761 * @param {Object} object The object to compare. 11762 * @param {Object} other The other object to compare. 11763 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 11764 * @param {Function} customizer The function to customize comparisons. 11765 * @param {Function} equalFunc The function to determine equivalents of values. 11766 * @param {Object} stack Tracks traversed `object` and `other` objects. 11767 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 11768 */ 11769 function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { 11770 var isPartial = bitmask & COMPARE_PARTIAL_FLAG, 11771 objProps = getAllKeys(object), 11772 objLength = objProps.length, 11773 othProps = getAllKeys(other), 11774 othLength = othProps.length; 11775 11776 if (objLength != othLength && !isPartial) { 11777 return false; 11778 } 11779 var index = objLength; 11780 while (index--) { 11781 var key = objProps[index]; 11782 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { 11783 return false; 11784 } 11785 } 11786 // Check that cyclic values are equal. 11787 var objStacked = stack.get(object); 11788 var othStacked = stack.get(other); 11789 if (objStacked && othStacked) { 11790 return objStacked == other && othStacked == object; 11791 } 11792 var result = true; 11793 stack.set(object, other); 11794 stack.set(other, object); 11795 11796 var skipCtor = isPartial; 11797 while (++index < objLength) { 11798 key = objProps[index]; 11799 var objValue = object[key], 11800 othValue = other[key]; 11801 11802 if (customizer) { 11803 var compared = isPartial 11804 ? customizer(othValue, objValue, key, other, object, stack) 11805 : customizer(objValue, othValue, key, object, other, stack); 11806 } 11807 // Recursively compare objects (susceptible to call stack limits). 11808 if (!(compared === undefined$1 11809 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) 11810 : compared 11811 )) { 11812 result = false; 11813 break; 11814 } 11815 skipCtor || (skipCtor = key == 'constructor'); 11816 } 11817 if (result && !skipCtor) { 11818 var objCtor = object.constructor, 11819 othCtor = other.constructor; 11820 11821 // Non `Object` object instances with different constructors are not equal. 11822 if (objCtor != othCtor && 11823 ('constructor' in object && 'constructor' in other) && 11824 !(typeof objCtor == 'function' && objCtor instanceof objCtor && 11825 typeof othCtor == 'function' && othCtor instanceof othCtor)) { 11826 result = false; 11827 } 11828 } 11829 stack['delete'](object); 11830 stack['delete'](other); 11831 return result; 11832 } 11833 11834 /** 11835 * A specialized version of `baseRest` which flattens the rest array. 11836 * 11837 * @private 11838 * @param {Function} func The function to apply a rest parameter to. 11839 * @returns {Function} Returns the new function. 11840 */ 11841 function flatRest(func) { 11842 return setToString(overRest(func, undefined$1, flatten), func + ''); 11843 } 11844 11845 /** 11846 * Creates an array of own enumerable property names and symbols of `object`. 11847 * 11848 * @private 11849 * @param {Object} object The object to query. 11850 * @returns {Array} Returns the array of property names and symbols. 11851 */ 11852 function getAllKeys(object) { 11853 return baseGetAllKeys(object, keys, getSymbols); 11854 } 11855 11856 /** 11857 * Creates an array of own and inherited enumerable property names and 11858 * symbols of `object`. 11859 * 11860 * @private 11861 * @param {Object} object The object to query. 11862 * @returns {Array} Returns the array of property names and symbols. 11863 */ 11864 function getAllKeysIn(object) { 11865 return baseGetAllKeys(object, keysIn, getSymbolsIn); 11866 } 11867 11868 /** 11869 * Gets metadata for `func`. 11870 * 11871 * @private 11872 * @param {Function} func The function to query. 11873 * @returns {*} Returns the metadata for `func`. 11874 */ 11875 var getData = !metaMap ? noop : function(func) { 11876 return metaMap.get(func); 11877 }; 11878 11879 /** 11880 * Gets the name of `func`. 11881 * 11882 * @private 11883 * @param {Function} func The function to query. 11884 * @returns {string} Returns the function name. 11885 */ 11886 function getFuncName(func) { 11887 var result = (func.name + ''), 11888 array = realNames[result], 11889 length = hasOwnProperty.call(realNames, result) ? array.length : 0; 11890 11891 while (length--) { 11892 var data = array[length], 11893 otherFunc = data.func; 11894 if (otherFunc == null || otherFunc == func) { 11895 return data.name; 11896 } 11897 } 11898 return result; 11899 } 11900 11901 /** 11902 * Gets the argument placeholder value for `func`. 11903 * 11904 * @private 11905 * @param {Function} func The function to inspect. 11906 * @returns {*} Returns the placeholder value. 11907 */ 11908 function getHolder(func) { 11909 var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func; 11910 return object.placeholder; 11911 } 11912 11913 /** 11914 * Gets the appropriate "iteratee" function. If `_.iteratee` is customized, 11915 * this function returns the custom method, otherwise it returns `baseIteratee`. 11916 * If arguments are provided, the chosen function is invoked with them and 11917 * its result is returned. 11918 * 11919 * @private 11920 * @param {*} [value] The value to convert to an iteratee. 11921 * @param {number} [arity] The arity of the created iteratee. 11922 * @returns {Function} Returns the chosen function or its result. 11923 */ 11924 function getIteratee() { 11925 var result = lodash.iteratee || iteratee; 11926 result = result === iteratee ? baseIteratee : result; 11927 return arguments.length ? result(arguments[0], arguments[1]) : result; 11928 } 11929 11930 /** 11931 * Gets the data for `map`. 11932 * 11933 * @private 11934 * @param {Object} map The map to query. 11935 * @param {string} key The reference key. 11936 * @returns {*} Returns the map data. 11937 */ 11938 function getMapData(map, key) { 11939 var data = map.__data__; 11940 return isKeyable(key) 11941 ? data[typeof key == 'string' ? 'string' : 'hash'] 11942 : data.map; 11943 } 11944 11945 /** 11946 * Gets the property names, values, and compare flags of `object`. 11947 * 11948 * @private 11949 * @param {Object} object The object to query. 11950 * @returns {Array} Returns the match data of `object`. 11951 */ 11952 function getMatchData(object) { 11953 var result = keys(object), 11954 length = result.length; 11955 11956 while (length--) { 11957 var key = result[length], 11958 value = object[key]; 11959 11960 result[length] = [key, value, isStrictComparable(value)]; 11961 } 11962 return result; 11963 } 11964 11965 /** 11966 * Gets the native function at `key` of `object`. 11967 * 11968 * @private 11969 * @param {Object} object The object to query. 11970 * @param {string} key The key of the method to get. 11971 * @returns {*} Returns the function if it's native, else `undefined`. 11972 */ 11973 function getNative(object, key) { 11974 var value = getValue(object, key); 11975 return baseIsNative(value) ? value : undefined$1; 11976 } 11977 11978 /** 11979 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. 11980 * 11981 * @private 11982 * @param {*} value The value to query. 11983 * @returns {string} Returns the raw `toStringTag`. 11984 */ 11985 function getRawTag(value) { 11986 var isOwn = hasOwnProperty.call(value, symToStringTag), 11987 tag = value[symToStringTag]; 11988 11989 try { 11990 value[symToStringTag] = undefined$1; 11991 var unmasked = true; 11992 } catch (e) {} 11993 11994 var result = nativeObjectToString.call(value); 11995 if (unmasked) { 11996 if (isOwn) { 11997 value[symToStringTag] = tag; 11998 } else { 11999 delete value[symToStringTag]; 12000 } 12001 } 12002 return result; 12003 } 12004 12005 /** 12006 * Creates an array of the own enumerable symbols of `object`. 12007 * 12008 * @private 12009 * @param {Object} object The object to query. 12010 * @returns {Array} Returns the array of symbols. 12011 */ 12012 var getSymbols = !nativeGetSymbols ? stubArray : function(object) { 12013 if (object == null) { 12014 return []; 12015 } 12016 object = Object(object); 12017 return arrayFilter(nativeGetSymbols(object), function(symbol) { 12018 return propertyIsEnumerable.call(object, symbol); 12019 }); 12020 }; 12021 12022 /** 12023 * Creates an array of the own and inherited enumerable symbols of `object`. 12024 * 12025 * @private 12026 * @param {Object} object The object to query. 12027 * @returns {Array} Returns the array of symbols. 12028 */ 12029 var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { 12030 var result = []; 12031 while (object) { 12032 arrayPush(result, getSymbols(object)); 12033 object = getPrototype(object); 12034 } 12035 return result; 12036 }; 12037 12038 /** 12039 * Gets the `toStringTag` of `value`. 12040 * 12041 * @private 12042 * @param {*} value The value to query. 12043 * @returns {string} Returns the `toStringTag`. 12044 */ 12045 var getTag = baseGetTag; 12046 12047 // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. 12048 if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || 12049 (Map && getTag(new Map) != mapTag) || 12050 (Promise && getTag(Promise.resolve()) != promiseTag) || 12051 (Set && getTag(new Set) != setTag) || 12052 (WeakMap && getTag(new WeakMap) != weakMapTag)) { 12053 getTag = function(value) { 12054 var result = baseGetTag(value), 12055 Ctor = result == objectTag ? value.constructor : undefined$1, 12056 ctorString = Ctor ? toSource(Ctor) : ''; 12057 12058 if (ctorString) { 12059 switch (ctorString) { 12060 case dataViewCtorString: return dataViewTag; 12061 case mapCtorString: return mapTag; 12062 case promiseCtorString: return promiseTag; 12063 case setCtorString: return setTag; 12064 case weakMapCtorString: return weakMapTag; 12065 } 12066 } 12067 return result; 12068 }; 12069 } 12070 12071 /** 12072 * Gets the view, applying any `transforms` to the `start` and `end` positions. 12073 * 12074 * @private 12075 * @param {number} start The start of the view. 12076 * @param {number} end The end of the view. 12077 * @param {Array} transforms The transformations to apply to the view. 12078 * @returns {Object} Returns an object containing the `start` and `end` 12079 * positions of the view. 12080 */ 12081 function getView(start, end, transforms) { 12082 var index = -1, 12083 length = transforms.length; 12084 12085 while (++index < length) { 12086 var data = transforms[index], 12087 size = data.size; 12088 12089 switch (data.type) { 12090 case 'drop': start += size; break; 12091 case 'dropRight': end -= size; break; 12092 case 'take': end = nativeMin(end, start + size); break; 12093 case 'takeRight': start = nativeMax(start, end - size); break; 12094 } 12095 } 12096 return { 'start': start, 'end': end }; 12097 } 12098 12099 /** 12100 * Extracts wrapper details from the `source` body comment. 12101 * 12102 * @private 12103 * @param {string} source The source to inspect. 12104 * @returns {Array} Returns the wrapper details. 12105 */ 12106 function getWrapDetails(source) { 12107 var match = source.match(reWrapDetails); 12108 return match ? match[1].split(reSplitDetails) : []; 12109 } 12110 12111 /** 12112 * Checks if `path` exists on `object`. 12113 * 12114 * @private 12115 * @param {Object} object The object to query. 12116 * @param {Array|string} path The path to check. 12117 * @param {Function} hasFunc The function to check properties. 12118 * @returns {boolean} Returns `true` if `path` exists, else `false`. 12119 */ 12120 function hasPath(object, path, hasFunc) { 12121 path = castPath(path, object); 12122 12123 var index = -1, 12124 length = path.length, 12125 result = false; 12126 12127 while (++index < length) { 12128 var key = toKey(path[index]); 12129 if (!(result = object != null && hasFunc(object, key))) { 12130 break; 12131 } 12132 object = object[key]; 12133 } 12134 if (result || ++index != length) { 12135 return result; 12136 } 12137 length = object == null ? 0 : object.length; 12138 return !!length && isLength(length) && isIndex(key, length) && 12139 (isArray(object) || isArguments(object)); 12140 } 12141 12142 /** 12143 * Initializes an array clone. 12144 * 12145 * @private 12146 * @param {Array} array The array to clone. 12147 * @returns {Array} Returns the initialized clone. 12148 */ 12149 function initCloneArray(array) { 12150 var length = array.length, 12151 result = new array.constructor(length); 12152 12153 // Add properties assigned by `RegExp#exec`. 12154 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { 12155 result.index = array.index; 12156 result.input = array.input; 12157 } 12158 return result; 12159 } 12160 12161 /** 12162 * Initializes an object clone. 12163 * 12164 * @private 12165 * @param {Object} object The object to clone. 12166 * @returns {Object} Returns the initialized clone. 12167 */ 12168 function initCloneObject(object) { 12169 return (typeof object.constructor == 'function' && !isPrototype(object)) 12170 ? baseCreate(getPrototype(object)) 12171 : {}; 12172 } 12173 12174 /** 12175 * Initializes an object clone based on its `toStringTag`. 12176 * 12177 * **Note:** This function only supports cloning values with tags of 12178 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. 12179 * 12180 * @private 12181 * @param {Object} object The object to clone. 12182 * @param {string} tag The `toStringTag` of the object to clone. 12183 * @param {boolean} [isDeep] Specify a deep clone. 12184 * @returns {Object} Returns the initialized clone. 12185 */ 12186 function initCloneByTag(object, tag, isDeep) { 12187 var Ctor = object.constructor; 12188 switch (tag) { 12189 case arrayBufferTag: 12190 return cloneArrayBuffer(object); 12191 12192 case boolTag: 12193 case dateTag: 12194 return new Ctor(+object); 12195 12196 case dataViewTag: 12197 return cloneDataView(object, isDeep); 12198 12199 case float32Tag: case float64Tag: 12200 case int8Tag: case int16Tag: case int32Tag: 12201 case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: 12202 return cloneTypedArray(object, isDeep); 12203 12204 case mapTag: 12205 return new Ctor; 12206 12207 case numberTag: 12208 case stringTag: 12209 return new Ctor(object); 12210 12211 case regexpTag: 12212 return cloneRegExp(object); 12213 12214 case setTag: 12215 return new Ctor; 12216 12217 case symbolTag: 12218 return cloneSymbol(object); 12219 } 12220 } 12221 12222 /** 12223 * Inserts wrapper `details` in a comment at the top of the `source` body. 12224 * 12225 * @private 12226 * @param {string} source The source to modify. 12227 * @returns {Array} details The details to insert. 12228 * @returns {string} Returns the modified source. 12229 */ 12230 function insertWrapDetails(source, details) { 12231 var length = details.length; 12232 if (!length) { 12233 return source; 12234 } 12235 var lastIndex = length - 1; 12236 details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; 12237 details = details.join(length > 2 ? ', ' : ' '); 12238 return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n'); 12239 } 12240 12241 /** 12242 * Checks if `value` is a flattenable `arguments` object or array. 12243 * 12244 * @private 12245 * @param {*} value The value to check. 12246 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. 12247 */ 12248 function isFlattenable(value) { 12249 return isArray(value) || isArguments(value) || 12250 !!(spreadableSymbol && value && value[spreadableSymbol]); 12251 } 12252 12253 /** 12254 * Checks if `value` is a valid array-like index. 12255 * 12256 * @private 12257 * @param {*} value The value to check. 12258 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. 12259 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. 12260 */ 12261 function isIndex(value, length) { 12262 var type = typeof value; 12263 length = length == null ? MAX_SAFE_INTEGER : length; 12264 12265 return !!length && 12266 (type == 'number' || 12267 (type != 'symbol' && reIsUint.test(value))) && 12268 (value > -1 && value % 1 == 0 && value < length); 12269 } 12270 12271 /** 12272 * Checks if the given arguments are from an iteratee call. 12273 * 12274 * @private 12275 * @param {*} value The potential iteratee value argument. 12276 * @param {*} index The potential iteratee index or key argument. 12277 * @param {*} object The potential iteratee object argument. 12278 * @returns {boolean} Returns `true` if the arguments are from an iteratee call, 12279 * else `false`. 12280 */ 12281 function isIterateeCall(value, index, object) { 12282 if (!isObject(object)) { 12283 return false; 12284 } 12285 var type = typeof index; 12286 if (type == 'number' 12287 ? (isArrayLike(object) && isIndex(index, object.length)) 12288 : (type == 'string' && index in object) 12289 ) { 12290 return eq(object[index], value); 12291 } 12292 return false; 12293 } 12294 12295 /** 12296 * Checks if `value` is a property name and not a property path. 12297 * 12298 * @private 12299 * @param {*} value The value to check. 12300 * @param {Object} [object] The object to query keys on. 12301 * @returns {boolean} Returns `true` if `value` is a property name, else `false`. 12302 */ 12303 function isKey(value, object) { 12304 if (isArray(value)) { 12305 return false; 12306 } 12307 var type = typeof value; 12308 if (type == 'number' || type == 'symbol' || type == 'boolean' || 12309 value == null || isSymbol(value)) { 12310 return true; 12311 } 12312 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || 12313 (object != null && value in Object(object)); 12314 } 12315 12316 /** 12317 * Checks if `value` is suitable for use as unique object key. 12318 * 12319 * @private 12320 * @param {*} value The value to check. 12321 * @returns {boolean} Returns `true` if `value` is suitable, else `false`. 12322 */ 12323 function isKeyable(value) { 12324 var type = typeof value; 12325 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') 12326 ? (value !== '__proto__') 12327 : (value === null); 12328 } 12329 12330 /** 12331 * Checks if `func` has a lazy counterpart. 12332 * 12333 * @private 12334 * @param {Function} func The function to check. 12335 * @returns {boolean} Returns `true` if `func` has a lazy counterpart, 12336 * else `false`. 12337 */ 12338 function isLaziable(func) { 12339 var funcName = getFuncName(func), 12340 other = lodash[funcName]; 12341 12342 if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { 12343 return false; 12344 } 12345 if (func === other) { 12346 return true; 12347 } 12348 var data = getData(other); 12349 return !!data && func === data[0]; 12350 } 12351 12352 /** 12353 * Checks if `func` has its source masked. 12354 * 12355 * @private 12356 * @param {Function} func The function to check. 12357 * @returns {boolean} Returns `true` if `func` is masked, else `false`. 12358 */ 12359 function isMasked(func) { 12360 return !!maskSrcKey && (maskSrcKey in func); 12361 } 12362 12363 /** 12364 * Checks if `func` is capable of being masked. 12365 * 12366 * @private 12367 * @param {*} value The value to check. 12368 * @returns {boolean} Returns `true` if `func` is maskable, else `false`. 12369 */ 12370 var isMaskable = coreJsData ? isFunction : stubFalse; 12371 12372 /** 12373 * Checks if `value` is likely a prototype object. 12374 * 12375 * @private 12376 * @param {*} value The value to check. 12377 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. 12378 */ 12379 function isPrototype(value) { 12380 var Ctor = value && value.constructor, 12381 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; 12382 12383 return value === proto; 12384 } 12385 12386 /** 12387 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. 12388 * 12389 * @private 12390 * @param {*} value The value to check. 12391 * @returns {boolean} Returns `true` if `value` if suitable for strict 12392 * equality comparisons, else `false`. 12393 */ 12394 function isStrictComparable(value) { 12395 return value === value && !isObject(value); 12396 } 12397 12398 /** 12399 * A specialized version of `matchesProperty` for source values suitable 12400 * for strict equality comparisons, i.e. `===`. 12401 * 12402 * @private 12403 * @param {string} key The key of the property to get. 12404 * @param {*} srcValue The value to match. 12405 * @returns {Function} Returns the new spec function. 12406 */ 12407 function matchesStrictComparable(key, srcValue) { 12408 return function(object) { 12409 if (object == null) { 12410 return false; 12411 } 12412 return object[key] === srcValue && 12413 (srcValue !== undefined$1 || (key in Object(object))); 12414 }; 12415 } 12416 12417 /** 12418 * A specialized version of `_.memoize` which clears the memoized function's 12419 * cache when it exceeds `MAX_MEMOIZE_SIZE`. 12420 * 12421 * @private 12422 * @param {Function} func The function to have its output memoized. 12423 * @returns {Function} Returns the new memoized function. 12424 */ 12425 function memoizeCapped(func) { 12426 var result = memoize(func, function(key) { 12427 if (cache.size === MAX_MEMOIZE_SIZE) { 12428 cache.clear(); 12429 } 12430 return key; 12431 }); 12432 12433 var cache = result.cache; 12434 return result; 12435 } 12436 12437 /** 12438 * Merges the function metadata of `source` into `data`. 12439 * 12440 * Merging metadata reduces the number of wrappers used to invoke a function. 12441 * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` 12442 * may be applied regardless of execution order. Methods like `_.ary` and 12443 * `_.rearg` modify function arguments, making the order in which they are 12444 * executed important, preventing the merging of metadata. However, we make 12445 * an exception for a safe combined case where curried functions have `_.ary` 12446 * and or `_.rearg` applied. 12447 * 12448 * @private 12449 * @param {Array} data The destination metadata. 12450 * @param {Array} source The source metadata. 12451 * @returns {Array} Returns `data`. 12452 */ 12453 function mergeData(data, source) { 12454 var bitmask = data[1], 12455 srcBitmask = source[1], 12456 newBitmask = bitmask | srcBitmask, 12457 isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG); 12458 12459 var isCombo = 12460 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) || 12461 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) || 12462 ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG)); 12463 12464 // Exit early if metadata can't be merged. 12465 if (!(isCommon || isCombo)) { 12466 return data; 12467 } 12468 // Use source `thisArg` if available. 12469 if (srcBitmask & WRAP_BIND_FLAG) { 12470 data[2] = source[2]; 12471 // Set when currying a bound function. 12472 newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG; 12473 } 12474 // Compose partial arguments. 12475 var value = source[3]; 12476 if (value) { 12477 var partials = data[3]; 12478 data[3] = partials ? composeArgs(partials, value, source[4]) : value; 12479 data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4]; 12480 } 12481 // Compose partial right arguments. 12482 value = source[5]; 12483 if (value) { 12484 partials = data[5]; 12485 data[5] = partials ? composeArgsRight(partials, value, source[6]) : value; 12486 data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6]; 12487 } 12488 // Use source `argPos` if available. 12489 value = source[7]; 12490 if (value) { 12491 data[7] = value; 12492 } 12493 // Use source `ary` if it's smaller. 12494 if (srcBitmask & WRAP_ARY_FLAG) { 12495 data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); 12496 } 12497 // Use source `arity` if one is not provided. 12498 if (data[9] == null) { 12499 data[9] = source[9]; 12500 } 12501 // Use source `func` and merge bitmasks. 12502 data[0] = source[0]; 12503 data[1] = newBitmask; 12504 12505 return data; 12506 } 12507 12508 /** 12509 * This function is like 12510 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 12511 * except that it includes inherited enumerable properties. 12512 * 12513 * @private 12514 * @param {Object} object The object to query. 12515 * @returns {Array} Returns the array of property names. 12516 */ 12517 function nativeKeysIn(object) { 12518 var result = []; 12519 if (object != null) { 12520 for (var key in Object(object)) { 12521 result.push(key); 12522 } 12523 } 12524 return result; 12525 } 12526 12527 /** 12528 * Converts `value` to a string using `Object.prototype.toString`. 12529 * 12530 * @private 12531 * @param {*} value The value to convert. 12532 * @returns {string} Returns the converted string. 12533 */ 12534 function objectToString(value) { 12535 return nativeObjectToString.call(value); 12536 } 12537 12538 /** 12539 * A specialized version of `baseRest` which transforms the rest array. 12540 * 12541 * @private 12542 * @param {Function} func The function to apply a rest parameter to. 12543 * @param {number} [start=func.length-1] The start position of the rest parameter. 12544 * @param {Function} transform The rest array transform. 12545 * @returns {Function} Returns the new function. 12546 */ 12547 function overRest(func, start, transform) { 12548 start = nativeMax(start === undefined$1 ? (func.length - 1) : start, 0); 12549 return function() { 12550 var args = arguments, 12551 index = -1, 12552 length = nativeMax(args.length - start, 0), 12553 array = Array(length); 12554 12555 while (++index < length) { 12556 array[index] = args[start + index]; 12557 } 12558 index = -1; 12559 var otherArgs = Array(start + 1); 12560 while (++index < start) { 12561 otherArgs[index] = args[index]; 12562 } 12563 otherArgs[start] = transform(array); 12564 return apply(func, this, otherArgs); 12565 }; 12566 } 12567 12568 /** 12569 * Gets the parent value at `path` of `object`. 12570 * 12571 * @private 12572 * @param {Object} object The object to query. 12573 * @param {Array} path The path to get the parent value of. 12574 * @returns {*} Returns the parent value. 12575 */ 12576 function parent(object, path) { 12577 return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); 12578 } 12579 12580 /** 12581 * Reorder `array` according to the specified indexes where the element at 12582 * the first index is assigned as the first element, the element at 12583 * the second index is assigned as the second element, and so on. 12584 * 12585 * @private 12586 * @param {Array} array The array to reorder. 12587 * @param {Array} indexes The arranged array indexes. 12588 * @returns {Array} Returns `array`. 12589 */ 12590 function reorder(array, indexes) { 12591 var arrLength = array.length, 12592 length = nativeMin(indexes.length, arrLength), 12593 oldArray = copyArray(array); 12594 12595 while (length--) { 12596 var index = indexes[length]; 12597 array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined$1; 12598 } 12599 return array; 12600 } 12601 12602 /** 12603 * Gets the value at `key`, unless `key` is "__proto__" or "constructor". 12604 * 12605 * @private 12606 * @param {Object} object The object to query. 12607 * @param {string} key The key of the property to get. 12608 * @returns {*} Returns the property value. 12609 */ 12610 function safeGet(object, key) { 12611 if (key === 'constructor' && typeof object[key] === 'function') { 12612 return; 12613 } 12614 12615 if (key == '__proto__') { 12616 return; 12617 } 12618 12619 return object[key]; 12620 } 12621 12622 /** 12623 * Sets metadata for `func`. 12624 * 12625 * **Note:** If this function becomes hot, i.e. is invoked a lot in a short 12626 * period of time, it will trip its breaker and transition to an identity 12627 * function to avoid garbage collection pauses in V8. See 12628 * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) 12629 * for more details. 12630 * 12631 * @private 12632 * @param {Function} func The function to associate metadata with. 12633 * @param {*} data The metadata. 12634 * @returns {Function} Returns `func`. 12635 */ 12636 var setData = shortOut(baseSetData); 12637 12638 /** 12639 * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout). 12640 * 12641 * @private 12642 * @param {Function} func The function to delay. 12643 * @param {number} wait The number of milliseconds to delay invocation. 12644 * @returns {number|Object} Returns the timer id or timeout object. 12645 */ 12646 var setTimeout = ctxSetTimeout || function(func, wait) { 12647 return root.setTimeout(func, wait); 12648 }; 12649 12650 /** 12651 * Sets the `toString` method of `func` to return `string`. 12652 * 12653 * @private 12654 * @param {Function} func The function to modify. 12655 * @param {Function} string The `toString` result. 12656 * @returns {Function} Returns `func`. 12657 */ 12658 var setToString = shortOut(baseSetToString); 12659 12660 /** 12661 * Sets the `toString` method of `wrapper` to mimic the source of `reference` 12662 * with wrapper details in a comment at the top of the source body. 12663 * 12664 * @private 12665 * @param {Function} wrapper The function to modify. 12666 * @param {Function} reference The reference function. 12667 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 12668 * @returns {Function} Returns `wrapper`. 12669 */ 12670 function setWrapToString(wrapper, reference, bitmask) { 12671 var source = (reference + ''); 12672 return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); 12673 } 12674 12675 /** 12676 * Creates a function that'll short out and invoke `identity` instead 12677 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` 12678 * milliseconds. 12679 * 12680 * @private 12681 * @param {Function} func The function to restrict. 12682 * @returns {Function} Returns the new shortable function. 12683 */ 12684 function shortOut(func) { 12685 var count = 0, 12686 lastCalled = 0; 12687 12688 return function() { 12689 var stamp = nativeNow(), 12690 remaining = HOT_SPAN - (stamp - lastCalled); 12691 12692 lastCalled = stamp; 12693 if (remaining > 0) { 12694 if (++count >= HOT_COUNT) { 12695 return arguments[0]; 12696 } 12697 } else { 12698 count = 0; 12699 } 12700 return func.apply(undefined$1, arguments); 12701 }; 12702 } 12703 12704 /** 12705 * A specialized version of `_.shuffle` which mutates and sets the size of `array`. 12706 * 12707 * @private 12708 * @param {Array} array The array to shuffle. 12709 * @param {number} [size=array.length] The size of `array`. 12710 * @returns {Array} Returns `array`. 12711 */ 12712 function shuffleSelf(array, size) { 12713 var index = -1, 12714 length = array.length, 12715 lastIndex = length - 1; 12716 12717 size = size === undefined$1 ? length : size; 12718 while (++index < size) { 12719 var rand = baseRandom(index, lastIndex), 12720 value = array[rand]; 12721 12722 array[rand] = array[index]; 12723 array[index] = value; 12724 } 12725 array.length = size; 12726 return array; 12727 } 12728 12729 /** 12730 * Converts `string` to a property path array. 12731 * 12732 * @private 12733 * @param {string} string The string to convert. 12734 * @returns {Array} Returns the property path array. 12735 */ 12736 var stringToPath = memoizeCapped(function(string) { 12737 var result = []; 12738 if (string.charCodeAt(0) === 46 /* . */) { 12739 result.push(''); 12740 } 12741 string.replace(rePropName, function(match, number, quote, subString) { 12742 result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); 12743 }); 12744 return result; 12745 }); 12746 12747 /** 12748 * Converts `value` to a string key if it's not a string or symbol. 12749 * 12750 * @private 12751 * @param {*} value The value to inspect. 12752 * @returns {string|symbol} Returns the key. 12753 */ 12754 function toKey(value) { 12755 if (typeof value == 'string' || isSymbol(value)) { 12756 return value; 12757 } 12758 var result = (value + ''); 12759 return (result == '0' && (1 / value) == -I
12759NFINITY) ? '-0' : result; 12760 } 12761 12762 /** 12763 * Converts `func` to its source code. 12764 * 12765 * @private 12766 * @param {Function} func The function to convert. 12767 * @returns {string} Returns the source code. 12768 */ 12769 function toSource(func) { 12770 if (func != null) { 12771 try { 12772 return funcToString.call(func); 12773 } catch (e) {} 12774 try { 12775 return (func + ''); 12776 } catch (e) {} 12777 } 12778 return ''; 12779 } 12780 12781 /** 12782 * Updates wrapper `details` based on `bitmask` flags. 12783 * 12784 * @private 12785 * @returns {Array} details The details to modify. 12786 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 12787 * @returns {Array} Returns `details`. 12788 */ 12789 function updateWrapDetails(details, bitmask) { 12790 arrayEach(wrapFlags, function(pair) { 12791 var value = '_.' + pair[0];
vendor: 2,339 bytes, lines 12792-12862
12792 if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { 12793 details.push(value); 12794 } 12795 }); 12796 return details.sort(); 12797 } 12798 12799 /** 12800 * Creates a clone of `wrapper`. 12801 * 12802 * @private 12803 * @param {Object} wrapper The wrapper to clone. 12804 * @returns {Object} Returns the cloned wrapper. 12805 */ 12806 function wrapperClone(wrapper) { 12807 if (wrapper instanceof LazyWrapper) { 12808 return wrapper.clone(); 12809 } 12810 var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); 12811 result.__actions__ = copyArray(wrapper.__actions__); 12812 result.__index__ = wrapper.__index__; 12813 result.__values__ = wrapper.__values__; 12814 return result; 12815 } 12816 12817 /*------------------------------------------------------------------------*/ 12818 12819 /** 12820 * Creates an array of elements split into groups the length of `size`. 12821 * If `array` can't be split evenly, the final chunk will be the remaining 12822 * elements. 12823 * 12824 * @static 12825 * @memberOf _ 12826 * @since 3.0.0 12827 * @category Array 12828 * @param {Array} array The array to process. 12829 * @param {number} [size=1] The length of each chunk 12830 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 12831 * @returns {Array} Returns the new array of chunks. 12832 * @example 12833 * 12834 * _.chunk(['a', 'b', 'c', 'd'], 2); 12835 * // => [['a', 'b'], ['c', 'd']] 12836 * 12837 * _.chunk(['a', 'b', 'c', 'd'], 3); 12838 * // => [['a', 'b', 'c'], ['d']] 12839 */ 12840 function chunk(array, size, guard) { 12841 if ((guard ? isIterateeCall(array, size, guard) : size === undefined$1)) { 12842 size = 1; 12843 } else { 12844 size = nativeMax(toInteger(size), 0); 12845 } 12846 var length = array == null ? 0 : array.length; 12847 if (!length || size < 1) { 12848 return []; 12849 } 12850 var index = 0, 12851 resIndex = 0, 12852 result = Array(nativeCeil(length / size)); 12853 12854 while (index < length) { 12855 result[resIndex++] = baseSlice(array, index, (index += size)); 12856 } 12857 return result; 12858 } 12859 12860 /** 12861 * Creates an array with all falsey values removed. The values `false`, `null`, 12862 * `0`, `""`, `undefined`, and `NaN` are false
vendor: 17,660 bytes, lines 12862-13401
12862y. 12863 * 12864 * @static 12865 * @memberOf _ 12866 * @since 0.1.0 12867 * @category Array 12868 * @param {Array} array The array to compact. 12869 * @returns {Array} Returns the new array of filtered values. 12870 * @example 12871 * 12872 * _.compact([0, 1, false, 2, '', 3]); 12873 * // => [1, 2, 3] 12874 */ 12875 function compact(array) { 12876 var index = -1, 12877 length = array == null ? 0 : array.length, 12878 resIndex = 0, 12879 result = []; 12880 12881 while (++index < length) { 12882 var value = array[index]; 12883 if (value) { 12884 result[resIndex++] = value; 12885 } 12886 } 12887 return result; 12888 } 12889 12890 /** 12891 * Creates a new array concatenating `array` with any additional arrays 12892 * and/or values. 12893 * 12894 * @static 12895 * @memberOf _ 12896 * @since 4.0.0 12897 * @category Array 12898 * @param {Array} array The array to concatenate. 12899 * @param {...*} [values] The values to concatenate. 12900 * @returns {Array} Returns the new concatenated array. 12901 * @example 12902 * 12903 * var array = [1]; 12904 * var other = _.concat(array, 2, [3], [[4]]); 12905 * 12906 * console.log(other); 12907 * // => [1, 2, 3, [4]] 12908 * 12909 * console.log(array); 12910 * // => [1] 12911 */ 12912 function concat() { 12913 var length = arguments.length; 12914 if (!length) { 12915 return []; 12916 } 12917 var args = Array(length - 1), 12918 array = arguments[0], 12919 index = length; 12920 12921 while (index--) { 12922 args[index - 1] = arguments[index]; 12923 } 12924 return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1)); 12925 } 12926 12927 /** 12928 * Creates an array of `array` values not included in the other given arrays 12929 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 12930 * for equality comparisons. The order and references of result values are 12931 * determined by the first array. 12932 * 12933 * **Note:** Unlike `_.pullAll`, this method returns a new array. 12934 * 12935 * @static 12936 * @memberOf _ 12937 * @since 0.1.0 12938 * @category Array 12939 * @param {Array} array The array to inspect. 12940 * @param {...Array} [values] The values to exclude. 12941 * @returns {Array} Returns the new array of filtered values. 12942 * @see _.without, _.xor 12943 * @example 12944 * 12945 * _.difference([2, 1], [2, 3]); 12946 * // => [1] 12947 */ 12948 var difference = baseRest(function(array, values) { 12949 return isArrayLikeObject(array) 12950 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) 12951 : []; 12952 }); 12953 12954 /** 12955 * This method is like `_.difference` except that it accepts `iteratee` which 12956 * is invoked for each element of `array` and `values` to generate the criterion 12957 * by which they're compared. The order and references of result values are 12958 * determined by the first array. The iteratee is invoked with one argument: 12959 * (value). 12960 * 12961 * **Note:** Unlike `_.pullAllBy`, this method returns a new array. 12962 * 12963 * @static 12964 * @memberOf _ 12965 * @since 4.0.0 12966 * @category Array 12967 * @param {Array} array The array to inspect. 12968 * @param {...Array} [values] The values to exclude. 12969 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 12970 * @returns {Array} Returns the new array of filtered values. 12971 * @example 12972 * 12973 * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); 12974 * // => [1.2] 12975 * 12976 * // The `_.property` iteratee shorthand. 12977 * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); 12978 * // => [{ 'x': 2 }] 12979 */ 12980 var differenceBy = baseRest(function(array, values) { 12981 var iteratee = last(values); 12982 if (isArrayLikeObject(iteratee)) { 12983 iteratee = undefined$1; 12984 } 12985 return isArrayLikeObject(array) 12986 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)) 12987 : []; 12988 }); 12989 12990 /** 12991 * This method is like `_.difference` except that it accepts `comparator` 12992 * which is invoked to compare elements of `array` to `values`. The order and 12993 * references of result values are determined by the first array. The comparator 12994 * is invoked with two arguments: (arrVal, othVal). 12995 * 12996 * **Note:** Unlike `_.pullAllWith`, this method returns a new array. 12997 * 12998 * @static 12999 * @memberOf _ 13000 * @since 4.0.0 13001 * @category Array 13002 * @param {Array} array The array to inspect. 13003 * @param {...Array} [values] The values to exclude. 13004 * @param {Function} [comparator] The comparator invoked per element. 13005 * @returns {Array} Returns the new array of filtered values. 13006 * @example 13007 * 13008 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 13009 * 13010 * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); 13011 * // => [{ 'x': 2, 'y': 1 }] 13012 */ 13013 var differenceWith = baseRest(function(array, values) { 13014 var comparator = last(values); 13015 if (isArrayLikeObject(comparator)) { 13016 comparator = undefined$1; 13017 } 13018 return isArrayLikeObject(array) 13019 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined$1, comparator) 13020 : []; 13021 }); 13022 13023 /** 13024 * Creates a slice of `array` with `n` elements dropped from the beginning. 13025 * 13026 * @static 13027 * @memberOf _ 13028 * @since 0.5.0 13029 * @category Array 13030 * @param {Array} array The array to query. 13031 * @param {number} [n=1] The number of elements to drop. 13032 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 13033 * @returns {Array} Returns the slice of `array`. 13034 * @example 13035 * 13036 * _.drop([1, 2, 3]); 13037 * // => [2, 3] 13038 * 13039 * _.drop([1, 2, 3], 2); 13040 * // => [3] 13041 * 13042 * _.drop([1, 2, 3], 5); 13043 * // => [] 13044 * 13045 * _.drop([1, 2, 3], 0); 13046 * // => [1, 2, 3] 13047 */ 13048 function drop(array, n, guard) { 13049 var length = array == null ? 0 : array.length; 13050 if (!length) { 13051 return []; 13052 } 13053 n = (guard || n === undefined$1) ? 1 : toInteger(n); 13054 return baseSlice(array, n < 0 ? 0 : n, length); 13055 } 13056 13057 /** 13058 * Creates a slice of `array` with `n` elements dropped from the end. 13059 * 13060 * @static 13061 * @memberOf _ 13062 * @since 3.0.0 13063 * @category Array 13064 * @param {Array} array The array to query. 13065 * @param {number} [n=1] The number of elements to drop. 13066 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 13067 * @returns {Array} Returns the slice of `array`. 13068 * @example 13069 * 13070 * _.dropRight([1, 2, 3]); 13071 * // => [1, 2] 13072 * 13073 * _.dropRight([1, 2, 3], 2); 13074 * // => [1] 13075 * 13076 * _.dropRight([1, 2, 3], 5); 13077 * // => [] 13078 * 13079 * _.dropRight([1, 2, 3], 0); 13080 * // => [1, 2, 3] 13081 */ 13082 function dropRight(array, n, guard) { 13083 var length = array == null ? 0 : array.length; 13084 if (!length) { 13085 return []; 13086 } 13087 n = (guard || n === undefined$1) ? 1 : toInteger(n); 13088 n = length - n; 13089 return baseSlice(array, 0, n < 0 ? 0 : n); 13090 } 13091 13092 /** 13093 * Creates a slice of `array` excluding elements dropped from the end. 13094 * Elements are dropped until `predicate` returns falsey. The predicate is 13095 * invoked with three arguments: (value, index, array). 13096 * 13097 * @static 13098 * @memberOf _ 13099 * @since 3.0.0 13100 * @category Array 13101 * @param {Array} array The array to query. 13102 * @param {Function} [predicate=_.identity] The function invoked per iteration. 13103 * @returns {Array} Returns the slice of `array`. 13104 * @example 13105 * 13106 * var users = [ 13107 * { 'user': 'barney', 'active': true }, 13108 * { 'user': 'fred', 'active': false }, 13109 * { 'user': 'pebbles', 'active': false } 13110 * ]; 13111 * 13112 * _.dropRightWhile(users, function(o) { return !o.active; }); 13113 * // => objects for ['barney'] 13114 * 13115 * // The `_.matches` iteratee shorthand. 13116 * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); 13117 * // => objects for ['barney', 'fred'] 13118 * 13119 * // The `_.matchesProperty` iteratee shorthand. 13120 * _.dropRightWhile(users, ['active', false]); 13121 * // => objects for ['barney'] 13122 * 13123 * // The `_.property` iteratee shorthand. 13124 * _.dropRightWhile(users, 'active'); 13125 * // => objects for ['barney', 'fred', 'pebbles'] 13126 */ 13127 function dropRightWhile(array, predicate) { 13128 return (array && array.length) 13129 ? baseWhile(array, getIteratee(predicate, 3), true, true) 13130 : []; 13131 } 13132 13133 /** 13134 * Creates a slice of `array` excluding elements dropped from the beginning. 13135 * Elements are dropped until `predicate` returns falsey. The predicate is 13136 * invoked with three arguments: (value, index, array). 13137 * 13138 * @static 13139 * @memberOf _ 13140 * @since 3.0.0 13141 * @category Array 13142 * @param {Array} array The array to query. 13143 * @param {Function} [predicate=_.identity] The function invoked per iteration. 13144 * @returns {Array} Returns the slice of `array`. 13145 * @example 13146 * 13147 * var users = [ 13148 * { 'user': 'barney', 'active': false }, 13149 * { 'user': 'fred', 'active': false }, 13150 * { 'user': 'pebbles', 'active': true } 13151 * ]; 13152 * 13153 * _.dropWhile(users, function(o) { return !o.active; }); 13154 * // => objects for ['pebbles'] 13155 * 13156 * // The `_.matches` iteratee shorthand. 13157 * _.dropWhile(users, { 'user': 'barney', 'active': false }); 13158 * // => objects for ['fred', 'pebbles'] 13159 * 13160 * // The `_.matchesProperty` iteratee shorthand. 13161 * _.dropWhile(users, ['active', false]); 13162 * // => objects for ['pebbles'] 13163 * 13164 * // The `_.property` iteratee shorthand. 13165 * _.dropWhile(users, 'active'); 13166 * // => objects for ['barney', 'fred', 'pebbles'] 13167 */ 13168 function dropWhile(array, predicate) { 13169 return (array && array.length) 13170 ? baseWhile(array, getIteratee(predicate, 3), true) 13171 : []; 13172 } 13173 13174 /** 13175 * Fills elements of `array` with `value` from `start` up to, but not 13176 * including, `end`. 13177 * 13178 * **Note:** This method mutates `array`. 13179 * 13180 * @static 13181 * @memberOf _ 13182 * @since 3.2.0 13183 * @category Array 13184 * @param {Array} array The array to fill. 13185 * @param {*} value The value to fill `array` with. 13186 * @param {number} [start=0] The start position. 13187 * @param {number} [end=array.length] The end position. 13188 * @returns {Array} Returns `array`. 13189 * @example 13190 * 13191 * var array = [1, 2, 3]; 13192 * 13193 * _.fill(array, 'a'); 13194 * console.log(array); 13195 * // => ['a', 'a', 'a'] 13196 * 13197 * _.fill(Array(3), 2); 13198 * // => [2, 2, 2] 13199 * 13200 * _.fill([4, 6, 8, 10], '*', 1, 3); 13201 * // => [4, '*', '*', 10] 13202 */ 13203 function fill(array, value, start, end) { 13204 var length = array == null ? 0 : array.length; 13205 if (!length) { 13206 return []; 13207 } 13208 if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { 13209 start = 0; 13210 end = length; 13211 } 13212 return baseFill(array, value, start, end); 13213 } 13214 13215 /** 13216 * This method is like `_.find` except that it returns the index of the first 13217 * element `predicate` returns truthy for instead of the element itself. 13218 * 13219 * @static 13220 * @memberOf _ 13221 * @since 1.1.0 13222 * @category Array 13223 * @param {Array} array The array to inspect. 13224 * @param {Function} [predicate=_.identity] The function invoked per iteration. 13225 * @param {number} [fromIndex=0] The index to search from. 13226 * @returns {number} Returns the index of the found element, else `-1`. 13227 * @example 13228 * 13229 * var users = [ 13230 * { 'user': 'barney', 'active': false }, 13231 * { 'user': 'fred', 'active': false }, 13232 * { 'user': 'pebbles', 'active': true } 13233 * ]; 13234 * 13235 * _.findIndex(users, function(o) { return o.user == 'barney'; }); 13236 * // => 0 13237 * 13238 * // The `_.matches` iteratee shorthand. 13239 * _.findIndex(users, { 'user': 'fred', 'active': false }); 13240 * // => 1 13241 * 13242 * // The `_.matchesProperty` iteratee shorthand. 13243 * _.findIndex(users, ['active', false]); 13244 * // => 0 13245 * 13246 * // The `_.property` iteratee shorthand. 13247 * _.findIndex(users, 'active'); 13248 * // => 2 13249 */ 13250 function findIndex(array, predicate, fromIndex) { 13251 var length = array == null ? 0 : array.length; 13252 if (!length) { 13253 return -1; 13254 } 13255 var index = fromIndex == null ? 0 : toInteger(fromIndex); 13256 if (index < 0) { 13257 index = nativeMax(length + index, 0); 13258 } 13259 return baseFindIndex(array, getIteratee(predicate, 3), index); 13260 } 13261 13262 /** 13263 * This method is like `_.findIndex` except that it iterates over elements 13264 * of `collection` from right to left. 13265 * 13266 * @static 13267 * @memberOf _ 13268 * @since 2.0.0 13269 * @category Array 13270 * @param {Array} array The array to inspect. 13271 * @param {Function} [predicate=_.identity] The function invoked per iteration. 13272 * @param {number} [fromIndex=array.length-1] The index to search from. 13273 * @returns {number} Returns the index of the found element, else `-1`. 13274 * @example 13275 * 13276 * var users = [ 13277 * { 'user': 'barney', 'active': true }, 13278 * { 'user': 'fred', 'active': false }, 13279 * { 'user': 'pebbles', 'active': false } 13280 * ]; 13281 * 13282 * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); 13283 * // => 2 13284 * 13285 * // The `_.matches` iteratee shorthand. 13286 * _.findLastIndex(users, { 'user': 'barney', 'active': true }); 13287 * // => 0 13288 * 13289 * // The `_.matchesProperty` iteratee shorthand. 13290 * _.findLastIndex(users, ['active', false]); 13291 * // => 2 13292 * 13293 * // The `_.property` iteratee shorthand. 13294 * _.findLastIndex(users, 'active'); 13295 * // => 0 13296 */ 13297 function findLastIndex(array, predicate, fromIndex) { 13298 var length = array == null ? 0 : array.length; 13299 if (!length) { 13300 return -1; 13301 } 13302 var index = length - 1; 13303 if (fromIndex !== undefined$1) { 13304 index = toInteger(fromIndex); 13305 index = fromIndex < 0 13306 ? nativeMax(length + index, 0) 13307 : nativeMin(index, length - 1); 13308 } 13309 return baseFindIndex(array, getIteratee(predicate, 3), index, true); 13310 } 13311 13312 /** 13313 * Flattens `array` a single level deep. 13314 * 13315 * @static 13316 * @memberOf _ 13317 * @since 0.1.0 13318 * @category Array 13319 * @param {Array} array The array to flatten. 13320 * @returns {Array} Returns the new flattened array. 13321 * @example 13322 * 13323 * _.flatten([1, [2, [3, [4]], 5]]); 13324 * // => [1, 2, [3, [4]], 5] 13325 */ 13326 function flatten(array) { 13327 var length = array == null ? 0 : array.length; 13328 return length ? baseFlatten(array, 1) : []; 13329 } 13330 13331 /** 13332 * Recursively flattens `array`. 13333 * 13334 * @static 13335 * @memberOf _ 13336 * @since 3.0.0 13337 * @category Array 13338 * @param {Array} array The array to flatten. 13339 * @returns {Array} Returns the new flattened array. 13340 * @example 13341 * 13342 * _.flattenDeep([1, [2, [3, [4]], 5]]); 13343 * // => [1, 2, 3, 4, 5] 13344 */ 13345 function flattenDeep(array) { 13346 var length = array == null ? 0 : array.length; 13347 return length ? baseFlatten(array, INFINITY) : []; 13348 } 13349 13350 /** 13351 * Recursively flatten `array` up to `depth` times. 13352 * 13353 * @static 13354 * @memberOf _ 13355 * @since 4.4.0 13356 * @category Array 13357 * @param {Array} array The array to flatten. 13358 * @param {number} [depth=1] The maximum recursion depth. 13359 * @returns {Array} Returns the new flattened array. 13360 * @example 13361 * 13362 * var array = [1, [2, [3, [4]], 5]]; 13363 * 13364 * _.flattenDepth(array, 1); 13365 * // => [1, 2, [3, [4]], 5] 13366 * 13367 * _.flattenDepth(array, 2); 13368 * // => [1, 2, 3, [4], 5] 13369 */ 13370 function flattenDepth(array, depth) { 13371 var length = array == null ? 0 : array.length; 13372 if (!length) { 13373 return []; 13374 } 13375 depth = depth === undefined$1 ? 1 : toInteger(depth); 13376 return baseFlatten(array, depth); 13377 } 13378 13379 /** 13380 * The inverse of `_.toPairs`; this method returns an object composed 13381 * from key-value `pairs`. 13382 * 13383 * @static 13384 * @memberOf _ 13385 * @since 4.0.0 13386 * @category Array 13387 * @param {Array} pairs The key-value pairs. 13388 * @returns {Object} Returns the new object. 13389 * @example 13390 * 13391 * _.fromPairs([['a', 1], ['b', 2]]); 13392 * // => { 'a': 1, 'b': 2 } 13393 */ 13394 function fromPairs(pairs) { 13395 var index = -1, 13396 length = pairs == null ? 0 : pairs.length, 13397 result = {}; 13398 13399 while (++index < length) { 13400 var pair = pairs[index]; 13401
13401result[pair[0]] = pair[1]
vendor: 157,291 bytes, lines 13401-18101
13401; 13402 } 13403 return result; 13404 } 13405 13406 /** 13407 * Gets the first element of `array`. 13408 * 13409 * @static 13410 * @memberOf _ 13411 * @since 0.1.0 13412 * @alias first 13413 * @category Array 13414 * @param {Array} array The array to query. 13415 * @returns {*} Returns the first element of `array`. 13416 * @example 13417 * 13418 * _.head([1, 2, 3]); 13419 * // => 1 13420 * 13421 * _.head([]); 13422 * // => undefined 13423 */ 13424 function head(array) { 13425 return (array && array.length) ? array[0] : undefined$1; 13426 } 13427 13428 /** 13429 * Gets the index at which the first occurrence of `value` is found in `array` 13430 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 13431 * for equality comparisons. If `fromIndex` is negative, it's used as the 13432 * offset from the end of `array`. 13433 * 13434 * @static 13435 * @memberOf _ 13436 * @since 0.1.0 13437 * @category Array 13438 * @param {Array} array The array to inspect. 13439 * @param {*} value The value to search for. 13440 * @param {number} [fromIndex=0] The index to search from. 13441 * @returns {number} Returns the index of the matched value, else `-1`. 13442 * @example 13443 * 13444 * _.indexOf([1, 2, 1, 2], 2); 13445 * // => 1 13446 * 13447 * // Search from the `fromIndex`. 13448 * _.indexOf([1, 2, 1, 2], 2, 2); 13449 * // => 3 13450 */ 13451 function indexOf(array, value, fromIndex) { 13452 var length = array == null ? 0 : array.length; 13453 if (!length) { 13454 return -1; 13455 } 13456 var index = fromIndex == null ? 0 : toInteger(fromIndex); 13457 if (index < 0) { 13458 index = nativeMax(length + index, 0); 13459 } 13460 return baseIndexOf(array, value, index); 13461 } 13462 13463 /** 13464 * Gets all but the last element of `array`. 13465 * 13466 * @static 13467 * @memberOf _ 13468 * @since 0.1.0 13469 * @category Array 13470 * @param {Array} array The array to query. 13471 * @returns {Array} Returns the slice of `array`. 13472 * @example 13473 * 13474 * _.initial([1, 2, 3]); 13475 * // => [1, 2] 13476 */ 13477 function initial(array) { 13478 var length = array == null ? 0 : array.length; 13479 return length ? baseSlice(array, 0, -1) : []; 13480 } 13481 13482 /** 13483 * Creates an array of unique values that are included in all given arrays 13484 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 13485 * for equality comparisons. The order and references of result values are 13486 * determined by the first array. 13487 * 13488 * @static 13489 * @memberOf _ 13490 * @since 0.1.0 13491 * @category Array 13492 * @param {...Array} [arrays] The arrays to inspect. 13493 * @returns {Array} Returns the new array of intersecting values. 13494 * @example 13495 * 13496 * _.intersection([2, 1], [2, 3]); 13497 * // => [2] 13498 */ 13499 var intersection = baseRest(function(arrays) { 13500 var mapped = arrayMap(arrays, castArrayLikeObject); 13501 return (mapped.length && mapped[0] === arrays[0]) 13502 ? baseIntersection(mapped) 13503 : []; 13504 }); 13505 13506 /** 13507 * This method is like `_.intersection` except that it accepts `iteratee` 13508 * which is invoked for each element of each `arrays` to generate the criterion 13509 * by which they're compared. The order and references of result values are 13510 * determined by the first array. The iteratee is invoked with one argument: 13511 * (value). 13512 * 13513 * @static 13514 * @memberOf _ 13515 * @since 4.0.0 13516 * @category Array 13517 * @param {...Array} [arrays] The arrays to inspect. 13518 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 13519 * @returns {Array} Returns the new array of intersecting values. 13520 * @example 13521 * 13522 * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); 13523 * // => [2.1] 13524 * 13525 * // The `_.property` iteratee shorthand. 13526 * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 13527 * // => [{ 'x': 1 }] 13528 */ 13529 var intersectionBy = baseRest(function(arrays) { 13530 var iteratee = last(arrays), 13531 mapped = arrayMap(arrays, castArrayLikeObject); 13532 13533 if (iteratee === last(mapped)) { 13534 iteratee = undefined$1; 13535 } else { 13536 mapped.pop(); 13537 } 13538 return (mapped.length && mapped[0] === arrays[0]) 13539 ? baseIntersection(mapped, getIteratee(iteratee, 2)) 13540 : []; 13541 }); 13542 13543 /** 13544 * This method is like `_.intersection` except that it accepts `comparator` 13545 * which is invoked to compare elements of `arrays`. The order and references 13546 * of result values are determined by the first array. The comparator is 13547 * invoked with two arguments: (arrVal, othVal). 13548 * 13549 * @static 13550 * @memberOf _ 13551 * @since 4.0.0 13552 * @category Array 13553 * @param {...Array} [arrays] The arrays to inspect. 13554 * @param {Function} [comparator] The comparator invoked per element. 13555 * @returns {Array} Returns the new array of intersecting values. 13556 * @example 13557 * 13558 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 13559 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 13560 * 13561 * _.intersectionWith(objects, others, _.isEqual); 13562 * // => [{ 'x': 1, 'y': 2 }] 13563 */ 13564 var intersectionWith = baseRest(function(arrays) { 13565 var comparator = last(arrays), 13566 mapped = arrayMap(arrays, castArrayLikeObject); 13567 13568 comparator = typeof comparator == 'function' ? comparator : undefined$1; 13569 if (comparator) { 13570 mapped.pop(); 13571 } 13572 return (mapped.length && mapped[0] === arrays[0]) 13573 ? baseIntersection(mapped, undefined$1, comparator) 13574 : []; 13575 }); 13576 13577 /** 13578 * Converts all elements in `array` into a string separated by `separator`. 13579 * 13580 * @static 13581 * @memberOf _ 13582 * @since 4.0.0 13583 * @category Array 13584 * @param {Array} array The array to convert. 13585 * @param {string} [separator=','] The element separator. 13586 * @returns {string} Returns the joined string. 13587 * @example 13588 * 13589 * _.join(['a', 'b', 'c'], '~'); 13590 * // => 'a~b~c' 13591 */ 13592 function join(array, separator) { 13593 return array == null ? '' : nativeJoin.call(array, separator); 13594 } 13595 13596 /** 13597 * Gets the last element of `array`. 13598 * 13599 * @static 13600 * @memberOf _ 13601 * @since 0.1.0 13602 * @category Array 13603 * @param {Array} array The array to query. 13604 * @returns {*} Returns the last element of `array`. 13605 * @example 13606 * 13607 * _.last([1, 2, 3]); 13608 * // => 3 13609 */ 13610 function last(array) { 13611 var length = array == null ? 0 : array.length; 13612 return length ? array[length - 1] : undefined$1; 13613 } 13614 13615 /** 13616 * This method is like `_.indexOf` except that it iterates over elements of 13617 * `array` from right to left. 13618 * 13619 * @static 13620 * @memberOf _ 13621 * @since 0.1.0 13622 * @category Array 13623 * @param {Array} array The array to inspect. 13624 * @param {*} value The value to search for. 13625 * @param {number} [fromIndex=array.length-1] The index to search from. 13626 * @returns {number} Returns the index of the matched value, else `-1`. 13627 * @example 13628 * 13629 * _.lastIndexOf([1, 2, 1, 2], 2); 13630 * // => 3 13631 * 13632 * // Search from the `fromIndex`. 13633 * _.lastIndexOf([1, 2, 1, 2], 2, 2); 13634 * // => 1 13635 */ 13636 function lastIndexOf(array, value, fromIndex) { 13637 var length = array == null ? 0 : array.length; 13638 if (!length) { 13639 return -1; 13640 } 13641 var index = length; 13642 if (fromIndex !== undefined$1) { 13643 index = toInteger(fromIndex); 13644 index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1); 13645 } 13646 return value === value 13647 ? strictLastIndexOf(array, value, index) 13648 : baseFindIndex(array, baseIsNaN, index, true); 13649 } 13650 13651 /** 13652 * Gets the element at index `n` of `array`. If `n` is negative, the nth 13653 * element from the end is returned. 13654 * 13655 * @static 13656 * @memberOf _ 13657 * @since 4.11.0 13658 * @category Array 13659 * @param {Array} array The array to query. 13660 * @param {number} [n=0] The index of the element to return. 13661 * @returns {*} Returns the nth element of `array`. 13662 * @example 13663 * 13664 * var array = ['a', 'b', 'c', 'd']; 13665 * 13666 * _.nth(array, 1); 13667 * // => 'b' 13668 * 13669 * _.nth(array, -2); 13670 * // => 'c'; 13671 */ 13672 function nth(array, n) { 13673 return (array && array.length) ? baseNth(array, toInteger(n)) : undefined$1; 13674 } 13675 13676 /** 13677 * Removes all given values from `array` using 13678 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 13679 * for equality comparisons. 13680 * 13681 * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` 13682 * to remove elements from an array by predicate. 13683 * 13684 * @static 13685 * @memberOf _ 13686 * @since 2.0.0 13687 * @category Array 13688 * @param {Array} array The array to modify. 13689 * @param {...*} [values] The values to remove. 13690 * @returns {Array} Returns `array`. 13691 * @example 13692 * 13693 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 13694 * 13695 * _.pull(array, 'a', 'c'); 13696 * console.log(array); 13697 * // => ['b', 'b'] 13698 */ 13699 var pull = baseRest(pullAll); 13700 13701 /** 13702 * This method is like `_.pull` except that it accepts an array of values to remove. 13703 * 13704 * **Note:** Unlike `_.difference`, this method mutates `array`. 13705 * 13706 * @static 13707 * @memberOf _ 13708 * @since 4.0.0 13709 * @category Array 13710 * @param {Array} array The array to modify. 13711 * @param {Array} values The values to remove. 13712 * @returns {Array} Returns `array`. 13713 * @example 13714 * 13715 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 13716 * 13717 * _.pullAll(array, ['a', 'c']); 13718 * console.log(array); 13719 * // => ['b', 'b'] 13720 */ 13721 function pullAll(array, values) { 13722 return (array && array.length && values && values.length) 13723 ? basePullAll(array, values) 13724 : array; 13725 } 13726 13727 /** 13728 * This method is like `_.pullAll` except that it accepts `iteratee` which is 13729 * invoked for each element of `array` and `values` to generate the criterion 13730 * by which they're compared. The iteratee is invoked with one argument: (value). 13731 * 13732 * **Note:** Unlike `_.differenceBy`, this method mutates `array`. 13733 * 13734 * @static 13735 * @memberOf _ 13736 * @since 4.0.0 13737 * @category Array 13738 * @param {Array} array The array to modify. 13739 * @param {Array} values The values to remove. 13740 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 13741 * @returns {Array} Returns `array`. 13742 * @example 13743 * 13744 * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; 13745 * 13746 * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); 13747 * console.log(array); 13748 * // => [{ 'x': 2 }] 13749 */ 13750 function pullAllBy(array, values, iteratee) { 13751 return (array && array.length && values && values.length) 13752 ? basePullAll(array, values, getIteratee(iteratee, 2)) 13753 : array; 13754 } 13755 13756 /** 13757 * This method is like `_.pullAll` except that it accepts `comparator` which 13758 * is invoked to compare elements of `array` to `values`. The comparator is 13759 * invoked with two arguments: (arrVal, othVal). 13760 * 13761 * **Note:** Unlike `_.differenceWith`, this method mutates `array`. 13762 * 13763 * @static 13764 * @memberOf _ 13765 * @since 4.6.0 13766 * @category Array 13767 * @param {Array} array The array to modify. 13768 * @param {Array} values The values to remove. 13769 * @param {Function} [comparator] The comparator invoked per element. 13770 * @returns {Array} Returns `array`. 13771 * @example 13772 * 13773 * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]; 13774 * 13775 * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual); 13776 * console.log(array); 13777 * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] 13778 */ 13779 function pullAllWith(array, values, comparator) { 13780 return (array && array.length && values && values.length) 13781 ? basePullAll(array, values, undefined$1, comparator) 13782 : array; 13783 } 13784 13785 /** 13786 * Removes elements from `array` corresponding to `indexes` and returns an 13787 * array of removed elements. 13788 * 13789 * **Note:** Unlike `_.at`, this method mutates `array`. 13790 * 13791 * @static 13792 * @memberOf _ 13793 * @since 3.0.0 13794 * @category Array 13795 * @param {Array} array The array to modify. 13796 * @param {...(number|number[])} [indexes] The indexes of elements to remove. 13797 * @returns {Array} Returns the new array of removed elements. 13798 * @example 13799 * 13800 * var array = ['a', 'b', 'c', 'd']; 13801 * var pulled = _.pullAt(array, [1, 3]); 13802 * 13803 * console.log(array); 13804 * // => ['a', 'c'] 13805 * 13806 * console.log(pulled); 13807 * // => ['b', 'd'] 13808 */ 13809 var pullAt = flatRest(function(array, indexes) { 13810 var length = array == null ? 0 : array.length, 13811 result = baseAt(array, indexes); 13812 13813 basePullAt(array, arrayMap(indexes, function(index) { 13814 return isIndex(index, length) ? +index : index; 13815 }).sort(compareAscending)); 13816 13817 return result; 13818 }); 13819 13820 /** 13821 * Removes all elements from `array` that `predicate` returns truthy for 13822 * and returns an array of the removed elements. The predicate is invoked 13823 * with three arguments: (value, index, array). 13824 * 13825 * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` 13826 * to pull elements from an array by value. 13827 * 13828 * @static 13829 * @memberOf _ 13830 * @since 2.0.0 13831 * @category Array 13832 * @param {Array} array The array to modify. 13833 * @param {Function} [predicate=_.identity] The function invoked per iteration. 13834 * @returns {Array} Returns the new array of removed elements. 13835 * @example 13836 * 13837 * var array = [1, 2, 3, 4]; 13838 * var evens = _.remove(array, function(n) { 13839 * return n % 2 == 0; 13840 * }); 13841 * 13842 * console.log(array); 13843 * // => [1, 3] 13844 * 13845 * console.log(evens); 13846 * // => [2, 4] 13847 */ 13848 function remove(array, predicate) { 13849 var result = []; 13850 if (!(array && array.length)) { 13851 return result; 13852 } 13853 var index = -1, 13854 indexes = [], 13855 length = array.length; 13856 13857 predicate = getIteratee(predicate, 3); 13858 while (++index < length) { 13859 var value = array[index]; 13860 if (predicate(value, index, array)) { 13861 result.push(value); 13862 indexes.push(index); 13863 } 13864 } 13865 basePullAt(array, indexes); 13866 return result; 13867 } 13868 13869 /** 13870 * Reverses `array` so that the first element becomes the last, the second 13871 * element becomes the second to last, and so on. 13872 * 13873 * **Note:** This method mutates `array` and is based on 13874 * [`Array#reverse`](https://mdn.io/Array/reverse). 13875 * 13876 * @static 13877 * @memberOf _ 13878 * @since 4.0.0 13879 * @category Array 13880 * @param {Array} array The array to modify. 13881 * @returns {Array} Returns `array`. 13882 * @example 13883 * 13884 * var array = [1, 2, 3]; 13885 * 13886 * _.reverse(array); 13887 * // => [3, 2, 1] 13888 * 13889 * console.log(array); 13890 * // => [3, 2, 1] 13891 */ 13892 function reverse(array) { 13893 return array == null ? array : nativeReverse.call(array); 13894 } 13895 13896 /** 13897 * Creates a slice of `array` from `start` up to, but not including, `end`. 13898 * 13899 * **Note:** This method is used instead of 13900 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are 13901 * returned. 13902 * 13903 * @static 13904 * @memberOf _ 13905 * @since 3.0.0 13906 * @category Array 13907 * @param {Array} array The array to slice. 13908 * @param {number} [start=0] The start position. 13909 * @param {number} [end=array.length] The end position. 13910 * @returns {Array} Returns the slice of `array`. 13911 */ 13912 function slice(array, start, end) { 13913 var length = array == null ? 0 : array.length; 13914 if (!length) { 13915 return []; 13916 } 13917 if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { 13918 start = 0; 13919 end = length; 13920 } 13921 else { 13922 start = start == null ? 0 : toInteger(start); 13923 end = end === undefined$1 ? length : toInteger(end); 13924 } 13925 return baseSlice(array, start, end); 13926 } 13927 13928 /** 13929 * Uses a binary search to determine the lowest index at which `value` 13930 * should be inserted into `array` in order to maintain its sort order. 13931 * 13932 * @static 13933 * @memberOf _ 13934 * @since 0.1.0 13935 * @category Array 13936 * @param {Array} array The sorted array to inspect. 13937 * @param {*} value The value to evaluate. 13938 * @returns {number} Returns the index at which `value` should be inserted 13939 * into `array`. 13940 * @example 13941 * 13942 * _.sortedIndex([30, 50], 40); 13943 * // => 1 13944 */ 13945 function sortedIndex(array, value) { 13946 return baseSortedIndex(array, value); 13947 } 13948 13949 /** 13950 * This method is like `_.sortedIndex` except that it accepts `iteratee` 13951 * which is invoked for `value` and each element of `array` to compute their 13952 * sort ranking. The iteratee is invoked with one argument: (value). 13953 * 13954 * @static 13955 * @memberOf _ 13956 * @since 4.0.0 13957 * @category Array 13958 * @param {Array} array The sorted array to inspect. 13959 * @param {*} value The value to evaluate. 13960 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 13961 * @returns {number} Returns the index at which `value` should be inserted 13962 * into `array`. 13963 * @example 13964 * 13965 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 13966 * 13967 * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 13968 * // => 0 13969 * 13970 * // The `_.property` iteratee shorthand. 13971 * _.sortedIndexBy(objects, { 'x': 4 }, 'x'); 13972 * // => 0 13973 */ 13974 function sortedIndexBy(array, value, iteratee) { 13975 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2)); 13976 } 13977 13978 /** 13979 * This method is like `_.indexOf` except that it performs a binary 13980 * search on a sorted `array`. 13981 * 13982 * @static 13983 * @memberOf _ 13984 * @since 4.0.0 13985 * @category Array 13986 * @param {Array} array The array to inspect. 13987 * @param {*} value The value to search for. 13988 * @returns {number} Returns the index of the matched value, else `-1`. 13989 * @example 13990 * 13991 * _.sortedIndexOf([4, 5, 5, 5, 6], 5); 13992 * // => 1 13993 */ 13994 function sortedIndexOf(array, value) { 13995 var length = array == null ? 0 : array.length; 13996 if (length) { 13997 var index = baseSortedIndex(array, value); 13998 if (index < length && eq(array[index], value)) { 13999 return index; 14000 } 14001 } 14002 return -1; 14003 } 14004 14005 /** 14006 * This method is like `_.sortedIndex` except that it returns the highest 14007 * index at which `value` should be inserted into `array` in order to 14008 * maintain its sort order. 14009 * 14010 * @static 14011 * @memberOf _ 14012 * @since 3.0.0 14013 * @category Array 14014 * @param {Array} array The sorted array to inspect. 14015 * @param {*} value The value to evaluate. 14016 * @returns {number} Returns the index at which `value` should be inserted 14017 * into `array`. 14018 * @example 14019 * 14020 * _.sortedLastIndex([4, 5, 5, 5, 6], 5); 14021 * // => 4 14022 */ 14023 function sortedLastIndex(array, value) { 14024 return baseSortedIndex(array, value, true); 14025 } 14026 14027 /** 14028 * This method is like `_.sortedLastIndex` except that it accepts `iteratee` 14029 * which is invoked for `value` and each element of `array` to compute their 14030 * sort ranking. The iteratee is invoked with one argument: (value). 14031 * 14032 * @static 14033 * @memberOf _ 14034 * @since 4.0.0 14035 * @category Array 14036 * @param {Array} array The sorted array to inspect. 14037 * @param {*} value The value to evaluate. 14038 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 14039 * @returns {number} Returns the index at which `value` should be inserted 14040 * into `array`. 14041 * @example 14042 * 14043 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 14044 * 14045 * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 14046 * // => 1 14047 * 14048 * // The `_.property` iteratee shorthand. 14049 * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x'); 14050 * // => 1 14051 */ 14052 function sortedLastIndexBy(array, value, iteratee) { 14053 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true); 14054 } 14055 14056 /** 14057 * This method is like `_.lastIndexOf` except that it performs a binary 14058 * search on a sorted `array`. 14059 * 14060 * @static 14061 * @memberOf _ 14062 * @since 4.0.0 14063 * @category Array 14064 * @param {Array} array The array to inspect. 14065 * @param {*} value The value to search for. 14066 * @returns {number} Returns the index of the matched value, else `-1`. 14067 * @example 14068 * 14069 * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5); 14070 * // => 3 14071 */ 14072 function sortedLastIndexOf(array, value) { 14073 var length = array == null ? 0 : array.length; 14074 if (length) { 14075 var index = baseSortedIndex(array, value, true) - 1; 14076 if (eq(array[index], value)) { 14077 return index; 14078 } 14079 } 14080 return -1; 14081 } 14082 14083 /** 14084 * This method is like `_.uniq` except that it's designed and optimized 14085 * for sorted arrays. 14086 * 14087 * @static 14088 * @memberOf _ 14089 * @since 4.0.0 14090 * @category Array 14091 * @param {Array} array The array to inspect. 14092 * @returns {Array} Returns the new duplicate free array. 14093 * @example 14094 * 14095 * _.sortedUniq([1, 1, 2]); 14096 * // => [1, 2] 14097 */ 14098 function sortedUniq(array) { 14099 return (array && array.length) 14100 ? baseSortedUniq(array) 14101 : []; 14102 } 14103 14104 /** 14105 * This method is like `_.uniqBy` except that it's designed and optimized 14106 * for sorted arrays. 14107 * 14108 * @static 14109 * @memberOf _ 14110 * @since 4.0.0 14111 * @category Array 14112 * @param {Array} array The array to inspect. 14113 * @param {Function} [iteratee] The iteratee invoked per element. 14114 * @returns {Array} Returns the new duplicate free array. 14115 * @example 14116 * 14117 * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); 14118 * // => [1.1, 2.3] 14119 */ 14120 function sortedUniqBy(array, iteratee) { 14121 return (array && array.length) 14122 ? baseSortedUniq(array, getIteratee(iteratee, 2)) 14123 : []; 14124 } 14125 14126 /** 14127 * Gets all but the first element of `array`. 14128 * 14129 * @static 14130 * @memberOf _ 14131 * @since 4.0.0 14132 * @category Array 14133 * @param {Array} array The array to query. 14134 * @returns {Array} Returns the slice of `array`. 14135 * @example 14136 * 14137 * _.tail([1, 2, 3]); 14138 * // => [2, 3] 14139 */ 14140 function tail(array) { 14141 var length = array == null ? 0 : array.length; 14142 return length ? baseSlice(array, 1, length) : []; 14143 } 14144 14145 /** 14146 * Creates a slice of `array` with `n` elements taken from the beginning. 14147 * 14148 * @static 14149 * @memberOf _ 14150 * @since 0.1.0 14151 * @category Array 14152 * @param {Array} array The array to query. 14153 * @param {number} [n=1] The number of elements to take. 14154 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 14155 * @returns {Array} Returns the slice of `array`. 14156 * @example 14157 * 14158 * _.take([1, 2, 3]); 14159 * // => [1] 14160 * 14161 * _.take([1, 2, 3], 2); 14162 * // => [1, 2] 14163 * 14164 * _.take([1, 2, 3], 5); 14165 * // => [1, 2, 3] 14166 * 14167 * _.take([1, 2, 3], 0); 14168 * // => [] 14169 */ 14170 function take(array, n, guard) { 14171 if (!(array && array.length)) { 14172 return []; 14173 } 14174 n = (guard || n === undefined$1) ? 1 : toInteger(n); 14175 return baseSlice(array, 0, n < 0 ? 0 : n); 14176 } 14177 14178 /** 14179 * Creates a slice of `array` with `n` elements taken from the end. 14180 * 14181 * @static 14182 * @memberOf _ 14183 * @since 3.0.0 14184 * @category Array 14185 * @param {Array} array The array to query. 14186 * @param {number} [n=1] The number of elements to take. 14187 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 14188 * @returns {Array} Returns the slice of `array`. 14189 * @example 14190 * 14191 * _.takeRight([1, 2, 3]); 14192 * // => [3] 14193 * 14194 * _.takeRight([1, 2, 3], 2); 14195 * // => [2, 3] 14196 * 14197 * _.takeRight([1, 2, 3], 5); 14198 * // => [1, 2, 3] 14199 * 14200 * _.takeRight([1, 2, 3], 0); 14201 * // => [] 14202 */ 14203 function takeRight(array, n, guard) { 14204 var length = array == null ? 0 : array.length; 14205 if (!length) { 14206 return []; 14207 } 14208 n = (guard || n === undefined$1) ? 1 : toInteger(n); 14209 n = length - n; 14210 return baseSlice(array, n < 0 ? 0 : n, length); 14211 } 14212 14213 /** 14214 * Creates a slice of `array` with elements taken from the end. Elements are 14215 * taken until `predicate` returns falsey. The predicate is invoked with 14216 * three arguments: (value, index, array). 14217 * 14218 * @static 14219 * @memberOf _ 14220 * @since 3.0.0 14221 * @category Array 14222 * @param {Array} array The array to query. 14223 * @param {Function} [predicate=_.identity] The function invoked per iteration. 14224 * @returns {Array} Returns the slice of `array`. 14225 * @example 14226 * 14227 * var users = [ 14228 * { 'user': 'barney', 'active': true }, 14229 * { 'user': 'fred', 'active': false }, 14230 * { 'user': 'pebbles', 'active': false } 14231 * ]; 14232 * 14233 * _.takeRightWhile(users, function(o) { return !o.active; }); 14234 * // => objects for ['fred', 'pebbles'] 14235 * 14236 * // The `_.matches` iteratee shorthand. 14237 * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); 14238 * // => objects for ['pebbles'] 14239 * 14240 * // The `_.matchesProperty` iteratee shorthand. 14241 * _.takeRightWhile(users, ['active', false]); 14242 * // => objects for ['fred', 'pebbles'] 14243 * 14244 * // The `_.property` iteratee shorthand. 14245 * _.takeRightWhile(users, 'active'); 14246 * // => [] 14247 */ 14248 function takeRightWhile(array, predicate) { 14249 return (array && array.length) 14250 ? baseWhile(array, getIteratee(predicate, 3), false, true) 14251 : []; 14252 } 14253 14254 /** 14255 * Creates a slice of `array` with elements taken from the beginning. Elements 14256 * are taken until `predicate` returns falsey. The predicate is invoked with 14257 * three arguments: (value, index, array). 14258 * 14259 * @static 14260 * @memberOf _ 14261 * @since 3.0.0 14262 * @category Array 14263 * @param {Array} array The array to query. 14264 * @param {Function} [predicate=_.identity] The function invoked per iteration. 14265 * @returns {Array} Returns the slice of `array`. 14266 * @example 14267 * 14268 * var users = [ 14269 * { 'user': 'barney', 'active': false }, 14270 * { 'user': 'fred', 'active': false }, 14271 * { 'user': 'pebbles', 'active': true } 14272 * ]; 14273 * 14274 * _.takeWhile(users, function(o) { return !o.active; }); 14275 * // => objects for ['barney', 'fred'] 14276 * 14277 * // The `_.matches` iteratee shorthand. 14278 * _.takeWhile(users, { 'user': 'barney', 'active': false }); 14279 * // => objects for ['barney'] 14280 * 14281 * // The `_.matchesProperty` iteratee shorthand. 14282 * _.takeWhile(users, ['active', false]); 14283 * // => objects for ['barney', 'fred'] 14284 * 14285 * // The `_.property` iteratee shorthand. 14286 * _.takeWhile(users, 'active'); 14287 * // => [] 14288 */ 14289 function takeWhile(array, predicate) { 14290 return (array && array.length) 14291 ? baseWhile(array, getIteratee(predicate, 3)) 14292 : []; 14293 } 14294 14295 /** 14296 * Creates an array of unique values, in order, from all given arrays using 14297 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 14298 * for equality comparisons. 14299 * 14300 * @static 14301 * @memberOf _ 14302 * @since 0.1.0 14303 * @category Array 14304 * @param {...Array} [arrays] The arrays to inspect. 14305 * @returns {Array} Returns the new array of combined values. 14306 * @example 14307 * 14308 * _.union([2], [1, 2]); 14309 * // => [2, 1] 14310 */ 14311 var union = baseRest(function(arrays) { 14312 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); 14313 }); 14314 14315 /** 14316 * This method is like `_.union` except that it accepts `iteratee` which is 14317 * invoked for each element of each `arrays` to generate the criterion by 14318 * which uniqueness is computed. Result values are chosen from the first 14319 * array in which the value occurs. The iteratee is invoked with one argument: 14320 * (value). 14321 * 14322 * @static 14323 * @memberOf _ 14324 * @since 4.0.0 14325 * @category Array 14326 * @param {...Array} [arrays] The arrays to inspect. 14327 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 14328 * @returns {Array} Returns the new array of combined values. 14329 * @example 14330 * 14331 * _.unionBy([2.1], [1.2, 2.3], Math.floor); 14332 * // => [2.1, 1.2] 14333 * 14334 * // The `_.property` iteratee shorthand. 14335 * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 14336 * // => [{ 'x': 1 }, { 'x': 2 }] 14337 */ 14338 var unionBy = baseRest(function(arrays) { 14339 var iteratee = last(arrays); 14340 if (isArrayLikeObject(iteratee)) { 14341 iteratee = undefined$1; 14342 } 14343 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)); 14344 }); 14345 14346 /** 14347 * This method is like `_.union` except that it accepts `comparator` which 14348 * is invoked to compare elements of `arrays`. Result values are chosen from 14349 * the first array in which the value occurs. The comparator is invoked 14350 * with two arguments: (arrVal, othVal). 14351 * 14352 * @static 14353 * @memberOf _ 14354 * @since 4.0.0 14355 * @category Array 14356 * @param {...Array} [arrays] The arrays to inspect. 14357 * @param {Function} [comparator] The comparator invoked per element. 14358 * @returns {Array} Returns the new array of combined values. 14359 * @example 14360 * 14361 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 14362 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 14363 * 14364 * _.unionWith(objects, others, _.isEqual); 14365 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 14366 */ 14367 var unionWith = baseRest(function(arrays) { 14368 var comparator = last(arrays); 14369 comparator = typeof comparator == 'function' ? comparator : undefined$1; 14370 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined$1, comparator); 14371 }); 14372 14373 /** 14374 * Creates a duplicate-free version of an array, using 14375 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 14376 * for equality comparisons, in which only the first occurrence of each element 14377 * is kept. The order of result values is determined by the order they occur 14378 * in the array. 14379 * 14380 * @static 14381 * @memberOf _ 14382 * @since 0.1.0 14383 * @category Array 14384 * @param {Array} array The array to inspect. 14385 * @returns {Array} Returns the new duplicate free array. 14386 * @example 14387 * 14388 * _.uniq([2, 1, 2]); 14389 * // => [2, 1] 14390 */ 14391 function uniq(array) { 14392 return (array && array.length) ? baseUniq(array) : []; 14393 } 14394 14395 /** 14396 * This method is like `_.uniq` except that it accepts `iteratee` which is 14397 * invoked for each element in `array` to generate the criterion by which 14398 * uniqueness is computed. The order of result values is determined by the 14399 * order they occur in the array. The iteratee is invoked with one argument: 14400 * (value). 14401 * 14402 * @static 14403 * @memberOf _ 14404 * @since 4.0.0 14405 * @category Array 14406 * @param {Array} array The array to inspect. 14407 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 14408 * @returns {Array} Returns the new duplicate free array. 14409 * @example 14410 * 14411 * _.uniqBy([2.1, 1.2, 2.3], Math.floor); 14412 * // => [2.1, 1.2] 14413 * 14414 * // The `_.property` iteratee shorthand. 14415 * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); 14416 * // => [{ 'x': 1 }, { 'x': 2 }] 14417 */ 14418 function uniqBy(array, iteratee) { 14419 return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : []; 14420 } 14421 14422 /** 14423 * This method is like `_.uniq` except that it accepts `comparator` which 14424 * is invoked to compare elements of `array`. The order of result values is 14425 * determined by the order they occur in the array.The comparator is invoked 14426 * with two arguments: (arrVal, othVal). 14427 * 14428 * @static 14429 * @memberOf _ 14430 * @since 4.0.0 14431 * @category Array 14432 * @param {Array} array The array to inspect. 14433 * @param {Function} [comparator] The comparator invoked per element. 14434 * @returns {Array} Returns the new duplicate free array. 14435 * @example 14436 * 14437 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; 14438 * 14439 * _.uniqWith(objects, _.isEqual); 14440 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] 14441 */ 14442 function uniqWith(array, comparator) { 14443 comparator = typeof comparator == 'function' ? comparator : undefined$1; 14444 return (array && array.length) ? baseUniq(array, undefined$1, comparator) : []; 14445 } 14446 14447 /** 14448 * This method is like `_.zip` except that it accepts an array of grouped 14449 * elements and creates an array regrouping the elements to their pre-zip 14450 * configuration. 14451 * 14452 * @static 14453 * @memberOf _ 14454 * @since 1.2.0 14455 * @category Array 14456 * @param {Array} array The array of grouped elements to process. 14457 * @returns {Array} Returns the new array of regrouped elements. 14458 * @example 14459 * 14460 * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]); 14461 * // => [['a', 1, true], ['b', 2, false]] 14462 * 14463 * _.unzip(zipped); 14464 * // => [['a', 'b'], [1, 2], [true, false]] 14465 */ 14466 function unzip(array) { 14467 if (!(array && array.length)) { 14468 return []; 14469 } 14470 var length = 0; 14471 array = arrayFilter(array, function(group) { 14472 if (isArrayLikeObject(group)) { 14473 length = nativeMax(group.length, length); 14474 return true; 14475 } 14476 }); 14477 return baseTimes(length, function(index) { 14478 return arrayMap(array, baseProperty(index)); 14479 }); 14480 } 14481 14482 /** 14483 * This method is like `_.unzip` except that it accepts `iteratee` to specify 14484 * how regrouped values should be combined. The iteratee is invoked with the 14485 * elements of each group: (...group). 14486 * 14487 * @static 14488 * @memberOf _ 14489 * @since 3.8.0 14490 * @category Array 14491 * @param {Array} array The array of grouped elements to process. 14492 * @param {Function} [iteratee=_.identity] The function to combine 14493 * regrouped values. 14494 * @returns {Array} Returns the new array of regrouped elements. 14495 * @example 14496 * 14497 * var zipped = _.zip([1, 2], [10, 20], [100, 200]); 14498 * // => [[1, 10, 100], [2, 20, 200]] 14499 * 14500 * _.unzipWith(zipped, _.add); 14501 * // => [3, 30, 300] 14502 */ 14503 function unzipWith(array, iteratee) { 14504 if (!(array && array.length)) { 14505 return []; 14506 } 14507 var result = unzip(array); 14508 if (iteratee == null) { 14509 return result; 14510 } 14511 return arrayMap(result, function(group) { 14512 return apply(iteratee, undefined$1, group); 14513 }); 14514 } 14515 14516 /** 14517 * Creates an array excluding all given values using 14518 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 14519 * for equality comparisons. 14520 * 14521 * **Note:** Unlike `_.pull`, this method returns a new array. 14522 * 14523 * @static 14524 * @memberOf _ 14525 * @since 0.1.0 14526 * @category Array 14527 * @param {Array} array The array to inspect. 14528 * @param {...*} [values] The values to exclude. 14529 * @returns {Array} Returns the new array of filtered values. 14530 * @see _.difference, _.xor 14531 * @example 14532 * 14533 * _.without([2, 1, 2, 3], 1, 2); 14534 * // => [3] 14535 */ 14536 var without = baseRest(function(array, values) { 14537 return isArrayLikeObject(array) 14538 ? baseDifference(array, values) 14539 : []; 14540 }); 14541 14542 /** 14543 * Creates an array of unique values that is the 14544 * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) 14545 * of the given arrays. The order of result values is determined by the order 14546 * they occur in the arrays. 14547 * 14548 * @static 14549 * @memberOf _ 14550 * @since 2.4.0 14551 * @category Array 14552 * @param {...Array} [arrays] The arrays to inspect. 14553 * @returns {Array} Returns the new array of filtered values. 14554 * @see _.difference, _.without 14555 * @example 14556 * 14557 * _.xor([2, 1], [2, 3]); 14558 * // => [1, 3] 14559 */ 14560 var xor = baseRest(function(arrays) { 14561 return baseXor(arrayFilter(arrays, isArrayLikeObject)); 14562 }); 14563 14564 /** 14565 * This method is like `_.xor` except that it accepts `iteratee` which is 14566 * invoked for each element of each `arrays` to generate the criterion by 14567 * which by which they're compared. The order of result values is determined 14568 * by the order they occur in the arrays. The iteratee is invoked with one 14569 * argument: (value). 14570 * 14571 * @static 14572 * @memberOf _ 14573 * @since 4.0.0 14574 * @category Array 14575 * @param {...Array} [arrays] The arrays to inspect. 14576 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 14577 * @returns {Array} Returns the new array of filtered values. 14578 * @example 14579 * 14580 * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); 14581 * // => [1.2, 3.4] 14582 * 14583 * // The `_.property` iteratee shorthand. 14584 * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 14585 * // => [{ 'x': 2 }] 14586 */ 14587 var xorBy = baseRest(function(arrays) { 14588 var iteratee = last(arrays); 14589 if (isArrayLikeObject(iteratee)) { 14590 iteratee = undefined$1; 14591 } 14592 return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2)); 14593 }); 14594 14595 /** 14596 * This method is like `_.xor` except that it accepts `comparator` which is 14597 * invoked to compare elements of `arrays`. The order of result values is 14598 * determined by the order they occur in the arrays. The comparator is invoked 14599 * with two arguments: (arrVal, othVal). 14600 * 14601 * @static 14602 * @memberOf _ 14603 * @since 4.0.0 14604 * @category Array 14605 * @param {...Array} [arrays] The arrays to inspect. 14606 * @param {Function} [comparator] The comparator invoked per element. 14607 * @returns {Array} Returns the new array of filtered values. 14608 * @example 14609 * 14610 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 14611 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 14612 * 14613 * _.xorWith(objects, others, _.isEqual); 14614 * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 14615 */ 14616 var xorWith = baseRest(function(arrays) { 14617 var comparator = last(arrays); 14618 comparator = typeof comparator == 'function' ? comparator : undefined$1; 14619 return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined$1, comparator); 14620 }); 14621 14622 /** 14623 * Creates an array of grouped elements, the first of which contains the 14624 * first elements of the given arrays, the second of which contains the 14625 * second elements of the given arrays, and so on. 14626 * 14627 * @static 14628 * @memberOf _ 14629 * @since 0.1.0 14630 * @category Array 14631 * @param {...Array} [arrays] The arrays to process. 14632 * @returns {Array} Returns the new array of grouped elements. 14633 * @example 14634 * 14635 * _.zip(['a', 'b'], [1, 2], [true, false]); 14636 * // => [['a', 1, true], ['b', 2, false]] 14637 */ 14638 var zip = baseRest(unzip); 14639 14640 /** 14641 * This method is like `_.fromPairs` except that it accepts two arrays, 14642 * one of property identifiers and one of corresponding values. 14643 * 14644 * @static 14645 * @memberOf _ 14646 * @since 0.4.0 14647 * @category Array 14648 * @param {Array} [props=[]] The property identifiers. 14649 * @param {Array} [values=[]] The property values. 14650 * @returns {Object} Returns the new object. 14651 * @example 14652 * 14653 * _.zipObject(['a', 'b'], [1, 2]); 14654 * // => { 'a': 1, 'b': 2 } 14655 */ 14656 function zipObject(props, values) { 14657 return baseZipObject(props || [], values || [], assignValue); 14658 } 14659 14660 /** 14661 * This method is like `_.zipObject` except that it supports property paths. 14662 * 14663 * @static 14664 * @memberOf _ 14665 * @since 4.1.0 14666 * @category Array 14667 * @param {Array} [props=[]] The property identifiers. 14668 * @param {Array} [values=[]] The property values. 14669 * @returns {Object} Returns the new object. 14670 * @example 14671 * 14672 * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]); 14673 * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } 14674 */ 14675 function zipObjectDeep(props, values) { 14676 return baseZipObject(props || [], values || [], baseSet); 14677 } 14678 14679 /** 14680 * This method is like `_.zip` except that it accepts `iteratee` to specify 14681 * how grouped values should be combined. The iteratee is invoked with the 14682 * elements of each group: (...group). 14683 * 14684 * @static 14685 * @memberOf _ 14686 * @since 3.8.0 14687 * @category Array 14688 * @param {...Array} [arrays] The arrays to process. 14689 * @param {Function} [iteratee=_.identity] The function to combine 14690 * grouped values. 14691 * @returns {Array} Returns the new array of grouped elements. 14692 * @example 14693 * 14694 * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { 14695 * return a + b + c; 14696 * }); 14697 * // => [111, 222] 14698 */ 14699 var zipWith = baseRest(function(arrays) { 14700 var length = arrays.length, 14701 iteratee = length > 1 ? arrays[length - 1] : undefined$1; 14702 14703 iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined$1; 14704 return unzipWith(arrays, iteratee); 14705 }); 14706 14707 /*------------------------------------------------------------------------*/ 14708 14709 /** 14710 * Creates a `lodash` wrapper instance that wraps `value` with explicit method 14711 * chain sequences enabled. The result of such sequences must be unwrapped 14712 * with `_#value`. 14713 * 14714 * @static 14715 * @memberOf _ 14716 * @since 1.3.0 14717 * @category Seq 14718 * @param {*} value The value to wrap. 14719 * @returns {Object} Returns the new `lodash` wrapper instance. 14720 * @example 14721 * 14722 * var users = [ 14723 * { 'user': 'barney', 'age': 36 }, 14724 * { 'user': 'fred', 'age': 40 }, 14725 * { 'user': 'pebbles', 'age': 1 } 14726 * ]; 14727 * 14728 * var youngest = _ 14729 * .chain(users) 14730 * .sortBy('age') 14731 * .map(function(o) { 14732 * return o.user + ' is ' + o.age; 14733 * }) 14734 * .head() 14735 * .value(); 14736 * // => 'pebbles is 1' 14737 */ 14738 function chain(value) { 14739 var result = lodash(value); 14740 result.__chain__ = true; 14741 return result; 14742 } 14743 14744 /** 14745 * This method invokes `interceptor` and returns `value`. The interceptor 14746 * is invoked with one argument; (value). The purpose of this method is to 14747 * "tap into" a method chain sequence in order to modify intermediate results. 14748 * 14749 * @static 14750 * @memberOf _ 14751 * @since 0.1.0 14752 * @category Seq 14753 * @param {*} value The value to provide to `interceptor`. 14754 * @param {Function} interceptor The function to invoke. 14755 * @returns {*} Returns `value`. 14756 * @example 14757 * 14758 * _([1, 2, 3]) 14759 * .tap(function(array) { 14760 * // Mutate input array. 14761 * array.pop(); 14762 * }) 14763 * .reverse() 14764 * .value(); 14765 * // => [2, 1] 14766 */ 14767 function tap(value, interceptor) { 14768 interceptor(value); 14769 return value; 14770 } 14771 14772 /** 14773 * This method is like `_.tap` except that it returns the result of `interceptor`. 14774 * The purpose of this method is to "pass thru" values replacing intermediate 14775 * results in a method chain sequence. 14776 * 14777 * @static 14778 * @memberOf _ 14779 * @since 3.0.0 14780 * @category Seq 14781 * @param {*} value The value to provide to `interceptor`. 14782 * @param {Function} interceptor The function to invoke. 14783 * @returns {*} Returns the result of `interceptor`. 14784 * @example 14785 * 14786 * _(' abc ') 14787 * .chain() 14788 * .trim() 14789 * .thru(function(value) { 14790 * return [value]; 14791 * }) 14792 * .value(); 14793 * // => ['abc'] 14794 */ 14795 function thru(value, interceptor) { 14796 return interceptor(value); 14797 } 14798 14799 /** 14800 * This method is the wrapper version of `_.at`. 14801 * 14802 * @name at 14803 * @memberOf _ 14804 * @since 1.0.0 14805 * @category Seq 14806 * @param {...(string|string[])} [paths] The property paths to pick. 14807 * @returns {Object} Returns the new `lodash` wrapper instance. 14808 * @example 14809 * 14810 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 14811 * 14812 * _(object).at(['a[0].b.c', 'a[1]']).value(); 14813 * // => [3, 4] 14814 */ 14815 var wrapperAt = flatRest(function(paths) { 14816 var length = paths.length, 14817 start = length ? paths[0] : 0, 14818 value = this.__wrapped__, 14819 interceptor = function(object) { return baseAt(object, paths); }; 14820 14821 if (length > 1 || this.__actions__.length || 14822 !(value instanceof LazyWrapper) || !isIndex(start)) { 14823 return this.thru(interceptor); 14824 } 14825 value = value.slice(start, +start + (length ? 1 : 0)); 14826 value.__actions__.push({ 14827 'func': thru, 14828 'args': [interceptor], 14829 'thisArg': undefined$1 14830 }); 14831 return new LodashWrapper(value, this.__chain__).thru(function(array) { 14832 if (length && !array.length) { 14833 array.push(undefined$1); 14834 } 14835 return array; 14836 }); 14837 }); 14838 14839 /** 14840 * Creates a `lodash` wrapper instance with explicit method chain sequences enabled. 14841 * 14842 * @name chain 14843 * @memberOf _ 14844 * @since 0.1.0 14845 * @category Seq 14846 * @returns {Object} Returns the new `lodash` wrapper instance. 14847 * @example 14848 * 14849 * var users = [ 14850 * { 'user': 'barney', 'age': 36 }, 14851 * { 'user': 'fred', 'age': 40 } 14852 * ]; 14853 * 14854 * // A sequence without explicit chaining. 14855 * _(users).head(); 14856 * // => { 'user': 'barney', 'age': 36 } 14857 * 14858 * // A sequence with explicit chaining. 14859 * _(users) 14860 * .chain() 14861 * .head() 14862 * .pick('user') 14863 * .value(); 14864 * // => { 'user': 'barney' } 14865 */ 14866 function wrapperChain() { 14867 return chain(this); 14868 } 14869 14870 /** 14871 * Executes the chain sequence and returns the wrapped result. 14872 * 14873 * @name commit 14874 * @memberOf _ 14875 * @since 3.2.0 14876 * @category Seq 14877 * @returns {Object} Returns the new `lodash` wrapper instance. 14878 * @example 14879 * 14880 * var array = [1, 2]; 14881 * var wrapped = _(array).push(3); 14882 * 14883 * console.log(array); 14884 * // => [1, 2] 14885 * 14886 * wrapped = wrapped.commit(); 14887 * console.log(array); 14888 * // => [1, 2, 3] 14889 * 14890 * wrapped.last(); 14891 * // => 3 14892 * 14893 * console.log(array); 14894 * // => [1, 2, 3] 14895 */ 14896 function wrapperCommit() { 14897 return new LodashWrapper(this.value(), this.__chain__); 14898 } 14899 14900 /** 14901 * Gets the next value on a wrapped object following the 14902 * [iterator protocol](https://mdn.io/iteration_protocols#iterator). 14903 * 14904 * @name next 14905 * @memberOf _ 14906 * @since 4.0.0 14907 * @category Seq 14908 * @returns {Object} Returns the next iterator value. 14909 * @example 14910 * 14911 * var wrapped = _([1, 2]); 14912 * 14913 * wrapped.next(); 14914 * // => { 'done': false, 'value': 1 } 14915 * 14916 * wrapped.next(); 14917 * // => { 'done': false, 'value': 2 } 14918 * 14919 * wrapped.next(); 14920 * // => { 'done': true, 'value': undefined } 14921 */ 14922 function wrapperNext() { 14923 if (this.__values__ === undefined$1) { 14924 this.__values__ = toArray(this.value()); 14925 } 14926 var done = this.__index__ >= this.__values__.length, 14927 value = done ? undefined$1 : this.__values__[this.__index__++]; 14928 14929 return { 'done': done, 'value': value }; 14930 } 14931 14932 /** 14933 * Enables the wrapper to be iterable. 14934 * 14935 * @name Symbol.iterator 14936 * @memberOf _ 14937 * @since 4.0.0 14938 * @category Seq 14939 * @returns {Object} Returns the wrapper object. 14940 * @example 14941 * 14942 * var wrapped = _([1, 2]); 14943 * 14944 * wrapped[Symbol.iterator]() === wrapped; 14945 * // => true 14946 * 14947 * Array.from(wrapped); 14948 * // => [1, 2] 14949 */ 14950 function wrapperToIterator() { 14951 return this; 14952 } 14953 14954 /** 14955 * Creates a clone of the chain sequence planting `value` as the wrapped value. 14956 * 14957 * @name plant 14958 * @memberOf _ 14959 * @since 3.2.0 14960 * @category Seq 14961 * @param {*} value The value to plant. 14962 * @returns {Object} Returns the new `lodash` wrapper instance. 14963 * @example 14964 * 14965 * function square(n) { 14966 * return n * n; 14967 * } 14968 * 14969 * var wrapped = _([1, 2]).map(square); 14970 * var other = wrapped.plant([3, 4]); 14971 * 14972 * other.value(); 14973 * // => [9, 16] 14974 * 14975 * wrapped.value(); 14976 * // => [1, 4] 14977 */ 14978 function wrapperPlant(value) { 14979 var result, 14980 parent = this; 14981 14982 while (parent instanceof baseLodash) { 14983 var clone = wrapperClone(parent); 14984 clone.__index__ = 0; 14985 clone.__values__ = undefined$1; 14986 if (result) { 14987 previous.__wrapped__ = clone; 14988 } else { 14989 result = clone; 14990 } 14991 var previous = clone; 14992 parent = parent.__wrapped__; 14993 } 14994 previous.__wrapped__ = value; 14995 return result; 14996 } 14997 14998 /** 14999 * This method is the wrapper version of `_.reverse`. 15000 * 15001 * **Note:** This method mutates the wrapped array. 15002 * 15003 * @name reverse 15004 * @memberOf _ 15005 * @since 0.1.0 15006 * @category Seq 15007 * @returns {Object} Returns the new `lodash` wrapper instance. 15008 * @example 15009 * 15010 * var array = [1, 2, 3]; 15011 * 15012 * _(array).reverse().value() 15013 * // => [3, 2, 1] 15014 * 15015 * console.log(array); 15016 * // => [3, 2, 1] 15017 */ 15018 function wrapperReverse() { 15019 var value = this.__wrapped__; 15020 if (value instanceof LazyWrapper) { 15021 var wrapped = value; 15022 if (this.__actions__.length) { 15023 wrapped = new LazyWrapper(this); 15024 } 15025 wrapped = wrapped.reverse(); 15026 wrapped.__actions__.push({ 15027 'func': thru, 15028 'args': [reverse], 15029 'thisArg': undefined$1 15030 }); 15031 return new LodashWrapper(wrapped, this.__chain__); 15032 } 15033 return this.thru(reverse); 15034 } 15035 15036 /** 15037 * Executes the chain sequence to resolve the unwrapped value. 15038 * 15039 * @name value 15040 * @memberOf _ 15041 * @since 0.1.0 15042 * @alias toJSON, valueOf 15043 * @category Seq 15044 * @returns {*} Returns the resolved unwrapped value. 15045 * @example 15046 * 15047 * _([1, 2, 3]).value(); 15048 * // => [1, 2, 3] 15049 */ 15050 function wrapperValue() { 15051 return baseWrapperValue(this.__wrapped__, this.__actions__); 15052 } 15053 15054 /*------------------------------------------------------------------------*/ 15055 15056 /** 15057 * Creates an object composed of keys generated from the results of running 15058 * each element of `collection` thru `iteratee`. The corresponding value of 15059 * each key is the number of times the key was returned by `iteratee`. The 15060 * iteratee is invoked with one argument: (value). 15061 * 15062 * @static 15063 * @memberOf _ 15064 * @since 0.5.0 15065 * @category Collection 15066 * @param {Array|Object} collection The collection to iterate over. 15067 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 15068 * @returns {Object} Returns the composed aggregate object. 15069 * @example 15070 * 15071 * _.countBy([6.1, 4.2, 6.3], Math.floor); 15072 * // => { '4': 1, '6': 2 } 15073 * 15074 * // The `_.property` iteratee shorthand. 15075 * _.countBy(['one', 'two', 'three'], 'length'); 15076 * // => { '3': 2, '5': 1 } 15077 */ 15078 var countBy = createAggregator(function(result, value, key) { 15079 if (hasOwnProperty.call(result, key)) { 15080 ++result[key]; 15081 } else { 15082 baseAssignValue(result, key, 1); 15083 } 15084 }); 15085 15086 /** 15087 * Checks if `predicate` returns truthy for **all** elements of `collection`. 15088 * Iteration is stopped once `predicate` returns falsey. The predicate is 15089 * invoked with three arguments: (value, index|key, collection). 15090 * 15091 * **Note:** This method returns `true` for 15092 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because 15093 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of 15094 * elements of empty collections. 15095 * 15096 * @static 15097 * @memberOf _ 15098 * @since 0.1.0 15099 * @category Collection 15100 * @param {Array|Object} collection The collection to iterate over. 15101 * @param {Function} [predicate=_.identity] The function invoked per iteration. 15102 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 15103 * @returns {boolean} Returns `true` if all elements pass the predicate check, 15104 * else `false`. 15105 * @example 15106 * 15107 * _.every([true, 1, null, 'yes'], Boolean); 15108 * // => false 15109 * 15110 * var users = [ 15111 * { 'user': 'barney', 'age': 36, 'active': false }, 15112 * { 'user': 'fred', 'age': 40, 'active': false } 15113 * ]; 15114 * 15115 * // The `_.matches` iteratee shorthand. 15116 * _.every(users, { 'user': 'barney', 'active': false }); 15117 * // => false 15118 * 15119 * // The `_.matchesProperty` iteratee shorthand. 15120 * _.every(users, ['active', false]); 15121 * // => true 15122 * 15123 * // The `_.property` iteratee shorthand. 15124 * _.every(users, 'active'); 15125 * // => false 15126 */ 15127 function every(collection, predicate, guard) { 15128 var func = isArray(collection) ? arrayEvery : baseEvery; 15129 if (guard && isIterateeCall(collection, predicate, guard)) { 15130 predicate = undefined$1; 15131 } 15132 return func(collection, getIteratee(predicate, 3)); 15133 } 15134 15135 /** 15136 * Iterates over elements of `collection`, returning an array of all elements 15137 * `predicate` returns truthy for. The predicate is invoked with three 15138 * arguments: (value, index|key, collection). 15139 * 15140 * **Note:** Unlike `_.remove`, this method returns a new array. 15141 * 15142 * @static 15143 * @memberOf _ 15144 * @since 0.1.0 15145 * @category Collection 15146 * @param {Array|Object} collection The collection to iterate over. 15147 * @param {Function} [predicate=_.identity] The function invoked per iteration. 15148 * @returns {Array} Returns the new filtered array. 15149 * @see _.reject 15150 * @example 15151 * 15152 * var users = [ 15153 * { 'user': 'barney', 'age': 36, 'active': true }, 15154 * { 'user': 'fred', 'age': 40, 'active': false } 15155 * ]; 15156 * 15157 * _.filter(users, function(o) { return !o.active; }); 15158 * // => objects for ['fred'] 15159 * 15160 * // The `_.matches` iteratee shorthand. 15161 * _.filter(users, { 'age': 36, 'active': true }); 15162 * // => objects for ['barney'] 15163 * 15164 * // The `_.matchesProperty` iteratee shorthand. 15165 * _.filter(users, ['active', false]); 15166 * // => objects for ['fred'] 15167 * 15168 * // The `_.property` iteratee shorthand. 15169 * _.filter(users, 'active'); 15170 * // => objects for ['barney'] 15171 * 15172 * // Combining several predicates using `_.overEvery` or `_.overSome`. 15173 * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]])); 15174 * // => objects for ['fred', 'barney'] 15175 */ 15176 function filter(collection, predicate) { 15177 var func = isArray(collection) ? arrayFilter : baseFilter; 15178 return func(collection, getIteratee(predicate, 3)); 15179 } 15180 15181 /** 15182 * Iterates over elements of `collection`, returning the first element 15183 * `predicate` returns truthy for. The predicate is invoked with three 15184 * arguments: (value, index|key, collection). 15185 * 15186 * @static 15187 * @memberOf _ 15188 * @since 0.1.0 15189 * @category Collection 15190 * @param {Array|Object} collection The collection to inspect. 15191 * @param {Function} [predicate=_.identity] The function invoked per iteration. 15192 * @param {number} [fromIndex=0] The index to search from. 15193 * @returns {*} Returns the matched element, else `undefined`. 15194 * @example 15195 * 15196 * var users = [ 15197 * { 'user': 'barney', 'age': 36, 'active': true }, 15198 * { 'user': 'fred', 'age': 40, 'active': false }, 15199 * { 'user': 'pebbles', 'age': 1, 'active': true } 15200 * ]; 15201 * 15202 * _.find(users, function(o) { return o.age < 40; }); 15203 * // => object for 'barney' 15204 * 15205 * // The `_.matches` iteratee shorthand. 15206 * _.find(users, { 'age': 1, 'active': true }); 15207 * // => object for 'pebbles' 15208 * 15209 * // The `_.matchesProperty` iteratee shorthand. 15210 * _.find(users, ['active', false]); 15211 * // => object for 'fred' 15212 * 15213 * // The `_.property` iteratee shorthand. 15214 * _.find(users, 'active'); 15215 * // => object for 'barney' 15216 */ 15217 var find = createFind(findIndex); 15218 15219 /** 15220 * This method is like `_.find` except that it iterates over elements of 15221 * `collection` from right to left. 15222 * 15223 * @static 15224 * @memberOf _ 15225 * @since 2.0.0 15226 * @category Collection 15227 * @param {Array|Object} collection The collection to inspect. 15228 * @param {Function} [predicate=_.identity] The function invoked per iteration. 15229 * @param {number} [fromIndex=collection.length-1] The index to search from. 15230 * @returns {*} Returns the matched element, else `undefined`. 15231 * @example 15232 * 15233 * _.findLast([1, 2, 3, 4], function(n) { 15234 * return n % 2 == 1; 15235 * }); 15236 * // => 3 15237 */ 15238 var findLast = createFind(findLastIndex); 15239 15240 /** 15241 * Creates a flattened array of values by running each element in `collection` 15242 * thru `iteratee` and flattening the mapped results. The iteratee is invoked 15243 * with three arguments: (value, index|key, collection). 15244 * 15245 * @static 15246 * @memberOf _ 15247 * @since 4.0.0 15248 * @category Collection 15249 * @param {Array|Object} collection The collection to iterate over. 15250 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15251 * @returns {Array} Returns the new flattened array. 15252 * @example 15253 * 15254 * function duplicate(n) { 15255 * return [n, n]; 15256 * } 15257 * 15258 * _.flatMap([1, 2], duplicate); 15259 * // => [1, 1, 2, 2] 15260 */ 15261 function flatMap(collection, iteratee) { 15262 return baseFlatten(map(collection, iteratee), 1); 15263 } 15264 15265 /** 15266 * This method is like `_.flatMap` except that it recursively flattens the 15267 * mapped results. 15268 * 15269 * @static 15270 * @memberOf _ 15271 * @since 4.7.0 15272 * @category Collection 15273 * @param {Array|Object} collection The collection to iterate over. 15274 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15275 * @returns {Array} Returns the new flattened array. 15276 * @example 15277 * 15278 * function duplicate(n) { 15279 * return [[[n, n]]]; 15280 * } 15281 * 15282 * _.flatMapDeep([1, 2], duplicate); 15283 * // => [1, 1, 2, 2] 15284 */ 15285 function flatMapDeep(collection, iteratee) { 15286 return baseFlatten(map(collection, iteratee), INFINITY); 15287 } 15288 15289 /** 15290 * This method is like `_.flatMap` except that it recursively flattens the 15291 * mapped results up to `depth` times. 15292 * 15293 * @static 15294 * @memberOf _ 15295 * @since 4.7.0 15296 * @category Collection 15297 * @param {Array|Object} collection The collection to iterate over. 15298 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15299 * @param {number} [depth=1] The maximum recursion depth. 15300 * @returns {Array} Returns the new flattened array. 15301 * @example 15302 * 15303 * function duplicate(n) { 15304 * return [[[n, n]]]; 15305 * } 15306 * 15307 * _.flatMapDepth([1, 2], duplicate, 2); 15308 * // => [[1, 1], [2, 2]] 15309 */ 15310 function flatMapDepth(collection, iteratee, depth) { 15311 depth = depth === undefined$1 ? 1 : toInteger(depth); 15312 return baseFlatten(map(collection, iteratee), depth); 15313 } 15314 15315 /** 15316 * Iterates over elements of `collection` and invokes `iteratee` for each element. 15317 * The iteratee is invoked with three arguments: (value, index|key, collection). 15318 * Iteratee functions may exit iteration early by explicitly returning `false`. 15319 * 15320 * **Note:** As with other "Collections" methods, objects with a "length" 15321 * property are iterated like arrays. To avoid this behavior use `_.forIn` 15322 * or `_.forOwn` for object iteration. 15323 * 15324 * @static 15325 * @memberOf _ 15326 * @since 0.1.0 15327 * @alias each 15328 * @category Collection 15329 * @param {Array|Object} collection The collection to iterate over. 15330 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15331 * @returns {Array|Object} Returns `collection`. 15332 * @see _.forEachRight 15333 * @example 15334 * 15335 * _.forEach([1, 2], function(value) { 15336 * console.log(value); 15337 * }); 15338 * // => Logs `1` then `2`. 15339 * 15340 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { 15341 * console.log(key); 15342 * }); 15343 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 15344 */ 15345 function forEach(collection, iteratee) { 15346 var func = isArray(collection) ? arrayEach : baseEach; 15347 return func(collection, getIteratee(iteratee, 3)); 15348 } 15349 15350 /** 15351 * This method is like `_.forEach` except that it iterates over elements of 15352 * `collection` from right to left. 15353 * 15354 * @static 15355 * @memberOf _ 15356 * @since 2.0.0 15357 * @alias eachRight 15358 * @category Collection 15359 * @param {Array|Object} collection The collection to iterate over. 15360 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15361 * @returns {Array|Object} Returns `collection`. 15362 * @see _.forEach 15363 * @example 15364 * 15365 * _.forEachRight([1, 2], function(value) { 15366 * console.log(value); 15367 * }); 15368 * // => Logs `2` then `1`. 15369 */ 15370 function forEachRight(collection, iteratee) { 15371 var func = isArray(collection) ? arrayEachRight : baseEachRight; 15372 return func(collection, getIteratee(iteratee, 3)); 15373 } 15374 15375 /** 15376 * Creates an object composed of keys generated from the results of running 15377 * each element of `collection` thru `iteratee`. The order of grouped values 15378 * is determined by the order they occur in `collection`. The corresponding 15379 * value of each key is an array of elements responsible for generating the 15380 * key. The iteratee is invoked with one argument: (value). 15381 * 15382 * @static 15383 * @memberOf _ 15384 * @since 0.1.0 15385 * @category Collection 15386 * @param {Array|Object} collection The collection to iterate over. 15387 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 15388 * @returns {Object} Returns the composed aggregate object. 15389 * @example 15390 * 15391 * _.groupBy([6.1, 4.2, 6.3], Math.floor); 15392 * // => { '4': [4.2], '6': [6.1, 6.3] } 15393 * 15394 * // The `_.property` iteratee shorthand. 15395 * _.groupBy(['one', 'two', 'three'], 'length'); 15396 * // => { '3': ['one', 'two'], '5': ['three'] } 15397 */ 15398 var groupBy = createAggregator(function(result, value, key) { 15399 if (hasOwnProperty.call(result, key)) { 15400 result[key].push(value); 15401 } else { 15402 baseAssignValue(result, key, [value]); 15403 } 15404 }); 15405 15406 /** 15407 * Checks if `value` is in `collection`. If `collection` is a string, it's 15408 * checked for a substring of `value`, otherwise 15409 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 15410 * is used for equality comparisons. If `fromIndex` is negative, it's used as 15411 * the offset from the end of `collection`. 15412 * 15413 * @static 15414 * @memberOf _ 15415 * @since 0.1.0 15416 * @category Collection 15417 * @param {Array|Object|string} collection The collection to inspect. 15418 * @param {*} value The value to search for. 15419 * @param {number} [fromIndex=0] The index to search from. 15420 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 15421 * @returns {boolean} Returns `true` if `value` is found, else `false`. 15422 * @example 15423 * 15424 * _.includes([1, 2, 3], 1); 15425 * // => true 15426 * 15427 * _.includes([1, 2, 3], 1, 2); 15428 * // => false 15429 * 15430 * _.includes({ 'a': 1, 'b': 2 }, 1); 15431 * // => true 15432 * 15433 * _.includes('abcd', 'bc'); 15434 * // => true 15435 */ 15436 function includes(collection, value, fromIndex, guard) { 15437 collection = isArrayLike(collection) ? collection : values(collection); 15438 fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0; 15439 15440 var length = collection.length; 15441 if (fromIndex < 0) { 15442 fromIndex = nativeMax(length + fromIndex, 0); 15443 } 15444 return isString(collection) 15445 ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1) 15446 : (!!length && baseIndexOf(collection, value, fromIndex) > -1); 15447 } 15448 15449 /** 15450 * Invokes the method at `path` of each element in `collection`, returning 15451 * an array of the results of each invoked method. Any additional arguments 15452 * are provided to each invoked method. If `path` is a function, it's invoked 15453 * for, and `this` bound to, each element in `collection`. 15454 * 15455 * @static 15456 * @memberOf _ 15457 * @since 4.0.0 15458 * @category Collection 15459 * @param {Array|Object} collection The collection to iterate over. 15460 * @param {Array|Function|string} path The path of the method to invoke or 15461 * the function invoked per iteration. 15462 * @param {...*} [args] The arguments to invoke each method with. 15463 * @returns {Array} Returns the array of results. 15464 * @example 15465 * 15466 * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); 15467 * // => [[1, 5, 7], [1, 2, 3]] 15468 * 15469 * _.invokeMap([123, 456], String.prototype.split, ''); 15470 * // => [['1', '2', '3'], ['4', '5', '6']] 15471 */ 15472 var invokeMap = baseRest(function(collection, path, args) { 15473 var index = -1, 15474 isFunc = typeof path == 'function', 15475 result = isArrayLike(collection) ? Array(collection.length) : []; 15476 15477 baseEach(collection, function(value) { 15478 result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args); 15479 }); 15480 return result; 15481 }); 15482 15483 /** 15484 * Creates an object composed of keys generated from the results of running 15485 * each element of `collection` thru `iteratee`. The corresponding value of 15486 * each key is the last element responsible for generating the key. The 15487 * iteratee is invoked with one argument: (value). 15488 * 15489 * @static 15490 * @memberOf _ 15491 * @since 4.0.0 15492 * @category Collection 15493 * @param {Array|Object} collection The collection to iterate over. 15494 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 15495 * @returns {Object} Returns the composed aggregate object. 15496 * @example 15497 * 15498 * var array = [ 15499 * { 'dir': 'left', 'code': 97 }, 15500 * { 'dir': 'right', 'code': 100 } 15501 * ]; 15502 * 15503 * _.keyBy(array, function(o) { 15504 * return String.fromCharCode(o.code); 15505 * }); 15506 * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } 15507 * 15508 * _.keyBy(array, 'dir'); 15509 * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } 15510 */ 15511 var keyBy = createAggregator(function(result, value, key) { 15512 baseAssignValue(result, key, value); 15513 }); 15514 15515 /** 15516 * Creates an array of values by running each element in `collection` thru 15517 * `iteratee`. The iteratee is invoked with three arguments: 15518 * (value, index|key, collection). 15519 * 15520 * Many lodash methods are guarded to work as iteratees for methods like 15521 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. 15522 * 15523 * The guarded methods are: 15524 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, 15525 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, 15526 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, 15527 * `template`, `trim`, `trimEnd`, `trimStart`, and `words` 15528 * 15529 * @static 15530 * @memberOf _ 15531 * @since 0.1.0 15532 * @category Collection 15533 * @param {Array|Object} collection The collection to iterate over. 15534 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15535 * @returns {Array} Returns the new mapped array. 15536 * @example 15537 * 15538 * function square(n) { 15539 * return n * n; 15540 * } 15541 * 15542 * _.map([4, 8], square); 15543 * // => [16, 64] 15544 * 15545 * _.map({ 'a': 4, 'b': 8 }, square); 15546 * // => [16, 64] (iteration order is not guaranteed) 15547 * 15548 * var users = [ 15549 * { 'user': 'barney' }, 15550 * { 'user': 'fred' } 15551 * ]; 15552 * 15553 * // The `_.property` iteratee shorthand. 15554 * _.map(users, 'user'); 15555 * // => ['barney', 'fred'] 15556 */ 15557 function map(collection, iteratee) { 15558 var func = isArray(collection) ? arrayMap : baseMap; 15559 return func(collection, getIteratee(iteratee, 3)); 15560 } 15561 15562 /** 15563 * This method is like `_.sortBy` except that it allows specifying the sort 15564 * orders of the iteratees to sort by. If `orders` is unspecified, all values 15565 * are sorted in ascending order. Otherwise, specify an order of "desc" for 15566 * descending or "asc" for ascending sort order of corresponding values. 15567 * 15568 * @static 15569 * @memberOf _ 15570 * @since 4.0.0 15571 * @category Collection 15572 * @param {Array|Object} collection The collection to iterate over. 15573 * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]] 15574 * The iteratees to sort by. 15575 * @param {string[]} [orders] The sort orders of `iteratees`. 15576 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 15577 * @returns {Array} Returns the new sorted array. 15578 * @example 15579 * 15580 * var users = [ 15581 * { 'user': 'fred', 'age': 48 }, 15582 * { 'user': 'barney', 'age': 34 }, 15583 * { 'user': 'fred', 'age': 40 }, 15584 * { 'user': 'barney', 'age': 36 } 15585 * ]; 15586 * 15587 * // Sort by `user` in ascending order and by `age` in descending order. 15588 * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); 15589 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] 15590 */ 15591 function orderBy(collection, iteratees, orders, guard) { 15592 if (collection == null) { 15593 return []; 15594 } 15595 if (!isArray(iteratees)) { 15596 iteratees = iteratees == null ? [] : [iteratees]; 15597 } 15598 orders = guard ? undefined$1 : orders; 15599 if (!isArray(orders)) { 15600 orders = orders == null ? [] : [orders]; 15601 } 15602 return baseOrderBy(collection, iteratees, orders); 15603 } 15604 15605 /** 15606 * Creates an array of elements split into two groups, the first of which 15607 * contains elements `predicate` returns truthy for, the second of which 15608 * contains elements `predicate` returns falsey for. The predicate is 15609 * invoked with one argument: (value). 15610 * 15611 * @static 15612 * @memberOf _ 15613 * @since 3.0.0 15614 * @category Collection 15615 * @param {Array|Object} collection The collection to iterate over. 15616 * @param {Function} [predicate=_.identity] The function invoked per iteration. 15617 * @returns {Array} Returns the array of grouped elements. 15618 * @example 15619 * 15620 * var users = [ 15621 * { 'user': 'barney', 'age': 36, 'active': false }, 15622 * { 'user': 'fred', 'age': 40, 'active': true }, 15623 * { 'user': 'pebbles', 'age': 1, 'active': false } 15624 * ]; 15625 * 15626 * _.partition(users, function(o) { return o.active; }); 15627 * // => objects for [['fred'], ['barney', 'pebbles']] 15628 * 15629 * // The `_.matches` iteratee shorthand. 15630 * _.partition(users, { 'age': 1, 'active': false }); 15631 * // => objects for [['pebbles'], ['barney', 'fred']] 15632 * 15633 * // The `_.matchesProperty` iteratee shorthand. 15634 * _.partition(users, ['active', false]); 15635 * // => objects for [['barney', 'pebbles'], ['fred']] 15636 * 15637 * // The `_.property` iteratee shorthand. 15638 * _.partition(users, 'active'); 15639 * // => objects for [['fred'], ['barney', 'pebbles']] 15640 */ 15641 var partition = createAggregator(function(result, value, key) { 15642 result[key ? 0 : 1].push(value); 15643 }, function() { return [[], []]; }); 15644 15645 /** 15646 * Reduces `collection` to a value which is the accumulated result of running 15647 * each element in `collection` thru `iteratee`, where each successive 15648 * invocation is supplied the return value of the previous. If `accumulator` 15649 * is not given, the first element of `collection` is used as the initial 15650 * value. The iteratee is invoked with four arguments: 15651 * (accumulator, value, index|key, collection). 15652 * 15653 * Many lodash methods are guarded to work as iteratees for methods like 15654 * `_.reduce`, `_.reduceRight`, and `_.transform`. 15655 * 15656 * The guarded methods are: 15657 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, 15658 * and `sortBy` 15659 * 15660 * @static 15661 * @memberOf _ 15662 * @since 0.1.0 15663 * @category Collection 15664 * @param {Array|Object} collection The collection to iterate over. 15665 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15666 * @param {*} [accumulator] The initial value. 15667 * @returns {*} Returns the accumulated value. 15668 * @see _.reduceRight 15669 * @example 15670 * 15671 * _.reduce([1, 2], function(sum, n) { 15672 * return sum + n; 15673 * }, 0); 15674 * // => 3 15675 * 15676 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 15677 * (result[value] || (result[value] = [])).push(key); 15678 * return result; 15679 * }, {}); 15680 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) 15681 */ 15682 function reduce(collection, iteratee, accumulator) { 15683 var func = isArray(collection) ? arrayReduce : baseReduce, 15684 initAccum = arguments.length < 3; 15685 15686 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach); 15687 } 15688 15689 /** 15690 * This method is like `_.reduce` except that it iterates over elements of 15691 * `collection` from right to left. 15692 * 15693 * @static 15694 * @memberOf _ 15695 * @since 0.1.0 15696 * @category Collection 15697 * @param {Array|Object} collection The collection to iterate over. 15698 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15699 * @param {*} [accumulator] The initial value. 15700 * @returns {*} Returns the accumulated value. 15701 * @see _.reduce 15702 * @example 15703 * 15704 * var array = [[0, 1], [2, 3], [4, 5]]; 15705 * 15706 * _.reduceRight(array, function(flattened, other) { 15707 * return flattened.concat(other); 15708 * }, []); 15709 * // => [4, 5, 2, 3, 0, 1] 15710 */ 15711 function reduceRight(collection, iteratee, accumulator) { 15712 var func = isArray(collection) ? arrayReduceRight : baseReduce, 15713 initAccum = arguments.length < 3; 15714 15715 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); 15716 } 15717 15718 /** 15719 * The opposite of `_.filter`; this method returns the elements of `collection` 15720 * that `predicate` does **not** return truthy for. 15721 * 15722 * @static 15723 * @memberOf _ 15724 * @since 0.1.0 15725 * @category Collection 15726 * @param {Array|Object} collection The collection to iterate over. 15727 * @param {Function} [predicate=_.identity] The function invoked per iteration. 15728 * @returns {Array} Returns the new filtered array. 15729 * @see _.filter 15730 * @example 15731 * 15732 * var users = [ 15733 * { 'user': 'barney', 'age': 36, 'active': false }, 15734 * { 'user': 'fred', 'age': 40, 'active': true } 15735 * ]; 15736 * 15737 * _.reject(users, function(o) { return !o.active; }); 15738 * // => objects for ['fred'] 15739 * 15740 * // The `_.matches` iteratee shorthand. 15741 * _.reject(users, { 'age': 40, 'active': true }); 15742 * // => objects for ['barney'] 15743 * 15744 * // The `_.matchesProperty` iteratee shorthand. 15745 * _.reject(users, ['active', false]); 15746 * // => objects for ['fred'] 15747 * 15748 * // The `_.property` iteratee shorthand. 15749 * _.reject(users, 'active'); 15750 * // => objects for ['barney'] 15751 */ 15752 function reject(collection, predicate) { 15753 var func = isArray(collection) ? arrayFilter : baseFilter; 15754 return func(collection, negate(getIteratee(predicate, 3))); 15755 } 15756 15757 /** 15758 * Gets a random element from `collection`. 15759 * 15760 * @static 15761 * @memberOf _ 15762 * @since 2.0.0 15763 * @category Collection 15764 * @param {Array|Object} collection The collection to sample. 15765 * @returns {*} Returns the random element. 15766 * @example 15767 * 15768 * _.sample([1, 2, 3, 4]); 15769 * // => 2 15770 */ 15771 function sample(collection) { 15772 var func = isArray(collection) ? arraySample : baseSample; 15773 return func(collection); 15774 } 15775 15776 /** 15777 * Gets `n` random elements at unique keys from `collection` up to the 15778 * size of `collection`. 15779 * 15780 * @static 15781 * @memberOf _ 15782 * @since 4.0.0 15783 * @category Collection 15784 * @param {Array|Object} collection The collection to sample. 15785 * @param {number} [n=1] The number of elements to sample. 15786 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 15787 * @returns {Array} Returns the random elements. 15788 * @example 15789 * 15790 * _.sampleSize([1, 2, 3], 2); 15791 * // => [3, 1] 15792 * 15793 * _.sampleSize([1, 2, 3], 4); 15794 * // => [2, 3, 1] 15795 */ 15796 function sampleSize(collection, n, guard) { 15797 if ((guard ? isIterateeCall(collection, n, guard) : n === undefined$1)) { 15798 n = 1; 15799 } else { 15800 n = toInteger(n); 15801 } 15802 var func = isArray(collection) ? arraySampleSize : baseSampleSize; 15803 return func(collection, n); 15804 } 15805 15806 /** 15807 * Creates an array of shuffled values, using a version of the 15808 * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). 15809 * 15810 * @static 15811 * @memberOf _ 15812 * @since 0.1.0 15813 * @category Collection 15814 * @param {Array|Object} collection The collection to shuffle. 15815 * @returns {Array} Returns the new shuffled array. 15816 * @example 15817 * 15818 * _.shuffle([1, 2, 3, 4]); 15819 * // => [4, 1, 3, 2] 15820 */ 15821 function shuffle(collection) { 15822 var func = isArray(collection) ? arrayShuffle : baseShuffle; 15823 return func(collection); 15824 } 15825 15826 /** 15827 * Gets the size of `collection` by returning its length for array-like 15828 * values or the number of own enumerable string keyed properties for objects. 15829 * 15830 * @static 15831 * @memberOf _ 15832 * @since 0.1.0 15833 * @category Collection 15834 * @param {Array|Object|string} collection The collection to inspect. 15835 * @returns {number} Returns the collection size. 15836 * @example 15837 * 15838 * _.size([1, 2, 3]); 15839 * // => 3 15840 * 15841 * _.size({ 'a': 1, 'b': 2 }); 15842 * // => 2 15843 * 15844 * _.size('pebbles'); 15845 * // => 7 15846 */ 15847 function size(collection) { 15848 if (collection == null) { 15849 return 0; 15850 } 15851 if (isArrayLike(collection)) { 15852 return isString(collection) ? stringSize(collection) : collection.length; 15853 } 15854 var tag = getTag(collection); 15855 if (tag == mapTag || tag == setTag) { 15856 return collection.size; 15857 } 15858 return baseKeys(collection).length; 15859 } 15860 15861 /** 15862 * Checks if `predicate` returns truthy for **any** element of `collection`. 15863 * Iteration is stopped once `predicate` returns truthy. The predicate is 15864 * invoked with three arguments: (value, index|key, collection). 15865 * 15866 * @static 15867 * @memberOf _ 15868 * @since 0.1.0 15869 * @category Collection 15870 * @param {Array|Object} collection The collection to iterate over. 15871 * @param {Function} [predicate=_.identity] The function invoked per iteration. 15872 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 15873 * @returns {boolean} Returns `true` if any element passes the predicate check, 15874 * else `false`. 15875 * @example 15876 * 15877 * _.some([null, 0, 'yes', false], Boolean); 15878 * // => true 15879 * 15880 * var users = [ 15881 * { 'user': 'barney', 'active': true }, 15882 * { 'user': 'fred', 'active': false } 15883 * ]; 15884 * 15885 * // The `_.matches` iteratee shorthand. 15886 * _.some(users, { 'user': 'barney', 'active': false }); 15887 * // => false 15888 * 15889 * // The `_.matchesProperty` iteratee shorthand. 15890 * _.some(users, ['active', false]); 15891 * // => true 15892 * 15893 * // The `_.property` iteratee shorthand. 15894 * _.some(users, 'active'); 15895 * // => true 15896 */ 15897 function some(collection, predicate, guard) { 15898 var func = isArray(collection) ? arraySome : baseSome; 15899 if (guard && isIterateeCall(collection, predicate, guard)) { 15900 predicate = undefined$1; 15901 } 15902 return func(collection, getIteratee(predicate, 3)); 15903 } 15904 15905 /** 15906 * Creates an array of elements, sorted in ascending order by the results of 15907 * running each element in a collection thru each iteratee. This method 15908 * performs a stable sort, that is, it preserves the original sort order of 15909 * equal elements. The iteratees are invoked with one argument: (value). 15910 * 15911 * @static 15912 * @memberOf _ 15913 * @since 0.1.0 15914 * @category Collection 15915 * @param {Array|Object} collection The collection to iterate over. 15916 * @param {...(Function|Function[])} [iteratees=[_.identity]] 15917 * The iteratees to sort by. 15918 * @returns {Array} Returns the new sorted array. 15919 * @example 15920 * 15921 * var users = [ 15922 * { 'user': 'fred', 'age': 48 }, 15923 * { 'user': 'barney', 'age': 36 }, 15924 * { 'user': 'fred', 'age': 30 }, 15925 * { 'user': 'barney', 'age': 34 } 15926 * ]; 15927 * 15928 * _.sortBy(users, [function(o) { return o.user; }]); 15929 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]] 15930 * 15931 * _.sortBy(users, ['user', 'age']); 15932 * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]] 15933 */ 15934 var sortBy = baseRest(function(collection, iteratees) { 15935 if (collection == null) { 15936 return []; 15937 } 15938 var length = iteratees.length; 15939 if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { 15940 iteratees = []; 15941 } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { 15942 iteratees = [iteratees[0]]; 15943 } 15944 return baseOrderBy(collection, baseFlatten(iteratees, 1), []); 15945 }); 15946 15947 /*------------------------------------------------------------------------*/ 15948 15949 /** 15950 * Gets the timestamp of the number of milliseconds that have elapsed since 15951 * the Unix epoch (1 January 1970 00:00:00 UTC). 15952 * 15953 * @static 15954 * @memberOf _ 15955 * @since 2.4.0 15956 * @category Date 15957 * @returns {number} Returns the timestamp. 15958 * @example 15959 * 15960 * _.defer(function(stamp) { 15961 * console.log(_.now() - stamp); 15962 * }, _.now()); 15963 * // => Logs the number of milliseconds it took for the deferred invocation. 15964 */ 15965 var now = ctxNow || function() { 15966 return root.Date.now(); 15967 }; 15968 15969 /*------------------------------------------------------------------------*/ 15970 15971 /** 15972 * The opposite of `_.before`; this method creates a function that invokes 15973 * `func` once it's called `n` or more times. 15974 * 15975 * @static 15976 * @memberOf _ 15977 * @since 0.1.0 15978 * @category Function 15979 * @param {number} n The number of calls before `func` is invoked. 15980 * @param {Function} func The function to restrict. 15981 * @returns {Function} Returns the new restricted function. 15982 * @example 15983 * 15984 * var saves = ['profile', 'settings']; 15985 * 15986 * var done = _.after(saves.length, function() { 15987 * console.log('done saving!'); 15988 * }); 15989 * 15990 * _.forEach(saves, function(type) { 15991 * asyncSave({ 'type': type, 'complete': done }); 15992 * }); 15993 * // => Logs 'done saving!' after the two async saves have completed. 15994 */ 15995 function after(n, func) { 15996 if (typeof func != 'function') { 15997 throw new TypeError(FUNC_ERROR_TEXT); 15998 } 15999 n = toInteger(n); 16000 return function() { 16001 if (--n < 1) { 16002 return func.apply(this, arguments); 16003 } 16004 }; 16005 } 16006 16007 /** 16008 * Creates a function that invokes `func`, with up to `n` arguments, 16009 * ignoring any additional arguments. 16010 * 16011 * @static 16012 * @memberOf _ 16013 * @since 3.0.0 16014 * @category Function 16015 * @param {Function} func The function to cap arguments for. 16016 * @param {number} [n=func.length] The arity cap. 16017 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16018 * @returns {Function} Returns the new capped function. 16019 * @example 16020 * 16021 * _.map(['6', '8', '10'], _.ary(parseInt, 1)); 16022 * // => [6, 8, 10] 16023 */ 16024 function ary(func, n, guard) { 16025 n = guard ? undefined$1 : n; 16026 n = (func && n == null) ? func.length : n; 16027 return createWrap(func, WRAP_ARY_FLAG, undefined$1, undefined$1, undefined$1, undefined$1, n); 16028 } 16029 16030 /** 16031 * Creates a function that invokes `func`, with the `this` binding and arguments 16032 * of the created function, while it's called less than `n` times. Subsequent 16033 * calls to the created function return the result of the last `func` invocation. 16034 * 16035 * @static 16036 * @memberOf _ 16037 * @since 3.0.0 16038 * @category Function 16039 * @param {number} n The number of calls at which `func` is no longer invoked. 16040 * @param {Function} func The function to restrict. 16041 * @returns {Function} Returns the new restricted function. 16042 * @example 16043 * 16044 * jQuery(element).on('click', _.before(5, addContactToList)); 16045 * // => Allows adding up to 4 contacts to the list. 16046 */ 16047 function before(n, func) { 16048 var result; 16049 if (typeof func != 'function') { 16050 throw new TypeError(FUNC_ERROR_TEXT); 16051 } 16052 n = toInteger(n); 16053 return function() { 16054 if (--n > 0) { 16055 result = func.apply(this, arguments); 16056 } 16057 if (n <= 1) { 16058 func = undefined$1; 16059 } 16060 return result; 16061 }; 16062 } 16063 16064 /** 16065 * Creates a function that invokes `func` with the `this` binding of `thisArg` 16066 * and `partials` prepended to the arguments it receives. 16067 * 16068 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, 16069 * may be used as a placeholder for partially applied arguments. 16070 * 16071 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length" 16072 * property of bound functions. 16073 * 16074 * @static 16075 * @memberOf _ 16076 * @since 0.1.0 16077 * @category Function 16078 * @param {Function} func The function to bind. 16079 * @param {*} thisArg The `this` binding of `func`. 16080 * @param {...*} [partials] The arguments to be partially applied. 16081 * @returns {Function} Returns the new bound function. 16082 * @example 16083 * 16084 * function greet(greeting, punctuation) { 16085 * return greeting + ' ' + this.user + punctuation; 16086 * } 16087 * 16088 * var object = { 'user': 'fred' }; 16089 * 16090 * var bound = _.bind(greet, object, 'hi'); 16091 * bound('!'); 16092 * // => 'hi fred!' 16093 * 16094 * // Bound with placeholders. 16095 * var bound = _.bind(greet, object, _, '!'); 16096 * bound('hi'); 16097 * // => 'hi fred!' 16098 */ 16099 var bind = baseRest(function(func, thisArg, partials) { 16100 var bitmask = WRAP_BIND_FLAG; 16101 if (partials.length) { 16102 var holders = replaceHolders(partials, getHolder(bind)); 16103 bitmask |= WRAP_PARTIAL_FLAG; 16104 } 16105 return createWrap(func, bitmask, thisArg, partials, holders); 16106 }); 16107 16108 /** 16109 * Creates a function that invokes the method at `object[key]` with `partials` 16110 * prepended to the arguments it receives. 16111 * 16112 * This method differs from `_.bind` by allowing bound functions to reference 16113 * methods that may be redefined or don't yet exist. See 16114 * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) 16115 * for more details. 16116 * 16117 * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic 16118 * builds, may be used as a placeholder for partially applied arguments. 16119 * 16120 * @static 16121 * @memberOf _ 16122 * @since 0.10.0 16123 * @category Function 16124 * @param {Object} object The object to invoke the method on. 16125 * @param {string} key The key of the method. 16126 * @param {...*} [partials] The arguments to be partially applied. 16127 * @returns {Function} Returns the new bound function. 16128 * @example 16129 * 16130 * var object = { 16131 * 'user': 'fred', 16132 * 'greet': function(greeting, punctuation) { 16133 * return greeting + ' ' + this.user + punctuation; 16134 * } 16135 * }; 16136 * 16137 * var bound = _.bindKey(object, 'greet', 'hi'); 16138 * bound('!'); 16139 * // => 'hi fred!' 16140 * 16141 * object.greet = function(greeting, punctuation) { 16142 * return greeting + 'ya ' + this.user + punctuation; 16143 * }; 16144 * 16145 * bound('!'); 16146 * // => 'hiya fred!' 16147 * 16148 * // Bound with placeholders. 16149 * var bound = _.bindKey(object, 'greet', _, '!'); 16150 * bound('hi'); 16151 * // => 'hiya fred!' 16152 */ 16153 var bindKey = baseRest(function(object, key, partials) { 16154 var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG; 16155 if (partials.length) { 16156 var holders = replaceHolders(partials, getHolder(bindKey)); 16157 bitmask |= WRAP_PARTIAL_FLAG; 16158 } 16159 return createWrap(key, bitmask, object, partials, holders); 16160 }); 16161 16162 /** 16163 * Creates a function that accepts arguments of `func` and either invokes 16164 * `func` returning its result, if at least `arity` number of arguments have 16165 * been provided, or returns a function that accepts the remaining `func` 16166 * arguments, and so on. The arity of `func` may be specified if `func.length` 16167 * is not sufficient. 16168 * 16169 * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, 16170 * may be used as a placeholder for provided arguments. 16171 * 16172 * **Note:** This method doesn't set the "length" property of curried functions. 16173 * 16174 * @static 16175 * @memberOf _ 16176 * @since 2.0.0 16177 * @category Function 16178 * @param {Function} func The function to curry. 16179 * @param {number} [arity=func.length] The arity of `func`. 16180 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16181 * @returns {Function} Returns the new curried function. 16182 * @example 16183 * 16184 * var abc = function(a, b, c) { 16185 * return [a, b, c]; 16186 * }; 16187 * 16188 * var curried = _.curry(abc); 16189 * 16190 * curried(1)(2)(3); 16191 * // => [1, 2, 3] 16192 * 16193 * curried(1, 2)(3); 16194 * // => [1, 2, 3] 16195 * 16196 * curried(1, 2, 3); 16197 * // => [1, 2, 3] 16198 * 16199 * // Curried with placeholders. 16200 * curried(1)(_, 3)(2); 16201 * // => [1, 2, 3] 16202 */ 16203 function curry(func, arity, guard) { 16204 arity = guard ? undefined$1 : arity; 16205 var result = createWrap(func, WRAP_CURRY_FLAG, undefined$1, undefined$1, undefined$1, undefined$1, undefined$1, arity); 16206 result.placeholder = curry.placeholder; 16207 return result; 16208 } 16209 16210 /** 16211 * This method is like `_.curry` except that arguments are applied to `func` 16212 * in the manner of `_.partialRight` instead of `_.partial`. 16213 * 16214 * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic 16215 * builds, may be used as a placeholder for provided arguments. 16216 * 16217 * **Note:** This method doesn't set the "length" property of curried functions. 16218 * 16219 * @static 16220 * @memberOf _ 16221 * @since 3.0.0 16222 * @category Function 16223 * @param {Function} func The function to curry. 16224 * @param {number} [arity=func.length] The arity of `func`. 16225 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16226 * @returns {Function} Returns the new curried function. 16227 * @example 16228 * 16229 * var abc = function(a, b, c) { 16230 * return [a, b, c]; 16231 * }; 16232 * 16233 * var curried = _.curryRight(abc); 16234 * 16235 * curried(3)(2)(1); 16236 * // => [1, 2, 3] 16237 * 16238 * curried(2, 3)(1); 16239 * // => [1, 2, 3] 16240 * 16241 * curried(1, 2, 3); 16242 * // => [1, 2, 3] 16243 * 16244 * // Curried with placeholders. 16245 * curried(3)(1, _)(2); 16246 * // => [1, 2, 3] 16247 */ 16248 function curryRight(func, arity, guard) { 16249 arity = guard ? undefined$1 : arity; 16250 var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined$1, undefined$1, undefined$1, undefined$1, undefined$1, arity); 16251 result.placeholder = curryRight.placeholder; 16252 return result; 16253 } 16254 16255 /** 16256 * Creates a debounced function that delays invoking `func` until after `wait` 16257 * milliseconds have elapsed since the last time the debounced function was 16258 * invoked. The debounced function comes with a `cancel` method to cancel 16259 * delayed `func` invocations and a `flush` method to immediately invoke them. 16260 * Provide `options` to indicate whether `func` should be invoked on the 16261 * leading and/or trailing edge of the `wait` timeout. The `func` is invoked 16262 * with the last arguments provided to the debounced function. Subsequent 16263 * calls to the debounced function return the result of the last `func` 16264 * invocation. 16265 * 16266 * **Note:** If `leading` and `trailing` options are `true`, `func` is 16267 * invoked on the trailing edge of the timeout only if the debounced function 16268 * is invoked more than once during the `wait` timeout. 16269 * 16270 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 16271 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 16272 * 16273 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 16274 * for details over the differences between `_.debounce` and `_.throttle`. 16275 * 16276 * @static 16277 * @memberOf _ 16278 * @since 0.1.0 16279 * @category Function 16280 * @param {Function} func The function to debounce. 16281 * @param {number} [wait=0] The number of milliseconds to delay. 16282 * @param {Object} [options={}] The options object. 16283 * @param {boolean} [options.leading=false] 16284 * Specify invoking on the leading edge of the timeout. 16285 * @param {number} [options.maxWait] 16286 * The maximum time `func` is allowed to be delayed before it's invoked. 16287 * @param {boolean} [options.trailing=true] 16288 * Specify invoking on the trailing edge of the timeout. 16289 * @returns {Function} Returns the new debounced function. 16290 * @example 16291 * 16292 * // Avoid costly calculations while the window size is in flux. 16293 * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); 16294 * 16295 * // Invoke `sendMail` when clicked, debouncing subsequent calls. 16296 * jQuery(element).on('click', _.debounce(sendMail, 300, { 16297 * 'leading': true, 16298 * 'trailing': false 16299 * })); 16300 * 16301 * // Ensure `batchLog` is invoked once after 1 second of debounced calls. 16302 * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); 16303 * var source = new EventSource('/stream'); 16304 * jQuery(source).on('message', debounced); 16305 * 16306 * // Cancel the trailing debounced invocation. 16307 * jQuery(window).on('popstate', debounced.cancel); 16308 */ 16309 function debounce(func, wait, options) { 16310 var lastArgs, 16311 lastThis, 16312 maxWait, 16313 result, 16314 timerId, 16315 lastCallTime, 16316 lastInvokeTime = 0, 16317 leading = false, 16318 maxing = false, 16319 trailing = true; 16320 16321 if (typeof func != 'function') { 16322 throw new TypeError(FUNC_ERROR_TEXT); 16323 } 16324 wait = toNumber(wait) || 0; 16325 if (isObject(options)) { 16326 leading = !!options.leading; 16327 maxing = 'maxWait' in options; 16328 maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; 16329 trailing = 'trailing' in options ? !!options.trailing : trailing; 16330 } 16331 16332 function invokeFunc(time) { 16333 var args = lastArgs, 16334 thisArg = lastThis; 16335 16336 lastArgs = lastThis = undefined$1; 16337 lastInvokeTime = time; 16338 result = func.apply(thisArg, args); 16339 return result; 16340 } 16341 16342 function leadingEdge(time) { 16343 // Reset any `maxWait` timer. 16344 lastInvokeTime = time; 16345 // Start the timer for the trailing edge. 16346 timerId = setTimeout(timerExpired, wait); 16347 // Invoke the leading edge. 16348 return leading ? invokeFunc(time) : result; 16349 } 16350 16351 function remainingWait(time) { 16352 var timeSinceLastCall = time - lastCallTime, 16353 timeSinceLastInvoke = time - lastInvokeTime, 16354 timeWaiting = wait - timeSinceLastCall; 16355 16356 return maxing 16357 ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) 16358 : timeWaiting; 16359 } 16360 16361 function shouldInvoke(time) { 16362 var timeSinceLastCall = time - lastCallTime, 16363 timeSinceLastInvoke = time - lastInvokeTime; 16364 16365 // Either this is the first call, activity has stopped and we're at the 16366 // trailing edge, the system time has gone backwards and we're treating 16367 // it as the trailing edge, or we've hit the `maxWait` limit. 16368 return (lastCallTime === undefined$1 || (timeSinceLastCall >= wait) || 16369 (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); 16370 } 16371 16372 function timerExpired() { 16373 var time = now(); 16374 if (shouldInvoke(time)) { 16375 return trailingEdge(time); 16376 } 16377 // Restart the timer. 16378 timerId = setTimeout(timerExpired, remainingWait(time)); 16379 } 16380 16381 function trailingEdge(time) { 16382 timerId = undefined$1; 16383 16384 // Only invoke if we have `lastArgs` which means `func` has been 16385 // debounced at least once. 16386 if (trailing && lastArgs) { 16387 return invokeFunc(time); 16388 } 16389 lastArgs = lastThis = undefined$1; 16390 return result; 16391 } 16392 16393 function cancel() { 16394 if (timerId !== undefined$1) { 16395 clearTimeout(timerId); 16396 } 16397 lastInvokeTime = 0; 16398 lastArgs = lastCallTime = lastThis = timerId = undefined$1; 16399 } 16400 16401 function flush() { 16402 return timerId === undefined$1 ? result : trailingEdge(now()); 16403 } 16404 16405 function debounced() { 16406 var time = now(), 16407 isInvoking = shouldInvoke(time); 16408 16409 lastArgs = arguments; 16410 lastThis = this; 16411 lastCallTime = time; 16412 16413 if (isInvoking) { 16414 if (timerId === undefined$1) { 16415 return leadingEdge(lastCallTime); 16416 } 16417 if (maxing) { 16418 // Handle invocations in a tight loop. 16419 clearTimeout(timerId); 16420 timerId = setTimeout(timerExpired, wait); 16421 return invokeFunc(lastCallTime); 16422 } 16423 } 16424 if (timerId === undefined$1) { 16425 timerId = setTimeout(timerExpired, wait); 16426 } 16427 return result; 16428 } 16429 debounced.cancel = cancel; 16430 debounced.flush = flush; 16431 return debounced; 16432 } 16433 16434 /** 16435 * Defers invoking the `func` until the current call stack has cleared. Any 16436 * additional arguments are provided to `func` when it's invoked. 16437 * 16438 * @static 16439 * @memberOf _ 16440 * @since 0.1.0 16441 * @category Function 16442 * @param {Function} func The function to defer. 16443 * @param {...*} [args] The arguments to invoke `func` with. 16444 * @returns {number} Returns the timer id. 16445 * @example 16446 * 16447 * _.defer(function(text) { 16448 * console.log(text); 16449 * }, 'deferred'); 16450 * // => Logs 'deferred' after one millisecond. 16451 */ 16452 var defer = baseRest(function(func, args) { 16453 return baseDelay(func, 1, args); 16454 }); 16455 16456 /** 16457 * Invokes `func` after `wait` milliseconds. Any additional arguments are 16458 * provided to `func` when it's invoked. 16459 * 16460 * @static 16461 * @memberOf _ 16462 * @since 0.1.0 16463 * @category Function 16464 * @param {Function} func The function to delay. 16465 * @param {number} wait The number of milliseconds to delay invocation. 16466 * @param {...*} [args] The arguments to invoke `func` with. 16467 * @returns {number} Returns the timer id. 16468 * @example 16469 * 16470 * _.delay(function(text) { 16471 * console.log(text); 16472 * }, 1000, 'later'); 16473 * // => Logs 'later' after one second. 16474 */ 16475 var delay = baseRest(function(func, wait, args) { 16476 return baseDelay(func, toNumber(wait) || 0, args); 16477 }); 16478 16479 /** 16480 * Creates a function that invokes `func` with arguments reversed. 16481 * 16482 * @static 16483 * @memberOf _ 16484 * @since 4.0.0 16485 * @category Function 16486 * @param {Function} func The function to flip arguments for. 16487 * @returns {Function} Returns the new flipped function. 16488 * @example 16489 * 16490 * var flipped = _.flip(function() { 16491 * return _.toArray(arguments); 16492 * }); 16493 * 16494 * flipped('a', 'b', 'c', 'd'); 16495 * // => ['d', 'c', 'b', 'a'] 16496 */ 16497 function flip(func) { 16498 return createWrap(func, WRAP_FLIP_FLAG); 16499 } 16500 16501 /** 16502 * Creates a function that memoizes the result of `func`. If `resolver` is 16503 * provided, it determines the cache key for storing the result based on the 16504 * arguments provided to the memoized function. By default, the first argument 16505 * provided to the memoized function is used as the map cache key. The `func` 16506 * is invoked with the `this` binding of the memoized function. 16507 * 16508 * **Note:** The cache is exposed as the `cache` property on the memoized 16509 * function. Its creation may be customized by replacing the `_.memoize.Cache` 16510 * constructor with one whose instances implement the 16511 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) 16512 * method interface of `clear`, `delete`, `get`, `has`, and `set`. 16513 * 16514 * @static 16515 * @memberOf _ 16516 * @since 0.1.0 16517 * @category Function 16518 * @param {Function} func The function to have its output memoized. 16519 * @param {Function} [resolver] The function to resolve the cache key. 16520 * @returns {Function} Returns the new memoized function. 16521 * @example 16522 * 16523 * var object = { 'a': 1, 'b': 2 }; 16524 * var other = { 'c': 3, 'd': 4 }; 16525 * 16526 * var values = _.memoize(_.values); 16527 * values(object); 16528 * // => [1, 2] 16529 * 16530 * values(other); 16531 * // => [3, 4] 16532 * 16533 * object.a = 2; 16534 * values(object); 16535 * // => [1, 2] 16536 * 16537 * // Modify the result cache. 16538 * values.cache.set(object, ['a', 'b']); 16539 * values(object); 16540 * // => ['a', 'b'] 16541 * 16542 * // Replace `_.memoize.Cache`. 16543 * _.memoize.Cache = WeakMap; 16544 */ 16545 function memoize(func, resolver) { 16546 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { 16547 throw new TypeError(FUNC_ERROR_TEXT); 16548 } 16549 var memoized = function() { 16550 var args = arguments, 16551 key = resolver ? resolver.apply(this, args) : args[0], 16552 cache = memoized.cache; 16553 16554 if (cache.has(key)) { 16555 return cache.get(key); 16556 } 16557 var result = func.apply(this, args); 16558 memoized.cache = cache.set(key, result) || cache; 16559 return result; 16560 }; 16561 memoized.cache = new (memoize.Cache || MapCache); 16562 return memoized; 16563 } 16564 16565 // Expose `MapCache`. 16566 memoize.Cache = MapCache; 16567 16568 /** 16569 * Creates a function that negates the result of the predicate `func`. The 16570 * `func` predicate is invoked with the `this` binding and arguments of the 16571 * created function. 16572 * 16573 * @static 16574 * @memberOf _ 16575 * @since 3.0.0 16576 * @category Function 16577 * @param {Function} predicate The predicate to negate. 16578 * @returns {Function} Returns the new negated function. 16579 * @example 16580 * 16581 * function isEven(n) { 16582 * return n % 2 == 0; 16583 * } 16584 * 16585 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); 16586 * // => [1, 3, 5] 16587 */ 16588 function negate(predicate) { 16589 if (typeof predicate != 'function') { 16590 throw new TypeError(FUNC_ERROR_TEXT); 16591 } 16592 return function() { 16593 var args = arguments; 16594 switch (args.length) { 16595 case 0: return !predicate.call(this); 16596 case 1: return !predicate.call(this, args[0]); 16597 case 2: return !predicate.call(this, args[0], args[1]); 16598 case 3: return !predicate.call(this, args[0], args[1], args[2]); 16599 } 16600 return !predicate.apply(this, args); 16601 }; 16602 } 16603 16604 /** 16605 * Creates a function that is restricted to invoking `func` once. Repeat calls 16606 * to the function return the value of the first invocation. The `func` is 16607 * invoked with the `this` binding and arguments of the created function. 16608 * 16609 * @static 16610 * @memberOf _ 16611 * @since 0.1.0 16612 * @category Function 16613 * @param {Function} func The function to restrict. 16614 * @returns {Function} Returns the new restricted function. 16615 * @example 16616 * 16617 * var initialize = _.once(createApplication); 16618 * initialize(); 16619 * initialize(); 16620 * // => `createApplication` is invoked once 16621 */ 16622 function once(func) { 16623 return before(2, func); 16624 } 16625 16626 /** 16627 * Creates a function that invokes `func` with its arguments transformed. 16628 * 16629 * @static 16630 * @since 4.0.0 16631 * @memberOf _ 16632 * @category Function 16633 * @param {Function} func The function to wrap. 16634 * @param {...(Function|Function[])} [transforms=[_.identity]] 16635 * The argument transforms. 16636 * @returns {Function} Returns the new function. 16637 * @example 16638 * 16639 * function doubled(n) { 16640 * return n * 2; 16641 * } 16642 * 16643 * function square(n) { 16644 * return n * n; 16645 * } 16646 * 16647 * var func = _.overArgs(function(x, y) { 16648 * return [x, y]; 16649 * }, [square, doubled]); 16650 * 16651 * func(9, 3); 16652 * // => [81, 6] 16653 * 16654 * func(10, 5); 16655 * // => [100, 10] 16656 */ 16657 var overArgs = castRest(function(func, transforms) { 16658 transforms = (transforms.length == 1 && isArray(transforms[0])) 16659 ? arrayMap(transforms[0], baseUnary(getIteratee())) 16660 : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee())); 16661 16662 var funcsLength = transforms.length; 16663 return baseRest(function(args) { 16664 var index = -1, 16665 length = nativeMin(args.length, funcsLength); 16666 16667 while (++index < length) { 16668 args[index] = transforms[index].call(this, args[index]); 16669 } 16670 return apply(func, this, args); 16671 }); 16672 }); 16673 16674 /** 16675 * Creates a function that invokes `func` with `partials` prepended to the 16676 * arguments it receives. This method is like `_.bind` except it does **not** 16677 * alter the `this` binding. 16678 * 16679 * The `_.partial.placeholder` value, which defaults to `_` in monolithic 16680 * builds, may be used as a placeholder for partially applied arguments. 16681 * 16682 * **Note:** This method doesn't set the "length" property of partially 16683 * applied functions. 16684 * 16685 * @static 16686 * @memberOf _ 16687 * @since 0.2.0 16688 * @category Function 16689 * @param {Function} func The function to partially apply arguments to. 16690 * @param {...*} [partials] The arguments to be partially applied. 16691 * @returns {Function} Returns the new partially applied function. 16692 * @example 16693 * 16694 * function greet(greeting, name) { 16695 * return greeting + ' ' + name; 16696 * } 16697 * 16698 * var sayHelloTo = _.partial(greet, 'hello'); 16699 * sayHelloTo('fred'); 16700 * // => 'hello fred' 16701 * 16702 * // Partially applied with placeholders. 16703 * var greetFred = _.partial(greet, _, 'fred'); 16704 * greetFred('hi'); 16705 * // => 'hi fred' 16706 */ 16707 var partial = baseRest(function(func, partials) { 16708 var holders = replaceHolders(partials, getHolder(partial)); 16709 return createWrap(func, WRAP_PARTIAL_FLAG, undefined$1, partials, holders); 16710 }); 16711 16712 /** 16713 * This method is like `_.partial` except that partially applied arguments 16714 * are appended to the arguments it receives. 16715 * 16716 * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic 16717 * builds, may be used as a placeholder for partially applied arguments. 16718 * 16719 * **Note:** This method doesn't set the "length" property of partially 16720 * applied functions. 16721 * 16722 * @static 16723 * @memberOf _ 16724 * @since 1.0.0 16725 * @category Function 16726 * @param {Function} func The function to partially apply arguments to. 16727 * @param {...*} [partials] The arguments to be partially applied. 16728 * @returns {Function} Returns the new partially applied function. 16729 * @example 16730 * 16731 * function greet(greeting, name) { 16732 * return greeting + ' ' + name; 16733 * } 16734 * 16735 * var greetFred = _.partialRight(greet, 'fred'); 16736 * greetFred('hi'); 16737 * // => 'hi fred' 16738 * 16739 * // Partially applied with placeholders. 16740 * var sayHelloTo = _.partialRight(greet, 'hello', _); 16741 * sayHelloTo('fred'); 16742 * // => 'hello fred' 16743 */ 16744 var partialRight = baseRest(function(func, partials) { 16745 var holders = replaceHolders(partials, getHolder(partialRight)); 16746 return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined$1, partials, holders); 16747 }); 16748 16749 /** 16750 * Creates a function that invokes `func` with arguments arranged according 16751 * to the specified `indexes` where the argument value at the first index is 16752 * provided as the first argument, the argument value at the second index is 16753 * provided as the second argument, and so on. 16754 * 16755 * @static 16756 * @memberOf _ 16757 * @since 3.0.0 16758 * @category Function 16759 * @param {Function} func The function to rearrange arguments for. 16760 * @param {...(number|number[])} indexes The arranged argument indexes. 16761 * @returns {Function} Returns the new function. 16762 * @example 16763 * 16764 * var rearged = _.rearg(function(a, b, c) { 16765 * return [a, b, c]; 16766 * }, [2, 0, 1]); 16767 * 16768 * rearged('b', 'c', 'a') 16769 * // => ['a', 'b', 'c'] 16770 */ 16771 var rearg = flatRest(function(func, indexes) { 16772 return createWrap(func, WRAP_REARG_FLAG, undefined$1, undefined$1, undefined$1, indexes); 16773 }); 16774 16775 /** 16776 * Creates a function that invokes `func` with the `this` binding of the 16777 * created function and arguments from `start` and beyond provided as 16778 * an array. 16779 * 16780 * **Note:** This method is based on the 16781 * [rest parameter](https://mdn.io/rest_parameters). 16782 * 16783 * @static 16784 * @memberOf _ 16785 * @since 4.0.0 16786 * @category Function 16787 * @param {Function} func The function to apply a rest parameter to. 16788 * @param {number} [start=func.length-1] The start position of the rest parameter. 16789 * @returns {Function} Returns the new function. 16790 * @example 16791 * 16792 * var say = _.rest(function(what, names) { 16793 * return what + ' ' + _.initial(names).join(', ') + 16794 * (_.size(names) > 1 ? ', & ' : '') + _.last(names); 16795 * }); 16796 * 16797 * say('hello', 'fred', 'barney', 'pebbles'); 16798 * // => 'hello fred, barney, & pebbles' 16799 */ 16800 function rest(func, start) { 16801 if (typeof func != 'function') { 16802 throw new TypeError(FUNC_ERROR_TEXT); 16803 } 16804 start = start === undefined$1 ? start : toInteger(start); 16805 return baseRest(func, start); 16806 } 16807 16808 /** 16809 * Creates a function that invokes `func` with the `this` binding of the 16810 * create function and an array of arguments much like 16811 * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply). 16812 * 16813 * **Note:** This method is based on the 16814 * [spread operator](https://mdn.io/spread_operator). 16815 * 16816 * @static 16817 * @memberOf _ 16818 * @since 3.2.0 16819 * @category Function 16820 * @param {Function} func The function to spread arguments over. 16821 * @param {number} [start=0] The start position of the spread. 16822 * @returns {Function} Returns the new function. 16823 * @example 16824 * 16825 * var say = _.spread(function(who, what) { 16826 * return who + ' says ' + what; 16827 * }); 16828 * 16829 * say(['fred', 'hello']); 16830 * // => 'fred says hello' 16831 * 16832 * var numbers = Promise.all([ 16833 * Promise.resolve(40), 16834 * Promise.resolve(36) 16835 * ]); 16836 * 16837 * numbers.then(_.spread(function(x, y) { 16838 * return x + y; 16839 * })); 16840 * // => a Promise of 76 16841 */ 16842 function spread(func, start) { 16843 if (typeof func != 'function') { 16844 throw new TypeError(FUNC_ERROR_TEXT); 16845 } 16846 start = start == null ? 0 : nativeMax(toInteger(start), 0); 16847 return baseRest(function(args) { 16848 var array = args[start], 16849 otherArgs = castSlice(args, 0, start); 16850 16851 if (array) { 16852 arrayPush(otherArgs, array); 16853 } 16854 return apply(func, this, otherArgs); 16855 }); 16856 } 16857 16858 /** 16859 * Creates a throttled function that only invokes `func` at most once per 16860 * every `wait` milliseconds. The throttled function comes with a `cancel` 16861 * method to cancel delayed `func` invocations and a `flush` method to 16862 * immediately invoke them. Provide `options` to indicate whether `func` 16863 * should be invoked on the leading and/or trailing edge of the `wait` 16864 * timeout. The `func` is invoked with the last arguments provided to the 16865 * throttled function. Subsequent calls to the throttled function return the 16866 * result of the last `func` invocation. 16867 * 16868 * **Note:** If `leading` and `trailing` options are `true`, `func` is 16869 * invoked on the trailing edge of the timeout only if the throttled function 16870 * is invoked more than once during the `wait` timeout. 16871 * 16872 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 16873 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 16874 * 16875 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 16876 * for details over the differences between `_.throttle` and `_.debounce`. 16877 * 16878 * @static 16879 * @memberOf _ 16880 * @since 0.1.0 16881 * @category Function 16882 * @param {Function} func The function to throttle. 16883 * @param {number} [wait=0] The number of milliseconds to throttle invocations to. 16884 * @param {Object} [options={}] The options object. 16885 * @param {boolean} [options.leading=true] 16886 * Specify invoking on the leading edge of the timeout. 16887 * @param {boolean} [options.trailing=true] 16888 * Specify invoking on the trailing edge of the timeout. 16889 * @returns {Function} Returns the new throttled function. 16890 * @example 16891 * 16892 * // Avoid excessively updating the position while scrolling. 16893 * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); 16894 * 16895 * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. 16896 * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); 16897 * jQuery(element).on('click', throttled); 16898 * 16899 * // Cancel the trailing throttled invocation. 16900 * jQuery(window).on('popstate', throttled.cancel); 16901 */ 16902 function throttle(func, wait, options) { 16903 var leading = true, 16904 trailing = true; 16905 16906 if (typeof func != 'function') { 16907 throw new TypeError(FUNC_ERROR_TEXT); 16908 } 16909 if (isObject(options)) { 16910 leading = 'leading' in options ? !!options.leading : leading; 16911 trailing = 'trailing' in options ? !!options.trailing : trailing; 16912 } 16913 return debounce(func, wait, { 16914 'leading': leading, 16915 'maxWait': wait, 16916 'trailing': trailing 16917 }); 16918 } 16919 16920 /** 16921 * Creates a function that accepts up to one argument, ignoring any 16922 * additional arguments. 16923 * 16924 * @static 16925 * @memberOf _ 16926 * @since 4.0.0 16927 * @category Function 16928 * @param {Function} func The function to cap arguments for. 16929 * @returns {Function} Returns the new capped function. 16930 * @example 16931 * 16932 * _.map(['6', '8', '10'], _.unary(parseInt)); 16933 * // => [6, 8, 10] 16934 */ 16935 function unary(func) { 16936 return ary(func, 1); 16937 } 16938 16939 /** 16940 * Creates a function that provides `value` to `wrapper` as its first 16941 * argument. Any additional arguments provided to the function are appended 16942 * to those provided to the `wrapper`. The wrapper is invoked with the `this` 16943 * binding of the created function. 16944 * 16945 * @static 16946 * @memberOf _ 16947 * @since 0.1.0 16948 * @category Function 16949 * @param {*} value The value to wrap. 16950 * @param {Function} [wrapper=identity] The wrapper function. 16951 * @returns {Function} Returns the new function. 16952 * @example 16953 * 16954 * var p = _.wrap(_.escape, function(func, text) { 16955 * return '<p>' + func(text) + '</p>'; 16956 * }); 16957 * 16958 * p('fred, barney, & pebbles'); 16959 * // => '<p>fred, barney, & pebbles</p>' 16960 */ 16961 function wrap(value, wrapper) { 16962 return partial(castFunction(wrapper), value); 16963 } 16964 16965 /*------------------------------------------------------------------------*/ 16966 16967 /** 16968 * Casts `value` as an array if it's not one. 16969 * 16970 * @static 16971 * @memberOf _ 16972 * @since 4.4.0 16973 * @category Lang 16974 * @param {*} value The value to inspect. 16975 * @returns {Array} Returns the cast array. 16976 * @example 16977 * 16978 * _.castArray(1); 16979 * // => [1] 16980 * 16981 * _.castArray({ 'a': 1 }); 16982 * // => [{ 'a': 1 }] 16983 * 16984 * _.castArray('abc'); 16985 * // => ['abc'] 16986 * 16987 * _.castArray(null); 16988 * // => [null] 16989 * 16990 * _.castArray(undefined); 16991 * // => [undefined] 16992 * 16993 * _.castArray(); 16994 * // => [] 16995 * 16996 * var array = [1, 2, 3]; 16997 * console.log(_.castArray(array) === array); 16998 * // => true 16999 */ 17000 function castArray() { 17001 if (!arguments.length) { 17002 return []; 17003 } 17004 var value = arguments[0]; 17005 return isArray(value) ? value : [value]; 17006 } 17007 17008 /** 17009 * Creates a shallow clone of `value`. 17010 * 17011 * **Note:** This method is loosely based on the 17012 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) 17013 * and supports cloning arrays, array buffers, booleans, date objects, maps, 17014 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed 17015 * arrays. The own enumerable properties of `arguments` objects are cloned 17016 * as plain objects. An empty object is returned for uncloneable values such 17017 * as error objects, functions, DOM nodes, and WeakMaps. 17018 * 17019 * @static 17020 * @memberOf _ 17021 * @since 0.1.0 17022 * @category Lang 17023 * @param {*} value The value to clone. 17024 * @returns {*} Returns the cloned value. 17025 * @see _.cloneDeep 17026 * @example 17027 * 17028 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 17029 * 17030 * var shallow = _.clone(objects); 17031 * console.log(shallow[0] === objects[0]); 17032 * // => true 17033 */ 17034 function clone(value) { 17035 return baseClone(value, CLONE_SYMBOLS_FLAG); 17036 } 17037 17038 /** 17039 * This method is like `_.clone` except that it accepts `customizer` which 17040 * is invoked to produce the cloned value. If `customizer` returns `undefined`, 17041 * cloning is handled by the method instead. The `customizer` is invoked with 17042 * up to four arguments; (value [, index|key, object, stack]). 17043 * 17044 * @static 17045 * @memberOf _ 17046 * @since 4.0.0 17047 * @category Lang 17048 * @param {*} value The value to clone. 17049 * @param {Function} [customizer] The function to customize cloning. 17050 * @returns {*} Returns the cloned value. 17051 * @see _.cloneDeepWith 17052 * @example 17053 * 17054 * function customizer(value) { 17055 * if (_.isElement(value)) { 17056 * return value.cloneNode(false); 17057 * } 17058 * } 17059 * 17060 * var el = _.cloneWith(document.body, customizer); 17061 * 17062 * console.log(el === document.body); 17063 * // => false 17064 * console.log(el.nodeName); 17065 * // => 'BODY' 17066 * console.log(el.childNodes.length); 17067 * // => 0 17068 */ 17069 function cloneWith(value, customizer) { 17070 customizer = typeof customizer == 'function' ? customizer : undefined$1; 17071 return baseClone(value, CLONE_SYMBOLS_FLAG, customizer); 17072 } 17073 17074 /** 17075 * This method is like `_.clone` except that it recursively clones `value`. 17076 * 17077 * @static 17078 * @memberOf _ 17079 * @since 1.0.0 17080 * @category Lang 17081 * @param {*} value The value to recursively clone. 17082 * @returns {*} Returns the deep cloned value. 17083 * @see _.clone 17084 * @example 17085 * 17086 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 17087 * 17088 * var deep = _.cloneDeep(objects); 17089 * console.log(deep[0] === objects[0]); 17090 * // => false 17091 */ 17092 function cloneDeep(value) { 17093 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); 17094 } 17095 17096 /** 17097 * This method is like `_.cloneWith` except that it recursively clones `value`. 17098 * 17099 * @static 17100 * @memberOf _ 17101 * @since 4.0.0 17102 * @category Lang 17103 * @param {*} value The value to recursively clone. 17104 * @param {Function} [customizer] The function to customize cloning. 17105 * @returns {*} Returns the deep cloned value. 17106 * @see _.cloneWith 17107 * @example 17108 * 17109 * function customizer(value) { 17110 * if (_.isElement(value)) { 17111 * return value.cloneNode(true); 17112 * } 17113 * } 17114 * 17115 * var el = _.cloneDeepWith(document.body, customizer); 17116 * 17117 * console.log(el === document.body); 17118 * // => false 17119 * console.log(el.nodeName); 17120 * // => 'BODY' 17121 * console.log(el.childNodes.length); 17122 * // => 20 17123 */ 17124 function cloneDeepWith(value, customizer) { 17125 customizer = typeof customizer == 'function' ? customizer : undefined$1; 17126 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer); 17127 } 17128 17129 /** 17130 * Checks if `object` conforms to `source` by invoking the predicate 17131 * properties of `source` with the corresponding property values of `object`. 17132 * 17133 * **Note:** This method is equivalent to `_.conforms` when `source` is 17134 * partially applied. 17135 * 17136 * @static 17137 * @memberOf _ 17138 * @since 4.14.0 17139 * @category Lang 17140 * @param {Object} object The object to inspect. 17141 * @param {Object} source The object of property predicates to conform to. 17142 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 17143 * @example 17144 * 17145 * var object = { 'a': 1, 'b': 2 }; 17146 * 17147 * _.conformsTo(object, { 'b': function(n) { return n > 1; } }); 17148 * // => true 17149 * 17150 * _.conformsTo(object, { 'b': function(n) { return n > 2; } }); 17151 * // => false 17152 */ 17153 function conformsTo(object, source) { 17154 return source == null || baseConformsTo(object, source, keys(source)); 17155 } 17156 17157 /** 17158 * Performs a 17159 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 17160 * comparison between two values to determine if they are equivalent. 17161 * 17162 * @static 17163 * @memberOf _ 17164 * @since 4.0.0 17165 * @category Lang 17166 * @param {*} value The value to compare. 17167 * @param {*} other The other value to compare. 17168 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 17169 * @example 17170 * 17171 * var object = { 'a': 1 }; 17172 * var other = { 'a': 1 }; 17173 * 17174 * _.eq(object, object); 17175 * // => true 17176 * 17177 * _.eq(object, other); 17178 * // => false 17179 * 17180 * _.eq('a', 'a'); 17181 * // => true 17182 * 17183 * _.eq('a', Object('a')); 17184 * // => false 17185 * 17186 * _.eq(NaN, NaN); 17187 * // => true 17188 */ 17189 function eq(value, other) { 17190 return value === other || (value !== value && other !== other); 17191 } 17192 17193 /** 17194 * Checks if `value` is greater than `other`. 17195 * 17196 * @static 17197 * @memberOf _ 17198 * @since 3.9.0 17199 * @category Lang 17200 * @param {*} value The value to compare. 17201 * @param {*} other The other value to compare. 17202 * @returns {boolean} Returns `true` if `value` is greater than `other`, 17203 * else `false`. 17204 * @see _.lt 17205 * @example 17206 * 17207 * _.gt(3, 1); 17208 * // => true 17209 * 17210 * _.gt(3, 3); 17211 * // => false 17212 * 17213 * _.gt(1, 3); 17214 * // => false 17215 */ 17216 var gt = createRelationalOperation(baseGt); 17217 17218 /** 17219 * Checks if `value` is greater than or equal to `other`. 17220 * 17221 * @static 17222 * @memberOf _ 17223 * @since 3.9.0 17224 * @category Lang 17225 * @param {*} value The value to compare. 17226 * @param {*} other The other value to compare. 17227 * @returns {boolean} Returns `true` if `value` is greater than or equal to 17228 * `other`, else `false`. 17229 * @see _.lte 17230 * @example 17231 * 17232 * _.gte(3, 1); 17233 * // => true 17234 * 17235 * _.gte(3, 3); 17236 * // => true 17237 * 17238 * _.gte(1, 3); 17239 * // => false 17240 */ 17241 var gte = createRelationalOperation(function(value, other) { 17242 return value >= other; 17243 }); 17244 17245 /** 17246 * Checks if `value` is likely an `arguments` object. 17247 * 17248 * @static 17249 * @memberOf _ 17250 * @since 0.1.0 17251 * @category Lang 17252 * @param {*} value The value to check. 17253 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 17254 * else `false`. 17255 * @example 17256 * 17257 * _.isArguments(function() { return arguments; }()); 17258 * // => true 17259 * 17260 * _.isArguments([1, 2, 3]); 17261 * // => false 17262 */ 17263 var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { 17264 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && 17265 !propertyIsEnumerable.call(value, 'callee'); 17266 }; 17267 17268 /** 17269 * Checks if `value` is classified as an `Array` object. 17270 * 17271 * @static 17272 * @memberOf _ 17273 * @since 0.1.0 17274 * @category Lang 17275 * @param {*} value The value to check. 17276 * @returns {boolean} Returns `true` if `value` is an array, else `false`. 17277 * @example 17278 * 17279 * _.isArray([1, 2, 3]); 17280 * // => true 17281 * 17282 * _.isArray(document.body.children); 17283 * // => false 17284 * 17285 * _.isArray('abc'); 17286 * // => false 17287 * 17288 * _.isArray(_.noop); 17289 * // => false 17290 */ 17291 var isArray = Array.isArray; 17292 17293 /** 17294 * Checks if `value` is classified as an `ArrayBuffer` object. 17295 * 17296 * @static 17297 * @memberOf _ 17298 * @since 4.3.0 17299 * @category Lang 17300 * @param {*} value The value to check. 17301 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 17302 * @example 17303 * 17304 * _.isArrayBuffer(new ArrayBuffer(2)); 17305 * // => true 17306 * 17307 * _.isArrayBuffer(new Array(2)); 17308 * // => false 17309 */ 17310 var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; 17311 17312 /** 17313 * Checks if `value` is array-like. A value is considered array-like if it's 17314 * not a function and has a `value.length` that's an integer greater than or 17315 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. 17316 * 17317 * @static 17318 * @memberOf _ 17319 * @since 4.0.0 17320 * @category Lang 17321 * @param {*} value The value to check. 17322 * @returns {boolean} Returns `true` if `value` is array-like, else `false`. 17323 * @example 17324 * 17325 * _.isArrayLike([1, 2, 3]); 17326 * // => true 17327 * 17328 * _.isArrayLike(document.body.children); 17329 * // => true 17330 * 17331 * _.isArrayLike('abc'); 17332 * // => true 17333 * 17334 * _.isArrayLike(_.noop); 17335 * // => false 17336 */ 17337 function isArrayLike(value) { 17338 return value != null && isLength(value.length) && !isFunction(value); 17339 } 17340 17341 /** 17342 * This method is like `_.isArrayLike` except that it also checks if `value` 17343 * is an object. 17344 * 17345 * @static 17346 * @memberOf _ 17347 * @since 4.0.0 17348 * @category Lang 17349 * @param {*} value The value to check. 17350 * @returns {boolean} Returns `true` if `value` is an array-like object, 17351 * else `false`. 17352 * @example 17353 * 17354 * _.isArrayLikeObject([1, 2, 3]); 17355 * // => true 17356 * 17357 * _.isArrayLikeObject(document.body.children); 17358 * // => true 17359 * 17360 * _.isArrayLikeObject('abc'); 17361 * // => false 17362 * 17363 * _.isArrayLikeObject(_.noop); 17364 * // => false 17365 */ 17366 function isArrayLikeObject(value) { 17367 return isObjectLike(value) && isArrayLike(value); 17368 } 17369 17370 /** 17371 * Checks if `value` is classified as a boolean primitive or object. 17372 * 17373 * @static 17374 * @memberOf _ 17375 * @since 0.1.0 17376 * @category Lang 17377 * @param {*} value The value to check. 17378 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`. 17379 * @example 17380 * 17381 * _.isBoolean(false); 17382 * // => true 17383 * 17384 * _.isBoolean(null); 17385 * // => false 17386 */ 17387 function isBoolean(value) { 17388 return value === true || value === false || 17389 (isObjectLike(value) && baseGetTag(value) == boolTag); 17390 } 17391 17392 /** 17393 * Checks if `value` is a buffer. 17394 * 17395 * @static 17396 * @memberOf _ 17397 * @since 4.3.0 17398 * @category Lang 17399 * @param {*} value The value to check. 17400 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. 17401 * @example 17402 * 17403 * _.isBuffer(new Buffer(2)); 17404 * // => true 17405 * 17406 * _.isBuffer(new Uint8Array(2)); 17407 * // => false 17408 */ 17409 var isBuffer = nativeIsBuffer || stubFalse; 17410 17411 /** 17412 * Checks if `value` is classified as a `Date` object. 17413 * 17414 * @static 17415 * @memberOf _ 17416 * @since 0.1.0 17417 * @category Lang 17418 * @param {*} value The value to check. 17419 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 17420 * @example 17421 * 17422 * _.isDate(new Date); 17423 * // => true 17424 * 17425 * _.isDate('Mon April 23 2012'); 17426 * // => false 17427 */ 17428 var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; 17429 17430 /** 17431 * Checks if `value` is likely a DOM element. 17432 * 17433 * @static 17434 * @memberOf _ 17435 * @since 0.1.0 17436 * @category Lang 17437 * @param {*} value The value to check. 17438 * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. 17439 * @example 17440 * 17441 * _.isElement(document.body); 17442 * // => true 17443 * 17444 * _.isElement('<body>'); 17445 * // => false 17446 */ 17447 function isElement(value) { 17448 return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value); 17449 } 17450 17451 /** 17452 * Checks if `value` is an empty object, collection, map, or set. 17453 * 17454 * Objects are considered empty if they have no own enumerable string keyed 17455 * properties. 17456 * 17457 * Array-like values such as `arguments` objects, arrays, buffers, strings, or 17458 * jQuery-like collections are considered empty if they have a `length` of `0`. 17459 * Similarly, maps and sets are considered empty if they have a `size` of `0`. 17460 * 17461 * @static 17462 * @memberOf _ 17463 * @since 0.1.0 17464 * @category Lang 17465 * @param {*} value The value to check. 17466 * @returns {boolean} Returns `true` if `value` is empty, else `false`. 17467 * @example 17468 * 17469 * _.isEmpty(null); 17470 * // => true 17471 * 17472 * _.isEmpty(true); 17473 * // => true 17474 * 17475 * _.isEmpty(1); 17476 * // => true 17477 * 17478 * _.isEmpty([1, 2, 3]); 17479 * // => false 17480 * 17481 * _.isEmpty({ 'a': 1 }); 17482 * // => false 17483 */ 17484 function isEmpty(value) { 17485 if (value == null) { 17486 return true; 17487 } 17488 if (isArrayLike(value) && 17489 (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || 17490 isBuffer(value) || isTypedArray(value) || isArguments(value))) { 17491 return !value.length; 17492 } 17493 var tag = getTag(value); 17494 if (tag == mapTag || tag == setTag) { 17495 return !value.size; 17496 } 17497 if (isPrototype(value)) { 17498 return !baseKeys(value).length; 17499 } 17500 for (var key in value) { 17501 if (hasOwnProperty.call(value, key)) { 17502 return false; 17503 } 17504 } 17505 return true; 17506 } 17507 17508 /** 17509 * Performs a deep comparison between two values to determine if they are 17510 * equivalent. 17511 * 17512 * **Note:** This method supports comparing arrays, array buffers, booleans, 17513 * date objects, error objects, maps, numbers, `Object` objects, regexes, 17514 * sets, strings, symbols, and typed arrays. `Object` objects are compared 17515 * by their own, not inherited, enumerable properties. Functions and DOM 17516 * nodes are compared by strict equality, i.e. `===`. 17517 * 17518 * @static 17519 * @memberOf _ 17520 * @since 0.1.0 17521 * @category Lang 17522 * @param {*} value The value to compare. 17523 * @param {*} other The other value to compare. 17524 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 17525 * @example 17526 * 17527 * var object = { 'a': 1 }; 17528 * var other = { 'a': 1 }; 17529 * 17530 * _.isEqual(object, other); 17531 * // => true 17532 * 17533 * object === other; 17534 * // => false 17535 */ 17536 function isEqual(value, other) { 17537 return baseIsEqual(value, other); 17538 } 17539 17540 /** 17541 * This method is like `_.isEqual` except that it accepts `customizer` which 17542 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 17543 * are handled by the method instead. The `customizer` is invoked with up to 17544 * six arguments: (objValue, othValue [, index|key, object, other, stack]). 17545 * 17546 * @static 17547 * @memberOf _ 17548 * @since 4.0.0 17549 * @category Lang 17550 * @param {*} value The value to compare. 17551 * @param {*} other The other value to compare. 17552 * @param {Function} [customizer] The function to customize comparisons. 17553 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 17554 * @example 17555 * 17556 * function isGreeting(value) { 17557 * return /^h(?:i|ello)$/.test(value); 17558 * } 17559 * 17560 * function customizer(objValue, othValue) { 17561 * if (isGreeting(objValue) && isGreeting(othValue)) { 17562 * return true; 17563 * } 17564 * } 17565 * 17566 * var array = ['hello', 'goodbye']; 17567 * var other = ['hi', 'goodbye']; 17568 * 17569 * _.isEqualWith(array, other, customizer); 17570 * // => true 17571 */ 17572 function isEqualWith(value, other, customizer) { 17573 customizer = typeof customizer == 'function' ? customizer : undefined$1; 17574 var result = customizer ? customizer(value, other) : undefined$1; 17575 return result === undefined$1 ? baseIsEqual(value, other, undefined$1, customizer) : !!result; 17576 } 17577 17578 /** 17579 * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, 17580 * `SyntaxError`, `TypeError`, or `URIError` object. 17581 * 17582 * @static 17583 * @memberOf _ 17584 * @since 3.0.0 17585 * @category Lang 17586 * @param {*} value The value to check. 17587 * @returns {boolean} Returns `true` if `value` is an error object, else `false`. 17588 * @example 17589 * 17590 * _.isError(new Error); 17591 * // => true 17592 * 17593 * _.isError(Error); 17594 * // => false 17595 */ 17596 function isError(value) { 17597 if (!isObjectLike(value)) { 17598 return false; 17599 } 17600 var tag = baseGetTag(value); 17601 return tag == errorTag || tag == domExcTag || 17602 (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value)); 17603 } 17604 17605 /** 17606 * Checks if `value` is a finite primitive number. 17607 * 17608 * **Note:** This method is based on 17609 * [`Number.isFinite`](https://mdn.io/Number/isFinite). 17610 * 17611 * @static 17612 * @memberOf _ 17613 * @since 0.1.0 17614 * @category Lang 17615 * @param {*} value The value to check. 17616 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. 17617 * @example 17618 * 17619 * _.isFinite(3); 17620 * // => true 17621 * 17622 * _.isFinite(Number.MIN_VALUE); 17623 * // => true 17624 * 17625 * _.isFinite(Infinity); 17626 * // => false 17627 * 17628 * _.isFinite('3'); 17629 * // => false 17630 */ 17631 function isFinite(value) { 17632 return typeof value == 'number' && nativeIsFinite(value); 17633 } 17634 17635 /** 17636 * Checks if `value` is classified as a `Function` object. 17637 * 17638 * @static 17639 * @memberOf _ 17640 * @since 0.1.0 17641 * @category Lang 17642 * @param {*} value The value to check. 17643 * @returns {boolean} Returns `true` if `value` is a function, else `false`. 17644 * @example 17645 * 17646 * _.isFunction(_); 17647 * // => true 17648 * 17649 * _.isFunction(/abc/); 17650 * // => false 17651 */ 17652 function isFunction(value) { 17653 if (!isObject(value)) { 17654 return false; 17655 } 17656 // The use of `Object#toString` avoids issues with the `typeof` operator 17657 // in Safari 9 which returns 'object' for typed arrays and other constructors. 17658 var tag = baseGetTag(value); 17659 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; 17660 } 17661 17662 /** 17663 * Checks if `value` is an integer. 17664 * 17665 * **Note:** This method is based on 17666 * [`Number.isInteger`](https://mdn.io/Number/isInteger). 17667 * 17668 * @static 17669 * @memberOf _ 17670 * @since 4.0.0 17671 * @category Lang 17672 * @param {*} value The value to check. 17673 * @returns {boolean} Returns `true` if `value` is an integer, else `false`. 17674 * @example 17675 * 17676 * _.isInteger(3); 17677 * // => true 17678 * 17679 * _.isInteger(Number.MIN_VALUE); 17680 * // => false 17681 * 17682 * _.isInteger(Infinity); 17683 * // => false 17684 * 17685 * _.isInteger('3'); 17686 * // => false 17687 */ 17688 function isInteger(value) { 17689 return typeof value == 'number' && value == toInteger(value); 17690 } 17691 17692 /** 17693 * Checks if `value` is a valid array-like length. 17694 * 17695 * **Note:** This method is loosely based on 17696 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 17697 * 17698 * @static 17699 * @memberOf _ 17700 * @since 4.0.0 17701 * @category Lang 17702 * @param {*} value The value to check. 17703 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. 17704 * @example 17705 * 17706 * _.isLength(3); 17707 * // => true 17708 * 17709 * _.isLength(Number.MIN_VALUE); 17710 * // => false 17711 * 17712 * _.isLength(Infinity); 17713 * // => false 17714 * 17715 * _.isLength('3'); 17716 * // => false 17717 */ 17718 function isLength(value) { 17719 return typeof value == 'number' && 17720 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; 17721 } 17722 17723 /** 17724 * Checks if `value` is the 17725 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) 17726 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) 17727 * 17728 * @static 17729 * @memberOf _ 17730 * @since 0.1.0 17731 * @category Lang 17732 * @param {*} value The value to check. 17733 * @returns {boolean} Returns `true` if `value` is an object, else `false`. 17734 * @example 17735 * 17736 * _.isObject({}); 17737 * // => true 17738 * 17739 * _.isObject([1, 2, 3]); 17740 * // => true 17741 * 17742 * _.isObject(_.noop); 17743 * // => true 17744 * 17745 * _.isObject(null); 17746 * // => false 17747 */ 17748 function isObject(value) { 17749 var type = typeof value; 17750 return value != null && (type == 'object' || type == 'function'); 17751 } 17752 17753 /** 17754 * Checks if `value` is object-like. A value is object-like if it's not `null` 17755 * and has a `typeof` result of "object". 17756 * 17757 * @static 17758 * @memberOf _ 17759 * @since 4.0.0 17760 * @category Lang 17761 * @param {*} value The value to check. 17762 * @returns {boolean} Returns `true` if `value` is object-like, else `false`. 17763 * @example 17764 * 17765 * _.isObjectLike({}); 17766 * // => true 17767 * 17768 * _.isObjectLike([1, 2, 3]); 17769 * // => true 17770 * 17771 * _.isObjectLike(_.noop); 17772 * // => false 17773 * 17774 * _.isObjectLike(null); 17775 * // => false 17776 */ 17777 function isObjectLike(value) { 17778 return value != null && typeof value == 'object'; 17779 } 17780 17781 /** 17782 * Checks if `value` is classified as a `Map` object. 17783 * 17784 * @static 17785 * @memberOf _ 17786 * @since 4.3.0 17787 * @category Lang 17788 * @param {*} value The value to check. 17789 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 17790 * @example 17791 * 17792 * _.isMap(new Map); 17793 * // => true 17794 * 17795 * _.isMap(new WeakMap); 17796 * // => false 17797 */ 17798 var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; 17799 17800 /** 17801 * Performs a partial deep comparison between `object` and `source` to 17802 * determine if `object` contains equivalent property values. 17803 * 17804 * **Note:** This method is equivalent to `_.matches` when `source` is 17805 * partially applied. 17806 * 17807 * Partial comparisons will match empty array and empty object `source` 17808 * values against any array or object value, respectively. See `_.isEqual` 17809 * for a list of supported value comparisons. 17810 * 17811 * @static 17812 * @memberOf _ 17813 * @since 3.0.0 17814 * @category Lang 17815 * @param {Object} object The object to inspect. 17816 * @param {Object} source The object of property values to match. 17817 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 17818 * @example 17819 * 17820 * var object = { 'a': 1, 'b': 2 }; 17821 * 17822 * _.isMatch(object, { 'b': 2 }); 17823 * // => true 17824 * 17825 * _.isMatch(object, { 'b': 1 }); 17826 * // => false 17827 */ 17828 function isMatch(object, source) { 17829 return object === source || baseIsMatch(object, source, getMatchData(source)); 17830 } 17831 17832 /** 17833 * This method is like `_.isMatch` except that it accepts `customizer` which 17834 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 17835 * are handled by the method instead. The `customizer` is invoked with five 17836 * arguments: (objValue, srcValue, index|key, object, source). 17837 * 17838 * @static 17839 * @memberOf _ 17840 * @since 4.0.0 17841 * @category Lang 17842 * @param {Object} object The object to inspect. 17843 * @param {Object} source The object of property values to match. 17844 * @param {Function} [customizer] The function to customize comparisons. 17845 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 17846 * @example 17847 * 17848 * function isGreeting(value) { 17849 * return /^h(?:i|ello)$/.test(value); 17850 * } 17851 * 17852 * function customizer(objValue, srcValue) { 17853 * if (isGreeting(objValue) && isGreeting(srcValue)) { 17854 * return true; 17855 * } 17856 * } 17857 * 17858 * var object = { 'greeting': 'hello' }; 17859 * var source = { 'greeting': 'hi' }; 17860 * 17861 * _.isMatchWith(object, source, customizer); 17862 * // => true 17863 */ 17864 function isMatchWith(object, source, customizer) { 17865 customizer = typeof customizer == 'function' ? customizer : undefined$1; 17866 return baseIsMatch(object, source, getMatchData(source), customizer); 17867 } 17868 17869 /** 17870 * Checks if `value` is `NaN`. 17871 * 17872 * **Note:** This method is based on 17873 * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as 17874 * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for 17875 * `undefined` and other non-number values. 17876 * 17877 * @static 17878 * @memberOf _ 17879 * @since 0.1.0 17880 * @category Lang 17881 * @param {*} value The value to check. 17882 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 17883 * @example 17884 * 17885 * _.isNaN(NaN); 17886 * // => true 17887 * 17888 * _.isNaN(new Number(NaN)); 17889 * // => true 17890 * 17891 * isNaN(undefined); 17892 * // => true 17893 * 17894 * _.isNaN(undefined); 17895 * // => false 17896 */ 17897 function isNaN(value) { 17898 // An `NaN` primitive is the only value that is not equal to itself. 17899 // Perform the `toStringTag` check first to avoid errors with some 17900 // ActiveX objects in IE. 17901 return isNumber(value) && value != +value; 17902 } 17903 17904 /** 17905 * Checks if `value` is a pristine native function. 17906 * 17907 * **Note:** This method can't reliably detect native functions in the presence 17908 * of the core-js package because core-js circumvents this kind of detection. 17909 * Despite multiple requests, the core-js maintainer has made it clear: any 17910 * attempt to fix the detection will be obstructed. As a result, we're left 17911 * with little choice but to throw an error. Unfortunately, this also affects 17912 * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill), 17913 * which rely on core-js. 17914 * 17915 * @static 17916 * @memberOf _ 17917 * @since 3.0.0 17918 * @category Lang 17919 * @param {*} value The value to check. 17920 * @returns {boolean} Returns `true` if `value` is a native function, 17921 * else `false`. 17922 * @example 17923 * 17924 * _.isNative(Array.prototype.push); 17925 * // => true 17926 * 17927 * _.isNative(_); 17928 * // => false 17929 */ 17930 function isNative(value) { 17931 if (isMaskable(value)) { 17932 throw new Error(CORE_ERROR_TEXT); 17933 } 17934 return baseIsNative(value); 17935 } 17936 17937 /** 17938 * Checks if `value` is `null`. 17939 * 17940 * @static 17941 * @memberOf _ 17942 * @since 0.1.0 17943 * @category Lang 17944 * @param {*} value The value to check. 17945 * @returns {boolean} Returns `true` if `value` is `null`, else `false`. 17946 * @example 17947 * 17948 * _.isNull(null); 17949 * // => true 17950 * 17951 * _.isNull(void 0); 17952 * // => false 17953 */ 17954 function isNull(value) { 17955 return value === null; 17956 } 17957 17958 /** 17959 * Checks if `value` is `null` or `undefined`. 17960 * 17961 * @static 17962 * @memberOf _ 17963 * @since 4.0.0 17964 * @category Lang 17965 * @param {*} value The value to check. 17966 * @returns {boolean} Returns `true` if `value` is nullish, else `false`. 17967 * @example 17968 * 17969 * _.isNil(null); 17970 * // => true 17971 * 17972 * _.isNil(void 0); 17973 * // => true 17974 * 17975 * _.isNil(NaN); 17976 * // => false 17977 */ 17978 function isNil(value) { 17979 return value == null; 17980 } 17981 17982 /** 17983 * Checks if `value` is classified as a `Number` primitive or object. 17984 * 17985 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are 17986 * classified as numbers, use the `_.isFinite` method. 17987 * 17988 * @static 17989 * @memberOf _ 17990 * @since 0.1.0 17991 * @category Lang 17992 * @param {*} value The value to check. 17993 * @returns {boolean} Returns `true` if `value` is a number, else `false`. 17994 * @example 17995 * 17996 * _.isNumber(3); 17997 * // => true 17998 * 17999 * _.isNumber(Number.MIN_VALUE); 18000 * // => true 18001 * 18002 * _.isNumber(Infinity); 18003 * // => true 18004 * 18005 * _.isNumber('3'); 18006 * // => false 18007 */ 18008 function isNumber(value) { 18009 return typeof value == 'number' || 18010 (isObjectLike(value) && baseGetTag(value) == numberTag); 18011 } 18012 18013 /** 18014 * Checks if `value` is a plain object, that is, an object created by the 18015 * `Object` constructor or one with a `[[Prototype]]` of `null`. 18016 * 18017 * @static 18018 * @memberOf _ 18019 * @since 0.8.0 18020 * @category Lang 18021 * @param {*} value The value to check. 18022 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. 18023 * @example 18024 * 18025 * function Foo() { 18026 * this.a = 1; 18027 * } 18028 * 18029 * _.isPlainObject(new Foo); 18030 * // => false 18031 * 18032 * _.isPlainObject([1, 2, 3]); 18033 * // => false 18034 * 18035 * _.isPlainObject({ 'x': 0, 'y': 0 }); 18036 * // => true 18037 * 18038 * _.isPlainObject(Object.create(null)); 18039 * // => true 18040 */ 18041 function isPlainObject(value) { 18042 if (!isObjectLike(value) || baseGetTag(value) != objectTag) { 18043 return false; 18044 } 18045 var proto = getPrototype(value); 18046 if (proto === null) { 18047 return true; 18048 } 18049 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; 18050 return typeof Ctor == 'function' && Ctor instanceof Ctor && 18051 funcToString.call(Ctor) == objectCtorString; 18052 } 18053 18054 /** 18055 * Checks if `value` is classified as a `RegExp` object. 18056 * 18057 * @static 18058 * @memberOf _ 18059 * @since 0.1.0 18060 * @category Lang 18061 * @param {*} value The value to check. 18062 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 18063 * @example 18064 * 18065 * _.isRegExp(/abc/); 18066 * // => true 18067 * 18068 * _.isRegExp('/abc/'); 18069 * // => false 18070 */ 18071 var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; 18072 18073 /** 18074 * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 18075 * double precision number which isn't the result of a rounded unsafe integer. 18076 * 18077 * **Note:** This method is based on 18078 * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). 18079 * 18080 * @static 18081 * @memberOf _ 18082 * @since 4.0.0 18083 * @category Lang 18084 * @param {*} value The value to check. 18085 * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. 18086 * @example 18087 * 18088 * _.isSafeInteger(3); 18089 * // => true 18090 * 18091 * _.isSafeInteger(Number.MIN_VALUE); 18092 * // => false 18093 * 18094 * _.isSafeInteger(Infinity); 18095 * // => false 18096 * 18097 * _.isSafeInteger('3'); 18098 * // => false 18099 */ 18100 function isSafeInteger(value) { 18101 return isInteger(value) && value >= -
vendor: 5,296 bytes, lines 18101-18302
18101MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER; 18102 } 18103 18104 /** 18105 * Checks if `value` is classified as a `Set` object. 18106 * 18107 * @static 18108 * @memberOf _ 18109 * @since 4.3.0 18110 * @category Lang 18111 * @param {*} value The value to check. 18112 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 18113 * @example 18114 * 18115 * _.isSet(new Set); 18116 * // => true 18117 * 18118 * _.isSet(new WeakSet); 18119 * // => false 18120 */ 18121 var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; 18122 18123 /** 18124 * Checks if `value` is classified as a `String` primitive or object. 18125 * 18126 * @static 18127 * @since 0.1.0 18128 * @memberOf _ 18129 * @category Lang 18130 * @param {*} value The value to check. 18131 * @returns {boolean} Returns `true` if `value` is a string, else `false`. 18132 * @example 18133 * 18134 * _.isString('abc'); 18135 * // => true 18136 * 18137 * _.isString(1); 18138 * // => false 18139 */ 18140 function isString(value) { 18141 return typeof value == 'string' || 18142 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); 18143 } 18144 18145 /** 18146 * Checks if `value` is classified as a `Symbol` primitive or object. 18147 * 18148 * @static 18149 * @memberOf _ 18150 * @since 4.0.0 18151 * @category Lang 18152 * @param {*} value The value to check. 18153 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. 18154 * @example 18155 * 18156 * _.isSymbol(Symbol.iterator); 18157 * // => true 18158 * 18159 * _.isSymbol('abc'); 18160 * // => false 18161 */ 18162 function isSymbol(value) { 18163 return typeof value == 'symbol' || 18164 (isObjectLike(value) && baseGetTag(value) == symbolTag); 18165 } 18166 18167 /** 18168 * Checks if `value` is classified as a typed array. 18169 * 18170 * @static 18171 * @memberOf _ 18172 * @since 3.0.0 18173 * @category Lang 18174 * @param {*} value The value to check. 18175 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 18176 * @example 18177 * 18178 * _.isTypedArray(new Uint8Array); 18179 * // => true 18180 * 18181 * _.isTypedArray([]); 18182 * // => false 18183 */ 18184 var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; 18185 18186 /** 18187 * Checks if `value` is `undefined`. 18188 * 18189 * @static 18190 * @since 0.1.0 18191 * @memberOf _ 18192 * @category Lang 18193 * @param {*} value The value to check. 18194 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. 18195 * @example 18196 * 18197 * _.isUndefined(void 0); 18198 * // => true 18199 * 18200 * _.isUndefined(null); 18201 * // => false 18202 */ 18203 function isUndefined(value) { 18204 return value === undefined$1; 18205 } 18206 18207 /** 18208 * Checks if `value` is classified as a `WeakMap` object. 18209 * 18210 * @static 18211 * @memberOf _ 18212 * @since 4.3.0 18213 * @category Lang 18214 * @param {*} value The value to check. 18215 * @returns {boolean} Returns `true` if `value` is a weak map, else `false`. 18216 * @example 18217 * 18218 * _.isWeakMap(new WeakMap); 18219 * // => true 18220 * 18221 * _.isWeakMap(new Map); 18222 * // => false 18223 */ 18224 function isWeakMap(value) { 18225 return isObjectLike(value) && getTag(value) == weakMapTag; 18226 } 18227 18228 /** 18229 * Checks if `value` is classified as a `WeakSet` object. 18230 * 18231 * @static 18232 * @memberOf _ 18233 * @since 4.3.0 18234 * @category Lang 18235 * @param {*} value The value to check. 18236 * @returns {boolean} Returns `true` if `value` is a weak set, else `false`. 18237 * @example 18238 * 18239 * _.isWeakSet(new WeakSet); 18240 * // => true 18241 * 18242 * _.isWeakSet(new Set); 18243 * // => false 18244 */ 18245 function isWeakSet(value) { 18246 return isObjectLike(value) && baseGetTag(value) == weakSetTag; 18247 } 18248 18249 /** 18250 * Checks if `value` is less than `other`. 18251 * 18252 * @static 18253 * @memberOf _ 18254 * @since 3.9.0 18255 * @category Lang 18256 * @param {*} value The value to compare. 18257 * @param {*} other The other value to compare. 18258 * @returns {boolean} Returns `true` if `value` is less than `other`, 18259 * else `false`. 18260 * @see _.gt 18261 * @example 18262 * 18263 * _.lt(1, 3); 18264 * // => true 18265 * 18266 * _.lt(3, 3); 18267 * // => false 18268 * 18269 * _.lt(3, 1); 18270 * // => false 18271 */ 18272 var lt = createRelationalOperation(baseLt); 18273 18274 /** 18275 * Checks if `value` is less than or equal to `other`. 18276 * 18277 * @static 18278 * @memberOf _ 18279 * @since 3.9.0 18280 * @category Lang 18281 * @param {*} value The value to compare. 18282 * @param {*} other The other value to compare. 18283 * @returns {boolean} Returns `true` if `value` is less than or equal to 18284 * `other`, else `false`. 18285 * @see _.gte 18286 * @example 18287 * 18288 * _.lte(1, 3); 18289 * // => true 18290 * 18291 * _.lte(3, 3); 18292 * // => true 18293 * 18294 * _.lte(3, 1); 18295 * // => false 18296 */ 18297 var lte = createRelationalOperation(function(value, other) { 18298 return value <= other; 18299 }); 18300 18301 /** 18302 * Converts `value` to an array.
18303 * 18304 * @static 18305 * @since 0.1.0 18306 * @memberOf _ 18307 * @category Lang 18308 * @param {*} value The value to convert. 18309 * @returns {Array} Returns the converted array. 18310 * @example 18311 * 18312 * _.toArray({ 'a': 1, 'b': 2 }); 18313 * // => [1, 2] 18314 * 18315 * _.toArray('abc'); 18316 * // => ['a', 'b', 'c'] 18317 * 18318 * _.toArray(1); 18319 * // => [] 18320 * 18321 * _.toArray(null); 18322 * // => [] 18323 */ 18324 function toArray(value) { 18325 if (!value) { 18326 return []; 18327 } 18328 if (isArrayLike(value)) { 18329 return isString(value) ? stringToArray(value) : copyArray(value); 18330 } 18331 if (symIterator && value[symIterator]) { 18332 return iteratorToArray(value[symIterator]()); 18333 } 18334 var tag = getTag(value), 18335 func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values); 18336 18337 return func(value); 18338 } 18339 18340 /** 18341 * Converts `value` to a finite number. 18342 * 18343 * @static 18344 * @memberOf _ 18345 * @since 4.12.0 18346 * @category Lang 18347 * @param {*} value The value to convert. 18348 * @returns {number} Returns the converted number. 18349 * @example 18350 * 18351 * _.toFinite(3.2); 18352 * // => 3.2 18353 * 18354 * _.toFinite(Number.MIN_VALUE); 18355 * // => 5e-324 18356 * 18357 * _.toFinite(Infinity); 18358 * // => 1.7976931348623157e+308 18359 * 18360 * _.toFinite('3.2'); 18361 * // => 3.2 18362 */ 18363 function toFinite(value) { 18364 if (!value) { 18365 return value === 0 ? value : 0; 18366 } 18367 value = toNumber(value); 18368 if (value === INFINITY || value === -INFINITY) { 18369 var sign = (value < 0 ? -1 : 1); 18370 return sign * MAX_INTEGER; 18371 } 18372 return value === value ? value : 0; 18373 } 18374 18375 /** 18376 * Converts `value` to an integer. 18377 * 18378 * **Note:** This method is loosely based on 18379 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). 18380 * 18381 * @static 18382 * @memberOf _ 18383 * @since 4.0.0 18384 * @category Lang 18385 * @param {*} value The value to convert. 18386 * @returns {number} Returns the converted integer. 18387 * @example 18388 * 18389 * _.toInteger(3.2); 18390 * // => 3 18391 * 18392 * _.toInteger(Number.MIN_VALUE); 18393 * // => 0 18394 * 18395 * _.toInteger(Infinity); 18396 * // => 1.7976931348623157e+308 18397 * 18398 * _.toInteger('3.2'); 18399 * // => 3 18400 */ 18401 function toInteger(value) { 18402 var result = toFinite(value), 18403 remainder = result % 1; 18404 18405 return result === result ? (remainder ? result - remainder : result) : 0; 18406 } 18407 18408 /** 18409 * Converts `value` to an integer suitable for use as the length of an 18410 * array-like object. 18411 * 18412 * **Note:** This method is based on 18413 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 18414 * 18415 * @static 18416 * @memberOf _ 18417 * @since 4.0.0 18418 * @category Lang 18419 * @param {*} value The value to convert. 18420 * @returns {number} Returns the converted integer. 18421 * @example 18422 * 18423 * _.toLength(3.2); 18424 * // => 3 18425 * 18426 * _.toLength(Number.MIN_VALUE); 18427 * // => 0 18428 * 18429 * _.toLength(Infinity); 18430 * // => 4294967295 18431 * 18432 * _.toLength('3.2'); 18433 * // => 3 18434 */ 18435 function toLength(value) { 18436 return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0; 18437 } 18438 18439 /** 18440 * Converts `value` to a number. 18441 * 18442 * @static 18443 * @memberOf _ 18444 * @since 4.0.0 18445 * @category Lang 18446 * @param {*} value The value to process. 18447 * @returns {number} Returns the number. 18448 * @example 18449 * 18450 * _.toNumber(3.2); 18451 * // => 3.2 18452 * 18453 * _.toNumber(Number.MIN_VALUE); 18454 * // => 5e-324 18455 * 18456 * _.toNumber(Infinity); 18457 * // => Infinity 18458 * 18459 * _.toNumber('3.2'); 18460 * // => 3.2 18461 */ 18462 function toNumber(value) { 18463 if (typeof value == 'number') { 18464 return value; 18465 } 18466 if (isSymbol(value)) { 18467 return NAN; 18468 } 18469 if (isObject(value)) { 18470 var other = typeof value.valueOf == 'function' ? value.valueOf() : value; 18471 value = isObject(other) ? (other + '') : other; 18472 } 18473 if (typeof value != 'string') { 18474 return value === 0 ? value : +value; 18475 } 18476 value = baseTrim(value); 18477 var isBinary = reIsBinary.test(value); 18478 return (isBinary || reIsOctal.test(value)) 18479 ? freeParseInt(value.slice(2), isBinary ? 2 : 8) 18480 : (reIsBadHex.test(value) ? NAN : +value); 18481 } 18482 18483 /** 18484 * Converts `value` to a plain object flattening inherited enumerable str
18484ing 18485 * keyed properties of `value` to own properties of the plain object. 18486 * 18487 * @static 18488 * @memberOf _ 18489 * @since 3.0.0 18490 * @category Lang 18491 * @param {*} value The value to convert. 18492 * @returns {Object} Returns the converted plain object. 18493 * @example 18494 * 18495 * function Foo() { 18496 * this.b = 2; 18497 * } 18498 * 18499 * Foo.prototype.c = 3; 18500 * 18501 * _.assign({ 'a': 1 }, new Foo); 18502 * // => { 'a': 1, 'b': 2 } 18503 * 18504 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); 18505 * // => { 'a': 1, 'b': 2, 'c': 3 } 18506 */ 18507 function toPlainObject(value) { 18508 return copyObject(value, keysIn(value)); 18509 } 18510 18511 /** 18512 * Converts `value` to a safe integer. A safe integer can be compared and 18513 * represented correctly. 18514 * 18515 * @static 18516 * @memberOf _ 18517 * @since 4.0.0 18518 * @category Lang 18519 * @param {*} value The value to convert. 18520 * @returns {number} Returns the converted integer. 18521 * @example 18522 * 18523 * _.toSafeInteger(3.2); 18524 * // => 3 18525 * 18526 * _.toSafeInteger(Number.MIN_VALUE); 18527 * // => 0 18528 * 18529 * _.toSafeInteger(Infinity); 18530 * // => 9007199254740991 18531 * 18532 * _.toSafeInteger('3.2'); 18533 * // => 3 18534 */ 18535 function toSafeInteger(value) { 18536 return value 18537 ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER
vendor: 49,772 bytes, lines 18537-20061
18537, MAX_SAFE_INTEGER) 18538 : (value === 0 ? value : 0); 18539 } 18540 18541 /** 18542 * Converts `value` to a string. An empty string is returned for `null` 18543 * and `undefined` values. The sign of `-0` is preserved. 18544 * 18545 * @static 18546 * @memberOf _ 18547 * @since 4.0.0 18548 * @category Lang 18549 * @param {*} value The value to convert. 18550 * @returns {string} Returns the converted string. 18551 * @example 18552 * 18553 * _.toString(null); 18554 * // => '' 18555 * 18556 * _.toString(-0); 18557 * // => '-0' 18558 * 18559 * _.toString([1, 2, 3]); 18560 * // => '1,2,3' 18561 */ 18562 function toString(value) { 18563 return value == null ? '' : baseToString(value); 18564 } 18565 18566 /*------------------------------------------------------------------------*/ 18567 18568 /** 18569 * Assigns own enumerable string keyed properties of source objects to the 18570 * destination object. Source objects are applied from left to right. 18571 * Subsequent sources overwrite property assignments of previous sources. 18572 * 18573 * **Note:** This method mutates `object` and is loosely based on 18574 * [`Object.assign`](https://mdn.io/Object/assign). 18575 * 18576 * @static 18577 * @memberOf _ 18578 * @since 0.10.0 18579 * @category Object 18580 * @param {Object} object The destination object. 18581 * @param {...Object} [sources] The source objects. 18582 * @returns {Object} Returns `object`. 18583 * @see _.assignIn 18584 * @example 18585 * 18586 * function Foo() { 18587 * this.a = 1; 18588 * } 18589 * 18590 * function Bar() { 18591 * this.c = 3; 18592 * } 18593 * 18594 * Foo.prototype.b = 2; 18595 * Bar.prototype.d = 4; 18596 * 18597 * _.assign({ 'a': 0 }, new Foo, new Bar); 18598 * // => { 'a': 1, 'c': 3 } 18599 */ 18600 var assign = createAssigner(function(object, source) { 18601 if (isPrototype(source) || isArrayLike(source)) { 18602 copyObject(source, keys(source), object); 18603 return; 18604 } 18605 for (var key in source) { 18606 if (hasOwnProperty.call(source, key)) { 18607 assignValue(object, key, source[key]); 18608 } 18609 } 18610 }); 18611 18612 /** 18613 * This method is like `_.assign` except that it iterates over own and 18614 * inherited source properties. 18615 * 18616 * **Note:** This method mutates `object`. 18617 * 18618 * @static 18619 * @memberOf _ 18620 * @since 4.0.0 18621 * @alias extend 18622 * @category Object 18623 * @param {Object} object The destination object. 18624 * @param {...Object} [sources] The source objects. 18625 * @returns {Object} Returns `object`. 18626 * @see _.assign 18627 * @example 18628 * 18629 * function Foo() { 18630 * this.a = 1; 18631 * } 18632 * 18633 * function Bar() { 18634 * this.c = 3; 18635 * } 18636 * 18637 * Foo.prototype.b = 2; 18638 * Bar.prototype.d = 4; 18639 * 18640 * _.assignIn({ 'a': 0 }, new Foo, new Bar); 18641 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } 18642 */ 18643 var assignIn = createAssigner(function(object, source) { 18644 copyObject(source, keysIn(source), object); 18645 }); 18646 18647 /** 18648 * This method is like `_.assignIn` except that it accepts `customizer` 18649 * which is invoked to produce the assigned values. If `customizer` returns 18650 * `undefined`, assignment is handled by the method instead. The `customizer` 18651 * is invoked with five arguments: (objValue, srcValue, key, object, source). 18652 * 18653 * **Note:** This method mutates `object`. 18654 * 18655 * @static 18656 * @memberOf _ 18657 * @since 4.0.0 18658 * @alias extendWith 18659 * @category Object 18660 * @param {Object} object The destination object. 18661 * @param {...Object} sources The source objects. 18662 * @param {Function} [customizer] The function to customize assigned values. 18663 * @returns {Object} Returns `object`. 18664 * @see _.assignWith 18665 * @example 18666 * 18667 * function customizer(objValue, srcValue) { 18668 * return _.isUndefined(objValue) ? srcValue : objValue; 18669 * } 18670 * 18671 * var defaults = _.partialRight(_.assignInWith, customizer); 18672 * 18673 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 18674 * // => { 'a': 1, 'b': 2 } 18675 */ 18676 var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { 18677 copyObject(source, keysIn(source), object, customizer); 18678 }); 18679 18680 /** 18681 * This method is like `_.assign` except that it accepts `customizer` 18682 * which is invoked to produce the assigned values. If `customizer` returns 18683 * `undefined`, assignment is handled by the method instead. The `customizer` 18684 * is invoked with five arguments: (objValue, srcValue, key, object, source). 18685 * 18686 * **Note:** This method mutates `object`. 18687 * 18688 * @static 18689 * @memberOf _ 18690 * @since 4.0.0 18691 * @category Object 18692 * @param {Object} object The destination object. 18693 * @param {...Object} sources The source objects. 18694 * @param {Function} [customizer] The function to customize assigned values. 18695 * @returns {Object} Returns `object`. 18696 * @see _.assignInWith 18697 * @example 18698 * 18699 * function customizer(objValue, srcValue) { 18700 * return _.isUndefined(objValue) ? srcValue : objValue; 18701 * } 18702 * 18703 * var defaults = _.partialRight(_.assignWith, customizer); 18704 * 18705 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 18706 * // => { 'a': 1, 'b': 2 } 18707 */ 18708 var assignWith = createAssigner(function(object, source, srcIndex, customizer) { 18709 copyObject(source, keys(source), object, customizer); 18710 }); 18711 18712 /** 18713 * Creates an array of values corresponding to `paths` of `object`. 18714 * 18715 * @static 18716 * @memberOf _ 18717 * @since 1.0.0 18718 * @category Object 18719 * @param {Object} object The object to iterate over. 18720 * @param {...(string|string[])} [paths] The property paths to pick. 18721 * @returns {Array} Returns the picked values. 18722 * @example 18723 * 18724 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 18725 * 18726 * _.at(object, ['a[0].b.c', 'a[1]']); 18727 * // => [3, 4] 18728 */ 18729 var at = flatRest(baseAt); 18730 18731 /** 18732 * Creates an object that inherits from the `prototype` object. If a 18733 * `properties` object is given, its own enumerable string keyed properties 18734 * are assigned to the created object. 18735 * 18736 * @static 18737 * @memberOf _ 18738 * @since 2.3.0 18739 * @category Object 18740 * @param {Object} prototype The object to inherit from. 18741 * @param {Object} [properties] The properties to assign to the object. 18742 * @returns {Object} Returns the new object. 18743 * @example 18744 * 18745 * function Shape() { 18746 * this.x = 0; 18747 * this.y = 0; 18748 * } 18749 * 18750 * function Circle() { 18751 * Shape.call(this); 18752 * } 18753 * 18754 * Circle.prototype = _.create(Shape.prototype, { 18755 * 'constructor': Circle 18756 * }); 18757 * 18758 * var circle = new Circle; 18759 * circle instanceof Circle; 18760 * // => true 18761 * 18762 * circle instanceof Shape; 18763 * // => true 18764 */ 18765 function create(prototype, properties) { 18766 var result = baseCreate(prototype); 18767 return properties == null ? result : baseAssign(result, properties); 18768 } 18769 18770 /** 18771 * Assigns own and inherited enumerable string keyed properties of source 18772 * objects to the destination object for all destination properties that 18773 * resolve to `undefined`. Source objects are applied from left to right. 18774 * Once a property is set, additional values of the same property are ignored. 18775 * 18776 * **Note:** This method mutates `object`. 18777 * 18778 * @static 18779 * @since 0.1.0 18780 * @memberOf _ 18781 * @category Object 18782 * @param {Object} object The destination object. 18783 * @param {...Object} [sources] The source objects. 18784 * @returns {Object} Returns `object`. 18785 * @see _.defaultsDeep 18786 * @example 18787 * 18788 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 18789 * // => { 'a': 1, 'b': 2 } 18790 */ 18791 var defaults = baseRest(function(object, sources) { 18792 object = Object(object); 18793 18794 var index = -1; 18795 var length = sources.length; 18796 var guard = length > 2 ? sources[2] : undefined$1; 18797 18798 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 18799 length = 1; 18800 } 18801 18802 while (++index < length) { 18803 var source = sources[index]; 18804 var props = keysIn(source); 18805 var propsIndex = -1; 18806 var propsLength = props.length; 18807 18808 while (++propsIndex < propsLength) { 18809 var key = props[propsIndex]; 18810 var value = object[key]; 18811 18812 if (value === undefined$1 || 18813 (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) { 18814 object[key] = source[key]; 18815 } 18816 } 18817 } 18818 18819 return object; 18820 }); 18821 18822 /** 18823 * This method is like `_.defaults` except that it recursively assigns 18824 * default properties. 18825 * 18826 * **Note:** This method mutates `object`. 18827 * 18828 * @static 18829 * @memberOf _ 18830 * @since 3.10.0 18831 * @category Object 18832 * @param {Object} object The destination object. 18833 * @param {...Object} [sources] The source objects. 18834 * @returns {Object} Returns `object`. 18835 * @see _.defaults 18836 * @example 18837 * 18838 * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); 18839 * // => { 'a': { 'b': 2, 'c': 3 } } 18840 */ 18841 var defaultsDeep = baseRest(function(args) { 18842 args.push(undefined$1, customDefaultsMerge); 18843 return apply(mergeWith, undefined$1, args); 18844 }); 18845 18846 /** 18847 * This method is like `_.find` except that it returns the key of the first 18848 * element `predicate` returns truthy for instead of the element itself. 18849 * 18850 * @static 18851 * @memberOf _ 18852 * @since 1.1.0 18853 * @category Object 18854 * @param {Object} object The object to inspect. 18855 * @param {Function} [predicate=_.identity] The function invoked per iteration. 18856 * @returns {string|undefined} Returns the key of the matched element, 18857 * else `undefined`. 18858 * @example 18859 * 18860 * var users = { 18861 * 'barney': { 'age': 36, 'active': true }, 18862 * 'fred': { 'age': 40, 'active': false }, 18863 * 'pebbles': { 'age': 1, 'active': true } 18864 * }; 18865 * 18866 * _.findKey(users, function(o) { return o.age < 40; }); 18867 * // => 'barney' (iteration order is not guaranteed) 18868 * 18869 * // The `_.matches` iteratee shorthand. 18870 * _.findKey(users, { 'age': 1, 'active': true }); 18871 * // => 'pebbles' 18872 * 18873 * // The `_.matchesProperty` iteratee shorthand. 18874 * _.findKey(users, ['active', false]); 18875 * // => 'fred' 18876 * 18877 * // The `_.property` iteratee shorthand. 18878 * _.findKey(users, 'active'); 18879 * // => 'barney' 18880 */ 18881 function findKey(object, predicate) { 18882 return baseFindKey(object, getIteratee(predicate, 3), baseForOwn); 18883 } 18884 18885 /** 18886 * This method is like `_.findKey` except that it iterates over elements of 18887 * a collection in the opposite order. 18888 * 18889 * @static 18890 * @memberOf _ 18891 * @since 2.0.0 18892 * @category Object 18893 * @param {Object} object The object to inspect. 18894 * @param {Function} [predicate=_.identity] The function invoked per iteration. 18895 * @returns {string|undefined} Returns the key of the matched element, 18896 * else `undefined`. 18897 * @example 18898 * 18899 * var users = { 18900 * 'barney': { 'age': 36, 'active': true }, 18901 * 'fred': { 'age': 40, 'active': false }, 18902 * 'pebbles': { 'age': 1, 'active': true } 18903 * }; 18904 * 18905 * _.findLastKey(users, function(o) { return o.age < 40; }); 18906 * // => returns 'pebbles' assuming `_.findKey` returns 'barney' 18907 * 18908 * // The `_.matches` iteratee shorthand. 18909 * _.findLastKey(users, { 'age': 36, 'active': true }); 18910 * // => 'barney' 18911 * 18912 * // The `_.matchesProperty` iteratee shorthand. 18913 * _.findLastKey(users, ['active', false]); 18914 * // => 'fred' 18915 * 18916 * // The `_.property` iteratee shorthand. 18917 * _.findLastKey(users, 'active'); 18918 * // => 'pebbles' 18919 */ 18920 function findLastKey(object, predicate) { 18921 return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight); 18922 } 18923 18924 /** 18925 * Iterates over own and inherited enumerable string keyed properties of an 18926 * object and invokes `iteratee` for each property. The iteratee is invoked 18927 * with three arguments: (value, key, object). Iteratee functions may exit 18928 * iteration early by explicitly returning `false`. 18929 * 18930 * @static 18931 * @memberOf _ 18932 * @since 0.3.0 18933 * @category Object 18934 * @param {Object} object The object to iterate over. 18935 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18936 * @returns {Object} Returns `object`. 18937 * @see _.forInRight 18938 * @example 18939 * 18940 * function Foo() { 18941 * this.a = 1; 18942 * this.b = 2; 18943 * } 18944 * 18945 * Foo.prototype.c = 3; 18946 * 18947 * _.forIn(new Foo, function(value, key) { 18948 * console.log(key); 18949 * }); 18950 * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). 18951 */ 18952 function forIn(object, iteratee) { 18953 return object == null 18954 ? object 18955 : baseFor(object, getIteratee(iteratee, 3), keysIn); 18956 } 18957 18958 /** 18959 * This method is like `_.forIn` except that it iterates over properties of 18960 * `object` in the opposite order. 18961 * 18962 * @static 18963 * @memberOf _ 18964 * @since 2.0.0 18965 * @category Object 18966 * @param {Object} object The object to iterate over. 18967 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18968 * @returns {Object} Returns `object`. 18969 * @see _.forIn 18970 * @example 18971 * 18972 * function Foo() { 18973 * this.a = 1; 18974 * this.b = 2; 18975 * } 18976 * 18977 * Foo.prototype.c = 3; 18978 * 18979 * _.forInRight(new Foo, function(value, key) { 18980 * console.log(key); 18981 * }); 18982 * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. 18983 */ 18984 function forInRight(object, iteratee) { 18985 return object == null 18986 ? object 18987 : baseForRight(object, getIteratee(iteratee, 3), keysIn); 18988 } 18989 18990 /** 18991 * Iterates over own enumerable string keyed properties of an object and 18992 * invokes `iteratee` for each property. The iteratee is invoked with three 18993 * arguments: (value, key, object). Iteratee functions may exit iteration 18994 * early by explicitly returning `false`. 18995 * 18996 * @static 18997 * @memberOf _ 18998 * @since 0.3.0 18999 * @category Object 19000 * @param {Object} object The object to iterate over. 19001 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 19002 * @returns {Object} Returns `object`. 19003 * @see _.forOwnRight 19004 * @example 19005 * 19006 * function Foo() { 19007 * this.a = 1; 19008 * this.b = 2; 19009 * } 19010 * 19011 * Foo.prototype.c = 3; 19012 * 19013 * _.forOwn(new Foo, function(value, key) { 19014 * console.log(key); 19015 * }); 19016 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 19017 */ 19018 function forOwn(object, iteratee) { 19019 return object && baseForOwn(object, getIteratee(iteratee, 3)); 19020 } 19021 19022 /** 19023 * This method is like `_.forOwn` except that it iterates over properties of 19024 * `object` in the opposite order. 19025 * 19026 * @static 19027 * @memberOf _ 19028 * @since 2.0.0 19029 * @category Object 19030 * @param {Object} object The object to iterate over. 19031 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 19032 * @returns {Object} Returns `object`. 19033 * @see _.forOwn 19034 * @example 19035 * 19036 * function Foo() { 19037 * this.a = 1; 19038 * this.b = 2; 19039 * } 19040 * 19041 * Foo.prototype.c = 3; 19042 * 19043 * _.forOwnRight(new Foo, function(value, key) { 19044 * console.log(key); 19045 * }); 19046 * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. 19047 */ 19048 function forOwnRight(object, iteratee) { 19049 return object && baseForOwnRight(object, getIteratee(iteratee, 3)); 19050 } 19051 19052 /** 19053 * Creates an array of function property names from own enumerable properties 19054 * of `object`. 19055 * 19056 * @static 19057 * @since 0.1.0 19058 * @memberOf _ 19059 * @category Object 19060 * @param {Object} object The object to inspect. 19061 * @returns {Array} Returns the function names. 19062 * @see _.functionsIn 19063 * @example 19064 * 19065 * function Foo() { 19066 * this.a = _.constant('a'); 19067 * this.b = _.constant('b'); 19068 * } 19069 * 19070 * Foo.prototype.c = _.constant('c'); 19071 * 19072 * _.functions(new Foo); 19073 * // => ['a', 'b'] 19074 */ 19075 function functions(object) { 19076 return object == null ? [] : baseFunctions(object, keys(object)); 19077 } 19078 19079 /** 19080 * Creates an array of function property names from own and inherited 19081 * enumerable properties of `object`. 19082 * 19083 * @static 19084 * @memberOf _ 19085 * @since 4.0.0 19086 * @category Object 19087 * @param {Object} object The object to inspect. 19088 * @returns {Array} Returns the function names. 19089 * @see _.functions 19090 * @example 19091 * 19092 * function Foo() { 19093 * this.a = _.constant('a'); 19094 * this.b = _.constant('b'); 19095 * } 19096 * 19097 * Foo.prototype.c = _.constant('c'); 19098 * 19099 * _.functionsIn(new Foo); 19100 * // => ['a', 'b', 'c'] 19101 */ 19102 function functionsIn(object) { 19103 return object == null ? [] : baseFunctions(object, keysIn(object)); 19104 } 19105 19106 /** 19107 * Gets the value at `path` of `object`. If the resolved value is 19108 * `undefined`, the `defaultValue` is returned in its place. 19109 * 19110 * @static 19111 * @memberOf _ 19112 * @since 3.7.0 19113 * @category Object 19114 * @param {Object} object The object to query. 19115 * @param {Array|string} path The path of the property to get. 19116 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 19117 * @returns {*} Returns the resolved value. 19118 * @example 19119 * 19120 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 19121 * 19122 * _.get(object, 'a[0].b.c'); 19123 * // => 3 19124 * 19125 * _.get(object, ['a', '0', 'b', 'c']); 19126 * // => 3 19127 * 19128 * _.get(object, 'a.b.c', 'default'); 19129 * // => 'default' 19130 */ 19131 function get(object, path, defaultValue) { 19132 var result = object == null ? undefined$1 : baseGet(object, path); 19133 return result === undefined$1 ? defaultValue : result; 19134 } 19135 19136 /** 19137 * Checks if `path` is a direct property of `object`. 19138 * 19139 * @static 19140 * @since 0.1.0 19141 * @memberOf _ 19142 * @category Object 19143 * @param {Object} object The object to query. 19144 * @param {Array|string} path The path to check. 19145 * @returns {boolean} Returns `true` if `path` exists, else `false`. 19146 * @example 19147 * 19148 * var object = { 'a': { 'b': 2 } }; 19149 * var other = _.create({ 'a': _.create({ 'b': 2 }) }); 19150 * 19151 * _.has(object, 'a'); 19152 * // => true 19153 * 19154 * _.has(object, 'a.b'); 19155 * // => true 19156 * 19157 * _.has(object, ['a', 'b']); 19158 * // => true 19159 * 19160 * _.has(other, 'a'); 19161 * // => false 19162 */ 19163 function has(object, path) { 19164 return object != null && hasPath(object, path, baseHas); 19165 } 19166 19167 /** 19168 * Checks if `path` is a direct or inherited property of `object`. 19169 * 19170 * @static 19171 * @memberOf _ 19172 * @since 4.0.0 19173 * @category Object 19174 * @param {Object} object The object to query. 19175 * @param {Array|string} path The path to check. 19176 * @returns {boolean} Returns `true` if `path` exists, else `false`. 19177 * @example 19178 * 19179 * var object = _.create({ 'a': _.create({ 'b': 2 }) }); 19180 * 19181 * _.hasIn(object, 'a'); 19182 * // => true 19183 * 19184 * _.hasIn(object, 'a.b'); 19185 * // => true 19186 * 19187 * _.hasIn(object, ['a', 'b']); 19188 * // => true 19189 * 19190 * _.hasIn(object, 'b'); 19191 * // => false 19192 */ 19193 function hasIn(object, path) { 19194 return object != null && hasPath(object, path, baseHasIn); 19195 } 19196 19197 /** 19198 * Creates an object composed of the inverted keys and values of `object`. 19199 * If `object` contains duplicate values, subsequent values overwrite 19200 * property assignments of previous values. 19201 * 19202 * @static 19203 * @memberOf _ 19204 * @since 0.7.0 19205 * @category Object 19206 * @param {Object} object The object to invert. 19207 * @returns {Object} Returns the new inverted object. 19208 * @example 19209 * 19210 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 19211 * 19212 * _.invert(object); 19213 * // => { '1': 'c', '2': 'b' } 19214 */ 19215 var invert = createInverter(function(result, value, key) { 19216 if (value != null && 19217 typeof value.toString != 'function') { 19218 value = nativeObjectToString.call(value); 19219 } 19220 19221 result[value] = key; 19222 }, constant(identity)); 19223 19224 /** 19225 * This method is like `_.invert` except that the inverted object is generated 19226 * from the results of running each element of `object` thru `iteratee`. The 19227 * corresponding inverted value of each inverted key is an array of keys 19228 * responsible for generating the inverted value. The iteratee is invoked 19229 * with one argument: (value). 19230 * 19231 * @static 19232 * @memberOf _ 19233 * @since 4.1.0 19234 * @category Object 19235 * @param {Object} object The object to invert. 19236 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 19237 * @returns {Object} Returns the new inverted object. 19238 * @example 19239 * 19240 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 19241 * 19242 * _.invertBy(object); 19243 * // => { '1': ['a', 'c'], '2': ['b'] } 19244 * 19245 * _.invertBy(object, function(value) { 19246 * return 'group' + value; 19247 * }); 19248 * // => { 'group1': ['a', 'c'], 'group2': ['b'] } 19249 */ 19250 var invertBy = createInverter(function(result, value, key) { 19251 if (value != null && 19252 typeof value.toString != 'function') { 19253 value = nativeObjectToString.call(value); 19254 } 19255 19256 if (hasOwnProperty.call(result, value)) { 19257 result[value].push(key); 19258 } else { 19259 result[value] = [key]; 19260 } 19261 }, getIteratee); 19262 19263 /** 19264 * Invokes the method at `path` of `object`. 19265 * 19266 * @static 19267 * @memberOf _ 19268 * @since 4.0.0 19269 * @category Object 19270 * @param {Object} object The object to query. 19271 * @param {Array|string} path The path of the method to invoke. 19272 * @param {...*} [args] The arguments to invoke the method with. 19273 * @returns {*} Returns the result of the invoked method. 19274 * @example 19275 * 19276 * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; 19277 * 19278 * _.invoke(object, 'a[0].b.c.slice', 1, 3); 19279 * // => [2, 3] 19280 */ 19281 var invoke = baseRest(baseInvoke); 19282 19283 /** 19284 * Creates an array of the own enumerable property names of `object`. 19285 * 19286 * **Note:** Non-object values are coerced to objects. See the 19287 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 19288 * for more details. 19289 * 19290 * @static 19291 * @since 0.1.0 19292 * @memberOf _ 19293 * @category Object 19294 * @param {Object} object The object to query. 19295 * @returns {Array} Returns the array of property names. 19296 * @example 19297 * 19298 * function Foo() { 19299 * this.a = 1; 19300 * this.b = 2; 19301 * } 19302 * 19303 * Foo.prototype.c = 3; 19304 * 19305 * _.keys(new Foo); 19306 * // => ['a', 'b'] (iteration order is not guaranteed) 19307 * 19308 * _.keys('hi'); 19309 * // => ['0', '1'] 19310 */ 19311 function keys(object) { 19312 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); 19313 } 19314 19315 /** 19316 * Creates an array of the own and inherited enumerable property names of `object`. 19317 * 19318 * **Note:** Non-object values are coerced to objects. 19319 * 19320 * @static 19321 * @memberOf _ 19322 * @since 3.0.0 19323 * @category Object 19324 * @param {Object} object The object to query. 19325 * @returns {Array} Returns the array of property names. 19326 * @example 19327 * 19328 * function Foo() { 19329 * this.a = 1; 19330 * this.b = 2; 19331 * } 19332 * 19333 * Foo.prototype.c = 3; 19334 * 19335 * _.keysIn(new Foo); 19336 * // => ['a', 'b', 'c'] (iteration order is not guaranteed) 19337 */ 19338 function keysIn(object) { 19339 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); 19340 } 19341 19342 /** 19343 * The opposite of `_.mapValues`; this method creates an object with the 19344 * same values as `object` and keys generated by running each own enumerable 19345 * string keyed property of `object` thru `iteratee`. The iteratee is invoked 19346 * with three arguments: (value, key, object). 19347 * 19348 * @static 19349 * @memberOf _ 19350 * @since 3.8.0 19351 * @category Object 19352 * @param {Object} object The object to iterate over. 19353 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 19354 * @returns {Object} Returns the new mapped object. 19355 * @see _.mapValues 19356 * @example 19357 * 19358 * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { 19359 * return key + value; 19360 * }); 19361 * // => { 'a1': 1, 'b2': 2 } 19362 */ 19363 function mapKeys(object, iteratee) { 19364 var result = {}; 19365 iteratee = getIteratee(iteratee, 3); 19366 19367 baseForOwn(object, function(value, key, object) { 19368 baseAssignValue(result, iteratee(value, key, object), value); 19369 }); 19370 return result; 19371 } 19372 19373 /** 19374 * Creates an object with the same keys as `object` and values generated 19375 * by running each own enumerable string keyed property of `object` thru 19376 * `iteratee`. The iteratee is invoked with three arguments: 19377 * (value, key, object). 19378 * 19379 * @static 19380 * @memberOf _ 19381 * @since 2.4.0 19382 * @category Object 19383 * @param {Object} object The object to iterate over. 19384 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 19385 * @returns {Object} Returns the new mapped object. 19386 * @see _.mapKeys 19387 * @example 19388 * 19389 * var users = { 19390 * 'fred': { 'user': 'fred', 'age': 40 }, 19391 * 'pebbles': { 'user': 'pebbles', 'age': 1 } 19392 * }; 19393 * 19394 * _.mapValues(users, function(o) { return o.age; }); 19395 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 19396 * 19397 * // The `_.property` iteratee shorthand. 19398 * _.mapValues(users, 'age'); 19399 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 19400 */ 19401 function mapValues(object, iteratee) { 19402 var result = {}; 19403 iteratee = getIteratee(iteratee, 3); 19404 19405 baseForOwn(object, function(value, key, object) { 19406 baseAssignValue(result, key, iteratee(value, key, object)); 19407 }); 19408 return result; 19409 } 19410 19411 /** 19412 * This method is like `_.assign` except that it recursively merges own and 19413 * inherited enumerable string keyed properties of source objects into the 19414 * destination object. Source properties that resolve to `undefined` are 19415 * skipped if a destination value exists. Array and plain object properties 19416 * are merged recursively. Other objects and value types are overridden by 19417 * assignment. Source objects are applied from left to right. Subsequent 19418 * sources overwrite property assignments of previous sources. 19419 * 19420 * **Note:** This method mutates `object`. 19421 * 19422 * @static 19423 * @memberOf _ 19424 * @since 0.5.0 19425 * @category Object 19426 * @param {Object} object The destination object. 19427 * @param {...Object} [sources] The source objects. 19428 * @returns {Object} Returns `object`. 19429 * @example 19430 * 19431 * var object = { 19432 * 'a': [{ 'b': 2 }, { 'd': 4 }] 19433 * }; 19434 * 19435 * var other = { 19436 * 'a': [{ 'c': 3 }, { 'e': 5 }] 19437 * }; 19438 * 19439 * _.merge(object, other); 19440 * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } 19441 */ 19442 var merge = createAssigner(function(object, source, srcIndex) { 19443 baseMerge(object, source, srcIndex); 19444 }); 19445 19446 /** 19447 * This method is like `_.merge` except that it accepts `customizer` which 19448 * is invoked to produce the merged values of the destination and source 19449 * properties. If `customizer` returns `undefined`, merging is handled by the 19450 * method instead. The `customizer` is invoked with six arguments: 19451 * (objValue, srcValue, key, object, source, stack). 19452 * 19453 * **Note:** This method mutates `object`. 19454 * 19455 * @static 19456 * @memberOf _ 19457 * @since 4.0.0 19458 * @category Object 19459 * @param {Object} object The destination object. 19460 * @param {...Object} sources The source objects. 19461 * @param {Function} customizer The function to customize assigned values. 19462 * @returns {Object} Returns `object`. 19463 * @example 19464 * 19465 * function customizer(objValue, srcValue) { 19466 * if (_.isArray(objValue)) { 19467 * return objValue.concat(srcValue); 19468 * } 19469 * } 19470 * 19471 * var object = { 'a': [1], 'b': [2] }; 19472 * var other = { 'a': [3], 'b': [4] }; 19473 * 19474 * _.mergeWith(object, other, customizer); 19475 * // => { 'a': [1, 3], 'b': [2, 4] } 19476 */ 19477 var mergeWith = createAssigner(function(object, source, srcIndex, customizer) { 19478 baseMerge(object, source, srcIndex, customizer); 19479 }); 19480 19481 /** 19482 * The opposite of `_.pick`; this method creates an object composed of the 19483 * own and inherited enumerable property paths of `object` that are not omitted. 19484 * 19485 * **Note:** This method is considerably slower than `_.pick`. 19486 * 19487 * @static 19488 * @since 0.1.0 19489 * @memberOf _ 19490 * @category Object 19491 * @param {Object} object The source object. 19492 * @param {...(string|string[])} [paths] The property paths to omit. 19493 * @returns {Object} Returns the new object. 19494 * @example 19495 * 19496 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 19497 * 19498 * _.omit(object, ['a', 'c']); 19499 * // => { 'b': '2' } 19500 */ 19501 var omit = flatRest(function(object, paths) { 19502 var result = {}; 19503 if (object == null) { 19504 return result; 19505 } 19506 var isDeep = false; 19507 paths = arrayMap(paths, function(path) { 19508 path = castPath(path, object); 19509 isDeep || (isDeep = path.length > 1); 19510 return path; 19511 }); 19512 copyObject(object, getAllKeysIn(object), result); 19513 if (isDeep) { 19514 result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone); 19515 } 19516 var length = paths.length; 19517 while (length--) { 19518 baseUnset(result, paths[length]); 19519 } 19520 return result; 19521 }); 19522 19523 /** 19524 * The opposite of `_.pickBy`; this method creates an object composed of 19525 * the own and inherited enumerable string keyed properties of `object` that 19526 * `predicate` doesn't return truthy for. The predicate is invoked with two 19527 * arguments: (value, key). 19528 * 19529 * @static 19530 * @memberOf _ 19531 * @since 4.0.0 19532 * @category Object 19533 * @param {Object} object The source object. 19534 * @param {Function} [predicate=_.identity] The function invoked per property. 19535 * @returns {Object} Returns the new object. 19536 * @example 19537 * 19538 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 19539 * 19540 * _.omitBy(object, _.isNumber); 19541 * // => { 'b': '2' } 19542 */ 19543 function omitBy(object, predicate) { 19544 return pickBy(object, negate(getIteratee(predicate))); 19545 } 19546 19547 /** 19548 * Creates an object composed of the picked `object` properties. 19549 * 19550 * @static 19551 * @since 0.1.0 19552 * @memberOf _ 19553 * @category Object 19554 * @param {Object} object The source object. 19555 * @param {...(string|string[])} [paths] The property paths to pick. 19556 * @returns {Object} Returns the new object. 19557 * @example 19558 * 19559 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 19560 * 19561 * _.pick(object, ['a', 'c']); 19562 * // => { 'a': 1, 'c': 3 } 19563 */ 19564 var pick = flatRest(function(object, paths) { 19565 return object == null ? {} : basePick(object, paths); 19566 }); 19567 19568 /** 19569 * Creates an object composed of the `object` properties `predicate` returns 19570 * truthy for. The predicate is invoked with two arguments: (value, key). 19571 * 19572 * @static 19573 * @memberOf _ 19574 * @since 4.0.0 19575 * @category Object 19576 * @param {Object} object The source object. 19577 * @param {Function} [predicate=_.identity] The function invoked per property. 19578 * @returns {Object} Returns the new object. 19579 * @example 19580 * 19581 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 19582 * 19583 * _.pickBy(object, _.isNumber); 19584 * // => { 'a': 1, 'c': 3 } 19585 */ 19586 function pickBy(object, predicate) { 19587 if (object == null) { 19588 return {}; 19589 } 19590 var props = arrayMap(getAllKeysIn(object), function(prop) { 19591 return [prop]; 19592 }); 19593 predicate = getIteratee(predicate); 19594 return basePickBy(object, props, function(value, path) { 19595 return predicate(value, path[0]); 19596 }); 19597 } 19598 19599 /** 19600 * This method is like `_.get` except that if the resolved value is a 19601 * function it's invoked with the `this` binding of its parent object and 19602 * its result is returned. 19603 * 19604 * @static 19605 * @since 0.1.0 19606 * @memberOf _ 19607 * @category Object 19608 * @param {Object} object The object to query. 19609 * @param {Array|string} path The path of the property to resolve. 19610 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 19611 * @returns {*} Returns the resolved value. 19612 * @example 19613 * 19614 * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; 19615 * 19616 * _.result(object, 'a[0].b.c1'); 19617 * // => 3 19618 * 19619 * _.result(object, 'a[0].b.c2'); 19620 * // => 4 19621 * 19622 * _.result(object, 'a[0].b.c3', 'default'); 19623 * // => 'default' 19624 * 19625 * _.result(object, 'a[0].b.c3', _.constant('default')); 19626 * // => 'default' 19627 */ 19628 function result(object, path, defaultValue) { 19629 path = castPath(path, object); 19630 19631 var index = -1, 19632 length = path.length; 19633 19634 // Ensure the loop is entered when path is empty. 19635 if (!length) { 19636 length = 1; 19637 object = undefined$1; 19638 } 19639 while (++index < length) { 19640 var value = object == null ? undefined$1 : object[toKey(path[index])]; 19641 if (value === undefined$1) { 19642 index = length; 19643 value = defaultValue; 19644 } 19645 object = isFunction(value) ? value.call(object) : value; 19646 } 19647 return object; 19648 } 19649 19650 /** 19651 * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, 19652 * it's created. Arrays are created for missing index properties while objects 19653 * are created for all other missing properties. Use `_.setWith` to customize 19654 * `path` creation. 19655 * 19656 * **Note:** This method mutates `object`. 19657 * 19658 * @static 19659 * @memberOf _ 19660 * @since 3.7.0 19661 * @category Object 19662 * @param {Object} object The object to modify. 19663 * @param {Array|string} path The path of the property to set. 19664 * @param {*} value The value to set. 19665 * @returns {Object} Returns `object`. 19666 * @example 19667 * 19668 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 19669 * 19670 * _.set(object, 'a[0].b.c', 4); 19671 * console.log(object.a[0].b.c); 19672 * // => 4 19673 * 19674 * _.set(object, ['x', '0', 'y', 'z'], 5); 19675 * console.log(object.x[0].y.z); 19676 * // => 5 19677 */ 19678 function set(object, path, value) { 19679 return object == null ? object : baseSet(object, path, value); 19680 } 19681 19682 /** 19683 * This method is like `_.set` except that it accepts `customizer` which is 19684 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 19685 * path creation is handled by the method instead. The `customizer` is invoked 19686 * with three arguments: (nsValue, key, nsObject). 19687 * 19688 * **Note:** This method mutates `object`. 19689 * 19690 * @static 19691 * @memberOf _ 19692 * @since 4.0.0 19693 * @category Object 19694 * @param {Object} object The object to modify. 19695 * @param {Array|string} path The path of the property to set. 19696 * @param {*} value The value to set. 19697 * @param {Function} [customizer] The function to customize assigned values. 19698 * @returns {Object} Returns `object`. 19699 * @example 19700 * 19701 * var object = {}; 19702 * 19703 * _.setWith(object, '[0][1]', 'a', Object); 19704 * // => { '0': { '1': 'a' } } 19705 */ 19706 function setWith(object, path, value, customizer) { 19707 customizer = typeof customizer == 'function' ? customizer : undefined$1; 19708 return object == null ? object : baseSet(object, path, value, customizer); 19709 } 19710 19711 /** 19712 * Creates an array of own enumerable string keyed-value pairs for `object` 19713 * which can be consumed by `_.fromPairs`. If `object` is a map or set, its 19714 * entries are returned. 19715 * 19716 * @static 19717 * @memberOf _ 19718 * @since 4.0.0 19719 * @alias entries 19720 * @category Object 19721 * @param {Object} object The object to query. 19722 * @returns {Array} Returns the key-value pairs. 19723 * @example 19724 * 19725 * function Foo() { 19726 * this.a = 1; 19727 * this.b = 2; 19728 * } 19729 * 19730 * Foo.prototype.c = 3; 19731 * 19732 * _.toPairs(new Foo); 19733 * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) 19734 */ 19735 var toPairs = createToPairs(keys); 19736 19737 /** 19738 * Creates an array of own and inherited enumerable string keyed-value pairs 19739 * for `object` which can be consumed by `_.fromPairs`. If `object` is a map 19740 * or set, its entries are returned. 19741 * 19742 * @static 19743 * @memberOf _ 19744 * @since 4.0.0 19745 * @alias entriesIn 19746 * @category Object 19747 * @param {Object} object The object to query. 19748 * @returns {Array} Returns the key-value pairs. 19749 * @example 19750 * 19751 * function Foo() { 19752 * this.a = 1; 19753 * this.b = 2; 19754 * } 19755 * 19756 * Foo.prototype.c = 3; 19757 * 19758 * _.toPairsIn(new Foo); 19759 * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) 19760 */ 19761 var toPairsIn = createToPairs(keysIn); 19762 19763 /** 19764 * An alternative to `_.reduce`; this method transforms `object` to a new 19765 * `accumulator` object which is the result of running each of its own 19766 * enumerable string keyed properties thru `iteratee`, with each invocation 19767 * potentially mutating the `accumulator` object. If `accumulator` is not 19768 * provided, a new object with the same `[[Prototype]]` will be used. The 19769 * iteratee is invoked with four arguments: (accumulator, value, key, object). 19770 * Iteratee functions may exit iteration early by explicitly returning `false`. 19771 * 19772 * @static 19773 * @memberOf _ 19774 * @since 1.3.0 19775 * @category Object 19776 * @param {Object} object The object to iterate over. 19777 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 19778 * @param {*} [accumulator] The custom accumulator value. 19779 * @returns {*} Returns the accumulated value. 19780 * @example 19781 * 19782 * _.transform([2, 3, 4], function(result, n) { 19783 * result.push(n *= n); 19784 * return n % 2 == 0; 19785 * }, []); 19786 * // => [4, 9] 19787 * 19788 * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 19789 * (result[value] || (result[value] = [])).push(key); 19790 * }, {}); 19791 * // => { '1': ['a', 'c'], '2': ['b'] } 19792 */ 19793 function transform(object, iteratee, accumulator) { 19794 var isArr = isArray(object), 19795 isArrLike = isArr || isBuffer(object) || isTypedArray(object); 19796 19797 iteratee = getIteratee(iteratee, 4); 19798 if (accumulator == null) { 19799 var Ctor = object && object.constructor; 19800 if (isArrLike) { 19801 accumulator = isArr ? new Ctor : []; 19802 } 19803 else if (isObject(object)) { 19804 accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; 19805 } 19806 else { 19807 accumulator = {}; 19808 } 19809 } 19810 (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) { 19811 return iteratee(accumulator, value, index, object); 19812 }); 19813 return accumulator; 19814 } 19815 19816 /** 19817 * Removes the property at `path` of `object`. 19818 * 19819 * **Note:** This method mutates `object`. 19820 * 19821 * @static 19822 * @memberOf _ 19823 * @since 4.0.0 19824 * @category Object 19825 * @param {Object} object The object to modify. 19826 * @param {Array|string} path The path of the property to unset. 19827 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 19828 * @example 19829 * 19830 * var object = { 'a': [{ 'b': { 'c': 7 } }] }; 19831 * _.unset(object, 'a[0].b.c'); 19832 * // => true 19833 * 19834 * console.log(object); 19835 * // => { 'a': [{ 'b': {} }] }; 19836 * 19837 * _.unset(object, ['a', '0', 'b', 'c']); 19838 * // => true 19839 * 19840 * console.log(object); 19841 * // => { 'a': [{ 'b': {} }] }; 19842 */ 19843 function unset(object, path) { 19844 return object == null ? true : baseUnset(object, path); 19845 } 19846 19847 /** 19848 * This method is like `_.set` except that accepts `updater` to produce the 19849 * value to set. Use `_.updateWith` to customize `path` creation. The `updater` 19850 * is invoked with one argument: (value). 19851 * 19852 * **Note:** This method mutates `object`. 19853 * 19854 * @static 19855 * @memberOf _ 19856 * @since 4.6.0 19857 * @category Object 19858 * @param {Object} object The object to modify. 19859 * @param {Array|string} path The path of the property to set. 19860 * @param {Function} updater The function to produce the updated value. 19861 * @returns {Object} Returns `object`. 19862 * @example 19863 * 19864 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 19865 * 19866 * _.update(object, 'a[0].b.c', function(n) { return n * n; }); 19867 * console.log(object.a[0].b.c); 19868 * // => 9 19869 * 19870 * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; }); 19871 * console.log(object.x[0].y.z); 19872 * // => 0 19873 */ 19874 function update(object, path, updater) { 19875 return object == null ? object : baseUpdate(object, path, castFunction(updater)); 19876 } 19877 19878 /** 19879 * This method is like `_.update` except that it accepts `customizer` which is 19880 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 19881 * path creation is handled by the method instead. The `customizer` is invoked 19882 * with three arguments: (nsValue, key, nsObject). 19883 * 19884 * **Note:** This method mutates `object`. 19885 * 19886 * @static 19887 * @memberOf _ 19888 * @since 4.6.0 19889 * @category Object 19890 * @param {Object} object The object to modify. 19891 * @param {Array|string} path The path of the property to set. 19892 * @param {Function} updater The function to produce the updated value. 19893 * @param {Function} [customizer] The function to customize assigned values. 19894 * @returns {Object} Returns `object`. 19895 * @example 19896 * 19897 * var object = {}; 19898 * 19899 * _.updateWith(object, '[0][1]', _.constant('a'), Object); 19900 * // => { '0': { '1': 'a' } } 19901 */ 19902 function updateWith(object, path, updater, customizer) { 19903 customizer = typeof customizer == 'function' ? customizer : undefined$1; 19904 return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer); 19905 } 19906 19907 /** 19908 * Creates an array of the own enumerable string keyed property values of `object`. 19909 * 19910 * **Note:** Non-object values are coerced to objects. 19911 * 19912 * @static 19913 * @since 0.1.0 19914 * @memberOf _ 19915 * @category Object 19916 * @param {Object} object The object to query. 19917 * @returns {Array} Returns the array of property values. 19918 * @example 19919 * 19920 * function Foo() { 19921 * this.a = 1; 19922 * this.b = 2; 19923 * } 19924 * 19925 * Foo.prototype.c = 3; 19926 * 19927 * _.values(new Foo); 19928 * // => [1, 2] (iteration order is not guaranteed) 19929 * 19930 * _.values('hi'); 19931 * // => ['h', 'i'] 19932 */ 19933 function values(object) { 19934 return object == null ? [] : baseValues(object, keys(object)); 19935 } 19936 19937 /** 19938 * Creates an array of the own and inherited enumerable string keyed property 19939 * values of `object`. 19940 * 19941 * **Note:** Non-object values are coerced to objects. 19942 * 19943 * @static 19944 * @memberOf _ 19945 * @since 3.0.0 19946 * @category Object 19947 * @param {Object} object The object to query. 19948 * @returns {Array} Returns the array of property values. 19949 * @example 19950 * 19951 * function Foo() { 19952 * this.a = 1; 19953 * this.b = 2; 19954 * } 19955 * 19956 * Foo.prototype.c = 3; 19957 * 19958 * _.valuesIn(new Foo); 19959 * // => [1, 2, 3] (iteration order is not guaranteed) 19960 */ 19961 function valuesIn(object) { 19962 return object == null ? [] : baseValues(object, keysIn(object)); 19963 } 19964 19965 /*------------------------------------------------------------------------*/ 19966 19967 /** 19968 * Clamps `number` within the inclusive `lower` and `upper` bounds. 19969 * 19970 * @static 19971 * @memberOf _ 19972 * @since 4.0.0 19973 * @category Number 19974 * @param {number} number The number to clamp. 19975 * @param {number} [lower] The lower bound. 19976 * @param {number} upper The upper bound. 19977 * @returns {number} Returns the clamped number. 19978 * @example 19979 * 19980 * _.clamp(-10, -5, 5); 19981 * // => -5 19982 * 19983 * _.clamp(10, -5, 5); 19984 * // => 5 19985 */ 19986 function clamp(number, lower, upper) { 19987 if (upper === undefined$1) { 19988 upper = lower; 19989 lower = undefined$1; 19990 } 19991 if (upper !== undefined$1) { 19992 upper = toNumber(upper); 19993 upper = upper === upper ? upper : 0; 19994 } 19995 if (lower !== undefined$1) { 19996 lower = toNumber(lower); 19997 lower = lower === lower ? lower : 0; 19998 } 19999 return baseClamp(toNumber(number), lower, upper); 20000 } 20001 20002 /** 20003 * Checks if `n` is between `start` and up to, but not including, `end`. If 20004 * `end` is not specified, it's set to `start` with `start` then set to `0`. 20005 * If `start` is greater than `end` the params are swapped to support 20006 * negative ranges. 20007 * 20008 * @static 20009 * @memberOf _ 20010 * @since 3.3.0 20011 * @category Number 20012 * @param {number} number The number to check. 20013 * @param {number} [start=0] The start of the range. 20014 * @param {number} end The end of the range. 20015 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 20016 * @see _.range, _.rangeRight 20017 * @example 20018 * 20019 * _.inRange(3, 2, 4); 20020 * // => true 20021 * 20022 * _.inRange(4, 8); 20023 * // => true 20024 * 20025 * _.inRange(4, 2); 20026 * // => false 20027 * 20028 * _.inRange(2, 2); 20029 * // => false 20030 * 20031 * _.inRange(1.2, 2); 20032 * // => true 20033 * 20034 * _.inRange(5.2, 4); 20035 * // => false 20036 * 20037 * _.inRange(-3, -2, -6); 20038 * // => true 20039 */ 20040 function inRange(number, start, end) { 20041 start = toFinite(start); 20042 if (end === undefined$1) { 20043 end = start; 20044 start = 0; 20045 } else { 20046 end = toFinite(end); 20047 } 20048 number = toNumber(number); 20049 return baseInRange(number, start, end); 20050 } 20051 20052 /** 20053 * Produces a random number between the inclusive `lower` and `upper` bounds. 20054 * If only one argument is provided a number between `0` and the given number 20055 * is returned. If `floating` is `true`, or either `lower` or `upper` are 20056 * floats, a floating-point number is returned instead of an integer. 20057 * 20058 * **Note:** JavaScript follows the IEEE-754 standard for resolving 20059 * floating-point values which can produce unexpected results. 20060 * 20061 *
20061@static 20062 * @memberOf _ 20063 * @since 0.7.0 20064 * @category Number 20065 * @param {number} [lower=0] The lower bound. 20066 * @param {number} [upper=1] The upper bound. 20067 * @param {boolean} [floating] Specify returning a floating-point number. 20068 * @returns {number} Returns the random number. 20069 * @example 20070 * 20071 * _.random(0, 5); 20072 * // => an integer between 0 and 5 20073 * 20074 * _.random(5); 20075 * // => also an integer between 0 and 5
vendor: 18,984 bytes, lines 20075-20678
20075 20076 * 20077 * _.random(5, true); 20078 * // => a floating-point number between 0 and 5 20079 * 20080 * _.random(1.2, 5.2); 20081 * // => a floating-point number between 1.2 and 5.2 20082 */ 20083 function random(lower, upper, floating) { 20084 if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) { 20085 upper = floating = undefined$1; 20086 } 20087 if (floating === undefined$1) { 20088 if (typeof upper == 'boolean') { 20089 floating = upper; 20090 upper = undefined$1; 20091 } 20092 else if (typeof lower == 'boolean') { 20093 floating = lower; 20094 lower = undefined$1; 20095 } 20096 } 20097 if (lower === undefined$1 && upper === undefined$1) { 20098 lower = 0; 20099 upper = 1; 20100 } 20101 else { 20102 lower = toFinite(lower); 20103 if (upper === undefined$1) { 20104 upper = lower; 20105 lower = 0; 20106 } else { 20107 upper = toFinite(upper); 20108 } 20109 } 20110 if (lower > upper) { 20111 var temp = lower; 20112 lower = upper; 20113 upper = temp; 20114 } 20115 if (floating || lower % 1 || upper % 1) { 20116 var rand = nativeRandom(); 20117 return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper); 20118 } 20119 return baseRandom(lower, upper); 20120 } 20121 20122 /*------------------------------------------------------------------------*/ 20123 20124 /** 20125 * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). 20126 * 20127 * @static 20128 * @memberOf _ 20129 * @since 3.0.0 20130 * @category String 20131 * @param {string} [string=''] The string to convert. 20132 * @returns {string} Returns the camel cased string. 20133 * @example 20134 * 20135 * _.camelCase('Foo Bar'); 20136 * // => 'fooBar' 20137 * 20138 * _.camelCase('--foo-bar--'); 20139 * // => 'fooBar' 20140 * 20141 * _.camelCase('__FOO_BAR__'); 20142 * // => 'fooBar' 20143 */ 20144 var camelCase = createCompounder(function(result, word, index) { 20145 word = word.toLowerCase(); 20146 return result + (index ? capitalize(word) : word); 20147 }); 20148 20149 /** 20150 * Converts the first character of `string` to upper case and the remaining 20151 * to lower case. 20152 * 20153 * @static 20154 * @memberOf _ 20155 * @since 3.0.0 20156 * @category String 20157 * @param {string} [string=''] The string to capitalize. 20158 * @returns {string} Returns the capitalized string. 20159 * @example 20160 * 20161 * _.capitalize('FRED'); 20162 * // => 'Fred' 20163 */ 20164 function capitalize(string) { 20165 return upperFirst(toString(string).toLowerCase()); 20166 } 20167 20168 /** 20169 * Deburrs `string` by converting 20170 * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) 20171 * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) 20172 * letters to basic Latin letters and removing 20173 * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). 20174 * 20175 * @static 20176 * @memberOf _ 20177 * @since 3.0.0 20178 * @category String 20179 * @param {string} [string=''] The string to deburr. 20180 * @returns {string} Returns the deburred string. 20181 * @example 20182 * 20183 * _.deburr('déjà vu'); 20184 * // => 'deja vu' 20185 */ 20186 function deburr(string) { 20187 string = toString(string); 20188 return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); 20189 } 20190 20191 /** 20192 * Checks if `string` ends with the given target string. 20193 * 20194 * @static 20195 * @memberOf _ 20196 * @since 3.0.0 20197 * @category String 20198 * @param {string} [string=''] The string to inspect. 20199 * @param {string} [target] The string to search for. 20200 * @param {number} [position=string.length] The position to search up to. 20201 * @returns {boolean} Returns `true` if `string` ends with `target`, 20202 * else `false`. 20203 * @example 20204 * 20205 * _.endsWith('abc', 'c'); 20206 * // => true 20207 * 20208 * _.endsWith('abc', 'b'); 20209 * // => false 20210 * 20211 * _.endsWith('abc', 'b', 2); 20212 * // => true 20213 */ 20214 function endsWith(string, target, position) { 20215 string = toString(string); 20216 target = baseToString(target); 20217 20218 var length = string.length; 20219 position = position === undefined$1 20220 ? length 20221 : baseClamp(toInteger(position), 0, length); 20222 20223 var end = position; 20224 position -= target.length; 20225 return position >= 0 && string.slice(position, end) == target; 20226 } 20227 20228 /** 20229 * Converts the characters "&", "<", ">", '"', and "'" in `string` to their 20230 * corresponding HTML entities. 20231 * 20232 * **Note:** No other characters are escaped. To escape additional 20233 * characters use a third-party library like [_he_](https://mths.be/he). 20234 * 20235 * Though the ">" character is escaped for symmetry, characters like 20236 * ">" and "/" don't need escaping in HTML and have no special meaning 20237 * unless they're part of a tag or unquoted attribute value. See 20238 * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) 20239 * (under "semi-related fun fact") for more details. 20240 * 20241 * When working with HTML you should always 20242 * [quote attribute values](http://wonko.com/post/html-escaping) to reduce 20243 * XSS vectors. 20244 * 20245 * @static 20246 * @since 0.1.0 20247 * @memberOf _ 20248 * @category String 20249 * @param {string} [string=''] The string to escape. 20250 * @returns {string} Returns the escaped string. 20251 * @example 20252 * 20253 * _.escape('fred, barney, & pebbles'); 20254 * // => 'fred, barney, & pebbles' 20255 */ 20256 function escape(string) { 20257 string = toString(string); 20258 return (string && reHasUnescapedHtml.test(string)) 20259 ? string.replace(reUnescapedHtml, escapeHtmlChar) 20260 : string; 20261 } 20262 20263 /** 20264 * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", 20265 * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. 20266 * 20267 * @static 20268 * @memberOf _ 20269 * @since 3.0.0 20270 * @category String 20271 * @param {string} [string=''] The string to escape. 20272 * @returns {string} Returns the escaped string. 20273 * @example 20274 * 20275 * _.escapeRegExp('[lodash](https://lodash.com/)'); 20276 * // => '\[lodash\]\(https://lodash\.com/\)' 20277 */ 20278 function escapeRegExp(string) { 20279 string = toString(string); 20280 return (string && reHasRegExpChar.test(string)) 20281 ? string.replace(reRegExpChar, '\\$&') 20282 : string; 20283 } 20284 20285 /** 20286 * Converts `string` to 20287 * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). 20288 * 20289 * @static 20290 * @memberOf _ 20291 * @since 3.0.0 20292 * @category String 20293 * @param {string} [string=''] The string to convert. 20294 * @returns {string} Returns the kebab cased string. 20295 * @example 20296 * 20297 * _.kebabCase('Foo Bar'); 20298 * // => 'foo-bar' 20299 * 20300 * _.kebabCase('fooBar'); 20301 * // => 'foo-bar' 20302 * 20303 * _.kebabCase('__FOO_BAR__'); 20304 * // => 'foo-bar' 20305 */ 20306 var kebabCase = createCompounder(function(result, word, index) { 20307 return result + (index ? '-' : '') + word.toLowerCase(); 20308 }); 20309 20310 /** 20311 * Converts `string`, as space separated words, to lower case. 20312 * 20313 * @static 20314 * @memberOf _ 20315 * @since 4.0.0 20316 * @category String 20317 * @param {string} [string=''] The string to convert. 20318 * @returns {string} Returns the lower cased string. 20319 * @example 20320 * 20321 * _.lowerCase('--Foo-Bar--'); 20322 * // => 'foo bar' 20323 * 20324 * _.lowerCase('fooBar'); 20325 * // => 'foo bar' 20326 * 20327 * _.lowerCase('__FOO_BAR__'); 20328 * // => 'foo bar' 20329 */ 20330 var lowerCase = createCompounder(function(result, word, index) { 20331 return result + (index ? ' ' : '') + word.toLowerCase(); 20332 }); 20333 20334 /** 20335 * Converts the first character of `string` to lower case. 20336 * 20337 * @static 20338 * @memberOf _ 20339 * @since 4.0.0 20340 * @category String 20341 * @param {string} [string=''] The string to convert. 20342 * @returns {string} Returns the converted string. 20343 * @example 20344 * 20345 * _.lowerFirst('Fred'); 20346 * // => 'fred' 20347 * 20348 * _.lowerFirst('FRED'); 20349 * // => 'fRED' 20350 */ 20351 var lowerFirst = createCaseFirst('toLowerCase'); 20352 20353 /** 20354 * Pads `string` on the left and right sides if it's shorter than `length`. 20355 * Padding characters are truncated if they can't be evenly divided by `length`. 20356 * 20357 * @static 20358 * @memberOf _ 20359 * @since 3.0.0 20360 * @category String 20361 * @param {string} [string=''] The string to pad. 20362 * @param {number} [length=0] The padding length. 20363 * @param {string} [chars=' '] The string used as padding. 20364 * @returns {string} Returns the padded string. 20365 * @example 20366 * 20367 * _.pad('abc', 8); 20368 * // => ' abc ' 20369 * 20370 * _.pad('abc', 8, '_-'); 20371 * // => '_-abc_-_' 20372 * 20373 * _.pad('abc', 3); 20374 * // => 'abc' 20375 */ 20376 function pad(string, length, chars) { 20377 string = toString(string); 20378 length = toInteger(length); 20379 20380 var strLength = length ? stringSize(string) : 0; 20381 if (!length || strLength >= length) { 20382 return string; 20383 } 20384 var mid = (length - strLength) / 2; 20385 return ( 20386 createPadding(nativeFloor(mid), chars) + 20387 string + 20388 createPadding(nativeCeil(mid), chars) 20389 ); 20390 } 20391 20392 /** 20393 * Pads `string` on the right side if it's shorter than `length`. Padding 20394 * characters are truncated if they exceed `length`. 20395 * 20396 * @static 20397 * @memberOf _ 20398 * @since 4.0.0 20399 * @category String 20400 * @param {string} [string=''] The string to pad. 20401 * @param {number} [length=0] The padding length. 20402 * @param {string} [chars=' '] The string used as padding. 20403 * @returns {string} Returns the padded string. 20404 * @example 20405 * 20406 * _.padEnd('abc', 6); 20407 * // => 'abc ' 20408 * 20409 * _.padEnd('abc', 6, '_-'); 20410 * // => 'abc_-_' 20411 * 20412 * _.padEnd('abc', 3); 20413 * // => 'abc' 20414 */ 20415 function padEnd(string, length, chars) { 20416 string = toString(string); 20417 length = toInteger(length); 20418 20419 var strLength = length ? stringSize(string) : 0; 20420 return (length && strLength < length) 20421 ? (string + createPadding(length - strLength, chars)) 20422 : string; 20423 } 20424 20425 /** 20426 * Pads `string` on the left side if it's shorter than `length`. Padding 20427 * characters are truncated if they exceed `length`. 20428 * 20429 * @static 20430 * @memberOf _ 20431 * @since 4.0.0 20432 * @category String 20433 * @param {string} [string=''] The string to pad. 20434 * @param {number} [length=0] The padding length. 20435 * @param {string} [chars=' '] The string used as padding. 20436 * @returns {string} Returns the padded string. 20437 * @example 20438 * 20439 * _.padStart('abc', 6); 20440 * // => ' abc' 20441 * 20442 * _.padStart('abc', 6, '_-'); 20443 * // => '_-_abc' 20444 * 20445 * _.padStart('abc', 3); 20446 * // => 'abc' 20447 */ 20448 function padStart(string, length, chars) { 20449 string = toString(string); 20450 length = toInteger(length); 20451 20452 var strLength = length ? stringSize(string) : 0; 20453 return (length && strLength < length) 20454 ? (createPadding(length - strLength, chars) + string) 20455 : string; 20456 } 20457 20458 /** 20459 * Converts `string` to an integer of the specified radix. If `radix` is 20460 * `undefined` or `0`, a `radix` of `10` is used unless `value` is a 20461 * hexadecimal, in which case a `radix` of `16` is used. 20462 * 20463 * **Note:** This method aligns with the 20464 * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. 20465 * 20466 * @static 20467 * @memberOf _ 20468 * @since 1.1.0 20469 * @category String 20470 * @param {string} string The string to convert. 20471 * @param {number} [radix=10] The radix to interpret `value` by. 20472 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 20473 * @returns {number} Returns the converted integer. 20474 * @example 20475 * 20476 * _.parseInt('08'); 20477 * // => 8 20478 * 20479 * _.map(['6', '08', '10'], _.parseInt); 20480 * // => [6, 8, 10] 20481 */ 20482 function parseInt(string, radix, guard) { 20483 if (guard || radix == null) { 20484 radix = 0; 20485 } else if (radix) { 20486 radix = +radix; 20487 } 20488 return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0); 20489 } 20490 20491 /** 20492 * Repeats the given string `n` times. 20493 * 20494 * @static 20495 * @memberOf _ 20496 * @since 3.0.0 20497 * @category String 20498 * @param {string} [string=''] The string to repeat. 20499 * @param {number} [n=1] The number of times to repeat the string. 20500 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 20501 * @returns {string} Returns the repeated string. 20502 * @example 20503 * 20504 * _.repeat('*', 3); 20505 * // => '***' 20506 * 20507 * _.repeat('abc', 2); 20508 * // => 'abcabc' 20509 * 20510 * _.repeat('abc', 0); 20511 * // => '' 20512 */ 20513 function repeat(string, n, guard) { 20514 if ((guard ? isIterateeCall(string, n, guard) : n === undefined$1)) { 20515 n = 1; 20516 } else { 20517 n = toInteger(n); 20518 } 20519 return baseRepeat(toString(string), n); 20520 } 20521 20522 /** 20523 * Replaces matches for `pattern` in `string` with `replacement`. 20524 * 20525 * **Note:** This method is based on 20526 * [`String#replace`](https://mdn.io/String/replace). 20527 * 20528 * @static 20529 * @memberOf _ 20530 * @since 4.0.0 20531 * @category String 20532 * @param {string} [string=''] The string to modify. 20533 * @param {RegExp|string} pattern The pattern to replace. 20534 * @param {Function|string} replacement The match replacement. 20535 * @returns {string} Returns the modified string. 20536 * @example 20537 * 20538 * _.replace('Hi Fred', 'Fred', 'Barney'); 20539 * // => 'Hi Barney' 20540 */ 20541 function replace() { 20542 var args = arguments, 20543 string = toString(args[0]); 20544 20545 return args.length < 3 ? string : string.replace(args[1], args[2]); 20546 } 20547 20548 /** 20549 * Converts `string` to 20550 * [snake case](https://en.wikipedia.org/wiki/Snake_case). 20551 * 20552 * @static 20553 * @memberOf _ 20554 * @since 3.0.0 20555 * @category String 20556 * @param {string} [string=''] The string to convert. 20557 * @returns {string} Returns the snake cased string. 20558 * @example 20559 * 20560 * _.snakeCase('Foo Bar'); 20561 * // => 'foo_bar' 20562 * 20563 * _.snakeCase('fooBar'); 20564 * // => 'foo_bar' 20565 * 20566 * _.snakeCase('--FOO-BAR--'); 20567 * // => 'foo_bar' 20568 */ 20569 var snakeCase = createCompounder(function(result, word, index) { 20570 return result + (index ? '_' : '') + word.toLowerCase(); 20571 }); 20572 20573 /** 20574 * Splits `string` by `separator`. 20575 * 20576 * **Note:** This method is based on 20577 * [`String#split`](https://mdn.io/String/split). 20578 * 20579 * @static 20580 * @memberOf _ 20581 * @since 4.0.0 20582 * @category String 20583 * @param {string} [string=''] The string to split. 20584 * @param {RegExp|string} separator The separator pattern to split by. 20585 * @param {number} [limit] The length to truncate results to. 20586 * @returns {Array} Returns the string segments. 20587 * @example 20588 * 20589 * _.split('a-b-c', '-', 2); 20590 * // => ['a', 'b'] 20591 */ 20592 function split(string, separator, limit) { 20593 if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) { 20594 separator = limit = undefined$1; 20595 } 20596 limit = limit === undefined$1 ? MAX_ARRAY_LENGTH : limit >>> 0; 20597 if (!limit) { 20598 return []; 20599 } 20600 string = toString(string); 20601 if (string && ( 20602 typeof separator == 'string' || 20603 (separator != null && !isRegExp(separator)) 20604 )) { 20605 separator = baseToString(separator); 20606 if (!separator && hasUnicode(string)) { 20607 return castSlice(stringToArray(string), 0, limit); 20608 } 20609 } 20610 return string.split(separator, limit); 20611 } 20612 20613 /** 20614 * Converts `string` to 20615 * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). 20616 * 20617 * @static 20618 * @memberOf _ 20619 * @since 3.1.0 20620 * @category String 20621 * @param {string} [string=''] The string to convert. 20622 * @returns {string} Returns the start cased string. 20623 * @example 20624 * 20625 * _.startCase('--foo-bar--'); 20626 * // => 'Foo Bar' 20627 * 20628 * _.startCase('fooBar'); 20629 * // => 'Foo Bar' 20630 * 20631 * _.startCase('__FOO_BAR__'); 20632 * // => 'FOO BAR' 20633 */ 20634 var startCase = createCompounder(function(result, word, index) { 20635 return result + (index ? ' ' : '') + upperFirst(word); 20636 }); 20637 20638 /** 20639 * Checks if `string` starts with the given target string. 20640 * 20641 * @static 20642 * @memberOf _ 20643 * @since 3.0.0 20644 * @category String 20645 * @param {string} [string=''] The string to inspect. 20646 * @param {string} [target] The string to search for. 20647 * @param {number} [position=0] The position to search from. 20648 * @returns {boolean} Returns `true` if `string` starts with `target`, 20649 * else `false`. 20650 * @example 20651 * 20652 * _.startsWith('abc', 'a'); 20653 * // => true 20654 * 20655 * _.startsWith('abc', 'b'); 20656 * // => false 20657 * 20658 * _.startsWith('abc', 'b', 1); 20659 * // => true 20660 */ 20661 function startsWith(string, target, position) { 20662 string = toString(string); 20663 position = position == null 20664 ? 0 20665 : baseClamp(toInteger(position), 0, string.length); 20666 20667 target = baseToString(target); 20668 return string.slice(position, position + target.length) == target; 20669 } 20670 20671 /** 20672 * Creates a compiled template function that can interpolate data properties 20673 * in "interpolate" delimiters, HTML-escape interpolated data properties in 20674 * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data 20675 * properties may be accessed as free variables in the template. If a setting 20676 * object is given, it takes precedence over `_.templateSettings` values. 20677 * 20678 * **
20678Note:** In the development build `_.template` utilizes 20679 * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) 20680 * for easier debugging. 20681 * 20682 * For more information on precompiling templates see 20683 * [lodash's custom builds documentation](https://lodash.com/custom-builds). 20684 * 20685 * For more information on Chrome extension sandboxes see 20686 * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). 20687 * 20688 * @static 20689 * @since 0.1.0 20690 * @memberOf _ 20691 * @category String 20692 * @param {string} [string=''] The template string. 20693 * @param {Object} [options={}] The options object. 20694 * @param {RegExp} [options.escape=_.templateSettings.escape] 20695 * The HTML "escape" delimiter. 20696 * @param {RegExp} [options.evaluate=_.templateSettings.evaluate] 20697 * The "evaluate" delimiter. 20698 * @param {Object} [options.imports=_.templateSettings.imports] 20699 * An object to import into the template as free variables. 20700 * @param {RegExp} [options.interpolate=_.templateSettings.interpolate] 20701 * The "interpolate" delimiter. 20702 * @param {string} [options.sourceURL='lodash.templateSources[n]'] 20703 * The sourceURL of the compiled template. 20704 * @param {string} [options.variable='obj'] 20705 * The data object variable name. 20706 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 20707 * @returns {Function} Returns the compiled template function. 20708 * @example 20709 * 20710 * // Use the "interpolate" delimiter to create a compiled template. 20711 * var compiled = _.template('hello <%= user %>!'); 20712 * compiled({ 'user': 'fred' }); 20713 * // => 'hello fred!' 20714 * 20715 * // Use the HTML "escape" delimiter to escape data property values. 20716 * var compiled = _.template('<b><%- value %></b>'); 20717 * compiled({ 'value': '<script>' }); 20718 * // => '<b><script></b>' 20719 * 20720 * // Use the "evaluate" delimiter to execute JavaScript and generate HTML. 20721 * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>'); 20722 * compiled({ 'users': ['fred', 'barney'] }); 20723 * // => '<li>fred</li><li>barney</li>' 20724 * 20725 * // Use the internal `print` function in "evaluate" delimiters. 20726 * var compiled = _.template('<% print("hello " + user); %>!'); 20727 * compiled({ 'user': 'barney' }); 20728 * // => 'hello barney!' 20729 * 20730 * // Use the ES template literal delimiter as an "interpolate" delimiter. 20731 * // Disable support by replacing the "interpolate" delimiter. 20732 * var compiled = _.template('hello ${ user }!'); 20733 * compiled({ 'user': 'pebbles' }); 20734 * // => 'hello pebbles!' 20735 * 20736 * // Use backslashes to treat delimiters as plain text. 20737 * var compiled = _.template('<%= "\\<%- value %\\>" %>'); 20738 * compiled({ 'value': 'ignored' }); 20739 * // => '<%- value %>' 20740 * 20741 * // Use the `imports` option to import `jQuery` as `jq`. 20742 * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>'; 20743 * var compiled = _.template(text, { 'imports': { 'jq': jQuery } }); 20744 * compiled({ 'users': ['fred', 'barney'] }); 20745 * // => '<li>fred</li><li>barney</li>' 20746 * 20747 * // Use the `sourceURL` option to specify a custom sourceURL for the template. 20748 * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' }); 20749 * compiled(data); 20750 * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector. 20751 * 20752 * // Use the `variable` option to ensure a with-statement isn't used in the compiled template. 20753 * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); 20754 * compiled.source; 20755 * // => function(data) { 20756 * // var __t, __p = ''; 20757 * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; 20758 * // return __p; 20759 * // } 20760 * 20761 * // Use custom template delimiters. 20762 * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g; 20763 * var compiled = _.template('hello {{ user }}!'); 20764 * compiled({ 'user': 'mustache' }); 20765 * // => 'hello mustache!' 20766 * 20767 * // Use the `source` property to inline compiled templates for meaningful 20768 * // line numbers in error messages and stack traces. 20769 * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\ 20770 * var JST = {\ 20771 * "main": ' + _.template(mainText).source + '\ 20772 * };\ 20773 * '); 20774 */ 20775 function template(string, options, guard) { 20776 // Based on John Resig's `tmpl` implementation 20777 // (http://ejohn.org/blog/javascript-micro-templating/) 20778 // and Laura Doktorova's doT.js (https://github.com/olado/doT). 20779 var settings = lodash.templateSettings; 20780 20781 if (guard && isIterateeCall(string, options, guard)) { 20782 options = undefined$1; 20783 }
20784 string = toString(string); 20785 options = assignInWith({}, options, settings, customDefaultsAssignIn); 20786 20787 var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn), 20788 importsKeys = keys(imports), 20789 importsValues = baseValues(imports, importsKeys
vendor: 74,185 bytes, lines 20789-23136
20789); 20790 20791 var isEscaping, 20792 isEvaluating, 20793 index = 0, 20794 interpolate = options.interpolate || reNoMatch, 20795 source = "__p += '"; 20796 20797 // Compile the regexp to match each delimiter. 20798 var reDelimiters = RegExp( 20799 (options.escape || reNoMatch).source + '|' + 20800 interpolate.source + '|' + 20801 (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' + 20802 (options.evaluate || reNoMatch).source + '|$' 20803 , 'g'); 20804 20805 // Use a sourceURL for easier debugging. 20806 // The sourceURL gets injected into the source that's eval-ed, so be careful 20807 // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in 20808 // and escape the comment, thus injecting code that gets evaled. 20809 var sourceURL = '//# sourceURL=' + 20810 (hasOwnProperty.call(options, 'sourceURL') 20811 ? (options.sourceURL + '').replace(/\s/g, ' ') 20812 : ('lodash.templateSources[' + (++templateCounter) + ']') 20813 ) + '\n'; 20814 20815 string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { 20816 interpolateValue || (interpolateValue = esTemplateValue); 20817 20818 // Escape characters that can't be included in string literals. 20819 source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); 20820 20821 // Replace delimiters with snippets. 20822 if (escapeValue) { 20823 isEscaping = true; 20824 source += "' +\n__e(" + escapeValue + ") +\n'"; 20825 } 20826 if (evaluateValue) { 20827 isEvaluating = true; 20828 source += "';\n" + evaluateValue + ";\n__p += '"; 20829 } 20830 if (interpolateValue) { 20831 source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'"; 20832 } 20833 index = offset + match.length; 20834 20835 // The JS engine embedded in Adobe products needs `match` returned in 20836 // order to produce the correct `offset` value. 20837 return match; 20838 }); 20839 20840 source += "';\n"; 20841 20842 // If `variable` is not specified wrap a with-statement around the generated 20843 // code to add the data object to the top of the scope chain. 20844 var variable = hasOwnProperty.call(options, 'variable') && options.variable; 20845 if (!variable) { 20846 source = 'with (obj) {\n' + source + '\n}\n'; 20847 } 20848 // Throw an error if a forbidden character was found in `variable`, to prevent 20849 // potential command injection attacks. 20850 else if (reForbiddenIdentifierChars.test(variable)) { 20851 throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT); 20852 } 20853 20854 // Cleanup code by stripping empty strings. 20855 source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source) 20856 .replace(reEmptyStringMiddle, '$1') 20857 .replace(reEmptyStringTrailing, '$1;'); 20858 20859 // Frame code as the function body. 20860 source = 'function(' + (variable || 'obj') + ') {\n' + 20861 (variable 20862 ? '' 20863 : 'obj || (obj = {});\n' 20864 ) + 20865 "var __t, __p = ''" + 20866 (isEscaping 20867 ? ', __e = _.escape' 20868 : '' 20869 ) + 20870 (isEvaluating 20871 ? ', __j = Array.prototype.join;\n' + 20872 "function print() { __p += __j.call(arguments, '') }\n" 20873 : ';\n' 20874 ) + 20875 source + 20876 'return __p\n}'; 20877 20878 var result = attempt(function() { 20879 return Function(importsKeys, sourceURL + 'return ' + source) 20880 .apply(undefined$1, importsValues); 20881 }); 20882 20883 // Provide the compiled function's source by its `toString` method or 20884 // the `source` property as a convenience for inlining compiled templates. 20885 result.source = source; 20886 if (isError(result)) { 20887 throw result; 20888 } 20889 return result; 20890 } 20891 20892 /** 20893 * Converts `string`, as a whole, to lower case just like 20894 * [String#toLowerCase](https://mdn.io/toLowerCase). 20895 * 20896 * @static 20897 * @memberOf _ 20898 * @since 4.0.0 20899 * @category String 20900 * @param {string} [string=''] The string to convert. 20901 * @returns {string} Returns the lower cased string. 20902 * @example 20903 * 20904 * _.toLower('--Foo-Bar--'); 20905 * // => '--foo-bar--' 20906 * 20907 * _.toLower('fooBar'); 20908 * // => 'foobar' 20909 * 20910 * _.toLower('__FOO_BAR__'); 20911 * // => '__foo_bar__' 20912 */ 20913 function toLower(value) { 20914 return toString(value).toLowerCase(); 20915 } 20916 20917 /** 20918 * Converts `string`, as a whole, to upper case just like 20919 * [String#toUpperCase](https://mdn.io/toUpperCase). 20920 * 20921 * @static 20922 * @memberOf _ 20923 * @since 4.0.0 20924 * @category String 20925 * @param {string} [string=''] The string to convert. 20926 * @returns {string} Returns the upper cased string. 20927 * @example 20928 * 20929 * _.toUpper('--foo-bar--'); 20930 * // => '--FOO-BAR--' 20931 * 20932 * _.toUpper('fooBar'); 20933 * // => 'FOOBAR' 20934 * 20935 * _.toUpper('__foo_bar__'); 20936 * // => '__FOO_BAR__' 20937 */ 20938 function toUpper(value) { 20939 return toString(value).toUpperCase(); 20940 } 20941 20942 /** 20943 * Removes leading and trailing whitespace or specified characters from `string`. 20944 * 20945 * @static 20946 * @memberOf _ 20947 * @since 3.0.0 20948 * @category String 20949 * @param {string} [string=''] The string to trim. 20950 * @param {string} [chars=whitespace] The characters to trim. 20951 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 20952 * @returns {string} Returns the trimmed string. 20953 * @example 20954 * 20955 * _.trim(' abc '); 20956 * // => 'abc' 20957 * 20958 * _.trim('-_-abc-_-', '_-'); 20959 * // => 'abc' 20960 * 20961 * _.map([' foo ', ' bar '], _.trim); 20962 * // => ['foo', 'bar'] 20963 */ 20964 function trim(string, chars, guard) { 20965 string = toString(string); 20966 if (string && (guard || chars === undefined$1)) { 20967 return baseTrim(string); 20968 } 20969 if (!string || !(chars = baseToString(chars))) { 20970 return string; 20971 } 20972 var strSymbols = stringToArray(string), 20973 chrSymbols = stringToArray(chars), 20974 start = charsStartIndex(strSymbols, chrSymbols), 20975 end = charsEndIndex(strSymbols, chrSymbols) + 1; 20976 20977 return castSlice(strSymbols, start, end).join(''); 20978 } 20979 20980 /** 20981 * Removes trailing whitespace or specified characters from `string`. 20982 * 20983 * @static 20984 * @memberOf _ 20985 * @since 4.0.0 20986 * @category String 20987 * @param {string} [string=''] The string to trim. 20988 * @param {string} [chars=whitespace] The characters to trim. 20989 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 20990 * @returns {string} Returns the trimmed string. 20991 * @example 20992 * 20993 * _.trimEnd(' abc '); 20994 * // => ' abc' 20995 * 20996 * _.trimEnd('-_-abc-_-', '_-'); 20997 * // => '-_-abc' 20998 */ 20999 function trimEnd(string, chars, guard) { 21000 string = toString(string); 21001 if (string && (guard || chars === undefined$1)) { 21002 return string.slice(0, trimmedEndIndex(string) + 1); 21003 } 21004 if (!string || !(chars = baseToString(chars))) { 21005 return string; 21006 } 21007 var strSymbols = stringToArray(string), 21008 end = charsEndIndex(strSymbols, stringToArray(chars)) + 1; 21009 21010 return castSlice(strSymbols, 0, end).join(''); 21011 } 21012 21013 /** 21014 * Removes leading whitespace or specified characters from `string`. 21015 * 21016 * @static 21017 * @memberOf _ 21018 * @since 4.0.0 21019 * @category String 21020 * @param {string} [string=''] The string to trim. 21021 * @param {string} [chars=whitespace] The characters to trim. 21022 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 21023 * @returns {string} Returns the trimmed string. 21024 * @example 21025 * 21026 * _.trimStart(' abc '); 21027 * // => 'abc ' 21028 * 21029 * _.trimStart('-_-abc-_-', '_-'); 21030 * // => 'abc-_-' 21031 */ 21032 function trimStart(string, chars, guard) { 21033 string = toString(string); 21034 if (string && (guard || chars === undefined$1)) { 21035 return string.replace(reTrimStart, ''); 21036 } 21037 if (!string || !(chars = baseToString(chars))) { 21038 return string; 21039 } 21040 var strSymbols = stringToArray(string), 21041 start = charsStartIndex(strSymbols, stringToArray(chars)); 21042 21043 return castSlice(strSymbols, start).join(''); 21044 } 21045 21046 /** 21047 * Truncates `string` if it's longer than the given maximum string length. 21048 * The last characters of the truncated string are replaced with the omission 21049 * string which defaults to "...". 21050 * 21051 * @static 21052 * @memberOf _ 21053 * @since 4.0.0 21054 * @category String 21055 * @param {string} [string=''] The string to truncate. 21056 * @param {Object} [options={}] The options object. 21057 * @param {number} [options.length=30] The maximum string length. 21058 * @param {string} [options.omission='...'] The string to indicate text is omitted. 21059 * @param {RegExp|string} [options.separator] The separator pattern to truncate to. 21060 * @returns {string} Returns the truncated string. 21061 * @example 21062 * 21063 * _.truncate('hi-diddly-ho there, neighborino'); 21064 * // => 'hi-diddly-ho there, neighbo...' 21065 * 21066 * _.truncate('hi-diddly-ho there, neighborino', { 21067 * 'length': 24, 21068 * 'separator': ' ' 21069 * }); 21070 * // => 'hi-diddly-ho there,...' 21071 * 21072 * _.truncate('hi-diddly-ho there, neighborino', { 21073 * 'length': 24, 21074 * 'separator': /,? +/ 21075 * }); 21076 * // => 'hi-diddly-ho there...' 21077 * 21078 * _.truncate('hi-diddly-ho there, neighborino', { 21079 * 'omission': ' [...]' 21080 * }); 21081 * // => 'hi-diddly-ho there, neig [...]' 21082 */ 21083 function truncate(string, options) { 21084 var length = DEFAULT_TRUNC_LENGTH, 21085 omission = DEFAULT_TRUNC_OMISSION; 21086 21087 if (isObject(options)) { 21088 var separator = 'separator' in options ? options.separator : separator; 21089 length = 'length' in options ? toInteger(options.length) : length; 21090 omission = 'omission' in options ? baseToString(options.omission) : omission; 21091 } 21092 string = toString(string); 21093 21094 var strLength = string.length; 21095 if (hasUnicode(string)) { 21096 var strSymbols = stringToArray(string); 21097 strLength = strSymbols.length; 21098 } 21099 if (length >= strLength) { 21100 return string; 21101 } 21102 var end = length - stringSize(omission); 21103 if (end < 1) { 21104 return omission; 21105 } 21106 var result = strSymbols 21107 ? castSlice(strSymbols, 0, end).join('') 21108 : string.slice(0, end); 21109 21110 if (separator === undefined$1) { 21111 return result + omission; 21112 } 21113 if (strSymbols) { 21114 end += (result.length - end); 21115 } 21116 if (isRegExp(separator)) { 21117 if (string.slice(end).search(separator)) { 21118 var match, 21119 substring = result; 21120 21121 if (!separator.global) { 21122 separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g'); 21123 } 21124 separator.lastIndex = 0; 21125 while ((match = separator.exec(substring))) { 21126 var newEnd = match.index; 21127 } 21128 result = result.slice(0, newEnd === undefined$1 ? end : newEnd); 21129 } 21130 } else if (string.indexOf(baseToString(separator), end) != end) { 21131 var index = result.lastIndexOf(separator); 21132 if (index > -1) { 21133 result = result.slice(0, index); 21134 } 21135 } 21136 return result + omission; 21137 } 21138 21139 /** 21140 * The inverse of `_.escape`; this method converts the HTML entities 21141 * `&`, `<`, `>`, `"`, and `'` in `string` to 21142 * their corresponding characters. 21143 * 21144 * **Note:** No other HTML entities are unescaped. To unescape additional 21145 * HTML entities use a third-party library like [_he_](https://mths.be/he). 21146 * 21147 * @static 21148 * @memberOf _ 21149 * @since 0.6.0 21150 * @category String 21151 * @param {string} [string=''] The string to unescape. 21152 * @returns {string} Returns the unescaped string. 21153 * @example 21154 * 21155 * _.unescape('fred, barney, & pebbles'); 21156 * // => 'fred, barney, & pebbles' 21157 */ 21158 function unescape(string) { 21159 string = toString(string); 21160 return (string && reHasEscapedHtml.test(string)) 21161 ? string.replace(reEscapedHtml, unescapeHtmlChar) 21162 : string; 21163 } 21164 21165 /** 21166 * Converts `string`, as space separated words, to upper case. 21167 * 21168 * @static 21169 * @memberOf _ 21170 * @since 4.0.0 21171 * @category String 21172 * @param {string} [string=''] The string to convert. 21173 * @returns {string} Returns the upper cased string. 21174 * @example 21175 * 21176 * _.upperCase('--foo-bar'); 21177 * // => 'FOO BAR' 21178 * 21179 * _.upperCase('fooBar'); 21180 * // => 'FOO BAR' 21181 * 21182 * _.upperCase('__foo_bar__'); 21183 * // => 'FOO BAR' 21184 */ 21185 var upperCase = createCompounder(function(result, word, index) { 21186 return result + (index ? ' ' : '') + word.toUpperCase(); 21187 }); 21188 21189 /** 21190 * Converts the first character of `string` to upper case. 21191 * 21192 * @static 21193 * @memberOf _ 21194 * @since 4.0.0 21195 * @category String 21196 * @param {string} [string=''] The string to convert. 21197 * @returns {string} Returns the converted string. 21198 * @example 21199 * 21200 * _.upperFirst('fred'); 21201 * // => 'Fred' 21202 * 21203 * _.upperFirst('FRED'); 21204 * // => 'FRED' 21205 */ 21206 var upperFirst = createCaseFirst('toUpperCase'); 21207 21208 /** 21209 * Splits `string` into an array of its words. 21210 * 21211 * @static 21212 * @memberOf _ 21213 * @since 3.0.0 21214 * @category String 21215 * @param {string} [string=''] The string to inspect. 21216 * @param {RegExp|string} [pattern] The pattern to match words. 21217 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 21218 * @returns {Array} Returns the words of `string`. 21219 * @example 21220 * 21221 * _.words('fred, barney, & pebbles'); 21222 * // => ['fred', 'barney', 'pebbles'] 21223 * 21224 * _.words('fred, barney, & pebbles', /[^, ]+/g); 21225 * // => ['fred', 'barney', '&', 'pebbles'] 21226 */ 21227 function words(string, pattern, guard) { 21228 string = toString(string); 21229 pattern = guard ? undefined$1 : pattern; 21230 21231 if (pattern === undefined$1) { 21232 return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); 21233 } 21234 return string.match(pattern) || []; 21235 } 21236 21237 /*------------------------------------------------------------------------*/ 21238 21239 /** 21240 * Attempts to invoke `func`, returning either the result or the caught error 21241 * object. Any additional arguments are provided to `func` when it's invoked. 21242 * 21243 * @static 21244 * @memberOf _ 21245 * @since 3.0.0 21246 * @category Util 21247 * @param {Function} func The function to attempt. 21248 * @param {...*} [args] The arguments to invoke `func` with. 21249 * @returns {*} Returns the `func` result or error object. 21250 * @example 21251 * 21252 * // Avoid throwing errors for invalid selectors. 21253 * var elements = _.attempt(function(selector) { 21254 * return document.querySelectorAll(selector); 21255 * }, '>_>'); 21256 * 21257 * if (_.isError(elements)) { 21258 * elements = []; 21259 * } 21260 */ 21261 var attempt = baseRest(function(func, args) { 21262 try { 21263 return apply(func, undefined$1, args); 21264 } catch (e) { 21265 return isError(e) ? e : new Error(e); 21266 } 21267 }); 21268 21269 /** 21270 * Binds methods of an object to the object itself, overwriting the existing 21271 * method. 21272 * 21273 * **Note:** This method doesn't set the "length" property of bound functions. 21274 * 21275 * @static 21276 * @since 0.1.0 21277 * @memberOf _ 21278 * @category Util 21279 * @param {Object} object The object to bind and assign the bound methods to. 21280 * @param {...(string|string[])} methodNames The object method names to bind. 21281 * @returns {Object} Returns `object`. 21282 * @example 21283 * 21284 * var view = { 21285 * 'label': 'docs', 21286 * 'click': function() { 21287 * console.log('clicked ' + this.label); 21288 * } 21289 * }; 21290 * 21291 * _.bindAll(view, ['click']); 21292 * jQuery(element).on('click', view.click); 21293 * // => Logs 'clicked docs' when clicked. 21294 */ 21295 var bindAll = flatRest(function(object, methodNames) { 21296 arrayEach(methodNames, function(key) { 21297 key = toKey(key); 21298 baseAssignValue(object, key, bind(object[key], object)); 21299 }); 21300 return object; 21301 }); 21302 21303 /** 21304 * Creates a function that iterates over `pairs` and invokes the corresponding 21305 * function of the first predicate to return truthy. The predicate-function 21306 * pairs are invoked with the `this` binding and arguments of the created 21307 * function. 21308 * 21309 * @static 21310 * @memberOf _ 21311 * @since 4.0.0 21312 * @category Util 21313 * @param {Array} pairs The predicate-function pairs. 21314 * @returns {Function} Returns the new composite function. 21315 * @example 21316 * 21317 * var func = _.cond([ 21318 * [_.matches({ 'a': 1 }), _.constant('matches A')], 21319 * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], 21320 * [_.stubTrue, _.constant('no match')] 21321 * ]); 21322 * 21323 * func({ 'a': 1, 'b': 2 }); 21324 * // => 'matches A' 21325 * 21326 * func({ 'a': 0, 'b': 1 }); 21327 * // => 'matches B' 21328 * 21329 * func({ 'a': '1', 'b': '2' }); 21330 * // => 'no match' 21331 */ 21332 function cond(pairs) { 21333 var length = pairs == null ? 0 : pairs.length, 21334 toIteratee = getIteratee(); 21335 21336 pairs = !length ? [] : arrayMap(pairs, function(pair) { 21337 if (typeof pair[1] != 'function') { 21338 throw new TypeError(FUNC_ERROR_TEXT); 21339 } 21340 return [toIteratee(pair[0]), pair[1]]; 21341 }); 21342 21343 return baseRest(function(args) { 21344 var index = -1; 21345 while (++index < length) { 21346 var pair = pairs[index]; 21347 if (apply(pair[0], this, args)) { 21348 return apply(pair[1], this, args); 21349 } 21350 } 21351 }); 21352 } 21353 21354 /** 21355 * Creates a function that invokes the predicate properties of `source` with 21356 * the corresponding property values of a given object, returning `true` if 21357 * all predicates return truthy, else `false`. 21358 * 21359 * **Note:** The created function is equivalent to `_.conformsTo` with 21360 * `source` partially applied. 21361 * 21362 * @static 21363 * @memberOf _ 21364 * @since 4.0.0 21365 * @category Util 21366 * @param {Object} source The object of property predicates to conform to. 21367 * @returns {Function} Returns the new spec function. 21368 * @example 21369 * 21370 * var objects = [ 21371 * { 'a': 2, 'b': 1 }, 21372 * { 'a': 1, 'b': 2 } 21373 * ]; 21374 * 21375 * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } })); 21376 * // => [{ 'a': 1, 'b': 2 }] 21377 */ 21378 function conforms(source) { 21379 return baseConforms(baseClone(source, CLONE_DEEP_FLAG)); 21380 } 21381 21382 /** 21383 * Creates a function that returns `value`. 21384 * 21385 * @static 21386 * @memberOf _ 21387 * @since 2.4.0 21388 * @category Util 21389 * @param {*} value The value to return from the new function. 21390 * @returns {Function} Returns the new constant function. 21391 * @example 21392 * 21393 * var objects = _.times(2, _.constant({ 'a': 1 })); 21394 * 21395 * console.log(objects); 21396 * // => [{ 'a': 1 }, { 'a': 1 }] 21397 * 21398 * console.log(objects[0] === objects[1]); 21399 * // => true 21400 */ 21401 function constant(value) { 21402 return function() { 21403 return value; 21404 }; 21405 } 21406 21407 /** 21408 * Checks `value` to determine whether a default value should be returned in 21409 * its place. The `defaultValue` is returned if `value` is `NaN`, `null`, 21410 * or `undefined`. 21411 * 21412 * @static 21413 * @memberOf _ 21414 * @since 4.14.0 21415 * @category Util 21416 * @param {*} value The value to check. 21417 * @param {*} defaultValue The default value. 21418 * @returns {*} Returns the resolved value. 21419 * @example 21420 * 21421 * _.defaultTo(1, 10); 21422 * // => 1 21423 * 21424 * _.defaultTo(undefined, 10); 21425 * // => 10 21426 */ 21427 function defaultTo(value, defaultValue) { 21428 return (value == null || value !== value) ? defaultValue : value; 21429 } 21430 21431 /** 21432 * Creates a function that returns the result of invoking the given functions 21433 * with the `this` binding of the created function, where each successive 21434 * invocation is supplied the return value of the previous. 21435 * 21436 * @static 21437 * @memberOf _ 21438 * @since 3.0.0 21439 * @category Util 21440 * @param {...(Function|Function[])} [funcs] The functions to invoke. 21441 * @returns {Function} Returns the new composite function. 21442 * @see _.flowRight 21443 * @example 21444 * 21445 * function square(n) { 21446 * return n * n; 21447 * } 21448 * 21449 * var addSquare = _.flow([_.add, square]); 21450 * addSquare(1, 2); 21451 * // => 9 21452 */ 21453 var flow = createFlow(); 21454 21455 /** 21456 * This method is like `_.flow` except that it creates a function that 21457 * invokes the given functions from right to left. 21458 * 21459 * @static 21460 * @since 3.0.0 21461 * @memberOf _ 21462 * @category Util 21463 * @param {...(Function|Function[])} [funcs] The functions to invoke. 21464 * @returns {Function} Returns the new composite function. 21465 * @see _.flow 21466 * @example 21467 * 21468 * function square(n) { 21469 * return n * n; 21470 * } 21471 * 21472 * var addSquare = _.flowRight([square, _.add]); 21473 * addSquare(1, 2); 21474 * // => 9 21475 */ 21476 var flowRight = createFlow(true); 21477 21478 /** 21479 * This method returns the first argument it receives. 21480 * 21481 * @static 21482 * @since 0.1.0 21483 * @memberOf _ 21484 * @category Util 21485 * @param {*} value Any value. 21486 * @returns {*} Returns `value`. 21487 * @example 21488 * 21489 * var object = { 'a': 1 }; 21490 * 21491 * console.log(_.identity(object) === object); 21492 * // => true 21493 */ 21494 function identity(value) { 21495 return value; 21496 } 21497 21498 /** 21499 * Creates a function that invokes `func` with the arguments of the created 21500 * function. If `func` is a property name, the created function returns the 21501 * property value for a given element. If `func` is an array or object, the 21502 * created function returns `true` for elements that contain the equivalent 21503 * source properties, otherwise it returns `false`. 21504 * 21505 * @static 21506 * @since 4.0.0 21507 * @memberOf _ 21508 * @category Util 21509 * @param {*} [func=_.identity] The value to convert to a callback. 21510 * @returns {Function} Returns the callback. 21511 * @example 21512 * 21513 * var users = [ 21514 * { 'user': 'barney', 'age': 36, 'active': true }, 21515 * { 'user': 'fred', 'age': 40, 'active': false } 21516 * ]; 21517 * 21518 * // The `_.matches` iteratee shorthand. 21519 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true })); 21520 * // => [{ 'user': 'barney', 'age': 36, 'active': true }] 21521 * 21522 * // The `_.matchesProperty` iteratee shorthand. 21523 * _.filter(users, _.iteratee(['user', 'fred'])); 21524 * // => [{ 'user': 'fred', 'age': 40 }] 21525 * 21526 * // The `_.property` iteratee shorthand. 21527 * _.map(users, _.iteratee('user')); 21528 * // => ['barney', 'fred'] 21529 * 21530 * // Create custom iteratee shorthands. 21531 * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) { 21532 * return !_.isRegExp(func) ? iteratee(func) : function(string) { 21533 * return func.test(string); 21534 * }; 21535 * }); 21536 * 21537 * _.filter(['abc', 'def'], /ef/); 21538 * // => ['def'] 21539 */ 21540 function iteratee(func) { 21541 return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG)); 21542 } 21543 21544 /** 21545 * Creates a function that performs a partial deep comparison between a given 21546 * object and `source`, returning `true` if the given object has equivalent 21547 * property values, else `false`. 21548 * 21549 * **Note:** The created function is equivalent to `_.isMatch` with `source` 21550 * partially applied. 21551 * 21552 * Partial comparisons will match empty array and empty object `source` 21553 * values against any array or object value, respectively. See `_.isEqual` 21554 * for a list of supported value comparisons. 21555 * 21556 * **Note:** Multiple values can be checked by combining several matchers 21557 * using `_.overSome` 21558 * 21559 * @static 21560 * @memberOf _ 21561 * @since 3.0.0 21562 * @category Util 21563 * @param {Object} source The object of property values to match. 21564 * @returns {Function} Returns the new spec function. 21565 * @example 21566 * 21567 * var objects = [ 21568 * { 'a': 1, 'b': 2, 'c': 3 }, 21569 * { 'a': 4, 'b': 5, 'c': 6 } 21570 * ]; 21571 * 21572 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 })); 21573 * // => [{ 'a': 4, 'b': 5, 'c': 6 }] 21574 * 21575 * // Checking for several possible values 21576 * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })])); 21577 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] 21578 */ 21579 function matches(source) { 21580 return baseMatches(baseClone(source, CLONE_DEEP_FLAG)); 21581 } 21582 21583 /** 21584 * Creates a function that performs a partial deep comparison between the 21585 * value at `path` of a given object to `srcValue`, returning `true` if the 21586 * object value is equivalent, else `false`. 21587 * 21588 * **Note:** Partial comparisons will match empty array and empty object 21589 * `srcValue` values against any array or object value, respectively. See 21590 * `_.isEqual` for a list of supported value comparisons. 21591 * 21592 * **Note:** Multiple values can be checked by combining several matchers 21593 * using `_.overSome` 21594 * 21595 * @static 21596 * @memberOf _ 21597 * @since 3.2.0 21598 * @category Util 21599 * @param {Array|string} path The path of the property to get. 21600 * @param {*} srcValue The value to match. 21601 * @returns {Function} Returns the new spec function. 21602 * @example 21603 * 21604 * var objects = [ 21605 * { 'a': 1, 'b': 2, 'c': 3 }, 21606 * { 'a': 4, 'b': 5, 'c': 6 } 21607 * ]; 21608 * 21609 * _.find(objects, _.matchesProperty('a', 4)); 21610 * // => { 'a': 4, 'b': 5, 'c': 6 } 21611 * 21612 * // Checking for several possible values 21613 * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)])); 21614 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] 21615 */ 21616 function matchesProperty(path, srcValue) { 21617 return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG)); 21618 } 21619 21620 /** 21621 * Creates a function that invokes the method at `path` of a given object. 21622 * Any additional arguments are provided to the invoked method. 21623 * 21624 * @static 21625 * @memberOf _ 21626 * @since 3.7.0 21627 * @category Util 21628 * @param {Array|string} path The path of the method to invoke. 21629 * @param {...*} [args] The arguments to invoke the method with. 21630 * @returns {Function} Returns the new invoker function. 21631 * @example 21632 * 21633 * var objects = [ 21634 * { 'a': { 'b': _.constant(2) } }, 21635 * { 'a': { 'b': _.constant(1) } } 21636 * ]; 21637 * 21638 * _.map(objects, _.method('a.b')); 21639 * // => [2, 1] 21640 * 21641 * _.map(objects, _.method(['a', 'b'])); 21642 * // => [2, 1] 21643 */ 21644 var method = baseRest(function(path, args) { 21645 return function(object) { 21646 return baseInvoke(object, path, args); 21647 }; 21648 }); 21649 21650 /** 21651 * The opposite of `_.method`; this method creates a function that invokes 21652 * the method at a given path of `object`. Any additional arguments are 21653 * provided to the invoked method. 21654 * 21655 * @static 21656 * @memberOf _ 21657 * @since 3.7.0 21658 * @category Util 21659 * @param {Object} object The object to query. 21660 * @param {...*} [args] The arguments to invoke the method with. 21661 * @returns {Function} Returns the new invoker function. 21662 * @example 21663 * 21664 * var array = _.times(3, _.constant), 21665 * object = { 'a': array, 'b': array, 'c': array }; 21666 * 21667 * _.map(['a[2]', 'c[0]'], _.methodOf(object)); 21668 * // => [2, 0] 21669 * 21670 * _.map([['a', '2'], ['c', '0']], _.methodOf(object)); 21671 * // => [2, 0] 21672 */ 21673 var methodOf = baseRest(function(object, args) { 21674 return function(path) { 21675 return baseInvoke(object, path, args); 21676 }; 21677 }); 21678 21679 /** 21680 * Adds all own enumerable string keyed function properties of a source 21681 * object to the destination object. If `object` is a function, then methods 21682 * are added to its prototype as well. 21683 * 21684 * **Note:** Use `_.runInContext` to create a pristine `lodash` function to 21685 * avoid conflicts caused by modifying the original. 21686 * 21687 * @static 21688 * @since 0.1.0 21689 * @memberOf _ 21690 * @category Util 21691 * @param {Function|Object} [object=lodash] The destination object. 21692 * @param {Object} source The object of functions to add. 21693 * @param {Object} [options={}] The options object. 21694 * @param {boolean} [options.chain=true] Specify whether mixins are chainable. 21695 * @returns {Function|Object} Returns `object`. 21696 * @example 21697 * 21698 * function vowels(string) { 21699 * return _.filter(string, function(v) { 21700 * return /[aeiou]/i.test(v); 21701 * }); 21702 * } 21703 * 21704 * _.mixin({ 'vowels': vowels }); 21705 * _.vowels('fred'); 21706 * // => ['e'] 21707 * 21708 * _('fred').vowels().value(); 21709 * // => ['e'] 21710 * 21711 * _.mixin({ 'vowels': vowels }, { 'chain': false }); 21712 * _('fred').vowels(); 21713 * // => ['e'] 21714 */ 21715 function mixin(object, source, options) { 21716 var props = keys(source), 21717 methodNames = baseFunctions(source, props); 21718 21719 if (options == null && 21720 !(isObject(source) && (methodNames.length || !props.length))) { 21721 options = source; 21722 source = object; 21723 object = this; 21724 methodNames = baseFunctions(source, keys(source)); 21725 } 21726 var chain = !(isObject(options) && 'chain' in options) || !!options.chain, 21727 isFunc = isFunction(object); 21728 21729 arrayEach(methodNames, function(methodName) { 21730 var func = source[methodName]; 21731 object[methodName] = func; 21732 if (isFunc) { 21733 object.prototype[methodName] = function() { 21734 var chainAll = this.__chain__; 21735 if (chain || chainAll) { 21736 var result = object(this.__wrapped__), 21737 actions = result.__actions__ = copyArray(this.__actions__); 21738 21739 actions.push({ 'func': func, 'args': arguments, 'thisArg': object }); 21740 result.__chain__ = chainAll; 21741 return result; 21742 } 21743 return func.apply(object, arrayPush([this.value()], arguments)); 21744 }; 21745 } 21746 }); 21747 21748 return object; 21749 } 21750 21751 /** 21752 * Reverts the `_` variable to its previous value and returns a reference to 21753 * the `lodash` function. 21754 * 21755 * @static 21756 * @since 0.1.0 21757 * @memberOf _ 21758 * @category Util 21759 * @returns {Function} Returns the `lodash` function. 21760 * @example 21761 * 21762 * var lodash = _.noConflict(); 21763 */ 21764 function noConflict() { 21765 if (root._ === this) { 21766 root._ = oldDash; 21767 } 21768 return this; 21769 } 21770 21771 /** 21772 * This method returns `undefined`. 21773 * 21774 * @static 21775 * @memberOf _ 21776 * @since 2.3.0 21777 * @category Util 21778 * @example 21779 * 21780 * _.times(2, _.noop); 21781 * // => [undefined, undefined] 21782 */ 21783 function noop() { 21784 // No operation performed. 21785 } 21786 21787 /** 21788 * Creates a function that gets the argument at index `n`. If `n` is negative, 21789 * the nth argument from the end is returned. 21790 * 21791 * @static 21792 * @memberOf _ 21793 * @since 4.0.0 21794 * @category Util 21795 * @param {number} [n=0] The index of the argument to return. 21796 * @returns {Function} Returns the new pass-thru function. 21797 * @example 21798 * 21799 * var func = _.nthArg(1); 21800 * func('a', 'b', 'c', 'd'); 21801 * // => 'b' 21802 * 21803 * var func = _.nthArg(-2); 21804 * func('a', 'b', 'c', 'd'); 21805 * // => 'c' 21806 */ 21807 function nthArg(n) { 21808 n = toInteger(n); 21809 return baseRest(function(args) { 21810 return baseNth(args, n); 21811 }); 21812 } 21813 21814 /** 21815 * Creates a function that invokes `iteratees` with the arguments it receives 21816 * and returns their results. 21817 * 21818 * @static 21819 * @memberOf _ 21820 * @since 4.0.0 21821 * @category Util 21822 * @param {...(Function|Function[])} [iteratees=[_.identity]] 21823 * The iteratees to invoke. 21824 * @returns {Function} Returns the new function. 21825 * @example 21826 * 21827 * var func = _.over([Math.max, Math.min]); 21828 * 21829 * func(1, 2, 3, 4); 21830 * // => [4, 1] 21831 */ 21832 var over = createOver(arrayMap); 21833 21834 /** 21835 * Creates a function that checks if **all** of the `predicates` return 21836 * truthy when invoked with the arguments it receives. 21837 * 21838 * Following shorthands are possible for providing predicates. 21839 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. 21840 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. 21841 * 21842 * @static 21843 * @memberOf _ 21844 * @since 4.0.0 21845 * @category Util 21846 * @param {...(Function|Function[])} [predicates=[_.identity]] 21847 * The predicates to check. 21848 * @returns {Function} Returns the new function. 21849 * @example 21850 * 21851 * var func = _.overEvery([Boolean, isFinite]); 21852 * 21853 * func('1'); 21854 * // => true 21855 * 21856 * func(null); 21857 * // => false 21858 * 21859 * func(NaN); 21860 * // => false 21861 */ 21862 var overEvery = createOver(arrayEvery); 21863 21864 /** 21865 * Creates a function that checks if **any** of the `predicates` return 21866 * truthy when invoked with the arguments it receives. 21867 * 21868 * Following shorthands are possible for providing predicates. 21869 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. 21870 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. 21871 * 21872 * @static 21873 * @memberOf _ 21874 * @since 4.0.0 21875 * @category Util 21876 * @param {...(Function|Function[])} [predicates=[_.identity]] 21877 * The predicates to check. 21878 * @returns {Function} Returns the new function. 21879 * @example 21880 * 21881 * var func = _.overSome([Boolean, isFinite]); 21882 * 21883 * func('1'); 21884 * // => true 21885 * 21886 * func(null); 21887 * // => true 21888 * 21889 * func(NaN); 21890 * // => false 21891 * 21892 * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }]) 21893 * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]]) 21894 */ 21895 var overSome = createOver(arraySome); 21896 21897 /** 21898 * Creates a function that returns the value at `path` of a given object. 21899 * 21900 * @static 21901 * @memberOf _ 21902 * @since 2.4.0 21903 * @category Util 21904 * @param {Array|string} path The path of the property to get. 21905 * @returns {Function} Returns the new accessor function. 21906 * @example 21907 * 21908 * var objects = [ 21909 * { 'a': { 'b': 2 } }, 21910 * { 'a': { 'b': 1 } } 21911 * ]; 21912 * 21913 * _.map(objects, _.property('a.b')); 21914 * // => [2, 1] 21915 * 21916 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); 21917 * // => [1, 2] 21918 */ 21919 function property(path) { 21920 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); 21921 } 21922 21923 /** 21924 * The opposite of `_.property`; this method creates a function that returns 21925 * the value at a given path of `object`. 21926 * 21927 * @static 21928 * @memberOf _ 21929 * @since 3.0.0 21930 * @category Util 21931 * @param {Object} object The object to query. 21932 * @returns {Function} Returns the new accessor function. 21933 * @example 21934 * 21935 * var array = [0, 1, 2], 21936 * object = { 'a': array, 'b': array, 'c': array }; 21937 * 21938 * _.map(['a[2]', 'c[0]'], _.propertyOf(object)); 21939 * // => [2, 0] 21940 * 21941 * _.map([['a', '2'], ['c', '0']], _.propertyOf(object)); 21942 * // => [2, 0] 21943 */ 21944 function propertyOf(object) { 21945 return function(path) { 21946 return object == null ? undefined$1 : baseGet(object, path); 21947 }; 21948 } 21949 21950 /** 21951 * Creates an array of numbers (positive and/or negative) progressing from 21952 * `start` up to, but not including, `end`. A step of `-1` is used if a negative 21953 * `start` is specified without an `end` or `step`. If `end` is not specified, 21954 * it's set to `start` with `start` then set to `0`. 21955 * 21956 * **Note:** JavaScript follows the IEEE-754 standard for resolving 21957 * floating-point values which can produce unexpected results. 21958 * 21959 * @static 21960 * @since 0.1.0 21961 * @memberOf _ 21962 * @category Util 21963 * @param {number} [start=0] The start of the range. 21964 * @param {number} end The end of the range. 21965 * @param {number} [step=1] The value to increment or decrement by. 21966 * @returns {Array} Returns the range of numbers. 21967 * @see _.inRange, _.rangeRight 21968 * @example 21969 * 21970 * _.range(4); 21971 * // => [0, 1, 2, 3] 21972 * 21973 * _.range(-4); 21974 * // => [0, -1, -2, -3] 21975 * 21976 * _.range(1, 5); 21977 * // => [1, 2, 3, 4] 21978 * 21979 * _.range(0, 20, 5); 21980 * // => [0, 5, 10, 15] 21981 * 21982 * _.range(0, -4, -1); 21983 * // => [0, -1, -2, -3] 21984 * 21985 * _.range(1, 4, 0); 21986 * // => [1, 1, 1] 21987 * 21988 * _.range(0); 21989 * // => [] 21990 */ 21991 var range = createRange(); 21992 21993 /** 21994 * This method is like `_.range` except that it populates values in 21995 * descending order. 21996 * 21997 * @static 21998 * @memberOf _ 21999 * @since 4.0.0 22000 * @category Util 22001 * @param {number} [start=0] The start of the range. 22002 * @param {number} end The end of the range. 22003 * @param {number} [step=1] The value to increment or decrement by. 22004 * @returns {Array} Returns the range of numbers. 22005 * @see _.inRange, _.range 22006 * @example 22007 * 22008 * _.rangeRight(4); 22009 * // => [3, 2, 1, 0] 22010 * 22011 * _.rangeRight(-4); 22012 * // => [-3, -2, -1, 0] 22013 * 22014 * _.rangeRight(1, 5); 22015 * // => [4, 3, 2, 1] 22016 * 22017 * _.rangeRight(0, 20, 5); 22018 * // => [15, 10, 5, 0] 22019 * 22020 * _.rangeRight(0, -4, -1); 22021 * // => [-3, -2, -1, 0] 22022 * 22023 * _.rangeRight(1, 4, 0); 22024 * // => [1, 1, 1] 22025 * 22026 * _.rangeRight(0); 22027 * // => [] 22028 */ 22029 var rangeRight = createRange(true); 22030 22031 /** 22032 * This method returns a new empty array. 22033 * 22034 * @static 22035 * @memberOf _ 22036 * @since 4.13.0 22037 * @category Util 22038 * @returns {Array} Returns the new empty array. 22039 * @example 22040 * 22041 * var arrays = _.times(2, _.stubArray); 22042 * 22043 * console.log(arrays); 22044 * // => [[], []] 22045 * 22046 * console.log(arrays[0] === arrays[1]); 22047 * // => false 22048 */ 22049 function stubArray() { 22050 return []; 22051 } 22052 22053 /** 22054 * This method returns `false`. 22055 * 22056 * @static 22057 * @memberOf _ 22058 * @since 4.13.0 22059 * @category Util 22060 * @returns {boolean} Returns `false`. 22061 * @example 22062 * 22063 * _.times(2, _.stubFalse); 22064 * // => [false, false] 22065 */ 22066 function stubFalse() { 22067 return false; 22068 } 22069 22070 /** 22071 * This method returns a new empty object. 22072 * 22073 * @static 22074 * @memberOf _ 22075 * @since 4.13.0 22076 * @category Util 22077 * @returns {Object} Returns the new empty object. 22078 * @example 22079 * 22080 * var objects = _.times(2, _.stubObject); 22081 * 22082 * console.log(objects); 22083 * // => [{}, {}] 22084 * 22085 * console.log(objects[0] === objects[1]); 22086 * // => false 22087 */ 22088 function stubObject() { 22089 return {}; 22090 } 22091 22092 /** 22093 * This method returns an empty string. 22094 * 22095 * @static 22096 * @memberOf _ 22097 * @since 4.13.0 22098 * @category Util 22099 * @returns {string} Returns the empty string. 22100 * @example 22101 * 22102 * _.times(2, _.stubString); 22103 * // => ['', ''] 22104 */ 22105 function stubString() { 22106 return ''; 22107 } 22108 22109 /** 22110 * This method returns `true`. 22111 * 22112 * @static 22113 * @memberOf _ 22114 * @since 4.13.0 22115 * @category Util 22116 * @returns {boolean} Returns `true`. 22117 * @example 22118 * 22119 * _.times(2, _.stubTrue); 22120 * // => [true, true] 22121 */ 22122 function stubTrue() { 22123 return true; 22124 } 22125 22126 /** 22127 * Invokes the iteratee `n` times, returning an array of the results of 22128 * each invocation. The iteratee is invoked with one argument; (index). 22129 * 22130 * @static 22131 * @since 0.1.0 22132 * @memberOf _ 22133 * @category Util 22134 * @param {number} n The number of times to invoke `iteratee`. 22135 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 22136 * @returns {Array} Returns the array of results. 22137 * @example 22138 * 22139 * _.times(3, String); 22140 * // => ['0', '1', '2'] 22141 * 22142 * _.times(4, _.constant(0)); 22143 * // => [0, 0, 0, 0] 22144 */ 22145 function times(n, iteratee) { 22146 n = toInteger(n); 22147 if (n < 1 || n > MAX_SAFE_INTEGER) { 22148 return []; 22149 } 22150 var index = MAX_ARRAY_LENGTH, 22151 length = nativeMin(n, MAX_ARRAY_LENGTH); 22152 22153 iteratee = getIteratee(iteratee); 22154 n -= MAX_ARRAY_LENGTH; 22155 22156 var result = baseTimes(length, iteratee); 22157 while (++index < n) { 22158 iteratee(index); 22159 } 22160 return result; 22161 } 22162 22163 /** 22164 * Converts `value` to a property path array. 22165 * 22166 * @static 22167 * @memberOf _ 22168 * @since 4.0.0 22169 * @category Util 22170 * @param {*} value The value to convert. 22171 * @returns {Array} Returns the new property path array. 22172 * @example 22173 * 22174 * _.toPath('a.b.c'); 22175 * // => ['a', 'b', 'c'] 22176 * 22177 * _.toPath('a[0].b.c'); 22178 * // => ['a', '0', 'b', 'c'] 22179 */ 22180 function toPath(value) { 22181 if (isArray(value)) { 22182 return arrayMap(value, toKey); 22183 } 22184 return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value))); 22185 } 22186 22187 /** 22188 * Generates a unique ID. If `prefix` is given, the ID is appended to it. 22189 * 22190 * @static 22191 * @since 0.1.0 22192 * @memberOf _ 22193 * @category Util 22194 * @param {string} [prefix=''] The value to prefix the ID with. 22195 * @returns {string} Returns the unique ID. 22196 * @example 22197 * 22198 * _.uniqueId('contact_'); 22199 * // => 'contact_104' 22200 * 22201 * _.uniqueId(); 22202 * // => '105' 22203 */ 22204 function uniqueId(prefix) { 22205 var id = ++idCounter; 22206 return toString(prefix) + id; 22207 } 22208 22209 /*------------------------------------------------------------------------*/ 22210 22211 /** 22212 * Adds two numbers. 22213 * 22214 * @static 22215 * @memberOf _ 22216 * @since 3.4.0 22217 * @category Math 22218 * @param {number} augend The first number in an addition. 22219 * @param {number} addend The second number in an addition. 22220 * @returns {number} Returns the total. 22221 * @example 22222 * 22223 * _.add(6, 4); 22224 * // => 10 22225 */ 22226 var add = createMathOperation(function(augend, addend) { 22227 return augend + addend; 22228 }, 0); 22229 22230 /** 22231 * Computes `number` rounded up to `precision`. 22232 * 22233 * @static 22234 * @memberOf _ 22235 * @since 3.10.0 22236 * @category Math 22237 * @param {number} number The number to round up. 22238 * @param {number} [precision=0] The precision to round up to. 22239 * @returns {number} Returns the rounded up number. 22240 * @example 22241 * 22242 * _.ceil(4.006); 22243 * // => 5 22244 * 22245 * _.ceil(6.004, 2); 22246 * // => 6.01 22247 * 22248 * _.ceil(6040, -2); 22249 * // => 6100 22250 */ 22251 var ceil = createRound('ceil'); 22252 22253 /** 22254 * Divide two numbers. 22255 * 22256 * @static 22257 * @memberOf _ 22258 * @since 4.7.0 22259 * @category Math 22260 * @param {number} dividend The first number in a division. 22261 * @param {number} divisor The second number in a division. 22262 * @returns {number} Returns the quotient. 22263 * @example 22264 * 22265 * _.divide(6, 4); 22266 * // => 1.5 22267 */ 22268 var divide = createMathOperation(function(dividend, divisor) { 22269 return dividend / divisor; 22270 }, 1); 22271 22272 /** 22273 * Computes `number` rounded down to `precision`. 22274 * 22275 * @static 22276 * @memberOf _ 22277 * @since 3.10.0 22278 * @category Math 22279 * @param {number} number The number to round down. 22280 * @param {number} [precision=0] The precision to round down to. 22281 * @returns {number} Returns the rounded down number. 22282 * @example 22283 * 22284 * _.floor(4.006); 22285 * // => 4 22286 * 22287 * _.floor(0.046, 2); 22288 * // => 0.04 22289 * 22290 * _.floor(4060, -2); 22291 * // => 4000 22292 */ 22293 var floor = createRound('floor'); 22294 22295 /** 22296 * Computes the maximum value of `array`. If `array` is empty or falsey, 22297 * `undefined` is returned. 22298 * 22299 * @static 22300 * @since 0.1.0 22301 * @memberOf _ 22302 * @category Math 22303 * @param {Array} array The array to iterate over. 22304 * @returns {*} Returns the maximum value. 22305 * @example 22306 * 22307 * _.max([4, 2, 8, 6]); 22308 * // => 8 22309 * 22310 * _.max([]); 22311 * // => undefined 22312 */ 22313 function max(array) { 22314 return (array && array.length) 22315 ? baseExtremum(array, identity, baseGt) 22316 : undefined$1; 22317 } 22318 22319 /** 22320 * This method is like `_.max` except that it accepts `iteratee` which is 22321 * invoked for each element in `array` to generate the criterion by which 22322 * the value is ranked. The iteratee is invoked with one argument: (value). 22323 * 22324 * @static 22325 * @memberOf _ 22326 * @since 4.0.0 22327 * @category Math 22328 * @param {Array} array The array to iterate over. 22329 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 22330 * @returns {*} Returns the maximum value. 22331 * @example 22332 * 22333 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 22334 * 22335 * _.maxBy(objects, function(o) { return o.n; }); 22336 * // => { 'n': 2 } 22337 * 22338 * // The `_.property` iteratee shorthand. 22339 * _.maxBy(objects, 'n'); 22340 * // => { 'n': 2 } 22341 */ 22342 function maxBy(array, iteratee) { 22343 return (array && array.length) 22344 ? baseExtremum(array, getIteratee(iteratee, 2), baseGt) 22345 : undefined$1; 22346 } 22347 22348 /** 22349 * Computes the mean of the values in `array`. 22350 * 22351 * @static 22352 * @memberOf _ 22353 * @since 4.0.0 22354 * @category Math 22355 * @param {Array} array The array to iterate over. 22356 * @returns {number} Returns the mean. 22357 * @example 22358 * 22359 * _.mean([4, 2, 8, 6]); 22360 * // => 5 22361 */ 22362 function mean(array) { 22363 return baseMean(array, identity); 22364 } 22365 22366 /** 22367 * This method is like `_.mean` except that it accepts `iteratee` which is 22368 * invoked for each element in `array` to generate the value to be averaged. 22369 * The iteratee is invoked with one argument: (value). 22370 * 22371 * @static 22372 * @memberOf _ 22373 * @since 4.7.0 22374 * @category Math 22375 * @param {Array} array The array to iterate over. 22376 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 22377 * @returns {number} Returns the mean. 22378 * @example 22379 * 22380 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 22381 * 22382 * _.meanBy(objects, function(o) { return o.n; }); 22383 * // => 5 22384 * 22385 * // The `_.property` iteratee shorthand. 22386 * _.meanBy(objects, 'n'); 22387 * // => 5 22388 */ 22389 function meanBy(array, iteratee) { 22390 return baseMean(array, getIteratee(iteratee, 2)); 22391 } 22392 22393 /** 22394 * Computes the minimum value of `array`. If `array` is empty or falsey, 22395 * `undefined` is returned. 22396 * 22397 * @static 22398 * @since 0.1.0 22399 * @memberOf _ 22400 * @category Math 22401 * @param {Array} array The array to iterate over. 22402 * @returns {*} Returns the minimum value. 22403 * @example 22404 * 22405 * _.min([4, 2, 8, 6]); 22406 * // => 2 22407 * 22408 * _.min([]); 22409 * // => undefined 22410 */ 22411 function min(array) { 22412 return (array && array.length) 22413 ? baseExtremum(array, identity, baseLt) 22414 : undefined$1; 22415 } 22416 22417 /** 22418 * This method is like `_.min` except that it accepts `iteratee` which is 22419 * invoked for each element in `array` to generate the criterion by which 22420 * the value is ranked. The iteratee is invoked with one argument: (value). 22421 * 22422 * @static 22423 * @memberOf _ 22424 * @since 4.0.0 22425 * @category Math 22426 * @param {Array} array The array to iterate over. 22427 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 22428 * @returns {*} Returns the minimum value. 22429 * @example 22430 * 22431 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 22432 * 22433 * _.minBy(objects, function(o) { return o.n; }); 22434 * // => { 'n': 1 } 22435 * 22436 * // The `_.property` iteratee shorthand. 22437 * _.minBy(objects, 'n'); 22438 * // => { 'n': 1 } 22439 */ 22440 function minBy(array, iteratee) { 22441 return (array && array.length) 22442 ? baseExtremum(array, getIteratee(iteratee, 2), baseLt) 22443 : undefined$1; 22444 } 22445 22446 /** 22447 * Multiply two numbers. 22448 * 22449 * @static 22450 * @memberOf _ 22451 * @since 4.7.0 22452 * @category Math 22453 * @param {number} multiplier The first number in a multiplication. 22454 * @param {number} multiplicand The second number in a multiplication. 22455 * @returns {number} Returns the product. 22456 * @example 22457 * 22458 * _.multiply(6, 4); 22459 * // => 24 22460 */ 22461 var multiply = createMathOperation(function(multiplier, multiplicand) { 22462 return multiplier * multiplicand; 22463 }, 1); 22464 22465 /** 22466 * Computes `number` rounded to `precision`. 22467 * 22468 * @static 22469 * @memberOf _ 22470 * @since 3.10.0 22471 * @category Math 22472 * @param {number} number The number to round. 22473 * @param {number} [precision=0] The precision to round to. 22474 * @returns {number} Returns the rounded number. 22475 * @example 22476 * 22477 * _.round(4.006); 22478 * // => 4 22479 * 22480 * _.round(4.006, 2); 22481 * // => 4.01 22482 * 22483 * _.round(4060, -2); 22484 * // => 4100 22485 */ 22486 var round = createRound('round'); 22487 22488 /** 22489 * Subtract two numbers. 22490 * 22491 * @static 22492 * @memberOf _ 22493 * @since 4.0.0 22494 * @category Math 22495 * @param {number} minuend The first number in a subtraction. 22496 * @param {number} subtrahend The second number in a subtraction. 22497 * @returns {number} Returns the difference. 22498 * @example 22499 * 22500 * _.subtract(6, 4); 22501 * // => 2 22502 */ 22503 var subtract = createMathOperation(function(minuend, subtrahend) { 22504 return minuend - subtrahend; 22505 }, 0); 22506 22507 /** 22508 * Computes the sum of the values in `array`. 22509 * 22510 * @static 22511 * @memberOf _ 22512 * @since 3.4.0 22513 * @category Math 22514 * @param {Array} array The array to iterate over. 22515 * @returns {number} Returns the sum. 22516 * @example 22517 * 22518 * _.sum([4, 2, 8, 6]); 22519 * // => 20 22520 */ 22521 function sum(array) { 22522 return (array && array.length) 22523 ? baseSum(array, identity) 22524 : 0; 22525 } 22526 22527 /** 22528 * This method is like `_.sum` except that it accepts `iteratee` which is 22529 * invoked for each element in `array` to generate the value to be summed. 22530 * The iteratee is invoked with one argument: (value). 22531 * 22532 * @static 22533 * @memberOf _ 22534 * @since 4.0.0 22535 * @category Math 22536 * @param {Array} array The array to iterate over. 22537 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 22538 * @returns {number} Returns the sum. 22539 * @example 22540 * 22541 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 22542 * 22543 * _.sumBy(objects, function(o) { return o.n; }); 22544 * // => 20 22545 * 22546 * // The `_.property` iteratee shorthand. 22547 * _.sumBy(objects, 'n'); 22548 * // => 20 22549 */ 22550 function sumBy(array, iteratee) { 22551 return (array && array.length) 22552 ? baseSum(array, getIteratee(iteratee, 2)) 22553 : 0; 22554 } 22555 22556 /*------------------------------------------------------------------------*/ 22557 22558 // Add methods that return wrapped values in chain sequences. 22559 lodash.after = after; 22560 lodash.ary = ary; 22561 lodash.assign = assign; 22562 lodash.assignIn = assignIn; 22563 lodash.assignInWith = assignInWith; 22564 lodash.assignWith = assignWith; 22565 lodash.at = at; 22566 lodash.before = before; 22567 lodash.bind = bind; 22568 lodash.bindAll = bindAll; 22569 lodash.bindKey = bindKey; 22570 lodash.castArray = castArray; 22571 lodash.chain = chain; 22572 lodash.chunk = chunk; 22573 lodash.compact = compact; 22574 lodash.concat = concat; 22575 lodash.cond = cond; 22576 lodash.conforms = conforms; 22577 lodash.constant = constant; 22578 lodash.countBy = countBy; 22579 lodash.create = create; 22580 lodash.curry = curry; 22581 lodash.curryRight = curryRight; 22582 lodash.debounce = debounce; 22583 lodash.defaults = defaults; 22584 lodash.defaultsDeep = defaultsDeep; 22585 lodash.defer = defer; 22586 lodash.delay = delay; 22587 lodash.difference = difference; 22588 lodash.differenceBy = differenceBy; 22589 lodash.differenceWith = differenceWith; 22590 lodash.drop = drop; 22591 lodash.dropRight = dropRight; 22592 lodash.dropRightWhile = dropRightWhile; 22593 lodash.dropWhile = dropWhile; 22594 lodash.fill = fill; 22595 lodash.filter = filter; 22596 lodash.flatMap = flatMap; 22597 lodash.flatMapDeep = flatMapDeep; 22598 lodash.flatMapDepth = flatMapDepth; 22599 lodash.flatten = flatten; 22600 lodash.flattenDeep = flattenDeep; 22601 lodash.flattenDepth = flattenDepth; 22602 lodash.flip = flip; 22603 lodash.flow = flow; 22604 lodash.flowRight = flowRight; 22605 lodash.fromPairs = fromPairs; 22606 lodash.functions = functions; 22607 lodash.functionsIn = functionsIn; 22608 lodash.groupBy = groupBy; 22609 lodash.initial = initial; 22610 lodash.intersection = intersection; 22611 lodash.intersectionBy = intersectionBy; 22612 lodash.intersectionWith = intersectionWith; 22613 lodash.invert = invert; 22614 lodash.invertBy = invertBy; 22615 lodash.invokeMap = invokeMap; 22616 lodash.iteratee = iteratee; 22617 lodash.keyBy = keyBy; 22618 lodash.keys = keys; 22619 lodash.keysIn = keysIn; 22620 lodash.map = map; 22621 lodash.mapKeys = mapKeys; 22622 lodash.mapValues = mapValues; 22623 lodash.matches = matches; 22624 lodash.matchesProperty = matchesProperty; 22625 lodash.memoize = memoize; 22626 lodash.merge = merge; 22627 lodash.mergeWith = mergeWith; 22628 lodash.method = method; 22629 lodash.methodOf = methodOf; 22630 lodash.mixin = mixin; 22631 lodash.negate = negate; 22632 lodash.nthArg = nthArg; 22633 lodash.omit = omit; 22634 lodash.omitBy = omitBy; 22635 lodash.once = once; 22636 lodash.orderBy = orderBy; 22637 lodash.over = over; 22638 lodash.overArgs = overArgs; 22639 lodash.overEvery = overEvery; 22640 lodash.overSome = overSome; 22641 lodash.partial = partial; 22642 lodash.partialRight = partialRight; 22643 lodash.partition = partition; 22644 lodash.pick = pick; 22645 lodash.pickBy = pickBy; 22646 lodash.property = property; 22647 lodash.propertyOf = propertyOf; 22648 lodash.pull = pull; 22649 lodash.pullAll = pullAll; 22650 lodash.pullAllBy = pullAllBy; 22651 lodash.pullAllWith = pullAllWith; 22652 lodash.pullAt = pullAt; 22653 lodash.range = range; 22654 lodash.rangeRight = rangeRight; 22655 lodash.rearg = rearg; 22656 lodash.reject = reject; 22657 lodash.remove = remove; 22658 lodash.rest = rest; 22659 lodash.reverse = reverse; 22660 lodash.sampleSize = sampleSize; 22661 lodash.set = set; 22662 lodash.setWith = setWith; 22663 lodash.shuffle = shuffle; 22664 lodash.slice = slice; 22665 lodash.sortBy = sortBy; 22666 lodash.sortedUniq = sortedUniq; 22667 lodash.sortedUniqBy = sortedUniqBy; 22668 lodash.split = split; 22669 lodash.spread = spread; 22670 lodash.tail = tail; 22671 lodash.take = take; 22672 lodash.takeRight = takeRight; 22673 lodash.takeRightWhile = takeRightWhile; 22674 lodash.takeWhile = takeWhile; 22675 lodash.tap = tap; 22676 lodash.throttle = throttle; 22677 lodash.thru = thru; 22678 lodash.toArray = toArray; 22679 lodash.toPairs = toPairs; 22680 lodash.toPairsIn = toPairsIn; 22681 lodash.toPath = toPath; 22682 lodash.toPlainObject = toPlainObject; 22683 lodash.transform = transform; 22684 lodash.unary = unary; 22685 lodash.union = union; 22686 lodash.unionBy = unionBy; 22687 lodash.unionWith = unionWith; 22688 lodash.uniq = uniq; 22689 lodash.uniqBy = uniqBy; 22690 lodash.uniqWith = uniqWith; 22691 lodash.unset = unset; 22692 lodash.unzip = unzip; 22693 lodash.unzipWith = unzipWith; 22694 lodash.update = update; 22695 lodash.updateWith = updateWith; 22696 lodash.values = values; 22697 lodash.valuesIn = valuesIn; 22698 lodash.without = without; 22699 lodash.words = words; 22700 lodash.wrap = wrap; 22701 lodash.xor = xor; 22702 lodash.xorBy = xorBy; 22703 lodash.xorWith = xorWith; 22704 lodash.zip = zip; 22705 lodash.zipObject = zipObject; 22706 lodash.zipObjectDeep = zipObjectDeep; 22707 lodash.zipWith = zipWith; 22708 22709 // Add aliases. 22710 lodash.entries = toPairs; 22711 lodash.entriesIn = toPairsIn; 22712 lodash.extend = assignIn; 22713 lodash.extendWith = assignInWith; 22714 22715 // Add methods to `lodash.prototype`. 22716 mixin(lodash, lodash); 22717 22718 /*------------------------------------------------------------------------*/ 22719 22720 // Add methods that return unwrapped values in chain sequences. 22721 lodash.add = add; 22722 lodash.attempt = attempt; 22723 lodash.camelCase = camelCase; 22724 lodash.capitalize = capitalize; 22725 lodash.ceil = ceil; 22726 lodash.clamp = clamp; 22727 lodash.clone = clone; 22728 lodash.cloneDeep = cloneDeep; 22729 lodash.cloneDeepWith = cloneDeepWith; 22730 lodash.cloneWith = cloneWith; 22731 lodash.conformsTo = conformsTo; 22732 lodash.deburr = deburr; 22733 lodash.defaultTo = defaultTo; 22734 lodash.divide = divide; 22735 lodash.endsWith = endsWith; 22736 lodash.eq = eq; 22737 lodash.escape = escape; 22738 lodash.escapeRegExp = escapeRegExp; 22739 lodash.every = every; 22740 lodash.find = find; 22741 lodash.findIndex = findIndex; 22742 lodash.findKey = findKey; 22743 lodash.findLast = findLast; 22744 lodash.findLastIndex = findLastIndex; 22745 lodash.findLastKey = findLastKey; 22746 lodash.floor = floor; 22747 lodash.forEach = forEach; 22748 lodash.forEachRight = forEachRight; 22749 lodash.forIn = forIn; 22750 lodash.forInRight = forInRight; 22751 lodash.forOwn = forOwn; 22752 lodash.forOwnRight = forOwnRight; 22753 lodash.get = get; 22754 lodash.gt = gt; 22755 lodash.gte = gte; 22756 lodash.has = has; 22757 lodash.hasIn = hasIn; 22758 lodash.head = head; 22759 lodash.identity = identity; 22760 lodash.includes = includes; 22761 lodash.indexOf = indexOf; 22762 lodash.inRange = inRange; 22763 lodash.invoke = invoke; 22764 lodash.isArguments = isArguments; 22765 lodash.isArray = isArray; 22766 lodash.isArrayBuffer = isArrayBuffer; 22767 lodash.isArrayLike = isArrayLike; 22768 lodash.isArrayLikeObject = isArrayLikeObject; 22769 lodash.isBoolean = isBoolean; 22770 lodash.isBuffer = isBuffer; 22771 lodash.isDate = isDate; 22772 lodash.isElement = isElement; 22773 lodash.isEmpty = isEmpty; 22774 lodash.isEqual = isEqual; 22775 lodash.isEqualWith = isEqualWith; 22776 lodash.isError = isError; 22777 lodash.isFinite = isFinite; 22778 lodash.isFunction = isFunction; 22779 lodash.isInteger = isInteger; 22780 lodash.isLength = isLength; 22781 lodash.isMap = isMap; 22782 lodash.isMatch = isMatch; 22783 lodash.isMatchWith = isMatchWith; 22784 lodash.isNaN = isNaN; 22785 lodash.isNative = isNative; 22786 lodash.isNil = isNil; 22787 lodash.isNull = isNull; 22788 lodash.isNumber = isNumber; 22789 lodash.isObject = isObject; 22790 lodash.isObjectLike = isObjectLike; 22791 lodash.isPlainObject = isPlainObject; 22792 lodash.isRegExp = isRegExp; 22793 lodash.isSafeInteger = isSafeInteger; 22794 lodash.isSet = isSet; 22795 lodash.isString = isString; 22796 lodash.isSymbol = isSymbol; 22797 lodash.isTypedArray = isTypedArray; 22798 lodash.isUndefined = isUndefined; 22799 lodash.isWeakMap = isWeakMap; 22800 lodash.isWeakSet = isWeakSet; 22801 lodash.join = join; 22802 lodash.kebabCase = kebabCase; 22803 lodash.last = last; 22804 lodash.lastIndexOf = lastIndexOf; 22805 lodash.lowerCase = lowerCase; 22806 lodash.lowerFirst = lowerFirst; 22807 lodash.lt = lt; 22808 lodash.lte = lte; 22809 lodash.max = max; 22810 lodash.maxBy = maxBy; 22811 lodash.mean = mean; 22812 lodash.meanBy = meanBy; 22813 lodash.min = min; 22814 lodash.minBy = minBy; 22815 lodash.stubArray = stubArray; 22816 lodash.stubFalse = stubFalse; 22817 lodash.stubObject = stubObject; 22818 lodash.stubString = stubString; 22819 lodash.stubTrue = stubTrue; 22820 lodash.multiply = multiply; 22821 lodash.nth = nth; 22822 lodash.noConflict = noConflict; 22823 lodash.noop = noop; 22824 lodash.now = now; 22825 lodash.pad = pad; 22826 lodash.padEnd = padEnd; 22827 lodash.padStart = padStart; 22828 lodash.parseInt = parseInt; 22829 lodash.random = random; 22830 lodash.reduce = reduce; 22831 lodash.reduceRight = reduceRight; 22832 lodash.repeat = repeat; 22833 lodash.replace = replace; 22834 lodash.result = result; 22835 lodash.round = round; 22836 lodash.runInContext = runInContext; 22837 lodash.sample = sample; 22838 lodash.size = size; 22839 lodash.snakeCase = snakeCase; 22840 lodash.some = some; 22841 lodash.sortedIndex = sortedIndex; 22842 lodash.sortedIndexBy = sortedIndexBy; 22843 lodash.sortedIndexOf = sortedIndexOf; 22844 lodash.sortedLastIndex = sortedLastIndex; 22845 lodash.sortedLastIndexBy = sortedLastIndexBy; 22846 lodash.sortedLastIndexOf = sortedLastIndexOf; 22847 lodash.startCase = startCase; 22848 lodash.startsWith = startsWith; 22849 lodash.subtract = subtract; 22850 lodash.sum = sum; 22851 lodash.sumBy = sumBy; 22852 lodash.template = template; 22853 lodash.times = times; 22854 lodash.toFinite = toFinite; 22855 lodash.toInteger = toInteger; 22856 lodash.toLength = toLength; 22857 lodash.toLower = toLower; 22858 lodash.toNumber = toNumber; 22859 lodash.toSafeInteger = toSafeInteger; 22860 lodash.toString = toString; 22861 lodash.toUpper = toUpper; 22862 lodash.trim = trim; 22863 lodash.trimEnd = trimEnd; 22864 lodash.trimStart = trimStart; 22865 lodash.truncate = truncate; 22866 lodash.unescape = unescape; 22867 lodash.uniqueId = uniqueId; 22868 lodash.upperCase = upperCase; 22869 lodash.upperFirst = upperFirst; 22870 22871 // Add aliases. 22872 lodash.each = forEach; 22873 lodash.eachRight = forEachRight; 22874 lodash.first = head; 22875 22876 mixin(lodash, (function() { 22877 var source = {}; 22878 baseForOwn(lodash, function(func, methodName) { 22879 if (!hasOwnProperty.call(lodash.prototype, methodName)) { 22880 source[methodName] = func; 22881 } 22882 }); 22883 return source; 22884 }()), { 'chain': false }); 22885 22886 /*------------------------------------------------------------------------*/ 22887 22888 /** 22889 * The semantic version number. 22890 * 22891 * @static 22892 * @memberOf _ 22893 * @type {string} 22894 */ 22895 lodash.VERSION = VERSION; 22896 22897 // Assign default placeholders. 22898 arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) { 22899 lodash[methodName].placeholder = lodash; 22900 }); 22901 22902 // Add `LazyWrapper` methods for `_.drop` and `_.take` variants. 22903 arrayEach(['drop', 'take'], function(methodName, index) { 22904 LazyWrapper.prototype[methodName] = function(n) { 22905 n = n === undefined$1 ? 1 : nativeMax(toInteger(n), 0); 22906 22907 var result = (this.__filtered__ && !index) 22908 ? new LazyWrapper(this) 22909 : this.clone(); 22910 22911 if (result.__filtered__) { 22912 result.__takeCount__ = nativeMin(n, result.__takeCount__); 22913 } else { 22914 result.__views__.push({ 22915 'size': nativeMin(n, MAX_ARRAY_LENGTH), 22916 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') 22917 }); 22918 } 22919 return result; 22920 }; 22921 22922 LazyWrapper.prototype[methodName + 'Right'] = function(n) { 22923 return this.reverse()[methodName](n).reverse(); 22924 }; 22925 }); 22926 22927 // Add `LazyWrapper` methods that accept an `iteratee` value. 22928 arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { 22929 var type = index + 1, 22930 isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG; 22931 22932 LazyWrapper.prototype[methodName] = function(iteratee) { 22933 var result = this.clone(); 22934 result.__iteratees__.push({ 22935 'iteratee': getIteratee(iteratee, 3), 22936 'type': type 22937 }); 22938 result.__filtered__ = result.__filtered__ || isFilter; 22939 return result; 22940 }; 22941 }); 22942 22943 // Add `LazyWrapper` methods for `_.head` and `_.last`. 22944 arrayEach(['head', 'last'], function(methodName, index) { 22945 var takeName = 'take' + (index ? 'Right' : ''); 22946 22947 LazyWrapper.prototype[methodName] = function() { 22948 return this[takeName](1).value()[0]; 22949 }; 22950 }); 22951 22952 // Add `LazyWrapper` methods for `_.initial` and `_.tail`. 22953 arrayEach(['initial', 'tail'], function(methodName, index) { 22954 var dropName = 'drop' + (index ? '' : 'Right'); 22955 22956 LazyWrapper.prototype[methodName] = function() { 22957 return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1); 22958 }; 22959 }); 22960 22961 LazyWrapper.prototype.compact = function() { 22962 return this.filter(identity); 22963 }; 22964 22965 LazyWrapper.prototype.find = function(predicate) { 22966 return this.filter(predicate).head(); 22967 }; 22968 22969 LazyWrapper.prototype.findLast = function(predicate) { 22970 return this.reverse().find(predicate); 22971 }; 22972 22973 LazyWrapper.prototype.invokeMap = baseRest(function(path, args) { 22974 if (typeof path == 'function') { 22975 return new LazyWrapper(this); 22976 } 22977 return this.map(function(value) { 22978 return baseInvoke(value, path, args); 22979 }); 22980 }); 22981 22982 LazyWrapper.prototype.reject = function(predicate) { 22983 return this.filter(negate(getIteratee(predicate))); 22984 }; 22985 22986 LazyWrapper.prototype.slice = function(start, end) { 22987 start = toInteger(start); 22988 22989 var result = this; 22990 if (result.__filtered__ && (start > 0 || end < 0)) { 22991 return new LazyWrapper(result); 22992 } 22993 if (start < 0) { 22994 result = result.takeRight(-start); 22995 } else if (start) { 22996 result = result.drop(start); 22997 } 22998 if (end !== undefined$1) { 22999 end = toInteger(end); 23000 result = end < 0 ? result.dropRight(-end) : result.take(end - start); 23001 } 23002 return result; 23003 }; 23004 23005 LazyWrapper.prototype.takeRightWhile = function(predicate) { 23006 return this.reverse().takeWhile(predicate).reverse(); 23007 }; 23008 23009 LazyWrapper.prototype.toArray = function() { 23010 return this.take(MAX_ARRAY_LENGTH); 23011 }; 23012 23013 // Add `LazyWrapper` methods to `lodash.prototype`. 23014 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 23015 var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), 23016 isTaker = /^(?:head|last)$/.test(methodName), 23017 lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName], 23018 retUnwrapped = isTaker || /^find/.test(methodName); 23019 23020 if (!lodashFunc) { 23021 return; 23022 } 23023 lodash.prototype[methodName] = function() { 23024 var value = this.__wrapped__, 23025 args = isTaker ? [1] : arguments, 23026 isLazy = value instanceof LazyWrapper, 23027 iteratee = args[0], 23028 useLazy = isLazy || isArray(value); 23029 23030 var interceptor = function(value) { 23031 var result = lodashFunc.apply(lodash, arrayPush([value], args)); 23032 return (isTaker && chainAll) ? result[0] : result; 23033 }; 23034 23035 if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) { 23036 // Avoid lazy use if the iteratee has a "length" value other than `1`. 23037 isLazy = useLazy = false; 23038 } 23039 var chainAll = this.__chain__, 23040 isHybrid = !!this.__actions__.length, 23041 isUnwrapped = retUnwrapped && !chainAll, 23042 onlyLazy = isLazy && !isHybrid; 23043 23044 if (!retUnwrapped && useLazy) { 23045 value = onlyLazy ? value : new LazyWrapper(this); 23046 var result = func.apply(value, args); 23047 result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined$1 }); 23048 return new LodashWrapper(result, chainAll); 23049 } 23050 if (isUnwrapped && onlyLazy) { 23051 return func.apply(this, args); 23052 } 23053 result = this.thru(interceptor); 23054 return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result; 23055 }; 23056 }); 23057 23058 // Add `Array` methods to `lodash.prototype`. 23059 arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { 23060 var func = arrayProto[methodName], 23061 chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', 23062 retUnwrapped = /^(?:pop|shift)$/.test(methodName); 23063 23064 lodash.prototype[methodName] = function() { 23065 var args = arguments; 23066 if (retUnwrapped && !this.__chain__) { 23067 var value = this.value(); 23068 return func.apply(isArray(value) ? value : [], args); 23069 } 23070 return this[chainName](function(value) { 23071 return func.apply(isArray(value) ? value : [], args); 23072 }); 23073 }; 23074 }); 23075 23076 // Map minified method names to their real names. 23077 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 23078 var lodashFunc = lodash[methodName]; 23079 if (lodashFunc) { 23080 var key = lodashFunc.name + ''; 23081 if (!hasOwnProperty.call(realNames, key)) { 23082 realNames[key] = []; 23083 } 23084 realNames[key].push({ 'name': methodName, 'func': lodashFunc }); 23085 } 23086 }); 23087 23088 realNames[createHybrid(undefined$1, WRAP_BIND_KEY_FLAG).name] = [{ 23089 'name': 'wrapper', 23090 'func': undefined$1 23091 }]; 23092 23093 // Add methods to `LazyWrapper`. 23094 LazyWrapper.prototype.clone = lazyClone; 23095 LazyWrapper.prototype.reverse = lazyReverse; 23096 LazyWrapper.prototype.value = lazyValue; 23097 23098 // Add chain sequence methods to the `lodash` wrapper. 23099 lodash.prototype.at = wrapperAt; 23100 lodash.prototype.chain = wrapperChain; 23101 lodash.prototype.commit = wrapperCommit; 23102 lodash.prototype.next = wrapperNext; 23103 lodash.prototype.plant = wrapperPlant; 23104 lodash.prototype.reverse = wrapperReverse; 23105 lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; 23106 23107 // Add lazy aliases. 23108 lodash.prototype.first = lodash.prototype.head; 23109 23110 if (symIterator) { 23111 lodash.prototype[symIterator] = wrapperToIterator; 23112 } 23113 return lodash; 23114 }); 23115 23116 /*--------------------------------------------------------------------------*/ 23117 23118 // Export lodash. 23119 var _ = runInContext(); 23120 23121 // Some AMD build optimizers, like r.js, check for condition patterns like: 23122 if (freeModule) { 23123 // Export for Node.js. 23124 (freeModule.exports = _)._ = _; 23125 // Export for CommonJS support. 23126 freeExports._ = _; 23127 } 23128 else { 23129 // Export to the global object. 23130 root._ = _; 23131 } 23132 }.call(lodash)); 23133 } (lodash$1, lodash$1.exports)); 23134 return lodash$1.exports; 23135} 23136
23137requireLodash(); 23138 23139class SplideProductOtherInGamme { 23140 constructor(sliders) { 23141 // if (!container) { 23142 // return; 23143 // } 23144 23145 // console.log('init slider other in same gamme'); 23146 23147 sliders.forEach(slider => { 23148 if (slider) { 23149 let config = this.initConfig(slider); 23150 this.initEvents(slider, config); 23151 23152 if (slider.classList.contains('related-products-splide')) { 23153 this.positionCenter(slider); 23154 23155 const self = this; 23156 window.addEventListener('resize', function(event) { 23157 self.positionCenter(slider); 23158 }, true); 23159 } 23160 } 23161 }); 23162 } 23163 23164 initConfig(slider) { 23165 const config = { 23166 splideConfig: { 23167 // rewind: true, 23168 type: "slide", 23169 // type: "loop", 23170 autoplay: false, // Uncomment to have the progressbar & comment to increase performance 23171 pauseOnHover: false, 23172 gap: "15px", 23173 // cover: true, 23174 // fixedHeight: 500, 23175 pagination: false, 23176 arrows: 23177 slider.querySelectorAll(".splide__slide").length > 4 ? true : false, 23178 // autoWidth: true, 23179 perPage: 4, 23180 // count slides > 4 ? true : false, 23181 drag: 23182 slider.querySelectorAll(".splide__slide").length > 4 ? true : false, 23183 // focus: 0, 23184 // omitEnd: true, 23185 breakpoints: { 23186 1024: { 23187 perPage: 3, 23188 drag: 23189 slider.querySelectorAll(".splide__slide").length > 3 23190 ? true 23191 : false, 23192 arrows: 23193 slider.querySelectorAll(".splide__slide").length > 3 23194 ? true 23195 : false, 23196 }, 23197 768: { 23198 perPage: 2, 23199 drag: 23200 slider.querySelectorAll(".splide__slide").length > 2 23201 ? true 23202 : false, 23203 arrows: 23204 slider.querySelectorAll(".splide__slide").length > 2 23205 ? true 23206 : false, 23207 }, 23208 640: { 23209 destroy: true, 23210 }, 23211 }, 23212 // lazyLoad: "sequential", 23213 }, 23214 }; 23215 23216 return config; 23217 } 23218 23219 initEvents(slider, config) { 23220 new Splide( 23221 slider, 23222 config.splideConfig 23223 ).mount(); 23224 } 23225 23226 positionCenter(slider) { 23227 const container1 = slider.querySelector('.splide__track'); 23228 const container2 = slider.querySelector('.splide__list'); 23229 23230 const width1 = container1.offsetWidth; 23231 23232 const listItems = container2.querySelectorAll('.splide__slide'); 23233 let width2 = 0; 23234 23235 listItems.forEach(item => { 23236 width2 = width2 + item.offsetWidth; 23237 }); 23238 23239 if (width1 > width2) { 23240 container2.style.justifyContent = 'center'; 23241 } else if (width2 > width1) { 23242 container2.style.justifyContent = ''; 23243 } else { 23244 container2.style.justifyContent = ''; 23245 } 23246 } 23247} 23248 23249class SplideGamme {
23250 constructor(containers) { 23251 if (!containers) { 23252 return; 23253 } 23254 23255 containers.forEach(container => { 23256 const slider = { 23257 container, 23258 item: container.querySelector(".splide--gamme"), 23259 }; 23260 23261 if (slider.container) { 23262 let config = this.initConfig(slider); 23263 this.initEvents(slider, config); 23264 } 23265 }); 23266 23267 // this.ui = { 23268 // container, 23269 // item: container.querySelector(".splide--gamme"), 23270 // }; 23271 23272 // if (this.ui.container) { 23273 // this.initConfig(); 23274 // this.initEvents(); 23275 // } 23276 } 23277 23278 initConfig(slider) { 23279 const config = { 23280 splideConfig: { 23281 // rewind: true, 23282 // type: "loop", 23283 autoplay: slider.item.dataset.autoplay == '1' ? true : false, 23284 pauseOnHover: false, 23285 gap: "15px", 23286 // cover: true, 23287 // fixedHeight: 500, 23288 pagination: false, 23289 autoWidth: true, 23290 // perPage: 1, 23291 focus: 0, 23292 omitEnd: true, 23293 arrows: slider.item.querySelectorAll('.splide__slide').length > 3 && slider.item.dataset.arrows == '1' ? true : false, 23294 breakpoints: { 23295 1024: { 23296 perPage: 2, 23297 arrows: slider.item.querySelectorAll('.splide__slide').length > 2 && slider.item.dataset.arrows == '1' ? true : false, 23298 }, 23299 768: { 23300 perPage: 2, 23301 arrows: false, 23302 }, 23303 }, 23304 23305 // breakpoints: { 23306 // 768: { 23307 // fixedHeight: 400, 23308 // }, 23309 // }, 23310 // lazyLoad: "sequential", 23311 }, 23312 }; 23313 23314 return config; 23315 } 23316 23317 initEvents(slider, config) { 23318 new Splide( 23319 slider.item, 23320 config.splideConfig 23321 ).mount(); 23322 } 23323} 23324 23325class SplideExpansion {
23326 constructor(containers) { 23327 if (!containers) { 23328 return; 23329 } 23330 23331 containers.forEach((container) => { 23332 const slider = { 23333 container, 23334 item: container, 23335 }; 23336 23337 if (slider.container) { 23338 let config = this.initConfig(slider); 23339 this.initEvents(slider, config); 23340 } 23341 }); 23342 } 23343 23344 initConfig(slider) { 23345 const config = { 23346 splideConfig: { 23347 autoplay: slider.item.dataset.autoplay == "1" ? true : false, 23348 pauseOnHover: false, 23349 gap: "20px", 23350 pagination: false, 23351 autowidth: true, 23352 focus: 0, 23353 omitEnd: true, 23354 arrows: 23355 slider.item.querySelectorAll(".splide__slide").length > 3 23356 ? true 23357 : false, 23358 breakpoints: { 23359 640: { 23360 destroy: true, 23361 }, 23362 }, 23363 }, 23364 }; 23365 23366 return config; 23367 } 23368 23369 initEvents(slider, config) { 23370 new Splide(slider.item, config.splideConfig).mount(); 23371 } 23372} 23373 23374class GridGamme { 23375 // constant 23376 constructor(container) { 23377 // check if container exist 23378 if (!container) { 23379 return; 23380 } 23381 this.loadMoreButton = document.querySelector( 23382 ".gamme-grid--loadmore--button" 23383 ); 23384 this.gammeGrid = document.querySelector(".gamme-grid"); 23385 if (!this.gammeGrid) { 23386 return; 23387 } 23388 this.openSize = document.querySelector(".gamme-grid--wrapper").offsetHeight + "px"; 23389 this.closedSize = this.computeClosedHeightDesktop(); 23390 this.gammeGridWrapper = document.querySelector(".gamme-grid--wrapper"); 23391 23392 // console.log(this.closedSize, this.openSize); 23393 23394 if (this.loadMoreButton) { 23395 window.addEventListener("resize", (e) => { 23396 e.preventDefault(); 23397 this.resize(); 23398 }); 23399 23400 this.init(); 23401 } 23402 } 23403 computeClosedHeightDesktop() { 23404 this.gammeCard = document.querySelector(".card-gamme--secondary"); 23405 let h = (this.gammeCard.offsetHeight + 3) * 2 + 15 + "px"; 23406 23407 if (window.matchMedia("(max-width: 768px)").matches) { 23408 h = (this.gammeCard.offsetHeight + 3) * 4 + (15 * 3) + "px"; 23409 } 23410 23411 return h; 23412 } 23413 23414 init() { 23415 // console.log(window.innerWidth); 23416 this.gammeCard = document.querySelector(".card-gamme--secondary"); 23417 this.closedSize = this.computeClosedHeightDesktop(); // 376px for mobile, 650px for desktop 23418 this.gammeGridWrapper.style.height = this.closedSize; 23419 // add event on touchstart for mobile & click for desktop 23420 this.loadMoreButton.addEventListener("click", (e) => { 23421 e.preventDefault(); 23422 this.manageOpenClose(); 23423 }); 23424 } 23425 23426 //windows resize event 23427 resize() { 23428 this.closedSize = this.computeClosedHeightDesktop(); 23429 this.openSize = document.querySelector(".gamme-grid--wrapper").offsetHeight + "px"; 23430 // this.gammeGridWrapper.style.height = this.closedSize; 23431 // this.gammeGrid.classList.remove("open"); 23432 } 23433 23434 // manage open and close 23435 manageOpenClose() { 23436 if (this.gammeGrid.classList.contains("open")) { 23437 this.gammeGrid.classList.remove("open"); 23438 this.gammeGridWrapper.style.height = this.closedSize; 23439 } else { 23440 this.gammeGridWrapper.style.height = this.openSize; 23441 this.gammeGrid.classList.add("open"); 23442 } 23443 } 23444} 23445 23446// import Splide from "@splidejs/splide"; 23447 23448class ProductVideoWrapper { 23449 constructor(container) { 23450 // if (!container) { 23451 // return; 23452 // } 23453 23454 // this.ui = { 23455 // container, 23456 // item: container.querySelector(".splide--gamme"), 23457 // }; 23458 23459 // if (this.ui.container) { 23460 this.init(); 23461 // this.initEvents(); 23462 // } 23463 } 23464 23465 init() { 23466 23467 // parse each element with class .immersion__wrapper--video 23468 const immersionVideoWrappers = document.querySelectorAll(".immersion--click"); 23469 // add click event on each element 23470 immersionVideoWrappers.forEach.call(immersionVideoWrappers, (immersionVideoWrapper) => { 23471 immersionVideoWrapper.addEventListener("click", this.showVideo); 23472 }); 23473 23474 } 23475 23476 showVideo(event) { 23477 const immersionVideoWrapper = event.currentTarget.parentNode; 23478 const video = immersionVideoWrapper.querySelector(".immersion__video"); 23479 const image = immersionVideoWrapper.querySelector(".immersion--click"); 23480 23481 const iframe = immersionVideoWrapper.querySelector("iframe"); 23482 if (iframe) { 23483 // Case 1: cookies accepted, iframe already in the DOM 23484 const src = iframe.getAttribute("src") || ""; 23485 const sep = src.includes("?") ? "&" : "?"; 23486 iframe.setAttribute("allow", "autoplay"); 23487 iframe.setAttribute("src", src.includes("autoplay=1") ? src : src + sep + "autoplay=1"); 23488 } else { 23489 // Case 2: Didomi placeholder â watch for iframe injection by setConsentStatusForVendor() 23490 const observer = new MutationObserver((mutations) => { 23491 for (const mutation of mutations) { 23492 for (const node of mutation.addedNodes) { 23493 if (node.tagName === "IFRAME") { 23494 const src = node.getAttribute("src") || ""; 23495 const sep = src.includes("?") ? "&" : "?"; 23496 node.setAttribute("allow", "autoplay"); 23497 node.setAttribute("src", src.includes("autoplay=1") ? src : src + sep + "autoplay=1"); 23498 observer.disconnect(); 23499 } 23500 } 23501 } 23502 }); 23503 observer.observe(video, { childList: true }); 23504 } 23505 23506 image.style.display = "none"; 23507 video.style.display = "block"; 23508 } 23509 23510// initEvents() { 23511// new Splide(this.ui.item, this.config.splideConfig).mount(); 23512// } 23513} 23514 23515class BlogTabs { 23516 constructor() { 23517 this.menuElements = document.querySelectorAll("[data-tab]"); 23518 this.pannelElements = document.querySelectorAll(".blog-tabs--panel"); 23519 this.tabClick = this.tabClick.bind(this); 23520 this.bindTabs(); 23521 } 23522 23523 bindTabs() {
23524 this.menuElements.forEach((tab) => { 23525 tab.addEventListener("click", this.tabClick); 23526 }); 23527 } 23528 23529 tabClick(e) { 23530 e.preventDefault(); 23531 e.target.getAttribute('data-tab'); 23532 this.menuElements.forEach((tab) => tab.classList.remove("selected")); 23533 e.target.classList.add("selected"); 23534 this.pannelElements.forEach((t) => t.classList.add("hidden")); 23535 // document.querySelector(`#${id}`).classList.remove('hidden'); 23536 } 23537} 23538 23539class BlogFilters { 23540 constructor(ajax_url, action, nonce) { 23541 this.ajax_url = ajax_url; 23542 this.action = action; 23543 this.nonce = nonce; 23544 this.tags = document.querySelectorAll(".news-filter"); 23545 23546 this.results = document.getElementById("blog-results"); 23547 this.pagination = document.getElementById("blog-pagination"); 23548 this.exclude = this.results.getAttribute("data-exclude"); 23549 this.loading = document.getElementById("blog-filter-loading"); 23550 23551 // Appel après initialisation 23552 this.initFilterFromURL(); 23553 23554 23555 this.paged = this.results.getAttribute("data-paged"); 23556 this.post_per_page = this.results.getAttribute("data-ppp"); 23557 this.fetchData = this.fetchData.bind(this); 23558 // this.tagClick = this.tagClick.bind(this); 23559 this.pageClick = this.pageClick.bind(this); 23560 this.continue = true; 23561 23562 this.bindTags(); 23563 if (this.pagination.getAttribute("data-more") === "click") { 23564 this.bindPagination(); 23565 } else { 23566 // add event on scroll bottom 23567 // console.log('Scroll'); 23568 let recentScroll = false; 23569 window.addEventListener("scroll", () => { 23570 23571 if (window.scrollY + window.innerHeight + 300 >= document.body.scrollHeight && this.continue === true && !recentScroll) { 23572 this.pageScrolled(); 23573 recentScroll = true; 23574 window.setTimeout(() => { 23575 recentScroll = false; 23576 }, 1000); 23577 } 23578 23579 }); 23580 } 23581 } 23582 23583 initFilterFromURL() { 23584 const url = new URL(window.location); 23585 const slug = url.searchParams.get("filter_slug"); 23586 23587 if (!slug) return; // aucun filtre dans l'URL 23588 23589 // Supprimer active et selected de tous les tags
23590 this.tags.forEach((tag) => { 23591 tag.classList.remove("active", "selected"); 23592 }); 23593 23594 // Trouver tous les éléments avec ce slug 23595 const tags = Array.from(this.tags).filter( 23596 (el) => el.getAttribute("data-tab") === slug 23597 ); 23598 23599 if (tags.length) { 23600 // Ajouter "active" et "selected" à tous les éléments correspondants 23601 tags.forEach((tag) => { 23602 tag.classList.add("active", "selected"); 23603 }); 23604 23605 // Déclencher le filtrage AJAX sur le premier élément seulement 23606 // this.tagClick({ target: tags[0] }); 23607 } 23608 } 23609 23610 bindTags() { 23611 this.tags.forEach((tag) => { 23612 // tag.addEventListener("click", this.tagClick); 23613 }); 23614 } 23615 23616 bindPagination() { 23617 const paginationItems = document.querySelectorAll( 23618 "#blog-pagination .page-numbers:not(.current):not(.dots)" 23619 ); 23620 paginationItems.forEach((pageButton) => { 23621 pageButton.addEventListener("click", this.pageClick); 23622 }); 23623 } 23624 23625 pageClick(e) { 23626 e.preventDefault(); 23627 23628 // get from href attribute 23629 const url = e.target.getAttribute("data-href"); 23630 23631 // si l'url est sous ce format (regex) /page/2 on récupère le 2 23632 if (url.match(/\/page\/\d+/)) { 23633 this.paged = url.match(/\/page\/(\d+)/)[1]; 23634 } else if (url == "") { 23635 this.paged = 1; 23636 } else { 23637 const p = new URL(url).pathname.split("/").filter(Boolean).pop(); 23638 this.paged = p; 23639 } 23640 23641 const formData = new FormData(); 23642 const filter = this.results.getAttribute("data-current-cat"); 23643 23644 this.results.style.opacity = 0.2; 23645 this.pagination.style.opacity = 0.2; 23646 23647 formData.append("action", this.action); 23648 formData.append("taxonomie", filter); 23649 formData.append("exclude", this.exclude); 23650 formData.append("post_per_page", this.post_per_page); 23651 formData.append("paged", this.paged); 23652 formData.append("page", this.paged); 23653 formData.append("nonce", this.nonce); 23654 23655 this.fetchData(formData); 23656 } 23657 23658 pageScrolled(e) { 23659 // e.preventDefault(); 23660 const formData = new FormData(); 23661 const filter = this.results.getAttribute("data-current-cat"); 23662 const loading = document.getElementById("loadmore"); 23663 23664 loading.style.opacity = 1; 23665 23666 // this.results.style.opacity = 0.2; 23667 // this.pagination.style.opacity = 0.2; 23668 const currentPage = this.results.getAttribute("data-paged"); 23669 formData.append("action", this.action); 23670 formData.append("taxonomie", filter); 23671 formData.append("exclude", this.exclude); 23672 formData.append("post_per_page", this.post_per_page); 23673 formData.append("paged", currentPage); 23674 formData.append("nonce", this.nonce); 23675 23676 fetch(this.ajax_url, { method: "POST", body: formData }) 23677 .then((response) => { 23678 response.json().then((data) => { 23679 // APPEND 23680 this.results.setAttribute("data-paged", data.paged); 23681 this.continue = data.continue; 23682 23683 // check if data.html contain string "no-results-blog" 23684 if (data.continue === false) { 23685 loading.remove(); 23686 } else { 23687 this.results.innerHTML += data.html; 23688 } 23689 23690 // this.pagination.innerHTML = data.pagination; 23691 // this.results.style.opacity = 1; 23692 // this.pagination.style.opacity = 1; 23693 // this.bindPagination(); 23694 }); 23695 }) 23696 .catch(() => { 23697 this.btnText = "Ooops! Something went wrong!"; 23698 }) 23699 .finally(() => { 23700 loading.style.opacity = 1; 23701 // location.hash = "#blog-results"; 23702 // this.loading.classList.remove("active"); 23703 }); 23704 23705 } 23706 23707 tagClick(e) { 23708 const formData = new FormData(); 23709 let filter = ""; 23710 let slug = ""; 23711 23712 const target = e.target; 23713 23714 if ( 23715 target.classList.contains("active") && 23716 target.classList.contains("blog-tags-filter--item") 23717 ) { 23718 target.classList.remove("active"); 23719 const activeBtn = document.querySelector(".blog-tabs--item-btn.active.selected"); 23720 if (activeBtn) { 23721 filter = activeBtn.getAttribute("data-filter") || ""; 23722 slug = activeBtn.getAttribute("data-tab") || ""; 23723 } 23724 this.results.setAttribute("data-paged", 2); 23725 } else {
23726 this.tags.forEach((tag) => tag.classList.remove("active")); 23727 target.classList.add("active"); 23728 target.classList.add("selected"); 23729 filter = target.getAttribute("data-filter") || ""; 23730 slug = target.getAttribute("data-tab") || ""; 23731 } 23732 23733 this.results.setAttribute("data-current-cat", filter); 23734 this.results.getAttribute("data-exclude"); 23735 this.results.style.opacity = 0.2; 23736 23737 // Mettre à jour lâURL avec le slug 23738 const url = new URL(window.location); 23739 if (slug) { 23740 url.searchParams.set("filter_slug", slug); 23741 } else { 23742 url.searchParams.delete("filter_slug"); 23743 } 23744 window.history.pushState({}, "", url); 23745 23746 formData.append("action", this.action); 23747 formData.append("taxonomie", filter); 23748 formData.append("exclude", this.exclude); 23749 formData.append("post_per_page", this.post_per_page); 23750 formData.append("paged", this.paged); 23751 formData.append("nonce", this.nonce); 23752 23753 this.fetchData(formData); 23754 } 23755 23756 fetchData(formData) { 23757 this.loading.classList.add("active"); 23758 this.loading.classList.remove("!hidden"); 23759 23760 fetch(this.ajax_url, { method: "POST", body: formData }) 23761 .then((response) => { 23762 response.json().then((data) => { 23763 this.results.innerHTML = data.html; 23764 this.pagination.innerHTML = data.pagination; 23765 this.results.style.opacity = 1; 23766 this.pagination.style.opacity = 1; 23767 this.bindPagination(); 23768 }); 23769 23770 // scrol to top of div results 23771 setTimeout(() => { 23772 document.getElementById("blog-results").scrollIntoView(); 23773 }, 10); 23774 }) 23775 .catch(() => { 23776 this.btnText = "Ooops! Something went wrong!"; 23777 }) 23778 .finally(() => { 23779 this.loading.classList.remove("active"); 23780 this.loading.classList.add("!hidden"); 23781 }); 23782 } 23783} 23784 23785class BlogSlider { 23786 constructor(container) { 23787 if (!container) { 23788 return; 23789 } 23790 23791 this.ui = { 23792 container, 23793 splideNewsSelector: container.querySelector(".splide--blog"), 23794 // splideNewsBackgroundSelector: container.querySelector(".splide--blogbg"), 23795 }; 23796 23797 if (this.ui.container) { 23798 this.initConfig(); 23799 this.initEvents(); 23800 } 23801 } 23802 23803 initConfig() { 23804 this.config = { 23805 splideNewsSlider: { 23806 rewind: true, 23807 type: "loop", 23808 autoplay: false, // Uncomment to have the progressbar & comment to increase performance 23809 pauseOnHover: true, 23810 pagination: false, 23811 // isNavigation: true, 23812 breakpoints: { 23813 // 768: { 23814 // fixedHeight: 228, 23815 // height: 228, 23816 // }, 23817 // 1024: { 23818 // fixedHeight: 300, 23819 // height: 300, 23820 // }, 23821 // 1339: { 23822 // fixedHeight: 400, 23823 // height: 400, 23824 // }, 23825 // 1440: { 23826 // fixedHeight: 450, 23827 // height: 450, 23828 // }, 23829 // 1919: { 23830 // fixedHeight: 500, 23831 // height: 500, 23832 // }, 23833 // 1920: { 23834 // fixedHeight: 600, 23835 // height: 600, 23836 // }, 23837 // 2560: { 23838 // fixedHeight: 700, 23839 // height: 700, 23840 // }, 23841 }, 23842 lazyLoad: "sequential", 23843 }, 23844 // splideNewsBg: { 23845 // rewind: true, 23846 // type: "loop", 23847 // autoplay: true, // Uncomment to have the progressbar & comment to increase performance 23848 // pauseOnHover: false, 23849 // cover: true, 23850 // // fixedHeight: 464, 23851 // pagination: false, 23852 // arrows: false, 23853 // // breakpoints: { 23854 // // 768: { 23855 // // fixedHeight: 228, 23856 // // height: 228, 23857 // // }, 23858 // // 1024: { 23859 // // fixedHeight: 300, 23860 // // height: 300, 23861 // // }, 23862 // // 1339: { 23863 // // fixedHeight: 400, 23864 // // height: 400, 23865 // // }, 23866 // // 1440: { 23867 // // fixedHeight: 450, 23868 // // height: 450, 23869 // // }, 23870 // // 1919: { 23871 // // fixedHeight: 500, 23872 // // height: 500, 23873 // // }, 23874 // // 1920: { 23875 // // fixedHeight: 600, 23876 // // height: 600, 23877 // // }, 23878 // // 2560: { 23879 // // fixedHeight: 700, 23880 // // height: 700, 23881 // // }, 23882 // // }, 23883 // lazyLoad: "sequential", 23884 // }, 23885 }; 23886 } 23887 23888 initEvents() { 23889 new Splide( 23890 this.ui.splideNewsSelector, 23891 this.config.splideNewsSlider 23892 ).mount(); 23893 23894 // const bgSlider = new Splide(
23895 // this.ui.splideNewsBackgroundSelector, 23896 // this.config.splideNewsBg 23897 // ).mount(); 23898 // bgSlider.sync(contentSlider); 23899 23900 // new Splide( 23901 // this.ui.splideNewsSliderSelector, 23902 // this.config.splideNewsSlider 23903 // ).mount(); 23904 } 23905} 23906 23907// import tippy from "tippy.js"; 23908// import "tippy.js/dist/tippy.css"; 23909 23910class EventFilters { 23911 constructor(ajax_url, action, nonce) { 23912 // console.log("eventFilters") 23913 // console.log(action) 23914 23915 this.trigger = document.querySelectorAll( 23916 '[data-accordion-event="trigger"]' 23917 ); 23918 23919 this.initEvents(); 23920 23921 this.ajax_url = ajax_url; 23922 this.action = action; 23923 this.nonce = nonce; 23924 this.results = document.getElementById("events-results"); 23925 this.pagination = document.getElementById("blog-pagination"); 23926 this.exclude = this.results.getAttribute("data-exclude"); 23927 // this.exclude = this.results.getAttribute("data-exclude"); 23928 this.loading = document.getElementById("blog-filter-loading"); 23929 23930 this.paged = this.results.getAttribute("data-paged"); 23931 this.post_per_page = this.results.getAttribute("data-ppp"); 23932 this.fetchData = this.fetchData.bind(this); 23933 this.filter = this.filter.bind(this); 23934 this.pageClick = this.pageClick.bind(this); 23935 this.continue = true; 23936 23937 this.temporalfilters = document.querySelectorAll( 23938 'input[name="event_time"]' 23939 ); 23940 // console.log("temporalfilters", this.temporalfilters); 23941 23942 this.form = document.getElementById("filter-blog"); 23943 this.loadOnScroll = this.results.getAttribute("data-loadmore") === "scroll"; 23944 23945 if (this.loadOnScroll) { 23946 this.lmButton = document.getElementById("loadmore"); 23947 this.lmButton.style.display = "none"; 23948 this.bindScroll(); 23949 this.form.addEventListener( 23950 "change", 23951 this.pageScrolled.bind(this, { change: true }) 23952 ); 23953 } else { 23954 this.bindPagination(); 23955 this.form.addEventListener("change", this.filter.bind(this, true)); 23956 } 23957 23958 this.onlyOneDateSelectable(); 23959 23960 this.initViewSwitcher(); 23961 23962 // bind temporalfilters 23963 this.temporalfilters.forEach((temporalfilter) => { 23964 temporalfilter.addEventListener("change", this.filter.bind(this, true)); 23965 }); 23966 23967 23968 // mobile open filters 23969 const openFilters = document.querySelector(".filter-by__title"); 23970 if (openFilters) { 23971 openFilters.addEventListener("click", (e) => { 23972 e.preventDefault(); 23973 // toggle hidden on #filter-blog 23974 const filterForm = document.getElementById("filter-blog"); 23975 if (filterForm.classList.contains("hidden")) { 23976 filterForm.classList.remove("hidden"); 23977 } else { 23978 filterForm.classList.add("hidden"); 23979 } 23980 }); 23981 } 23982 23983 } 23984 23985 initViewSwitcher() { 23986 const grid = document.querySelector(".toggle-style-wrapper"); 23987 if (!grid) return; 23988 23989 const buttons = document.querySelectorAll(".toggle-style"); 23990 if (!buttons) return; 23991 23992 if (buttons.length >= 1) { 23993 buttons.forEach((button) => { 23994 // activate tooltips on button 23995 // let ttContent = button.getAttribute("data-tooltip"); 23996 // console.log("tooltip init", ttContent); 23997 // tippy(button, { 23998 // content: ttContent || "ZZZ", 23999 // placement: "right", 24000 // allowHTML: true, 24001 // }); 24002 24003 // add event listener on button 24004 button.addEventListener("click", function () { 24005 // set local storage 24006 let columns = this.getAttribute("data-columns"); 24007 localStorage.setItem("columns_event", columns); 24008 // remove other button class active and add class active to clicked button 24009 document.querySelectorAll(".toggle-style").forEach((b) => { 24010 b.classList.remove("active"); 24011 }); 24012 24013 this.classList.add("active"); 24014 const gridEvent = document.getElementById("events-results"); 24015 gridEvent.classList.remove("grid-3", "grid-4", "grid-5", "grid-6"); 24016 gridEvent.classList.add(`grid-${columns}`); 24017 }); 24018 }); 24019 } 24020 24021 const columns = localStorage.getItem("columns_event"); 24022 // const currentColumns = document.querySelector(".toggle-style.active"); 24023 // let mustReload = false;
24024 // if (currentColumns !== columns) { 24025 // mustReload = true; 24026 // } 24027 24028 // check on pageLoad if we must reload the view from local storage 24029 24030 // On page load - if columns is not null on load 24031 if (columns) { 24032 // console.log("columns", columns); 24033 // remove class start with grid- and add grid- + columns 24034 document 24035 .getElementById("events-results") 24036 .classList.remove("grid-3", "grid-4", "grid-5", "grid-6"); 24037 document 24038 .getElementById("events-results") 24039 .classList.add(`grid-${columns}`); 24040 24041 // set data-ppp attribute to columns 24042 const ppp = columns == 5 ? 15 : 12; 24043 document.querySelector("#filter-blog").setAttribute("data-ppp", ppp); 24044 // console.log('ppp', ppp); 24045 24046 //remove active class from all buttons 24047 const currentActiveButton = document.querySelector( 24048 ".toggle-style.active" 24049 ); 24050 if (currentActiveButton) { 24051 currentActiveButton.classList.remove("active"); 24052 } 24053 24054 // add class active to button with data-columns = columns 24055 const button = document.querySelector(`[data-columns="${columns}"]`); 24056 button.classList.add("active"); 24057 } 24058 } 24059 24060 onlyOneDateSelectable() { 24061 // add event on check box in #locations to uncheck other checkboxes 24062 const locationsCheckbox = document.querySelectorAll( 24063 "li#date input[type=checkbox]" 24064 );
24065 locationsCheckbox.forEach((location) => { 24066 location.addEventListener("change", (e) => { 24067 if (e.target.checked) { 24068 locationsCheckbox.forEach((loc) => { 24069 if (loc !== e.target) { 24070 loc.checked = false; 24071 } 24072 }); 24073 } 24074 }); 24075 }); 24076 24077 // same with #event_type 24078 const eventTypeCheckbox = document.querySelectorAll( 24079 "li#event_type input[type=checkbox]" 24080 ); 24081 eventTypeCheckbox.forEach((eventType) => { 24082 eventType.addEventListener("change", (e) => { 24083 if (e.target.checked) { 24084 eventTypeCheckbox.forEach((et) => { 24085 if (et !== e.target) { 24086 et.checked = false; 24087 } 24088 }); 24089 } 24090 }); 24091 }); 24092 } 24093 24094 bindScroll() { 24095 // console.log('bindScroll'); 24096 let recentScroll = false; 24097 window.addEventListener("scroll", () => { 24098 if ( 24099 window.scrollY + window.innerHeight + 400 >= 24100 document.body.scrollHeight && 24101 this.continue === true && 24102 !recentScroll 24103 ) { 24104 // console.log('Plop'); 24105 this.pageScrolled(); 24106 recentScroll = true; 24107 window.setTimeout(() => { 24108 recentScroll = false; 24109 }, 1000); 24110 } 24111 }); 24112 } 24113 24114 bindPagination() { 24115 const paginationItems = document.querySelectorAll( 24116 "#blog-pagination .page-numbers:not(.current):not(.dots)" 24117 ); 24118 24119 paginationItems.forEach((pageButton) => { 24120 pageButton.addEventListener("click", this.pageClick); 24121 }); 24122 } 24123 24124 pageScrolled(e) { 24125 let append = true; 24126 24127 this.paged = this.results.getAttribute("data-paged"); 24128 24129 // Form change (and not scroll down) 24130 if (e != undefined && e.change === true) { 24131 append = false; 24132 this.continue = true; 24133 this.results.setAttribute("data-paged", 1); 24134 this.paged = 1; 24135 this.results.style.opacity = 0.2; 24136 } 24137 24138 // console.table('append', append); 24139 // console.table('continue', this.continue); 24140 24141 // if () ( 24142 // console.log('FORM CHANGED'); 24143 // this.results.setAttribute("data-paged", 1); 24144 // } 24145 const formData = new FormData(this.form); 24146 // this.results.style.opacity = 0.2; 24147 24148 formData.append("action", this.action); 24149 formData.append("post_per_page", this.post_per_page); 24150 formData.append("paged", this.paged); 24151 formData.append("nonce", this.nonce); 24152 formData.append("exclude", this.exclude); 24153 formData.append("loadmoreOnScroll", true); 24154 24155 // this.loading.classList.add("active"); 24156 this.lmButton.style.display = "block"; 24157 fetch(this.ajax_url, { method: "POST", body: formData }) 24158 .then((response) => { 24159 response.json().then((data) => { 24160 this.lmButton.style.display = "none"; 24161 if (data.continue === false) { 24162 this.continue = false; 24163 } else { 24164 if (append === true) { 24165 this.results.innerHTML += data.html; 24166 } else { 24167 this.results.innerHTML = data.html; 24168 } 24169 24170 // console.log('paged:', data.paged); 24171 24172 this.results.setAttribute("data-paged", data.paged); 24173 if (data.disableLocation === true) { 24174 document.querySelector("#locations").classList.remove("is-open"); 24175 document.querySelector("#locations").classList.add("disabled"); 24176 } else { 24177 document.querySelector("#locations").classList.remove("disabled"); 24178 } 24179 } 24180 }); 24181 }) 24182 .catch(() => { 24183 this.btnText = "Ooops! Something went wrong!"; 24184 }) 24185 .finally(() => { 24186 this.results.style.opacity = 1; 24187 const el = document.querySelectorAll("li.accordion.is-open"); 24188 // console.log("close dropdown", el); 24189 if (el.length > 0) { 24190 el.forEach((e) => { 24191 e.classList.remove("is-open"); 24192 }); 24193 } 24194 // this.loading.classList.remove("active"); 24195 }); 24196 } 24197 24198 pageClick(e) { 24199 e.preventDefault(); 24200 // const p = e.target.innerText; 24201 const p = new URL(e.target.href).pathname.split("/").filter(Boolean).pop(); 24202 this.paged = p; 24203 this.filter(false); 24204 } 24205 24206 filter(reset) { 24207 if (reset) { 24208 this.results.setAttribute("data-paged", 1); 24209 this.paged = 1; 24210 } 24211 24212 // this.paged = 1; 24213 const formData = new FormData(this.form); 24214 this.results.style.opacity = 0.2; 24215 formData.append("temporalFilter", document.querySelector('input[name="event_time"]:checked').value); 24216 formData.append("paged", this.paged); 24217 formData.append("action", this.action); 24218 formData.append("post_per_page", this.post_per_page); 24219 formData.append("nonce", this.nonce); 24220 formData.append("exclude", this.exclude); 24221 24222 // console.log(formData); 24223 this.fetchData(formData); 24224 } 24225 24226 fetchData(formData) { 24227 this.loading.classList.add("active"); 24228 this.loading.classList.remove("!hidden"); 24229 24230 fetch(this.ajax_url, { method: "POST", body: formData }) 24231 .then((response) => { 24232 response.json().then((data) => { 24233 // console.log(data.paged); 24234 this.results.innerHTML = data.html; 24235 this.results.setAttribute("data-paged", data.paged + 1); 24236 this.pagination.innerHTML = data.pagination; 24237 this.results.style.opacity = 1; 24238 this.pagination.style.opacity = 1; 24239 this.bindPagination(); 24240 if (data.disableLocation === true) { 24241 // this.form.removeEventListener("change", this.filter); 24242 document.querySelector("#locations").classList.remove("is-open"); 24243 document.querySelector("#locations").classList.add("disabled"); 24244 } else { 24245 document.querySelector("#locations").classList.remove("disabled"); 24246 } 24247 }); 24248 24249 // scrol to top of div results 24250 setTimeout(() => { 24251 document.getElementById("events-results").scrollIntoView(); 24252 }, 10); 24253 24254 }) 24255 .catch(() => { 24256 this.btnText = "Ooops! Something went wrong!"; 24257 }) 24258 .finally(() => { 24259 // location.hash = "#events-results"; 24260 this.loading.classList.remove("active"); 24261 this.loading.classList.add("!hidden"); 24262 24263 const el = document.querySelectorAll("li.accordion.is-open"); 24264 // console.log("close dropdown", el); 24265 if (el.length > 0) { 24266 el.forEach((e) => { 24267 e.classList.remove("is-open"); 24268 }); 24269 } 24270 24271 }); 24272 } 24273 24274 initEvents() { 24275 // console.log("EventFilters initEvents", this.trigger); 24276 this.trigger.forEach((trig) => { 24277 trig.addEventListener("click", this.onToggle.bind(this)); 24278 }); 24279 } 24280 24281 onToggle(e) { 24282 e.preventDefault(); 24283 // console.log("EventFilters onToggle"); 24284 // toggle is-open 24285 const container = e.currentTarget.closest( 24286 '[data-accordion-event="container"]' 24287 ); 24288 24289 24290 // check if has class disabled 24291 if(container.classList.contains("disabled")) return; 24292 24293 24294 if (!container) return; 24295 if (container.classList.contains("is-open")) { 24296 container.classList.remove("is-open"); 24297 } else { 24298 container.classList.add("is-open"); 24299 } 24300 } 24301} 24302 24303class SplideShopSlider {
24304 constructor(containers) { 24305 if (!containers) { 24306 return; 24307 } 24308 24309 containers.forEach(container => { 24310 const slider = { 24311 container, 24312 splideShopSliderSelector: container.querySelector(".splide--shop"), 24313 }; 24314 24315 if (slider.container) { 24316 let config = this.initConfig(slider); 24317 this.initEvents(slider, config); 24318 } 24319 }); 24320 } 24321 24322 initConfig(slider) { 24323 const config = { 24324 splideShop: { 24325 type: "slide", 24326 rewind: true, 24327 focus: 0, 24328 omitEnd: true, 24329 24330 // height: '10rem', 24331 // rewind: true, 24332 drag: "free", 24333 pagination: false, 24334 gap: "8px", 24335 autoWidth: true, 24336 // arrows only if > 4 slide 24337 arrows: 24338 slider.splideShopSliderSelector.querySelectorAll(".splide__slide") 24339 .length > 4 24340 ? true 24341 : false, 24342 // responsive 24343 breakpoints: { 24344 1024: { 24345 perPage: 3, 24346 arrows: 24347 slider.splideShopSliderSelector.querySelectorAll(".splide__slide") 24348 .length > 3 24349 ? true 24350 : false, 24351 }, 24352 768: { 24353 perPage: 2, 24354 arrows: 24355 slider.splideShopSliderSelector.querySelectorAll(".splide__slide") 24356 .length > 2 24357 ? true 24358 : false, 24359 }, 24360 640: { 24361 destroy: true, 24362 }, 24363 }, 24364 24365 // lazyLoad: "sequential", 24366 }, 24367 }; 24368 24369 return config; 24370 } 24371 24372 initEvents(slider, config) { 24373 // console.log(this.config.splideShopSlider); 24374 new Splide( 24375 slider.splideShopSliderSelector, 24376 config.splideShop, 24377 ).mount(); 24378 } 24379} 24380 24381var top = 'top'; 24382var bottom = 'bottom'; 24383var right = 'right'; 24384var left = 'left'; 24385var auto = 'auto'; 24386var basePlacements = [top, bottom, right, left]; 24387var start = 'start'; 24388var end = 'end'; 24389var clippingParents = 'clippingParents'; 24390var viewport = 'viewport'; 24391var popper = 'popper'; 24392var reference = 'reference'; 24393var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) { 24394 return acc.concat([placement + "-" + start, placement + "-" + end]); 24395}, []); 24396var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) { 24397 return acc.concat([placement, placement + "-" + start, placement + "-" + end]); 24398}, []); // modifiers that need to read the DOM 24399 24400var beforeRead = 'beforeRead'; 24401var read = 'read'; 24402var afterRead = 'afterRead'; // pure-logic modifiers 24403 24404var beforeMain = 'beforeMain'; 24405var main = 'main'; 24406var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state) 24407 24408var beforeWrite = 'beforeWrite'; 24409var write = 'write'; 24410var afterWrite = 'afterWrite'; 24411var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite]; 24412 24413function getNodeName(element) { 24414 return element ? (element.nodeName || '').toLowerCase() : null; 24415} 24416 24417function getWindow(node) { 24418 if (node == null) { 24419 return window; 24420 } 24421 24422 if (node.toString() !== '[object Window]') { 24423 var ownerDocument = node.ownerDocument; 24424 return ownerDocument ? ownerDocument.defaultView || window : window; 24425 } 24426 24427 return node; 24428} 24429 24430function isElement$1(node) { 24431 var OwnElement = getWindow(node).Element; 24432 return node instanceof OwnElement || node instanceof Element; 24433} 24434 24435function isHTMLElement(node) { 24436 var OwnElement = getWindow(node).HTMLElement; 24437 return node instanceof OwnElement || node instanceof HTMLElement; 24438} 24439 24440function isShadowRoot(node) { 24441 // IE 11 has no ShadowRoot 24442 if (typeof ShadowRoot === 'undefined') { 24443 return false; 24444 } 24445 24446 var OwnElement = getWindow(node).ShadowRoot; 24447 return node instanceof OwnElement || node instanceof ShadowRoot; 24448} 24449 24450// and applies them to the HTMLElements such as popper and arrow 24451 24452function applyStyles(_ref) { 24453 var state = _ref.state; 24454 Object.keys(state.elements).forEach(function (name) { 24455 var style = state.styles[name] || {}; 24456 var attributes = state.attributes[name] || {}; 24457 var element = state.elements[name]; // arrow is optional + virtual elements 24458 24459 if (!isHTMLElement(element) || !getNodeName(element)) { 24460 return; 24461 } // Flow doesn't support to extend this property, but it's the most 24462 // effective way to apply styles to an HTMLElement 24463 // $FlowFixMe[cannot-write] 24464 24465 24466 Object.assign(element.style, style);
vendor: 23,649 bytes, lines 24467-25235
24467 Object.keys(attributes).forEach(function (name) { 24468 var value = attributes[name]; 24469 24470 if (value === false) { 24471 element.removeAttribute(name); 24472 } else { 24473 element.setAttribute(name, value === true ? '' : value); 24474 } 24475 }); 24476 }); 24477} 24478 24479function effect$2(_ref2) { 24480 var state = _ref2.state; 24481 var initialStyles = { 24482 popper: { 24483 position: state.options.strategy, 24484 left: '0', 24485 top: '0', 24486 margin: '0' 24487 }, 24488 arrow: { 24489 position: 'absolute' 24490 }, 24491 reference: {} 24492 }; 24493 Object.assign(state.elements.popper.style, initialStyles.popper); 24494 state.styles = initialStyles; 24495 24496 if (state.elements.arrow) { 24497 Object.assign(state.elements.arrow.style, initialStyles.arrow); 24498 } 24499 24500 return function () { 24501 Object.keys(state.elements).forEach(function (name) { 24502 var element = state.elements[name]; 24503 var attributes = state.attributes[name] || {}; 24504 var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them 24505 24506 var style = styleProperties.reduce(function (style, property) { 24507 style[property] = ''; 24508 return style; 24509 }, {}); // arrow is optional + virtual elements 24510 24511 if (!isHTMLElement(element) || !getNodeName(element)) { 24512 return; 24513 } 24514 24515 Object.assign(element.style, style); 24516 Object.keys(attributes).forEach(function (attribute) { 24517 element.removeAttribute(attribute); 24518 }); 24519 }); 24520 }; 24521} // eslint-disable-next-line import/no-unused-modules 24522 24523 24524const applyStyles$1 = { 24525 name: 'applyStyles', 24526 enabled: true, 24527 phase: 'write', 24528 fn: applyStyles, 24529 effect: effect$2, 24530 requires: ['computeStyles'] 24531}; 24532 24533function getBasePlacement$1(placement) { 24534 return placement.split('-')[0]; 24535} 24536 24537var max = Math.max; 24538var min = Math.min; 24539var round = Math.round; 24540 24541function getUAString() { 24542 var uaData = navigator.userAgentData; 24543 24544 if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) { 24545 return uaData.brands.map(function (item) { 24546 return item.brand + "/" + item.version; 24547 }).join(' '); 24548 } 24549 24550 return navigator.userAgent; 24551} 24552 24553function isLayoutViewport() { 24554 return !/^((?!chrome|android).)*safari/i.test(getUAString()); 24555} 24556 24557function getBoundingClientRect(element, includeScale, isFixedStrategy) { 24558 if (includeScale === void 0) { 24559 includeScale = false; 24560 } 24561 24562 if (isFixedStrategy === void 0) { 24563 isFixedStrategy = false; 24564 } 24565 24566 var clientRect = element.getBoundingClientRect(); 24567 var scaleX = 1; 24568 var scaleY = 1; 24569 24570 if (includeScale && isHTMLElement(element)) { 24571 scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1; 24572 scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1; 24573 } 24574 24575 var _ref = isElement$1(element) ? getWindow(element) : window, 24576 visualViewport = _ref.visualViewport; 24577 24578 var addVisualOffsets = !isLayoutViewport() && isFixedStrategy; 24579 var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX; 24580 var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY; 24581 var width = clientRect.width / scaleX; 24582 var height = clientRect.height / scaleY; 24583 return { 24584 width: width, 24585 height: height, 24586 top: y, 24587 right: x + width, 24588 bottom: y + height, 24589 left: x, 24590 x: x, 24591 y: y 24592 }; 24593} 24594 24595// means it doesn't take into account transforms. 24596 24597function getLayoutRect(element) { 24598 var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed. 24599 // Fixes https://github.com/popperjs/popper-core/issues/1223 24600 24601 var width = element.offsetWidth; 24602 var height = element.offsetHeight; 24603 24604 if (Math.abs(clientRect.width - width) <= 1) { 24605 width = clientRect.width; 24606 } 24607 24608 if (Math.abs(clientRect.height - height) <= 1) { 24609 height = clientRect.height; 24610 } 24611 24612 return { 24613 x: element.offsetLeft, 24614 y: element.offsetTop, 24615 width: width, 24616 height: height 24617 }; 24618} 24619 24620function contains(parent, child) { 24621 var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method 24622 24623 if (parent.contains(child)) { 24624 return true; 24625 } // then fallback to custom implementation with Shadow DOM support 24626 else if (rootNode && isShadowRoot(rootNode)) { 24627 var next = child; 24628 24629 do { 24630 if (next && parent.isSameNode(next)) { 24631 return true; 24632 } // $FlowFixMe[prop-missing]: need a better way to handle this... 24633 24634 24635 next = next.parentNode || next.host; 24636 } while (next); 24637 } // Give up, the result is false 24638 24639 24640 return false; 24641} 24642 24643function getComputedStyle$1(element) { 24644 return getWindow(element).getComputedStyle(element); 24645} 24646 24647function isTableElement(element) { 24648 return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0; 24649} 24650 24651function getDocumentElement(element) { 24652 // $FlowFixMe[incompatible-return]: assume body is always available 24653 return ((isElement$1(element) ? element.ownerDocument : // $FlowFixMe[prop-missing] 24654 element.document) || window.document).documentElement; 24655} 24656 24657function getParentNode(element) { 24658 if (getNodeName(element) === 'html') { 24659 return element; 24660 } 24661 24662 return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle 24663 // $FlowFixMe[incompatible-return] 24664 // $FlowFixMe[prop-missing] 24665 element.assignedSlot || // step into the shadow DOM of the parent of a slotted node 24666 element.parentNode || ( // DOM Element detected 24667 isShadowRoot(element) ? element.host : null) || // ShadowRoot detected 24668 // $FlowFixMe[incompatible-call]: HTMLElement is a Node 24669 getDocumentElement(element) // fallback 24670 24671 ); 24672} 24673 24674function getTrueOffsetParent(element) { 24675 if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837 24676 getComputedStyle$1(element).position === 'fixed') { 24677 return null; 24678 } 24679 24680 return element.offsetParent; 24681} // `.offsetParent` reports `null` for fixed elements, while absolute elements 24682// return the containing block 24683 24684 24685function getContainingBlock(element) { 24686 var isFirefox = /firefox/i.test(getUAString()); 24687 var isIE = /Trident/i.test(getUAString()); 24688 24689 if (isIE && isHTMLElement(element)) { 24690 // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport 24691 var elementCss = getComputedStyle$1(element); 24692 24693 if (elementCss.position === 'fixed') { 24694 return null; 24695 } 24696 } 24697 24698 var currentNode = getParentNode(element); 24699 24700 if (isShadowRoot(currentNode)) { 24701 currentNode = currentNode.host; 24702 } 24703 24704 while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) { 24705 var css = getComputedStyle$1(currentNode); // This is non-exhaustive but covers the most common CSS properties that 24706 // create a containing block. 24707 // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block 24708 24709 if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') { 24710 return currentNode; 24711 } else { 24712 currentNode = currentNode.parentNode; 24713 } 24714 } 24715 24716 return null; 24717} // Gets the closest ancestor positioned element. Handles some edge cases, 24718// such as table ancestors and cross browser bugs. 24719 24720 24721function getOffsetParent(element) { 24722 var window = getWindow(element); 24723 var offsetParent = getTrueOffsetParent(element); 24724 24725 while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') { 24726 offsetParent = getTrueOffsetParent(offsetParent); 24727 } 24728 24729 if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static')) { 24730 return window; 24731 } 24732 24733 return offsetParent || getContainingBlock(element) || window; 24734} 24735 24736function getMainAxisFromPlacement(placement) { 24737 return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y'; 24738} 24739 24740function within(min$1, value, max$1) { 24741 return max(min$1, min(value, max$1)); 24742} 24743function withinMaxClamp(min, value, max) { 24744 var v = within(min, value, max); 24745 return v > max ? max : v; 24746} 24747 24748function getFreshSideObject() { 24749 return { 24750 top: 0, 24751 right: 0, 24752 bottom: 0, 24753 left: 0 24754 }; 24755} 24756 24757function mergePaddingObject(paddingObject) { 24758 return Object.assign({}, getFreshSideObject(), paddingObject); 24759} 24760 24761function expandToHashMap(value, keys) { 24762 return keys.reduce(function (hashMap, key) { 24763 hashMap[key] = value; 24764 return hashMap; 24765 }, {}); 24766} 24767 24768var toPaddingObject = function toPaddingObject(padding, state) { 24769 padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, { 24770 placement: state.placement 24771 })) : padding; 24772 return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements)); 24773}; 24774 24775function arrow(_ref) { 24776 var _state$modifiersData$; 24777 24778 var state = _ref.state, 24779 name = _ref.name, 24780 options = _ref.options; 24781 var arrowElement = state.elements.arrow; 24782 var popperOffsets = state.modifiersData.popperOffsets; 24783 var basePlacement = getBasePlacement$1(state.placement); 24784 var axis = getMainAxisFromPlacement(basePlacement); 24785 var isVertical = [left, right].indexOf(basePlacement) >= 0; 24786 var len = isVertical ? 'height' : 'width'; 24787 24788 if (!arrowElement || !popperOffsets) { 24789 return; 24790 } 24791 24792 var paddingObject = toPaddingObject(options.padding, state); 24793 var arrowRect = getLayoutRect(arrowElement); 24794 var minProp = axis === 'y' ? top : left; 24795 var maxProp = axis === 'y' ? bottom : right; 24796 var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len]; 24797 var startDiff = popperOffsets[axis] - state.rects.reference[axis]; 24798 var arrowOffsetParent = getOffsetParent(arrowElement); 24799 var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0; 24800 var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is 24801 // outside of the popper bounds 24802 24803 var min = paddingObject[minProp]; 24804 var max = clientSize - arrowRect[len] - paddingObject[maxProp]; 24805 var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference; 24806 var offset = within(min, center, max); // Prevents breaking syntax highlighting... 24807 24808 var axisProp = axis; 24809 state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$); 24810} 24811 24812function effect$1(_ref2) { 24813 var state = _ref2.state, 24814 options = _ref2.options; 24815 var _options$element = options.element, 24816 arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element; 24817 24818 if (arrowElement == null) { 24819 return; 24820 } // CSS selector 24821 24822 24823 if (typeof arrowElement === 'string') { 24824 arrowElement = state.elements.popper.querySelector(arrowElement); 24825 24826 if (!arrowElement) { 24827 return; 24828 } 24829 } 24830 24831 if (!contains(state.elements.popper, arrowElement)) { 24832 return; 24833 } 24834 24835 state.elements.arrow = arrowElement; 24836} // eslint-disable-next-line import/no-unused-modules 24837 24838 24839const arrow$1 = { 24840 name: 'arrow', 24841 enabled: true, 24842 phase: 'main', 24843 fn: arrow, 24844 effect: effect$1, 24845 requires: ['popperOffsets'], 24846 requiresIfExists: ['preventOverflow'] 24847}; 24848 24849function getVariation(placement) { 24850 return placement.split('-')[1]; 24851} 24852 24853var unsetSides = { 24854 top: 'auto', 24855 right: 'auto', 24856 bottom: 'auto', 24857 left: 'auto' 24858}; // Round the offsets to the nearest suitable subpixel based on the DPR. 24859// Zooming can change the DPR, but it seems to report a value that will 24860// cleanly divide the values into the appropriate subpixels. 24861 24862function roundOffsetsByDPR(_ref, win) { 24863 var x = _ref.x, 24864 y = _ref.y; 24865 var dpr = win.devicePixelRatio || 1; 24866 return { 24867 x: round(x * dpr) / dpr || 0, 24868 y: round(y * dpr) / dpr || 0 24869 }; 24870} 24871 24872function mapToStyles(_ref2) { 24873 var _Object$assign2; 24874 24875 var popper = _ref2.popper, 24876 popperRect = _ref2.popperRect, 24877 placement = _ref2.placement, 24878 variation = _ref2.variation, 24879 offsets = _ref2.offsets, 24880 position = _ref2.position, 24881 gpuAcceleration = _ref2.gpuAcceleration, 24882 adaptive = _ref2.adaptive, 24883 roundOffsets = _ref2.roundOffsets, 24884 isFixed = _ref2.isFixed; 24885 var _offsets$x = offsets.x, 24886 x = _offsets$x === void 0 ? 0 : _offsets$x, 24887 _offsets$y = offsets.y, 24888 y = _offsets$y === void 0 ? 0 : _offsets$y; 24889 24890 var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({ 24891 x: x, 24892 y: y 24893 }) : { 24894 x: x, 24895 y: y 24896 }; 24897 24898 x = _ref3.x; 24899 y = _ref3.y; 24900 var hasX = offsets.hasOwnProperty('x'); 24901 var hasY = offsets.hasOwnProperty('y'); 24902 var sideX = left; 24903 var sideY = top; 24904 var win = window; 24905 24906 if (adaptive) { 24907 var offsetParent = getOffsetParent(popper); 24908 var heightProp = 'clientHeight'; 24909 var widthProp = 'clientWidth'; 24910 24911 if (offsetParent === getWindow(popper)) { 24912 offsetParent = getDocumentElement(popper); 24913 24914 if (getComputedStyle$1(offsetParent).position !== 'static' && position === 'absolute') { 24915 heightProp = 'scrollHeight'; 24916 widthProp = 'scrollWidth'; 24917 } 24918 } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it 24919 24920 24921 offsetParent = offsetParent; 24922 24923 if (placement === top || (placement === left || placement === right) && variation === end) { 24924 sideY = bottom; 24925 var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing] 24926 offsetParent[heightProp]; 24927 y -= offsetY - popperRect.height; 24928 y *= gpuAcceleration ? 1 : -1; 24929 } 24930 24931 if (placement === left || (placement === top || placement === bottom) && variation === end) { 24932 sideX = right; 24933 var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing] 24934 offsetParent[widthProp]; 24935 x -= offsetX - popperRect.width; 24936 x *= gpuAcceleration ? 1 : -1; 24937 } 24938 } 24939 24940 var commonStyles = Object.assign({ 24941 position: position 24942 }, adaptive && unsetSides); 24943 24944 var _ref4 = roundOffsets === true ? roundOffsetsByDPR({ 24945 x: x, 24946 y: y 24947 }, getWindow(popper)) : { 24948 x: x, 24949 y: y 24950 }; 24951 24952 x = _ref4.x; 24953 y = _ref4.y; 24954 24955 if (gpuAcceleration) { 24956 var _Object$assign; 24957 24958 return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign)); 24959 } 24960 24961 return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2)); 24962} 24963 24964function computeStyles(_ref5) { 24965 var state = _ref5.state, 24966 options = _ref5.options; 24967 var _options$gpuAccelerat = options.gpuAcceleration, 24968 gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat, 24969 _options$adaptive = options.adaptive, 24970 adaptive = _options$adaptive === void 0 ? true : _options$adaptive, 24971 _options$roundOffsets = options.roundOffsets, 24972 roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets; 24973 var commonStyles = { 24974 placement: getBasePlacement$1(state.placement), 24975 variation: getVariation(state.placement), 24976 popper: state.elements.popper, 24977 popperRect: state.rects.popper, 24978 gpuAcceleration: gpuAcceleration, 24979 isFixed: state.options.strategy === 'fixed' 24980 }; 24981 24982 if (state.modifiersData.popperOffsets != null) { 24983 state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, { 24984 offsets: state.modifiersData.popperOffsets, 24985 position: state.options.strategy, 24986 adaptive: adaptive, 24987 roundOffsets: roundOffsets 24988 }))); 24989 } 24990 24991 if (state.modifiersData.arrow != null) { 24992 state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, { 24993 offsets: state.modifiersData.arrow, 24994 position: 'absolute', 24995 adaptive: false, 24996 roundOffsets: roundOffsets 24997 }))); 24998 } 24999 25000 state.attributes.popper = Object.assign({}, state.attributes.popper, { 25001 'data-popper-placement': state.placement 25002 }); 25003} // eslint-disable-next-line import/no-unused-modules 25004 25005 25006const computeStyles$1 = { 25007 name: 'computeStyles', 25008 enabled: true, 25009 phase: 'beforeWrite', 25010 fn: computeStyles, 25011 data: {} 25012}; 25013 25014var passive = { 25015 passive: true 25016}; 25017 25018function effect(_ref) { 25019 var state = _ref.state, 25020 instance = _ref.instance, 25021 options = _ref.options; 25022 var _options$scroll = options.scroll, 25023 scroll = _options$scroll === void 0 ? true : _options$scroll, 25024 _options$resize = options.resize, 25025 resize = _options$resize === void 0 ? true : _options$resize; 25026 var window = getWindow(state.elements.popper); 25027 var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper); 25028 25029 if (scroll) { 25030 scrollParents.forEach(function (scrollParent) { 25031 scrollParent.addEventListener('scroll', instance.update, passive); 25032 }); 25033 } 25034 25035 if (resize) { 25036 window.addEventListener('resize', instance.update, passive); 25037 } 25038 25039 return function () { 25040 if (scroll) { 25041 scrollParents.forEach(function (scrollParent) { 25042 scrollParent.removeEventListener('scroll', instance.update, passive); 25043 }); 25044 } 25045 25046 if (resize) { 25047 window.removeEventListener('resize', instance.update, passive); 25048 } 25049 }; 25050} // eslint-disable-next-line import/no-unused-modules 25051 25052 25053const eventListeners = { 25054 name: 'eventListeners', 25055 enabled: true, 25056 phase: 'write', 25057 fn: function fn() {}, 25058 effect: effect, 25059 data: {} 25060}; 25061 25062var hash$1 = { 25063 left: 'right', 25064 right: 'left', 25065 bottom: 'top', 25066 top: 'bottom' 25067}; 25068function getOppositePlacement(placement) { 25069 return placement.replace(/left|right|bottom|top/g, function (matched) { 25070 return hash$1[matched]; 25071 }); 25072} 25073 25074var hash = { 25075 start: 'end', 25076 end: 'start' 25077}; 25078function getOppositeVariationPlacement(placement) { 25079 return placement.replace(/start|end/g, function (matched) { 25080 return hash[matched]; 25081 }); 25082} 25083 25084function getWindowScroll(node) { 25085 var win = getWindow(node); 25086 var scrollLeft = win.pageXOffset; 25087 var scrollTop = win.pageYOffset; 25088 return { 25089 scrollLeft: scrollLeft, 25090 scrollTop: scrollTop 25091 }; 25092} 25093 25094function getWindowScrollBarX(element) { 25095 // If <html> has a CSS width greater than the viewport, then this will be 25096 // incorrect for RTL. 25097 // Popper 1 is broken in this case and never had a bug report so let's assume 25098 // it's not an issue. I don't think anyone ever specifies width on <html> 25099 // anyway. 25100 // Browsers where the left scrollbar doesn't cause an issue report `0` for 25101 // this (e.g. Edge 2019, IE11, Safari) 25102 return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft; 25103} 25104 25105function getViewportRect(element, strategy) { 25106 var win = getWindow(element); 25107 var html = getDocumentElement(element); 25108 var visualViewport = win.visualViewport; 25109 var width = html.clientWidth; 25110 var height = html.clientHeight; 25111 var x = 0; 25112 var y = 0; 25113 25114 if (visualViewport) { 25115 width = visualViewport.width; 25116 height = visualViewport.height; 25117 var layoutViewport = isLayoutViewport(); 25118 25119 if (layoutViewport || !layoutViewport && strategy === 'fixed') { 25120 x = visualViewport.offsetLeft; 25121 y = visualViewport.offsetTop; 25122 } 25123 } 25124 25125 return { 25126 width: width, 25127 height: height, 25128 x: x + getWindowScrollBarX(element), 25129 y: y 25130 }; 25131} 25132 25133// of the `<html>` and `<body>` rect bounds if horizontally scrollable 25134 25135function getDocumentRect(element) { 25136 var _element$ownerDocumen; 25137 25138 var html = getDocumentElement(element); 25139 var winScroll = getWindowScroll(element); 25140 var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body; 25141 var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0); 25142 var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0); 25143 var x = -winScroll.scrollLeft + getWindowScrollBarX(element); 25144 var y = -winScroll.scrollTop; 25145 25146 if (getComputedStyle$1(body || html).direction === 'rtl') { 25147 x += max(html.clientWidth, body ? body.clientWidth : 0) - width; 25148 } 25149 25150 return { 25151 width: width, 25152 height: height, 25153 x: x, 25154 y: y 25155 }; 25156} 25157 25158function isScrollParent(element) { 25159 // Firefox wants us to check `-x` and `-y` variations as well 25160 var _getComputedStyle = getComputedStyle$1(element), 25161 overflow = _getComputedStyle.overflow, 25162 overflowX = _getComputedStyle.overflowX, 25163 overflowY = _getComputedStyle.overflowY; 25164 25165 return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX); 25166} 25167 25168function getScrollParent(node) { 25169 if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) { 25170 // $FlowFixMe[incompatible-return]: assume body is always available 25171 return node.ownerDocument.body; 25172 } 25173 25174 if (isHTMLElement(node) && isScrollParent(node)) { 25175 return node; 25176 } 25177 25178 return getScrollParent(getParentNode(node)); 25179} 25180 25181/* 25182given a DOM element, return the list of all scroll parents, up the list of ancesors 25183until we get to the top window object. This list is what we attach scroll listeners 25184to, because if any of these parent elements scroll, we'll need to re-calculate the 25185reference element's position. 25186*/ 25187 25188function listScrollParents(element, list) { 25189 var _element$ownerDocumen; 25190 25191 if (list === void 0) { 25192 list = []; 25193 } 25194 25195 var scrollParent = getScrollParent(element); 25196 var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body); 25197 var win = getWindow(scrollParent); 25198 var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent; 25199 var updatedList = list.concat(target); 25200 return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here 25201 updatedList.concat(listScrollParents(getParentNode(target))); 25202} 25203 25204function rectToClientRect(rect) { 25205 return Object.assign({}, rect, { 25206 left: rect.x, 25207 top: rect.y, 25208 right: rect.x + rect.width, 25209 bottom: rect.y + rect.height 25210 }); 25211} 25212 25213function getInnerBoundingClientRect(element, strategy) { 25214 var rect = getBoundingClientRect(element, false, strategy === 'fixed'); 25215 rect.top = rect.top + element.clientTop; 25216 rect.left = rect.left + element.clientLeft; 25217 rect.bottom = rect.top + element.clientHeight; 25218 rect.right = rect.left + element.clientWidth; 25219 rect.width = element.clientWidth; 25220 rect.height = element.clientHeight; 25221 rect.x = rect.left; 25222 rect.y = rect.top; 25223 return rect; 25224} 25225 25226function getClientRectFromMixedType(element, clippingParent, strategy) { 25227 return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement$1(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element))); 25228} // A "clipping parent" is an overflowable container with the characteristic of 25229// clipping (or hiding) overflowing elements with a position different from 25230// `initial` 25231 25232 25233function getClippingParents(element) { 25234 var clippingParents = listScrollParents(getParentNode(element)); 25235 var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle$1
vendor: 11,553 bytes, lines 25235-25557
25235(element).position) >= 0; 25236 var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element; 25237 25238 if (!isElement$1(clipperElement)) { 25239 return []; 25240 } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414 25241 25242 25243 return clippingParents.filter(function (clippingParent) { 25244 return isElement$1(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body'; 25245 }); 25246} // Gets the maximum area that the element is visible in due to any number of 25247// clipping parents 25248 25249 25250function getClippingRect(element, boundary, rootBoundary, strategy) { 25251 var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary); 25252 var clippingParents = [].concat(mainClippingParents, [rootBoundary]); 25253 var firstClippingParent = clippingParents[0]; 25254 var clippingRect = clippingParents.reduce(function (accRect, clippingParent) { 25255 var rect = getClientRectFromMixedType(element, clippingParent, strategy); 25256 accRect.top = max(rect.top, accRect.top); 25257 accRect.right = min(rect.right, accRect.right); 25258 accRect.bottom = min(rect.bottom, accRect.bottom); 25259 accRect.left = max(rect.left, accRect.left); 25260 return accRect; 25261 }, getClientRectFromMixedType(element, firstClippingParent, strategy)); 25262 clippingRect.width = clippingRect.right - clippingRect.left; 25263 clippingRect.height = clippingRect.bottom - clippingRect.top; 25264 clippingRect.x = clippingRect.left; 25265 clippingRect.y = clippingRect.top; 25266 return clippingRect; 25267} 25268 25269function computeOffsets(_ref) { 25270 var reference = _ref.reference, 25271 element = _ref.element, 25272 placement = _ref.placement; 25273 var basePlacement = placement ? getBasePlacement$1(placement) : null; 25274 var variation = placement ? getVariation(placement) : null; 25275 var commonX = reference.x + reference.width / 2 - element.width / 2; 25276 var commonY = reference.y + reference.height / 2 - element.height / 2; 25277 var offsets; 25278 25279 switch (basePlacement) { 25280 case top: 25281 offsets = { 25282 x: commonX, 25283 y: reference.y - element.height 25284 }; 25285 break; 25286 25287 case bottom: 25288 offsets = { 25289 x: commonX, 25290 y: reference.y + reference.height 25291 }; 25292 break; 25293 25294 case right: 25295 offsets = { 25296 x: reference.x + reference.width, 25297 y: commonY 25298 }; 25299 break; 25300 25301 case left: 25302 offsets = { 25303 x: reference.x - element.width, 25304 y: commonY 25305 }; 25306 break; 25307 25308 default: 25309 offsets = { 25310 x: reference.x, 25311 y: reference.y 25312 }; 25313 } 25314 25315 var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null; 25316 25317 if (mainAxis != null) { 25318 var len = mainAxis === 'y' ? 'height' : 'width'; 25319 25320 switch (variation) { 25321 case start: 25322 offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2); 25323 break; 25324 25325 case end: 25326 offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2); 25327 break; 25328 } 25329 } 25330 25331 return offsets; 25332} 25333 25334function detectOverflow(state, options) { 25335 if (options === void 0) { 25336 options = {}; 25337 } 25338 25339 var _options = options, 25340 _options$placement = _options.placement, 25341 placement = _options$placement === void 0 ? state.placement : _options$placement, 25342 _options$strategy = _options.strategy, 25343 strategy = _options$strategy === void 0 ? state.strategy : _options$strategy, 25344 _options$boundary = _options.boundary, 25345 boundary = _options$boundary === void 0 ? clippingParents : _options$boundary, 25346 _options$rootBoundary = _options.rootBoundary, 25347 rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary, 25348 _options$elementConte = _options.elementContext, 25349 elementContext = _options$elementConte === void 0 ? popper : _options$elementConte, 25350 _options$altBoundary = _options.altBoundary, 25351 altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary, 25352 _options$padding = _options.padding, 25353 padding = _options$padding === void 0 ? 0 : _options$padding; 25354 var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements)); 25355 var altContext = elementContext === popper ? reference : popper; 25356 var popperRect = state.rects.popper; 25357 var element = state.elements[altBoundary ? altContext : elementContext]; 25358 var clippingClientRect = getClippingRect(isElement$1(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy); 25359 var referenceClientRect = getBoundingClientRect(state.elements.reference); 25360 var popperOffsets = computeOffsets({ 25361 reference: referenceClientRect, 25362 element: popperRect, 25363 placement: placement 25364 }); 25365 var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets)); 25366 var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect 25367 // 0 or negative = within the clipping rect 25368 25369 var overflowOffsets = { 25370 top: clippingClientRect.top - elementClientRect.top + paddingObject.top, 25371 bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom, 25372 left: clippingClientRect.left - elementClientRect.left + paddingObject.left, 25373 right: elementClientRect.right - clippingClientRect.right + paddingObject.right 25374 }; 25375 var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element 25376 25377 if (elementContext === popper && offsetData) { 25378 var offset = offsetData[placement]; 25379 Object.keys(overflowOffsets).forEach(function (key) { 25380 var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1; 25381 var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x'; 25382 overflowOffsets[key] += offset[axis] * multiply; 25383 }); 25384 } 25385 25386 return overflowOffsets; 25387} 25388 25389function computeAutoPlacement(state, options) { 25390 if (options === void 0) { 25391 options = {}; 25392 } 25393 25394 var _options = options, 25395 placement = _options.placement, 25396 boundary = _options.boundary, 25397 rootBoundary = _options.rootBoundary, 25398 padding = _options.padding, 25399 flipVariations = _options.flipVariations, 25400 _options$allowedAutoP = _options.allowedAutoPlacements, 25401 allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP; 25402 var variation = getVariation(placement); 25403 var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) { 25404 return getVariation(placement) === variation; 25405 }) : basePlacements; 25406 var allowedPlacements = placements$1.filter(function (placement) { 25407 return allowedAutoPlacements.indexOf(placement) >= 0; 25408 }); 25409 25410 if (allowedPlacements.length === 0) { 25411 allowedPlacements = placements$1; 25412 } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions... 25413 25414 25415 var overflows = allowedPlacements.reduce(function (acc, placement) { 25416 acc[placement] = detectOverflow(state, { 25417 placement: placement, 25418 boundary: boundary, 25419 rootBoundary: rootBoundary, 25420 padding: padding 25421 })[getBasePlacement$1(placement)]; 25422 return acc; 25423 }, {}); 25424 return Object.keys(overflows).sort(function (a, b) { 25425 return overflows[a] - overflows[b]; 25426 }); 25427} 25428 25429function getExpandedFallbackPlacements(placement) { 25430 if (getBasePlacement$1(placement) === auto) { 25431 return []; 25432 } 25433 25434 var oppositePlacement = getOppositePlacement(placement); 25435 return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)]; 25436} 25437 25438function flip(_ref) { 25439 var state = _ref.state, 25440 options = _ref.options, 25441 name = _ref.name; 25442 25443 if (state.modifiersData[name]._skip) { 25444 return; 25445 } 25446 25447 var _options$mainAxis = options.mainAxis, 25448 checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, 25449 _options$altAxis = options.altAxis, 25450 checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis, 25451 specifiedFallbackPlacements = options.fallbackPlacements, 25452 padding = options.padding, 25453 boundary = options.boundary, 25454 rootBoundary = options.rootBoundary, 25455 altBoundary = options.altBoundary, 25456 _options$flipVariatio = options.flipVariations, 25457 flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio, 25458 allowedAutoPlacements = options.allowedAutoPlacements; 25459 var preferredPlacement = state.options.placement; 25460 var basePlacement = getBasePlacement$1(preferredPlacement); 25461 var isBasePlacement = basePlacement === preferredPlacement; 25462 var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement)); 25463 var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) { 25464 return acc.concat(getBasePlacement$1(placement) === auto ? computeAutoPlacement(state, { 25465 placement: placement, 25466 boundary: boundary, 25467 rootBoundary: rootBoundary, 25468 padding: padding, 25469 flipVariations: flipVariations, 25470 allowedAutoPlacements: allowedAutoPlacements 25471 }) : placement); 25472 }, []); 25473 var referenceRect = state.rects.reference; 25474 var popperRect = state.rects.popper; 25475 var checksMap = new Map(); 25476 var makeFallbackChecks = true; 25477 var firstFittingPlacement = placements[0]; 25478 25479 for (var i = 0; i < placements.length; i++) { 25480 var placement = placements[i]; 25481 25482 var _basePlacement = getBasePlacement$1(placement); 25483 25484 var isStartVariation = getVariation(placement) === start; 25485 var isVertical = [top, bottom].indexOf(_basePlacement) >= 0; 25486 var len = isVertical ? 'width' : 'height'; 25487 var overflow = detectOverflow(state, { 25488 placement: placement, 25489 boundary: boundary, 25490 rootBoundary: rootBoundary, 25491 altBoundary: altBoundary, 25492 padding: padding 25493 }); 25494 var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top; 25495 25496 if (referenceRect[len] > popperRect[len]) { 25497 mainVariationSide = getOppositePlacement(mainVariationSide); 25498 } 25499 25500 var altVariationSide = getOppositePlacement(mainVariationSide); 25501 var checks = []; 25502 25503 if (checkMainAxis) { 25504 checks.push(overflow[_basePlacement] <= 0); 25505 } 25506 25507 if (checkAltAxis) { 25508 checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0); 25509 } 25510 25511 if (checks.every(function (check) { 25512 return check; 25513 })) { 25514 firstFittingPlacement = placement; 25515 makeFallbackChecks = false; 25516 break; 25517 } 25518 25519 checksMap.set(placement, checks); 25520 } 25521 25522 if (makeFallbackChecks) { 25523 // `2` may be desired in some cases â research later 25524 var numberOfChecks = flipVariations ? 3 : 1; 25525 25526 var _loop = function _loop(_i) { 25527 var fittingPlacement = placements.find(function (placement) { 25528 var checks = checksMap.get(placement); 25529 25530 if (checks) { 25531 return checks.slice(0, _i).every(function (check) { 25532 return check; 25533 }); 25534 } 25535 }); 25536 25537 if (fittingPlacement) { 25538 firstFittingPlacement = fittingPlacement; 25539 return "break"; 25540 } 25541 }; 25542 25543 for (var _i = numberOfChecks; _i > 0; _i--) { 25544 var _ret = _loop(_i); 25545 25546 if (_ret === "break") break; 25547 } 25548 } 25549 25550 if (state.placement !== firstFittingPlacement) { 25551 state.modifiersData[name]._skip = true; 25552 state.placement = firstFittingPlacement; 25553 state.reset = true; 25554 } 25555} // eslint-disable-next-line import/no-unused-modules 25556 25557
vendor: 5,068 bytes, lines 25558-25729
25558const flip$1 = { 25559 name: 'flip', 25560 enabled: true, 25561 phase: 'main', 25562 fn: flip, 25563 requiresIfExists: ['offset'], 25564 data: { 25565 _skip: false 25566 } 25567}; 25568 25569function getSideOffsets(overflow, rect, preventedOffsets) { 25570 if (preventedOffsets === void 0) { 25571 preventedOffsets = { 25572 x: 0, 25573 y: 0 25574 }; 25575 } 25576 25577 return { 25578 top: overflow.top - rect.height - preventedOffsets.y, 25579 right: overflow.right - rect.width + preventedOffsets.x, 25580 bottom: overflow.bottom - rect.height + preventedOffsets.y, 25581 left: overflow.left - rect.width - preventedOffsets.x 25582 }; 25583} 25584 25585function isAnySideFullyClipped(overflow) { 25586 return [top, right, bottom, left].some(function (side) { 25587 return overflow[side] >= 0; 25588 }); 25589} 25590 25591function hide(_ref) { 25592 var state = _ref.state, 25593 name = _ref.name; 25594 var referenceRect = state.rects.reference; 25595 var popperRect = state.rects.popper; 25596 var preventedOffsets = state.modifiersData.preventOverflow; 25597 var referenceOverflow = detectOverflow(state, { 25598 elementContext: 'reference' 25599 }); 25600 var popperAltOverflow = detectOverflow(state, { 25601 altBoundary: true 25602 }); 25603 var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect); 25604 var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets); 25605 var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets); 25606 var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets); 25607 state.modifiersData[name] = { 25608 referenceClippingOffsets: referenceClippingOffsets, 25609 popperEscapeOffsets: popperEscapeOffsets, 25610 isReferenceHidden: isReferenceHidden, 25611 hasPopperEscaped: hasPopperEscaped 25612 }; 25613 state.attributes.popper = Object.assign({}, state.attributes.popper, { 25614 'data-popper-reference-hidden': isReferenceHidden, 25615 'data-popper-escaped': hasPopperEscaped 25616 }); 25617} // eslint-disable-next-line import/no-unused-modules 25618 25619 25620const hide$1 = { 25621 name: 'hide', 25622 enabled: true, 25623 phase: 'main', 25624 requiresIfExists: ['preventOverflow'], 25625 fn: hide 25626}; 25627 25628function distanceAndSkiddingToXY(placement, rects, offset) { 25629 var basePlacement = getBasePlacement$1(placement); 25630 var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1; 25631 25632 var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, { 25633 placement: placement 25634 })) : offset, 25635 skidding = _ref[0], 25636 distance = _ref[1]; 25637 25638 skidding = skidding || 0; 25639 distance = (distance || 0) * invertDistance; 25640 return [left, right].indexOf(basePlacement) >= 0 ? { 25641 x: distance, 25642 y: skidding 25643 } : { 25644 x: skidding, 25645 y: distance 25646 }; 25647} 25648 25649function offset(_ref2) { 25650 var state = _ref2.state, 25651 options = _ref2.options, 25652 name = _ref2.name; 25653 var _options$offset = options.offset, 25654 offset = _options$offset === void 0 ? [0, 0] : _options$offset; 25655 var data = placements.reduce(function (acc, placement) { 25656 acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset); 25657 return acc; 25658 }, {}); 25659 var _data$state$placement = data[state.placement], 25660 x = _data$state$placement.x, 25661 y = _data$state$placement.y; 25662 25663 if (state.modifiersData.popperOffsets != null) { 25664 state.modifiersData.popperOffsets.x += x; 25665 state.modifiersData.popperOffsets.y += y; 25666 } 25667 25668 state.modifiersData[name] = data; 25669} // eslint-disable-next-line import/no-unused-modules 25670 25671 25672const offset$1 = { 25673 name: 'offset', 25674 enabled: true, 25675 phase: 'main', 25676 requires: ['popperOffsets'], 25677 fn: offset 25678}; 25679 25680function popperOffsets(_ref) { 25681 var state = _ref.state, 25682 name = _ref.name; 25683 // Offsets are the actual position the popper needs to have to be 25684 // properly positioned near its reference element 25685 // This is the most basic placement, and will be adjusted by 25686 // the modifiers in the next step 25687 state.modifiersData[name] = computeOffsets({ 25688 reference: state.rects.reference, 25689 element: state.rects.popper, 25690 placement: state.placement 25691 }); 25692} // eslint-disable-next-line import/no-unused-modules 25693 25694 25695const popperOffsets$1 = { 25696 name: 'popperOffsets', 25697 enabled: true, 25698 phase: 'read', 25699 fn: popperOffsets, 25700 data: {} 25701}; 25702 25703function getAltAxis(axis) { 25704 return axis === 'x' ? 'y' : 'x'; 25705} 25706 25707function preventOverflow(_ref) { 25708 var state = _ref.state, 25709 options = _ref.options, 25710 name = _ref.name; 25711 var _options$mainAxis = options.mainAxis, 25712 checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, 25713 _options$altAxis = options.altAxis, 25714 checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis, 25715 boundary = options.boundary, 25716 rootBoundary = options.rootBoundary, 25717 altBoundary = options.altBoundary, 25718 padding = options.padding, 25719 _options$tether = options.tether, 25720 tether = _options$tether === void 0 ? true : _options$tether, 25721 _options$tetherOffset = options.tetherOffset, 25722 tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset; 25723 var overflow = detectOverflow(state, { 25724 boundary: boundary, 25725 rootBoundary: rootBoundary, 25726 padding: padding, 25727 altBoundary: altBoundary 25728 }); 25729 var basePlacement = getBasePlacement$1
vendor: 7,033 bytes, lines 25729-25906
25729(state.placement); 25730 var variation = getVariation(state.placement); 25731 var isBasePlacement = !variation; 25732 var mainAxis = getMainAxisFromPlacement(basePlacement); 25733 var altAxis = getAltAxis(mainAxis); 25734 var popperOffsets = state.modifiersData.popperOffsets; 25735 var referenceRect = state.rects.reference; 25736 var popperRect = state.rects.popper; 25737 var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, { 25738 placement: state.placement 25739 })) : tetherOffset; 25740 var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? { 25741 mainAxis: tetherOffsetValue, 25742 altAxis: tetherOffsetValue 25743 } : Object.assign({ 25744 mainAxis: 0, 25745 altAxis: 0 25746 }, tetherOffsetValue); 25747 var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null; 25748 var data = { 25749 x: 0, 25750 y: 0 25751 }; 25752 25753 if (!popperOffsets) { 25754 return; 25755 } 25756 25757 if (checkMainAxis) { 25758 var _offsetModifierState$; 25759 25760 var mainSide = mainAxis === 'y' ? top : left; 25761 var altSide = mainAxis === 'y' ? bottom : right; 25762 var len = mainAxis === 'y' ? 'height' : 'width'; 25763 var offset = popperOffsets[mainAxis]; 25764 var min$1 = offset + overflow[mainSide]; 25765 var max$1 = offset - overflow[altSide]; 25766 var additive = tether ? -popperRect[len] / 2 : 0; 25767 var minLen = variation === start ? referenceRect[len] : popperRect[len]; 25768 var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go 25769 // outside the reference bounds 25770 25771 var arrowElement = state.elements.arrow; 25772 var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : { 25773 width: 0, 25774 height: 0 25775 }; 25776 var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject(); 25777 var arrowPaddingMin = arrowPaddingObject[mainSide]; 25778 var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want 25779 // to include its full size in the calculation. If the reference is small 25780 // and near the edge of a boundary, the popper can overflow even if the 25781 // reference is not overflowing as well (e.g. virtual elements with no 25782 // width or height) 25783 25784 var arrowLen = within(0, referenceRect[len], arrowRect[len]); 25785 var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis; 25786 var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis; 25787 var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow); 25788 var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0; 25789 var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0; 25790 var tetherMin = offset + minOffset - offsetModifierValue - clientOffset; 25791 var tetherMax = offset + maxOffset - offsetModifierValue; 25792 var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1); 25793 popperOffsets[mainAxis] = preventedOffset; 25794 data[mainAxis] = preventedOffset - offset; 25795 } 25796 25797 if (checkAltAxis) { 25798 var _offsetModifierState$2; 25799 25800 var _mainSide = mainAxis === 'x' ? top : left; 25801 25802 var _altSide = mainAxis === 'x' ? bottom : right; 25803 25804 var _offset = popperOffsets[altAxis]; 25805 25806 var _len = altAxis === 'y' ? 'height' : 'width'; 25807 25808 var _min = _offset + overflow[_mainSide]; 25809 25810 var _max = _offset - overflow[_altSide]; 25811 25812 var isOriginSide = [top, left].indexOf(basePlacement) !== -1; 25813 25814 var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0; 25815 25816 var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis; 25817 25818 var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max; 25819 25820 var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max); 25821 25822 popperOffsets[altAxis] = _preventedOffset; 25823 data[altAxis] = _preventedOffset - _offset; 25824 } 25825 25826 state.modifiersData[name] = data; 25827} // eslint-disable-next-line import/no-unused-modules 25828 25829 25830const preventOverflow$1 = { 25831 name: 'preventOverflow', 25832 enabled: true, 25833 phase: 'main', 25834 fn: preventOverflow, 25835 requiresIfExists: ['offset'] 25836}; 25837 25838function getHTMLElementScroll(element) { 25839 return { 25840 scrollLeft: element.scrollLeft, 25841 scrollTop: element.scrollTop 25842 }; 25843} 25844 25845function getNodeScroll(node) { 25846 if (node === getWindow(node) || !isHTMLElement(node)) { 25847 return getWindowScroll(node); 25848 } else { 25849 return getHTMLElementScroll(node); 25850 } 25851} 25852 25853function isElementScaled(element) { 25854 var rect = element.getBoundingClientRect(); 25855 var scaleX = round(rect.width) / element.offsetWidth || 1; 25856 var scaleY = round(rect.height) / element.offsetHeight || 1; 25857 return scaleX !== 1 || scaleY !== 1; 25858} // Returns the composite rect of an element relative to its offsetParent. 25859// Composite means it takes into account transforms as well as layout. 25860 25861 25862function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) { 25863 if (isFixed === void 0) { 25864 isFixed = false; 25865 } 25866 25867 var isOffsetParentAnElement = isHTMLElement(offsetParent); 25868 var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent); 25869 var documentElement = getDocumentElement(offsetParent); 25870 var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed); 25871 var scroll = { 25872 scrollLeft: 0, 25873 scrollTop: 0 25874 }; 25875 var offsets = { 25876 x: 0, 25877 y: 0 25878 }; 25879 25880 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { 25881 if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078 25882 isScrollParent(documentElement)) { 25883 scroll = getNodeScroll(offsetParent); 25884 } 25885 25886 if (isHTMLElement(offsetParent)) { 25887 offsets = getBoundingClientRect(offsetParent, true); 25888 offsets.x += offsetParent.clientLeft; 25889 offsets.y += offsetParent.clientTop; 25890 } else if (documentElement) { 25891 offsets.x = getWindowScrollBarX(documentElement); 25892 } 25893 } 25894 25895 return { 25896 x: rect.left + scroll.scrollLeft - offsets.x, 25897 y: rect.top + scroll.scrollTop - offsets.y, 25898 width: rect.width, 25899 height: rect.height 25900 }; 25901} 25902 25903function order(modifiers) { 25904 var map = new Map(); 25905 var visited = new Set(); 25906 var result = [];
vendor: 8,811 bytes, lines 25907-26169
25907 modifiers.forEach(function (modifier) { 25908 map.set(modifier.name, modifier); 25909 }); // On visiting object, check for its dependencies and visit them recursively 25910 25911 function sort(modifier) { 25912 visited.add(modifier.name); 25913 var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []); 25914 requires.forEach(function (dep) { 25915 if (!visited.has(dep)) { 25916 var depModifier = map.get(dep); 25917 25918 if (depModifier) { 25919 sort(depModifier); 25920 } 25921 } 25922 }); 25923 result.push(modifier); 25924 } 25925 25926 modifiers.forEach(function (modifier) { 25927 if (!visited.has(modifier.name)) { 25928 // check for visited object 25929 sort(modifier); 25930 } 25931 }); 25932 return result; 25933} 25934 25935function orderModifiers(modifiers) { 25936 // order based on dependencies 25937 var orderedModifiers = order(modifiers); // order based on phase 25938 25939 return modifierPhases.reduce(function (acc, phase) { 25940 return acc.concat(orderedModifiers.filter(function (modifier) { 25941 return modifier.phase === phase; 25942 })); 25943 }, []); 25944} 25945 25946function debounce$1(fn) { 25947 var pending; 25948 return function () { 25949 if (!pending) { 25950 pending = new Promise(function (resolve) { 25951 Promise.resolve().then(function () { 25952 pending = undefined; 25953 resolve(fn()); 25954 }); 25955 }); 25956 } 25957 25958 return pending; 25959 }; 25960} 25961 25962function mergeByName(modifiers) { 25963 var merged = modifiers.reduce(function (merged, current) { 25964 var existing = merged[current.name]; 25965 merged[current.name] = existing ? Object.assign({}, existing, current, { 25966 options: Object.assign({}, existing.options, current.options), 25967 data: Object.assign({}, existing.data, current.data) 25968 }) : current; 25969 return merged; 25970 }, {}); // IE11 does not support Object.values 25971 25972 return Object.keys(merged).map(function (key) { 25973 return merged[key]; 25974 }); 25975} 25976 25977var DEFAULT_OPTIONS = { 25978 placement: 'bottom', 25979 modifiers: [], 25980 strategy: 'absolute' 25981}; 25982 25983function areValidElements() { 25984 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 25985 args[_key] = arguments[_key]; 25986 } 25987 25988 return !args.some(function (element) { 25989 return !(element && typeof element.getBoundingClientRect === 'function'); 25990 }); 25991} 25992 25993function popperGenerator(generatorOptions) { 25994 if (generatorOptions === void 0) { 25995 generatorOptions = {}; 25996 } 25997 25998 var _generatorOptions = generatorOptions, 25999 _generatorOptions$def = _generatorOptions.defaultModifiers, 26000 defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def, 26001 _generatorOptions$def2 = _generatorOptions.defaultOptions, 26002 defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2; 26003 return function createPopper(reference, popper, options) { 26004 if (options === void 0) { 26005 options = defaultOptions; 26006 } 26007 26008 var state = { 26009 placement: 'bottom', 26010 orderedModifiers: [], 26011 options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions), 26012 modifiersData: {}, 26013 elements: { 26014 reference: reference, 26015 popper: popper 26016 }, 26017 attributes: {}, 26018 styles: {} 26019 }; 26020 var effectCleanupFns = []; 26021 var isDestroyed = false; 26022 var instance = { 26023 state: state, 26024 setOptions: function setOptions(setOptionsAction) { 26025 var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction; 26026 cleanupModifierEffects(); 26027 state.options = Object.assign({}, defaultOptions, state.options, options); 26028 state.scrollParents = { 26029 reference: isElement$1(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [], 26030 popper: listScrollParents(popper) 26031 }; // Orders the modifiers based on their dependencies and `phase` 26032 // properties 26033 26034 var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers 26035 26036 state.orderedModifiers = orderedModifiers.filter(function (m) { 26037 return m.enabled; 26038 }); 26039 runModifierEffects(); 26040 return instance.update(); 26041 }, 26042 // Sync update â it will always be executed, even if not necessary. This 26043 // is useful for low frequency updates where sync behavior simplifies the 26044 // logic. 26045 // For high frequency updates (e.g. `resize` and `scroll` events), always 26046 // prefer the async Popper#update method 26047 forceUpdate: function forceUpdate() { 26048 if (isDestroyed) { 26049 return; 26050 } 26051 26052 var _state$elements = state.elements, 26053 reference = _state$elements.reference, 26054 popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements 26055 // anymore 26056 26057 if (!areValidElements(reference, popper)) { 26058 return; 26059 } // Store the reference and popper rects to be read by modifiers 26060 26061 26062 state.rects = { 26063 reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'), 26064 popper: getLayoutRect(popper) 26065 }; // Modifiers have the ability to reset the current update cycle. The 26066 // most common use case for this is the `flip` modifier changing the 26067 // placement, which then needs to re-run all the modifiers, because the 26068 // logic was previously ran for the previous placement and is therefore 26069 // stale/incorrect 26070 26071 state.reset = false; 26072 state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier 26073 // is filled with the initial data specified by the modifier. This means 26074 // it doesn't persist and is fresh on each update. 26075 // To ensure persistent data, use `${name}#persistent` 26076 26077 state.orderedModifiers.forEach(function (modifier) { 26078 return state.modifiersData[modifier.name] = Object.assign({}, modifier.data); 26079 }); 26080 26081 for (var index = 0; index < state.orderedModifiers.length; index++) { 26082 if (state.reset === true) { 26083 state.reset = false; 26084 index = -1; 26085 continue; 26086 } 26087 26088 var _state$orderedModifie = state.orderedModifiers[index], 26089 fn = _state$orderedModifie.fn, 26090 _state$orderedModifie2 = _state$orderedModifie.options, 26091 _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2, 26092 name = _state$orderedModifie.name; 26093 26094 if (typeof fn === 'function') { 26095 state = fn({ 26096 state: state, 26097 options: _options, 26098 name: name, 26099 instance: instance 26100 }) || state; 26101 } 26102 } 26103 }, 26104 // Async and optimistically optimized update â it will not be executed if 26105 // not necessary (debounced to run at most once-per-tick) 26106 update: debounce$1(function () { 26107 return new Promise(function (resolve) { 26108 instance.forceUpdate(); 26109 resolve(state); 26110 }); 26111 }), 26112 destroy: function destroy() { 26113 cleanupModifierEffects(); 26114 isDestroyed = true; 26115 } 26116 }; 26117 26118 if (!areValidElements(reference, popper)) { 26119 return instance; 26120 } 26121 26122 instance.setOptions(options).then(function (state) { 26123 if (!isDestroyed && options.onFirstUpdate) { 26124 options.onFirstUpdate(state); 26125 } 26126 }); // Modifiers have the ability to execute arbitrary code before the first 26127 // update cycle runs. They will be executed in the same order as the update 26128 // cycle. This is useful when a modifier adds some persistent data that 26129 // other modifiers need to use, but the modifier is run after the dependent 26130 // one. 26131 26132 function runModifierEffects() { 26133 state.orderedModifiers.forEach(function (_ref) { 26134 var name = _ref.name, 26135 _ref$options = _ref.options, 26136 options = _ref$options === void 0 ? {} : _ref$options, 26137 effect = _ref.effect; 26138 26139 if (typeof effect === 'function') { 26140 var cleanupFn = effect({ 26141 state: state, 26142 name: name, 26143 instance: instance, 26144 options: options 26145 }); 26146 26147 var noopFn = function noopFn() {}; 26148 26149 effectCleanupFns.push(cleanupFn || noopFn); 26150 } 26151 }); 26152 } 26153 26154 function cleanupModifierEffects() { 26155 effectCleanupFns.forEach(function (fn) { 26156 return fn(); 26157 }); 26158 effectCleanupFns = []; 26159 } 26160 26161 return instance; 26162 }; 26163} 26164 26165var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1]; 26166var createPopper = /*#__PURE__*/popperGenerator({ 26167 defaultModifiers: defaultModifiers 26168}); // eslint-disable-next-line import/no-unused-modules 26169
vendor: 707 bytes, lines 26170-26192
26170var BOX_CLASS = "tippy-box"; 26171var CONTENT_CLASS = "tippy-content"; 26172var BACKDROP_CLASS = "tippy-backdrop"; 26173var ARROW_CLASS = "tippy-arrow"; 26174var SVG_ARROW_CLASS = "tippy-svg-arrow"; 26175var TOUCH_OPTIONS = { 26176 passive: true, 26177 capture: true 26178}; 26179var TIPPY_DEFAULT_APPEND_TO = function TIPPY_DEFAULT_APPEND_TO2() { 26180 return document.body; 26181}; 26182function getValueAtIndexOrReturn(value, index, defaultValue) { 26183 if (Array.isArray(value)) { 26184 var v = value[index]; 26185 return v == null ? Array.isArray(defaultValue) ? defaultValue[index] : defaultValue : v; 26186 } 26187 return value; 26188} 26189function isType(value, type) { 26190 var str = {}.toString.call(value); 26191 return str.indexOf("[object") === 0 && str.indexOf(type + "]") > -1; 26192}
vendor: 1,736 bytes, lines 26193-26267
26193function invokeWithArgsOrReturn(value, args) { 26194 return typeof value === "function" ? value.apply(void 0, args) : value; 26195} 26196function debounce(fn5, ms) { 26197 if (ms === 0) { 26198 return fn5; 26199 } 26200 var timeout; 26201 return function(arg) { 26202 clearTimeout(timeout); 26203 timeout = setTimeout(function() { 26204 fn5(arg); 26205 }, ms); 26206 }; 26207} 26208function splitBySpaces(value) { 26209 return value.split(/\s+/).filter(Boolean); 26210} 26211function normalizeToArray(value) { 26212 return [].concat(value); 26213} 26214function pushIfUnique(arr, value) { 26215 if (arr.indexOf(value) === -1) { 26216 arr.push(value); 26217 } 26218} 26219function unique(arr) { 26220 return arr.filter(function(item, index) { 26221 return arr.indexOf(item) === index; 26222 }); 26223} 26224function getBasePlacement(placement) { 26225 return placement.split("-")[0]; 26226} 26227function arrayFrom(value) { 26228 return [].slice.call(value); 26229} 26230function removeUndefinedProps(obj) { 26231 return Object.keys(obj).reduce(function(acc, key) { 26232 if (obj[key] !== void 0) { 26233 acc[key] = obj[key]; 26234 } 26235 return acc; 26236 }, {}); 26237} 26238function div() { 26239 return document.createElement("div"); 26240} 26241function isElement(value) { 26242 return ["Element", "Fragment"].some(function(type) { 26243 return isType(value, type); 26244 }); 26245} 26246function isNodeList(value) { 26247 return isType(value, "NodeList"); 26248} 26249function isMouseEvent(value) { 26250 return isType(value, "MouseEvent"); 26251} 26252function isReferenceElement(value) { 26253 return !!(value && value._tippy && value._tippy.reference === value); 26254} 26255function getArrayOfElements(value) { 26256 if (isElement(value)) { 26257 return [value]; 26258 } 26259 if (isNodeList(value)) { 26260 return arrayFrom(value); 26261 } 26262 if (Array.isArray(value)) { 26263 return value; 26264 } 26265 return arrayFrom(document.querySelectorAll(value)); 26266} 26267function setTransitionDuration(els, value) {
vendor: 19,182 bytes, lines 26268-26880
26268 els.forEach(function(el) { 26269 if (el) { 26270 el.style.transitionDuration = value + "ms"; 26271 } 26272 }); 26273} 26274function setVisibilityState(els, state) { 26275 els.forEach(function(el) { 26276 if (el) { 26277 el.setAttribute("data-state", state); 26278 } 26279 }); 26280} 26281function getOwnerDocument(elementOrElements) { 26282 var _element$ownerDocumen; 26283 var _normalizeToArray = normalizeToArray(elementOrElements), element = _normalizeToArray[0]; 26284 return element != null && (_element$ownerDocumen = element.ownerDocument) != null && _element$ownerDocumen.body ? element.ownerDocument : document; 26285} 26286function isCursorOutsideInteractiveBorder(popperTreeData, event) { 26287 var clientX = event.clientX, clientY = event.clientY; 26288 return popperTreeData.every(function(_ref) { 26289 var popperRect = _ref.popperRect, popperState = _ref.popperState, props = _ref.props; 26290 var interactiveBorder = props.interactiveBorder; 26291 var basePlacement = getBasePlacement(popperState.placement); 26292 var offsetData = popperState.modifiersData.offset; 26293 if (!offsetData) { 26294 return true; 26295 } 26296 var topDistance = basePlacement === "bottom" ? offsetData.top.y : 0; 26297 var bottomDistance = basePlacement === "top" ? offsetData.bottom.y : 0; 26298 var leftDistance = basePlacement === "right" ? offsetData.left.x : 0; 26299 var rightDistance = basePlacement === "left" ? offsetData.right.x : 0; 26300 var exceedsTop = popperRect.top - clientY + topDistance > interactiveBorder; 26301 var exceedsBottom = clientY - popperRect.bottom - bottomDistance > interactiveBorder; 26302 var exceedsLeft = popperRect.left - clientX + leftDistance > interactiveBorder; 26303 var exceedsRight = clientX - popperRect.right - rightDistance > interactiveBorder; 26304 return exceedsTop || exceedsBottom || exceedsLeft || exceedsRight; 26305 }); 26306} 26307function updateTransitionEndListener(box, action, listener) { 26308 var method = action + "EventListener"; 26309 ["transitionend", "webkitTransitionEnd"].forEach(function(event) { 26310 box[method](event, listener); 26311 }); 26312} 26313function actualContains(parent, child) { 26314 var target = child; 26315 while (target) { 26316 var _target$getRootNode; 26317 if (parent.contains(target)) { 26318 return true; 26319 } 26320 target = target.getRootNode == null ? void 0 : (_target$getRootNode = target.getRootNode()) == null ? void 0 : _target$getRootNode.host; 26321 } 26322 return false; 26323} 26324var currentInput = { 26325 isTouch: false 26326}; 26327var lastMouseMoveTime = 0; 26328function onDocumentTouchStart() { 26329 if (currentInput.isTouch) { 26330 return; 26331 } 26332 currentInput.isTouch = true; 26333 if (window.performance) { 26334 document.addEventListener("mousemove", onDocumentMouseMove); 26335 } 26336} 26337function onDocumentMouseMove() { 26338 var now = performance.now(); 26339 if (now - lastMouseMoveTime < 20) { 26340 currentInput.isTouch = false; 26341 document.removeEventListener("mousemove", onDocumentMouseMove); 26342 } 26343 lastMouseMoveTime = now; 26344} 26345function onWindowBlur() { 26346 var activeElement = document.activeElement; 26347 if (isReferenceElement(activeElement)) { 26348 var instance = activeElement._tippy; 26349 if (activeElement.blur && !instance.state.isVisible) { 26350 activeElement.blur(); 26351 } 26352 } 26353} 26354function bindGlobalEventListeners() { 26355 document.addEventListener("touchstart", onDocumentTouchStart, TOUCH_OPTIONS); 26356 window.addEventListener("blur", onWindowBlur); 26357} 26358var isBrowser = typeof window !== "undefined" && typeof document !== "undefined"; 26359var isIE11 = isBrowser ? ( 26360 // @ts-ignore 26361 !!window.msCrypto 26362) : false; 26363var pluginProps = { 26364 animateFill: false, 26365 followCursor: false, 26366 inlinePositioning: false, 26367 sticky: false 26368}; 26369var renderProps = { 26370 allowHTML: false, 26371 animation: "fade", 26372 arrow: true, 26373 content: "", 26374 inertia: false, 26375 maxWidth: 350, 26376 role: "tooltip", 26377 theme: "", 26378 zIndex: 9999 26379}; 26380var defaultProps = Object.assign({ 26381 appendTo: TIPPY_DEFAULT_APPEND_TO, 26382 aria: { 26383 content: "auto", 26384 expanded: "auto" 26385 }, 26386 delay: 0, 26387 duration: [300, 250], 26388 getReferenceClientRect: null, 26389 hideOnClick: true, 26390 ignoreAttributes: false, 26391 interactive: false, 26392 interactiveBorder: 2, 26393 interactiveDebounce: 0, 26394 moveTransition: "", 26395 offset: [0, 10], 26396 onAfterUpdate: function onAfterUpdate() { 26397 }, 26398 onBeforeUpdate: function onBeforeUpdate() { 26399 }, 26400 onCreate: function onCreate() { 26401 }, 26402 onDestroy: function onDestroy() { 26403 }, 26404 onHidden: function onHidden() { 26405 }, 26406 onHide: function onHide() { 26407 }, 26408 onMount: function onMount() { 26409 }, 26410 onShow: function onShow() { 26411 }, 26412 onShown: function onShown() { 26413 }, 26414 onTrigger: function onTrigger() { 26415 }, 26416 onUntrigger: function onUntrigger() { 26417 }, 26418 onClickOutside: function onClickOutside() { 26419 }, 26420 placement: "top", 26421 plugins: [], 26422 popperOptions: {}, 26423 render: null, 26424 showOnCreate: false, 26425 touch: true, 26426 trigger: "mouseenter focus", 26427 triggerTarget: null 26428}, pluginProps, renderProps); 26429var defaultKeys = Object.keys(defaultProps); 26430var setDefaultProps = function setDefaultProps2(partialProps) { 26431 var keys = Object.keys(partialProps); 26432 keys.forEach(function(key) { 26433 defaultProps[key] = partialProps[key]; 26434 }); 26435}; 26436function getExtendedPassedProps(passedProps) { 26437 var plugins = passedProps.plugins || []; 26438 var pluginProps2 = plugins.reduce(function(acc, plugin) { 26439 var name = plugin.name, defaultValue = plugin.defaultValue; 26440 if (name) { 26441 var _name; 26442 acc[name] = passedProps[name] !== void 0 ? passedProps[name] : (_name = defaultProps[name]) != null ? _name : defaultValue; 26443 } 26444 return acc; 26445 }, {}); 26446 return Object.assign({}, passedProps, pluginProps2); 26447} 26448function getDataAttributeProps(reference, plugins) { 26449 var propKeys = plugins ? Object.keys(getExtendedPassedProps(Object.assign({}, defaultProps, { 26450 plugins 26451 }))) : defaultKeys; 26452 var props = propKeys.reduce(function(acc, key) { 26453 var valueAsString = (reference.getAttribute("data-tippy-" + key) || "").trim(); 26454 if (!valueAsString) { 26455 return acc; 26456 } 26457 if (key === "content") { 26458 acc[key] = valueAsString; 26459 } else { 26460 try { 26461 acc[key] = JSON.parse(valueAsString); 26462 } catch (e) { 26463 acc[key] = valueAsString; 26464 } 26465 } 26466 return acc; 26467 }, {}); 26468 return props; 26469} 26470function evaluateProps(reference, props) { 26471 var out = Object.assign({}, props, { 26472 content: invokeWithArgsOrReturn(props.content, [reference]) 26473 }, props.ignoreAttributes ? {} : getDataAttributeProps(reference, props.plugins)); 26474 out.aria = Object.assign({}, defaultProps.aria, out.aria); 26475 out.aria = { 26476 expanded: out.aria.expanded === "auto" ? props.interactive : out.aria.expanded, 26477 content: out.aria.content === "auto" ? props.interactive ? null : "describedby" : out.aria.content 26478 }; 26479 return out; 26480} 26481var innerHTML = function innerHTML2() { 26482 return "innerHTML"; 26483}; 26484function dangerouslySetInnerHTML(element, html) { 26485 element[innerHTML()] = html; 26486} 26487function createArrowElement(value) { 26488 var arrow = div(); 26489 if (value === true) { 26490 arrow.className = ARROW_CLASS; 26491 } else { 26492 arrow.className = SVG_ARROW_CLASS; 26493 if (isElement(value)) { 26494 arrow.appendChild(value); 26495 } else { 26496 dangerouslySetInnerHTML(arrow, value); 26497 } 26498 } 26499 return arrow; 26500} 26501function setContent(content, props) { 26502 if (isElement(props.content)) { 26503 dangerouslySetInnerHTML(content, ""); 26504 content.appendChild(props.content); 26505 } else if (typeof props.content !== "function") { 26506 if (props.allowHTML) { 26507 dangerouslySetInnerHTML(content, props.content); 26508 } else { 26509 content.textContent = props.content; 26510 } 26511 } 26512} 26513function getChildren(popper) { 26514 var box = popper.firstElementChild; 26515 var boxChildren = arrayFrom(box.children); 26516 return { 26517 box, 26518 content: boxChildren.find(function(node) { 26519 return node.classList.contains(CONTENT_CLASS); 26520 }), 26521 arrow: boxChildren.find(function(node) { 26522 return node.classList.contains(ARROW_CLASS) || node.classList.contains(SVG_ARROW_CLASS); 26523 }), 26524 backdrop: boxChildren.find(function(node) { 26525 return node.classList.contains(BACKDROP_CLASS); 26526 }) 26527 }; 26528} 26529function render(instance) { 26530 var popper = div(); 26531 var box = div(); 26532 box.className = BOX_CLASS; 26533 box.setAttribute("data-state", "hidden"); 26534 box.setAttribute("tabindex", "-1"); 26535 var content = div(); 26536 content.className = CONTENT_CLASS; 26537 content.setAttribute("data-state", "hidden"); 26538 setContent(content, instance.props); 26539 popper.appendChild(box); 26540 box.appendChild(content); 26541 onUpdate(instance.props, instance.props); 26542 function onUpdate(prevProps, nextProps) { 26543 var _getChildren = getChildren(popper), box2 = _getChildren.box, content2 = _getChildren.content, arrow = _getChildren.arrow; 26544 if (nextProps.theme) { 26545 box2.setAttribute("data-theme", nextProps.theme); 26546 } else { 26547 box2.removeAttribute("data-theme"); 26548 } 26549 if (typeof nextProps.animation === "string") { 26550 box2.setAttribute("data-animation", nextProps.animation); 26551 } else { 26552 box2.removeAttribute("data-animation"); 26553 } 26554 if (nextProps.inertia) { 26555 box2.setAttribute("data-inertia", ""); 26556 } else { 26557 box2.removeAttribute("data-inertia"); 26558 } 26559 box2.style.maxWidth = typeof nextProps.maxWidth === "number" ? nextProps.maxWidth + "px" : nextProps.maxWidth; 26560 if (nextProps.role) { 26561 box2.setAttribute("role", nextProps.role); 26562 } else { 26563 box2.removeAttribute("role"); 26564 } 26565 if (prevProps.content !== nextProps.content || prevProps.allowHTML !== nextProps.allowHTML) { 26566 setContent(content2, instance.props); 26567 } 26568 if (nextProps.arrow) { 26569 if (!arrow) { 26570 box2.appendChild(createArrowElement(nextProps.arrow)); 26571 } else if (prevProps.arrow !== nextProps.arrow) { 26572 box2.removeChild(arrow); 26573 box2.appendChild(createArrowElement(nextProps.arrow)); 26574 } 26575 } else if (arrow) { 26576 box2.removeChild(arrow); 26577 } 26578 } 26579 return { 26580 popper, 26581 onUpdate 26582 }; 26583} 26584render.$$tippy = true; 26585var idCounter = 1; 26586var mouseMoveListeners = []; 26587var mountedInstances = []; 26588function createTippy(reference, passedProps) { 26589 var props = evaluateProps(reference, Object.assign({}, defaultProps, getExtendedPassedProps(removeUndefinedProps(passedProps)))); 26590 var showTimeout; 26591 var hideTimeout; 26592 var scheduleHideAnimationFrame; 26593 var isVisibleFromClick = false; 26594 var didHideDueToDocumentMouseDown = false; 26595 var didTouchMove = false; 26596 var ignoreOnFirstUpdate = false; 26597 var lastTriggerEvent; 26598 var currentTransitionEndListener; 26599 var onFirstUpdate; 26600 var listeners = []; 26601 var debouncedOnMouseMove = debounce(onMouseMove, props.interactiveDebounce); 26602 var currentTarget; 26603 var id = idCounter++; 26604 var popperInstance = null; 26605 var plugins = unique(props.plugins); 26606 var state = { 26607 // Is the instance currently enabled? 26608 isEnabled: true, 26609 // Is the tippy currently showing and not transitioning out? 26610 isVisible: false, 26611 // Has the instance been destroyed? 26612 isDestroyed: false, 26613 // Is the tippy currently mounted to the DOM? 26614 isMounted: false, 26615 // Has the tippy finished transitioning in? 26616 isShown: false 26617 }; 26618 var instance = { 26619 // properties 26620 id, 26621 reference, 26622 popper: div(), 26623 popperInstance, 26624 props, 26625 state, 26626 plugins, 26627 // methods 26628 clearDelayTimeouts, 26629 setProps, 26630 setContent: setContent2, 26631 show, 26632 hide, 26633 hideWithInteractivity, 26634 enable, 26635 disable, 26636 unmount, 26637 destroy 26638 }; 26639 if (!props.render) { 26640 return instance; 26641 } 26642 var _props$render = props.render(instance), popper = _props$render.popper, onUpdate = _props$render.onUpdate; 26643 popper.setAttribute("data-tippy-root", ""); 26644 popper.id = "tippy-" + instance.id; 26645 instance.popper = popper; 26646 reference._tippy = instance; 26647 popper._tippy = instance; 26648 var pluginsHooks = plugins.map(function(plugin) { 26649 return plugin.fn(instance); 26650 }); 26651 var hasAriaExpanded = reference.hasAttribute("aria-expanded"); 26652 addListeners(); 26653 handleAriaExpandedAttribute(); 26654 handleStyles(); 26655 invokeHook("onCreate", [instance]); 26656 if (props.showOnCreate) { 26657 scheduleShow(); 26658 } 26659 popper.addEventListener("mouseenter", function() { 26660 if (instance.props.interactive && instance.state.isVisible) { 26661 instance.clearDelayTimeouts(); 26662 } 26663 }); 26664 popper.addEventListener("mouseleave", function() { 26665 if (instance.props.interactive && instance.props.trigger.indexOf("mouseenter") >= 0) { 26666 getDocument().addEventListener("mousemove", debouncedOnMouseMove); 26667 } 26668 }); 26669 return instance; 26670 function getNormalizedTouchSettings() { 26671 var touch = instance.props.touch; 26672 return Array.isArray(touch) ? touch : [touch, 0]; 26673 } 26674 function getIsCustomTouchBehavior() { 26675 return getNormalizedTouchSettings()[0] === "hold"; 26676 } 26677 function getIsDefaultRenderFn() { 26678 var _instance$props$rende; 26679 return !!((_instance$props$rende = instance.props.render) != null && _instance$props$rende.$$tippy); 26680 } 26681 function getCurrentTarget() { 26682 return currentTarget || reference; 26683 } 26684 function getDocument() { 26685 var parent = getCurrentTarget().parentNode; 26686 return parent ? getOwnerDocument(parent) : document; 26687 } 26688 function getDefaultTemplateChildren() { 26689 return getChildren(popper); 26690 } 26691 function getDelay(isShow) { 26692 if (instance.state.isMounted && !instance.state.isVisible || currentInput.isTouch || lastTriggerEvent && lastTriggerEvent.type === "focus") { 26693 return 0; 26694 } 26695 return getValueAtIndexOrReturn(instance.props.delay, isShow ? 0 : 1, defaultProps.delay); 26696 } 26697 function handleStyles(fromHide) { 26698 if (fromHide === void 0) { 26699 fromHide = false; 26700 } 26701 popper.style.pointerEvents = instance.props.interactive && !fromHide ? "" : "none"; 26702 popper.style.zIndex = "" + instance.props.zIndex; 26703 } 26704 function invokeHook(hook, args, shouldInvokePropsHook) { 26705 if (shouldInvokePropsHook === void 0) { 26706 shouldInvokePropsHook = true; 26707 } 26708 pluginsHooks.forEach(function(pluginHooks) { 26709 if (pluginHooks[hook]) { 26710 pluginHooks[hook].apply(pluginHooks, args); 26711 } 26712 }); 26713 if (shouldInvokePropsHook) { 26714 var _instance$props; 26715 (_instance$props = instance.props)[hook].apply(_instance$props, args); 26716 } 26717 } 26718 function handleAriaContentAttribute() { 26719 var aria = instance.props.aria; 26720 if (!aria.content) { 26721 return; 26722 } 26723 var attr = "aria-" + aria.content; 26724 var id2 = popper.id; 26725 var nodes = normalizeToArray(instance.props.triggerTarget || reference); 26726 nodes.forEach(function(node) { 26727 var currentValue = node.getAttribute(attr); 26728 if (instance.state.isVisible) { 26729 node.setAttribute(attr, currentValue ? currentValue + " " + id2 : id2); 26730 } else { 26731 var nextValue = currentValue && currentValue.replace(id2, "").trim(); 26732 if (nextValue) { 26733 node.setAttribute(attr, nextValue); 26734 } else { 26735 node.removeAttribute(attr); 26736 } 26737 } 26738 }); 26739 } 26740 function handleAriaExpandedAttribute() { 26741 if (hasAriaExpanded || !instance.props.aria.expanded) { 26742 return; 26743 } 26744 var nodes = normalizeToArray(instance.props.triggerTarget || reference); 26745 nodes.forEach(function(node) { 26746 if (instance.props.interactive) { 26747 node.setAttribute("aria-expanded", instance.state.isVisible && node === getCurrentTarget() ? "true" : "false"); 26748 } else { 26749 node.removeAttribute("aria-expanded"); 26750 } 26751 }); 26752 } 26753 function cleanupInteractiveMouseListeners() { 26754 getDocument().removeEventListener("mousemove", debouncedOnMouseMove); 26755 mouseMoveListeners = mouseMoveListeners.filter(function(listener) { 26756 return listener !== debouncedOnMouseMove; 26757 }); 26758 } 26759 function onDocumentPress(event) { 26760 if (currentInput.isTouch) { 26761 if (didTouchMove || event.type === "mousedown") { 26762 return; 26763 } 26764 } 26765 var actualTarget = event.composedPath && event.composedPath()[0] || event.target; 26766 if (instance.props.interactive && actualContains(popper, actualTarget)) { 26767 return; 26768 } 26769 if (normalizeToArray(instance.props.triggerTarget || reference).some(function(el) { 26770 return actualContains(el, actualTarget); 26771 })) { 26772 if (currentInput.isTouch) { 26773 return; 26774 } 26775 if (instance.state.isVisible && instance.props.trigger.indexOf("click") >= 0) { 26776 return; 26777 } 26778 } else { 26779 invokeHook("onClickOutside", [instance, event]); 26780 } 26781 if (instance.props.hideOnClick === true) { 26782 instance.clearDelayTimeouts(); 26783 instance.hide(); 26784 didHideDueToDocumentMouseDown = true; 26785 setTimeout(function() { 26786 didHideDueToDocumentMouseDown = false; 26787 }); 26788 if (!instance.state.isMounted) { 26789 removeDocumentPress(); 26790 } 26791 } 26792 } 26793 function onTouchMove() { 26794 didTouchMove = true; 26795 } 26796 function onTouchStart() { 26797 didTouchMove = false; 26798 } 26799 function addDocumentPress() { 26800 var doc = getDocument(); 26801 doc.addEventListener("mousedown", onDocumentPress, true); 26802 doc.addEventListener("touchend", onDocumentPress, TOUCH_OPTIONS); 26803 doc.addEventListener("touchstart", onTouchStart, TOUCH_OPTIONS); 26804 doc.addEventListener("touchmove", onTouchMove, TOUCH_OPTIONS); 26805 } 26806 function removeDocumentPress() { 26807 var doc = getDocument(); 26808 doc.removeEventListener("mousedown", onDocumentPress, true); 26809 doc.removeEventListener("touchend", onDocumentPress, TOUCH_OPTIONS); 26810 doc.removeEventListener("touchstart", onTouchStart, TOUCH_OPTIONS); 26811 doc.removeEventListener("touchmove", onTouchMove, TOUCH_OPTIONS); 26812 } 26813 function onTransitionedOut(duration, callback) { 26814 onTransitionEnd(duration, function() { 26815 if (!instance.state.isVisible && popper.parentNode && popper.parentNode.contains(popper)) { 26816 callback(); 26817 } 26818 }); 26819 } 26820 function onTransitionedIn(duration, callback) { 26821 onTransitionEnd(duration, callback); 26822 } 26823 function onTransitionEnd(duration, callback) { 26824 var box = getDefaultTemplateChildren().box; 26825 function listener(event) { 26826 if (event.target === box) { 26827 updateTransitionEndListener(box, "remove", listener); 26828 callback(); 26829 } 26830 } 26831 if (duration === 0) { 26832 return callback(); 26833 } 26834 updateTransitionEndListener(box, "remove", currentTransitionEndListener); 26835 updateTransitionEndListener(box, "add", listener); 26836 currentTransitionEndListener = listener; 26837 } 26838 function on(eventType, handler, options) { 26839 if (options === void 0) { 26840 options = false; 26841 } 26842 var nodes = normalizeToArray(instance.props.triggerTarget || reference); 26843 nodes.forEach(function(node) { 26844 node.addEventListener(eventType, handler, options); 26845 listeners.push({ 26846 node, 26847 eventType, 26848 handler, 26849 options 26850 }); 26851 }); 26852 } 26853 function addListeners() { 26854 if (getIsCustomTouchBehavior()) { 26855 on("touchstart", onTrigger2, { 26856 passive: true 26857 }); 26858 on("touchend", onMouseLeave, { 26859 passive: true 26860 }); 26861 } 26862 splitBySpaces(instance.props.trigger).forEach(function(eventType) { 26863 if (eventType === "manual") { 26864 return; 26865 } 26866 on(eventType, onTrigger2); 26867 switch (eventType) { 26868 case "mouseenter": 26869 on("mouseleave", onMouseLeave); 26870 break; 26871 case "focus": 26872 on(isIE11 ? "focusout" : "blur", onBlurOrFocusOut); 26873 break; 26874 case "focusin": 26875 on("focusout", onBlurOrFocusOut); 26876 break; 26877 } 26878 }); 26879 } 26880 function removeListeners() {
vendor: 4,128 bytes, lines 26881-26981
26881 listeners.forEach(function(_ref) { 26882 var node = _ref.node, eventType = _ref.eventType, handler = _ref.handler, options = _ref.options; 26883 node.removeEventListener(eventType, handler, options); 26884 }); 26885 listeners = []; 26886 } 26887 function onTrigger2(event) { 26888 var _lastTriggerEvent; 26889 var shouldScheduleClickHide = false; 26890 if (!instance.state.isEnabled || isEventListenerStopped(event) || didHideDueToDocumentMouseDown) { 26891 return; 26892 } 26893 var wasFocused = ((_lastTriggerEvent = lastTriggerEvent) == null ? void 0 : _lastTriggerEvent.type) === "focus"; 26894 lastTriggerEvent = event; 26895 currentTarget = event.currentTarget; 26896 handleAriaExpandedAttribute(); 26897 if (!instance.state.isVisible && isMouseEvent(event)) { 26898 mouseMoveListeners.forEach(function(listener) { 26899 return listener(event); 26900 }); 26901 } 26902 if (event.type === "click" && (instance.props.trigger.indexOf("mouseenter") < 0 || isVisibleFromClick) && instance.props.hideOnClick !== false && instance.state.isVisible) { 26903 shouldScheduleClickHide = true; 26904 } else { 26905 scheduleShow(event); 26906 } 26907 if (event.type === "click") { 26908 isVisibleFromClick = !shouldScheduleClickHide; 26909 } 26910 if (shouldScheduleClickHide && !wasFocused) { 26911 scheduleHide(event); 26912 } 26913 } 26914 function onMouseMove(event) { 26915 var target = event.target; 26916 var isCursorOverReferenceOrPopper = getCurrentTarget().contains(target) || popper.contains(target); 26917 if (event.type === "mousemove" && isCursorOverReferenceOrPopper) { 26918 return; 26919 } 26920 var popperTreeData = getNestedPopperTree().concat(popper).map(function(popper2) { 26921 var _instance$popperInsta; 26922 var instance2 = popper2._tippy; 26923 var state2 = (_instance$popperInsta = instance2.popperInstance) == null ? void 0 : _instance$popperInsta.state; 26924 if (state2) { 26925 return { 26926 popperRect: popper2.getBoundingClientRect(), 26927 popperState: state2, 26928 props 26929 }; 26930 } 26931 return null; 26932 }).filter(Boolean); 26933 if (isCursorOutsideInteractiveBorder(popperTreeData, event)) { 26934 cleanupInteractiveMouseListeners(); 26935 scheduleHide(event); 26936 } 26937 } 26938 function onMouseLeave(event) { 26939 var shouldBail = isEventListenerStopped(event) || instance.props.trigger.indexOf("click") >= 0 && isVisibleFromClick; 26940 if (shouldBail) { 26941 return; 26942 } 26943 if (instance.props.interactive) { 26944 instance.hideWithInteractivity(event); 26945 return; 26946 } 26947 scheduleHide(event); 26948 } 26949 function onBlurOrFocusOut(event) { 26950 if (instance.props.trigger.indexOf("focusin") < 0 && event.target !== getCurrentTarget()) { 26951 return; 26952 } 26953 if (instance.props.interactive && event.relatedTarget && popper.contains(event.relatedTarget)) { 26954 return; 26955 } 26956 scheduleHide(event); 26957 } 26958 function isEventListenerStopped(event) { 26959 return currentInput.isTouch ? getIsCustomTouchBehavior() !== event.type.indexOf("touch") >= 0 : false; 26960 } 26961 function createPopperInstance() { 26962 destroyPopperInstance(); 26963 var _instance$props2 = instance.props, popperOptions = _instance$props2.popperOptions, placement = _instance$props2.placement, offset = _instance$props2.offset, getReferenceClientRect = _instance$props2.getReferenceClientRect, moveTransition = _instance$props2.moveTransition; 26964 var arrow = getIsDefaultRenderFn() ? getChildren(popper).arrow : null; 26965 var computedReference = getReferenceClientRect ? { 26966 getBoundingClientRect: getReferenceClientRect, 26967 contextElement: getReferenceClientRect.contextElement || getCurrentTarget() 26968 } : reference; 26969 var tippyModifier = { 26970 name: "$$tippy", 26971 enabled: true, 26972 phase: "beforeWrite", 26973 requires: ["computeStyles"], 26974 fn: function fn5(_ref2) { 26975 var state2 = _ref2.state; 26976 if (getIsDefaultRenderFn()) { 26977 var _getDefaultTemplateCh = getDefaultTemplateChildren(), box = _getDefaultTemplateCh.box; 26978 ["placement", "reference-hidden", "escaped"].forEach(function(attr) { 26979 if (attr === "placement") { 26980 box.setAttribute("data-placement", state2.placement); 26981 } else {
vendor: 9,007 bytes, lines 26982-27261
26982 if (state2.attributes.popper["data-popper-" + attr]) { 26983 box.setAttribute("data-" + attr, ""); 26984 } else { 26985 box.removeAttribute("data-" + attr); 26986 } 26987 } 26988 }); 26989 state2.attributes.popper = {}; 26990 } 26991 } 26992 }; 26993 var modifiers = [{ 26994 name: "offset", 26995 options: { 26996 offset 26997 } 26998 }, { 26999 name: "preventOverflow", 27000 options: { 27001 padding: { 27002 top: 2, 27003 bottom: 2, 27004 left: 5, 27005 right: 5 27006 } 27007 } 27008 }, { 27009 name: "flip", 27010 options: { 27011 padding: 5 27012 } 27013 }, { 27014 name: "computeStyles", 27015 options: { 27016 adaptive: !moveTransition 27017 } 27018 }, tippyModifier]; 27019 if (getIsDefaultRenderFn() && arrow) { 27020 modifiers.push({ 27021 name: "arrow", 27022 options: { 27023 element: arrow, 27024 padding: 3 27025 } 27026 }); 27027 } 27028 modifiers.push.apply(modifiers, (popperOptions == null ? void 0 : popperOptions.modifiers) || []); 27029 instance.popperInstance = createPopper(computedReference, popper, Object.assign({}, popperOptions, { 27030 placement, 27031 onFirstUpdate, 27032 modifiers 27033 })); 27034 } 27035 function destroyPopperInstance() { 27036 if (instance.popperInstance) { 27037 instance.popperInstance.destroy(); 27038 instance.popperInstance = null; 27039 } 27040 } 27041 function mount() { 27042 var appendTo = instance.props.appendTo; 27043 var parentNode; 27044 var node = getCurrentTarget(); 27045 if (instance.props.interactive && appendTo === TIPPY_DEFAULT_APPEND_TO || appendTo === "parent") { 27046 parentNode = node.parentNode; 27047 } else { 27048 parentNode = invokeWithArgsOrReturn(appendTo, [node]); 27049 } 27050 if (!parentNode.contains(popper)) { 27051 parentNode.appendChild(popper); 27052 } 27053 instance.state.isMounted = true; 27054 createPopperInstance(); 27055 } 27056 function getNestedPopperTree() { 27057 return arrayFrom(popper.querySelectorAll("[data-tippy-root]")); 27058 } 27059 function scheduleShow(event) { 27060 instance.clearDelayTimeouts(); 27061 if (event) { 27062 invokeHook("onTrigger", [instance, event]); 27063 } 27064 addDocumentPress(); 27065 var delay = getDelay(true); 27066 var _getNormalizedTouchSe = getNormalizedTouchSettings(), touchValue = _getNormalizedTouchSe[0], touchDelay = _getNormalizedTouchSe[1]; 27067 if (currentInput.isTouch && touchValue === "hold" && touchDelay) { 27068 delay = touchDelay; 27069 } 27070 if (delay) { 27071 showTimeout = setTimeout(function() { 27072 instance.show(); 27073 }, delay); 27074 } else { 27075 instance.show(); 27076 } 27077 } 27078 function scheduleHide(event) { 27079 instance.clearDelayTimeouts(); 27080 invokeHook("onUntrigger", [instance, event]); 27081 if (!instance.state.isVisible) { 27082 removeDocumentPress(); 27083 return; 27084 } 27085 if (instance.props.trigger.indexOf("mouseenter") >= 0 && instance.props.trigger.indexOf("click") >= 0 && ["mouseleave", "mousemove"].indexOf(event.type) >= 0 && isVisibleFromClick) { 27086 return; 27087 } 27088 var delay = getDelay(false); 27089 if (delay) { 27090 hideTimeout = setTimeout(function() { 27091 if (instance.state.isVisible) { 27092 instance.hide(); 27093 } 27094 }, delay); 27095 } else { 27096 scheduleHideAnimationFrame = requestAnimationFrame(function() { 27097 instance.hide(); 27098 }); 27099 } 27100 } 27101 function enable() { 27102 instance.state.isEnabled = true; 27103 } 27104 function disable() { 27105 instance.hide(); 27106 instance.state.isEnabled = false; 27107 } 27108 function clearDelayTimeouts() { 27109 clearTimeout(showTimeout); 27110 clearTimeout(hideTimeout); 27111 cancelAnimationFrame(scheduleHideAnimationFrame); 27112 } 27113 function setProps(partialProps) { 27114 if (instance.state.isDestroyed) { 27115 return; 27116 } 27117 invokeHook("onBeforeUpdate", [instance, partialProps]); 27118 removeListeners(); 27119 var prevProps = instance.props; 27120 var nextProps = evaluateProps(reference, Object.assign({}, prevProps, removeUndefinedProps(partialProps), { 27121 ignoreAttributes: true 27122 })); 27123 instance.props = nextProps; 27124 addListeners(); 27125 if (prevProps.interactiveDebounce !== nextProps.interactiveDebounce) { 27126 cleanupInteractiveMouseListeners(); 27127 debouncedOnMouseMove = debounce(onMouseMove, nextProps.interactiveDebounce); 27128 } 27129 if (prevProps.triggerTarget && !nextProps.triggerTarget) { 27130 normalizeToArray(prevProps.triggerTarget).forEach(function(node) { 27131 node.removeAttribute("aria-expanded"); 27132 }); 27133 } else if (nextProps.triggerTarget) { 27134 reference.removeAttribute("aria-expanded"); 27135 } 27136 handleAriaExpandedAttribute(); 27137 handleStyles(); 27138 if (onUpdate) { 27139 onUpdate(prevProps, nextProps); 27140 } 27141 if (instance.popperInstance) { 27142 createPopperInstance(); 27143 getNestedPopperTree().forEach(function(nestedPopper) { 27144 requestAnimationFrame(nestedPopper._tippy.popperInstance.forceUpdate); 27145 }); 27146 } 27147 invokeHook("onAfterUpdate", [instance, partialProps]); 27148 } 27149 function setContent2(content) { 27150 instance.setProps({ 27151 content 27152 }); 27153 } 27154 function show() { 27155 var isAlreadyVisible = instance.state.isVisible; 27156 var isDestroyed = instance.state.isDestroyed; 27157 var isDisabled = !instance.state.isEnabled; 27158 var isTouchAndTouchDisabled = currentInput.isTouch && !instance.props.touch; 27159 var duration = getValueAtIndexOrReturn(instance.props.duration, 0, defaultProps.duration); 27160 if (isAlreadyVisible || isDestroyed || isDisabled || isTouchAndTouchDisabled) { 27161 return; 27162 } 27163 if (getCurrentTarget().hasAttribute("disabled")) { 27164 return; 27165 } 27166 invokeHook("onShow", [instance], false); 27167 if (instance.props.onShow(instance) === false) { 27168 return; 27169 } 27170 instance.state.isVisible = true; 27171 if (getIsDefaultRenderFn()) { 27172 popper.style.visibility = "visible"; 27173 } 27174 handleStyles(); 27175 addDocumentPress(); 27176 if (!instance.state.isMounted) { 27177 popper.style.transition = "none"; 27178 } 27179 if (getIsDefaultRenderFn()) { 27180 var _getDefaultTemplateCh2 = getDefaultTemplateChildren(), box = _getDefaultTemplateCh2.box, content = _getDefaultTemplateCh2.content; 27181 setTransitionDuration([box, content], 0); 27182 } 27183 onFirstUpdate = function onFirstUpdate2() { 27184 var _instance$popperInsta2; 27185 if (!instance.state.isVisible || ignoreOnFirstUpdate) { 27186 return; 27187 } 27188 ignoreOnFirstUpdate = true; 27189 void popper.offsetHeight; 27190 popper.style.transition = instance.props.moveTransition; 27191 if (getIsDefaultRenderFn() && instance.props.animation) { 27192 var _getDefaultTemplateCh3 = getDefaultTemplateChildren(), _box = _getDefaultTemplateCh3.box, _content = _getDefaultTemplateCh3.content; 27193 setTransitionDuration([_box, _content], duration); 27194 setVisibilityState([_box, _content], "visible"); 27195 } 27196 handleAriaContentAttribute(); 27197 handleAriaExpandedAttribute(); 27198 pushIfUnique(mountedInstances, instance); 27199 (_instance$popperInsta2 = instance.popperInstance) == null ? void 0 : _instance$popperInsta2.forceUpdate(); 27200 invokeHook("onMount", [instance]); 27201 if (instance.props.animation && getIsDefaultRenderFn()) { 27202 onTransitionedIn(duration, function() { 27203 instance.state.isShown = true; 27204 invokeHook("onShown", [instance]); 27205 }); 27206 } 27207 }; 27208 mount(); 27209 } 27210 function hide() { 27211 var isAlreadyHidden = !instance.state.isVisible; 27212 var isDestroyed = instance.state.isDestroyed; 27213 var isDisabled = !instance.state.isEnabled; 27214 var duration = getValueAtIndexOrReturn(instance.props.duration, 1, defaultProps.duration); 27215 if (isAlreadyHidden || isDestroyed || isDisabled) { 27216 return; 27217 } 27218 invokeHook("onHide", [instance], false); 27219 if (instance.props.onHide(instance) === false) { 27220 return; 27221 } 27222 instance.state.isVisible = false; 27223 instance.state.isShown = false; 27224 ignoreOnFirstUpdate = false; 27225 isVisibleFromClick = false; 27226 if (getIsDefaultRenderFn()) { 27227 popper.style.visibility = "hidden"; 27228 } 27229 cleanupInteractiveMouseListeners(); 27230 removeDocumentPress(); 27231 handleStyles(true); 27232 if (getIsDefaultRenderFn()) { 27233 var _getDefaultTemplateCh4 = getDefaultTemplateChildren(), box = _getDefaultTemplateCh4.box, content = _getDefaultTemplateCh4.content; 27234 if (instance.props.animation) { 27235 setTransitionDuration([box, content], duration); 27236 setVisibilityState([box, content], "hidden"); 27237 } 27238 } 27239 handleAriaContentAttribute(); 27240 handleAriaExpandedAttribute(); 27241 if (instance.props.animation) { 27242 if (getIsDefaultRenderFn()) { 27243 onTransitionedOut(duration, instance.unmount); 27244 } 27245 } else { 27246 instance.unmount(); 27247 } 27248 } 27249 function hideWithInteractivity(event) { 27250 getDocument().addEventListener("mousemove", debouncedOnMouseMove); 27251 pushIfUnique(mouseMoveListeners, debouncedOnMouseMove); 27252 debouncedOnMouseMove(event); 27253 } 27254 function unmount() { 27255 if (instance.state.isVisible) { 27256 instance.hide(); 27257 } 27258 if (!instance.state.isMounted) { 27259 return; 27260 } 27261 destroyPopperInstance();
27262 getNestedPopperTree().forEach(function(nestedPopper) { 27263 nestedPopper._tippy.unmount(); 27264 }); 27265 if (popper.parentNode) { 27266 popper.parentNode.removeChild(popper); 27267 } 27268 mountedInstances = mountedInstances.filter(function(i) { 27269 return i !== instance; 27270 }); 27271 instance.state.isMounted = false; 27272 invokeHook("onHidden", [instance]); 27273 } 27274 function destroy() { 27275 if (instance.state.isDestroyed) { 27276 return; 27277 } 27278 instance.clearDelayTimeouts(); 27279 instance.unmount(); 27280 removeListeners(); 27281 delete reference._tippy; 27282 instance.state.isDestroyed = true; 27283 invokeHook("onDestroy", [instance]); 27284 } 27285} 27286function tippy(targets, optionalProps) { 27287 if (optionalProps === void 0) { 27288 optionalProps = {}; 27289 } 27290 var plugins = defaultProps.plugins.concat(optionalProps.plugins || []); 27291 bindGlobalEventListeners(); 27292 var passedProps = Object.assign({}, optionalProps, { 27293 plugins 27294 }); 27295 var elements = getArrayOfElements(targets); 27296 var instances = elements.reduce(function(acc, reference) { 27297 var instance = reference && createTippy(reference, passedProps); 27298 if (instance) { 27299 acc.push(instance); 27300 } 27301 return acc; 27302 }, []); 27303 return isElement(targets) ? instances[0] : instances; 27304} 27305tippy.defaultProps = defaultProps; 27306tippy.setDefaultProps = setDefaultProps; 27307tippy.currentInput = currentInput; 27308Object.assign({}, applyStyles$1, { 27309 effect: function effect(_ref) { 27310 var state = _ref.state; 27311 var initialStyles = { 27312 popper: { 27313 position: state.options.strategy, 27314 left: "0", 27315 top: "0", 27316 margin: "0" 27317 }, 27318 arrow: { 27319 position: "absolute" 27320 }, 27321 reference: {} 27322 }; 27323 Object.assign(state.elements.popper.style, initialStyles.popper); 27324 state.styles = initialStyles; 27325 if (state.elements.arrow) { 27326 Object.assign(state.elements.arrow.style, initialStyles.arrow); 27327 } 27328 } 27329}); 27330tippy.setDefaultProps({ 27331 render 27332}); 27333 27334class Tooltips { 27335 constructor() { 27336 this.ui = { 27337 container: document.querySelectorAll(".pricerangebutton"), 27338 }; 27339 27340 if (this.ui.container) { 27341 this.initEvents(); 27342 } 27343 27344 this.initTippy(); 27345 27346 } 27347 27348 initEvents() { 27349 // screen size 27350 27351 this.ui.container.forEach((element) => { 27352 element.addEventListener("click", this.showPopin.bind(this)); 27353 // element.querySelector(".pricerange__popin--close").addEventListener("click", this.hidePopin.bind(this)); 27354 }); 27355 // const priceRange = document.getElementById("pricerangetest"); 27356 // console.log(priceRange); 27357 // //Style color red 27358 // priceRange.style.color = "orange"; 27359 // if (priceRange) { 27360 // console.log("constructor"); 27361 // // add click event 27362 // priceRange.addEventListener("click", function (e) { 27363 // console.log("click"); 27364 // }); 27365 // } 27366 // add click and touch event on elemenet with id = pricerange 27367 } 27368 27369 initTippy() { 27370 tippy("[data-tippy-content]", { 27371 placement: 'right', 27372 trigger: "click", 27373 arrow: true, 27374 interactive: true, 27375 }); 27376 } 27377 27378 // hidePopin(e) { 27379 // // find child element with class = pricerange__popin 27380 // const popin = document.querySelectorAll(".pricerangebutton .pricerange__popin"); 27381 // if (popin) { 27382 // popin.forEach((element) => { 27383 // element.classList.remove("show"); 27384 // }); 27385 // } 27386 // } 27387 27388 // showPopin(e) { 27389 // e.preventDefault(); 27390 27391 // console.log(e.target); 27392 // if (e.target.classList.contains("pricerange__popin--close")) { 27393 // this.hidePopin(e); 27394 // return; 27395 // } else { 27396 // const popin = e.target.querySelector(".pricerange__popin"); 27397 // if (popin) { 27398 // popin.classList.toggle("show"); 27399 // } 27400 // } 27401 27402 // } 27403} 27404 27405class ProductLightbox { 27406 constructor() { 27407 this.modal = document.getElementById("modal-product"); 27408 this.closeButton = this.modal.querySelector(".modal-product__close"); 27409 this.sliderInstance = null; 27410 27411 this.initEvents(); 27412 // bind this to close modal 27413 this.closeModal = this.closeModal.bind(this); 27414 // bind this to show modal 27415 this.showModal = this.showModal.bind(this); 27416 27417 } 27418 27419 initEvents() { 27420 const images = document.querySelectorAll(".product-lightbox");
27421 images.forEach((image) => { 27422 image.addEventListener("click", (event) => { 27423 this.showModal(event); 27424 }); 27425 }); 27426 27427 this.closeButton.addEventListener("click", () => { 27428 this.closeModal(); 27429 }); 27430 27431 this.modal.addEventListener("click", (event) => { 27432 if (event.target === this.modal) { 27433 this.closeModal(); 27434 } 27435 }); 27436 } 27437 27438 closeModal() { 27439 console.log("closeModal"); 27440 this.modal.classList.remove("modal--open"); 27441 //delay 27442 setTimeout(() => { 27443 this.sliderInstance.destroy(); 27444 this.sliderInstance = null; 27445 document.querySelector(".splide-modal").classList.add("hidden"); 27446 }, 250); 27447 } 27448 27449 showModal(event) { 27450 const image = event.currentTarget; 27451 27452 const index = image.dataset.index; 27453 27454 27455 this.modal.classList.add("modal--open"); 27456 27457 setTimeout(() => { 27458 document.querySelector(".splide-modal").classList.remove("hidden"); 27459 this.sliderInstance = new Splide(".splide-modal", { 27460 type: "loop", 27461 perPage: 1, 27462 perMove: 1, 27463 pagination: false, 27464 arrows: true, 27465 start: index, 27466 gap: 0, 27467 }); 27468 this.sliderInstance.mount(); 27469 }, 250); 27470 27471 } 27472} 27473 27474class ToggleItemMobile { 27475 constructor() { 27476 27477 // this.ui = { 27478 // container, 27479 // splideBrandsSliderSelector: container.querySelector(".splide--brands"), 27480 // }; 27481 27482 // if (this.ui.container) { 27483 // this.initConfig(); 27484 // this.initEvents(); 27485 // } 27486 this.initToggle(); 27487 // console.log('ToggleItemMobile'); 27488 } 27489 27490 initToggle() { 27491 const toggleItemMobile = document.querySelectorAll(".toggle-item-mobile"); 27492 // parse toggleItemMobile to add event listener 27493 [].forEach.call(toggleItemMobile, (toggle) => { 27494 toggle.addEventListener("click", (e) => { 27495 e.preventDefault(); 27496 toggle.classList.toggle("is-active"); 27497 const target = toggle.getAttribute("data-target"); 27498 // toggle class on target elements 27499 document.querySelectorAll("." + target + ' .item--mobilehide').forEach(function (el) { 27500 el.classList.toggle('is-active'); 27501 }); 27502 27503 }); 27504 }); 27505 } 27506} 27507 27508class productDisplaySwitcher { 27509 constructor(container) { 27510 const grid = document.querySelector(".product-grid"); 27511 if (!grid) return; 27512 27513 const buttons = document.querySelectorAll(".toggle-style"); 27514 if (!buttons) return; 27515 27516 if (buttons.length >= 1) { 27517 buttons.forEach((button) => { 27518 const tooltip = button.getAttribute("data-tooltip"); 27519 if (tooltip) button.setAttribute("title", tooltip); 27520 // button.addEventListener("click", this.toggleProductDisplay); 27521 }); 27522 } 27523 27524 // const columns = localStorage.getItem("columns"); 27525 // // if columns is not null 27526 // if (columns) { 27527 // // console.log("columns", columns); 27528 // // remove class start with grid- and add grid- + columns 27529 // grid.classList.remove("grid-3", "grid-4", "grid-5", "grid-6"); 27530 // grid.classList.add(`grid-${columns}`); 27531 27532 // // set data-ppp attribute to columns 27533 // const ppp = columns == 5 ? 15 : columns == 6 ? 18 : 12; 27534 // document 27535 // .querySelector("#collection-header") 27536 // .setAttribute("data-ppp", ppp); 27537 // // console.log('ppp', ppp); 27538 27539 // //remove active class from all buttons 27540 // const currentActiveButton = document.querySelector( 27541 // ".toggle-style.active" 27542 // ); 27543 // if (currentActiveButton) { 27544 // currentActiveButton.classList.remove("active"); 27545 // } 27546 27547 // // add class active to button with data-columns = columns 27548 // const button = document.querySelector(`[data-columns="${columns}"]`); 27549 // button.classList.add("active"); 27550 // } 27551 27552 // const wrapper = document.querySelector("#collection-header"); 27553 // if (!wrapper) { 27554 // // no filter on this page 27555 // return; 27556 // } 27557 27558 // // Current collection page taxonomy 27559 // const currentTaxonomy = wrapper.dataset.current_taxonomy; 27560 // const currentTerm = wrapper.dataset.current_term; 27561 27562 // let params = []; 27563 // if (currentTaxonomy !== "" && currentTerm !== "") { 27564 // params.push(currentTerm + "#" + currentTaxonomy); 27565 // } 27566 27567 // params = params.filter( 27568 // (item) => item !== "undefined#undefined" && item !== "#" 27569 // ); 27570 27571 // test function 27572 } 27573 27574 // loadProducts() { 27575 // console.log("loadProducts change display"); 27576 // if (this.params === undefined) { 27577 // return; 27578 // } 27579 27580 // // delay close dropdown after click 27581 // setTimeout(function () { 27582 // const open = document.querySelector("li.accordion.is-open"); 27583 // if (open) { 27584 // open.classList.remove("is-open"); 27585 // } 27586 // }, 400); 27587 27588 // button.show(); 27589 27590 // $(".no-results-grid").remove(); 27591 27592 // // set data attribute data-end to element #collection-header 27593 // // $("#collection-header").data("end", false); 27594 // const wrapper = document.querySelector("#collection-header"); 27595 // wrapper.setAttribute("data-end", "0"); 27596 27597 // // remove load more button 27598 // // $(".collection-cards__view-more,.boardgame-cards__view-more").remove(); 27599 27600 // const checkbox = $(this).find(":input"); 27601 // const parent = $(this) 27602 // .closest(".filter-by__filter-item") 27603 // .find("input[type=checkbox]"); 27604 27605 // if (checkbox.attr("type") == "checkbox") { 27606 // checkbox.prop("checked", !checkbox.prop("checked")); 27607 // } 27608 27609 // parent.each(function (index, element) { 27610 // const taxonomy = $(element) 27611 // .closest(".accordion__content-item") 27612 // .data("taxonomy"); 27613 // const term = $(element).closest(".accordion__content-item").data("term"); 27614 // const search = term + "#" + taxonomy; 27615 27616 // if (!$(element).is(checkbox)) { 27617 // $(element).prop("checked", false); 27618 // params = params.filter((item) => item !== search); 27619 // // console.log(params); 27620 // } 27621 // }); 27622 27623 // // find all checkboxes checked 27624 // unboxnow_filter_products_options.params = getParams(); 27625 27626 // setUrlParameters(); 27627 27628 // if (unboxnow_filter_products_options.params.length >= 1) { 27629 // $(".container--full-width-mobile").hide(); 27630 // $(".slider-visible-4").hide(); 27631 // } else { 27632 // $(".container--full-width-mobile").show(); 27633 // $(".slider-visible-4").show(); 27634 // } 27635 // const data = { 27636 // action: "filter_products", 27637 // params: unboxnow_filter_products_options.params, 27638 // page: 1, 27639 // posts_per_page: wrapper.getAttribute("data-ppp"), 27640 // }; 27641 27642 // const loading = $(".loading-product"); 27643 27644 // // $("#collection-header").data("current-page", 1); 27645 // wrapper.setAttribute("data-current-page", 1); 27646 // unboxnow_filter_products_options.current_page = 1; 27647 27648 // $.ajax({ 27649 // url: unboxnow_filter_products_options.ajaxurl, 27650 // data: data, 27651 // type: "POST", 27652 // beforeSend: function (xhr) { 27653 // loading.addClass("active"); 27654 // }, 27655 // success: function (data) { 27656 // if (data) { 27657 // // close dropdown 27658 // // increment current page 27659 // // wrapper.setAttribute("data-current-page", 1); 27660 27661 // $("#unboxnow-filter-products").html(data); 27662 // loading.removeClass("active"); 27663 // // count element 27664 // let count = $( 27665 // "#unboxnow-filter-products .collection-cards__card-primary" 27666 // ).length; 27667 // // console.log(count); 27668 // if (count < 12) { 27669 // button.hide(); 27670 // } else { 27671 // button.show(); 27672 // } 27673 // } 27674 // }, 27675 // }); 27676 // } 27677 27678 // toggleProductDisplay(e) { 27679 // // exit if button is already active 27680 // if (e.target.classList.contains("active")) return; 27681 27682 // // add class active and remove from other buttons 27683 // const buttons = document.querySelectorAll(".toggle-style"); 27684 // // arrow function to remove active class from all buttons 27685 // buttons.forEach((button) => { 27686 // if (button !== e.target) button.classList.remove("active"); 27687 // }); 27688 27689 // e.target.classList.add("active"); 27690 27691 // const columns = e.target.getAttribute("data-columns"); 27692 // console.log(columns); 27693 // const grid = document.querySelector(".product-grid"); 27694 27695 // const ppp = columns == 5 ? 15 : columns == 6 ? 18 : 12; 27696 // document.querySelector("#collection-header").setAttribute("data-ppp", ppp); 27697 // console.log("ppp", ppp); 27698 27699 // // remove class start with grid- and add grid- + columns 27700 // grid.className = grid.className.replace(/(^|\s)grid-\S+/g, ""); 27701 // grid.classList.add(`grid-${columns}`); 27702 27703 // // save columns in local storage 27704 // localStorage.setItem("columns", columns); 27705 // // ajax query load more page 1 27706 // } 27707} 27708 27709class ProductZoom { 27710 constructor(containers, type) { 27711 if (!containers || containers.length === 0) { 27712 return; 27713 } 27714 if (type == "onHover") { 27715 this.containers = containers; 27716 this.zoomOnHoverInit(); 27717 } else { 27718 this.active = true; 27719 this.result = document.querySelector("#zoom-result"); // Sélectionne le conteneur de résultat du zoom 27720 // set zIndex to 99999 27721 this.result.style.zIndex = "9999999"; 27722 27723 if (window.innerWidth < 768) { 27724 this.active = false;
27725 } 27726 27727 this.containers = containers; 27728 27729 // console.log(this.containers); 27730 // windows size event 27731 window.addEventListener("resize", this.onResize.bind(this)); 27732 27733 if (this.active) { 27734 this.initZoom(); // Initialisation du zoom 27735 // hide results on load 27736 this.result.style.display = "none"; 27737 } 27738 } 27739 } 27740 27741 initZoom() { 27742 this.result.style.width = "calc(50vw - 50px)"; 27743 this.result.style.display = "none"; 27744 this.containers.forEach((container) => { 27745 const img = container.querySelector("img"); // Sélectionne l'image dans le conteneur 27746 if (img && this.result) { 27747 this.imageZoom(img, this.result); // Appelle la fonction de zoom pour chaque image 27748 } 27749 }); 27750 } 27751 27752 imageZoom(img, result) { 27753 let lens = img.parentElement.querySelector(".img-zoom-lens"); 27754 const lw = 200; // Largeur de la lentille 27755 const lh = 200; // Hauteur de la lentille 27756 27757 if (!lens) { 27758 lens = document.createElement("div"); 27759 lens.setAttribute("class", "img-zoom-lens"); 27760 img.parentElement.appendChild(lens); 27761 lens.style.width = `${lw}px`; 27762 lens.style.height = `${lh}px`; 27763 27764 // z index 99999 27765 lens.style.zIndex = "99999"; 27766 } 27767 27768 //show result 27769 27770 result.style.display = "block"; 27771 // result.style.backgroundImage = `url('${img.src}')`; 27772 // result.style.backgroundImage = `url('${img.getAttribute("data-src")}')`; 27773 27774 // result.style.backgroundSize = `${img.clientWidth * cx}px ${ 27775 // img.clientHeight * cy 27776 // }px`; 27777 result.style.backgroundColor = "#fff"; 27778 27779 const moveLens = (e) => { 27780 e.preventDefault(); 27781 if (!this.active) { 27782 return; 27783 } 27784 27785 if (e.type === "mouseleave") { 27786 lens.style.display = "none"; 27787 result.style.display = "none"; 27788 return; 27789 } 27790 27791 const cx = result.offsetWidth / lens.offsetWidth; // Coefficient de zoom 27792 const cy = result.offsetHeight / lens.offsetHeight; // Coefficient de zoom 27793 27794 if (e.type === "mouseenter") { 27795 lens.style.display = "block"; 27796 result.style.display = "block"; 27797 result.style.backgroundImage = `url('${img.getAttribute("data-src")}')`; 27798 this.result.style.height = "calc(50vh - 50px)"; 27799 27800 // Utiliser les dimensions naturelles de l'image pour le zoom 27801 const imgWidth = img.naturalWidth; 27802 const imgHeight = img.naturalHeight; 27803 27804 // Taille de l'arrière-plan et empêcher la répétition 27805 result.style.backgroundSize = `${imgWidth * cx}px ${imgHeight * cy}px`; 27806 result.style.backgroundRepeat = "no-repeat"; 27807 } 27808 27809 // Calcul de la position du curseur 27810 const pos = this.getCursorPos(e, img); 27811 27812 // Ajuster pour centrer la lentille sur le curseur 27813 let x = pos.x - lens.offsetWidth / 2; 27814 let y = pos.y - lens.offsetHeight / 2; 27815 27816 // Empêcher la lentille de sortir de l'image 27817 x = Math.max(0, Math.min(x, img.width - lens.offsetWidth)); 27818 y = Math.max(0, Math.min(y, img.height - lens.offsetHeight)); 27819 27820 // Déplacer la lentille à la position calculée 27821 lens.style.left = `${x}px`; 27822 lens.style.top = `${y}px`; 27823 27824 // Calculer la position en pourcentages 27825 const xPercent = (x / (img.width - lens.offsetWidth)) * 100; 27826 const yPercent = (y / (img.height - lens.offsetHeight)) * 100; 27827 27828 // Utiliser les pourcentages pour ajuster l'arrière-plan 27829 result.style.backgroundPosition = `${xPercent}% ${yPercent}%`; 27830 }; 27831 27832 img.addEventListener("mousemove", moveLens); 27833 img.addEventListener("mouseenter", moveLens); 27834 img.addEventListener("mouseleave", moveLens); 27835 27836 // Gestion du tactile 27837 img.addEventListener("touchmove", (e) => { 27838 e.preventDefault(); 27839 moveLens(e.touches[0]); 27840 }); 27841 27842 img.addEventListener("touchstart", moveLens); 27843 27844 img.addEventListener("touchend", () => { 27845 lens.style.display = "none"; 27846 this.result.style.display = "none"; 27847 }); 27848 } 27849 27850 getCursorPos(e, img) { 27851 const rect = img.getBoundingClientRect(); 27852 const x = e.pageX - rect.left - window.scrollX; 27853 const y = e.pageY - rect.top - window.scrollY; 27854 return { x, y }; 27855 } 27856 // windows size event 27857 27858 onResize() { 27859 // if mobile destroz zoom 27860 if (window.innerWidth < 768 && this.active) { 27861 this.destroy(); 27862 this.active = false;
27863 return; 27864 } else if (window.innerWidth > 768 && !this.active) { 27865 this.initZoom(); 27866 this.result.style.display = "none"; 27867 this.active = true; 27868 } 27869 } 27870 27871 destroy() { 27872 document.querySelector("#zoom-result"); // Sélectionne le conteneur de résultat du zoom 27873 this.result.style.display = "none"; 27874 this.containers.forEach((container) => { 27875 const img = container.querySelector("img"); // Sélectionne l'image dans le conteneur 27876 const lens = img.parentElement.querySelector(".img-zoom-lens"); 27877 if (img) { 27878 img.removeEventListener("mousemove", this.moveLens); 27879 img.removeEventListener("mouseenter", this.moveLens); 27880 img.removeEventListener("mouseleave", this.moveLens); 27881 img.removeEventListener("touchmove", this.moveLens); 27882 img.removeEventListener("touchstart", this.moveLens); 27883 img.removeEventListener("touchend", this.moveLens); 27884 lens.remove(); 27885 } 27886 }); 27887 } 27888 27889 zoomOnHoverInit() { 27890 // console.log('zoomOnHover'); 27891 27892 this.containers.forEach((img) => { 27893 // if (img) { 27894 this.zoomOnHover(img); // Appelle la fonction de zoom pour chaque image 27895 // } 27896 }); 27897 } 27898 zoomOnHover(img) { 27899 // Sélectionne ou crée le conteneur de résultat du zoom 27900 let lens = img.parentElement.querySelector(".img-zoom-lens"); 27901 const lw = 300; // Largeur de la lentille 27902 const lh = 300; // Hauteur de la lentille 27903 27904 if (!lens) { 27905 lens = document.createElement("div"); 27906 lens.setAttribute("id", "zoom-lens"); 27907 lens.setAttribute("class", "img-zoom-lens"); 27908 img.parentElement.appendChild(lens); 27909 lens.style.width = `${lw}px`; 27910 lens.style.height = `${lh}px`; 27911 lens.style.position = "absolute"; 27912 lens.style.border = "1px solid #d4d4d4"; 27913 lens.style.backgroundColor = "#fff"; 27914 lens.style.zIndex = "99999"; 27915 lens.style.pointerEvents = "none"; // Empêche la lentille d'interférer avec les événements de la souris 27916 // rounded full 27917 lens.style.borderRadius = "50%"; 27918 } 27919 27920 const moveLens = (e) => { 27921 e.preventDefault(); 27922 27923 if (e.type === "mouseleave") { 27924 lens.style.display = "none"; 27925 return; 27926 } 27927 27928 lens.style.display = "block"; 27929 27930 const zoomFactor = 2; // Facteur de zoom 27931 const cx = img.naturalWidth * zoomFactor; 27932 const cy = img.naturalHeight * zoomFactor; 27933 27934 27935 if (e.type === "mouseenter") { 27936 lens.style.backgroundImage = `url('${ 27937 img.getAttribute("data-src") || img.src 27938 }')`; 27939 lens.style.backgroundSize = `${cx}px ${cy}px`; 27940 lens.style.backgroundRepeat = "no-repeat"; 27941 } 27942 27943 // Calcul de la position du curseur 27944 const pos = this.getCursorPos(e, img); 27945 27946 // Ajuster pour centrer la lentille sur le curseur 27947 let x = pos.x - lens.offsetWidth / 2; 27948 let y = pos.y - lens.offsetHeight / 2; 27949 27950 // Empêcher la lentille de sortir de l'image 27951 x = Math.max(0, Math.min(x, img.width - lens.offsetWidth)); 27952 y = Math.max(0, Math.min(y, img.height - lens.offsetHeight)); 27953 27954 // Déplacer la lentille à la position calculée 27955 lens.style.left = `${x}px`; 27956 lens.style.top = `${y}px`; 27957 27958 // Calculer la position en pourcentages 27959 const xPercent = (x / (img.width - lens.offsetWidth)) * 100; 27960 const yPercent = (y / (img.height - lens.offsetHeight)) * 100; 27961 27962 // Utiliser les pourcentages pour ajuster l'arrière-plan 27963 lens.style.backgroundPosition = `${xPercent}% ${yPercent}%`; 27964 }; 27965 27966 img.addEventListener("mousemove", moveLens); 27967 img.addEventListener("mouseenter", moveLens); 27968 img.addEventListener("mouseleave", moveLens); 27969 27970 // Gestion du tactile 27971 img.addEventListener("touchmove", (e) => { 27972 e.preventDefault(); 27973 moveLens(e.touches[0]); 27974 }); 27975 27976 img.addEventListener("touchstart", moveLens); 27977 27978 img.addEventListener("touchend", () => { 27979 lens.style.display = "none"; 27980 }); 27981 } 27982} 27983 27984const ajax_url = unboxnow_js_options.ajax_url; 27985const nonce = unboxnow_js_options.nonce; 27986const instagram_post_action = unboxnow_js_options.instagram_post_action; 27987
27988function init() { 27989 new SplideThumbnailsSlider(document.querySelector(".product-block__slider")); 27990 new SplideBannerSlider(document.querySelector(".banner-slider")); 27991 // new SplideBrandsSlider(document.querySelector(".brands-slider")); 27992 new SplideBrandsSlider(document.querySelectorAll(".brands-slider")); 27993 // new SplideHeroSlider(document.querySelector(".hero-slider")); 27994 new SplideHeroSlider$1(document.querySelectorAll(".splide--hero")); 27995 new SplideHeroSlider(document.querySelectorAll(".hero-slider-image")); 27996 // new SplideGamme(document.querySelector(".gamme-slider")); 27997 new SplideGamme(document.querySelectorAll(".gamme-slider")); 27998 new SplideExpansion(document.querySelectorAll(".splide--expansion")); 27999 new GridGamme(document.querySelector(".gamme-slider-grid")); 28000 new SplideVisible4Slider(document.querySelector(".all-boardgames__slider")); 28001 new SplideShopSlider(document.querySelectorAll(".shop-slider")); 28002 new Header(document.querySelector(".header")); 28003 new HeaderSearch(document.querySelector(".header__menu")); 28004 new MenuMobile(document.querySelector(".menu__nav")); 28005 28006 new FooterAccordion(document.querySelector(".footer__nav")); 28007 // new FilterTabs(document.querySelector(".best-sellers")); 28008 new FilterTabs(document.querySelectorAll(".best-sellers")); 28009 new FilterTabsSearch(document.querySelector(".search__page-wrapper")); 28010 new GameRecap(document.querySelector(".product__page-wrapper")); 28011 new ViewToggle(document.querySelector(".in-the-box")); 28012 new ScrollToAnchor(document.querySelector(".product__page-wrapper, .collection__page-wrapper")); 28013 new Share(document.querySelector(".share")); 28014 new CardSocial( document.querySelector(".card-banner-social"), ajax_url, instagram_post_action); 28015 new ProductVideoWrapper(); 28016 new SplideProductOtherInGamme(document.querySelectorAll(".splide--other-in-gamme")); 28017 28018 new productDisplaySwitcher(document.querySelector(".products-display")); 28019 new OrderProducts(document.querySelector("#order-products")); 28020 28021 // Blog 28022 if (document.body.classList.contains("blog")) { 28023 new BlogSlider(document.querySelector(".blog-slider")); 28024 new BlogTabs(); 28025 new BlogFilters(ajax_url, "filter_blog", nonce); 28026 } 28027 28028 // Product single 28029 if (document.body.classList.contains("single-product")) { 28030 new Tooltips(); 28031 new ProductLightbox(); 28032 new ToggleItemMobile(); 28033 28034 new ProductZoom(document.querySelectorAll(".product-block__slider .product-lightbox"), 'onSide'); // on main slider 28035 new ProductZoom(document.querySelectorAll(".splide-modal img"), 'onHover'); // on lightbox open 28036 } 28037 28038 if (document.body.classList.contains("page-template-tpl-events")) { 28039 // const accordionsEvents = document.querySelectorAll('[data-accordion-event="container"]'); 28040 // [].forEach.call(accordionsEvents, (accordion) => new FilterAccordionEvents(accordion)); 28041 new EventFilters(ajax_url, "filter_event", nonce); 28042 } 28043 28044 28045 28046 const modals = document.querySelectorAll(".modal"); 28047 [].forEach.call(modals, (modal) => new ModalProduct(modal)); 28048 28049 const backLinks = document.querySelectorAll(".backlink"); 28050 [].forEach.call(backLinks, (backlink) => new BackLink(backlink)); 28051 28052 if (!document.body.classList.contains("page-template-tpl-events")) { 28053 const accordions = document.querySelectorAll('[data-accordion="container"]'); 28054 [].forEach.call(accordions, (accordion) => new FilterAccordion(accordion)); 28055 } 28056 28057} 28058 28059document.addEventListener("DOMContentLoaded", function () { 28060 init(); 28061});
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.