1/******************************************************************************* 2 * Copyright 2019 Adobe 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 ******************************************************************************/ 16 17/** 18 * Element.matches() 19 * https://developer.mozilla.org/enUS/docs/Web/API/Element/matches#Polyfill 20 */ 21if (!Element.prototype.matches) { 22 Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; 23} 24 25// eslint-disable-next-line valid-jsdoc 26/** 27 * Element.closest() 28 * https://developer.mozilla.org/enUS/docs/Web/API/Element/closest#Polyfill 29 */ 30if (!Element.prototype.closest) { 31 Element.prototype.closest = function(s) { 32 "use strict"; 33 var el = this; 34 if (!document.documentElement.contains(el)) { 35 return null; 36 } 37 do { 38 if (el.matches(s)) { 39 return el; 40 } 41 el = el.parentElement || el.parentNode; 42 } while (el !== null && el.nodeType === 1); 43 return null; 44 }; 45} 46 47/******************************************************************************* 48 * Copyright 2019 Adobe 49 * 50 * Licensed under the Apache License, Version 2.0 (the "License"); 51 * you may not use this file except in compliance with the License. 52 * You may obtain a copy of the License at 53 * 54 * http://www.apache.org/licenses/LICENSE-2.0 55 * 56 * Unless required by applicable law or agreed to in writing, software 57 * distributed under the License is distributed on an "AS IS" BASIS, 58 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 59 * See the License for the specific language governing permissions and 60 * limitations under the License. 61 ******************************************************************************/ 62(function() { 63 "use strict"; 64 65 var containerUtils = window.CQ && window.CQ.CoreComponents && window.CQ.CoreComponents.container && window.CQ.CoreComponents.container.utils ? window.CQ.CoreComponents.container.utils : undefined; 66 if (!containerUtils) { 67 // eslint-disable-next-line no-console 68 console.warn("Accordion: container utilities at window.CQ.CoreComponents.container.utils are not available. This can lead to missing features. Ensure the core.wcm.components.commons.site.container client library is included on the page."); 69 } 70 var dataLayerEnabled; 71 var dataLayer; 72 var dataLayerName; 73 var delay = 100; 74 75 var NS = "cmp"; 76 var IS = "accordion"; 77 78 var keyCodes = { 79 ENTER: 13, 80 SPACE: 32, 81 END: 35, 82 HOME: 36, 83 ARROW_LEFT: 37, 84 ARROW_UP: 38, 85 ARROW_RIGHT: 39, 86 ARROW_DOWN: 40 87 }; 88 89 var selectors = { 90 self: "[data-" + NS + '-is="' + IS + '"]' 91 }; 92
93 var cssClasses = { 94 button: { 95 disabled: "cmp-accordion__button--disabled", 96 expanded: "cmp-accordion__button--expanded" 97 }, 98 panel: { 99 hidden: "cmp-accordion__panel--hidden", 100 expanded: "cmp-accordion__panel--expanded" 101 } 102 }; 103 104 var dataAttributes = { 105 item: { 106 expanded: "data-cmp-expanded" 107 } 108 }; 109 110 var properties = { 111 /** 112 * Determines whether a single accordion item is forced to be expanded at a time. 113 * Expanding one item will collapse all others. 114 * 115 * @memberof Accordion 116 * @type {Boolean} 117 * @default false 118 */ 119 "singleExpansion": { 120 "default": false, 121 "transform": function(value) { 122 return !(value === null || typeof value === "undefined"); 123 } 124 } 125 }; 126 127 /** 128 * Accordion Configuration. 129 * 130 * @typedef {Object} AccordionConfig Represents an Accordion configuration 131 * @property {HTMLElement} element The HTMLElement representing the Accordion 132 * @property {Object} options The Accordion options 133 */ 134 135 /** 136 * Accordion. 137 * 138 * @class Accordion 139 * @classdesc An interactive Accordion component for toggling panels of related content 140 * @param {AccordionConfig} config The Accordion configuration 141 */ 142 function Accordion(config) { 143 var that = this; 144 145 if (config && config.element) { 146 init(config); 147 } 148 149 /** 150 * Initializes the Accordion. 151 * 152 * @private 153 * @param {AccordionConfig} config The Accordion configuration 154 */ 155 function init(config) { 156 that._config = config; 157 158 // prevents multiple initialization 159 config.element.removeAttribute("data-" + NS + "-is"); 160 161 setupProperties(config.options); 162 cacheElements(config.element); 163 164 if (that._elements["item"]) { 165 // ensures multiple element types are arrays. 166 that._elements["item"] = Array.isArray(that._elements["item"]) ? that._elements["item"] : [that._elements["item"]]; 167 that._elements["button"] = Array.isArray(that._elements["button"]) ? that._elements["button"] : [that._elements["button"]]; 168 that._elements["panel"] = Array.isArray(that._elements["panel"]) ? that._elements["panel"] : [that._elements["panel"]]; 169 170 if (that._properties.singleExpansion) { 171 var expandedItems = getExpandedItems(); 172 // multiple expanded items annotated, display the last item open. 173 if (expandedItems.length > 1) { 174 toggle(expandedItems.length - 1); 175 } 176 } 177 178 refreshItems(); 179 bindEvents(); 180 scrollToDeepLinkIdInAccordion(); 181 } 182 if (window.Granite && window.Granite.author && window.Granite.author.MessageChannel) { 183 /* 184 * Editor message handling: 185 * - subscribe to "cmp.panelcontainer" message requests sent by the editor frame 186 * - check that the message data panel container type is correct and that the id (path) matches this specific Accordion component 187 * - if so, route the "navigate" operation to enact a navigation of the Accordion based on index data 188 */ 189 window.CQ.CoreComponents.MESSAGE_CHANNEL = window.CQ.CoreComponents.MESSAGE_CHANNEL || new window.Granite.author.MessageChannel("cqauthor", window); 190 window.CQ.CoreComponents.MESSAGE_CHANNEL.subscribeRequestMessage("cmp.panelcontainer", function(message) { 191 if (message.data && message.data.type === "cmp-accordion" && message.data.id === that._elements.self.dataset["cmpPanelcontainerId"]) { 192 if (message.data.operation === "navigate") { 193 // switch to single expansion mode when navigating in edit mode. 194 var singleExpansion = that._properties.singleExpansion; 195 that._properties.singleExpansion = true; 196 toggle(message.data.index); 197 198 // revert to the configured state. 199 that._properties.singleExpansion = singleExpansion; 200 } 201 } 202 }); 203 } 204 } 205 206 /**
207 * Displays the panel containing the element that corresponds to the deep link in the URI fragment 208 * and scrolls the browser to this element. 209 */ 210 function scrollToDeepLinkIdInAccordion() { 211 if (containerUtils) { 212 var deepLinkItemIdx = containerUtils.getDeepLinkItemIdx(that, "item", "item"); 213 if (deepLinkItemIdx > -1) { 214 var deepLinkItem = that._elements["item"][deepLinkItemIdx]; 215 if (deepLinkItem && !deepLinkItem.hasAttribute(dataAttributes.item.expanded)) { 216 // if single expansion: close all accordion items 217 if (that._properties.singleExpansion) { 218 for (var j = 0; j < that._elements["item"].length; j++) { 219 if (that._elements["item"][j].hasAttribute(dataAttributes.item.expanded)) { 220 setItemExpanded(that._elements["item"][j], false, true); 221 } 222 } 223 } 224 // expand the accordion item containing the deep link 225 setItemExpanded(deepLinkItem, true, true); 226 } 227 var hashId = window.location.hash.substring(1); 228 if (hashId) { 229 var hashItem = document.querySelector("[id='" + hashId + "']"); 230 if (hashItem) { 231 hashItem.scrollIntoView(); 232 } 233 } 234 } 235 } 236 } 237 238 /** 239 * Caches the Accordion elements as defined via the {@code data-accordion-hook="ELEMENT_NAME"} markup API. 240 * 241 * @private 242 * @param {HTMLElement} wrapper The Accordion wrapper element 243 */ 244 function cacheElements(wrapper) { 245 that._elements = {}; 246 that._elements.self = wrapper; 247 var hooks = that._elements.self.querySelectorAll("[data-" + NS + "-hook-" + IS + "]"); 248 249 for (var i = 0; i < hooks.length; i++) { 250 var hook = hooks[i]; 251 if (hook.closest("." + NS + "-" + IS) === that._elements.self) { // only process own accordion elements 252 var capitalized = IS; 253 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 254 var key = hook.dataset[NS + "Hook" + capitalized]; 255 if (that._elements[key]) { 256 if (!Array.isArray(that._elements[key])) { 257 var tmp = that._elements[key]; 258 that._elements[key] = [tmp]; 259 } 260 that._elements[key].push(hook); 261 } else { 262 that._elements[key] = hook; 263 } 264 } 265 } 266 } 267 268 /** 269 * Sets up properties for the Accordion based on the passed options. 270 * 271 * @private 272 * @param {Object} options The Accordion options 273 */ 274 function setupProperties(options) { 275 that._properties = {}; 276 277 for (var key in properties) { 278 if (Object.prototype.hasOwnProperty.call(properties, key)) { 279 var property = properties[key]; 280 var value = null; 281 282 if (options && options[key] != null) { 283 value = options[key]; 284 285 // transform the provided option 286 if (property && typeof property.transform === "function") { 287 value = property.transform(value); 288 } 289 } 290 291 if (value === null) { 292 // value still null, take the property default 293 value = properties[key]["default"]; 294 } 295 296 that._properties[key] = value; 297 } 298 } 299 } 300 301 /** 302 * Binds Accordion event handling. 303 * 304 * @private 305 */ 306 function bindEvents() { 307 window.addEventListener("hashchange", scrollToDeepLinkIdInAccordion, false); 308 var buttons = that._elements["button"]; 309 if (buttons) { 310 for (var i = 0; i < buttons.length; i++) { 311 (function(index) { 312 buttons[i].addEventListener("click", function(event) { 313 toggle(index); 314 focusButton(index); 315 }); 316 buttons[i].addEventListener("keydown", function(event) { 317 onButtonKeyDown(event, index); 318 }); 319 })(i); 320 } 321 } 322 } 323 324 /** 325 * Handles button keydown events. 326 * 327 * @private 328 * @param {Object} event The keydown event 329 * @param {Number} index The index of the button triggering the event 330 */ 331 function onButtonKeyDown(event, index) { 332 var lastIndex = that._elements["button"].length - 1; 333 334 switch (event.keyCode) { 335 case keyCodes.ARROW_LEFT: 336 case keyCodes.ARROW_UP: 337 event.preventDefault(); 338 if (index > 0) { 339 focusButton(index - 1); 340 } 341 break; 342 case keyCodes.ARROW_RIGHT: 343 case keyCodes.ARROW_DOWN: 344 event.preventDefault(); 345 if (index < lastIndex) { 346 focusButton(index + 1); 347 } 348 break; 349 case keyCodes.HOME: 350 event.preventDefault(); 351 focusButton(0); 352 break; 353 case keyCodes.END: 354 event.preventDefault(); 355 focusButton(lastIndex); 356 break;
357 case keyCodes.ENTER: 358 case keyCodes.SPACE: 359 event.preventDefault(); 360 toggle(index); 361 focusButton(index); 362 break; 363 default: 364 return; 365 } 366 } 367 368 /** 369 * General handler for toggle of an item. 370 * 371 * @private 372 * @param {Number} index The index of the item to toggle 373 */ 374 function toggle(index) { 375 var item = that._elements["item"][index]; 376 if (item) { 377 if (that._properties.singleExpansion) { 378 // ensure only a single item is expanded if single expansion is enabled. 379 for (var i = 0; i < that._elements["item"].length; i++) { 380 if (that._elements["item"][i] !== item) { 381 var expanded = getItemExpanded(that._elements["item"][i]); 382 if (expanded) { 383 setItemExpanded(that._elements["item"][i], false); 384 } 385 } 386 } 387 } 388 setItemExpanded(item, !getItemExpanded(item)); 389 390 if (dataLayerEnabled) { 391 var accordionId = that._elements.self.id; 392 var expandedItems = getExpandedItems() 393 .map(function(item) { 394 return getDataLayerId(item); 395 }); 396 397 var uploadPayload = { component: {} }; 398 uploadPayload.component[accordionId] = { shownItems: expandedItems }; 399 400 var removePayload = { component: {} }; 401 removePayload.component[accordionId] = { shownItems: undefined }; 402 403 dataLayer.push(removePayload); 404 dataLayer.push(uploadPayload); 405 } 406 } 407 } 408 409 /** 410 * Sets an item's expanded state based on the provided flag and refreshes its internals. 411 * 412 * @private 413 * @param {HTMLElement} item The item to mark as expanded, or not expanded 414 * @param {Boolean} expanded true to mark the item expanded, false otherwise 415 * @param {Boolean} keepHash true to keep the hash in the URL, false to update it 416 */ 417 function setItemExpanded(item, expanded, keepHash) { 418 if (expanded) { 419 item.setAttribute(dataAttributes.item.expanded, ""); 420 var index = that._elements["item"].indexOf(item); 421 if (!keepHash && containerUtils) { 422 containerUtils.updateUrlHash(that, "item", index); 423 } 424 if (dataLayerEnabled) { 425 dataLayer.push({ 426 event: "cmp:show", 427 eventInfo: { 428 path: "component." + getDataLayerId(item) 429 } 430 }); 431 } 432 433 } else { 434 item.removeAttribute(dataAttributes.item.expanded); 435 if (!keepHash && containerUtils) { 436 containerUtils.removeUrlHash(); 437 } 438 if (dataLayerEnabled) { 439 dataLayer.push({ 440 event: "cmp:hide", 441 eventInfo: { 442 path: "component." + getDataLayerId(item) 443 } 444 }); 445 } 446 } 447 refreshItem(item); 448 } 449 450 /** 451 * Gets an item's expanded state. 452 * 453 * @private 454 * @param {HTMLElement} item The item for checking its expanded state 455 * @returns {Boolean} true if the item is expanded, false otherwise 456 */ 457 function getItemExpanded(item) { 458 return item && item.dataset && item.dataset["cmpExpanded"] !== undefined; 459 } 460 461 /** 462 * Refreshes an item based on its expanded state. 463 * 464 * @private 465 * @param {HTMLElement} item The item to refresh 466 */ 467 function refreshItem(item) { 468 var expanded = getItemExpanded(item); 469 if (expanded) { 470 expandItem(item); 471 } else { 472 collapseItem(item); 473 } 474 } 475 476 /** 477 * Refreshes all items based on their expanded state. 478 * 479 * @private 480 */ 481 function refreshItems() { 482 for (var i = 0; i < that._elements["item"].length; i++) { 483 refreshItem(that._elements["item"][i]); 484 } 485 } 486 487 /** 488 * Returns all expanded items. 489 * 490 * @private 491 * @returns {HTMLElement[]} The expanded items 492 */ 493 function getExpandedItems() { 494 var expandedItems = []; 495 496 for (var i = 0; i < that._elements["item"].length; i++) { 497 var item = that._elements["item"][i]; 498 var expanded = getItemExpanded(item); 499 if (expanded) { 500 expandedItems.push(item); 501 } 502 } 503 504 return expandedItems; 505 } 506 507 /** 508 * Annotates the item and its internals with 509 * the necessary style and accessibility attributes to indicate it is expanded. 510 * 511 * @private 512 * @param {HTMLElement} item The item to annotate as expanded 513 */ 514 function expandItem(item) { 515 var index = that._elements["item"].indexOf(item); 516 if (index > -1) { 517 var button = that._elements["button"][index]; 518 var panel = that._elements["panel"][index];
519 button.classList.add(cssClasses.button.expanded); 520 // used to fix some known screen readers issues in reading the correct state of the 'aria-expanded' attribute 521 // e.g. https://bugs.webkit.org/show_bug.cgi?id=210934 522 setTimeout(function() { 523 button.setAttribute("aria-expanded", true); 524 }, delay); 525 panel.classList.add(cssClasses.panel.expanded); 526 panel.classList.remove(cssClasses.panel.hidden); 527 panel.setAttribute("aria-hidden", false); 528 } 529 } 530 531 /** 532 * Annotates the item and its internals with 533 * the necessary style and accessibility attributes to indicate it is not expanded. 534 * 535 * @private 536 * @param {HTMLElement} item The item to annotate as not expanded 537 */ 538 function collapseItem(item) { 539 var index = that._elements["item"].indexOf(item); 540 if (index > -1) { 541 var button = that._elements["button"][index]; 542 var panel = that._elements["panel"][index]; 543 button.classList.remove(cssClasses.button.expanded); 544 // used to fix some known screen readers issues in reading the correct state of the 'aria-expanded' attribute 545 // e.g. https://bugs.webkit.org/show_bug.cgi?id=210934 546 setTimeout(function() { 547 button.setAttribute("aria-expanded", false); 548 }, delay); 549 panel.classList.add(cssClasses.panel.hidden); 550 panel.classList.remove(cssClasses.panel.expanded); 551 panel.setAttribute("aria-hidden", true); 552 } 553 } 554 555 /** 556 * Focuses the button at the provided index. 557 * 558 * @private 559 * @param {Number} index The index of the button to focus 560 */ 561 function focusButton(index) { 562 var button = that._elements["button"][index]; 563 button.focus(); 564 } 565 } 566 567 /** 568 * Reads options data from the Accordion wrapper element, defined via {@code data-cmp-*} data attributes. 569 * 570 * @private 571 * @param {HTMLElement} element The Accordion element to read options data from 572 * @returns {Object} The options read from the component data attributes 573 */ 574 function readData(element) { 575 var data = element.dataset; 576 var options = []; 577 var capitalized = IS; 578 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 579 var reserved = ["is", "hook" + capitalized]; 580 581 for (var key in data) { 582 if (Object.prototype.hasOwnProperty.call(data, key)) { 583 var value = data[key]; 584 585 if (key.indexOf(NS) === 0) { 586 key = key.slice(NS.length); 587 key = key.charAt(0).toLowerCase() + key.substring(1); 588 589 if (reserved.indexOf(key) === -1) { 590 options[key] = value; 591 } 592 } 593 } 594 } 595 596 return options; 597 } 598 599 /** 600 * Parses the dataLayer string and returns the ID 601 * 602 * @private 603 * @param {HTMLElement} item the accordion item 604 * @returns {String} dataLayerId or undefined 605 */ 606 function getDataLayerId(item) { 607 if (item) { 608 if (item.dataset.cmpDataLayer) { 609 return Object.keys(JSON.parse(item.dataset.cmpDataLayer))[0]; 610 } else { 611 return item.id; 612 } 613 } 614 return null; 615 } 616 617 /** 618 * Document ready handler and DOM mutation observers. Initializes Accordion components as necessary. 619 * 620 * @private 621 */ 622 function onDocumentReady() { 623 dataLayerEnabled = document.body.hasAttribute("data-cmp-data-layer-enabled"); 624 if (dataLayerEnabled) { 625 dataLayerName = document.body.getAttribute("data-cmp-data-layer-name") || "adobeDataLayer"; 626 dataLayer = window[dataLayerName] = window[dataLayerName] || []; 627 } 628 629 var elements = document.querySelectorAll(selectors.self); 630 for (var i = 0; i < elements.length; i++) { 631 new Accordion({ element: elements[i], options: readData(elements[i]) }); 632 } 633 634 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 635 var body = document.querySelector("body"); 636 var observer = new MutationObserver(function(mutations) { 637 mutations.forEach(function(mutation) { 638 // needed for IE 639 var nodesArray = [].slice.call(mutation.addedNodes); 640 if (nodesArray.length > 0) { 641 nodesArray.forEach(function(addedNode) { 642 if (addedNode.querySelectorAll) { 643 var elementsArray = [].slice.call(addedNode.querySelectorAll(selectors.self)); 644 elementsArray.forEach(function(element) { 645 new Accordion({ element: element, options: readData(element) }); 646 }); 647 } 648 }); 649 } 650 }); 651 }); 652 653 observer.observe(body, { 654 subtree: true, 655 childList: true, 656 characterData: true 657 }); 658 } 659 660 if (document.readyState !== "loading") { 661 onDocumentReady(); 662 } else { 663 document.addEventListener("DOMContentLoaded", onDocumentReady); 664 } 665 666 if (containerUtils) { 667 window.addEventListener("load", containerUtils.scrollToAnchor, false); 668 } 669 670}()); 671 672/******************************************************************************* 673 * Copyright 2018 Adobe 674 * 675 * Licensed under the Apache License, Version 2.0 (the "License");
676 * you may not use this file except in compliance with the License. 677 * You may obtain a copy of the License at 678 * 679 * http://www.apache.org/licenses/LICENSE2.0 680 * 681 * Unless required by applicable law or agreed to in writing, software 682 * distributed under the License is distributed on an "AS IS" BASIS, 683 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 684 * See the License for the specific language governing permissions and 685 * limitations under the License. 686 ******************************************************************************/ 687 688/** 689 * Element.matches() 690 * https://developer.mozilla.org/enUS/docs/Web/API/Element/matches#Polyfill 691 */ 692if (!Element.prototype.matches) { 693 Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; 694} 695 696// eslint-disable-next-line valid-jsdoc 697/** 698 * Element.closest() 699 * https://developer.mozilla.org/enUS/docs/Web/API/Element/closest#Polyfill 700 */ 701if (!Element.prototype.closest) { 702 Element.prototype.closest = function(s) { 703 "use strict"; 704 var el = this; 705 if (!document.documentElement.contains(el)) { 706 return null; 707 } 708 do { 709 if (el.matches(s)) { 710 return el; 711 } 712 el = el.parentElement || el.parentNode; 713 } while (el !== null && el.nodeType === 1); 714 return null; 715 }; 716} 717 718/******************************************************************************* 719 * Copyright 2018 Adobe 720 * 721 * Licensed under the Apache License, Version 2.0 (the "License"); 722 * you may not use this file except in compliance with the License. 723 * You may obtain a copy of the License at 724 * 725 * http://www.apache.org/licenses/LICENSE-2.0 726 * 727 * Unless required by applicable law or agreed to in writing, software 728 * distributed under the License is distributed on an "AS IS" BASIS, 729 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 730 * See the License for the specific language governing permissions and 731 * limitations under the License. 732 ******************************************************************************/ 733/* global 734 CQ 735 */ 736(function() { 737 "use strict"; 738 739 var containerUtils = window.CQ && window.CQ.CoreComponents && window.CQ.CoreComponents.container && window.CQ.CoreComponents.container.utils ? window.CQ.CoreComponents.container.utils : undefined; 740 if (!containerUtils) { 741 // eslint-disable-next-line no-console 742 console.warn("Tabs: container utilities at window.CQ.CoreComponents.container.utils are not available. This can lead to missing features. Ensure the core.wcm.components.commons.site.container client library is included on the page."); 743 } 744 var dataLayerEnabled; 745 var dataLayer; 746 var dataLayerName; 747 748 var NS = "cmp"; 749 var IS = "tabs"; 750 751 var keyCodes = { 752 END: 35, 753 HOME: 36, 754 ARROW_LEFT: 37, 755 ARROW_UP: 38, 756 ARROW_RIGHT: 39, 757 ARROW_DOWN: 40 758 }; 759 760 var selectors = { 761 self: "[data-" + NS + '-is="' + IS + '"]', 762 active: { 763 tab: "cmp-tabs__tab--active", 764 tabpanel: "cmp-tabs__tabpanel--active" 765 } 766 }; 767 768 /** 769 * Tabs Configuration 770 * 771 * @typedef {Object} TabsConfig Represents a Tabs configuration 772 * @property {HTMLElement} element The HTMLElement representing the Tabs 773 * @property {Object} options The Tabs options 774 */ 775 776 /** 777 * Tabs 778 * 779 * @class Tabs 780 * @classdesc An interactive Tabs component for navigating a list of tabs 781 * @param {TabsConfig} config The Tabs configuration 782 */ 783 function Tabs(config) { 784 var that = this; 785 786 if (config && config.element) { 787 init(config); 788 } 789 790 /** 791 * Initializes the Tabs 792 * 793 * @private 794 * @param {TabsConfig} config The Tabs configuration 795 */ 796 function init(config) { 797 that._config = config; 798 799 // prevents multiple initialization 800 config.element.removeAttribute("data-" + NS + "-is"); 801 802 cacheElements(config.element); 803 that._active = getActiveIndex(that._elements["tab"]); 804 805 if (that._elements.tabpanel) { 806 refreshActive(); 807 bindEvents(); 808 scrollToDeepLinkIdInTabs(); 809 } 810 811 if (window.Granite && window.Granite.author && window.Granite.author.MessageChannel) { 812 /* 813 * Editor message handling: 814 * - subscribe to "cmp.panelcontainer" message requests sent by the editor frame
815 * - check that the message data panel container type is correct and that the id (path) matches this specific Tabs component 816 * - if so, route the "navigate" operation to enact a navigation of the Tabs based on index data 817 */ 818 CQ.CoreComponents.MESSAGE_CHANNEL = CQ.CoreComponents.MESSAGE_CHANNEL || new window.Granite.author.MessageChannel("cqauthor", window); 819 CQ.CoreComponents.MESSAGE_CHANNEL.subscribeRequestMessage("cmp.panelcontainer", function(message) { 820 if (message.data && message.data.type === "cmp-tabs" && message.data.id === that._elements.self.dataset["cmpPanelcontainerId"]) { 821 if (message.data.operation === "navigate") { 822 navigate(message.data.index); 823 } 824 } 825 }); 826 } 827 } 828 829 /** 830 * Displays the panel containing the element that corresponds to the deep link in the URI fragment 831 * and scrolls the browser to this element. 832 */ 833 function scrollToDeepLinkIdInTabs() { 834 if (containerUtils) { 835 var deepLinkItemIdx = containerUtils.getDeepLinkItemIdx(that, "tab", "tabpanel"); 836 if (deepLinkItemIdx > -1) { 837 var deepLinkItem = that._elements["tab"][deepLinkItemIdx]; 838 if (deepLinkItem && that._elements["tab"][that._active].id !== deepLinkItem.id) { 839 navigateAndFocusTab(deepLinkItemIdx, true); 840 } 841 var hashId = window.location.hash.substring(1); 842 if (hashId) { 843 var hashItem = document.querySelector("[id='" + hashId + "']"); 844 if (hashItem) { 845 hashItem.scrollIntoView(); 846 } 847 } 848 } 849 } 850 } 851 852 /** 853 * Returns the index of the active tab, if no tab is active returns 0 854 * 855 * @param {Array} tabs Tab elements 856 * @returns {Number} Index of the active tab, 0 if none is active 857 */ 858 function getActiveIndex(tabs) { 859 if (tabs) { 860 for (var i = 0; i < tabs.length; i++) { 861 if (tabs[i].classList.contains(selectors.active.tab)) { 862 return i; 863 } 864 } 865 } 866 return 0; 867 } 868 869 /** 870 * Caches the Tabs elements as defined via the {@code data-tabs-hook="ELEMENT_NAME"} markup API 871 * 872 * @private 873 * @param {HTMLElement} wrapper The Tabs wrapper element 874 */ 875 function cacheElements(wrapper) { 876 that._elements = {}; 877 that._elements.self = wrapper; 878 var hooks = that._elements.self.querySelectorAll("[data-" + NS + "-hook-" + IS + "]"); 879 880 for (var i = 0; i < hooks.length; i++) { 881 var hook = hooks[i]; 882 if (hook.closest("." + NS + "-" + IS) === that._elements.self) { // only process own tab elements 883 var capitalized = IS; 884 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 885 var key = hook.dataset[NS + "Hook" + capitalized]; 886 if (that._elements[key]) { 887 if (!Array.isArray(that._elements[key])) { 888 var tmp = that._elements[key]; 889 that._elements[key] = [tmp]; 890 } 891 that._elements[key].push(hook); 892 } else { 893 that._elements[key] = hook; 894 } 895 } 896 } 897 } 898 899 /** 900 * Binds Tabs event handling 901 * 902 * @private 903 */ 904 function bindEvents() { 905 window.addEventListener("hashchange", scrollToDeepLinkIdInTabs, false); 906 var tabs = that._elements["tab"]; 907 if (tabs) { 908 for (var i = 0; i < tabs.length; i++) { 909 (function(index) { 910 tabs[i].addEventListener("click", function(event) { 911 navigateAndFocusTab(index); 912 }); 913 tabs[i].addEventListener("keydown", function(event) { 914 onKeyDown(event); 915 }); 916 })(i); 917 } 918 } 919 } 920 921 /** 922 * Handles tab keydown events 923 * 924 * @private 925 * @param {Object} event The keydown event 926 */ 927 function onKeyDown(event) { 928 var index = that._active; 929 var lastIndex = that._elements["tab"].length - 1; 930 931 switch (event.keyCode) { 932 case keyCodes.ARROW_LEFT: 933 case keyCodes.ARROW_UP: 934 event.preventDefault(); 935 if (index > 0) { 936 navigateAndFocusTab(index - 1); 937 } 938 break; 939 case keyCodes.ARROW_RIGHT: 940 case keyCodes.ARROW_DOWN: 941 event.preventDefault(); 942 if (index < lastIndex) { 943 navigateAndFocusTab(index + 1); 944 } 945 break; 946 case keyCodes.HOME: 947 event.preventDefault(); 948 navigateAndFocusTab(0); 949 break; 950 case keyCodes.END: 951 event.preventDefault(); 952 navigateAndFocusTab(lastIndex); 953 break; 954 default: 955 return; 956 } 957 } 958 959 /** 960 * Refreshes the tab markup based on the current {@code Tabs#_active} index 961 * 962 * @private 963 */ 964 function refreshActive() { 965 var tabpanels = that._elements["tabpanel"]; 966 var tabs = that._elements["tab"]; 967 968 if (tabpanels) { 969 if (Array.isArray(tabpanels)) { 970 for (var i = 0; i < tabpanels.length; i++) { 971 if (i === parseInt(that._active)) { 972 tabpanels[i].classList.add(selectors.active.tabpanel); 973 tabpanels[i].removeAttribute("aria-hidden"); 974 tabs[i].classList.add(selectors.active.tab); 975 tabs[i].setAttribute("aria-selected", true); 976 tabs[i].setAttribute("tabindex", "0"); 977 } else { 978 tabpanels[i].classList.remove(selectors.active.tabpanel); 979 tabpanels[i].setAttribute("aria-hidden", true); 980 tabs[i].classList.remove(selectors.active.tab); 981 tabs[i].setAttribute("aria-selected", false); 982 tabs[i].setAttribute("tabindex", "-1"); 983 } 984 } 985 } else { 986 // only one tab 987 tabpanels.classList.add(selectors.active.tabpanel); 988 tabs.classList.add(selectors.active.tab); 989 } 990 } 991 } 992 993 /** 994 * Focuses the element and prevents scrolling the element into view 995 * 996 * @param {HTMLElement} element Element to focus 997 */ 998 function focusWithoutScroll(element) { 999 var x = window.scrollX || window.pageXOffset; 1000 var y = window.scrollY || window.pageYOffset; 1001 element.focus(); 1002 window.scrollTo(x, y); 1003 } 1004 1005 /** 1006 * Navigates to the tab at the provided index 1007 * 1008 * @private 1009 * @param {Number} index The index of the tab to navigate to 1010 */ 1011 function navigate(index) { 1012 that._active = index; 1013 refreshActive(); 1014 } 1015 1016 /** 1017 * Navigates to the item at the provided index and ensures the active tab gains focus 1018 * 1019 * @private 1020 * @param {Number} index The index of the item to navigate to 1021 * @param {Boolean} keepHash true to keep the hash in the URL, false to update it 1022 */ 1023 function navigateAndFocusTab(index, keepHash) { 1024 var exActive = that._active; 1025 if (!keepHash && containerUtils) { 1026 containerUtils.updateUrlHash(that, "tab", index); 1027 } 1028 navigate(index); 1029 focusWithoutScroll(that._elements["tab"][index]); 1030 1031 if (dataLayerEnabled) { 1032 1033 var activeItem = getDataLayerId(that._elements.tabpanel[index]); 1034 var exActiveItem = getDataLayerId(that._elements.tabpanel[exActive]); 1035 1036 dataLayer.push({ 1037 event: "cmp:show", 1038 eventInfo: { 1039 path: "component." + activeItem 1040 } 1041 }); 1042 1043 dataLayer.push({ 1044 event: "cmp:hide", 1045 eventInfo: { 1046 path: "component." + exActiveItem 1047 } 1048 }); 1049 1050 var tabsId = that._elements.self.id; 1051 var uploadPayload = { component: {} }; 1052 uploadPayload.component[tabsId] = { shownItems: [activeItem] }; 1053 1054 var removePayload = { component: {} }; 1055 removePayload.component[tabsId] = { shownItems: undefined }; 1056 1057 dataLayer.push(removePayload); 1058 dataLayer.push(uploadPayload); 1059 } 1060 } 1061 } 1062 1063 /**
1064 * Reads options data from the Tabs wrapper element, defined via {@code data-cmp-*} data attributes 1065 * 1066 * @private 1067 * @param {HTMLElement} element The Tabs element to read options data from 1068 * @returns {Object} The options read from the component data attributes 1069 */ 1070 function readData(element) { 1071 var data = element.dataset; 1072 var options = []; 1073 var capitalized = IS; 1074 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 1075 var reserved = ["is", "hook" + capitalized]; 1076 1077 for (var key in data) { 1078 if (Object.prototype.hasOwnProperty.call(data, key)) { 1079 var value = data[key]; 1080 1081 if (key.indexOf(NS) === 0) { 1082 key = key.slice(NS.length); 1083 key = key.charAt(0).toLowerCase() + key.substring(1); 1084 1085 if (reserved.indexOf(key) === -1) { 1086 options[key] = value; 1087 } 1088 } 1089 } 1090 } 1091 1092 return options; 1093 } 1094 1095 /** 1096 * Parses the dataLayer string and returns the ID 1097 * 1098 * @private 1099 * @param {HTMLElement} item the accordion item 1100 * @returns {String} dataLayerId or undefined 1101 */ 1102 function getDataLayerId(item) { 1103 if (item) { 1104 if (item.dataset.cmpDataLayer) { 1105 return Object.keys(JSON.parse(item.dataset.cmpDataLayer))[0]; 1106 } else { 1107 return item.id; 1108 } 1109 } 1110 return null; 1111 } 1112 1113 /** 1114 * Document ready handler and DOM mutation observers. Initializes Tabs components as necessary. 1115 * 1116 * @private 1117 */ 1118 function onDocumentReady() { 1119 dataLayerEnabled = document.body.hasAttribute("data-cmp-data-layer-enabled"); 1120 if (dataLayerEnabled) { 1121 dataLayerName = document.body.getAttribute("data-cmp-data-layer-name") || "adobeDataLayer"; 1122 dataLayer = window[dataLayerName] = window[dataLayerName] || []; 1123 } 1124 1125 var elements = document.querySelectorAll(selectors.self); 1126 for (var i = 0; i < elements.length; i++) { 1127 new Tabs({ element: elements[i], options: readData(elements[i]) }); 1128 } 1129 1130 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 1131 var body = document.querySelector("body"); 1132 var observer = new MutationObserver(function(mutations) { 1133 mutations.forEach(function(mutation) { 1134 // needed for IE 1135 var nodesArray = [].slice.call(mutation.addedNodes); 1136 if (nodesArray.length > 0) { 1137 nodesArray.forEach(function(addedNode) { 1138 if (addedNode.querySelectorAll) { 1139 var elementsArray = [].slice.call(addedNode.querySelectorAll(selectors.self)); 1140 elementsArray.forEach(function(element) { 1141 new Tabs({ element: element, options: readData(element) }); 1142 }); 1143 } 1144 }); 1145 } 1146 }); 1147 }); 1148 1149 observer.observe(body, { 1150 subtree: true, 1151 childList: true, 1152 characterData: true 1153 }); 1154 } 1155 1156 if (document.readyState !== "loading") { 1157 onDocumentReady(); 1158 } else { 1159 document.addEventListener("DOMContentLoaded", onDocumentReady); 1160 } 1161 1162 if (containerUtils) { 1163 window.addEventListener("load", containerUtils.scrollToAnchor, false); 1164 } 1165 1166}()); 1167 1168/******************************************************************************* 1169 * Copyright 2022 Adobe 1170 * 1171 * Licensed under the Apache License, Version 2.0 (the "License"); 1172 * you may not use this file except in compliance with the License. 1173 * You may obtain a copy of the License at 1174 * 1175 * http://www.apache.org/licenses/LICENSE-2.0 1176 * 1177 * Unless required by applicable law or agreed to in writing, software 1178 * distributed under the License is distributed on an "AS IS" BASIS, 1179 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1180 * See the License for the specific language governing permissions and 1181 * limitations under the License. 1182 ******************************************************************************/ 1183(function(document) { 1184 "use strict"; 1185 1186 window.CMP = window.CMP || {}; 1187 window.CMP.utils = (function() { 1188 var NS = "cmp"; 1189 1190 /**
1191 * Reads options data from the Component wrapper element, defined via {@code data-cmp-*} data attributes 1192 * 1193 * @param {HTMLElement} element The component element to read options data from 1194 * @param {String} is The component identifier 1195 * @returns {String[]} The options read from the component data attributes 1196 */ 1197 var readData = function(element, is) { 1198 var data = element.dataset; 1199 var options = []; 1200 var capitalized = is; 1201 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 1202 var reserved = ["is", "hook" + capitalized]; 1203 1204 for (var key in data) { 1205 if (Object.prototype.hasOwnProperty.call(data, key)) { 1206 var value = data[key]; 1207 1208 if (key.indexOf(NS) === 0) { 1209 key = key.slice(NS.length); 1210 key = key.charAt(0).toLowerCase() + key.substring(1); 1211 1212 if (reserved.indexOf(key) === -1) { 1213 options[key] = value; 1214 } 1215 } 1216 } 1217 } 1218 return options; 1219 }; 1220 1221 /** 1222 * Set up the final properties of a component by evaluating the transform function or fall back to the default value on demand 1223 * @param {String[]} options the options to transform 1224 * @param {Object} properties object of properties of property functions 1225 * @returns {Object} transformed properties 1226 */ 1227 var setupProperties = function(options, properties) { 1228 var transformedProperties = {}; 1229 1230 for (var key in properties) { 1231 if (Object.prototype.hasOwnProperty.call(properties, key)) { 1232 var property = properties[key]; 1233 if (options && options[key] != null) { 1234 if (property && typeof property.transform === "function") { 1235 transformedProperties[key] = property.transform(options[key]); 1236 } else { 1237 transformedProperties[key] = options[key]; 1238 } 1239 } else { 1240 transformedProperties[key] = properties[key]["default"]; 1241 } 1242 } 1243 } 1244 return transformedProperties; 1245 }; 1246 1247 1248 return { 1249 readData: readData, 1250 setupProperties: setupProperties 1251 }; 1252 }()); 1253}(window.document)); 1254 1255/******************************************************************************* 1256 * Copyright 2018 Adobe 1257 * 1258 * Licensed under the Apache License, Version 2.0 (the "License"); 1259 * you may not use this file except in compliance with the License. 1260 * You may obtain a copy of the License at 1261 * 1262 * http://www.apache.org/licenses/LICENSE-2.0 1263 * 1264 * Unless required by applicable law or agreed to in writing, software 1265 * distributed under the License is distributed on an "AS IS" BASIS, 1266 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1267 * See the License for the specific language governing permissions and 1268 * limitations under the License. 1269 ******************************************************************************/ 1270(function() { 1271 "use strict"; 1272 1273 var containerUtils = window.CQ && window.CQ.CoreComponents && window.CQ.CoreComponents.container && window.CQ.CoreComponents.container.utils ? window.CQ.CoreComponents.container.utils : undefined; 1274 if (!containerUtils) { 1275 // eslint-disable-next-line no-console 1276 console.warn("Tabs: container utilities at window.CQ.CoreComponents.container.utils are not available. This can lead to missing features. Ensure the core.wcm.components.commons.site.container client library is included on the page."); 1277 } 1278 var dataLayerEnabled; 1279 var dataLayer; 1280 var dataLayerName; 1281 1282 var NS = "cmp"; 1283 var IS = "carousel"; 1284 1285 var keyCodes = { 1286 SPACE: 32, 1287 END: 35, 1288 HOME: 36, 1289 ARROW_LEFT: 37, 1290 ARROW_UP: 38, 1291 ARROW_RIGHT: 39, 1292 ARROW_DOWN: 40 1293 }; 1294 1295 var selectors = { 1296 self: "[data-" + NS + '-is="' + IS + '"]' 1297 }; 1298 1299 var properties = { 1300 /** 1301 * Determines whether the Carousel will automatically transition between slides 1302 * 1303 * @memberof Carousel
1304 * @type {Boolean} 1305 * @default false 1306 */ 1307 "autoplay": { 1308 "default": false, 1309 "transform": function(value) { 1310 return !(value === null || typeof value === "undefined"); 1311 } 1312 }, 1313 /** 1314 * Duration (in milliseconds) before automatically transitioning to the next slide 1315 * 1316 * @memberof Carousel 1317 * @type {Number} 1318 * @default 5000 1319 */ 1320 "delay": { 1321 "default": 5000, 1322 "transform": function(value) { 1323 value = parseFloat(value); 1324 return !isNaN(value) ? value : null; 1325 } 1326 }, 1327 /** 1328 * Determines whether automatic pause on hovering the carousel is disabled 1329 * 1330 * @memberof Carousel 1331 * @type {Boolean} 1332 * @default false 1333 */ 1334 "autopauseDisabled": { 1335 "default": false, 1336 "transform": function(value) { 1337 return !(value === null || typeof value === "undefined"); 1338 } 1339 } 1340 }; 1341 1342 /** 1343 * Carousel Configuration 1344 * 1345 * @typedef {Object} CarouselConfig Represents a Carousel configuration 1346 * @property {HTMLElement} element The HTMLElement representing the Carousel 1347 * @property {*[]} options The Carousel options 1348 */ 1349 1350 /** 1351 * Carousel 1352 * 1353 * @class Carousel 1354 * @classdesc An interactive Carousel component for navigating a list of generic items 1355 * @param {CarouselConfig} config The Carousel configuration 1356 */ 1357 function Carousel(config) { 1358 var that = this; 1359 1360 if (config && config.element) { 1361 init(config); 1362 } 1363 1364 /** 1365 * Initializes the Carousel 1366 * 1367 * @private 1368 * @param {CarouselConfig} config The Carousel configuration 1369 */ 1370 function init(config) { 1371 that._config = config; 1372 1373 // prevents multiple initialization 1374 config.element.removeAttribute("data-" + NS + "-is"); 1375 1376 setupProperties(config.options); 1377 cacheElements(config.element); 1378 1379 that._active = 0; 1380 that._paused = false; 1381 1382 if (that._elements.item) { 1383 initializeActive(); 1384 bindEvents(); 1385 resetAutoplayInterval(); 1386 refreshPlayPauseActions(); 1387 scrollToDeepLinkIdInCarousel(); 1388 } 1389 1390 // TODO: This section is only relevant in edit mode and should move to the editor clientLib 1391 if (window.Granite && window.Granite.author && window.Granite.author.MessageChannel) { 1392 /* 1393 * Editor message handling: 1394 * - subscribe to "cmp.panelcontainer" message requests sent by the editor frame 1395 * - check that the message data panel container type is correct and that the id (path) matches this specific Carousel component 1396 * - if so, route the "navigate" operation to enact a navigation of the Carousel based on index data 1397 */ 1398 window.CQ = window.CQ || {}; 1399 window.CQ.CoreComponents = window.CQ.CoreComponents || {}; 1400 window.CQ.CoreComponents.MESSAGE_CHANNEL = window.CQ.CoreComponents.MESSAGE_CHANNEL || new window.Granite.author.MessageChannel("cqauthor", window); 1401 window.CQ.CoreComponents.MESSAGE_CHANNEL.subscribeRequestMessage("cmp.panelcontainer", function(message) { 1402 if (message.data && message.data.type === "cmp-carousel" && message.data.id === that._elements.self.dataset["cmpPanelcontainerId"]) { 1403 if (message.data.operation === "navigate") { 1404 navigate(message.data.index); 1405 } 1406 } 1407 }); 1408 } 1409 } 1410 1411 /** 1412 * Displays the slide containing the element that corresponds to the deep link in the URI fragment 1413 * and scrolls the browser to this element. 1414 */ 1415 function scrollToDeepLinkIdInCarousel() { 1416 if (containerUtils) { 1417 var deepLinkItemIdx = containerUtils.getDeepLinkItemIdx(that, "item", "item"); 1418 if (deepLinkItemIdx > -1) { 1419 var deepLinkItem = that._elements["item"][deepLinkItemIdx]; 1420 if (deepLinkItem && that._elements["item"][that._active].id !== deepLinkItem.id) { 1421 navigateAndFocusIndicator(deepLinkItemIdx, true); 1422 // pause the carousel auto-rotation 1423 pause(); 1424 } 1425 var hashId = window.location.hash.substring(1); 1426 if (hashId) { 1427 var hashItem = document.querySelector("[id='" + hashId + "']"); 1428 if (hashItem) { 1429 hashItem.scrollIntoView(); 1430 } 1431 } 1432 } 1433 } 1434 } 1435 1436 /** 1437 * Caches the Carousel elements as defined via the {@code data-carousel-hook="ELEMENT_NAME"} markup API 1438 * 1439 * @private 1440 * @param {HTMLElement} wrapper The Carousel wrapper element 1441 */ 1442 function cacheElements(wrapper) { 1443 that._elements = {}; 1444 that._elements.self = wrapper; 1445 var hooks = that._elements.self.querySelectorAll("[data-" + NS + "-hook-" + IS + "]"); 1446 1447 for (var i = 0; i < hooks.length; i++) { 1448 var hook = hooks[i]; 1449 var capitalized = IS; 1450 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 1451 var key = hook.dataset[NS + "Hook" + capitalized]; 1452 if (that._elements[key]) { 1453 if (!Array.isArray(that._elements[key])) { 1454 var tmp = that._elements[key]; 1455 that._elements[key] = [tmp]; 1456 } 1457 that._elements[key].push(hook); 1458 } else { 1459 that._elements[key] = hook; 1460 } 1461 } 1462 } 1463 1464 /** 1465 * Sets up properties for the Carousel based on the passed options. 1466 * 1467 * @private 1468 * @param {Object} options The Carousel options 1469 */ 1470 function setupProperties(options) { 1471 that._properties = {}; 1472 1473 for (var key in properties) { 1474 if (Object.prototype.hasOwnProperty.call(properties, key)) { 1475 var property = properties[key]; 1476 var value = null; 1477 1478 if (options && options[key] != null) { 1479 value = options[key]; 1480 1481 // transform the provided option 1482 if (property && typeof property.transform === "function") { 1483 value = property.transform(value); 1484 } 1485 } 1486 1487 if (value === null) { 1488 // value still null, take the property default 1489 value = properties[key]["default"]; 1490 } 1491 1492 that._properties[key] = value; 1493 } 1494 } 1495 } 1496 1497 /** 1498 * Binds Carousel event handling 1499 * 1500 * @private 1501 */ 1502 function bindEvents() { 1503 window.addEventListener("hashchange", scrollToDeepLinkIdInCarousel, false); 1504 if (that._elements["previous"]) { 1505 that._elements["previous"].addEventListener("click", function() { 1506 var index = getPreviousIndex(); 1507 navigate(index); 1508 if (dataLayerEnabled) { 1509 dataLayer.push({ 1510 event: "cmp:show", 1511 eventInfo: { 1512 path: "component." + getDataLayerId(that._elements.item[index]) 1513 } 1514 }); 1515 } 1516 }); 1517 } 1518 1519 if (that._elements["next"]) { 1520 that._elements["next"].addEventListener("click", function() { 1521 var index = getNextIndex(); 1522 navigate(index); 1523 if (dataLayerEnabled) { 1524 dataLayer.push({ 1525 event: "cmp:show", 1526 eventInfo: { 1527 path: "component." + getDataLayerId(that._elements.item[index]) 1528 } 1529 }); 1530 } 1531 }); 1532 } 1533 1534 var indicators = that._elements["indicator"]; 1535 if (indicators) { 1536 for (var i = 0; i < indicators.length; i++) { 1537 (function(index) { 1538 indicators[i].addEventListener("click", function(event) { 1539 navigateAndFocusIndicator(index); 1540 // pause the carousel auto-rotation 1541 pause(); 1542 }); 1543 })(i); 1544 } 1545 } 1546 1547 if (that._elements["pause"]) { 1548 if (that._properties.autoplay) { 1549 that._elements["pause"].addEventListener("click", onPauseClick); 1550 } 1551 } 1552 1553 if (that._elements["play"]) { 1554 if (that._properties.autoplay) { 1555 that._elements["play"].addEventListener("click", onPlayClick); 1556 } 1557 } 1558 1559 that._elements.self.addEventListener("keydown", onKeyDown); 1560 1561 if (!that._properties.autopauseDisabled) { 1562 that._elements.self.addEventListener("mouseenter", onMouseEnter); 1563 that._elements.self.addEventListener("mouseleave", onMouseLeave); 1564 } 1565 1566 // for accessibility we pause animation when a element get focused 1567 var items = that._elements["item"]; 1568 if (items) { 1569 for (var j = 0; j < items.length; j++) { 1570 items[j].addEventListener("focusin", onMouseEnter); 1571 items[j].addEventListener("focusout", onMouseLeave); 1572 } 1573 } 1574 } 1575 1576 /**
1577 * Handles carousel keydown events 1578 * 1579 * @private 1580 * @param {Object} event The keydown event 1581 */ 1582 function onKeyDown(event) { 1583 var index = that._active; 1584 var lastIndex = that._elements["indicator"].length - 1; 1585 1586 switch (event.keyCode) { 1587 case keyCodes.ARROW_LEFT: 1588 case keyCodes.ARROW_UP: 1589 event.preventDefault(); 1590 if (index > 0) { 1591 navigateAndFocusIndicator(index - 1); 1592 } 1593 break; 1594 case keyCodes.ARROW_RIGHT: 1595 case keyCodes.ARROW_DOWN: 1596 event.preventDefault(); 1597 if (index < lastIndex) { 1598 navigateAndFocusIndicator(index + 1); 1599 } 1600 break; 1601 case keyCodes.HOME: 1602 event.preventDefault(); 1603 navigateAndFocusIndicator(0); 1604 break; 1605 case keyCodes.END: 1606 event.preventDefault(); 1607 navigateAndFocusIndicator(lastIndex); 1608 break; 1609 case keyCodes.SPACE: 1610 if (that._properties.autoplay && (event.target !== that._elements["previous"] && event.target !== that._elements["next"])) { 1611 event.preventDefault(); 1612 if (!that._paused) { 1613 pause(); 1614 } else { 1615 play(); 1616 } 1617 } 1618 if (event.target === that._elements["pause"]) { 1619 that._elements["play"].focus(); 1620 } 1621 if (event.target === that._elements["play"]) { 1622 that._elements["pause"].focus(); 1623 } 1624 break; 1625 default: 1626 return; 1627 } 1628 } 1629 1630 /** 1631 * Handles carousel mouseenter events 1632 * 1633 * @private 1634 * @param {Object} event The mouseenter event 1635 */ 1636 function onMouseEnter(event) { 1637 clearAutoplayInterval(); 1638 } 1639 1640 /** 1641 * Handles carousel mouseleave events 1642 * 1643 * @private 1644 * @param {Object} event The mouseleave event 1645 */ 1646 function onMouseLeave(event) { 1647 resetAutoplayInterval(); 1648 } 1649 1650 /** 1651 * Handles pause element click events 1652 * 1653 * @private 1654 * @param {Object} event The click event 1655 */ 1656 function onPauseClick(event) { 1657 pause(); 1658 that._elements["play"].focus(); 1659 } 1660 1661 /** 1662 * Handles play element click events 1663 * 1664 * @private 1665 * @param {Object} event The click event 1666 */ 1667 function onPlayClick() { 1668 play(); 1669 that._elements["pause"].focus(); 1670 } 1671 1672 /** 1673 * Pauses the playing of the Carousel. Sets {@code Carousel#_paused} marker. 1674 * Only relevant when autoplay is enabled 1675 * 1676 * @private 1677 */ 1678 function pause() { 1679 that._paused = true; 1680 clearAutoplayInterval(); 1681 refreshPlayPauseActions(); 1682 } 1683 1684 /** 1685 * Enables the playing of the Carousel. Sets {@code Carousel#_paused} marker. 1686 * Only relevant when autoplay is enabled 1687 * 1688 * @private 1689 */ 1690 function play() { 1691 that._paused = false; 1692 1693 // If the Carousel is hovered, don't begin auto transitioning until the next mouse leave event 1694 var hovered = false; 1695 if (that._elements.self.parentElement) { 1696 hovered = that._elements.self.parentElement.querySelector(":hover") === that._elements.self; 1697 } 1698 if (that._properties.autopauseDisabled || !hovered) { 1699 resetAutoplayInterval(); 1700 } 1701 1702 refreshPlayPauseActions(); 1703 } 1704 1705 /** 1706 * Refreshes the play/pause action markup based on the {@code Carousel#_paused} state 1707 * 1708 * @private 1709 */ 1710 function refreshPlayPauseActions() {
1711 setActionDisabled(that._elements["pause"], that._paused); 1712 setActionDisabled(that._elements["play"], !that._paused); 1713 } 1714 1715 /** 1716 * Initialize {@code Carousel#_active} based on the active item of the carousel. 1717 */ 1718 function initializeActive() { 1719 var items = that._elements["item"]; 1720 if (items && Array.isArray(items)) { 1721 for (var i = 0; i < items.length; i++) { 1722 if (items[i].classList.contains("cmp-carousel__item--active")) { 1723 that._active = i; 1724 break; 1725 } 1726 } 1727 } 1728 } 1729 1730 /** 1731 * Refreshes the item markup based on the current {@code Carousel#_active} index 1732 * 1733 * @private 1734 */ 1735 function refreshActive() { 1736 var items = that._elements["item"]; 1737 var indicators = that._elements["indicator"]; 1738 1739 if (items) { 1740 if (Array.isArray(items)) { 1741 for (var i = 0; i < items.length; i++) { 1742 if (i === parseInt(that._active)) { 1743 items[i].classList.add("cmp-carousel__item--active"); 1744 items[i].removeAttribute("aria-hidden"); 1745 indicators[i].classList.add("cmp-carousel__indicator--active"); 1746 indicators[i].setAttribute("aria-selected", true); 1747 indicators[i].setAttribute("tabindex", "0"); 1748 } else { 1749 items[i].classList.remove("cmp-carousel__item--active"); 1750 items[i].setAttribute("aria-hidden", true); 1751 indicators[i].classList.remove("cmp-carousel__indicator--active"); 1752 indicators[i].setAttribute("aria-selected", false); 1753 indicators[i].setAttribute("tabindex", "-1"); 1754 } 1755 } 1756 } else { 1757 // only one item 1758 items.classList.add("cmp-carousel__item--active"); 1759 indicators.classList.add("cmp-carousel__indicator--active"); 1760 } 1761 } 1762 } 1763 1764 /** 1765 * Focuses the element and prevents scrolling the element into view 1766 * 1767 * @param {HTMLElement} element Element to focus 1768 */ 1769 function focusWithoutScroll(element) { 1770 var x = window.scrollX || window.pageXOffset; 1771 var y = window.scrollY || window.pageYOffset; 1772 element.focus(); 1773 window.scrollTo(x, y); 1774 } 1775 1776 /** 1777 * Retrieves the next active index, with looping 1778 * 1779 * @private 1780 * @returns {Number} Index of the next carousel item 1781 */ 1782 function getNextIndex() { 1783 return that._active === (that._elements["item"].length - 1) ? 0 : that._active + 1; 1784 } 1785 1786 /** 1787 * Retrieves the previous active index, with looping 1788 * 1789 * @private 1790 * @returns {Number} Index of the previous carousel item 1791 */ 1792 function getPreviousIndex() { 1793 return that._active === 0 ? (that._elements["item"].length - 1) : that._active - 1; 1794 } 1795 1796 /** 1797 * Navigates to the item at the provided index 1798 * 1799 * @private 1800 * @param {Number} index The index of the item to navigate to 1801 * @param {Boolean} keepHash true to keep the hash in the URL, false to update it 1802 */ 1803 function navigate(index, keepHash) { 1804 if (index < 0 || index > (that._elements["item"].length - 1)) { 1805 return; 1806 } 1807 1808 that._active = index; 1809 refreshActive(); 1810 1811 if (!keepHash && containerUtils) { 1812 containerUtils.updateUrlHash(that, "item", index); 1813 } 1814 1815 if (dataLayerEnabled) { 1816 var carouselId = that._elements.self.id; 1817 var activeItem = getDataLayerId(that._elements.item[index]); 1818 var updatePayload = { component: {} }; 1819 updatePayload.component[carouselId] = { shownItems: [activeItem] }; 1820 1821 var removePayload = { component: {} }; 1822 removePayload.component[carouselId] = { shownItems: undefined }; 1823 1824 dataLayer.push(removePayload); 1825 dataLayer.push(updatePayload); 1826 } 1827 1828 // reset the autoplay transition interval following navigation, if not already hovering the carousel
1829 if (that._elements.self.parentElement) { 1830 if (that._elements.self.parentElement.querySelector(":hover") !== that._elements.self) { 1831 resetAutoplayInterval(); 1832 } 1833 } 1834 } 1835 1836 /** 1837 * Navigates to the item at the provided index and ensures the active indicator gains focus 1838 * 1839 * @private 1840 * @param {Number} index The index of the item to navigate to 1841 * @param {Boolean} keepHash true to keep the hash in the URL, false to update it 1842 */ 1843 function navigateAndFocusIndicator(index, keepHash) { 1844 navigate(index, keepHash); 1845 focusWithoutScroll(that._elements["indicator"][index]); 1846 1847 if (dataLayerEnabled) { 1848 dataLayer.push({ 1849 event: "cmp:show", 1850 eventInfo: { 1851 path: "component." + getDataLayerId(that._elements.item[index]) 1852 } 1853 }); 1854 } 1855 } 1856 1857 /** 1858 * Starts/resets automatic slide transition interval 1859 * 1860 * @private 1861 */ 1862 function resetAutoplayInterval() { 1863 if (that._paused || !that._properties.autoplay) { 1864 return; 1865 } 1866 clearAutoplayInterval(); 1867 that._autoplayIntervalId = window.setInterval(function() { 1868 if (document.visibilityState && document.hidden) { 1869 return; 1870 } 1871 var indicators = that._elements["indicators"]; 1872 if (indicators !== document.activeElement && indicators.contains(document.activeElement)) { 1873 // if an indicator has focus, ensure we switch focus following navigation 1874 navigateAndFocusIndicator(getNextIndex(), true); 1875 } else { 1876 navigate(getNextIndex(), true); 1877 } 1878 }, that._properties.delay); 1879 } 1880 1881 /** 1882 * Clears/pauses automatic slide transition interval 1883 * 1884 * @private 1885 */ 1886 function clearAutoplayInterval() { 1887 window.clearInterval(that._autoplayIntervalId); 1888 that._autoplayIntervalId = null; 1889 } 1890 1891 /** 1892 * Sets the disabled state for an action and toggles the appropriate CSS classes 1893 * 1894 * @private 1895 * @param {HTMLElement} action Action to disable 1896 * @param {Boolean} [disable] {@code true} to disable, {@code false} to enable 1897 */ 1898 function setActionDisabled(action, disable) { 1899 if (!action) { 1900 return; 1901 } 1902 if (disable !== false) { 1903 action.disabled = true; 1904 action.classList.add("cmp-carousel__action--disabled"); 1905 } else { 1906 action.disabled = false; 1907 action.classList.remove("cmp-carousel__action--disabled"); 1908 } 1909 } 1910 } 1911 1912 /** 1913 * Parses the dataLayer string and returns the ID 1914 * 1915 * @private 1916 * @param {HTMLElement} item the accordion item 1917 * @returns {String} dataLayerId or undefined 1918 */ 1919 function getDataLayerId(item) { 1920 if (item) { 1921 if (item.dataset.cmpDataLayer) { 1922 return Object.keys(JSON.parse(item.dataset.cmpDataLayer))[0]; 1923 } else { 1924 return item.id; 1925 } 1926 } 1927 return null; 1928 } 1929 1930 /** 1931 * Document ready handler and DOM mutation observers. Initializes Carousel components as necessary. 1932 * 1933 * @private 1934 */ 1935 function onDocumentReady() { 1936 dataLayerEnabled = document.body.hasAttribute("data-cmp-data-layer-enabled"); 1937 if (dataLayerEnabled) { 1938 dataLayerName = document.body.getAttribute("data-cmp-data-layer-name") || "adobeDataLayer"; 1939 dataLayer = window[dataLayerName] = window[dataLayerName] || []; 1940 } 1941 1942 var elements = document.querySelectorAll(selectors.self); 1943 for (var i = 0; i < elements.length; i++) { 1944 new Carousel({ element: elements[i], options: CMP.utils.readData(elements[i], IS) }); 1945 } 1946 1947 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 1948 var body = document.querySelector("body"); 1949 var observer = new MutationObserver(function(mutations) { 1950 mutations.forEach(function(mutation) { 1951 // needed for IE 1952 var nodesArray = [].slice.call(mutation.addedNodes); 1953 if (nodesArray.length > 0) { 1954 nodesArray.forEach(function(addedNode) { 1955 if (addedNode.querySelectorAll) { 1956 var elementsArray = [].slice.call(addedNode.querySelectorAll(selectors.self)); 1957 elementsArray.forEach(function(element) { 1958 new Carousel({ element: element, options: CMP.utils.readData(element, IS) }); 1959 }); 1960 } 1961 }); 1962 } 1963 }); 1964 }); 1965 1966 observer.observe(body, { 1967 subtree: true, 1968 childList: true, 1969 characterData: true 1970 }); 1971 } 1972 1973 var documentReady = document.readyState !== "loading" ? Promise.resolve() : new Promise(function(resolve) { 1974 document.addEventListener("DOMContentLoaded", resolve); 1975 }); 1976 Promise.all([documentReady]).then(onDocumentReady); 1977 1978 if (containerUtils) { 1979 window.addEventListener("load", containerUtils.scrollToAnchor, false); 1980 } 1981 1982}()); 1983 1984/******************************************************************************* 1985 * Copyright 2017 Adobe 1986 * 1987 * Licensed under the Apache License, Version 2.0 (the "License");
1988 * you may not use this file except in compliance with the License. 1989 * You may obtain a copy of the License at 1990 * 1991 * http://www.apache.org/licenses/LICENSE-2.0 1992 * 1993 * Unless required by applicable law or agreed to in writing, software 1994 * distributed under the License is distributed on an "AS IS" BASIS, 1995 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1996 * See the License for the specific language governing permissions and 1997 * limitations under the License. 1998 ******************************************************************************/ 1999if (window.Element && !Element.prototype.closest) { 2000 // eslint valid-jsdoc: "off" 2001 Element.prototype.closest = 2002 function(s) { 2003 "use strict"; 2004 var matches = (this.document || this.ownerDocument).querySelectorAll(s); 2005 var el = this; 2006 var i; 2007 do { 2008 i = matches.length; 2009 while (--i >= 0 && matches.item(i) !== el) { 2010 // continue 2011 } 2012 } while ((i < 0) && (el = el.parentElement)); 2013 return el; 2014 }; 2015} 2016 2017if (window.Element && !Element.prototype.matches) { 2018 Element.prototype.matches = 2019 Element.prototype.matchesSelector || 2020 Element.prototype.mozMatchesSelector || 2021 Element.prototype.msMatchesSelector || 2022 Element.prototype.oMatchesSelector || 2023 Element.prototype.webkitMatchesSelector || 2024 function(s) { 2025 "use strict"; 2026 var matches = (this.document || this.ownerDocument).querySelectorAll(s); 2027 var i = matches.length; 2028 while (--i >= 0 && matches.item(i) !== this) { 2029 // continue 2030 } 2031 return i > -1; 2032 }; 2033} 2034 2035if (!Object.assign) { 2036 Object.assign = function(target, varArgs) { // .length of function is 2 2037 "use strict"; 2038 if (target === null) { 2039 throw new TypeError("Cannot convert undefined or null to object"); 2040 } 2041 2042 var to = Object(target); 2043 2044 for (var index = 1; index < arguments.length; index++) { 2045 var nextSource = arguments[index]; 2046 2047 if (nextSource !== null) { 2048 for (var nextKey in nextSource) { 2049 if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { 2050 to[nextKey] = nextSource[nextKey]; 2051 } 2052 } 2053 } 2054 } 2055 return to; 2056 }; 2057} 2058 2059(function(arr) { 2060 "use strict"; 2061 arr.forEach(function(item) { 2062 if (Object.prototype.hasOwnProperty.call(item, "remove")) { 2063 return; 2064 } 2065 Object.defineProperty(item, "remove", { 2066 configurable: true, 2067 enumerable: true, 2068 writable: true, 2069 value: function remove() { 2070 this.parentNode.removeChild(this); 2071 } 2072 }); 2073 }); 2074})([Element.prototype, CharacterData.prototype, DocumentType.prototype]); 2075 2076/******************************************************************************* 2077 * Copyright 2022 Adobe 2078 * 2079 * Licensed under the Apache License, Version 2.0 (the "License"); 2080 * you may not use this file except in compliance with the License. 2081 * You may obtain a copy of the License at 2082 * 2083 * http://www.apache.org/licenses/LICENSE-2.0 2084 * 2085 * Unless required by applicable law or agreed to in writing, software 2086 * distributed under the License is distributed on an "AS IS" BASIS, 2087 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2088 * See the License for the specific language governing permissions and 2089 * limitations under the License. 2090 ******************************************************************************/ 2091(function(document) { 2092 "use strict"; 2093 2094 window.CMP = window.CMP || {}; 2095 window.CMP.utils = (function() { 2096 var NS = "cmp"; 2097 2098 /** 2099 * Reads options data from the Component wrapper element, defined via {@code data-cmp-*} data attributes 2100 * 2101 * @param {HTMLElement} element The component element to read options data from 2102 * @param {String} is The component identifier 2103 * @returns {String[]} The options read from the component data attributes 2104 */ 2105 var readData = function(element, is) { 2106 var data = element.dataset; 2107 var options = []; 2108 var capitalized = is; 2109 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 2110 var reserved = ["is", "hook" + capitalized]; 2111 2112 for (var key in data) { 2113 if (Object.prototype.hasOwnProperty.call(data, key)) { 2114 var value = data[key]; 2115 2116 if (key.indexOf(NS) === 0) { 2117 key = key.slice(NS.length); 2118 key = key.charAt(0).toLowerCase() + key.substring(1); 2119 2120 if (reserved.indexOf(key) === -1) { 2121 options[key] = value; 2122 } 2123 } 2124 } 2125 } 2126 return options; 2127 }; 2128 2129 /** 2130 * Set up the final properties of a component by evaluating the transform function or fall back to the default value on demand 2131 * @param {String[]} options the options to transform 2132 * @param {Object} properties object of properties of property functions 2133 * @returns {Object} transformed properties 2134 */ 2135 var setupProperties = function(options, properties) { 2136 var transformedProperties = {}; 2137 2138 for (var key in properties) { 2139 if (Object.prototype.hasOwnProperty.call(properties, key)) { 2140 var property = properties[key]; 2141 if (options && options[key] != null) { 2142 if (property && typeof property.transform === "function") { 2143 transformedProperties[key] = property.transform(options[key]); 2144 } else { 2145 transformedProperties[key] = options[key]; 2146 } 2147 } else { 2148 transformedProperties[key] = properties[key]["default"]; 2149 } 2150 } 2151 } 2152 return transformedProperties; 2153 }; 2154 2155 2156 return { 2157 readData: readData, 2158 setupProperties: setupProperties 2159 }; 2160 }()); 2161}(window.document)); 2162 2163/******************************************************************************* 2164 * Copyright 2022 Adobe 2165 * 2166 * Licensed under the Apache License, Version 2.0 (the "License");
2167 * you may not use this file except in compliance with the License. 2168 * You may obtain a copy of the License at 2169 * 2170 * http://www.apache.org/licenses/LICENSE-2.0 2171 * 2172 * Unless required by applicable law or agreed to in writing, software 2173 * distributed under the License is distributed on an "AS IS" BASIS, 2174 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2175 * See the License for the specific language governing permissions and 2176 * limitations under the License. 2177 ******************************************************************************/ 2178(function(document) { 2179 "use strict"; 2180 2181 window.CMP = window.CMP || {}; 2182 window.CMP.image = window.CMP.image || {}; 2183 window.CMP.image.dynamicMedia = (function() { 2184 var autoSmartCrops = {}; 2185 var SRC_URI_TEMPLATE_WIDTH_VAR = "{.width}"; 2186 var SRC_URI_TEMPLATE_DPR_VAR = "{dpr}"; 2187 var SRC_URI_DPR_OFF = "dpr=off"; 2188 var SRC_URI_DPR_ON = "dpr=on,{dpr}"; 2189 var dpr = window.devicePixelRatio || 1; 2190 var config = { 2191 minWidth: 20 2192 }; 2193 2194 /** 2195 * get auto smart crops from dm 2196 * @param {String} src the src uri 2197 * @returns {{}} the smart crop json object 2198 */ 2199 var getAutoSmartCrops = function(src) { 2200 var request = new XMLHttpRequest(); 2201 var url = src.split(SRC_URI_TEMPLATE_WIDTH_VAR)[0] + "?req=set,json"; 2202 request.open("GET", url, false); 2203 request.onload = function() { 2204 if (request.status >= 200 && request.status < 400) { 2205 // success status 2206 var responseText = request.responseText; 2207 var rePayload = new RegExp(/^(?:\/\*jsonp\*\/)?\s*([^()]+)\(([\s\S]+),\s*"[0-9]*"\);?$/gmi); 2208 var rePayloadJSON = new RegExp(/^{[\s\S]*}$/gmi); 2209 var resPayload = rePayload.exec(responseText); 2210 var payload; 2211 if (resPayload) { 2212 var payloadStr = resPayload[2]; 2213 if (rePayloadJSON.test(payloadStr)) { 2214 payload = JSON.parse(payloadStr); 2215 } 2216 2217 } 2218 // check "relation" - only in case of smartcrop preset 2219 if (payload && payload.set.relation && payload.set.relation.length > 0) { 2220 for (var i = 0; i < payload.set.relation.length; i++) { 2221 autoSmartCrops[parseInt(payload.set.relation[i].userdata.SmartCropWidth)] = 2222 ":" + payload.set.relation[i].userdata.SmartCropDef; 2223 } 2224 } 2225 } else { 2226 // error status 2227 } 2228 }; 2229 request.send(); 2230 return autoSmartCrops; 2231 }; 2232 2233 /** 2234 * Build and return the srcset value based on the available auto smart crops 2235 * @param {String} src the src uri 2236 * @param {Object} smartCrops the smart crops object 2237 * @returns {String} the srcset 2238 */ 2239 var getSrcSet = function(src, smartCrops) { 2240 var srcset; 2241 var keys = Object.keys(smartCrops); 2242 if (keys.length > 0) { 2243 srcset = []; 2244 for (var key in autoSmartCrops) { 2245 srcset.push(src.replace(SRC_URI_TEMPLATE_WIDTH_VAR, smartCrops[key]) + " " + key + "w"); 2246 } 2247 } 2248 return srcset.join(","); 2249 }; 2250 2251 /** 2252 * Get the optimal width based on the available sizes 2253 * @param {[Number]} sizes the available sizes 2254 * @param {Number} width the element width 2255 * @returns {String} the optimal width 2256 */ 2257 function getOptimalWidth(sizes, width) { 2258 var len = sizes.length; 2259 var key = 0; 2260 2261 while ((key < len - 1) && (sizes[key] < width)) { 2262 key++; 2263 } 2264 2265 return sizes[key] !== undefined ? sizes[key].toString() : width; 2266 } 2267 2268 /** 2269 * Get the width of an element or parent element if the width is smaller than the minimum width 2270 * @param {HTMLElement} component the image component 2271 * @param {HTMLElement | Node} parent the parent element 2272 * @returns {Number} the width of the element 2273 */ 2274 var getWidth = function(component, parent) { 2275 var width = component.offsetWidth; 2276 while (width < config.minWidth && parent && !component._autoWidth) { 2277 width = parent.offsetWidth; 2278 parent = parent.parentNode; 2279 } 2280 return width; 2281 }; 2282 2283 /** 2284 * Set the src and srcset attribute for a Dynamic Media Image which auto smart crops enabled. 2285 * @param {HTMLElement} component the image component 2286 * @param {{}} properties the component properties 2287 */ 2288 var setDMAttributes = function(component, properties) { 2289 // for v3 we first have to turn the dpr on
2290 var src = properties.src.replace(SRC_URI_DPR_OFF, SRC_URI_DPR_ON); 2291 src = src.replace(SRC_URI_TEMPLATE_DPR_VAR, dpr); 2292 var smartCrops = {}; 2293 var width; 2294 if (properties["smartcroprendition"] === "SmartCrop:Auto") { 2295 smartCrops = getAutoSmartCrops(src); 2296 } 2297 var hasWidths = (properties.widths && properties.widths.length > 0) || Object.keys(smartCrops).length > 0; 2298 if (hasWidths) { 2299 var image = component.querySelector("img"); 2300 var elemWidth = getWidth(component, component.parentNode); 2301 if (properties["smartcroprendition"] === "SmartCrop:Auto") { 2302 image.setAttribute("srcset", CMP.image.dynamicMedia.getSrcSet(src, smartCrops)); 2303 width = getOptimalWidth(Object.keys(smartCrops, elemWidth)); 2304 image.setAttribute("src", CMP.image.dynamicMedia.getSrc(src, smartCrops[width])); 2305 } else { 2306 width = getOptimalWidth(properties.widths, elemWidth); 2307 image.setAttribute("src", CMP.image.dynamicMedia.getSrc(src, width)); 2308 } 2309 } 2310 }; 2311 2312 /** 2313 * Get the src attribute based on the optimal width 2314 * @param {String} src the src uri 2315 * @param {String} width the element width 2316 * @returns {String} the final src attribute 2317 */ 2318 var getSrc = function(src, width) { 2319 if (src.indexOf(SRC_URI_TEMPLATE_WIDTH_VAR) > -1) { 2320 src = src.replace(SRC_URI_TEMPLATE_WIDTH_VAR, width); 2321 } 2322 return src; 2323 }; 2324 2325 2326 return { 2327 getAutoSmartCrops: getAutoSmartCrops, 2328 getSrcSet: getSrcSet, 2329 getSrc: getSrc, 2330 setDMAttributes: setDMAttributes, 2331 getWidth: getWidth 2332 }; 2333 }()); 2334 document.dispatchEvent(new CustomEvent("core.wcm.components.commons.site.image.dynamic-media.loaded")); 2335}(window.document)); 2336 2337/******************************************************************************* 2338 * Copyright 2016 Adobe 2339 * 2340 * Licensed under the Apache License, Version 2.0 (the "License"); 2341 * you may not use this file except in compliance with the License. 2342 * You may obtain a copy of the License at 2343 * 2344 * http://www.apache.org/licenses/LICENSE-2.0 2345 * 2346 * Unless required by applicable law or agreed to in writing, software 2347 * distributed under the License is distributed on an "AS IS" BASIS, 2348 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2349 * See the License for the specific language governing permissions and 2350 * limitations under the License. 2351 ******************************************************************************/ 2352(function() { 2353 "use strict"; 2354 2355 var NS = "cmp"; 2356 var IS = "image"; 2357 2358 var EMPTY_PIXEL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"; 2359 var LAZY_THRESHOLD_DEFAULT = 0; 2360 var SRC_URI_TEMPLATE_WIDTH_VAR = "{.width}"; 2361 var SRC_URI_TEMPLATE_WIDTH_VAR_ASSET_DELIVERY = "width={width}"; 2362 var SRC_URI_TEMPLATE_DPR_VAR = "{dpr}"; 2363 2364 var selectors = { 2365 self: "[data-" + NS + '-is="' + IS + '"]', 2366 image: '[data-cmp-hook-image="image"]', 2367 map: '[data-cmp-hook-image="map"]', 2368 area: '[data-cmp-hook-image="area"]' 2369 }; 2370 2371 var lazyLoader = { 2372 "cssClass": "cmp-image__image--is-loading", 2373 "style": { 2374 "height": 0, 2375 "padding-bottom": "" // will be replaced with % ratio 2376 } 2377 }; 2378 2379 var properties = { 2380 /** 2381 * An array of alternative image widths (in pixels). 2382 * Used to replace a {.width} variable in the src property with an optimal width if a URI template is provided. 2383 * 2384 * @memberof Image 2385 * @type {Number[]} 2386 * @default [] 2387 */ 2388 "widths": { 2389 "default": [], 2390 "transform": function(value) { 2391 var widths = []; 2392 value.split(",").forEach(function(item) { 2393 item = parseFloat(item); 2394 if (!isNaN(item)) { 2395 widths.push(item); 2396 } 2397 }); 2398 return widths; 2399 } 2400 }, 2401 /** 2402 * Indicates whether the image should be rendered lazily. 2403 * 2404 * @memberof Image 2405 * @type {Boolean} 2406 * @default false 2407 */ 2408 "lazy": { 2409 "default": false, 2410 "transform": function(value) { 2411 return !(value === null || typeof value === "undefined"); 2412 } 2413 }, 2414 /** 2415 * Indicates image is DynamicMedia image. 2416 * 2417 * @memberof Image 2418 * @type {Boolean} 2419 * @default false 2420 */ 2421 "dmimage": { 2422 "default": false, 2423 "transform": function(value) { 2424 return !(value === null || typeof value === "undefined"); 2425 } 2426 }, 2427 /** 2428 * The lazy threshold. 2429 * This is the number of pixels, in advance of becoming visible, when an lazy-loading image should begin 2430 * to load. 2431 * 2432 * @memberof Image 2433 * @type {Number} 2434 * @default 0 2435 */ 2436 "lazythreshold": { 2437 "default": 0, 2438 "transform": function(value) { 2439 var val = parseInt(value); 2440 if (isNaN(val)) { 2441 return LAZY_THRESHOLD_DEFAULT; 2442 } 2443 return val; 2444 } 2445 }, 2446 /** 2447 * The image source. 2448 * 2449 * Can be a simple image source, or a URI template representation that 2450 * can be variable expanded - useful for building an image configuration with an alternative width. 2451 * e.g. '/path/image.coreimg{.width}.jpeg/1506620954214.jpeg' 2452 * 2453 * @memberof Image 2454 * @type {String} 2455 */ 2456 "src": { 2457 "transform": function(value) { 2458 return decodeURIComponent(value); 2459 } 2460 } 2461 }; 2462 2463 var devicePixelRatio = window.devicePixelRatio || 1; 2464 2465 function Image(config) { 2466 var that = this; 2467 2468 var smartCrops = {}; 2469 2470 var useAssetDelivery = false;
2471 var srcUriTemplateWidthVar = SRC_URI_TEMPLATE_WIDTH_VAR; 2472 2473 function init(config) { 2474 // prevents multiple initialization 2475 config.element.removeAttribute("data-" + NS + "-is"); 2476 2477 // check if asset delivery is used 2478 if (config.options.src && config.options.src.indexOf(SRC_URI_TEMPLATE_WIDTH_VAR_ASSET_DELIVERY) >= 0) { 2479 useAssetDelivery = true; 2480 srcUriTemplateWidthVar = SRC_URI_TEMPLATE_WIDTH_VAR_ASSET_DELIVERY; 2481 } 2482 2483 that._properties = CMP.utils.setupProperties(config.options, properties); 2484 cacheElements(config.element); 2485 // check image is DM asset; if true try to make req=set 2486 if (config.options.src && Object.prototype.hasOwnProperty.call(config.options, "dmimage") && (config.options["smartcroprendition"] === "SmartCrop:Auto")) { 2487 smartCrops = CMP.image.dynamicMedia.getAutoSmartCrops(config.options.src); 2488 } 2489 2490 if (!that._elements.noscript) { 2491 return; 2492 } 2493 2494 that._elements.container = that._elements.link ? that._elements.link : that._elements.self; 2495 2496 unwrapNoScript(); 2497 2498 if (that._properties.lazy) { 2499 addLazyLoader(); 2500 } 2501 2502 if (that._elements.map) { 2503 that._elements.image.addEventListener("load", onLoad); 2504 } 2505 2506 window.addEventListener("resize", onWindowResize); 2507 ["focus", "click", "load", "transitionend", "animationend", "scroll"].forEach(function(name) { 2508 document.addEventListener(name, that.update); 2509 }); 2510 2511 that._elements.image.addEventListener("cmp-image-redraw", that.update); 2512 2513 that._interSectionObserver = new IntersectionObserver(function(entries, interSectionObserver) { 2514 entries.forEach(function(entry) { 2515 if (entry.intersectionRatio > 0) { 2516 that.update(); 2517 } 2518 }); 2519 }); 2520 that._interSectionObserver.observe(that._elements.self); 2521 2522 that.update(); 2523 } 2524 2525 function loadImage() { 2526 var hasWidths = (that._properties.widths && that._properties.widths.length > 0) || Object.keys(smartCrops).length > 0; 2527 var replacement; 2528 if (Object.keys(smartCrops).length > 0) { 2529 var optimalWidth = getOptimalWidth(Object.keys(smartCrops), false); 2530 replacement = smartCrops[optimalWidth]; 2531 } else { 2532 replacement = hasWidths ? (that._properties.dmimage ? "" : ".") + getOptimalWidth(that._properties.widths, true) : ""; 2533 } 2534 if (useAssetDelivery) { 2535 replacement = replacement !== "" ? ("width=" + replacement.substring(1)) : ""; 2536 } 2537 var url = that._properties.src.replace(srcUriTemplateWidthVar, replacement); 2538 url = url.replace(SRC_URI_TEMPLATE_DPR_VAR, devicePixelRatio); 2539 2540 var imgSrcAttribute = that._elements.image.getAttribute("src"); 2541 2542 if (url !== imgSrcAttribute) { 2543 if (imgSrcAttribute === null || imgSrcAttribute === EMPTY_PIXEL) { 2544 that._elements.image.setAttribute("src", url); 2545 } else { 2546 var urlTemplateParts = that._properties.src.split(srcUriTemplateWidthVar); 2547 // check if image src was dynamically swapped meanwhile (e.g. by Target) 2548 var isImageRefSame = imgSrcAttribute.startsWith(urlTemplateParts[0]); 2549 if (isImageRefSame && urlTemplateParts.length > 1) { 2550 isImageRefSame = imgSrcAttribute.endsWith(urlTemplateParts[urlTemplateParts.length - 1]); 2551 } 2552 if (isImageRefSame) { 2553 that._elements.image.setAttribute("src", url); 2554 if (!hasWidths) { 2555 window.removeEventListener("scroll", that.update); 2556 } 2557 } 2558 } 2559 } 2560 if (that._lazyLoaderShowing) { 2561 that._elements.image.addEventListener("load", removeLazyLoader); 2562 } 2563 that._interSectionObserver.unobserve(that._elements.self); 2564 } 2565 2566 function getOptimalWidth(widths, useDevicePixelRatio) { 2567 var container = that._elements.self; 2568 var containerWidth = container.clientWidth; 2569 while (containerWidth === 0 && container.parentNode) { 2570 container = container.parentNode; 2571 containerWidth = container.clientWidth; 2572 } 2573 2574 var dpr = useDevicePixelRatio ? devicePixelRatio : 1; 2575 var optimalWidth = containerWidth * dpr; 2576 var len = widths.length; 2577 var key = 0; 2578 2579 while ((key < len - 1) && (widths[key] < optimalWidth)) { 2580 key++; 2581 } 2582 2583 return widths[key].toString(); 2584 } 2585 2586 function addLazyLoader() { 2587 var width = that._elements.image.getAttribute("width"); 2588 var height = that._elements.image.getAttribute("height"); 2589 2590 if (width && height) { 2591 var ratio = (height / width) * 100; 2592 var styles = lazyLoader.style; 2593 2594 styles["padding-bottom"] = ratio + "%"; 2595 2596 for (var s in styles) { 2597 if (Object.prototype.hasOwnProperty.call(styles, s)) { 2598 that._elements.image.style[s] = styles[s]; 2599 } 2600 } 2601 } 2602 that._elements.image.setAttribute("src", EMPTY_PIXEL); 2603 that._elements.image.classList.add(lazyLoader.cssClass); 2604 that._lazyLoaderShowing = true; 2605 } 2606 2607 function unwrapNoScript() { 2608 var markup = decodeNoscript(that._elements.noscript.textContent.trim()); 2609 var parser = new DOMParser(); 2610 2611 // temporary document avoids requesting the image before removing its src 2612 var temporaryDocument = parser.parseFromString(markup, "text/html"); 2613 var imageElement = temporaryDocument.querySelector(selectors.image); 2614 imageElement.removeAttribute("src"); 2615 that._elements.container.insertBefore(imageElement, that._elements.noscript); 2616 2617 var mapElement = temporaryDocument.querySelector(selectors.map); 2618 if (mapElement) { 2619 that._elements.container.insertBefore(mapElement, that._elements.noscript); 2620 } 2621 2622 that._elements.noscript.parentNode.removeChild(that._elements.noscript); 2623 if (that._elements.container.matches(selectors.image)) { 2624 that._elements.image = that._elements.container; 2625 } else { 2626 that._elements.image = that._elements.container.querySelector(selectors.image); 2627 } 2628 2629 that._elements.map = that._elements.container.querySelector(selectors.map); 2630 that._elements.areas = that._elements.container.querySelectorAll(selectors.area); 2631 } 2632 2633 function removeLazyLoader() { 2634 that._elements.image.classList.remove(lazyLoader.cssClass); 2635 for (var property in lazyLoader.style) { 2636 if (Object.prototype.hasOwnProperty.call(lazyLoader.style, property)) { 2637 that._elements.image.style[property] = ""; 2638 } 2639 } 2640 that._elements.image.removeEventListener("load", removeLazyLoader); 2641 that._lazyLoaderShowing = false;
2642 } 2643 2644 function isLazyVisible() { 2645 if (that._elements.container.offsetParent === null) { 2646 return false; 2647 } 2648 2649 var wt = window.pageYOffset; 2650 var wb = wt + document.documentElement.clientHeight; 2651 var et = that._elements.container.getBoundingClientRect().top + wt; 2652 var eb = et + that._elements.container.clientHeight; 2653 2654 return eb >= wt - that._properties.lazythreshold && et <= wb + that._properties.lazythreshold; 2655 } 2656 2657 function resizeAreas() { 2658 if (that._elements.areas && that._elements.areas.length > 0) { 2659 for (var i = 0; i < that._elements.areas.length; i++) { 2660 var width = that._elements.image.width; 2661 var height = that._elements.image.height; 2662 2663 if (width && height) { 2664 var relcoords = that._elements.areas[i].dataset.cmpRelcoords; 2665 if (relcoords) { 2666 var relativeCoordinates = relcoords.split(","); 2667 var coordinates = new Array(relativeCoordinates.length); 2668 2669 for (var j = 0; j < coordinates.length; j++) { 2670 if (j % 2 === 0) { 2671 coordinates[j] = parseInt(relativeCoordinates[j] * width); 2672 } else { 2673 coordinates[j] = parseInt(relativeCoordinates[j] * height); 2674 } 2675 } 2676 2677 that._elements.areas[i].coords = coordinates; 2678 } 2679 } 2680 } 2681 } 2682 } 2683 2684 function cacheElements(wrapper) { 2685 that._elements = {}; 2686 that._elements.self = wrapper; 2687 var hooks = that._elements.self.querySelectorAll("[data-" + NS + "-hook-" + IS + "]"); 2688 2689 for (var i = 0; i < hooks.length; i++) { 2690 var hook = hooks[i]; 2691 var capitalized = IS; 2692 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 2693 var key = hook.dataset[NS + "Hook" + capitalized]; 2694 that._elements[key] = hook; 2695 } 2696 } 2697 2698 function onWindowResize() { 2699 that.update(); 2700 resizeAreas(); 2701 } 2702 2703 function onLoad() { 2704 resizeAreas(); 2705 } 2706 2707 that.update = function() { 2708 if (that._properties.lazy) { 2709 if (isLazyVisible()) { 2710 loadImage(); 2711 } 2712 } else { 2713 loadImage(); 2714 } 2715 }; 2716 2717 if (config && config.element) { 2718 init(config); 2719 } 2720 } 2721 2722 function onDocumentReady() { 2723 var elements = document.querySelectorAll(selectors.self); 2724 for (var i = 0; i < elements.length; i++) { 2725 new Image({ element: elements[i], options: CMP.utils.readData(elements[i], IS) }); 2726 } 2727 2728 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 2729 var body = document.querySelector("body"); 2730 var observer = new MutationObserver(function(mutations) { 2731 mutations.forEach(function(mutation) { 2732 // needed for IE 2733 var nodesArray = [].slice.call(mutation.addedNodes); 2734 if (nodesArray.length > 0) { 2735 nodesArray.forEach(function(addedNode) { 2736 if (addedNode.querySelectorAll) { 2737 var elementsArray = [].slice.call(addedNode.querySelectorAll(selectors.self)); 2738 elementsArray.forEach(function(element) { 2739 new Image({ element: element, options: CMP.utils.readData(element, IS) }); 2740 }); 2741 } 2742 }); 2743 } 2744 }); 2745 }); 2746 2747 observer.observe(body, { 2748 subtree: true, 2749 childList: true, 2750 characterData: true 2751 }); 2752 } 2753 2754 var documentReady = document.readyState !== "loading" ? Promise.resolve() : new Promise(function(resolve) { 2755 document.addEventListener("DOMContentLoaded", resolve); 2756 }); 2757 2758 Promise.all([documentReady]).then(onDocumentReady); 2759 /* 2760 on drag & drop of the component into a parsys, noscript's content will be escaped multiple times by the editor which creates 2761 the DOM for editing; the HTML parser cannot be used here due to the multiple escaping 2762 */ 2763 function decodeNoscript(text) { 2764 text = text.replace(/&(amp;)*lt;/g, "<"); 2765 text = text.replace(/&(amp;)*gt;/g, ">"); 2766 return text; 2767 } 2768 2769})(); 2770 2771/******************************************************************************* 2772 * Copyright 2017 Adobe 2773 * 2774 * Licensed under the Apache License, Version 2.0 (the "License");
2775 * you may not use this file except in compliance with the License. 2776 * You may obtain a copy of the License at 2777 * 2778 * http://www.apache.org/licenses/LICENSE-2.0 2779 * 2780 * Unless required by applicable law or agreed to in writing, software 2781 * distributed under the License is distributed on an "AS IS" BASIS, 2782 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2783 * See the License for the specific language governing permissions and 2784 * limitations under the License. 2785 ******************************************************************************/ 2786(function() { 2787 "use strict"; 2788 2789 var NS = "cmp"; 2790 var IS = "search"; 2791 2792 var DELAY = 300; // time before fetching new results when the user is typing a search string 2793 var LOADING_DISPLAY_DELAY = 300; // minimum time during which the loading indicator is displayed 2794 var PARAM_RESULTS_OFFSET = "resultsOffset"; 2795 2796 var keyCodes = { 2797 TAB: 9, 2798 ENTER: 13, 2799 ESCAPE: 27, 2800 ARROW_UP: 38, 2801 ARROW_DOWN: 40 2802 }; 2803 2804 var selectors = { 2805 self: "[data-" + NS + '-is="' + IS + '"]', 2806 item: { 2807 self: "[data-" + NS + "-hook-" + IS + '="item"]', 2808 title: "[data-" + NS + "-hook-" + IS + '="itemTitle"]', 2809 focused: "." + NS + "-search__item--is-focused" 2810 } 2811 }; 2812 2813 var properties = { 2814 /** 2815 * The minimum required length of the search term before results are fetched. 2816 * 2817 * @memberof Search 2818 * @type {Number} 2819 * @default 3 2820 */ 2821 minLength: { 2822 "default": 3, 2823 transform: function(value) { 2824 value = parseFloat(value); 2825 return isNaN(value) ? null : value; 2826 } 2827 }, 2828 /** 2829 * The maximal number of results fetched by a search request. 2830 * 2831 * @memberof Search 2832 * @type {Number} 2833 * @default 10 2834 */ 2835 resultsSize: { 2836 "default": 10, 2837 transform: function(value) { 2838 value = parseFloat(value); 2839 return isNaN(value) ? null : value; 2840 } 2841 } 2842 }; 2843 2844 var idCount = 0; 2845 2846 function readData(element) { 2847 var data = element.dataset; 2848 var options = []; 2849 var capitalized = IS; 2850 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 2851 var reserved = ["is", "hook" + capitalized]; 2852 2853 for (var key in data) { 2854 if (Object.prototype.hasOwnProperty.call(data, key)) { 2855 var value = data[key]; 2856 2857 if (key.indexOf(NS) === 0) { 2858 key = key.slice(NS.length); 2859 key = key.charAt(0).toLowerCase() + key.substring(1); 2860 2861 if (reserved.indexOf(key) === -1) { 2862 options[key] = value; 2863 } 2864 } 2865 } 2866 } 2867 2868 return options; 2869 } 2870 2871 function toggleShow(element, show) { 2872 if (element) { 2873 if (show !== false) { 2874 element.style.display = "block"; 2875 element.setAttribute("aria-hidden", false); 2876 } else { 2877 element.style.display = "none"; 2878 element.setAttribute("aria-hidden", true); 2879 } 2880 } 2881 } 2882 2883 function serialize(form) { 2884 var query = []; 2885 if (form && form.elements) { 2886 for (var i = 0; i < form.elements.length; i++) { 2887 var node = form.elements[i]; 2888 if (!node.disabled && node.name) { 2889 var param = [node.name, encodeURIComponent(node.value)]; 2890 query.push(param.join("=")); 2891 } 2892 } 2893 } 2894 return query.join("&"); 2895 } 2896 2897 function mark(node, regex) { 2898 if (!node || !regex) { 2899 return; 2900 } 2901 2902 // text nodes 2903 if (node.nodeType === 3) { 2904 var nodeValue = node.nodeValue; 2905 var match = regex.exec(nodeValue); 2906 2907 if (nodeValue && match) { 2908 var element = document.createElement("mark"); 2909 element.className = NS + "-search__item-mark"; 2910 element.appendChild(document.createTextNode(match[0])); 2911 2912 var after = node.splitText(match.index); 2913 after.nodeValue = after.nodeValue.substring(match[0].length); 2914 node.parentNode.insertBefore(element, after); 2915 } 2916 } else if (node.hasChildNodes()) { 2917 for (var i = 0; i < node.childNodes.length; i++) { 2918 // recurse 2919 mark(node.childNodes[i], regex); 2920 } 2921 } 2922 } 2923 2924 function Search(config) { 2925 if (config.element) { 2926 // prevents multiple initialization 2927 config.element.removeAttribute("data-" + NS + "-is"); 2928 } 2929 2930 this._cacheElements(config.element); 2931 this._setupProperties(config.options); 2932 2933 this._action = this._elements.form.getAttribute("action"); 2934 this._resultsOffset = 0; 2935 this._hasMoreResults = true; 2936 2937 this._elements.input.addEventListener("input", this._onInput.bind(this)); 2938 this._elements.input.addEventListener("focus", this._onInput.bind(this)); 2939 this._elements.input.addEventListener("keydown", this._onKeydown.bind(this)); 2940 this._elements.clear.addEventListener("click", this._onClearClick.bind(this)); 2941 document.addEventListener("click", this._onDocumentClick.bind(this)); 2942 this._elements.results.addEventListener("scroll", this._onScroll.bind(this)); 2943 2944 this._makeAccessible(); 2945 } 2946 2947 Search.prototype._displayResults = function() { 2948 if (this._elements.input.value.length === 0) { 2949 toggleShow(this._elements.clear, false); 2950 this._cancelResults(); 2951 } else if (this._elements.input.value.length < this._properties.minLength) { 2952 toggleShow(this._elements.clear, true); 2953 } else { 2954 this._updateResults(); 2955 toggleShow(this._elements.clear, true); 2956 } 2957 }; 2958 2959 Search.prototype._onScroll = function(event) { 2960 // fetch new results when the results to be scrolled down are less than the visible results 2961 if (this._elements.results.scrollTop + 2 * this._elements.results.clientHeight >= this._elements.results.scrollHeight) { 2962 this._resultsOffset += this._properties.resultsSize; 2963 this._displayResults(); 2964 } 2965 }; 2966 2967 Search.prototype._onInput = function(event) { 2968 var self = this; 2969 self._cancelResults(); 2970 // start searching when the search term reaches the minimum length 2971 this._timeout = setTimeout(function() { 2972 self._displayResults(); 2973 }, DELAY); 2974 }; 2975 2976 Search.prototype._onKeydown = function(event) { 2977 var self = this; 2978 2979 switch (event.keyCode) { 2980 case keyCodes.TAB: 2981 if (self._resultsOpen()) { 2982 toggleShow(self._elements.results, false); 2983 self._elements.input.setAttribute("aria-expanded", "false"); 2984 } 2985 break;
2986 case keyCodes.ENTER: 2987 event.preventDefault(); 2988 if (self._resultsOpen()) { 2989 var focused = self._elements.results.querySelector(selectors.item.focused); 2990 if (focused) { 2991 focused.click(); 2992 } 2993 } 2994 break; 2995 case keyCodes.ESCAPE: 2996 self._cancelResults(); 2997 break; 2998 case keyCodes.ARROW_UP: 2999 if (self._resultsOpen()) { 3000 event.preventDefault(); 3001 self._stepResultFocus(true); 3002 } 3003 break; 3004 case keyCodes.ARROW_DOWN: 3005 if (self._resultsOpen()) { 3006 event.preventDefault(); 3007 self._stepResultFocus(); 3008 } else { 3009 // test the input and if necessary fetch and display the results 3010 self._onInput(); 3011 } 3012 break; 3013 default: 3014 return; 3015 } 3016 }; 3017 3018 Search.prototype._onClearClick = function(event) { 3019 event.preventDefault(); 3020 this._elements.input.value = ""; 3021 toggleShow(this._elements.clear, false); 3022 toggleShow(this._elements.results, false); 3023 this._elements.input.setAttribute("aria-expanded", "false"); 3024 }; 3025 3026 Search.prototype._onDocumentClick = function(event) { 3027 var inputContainsTarget = this._elements.input.contains(event.target); 3028 var resultsContainTarget = this._elements.results.contains(event.target); 3029 3030 if (!(inputContainsTarget || resultsContainTarget)) { 3031 toggleShow(this._elements.results, false); 3032 this._elements.input.setAttribute("aria-expanded", "false"); 3033 } 3034 }; 3035 3036 Search.prototype._resultsOpen = function() { 3037 return this._elements.results.style.display !== "none"; 3038 }; 3039 3040 Search.prototype._makeAccessible = function() { 3041 var id = NS + "-search-results-" + idCount; 3042 this._elements.input.setAttribute("aria-owns", id); 3043 this._elements.results.id = id; 3044 idCount++; 3045 }; 3046 3047 Search.prototype._generateItems = function(data, results) { 3048 var self = this; 3049 3050 data.forEach(function(item) { 3051 var el = document.createElement("span"); 3052 el.innerHTML = self._elements.itemTemplate.innerHTML; 3053 el.querySelectorAll(selectors.item.title)[0].appendChild(document.createTextNode(item.title)); 3054 el.querySelectorAll(selectors.item.self)[0].setAttribute("href", self._safeHref(item.url)); 3055 results.innerHTML += el.innerHTML; 3056 }); 3057 }; 3058 3059 Search.prototype._safeHref = function(href) { 3060 var a = document.createElement("a"); 3061 a.href = href; 3062 return a.pathname; 3063 }; 3064 3065 Search.prototype._markResults = function() { 3066 var nodeList = this._elements.results.querySelectorAll(selectors.item.self); 3067 var escapedTerm = this._elements.input.value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); 3068 var regex = new RegExp("(" + escapedTerm + ")", "gi"); 3069 3070 for (var i = this._resultsOffset - 1; i < nodeList.length; ++i) { 3071 var result = nodeList[i]; 3072 mark(result, regex); 3073 } 3074 }; 3075 3076 Search.prototype._stepResultFocus = function(reverse) { 3077 var results = this._elements.results.querySelectorAll(selectors.item.self); 3078 var focused = this._elements.results.querySelector(selectors.item.focused); 3079 var newFocused; 3080 var index = Array.prototype.indexOf.call(results, focused); 3081 var focusedCssClass = NS + "-search__item--is-focused"; 3082 3083 if (results.length > 0) { 3084 3085 if (!reverse) { 3086 // highlight the next result 3087 if (index < 0) { 3088 results[0].classList.add(focusedCssClass); 3089 results[0].setAttribute("aria-selected", "true"); 3090 } else if (index + 1 < results.length) { 3091 results[index].classList.remove(focusedCssClass); 3092 results[index].setAttribute("aria-selected", "false"); 3093 results[index + 1].classList.add(focusedCssClass); 3094 results[index + 1].setAttribute("aria-selected", "true"); 3095 } 3096 3097 // if the last visible result is partially hidden, scroll up until it's completely visible 3098 newFocused = this._elements.results.querySelector(selectors.item.focused); 3099 if (newFocused) { 3100 var bottomHiddenHeight = newFocused.offsetTop + newFocused.offsetHeight - this._elements.results.scrollTop - this._elements.results.clientHeight; 3101 if (bottomHiddenHeight > 0) { 3102 this._elements.results.scrollTop += bottomHiddenHeight; 3103 } else { 3104 this._onScroll(); 3105 } 3106 } 3107 3108 } else { 3109 // highlight the previous result 3110 if (index >= 1) { 3111 results[index].classList.remove(focusedCssClass); 3112 results[index].setAttribute("aria-selected", "false"); 3113 results[index - 1].classList.add(focusedCssClass); 3114 results[index - 1].setAttribute("aria-selected", "true"); 3115 } 3116 3117 // if the first visible result is partially hidden, scroll down until it's completely visible 3118 newFocused = this._elements.results.querySelector(selectors.item.focused); 3119 if (newFocused) { 3120 var topHiddenHeight = this._elements.results.scrollTop - newFocused.offsetTop; 3121 if (topHiddenHeight > 0) { 3122 this._elements.results.scrollTop -= topHiddenHeight; 3123 } 3124 } 3125 } 3126 } 3127 }; 3128 3129 Search.prototype._updateResults = function() { 3130 var self = this; 3131 if (self._hasMoreResults) { 3132 var request = new XMLHttpRequest(); 3133 var url = self._action + "?" + serialize(self._elements.form) + "&" + PARAM_RESULTS_OFFSET + "=" + self._resultsOffset; 3134 3135 request.open("GET", url, true); 3136 request.onload = function() { 3137 // when the results are loaded: hide the loading indicator and display the search icon after a minimum period 3138 setTimeout(function() { 3139 toggleShow(self._elements.loadingIndicator, false); 3140 toggleShow(self._elements.icon, true); 3141 }, LOADING_DISPLAY_DELAY); 3142 if (request.status >= 200 && request.status < 400) { 3143 // success status 3144 var data = JSON.parse(request.responseText); 3145 if (data.length > 0) { 3146 self._generateItems(data, self._elements.results); 3147 self._markResults(); 3148 toggleShow(self._elements.results, true); 3149 self._elements.input.setAttribute("aria-expanded", "true"); 3150 } else { 3151 self._hasMoreResults = false;
3152 } 3153 // the total number of results is not a multiple of the fetched results: 3154 // -> we reached the end of the query 3155 if (self._elements.results.querySelectorAll(selectors.item.self).length % self._properties.resultsSize > 0) { 3156 self._hasMoreResults = false; 3157 } 3158 } else { 3159 // error status 3160 } 3161 }; 3162 // when the results are loading: display the loading indicator and hide the search icon 3163 toggleShow(self._elements.loadingIndicator, true); 3164 toggleShow(self._elements.icon, false); 3165 request.send(); 3166 } 3167 }; 3168 3169 Search.prototype._cancelResults = function() { 3170 clearTimeout(this._timeout); 3171 this._elements.results.scrollTop = 0; 3172 this._resultsOffset = 0; 3173 this._hasMoreResults = true; 3174 this._elements.results.innerHTML = ""; 3175 this._elements.input.setAttribute("aria-expanded", "false"); 3176 }; 3177 3178 Search.prototype._cacheElements = function(wrapper) { 3179 this._elements = {}; 3180 this._elements.self = wrapper; 3181 var hooks = this._elements.self.querySelectorAll("[data-" + NS + "-hook-" + IS + "]"); 3182 3183 for (var i = 0; i < hooks.length; i++) { 3184 var hook = hooks[i]; 3185 var capitalized = IS; 3186 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 3187 var key = hook.dataset[NS + "Hook" + capitalized]; 3188 this._elements[key] = hook; 3189 } 3190 }; 3191 3192 Search.prototype._setupProperties = function(options) { 3193 this._properties = {}; 3194 3195 for (var key in properties) { 3196 if (Object.prototype.hasOwnProperty.call(properties, key)) { 3197 var property = properties[key]; 3198 if (options && options[key] != null) { 3199 if (property && typeof property.transform === "function") { 3200 this._properties[key] = property.transform(options[key]); 3201 } else { 3202 this._properties[key] = options[key]; 3203 } 3204 } else { 3205 this._properties[key] = properties[key]["default"]; 3206 } 3207 } 3208 } 3209 }; 3210 3211 function onDocumentReady() { 3212 var elements = document.querySelectorAll(selectors.self); 3213 for (var i = 0; i < elements.length; i++) { 3214 new Search({ element: elements[i], options: readData(elements[i]) }); 3215 } 3216 3217 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 3218 var body = document.querySelector("body"); 3219 var observer = new MutationObserver(function(mutations) { 3220 mutations.forEach(function(mutation) { 3221 // needed for IE 3222 var nodesArray = [].slice.call(mutation.addedNodes); 3223 if (nodesArray.length > 0) { 3224 nodesArray.forEach(function(addedNode) { 3225 if (addedNode.querySelectorAll) { 3226 var elementsArray = [].slice.call(addedNode.querySelectorAll(selectors.self)); 3227 elementsArray.forEach(function(element) { 3228 new Search({ element: element, options: readData(element) }); 3229 }); 3230 } 3231 }); 3232 } 3233 }); 3234 }); 3235 3236 observer.observe(body, { 3237 subtree: true, 3238 childList: true, 3239 characterData: true 3240 }); 3241 } 3242 3243 if (document.readyState !== "loading") { 3244 onDocumentReady(); 3245 } else { 3246 document.addEventListener("DOMContentLoaded", onDocumentReady); 3247 } 3248 3249})(); 3250 3251/******************************************************************************* 3252 * Copyright 2016 Adobe 3253 * 3254 * Licensed under the Apache License, Version 2.0 (the "License"); 3255 * you may not use this file except in compliance with the License. 3256 * You may obtain a copy of the License at 3257 * 3258 * http://www.apache.org/licenses/LICENSE-2.0 3259 * 3260 * Unless required by applicable law or agreed to in writing, softw
3260are 3261 * distributed under the License is distributed on an "AS IS" BASIS, 3262 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3263 * See the License for the specific language governing permissions and 3264 * limitations under the License. 3265 ******************************************************************************/ 3266(function() { 3267 "use strict"; 3268 3269 var NS = "cmp"; 3270 var IS = "formText"; 3271 var IS_DASH = "form-text"; 3272 var SELF_SELECTOR = "[data-" + NS + '-is="' + IS + '"]'; 3273 3274 var selectors = { 3275 self: SELF_SELECTOR, 3276 validationMessage: SELF_SELECTOR + " .cmp-form-text__validation-message" 3277 }; 3278 3279 var displayValidationMessage = false; 3280 3281 var properties = { 3282 /** 3283 * A validation message to display if there is a type mismatch between the user input and expected input. 3284 * 3285 * @type {String} 3286 */ 3287 constraintMessage: "", 3288 /** 3289 * A validation message to display if no input is supplied, but input is expected for the field. 3290 * 3291 * @type {String} 3292 */ 3293 requiredMessage: "" 3294 }; 3295 3296 function readData(element) { 3297 var data = element.dataset; 3298 var options = []; 3299 var capitalized = IS; 3300 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 3301 var reserved = ["is", "hook" + capitalized]; 3302 3303 for (var key in data) { 3304 if (Object.prototype.hasOwnProperty.call(data, key)) { 3305 var value = data[key]; 3306 3307 if (key.indexOf(NS) === 0) { 3308 key = key.slice(NS.length); 3309 key = key.charAt(0).toLowerCase() + key.substring(1); 3310 3311 if (reserved.indexOf(key) === -1) { 3312 options[key] = value; 3313 } 3314 } 3315 } 3316 } 3317 3318 return options; 3319 } 3320 3321 function FormText(config) { 3322 if (config.element) { 3323 // prevents multiple initialization 3324 config.element.removeAttribute("data-" + NS + "-is"); 3325 } 3326 3327 this._cacheElements(config.element); 3328 this._setupProperties(config.options); 3329 3330 this._elements.input.addEventListener("invalid", this._onInvalid.bind(this)); 3331 this._elements.input.addEventListener("input", this._onInput.bind(this)); 3332 if (displayValidationMessage) { 3333 this._elements.input.checkValidity(); 3334 } 3335 } 3336 3337 FormText.prototype._onInvalid = function(event) { 3338 event.target.setCustomValidity(""); 3339 if (event.target.validity.typeMismatch) { 3340 if (this._properties.constraintMessage) { 3341 event.target.setCustomValidity(this._properties.constraintMessage); 3342 } 3343 } else if (event.target.validity.valueMissing) { 3344 if (this._properties.requiredMessage) { 3345 event.target.setCustomValidity(this._properties.requiredMessage); 3346 } 3347 } 3348 if (displayValidationMessage) { 3349 var validationMessage = event.target.parentElement.querySelector(".cmp-form-text__validation-message"); 3350 if (validationMessage) { 3351 validationMessage.innerText = event.target.validationMessage; 3352 } 3353 } 3354 }; 3355 3356 FormText.prototype._onInput = function(event) { 3357 event.target.setCustomValidity(""); 3358 if (displayValidationMessage) { 3359 event.target.checkValidity(); 3360 } 3361 }; 3362 3363 FormText.prototype._cacheElements = function(wrapper) { 3364 this._elements = {}; 3365 this._elements.self = wrapper; 3366 var hooks = this._elements.self.querySelectorAll("[data-" + NS + "-hook-" + IS_DASH + "]"); 3367 for (var i = 0; i < hooks.length; i++) { 3368 var hook = hooks[i]; 3369 var capitalized = IS; 3370 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 3371 var key = hook.dataset[NS + "Hook" + capitalized]; 3372 this._elements[key] = hook; 3373 } 3374 }; 3375 3376 FormText.prototype._setupProperties = function(options) { 3377 this._properties = {}; 3378 3379 for (var key in properties) { 3380 if (Object.prototype.hasOwnProperty.call(properties, key)) { 3381 var property = properties[key]; 3382 if (options && options[key] != null) { 3383 if (property && typeof property.transform === "function") { 3384 this._properties[key] = property.transform(options[key]); 3385 } else { 3386 this._properties[key] = options[key]; 3387 } 3388 } else { 3389 this._properties[key] = properties[key]["default"]; 3390 } 3391 } 3392 } 3393 }; 3394 3395 function onDocumentReady() {
3396 var validationMessages = document.querySelectorAll(selectors.validationMessage); 3397 if (validationMessages && validationMessages.length > 0) { 3398 displayValidationMessage = true; 3399 } 3400 3401 var elements = document.querySelectorAll(selectors.self); 3402 for (var i = 0; i < elements.length; i++) { 3403 new FormText({ element: elements[i], options: readData(elements[i]) }); 3404 } 3405 3406 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 3407 var body = document.querySelector("body"); 3408 var observer = new MutationObserver(function(mutations) { 3409 mutations.forEach(function(mutation) { 3410 // needed for IE 3411 var nodesArray = [].slice.call(mutation.addedNodes); 3412 if (nodesArray.length > 0) { 3413 nodesArray.forEach(function(addedNode) { 3414 if (addedNode.querySelectorAll) { 3415 var elementsArray = [].slice.call(addedNode.querySelectorAll(selectors.self)); 3416 elementsArray.forEach(function(element) { 3417 new FormText({ element: element, options: readData(element) }); 3418 }); 3419 } 3420 }); 3421 } 3422 }); 3423 }); 3424 3425 observer.observe(body, { 3426 subtree: true, 3427 childList: true, 3428 characterData: true 3429 }); 3430 } 3431 3432 if (document.readyState !== "loading") { 3433 onDocumentReady(); 3434 } else { 3435 document.addEventListener("DOMContentLoaded", onDocumentReady); 3436 } 3437 3438})(); 3439 3440/******************************************************************************* 3441 * Copyright 2020 Adobe 3442 * 3443 * Licensed under the Apache License, Version 2.0 (the "License"); 3444 * you may not use this file except in compliance with the License. 3445 * You may obtain a copy of the License at 3446 * 3447 * http://www.apache.org/licenses/LICENSE-2.0 3448 * 3449 * Unless required by applicable law or agreed to in writing, software 3450 * distributed under the License is distributed on an "AS IS" BASIS, 3451 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3452 * See the License for the specific language governing permissions and 3453 * limitations under the License. 3454 ******************************************************************************/ 3455(function() { 3456 "use strict"; 3457 3458 var NS = "cmp"; 3459 var IS = "pdfviewer"; 3460 var SDK_URL = "https://acrobatservices.adobe.com/view-sdk/viewer.js"; 3461 var SDK_READY_EVENT = "adobe_dc_view_sdk.ready"; 3462 3463 var selectors = { 3464 self: "[data-" + NS + '-is="' + IS + '"]', 3465 sdkScript: 'script[src="' + SDK_URL + '"]' 3466 }; 3467 3468 function initSDK() { 3469 var sdkIncluded = document.querySelectorAll(selectors.sdkScript).length > 0; 3470 if (!window.adobe_dc_view_sdk && !sdkIncluded) { 3471 var dcv = document.createElement("script"); 3472 dcv.type = "text/javascript"; 3473 dcv.src = SDK_URL; 3474 document.body.appendChild(dcv); 3475 } 3476 } 3477 3478 function previewPdf(component) { 3479 // prevents multiple initialization 3480 component.removeAttribute("data-" + NS + "-is"); 3481 3482 // add the view sdk to the page 3483 initSDK(); 3484 3485 // manage the preview 3486 if (component.dataset && component.id) { 3487 if (window.AdobeDC && window.AdobeDC.View) { 3488 dcView(component); 3489 } else { 3490 document.addEventListener(SDK_READY_EVENT, function() { 3491 dcView(component); 3492 }); 3493 } 3494 } 3495 } 3496 3497 function dcView(component) { 3498 var adobeDCView = new window.AdobeDC.View({ 3499 clientId: component.dataset.cmpClientId, 3500 divId: component.id + "-content", 3501 reportSuiteId: component.dataset.cmpReportSuiteId 3502 }); 3503 adobeDCView.previewFile({ 3504 content: { location: { url: component.dataset.cmpDocumentPath } }, 3505 metaData: { fileName: component.dataset.cmpDocumentFileName } 3506 }, JSON.parse(component.dataset.cmpViewerConfigJson)); 3507 } 3508 3509 /** 3510 * Document ready handler and DOM mutation observers. Initializes Accordion components as necessary. 3511 * 3512 * @private 3513 */ 3514 function onDocumentReady() { 3515 var elements = document.querySelectorAll(selectors.self); 3516 for (var i = 0; i < elements.length; i++) { 3517 previewPdf(elements[i]); 3518 } 3519 3520 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 3521 var body = document.querySelector("body"); 3522 var observer = new MutationObserver(function(mutations) { 3523 mutations.forEach(function(mutation) { 3524 // needed for IE 3525 var nodesArray = [].slice.call(mutation.addedNodes); 3526 if (nodesArray.length > 0) { 3527 nodesArray.forEach(function(addedNode) { 3528 if (addedNode.querySelectorAll) { 3529 var elementsArray = [].slice.call(addedNode.querySelectorAll(selectors.self)); 3530 elementsArray.forEach(function(element) { 3531 previewPdf(element); 3532 }); 3533 } 3534 }); 3535 } 3536 }); 3537 }); 3538 3539 observer.observe(body, { 3540 subtree: true, 3541 childList: true, 3542 characterData: true 3543 }); 3544 3545 } 3546 3547 if (document.readyState !== "loading") { 3548 onDocumentReady(); 3549 } else { 3550 document.addEventListener("DOMContentLoaded", onDocumentReady); 3551 } 3552}()); 3553 3554/******************************************************************************* 3555 * Copyright 2020 Adobe 3556 * 3557 * Licensed under the Apache License, Version 2.0 (the "License");
3558 * you may not use this file except in compliance with the License. 3559 * You may obtain a copy of the License at 3560 * 3561 * http://www.apache.org/licenses/LICENSE2.0 3562 * 3563 * Unless required by applicable law or agreed to in writing, software 3564 * distributed under the License is distributed on an "AS IS" BASIS, 3565 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3566 * See the License for the specific language governing permissions and 3567 * limitations under the License. 3568 ******************************************************************************/ 3569 3570/** 3571 * Element.matches() 3572 * https://developer.mozilla.org/enUS/docs/Web/API/Element/matches#Polyfill 3573 */ 3574if (!Element.prototype.matches) { 3575 Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; 3576} 3577 3578// eslint-disable-next-line valid-jsdoc 3579/** 3580 * Element.closest() 3581 * https://developer.mozilla.org/enUS/docs/Web/API/Element/closest#Polyfill 3582 */ 3583if (!Element.prototype.closest) { 3584 Element.prototype.closest = function(s) { 3585 "use strict"; 3586 var el = this; 3587 if (!document.documentElement.contains(el)) { 3588 return null; 3589 } 3590 do { 3591 if (el.matches(s)) { 3592 return el; 3593 } 3594 el = el.parentElement || el.parentNode; 3595 } while (el !== null && el.nodeType === 1); 3596 return null; 3597 }; 3598} 3599 3600// https://tc39.github.io/ecma262/#sec-array.prototype.find 3601if (!Array.prototype.find) { 3602 Object.defineProperty(Array.prototype, "find", { 3603 value: function(predicate) { 3604 "use strict"; 3605 // 1. Let O be ? ToObject(this value). 3606 if (this == null) { 3607 throw TypeError('"this" is null or not defined'); 3608 } 3609 3610 var o = Object(this); 3611 3612 // 2. Let len be ? ToLength(? Get(O, "length")). 3613 var len = o.length >>> 0; 3614 3615 // 3. If IsCallable(predicate) is false, throw a TypeError exception. 3616 if (typeof predicate !== "function") { 3617 throw TypeError("predicate must be a function"); 3618 } 3619 3620 // 4. If thisArg was supplied, let T be thisArg; else let T be undefined. 3621 var thisArg = arguments[1]; 3622 3623 // 5. Let k be 0. 3624 var k = 0; 3625 3626 // 6. Repeat, while k < len 3627 while (k < len) { 3628 // a. Let Pk be ! ToString(k). 3629 // b. Let kValue be ? Get(O, Pk). 3630 // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). 3631 // d. If testResult is true, return kValue. 3632 var kValue = o[k]; 3633 if (predicate.call(thisArg, kValue, k, o)) { 3634 return kValue; 3635 } 3636 // e. Increase k by 1. 3637 k++; 3638 } 3639 3640 // 7. Return undefined. 3641 return undefined; 3642 }, 3643 configurable: true, 3644 writable: true 3645 }); 3646} 3647 3648"use strict";function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var n=[],r=!0,o=!1,a=void 0;try{for(var i,u=t[Symbol.iterator]();!(r=(i=u.next()).done)&&(n.push(i.value),!e||n.length!==e);r=!0);}catch(t){o=!0,a=t}finally{try{r||null==u.return||u.return()}finally{if(o)throw a}}return n}}function _arrayWithHoles(t){if(Array.isArray(t))return t}function _createForOfIteratorHelper(t){if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(t=_unsupportedIterableToArray(t))){var e=0,n=function(){};return{s:n,n:function(){return e>=t.length?{done:!0}:{done:!1,value:t[e++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o,a=!0,i=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return a=t.done,t},e:function(t){i=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(i)throw o}}}}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}!function a(i,u,c){function f(e,t){if(!u[e]){if(!i[e]){var n="function"==typeof require&&require;if(!t&&n)return n(e,!0);if(s)return s(e,!0);var r=new Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r}var o=u[e]={exports:{}};i[e][0].call(o.exports,function(t){return f(i[e][1][t]||t)},o,o.exports,a,i,u,c)}return u[e].exports}for(var s="function"==typeof require&&require,t=0;t<c.length;t++)f(c[t]);return f}({1:[function(t,wn,En){(function(On){(function(){function n(t,e){for(var n=-1,r=null==t?0:t.length,o=0,a=[];++n<r;){var i=t[n];e(i,n,t)&&(a[o++]=i)}return a}function a(t,e){for(var n=-1,r=null==t?0:t.length,o=Array(r);++n<r;)o[n]=e(t[n],n,t);return o}function f(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}function b(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}function o(t,e,n){var r=t.length;for(n+=-1;++n<r;)if(e(t[n],n,t))return n;return-1}function i(t){return t!=t}function t(e){return function(t){return e(t)}}function h(t){var n=-1,r=Array(t.size);return t.forEach(function(t,e){r[++n]=[e,t]}),r}function e(e){var n=Object;return function(t){return e(n(t))}}function v(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}function r(){}function u(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function c(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function s(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function d(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new s;++e<n;)this.add(t[e])}function g(t){this.size=(this.__data__=new c(t)).size}function l(t,e){var n=hn(t),r=!n&&bn(t),o=!n&&!r&&vn(t),a=!n&&!r&&!o&&_n(t);if(n=n||r||o||a){r=t.length;for(var i=String,u=-1,c=Array(r);++u<r;)c[u]=i(u);r=c}else r=[];var f;i=r.length;for(f in t)!e&&!be.call(t,f)||n&&("length"==f||o&&("offset"==f||"parent"==f)||a&&("buffer"==f||"byteLength"==f||"byteOffset"==f)||Q(f,i))||r.push(f);return r}function _(t,e,n){(n===Mt||ft(t[e],n))&&(n!==Mt||e in t)||j(t,e,n)}function y(t,e,n){var r=t[e];be.call(t,e)&&ft(r,n)&&(n!==Mt||e in t)||j(t,e,n)}function p(t,e){for(var n=t.length;n--;)if(ft(t[n][0],e))return n;return-1}function j(t,e,n){"__proto__"==e&&xe?xe(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}function m(n,r,o,t,e,a){var i,u=1&r,c=2&r,f=4&r;
3648if(o&&(i=e?o(n,t,e,a):o(n)),i!==Mt)return i;if(!bt(n))return n;if(t=hn(n)){if(i=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&be.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(n),!u)return U(n,i)}else{var s=nn(n),l="[object Function]"==s||"[object GeneratorFunction]"==s;if(vn(n))return M(n,u);if("[object Object]"==s||"[object Arguments]"==s||l&&!e){if(i=c||l?{}:Y(n),!u)return c?function(t,e){return P(t,en(t),e)}(n,function(t,e){return t&&P(e,St(e),t)}(i,n)):function(t,e){return P(t,tn(t),e)}(n,function(t,e){return t&&P(e,Lt(e),t)}(i,n))}else{if(!Kt[s])return e?n:{};i=function(t,e,n){var r=t.constructor;switch(e){case"[object ArrayBuffer]":return z(t);case"[object Boolean]":case"[object Date]":return new r(+t);case"[object DataView]":return e=n?z(t.buffer):t.buffer,new t.constructor(e,t.byteOffset,t.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return C(t,n);case"[object Map]":return new r;case"[object Number]":case"[object String]":return new r(t);case"[object RegExp]":return(e=new t.constructor(t.source,Ht.exec(t))).lastIndex=t.lastIndex,e;case"[object Set]":return new r;case"[object Symbol]":return qe?Object(qe.call(t)):{}}}(n,s,u)}}if(e=(a=a||new g).get(n))return e;if(a.set(n,i),gn(n))return n.forEach(function(t){i.add(m(t,r,o,t,n,a))}),i;if(dn(n))return n.forEach(function(t,e){i.set(e,m(t,r,o,e,n,a))}),i;c=f?c?B:H:c?St:Lt;var p=t?Mt:c(n);return function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););}(p||n,function(t,e){p&&(t=n[e=t]),y(i,e,m(t,r,o,e,n,a))}),i}function A(t,e){for(var n=0,r=(e=F(e,t)).length;null!=t&&n<r;)t=t[nt(e[n++])];return n&&n==r?t:Mt}function O(t,e,n){return e=e(t),hn(t)?e:f(e,n(t))}function w(t){if(null==t)t=t===Mt?"[object Undefined]":"[object Null]";else if(Te&&Te in Object(t)){var e=be.call(t,Te),n=t[Te];try{t[Te]=Mt;var r=!0}catch(t){}var o=ve.call(t);r&&(e?t[Te]=n:delete t[Te]),t=o}else t=ve.call(t);return t}function E(t,e){return null!=t&&be.call(t,e)}function L(t,e){return null!=t&&e in Object(t)}function S(t){return ht(t)&&"[object Arguments]"==w(t)}function T(t,e,n,r,o){if(t===e)e=!0;else if(null==t||null==e||!ht(t)&&!ht(e))e=t!=t&&e!=e;else t:{var a,i,u=hn(t),c=hn(e),f="[object Object]"==(a="[object Arguments]"==(a=u?"[object Array]":nn(t))?"[object Object]":a);c="[object Object]"==(i="[object Arguments]"==(i=c?"[object Array]":nn(e))?"[object Object]":i);if((i=a==i)&&vn(t)){if(!vn(e)){e=!1;break t}f=!(u=!0)}if(i&&!f)o=o||new g,e=u||_n(t)?V(t,e,n,r,T,o):function(t,e,n,r,o,a,i){switch(n){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)break;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":if(t.byteLength!=e.byteLength||!a(new me(t),new me(e)))break;return!0;case"[object Boolean]":case"[object Date]":case"[object Number]":return ft(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var u=h;case"[object Set]":if(u=u||v,t.size!=e.size&&!(1&r))break;return(n=i.get(t))?n==e:(r|=2,i.set(t,e),e=V(u(t),u(e),r,o,a,i),i.delete(t),e);case"[object Symbol]":if(qe)return qe.call(t)==qe.call(e)}return!1}(t,e,a,n,r,T,o);else{if(!(1&n)&&(u=f&&be.call(t,"__wrapped__"),a=c&&be.call(e,"__wrapped__"),u||a)){e=T(t=u?t.value():t,e=a?e.value():e,n,r,o=o||new g);break t}if(i)e:if(o=o||new g,u=1&n,a=H(t),c=a.length,i=H(e).length,c==i||u){for(f=c;f--;){var s=a[f];if(!(u?s in e:be.call(e,s))){e=!1;break e}}if((i=o.get(t))&&o.get(e))e=i==e;else{i=!0,o.set(t,e),o.set(e,t);for(var l=u;++f<c;){var p=t[s=a[f]],y=e[s];if(r)var b=u?r(y,p,s,e,t,o):r(p,y,s,t,e,o);if(b===Mt?p!==y&&!T(p,y,n,r,o):!b){i=!1;break}l=l||"constructor"==s}i&&!l&&((n=t.constructor)!=(r=e.constructor)&&"constructor"in t&&"constructor"in e&&!("function"==typeof n&&n instanceof n&&"function"==typeof r&&r instanceof r)&&(i=!1)),o.delete(t),o.delete(e),e=i}}else e=!1;else e=!1}}return e}function x(t){return"function"==typeof t?t:null==t?It:"object"==_typeof(t)?hn(t)?function(n,r){return X(n)&&r==r&&!bt(r)?tt(nt(n),r):function(t){var e=wt(t,n);return e===Mt&&e===r?Et(t,n):T(r,e,3)}}(t[0],t[1]):function(e){var n=function(t){for(var e=Lt(t),n=e.length;n--;){var r=e[n],o=t[r];e[n]=[r,o,o==o&&!bt(o)]}return e}(e);return 1==n.length&&n[0][2]?tt(n[0][0],n[0][1]):function(t){return t===e||function(t,e){var n=e.length,r=n;if(null==t)return!r;for(t=Object(t);n--;){if((o=e[n])[2]?o[1]!==t[o[0]]:!(o[0]in t))return!1}for(;++n<r;
3648){var o,a=(o=e[n])[0],i=t[a],u=o[1];if(o[2]){if(i===Mt&&!(a in t))return!1}else if(o=new g,void 0!==Mt||!T(u,i,3,void 0,o))return!1}return!0}(t,n)}}(t):Nt(t)}function I(t){if(!Z(t))return Ne(t);var e,n=[];for(e in Object(t))be.call(t,e)&&"constructor"!=e&&n.push(e);return n}function k(s,l,p,y,b){s!==l&&Xe(l,function(t,e){if(bt(t)){var n=b=b||new g,r="__proto__"==e?Mt:s[e],o="__proto__"==e?Mt:l[e];if(f=n.get(o))_(s,e,f);else{var a=(f=y?y(r,o,e+"",s,l,n):Mt)===Mt;if(a){var i=hn(o),u=!i&&vn(o),c=!i&&!u&&_n(o),f=o;i||u||c?f=hn(r)?r:lt(r)?U(r):u?M(o,!(a=!1)):c?C(o,!(a=!1)):[]:vt(o)||bn(o)?bn(f=r)?f=At(r):(!bt(r)||p&&pt(r))&&(f=Y(o)):a=!1}a&&(n.set(o,f),k(f,o,p,y,n),n.delete(o)),_(s,e,f)}}else(n=y?y("__proto__"==e?Mt:s[e],t,e+"",s,l,b):Mt)===Mt&&(n=t),_(s,e,n)},St)}function N(t){if("string"==typeof t)return t;if(hn(t))return a(t,N)+"";if(gt(t))return Je?Je.call(t):"";var e=t+"";return"0"==e&&1/t==-zt?"-0":e}function D(t,e){var n;if((e=F(e,t)).length<2)n=t;else{var r=0,o=-1,a=-1,i=(n=e).length;for(r<0&&(r=i<-r?0:i+r),(o=i<o?i:o)<0&&(o+=i),i=o<r?0:o-r>>>0,r>>>=0,o=Array(i);++a<i;)o[a]=n[a+r];n=A(t,o)}null==(t=n)||delete t[nt(it(e))]}function F(t,e){return hn(t)?t:X(t,e)?[t]:ln(Ot(t))}function M(t,e){if(e)return t.slice();var n=t.length;n=Ae?Ae(n):new t.constructor(n);return t.copy(n),n}function z(t){var e=new t.constructor(t.byteLength);return new me(e).set(new me(t)),e}function C(t,e){return new t.constructor(e?z(t.buffer):t.buffer,t.byteOffset,t.length)}function U(t,e){var n=-1,r=t.length;for(e=e||Array(r);++n<r;)e[n]=t[n];return e}function P(t,e,n){var r=!n;n=n||{};for(var o=-1,a=e.length;++o<a;){var i=e[o],u=Mt;u===Mt&&(u=t[i]),r?j(n,i,u):y(n,i,u)}return n}function R(f){return function(t){return sn(et(t,void 0,It),t+"")}(function(t,e){var n,r=-1,o=e.length,a=1<o?e[o-1]:Mt,i=2<o?e[2]:Mt;a=3<f.length&&"function"==typeof a?(o--,a):Mt;if(n=i){n=e[0];var u=e[1];if(bt(i)){var c=_typeof(u);n=!!("number"==c?st(i)&&Q(u,i.length):"string"==c&&u in i)&&ft(i[u],n)}else n=!1}for(n&&(a=o<3?Mt:a,o=1),t=Object(t);++r<o;)(i=e[r])&&f(t,i,r,a);return t})}function $(t){return vt(t)?Mt:t}function V(t,e,n,r,o,a){var i=1&n,u=t.length;if(u!=(c=e.length)&&!(i&&u<c))return!1;if((c=a.get(t))&&a.get(e))return c==e;var c=-1,f=!0,s=2&n?new d:Mt;for(a.set(t,e),a.set(e,t);++c<u;){var l=t[c],p=e[c];if(r)var y=i?r(p,l,c,e,t,a):r(l,p,c,t,e,a);if(y!==Mt){if(y)continue;f=!1;break}if(s){if(!b(e,function(t,e){if(!s.has(e)&&(l===t||o(l,t,n,r,a)))return s.push(e)})){f=!1;break}}else if(l!==p&&!o(l,p,n,r,a)){f=!1;break}}return a.delete(t),a.delete(e),f}function H(t){return O(t,Lt,tn)}function B(t){return O(t,St,en)}function W(t,e){var n=(n=r.iteratee||kt)===kt?x:n;return arguments.length?n(t,e):n}function G(t,e){var n=t.__data__,r=_typeof(e);return("string"==r||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==e:null===e)?n["string"==typeof e?"string":"hash"]:n.map}function q(t,e){var n=null==t?Mt:t[e];return!bt(n)||he&&he in n||!(pt(n)?ge:Gt).test(rt(n))?Mt:n}function J(t,e,n){for(var r=-1,o=(e=F(e,t)).length,a=!1;++r<o;){var i=nt(e[r]);if(!(a=null!=t&&n(t,i)))break;t=t[i]}return a||++r!=o?a:!!(o=null==t?0:t.length)&&yt(o)&&Q(i,o)&&(hn(t)||bn(t))}function Y(t){return"function"!=typeof t.constructor||Z(t)?{}:Ye(Oe(t))}function K(t){return hn(t)||bn(t)||!!(Se&&t&&t[Se])}function Q(t,e){var n=_typeof(t);return!!(e=null==e?9007199254740991:e)&&("number"==n||"symbol"!=n&&Jt.test(t))&&-1<t&&0==t%1&&t<e}function X(t,e){if(hn(t))return!1;var n=_typeof(t);return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!gt(t))||Pt.test(t)||!Ut.test(t)||null!=e&&t in Object(e)}function Z(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||le)}function tt(e,n){return function(t){return null!=t&&t[e]===n&&(n!==Mt||e in Object(t))}}function et(o,a,i){return a=De(a===Mt?o.length-1:a,0),function(){for(var t=arguments,e=-1,n=De(t.length-a,0),r=Array(n);++e<n;)r[e]=t[a+e];for(e=-1,n=Array(a+1);++e<a;)n[e]=t[e];return n[a]=i(r),function(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}(o,this,n)}}function nt(t){if("string"==typeof t||gt(t))return t;var e=t+"";return"0"==e&&1/t==-zt?"-0":e}function rt(t){if(null==t)return"";try{return ye.call(t)}catch(t){}return t+""}function ot(t,e,n){var r=null==t?0:t.length;return r?((n=null==n?0:jt(n))<0&&(n=De(r+n,0)),o(t,W(e,3),n)):-1}function at(t){return null!=t&&t.length?function t(e,n,r,o,a){var i=-1,u=e.length;for(r=r||K,a=a||[];++i<u;){var c=e[i];0<n&&r(c)?1<n?t(c,n-1,r,o,a):f(a,c):o||(a[a.length]=c)}return a}(t,1):[]}function it(t){var e=null==t?0:t.length;return e?t[e-1]:Mt}function ut(r,o){function a(){var t=arguments,e=o?o.apply(this,t):t[0],n=a.cache;return n.has(e)?n.get(e):(t=r.apply(this,t),a.cache=n.set(e,t)||n,t)}if("function"!=typeof r||null!=o&&"function"!=typeof o)throw new TypeError("Expected a function");return a.cache=new(ut.Cache||s),a}function ct(e){if("function"!=typeof e)throw new TypeError("Expected a function");return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}function ft(t,e){return t===e||t!=t&&e!=e}function st(t){return null!=t&&yt(t.length)&&!pt(t)}function lt(t){return ht(t)&&st(t)}function pt(t){return!!bt(t)&&("[object Function]"==(t=w(t))||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t)}function yt(t){return"number"==typeof t&&-1<t&&0==t%1&&t<=9007199254740991}function bt(t){var e=_typeof(t);return null!=t&&("object"==e||"function"==e)}function ht(t){return null!=t&&"object"==_typeof(t)}function vt(t){return!(!ht(t)||"[object Object]"!=w(t))&&(null===(t=Oe(t))||"function"==typeof(t=be.call(t,"constructor")&&t.constructor)&&t instanceof t&&ye.call(t)==de)}function dt(t){return"string"==typeof t||!hn(t)&&ht(t)&&"[object String]"==w(t)}function gt(t){return"symbol"==_typeof(t)||ht(t)&&"[object Symbol]"==w(t)}function _t(t){return t?(t=mt(t))===zt||t===-zt?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function jt(t){var e=(t=_t(t))%1;return t==t?e?t-e:t:0}function mt(t){if("number"==typeof t)return t;if(gt(t))return Ct;if(bt(t)&&(t=bt(t="function"==typeof t.valueOf?t.valueOf():t)?t+"":t),"string"!=typeof t)return 0===t?t:+t;t=t.replace($t,"");var e=Wt.test(t);return e||qt.test(t)?Xt(t.slice(2),e?2:8):Bt.test(t)?Ct:+t}function At(t){return P(t,St(t))}function Ot(t){return null==t?"":N(t)}function wt(t,e,n){return(t=null==t?Mt:A(t,e))===Mt?n:t}function Et(t,e){return null!=t&&J(t,e,L)}function Lt(t){return st(t)?l(t):I(t)}function St(t){if(st(t))t=l(t,!0);else if(bt(t)){var e,n=Z(t),r=[];for(e in t)("constructor"!=e||!n&&be.call(t,e))&&r.push(e);t=r}else{if(e=[],null!=t)for(n in Object(t))e.push(n);t=e}return t}function Tt(t){return null==t?[]:function(e,t){return a(t,function(t){return e[t]})}(t,Lt(t))}function xt(t){return function(){return t}}function It(t){return t}function kt(t){return x("function"==typeof t?t:m(t,1))}function Nt(t){return X(t)?function(e){return function(t){return null==t?Mt:t[e]}}(nt(t)):function(e){return function(t){return A(t,e)}}(t)}function Dt(){return[]}function Ft(){return!1}var Mt,zt=1/0,Ct=NaN,Ut=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Pt=/^\w*$/,Rt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,$t=/^\s+|\s+$/g,Vt=/\\(\\)?/g,Ht=/\w*$/,Bt=/^[-+]0x[0-9a-f]+$/i,Wt=/^0b[01]+$/i,Gt=/^\[object .+?Constructor\]$/,qt=/^0o[0-7]+$/i,Jt=/^(?:0|[1-9]\d*)$/,Yt={};
3648Yt["[object Float32Array]"]=Yt["[object Float64Array]"]=Yt["[object Int8Array]"]=Yt["[object Int16Array]"]=Yt["[object Int32Array]"]=Yt["[object Uint8Array]"]=Yt["[object Uint8ClampedArray]"]=Yt["[object Uint16Array]"]=Yt["[object Uint32Array]"]=!0,Yt["[object Arguments]"]=Yt["[object Array]"]=Yt["[object ArrayBuffer]"]=Yt["[object Boolean]"]=Yt["[object DataView]"]=Yt["[object Date]"]=Yt["[object Error]"]=Yt["[object Function]"]=Yt["[object Map]"]=Yt["[object Number]"]=Yt["[object Object]"]=Yt["[object RegExp]"]=Yt["[object Set]"]=Yt["[object String]"]=Yt["[object WeakMap]"]=!1;var Kt={};Kt["[object Arguments]"]=Kt["[object Array]"]=Kt["[object ArrayBuffer]"]=Kt["[object DataView]"]=Kt["[object Boolean]"]=Kt["[object Date]"]=Kt["[object Float32Array]"]=Kt["[object Float64Array]"]=Kt["[object Int8Array]"]=Kt["[object Int16Array]"]=Kt["[object Int32Array]"]=Kt["[object Map]"]=Kt["[object Number]"]=Kt["[object Object]"]=Kt["[object RegExp]"]=Kt["[object Set]"]=Kt["[object String]"]=Kt["[object Symbol]"]=Kt["[object Uint8Array]"]=Kt["[object Uint8ClampedArray]"]=Kt["[object Uint16Array]"]=Kt["[object Uint32Array]"]=!0,Kt["[object Error]"]=Kt["[object Function]"]=Kt["[object WeakMap]"]=!1;var Qt,Xt=parseInt,Zt="object"==_typeof(On)&&On&&On.Object===Object&&On,te="object"==("undefined"==typeof self?"undefined":_typeof(self))&&self&&self.Object===Object&&self,ee=Zt||te||Function("return this")(),ne="object"==_typeof(En)&&En&&!En.nodeType&&En,re=ne&&"object"==_typeof(wn)&&wn&&!wn.nodeType&&wn,oe=re&&re.exports===ne,ae=oe&&Zt.process;t:{try{Qt=ae&&ae.binding&&ae.binding("util");break t}catch(t){}Qt=void 0}var ie,ue=Qt&&Qt.isMap,ce=Qt&&Qt.isSet,fe=Qt&&Qt.isTypedArray,se=Array.prototype,le=Object.prototype,pe=ee["__core-js_shared__"],ye=Function.prototype.toString,be=le.hasOwnProperty,he=(ie=/[^.]+$/.exec(pe&&pe.keys&&pe.keys.IE_PROTO||""))?"Symbol(src)_1."+ie:"",ve=le.toString,de=ye.call(Object),ge=RegExp("^"+ye.call(be).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),_e=oe?ee.Buffer:Mt,je=ee.Symbol,me=ee.Uint8Array,Ae=_e?_e.a:Mt,Oe=e(Object.getPrototypeOf),we=Object.create,Ee=le.propertyIsEnumerable,Le=se.splice,Se=je?je.isConcatSpreadable:Mt,Te=je?je.toStringTag:Mt,xe=function(){try{var t=q(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),Ie=Object.getOwnPropertySymbols,ke=_e?_e.isBuffer:Mt,Ne=e(Object.keys),De=Math.max,Fe=Date.now,Me=q(ee,"DataView"),ze=q(ee,"Map"),Ce=q(ee,"Promise"),Ue=q(ee,"Set"),Pe=q(ee,"WeakMap"),Re=q(Object,"create"),$e=rt(Me),Ve=rt(ze),He=rt(Ce),Be=rt(Ue),We=rt(Pe),Ge=je?je.prototype:Mt,qe=Ge?Ge.valueOf:Mt,Je=Ge?Ge.toString:Mt,Ye=function(t){return bt(t)?we?we(t):(Ke.prototype=t,t=new Ke,Ke.prototype=Mt,t):{}};function Ke(){}u.prototype.clear=function(){this.__data__=Re?Re(null):{},this.size=0},u.prototype.delete=function(t){return t=this.has(t)&&delete this.__data__[t],this.size-=t?1:0,t},u.prototype.get=function(t){var e=this.__data__;return Re?"__lodash_hash_undefined__"===(t=e[t])?Mt:t:be.call(e,t)?e[t]:Mt},u.prototype.has=function(t){var e=this.__data__;return Re?e[t]!==Mt:be.call(e,t)},u.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=Re&&e===Mt?"__lodash_hash_undefined__":e,this},c.prototype.clear=function(){this.__data__=[],this.size=0},c.prototype.delete=function(t){var e=this.__data__;return!((t=p(e,t))<0||(t==e.length-1?e.pop():Le.call(e,t,1),--this.size,0))},c.prototype.get=function(t){var e=this.__data__;return(t=p(e,t))<0?Mt:e[t][1]},c.prototype.has=function(t){return-1<p(this.__data__,t)},c.prototype.set=function(t,e){var n=this.__data__,r=p(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},s.prototype.clear=function(){this.size=0,this.__data__={hash:new u,map:new(ze||c),string:new u}},s.prototype.delete=function(t){return t=G(this,t).delete(t),this.size-=t?1:0,t},s.prototype.get=function(t){return G(this,t).get(t)},s.prototype.has=function(t){return G(this,t).has(t)},s.prototype.set=function(t,e){var n=G(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},d.prototype.add=d.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},d.prototype.has=function(t){return this.__data__.has(t)},g.prototype.clear=function(){this.__data__=new c,this.size=0},g.prototype.delete=function(t){var e=this.__data__;return t=e.delete(t),this.size=e.size,t},g.prototype.get=function(t){return this.__data__.get(t)},g.prototype.has=function(t){return this.__data__.has(t)},g.prototype.set=function(t,e){var n=this.__data__;if(n instanceof c){var r=n.__data__;if(!ze||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new s(r)}return n.set(t,e),this.size=n.size,this};var Qe=function(t,e){if(null==t)return t;if(!st(t))return function(t,e){return t&&Xe(t,e,Lt)}(t,e);for(var n=t.length,r=-1,o=Object(t);++r<n&&!1!==e(o[r],r,o););return t},Xe=function(t,e,n){for(var r=-1,o=Object(t),a=(n=n(t)).length;a--;){var i=n[++r];if(!1===e(o[i],i,o))break}return t},Ze=xe?function(t,e){return xe(t,"toString",{configurable:!0,enumerable:!1,value:xt(e),writable:!0})}:It,tn=Ie?function(e){return null==e?[]:(e=Object(e),n(Ie(e),function(t){return Ee.call(e,t)}))}:Dt,en=Ie?function(t){for(var e=[];t;)f(e,tn(t)),t=Oe(t);return e}:Dt,nn=w;(Me&&"[object DataView]"!=nn(new Me(new ArrayBuffer(1)))||ze&&"[object Map]"!=nn(new ze)||Ce&&"[object Promise]"!=nn(Ce.resolve())||Ue&&"[object Set]"!=nn(new Ue)||Pe&&"[object WeakMap]"!=nn(new Pe))&&(nn=function(t){var e=w(t);if(t=(t="[object Object]"==e?t.constructor:Mt)?rt(t):"")switch(t){case $e:return"[object DataView]";case Ve:return"[object Map]";case He:return"[object Promise]";case Be:return"[object Set]";case We:return"[object WeakMap]"}return e});var rn,on,an,un,cn,fn,sn=(un=Ze,fn=cn=0,function(){var t=Fe(),e=16-(t-fn);if(fn=t,0<e){if(800<=++cn)return arguments[0]}else cn=0;return un.apply(Mt,arguments)}),ln=(an=(on=ut(on=function(t){var o=[];return 46===t.charCodeAt(0)&&o.push(""),t.replace(Rt,function(t,e,n,r){o.push(n?r.replace(Vt,"$1"):e||t)}),o},function(t){return 500===an.size&&an.clear(),t})).cache,on),pn=(rn=ot,function(t,e,n){var r=Object(t);if(!st(t)){var o=W(e,3);t=Lt(t),e=function(t){return o(r[t],t,r)}}return-1<(e=rn(t,e,n))?r[o?t[e]:e]:Mt});ut.Cache=s;var yn,bn=S(function(){return arguments}())?S:function(t){return ht(t)&&be.call(t,"callee")&&!Ee.call(t,"callee")},hn=Array.isArray,vn=ke||Ft,dn=ue?t(ue):function(t){return ht(t)&&"[object Map]"==nn(t)},gn=ce?t(ce):function(t){return ht(t)&&"[object Set]"==nn(t)}
3648,_n=fe?t(fe):function(t){return ht(t)&&yt(t.length)&&!!Yt[w(t)]},jn=R(function(t,e,n){k(t,e,n)}),mn=R(function(t,e,n,r){k(t,e,n,r)}),An=sn(et(yn=function(e,t){var n={};if(null==e)return n;var r=!1;t=a(t,function(t){return t=F(t,e),r=r||1<t.length,t}),P(e,B(e),n),r&&(n=m(n,7,$));for(var o=t.length;o--;)D(n,t[o]);return n},Mt,at),yn+"");r.constant=xt,r.flatten=at,r.iteratee=kt,r.keys=Lt,r.keysIn=St,r.memoize=ut,r.merge=jn,r.mergeWith=mn,r.negate=ct,r.omit=An,r.property=Nt,r.reject=function(t,e){return(hn(t)?n:function(t,r){var o=[];return Qe(t,function(t,e,n){r(t,e,n)&&o.push(t)}),o})(t,ct(W(e,3)))},r.toPlainObject=At,r.values=Tt,r.cloneDeep=function(t){return m(t,5)},r.cloneDeepWith=function(t,e){return m(t,5,e="function"==typeof e?e:Mt)},r.eq=ft,r.find=pn,r.findIndex=ot,r.get=wt,r.has=function(t,e){return null!=t&&J(t,e,E)},r.hasIn=Et,r.identity=It,r.includes=function(t,e,n,r){if(t=st(t)?t:Tt(t),n=n&&!r?jt(n):0,r=t.length,n<0&&(n=De(r+n,0)),dt(t))t=n<=r&&-1<t.indexOf(e,n);else{if(r=!!r){if(e==e)t:{for(n-=1,r=t.length;++n<r;)if(t[n]===e){t=n;break t}t=-1}else t=o(t,i,n);r=-1<t}t=r}return t},r.isArguments=bn,r.isArray=hn,r.isArrayLike=st,r.isArrayLikeObject=lt,r.isBuffer=vn,r.isEmpty=function(t){if(null==t)return!0;if(st(t)&&(hn(t)||"string"==typeof t||"function"==typeof t.splice||vn(t)||_n(t)||bn(t)))return!t.length;var e=nn(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(Z(t))return!I(t).length;for(var n in t)if(be.call(t,n))return!1;return!0},r.isEqual=function(t,e){return T(t,e)},r.isFunction=pt,r.isLength=yt,r.isMap=dn,r.isNull=function(t){return null===t},r.isObject=bt,r.isObjectLike=ht,r.isPlainObject=vt,r.isSet=gn,r.isString=dt,r.isSymbol=gt,r.isTypedArray=_n,r.last=it,r.stubArray=Dt,r.stubFalse=Ft,r.toFinite=_t,r.toInteger=jt,r.toNumber=mt,r.toString=Ot,r.VERSION="4.17.5",re&&((re.exports=r)._=r,ne._=r)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(t,e,n){e.exports={itemType:{DATA:"data",FCTN:"fctn",EVENT:"event",LISTENER_ON:"listenerOn",LISTENER_OFF:"listenerOff"},dataLayerEvent:{CHANGE:"adobeDataLayer:change",EVENT:"adobeDataLayer:event"},listenerScope:{PAST:"past",FUTURE:"future",ALL:"all"}}},{}],3:[function(t,e,n){var r=t("../custom-lodash"),c=t("../version.json").version,l=r.cloneDeep,p=r.get,y=t("./item"),b=t("./listener"),h=t("./listenerManager"),v=t("./constants"),d=t("./utils/customMerge");e.exports=function(t){var f,e=t||{},n=[],r=[],o={},a={getState:function(){return o},getDataLayer:function(){return n}};function i(t){o=d(o,t.data)}function u(t){t.valid?{data:function(t){i(t),f.triggerListeners(t)},fctn:function(t){t.config.call(n,n)},event:function(t){t.data&&i(t),f.triggerListeners(t)},listenerOn:function(t){var e=b(t);switch(e.scope){case v.listenerScope.PAST:var n,r=_createForOfIteratorHelper(c(t));try{for(r.s();!(n=r.n()).done;){var o=n.value;f.triggerListener(e,o)}}catch(t){r.e(t)}finally{r.f()}break;case v.listenerScope.FUTURE:f.register(e);break;case v.listenerScope.ALL:if(f.register(e)){var a,i=_createForOfIteratorHelper(c(t));try{for(i.s();!(a=i.n()).done;){var u=a.value;f.triggerListener(e,u)}}catch(t){i.e(t)}finally{i.f()}}}},listenerOff:function(t){f.unregister(b(t))}}[t.type](t):s(t);function c(t){return 0===n.length||t.index>n.length-1?[]:n.slice(0,t.index).map(function(t){return y(t)})}}function s(t){var e="The following item cannot be handled by the data layer because it does not have a valid format: "+JSON.stringify(t.config);console.error(e)}return function(){Array.isArray(e.dataLayer)||(e.dataLayer=[]);r=e.dataLayer.splice(0,e.dataLayer.length),(n=e.dataLayer).version=c,o={},f=h(a)}(),n.push=function(t){var n=arguments,r=arguments;if(Object.keys(n).forEach(function(t){var e=y(n[t]);switch(e.valid||(s(e),delete r[t]),e.type){case v.itemType.DATA:case v.itemType.EVENT:u(e);break;case v.itemType.FCTN:delete r[t],u(e);break;case v.itemType.LISTENER_ON:case v.itemType.LISTENER_OFF:delete r[t]}}),r[0])return Array.prototype.push.apply(this,r)},n.getState=function(t){return t?p(l(o),t):l(o)},n.addEventListener=function(t,e,n){u(y({on:t,handler:e,scope:n&&n.scope,path:n&&n.path}))},n.removeEventListener=function(t,e){u(y({off:t,handler:e}))},function(){for(var t=0;t<r.length;t++)n.push(r[t])}(),a}},{"../custom-lodash":1,"../version.json":14,"./constants":2,"./item":5,"./listener":7,"./listenerManager":8,"./utils/customMerge":10}],4:[function(t,e,n){var r={Manager:t("./dataLayerManager")};window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer.version?console.warn("Adobe Client Data Layer v".concat(window.adobeDataLayer.version," has already been imported/initialized on this page. You may be erroneously loading it a second time.")):r.Manager({dataLayer:window.adobeDataLayer}),e.exports=r},{"./dataLayerManager":3}],5:[function(t,e,n){var r=t("../custom-lodash"),i=r.isPlainObject,u=r.isEmpty,c=r.omit,f=r.find,s=t("./utils/dataMatchesContraints"),l=t("./itemConstraints"),p=t("./constants");e.exports=function(t,e){var n=t,r=e,o=f(Object.keys(l),function(t){return s(n,l[t])})||"function"==typeof n&&p.itemType.FCTN||i(n)&&p.itemType.DATA,a=function(){var t=c(n,Object.keys(l.event));if(!u(t))return t}();return{config:n,type:o,data:a,valid:!!o,index:r}}},{"../custom-lodash":1,"./constants":2,"./itemConstraints":6,"./utils/dataMatchesContraints":11}],6:[function(t,e,n){e.exports={event:{event:{type:"string"},eventInfo:{optional:!0}},listenerOn:{on:{type:"string"},handler:{type:"function"},scope:{type:"string",values:["past","future","all"],optional:!0},path:{type:"string",optional:!0}},listenerOff:{off:{type:"string"},handler:{type:"function",optional:!0},scope:{type:"string",values:["past","future","all"],optional:!0},path:{type:"string",optional:!0}}}},{}],7:[function(t,e,n){var r=t("./constants");e.exports=function(t){return{event:t.config.on||t.config.off,handler:t.config.handler||null,scope:t.config.scope||t.config.on&&r.listenerScope.ALL||null,path:t.config.path||null}}},{"./constants":2}],8:[function(t,e,n){var u=t("../custom-lodash").cloneDeep,c=t("./constants"),f=t("./utils/listenerMatch"),s=t("./utils/indexOfListener");e.exports=function(t){var o={},r=t,a=s.bind(null,o);function i(t,e){if(f(t,e)){var n=[u(e.config)];t.handler.apply(r.getDataLayer(),n)}}return{register:function(t){var e=t.event;return Object.prototype.hasOwnProperty.call(o,e)?-1===a(t)&&(o[t.event].push(t),!0):(o[t.event]=[t],!0)},unregister:function(t){var e=t.event;if(Object.prototype.hasOwnProperty.call(o,e))if(t.handler||t.scope||t.path){var n=a(t);-1<n&&o[e].splice(n,1)}else o[e]=[]},triggerListeners:function(r){(function(t){var e=[];switch(t.type){case c.itemType.DATA:e.push(c.dataLayerEvent.CHANGE);break;case c.itemType.EVENT:e.push(c.dataLayerEvent.EVENT),t.data&&e.push(c.dataLayerEvent.CHANGE),t.config.event!==c.dataLayerEvent.CHANGE&&e.push(t.config.event)}return e})(r).forEach(function(t){if(Object.prototype.hasOwnProperty.call(o,t)){var e,n=_createForOfIteratorHelper(o[t]);try{for(n.s();!(e=n.n()).done;){i(e.value,r)}}catch(t){n.e(t)}finally{n.f()}}})},triggerListener:function(t,e){i(t,e)}}}},{"../custom-lodash":1,"./constants":2,"./utils/indexOfListener":12,"./utils/listenerMatch":13}],9:[function(t,e,n){var r=t("../../custom-lodash"),o=r.has,a=r.get;e.exports=function(t,e){for(var n=e.substring(0,e.lastIndexOf("."));n;){if(o(t,n)){var r=a(t,n);if(null==r)return!0}n=n.substring(0,n.lastIndexOf("."))}return!1}},{"../../custom-lodash":1}],10:[function(t,e,n){var r=t("../../custom-lodash"),s=r.cloneDeepWith,l=r.isObject,p=r.isArray,y=r.reject,o=r.mergeWith,a=r.isNull;e.exports=function(t,e){return o(t,e,function(t,e,n,r){if(null==e)return null}),t=function(t,e){return s(t,function(f){return function e(t,n,r,o){if(l(t)){if(p(t))return y(t,f).map(function(t){return s(t,e)});for(var a={},i=0,u=Object.keys(t);i<u.length;i++){var c=u[i];f(t[c])||(a[c]=s(t[c],e))}return a}}}(1<arguments.length&&void 0!==e?e:function(t){return!t}))}(t,a)}},{"../../custom-lodash":1}],11:[function(t,e,n){var r=t("../../custom-lodash"),o=r.find,s=r.includes;e.exports=function(c,f){return void 0===o(Object.keys(f),function(t){var e=f[t].type,n=t&&f[t].values,r=!f[t].optional,o=c[t],a=_typeof(o),i=e&&a!==e,u=n&&!s(n,o);return r?!o||i||u:o&&(i||u)})}},{"../../custom-lodash":1}],12:[function(t,e,n){var c=t("../../custom-lodash").isEqual;e.exports=function(t,e){var n=e.event;if(Object.prototype.hasOwnProperty.call(t,n)){var r,o=_createForOfIteratorHelper(t[n].entries());try{for(o.s();!(r=o.n()).done;){var a=_slicedToArray(r.value,2),i=a[0],u=a[1];if(c(u.handler,e.handler))return i}}catch(t){o.e(t)}finally{o.f()}}return-1}},{"../../custom-lodash":1}],13:[function(t,e,n){var r=t("../../custom-lodash").has,a=t("../constants"),o=t("./ancestorRemoved");function i(t,e){return!e.data||!t.path||(r(e.data,t.path)||o(e.data,t.path))}
3648e.exports=function(t,e){var n=t.event,r=e.config,o=!1;return e.type===a.itemType.DATA?n===a.dataLayerEvent.CHANGE&&(o=i(t,e)):e.type===a.itemType.EVENT&&(n!==a.dataLayerEvent.EVENT&&n!==r.event||(o=i(t,e)),e.data&&n===a.dataLayerEvent.CHANGE&&(o=i(t,e))),o}},{"../../custom-lodash":1,"../constants":2,"./ancestorRemoved":9}],14:[function(t,e,n){e.exports={version:"2.0.2"}},{}]},{},[4]); 3649//# sourceMappingURL=adobe-client-data-layer.min.js.map 3650 3651/******************************************************************************* 3652 * Copyright 2020 Adobe 3653 * 3654 * Licensed under the Apache License, Version 2.0 (the "License"); 3655 * you may not use this file except in compliance with the License. 3656 * You may obtain a copy of the License at 3657 * 3658 * http://www.apache.org/licenses/LICENSE-2.0 3659 * 3660 * Unless required by applicable law or agreed to in writing, software 3661 * distributed under the License is distributed on an "AS IS" BASIS, 3662 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3663 * See the License for the specific language governing permissions and 3664 * limitations under the License. 3665 ******************************************************************************/ 3666(function() { 3667 "use strict"; 3668 3669 var dataLayerEnabled; 3670 var dataLayerName; 3671 var dataLayer; 3672 3673 function addComponentToDataLayer(component) { 3674 dataLayer.push({ 3675 component: getComponentObject(component) 3676 }); 3677 } 3678 3679 function attachClickEventListener(element) { 3680 element.addEventListener("click", addClickToDataLayer); 3681 } 3682 3683 function getComponentObject(element) { 3684 var component = getComponentData(element); 3685 var componentID = Object.keys(component)[0]; 3686 // if the component does not have a parent ID property, use the ID of the parent element 3687 if (component && component[componentID] && !component[componentID].parentId) { 3688 var parentElement = element.parentNode.closest("[data-cmp-data-layer], body"); 3689 if (parentElement) { 3690 component[componentID].parentId = parentElement.id; 3691 } 3692 } 3693 3694 return component; 3695 } 3696 3697 function addClickToDataLayer(event) { 3698 var element = event.currentTarget; 3699 var componentId = getClickId(element); 3700 3701 dataLayer.push({ 3702 event: "cmp:click", 3703 eventInfo: { 3704 path: "component." + componentId 3705 } 3706 }); 3707 } 3708 3709 function getComponentData(element) { 3710 var dataLayerJson = element.dataset.cmpDataLayer; 3711 if (dataLayerJson) { 3712 return JSON.parse(dataLayerJson); 3713 } else { 3714 return undefined; 3715 } 3716 } 3717 3718 function getClickId(element) { 3719 if (element.dataset.cmpDataLayer) { 3720 return Object.keys(JSON.parse(element.dataset.cmpDataLayer))[0]; 3721 } 3722 3723 var componentElement = element.closest("[data-cmp-data-layer]"); 3724 3725 return Object.keys(JSON.parse(componentElement.dataset.cmpDataLayer))[0]; 3726 } 3727 3728 function onDocumentReady() { 3729 dataLayerEnabled = document.body.hasAttribute("data-cmp-data-layer-enabled"); 3730 if (dataLayerEnabled) { 3731 dataLayerName = document.body.getAttribute("data-cmp-data-layer-name") || "adobeDataLayer"; 3732 dataLayer = window[dataLayerName] = window[dataLayerName] || []; 3733 3734 var components = document.querySelectorAll("[data-cmp-data-layer]"); 3735 var clickableElements = document.querySelectorAll("[data-cmp-clickable]"); 3736 3737 components.forEach(function(component) { 3738 addComponentToDataLayer(component); 3739 }); 3740 3741 clickableElements.forEach(function(element) { 3742 attachClickEventListener(element); 3743 }); 3744 3745 dataLayer.push({ 3746 event: "cmp:loaded" 3747 }); 3748 } 3749 } 3750 3751 if (document.readyState !== "loading") { 3752 onDocumentReady(); 3753 } else { 3754 document.addEventListener("DOMContentLoaded", onDocumentReady); 3755 } 3756 3757}()); 3758 3759/* 3760 * Copyright 1997-2010 Day Management AG 3761 * Barfuesserplatz 6, 4001 Basel, Switzerland 3762 * All Rights Reserved. 3763 * 3764 * This software is the confidential and proprietary information of 3765 * Day Management AG, ("Confidential Information"). You shall not 3766 * disclose such Confidential Information and shall use it only in 3767 * accordance with the terms of the license agreement you entered into 3768 * with Day. 3769 */ 3770 3771// map $CQ to Granite jQuery 3772window.$CQ = _g.$; 3773 3774 3775/** 3776 * @license 3777 * Video.js 8.3.0 <http://videojs.com/> 3778 * Copyright Brightcove, Inc. <https://www.brightcove.com/> 3779 * Available under Apache License Version 2.0 3780 * <https://github.com/videojs/video.js/blob/main/LICENSE> 3781 * 3782 * Includes vtt.js <https://github.com/mozilla/vtt.js> 3783 * Available under Apache License Version 2.0 3784 * <https://github.com/mozilla/vtt.js/blob/main/LICENSE> 3785 */ 3786!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).videojs=t()}(this,function(){"use strict";var R="8.3.0";const U={},B=function(e,t){return U[e]=U[e]||[],t&&(U[e]=U[e].concat(t)),U[e]};function F(e,t){return!((t=B(e).indexOf(t))<=-1||(U[e]=U[e].slice(),U[e].splice(t,1),0))}const j={prefixed:!0};var H=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror","fullscreen"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror","-webkit-full-screen"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror","-moz-full-screen"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError","-ms-fullscreen"]],q=H[0];let V;for(let e=0;e<H.length;e++)if(H[e][1]in document){V=H[e];break}if(V){for(let e=0;e<V.length;e++)j[q[e]]=V[e];j.prefixed=V[0]!==q[0]}let l=[];function $(e){return K(e)?Object.keys(e):[]}const d=function t(i){let s="info",r;function n(...e){r("log",s,e)}var a,o;return r=(a=i,(t,i,s)=>{var e,i=o.levels[i],r=new RegExp(`^(${i})$`);if("log"!==t&&s.unshift(t.toUpperCase()+":"),s.unshift(a+":"),l&&(l.push([].concat(s)),e=l.length-1e3,l.splice(0,0<e?e:0)),window.console){let e=window.console[t];(e=e||"debug"!==t?e:window.console.info||window.console.log)&&i&&r.test(t)&&e[Array.isArray(s)?"apply":"call"](window.console,s)}}),(o=n).createLogger=e=>t(i+": "+e),n.levels={all:"debug|log|warn|error",off:"",debug:"debug|log|warn|error",info:"log|warn|error",warn:"warn|error",error:"error",DEFAULT:s},n.level=e=>{if("string"==typeof e){if(!n.levels.hasOwnProperty(e))throw new Error(`"${e}" in not a valid log level`);s=e}return s},n.history=()=>l?[].concat(l):[],n.history.filter=t=>(l||[]).filter(e=>new RegExp(`.*${t}.*`).test(e[0])),n.history.clear=()=>{l&&(l.length=0)},n.history.disable=()=>{null!==l&&(l.length=0,l=null)},n.history.enable=()=>{null===l&&(l=[])},n.error=(...e)=>r("error",s,e),n.warn=(...e)=>r("warn",s,e),n.debug=(...e)=>r("debug",s,e),n}("VIDEOJS"),W=d.createLogger,G=Object.prototype.toString;
vendor: 14,246 bytes, line 3786
3786function z(t,i){$(t).forEach(e=>i(t[e],e))}function X(i,s,e=0){return $(i).reduce((e,t)=>s(e,i[t],t),e)}function K(e){return!!e&&"object"==typeof e}function Y(e){return K(e)&&"[object Object]"===G.call(e)&&e.constructor===Object}function h(...e){const i={};return e.forEach(e=>{e&&z(e,(e,t)=>{Y(e)?(Y(i[t])||(i[t]={}),i[t]=h(i[t],e)):i[t]=e})}),i}function Q(t,i,s,e=!0){const r=e=>Object.defineProperty(t,i,{value:e,enumerable:!0,writable:!0});var n={configurable:!0,enumerable:!0,get(){var e=s();return r(e),e}};return e&&(n.set=r),Object.defineProperty(t,i,n)}var J=Object.freeze({__proto__:null,each:z,reduce:X,isObject:K,isPlain:Y,merge:h,defineLazyProperty:Q});let Z=!1,ee=null,te=!1,ie,se=!1,re=!1,ne=!1,ae=!1,oe=null,le=null,de=null,he=!1,ue=!1,ce=!1,pe=!1;const me=Boolean(_e()&&("ontouchstart"in window||window.navigator.maxTouchPoints||window.DocumentTouch&&window.document instanceof window.DocumentTouch));var ge,e=window.navigator&&window.navigator.userAgentData;if(e&&(te="Android"===e.platform,re=Boolean(e.brands.find(e=>"Microsoft Edge"===e.brand)),ne=Boolean(e.brands.find(e=>"Chromium"===e.brand)),ae=!re&&ne,oe=le=(e.brands.find(e=>"Chromium"===e.brand)||{}).version||null,ue="Windows"===e.platform),!ne){const M=window.navigator&&window.navigator.userAgent||"";Z=/iPod/i.test(M),ee=(e=M.match(/OS (\d+)_/i))&&e[1]?e[1]:null,te=/Android/i.test(M),ie=(e=M.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i))?(mt=e[1]&&parseFloat(e[1]),ge=e[2]&&parseFloat(e[2]),mt&&ge?parseFloat(e[1]+"."+e[2]):mt||null):null,se=/Firefox/i.test(M),re=/Edg/i.test(M),ne=/Chrome/i.test(M)||/CriOS/i.test(M),ae=!re&&ne,oe=le=(ge=M.match(/(Chrome|CriOS)\/(\d+)/))&&ge[2]?parseFloat(ge[2]):null,de=function(){var e=/MSIE\s(\d+)\.\d/.exec(M);let t=e&&parseFloat(e[1]);return t=!t&&/Trident\/7.0/i.test(M)&&/rv:11.0/.test(M)?11:t}(),he=/Safari/i.test(M)&&!ae&&!te&&!re,ue=/Windows/i.test(M),ce=/iPad/i.test(M)||he&&me&&!/iPhone/i.test(M),pe=/iPhone/i.test(M)&&!ce}const u=pe||ce||Z,fe=(he||u)&&!ae;e=Object.freeze({__proto__:null,get IS_IPOD(){return Z},get IOS_VERSION(){return ee},get IS_ANDROID(){return te},get ANDROID_VERSION(){return ie},get IS_FIREFOX(){return se},get IS_EDGE(){return re},get IS_CHROMIUM(){return ne},get IS_CHROME(){return ae},get CHROMIUM_VERSION(){return oe},get CHROME_VERSION(){return le},get IE_VERSION(){return de},get IS_SAFARI(){return he},get IS_WINDOWS(){return ue},get IS_IPAD(){return ce},get IS_IPHONE(){return pe},TOUCH_ENABLED:me,IS_IOS:u,IS_ANY_SAFARI:fe});function ye(e){return"string"==typeof e&&Boolean(e.trim())}function _e(){return document===window.document}function ve(e){return K(e)&&1===e.nodeType}function be(){try{return window.parent!==window.self}catch(e){return!0}}function Te(i){return function(e,t){return ye(e)?(t=ve(t=ye(t)?document.querySelector(t):t)?t:document)[i]&&t[i](e):document[i](null)}}function o(e="div",i={},t={},s){const r=document.createElement(e);return Object.getOwnPropertyNames(i).forEach(function(e){var t=i[e];"textContent"===e?Se(r,t):r[e]===t&&"tabIndex"!==e||(r[e]=t)}),Object.getOwnPropertyNames(t).forEach(function(e){r.setAttribute(e,t[e])}),s&&He(r,s),r}function Se(e,t){return"undefined"==typeof e.textContent?e.innerText=t:e.textContent=t,e}function we(e,t){t.firstChild?t.insertBefore(e,t.firstChild):t.appendChild(e)}function Ee(e,t){if(0<=t.indexOf(" "))throw new Error("class has illegal whitespace characters");return e.classList.contains(t)}function ke(e,...t){return e.classList.add(...t.reduce((e,t)=>e.concat(t.split(/\s+/)),[])),e}function Ce(e,...t){return e?(e.classList.remove(...t.reduce((e,t)=>e.concat(t.split(/\s+/)),[])),e):(d.warn("removeClass was called with an element that doesn't exist"),null)}function Ie(t,e,i){return"boolean"!=typeof(i="function"==typeof i?i(t,e):i)&&(i=void 0),e.split(/\s+/).forEach(e=>t.classList.toggle(e,i)),t}function xe(i,s){Object.getOwnPropertyNames(s).forEach(function(e){var t=s[e];null===t||"undefined"==typeof t||!1===t?i.removeAttribute(e):i.setAttribute(e,!0===t?"":t)})}function Ae(i){var s={};if(i&&i.attributes&&0<i.attributes.length){var r=i.attributes;for(let t=r.length-1;0<=t;t--){var n=r[t].name;let e=r[t].value;"boolean"!=typeof i[n]&&-1===",autoplay,controls,playsinline,loop,muted,default,defaultMuted,".indexOf(","+n+",")||(e=null!==e),s[n]=e}}return s}function Pe(e,t){return e.getAttribute(t)}function Le(e,t,i){e.setAttribute(t,i)}function Oe(e,t){e.removeAttribute(t)}function De(){document.body.focus(),document.onselectstart=function(){return!1}}function Ne(){document.onselectstart=function(){return!0}}function Me(e){if(e&&e.getBoundingClientRect&&e.parentNode){const t=e.getBoundingClientRect(),i={};return["bottom","height","left","right","top","width"].forEach(e=>{void 0!==t[e]&&(i[e]=t[e])}),i.height||(i.height=parseFloat(Ge(e,"height"))),i.width||(i.width=parseFloat(Ge(e,"width"))),i}}function Re(e){if(!e||!e.offsetParent)return{left:0,top:0,width:0,height:0};var t=e.offsetWidth,i=e.offsetHeight;let s=0,r=0;for(;e.offsetParent&&e!==document[j.fullscreenElement];)s+=e.offsetLeft,r+=e.offsetTop,e=e.offsetParent;return{left:s,top:r,width:t,height:i}}function Ue(t,e){var i={x:0,y:0};if(u){let e=t;for(;e&&"html"!==e.nodeName.toLowerCase();){var s,r=Ge(e,"transform");/^matrix/.test(r)?(s=r.slice(7,-1).split(/,\s/).map(Number),i.x+=s[4],i.y+=s[5]):/^matrix3d/.test(r)&&(s=r.slice(9,-1).split(/,\s/).map(Number),i.x+=s[12],i.y+=s[13]),e=e.parentNode}}var n={},a=Re(e.target),t=Re(t),o=t.width,l=t.height;let d=e.offsetY-(t.top-a.top),h=e.offsetX-(t.left-a.left);return e.changedTouches&&(h=e.changedTouches[0].pageX-t.left,d=e.changedTouches[0].pageY+t.top,u)&&(h-=i.x,d-=i.y),n.y=1-Math.max(0,Math.min(1,d/l)),n.x=Math.max(0,Math.min(1,h/o)),n}function Be(e){return K(e)&&3===e.nodeType}function Fe(e){for(;e.firstChild;)e.removeChild(e.firstChild);return e}function je(e){return"function"==typeof e&&(e=e()),(Array.isArray(e)?e:[e]).map(e=>ve(e="function"==typeof e?e():e)||Be(e)?e:"string"==typeof e&&/\S/.test(e)?document.createTextNode(e):void 0).filter(e=>e)}function He(t,e){return je(e).forEach(e=>t.appendChild(e)),t}function qe(e,t){return He(Fe(e),t)}function Ve(e){return void 0===e.button&&void 0===e.buttons||0===e.button&&void 0===e.buttons||"mouseup"===e.type&&0===e.button&&0===e.buttons||0===e.button&&1===e.buttons}const $e=Te("querySelector"),We=Te("querySelectorAll");function Ge(t,i){if(!t||!i)return"";if("function"!=typeof window.getComputedStyle)return"";{let e;try{e=window.getComputedStyle(t)}catch(e){return""}return e?e.getPropertyValue(i)||e[i]:""}}var ze=Object.freeze({__proto__:null,isReal:_e,isEl:ve,isInFrame:be,createEl:o,textContent:Se,prependTo:we,hasClass:Ee,addClass:ke,removeClass:Ce,toggleClass:Ie,setAttributes:xe,getAttributes:Ae,getAttribute:Pe,setAttribute:Le,removeAttribute:Oe,blockTextSelection:De,unblockTextSelection:Ne,getBoundingClientRect:Me,findPosition:Re,getPointerPosition:Ue,isTextNode:Be,emptyEl:Fe,normalizeContent:je,appendContent:He,insertContent:qe,isSingleLeftClick:Ve,$:$e,$$:We,computedStyle:Ge});let Xe=!1,Ke;function Ye(){if(!1!==Ke.options.autoSetup){var e=Array.prototype.slice.call(document.getElementsByTagName("video")),t=Array.prototype.slice.call(document.getElementsByTagName("audio")),i=Array.prototype.slice.call(document.getElementsByTagName("video-js")),s=e.concat(t,i);if(s&&0<s.length)for(let e=0,t=s.length;e<t;e++){var r=s[e];if(!r||!r.getAttribute){Qe(1);break}void 0===r.player&&null!==r.getAttribute("data-setup")&&Ke(r)}else Xe||Qe(1)}}function Qe(e,t){_e()&&(t&&(Ke=t),window.setTimeout(Ye,e))}function Je(){Xe=!0,window.removeEventListener("load",Je)}_e()&&("complete"===document.readyState?Je():window.addEventListener("load",Je));function Ze(e){var t=document.createElement("style");return t.className=e,t}function et(e,t){e.styleSheet?e.styleSheet.cssText=t:e.textContent=t}var c=new WeakMap;let tt=3;function it(e,t){var i;c.has(e)&&(0===(i=c.get(e)).handlers[t].length&&(delete i.handlers[t],e.removeEventListener?e.removeEventListener(t,i.dispatcher,!1):e.detachEvent&&e.detachEvent("on"+t,i.dispatcher)),Object.getOwnPropertyNames(i.handlers).length<=0&&(delete i.handlers,delete i.dispatcher,delete i.disabled),0===Object.getOwnPropertyNames(i).length)&&c.delete(e)}function st(t,i,e,s){e.forEach(function(e){t(i,e,s)})}function rt(e){if(!e.fixed_){if(!e||!e.isPropagationStopped||!e.isImmediatePropagationStopped){const n=e||window.event;e={};for(const a in n)"layerX"===a||"layerY"===a||"keyLocation"===a||"webkitMovementX"===a||"webkitMovementY"===a||"path"===a||"returnValue"===a&&n.preventDefault||(e[a]=n[a]);var t,i;e.target||(e.target=e.srcElement||document),e.relatedTarget||(e.relatedTarget=e.fromElement===e.target?e.toElement:e.fromElement),e.preventDefault=function(){n.preventDefault&&n.preventDefault(),e.returnValue=!1,n.returnValue=!1,e.defaultPrevented=!0},e.defaultPrevented=!1,e.stopPropagation=function(){n.stopPropagation&&n.stopPropagation(),e.cancelBubble=!0,n.cancelBubble=!0,e.isPropagationStopped=s},e.isPropagationStopped=r,e.stopImmediatePropagation=function(){n.stopImmediatePropagation&&n.stopImmediatePropagation(),e.isImmediatePropagationStopped=s,e.stopPropagation()},e.isImmediatePropagationStopped=r,null!==e.clientX&&void 0!==e.clientX&&(t=document.documentElement,i=document.body,e.pageX=e.clientX+(t&&t.scrollLeft||i&&i.scrollLeft||0)-(t&&t.clientLeft||i&&i.clientLeft||0),e.pageY=e.clientY+(t&&t.scrollTop||i&&i.scrollTop||0)-(t&&t.clientTop||i&&i.clientTop||0)),e.which=e.charCode||e.keyCode,null!==e.button&&void 0!==e.button&&(e.button=1&e.button?0:4&e.button?1:2&e.button?2:0)}e.fixed_=!0}return e;function s(){return!0}function r(){return!1}}let nt;const at=["touchstart","touchmove"];function ot(n,t,e){if(Array.isArray(t))return st(ot,n,t,e);c.has(n)||c.set(n,{});const a=c.get(n);if(a.handlers||(a.handlers={}),a.handlers[t]||(a.handlers[t]=[]),e.guid||(e.guid=tt++),a.handlers[t].push(e),a.dispatcher||(a.disabled=!1,a.dispatcher=function(i,s){if(!a.disabled){i=rt(i);var e=a.handlers[i.type];if(e){var r=e.slice(0);for(let e=0,t=r.length;e<t&&!i.isImmediatePropagationStopped();e++)try{r[e].call(n,i,s)}catch(e){d.error(e)}}}}),1===a.handlers[t].length)if(n.addEventListener){let e=!1;(function(){if("boolean"!=typeof nt){nt=!1;try{var e=Object.defineProperty({},"passive",{get(){nt=!0}});window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(e){}}return nt})()&&-1<at.indexOf(t)&&(e={passive:!0}),n.addEventListener(t,a.dispatcher,e)}else n.attachEvent&&n.attachEvent("on"+t,a.dispatcher)}function p(e,t,i){if(c.has(e)){const n=c.get(e);if(n.handlers){if(Array.isArray(t))return st(p,e,t,i);var s=function(e,t){n.handlers[t]=[],it(e,t)};if(void 0===t)for(const a in n.handlers)Object.prototype.hasOwnProperty.call(n.handlers||{},a)&&s(e,a);else{var r=n.handlers[t];if(r)if(i){if(i.guid)for(let e=0;e<r.length;e++)r[e].guid===i.guid&&r.splice(e--,1);it(e,t)}else s(e,t)}}}}function lt(e,t,i){var s=c.has(e)?c.get(e):{},r=e.parentNode||e.ownerDocument;return"string"==typeof t?t={type:t,target:e}:t.target||(t.target=e),t=rt(t),s.dispatcher&&s.dispatcher.call(e,t,i),r&&!t.isPropagationStopped()&&!0===t.bubbles?lt.call(null,r,t,i):!r&&!t.defaultPrevented&&t.target&&t.target[t.type]&&(c.has(t.target)||c.set(t.target,{}),s=c.get(t.target),t.target[t.type])&&(s.disabled=!0,"function"==typeof t.target[t.type]&&t.target[t.type](),s.disabled=!1),!t.defaultPrevented}function dt(e,t,i){if(Array.isArray(t))return st(dt,e,t,i);function s(){p(e,t,s),i.apply(this,arguments)}s.guid=i.guid=i.guid||tt++,ot(e,t,s)}function ht(e,t,i){function s(){p(e,t,s),i.apply(this,arguments)}s.guid=i.guid=i.guid||tt++,ot(e,t,s)}var ut=Object.freeze({__proto__:null,fixEvent:rt,on:ot,off:p,trigger:lt,one:dt,any:ht});function m(e,t,i){return t.guid||(t.guid=tt++),(e=t.bind(e)).guid=i?i+"_"+t.guid:t.guid,e}function ct(i,s){let r=window.performance.now();return function(...e){var t=window.performance.now();t-r>=s&&(i(...e),r=t)}}function pt(s,r,n,a=window){let o;function e(){const e=this,t=arguments;let i=function(){o=null,i=null,n||s.apply(e,t)};!o&&n&&s.apply(e,t),a.clearTimeout(o),o=a.setTimeout(i,r)}return e.cancel=()=>{a.clearTimeout(o),o=null},e}var mt=Object.freeze({__proto__:null,UPDATE_REFRESH_INTERVAL:30,bind_:m,throttle:ct,debounce:pt});let gt;class ft{on(e,t){var i=this.addEventListener;this.addEventListener=()=>{},ot(this,e,t),this.addEventListener=i}off(e,t){p(this,e,t)}one(e,t){var i=this.addEventListener;this.addEventListener=()=>{},dt(this,e,t),this.addEventListener=i}any(e,t){var i=this.addEventListener;this.addEventListener=()=>{},ht(this,e,t),this.addEventListener=i}trigger(e){var t=e.type||e;e=rt(e="string"==typeof e?{type:t}:e),this.allowedEvents_[t]&&this["on"+t]&&this["on"+t](e),lt(this,e)}queueTrigger(e){gt=gt||new Map;const t=e.type||e;let i=gt.get(this);i||(i=new Map,gt.set(this,i));var s=i.get(t),s=(i.delete(t),window.clearTimeout(s),window.setTimeout(()=>{i.delete(t),0===i.size&&(i=null,gt.delete(this)),this.trigger(e)},0));i.set(t,s)}}ft.prototype.allowedEvents_={},ft.prototype.addEventListener=ft.prototype.on,ft.prototype.removeEventListener=ft.prototype.off,ft.prototype.dispatchEvent=ft.prototype.trigger;const yt=e=>"function"==typeof e.name?e.name():"string"==typeof e.name?e.name:e.name_||(e.constructor&&e.constructor.name?e.constructor.name:typeof e),_t=t=>t instanceof ft||!!t.eventBusEl_&&["on","one","off","trigger"].every(e=>"function"==typeof t[e]),vt=e=>"string"==typeof e&&/\S/.test(e)||Array.isArray(e)&&!!e.length,bt=(e,t,i)=>{if(!e||!e.nodeName&&!_t(e))throw new Error(`Invalid target for ${yt(t)}#${i}; must be a DOM node or evented object.`)},Tt=(e,t,i)=>{if(!vt(e))throw new Error(`Invalid event type for ${yt(t)}#${i}; must be a non-empty string or array.`)},St=(e,t,i)=>{if("function"!=typeof e)throw new Error(`Invalid listener for ${yt(t)}#${i}; must be a function.`)},wt=(e,t,i)=>{var s=t.length<3||t[0]===e||t[0]===e.eventBusEl_;let r,n,a;return s?(r=e.eventBusEl_,3<=t.length&&t.shift(),[n,a]=t):[r,n,a]=t,bt(r,e,i),Tt(n,e,i),St(a,e,i),a=m(e,a),{isTargetingSelf:s,target:r,type:n,listener:a}},Et=(e,t,i,s)=>{bt(e,e,t),e.nodeName?ut[t](e,i,s):e[t](i,s)},kt={on(...e){const{isTargetingSelf:t,target:i,type:s,listener:r}=wt(this,e,"on");
3786if(Et(i,"on",s,r),!t){const n=()=>this.off(i,s,r);n.guid=r.guid;e=()=>this.off("dispose",n);e.guid=r.guid,Et(this,"on","dispose",n),Et(i,"on","dispose",e)}},one(...e){const{isTargetingSelf:t,target:i,type:s,listener:r}=wt(this,e,"one");if(t)Et(i,"one",s,r);else{const n=(...e)=>{this.off(i,s,n),r.apply(null,e)};n.guid=r.guid,Et(i,"one",s,n)}},any(...e){const{isTargetingSelf:t,target:i,type:s,listener:r}=wt(this,e,"any");if(t)Et(i,"any",s,r);else{const n=(...e)=>{this.off(i,s,n),r.apply(null,e)};n.guid=r.guid,Et(i,"any",s,n)}},off(e,t,i){!e||vt(e)?p(this.eventBusEl_,e,t):(e=e,t=t,bt(e,this,"off"),Tt(t,this,"off"),St(i,this,"off"),i=m(this,i),this.off("dispose",i),e.nodeName?(p(e,t,i),p(e,"dispose",i)):_t(e)&&(e.off(t,i),e.off("dispose",i)))},trigger(e,t){bt(this.eventBusEl_,this,"trigger");var i=e&&"string"!=typeof e?e.type:e;if(vt(i))return lt(this.eventBusEl_,e,t);throw new Error(`Invalid event type for ${yt(this)}#trigger; `+"must be a non-empty string or object with a type key that has a non-empty value.")}};function Ct(e,t={}){t=t.eventBusKey;if(t){if(!e[t].nodeName)throw new Error(`The eventBusKey "${t}" does not refer to an element.`);e.eventBusEl_=e[t]}else e.eventBusEl_=o("span",{className:"vjs-event-bus"});Object.assign(e,kt),e.eventedCallbacks&&e.eventedCallbacks.forEach(e=>{e()}),e.on("dispose",()=>{e.off(),[e,e.el_,e.eventBusEl_].forEach(function(e){e&&c.has(e)&&c.delete(e)}),window.setTimeout(()=>{e.eventBusEl_=null},0)})}const It={state:{},setState(e){"function"==typeof e&&(e=e());let i;return z(e,(e,t)=>{this.state[t]!==e&&((i=i||{})[t]={from:this.state[t],to:e}),this.state[t]=e}),i&&_t(this)&&this.trigger({changes:i,type:"statechanged"}),i}};function xt(e,t){Object.assign(e,It),e.state=Object.assign({},e.state,t),"function"==typeof e.handleStateChanged&&_t(e)&&e.on("statechanged",e.handleStateChanged)}function At(e){return"string"!=typeof e?e:e.replace(/./,e=>e.toLowerCase())}function g(e){return"string"!=typeof e?e:e.replace(/./,e=>e.toUpperCase())}function Pt(e,t){return g(e)===g(t)}var Lt=Object.freeze({__proto__:null,toLowerCase:At,toTitleCase:g,titleCaseEquals:Pt}),Ot="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Dt(e,t){return e(t={exports:{}},t.exports),t.exports}var r=Dt(function(e,t){function i(e){var t;return"number"==typeof(e=e&&"object"==typeof e&&(t=e.which||e.keyCode||e.charCode)?t:e)?o[e]:(t=String(e),s[t.toLowerCase()]||r[t.toLowerCase()]||(1===t.length?t.charCodeAt(0):void 0))}i.isEventKey=function(e,t){if(e&&"object"==typeof e){e=e.which||e.keyCode||e.charCode;if(null!=e)if("string"==typeof t){var i=s[t.toLowerCase()];if(i)return i===e;if(i=r[t.toLowerCase()])return i===e}else if("number"==typeof t)return t===e;return!1}};for(var s=(t=e.exports=i).code=t.codes={backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,"pause/break":19,"caps lock":20,esc:27,space:32,"page up":33,"page down":34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,delete:46,command:91,"left command":91,"right command":93,"numpad *":106,"numpad +":107,"numpad -":109,"numpad .":110,"numpad /":111,"num lock":144,"scroll lock":145,"my computer":182,"my calculator":183,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},r=t.aliases={windows:91,"ââ¡Â§":16,"âÅÂ¥":18,"Ã¢ÅÆ":17,"âÅË":91,ctl:17,control:17,option:18,pause:19,break:19,caps:20,return:13,escape:27,spc:32,spacebar:32,pgup:33,pgdn:34,ins:45,del:46,cmd:91},n=97;n<123;n++)s[String.fromCharCode(n)]=n-32;for(var n=48;n<58;n++)s[n-48]=n;for(n=1;n<13;n++)s["f"+n]=n+111;for(n=0;n<10;n++)s["numpad "+n]=n+96;var a,o=t.names=t.title={};for(n in s)o[s[n]]=n;for(a in r)s[a]=r[a]});r.code,r.codes,r.aliases,r.names,r.title;class f{constructor(e,t,i){!e&&this.play?this.player_=e=this:this.player_=e,this.isDisposed_=!1,this.parentComponent_=null,this.options_=h({},this.options_),t=this.options_=h(this.options_,t),this.id_=t.id||t.el&&t.el.id,this.id_||(e=e&&e.id&&e.id()||"no_player",this.id_=e+"_component_"+tt++),this.name_=t.name||null,t.el?this.el_=t.el:!1!==t.createEl&&(this.el_=this.createEl()),t.className&&this.el_&&t.className.split(" ").forEach(e
vendor: 19,101 bytes, line 3786
3786=>this.addClass(e)),["on","off","one","any","trigger"].forEach(e=>{this[e]=void 0}),!1!==t.evented&&(Ct(this,{eventBusKey:this.el_?"el_":null}),this.handleLanguagechange=this.handleLanguagechange.bind(this),this.on(this.player_,"languagechange",this.handleLanguagechange)),xt(this,this.constructor.defaultState),this.children_=[],this.childIndex_={},this.childNameIndex_={},this.setTimeoutIds_=new Set,this.setIntervalIds_=new Set,this.rafIds_=new Set,this.namedRafs_=new Map,(this.clearingTimersOnDispose_=!1)!==t.initChildren&&this.initChildren(),this.ready(i),!1!==t.reportTouchActivity&&this.enableTouchActivity()}on(e,t){}off(e,t){}one(e,t){}any(e,t){}trigger(e){}dispose(e={}){if(!this.isDisposed_){if(this.readyQueue_&&(this.readyQueue_.length=0),this.trigger({type:"dispose",bubbles:!1}),this.isDisposed_=!0,this.children_)for(let e=this.children_.length-1;0<=e;e--)this.children_[e].dispose&&this.children_[e].dispose();this.children_=null,this.childIndex_=null,this.childNameIndex_=null,this.parentComponent_=null,this.el_&&(this.el_.parentNode&&(e.restoreEl?this.el_.parentNode.replaceChild(e.restoreEl,this.el_):this.el_.parentNode.removeChild(this.el_)),this.el_=null),this.player_=null}}isDisposed(){return Boolean(this.isDisposed_)}player(){return this.player_}options(e){return e&&(this.options_=h(this.options_,e)),this.options_}el(){return this.el_}createEl(e,t,i){return o(e,t,i)}localize(e,s,t=e){var i=this.player_.language&&this.player_.language(),r=this.player_.languages&&this.player_.languages(),n=r&&r[i],i=i&&i.split("-")[0],r=r&&r[i];let a=t;return n&&n[e]?a=n[e]:r&&r[e]&&(a=r[e]),a=s?a.replace(/\{(\d+)\}/g,function(e,t){t=s[t-1];let i="undefined"==typeof t?e:t;return i}):a}handleLanguagechange(){}contentEl(){return this.contentEl_||this.el_}id(){return this.id_}name(){return this.name_}children(){return this.children_}getChildById(e){return this.childIndex_[e]}getChild(e){if(e)return this.childNameIndex_[e]}getDescendant(...t){t=t.reduce((e,t)=>e.concat(t),[]);let i=this;for(let e=0;e<t.length;e++)if(!(i=i.getChild(t[e]))||!i.getChild)return;return i}addChild(e,t={},i=this.children_.length){let s,r;if("string"==typeof e){r=g(e);var n=t.componentClass||r,a=(t.name=r,f.getComponent(n));if(!a)throw new Error(`Component ${n} does not exist`);if("function"!=typeof a)return null;s=new a(this.player_||this,t)}else s=e;if(s.parentComponent_&&s.parentComponent_.removeChild(s),this.children_.splice(i,0,s),s.parentComponent_=this,"function"==typeof s.id&&(this.childIndex_[s.id()]=s),(r=r||s.name&&g(s.name()))&&(this.childNameIndex_[r]=s,this.childNameIndex_[At(r)]=s),"function"==typeof s.el&&s.el()){let e=null;this.children_[i+1]&&(this.children_[i+1].el_?e=this.children_[i+1].el_:ve(this.children_[i+1])&&(e=this.children_[i+1])),this.contentEl().insertBefore(s.el(),e)}return s}removeChild(i){if((i="string"==typeof i?this.getChild(i):i)&&this.children_){let t=!1;for(let e=this.children_.length-1;0<=e;e--)if(this.children_[e]===i){t=!0,this.children_.splice(e,1);break}var e;t&&(i.parentComponent_=null,this.childIndex_[i.id()]=null,this.childNameIndex_[g(i.name())]=null,this.childNameIndex_[At(i.name())]=null,e=i.el())&&e.parentNode===this.contentEl()&&this.contentEl().removeChild(i.el())}}initChildren(){const s=this.options_.children;if(s){const r=this.options_;let e;const t=f.getComponent("Tech");(e=Array.isArray(s)?s:Object.keys(s)).concat(Object.keys(this.options_).filter(function(t){return!e.some(function(e){return"string"==typeof e?t===e:t===e.name})})).map(e=>{let t,i;return i="string"==typeof e?(t=e,s[t]||this.options_[t]||{}):(t=e.name,e),{name:t,opts:i}}).filter(e=>{e=f.getComponent(e.opts.componentClass||g(e.name));return e&&!t.isTech(e)}).forEach(e=>{var t=e.name;let i=e.opts;!1!==(i=void 0!==r[t]?r[t]:i)&&((i=!0===i?{}:i).playerOptions=this.options_.playerOptions,e=this.addChild(t,i))&&(this[t]=e)})}}buildCSSClass(){return""}ready(e,t=!1){e&&(this.isReady_?t?e.call(this):this.setTimeout(e,1):(this.readyQueue_=this.readyQueue_||[],this.readyQueue_.push(e)))}triggerReady(){this.isReady_=!0,this.setTimeout(function(){var e=this.readyQueue_;this.readyQueue_=[],e&&0<e.length&&e.forEach(function(e){e.call(this)},this),this.trigger("ready")},1)}$(e,t){return $e(e,t||this.contentEl())}$$(e,t){return We(e,t||this.contentEl())}hasClass(e){return Ee(this.el_,e)}addClass(...e){ke(this.el_,...e)}removeClass(...e){Ce(this.el_,...e)}toggleClass(e,t){Ie(this.el_,e,t)}show(){this.removeClass("vjs-hidden")}hide(){this.addClass("vjs-hidden")}lockShowing(){this.addClass("vjs-lock-showing")}unlockShowing(){this.removeClass("vjs-lock-showing")}getAttribute(e){return Pe(this.el_,e)}setAttribute(e,t){Le(this.el_,e,t)}removeAttribute(e){Oe(this.el_,e)}width(e,t){return this.dimension("width",e,t)}height(e,t){return this.dimension("height",e,t)}dimensions(e,t){this.width(e,!0),this.height(t)}dimension(e,t,i){var s,r;if(void 0===t)return this.el_?-1!==(r=(s=this.el_.style[e]).indexOf("px"))?parseInt(s.slice(0,r),10):parseInt(this.el_["offset"+g(e)],10):0;-1!==(""+(t=null!==t&&t==t?t:0)).indexOf("%")||-1!==(""+t).indexOf("px")?this.el_.style[e]=t:this.el_.style[e]="auto"===t?"":t+"px",i||this.trigger("componentresize")}currentDimension(e){let t=0;if("width"!==e&&"height"!==e)throw new Error("currentDimension only accepts width or height value");return t=Ge(this.el_,e),0!==(t=parseFloat(t))&&!isNaN(t)||(e="offset"+g(e),t=this.el_[e]),t}currentDimensions(){return{width:this.currentDimension("width"),height:this.currentDimension("height")}}currentWidth(){return this.currentDimension("width")}currentHeight(){return this.currentDimension("height")}focus(){this.el_.focus()}blur(){this.el_.blur()}handleKeyDown(e){this.player_&&(r.isEventKey(e,"Tab")||e.stopPropagation(),this.player_.handleKeyDown(e))}handleKeyPress(e){this.handleKeyDown(e)}emitTapEvents(){let t=0,i=null;let s;this.on("touchstart",function(e){1===e.touches.length&&(i={pageX:e.touches[0].pageX,pageY:e.touches[0].pageY},t=window.performance.now(),s=!0)}),this.on("touchmove",function(e){var t;(1<e.touches.length||i&&(t=e.touches[0].pageX-i.pageX,e=e.touches[0].pageY-i.pageY,10<Math.sqrt(t*t+e*e)))&&(s=!1)});function e(){s=!1}this.on("touchleave",e),this.on("touchcancel",e),this.on("touchend",function(e){!(i=null)===s&&window.performance.now()-t<200&&(e.preventDefault(),this.trigger("tap"))})}enableTouchActivity(){if(this.player()&&this.player().reportUserActivity){const i=m(this.player(),this.player().reportUserActivity);let t;this.on("touchstart",function(){i(),this.clearInterval(t),t=this.setInterval(i,250)});var e=function(e){i(),this.clearInterval(t)};this.on("touchmove",i),this.on("touchend",e),this.on("touchcancel",e)}}setTimeout(e,t){var i;return e=m(this,e),this.clearTimersOnDispose_(),i=window.setTimeout(()=>{this.setTimeoutIds_.has(i)&&this.setTimeoutIds_.delete(i),e()},t),this.setTimeoutIds_.add(i),i}clearTimeout(e){return this.setTimeoutIds_.has(e)&&(this.setTimeoutIds_.delete(e),window.clearTimeout(e)),e}setInterval(e,t){e=m(this,e),this.clearTimersOnDispose_();e=window.setInterval(e,t);return this.setIntervalIds_.add(e),e}clearInterval(e){return this.setIntervalIds_.has(e)&&(this.setIntervalIds_.delete(e),window.clearInterval(e)),e}requestAnimationFrame(e){var t;return this.clearTimersOnDispose_(),e=m(this,e),t=window.requestAnimationFrame(()=>{this.rafIds_.has(t)&&this.rafIds_.delete(t),e()}),this.rafIds_.add(t),t}requestNamedAnimationFrame(e,t){var i;if(!this.namedRafs_.has(e))return this.clearTimersOnDispose_(),t=m(this,t),i=this.requestAnimationFrame(()=>{t(),this.namedRafs_.has(e)&&this.namedRafs_.delete(e)}),this.namedRafs_.set(e,i),e}cancelNamedAnimationFrame(e){this.namedRafs_.has(e)&&(this.cancelAnimationFrame(this.namedRafs_.get(e)),this.namedRafs_.delete(e))}cancelAnimationFrame(e){return this.rafIds_.has(e)&&(this.rafIds_.delete(e),window.cancelAnimationFrame(e)),e}clearTimersOnDispose_(){this.clearingTimersOnDispose_||(this.clearingTimersOnDispose_=!0,this.one("dispose",()=>{[["namedRafs_","cancelNamedAnimationFrame"],["rafIds_","cancelAnimationFrame"],["setTimeoutIds_","clearTimeout"],["setIntervalIds_","clearInterval"]].forEach(([e,i])=>{this[e].forEach((e,t)=>this[i](t))}),this.clearingTimersOnDispose_=!1}))}static registerComponent(t,e){if("string"!=typeof t||!t)throw new Error(`Illegal component name, "${t}"; must be a non-empty string.`);var i=f.getComponent("Tech"),i=i&&i.isTech(e),s=f===e||f.prototype.isPrototypeOf(e.prototype);if(i||!s){let e;throw e=i?"techs must be registered using Tech.registerTech()":"must be a Component subclass",new Error(`Illegal component, "${t}"; ${e}.`)}t=g(t),f.components_||(f.components_={});s=f.getComponent("Player");if("Player"===t&&s&&s.players){const r=s.players;i=Object.keys(r);if(r&&0<i.length&&i.map(e=>r[e]).every(Boolean))throw new Error("Can not register Player component after player has been created.")}return f.components_[t]=e,f.components_[At(t)]=e}static getComponent(e){if(e&&f.components_)return f.components_[e]}}function Nt(e,t,i,s){var r=s,n=i.length-1;if("number"!=typeof r||r<0||n<r)throw new Error(`Failed to execute '${e}' on 'TimeRanges': The index provided (${r}) is non-numeric or out of bounds (0-${n}).`);return i[s][t]}function Mt(e){let t;return t=void 0===e||0===e.length?{length:0,start(){throw new Error("This TimeRanges object is empty")},end(){throw new Error("This TimeRanges object is empty")}}:{length:e.length,start:Nt.bind(null,"start",0,e),end:Nt.bind(null,"end",1,e)},window.Symbol&&window.Symbol.iterator&&(t[window.Symbol.iterator]=()=>(e||[]).values()),t}function Rt(e,t){return Array.isArray(e)?Mt(e):void 0===e||void 0===t?Mt():Mt([[e,t]])}f.registerComponent("Component",f);function Ut(e,t){e=e<0?0:e;let i=Math.floor(e%60),s=Math.floor(e/60%60),r=Math.floor(e/3600);var n=Math.floor(t/60%60),t=Math.floor(t/3600);return r=0<(r=!isNaN(e)&&e!==1/0?r:s=i="-")||0<t?r+":":"",s=((r||10<=n)&&s<10?"0"+s:s)+":",i=i<10?"0"+i:i,r+s+i}let Bt=Ut;function Ft(e){Bt=e}function jt(){Bt=Ut}function Ht(e,t=e){return Bt(e,t)}var qt=Object.freeze({__proto__:null,createTimeRanges:Rt,createTimeRange:Rt,setFormatTime:Ft,resetFormatTime:jt,formatTime:Ht});function Vt(t,i){let s=0;var r;let n;if(!i)return 0;t&&t.length||(t=Rt(0,0));for(let e=0;e<t.length;e++)r=t.start(e),(n=t.end(e))>i&&(n=i),s+=n-r;return s/i}function i(e){if(e instanceof i)return e;"number"==typeof e?this.code=e:"string"==typeof e?this.message=e:K(e)&&("number"==typeof e.code&&(this.code=e.code),Object.assign(this,e)),this.message||(this.message=i.defaultMessages[this.code]||"")}i.prototype.code=0,i.prototype.message="",i.prototype.status=null,i.errorTypes=["MEDIA_ERR_CUSTOM","MEDIA_ERR_ABORTED","MEDIA_ERR_NETWORK","MEDIA_ERR_DECODE","MEDIA_ERR_SRC_NOT_SUPPORTED","MEDIA_ERR_ENCRYPTED"],i.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail part-way.",3:"The media playback was aborted due to a corruption problem or because the media used features your browser did not support.",4:"The media could not be loaded, either because the server or network failed or because the format is not supported.",5:"The media is encrypted and we do not have the keys to decrypt it."};for(let e=0;e<i.errorTypes.length;e++)i[i.errorTypes[e]]=e,i.prototype[i.errorTypes[e]]=e;var $t=function(e,t){var i,s=null;try{i=JSON.parse(e,t)}catch(e){s=e}return[s,i]};function Wt(e){return null!=e&&"function"==typeof e.then}function Gt(e){Wt(e)&&e.then(null,e=>{})}function zt(s){return["kind","label","language","id","inBandMetadataTrackDispatchType","mode","src"].reduce((e,t,i)=>(s[t]&&(e[t]=s[t]),e),{cues:s.cues&&Array.prototype.map.call(s.cues,function(e){return{startTime:e.startTime,endTime:e.endTime,text:e.text,id:e.id}})})}var Xt=function(e){var t=e.$$("track");const i=Array.prototype.map.call(t,e=>e.track);return Array.prototype.map.call(t,function(e){var t=zt(e.track);return e.src&&(t.src=e.src),t}).concat(Array.prototype.filter.call(e.textTracks(),function(e){return-1===i.indexOf(e)}).map(zt))},Kt=function(e,i){return e.forEach(function(e){const t=i.addRemoteTextTrack(e).track;!e.src&&e.cues&&e.cues.forEach(e=>t.addCue(e))}),i.textTracks()};zt;const Yt="vjs-modal-dialog";class Qt extends f{constructor(e,t){super(e,t),this.handleKeyDown_=e=>this.handleKeyDown(e),this.close_=e=>this.close(e),this.opened_=this.hasBeenOpened_=this.hasBeenFilled_=!1,this.closeable(!this.options_.uncloseable),this.content(this.options_.content),this.contentEl_=o("div",{className:Yt+"-content"},{role:"document"}),this.descEl_=o("p",{className:Yt+"-description vjs-control-text",id:this.el().getAttribute("aria-describedby")}),Se(this.descEl_,this.description()),this.el_.appendChild(this.descEl_),this.el_.appendChild(this.contentEl_)}createEl(){return super.createEl("div",{className:this.buildCSSClass(),tabIndex:-1},{"aria-describedby":this.id()+"_description","aria-hidden":"true","aria-label":this.label(),role:"dialog"})}dispose(){this.contentEl_=null,this.descEl_=null,this.previouslyActiveEl_=null,super.dispose()}buildCSSClass(){return Yt+" vjs-hidden "+super.buildCSSClass()}label(){return this.localize(this.options_.label||"Modal Window")}description(){let e=this.options_.description||this.localize("This is a modal window.");return this.closeable()&&(e+=" "+this.localize("This modal can be closed by pressing the Escape key or activating the close button.")),e}open(){var e;this.opened_||(e=this.player(),this.trigger("beforemodalopen"),this.opened_=!0,!this.options_.fillAlways&&(this.hasBeenOpened_||this.hasBeenFilled_)||this.fill(),this.wasPlaying_=!e.paused(),this.options_.pauseOnOpen&&this.wasPlaying_&&e.pause(),this.on("keydown",this.handleKeyDown_),this.hadControls_=e.controls(),e.controls(!1),this.show(),this.conditionalFocus_(),this.el().setAttribute("aria-hidden","false"),this.trigger("modalopen"),this.hasBeenOpened_=!0)}opened(e){return"boolean"==typeof e&&this[e?"open":"close"](),this.opened_}close(){var e;this.opened_&&(e=this.player(),this.trigger("beforemodalclose"),this.opened_=!1,this.wasPlaying_&&this.options_.pauseOnOpen&&e.play(),this.off("keydown",this.handleKeyDown_),this.hadControls_&&e.controls(!0),this.hide(),this.el().setAttribute("aria-hidden","true"),this.trigger("modalclose"),this.conditionalBlur_(),this.options_.temporary)&&this.dispose()}closeable(t){if("boolean"==typeof t){var i,t=this.closeable_=!!t;let e=this.getChild("closeButton");t&&!e&&(i=this.contentEl_,this.contentEl_=this.el_,e=this.addChild("closeButton",{controlText:"Close Modal Dialog"}),this.contentEl_=i,this.on(e,"close",this.close_)),!t&&e&&(this.off(e,"close",this.close_),this.removeChild(e),e.dispose())}return this.closeable_}fill(){this.fillWith(this.content())}fillWith(e){var t=this.contentEl(),i=t.parentNode,s=t.nextSibling,e=(this.trigger("beforemodalfill"),this.hasBeenFilled_=!0,i.removeChild(t),this.empty(),qe(t,e),this.trigger("modalfill"),s?i.insertBefore(t,s):i.appendChild(t),this.getChild("closeButton"));e&&i.appendChild(e.el_)}empty(){this.trigger("beforemodalempty"),Fe(this.contentEl()),this.trigger("modalempty")}content(e){return"undefined"!=typeof e&&(this.content_=e),this.content_}conditionalFocus_(){var e=document.activeElement,t=this.player_.el_;this.previouslyActiveEl_=null,!t.contains(e)&&t!==e||(this.previouslyActiveEl_=e,this.focus())}conditionalBlur_(){this.previouslyActiveEl_&&(this.previouslyActiveEl_.focus(),this.previouslyActiveEl_=null)}handleKeyDown(e){if(e.stopPropagation(),r.isEventKey(e,"Escape")&&this.closeable())e.preventDefault(),this.close();else if(r.isEventKey(e,"Tab")){var i=this.focusableEls_(),s=this.el_.querySelector(":focus");let t;for(let e=0;e<i.length;e++)if(s===i[e]){t=e;break}document.activeElement===this.el_&&(t=0),e.shiftKey&&0===t?(i[i.length-1].focus(),e.preventDefault()):e.shiftKey||t!==i.length-1||(i[0].focus(),e.preventDefault())}}focusableEls_(){var e=this.el_.querySelectorAll("*");return Array.prototype.filter.call(e,e=>(e instanceof window.HTMLAnchorElement||e instanceof window.HTMLAreaElement)&&e.hasAttribute("href")||(e instanceof window.HTMLInputElement||e instanceof window.HTMLSelectElement||e instanceof window.HTMLTextAreaElement||e instanceof window.HTMLButtonElement)&&!e.hasAttribute("disabled")||e instanceof window.HTMLIFrameElement||e instanceof window.HTMLObjectElement||e instanceof window.HTMLEmbedElement||e.hasAttribute("tabindex")&&-1!==e.getAttribute("tabindex")||e.hasAttribute("contenteditable"))}}Qt.prototype.options_={pauseOnOpen:!0,temporary:!0},f.registerComponent("ModalDialog",Qt);class Jt extends ft{constructor(t=[]){super(),this.tracks_=[],Object.defineProperty(this,"length",{get(){return this.tracks_.length}});for(let e=0;e<t.length;e++)this.addTrack(t[e])}addTrack(e){const t=this.tracks_.length;""+t in this||Object.defineProperty(this,t,{get(){return this.tracks_[t]}}),-1===this.tracks_.indexOf(e)&&(this.tracks_.push(e),this.trigger({track:e,type:"addtrack",target:this})),e.labelchange_=()=>{this.trigger({track:e,type:"labelchange",target:this})},_t(e)&&e.addEventListener("labelchange",e.labelchange_)}removeTrack(i){let s;for(let e=0,t=this.length;e<t;e++)if(this[e]===i){(s=this[e]).off&&s.off(),this.tracks_.splice(e,1);break}s&&this.trigger({track:s,type:"removetrack",target:this})}getTrackById(i){let s=null;for(let e=0,t=this.length;e<t;e++){var r=this[e];if(r.id===i){s=r;break}}return s}}for(const Nu in Jt.prototype.allowedEvents_={change:"change",addtrack:"addtrack",removetrack:"removetrack",labelchange:"labelchange"})Jt.prototype["on"+Nu]=null;function Zt(t,i){for(let e=0;e<t.length;e++)Object.keys(t[e]).length&&i.id!==t[e].id&&(t[e].enabled=!1)}function ei(t,i){for(let e=0;e<t.length;e++)Object.keys(t[e]).length&&i.id!==t[e].id&&(t[e].selected=!1)}class ti extends Jt{addTrack(e){super.addTrack(e),this.queueChange_||(this.queueChange_=()=>this.queueTrigger("change")),this.triggerSelectedlanguagechange||(this.triggerSelectedlanguagechange_=()=>this.trigger("selectedlanguagechange")),e.addEventListener("modechange",this.queueChange_);-1===["metadata","chapters"].indexOf(e.kind)&&e.addEventListener("modechange",this.triggerSelectedlanguagechange_)}removeTrack(e){super.removeTrack(e),e.removeEventListener&&(this.queueChange_&&e.removeEventListener("modechange",this.queueChange_),this.selectedlanguagechange_)&&e.removeEventListener("modechange",this.triggerSelectedlanguagechange_)}}class ii{constructor(e){ii.prototype.setCues_.call(this,e),Object.defineProperty(this,"length",{get(){return this.length_}})}setCues_(e){var t=this.length||0;let i=0;function s(e){""+e in this||Object.defineProperty(this,""+e,{get(){return this.cues_[e]}})}var r=e.length;this.cues_=e,this.length_=e.length;if(t<r)for(i=t;i<r;i++)s.call(this,i)}getCueById(i){let s=null;for(let e=0,t=this.length;e<t;e++){var r=this[e];if(r.id===i){s=r;break}}return s}}const si={alternative:"alternative",captions:"captions",main:"main",sign:"sign",subtitles:"subtitles",commentary:"commentary"},ri={alternative:"alternative",descriptions:"descriptions",main:"main","main-desc":"main-desc",translation:"translation",commentary:"commentary"}
3786,ni={subtitles:"subtitles",captions:"captions",descriptions:"descriptions",chapters:"chapters",metadata:"metadata"},ai={disabled:"disabled",hidden:"hidden",showing:"showing"};class oi extends ft{constructor(e={}){super();const t={id:e.id||"vjs_track_"+tt++,kind:e.kind||"",language:e.language||""};let i=e.label||"";for(const s in t)Object.defineProperty(this,s,{get(){return t[s]},set(){}});Object.defineProperty(this,"label",{get(){return i},set(e){e!==i&&(i=e,this.trigger("labelchange"))}})}}function li(e){var t=["protocol","hostname","port","pathname","search","hash","host"],i=document.createElement("a"),s=(i.href=e,{});for(let e=0;e<t.length;e++)s[t[e]]=i[t[e]];return"http:"===s.protocol&&(s.host=s.host.replace(/:80$/,"")),"https:"===s.protocol&&(s.host=s.host.replace(/:443$/,"")),s.protocol||(s.protocol=window.location.protocol),s.host||(s.host=window.location.host),s}function di(e){var t;return e.match(/^https?:\/\//)||((t=document.createElement("a")).href=e,e=t.href),e}function hi(e,t=window.location){return(":"===(e=li(e)).protocol?t:e).protocol+e.host!==t.protocol+t.host}const ui=function(e){if("string"==typeof e){e=/^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.([^\.\/\?]+)))(?:[\/]*|[\?].*)$/.exec(e);if(e)return e.pop().toLowerCase()}return""};var ci=Object.freeze({__proto__:null,parseUrl:li,getAbsoluteURL:di,getFileExtension:ui,isCrossOrigin:hi}),pi="undefined"!=typeof window?window:"undefined"!=typeof Ot?Ot:"undefined"!=typeof self?self:{},mi=pi,gi=Dt(function(e){function t(){return e.exports=t=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i,s=arguments[t];for(i in s)Object.prototype.hasOwnProperty.call(s,i)&&(e[i]=s[i])}return e},e.exports.__esModule=!0,e.exports.default=e.exports,t.apply(this,arguments)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}),fi=(pi=gi)&&pi.__esModule&&Object.prototype.hasOwnProperty.call(pi,"default")?pi.default:pi,yi=function(e){var t;return!!e&&("[object Function]"===(t=_i.call(e))||"function"==typeof e&&"[object RegExp]"!==t||"undefined"!=typeof window&&(e===window.setTimeout||e===window.alert||e===window.confirm||e===window.prompt))},_i=Object.prototype.toString;ki.httpHandler=function(s,r){return void 0===r&&(r=!1),function(e,t,i){if(e)s(e);else if(400<=t.statusCode&&t.statusCode<=599){e=i;if(r)if(mi.TextDecoder){t=function(e){void 0===e&&(e="");return e.toLowerCase().split(";").reduce(function(e,t){var t=t.split("="),i=t[0],t=t[1];return"charset"===i.trim()?t.trim():e},"utf-8")}(t.headers&&t.headers["content-type"]);try{e=new TextDecoder(t).decode(i)}catch(e){}}else e=String.fromCharCode.apply(null,new Uint8Array(i));s({cause:e})}else s(null,i)}};for(var vi=function(e){var s={};return e&&e.trim().split("\n").forEach(function(e){var t=e.indexOf(":"),i=e.slice(0,t).trim().toLowerCase(),e=e.slice(t+1).trim();"undefined"==typeof s[i]?s[i]=e:Array.isArray(s[i])?s[i].push(e):s[i]=[s[i],e]}),s},bi=ki,pi=ki,Ti=(ki.XMLHttpRequest=mi.XMLHttpRequest||function(){},ki.XDomainRequest="withCredentials"in new ki.XMLHttpRequest?ki.XMLHttpRequest:mi.XDomainRequest,["get","put","post","patch","head","delete"]),Si=function(s){ki["delete"===s?"del":s]=function(e,t,i){return(t=Ei(e,t,i)).method=s.toUpperCase(),Ci(t)}},wi=0;wi<Ti.length;wi++)Si(Ti[wi]);function Ei(e,t,i){var s=e;return yi(t)?(i=t,"string"==typeof e&&(s={uri:e})):s=gi({},t,{uri:e}),s.callback=i,s}function ki(e,t,i){return Ci(t=Ei(e,t,i))}function Ci(s){if("undefined"==typeof s.callback)throw new Error("callback argument missing");var r=!1,n=function(e,t,i){r||(r=!0,s.callback(e,t,i))};function a(){var e=void 0,e=d.response||d.responseText||function(e){try{if("document"===e.responseType)return e.responseXML;var t=e.responseXML&&"parsererror"===e.responseXML.documentElement.nodeName;if(""===e.responseType&&!t)return e.responseXML}catch(e){}return null}(d);if(g)try{e=JSON.parse(e)}catch(e){}return e}function t(e){return clearTimeout(l),(e=e instanceof Error?e:new Error(""+(e||"Unknown XMLHttpRequest Error"))).statusCode=0,n(e,f)}function e(){var e,t,i;if(!o)return clearTimeout(l),e=s.useXDR&&void 0===d.status?200:1223===d.status?204:d.status,t=f,i=null,0!==e?(t={body:a(),statusCode:e,method:u,headers:{},url:h,rawRequest:d},d.getAllResponseHeaders&&(t.headers=vi(d.getAllResponseHeaders()))):i=new Error("Internal XMLHttpRequest Error"),n(i,t,t.body)}var i,o,l,d=s.xhr||null,h=(d=d||new(s.cors||s.useXDR?ki.XDomainRequest:ki.XMLHttpRequest)).url=s.uri||s.url,u=d.method=s.method||"GET",c=s.body||s.data,p=d.headers=s.headers||{},m=!!s.sync,g=!1,f={body:void 0,headers:{},statusCode:0,method:u,url:h,rawRequest:d};if("json"in s&&!1!==s.json&&(g=!0,p.accept||p.Accept||(p.Accept="application/json"),"GET"!==u)&&"HEAD"!==u&&(p["content-type"]||p["Content-Type"]||(p["Content-Type"]="application/json"),c=JSON.stringify(!0===s.json?c:s.json)),d.onreadystatechange=function(){4===d.readyState&&setTimeout(e,0)},d.onload=e,d.onerror=t,d.onprogress=function(){},d.onabort=function(){o=!0},d.ontimeout=t,d.open(u,h,!m,s.username,s.password),m||(d.withCredentials=!!s.withCredentials),!m&&0<s.timeout&&(l=setTimeout(function(){var e;o||(o=!0,d.abort("timeout"),(e=new Error("XMLHttpRequest timeout")).code="ETIMEDOUT",t(e))},s.timeout)),d.setRequestHeader)for(i in p)p.hasOwnProperty(i)&&d.setRequestHeader(i,p[i]);else if(s.headers&&!function(e){for(var t in e)if(e.hasOwnProperty(t))return;return 1}(s.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in s&&(d.responseType=s.responseType),"beforeSend"in s&&"function"==typeof s.beforeSend&&s.beforeSend(d),d.send(c||null),d}bi.default=pi;function Ii(e,t){var i=new window.WebVTT.Parser(window,window.vttjs,window.WebVTT.StringDecoder());const s=[];i.oncue=function(e){t.addCue(e)},i.onparsingerror=function(e){s.push(e)},i.onflush=function(){t.trigger({type:"loadeddata",target:t})},i.parse(e),0<s.length&&(window.console&&window.console.groupCollapsed&&window.console.groupCollapsed("Text Track parsing errors for "+t.src),s.forEac
vendor: 44,607 bytes, line 3786
3786h(e=>d.error(e)),window.console)&&window.console.groupEnd&&window.console.groupEnd(),i.flush()}function xi(e,s){var t={uri:e};(e=hi(e))&&(t.cors=e),(e="use-credentials"===s.tech_.crossOrigin())&&(t.withCredentials=e),bi(t,m(this,function(e,t,i){if(e)return d.error(e,t);s.loaded_=!0,"function"!=typeof window.WebVTT?s.tech_&&s.tech_.any(["vttjsloaded","vttjserror"],e=>{if("vttjserror"!==e.type)return Ii(i,s);d.error("vttjs failed to load, stopping trying to process "+s.src)}):Ii(i,s)}))}class Ai extends oi{constructor(e={}){if(!e.tech)throw new Error("A tech was not provided.");e=h(e,{kind:ni[e.kind]||"subtitles",language:e.language||e.srclang||""});let t=ai[e.mode]||"disabled";const i=e.default,s=("metadata"!==e.kind&&"chapters"!==e.kind||(t="hidden"),super(e),this.tech_=e.tech,this.cues_=[],this.activeCues_=[],this.preload_=!1!==this.tech_.preloadTextTracks,new ii(this.cues_)),n=new ii(this.activeCues_);let a=!1;this.timeupdateHandler=m(this,function(e={}){this.tech_.isDisposed()||(this.tech_.isReady_&&(this.activeCues=this.activeCues,a)&&(this.trigger("cuechange"),a=!1),"timeupdate"!==e.type&&(this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler)))});this.tech_.one("dispose",()=>{this.stopTracking()}),"disabled"!==t&&this.startTracking(),Object.defineProperties(this,{default:{get(){return i},set(){}},mode:{get(){return t},set(e){ai[e]&&t!==e&&(t=e,this.preload_||"disabled"===t||0!==this.cues.length||xi(this.src,this),this.stopTracking(),"disabled"!==t&&this.startTracking(),this.trigger("modechange"))}},cues:{get(){return this.loaded_?s:null},set(){}},activeCues:{get(){if(!this.loaded_)return null;if(0!==this.cues.length){var i=this.tech_.currentTime(),s=[];for(let e=0,t=this.cues.length;e<t;e++){var r=this.cues[e];r.startTime<=i&&r.endTime>=i&&s.push(r)}if(a=!1,s.length!==this.activeCues_.length)a=!0;else for(let e=0;e<s.length;e++)-1===this.activeCues_.indexOf(s[e])&&(a=!0);this.activeCues_=s,n.setCues_(this.activeCues_)}return n},set(){}}}),e.src?(this.src=e.src,this.preload_||(this.loaded_=!0),(this.preload_||"subtitles"!==e.kind&&"captions"!==e.kind)&&xi(this.src,this)):this.loaded_=!0}startTracking(){this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler),this.tech_.on("timeupdate",this.timeupdateHandler)}stopTracking(){this.rvf_&&(this.tech_.cancelVideoFrameCallback(this.rvf_),this.rvf_=void 0),this.tech_.off("timeupdate",this.timeupdateHandler)}addCue(e){let t=e;if(window.vttjs&&!(e instanceof window.vttjs.VTTCue)){t=new window.vttjs.VTTCue(e.startTime,e.endTime,e.text);for(const s in e)s in t||(t[s]=e[s]);t.id=e.id,t.originalCue_=e}var i=this.tech_.textTracks();for(let e=0;e<i.length;e++)i[e]!==this&&i[e].removeCue(t);this.cues_.push(t),this.cues.setCues_(this.cues_)}removeCue(e){let t=this.cues_.length;for(;t--;){var i=this.cues_[t];if(i===e||i.originalCue_&&i.originalCue_===e){this.cues_.splice(t,1),this.cues.setCues_(this.cues_);break}}}}Ai.prototype.allowedEvents_={cuechange:"cuechange"};class Pi extends oi{constructor(e={}){e=h(e,{kind:ri[e.kind]||""});super(e);let t=!1;Object.defineProperty(this,"enabled",{get(){return t},set(e){"boolean"==typeof e&&e!==t&&(t=e,this.trigger("enabledchange"))}}),e.enabled&&(this.enabled=e.enabled),this.loaded_=!0}}class Li extends oi{constructor(e={}){e=h(e,{kind:si[e.kind]||""});super(e);let t=!1;Object.defineProperty(this,"selected",{get(){return t},set(e){"boolean"==typeof e&&e!==t&&(t=e,this.trigger("selectedchange"))}}),e.selected&&(this.selected=e.selected)}}class Oi extends ft{constructor(e={}){super();let t;const i=new Ai(e);this.kind=i.kind,this.src=i.src,this.srclang=i.language,this.label=i.label,this.default=i.default,Object.defineProperties(this,{readyState:{get(){return t}},track:{get(){return i}}}),t=Oi.NONE,i.addEventListener("loadeddata",()=>{t=Oi.LOADED,this.trigger({type:"load",target:this})})}}Oi.prototype.allowedEvents_={load:"load"},Oi.NONE=0,Oi.LOADING=1,Oi.LOADED=2,Oi.ERROR=3;const Di={audio:{ListClass:class extends Jt{constructor(t=[]){for(let e=t.length-1;0<=e;e--)if(t[e].enabled){Zt(t,t[e]);break}super(t),this.changing_=!1}addTrack(e){e.enabled&&Zt(this,e),super.addTrack(e),e.addEventListener&&(e.enabledChange_=()=>{this.changing_||(this.changing_=!0,Zt(this,e),this.changing_=!1,this.trigger("change"))},e.addEventListener("enabledchange",e.enabledChange_))}removeTrack(e){super.removeTrack(e),e.removeEventListener&&e.enabledChange_&&(e.removeEventListener("enabledchange",e.enabledChange_),e.enabledChange_=null)}},TrackClass:Pi,capitalName:"Audio"},video:{ListClass:class extends Jt{constructor(t=[]){for(let e=t.length-1;0<=e;e--)if(t[e].selected){ei(t,t[e]);break}super(t),this.changing_=!1,Object.defineProperty(this,"selectedIndex",{get(){for(let e=0;e<this.length;e++)if(this[e].selected)return e;return-1},set(){}})}addTrack(e){e.selected&&ei(this,e),super.addTrack(e),e.addEventListener&&(e.selectedChange_=()=>{this.changing_||(this.changing_=!0,ei(this,e),this.changing_=!1,this.trigger("change"))},e.addEventListener("selectedchange",e.selectedChange_))}removeTrack(e){super.removeTrack(e),e.removeEventListener&&e.selectedChange_&&(e.removeEventListener("selectedchange",e.selectedChange_),e.selectedChange_=null)}},TrackClass:Li,capitalName:"Video"},text:{ListClass:ti,TrackClass:Ai,capitalName:"Text"}},Ni=(Object.keys(Di).forEach(function(e){Di[e].getterName=e+"Tracks",Di[e].privateName=e+"Tracks_"}),{remoteText:{ListClass:ti,TrackClass:Ai,capitalName:"RemoteText",getterName:"remoteTextTracks",privateName:"remoteTextTracks_"},remoteTextEl:{ListClass:class{constructor(i=[]){this.trackElements_=[],Object.defineProperty(this,"length",{get(){return this.trackElements_.length}});for(let e=0,t=i.length;e<t;e++)this.addTrackElement_(i[e])}addTrackElement_(e){const t=this.trackElements_.length;""+t in this||Object.defineProperty(this,t,{get(){return this.trackElements_[t]}}),-1===this.trackElements_.indexOf(e)&&this.trackElements_.push(e)}getTrackElementByTrack_(i){let s;for(let e=0,t=this.trackElements_.length;e<t;e++)if(i===this.trackElements_[e].track){s=this.trackElements_[e];break}return s}removeTrackElement_(i){for(let e=0,t=this.trackElements_.length;e<t;e++)if(i===this.trackElements_[e]){this.trackElements_[e].track&&"function"==typeof this.trackElements_[e].track.off&&this.trackElements_[e].track.off(),"function"==typeof this.trackElements_[e].off&&this.trackElements_[e].off(),this.trackElements_.splice(e,1);break}}},TrackClass:Oi,capitalName:"RemoteTextTrackEls",getterName:"remoteTextTrackEls",privateName:"remoteTextTrackEls_"}}),a=Object.assign({},Di,Ni);Ni.names=Object.keys(Ni),Di.names=Object.keys(Di),a.names=[].concat(Ni.names).concat(Di.names);var pi="undefined"!=typeof Ot?Ot:"undefined"!=typeof window?window:{},Mi="undefined"!=typeof document?document:(Mi=pi["__GLOBAL_DOCUMENT_CACHE@4"])||(pi["__GLOBAL_DOCUMENT_CACHE@4"]={}),Ot=Mi,Ri=Object.create||function(e){if(1!==arguments.length)throw new Error("Object.create shim only accepts one parameter.");return Ui.prototype=e,new Ui};function Ui(){}function Bi(e,t){this.name="ParsingError",this.code=e.code,this.message=t||e.message}function Fi(e){function t(e,t,i,s){return 3600*(0|e)+60*(0|t)+(0|i)+(0|s)/1e3}e=e.match(/^(\d+):(\d{1,2})(:\d{1,2})?\.(\d{3})/);return e?e[3]?t(e[1],e[2],e[3].replace(":",""),e[4]):59<e[1]?t(e[1],e[2],0,e[4]):t(0,e[1],e[2],e[4]):null}function ji(){this.values=Ri(null)}function Hi(e,t,i,s){var r,n,a=s?e.split(s):[e];for(r in a)"string"==typeof a[r]&&2===(n=a[r].split(i)).length&&t(n[0].trim(),n[1].trim())}((Bi.prototype=Ri(Error.prototype)).constructor=Bi).Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}},ji.prototype={set:function(e,t){this.get(e)||""===t||(this.values[e]=t)},get:function(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t},has:function(e){return e in this.values},alt:function(e,t,i){for(var s=0;s<i.length;++s)if(t===i[s]){this.set(e,t);break}},integer:function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},percent:function(e,t){return!!(t.match(/^([\d]{1,3})(\.[\d]*)?%$/)&&0<=(t=parseFloat(t))&&t<=100)&&(this.set(e,t),!0)}};var qi=Ot.createElement&&Ot.createElement("textarea"),Vi={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},$i={white:"rgba(255,255,255,1)",lime:"rgba(0,255,0,1)",cyan:"rgba(0,255,255,1)",red:"rgba(255,0,0,1)",yellow:"rgba(255,255,0,1)",magenta:"rgba(255,0,255,1)",blue:"rgba(0,0,255,1)",black:"rgba(0,0,0,1)"},Wi={v:"title",lang:"lang"},Gi={rt:"ruby"};function zi(e,t){for(var i,s,r,n,a,o,l=e.document.createElement("div"),d=l,h=[];null!==(o=void 0,o=t?(o=(o=t.match(/^([^<]*)(<[^>]*>?)?/))[1]||o[2],t=t.substr(o.length),o):null);)"<"===o[0]?"/"===o[1]?h.length&&h[h.length-1]===o.substr(2).replace(">","")&&(h.pop(),d=d.parentNode):(s=Fi(o.substr(1,o.length-2)))?(i=e.document.createProcessingInstruction("timestamp",s),d.appendChild(i)):(s=o.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/))&&(r=s[1],n=s[3],a=void 0,a=Vi[r],i=a?(a=e.document.createElement(a),(r=Wi[r])&&n&&(a[r]=n.trim()),a):null)&&(r=d,Gi[(n=i).localName]&&Gi[n.localName]!==r.localName||(s[2]&&((a=s[2].split(".")).forEach(function(e){var t=/^bg_/.test(e),e=t?e.slice(3):e;$i.hasOwnProperty(e)&&(e=$i[e],i.style[t?"background-color":"color"]=e)}),i.className=a.join(" ")),h.push(s[1]),d.appendChild(i),d=i)):d.appendChild(e.document.createTextNode((n=o,qi.innerHTML=n,n=qi.textContent,qi.textContent="",n)));return l}var Xi=[[1470,1470],[1472,1472],[1475,1475],[1478,1478],[1488,1514],[1520,1524],[1544,1544],[1547,1547],[1549,1549],[1563,1563],[1566,1610],[1645,1647],[1649,1749],[1765,1766],[1774,1775],[1786,1805],[1807,1808],[1810,1839],[1869,1957],[1969,1969],[1984,2026],[2036,2037],[2042,2042],[2048,2069],[2074,2074],[2084,2084],[2088,2088],[2096,2110],[2112,2136],[2142,2142],[2208,2208],[2210,2220],[8207,8207],[64285,64285],[64287,64296],[64298,64310],[64312,64316],[64318,64318],[64320,64321],[64323,64324],[64326,64449],[64467,64829],[64848,64911],[64914,64967],[65008,65020],[65136,65140],[65142,65276],[67584,67589],[67592,67592],[67594,67637],[67639,67640],[67644,67644],[67647,67669],[67671,67679],[67840,67867],[67872,67897],[67903,67903],[67968,68023],[68030,68031],[68096,68096],[68112,68115],[68117,68119],[68121,68147],[68160,68167],[68176,68184],[68192,68223],[68352,68405],[68416,68437],[68440,68466],[68472,68479],[68608,68680],[126464,126467],[126469,126495],[126497,126498],[126500,126500],[126503,126503],[126505,126514],[126516,126519],[126521,126521],[126523,126523],[126530,126530],[126535,126535],[126537,126537],[126539,126539],[126541,126543],[126545,126546],[126548,126548],[126551,126551],[126553,126553],[126555,126555],[126557,126557],[126559,126559],[126561,126562],[126564,126564],[126567,126570],[126572,126578],[126580,126583],[126585,126588],[126590,126590],[126592,126601],[126603,126619],[126625,126627],[126629,126633],[126635,126651],[1114109,1114109]];function Ki(e){var t=[],i="";if(e&&e.childNodes)for(n(t,e);i=function e(t){var i,s,r;return t&&t.length?(s=(i=t.pop()).textContent||i.innerText)?(r=s.match(/^.*(\n|\r)/))?r[t.length=0]:s:"ruby"===i.tagName?e(t):i.childNodes?(n(t,i),e(t)):void 0:null}(t);)for(var s=0;s<i.length;s++)if(function(e){for(var t=0;t<Xi.length;t++){var i=Xi[t];if(e>=i[0]&&e<=i[1])return 1}}(i.charCodeAt(s)))return"rtl";return"ltr";function n(e,t){for(var i=t.childNodes.length-1;0<=i;i--)e.push(t.childNodes[i])}}function Yi(){}function Qi(e,t,i){Yi.call(this),this.cue=t,this.cueDiv=zi(e,t.text);var s={color:"rgba(255, 255, 255, 1)",backgroundColor:"rgba(0, 0, 0, 0.8)",position:"relative",left:0,right:0,top:0,bottom:0,display:"inline",writingMode:""===t.vertical?"horizontal-tb":"lr"===t.vertical?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext"},r=(this.applyStyles(s,this.cueDiv),this.div=e.document.createElement("div"),s={direction:Ki(this.cueDiv),writingMode:""===t.vertical?"horizontal-tb":"lr"===t.vertical?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext",textAlign:"middle"===t.align?"center":t.align,font:i.font,whiteSpace:"pre-line",position:"absolute"},this.applyStyles(s),this.div.appendChild(this.cueDiv),0);switch(t.positionAlign){case"start":r=t.position;break;case"center":r=t.position-t.size/2;break;case"end":r=t.position-t.size}""===t.vertical?this.applyStyles({left:this.formatStyle(r,"%"),width:this.formatStyle(t.size,"%")}):this.applyStyles({top:this.formatStyle(r,"%"),height:this.formatStyle(t.size,"%")}),this.move=function(e){this.applyStyles({top:this.formatStyle(e.top,"px"),bottom:this.formatStyle(e.bottom,"px"),left:this.formatStyle(e.left,"px"),right:this.formatStyle(e.right,"px"),height:this.formatStyle(e.height,"px"),width:this.formatStyle(e.width,"px")})}}function y(e){var t,i,s,r;e.div&&(t=e.div.offsetHeight,i=e.div.offsetWidth,s=e.div.offsetTop,r=(r=(r=e.div.childNodes)&&r[0])&&r.getClientRects&&r.getClientRects(),e=e.div.getBoundingClientRect(),r=r?Math.max(r[0]&&r[0].height||0,e.height/r.length):0),this.left=e.left,this.right=e.right,this.top=e.top||s,this.height=e.height||t,this.bottom=e.bottom||s+(e.height||t),this.width=e.width||i,this.lineHeight=void 0!==r?r:e.lineHeight}function Ji(e,t,o,l){var i,s=new y(t),r=t.cue,n=function(e){if("number"==typeof e.line&&(e.snapToLines||0<=e.line&&e.line<=100))return e.line;if(!e.track||!e.track.textTrackList||!e.track.textTrackList.mediaElement)return-1;for(var t=e.track,i=t.textTrackList,s=0,r=0;r<i.length&&i[r]!==t;r++)"showing"===i[r].mode&&s++;return-1*++s}(r),a=[];if(r.snapToLines){switch(r.vertical){case"":a=["+y","-y"],i="height";break;case"rl":a=["+x","-x"],i="width";break;case"lr":a=["-x","+x"],i="width"}var d=s.lineHeight,h=d*Math.round(n),u=o[i]+d,c=a[0];Math.abs(h)>u&&(h=h<0?-1:1,h*=Math.ceil(u/d)*d),n<0&&(h+=""===r.vertical?o.height:o.width,a=a.reverse()),s.move(c,h)}else{var p=s.lineHeight/o.height*100;switch(r.lineAlign){case"center":n-=p/2;break;case"end":n-=p}switch(r.vertical){case"":t.applyStyles({top:t.formatStyle(n,"%")});break;case"rl":t.applyStyles({left:t.formatStyle(n,"%")});break;case"lr":t.applyStyles({right:t.formatStyle(n,"%")})}a=["+y","-x","+x","-y"],s=new y(t)}u=function(e,t){for(var i,s=new y(e),r=1,n=0;n<t.length;n++){for(;e.overlapsOppositeAxis(o,t[n])||e.within(o)&&e.overlapsAny(l);)e.move(t[n]);if(e.within(o))return e;var a=e.intersectPercentage(o);a<r&&(i=new y(e),r=a),e=new y(s)}return i||s}(s,a);t.move(u.toCSSCompatValues(o))}function Zi(){}Yi.prototype.applyStyles=function(e,t){for(var i in t=t||this.div,e)e.hasOwnProperty(i)&&(t.style[i]=e[i])},Yi.prototype.formatStyle=function(e,t){return 0===e?0:e+t},(Qi.prototype=Ri(Yi.prototype)).constructor=Qi,y.prototype.move=function(e,t){switch(t=void 0!==t?t:this.lineHeight,e){case"+x":this.left+=t,this.right+=t;break;case"-x":this.left-=t,this.right-=t;break;case"+y":this.top+=t,this.bottom+=t;break;case"-y":this.top-=t,this.bottom-=t}},y.prototype.overlaps=function(e){return this.left<e.right&&this.right>e.left&&this.top<e.bottom&&this.bottom>e.top},y.prototype.overlapsAny=function(e){for(var t=0;t<e.length;t++)if(this.overlaps(e[t]))return!0;return!1},y.prototype.within=function(e){return this.top>=e.top&&this.bottom<=e.bottom&&this.left>=e.left&&this.right<=e.right},y.prototype.overlapsOppositeAxis=function(e,t){switch(t){case"+x":return this.left<e.left;case"-x":return this.right>e.right;case"+y":return this.top<e.top;case"-y":return this.bottom>e.bottom}},y.prototype.intersectPercentage=function(e){return Math.max(0,Math.min(this.right,e.right)-Math.max(this.left,e.left))*Math.max(0,Math.min(this.bottom,e.bottom)-Math.max(this.top,e.top))/(this.height*this.width)},y.prototype.toCSSCompatValues=function(e){return{top:this.top-e.top,bottom:e.bottom-this.bottom,left:this.left-e.left,right:e.right-this.right,height:this.height,width:this.width}},y.getSimpleBoxPosition=function(e){var t=e.div?e.div.offsetHeight:e.tagName?e.offsetHeight:0,i=e.div?e.div.offsetWidth:e.tagName?e.offsetWidth:0,s=e.div?e.div.offsetTop:e.tagName?e.offsetTop:0;return{left:(e=e.div?e.div.getBoundingClientRect():e.tagName?e.getBoundingClientRect():e).left,right:e.right,top:e.top||s,height:e.height||t,bottom:e.bottom||s+(e.height||t),width:e.width||i}},Zi.StringDecoder=function(){return{decode:function(e){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}},Zi.convertCueToDOMTree=function(e,t){return e&&t?zi(e,t):null};Zi.processCues=function(e,t,i){if(!e||!t||!i)return null;for(;i.firstChild;)i.removeChild(i.firstChild);var s=e.document.createElement("div");if(s.style.position="absolute",s.style.left="0",s.style.right="0",s.style.top="0",s.style.bottom="0",s.style.margin="1.5%",i.appendChild(s),function(e){for(var t=0;t<e.length;t++)if(e[t].hasBeenReset||!e[t].displayState)return 1}(t))for(var r,n,a=[],o=y.getSimpleBoxPosition(s),l={font:Math.round(.05*o.height*100)/100+"px sans-serif"},d=0;d<t.length;d++)n=t[d],r=new Qi(e,n,l),s.appendChild(r.div),Ji(0,r,o,a),n.displayState=r.div,a.push(y.getSimpleBoxPosition(r));else for(var h=0;h<t.length;h++)s.appendChild(t[h].displayState)},(Zi.Parser=function(e,t,i){i||(i=t,t={}),t=t||{},this.window=e,this.vttjs=t,this.state="INITIAL",this.buffer="",this.decoder=i||new TextDecoder("utf8"),this.regionList=[]}).prototype={reportOrThrowError:function(e){if(!(e instanceof Bi))throw e;this.onparsingerror&&this.onparsingerror(e)},parse:function(e){var s=this;function t(){for(var e=s.buffer,t=0;t<e.length&&"\r"!==e[t]&&"\n"!==e[t];)++t;var i=e.substr(0,t);return"\r"===e[t]&&++t,"\n"===e[t]&&++t,s.buffer=e.substr(t),i}function i(e){e.match(/X-TIMESTAMP-MAP/)?Hi(e,function(e,t){var i;"X-TIMESTAMP-MAP"===e&&(e=t,i=new ji,Hi(e,function(e,t){switch(e){case"MPEGT":i.integer(e+"S",t);break;case"LOCA":i.set(e+"L",Fi(t))}},/[^\d]:/,/,/),s.ontimestampmap)&&s.ontimestampmap({MPEGTS:i.get("MPEGTS"),LOCAL:i.get("LOCAL")})},/=/):Hi(e,function(e,t){var r;"Region"===e&&(e=t,r=new ji,Hi(e,function(e,t){switch(e){case"id":r.set(e,t);break;case"width":r.percent(e,t);break;case"lines":r.integer(e,t);break;case"regionanchor":case"viewportanchor":var i,s=t.split(",");2===s.length&&((i=new ji).percent("x",s[0]),i.percent("y",s[1]),i.has("x")&&i.has("y"))&&(r.set(e+"X",i.get("x")),r.set(e+"Y",i.get("y")));break;case"scroll":r.alt(e,t,["up"])}},/=/,/\s/),r.has("id"))&&((e=new(s.vttjs.VTTRegion||s.window.VTTRegion)).width=r.get("width",100),e.lines=r.get("lines",3),e.regionAnchorX=r.get("regionanchorX",0),e.regionAnchorY=r.get("regionanchorY",100),e.viewportAnchorX=r.get("viewportanchorX",0),e.viewportAnchorY=r.get("viewportanchorY",100),e.scroll=r.get("scroll",""),s.onregion&&s.onregion(e),s.regionList.push({id:r.get("id"),region:e}))},/:/)}e&&(s.buffer+=s.decoder.decode(e,{stream:!0}));try{if("INITIAL"===s.state){if(!/\r\n|\n/.test(s.buffer))return this;var r,n=(r=t()).match(/^WEBVTT([ \t].*)?$/);if(!n||!n[0])throw new Bi(Bi.Errors.BadSignature);s.state="HEADER"}for(var a=!1;s.buffer;){if(!/\r\n|\n/.test(s.buffer))return this;switch(a?a=!1:r=t(),s.state){case"HEADER":/:/.test(r)?i(r):r||(s.state="ID");continue;case"NOTE":r||(s.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(r)){s.state="NOTE";break}if(!r)continue;s.cue=new(s.vttjs.VTTCue||s.window.VTTCue)(0,0,"");try{s.cue.align="center"}catch(e){s.cue.align="middle"}if(s.state="CUE",-1===r.indexOf("--\x3e")){s.cue.id=r;continue}case"CUE":try{!function(t,i,n){var s=t;function e(){var e=Fi(t);if(null===e)throw new Bi(Bi.Errors.BadTimeStamp,"Malformed timestamp: "+s);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function r(){t=t.replace(/^\s+/,"")}if(r(),i.startTime=e(),r(),"--\x3e"!==t.substr(0,3))throw new Bi(Bi.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '--\x3e'): "+s);t=t.substr(3),r(),i.endTime=e(),r();var a=t,o=new ji;Hi(a,function(e,t){switch(e){case"region":for(var i=n.length-1;0<=i;i--)if(n[i].id===t){o.set(e,n[i].region);break}break;case"vertical":o.alt(e,t,["rl","lr"]);break;case"line":var s=t.split(","),r=s[0];o.integer(e,r),o.percent(e,r)&&o.set("snapToLines",!1),o.alt(e,r,["auto"]),2===s.length&&o.alt("lineAlign",s[1],["start","center","end"]);break;case"position":s=t.split(","),o.percent(e,s[0]),2===s.length&&o.alt("positionAlign",s[1],["start","center","end"]);break;case"size":o.percent(e,t);break;case"align":o.alt(e,t,["start","center","end","left","right"])}},/:/,/\s/),i.region=o.get("region",null),i.vertical=o.get("vertical","");try{i.line=o.get("line","auto")}catch(e){}i.lineAlign=o.get("lineAlign","start"),i.snapToLines=o.get("snapToLines",!0),i.size=o.get("size",100);try{i.align=o.get("align","center")}catch(e){i.align=o.get("align","middle")}try{i.position=o.get("position","auto")}catch(e){i.position=o.get("position",{start:0,left:0,center:50,middle:50,end:100,right:100},i.align)}i.positionAlign=o.get("positionAlign",{start:"start",left:"start",center:"center",middle:"center",end:"end",right:"end"},i.align)}(r,s.cue,s.regionList)}catch(e){s.reportOrThrowError(e),s.cue=null,s.state="BADCUE";continue}s.state="CUETEXT";continue;case"CUETEXT":var o=-1!==r.indexOf("--\x3e");if(!r||o&&(a=!0)){s.oncue&&s.oncue(s.cue),s.cue=null,s.state="ID";continue}s.cue.text&&(s.cue.text+="\n"),s.cue.text+=r.replace(/\u2028/g,"\n").replace(/u2029/g,"\n");continue;case"BADCUE":r||(s.state="ID");continue}}}catch(e){s.reportOrThrowError(e),"CUETEXT"===s.state&&s.cue&&s.oncue&&s.oncue(s.cue),s.cue=null,s.state="INITIAL"===s.state?"BADWEBVTT":"BADCUE"}return this},flush:function(){var t=this;try{if(t.buffer+=t.decoder.decode(),!t.cue&&"HEADER"!==t.state||(t.buffer+="\n\n",t.parse()),"INITIAL"===t.state)throw new Bi(Bi.Errors.BadSignature)}catch(e){t.reportOrThrowError(e)}return t.onflush&&t.onflush(),this}};var es=Zi,ts={"":1,lr:1,rl:1},is={start:1,center:1,end:1,left:1,right:1,auto:1,"line-left":1,"line-right":1};function ss(e){return"string"==typeof e&&!!is[e.toLowerCase()]&&e.toLowerCase()}function rs(e,t,i){this.hasBeenReset=!1;var s="",r=!1,n=e,a=t,o=i,l=null,d="",h=!0,u="auto",c="start",p="auto",m="auto",g=100,f="center";Object.defineProperties(this,{id:{enumerable:!0,get:function(){return s},set:function(e){s=""+e}},pauseOnExit:{enumerable:!0,get:function(){return r},set:function(e){r=!!e}},startTime:{enumerable:!0,get:function(){return n},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");n=e,this.hasBeenReset=!0}},endTime:{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");a=e,this.hasBeenReset=!0}},text:{enumerable:!0,get:function(){return o},set:function(e){o=""+e,this.hasBeenReset=!0}},region:{enumerable:!0,get:function(){return l},set:function(e){l=e,this.hasBeenReset=!0}},vertical:{enumerable:!0,get:function(){return d},set:function(e){e="string"==typeof(e=e)&&!!ts[e.toLowerCase()]&&e.toLowerCase();if(!1===e)throw new SyntaxError("Vertical: an invalid or illegal direction string was specified.");d=e,this.hasBeenReset=!0}},snapToLines:{enumerable:!0,get:function(){return h},set:function(e){h=!!e,this.hasBeenReset=!0}},line:{enumerable:!0,get:function(){return u},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("Line: an invalid number or illegal string was specified.");u=e,this.hasBeenReset=!0}},lineAlign:{enumerable:!0,get:function(){return c},set:function(e){e=ss(e);e&&(c=e,this.hasBeenReset=!0)}},position:{enumerable:!0,get:function(){return p},set:function(e){if(e<0||100<e)throw new Error("Position must be between 0 and 100.");p=e,this.hasBeenReset=!0}},positionAlign:{enumerable:!0,get:function(){return m},set:function(e){e=ss(e);e&&(m=e,this.hasBeenReset=!0)}},size:{enumerable:!0,get:function(){return g},set:function(e){if(e<0||100<e)throw new Error("Size must be between 0 and 100.");g=e,this.hasBeenReset=!0}},align:{enumerable:!0,get:function(){return f},set:function(e){e=ss(e);if(!e)throw new SyntaxError("align: an invalid or illegal alignment string was specified.");f=e,this.hasBeenReset=!0}}}),this.displayState=void 0}rs.prototype.getCueAsHTML=function(){return WebVTT.convertCueToDOMTree(window,this.text)};var ns=rs,as={"":!0,up:!0};function os(e){return"number"==typeof e&&0<=e&&e<=100}function ls(){var t=100,i=3,s=0,r=100,n=0,a=100,o="";Object.defineProperties(this,{width:{enumerable:!0,get:function(){return t},set:function(e){if(!os(e))throw new Error("Width must be between 0 and 100.");t=e}},lines:{enumerable:!0,get:function(){return i},set:function(e){if("number"!=typeof e)throw new TypeError("Lines must be set to a number.");i=e}},regionAnchorY:{enumerable:!0,get:function(){return r},set:function(e){if(!os(e))throw new Error("RegionAnchorX must be between 0 and 100.");r=e}},regionAnchorX:{enumerable:!0,get:function(){return s},set:function(e){if(!os(e))throw new Error("RegionAnchorY must be between 0 and 100.");s=e}},viewportAnchorY:{enumerable:!0,get:function(){return a},set:function(e){if(!os(e))throw new Error("ViewportAnchorY must be between 0 and 100.");a=e}},viewportAnchorX:{enumerable:!0,get:function(){return n},set:function(e){if(!os(e))throw new Error("ViewportAnchorX must be between 0 and 100.");n=e}},scroll:{enumerable:!0,get:function(){return o},set:function(e){e="string"==typeof(e=e)&&!!as[e.toLowerCase()]&&e.toLowerCase();!1!==e&&(o=e)}}})}var ds=Dt(function(e){var e=e.exports={WebVTT:es,VTTCue:ns,VTTRegion:ls},t=(mi.vttjs=e,mi.WebVTT=e.WebVTT,e.VTTCue),i=e.VTTRegion,s=mi.VTTCue,r=mi.VTTRegion;e.shim=function(){mi.VTTCue=t,mi.VTTRegion=i},e.restore=function(){mi.VTTCue=s,mi.VTTRegion=r},mi.VTTCue||e.shim()});ds.WebVTT,ds.VTTCue,ds.VTTRegion;class _ extends f{constructor(t={},e=function(){}){t.reportTouchActivity=!1,super(null,t,e),this.onDurationChange_=e=>this.onDurationChange(e),this.trackProgress_=e=>this.trackProgress(e),this.trackCurrentTime_=e=>this.trackCurrentTime(e),this.stopTrackingCurrentTime_=e=>this.stopTrackingCurrentTime(e),this.disposeSourceHandler_=e=>this.disposeSourceHandler(e),this.queuedHanders_=new Set,this.hasStarted_=!1,this.on("playing",function(){this.hasStarted_=!0}),this.on("loadstart",function(){this.hasStarted_=!1}),a.names.forEach(e=>{e=a[e];t&&t[e.getterName]&&(this[e.privateName]=t[e.getterName])}),this.featuresProgressEvents||this.manualProgressOn(),this.featuresTimeupdateEvents||this.manualTimeUpdatesOn(),["Text","Audio","Video"].forEach(e=>{!1===t[`native${e}Tracks`]&&(this[`featuresNative${e}Tracks`]=!1)}),!1===t.nativeCaptions||!1===t.nativeTextTracks?this.featuresNativeTextTracks=!1:!0!==t.nativeCaptions&&!0!==t.nativeTextTracks||(this.featuresNativeTextTracks=!0),this.featuresNativeTextTracks||this.emulateTextTracks(),this.preloadTextTracks=!1!==t.preloadTextTracks,this.autoRemoteTextTracks_=new a.text.ListClass,this.initTrackListeners(),t.nativeControlsForTouch||this.emitTapEvents(),this.constructor&&(this.name_=this.constructor.name||"Unknown Tech")}triggerSourceset(e){this.isReady_||this.one("ready",()=>this.setTimeout(()=>this.triggerSourceset(e),1)),this.trigger({src:e,type:"sourceset"})}manualProgressOn(){this.on("durationchange",this.onDurationChange_),this.manualProgress=!0,this.one("ready",this.trackProgress_)}manualProgressOff(){this.manualProgress=!1,this.stopTrackingProgress(),this.off("durationchange",this.onDurationChange_)}trackProgress(e){this.stopTrackingProgress(),this.progressInterval=this.setInterval(m(this,function(){var e=this.bufferedPercent();this.bufferedPercent_!==e&&this.trigger("progress"),1===(this.bufferedPercent_=e)&&this.stopTrackingProgress()}),500)}onDurationChange(e){this.duration_=this.duration()}buffered(){return Rt(0,0)}bufferedPercent(){return Vt(this.buffered(),this.duration_)}stopTrackingProgress(){this.clearInterval(this.progressInterval)}manualTimeUpdatesOn(){this.manualTimeUpdates=!0,this.on("play",this.trackCurrentTime_),this.on("pause",this.stopTrackingCurrentTime_)}manualTimeUpdatesOff(){this.manualTimeUpdates=!1,this.stopTrackingCurrentTime(),this.off("play",this.trackCurrentTime_),this.off("pause",this.stopTrackingCurrentTime_)}trackCurrentTime(){this.currentTimeInterval&&this.stopTrackingCurrentTime(),this.currentTimeInterval=this.setInterval(function(){this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})},250)}stopTrackingCurrentTime(){this.clearInterval(this.currentTimeInterval),this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}dispose(){this.clearTracks(Di.names),this.manualProgress&&this.manualProgressOff(),this.manualTimeUpdates&&this.manualTimeUpdatesOff(),super.dispose()}clearTracks(e){(e=[].concat(e)).forEach(e=>{var t=this[e+"Tracks"]()||[];let i=t.length;for(;i--;){var s=t[i];"text"===e&&this.removeRemoteTextTrack(s),t.removeTrack(s)}})}cleanupAutoTextTracks(){var e=this.autoRemoteTextTracks_||[];let t=e.length;for(;t--;){var i=e[t];this.removeRemoteTextTrack(i)}}reset(){}crossOrigin(){}setCrossOrigin(){}error(e){return void 0!==e&&(this.error_=new i(e),this.trigger("error")),this.error_}played(){return this.hasStarted_?Rt(0,0):Rt()}play(){}setScrubbing(e){}scrubbing(){}setCurrentTime(e){this.manualTimeUpdates&&this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}initTrackListeners(){Di.names.forEach(e=>{var t=Di[e];const i=()=>{this.trigger(e+"trackchange")},s=this[t.getterName]();s.addEventListener("removetrack",i),s.addEventListener("addtrack",i),this.on("dispose",()=>{s.removeEventListener("removetrack",i),s.removeEventListener("addtrack",i)})})}addWebVttScript_(){if(!window.WebVTT)if(document.body.contains(this.el()))if(!this.options_["vtt.js"]&&Y(ds)&&0<Object.keys(ds).length)this.trigger("vttjsloaded");else{const e=document.createElement("script");e.src=this.options_["vtt.js"]||"https://vjs.zencdn.net/vttjs/0.14.1/vtt.min.js",e.onload=()=>{this.trigger("vttjsloaded")},e.onerror=()=>{this.trigger("vttjserror")},this.on("dispose",()=>{e.onload=null,e.onerror=null}),window.WebVTT=!0,this.el().parentNode.appendChild(e)}else this.ready(this.addWebVttScript_)}emulateTextTracks(){const i=this.textTracks(),e=this.remoteTextTracks(),t=e=>i.addTrack(e.track),s=e=>i.removeTrack(e.track),r=(e.on("addtrack",t),e.on("removetrack",s),this.addWebVttScript_(),()=>this.trigger("texttrackchange")),n=()=>{r();for(let e=0;e<i.length;e++){var t=i[e];t.removeEventListener("cuechange",r),"showing"===t.mode&&t.addEventListener("cuechange",r)}};n(),i.addEventListener("change",n),i.addEventListener("addtrack",n),i.addEventListener("removetrack",n),this.on("dispose",function(){e.off("addtrack",t),e.off("removetrack",s),i.removeEventListener("change",n),i.removeEventListener("addtrack",n),i.removeEventListener("removetrack",n);for(let e=0;e<i.length;e++)i[e].removeEventListener("cuechange",r)})}addTextTrack(e,t,i){if(e)return e=e,t=t,i=i,r={},n=(s=this).textTracks(),r.kind=e,t&&(r.label=t),i&&(r.language=i),r.tech=s,e=new a.text.TrackClass(r),n.addTrack(e),e;throw new Error("TextTrack kind is required but was not provided");var s,r,n}createRemoteTextTrack(e){e=h(e,{tech:this});return new Ni.remoteTextEl.TrackClass(e)}addRemoteTextTrack(e={},t){const i=this.createRemoteTextTrack(e);return"boolean"!=typeof t&&(t=!1),this.remoteTextTrackEls().addTrackElement_(i),this.remoteTextTracks().addTrack(i.track),!1===t&&this.ready(()=>this.autoRemoteTextTracks_.addTrack(i.track)),i}removeRemoteTextTrack(e){var t=this.remoteTextTrackEls().getTrackElementByTrack_(e);this.remoteTextTrackEls().removeTrackElement_(t),this.remoteTextTracks().removeTrack(e),this.autoRemoteTextTracks_.removeTrack(e)}getVideoPlaybackQuality(){return{}}requestPictureInPicture(){return Promise.reject()}disablePictureInPicture(){return!0}setDisablePictureInPicture(){}requestVideoFrameCallback(e){const t=tt++;return!this.isReady_||this.paused()?(this.queuedHanders_.add(t),this.one("playing",()=>{this.queuedHanders_.has(t)&&(this.queuedHanders_.delete(t),e())})):this.requestNamedAnimationFrame(t,e),t}cancelVideoFrameCallback(e){this.queuedHanders_.has(e)?this.queuedHanders_.delete(e):this.cancelNamedAnimationFrame(e)}setPoster(){}playsinline(){}setPlaysinline(){}overrideNativeAudioTracks(e){}overrideNativeVideoTracks(e){}canPlayType(e){return""}static canPlayType(e){return""}static canPlaySource(e,t){return _.canPlayType(e.type)}static isTech(e){return e.prototype instanceof _||e instanceof _||e===_}static registerTech(e,t){if(_.techs_||(_.techs_={}),!_.isTech(t))throw new Error(`Tech ${e} must be a Tech`);if(!_.canPlayType)throw new Error("Techs must have a static canPlayType method on them");if(_.canPlaySource)return e=g(e),_.techs_[e]=t,_.techs_[At(e)]=t,"Tech"!==e&&_.defaultTechOrder_.push(e),t;throw new Error("Techs must have a static canPlaySource method on them")}static getTech(e){if(e)return _.techs_&&_.techs_[e]?_.techs_[e]:(e=g(e),window&&window.videojs&&window.videojs[e]?(d.warn(`The ${e} tech was added to the videojs object when it should be registered using videojs.registerTech(name, tech)`),window.videojs[e]):void 0)}}a.names.forEach(function(e){const t=a[e];_.prototype[t.getterName]=function(){return this[t.privateName]=this[t.privateName]||new t.ListClass,this[t.privateName]}}),_.prototype.featuresVolumeControl=!0,_.prototype.featuresMuteControl=!0,_.prototype.featuresFullscreenResize=!1,_.prototype.featuresPlaybackRate=!1,_.prototype.featuresProgressEvents=!1,_.prototype.featuresSourceset=!1,_.prototype.featuresTimeupdateEvents=!1,_.prototype.featuresNativeTextTracks=!1,_.prototype.featuresVideoFrameCallback=!1,_.withSourceHandlers=function(r){r.registerSourceHandler=function(e,t){let i=r.sourceHandlers;i=i||(r.sourceHandlers=[]),void 0===t&&(t=i.length),i.splice(t,0,e)},r.canPlayType=function(t){var i,s=r.sourceHandlers||[];for(let e=0;e<s.length;e++)if(i=s[e].canPlayType(t))return i;return""},r.selectSourceHandler=function(t,i){var s=r.sourceHandlers||[];for(let e=0;e<s.length;e++)if(s[e].canHandleSource(t,i))return s[e];return null},r.canPlaySource=function(e,t){var i=r.selectSourceHandler(e,t);return i?i.canHandleSource(e,t):""};["seekable","seeking","duration"].forEach(function(e){const t=this[e];"function"==typeof t&&(this[e]=function(){return this.sourceHandler_&&this.sourceHandler_[e]?this.sourceHandler_[e].apply(this.sourceHandler_,arguments):t.apply(this,arguments)})},r.prototype),r.prototype.setSource=function(e){let t=r.selectSourceHandler(e,this.options_);t||(r.nativeSourceHandler?t=r.nativeSourceHandler:d.error("No source handler found for the current source.")),this.disposeSourceHandler(),this.off("dispose",this.disposeSourceHandler_),t!==r.nativeSourceHandler&&(this.currentSource_=e),this.sourceHandler_=t.handleSource(e,this,this.options_),this.one("dispose",this.disposeSourceHandler_)},r.prototype.disposeSourceHandler=function(){this.currentSource_&&(this.clearTracks(["audio","video"]),this.currentSource_=null),this.cleanupAutoTextTracks(),this.sourceHandler_&&(this.sourceHandler_.dispose&&this.sourceHandler_.dispose(),this.sourceHandler_=null)}},f.registerComponent("Tech",_),_.registerTech("Tech",_),_.defaultTechOrder_=[];const hs={},us={},cs={};function ps(e,t,i){e.setTimeout(()=>function i(s={},e=[],r,n,a=[],o=!1){const[t,...l]=e;if("string"==typeof t)i(s,hs[t],r,n,a,o);else if(t){const d=vs(n,t);if(!d.setSource)return a.push(d),i(s,l,r,n,a,o);d.setSource(Object.assign({},s),function(e,t){if(e)return i(s,l,r,n,a,o);a.push(d),i(t,s.type===t.type?l:hs[t.type],r,n,a,o)})}else l.length?i(s,l,r,n,a,o):o?r(s,a):i(s,hs["*"],r,n,a,!0)}(t,hs[t.type],i,e),1)}function ms(e,t,i,s=null){var r="call"+g(i),r=e.reduce(_s(r),s),s=r===cs,t=s?null:t[i](r),n=e,a=i,o=t,l=s;for(let e=n.length-1;0<=e;e--){var d=n[e];d[a]&&d[a](l,o)}return t}const gs={buffered:1,currentTime:1,duration:1,muted:1,played:1,paused:1,seekable:1,volume:1,ended:1},fs={setCurrentTime:1,setMuted:1,setVolume:1},ys={play:1,pause:1};function _s(i){return(e,t)=>e===cs?cs:t[i]?t[i](e):e}function vs(e,t){var i=us[e.id()];let s=null;if(null==i)s=t(e),us[e.id()]=[[t,s]];else{for(let e=0;e<i.length;e++){var[r,n]=i[e];r===t&&(s=n)}null===s&&(s=t(e),i.push([t,s]))}return s}function bs(e){if(Array.isArray(e)){let t=[];e.forEach(function(e){e=bs(e),Array.isArray(e)?t=t.concat(e):K(e)&&t.push(e)}),e=t}else e="string"==typeof e&&e.trim()?[ws({src:e})]:K(e)&&"string"==typeof e.src&&e.src&&e.src.trim()?[ws(e)]:[];return e}const Ts={opus:"video/ogg",ogv:"video/ogg",mp4:"video/mp4",mov:"video/mp4",m4v:"video/mp4",mkv:"video/x-matroska",m4a:"audio/mp4",mp3:"audio/mpeg",aac:"audio/aac",caf:"audio/x-caf",flac:"audio/flac",oga:"audio/ogg",wav:"audio/wav",m3u8:"application/x-mpegURL",mpd:"application/dash+xml",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",png:"image/png",svg:"image/svg+xml",webp:"image/webp"},Ss=function(e=""){e=ui(e);return Ts[e.toLowerCase()]||""};function ws(e){var t;return e.type||(t=Ss(e.src))&&(e.type=t),e}class Es extends f{constructor(s,e,t){if(super(s,h({createEl:!1},e),t),e.playerOptions.sources&&0!==e.playerOptions.sources.length)s.src(e.playerOptions.sources);else for(let t=0,i=e.playerOptions.techOrder;t<i.length;t++){var r=g(i[t]);let e=_.getTech(r);if((e=r?e:f.getComponent(r))&&e.isSupported()){s.loadTech_(r);break}}}}f.registerComponent("MediaLoader",Es);class ks extends f{constructor(e,t){super(e,t),this.options_.controlText&&this.controlText(this.options_.controlText),this.handleMouseOver_=e=>this.handleMouseOver(e),this.handleMouseOut_=e=>this.handleMouseOut(e),this.handleClick_=e=>this.handleClick(e),this.handleKeyDown_=e=>this.handleKeyDown(e),this.emitTapEvents(),this.enable()}createEl(e="div",t={},i={}){t=Object.assign({className:this.buildCSSClass(),tabIndex:0},t),"button"===e&&d.error(`Creating a ClickableComponent with an HTML element of ${e} is not supported; use a Button instead.`),i=Object.assign({role:"button"},i),this.tabIndex_=t.tabIndex;e=o(e,t,i);return e.appendChild(o("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),this.createControlTextEl(e),e}dispose(){this.controlTextEl_=null,super.dispose()}createControlTextEl(e){return this.controlTextEl_=o("span",{className:"vjs-control-text"},{"aria-live":"polite"}),e&&e.appendChild(this.controlTextEl_),this.controlText(this.controlText_,e),this.controlTextEl_}controlText(e,t=this.el()){if(void 0===e)return this.controlText_||"Need Text";var i=this.localize(e);this.controlText_=e,Se(this.controlTextEl_,i),this.nonIconControl||this.player_.options_.noUITitleAttributes||t.setAttribute("title",i)}buildCSSClass(){return"vjs-control vjs-button "+super.buildCSSClass()}enable(){this.enabled_||(this.enabled_=!0,this.removeClass("vjs-disabled"),this.el_.setAttribute("aria-disabled","false"),"undefined"!=typeof this.tabIndex_&&this.el_.setAttribute("tabIndex",this.tabIndex_),this.on(["tap","click"],this.handleClick_),this.on("keydown",this.handleKeyDown_))}disable(){this.enabled_=!1,this.addClass("vjs-disabled"),this.el_.setAttribute("aria-disabled","true"),"undefined"!=typeof this.tabIndex_&&this.el_.removeAttribute("tabIndex"),this.off("mouseover",this.handleMouseOver_),this.off("mouseout",this.handleMouseOut_),this.off(["tap","click"],this.handleClick_),this.off("keydown",this.handleKeyDown_)}handleLanguagechange(){this.controlText(this.controlText_)}handleClick(e){this.options_.clickHandler&&this.options_.clickHandler.call(this,arguments)}handleKeyDown(e){r.isEventKey(e,"Space")||r.isEventKey(e,"Enter")?(e.preventDefault(),e.stopPropagation(),this.trigger("click")):super.handleKeyDown(e)}}f.registerComponent("ClickableComponent",ks);class Cs extends ks{constructor(e,t){super(e,t),this.update(),this.update_=e=>this.update(e),e.on("posterchange",this.update_)}dispose(){this.player().off("posterchange",this.update_),super.dispose()}createEl(){return o("div",{className:"vjs-poster"})}crossOrigin(e){if("undefined"==typeof e)return this.$("img")?this.$("img").crossOrigin:this.player_.tech_&&this.player_.tech_.isReady_?this.player_.crossOrigin():this.player_.options_.crossOrigin||this.player_.options_.crossorigin||null;null!==e&&"anonymous"!==e&&"use-credentials"!==e?this.player_.log.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`):this.$("img")&&(this.$("img").crossOrigin=e)}update(e){var t=this.player().poster();this.setSrc(t),t?this.show():this.hide()}setSrc(e){e?(this.$("img")||this.el_.appendChild(o("picture",{className:"vjs-poster",tabIndex:-1},{},o("img",{loading:"lazy",crossOrigin:this.crossOrigin()},{alt:""}))),this.$("img").src=e):this.el_.textContent=""}handleClick(e){this.player_.controls()&&(this.player_.tech(!0)&&this.player_.tech(!0).focus(),this.player_.paused()?Gt(this.player_.play()):this.player_.pause())}}Cs.prototype.crossorigin=Cs.prototype.crossOrigin,f.registerComponent("PosterImage",Cs);const Is={monospace:"monospace",sansSerif:"sans-serif",serif:"serif",monospaceSansSerif:'"Andale Mono", "Lucida Console", monospace',monospaceSerif:'"Courier New", monospace',proportionalSansSerif:"sans-serif",proportionalSerif:"serif",casual:'"Comic Sans MS", Impact, fantasy',script:'"Monotype Corsiva", cursive',smallcaps:'"Andale Mono", "Lucida Console", monospace, sans-serif'};function xs(e,t){let i;if(4===e.length)i=e[1]+e[1]+e[2]+e[2]+e[3]+e[3];else{if(7!==e.length)throw new Error("Invalid color code provided, "+e+"; must be formatted as e.g. #f0e or #f604e2.");i=e.slice(1)}return"rgba("+parseInt(i.slice(0,2),16)+","+parseInt(i.slice(2,4),16)+","+parseInt(i.slice(4,6),16)+","+t+")"}function As(e,t,i){try{e.style[t]=i}catch(e){}}class Ps extends f{constructor(s,e,t){super(s,e,t);const r=e=>this.updateDisplay(e);s.on("loadstart",e=>this.toggleDisplay(e)),s.on("texttrackchange",r),s.on("loadedmetadata",e=>this.preselectTrack(e)),s.ready(m(this,function(){if(s.tech_&&s.tech_.featuresNativeTextTracks)this.hide();else{s.on("fullscreenchange",r),s.on("playerresize",r);const e=window.screen.orientation||window,i=window.screen.orientation?"change":"orientationchange";e.addEventListener(i,r),s.on("dispose",()=>e.removeEventListener(i,r));var t=this.options_.playerOptions.tracks||[];for(let e=0;e<t.length;e++)this.player_.addRemoteTextTrack(t[e],!0);this.preselectTrack()}}))}preselectTrack(){var t={captions:1,subtitles:1},i=this.player_.textTracks(),s=this.player_.cache_.selectedLanguage;let r,n,a;for(let e=0;e<i.length;e++){var o=i[e];s&&s.enabled&&s.language&&s.language===o.language&&o.kind in t?a=o.kind!==s.kind&&a||o:s&&!s.enabled?(a=null,r=null,n=null):o.default&&("descriptions"!==o.kind||r?o.kind in t&&!n&&(n=o):r=o)}a?a.mode="showing":n?n.mode="showing":r&&(r.mode="showing")}toggleDisplay(){this.player_.tech_&&this.player_.tech_.featuresNativeTextTracks?this.hide():this.show()}createEl(){return super.createEl("div",{className:"vjs-text-track-display"},{translate:"yes","aria-live":"off","aria-atomic":"true"})}clearDisplay(){"function"==typeof window.WebVTT&&window.WebVTT.processCues(window,[],this.el_)}updateDisplay(){var s=this.player_.textTracks(),e=this.options_.allowMultipleShowingTracks;if(this.clearDisplay(),e){var t=[];for(let e=0;e<s.length;++e){var i=s[e];"showing"===i.mode&&t.push(i)}this.updateForTrack(t)}else{let e=null,t=null,i=s.length;for(;i--;){var r=s[i];"showing"===r.mode&&("descriptions"===r.kind?e=r:t=r)}t?("off"!==this.getAttribute("aria-live")&&this.setAttribute("aria-live","off"),this.updateForTrack(t)):e&&("assertive"!==this.getAttribute("aria-live")&&this.setAttribute("aria-live","assertive"),this.updateForTrack(e))}}updateDisplayState(e){var t=this.player_.textTrackSettings.getValues(),i=e.activeCues;let s=i.length;for(;s--;){var r,n=i[s];n&&(n=n.displayState,t.color&&(n.firstChild.style.color=t.color),t.textOpacity&&As(n.firstChild,"color",xs(t.color||"#fff",t.textOpacity)),t.backgroundColor&&(n.firstChild.style.backgroundColor=t.backgroundColor),t.backgroundOpacity&&As(n.firstChild,"backgroundColor",xs(t.backgroundColor||"#000",t.backgroundOpacity)),t.windowColor&&(t.windowOpacity?As(n,"backgroundColor",xs(t.windowColor,t.windowOpacity)):n.style.backgroundColor=t.windowColor),t.edgeStyle&&("dropshadow"===t.edgeStyle?n.firstChild.style.textShadow="2px 2px 3px #222, 2px 2px 4px #222, 2px 2px 5px #222":"raised"===t.edgeStyle?n.firstChild.style.textShadow="1px 1px #222, 2px 2px #222, 3px 3px #222":"depressed"===t.edgeStyle?n.firstChild.style.textShadow="1px 1px #ccc, 0 1px #ccc, -1px -1px #222, 0 -1px #222":"uniform"===t.edgeStyle&&(n.firstChild.style.textShadow="0 0 4px #222, 0 0 4px #222, 0 0 4px #222, 0 0 4px #222")),t.fontPercent&&1!==t.fontPercent&&(r=window.parseFloat(n.style.fontSize),n.style.fontSize=r*t.fontPercent+"px",n.style.height="auto",n.style.top="auto"),t.fontFamily)&&"default"!==t.fontFamily&&
vendor: 26,881 bytes, line 3786
3786("small-caps"===t.fontFamily?n.firstChild.style.fontVariant="small-caps":n.firstChild.style.fontFamily=Is[t.fontFamily])}}updateForTrack(i){if(Array.isArray(i)||(i=[i]),"function"==typeof window.WebVTT&&!i.every(e=>!e.activeCues)){var t=[];for(let e=0;e<i.length;++e){var s=i[e];for(let e=0;e<s.activeCues.length;++e)t.push(s.activeCues[e])}window.WebVTT.processCues(window,t,this.el_);for(let t=0;t<i.length;++t){var r=i[t];for(let e=0;e<r.activeCues.length;++e){var n=r.activeCues[e].displayState;ke(n,"vjs-text-track-cue","vjs-text-track-cue-"+(r.language||t)),r.language&&Le(n,"lang",r.language)}this.player_.textTrackSettings&&this.updateDisplayState(r)}}}}f.registerComponent("TextTrackDisplay",Ps);class Ls extends f{createEl(){var e=this.player_.isAudio(),e=this.localize(e?"Audio Player":"Video Player"),e=o("span",{className:"vjs-control-text",textContent:this.localize("{1} is loading.",[e])}),t=super.createEl("div",{className:"vjs-loading-spinner",dir:"ltr"});return t.appendChild(e),t}handleLanguagechange(){this.$(".vjs-control-text").textContent=this.localize("{1} is loading.",[this.player_.isAudio()?"Audio Player":"Video Player"])}}f.registerComponent("LoadingSpinner",Ls);class s extends ks{createEl(e,t={},i={}){t=o("button",t=Object.assign({className:this.buildCSSClass()},t),i=Object.assign({type:"button"},i));return t.appendChild(o("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),this.createControlTextEl(t),t}addChild(e,t={}){var i=this.constructor.name;return d.warn(`Adding an actionable (user controllable) child to a Button (${i}) is not supported; use a ClickableComponent instead.`),f.prototype.addChild.call(this,e,t)}enable(){super.enable(),this.el_.removeAttribute("disabled")}disable(){super.disable(),this.el_.setAttribute("disabled","disabled")}handleKeyDown(e){r.isEventKey(e,"Space")||r.isEventKey(e,"Enter")?e.stopPropagation():super.handleKeyDown(e)}}f.registerComponent("Button",s);class Os extends s{constructor(e,t){super(e,t),this.mouseused_=!1,this.on("mousedown",e=>this.handleMouseDown(e))}buildCSSClass(){return"vjs-big-play-button"}handleClick(e){var t=this.player_.play();if(this.mouseused_&&e.clientX&&e.clientY)Gt(t),this.player_.tech(!0)&&this.player_.tech(!0).focus();else{var e=this.player_.getChild("controlBar");const i=e&&e.getChild("playToggle");i?(e=()=>i.focus(),Wt(t)?t.then(e,()=>{}):this.setTimeout(e,1)):this.player_.tech(!0).focus()}}handleKeyDown(e){this.mouseused_=!1,super.handleKeyDown(e)}handleMouseDown(e){this.mouseused_=!0}}Os.prototype.controlText_="Play Video",f.registerComponent("BigPlayButton",Os);s;f.registerComponent("CloseButton",class extends s{constructor(e,t){super(e,t),this.controlText(t&&t.controlText||this.localize("Close"))}buildCSSClass(){return"vjs-close-button "+super.buildCSSClass()}handleClick(e){this.trigger({type:"close",bubbles:!1})}handleKeyDown(e){r.isEventKey(e,"Esc")?(e.preventDefault(),e.stopPropagation(),this.trigger("click")):super.handleKeyDown(e)}});class Ds extends s{constructor(e,t={}){super(e,t),t.replay=void 0===t.replay||t.replay,this.on(e,"play",e=>this.handlePlay(e)),this.on(e,"pause",e=>this.handlePause(e)),t.replay&&this.on(e,"ended",e=>this.handleEnded(e))}buildCSSClass(){return"vjs-play-control "+super.buildCSSClass()}handleClick(e){this.player_.paused()?Gt(this.player_.play()):this.player_.pause()}handleSeeked(e){this.removeClass("vjs-ended"),this.player_.paused()?this.handlePause(e):this.handlePlay(e)}handlePlay(e){this.removeClass("vjs-ended","vjs-paused"),this.addClass("vjs-playing"),this.controlText("Pause")}handlePause(e){this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.controlText("Play")}handleEnded(e){this.removeClass("vjs-playing"),this.addClass("vjs-ended"),this.controlText("Replay"),this.one(this.player_,"seeked",e=>this.handleSeeked(e))}}Ds.prototype.controlText_="Play",f.registerComponent("PlayToggle",Ds);class Ns extends f{constructor(e,t){super(e,t),this.on(e,["timeupdate","ended"],e=>this.updateContent(e)),this.updateTextNode_()}createEl(){var e=this.buildCSSClass(),t=super.createEl("div",{className:e+" vjs-time-control vjs-control"}),i=o("span",{className:"vjs-control-text",textContent:this.localize(this.labelText_)+"Ã "},{role:"presentation"});return t.appendChild(i),this.contentEl_=o("span",{className:e+"-display"},{role:"presentation"}),t.appendChild(this.contentEl_),t}dispose(){this.contentEl_=null,this.textNode_=null,super.dispose()}updateTextNode_(e=0){e=Ht(e),this.formattedTime_!==e&&(this.formattedTime_=e,this.requestNamedAnimationFrame("TimeDisplay#updateTextNode_",()=>{if(this.contentEl_){let e=this.textNode_;e&&this.contentEl_.firstChild!==e&&(e=null,d.warn("TimeDisplay#updateTextnode_: Prevented replacement of text node element since it was no longer a child of this node. Appending a new node instead.")),this.textNode_=document.createTextNode(this.formattedTime_),this.textNode_&&(e?this.contentEl_.replaceChild(this.textNode_,e):this.contentEl_.appendChild(this.textNode_))}}))}updateContent(e){}}Ns.prototype.labelText_="Time",Ns.prototype.controlText_="Time",f.registerComponent("TimeDisplay",Ns);class Ms extends Ns{buildCSSClass(){return"vjs-current-time"}updateContent(e){let t;t=this.player_.ended()?this.player_.duration():this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime(),this.updateTextNode_(t)}}Ms.prototype.labelText_="Current Time",Ms.prototype.controlText_="Current Time",f.registerComponent("CurrentTimeDisplay",Ms);class Rs extends Ns{constructor(e,t){super(e,t);t=e=>this.updateContent(e);this.on(e,"durationchange",t),this.on(e,"loadstart",t),this.on(e,"loadedmetadata",t)}buildCSSClass(){return"vjs-duration"}updateContent(e){var t=this.player_.duration();this.updateTextNode_(t)}}Rs.prototype.labelText_="Duration",Rs.prototype.controlText_="Duration",f.registerComponent("DurationDisplay",Rs);class Us extends f{createEl(){var e=super.createEl("div",{className:"vjs-time-control vjs-time-divider"},{"aria-hidden":!0}),t=super.createEl("div"),i=super.createEl("span",{textContent:"/"});return t.appendChild(i),e.appendChild(t),e}}f.registerComponent("TimeDivider",Us);class Bs extends Ns{constructor(e,t){super(e,t),this.on(e,"durationchange",e=>this.updateContent(e))}buildCSSClass(){return"vjs-remaining-time"}createEl(){var e=super.createEl();return!1!==this.options_.displayNegative&&e.insertBefore(o("span",{},{"aria-hidden":!0},"-"),this.contentEl_),e}updateContent(e){if("number"==typeof this.player_.duration()){let e;e=this.player_.ended()?0:this.player_.remainingTimeDisplay?this.player_.remainingTimeDisplay():this.player_.remainingTime(),this.updateTextNode_(e)}}}Bs.prototype.labelText_="Remaining Time",Bs.prototype.controlText_="Remaining Time",f.registerComponent("RemainingTimeDisplay",Bs);class Fs extends f{constructor(e,t){super(e,t),this.updateShowing(),this.on(this.player(),"durationchange",e=>this.updateShowing(e))}createEl(){var e=super.createEl("div",{className:"vjs-live-control vjs-control"});return this.contentEl_=o("div",{className:"vjs-live-display"},{"aria-live":"off"}),this.contentEl_.appendChild(o("span",{className:"vjs-control-text",textContent:this.localize("Stream Type")+"Ã "})),this.contentEl_.appendChild(document.createTextNode(this.localize("LIVE"))),e.appendChild(this.contentEl_),e}dispose(){this.contentEl_=null,super.dispose()}updateShowing(e){this.player().duration()===1/0?this.show():this.hide()}}f.registerComponent("LiveDisplay",Fs);class js extends s{constructor(e,t){super(e,t),this.updateLiveEdgeStatus(),this.player_.liveTracker&&(this.updateLiveEdgeStatusHandler_=e=>this.updateLiveEdgeStatus(e),this.on(this.player_.liveTracker,"liveedgechange",this.updateLiveEdgeStatusHandler_))}createEl(){var e=super.createEl("button",{className:"vjs-seek-to-live-control vjs-control"});return this.textEl_=o("span",{className:"vjs-seek-to-live-text",textContent:this.localize("LIVE")},{"aria-hidden":"true"}),e.appendChild(this.textEl_),e}updateLiveEdgeStatus(){!this.player_.liveTracker||this.player_.liveTracker.atLiveEdge()?(this.setAttribute("aria-disabled",!0),this.addClass("vjs-at-live-edge"),this.controlText("Seek to live, currently playing live")):(this.setAttribute("aria-disabled",!1),this.removeClass("vjs-at-live-edge"),this.controlText("Seek to live, currently behind live"))}handleClick(){this.player_.liveTracker.seekToLiveEdge()}dispose(){this.player_.liveTracker&&this.off(this.player_.liveTracker,"liveedgechange",this.updateLiveEdgeStatusHandler_),this.textEl_=null,super.dispose()}}function Hs(e,t,i){return e=Number(e),Math.min(i,Math.max(t,isNaN(e)?t:e))}js.prototype.controlText_="Seek to live, currently playing live",f.registerComponent("SeekToLive",js);pi=Object.freeze({__proto__:null,clamp:Hs});class qs extends f{constructor(e,t){super(e,t),this.handleMouseDown_=e=>this.handleMouseDown(e),this.handleMouseUp_=e=>this.handleMouseUp(e),this.handleKeyDown_=e=>this.handleKeyDown(e),this.handleClick_=e=>this.handleClick(e),this.handleMouseMove_=e=>this.handleMouseMove(e),this.update_=e=>this.update(e),this.bar=this.getChild(this.options_.barName),this.vertical(!!this.options_.vertical),this.enable()}enabled(){return this.enabled_}enable(){this.enabled()||(this.on("mousedown",this.handleMouseDown_),this.on("touchstart",this.handleMouseDown_),this.on("keydown",this.handleKeyDown_),this.on("click",this.handleClick_),this.on(this.player_,"controlsvisible",this.update),this.playerEvent&&this.on(this.player_,this.playerEvent,this.update),this.removeClass("disabled"),this.setAttribute("tabindex",0),this.enabled_=!0)}disable(){var e;this.enabled()&&(e=this.bar.el_.ownerDocument,this.off("mousedown",this.handleMouseDown_),this.off("touchstart",this.handleMouseDown_),this.off("keydown",this.handleKeyDown_),this.off("click",this.handleClick_),this.off(this.player_,"controlsvisible",this.update_),this.off(e,"mousemove",this.handleMouseMove_),this.off(e,"mouseup",this.handleMouseUp_),this.off(e,"touchmove",this.handleMouseMove_),this.off(e,"touchend",this.handleMouseUp_),this.removeAttribute("tabindex"),this.addClass("disabled"),this.playerEvent&&this.off(this.player_,this.playerEvent,this.update),this.enabled_=!1)}createEl(e,t={},i={}){return t.className=t.className+" vjs-slider",t=Object.assign({tabIndex:0},t),i=Object.assign({role:"slider","aria-valuenow":0,"aria-valuemin":0,"aria-valuemax":100},i),super.createEl(e,t,i)}handleMouseDown(e){var t=this.bar.el_.ownerDocument;"mousedown"===e.type&&e.preventDefault(),"touchstart"!==e.type||ae||e.preventDefault(),De(),this.addClass("vjs-sliding"),this.trigger("slideractive"),this.on(t,"mousemove",this.handleMouseMove_),this.on(t,"mouseup",this.handleMouseUp_),this.on(t,"touchmove",this.handleMouseMove_),this.on(t,"touchend",this.handleMouseUp_),this.handleMouseMove(e,!0)}handleMouseMove(e){}handleMouseUp(e){var t=this.bar.el_.ownerDocument;Ne(),this.removeClass("vjs-sliding"),this.trigger("sliderinactive"),this.off(t,"mousemove",this.handleMouseMove_),this.off(t,"mouseup",this.handleMouseUp_),this.off(t,"touchmove",this.handleMouseMove_),this.off(t,"touchend",this.handleMouseUp_),this.update()}update(){if(this.el_&&this.bar){const t=this.getProgress();return t!==this.progress_&&(this.progress_=t,this.requestNamedAnimationFrame("Slider#update",()=>{var e=this.vertical()?"height":"width";this.bar.el().style[e]=(100*t).toFixed(2)+"%"})),t}}getProgress(){return Number(Hs(this.getPercent(),0,1).toFixed(4))}calculateDistance(e){e=Ue(this.el_,e);return this.vertical()?e.y:e.x}handleKeyDown(e){r.isEventKey(e,"Left")||r.isEventKey(e,"Down")?(e.preventDefault(),e.stopPropagation(),this.stepBack()):r.isEventKey(e,"Right")||r.isEventKey(e,"Up")?(e.preventDefault(),e.stopPropagation(),this.stepForward()):super.handleKeyDown(e)}handleClick(e){e.stopPropagation(),e.preventDefault()}vertical(e){if(void 0===e)return this.vertical_||!1;this.vertical_=!!e,this.vertical_?this.addClass("vjs-slider-vertical"):this.addClass("vjs-slider-horizontal")}}f.registerComponent("Slider",qs);const Vs=(e,t)=>Hs(e/t*100,0,100).toFixed(2)+"%";class $s extends f{constructor(e,t){super(e,t),this.partEls_=[],this.on(e,"progress",e=>this.update(e))}createEl(){var e=super.createEl("div",{className:"vjs-load-progress"}),t=o("span",{className:"vjs-control-text"}),i=o("span",{textContent:this.localize("Loaded")}),s=document.createTextNode(": ");return this.percentageEl_=o("span",{className:"vjs-control-text-loaded-percentage",textContent:"0%"}),e.appendChild(t),t.appendChild(i),t.appendChild(s),t.appendChild(this.percentageEl_),e}dispose(){this.partEls_=null,this.percentageEl_=null,super.dispose()}update(e){this.requestNamedAnimationFrame("LoadProgressBar#update",()=>{var e=this.player_.liveTracker,i=this.player_.buffered(),e=e&&e.isLive()?e.seekableEnd():this.player_.duration(),s=this.player_.bufferedEnd(),r=this.partEls_,e=Vs(s,e);this.percent_!==e&&(this.el_.style.width=e,Se(this.percentageEl_,e),this.percent_=e);for(let t=0;t<i.length;t++){var n=i.start(t),a=i.end(t);let e=r[t];e||(e=this.el_.appendChild(o()),r[t]=e),e.dataset.start===n&&e.dataset.end===a||(e.dataset.start=n,e.dataset.end=a,e.style.left=Vs(n,s),e.style.width=Vs(a-n,s))}for(let e=r.length;e>i.length;e--)this.el_.removeChild(r[e-1]);r.length=i.length})}}f.registerComponent("LoadProgressBar",$s);class Ws extends f{constructor(e,t){super(e,t),this.update=ct(m(this,this.update),30)}createEl(){return super.createEl("div",{className:"vjs-time-tooltip"},{"aria-hidden":"true"})}update(t,i,s){var r=Re(this.el_),n=Me(this.player_.el()),i=t.width*i;if(n&&r){var a=t.left-n.left+i,i=t.width-i+(n.right-t.right);let e=r.width/2;a<e?e+=e-a:i<e&&(e=i),e<0?e=0:e>r.width&&(e=r.width),e=Math.round(e),this.el_.style.right=`-${e}px`,this.write(s)}}write(e){Se(this.el_,e)}updateTime(r,n,a,o){this.requestNamedAnimationFrame("TimeTooltip#updateTime",()=>{let e;var t,i,s=this.player_.duration();e=this.player_.liveTracker&&this.player_.liveTracker.isLive()?((i=(t=this.player_.liveTracker.liveWindow())-n*t)<1?"":"-")+Ht(i,t):Ht(a,s),this.update(r,n,e),o&&o()})}}f.registerComponent("TimeTooltip",Ws);class Gs extends f{constructor(e,t){super(e,t),this.update=ct(m(this,this.update),30)}createEl(){return super.createEl("div",{className:"vjs-play-progress vjs-slider-bar"},{"aria-hidden":"true"})}update(e,t){var i,s=this.getChild("timeTooltip");s&&(i=this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime(),s.updateTime(e,t,i))}}Gs.prototype.options_={children:[]},u||te||Gs.prototype.options_.children.push("timeTooltip"),f.registerComponent("PlayProgressBar",Gs);class zs extends f{constructor(e,t){super(e,t),this.update=ct(m(this,this.update),30)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(e,t){var i=t*this.player_.duration();this.getChild("timeTooltip").updateTime(e,t,i,()=>{this.el_.style.left=e.width*t+"px"})}}zs.prototype.options_={children:["timeTooltip"]},f.registerComponent("MouseTimeDisplay",zs);class Xs extends qs{constructor(e,t){super(e,t),this.setEventHandlers_()}setEventHandlers_(){this.update_=m(this,this.update),this.update=ct(this.update_,30),this.on(this.player_,["ended","durationchange","timeupdate"],this.update),this.player_.liveTracker&&this.on(this.player_.liveTracker,"liveedgechange",this.update),this.updateInterval=null,this.enableIntervalHandler_=e=>this.enableInterval_(e),this.disableIntervalHandler_=e=>this.disableInterval_(e),this.on(this.player_,["playing"],this.enableIntervalHandler_),this.on(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in document&&"visibilityState"in document&&this.on(document,"visibilitychange",this.toggleVisibility_)}toggleVisibility_(e){"hidden"===document.visibilityState?(this.cancelNamedAnimationFrame("SeekBar#update"),this.cancelNamedAnimationFrame("Slider#update"),this.disableInterval_(e)):(this.player_.ended()||this.player_.paused()||this.enableInterval_(),this.update())}enableInterval_(){this.updateInterval||(this.updateInterval=this.setInterval(this.update,30))}disableInterval_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&e&&"ended"!==e.type||this.updateInterval&&(this.clearInterval(this.updateInterval),this.updateInterval=null)}createEl(){return super.createEl("div",{className:"vjs-progress-holder"},{"aria-label":this.localize("Progress Bar")})}update(e){if("hidden"!==document.visibilityState){const s=super.update();return this.requestNamedAnimationFrame("SeekBar#update",()=>{var e=this.player_.ended()?this.player_.duration():this.getCurrentTime_(),t=this.player_.liveTracker;let i=this.player_.duration();t&&t.isLive()&&(i=this.player_.liveTracker.liveCurrentTime()),this.percent_!==s&&(this.el_.setAttribute("aria-valuenow",(100*s).toFixed(2)),this.percent_=s),this.currentTime_===e&&this.duration_===i||(this.el_.setAttribute("aria-valuetext",this.localize("progress bar timing: currentTime={1} duration={2}",[Ht(e,i),Ht(i,i)],"{1} of {2}")),this.currentTime_=e,this.duration_=i),this.bar&&this.bar.update(Me(this.el()),this.getProgress())}),s}}userSeek_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&this.player_.liveTracker.nextSeekedFromUser(),this.player_.currentTime(e)}getCurrentTime_(){return this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime()}getPercent(){var e=this.getCurrentTime_();let t;var i=this.player_.liveTracker;return i&&i.isLive()?(t=(e-i.seekableStart())/i.liveWindow(),i.atLiveEdge()&&(t=1)):t=e/this.player_.duration(),t}handleMouseDown(e){Ve(e)&&(e.stopPropagation(),this.videoWasPlaying=!this.player_.paused(),this.player_.pause(),super.handleMouseDown(e))}handleMouseMove(t,i=!1){if(Ve(t)){i||this.player_.scrubbing()||this.player_.scrubbing(!0);let e;i=this.calculateDistance(t),t=this.player_.liveTracker;if(t&&t.isLive()){if(.99<=i)return void t.seekToLiveEdge();var s=t.seekableStart(),r=t.liveCurrentTime();if((e=(e=(e=s+i*t.liveWindow())>=r?r:e)<=s?s+.1:e)===1/0)return}else(e=i*this.player_.duration())===this.player_.duration()&&(e-=.1);this.userSeek_(e)}}enable(){super.enable();var e=this.getChild("mouseTimeDisplay");e&&e.show()}disable(){super.disable();var e=this.getChild("mouseTimeDisplay");e&&e.hide()}handleMouseUp(e){super.handleMouseUp(e),e&&e.stopPropagation(),this.player_.scrubbing(!1),this.player_.trigger({type:"timeupdate",target:this,manuallyTriggered:!0}),this.videoWasPlaying?Gt(this.player_.play()):this.update_()}stepForward(){this.userSeek_(this.player_.currentTime()+5)}stepBack(){this.userSeek_(this.player_.currentTime()-5)}handleAction(e){this.player_.paused()?this.player_.play():this.player_.pause()}handleKeyDown(e){var t,i=this.player_.liveTracker;r.isEventKey(e,"Space")||r.isEventKey(e,"Enter")?(e.preventDefault(),e.stopPropagation(),this.handleAction(e)):r.isEventKey(e,"Home")?(e.preventDefault(),e.stopPropagation(),this.userSeek_(0)):r.isEventKey(e,"End")?(e.preventDefault(),e.stopPropagation(),i&&i.isLive()?this.userSeek_(i.liveCurrentTime()):this.userSeek_(this.player_.duration())):/^[0-9]$/.test(r(e))?(e.preventDefault(),e.stopPropagation(),t=10*(r.codes[r(e)]-r.codes[0])/100,i&&i.isLive()?this.userSeek_(i.seekableStart()+i.liveWindow()*t):this.userSeek_(this.player_.duration()*t)):r.isEventKey(e,"PgDn")?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()-60)):r.isEventKey(e,"PgUp")?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()+60)):super.handleKeyDown(e)}dispose(){this.disableInterval_(),this.off(this.player_,["ended","durationchange","timeupdate"],this.update),this.player_.liveTracker&&this.off(this.player_.liveTracker,"liveedgechange",this.update),this.off(this.player_,["playing"],this.enableIntervalHandler_),this.off(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in document&&"visibilityState"in document&&this.off(document,"visibilitychange",this.toggleVisibility_),super.dispose()}}Xs.prototype.options_={children:["loadProgressBar","playProgressBar"],barName:"playProgressBar"},u||te||Xs.prototype.options_.children.splice(1,0,"mouseTimeDisplay"),f.registerComponent("SeekBar",Xs);class Ks extends f{constructor(e,t){super(e,t),this.handleMouseMove=ct(m(this,this.handleMouseMove),30),this.throttledHandleMouseSeek=ct(m(this,this.handleMouseSeek),30),this.handleMouseUpHandler_=e=>this.handleMouseUp(e),this.handleMouseDownHandler_=e=>this.handleMouseDown(e),this.enable()}createEl(){return super.createEl("div",{className:"vjs-progress-control vjs-control"})}handleMouseMove(e){var t,i,s,r,n=this.getChild("seekBar");n&&(t=n.getChild("playProgressBar"),i=n.getChild("mouseTimeDisplay"),t||i)&&(s=Re(r=n.el()),r=Hs(r=Ue(r,e).x,0,1),i&&i.update(s,r),t)&&t.update(s,n.getProgress())}handleMouseSeek(e){var t=this.getChild("seekBar");t&&t.handleMouseMove(e)}enabled(){return this.enabled_}disable(){var e;this.children().forEach(e=>e.disable&&e.disable()),this.enabled()&&(this.off(["mousedown","touchstart"],this.handleMouseDownHandler_),this.off(this.el_,"mousemove",this.handleMouseMove),this.removeListenersAddedOnMousedownAndTouchstart(),this.addClass("disabled"),this.enabled_=!1,this.player_.scrubbing())&&(e=this.getChild("seekBar"),this.player_.scrubbing(!1),e.videoWasPlaying)&&Gt(this.player_.play())}enable(){this.children().forEach(e=>e.enable&&e.enable()),this.enabled()||(this.on(["mousedown","touchstart"],this.handleMouseDownHandler_),this.on(this.el_,"mousemove",this.handleMouseMove),this.removeClass("disabled"),this.enabled_=!0)}removeListenersAddedOnMousedownAndTouchstart(){var e=this.el_.ownerDocument;this.off(e,"mousemove",this.throttledHandleMouseSeek),this.off(e,"touchmove",this.throttledHandleMouseSeek),this.off(e,"mouseup",this.handleMouseUpHandler_),this.off(e,"touchend",this.handleMouseUpHandler_)}handleMouseDown(e){var t=this.el_.ownerDocument,i=this.getChild("seekBar");i&&i.handleMouseDown(e),this.on(t,"mousemove",this.throttledHandleMouseSeek),this.on(t,"touchmove",this.throttledHandleMouseSeek),this.on(t,"mouseup",this.handleMouseUpHandler_),this.on(t,"touchend",this.handleMouseUpHandler_)}handleMouseUp(e){var t=this.getChild("seekBar");t&&t.handleMouseUp(e),this.removeListenersAddedOnMousedownAndTouchstart()}}Ks.prototype.options_={children:["seekBar"]},f.registerComponent("ProgressControl",Ks);class Ys extends s{constructor(e,t){super(e,t),this.on(e,["enterpictureinpicture","leavepictureinpicture"],e=>this.handlePictureInPictureChange(e)),this.on(e,["disablepictureinpicturechanged","loadedmetadata"],e=>this.handlePictureInPictureEnabledChange(e)),this.on(e,["loadedmetadata","audioonlymodechange","audiopostermodechange"],()=>{"audio"===e.currentType().substring(0,5)||e.audioPosterMode()||e.audioOnlyMode()?(e.isInPictureInPicture()&&e.exitPictureInPicture(),this.hide()):this.show()}),this.disable()}buildCSSClass(){return"vjs-picture-in-picture-control "+super.buildCSSClass()}handlePictureInPictureEnabledChange(){document.pictureInPictureEnabled&&!1===this.player_.disablePictureInPicture()||this.player_.options_.enableDocumentPictureInPicture&&"documentPictureInPicture"in window?this.enable():this.disable()}handlePictureInPictureChange(e){this.player_.isInPictureInPicture()?this.controlText("Exit Picture-in-Picture"):this.controlText("Picture-in-Picture"),this.handlePictureInPictureEnabledChange()}handleClick(e){this.player_.isInPictureInPicture()?this.player_.exitPictureInPicture():this.player_.requestPictureInPicture()}}Ys.prototype.controlText_="Picture-in-Picture",f.registerComponent("PictureInPictureToggle",Ys);class Qs extends s{constructor(e,t){super(e,t),this.on(e,"fullscreenchange",e=>this.handleFullscreenChange(e)),!1===document[e.fsApi_.fullscreenEnabled]&&this.disable()}buildCSSClass(){return"vjs-fullscreen-control "+super.buildCSSClass()}handleFullscreenChange(e){this.player_.isFullscreen()?this.controlText("Exit Fullscreen"):this.controlText("Fullscreen")}handleClick(e){this.player_.isFullscreen()?this.player_.exitFullscreen():this.player_.requestFullscreen()}}Qs.prototype.controlText_="Fullscreen",f.registerComponent("FullscreenToggle",Qs);class Js extends f{createEl(){var e=super.createEl("div",{className:"vjs-volume-level"});return e.appendChild(super.createEl("span",{className:"vjs-control-text"})),e}}f.registerComponent("VolumeLevel",Js);class Zs extends f{constructor(e,t){super(e,t),this.update=ct(m(this,this.update),30)}createEl(){return super.createEl("div",{className:"vjs-volume-tooltip"},{"aria-hidden":"true"})}update(t,i,s,e){if(!s){var s=Me(this.el_),r=Me(this.player_.el()),i=t.width*i;if(!r||!s)return;var n=t.left-r.left+i,i=t.width-i+(r.right-t.right);let e=s.width/2;n<e?e+=e-n:i<e&&(e=i),e<0?e=0:e>s.width&&(e=s.width),this.el_.style.right=`-${e}px`}this.write(e+"%")}write(e){Se(this.el_,e)}updateVolume(e,t,i,s,r){this.requestNamedAnimationFrame("VolumeLevelTooltip#updateVolume",()=>{this.update(e,t,i,s.toFixed(0)),r&&r()})}}f.registerComponent("VolumeLevelTooltip",Zs);class er extends f{constructor(e,t){super(e,t),this.update=ct(m(this,this.update),30)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(e,t,i){var s=100*t;this.getChild("volumeLevelTooltip").updateVolume(e,t,i,s,()=>{i?this.el_.style.bottom=e.height*t+"px":this.el_.style.left=e.width*t+"px"})}}er.prototype.options_={children:["volumeLevelTooltip"]},f.registerComponent("MouseVolumeLevelDisplay",er);class tr extends qs{constructor(e,t){super(e,t),this.on("slideractive",e=>this.updateLastVolume_(e)),this.on(e,"volumechange",e=>this.updateARIAAttributes(e)),e.ready(()=>this.updateARIAAttributes())}createEl(){return super.createEl("div",{className:"vjs-volume-bar vjs-slider-bar"},{"aria-label":this.localize("Volume Level"),"aria-live":"polite"})}handleMouseDown(e){Ve(e)&&super.handleMouseDown(e)}handleMouseMove(e){var t,i,s,r=this.getChild("mouseVolumeLevelDisplay");r&&(t=Me(s=this.el()),i=this.vertical(),s=Ue(s,e),s=Hs(s=i?s.y:s.x,0,1),r.update(t,s,i)),Ve(e)&&(this.checkMuted(),this.player_.volume(this.calculateDistance(e)))}checkMuted(){this.player_.muted()&&this.player_.muted(!1)}getPercent(){return this.player_.muted()?0:this.player_.volume()}stepForward(){this.checkMuted(),this.player_.volume(this.player_.volume()+.1)}stepBack(){this.checkMuted(),this.player_.volume(this.player_.volume()-.1)}updateARIAAttributes(e){var t=this.player_.muted()?0:this.volumeAsPercentage_();this.el_.setAttribute("aria-valuenow",t),this.el_.setAttribute("aria-valuetext",t+"%")}volumeAsPercentage_(){return Math.round(100*this.player_.volume())}updateLastVolume_(){const e=this.player_.volume();this.one("sliderinactive",()=>{0===this.player_.volume()&&this.player_.lastVolume_(e)})}}tr.prototype.options_={children:["volumeLevel"],barName:"volumeLevel"},u||te||tr.prototype.options_.children.splice(0,0,"mouseVolumeLevelDisplay"),tr.prototype.playerEvent="volumechange",f.registerComponent("
3786VolumeBar",tr);class ir extends f{constructor(e,t={}){var i,s;t.vertical=t.vertical||!1,"undefined"!=typeof t.volumeBar&&!Y(t.volumeBar)||(t.volumeBar=t.volumeBar||{},t.volumeBar.vertical=t.vertical),super(e,t),i=this,(s=e).tech_&&!s.tech_.featuresVolumeControl&&i.addClass("vjs-hidden"),i.on(s,"loadstart",function(){s.tech_.featuresVolumeControl?i.removeClass("vjs-hidden"):i.addClass("vjs-hidden")}),this.throttledHandleMouseMove=ct(m(this,this.handleMouseMove),30),this.handleMouseUpHandler_=e=>this.handleMouseUp(e),this.on("mousedown",e=>this.handleMouseDown(e)),this.on("touchstart",e=>this.handleMouseDown(e)),this.on("mousemove",e=>this.handleMouseMove(e)),this.on(this.volumeBar,["focus","slideractive"],()=>{this.volumeBar.addClass("vjs-slider-active"),this.addClass("vjs-slider-active"),this.trigger("slideractive")}),this.on(this.volumeBar,["blur","sliderinactive"],()=>{this.volumeBar.removeClass("vjs-slider-active"),this.removeClass("vjs-slider-active"),this.trigger("sliderinactive")})}createEl(){let e="vjs-volume-horizontal";return this.options_.vertical&&(e="vjs-volume-vertical"),super.createEl("div",{className:"vjs-volume-control vjs-control "+e})}handleMouseDown(e){var t=this.el_.ownerDocument;this.on(t,"mousemove",this.throttledHandleMouseMove),this.on(t,"touchmove",this.throttledHandleMouseMove),this.on(t,"mouseup",this.handleMouseUpHandler_),this.on(t,"touchend",this.handleMouseUpHandler_)}handleMouseUp(e){var t=this.el_.ownerDocument;this.off(t,"mousemove",this.throttledHandleMouseMove),this.off(t,"touchmove",this.throttledHandleMouseMove),this.off(t,"mouseup",this.handleMouseUpHandler_),this.off(t,"touchend",this.handleMouseUpHandler_)}handleMouseMove(e){this.volumeBar.handleMouseMove(e)}}ir.prototype.options_={children:["volumeBar"]},f.registerComponent("VolumeControl",ir);class sr extends s{constructor(e,t){var i,s;super(e,t),i=this,(s=e).tech_&&!s.tech_.featuresMuteControl&&i.addClass("vjs-hidden"),i.on(s,"loadstart",function(){s.tech_.featuresMuteControl?i.removeClass("vjs-hidden"):i.addClass("vjs-hidden")}),this.on(e,["loadstart","volumechange"],e=>this.update(e))}buildCSSClass(){return"vjs-mute-control "+super.buildCSSClass()}handleClick(e){var t=this.player_.volume(),i=this.player_.lastVolume_();0===t?(this.player_.volume(i<.1?.1:i),this.player_.muted(!1)):this.player_.muted(!this.player_.muted())}update(e){this.updateIcon_(),this.updateControlText_()}updateIcon_(){var e=this.player_.volume();let t=3;u&&this.player_.tech_&&this.player_.tech_.el_&&this.player_.muted(this.player_.tech_.el_.muted),0===e||this.player_.muted()?t=0:e<.33?t=1:e<.67&&(t=2),Ce(this.el_,[0,1,2,3].reduce((e,t)=>e+`${t?" ":""}vjs-vol-`+t,"")),ke(this.el_,"vjs-vol-"+t)}updateControlText_(){var e=this.player_.muted()||0===this.player_.volume()?"Unmute":"Mute";this.controlText()!==e&&this.controlText(e)}}sr.prototype.controlText_="Mute",f.registerComponent("MuteToggle",sr);class rr extends f{constructor(e,t={}){"undefined"!=typeof t.inline?t.inline=t.inline:t.inline=!0,"undefined"!=typeof t.volumeControl&&!Y(t.volumeControl)||(t.volumeControl=t.volumeControl||{},t.volumeControl.vertical=!t.inline),super(e,t),this.handleKeyPressHandler_=e=>this.handleKeyPress(e),this.on(e,["loadstart"],e=>this.volumePanelState_(e)),this.on(this.muteToggle,"keyup",e=>this.handleKeyPress(e)),this.on(this.volumeControl,"keyup",e=>this.handleVolumeControlKeyUp(e)),this.on("keydown",e=>this.handleKeyPress(e)),this.on("mouseover",e=>this.handleMouseOver(e)),this.on("mouseout",e=>this.handleMouseOut(e)),this.on(this.volumeControl,["slideractive"],this.sliderActive_),this.on(this.volumeControl,["sliderinactive"],this.sliderInactive_)}sliderActive_(){this.addClass("vjs-slider-active")}sliderInactive_(){this.removeClass("vjs-slider-active")}volumePanelState_(){this.volumeControl.hasClass("vjs-hidden")&&this.muteToggle.hasClass("vjs-hidden")&&this.addClass("vjs-hidden"),this.volumeControl.hasClass("vjs-hidden")&&!this.muteToggle.hasClass("vjs-hidden")&&this.addClass("vjs-mute-toggle-only")}createEl(){let e="vjs-volume-panel-horizontal";return this.options_.inline||(e="vjs-volume-panel-vertical"),super.createEl("div",{className:"vjs-volume-panel vjs-control "+e})}dispose(){this.handleMouseOut(),super.dispose()}handleVolumeControlKeyUp(e){r.isEventKey(e,"Esc")&&this.muteToggle.focus()}handleMouseOver(e){this.addClass("vjs-hover"),ot(document,"keyup",this.handleKeyPressHandler_)}handleMouseOut(e){this.removeClass("vjs-hover"),p(document,"keyup",this.handleKeyPressHandler_)}handleKeyPress(e){r.isEventKey(e,"Esc")&&this.handleMouseOut()}}rr.prototype.options_={children:["muteToggle","volumeControl"]}
vendor: 4,644 bytes, line 3786
3786,f.registerComponent("VolumePanel",rr);s;f.registerComponent("SkipForward",class extends s{constructor(e,t){super(e,t),this.validOptions=[5,10,30],this.skipTime=this.getSkipForwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.controlText(this.localize("Skip forward {1} seconds",[this.skipTime])),this.show()):this.hide()}getSkipForwardTime(){var e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.forward}buildCSSClass(){return`vjs-skip-forward-${this.getSkipForwardTime()} `+super.buildCSSClass()}handleClick(e){var t=this.player_.currentTime(),i=this.player_.liveTracker,i=i&&i.isLive()?i.seekableEnd():this.player_.duration();let s;s=t+this.skipTime<=i?t+this.skipTime:i,this.player_.currentTime(s)}handleLanguagechange(){this.controlText(this.localize("Skip forward {1} seconds",[this.skipTime]))}});class nr extends s{constructor(e,t){super(e,t),this.validOptions=[5,10,30],this.skipTime=this.getSkipBackwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.controlText(this.localize("Skip backward {1} seconds",[this.skipTime])),this.show()):this.hide()}getSkipBackwardTime(){var e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.backward}buildCSSClass(){return`vjs-skip-backward-${this.getSkipBackwardTime()} `+super.buildCSSClass()}handleClick(e){var t=this.player_.currentTime(),i=this.player_.liveTracker,i=i&&i.isLive()&&i.seekableStart();let s;s=i&&t-this.skipTime<=i?i:t>=this.skipTime?t-this.skipTime:0,this.player_.currentTime(s)}handleLanguagechange(){this.controlText(this.localize("Skip backward {1} seconds",[this.skipTime]))}}nr.prototype.controlText_="Skip Backward",f.registerComponent("SkipBackward",nr);class ar extends f{constructor(e,t){super(e,t),t&&(this.menuButton_=t.menuButton),this.focusedChild_=-1,this.on("keydown",e=>this.handleKeyDown(e)),this.boundHandleBlur_=e=>this.handleBlur(e),this.boundHandleTapClick_=e=>this.handleTapClick(e)}addEventListenerForItem(e){e instanceof f&&(this.on(e,"blur",this.boundHandleBlur_),this.on(e,["tap","click"],this.boundHandleTapClick_))}removeEventListenerForItem(e){e instanceof f&&(this.off(e,"blur",this.boundHandleBlur_),this.off(e,["tap","click"],this.boundHandleTapClick_))}removeChild(e){"string"==typeof e&&(e=this.getChild(e)),this.removeEventListenerForItem(e),super.removeChild(e)}addItem(e){e=this.addChild(e);e&&this.addEventListenerForItem(e)}createEl(){var e=this.options_.contentElType||"ul",e=(this.contentEl_=o(e,{className:"vjs-menu-content"}),this.contentEl_.setAttribute("role","menu"),super.createEl("div",{append:this.contentEl_,className:"vjs-menu"}));return e.appendChild(this.contentEl_),ot(e,"click",function(e){e.preventDefault(),e.stopImmediatePropagation()}),e}dispose(){this.contentEl_=null,this.boundHandleBlur_=null,this.boundHandleTapClick_=null,super.dispose()}handleBlur(e){const t=e.relatedTarget||document.activeElement;this.children().some(e=>e.el()===t)||(e=this.menuButton_)&&e.buttonPressed_&&t!==e.el().firstChild&&e.unpressButton()}handleTapClick(t){var e;this.menuButton_&&(this.menuButton_.unpressButton(),e=this.children(),Array.isArray(e))&&(e=e.filter(e=>e.el()===t.target)[0])&&"CaptionSettingsMenuItem"!==e.name()&&this.menuButton_.focus()}handleKeyDown(e){r.isEventKey(e,"Left")||r.isEventKey(e,"Down")?(e.preventDefault(),e.stopPropagation(),this.stepForward()):(r.isEventKey(e,"Right")||r.isEventKey(e,"Up"))&&(e.preventDefault(),e.stopPropagation(),this.stepBack())}stepForward(){let e=0;void 0!==this.focusedChild_&&(e=this.focusedChild_+1),this.focus(e)}stepBack(){let e=0;void 0!==this.focusedChild_&&(e=this.focusedChild_-1),this.focus(e)}focus(e=0){var t=this.children().slice();t.length&&t[0].hasClass("vjs-menu-title")&&t.shift(),0<t.length&&(e<0?e=0:e>=t.length&&(e=t.length-1),t[this.focusedChild_=e].el_.focus())}}f.registerComponent("Menu",ar);class or extends f{constructor(e,t={}){super(e,t),this.menuButton_=new s(e,t),this.menuButton_.controlText(this.controlText_),this.menuButton_.el_.setAttribute("aria-haspopup","true");e=s.prototype.buildCSSClass(),this.menuButton_.el_.className=this.buildCSSClass()+" "+e,this.menuButton_.removeClass("vjs-control"),this.addChild(this.menuButton_),this.update(),this.enabled_=!0,t=e=>this.handleClick(e);this.handleMenuKeyUp_=e=>this.handleMenuKeyUp(e),this.on(this.menuButton_,"tap",t),this.on(this.menuButton_,"click",t),this.on(this.menuButton_,"keydown",e=>this.handleKeyDown(e)),this.on(this.menuButton_,"mouseenter",()=>{this.addClass("vjs-hover"),this.menu.show(),ot(document,"keyup",this.handleMenuKeyUp_)}
3786),this.on("mouseleave",e=>this.handleMouseLeave(e)),this.on("keydown",e=>this.handleSubmenuKeyDown(e))}update(){var e=this.createMenu();this.menu&&(this.menu.dispose(),this.removeChild(this.menu)),this.menu=e,this.addChild(e),this.buttonPressed_=!1,this.menuButton_.el_.setAttribute("aria-expanded","false"),this.items&&this.items.length<=this.hideThreshold_?(this.hide(),this.menu.contentEl_.removeAttribute("role")):(this.show(),this.menu.contentEl_.setAttribute("role","menu"))}createMenu(){var e,t=new ar(this.player_,{menuButton:this});if(this.hideThreshold_=0,this.options_.title&&(e=o("li",{className:"vjs-menu-title",textContent:g(this.options_.title),tabIndex:-1}),e=new f(this.player_,{el:e}),t.addItem(e)),this.items=this.createItems(),this.items)for(let e=0;e<this.items.length;e++)t.addItem(this.items[e]);return t}createItems(){}createEl(){return super.createEl("div",{className:this.buildWrapperCSSClass()},{})}buildWrapperCSSClass(){let e="vjs-menu-button";!0===this.options_.inline?e+="-inline":e+="-popup";var t=s.prototype.buildCSSClass();return`vjs-menu-button ${e} ${t} `+super.buildCSSClass()}buildCSSClass(){let e="vjs-menu-button";return!0===this.options_.inline?e+="-inline":e+="-popup",`vjs-menu-button ${e} `+super.buildCSSClass()}controlText(e,t=this.menuButton_.el()){return this.menuButton_.controlText(e,t)}dispose(){this.handleMouseLeave(),super.dispose()}handleClick(e){this.buttonPressed_?this.unpressButton():this.pressButton()}handleMouseLeave(e){this.removeClass("vjs-hover"),p(document,"keyup",this.handleMenuKeyUp_)}focus(){this.menuButton_.focus()}blur(){this.menuButton_.blur()}handleKeyDown(e){r.isEventKey(e,"Esc")||r.isEventKey(e,"Tab")?(this.buttonPressed_&&this.unpressButton(),r.isEventKey(e,"Tab")||(e.preventDefault(),this.menuButton_.focus())):!r.isEventKey(e,"Up")&&!r.isEventKey(e,"Down")||this.buttonPressed_||(e.preventDefault(),this.pressButton())}handleMenuKeyUp(e){(r.isEventKey(e,"Esc")||r.isEventKey(e,"Tab"))&&this.removeClass("vjs-hover")}handleSubmenuKeyPress(e){this.handleSubmenuKeyDown(e)}handleSubmenuKeyDown(e){(r.isEventKey(e,"Esc")||r.isEventKey(e,"Tab"))&&(this.buttonPressed_&&this.unpressButton(),r.isEventKey(e,"Tab")||(e.preventDefault(),this.menuButton_.focus()))}pressButton(){this.enabled_&&(this.buttonPressed_=!0,this.menu.show(),this.menu.lockShowing(),this.menuButton_.el_.setAttribute("aria-expanded","true"),u&&be()||this.menu.focus())}unpressButton(){this.enabled_&&(this.buttonPressed_=!1,this.menu.unlockShowing(),this.menu.hide(),this.menuButton_.el_.setAttribute("aria-expanded","false"))}disable(){this.unpressButton(),this.enabled_=!1,this.addClass("vjs-disabled"),this.menuButton_.disable()}enable(){this.enabled_=!0,this.removeClass("vjs-disabled"),this.menuButton_.enable()}}f.registerComponent("MenuButton",or);class lr extends or{constructor(e,t){const i=t.tracks;if(super(e,t),this.items.length<=1&&this.hide(),i){const s=m(this,this.update);i.addEventListener("removetrack",s),i.addEventListener("addtrack",s),i.addEventListener("labelchange",s),this.player_.on("ready",s),this.player_.on("dispose",function(){i.removeEventListener("removetrack",s),i.removeEventListener("addtrack",s),i.removeEventListener("labelchange",s)})}}}f.registerComponent("TrackButton",lr);const dr=["Tab","Esc","Up","Down","Right","Left"];class hr extends ks{constructor(e,t){super(e,t),this.selectable=t.selectable,this.isSelected_=t.selected||!1,this.multiSelectable=t.multiSelectable,this.selected(this.isSelected_),this.selectable?this.multiSelectable?this.el_.setAttribute("role","menuitemcheckbox"):this.el_.setAttribute("role","menuitemradio"):this.el_.setAttribute("role","menuitem")}createEl(e,t,i){this.nonIconControl=!0;t=super.createEl("li",Object.assign({className:"vjs-menu-item",tabIndex:-1},t),i);return t.replaceChild(o("span",{className:"vjs-menu-item-text",textContent:this.localize(this.options_.label)}),t.querySelector(".vjs-icon-placeholder")),t}handleKeyDown(t){dr.some(e=>r.isEventKey(t,e))||super.handleKeyDown(t)}handleClick(e){this.selected(!0)}selected(e){this.selectable&&(e?(this.addClass("vjs-selected"),this.el_.setAttribute("aria-checked","true"),this.controlText(", selected"),this.isSelected_=!0):(this.removeClass("vjs-selected"),this.el_.setAttribute("aria-checked","fal
3786se"),this.controlText(""),this.isSelected_=!1))}}f.registerComponent("MenuItem",hr);class ur extends hr{constructor(e,t){var i=t.track;const s=e.textTracks(),r=(t.label=i.label||i.language||"Unknown",t.selected="showing"===i.mode,super(e,t),this.track=i,this.kinds=(t.kinds||[t.kind||this.track.kind]).filter(Boolean),(...e)=>{this.handleTracksChange.apply(this,e)}),n=(...e)=>{this.handleSelectedLanguageChange.apply(this,e)};if(e.on(["loadstart","texttrackchange"],r),s.addEventListener("change",r),s.addEventListener("selectedlanguagechange",n),this.on("dispose",function(){e.off(["loadstart","texttrackchange"],r),s.removeEventListener("change",r),s.removeEventListener("selectedlanguagechange",n)}),void 0===s.onchange){let e;this.on(["tap","click"],function(){if("object"!=typeof window.Event)try{e=new window.Event("change")}catch(e){}e||(e=document.createEvent("Event")).initEvent("change",!0,!0),s.dispatchEvent(e)})}this.handleTracksChange()}handleClick(e){var t=this.track,i=this.player_.textTracks();if(super.handleClick(e),i)for(let e=0;e<i.length;e++){var s=i[e];-1!==this.kinds.indexOf(s.kind)&&(s===t?"showing"!==s.mode&&(s.mode="showing"):"disabled"!==s.mode&&(s.mode="disabled"))}}handleTracksChange(e){var t="showing"===this.track.mode;t!==this.isSelected_&&this.selected(t)}handleSelectedLanguageChange(e){var t;"showing"!==this.track.mode||(t=this.player_.cache_.selectedLanguage)&&t.enabled&&t.language===this.track.language&&t.kind!==this.track.kind||(this.player_.cache_.selectedLanguage={enabled:!0,language:this.track.language,kind:this.track.kind})}dispose(){this.track=null,super.dispose()}}f.registerComponent("TextTrackMenuItem",ur);class cr extends ur{constructor(e,t){t.track={player:e,kind:t.kind,kinds:t.kinds,default:!1,mode:"disabled"},t.kinds||(t.kinds=[t.kind]),t.label?t.track.label=t.label:t.track.label=t.kinds.join(" and ")+" off",t.selectable=!0,t.multiSelectable=!1,super(e,t)}handleTracksChange(e){var i=this.player().textTracks();let s=!0;for(let e=0,t=i.length;e<t;e++){var r=i[e];if(-1<this.options_.kinds.indexOf(r.kind)&&"showing"===r.mode){s=!1;break}}s!==this.isSelected_&&this.selected(s)}handleSelectedLanguageChange(e){var i=this.player().textTracks();let s=!0;for(let e=0,t=i.length;e<t;e++){var r=i[e];if(-1<["captions","descriptions","subtitles"].indexOf(r.kind)&&"showing"===r.mode){s=!1;break}}s&&(this.player_.cache_.selectedLanguage={enabled:!1})}handleLanguagechange(){this.$(".vjs-menu-item-text").textContent=this.player_.localize(this.options_.label),super.handleLanguagechange()}}f.registerComponent("OffTextTrackMenuItem",cr);class pr extends lr{constructor(e,t={}){t.tracks=e.textTracks(),super(e,t)}createItems(t=[],i=ur){let e;this.label_&&(e=this.label_+" off"),t.push(new cr(this.player_,{kinds:this.kinds_,kind:this.kind_,label:e})),this.hideThreshold_+=1;var s=this.player_.textTracks();Array.isArray(this.kinds_)||(this.kinds_=[this.kind_]);for(let e=0;e<s.length;e++){var r,n=s[e];-1<this.kinds_.indexOf(n.kind)&&((r=new i(this.player_,{track:n,kinds:this.kinds_,kind:this.kind_,selectable:!0,multiSelectable:!1})).addClass(`vjs-${n.kind}-menu-item`),t.push(r))}return t}}f.registerComponent("TextTrackButton",pr);class mr extends hr{constructor(e,t){var i=t.track,s=t.cue,r=e.currentTime();t.selectable=!0,t.multiSelectable=!1,t.label=s.text,t.selected=s.startTime<=r&&r<s.endTime,super(e,t),this.track=i,this.cue=s}handleClick(e){super.handleClick(),this.player_.currentTime(this.cue.startTime)}}f.registerComponent("ChaptersTrackMenuItem",mr);class gr extends pr{constructor(e,t,i){super(e,t,i),this.selectCurrentItem_=()=>{this.items.forEach(e=>{e.selected(this.track_.activeCues[0]===e.cue)})}}buildCSSClass(){return"vjs-chapters-button "+super.buildCSSClass()}buildWrapperCSSClass(){return"vjs-chapters-button "+super.buildWrapperCSSClass()}update(e){e&&e.track&&"chapters"!==e.track.kind||((e=this.findChaptersTrack())!==this.track_?(this.setTrack(e),super.update()):(!this.items||e&&e.cues&&e.cues.length!==this.items.length)&&super.update())}setTrack(e){var t;this.track_!==e&&(this.updateHandler_||(this.updateHandler_=this.update.bind(this)),this.track_&&((t=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_))&&t.removeEventListener("load",this.updateHandler_),this.track_.removeEventListener("cuechange",this.selectCurrentItem_),this.track_=null),this.track_=e,this.track_)&&(this.track_.mode="hidden",(t=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_))&&t.addEventListener("load",this.updateHandler_),this.track_.addEventListener("cuechange",this.selectCurrentItem_))}
vendor: 8,502 bytes, line 3786
3786findChaptersTrack(){var t=this.player_.textTracks()||[];for(let e=t.length-1;0<=e;e--){var i=t[e];if(i.kind===this.kind_)return i}}getMenuCaption(){return this.track_&&this.track_.label?this.track_.label:this.localize(g(this.kind_))}createMenu(){return this.options_.title=this.getMenuCaption(),super.createMenu()}createItems(){var i=[];if(this.track_){var s=this.track_.cues;if(s)for(let e=0,t=s.length;e<t;e++){var r=s[e],r=new mr(this.player_,{track:this.track_,cue:r});i.push(r)}}return i}}gr.prototype.kind_="chapters",gr.prototype.controlText_="Chapters",f.registerComponent("ChaptersButton",gr);class fr extends pr{constructor(e,t,i){super(e,t,i);const s=e.textTracks(),r=m(this,this.handleTracksChange);s.addEventListener("change",r),this.on("dispose",function(){s.removeEventListener("change",r)})}handleTracksChange(e){var i=this.player().textTracks();let s=!1;for(let e=0,t=i.length;e<t;e++){var r=i[e];if(r.kind!==this.kind_&&"showing"===r.mode){s=!0;break}}s?this.disable():this.enable()}buildCSSClass(){return"vjs-descriptions-button "+super.buildCSSClass()}buildWrapperCSSClass(){return"vjs-descriptions-button "+super.buildWrapperCSSClass()}}fr.prototype.kind_="descriptions",fr.prototype.controlText_="Descriptions",f.registerComponent("DescriptionsButton",fr);class yr extends pr{constructor(e,t,i){super(e,t,i)}buildCSSClass(){return"vjs-subtitles-button "+super.buildCSSClass()}buildWrapperCSSClass(){return"vjs-subtitles-button "+super.buildWrapperCSSClass()}}yr.prototype.kind_="subtitles",yr.prototype.controlText_="Subtitles",f.registerComponent("SubtitlesButton",yr);class _r extends ur{constructor(e,t){t.track={player:e,kind:t.kind,label:t.kind+" settings",selectable:!1,default:!1,mode:"disabled"},t.selectable=!1,t.name="CaptionSettingsMenuItem",super(e,t),this.addClass("vjs-texttrack-settings"),this.controlText(", opens "+t.kind+" settings dialog")}handleClick(e){this.player().getChild("textTrackSettings").open()}handleLanguagechange(){this.$(".vjs-menu-item-text").textContent=this.player_.localize(this.options_.kind+" settings"),super.handleLanguagechange()}}f.registerComponent("CaptionSettingsMenuItem",_r);class vr extends pr{constructor(e,t,i){super(e,t,i)}buildCSSClass(){return"vjs-captions-button "+super.buildCSSClass()}buildWrapperCSSClass(){return"vjs-captions-button "+super.buildWrapperCSSClass()}createItems(){var e=[];return this.player().tech_&&this.player().tech_.featuresNativeTextTracks||!this.player().getChild("textTrackSettings")||(e.push(new _r(this.player_,{kind:this.kind_})),this.hideThreshold_+=1),super.createItems(e)}}vr.prototype.kind_="captions",vr.prototype.controlText_="Captions",f.registerComponent("CaptionsButton",vr);class br extends ur{createEl(e,t,i){e=super.createEl(e,t,i),t=e.querySelector(".vjs-menu-item-text");return"captions"===this.options_.track.kind&&(t.appendChild(o("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),t.appendChild(o("span",{className:"vjs-control-text",textContent:" "+this.localize("Captions")}))),e}}f.registerComponent("SubsCapsMenuItem",br);class Tr extends pr{constructor(e,t={}){super(e,t),this.label_="subtitles",-1<["en","en-us","en-ca","fr-ca"].indexOf(this.player_.language_)&&(this.label_="captions"),this.menuButton_.controlText(g(this.label_))}buildCSSClass(){return"vjs-subs-caps-button "+super.buildCSSClass()}buildWrapperCSSClass(){return"vjs-subs-caps-button "+super.buildWrapperCSSClass()}createItems(){let e=[];return this.player().tech_&&this.player().tech_.featuresNativeTextTracks||!this.player().getChild("textTrackSettings")||(e.push(new _r(this.player_,{kind:this.label_})),this.hideThreshold_+=1),e=super.createItems(e,br)}}Tr.prototype.kinds_=["captions","subtitles"],Tr.prototype.controlText_="Subtitles",f.registerComponent("SubsCapsButton",Tr);class Sr extends hr{constructor(e,t){var i=t.track;const s=e.audioTracks(),r=(t.label=i.label||i.language||"Unknown",t.selected=i.enabled,super(e,t),this.track=i,this.addClass(`vjs-${i.kind}-menu-item`),(...e)=>{this.handleTracksChange.apply(this,e)});s.addEventListener("change",r),this.on("dispose",()=>{s.removeEventListener("change",r)})}createEl(e,t,i){e=super.createEl(e,t,i),t=e.querySelector(".vjs-menu-item-text");return"main-desc"===this.options_.track.kind&&(t.appendChild(o("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),t.appendChild(o("span",{className:"vjs-control-text",textContent:" "+this.localize("Descriptions")}))),e}handleClick(e){if(super.handleClick(e),this.track.enabled=!0,this.player_.tech_.featuresNativeAudioTracks){var t=this.player_.audioTracks();for(let e=0;e<t.length;e++){var i=t[e];i!==this.track&&(i.enabled=i===this.track)}}}handleTracksChange(e){this.selected(this.track.enabled)}}f.registerComponent("AudioTrackMenuItem",Sr);class wr extends lr{constructor(e,t={}){t.tracks=e.audioTracks(),super(e,t)}buildCSSClass(){return"vjs-audio-button "+super.buildCSSClass()}buildWrapperCSSClass(){return"vjs-audio-button "+super.buildWrapperCSSClass()}createItems(t=[]){this.hideThreshold_=1;var i=this.player_.audioTracks();for(let e=0;e<i.length;e++){var s=i[e];t.push(new Sr(this.player_,{track:s,selectable:!0,multiSelectable:!1}))}return t}}wr.prototype.controlText_="Audio Track",f.registerComponent("AudioTrackButton",wr);class Er extends hr{constructor(e,t){var i=t.rate,s=parseFloat(i,10);t.label=i,t.selected=s===e.playbackRate(),t.selectable=!0,t.multiSelectable=!1,super(e,t),this.label=i,this.rate=s,this.on(e,"ratechange",e=>this.update(e))}handleClick(e){super.handleClick(),this.player().playbackRate(this.rate)}update(e){this.selected(this.player().playbackRate()===this.rate)}}Er.prototype.contentElType="button",f.registerComponent("PlaybackRateMenuItem",Er);class kr extends or{constructor(e,t){super(e,t),this.menuButton_.el_.setAttribute("aria-describedby",this.labelElId_),this.updateVisibility(),this.updateLabel(),this.on(e,"loadstart",e=>this.updateVisibility(e)),this.on(e,"ratechange",e=>this.updateLabel(e)),this.on(e,"playbackrateschange",e=>this.handlePlaybackRateschange(e))}createEl(){var e=super.createEl();return this.labelElId_="vjs-playback-rate-value-label-"+this.id_,this.labelEl_=o("div",{className:"vjs-playback-rate-value",id:this.labelElId_,textContent:"1x"}),e.appendChild(this.labelEl_),e}dispose(){this.labelEl_=null,super.dispose()}buildCSSClass(){return"vjs-playback-rate "+super.buildCSSClass()}buildWrapperCSSClass(){return"vjs-playback-rate "+super.buildWrapperCSSClass()}createItems(){var t=this.playbackRates(),i=[];for(let e=t.length-1;0<=e;e--)i.push(new Er(this.player(),{rate:t[e]+"x"}));return i}handlePlaybackRateschange(e){this.update()}playbackRates(){var e=this.player();return e.playbackRates&&e.playbackRates()||[]}playbackRateSupported(){return this.player().tech_&&this.player().tech_.featuresPlaybackRate&&this.playbackRates()&&0<this.playbackRates().length}updateVisibility(e){this.playbackRateSupported()?this.removeClass("vjs-hidden"):this.addClass("vjs-hidden")}updateLabel(e){this.playbackRateSupported()&&(this.labelEl_.textContent=this.player().playbackRate()+"x")}}kr.prototype.controlText_="Playback Rate",f.registerComponent("PlaybackRateMenuButton",kr);class Cr extends f{buildCSSClass(){return"vjs-spacer "+super.buildCSSClass()}createEl(e="div",t={},i={}){return t.className||(t.className=this.buildCSSClass()),super.createEl(e,t,i)}}f.registerComponent("Spacer",Cr);f.registerComponent("CustomControlSpacer",class extends Cr{buildCSSClass(){return"vjs-custom-control-spacer "+super.buildCSSClass()}createEl(){return super.createEl("div",{className:this.buildCSSClass(),textContent:"Ã "})}});class Ir extends f{createEl(){return super.createEl("div",{className:"vjs-control-bar",dir:"ltr"})}}Ir.prototype.options_={children:["playToggle","skipBackward","skipForward","volumePanel","currentTimeDisplay","timeDivider","durationDisplay","progressControl","liveDisplay","seekToLive","remainingTimeDisplay","customControlSpacer","playbackRateMenuButton","chaptersButton","descriptionsButton","subsCapsButton","audioTrackButton","fullscreenToggle"]},"exitPictureInPicture"in document&&Ir.prototype.options_.children.splice(Ir.prototype.options_.children.length-1,0,"pictureInPictureToggle"),f.registerComponent("ControlBar",Ir);class xr extends Qt{constructor(e,t){super(e,t),this.on(e,"error",e=>this.open(e))}buildCSSClass(){return"vjs-error-display "+super.buildCSSClass()}content(){var e=this.player().error();return e?this.localize(e.message):""}}xr.prototype.options_=Object.assign({}
3786,Qt.prototype.options_,{pauseOnOpen:!1,fillAlways:!0,temporary:!1,uncloseable:!0}),f.registerComponent("ErrorDisplay",xr);const Ar="vjs-text-track-settings";var Mi=["#000","Black"],Ot=["#00F","Blue"],Pr=["#0FF","Cyan"],Lr=["#0F0","Green"],t=["#F0F","Magenta"],Or=["#F00","Red"],Dr=["#FFF","White"],n=["#FF0","Yellow"],Nr=["1","Opaque"],Mr=["0.5","Semi-Transparent"],Rr=["0","Transparent"];const Ur={backgroundColor:{selector:".vjs-bg-color > select",id:"captions-background-color-%s",label:"Color",options:[Mi,Dr,Or,Lr,Ot,n,t,Pr]},backgroundOpacity:{selector:".vjs-bg-opacity > select",id:"captions-background-opacity-%s",label:"Opacity",options:[Nr,Mr,Rr]},color:{selector:".vjs-text-color > select",id:"captions-foreground-color-%s",label:"Color",options:[Dr,Mi,Or,Lr,Ot,n,t,Pr]},edgeStyle:{selector:".vjs-edge-style > select",id:"%s",label:"Text Edge Style",options:[["none","None"],["raised","Raised"],["depressed","Depressed"],["uniform","Uniform"],["dropshadow","Dropshadow"]]},fontFamily:{selector:".vjs-font-family > select",id:"captions-font-family-%s",label:"Font Family",options:[["proportionalSansSerif","Proportional Sans-Serif"],["monospaceSansSerif","Monospace Sans-Serif"],["proportionalSerif","Proportional Serif"],["monospaceSerif","Monospace Serif"],["casual","Casual"],["script","Script"],["small-caps","Small Caps"]]},fontPercent:{selector:".vjs-font-percent > select",id:"captions-font-size-%s",label:"Font Size",options:[["0.50","50%"],["0.75","75%"],["1.00","100%"],["1.25","125%"],["1.50","150%"],["1.75","175%"],["2.00","200%"],["3.00","300%"],["4.00","400%"]],default:2,parser:e=>"1.00"===e?null:Number(e)},textOpacity:{selector:".vjs-text-opacity > select",id:"captions-foreground-opacity-%s",label:"Opacity",options:[Nr,Mr]},windowColor:{selector:".vjs-window-color > select",id:"captions-window-color-%s",label:"Color"},windowOpacity:{selector:".vjs-window-opacity > select",id:"captions-window-opacity-%s",label:"Opacity",options:[Rr,Mr,Nr]}};function Br(e,t){if((e=t?t(e):e)&&"none"!==e)return e}Ur.windowColor.options=Ur.backgroundColor.options;class Fr extends Qt{constructor(e,t){t.temporary=!1,super(e,t),this.updateDisplay=this.updateDisplay.bind(this),this.fill(),this.hasBeenOpened_=this.hasBeenFilled_=!0,this.endDialog=o("p",{className:"vjs-control-text",textContent:this.localize("End of dialog window.")}),this.el().appendChild(this.endDialog),this.setDefaults(),void 0===t.persistTextTrackSettings&&(this.options_.persistTextTrackSettings=this.options_.playerOptions.persistTextTrackSettings),this.on(this.$(".vjs-done-button"),"click",()=>{this.saveSettings(),this.close()}),this.on(this.$(".vjs-default-button"),"click",()=>{this.setDefaults(),this.updateDisplay()}),z(Ur,e=>{this.on(this.$(e.selector),"change",this.updateDisplay)}),this.options_.persistTextTrackSettings&&this.restoreSettings()}dispose(){this.endDialog=null,super.dispose()}createElSelect_(e,t="",i="label"){e=Ur[e];const s=e.id.replace("%s",this.id_),r=[t,s].join(" ").trim();return[`<${i} id="${s}" class="${"label"===i?"vjs-label":""}">`,this.localize(e.label),`</${i}>`,`<select aria-labelledby="${r}">`].concat(e.options.map(e=>{var t=s+"-"+e[1].replace(/\W+/g,"");return[`<option id="${t}" value="${e[0]}" `,`aria-labelledby="${r} ${t}">`,this.localize(e[1]),"</option>"].join("")})).concat("</select>").join("")}createElFgColor_(){var e="captions-text-legend-"+this.id_;return['<fieldset class="vjs-fg vjs-track-setting">',`<legend id="${e}">`,this.localize("Text"),"</legend>",'<span class="vjs-text-color">',this.createElSelect_("color",e),"</span>",'<span class="vjs-text-opacity vjs-opacity">',this.createElSelect_("textOpacity",e),"</span>","</fieldset>"].join("")}createElBgColor_(){var e="captions-background-"+this.id_;return['<fieldset class="vjs-bg vjs-track-setting">',`<legend id="${e}">`,this.localize("Text Background"),"</legend>",'<span class="vjs-bg-color">',this.createElSelect_("backgroundColor",e),"</span>",'<span class="vjs-bg-opacity vjs-opacity">',this.createElSelect_("backgroundOpacity",e),"</span>","</fieldset>"].join("")}createElWinColor_(){var e="captions-window-"+this.id_;return['<fieldset class="vjs-window vjs-track-setting">',`<legend id="${e}">
3786`,this.localize("Caption Area Background"),"</legend>",'<span class="vjs-window-color">',this.createElSelect_("windowColor",e),"</span>",'<span class="vjs-window-opacity vjs-opacity">',this.createElSelect_("windowOpacity",e),"</span>","</fieldset>"].join("")}createElColors_(){return o("div",{className:"vjs-track-settings-colors",innerHTML:[this.createElFgColor_(),this.createElBgColor_(),this.createElWinColor_()].join("")})}createElFont_(){return o("div",{className:"vjs-track-settings-font",innerHTML:['<fieldset class="vjs-font-percent vjs-track-setting">',this.createElSelect_("fontPercent","","legend"),"</fieldset>",'<fieldset class="vjs-edge-style vjs-track-setting">',this.createElSelect_("edgeStyle","","legend"),"</fieldset>",'<fieldset class="vjs-font-family vjs-track-setting">',this.createElSelect_("fontFamily","","legend"),"</fieldset>"].join("")})}createElControls_(){var e=this.localize("restore all settings to the default values");return o("div",{className:"vjs-track-settings-controls",innerHTML:[`<button type="button" class="vjs-default-button" title="${e}">`,this.localize("Reset"),`<span class="vjs-control-text"> ${e}</span>`,"</button>",`<button type="button" class="vjs-done-button">${this.localize("Done")}</button>`].join("")})}content(){return[this.createElColors_(),this.createElFont_(),this.createElControls_()]}label(){return this.localize("Caption Settings Dialog")}description(){return this.localize("Beginning of dialog window. Escape will cancel and close the window.")}buildCSSClass(){return super.buildCSSClass()+" vjs-text-track-settings"}getValues(){return X(Ur,(e,t,i)=>{s=this.$(t.selector),t=t.parser;var s=Br(s.options[s.options.selectedIndex].value,t);return void 0!==s&&(e[i]=s),e},{})}setValues(n){z(Ur,(e,t)=>{var i=this.$(e.selector),s=n[t],r=e.parser;if(s)for(let e=0;e<i.options.length;e++)if(Br(i.options[e].value,r)===s){i.selectedIndex=e;break}})}setDefaults(){z(Ur,e=>{var t=e.hasOwnProperty("default")?e.default:0;this.$(e.selector).selectedIndex=t})}restoreSettings(){let e;try{e=JSON.parse(window.localStorage.getItem(Ar))}catch(e){d.warn(e)}e&&this.setValues(e)}saveSettings(){if(this.options_.persistTextTrackSettings){var e=this.getValues();try{Object.keys(e).length?window.localStorage.setItem(Ar,JSON.stringify(e)):window.localStorage.removeItem(Ar)}catch(e){d.warn(e)}}}updateDisplay(){var e=this.player_.getChild("textTrackDisplay");e&&e.updateDisplay()}conditionalBlur_(){this.previouslyActiveEl_=null;var e=this.player_.controlBar,t=e&&e.subsCapsButton,e=e&&e.captionsButton;t?t.focus():e&&e.focus()}handleLanguagechange(){this.fill()}}f.registerComponent("TextTrackSettings",Fr);class jr extends f{constructor(e,t){let i=t.ResizeObserver||window.ResizeObserver;super(e,h({createEl:!(i=null===t.ResizeObserver?!1:i),reportTouchActivity:!1},t)),this.ResizeObserver=t.ResizeObserver||window.ResizeObserver,this.loadListener_=null,this.resizeObserver_=null,this.debouncedHandler_=pt(()=>{this.resizeHandler()},100,!1,this),i?(this.resizeObserver_=new this.ResizeObserver(this.debouncedHandler_),this.resizeObserver_.observe(e.el())):(this.loadListener_=()=>{if(this.el_&&this.el_.contentWindow){const t=this.debouncedHandler_;let e=this.unloadListener_=function(){p(this,"resize",t),p(this,"unload",e),e=null};ot(this.el_.contentWindow,"unload",e),ot(this.el_.contentWindow,"resize",t)}},this.one("load",this.loadListener_))}createEl(){return super.createEl("iframe",{className:"vjs-resize-manager",tabIndex:-1,title:this.localize("No content")},{"aria-hidden":"true"})}resizeHandler(){this.player_&&this.player_.trigger&&this.player_.trigger("playerresize")}dispose(){this.debouncedHandler_&&this.debouncedHandler_.cancel(),this.resizeObserver_&&(this.player_.el()&&this.resizeObserver_.unobserve(this.player_.el()),this.resizeObserver_.disconnect()),this.loadListener_&&this.off("load",this.loadListener_),this.el_&&this.el_.contentWindow&&this.unloadListener_&&this.unloadListener_.call(this.el_.contentWindow),this.ResizeObserver=null,this.resizeObserver=null,this.debouncedHandler_=null,this.loadListener_=null,super.dispose()}}f.registerComponent("ResizeManager",jr);const Hr={trackingThreshold:20,liveTolerance:15};class qr extends f{constructor(e,t){super(e,h(Hr,t,{createEl:!1})),this.trackLiveHandler_=()=>this.trackLive_(),this.handlePlay_=e=>this.handlePlay(e),this.handleFirstTimeupdate_=e=>this.handleFirstTimeupdate(e),this.handleSeeked_=e=>this.handleSeeked(e),this.seekToLiveEdge_=e=>this.seekToLiveEdge(e),this.reset_(),this.on(this.player_,"durationchange",e=>this.handleDurationchange(e)),this.on(this.player_,"canplay",()=>this.toggleTracking())}trackLive_(){var t=this.player_.seekable();if(t&&t.length){var t=Number(window.performance.now().toFixed(4)),i=-1===this.lastTime_?0:(t-this.lastTime_)/1e3,t=(this.lastTime_=t,this.pastSeekEnd_=this.pastSeekEnd()+i,this.liveCurrentTime()),i=this.player_.currentTime();let e=this.player_.paused()||this.seekedBehindLive_||Math.abs(t-i)>this.options_.liveTolerance;(e=this.timeupdateSeen_&&t!==1/0?e:!1)!==this.behindLiveEdge_&&(this.behindLiveEdge_=e,this.trigger("liveedgechange"))}}handleDurationchange(){this.toggleTracking()}toggleTracking(){this.player_.duration()===1/0&&this.liveWindow()>=this.options_.trackingThreshold?(this.player_.options_.liveui&&this.player_.addClass("vjs-liveui"),this.startTracking()):(this.player_.removeClass("vjs-liveui"),this.stopTracking())}startTracking(){this.isTracking()||(this.timeupdateSeen_||(this.timeupdateSeen_=this.player_.hasStarted()),this.trackingInterval_=this.setInterval(this.trackLiveHandler_,30),this.trackLive_(),this.on(this.player_,["play","pause"],this.trackLiveHandler_),this.timeupdateSeen_?this.on(this.player_,"seeked",this.handleSeeked_):(this.one(this.player_,"play",this.handlePlay_),this.one(this.player_,"timeupdate",this.handleFirstTimeupdate_)))}handleFirstTimeupdate(){this.timeupdateSeen_=!0,this.on(this.player_,"seeked",this.handleSeeked_)}handleSeeked(){var e=Math.abs(this.liveCurrentTime()-this.player_.currentTime());this.seekedBehindLive_=this.nextSeekedFromUser_&&2<e,this.nextSeekedFromUser_=!1,this.trackLive_()}handlePlay(){this.one(this.player_,"timeupdate",this.seekToLiveEdge_)}reset_(){this.lastTime_=-1,this.pastSeekEnd_=0,this.lastSeekEnd_=-1,this.behindLiveEdge_=!0,this.timeupdateSeen_=!1,this.seekedBehindLive_=!1,this.nextSeekedFromUser_=!1,this.clearInterval(this.trackingInterval_),this.trackingInterval_=null,this.off(this.player_,["play","pause"],this.trackLiveHandler_),this.off(this.player_,"seeked",this.handleSeeked_),this.off(this.player_,"play",this.handlePlay_),this.off(this.player_,"timeupdate",this.handleFirstTimeupdate_),this.off(this.player_,"timeupdate",this.seekToLiveEdge_)}nextSeekedFromUser(){this.nextSeekedFromUser_=!0}stopTracking(){this.isTracking()&&(this.reset_(),this.trigger("liveedgechange"))}seekableEnd(){var e=this.player_.seekable(),t=[];let i=e?e.length:0;for(;i--;)t.push(e.end(i));return t.length?t.sort()[t.length-1]:1/0}seekableStart(){var e=this.player_.seekable(),t=[];let i=e?e.length:0;for(;i--;)t.push(e.start(i));return t.length?t.sort()[0]:0}
vendor: 6,012 bytes, line 3786
3786liveWindow(){var e=this.liveCurrentTime();return e===1/0?0:e-this.seekableStart()}isLive(){return this.isTracking()}atLiveEdge(){return!this.behindLiveEdge()}liveCurrentTime(){return this.pastSeekEnd()+this.seekableEnd()}pastSeekEnd(){var e=this.seekableEnd();return-1!==this.lastSeekEnd_&&e!==this.lastSeekEnd_&&(this.pastSeekEnd_=0),this.lastSeekEnd_=e,this.pastSeekEnd_}behindLiveEdge(){return this.behindLiveEdge_}isTracking(){return"number"==typeof this.trackingInterval_}seekToLiveEdge(){this.seekedBehindLive_=!1,this.atLiveEdge()||(this.nextSeekedFromUser_=!1,this.player_.currentTime(this.liveCurrentTime()))}dispose(){this.stopTracking(),super.dispose()}}f.registerComponent("LiveTracker",qr);class Vr extends f{constructor(e,t){super(e,t),this.on("statechanged",e=>this.updateDom_()),this.updateDom_()}createEl(){return this.els={title:o("div",{className:"vjs-title-bar-title",id:"vjs-title-bar-title-"+tt++}),description:o("div",{className:"vjs-title-bar-description",id:"vjs-title-bar-description-"+tt++})},o("div",{className:"vjs-title-bar"},{},Object.values(this.els))}updateDom_(){var e=this.player_.tech_;const s=e&&e.el_,r={title:"aria-labelledby",description:"aria-describedby"};["title","description"].forEach(e=>{var t=this.state[e],i=this.els[e],e=r[e];Fe(i),t&&Se(i,t),s&&(s.removeAttribute(e),t)&&s.setAttribute(e,i.id)}),this.state.title||this.state.description?this.show():this.hide()}update(e){this.setState(e)}dispose(){var e=this.player_.tech_,e=e&&e.el_;e&&(e.removeAttribute("aria-labelledby"),e.removeAttribute("aria-describedby")),super.dispose(),this.els=null}}f.registerComponent("TitleBar",Vr);function $r(i){const s=i.el();if(!s.resetSourceWatch_){const t={},e=Kr(i),r=t=>(...e)=>{e=t.apply(s,e);return Gr(i),e};["append","appendChild","insertAdjacentHTML"].forEach(e=>{s[e]&&(t[e]=s[e],s[e]=r(t[e]))}),Object.defineProperty(s,"innerHTML",h(e,{set:r(e.set)})),s.resetSourceWatch_=()=>{s.resetSourceWatch_=null,Object.keys(t).forEach(e=>{s[e]=t[e]}),Object.defineProperty(s,"innerHTML",e)},i.one("sourceset",s.resetSourceWatch_)}}function Wr(i){if(i.featuresSourceset){const s=i.el();if(!s.resetSourceset_){e=i;const t=Xr([e.el(),window.HTMLMediaElement.prototype,Yr],"src");var e;const r=s.setAttribute,n=s.load;Object.defineProperty(s,"src",h(t,{set:e=>{e=t.set.call(s,e);return i.triggerSourceset(s.src),e}})),s.setAttribute=(e,t)=>{t=r.call(s,e,t);return/src/i.test(e)&&i.triggerSourceset(s.src),t},s.load=()=>{var e=n.call(s);return Gr(i)||(i.triggerSourceset(""),$r(i)),e},s.currentSrc?i.triggerSourceset(s.currentSrc):Gr(i)||$r(i),s.resetSourceset_=()=>{s.resetSourceset_=null,s.load=n,s.setAttribute=r,Object.defineProperty(s,"src",t),s.resetSourceWatch_&&s.resetSourceWatch_()}}}}const Gr=t=>{var e=t.el();if(e.hasAttribute("src"))t.triggerSourceset(e.src);else{var i=t.$$("source"),s=[];let e="";if(!i.length)return!1;for(let e=0;e<i.length;e++){var r=i[e].src;r&&-1===s.indexOf(r)&&s.push(r)}if(!s.length)return!1;1===s.length&&(e=s[0]),t.triggerSourceset(e)}return!0},zr=Object.defineProperty({},"innerHTML",{get(){return this.cloneNode(!0).innerHTML},set(e){for(var t=document.createElement(this.nodeName.toLowerCase()),i=(t.innerHTML=e,document.createDocumentFragment());t.childNodes.length;)i.appendChild(t.childNodes[0]);return this.innerText="",window.Element.prototype.appendChild.call(this,i),this.innerHTML}}),Xr=(t,i)=>{let s={};for(let e=0;e<t.length&&!((s=Object.getOwnPropertyDescriptor(t[e],i))&&s.set&&s.get);e++);return s.enumerable=!0,s.configurable=!0,s},Kr=e=>Xr([e.el(),window.HTMLMediaElement.prototype,window.Element.prototype,zr],"innerHTML"),Yr=Object.defineProperty({},"src",{get(){return this.hasAttribute("src")?di(window.Element.prototype.getAttribute.call(this,"src")):""},set(e){return window.Element.prototype.setAttribute.call(this,"src",e),e}});class v extends _{constructor(e,t){super(e,t);t=e.source;let i=!1;if(this.featuresVideoFrameCallback=this.featuresVideoFrameCallback&&"VIDEO"===this.el_.tagName,t&&(this.el_.currentSrc!==t.src||e.tag&&3===e.tag.initNetworkState_)?this.setSource(t):this.handleLateInit_(this.el_),e.enableSourceset&&this.setupSourcesetHandling_(),this.isScrubbing_=!1,this.el_.hasChildNodes()){var s=this.el_.childNodes;let e=s.length;for(var r=[];e--;){var n=s[e];"track"===n.nodeName.toLowerCase()&&(this.featuresNativeTextTracks?(this.remoteTextTrackEls().addTrackElement_(n),this.remoteTextTracks().addTrack(n.track),this.textTracks().addTrack(n.track),i||this.el_.hasAttribute("crossorigin")||!hi(n.src)||(i=!0)):r.push(n))}for(let e=0;e<r.length;e++)this.el_.removeChild(r[e])}this.proxyNativeTracks_(),this.featuresNativeTextTracks&&i&&d.warn("Text Tracks are being loaded from another origin but the crossorigin attribute isn't used.\nThis may prevent text tracks from loading."),this.restoreMetadataTracksInIOSNativePlayer_(),(me||pe)&&!0===e.nativeControlsForTouch&&this.setControls(!0),this.proxyWebkitFullscreen_(),this.triggerReady()}dispose(){this.el_&&this.el_.resetSourceset_&&this.el_.resetSourceset_(),v.disposeMediaElement(this.el_),this.options_=null,super.dispose()}setupSourcesetHandling_(){Wr(this)}restoreMetadataTracksInIOSNativePlayer_(){const i=this.textTracks();let s;const e=()=>{s=[];for(let e=0;e<i.length;e++){var t=i[e];"metadata"===t.kind&&s.push({track:t,storedMode:t.mode})}},r=(e(),i.addEventListener("change",e),this.on("dispose",()=>i.removeEventListener("change",e)),()=>{for(let e=0;e<s.length;e++){var t=s[e];"disabled"===t.track.mode&&t.track.mode!==t.storedMode&&(t.track.mode=t.storedMode)}i.removeEventListener("change",r)});this.on("webkitbeginfullscreen",()=>{i.removeEventListener("change",e),i.removeEventListener("change",r),i.addEventListener("change",r)}),this.on("webkitendfullscreen",()=>{i.removeEventListener("change",e),i.addEventListener("change",e),i.removeEventListener("change",r)})}overrideNative_(e,t){if(t===this[`featuresNative${e}Tracks`]){const i=e.toLowerCase();this[i+"TracksListeners_"]&&Object.keys(this[i+"TracksListeners_"]).forEac
vendor: 6,461 bytes, line 3786
3786h(e=>{this.el()[i+"Tracks"].removeEventListener(e,this[i+"TracksListeners_"][e])}),this[`featuresNative${e}Tracks`]=!t,this[i+"TracksListeners_"]=null,this.proxyNativeTracksForType_(i)}}overrideNativeAudioTracks(e){this.overrideNative_("Audio",e)}overrideNativeVideoTracks(e){this.overrideNative_("Video",e)}proxyNativeTracksForType_(i){var e=Di[i];const s=this.el()[e.getterName],r=this[e.getterName]();if(this[`featuresNative${e.capitalName}Tracks`]&&s&&s.addEventListener){const n={change:e=>{var t={type:"change",target:r,currentTarget:r,srcElement:r};r.trigger(t),"text"===i&&this[Ni.remoteText.getterName]().trigger(t)},addtrack(e){r.addTrack(e.track)},removetrack(e){r.removeTrack(e.track)}},t=function(){var e=[];for(let i=0;i<r.length;i++){let t=!1;for(let e=0;e<s.length;e++)if(s[e]===r[i]){t=!0;break}t||e.push(r[i])}for(;e.length;)r.removeTrack(e.shift())};this[e.getterName+"Listeners_"]=n,Object.keys(n).forEach(t=>{const i=n[t];s.addEventListener(t,i),this.on("dispose",e=>s.removeEventListener(t,i))}),this.on("loadstart",t),this.on("dispose",e=>this.off("loadstart",t))}}proxyNativeTracks_(){Di.names.forEach(e=>{this.proxyNativeTracksForType_(e)})}createEl(){let t=this.options_.tag;t&&(this.options_.playerElIngest||this.movingMediaElementInDOM)||(t?(e=t.cloneNode(!0),t.parentNode&&t.parentNode.insertBefore(e,t),v.disposeMediaElement(t),t=e):(t=document.createElement("video"),e=h({},this.options_.tag&&Ae(this.options_.tag)),me&&!0===this.options_.nativeControlsForTouch||delete e.controls,xe(t,Object.assign(e,{id:this.options_.techId,class:"vjs-tech"}))),t.playerId=this.options_.playerId),"undefined"!=typeof this.options_.preload&&Le(t,"preload",this.options_.preload),void 0!==this.options_.disablePictureInPicture&&(t.disablePictureInPicture=this.options_.disablePictureInPicture);var e,i=["loop","muted","playsinline","autoplay"];for(let e=0;e<i.length;e++){var s=i[e],r=this.options_[s];"undefined"!=typeof r&&(r?Le(t,s,s):Oe(t,s),t[s]=r)}return t}handleLateInit_(e){if(0!==e.networkState&&3!==e.networkState)if(0===e.readyState){let e=!1;const t=function(){e=!0},i=(this.on("loadstart",t),function(){e||this.trigger("loadstart")});this.on("loadedmetadata",i),void this.ready(function(){this.off("loadstart",t),this.off("loadedmetadata",i),e||this.trigger("loadstart")})}else{const s=["loadstart"];s.push("loadedmetadata"),2<=e.readyState&&s.push("loadeddata"),3<=e.readyState&&s.push("canplay"),4<=e.readyState&&s.push("canplaythrough"),this.ready(function(){s.forEach(function(e){this.trigger(e)},this)})}}setScrubbing(e){this.isScrubbing_=e}scrubbing(){return this.isScrubbing_}setCurrentTime(e){try{this.isScrubbing_&&this.el_.fastSeek&&fe?this.el_.fastSeek(e):this.el_.currentTime=e}catch(e){d(e,"Video is not ready. (Video.js)")}}duration(){if(this.el_.duration===1/0&&te&&ae&&0===this.el_.currentTime){const e=()=>{0<this.el_.currentTime&&(this.el_.duration===1/0&&this.trigger("durationchange"),this.off("timeupdate",e))};return this.on("timeupdate",e),NaN}return this.el_.duration||NaN}width(){return this.el_.offsetWidth}height(){return this.el_.offsetHeight}proxyWebkitFullscreen_(){if("webkitDisplayingFullscreen"in this.el_){const e=function(){this.trigger("fullscreenchange",{isFullscreen:!1}),this.el_.controls&&!this.options_.nativeControlsForTouch&&this.controls()&&(this.el_.controls=!1)},t=function(){"webkitPresentationMode"in this.el_&&"picture-in-picture"!==this.el_.webkitPresentationMode&&(this.one("webkitendfullscreen",e),this.trigger("fullscreenchange",{isFullscreen:!0,nativeIOSFullscreen:!0}))};this.on("webkitbeginfullscreen",t),this.on("dispose",()=>{this.off("webkitbeginfullscreen",t),this.off("webkitendfullscreen",e)})}}supportsFullScreen(){return"function"==typeof this.el_.webkitEnterFullScreen}enterFullScreen(){const e=this.el_;if(e.paused&&e.networkState<=e.HAVE_METADATA)Gt(this.el_.play()),this.setTimeout(function(){e.pause();try{e.webkitEnterFullScreen()}catch(e){this.trigger("fullscreenerror",e)}},0);else try{e.webkitEnterFullScreen()}catch(e){this.trigger("fullscreenerror",e)}}exitFullScreen(){this.el_.webkitDisplayingFullscreen?this.el_.webkitExitFullScreen():this.trigger("fullscreenerror",new Error("The video is not fullscreen"))}requestPictureInPicture(){return this.el_.requestPictureInPicture()}requestVideoFrameCallback(e){return this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.requestVideoFrameCallback(e):super.requestVideoFrameCallback(e)}cancelVideoFrameCallback(e){this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.cancelVideoFrameCallback(e):super.cancelVideoFrameCallback(e)}src(e){if(void 0===e)return this.el_.src;this.setSrc(e)}reset(){v.resetMediaElement(this.el_)}currentSrc(){return this.currentSource_?this.currentSource_.src:this.el_.currentSrc}setControls(e){this.el_.controls=!!e}addTextTrack(e,t,i){return this.featuresNativeTextTracks?this.el_.addTextTrack(e,t,i):super.addTextTrack(e,t,i)}createRemoteTextTrack(e){var t;return this.featuresNativeTextTracks?(t=document.createElement("track"),e.kind&&(t.kind=e.kind),e.label&&(t.label=e.label),(e.language||e.srclang)&&(t.srclang=e.language||e.srclang),e.default&&(t.default=e.default),e.id&&(t.id=e.id),e.src&&(t.src=e.src),t):super.createRemoteTextTrack(e)}addRemoteTextTrack(e,t){e=super.addRemoteTextTrack(e,t);return this.featuresNativeTextTracks&&this.el().appendChild(e),e}removeRemoteTextTrack(t){if(super.removeRemoteTextTrack(t),this.featuresNativeTextTracks){var i=this.$$("track");let e=i.length;for(;e--;)t!==i[e]&&t!==i[e].track||this.el().removeChild(i[e])}}getVideoPlaybackQuality(){var e;return"function"==typeof this.el().getVideoPlaybackQuality?this.el().getVideoPlaybackQuality():(e={},"undefined"!=typeof this.el().webkitDroppedFrameCount&&"undefined"!=typeof this.el().webkitDecodedFrameCount&&(e.droppedVideoFrames=this.el().webkitDroppedFrameCount,e.totalVideoFrames=this.el().webkitDecodedFrameCount),window.performance&&(e.creationTime=window.performance.now()),e)}}Q(v,"TEST_VID",function(){var e,t;if(_e())return e=document.createElement("video"),(t=document.createElement("track")).kind="captions",t.srclang="en",t.label="English",e.appendChild(t),e}),v.isSupported=function(){try{v.TEST_VID.volume=.5}catch(e){return!1}return!(!v.TEST_VID||!v.TEST_VID.canPlayType)},v.canPlayType=function(e){return v.TEST_VID.canPlayType(e)},v.canPlaySource=function(e,t){return v.canPlayType(e.type)},v.canControlVolume=function(){try{const t=v.TEST_VID.volume;
vendor: 8,668 bytes, line 3786
3786v.TEST_VID.volume=t/2+.1;var e=t!==v.TEST_VID.volume;return e&&u?(window.setTimeout(()=>{v&&v.prototype&&(v.prototype.featuresVolumeControl=t!==v.TEST_VID.volume)}),!1):e}catch(e){return!1}},v.canMuteVolume=function(){try{var e=v.TEST_VID.muted;return v.TEST_VID.muted=!e,v.TEST_VID.muted?Le(v.TEST_VID,"muted","muted"):Oe(v.TEST_VID,"muted"),e!==v.TEST_VID.muted}catch(e){return!1}},v.canControlPlaybackRate=function(){if(te&&ae&&le<58)return!1;try{var e=v.TEST_VID.playbackRate;return v.TEST_VID.playbackRate=e/2+.1,e!==v.TEST_VID.playbackRate}catch(e){return!1}},v.canOverrideAttributes=function(){try{var e=()=>{};Object.defineProperty(document.createElement("video"),"src",{get:e,set:e}),Object.defineProperty(document.createElement("audio"),"src",{get:e,set:e}),Object.defineProperty(document.createElement("video"),"innerHTML",{get:e,set:e}),Object.defineProperty(document.createElement("audio"),"innerHTML",{get:e,set:e})}catch(e){return!1}return!0},v.supportsNativeTextTracks=function(){return fe||u&&ae},v.supportsNativeVideoTracks=function(){return!(!v.TEST_VID||!v.TEST_VID.videoTracks)},v.supportsNativeAudioTracks=function(){return!(!v.TEST_VID||!v.TEST_VID.audioTracks)},v.Events=["loadstart","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","ended","durationchange","timeupdate","progress","play","pause","ratechange","resize","volumechange"],[["featuresMuteControl","canMuteVolume"],["featuresPlaybackRate","canControlPlaybackRate"],["featuresSourceset","canOverrideAttributes"],["featuresNativeTextTracks","supportsNativeTextTracks"],["featuresNativeVideoTracks","supportsNativeVideoTracks"],["featuresNativeAudioTracks","supportsNativeAudioTracks"]].forEach(function([e,t]){Q(v.prototype,e,()=>v[t](),!0)}),v.prototype.featuresVolumeControl=v.canControlVolume(),v.prototype.movingMediaElementInDOM=!u,v.prototype.featuresFullscreenResize=!0,v.prototype.featuresProgressEvents=!0,v.prototype.featuresTimeupdateEvents=!0,v.prototype.featuresVideoFrameCallback=!(!v.TEST_VID||!v.TEST_VID.requestVideoFrameCallback),v.disposeMediaElement=function(e){if(e){for(e.parentNode&&e.parentNode.removeChild(e);e.hasChildNodes();)e.removeChild(e.firstChild);if(e.removeAttribute("src"),"function"==typeof e.load)try{e.load()}catch(e){}}},v.resetMediaElement=function(t){if(t){var i=t.querySelectorAll("source");let e=i.length;for(;e--;)t.removeChild(i[e]);if(t.removeAttribute("src"),"function"==typeof t.load)try{t.load()}catch(e){}}},["muted","defaultMuted","autoplay","controls","loop","playsinline"].forEach(function(e){v.prototype[e]=function(){return this.el_[e]||this.el_.hasAttribute(e)}}),["muted","defaultMuted","autoplay","loop","playsinline"].forEach(function(t){v.prototype["set"+g(t)]=function(e){(this.el_[t]=e)?this.el_.setAttribute(t,t):this.el_.removeAttribute(t)}}),["paused","currentTime","buffered","volume","poster","preload","error","seeking","seekable","ended","playbackRate","defaultPlaybackRate","disablePictureInPicture","played","networkState","readyState","videoWidth","videoHeight","crossOrigin"].forEach(function(e){v.prototype[e]=function(){return this.el_[e]}}),["volume","src","poster","preload","playbackRate","defaultPlaybackRate","disablePictureInPicture","crossOrigin"].forEach(function(t){v.prototype["set"+g(t)]=function(e){this.el_[t]=e}}),["pause","load","play"].forEach(function(e){v.prototype[e]=function(){return this.el_[e]()}}),_.withSourceHandlers(v),v.nativeSourceHandler={},v.nativeSourceHandler.canPlayType=function(e){try{return v.TEST_VID.canPlayType(e)}catch(e){return""}},v.nativeSourceHandler.canHandleSource=function(e,t){return e.type?v.nativeSourceHandler.canPlayType(e.type):e.src?(e=ui(e.src),v.nativeSourceHandler.canPlayType("video/"+e)):""},v.nativeSourceHandler.handleSource=function(e,t,i){t.setSrc(e.src)},v.nativeSourceHandler.dispose=function(){},v.registerSourceHandler(v.nativeSourceHandler),_.registerTech("Html5",v);const Qr=["progress","abort","suspend","emptied","stalled","loadedmetadata","loadeddata","timeupdate","resize","volumechange","texttrackchange"],Jr={canplay:"CanPlay",canplaythrough:"CanPlayThrough",playing:"Playing",seeked:"Seeked"},Zr=["tiny","xsmall","small","medium","large","xlarge","huge"],en={},tn=(Zr.forEach(e=>{var t="x"===e.charAt(0)?"x-"+e.substring(1):e;en[e]="vjs-layout-"+t}),{tiny:210,xsmall:320,small:425,medium:768,large:1440,xlarge:2560,huge:1/0});class b extends f{constructor(e,t,i){if(e.id=e.id||t.id||"vjs_video_"+tt++,(t=Object.assign(b.getTagSettings(e),t)).initChildren=!1,t.createEl=!1,t.evented=!1,t.reportTouchActivity=!1,t.language||(s=e.closest("[lang]"))&&(t.language=s.getAttribute("lang")),super(null,t,i),this.boundDocumentFullscreenChange_=e=>this.documentFullscreenChange_(e),this.boundFullWindowOnEscKey_=e=>this.fullWindowOnEscKey(e),this.boundUpdateStyleEl_=e=>this.updateStyleEl_(e),this.boundApplyInitTime_=e=>this.applyInitTime_(e),this.boundUpdateCurrentBreakpoint_=e=>this.updateCurrentBreakpoint_(e),this.boundHandleTechClick_=e=>this.handleTechClick_(e),this.boundHandleTechDoubleClick_=e=>this.handleTechDoubleClick_(e),this.boundHandleTechTouchStart_=e=>this.handleTechTouchStart_(e),this.boundHandleTechTouchMove_=e=>this.handleTechTouchMove_(e),this.boundHandleTechTouchEnd_=e=>this.handleTechTouchEnd_(e),this.boundHandleTechTap_=e=>this.handleTechTap_(e),this.isFullscreen_=!1,this.log=W(this.id_),this.fsApi_=j,this.isPosterFromTech_=!1,this.queuedCallbacks_=[],this.isReady_=!1,this.hasStarted_=!1,this.userActive_=!1,this.debugEnabled_=!1,this.audioOnlyMode_=!1,this.audioPosterMode_=!1,this.audioOnlyCache_={playerHeight:null,hiddenChildren:[]},!this.options_||!this.options_.techOrder||!this.options_.techOrder.length)throw new Error("No techOrder specified. Did you overwrite videojs.options instead of just changing the properties you want to override?");if(this.tag=e,this.tagAttributes=e&&Ae(e),this.language(this.options_.language),t.languages){const r={};Object.getOwnPropertyNames(t.languages).forEach(function(e){r[e.toLowerCase()]=t.languages[e]}),this.languages_=r}else this.languages_=b.prototype.options_.languages;this.resetCache_(),this.poster_=t.poster||"",this.controls_=!!t.controls,e.controls=!1,e.removeAttribute("controls"),this.changingSrc_=!1,this.playCallbacks_=[],this.playTerminatedQueue_=[],e.hasAttribute("autoplay")?this.autoplay(!0):this.autoplay(this.options_.autoplay),t.plugins&&Object.keys(t.plugins).forEach(e=>{if("function"!=typeof this[e])throw new Error(`plugin "${e}" does not exist`)}),this.scrubbing_=!1,this.el_=this.createEl(),Ct(this,{eventBusKey:"el_"}),this.fsApi_.requestFullscreen&&(ot(document,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),this.on(this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_)),this.fluid_&&this.on(["playerreset","resize"],this.boundUpdateStyleEl_);var s=h(this.options_),i=(t.plugins&&Object.keys(t.plugins).forEach(e=>{this[e](t.plugins[e])}),t.debug&&this.debug(!0),this.options_.playerOptions=s,this.middleware_=[],this.playbackRates(t.playbackRates),this.initChildren(),this.isAudio("audio"===e.nodeName.toLowerCase()),this.controls()?this.addClass("vjs-controls-enabled"):this.addClass("vjs-controls-disabled"),this.el_.setAttribute("role","region"),this.isAudio()?this.el_.setAttribute("aria-label",this.localize("Audio Player")):this.el_.setAttribute("aria-label",this.localize("Video Player")),this.isAudio()&&this.addClass("vjs-audio"),me&&this.addClass("vjs-touch-enabled"),u||this.addClass("vjs-workinghover"),b.players[this.id_]=this,R.split(".")[0]);this.addClass("vjs-v"+i),this.userActive(!0),this.reportUserActivity(),this.one("play",e=>this.listenForUserActivity_(e)),this.on("keydown",e=>this.handleKeyDown(e)),this.on("languagechange",e=>this.handleLanguagechange(e)),this.breakpoints(this.options_.breakpoints),this.responsive(this.options_.responsive),this.on("ready",()=>{this.audioPosterMode(this.options_.audioPosterMode),this.audioOnlyMode(this.options_.audioOnlyMode)})}dispose(){var e;this.trigger("dispose"),this.off("dispose"),p(document,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),p(document,"keydown",this.boundFullWindowOnEscKey_),this.styleEl_&&this.styleEl_.parentNode&&(this.styleEl_.parentNode.removeChild(this.styleEl_),this.styleEl_=null),b.players[this.id_]=null,this.tag&&this.tag.player&&(this.tag.player=null),this.el_&&this.el_.player&&(this.el_.player=null),this.tech_&&(this.tech_.dispose(),this.isPosterFromTech_=!1,this.poster_=""),this.playerElIngest_&&(this.playerElIngest_=null),this.tag&&(this.tag=null),e=this,us[e.id()]=null,a.names.forEac
vendor: 5,031 bytes, lines 3786-3795
3786h(e=>{e=this[a[e].getterName]();e&&e.off&&e.off()}),super.dispose({restoreEl:this.options_.restoreEl})}createEl(){let t=this.tag,i,e=this.playerElIngest_=t.parentNode&&t.parentNode.hasAttribute&&t.parentNode.hasAttribute("data-vjs-player");const s="video-js"===this.tag.tagName.toLowerCase(),r=(e?i=this.el_=t.parentNode:s||(i=this.el_=super.createEl("div")),Ae(t));if(s){for(i=this.el_=t,t=this.tag=document.createElement("video");i.children.length;)t.appendChild(i.firstChild);Ee(i,"video-js")||ke(i,"video-js"),i.appendChild(t),e=this.playerElIngest_=i,Object.keys(i).forEach(e=>{try{t[e]=i[e]}catch(e){}})}t.setAttribute("tabindex","-1"),r.tabindex="-1",ae&&ue&&(t.setAttribute("role","application"),r.role="application"),t.removeAttribute("width"),t.removeAttribute("height"),"width"in r&&delete r.width,"height"in r&&delete r.height,Object.getOwnPropertyNames(r).forEach(function(e){s&&"class"===e||i.setAttribute(e,r[e]),s&&t.setAttribute(e,r[e])}),t.playerId=t.id,t.id+="_html5_api",t.className="vjs-tech",(t.player=i.player=this).addClass("vjs-paused"),!0!==window.VIDEOJS_NO_DYNAMIC_STYLE&&(this.styleEl_=Ze("vjs-styles-dimensions"),n=$e(".vjs-styles-defaults"),(a=$e("head")).insertBefore(this.styleEl_,n?n.nextSibling:a.firstChild)),this.fill_=!1,this.fluid_=!1,this.width(this.options_.width),this.height(this.options_.height),this.fill(this.options_.fill),this.fluid(this.options_.fluid),this.aspectRatio(this.options_.aspectRatio),this.crossOrigin(this.options_.crossOrigin||this.options_.crossorigin);var n,a,o=t.getElementsByTagName("a");for(let e=0;e<o.length;e++){var l=o.item(e);ke(l,"vjs-hidden"),l.setAttribute("hidden","hidden")}return t.initNetworkState_=t.networkState,t.parentNode&&!e&&t.parentNode.insertBefore(i,t),we(t,i),this.children_.unshift(t),this.el_.setAttribute("lang",this.language_),this.el_.setAttribute("translate","no"),this.el_=i}crossOrigin(e){if("undefined"==typeof e)return this.techGet_("crossOrigin");null!==e&&"anonymous"!==e&&"use-credentials"!==e?d.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`):(this.techCall_("setCrossOrigin",e),this.posterImage&&this.posterImage.crossOrigin(e))}width(e){return this.dimension("width",e)}height(e){return this.dimension("height",e)}dimension(e,t){var i,s=e+"_";if(void 0===t)return this[s]||0;""===t||"auto"===t?(this[s]=void 0,this.updateStyleEl_()):(i=parseFloat(t),isNaN(i)?d.error(`Improper value "${t}" supplied for for `+e):(this[s]=i,this.updateStyleEl_()))}fluid(e){if(void 0===e)return!!this.fluid_;var t;this.fluid_=!!e,_t(this)&&this.off(["playerreset","resize"],this.boundUpdateStyleEl_),e?(this.addClass("vjs-fluid"),this.fill(!1),e=this,t=()=>{this.on(["playerreset","resize"],this.boundUpdateStyleEl_)},_t(e)?t():(e.eventedCallbacks||(e.eventedCallbacks=[]),e.eventedCallbacks.push(t))):this.removeClass("vjs-fluid"),this.updateStyleEl_()}fill(e){if(void 0===e)return!!this.fill_;this.fill_=!!e,e?(this.addClass("vjs-fill"),this.fluid(!1)):this.removeClass("vjs-fill")}aspectRatio(e){if(void 0===e)return this.aspectRatio_;if(!/^\d+\:\d+$/.test(e))throw new Error("Improper value supplied for aspect ratio. The format should be width:height, for example 16:9.");this.aspectRatio_=e,this.fluid(!0),this.updateStyleEl_()}updateStyleEl_(){if(!0===window.VIDEOJS_NO_DYNAMIC_STYLE){const e="number"==typeof this.width_?this.width_:this.options_.width,t="number"==typeof this.height_?this.height_:this.options_.height;var r=this.tech_&&this.tech_.el();void(r&&(0<=e&&(r.width=e),0<=t)&&(r.height=t))}else{let e,t,i,s;r=(i=void 0!==this.aspectRatio_&&"auto"!==this.aspectRatio_?this.aspectRatio_:0<this.videoWidth()?this.videoWidth()+":"+this.videoHeight():"16:9").split(":"),r=r[1]/r[0];e=void 0!==this.width_?this.width_:void 0!==this.height_?this.height_/r:this.videoWidth()||300,t=void 0!==this.height_?this.height_:e*r,s=/^[^a-zA-Z]/.test(this.id())?"dimensions-"+this.id():this.id()+"-dimensions",this.addClass(s),et(this.styleEl_,` 3787 .${s} { 3788 width: ${e}px; 3789 height: ${t}px; 3790 } 3791 3792 .${s}.vjs-fluid:not(.vjs-audio-only-mode) { 3793 padding-top: ${100*r}%; 3794 } 3795 `)}}loadTech_(e,t){this.tech_&&this.unloadTech_();var i=g(e),s=e.charAt(0).toLowerCase()+e.slice(1);"Html5"!==i&&this.tag&&(_.getTech("Html5").disposeMediaElement(this.tag),this.tag.player=null,this.tag=null),this.techName_=i,this.isReady_=!1;let r=this.autoplay();const n={source:t,autoplay:r="string"==typeof this.autoplay()||!0===this.autoplay()&&this.options_.normalizeAutoplay?!1:r,nativeControlsForTouch:this.options_.nativeControlsForTouch,playerId:this.id(),techId:this.id()+`_${s}_api`,playsinline:this.options_.playsinline,preload:this.options_.preload,loop:this.options_.loop,disablePictureInPicture:this.options_.disablePictureInPicture,muted:this.options_.muted,poster:this.poster(),language:this.language(),playerElIngest:this.playerElIngest_||!1,"vtt.js":this.options_["vtt.js"],canOverridePoster:!!this.options_.techCanOverridePoster,enableSourceset:this.options_.enableSourceset};
vendor: 2,616 bytes, line 3795
3795a.names.forEach(e=>{e=a[e];n[e.getterName]=this[e.privateName]}),Object.assign(n,this.options_[i]),Object.assign(n,this.options_[s]),Object.assign(n,this.options_[e.toLowerCase()]),this.tag&&(n.tag=this.tag),t&&t.src===this.cache_.src&&0<this.cache_.currentTime&&(n.startTime=this.cache_.currentTime);s=_.getTech(e);if(!s)throw new Error(`No Tech named '${i}' exists! '${i}' should be registered using videojs.registerTech()'`);this.tech_=new s(n),this.tech_.ready(m(this,this.handleTechReady_),!0),Kt(this.textTracksJson_||[],this.tech_),Qr.forEach(t=>{this.on(this.tech_,t,e=>this[`handleTech${g(t)}_`](e))}),Object.keys(Jr).forEach(t=>{this.on(this.tech_,t,e=>{0===this.tech_.playbackRate()&&this.tech_.seeking()?this.queuedCallbacks_.push({callback:this[`handleTech${Jr[t]}_`].bind(this),event:e}):this[`handleTech${Jr[t]}_`](e)})}),this.on(this.tech_,"loadstart",e=>this.handleTechLoadStart_(e)),this.on(this.tech_,"sourceset",e=>this.handleTechSourceset_(e)),this.on(this.tech_,"waiting",e=>this.handleTechWaiting_(e)),this.on(this.tech_,"ended",e=>this.handleTechEnded_(e)),this.on(this.tech_,"seeking",e=>this.handleTechSeeking_(e)),this.on(this.tech_,"play",e=>this.handleTechPlay_(e)),this.on(this.tech_,"pause",e=>this.handleTechPause_(e)),this.on(this.tech_,"durationchange",e=>this.handleTechDurationChange_(e)),this.on(this.tech_,"fullscreenchange",(e,t)=>this.handleTechFullscreenChange_(e,t)),this.on(this.tech_,"fullscreenerror",(e,t)=>this.handleTechFullscreenError_(e,t)),this.on(this.tech_,"enterpictureinpicture",e=>this.handleTechEnterPictureInPicture_(e)),this.on(this.tech_,"leavepictureinpicture",e=>this.handleTechLeavePictureInPicture_(e)),this.on(this.tech_,"error",e=>this.handleTechError_(e)),this.on(this.tech_,"posterchange",e=>this.handleTechPosterChange_(e)),this.on(this.tech_,"textdata",e=>this.handleTechTextData_(e)),this.on(this.tech_,"ratechange",e=>this.handleTechRateChange_(e)),this.on(this.tech_,"loadedmetadata",this.boundUpdateStyleEl_),this.usingNativeControls(this.techGet_("controls")),this.controls()&&!this.usingNativeControls()&&this.addTechControlsListeners_(),this.tech_.el().parentNode===this.el()||"Html5"===i&&this.tag||we(this.tech_.el(),this.el()),this.tag&&(this.tag.player=null,this.tag=null)}unloadTech_(){a.names.forEach(e=>{e=a[e];this[e.privateName]=this[e.getterName]()}),this.textTracksJson_=Xt(this.tech_),this.isReady_=!1,this.tech_.dispose(),this.tech_=!1,this.isPosterFromTech_&&(this.poster_="",this.trigger("posterchange")),this.isPosterFromTech_=!1}tech(e){return void 0===e&&d.warn("Using the tech directly can be dangerous. I hope you know
3795what you're doing.\nSee https://github.com/videojs/video.js/issues/2617 for more info.\n"),this.tech_}addTechControlsListeners_(){this.removeTechControlsListeners_(),this.on(this.tech_,"click",this.boundHandleTechClick_),this.on(this.tech_,"dblclick",this.boundHandleTechDoubleClick_),this.on(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.on(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.on(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.on(this.tech_,"tap",this.boundHandleTechTap_)}removeTechControlsListeners_(){this.off(this.tech_,"tap",this.boundHandleTechTap_),this.off(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.off(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.off(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.off(this.tech_,"click",this.boundHandleTechClick_),this.off(this.tech_,"dblclick",this.boundHandleTechDoubleClick_)}handleTechReady_(){this.triggerReady(),this.cache_.volume&&this.techCall_("setVolume",this.cache_.volume),this.handleTechPosterChange_(),this.handleTechDurationChange_()}handleTechLoadStart_(){this.removeClass("vjs-ended","vjs-seeking"),this.error(null),this.handleTechDurationChange_(),this.paused()&&this.hasStarted(!1),this.trigger("loadstart"),this.manualAutoplay_(!0===this.autoplay()&&this.options_.normalizeAutoplay?"play":this.autoplay())}manualAutoplay_(t){if(this.tech_&&"string"==typeof t){var i=()=>{const e=this.muted(),t=(this.muted(!0),()=>{this.muted(e)});this.playTerminatedQueue_.push(t);var i=this.play();if(Wt(i))return i.catch(e=>{throw t(),new Error("Rejection at manualAutoplay. Restoring muted value. "+(e||""))})};let e;if("any"!==t||this.muted()?e="muted"!==t||this.muted()?this.play():i():Wt(e=this.play())&&(e=e.catch(i)),Wt(e))return e.then(()=>{this.trigger({type:"autoplay-success",autoplay:t})}).catch(()=>{this.trigger({type:"autoplay-failure",autoplay:t})})}}updateSourceCaches_(e=""){let t=e,i="";"string"!=typeof t&&(t=e.src,i=e.type),this.cache_.source=this.cache_.source||{},this.cache_.sources=this.cache_.sources||[],t&&!i&&(i=((e,t)=>{if(!t)return"";if(e.cache_.source.src===t&&e.cache_.source.type)return e.cache_.source.type;var i=e.cache_.sources.filter(e=>e.src===t);if(i.length)return i[0].type;var s=e.$$("source");for(let e=0;e<s.length;e++){var r=s[e];if(r.type&&r.src&&r.src===t)return r.type}return Ss(t)})(this,t)),this.cache_.source=h({},e,{src:t,type:i});var e=this.cache_.sources.filter(e=>e.src&&e.src===t),s=[],r=this.$$("source"),n=[];for(let e=0;e<r.length;e++){var a=Ae(r[e]);s.push(a),a.src&&a.src===t&&n.push(a.src)}n.length&&!e.length?this.cache_.sources=s:e.length||(this.cache_.sources=[this.cache_.source]),this.cache_.src=t}handleTechSourceset_(t){if(!this.changingSrc_){let e=e=>this.updateSourceCaches_(e);var i=this.currentSource().src,s=t.src;(e=!i||/^blob:/.test(i)||!/^blob:/.test(s)||this.lastSource_&&(this.lastSource_.tech===s||this.lastSource_.player===i)?e:()=>{})(s),t.src||this.tech_.any(["sourceset","loadstart"],e=>{"sourceset"!==e.type&&(e=this.techGet("currentSrc"),this.lastSource_.tech=e,this.updateSourceCaches_(e))})}this.lastSource_={player:this.currentSource().src,tech:t.src},this.trigger({src:t.src,type:"sourceset"})}hasStarted(e){if(void 0===e)return this.hasStarted_;e!==this.hasStarted_&&(this.hasStarted_=e,this.hasStarted_?this.addClass("vjs-has-started"):this.removeClass("vjs-has-started"))}handleTechPlay_(){this.removeClass("vjs-ended","vjs-paused"),this.addClass("vjs-playing"),this.hasStarted(!0),this.trigger("play")}handleTechRateChange_(){0<this.tech_.playbackRate()&&0===this.cache_.lastPlaybackRate&&(this.queuedCallbacks_.forEach(e=>e.callback(e.event)),this.queuedCallbacks_=[]),this.cache_.lastPlaybackRate=this.tech_.playbackRate(),this.trigger("ratechange")}handleTechWaiting_(){this.addClass("vjs-waiting"),this.trigger("waiting");const e=this.currentTime(),t=()=>{e!==this.currentTime()&&(this.removeClass("vjs-waiting"),this.off("timeupdate",t))};this.on("timeupdate",t)}handleTechCanPlay_(){this.removeClass("vjs-waiting"),this.trigger("canplay")}handleTechCanPlayThrough_(){this.removeClass("vjs-waiting"),this.trigger("canplaythrough")}handleTechPlaying_(){this.removeClass("vjs-waiting"),this.trigger("playing")}handleTechSeeking_(){this.addClass("vjs-seeking"),this.trigger("seeking")}
vendor: 11,492 bytes, line 3795
3795handleTechSeeked_(){this.removeClass("vjs-seeking","vjs-ended"),this.trigger("seeked")}handleTechPause_(){this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.trigger("pause")}handleTechEnded_(){this.addClass("vjs-ended"),this.removeClass("vjs-waiting"),this.options_.loop?(this.currentTime(0),this.play()):this.paused()||this.pause(),this.trigger("ended")}handleTechDurationChange_(){this.duration(this.techGet_("duration"))}handleTechClick_(e){!this.controls_||void 0!==this.options_&&void 0!==this.options_.userActions&&void 0!==this.options_.userActions.click&&!1===this.options_.userActions.click||(void 0!==this.options_&&void 0!==this.options_.userActions&&"function"==typeof this.options_.userActions.click?this.options_.userActions.click.call(this,e):this.paused()?Gt(this.play()):this.pause())}handleTechDoubleClick_(t){!this.controls_||Array.prototype.some.call(this.$$(".vjs-control-bar, .vjs-modal-dialog"),e=>e.contains(t.target))||void 0!==this.options_&&void 0!==this.options_.userActions&&void 0!==this.options_.userActions.doubleClick&&!1===this.options_.userActions.doubleClick||(void 0!==this.options_&&void 0!==this.options_.userActions&&"function"==typeof this.options_.userActions.doubleClick?this.options_.userActions.doubleClick.call(this,t):this.isFullscreen()?this.exitFullscreen():this.requestFullscreen())}handleTechTap_(){this.userActive(!this.userActive())}handleTechTouchStart_(){this.userWasActive=this.userActive()}handleTechTouchMove_(){this.userWasActive&&this.reportUserActivity()}handleTechTouchEnd_(e){e.cancelable&&e.preventDefault()}toggleFullscreenClass_(){this.isFullscreen()?this.addClass("vjs-fullscreen"):this.removeClass("vjs-fullscreen")}documentFullscreenChange_(t){t=t.target.player;if(!t||t===this){t=this.el();let e=document[this.fsApi_.fullscreenElement]===t;!e&&t.matches?e=t.matches(":"+this.fsApi_.fullscreen):!e&&t.msMatchesSelector&&(e=t.msMatchesSelector(":"+this.fsApi_.fullscreen)),this.isFullscreen(e)}}handleTechFullscreenChange_(e,t){t&&(t.nativeIOSFullscreen&&(this.addClass("vjs-ios-native-fs"),this.tech_.one("webkitendfullscreen",()=>{this.removeClass("vjs-ios-native-fs")})),this.isFullscreen(t.isFullscreen))}handleTechFullscreenError_(e,t){this.trigger("fullscreenerror",t)}togglePictureInPictureClass_(){this.isInPictureInPicture()?this.addClass("vjs-picture-in-picture"):this.removeClass("vjs-picture-in-picture")}handleTechEnterPictureInPicture_(e){this.isInPictureInPicture(!0)}handleTechLeavePictureInPicture_(e){this.isInPictureInPicture(!1)}handleTechError_(){var e=this.tech_.error();this.error(e)}handleTechTextData_(){let e=1<arguments.length?arguments[1]:null;this.trigger("textdata",e)}getCache(){return this.cache_}resetCache_(){this.cache_={currentTime:0,initTime:0,inactivityTimeout:this.options_.inactivityTimeout,duration:NaN,lastVolume:1,lastPlaybackRate:this.defaultPlaybackRate(),media:null,src:"",source:{},sources:[],playbackRates:[],volume:1}}techCall_(t,i){this.ready(function(){if(t in fs)return e=this.middleware_,this.tech_[t](e.reduce(_s(t),i));if(t in ys)return ms(this.middleware_,this.tech_,t,i);var e;try{this.tech_&&this.tech_[t](i)}catch(e){throw d(e),e}},!0)}techGet_(t){if(this.tech_&&this.tech_.isReady_){if(t in gs)return e=this.middleware_,i=this.tech_,e.reduceRight(_s(t),i[t]());if(t in ys)return ms(this.middleware_,this.tech_,t);var e,i;try{return this.tech_[t]()}catch(e){throw void 0===this.tech_[t]?d(`Video.js: ${t} method not defined for ${this.techName_} playback technology.`,e):"TypeError"===e.name?(d(`Video.js: ${t} unavailable on ${this.techName_} playback technology element.`,e),this.tech_.isReady_=!1):d(e),e}}}play(){return new Promise(e=>{this.play_(e)})}play_(e=Gt){this.playCallbacks_.push(e);var t,e=Boolean(!this.changingSrc_&&(this.src()||this.currentSrc())),i=Boolean(fe||u);this.waitToPlay_&&(this.off(["ready","loadstart"],this.waitToPlay_),this.waitToPlay_=null),this.isReady_&&e?(t=this.techGet_("play"),i&&this.hasClass("vjs-ended")&&this.resetProgressBar_(),null===t?this.runPlayTerminatedQueue_():this.runPlayCallbacks_(t)):(this.waitToPlay_=e=>{this.play_()},this.one(["ready","loadstart"],this.waitToPlay_),!e&&i&&this.load())}runPlayTerminatedQueue_(){var e=this.playTerminatedQueue_.slice(0);this.playTerminatedQueue_=[],e.forEach(function(e){e()})}runPlayCallbacks_(t){var e=this.playCallbacks_.slice(0);this.playCallbacks_=[],this.playTerminatedQueue_=[],e.forEach(function(e){e(t)})}pause(){this.techCall_("pause")}paused(){return!1!==this.techGet_("paused")}played(){return this.techGet_("played")||Rt(0,0)}scrubbing(e){if("undefined"==typeof e)return this.scrubbing_;this.scrubbing_=!!e,this.techCall_("setScrubbing",this.scrubbing_),e?this.addClass("vjs-scrubbing"):this.removeClass("vjs-scrubbing")}currentTime(e){return"undefined"!=typeof e?(e<0&&(e=0),this.isReady_&&!this.changingSrc_&&this.tech_&&this.tech_.isReady_?(this.techCall_("setCurrentTime",e),void(this.cache_.initTime=0)):(this.cache_.initTime=e,this.off("canplay",this.boundApplyInitTime_),void this.one("canplay",this.boundApplyInitTime_))):(this.cache_.currentTime=this.techGet_("currentTime")||0,this.cache_.currentTime)}applyInitTime_(){this.currentTime(this.cache_.initTime)}duration(e){if(void 0===e)return void 0!==this.cache_.duration?this.cache_.duration:NaN;(e=(e=parseFloat(e))<0?1/0:e)!==this.cache_.duration&&((this.cache_.duration=e)===1/0?this.addClass("vjs-live"):this.removeClass("vjs-live"),isNaN(e)||this.trigger("durationchange"))}remainingTime(){return this.duration()-this.currentTime()}remainingTimeDisplay(){return Math.floor(this.duration())-Math.floor(this.currentTime())}buffered(){let e=this.techGet_("buffered");return e=e&&e.length?e:Rt(0,0)}bufferedPercent(){return Vt(this.buffered(),this.duration())}bufferedEnd(){var e=this.buffered(),t=this.duration();let i=e.end(e.length-1);return i=i>t?t:i}volume(e){let t;if(void 0===e)return t=parseFloat(this.techGet_("volume")),isNaN(t)?1:t;t=Math.max(0,Math.min(1,parseFloat(e))),this.cache_.volume=t,this.techCall_("setVolume",t),0<t&&this.lastVolume_(t)}muted(e){if(void 0===e)return this.techGet_("muted")||!1;this.techCall_("setMuted",e)}defaultMuted(e){return void 0!==e?this.techCall_("setDefaultMuted",e):this.techGet_("defaultMuted")||!1}lastVolume_(e){if(void 0===e||0===e)return this.cache_.lastVolume;this.cache_.lastVolume=e}supportsFullScreen(){return this.techGet_("supportsFullScreen")||!1}isFullscreen(e){var t;if(void 0===e)return this.isFullscreen_;t=this.isFullscreen_,this.isFullscreen_=Boolean(e),this.isFullscreen_!==t&&this.fsApi_.prefixed&&this.trigger("fullscreenchange"),this.toggleFullscreenClass_()}requestFullscreen(a){this.isInPictureInPicture()&&this.exitPictureInPicture();const o=this;return new Promise((e,i)=>{function s(){o.off("fullscreenerror",r),o.off("fullscreenchange",t)}function t(){s(),e()}function r(e,t){s(),i(t)}o.one("fullscreenchange",t),o.one("fullscreenerror",r);var n=o.requestFullscreenHelper_(a);n&&(n.then(s,s),n.then(e,i))})}requestFullscreenHelper_(e){let t;if(this.fsApi_.prefixed||(t=this.options_.fullscreen&&this.options_.fullscreen.options||{},void 0!==e&&(t=e)),this.fsApi_.requestFullscreen)return(e=this.el_[this.fsApi_.requestFullscreen](t))&&e.then(()=>this.isFullscreen(!0),()=>this.isFullscreen(!1)),e;this.tech_.supportsFullScreen()&&!0==!this.options_.preferFullWindow?this.techCall_("enterFullScreen"):this.enterFullWindow()}exitFullscreen(){const a=this;return new Promise((e,i)=>{function s(){a.off("fullscreenerror",r),a.off("fullscreenchange",t)}function t(){s(),e()}function r(e,t){s(),i(t)}a.one("fullscreenchange",t),a.one("fullscreenerror",r);var n=a.exitFullscreenHelper_();n&&(n.then(s,s),n.then(e,i))})}exitFullscreenHelper_(){var e;if(this.fsApi_.requestFullscreen)return(e=document[this.fsApi_.exitFullscreen]())&&Gt(e.then(()=>this.isFullscreen(!1))),e;this.tech_.supportsFullScreen()&&!0==!this.options_.preferFullWindow?this.techCall_("exitFullScreen"):this.exitFullWindow()}enterFullWindow(){this.isFullscreen(!0),this.isFullWindow=!0,this.docOrigOverflow=document.documentElement.style.overflow,ot(document,"keydown",this.boundFullWindowOnEscKey_),document.documentElement.style.overflow="hidden",ke(document.body,"vjs-full-window"),this.trigger("enterFullWindow")}fullWindowOnEscKey(e){r.isEventKey(e,"Esc")&&!0===this.isFullscreen()&&(this.isFullWindow?this.exitFullWindow():this.exitFullscreen())}exitFullWindow(){this.isFullscreen(!1),this.isFullWindow=!1,p(document,"keydown",this.boundFullWindowOnEscKey_),document.documentElement.style.overflow=this.docOrigOverflow,Ce(document.body,"vjs-full-window"),this.trigger("exitFullWindow")}disablePictureInPicture(e){if(void 0===e)return this.techGet_("disablePictureInPicture");this.techCall_("setDisablePictureInPicture",e),this.options_.disablePictureInPicture=e,this.trigger("disablepictureinpicturechanged")}isInPictureInPicture(e){if(void 0===e)return!!this.isInPictureInPicture_;this.isInPictureInPicture_=!!e,this.togglePictureInPictureClass_()}requestPictureInPicture(){if(this.options_.enableDocumentPictureInPicture&&window.documentPictureInPicture){const t=document.createElement(this.el().tagName);return t.classList=this.el().classList,t.classList.add("vjs-pip-container"),this.posterImage&&t.appendChild(this.posterImage.el().cloneNode(!0)),this.titleBar&&t.appendChild(this.titleBar.el().cloneNode(!0)),t.appendChild(o("p",{className:"vjs-pip-text"},{},this.localize("Playing in picture-in-picture"))),window.documentPictureInPicture.requestWindow({initialAspectRatio:this.videoWidth()/this.videoHeight(),copyStyleSheets:!0}).then(e=>(this.el_.parentNode.insertBefore(t,this.el_),e.document.body.append(this.el_),e.document.body.classList.add("vjs-pip-window"),this.player_.isInPictureInPicture(!0),this.player_.trigger("enterpictureinpicture"),e.addEventListener("unload",e=>{e=e.target.querySelector(".video-js");t.replaceWith(e),this.player_.isInPictureInPicture(!1),this.player_.trigger("leavepictureinpicture")}),e))}return"pictureInPictureEnabled"in document&&!1===this.disablePictureInPicture()?this.techGet_("requestPictureInPicture"):Promise.reject("No PiP mode is available")}exitPictureInPicture(){return window.documentPictureInPicture&&window.documentPictureInPicture.window?(window.documentPictureInPicture.window.close(),Promise.resolve()):"pictureInPictureEnabled"in document?document.exitPictureInPicture():void 0}handleKeyDown(e){var t,i,s=this.options_["userActions"];s&&s.hotkeys&&(t=this.el_.ownerDocument.activeElement,i=t.tagName.toLowerCase(),t.isContentEditable||("input"===i?-1===["button","checkbox","hidden","radio","reset","submit"].indexOf(t.type):-1!==["textarea"].indexOf(i))||("function"==typeof s.hotkeys?s.hotkeys.call(this,e):this.handleHotkeys(e)))}handleHotkeys(e){var{fullscreenKey:t=e=>r.isEventKey(e,"f"),muteKey:i=e=>r.isEventKey(e,"m"),playPauseKey:s=e=>r.isEventKey(e,"k")||r.isEventKey(e,"Space")}=this.options_.userActions?this.options_.userActions.hotkeys:{};t.call(this,e)?(e.preventDefault(),e.stopPropagation(),t=f.getComponent("FullscreenToggle"),!1!==document[this.fsApi_.fullscreenEnabled]&&t.prototype.handleClick.call(this,e)):i.call(this,e)?(e.preventDefault(),e.stopPropagation(),f.getComponent("MuteToggle").prototype.handleClick.call(this,e)):s.call(this,e)&&(e.preventDefault(),e.stopPropagation(),f.getComponent("PlayToggle").prototype.handleClick.call(this,e))}canPlayType(s){var r;for(let t=0,i=this.options_.techOrder;t<i.length;t++){var n=i[t];let e=_.getTech(n);
vendor: 14,142 bytes, line 3795
3795if(e=e||f.getComponent(n)){if(e.isSupported()&&(r=e.canPlayType(s)))return r}else d.error(`The "${n}" tech is undefined. Skipped browser support check for that tech.`)}return""}selectSource(e){function t(e,i,s){let r;return e.some(t=>i.some(e=>{if(r=s(t,e))return!0})),r}var i=this.options_.techOrder.map(e=>[e,_.getTech(e)]).filter(([e,t])=>t?t.isSupported():(d.error(`The "${e}" tech is undefined. Skipped browser support check for that tech.`),!1));let s;var r,n=([e,t],i)=>{if(t.canPlaySource(i,this.options_[e.toLowerCase()]))return{source:i,tech:e}};return(s=this.options_.sourceOrder?t(e,i,(r=n,(e,t)=>r(t,e))):t(i,e,n))||!1}handleSrc_(e,s){if("undefined"==typeof e)return this.cache_.src||"";this.resetRetryOnError_&&this.resetRetryOnError_();const r=bs(e);if(r.length){if(this.changingSrc_=!0,s||(this.cache_.sources=r),this.updateSourceCaches_(r[0]),ps(this,r[0],(e,t)=>{var i;if(this.middleware_=t,s||(this.cache_.sources=r),this.updateSourceCaches_(e),this.src_(e))return 1<r.length?this.handleSrc_(r.slice(1)):(this.changingSrc_=!1,this.setTimeout(function(){this.error({code:4,message:this.options_.notSupportedMessage})},0),void this.triggerReady());i=this.tech_,t.forEach(e=>e.setTech&&e.setTech(i))}),1<r.length){const t=()=>{this.error(null),this.handleSrc_(r.slice(1),!0)},i=()=>{this.off("error",t)};this.one("error",t),this.one("playing",i),this.resetRetryOnError_=()=>{this.off("error",t),this.off("playing",i)}}}else this.setTimeout(function(){this.error({code:4,message:this.options_.notSupportedMessage})},0)}src(e){return this.handleSrc_(e,!1)}src_(e){var t=this.selectSource([e]);return!t||(Pt(t.tech,this.techName_)?this.ready(function(){this.tech_.constructor.prototype.hasOwnProperty("setSource")?this.techCall_("setSource",e):this.techCall_("src",e.src),this.changingSrc_=!1},!0):(this.changingSrc_=!0,this.loadTech_(t.tech,t.source),this.tech_.ready(()=>{this.changingSrc_=!1})),!1)}load(){this.techCall_("load")}reset(){this.paused()?this.doReset_():Gt(this.play().then(()=>this.doReset_()))}doReset_(){this.tech_&&this.tech_.clearTracks("text"),this.resetCache_(),this.poster(""),this.loadTech_(this.options_.techOrder[0],null),this.techCall_("reset"),this.resetControlBarUI_(),_t(this)&&this.trigger("playerreset")}resetControlBarUI_(){this.resetProgressBar_(),this.resetPlaybackRate_(),this.resetVolumeBar_()}resetProgressBar_(){this.currentTime(0);var{currentTimeDisplay:e,durationDisplay:t,progressControl:i,remainingTimeDisplay:s}=this.controlBar||{},i=(i||{})["seekBar"];e&&e.updateContent(),t&&t.updateContent(),s&&s.updateContent(),i&&(i.update(),i.loadProgressBar)&&i.loadProgressBar.update()}resetPlaybackRate_(){this.playbackRate(this.defaultPlaybackRate()),this.handleTechRateChange_()}resetVolumeBar_(){this.volume(1),this.trigger("volumechange")}currentSources(){var e=this.currentSource(),t=[];return 0!==Object.keys(e).length&&t.push(e),this.cache_.sources||t}currentSource(){return this.cache_.source||{}}currentSrc(){return this.currentSource()&&this.currentSource().src||""}currentType(){return this.currentSource()&&this.currentSource().type||""}preload(e){if(void 0===e)return this.techGet_("preload");this.techCall_("setPreload",e),this.options_.preload=e}autoplay(e){if(void 0===e)return this.options_.autoplay||!1;let t;"string"==typeof e&&/(any|play|muted)/.test(e)||!0===e&&this.options_.normalizeAutoplay?(this.options_.autoplay=e,this.manualAutoplay_("string"==typeof e?e:"play"),t=!1):this.options_.autoplay=!!e,t="undefined"==typeof t?this.options_.autoplay:t,this.tech_&&this.techCall_("setAutoplay",t)}playsinline(e){return void 0!==e?(this.techCall_("setPlaysinline",e),this.options_.playsinline=e,this):this.techGet_("playsinline")}loop(e){if(void 0===e)return this.techGet_("loop");this.techCall_("setLoop",e),this.options_.loop=e}poster(e){if(void 0===e)return this.poster_;(e=e||"")!==this.poster_&&(this.poster_=e,this.techCall_("setPoster",e),this.isPosterFromTech_=!1,this.trigger("posterchange"))}handleTechPosterChange_(){var e;(!this.poster_||this.options_.techCanOverridePoster)&&this.tech_&&this.tech_.poster&&(e=this.tech_.poster()||"")!==this.poster_&&(this.poster_=e,this.isPosterFromTech_=!0,this.trigger("posterchange"))}controls(e){if(void 0===e)return!!this.controls_;this.controls_!==(e=!!e)&&(this.controls_=e,this.usingNativeControls()&&this.techCall_("setControls",e),this.controls_?(this.removeClass("vjs-controls-disabled"),this.addClass("vjs-controls-enabled"),this.trigger("controlsenabled"),this.usingNativeControls()||this.addTechControlsListeners_()):(this.removeClass("vjs-controls-enabled"),this.addClass("vjs-controls-disabled"),this.trigger("controlsdisabled"),this.usingNativeControls()||this.removeTechControlsListeners_()))}usingNativeControls(e){if(void 0===e)return!!this.usingNativeControls_;this.usingNativeControls_!==(e=!!e)&&(this.usingNativeControls_=e,this.usingNativeControls_?(this.addClass("vjs-using-native-controls"),this.trigger("usingnativecontrols")):(this.removeClass("vjs-using-native-controls"),this.trigger("usingcustomcontrols")))}error(t){if(void 0===t)return this.error_||null;if(B("beforeerror").forEach(e=>{e=e(this,t);K(e)&&!Array.isArray(e)||"string"==typeof e||"number"==typeof e||null===e?t=e:this.log.error("please return a value that MediaError expects in beforeerror hooks")}),this.options_.suppressNotSupportedError&&t&&4===t.code){const e=function(){this.error(t)};this.options_.suppressNotSupportedError=!1,this.any(["click","touchstart"],e),void this.one("loadstart",function(){this.off(["click","touchstart"],e)})}else null===t?(this.error_=t,this.removeClass("vjs-error"),this.errorDisplay&&this.errorDisplay.close()):(this.error_=new i(t),this.addClass("vjs-error"),d.error(`(CODE:${this.error_.code} ${i.errorTypes[this.error_.code]})`,this.error_.message,this.error_),this.trigger("error"),B("error").forEach(e=>e(this,this.error_)))}reportUserActivity(e){this.userActivity_=!0}userActive(e){if(void 0===e)return this.userActive_;(e=!!e)!==this.userActive_&&(this.userActive_=e,this.userActive_?(this.userActivity_=!0,this.removeClass("vjs-user-inactive"),this.addClass("vjs-user-active"),this.trigger("useractive")):(this.tech_&&this.tech_.one("mousemove",function(e){e.stopPropagation(),e.preventDefault()}),this.userActivity_=!1,this.removeClass("vjs-user-active"),this.addClass("vjs-user-inactive"),this.trigger("userinactive")))}listenForUserActivity_(){let t,i,s;const r=m(this,this.reportUserActivity);function e(e){r(),this.clearInterval(t)}this.on("mousedown",function(){r(),this.clearInterval(t),t=this.setInterval(r,250)}),this.on("mousemove",function(e){e.screenX===i&&e.screenY===s||(i=e.screenX,s=e.screenY,r())}),this.on("mouseup",e),this.on("mouseleave",e);var n=this.getChild("controlBar");!n||u||te||(n.on("mouseenter",function(e){0!==this.player().options_.inactivityTimeout&&(this.player().cache_.inactivityTimeout=this.player().options_.inactivityTimeout),this.player().options_.inactivityTimeout=0}),n.on("mouseleave",function(e){this.player().options_.inactivityTimeout=this.player().cache_.inactivityTimeout})),this.on("keydown",r),this.on("keyup",r);let a;this.setInterval(function(){var e;this.userActivity_&&(this.userActivity_=!1,this.userActive(!0),this.clearTimeout(a),(e=this.options_.inactivityTimeout)<=0||(a=this.setTimeout(function(){this.userActivity_||this.userActive(!1)},e)))},250)}playbackRate(e){if(void 0===e)return this.tech_&&this.tech_.featuresPlaybackRate?this.cache_.lastPlaybackRate||this.techGet_("playbackRate"):1;this.techCall_("setPlaybackRate",e)}defaultPlaybackRate(e){return void 0!==e?this.techCall_("setDefaultPlaybackRate",e):this.tech_&&this.tech_.featuresPlaybackRate?this.techGet_("defaultPlaybackRate"):1}isAudio(e){if(void 0===e)return!!this.isAudio_;this.isAudio_=!!e}enableAudioOnlyUI_(){this.addClass("vjs-audio-only-mode");var e=this.children();const t=this.getChild("ControlBar");var i=t&&t.currentHeight();e.forEach(e=>{e!==t&&e.el_&&!e.hasClass("vjs-hidden")&&(e.hide(),this.audioOnlyCache_.hiddenChildren.push(e))}),this.audioOnlyCache_.playerHeight=this.currentHeight(),this.height(i),this.trigger("audioonlymodechange")}disableAudioOnlyUI_(){this.removeClass("vjs-audio-only-mode"),this.audioOnlyCache_.hiddenChildren.forEach(e=>e.show()),this.height(this.audioOnlyCache_.playerHeight),this.trigger("audioonlymodechange")}audioOnlyMode(e){return"boolean"!=typeof e||e===this.audioOnlyMode_?this.audioOnlyMode_:(this.audioOnlyMode_=e)?(e=[],this.isInPictureInPicture()&&e.push(this.exitPictureInPicture()),this.isFullscreen()&&e.push(this.exitFullscreen()),this.audioPosterMode()&&e.push(this.audioPosterMode(!1)),Promise.all(e).then(()=>this.enableAudioOnlyUI_())):Promise.resolve().then(()=>this.disableAudioOnlyUI_())}enablePosterModeUI_(){(this.tech_&&this.tech_).hide(),this.addClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}disablePosterModeUI_(){(this.tech_&&this.tech_).show(),this.removeClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}audioPosterMode(e){return"boolean"!=typeof e||e===this.audioPosterMode_?this.audioPosterMode_:(this.audioPosterMode_=e)?(this.audioOnlyMode()?this.audioOnlyMode(!1):Promise.resolve()).then(()=>{this.enablePosterModeUI_()}):Promise.resolve().then(()=>{this.disablePosterModeUI_()})}addTextTrack(e,t,i){if(this.tech_)return this.tech_.addTextTrack(e,t,i)}addRemoteTextTrack(e,t){if(this.tech_)return this.tech_.addRemoteTextTrack(e,t)}removeRemoteTextTrack(e={}){let t=e["track"];if(t=t||e,this.tech_)return this.tech_.removeRemoteTextTrack(t)}getVideoPlaybackQuality(){return this.techGet_("getVideoPlaybackQuality")}videoWidth(){return this.tech_&&this.tech_.videoWidth&&this.tech_.videoWidth()||0}videoHeight(){return this.tech_&&this.tech_.videoHeight&&this.tech_.videoHeight()||0}language(e){if(void 0===e)return this.language_;this.language_!==String(e).toLowerCase()&&(this.language_=String(e).toLowerCase(),_t(this))&&this.trigger("languagechange")}languages(){return h(b.prototype.options_.languages,this.languages_)}toJSON(){var t=h(this.options_),i=t.tracks;t.tracks=[];for(let e=0;e<i.length;e++){var s=i[e];(s=h(s)).player=void 0,t.tracks[e]=s}return t}createModal(e,t){(t=t||{}).content=e||"";const i=new Qt(this,t);return this.addChild(i),i.on("dispose",()=>{this.removeChild(i)}),i.open(),i}updateCurrentBreakpoint_(){if(this.responsive()){var t=this.currentBreakpoint(),i=this.currentWidth();for(let e=0;e<Zr.length;e++){var s=Zr[e];if(i<=this.breakpoints_[s]){if(t===s)return;t&&this.removeClass(en[t]),this.addClass(en[s]),this.breakpoint_=s;break}}}}removeCurrentBreakpoint_(){var e=this.currentBreakpointClass();this.breakpoint_="",e&&this.removeClass(e)}breakpoints(e){return void 0!==e&&(this.breakpoint_="",this.breakpoints_=Object.assign({},tn,e),this.updateCurrentBreakpoint_()),Object.assign(this.breakpoints_)}responsive(e){return void 0===e?this.responsive_:(e=Boolean(e))!==this.responsive_?((this.responsive_=e)?(this.on("playerresize",this.boundUpdateCurrentBreakpoint_),this.updateCurrentBreakpoint_()):(this.off("playerresize",this.boundUpdateCurrentBreakpoint_),this.removeCurrentBreakpoint_()),e):void 0}currentBreakpoint(){return this.breakpoint_}currentBreakpointClass(){return en[this.breakpoint_]||""}loadMedia(e,t){var i,s,r,n,a,o;e&&"object"==typeof e&&(this.reset(),this.cache_.media=h(e),{artist:e,artwork:i,description:s,poster:r,src:n,textTracks:a,title:o}=this.cache_.media,!i&&r&&(this.cache_.media.artwork=[{src:r,type:Ss(r)}]),n&&this.src(n),r&&this.poster(r),Array.isArray(a)&&a.forEach(e=>this.addRemoteTextTrack(e,!1)),this.titleBar&&this.titleBar.update({title:o,description:s||e||""}),this.ready(t))}getMedia(){var e,t;return this.cache_.media?h(this.cache_.media):(e=this.poster(),t={src:this.currentSources(),textTracks:Array.prototype.map.call(this.remoteTextTracks(),e=>({kind:e.kind,label:e.label,language:e.language,src:e.src}))},e&&(t.poster=e,t.artwork=[{src:t.poster,type:Ss(t.poster)}]),t)}static getTagSettings(e){var t,i={sources:[],tracks:[]},s=Ae(e),r=s["data-setup"];if(Ee(e,"vjs-fill")&&(s.fill=!0),Ee(e,"vjs-fluid")&&(s.fluid=!0),null!==r&&([r,t]=$t(r||"{}"),r&&d.error(r),Object.assign(s,t)),Object.assign(i,s),e.hasChildNodes()){var n=e.childNodes;for(let e=0,t=n.length;e<t;e++){var a=n[e],o=a.nodeName.toLowerCase();"source"===o?i.sources.push(Ae(a)):"track"===o&&i.tracks.push(Ae(a))}}return i}debug(e){if(void 0===e)return this.debugEnabled_;e?(this.trigger("debugon"),this.previousLogLevel_=this.log.level,this.log.level("debug"),this.debugEnabled_=!0):(this.trigger("debugoff"),this.log.level(this.previousLogLevel_),this.previousLogLevel_=void 0,this.debugEnabled_=!1)}playbackRates(e){if(void 0===e)return this.cache_.playbackRates;Array.isArray(e)&&e.every(e=>"number"==typeof e)&&(this.cache_.playbackRates=e,this.trigger("playbackrateschange"))}}a.names.forEach(function(e){const t=a[e];b.prototype[t.getterName]=function(){return this.tech_?this.tech_[t.getterName]():(this[t.privateName]=this[t.privateName]||new t.ListClass,this[t.privateName])}}),b.prototype.crossorigin=b.prototype.crossOrigin,b.players={};Dr=window.navigator;b.prototype.options_={techOrder:_.defaultTechOrder_,html5:{},enableSourceset:!0,inactivityTimeout:2e3,playbackRates:[],liveui:!1,children:["mediaLoader","posterImage","titleBar","textTrackDisplay","loadingSpinner","bigPlayButton","liveTracker","controlBar","errorDisplay","textTrackSettings","resizeManager"],language:Dr&&(Dr.languages&&Dr.languages[0]||Dr.userLanguage||Dr.language)||"en",languages:{},notSupportedMessage:"No compatible source was found for this media.",normalizeAutoplay:!1,fullscreen:{options:{navigationUI:"hide"}},breakpoints:{},responsive:!1,audioOnlyMode:!1,audioPosterMode:!1},["ended","seeking","seekable","networkState","readyState"].forEach(function(e){b.prototype[e]=function(){return this.techGet_(e)}}),Qr.forEach(function(e){b.prototype[`handleTech${g(e)}_`]=function(){return this.trigger(e)}}),f.registerComponent("Player",b);function sn(t,i){function s(){hn(this,{name:t,plugin:i,instance:null},!0);var e=i.apply(this,arguments);return dn(this,t),hn(this,{name:t,plugin:i,instance:e}),e}
vendor: 4,083 bytes, lines 3795-3804
3795return Object.keys(i).forEach(function(e){s[e]=i[e]}),s}const rn="plugin",nn="activePlugins_",an={},on=e=>an.hasOwnProperty(e),ln=e=>on(e)?an[e]:void 0,dn=(e,t)=>{e[nn]=e[nn]||{},e[nn][t]=!0},hn=(e,t,i)=>{i=(i?"before":"")+"pluginsetup";e.trigger(i,t),e.trigger(i+":"+t.name,t)},un=(i,s)=>(s.prototype.name=i,function(...e){hn(this,{name:i,plugin:s,instance:null},!0);const t=new s(this,...e);return this[i]=()=>t,hn(this,t.getEventHash()),t});class cn{constructor(e){if(this.constructor===cn)throw new Error("Plugin must be sub-classed; not directly instantiated.");this.player=e,this.log||(this.log=this.player.log.createLogger(this.name)),Ct(this),delete this.trigger,xt(this,this.constructor.defaultState),dn(e,this.name),this.dispose=this.dispose.bind(this),e.on("dispose",this.dispose)}version(){return this.constructor.VERSION}getEventHash(e={}){return e.name=this.name,e.plugin=this.constructor,e.instance=this,e}trigger(e,t={}){return lt(this.eventBusEl_,e,this.getEventHash(t))}handleStateChanged(e){}dispose(){var{name:e,player:t}=this;this.trigger("dispose"),this.off(),t.off("dispose",this.dispose),t[nn][e]=!1,this.player=this.state=null,t[e]=un(e,an[e])}static isBasic(e){e="string"==typeof e?ln(e):e;return"function"==typeof e&&!cn.prototype.isPrototypeOf(e.prototype)}static registerPlugin(e,t){if("string"!=typeof e)throw new Error(`Illegal plugin name, "${e}", must be a string, was ${typeof e}.`);if(on(e))d.warn(`A plugin named "${e}" already exists. You may want to avoid re-registering plugins!`);else if(b.prototype.hasOwnProperty(e))throw new Error(`Illegal plugin name, "${e}", cannot share a name with an existing player method!`);if("function"!=typeof t)throw new Error(`Illegal plugin for "${e}", must be a function, was ${typeof t}.`);return an[e]=t,e!==rn&&(cn.isBasic(t)?b.prototype[e]=sn(e,t):b.prototype[e]=un(e,t)),t}static deregisterPlugin(e){if(e===rn)throw new Error("Cannot de-register base plugin.");on(e)&&(delete an[e],delete b.prototype[e])}static getPlugins(e=Object.keys(an)){let i;return e.forEach(e=>{var t=ln(e);t&&((i=i||{})[e]=t)}),i}static getPluginVersion(e){e=ln(e);return e&&e.VERSION||""}}function pn(e,i,s,r){{var n=i+` is deprecated and will be removed in ${e}.0; please use ${s} instead.`,a=r;let t=!1;return function(...e){return t||d.warn(n),t=!0,a.apply(this,e)}}}cn.getPlugin=ln,cn.BASE_PLUGIN_NAME=rn,cn.registerPlugin(rn,cn),b.prototype.usingPlugin=function(e){return!!this[nn]&&!0===this[nn][e]},b.prototype.hasPlugin=function(e){return!!on(e)};const mn=e=>0===e.indexOf("#")?e.slice(1):e;function T(e,t,i){let s=T.getPlayer(e);if(s)t&&d.warn(`Player "${e}" is already initialised. Options will not be applied.`),i&&s.ready(i);else{const r="string"==typeof e?$e("#"+mn(e)):e;if(!ve(r))throw new TypeError("The element or ID supplied is not valid. (videojs)");r.ownerDocument.defaultView&&r.ownerDocument.body.contains(r)||d.warn("The element supplied is not included in the DOM"),!0===(t=t||{}).restoreEl&&(t.restoreEl=(r.parentNode&&r.parentNode.hasAttribute("data-vjs-player")?r.parentNode:r).cloneNode(!0)),B("beforesetup").forEach(e=>{e=e(r,h(t));!K(e)||Array.isArray(e)?d.error("please return an object in beforesetup hooks"):t=h(t,e)});e=f.getComponent("Player");s=new e(r,t,i),B("setup").forEach(e=>e(s))}return s}T.hooks_=U,T.hooks=B,T.hook=function(e,t){B(e,t)},T.hookOnce=function(s,e){B(s,[].concat(e).map(t=>{const i=(...e)=>(F(s,i),t(...e));return i}))},T.removeHook=F,!0!==window.VIDEOJS_NO_DYNAMIC_STYLE&&_e()&&!(Mi=$e(".vjs-styles-defaults"))&&(Mi=Ze("vjs-styles-defaults"),(Or=$e("head"))&&Or.insertBefore(Mi,Or.firstChild),et(Mi,` 3796 .video-js { 3797 width: 300px; 3798 height: 150px; 3799 } 3800 3801 .vjs-fluid:not(.vjs-audio-only-mode) { 3802 padding-top: 56.25% 3803 } 3804 `)),Qe(1,T),T.VERSION=R,T.options=b.prototype.options_,T.getPlayers=()=>b.players,T.getPlayer=e=>{var t=b.players;let i;if("string"==typeof e){var s=mn(e),r=t[s];if(r)return r;i=$e("#"+s)}else i=e;if(ve(i)){var{player:r,playerId:s}=i;if(r||t[s])return r||t[s]}},T.getAllPlayers=()=>Object.keys(b.players).map(e=>
3804b.players[e]).filter(Boolean),T.players=b.players,T.getComponent=f.getComponent,T.registerComponent=(e,t)=>{_.isTech(t)&&d.warn(`The ${e} tech was registered as a component. It should instead be registered using videojs.registerTech(name, tech)`),f.registerComponent.call(f,e,t)},T.getTech=_.getTech,T.registerTech=_.registerTech,T.use=function(e,t){hs[e]=hs[e]||[],hs[e].push(t)},Object.defineProperty(T,"middleware",{value:{},writeable:!1,enumerable:!0}),Object.defineProperty(T.middleware,"TERMINATOR",{value:cs,writeable:!1,enumerable:!0}),T.browser=e,T.obj=J,T.mergeOptions=pn(9,"videojs.mergeOptions","videojs.obj.merge",h),T.defineLazyProperty=pn(9,"videojs.defineLazyProperty","videojs.obj.defineLazyProperty",Q),T.bind=pn(9,"videojs.bind","native Function.prototype.bind",m),T.registerPlugin=cn.registerPlugin,T.deregisterPlugin=cn.deregisterPlugin,T.plugin=(e,t)=>(d.warn("videojs.plugin() is deprecated; use videojs.registerPlugin() instead"),cn.registerPlugin(e,t)),T.getPlugins=cn.getPlugins,T.getPlugin=cn.getPlugin,T.getPluginVersion=cn.getPluginVersion,T.addLanguage=function(e,t){return e=(""+e).toLowerCase(),T.options.languages=h(T.options.languages,{[e]:t}),T.options.languages[e]},T.log=d,T.createLogger=W,T.time=qt,T.createTimeRange=pn(9,"videojs.createTimeRange","videojs.time.createTimeRanges",Rt),T.createTimeRanges=pn(9,"videojs.createTimeRanges","videojs.time.createTimeRanges",Rt),T.formatTime=pn(9,"videojs.formatTime","videojs.time.formatTime",Ht),T.setFormatTime=pn(9,"videojs.setFormatTime","videojs.time.setFormatTime",Ft),T.resetFormatTime=pn(9,"videojs.resetFormatTime","videojs.time.resetFormatTime",jt),T.parseUrl=pn(9,"videojs.parseUrl","videojs.url.parseUrl",li),T.isCrossOrigin=pn(9,"videojs.isCrossOrigin","videojs.url.isCrossOrigin",hi),T.EventTarget=ft,T.any=ht,T.on=ot,T.one=dt,T.off=p,T.trigger=lt,T.xhr=bi,T.TextTrack=Ai,T.AudioTrack=Pi,T.VideoTrack=Li,["isEl","isTextNode","createEl","hasClass","addClass","removeClass","toggleClass","setAttributes","getAttributes","emptyEl","appendContent","insertContent"].forEach(e=>{T[e]=function(){return d.warn(`videojs.${e}() is deprecated; use videojs.dom.${e}() instead`),ze[e].apply(null,arguments)}}),T.computedStyle=pn(9,"videojs.computedStyle","videojs.dom.computedStyle",Ge),T.dom=ze,T.fn=mt,T.num=pi,T.str=Lt,T.url=ci,Dt(function(e,t){ 3805/*! @name videojs-contrib-quality-levels @version 3.0.0 @license Apache-2.0 */ 3806e.exports=function(e){function t(e){return e&&typeof e==="object"&&"default"in e?e:{default:e}}var i=t(e);class s{constructor(e){let t=this;t.id=e.id;t.label=t.id;t.width=e.width;t.height=e.height;t.bitrate=e.bandwidth;t.frameRate=e.frameRate;t.enabled_=e.enabled;Object.defineProperty(t,"enabled",{get(){return t.enabled_()},set(e){t.enabled_(e)}});return t}}class n extends i["default"].EventTarget{constructor(){super();let e=this;e.levels_=[];e.selectedIndex_=-1;Object.defineProperty(e,"selectedIndex",{get(){return e.selectedIndex_}});Object.defineProperty(e,"length",{get(){return e.levels_.length}});return e}addQualityLevel(e){let t=this.getQualityLevelById(e.id);if(t)return t;const i=this.levels_.length;t=new s(e);if(!(""+i in this))Object.defineProperty(this,i,{get(){return this.levels_[i]}});this.levels_.push(t);this.trigger({qualityLevel:t,type:"addqualitylevel"});return t}removeQualityLevel(i){let s=null;for(let e=0,t=this.length;e<t;e++)if(this[e]===i){s=this.levels_.splice(e,1)[0];if(this.selectedIndex_===e)this.selectedIndex_=-1;else if(this.selectedIndex_>e)this.selectedIndex_--;break}if(s)this.trigger({qualityLevel:i,type:"removequalitylevel"});return s}getQualityLevelById(i){for(let e=0,t=this.length;e<t;e++){const s=this[e];if(s.id===i)return s}return null}dispose(){this.selectedIndex_=-1;this.levels_.length=0}}n.prototype.allowedEvents_={change:"change",addqualitylevel:"addqualitylevel",removequalitylevel:"removequalitylevel"};for(const d in n.prototype.allowedEvents_)n.prototype["on"+d]=null;var a="3.0.0";const r=i["default"].registerPlugin||i["default"].plugin,o=function(e,t){const i=e.qualityLevels;const s=new n;const r=function(){s.dispose();e.qualityLevels=i;e.off("dispose",r)};e.on("dispose",r);e.qualityLevels=()=>s;e.qualityLevels.VERSION=a;return s},l=function(e){return o(this,i["default"].mergeOptions({},e))};return r("qualityLevels",l),l.VERSION=a,l}(T)});var gn=Dt(function(e,t){var i,n,s,r,a;i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,n=/^(?=([^\/?#]*))\1([^]*)$/,s=/(?:\/|^)\.(?=\/)/g,r=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(e,t,i){if(i=i||{},e=e.trim(),!(t=t.trim())){if(!i.alwaysNormalize)return e;var s=a.parseURL(e);if(s)return s.path=a.normalizePath(s.path),a.buildURLFromParts(s);throw new Error("Error trying to parse base URL.")}s=a.parseURL(t);if(!s)throw new Error("Error trying to parse relative URL.");
3806if(s.scheme)return i.alwaysNormalize?(s.path=a.normalizePath(s.path),a.buildURLFromParts(s)):t;t=a.parseURL(e);if(!t)throw new Error("Error trying to parse base URL.");!t.netLoc&&t.path&&"/"!==t.path[0]&&(e=n.exec(t.path),t.netLoc=e[1],t.path=e[2]),t.netLoc&&!t.path&&(t.path="/");var r,e={scheme:t.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};return s.netLoc||(e.netLoc=t.netLoc,"/"!==s.path[0]&&(s.path?(r=(r=t.path).substring(0,r.lastIndexOf("/")+1)+s.path,e.path=a.normalizePath(r)):(e.path=t.path,s.params||(e.params=t.params,s.query)||(e.query=t.query)))),null===e.path&&(e.path=i.alwaysNormalize?a.normalizePath(s.path):s.path),a.buildURLFromParts(e)},parseURL:function(e){e=i.exec(e);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(s,"");e.length!==(e=e.replace(r,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=a}),fn="http://example.com",Lr=function(){function e(){this.listeners={}}var t=e.prototype;return t.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},t.off=function(e,t){return!!this.listeners[e]&&(t=this.listeners[e].indexOf(t),this.listeners[e]=this.listeners[e].slice(0),this.listeners[e].splice(t,1),-1<t)},t.trigger=function(e){var t=this.listeners[e];if(t)if(2===arguments.length)for(var i=t.length,s=0;s<i;++s)t[s].call(this,arguments[1]);else for(var r=Array.prototype.slice.call(arguments,1),n=t.length,a=0;a<n;++a)t[a].apply(this,r)},t.dispose=function(){this.listeners={}},t.pipe=function(t){this.on("data",function(e){t.push(e)})},e}();function yn(e){e=e;for(var t=window.atob?window.atob(e):Buffer.from(e,"base64").toString("binary"),i=new Uint8Array(t.length),s=0;s<t.length;s++)i[s]=t.charCodeAt(s);return i} 3807/*! @name m3u8-parser @version 6.0.0 @license Apache-2.0 */class _n extends Lr{constructor(){super(),this.buffer=""}push(e){let t;for(this.buffer+=e,t=this.buffer.indexOf("\n");-1<t;t=this.buffer.indexOf("\n"))this.trigger("data",this.buffer.substring(0,t)),this.buffer=this.buffer.substring(t+1)}}function vn(e){var e=/([0-9.]*)?@?([0-9.]*)?/.exec(e||""),t={};return e[1]&&(t.length=parseInt(e[1],10)),e[2]&&(t.offset=parseInt(e[2],10)),t}function bn(t){var i={};if(t){var s,r=t.split(new RegExp('(?:^|,)((?:[^=]*)=(?:"[^"]*"|[^,]*))'));let e=r.length;for(;e--;)""!==r[e]&&((s=/([^=]*)=(.*)/.exec(r[e]).slice(1))[0]=s[0].replace(/^\s+|\s+$/g,""),s[1]=s[1].replace(/^\s+|\s+$/g,""),s[1]=s[1].replace(/^['"](.*)['"]$/g,"$1"),i[s[0]]=s[1])}return i}const Tn=String.fromCharCode(9);class Sn extends Lr{constructor(){super(),this.customParsers=[],this.tagMappers=[]}push(i){let s,r;0!==(i=i.trim()).length&&("#"!==i[0]?this.trigger("data",{type:"uri",uri:i}):this.tagMappers.reduce((e,t)=>{t=t(i);return t===i?e:e.concat([t])},[i]).forEach(t=>{for(let e=0;e<this.customParsers.length;e++)if(this.customParsers[e].call(this,t))return;var e,i;0!==t.indexOf("#EXT")?this.trigger("data",{type:"comment",text:t.slice(1)}):(t=t.replace("\r",""),(s=/^#EXTM3U/.exec(t))?this.trigger("data",{type:"tag",tagType:"m3u"}):(s=/^#EXTINF:([0-9\.]*)?,?(.*)?$/.exec(t))?(r={type:"tag",tagType:"inf"},s[1]&&(r.duration=parseFloat(s[1])),s[2]&&(r.title=s[2]),this.trigger("data",r)):(s=/^#EXT-X-TARGETDURATION:([0-9.]*)?/.exec(t))?(r={type:"tag",tagType:"targetduration"},s[1]&&(r.duration=parseInt(s[1],10)),this.trigger("data",r)):(s=/^#EXT-X-VERSION:([0-9.]*)?/.exec(t))?(r={type:"tag",tagType:"version"},s[1]&&(r.version=parseInt(s[1],10)),this.trigger("data",r)):(s=/^#EXT-X-MEDIA-SEQUENCE:(\-?[0-9.]*)?/.exec(t))?(r={type:"tag",tagType:"media-sequence"},s[1]&&(r.number=parseInt(s[1],10)),this.trigger("data",r)):(s=/^#EXT-X-DISCONTINUITY-SEQUENCE:(\-?[0-9.]*)?/.exec(t))?(r={type:"tag",tagType:"discontinuity-sequence"},s[1]&&(r.number=parseInt(s[1],10)),this.trigger("data",r)):(s=/^#EXT-X-PLAYLIST-TYPE:(.*)?$/.exec(t))?(r={type:"tag",tagType:"playlist-type"},s[1]&&(r.playlistType=s[1]),this.trigger("data",r)):(s=/^#EXT-X-BYTERANGE:(.*)?$/.exec(t))?(r=fi(vn(s[1]),{type:"tag",tagType:"byterange"}),this.trigger("data",r)):(s=/^#EXT-X-ALLOW-CACHE:(YES|NO)?/.exec(t))?(r={type:"tag",tagType:"allow-cache"},s[1]&&(r.allowed=!/NO/.test(s[1])),this.trigger("data",r)):(s=/^#EXT-X-MAP:(.*)$/.exec(t))?(r={type:"tag",tagType:"map"},s[1]&&((i=bn(s[1])).URI&&(r.uri=i.URI),i.BYTERANGE)&&(r.byterange=vn(i.BYTERANGE)),this.trigger("data",r)):(s=/^#EXT-X-STREAM-INF:(.*)$/.exec(t))?(r={type:"tag",tagType:"stream-inf"},s[1]&&(r.attributes=bn(s[1]),r.attributes.RESOLUTION&&(i={},(e=r.attributes.RESOLUTION.split("x"))[0]&&(i.width=parseInt(e[0],10)),e[1]&&(i.height=parseInt(e[1],10)),r.attributes.RESOLUTION=i),r.attributes.BANDWIDTH&&(r.attributes.BANDWIDTH=parseInt(r.attributes.BANDWIDTH,10)),r.attributes["FRAME-RATE"]&&(r.attributes["FRAME-RATE"]=parseFloat(r.attributes["FRAME-RATE"])),r.attributes["PROGRAM-ID"])&&(r.attributes["PROGRAM-ID"]=parseInt(r.attributes["PROGRAM-ID"],10)),this.trigger("data",r)):(s=/^#EXT-X-MEDIA:(.*)$/.exec(t))?(r={type:"tag",tagType:"media"},s[1]&&(r.attributes=bn(s[1])),this.trigger("data",r)):(s=/^#EXT-X-ENDLIST/.exec(t))?this.trigger("data",{type:"tag",tagType:"endlist"}):(s=/^#EXT-X-DISCONTINUITY/.exec(t))?this.trigger("data",{type:"tag",tagType:"discontinuity"}):(s=/^#EXT-X-PROGRAM-DATE-TIME:(.*)$/.exec(t))?(r={type:"tag",tagType:"program-date-time"}
vendor: 22,825 bytes, line 3807
3807,s[1]&&(r.dateTimeString=s[1],r.dateTimeObject=new Date(s[1])),this.trigger("data",r)):(s=/^#EXT-X-KEY:(.*)$/.exec(t))?(r={type:"tag",tagType:"key"},s[1]&&(r.attributes=bn(s[1]),r.attributes.IV)&&("0x"===r.attributes.IV.substring(0,2).toLowerCase()&&(r.attributes.IV=r.attributes.IV.substring(2)),r.attributes.IV=r.attributes.IV.match(/.{8}/g),r.attributes.IV[0]=parseInt(r.attributes.IV[0],16),r.attributes.IV[1]=parseInt(r.attributes.IV[1],16),r.attributes.IV[2]=parseInt(r.attributes.IV[2],16),r.attributes.IV[3]=parseInt(r.attributes.IV[3],16),r.attributes.IV=new Uint32Array(r.attributes.IV)),this.trigger("data",r)):(s=/^#EXT-X-START:(.*)$/.exec(t))?(r={type:"tag",tagType:"start"},s[1]&&(r.attributes=bn(s[1]),r.attributes["TIME-OFFSET"]=parseFloat(r.attributes["TIME-OFFSET"]),r.attributes.PRECISE=/YES/.test(r.attributes.PRECISE)),this.trigger("data",r)):(s=/^#EXT-X-CUE-OUT-CONT:(.*)?$/.exec(t))?(r={type:"tag",tagType:"cue-out-cont"},s[1]?r.data=s[1]:r.data="",this.trigger("data",r)):(s=/^#EXT-X-CUE-OUT:(.*)?$/.exec(t))?(r={type:"tag",tagType:"cue-out"},s[1]?r.data=s[1]:r.data="",this.trigger("data",r)):(s=/^#EXT-X-CUE-IN:(.*)?$/.exec(t))?(r={type:"tag",tagType:"cue-in"},s[1]?r.data=s[1]:r.data="",this.trigger("data",r)):(s=/^#EXT-X-SKIP:(.*)$/.exec(t))&&s[1]?((r={type:"tag",tagType:"skip"}).attributes=bn(s[1]),r.attributes.hasOwnProperty("SKIPPED-SEGMENTS")&&(r.attributes["SKIPPED-SEGMENTS"]=parseInt(r.attributes["SKIPPED-SEGMENTS"],10)),r.attributes.hasOwnProperty("RECENTLY-REMOVED-DATERANGES")&&(r.attributes["RECENTLY-REMOVED-DATERANGES"]=r.attributes["RECENTLY-REMOVED-DATERANGES"].split(Tn)),this.trigger("data",r)):(s=/^#EXT-X-PART:(.*)$/.exec(t))&&s[1]?((r={type:"tag",tagType:"part"}).attributes=bn(s[1]),["DURATION"].forEach(function(e){r.attributes.hasOwnProperty(e)&&(r.attributes[e]=parseFloat(r.attributes[e]))}),["INDEPENDENT","GAP"].forEach(function(e){r.attributes.hasOwnProperty(e)&&(r.attributes[e]=/YES/.test(r.attributes[e]))}),r.attributes.hasOwnProperty("BYTERANGE")&&(r.attributes.byterange=vn(r.attributes.BYTERANGE)),this.trigger("data",r)):(s=/^#EXT-X-SERVER-CONTROL:(.*)$/.exec(t))&&s[1]?((r={type:"tag",tagType:"server-control"}).attributes=bn(s[1]),["CAN-SKIP-UNTIL","PART-HOLD-BACK","HOLD-BACK"].forEach(function(e){r.attributes.hasOwnProperty(e)&&(r.attributes[e]=parseFloat(r.attributes[e]))}),["CAN-SKIP-DATERANGES","CAN-BLOCK-RELOAD"].forEach(function(e){r.attributes.hasOwnProperty(e)&&(r.attributes[e]=/YES/.test(r.attributes[e]))}),this.trigger("data",r)):(s=/^#EXT-X-PART-INF:(.*)$/.exec(t))&&s[1]?((r={type:"tag",tagType:"part-inf"}).attributes=bn(s[1]),["PART-TARGET"].forEach(function(e){r.attributes.hasOwnProperty(e)&&(r.attributes[e]=parseFloat(r.attributes[e]))}),this.trigger("data",r)):(s=/^#EXT-X-PRELOAD-HINT:(.*)$/.exec(t))&&s[1]?((r={type:"tag",tagType:"preload-hint"}).attributes=bn(s[1]),["BYTERANGE-START","BYTERANGE-LENGTH"].forEach(function(e){var t;r.attributes.hasOwnProperty(e)&&(r.attributes[e]=parseInt(r.attributes[e],10),t="BYTERANGE-LENGTH"===e?"length":"offset",r.attributes.byterange=r.attributes.byterange||{},r.attributes.byterange[t]=r.attributes[e],delete r.attributes[e])}),this.trigger("data",r)):(s=/^#EXT-X-RENDITION-REPORT:(.*)$/.exec(t))&&s[1]?((r={type:"tag",tagType:"rendition-report"}).attributes=bn(s[1]),["LAST-MSN","LAST-PART"].forEach(function(e){r.attributes.hasOwnProperty(e)&&(r.attributes[e]=parseInt(r.attributes[e],10))}),this.trigger("data",r)):this.trigger("data",{type:"tag",data:t.slice(4)}))}))}addParser({expression:t,customType:i,dataParser:s,segment:r}){"function"!=typeof s&&(s=e=>e),this.customParsers.push(e=>{if(t.exec(e))return this.trigger("data",{type:"custom",data:s(e),customType:i,segment:r}),!0})}addTagMapper({expression:t,map:i}){this.tagMappers.push(e=>t.test(e)?i(e):e)}}function wn(t){const i={};return Object.keys(t).forEach(function(e){i[e.toLowerCase().replace(/-(\w)/g,e=>e[1].toUpperCase())]=t[e]}),i}function En(e){var t,i,s,r,n,{serverControl:e,targetDuration:a,partTargetDuration:o}=e;e&&(t="#EXT-X-SERVER-CONTROL",i="holdBack",s="partHoldBack",r=a&&3*a,n=o&&2*o,a&&!e.hasOwnProperty(i)&&(e[i]=r,this.trigger("info",{message:t+` defaulting HOLD-BACK to targetDuration * 3 (${r}).`})),r&&e[i]<r&&(this.trigger("warn",{message:t+` clamping HOLD-BACK (${e[i]}) to targetDuration * 3 (${r})`}),e[i]=r),o&&!e.hasOwnProperty(s)&&(e[s]=3*o,this.trigger("info",{message:t+` defaulting PART-HOLD-BACK to partTargetDuration * 3 (${e[s]}).`})),o)&&e[s]<n&&(this.trigger("warn",{message:t+` clamping PART-HOLD-BACK (${e[s]}) to partTargetDuration * 2 (${n}).`}),e[s]=n)}class kn extends Lr{constructor(){super(),this.lineStream=new _n,this.parseStream=new Sn,this.lineStream.pipe(this.parseStream);const e=this,s=[];let a={},r,o,l=!1;const d={AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}};let h=0,u=(this.manifest={allowCache:!0,discontinuityStarts:[],segments:[]},0),c=0;this.on("end",()=>{a.uri||!a.parts&&!a.preloadHints||(!a.map&&r&&(a.map=r),!a.key&&o&&(a.key=o),a.timeline||"number"!=typeof h||(a.timeline=h),this.manifest.preloadSegment=a)}),this.parseStream.on("data",function(n){let t,i;({tag(){({version(){n.version&&(this.manifest.version=n.version)},"allow-cache"(){this.manifest.allowCache=n.allowed,"allowed"in n||(this.trigger("info",{message:"defaulting allowCache to YES"}),this.manifest.allowCache=!0)},byterange(){var e={};"length"in n&&((a.byterange=e).length=n.length,"offset"in n||(n.offset=u)),"offset"in n&&((a.byterange=e).offset=n.offset),u=e.offset+e.length},endlist(){this.manifest.endList=!0},inf(){"mediaSequence"in this.manifest||(this.manifest.mediaSequence=0,this.trigger("info",{message:"defaulting media sequence to zero"})),"discontinuitySequence"in this.manifest||(this.manifest.discontinuitySequence=0,this.trigger("info",{message:"defaulting discontinuity sequence to zero"})),0<n.duration&&(a.duration=n.duration),0===n.duration&&(a.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=s},key(){if(n.attributes)if("NONE"===n.attributes.METHOD)o=null;else if(n.attributes.URI)if("com.apple.streamingkeydelivery"===n.attributes.KEYFORMAT)this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.apple.fps.1_0"]={attributes:n.attributes};else if("com.microsoft.playready"===n.attributes.KEYFORMAT)this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.microsoft.playready"]={uri:n.attributes.URI};else{if("urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"===n.attributes.KEYFORMAT)return-1===["SAMPLE-AES","SAMPLE-AES-CTR","SAMPLE-AES-CENC"].indexOf(n.attributes.METHOD)?void this.trigger("warn",{message:"invalid key method provided for Widevine"}):("SAMPLE-AES-CENC"===n.attributes.METHOD&&this.trigger("warn",{message:"SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead"}),"data:text/plain;base64,"!==n.attributes.URI.substring(0,23)?void this.trigger("warn",{message:"invalid key URI provided for Widevine"}):n.attributes.KEYID&&"0x"===n.attributes.KEYID.substring(0,2)?(this.manifest.contentProtection=this.manifest.contentProtection||{},void(this.manifest.contentProtection["com.widevine.alpha"]={attributes:{schemeIdUri:n.attributes.KEYFORMAT,keyId:n.attributes.KEYID.substring(2)},pssh:yn(n.attributes.URI.split(",")[1])})):void this.trigger("warn",{message:"invalid key ID provided for Widevine"}));n.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),o={method:n.attributes.METHOD||"AES-128",uri:n.attributes.URI},"undefined"!=typeof n.attributes.IV&&(o.iv=n.attributes.IV)}else this.trigger("warn",{message:"ignoring key declaration without URI"});else this.trigger("warn",{message:"ignoring key declaration without attribute list"})},"media-sequence"(){isFinite(n.number)?this.manifest.mediaSequence=n.number:this.trigger("warn",{message:"ignoring invalid media sequence: "+n.number})},"discontinuity-sequence"(){isFinite(n.number)?(this.manifest.discontinuitySequence=n.number,h=n.number):this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+n.number})},"playlist-type"(){/VOD|EVENT/.test(n.playlistType)?this.manifest.playlistType=n.playlistType:this.trigger("warn",{message:"ignoring unknown playlist type: "+n.playlist})},map(){r={},n.uri&&(r.uri=n.uri),n.byterange&&(r.byterange=n.byterange),o&&(r.key=o)},"stream-inf"(){this.manifest.playlists=s,this.manifest.mediaGroups=this.manifest.mediaGroups||d,n.attributes?(a.attributes||(a.attributes={}),fi(a.attributes,n.attributes)):this.trigger("warn",{message:"ignoring empty stream-inf attributes"})},media(){var e;this.manifest.mediaGroups=this.manifest.mediaGroups||d,n.attributes&&n.attributes.TYPE&&n.attributes["GROUP-ID"]&&n.attributes.NAME?((e=this.manifest.mediaGroups[n.attributes.TYPE])[n.attributes["GROUP-ID"]]=e[n.attributes["GROUP-ID"]]||{},t=e[n.attributes["GROUP-ID"]],(i={default:/yes/i.test(n.attributes.DEFAULT)}).default?i.autoselect=!0:i.autoselect=/yes/i.test(n.attributes.AUTOSELECT),n.attributes.LANGUAGE&&(i.language=n.attributes.LANGUAGE),n.attributes.URI&&(i.uri=n.attributes.URI),n.attributes["INSTREAM-ID"]&&(i.instreamId=n.attributes["INSTREAM-ID"]),n.attributes.CHARACTERISTICS&&(i.characteristics=n.attributes.CHARACTERISTICS),n.attributes.FORCED&&(i.forced=/yes/i.test(n.attributes.FORCED)),t[n.attributes.NAME]=i):this.trigger("warn",{message:"ignoring incomplete or missing media group"})},discontinuity(){h+=1,a.discontinuity=!0,this.manifest.discontinuityStarts.push(s.length)},"program-date-time"(){"undefined"==typeof this.manifest.dateTimeString&&(this.manifest.dateTimeString=n.dateTimeString,this.manifest.dateTimeObject=n.dateTimeObject),a.dateTimeString=n.dateTimeString,a.dateTimeObject=n.dateTimeObject},targetduration(){!isFinite(n.duration)||n.duration<0?this.trigger("warn",{message:"ignoring invalid target duration: "+n.duration}):(this.manifest.targetDuration=n.duration,En.call(this,this.manifest))},start(){!n.attributes||isNaN(n.attributes["TIME-OFFSET"])?this.trigger("warn",{message:"ignoring start declaration without appropriate attribute list"}):this.manifest.start={timeOffset:n.attributes["TIME-OFFSET"],precise:n.attributes.PRECISE}},"cue-out"(){a.cueOut=n.data},"cue-out-cont"(){a.cueOutCont=n.data},"cue-in"(){a.cueIn=n.data},skip(){this.manifest.skip=wn(n.attributes),this.warnOnMissingAttributes_("#EXT-X-SKIP",n.attributes,["SKIPPED-SEGMENTS"])},part(){l=!0;var e=this.manifest.segments.length,t=wn(n.attributes),t=(a.parts=a.parts||[],a.parts.push(t),t.byterange&&(t.byterange.hasOwnProperty("offset")||(t.byterange.offset=c),c=t.byterange.offset+t.byterange.length),a.parts.length-1);this.warnOnMissingAttributes_(`#EXT-X-PART #${t} for segment #`+e,n.attributes,["URI","DURATION"]),this.manifest.renditionReports&&this.manifest.renditionReports.forEach((e,t)=>{e.hasOwnProperty("lastPart")||this.trigger("warn",{message:`#EXT-X-RENDITION-REPORT #${t} lacks required attribute(s): LAST-PART`})})},"server-control"(){var e=this.manifest.serverControl=wn(n.attributes);e.hasOwnProperty("canBlockReload")||(e.canBlockReload=!1,this.trigger("info",{message:"#EXT-X-SERVER-CONTROL defaulting CAN-BLOCK-RELOAD to false"})),En.call(this,this.manifest),e.canSkipDateranges&&!e.hasOwnProperty("canSkipUntil")&&this.trigger("warn",{message:"#EXT-X-SERVER-CONTROL lacks required attribute CAN-SKIP-UNTIL which is required when CAN-SKIP-DATERANGES is set"})},"preload-hint"(){var t=this.manifest.segments.length,i=wn(n.attributes),e=i.type&&"PART"===i.type,s=(a.preloadHints=a.preloadHints||[],a.preloadHints.push(i),!i.byterange||i.byterange.hasOwnProperty("offset")||(i.byterange.offset=e?c:0,e&&(c=i.byterange.offset+i.byterange.length)),a.preloadHints.length-1);if(this.warnOnMissingAttributes_(`#EXT-X-PRELOAD-HINT #${s} for segment #`+t,n.attributes,["TYPE","URI"]),i.type)for(let e=0;e<a.preloadHints.length-1;e++){var r=a.preloadHints[e];r.type&&r.type===i.type&&this.trigger("warn",{message:`#EXT-X-PRELOAD-HINT #${s} for segment #${t} has the same TYPE ${i.type} as preload hint #`+e})}},"rendition-report"(){var e=wn(n.attributes),e=(this.manifest.renditionReports=this.manifest.renditionReports||[],this.manifest.renditionReports.push(e),this.manifest.renditionReports.length-1),t=["LAST-MSN","URI"];l&&t.push("LAST-PART"),this.warnOnMissingAttributes_("#EXT-X-RENDITION-REPORT #"+e,n.attributes,t)},"part-inf"(){this.manifest.partInf=wn(n.attributes),this.warnOnMissingAttributes_("#EXT-X-PART-INF",n.attributes,["PART-TARGET"]),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),En.call(this,this.manifest)}}[n.tagType]||function(){}).call(e)},uri(){a.uri=n.uri,s.push(a),!this.manifest.targetDuration||"duration"in a||(this.trigger("warn",{message:"defaulting segment duration to the target duration"}),a.duration=this.manifest.targetDuration),o&&(a.key=o),a.timeline=h,r&&(a.map=r),c=0,a={}},comment(){},custom(){n.segment?(a.custom=a.custom||{},a.custom[n.customType]=n.data):(this.manifest.custom=this.manifest.custom||{},this.manifest.custom[n.customType]=n.data)}})[n.type].call(e)})}warnOnMissingAttributes_(e,t,i){const s=[];i.forEach(function(e){t.hasOwnProperty(e)||s.push(e)}),s.length&&this.trigger("warn",{message:e+" lacks required attribute(s): "+s.join(", ")})}push(e){this.lineStream.push(e)}end(){this.lineStream.push("\n"),this.trigger("end")}addParser(e){this.parseStream.addParser(e)}addTagMapper(e){this.parseStream.addTagMapper(e)}}function Cn(e){return Dn.audio.test((e=void 0===e?"":e).trim().toLowerCase())}function In(e){return void 0===e&&(e=""),window.MediaSource&&window.MediaSource.isTypeSupported&&window.MediaSource.isTypeSupported(Bn(e))||!1}function xn(e){return(e=void 0===e?"":e).toLowerCase().split(",").every(function(e){e=e.trim();for(var t=0;t<Mn.length;t++){var i=Mn[t];if(Dn["muxer"+i].test(e))return!0}return!1})}function An(e){return jn.test(e)?"hls":Hn.test(e)?"dash":"application/vnd.videojs.vhs+json"===e?"vhs-json":null}function Pn(e,t){for(var i=void 0!==(t=(void 0===t?{}:t).le)&&t,s=(e=w(e="bigint"!=typeof e&&"number"!=typeof e||"number"==typeof e&&e!=e?0:e),t=e,Math.ceil(t.toString(2).length/8)),r=new Uint8Array(new ArrayBuffer(s)),n=0;n<s;n++){var a=i?n:Math.abs(n+1-r.length);r[a]=Number(e/Vn[n]&w(255)),e<0&&(r[a]=Math.abs(~r[a]),r[a]-=0===n?1:2)}return r}function Ln(e,t){if("string"!=typeof(e="string"!=typeof e&&e&&"function"==typeof e.toString?e.toString():e))return new Uint8Array;t||(e=unescape(encodeURIComponent(e)));for(var i=new Uint8Array(e.length),s=0;s<e.length;s++)i[s]=e.charCodeAt(s);return i}function On(e,t){if(/^[a-z]+:/i.test(t))return t;/^data:/.test(e)&&(e=window.location&&window.location.href||"");var i="function"==typeof window.URL,s=/^\/\//.test(e),r=!window.location&&!/\/\//i.test(e);return i?e=new window.URL(e,window.location||Wn):/\/\//i.test(e)||(e=gn.buildAbsoluteURL(window.location&&window.location.href||"",e)),i?(i=new URL(t,e),r?i.href.slice(Wn.length):s?i.href.slice(i.protocol.length):i.href):gn.buildAbsoluteURL(e,t)}var Dn={mp4:/^(av0?1|avc0?[1234]|vp0?9|flac|opus|mp3|mp4a|mp4v|stpp.ttml.im1t)/,webm:/^(vp0?[89]|av0?1|opus|vorbis)/,ogg:/^(vp0?[89]|theora|flac|opus|vorbis)/,video:/^(av0?1|avc0?[1234]|vp0?[89]|hvc1|hev1|theora|mp4v)/,audio:/^(mp4a|flac|vorbis|opus|ac-[34]|ec-3|alac|mp3|speex|aac)/,text:/^(stpp.ttml.im1t)/,muxerVideo:/^(avc0?1)/,muxerAudio:/^(mp4a)/,muxerText:/a^/},Nn=["video","audio","text"],Mn=["Video","Audio","Text"],Rn=function(e){return e&&e.replace(/avc1\.(\d+)\.(\d+)/i,function(e,t,i){return"avc1."+("00"+Number(t).toString(16)).slice(-2)+"00"+("00"+Number(i).toString(16)).slice(-2)})},Un=function(e){var e=(e=void 0===e?"":e).split(","),n=[];return e.forEach(function(s){var r;s=s.trim(),Nn.forEach(function(e){var t,i=Dn[e].exec(s.toLowerCase());!i||i.length<=1||(r=e,i=s.substring(0,i[1].length),t=s.replace(i,""),n.push({type:i,details:t,mediaType:e}))}),r||n.push({type:s,details:"",mediaType:"unknown"})}),n},Bn=function(e){var t,i,s;if(e&&"string"==typeof e)return i="video",1===(t=e.toLowerCase().split(",").map(function(e){return Rn(e.trim())})).length&&Cn(t[0])?i="audio":1===t.length&&(s=t[0],Dn.text.test((s=void 0===s?"":s).trim().toLowerCase()))&&(i="application"),s="mp4",t.every(function(e){return Dn.mp4.test(e)})?s="mp4":t.every(function(e){return Dn.webm.test(e)})?s="webm":t.every(function(e){return Dn.ogg.test(e)})&&(s="ogg"),i+"/"+s+';codecs="'+e+'"'},Fn="mp4a.40.2",jn=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i,Hn=/^application\/dash\+xml/i,qn=function(e){return"function"===ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer},S=function(e){return e instanceof Uint8Array?e:(Array.isArray(e)||qn(e)||e instanceof ArrayBuffer||(e="number"!=typeof e||"number"==typeof e&&e!=e?0:[e]),new Uint8Array(e&&e.buffer||e,e&&e.byteOffset||0,e&&e.byteLength||0))},w=window.BigInt||Number,Vn=[w("0x1"),w("0x100"),w("0x10000"),w("0x1000000"),w("0x100000000"),w("0x10000000000"),w("0x1000000000000"),w("0x100000000000000"),w("0x10000000000000000")],$n=(Ot=new Uint16Array([65484]),255!==(Ot=new Uint8Array(Ot.buffer,Ot.byteOffset,Ot.byteLength))[0]&&Ot[0],function(s,e){var e=void 0===e?{}:e,t=e.signed,t=void 0!==t&&t,e=e.le,r=void 0!==e&&e,e=(s=S(s),r?"reduce":"reduceRight"),e=(s[e]||Array.prototype[e]).call(s,function(e,t,i){i=r?i:Math.abs(i+1-s.length);return e+w(t)*Vn[i]},w(0));return t&&(t=Vn[s.length]/w(2)-w(1))<(e=w(e))&&(e=(e=e-t-t)-w(2)),Number(e)}),E=function(i,e,t){var t=void 0===t?{}:t,s=t.offset,r=void 0===s?0:s,s=t.mask,n=void 0===s?[]:s,t=(i=S(i),(e=S(e)).every||Array.prototype.every);return e.length&&i.length-r>=e.length&&t.call(e,function(e,t){return e===(n[t]?n[t]&i[r+t]:i[r+t])})},Wn="http://example.com";function Gn(e){e=e;for(var t=window.atob?window.atob(e):Buffer.from(e,"base64").toString("binary"),i=new Uint8Array(t.length),s=0;s<t.length;s++)i[s]=t.charCodeAt(s);return i}function zn(e,t){return(t=void 0===t?Object:t)&&"function"==typeof t.freeze?t.freeze(e):e}var Xn=zn({HTML:"text/html",isHTML:function(e){return e===Xn.HTML},XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),Kn=zn({HTML:"http://www.w3.org/1999/xhtml",isHTML:function(e){return e===Kn.HTML},SVG:"http://www.w3.org/2000/svg",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"}),Yn={assign:function(e,t){if(null===e||"object"!=typeof e)throw new TypeError("target is not an object");for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},find:function(e,t,i){if(void 0===i&&(i=Array.prototype),e&&"function"==typeof i.find)return i.find.call(e,t);for(var s=0;s<e.length;s++)if(Object.prototype.hasOwnProperty.call(e,s)){var r=e[s];if(t.call(void 0,r,s,e))return r}},freeze:zn,MIME_TYPE:Xn,NAMESPACE:Kn},Qn=Yn.find,Jn=Yn.NAMESPACE;function Zn(e){return""!==e}function ea(e,t){return e.hasOwnProperty(t)||(e[t]=!0),e}function ta(e){return e?(e=(e=e)?e.split(/[\t\n\f\r ]+/).filter(Zn):[],Object.keys(e.reduce(ea,{}))):[]}function ia(e,t){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}function sa(e,t){var i=e.prototype;function s(){}i instanceof t||(s.prototype=t.prototype,ia(i,s=new s),e.prototype=i=s),i.constructor!=e&&(i.constructor=e)}var n={},t=(n.ELEMENT_NODE=1,n.ATTRIBUTE_NODE=2,n.TEXT_NODE=3,n.CDATA_SECTION_NODE=4,n.ENTITY_REFERENCE_NODE=5,n.ENTITY_NODE=6,n.PROCESSING_INSTRUCTION_NODE=7,n.COMMENT_NODE=8,n.DOCUMENT_NODE=9,n.DOCUMENT_TYPE_NODE=10,n.DOCUMENT_FRAGMENT_NODE=11,n.NOTATION_NODE=12,{}),k={},ra=(t.INDEX_SIZE_ERR=(k[1]="Index size error",1),t.DOMSTRING_SIZE_ERR=(k[2]="DOMString size error",2),t.HIERARCHY_REQUEST_ERR=(k[3]="Hierarchy request error",3)),na=(t.WRONG_DOCUMENT_ERR=(k[4]="Wrong document",4),t.INVALID_CHARACTER_ERR=(k[5]="Invalid character",5),t.NO_DATA_ALLOWED_ERR=(k[6]="No data allowed",6),t.NO_MODIFICATION_ALLOWED_ERR=(k[7]="No modification allowed",7),t.NOT_FOUND_ERR=(k[8]="Not found",8));t.NOT_SUPPORTED_ERR=(k[9]="Not supported",9),t.INUSE_ATTRIBUTE_ERR=(k[10]="Attribute in use",10);function C(e,t){var i;return t instanceof Error?i=t:(i=this,Error.call(this,k[e]),this.message=k[e],Error.captureStackTrace&&Error.captureStackTrace(this,C)),i.code=e,t&&(this.message=this.message+": "+t),i}function aa(){}function oa(e,t){this._node=e,this._refresh=t,la(this)}function la(e){var t,i=e._node._inc||e._node.ownerDocument._inc;e._inc!=i&&(t=e._refresh(e._node),Ga(e,"length",t.length),ia(t,e),e._inc=i)}function da(){}function ha(e,t){for(var i=e.length;i--;)if(e[i]===t)return i}function ua(e,t,i,s){s?t[ha(t,s)]=i:t[t.length++]=i,e&&(t=(i.ownerElement=e).ownerDocument)&&(s&&ya(t,e,s),s=e,e=i,(i=t)&&i._inc++,e.namespaceURI===Jn.XMLNS)&&(s._nsMap[e.prefix?e.localName:""]=e.value)}function ca(e,t,i){var s=ha(t,i);if(!(0<=s))throw new C(na,new Error(e.tagName+"@"+i));for(var r,n=t.length-1;s<n;)t[s]=t[++s];t.length=n,e&&(r=e.ownerDocument)&&(ya(r,e,i),i.ownerElement=null)}function pa(){}function I(){}function ma(e){return("<"==e?"<":">"==e&&">")||("&"==e?"&":'"'==e&&""")||"&#"+e.charCodeAt()+";"}function ga(e,t){if(t(e))return 1;if(e=e.firstChild)do{if(ga(e,t))return 1}while(e=e.nextSibling)}function fa(){this.ownerDocument=this}function ya(e,t,i){e&&e._inc++,i.namespaceURI===Jn.XMLNS&&delete t._nsMap[i.prefix?i.localName:""]}function _a(e,t,i){if(e&&e._inc){e._inc++;var s=t.childNodes;if(i)s[s.length++]=i;else{for(var r=t.firstChild,n=0;r;)r=(s[n++]=r).nextSibling;s.length=n,delete s[s.length]}}}function va(e,t){var i=t.previousSibling,s=t.nextSibling;return i?i.nextSibling=s:e.firstChild=s,s?s.previousSibling=i:e.lastChild=i,t.parentNode=null,t.previousSibling=null,t.nextSibling=null,_a(e.ownerDocument,e),t}function ba(e){return e&&e.nodeType===I.DOCUMENT_TYPE_NODE}function Ta(e){return e&&e.nodeType===I.ELEMENT_NODE}function Sa(e){return e&&e.nodeType===I.TEXT_NODE}function wa(e,t){var i,e=e.childNodes||[];if(!Qn(e,Ta)&&!ba(t))return i=Qn(e,ba),!(t&&i&&e.indexOf(i)>e.indexOf(t))}function Ea(e,t){var i,e=e.childNodes||[];if(!Qn(e,function(e){return Ta(e)&&e!==t}))return i=Qn(e,ba),!(t&&i&&e.indexOf(i)>e.indexOf(t))}function ka(e,t,i){if(!(s=e)||s.nodeType!==I.DOCUMENT_NODE&&s.nodeType!==I.DOCUMENT_FRAGMENT_NODE&&s.nodeType!==I.ELEMENT_NODE)throw new C(ra,"Unexpected parent node type "+e.nodeType);var s;if(i&&i.parentNode!==e)throw new C(na,"child not in parent");if(!(s=t)||!(Ta(s)||Sa(s)||ba(s)||s.nodeType===I.DOCUMENT_FRAGMENT_NODE||s.nodeType===I.COMMENT_NODE||s.nodeType===I.PROCESSING_INSTRUCTION_NODE)||ba(t)&&e.nodeType!==I.DOCUMENT_NODE)throw new C(ra,"Unexpected node type "+t.nodeType+" for parent node type "+e.nodeType)}function Ca(e,t,i){var s=e.childNodes||[],r=t.childNodes||[];
3807if(t.nodeType===I.DOCUMENT_FRAGMENT_NODE){var n=r.filter(Ta);if(1<n.length||Qn(r,Sa))throw new C(ra,"More than one element or text in fragment");if(1===n.length&&!wa(e,i))throw new C(ra,"Element in fragment can not be inserted before doctype")}if(Ta(t)&&!wa(e,i))throw new C(ra,"Only one element can be added and only after doctype");if(ba(t)){if(Qn(s,ba))throw new C(ra,"Only one doctype is allowed");r=Qn(s,Ta);if(i&&s.indexOf(r)<s.indexOf(i))throw new C(ra,"Doctype can only be inserted before an element");if(!i&&r)throw new C(ra,"Doctype can not be appended since element is present")}}function Ia(e,t,i){var s=e.childNodes||[],r=t.childNodes||[];if(t.nodeType===I.DOCUMENT_FRAGMENT_NODE){var n=r.filter(Ta);if(1<n.length||Qn(r,Sa))throw new C(ra,"More than one element or text in fragment");if(1===n.length&&!Ea(e,i))throw new C(ra,"Element in fragment can not be inserted before doctype")}if(Ta(t)&&!Ea(e,i))throw new C(ra,"Only one element can be added and only after doctype");if(ba(t)){if(Qn(s,function(e){return ba(e)&&e!==i}))throw new C(ra,"Only one doctype is allowed");r=Qn(s,Ta);if(i&&s.indexOf(r)<s.indexOf(i))throw new C(ra,"Doctype can only be inserted before an element")}}function xa(e,t,i,s){ka(e,t,i),e.nodeType===I.DOCUMENT_NODE&&(s||Ca)(e,t,i);s=t.parentNode;if(s&&s.removeChild(t),11===t.nodeType){var r=t.firstChild;if(null==r)return t;var n=t.lastChild}else r=n=t;s=i?i.previousSibling:e.lastChild;for(r.previousSibling=s,n.nextSibling=i,s?s.nextSibling=r:e.firstChild=r,null==i?e.lastChild=n:i.previousSibling=n;r.parentNode=e,r!==n&&(r=r.nextSibling););return _a(e.ownerDocument||e,e),11==t.nodeType&&(t.firstChild=t.lastChild=null),t}function Aa(){this._nsMap={}}function Pa(){}function La(){}function Oa(){}function Da(){}function Na(){}function Ma(){}function Ra(){}function Ua(){}function Ba(){}function Fa(){}function ja(){}function Ha(){}function qa(e,t){var i,s=[],r=9==this.nodeType&&this.documentElement||this,n=r.prefix,a=r.namespaceURI;return Wa(this,s,e,t,i=a&&null==n&&null==r.lookupPrefix(a)?[{namespace:a,prefix:null}]:i),s.join("")}function Va(e,t,i){var s=e.prefix||"",r=e.namespaceURI;if(r&&("xml"!==s||r!==Jn.XML)&&r!==Jn.XMLNS){for(var n=i.length;n--;){var a=i[n];if(a.prefix===s)return a.namespace!==r}return 1}}function $a(e,t,i){e.push(" ",t,'="',i.replace(/[<>&"\t\n\r]/g,ma),'"')}function Wa(e,t,i,s,r){if(r=r||[],s){if(!(e=s(e)))return;if("string"==typeof e)return void t.push(e)}switch(e.nodeType){case 1:var n=e.attributes,a=n.length,o=e.firstChild,l=e.tagName,d=l;if(!(i=Jn.isHTML(e.namespaceURI)||i)&&!e.prefix&&e.namespaceURI){for(var h,u=0;u<n.length;u++)if("xmlns"===n.item(u).name){h=n.item(u).value;break}if(!h)for(var c=r.length-1;0<=c;c--)if(""===(p=r[c]).prefix&&p.namespace===e.namespaceURI){h=p.namespace;break}if(h!==e.namespaceURI)for(var p,c=r.length-1;0<=c;c--)if((p=r[c]).namespace===e.namespaceURI){p.prefix&&(d=p.prefix+":"+l);break}}t.push("<",d);for(var m=0;m<a;m++)"xmlns"==(g=n.item(m)).prefix?r.push({prefix:g.localName,namespace:g.value}):"xmlns"==g.nodeName&&r.push({prefix:"",namespace:g.value});for(var g,f,y,m=0;m<a;m++)Va(g=n.item(m),0,r)&&($a(t,(f=g.prefix||"")?"xmlns:"+f:"xmlns",y=g.namespaceURI),r.push({prefix:f,namespace:y})),Wa(g,t,i,s,r);if(l===d&&Va(e,0,r)&&($a(t,(f=e.prefix||"")?"xmlns:"+f:"xmlns",y=e.namespaceURI),r.push({prefix:f,namespace:y})),o||i&&!/^(?:meta|link|img|br|hr|input)$/i.test(l)){if(t.push(">"),i&&/^script$/i.test(l))for(;o;)o.data?t.push(o.data):Wa(o,t,i,s,r.slice()),o=o.nextSibling;else for(;o;)Wa(o,t,i,s,r.slice()),o=o.nextSibling;t.push("</",d,">")}else t.push("/>");return;case 9:case 11:for(o=e.firstChild;o;)Wa(o,t,i,s,r.slice()),o=o.nextSibling;return;case 2:return $a(t,e.name,e.value);case 3:return t.push(e.data.replace(/[<&>]/g,ma));case 4:return t.push("<![CDATA[",e.data,"]]>");case 8:return t.push("\x3c!--",e.data,"--\x3e");case 10:var _=e.publicId,v=e.systemId;return t.push("<!DOCTYPE ",e.name),void(_?(t.push(" PUBLIC ",_),v&&"."!=v&&t.push(" ",v),t.push(">")):v&&"."!=v?t.push(" SYSTEM ",v,">"):((_=e.internalSubset)&&t.push(" [",_,"]"),t.push(">")));case 7:return t.push("<?",e.target," ",e.data,"?>");case 5:return t.push("&",e.nodeName,";");default:t.push("??",e.nodeName)}}function Ga(e,t,i){e[t]=i}t.INVALID_STATE_ERR=(k[11]="Invalid state",11),t.SYNTAX_ERR=(k[12]="Syntax error",12),t.INVALID_MODIFICATION_ERR=(k[13]="Invalid modification",13),t.NAMESPACE_ERR=(k[14]="Invalid namespace",14),t.INVALID_ACCESS_ERR=(k[15]="Invalid access",15),C.prototype=Error.prototype,ia(t,C),aa.prototype={length:0,item:function(e){return this[e]||null},toString:function(e,t){for(var i=[],s=0;s<this.length;s++)Wa(this[s],i,e,t);return i.join("")},filter:function(e){return Array.prototype.filter.call(this,e)},indexOf:function(e){return Array.prototype.indexOf.call(this,e)}},oa.prototype.item=function(e){return la(this),this[e]},sa(oa,aa),da.prototype={length:0,item:aa.prototype.item,getNamedItem:function(e){for(var t=this.length;t--;){var i=this[t];if(i.nodeName==e)return i}},setNamedItem:function(e){var t=e.ownerElement;if(t&&t!=this._ownerElement)throw new C(10);t=this.getNamedItem(e.nodeName);return ua(this._ownerElement,this,e,t),t},setNamedItemNS:function(e){var t=e.ownerElement;if(t&&t!=this._ownerElement)throw new C(10);return t=this.getNamedItemNS(e.namespaceURI,e.localName),ua(this._ownerElement,this,e,t),t},removeNamedItem:function(e){e=this.getNamedItem(e);return ca(this._ownerElement,this,e),e},removeNamedItemNS:function(e,t){e=this.getNamedItemNS(e,t);return ca(this._ownerElement,this,e),e},getNamedItemNS:function(e,t){for(var i=this.length;i--;){var s=this[i];if(s.localName==t&&s.namespaceURI==e)return s}return null}},pa.prototype={hasFeature:function(e,t){return!0},createDocument:function(e,t,i){var s=new fa;return s.implementation=this,s.childNodes=new aa,s.doctype=i||null,i&&s.appendChild(i),t&&(i=s.createElementNS(e,t),s.appendChild(i)),s},createDocumentType:function(e,t,i){var s=new Ma;return s.name=e,s.nodeName=e,s.publicId=t||"",s.systemId=i||"",s}},I.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,attributes:null,parentNode:null,childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,insertBefore:function(e,t){return xa(this,e,t)},replaceChild:function(e,t){xa(this,e,t,Ia),t&&this.removeChild(t)},removeChild:function(e){return va(this,e)},appendChild:function(e){return this.insertBefore(e,null)},hasChildNodes:function(){return null!=this.firstChild},cloneNode:function(e){return function e(t,i,s){var r=new i.constructor;for(var n in i){var a;Object.prototype.hasOwnProperty.call(i,n)&&"object"!=typeof(a=i[n])&&a!=r[n]&&(r[n]=a)}i.childNodes&&(r.childNodes=new aa);r.ownerDocument=t;switch(r.nodeType){case 1:var o=i.attributes,l=r.attributes=new da,d=o.length;l._ownerElement=r;for(var h=0;h<d;h++)r.setAttributeNode(e(t,o.item(h),!0));break;case 2:s=!0}
3807if(s)for(var u=i.firstChild;u;)r.appendChild(e(t,u,s)),u=u.nextSibling;return r}(this.ownerDocument||this,this,e)},normalize:function(){for(var e=this.firstChild;e;){var t=e.nextSibling;t&&3==t.nodeType&&3==e.nodeType?(this.removeChild(t),e.appendData(t.data)):(e.normalize(),e=t)}},isSupported:function(e,t){return this.ownerDocument.implementation.hasFeature(e,t)},hasAttributes:function(){return 0<this.attributes.length},lookupPrefix:function(e){for(var t=this;t;){var i=t._nsMap;if(i)for(var s in i)if(Object.prototype.hasOwnProperty.call(i,s)&&i[s]===e)return s;t=2==t.nodeType?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){for(var t=this;t;){var i=t._nsMap;if(i&&Object.prototype.hasOwnProperty.call(i,e))return i[e];t=2==t.nodeType?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){return null==this.lookupPrefix(e)}},ia(n,I),ia(n,I.prototype),fa.prototype={nodeName:"#document",nodeType:9,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(11==e.nodeType)for(var i=e.firstChild;i;){var s=i.nextSibling;this.insertBefore(i,t),i=s}else xa(this,e,t),null===(e.ownerDocument=this).documentElement&&1===e.nodeType&&(this.documentElement=e);return e},removeChild:function(e){return this.documentElement==e&&(this.documentElement=null),va(this,e)},replaceChild:function(e,t){xa(this,e,t,Ia),e.ownerDocument=this,t&&this.removeChild(t),Ta(e)&&(this.documentElement=e)},importNode:function(e,t){return function e(t,i,s){var r;switch(i.nodeType){case 1:(r=i.cloneNode(!1)).ownerDocument=t;case 11:break;case 2:s=!0}r=r||i.cloneNode(!1);r.ownerDocument=t;r.parentNode=null;if(s)for(var n=i.firstChild;n;)r.appendChild(e(t,n,s)),n=n.nextSibling;return r}(this,e,t)},getElementById:function(t){var i=null;return ga(this.documentElement,function(e){if(1==e.nodeType&&e.getAttribute("id")==t)return i=e,!0}),i},getElementsByClassName:function(a){var o=ta(a);return new oa(this,function(r){var n=[];return 0<o.length&&ga(r.documentElement,function(e){var t,i,s;e!==r&&1===e.nodeType&&(t=e.getAttribute("class"))&&((i=a===t)||(t=ta(t),i=o.every((s=t,function(e){return s&&-1!==s.indexOf(e)}))),i)&&n.push(e)}),n})},createElement:function(e){var t=new Aa;return t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.localName=e,t.childNodes=new aa,(t.attributes=new da)._ownerElement=t},createDocumentFragment:function(){var e=new Fa;return e.ownerDocument=this,e.childNodes=new aa,e},createTextNode:function(e){var t=new Oa;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new Da;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){var t=new Na;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var i=new ja;return i.ownerDocument=this,i.tagName=i.target=e,i.nodeValue=i.data=t,i},createAttribute:function(e){var t=new Pa;return t.ownerDocument=this,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){var t=new Ba;return t.ownerDocument=this,t.nodeName=e,t},createElementNS:function(e,t){var i=new Aa,s=t.split(":"),r=i.attributes=new da;return i.childNodes=new aa,i.ownerDocument=this,i.nodeName=t,i.tagName=t,i.namespaceURI=e,2==s.length?(i.prefix=s[0],i.localName=s[1]):i.localName=t,r._ownerElement=i},createAttributeNS:function(e,t){var i=new Pa,s=t.split(":");return i.ownerDocument=this,i.nodeName=t,i.name=t,i.namespaceURI=e,i.specified=!0,2==s.length?(i.prefix=s[0],i.localName=s[1]):i.localName=t,i}},sa(fa,I),fa.prototype.getElementsByTagName=(Aa.prototype={nodeType:1,hasAttribute:function(e){return null!=this.getAttributeNode(e)},getAttribute:function(e){e=this.getAttributeNode(e);return e&&e.value||""},getAttributeNode:function(e){return this.attributes.getNamedItem(e)},setAttribute:function(e,t){e=this.ownerDocument.createAttribute(e);e.value=e.nodeValue=""+t,this.setAttributeNode(e)},removeAttribute:function(e){e=this.getAttributeNode(e);e&&this.removeAttributeNode(e)},appendChild:function(e){return 11===e.nodeType?this.insertBefore(e,null):(t=this,(e=e).parentNode&&e.parentNode.removeChild(e),e.parentNode=t,e.previousSibling=t.lastChild,e.nextSibling=null,e.previousSibling?e.previousSibling.nextSibling=e:t.firstChild=e,t.last
vendor: 9,495 bytes, line 3807
3807Child=e,_a(t.ownerDocument,t,e),e);var t},setAttributeNode:function(e){return this.attributes.setNamedItem(e)},setAttributeNodeNS:function(e){return this.attributes.setNamedItemNS(e)},removeAttributeNode:function(e){return this.attributes.removeNamedItem(e.nodeName)},removeAttributeNS:function(e,t){e=this.getAttributeNodeNS(e,t);e&&this.removeAttributeNode(e)},hasAttributeNS:function(e,t){return null!=this.getAttributeNodeNS(e,t)},getAttributeNS:function(e,t){e=this.getAttributeNodeNS(e,t);return e&&e.value||""},setAttributeNS:function(e,t,i){e=this.ownerDocument.createAttributeNS(e,t);e.value=e.nodeValue=""+i,this.setAttributeNode(e)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(s){return new oa(this,function(t){var i=[];return ga(t,function(e){e===t||1!=e.nodeType||"*"!==s&&e.tagName!=s||i.push(e)}),i})},getElementsByTagNameNS:function(s,r){return new oa(this,function(t){var i=[];return ga(t,function(e){e===t||1!==e.nodeType||"*"!==s&&e.namespaceURI!==s||"*"!==r&&e.localName!=r||i.push(e)}),i})}}).getElementsByTagName,fa.prototype.getElementsByTagNameNS=Aa.prototype.getElementsByTagNameNS,sa(Aa,I),Pa.prototype.nodeType=2,sa(Pa,I),La.prototype={data:"",substringData:function(e,t){return this.data.substring(e,e+t)},appendData:function(e){e=this.data+e,this.nodeValue=this.data=e,this.length=e.length},insertData:function(e,t){this.replaceData(e,0,t)},appendChild:function(e){throw new Error(k[ra])},deleteData:function(e,t){this.replaceData(e,t,"")},replaceData:function(e,t,i){var s=this.data.substring(0,e),e=this.data.substring(e+t);this.nodeValue=this.data=i=s+i+e,this.length=i.length}},sa(La,I),Oa.prototype={nodeName:"#text",nodeType:3,splitText:function(e){var t=(i=this.data).substring(e),i=i.substring(0,e),e=(this.data=this.nodeValue=i,this.length=i.length,this.ownerDocument.createTextNode(t));return this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling),e}},sa(Oa,La),Da.prototype={nodeName:"#comment",nodeType:8},sa(Da,La),Na.prototype={nodeName:"#cdata-section",nodeType:4},sa(Na,La),Ma.prototype.nodeType=10,sa(Ma,I),Ra.prototype.nodeType=12,sa(Ra,I),Ua.prototype.nodeType=6,sa(Ua,I),Ba.prototype.nodeType=5,sa(Ba,I),Fa.prototype.nodeName="#document-fragment",Fa.prototype.nodeType=11,sa(Fa,I),ja.prototype.nodeType=7,sa(ja,I),Ha.prototype.serializeToString=function(e,t,i){return qa.call(e,t,i)},I.prototype.toString=qa;try{Object.defineProperty&&(Object.defineProperty(oa.prototype,"length",{get:function(){return la(this),this.$$length}}),Object.defineProperty(I.prototype,"textContent",{get:function(){return function e(t){switch(t.nodeType){case 1:case 11:var i=[];for(t=t.firstChild;t;)7!==t.nodeType&&8!==t.nodeType&&i.push(e(t)),t=t.nextSibling;return i.join("");default:return t.nodeValue}}(this)},set:function(e){switch(this.nodeType){case 1:case 11:for(;this.firstChild;)this.removeChild(this.firstChild);(e||String(e))&&this.appendChild(this.ownerDocument.createTextNode(e));break;default:this.data=e,this.value=e,this.nodeValue=e}}}),Ga=function(e,t,i){e["$$"+t]=i})}catch(e){}var Pr={DocumentType:Ma,DOMException:C,DOMImplementation:pa,Element:Aa,Node:I,NodeList:aa,XMLSerializer:Ha},za=Dt(function(e,t){var i=Yn.freeze;t.XML_ENTITIES=i({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'}),t.HTML_ENTITIES=i({lt:"<",gt:">",amp:"&",quot:'"',apos:"'",Agrave:"Ãâ¬",Aacute:"ÃÂ",Acirc:"Ãâ",Atilde:"ÃÆ",Auml:"Ãâ",Aring:"Ãâ¦",AElig:"Ãâ ",Ccedil:"Ãâ¡",Egrave:"ÃË",Eacute:"Ãâ°",Ecirc:"ÃÅ ",Euml:"Ãâ¹",Igrave:"ÃÅ",Iacute:"ÃÂ",Icirc:"ÃŽ",Iuml:"ÃÂ",ETH:"ÃÂ",Ntilde:"Ãâ",Ograve:"Ãâ",Oacute:"Ãâ",Ocirc:"Ãâ",Otilde:"Ãâ¢",Ouml:"Ãâ",Oslash:"ÃË",Ugrave:"Ãâ¢",Uacute:"ÃÅ¡",Ucirc:"Ãâº",Uuml:"ÃÅ",Yacute:"ÃÂ",THORN:"Þ",szlig:"ß",agrave:"à ",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"ÃÂ¥",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"ÃÂ",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",nbsp:"à ",iexcl:"á",cent:"â",pound:"ã",curren:"ä",yen:"ÃÂ¥",brvbar:"æ",sect:"ç",uml:"è",copy:"é",ordf:"ê",laquo:"ë",not:"ì",shy:"ÃÂÃÂ",reg:"î",macr:"ï",deg:"ð",plusmn:"ñ",sup2:"ò",sup3:"ó",acute:"ô",micro:"õ",para:"ö",middot:"÷",cedil:"ø",sup1:"ù",ordm:"ú",raquo:"û",frac14:"ü",frac12:"ý",frac34:"þ",iquest:"ÿ",times:"Ãâ",divide:"÷",forall:"âËâ¬",part:"âËâ",exist:"Ã¢ËÆ",empty:"âËâ¦",nabla:"âËâ¡",isin:"âËË",notin:"âËâ°",ni:"âËâ¹",prod:"âËÂ",sum:"âËâ",minus:"âËâ",lowast:"âËâ",radic:"âËÅ¡",prop:"âËÂ",infin:"âËž",ang:"Ã¢Ë ",and:"â˧",or:"â˨",cap:"âË©",cup:"â˪",int:"âË«",there4:"âË´",sim:"â˼",cong:"ââ°â¦",asymp:"ââ°Ë",ne:"âⰠ",equiv:"ââ°Â¡",le:"ââ°Â¤",ge:"ââ°Â¥",sub:"âŠâ",sup:"âŠÆ",nsub:"âŠâ",sube:"âŠâ ",supe:"âŠâ¡",oplus:"âŠâ¢",otimes:"âŠâ",perp:"⊥",sdot:"ââ¹â¦",Alpha:"Ãâ",Beta:"Ãâ",Gamma:"Ãâ",Delta:"Ãâ",Epsilon:"Ãâ¢",Zeta:"Ãâ",Eta:"Ãâ",Theta:"ÃË",Iota:"Ãâ¢",Kappa:"ÃÅ¡",Lambda:"Ãâº",Mu:"ÃÅ",Nu:"ÃÂ",Xi:"Þ",Omicron:"ß",Pi:"à ",Rho:"á",Sigma:"ã",Tau:"ä",Upsilon:"ÃÂ¥",Phi:"æ",Chi:"ç",Psi:"è",Omega:"é",alpha:"ñ",beta:"ò",gamma:"ó",delta:"ô",epsilon:"õ",zeta:"ö",eta:"÷",theta:"ø",iota:"ù",kappa:"ú",lambda:"û",mu:"ü",nu:"ý",xi:"þ",omicron:"ÿ",pi:"Ãâ¬",rho:"ÃÂ",sigmaf:"Ãâ",sigma:"ÃÆ",tau:"Ãâ",upsilon:"Ãâ¦",phi:"Ãâ ",chi:"Ãâ¡",psi:"ÃË",omega:"Ãâ°",thetasym:"Ãâ",upsih:"Ãâ",piv:"Ãâ",OElig:"Ã
â",oelig:"Ã
â",Scaron:"Ã
",scaron:"Ã
¡",Yuml:"Ã
¸",fnof:"Ãâ",circ:"Ãâ ",tilde:"ÃÅ",ensp:"ââ¬â",emsp:"Ã¢â¬Æ",thinsp:"ââ¬â°",zwnj:"ââ¬Å",zwj:"ââ¬Â",lrm:"ââ¬Å½",rlm:"ââ¬Â",ndash:"ââ¬â",mdash:"ââ¬â",lsquo:"ââ¬Ë",rsquo:"ââ¬â¢",sbquo:"ââ¬Å¡",ldquo:"ââ¬Å",rdquo:"ââ¬Â",bdquo:"ââ¬Å¾",dagger:"â⬠",Dagger:"ââ¬Â¡",bull:"ââ¬Â¢",hellip:"ââ¬Â¦",permil:"ââ¬Â°",prime:"ââ¬Â²",Prime:"ââ¬Â³",lsaquo:"ââ¬Â¹",rsaquo:"ââ¬Âº",oline:"ââ¬Â¾",euro:"ââ¬",trade:"ââ¢",larr:"ââ Â",uarr:"ââ â",rarr:"ââ â",darr:"ââ â",harr:"ââ â",crarr:"ââ µ",lceil:"âÅË",rceil:"âÅâ°",lfloor:"âÅÅ ",rfloor:"âÅâ¹",loz:"ââÅ ",spades:"â⢠",clubs:"ââ¢Â£",hearts:"ââ¢Â¥",diams:"ââ¢Â¦"}),t.entityMap=t.HTML_ENTITIES}),Xa=(za.XML_ENTITIES,za.HTML_ENTITIES,za.entityMap,Yn.NAMESPACE),Rr=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,Mr=new RegExp("[\\-\\.0-9"+Rr.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),Ka=new RegExp("^"+Rr.source+Mr.source+"*(?::"+Rr.source+Mr.source+"*)?$"),Ya=0,Qa=1,Ja=2,Za=3,eo=4,to=5,io=6,so=7;function ro(e,t){this.message=e,this.locator=t,Error.captureStackTrace&&Error.captureStackTrace(this,ro)}function no(){}function ao(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function oo(e,t,i){for(var s=e.tagName,r=null,n=e.length;n--;){var a=e[n],o=a.qName,l=a.value,o=0<(h=o.indexOf(":"))?(d=a.prefix=o.slice(0,h),u=o.slice(h+1),"xmlns"===d&&u):(d=null,"xmlns"===(u=o)&&"");a.localName=u,!1!==o&&(null==r&&(r={},lo(i,i={})),i[o]=r[o]=l,a.uri=Xa.XMLNS,t.startPrefixMapping(o,l))}for(var d,n=e.length;n--;)(d=(a=e[n]).prefix)&&("xml"===d&&(a.uri=Xa.XML),"xmlns"!==d)&&(a.uri=i[d||""]);var h,u=0<(h=s.indexOf(":"))?(d=e.prefix=s.slice(0,h),e.localName=s.slice(h+1)):(d=null,e.localName=s),c=e.uri=i[d||""];if(t.startElement(c,u,s,e),!e.closed)return e.currentNSMap=i,e.localNSMap=r,1;if(t.endElement(c,u,s),r)for(d in r)Object.prototype.hasOwnProperty.call(r,d)&&t.endPrefixMapping(d)}function lo(e,t){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}function ho(){this.attributeNames={}}(ro.prototype=new Error).name=ro.name,no.prototype={parse:function(e,t,i){var s=this.domBuilder;s.startDocument(),lo(t,t={}),function(i,e,s,r,n){function a(e){var t=e.slice(1,-1);return Object.hasOwnProperty.call(s,t)?s[t]:"#"===t.charAt(0)?65535<(t=parseInt(t.substr(1).replace("x","0x")))?(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t))):String.fromCharCode(t):(n.error("entity not found:"+e),e)}function t(e){var t;m<e&&(t=i.substring(m,e).replace(/&#?\w+;/g,a),u&&o(m),r.characters(t,0,e-m),m=e)}function o(e,t){for(;d<=e&&(t=h.exec(i));)l=t.index,d=l+t[0].length,u.lineNumber++;u.columnNumber=e-l+1}var l=0,d=0,h=/.*(?:\r\n?|\n)|.*$/g,u=r.locator,c=[{currentNSMap:e}],p={},m=0;for(;;){try{var g,f,y=i.indexOf("<",m);if(y<0)return i.substr(m).match(/^\s*$/)||(g=r.doc,f=g.createTextNode(i.substr(m)),g.appendChild(f),r.currentElement=f);switch(m<y&&t(y),i.charAt(y+1)){case"/":var _=i.indexOf(">",y+3),v=i.substring(y+2,_).replace(/[ \t\n\r]+$/g,""),b=c.pop(),T=(_<0?(v=i.substring(y+2).replace(/[\s<].*/,""),n.error("end tag name: "+v+" is not complete:"+b.tagName),_=y+1+v.length):v.match(/\s</)&&(v=v.replace(/[\s<].*/,""),n.error("end tag name: "+v+" maybe not complete"),_=y+1+v.length),b.localNSMap),S=b.tagName==v;if(S||b.tagName&&b.tagName.toLowerCase()==v.toLowerCase()){if(r.endElement(b.uri,b.localName,v),T)for(var w in T)Object.prototype.hasOwnProperty.call(T,w
vendor: 13,164 bytes, lines 3807-3809
3807)&&r.endPrefixMapping(w);S||n.fatalError("end tag name: "+v+" is not match the current start tagName:"+b.tagName)}else c.push(b);_++;break;case"?":u&&o(y),_=function(e,t,i){var s=e.indexOf("?>",t);if(s){e=e.substring(t,s).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);if(e)return e[0].length,i.processingInstruction(e[1],e[2]),s+2}return-1}(i,y,r);break;case"!":u&&o(y),_=function(e,t,i,s){{if("-"===e.charAt(t+2))return"-"===e.charAt(t+3)?(n=e.indexOf("--\x3e",t+4),t<n?(i.comment(e,t+4,n-t-4),n+3):(s.error("Unclosed comment"),-1)):-1;if("CDATA["==e.substr(t+3,6))return n=e.indexOf("]]>",t+9),i.startCDATA(),i.characters(e,t+9,n-t-9),i.endCDATA(),n+3;var r,s=function(e,t){var i,s=[],r=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;r.lastIndex=t,r.exec(e);for(;i=r.exec(e);)if(s.push(i),i[1])return s}(e,t),n=s.length;if(1<n&&/!doctype/i.test(s[0][0]))return e=s[1][0],r=t=!1,3<n&&(/^public$/i.test(s[2][0])?(t=s[3][0],r=4<n&&s[4][0]):/^system$/i.test(s[2][0])&&(r=s[3][0])),s=s[n-1],i.startDTD(e,t,r),i.endDTD(),s.index+s[0].length}return-1}(i,y,r,n);break;default:u&&o(y);var E=new ho,k=c[c.length-1].currentNSMap,_=function(e,t,s,i,r,n){function a(e,t,i){s.attributeNames.hasOwnProperty(e)&&n.fatalError("Attribute "+e+" redefined"),s.addValue(e,t.replace(/[\t\n\r]/g," ").replace(/&#?\w+;/g,r),i)}var o,l=++t,d=Ya;for(;;){var h=e.charAt(l);switch(h){case"=":if(d===Qa)o=e.slice(t,l);else if(d!==Ja)throw new Error("attribute equal must after attrName");d=Za;break;case"'":case'"':if(d===Za||d===Qa){if(d===Qa&&(n.warning('attribute value must after "="'),o=e.slice(t,l)),t=l+1,!(0<(l=e.indexOf(h,t))))throw new Error("attribute value no end '"+h+"' match");u=e.slice(t,l),a(o,u,t-1)}else{if(d!=eo)throw new Error('attribute value must after "="');u=e.slice(t,l),a(o,u,t),n.warning('attribute "'+o+'" missed start quot('+h+")!!"),t=l+1}d=to;break;case"/":switch(d){case Ya:s.setTagName(e.slice(t,l));case to:case io:case so:d=so,s.closed=!0;case eo:case Qa:case Ja:break;default:throw new Error("attribute invalid close char('/')")}break;case"":return n.error("unexpected end of input"),d==Ya&&s.setTagName(e.slice(t,l)),l;case">":switch(d){case Ya:s.setTagName(e.slice(t,l));case to:case io:case so:break;case eo:case Qa:"/"===(u=e.slice(t,l)).slice(-1)&&(s.closed=!0,u=u.slice(0,-1));case Ja:d===Ja&&(u=o),d==eo?(n.warning('attribute "'+u+'" missed quot(")!'),a(o,u,t)):(Xa.isHTML(i[""])&&u.match(/^(?:disabled|checked|selected)$/i)||n.warning('attribute "'+u+'" missed value!! "'+u+'" instead!!'),a(u,u,t));break;case Za:throw new Error("attribute value missed!!")}return l;case"Ãâ¬":h=" ";default:if(h<=" ")switch(d){case Ya:s.setTagName(e.slice(t,l)),d=io;break;case Qa:o=e.slice(t,l),d=Ja;break;case eo:var u=e.slice(t,l);n.warning('attribute "'+u+'" missed quot(")!!'),a(o,u,t);case to:d=io}else switch(d){case Ja:s.tagName,Xa.isHTML(i[""])&&o.match(/^(?:disabled|checked|selected)$/i)||n.warning('attribute "'+o+'" missed value!! "'+o+'" instead2!!'),a(o,o,t),t=l,d=Qa;break;case to:n.warning('attribute space is required"'+o+'"!!');case io:d=Qa,t=l;break;case Za:d=eo,t=l;break;case so:throw new Error("elements closed character '/' and '>' must be connected to")}}l++}}(i,y,E,k,a,n),C=E.length;if(!E.closed&&function(e,t,i,s){var r=s[i];null==r&&((r=e.lastIndexOf("</"+i+">"))<t&&(r=e.lastIndexOf("</"+i)),s[i]=r);return r<t}(i,_,E.tagName,p)&&(E.closed=!0,s.nbsp||n.warning("unclosed xml attribute")),u&&C){for(var I=ao(u,{}),x=0;x<C;x++){var A=E[x];o(A.offset),A.locator=ao(u,{})}r.locator=I,oo(E,r,k)&&c.push(E),r.locator=u}else oo(E,r,k)&&c.push(E);Xa.isHTML(E.uri)&&!E.closed?_=function(e,t,i,s,r){if(/^(?:script|textarea)$/i.test(i)){var n=e.indexOf("</"+i+">",t),e=e.substring(t+1,n);if(/[&<]/.test(e))return/^script$/i.test(i)?r.characters(e,0,e.length):(e=e.replace(/&#?\w+;/g,s),r.characters(e,0,e.length)),n}return t+1}(i,_,E.tagName,a,r):_++}}catch(e){if(e instanceof ro)throw e;n.error("element parse error: "+e),_=-1}m<_?m=_:t(Math.max(y,m)+1)}}(e,t,i,s,this.errorHandler),s.endDocument()}},ho.prototype={setTagName:function(e){if(!Ka.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},addValue:function(e,t,i){if(!Ka.test(e))throw new Error("invalid attribute:"+e);this.attributeNames[e]=this.length,this[this.length++]={qName:e,value:t,offset:i}},length:0,getLocalName:function(e){return this[e].localName},getLocator:function(e){return this[e].locator},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}};var Nr={XMLReader:no,ParseError:ro},uo=Pr.DOMImplementation,co=Yn.NAMESPACE,po=Nr.ParseError,mo=Nr.XMLReader;function go(e){return e.replace(/\r[\n\u0085]/g,"\n").replace(/[\r\u0085\u2028]/g,"\n")}function fo(e){this.options=e||{locator:{}}}function yo(){this.cdata=!1}function _o(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}function vo(e){if(e)return"\n@"+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function bo(e,t,i){return"string"==typeof e?e.substr(t,i):e.length>=t+i||t?new java.lang.String(e,t,i)+"":e}function To(e,t){(e.currentElement||e.doc).appendChild(t)}fo.prototype.parseFromString=function(e,t){var i=this.options,s=new mo,r=i.domBuilder||new yo,n=i.errorHandler,a=i.locator,o=i.xmlns||{},t=/\/x?html?$/.test(t),l=t?za.HTML_ENTITIES:za.XML_ENTITIES,n=(a&&r.setDocumentLocator(a),s.errorHandler=function(s,e,r){if(!s){if(e instanceof yo)return e;s=e}var n={},a=s instanceof Function;function t(t){var i=s[t];!i&&a&&(i=2==s.length?function(e){s(t,e)}:s),n[t]=i?function(e){i("[xmldom "+t+"]\t"+e+vo(r))}:function(){}}return r=r||{},t("warning"),t("error"),t("fatalError"),n}(n,r,a),s.domBuilder=i.domBuilder||r,t&&(o[""]=co.HTML),o.xml=o.xml||co.XML,i.normalizeLineEndings||go);return e&&"string"==typeof e?s.parse(n(e),o,l):s.errorHandler.error("invalid doc source"),r.doc},yo.prototype={startDocument:function(){this.doc=(new uo).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,i,s){var r=this.doc,n=r.createElementNS(e,i||t),a=s.length;To(this,n),this.currentElement=n,this.locator&&_o(this.locator,n);for(var o=0;o<a;o++){var e=s.getURI(o),l=s.getValue(o),i=s.getQName(o),d=r.createAttributeNS(e,i);this.locator&&_o(s.getLocator(o),d),d.value=d.nodeValue=l,n.setAttributeNode(d)}},endElement:function(e,t,i){var s=this.currentElement;s.tagName,this.currentElement=s.parentNode},startPrefixMapping:function(e,t){},endPrefixMapping:function(e){},processingInstruction:function(e,t){e=this.doc.createProcessingInstruction(e,t);this.locator&&_o(this.locator,e),To(this,e)},ignorableWhitespace:function(e,t,i){},characters:function(e,t,i){var s;(e=bo.apply(this,arguments))&&(s=this.cdata?this.doc.createCDATASection(e):this.doc.createTextNode(e),this.currentElement?this.currentElement.appendChild(s):/^\s*$/.test(e)&&this.doc.appendChild(s),this.locator)&&_o(this.locator,s)},skippedEntity:function(e){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(e){(this.locator=e)&&(e.lineNumber=0)},comment:function(e,t,i){e=bo.apply(this,arguments);e=this.doc.createComment(e);this.locator&&_o(this.locator,e),To(this,e)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(e,t,i){var s=this.doc.implementation;s&&s.createDocumentType&&(s=s.createDocumentType(e,t,i),this.locator&&_o(this.locator,s),To(this,s),this.doc.doctype=s)},warning:function(e){},error:function(e){},fatalError:function(e){throw new po(e,this.locator)}},"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(e){yo.prototype[e]=function(){return null}});var So={__DOMHandler:yo,normalizeLineEndings:go,DOMParser:fo}.DOMParser; 3808/*! @name mpd-parser @version 1.0.1 @license Apache-2.0 */ 3809const wo=e=>!!e&&"object"==typeof e,x=(...e)=>e.reduce((t,i)=>("object"==typeof i&&Object.keys(i).forEach(e=>{Array.isArray(t[e])&&Array.isArray(i[e])?t[e]=t[e].concat(i[e]):wo(t[e])&&wo(i[e])?t[e]=x(t[e],i[e]):t[e]=i[e]}),t),{}),Eo=t=>Object.keys(t).map(e=>t[e]),ko=e=>e.reduce((e,t)=>e.concat(t),[]),Co=t=>{if(!t.length)return[];var i=[];for(let e=0;e<t.length;e++)i.push(t[e]);return i};var Io={INVALID_NUMBER_OF_PERIOD:"INVALID_NUMBER_OF_PERIOD",DASH_EMPTY_MANIFEST:"DASH_EMPTY_MANIFEST",DASH_INVALID_XML:"DASH_INVALID_XML",NO_BASE_URL:"NO_BASE_URL",MISSING_SEGMENT_INFORMATION:"MISSING_SEGMENT_INFORMATION",SEGMENT_TIME_UNSPECIFIED:"SEGMENT_TIME_UNSPECIFIED",UNSUPPORTED_UTC_TIMING_SCHEME:"UNSUPPORTED_UTC_TIMING_SCHEME"};const xo=({baseUrl:s="",source:r="",range:n="",indexRange:a=""})=>{s={uri:r,resolvedUri:On(s||"",r)};if(n||a){r=(n||a).split("-");let e=window.BigInt?window.BigInt(r[0]):parseInt(r[0],10),t=window.BigInt?window.BigInt(r[1]):parseInt(r[1],10);e<Number.MAX_SAFE_INTEGER&&"bigint"==typeof e&&(e=Number(e)),t<Number.MAX_SAFE_INTEGER&&"bigint"==typeof t&&(t=Number(t));let i;"bigint"==typeof(i="bigint"==typeof t||"bigint"==typeof e?window.BigInt(t)-window.BigInt(e)+window.BigInt(1):t-e+1)&&i<Number.MAX_SAFE_INTEGER&&(i=Number(i)),s.byterange={length:i,offset:e}}return s},Ao=e=>(e&&"number"!=typeof e&&(e=parseInt(e,10)),isNaN(e)?null:e),Po={static(e){var{duration:t,timescale:i=1,sourceDuration:s,periodDuration:r}=e,e=Ao(e.endNumber),t=t/i;return"number"==typeof e?{start:0,end:e}:"number"==typeof r?{start:0,end:r/t}:{start:0,end:s/t}},dynamic(e){var{NOW:t,clientOffset:i,availabilityStartTime:s,timescale:r=1,duration:n,periodStart:a=0,minimumUpdatePeriod:o=0,timeShiftBufferDepth:l=1/0}=e,e=Ao(e.endNumber),t=(t+i)/1e3,i=s+a,s=Math.ceil((t+o-i)*r/n),a=Math.floor((t-i-l)*r/n),o=Math.floor((t-i)*r/n);return{start:Math.max(0,a),end:"number"==typeof e?e:Math.min(s,o)}}},Lo=e=>{var n,{type:t,duration:i,timescale:s=1,periodDuration:r,sourceDuration:a}=e,{start:o,end:l}=Po[t](e),o=((t,i)=>{var s=[];for(let e=t;e<i;e++)s.push(e);return s})(o,l).map((n=e,e=>{var{duration:t,timescale:i=1,periodStart:s,startNumber:r=1}=n;return{number:r+e,duration:t/i,timeline:s,time:e*t}}));return"static"===t&&(o[l=o.length-1].duration=("number"==typeof r?r:a)-i/s*l),o},Oo=e=>{var{baseUrl:t,initialization:i={},sourceDuration:s,indexRange:r="",periodStart:n,presentationTime:a,number:o=0,duration:l}=e;if(t)return i=xo({baseUrl:t,source:i.sourceURL,range:i.range}),(t=xo({baseUrl:t,source:t,indexRange:r})).map=i,l?(r=Lo(e)).length&&(t.duration=r[0].duration,t.timeline=r[0].timeline):s&&(t.duration=s,t.timeline=n),t.presentationTime=a||n,t.number=o,[t];throw new Error(Io.NO_BASE_URL)},Do=(e,i,s)=>{var r=e.sidx.map||null,n=e.sidx.duration,a=e.timeline||0,t=e.sidx.byterange,t=t.offset+t.length,o=i.timescale,l=i.references.filter(e=>1!==e.referenceType),d=[],h=e.endList?"static":"dynamic",u=e.sidx.timeline;let c=u,p=e.mediaSequence||0,m;m="bigint"==typeof i.firstOffset?window.BigInt(t)+i.firstOffset:t+i.firstOffset;for(let t=0;t<l.length;t++){var g=i.references[t],f=g.referencedSize,g=g.subsegmentDuration;let e;e="bigint"==typeof m?m+window.BigInt(f)-window.BigInt(1):m+f-1;var y=m+"-"+e,y={baseUrl:s,timescale:o,timeline:a,periodStart:u,presentationTime:c,number:p,duration:g,sourceDuration:n,indexRange:y,type:h},y=Oo(y)[0];r&&(y.map=r),d.push(y),"bigint"==typeof m?m+=window.BigInt(f):m+=f,c+=g/o,p++}return e.segments=d,e},No=["AUDIO","SUBTITLES"],Mo=e=>{return e=e,i=({timeline:e})=>e,Eo(e.reduce((t,e)=>(e.forEach(e=>{t[i(e)]=e}),t),{})).sort((e,t)=>e.timeline>t.timeline?1:-1);var i},Ro=e=>{let r=[];var n,a;return n=e,e=No,a=(e,t,i,s)=>{r=r.concat(e.playlists||[])},e.forEach(function(e){for(var t in n.mediaGroups[e])for(var i in n.mediaGroups[e][t]){var s=n.mediaGroups[e][t][i];a(s,e,t,i)}}),r},Uo=({playlist:i,mediaSequence:e})=>{i.mediaSequence=e,i.segments.forEach((e,t)=>{e.number=i.mediaSequence+t})},Bo=({oldManifest:e,newManifest:t})=>{var r,n,i=e.playlists.concat(Ro(e)),s=t.playlists.concat(Ro(t));return t.timelineStarts=Mo([e.timelineStarts,t.timelineStarts]),{oldPlaylists:r,newPlaylists:e,timelineStarts:n}=[{oldPlaylists:i,newPlaylists:s,timelineStarts:t.timelineStarts}][0],e.forEach(t=>{t.discontinuitySequence=n.findIndex(function({timeline:e}){return e===t.timeline});var e=((t,i)=>{for(let e=0;e<t.length;e++)if(t[e].attributes.NAME===i)return t[e];return null})(r,t.attributes.NAME);if(e&&!t.sidx){const s=t.segments[0];var i=e.segments.findIndex(function(e){return Math.abs(e.presentationTime-s.presentationTime)<1/60});-1===i?(Uo({playlist:t,mediaSequence:e.mediaSequence+e.segments.length}),t.segments[0].discontinuity=!0,t.discontinuityStarts.unshift(0),(!e.segments.length&&t.timeline>e.timeline||e.segments.length&&t.timeline>e.segments[e.segments.length-1].timeline)&&t.discontinuitySequence--):(e.segments[i].discontinuity&&!s.discontinuity&&(s.discontinuity=!0,t.discontinuityStarts.unshift(0),t.discontinuitySequence--),Uo({playlist:t,mediaSequence:e.segments[i].number}))}}),t},Fo=e=>e&&e.uri+"-"+(e=>{let t;return t="bigint"==typeof e.offset||"bigint"==typeof e.length?window.BigInt(e.offset)+window.BigInt(e.length)-window.BigInt(1):e.offset+e.length-1,e.offset+"-"+t})(e.byterange),jo=e=>{return Eo(e.reduce((e,t)=>
3809{var i=t.attributes.id+(t.attributes.lang||"");return e[i]?(t.segments&&(t.segments[0]&&(t.segments[0].discontinuity=!0),e[i].segments.push(...t.segments)),t.attributes.contentProtection&&(e[i].attributes.contentProtection=t.attributes.contentProtection)):(e[i]=t,e[i].attributes.timelineStarts=[]),e[i].attributes.timelineStarts.push({start:t.attributes.periodStart,timeline:t.attributes.periodStart}),e},{})).map(e=>{var t,s;return e.discontinuityStarts=(t=e.segments||[],s="discontinuity",t.reduce((e,t,i)=>(t[s]&&e.push(i),e),[])),e})},Ho=(e,t)=>{var i=Fo(e.sidx),t=i&&t[i]&&t[i].sidx;return t&&Do(e,t,e.sidx.resolvedUri),e},qo=(e,o={})=>e.reduce((e,t)=>{var i,s,r,n,a=t.attributes.lang||"text";return e[a]||(e[a]={language:a,default:!1,autoselect:!1,playlists:[],uri:""}),e[a].playlists.push(Ho(({attributes:a,segments:t,mediaSequence:i,discontinuityStarts:s,discontinuitySequence:r}=[t][0],"undefined"==typeof t&&(t=[{uri:a.baseUrl,timeline:a.periodStart,resolvedUri:a.baseUrl||"",duration:a.sourceDuration,number:0}],a.duration=a.sourceDuration),n={NAME:a.id,BANDWIDTH:a.bandwidth,"PROGRAM-ID":1},a.codecs&&(n.CODECS=a.codecs),{attributes:n,uri:"",endList:"static"===a.type,timeline:a.periodStart,resolvedUri:a.baseUrl||"",targetDuration:a.duration,timelineStarts:a.timelineStarts,discontinuityStarts:s,discontinuitySequence:r,mediaSequence:i,segments:t}),o)),e},{}),Vo=({attributes:e,segments:t,sidx:i,discontinuityStarts:s})=>{s={attributes:{NAME:e.id,AUDIO:"audio",SUBTITLES:"subs",RESOLUTION:{width:e.width,height:e.height},CODECS:e.codecs,BANDWIDTH:e.bandwidth,"PROGRAM-ID":1},uri:"",endList:"static"===e.type,timeline:e.periodStart,resolvedUri:"",targetDuration:e.duration,discontinuityStarts:s,timelineStarts:e.timelineStarts,segments:t};return e.frameRate&&(s.attributes["FRAME-RATE"]=e.frameRate),e.contentProtection&&(s.contentProtection=e.contentProtection),i&&(s.sidx=i),s},$o=({attributes:e})=>"video/mp4"===e.mimeType||"video/webm"===e.mimeType||"video"===e.contentType,Wo=({attributes:e})=>"audio/mp4"===e.mimeType||"audio/webm"===e.mimeType||"audio"===e.contentType,Go=({attributes:e})=>"text/vtt"===e.mimeType||"text"===e.contentType,zo=i=>i?Object.keys(i).reduce((e,t)=>{t=i[t];return e.concat(t.playlists)},[]):[],Xo=({dashPlaylists:e,locations:t,sidxMapping:i={},previousManifest:s})=>{var r,n,a,o,l,d,h,u;return e.length?({sourceDuration:a,type:l,suggestedPresentationDelay:d,minimumUpdatePeriod:o}=e[0].attributes,r=jo(e.filter($o)).map(Vo),h=jo(e.filter(Wo)),n=jo(e.filter(Go)),e=e.map(e=>e.attributes.captionServices).filter(Boolean),a={allowCache:!0,discontinuityStarts:[],segments:[],endList:!0,mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:"",duration:a,playlists:((e,t={})=>{if(Object.keys(t).length)for(const i in e)e[i]=Ho(e[i],t);return e})(r,i)},0<=o&&(a.minimumUpdatePeriod=1e3*o),t&&(a.locations=t),"dynamic"===l&&(a.suggestedPresentationDelay=d),o=0===a.playlists.length,t=h.length?((e,n={},a)=>{let o;e=e.reduce((e,t)=>{var i=t.attributes.role&&t.attributes.role.value||"",s=t.attributes.lang||"";let r=t.attributes.label||"main";e[r=s&&!t.attributes.label?t.attributes.lang+(i?` (${i})`:""):r]||(e[r]={language:s,autoselect:!0,default:"main"===i,playlists:[],uri:""});s=Ho((({attributes:e,segments:t,sidx:i,mediaSequence:s,discontinuitySequence:r,discontinuityStarts:n},a)=>{r={attributes:{NAME:e.id,BANDWIDTH:e.bandwidth,CODECS:e.codecs,"PROGRAM-ID":1},uri:"",endList:"static"===e.type,timeline:e.periodStart,resolvedUri:"",targetDuration:e.duration,discontinuitySequence:r,discontinuityStarts:n,timelineStarts:e.timelineStarts,mediaSequence:s,segments:t};return e.contentProtection&&(r.contentProtection=e.contentProtection),i&&(r.sidx=i),a&&(r.attributes.AUDIO="audio",r.attributes.SUBTITLES="subs"),r})(t,a),n);return e[r].playlists.push(s),"undefined"==typeof o&&"main"===i&&((o=t).default=!0),e},{});return o||(e[Object.keys(e)[0]].default=!0),e})(h,i,o):null,l=n.length?qo(n,i):null,h=(d=r.concat(zo(t),zo(l))).map(({timelineStarts:e})=>e),a.timelineStarts=Mo(h),u=a.timelineStarts,d.forEach(t=>{t.mediaSequence=0,t.discontinuitySequence=u.findIndex(function({timeline:e}){return e===t.timeline}
3809),t.segments&&t.segments.forEach((e,t)=>{e.number=t})}),t&&(a.mediaGroups.AUDIO.audio=t),l&&(a.mediaGroups.SUBTITLES.subs=l),e.length&&(a.mediaGroups["CLOSED-CAPTIONS"].cc=e.reduce((s,e)=>(e&&e.forEach(e=>{var{channel:t,language:i}=e;s[i]={autoselect:!1,default:!1,instreamId:t,language:i},e.hasOwnProperty("aspectRatio")&&(s[i].aspectRatio=e.aspectRatio),e.hasOwnProperty("easyReader")&&(s[i].easyReader=e.easyReader),e.hasOwnProperty("3D")&&(s[i]["3D"]=e["3D"])}),s),{})),s?Bo({oldManifest:s,newManifest:a}):a):{}},Ko=(s,r)=>{var{type:n,minimumUpdatePeriod:a=0,media:o="",sourceDuration:l,timescale:d=1,startNumber:h=1,periodStart:u}=s,c=[];let p=-1;for(let i=0;i<r.length;i++){var m=r[i],g=m.d,f=m.r||0,m=m.t||0;p<0&&(p=m),m&&m>p&&(p=m);let e;e=f<0?(m=i+1)===r.length?"dynamic"===n&&0<a&&0<o.indexOf("$Number$")?((e,t,i)=>{var{NOW:e,clientOffset:s,availabilityStartTime:r,timescale:n=1,periodStart:a=0,minimumUpdatePeriod:o=0}=e;return Math.ceil((((e+s)/1e3+o-(r+a))*n-t)/i)})(s,p,g):(l*d-p)/g:(r[m].t-p)/g:f+1;var y=h+c.length+e;let t=h+c.length;for(;t<y;)c.push({number:t,duration:g/d,time:p,timeline:u}),p+=g,t++}return c},Yo=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,Qo=(e,t)=>{return e.replace(Yo,(r=t,(e,t,i,s)=>{return"$$"===e?"$":"undefined"==typeof r[t]?e:(e=""+r[t],"RepresentationID"===t||(s=i?parseInt(s,10):1)<=e.length?e:new Array(s-e.length+1).join("0")+e)}));var r},Jo=(r,e)=>{const n={RepresentationID:r.id,Bandwidth:r.bandwidth||0};var{initialization:t={sourceURL:"",range:""}}
vendor: 4,261 bytes, line 3809
3809=r;const a=xo({baseUrl:r.baseUrl,source:Qo(t.sourceURL,n),range:t.range});return t=e,((e=r).duration||t?e.duration?Lo(e):Ko(e,t):[{number:e.startNumber||1,duration:e.sourceDuration,time:0,timeline:e.periodStart}]).map(e=>{n.Number=e.number,n.Time=e.time;var t=Qo(r.media||"",n),i=r.timescale||1,s=r.presentationTimeOffset||0,s=r.periodStart+(e.time-s)/i;return{uri:t,timeline:e.timeline,duration:e.duration,resolvedUri:On(r.baseUrl||"",t),map:a,number:e.number,presentationTime:s}})},Zo=(r,e)=>{const{duration:t,segmentUrls:i=[],periodStart:n}=r;if(!t&&!e||t&&e)throw new Error(Io.SEGMENT_TIME_UNSPECIFIED);const a=i.map(e=>{var{baseUrl:t,initialization:i={}}=t=r,i=xo({baseUrl:t,source:i.sourceURL,range:i.range});return(t=xo({baseUrl:t,source:e.media,range:e.mediaRange})).map=i,t});let s;return t&&(s=Lo(r)),(s=e?Ko(r,e):s).map((e,t)=>{var i,s;if(a[t])return t=a[t],i=r.timescale||1,s=r.presentationTimeOffset||0,t.timeline=e.timeline,t.duration=e.duration,t.number=e.number,t.presentationTime=n+(e.time-s)/i,t}).filter(e=>e)},el=({attributes:e,segmentInfo:t})=>{let i,s;t.template?(s=Jo,i=x(e,t.template)):t.base?(s=Oo,i=x(e,t.base)):t.list&&(s=Zo,i=x(e,t.list));var r,n,a,e={attributes:e};return s&&(r=s(i,t.segmentTimeline),i.duration?({duration:n,timescale:a=1}=i,i.duration=n/a):r.length?i.duration=r.reduce((e,t)=>Math.max(e,Math.ceil(t.duration)),0):i.duration=0,e.attributes=i,e.segments=r,t.base)&&i.indexRange&&(e.sidx=r[0],e.segments=[]),e},tl=e=>e.map(el),A=(e,t)=>Co(e.childNodes).filter(({tagName:e})=>e===t),il=e=>e.textContent.trim(),sl=e=>{var t,i,s,r,n,e=/P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)D)?(?:T(?:(\d*)H)?(?:(\d*)M)?(?:([\d.]*)S)?)?/.exec(e);return e?([e,t,i,s,r,n]=e.slice(1),31536e3*parseFloat(e||0)+2592e3*parseFloat(t||0)+86400*parseFloat(i||0)+3600*parseFloat(s||0)+60*parseFloat(r||0)+parseFloat(n||0)):0},rl={mediaPresentationDuration(e){return sl(e)},availabilityStartTime(e){return/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(e=e)&&(e+="Z"),Date.parse(e)/1e3},minimumUpdatePeriod(e){return sl(e)},suggestedPresentationDelay(e){return sl(e)},type(e){return e},timeShiftBufferDepth(e){return sl(e)},start(e){return sl(e)},width(e){return parseInt(e,10)},height(e){return parseInt(e,10)},bandwidth(e){return parseInt(e,10)},frameRate(e){return parseFloat(e.split("/").reduce((e,t)=>e/t))},startNumber(e){return parseInt(e,10)},timescale(e){return parseInt(e,10)},presentationTimeOffset(e){return parseInt(e,10)},duration(e){var t=parseInt(e,10);return isNaN(t)?sl(e):t},d(e){return parseInt(e,10)},t(e){return parseInt(e,10)},r(e){return parseInt(e,10)},DEFAULT(e){return e}},P=e=>e&&e.attributes?Co(e.attributes).reduce((e,t)=>{var i=rl[t.name]||rl.DEFAULT;return e[t.name]=i(t.value),e},{}):{},nl={"urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b":"org.w3.clearkey","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":"com.widevine.alpha","urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":"com.microsoft.playready","urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb":"com.adobe.primetime"},al=(e,i)=>i.length?ko(e.map(function(t){return i.map(function(e){return On(t,il(e))})})):e,ol=e=>{var t=A(e,"SegmentTemplate")[0],i=A(e,"SegmentList")[0],s=i&&A(i,"SegmentURL").map(e=>x({tag:"SegmentURL"},P(e))),e=A(e,"SegmentBase")[0],r=i||t,r=r&&A(r,"SegmentTimeline")[0],n=i||e||t,n=n&&A(n,"Initialization")[0],t=t&&P(t);t&&n?t.initialization=n&&P(n):t&&t.initialization&&(t.initialization={sourceURL:t.initialization});const a={template:t,segmentTimeline:r&&A(r,"S").map(e=>P(e)),list:i&&x(P(i),{segmentUrls:s,initialization:P(n)}),base:e&&x(P(e),{initialization:P(n)})};return Object.keys(a).forEach(e=>{a[e]||delete a[e]}),a},ll=(l,d,h)=>e=>{var t=P(e),i=al(d,A(e,"BaseURL")),s=A(e,"Role")[0],s={role:P(s)};let r=x(l,t,s);var n,a,o,t=A(e,"Accessibility")[0],t="urn:scte:dash:cc:cea-608:2015"===(s=P(t)).schemeIdUri?("string"!=typeof s.value?[]:s.value.split(";")).map(e=>{let t,i;return i=e,/^CC\d=/.test(e)?[t,i]=e.split("="):/^CC\d$/.test(e)&&(t=e),{channel:t,language:i}}):"urn:scte:dash:cc:cea-708:2015"===s.schemeIdUri?("string"!=typeof s.value?[]:s.value.split(";")).map(e=>{const i={channel:void 0,language:void 0,aspectRatio:1,easyReader:0,"3D":0};var t,s;return/=/.test(e)?([t,s=""]=e.split("="),i.channel=t,i.language=e,s.split(",").forEach(e
3809=>{var[e,t]=e.split(":");"lang"===e?i.language=t:"er"===e?i.easyReader=Number(t):"war"===e?i.aspectRatio=Number(t):"3D"===e&&(i["3D"]=Number(t))})):i.language=e,i.channel&&(i.channel="SERVICE"+i.channel),i}):void 0,s=(t&&(r=x(r,{captionServices:t})),A(e,"Label")[0]),s=(s&&s.childNodes.length&&(t=s.childNodes[0].nodeValue.trim(),r=x(r,{label:t})),A(e,"ContentProtection").reduce((e,t)=>{var i=P(t),s=(i.schemeIdUri&&(i.schemeIdUri=i.schemeIdUri.toLowerCase()),nl[i.schemeIdUri]);return s&&(e[s]={attributes:i},i=A(t,"cenc:pssh")[0])&&(t=il(i),e[s].pssh=t&&Gn(t)),e},{})),t=(Object.keys(s).length&&(r=x(r,{contentProtection:s})),ol(e)),s=A(e,"Representation"),e=x(h,t);return ko(s.map((n=r,a=i,o=e,e=>{var t=A(e,"BaseURL"),t=al(a,t);const i=x(n,P(e)),s=ol(e);return t.map(e=>({segmentInfo:x(o,s),attributes:x(i,{baseUrl:e})}))})))},dl=(e,t={})=>{var{manifestUri:t="",NOW:i=Date.now(),clientOffset:s=0}=t,r=A(e,"Period");if(!r.length)throw new Error(Io.INVALID_NUMBER_OF_PERIOD);var n=A(e,"Location");const a=P(e);var o,l,t=al([t],A(e,"BaseURL"));a.type=a.type||"static",a.sourceDuration=a.mediaPresentationDuration||0,a.NOW=i,a.clientOffset=s,n.length&&(a.locations=n.map(il));const d=[];return r.forEach((e,t)=>{var i,s,r=P(e),t=d[t-1];r.start=({attributes:t,priorPeriodAttributes:i,mpdType:s}=[{attributes:r,priorPeriodAttributes:t?t.attributes:null,mpdType:a.type}][0],"number"==typeof t.start?t.start:i&&"number"==typeof i.start&&"number"==typeof i.duration?i.start+i.duration:i||"static"!==s?null:0),d.push({node:e,attributes:r})}),{locations:a.locations,representationInfo:ko(d.map((o=a,l=t,(e,t)=>{var i=al(l,A(e.node,"BaseURL")),s=x(o,{periodStart:e.attributes.start}),r=("number"==typeof e.attributes.duration&&(s.periodDuration=e.attributes.duration),A(e.node,"AdaptationSet")),e=ol(e.node);return ko(r.map(ll(s,i,e)))})))}},hl=e=>{if(""===e)throw new Error(Io.DASH_EMPTY_MANIFEST);var t,i=new So;let s;try{t=i.parseFromString(e,"application/xml"),s=t&&"MPD"===t.documentElement.tagName?t.documentElement:null}catch(e){}if(!s||s&&0<s.getElementsByTagName("parsererror").length)throw new Error(Io.DASH_INVALID_XML);return s},ul=e=>{e=hl(e);if(!(e=A(e,"UTCTiming")[0]))return null;var t=P(e);switch(t.schemeIdUri){case"urn:mpeg:dash:utc:http-head:2014":case"urn:mpeg:dash:utc:http-head:2012":t.method="HEAD";break;case"urn:mpeg:dash:utc:http-xsdate:2014":case"urn:mpeg:dash:utc:http-iso:2014":case"urn:mpeg:dash:utc:http-xsdate:2012":case"urn:mpeg:dash:utc:http-iso:2012":t.method="GET";break;case"urn:mpeg:dash:utc:direct:2014":case"urn:mpeg:dash:utc:direct:2012":t.method="DIRECT",t.value=Date.parse(t.value);break;default:throw new Error(Io.UNSUPPORTED_UTC_TIMING_SCHEME)}return t};function cl(e,t){var i,s,r;return void 0===t&&(t=0),(e=S(e)).length-t<10||!E(e,Sl,{offset:t})?t:(t+=(void 0===(s=t)&&(s=0),r=(i=S(i=e))[s+5],i=i[s+6]<<21|i[s+7]<<14|i[s+8]<<7|i[s+9],(16&r)>>4?20+i:10+i),cl(e,t))}function pl(e){return"string"==typeof e?Ln(e):e}function ml(e,t,i){void 0===i&&(i=!1),s=t,t=Array.isArray(s)?s.map(pl):[pl(s)],e=S(e);var s,r=[];if(t.length)for(var n=0;n<e.length;){var a=(e[n]<<24|e[n+1]<<16|e[n+2]<<8|e[n+3])>>>0,o=e.subarray(n+4,n+8);if(0==a)break;a=n+a;if(a>e.length){if(i)break;a=e.length}var l=e.subarray(n+8,a);E(o,t[0])&&(1===t.length?r.push(l):r.push.apply(r,ml(l,t.slice(1),i))),n=a}return r}function gl(e,t,i){var s;return i>=t.length?t.length:(s=Cl(t,i,!1),E(e.bytes,s.bytes)?i:gl(e,t,i+(e=Cl(t,i+s.length)).length+e.value+s.length))}function fl(e,t){i=t,t=Array.isArray(i)?i.map(function(e){return Il(e)}):[Il(i)],e=S(e);var i,s=[];if(t.length)for(var r=0;r<e.length;){var n=Cl(e,r,!1),a=Cl(e,r+n.length),o=r+n.length+a.length,l=(127===a.value&&(a.value=gl(n,e,o),a.value!==e.length)&&(a.value-=o),o+a.value>e.length?e.length:o+a.value),o=e.subarray(o,l);E(t[0],n.bytes)&&(1===t.length?s.push(o):s=s.concat(fl(o,t.slice(1)))),r+=n.length+a.length+o.length}return s}function yl(e,t,i,s){void 0===s&&(s=1/0),e=S(e),i=[].concat(i);for(var r,n=0,a=0;n<e.length&&(a<s||r);){var o=void 0;if(E(e.subarray(n),xl)?o=4:E(e.subarray(n),Al)&&(o=3),o){if(a++,r)return Ll(e.subarray(r,n));var l=void 0;"h264"===t?l=31&e[n+o]:"h265"===t&&(l=e[n+o]>>1&63),-1!==i.indexOf(l)&&(r=n+o),n+=o+("h264"===t?1:2)}else n++}return e.subarray(0,0)}function _l(e){e=S(e);for(var t=0;t<Dl.length;t++){var i=Dl[t];if(Nl[i](e))return i}return""}var vl=Math.pow(2,32),bl=function(e){var t,e=new DataView(e.buffer,e.byteOffset,e.byteLength);return e.getBigUint64?(t=e.getBigUint64(0))<Number.MAX_SAFE_INTEGER?
vendor: 14,629 bytes, lines 3809-3811
3809Number(t):t:e.getUint32(0)*vl+e.getUint32(4)},Tl=function(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength),i={version:e[0],flags:new Uint8Array(e.subarray(1,4)),references:[],referenceId:t.getUint32(4),timescale:t.getUint32(8)},s=12,r=(0===i.version?(i.earliestPresentationTime=t.getUint32(s),i.firstOffset=t.getUint32(s+4),s+=8):(i.earliestPresentationTime=bl(e.subarray(s)),i.firstOffset=bl(e.subarray(s+8)),s+=16),t.getUint16(s+=2));for(s+=2;0<r;s+=12,r--)i.references.push({referenceType:(128&e[s])>>>7,referencedSize:2147483647&t.getUint32(s),subsegmentDuration:t.getUint32(s+4),startsWithSap:!!(128&e[s+8]),sapType:(112&e[s+8])>>>4,sapDeltaTime:268435455&t.getUint32(s+8)});return i},Sl=S([73,68,51]),wl={EBML:S([26,69,223,163]),DocType:S([66,130]),Segment:S([24,83,128,103]),SegmentInfo:S([21,73,169,102]),Tracks:S([22,84,174,107]),Track:S([174]),TrackNumber:S([215]),DefaultDuration:S([35,227,131]),TrackEntry:S([174]),TrackType:S([131]),FlagDefault:S([136]),CodecID:S([134]),CodecPrivate:S([99,162]),VideoTrack:S([224]),AudioTrack:S([225]),Cluster:S([31,67,182,117]),Timestamp:S([231]),TimestampScale:S([42,215,177]),BlockGroup:S([160]),BlockDuration:S([155]),Block:S([161]),SimpleBlock:S([163])},El=[128,64,32,16,8,4,2,1],kl=function(e){for(var t=1,i=0;i<El.length&&!(e&El[i]);i++)t++;return t},Cl=function(e,t,i,s){void 0===i&&(i=!0),void 0===s&&(s=!1);var r=kl(e[t]),n=e.subarray(t,t+r);return i&&((n=Array.prototype.slice.call(e,t,t+r))[0]^=El[r-1]),{length:r,value:$n(n,{signed:s}),bytes:n}},Il=function e(t){return"string"==typeof t?t.match(/.{1,2}/g).map(e):"number"==typeof t?Pn(t):t},xl=S([0,0,0,1]),Al=S([0,0,1]),Pl=S([0,0,3]),Ll=function(e){for(var t=[],i=1;i<e.length-2;)E(e.subarray(i,i+3),Pl)&&(t.push(i+2),i++),i++;if(0===t.length)return e;for(var s=e.length-t.length,r=new Uint8Array(s),n=0,i=0;i<s;n++,i++)n===t[0]&&(n++,t.shift()),r[i]=e[n];return r},L={webm:S([119,101,98,109]),matroska:S([109,97,116,114,111,115,107,97]),flac:S([102,76,97,67]),ogg:S([79,103,103,83]),ac3:S([11,119]),riff:S([82,73,70,70]),avi:S([65,86,73]),wav:S([87,65,86,69]),"3gp":S([102,116,121,112,51,103]),mp4:S([102,116,121,112]),fmp4:S([115,116,121,112]),mov:S([102,116,121,112,113,116]),moov:S([109,111,111,118]),moof:S([109,111,111,102])},Ol={aac:function(e){var t=cl(e);return E(e,[255,16],{offset:t,mask:[255,22]})},mp3:function(e){var t=cl(e);return E(e,[255,2],{offset:t,mask:[255,6]})},webm:function(e){e=fl(e,[wl.EBML,wl.DocType])[0];return E(e,L.webm)},mkv:function(e){e=fl(e,[wl.EBML,wl.DocType])[0];return E(e,L.matroska)},mp4:function(e){return!Ol["3gp"](e)&&!Ol.mov(e)&&(!!(E(e,L.mp4,{offset:4})||E(e,L.fmp4,{offset:4})||E(e,L.moof,{offset:4})||E(e,L.moov,{offset:4}))||void 0)},mov:function(e){return E(e,L.mov,{offset:4})},"3gp":function(e){return E(e,L["3gp"],{offset:4})},ac3:function(e){var t=cl(e);return E(e,L.ac3,{offset:t})},ts:function(e){if(e.length<189&&1<=e.length)return 71===e[0];for(var t=0;t+188<e.length&&t<188;){if(71===e[t]&&71===e[t+188])return!0;t+=1}return!1},flac:function(e){var t=cl(e);return E(e,L.flac,{offset:t})},ogg:function(e){return E(e,L.ogg)},avi:function(e){return E(e,L.riff)&&E(e,L.avi,{offset:8})},wav:function(e){return E(e,L.riff)&&E(e,L.wav,{offset:8})},h264:function(e){return yl(e,"h264",7,3).length},h265:function(e){return yl(e,"h265",[32,33],3).length}},Dl=Object.keys(Ol).filter(function(e){return"ts"!==e&&"h264"!==e&&"h265"!==e}).concat(["ts","h264","h265"]),Nl=(Dl.forEach(function(e){var t=Ol[e];Ol[e]=function(e){return t(S(e))}}),Ol),Ml=9e4; 3810/*! @name @videojs/http-streaming @version 3.0.2 @license Apache-2.0 */ 3811const Rl=function(e,t){if(/^[a-z]+:/i.test(t))return t;/^data:/.test(e)&&(e=window.location&&window.location.href||"");var i="function"==typeof window.URL,s=/^\/\//.test(e),r=!window.location&&!/\/\//i.test(e);return i?e=new window.URL(e,window.location||fn):/\/\//i.test(e)||(e=gn.buildAbsoluteURL(window.location&&window.location.href||"",e)),i?(i=new URL(t,e),r?i.href.slice(fn.length):s?i.href.slice(i.protocol.length):i.href):gn.buildAbsoluteURL(e,t)},Ul=(e,t)=>t&&t.responseURL&&e!==t.responseURL?t.responseURL:e,Bl=e=>T.log.debug?T.log.debug.bind(T,"VHS:",e+" >"):function(){};function O(...e){var t=T.obj||T;return(t.merge||t.mergeOptions).apply(t,e)}function Fl(...e){var t=T.time||T;return(t.createTimeRanges||t.createTimeRanges).apply(t,e)}function jl(e,i){return Xl(e,function(e,t){return e-zl<=i&&t+zl>=i})}function Hl(e,t){return Xl(e,function(e){return e-Gl>=t})}function ql(e){if(e&&e.length&&e.end)return e.end(e.length-1)}function Vl(t,i){let s=0;if(t&&t.length)for(let e=0;e<t.length;e++){var r=t.start(e),n=t.end(e);n<i||(s+=r<i&&i<=n?n-i:n-r)}return s}function $l({defaultDuration:t,durationList:i,startIndex:s,endIndex:r}){let n=0;if(r<s&&([s,r]=[r,s]),s<0){for(let e=s;e<Math.min(0,r);e++)n+=t;s=0}for(let e=s;e<r;e++)n+=i[e].duration;return n}function Wl(e,t,i,s){if(!e||!e.segments)return null;if(e.endList)return nd(e);if(null===t)return null;t=t||0;let r=rd(e,e.mediaSequence+e.segments.length,t);return i&&(s="number"==typeof s?s:td(null,e),r-=s),Math.max(0,r)}const Gl=1/30,zl=3*Gl,Xl=function(e,t){var i=[];let s;if(e&&e.length)for(s=0;s<e.length;s++)t(e.start(s),e.end(s))&&i.push([e.start(s),e.end(s)]);return Fl(i)},Kl=t=>{var i=[];if(!t||!t.length)return"";for(let e=0;e<t.length;e++)i.push(t.start(e)+" => "+t.end(e));return i.join(", ")},Yl=t=>{var i=[];for(let e=0;e<t.length;e++)i.push({start:t.start(e),end:t.end(e)});return i},Ql=(t,e)=>{if(!e.preload)return e.duration;let i=0;return(e.parts||[]).forEach(function(e){i+=e.duration}),(e.preloadHints||[]).forEach(function(e){"PART"===e.type&&(i+=t.partTargetDuration)}),i},Jl=e=>(e.segments||[]).reduce((i,s,r)=>(s.parts?s.parts.forEach(function(e,t){i.push({duration:e.duration,segmentIndex:r,partIndex:t,part:e,segment:s})}):i.push({duration:s.duration,segmentIndex:r,partIndex:null,segment:s,part:null}),i),[]),Zl=e=>{e=e.segments&&e.segments.length&&e.segments[e.segments.length-1];return e&&e.parts||[]},ed=({preloadSegment:e})=>{var t;if(e)return{parts:e,preloadHints:t}=e,(t||[]).reduce((e,t)=>e+("PART"===t.type?1:0),0)+(e&&e.length?e.length:0)},td=(e,t)=>{return t.endList?0:e&&e.suggestedPresentationDelay?e.suggestedPresentationDelay:(e=0<Zl(t).length)&&t.serverControl&&t.serverControl.partHoldBack?t.serverControl.partHoldBack:e&&t.partTargetDuration?3*t.partTargetDuration:t.serverControl&&t.serverControl.holdBack?t.serverControl.holdBack:t.targetDuration?3*t.targetDuration:0},id=function(e,t){let i=0,s=t-e.mediaSequence,r=e.segments[s];if(r){if("undefined"!=typeof r.start)return{result:r.start,precise:!0};if("undefined"!=typeof r.end)return{result:r.end-r.duration,precise:!0}}for(;s--;){if("undefined"!=typeof(r=e.segments[s]).end)return{result:i+r.end,precise:!0};if(i+=Ql(e,r),"undefined"!=typeof r.start)return{result:i+r.start,precise:!0}}return{result:i,precise:!1}},sd=function(e,t){let i=0;var s;let r=t-e.mediaSequence;for(;r<e.segments.length;r++){if("undefined"!=typeof(s=e.segments[r]).start)return{result:s.start-i,precise:!0};if(i+=Ql(e,s),"undefined"!=typeof s.end)return{result:s.end-i,precise:!0}}return{result:-1,precise:!1}},rd=function(e,t,i){var s;return(t="undefined"==typeof t?e.mediaSequence+e.segments.length:t)<e.mediaSequence?0:(s=id(e,t)).precise?s.result:(e=sd(e,t)).precise?e.result:s.result+i},nd=function(e,t,i){if(!e)return 0;if("number"!=typeof i&&(i=0),"undefined"==typeof t){if(e.totalDuration)return e.totalDuration;if(!e.endList)return window.Infinity}return rd(e,t,i)};function ad(e){return e.excludeUntil&&e.excludeUntil>Date.now()}function od(e){return e.excludeUntil&&e.excludeUntil===1/0}function ld(e){var t=ad(e);return!e.disabled&&!t}function dd(e,t){return t.attributes&&t.attributes[e]}function hd(e,t){var i=e&&e.mediaGroups&&e.mediaGroups.AUDIO||{};let s=!1;for(const r in i){for(const n in i[r])if(s=t(i[r][n]))break;if(s)break}return!!s}const ud=(e,t)=>{if(1===e.playlists.length)return!0;const i=t.attributes.BANDWIDTH||Number.MAX_VALUE;return 0===e.playlists.filter(e=>!!ld(e)&&(e.attributes.BANDWIDTH||0)<i).length},cd=(e,t)=>!(!e&&!t||!e&&t||e&&!t||e!==t&&(!e.id||!t.id||e.id!==t.id)&&(!e.resolvedUri||!t.resolvedUri||e.resolvedUri!==t.resolvedUri)&&(!e.uri||!t.uri||e.uri!==t.uri)),pd=t=>{if(!t||!t.playlists||!t.playlists.length)return hd(t,e=>e.playlists&&e.playlists.length||e.uri);for(let e=0;e<t.playlists.length;e++){const s=t.playlists[e];var i=s.attributes&&s.attributes.CODECS;if(!i||!i.split(",").every(e=>Cn(e))){i=hd(t,e=>cd(s,e));if(!i)return!1}}return!0};var md={liveEdgeDelay:td,duration:nd,seekable:function(e,t,i){var s=t||0,e=Wl(e,t,!0,i);return null===e?Fl():Fl(s,e)},getMediaInfoForTime:function({playlist:t,currentTime:i,startingSegmentIndex:s,startingPartIndex:r,startTime:n,exactManifestTimings:a}){let o=i-n;var l=Jl(t);let d=0;for(let e=0;e<l.length;e++){var h=l[e];if(s===h.segmentIndex&&("number"!=typeof r||"number"!=typeof h.partIndex||r===h.partIndex)){d=e;break}}if(o<0){if(0<d)for(let e=d-1;0<=e;e--){var u=l[e];if(o+=u.duration,a){if(o<0)continue}else if(o+Gl<=0)continue;return{partIndex:u.partIndex,segmentIndex:u.segmentIndex,startTime:n-$l({defaultDuration:t.targetDuration,durationList:l,startIndex:d,endIndex:e})}}return{partIndex:l[0]&&l[0].partIndex||null,segmentIndex:l[0]&&l[0].segmentIndex||0,startTime:i}}if(d<0){for(let e=d;e<0;e++)if((o-=t.targetDuration)<0)return{partIndex:l[0]&&l[0].partIndex||null,segmentIndex:l[0]&&l[0].segmentIndex||0,startTime:i};d=0}for(let e=d;e<l.length;e++){var c=l[e];if(o-=c.duration,a){if(0<o)continue}else if(0<=o-Gl)continue;return{partIndex:c.partIndex,segmentIndex:c.segmentIndex,startTime:n+$l({defaultDuration:t.targetDuration,durationList:l,startIndex:d,endIndex:e})}}return{segmentIndex:l[l.length-1].segmentIndex,partIndex:l[l.length-1].partIndex,startTime:i}},isEnabled:ld,isDisabled:function(e){return e.disabled},isExcluded:ad,isIncompatible:od,playlistEnd:Wl,isAes:function(t){for(let e=0;e<t.segments.length;e++)if(t.segments[e].key)return!0;return!1},hasAttribute:dd,estimateSegmentRequestTime:function(e,t,i,s=0){return dd("BANDWIDTH",i)?(e*i.attributes.BANDWIDTH-8*s)/t:NaN},isLowestEnabledRendition:ud,isAudioOnly:pd,playlistMatch:cd,segmentDurationWithParts:Ql};const gd=T["log"],fd=(e,t)=>e+"-"+t,yd=(r,n)=>{r.mediaGroups&&["AUDIO","SUBTITLES"].forEach(e=>{if(r.mediaGroups[e])for(const i in r.mediaGroups[e])for(const s in r.mediaGroups[e][i]){var t=r.mediaGroups[e][i][s];n(t,e,i,s)}})},_d=({playlist:e,uri:t,id:i})=>{e.id=i,e.playlistErrors_=0,t&&(e.uri=t),e.attributes=e.attributes||{}},vd=(o,e,l=(e,t,i)=>`placeholder-uri-${e}-${t}-`+i)=>{o.uri=e;for(let e=0;e<o.playlists.length;e++){var t;o.playlists[e].uri||(t="placeholder-uri-"+e,o.playlists[e].uri=t)}const i=pd(o);yd(o,(e,r,n,a)=>{if(!e.playlists||!e.playlists.length){if(i&&"AUDIO"===r&&!e.uri)for(let e=0;e<o.playlists.length;e++){var t=o.playlists[e];if(t.attributes&&t.attributes.AUDIO&&t.attributes.AUDIO===n)return}e.playlists=[fi({},e)]}e.playlists.forEach(function(e,t){var i=l(r,n,a,e),s=fd(t,i);e.uri?e.resolvedUri=e.resolvedUri||Rl(o.uri,e.uri):(e.uri=0===t?i:s,e.resolvedUri=e.uri),e.id=e.id||s,e.attributes=e.attributes||{},o.playlists[e.id]=e,o.playlists[e.uri]=e})});{var s=o;let e=s.playlists.length;for(;e--;){var r=s.playlists[e];_d({playlist:r,id:fd(e,r.uri)}),r.resolvedUri=Rl(s.uri,r.uri),s.playlists[r.id]=r,(s.playlists[r.uri]=r).attributes.BANDWIDTH||gd.warn("Invalid playlist STREAM-INF detected. Missing BANDWIDTH attribute.")}}var n;n=o,yd(n,e=>{e.uri&&(e.resolvedUri=Rl(n.uri,e.uri))})};Dr=T.EventTarget;function bd(e){var t=e.segments||[],i=e.preloadSegment;if(i&&i.parts&&i.parts.length){if(i.preloadHints)for(let e=0;e<i.preloadHints.length;e++)if("MAP"===i.preloadHints[e].type)return t;i.duration=e.targetDuration,i.preload=!0,t.push(i)}return t}const Td=(t,i)=>{if(!t)return i;var s=O(t,i);if(t.preloadHints&&!i.preloadHints&&delete s.preloadHints,t.parts&&!i.parts)delete s.parts;else if(t.parts&&i.parts)for(let e=0;e<i.parts.length;e++)t.parts&&t.parts[e]&&(s.parts[e]=O(t.parts[e],i.parts[e]));return!t.skipped&&i.skipped&&(s.skipped=!1),t.preload&&!i.preload&&(s.preload=!1),s},Sd=(e,t)=>{!e.resolvedUri&&e.uri&&(e.resolvedUri=Rl(t,e.uri)),e.key&&!e.key.resolvedUri&&(e.key.resolvedUri=Rl(t,e.key.uri)),e.map&&!e.map.resolvedUri&&(e.map.resolvedUri=Rl(t,e.map.uri)),e.map&&e.map.key&&!e.map.key.resolvedUri&&(e.map.key.resolvedUri=Rl(t,e.map.key.uri)),e.parts&&e.parts.length&&e.parts.forEach(e=>{e.resolvedUri||(e.resolvedUri=Rl(t,e.uri))}),e.preloadHints&&e.preloadHints.length&&e.preloadHints.forEach(e=>{e.resolvedUri||(e.resolvedUri=Rl(t,e.uri))})},wd=(e,t)=>e===t||e.segments&&t.segments&&e.segments.length===t.segments.length&&e.endList===t.endList&&e.mediaSequence===t.mediaSequence&&e.preloadSegment===t.preloadSegment,Ed=(e,r,t=wd)=>{var i=O(e,{}),s=i.playlists[r.id];if(!s)return null;if(t(s,r))return null;r.segments=bd(r);const n=O(s,r);if(n.preloadSegment&&!r.preloadSegment&&delete n.preloadSegment,s.segments){if(r.skip){r.segments=r.segments||[];for(let e=0;e<r.skip.skippedSegments;e++)r.segments.unshift({skipped:!0})}n.segments=((e,t,i)=>{var s=e.slice(),r=t.slice(),n=(i=i||0,[]);let a;for(let e=0;e<r.length;e++){var o=s[e+i],l=r[e];o?(a=o.map||a,n.push(Td(o,l))):(a&&!l.map&&(l.map=a),n.push(l))}return n})(s.segments,r.segments,r.mediaSequence-s.mediaSequence)}n.segments.forEach(e=>{Sd(e,n.resolvedUri)});for(let e=0;e<i.playlists.length;e++)i.playlists[e].id===r.id&&(i.playlists[e]=n);return i.playlists[r.id]=n,i.playlists[r.uri]=n,yd(e,(t,e,i,s)=>{if(t.playlists)for(let e=0;e<t.playlists.length;e++)r.id===t.playlists[e].id&&(t.playlists[e]=n)}),i},kd=(e,t)=>{var i=e.segments||[],i=i[i.length-1],s=i&&i.parts&&i.parts[i.parts.length-1],s=s&&s.duration||i&&i.duration;return t&&s?1e3*s:500*(e.partTargetDuration||e.targetDuration||10)};class Cd extends Dr{constructor(e,t,i={}){if(super(),!e)throw new Error("A non-empty playlist URL or object is required");this.logger_=Bl("PlaylistLoader");var{withCredentials:i=!1}=i,e=(this.src=e,this.vhs_=t,this.withCredentials=i,t.options_);this.customTagParsers=e&&e.customTagParsers||[],this.customTagMappers=e&&e.customTagMappers||[],this.llhls=e&&e.llhls,this.state="HAVE_NOTHING",this.handleMediaupdatetimeout_=this.handleMediaupdatetimeout_.bind(this),this.on("mediaupdatetimeout",this.handleMediaupdatetimeout_)}handleMediaupdatetimeout_(){if("HAVE_METADATA"===this.state){var t=this.media();let e=Rl(this.main.uri,t.uri);this.llhls&&(e=((e,t)=>{if(!t.endList&&t.serverControl){const r={};if(t.serverControl.canBlockReload){var i,s=t["preloadSegment"];let e=t.mediaSequence+t.segments.length;
3811s&&(s=s.parts||[],-1<(i=ed(t)-1)&&i!=s.length-1&&(r._HLS_part=i),-1<i||s.length)&&e--,r._HLS_msn=e}if(t.serverControl&&t.serverControl.canSkipUntil&&(r._HLS_skip=t.serverControl.canSkipDateranges?"v2":"YES"),Object.keys(r).length){const n=new window.URL(e);["_HLS_skip","_HLS_msn","_HLS_part"].forEach(function(e){r.hasOwnProperty(e)&&n.searchParams.set(e,r[e])}),e=n.toString()}}return e})(e,t)),this.state="HAVE_CURRENT_METADATA",this.request=this.vhs_.xhr({uri:e,withCredentials:this.withCredentials},(e,t)=>{if(this.request)return e?this.playlistRequestError(this.request,this.media(),"HAVE_METADATA"):void this.haveMetadata({playlistString:this.request.responseText,url:this.media().uri,id:this.media().id})})}}playlistRequestError(e,t,i){var{uri:t,id:s}=t;this.request=null,i&&(this.state=i),this.error={playlist:this.main.playlists[s],status:e.status,message:`HLS playlist request error at URL: ${t}.`,responseText:e.responseText,code:500<=e.status?4:2},this.trigger("error")}parseManifest_({url:t,manifestString:i}){{var[{onwarn:i,oninfo:e,manifestString:s,customTagParsers:r=[],customTagMappers:n=[],llhls:a}]=[{onwarn:({message:e})=>this.logger_(`m3u8-parser warn for ${t}: `+e),oninfo:({message:e})=>this.logger_(`m3u8-parser info for ${t}: `+e),manifestString:i,customTagParsers:this.customTagParsers,customTagMappers:this.customTagMappers,llhls:this.llhls}];const o=new kn,l=(i&&o.on("warn",i),e&&o.on("info",e),r.forEach(e=>
3811o.addParser(e)),n.forEach(e=>o.addTagMapper(e)),o.push(s),o.end(),o.manifest);if(a||(["preloadSegment","skip","serverControl","renditionReports","partInf","partTargetDuration"].forEach(function(e){l.hasOwnProperty(e)&&delete l[e]}),l.segments&&l.segments.forEach(function(t){["parts","preloadHints"].forEach(function(e){t.hasOwnProperty(e)&&delete t[e]})})),!l.targetDuration){let e=10;l.segments&&l.segments.length&&(e=l.segments.reduce((e,t)=>Math.max(e,t.duration),0)),i&&i("manifest has no targetDuration defaulting to "+e),l.targetDuration=e}return(e=Zl(l)).length&&!l.partTargetDuration&&(r=e.reduce((e,t)=>Math.max(e,t.duration),0),i&&(i("manifest has no partTargetDuration defaulting to "+r),gd.error("LL-HLS manifest has parts but lacks required #EXT-X-PART-INF:PART-TARGET value. See https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis-09#section-4.4.3.7. Playback is not guaranteed.")),l.partTargetDuration=r),l}}haveMetadata({playlistString:e,playlistObject:t,url:i,id:s}){this.request=null,this.state="HAVE_METADATA";t=t||this.parseManifest_({url:i,manifestString:e}),t.lastRequest=Date.now(),_d({playlist:t,uri:i,id:s}),e=Ed(this.main,t);this.targetDuration=t.partTargetDuration||t.targetDuration,this.pendingMedia_=null,e?(this.main=e,this.media_=this.main.playlists[s]):this.trigger("playlistunchanged"),this.updateMediaUpdateTimeout_(kd(this.media(),!!e)),this.trigger("loadedplaylist")}dispose(){this.trigger("dispose"),this.stopRequest(),window.clearTimeout(this.mediaUpdateTimeout),window.clearTimeout(this.finalRenditionTimeout),this.off()}stopRequest(){var e;this.request&&(e=this.request,this.request=null,e.onreadystatechange=null,e.abort())}media(i,e){if(!i)return this.media_;if("HAVE_NOTHING"===this.state)throw new Error("Cannot switch media playlist from "+this.state);if("string"==typeof i){if(!this.main.playlists[i])throw new Error("Unknown playlist URI: "+i);i=this.main.playlists[i]}if(window.clearTimeout(this.finalRenditionTimeout),e)e=(i.partTargetDuration||i.targetDuration)/2*1e3||5e3,this.finalRenditionTimeout=window.setTimeout(this.media.bind(this,i,!1),e);else{const s=this.state;var e=!this.media_||i.id!==this.media_.id,t=this.main.playlists[i.id];if(t&&t.endList||i.endList&&i.segments.length)this.request&&(this.request.onreadystatechange=null,this.request.abort(),this.request=null),this.state="HAVE_METADATA",this.media_=i,e&&(this.trigger("mediachanging"),"HAVE_MAIN_MANIFEST"===s?this.trigger("loadedmetadata"):this.trigger("mediachange"));else if(this.updateMediaUpdateTimeout_(kd(i,!0)),e){if(this.state="SWITCHING_MEDIA",this.request){if(i.resolvedUri===this.request.url)return;this.request.onreadystatechange=null,this.request.abort(),this.request=null}this.media_&&this.trigger("mediachanging"),this.pendingMedia_=i,this.request=this.vhs_.xhr({uri:i.resolvedUri,withCredentials:this.withCredentials},(e,t)=>{if(this.request){if(i.lastRequest=Date.now(),i.resolvedUri=Ul(i.resolvedUri,t),e)return this.playlistRequestError(this.request,i,s);this.haveMetadata({playlistString:t.responseText,url:i.uri,id:i.id}),"HAVE_MAIN_MANIFEST"===s?this.trigger("loadedmetadata"):this.trigger("mediachange")}})}}}pause(){this.mediaUpdateTimeout&&(window.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null),this.stopRequest(),"HAVE_NOTHING"===this.state&&(this.started=!1),"SWITCHING_MEDIA"===this.state?this.media_?this.state="HAVE_METADATA":this.state="HAVE_MAIN_MANIFEST":"HAVE_CURRENT_METADATA"===this.state&&(this.state="HAVE_METADATA")}load(e){this.mediaUpdateTimeout&&(window.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null);var t=this.media();e?(e=t?(t.partTargetDuration||t.targetDuration)/2*1e3:5e3,this.mediaUpdateTimeout=window.setTimeout(()=>{this.mediaUpdateTimeout=null,this.load()},e)):this.started?t&&!t.endList?this.trigger("mediaupdatetimeout"):this.trigger("loadedplaylist"):this.start()}updateMediaUpdateTimeout_(e){this.mediaUpdateTimeout&&(window.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null),this.media()&&!this.media().endList&&(this.mediaUpdateTimeout=window.setTimeout(()=>{this.mediaUpdateTimeout=null,this.trigger("mediaupdatetimeout"),this.updateMediaUpdateTimeout_(e)},e))}start(){this.started=!0,"object"==typeof this.src?(this.src.uri||(this.src.uri=window.location.href),this.src.resolvedUri=this.src.uri,setTimeout(()=>{this.setupInitialPlaylist(this.src)},0)):this.request=this.vhs_.xhr({uri:this.src,withCredentials:this.withCredentials},(e,t)=>{if(this.request){if(this.request=null,e)return this.error={status:t.status,message:`HLS playlist request error at URL: ${this.src}.`,responseText:t.responseText,code:2},"HAVE_NOTHING"===this.state&&(this.started=!1),this.trigger("error");this.src=Ul(this.src,t);e=this.parseManifest_({manifestString:t.responseText,url:this.src});this.setupInitialPlaylist(e)}})}srcUri(){return"string"==typeof this.src?this.src:this.src.uri}setupInitialPlaylist(e){var t,i,s,r;this.state="HAVE_MAIN_MANIFEST",e.playlists?(this.main=e,vd(this.main,this.srcUri()),e.playlists.forEac
vendor: 6,444 bytes, line 3811
3811h(t=>{t.segments=bd(t),t.segments.forEach(e=>{Sd(e,t.resolvedUri)})}),this.trigger("loadedplaylist"),this.request||this.media(this.main.playlists[0])):(t=this.srcUri()||window.location.href,this.main=(i=t,s=fd(0,i),(r={mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:window.location.href,resolvedUri:window.location.href,playlists:[{uri:i,id:s,resolvedUri:i,attributes:{}}]}).playlists[s]=r.playlists[0],r.playlists[i]=r.playlists[0],r),this.haveMetadata({playlistObject:e,url:t,id:this.main.playlists[0].id}),this.trigger("loadedmetadata"))}}function Id(e,t,i,s){var r="arraybuffer"===e.responseType?e.response:e.responseText;!t&&r&&(e.responseTime=Date.now(),e.roundTripTime=e.responseTime-e.requestTime,e.bytesReceived=r.byteLength||r.length,e.bandwidth||(e.bandwidth=Math.floor(e.bytesReceived/e.roundTripTime*8*1e3))),i.headers&&(e.responseHeaders=i.headers),t&&"ETIMEDOUT"===t.code&&(e.timedout=!0),s(t=t||e.aborted||200===i.statusCode||206===i.statusCode||0===i.statusCode?t:new Error("XHR Failed with a response of: "+(e&&(r||e.responseText))),e)}function xd(){function n(e,i){e=O({timeout:45e3},e);var t=n.beforeRequest||T.Vhs.xhr.beforeRequest;t&&"function"==typeof t&&(t=t(e))&&(e=t);const s=(!0===T.Vhs.xhr.original?Md:T.Vhs.xhr)(e,function(e,t){return Id(s,e,t,i)}),r=s.abort;return s.abort=function(){return s.aborted=!0,r.apply(s,arguments)},s.uri=e.uri,s.requestTime=Date.now(),s}return n.original=!0,n}function Ad(e){var t={};return e.byterange&&(t.Range=function(e){let t;return"bytes="+e.offset+"-"+(t="bigint"==typeof e.offset||"bigint"==typeof e.length?window.BigInt(e.offset)+window.BigInt(e.length)-window.BigInt(1):e.offset+e.length-1)}(e.byterange)),t}function Pd(e,t){return e=e.toString(16),"00".substring(0,2-e.length)+e+(t%2?" ":"")}function Ld(e){return 32<=e&&e<126?String.fromCharCode(e):"."}function Od(i){const s={};return Object.keys(i).forEach(e=>{var t=i[e];qn(t)?s[e]={bytes:t.buffer,byteOffset:t.byteOffset,byteLength:t.byteLength}:s[e]=t}),s}function Dd(e){var t=e.byterange||{length:1/0,offset:0};return[t.length,t.offset,e.resolvedUri].join(",")}function Nd(e){return e.resolvedUri}const Md=T["xhr"],Rd=e=>{var t,i,s=Array.prototype.slice.call(e);let r="";for(let e=0;e<s.length/16;e++)t=s.slice(16*e,16*e+16).map(Pd).join(""),i=s.slice(16*e,16*e+16).map(Ld).join(""),r+=t+" "+i+"\n";return r};Or=Object.freeze({__proto__:null,createTransferableMessage:Od,initSegmentId:Dd,segmentKeyId:Nd,hexDump:Rd,tagDump:({bytes:e})=>Rd(e),textRanges:e=>{let t="",i;for(i=0;i<e.length;i++)t+=(s=e,r=i,s.start(r)+"-"+s.end(r)+" ");var s,r;return t}});const Ud=.25,Bd=e=>e.transmuxedPresentationEnd-e.transmuxedPresentationStart-e.transmuxerPrependedSeconds,Fd=({playlist:e,time:t=void 0,callback:i})=>{var s,r;if(i)return e&&void 0!==t?(e=((t,i)=>{if(!i||!i.segments||0===i.segments.length)return null;let s=0,r;for(let e=0;e<i.segments.length&&(r=i.segments[e],!(t<=(s=r.videoTimingInfo?r.videoTimingInfo.transmuxedPresentationEnd:s+r.duration)));e++);var e=i.segments[i.segments.length-1];if(e.videoTimingInfo&&e.videoTimingInfo.transmuxedPresentationEnd<t)return null;if(t>s){if(t>s+e.duration*Ud)return null;r=e}return{segment:r,estimatedStart:r.videoTimingInfo?r.videoTimingInfo.transmuxedPresentationStart:s-r.duration,type:r.videoTimingInfo?"accurate":"estimate"}})(t,e))?"estimate"===e.type?i({message:"Accurate programTime could not be determined. Please seek to e.seekTime and try again",seekTime:e.estimatedStart}):(s={mediaSeconds:t},t=t,(r=(e=e.segment).dateTimeObject?(r=e.videoTimingInfo.transmuxerPrependedSeconds,t=t-(e.videoTimingInfo.transmuxedPresentationStart+r),new Date(e.dateTimeObject.getTime()+1e3*t)):null)&&(s.programDateTime=r.toISOString()),i(null,s)):i({message:"valid programTime was not found"}):i({message:"getProgramTime: playlist and time must be provided"});throw new Error("getProgramTime: callback must be provided")},jd=({programTime:e,playlist:t,retryCount:i=2,seekTo:s,pauseAfterSeek:r=!0,tech:n,callback:a})=>{var o,l,d;if(a)return"undefined"!=typeof e&&t&&s?t.endList||n.hasStarted_?(t=>{if(!t.segments||0===t.segments.length)return!1;for(let e=0;e<t.segments.length;e++)if(!t.segments[e].dateTimeObject)return!1;return!0})(t)?(d=((e,t)=>{let i;try{i=new Date(e)}catch(e){return null}if(!t||!t.segments||0===t.segments.length)return null;let s=t.segments[0];if(i<s.dateTimeObject)return null;for(let e=0;e<t.segments.length-1;e++){s=t.segments[e];var r=t.segments[e+1].dateTimeObject;if(i<r)break}var e=t.segments[t.segments.length-1],n=e.dateTimeObject,a=e.videoTimingInfo?Bd(e.videoTimingInfo):e.duration+e.duration*Ud,a=new Date(n.getTime()+1e3*a);return i>a?null:{segment:s=i>n?e:s,estimatedStart:s.videoTimingInfo?s.videoTimingInfo.transmuxedPresentationStart:md.duration(t,t.mediaSequence+t.segments.indexOf(s)),type:s.videoTimingInfo?"accurate":"estimate"}})(e,t))?(l=((e,t)=>{let i,s;try{i=new Date(e),s=new Date(t)}catch(e){}e=i.getTime();return(s.getTime()-e)/1e3})((o=d.segment).dateTimeObject,e),"estimate"===d.type?0===i?a({message:e+" is not buffered yet. Try again"}):(s(d.estimatedStart+l),void n.one("seeked",()=>{jd({programTime:e,playlist:t,retryCount:i-1,seekTo:s,pauseAfterSeek:r,tech:n,callback:a})})):(d=o.start+l,n.one("seeked",()=>a(null,n.currentTime())),r&&n.pause(),void s(d))):a({message:e+" was not found in the stream"}):a({message:"programDateTime tags must be provided in the manifest "+t.resolvedUri}):a({message:"player must be playing a live stream to start buffering"}):a({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});throw new Error("seekToProgramTime: callback must be provided")},Hd=(e,t)=>{if(4===e.readyState)return t()},qd=(e,t,r)=>{let s=[],n,a=!1;function o(e,t,i,s){return t.abort(),a=!0,r(e,t,i,s)}function i(e,t){var i;if(!a)return e?o(e,t,"",s):(i=t.responseText.substring(s&&s.byteLength||0,t.responseText.length),s=function(){for(var e,t,i,s=arguments.length,r=new Array(s),n=0;n<s;n++)r[n]=arguments[n];return(r=r.filter(function(e){return e&&(e.byteLength||e.length)&&"string"!=typeof e})).length<=1?S(r[0]):(e=r.reduce(function(e,t,i){return e+(t.byteLength||t.length)},0),t=new Uint8Array(e),i=0,r.forEach(function(e){e=S(e),t.set(e,i),i+=e.byteLength}),t)}(s,Ln(i,!0)),n=n||cl(s),s.length<10||n&&s.length<n+2||"ts"===(i=_l(s))&&s.length<188||!i&&s.length<376?Hd(t,()=>o(e,t,"",s)):o(null,t,i,s))}const l=t({uri:e,beforeSend(e){e.overrideMimeType("text/plain;
3811 charset=x-user-defined"),e.addEventListener("progress",function({}){return Id(e,null,{statusCode:e.status},i)})}},function(e,t){return Id(l,e,t,i)});return l};Mi=T.EventTarget;function Vd(t,i){if(!wd(t,i))return!1;if(t.sidx&&i.sidx&&(t.sidx.offset!==i.sidx.offset||t.sidx.length!==i.sidx.length))return!1;if(!t.sidx&&i.sidx||t.sidx&&!i.sidx)return!1;if(t.segments&&!i.segments||!t.segments&&i.segments)return!1;if(t.segments||i.segments)for(let e=0;e<t.segments.length;e++){var s=t.segments[e],r=i.segments[e];if(s.uri!==r.uri)return!1;if(s.byterange||r.byterange){s=s.byterange,r=r.byterange;if(s&&!r||!s&&r)return!1;if(s.offset!==r.offset||s.length!==r.length)return!1}}return!0}const $d=(e,t,i,s)=>{return`placeholder-uri-${e}-${t}-`+(s.attributes.NAME||i)},Wd=({mainXml:e,srcUrl:t,clientOffset:i,sidxMapping:s,previousManifest:r})=>{e=e,i={manifestUri:t,clientOffset:i,sidxMapping:s,previousManifest:r},e=dl(hl(e),i),s=tl(e.representationInfo);r=Xo({dashPlaylists:s,locations:e.locations,sidxMapping:i.sidxMapping,previousManifest:i.previousManifest});return vd(r,t,$d),r},Gd=(e,t,i)=>{let a=!0,o=O(e,{duration:t.duration,minimumUpdatePeriod:t.minimumUpdatePeriod,timelineStarts:t.timelineStarts});for(let e=0;e<t.playlists.length;e++){var s=t.playlists[e],r=(s.sidx&&(r=Fo(s.sidx),i)&&i[r]&&i[r].sidx&&Do(s,i[r].sidx,s.sidx.resolvedUri),Ed(o,s,Vd));r&&(o=r,a=!1)}var n,l;return yd(t,(e,t,i,s)=>{var r,n;e.playlists&&e.playlists.length&&(r=e.playlists[0].id,n=Ed(o,e.playlists[0],Vd))&&(s in(o=n).mediaGroups[t][i]||(o.mediaGroups[t][i][s]=e),o.mediaGroups[t][i][s].playlists[0]=o.playlists[r],a=!1)}),n=o,l=t,yd(n,(e,t,i,s)=>{s in l.mediaGroups[t][i]||delete n.mediaGroups[t][i][s]}),(a=t.minimumUpdatePeriod===e.minimumUpdatePeriod&&a)?null:o},zd=(e,t)=>{return(Boolean(!e.map&&!t.map)||Boolean(e.map&&t.map&&e.map.byterange.offset===t.map.byterange.offset&&e.map.byterange.length===t.map.byterange.length))&&e.uri===t.uri&&e.byterange.offset===t.byterange.offset&&e.byterange.length===t.byterange.length},Xd=(e,t)=>{var i={};for(const a in e){var s=e[a].sidx;if(s){var r=Fo(s);if(!t[r])break;var n=t[r].sidxInfo;zd(n,s)&&(i[r]=t[r])}}return i};class Kd extends Mi{constructor(e,t,i={},s){super(),this.mainPlaylistLoader_=s||this,s||(this.isMain_=!0);var{withCredentials:s=!1}=i;if(this.vhs_=t,this.withCredentials=s,!e)throw new Error("A non-empty playlist URL or object is required");this.on("minimumUpdatePeriod",()=>{this.refreshXml_()}),this.on("mediaupdatetimeout",()=>{this.refreshMedia_(this.media().id)}),this.state="HAVE_NOTHING",this.loadedPlaylists_={},this.logger_=Bl("DashPlaylistLoader"),this.isMain_?(this.mainPlaylistLoader_.srcUrl=e,this.mainPlaylistLoader_.sidxMapping_={}):this.childPlaylist_=e}requestErrored_(e,t,i){return!this.request||(this.request=null,e?(this.error="object"!=typeof e||e instanceof Error?{status:t.status,message:"DASH request error at URL: "+t.uri,response:t.response,code:2}:e,i&&(this.state=i),this.trigger("error"),!0):void 0)}addSidxSegments_(a,s,r){const n=a.sidx&&Fo(a.sidx);if(a.sidx&&n&&!this.mainPlaylistLoader_.sidxMapping_[n]){const o=Ul(a.sidx.resolvedUri),l=(t,i)=>{if(!this.requestErrored_(t,i,s)){t=this.mainPlaylistLoader_.sidxMapping_;let e;try{e=Tl(S(i.response).subarray(8))}catch(e){return void this.requestErrored_(e,i,s)}return t[n]={sidxInfo:a.sidx,sidx:e},Do(a,e,a.sidx.resolvedUri),r(!0)}};this.request=qd(o,this.vhs_.xhr,(e,t,i,s)=>{var r,n;return e?l(e,t):i&&"mp4"===i?({offset:r,length:n}=a.sidx.byterange,s.length>=n+r?l(e,{response:s.subarray(r,r+n),status:t.status,uri:t.uri}):void(this.request=this.vhs_.xhr({uri:o,responseType:"arraybuffer",headers:Ad({byterange:a.sidx.byterange})},l))):l({status:t.status,message:`Unsupported ${i||"unknown"} container type for sidx segment at URL: `+o,response:"",playlist:a,internal:!0,playlistExclusionDuration:1/0,code:2},t)})}else this.mediaRequest_=window.setTimeout(()=>r(!1),0)}dispose(){this.trigger("dispose"),this.stopRequest(),this.loadedPlaylists_={},window.clearTimeout(this.minimumUpdatePeriodTimeout_),window.clearTimeout(this.mediaRequest_),window.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.mediaRequest_=null,this.minimumUpdatePeriodTimeout_=null,this.mainPlaylistLoader_.createMupOnMedia_&&(this.off("loadedmetadata",this.mainPlaylistLoader_.createMupOnMedia_),this.mainPlaylistLoader_.createMupOnMedia_=null),this.off()}hasPendingRequest(){return this.request||this.mediaRequest_}stopRequest(){var e;this.request&&(e=this.request,this.request=null,e.onreadystatechange=null,e.abort())}media(t){if(!t)return this.media_;if("HAVE_NOTHING"===this.state)throw new Error("Cannot switch media playlist from "+this.state);const i=this.state;if("string"==typeof t){if(!this.mainPlaylistLoader_.main.playlists[t])throw new Error("Unknown playlist URI: "+t);t=this.mainPlaylistLoader_.main.playlists[t]}var e=!this.media_||t.id!==this.media_.id;e&&this.loadedPlaylists_[t.id]&&this.loadedPlaylists_[t.id].endList?(this.state="HAVE_METADATA",this.media_=t,e&&(this.trigger("mediachanging"),this.trigger("mediachange"))):e&&(this.media_&&this.trigger("mediachanging"),this.addSidxSegments_(t,i,e=>{this.haveMetadata({startingState:i,playlist:t})}))}haveMetadata({startingState:e,playlist:t}){this.state="HAVE_METADATA",this.loadedPlaylists_[t.id]=t,this.mediaRequest_=null,this.refreshMedia_(t.id),"HAVE_MAIN_MANIFEST"===e?this.trigger("loadedmetadata"):this.trigger("mediachange")}pause(){this.mainPlaylistLoader_.createMupOnMedia_&&(this.off("loadedmetadata",this.mainPlaylistLoader_.createMupOnMedia_),this.mainPlaylistLoader_.createMupOnMedia_=null),this.stopRequest(),window.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.isMain_&&(window.clearTimeout(this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_),this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_=null),"HAVE_NOTHING"===this.state&&(this.started=!1)}load(e){window.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null;var t=this.media();e?(e=t?t.targetDuration/2*1e3:5e3,this.mediaUpdateTimeout=window.setTimeout(()=>this.load(),e)):this.started?t&&!t.endList?(this.isMain_&&!this.minimumUpdatePeriodTimeout_&&(this.trigger("minimumUpdatePeriod"),this.updateMinimumUpdatePeriodTimeout_()),this.trigger("mediaupdatetimeout")):this.trigger("loadedplaylist"):this.start()}start(){this.started=!0,this.isMain_?this.requestMain_((e,t)=>
vendor: 90,868 bytes, lines 3811-3812
3811{this.haveMain_(),this.hasPendingRequest()||this.media_||this.media(this.mainPlaylistLoader_.main.playlists[0])}):this.mediaRequest_=window.setTimeout(()=>this.haveMain_(),0)}requestMain_(s){this.request=this.vhs_.xhr({uri:this.mainPlaylistLoader_.srcUrl,withCredentials:this.withCredentials},(e,t)=>{if(this.requestErrored_(e,t))"HAVE_NOTHING"===this.state&&(this.started=!1);else{const i=t.responseText!==this.mainPlaylistLoader_.mainXml_;if(this.mainPlaylistLoader_.mainXml_=t.responseText,t.responseHeaders&&t.responseHeaders.date?this.mainLoaded_=Date.parse(t.responseHeaders.date):this.mainLoaded_=Date.now(),this.mainPlaylistLoader_.srcUrl=Ul(this.mainPlaylistLoader_.srcUrl,t),!i)return s(t,i);this.handleMain_(),this.syncClientServerClock_(()=>s(t,i))}})}syncClientServerClock_(s){const r=ul(this.mainPlaylistLoader_.mainXml_);return null===r?(this.mainPlaylistLoader_.clientOffset_=this.mainLoaded_-Date.now(),s()):"DIRECT"===r.method?(this.mainPlaylistLoader_.clientOffset_=r.value-Date.now(),s()):void(this.request=this.vhs_.xhr({uri:Rl(this.mainPlaylistLoader_.srcUrl,r.value),method:r.method,withCredentials:this.withCredentials},(t,i)=>{if(this.request){if(t)return this.mainPlaylistLoader_.clientOffset_=this.mainLoaded_-Date.now(),s();let e;e="HEAD"===r.method?i.responseHeaders&&i.responseHeaders.date?Date.parse(i.responseHeaders.date):this.mainLoaded_:Date.parse(i.responseText),this.mainPlaylistLoader_.clientOffset_=e-Date.now(),s()}}))}haveMain_(){this.state="HAVE_MAIN_MANIFEST",this.isMain_?this.trigger("loadedplaylist"):this.media_||this.media(this.childPlaylist_)}handleMain_(){this.mediaRequest_=null;var e=this.mainPlaylistLoader_.main;let t=Wd({mainXml:this.mainPlaylistLoader_.mainXml_,srcUrl:this.mainPlaylistLoader_.srcUrl,clientOffset:this.mainPlaylistLoader_.clientOffset_,sidxMapping:this.mainPlaylistLoader_.sidxMapping_,previousManifest:e});e&&(t=Gd(e,t,this.mainPlaylistLoader_.sidxMapping_)),this.mainPlaylistLoader_.main=t||e;var i=this.mainPlaylistLoader_.main.locations&&this.mainPlaylistLoader_.main.locations[0];return i&&i!==this.mainPlaylistLoader_.srcUrl&&(this.mainPlaylistLoader_.srcUrl=i),(!e||t&&t.minimumUpdatePeriod!==e.minimumUpdatePeriod)&&this.updateMinimumUpdatePeriodTimeout_(),Boolean(t)}updateMinimumUpdatePeriodTimeout_(){var e=this.mainPlaylistLoader_;e.createMupOnMedia_&&(e.off("loadedmetadata",e.createMupOnMedia_),e.createMupOnMedia_=null),e.minimumUpdatePeriodTimeout_&&(window.clearTimeout(e.minimumUpdatePeriodTimeout_),e.minimumUpdatePeriodTimeout_=null);let t=e.main&&e.main.minimumUpdatePeriod;0===t&&(e.media()?t=1e3*e.media().targetDuration:(e.createMupOnMedia_=e.updateMinimumUpdatePeriodTimeout_,e.one("loadedmetadata",e.createMupOnMedia_))),"number"!=typeof t||t<=0?t<0&&this.logger_(`found invalid minimumUpdatePeriod of ${t}, not setting a timeout`):this.createMUPTimeout_(t)}createMUPTimeout_(e){const t=this.mainPlaylistLoader_;t.minimumUpdatePeriodTimeout_=window.setTimeout(()=>{t.minimumUpdatePeriodTimeout_=null,t.trigger("minimumUpdatePeriod"),t.createMUPTimeout_(e)},e)}refreshXml_(){this.requestMain_((e,t)=>{t&&(this.media_&&(this.media_=this.mainPlaylistLoader_.main.playlists[this.media_.id]),this.mainPlaylistLoader_.sidxMapping_=((e,r)=>{let n=Xd(e.playlists,r);return yd(e,(e,t,i,s)=>{e.playlists&&e.playlists.length&&(e=e.playlists,n=O(n,Xd(e,r)))}),n})(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.sidxMapping_),this.addSidxSegments_(this.media(),this.state,e=>{this.refreshMedia_(this.media().id)}))})}refreshMedia_(e){if(!e)throw new Error("refreshMedia_ must take a media id");this.media_&&this.isMain_&&this.handleMain_();var t=this.mainPlaylistLoader_.main.playlists;const i=!this.media_||this.media_!==t[e];if(i?this.media_=t[e]:this.trigger("playlistunchanged"),!this.mediaUpdateTimeout){const s=()=>{this.media().endList||(this.mediaUpdateTimeout=window.setTimeout(()=>{this.trigger("mediaupdatetimeout"),s()},kd(this.media(),Boolean(i))))};s()}this.trigger("loadedplaylist")}}var D={GOAL_BUFFER_LENGTH:30,MAX_GOAL_BUFFER_LENGTH:60,BACK_BUFFER_LENGTH:30,GOAL_BUFFER_LENGTH_RATE:1,INITIAL_BANDWIDTH:4194304,BANDWIDTH_VARIANCE:1.2,BUFFER_LOW_WATER_LINE:0,MAX_BUFFER_LOW_WATER_LINE:30,EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:16,BUFFER_LOW_WATER_LINE_RATE:1,BUFFER_HIGH_WATER_LINE:30};function Yd(e){return e.on=e.addEventListener,e.off=e.removeEventListener,e}const Qd=t=>{var i=new Uint8Array(new ArrayBuffer(t.length));for(let e=0;e<t.length;e++)i[e]=t.charCodeAt(e);return i.buffer};function Jd(s){return function(){const e=function(t){try{return URL.createObjectURL(new Blob([t],{type:"application/javascript"}))}catch(e){var i=new BlobBuilder;return i.append(t),URL.createObjectURL(i.getBlob())}}(s);var t=Yd(new Worker(e));t.objURL=e;const i=t.terminate;return t.on=t.addEventListener,t.off=t.removeEventListener,t.terminate=function(){return URL.revokeObjectURL(e),i.call(this)},t}}function Zd(e){return`var browserWorkerPolyFill = ${Yd.toString()}; 3812`+"browserWorkerPolyFill(self);\n"+e}function eh(e){return e.toString().replace(/^function.+?{/,"").slice(0,-1)}var th=Jd(Zd(eh(function(){function e(){this.init=function(){var n={};this.on=function(e,t){n[e]||(n[e]=[]),n[e]=n[e].concat(t)},this.off=function(e,t){return!!n[e]&&(t=n[e].indexOf(t),n[e]=n[e].slice(),n[e].splice(t,1),-1<t)},this.trigger=function(e){var t,i,s,r=n[e];if(r)if(2===arguments.length)for(i=r.length,t=0;t<i;++t)r[t].call(this,arguments[1]);else{for(s=[],t=arguments.length,t=1;t<arguments.length;++t)s.push(arguments[t]);for(i=r.length,t=0;t<i;++t)r[t].apply(this,s)}},this.dispose=function(){n={}}}}var l,R,U,B,F,j,H,q,V,$,W,G,z,X,K,Y,Q,J,Z,ee,d,te,ie,se,re,ne,ae,oe,t,le,de,he,ue,ce,pe,me,ge,fe="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i=(e.prototype.pipe=function(t){return this.on("data",function(e){t.push(e)}),this.on("done",function(e){t.flush(e)}),this.on("partialdone",function(e){t.partialFlush(e)}),this.on("endedtimeline",function(e){t.endTimeline(e)}),this.on("reset",function(e){t.reset(e)}),t},e.prototype.push=function(e){this.trigger("data",e)},e.prototype.flush=function(e){this.trigger("done",e)},e.prototype.partialFlush=function(e){this.trigger("partialdone",e)},e.prototype.endTimeline=function(e){this.trigger("endedtimeline",e)},e.prototype.reset=function(e){this.trigger("reset",e)},e),ye=Math.pow(2,32),_e={getUint64:function(e){var t,e=new DataView(e.buffer,e.byteOffset,e.byteLength);return e.getBigUint64?(t=e.getBigUint64(0))<Number.MAX_SAFE_INTEGER?Number(t):t:e.getUint32(0)*ye+e.getUint32(4)},MAX_UINT32:ye},ve=_e.MAX_UINT32;if(d={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],pasp:[],sdtp:[],smhd:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],styp:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[]},"undefined"!=typeof Uint8Array){for(var s in d)d.hasOwnProperty(s)&&(d[s]=[s.charCodeAt(0),s.charCodeAt(1),s.charCodeAt(2),s.charCodeAt(3)]);te=new Uint8Array(["i".charCodeAt(0),"s".charCodeAt(0),"o".charCodeAt(0),"m".charCodeAt(0)]),se=new Uint8Array(["a".charCodeAt(0),"v".charCodeAt(0),"c".charCodeAt(0),"1".charCodeAt(0)]),ie=new Uint8Array([0,0,0,1]),Ce=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),xe=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),re={video:Ce,audio:xe},oe=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),ae=new Uint8Array([0,0,0,0,0,0,0,0]),t=new Uint8Array([0,0,0,0,0,0,0,0]),le=t,de=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),he=t,ne=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}l=function(e){for(var t,i=[],s=0,r=1;r<arguments.length;r++)i.push(arguments[r]);for(r=i.length;r--;)s+=i[r].byteLength;for(t=new Uint8Array(s+8),new DataView(t.buffer,t.byteOffset,t.byteLength).setUint32(0,t.byteLength),t.set(e,4),r=0,s=8;r<i.length;r++)t.set(i[r],s),s+=i[r].byteLength;return t},R=function(){return l(d.dinf,l(d.dref,oe))},U=function(e){return l(d.esds,new Uint8Array([0,0,0,0,3,25,0,0,0,4,17,64,21,0,6,0,0,0,218,192,0,0,218,192,5,2,e.audioobjecttype<<3|e.samplingfrequencyindex>>>1,e.samplingfrequencyindex<<7|e.channelcount<<3,6,1,2]))},X=function(e){return l(d.hdlr,re[e])},z=function(e){var t=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,e.duration>>>24&255,e.duration>>>16&255,e.duration>>>8&255,255&e.duration,85,196,0,0]);return e.samplerate&&(t[12]=e.samplerate>>>24&255,t[13]=e.samplerate>>>16&255,t[14]=e.samplerate>>>8&255,t[15]=255&e.samplerate),l(d.mdhd,t)},G=function(e){return l(d.mdia,z(e),X(e.type),j(e))},F=function(e){return l(d.mfhd,new Uint8Array([0,0,0,0,(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e]))},j=function(e){return l(d.minf,"video"===e.type?l(d.vmhd,ne):l(d.smhd,ae),R(),Y(e))},q=function(e){for(var t=e.length,i=[];t--;)i[t]=Z(e[t]);return l.apply(null,[d.mvex].concat(i))},V=function(e){e=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return l(d.mvhd,e)},K=function(e){for(var t,i=e.samples||[],s=new Uint8Array(4+i.length),r=0;r<i.length;r++)t=i[r].flags,s[r+4]=t.dependsOn<<4|t.isDependedOn<<2|t.hasRedundancy;return l(d.sdtp,s)},Y=function(e){return l(d.stbl,Q(e),l(d.stts,he),l(d.stsc,le),l(d.stsz,de),l(d.stco,t))},Q=function(e){return l(d.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),("video"===e.type?ue:ce)(e))},ue=function(e){for(var t,i,s=e.sps||[],r=e.pps||[],n=[],a=[],o=0;o<s.length;o++)n.push((65280&s[o].byteLength)>>>8),n.push(255&s[o].byteLength),n=n.concat(Array.prototype.slice.call(s[o]));for(o=0;o<r.length;o++)a.push((65280&r[o].byteLength)>>>8),a.push(255&r[o].byteLength),a=a.concat(Array.prototype.slice.call(r[o]));return t=[d.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(65280&e.width)>>8,255&e.width,(65280&e.height)>>8,255&e.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l(d.avcC,new Uint8Array([1,e.profileIdc,e.profileCompatibility,e.levelIdc,255].concat([s.length],n,[r.length],a))),l(d.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],e.sarRatio&&(i=e.sarRatio[0],e=e.sarRatio[1],t.push(l(d.pasp,new Uint8Array([(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i,(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e])))),l.apply(null,t)},ce=function(e){return l(d.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(65280&e.channelcount)>>8,255&e.channelcount,(65280&e.samplesize)>>8,255&e.samplesize,0,0,0,0,(65280&e.samplerate)>>8,255&e.samplerate,0,0]),U(e))},W=function(e){e=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(4278190080&e.id)>>24,(16711680&e.id)>>16,(65280&e.id)>>8,255&e.id,0,0,0,0,(4278190080&e.duration)>>24,(16711680&e.duration)>>16,(65280&e.duration)>>8,255&e.duration,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,(65280&e.width)>>8,255&e.width,0,0,(65280&e.height)>>8,255&e.height,0,0]);return l(d.tkhd,e)},J=function(e){var t,i=l(d.tfhd,new Uint8Array([0,0,0,58,(4278190080&e.id)>>24,(16711680&e.id)>>16,(65280&e.id)>>8,255&e.id,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),s=Math.floor(e.baseMediaDecodeTime/ve),r=Math.floor(e.baseMediaDecodeTime%ve),s=l(d.tfdt,new Uint8Array([1,0,0,0,s>>>24&255,s>>>16&255,s>>>8&255,255&s,r>>>24&255,r>>>16&255,r>>>8&255,255&r]));return"audio"===e.type?(t=ee(e,92),l(d.traf,i,s,t)):(r=K(e),t=ee(e,r.length+92),l(d.traf,i,s,t,r))},$=function(e){return e.duration=e.duration||4294967295,l(d.trak,W(e),G(e))},Z=function(e){var t=new Uint8Array([0,0,0,0,(4278190080&e.id)>>24,(16711680&e.id)>>16,(65280&e.id)>>8,255&e.id,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return"video"!==e.type&&(t[t.length-1]=0),l(d.trex,t)},pe=function(e,t){var i=0,s=0,r=0,n=0;return e.length&&(void 0!==e[0].duration&&(i=1),void 0!==e[0].size&&(s=2),void 0!==e[0].flags&&(r=4),void 0!==e[0].compositionTimeOffset)&&(n=8),[0,0,i|s|r|n,1,(4278190080&e.length)>>>24,(16711680&e.length)>>>16,(65280&e.length)>>>8,255&e.length,(4278190080&t)>>>24,(16711680&t)>>>16,(65280&t)>>>8,255&t]},me=function(e,t){var i,s,r,n,a=e.samples||[];for(t+=20+16*a.length,e=pe(a,t),(s=new Uint8Array(e.length+16*a.length)).set(e),i=e.length,n=0;n<a.length;n++)r=a[n],s[i++]=(4278190080&r.duration)>>>24,s[i++]=(16711680&r.duration)>>>16,s[i++]=(65280&r.duration)>>>8,s[i++]=255&r.duration,s[i++]=(4278190080&r.size)>>>24,s[i++]=(16711680&r.size)>>>16,s[i++]=(65280&r.size)>>>8,s[i++]=255&r.size,s[i++]=r.flags.isLeading<<2|r.flags.dependsOn,s[i++]=r.flags.isDependedOn<<6|r.flags.hasRedundancy<<4|r.flags.paddingValue<<1|r.flags.isNonSyncSample,s[i++]=61440&r.flags.degradationPriority,s[i++]=15&r.flags.degradationPriority,s[i++]=(4278190080&r.compositionTimeOffset)>>>24,s[i++]=(16711680&r.compositionTimeOffset)>>>16,s[i++]=(65280&r.compositionTimeOffset)>>>8,s[i++]=255&r.compositionTimeOffset;return l(d.trun,s)},ge=function(e,t){var i,s,r,n,a=e.samples||[];for(t+=20+8*a.length,e=pe(a,t),(i=new Uint8Array(e.length+8*a.length)).set(e),s=e.length,n=0;n<a.length;n++)r=a[n],i[s++]=(4278190080&r.duration)>>>24,i[s++]=(16711680&r.duration)>>>16,i[s++]=(65280&r.duration)>>>8,i[s++]=255&r.duration,i[s++]=(4278190080&r.size)>>>24,i[s++]=(16711680&r.size)>>>16,i[s++]=(65280&r.size)>>>8,i[s++]=255&r.size;return l(d.trun,i)},ee=function(e,t){return("audio"===e.type?ge:me)(e,t)};function be(e,t){var i=Ie();return i.dataOffset=t,i.compositionTimeOffset=e.pts-e.dts,i.duration=e.duration,i.size=4*e.length,i.size+=e.byteLength,e.keyFrame&&(i.flags.dependsOn=2,i.flags.isNonSyncSample=0),i}function r(e){for(var t=[];e--;)t.push(0);return t}function n(e){e=e||{},n.prototype.init.call(this),this.parse708captions_="boolean"!=typeof e.parse708captions||e.parse708captions,this.captionPackets_=[],this.ccStreams_=[new g(0,0),new g(0,1),new g(1,0),new g(1,1)],this.parse708captions_&&(this.cc708Stream_=new m({captionServices:e.captionServices})),this.reset(),this.ccStreams_.forEach(function(e){e.on("data",this.trigger.bind(this,"data")),e.on("partialdone",this.trigger.bind(this,"partialdone")),e.on("done",this.trigger.bind(this,"done"))},this),this.parse708captions_&&(this.cc708Stream_.on("data",this.trigger.bind(this,"data")),this.cc708Stream_.on("partialdone",this.trigger.bind(this,"partialdone")),this.cc708Stream_.on("done",this.trigger.bind(this,"done")))}function o(e){return 32<=e&&e<=127||160<=e&&e<=255}function a(e){this.windowNum=e,this.reset()}function Te(e,t,i){this.serviceNum=e,this.text="",this.currentWindow=new a(-1),this.windows=[],this.stream=i,"string"==typeof t&&this.createTextDecoder(t)}function Se(e){return null===e?"":(e=Fe[e]||e,String.fromCharCode(e))}function h(){for(var e=[],t=je+1;t--;)e.push("");return e}function we(e,t){var i=1;for(t<e&&(i=-1);Math.abs(t-e)>We;)e+=i*$e;return e}function Ee(e){var t,i;Ee.prototype.init.call(this),this.type_=e||"shared",this.push=function(e){"shared"!==this.type_&&e.type!==this.type_||(void 0===i&&(i=e.dts),e.dts=we(e.dts,i),e.pts=we(e.pts,i),t=e.dts,this.trigger("data",e))},this.flush=function(){i=t,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.discontinuity=function(){t=i=void 0},this.reset=function(){this.discontinuity(),this.trigger("reset")}}var ke,Ce={ftyp:B=function(){return l(d.ftyp,te,ie,te,se)},mdat:function(e){return l(d.mdat,e)},moof:function(e,t){for(var i=[],s=t.length;s--;)i[s]=J(t[s]);return l.apply(null,[d.moof,F(e)].concat(i))},moov:H=function(e){for(var t=e.length,i=[];t--;)i[t]=$(e[t]);return l.apply(null,[d.moov,V(4294967295)].concat(i).concat(q(e)))},initSegment:function(e){var t=B(),e=H(e),i=new Uint8Array(t.byteLength+e.byteLength);return i.set(t),i.set(e,t.byteLength),i}},Ie=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}}},xe={groupNalsIntoFrames:function(e){var t,i,s=[],r=[];for(r.byteLength=0,r.nalCount=0,t=s.byteLength=r.duration=0;t<e.length;t++)"access_unit_delimiter_rbsp"===(i=e[t]).nalUnitType?(s.length&&(s.duration=i.dts-s.dts,r.byteLength+=s.byteLength,r.nalCount+=s.length,r.duration+=s.duration,r.push(s)),(s=[i]).byteLength=i.data.byteLength,s.pts=i.pts,s.dts=i.dts):("slice_layer_without_partitioning_rbsp_idr"===i.nalUnitType&&(s.keyFrame=!0),s.duration=i.dts-s.dts,s.byteLength+=i.data.byteLength,s.push(i));return r.length&&(!s.duration||s.duration<=0)&&(s.duration=r[r.length-1].duration),r.byteLength+=s.byteLength,r.nalCount+=s.length,r.duration+=s.duration,r.push(s),r},groupFramesIntoGops:function(e){var t,i,s=[],r=[];for(s.byteLength=0,s.nalCount=0,s.duration=0,s.pts=e[0].pts,s.dts=e[0].dts,r.byteLength=0,r.nalCount=0,r.duration=0,r.pts=e[0].pts,r.dts=e[0].dts,t=0;t<e.length;t++)(i=e[t]).keyFrame?(s.length&&(r.push(s),r.byteLength+=s.byteLength,r.nalCount+=s.nalCount,r.duration+=s.duration),(s=[i]).nalCount=i.length,s.byteLength=i.byteLength,s.pts=i.pts,s.dts=i.dts,s.duration=i.duration):(s.duration+=i.duration,s.nalCount+=i.length,s.byteLength+=i.byteLength,s.push(i));return r.length&&s.duration<=0&&(s.duration=r[r.length-1].duration),r.byteLength+=s.byteLength,r.nalCount+=s.nalCount,r.duration+=s.duration,r.push(s),r},extendFirstKeyFrame:function(e){var t;return!e[0][0].keyFrame&&1<e.length&&(t=e.shift(),e.byteLength-=t.byteLength,e.nalCount-=t.nalCount,e[0][0].dts=t.dts,e[0][0].pts=t.pts,e[0][0].duration+=t.duration),e},generateSampleTable:function(e,t){for(var i,s,r,n=t||0,a=[],o=0;o<e.length;o++)for(s=e[o],i=0;i<s.length;i++)r=s[i],n+=(r=be(r,n)).size,a.push(r);return a},concatenateNalData:function(e){for(var t,i,s,r,n,a=0,o=e.byteLength,l=e.nalCount,d=new Uint8Array(o+4*l),h=new DataView(d.buffer),u=0;u<e.length;u++)for(s=e[u],t=0;t<s.length;t++)for(r=s[t],i=0;i<r.length;i++)n=r[i],h.setUint32(a,n.data.byteLength),d.set(n.data,a+=4),a+=n.data.byteLength;return d},generateSampleTableForFrame:function(e,t){var i=[],e=be(e,t||0);return i.push(e),i},concatenateNalDataForFrame:function(e){for(var t,i=0,s=e.byteLength,r=e.length,n=new Uint8Array(s+4*r),a=new DataView(n.buffer),o=0;o<e.length;o++)t=e[o],a.setUint32(i,t.data.byteLength),n.set(t.data,i+=4),i+=t.data.byteLength;return n}},u=[33,16,5,32,164,27],Ae=[33,65,108,84,1,2,4,8,168,2,4,8,17,191,252],Pe=function(e){return 9e4*e},Le=function(e,t){return e*t},Oe=function(e){return e/9e4},De=function(e,t){return e/t},c={ONE_SECOND_IN_TS:9e4,secondsToVideoTs:Pe,secondsToAudioTs:Le,videoTsToSeconds:Oe,audioTsToSeconds:De,audioTsToVideoTs:function(e,t){return e/t*9e4},videoTsToAudioTs:function(e,t){return e/9e4*t},metadataTsToSeconds:function(e,t,i){return Oe(i?e:e-t)}},Ne=function(){var e,i;return ke||(e={96e3:[u,[227,64],r(154),[56]],88200:[u,[231],r(170),[56]],64e3:[u,[248,192],r(240),[56]],48e3:[u,[255,192],r(268),[55,148,128],r(54),[112]],44100:[u,[255,192],r(268),[55,163,128],r(84),[112]],32e3:[u,[255,192],r(268),[55,234],r(226),[112]],24e3:[u,[255,192],r(268),[55,255,128],r(268),[111,112],r(126),[224]],16e3:[u,[255,192],r(268),[55,255,128],r(268),[111,255],r(269),[223,108],r(195),[1,192]],12e3:[Ae,r(268),[3,127,248],r(268),[6,255,240],r(268),[13,255,224],r(268),[27,253,128],r(259),[56]],11025:[Ae,r(268),[3,127,248],r(268),[6,255,240],r(268),[13,255,224],r(268),[27,255,192],r(268),[55,175,128],r(108),[112]],8e3:[Ae,r(268),[3,121,16],r(47),[7]]},i=e,ke=Object.keys(i).reduce(function(e,t){return e[t]=new Uint8Array(i[t].reduce(function(e,t){return e.concat(t)},[])),e},{})),ke},Me=c,Pe={prefixWithSilence:function(e,t,i,s){var r,n,a,o,l,d=0,h=0;if(t.length&&(n=Me.audioTsToVideoTs(e.baseMediaDecodeTime,e.samplerate),r=Math.ceil(Me.ONE_SECOND_IN_TS/(e.samplerate/1024)),i&&s&&(n=n-Math.max(i,s),h=(d=Math.floor(n/r))*r),!(d<1||h>Me.ONE_SECOND_IN_TS/2))){for(a=(a=Ne()[e.samplerate])||t[0].data,o=0;o<d;o++)l=t[0],t.splice(0,0,{data:a,dts:l.dts-r,pts:l.pts-r});return e.baseMediaDecodeTime-=Math.floor(Me.videoTsToAudioTs(h,e.samplerate)),h}},trimAdtsFramesByEarliestDts:function(e,t,i){return t.minSegmentDts>=i?e:(t.minSegmentDts=1/0,e.filter(function(e){return e.dts>=i&&(t.minSegmentDts=Math.min(t.minSegmentDts,e.dts),t.minSegmentPts=t.minSegmentDts,!0)}))},generateSampleTable:function(e){for(var t,i=[],s=0;s<e.length;s++)t=e[s],i.push({size:t.data.byteLength,duration:1024});return i},concatenateFrameData:function(e){for(var t,i=0,s=new Uint8Array(function(e){for(var t=0,i=0;i<e.length;i++)t+=e[i].data.byteLength;return t}(e)),r=0;r<e.length;r++)t=e[r],s.set(t.data,i),i+=t.data.byteLength;return s}},Re=c.ONE_SECOND_IN_TS,Le={clearDtsInfo:function(e){delete e.minSegmentDts,delete e.maxSegmentDts,delete e.minSegmentPts,delete e.maxSegmentPts},calculateTrackBaseMediaDecodeTime:function(e,t){var i=e.minSegmentDts;return t||(i-=e.timelineStartInfo.dts),t=e.timelineStartInfo.baseMediaDecodeTime,t+=i,t=Math.max(0,t),"audio"===e.type&&(t*=e.samplerate/Re,t=Math.floor(t)),t},collectDtsInfo:function(e,t){"number"==typeof t.pts&&(void 0===e.timelineStartInfo.pts&&(e.timelineStartInfo.pts=t.pts),void 0===e.minSegmentPts?e.minSegmentPts=t.pts:e.minSegmentPts=Math.min(e.minSegmentPts,t.pts),void 0===e.maxSegmentPts?e.maxSegmentPts=t.pts:e.maxSegmentPts=Math.max(e.maxSegmentPts,t.pts)),"number"==typeof t.dts&&(void 0===e.timelineStartInfo.dts&&(e.timelineStartInfo.dts=t.dts),void 0===e.minSegmentDts?e.minSegmentDts=t.dts:e.minSegmentDts=Math.min(e.minSegmentDts,t.dts),void 0===e.maxSegmentDts?e.maxSegmentDts=t.dts:e.maxSegmentDts=Math.max(e.maxSegmentDts,t.dts))}},De={parseSei:function(e){for(var t=0,i={payloadType:-1,payloadSize:0},s=0,r=0;t<e.byteLength&&128!==e[t];){for(;255===e[t];)s+=255,t++;for(s+=e[t++];255===e[t];)r+=255,t++;if(r+=e[t++],!i.payload&&4===s){if("GA94"===String.fromCharCode(e[t+3],e[t+4],e[t+5],e[t+6])){i.payloadType=s,i.payloadSize=r,i.payload=e.subarray(t,t+r);break}i.payload=void 0}t+=r,r=s=0}return i},parseUserData:function(e){return 181!==e.payload[0]||49!=(e.payload[1]<<8|e.payload[2])||"GA94"!==String.fromCharCode(e.payload[3],e.payload[4],e.payload[5],e.payload[6])||3!==e.payload[7]?null:e.payload.subarray(8,e.payload.length-1)},parseCaptionPackets:function(e,t){var i,s,r,n,a=[];if(64&t[0])for(s=31&t[0],i=0;i<s;i++)n={type:3&t[2+(r=3*i)],pts:e},4&t[2+r]&&(n.ccData=t[3+r]<<8|t[4+r],a.push(n));return a},discardEmulationPreventionBytes:function(e){for(var t=e.byteLength,i=[],s=1;s<t-2;)0===e[s]&&0===e[s+1]&&3===e[s+2]?(i.push(s+2),s+=2):s++;if(0===i.length)return e;for(var r=t-i.length,n=new Uint8Array(r),a=0,s=0;s<r;a++,s++)a===i[0]&&(a++,i.shift()),n[s]=e[a];return n},USER_DATA_REGISTERED_ITU_T_T35:4},p=i,Ue=De,Be=((n.prototype=new p).push=function(e){var t;"sei_rbsp"===e.nalUnitType&&(t=Ue.parseSei(e.escapedRBSP)).payload&&t.payloadType===Ue.USER_DATA_REGISTERED_ITU_T_T35&&(t=Ue.parseUserData(t))&&(e.dts<this.latestDts_?this.ignoreNextEqualDts_=!0:e.dts===this.latestDts_&&this.ignoreNextEqualDts_?(this.numSameDts_--,this.numSameDts_||(this.ignoreNextEqualDts_=!1)):(t=Ue.parseCaptionPackets(e.pts,t),this.captionPackets_=this.captionPackets_.concat(t),this.latestDts_!==e.dts&&(this.numSameDts_=0),this.numSameDts_++,this.latestDts_=e.dts))},n.prototype.flushCCStreams=function(t){this.ccStreams_.forEach(function(e){return"flush"===t?e.flush():e.partialFlush()},this)},n.prototype.flushStream=function(e){this.captionPackets_.length&&(this.captionPackets_.forEach(function(e,t){e.presortIndex=t}),this.captionPackets_.sort(function(e,t){return e.pts===t.pts?e.presortIndex-t.presortIndex:e.pts-t.pts}),this.captionPackets_.forEach(function(e){e.type<2?this.dispatchCea608Packet(e):this.dispatchCea708Packet(e)},this),this.captionPackets_.length=0),this.flushCCStreams(e)},n.prototype.flush=function(){return this.flushStream("flush")},n.prototype.partialFlush=function(){return this.flushStream("partialFlush")},n.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(e){e.reset()})},n.prototype.dispatchCea608Packet=function(e){this.setsTextOrXDSActive(e)?this.activeCea608Channel_[e.type]=null:this.setsChannel1Active(e)?this.activeCea608Channel_[e.type]=0:this.setsChannel2Active(e)&&(this.activeCea608Channel_[e.type]=1),null!==this.activeCea608Channel_[e.type]&&this.ccStreams_[(e.type<<1)+this.activeCea608Channel_[e.type]].push(e)},n.prototype.setsChannel1Active=function(e){return 4096==(30720&e.ccData)},n.prototype.setsChannel2Active=function(e){return 6144==(30720&e.ccData)},n.prototype.setsTextOrXDSActive=function(e){return 256==(28928&e.ccData)||4138==(30974&e.ccData)||6186==(30974&e.ccData)},n.prototype.dispatchCea708Packet=function(e){this.parse708captions_&&this.cc708Stream_.push(e)},{127:9834,4128:32,4129:160,4133:8230,4138:352,4140:338,4144:9608,4145:8216,4146:8217,4147:8220,4148:8221,4149:8226,4153:8482,4154:353,4156:339,4157:8480,4159:376,4214:8539,4215:8540,4216:8541,4217:8542,4218:9168,4219:9124,4220:9123,4221:9135,4222:9126,4223:9121,4256:12600}),m=(a.prototype.reset=function(){this.clearText(),this.pendingNewLine=!1,this.winAttr={},this.penAttr={},this.penLoc={},this.penColor={},this.visible=0,this.rowLock=0,this.columnLock=0,this.priority=0,this.relativePositioning=0,this.anchorVertical=0,this.anchorHorizontal=0,this.anchorPoint=0,this.rowCount=1,this.virtualRowCount=this.rowCount+1,this.columnCount=41,this.windowStyle=0,this.penStyle=0},a.prototype.getText=function(){return this.rows.join("\n")},a.prototype.clearText=function(){this.rows=[""],this.rowIdx=0},a.prototype.newLine=function(e){for(this.rows.length>=this.virtualRowCount&&"function"==typeof this.beforeRowOverflow&&this.beforeRowOverflow(e),0<this.rows.length&&(this.rows.push(""),this.rowIdx++);this.rows.length>this.virtualRowCount;)this.rows.shift(),this.rowIdx--},a.prototype.isEmpty=function(){return 0===this.rows.length||1===this.rows.length&&""===this.rows[0]},a.prototype.addText=function(e){this.rows[this.rowIdx]+=e},a.prototype.backspace=function(){var e;this.isEmpty()||(e=this.rows[this.rowIdx],this.rows[this.rowIdx]=e.substr(0,e.length-1))},Te.prototype.init=function(e,t){this.startPts=e;for(var i=0;i<8;i++)this.windows[i]=new a(i),"function"==typeof t&&(this.windows[i].beforeRowOverflow=t)},Te.prototype.setCurrentWindow=function(e){this.currentWindow=this.windows[e]},Te.prototype.createTextDecoder=function(t){if("undefined"==typeof TextDecoder)this.stream.trigger("log",{level:"warn",message:"The `encoding` option is unsupported without TextDecoder support"});else try{this.textDecoder_=new TextDecoder(t)}catch(e){this.stream.trigger("log",{level:"warn",message:"TextDecoder could not be created with "+t+" encoding. "+e})}},function(e){e=e||{},m.prototype.init.call(this);var t,i=this,s=e.captionServices||{},r={};Object.keys(s).forEach(e=>{t=s[e],/^SERVICE/.test(e)&&(r[e]=t.encoding)}),this.serviceEncodings=r,this.current708Packet=null,this.services={},this.push=function(e){(3===e.type||null===i.current708Packet)&&i.new708Packet(),i.add708Bytes(e)}}),Fe=(m.prototype=new p,m.prototype.new708Packet=function(){null!==this.current708Packet&&this.push708Packet(),this.current708Packet={data:[],ptsVals:[]}},m.prototype.add708Bytes=function(e){var t=e.ccData,i=t>>>8,t=255&t;this.current708Packet.ptsVals.push(e.pts),this.current708Packet.data.push(i),this.current708Packet.data.push(t)},m.prototype.push708Packet=function(){var e,t=this.current708Packet,i=t.data,s=null,r=0,n=i[r++];for(t.seq=n>>6,t.sizeCode=63&n;r<i.length;r++)e=31&(n=i[r++]),7===(s=n>>5)&&0<e&&(s=i[r++]),this.pushServiceBlock(s,r,e),0<e&&(r+=e-1)},m.prototype.pushServiceBlock=function(e,t,i){for(var s,r=t,n=this.current708Packet.data,a=(a=this.services[e])||this.initService(e,r);r<t+i&&r<n.length;r++)s=n[r],o(s)?r=this.handleText(r,a):24===s?r=this.multiByteCharacter(r,a):16===s?r=this.extendedCommands(r,a):128<=s&&s<=135?r=this.setCurrentWindow(r,a):152<=s&&s<=159?r=this.defineWindow(r,a):136===s?r=this.clearWindows(r,a):140===s?r=this.deleteWindows(r,a):137===s?r=this.displayWindows(r,a):138===s?r=this.hideWindows(r,a):139===s?r=this.toggleWindows(r,a):151===s?r=this.setWindowAttributes(r,a):144===s?r=this.setPenAttributes(r,a):145===s?r=this.setPenColor(r,a):146===s?r=this.setPenLocation(r,a):143===s?a=this.reset(r,a):8===s?a.currentWindow.backspace():12===s?a.currentWindow.clearText():13===s?a.currentWindow.pendingNewLine=!0:14===s?a.currentWindow.clearText():141===s&&r++},m.prototype.extendedCommands=function(e,t){var i=this.current708Packet.data[++e];return e=o(i)?this.handleText(e,t,{isExtended:!0}):e},m.prototype.getPts=function(e){return this.current708Packet.ptsVals[Math.floor(e/2)]},m.prototype.initService=function(t,e){var i,s="SERVICE"+t,r=this;return s in this.serviceEncodings&&(i=this.serviceEncodings[s]),this.services[t]=new Te(t,i,r),this.services[t].init(this.getPts(e),function(e){r.flushDisplayed(e,r.services[t])}),this.services[t]},m.prototype.handleText=function(e,t,i){var s,r=i&&i.isExtended,i=i&&i.isMultiByte,n=this.current708Packet.data,a=r?4096:0,o=n[e],n=n[e+1],l=t.currentWindow,n=t.textDecoder_&&!r?(i?(s=[o,n],e++):s=[o],t.textDecoder_.decode(new Uint8Array(s))):(i=Be[r=a|o]||r,4096&r&&r===i?"":String.fromCharCode(i));return l.pendingNewLine&&!l.isEmpty()&&l.newLine(this.getPts(e)),l.pendingNewLine=!1,l.addText(n),e},m.prototype.multiByteCharacter=function(e,t){var i=this.current708Packet.data,s=i[e+1],i=i[e+2];return e=o(s)&&o(i)?this.handleText(++e,t,{isMultiByte:!0}):e},m.prototype.setCurrentWindow=function(e,t){var i=this.current708Packet.data[e];return t.setCurrentWindow(7&i),e},m.prototype.defineWindow=function(e,t){var i=this.current708Packet.data,s=i[e],t=(t.setCurrentWindow(7&s),t.currentWindow),s=i[++e];return t.visible=(32&s)>>5,t.rowLock=(16&s)>>4,t.columnLock=(8&s)>>3,t.priority=7&s,s=i[++e],t.relativePositioning=(128&s)>>7,t.anchorVertical=127&s,s=i[++e],t.anchorHorizontal=s,s=i[++e],t.anchorPoint=(240&s)>>4,t.rowCount=15&s,s=i[++e],t.columnCount=63&s,s=i[++e],t.windowStyle=(56&s)>>3,t.penStyle=7&s,t.virtualRowCount=t.rowCount+1,e},m.prototype.setWindowAttributes=function(e,t){var i=this.current708Packet.data,t=(i[e],t.currentWindow.winAttr),s=i[++e];return t.fillOpacity=(192&s)>>6,t.fillRed=(48&s)>>4,t.fillGreen=(12&s)>>2,t.fillBlue=3&s,s=i[++e],t.borderType=(192&s)>>6,t.borderRed=(48&s)>>4,t.borderGreen=(12&s)>>2,t.borderBlue=3&s,s=i[++e],t.borderType+=(128&s)>>5,t.wordWrap=(64&s)>>6,t.printDirection=(48&s)>>4,t.scrollDirection=(12&s)>>2,t.justify=3&s,s=i[++e],t.effectSpeed=(240&s)>>4,t.effectDirection=(12&s)>>2,t.displayEffect=3&s,e},m.prototype.flushDisplayed=function(e,t){for(var i=[],s=0;s<8;s++)t.windows[s].visible&&!t.windows[s].isEmpty()&&i.push(t.windows[s].getText());t.endPts=e,t.text=i.join("\n\n"),this.pushCaption(t),t.startPts=e},m.prototype.pushCaption=function(e){""!==e.text&&(this.trigger("data",{startPts:e.startPts,endPts:e.endPts,text:e.text,stream:"cc708_"+e.serviceNum}),e.text="",e.startPts=e.endPts)},m.prototype.displayWindows=function(e,t){var i=this.current708Packet.data[++e],s=this.getPts(e);this.flushDisplayed(s,t);for(var r=0;r<8;r++)i&1<<r&&(t.windows[r].visible=1);return e},m.prototype.hideWindows=function(e,t){var i=this.current708Packet.data[++e],s=this.getPts(e);this.flushDisplayed(s,t);for(var r=0;r<8;r++)i&1<<r&&(t.windows[r].visible=0);return e},m.prototype.toggleWindows=function(e,t){var i=this.current708Packet.data[++e],s=this.getPts(e);this.flushDisplayed(s,t);for(var r=0;r<8;r++)i&1<<r&&(t.windows[r].visible^=1);return e},m.prototype.clearWindows=function(e,t){var i=this.current708Packet.data[++e],s=this.getPts(e);this.flushDisplayed(s,t);for(var r=0;r<8;r++)i&1<<r&&t.windows[r].clearText();return e},m.prototype.deleteWindows=function(e,t){var i=this.current708Packet.data[++e],s=this.getPts(e);this.flushDisplayed(s,t);for(var r=0;r<8;r++)i&1<<r&&t.windows[r].reset();return e},m.prototype.setPenAttributes=function(e,t){var i=this.current708Packet.data,t=(i[e],t.currentWindow.penAttr),s=i[++e];return t.textTag=(240&s)>>4,t.offset=(12&s)>>2,t.penSize=3&s,s=i[++e],t.italics=(128&s)>>7,t.underline=(64&s)>>6,t.edgeType=(56&s)>>3,t.fontStyle=7&s,e},m.prototype.setPenColor=function(e,t){var i=this.current708Packet.data,t=(i[e],t.currentWindow.penColor),s=i[++e];return t.fgOpacity=(192&s)>>6,t.fgRed=(48&s)>>4,t.fgGreen=(12&s)>>2,t.fgBlue=3&s,s=i[++e],t.bgOpacity=(192&s)>>6,t.bgRed=(48&s)>>4,t.bgGreen=(12&s)>>2,t.bgBlue=3&s,s=i[++e],t.edgeRed=(48&s)>>4,t.edgeGreen=(12&s)>>2,t.edgeBlue=3&s,e},m.prototype.setPenLocation=function(e,t){var i=this.current708Packet.data,s=(i[e],t.currentWindow.penLoc);return t.currentWindow.pendingNewLine=!0,t=i[++e],s.row=15&t,t=i[++e],s.column=63&t,e},m.prototype.reset=function(e,t){var i=this.getPts(e);return this.flushDisplayed(i,t),this.initService(t.serviceNum,e)},{42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496}),je=14,He=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],g=function(e,t){g.prototype.init.call(this),this.field_=e||0,this.dataChannel_=t||0,this.name_="CC"+(1+(this.field_<<1|this.dataChannel_)),this.setConstants(),this.reset(),this.push=function(e){var t,i,s,r,n=32639&e.ccData;n===this.lastControlCode_?this.lastControlCode_=null:(4096==(61440&n)?this.lastControlCode_=n:n!==this.PADDING_&&(this.lastControlCode_=null),t=n>>>8,i=255&n,n!==this.PADDING_&&(n===this.RESUME_CAPTION_LOADING_?this.mode_="popOn":n===this.END_OF_CAPTION_?(this.mode_="popOn",this.clearFormatting(e.pts),this.flushDisplayed(e.pts),r=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=r,this.startPts_=e.pts):n===this.ROLL_UP_2_ROWS_?(this.rollUpRows_=2,this.setRollUp(e.pts)):n===this.ROLL_UP_3_ROWS_?(this.rollUpRows_=3,this.setRollUp(e.pts)):n===this.ROLL_UP_4_ROWS_?(this.rollUpRows_=4,this.setRollUp(e.pts)):n===this.CARRIAGE_RETURN_?(this.clearFormatting(e.pts),this.flushDisplayed(e.pts),this.shiftRowsUp_(),this.startPts_=e.pts):n===this.BACKSPACE_?"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1):n===this.ERASE_DISPLAYED_MEMORY_?(this.flushDisplayed(e.pts),this.displayed_=h()):n===this.ERASE_NON_DISPLAYED_MEMORY_?this.nonDisplayed_=h():n===this.RESUME_DIRECT_CAPTIONING_?("paintOn"!==this.mode_&&(this.flushDisplayed(e.pts),this.displayed_=h()),this.mode_="paintOn",this.startPts_=e.pts):this.isSpecialCharacter(t,i)?(s=Se((t=(3&t)<<8)|i),this[this.mode_](e.pts,s),this.column_++):this.isExtCharacter(t,i)?("popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1),s=Se((t=(3&t)<<8)|i),this[this.mode_](e.pts,s),this.column_++):this.isMidRowCode(t,i)?(this.clearFormatting(e.pts),this[this.mode_](e.pts," "),this.column_++,14==(14&i)&&this.addFormatting(e.pts,["i"]),1==(1&i)&&this.addFormatting(e.pts,["u"])):this.isOffsetControlCode(t,i)?this.column_+=3&i:this.isPAC(t,i)?(r=He.indexOf(7968&n),"rollUp"===this.mode_&&(r-this.rollUpRows_+1<0&&(r=this.rollUpRows_-1),this.setRollUp(e.pts,r)),r!==this.row_&&(this.clearFormatting(e.pts),this.row_=r),1&i&&-1===this.formatting_.indexOf("u")&&this.addFormatting(e.pts,["u"]),16==(16&n)&&(this.column_=4*((14&n)>>1)),this.isColorPAC(i)&&14==(14&i)&&this.addFormatting(e.pts,["i"])):this.isNormalChar(t)&&(0===i&&(i=null),s=Se(t),s+=Se(i),this[this.mode_](e.pts,s),this.column_+=s.length)))}},p=(g.prototype=new p,g.prototype.flushDisplayed=function(e){var t=this.displayed_.map(function(e,t){try{return e.trim()}catch(e){return this.trigger("log",{level:"warn",message:"Skipping a malformed 608 caption at index "+t+"."}),""}},this).join("\n").replace(/^\n+|\n+$/g,"");t.length&&this.trigger("data",{startPts:this.startPts_,endPts:e,text:t,stream:this.name_})},g.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=h(),this.nonDisplayed_=h(),this.lastControlCode_=null,this.column_=0,this.row_=je,this.rollUpRows_=2,this.formatting_=[]},g.prototype.setConstants=function(){0===this.dataChannel_?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):1===this.dataChannel_&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=32|this.CONTROL_,this.END_OF_CAPTION_=47|this.CONTROL_,this.ROLL_UP_2_ROWS_=37|this.CONTROL_,this.ROLL_UP_3_ROWS_=38|this.CONTROL_,this.ROLL_UP_4_ROWS_=39|this.CONTROL_,this.CARRIAGE_RETURN_=45|this.CONTROL_,this.RESUME_DIRECT_CAPTIONING_=41|this.CONTROL_,this.BACKSPACE_=33|this.CONTROL_,this.ERASE_DISPLAYED_MEMORY_=44|this.CONTROL_,this.ERASE_NON_DISPLAYED_MEMORY_=46|this.CONTROL_},g.prototype.isSpecialCharacter=function(e,t){return e===this.EXT_&&48<=t&&t<=63},g.prototype.isExtCharacter=function(e,t){return(e===this.EXT_+1||e===this.EXT_+2)&&32<=t&&t<=63},g.prototype.isMidRowCode=function(e,t){return e===this.EXT_&&32<=t&&t<=47},g.prototype.isOffsetControlCode=function(e,t){return e===this.OFFSET_&&33<=t&&t<=35},g.prototype.isPAC=function(e,t){return e>=this.BASE_&&e<this.BASE_+8&&64<=t&&t<=127},g.prototype.isColorPAC=function(e){return 64<=e&&e<=79||96<=e&&e<=127},g.prototype.isNormalChar=function(e){return 32<=e&&e<=127},g.prototype.setRollUp=function(e,t){if("rollUp"!==this.mode_&&(this.row_=je,this.mode_="rollUp",this.flushDisplayed(e),this.nonDisplayed_=h(),this.displayed_=h()),void 0!==t&&t!==this.row_)for(var i=0;i<this.rollUpRows_;i++)this.displayed_[t-i]=this.displayed_[this.row_-i],this.displayed_[this.row_-i]="";void 0===t&&(t=this.row_),this.topRow_=t-this.rollUpRows_+1},g.prototype.addFormatting=function(e,t){this.formatting_=this.formatting_.concat(t);t=t.reduce(function(e,t){return e+"<"+t+">"},"");this[this.mode_](e,t)},g.prototype.clearFormatting=function(e){var t;this.formatting_.length&&(t=this.formatting_.reverse().reduce(function(e,t){return e+"</"+t+">"},""),this.formatting_=[],this[this.mode_](e,t))},g.prototype.popOn=function(e,t){var i=this.nonDisplayed_[this.row_];this.nonDisplayed_[this.row_]=i+=t},g.prototype.rollUp=function(e,t){var i=this.displayed_[this.row_];this.displayed_[this.row_]=i+=t},g.prototype.shiftRowsUp_=function(){for(var e=0;e<this.topRow_;e++)this.displayed_[e]="";for(e=this.row_+1;e<je+1;e++)this.displayed_[e]="";for(e=this.topRow_;e<this.row_;e++)this.displayed_[e]=this.displayed_[e+1];this.displayed_[this.row_]=""},g.prototype.paintOn=function(e,t){var i=this.displayed_[this.row_];this.displayed_[this.row_]=i+=t},{CaptionStream:n,Cea608Stream:g,Cea708Stream:m}),qe={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},Ve=i,$e=8589934592,We=4294967296;Ee.prototype=new Ve;function Ge(e,t,i){for(var s="",r=t;r<i;r++)s+="%"+("00"+e[r].toString(16)).slice(-2);return s}function f(e,t,i){return decodeURIComponent(Ge(e,t,i))}function y(e,t,i){return unescape(Ge(e,t,i))}function _(e){return e[0]<<21|e[1]<<14|e[2]<<7|e[3]}var ze,Xe,Ke,Ve=Ee,Ye=we,Qe=(e,t,i)=>{if(e)for(var s=i;s<e.length;s++)if(e[s]===t)return s;return-1},Je=3,v={APIC:function(e){var t,i=1;e.data[0]!==Je||(t=Qe(e.data,0,1))<0||(e.mimeType=y(e.data,1,t),e.pictureType=e.data[i=t+1],(t=Qe(e.data,0,++i))<0)||(e.description=f(e.data,i,t),i=t+1,"--\x3e"===e.mimeType?e.url=y(e.data,i,e.data.length):e.pictureData=e.data.subarray(i,e.data.length))},"T*":function(e){e.data[0]===Je&&(e.value=f(e.data,1,e.data.length).replace(/\0*$/,""),e.values=e.value.split("\0"))},TXXX:function(e){var t;e.data[0]===Je&&-1!==(t=Qe(e.data,0,1))&&(e.description=f(e.data,1,t),e.value=f(e.data,t+1,e.data.length).replace(/\0*$/,""),e.data=e.value)},"W*":function(e){e.url=y(e.data,0,e.data.length).replace(/\0.*$/,"")},WXXX:function(e){var t;e.data[0]===Je&&-1!==(t=Qe(e.data,0,1))&&(e.description=f(e.data,1,t),e.url=y(e.data,t+1,e.data.length).replace(/\0.*$/,""))},PRIV:function(e){for(var t=0;t<e.data.length;t++)if(0===e.data[t]){e.owner=y(e.data,0,t);break}e.privateData=e.data.subarray(t+1),e.data=e.privateData}},b={parseId3Frames:function(e){var t,i=10,s=0,r=[];if(!(e.length<10||e[0]!=="I".charCodeAt(0)||e[1]!=="D".charCodeAt(0)||e[2]!=="3".charCodeAt(0))){s=_(e.subarray(6,10));s+=10,64&e[5]&&(i=(i+=4)+_(e.subarray(10,14)),s-=_(e.subarray(16,20)));do{if((t=_(e.subarray(i+4,i+8)))<1)break;var n={id:String.fromCharCode(e[i],e[i+1],e[i+2],e[i+3]),data:e.subarray(i+10,i+t+10)}}while(n.key=n.id,v[n.id]?v[n.id](n):"T"===n.id[0]?v["T*"](n):"W"===n.id[0]&&v["W*"](n),r.push(n),(i=i+10+t)<s);return r}},parseSyncSafeInteger:_,frameParsers:v},T=i,Ze=qe,S=b,et=function(e){var t,i={descriptor:e&&e.descriptor},l=0,d=[],h=0;if(et.prototype.init.call(this),this.dispatchType=Ze.METADATA_STREAM_TYPE.toString(16),i.descriptor)for(t=0;t<i.descriptor.length;t++)this.dispatchType+=("00"+i.descriptor[t].toString(16)).slice(-2);this.push=function(e){var t,i,s,r,n,a,o;if("timed-metadata"===e.type)if(e.dataAlignmentIndicator&&(h=0,d.length=0),0===d.length&&(e.data.length<10||e.data[0]!=="I".charCodeAt(0)||e.data[1]!=="D".charCodeAt(0)||e.data[2]!=="3".charCodeAt(0)))this.trigger("log",{level:"warn",message:"Skipping unrecognized metadata packet"});else if(d.push(e),h+=e.data.byteLength,1===d.length&&(l=S.parseSyncSafeInteger(e.data.subarray(6,10)),l+=10),!(h<l)){for(t={data:new Uint8Array(l),frames:[],pts:d[0].pts,dts:d[0].dts},r=0;r<l;)t.data.set(d[0].data.subarray(0,l-r),r),r+=d[0].data.byteLength,h-=d[0].data.byteLength,d.shift();i=10,64&t.data[5]&&(i=(i+=4)+S.parseSyncSafeInteger(t.data.subarray(10,14)),l-=S.parseSyncSafeInteger(t.data.subarray(16,20)));do{if((s=S.parseSyncSafeInteger(t.data.subarray(i+4,i+8)))<1){this.trigger("log",{level:"warn",message:"Malformed ID3 frame encountered. Skipping remaining metadata parsing."});break}}while((o={id:String.fromCharCode(t.data[i],t.data[i+1],t.data[i+2],t.data[i+3]),data:t.data.subarray(i+10,i+s+10)}).key=o.id,S.frameParsers[o.id]?S.frameParsers[o.id](o):"T"===o.id[0]?S.frameParsers["T*"](o):"W"===o.id[0]&&S.frameParsers["W*"](o),"com.apple.streaming.transportStreamTimestamp"===o.owner&&(a=(1&(n=o.data)[3])<<30|n[4]<<22|n[5]<<14|n[6]<<6|n[7]>>>2,a=(a*=4)+(3&n[7]),o.timeStamp=a,void 0===t.pts&&void 0===t.dts&&(t.pts=o.timeStamp,t.dts=o.timeStamp),this.trigger("timestamp",o)),t.frames.push(o),(i=i+10+s)<l);this.trigger("data",t)}}},b=(et.prototype=new T,et),T=i,tt=p,w=qe,it=function(){var r=new Uint8Array(188),n=0;it.prototype.init.call(this),this.push=function(e){var t,i=0,s=188;for(n?((t=new Uint8Array(e.byteLength+n)).set(r.subarray(0,n)),t.set(e,n),n=0):t=e;s<t.byteLength;)71===t[i]&&71===t[s]?(this.trigger("data",t.subarray(i,s)),i+=188,s+=188):(i++,s++);i<t.byteLength&&(r.set(t.subarray(i),0),n=t.byteLength-i)},this.flush=function(){188===n&&71===r[0]&&(this.trigger("data",r),n=0),this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.reset=function(){n=0,this.trigger("reset")}},st=(it.prototype=new T,(ze=function(){var s,r,n,a;ze.prototype.init.call(this),(a=this).packetsWaitingForPmt=[],this.programMapTable=void 0,s=function(e,t){var i=0;t.payloadUnitStartIndicator&&(i+=e[i]+1),("pat"===t.type?r:n)(e.subarray(i),t)},r=function(e,t){t.section_number=e[7],t.last_section_number=e[8],a.pmtPid=(31&e[10])<<8|e[11],t.pmtPid=a.pmtPid},n=function(e,t){var i,s;if(1&e[5]){for(a.programMapTable={video:null,audio:null,"timed-metadata":{}},i=3+((15&e[1])<<8|e[2])-4,s=12+((15&e[10])<<8|e[11]);s<i;){var r=e[s],n=(31&e[s+1])<<8|e[s+2];r===w.H264_STREAM_TYPE&&null===a.programMapTable.video?a.programMapTable.video=n:r===w.ADTS_STREAM_TYPE&&null===a.programMapTable.audio?a.programMapTable.audio=n:r===w.METADATA_STREAM_TYPE&&(a.programMapTable["timed-metadata"][n]=r),s+=5+((15&e[s+3])<<8|e[s+4])}t.programMapTable=a.programMapTable}},this.push=function(e){var t={},i=4;if(t.payloadUnitStartIndicator=!!(64&e[1]),t.pid=31&e[1],t.pid<<=8,t.pid|=e[2],1<(48&e[3])>>>4&&(i+=e[i]+1),0===t.pid)t.type="pat",s(e.subarray(i),t),this.trigger("data",t);else if(t.pid===this.pmtPid)for(t.type="pmt",s(e.subarray(i),t),this.trigger("data",t);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else void 0===this.programMapTable?this.packetsWaitingForPmt.push([e,i,t]):this.processPes_(e,i,t)},this.processPes_=function(e,t,i){i.pid===this.programMapTable.video?i.streamType=w.H264_STREAM_TYPE:i.pid===this.programMapTable.audio?i.streamType=w.ADTS_STREAM_TYPE:i.streamType=this.programMapTable["timed-metadata"][i.pid],i.type="pes",i.data=e.subarray(t),this.trigger("data",i)}}).prototype=new T,ze.STREAM_TYPES={h264:27,adts:15},(Xe=function(){function s(e,t,i){var s,r=new Uint8Array(e.size),n={type:t},a=0,o=0;if(e.data.length&&!(e.size<9)){for(n.trackId=e.data[0].pid,a=0;a<e.data.length;a++)s=e.data[a],r.set(s.data,o),o+=s.data.byteLength;d(r,n),t="video"===t||n.packetLength<=e.size,(i||t)&&(e.size=0,e.data.length=0),t&&l.trigger("data",n)}}var t,l=this,r=!1,n={data:[],size:0},a={data:[],size:0},o={data:[],size:0},d=function(e,t){var i=e[0]<<16|e[1]<<8|e[2];t.data=new Uint8Array,1==i&&(t.packetLength=6+(e[4]<<8|e[5]),t.dataAlignmentIndicator=0!=(4&e[6]),192&(i=e[7])&&(t.pts=(14&e[9])<<27|(255&e[10])<<20|(254&e[11])<<12|(255&e[12])<<5|(254&e[13])>>>3,t.pts*=4,t.pts+=(6&e[13])>>>1,t.dts=t.pts,64&i)&&(t.dts=(14&e[14])<<27|(255&e[15])<<20|(254&e[16])<<12|(255&e[17])<<5|(254&e[18])>>>3,t.dts*=4,t.dts+=(6&e[18])>>>1),t.data=e.subarray(9+e[8]))};Xe.prototype.init.call(this),this.push=function(i){({pat:function(){},pes:function(){var e,t;switch(i.streamType){case w.H264_STREAM_TYPE:e=n,t="video";break;case w.ADTS_STREAM_TYPE:e=a,t="audio";break;case w.METADATA_STREAM_TYPE:e=o,t="timed-metadata";break;default:return}i.payloadUnitStartIndicator&&s(e,t,!0),e.data.push(i),e.size+=i.data.byteLength},pmt:function(){var e={type:"metadata",tracks:[]};null!==(t=i.programMapTable).video&&e.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+t.video,codec:"avc",type:"video"}),null!==t.audio&&e.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+t.audio,codec:"adts",type:"audio"}),r=!0,l.trigger("data",e)}})[i.type]()},this.reset=function(){n.size=0,n.data.length=0,a.size=0,a.data.length=0,this.trigger("reset")},this.flushStreams_=function(){s(n,"video"),s(a,"audio"),s(o,"timed-metadata")},this.flush=function(){var e;!r&&t&&(e={type:"metadata",tracks:[]},null!==t.video&&e.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+t.video,codec:"avc",type:"video"}),null!==t.audio&&e.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+t.audio,codec:"adts",type:"audio"}),l.trigger("data",e)),r=!1,this.flushStreams_(),this.trigger("done")}}).prototype=new T,{PAT_PID:0,MP2T_PACKET_LENGTH:188,TransportPacketStream:it,TransportParseStream:ze,ElementaryStream:Xe,TimestampRolloverStream:Ve,CaptionStream:tt.CaptionStream,Cea608Stream:tt.Cea608Stream,Cea708Stream:tt.Cea708Stream,MetadataStream:b});for(Ke in w)w.hasOwnProperty(Ke)&&(st[Ke]=w[Ke]);var rt,nt,T=st,Ve=i,at=c.ONE_SECOND_IN_TS,ot=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],lt=function(l){var d,h=0;lt.prototype.init.call(this),this.skipWarn_=function(e,t){this.trigger("log",{level:"warn",message:`adts skiping bytes ${e} to ${t} in frame ${h} outside syncword`})},this.push=function(e){var t,i,s,r,n,a,o=0;if(l||(h=0),"audio"===e.type){for(d&&d.length?(s=d,(d=new Uint8Array(s.byteLength+e.data.byteLength)).set(s),d.set(e.data,s.byteLength)):d=e.data;o+7<d.length;)if(255!==d[o]||240!=(246&d[o+1]))"number"!=typeof a&&(a=o),o++;else{if("number"==typeof a&&(this.skipWarn_(a,o),a=null),i=2*(1&~d[o+1]),t=(3&d[o+3])<<11|d[o+4]<<3|(224&d[o+5])>>5,n=(r=1024*(1+(3&d[o+6])))*at/ot[(60&d[o+2])>>>2],d.byteLength-o<t)break;this.trigger("data",{pts:e.pts+h*n,dts:e.dts+h*n,sampleCount:r,audioobjecttype:1+(d[o+2]>>>6&3),channelcount:(1&d[o+2])<<2|(192&d[o+3])>>>6,samplerate:ot[(60&d[o+2])>>>2],samplingfrequencyindex:(60&d[o+2])>>>2,samplesize:16,data:d.subarray(o+7+i,o+t)}),h++,o+=t}"number"==typeof a&&(this.skipWarn_(a,o),a=null),d=d.subarray(o)}},this.flush=function(){h=0,this.trigger("done")},this.reset=function(){d=void 0,this.trigger("reset")},this.endTimeline=function(){d=void 0,this.trigger("endedtimeline")}},tt=(lt.prototype=new Ve,lt),b=i,dt=function(s){var r=s.byteLength,n=0,a=0;this.length=function(){return 8*r},this.bitsAvailable=function(){return 8*r+a},this.loadWord=function(){var e=s.byteLength-r,t=new Uint8Array(4),i=Math.min(4,r);if(0===i)throw new Error("no bytes available");t.set(s.subarray(e,e+i)),n=new DataView(t.buffer).getUint32(0),a=8*i,r-=i},this.skipBits=function(e){var t;e<a||(e=(e-=a)-8*(t=Math.floor(e/8)),r-=t,this.loadWord()),n<<=e,a-=e},this.readBits=function(e){var t=Math.min(a,e),i=n>>>32-t;return 0<(a-=t)?n<<=t:0<r&&this.loadWord(),0<(t=e-t)?i<<t|this.readBits(t):i},this.skipLeadingZeros=function(){for(var e=0;e<a;++e)if(0!=(n&2147483648>>>e))return n<<=e,a-=e,e;return this.loadWord(),e+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var e=this.skipLeadingZeros();return this.readBits(e+1)-1},this.readExpGolomb=function(){var e=this.readUnsignedExpGolomb();return 1&e?1+e>>>1:-1*(e>>>1)},this.readBoolean=function(){return 1===this.readBits(1)},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()},ht=function(){var s,r,n=0;ht.prototype.init.call(this),this.push=function(e){for(var t,i=(r=r?((t=new Uint8Array(r.byteLength+e.data.byteLength)).set(r),t.set(e.data,r.byteLength),t):e.data).byteLength;n<i-3;n++)if(1===r[n+2]){s=n+5;break}for(;s<i;)switch(r[s]){case 0:if(0!==r[s-1])s+=2;else if(0!==r[s-2])s++;else{for(n+3!==s-2&&this.trigger("data",r.subarray(n+3,s-2));1!==r[++s]&&s<i;);n=s-2,s+=3}break;case 1:0!==r[s-1]||0!==r[s-2]?s+=3:(this.trigger("data",r.subarray(n+3,s-2)),n=s-2,s+=3);break;default:s+=3}r=r.subarray(n),s-=n,n=0},this.reset=function(){r=null,n=0,this.trigger("reset")},this.flush=function(){r&&3<r.byteLength&&this.trigger("data",r.subarray(n+3)),r=null,n=0,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")}};ht.prototype=new b,nt={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},(rt=function(){var i,s,r,n,a,o,g,t=new ht;rt.prototype.init.call(this),(i=this).push=function(e){"video"===e.type&&(s=e.trackId,r=e.pts,n=e.dts,t.push(e))},t.on("data",function(e){var t={trackId:s,pts:r,dts:n,data:e,nalUnitTypeCode:31&e[0]};switch(t.nalUnitTypeCode){case 5:t.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:t.nalUnitType="sei_rbsp",t.escapedRBSP=a(e.subarray(1));break;case 7:t.nalUnitType="seq_parameter_set_rbsp",t.escapedRBSP=a(e.subarray(1)),t.config=o(t.escapedRBSP);break;case 8:t.nalUnitType="pic_parameter_set_rbsp";break;case 9:t.nalUnitType="access_unit_delimiter_rbsp"}i.trigger("data",t)}),t.on("done",function(){i.trigger("done")}),t.on("partialdone",function(){i.trigger("partialdone")}),t.on("reset",function(){i.trigger("reset")}),t.on("endedtimeline",function(){i.trigger("endedtimeline")}),this.flush=function(){t.flush()},this.partialFlush=function(){t.partialFlush()},this.reset=function(){t.reset()},this.endTimeline=function(){t.endTimeline()},g=function(e,t){for(var i=8,s=8,r=0;r<e;r++)i=0===(s=0!==s?(i+t.readExpGolomb()+256)%256:s)?i:s},a=function(e){for(var t=e.byteLength,i=[],s=1;s<t-2;)0===e[s]&&0===e[s+1]&&3===e[s+2]?(i.push(s+2),s+=2):s++;if(0===i.length)return e;for(var r=t-i.length,n=new Uint8Array(r),a=0,s=0;s<r;a++,s++)a===i[0]&&(a++,i.shift()),n[s]=e[a];return n},o=function(e){var t,i,s,r,n,a,o=0,l=0,d=0,h=0,u=[1,1],c=new dt(e),e=c.readUnsignedByte(),p=c.readUnsignedByte(),m=c.readUnsignedByte();if(c.skipUnsignedExpGolomb(),nt[e]&&(3===(i=c.readUnsignedExpGolomb())&&c.skipBits(1),c.skipUnsignedExpGolomb(),c.skipUnsignedExpGolomb(),c.skipBits(1),c.readBoolean()))for(n=3!==i?8:12,a=0;a<n;a++)c.readBoolean()&&g(a<6?16:64,c);if(c.skipUnsignedExpGolomb(),0===(i=c.readUnsignedExpGolomb()))c.readUnsignedExpGolomb();else if(1===i)for(c.skipBits(1),c.skipExpGolomb(),c.skipExpGolomb(),t=c.readUnsignedExpGolomb(),a=0;a<t;a++)c.skipExpGolomb();if(c.skipUnsignedExpGolomb(),c.skipBits(1),i=c.readUnsignedExpGolomb(),s=c.readUnsignedExpGolomb(),0===(r=c.readBits(1))&&c.skipBits(1),c.skipBits(1),c.readBoolean()&&(o=c.readUnsignedExpGolomb(),l=c.readUnsignedExpGolomb(),d=c.readUnsignedExpGolomb(),h=c.readUnsignedExpGolomb()),c.readBoolean()&&c.readBoolean()){switch(c.readUnsignedByte()){case 1:u=[1,1];break;case 2:u=[12,11];break;case 3:u=[10,11];break;case 4:u=[16,11];break;case 5:u=[40,33];break;case 6:u=[24,11];break;case 7:u=[20,11];break;case 8:u=[32,11];break;case 9:u=[80,33];break;case 10:u=[18,11];break;case 11:u=[15,11];break;case 12:u=[64,33];break;case 13:u=[160,99];break;case 14:u=[4,3];break;case 15:u=[3,2];break;case 16:u=[2,1];break;case 255:u=[c.readUnsignedByte()<<8|c.readUnsignedByte(),c.readUnsignedByte()<<8|c.readUnsignedByte()]}u&&(u[0],u[1])}return{profileIdc:e,levelIdc:m,profileCompatibility:p,width:16*(i+1)-2*o-2*l,height:(2-r)*(s+1)*16-2*d-2*h,sarRatio:u}}}).prototype=new b;function ut(e){return e[0]<<21|e[1]<<14|e[2]<<7|e[3]}var Ve=rt,ct=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],pt=function(e,t){var i=0<=(i=e[t+6]<<21|e[t+7]<<14|e[t+8]<<7|e[t+9])?i:0;return(16&e[t+5])>>4?20+i:10+i},mt=function(e,t){return e.length-t<10||e[t]!=="I".charCodeAt(0)||e[t+1]!=="D".charCodeAt(0)||e[t+2]!=="3".charCodeAt(0)?t:(t+=pt(e,t),mt(e,t))},gt=function(e,t,i){for(var s="",r=t;r<i;r++)s+="%"+("00"+e[r].toString(16)).slice(-2);return s},b={isLikelyAacData:function(e){var t=mt(e,0);return e.length>=t+2&&255==(255&e[t])&&240==(240&e[t+1])&&16==(22&e[t+1])},parseId3TagSize:pt,parseAdtsSize:function(e,t){var i=(224&e[t+5])>>5,s=e[t+4]<<3;return 6144&e[t+3]|s|i},parseType:function(e,t){return e[t]==="I".charCodeAt(0)&&e[t+1]==="D".charCodeAt(0)&&e[t+2]==="3".charCodeAt(0)?"timed-metadata":!0&e[t]&&240==(240&e[t+1])?"audio":null},parseSampleRate:function(e){for(var t=0;t+5<e.length;){if(255===e[t]&&240==(246&e[t+1]))return ct[(60&e[t+2])>>>2];t++}return null},parseAacTimestamp:function(e){var t,i=10;64&e[5]&&(i=(i+=4)+ut(e.subarray(10,14)));do{if((t=ut(e.subarray(i+4,i+8)))<1)return null;if("PRIV"===String.fromCharCode(e[i],e[i+1],e[i+2],e[i+3]))for(var s,r,n=e.subarray(i+10,i+t+10),a=0;a<n.byteLength;a++)if(0===n[a]){if("com.apple.streaming.transportStreamTimestamp"===unescape(gt(n,0,a)))return r=(1&(s=n.subarray(a+1))[3])<<30|s[4]<<22|s[5]<<14|s[6]<<6|s[7]>>>2,(r*=4)+(3&s[7]);break}}while((i=i+10+t)<e.byteLength);return null}},E=i,ft=b,yt=function(){var n=new Uint8Array,a=0;yt.prototype.init.call(this),this.setTimestamp=function(e){a=e},this.push=function(e){var t,i,s=0,r=0;for(n.length?(i=n.length,(n=new Uint8Array(e.byteLength+i)).set(n.subarray(0,i)),n.set(e,i)):n=e;3<=n.length-r;)if(n[r]==="I".charCodeAt(0)&&n[r+1]==="D".charCodeAt(0)&&n[r+2]==="3".charCodeAt(0)){if(n.length-r<10)break;if(r+(s=ft.parseId3TagSize(n,r))>n.length)break;t={type:"timed-metadata",data:n.subarray(r,r+s)},this.trigger("data",t),r+=s}else if(255==(255&n[r])&&240==(240&n[r+1])){if(n.length-r<7)break;if(r+(s=ft.parseAdtsSize(n,r))>n.length)break;t={type:"audio",data:n.subarray(r,r+s),pts:a,dts:a},this.trigger("data",t),r+=s}else r++;i=n.length-r,n=0<i?n.subarray(r):new Uint8Array},this.reset=function(){n=new Uint8Array,this.trigger("reset")},this.endTimeline=function(){n=new Uint8Array,this.trigger("endedtimeline")}};yt.prototype=new E;function _t(e,t){for(var i=Object.keys(t),s=0;s<i.length;s++){var r=i[s];"headOfPipeline"!==r&&t[r].on&&t[r].on("log",Ot.bind(e,r))}}function vt(e,t){var i;if(e.length===t.length){for(i=0;i<e.length;i++)if(e[i]!==t[i])return;return 1}}function bt(e,t,i,s,r,n){return{start:{dts:e,pts:e+(i-t)},end:{dts:e+(s-t),pts:e+(r-i)},prependedContentDuration:n,baseMediaDecodeTime:e}}var Tt,St,k,E=i,C=Ce,I=xe,wt=Pe,x=Le,A=T,Et=c,kt=tt,Ct=Ve,It=yt,xt=b.isLikelyAacData,At=c.ONE_SECOND_IN_TS,Pt=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],Lt=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],Ot=function(e,t){t.stream=e,this.trigger("log",t)},Dt=function(n,a){var o=[],l=0,d=0,h=1/0,u=(a=a||{}).firstSequenceNumber||0;Dt.prototype.init.call(this),this.push=function(t){x.collectDtsInfo(n,t),n&&Pt.forEach(function(e){n[e]=t[e]}),o.push(t)},this.setEarliestDts=function(e){l=e},this.setVideoBaseMediaDecodeTime=function(e){h=e},this.setAudioAppendStart=function(e){d=e},this.flush=function(){var e,t,i,s,r;0!==o.length&&(e=wt.trimAdtsFramesByEarliestDts(o,n,l),n.baseMediaDecodeTime=x.calculateTrackBaseMediaDecodeTime(n,a.keepOriginalTimestamps),r=wt.prefixWithSilence(n,e,d,h),n.samples=wt.generateSampleTable(e),i=C.mdat(wt.concatenateFrameData(e)),o=[],s=C.moof(u,[n]),t=new Uint8Array(s.byteLength+i.byteLength),u++,t.set(s),t.set(i,s.byteLength),x.clearDtsInfo(n),i=Math.ceil(1024*At/n.samplerate),e.length&&(s=e.length*i,this.trigger("segmentTimingInfo",bt(Et.audioTsToVideoTs(n.baseMediaDecodeTime,n.samplerate),e[0].dts,e[0].pts,e[0].dts+s,e[0].pts+s,r||0)),this.trigger("timingInfo",{start:e[0].pts,end:e[0].pts+s})),this.trigger("data",{track:n,boxes:t})),this.trigger("done","AudioSegmentStream")},this.reset=function(){x.clearDtsInfo(n),o=[],this.trigger("reset")}};Dt.prototype=new E,(Tt=function(a,n){var t,i,o=[],d=[],l=(n=n||{}).firstSequenceNumber||0;Tt.prototype.init.call(this),delete a.minPTS,this.gopCache_=[],this.push=function(e){x.collectDtsInfo(a,e),"seq_parameter_set_rbsp"!==e.nalUnitType||t||(t=e.config,a.sps=[e.data],Lt.forEach(function(e){a[e]=t[e]},this)),"pic_parameter_set_rbsp"!==e.nalUnitType||i||(i=e.data,a.pps=[e.data]),o.push(e)},this.flush=function(){for(var e,t,i,s=0;o.length&&"access_unit_delimiter_rbsp"!==o[0].nalUnitType;)o.shift();if(0!==o.length){if(e=I.groupNalsIntoFrames(o),(e=I.groupFramesIntoGops(e))[0][0].keyFrame||((r=this.getGopForFusion_(o[0],a))?(s=r.duration,e.unshift(r),e.byteLength+=r.byteLength,e.nalCount+=r.nalCount,e.pts=r.pts,e.dts=r.dts,e.duration+=r.duration):e=I.extendFirstKeyFrame(e)),d.length){var r=n.alignGopsAtEnd?this.alignGopsAtEnd_(e):this.alignGopsAtStart_(e);if(!r)return this.gopCache_.unshift({gop:e.pop(),pps:a.pps,sps:a.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),o=[],this.resetStream_(),void this.trigger("done","VideoSegmentStream");x.clearDtsInfo(a),e=r}x.collectDtsInfo(a,e),a.samples=I.generateSampleTable(e),r=C.mdat(I.concatenateNalData(e)),a.baseMediaDecodeTime=x.calculateTrackBaseMediaDecodeTime(a,n.keepOriginalTimestamps),this.trigger("processedGopsInfo",e.map(function(e){return{pts:e.pts,dts:e.dts,byteLength:e.byteLength}})),t=e[0],i=e[e.length-1],this.trigger("segmentTimingInfo",bt(a.baseMediaDecodeTime,t.dts,t.pts,i.dts+i.duration,i.pts+i.duration,s)),this.trigger("timingInfo",{start:e[0].pts,end:e[e.length-1].pts+e[e.length-1].duration}),this.gopCache_.unshift({gop:e.pop(),pps:a.pps,sps:a.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),o=[],this.trigger("baseMediaDecodeTime",a.baseMediaDecodeTime),this.trigger("timelineStartInfo",a.timelineStartInfo),t=C.moof(l,[a]),i=new Uint8Array(t.byteLength+r.byteLength),l++,i.set(t),i.set(r,t.byteLength),this.trigger("data",{track:a,boxes:i})}this.resetStream_(),this.trigger("done","VideoSegmentStream")},this.reset=function(){this.resetStream_(),o=[],this.gopCache_.length=0,d.length=0,this.trigger("reset")},this.resetStream_=function(){x.clearDtsInfo(a),i=t=void 0},this.getGopForFusion_=function(e){for(var t,i,s,r=1/0,n=0;n<this.gopCache_.length;n++)i=(s=this.gopCache_[n]).gop,a.pps&&vt(a.pps[0],s.pps[0])&&a.sps&&vt(a.sps[0],s.sps[0])&&(i.dts<a.timelineStartInfo.dts||-1e4<=(i=e.dts-i.dts-i.duration)&&i<=45e3&&(!t||i<r)&&(t=s,r=i));return t?t.gop:null},this.alignGopsAtStart_=function(e){for(var t,i,s,r,n=e.byteLength,a=e.nalCount,o=e.duration,l=t=0;l<d.length&&t<e.length&&(i=d[l],s=e[t],i.pts!==s.pts);)s.pts>i.pts?l++:(t++,n-=s.byteLength,a-=s.nalCount,o-=s.duration);return 0===t?e:t===e.length?null:((r=e.slice(t)).byteLength=n,r.duration=o,r.nalCount=a,r.pts=r[0].pts,r.dts=r[0].dts,r)},this.alignGopsAtEnd_=function(e){for(var t,i,s,r,n=d.length-1,a=e.length-1,o=null,l=!1;0<=n&&0<=a;){if(t=d[n],i=e[a],t.pts===i.pts){l=!0;break}t.pts>i.pts?n--:(n===d.length-1&&(o=a),a--)}return l||null!==o?0===(s=l?a:o)?e:(r=(s=e.slice(s)).reduce(function(e,t){return e.byteLength+=t.byteLength,e.duration+=t.duration,e.nalCount+=t.nalCount,e},{byteLength:0,duration:0,nalCount:0}),s.byteLength=r.byteLength,s.duration=r.duration,s.nalCount=r.nalCount,s.pts=s[0].pts,s.dts=s[0].dts,s):null},this.alignGopsWith=function(e){d=e}}).prototype=new E,((k=function(e,t){this.numberOfTracks=0,this.metadataStream=t,"undefined"!=typeof(e=e||{}).remux?this.remuxTracks=!!e.remux:this.remuxTracks=!0,"boolean"==typeof e.keepOriginalTimestamps?this.keepOriginalTimestamps=e.keepOriginalTimestamps:this.keepOriginalTimestamps=!1,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,k.prototype.init.call(this),this.push=function(e){return e.text?this.pendingCaptions.push(e):e.frames?this.pendingMetadata.push(e):(this.pendingTracks.push(e.track),this.pendingBytes+=e.boxes.byteLength,"video"===e.track.type&&(this.videoTrack=e.track,this.pendingBoxes.push(e.boxes)),void("audio"===e.track.type&&(this.audioTrack=e.track,this.pendingBoxes.unshift(e.boxes))))}}).prototype=new E).flush=function(e){var t,i,s,r=0,n={captions:[],captionStreams:{},metadata:[],info:{}},a=0;if(this.pendingTracks.length<this.numberOfTracks){if("VideoSegmentStream"!==e&&"AudioSegmentStream"!==e)return;if(this.remuxTracks)return;if(0===this.pendingTracks.length)return this.emittedTracks++,void(this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0))}if(this.videoTrack?(a=this.videoTrack.timelineStartInfo.pts,Lt.forEach(function(e){n.info[e]=this.videoTrack[e]},this)):this.audioTrack&&(a=this.audioTrack.timelineStartInfo.pts,Pt.forEach(function(e){n.info[e]=this.audioTrack[e]},this)),this.videoTrack||this.audioTrack){for(1===this.pendingTracks.length?n.type=this.pendingTracks[0].type:n.type="combined",this.emittedTracks+=this.pendingTracks.length,e=C.initSegment(this.pendingTracks),n.initSegment=new Uint8Array(e.byteLength),n.initSegment.set(e),n.data=new Uint8Array(this.pendingBytes),s=0;s<this.pendingBoxes.length;s++)n.data.set(this.pendingBoxes[s],r),r+=this.pendingBoxes[s].byteLength;for(s=0;s<this.pendingCaptions.length;s++)(t=this.pendingCaptions[s]).startTime=Et.metadataTsToSeconds(t.startPts,a,this.keepOriginalTimestamps),t.endTime=Et.metadataTsToSeconds(t.endPts,a,this.keepOriginalTimestamps),n.captionStreams[t.stream]=!0,n.captions.push(t);for(s=0;s<this.pendingMetadata.length;s++)(i=this.pendingMetadata[s]).cueTime=Et.metadataTsToSeconds(i.pts,a,this.keepOriginalTimestamps),n.metadata.push(i);for(n.metadata.dispatchType=this.metadataStream.dispatchType,this.pendingTracks.length=0,this.videoTrack=null,this.pendingBoxes.length=0,this.pendingCaptions.length=0,this.pendingBytes=0,this.pendingMetadata.length=0,this.trigger("data",n),s=0;s<n.captions.length;s++)t=n.captions[s],this.trigger("caption",t);for(s=0;s<n.metadata.length;s++)i=n.metadata[s],this.trigger("id3Frame",i)}this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},k.prototype.setRemux=function(e){this.remuxTracks=e},(St=function(s){var r,n,a=this,i=!0;St.prototype.init.call(this),s=s||{},this.baseMediaDecodeTime=s.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var t={};(this.transmuxPipeline_=t).type="aac",t.metadataStream=new A.MetadataStream,t.aacStream=new It,t.audioTimestampRolloverStream=new A.TimestampRolloverStream("audio"),t.timedMetadataTimestampRolloverStream=new A.TimestampRolloverStream("timed-metadata"),t.adtsStream=new kt,t.coalesceStream=new k(s,t.metadataStream),t.headOfPipeline=t.aacStream,t.aacStream.pipe(t.audioTimestampRolloverStream).pipe(t.adtsStream),t.aacStream.pipe(t.timedMetadataTimestampRolloverStream).pipe(t.metadataStream).pipe(t.coalesceStream),t.metadataStream.on("timestamp",function(e){t.aacStream.setTimestamp(e.timeStamp)}),t.aacStream.on("data",function(e){"timed-metadata"!==e.type&&"audio"!==e.type||t.audioSegmentStream||(n=n||{timelineStartInfo:{baseMediaDecodeTime:a.baseMediaDecodeTime},codec:"adts",type:"audio"},t.coalesceStream.numberOfTracks++,t.audioSegmentStream=new Dt(n,s),t.audioSegmentStream.on("log",a.getLogTrigger_("audioSegmentStream")),t.audioSegmentStream.on("timingInfo",a.trigger.bind(a,"audioTimingInfo")),t.adtsStream.pipe(t.audioSegmentStream).pipe(t.coalesceStream),a.trigger("trackinfo",{hasAudio:!!n,hasVideo:!!r}))}),t.coalesceStream.on("data",this.trigger.bind(this,"data")),t.coalesceStream.on("done",this.trigger.bind(this,"done")),_t(this,t)},this.setupTsPipeline=function(){var i={};(this.transmuxPipeline_=i).type="ts",i.metadataStream=new A.MetadataStream,i.packetStream=new A.TransportPacketStream,i.parseStream=new A.TransportParseStream,i.elementaryStream=new A.ElementaryStream,i.timestampRolloverStream=new A.TimestampRolloverStream,i.adtsStream=new kt,i.h264Stream=new Ct,i.captionStream=new A.CaptionStream(s),i.coalesceStream=new k(s,i.metadataStream),i.headOfPipeline=i.packetStream,i.packetStream.pipe(i.parseStream).pipe(i.elementaryStream).pipe(i.timestampRolloverStream),i.timestampRolloverStream.pipe(i.h264Stream),i.timestampRolloverStream.pipe(i.adtsStream),i.timestampRolloverStream.pipe(i.metadataStream).pipe(i.coalesceStream),i.h264Stream.pipe(i.captionStream).pipe(i.coalesceStream),i.elementaryStream.on("data",function(e){var t;if("metadata"===e.type){for(t=e.tracks.length;t--;)r||"video"!==e.tracks[t].type?n||"audio"!==e.tracks[t].type||((n=e.tracks[t]).timelineStartInfo.baseMediaDecodeTime=a.baseMediaDecodeTime):(r=e.tracks[t]).timelineStartInfo.baseMediaDecodeTime=a.baseMediaDecodeTime;r&&!i.videoSegmentStream&&(i.coalesceStream.numberOfTracks++,i.videoSegmentStream=new Tt(r,s),i.videoSegmentStream.on("log",a.getLogTrigger_("videoSegmentStream")),i.videoSegmentStream.on("timelineStartInfo",function(e){n&&!s.keepOriginalTimestamps&&(n.timelineStartInfo=e,i.audioSegmentStream.setEarliestDts(e.dts-a.baseMediaDecodeTime))}),i.videoSegmentStream.on("processedGopsInfo",a.trigger.bind(a,"gopInfo")),i.videoSegmentStream.on("segmentTimingInfo",a.trigger.bind(a,"videoSegmentTimingInfo")),i.videoSegmentStream.on("baseMediaDecodeTime",function(e){n&&i.audioSegmentStream.setVideoBaseMediaDecodeTime(e)}),i.videoSegmentStream.on("timingInfo",a.trigger.bind(a,"videoTimingInfo")),i.h264Stream.pipe(i.videoSegmentStream).pipe(i.coalesceStream)),n&&!i.audioSegmentStream&&(i.coalesceStream.numberOfTracks++,i.audioSegmentStream=new Dt(n,s),i.audioSegmentStream.on("log",a.getLogTrigger_("audioSegmentStream")),i.audioSegmentStream.on("timingInfo",a.trigger.bind(a,"audioTimingInfo")),i.audioSegmentStream.on("segmentTimingInfo",a.trigger.bind(a,"audioSegmentTimingInfo")),i.adtsStream.pipe(i.audioSegmentStream).pipe(i.coalesceStream)),a.trigger("trackinfo",{hasAudio:!!n,hasVideo:!!r})}}),i.coalesceStream.on("data",this.trigger.bind(this,"data")),i.coalesceStream.on("id3Frame",function(e){e.dispatchType=i.metadataStream.dispatchType,a.trigger("id3Frame",e)}),i.coalesceStream.on("caption",this.trigger.bind(this,"caption")),i.coalesceStream.on("done",this.trigger.bind(this,"done")),_t(this,i)},this.setBaseMediaDecodeTime=function(e){var t=this.transmuxPipeline_;s.keepOriginalTimestamps||(this.baseMediaDecodeTime=e),n&&(n.timelineStartInfo.dts=void 0,n.timelineStartInfo.pts=void 0,x.clearDtsInfo(n),t.audioTimestampRolloverStream)&&t.audioTimestampRolloverStream.discontinuity(),r&&(t.videoSegmentStream&&(t.videoSegmentStream.gopCache_=[]),r.timelineStartInfo.dts=void 0,r.timelineStartInfo.pts=void 0,x.clearDtsInfo(r),t.captionStream.reset()),t.timestampRolloverStream&&t.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(e){n&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(e)},this.setRemux=function(e){var t=this.transmuxPipeline_;s.remux=e,t&&t.coalesceStream&&t.coalesceStream.setRemux(e)},this.alignGopsWith=function(e){r&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(e)},this.getLogTrigger_=function(t){var i=this;return function(e){e.stream=t,i.trigger("log",e)}},this.push=function(e){var t;i&&((t=xt(e))&&"aac"!==this.transmuxPipeline_.type?this.setupAacPipeline():t||"ts"===this.transmuxPipeline_.type||this.setupTsPipeline(),i=!1),this.transmuxPipeline_.headOfPipeline.push(e)},this.flush=function(){i=!0,this.transmuxPipeline_.headOfPipeline.flush()},this.endTimeline=function(){this.transmuxPipeline_.headOfPipeline.endTimeline()},this.reset=function(){this.transmuxPipeline_.headOfPipeline&&this.transmuxPipeline_.headOfPipeline.reset()},this.resetCaptions=function(){this.transmuxPipeline_.captionStream&&this.transmuxPipeline_.captionStream.reset()}}).prototype=new E;function Nt(e){var t="";return(t+=String.fromCharCode(e[0]))+String.fromCharCode(e[1])+String.fromCharCode(e[2])+String.fromCharCode(e[3])}function Mt(e,t){var i,s,r,n=[];if(!t.length)return null;for(i=0;i<e.byteLength;)s=$t(e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]),r=Wt(e.subarray(i+4,i+8)),s=1<s?i+s:e.byteLength,r===t[0]&&(1===t.length?n.push(e.subarray(i+8,s)):(r=Mt(e.subarray(i+8,s),t.slice(1))).length&&(n=n.concat(r))),i=s;return n}function Rt(e){var t={version:e[0],flags:new Uint8Array(e.subarray(1,4))};return t.baseMediaDecodeTime=1===t.version?zt(e.subarray(4)):Gt(e[4]<<24|e[5]<<16|e[6]<<8|e[7]),t}function Ut(e){var t,i={version:e[0],flags:new Uint8Array(e.subarray(1,4)),samples:[]},s=new DataView(e.buffer,e.byteOffset,e.byteLength),r=1&i.flags[2],n=4&i.flags[2],a=1&i.flags[1],o=2&i.flags[1],l=4&i.flags[1],d=8&i.flags[1],h=s.getUint32(4),u=8;for(r&&(i.dataOffset=s.getInt32(u),u+=4),n&&h&&(t={flags:Xt(e.subarray(u,u+4))},u+=4,a&&(t.duration=s.getUint32(u),u+=4),o&&(t.size=s.getUint32(u),u+=4),d&&(t.compositionTimeOffset=1===i.version?s.getInt32(u):s.getUint32(u),u+=4),i.samples.push(t),h--);h--;)t={},a&&(t.duration=s.getUint32(u),u+=4),o&&(t.size=s.getUint32(u),u+=4),l&&(t.flags=Xt(e.subarray(u,u+4)),u+=4),d&&(t.compositionTimeOffset=1===i.version?s.getInt32(u):s.getUint32(u),u+=4),i.samples.push(t);return i}function Bt(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength),i=1&(e={version:e[0],flags:new Uint8Array(e.subarray(1,4)),trackId:t.getUint32(4)}).flags[2],s=2&e.flags[2],r=8&e.flags[2],n=16&e.flags[2],a=32&e.flags[2],o=65536&e.flags[0],l=131072&e.flags[0],d=8;return i&&(d+=4,e.baseDataOffset=t.getUint32(12),d+=4),s&&(e.sampleDescriptionIndex=t.getUint32(d),d+=4),r&&(e.defaultSampleDuration=t.getUint32(d),d+=4),n&&(e.defaultSampleSize=t.getUint32(d),d+=4),a&&(e.defaultSampleFlags=t.getUint32(d)),o&&(e.durationIsEmpty=!0),!i&&l&&(e.baseDataOffsetIsMoof=!0),e}function Ft(e){var t=31&e[1];return t<<8|e[2]}function jt(e){return!!(64&e[1])}function Ht(e){var t=0;return 1<(48&e[3])>>>4&&(t+=e[4]+1),t}function qt(e){switch(e){case 5:return"slice_layer_without_partitioning_rbsp_idr";case 6:return"sei_rbsp";case 7:return"seq_parameter_set_rbsp";case 8:return"pic_parameter_set_rbsp";case 9:return"access_unit_delimiter_rbsp";default:return null}}var Vt=St,i=function(e){return e>>>0},Pe=function(e){return("00"+e.toString(16)).slice(-2)},$t=i,Wt=Nt,Gt=i,zt=_e.getUint64,Xt=function(e){return{isLeading:(12&e[0])>>>2,dependsOn:3&e[0],isDependedOn:(192&e[1])>>>6,hasRedundancy:(48&e[1])>>>4,paddingValue:(14&e[1])>>>1,isNonSyncSample:1&e[1],degradationPriority:e[2]<<8|e[3]}},Le="undefined"!=typeof window?window:"undefined"!=typeof fe?fe:"undefined"!=typeof self?self:{},T=Le,Kt=De.discardEmulationPreventionBytes,Yt=p.CaptionStream,P=Mt,Qt=Rt,Jt=Ut,Zt=Bt,ei=T,ti=function(e,h){var i=P(e,["moof","traf"]),e=P(e,["mdat"]),u={},s=[];return e.forEach(function(e,t){t=i[t];s.push({mdat:e,traf:t})}),s.forEach(function(e){var t,i,s,r,n,a=e.mdat,e=e.traf,o=P(e,["tfhd"]),o=Zt(o[0]),l=o.trackId,d=P(e,["tfdt"]),d=0<d.length?Qt(d[0]).baseMediaDecodeTime:0,e=P(e,["trun"]);h===l&&0<e.length&&(t=d,i=o.defaultSampleDuration||0,s=o.defaultSampleSize||0,r=o.trackId,n=[],e.forEach(function(e){e=Jt(e).samples;e.forEach(function(e){void 0===e.duration&&(e.duration=i),void 0===e.size&&(e.size=s),e.trackId=r,e.dts=t,void 0===e.compositionTimeOffset&&(e.compositionTimeOffset=0),"bigint"==typeof t?(e.pts=t+ei.BigInt(e.compositionTimeOffset),t+=ei.BigInt(e.duration)):(e.pts=t+e.compositionTimeOffset,t+=e.duration)}),n=n.concat(e)}),d=function(e,t,i){for(var s,r,n=new DataView(e.buffer,e.byteOffset,e.byteLength),a={logs:[],seiNals:[]},o=0;o+4<e.length;o+=s)if(s=n.getUint32(o),o+=4,!(s<=0))switch(31&e[o]){case 6:var l=e.subarray(o+1,o+1+s),d=function(e,t){for(var i=e,s=0;s<t.length;s++){var r=t[s];if(i<r.size)return r;i-=r.size}return null}(o,t),l={nalUnitType:"sei_rbsp",size:s,data:l,escapedRBSP:Kt(l),trackId:i};if(d)l.pts=d.pts,l.dts=d.dts,r=d;else{if(!r){a.logs.push({level:"warn",message:"We've encountered a nal unit without data at "+o+" for trackId "+i+". See mux.js#223."});break}l.pts=r.pts,l.dts=r.dts}a.seiNals.push(l)}return a}(a,n,l),u[l]||(u[l]={seiNals:[],logs:[]}),u[l].seiNals=u[l].seiNals.concat(d.seiNals),u[l].logs=u[l].logs.concat(d.logs))}),u},ii=function(){var t,a,o,l,d,i,s=!1;this.isInitialized=function(){return s},this.init=function(e){t=new Yt,s=!0,i=!!e&&e.isPartial,t.on("data",function(e){e.startTime=e.startPts/l,e.endTime=e.endPts/l,d.captions.push(e),d.captionStreams[e.stream]=!0}),t.on("log",function(e){d.logs.push(e)})},this.isNewInit=function(e,t){return!(e&&0===e.length||t&&"object"==typeof t&&0===Object.keys(t).length||o===e[0]&&l===t[o])},this.parse=function(e,t,i){var s,r;if(!this.isInitialized())return null;if(!t||!i)return null;if(this.isNewInit(t,i))o=t[0],l=i[o];else if(null===o||!l)return a.push(e),null;for(;0<a.length;){var n=a.shift();this.parse(n,t,i)}return e=e,r=l,(s=null===(s=o)?null:{seiNals:(e=ti(e,s)[s]||{}).seiNals,logs:e.logs,timescale:r})&&s.logs&&(d.logs=d.logs.concat(s.logs)),null!==s&&s.seiNals?(this.pushNals(s.seiNals),this.flushStream(),d):d.logs.length?{logs:d.logs,captions:[],captionStreams:[]}:null},this.pushNals=function(e){if(!this.isInitialized()||!e||0===e.length)return null;e.forEach(function(e){t.push(e)})},this.flushStream=function(){if(!this.isInitialized())return null;i?t.partialFlush():t.flush()},this.clearParsedCaptions=function(){d.captions=[],d.captionStreams={},d.logs=[]},this.resetCaptionStream=function(){if(!this.isInitialized())return null;t.reset()},this.clearAllCaptions=function(){this.clearParsedCaptions(),this.resetCaptionStream()},this.reset=function(){a=[],l=o=null,d?this.clearParsedCaptions():d={captions:[],captionStreams:{},logs:[]},this.resetCaptionStream()},this.reset()},si=i,L=Pe,O=Mt,ri=Nt,ni=_e.getUint64,ai=T,oi=function(e){var t=0===e[0]?12:20;return si(e[t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t])},li=function(n,e){e=O(e,["moof","traf"]).reduce(function(e,t){var i=O(t,["tfhd"])[0],i=si(i[4]<<24|i[5]<<16|i[6]<<8|i[7]),i=n[i]||9e4,t=O(t,["tfdt"])[0],s=new DataView(t.buffer,t.byteOffset,t.byteLength),t=1===t[0]?ni(t.subarray(4,12)):s.getUint32(4);let r;return"bigint"==typeof t?r=t/ai.BigInt(i):"number"!=typeof t||isNaN(t)||(r=t/i),e=(r=r<Number.MAX_SAFE_INTEGER?Number(r):r)<e?r:e},1/0);return"bigint"==typeof e||isFinite(e)?e:0},di=function(e){var e=O(e,["moov","trak"]),n=[];return e.forEach(function(e){var t,i={},s=O(e,["tkhd"])[0],r=(s&&(r=(s=new DataView(s.buffer,s.byteOffset,s.byteLength)).getUint8(0),i.id=0===r?s.getUint32(12):s.getUint32(20)),O(e,["mdia","hdlr"])[0]),r=(r&&(s=ri(r.subarray(8,12)),i.type="vide"===s?"video":"soun"===s?"audio":s),O(e,["mdia","minf","stbl","stsd"])[0]),s=(r&&(s=r.subarray(8),i.codec=ri(s.subarray(4,8)),r=O(s,[i.codec])[0])&&(/^[asm]vc[1-9]$/i.test(i.codec)?(t=r.subarray(78),"avcC"===ri(t.subarray(4,8))&&11<t.length?(i.codec+=".",i.codec+=L(t[9]),i.codec+=L(t[10]),i.codec+=L(t[11])):i.codec="avc1.4d400d"):/^mp4[a,v]$/i.test(i.codec)?(t=r.subarray(28),"esds"===ri(t.subarray(4,8))&&20<t.length&&0!==t[19]?(i.codec+="."+L(t[19]),i.codec+="."+L(t[20]>>>2&63).replace(/^0/,"")):i.codec="mp4a.40.2"):i.codec=i.codec.toLowerCase()),O(e,["mdia","mdhd"])[0]);s&&(i.timescale=oi(s)),n.push(i)}),n},hi=qe,ui=qe,D=Ye,N={},M=(N.ts={parseType:function(e,t){e=Ft(e);return 0===e?"pat":e===t?"pmt":t?"pes":null},parsePat:function(e){var t=jt(e),i=4+Ht(e);return t&&(i+=e[i]+1),(31&e[i+10])<<8|e[i+11]},parsePmt:function(e){var t={},i=jt(e),s=4+Ht(e);if(i&&(s+=e[s]+1),1&e[s+5]){for(var r=3+((15&e[s+1])<<8|e[s+2])-4,n=12+((15&e[s+10])<<8|e[s+11]);n<r;){var a=s+n;t[(31&e[a+1])<<8|e[a+2]]=e[a],n+=5+((15&e[a+3])<<8|e[a+4])}return t}},parsePayloadUnitStartIndicator:jt,parsePesType:function(e,t){switch(t[Ft(e)]){case hi.H264_STREAM_TYPE:return"video";case hi.ADTS_STREAM_TYPE:return"audio";case hi.METADATA_STREAM_TYPE:return"timed-metadata";default:return null}},parsePesTime:function(e){var t,i,s;return!jt(e)||(t=4+Ht(e))>=e.byteLength?null:(i=null,192&(s=e[t+7])&&((i={}).pts=(14&e[t+9])<<27|(255&e[t+10])<<20|(254&e[t+11])<<12|(255&e[t+12])<<5|(254&e[t+13])>>>3,i.pts*=4,i.pts+=(6&e[t+13])>>>1,i.dts=i.pts,64&s)&&(i.dts=(14&e[t+14])<<27|(255&e[t+15])<<20|(254&e[t+16])<<12|(255&e[t+17])<<5|(254&e[t+18])>>>3,i.dts*=4,i.dts+=(6&e[t+18])>>>1),i)},videoPacketContainsKeyFrame:function(e){for(var t=4+Ht(e),i=e.subarray(t),s=0,r=0,n=!1;r<i.byteLength-3;r++)if(1===i[r+2]){s=r+5;break}for(;s<i.byteLength;)switch(i[s]){case 0:if(0!==i[s-1])s+=2;else if(0!==i[s-2])s++;else{for(r+3!==s-2&&"slice_layer_without_partitioning_rbsp_idr"===qt(31&i[r+3])&&(n=!0);1!==i[++s]&&s<i.length;);r=s-2,s+=3}break;case 1:0!==i[s-1]||0!==i[s-2]?s+=3:("slice_layer_without_partitioning_rbsp_idr"===qt(31&i[r+3])&&(n=!0),r=s-2,s+=3);break;default:s+=3}return i=i.subarray(r),s-=r,r=0,n=i&&3<i.byteLength&&"slice_layer_without_partitioning_rbsp_idr"===qt(31&i[r+3])?!0:n}},N.aac=b,c.ONE_SECOND_IN_TS),ci=function(e,t){for(var i,s=0,r=188;r<e.byteLength;)if(71===e[s]&&71===e[r]){switch(i=e.subarray(s,r),N.ts.parseType(i,t.pid)){case"pat":t.pid=N.ts.parsePat(i);break;case"pmt":var n=N.ts.parsePmt(i);t.table=t.table||{},Object.keys(n).forEach(function(e){t.table[e]=n[e]})}s+=188,r+=188}else s++,r++},pi=function(e,t,i){for(var s,r,n,a,o=0,l=188,d=!1;l<=e.byteLength;)if(71!==e[o]||71!==e[l]&&l!==e.byteLength)o++,l++;else{if(s=e.subarray(o,l),"pes"===N.ts.parseType(s,t.pid)&&(r=N.ts.parsePesType(s,t.table),n=N.ts.parsePayloadUnitStartIndicator(s),"audio"===r)&&n&&(a=N.ts.parsePesTime(s))&&(a.type="audio",i.audio.push(a),d=!0),d)break;o+=188,l+=188}for(o=(l=e.byteLength)-188,d=!1;0<=o;)if(71!==e[o]||71!==e[l]&&l!==e.byteLength)o--,l--;else{if(s=e.subarray(o,l),"pes"===N.ts.parseType(s,t.pid)&&(r=N.ts.parsePesType(s,t.table),n=N.ts.parsePayloadUnitStartIndicator(s),"audio"===r)&&n&&(a=N.ts.parsePesTime(s))&&(a.type="audio",i.audio.push(a),d=!0),d)break;o-=188,l-=188}},mi=function(e,t,i){for(var s,r,n,a,o,l,d,h,u=0,c=188,p=!1,m={data:[],size:0};c<e.byteLength;)if(71===e[u]&&71===e[c]){if(s=e.subarray(u,c),"pes"===N.ts.parseType(s,t.pid))if(r=N.ts.parsePesType(s,t.table),n=N.ts.parsePayloadUnitStartIndicator(s),"video"===r&&(n&&!p&&(a=N.ts.parsePesTime(s))&&(a.type="video",i.video.push(a),p=!0),!i.firstKeyFrame)){if(n&&0!==m.size){for(o=new Uint8Array(m.size),l=0;m.data.length;)d=m.data.shift(),o.set(d,l),l+=d.byteLength;N.ts.videoPacketContainsKeyFrame(o)&&(h=N.ts.parsePesTime(o))&&(i.firstKeyFrame=h,i.firstKeyFrame.type="video"),m.size=0}m.data.push(s),m.size+=s.byteLength}if(p&&i.firstKeyFrame)break;u+=188,c+=188}else u++,c++;for(u=(c=e.byteLength)-188,p=!1;0<=u;)if(71===e[u]&&71===e[c]){if(s=e.subarray(u,c),"pes"===N.ts.parseType(s,t.pid)&&(r=N.ts.parsePesType(s,t.table),n=N.ts.parsePayloadUnitStartIndicator(s),"video"===r)&&n&&(a=N.ts.parsePesTime(s))&&(a.type="video",i.video.push(a),p=!0),p)break;u-=188,c-=188}else u--,c--},gi=function(e,t){var i,s,r,e=(N.aac.isLikelyAacData(e)?function(e){for(var t,i,s=!1,r=0,n=null,a=null,o=0,l=0;3<=e.length-l;){switch(N.aac.parseType(e,l)){case"timed-metadata":e.length-l<10?s=!0:(o=N.aac.parseId3TagSize(e,l))>e.length?s=!0:(null===a&&(t=e.subarray(l,l+o),a=N.aac.parseAacTimestamp(t)),l+=o);break;case"audio":e.length-l<7?s=!0:(o=N.aac.parseAdtsSize(e,l))>e.length?s=!0:(null===n&&(t=e.subarray(l,l+o),n=N.aac.parseSampleRate(t)),r++,l+=o);break;default:l++}if(s)return null}return null===n||null===a?null:{audio:[{type:"audio",dts:a,pts:a},{type:"audio",dts:a+1024*r*(i=M/n),pts:a+1024*r*i}]}}:function(e){var t,i={pid:null,table:null},s={};for(t in ci(e,i),i.table)if(i.table.hasOwnProperty(t))switch(i.table[t]){case ui.H264_STREAM_TYPE:s.video=[],mi(e,i,s),0===s.video.length&&delete s.video;break;case ui.ADTS_STREAM_TYPE:s.audio=[],pi(e,i,s),0===s.audio.length&&delete s.audio}return s})(e);return e&&(e.audio||e.video)?(t=t,(i=e).audio&&i.audio.length&&("undefined"!=typeof(s=t)&&!isNaN(s)||(s=i.audio[0].dts),i.audio.forEach(function(e){e.dts=D(e.dts,s),e.pts=D(e.pts,s),e.dtsTime=e.dts/M,e.ptsTime=e.pts/M})),i.video&&i.video.length&&("undefined"!=typeof(r=t)&&!isNaN(r)||(r=i.video[0].dts),i.video.forEach(function(e){e.dts=D(e.dts,r),e.pts=D(e.pts,r),e.dtsTime=e.dts/M,e.ptsTime=e.pts/M}),i.firstKeyFrame)&&((t=i.firstKeyFrame).dts=D(t.dts,r),t.pts=D(t.pts,r),t.dtsTime=t.dts/M,t.ptsTime=t.pts/M),e):null};class fi{constructor(e,t){this.options=t||{},this.self=e,this.init()}init(){var i,e;this.transmuxer&&this.transmuxer.dispose(),this.transmuxer=new Vt(this.options),i=this.self,(e=this.transmuxer).on("data",function(e){var t=e.initSegment,t=(e.initSegment={data:t.buffer,byteOffset:t.byteOffset,byteLength:t.byteLength},e.data);e.data=t.buffer,i.postMessage({action:"data",segment:e,byteOffset:t.byteOffset,byteLength:t.byteLength},[e.data])}),e.on("done",function(e){i.postMessage({action:"done"})}),e.on("gopInfo",function(e){i.postMessage({action:"gopInfo",gopInfo:e})}),e.on("videoSegmentTimingInfo",function(e){var t={start:{decode:c.videoTsToSeconds(e.start.dts),presentation:c.videoTsToSeconds(e.start.pts)},end:{decode:c.videoTsToSeconds(e.end.dts),presentation:c.videoTsToSeconds(e.end.pts)},baseMediaDecodeTime:c.videoTsToSeconds(e.baseMediaDecodeTime)};e.prependedContentDuration&&(t.prependedContentDuration=c.videoTsToSeconds(e.prependedContentDuration)),i.postMessage({action:"videoSegmentTimingInfo",videoSegmentTimingInfo:t})}),e.on("audioSegmentTimingInfo",function(e){var t={start:{decode:c.videoTsToSeconds(e.start.dts),presentation:c.videoTsToSeconds(e.start.pts)},end:{decode:c.videoTsToSeconds(e.end.dts),presentation:c.videoTsToSeconds(e.end.pts)},baseMediaDecodeTime:c.videoTsToSeconds(e.baseMediaDecodeTime)};e.prependedContentDuration&&(t.prependedContentDuration=c.videoTsToSeconds(e.prependedContentDuration)),i.postMessage({action:"audioSegmentTimingInfo",audioSegmentTimingInfo:t})}),e.on("id3Frame",function(e){i.postMessage({action:"id3Frame",id3Frame:e})}),e.on("caption",function(e){i.postMessage({action:"caption",caption:e})}),e.on("trackinfo",function(e){i.postMessage({action:"trackinfo",trackInfo:e})}),e.on("audioTimingInfo",function(e){i.postMessage({action:"audioTimingInfo",audioTimingInfo:{start:c.videoTsToSeconds(e.start),end:c.videoTsToSeconds(e.end)}})}),e.on("videoTimingInfo",function(e){i.postMessage({action:"videoTimingInfo",videoTimingInfo:{start:c.videoTsToSeconds(e.start),end:c.videoTsToSeconds(e.end)}})}),e.on("log",function(e){i.postMessage({action:"log",log:e})})}pushMp4Captions(e){this.captionParser||(this.captionParser=new ii,this.captionParser.init());var t=new Uint8Array(e.data,e.byteOffset,e.byteLength),e=this.captionParser.parse(t,e.trackIds,e.timescales);this.self.postMessage({action:"mp4Captions",captions:e&&e.captions||[],logs:e&&e.logs||[],data:t.buffer},[t.buffer])}probeMp4StartTime({timescales:e,data:t}){e=li(e,t);this.self.postMessage({action:"probeMp4StartTime",startTime:e,data:t},[t.buffer])}probeMp4Tracks({data:e}){var t=di(e);this.self.postMessage({action:"probeMp4Tracks",tracks:t,data:e},[e.buffer])}probeTs({data:e,baseStartTime:t}){t="number"!=typeof t||isNaN(t)?void 0:t*c.ONE_SECOND_IN_TS,t=gi(e,t);let i=null;t&&((i={hasVideo:t.video&&2===t.video.length||!1,hasAudio:t.audio&&2===t.audio.length||!1}).hasVideo&&(i.videoStart=t.video[0].ptsTime),i.hasAudio)&&(i.audioStart=t.audio[0].ptsTime),this.self.postMessage({action:"probeTs",result:i,data:e},[e.buffer])}clearAllMp4Captions(){this.captionParser&&this.captionParser.clearAllCaptions()}clearParsedMp4Captions(){this.captionParser&&this.captionParser.clearParsedCaptions()}push(e){e=new Uint8Array(e.data,e.byteOffset,e.byteLength);this.transmuxer.push(e)}reset(){this.transmuxer.reset()}setTimestampOffset(e){e=e.timestampOffset||0;this.transmuxer.setBaseMediaDecodeTime(Math.round(c.secondsToVideoTs(e)))}setAudioAppendStart(e){this.transmuxer.setAudioAppendStart(Math.ceil(c.secondsToVideoTs(e.appendStart)))}setRemux(e){this.transmuxer.setRemux(e.remux)}flush(e){this.transmuxer.flush(),self.postMessage({action:"done",type:"transmuxed"})}endTimeline(){this.transmuxer.endTimeline(),self.postMessage({action:"endedtimeline",type:"transmuxed"})}alignGopsWith(e){this.transmuxer.alignGopsWith(e.gopsToAlignWith.slice())}}self.onmessage=function(e){"init"===e.data.action&&e.data.options?this.messageHandlers=new fi(self,e.data.options):(this.messageHandlers||(this.messageHandlers=new fi(self)),e.data&&e.data.action&&"init"!==e.data.action&&this.messageHandlers[e.data.action]&&this.messageHandlers[e.data.action](e.data))}})));const ih=(e,t,i)=>{var{type:s,initSegment:r,captions:n,captionStreams:a,metadata:o,videoFrameDtsTime:l,videoFramePtsTime:d}=e.data.segment,t=(t.buffer.push({captions:n,captionStreams:a,metadata:o}),e.data.segment.boxes||{data:e.data.segment.data}),n={type:s,data:new Uint8Array(t.data,t.data.byteOffset,t.data.byteLength),initSegment:new Uint8Array(r.data,r.byteOffset,r.byteLength)};"undefined"!=typeof l&&(n.videoFrameDtsTime=l),"undefined"!=typeof d&&(n.videoFramePtsTime=d),i(n)},sh=({transmuxedData:e,callback:t})=>{e.buffer=[],t(e)},rh=(e,t)=>{t.gopInfo=e.data.gopInfo},nh=t=>{const{transmuxer:i,bytes:e,audioAppendStart:s,gopsToAlignWith:r,remux:n,onData:a,onTrackInfo:o,onAudioTimingInfo:l,onVideoTimingInfo:d,onVideoSegmentTimingInfo:h,onAudioSegmentTimingInfo:u,onId3:c,onCaptions:p,onDone:m,onEndedTimeline:g,onTransmuxerLog:f,isEndOfTimeline:y}=t,_={buffer:[]};let v=y;var b,T;i.onmessage=e=>{i.currentTransmux!==t||("data"===e.data.action&&ih(e,_,a),"trackinfo"===e.data.action&&o(e.data.trackInfo),"gopInfo"===e.data.action&&rh(e,_),"audioTimingInfo"===e.data.action&&l(e.data.audioTimingInfo),"videoTimingInfo"===e.data.action&&d(e.data.videoTimingInfo),"videoSegmentTimingInfo"===e.data.action&&h(e.data.videoSegmentTimingInfo),"audioSegmentTimingInfo"===e.data.action&&u(e.data.audioSegmentTimingInfo),"id3Frame"===e.data.action&&c([e.data.id3Frame],e.data.id3Frame.dispatchType),"caption"===e.data.action&&p(e.data.caption),"endedtimeline"===e.data.action&&(v=!1,g()),"log"===e.data.action&&f(e.data.log),"transmuxed"!==e.data.type)||v||(i.onmessage=null,sh({transmuxedData:_,callback:m}),ah(i))},s&&i.postMessage({action:"setAudioAppendStart",appendStart:s}),Array.isArray(r)&&i.postMessage({action:"alignGopsWith",gopsToAlignWith:r}),"undefined"!=typeof n&&i.postMessage({action:"setRemux",remux:n}),e.byteLength&&(b=e instanceof ArrayBuffer?e:e.buffer,T=e instanceof ArrayBuffer?0:e.byteOffset,i.postMessage({action:"push",data:b,byteOffset:T,byteLength:e.byteLength},[b])),y&&i.postMessage({action:"endTimeline"}),i.postMessage({action:"flush"})},ah=e=>{e.currentTransmux=null,e.transmuxQueue.length&&(e.currentTransmux=e.transmuxQueue.shift(),"function"==typeof e.currentTransmux?e.currentTransmux():nh(e.currentTransmux))},oh=(e,t)=>{e.postMessage({action:t}),ah(e)},lh=(e,t)=>{t.currentTransmux?t.transmuxQueue.push(oh.bind(null,t,e)):(t.currentTransmux=e,oh(t,e))};const dh=e=>{e.transmuxer.currentTransmux?e.transmuxer.transmuxQueue.push(e):(e.transmuxer.currentTransmux=e,nh(e))};var hh=e=>{lh("reset",e)},uh=(dh,e=>{const t=new th,i=(t.currentTransmux=null,t.transmuxQueue=[],t.terminate);return t.terminate=()=>(t.currentTransmux=null,t.transmuxQueue.length=0,i.call(t)),t.postMessage({action:"init",options:e}),t});function ch(t){const i=t.transmuxer,s=t.endAction||t.action,r=t.callback;var e,n=fi({},t,{endAction:null,transmuxer:null,callback:null});const a=e=>{e.data.action===s&&(i.removeEventListener("message",a),e.data.data&&(e.data.data=new Uint8Array(e.data.data,t.byteOffset||0,t.byteLength||e.data.data.byteLength),t.data)&&(t.data=e.data.data),r(e.data))};i.addEventListener("message",a),t.data?(e=t.data instanceof ArrayBuffer,n.byteOffset=e?0:t.data.byteOffset,n.byteLength=t.data.byteLength,e=[e?t.data:t.data.buffer],i.postMessage(n,e)):i.postMessage(n)}function ph(e){let t=0;return e.audio&&t++,e.video&&t++,t}function mh(e,t){var i=t.attributes||{},s=Lh(function(e){e=e.attributes||{};if(e.CODECS)return Un(e.CODECS)}(t)||[]);return!Ph(e,t)||s.audio||((e,t)=>{if(!Ph(e,t))return!0;var t=t.attributes||{},i=e.mediaGroups.AUDIO[t.AUDIO];for(const s in i)if(!i[s].uri&&!i[s].playlists)return!0;return!1})(e,t)||(t=Lh(function(e,t){if(e.mediaGroups.AUDIO&&t){var i=e.mediaGroups.AUDIO[t];if(i)for(var s in i){s=i[s];if(s.default&&s.playlists)return Un(s.playlists[0].attributes.CODECS)}}return null}(e,i.AUDIO)||[])).audio&&(s.audio=t.audio),s}function gh(e,t){return(e=e&&window.getComputedStyle(e))?e[t]:""}function fh(e,t){let i,s;return i=(i=e.attributes.BANDWIDTH?e.attributes.BANDWIDTH:i)||window.Number.MAX_VALUE,s=(s=t.attributes.BANDWIDTH?t.attributes.BANDWIDTH:s)||window.Number.MAX_VALUE,i-s}const yh={FAILURE:2,TIMEOUT:-101,ABORTED:-102},_h=e=>
3812{e.forEach(e=>{e.abort()})},vh=e=>({bandwidth:e.bandwidth,bytesReceived:e.bytesReceived||0,roundTripTime:e.roundTripTime||0}),bh=e=>{var t=e.target,t={bandwidth:1/0,bytesReceived:0,roundTripTime:Date.now()-t.requestTime||0};return t.bytesReceived=e.loaded,t.bandwidth=Math.floor(t.bytesReceived/t.roundTripTime*8*1e3),t},Th=(e,t)=>t.timedout?{status:t.status,message:"HLS request timed-out at URL: "+t.uri,code:yh.TIMEOUT,xhr:t}:t.aborted?{status:t.status,message:"HLS request aborted at URL: "+t.uri,code:yh.ABORTED,xhr:t}:e?{status:t.status,message:"HLS request errored at URL: "+t.uri,code:yh.FAILURE,xhr:t}:"arraybuffer"===t.responseType&&0===t.response.byteLength?{status:t.status,message:"Empty HLS response at URL: "+t.uri,code:yh.FAILURE,xhr:t}:null,Sh=(r,n,a)=>(e,t)=>{var i=t.response,e=Th(e,t);if(e)return a(e,r);if(16!==i.byteLength)return a({status:t.status,message:"Invalid HLS key at URL: "+t.uri,code:yh.FAILURE,xhr:t},r);var e=new DataView(i),s=new Uint32Array([e.getUint32(0),e.getUint32(4),e.getUint32(8),e.getUint32(12)]);for(let e=0;e<n.length;e++)n[e].bytes=s;return a(null,r)},wh=(i,s)=>{var e,t=_l(i.map.bytes);if("mp4"!==t)return e=i.map.resolvedUri||i.map.uri,s({internal:!0,message:`Found unsupported ${t||"unknown"} container for initialization segment at URL: `+e,code:yh.FAILURE});ch({action:"probeMp4Tracks",data:i.map.bytes,transmuxer:i.transmuxer,callback:({tracks:e,data:t})=>(i.map.bytes=t,e.forEach(function(e){i.map.tracks=i.map.tracks||{},i.map.tracks[e.type]||"number"==typeof(i.map.tracks[e.type]=e).id&&e.timescale&&(i.map.timescales=i.map.timescales||{},i.map.timescales[e.id]=e.timescale)}),s(null))})},Eh=({segment:i,bytes:t,trackInfoFn:s,timingInfoFn:e,videoSegmentTimingInfoFn:r,audioSegmentTimingInfoFn:n,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:d,dataFn:h,doneFn:u,onTransmuxerLog:c})=>{var p=i.map&&i.map.tracks||{};const m=Boolean(p.audio&&p.video);let g=e.bind(null,i,"audio","start");const f=e.bind(null,i,"audio","end");let y=e.bind(null,i,"video","start");const _=e.bind(null,i,"video","end");ch({action:"probeTs",transmuxer:i.transmuxer,data:t,baseStartTime:i.baseStartTime,callback:e=>{i.bytes=t=e.data;e=e.result;e&&(s(i,{hasAudio:e.hasAudio,hasVideo:e.hasVideo,isMuxed:m}),s=null,e.hasAudio&&!m&&g(e.audioStart),e.hasVideo&&y(e.videoStart),g=null,y=null),dh({bytes:t,transmuxer:i.transmuxer,audioAppendStart:i.audioAppendStart,gopsToAlignWith:i.gopsToAlignWith,remux:m,onData:e=>{e.type="combined"===e.type?"video":e.type,h(i,e)},onTrackInfo:e=>{s&&(m&&(e.isMuxed=!0),s(i,e))},onAudioTimingInfo:e=>{g&&"undefined"!=typeof e.start&&(g(e.start),g=null),f&&"undefined"!=typeof e.end&&f(e.end)},onVideoTimingInfo:e=>{y&&"undefined"!=typeof e.start&&(y(e.start),y=null),_&&"undefined"!=typeof e.end&&_(e.end)},onVideoSegmentTimingInfo:e=>{r(e)},onAudioSegmentTimingInfo:e=>{n(e)},onId3:(e,t)=>{a(i,e,t)},onCaptions:e=>{o(i,[e])},isEndOfTimeline:l,onEndedTimeline:()=>{d()},onTransmuxerLog:c,onDone:e=>{u&&(e.type="combined"===e.type?"video":e.type,u(null,i,e))}})}})},kh=({segment:i,bytes:s,trackInfoFn:e,timingInfoFn:r,videoSegmentTimingInfoFn:t,audioSegmentTimingInfoFn:n,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:d,dataFn:h,doneFn:u,onTransmuxerLog:c})=>{let p=new Uint8Array(s);if(m=p,0<ml(m,["moof"]).length){i.isFmp4=!0;const g=i.map["tracks"],f={isFmp4:!0,hasVideo:!!g.video,hasAudio:!!g.audio},y=(g.audio&&g.audio.codec&&"enca"!==g.audio.codec&&(f.audioCodec=g.audio.codec),g.video&&g.video.codec&&"encv"!==g.video.codec&&(f.videoCodec=g.video.codec),g.video&&g.audio&&(f.isMuxed=!0),e(i,f),e=>{h(i,{data:p,type:f.hasAudio&&!f.isMuxed?"audio":"video"}),e&&e.length&&o(i,e),u(null,i,{})});void ch({action:"probeMp4StartTime",timescales:i.map.timescales,data:p,transmuxer:i.transmuxer,callback:({data:e,startTime:t})=>{s=e.buffer,i.bytes=p=e,f.hasAudio&&!f.isMuxed&&r(i,"audio","start",t),f.hasVideo&&r(i,"video","start",t),g.video&&e.byteLength&&i.transmuxer?ch({action:"pushMp4Captions",endAction:"mp4Captions",transmuxer:i.transmuxer,data:p,timescales:i.map.timescales,trackIds:[g.video.id],callback:e=>
3812{s=e.data.buffer,i.bytes=p=e.data,e.logs.forEach(function(e){c(O(e,{stream:"mp4CaptionParser"}))}),y(e.captions)}}):y()}})}else{var m;i.transmuxer?("undefined"==typeof i.container&&(i.container=_l(p)),"ts"!==i.container&&"aac"!==i.container?(e(i,{hasAudio:!1,hasVideo:!1}),u(null,i,{})):Eh({segment:i,bytes:s,trackInfoFn:e,timingInfoFn:r,videoSegmentTimingInfoFn:t,audioSegmentTimingInfoFn:n,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:d,dataFn:h,doneFn:u,onTransmuxerLog:c})):u(null,i,{})}},Ch=function({id:t,key:e,encryptedBytes:i,decryptionWorker:s},r){const n=e=>{e.data.source===t&&(s.removeEventListener("message",n),e=e.data.decrypted,r(new Uint8Array(e.bytes,e.byteOffset,e.byteLength)))};s.addEventListener("message",n);let a;a=e.bytes.slice?e.bytes.slice():new Uint32Array(Array.prototype.slice.call(e.bytes)),s.postMessage(Od({source:t,encrypted:i,key:a,iv:e.iv}),[i.buffer,a.buffer])},Ih=({decryptionWorker:e,segment:t,trackInfoFn:i,timingInfoFn:s,videoSegmentTimingInfoFn:r,audioSegmentTimingInfoFn:n,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:d,dataFn:h,doneFn:u,onTransmuxerLog:c})=>{Ch({id:t.requestId,key:t.key,encryptedBytes:t.encryptedBytes,decryptionWorker:e},e=>{t.bytes=e,kh({segment:t,bytes:t.bytes,trackInfoFn:i,timingInfoFn:s,videoSegmentTimingInfoFn:r,audioSegmentTimingInfoFn:n,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:d,dataFn:h,doneFn:u,onTransmuxerLog:c})})},xh=({xhr:e,xhrOptions:t,decryptionWorker:i,segment:s,abortFn:r,progressFn:n,trackInfoFn:a,timingInfoFn:o,videoSegmentTimingInfoFn:l,audioSegmentTimingInfoFn:d,id3Fn:h,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:p,dataFn:m,doneFn:g,onTransmuxerLog:f})=>{const y=[];var _,v,i=(({activeXhrs:s,decryptionWorker:r,trackInfoFn:n,timingInfoFn:a,videoSegmentTimingInfoFn:o,audioSegmentTimingInfoFn:l,id3Fn:d,captionsFn:h,isEndOfTimeline:u,endedTimelineFn:c,dataFn:p,doneFn:m,onTransmuxerLog:g})=>{let f=0,y=!1;return(e,t)=>{if(!y){if(e)return y=!0,_h(s),m(e,t);if((f+=1)===s.length){const i=function(){if(t.encryptedBytes)return Ih({decryptionWorker:r,segment:t,trackInfoFn:n,timingInfoFn:a,videoSegmentTimingInfoFn:o,audioSegmentTimingInfoFn:l,id3Fn:d,captionsFn:h,isEndOfTimeline:u,endedTimelineFn:c,dataFn:p,doneFn:m,onTransmuxerLog:g});kh({segment:t,bytes:t.bytes,trackInfoFn:n,timingInfoFn:a,videoSegmentTimingInfoFn:o,audioSegmentTimingInfoFn:l,id3Fn:d,captionsFn:h,isEndOfTimeline:u,endedTimelineFn:c,dataFn:p,doneFn:m,onTransmuxerLog:g})};if(t.endOfAllRequests=Date.now(),t.map&&t.map.encryptedBytes&&!t.map.bytes)return Ch({decryptionWorker:r,id:t.requestId+"-init",encryptedBytes:t.map.encryptedBytes,key:t.map.key},e=>{t.map.bytes=e,wh(t,e=>{if(e)return _h(s),m(e,t);i()})});i()}}}})({activeXhrs:y,decryptionWorker:i,trackInfoFn:a,timingInfoFn:o,videoSegmentTimingInfoFn:l,audioSegmentTimingInfoFn:d,id3Fn:h,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:p,dataFn:m,doneFn:g,onTransmuxerLog:f}),u=(s.key&&!s.key.bytes&&(a=[s.key],s.map&&!s.map.bytes&&s.map.key&&s.map.key.resolvedUri===s.key.resolvedUri&&a.push(s.map.key),o=e(O(t,{uri:s.key.resolvedUri,responseType:"arraybuffer"}),Sh(s,a,i)),y.push(o)),s.map&&!s.map.bytes&&(!s.map.key||s.key&&s.key.resolvedUri===s.map.key.resolvedUri||(l=e(O(t,{uri:s.map.key.resolvedUri,responseType:"arraybuffer"}),Sh(s,[s.map.key],i)),y.push(l)),d=O(t,{uri:s.map.resolvedUri,responseType:"arraybuffer",headers:Ad(s.map)}),{segment:_,finishProcessingFn:v}=[{segment:s,finishProcessingFn:i}][0],h=e(d,(e,t)=>{var e=Th(e,t);return e?v(e,_):(e=new Uint8Array(t.response),_.map.key?(_.map.encryptedBytes=e,v(null,_)):(_.map.bytes=e,void wh(_,function(e){if(e)return e.xhr=t,e.status=t.status,v(e,_);v(null,_)})))}),y.push(h)),O(t,{uri:s.part&&s.part.resolvedUri||s.resolvedUri,responseType:"arraybuffer",headers:Ad(s)}));({segment:b,finishProcessingFn:T,responseType:S}={segment:s,finishProcessingFn:i,responseType:u.responseType});var b,T,S,w,E,c=e(u,(e,t)=>{var e=Th(e,t);return e?T(e,b):(e="arraybuffer"!==S&&t.responseText?Qd(t.responseText.substring(b.lastReachedChar||0)):t.response,b.stats=vh(t),b.key?b.encryptedBytes=new Uint8Array(e):b.bytes=new Uint8Array(e),T(null,b))});c.addEventListener("progress",({segment:w,progressFn:E}=[{segment:s,progressFn:n}][0],e=>{var t=e.target;if(!t.aborted)return w.stats=O(w.stats,bh(e)),!w.stats.firstBytesReceivedAt&&w.stats.bytesReceived&&(w.stats.firstBytesReceivedAt=Date.now()),E(e,w)})),y.push(c);const k={};
vendor: 22,169 bytes, line 3812
3812return y.forEach(e=>{var t,i;e.addEventListener("loadend",({loadendState:t,abortFn:i}=[{loadendState:k,abortFn:r}][0],e=>{e.target.aborted&&i&&!t.calledAbortFn&&(i(),t.calledAbortFn=!0)}))}),()=>_h(y)},Ah=Bl("CodecUtils"),Ph=(e,t)=>{t=t.attributes||{};return e&&e.mediaGroups&&e.mediaGroups.AUDIO&&t.AUDIO&&e.mediaGroups.AUDIO[t.AUDIO]},Lh=function(e){const s={};return e.forEach(({mediaType:e,type:t,details:i})=>{s[e]=s[e]||[],s[e].push(Rn(""+t+i))}),Object.keys(s).forEach(function(e){1<s[e].length?(Ah(`multiple ${e} codecs found as attributes: ${s[e].join(", ")}. Setting playlist codecs to null so that we wait for mux.js to probe segments for real codecs.`),s[e]=null):s[e]=s[e][0]}),s},Oh=Bl("PlaylistSelector"),Dh=function(e){var t;if(e&&e.playlist)return t=e.playlist,JSON.stringify({id:t.id,bandwidth:e.bandwidth,width:e.width,height:e.height,codecs:t.attributes&&t.attributes.CODECS||""})},Nh=function(e,s){const r=e.slice();e.sort(function(e,t){var i=s(e,t);return 0===i?r.indexOf(e)-r.indexOf(t):i})};function Mh(o,t,l,d,h,u){if(o){var c={bandwidth:t,width:l,height:d,limitRenditionByPlayerDimensions:h};let e=o.playlists,r=(md.isAudioOnly(o)&&(e=u.getAudioTrackPlaylists_(),c.audioOnly=!0),e.map(e=>{var t=e.attributes&&e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width,i=e.attributes&&e.attributes.RESOLUTION&&e.attributes.RESOLUTION.height,s=e.attributes&&e.attributes.BANDWIDTH;return{bandwidth:s||window.Number.MAX_VALUE,width:t,height:i,playlist:e}})),n=(Nh(r,(e,t)=>e.bandwidth-t.bandwidth),(r=r.filter(e=>!md.isIncompatible(e.playlist))).filter(e=>md.isEnabled(e.playlist)));o=(n=n.length?n:r.filter(e=>!md.isDisabled(e.playlist))).filter(e=>e.bandwidth*D.BANDWIDTH_VARIANCE<t);let a=o[o.length-1];var p=o.filter(e=>e.bandwidth===a.bandwidth)[0];if(!1===h){const g=p||n[0]||r[0];if(g&&g.playlist){let e=p?"bandwidthBestRep":"sortedPlaylistReps";return n[0]&&(e="enabledPlaylistReps"),Oh(`choosing ${Dh(g)} using ${e} with options`,c),g.playlist}}else{var m,h=o.filter(e=>e.width&&e.height),o=(Nh(h,(e,t)=>e.width-t.width),h.filter(e=>e.width===l&&e.height===d)),o=(a=o[o.length-1],o.filter(e=>e.bandwidth===a.bandwidth)[0]);let t,i;o||(m=(t=h.filter(e=>e.width>l||e.height>d)).filter(e=>e.width===t[0].width&&e.height===t[0].height),a=m[m.length-1],i=m.filter(e=>e.bandwidth===a.bandwidth)[0]);let s;u.leastPixelDiffSelector&&(m=h.map(e=>(e.pixelDiff=Math.abs(e.width-l)+Math.abs(e.height-d),e)),Nh(m,(e,t)=>e.pixelDiff===t.pixelDiff?t.bandwidth-e.bandwidth:e.pixelDiff-t.pixelDiff),s=m[0]);const g=s||i||o||p||n[0]||r[0];if(g&&g.playlist){let e="sortedPlaylistReps";return s?e="leastPixelDiffRep":i?e="resolutionPlusOneRep":o?e="resolutionBestRep":p?e="bandwidthBestRep":n[0]&&(e="enabledPlaylistReps"),Oh(`choosing ${Dh(g)} using ${e} with options`,c),g.playlist}}return Oh("could not choose a playlist with options",c),null}}function Rh(){var e=this.useDevicePixelRatio&&window.devicePixelRatio||1;return Mh(this.playlists.main,this.systemBandwidth,parseInt(gh(this.tech_.el(),"width"),10)*e,parseInt(gh(this.tech_.el(),"height"),10)*e,this.limitRenditionByPlayerDimensions,this.playlistController_)}function Uh(e,t,i){let s;var r;if(i&&i.cues)for(s=i.cues.length;s--;)(r=i.cues[s]).startTime>=e&&r.endTime<=t&&i.removeCue(r)}const Bh=({inbandTextTracks:e,metadataArray:t,timestampOffset:i,videoDuration:s})=>{if(t){const a=window.WebKitDataCue||window.VTTCue,o=e.metadataTrack_;if(o&&(t.forEach(e=>{const s=e.cueTime+i;!("number"!=typeof s||window.isNaN(s)||s<0)&&s<1/0&&e.frames.forEach(e=>{var t,i=new a(s,s,e.value||e.url||e.data||"");i.frame=e,i.value=e,t=i,Object.defineProperties(t.frame,{id:{get(){return T.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),t.value.key}},value:{get(){return T.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),t.value.data}},privateData:{get(){return T.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),t.value.data}}}),o.addCue(i)})}),o.cues)&&o.cues.length){var r=o.cues,n=[];for(let e=0;e<r.length;e++)r[e]&&n.push(r[e]);const l=n.reduce((e,t)=>{var i=e[t.startTime]||[];return i.push(t),e[t.startTime]=i,e},{}),d=Object.keys(l).sort((e,t)=>Number(e)-Number(t));d.forEach((e,t)=>{e=l[e];const i=Number(d[t+1])||s;e.forEach(e=>{e.endTime=i})})}}},Fh=e=>"number"==typeof e&&isFinite(e),jh=e=>{var{startOfSegment:t,duration:i,segment:s,part:r,playlist:{mediaSequence:n,id:a,segments:o=[]},mediaIndex:l,partIndex:d,timeline:h}=e,o=o.length-1;let u="mediaIndex/partIndex increment";e.getMediaInfoForTime?u=`getMediaInfoForTime (${e.getMediaInfoForTime})`:e.isSyncRequest&&(u="getSyncSegmentCandidate (isSyncRequest)"),e.independent&&(u+=" with independent "+e.independent);var c="number"==typeof d,e=e.segment.uri?"segment":"pre-segment",p=c?ed({preloadSegment:s})-1:0;return e+` [${n+l}/${n+o}]`+(c?` part [${d}/${p}]`:"")+` segment start/end [${s.start} => ${s.end}]`+(c?` part start/end [${r.start} => ${r.end}]`:"")+` startOfSegment [${t}]`+` duration [${i}]`+` timeline [${h}]`+` selected by [${u}]`+` playlist [${a}]`},Hh=e=>e+"TimingInfo",qh=({timelineChangeController:e,currentTimeline:t,segmentTimeline:i,loaderType:s,audioDisabled:r})=>{return!(t===i||("audio"===s?(t=e.lastTimelineChange({type:"main"}))&&t.to===i:"main"!==s||!r||(t=e.pendingTimelineChange({type:"audio"}))&&t.to===i))},Vh=({segmentDuration:e,maxDuration:t})=>!!e&&Math.round(e)>t+Gl,$h=(e,t)=>{var i,s,r;return"hls"===t&&(t=(e=>{let s=0;return["video","audio"].forEach(function(t){t=e[t+"TimingInfo"];if(t){var{start:t,end:i}=t;let e;"bigint"==typeof t||"bigint"==typeof i?e=window.BigInt(i)-window.BigInt(t):"number"==typeof t&&"number"==typeof i&&(e=i-t),"undefined"!=typeof e&&e>s&&(s=e)}}),s="bigint"==typeof s&&s<Number.MAX_SAFE_INTEGER?Number(s):s})({audioTimingInfo:e.audioTimingInfo,videoTimingInfo:e.videoTimingInfo}))&&(i=e.playlist.targetDuration,s=Vh({segmentDuration:t,maxDuration:2*i}),r=Vh({segmentDuration:t,maxDuration:i}),t=`Segment with index ${e.mediaIndex} `+`from playlist ${e.playlist.id} `+`has a duration of ${t} `+`when the reported duration is ${e.duration} `+`and the target duration is ${i}. `+"For HLS content, a duration in excess of the target duration may result in playback issues. See the HLS specification section on EXT-X-TARGETDURATION for more details: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.3.1",s||r)?{severity:s?"warn":"info",message:t}:null};class Wh extends T.EventTarget{constructor(e,t=0){if(super(),!e)throw new TypeError("Initialization settings are required");if("function"!=typeof e.currentTime)throw new TypeError("No currentTime getter specified");if(!e.mediaSource)throw new TypeError("No MediaSource specified");this.bandwidth=e.bandwidth,this.throughput={rate:0,count:0},this.roundTrip=NaN,this.resetStats_(),this.mediaIndex=null,this.partIndex=null,this.hasPlayed_=e.hasPlayed,this.currentTime_=e.currentTime,this.seekable_=e.seekable,this.seeking_=e.seeking,this.duration_=e.duration,this.mediaSource_=e.mediaSource,this.vhs_=e.vhs,this.loaderType_=e.loaderType,this.currentMediaInfo_=void 0,this.startingMediaInfo_=void 0,this.segmentMetadataTrack_=e.segmentMetadataTrack,this.goalBufferLength_=e.goalBufferLength,this.sourceType_=e.sourceType,this.sourceUpdater_=e.sourceUpdater,this.inbandTextTracks_=e.inbandTextTracks,this.state_="INIT",this.timelineChangeController_=e.timelineChangeController,this.shouldSaveSegmentTimingInfo_=!0,this.parse708captions_=e.parse708captions,this.useDtsForTimestampOffset_=e.useDtsForTimestampOffset,this.captionServices_=e.captionServices,this.exactManifestTimings=e.exactManifestTimings,this.checkBufferTimeout_=null,this.error_=void 0,this.currentTimeline_=-1,this.pendingSegment_=null,this.xhrOptions_=null,this.pendingSegments_=[],this.audioDisabled_=!1,this.isPendingTimestampOffset_=!1,this.gopBuffer_=[],this.timeMapping_=0,this.safeAppend_=11<=T.browser.IE_VERSION,this.appendInitSegment_={audio:!0,video:!0},this.playlistOfLastInitSegment_={audio:null,video:null},this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_={id3:[],caption:[]},this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=null,this.activeInitSegmentId_=null,this.initSegments_={},this.cacheEncryptionKeys_=e.cacheEncryptionKeys,this.keyCache_={},this.decrypter_=e.decrypter,this.syncController_=e.syncController,this.syncPoint_={segmentIndex:0,time:0},this.transmuxer_=this.createTransmuxer_(),this.triggerSyncInfoUpdate_=()=>this.trigger("syncinfoupdate"),this.syncController_.on("syncinfoupdate",this.triggerSyncInfoUpdate_),this.mediaSource_.addEventListener("sourceopen",()=>{this.isEndOfStream_()||(this.ended_=!1)}),this.fetchAtBuffer_=!1,this.logger_=Bl(`SegmentLoader[${this.loaderType_}]`),Object.defineProperty(this,"state",{get(){return this.state_},set(e){e!==this.state_&&(this.logger_(this.state_+" -> "+e),this.state_=e,this.trigger("statechange"))}}),this.sourceUpdater_.on("ready",()=>{this.hasEnoughInfoToAppend_()&&this.processCallQueue_()}),"main"===this.loaderType_&&this.timelineChangeController_.on("pendingtimelinechange",()=>{this.hasEnoughInfoToAppend_()&&this.processCallQueue_()}),"audio"===this.loaderType_&&this.timelineChangeController_.on("timelinechange",()=>{this.hasEnoughInfoToLoad_()&&this.processLoadQueue_(),this.hasEnoughInfoToAppend_()&&this.processCallQueue_()})}createTransmuxer_(){return uh({remux:!1,alignGopsAtEnd:this.safeAppend_,keepOriginalTimestamps:!0,parse708captions:this.parse708captions_,captionServices:this.captionServices_})}resetStats_(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0,this.mediaAppends=0}dispose(){this.trigger("dispose"),this.state="DISPOSED",this.pause(),this.abort_(),this.transmuxer_&&this.transmuxer_.terminate(),this.resetStats_(),this.checkBufferTimeout_&&window.clearTimeout(this.checkBufferTimeout_),this.syncController_&&this.triggerSyncInfoUpdate_&&this.syncController_.off("syncinfoupdate",this.triggerSyncInfoUpdate_),this.off()}setAudio(e){this.audioDisabled_=!e,e?this.appendInitSegment_.audio=!0:this.sourceUpdater_.removeAudio(0,this.duration_())}abort(){"WAITING"!==this.state?this.pendingSegment_&&(this.pendingSegment_=null):(this.abort_(),this.state="READY",this.paused()||this.monitorBuffer_())}abort_(){this.pendingSegment_&&this.pendingSegment_.abortRequests&&this.pendingSegment_.abortRequests(),this.pendingSegment_=null,this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_),this.waitingOnRemove_=!1,window.clearTimeout(this.quotaExceededErrorRetryTimeout_),this.quotaExceededErrorRetryTimeout_=null}checkForAbort_(e){return"APPENDING"!==this.state||this.pendingSegment_?!this.pendingSegment_||this.pendingSegment_.requestId!==e:(this.state="READY",!0)}error(e){return"undefined"!=typeof e&&(this.logger_("error occurred:",e),this.error_=e),this.pendingSegment_=null,this.error_}endOfStream(){this.ended_=!0,this.transmuxer_&&hh(this.transmuxer_),this.gopBuffer_.length=0,this.pause(),this.trigger("ended")}buffered_(){var e=this.getMediaInfo_();if(!this.sourceUpdater_||!e)return Fl();if("main"===this.loaderType_){var{hasAudio:e,hasVideo:t,isMuxed:i}=e;if(t&&e&&!this.audioDisabled_&&!i)return this.sourceUpdater_.buffered();if(t)return this.sourceUpdater_.videoBuffered()}return this.sourceUpdater_.audioBuffered()}initSegmentForMap(e,t=!1){if(!e)return null;var i=Dd(e);let s=this.initSegments_[i];return t&&!s&&e.bytes&&(this.initSegments_[i]=s={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:e.bytes,tracks:e.tracks,timescales:e.timescales}),s||e}segmentKey(e,t=!1){if(!e)return null;var i=Nd(e);let s=this.keyCache_[i];this.cacheEncryptionKeys_&&t&&!s&&e.bytes&&(this.keyCache_[i]=s={resolvedUri:e.resolvedUri,bytes:e.bytes});t={resolvedUri:(s||e).resolvedUri};return s&&(t.bytes=s.bytes),t}couldBeginLoading_(){return this.playlist_&&!this.paused()}load(){if(this.monitorBuffer_(),this.playlist_)return"INIT"===this.state&&this.couldBeginLoading_()?this.init_():void(!this.couldBeginLoading_()||"READY"!==this.state&&"INIT"!==this.state||(this.state="READY"))}init_(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}playlist(t,i={}){if(t){var s,r=this.playlist_,n=this.pendingSegment_;this.playlist_=t,this.xhrOptions_=i,"INIT"===this.state&&(t.syncInfo={mediaSequence:t.mediaSequence,time:0},"main"===this.loaderType_)&&this.syncController_.setDateTimeMappingForStart(t);let e=null;if(r&&(r.id?e=r.id:r.uri&&(e=r.uri)),this.logger_(`playlist update [${e} => ${t.id||t.uri}]`),this.trigger("syncinfoupdate"),"INIT"===this.state&&this.couldBeginLoading_())return this.init_();r&&r.uri===t.uri?(i=t.mediaSequence-r.mediaSequence,this.logger_(`live window shift [${i}]`),null!==this.mediaIndex&&(this.mediaIndex-=i,this.mediaIndex<0?(this.mediaIndex=null,this.partIndex=null):(s=this.playlist_.segments[this.mediaIndex],!this.partIndex||s.parts&&s.parts.length&&s.parts[this.partIndex]||(s=this.mediaIndex,this.logger_(`currently processing part (index ${this.partIndex}) no longer exists.`),this.resetLoader(),this.mediaIndex=s))),n&&(n.mediaIndex-=i,n.mediaIndex<0?(n.mediaIndex=null,n.partIndex=null):(0<=n.mediaIndex&&(n.segment=t.segments[n.mediaIndex]),0<=n.partIndex&&n.segment.parts&&(n.part=n.segment.parts[n.partIndex]))),this.syncController_.saveExpiredSegmentInfo(r,t)):(null!==this.mediaIndex&&(t.endList?this.resyncLoader():this.resetLoader()),this.currentMediaInfo_=void 0,this.trigger("playlistupdate"))}}pause(){this.checkBufferTimeout_&&(window.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null)}paused(){return null===this.checkBufferTimeout_}resetEverything(e){this.ended_=!1,this.activeInitSegmentId_=null,this.appendInitSegment_={audio:!0,video:!0},this.resetLoader(),this.remove(0,1/0,e),this.transmuxer_&&(this.transmuxer_.postMessage({action:"clearAllMp4Captions"}),this.transmuxer_.postMessage({action:"reset"}))}resetLoader(){this.fetchAtBuffer_=!1,this.resyncLoader()}resyncLoader(){this.transmuxer_&&hh(this.transmuxer_),this.mediaIndex=null,this.partIndex=null,this.syncPoint_=null,this.isPendingTimestampOffset_=!1,this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.abort(),this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})}remove(t,i,s=()=>{},r=!1){if((i=i===1/0?this.duration_():i)<=t)this.logger_("skipping remove because end ${end} is <= start ${start}");else if(this.sourceUpdater_&&this.getMediaInfo_()){let e=1;var n=()=>{0===--e&&s()};!r&&this.audioDisabled_||(e++,this.sourceUpdater_.removeAudio(t,i,n)),!r&&"main"!==this.loaderType_||(this.gopBuffer_=((t,i,e,s)=>{var r=Math.ceil((i-s)*Ml),n=Math.ceil((e-s)*Ml),i=t.slice();let a=t.length;for(;a--&&!(t[a].pts<=n););if(-1!==a){let e=a+1;for(;e--&&!(t[e].pts<=r););e=Math.max(e,0),i.splice(e,a-e+1)}return i})(this.gopBuffer_,t,i,this.timeMapping_),e++,this.sourceUpdater_.removeVideo(t,i,n));for(const a in this.inbandTextTracks_)Uh(t,i,this.inbandTextTracks_[a]);Uh(t,i,this.segmentMetadataTrack_),n()}else this.logger_("skipping remove because no source updater or starting media info")}monitorBuffer_(){this.checkBufferTimeout_&&window.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=window.setTimeout(this.monitorBufferTick_.bind(this),1)}monitorBufferTick_(){"READY"===this.state&&this.fillBuffer_(),this.checkBufferTimeout_&&window.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=window.setTimeout(this.monitorBufferTick_.bind(this),500)}fillBuffer_(){var e;this.sourceUpdater_.updating()||(e=this.chooseNextRequest_())&&("number"==typeof e.timestampOffset&&(this.isPendingTimestampOffset_=!1,this.timelineChangeController_.pendingTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline})),this.loadSegment_(e))}isEndOfStream_(e=this.mediaIndex,t=this.playlist_,i=this.partIndex){var s;return!(!t||!this.mediaSource_)&&(s="number"==typeof e&&t.segments[e],e=e+1===t.segments.length,i=!s||!s.parts||i+1===s.parts.length,t.endList)&&"open"===this.mediaSource_.readyState&&e&&i}chooseNextRequest_(){var e=this.buffered_(),t=ql(e)||0,e=Vl(e,this.currentTime_()),i=!this.hasPlayed_()&&1<=e,s=e>=this.goalBufferLength_(),r=this.playlist_.segments;if(!r.length||i||s)return null;this.syncPoint_=this.syncPoint_||this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_());var n,i={partIndex:null,mediaIndex:null,startOfSegment:null,playlist:this.playlist_,isSyncRequest:Boolean(!this.syncPoint_)},t=(i.isSyncRequest?i.mediaIndex=function(t,i,s){i=i||[];var r=[];let n=0;for(let e=0;e<i.length;e++){var a=i[e];if(t===a.timeline&&(r.push(e),(n+=a.duration)>s))return e}return 0===r.length?0:r[r.length-1]}(this.currentTimeline_,r,t):null!==this.mediaIndex?(s=r[this.mediaIndex],n="number"==typeof this.partIndex?this.partIndex:-1,i.startOfSegment=s.end||t,s.parts&&s.parts[n+1]?(i.mediaIndex=this.mediaIndex,i.partIndex=n+1):i.mediaIndex=this.mediaIndex+1):({segmentIndex:s,startTime:n,partIndex:o}=md.getMediaInfoForTime({exactManifestTimings:this.exactManifestTimings,playlist:this.playlist_,currentTime:this.fetchAtBuffer_?t:this.currentTime_(),startingPartIndex:this.syncPoint_.partIndex,startingSegmentIndex:this.syncPoint_.segmentIndex,startTime:this.syncPoint_.time}),i.getMediaInfoForTime=this.fetchAtBuffer_?"bufferedEnd "+t:"currentTime "+this.currentTime_(),i.mediaIndex=s,i.startOfSegment=n,i.partIndex=o),r[i.mediaIndex]);let a=t&&"number"==typeof i.partIndex&&t.parts&&t.parts[i.partIndex];if(!t||"number"==typeof i.partIndex&&!a)return null;"number"!=typeof i.partIndex&&t.parts&&(i.partIndex=0,a=t.parts[0]),e||!a||a.independent||(0===i.partIndex?(n=(s=r[i.mediaIndex-1]).parts&&s.parts.length&&s.parts[s.parts.length-1])&&n.independent&&(--i.mediaIndex,i.partIndex=s.parts.length-1,i.independent="previous segment"):t.parts[i.partIndex-1].independent&&(--i.partIndex,i.independent="previous part"));var o=this.mediaSource_&&"ended"===this.mediaSource_.readyState;return i.mediaIndex>=r.length-1&&o&&!this.seeking_()?null:this.generateSegmentInfo_(i)}generateSegmentInfo_(e){var{independent:e,playlist:t,mediaIndex:i,startOfSegment:s,isSyncRequest:r,partIndex:n,forceTimestampOffset:a,getMediaInfoForTime:o}=e,l=t.segments[i],d="number"==typeof n&&l.parts[n],i={requestId:"segment-loader-"+Math.random(),uri:d&&d.resolvedUri||l.resolvedUri,mediaIndex:i,partIndex:d?n:null,isSyncRequest:r,startOfSegment:s,playlist:t,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:l.timeline,duration:d&&d.duration||l.duration,segment:l,part:d,byteLength:0,transmuxer:this.transmuxer_,getMediaInfoForTime:o,independent:e},n="undefined"!=typeof a?a:this.isPendingTimestampOffset_,r=(i.timestampOffset=this.timestampOffsetForSegment_({segmentTimeline:l.timeline,currentTimeline:this.currentTimeline_,startOfSegment:s,buffered:this.buffered_(),overrideCheck:n}),ql(this.sourceUpdater_.audioBuffered()));return"number"==typeof r&&(i.audioAppendStart=r-this.sourceUpdater_.audioTimestampOffset()),this.sourceUpdater_.videoBuffered().length&&(i.gopsToAlignWith=((e,t,i)=>{if("undefined"==typeof t||null===t||!e.length)return[];var s=Math.ceil((t-i+3)*Ml);let r;for(r=0;r<e.length&&!(e[r].pts>s);r++);return e.slice(r)})(this.gopBuffer_,this.currentTime_()-this.sourceUpdater_.videoTimestampOffset(),this.timeMapping_)),i}timestampOffsetForSegment_(e){return{segmentTimeline:e,currentTimeline:t,startOfSegment:i,buffered:s,overrideCheck:r}=[e][0],r||e!==t?!(e<t)&&s.length?s.end(s.length-1):i:null;var t,i,s,r}earlyAbortWhenNeeded_(t){if(!this.vhs_.tech_.paused()&&this.xhrOptions_.timeout&&this.playlist_.attributes.BANDWIDTH&&!(Date.now()-(t.firstBytesReceivedAt||Date.now())<1e3)){var e=this.currentTime_(),i=t.bandwidth,s=this.pendingSegment_.duration,t=md.estimateSegmentRequestTime(s,i,this.playlist_,t.bytesReceived),r=([r,n,a=1]=[this.buffered_(),e,this.vhs_.tech_.playbackRate()],((r.length?r.end(r.length-1):0)-n)/a-1);if(!(t<=r)){var n=function(e){const{main:t,currentTime:i,bandwidth:s,duration:r,segmentDuration:n,timeUntilRebuffer:a,currentTimeline:o,syncController:l}=e;e=t.playlists.filter(e=>!md.isIncompatible(e));let d=e.filter(md.isEnabled);var e=(d=d.length?d:e.filter(e=>!md.isDisabled(e))).filter(md.hasAttribute.bind(null,"BANDWIDTH")).map(e=>{var t=l.getSyncPoint(e,r,o,i)?1:2;return{playlist:e,rebufferingImpact:md.estimateSegmentRequestTime(n,s,e)*t-a}}),h=e.filter(e=>e.rebufferingImpact<=0);return Nh(h,(e,t)=>fh(t.playlist,e.playlist)),h.length?h[0]:(Nh(e,(e,t)=>e.rebufferingImpact-t.rebufferingImpact),e[0]||null)}({main:this.vhs_.playlists.main,currentTime:e,bandwidth:i,duration:this.duration_(),segmentDuration:s,timeUntilRebuffer:r,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(n){var a=t-r-n.rebufferingImpact;let e=.5;r<=Gl&&(e=1),!n.playlist||n.playlist.uri===this.playlist_.uri||a<e||(this.bandwidth=n.playlist.attributes.BANDWIDTH*D.BANDWIDTH_VARIANCE+1,this.trigger("earlyabort"))}}}}handleAbort_(e){this.logger_("Aborting "+jh(e)),this.mediaRequestsAborted+=1}handleProgress_(e,t){this.earlyAbortWhenNeeded_(t.stats),this.checkForAbort_(t.requestId)||this.trigger("progress")}handleTrackInfo_(e,t){this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId)||this.checkForIllegalMediaSwitch(t)||(function(t,i){if(!t&&!i||!t&&i||t&&!i)return!1;if(t!==i){var s=Object.keys(t).sort(),r=Object.keys(i).sort();if(s.length!==r.length)return!1;for(let e=0;e<s.length;e++){var n=s[e];if(n!==r[e])return!1;if(t[n]!==i[n])return!1}}return!0}(this.currentMediaInfo_,t=t||{})||(this.appendInitSegment_={audio:!0,video:!0},this.startingMediaInfo_=t,this.currentMediaInfo_=t,this.logger_("trackinfo update",t),this.trigger("trackinfo")),this.checkForAbort_(e.requestId))||(this.pendingSegment_.trackInfo=t,this.hasEnoughInfoToAppend_()&&this.processCallQueue_())}handleTimingInfo_(e,t,i,s){var r;this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId)||
3812((e=this.pendingSegment_)[r=Hh(t)]=e[r]||{},e[r][i]=s,this.logger_(`timinginfo: ${t} - ${i} - `+s),this.hasEnoughInfoToAppend_()&&this.processCallQueue_())}handleCaptions_(e,t){if(this.earlyAbortWhenNeeded_(e.stats),!this.checkForAbort_(e.requestId))if(0===t.length)this.logger_("SegmentLoader received no captions from a caption event");else if(this.pendingSegment_.hasAppendedData_){const c=null===this.sourceUpdater_.videoTimestampOffset()?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset(),p={};t.forEach(e=>{p[e.stream]=p[e.stream]||{startTime:1/0,captions:[],endTime:0};var t=p[e.stream];t.startTime=Math.min(t.startTime,e.startTime+c),t.endTime=Math.max(t.endTime,e.endTime+c),t.captions.push(e)}),Object.keys(p).forEach(e=>{var{startTime:t,endTime:i,captions:s}=p[e],r=this.inbandTextTracks_,n=(this.logger_(`adding cues from ${t} -> ${i} for `+e),r),a=this.vhs_.tech_,o=e;if(!n[o]){a.trigger({type:"usage",name:"vhs-608"});let s=o;/^cc708_/.test(o)&&(s="SERVICE"+o.split("_")[1]);var l=a.textTracks().getTrackById(s);if(l)n[o]=l;else{let e=o,t=o,i=!1;l=(a.options_.vhs&&a.options_.vhs.captionServices||{})[s];l&&(e=l.label,t=l.language,i=l.default),n[o]=a.addRemoteTextTrack({kind:"captions",id:s,default:i,label:e,language:t},!1).track}}Uh(t,i,r[e]);var{inbandTextTracks:d,captionArray:l,timestampOffset:h}={captionArray:s,inbandTextTracks:r,timestampOffset:c};if(l){const u=window.WebKitDataCue||window.VTTCue;l.forEach(e=>{var t=e.stream;d[t].addCue(new u(e.startTime+h,e.endTime+h,e.text))})}}),this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})}else this.metadataQueue_.caption.push(this.handleCaptions_.bind(this,e,t))}handleId3_(e,t,i){var s,r,n,a;this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId)||(this.pendingSegment_.hasAppendedData_?(s=null===this.sourceUpdater_.videoTimestampOffset()?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset(),r=this.inbandTextTracks_,n=i,a=this.vhs_.tech_,r.metadataTrack_||(r.metadataTrack_=a.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,r.metadataTrack_.inBandMetadataTrackDispatchType=n),Bh({inbandTextTracks:this.inbandTextTracks_,metadataArray:t,timestampOffset:s,videoDuration:this.duration_()})):this.metadataQueue_.id3.push(this.handleId3_.bind(this,e,t,i)))}processMetadataQueue_(){this.metadataQueue_.id3.forEach(e=>e()),this.metadataQueue_.caption.forEach(e=>e()),this.metadataQueue_.id3=[],this.metadataQueue_.caption=[]}processCallQueue_(){var e=this.callQueue_;this.callQueue_=[],e.forEach(e=>e())}processLoadQueue_(){var e=this.loadQueue_;this.loadQueue_=[],e.forEach(e=>e())}hasEnoughInfoToLoad_(){var e;return"audio"!==this.loaderType_||!(!(e=this.pendingSegment_)||this.getCurrentMediaInfo_()&&qh({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}))}getCurrentMediaInfo_(e=this.pendingSegment_){return e&&e.trackInfo||this.currentMediaInfo_}getMediaInfo_(e=this.pendingSegment_){return this.getCurrentMediaInfo_(e)||this.startingMediaInfo_}getPendingSegmentPlaylist(){return this.pendingSegment_?this.pendingSegment_.playlist:null}hasEnoughInfoToAppend_(){var e,t,i,s;return!!this.sourceUpdater_.ready()&&!(this.waitingOnRemove_||this.quotaExceededErrorRetryTimeout_||(e=this.pendingSegment_,t=this.getCurrentMediaInfo_(),!e)||!t||({hasAudio:t,hasVideo:i,isMuxed:s}=t,i&&!e.videoTimingInfo)||t&&!this.audioDisabled_&&!s&&!e.audioTimingInfo||qh({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}))}handleData_(t,e){if(this.earlyAbortWhenNeeded_(t.stats),!this.checkForAbort_(t.requestId))if(this.callQueue_.length||!this.hasEnoughInfoToAppend_())this.callQueue_.push(this.handleData_.bind(this,t,e));else{var i=this.pendingSegment_;if(this.setTimeMapping_(i.timeline),this.updateMediaSecondsLoaded_(i.part||i.segment),"closed"!==this.mediaSource_.readyState){if(t.map&&(t.map=this.initSegmentForMap(t.map,!0),i.segment.map=t.map),t.key&&this.segmentKey(t.key,!0),i.isFmp4=t.isFmp4,
vendor: 63,666 bytes, lines 3812-3814
3812i.timingInfo=i.timingInfo||{},i.isFmp4)this.trigger("fmp4"),i.timingInfo.start=i[Hh(e.type)].start;else{t=this.getCurrentMediaInfo_(),t="main"===this.loaderType_&&t&&t.hasVideo;let e;t&&(e=i.videoTimingInfo.start),i.timingInfo.start=this.trueSegmentStart_({currentStart:i.timingInfo.start,playlist:i.playlist,mediaIndex:i.mediaIndex,currentVideoTimestampOffset:this.sourceUpdater_.videoTimestampOffset(),useVideoTimingInfo:t,firstVideoFrameTimeForData:e,videoTimingInfo:i.videoTimingInfo,audioTimingInfo:i.audioTimingInfo})}if(this.updateAppendInitSegmentStatus(i,e.type),this.updateSourceBufferTimestampOffset_(i),i.isSyncRequest){this.updateTimingInfoEnd_(i),this.syncController_.saveSegmentTimingInfo({segmentInfo:i,shouldSaveTimelineMapping:"main"===this.loaderType_});t=this.chooseNextRequest_();if(t.mediaIndex!==i.mediaIndex||t.partIndex!==i.partIndex)return void this.logger_("sync segment was incorrect, not appending");this.logger_("sync segment was correct, appending")}i.hasAppendedData_=!0,this.processMetadataQueue_(),this.appendData_(i,e)}}}updateAppendInitSegmentStatus(e,t){"main"!==this.loaderType_||"number"!=typeof e.timestampOffset||e.changedTimestampOffset||(this.appendInitSegment_={audio:!0,video:!0}),this.playlistOfLastInitSegment_[t]!==e.playlist&&(this.appendInitSegment_[t]=!0)}getInitSegmentAndUpdateState_({type:e,initSegment:t,map:i,playlist:s}){if(i){var r=Dd(i);if(this.activeInitSegmentId_===r)return null;t=this.initSegmentForMap(i,!0).bytes,this.activeInitSegmentId_=r}return t&&this.appendInitSegment_[e]?(this.playlistOfLastInitSegment_[e]=s,this.appendInitSegment_[e]=!1,this.activeInitSegmentId_=null,t):null}handleQuotaExceededError_({segmentInfo:e,type:t,bytes:i},s){var r=this.sourceUpdater_.audioBuffered(),n=this.sourceUpdater_.videoBuffered(),a=(1<r.length&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the audio buffer: "+Yl(r).join(", ")),1<n.length&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the video buffer: "+Yl(n).join(", ")),r.length?r.start(0):0),o=r.length?r.end(r.length-1):0,l=n.length?n.start(0):0,d=n.length?n.end(n.length-1):0;o-a<=1&&d-l<=1?(this.logger_("On QUOTA_EXCEEDED_ERR, single segment too large to append to buffer, triggering an error. "+`Appended byte length: ${i.byteLength}, `+`audio buffer: ${Yl(r).join(", ")}, `+`video buffer: ${Yl(n).join(", ")}, `),this.error({message:"Quota exceeded error with append of a single segment of content",excludeUntil:1/0}),this.trigger("error")):(this.waitingOnRemove_=!0,this.callQueue_.push(this.appendToSourceBuffer_.bind(this,{segmentInfo:e,type:t,bytes:i})),o=this.currentTime_()-1,this.logger_("On QUOTA_EXCEEDED_ERR, removing audio/video from 0 to "+o),this.remove(0,o,()=>{this.logger_("On QUOTA_EXCEEDED_ERR, retrying append in 1s"),this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=window.setTimeout(()=>{this.logger_("On QUOTA_EXCEEDED_ERR, re-processing call queue"),this.quotaExceededErrorRetryTimeout_=null,this.processCallQueue_()},1e3)},!0))}handleAppendError_({segmentInfo:e,type:t,bytes:i},s){s&&(22===s.code?this.handleQuotaExceededError_({segmentInfo:e,type:t,bytes:i}):(this.logger_("Received non QUOTA_EXCEEDED_ERR on append",s),this.error(`${t} append of ${i.length}b failed for segment `+`#${e.mediaIndex} in playlist `+e.playlist.id),this.trigger("appenderror")))}appendToSourceBuffer_({segmentInfo:e,type:t,initSegment:i,data:s,bytes:r}){if(!r){var n=[s];let e=s.byteLength;i&&(n.unshift(i),e+=i.byteLength),r=(e=>{let t=0,i;return e.bytes&&(i=new Uint8Array(e.bytes),e.segments.forEach(e=>{i.set(e,t),t+=e.byteLength})),i})({bytes:e,segments:n})}this.sourceUpdater_.appendBuffer({segmentInfo:e,type:t,bytes:r},this.handleAppendError_.bind(this,{segmentInfo:e,type:t,bytes:r}))}handleSegmentTimingInfo_(e,t,i){this.pendingSegment_&&t===this.pendingSegment_.requestId&&((t=this.pendingSegment_.segment)[e=e+"TimingInfo"]||(t[e]={}),t[e].transmuxerPrependedSeconds=i.prependedContentDuration||0,t[e].transmuxedPresentationStart=i.start.presentation,t[e].transmuxedDecodeStart=i.start.decode,t[e].transmuxedPresentationEnd=i.end.presentation,t[e].transmuxedDecodeEnd=i.end.decode,t[e].baseMediaDecodeTime=i.baseMediaDecodeTime)}appendData_(e,t){var{type:i,data:s}=t;s&&s.byteLength&&("audio"===i&&this.audioDisabled_||(t=this.getInitSegmentAndUpdateState_({type:i,initSegment:t.initSegment,playlist:e.playlist,map:e.isFmp4?e.segment.map:null}),this.appendToSourceBuffer_({segmentInfo:e,type:i,initSegment:t,data:s})))}loadSegment_(t){this.state="WAITING",this.pendingSegment_=t,this.trimBackBuffer_(t),"number"==typeof t.timestampOffset&&this.transmuxer_&&this.transmuxer_.postMessage({action:"clearAllMp4Captions"}),this.hasEnoughInfoToLoad_()?this.updateTransmuxerAndRequestSegment_(t):this.loadQueue_.push(()=>{var e=fi({},t,{forceTimestampOffset:!0});fi(t,this.generateSegmentInfo_(e)),this.isPendingTimestampOffset_=!1,this.updateTransmuxerAndRequestSegment_(t)})}updateTransmuxerAndRequestSegment_(s){this.shouldUpdateTransmuxerTimestampOffset_(s.timestampOffset)&&(this.gopBuffer_.length=0,s.gopsToAlignWith=[],this.timeMapping_=0,this.transmuxer_.postMessage({action:"reset"}),this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:s.timestampOffset}));var e=this.createSimplifiedSegmentObj_(s),t=this.isEndOfStream_(s.mediaIndex,s.playlist,s.partIndex),i=null!==this.mediaIndex,r=s.timeline!==this.currentTimeline_&&0<s.timeline,t=t||i&&r;this.logger_("Requesting "+jh(s)),e.map&&!e.map.bytes&&(this.logger_("going to request init segment."),this.appendInitSegment_={video:!0,audio:!0}),s.abortRequests=xh({xhr:this.vhs_.xhr,xhrOptions:this.xhrOptions_,decryptionWorker:this.decrypter_,segment:e,abortFn:this.handleAbort_.bind(this,s),progressFn:this.handleProgress_.bind(this),trackInfoFn:this.handleTrackInfo_.bind(this),timingInfoFn:this.handleTimingInfo_.bind(this),videoSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"video",s.requestId),audioSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"audio",s.requestId),captionsFn:this.handleCaptions_.bind(this),isEndOfTimeline:t,endedTimelineFn:()=>{this.logger_("received endedtimeline callback")},id3Fn:this.handleId3_.bind(this),dataFn:this.handleData_.bind(this),doneFn:this.segmentRequestFinished_.bind(this),onTransmuxerLog:({message:e,level:t,stream:i})=>{this.logger_(jh(s)+` logged from transmuxer stream ${i} as a ${t}: `+e)}})}trimBackBuffer_(e){var t=((e,t,i)=>{let s=t-D.BACK_BUFFER_LENGTH;return e.length&&(s=Math.max(s,e.start(0))),Math.min(t-i,s)})(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10);0<t&&this.remove(0,t)}createSimplifiedSegmentObj_(e){var t=e.segment,i=e.part,i={resolvedUri:(i||t).resolvedUri,byterange:(i||t).byterange,requestId:e.requestId,transmuxer:e.transmuxer,audioAppendStart:e.audioAppendStart,gopsToAlignWith:e.gopsToAlignWith,part:e.part},s=e.playlist.segments[e.mediaIndex-1];return s&&s.timeline===t.timeline&&(s.videoTimingInfo?i.baseStartTime=s.videoTimingInfo.transmuxedDecodeEnd:s.audioTimingInfo&&(i.baseStartTime=s.audioTimingInfo.transmuxedDecodeEnd)),t.key&&(s=t.key.iv||new Uint32Array([0,0,0,e.mediaIndex+e.playlist.mediaSequence]),i.key=this.segmentKey(t.key),i.key.iv=s),t.map&&(i.map=this.initSegmentForMap(t.map)),i}saveTransferStats_(e){this.mediaRequests+=1,e&&(this.mediaBytesTransferred+=e.bytesReceived,this.mediaTransferDuration+=e.roundTripTime)}saveBandwidthRelatedStats_(e,t){this.pendingSegment_.byteLength=t.bytesReceived,e<1/60?this.logger_("Ignoring segment's bandwidth because its duration of "+e+" is less than the min to record "+1/60):(this.bandwidth=t.bandwidth,this.roundTrip=t.roundTripTime)}handleTimeout_(){this.mediaRequestsTimedout+=1,this.bandwidth=1,this.roundTrip=NaN,this.trigger("bandwidthupdate"),this.trigger("timeout")}segmentRequestFinished_(e,t,i){if(this.callQueue_.length)this.callQueue_.push(this.segmentRequestFinished_.bind(this,e,t,i));else if(this.saveTransferStats_(t.stats),this.pendingSegment_&&t.requestId===this.pendingSegment_.requestId){if(e)return this.pendingSegment_=null,this.state="READY",e.code===yh.ABORTED?void 0:(this.pause(),e.code===yh.TIMEOUT?void this.handleTimeout_():(this.mediaRequestsErrored+=1,this.error(e),void this.trigger("error")));e=this.pendingSegment_;this.saveBandwidthRelatedStats_(e.duration,t.stats),e.endOfAllRequests=t.endOfAllRequests,i.gopInfo&&(this.gopBuffer_=((e,t,i)=>{if(!t.length)return e;if(i)return t.slice();var s=t[0].pts;let r=0;for(r;r<e.length&&!(e[r].pts>=s);r++);return e.slice(0,r).concat(t)})(this.gopBuffer_,i.gopInfo,this.safeAppend_)),this.state="APPENDING",this.trigger("appending"),this.waitForAppendsToComplete_(e)}}setTimeMapping_(e){e=this.syncController_.mappingForTimeline(e);null!==e&&(this.timeMapping_=e)}updateMediaSecondsLoaded_(e){"number"==typeof e.start&&"number"==typeof e.end?this.mediaSecondsLoaded+=e.end-e.start:this.mediaSecondsLoaded+=e.duration}shouldUpdateTransmuxerTimestampOffset_(e){return null!==e&&("main"===this.loaderType_&&e!==this.sourceUpdater_.videoTimestampOffset()||!this.audioDisabled_&&e!==this.sourceUpdater_.audioTimestampOffset())}trueSegmentStart_({currentStart:e,playlist:t,mediaIndex:i,firstVideoFrameTimeForData:s,currentVideoTimestampOffset:r,useVideoTimingInfo:n,videoTimingInfo:a,audioTimingInfo:o}){return"undefined"!=typeof e?e:n?(e=t.segments[i-1],0!==i&&e&&"undefined"!=typeof e.start&&e.end===s+r?a.start:s):o.start}waitForAppendsToComplete_(e){var t,i,s=this.getCurrentMediaInfo_(e);s?({hasAudio:s,hasVideo:i,isMuxed:t}=s,i="main"===this.loaderType_&&i,s=!this.audioDisabled_&&s&&!t,e.waitingOnAppends=0,e.hasAppendedData_?(i&&e.waitingOnAppends++,s&&e.waitingOnAppends++,i&&this.sourceUpdater_.videoQueueCallback(this.checkAppendsDone_.bind(this,e)),s&&this.sourceUpdater_.audioQueueCallback(this.checkAppendsDone_.bind(this,e))):(e.timingInfo||"number"!=typeof e.timestampOffset||(this.isPendingTimestampOffset_=!0),e.timingInfo={start:0},e.waitingOnAppends++,this.isPendingTimestampOffset_||(this.updateSourceBufferTimestampOffset_(e),this.processMetadataQueue_()),this.checkAppendsDone_(e))):(this.error({message:"No starting media returned, likely due to an unsupported media format.",playlistExclusionDuration:1/0}),this.trigger("error"))}checkAppendsDone_(e){this.checkForAbort_(e.requestId)||(e.waitingOnAppends--,0===e.waitingOnAppends&&this.handleAppendsDone_())}checkForIllegalMediaSwitch(e){i=this.loaderType_,t=this.getCurrentMediaInfo_(),e=e;var t,i="main"===i&&t&&e?e.hasAudio||e.hasVideo?t.hasVideo&&!e.hasVideo?"Only audio found in segment when we expected video. We can't switch to audio only from a stream that had video. To get rid of this message, please add codec information to the manifest.":!t.hasVideo&&e.hasVideo?"Video found in segment when we expected only audio. We can't switch to a stream with video from an audio only stream. To get rid of this message, please add codec information to the manifest.":null:"Neither audio nor video found in segment.":null;return!!i&&(this.error({message:i,playlistExclusionDuration:1/0}),this.trigger("error"),!0)}updateSourceBufferTimestampOffset_(t){if(null!==t.timestampOffset&&"number"==typeof t.timingInfo.start&&!t.changedTimestampOffset&&"main"===this.loaderType_){let e=!1;t.timestampOffset-=this.getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:t.segment.videoTimingInfo,audioTimingInfo:t.segment.audioTimingInfo,timingInfo:t.timingInfo}),t.changedTimestampOffset=!0,t.timestampOffset!==this.sourceUpdater_.videoTimestampOffset()&&(this.sourceUpdater_.videoTimestampOffset(t.timestampOffset),e=!0),t.timestampOffset!==this.sourceUpdater_.audioTimestampOffset()&&(this.sourceUpdater_.audioTimestampOffset(t.timestampOffset),e=!0),e&&this.trigger("timestampoffset")}}getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e,audioTimingInfo:t,timingInfo:i}){return this.useDtsForTimestampOffset_?e&&"number"==typeof e.transmuxedDecodeStart?e.transmuxedDecodeStart:t&&"number"==typeof t.transmuxedDecodeStart?t.transmuxedDecodeStart:i.start:i.start}updateTimingInfoEnd_(e){e.timingInfo=e.timingInfo||{};var t=this.getMediaInfo_(),t="main"===this.loaderType_&&t&&t.hasVideo&&e.videoTimingInfo?e.videoTimingInfo:e.audioTimingInfo;t&&(e.timingInfo.end="number"==typeof t.end?t.end:t.start+e.duration)}handleAppendsDone_(){var e,t,i;this.pendingSegment_&&this.trigger("appendsdone"),this.pendingSegment_?(e=this.pendingSegment_,this.updateTimingInfoEnd_(e),this.shouldSaveSegmentTimingInfo_&&this.syncController_.saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:"main"===this.loaderType_}),(t=$h(e,this.sourceType_))&&("warn"===t.severity?T.log.warn(t.message):this.logger_(t.message)),this.recordThroughput_(e),this.pendingSegment_=null,this.state="READY",e.isSyncRequest&&(this.trigger("syncinfoupdate"),!e.hasAppendedData_)?this.logger_("Throwing away un-appended sync request "+jh(e)):(this.logger_("Appended "+jh(e)),this.addSegmentMetadataCue_(e),this.fetchAtBuffer_=!0,this.currentTimeline_!==e.timeline&&(this.timelineChangeController_.lastTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline}),"main"!==this.loaderType_||this.audioDisabled_||this.timelineChangeController_.lastTimelineChange({type:"audio",from:this.currentTimeline_,to:e.timeline})),this.currentTimeline_=e.timeline,this.trigger("syncinfoupdate"),t=e.segment,i=e.part,t=t.end&&this.currentTime_()-t.end>3*e.playlist.targetDuration,i=i&&i.end&&this.currentTime_()-i.end>3*e.playlist.partTargetDuration,t||i?(this.logger_(`bad ${t?"segment":"part"} `+jh(e)),this.resetEverything()):(null!==this.mediaIndex&&this.trigger("bandwidthupdate"),this.trigger("progress"),this.mediaIndex=e.mediaIndex,this.partIndex=e.partIndex,this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex)&&this.endOfStream(),this.trigger("appended"),e.hasAppendedData_&&this.mediaAppends++,this.paused()||this.monitorBuffer_()))):(this.state="READY",this.paused()||this.monitorBuffer_())}recordThroughput_(e){var t,i;e.duration<1/60?this.logger_("Ignoring segment's throughput because its duration of "+e.duration+" is less than the min to record "+1/60):(t=this.throughput.rate,i=Date.now()-e.endOfAllRequests+1,e=Math.floor(e.byteLength/i*8*1e3),this.throughput.rate+=(e-t)/++this.throughput.count)}addSegmentMetadataCue_(e){var t,i,s,r;this.segmentMetadataTrack_&&(t=(r=e.segment).start,i=r.end,Fh(t))&&Fh(i)&&(Uh(t,i,this.segmentMetadataTrack_),s=window.WebKitDataCue||window.VTTCue,r={custom:r.custom,dateTimeObject:r.dateTimeObject,dateTimeString:r.dateTimeString,bandwidth:e.playlist.attributes.BANDWIDTH,resolution:e.playlist.attributes.RESOLUTION,codecs:e.playlist.attributes.CODECS,byteLength:e.byteLength,uri:e.uri,timeline:e.timeline,playlist:e.playlist.id,start:t,end:i},(e=new s(t,i,JSON.stringify(r))).value=r,this.segmentMetadataTrack_.addCue(e))}}function Gh(){}function zh(e){return"string"!=typeof e?e:e.replace(/./,e=>e.toUpperCase())}const Xh=["video","audio"],Kh=(e,t)=>{var i=t[e+"Buffer"];return i&&i.updating||t.queuePending[e]},Yh=(i,s)=>{if(0!==s.queue.length){let e=0,t=s.queue[e];if("mediaSource"===t.type)s.updating()||"closed"===s.mediaSource.readyState||(s.queue.shift(),t.action(s),t.doneFn&&t.doneFn(),Yh("audio",s),Yh("video",s));else if("mediaSource"!==i&&s.ready()&&"closed"!==s.mediaSource.readyState&&!Kh(i,s)){if(t.type!==i){if(null===(e=((t,i)=>{for(let e=0;e<i.length;e++){var s=i[e];if("mediaSource"===s.type)return null;if(s.type===t)return e}return null})(i,s.queue)))return;t=s.queue[e]}s.queue.splice(e,1),(s.queuePending[i]=t).action(i,s),t.doneFn||(s.queuePending[i]=null,Yh(i,s))}}},Qh=(e,t)=>{var i=t[e+"Buffer"],s=zh(e);i&&(i.removeEventListener("updateend",t[`on${s}UpdateEnd_`]),i.removeEventListener("error",t[`on${s}Error_`]),t.codecs[e]=null,t[e+"Buffer"]=null)},Jh=(e,t)=>e&&t&&-1!==Array.prototype.indexOf.call(e.sourceBuffers,t),Zh={appendBuffer:(s,r,n)=>(t,i)=>{var e=i[t+"Buffer"];if(Jh(i.mediaSource,e)){i.logger_(`Appending segment ${r.mediaIndex}'s ${s.length} bytes to ${t}Buffer`);try{e.appendBuffer(s)}catch(e){i.logger_(`Error with code ${e.code} `+(22===e.code?"(QUOTA_EXCEEDED_ERR) ":"")+`when appending segment ${r.mediaIndex} to ${t}Buffer`),i.queuePending[t]=null,n(e)}}},remove:(s,r)=>(t,i)=>{var e=i[t+"Buffer"];if(Jh(i.mediaSource,e)){i.logger_(`Removing ${s} to ${r} from ${t}Buffer`);try{e.remove(s,r)}catch(e){i.logger_(`Remove ${s} to ${r} from ${t}Buffer failed`)}}},timestampOffset:s=>(e,t)=>{var i=t[e+"Buffer"];Jh(t.mediaSource,i)&&(t.logger_(`Setting ${e}timestampOffset to `+s),i.timestampOffset=s)},callback:i=>(e,t)=>{i()},endOfStream:t=>e=>{if("open"===e.mediaSource.readyState){e.logger_(`Calling mediaSource endOfStream(${t||""})`);try{e.mediaSource.endOfStream(t)}catch(e){T.log.warn("Failed to call media source endOfStream",e)}}},duration:t=>e=>{e.logger_("Setting mediaSource duration to "+t);try{e.mediaSource.duration=t}catch(e){T.log.warn("Failed to set media source duration",e)}},abort:()=>(t,e)=>{if("open"===e.mediaSource.readyState){var i=e[t+"Buffer"];if(Jh(e.mediaSource,i)){e.logger_(`calling abort on ${t}Buffer`);try{i.abort()}catch(e){T.log.warn(`Failed to abort on ${t}Buffer`,e)}}}},addSourceBuffer:(s,r)=>e=>{var t=zh(s),i=Bn(r),i=(e.logger_(`Adding ${s}Buffer with codec ${r} to mediaSource`),e.mediaSource.addSourceBuffer(i));i.addEventListener("updateend",e[`on${t}UpdateEnd_`]),i.addEventListener("error",e[`on${t}Error_`]),e.codecs[s]=r,e[s+"Buffer"]=i},removeSourceBuffer:i=>e=>{var t=e[i+"Buffer"];if(Qh(i,e),Jh(e.mediaSource,t)){e.logger_(`Removing ${i}Buffer with codec ${e.codecs[i]} from mediaSource`);try{e.mediaSource.removeSourceBuffer(t)}catch(e){T.log.warn(`Failed to removeSourceBuffer ${i}Buffer`,e)}}},changeType:r=>(e,t)=>{var i=t[e+"Buffer"],s=Bn(r);Jh(t.mediaSource,i)&&t.codecs[e]!==r&&(t.logger_(`changing ${e}Buffer codec from ${t.codecs[e]} to `+r),i.changeType(s),t.codecs[e]=r)}},eu=({type:e,sourceUpdater:t,action:i,doneFn:s,name:r})=>{t.queue.push({type:e,action:i,doneFn:s,name:r}),Yh(e,t)},tu=(i,s)=>e=>{var t;s.queuePending[i]&&(t=s.queuePending[i].doneFn,s.queuePending[i]=null,t)&&t(s[i+"Error_"]),Yh(i,s)};class iu extends T.EventTarget{constructor(e){super(),this.mediaSource=e,this.sourceopenListener_=()=>Yh("mediaSource",this),this.mediaSource.addEventListener("sourceopen",this.sourceopenListener_),this.logger_=Bl("SourceUpdater"),this.audioTimestampOffset_=0,this.videoTimestampOffset_=0,this.queue=[],this.queuePending={audio:null,video:null},this.delayedAudioAppendQueue_=[],this.videoAppendQueued_=!1,this.codecs={},this.onVideoUpdateEnd_=tu("video",this),this.onAudioUpdateEnd_=tu("audio",this),this.onVideoError_=e=>{this.videoError_=e},this.onAudioError_=e=>{this.audioError_=e},this.createdSourceBuffers_=!1,this.initializedEme_=!1,this.triggeredReady_=!1}initializedEme(){this.initializedEme_=!0,this.triggerReady()}hasCreatedSourceBuffers(){return this.createdSourceBuffers_}hasInitializedAnyEme(){return this.initializedEme_}ready(){return this.hasCreatedSourceBuffers()&&this.hasInitializedAnyEme()}createSourceBuffers(e){this.hasCreatedSourceBuffers()||(this.addOrChangeSourceBuffers(e),this.createdSourceBuffers_=!0,this.trigger("createdsourcebuffers"),this.triggerReady())}triggerReady(){this.ready()&&!this.triggeredReady_&&(this.triggeredReady_=!0,this.trigger("ready"))}addSourceBuffer(e,t){eu({type:"mediaSource",sourceUpdater:this,action:Zh.addSourceBuffer(e,t),name:"addSourceBuffer"})}abort(e){eu({type:e,sourceUpdater:this,action:Zh.abort(e),name:"abort"})}removeSourceBuffer(e){this.canRemoveSourceBuffer()?eu({type:"mediaSource",sourceUpdater:this,action:Zh.removeSourceBuffer(e),name:"removeSourceBuffer"}):T.log.error("removeSourceBuffer is not supported!")}canRemoveSourceBuffer(){return!T.browser.IE_VERSION&&!T.browser.IS_FIREFOX&&window.MediaSource&&window.MediaSource.prototype&&"function"==typeof window.MediaSource.prototype.removeSourceBuffer}static canChangeType(){return window.SourceBuffer&&window.SourceBuffer.prototype&&"function"==typeof window.SourceBuffer.prototype.changeType}canChangeType(){return this.constructor.canChangeType()}changeType(e,t){this.canChangeType()?eu({type:e,sourceUpdater:this,action:Zh.changeType(t),name:"changeType"}):T.log.error("changeType is not supported!")}addOrChangeSourceBuffers(i){if(!i||"object"!=typeof i||0===Object.keys(i).length)throw new Error("Cannot addOrChangeSourceBuffers to undefined codecs");Object.keys(i).forEach(e=>{var t=i[e];if(!this.hasCreatedSourceBuffers())return this.addSourceBuffer(e,t);this.canChangeType()&&this.changeType(e,t)})}appendBuffer(e,t){var{segmentInfo:i,type:s,bytes:r}=e;this.processedAppend_=!0,"audio"===s&&this.videoBuffer&&!this.videoAppendQueued_?(this.delayedAudioAppendQueue_.push([e,t]),this.logger_(`delayed audio append of ${r.length} until video append`)):(e=t,eu({type:s,sourceUpdater:this,action:Zh.appendBuffer(r,i||{mediaIndex:-1},e),doneFn:t,name:"appendBuffer"}),"video"===s&&(this.videoAppendQueued_=!0,this.delayedAudioAppendQueue_.length)&&(r=this.delayedAudioAppendQueue_.slice(),this.logger_(`queuing delayed audio ${r.length} appendBuffers`),this.delayedAudioAppendQueue_.length=0,r.forEach(e=>{this.appendBuffer.apply(this,e)})))}audioBuffered(){return Jh(this.mediaSource,this.audioBuffer)&&this.audioBuffer.buffered||Fl()}videoBuffered(){return Jh(this.mediaSource,this.videoBuffer)&&this.videoBuffer.buffered||Fl()}buffered(){var e=Jh(this.mediaSource,this.videoBuffer)?this.videoBuffer:null,t=Jh(this.mediaSource,this.audioBuffer)?this.audioBuffer:null;if(t&&!e)return this.audioBuffered();if(e&&!t)return this.videoBuffered();{var r=this.audioBuffered();var n=this.videoBuffered();let e=null,t=null,i=0;var a=[],o=[];if(!(r&&r.length&&n&&n.length))return Fl();let s=r.length;for(;s--;)a.push({time:r.start(s),type:"start"}),a.push({time:r.end(s),type:"end"});for(s=n.length;s--;)a.push({time:n.start(s),type:"start"}),a.push({time:n.end(s),type:"end"});for(a.sort(function(e,t){return e.time-t.time}),s=0;s<a.length;s++)"start"===a[s].type?2===++i&&(e=a[s].time):"end"===a[s].type&&1===--i&&(t=a[s].time),null!==e&&null!==t&&(o.push([e,t]),e=null,t=null);return Fl(o);return}}setDuration(e,t=Gh){eu({type:"mediaSource",sourceUpdater:this,action:Zh.duration(e),name:"duration",doneFn:t})}endOfStream(e=null,t=Gh){"string"!=typeof e&&(e=void 0),eu({type:"mediaSource",sourceUpdater:this,action:Zh.endOfStream(e),name:"endOfStream",doneFn:t})}removeAudio(e,t,i=Gh){this.audioBuffered().length&&0!==this.audioBuffered().end(0)?eu({type:"audio",sourceUpdater:this,action:Zh.remove(e,t),doneFn:i,name:"remove"}):i()}removeVideo(e,t,i=Gh){this.videoBuffered().length&&0!==this.videoBuffered().end(0)?eu({type:"video",sourceUpdater:this,action:Zh.remove(e,t),doneFn:i,name:"remove"}):i()}updating(){return!(!Kh("audio",this)&&!Kh("video",this))}audioTimestampOffset(e){return"undefined"!=typeof e&&this.audioBuffer&&this.audioTimestampOffset_!==e&&(eu({type:"audio",sourceUpdater:this,action:Zh.timestampOffset(e),name:"timestampOffset"}),this.audioTimestampOffset_=e),this.audioTimestampOffset_}videoTimestampOffset(e){return"undefined"!=typeof e&&this.videoBuffer&&this.videoTimestampOffset!==e&&(eu({type:"video",sourceUpdater:this,action:Zh.timestampOffset(e),name:"timestampOffset"}),this.videoTimestampOffset_=e),this.videoTimestampOffset_}audioQueueCallback(e){this.audioBuffer&&eu({type:"audio",sourceUpdater:this,action:Zh.callback(e),name:"callback"})}videoQueueCallback(e){this.videoBuffer&&eu({type:"video",sourceUpdater:this,action:Zh.callback(e),name:"callback"})}dispose(){this.trigger("dispose"),Xh.forEach(e=>{this.abort(e),this.canRemoveSourceBuffer()?this.removeSourceBuffer(e):this[e+"QueueCallback"](()=>Qh(e,this))}),this.videoAppendQueued_=!1,this.delayedAudioAppendQueue_.length=0,this.sourceopenListener_&&this.mediaSource.removeEventListener("sourceopen",this.sourceopenListener_),this.off()}}const su=e=>decodeURIComponent(escape(String.fromCharCode.apply(null,e))),ru=new Uint8Array("\n\n".split("").map(e=>e.charCodeAt(0)));class nu extends Error{constructor(){super("Trying to parse received VTT cues, but there is no WebVTT. Make sure vtt.js is loaded.")}}class au extends Wh{constructor(e,t={}){super(e,t),this.mediaSource_=null,this.subtitlesTrack_=null,this.loaderType_="subtitle",this.featuresNativeTextTracks_=e.featuresNativeTextTracks,this.loadVttJs=e.loadVttJs,this.shouldSaveSegmentTimingInfo_=!1}createTransmuxer_(){return null}buffered_(){var e;return this.subtitlesTrack_&&this.subtitlesTrack_.cues&&this.subtitlesTrack_.cues.length?Fl([[(e=this.subtitlesTrack_.cues)[0].startTime,e[e.length-1].startTime]]):Fl()}initSegmentForMap(e,t=!1){if(!e)return null;var i=Dd(e);let s=this.initSegments_[i];return t&&!s&&e.bytes&&(t=ru.byteLength+e.bytes.byteLength,(t=new Uint8Array(t)).set(e.bytes),t.set(ru,e.bytes.byteLength),this.initSegments_[i]=s={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:t}),s||e}couldBeginLoading_(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()}init_(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}track(e){return"undefined"!=typeof e&&(this.subtitlesTrack_=e,"INIT"===this.state&&this.couldBeginLoading_())&&this.init_(),this.subtitlesTrack_}remove(e,t){Uh(e,t,this.subtitlesTrack_)}fillBuffer_(){var e=this.chooseNextRequest_();e&&(null===this.syncController_.timestampOffsetForTimeline(e.timeline)?(this.syncController_.one("timestampoffset",()=>{this.state="READY",this.paused()||this.monitorBuffer_()}),this.state="WAITING_ON_TIMELINE"):this.loadSegment_(e))}timestampOffsetForSegment_(){return null}chooseNextRequest_(){return this.skipEmptySegments_(super.chooseNextRequest_())}skipEmptySegments_(e){for(;e&&e.segment.empty;){if(e.mediaIndex+1>=e.playlist.segments.length){e=null;break}e=this.generateSegmentInfo_({playlist:e.playlist,mediaIndex:e.mediaIndex+1,startOfSegment:e.startOfSegment+e.duration,isSyncRequest:e.isSyncRequest})}return e}stopForError(e){this.error(e),this.state="READY",this.pause(),this.trigger("error")}segmentRequestFinished_(e,t,i){if(this.subtitlesTrack_)if(this.saveTransferStats_(t.stats),this.pendingSegment_)if(e)e.code===yh.TIMEOUT&&this.handleTimeout_(),e.code===yh.ABORTED?this.mediaRequestsAborted+=1:this.mediaRequestsErrored+=1,this.stopForError(e);else{var s=this.pendingSegment_,r=(this.saveBandwidthRelatedStats_(s.duration,t.stats),t.key&&this.segmentKey(t.key,!0),this.state="APPENDING",this.trigger("appending"),s.segment);if(r.map&&(r.map.bytes=t.map.bytes),s.bytes=t.bytes,"function"!=typeof window.WebVTT&&"function"==typeof this.loadVttJs)this.state="WAITING_ON_VTTJS",this.loadVttJs().then(()=>this.segmentRequestFinished_(e,t,i),()=>this.stopForError({message:"Error loading vtt.js"}));else{r.requested=!0;try{this.parseVTTCues_(s)}catch(e){return void this.stopForError({message:e.message})}if(this.updateTimeMapping_(s,this.syncController_.timelines[s.timeline],this.playlist_),s.cues.length?s.timingInfo={start:s.cues[0].startTime,end:s.cues[s.cues.length-1].endTime}:s.timingInfo={start:s.startOfSegment,end:s.startOfSegment+s.duration},s.isSyncRequest)this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";else{s.byteLength=s.bytes.byteLength,this.mediaSecondsLoaded+=r.duration,s.cues.forEach(e=>{this.subtitlesTrack_.addCue(this.featuresNativeTextTracks_?new window.VTTCue(e.startTime,e.endTime,e.text):e)});var n=this.subtitlesTrack_,a=n.cues;if(a)for(let i=0;i<a.length;i++){var o=[];let t=0;for(let e=0;e<a.length;e++)a[i].startTime===a[e].startTime&&a[i].endTime===a[e].endTime&&a[i].text===a[e].text&&1<++t&&o.push(a[e]);o.length&&o.forEach(e=>n.removeCue(e))}this.handleAppendsDone_()}}}else this.state="READY",this.mediaRequestsAborted+=1;else this.state="READY"}handleData_(){}updateTimingInfoEnd_(){}parseVTTCues_(t){let e,i=!1;if("function"!=typeof window.WebVTT)throw new nu;"function"==typeof window.TextDecoder?e=new window.TextDecoder("utf8"):(e=window.WebVTT.StringDecoder(),i=!0);var s=new window.WebVTT.Parser(window,window.vttjs,e);if(t.cues=[],t.timestampmap={MPEGTS:0,LOCAL:0},s.oncue=t.cues.push.bind(t.cues),s.ontimestampmap=e=>{t.timestampmap=e},s.onparsingerror=e=>{T.log.warn("Error encountered when parsing cues: "+e.message)},t.segment.map){let e=t.segment.map.bytes;i&&(e=su(e)),s.parse(e)}let r=t.bytes;i&&(r=su(r)),s.parse(r),s.flush()}updateTimeMapping_(e,t,i){var s=e.segment;if(t)if(e.cues.length){var r=e.timestampmap;const n=r.MPEGTS/Ml-r.LOCAL+t.mapping;e.cues.forEach(e=>{e.startTime+=n,e.endTime+=n}),i.syncInfo||(r=e.cues[0].startTime,t=e.cues[e.cues.length-1].startTime,i.syncInfo={mediaSequence:i.mediaSequence+e.mediaIndex,time:Math.min(r,t-s.duration)})}else s.empty=!0}}const ou=[{name:"VOD",run:(e,t,i,s,r)=>{return i!==1/0?{time:0,segmentIndex:0,partIndex:null}:null}},{name:"ProgramDateTime",run:(t,i,e,s,r)=>{if(!Object.keys(t.timelineToDatetimeMappings).length)return null;let n=null,a=null;var o=Jl(i);r=r||0;for(let e=0;e<o.length;e++){var l=o[i.endList||0===r?e:o.length-(e+1)],d=l.segment,h=t.timelineToDatetimeMappings[d.timeline];if(h&&d.dateTimeObject){let t=d.dateTimeObject.getTime()/1e3+h;if(d.parts&&"number"==typeof l.partIndex)for(let e=0;e<l.partIndex;e++)t+=d.parts[e].duration;h=Math.abs(r-t);if(null!==a&&(0===h||a<h))break;a=h,n={time:t,segmentIndex:l.segmentIndex,partIndex:l.partIndex}}}return n}},{name:"Segment",run:(e,t,i,s,r)=>{let n=null,a=null;r=r||0;var o=Jl(t);for(let e=0;e<o.length;e++){var l=o[t.endList||0===r?e:o.length-(e+1)],d=l.segment,h=l.part&&l.part.start||d&&d.start;if(d.timeline===s&&"undefined"!=typeof h){d=Math.abs(r-h);if(null!==a&&a<d)break;(!n||null===a||a>=d)&&(a=d,n={time:h,segmentIndex:l.segmentIndex,partIndex:l.partIndex})}}return n}},{name:"Discontinuity",run:(i,s,e,t,r)=>{let n=null;if(r=r||0,s.discontinuityStarts&&s.discontinuityStarts.length){let t=null;for(let e=0;e<s.discontinuityStarts.length;e++){var a=s.discontinuityStarts[e],o=s.discontinuitySequence+e+1,o=i.discontinuities[o];if(o){var l=Math.abs(r-o.time);if(null!==t&&t<l)break;(!n||null===t||t>=l)&&(t=l,n={time:o.time,segmentIndex:a,partIndex:null})}}}return n}},{name:"Playlist",run:(e,t,i,s,r)=>{return t.syncInfo?{time:t.syncInfo.time,segmentIndex:t.syncInfo.mediaSequence-t.mediaSequence,partIndex:null}:null}}];class lu extends T.EventTarget{constructor(e=0){super(),this.timelines=[],this.discontinuities=[],this.timelineToDatetimeMappings={},this.logger_=Bl("SyncController")}getSyncPoint(e,t,i,s){e=this.runStrategies_(e,t,i,s);return e.length?this.selectSyncPoint_(e,{key:"time",value:s}):null}getExpiredTime(e,t){return e&&e.segments&&(t=this.runStrategies_(e,t,e.discontinuitySequence,0)).length?(0<(t=this.selectSyncPoint_(t,{key:"segmentIndex",value:0})).segmentIndex&&(t.time*=-1),Math.abs(t.time+$l({defaultDuration:e.targetDuration,durationList:e.segments,startIndex:t.segmentIndex,endIndex:0}))):null}runStrategies_(t,i,s,r){var n=[];for(let e=0;e<ou.length;e++){var a=ou[e],o=a.run(this,t,i,s,r);o&&(o.strategy=a.name,n.push({strategy:a.name,syncPoint:o}))}return n}selectSyncPoint_(t,i){let s=t[0].syncPoint,r=Math.abs(t[0].syncPoint[i.key]-i.value),n=t[0].strategy;for(let e=1;e<t.length;e++){var a=Math.abs(t[e].syncPoint[i.key]-i.value);a<r&&(r=a,s=t[e].syncPoint,n=t[e].strategy)}return this.logger_(`syncPoint for [${i.key}: ${i.value}] chosen with strategy`+` [${n}]: [time:${s.time},`+" segmentIndex:"+s.segmentIndex+("number"==typeof s.partIndex?",partIndex:"+s.partIndex:"")+"]"),s}saveExpiredSegmentInfo(t,i){var s=i.mediaSequence-t.mediaSequence;if(86400<s)T.log.warn(`Not saving expired segment info. Media sequence gap ${s} is too large.`);else for(let e=s-1;0<=e;e--){var r=t.segments[e];if(r&&"undefined"!=typeof r.start){i.syncInfo={mediaSequence:t.mediaSequence+e,time:r.start},this.logger_(`playlist refresh sync: [time:${i.syncInfo.time},`+` mediaSequence: ${i.syncInfo.mediaSequence}]`),this.trigger("syncinfoupdate");break}}}setDateTimeMappingForStart(e){var t;this.timelineToDatetimeMappings={},e.segments&&e.segments.length&&e.segments[0].dateTimeObject&&(t=(e=e.segments[0]).dateTimeObject.getTime()/1e3,this.timelineToDatetimeMappings[e.timeline]=-t)}saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:t}){var i=this.calculateSegmentTimeMapping_(e,e.timingInfo,t),s=e.segment,i=(i&&(this.saveDiscontinuitySyncInfo_(e),e.playlist.syncInfo||(e.playlist.syncInfo={mediaSequence:e.playlist.mediaSequence+e.mediaIndex,time:s.start})),s.dateTimeObject);s.discontinuity&&t&&i&&(this.timelineToDatetimeMappings[s.timeline]=-i.getTime()/1e3)}timestampOffsetForTimeline(e){return"undefined"==typeof this.timelines[e]?null:this.timelines[e].time}mappingForTimeline(e){return"undefined"==typeof this.timelines[e]?null:this.timelines[e].mapping}calculateSegmentTimeMapping_(e,t,i){var s=e.segment,r=e.part;let n=this.timelines[e.timeline],a,o;if("number"==typeof e.timestampOffset)n={time:e.startOfSegment,mapping:e.startOfSegment-t.start},i&&(this.timelines[e.timeline]=n,this.trigger("timestampoffset"),this.logger_(`time mapping for timeline ${e.timeline}: `+`[time: ${n.time}] [mapping: ${n.mapping}]`)),a=e.startOfSegment;else{if(!n)return!1;a=t.start+n.mapping}return o=t.end+n.mapping,r&&(r.start=a,r.end=o),(!s.start||a<s.start)&&(s.start=a),s.end=o,!0}saveDiscontinuitySyncInfo_(t){var i=t.playlist,s=t.segment;if(s.discontinuity)this.discontinuities[s.timeline]={time:s.start,accuracy:0};else if(i.discontinuityStarts&&i.discontinuityStarts.length)for(let e=0;e<i.discontinuityStarts.length;e++){var r=i.discontinuityStarts[e],n=i.discontinuitySequence+e+1,a=r-t.mediaIndex,o=Math.abs(a);if(!this.discontinuities[n]||this.discontinuities[n].accuracy>o){let e;e=a<0?s.start-$l({defaultDuration:i.targetDuration,durationList:i.segments,startIndex:t.mediaIndex,endIndex:r}):s.end+$l({defaultDuration:i.targetDuration,durationList:i.segments,startIndex:t.mediaIndex+1,endIndex:r}),this.discontinuities[n]={time:e,accuracy:o}}}}dispose(){this.trigger("dispose"),this.off()}}class du extends T.EventTarget{constructor(){super(),this.pendingTimelineChanges_={},this.lastTimelineChanges_={}}clearPendingTimelineChange(e){this.pendingTimelineChanges_[e]=null,this.trigger("pendingtimelinechange")}pendingTimelineChange({type:e,from:t,to:i}){return"number"==typeof t&&"number"==typeof i&&(this.pendingTimelineChanges_[e]={type:e,from:t,to:i},this.trigger("pendingtimelinechange")),this.pendingTimelineChanges_[e]}lastTimelineChange({type:e,from:t,to:i}){return"number"==typeof t&&"number"==typeof i&&(this.lastTimelineChanges_[e]={type:e,from:t,to:i},delete this.pendingTimelineChanges_[e],this.trigger("timelinechange")),this.lastTimelineChanges_[e]}dispose(){this.trigger("dispose"),this.pendingTimelineChanges_={},this.lastTimelineChanges_={},this.off()}}var hu=Jd(Zd(eh(function(){var e=function(){function e(){this.listeners={}}var t=e.prototype;return t.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},t.off=function(e,t){return!!this.listeners[e]&&(t=this.listeners[e].indexOf(t),this.listeners[e]=this.listeners[e].slice(0),this.listeners[e].splice(t,1),-1<t)},t.trigger=function(e){var t=this.listeners[e];if(t)if(2===arguments.length)for(var i=t.length,s=0;s<i;++s)t[s].call(this,arguments[1]);else for(var r=Array.prototype.slice.call(arguments,1),n=t.length,a=0;a<n;++a)t[a].apply(this,r)},t.dispose=function(){this.listeners={}},t.pipe=function(t){this.on("data",function(e){t.push(e)})},e}(); 3813/*! @name pkcs7 @version 1.0.4 @license Apache-2.0 */let h=null;class g{constructor(e){h=h||function(){var e=[[[],[],[],[],[]],[[],[],[],[],[]]],t=e[0],i=e[1],s=t[4],r=i[4];let n,a,o;var l,d,h,u,c=[],p=[];let m,g;for(n=0;n<256;n++)p[(c[n]=n<<1^283*(n>>7))^n]=n;for(a=o=0;!s[a];a^=l||1,o=p[o]||1)for(u=(u=o^o<<1^o<<2^o<<3^o<<4)>>8^255&u^99,h=c[d=c[l=c[r[s[a]=u]=a]]],g=16843009*h^65537*d^257*l^16843008*a,m=257*c[u]^16843008*u,n=0;n<4;n++)t[n][a]=m=m<<24^m>>>8,i[n][u]=g=g<<24^g>>>8;for(n=0;n<5;n++)t[n]=t[n].slice(0),i[n]=i[n].slice(0);return e}(),this._tables=[[h[0][0].slice(),h[0][1].slice(),h[0][2].slice(),h[0][3].slice(),h[0][4].slice()],[h[1][0].slice(),h[1][1].slice(),h[1][2].slice(),h[1][3].slice(),h[1][4].slice()]];let t,i,s;var r=this._tables[0][4],n=this._tables[1],a=e.length;let o=1;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size");var l=e.slice(0),d=[];for(this._key=[l,d],t=a;t<4*a+28;t++)s=l[t-1],(t%a==0||8===a&&t%a==4)&&(s=r[s>>>24]<<24^r[s>>16&255]<<16^r[s>>8&255]<<8^r[255&s],t%a==0)&&(s=s<<8^s>>>24^o<<24,o=o<<1^283*(o>>7)),l[t]=l[t-a]^s;for(i=0;t;i++,t--)s=l[3&i?t:t-4],t<=4||i<4?d[i]=s:d[i]=n[0][r[s>>>24]]^n[1][r[s>>16&255]]^n[2][r[s>>8&255]]^n[3][r[255&s]]}decrypt(e,t,i,s,r,n){var a,o,l=this._key[1];let d=e^l[0],h=s^l[1],u=i^l[2],c=t^l[3],p;var m=l.length/4-2;let g,f=4;var e=this._tables[1],y=e[0],_=e[1],v=e[2],b=e[3],T=e[4];for(g=0;g<m;g++)p=y[d>>>24]^_[h>>16&255]^v[u>>8&255]^b[255&c]^l[f],a=y[h>>>24]^_[u>>16&255]^v[c>>8&255]^b[255&d]^l[f+1],o=y[u>>>24]^_[c>>16&255]^v[d>>8&255]^b[255&h]^l[f+2],c=y[c>>>24]^_[d>>16&255]^v[h>>8&255]^b[255&u]^l[f+3],f+=4,d=p,h=a,u=o;for(g=0;g<4;g++)r[(3&-g)+n]=T[d>>>24]<<24^T[h>>16&255]<<16^T[u>>8&255]<<8^T[255&c]^l[f++],p=d,d=h,h=u,u=c,c=p}}class l extends e{constructor(){super(e),this.jobs=[],this.delay=1,this.timeout_=null}processJob_(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null}push(e){this.jobs.push(e),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))}}function f(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}class d{constructor(e,t,i,s){var r=d.STEP,n=new Int32Array(e.buffer);const a=new Uint8Array(e.byteLength);let o=0;for(this.asyncStream_=new l,this.asyncStream_.push(this.decryptChunk_(n.subarray(o,o+r),t,i,a)),o=r;o<n.length;o+=r)i=new Uint32Array([f(n[o-4]),f(n[o-3]),f(n[o-2]),f(n[o-1])]),this.asyncStream_.push(this.decryptChunk_(n.subarray(o,o+r),t,i,a));this.asyncStream_.push(function(){var e; 3814/*! @name aes-decrypter @version 4.0.1 @license Apache-2.0 */s(null,(e=a).subarray(0,e.byteLength-e[e.byteLength-1]))})}static get STEP(){return 32e3}decryptChunk_(t,i,s,r){return function(){var e=function(e,t,i){var s,r,n,a,o=new Int32Array(e.buffer,e.byteOffset,e.byteLength>>2),l=new g(Array.prototype.slice.call(t)),t=new Uint8Array(e.byteLength),d=new Int32Array(t.buffer);let h,u,c,p,m;for(h=i[0],u=i[1],c=i[2],p=i[3],m=0;m<o.length;m+=4)s=f(o[m]),r=f(o[m+1]),n=f(o[m+2]),a=f(o[m+3]),l.decrypt(s,r,n,a,d,m),d[m]=f(d[m]^h),d[m+1]=f(d[m+1]^u),d[m+2]=f(d[m+2]^c),d[m+3]=f(d[m+3]^p),h=s,u=r,c=n,p=a;return t}(t,i,s);r.set(e,t.byteOffset)}}}var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t="undefined"!=typeof window?window:"undefined"!=typeof t?t:"undefined"!=typeof self?self:{},t=t.BigInt||Number;t("0x1"),t("0x100"),t("0x10000"),t("0x1000000"),t("0x100000000"),t("0x10000000000"),t("0x1000000000000"),t("0x100000000000000"),t("0x10000000000000000"),t=new Uint16Array([65484]),255!==(t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))[0]&&t[0];function r(s){const r={};return Object.keys(s).forEach(e=>{var t,i=s[e];t=i,("function"===ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer)?r[e]={bytes:i.buffer,byteOffset:i.byteOffset,byteLength:i.byteLength}:r[e]=i}),r}self.onmessage=function(e){const i=e.data;var e=new Uint8Array(i.encrypted.bytes,i.encrypted.byteOffset,i.encrypted.byteLength),t=new Uint32Array(i.key.bytes,i.key.byteOffset,i.key.byteLength/4),s=new Uint32Array(i.iv.bytes,i.iv.byteOffset,i.iv.byteLength/4);new d(e,t,s,function(e,t){self.postMessage(r({source:i.source,decrypted:t}),[t.buffer])})}})));const uu=(e,t)=>{e.abort(),e.pause(),t&&t.activePlaylistLoader&&(t.activePlaylistLoader.pause(),t.activePlaylistLoader=null)},cu=(e,t)=>{(t.activePlaylistLoader=e).load()},pu={AUDIO:(a,o)=>()=>{var{segmentLoaders:{[a]:e},mediaTypes:{[a]:t},excludePlaylist:i}=o,e=(uu(e,t),t.activeTrack()),s=t.activeGroup(),s=(s.filter(e=>e.default)[0]||s[0]).id,r=t.tracks[s];if(e===r)i({error:{message:"Problem encountered loading the default audio track."}});else{T.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(const n in t.tracks)t.tracks[n].enabled=t.tracks[n]===r;t.onTrackChanged()}},SUBTITLES:(i,s)=>()=>{var{segmentLoaders:{[i]:e},mediaTypes:{[i]:t}}=s,e=(T.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track."),uu(e,t),t.activeTrack());e&&(e.mode="disabled"),t.onTrackChanged()}},mu={AUDIO:(e,t,i)=>{if(!t)return;const{tech:s,requestOptions:r,segmentLoaders:{[e]:n}}=i;t.on("loadedmetadata",()=>{var e=t.media();n.playlist(e,r),(!s.paused()||e.endList&&"none"!==s.preload())&&n.load()}),t.on("loadedplaylist",()=>{n.playlist(t.media(),r),s.paused()||n.load()}),t.on("error",pu[e](e,i))},SUBTITLES:(e,t,i)=>{const{tech:s,requestOptions:r,segmentLoaders:{[e]:n},mediaTypes:{[e]:a}}=i;t.on("loadedmetadata",()=>{var e=t.media();n.playlist(e,r),n.track(a.activeTrack()),(!s.paused()||e.endList&&"none"!==s.preload())&&n.load()}),t.on("loadedplaylist",()=>{n.playlist(t.media(),r),s.paused()||n.load()}),t.on("error",pu[e](e,i))}},gu={AUDIO:(i,s)=>{var r,{vhs:n,sourceType:a,segmentLoaders:{[i]:e},requestOptions:o,main:{mediaGroups:l},mediaTypes:{[i]:{groups:d,tracks:h,logger_:u}},mainPlaylistLoader:c}=s,p=pd(c.main);l[i]&&0!==Object.keys(l[i]).length||(l[i]={main:{default:{default:!0}}},p&&(l[i].main.default.playlists=c.main.playlists));for(const m in l[i]){d[m]||(d[m]=[]);for(const g in l[i][m]){let e=l[i][m][g],t;t=p?(u(`AUDIO group '${m}' label '${g}' is a main playlist`),e.isMainPlaylist=!0,null):"vhs-json"===a&&e.playlists?new Cd(e.playlists[0],n,o):e.resolvedUri?new Cd(e.resolvedUri,n,o):e.playlists&&"dash"===a?new Kd(e.playlists[0],n,o,c):null,e=O({id:g,playlistLoader:t},e),mu[i](i,e.playlistLoader,s),d[m].push(e),"undefined"==typeof h[g]&&(r=new T.AudioTrack({id:g,kind:(e=>{let t=e.default?"main":"alternative";return t=e.characteristics&&0<=e.characteristics.indexOf("public.accessibility.describes-video")?"main-desc":t})(e),enabled:!1,language:e.language,default:e.default,label:g}),h[g]=r)}}e.on("error",pu[i](i,s))},SUBTITLES:(i,s)=>{var r,{tech:n,vhs:a,sourceType:o,segmentLoaders:{[i]:e},requestOptions:l,main:{mediaGroups:d},mediaTypes:{[i]:{groups:h,tracks:u}},mainPlaylistLoader:c}=s;for(const p in d[i]){h[p]||(h[p]=[]);for(const m in d[i][p])if(!d[i][p][m].forced){let e=d[i][p][m],t;if("hls"===o)t=new Cd(e.resolvedUri,a,l);else if("dash"===o){if(!e.playlists.filter(e=>e.excludeUntil!==1/0).length)return;t=new Kd(e.playlists[0],a,l,c)}else"vhs-json"===o&&(t=new Cd(e.playlists?e.playlists[0]:e.resolvedUri,a,l));e=O({id:m,playlistLoader:t},e),mu[i](i,e.playlistLoader,s),h[p].push(e),"undefined"==typeof u[m]&&(r=n.addRemoteTextTrack({id:m,kind:"subtitles",default:e.default&&e.autoselect,language:e.language,label:m},!1).track,u[m]=r)}}e.on("error",pu[i](i,s))},"CLOSED-CAPTIONS":(e,t)=>{var{tech:i,main:{mediaGroups:s},mediaTypes:{[e]:{groups:r,tracks:n}}}=t;for(const l in s[e]){r[l]||(r[l]=[]);for(const d in s[e][l]){var a=s[e][l][d];if(/^(?:CC|SERVICE)/.test(a.instreamId)){var o=i.options_.vhs&&i.options_.vhs.captionServices||{};let e={label:d,language:a.language,instreamId:a.instreamId,default:a.default&&a.autoselect};void 0===(e=o[e.instreamId]?O(e,o[e.instreamId]):e).default&&delete e.default,r[l].push(O({id:d},a)),"undefined"==typeof n[d]&&(o=i.addRemoteTextTrack({id:e.instreamId,kind:"captions",default:e.default,language:e.language,label:e.label},!1).track,n[d]=o)}}}}},fu=(t,i)=>{for(let e=0;e<t.length;e++){if(cd(i,t[e]))return!0;if(t[e].playlists&&fu(t[e].playlists,i))return!0}return!1},yu={AUDIO:(i,s)=>()=>{var{[i]:{tracks:e}}=s["mediaTypes"];for(const t in e)if(e[t].enabled)return e[t];return null},SUBTITLES:(i,s)=>()=>{var{[i]:{tracks:e}}=s["mediaTypes"];for(const t in e)if("showing"===e[t].mode||"hidden"===e[t].mode)return e[t];return null}},_u=n=>{["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{gu[e](e,n)});const{mediaTypes:a,mainPlaylistLoader:e,tech:t,vhs:i,segmentLoaders:{AUDIO:s,main:r}}=n;["AUDIO","SUBTITLES"].forEach(e=>{var o,l,d,h,i,s,u,c,t,r;a[e].activeGroup=(o=e,l=n,t=>{var{mainPlaylistLoader:e,mediaTypes:{[o]:{groups:i}}}=l,s=e.media();if(!s)return null;let r=null;s.attributes[o]&&(r=i[s.attributes[o]]);var n=Object.keys(i);if(!r)if("AUDIO"===o&&1<n.length&&pd(l.main))for(let e=0;e<n.length;e++){var a=i[n[e]];if(fu(a,s)){r=a;break}}else i.main?r=i.main:1===n.length&&(r=i[n[0]]);return"undefined"==typeof t?r:null!==t&&r&&r.filter(e=>e.id===t.id)[0]||null}),a[e].activeTrack=yu[e](e,n),a[e].onGroupChanged=(d=e,h=n,()=>{var{segmentLoaders:{[d]:e,main:t},mediaTypes:{[d]:i}}=h,s=i.activeTrack(),r=i.getActiveGroup(),n=i.activePlaylistLoader,a=i.lastGroup_;r&&a&&r.id===a.id||(i.lastGroup_=r,i.lastTrack_=s,uu(e,i),r&&!r.isMainPlaylist&&(r.playlistLoader?(e.resyncLoader(),cu(r.playlistLoader,i)):n&&t.resetEverything()))}),a[e].onGroupChanging=(i=e,s=n,()=>{var{segmentLoaders:{[i]:e},mediaTypes:{[i]:t}}=s;t.lastGroup_=null,e.abort(),e.pause()}),a[e].onTrackChanged=(u=e,c=n,()=>{var e,t,{mainPlaylistLoader:i,segmentLoaders:{[u]:s,main:r},mediaTypes:{[u]:n}}=c,a=n.activeTrack(),o=n.getActiveGroup(),l=n.activePlaylistLoader,d=n.lastTrack_;if((!d||!a||d.id!==a.id)&&(n.lastGroup_=o,n.lastTrack_=a,uu(s,n),o)){if(o.isMainPlaylist)return!a||!d||a.id===d.id||(t=(e=c.vhs.playlistController_).selectPlaylist(),e.media()===t)?void 0:(n.logger_(`track change. Switching main audio from ${d.id} to `+a.id),i.pause(),r.resetEverything(),void e.fastQualityChange_(t));if("AUDIO"===u){if(!o.playlistLoader)return r.setAudio(!0),void r.resetEverything();s.setAudio(!0),r.setAudio(!1)}l===o.playlistLoader||(s.track&&s.track(a),s.resetEverything()),cu(o.playlistLoader,n)}}),a[e].getActiveGroup=([t,r]=[e,n["mediaTypes"]],()=>{var e=r[t].activeTrack();return e?r[t].activeGroup(e):null})});var o=a.AUDIO.activeGroup();o&&(o=(o.filter(e=>e.default)[0]||o[0]).id,a.AUDIO.tracks[o].enabled=!0,a.AUDIO.onGroupChanged(),a.AUDIO.onTrackChanged(),(a.AUDIO.getActiveGroup().playlistLoader?(r.setAudio(!1),s):r).setAudio(!0)),e.on("mediachange",()=>{["AUDIO","SUBTITLES"].forEach(e=>a[e].onGroupChanged())}),e.on("mediachanging",()=>{["AUDIO","SUBTITLES"].forEach(e=>a[e].onGroupChanging())});const l=()=>{a.AUDIO.onTrackChanged(),t.trigger({type:"usage",name:"vhs-audio-change"})};t.audioTracks().addEventListener("change",l),t.remoteTextTracks().addEventListener("change",a.SUBTITLES.onTrackChanged),i.on("dispose",()=>{t.audioTracks().removeEventListener("change",l),t.remoteTextTracks().removeEventListener("change",a.SUBTITLES.onTrackChanged)}),t.clearTracks("audio");for(const d in a.AUDIO.tracks)t.audioTracks().addTrack(a.AUDIO.tracks[d])};let vu;const bu=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred","mediaAppends"];class Tu extends T.EventTarget{constructor(e){super();const{src:t,withCredentials:i,tech:r,bandwidth:s,externVhs:n,useCueTags:a,playlistExclusionDuration:o,enableLowInitialPlaylist:l,sourceType:d,cacheEncryptionKeys:h,bufferBasedABR:u,leastPixelDiffSelector:c,captionServices:p}=e;if(!t)throw new Error("A non-empty playlist URL or JSON manifest string is required");let m=e["maxPlaylistRetries"];null!==m&&"undefined"!=typeof m||(m=1/0),vu=n,this.bufferBasedABR=Boolean(u),this.leastPixelDiffSelector=Boolean(c),this.withCredentials=i,this.tech_=r,this.vhs_=r.vhs,this.sourceType_=d,this.useCueTags_=a,this.playlistExclusionDuration=o,this.maxPlaylistRetries=m,this.enableLowInitialPlaylist=l,this.useCueTags_&&(this.cueTagsTrack_=this.tech_.addTextTrack("metadata","ad-cues"),this.cueTagsTrack_.inBandMetadataTrackDispatchType=""),this.requestOptions_={withCredentials:i,maxPlaylistRetries:m,timeout:null},this.on("error",this.pauseLoading),this.mediaTypes_=(()=>{const t={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{t[e]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:Gh,activeTrack:Gh,getActiveGroup:Gh,onGroupChanged:Gh,onTrackChanged:Gh,lastTrack_:null,logger_:Bl(`MediaGroups[${e}]`)}}),t})(),this.mediaSource=new window.MediaSource,this.handleDurationChange_=this.handleDurationChange_.bind(this),this.handleSourceOpen_=this.handleSourceOpen_.bind(this),this.handleSourceEnded_=this.handleSourceEnded_.bind(this),this.mediaSource.addEventListener("durationchange",this.handleDurationChange_),this.mediaSource.addEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.addEventListener("sourceended",this.handleSourceEnded_),this.seekable_=Fl(),this.hasPlayed_=!1,this.syncController_=new lu(e),this.segmentMetadataTrack_=r.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,this.decrypter_=new hu,this.sourceUpdater_=new iu(this.mediaSource),this.inbandTextTracks_={},this.timelineChangeController_=new du;var g={vhs:this.vhs_,parse708captions:e.parse708captions,useDtsForTimestampOffset:e.useDtsForTimestampOffset,captionServices:p,mediaSource:this.mediaSource,currentTime:this.tech_.currentTime.bind(this.tech_),seekable:()=>this.seekable(),seeking:()=>this.tech_.seeking(),duration:()=>this.duration(),hasPlayed:()=>this.hasPlayed_,goalBufferLength:()=>this.goalBufferLength(),bandwidth:s,syncController:this.syncController_,decrypter:this.decrypter_,sourceType:this.sourceType_,inbandTextTracks:this.inbandTextTracks_,cacheEncryptionKeys:h,sourceUpdater:this.sourceUpdater_,timelineChangeController:this.timelineChangeController_,exactManifestTimings:e.exactManifestTimings},g=(this.mainPlaylistLoader_=new("dash"===this.sourceType_?Kd:Cd)(t,this.vhs_,this.requestOptions_),this.setupMainPlaylistLoaderListeners_(),this.mainSegmentLoader_=new Wh(O(g,{segmentMetadataTrack:this.segmentMetadataTrack_,loaderType:"main"}),e),this.audioSegmentLoader_=new Wh(O(g,{loaderType:"audio"}),e),this.subtitleSegmentLoader_=new au(O(g,{loaderType:"vtt",featuresNativeTextTracks:this.tech_.featuresNativeTextTracks,loadVttJs:()=>new Promise((e,t)=>{function i(){r.off("vttjserror",s),e()}function s(){r.off("vttjsloaded",i),t()}r.one("vttjsloaded",i),r.one("vttjserror",s),r.addWebVttScript_()})}),e),this.setupSegmentLoaderListeners_(),this.bufferBasedABR&&(this.mainPlaylistLoader_.one("loadedplaylist",()=>this.startABRTimer_()),this.tech_.on("pause",()=>this.stopABRTimer_()),this.tech_.on("play",()=>this.startABRTimer_())),bu.forEach(e=>{this[e+"_"]=function(e){return this.audioSegmentLoader_[e]+this.mainSegmentLoader_[e]}.bind(this,e)}),this.logger_=Bl("pc"),this.triggeredFmp4Usage=!1,"none"===this.tech_.preload()?(this.loadOnPlay_=()=>{this.loadOnPlay_=null,this.mainPlaylistLoader_.load()},this.tech_.one("play",this.loadOnPlay_)):this.mainPlaylistLoader_.load(),this.timeToLoadedData__=-1,this.mainAppendsToLoadedData__=-1,this.audioAppendsToLoadedData__=-1,"none"===this.tech_.preload()?"play":"loadstart");this.tech_.one(g,()=>{const e=Date.now();this.tech_.one("loadeddata",()=>{this.timeToLoadedData__=Date.now()-e,this.mainAppendsToLoadedData__=this.mainSegmentLoader_.mediaAppends,this.audioAppendsToLoadedData__=this.audioSegmentLoader_.mediaAppends})})}mainAppendsToLoadedData_(){return this.mainAppendsToLoadedData__}audioAppendsToLoadedData_(){return this.audioAppendsToLoadedData__}appendsToLoadedData_(){var e=this.mainAppendsToLoadedData_(),t=this.audioAppendsToLoadedData_();return-1===e||-1===t?-1:e+t}timeToLoadedData_(){return this.timeToLoadedData__}checkABR_(e="abr"){var t=this.selectPlaylist();t&&this.shouldSwitchToMedia_(t)&&this.switchMedia_(t,e)}switchMedia_(e,t,i){var s=this.media(),s=s&&(s.id||s.uri),r=e.id||e.uri;s&&s!==r&&(this.logger_(`switch media ${s} -> ${r} from `+t),this.tech_.trigger({type:"usage",name:"vhs-rendition-change-"+t})),this.mainPlaylistLoader_.media(e,i)}startABRTimer_(){this.stopABRTimer_(),this.abrTimer_=window.setInterval(()=>this.checkABR_(),250)}stopABRTimer_(){this.tech_.scrubbing&&this.tech_.scrubbing()||(window.clearInterval(this.abrTimer_),this.abrTimer_=null)}getAudioTrackPlaylists_(){var t=this.main(),e=t&&t.playlists||[];if(!t||!t.mediaGroups||!t.mediaGroups.AUDIO)return e;var i=t.mediaGroups.AUDIO,s=Object.keys(i);let r;if(Object.keys(this.mediaTypes_.AUDIO.groups).length)r=this.mediaTypes_.AUDIO.activeTrack();else{var n=i.main||s.length&&i[s[0]];for(const d in n)if(n[d].default){r={label:d};break}}if(!r)return e;var a=[];for(const h in i)if(i[h][r.label]){var o=i[h][r.label];if(o.playlists&&o.playlists.length)a.push.apply(a,o.playlists);else if(o.uri)a.push(o);else if(t.playlists.length)for(let e=0;e<t.playlists.length;e++){var l=t.playlists[e];l.attributes&&l.attributes.AUDIO&&l.attributes.AUDIO===h&&a.push(l)}}return a.length?a:e}setupMainPlaylistLoaderListeners_(){this.mainPlaylistLoader_.on("loadedmetadata",()=>{var e=this.mainPlaylistLoader_.media(),t=1.5*e.targetDuration*1e3;ud(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=t,e.endList&&"none"!==this.tech_.preload()&&(this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.mainSegmentLoader_.load()),_u({sourceType:this.sourceType_,segmentLoaders:{AUDIO:this.audioSegmentLoader_,SUBTITLES:this.subtitleSegmentLoader_,main:this.mainSegmentLoader_},tech:this.tech_,requestOptions:this.requestOptions_,mainPlaylistLoader:this.mainPlaylistLoader_,vhs:this.vhs_,main:this.main(),mediaTypes:this.mediaTypes_,excludePlaylist:this.excludePlaylist.bind(this)}),this.triggerPresenceUsage_(this.main(),e),this.setupFirstPlay(),!this.mediaTypes_.AUDIO.activePlaylistLoader||this.mediaTypes_.AUDIO.activePlaylistLoader.media()?this.trigger("selectedinitialmedia"):this.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",()=>{this.trigger("selectedinitialmedia")})}),this.mainPlaylistLoader_.on("loadedplaylist",()=>{this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_);let t=this.mainPlaylistLoader_.media();if(!t){this.excludeUnsupportedVariants_();let e;if(!(e=(e=this.enableLowInitialPlaylist?this.selectInitialPlaylist():e)||this.selectPlaylist())||!this.shouldSwitchToMedia_(e))return;if(this.initialMedia_=e,this.switchMedia_(this.initialMedia_,"initial"),!("vhs-json"===this.sourceType_&&this.initialMedia_.segments))return;t=this.initialMedia_}this.handleUpdatedMediaPlaylist(t)}),this.mainPlaylistLoader_.on("error",()=>{var e=this.mainPlaylistLoader_.error;this.excludePlaylist({playlistToExclude:e.playlist,error:e})}),this.mainPlaylistLoader_.on("mediachanging",()=>{this.mainSegmentLoader_.abort(),this.mainSegmentLoader_.pause()}),this.mainPlaylistLoader_.on("mediachange",()=>{var e=this.mainPlaylistLoader_.media(),t=1.5*e.targetDuration*1e3;ud(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=t,this.mainPlaylistLoader_.load(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.mainSegmentLoader_.load(),this.tech_.trigger({type:"mediachange",bubbles:!0})}),this.mainPlaylistLoader_.on("playlistunchanged",()=>{var e=this.mainPlaylistLoader_.media();"playlist-unchanged"!==e.lastExcludeReason_&&this.stuckAtPlaylistEnd_(e)&&(this.excludePlaylist({error:{message:"Playlist no longer updating.",reason:"playlist-unchanged"}}),this.tech_.trigger("playliststuck"))}),this.mainPlaylistLoader_.on("renditiondisabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-disabled"})}),this.mainPlaylistLoader_.on("renditionenabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-enabled"})})}handleUpdatedMediaPlaylist(e){this.useCueTags_&&this.updateAdCues_(e),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.updateDuration(!e.endList),this.tech_.paused()||(this.mainSegmentLoader_.load(),this.audioSegmentLoader_&&this.audioSegmentLoader_.load())}triggerPresenceUsage_(e,t){var i=e.mediaGroups||{};let s=!0;e=Object.keys(i.AUDIO);for(const r in i.AUDIO)for(const n in i.AUDIO[r])i.AUDIO[r][n].uri||(s=!1);s&&this.tech_.trigger({type:"usage",name:"vhs-demuxed"}),Object.keys(i.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"vhs-webvtt"}),vu.Playlist.isAes(t)&&this.tech_.trigger({type:"usage",name:"vhs-aes"}),e.length&&1<Object.keys(i.AUDIO[e[0]]).length&&this.tech_.trigger({type:"usage",name:"vhs-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"vhs-playlist-cue-tags"})}shouldSwitchToMedia_(t){var e=this.mainPlaylistLoader_.media()||this.mainPlaylistLoader_.pendingMedia_,i=this.tech_.currentTime(),s=this.bufferLowWaterLine(),r=this.bufferHighWaterLine(),{currentPlaylist:i,buffered:e,currentTime:t,nextPlaylist:s,bufferLowWaterLine:r,bufferHighWaterLine:n,duration:a,bufferBasedABR:o,log:l}=[{buffered:this.tech_.buffered(),currentTime:i,currentPlaylist:e,nextPlaylist:t,bufferLowWaterLine:s,bufferHighWaterLine:r,duration:this.duration(),bufferBasedABR:this.bufferBasedABR,log:this.logger_}][0];if(s){var d=`allowing switch ${i&&i.id||"null"} -> `+s.id;if(!i)return l(d+" as current playlist is not set"),!0;if(s.id!==i.id){var h=Boolean(jl(e,t).length);if(!i.endList)return h||"number"!=typeof i.partTargetDuration?(l(d+" as current playlist is live"),!0):(l(`not ${d} as current playlist is live llhls, but currentTime isn't in buffered.`),!1);h=Vl(e,t),e=o?D.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:D.MAX_BUFFER_LOW_WATER_LINE;if(a<e)return l(d+` as duration < max low water line (${a} < ${e})`),!0;t=s.attributes.BANDWIDTH,a=i.attributes.BANDWIDTH;if(t<a&&(!o||h<n)){let e=d+` as next bandwidth < current bandwidth (${t} < ${a})`;return o&&(e+=` and forwardBuffer < bufferHighWaterLine (${h} < ${n})`),l(e),!0}if((!o||a<t)&&r<=h){let e=d+` as forwardBuffer >= bufferLowWaterLine (${h} >= ${r})`;return o&&(e+=` and next bandwidth > current bandwidth (${t} > ${a})`),l(e),!0}l(`not ${d} as no switching criteria met`)}}else T.log.warn("We received no playlist to switch to. Please check your stream.");return!1}setupSegmentLoaderListeners_(){this.mainSegmentLoader_.on("bandwidthupdate",()=>{this.checkABR_("bandwidthupdate"),this.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("timeout",()=>{this.bufferBasedABR&&this.mainSegmentLoader_.load()}),this.bufferBasedABR||this.mainSegmentLoader_.on("progress",()=>{this.trigger("progress")}),this.mainSegmentLoader_.on("error",()=>{var e=this.mainSegmentLoader_.error();this.excludePlaylist({playlistToExclude:e.playlist,error:e})}),this.mainSegmentLoader_.on("appenderror",()=>{this.error=this.mainSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",()=>{this.tech_.trigger({type:"usage",name:"vhs-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.audioSegmentLoader_.on("appenderror",()=>{this.error=this.audioSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("ended",()=>{this.logger_("main segment loader ended"),this.onEndOfStream()}),this.mainSegmentLoader_.on("earlyabort",e=>{this.bufferBasedABR||(this.delegateLoaders_("all",["abort"]),this.excludePlaylist({error:{message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},playlistExclusionDuration:120}))});var e=()=>{if(!this.sourceUpdater_.hasCreatedSourceBuffers())return this.tryToCreateSourceBuffers_();var e=this.getCodecsOrExclude_();e&&this.sourceUpdater_.addOrChangeSourceBuffers(e)};this.mainSegmentLoader_.on("trackinfo",e),this.audioSegmentLoader_.on("trackinfo",e),this.mainSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("ended",()=>{this.logger_("audioSegmentLoader ended"),this.onEndOfStream()})}mediaSecondsLoaded_(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}load(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}fastQualityChange_(e=this.selectPlaylist()){e===this.mainPlaylistLoader_.media()?this.logger_("skipping fastQualityChange because new media is same as old"):(this.switchMedia_(e,"fast-quality"),this.mainSegmentLoader_.resetEverything(()=>{T.browser.IE_VERSION||T.browser.IS_EDGE?this.tech_.setCurrentTime(this.tech_.currentTime()+.04):this.tech_.setCurrentTime(this.tech_.currentTime())}))}play(){var e;if(!this.setupFirstPlay())return this.tech_.ended()&&this.tech_.setCurrentTime(0),this.hasPlayed_&&this.load(),e=this.tech_.seekable(),this.tech_.duration()===1/0&&this.tech_.currentTime()<e.start(0)?this.tech_.setCurrentTime(e.end(e.length-1)):void 0}setupFirstPlay(){var e=this.mainPlaylistLoader_.media();if(!e||this.tech_.paused()||this.hasPlayed_)return!1;if(!e.endList){const t=this.seekable();if(!t.length)return!1;if(T.browser.IE_VERSION&&0===this.tech_.readyState())return this.tech_.one("loadedmetadata",()=>{this.trigger("firstplay"),this.tech_.setCurrentTime(t.end(0)),this.hasPlayed_=!0}),!1;this.trigger("firstplay"),this.tech_.setCurrentTime(t.end(0))}return this.hasPlayed_=!0,this.load(),!0}handleSourceOpen_(){var e;this.tryToCreateSourceBuffers_(),this.tech_.autoplay()&&"undefined"!=typeof(e=this.tech_.play())&&"function"==typeof e.then&&e.then(null,e=>{}),this.trigger("sourceopen")}handleSourceEnded_(){var e,t;this.inbandTextTracks_.metadataTrack_&&(e=this.inbandTextTracks_.metadataTrack_.cues)&&e.length&&(t=this.duration(),e[e.length-1].endTime=isNaN(t)||Math.abs(t)===1/0?Number.MAX_VALUE:t)}handleDurationChange_(){this.tech_.trigger("durationchange")}onEndOfStream(){let e=this.mainSegmentLoader_.ended_;var t;this.mediaTypes_.AUDIO.activePlaylistLoader&&(t=this.mainSegmentLoader_.getCurrentMediaInfo_(),e=(t&&!t.hasVideo||e)&&this.audioSegmentLoader_.ended_),e&&(this.stopABRTimer_(),this.sourceUpdater_.endOfStream())}stuckAtPlaylistEnd_(e){var t,i;return!!this.seekable().length&&null!==(t=this.syncController_.getExpiredTime(e,this.duration()))&&(e=vu.Playlist.playlistEnd(e,t),t=this.tech_.currentTime(),(i=this.tech_.buffered()).length?(i=i.end(i.length-1))-t<=zl&&e-i<=zl:e-t<=zl)}excludePlaylist({playlistToExclude:s=this.mainPlaylistLoader_.media(),error:t={},playlistExclusionDuration:i}){if(s=s||this.mainPlaylistLoader_.media(),i=i||t.playlistExclusionDuration||this.playlistExclusionDuration,s){s.playlistErrors_++;var r=this.mainPlaylistLoader_.main.playlists,n=r.filter(ld),n=1===n.length&&n[0]===s;if(1===r.length&&i!==1/0)return T.log.warn(`Problem encountered with playlist ${s.id}. `+"Trying again since it is the only playlist."),this.tech_.trigger("retryplaylist"),this.mainPlaylistLoader_.load(n);if(n){let i=!1;r.forEach(e=>{var t;e!==s&&"undefined"!=typeof(t=e.excludeUntil)&&t!==1/0&&(i=!0,delete e.excludeUntil)}),i&&(T.log.warn("Removing other playlists from the exclusion list because the last rendition is about to be excluded."),this.tech_.trigger("retryplaylist"))}let e;e=s.playlistErrors_>this.maxPlaylistRetries?1/0:Date.now()+1e3*i,s.excludeUntil=e,t.reason&&(s.lastExcludeReason_=t.reason),this.tech_.trigger("excludeplaylist"),this.tech_.trigger({type:"usage",name:"vhs-rendition-excluded"});var a,r=this.selectPlaylist();if(r)return i=t.internal?this.logger_:T.log.warn,a=t.message?" "+t.message:"",i(`${t.internal?"Internal problem":"Problem"} encountered with playlist ${s.id}
3814.`+a+` Switching to playlist ${r.id}.`),r.attributes.AUDIO!==s.attributes.AUDIO&&this.delegateLoaders_("audio",["abort","pause"]),r.attributes.SUBTITLES!==s.attributes.SUBTITLES&&this.delegateLoaders_("subtitle",["abort","pause"]),this.delegateLoaders_("main",["abort","pause"]),i=r.targetDuration/2*1e3||5e3,a="number"==typeof r.lastRequest&&Date.now()-r.lastRequest<=i,this.switchMedia_(r,"exclude",n||a);this.error="Playback cannot continue. No available working or supported playlists.",this.trigger("error")}else this.error=t,"open"!==this.mediaSource.readyState?this.trigger("error"):this.sourceUpdater_.endOfStream("network")}pauseLoading(){this.delegateLoaders_("all",["abort","pause"]),this.stopABRTimer_()}delegateLoaders_(i,e){const s=[];var t="all"===i,r=(!t&&"main"!==i||s.push(this.mainPlaylistLoader_),[]);!t&&"audio"!==i||r.push("AUDIO"),!t&&"subtitle"!==i||(r.push("CLOSED-CAPTIONS"),r.push("SUBTITLES")),r.forEach(e=>{e=this.mediaTypes_[e]&&this.mediaTypes_[e].activePlaylistLoader;e&&s.push(e)}),["main","audio","subtitle"].forEach(e=>{var t=this[e+"SegmentLoader_"];!t||i!==e&&"all"!==i||s.push(t)}),s.forEach(t=>e.forEach(e=>{"function"==typeof t[e]&&t[e]()}))}setCurrentTime(e){var t=jl(this.tech_.buffered(),e);return this.mainPlaylistLoader_&&this.mainPlaylistLoader_.media()&&this.mainPlaylistLoader_.media().segments?t&&t.length?e:(this.mainSegmentLoader_.resetEverything(),this.mainSegmentLoader_.abort(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.resetEverything(),this.audioSegmentLoader_.abort()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.resetEverything(),this.subtitleSegmentLoader_.abort()),void this.load()):0}duration(){var e;return this.mainPlaylistLoader_&&(e=this.mainPlaylistLoader_.media())?e.endList?this.mediaSource?this.mediaSource.duration:vu.Playlist.duration(e):1/0:0}seekable(){return this.seekable_}onSyncInfoUpdate_(){let i;if(this.mainPlaylistLoader_){var s=this.mainPlaylistLoader_.media();if(s){var r=this.syncController_.getExpiredTime(s,this.duration());if(null!==r){var n=this.mainPlaylistLoader_.main,a=vu.Playlist.seekable(s,r,vu.Playlist.liveEdgeDelay(n,s));if(0!==a.length){if(this.mediaTypes_.AUDIO.activePlaylistLoader){if(s=this.mediaTypes_.AUDIO.activePlaylistLoader.media(),null===(r=this.syncController_.getExpiredTime(s,this.duration())))return;if(0===(i=vu.Playlist.seekable(s,r,vu.Playlist.liveEdgeDelay(n,s))).length)return}let e,t;this.seekable_&&this.seekable_.length&&(e=this.seekable_.end(0),t=this.seekable_.start(0)),!i||i.start(0)>a.end(0)||a.start(0)>i.end(0)?this.seekable_=a:this.seekable_=Fl([[(i.start(0)>a.start(0)?i:a).start(0),(i.end(0)<a.end(0)?i:a).end(0)]]),this.seekable_&&this.seekable_.length&&this.seekable_.end(0)===e&&this.seekable_.start(0)===t||(this.logger_(`seekable updated [${Kl(this.seekable_)}]`),this.tech_.trigger("seekablechanged"))}}}}}updateDuration(t){if(this.updateDuration_&&(this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.updateDuration_=null),"open"!==this.mediaSource.readyState)this.updateDuration_=this.updateDuration.bind(this,t),this.mediaSource.addEventListener("sourceopen",this.updateDuration_);else{if(t)return(t=this.seekable()).length?void((isNaN(this.mediaSource.duration)||this.mediaSource.duration<t.end(t.length-1))&&this.sourceUpdater_.setDuration(t.end(t.length-1))):void 0;t=this.tech_.buffered();let e=vu.Playlist.duration(this.mainPlaylistLoader_.media());0<t.length&&(e=Math.max(e,t.end(t.length-1))),this.mediaSource.duration!==e&&this.sourceUpdater_.setDuration(e)}}dispose(){this.trigger("dispose"),this.decrypter_.terminate(),this.mainPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_),["AUDIO","SUBTITLES"].forEach(e=>{var t=this.mediaTypes_[e].groups;for(const i in t)t[i].forEach(e=>{e.playlistLoader&&e.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose(),this.sourceUpdater_.dispose(),this.timelineChangeController_.dispose(),this.stopABRTimer_(),this.updateDuration_&&this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.mediaSource.removeEventListener("durationchange",this.handleDurationChange_),this.mediaSource.removeEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.removeEventListener("sourceended",this.handleSourceEnded_),this.off()}main(){return this.mainPlaylistLoader_.main}media(){return this.mainPlaylistLoader_.media()||this.initialMedia_}areMediaTypesKnown_(){var e=!!this.mediaTypes_.AUDIO.activePlaylistLoader,t=!!this.mainSegmentLoader_.getCurrentMediaInfo_(),e=!e||!!this.audioSegmentLoader_.getCurrentMediaInfo_();return t&&e}getCodecsOrExclude_(){const r={main:this.mainSegmentLoader_.getCurrentMediaInfo_()||{},audio:this.audioSegmentLoader_.getCurrentMediaInfo_()||{}},t=this.mainSegmentLoader_.getPendingSegmentPlaylist()||this.media();r.video=r.main;var e=mh(this.main(),t);const n={};var i=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(r.main.hasVideo&&(n.video=e.video||r.main.videoCodec||"avc1.4d400d"),r.main.isMuxed&&(n.video+=","+(e.audio||r.main.audioCodec||Fn)),(r.main.hasAudio&&!r.main.isMuxed||r.audio.hasAudio||i)&&(n.audio=e.audio||r.main.audioCodec||r.audio.audioCodec||Fn,r.audio.isFmp4=(r.main.hasAudio&&!r.main.isMuxed?r.main:r.audio).isFmp4),n.audio||n.video){const a={};let s;if(["video","audio"].forEach(function(e){var t,i;n.hasOwnProperty(e)&&(t=r[e].isFmp4,i=n[e],!(t?In:xn)(i))&&(t=r[e].isFmp4?"browser":"muxer",a[t]=a[t]||[],a[t].push(n[e]),"audio"===e&&(s=t))}),i&&s&&t.attributes.AUDIO){const o=t.attributes.AUDIO;
vendor: 26,385 bytes, line 3814
3814this.main().playlists.forEach(e=>{(e.attributes&&e.attributes.AUDIO)===o&&e!==t&&(e.excludeUntil=1/0)}),this.logger_(`excluding audio group ${o} as ${s} does not support codec(s): "${n.audio}"`)}if(!Object.keys(a).length){if(this.sourceUpdater_.hasCreatedSourceBuffers()&&!this.sourceUpdater_.canChangeType()){const l=[];if(["video","audio"].forEach(e=>{var t=(Un(this.sourceUpdater_.codecs[e]||"")[0]||{}).type,i=(Un(n[e]||"")[0]||{}).type;t&&i&&t.toLowerCase()!==i.toLowerCase()&&l.push(`"${this.sourceUpdater_.codecs[e]}" -> "${n[e]}"`)}),l.length)return void this.excludePlaylist({playlistToExclude:t,error:{message:`Codec switching not supported: ${l.join(", ")}.`,internal:!0},playlistExclusionDuration:1/0})}return n}e=Object.keys(a).reduce((e,t)=>(e&&(e+=", "),e+=`${t} does not support codec(s): "${a[t].join(",")}"`),"")+".",this.excludePlaylist({playlistToExclude:t,error:{internal:!0,message:e},playlistExclusionDuration:1/0})}else this.excludePlaylist({playlistToExclude:t,error:{message:"Could not determine codecs for playlist."},playlistExclusionDuration:1/0})}tryToCreateSourceBuffers_(){var e;"open"!==this.mediaSource.readyState||this.sourceUpdater_.hasCreatedSourceBuffers()||this.areMediaTypesKnown_()&&(e=this.getCodecsOrExclude_())&&(this.sourceUpdater_.createSourceBuffers(e),e=[e.video,e.audio].filter(Boolean).join(","),this.excludeIncompatibleVariants_(e))}excludeUnsupportedVariants_(){const s=this.main().playlists,r=[];Object.keys(s).forEach(e=>{var t,i,e=s[e];-1===r.indexOf(e.id)&&(r.push(e.id),i=[],!(t=mh(this.main,e)).audio||xn(t.audio)||In(t.audio)||i.push("audio codec "+t.audio),!t.video||xn(t.video)||In(t.video)||i.push("video codec "+t.video),t.text&&"stpp.ttml.im1t"===t.text&&i.push("text codec "+t.text),i.length)&&(e.excludeUntil=1/0,this.logger_(`excluding ${e.id} for unsupported: `+i.join(", ")))})}excludeIncompatibleVariants_(e){const r=[],n=this.main().playlists;e=Lh(Un(e));const a=ph(e),o=e.video&&Un(e.video)[0]||null,l=e.audio&&Un(e.audio)[0]||null;Object.keys(n).forEach(e=>{var t,i,s,e=n[e];-1===r.indexOf(e.id)&&e.excludeUntil!==1/0&&(r.push(e.id),t=[],s=mh(this.mainPlaylistLoader_.main,e),i=ph(s),s.audio||s.video)&&(i!==a&&t.push(`codec count "${i}" !== "${a}"`),this.sourceUpdater_.canChangeType()||(i=s.video&&Un(s.video)[0]||null,s=s.audio&&Un(s.audio)[0]||null,i&&o&&i.type.toLowerCase()!==o.type.toLowerCase()&&t.push(`video codec "${i.type}" !== "${o.type}"`),s&&l&&s.type.toLowerCase()!==l.type.toLowerCase()&&t.push(`audio codec "${s.type}" !== "${l.type}"`)),t.length)&&(e.excludeUntil=1/0,this.logger_(`excluding ${e.id}: `+t.join(" && ")))})}updateAdCues_(e){let t=0;var s=this.seekable(),[r,n,s=0]=(s.length&&(t=s.start(0)),[e,this.cueTagsTrack_,t]);if(r.segments){let t=s,i;for(let e=0;e<r.segments.length;e++){var a,o,l=r.segments[e];if(i=i||function(e,t){var i=e.cues;for(let e=0;e<i.length;e++){var s=i[e];if(t>=s.adStartTime&&t<=s.adEndTime)return s}return null}(n,t+l.duration/2)){if("cueIn"in l){i.endTime=t,i.adEndTime=t,t+=l.duration,i=null;continue}if(t<i.endTime){t+=l.duration;continue}i.endTime+=l.duration}else"cueOut"in l&&((i=new window.VTTCue(t,t+l.duration,l.cueOut)).adStartTime=t,i.adEndTime=t+parseFloat(l.cueOut),n.addCue(i)),"cueOutCont"in l&&([a,o]=l.cueOutCont.split("/").map(parseFloat),(i=new window.VTTCue(t,t+l.duration,"")).adStartTime=t-a,i.adEndTime=i.adStartTime+o,n.addCue(i));t+=l.duration}}}goalBufferLength(){var e=this.tech_.currentTime(),t=D.GOAL_BUFFER_LENGTH,i=D.GOAL_BUFFER_LENGTH_RATE,s=Math.max(t,D.MAX_GOAL_BUFFER_LENGTH);return Math.min(t+e*i,s)}bufferLowWaterLine(){var e=this.tech_.currentTime(),t=D.BUFFER_LOW_WATER_LINE,i=D.BUFFER_LOW_WATER_LINE_RATE,s=Math.max(t,D.MAX_BUFFER_LOW_WATER_LINE),r=Math.max(t,D.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE);return Math.min(t+e*i,this.bufferBasedABR?r:s)}bufferHighWaterLine(){return D.BUFFER_HIGH_WATER_LINE}}class Su{constructor(e,t,i){var s,r,n,a,o=e["playlistController_"],l=o.fastQualityChange_.bind(o);t.attributes&&(s=t.attributes.RESOLUTION,this.width=s&&s.width,this.height=s&&s.height,this.bandwidth=t.attributes.BANDWIDTH,this.frameRate=t.attributes["FRAME-RATE"]),this.codecs=mh(o.main(),t),this.playlist=t,this.id=i,this.enabled=(r=e.playlists,n=t.id,a=l,e=>{var t=r.main.playlists[n],i=od(t),s=ld(t);return"undefined"==typeof e?s:(e?delete t.disabled:t.disabled=!0,e===s||i||(a(),e?r.trigger("renditionenabled"):r.trigger("renditiondisabled")),e)})}}const wu=["seeking","seeked","pause","playing","error"];class Eu{constructor(e){this.playlistController_=e.playlistController,this.tech_=e.tech,this.seekable=e.seekable,this.allowSeeksWithinUnsafeLiveWindow=e.allowSeeksWithinUnsafeLiveWindow,this.liveRangeSafeTimeDelta=e.liveRangeSafeTimeDelta,this.media=e.media,this.consecutiveUpdates=0,this.lastRecordedTime=null,this.checkCurrentTimeTimeout_=null,this.logger_=Bl("PlaybackWatcher"),this.logger_("initialize");const t=()=>this.monitorCurrentTime_(),i=()=>this.monitorCurrentTime_(),s=()=>this.techWaiting_(),r=()=>this.resetTimeUpdate_(),n=this.playlistController_,a=["main","subtitle","audio"],o={},l=(a.forEach(e=>{o[e]={reset:()=>this.resetSegmentDownloads_(e),updateend:()=>this.checkSegmentDownloads_(e)},n[e+"SegmentLoader_"].on("appendsdone",o[e].updateend),n[e+"SegmentLoader_"].on("playlistupdate",o[e].reset),this.tech_.on(["seeked","seeking"],o[e].reset)}),t=>{["main","audio"].forEach(e=>{n[e+"SegmentLoader_"][t]("appended",this.seekingAppendCheck_)})});this.seekingAppendCheck_=()=>{this.fixesBadSeeks_()&&(this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime(),l("off"))},this.clearSeekingAppendCheck_=()=>l("off"),this.watchForBadSeeking_=()=>{this.clearSeekingAppendCheck_(),l("on")},this.tech_.on("seeked",this.clearSeekingAppendCheck_),this.tech_.on("seeking",this.watchForBadSeeking_),this.tech_.on("waiting",s),this.tech_.on(wu,r),this.tech_.on("canplay",i),this.tech_.one("play",t),this.dispose=()=>{this.clearSeekingAppendCheck_(),this.logger_("dispose"),this.tech_.off("waiting",s),this.tech_.off(wu,r),this.tech_.off("canplay",i),this.tech_.off("play",t),this.tech_.off("seeking",this.watchForBadSeeking_),this.tech_.off("seeked",this.clearSeekingAppendCheck_),a.forEach(e=>{n[e+"SegmentLoader_"].off("appendsdone",o[e].updateend),n[e+"SegmentLoader_"].off("playlistupdate",o[e].reset),this.tech_.off(["seeked","seeking"],o[e].reset)}),this.checkCurrentTimeTimeout_&&window.clearTimeout(this.checkCurrentTimeTimeout_),this.resetTimeUpdate_()}}monitorCurrentTime_(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&window.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=window.setTimeout(this.monitorCurrentTime_.bind(this),250)}resetSegmentDownloads_(e){var t=this.playlistController_[e+"SegmentLoader_"];0<this[e+"StalledDownloads_"]&&this.logger_(`resetting possible stalled download count for ${e} loader`),this[e+"StalledDownloads_"]=0,this[e+"Buffered_"]=t.buffered_()}checkSegmentDownloads_(e){var t=this.playlistController_,i=t[e+"SegmentLoader_"],s=i.buffered_(),r=function(t,i){if(t!==i){if(!t&&i||!i&&t)return!0;if(t.length!==i.length)return!0;for(let e=0;e<t.length;e++)if(t.start(e)!==i.start(e)||t.end(e)!==i.end(e))return!0}return!1}(this[e+"Buffered_"],s);this[e+"Buffered_"]=s,r?this.resetSegmentDownloads_(e):(this[e+"StalledDownloads_"]++,this.logger_(`found #${this[e+"StalledDownloads_"]} ${e} appends that did not increase buffer (possible stalled download)`,{playlistId:i.playlist_&&i.playlist_.id,buffered:Yl(s)}),this[e+"StalledDownloads_"]<10||(this.logger_(e+" loader stalled download exclusion"),this.resetSegmentDownloads_(e),this.tech_.trigger({type:"usage",name:`vhs-${e}-download-exclusion`}),"subtitle"!==e&&t.excludePlaylist({error:{message:`Excessive ${e} segment downloading detected.`},playlistExclusionDuration:1/0})))}checkCurrentTime_(){var e,t;if(!this.tech_.paused()&&!this.tech_.seeking())return e=this.tech_.currentTime(),t=this.tech_.buffered(),this.lastRecordedTime===e&&(!t.length||e+zl>=t.end(t.length-1))?this.techWaiting_():void(5<=this.consecutiveUpdates&&e===this.lastRecordedTime?(this.consecutiveUpdates++,this.waiting_()):e===this.lastRecordedTime?this.consecutiveUpdates++:(this.consecutiveUpdates=0,this.lastRecordedTime=e))}resetTimeUpdate_(){this.consecutiveUpdates=0}fixesBadSeeks_(){if(!this.tech_.seeking())return!1;var e=this.seekable(),t=this.tech_.currentTime();let i;if(this.afterSeekableWindow_(e,t,this.media(),this.allowSeeksWithinUnsafeLiveWindow)&&(s=e.end(e.length-1),i=s),this.beforeSeekableWindow_(e,t)&&(s=e.start(0),i=s+(s===e.end(0)?0:zl)),"undefined"!=typeof i)this.logger_(`Trying to seek outside of seekable at time ${t} with `+`seekable range ${Kl(e)}. Seeking to `+i+".");else{var s=this.playlistController_.sourceUpdater_,e=this.tech_.buffered(),r=s.audioBuffer?s.audioBuffered():null,s=s.videoBuffer?s.videoBuffered():null,n=this.media(),a=n.partTargetDuration||2*(n.targetDuration-Gl),o=[r,s];for(let e=0;e<o.length;e++)if(o[e])if(Vl(o[e],t)<a)return!1;if(0===(n=Hl(e,t)).length)return!1;i=n.start(0)+zl,this.logger_(`Buffered region starts (${n.start(0)}) `+` just beyond seek point (${t}). Seeking to ${i}.`)}return this.tech_.setCurrentTime(i),!0}waiting_(){var e,t;this.techWaiting_()||(e=this.tech_.currentTime(),t=this.tech_.buffered(),(t=jl(t,e)).length&&e+3<=t.end(0)&&(this.resetTimeUpdate_(),this.tech_.setCurrentTime(e),this.logger_(`Stopped at ${e} while inside a buffered region `+`[${t.start(0)} -> ${t.end(0)}]. Attempting to resume `+"playback by seeking to the current time."),this.tech_.trigger({type:"usage",name:"vhs-unknown-waiting"})))}techWaiting_(){var e,t=this.seekable(),i=this.tech_.currentTime();return!!this.tech_.seeking()||(this.beforeSeekableWindow_(t,i)?(t=t.end(t.length-1),this.logger_(`Fell out of live window at time ${i}. Seeking to `+"live point (seekable end) "+t),this.resetTimeUpdate_(),this.tech_.setCurrentTime(t),this.tech_.trigger({type:"usage",name:"vhs-live-resync"}),!0):(t=this.tech_.vhs.playlistController_.sourceUpdater_,e=this.tech_.buffered(),this.videoUnderflow_({audioBuffered:t.audioBuffered(),videoBuffered:t.videoBuffered(),currentTime:i})?(this.resetTimeUpdate_(),this.tech_.setCurrentTime(i),this.tech_.trigger({type:"usage",name:"vhs-video-underflow"}),!0):0<(t=Hl(e,i)).length&&(this.logger_(`Stopped at ${i} and seeking to `+t.start(0)),this.resetTimeUpdate_(),this.skipTheGap_(i),!0)))}afterSeekableWindow_(e,t,i,s=!1){if(!e.length)return!1;let r=e.end(e.length-1)+zl;var n=!i.endList;return t>(r=n&&s?e.end(e.length-1)+3*i.targetDuration:r)}beforeSeekableWindow_(e,t){return!!(e.length&&0<e.start(0)&&t<e.start(0)-this.liveRangeSafeTimeDelta)}videoUnderflow_({videoBuffered:t,audioBuffered:i,currentTime:s}){if(t){let e;var r,n;return t.length&&i.length?(r=jl(t,s-3),n=jl(t,s),(i=jl(i,s)).length&&!n.length&&r.length&&(e={start:r.end(0),end:i.end(0)})):Hl(t,s).length||(e=this.gapFromVideoUnderflow_(t,s)),!!e&&(this.logger_(`Encountered a gap in video from ${e.start} to ${e.end}. `+"Seeking to current time "+s),!0)}}skipTheGap_(e){var t=this.tech_.buffered(),i=this.tech_.currentTime(),t=Hl(t,i);this.resetTimeUpdate_(),0!==t.length&&i===e&&(this.logger_("skipTheGap_:","currentTime:",i,"scheduled currentTime:",e,"nextRange start:",t.start(0)),this.tech_.setCurrentTime(t.start(0)+Gl),this.tech_.trigger({type:"usage",name:"vhs-gap-skip"}))}gapFromVideoUnderflow_(e,t){var i=function(t){if(t.length<2)return Fl();var i=[];for(let e=1;e<t.length;e++){var s=t.end(e-1),r=t.start(e);i.push([s,r])}return Fl(i)}(e);for(let e=0;e<i.length;e++){var s=i.start(e),r=i.end(e);if(t-s<4&&2<t-s)return{start:s,end:r}}return null}}const ku={errorInterval:30,getSource(e){return e(this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource())}},Cu=function(t,e){let i=0,s=0;function r(e){null!=e&&(s=t.duration()!==1/0&&t.currentTime()||0,t.one("loadedmetadata",l),t.src(e),t.trigger({type:"usage",name:"vhs-error-reload"}),t.play())}function n(){if(Date.now()-i<1e3*o.errorInterval)t.trigger({type:"usage",name:"vhs-error-reload-canceled"});else{if(o.getSource&&"function"==typeof o.getSource)return i=Date.now(),o.getSource.call(t,r);T.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!")}}function a(){t.off("loadedmetadata",l),t.off("error",n),t.off("dispose",a)}const o=O(ku,e),l=(t.ready(()=>{t.trigger({type:"usage",name:"vhs-error-reload-initialized"})}),function(){s&&t.currentTime(s)});t.on("error",n),t.on("dispose",a),t.reloadSourceOnError=function(e){a(),Cu(t,e)}};function Iu(t,e){var i=e.media();let s=-1;for(let e=0;e<t.length;e++)if(t[e].id===i.id){s=e;break}t.selectedIndex_=s,t.trigger({selectedIndex:s,type:"change"})}const N={PlaylistLoader:Cd,Playlist:md,utils:Or,STANDARD_PLAYLIST_SELECTOR:Rh,INITIAL_PLAYLIST_SELECTOR:function(){var e=this.playlists.main.playlists.filter(md.isEnabled),e=(Nh(e,(e,t)=>fh(e,t)),e.filter(e=>!!mh(this.playlists.main,e).video));return e[0]||null},lastBandwidthSelector:Rh,movingAverageBandwidthSelector:function(t){let i=-1,s=-1;if(t<0||1<t)throw new Error("Moving average bandwidth decay must be between 0 and 1.");return function(){var e=this.useDevicePixelRatio&&window.devicePixelRatio||1;return i<0&&(i=this.systemBandwidth,s=this.systemBandwidth),0<this.systemBandwidth&&this.systemBandwidth!==s&&(i=t*this.systemBandwidth+(1-t)*i,s=this.systemBandwidth),Mh(this.playlists.main,i,parseInt(gh(this.tech_.el(),"width"),10)*e,parseInt(gh(this.tech_.el(),"height"),10)*e,this.limitRenditionByPlayerDimensions,this.playlistController_)}},comparePlaylistBandwidth:fh,comparePlaylistResolution:function(e,t){let i,s;return i=(i=e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width?e.attributes.RESOLUTION.width:i)||window.Number.MAX_VALUE,s=(s=t.attributes.RESOLUTION&&t.attributes.RESOLUTION.width?t.attributes.RESOLUTION.width:s)||window.Number.MAX_VALUE,i===s&&e.attributes.BANDWIDTH&&t.attributes.BANDWIDTH?e.attributes.BANDWIDTH-t.attributes.BANDWIDTH:i-s},xhr:xd()},xu=(Object.keys(D).forEach(t=>{Object.defineProperty(N,t,{get(){return T.log.warn(`using Vhs.${t} is UNSAFE be sure you know what you are doing`),D[t]},set(e){T.log.warn(`using Vhs.${t} is UNSAFE be sure you know what you are doing`),"number"!=typeof e||e<0?T.log.warn(`value of Vhs.${t} must be greater than or equal to 0`):D[t]=e}})}),"videojs-vhs"),Au=(N.canPlaySource=function(){return T.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")},({player:s,sourceKeySystems:e,audioMedia:t,mainPlaylists:i})=>{if(!s.eme.initializeMediaKeys)return Promise.resolve();var r,t=t?i.concat([t]):i,t=(i=t,r=Object.keys(e),i.reduce((e,s)=>{var t;return s.contentProtection&&(t=r.reduce((e,t)=>{var i=s.contentProtection[t];return i&&i.pssh&&(e[t]={pssh:i.pssh}),e},{}),Object.keys(t).length)&&e.push(t),e},[]));const n=[],a=[];return t.forEach(e=>{a.push(new Promise((e,t)=>{s.tech_.one("keysessioncreated",e)})),n.push(new Promise((t,i)=>{s.eme.initializeMediaKeys({keySystems:e},e=>{e?i(e):t()})}))}),Promise.race([Promise.all(n),Promise.race(a)])}),Pu=({player:e,sourceKeySystems:t,media:i,audioMedia:s})=>{t=((e,t,i)=>{if(!e)return e;let s={};t&&t.attributes&&t.attributes.CODECS&&(s=Lh(Un(t.attributes.CODECS))),i&&i.attributes&&i.attributes.CODECS&&(s.audio=i.attributes.CODECS);var r=Bn(s.video),n=Bn(s.audio),a={};for(const o in e)a[o]={},n&&(a[o].audioContentType=n),r&&(a[o].videoContentType=r),t.contentProtection&&t.contentProtection[o]&&t.contentProtection[o].pssh&&(a[o].pssh=t.contentProtection[o].pssh),"string"==typeof e[o]&&(a[o].url=e[o]);return O(e,a)})(t,i,s);return!(!t||(e.currentSource().keySystems=t)&&!e.eme&&(T.log.warn("DRM encrypted source cannot be decrypted without a DRM plugin"),1))},Lu=()=>{if(!window.localStorage)return null;var e=window.localStorage.getItem(xu);if(!e)return null;try{return JSON.parse(e)}catch(e){return null}};N.supportsNativeHls=function(){if(!document||!document.createElement)return!1;const t=document.createElement("video");return!!T.getTech("Html5").isSupported()&&["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"].some(function(e){return/maybe|probably/i.test(t.canPlayType(e))})}(),N.supportsNativeDash=!!(document&&document.createElement&&T.getTech("Html5").isSupported())&&/maybe|probably/i.test(document.createElement("video").canPlayType("application/dash+xml")),N.supportsTypeNatively=e=>"hls"===e?N.supportsNativeHls:"dash"===e&&N.supportsNativeDash,N.isSupported=function(){return T.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};class Ou extends T.getComponent("Component"){constructor(e,t,i){if(super(t,i.vhs),"number"==typeof i.initialBandwidth&&(this.options_.bandwidth=i.initialBandwidth),this.logger_=Bl("VhsHandler"),t.options_&&t.options_.playerId&&(i=T.getPlayer(t.options_.playerId),this.player_=i),this.tech_=t,this.source_=e,this.stats={},this.ignoreNextSeekingEvent_=!1,this.setOptions_(),this.options_.overrideNative&&t.overrideNativeAudioTracks&&t.overrideNativeVideoTracks)t.overrideNativeAudioTracks(!0),t.overrideNativeVideoTracks(!0);else if(this.options_.overrideNative&&(t.featuresNativeVideoTracks||t.featuresNativeAudioTracks))throw new Error("Overriding native VHS requires emulated tracks. See https://git.io/vMpjB");this.on(document,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],e=>{var t=document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement;t&&t.contains(this.tech_.el())?this.playlistController_.fastQualityChange_():this.playlistController_.checkABR_()}),this.on(this.tech_,"seeking",function(){this.ignoreNextSeekingEvent_?this.ignoreNextSeekingEvent_=!1:this.setCurrentTime(this.tech_.currentTime())}),this.on(this.tech_,"error",function(){this.tech_.error()&&this.playlistController_&&this.playlistController_.pauseLoading()}),this.on(this.tech_,"play",this.play)}setOptions_(){var e;this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.limitRenditionByPlayerDimensions=!1!==this.options_.limitRenditionByPlayerDimensions,this.options_.useDevicePixelRatio=this.options_.useDevicePixelRatio||!1,this.options_.useBandwidthFromLocalStorage="undefined"!=typeof this.source_.useBandwidthFromLocalStorage?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.useNetworkInformationApi=this.options_.useNetworkInformationApi||!1,this.options_.useDtsForTimestampOffset=this.options_.useDtsForTimestampOffset||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,this.options_.llhls=!1!==this.options_.llhls,this.options_.bufferBasedABR=this.options_.bufferBasedABR||!1,"number"!=typeof this.options_.playlistExclusionDuration&&(this.options_.playlistExclusionDuration=300),"number"!=typeof this.options_.bandwidth&&this.options_.useBandwidthFromLocalStorage&&((e=Lu())&&e.bandwidth&&(this.options_.bandwidth=e.bandwidth,this.tech_.trigger({type:"usage",name:"vhs-bandwidth-from-local-storage"})),e)&&e.throughput&&(this.options_.throughput=e.throughput,this.tech_.trigger({type:"usage",name:"vhs-throughput-from-local-storage"})),"number"!=typeof this.options_.bandwidth&&(this.options_.bandwidth=D.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===D.INITIAL_BANDWIDTH,["withCredentials","useDevicePixelRatio","limitRenditionByPlayerDimensions","bandwidth","customTagParsers","customTagMappers","cacheEncryptionKeys","playlistSelector","initialPlaylistSelector","bufferBasedABR","liveRangeSafeTimeDelta","llhls","useNetworkInformationApi","useDtsForTimestampOffset","exactManifestTimings","leastPixelDiffSelector"].forEach(e=>{"undefined"!=typeof this.source_[e]&&(this.options_[e]=this.source_[e])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio}src(e,t){e&&(this.setOptions_(),this.options_.src=0===(e=this.source_.src).toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")?JSON.parse(e.substring(e.indexOf(",")+1)):e,this.options_.tech=this.tech_,this.options_.externVhs=N,this.options_.sourceType=An(t),this.options_.seekTo=e=>{this.tech_.setCurrentTime(e)},this.playlistController_=new Tu(this.options_),e=O({liveRangeSafeTimeDelta:zl},this.options_,{seekable:()=>this.seekable(),media:()=>this.playlistController_.media(),playlistController:this.playlistController_}),this.playbackWatcher_=new Eu(e),this.playlistController_.on("error",()=>{var e=T.players[this.tech_.options_.playerId];let t=this.playlistController_.error;"object"!=typeof t||t.code?"string"==typeof t&&(t={message:t,code:3}):t.code=3,e.error(t)}),t=this.options_.bufferBasedABR?N.movingAverageBandwidthSelector(.55):N.STANDARD_PLAYLIST_SELECTOR,this.playlistController_.selectPlaylist=(this.selectPlaylist||t).bind(this),this.playlistController_.selectInitialPlaylist=N.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.playlistController_.mainPlaylistLoader_,this.mediaSource=this.playlistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get(){return this.playlistController_.selectPlaylist},set(e){this.playlistController_.selectPlaylist=e.bind(this)}},throughput:{get(){return this.playlistController_.mainSegmentLoader_.throughput.rate},set(e){this.playlistController_.mainSegmentLoader_.throughput.rate=e,this.playlistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get(){let e=this.playlistController_.mainSegmentLoader_.bandwidth;var t=window.navigator.connection||window.navigator.mozConnection||window.navigator.webkitConnection;return this.options_.useNetworkInformationApi&&t&&(t=1e3*t.downlink*1e3,e=1e7<=t&&1e7<=e?Math.max(e,t):t),e},set(e){this.playlistController_.mainSegmentLoader_.bandwidth=e,this.playlistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get(){var e=1/(this.bandwidth||1);let t;return t=0<this.throughput?1/this.throughput:0,Math.floor(1/(e+t))},set(){T.log.error('The "systemBandwidth" property is read-only')}}}),this.options_.bandwidth&&(this.bandwidth=this.options_.bandwidth),this.options_.throughput&&(this.throughput=this.options_.throughput),Object.defineProperties(this.stats,{bandwidth:{get:()=>this.bandwidth||0,enumerable:!0},mediaRequests:{get:()=>this.playlistController_.mediaRequests_()||0,enumerable:!0},mediaRequestsAborted:{get:()=>this.playlistController_.mediaRequestsAborted_()||0,enumerable:!0},mediaRequestsTimedout:{get:()=>this.playlistController_.mediaRequestsTimedout_()||0,enumerable:!0},mediaRequestsErrored:{get:()=>this.playlistController_.mediaRequestsErrored_()||0,enumerable:!0},mediaTransferDuration:{get:()=>this.playlistController_.mediaTransferDuration_()||0,enumerable:!0},mediaBytesTransferred:{get:()=>this.playlistController_.mediaBytesTransferred_()||0,enumerable:!0},mediaSecondsLoaded:{get:()=>this.playlistController_.mediaSecondsLoaded_()||0,enumerable:!0},mediaAppends:{get:()=>this.playlistController_.mediaAppends_()||0,enumerable:!0},mainAppendsToLoadedData:{get:()=>this.playlistController_.mainAppendsToLoadedData_()||0,enumerable:!0},audioAppendsToLoadedData:{get:()=>this.playlistController_.audioAppendsToLoadedData_()||0,enumerable:!0},appendsToLoadedData:{get:()=>this.playlistController_.appendsToLoadedData_()||0,enumerable:!0},timeToLoadedData:{get:()=>this.playlistController_.timeToLoadedData_()||0,enumerable:!0},buffered:{get:()=>Yl(this.tech_.buffered()),enumerable:!0},currentTime:{get:()=>this.tech_.currentTime(),enumerable:!0},currentSource:{get:()=>this.tech_.currentSource_,enumerable:!0},currentTech:{get:()=>this.tech_.name_,enumerable:!0},duration:{get:()=>this.tech_.duration(),enumerable:!0},main:{get:()=>this.playlists.main,enumerable:!0},playerDimensions:{get:()=>this.tech_.currentDimensions(),enumerable:!0},seekable:{get:()=>Yl(this.tech_.seekable()),enumerable:!0},timestamp:{get:()=>Date.now(),enumerable:!0},videoPlaybackQuality:{get:()=>this.tech_.getVideoPlaybackQuality(),enumerable:!0}}),this.tech_.one("canplay",this.playlistController_.setupFirstPlay.bind(this.playlistController_)),this.tech_.on("bandwidthupdate",()=>{if(this.options_.useBandwidthFromLocalStorage){var e={bandwidth:this.bandwidth,throughput:Math.round(this.throughput)};if(window.localStorage){var t=(t=Lu())?O(t,e):e;try{window.localStorage.setItem(xu,JSON.stringify(t))}catch(e){return}}}}),this.playlistController_.on("selectedinitialmedia",()=>{var i;(i=this).representations=()=>{var e=i.playlistController_.main(),e=pd(e)?i.playlistController_.getAudioTrackPlaylists_():e.playlists;return e?e.filter(e=>!od(e)).map((e,t)=>new Su(i,e,e.id)):[]}}),this.playlistController_.sourceUpdater_.on("createdsourcebuffers",()=>{this.setupEme_()}),this.on(this.playlistController_,"progress",function(){this.tech_.trigger("progress")}),this.on(this.playlistController_,"firstplay",function(){this.ignoreNextSeekingEvent_=!0}),this.setupQualityLevels_(),this.tech_.el())&&(this.mediaSourceUrl_=window.URL.createObjectURL(this.playlistController_.mediaSource),this.tech_.src(this.mediaSourceUrl_))}createKeySessions_(){var e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader;this.logger_("waiting for EME key session creation"),Au({player:this.player_,sourceKeySystems:this.source_.keySystems,audioMedia:e&&e.media(),mainPlaylists:this.playlists.main.playlists}).then(()=>{this.logger_("created EME key session"),this.playlistController_.sourceUpdater_.initializedEme()}).catch(e=>{this.logger_("error while creating EME key session",e),this.player_.error({message:"Failed to initialize media keys for EME",code:3})})}handleWaitingForKey_(){this.logger_("waitingforkey fired, attempting to create any new key sessions"),this.createKeySessions_()}setupEme_(){var e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader,e=Pu({player:this.player_,sourceKeySystems:this.source_.keySystems,media:this.playlists.media(),audioMedia:e&&e.media()});this.player_.tech_.on("keystatuschange",e=>{if("output-restricted"===e.status){e=this.playlistController_.main();if(e&&e.playlists){const t=[];
3814e.playlists.forEach(e=>{e&&e.attributes&&e.attributes.RESOLUTION&&720<=e.attributes.RESOLUTION.height&&(!e.excludeUntil||e.excludeUntil<1/0)&&(e.excludeUntil=1/0,t.push(e))}),t.length&&(T.log.warn('DRM keystatus changed to "output-restricted." Removing the following HD playlists that will most likely fail to play and clearing the buffer. This may be due to HDCP restrictions on the stream and the capabilities of the current device.',...t),this.playlistController_.fastQualityChange_())}}}),this.handleWaitingForKey_=this.handleWaitingForKey_.bind(this),this.player_.tech_.on("waitingforkey",this.handleWaitingForKey_),11!==T.browser.IE_VERSION&&e?this.createKeySessions_():this.playlistController_.sourceUpdater_.initializedEme()}setupQualityLevels_(){var e=T.players[this.tech_.options_.playerId];e&&e.qualityLevels&&!this.qualityLevels_&&(this.qualityLevels_=e.qualityLevels(),this.playlistController_.on("selectedinitialmedia",()=>{var t,e;t=this.qualityLevels_,(e=this).representations().forEach(e=>{t.addQualityLevel(e)}),Iu(t,e.playlists)}),this.playlists.on("mediachange",()=>{Iu(this.qualityLevels_,this.playlists)}))}static version(){return{"@videojs/http-streaming":"3.0.2","mux.js":"6.3.0","mpd-parser":"1.0.1","m3u8-parser":"6.0.0","aes-decrypter":"4.0.1"}}version(){return this.constructor.version()}canChangeType(){return iu.canChangeType()}play(){this.playlistController_.play()}setCurrentTime(e){this.playlistController_.setCurrentTime(e)}duration(){return this.playlistController_.duration()}seekable(){return this.playlistController_.seekable()}dispose(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.playlistController_&&this.playlistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.tech_&&this.tech_.vhs&&delete this.tech_.vhs,this.mediaSourceUrl_&&window.URL.revokeObjectURL&&(window.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),this.tech_&&this.tech_.off("waitingforkey",this.handleWaitingForKey_),super.dispose()}convertToProgramTime(e,t){return Fd({playlist:this.playlistController_.media(),time:e,callback:t})}seekToProgramTime(e,t,i=!0,s=2){return jd({programTime:e,playlist:this.playlistController_.media(),retryCount:s,pauseAfterSeek:i,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:t})}}const Du={name:"videojs-http-streaming",VERSION:"3.0.2",canHandleSource(e,t={}){t=O(T.options,t);return Du.canPlayType(e.type,t)},handleSource(e,t,i={}){i=O(T.options,i);return t.vhs=new Ou(e,t,i),t.vhs.xhr=xd(),t.vhs.src(e.src,e.type),t.vhs},canPlayType(e,t){e=An(e);return e&&(t=Du.getOverrideNative(t),!N.supportsTypeNatively(e)||t)?"maybe":""},getOverrideNative(e={}){var{vhs:e={}}=e,t=!(T.browser.IS_ANY_SAFARI||T.browser.IS_IOS),{overrideNative:e=t}=e;return e}};return In("avc1.4d400d,mp4a.40.2")&&T.getTech("Html5").registerSourceHandler(Du,0),T.VhsHandler=Ou,T.VhsSourceHandler=Du,T.Vhs=N,T.use||T.registerComponent("Vhs",N),T.options.vhs=T.options.vhs||{},T.getPlugin&&T.getPlugin("reloadSourceOnError")||T.registerPlugin("reloadSourceOnError",function(e){Cu(this,e)}),T}); 3815console.log('video-streaming.js is running...'); 3816 3817let videojsEls = document.querySelectorAll('[data-videojs-videoelement]'); 3818 3819if (videojsEls) { 3820 for (let i = 0; i < videojsEls.length; i++) { 3821 let elVideojsAutoplayVal = videojsEls[i].getAttribute('data-videojs-autoplay'); 3822 let createdElVideojsID = "videojs-video-" + (parseInt(i) + 1); 3823 videojsEls[i].setAttribute('id', createdElVideojsID); 3824 3825 3826 let player = videojs(createdElVideojsID, { 3827 fluid: true 3828 }); 3829 3830 3831 if (elVideojsAutoplayVal) { 3832 player.autoplay(elVideojsAutoplayVal); 3833 } 3834 } 3835} 3836 3837let lang_page_link1Elem = document.querySelector('#lang_page_link1'); 3838let lang_page_title1Elem = document.querySelector('#lang_page_title1'); 3839let m_lang_page_link1Elem = document.querySelector('#lang_page_m_link1'); 3840let m_lang_page_title1Elem = document.querySelector('#lang_page_m_title1'); 3841let m_lang_logo_elem = document.querySelector('#lang_logo_link1'); 3842let m_lang_logo_elem1 = document.querySelector('#lang_logo_link2'); 3843 3844 3845let d_careers_link = document.querySelector('#d_careers_link'); 3846let m_careers_link = document.querySelector('#m_careers_link'); 3847 3848if(lang_page_link1Elem){
3849 let currUrl = window.location.pathname; 3850 /*if(currUrl.indexOf('/us/en/')>-1){ 3851 let lanUrl = currUrl.replace('/us/en/', '/us/es/'); 3852 lang_page_link1Elem.text = 'Spanish'; 3853 lang_page_link1Elem.href = lanUrl; 3854 lang_page_title1Elem.innerHTML = 'English'; 3855 3856 m_lang_page_link1Elem.text = 'Spanish'; 3857 m_lang_page_link1Elem.href = lanUrl; 3858 m_lang_page_title1Elem.innerHTML = 'English'; 3859 } else if(currUrl.indexOf('/us/es/')>-1){ 3860 let lanUrl = currUrl.replace('/us/es/', '/us/en/'); 3861 lang_page_link1Elem.text = 'English'; 3862 lang_page_link1Elem.href = lanUrl; 3863 lang_page_title1Elem.innerHTML = 'Spanish'; 3864 3865 m_lang_page_link1Elem.text = 'English'; 3866 m_lang_page_link1Elem.href = lanUrl; 3867 m_lang_page_title1Elem.innerHTML = 'Spanish'; 3868 }*/ 3869 3870 if(currUrl.indexOf('/es/')>-1 || currUrl.indexOf('/es.html')>-1 || currUrl.indexOf('/es')>-1){ 3871 let lanUrl = currUrl.replace('/es/', '/'); 3872 lanUrl = lanUrl.replace('/es.html', '/'); 3873 lang_page_link1Elem.text = 'English'; 3874 lang_page_link1Elem.href = lanUrl; 3875 lang_page_title1Elem.innerHTML = 'Spanish'; 3876 3877 m_lang_page_link1Elem.text = 'English'; 3878 m_lang_page_link1Elem.href = lanUrl; 3879 m_lang_page_title1Elem.innerHTML = 'Spanish'; 3880 m_lang_logo_elem.href = "/es/"; 3881 m_lang_logo_elem1.href = "/es/"; 3882 3883 3884 let career_url = d_careers_link ? d_careers_link.href : ""; 3885 3886 if(career_url){ 3887 d_careers_link.href = career_url.replace("/about/careers.html", "/es/about/careers.html"); 3888 m_careers_link.href = career_url.replace("/about/careers.html", "/es/about/careers.html"); 3889 } 3890 3891 } else{ 3892 let lanUrl = '/es' + currUrl 3893 lang_page_link1Elem.text = 'Spanish'; 3894 lang_page_link1Elem.href = lanUrl; 3895 lang_page_title1Elem.innerHTML = 'English'; 3896 3897 m_lang_page_link1Elem.text = 'Spanish'; 3898 m_lang_page_link1Elem.href = lanUrl; 3899 m_lang_page_title1Elem.innerHTML = 'English'; 3900 m_lang_logo_elem.href = "/"; 3901 m_lang_logo_elem1.href = "/"; 3902 } 3903 3904} 3905 3906// let svgImages = document.querySelectorAll('svg defs'); 3907 3908// if (svgImages) { 3909// for (let i = 0; i < svgImages.length; i++) { 3910// let defsElem = svgImages[i]; 3911// //console.log(styleElem); 3912// defsElem.remove(); 3913// } 3914// } 3915 3916//This finds all svgs and makes them accessible for accessibility devices 3917 3918let svgImages = document.querySelectorAll('svg'); 3919 3920if (svgImages) { 3921 for (let i = 0; i < svgImages.length; i++) { 3922 let defsElem = svgImages[i]; 3923 //console.log(styleElem); 3924 // defsElem.remove(); 3925 // && !defsElem.parentNode.classList.contains('decorative') 3926 if (defsElem.parentNode.nodeName.toLowerCase() !== "a") { 3927 //defsElem.setAttribute("role", "img"); 3928 3929 let altattribute = defsElem.getAttribute('alt'); 3930 let arialabel = defsElem.getAttribute('aria-label'); 3931 3932 if ((!altattribute || altattribute.length == 0) && (!arialabel || arialabel.length == 0)) { 3933 defsElem.setAttribute("aria-hidden", "true"); 3934 } 3935 else { 3936 if ((altattribute && altattribute.length > 0) || (arialabel && arialabel.length > 0)) { 3937 if (altattribute && altattribute.length > 0) { 3938 defsElem.setAttribute("aria-label", altattribute); 3939 } 3940 else { 3941 defsElem.setAttribute("aria-label", arialabel); 3942 } 3943 } 3944 else { 3945 defsElem.setAttribute("aria-label", "graphic"); 3946 } 3947 } 3948 } 3949 else { 3950 defsElem.setAttribute("aria-hidden", "true"); 3951 } 3952 } 3953} 3954//*-------- Navigating from header search section to Search Results Page ----------*/ 3955function handleSearch(event){ 3956 event.preventDefault(); 3957 let searchInputEle = document.getElementById("searchTextForm"); 3958 let searchInputErrorEle = document.getElementById("searchTextForm-error"); 3959 3960 if(searchInputEle){ 3961 let searchTermDesktop = searchInputEle.querySelector('#mm-search-input-desk').value; 3962 searchTermDesktop = searchTermDesktop.replaceAll('#', ''); 3963 window.location = "/search-results.html?text=" + searchTermDesktop + "&skip=0&top=50"; 3964 } 3965 if(searchInputErrorEle){ 3966 let searchTermErrorDesktop = searchInputErrorEle.querySelector('#mm-search-input-desk-error').value; 3967 searchTermErrorDesktop = searchTermErrorDesktop.replaceAll('#', ''); 3968 window.location = "/search-results.html?text=" + searchTermErrorDesktop + "&skip=0&top=50"; 3969 } 3970} 3971 3972function handleSearchMobile(event){ 3973 event.preventDefault(); 3974 let searchInputEle = document.getElementById("searchTextForm-mob"); 3975 let searchInputErrorEle = document.getElementById("searchTextForm-error-mob"); 3976 3977 if(searchInputEle){ 3978 let searchTermMobile = searchInputEle.querySelector('#mm-search-input-mob').value; 3979 searchTermMobile = searchTermMobile.replaceAll('#', ''); 3980 window.location = "/search-results.html?text=" + searchTermMobile + "&skip=0&top=50"; 3981 3982 } 3983 if(searchInputErrorEle){ 3984 let searchTermErrorMobile = searchInputErrorEle.querySelector('#mm-search-input-error-mob').value; 3985 searchTermErrorMobile = searchTermErrorMobile.replaceAll('#', ''); 3986 window.location = "/search-results.html?text=" + searchTermErrorMobile + "&skip=0&top=50"; 3987 } 3988} 3989 3990let searchButtonElem = document.getElementById("searchTextForm"); 3991let searchButtonMobileElem = document.getElementById("searchTextForm-mob"); 3992 3993let searchButtonErrorElem = document.getElementById("searchTextForm-error"); 3994let searchButtonMobileErrorElem = document.getElementById("searchTextForm-error-mob"); 3995 3996if(searchButtonElem || searchButtonMobileElem){ 3997 searchButtonElem.addEventListener("submit", handleSearch, false); 3998 searchButtonMobileElem.addEventListener("submit", handleSearchMobile, false); 3999} 4000 4001if(searchButtonErrorElem || searchButtonMobileErrorElem){ 4002 searchButtonErrorElem.addEventListener("submit", handleSearch, false); 4003 searchButtonMobileErrorElem.addEventListener("submit", handleSearchMobile, false); 4004} 4005 4006/*-------- Building html based on the servlet response ----------*/ 4007 4008function getSiteName(){ 4009 let siteName = "txdot";
4010 let currePath = window.location.pathname; 4011 let validateCurrePath = currePath.indexOf('/txdotreimagine'); 4012 if(validateCurrePath==8){ 4013 return siteName; 4014 } 4015 currePath = currePath.replace("/content/project/us/en", ""); 4016 currePath = currePath.replace(".html", ""); 4017 if(currePath == '/search-results'){ 4018 return siteName; 4019 } 4020 let pathArr = currePath.split("/"); 4021 if(pathArr && pathArr.length>1){ 4022 siteName = pathArr[1]; 4023 } 4024 return siteName; 4025} 4026 4027function getUrlVars() { 4028 var vars = [], hash; 4029 var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); 4030 for(var i = 0; i < hashes.length; i++) 4031 { 4032 hash = hashes[i].split('='); 4033 vars.push(hash[0]); 4034 vars[hash[0]] = hash[1]; 4035 } 4036 return vars; 4037} 4038 4039/******************* 4040 ** ACCORDION - VANILLA JS ** 4041 *******************/ 4042// console.log("Accordion JS running..."); 4043 4044let accordionTimeoutSmallDelay = 25; 4045let accordionAnimationSpeed = 300; 4046 4047// ADD ACTIVE CLASS TO BUBBLED UP PARENT ELEMENT IF aria-expanded="true" and parent doesn't have active class already 4048let accordionExpandedElem = document.querySelectorAll(".accord [aria-expanded=\"true\"]"); 4049 4050for (let i = 0; i < accordionExpandedElem.length; i++) { 4051 if (!accordionExpandedElem[i].closest(".accord-container").classList.contains("active")) { 4052 accordionExpandedElem[i].closest(".accord-container").classList.add("opened", "acc-p-bottom", "active"); 4053 } 4054} 4055 4056///////////////////////// 4057// ACCORDION FUNCTION 4058//////////////// 4059 4060function initAccordion(e) { 4061 if (!e) { 4062 e = window["event"]; 4063 } 4064 4065 e.preventDefault(); 4066 4067 let bubbedUpAccordionGroupedElem = e.target.closest(".accord-grouped"); 4068 let bubbedUpAccordContainer = e.target.closest(".accord-container"); 4069 4070 if (!bubbedUpAccordContainer.classList.contains("active")) { 4071 4072 if (bubbedUpAccordionGroupedElem) { 4073 let elementList = bubbedUpAccordionGroupedElem.querySelectorAll(".accord-container"); 4074 Array.prototype.forEach.call(elementList, function (e) { 4075 e.classList.remove("opened"); 4076 e.classList.remove("acc-p-bottom"); 4077 e.classList.remove("active"); 4078 }); 4079 } 4080 4081 // set aria expanded to true 4082 e.target.setAttribute("aria-expanded", "true"); 4083 4084 // Add 'opened' class 4085 bubbedUpAccordContainer.classList.add("opened"); 4086 4087 // add class for padding bottom animation 4088 bubbedUpAccordContainer.classList.add("acc-p-bottom"); 4089 4090 // after small delay add class for animating 4091 setTimeout(function () { 4092 bubbedUpAccordContainer.classList.add("active"); 4093 }, accordionTimeoutSmallDelay); 4094 4095 } 4096 else { 4097 4098 // set aria expanded to false 4099 e.target.setAttribute("aria-expanded", "false"); 4100 4101 // remove 'active' class 4102 bubbedUpAccordContainer.classList.remove("active"); 4103 4104 // small delay to remove padding bottom class 4105 setTimeout(function () { 4106 bubbedUpAccordContainer.classList.remove("acc-p-bottom"); 4107 }, accordionAnimationSpeed / 12); 4108 4109 // At the end of animation remove display block class 4110 setTimeout(function () { 4111 bubbedUpAccordContainer.classList.remove("opened"); 4112 }, accordionAnimationSpeed); 4113 4114 } 4115 4116 // Check if all are opened or closed to enable/disable Show/Hide All buttons. 4117 // Using aria attributes because they're more reliable than CSS classes here. 4118 // - Lina 4119 let accordContainers = document.getElementsByClassName("accord-container").length; 4120 let accordContainersOpened = document.querySelectorAll("[aria-expanded='true']").length; 4121 let showButton = document.getElementById("accordions-all-show"); 4122 let hideButton = document.getElementById("accordions-all-hide"); 4123 4124 if (accordContainersOpened === 0) { 4125 if (showButton) { 4126 showButton.classList.remove("disabled"); 4127 showButton.setAttribute("aria-disabled", "false"); 4128 } 4129 if (hideButton) { 4130 hideButton.classList.add("disabled"); 4131 hideButton.setAttribute("aria-disabled", "true"); 4132 } 4133 }
4134 else if (accordContainersOpened === accordContainers) { 4135 if (showButton) { 4136 showButton.classList.add("disabled"); 4137 showButton.setAttribute("aria-disabled", "true"); 4138 } 4139 if (hideButton) { 4140 hideButton.classList.remove("disabled"); 4141 hideButton.setAttribute("aria-disabled", "false"); 4142 } 4143 } 4144 else { 4145 if (showButton) { 4146 showButton.classList.remove("disabled"); 4147 showButton.setAttribute("aria-disabled", "false"); 4148 } 4149 if (hideButton) { 4150 hideButton.classList.remove("disabled"); 4151 hideButton.setAttribute("aria-disabled", "false"); 4152 } 4153 } 4154} 4155 4156/////////////////////////// 4157// Show/hide all accordions 4158/////////////////// 4159 4160function showAllAccordions() { 4161 //console.log('showAllAccordions clicked'); 4162 4163 let accordBtn1 = document.querySelectorAll(".accord-btn"); 4164 for (let i = 0; i < accordBtn1.length; i++) { 4165 let accordionButton1 = accordBtn1[i]; 4166 4167 // set aria expanded to true 4168 accordionButton1.setAttribute("aria-expanded", "true"); 4169 4170 // add display block class 4171 accordionButton1.closest(".accord-container").classList.add("opened"); 4172 4173 // add padding bottom class 4174 accordionButton1.closest(".accord-container").classList.add("acc-p-bottom"); 4175 4176 // setTimeout function can't go inside for loops so we run it here and define it outside of loop 4177 delayAccordShowAllHideRemoveClasses(i); 4178 } 4179 4180 function delayAccordShowAllHideRemoveClasses(i) { 4181 setTimeout(function () { 4182 accordBtn1[i].closest(".accord-container").classList.add("active"); 4183 }, accordionTimeoutSmallDelay); 4184 // Added accordionTimeoutSmallDelay to add active after opened class was added - This also fixed the accordion 4185 // instant open from sometimes occurring. 4186 } 4187 4188 // Set show button to disabled and hide button to enabled. 4189 let showButton = document.getElementById("accordions-all-show"); 4190 let hideButton = document.getElementById("accordions-all-hide"); 4191 showButton.classList.add("disabled"); 4192 showButton.setAttribute("aria-disabled", "true"); 4193 hideButton.classList.remove("disabled"); 4194 hideButton.setAttribute("aria-disabled", "false"); 4195} 4196 4197function hideAllAccordions() { 4198 //console.log('hideAllAccordions clicked'); 4199 4200 let accordBtn2 = document.querySelectorAll(".accord-btn"); 4201 4202 for (let i = 0; i < accordBtn2.length; i++) { 4203 let accordionButton2 = accordBtn2[i]; 4204 4205 // set aria expanded to false 4206 accordionButton2.setAttribute("aria-expanded", "false"); 4207 4208 // add 'closing' class 4209 accordionButton2.closest(".accord-container").classList.remove("active"); 4210 4211 // setTimeout function can't go inside for loops so we run it here and define it outside of loop 4212 delayAccordHideAllHideRemoveClasses(i); 4213 } 4214 4215 function delayAccordHideAllHideRemoveClasses(i) { 4216 setTimeout(function () { 4217 accordBtn2[i].closest(".accord-container").classList.remove("opened"); 4218 }, accordionAnimationSpeed); 4219 4220 setTimeout(function () { 4221 accordBtn2[i].closest(".accord-container").classList.remove("acc-p-bottom"); 4222 }, accordionAnimationSpeed / 12); 4223 } 4224 4225 // Set show button to enabled and hide button to disabled. 4226 let showButton = document.getElementById("accordions-all-show"); 4227 let hideButton = document.getElementById("accordions-all-hide"); 4228 showButton.classList.remove("disabled"); 4229 showButton.setAttribute("aria-disabled", "false"); 4230 hideButton.classList.add("disabled"); 4231 hideButton.setAttribute("aria-disabled", "true"); 4232} 4233 4234// add event listeners 4235 4236let showAccordionsAll = document.getElementById("accordions-all-show"); 4237// check if element is on the page 4238if (showAccordionsAll != null) { 4239 showAccordionsAll.addEventListener("click", showAllAccordions); 4240} 4241 4242let hideAccordionsAll = document.getElementById("accordions-all-hide"); 4243// check if element is on the page 4244if (hideAccordionsAll != null) { 4245 hideAccordionsAll.addEventListener("click", hideAllAccordions); 4246} 4247 4248// for loop for addEventListener accordion on click specific class 4249let accordClasses = document.getElementsByClassName("accord-btn"); 4250for (let i = 0; i < accordClasses.length; i++) { 4251 accordClasses[i].addEventListener("click", initAccordion); 4252} 4253/******************* 4254 ** ACC - VANILLA JS ** 4255 *******************/ 4256 4257// This file affects Header and accordion components 4258
4259//////////////////////// 4260// SHIFT FOCUS WHEN SEARCH ICON IS CLICKED 4261// (Runs before accordions to detect active classes) 4262///////////////// 4263 4264let dataSearchInputFocusElem = document.querySelectorAll('[data-search-input-focus]'); 4265 4266function searchIconClickedOn(theThis) { 4267 // Delay before focusing input 4268 let delayTime = 5; 4269 let panelOpenExtraDelayTime = 0; 4270 4271 // Get accordion group name from clicked icon 4272 let buttonDataAccGroup = theThis.currentTarget.getAttribute('data-acc-group'); 4273 4274 // Get all elements in that group 4275 let allMatchingDataAccGroups = document.querySelectorAll(`[data-acc-group="${buttonDataAccGroup}"]`); 4276 4277 // Count how many are currently active/open 4278 let countActiveClasses = 0; 4279 allMatchingDataAccGroups.forEach(element => { 4280 if (element.classList.contains('acc-active')) { 4281 countActiveClasses++; 4282 } 4283 }); 4284 4285 // If any panel is open, add extra delay to allow closing animation 4286 if (countActiveClasses > 0) { 4287 panelOpenExtraDelayTime += 370; 4288 } 4289 4290 // After delay, focus the matching search input 4291 setTimeout(() => { 4292 dataSearchInputFocusElem.forEach(element => { 4293 let searchIconAttributeValue = element.getAttribute('data-search-input-focus'); 4294 document.querySelector(`#mm-search-input-${searchIconAttributeValue}`).focus(); 4295 }); 4296 }, (panelOpenExtraDelayTime + delayTime)); 4297} 4298 4299// Attach click listeners to all search-focus elements 4300for (let i = 0; i < dataSearchInputFocusElem.length; i++) { 4301 dataSearchInputFocusElem[i].addEventListener("click", searchIconClickedOn); 4302} 4303 4304 4305 4306//////////////////////// 4307// ACCORDIONS 4308///////////////// 4309 4310let delayForFinishedCSSanimation = 250; 4311let allAccTypesBtns = document.querySelectorAll("[data-bandoneon-btn],[data-melodeon-btn],[data-concertina-btn]"); 4312let doubleClickingAcc = false; 4313 4314// Initialize accordion containers (enable/disable show/hide buttons) 4315function initAcc() { 4316 let accContainers = document.querySelectorAll(".acc-container"); 4317 4318 accContainers.forEach(accContainer => { 4319 let bellows; 4320 4321 // Determine accordion type by checking which data attribute exists 4322 if (accContainer.querySelectorAll("[data-melodeon-btn]").length != 0) { 4323 bellows = accContainer.querySelectorAll("[data-melodeon-btn]").length; 4324 } else if (accContainer.querySelectorAll("[data-bandoneon-btn]").length != 0) { 4325 bellows = accContainer.querySelectorAll("[data-bandoneon-btn]").length; 4326 } else if (accContainer.querySelectorAll("[data-concertina-btn]").length != 0) { 4327 bellows = accContainer.querySelectorAll("[data-concertina-btn]").length; 4328 } 4329 4330 // Count how many are open 4331 let bellowsOpened = accContainer.querySelectorAll("[aria-expanded='true']").length; 4332 4333 let showButton = accContainer.querySelector(".accs-all-show"); 4334 let hideButton = accContainer.querySelector(".accs-all-hide"); 4335 4336 // Enable/disable show/hide buttons based on open count 4337 if (!bellowsOpened) { 4338 // None open â enable "show all", disable "hide all" 4339 if (showButton) { 4340 showButton.classList.remove("disabled"); 4341 showButton.setAttribute("aria-disabled", "false"); 4342 showButton.removeAttribute("disabled"); 4343 } 4344 if (hideButton) { 4345 hideButton.classList.add("disabled"); 4346 hideButton.setAttribute("aria-disabled", "true"); 4347 hideButton.setAttribute("disabled", ""); 4348 } 4349 } 4350 else if (bellowsOpened === bellows) { 4351 // All open â disable "show all", enable "hide all" 4352 if (showButton) { 4353 showButton.classList.add("disabled"); 4354 showButton.setAttribute("aria-disabled", "true"); 4355 showButton.setAttribute("disabled", ""); 4356 } 4357 if (hideButton) { 4358 hideButton.classList.remove("disabled"); 4359 hideButton.setAttribute("aria-disabled", "false"); 4360 hideButton.removeAttribute("disabled"); 4361 } 4362 } 4363 else { 4364 // Some open â enable both 4365 if (showButton) { 4366 showButton.classList.remove("disabled"); 4367 showButton.setAttribute("aria-disabled", "false"); 4368 showButton.removeAttribute("disabled"); 4369 } 4370 if (hideButton) { 4371 hideButton.classList.remove("disabled"); 4372 hideButton.setAttribute("aria-disabled", "false"); 4373 hideButton.removeAttribute("disabled"); 4374 } 4375 } 4376 }) 4377} 4378 4379initAcc(); 4380 4381 4382 4383/////////////////////////// 4384// Show all accordions
4385/////////////////// 4386 4387function showAllAccs(e) { 4388 let accordBtn1 = e.currentTarget.closest('.acc-container').querySelectorAll(".accord-btn"); 4389 4390 // Loop through all accordion buttons and open them 4391 for (let i = 0; i < accordBtn1.length; i++) { 4392 let accordionButton1 = accordBtn1[i]; 4393 4394 // Mark as expanded 4395 accordionButton1.setAttribute("aria-expanded", "true"); 4396 accordionButton1.setAttribute("aria-selected", "true"); 4397 4398 // Add open classes 4399 accordionButton1.closest(".accord-container").classList.add("opened"); 4400 accordionButton1.closest(".accord-container").classList.add("acc-p-bottom"); 4401 4402 // Delay adding "active" class for animation timing 4403 delayAccordShowAllHideRemoveClasses(i); 4404 } 4405 4406 function delayAccordShowAllHideRemoveClasses(i) { 4407 setTimeout(function () { 4408 accordBtn1[i].closest(".accord-container").classList.add("active"); 4409 }, accordionTimeoutSmallDelay); 4410 } 4411 4412 // Update show/hide button states 4413 let showButton = e.currentTarget.parentElement.querySelector(".accs-all-show"); 4414 let hideButton = e.currentTarget.parentElement.querySelector(".accs-all-hide"); 4415 4416 showButton.classList.add("disabled"); 4417 showButton.setAttribute("aria-disabled", "true"); 4418 showButton.setAttribute("disabled", ""); 4419 4420 hideButton.classList.remove("disabled"); 4421 hideButton.setAttribute("aria-disabled", "false"); 4422 hideButton.removeAttribute("disabled"); 4423} 4424 4425 4426 4427/////////////////////////// 4428// Hide all accordions 4429/////////////////// 4430 4431function hideAllAccs(e) { 4432 let accordBtn2 = e.currentTarget.closest('.acc-container').querySelectorAll(".accord-btn"); 4433 4434 // Loop through all accordion buttons and close them 4435 for (let i = 0; i < accordBtn2.length; i++) { 4436 let accordionButton2 = accordBtn2[i]; 4437 4438 accordionButton2.setAttribute("aria-expanded", "false"); 4439 accordionButton2.setAttribute("aria-selected", "false"); 4440 4441 accordionButton2.closest(".accord-container").classList.remove("active"); 4442 4443 delayAccordHideAllHideRemoveClasses(i); 4444 } 4445 4446 function delayAccordHideAllHideRemoveClasses(i) { 4447 // Remove open classes after animation 4448 setTimeout(function () { 4449 accordBtn2[i].closest(".accord-container").classList.remove("opened"); 4450 }, accordionAnimationSpeed); 4451 4452 setTimeout(function () { 4453 accordBtn2[i].closest(".accord-container").classList.remove("acc-p-bottom"); 4454 }, accordionAnimationSpeed / 12); 4455 } 4456 4457 // Update show/hide button states 4458 let showButton = e.currentTarget.parentElement.querySelector(".accs-all-show"); 4459 let hideButton = e.currentTarget.parentElement.querySelector(".accs-all-hide"); 4460 4461 showButton.classList.remove("disabled"); 4462 showButton.setAttribute("aria-disabled", "false"); 4463 showButton.removeAttribute("disabled"); 4464 4465 hideButton.classList.add("disabled"); 4466 hideButton.setAttribute("aria-disabled", "true"); 4467 hideButton.setAttribute("disabled", ""); 4468} 4469 4470 4471 4472// Attach show/hide listeners to each accordion container 4473let accContainers = document.querySelectorAll(".acc-container"); 4474 4475accContainers.forEach(accContainer => { 4476 let showButton = accContainer.querySelector(".accs-all-show"); 4477 if (showButton) { 4478 showButton.addEventListener("click", (e) => { 4479 showAllAccs(e); 4480 4481 // Open all Concertina panels 4482 accContainer.querySelectorAll("[data-concertina-btn]").forEach(bellow => { 4483 bellow.classList.add("acc-active"); 4484 bellow.setAttribute("aria-expanded", "true"); 4485 bellow.setAttribute("aria-selected", "true"); 4486 4487 let div = bellow.closest('[data-concertina-wrap]').nextElementSibling; 4488 4489 div.classList.add("d-block"); 4490 div.querySelector(".acc-panel-inner").classList.add("acc-panel-inner-opacity"); 4491 4492 div.style.transition = "none"; 4493 div.style.maxHeight = "0px"; 4494 div.classList.remove("acc-panel-show"); 4495 4496 setTimeout(() => { 4497 div.style.transition = "max-height 0.25s ease-out"; 4498 div.style.maxHeight = div.scrollHeight + "px"; 4499 }, 5); 4500 4501 setTimeout(() => { 4502 div.style.transition = null; 4503 div.style.maxHeight = null;
4504 div.classList.add("acc-panel-show"); 4505 }, delayForFinishedCSSanimation); 4506 }); 4507 4508 // Open all Melodeon panels 4509 accContainer.querySelectorAll("[data-melodeon-btn]").forEach(bellow => { 4510 bellow.classList.add("acc-active"); 4511 bellow.setAttribute("aria-expanded", "true"); 4512 bellow.setAttribute("aria-selected", "true"); 4513 4514 let div = bellow.nextElementSibling; 4515 4516 div.classList.add("d-block"); 4517 div.querySelector(".acc-panel-inner").classList.add("acc-panel-inner-opacity"); 4518 4519 div.style.transition = "none"; 4520 div.style.maxHeight = "0px"; 4521 div.classList.remove("acc-panel-show"); 4522 4523 setTimeout(() => { 4524 div.style.transition = "max-height 0.25s ease-out"; 4525 div.style.maxHeight = div.scrollHeight + "px"; 4526 }, 5); 4527 4528 setTimeout(() => { 4529 div.style.transition = null; 4530 div.style.maxHeight = null; 4531 div.classList.add("acc-panel-show"); 4532 }, delayForFinishedCSSanimation); 4533 }); 4534 4535 // Open all Bandoneon panels 4536 accContainer.querySelectorAll("[data-bandoneon-btn]").forEach(bellow => { 4537 bellow.classList.add("acc-active"); 4538 bellow.setAttribute("aria-expanded", "true"); 4539 bellow.setAttribute("aria-selected", "true"); 4540 4541 let bandoneonButtonValue = bellow.getAttribute('data-bandoneon-btn'); 4542 let div = bellow.closest('.acc-container').querySelector(`[data-bandoneon-panel="${bandoneonButtonValue}"]`); 4543 4544 div.classList.add("d-block"); 4545 div.querySelector(".acc-panel-inner").classList.add("acc-panel-inner-opacity"); 4546 4547 div.style.transition = "none"; 4548 div.style.maxHeight = "0px"; 4549 div.classList.remove("acc-panel-show"); 4550 4551 setTimeout(() => { 4552 div.style.transition = "max-height 0.25s ease-out"; 4553 div.style.maxHeight = div.scrollHeight + "px"; 4554 }, 5); 4555 4556 setTimeout(() => { 4557 div.style.transition = null; 4558 div.style.maxHeight = null; 4559 div.classList.add("acc-panel-show"); 4560 }, delayForFinishedCSSanimation); 4561 }); 4562 4563 }) 4564 } 4565 4566 let hideButton = accContainer.querySelector(".accs-all-hide"); 4567 if (hideButton) { 4568 hideButton.addEventListener("click", (e) => { 4569 hideAllAccs(e); 4570 4571 // Close all Concertina panels 4572 accContainer.querySelectorAll("[data-concertina-btn]").forEach(bellow => { 4573 bellow.classList.remove("acc-active"); 4574 bellow.setAttribute("aria-expanded", "false"); 4575 bellow.setAttribute("aria-selected", "false"); 4576 4577 let div = bellow.closest('[data-concertina-wrap]').nextElementSibling; 4578 4579 div.querySelector('.acc-panel-inner').classList.remove('acc-panel-inner-opacity'); 4580 4581 div.style.transition = "none"; 4582 div.style.maxHeight = div.scrollHeight + "px"; 4583 div.classList.remove('acc-panel-show'); 4584 4585 setTimeout(() => { 4586 div.style.transition = 'max-height 0.25s ease-out'; 4587 div.style.maxHeight = "0px"; 4588 }, 5); 4589 4590 setTimeout(() => { 4591 div.style.transition = null; 4592 div.style.maxHeight = null; 4593 div.classList.remove('d-block'); 4594 }, delayForFinishedCSSanimation); 4595 }); 4596 4597 // Close all Melodeon panels 4598 accContainer.querySelectorAll("[data-melodeon-btn]").forEach(bellow => { 4599 bellow.classList.remove("acc-active"); 4600 bellow.setAttribute("aria-expanded", "false"); 4601 bellow.setAttribute("aria-selected", "false"); 4602 4603 let div = bellow.nextElementSibling; 4604 4605 div.querySelector('.acc-panel-inner').classList.remove('acc-panel-inner-opacity'); 4606 4607 div.style.transition = "none"; 4608 div.style.maxHeight = div.scrollHeight + "px";
4609 div.classList.remove('acc-panel-show'); 4610 4611 setTimeout(() => { 4612 div.style.transition = 'max-height 0.25s ease-out'; 4613 div.style.maxHeight = "0px"; 4614 }, 5); 4615 4616 setTimeout(() => { 4617 div.style.transition = null; 4618 div.style.maxHeight = null; 4619 div.classList.remove('d-block'); 4620 }, delayForFinishedCSSanimation); 4621 }); 4622 4623 // Close all Bandoneon panels 4624 accContainer.querySelectorAll("[data-bandoneon-btn]").forEach(bellow => { 4625 bellow.classList.remove("acc-active"); 4626 bellow.setAttribute("aria-expanded", "false"); 4627 bellow.setAttribute("aria-selected", "false"); 4628 4629 let bandoneonButtonValue = bellow.getAttribute('data-bandoneon-btn'); 4630 let div = bellow.closest('.acc-container').querySelector(`[data-bandoneon-panel="${bandoneonButtonValue}"]`); 4631 4632 div.querySelector('.acc-panel-inner').classList.remove('acc-panel-inner-opacity'); 4633 4634 div.style.transition = "none"; 4635 div.style.maxHeight = div.scrollHeight + "px"; 4636 div.classList.remove('acc-panel-show'); 4637 4638 setTimeout(() => { 4639 div.style.transition = 'max-height 0.25s ease-out'; 4640 div.style.maxHeight = "0px"; 4641 }, 5); 4642 4643 setTimeout(() => { 4644 div.style.transition = null; 4645 div.style.maxHeight = null; 4646 div.classList.remove('d-block'); 4647 }, delayForFinishedCSSanimation); 4648 }); 4649 }) 4650 } 4651 4652 // Add click listeners to all accordion buttons 4653 let accordClasses = document.getElementsByClassName("accord-btn"); 4654 for (let i = 0; i < accordClasses.length; i++) { 4655 accordClasses[i].addEventListener("click", initAccordion); 4656 } 4657}); 4658 4659 4660 4661/////////////////////////// 4662// Main accordion click handler 4663/////////////////// 4664 4665function allAccTypesBtnClickedOn() { 4666 if (doubleClickingAcc === true) { 4667 return; // Prevent double-click spam 4668 } 4669 4670 // Toggles active state and aria attributes 4671 function toggleAccActive(theThis) { 4672 theThis.classList.toggle("acc-active"); 4673 4674 let theTypeOfAccBtn; 4675 4676 if (theThis.hasAttribute('data-melodeon-btn')) { 4677 theTypeOfAccBtn = 'melodeon'; 4678 } else if (theThis.hasAttribute('data-bandoneon-btn')) { 4679 theTypeOfAccBtn = 'bandoneon'; 4680 } else if (theThis.hasAttribute('data-concertina-btn')) { 4681 theTypeOfAccBtn = 'concertina'; 4682 } 4683 4684 // Toggle aria-expanded 4685 if (theThis.getAttribute("aria-expanded") === "true") { 4686 theThis.setAttribute("aria-expanded", "false"); 4687 theThis.setAttribute("aria-selected", "false"); 4688 } 4689 else { 4690 theThis.setAttribute("aria-expanded", "true"); 4691 theThis.setAttribute("aria-selected", "true"); 4692 } 4693 4694 // Update show/hide all buttons inside container 4695 if (theThis.closest(".acc-container")) { 4696 let showButton = theThis.closest(".acc-container").querySelector(".accs-all-show"); 4697 let hideButton = theThis.closest(".acc-container").querySelector(".accs-all-hide"); 4698 4699 if (showButton && hideButton) { 4700 showButton.classList.remove("disabled"); 4701 showButton.setAttribute("aria-disabled", "false"); 4702 showButton.removeAttribute("disabled"); 4703 4704 hideButton.classList.add("disabled"); 4705 hideButton.setAttribute("aria-disabled", "true"); 4706 hideButton.setAttribute("disabled", ""); 4707 4708 let allButtons = theThis.closest(".acc-container").querySelectorAll(`[data-${theTypeOfAccBtn}-btn]`); 4709 let openButtons = theThis.closest(".acc-container").querySelectorAll(`[data-${theTypeOfAccBtn}-btn][aria-expanded='true']`); 4710 4711 if (openButtons.length === allButtons.length) { 4712 // All open 4713 showButton.classList.add("disabled"); 4714 showButton.setAttribute("aria-disabled", "true"); 4715 showButton.setAttribute("disabled", ""); 4716 4717 hideButton.classList.remove("disabled"); 4718 hideButton.setAttribute("aria-disabled", "false"); 4719 hideButton.removeAttribute("disabled"); 4720 } 4721 else if (!openButtons.length) { 4722 // None open 4723 showButton.classList.remove("disabled"); 4724 showButton.setAttribute("aria-disabled", "false"); 4725 showButton.removeAttribute("disabled"); 4726 4727 hideButton.classList.add("disabled"); 4728 hideButton.setAttribute("aria-disabled", "true"); 4729 hideButton.setAttribute("disabled", ""); 4730 } 4731 else { 4732 // Some open 4733 showButton.classList.remove("disabled"); 4734 showButton.setAttribute("aria-disabled", "false"); 4735 showButton.removeAttribute("disabled"); 4736 4737 hideButton.classList.remove("disabled"); 4738 hideButton.setAttribute("aria-disabled", "false"); 4739 hideButton.removeAttribute("disabled"); 4740 } 4741 } 4742 } 4743 } 4744 4745 let allAccTypesSelectedPanel; 4746 let accTypee; 4747 let accGroup; 4748 let atLeastOneDoesNotHaveActiveClass; 4749 4750 // Determine accordion type and panel 4751 if (this.hasAttribute("data-melodeon-btn")) { 4752 accTypee = "melodeon"; 4753 allAccTypesSelectedPanel = this.nextElementSibling; 4754 } 4755 else if (this.hasAttribute("data-concertina-btn")) { 4756 accTypee = "concertina"; 4757 allAccTypesSelectedPanel = this.closest('[data-concertina-wrap]').nextElementSibling; 4758 } 4759 else if (this.hasAttribute("data-bandoneon-btn")) { 4760 accTypee = "bandoneon"; 4761 let bandoneonBtnDataValue = this.getAttribute(`data-${accTypee}-btn`); 4762 allAccTypesSelectedPanel = document.querySelector(`[data-${accTypee}-panel='${bandoneonBtnDataValue}']`); 4763 4764 if (this.getAttribute("data-acc-group")) { 4765 accGroup = this.getAttribute("data-acc-group"); 4766 } 4767 } 4768
4769 if (allAccTypesSelectedPanel.classList.contains("acc-panel-show")) { 4770 // CLOSING the acc panel 4771 doubleClickingAcc = true; 4772 4773 // acc-panel-inner-opacity 4774 4775 toggleAccActive(this); 4776 4777 if (allAccTypesSelectedPanel.classList.contains("acc-panel-inner-opacity")) { 4778 allAccTypesSelectedPanel.querySelector(".acc-panel-inner").classList.remove("acc-panel-inner-opacity"); 4779 } 4780 allAccTypesSelectedPanel.style.transition = "none"; 4781 allAccTypesSelectedPanel.style.maxHeight = allAccTypesSelectedPanel.scrollHeight + "px"; 4782 allAccTypesSelectedPanel.classList.remove("acc-panel-show"); 4783 4784 setTimeout(() => { 4785 allAccTypesSelectedPanel.style.transition = "max-height 0.25s ease-out"; 4786 allAccTypesSelectedPanel.style.maxHeight = "0px"; 4787 }, 5); 4788 4789 setTimeout(() => { 4790 allAccTypesSelectedPanel.style.transition = null; 4791 allAccTypesSelectedPanel.style.maxHeight = null; 4792 allAccTypesSelectedPanel.classList.remove("d-block"); 4793 doubleClickingAcc = false; 4794 }, delayForFinishedCSSanimation); 4795 4796 } 4797 else { 4798 // OPENING the bandoneon panel 4799 doubleClickingAcc = true; 4800 let getUniqueDataNames = []; 4801 let getClickedOnGroupElements; 4802 let countAccActiveClasses = 0; 4803 4804 4805 4806 if (accGroup) { 4807 // if clicked on item is in a group then first close all the items that are in the group 4808 4809 getClickedOnGroupElements = document.querySelectorAll(`[data-acc-group='${accGroup}']`); 4810 4811 if (accTypee === "bandoneon") { 4812 for (let i = 0; i < getClickedOnGroupElements.length; i++) { 4813 getUniqueDataNames.push(getClickedOnGroupElements[i].getAttribute(`data-${accTypee}-btn`)); 4814 } 4815 } 4816 4817 for (let i = 0; i < getClickedOnGroupElements.length; i++) { 4818 if (getClickedOnGroupElements[i].classList.contains("acc-active")) { 4819 countAccActiveClasses = countAccActiveClasses + 1; 4820 } 4821 } 4822 4823 toggleAccActive(this); 4824 4825 for (let i = 0; i < getUniqueDataNames.length; i++) { 4826 4827 let getPanelFromGroupName = document.querySelector(`[data-${accTypee}-panel='${getUniqueDataNames[i]}']`); 4828 4829 if (getPanelFromGroupName !== allAccTypesSelectedPanel) { 4830 4831 if (accTypee === "bandoneon") { 4832 document.querySelector(`[data-${accTypee}-btn='${getUniqueDataNames[i]}']`).classList.remove("acc-active"); 4833 document.querySelector(`[data-${accTypee}-btn='${getUniqueDataNames[i]}']`).setAttribute("aria-expanded", "false"); 4834 document.querySelector(`[data-${accTypee}-btn='${getUniqueDataNames[i]}']`).setAttribute("aria-selected", "false"); 4835 } 4836 4837 // acc-panel-inner-opacity 4838 getPanelFromGroupName.querySelector(".acc-panel-inner").classList.remove("acc-panel-inner-opacity"); 4839 4840 getPanelFromGroupName.style.transition = "none"; 4841 getPanelFromGroupName.style.maxHeight = getPanelFromGroupName.scrollHeight + "px"; 4842 getPanelFromGroupName.classList.remove("acc-panel-show"); 4843 4844 setTimeout(() => { 4845 getPanelFromGroupName.style.transition = "max-height 0.25s ease-out"; 4846 getPanelFromGroupName.style.maxHeight = "0px"; 4847 }, 5); 4848 4849 setTimeout(() => { 4850 getPanelFromGroupName.style.transition = null; 4851 getPanelFromGroupName.style.maxHeight = null; 4852 getPanelFromGroupName.classList.remove("d-block"); 4853 }, delayForFinishedCSSanimation); 4854 } 4855 4856 } 4857 } 4858 else { 4859 toggleAccActive(this); 4860 } 4861 4862 let delayShowAccPanel; 4863 if (this.hasAttribute("data-acc-group")) { 4864 // in a group - maybe add delay 4865 for (let j = 0; j < getUniqueDataNames.length; j++) { 4866 4867 let allPanelsWithUniqueNames = document.querySelector(`[data-${accTypee}-panel='${getUniqueDataNames[j]}']`); 4868 4869 if (allPanelsWithUniqueNames !== allAccTypesSelectedPanel) { 4870 atLeastOneDoesNotHaveActiveClass = !document.querySelector(`[data-${accTypee}-btn='${getUniqueDataNames[j]}']`).classList.contains("acc-active"); 4871 } 4872 } 4873 4874 if (!this.hasAttribute("acc-active") && atLeastOneDoesNotHaveActiveClass && countAccActiveClasses > 0) { 4875 // Add delay here if clicked on element doesn't have active class and if there are no active classes in group 4876 delayShowAccPanel = delayForFinishedCSSanimation + 110; 4877 } 4878 else { 4879 // don't add delay 4880 delayShowAccPanel = 0; 4881 } 4882 } 4883 else { 4884 // not in a group - no delay 4885 delayShowAccPanel = 0; 4886 } 4887 4888 setTimeout(() => { 4889 allAccTypesSelectedPanel.classList.add("d-block"); 4890 4891 // acc-panel-inner-opacity 4892 allAccTypesSelectedPanel.querySelector(".acc-panel-inner").classList.add("acc-panel-inner-opacity"); 4893 allAccTypesSelectedPanel.style.maxHeight = allAccTypesSelectedPanel.scrollHeight + "px"; 4894 }, delayShowAccPanel); 4895 4896 setTimeout(() => { 4897 allAccTypesSelectedPanel.classList.add("acc-panel-sh
4897ow"); 4898 allAccTypesSelectedPanel.style.maxHeight = null; 4899 doubleClickingAcc = false; 4900 }, (delayForFinishedCSSanimation + delayShowAccPanel)); 4901 } 4902} 4903 4904for (let i = 0; i < allAccTypesBtns.length; i++) { 4905 allAccTypesBtns[i].addEventListener("click", allAccTypesBtnClickedOn); 4906} 4907 4908 4909 4910/******************* 4911** POLYFILLS - VANILLA JS ** 4912*******************/ 4913// console.log("a-polyfills JS running..."); 4914 4915// This allows older browsers to execute new javascript functions. 4916// It works in the background whenever a JS file tries to use the â.closest()â method 4917// to find something in the DOM. This affects lots of components 4918 4919// matches polyfill 4920this.Element && function(ElementPrototype) { 4921 ElementPrototype.matches = ElementPrototype.matches || 4922 ElementPrototype.matchesSelector || 4923 ElementPrototype.webkitMatchesSelector || 4924 ElementPrototype.msMatchesSelector || 4925 function(selector) { 4926 var node = this, nodes = (node.parentNode || node.document).querySelectorAll(selector), i = -1; 4927 // Empty while? 4928 while (nodes[++i] && nodes[i] !== node); 4929 return !!nodes[i]; 4930 } 4931}(Element.prototype); 4932 4933// closest polyfill 4934this.Element && function(ElementPrototype) { 4935 ElementPrototype.closest = ElementPrototype.closest || 4936 function(selector) { 4937 var el = this; 4938 while (el.matches && !el.matches(selector)) el = el.parentNode; 4939 return el.matches ? el : null; 4940 } 4941}(Element.prototype); 4942/******************* 4943** DATA TEST - VANILLA JS ** 4944*******************/ 4945// console.log("Data Test JS running..."); 4946 4947 4948 4949 4950let employees = [ 4951 { 4952 path: "/content/txdot-reimagine/us", 4953 title: "us", 4954 level: 0 4955 }, 4956 { 4957 path: "/content/txdot-reimagine/us/en", 4958 title: "en", 4959 level: 1 4960 }, 4961 { 4962 path: "/content/txdot-reimagine/us/en/home", 4963 title: "TXDOT Reimagine Home Page", 4964 level: 2 4965 }, 4966 { 4967 path: "/content/txdot-reimagine/us/en/home/asdfasdf", 4968 title: "asdfasdf", 4969 level: 3 4970 }, 4971 { 4972 path: "/content/txdot-reimagine/us/en/home/asdfasdf/asdfdssdf", 4973 title: "asdfdssdf", 4974 level: 4 4975 }, 4976 { 4977 path: "/content/txdot-reimagine/us/en/home/asdfasdf/asdfdssdf/asdfgd", 4978 title: "asdfgd", 4979 level: 5 4980 }, 4981 { 4982 path: "/content/txdot-reimagine/us/en/home/asdfasdf/asdfdssdf/asdfgd/aewar", 4983 title: "aewar", 4984 level: 6 4985 }, 4986 { 4987 path: "/content/txdot-reimagine/us/en/home/dfsd", 4988 title: "dfsd", 4989 level: 3 4990 }, 4991 { 4992 path: "/content/txdot-reimagine/us/es", 4993 title: "es", 4994 level: 1 4995 } 4996]; 4997 4998 4999employees.sort(function (a, b) { 5000 return a.level - b.level; 5001}); 5002 5003// employees.forEach(function (e) { 5004// console.log("".concat(e.path, " ").concat(e.title, " ").concat(e.level)); 5005// }); 5006/******************* 5007 ** DROPDOWN - VANILLA JS ** 5008 *******************/ 5009// console.log("Dropdown JS running...") 5010 5011let opened = null; 5012 5013function toggleVisibility(e) { 5014 if (!e) { 5015 e = window["event"]; 5016 } 5017 // console.log('togglevisibility funct'); 5018 5019 return e.classList.toggle("show"); 5020} 5021 5022function handleDropdown(e) { 5023 if (!e) { 5024 e = window["event"]; 5025 } 5026 5027 let clickedItem = e.parentElement.lastElementChild; 5028 toggleVisibility(clickedItem); 5029 5030 // console.log('handleDropdown funct'); 5031 5032 if (!opened) { 5033 opened = clickedItem; 5034 e.ariaExpanded = true; 5035 // console.log('hd funct: not opened'); 5036 // console.log(opened); 5037 } 5038 else if (opened === clickedItem) { 5039 opened = null; 5040 e.ariaExpanded = false; 5041 // console.log('hd funct: opened equals clickeditem'); 5042 // console.log(opened); 5043 } 5044 else { 5045 toggleVisibility(opened); 5046 opened = clickedItem; 5047 e.ariaExpanded = true; 5048 // console.log('hd funct: just regularly opened'); 5049 // console.log(opened); 5050 } 5051} 5052 5053function handleClick(e) { 5054 // console.log('handleclick func'); 5055 5056 if (e.target.classList.contains("dropdown-btn")) { 5057 // do this if dropdown-btn classname found on dropdown button 5058 // console.log('hc func: if contains dropdown-btn'); 5059 handleDropdown(e.target); 5060 } 5061 else if (e.target.closest(".dropdown-menu")) { 5062 // do nothing if clicking inside the dropdown menu 5063 // console.log('hc func: else if closest parent w/ .dropdown-menu'); 5064 } 5065 else if (opened) { 5066 // console.log('hc func: else if opened variable has a value'); 5067 toggleVisibility(opened); 5068 opened = null; 5069 } 5070} 5071 5072document.addEventListener("click", handleClick); 5073 5074// Handle dropdown accessible on 'focusout' 5075let dropdownmenus = document.querySelectorAll(".dropdown-menu"); 5076 5077function checkdropdownfocusout(e) { 5078 if (!e) { 5079 e = window["event"]; 5080 } 5081 // console.log('checkdropdownfocus func: examp 1'); 5082 5083 // using tab and shift tab will run this code 5084 if (e.keyCode === 9 || (e.shiftKey && e.keyCode) === 9) { 5085 // console.log('checkdropdownfocus func: examp 2'); 5086 5087 for (let i = 0; i < dropdownmenus.length; i++) {
5088 // do something when focus leaves the entire form 5089 5090 // If focus is still in the form, do nothing and kill this function 5091 // had to change this from 'e.relatedTarget' to e.target to run correctly 5092 if (dropdownmenus[i].contains(e.target)) { 5093 return; 5094 } 5095 5096 // Otherwise, log a message 5097 // console.log('Focus left!'); 5098 5099 if (dropdownmenus[i].classList.contains("show")) { 5100 dropdownmenus[i].classList.remove("show"); 5101 5102 if (opened) { 5103 opened = null; 5104 } 5105 } 5106 5107 } 5108 } 5109 5110} 5111 5112// changed this to keyup 'instead' of 'focusout' to help solve the problem w/ this running when clicking off 5113document.addEventListener('keyup', checkdropdownfocusout); 5114 5115 5116/******************* 5117** DISMISSAL - VANILLA JS ** 5118*******************/ 5119// console.log("Dismissal JS running..."); 5120 5121// Hides the parent element with class .dismissal-wrap is clicked 5122 5123let dismissalWrap = document.getElementsByClassName("dismissal-wrap"); 5124 5125for (let i = 0; i < dismissalWrap.length; i++) { 5126 dismissalWrap[i].onclick = function () { 5127 5128 let thisparent = this.parentElement; 5129 thisparent.classList.add('dismissal-fade'); 5130 5131 setTimeout(function() { 5132 thisparent.classList.remove('dismissal-fade'); 5133 thisparent.classList.add('d-none'); 5134 }, 400); 5135 5136 } 5137} 5138/******************* 5139 ** SEARCH ICON LIBRARY - VANILLA JS ** 5140 *******************/ 5141let accordIconWrap = document.getElementById("accord-icon-wrap"); 5142 5143let allUls 5144// check if element is on the page 5145if (accordIconWrap != null) { 5146 let inputSearchIconLibrary; 5147 5148 // get input element 5149 inputSearchIconLibrary = document.getElementById("search-text"); 5150 5151 // get list from ul 5152 allUls = accordIconWrap.querySelectorAll(".icon-keywords-ul"); 5153 5154 // add event listener 5155 inputSearchIconLibrary.addEventListener("keyup", filterNames); 5156} 5157 5158function filterNames() { 5159 5160 // get filter value of search input 5161 let filterValue = document.getElementById("search-text").value.toUpperCase(); 5162 5163 // loop through all UL's 5164 for (let i = 0; i < allUls.length; i++) { 5165 5166 // get all li's 5167 let a = allUls[i].querySelectorAll("li"); 5168 5169 // by default set match to false 5170 let match = false; 5171 5172 // loop through li's 5173 for (let ii = 0; ii < a.length; ii++) { 5174 // if there is a match set variable 5175 if (a[ii].textContent.toUpperCase().indexOf(filterValue) > -1) { 5176 match = true; 5177 } 5178 } 5179 5180 // if there is a match in the UL 5181 if (match === true) { 5182 // From the UL remove class of parentElement parentElement 5183 allUls[i].parentElement.parentElement.classList.remove("d-none"); 5184 } 5185 else { 5186 // From the UL add class of parentElement parentElement 5187 allUls[i].parentElement.parentElement.classList.add("d-none"); 5188 } 5189 5190 } 5191 5192} 5193 5194///////////////// 5195// Show Keywords Checkbox 5196///////////// 5197 5198// get keywords checkbox element 5199let keywordsCheckbox = document.getElementById("keywordscheckbox"); 5200 5201// check if element is on page 5202if (keywordsCheckbox != null) { 5203 // add event listener 5204 keywordsCheckbox.addEventListener("change", keywordsCheckboxFunc); 5205} 5206 5207function keywordsCheckboxFunc() { 5208 let i; 5209 let list = document.querySelectorAll(".icon-keywords-wrap"); 5210 5211 if (this.checked) { 5212 // checkbox is checked 5213 // console.log("checkbox is checked"); 5214 5215 for (i = 0; i < list.length; ++i) { 5216 list[i].classList.remove("d-none"); 5217 } 5218 5219 } 5220 else { 5221 // checkbox is unchecked 5222 // console.log("checkbox is unchecked"); 5223 5224 for (i = 0; i < list.length; ++i) { 5225 list[i].classList.add("d-none"); 5226 } 5227 } 5228} 5229 5230/* 5231// This is the code for creating icon macros and include code for icons 5232// Nunjucks rangeError: maximum call size stack exceeded 5233 5234const listttt = [] 5235const testtttt1 = document.querySelectorAll(".accord-panel")[2] 5236const labelssss = testtttt1.querySelectorAll("[aria-label]") 5237 5238for (let i = 0; i < labelssss.length; i++) { 5239const labelText = labelssss[i].getAttribute('aria-label') 5240let labelTextEdit = labelText.replace(/\s/g , "-") 5241let qoiueouou 5242qoiueouou = testtttt1.querySelectorAll("ul")[i] 5243 5244let aoisdjfoaisjdf = ` 5245<div class="icon in"> 5246<div> 5247{% include '../../macros/icons/${labelTextEdit}.njk' %} 5248</div> 5249<div class="icon-keywords-wrap"> 5250${qoiueouou.outerHTML} 5251</div> 5252</div> 5253`; 5254 5255listttt.push(aoisdjfoaisjdf) 5256} 5257 5258let textareaaaaElem = document.createElement("TEXTAREA") 5259textareaaaaElem.style.minWidth = '100%' 5260textareaaaaElem.style.minHeight = '400px' 5261 5262 5263 5264textareaaaaElem.innerHTML = listttt 5265document.body.appendChild(textareaaaaElem) 5266*/ 5267 5268/******************* 5269** TABS - VANILLA JS ** 5270*******************/ 5271// console.log("Tabs JS running..."); 5272 5273 5274 5275 5276let tabOuterWrap = document.querySelectorAll('.tabs-component-wrapper'); 5277 5278if (tabOuterWrap.length > 0) { 5279 5280 for (let i = 0; i < tabOuterWrap.length; i++) { 5281 let tabs = tabOuterWrap[i].querySelectorAll('[role="tab"]'); 5282 let tabList = tabOuterWrap[i].querySelector('[role="tablist"]'); 5283 let tabPanel = tabOuterWrap[i].querySelectorAll('[role="tabpanel"]'); 5284 5285 if (tabs && tabList) { 5286 5287 // Enable arrow navigation between tabs in the tab list 5288 let tabFocus = 0; 5289 5290 for(let k = 0; k < tabs.length; k++) { 5291 tabs[k].setAttribute("data-tabs-num", k); 5292 tabs[k].addEventListener("click", changeTabs); 5293 } 5294 5295 for(let k = 0; k < tabPanel.length; k++) { 5296 tabPanel[k].setAttribute("data-tabpanel", k); 5297 } 5298 5299 tabList.addEventListener("keydown", function (e) { 5300 // Move right 5301 if (e.keyCode === 39 || e.keyCode === 37) { 5302 tabs[tabFocus].setAttribute("tabindex", "-1"); 5303 if (e.keyCode === 39) { 5304 tabFocus++; 5305 // If we're at the end, go to the start 5306 if (tabFocus >= tabs.length) { 5307 tabFocus = 0; 5308 } 5309 // Move left 5310 } else if (e.keyCode === 37) { 5311 tabFocus--; 5312 // If we're at the start, move to the end 5313 if (tabFocus < 0) { 5314 tabFocus = tabs.length - 1; 5315 } 5316 } 5317 5318 tabs[tabFocus].setAttribute("tabindex", "0"); 5319 tabs[tabFocus].focus(); 5320 } 5321 }); 5322 5323 5324 5325 function changeTabs(e) { 5326 let ariaSelectedTrueParents = e.target.closest('.tabs-wrapper-inner').querySelectorAll('[aria-selected="true"]'); 5327 5328 for (let i = 0; i < ariaSelectedTrueParents.length; i++) { 5329 ariaSelectedTrueParents[i].setAttribute("aria-selected", "false"); 5330 ariaSelectedTrueParents[i].setAttribute("tabindex", "-1"); 5331 } 5332 5333 tabFocus = e.target.getAttribute("data-tabs-num"); 5334 5335 // Set this tab as selected 5336 e.target.setAttribute("aria-selected", "true"); 5337 e.target.setAttribute("tabindex", "0"); 5338 5339 let tabPanelsAll = tabOuterWrap[i].querySelectorAll('[role="tabpanel"]'); 5340 5341 for (let i = 0; i < tabPanelsAll.length; i++) { 5342 tabPanelsAll[i].setAttribute("hidden", ""); 5343 } 5344 5345 // Show the selected panel 5346 tabOuterWrap[i].querySelector('[data-tabpanel="' + e.target.getAttribute("data-tabs-num") + '"]').removeAttribute("hidden"); 5347 } 5348 5349 } 5350 } 5351 5352 5353 5354} 5355/******************* 5356** CARD.JS - VANILLA JS ** 5357*******************/ 5358// console.log("card JS running..."); 5359 5360var cardSteroidWrap; 5361var cardSteroidCard; 5362var cardSteroidCount; 5363 5364cardSteroidWrap = document.querySelectorAll('.cardsteroids-wrp'); 5365 5366if (cardSteroidWrap) { 5367 // get all the cardsteroids wrapper elements 5368 for (var i = 0; i < cardSteroidWrap.length; i++) { 5369 // get all the cardsteroids card elements 5370 cardSteroidCard = cardSteroidWrap[i].querySelectorAll('.cardsteroids-crd'); 5371 5372 // get count of cardsteroids card elements 5373 cardSteroidCount = cardSteroidCard.length; 5374 5375 // run a small loop add class to each cardsteroids-crd class 5376 for (var j = 0; j < cardSteroidCard.length; j++) { 5377 cardSteroidCard[j].classList.add('cardsteroids-crd-' + cardSteroidCount); 5378 } 5379 } 5380} 5381 5382/******************* 5383** CAREERS BANNER FORM HANDLING - VANILLA JS ** 5384*******************/ 5385// console.log("Careers Banner Form Handling JS running..."); 5386 5387// Get references to the input fields by their IDs 5388let jobTitleKeywords = document.getElementById("job-title-keywords"); 5389let jobLocation = document.getElementById("job-location"); 5390 5391// Add event listeners to both inputs (if they exist on the page) 5392// On each keyup (user typing), run the error control function 5393// The ternary operator is used to check if the element exists before adding the listener 5394(jobTitleKeywords != null) 5395 ? (jobTitleKeywords.addEventListener('keyup', careersBannerErrorControl)) 5396 : 0; 5397 5398(jobLocation != null) 5399 ? (jobLocation.addEventListener('keyup', careersBannerErrorControl)) 5400 : 0; 5401 5402 5403// Declare variables to store inputs and error message element 5404let careersBannerInputs, careersBannerError; 5405 5406 5407// Function that controls validation and error display 5408function careersBannerErrorControl() { 5409 5410 // Select all input fields with this class 5411 careersBannerInputs = document.querySelectorAll('.careers-banner-input'); 5412 5413 // Select the error message element 5414 careersBannerError = document.querySelector('.careers-banner-error'); 5415 5416 // Check if either input field has a value (not empty) 5417 if (jobTitleKeywords.value || jobLocation.value) { 5418 // At least one field has input 5419 5420 // Loop through all inputs and REMOVE error styling if present 5421 for (let i = 0; i < careersBannerInputs.length; i++) { 5422 if (careersBannerInputs[i].classList.contains('careers-banner-input-error')) { 5423 careersBannerInputs[i].classList.remove('careers-banner-input-error'); 5424 } 5425 } 5426 5427 // Hide the error message if it's currently visible 5428 if (careersBannerError.classList.contains('show')) { 5429 careersBannerError.classList.remove('show'); 5430 } 5431 5432 } else { 5433 // Both fields are empty 5434 5435 // Loop through inputs and ADD error styling if not already applied 5436 for (let i = 0; i < careersBannerInputs.length; i++) { 5437 if (!careersBannerInputs[i].classList.contains('careers-banner-input-error')) { 5438 careersBannerInputs[i].classList.add('careers-banner-input-error'); 5439 } 5440 } 5441 5442 // Show the error message if it's not already visible 5443 if (!careersBannerError.classList.contains('show')) { 5444 careersBannerError.classList.add('show'); 5445 } 5446 } 5447} 5448 5449 5450// Function that runs when the form is submitted 5451function careerSearchBanner() { 5452 5453 // Check if at least one input has a value 5454 if (jobTitleKeywords.value || jobLocation.value) { 5455 // Valid input exists 5456 5457 // This is where you would pass values to the next page (Search Results Page) 5458 // Example: build a query string or redirect 5459 5460 } else { 5461 // No input provided 5462 5463 // Trigger error display 5464 careersBannerErrorControl(); 5465 5466 // Stop form submission 5467 return false;
5468 } 5469} 5470 5471 5472// Utility function to focus an element by ID 5473function focusIdfunct(x) { 5474 // Set focus to the element with the provided ID 5475 document.getElementById(x).focus(); 5476} 5477/************************* 5478 ** CAREERS SEARCH LIST ** 5479 *************************/ 5480 5481function showFilterPanel() { 5482 document.getElementById("modal-backdrop").style.display = "unset"; 5483 5484 let filterPanel = document.getElementById("filterPanel"); 5485 filterPanel.style.display = "block"; 5486 filterPanel.classList.add("in", "show"); 5487 5488 document.getElementsByClassName("modal-dialog")[0].style.display = "inherit"; 5489} 5490 5491function hideFilterPanel() { 5492 document.getElementById("modal-backdrop").style.display = "none"; 5493 5494 let filterPanel = document.getElementById("filterPanel"); 5495 filterPanel.style.display = "none"; 5496 filterPanel.classList.remove("in", "show"); 5497 5498 document.getElementsByClassName("modal-dialog")[0].style.display = "none"; 5499} 5500 5501function setFilterFromPanel() { 5502 let chips = document.getElementsByClassName("job-filter-chip"); 5503 5504 for (let i = 0; i < chips.length; i++) { 5505 chips[i].classList.add("d-none"); 5506 } 5507 5508 let checked = document.querySelectorAll("input[class=form-check-input]:checked"); 5509 for (let i = 0; i < checked.length; i++) { 5510 let dataValue = checked[i].id; 5511 5512 document.querySelector("[data-value=" + dataValue + "]").classList.remove("d-none"); 5513 } 5514} 5515 5516// Modals are dynamically generated to prevent having a hidden permanent element on the template. 5517function openJobSearchRedirectModal(job) { 5518 // Parameter may not be necessary. Check with Gnanesh. 5519 // - Lina 5520 5521 let jobSearchRedirectModal = document.createElement("div"); 5522 jobSearchRedirectModal.setAttribute("id", "careers-search-modal"); 5523 jobSearchRedirectModal.setAttribute("class", "search-form"); 5524 jobSearchRedirectModal.innerHTML = ` 5525 <h5 class="mb-2">You are being taken to TxDOT's Applicant Site.</h5> 5526 <div class="mb-2">Do you want to proceed to view job details and apply?</div> 5527 <div class="job-search-modal-buttons"> 5528 <a href="https://www.google.com" class="btn btn-primary">Yes</a> 5529 <button class="btn btn-outline-secondary cancel" onclick="closeJobSearchRedirectModal()">No</button> 5530 </div> 5531 `; 5532 job.after(jobSearchRedirectModal); 5533 5534 document.getElementById("careers-search-modal").classList.add("active"); 5535 document.getElementById("careers-search-modal-overlay").classList.add("active"); 5536 document.body.classList.add("no-scroll"); 5537} 5538 5539function closeJobSearchRedirectModal() { 5540 document.getElementById("careers-search-modal").classList.remove("active"); 5541 document.getElementById("careers-search-modal-overlay").classList.remove("active"); 5542 document.body.classList.remove("no-scroll"); 5543 5544 document.getElementById("careers-search-modal").remove(); 5545} 5546 5547let salaryToggle = document.querySelector('.salary-toggle'); 5548 5549if(salaryToggle) { 5550 function salaryToggleFunc() { 5551 salaryToggle.classList.toggle('salary-toggle-show'); 5552 } 5553 5554 salaryToggle.addEventListener("click", salaryToggleFunc); 5555} 5556/******************* 5557 ** CAROUSEL - VANILLA JS ** 5558 *******************/ 5559// console.log("carousel JS running..."); 5560 5561// Find all the carousels on the page 5562let carousels = document.querySelectorAll(".carousel"); 5563 5564// Set Multiple Attributes Custom Function 5565function setAttributesCustom(el, attrs) { 5566 for (let key in attrs) { 5567 el.setAttribute(key, attrs[key]); 5568 } 5569} 5570 5571if (carousels) { 5572 // Loop through carousels 5573 for (let i = 0; i < carousels.length; i++) { 5574 let carouselSlides = carousels[i].querySelector(".carousel-slides"); 5575 let carouselSlidesCount = carouselSlides.childElementCount; 5576 let carouselFigCaption = carouselSlides.querySelectorAll(".carousel-slide-item figure figcaption"); 5577 let maxHeight 5578 5579 for (let j = 0; j < carouselFigCaption.length; j++) { 5580 setAttributesCustom(carouselFigCaption[j], { 5581 id: "carousel-" + (i + 1) + "-slide-" + (j + 1) 5582 }); 5583 } 5584
5585 ////////////////////// 5586 // CREATE THUMBNAIL UL 5587 ////////////////////// 5588 let thumbnailUl = document.createElement("ul"); 5589 let thumbnailUlWrapper = document.createElement("div"); 5590 let backButton = document.createElement("button"); 5591 let forwardButton = document.createElement("button"); 5592 5593 thumbnailUl.setAttribute("class", "carousel-thumbs-wrap"); 5594 thumbnailUlWrapper.setAttribute("class", "carousel-thumbs-wrap-wrap"); 5595 backButton.setAttribute("class","carousel-thumbs-nav-button"); 5596 forwardButton.setAttribute("class","carousel-thumbs-nav-button"); 5597 backButton.setAttribute("style","display: none;"), 5598 forwardButton.setAttribute("style","display: none;"), 5599 5600 backButton.innerHTML = ` 5601 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 5602 <path d="M30.83 32.67l-9.17-9.17 9.17-9.17L28 11.5l-12 12 12 12z"></path> 5603 </svg>`; 5604 forwardButton.innerHTML = ` 5605 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 5606 <path d="M17.17 32.92l9.17-9.17-9.17-9.17L20 11.75l12 12-12 12z"></path> 5607 </svg>`; 5608 5609 carouselSlides.insertAdjacentElement("afterend",thumbnailUlWrapper) 5610 thumbnailUlWrapper.appendChild(backButton); 5611 thumbnailUlWrapper.appendChild(thumbnailUl); 5612 thumbnailUlWrapper.appendChild(forwardButton); 5613 5614 backButton.addEventListener("click", () => { 5615 let thumbnails = backButton.closest("fieldset").querySelector(".carousel-thumbs-wrap"); 5616 thumbnails.scrollLeft -= thumbnails.offsetWidth; 5617 }); 5618 forwardButton.addEventListener("click", () => { 5619 let thumbnails = forwardButton.closest("fieldset").querySelector(".carousel-thumbs-wrap"); 5620 thumbnails.scrollLeft += thumbnails.offsetWidth; 5621 }); 5622 5623 // Loop through number of slides in carousel 5624 for (let j = 0; j < carouselSlidesCount; j++) {
5625 /////////////////////// 5626 // INSERT RADIO BUTTONS 5627 /////////////////////// 5628 let radioButton = document.createElement("input"); 5629 5630 5631 setAttributesCustom(radioButton, { 5632 class: "carousel-input-" + (j + 1), 5633 type: "radio", 5634 name: "carousel-" + (i + 1), 5635 "aria-labelledby": "carousel-" + (i + 1) + "-slide-" + (j + 1) 5636 }); 5637 5638 if (j === 0) { 5639 radioButton.setAttribute("checked", "checked"); 5640 } 5641 5642 carouselSlides.parentNode.insertBefore(radioButton, carouselSlides); 5643 5644 ////////////////////////// 5645 // INSERT THUMBNAILS in UL 5646 ////////////////////////// 5647 5648 let fragment = document.createDocumentFragment(); 5649 let carouselSlideItem = carouselSlides.querySelectorAll(".carousel-slide-item")[j]; 5650 5651 let carouselSlideItemImg = carouselSlideItem.querySelector("img"); 5652 let carouselSlideItemImgAlt = carouselSlideItemImg.alt; 5653 let carouselSlideItemImgSrc = carouselSlideItemImg.src; 5654 5655 let thumbnailLi = document.createElement("li"); 5656 thumbnailLi.className = "thumb-slide-" + (j + 1); 5657 5658 5659 5660 fragment.appendChild(thumbnailLi); 5661 5662 let thumbnailButton = document.createElement("button"); 5663 thumbnailButton.className = "carousel-thumbnail-button"; 5664 // thumbnailButton.setAttribute("aria-label",carouselSlideItemImgAlt); 5665 thumbnailButton.setAttribute("aria-label",carouselSlideItemImgAlt + " " + (j + 1) + " of " + carouselSlidesCount + " thumbnails"); 5666 thumbnailLi.appendChild(thumbnailButton); 5667 5668 // Start with the "selected" styling present on the first thumbnail 5669 if (j===0) { 5670 thumbnailLi.classList.add("carousel-thumbnail-button-selected"); 5671 thumbnailLi.querySelector('button').setAttribute("aria-current", true); 5672 } 5673 5674 // let thumbnailButtonSpan = document.createElement("span"); 5675 thumbnailButton.style.backgroundImage = "url('" + carouselSlideItemImgSrc + "')"; 5676 // thumbnailButton.style.backgroundSize = "cover"; 5677 // thumbnailButtonSpan.setAttribute("tabindex", "0"); 5678 // thumbnailButton.appendChild(thumbnailButtonSpan); 5679 5680 thumbnailUl.appendChild(fragment); 5681 } 5682 5683 carouselSlides.querySelectorAll("img").forEach(image=>{ 5684 const observer = new ResizeObserver(() => { 5685 image.style.height=maxHeight+"px" 5686 }); 5687 observer.observe(carouselSlides); 5688 }) 5689 } 5690} 5691 5692function carouselThumbClick(e) { 5693 if (!e) { 5694 e = window["event"]; 5695 } 5696 5697 let carousel = e.target.closest(".carousel"); 5698 // let thumbsWrap = e.target.closest('.carousel-thumbs-wrap'); 5699 let thumbClickedElem = e.target.closest("[class^=thumb-slide-]"); 5700 let thumbClickedClassName = thumbClickedElem.className; 5701 5702 let arr = thumbClickedClassName.match(/thumb-slide-(.*)/); 5703 let carouselClickedSlideNumb; 5704 // Did it match? 5705 if (arr) { 5706 carousel.querySelectorAll("li").forEach(li=>{ 5707 li.classList.remove("carousel-thumbnail-button-selected"); 5708 5709 if (li.querySelector('button')) { 5710 li.querySelector('button').removeAttribute('aria-current'); 5711 } 5712 5713 }) 5714 5715 carouselClickedSlideNumb = arr[1]; 5716 thumbClickedElem.classList.add("carousel-thumbnail-button-selected"); 5717 thumbClickedElem.querySelector('button').setAttribute("aria-current", true); 5718 } 5719 5720 if (carousel.querySelector(".carousel-input-" + carouselClickedSlideNumb)) { 5721 carousel.querySelector(".carousel-input-" + carouselClickedSlideNumb).checked = true; 5722 } 5723} 5724 5725// Add listeners to all thumbnail buttons 5726let carouselThumbnailButtons = document.querySelectorAll(".carousel-thumbnail-button"); 5727carouselThumbnailButtons.forEach(carouselThumbnailButton=>{ 5728 carouselThumbnailButton.addEventListener("click",carouselThumbClick) 5729}) 5730 5731/******************* 5732 ** TABLE - VANILLA JS ** 5733 *******************/ 5734 5735// For date validation 5736// Separate whole-word terms (case insensitive due to the "i") within the \\b boundaries, separated by a | 5737 5738 5739 5740/* 5741 * Date detection regexes used by table sorting. 5742 * 5743 * Whitelist: 5744 * - Header names containing words like "date", "updated", or "completion" 5745 * are treated as potential date columns. 5746 * 5747 * Blacklist: 5748 * - Prevents phrases such as "to date" from being treated as date fields. 5749 */ 5750 5751 5752// For date validation 5753// Separate whole-word terms (case insensitive due to the "i") within the \\b boundaries, separated by a | 5754const dateRegexWhitelist = new RegExp("\\bdate|updated|completion\\b", "i"); 5755const dateRegexBlacklist = new RegExp("\\bto date\\b", "i"); 5756const page_number = 1; 5757const page_size = 10; 5758 5759 5760 5761/** 5762 * Converts author-created rich text tables into accessible, 5763 * sortable tables. 5764 * 5765 * Responsibilities: 5766 * - Detect table type (top headers or side headers) 5767 * - Convert TD elements into TH elements where appropriate 5768 * - Add accessibility attributes (scope, captions) 5769 * - Handle rowspan scenarios 5770 * - Add hidden captions for screen readers 5771 */ 5772 5773function convertRichTextTable() { 5774 let tables = document.querySelectorAll("table"); 5775 let i, thead, th;
5776 tables.forEach(table => { 5777 // Check if the table's supposed to have vertical headers 5778 5779 // Maintain positioning context for later UI components 5780 table.style.position = 'relative'; 5781 5782 5783 // Prevent converting the same table multiple times 5784 if (table.hasAttribute('data-jstable-convertedrichtext')) { 5785 return; 5786 } 5787 5788 table.setAttribute('data-jstable-convertedrichtext', ''); 5789 5790 5791 /* 5792 * SIDE HEADER TABLES 5793 * 5794 * Converts first-column TD elements into TH elements 5795 * while accounting for rowspans. 5796 */ 5797 5798 if (table.closest(".table-ultimate-wrap[data-table-headers='th-side']")) { 5799 // Putting in a lot of redundant checks here to account for possible null values. If we can verify that all of 5800 // the required elements will *always* be present (or if there's a better way to do this), we can remove them. 5801 // - Lina --- Adding rowspan logic 5802 let tbody = table.firstElementChild; 5803 if (tbody) { 5804 let rows = tbody.querySelectorAll("tr"); 5805 console.log(rows); 5806 if (rows) { 5807 5808 5809 let rowspancount = 0; 5810 rows.forEach((row, index, rows) => { 5811 let recordrow = 0; 5812 5813 /* 5814 * Determine the largest rowspan that exists 5815 * within this row. 5816 * 5817 * Stored as a custom attribute so later rows 5818 * know whether a rowspan is affecting table 5819 * structure. 5820 */ 5821 5822 row.setAttribute('highestrowspan', 1); 5823 5824 5825 /* 5826 * Convert first TD in qualifying rows into TH 5827 * so assistive technologies recognize row headers. 5828 */ 5829 5830 5831 let tds = row.querySelectorAll('td'); 5832 tds.forEach(z => { 5833 5834 var rowspanatt = z.getAttribute('rowspan') 5835 if (rowspanatt && rowspanatt > 1) { 5836 if (rowspanatt > row.getAttribute('highestrowspan')) { 5837 row.setAttribute('highestrowspan', rowspanatt); 5838 } 5839 } 5840 }); 5841 5842 5843 5844 5845 rows.forEach((v, indx, rows) => { 5846 if (recordrow < v.getAttribute('highestrowspan')) { 5847 recordrow = v.getAttribute('highestrowspan'); 5848 } 5849 5850 5851 }) 5852 5853 let previousrecordrow = 0; 5854 5855 let rowaboveitems = table.querySelectorAll('tr'); 5856 5857 5858 let headerarray2 = table.querySelectorAll('.table-vertical-header'); 5859 //console.log(headerarray2); 5860 5861 let lastiteminheaderarray = headerarray2[headerarray2.length - 1]; 5862 //console.log(lastiteminheaderarray); 5863 5864 let totalindexofheaders = 0; 5865 5866 5867 headerarray2.forEach((headeritem, index, headerarray2) => { 5868 if (headeritem.attributes.rowspan) { 5869 5870 totalindexofheaders = Number(recordrow); 5871 } 5872 }) 5873 5874 5875 let td = row.querySelector("td"); 5876 if (td && index == 0) { 5877 // Create th tags 5878 th = document.createElement("th"); 5879 th.classList.add("table-vertical-header"); 5880 th.setAttribute("scope", "row"); 5881 // Put td.innerHTML inside th tags 5882 th.innerHTML = td.innerHTML; 5883 if (td.hasAttribute('rowspan')) { 5884 th.setAttribute('rowspan', td.getAttribute('rowspan')); 5885 5886 } 5887 // Replace td element with th element, 5888 // removing it from the collection 5889 td.parentNode.replaceChild(th, td); 5890 } 5891 5892 let headerarray = table.querySelectorAll('.table-vertical-header'); 5893 5894 let sumtotalofallheaderrows = 0; 5895 headerarray.forEach((c, i, headerarray) => { 5896 if (c.attributes.rowspan) { 5897 sumtotalofallheaderrows = Number(sumtotalofallheaderrows) + Number(c.attributes.rowspan.value); 5898 } 5899 else { 5900 sumtotalofallheaderrows = Number(sumtotalofallheaderrows) + 1; 5901 } 5902 }); 5903 5904 5905 if (td && index > 0 && !rows[index - 1].getAttribute('containsrowspans') && index + 1 > sumtotalofallheaderrows) { 5906 // Create th tags 5907 th = document.createElement("th"); 5908 th.classList.add("table-vertical-header"); 5909 th.setAttribute("scope", "row"); 5910 // Put td.innerHTML inside th tags 5911 th.innerHTML = td.innerHTML; 5912 if (td.hasAttribute('rowspan')) { 5913 th.setAttribute('rowspan', td.getAttribute('rowspan')); 5914 } 5915 // Replace td element with th element, 5916 // removing it from the collection 5917 td.parentNode.replaceChild(th, td); 5918 } 5919 5920 5921 5922 }); 5923 } 5924 } 5925 5926 5927 //row logic to accounnt for rowspans 5928 // for (j = 0; j < rows.length; j++) { 5929 // let doesThisRowspan = false;
5930 // for (x = 0; x < rows[j].cells.length; x++) { 5931 5932 // if (rows[j].cells[x].attributes.rowspan > 1) { 5933 5934 // } 5935 // } 5936 // } 5937 5938 5939 5940 5941 5942 5943 5944 } else if (table.closest(".table-ultimate-wrap[data-table-headers='th-top']")) { 5945 /* 5946 * If THEAD doesn't already exist, 5947 * create one from the first row. 5948 */ 5949 5950 if (table.firstElementChild.tagName !== "thead") { 5951 // If not, create thead element and put first row in it 5952 let tbody = table.firstElementChild; 5953 let header = tbody.firstElementChild; 5954 // Create thead tags 5955 thead = document.createElement("thead"); 5956 // Put header.innerHTML inside tr tags, then the thead 5957 thead.innerHTML = "<tr>" + header.innerHTML + "</tr>"; 5958 // Put header tr before tbody 5959 header.parentElement.before(header); 5960 // Put header tr in thead tags 5961 header.parentNode.replaceChild(thead, header); 5962 } 5963 5964 5965 /* 5966 * Convert all TD cells in THEAD into TH cells. 5967 * 5968 * This improves: 5969 * - Accessibility 5970 * - Sorting support 5971 * - Screen reader behavior 5972 */ 5973 5974 5975 thead = table.firstElementChild; 5976 let tds = thead.getElementsByTagName("td"); 5977 while (tds.length > 0) { 5978 // Changing tds into ths modifies the collection, 5979 // so the first element automatically itterates 5980 let td = tds[0]; 5981 // Create th tags 5982 th = document.createElement("th"); 5983 // Put td.innerHTML inside th tags 5984 th.innerHTML = td.innerHTML; 5985 // Replace td element with th element, 5986 // removing it from the collection 5987 5988 let tdAttributes = td.attributes; 5989 if (tdAttributes) { 5990 // Add attributes back in 5991 for (let x = 0; x < tdAttributes.length; x++) { 5992 th.setAttribute(tdAttributes[x].name, tdAttributes[x].value); 5993 } 5994 } 5995 5996 td.parentNode.replaceChild(th, td); 5997 } 5998 5999 let columns = thead.querySelector("tr").querySelectorAll("th"); 6000 let colIndex = []; 6001 6002 // Next, check for date columns 6003 // If there are, push their index into colIndex 6004 // for (let i = 0; i < columns.length; i++) { 6005 // if (dateRegexWhitelist.test(columns[i].innerText) && !dateRegexBlacklist.test(columns[i].innerText)) { 6006 // colIndex.push(i); 6007 // columns[i].classList.add('date-sort'); 6008 // } 6009 // } 6010 6011 // And validate each cell in each date column 6012 if (colIndex.length) { 6013 let rows = table.querySelector("tbody").querySelectorAll("tr"); 6014 6015 6016 6017 6018 6019 console.log(rows); 6020 let theRegexDashes = new RegExp("[âââËâââââ-]", "gm"); 6021 6022 // rows.forEach(row => { 6023 // let tds = row.querySelectorAll("td"); 6024 // for (let i = 0; i < colIndex.length; i++) { 6025 // let cell = tds[colIndex[i]]; 6026 // let cellText = cell.innerText; 6027 6028 // let regExDashTF = theRegexDashes.test(cellText); 6029 6030 // // console.log("cellText: ", cellText); 6031 // // console.log("theRegexDashes.test(cellText): ", theRegexDashes.test(cellText)); 6032 6033 // if (regExDashTF === true) { 6034 // // Find if date range then test if starting range can't be parsed 6035 // let cellTstring = cellText.replace(theRegexDashes, "-"); 6036 // // console.log("cellTstring: ", cellTstring); 6037 // let rangeSides = cellTstring.split('-'); 6038 // let beginRange = rangeSides[0].trim(); 6039 // let endRange = rangeSides[1].trim(); 6040 6041 // // console.log("rangeSides: ", rangeSides); 6042 // // console.log("Date.parse(beginRange): ", Date.parse(beginRange)); 6043 // // console.log("Date.parse(endRange): ", Date.parse(endRange)); 6044 6045 // if (!Date.parse(beginRange) || !Date.parse(endRange)) { 6046 // cell.classList.add("table-cell-invalid-date"); 6047 // } else { 6048 // cell.setAttribute('data-date-parse', Date.parse(beginRange)); 6049 // } 6050 6051 // } else if (Date.parse(cellText)) { 6052 // // cell text can be parsed into a date 6053 // cell.setAttribute('data-date-parse', Date.parse(cellText)); 6054 // } else { 6055 // // cell text can't be parsed into a date so insert invalid date class 6056 // cell.classList.add("table-cell-invalid-date"); 6057 // } 6058 6059 // } 6060 // }); 6061 } 6062 } 6063 6064 let masterTableWrap = table.closest(".table-ultimate-wrap"); 6065 let tableTitle = ""; 6066 let tableDescription = ""; 6067 6068 if (masterTableWrap) { 6069 tableTitle = table.closest(".table-ultimate-wrap").querySelectorAll(".tableTitle")[0]; 6070 } 6071 6072 if (masterTableWrap) { 6073 tableDescription = table.closest(".table-ultimate-wrap").querySelectorAll(".tableDescription")[0]; 6074 } 6075 6076 /* 6077 * Accessibility: 6078 * 6079 * Every table should have a caption. 6080 * 6081 * If author supplied: 6082 * - Title 6083 * - Description 6084 * 6085 * Use them. 6086 * 6087 * Otherwise create a generic hidden caption. 6088 */ 6089 6090 6091 if ((tableTitle == "" && tableDescription == "") || (!tableTitle && !tableDescription)) { 6092 table.insertAdjacentHTML('afterbegin', `<caption class="visually-hidden">Details</caption>`); 6093 } 6094 6095 6096 if (masterTableWrap && tableTitle && tableDescription) { 6097 table.insertAdjacentHTML('afterbegin', `<caption class="visually-hidden">` + tableTitle.innerHTML + tableDescription.innerHTML + `</caption>`); 6098 } 6099 6100 if (masterTableWrap && tableTitle && !tableDescription) { 6101 table.insertAdjacentHTML('afterbegin', `<caption class="visually-hidden">` + tableTitle.innerHTML + `</caption>`); 6102 } 6103 6104 if (masterTableWrap && !tableTitle && tableDescription) { 6105 table.insertAdjacentHTML('afterbegin', `<caption class="visually-hidden">` + tableDescription.innerHTML + `</caption>`); 6106 } 6107 6108 }); 6109} 6110 6111 6112/** 6113 * Applies Table Ultimate styling and behavior. 6114 * 6115 * Adds: 6116 * - CSS classes 6117 * - Sortable column headers 6118 * - Pagination controls 6119 * - Table cloning for pagination resets 6120 */ 6121 6122 6123function changeUltimateTables() { 6124 let ultimateTables = document.querySelectorAll(".table-ultimate-wrap"); 6125 let i, j, k; 6126 for (i = 0; i < ultimateTables.length; i++) { 6127 let ultimateTable = ultimateTables[i]; 6128 let tables = ultimateTable.querySelectorAll("table"); 6129 for (j = 0; j < tables.length; j++) { 6130 let table = tables[j]; 6131 let disableSorting = false;
6132 if (table.hasAttribute('data-jstable-convertedultimate')) { 6133 continue; 6134 } 6135 6136 table.setAttribute('data-jstable-convertedultimate', ''); 6137 6138 function removeAttributes(element, attributes) { 6139 attributes.forEach(attr => { 6140 element.removeAttribute(attr); 6141 }); 6142 } 6143 6144 const tableAttributes = ['width', 'cellspacing', 'cellpadding', 'border']; 6145 removeAttributes(table, tableAttributes); 6146 6147 table.classList.remove("table", "table-hover"); 6148 table.classList.add("table-el", "table-el-bordered", "table-sort", "table-filter"); 6149 6150 let cells = table.querySelectorAll("th, td"); 6151 cells.forEach(cell => { 6152 // Currently matches whitespace and s 6153 // We can add more if an author gets *really* creative. 6154 // - Lina 6155 if (!cell.innerHTML.replace(/\s| /g, "").length) { 6156 cell.innerHTML = ""; 6157 } 6158 6159 if (cell.hasAttribute('colspan') || cell.hasAttribute('rowspan')) { 6160 disableSorting = true; 6161 } 6162 }) 6163 6164 6165 if (!table.closest("[data-table-headers='th-side']")) { 6166 6167 let rowwwsss = table.querySelector("tbody").querySelectorAll("tr"); 6168 console.log(rowwwsss); 6169 let oneRow = true; 6170 // console.log(rowwwsss); 6171 if (rowwwsss.length > 1) { 6172 // console.log("rowwwsss is greater than 1"); 6173 oneRow = false; 6174 } 6175 6176 let headers = table.querySelectorAll("th"); 6177 headers.forEach(header => { 6178 if (!header.closest("[table-vertical-headers]")) { 6179 6180 header.setAttribute("scope", "col"); 6181 6182 if (oneRow == true || header.hasAttribute("data-table-th-nosort") || header.closest(".table-responsive").classList.contains('disablecolsort') || disableSorting) { 6183 header.innerHTML = ` 6184 <span class="table-header-notsortable"> 6185 ${header.innerHTML} 6186 </span> 6187 `; 6188 } else { 6189 if (!header.closest(".table-responsive").classList.contains('disablecolsort')) { 6190 6191 header.classList.add("table-sort-head"); 6192 6193 header.innerHTML = ` 6194 <button class="sortable-fast link-icon-js-import"> 6195 ${header.innerHTML} 6196 <svg viewBox="0 0 700 575" xmlns="http://www.w3.org/2000/svg"> 6197 <path class="table-sort-arrow-up-solid" d="m253.01 239.46h193.98c5.0078-0.003906 9.6367-2.668 12.152-7 2.5234-4.3281 2.5234-9.6758 0-14l-96.992-168.06c-2.5156-4.3281-7.1445-6.9922-12.152-6.9922s-9.6367 2.6641-12.152 6.9922l-96.992 168c-2.5234 4.3281-2.5234 9.6758 0 14 2.5 4.3555 7.1328 7.043 12.152 7.0586z"/> 6198 <path class="table-sort-arrow-up-outline" xmlns="http://www.w3.org/2000/svg" d="m253.01 239.46h193.98c5.0078-0.003906 9.6367-2.668 12.152-7 2.5234-4.3281 2.5234-9.6758 0-14l-96.992-168.06c-2.5156-4.3281-7.1445-6.9922-12.152-6.9922s-9.6367 2.6641-12.152 6.9922l-96.992 168c-2.5234 4.3281-2.5234 9.6758 0 14 2.5 4.3555 7.1328 7.043 12.152 7.0586zm96.992-154.06 72.801 126.06h-145.6z"/> 6199 <path class='table-sort-arrow-down-solid' d='m446.99 320.54h-193.98c-5.0078 0.003906-9.6367 2.668-12.152 7-2.5234 4.3281-2.5234 9.6758 0 14l96.992 168.06c2.5156 4.3281 7.1445 6.9922 12.152 6.9922s9.6367-2.6641 12.152-6.9922l96.992-168c2.5234-4.3281 2.5234-9.6758 0-14-2.5-4.3555-7.1328-7.043-12.152-7.0586z'/> 6200 <path class="table-sort-arrow-down-outline" xmlns="http://www.w3.org/2000/svg" d="m446.99 320.54h-193.98c-5.0078 0.003906-9.6367 2.668-12.152 7-2.5234 4.3281-2.5234 9.6758 0 14l96.992 168.06c2.5156 4.3281 7.1445 6.9922 12.152 6.9922s9.6367-2.6641 12.152-6.9922l96.992-168c2.5234-4.3281 2.5234-9.6758 0-14-2.5-4.3555-7.1328-7.043-12.152-7.0586zm-96.992 154.06-72.801-126.06h145.6z"/> 6201 </svg> 6202 </button> 6203 `; 6204 } 6205 else { 6206 header.innerHTML = `
6207 <span class="table-header-notsortable"> 6208 ${header.innerHTML} 6209 </span> 6210 `; 6211 } 6212 } 6213 6214 6215 6216 } 6217 }); 6218 6219 // <input type="button" value="1" class="pagenumber" /> 6220 if (table.closest('.enablepagination')) { 6221 //add pagination controls 6222 const paginationMarkup = `<div class="tablemobilecontainer"><div class="outerpagination"> 6223 6224 6225 <div class="leftSide"> 6226 <span class="rowRange"></span><span> of </span><span class="totalPages"></span> 6227 <span class="viewAllPages"> 6228 <button style="color: var(--bs-primary); cursor: pointer; font-weight: 700; padding: 0 24px; border: none; background: none;" class="tableNavBtn">Show all rows</button> 6229 </span> 6230 </div> 6231 6232 <div class="rightSide"> 6233 <button class="pageButton outline-none button_prev" style="color: var(--bs-primary); cursor: pointer; display: inline; border: none; background: none;"> 6234 <span class="tableNavBtn"> <span style="transform: rotate(3.142rad); position: relative; top: 7px; text-decoration: none;" class="material-icons"></span>Previous</span> 6235 </button> 6236 <input type="button" value="1" class="pagenumber" /> 6237 <ul class="paginationButtons list-unstyled"></ul> 6238 <button class="pageButton outline-none button_next" style="color: var(--bs-primary); cursor: pointer; border: none; background: none;"> 6239 <span class="tableNavBtn">Next<span style="position: relative; top: 7px; text-decoration: none;" class="material-icons"></span></button> 6240 6241 </span> 6242 </div> 6243 6244 </div></div>` 6245 6246 table.insertAdjacentHTML('afterend', paginationMarkup); 6247 6248 //add copy of table data 6249 const tablecopy = `<table class='tableCopy' style='display: none !important'></table>`; 6250 const elementsArray = Array.from(rowwwsss); 6251 let txt = ""; 6252 for (let i = 0; i < elementsArray.length; i++) { 6253 txt = txt + `<tr>${elementsArray[i].innerHTML}</tr>` 6254 } 6255 table.insertAdjacentHTML('afterend', tablecopy); 6256 table.closest('.table-ultimate-wrap').querySelector('.tableCopy').innerHTML = txt; 6257 6258 //initiate table pagination of rows 6259 // const page_number = 1; 6260 // const page_size = 2 6261 loadTableData(table, rowwwsss, page_size, page_number); 6262 renderPagination(table, rowwwsss, page_size, page_number); 6263 slimpageButtons(table, rowwwsss, page_size, page_number) 6264 } 6265 6266 6267 } 6268 } 6269 } 6270} 6271 6272 6273/** 6274 * Clears all active sorting states. 6275 * 6276 * Removes: 6277 * - Sort direction classes 6278 * - aria-sort attributes 6279 */ 6280 6281 6282function clearSorting(table) { 6283 let headers = table.querySelectorAll('th'); 6284 for (let i = 0; i < headers.length; i++) { 6285 if (headers[i].classList.contains("table-sort-head")) { 6286 headers[i].setAttribute('class', 'table-sort-head'); 6287 headers[i].removeAttribute('aria-sort'); 6288 } 6289 } 6290} 6291 6292 6293/** 6294 * Updates row count label 6295 */ 6296 6297 6298function setRowRange(table, rowwwsss, page_size, page_number) { 6299 var totalrows = rowwwsss.length; 6300 var parentTableDiv = table.closest('.enablepagination'); 6301 parentTableDiv.querySelector('.totalPages').innerHTML = totalrows + ' rows'; 6302 6303} 6304 6305 6306/** 6307 * Displays currently visible row range. 6308 */ 6309 6310 6311function setVisibleRowNumber(table, rowwwsss, page_size, page_number) { 6312 var parentTableDiv = table.closest('.enablepagination'); 6313 if (table.closest('div').querySelector('.pagenumber').value > 1) { 6314 parentTableDiv.querySelector('.rowRange').innerHTML = (table.closest('div').querySelector('.pagenumber').value * page_size - (page_size - 1)) + ' - ' + ((table.closest('div').querySelector('.pagenumber').value * page_size - page_size) + parentTableDiv.querySelector('tbody').querySelectorAll('tr').length); 6315 } 6316 else { 6317 parentTableDiv.querySelector('.rowRange').innerHTML = '1' + ' - ' + (parentTableDiv.querySelector('tbody').querySelectorAll('tr').length); 6318 } 6319 6320} 6321 6322 6323/** 6324 * Limits visible page number buttons. 6325 * 6326 * Prevents rendering every page button when 6327 * there are large numbers of pages. 6328 */ 6329 6330 6331function slimpageButtons(table, rowwwsss, page_size, page_number) { 6332 const pageButtonArray = Array.from(table.closest('.table-ultimate-wrap').querySelectorAll('.pageButtonNumber')); 6333 const pageNumber = table.closest('div').querySelector('.pagenumber').value; 6334 6335 for (let i = 0; i < pageButtonArray.length; i++) { 6336 pageButtonArray[i].classList.add('hidepageButton'); 6337 } 6338 6339 table.closest('div').querySelector('.button_prev').querySelector('.tableNavBtn').classList.remove('disabled'); 6340 table.closest('div').querySelector('.button_next').querySelector('.tableNavBtn').classList.remove('disabled'); 6341 6342 table.closest('div').querySelector('.button_prev').setAttribute('aria-disabled', false); 6343 table.closest('div').querySelector('.button_next').setAttribute('aria-disabled', false); 6344 6345 if (pageNumber == 1) { 6346 if (pageButtonArray[0] && pageButtonArray[0].classList.contains('hidepageButton')) { 6347 pageButtonArray[0].classList.remove('hidepageButton'); 6348 } 6349 6350 if (pageButtonArray[1] && pageButtonArray[1].classList.contains('hidepageButton')) { 6351 pageButtonArray[1].classList.remove('hidepageButton'); 6352 } 6353 6354 if (pageButtonArray[2] && pageButtonArray[2].classList.contains('hidepageButton')) { 6355 pageButtonArray[2].classList.remove('hidepageButton'); 6356 } 6357 6358 // pageButtonArray[1].classList.remove('hidepageButton'); 6359 // pageButtonArray[2].classList.remove('hidepageButton'); 6360 table.closest('div').querySelector('.button_prev').querySelector('.tableNavBtn').classList.add('disabled'); 6361 table.closest('div').querySelector('.button_prev').setAttribute('aria-disabled', true); 6362 } 6363 if (pageNumber > 1) { 6364 if (pageButtonArray[pageNumber - 2] && pageButtonArray[pageNumber - 2].classList.contains('hidepageButton')) { 6365 pageButtonArray[pageNumber - 2].classList.remove('hidepageButton'); 6366 } 6367 6368 if (pageButtonArray[pageNumber - 1] && pageButtonArray[pageNumber - 1].classList.contains('hidepageButton')) { 6369 pageButtonArray[pageNumber - 1].classList.remove('hidepageButton'); 6370 } 6371 6372 6373 // pageButtonArray[pageNumber - 1].classList.remove('hidepageButton'); 6374 if (pageButtonArray[pageNumber]) { 6375 6376 if (pageButtonArray[pageNumber] && pageButtonArray[pageNumber].classList.contains('hidepageButton')) { 6377 pageButtonArray[pageNumber].classList.remove('hidepageButton'); 6378 } 6379 // pageButtonArray[pageNumber].classList.remove('hidepageButton'); 6380 } 6381 if (pageButtonArray[pageButtonArray.length - 1].innerHTML == pageNumber) { 6382 6383 if (pageButtonArray[pageNumber - 3] && pageButtonArray[pageNumber - 3].
6383classList.contains('hidepageButton')) { 6384 pageButtonArray[pageNumber - 3].classList.remove('hidepageButton'); 6385 } 6386 // pageButtonArray[pageNumber - 3].classList.remove('hidepageButton'); 6387 } 6388 6389 if (pageButtonArray.length == pageNumber) { 6390 table.closest('div').querySelector('.button_next').querySelector('.tableNavBtn').classList.add('disabled'); 6391 table.closest('div').querySelector('.button_next').setAttribute('aria-disabled', true); 6392 } 6393 } 6394} 6395 6396 6397/** 6398 * Creates pagination controls and registers 6399 * page button click handlers. 6400 * 6401 * Responsibilities: 6402 * - Calculate total pages 6403 * - Create numbered page buttons 6404 * - Set selected page 6405 * - Refresh visible row ranges 6406 */ 6407 6408 6409function renderPagination(table, rowwwsss, page_size, page_number) { 6410 //set total number of pages 6411 var totalpagecount = rowwwsss.length / page_size; 6412 if (totalpagecount > Math.floor(totalpagecount)) { 6413 totalpagecount = Math.floor(totalpagecount) + 1; 6414 } 6415 else { 6416 totalpagecount = Math.floor(totalpagecount); 6417 } 6418 // var totalrows = rowwwsss.length; 6419 // var parentTableDiv = table.closest('.enablepagination'); 6420 // parentTableDiv.querySelector('.totalPages').innerHTML = totalrows + ' rows'; 6421 setRowRange(table, rowwwsss, page_size, page_number); 6422 6423 table.closest('.table-ultimate-wrap').querySelector('.paginationButtons').innerHTML = ""; 6424 6425 for (let i = 0; i < totalpagecount; i++) { 6426 var pagebutton = `<li style="display: inline;"> <button class="pageButtonNumber class` + i + `" style="display: inline; padding: 10px 12px;">` + (i + 1) + `</button></li>`; 6427 var pagebuttonFirst = `<li style="display: inline;"> <button class="pageButtonNumber selectedPageNumber class` + i + `" style="display: inline; padding: 10px 12px;">` + (i + 1) + `</button></li>`; 6428 6429 if (i == 0) { 6430 table.closest('.table-ultimate-wrap').querySelector('.paginationButtons').innerHTML += pagebuttonFirst; 6431 } 6432 else { 6433 table.closest('.table-ultimate-wrap').querySelector('.paginationButtons').innerHTML += pagebutton; 6434 } 6435 6436 6437 } 6438 6439 6440 const pageButtonArray = Array.from(table.closest('.table-ultimate-wrap').querySelectorAll('.pageButtonNumber')); 6441 6442 6443 6444 for (let xyb = 0; xyb < pageButtonArray.length; xyb++) { 6445 pageButtonArray[xyb].addEventListener('click', function (e) { 6446 const selectedButtons = table.closest('.table-ultimate-wrap').querySelectorAll('.selectedPageNumber') 6447 for (let x = 0; x < selectedButtons.length; x++) { 6448 selectedButtons[x].classList.remove('selectedPageNumber'); 6449 } 6450 changeTableData(table, rowwwsss, page_size, xyb + 1); 6451 const currentPage = table.closest('div').querySelector('.pagenumber').value; 6452 table.closest('div').querySelector('.pagenumber').value = e.target.innerHTML; 6453 e.target.classList.add('selectedPageNumber'); 6454 6455 6456 6457 // var parentTableDiv = table.closest('.enablepagination'); 6458 // if (table.closest('div').querySelector('.pagenumber').value > 1) { 6459 // parentTableDiv.querySelector('.rowRange').innerHTML = (table.closest('div').querySelector('.pagenumber').value * page_size - (page_size - 1)) + ' - ' + ((table.closest('div').querySelector('.pagenumber').value * page_size - page_size) + parentTableDiv.querySelector('tbody').querySelectorAll('tr').length); 6460 // } 6461 // else { 6462 // parentTableDiv.querySelector('.rowRange').innerHTML = '1' + ' - ' + (parentTableDiv.querySelector('tbody').querySelectorAll('tr').length); 6463 // } 6464 setVisibleRowNumber(table, rowwwsss, page_size, page_number); 6465 slimpageButtons(table, rowwwsss, page_size, page_number); 6466 6467 }) 6468 } 6469 6470 setVisibleRowNumber(table, rowwwsss, page_size, page_number); 6471 slimpageButtons(table, rowwwsss, page_size, page_number); 6472 6473 6474} 6475 6476 6477/** 6478 * Removes selected styling from all 6479 * pagination buttons. 6480 */ 6481 6482function clearSelectedPageNumbers(table, rowwwsss, page_size, page_number) { 6483 const selectedButtons = table.closest('.table-ultimate-wrap').querySelectorAll('.selectedPageNumber') 6484 for (let x = 0; x < selectedButtons.length; x++) { 6485 selectedButtons[x].classList.remove('selectedPageNumber'); 6486 } 6487} 6488 6489 6490/** 6491 * Loads the initial page of rows into the table. 6492 * 6493 * Also registers: 6494 * - Previous button 6495 * - Next button 6496 * - View All button 6497 * - Search button 6498 */ 6499 6500 6501function loadTableData(table, rowwwsss, page_size, page_number) { 6502 6503 // renderPagination(table, rowwwsss, page_size, page_number) 6504 6505 const elementsArray = Array.from(rowwwsss); 6506 6507 var movieDatap = elementsArray.slice((page_number - 1) * page_size, page_number * page_size); 6508 let txt = ""; 6509 for (let i = 0; i < movieDatap.length; i++) { 6510 txt = txt + `<tr>${movieDatap[i].innerHTML}</tr>` 6511 } 6512 6513 table.querySelector('tbody').innerHTML = txt; 6514 // const paginationMarkup = `<div class="pagination"> 6515 // <div class="pagination-block">
6516 // <span class="pageButton outline-none button_prev">Prev</span> 6517 // <input type="button" value="1" class="pagenumber" /> 6518 // <span class="pageButton outline-none button_next">Next</span> 6519 // </div> 6520 // </div>` 6521 // table.insertAdjacentHTML('afterend', paginationMarkup); 6522 setVisibleRowNumber(table, rowwwsss, page_size, page_number); 6523 6524 //pagination previous 6525 table.closest('div').querySelector('.button_prev').addEventListener('click', function (e) { 6526 let chipfilter = table.closest('.table-ultimate-wrap').querySelector('.chip-item-wrap'); 6527 var value = parseInt(table.closest('div').querySelector('.pagenumber').value); 6528 value = isNaN(value) ? 0 : value; 6529 clearSorting(table); 6530 6531 6532 if (value > 1) { 6533 value--; 6534 table.closest('div').querySelector('.pagenumber').value = value; 6535 6536 // const selectedButtons = table.closest('.table-ultimate-wrap').querySelectorAll('.selectedPageNumber') 6537 // for (let x = 0; x < selectedButtons.length; x++) { 6538 // selectedButtons[x].classList.remove('selectedPageNumber'); 6539 // } 6540 clearSelectedPageNumbers(table, rowwwsss, page_size, page_number); 6541 6542 6543 if (chipfilter) { 6544 changeTableData(table, rowwwsss, rowwwsss.length, 1); 6545 filterTable(true); 6546 6547 var rowswithhead = table.querySelectorAll('tr:not(.d-none)'); 6548 6549 6550 //var searchrows = Array.from(rowswithhead).slice(1); 6551 6552 var searchrows = Array.from(rowswithhead); 6553 if (searchrows[0].firstChild.nodeName == "TH") { 6554 searchrows = searchrows.slice(1); 6555 } 6556 6557 changeTableData(table, searchrows, page_size, value); 6558 } 6559 else { 6560 changeTableData(table, rowwwsss, page_size, value); 6561 } 6562 6563 var className = '.class' + (value - 1); 6564 const selectedNumberTile = table.closest('div').querySelector(className); 6565 selectedNumberTile.classList.add('selectedPageNumber'); 6566 setVisibleRowNumber(table, rowwwsss, page_size, page_number); 6567 } 6568 slimpageButtons(table, rowwwsss, page_size, page_number); 6569 }); 6570 6571 //pagination next 6572 table.closest('div').querySelector('.button_next').addEventListener('click', function (e) { 6573 let chipfilter = table.closest('.table-ultimate-wrap').querySelector('.chip-item-wrap'); 6574 var value = parseInt(table.closest('div').querySelector('.pagenumber').value); 6575 value = isNaN(value) ? 0 : value; 6576 clearSorting(table); 6577 6578 var xyz = rowwwsss.length 6579 if (value * page_size < rowwwsss.length) { 6580 value++; 6581 table.closest('div').querySelector('.pagenumber').value = value; 6582 6583 // const selectedButtons = table.closest('.table-ultimate-wrap').querySelectorAll('.selectedPageNumber') 6584 // for (let x = 0; x < selectedButtons.length; x++) { 6585 // selectedButtons[x].classList.remove('selectedPageNumber'); 6586 // } 6587 clearSelectedPageNumbers(table, rowwwsss, page_size, page_number); 6588 6589 6590 if (chipfilter) { 6591 changeTableData(table, rowwwsss, rowwwsss.length, 1); 6592 filterTable(true); 6593 6594 var rowswithhead = table.querySelectorAll('tr:not(.d-none)'); 6595 //var searchrows = Array.from(rowswithhead).slice(1); 6596 6597 var searchrows = Array.from(rowswithhead); 6598 if (searchrows[0].firstChild.nodeName == "TH") { 6599 searchrows = searchrows.slice(1); 6600 } 6601 6602 6603 //if (searchrows.length - page_size * value >= 0 - page_size) { 6604 if (page_size * value <= searchrows.length + (page_size - 1)) { 6605 changeTableData(table, searchrows, page_size, value); 6606 } 6607 else { 6608 value--; 6609 table.closest('div').querySelector('.pagenumber').value = value; 6610 changeTableData(table, searchrows, page_size, value); 6611 } 6612 } 6613 else { 6614 changeTableData(table, rowwwsss, page_size, value); 6615 } 6616 6617 var className = '.class' + (value - 1); 6618 const selectedNumberTile = table.closest('div').querySelector(className); 6619 selectedNumberTile.classList.add('selectedPageNumber'); 6620 setVisibleRowNumber(table, rowwwsss, page_size, page_number); 6621 6622 6623 } 6624 slimpageButtons(table, rowwwsss, page_size, page_number); 6625 }); 6626 6627 //pagination view all rows 6628 table.closest('div').querySelector('.viewAllPages').addEventListener('click', function (e) { 6629 // setRowRange(table, rowwwsss, page_size, page_number); 6630 clearSorting(table); 6631 const tableDivBody = e.currentTarget.closest('.table-ultimate-wrap').querySelector('table.table-el tbody'); 6632 const tableCopyBody = e.currentTarget.closest('.table-ultimate-wrap').querySelector('table.tableCopy tbody'); 6633 tableDivBody.innerHTML = tableCopyBody.innerHTML; 6634 e.currentTarget.closest('.table-ultimate-wrap').querySelector('.chip-container-wrap').innerHTML = ``; 6635 e.currentTarget.closest('.table-ultimate-wrap').querySelector('.search-table-relative-searchterms').innerHTML = ``; 6636 e.currentTarget.closest('.table-ultimate-wrap').querySelector('.pagenumber').value = 1; 6637 6638 //set total number of pages 6639 var totalpagecount = rowwwsss.length / page_size; 6640 if (totalpagecount > Math.floor(totalpagecount)) { 6641 totalpagecount = Math.floor(totalpagecount) + 1; 6642 } 6643 else { 6644 totalpagecount = Math.floor(totalpagecount); 6645 } 6646 // var parentTableDiv = table.closest('.enablepagination'); 6647 // parentTableDiv.querySelector('.totalPages').innerHTML = totalpagecount; 6648 clearSelectedPageNumbers(table, rowwwsss, page_size, page_number) 6649 setRowRange(table, rowwwsss, page_size, page_number); 6650 e.currentTarget.closest('.table-ultimate-wrap').querySelector('.rowRange').innerHTML = '1 - ' + e.currentTarget.closest('.table-ultimate-wrap').querySelector('.totalPages').innerHTML; 6651 renderPagination(table, tableCopyBody.querySelectorAll("tr"), page_size, page_number); 6652 slimpageButtons(table, rowwwsss, page_size, page_number); 6653 }); 6654 6655 table.closest('.table-ultimate-wrap').querySelector('.search-table-button').addEventListener('click', function (e) { 6656 clearSorting(table); 6657 changeTableData(table, rowwwsss, rowwwsss.length, 1); 6658 6659 6660 6661 }); 6662 6663 6664} 6665 6666 6667 6668 6669 6670 6671let searchTermChipContainer, searchTableFilter, relativeSearchTerms; 6672let relativeSearchTermsArr = []; 6673let getRelativeTableClass; 6674 6675
6676/** 6677 * Handles search form submission. 6678 * 6679 * Converts entered search terms into: 6680 * - Search chips 6681 * - Active filter criteria 6682 */ 6683 6684 6685function handleSearchTableSubmit(e) { 6686 console.time('Function #1'); 6687 e.preventDefault(); 6688 6689 getRelativeTableClass = e.target.closest(".searchable-table-wrapper"); 6690 6691 let input = getRelativeTableClass.querySelector(".search-table-input"); 6692 let filter = input.value.toLowerCase().replace(/ +(?= )/gmi, '').trim(); 6693 filter = filter.replace(/[<>]/gmi, ''); 6694 6695 if (input.value) { 6696 searchTermChipContainer = getRelativeTableClass.querySelector(".chip-container-table-wrap"); 6697 searchTableFilter = getRelativeTableClass.querySelector(".table-filter"); 6698 6699 const createdDivElement = document.createElement('div'); 6700 createdDivElement.classList.add('random-cls'); 6701 createdDivElement.innerHTML = filter; 6702 6703 relativeSearchTerms = getRelativeTableClass.querySelector(".search-table-relative-searchterms").innerHTML; 6704 6705 getRelativeTableClass.querySelector(".search-table-relative-searchterms").appendChild(createdDivElement); 6706 6707 relativeSearchTermsArr = Array.prototype.slice.call(getRelativeTableClass.querySelector(".search-table-relative-searchterms").getElementsByClassName('random-cls')).map(function (x) { return x.innerHTML.toLowerCase().replace(/ +(?= )/gmi, '').trim() }); 6708 6709 renderItem(); 6710 filterTable(); 6711 slimpageButtons(getRelativeTableClass); 6712 input.value = ""; 6713 } 6714 6715 console.timeEnd('Function #1'); 6716 6717 6718} 6719 6720 6721/** 6722 * Removes a search chip and reruns filtering. 6723 */ 6724 6725function handleSearchTableChipXclick(e) { 6726 let index; 6727 6728 if (e.currentTarget.closest('.table-ultimate-wrap').querySelector('.enablepagination')) { 6729 //reset table data to original for pagination 6730 const tableDivBody = e.currentTarget.closest('.table-ultimate-wrap').querySelector('table.table-el tbody'); 6731 const tableCopyBody = e.currentTarget.closest('.table-ultimate-wrap').querySelector('table.tableCopy tbody'); 6732 tableDivBody.innerHTML = tableCopyBody.innerHTML; 6733 tableDivBody.closest('div').querySelector('.pagenumber').value = 1; 6734 slimpageButtons(e.target.closest('.table-ultimate-wrap').querySelector('table')); 6735 } 6736 6737 6738 if (e.currentTarget.classList.contains("search-remove-chip")) { 6739 getRelativeTableClass = e.currentTarget.closest(".searchable-table-wrapper"); 6740 6741 searchTermChipContainer = getRelativeTableClass.querySelector(".chip-container-table-wrap"); 6742 searchTableFilter = getRelativeTableClass.querySelector(".table-filter"); 6743 6744 relativeSearchTermsArr = Array.prototype.slice.call(getRelativeTableClass.querySelector(".search-table-relative-searchterms").getElementsByClassName('random-cls')).map(function (x) { return x.innerHTML.toLowerCase().replace(/ +(?= )/gmi, '').trim() }); 6745 6746 let currentRemoveChipLi = e.currentTarget.closest(".chip-item-wrap"); 6747 6748 index = relativeSearchTermsArr.indexOf(currentRemoveChipLi.querySelector('span').innerText); 6749 6750 // console.log(index); 6751 6752 if (index > -1) { 6753 // console.log("index is greater than -1"); 6754 relativeSearchTermsArr.splice(index, 1); 6755 // console.log(relativeSearchTermsArr); 6756 } 6757 6758 getRelativeTableClass.querySelector(".search-table-relative-searchterms").innerHTML = ""; 6759 6760 relativeSearchTermsArr.forEach(element => { 6761 const createdDivvElementt = document.createElement('div'); 6762 createdDivvElementt.classList.add('random-cls'); 6763 createdDivvElementt.innerHTML = element; 6764 getRelativeTableClass.querySelector(".search-table-relative-searchterms").appendChild(createdDivvElementt); 6765 }); 6766 6767 // console.log(getRelativeTableClass.querySelector(".search-table-relative-searchterms").innerHTML); 6768 6769 // //pagination 6770 // let tableDiv = e.target.closest('.table-ultimate-wrap'); 6771 // tableDiv.querySelector('.pagenumber').value = 1; 6772 // var rowswithhead = tableDiv.querySelectorAll('tr:not(.d-none)'); 6773 // var searchrows = Array.from(rowswithhead); 6774 // searchrows = searchrows.slice(1); 6775 // changeTableData(tableDiv.querySelector('table'), searchrows, page_size, 1, true); 6776 6777 6778 renderItem(); 6779 filterTable(); 6780 6781 6782 6783 if (searchTermChipContainer.innerHTML === "") { 6784 searchTermChipContainer.innerHTML = ""; 6785 } 6786 } 6787 6788} 6789 6790 6791/** 6792 * Renders active filter chips. 6793 * 6794 */ 6795 6796function renderItem() { 6797 let nHTML = ""; 6798 let localSearchTermChipContainer = searchTermChipContainer; 6799 6800 if (relativeSearchTermsArr.length > 0) { 6801 nHTML += `<div class="chip-container-wrap-inner pb-3">`; 6802 6803 relativeSearchTermsArr.forEach(item => { 6804 nHTML += ` 6805 <div class="chip-item-wrap">
6806 <span>${item}</span> 6807 <button data-tablesearchchip-remove class="search-remove-chip table-removechip-icon" aria-label="remove ${item} filter"> 6808 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 6809 <path d="M38 12.83L35.17 10 24 21.17 12.83 10 10 12.83 21.17 24 10 35.17 12.83 38 24 26.83 35.17 38 38 35.17 26.83 24z"></path> 6810 </svg> 6811 </button> 6812 </div> 6813 `; 6814 }); 6815 6816 nHTML += `</div>`; 6817 } 6818 6819 localSearchTermChipContainer.innerHTML = nHTML; 6820 6821 let tableSearchChipRemoval = document.querySelectorAll('[data-tablesearchchip-remove]'); 6822 tableSearchChipRemoval.forEach(element => { 6823 element.addEventListener('click', handleSearchTableChipXclick); 6824 }); 6825} 6826 6827 6828/** 6829 * Filters table rows based on all active 6830 * search chips. 6831 * 6832 * Logic: 6833 * Row remains visible only if it contains 6834 * EVERY active search term. 6835 */ 6836 6837function filterTable(notNewSearch) { 6838 let table = searchTableFilter; 6839 let trElement = table.querySelectorAll("tr"); 6840 console.log(trElement); 6841 // let result = true; 6842 6843 for (let i = 0; i < trElement.length; i++) { 6844 trElement[i].classList.remove('d-none'); 6845 // reset result value 6846 // result = true; 6847 6848 let trInnerText = trElement[i].innerText.replace(/\r?\n|\r/gmi, ""); 6849 trInnerText = trInnerText.replace(/\s+/g, ' ').trim(); 6850 // console.log(trInnerText); 6851 6852 if (trInnerText && relativeSearchTermsArr.length) { 6853 // Using javascript label to break out of loop if search term was found in array 6854 tablesearchtermfor: 6855 for (let j = 0; j < relativeSearchTermsArr.length; j++) { 6856 // console.log(trInnerText.toLowerCase().indexOf(relativeSearchTermsArr[j])); 6857 if (trInnerText.toLowerCase().indexOf(relativeSearchTermsArr[j]) < 0) { 6858 // result = false;
6859 trElement[i].classList.add('d-none'); 6860 break tablesearchtermfor; 6861 } 6862 } 6863 // console.log(result); 6864 } 6865 } 6866 6867 6868 let tHeadTr = document.querySelectorAll("thead tr"); 6869 for (let i = 0; i < tHeadTr.length; i++) { 6870 tHeadTr[i].classList.remove('d-none'); 6871 } 6872 6873 //pagination 6874 if (!notNewSearch) { 6875 table.closest('div').querySelector('.pagenumber').value = 1; 6876 var rowswithhead = table.querySelectorAll('tr:not(.d-none)'); 6877 var searchrows = Array.from(rowswithhead); 6878 searchrows = searchrows.slice(1); 6879 var value = parseInt(table.closest('div').querySelector('.pagenumber').value); 6880 changeTableData(table, searchrows, page_size, 1); 6881 6882 //set total number of pages 6883 // var totalpagecount = Math.floor(searchrows.length/page_size); 6884 // var parentTableDiv = table.closest('.enablepagination'); 6885 // parentTableDiv.querySelector('.totalPages').innerHTML = totalpagecount; 6886 6887 //set total number of pages 6888 var totalpagecount = searchrows.length / page_size; 6889 if (totalpagecount > Math.floor(totalpagecount)) { 6890 totalpagecount = Math.floor(totalpagecount) + 1; 6891 } 6892 else { 6893 totalpagecount = Math.floor(totalpagecount); 6894 } 6895 var parentTableDiv = table.closest('.enablepagination'); 6896 parentTableDiv.querySelector('.totalPages').innerHTML = totalpagecount; 6897 6898 renderPagination(table, searchrows, page_size, 1); 6899 6900 } 6901} 6902 6903function changeTableData(table, rowwwsss, page_size, page_number) { 6904 // table.closest('div').querySelector('.pagenumber').value = 1; 6905 const elementsArray = Array.from(rowwwsss); 6906 6907 6908 //if (rowwwsss.length <= page_size * page_number) { 6909 var movieDatap = elementsArray.slice((page_number - 1) * page_size, page_number * page_size); 6910 let txt = ""; 6911 for (let i = 0; i < movieDatap.length; i++) { 6912 txt = txt + `<tr>${movieDatap[i].innerHTML}</tr>` 6913 } 6914 6915 let body = table.querySelector("table"); 6916 table.querySelector('tbody').innerHTML = txt; 6917 6918 // } 6919 // else { 6920 // var value = parseInt(table.closest('div').querySelector('.pagenumber').value); 6921 // value--; 6922 // } 6923 6924 6925} 6926 6927let searchTableFormTag = document.querySelectorAll(".search-table-form"); 6928 6929if (searchTableFormTag) { 6930 for (let i = 0; i < searchTableFormTag.length; i++) { 6931 searchTableFormTag[i].addEventListener("submit", handleSearchTableSubmit); 6932 } 6933} 6934 6935/*========== Table Sorting ==========*/ 6936 6937 6938/** 6939 * Sorts a table by the selected column. 6940 * 6941 * Supports: 6942 * - Ascending 6943 * - Descending 6944 * - Text values 6945 * - Numeric values 6946 * 6947 * Updates accessibility attributes: 6948 * aria-sort="ascending|descending" 6949 */ 6950 6951 6952function sortTable(e) { 6953 // console.log("button clicked. Sort Table Funct running"); 6954 // console.log("e: ", e); 6955 // console.log("e.target: ", e.target); 6956 6957 let element = e.target.closest('button'); 6958 // console.log("element: ", element); 6959 6960 if (element.classList.contains("sortable-fast") || element.closest(".sortable-fast")) { 6961 // console.log("button clicked. Sort Table Funct running"); 6962 let down_class = "dir-d"; 6963 let up_class = "dir-u"; 6964 6965 function reClassify(element, dir) { 6966 if (dir === "") { 6967 // Reset 6968 element.classList.remove('dir-d'); 6969 element.classList.remove('dir-u'); 6970 } else if (dir === "dir-u") { 6971 element.classList.remove('dir-d'); 6972 element.classList.add('dir-u'); 6973 } else if (dir === "dir-d") { 6974 element.classList.add('dir-d'); 6975 element.classList.remove('dir-u'); 6976 } 6977 } 6978 6979 function getValue(element) { 6980
6981 ///////// 6982 // DATES 6983 ///////// 6984 6985 // If it's a date, parse it and pass the seconds integer value instead 6986 // if (element.closest('[data-date-parse]')) { 6987 // return parseInt(element.closest('[data-date-parse]').getAttribute('data-date-parse')); 6988 // } 6989 // if (element.closest('.table-cell-invalid-date')) { 6990 // // Year 4000 6991 // return 64060610400000; 6992 // } 6993 6994 ///////// 6995 // ABC's 6996 ///////// 6997 6998 6999 7000 if (element.innerText.trim() === "" && element.querySelector('svg') && element.querySelector('svg').getAttribute('aria-label') !== "") { 7001 return element.querySelector('svg').getAttribute('aria-label').toString(); 7002 } 7003 7004 // If you aren't using data-sort and want to make it just the tiniest bit smaller/faster 7005 // comment this line and uncomment the next one 7006 // return element.getAttribute('data-sort') || element.innerText 7007 return element.innerText.trim(); 7008 } 7009 7010 try { 7011 let tr = element.closest("tr"); 7012 let th = element.closest("th"); 7013 let table = element.closest("table"); 7014 7015 if (table.classList.contains("table-sort")) { 7016 let column_index; 7017 let nodes = tr.cells; 7018 7019 // reset thead cells and get column index 7020 for (let i = 0; i < nodes.length; i++) { 7021 if (nodes[i] === th) { 7022 column_index = i; 7023 } else { 7024 reClassify(nodes[i], ""); 7025 } 7026 } 7027 7028 let dir = up_class; 7029 7030 // check if we're sorting up or down, and update the css accordingly 7031 if (th.className.indexOf(up_class) !== -1) { 7032 dir = down_class; 7033 } 7034 7035 reClassify(th, dir); 7036 7037 // extract all table rows, so the sorting can start. 7038 let org_tbody = table.tBodies[0]; 7039 7040 // get the rows in an array, so we can sort them... 7041 let rowsArray = [].slice.call(org_tbody.rows, 0); 7042 // console.log("rowsArray: ", rowsArray); 7043 7044 let reverse = dir === down_class; 7045 7046 // Remove all aria-sorts 7047 let allTableTHs = tr.querySelectorAll("th"); 7048 for (let i = 0; i < allTableTHs.length; i++) { 7049 allTableTHs[i].removeAttribute("aria-sort"); 7050 } 7051 7052 // Add back in correct aria-sort 7053 if (dir === up_class) { 7054 // add aria sorting attribute for ascending 7055 th.setAttribute("aria-sort", "ascending"); 7056 } else if (dir === down_class) { 7057 // add aria sorting attribute for descending 7058 th.setAttribute("aria-sort", "descending"); 7059 } 7060 7061 // sort them using custom built in array sort. 7062 rowsArray.sort((a, b) => { 7063 let x = getValue((reverse ? b : a).cells[column_index]); 7064 let y = getValue((reverse ? a : b).cells[column_index]); 7065 return isNaN(x - y) ? x.localeCompare(y) : x - y; 7066 }); 7067 7068 // Make a clone without content 7069 let clone_tbody = org_tbody.cloneNode(); 7070 7071 // Build a sorted table body and replace the old one. 7072 while (rowsArray.length) { 7073 clone_tbody.appendChild(rowsArray.splice(0, 1)[0]); 7074 } 7075 7076 // And finally insert the end result 7077 table.replaceChild(clone_tbody, org_tbody); 7078 } 7079 } catch (error) { 7080 console.error("sortTable(" + e + "):", error); 7081 } 7082 } 7083} 7084 7085 7086/** 7087 * Finds all sortable table header buttons 7088 * and attaches click handlers. 7089 */ 7090 7091let findAndRunSortableTablesOnPage = () => { 7092 let sortableFast = document.querySelectorAll(".sortable-fast"); 7093 7094 for (let s = 0; s < sortableFast.length; s++) { 7095 sortableFast[s].addEventListener("click", sortTable); 7096 } 7097} 7098 7099 7100 7101findAndRunSortableTablesOnPage(); 7102 7103 7104/* 7105 * Initialize table enhancements after page load. 7106 * 7107 * Delay allows author-generated markup 7108 * to finish rendering before conversion. 7109 */ 7110 7111 7112setTimeout(function () { 7113 convertRichTextTable(); 7114 changeUltimateTables(); 7115 findAndRunSortableTablesOnPage(); 7116}, 1000); 7117/******************* 7118 ** YouTube Wall - VANILLA JS ** 7119 *******************/ 7120// console.log("YouTube Wall JS running..."); 7121 7122let ytWallWrap = document.querySelector('[data-ytwall]'); 7123let ytWallWrapBackup = document.querySelector('[data-ytwall-backup]'); 7124 7125if (ytWallWrapBackup) { 7126 // console.log("ytWallWrapBackup running..."); 7127 7128 let ytWallWraps = document.querySelectorAll('[data-ytwall-backup]'); 7129 // console.log(ytWallWraps); 7130 7131 //https://stackoverflow.com/questions/3452546/how-do-i-get-the-youtube-video-id-from-a-url 7132 let rx = /^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/; 7133 7134 for (let i = 0; i < ytWallWraps.length; i++) { 7135 let ytWallItemWrappers = ytWallWraps[i].querySelectorAll(".yt-wall-item-wrap"); 7136 // console.log(ytWallItemWrappers); 7137 let rootYtWallVideoObj = []; 7138 7139 for (let j = 0; j < ytWallItemWrappers.length; j++) { 7140 let ytWallAlinkCurrent = ytWallItemWrappers[j].querySelector('.yt-wall-video-url').href; 7141 7142 let ytWallVidTranscriptLink = null; 7143 7144 if(ytWallItemWrappers[j].querySelector('.yt-wall-item-transcriptlink-wrap')) { 7145 ytWallVidTranscriptLink = ytWallItemWrappers[j].querySelector('.yt-wall-item-transcriptlink-wrap a').href; 7146 } else { 7147 ytWallVidTranscriptLink = null; 7148 } 7149 7150 let r = ytWallAlinkCurrent.match(rx); 7151 7152 rootYtWallVideoObj.push({ 7153 id: r[1], 7154 transcripturl: ytWallVidTranscriptLink 7155 }) 7156 } 7157 7158 // console.log(rootYtWallVideoObj) 7159 7160 ytWallWraps[i].innerHTML = ""; 7161 7162 let ytWallIndyWrap = ytWallWraps[i]; 7163 7164 const pullInsertYTvideos = async () => { 7165 for (let k in rootYtWallVideoObj) { 7166 let res = await fetch("https://www.youtube.com/oembed?url=https%3A//youtube.com/watch%3Fv%3D" + rootYtWallVideoObj[k].id + "&format=json"); 7167 7168 if (res.ok) { 7169 7170 let json = await res.json(); 7171 // console.log(json.title); 7172 7173 json.id = rootYtWallVideoObj[k].id; 7174 7175 let videoThumb = 'https://i.ytimg.com/vi/' + json.id + '/hqdefault.jpg'; 7176 7177 const ytWallItemWrap = document.createElement('div'); 7178 ytWallItemWrap.classList.add('yt-wall-item-wrap'); 7179 ytWallItemWrap.innerHTML = ` 7180 <a class="yt-wall-item-a" target="_blank" href="https://www.youtube.com/watch?v=${json.id}"> 7181 <div class="yt-wall-item-img-wrap-outer"> 7182 <div class="yt-wall-item-img-wrap-inner"> 7183 <img src="${videoThumb}" alt="${json.title}" class="yt-wall-item-img-img" /> 7184 </div> 7185 <div class="yt-wall-item-catagory-svg"> 7186 <svg xmlns="http://www.w3.org/2000/svg" aria-label="Play in new tab" viewBox="0 0 48 48"> 7187 <path d="M8 12H4v28c0 2.21 1.79 4 4 4h28v-4H8V12zm32-8H16c-2.21 0-4 1.79-4 4v24c0 2.21 1.79 4 4 4h24c2.21 0 4-1.79 4-4V8c0-2.21-1.79-4-4-4zM24 29V11l12 9-12 9z"></path> 7188 </svg> 7189 </div> 7190 </div> 7191 <div class="yt-wall-item-title">${json.title}</div> 7192 </a> 7193 <div class="yt-wall-item-author">${json.author_name}</div> 7194 `; 7195 7196 if(rootYtWallVideoObj[k].transcripturl !== null) { 7197 ytWallItemWrap.innerHTML += ` 7198 <div class="yt-wall-item-transcriptlink-wrap"> 7199 <a href="${rootYtWallVideoObj[k].transcripturl}" target="_blank">
7200 <span>Video Transcript</span> 7201 <svg xmlns="http://www.w3.org/2000/svg" aria-label="open in new tab" viewBox="0 0 48 48"> 7202 <path d="M38 38H10V10h14V6H10c-2.21 0-4 1.79-4 4v28c0 2.21 1.79 4 4 4h28c2.21 0 4-1.79 4-4V24h-4v14zM28 6v4h7.17L15.51 29.66l2.83 2.83L38 12.83V20h4V6H28z"></path> 7203 </svg> 7204 </a> 7205 </div> 7206 `; 7207 } 7208 7209 ytWallIndyWrap.appendChild(ytWallItemWrap); 7210 7211 } else { 7212 return `HTTP error: ${res.status}`; 7213 } 7214 } 7215 } 7216 7217 pullInsertYTvideos(); 7218 7219 } 7220} 7221let allSlimboxImgBtns = document.querySelectorAll('[data-slimbox="img"]'); 7222if (allSlimboxImgBtns) { 7223 // Add all the image slimbox html to the page 7224 allSlimboxImgBtns.forEach(el => { 7225 let imgElement; 7226 let arialabel; 7227 // if (el.querySelector('img')) { 7228 // imgElement = el.querySelector('img').outerHTML; 7229 // } else { 7230 // imgElement = el.querySelector('svg').outerHTML; 7231 // } 7232 7233 if (el.closest('button').closest('div').parentNode.querySelector('img')) { 7234 arialabel = el.closest('button').closest('div').parentNode.querySelector('img').getAttribute('alt'); 7235 imgElement = el.closest('button').closest('div').parentNode.querySelector('img').outerHTML; 7236 } else { 7237 arialabel = el.closest('button').closest('div').parentNode.querySelector('svg').getAttribute('alt'); 7238 imgElement = el.closest('button').closest('div').parentNode.querySelector('svg').outerHTML; 7239 } 7240 7241 let newImageElemString; 7242 // console.log("el", el); 7243 7244 if (el.getAttribute("data-slimbox-group")) { 7245 newImageElemString = ` 7246 <div class="slimbox-outer"> 7247 <div class="slimbox-inner"> 7248 <div class="slimbox-content-wrapper slimbox-content-wrapper-img"> 7249 <div> 7250 <button class="slimbox-nav-left" aria-label="Previous Photo"> 7251 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 7252 <path d="M30.83 32.67l-9.17-9.17 9.17-9.17L28 11.5l-12 12 12 12z"></path> 7253 </svg> 7254 </button> 7255 </div> 7256 <span class="slimbox-imgsvg-wrapper">${imgElement}</span> 7257 <div> 7258 <button class="slimbox-nav-right" aria-label="Next Photo"> 7259 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 7260 <path d="M17.17 32.92l9.17-9.17-9.17-9.17L20 11.75l12 12-12 12z"></path> 7261 </svg> 7262 </button> 7263 </div> 7264 </div> 7265 <button class="slimbox-closex slimbox-closex-grouped" aria-label="Close Photo"> 7266 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 7267 <path d="M38 12.83L35.17 10 24 21.17 12.83 10 10 12.83 21.17 24 10 35.17 12.83 38 24 26.83 35.17 38 38 35.17 26.83 24z"></path> 7268 </svg> 7269 </button> 7270 </div> 7271 </div> 7272 `; 7273 } else { 7274 newImageElemString = ` 7275 <div class="slimbox-outer" role="dialog" aria-modal="true"> 7276 <div class="slimbox-inner"> 7277 <div class="slimbox-content-wrapper slimbox-content-wrapper-img"> 7278 <span class="slimbox-imgsvg-wrapper">${imgElement}</span> 7279 </div> 7280 <button class="slimbox-closex" id="closex" aria-label="close button for image of ${arialabel}"> 7281 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" aria-hidden="true"> 7282 <path d="M38 12.83L35.17 10 24 21.17 12.83 10 10 12.83 21.17 24 10 35.17 12.83 38 24 26.83 35.17 38 38 35.17 26.83 24z"></path> 7283 </svg> 7284 </button> 7285 </div> 7286 </div> 7287 `; 7288 } 7289 7290 el.insertAdjacentHTML("afterend", newImageElemString); 7291 }); 7292} 7293 7294// Get all the slimbox btn elements 7295let slimboxEls = document.querySelectorAll("[data-slimbox]"); 7296if (slimboxEls) { 7297 // console.log(slimboxEls); 7298 7299 // get all slimbox-outer divs 7300 let slimboxOuterDivs = document.querySelectorAll(".slimbox-outer"); 7301
7302 /////////////// 7303 // FUNCTIONS // 7304 /////////////// 7305 7306 let openSlimboxFunc = e => { 7307 let slimbboxTriggerBtn = e.target.closest("[data-slimbox]"); 7308 let tempShowHideSBdivOuter 7309 let tempShowHideSBdivInner 7310 // console.log(slimbboxTriggerBtn); 7311 7312 // GET SHOW Hide Div(s) 7313 if (e.target.closest(".map-interactive")) { 7314 tempShowHideSBdivOuter = document.querySelector("#Map_Tooltip_Group [data-map-district='" + slimbboxTriggerBtn.getAttribute("data-map-district") + "']") 7315 } 7316 else { 7317 tempShowHideSBdivOuter = slimbboxTriggerBtn.nextElementSibling; 7318 } 7319 7320 tempShowHideSBdivInner = tempShowHideSBdivOuter.querySelector(".slimbox-inner"); 7321 7322 // Add show class(es) 7323 tempShowHideSBdivOuter.classList.add("slimbox-outer-show"); 7324 7325 // Add active class(es) 7326 // mini timer to for slight delay on add transitioning classes 7327 setTimeout(function () { 7328 tempShowHideSBdivOuter.classList.add("slimbox-outer-active"); 7329 tempShowHideSBdivInner.classList.add("slimbox-inner-active"); 7330 tempShowHideSBdivInner.querySelector('#closex').focus(); 7331 }, 20); 7332 7333 // Add no-scroll class to body 7334 document.body.classList.add("no-scroll"); 7335 7336 }; 7337 7338 let closeSlimboxFunc = (e, slimboxOuterShowElem) => { 7339 slimboxOuterShowElem.forEach(tempShowHideSBdivOuter => { 7340 // GET SHOW Hide Div(s) 7341 let tempShowHideSBdivInner = tempShowHideSBdivOuter.querySelector(".slimbox-inner-active"); 7342 7343 // Remove active class(es) 7344 tempShowHideSBdivOuter.classList.remove("slimbox-outer-active"); 7345 tempShowHideSBdivInner.classList.remove("slimbox-inner-active"); 7346 7347 // Add active class(es) 7348 // timer to match with css animation to display none slimbox-outer wrapper 7349 setTimeout(function () { 7350 tempShowHideSBdivOuter.classList.remove("slimbox-outer-show"); 7351 }, 300); 7352 7353 // Add no-scroll class to body 7354 document.body.classList.remove("no-scroll"); 7355 7356 let focusablebtn = tempShowHideSBdivOuter.parentNode.querySelector('.slimbox-btn') 7357 focusablebtn.focus(); 7358 7359 }); 7360 }; 7361 7362 // Combines code from above two functions to perform them in sequence when cycling
7363 let cycleSlimboxFunc = e => { 7364 // Get current active slimbox (there should only ever be one active) 7365 let targetSlimbox = document.querySelector(".slimbox-outer-active"); 7366 if (!targetSlimbox) { 7367 return; 7368 } 7369 7370 let slimboxGroupId = targetSlimbox.previousElementSibling.getAttribute("data-slimbox-group"); 7371 let slimboxGroup = []; 7372 7373 // Get list of slimboxes with the same group ID 7374 slimboxes.forEach(slimbox => { 7375 if (slimbox.previousElementSibling.matches(`[data-slimbox-group="${slimboxGroupId}"]`)) { 7376 slimboxGroup.push(slimbox); 7377 } 7378 }); 7379 7380 // Look through slimboxGroup to find targetSlimbox index 7381 let i; 7382 for (i = 0; i < slimboxGroup.length; i++) { 7383 // When target is found, stop loop, saving the index into i 7384 if (slimboxGroup[i] === targetSlimbox) { 7385 break; 7386 } 7387 } 7388 7389 // Close current slimbox 7390 closeSlimboxFunc(e, document.querySelectorAll(".slimbox-outer-active")); 7391 7392 // GET SHOW Hide Div(s) 7393 let tempShowHideSBdivOuter; 7394 if (e.target.closest(".slimbox-nav-left") || e.key === "ArrowLeft") { 7395 if (i - 1 < 0) { 7396 tempShowHideSBdivOuter = slimboxGroup[slimboxGroup.length - 1]; 7397 } else { 7398 tempShowHideSBdivOuter = slimboxGroup[i - 1]; 7399 } 7400 } else if (e.target.closest(".slimbox-nav-right") || e.key === "ArrowRight") { 7401 if (i + 1 > slimboxGroup.length - 1) { 7402 tempShowHideSBdivOuter = slimboxGroup[0]; 7403 } else { 7404 tempShowHideSBdivOuter = slimboxGroup[i + 1]; 7405 } 7406 } 7407 7408 let tempShowHideSBdivInner = tempShowHideSBdivOuter.querySelector(".slimbox-inner"); 7409 7410 // Add show class(es) 7411 tempShowHideSBdivOuter.classList.add("slimbox-outer-show"); 7412 7413 // Add active class(es) 7414 // mini timer to for slight delay on add transitioning classes 7415 setTimeout(function () { 7416 tempShowHideSBdivOuter.classList.add("slimbox-outer-active"); 7417 tempShowHideSBdivInner.classList.add("slimbox-inner-active"); 7418 }, 20); 7419 7420 // tempShowHideSBdivOuter.classList.add("slimbox-outer-active"); 7421 // tempShowHideSBdivInner.classList.add("slimbox-inner-active"); 7422 7423 // Add no-scroll class to body 7424 document.body.classList.add("no-scroll"); 7425 }; 7426 7427 ///////////////////// 7428 // EVENT LISTENERS // 7429 ///////////////////// 7430 7431 // Open Slimbox 7432 slimboxEls.forEach(element => { 7433 element.addEventListener("click", openSlimboxFunc); 7434 }); 7435 7436 let slimboxes = document.querySelectorAll(".slimbox-outer"); 7437 7438 // Close Slimbox 7439 slimboxOuterDivs.forEach(element => { 7440 // console.log(element); 7441 7442 element.addEventListener("click", e => { 7443 // console.log(e.target); 7444 7445 if (e.target.closest(".slimbox-nav-left") || e.target.closest(".slimbox-nav-right")) { 7446 cycleSlimboxFunc(e); 7447 // } else if (e.target.classList.contains("slimbox-outer") || e.target.closest(".slimbox-closex")) { 7448 } else if (e.target.closest(".slimbox-closex")) { 7449 // console.log('run closeSlimboxFunc'); 7450 7451 let slimboxOuterShowElem = document.querySelectorAll(".slimbox-outer-active"); 7452 closeSlimboxFunc(e, slimboxOuterShowElem); 7453 7454 } 7455 }); 7456 }); 7457 document.addEventListener("keyup", e => { 7458 if (e.key === "Escape") { 7459 let slimboxOuterShowElem = document.querySelectorAll(".slimbox-outer-active"); 7460 if (slimboxOuterShowElem.length > 0) { 7461 closeSlimboxFunc(e, slimboxOuterShowElem); 7462 } 7463 } 7464 7465 else if (e.key === "Tab") { 7466 // console.log('tab has been pressed'); 7467 // console.log(e.target); 7468 7469 7470 let slimboxOuterShowElem = document.querySelectorAll(".slimbox-outer-active"); 7471 if (slimboxOuterShowElem.length > 0) { 7472 if (!e.target.closest(".slimbox-outer-active")) { 7473 // closeSlimboxFunc(e, slimboxOuterShowElem); 7474 e.preventDefault(); 7475 } 7476 } 7477 } 7478 else if (e.key === "ArrowLeft" || e.key === "ArrowRight") { 7479 cycleSlimboxFunc(e); 7480 } 7481 }); 7482 7483 document.addEventListener("keydown", e => { 7484 if (e.key === "Tab") { 7485 let slimboxOuterShowElem = document.querySelectorAll(".slimbox-outer-active"); 7486 if (slimboxOuterShowElem.length > 0) { 7487 e.preventDefault(); 7488 slimboxOuterShowElem[0].querySelector('#closex').focus(); 7489 } 7490 } 7491 }); 7492} 7493 7494const SITE_DOMAIN="txdotgov"; 7495/*************** 7496 ** GLOBAL JS ** 7497 ***************/ 7498
7499///////////////////////// 7500// GLOBAL PREVENT DEFAULT 7501///////////////////////// 7502const PREVENT_DEFAULT_ARR = document.querySelectorAll('[data-preventdefault]'); 7503PREVENT_DEFAULT_ARR.forEach(element => { 7504 element.addEventListener("click", (el) => { 7505 el.preventDefault(); 7506 }); 7507}); 7508 7509// List of extensions for use with addInlineIcons() 7510// Recommend keeping extensions in alphabetical order for easier reading 7511// - Lina 7512const FILE_EXT_CAD = [ 7513 "ASM", 7514 "CAD", 7515 "DGN", 7516 "DWG", 7517 "MODEL", 7518 "PRT" 7519] 7520const FILE_EXT_IMG = [ 7521 "BMP", 7522 "GIF", 7523 "IMG", 7524 "JFIF", 7525 "JP2", 7526 "JPEG", 7527 "JPG", 7528 "PJP", 7529 "PJPEG", 7530 "PNG", 7531 "TIF", 7532 "TIFF", 7533 "WEBP" 7534] 7535const FILE_EXT_PDF = [ 7536 "PDF" 7537] 7538const FILE_EXT_PRES = [ 7539 "PPT", 7540 "PPTM", 7541 "PPTX" 7542] 7543const FILE_EXT_SPRD = [ 7544 "CSV" , 7545 "DAT" , 7546 "NUMBERS", 7547 "ODS" , 7548 "SXC" , 7549 "TSF" , 7550 "XLS" , 7551 "XLSX" 7552] 7553const FILE_EXT_VID = [ 7554 "AVCHD", 7555 "F4V", 7556 "FLV", 7557 "AVI", 7558 "M4P", 7559 "M4V", 7560 "MKV", 7561 "MOV", 7562 "MP2", 7563 "MP4", 7564 "MPE", 7565 "MPEG", 7566 "MPG", 7567 "MPV", 7568 "QT", 7569 "SWF", 7570 "WEBM", 7571 "WMV" 7572]; 7573const FILE_EXT_DOC = [ 7574 "DOC", 7575 "DOCM", 7576 "DOCX", 7577 "DOT" , 7578 "DOTM", 7579 "DOTX", 7580 "ODT" , 7581 "TXT" , 7582 "WPS" , 7583 "XPS" 7584] 7585const FILE_EXT_ZIP = [ 7586 "7Z", 7587 "RAR", 7588 "ZIP", 7589 "ZIPX" 7590] 7591const FILE_EXT_GEN = [ 7592 "EXE" 7593] 7594const FILE_SIZE_EXT=[ 7595 "PDF" 7596] 7597 7598function globalScripts(){ 7599 let anchors = document.querySelectorAll("a"); 7600 7601 anchors.forEach(anchor=>{ 7602 // Prevents all below scripts from running
7603 if(anchor.closest(".no-global-scripts")){ 7604 return 7605 } 7606 7607 // External link icon script call is handled by addInlineIcons() 7608 addInlineIcons(anchor) 7609 }) 7610 7611} 7612globalScripts() 7613 7614// adds svg file type icon to links 7615function addInlineIcons(anchor) { 7616 let anchorFirstWord; 7617 let anchorString = ""; 7618 7619 if (anchor.innerText) { 7620 anchorFirstWord = anchor.innerText.split(" ")[0]; 7621 } else { 7622 return; 7623 } 7624 7625 if (anchor.innerText.includes(" ")) { 7626 anchorString = anchor.innerText.substring(anchor.innerText.indexOf(" ") + 1); 7627 anchorString = "<span> " + anchorString + "</span>"; 7628 } 7629 7630 // anchorString=anchor.innerText 7631 7632 // Skip the anchor if it contains an image 7633 if (anchor.querySelector("img")) { 7634 return; 7635 } 7636 7637 // Lack of spacing in anchor.innerHTML setters in if statements below MUST be maintained between these tags: 7638 // </div><span>. Spacing is handled by margin-right in the link-icon-file styling class. Adding line 7639 // breaks will result in an unwanted space between the icon and string. 7640 7641 // Check if there's a file icon inhibitor class
7642 if (anchor.closest(".no-inline-file-icon")) { 7643 // If there is, skip down to the external link icon function 7644 externalLinkIcon(anchor); 7645 } 7646 // Matches eform URLs 7647 else if (anchor.href.includes("?formName")) { 7648 anchor.classList.add("link-icon-js-import", "link-icon-file"); 7649 anchor.innerHTML = 7650 `<div> 7651 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 7652 <path d="M24 42v-3.55l10.8-10.8 3.55 3.55L27.55 42ZM6 31.5v-3h15v3Zm34.5-2.45-3.55-3.55 1.45-1.45q.4-.4 1.05-.4t1.05.4l1.45 1.45q.4.4.4 1.05t-.4 1.05ZM6 23.25v-3h23.5v3ZM6 15v-3h23.5v3Z"/> 7653 </svg> 7654 <span>${anchorFirstWord}</span> 7655 </div>${anchorString}`; 7656 } 7657 // Matches CAD files 7658 else if (anchor.href && FILE_EXT_CAD.some(ext => anchor.href.slice(-ext.length - 1).toUpperCase() === "." + ext)) { 7659 anchor.classList.add("link-icon-js-import", "link-icon-file"); 7660 anchor.innerHTML = 7661 `<div> 7662 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 7663 <path d="M40 16v6H36V18H26V8H12V40H40a4 4 0 0 1-4 4H12a4 4 0 0 1-4-4V8a4 4 0 0 1 4-4H28Zm0 12v6
7663a2 2 0 0 1-2 2H34V26h4A2 2 0 0 1 40 28Zm-2 0H36v6h2Zm-8 8V32H28v4H26V28a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v8Zm0-6V28H28v2Zm-6-2V26H20a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h4V34H20V28Z"/> 7664 </svg> 7665 <span>${anchorFirstWord}</span> 7666 </div>${anchorString}`; 7667 } 7668 // Matches image files 7669 else if (anchor.href && FILE_EXT_IMG.some(ext => anchor.href.slice(-ext.length - 1).toUpperCase() === "." + ext)) { 7670 anchor.classList.add("link-icon-js-import", "link-icon-file"); 7671 anchor.innerHTML = 7672 `<div> 7673 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 7674 <polygon points="28.28 23.72 22.28 31.46 18 26.28 12 34 36 34 28.28 23.72"/> 7675 <path d="M38 6H10a4 4 0 0 0-4 4V38a4 4 0 0 0 4 4H38a4 4 0 0 0 4-4V10A4 4 0 0 0 38 6Zm0 32H10V10H38Z"/> 7676 </svg> 7677 <span>${anchorFirstWord}</span> 7678 </div>${anchorString}`; 7679 } 7680 // Matches PDF files 7681 else if (anchor.href && FILE_EXT_PDF.some(ext => anchor.href.slice(-ext.length - 1).toUpperCase() === "." + ext)) { 7682 anchor.classList.add("link-icon-js-import", "link-icon-file"); 7683 anchor.innerHTML = 7684 `<div> 7685 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 7686 <path d="M36 40h4a4 4 0 0 1-4 4H12a4 4 0 0 1-4-4V8a4 4 0 0 1 4-4H28L40 16v6H36V18H26V8H12V40H36ZM32 26a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H28V26Zm0 2H30v6h2Zm10 0V26H36V36h2V32h4V30H38V28ZM24 26a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2H22v4H20V26Zm0 2H22v2h2Z"/> 7687 </svg> 7688 <span>${anchorFirstWord}</span> 7689 </div>${anchorString}`; 7690 } 7691 // Matches presentation files 7692 else if (anchor.href && FILE_EXT_PRES.some(ext => anchor.href.slice(-ext.length - 1).toUpperCase() === "." + ext)) { 7693 anchor.classList.add("link-icon-js-import", "link-icon-file"); 7694 anchor.innerHTML = 7695 `<div> 7696 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 7697 <path d="M42 4H6A4 4 0 0 0 2 8V32a4 4 0 0 0 4 4H20v4H16v4H32V40H28V36H42a4 4 0 0 0 4-4V8A4 4 0 0 0 42 4Zm0 28H6V8H42ZM22 18h4V28H22Zm8-6h4V28H30ZM14 22h4v6H14Z"/> 7698 </svg> 7699 <span>${anchorFirstWord}</span> 7700 </div>${anchorString}`; 7701 } 7702 // Matches spreadsheet files 7703 else if (anchor.href && FILE_EXT_SPRD.some(ext => anchor.href.slice(-ext.length - 1).toUpperCase() === "." + ext)) { 7704 anchor.classList.add("link-icon-js-import", "link-icon-file"); 7705 anchor.innerHTML = 7706 `<div> 7707 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 7708 <path d="M36 38h4v2a4 4 0 0 1-4 4H12a4 4 0 0 1-4-4V8a4 4 0 0 1 4-4H36a4 4 0 0 1 4 4v2H36V8H12V40H36ZM46 12V36H16V12H46ZM42 22H38v4h4Zm-6 0H32v4h4Zm2-6v4h4V16Zm-6 0v4h4V16ZM20 20H30V16H20Zm0 6H30V22H20Zm10 6V28H20v4Zm6 0V28H32v4Zm6 0V28H38v4Z"/> 7709 </svg> 7710 <span>${anchorFirstWord}</span> 7711 </div>${anchorString}`; 7712 } 7713 // Matches video files 7714 else if (anchor.href && FILE_EXT_VID.some(ext => anchor.href.slice(-ext.length - 1).toUpperCase() === "." + ext)) { 7715 anchor.classList.add("link-icon-js-import", "link-icon-file"); 7716 anchor.innerHTML = 7717 `<div> 7718 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 7719 <path d="M38 10V38H10V10H38m0-4H10a4 4 0 0 0-4 4V38a4 4 0 0 0 4 4H38a4 4 0 0 0 4-4V10A4 4 0 0 0 38 6ZM20 15V33l12-9Z"/> 7720 </svg> 7721 <span>${anchorFirstWord}</span> 7722 </div>${anchorString}`; 7723 } 7724 // Matches Word files 7725 else if (anchor.href && FILE_EXT_DOC.some(ext => anchor.href.slice(-ext.length - 1).toUpperCase() === "." + ext)) { 7726 anchor.classList.add("link-icon-js-import", "link-icon-file"); 7727 anchor.innerHTML = 7728 `<div> 7729 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 7730 <path d="M16 32H32v4H16Zm0-8H32v4H16ZM28 4H12A4 4 0 0 0 8 8V40a4 4 0 0 0 4 4H36a4 4 0 0 0 4-4V16Zm8 36H12V8H26V18H36Z"/> 7731 </svg> 7732 <span>${anchorFirstWord}</span> 7733 </div>${anchorString}`; 7734 } 7735 // Matches compressed files 7736 else if (anchor.href && FILE_EXT_ZIP.some(ext => anchor.href.slice(-ext.length - 1).toUpperCase() === "." + ext)) { 7737 anchor.classList.add("link-icon-js-import", "link-icon-file"); 7738 anchor.innerHTML = 7739 `<div> 7740 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 7741 <path d="M40 12H24L20 8H8a4 4 0 0 0-4 4L4 36a4 4 0 0 0 4 4H40a4 4 0 0 0 4-4V16A4 4 0 0 0 40 12ZM32 32h4V28H32V24h4V20H32V16h8V36H32Zm0 0H28v4H8V12H18.34l4 4H28v4h4v4H28v4h4Z"/> 7742 </svg>
7743 <span>${anchorFirstWord}</span> 7744 </div>${anchorString}`; 7745 } 7746 // Matches "generic" files 7747 // Currently only .exe files (why??) 7748 else if (anchor.href && FILE_EXT_GEN.some(ext => anchor.href.slice(-ext.length - 1).toUpperCase() === "." + ext)) { 7749 anchor.classList.add("link-icon-js-import", "link-icon-file"); 7750 anchor.innerHTML = 7751 `<div> 7752 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> 7753 <path d="M14 2H6A2 2 0 0 0 4 4V20a2 2 0 0 0 2 2H18a2 2 0 0 0 2-2V8Zm4 18H6V4h7V9h5Z"/> 7754 </svg> 7755 <span>${anchorFirstWord}</span> 7756 </div>${anchorString}`; 7757 } 7758 // If it's not a file link, run the external link icon function to see if it needs that icon instead 7759 else if (anchor.hostname && anchor.hostname !== window.location.hostname) { 7760 if (SITE_DOMAIN === "txdotgov" && !anchor.hostname.includes("txdot.gov")) { 7761 externalLinkIcon(anchor); 7762 } else if (SITE_DOMAIN === "crossroads" && !(anchor.hostname.includes("crossroads")||anchor.hostname.includes("tntoday.dot.state.tx.us"))) { 7763 externalLinkIcon(anchor); 7764 } 7765 } 7766} 7767 7768// Add external link svg icon if link is external 7769function externalLinkIcon(anchor) { 7770 // Check if it contains the same domain as the current page 7771 if ( 7772 anchor.hostname && 7773 anchor.hostname !== window.location.hostname && 7774 !(SITE_DOMAIN === "txdotgov" && anchor.hostname.includes("txdot.gov")) && 7775 !(SITE_DOMAIN === "crossroads" && (anchor.hostname.includes("crossroads")||anchor.hostname.includes("tntoday.dot.state.tx.us"))) 7776 ) { 7777 // If not (and there's no inhibitor class), add an "open in new tab" icon after the text
7778 if (!anchor.closest(".no-inline-icon") && !anchor.classList.contains("link-icon-js-import")) { 7779 let anchorText = anchor.innerText.trim(); 7780 7781 // Remove right double arrows if present 7782 if (anchor.classList.contains("link-raquo")) { 7783 anchor.classList.remove("link-raquo"); 7784 } 7785 7786 anchor.classList.add("link-icon-js-import", "link-external"); 7787 7788 anchor.innerHTML = 7789 `<span>${anchorText}</span> 7790 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 7791 <path d="M38 38H10V10h14V6H10c-2.21 0-4 1.79-4 4v28c0 2.21 1.79 4 4 4h28c2.21 0 4-1.79 4-4V24h-4v14zM28 6v4h7.17L15.51 29.66l2.83 2.83L38 12.83V20h4V6H28z"></path> 7792 </svg>`; 7793 7794 anchor.setAttribute('aria-label', anchor.innerText + ' opens in new tab'); 7795 7796 if (anchor.classList.contains("link-raquo-white")) { 7797 anchor.classList.remove("link-raquo-white"); 7798 anchor.style.color = "white"; 7799 7800 anchor.querySelector("a svg").style.fill = "white"; 7801 } 7802 } 7803 7804 // And (if there's no inhibitor class) set the target attribute to _blank
7805 if (!anchor.closest(".no-inline-target")) { 7806 anchor.setAttribute("target", "_blank"); 7807 } 7808 } 7809} 7810 7811// Month abbreviation 7812const WHITELIST_LONG_MONTHS = ["JANUARY", "FEBRUARY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"]; 7813let dateLongMonthToShort = document.querySelectorAll('[data-date-longmonthtoshort]'); 7814let monthLongMonthToShort = document.querySelectorAll('[data-month-longmonthtoshort]'); 7815 7816if (monthLongMonthToShort) { 7817 for (let i = 0; i < monthLongMonthToShort.length; i++) { 7818 let monthLongShortMonthStr = monthLongMonthToShort[i].textContent.trim(); 7819 // Loop through array of whitelistlong months to find if there is a matching value in string 7820 for (let j = 0; j < WHITELIST_LONG_MONTHS.length; j++) { 7821 if (monthLongShortMonthStr.toUpperCase().indexOf(WHITELIST_LONG_MONTHS[j]) !== -1) { 7822 7823 const MATCHED_LONG_MONTH_STR = WHITELIST_LONG_MONTHS[j]; 7824 const MATCHED_LONG_MONTH_REGEX = new RegExp(MATCHED_LONG_MONTH_STR, "gmi"); 7825 7826 let monthLongMonthShortened; 7827 7828 const PERIOD_OR_NOT = monthLongMonthToShort[i].getAttribute('data-month-longmonthtoshort') == "noperiod" ? "" : "."; 7829 7830 if (MATCHED_LONG_MONTH_STR == "SEPTEMBER") { 7831 monthLongMonthShortened = monthLongShortMonthStr.slice(0, 4) + PERIOD_OR_NOT; 7832 } else { 7833 monthLongMonthShortened = monthLongShortMonthStr.slice(0, 3) + PERIOD_OR_NOT; 7834 } 7835 7836 monthLongMonthToShort[i].innerText = monthLongShortMonthStr.replace(MATCHED_LONG_MONTH_REGEX, monthLongMonthShortened); 7837 } 7838 } 7839 } 7840} 7841 7842if (dateLongMonthToShort) { 7843 for (let i = 0; i < dateLongMonthToShort.length; i++) { 7844 let longShortMonthFullStr = dateLongMonthToShort[i].innerText; 7845 7846 // Remove leading zeros 7847 let splitDateTextArr = longShortMonthFullStr.split(" "); 7848 for (let k = 1; k < splitDateTextArr.length; k++) { 7849 let cleanedValueOfComma = splitDateTextArr[k].replace(/,/gmi, ""); 7850 splitDateTextArr[k] = parseInt(cleanedValueOfComma, 10).toString(); 7851 } 7852 7853 longShortMonthFullStr = splitDateTextArr[0] + " " + splitDateTextArr[1] + ", " + splitDateTextArr[2]; 7854 7855 dateLongMonthToShort[i].innerText = longShortMonthFullStr; 7856 7857 // Loop through array of whitelistlong months to find if there is a matching value in string 7858 for (let j = 0; j < WHITELIST_LONG_MONTHS.length; j++) { 7859 if (longShortMonthFullStr.toUpperCase().indexOf(WHITELIST_LONG_MONTHS[j]) !== -1) { 7860 let longMonthShortened; 7861 // console.log(WHITELIST_LONG_MONTHS[j]); 7862 7863 const MATCHED_LONG_MONTH_STR = WHITELIST_LONG_MONTHS[j]; 7864 const MATCHED_LONG_MONTH_REGEX = new RegExp(MATCHED_LONG_MONTH_STR, "gmi"); 7865 const WHITELIST_CONV_TITLE_CASE = WHITELIST_LONG_MONTHS[j].slice(0, 1).toUpperCase() + 7866 WHITELIST_LONG_MONTHS[j].slice(1).toLowerCase(); 7867 7868 if (MATCHED_LONG_MONTH_STR == "SEPTEMBER") { 7869 longMonthShortened = WHITELIST_CONV_TITLE_CASE.slice(0, 4) + "."; 7870 } else { 7871 longMonthShortened = WHITELIST_CONV_TITLE_CASE.slice(0, 3) + "."; 7872 } 7873 7874 dateLongMonthToShort[i].innerText = longShortMonthFullStr.replace(MATCHED_LONG_MONTH_REGEX, 7875 longMonthShortened); 7876 } 7877 } 7878 7879 } 7880} 7881 7882//FIX for image component - put href link from data-link attribute on each of outer anchor tag of image. 7883//Reason - PDF link is breaking rendering of image. Hence had to go with JS solution 7884let cmpImageLinks = document.querySelectorAll('.cmp-image__link'); 7885 7886if (cmpImageLinks) { 7887 cmpImageLinks.forEach(element => { 7888 element.setAttribute('href', element.getAttribute('data-link')); 7889 }); 7890} 7891 7892// BEGIN Zeba code for set underline under active main menu item 7893 7894// highlight the selcted nav item for large devices 7895let path = location.pathname; 7896 7897//For spanish stes 7898if(path.indexOf('/es/') > -1){ 7899 path = path.replace('/es', '/us/es/home'); 7900} 7901 7902//searching the links 7903let navLinkElement = document.querySelector('.mm-item-wrap [href="' + path + '"]'); 7904if (!navLinkElement) { 7905 7906 if (path.indexOf('txdotreimagine') > 0) { 7907 let lastPart = path.split('/content/txdotreimagine/us/en/home/')[1]; 7908 if(lastPart) { 7909 path = '/content/txdotreimagine/us/en/home/' + lastPart.substring(0, lastPart.indexOf('/')) + '.html'; 7910 } 7911 } else if(path.indexOf('/es/') > 0){ 7912 path = '/us/es/home/'+ path.replace('/us/es/home/','').split('/')[0]+'.html'; 7913 } else if ('/' !== path) { 7914 path = '/' + path.replace('/', '').split('/')[0] + '.html'; 7915 } 7916 navLinkElement = document.querySelector('.mm-item-wrap [href="' + path + '"]'); 7917} 7918
7919//applying the class on the link 7920if (navLinkElement) { 7921 let navLinkParentElement = navLinkElement.closest('.mm-item-wrap'); 7922 if (navLinkParentElement) { 7923 let navLinkName = navLinkParentElement.getAttribute('data-mm-item'); 7924 console.log('navLinkName=' + navLinkName); 7925 let navButton = document.querySelector('.mm-nav-element [data-bandoneon-btn="' + navLinkName + '"]'); 7926 if (navButton) { 7927 navButton.classList.add('active'); // this is a placeholder class;create new class and add the styles and then change here 7928 } 7929 } 7930} 7931 7932// for small devices 7933// let navLinkElementSmalDevices = document.querySelectorAll('.mm-nav-mob-item-wrap > a[href="'+path+'"]')[0]; 7934let linkElementToActivateMobile = document.querySelector('.mm-nav-element-mob [href="' + path + '"]'); 7935 7936if (linkElementToActivateMobile) { 7937 7938 let mmNavItemWrapElementMobile = linkElementToActivateMobile.closest('.mm-nav-mob-item-wrap'); 7939 7940 if (mmNavItemWrapElementMobile) { 7941 mmNavItemWrapElementMobile.classList.add('active'); 7942 } else if (linkElementToActivateMobile.closest('.acc-panel').previousElementSibling.classList.contains('mm-nav-mob-item-wrap')) { 7943 linkElementToActivateMobile.closest('.acc-panel').previousElementSibling.classList.add('active'); 7944 } 7945 7946}
vendor: 6,790 bytes, lines 7947-8142
7947 7948/** 7949 * @license 7950 * Lodash <https://lodash.com/> 7951 * Copyright OpenJS Foundation and other contributors <https://openjsf.org/> 7952 * Released under MIT license <https://lodash.com/license> 7953 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> 7954 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 7955 */ 7956;(function() { 7957 7958 /** Used as a safe reference for `undefined` in pre-ES5 environments. */ 7959 var undefined; 7960 7961 /** Used as the semantic version number. */ 7962 var VERSION = '4.17.15'; 7963 7964 /** Used as the size to enable large array optimizations. */ 7965 var LARGE_ARRAY_SIZE = 200; 7966 7967 /** Error message constants. */ 7968 var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.', 7969 FUNC_ERROR_TEXT = 'Expected a function'; 7970 7971 /** Used to stand-in for `undefined` hash values. */ 7972 var HASH_UNDEFINED = '__lodash_hash_undefined__'; 7973 7974 /** Used as the maximum memoize cache size. */ 7975 var MAX_MEMOIZE_SIZE = 500; 7976 7977 /** Used as the internal argument placeholder. */ 7978 var PLACEHOLDER = '__lodash_placeholder__'; 7979 7980 /** Used to compose bitmasks for cloning. */ 7981 var CLONE_DEEP_FLAG = 1, 7982 CLONE_FLAT_FLAG = 2, 7983 CLONE_SYMBOLS_FLAG = 4; 7984 7985 /** Used to compose bitmasks for value comparisons. */ 7986 var COMPARE_PARTIAL_FLAG = 1, 7987 COMPARE_UNORDERED_FLAG = 2; 7988 7989 /** Used to compose bitmasks for function metadata. */ 7990 var WRAP_BIND_FLAG = 1, 7991 WRAP_BIND_KEY_FLAG = 2, 7992 WRAP_CURRY_BOUND_FLAG = 4, 7993 WRAP_CURRY_FLAG = 8, 7994 WRAP_CURRY_RIGHT_FLAG = 16, 7995 WRAP_PARTIAL_FLAG = 32, 7996 WRAP_PARTIAL_RIGHT_FLAG = 64, 7997 WRAP_ARY_FLAG = 128, 7998 WRAP_REARG_FLAG = 256, 7999 WRAP_FLIP_FLAG = 512; 8000 8001 /** Used as default options for `_.truncate`. */ 8002 var DEFAULT_TRUNC_LENGTH = 30, 8003 DEFAULT_TRUNC_OMISSION = '...'; 8004 8005 /** Used to detect hot functions by number of calls within a span of milliseconds. */ 8006 var HOT_COUNT = 800, 8007 HOT_SPAN = 16; 8008 8009 /** Used to indicate the type of lazy iteratees. */ 8010 var LAZY_FILTER_FLAG = 1, 8011 LAZY_MAP_FLAG = 2, 8012 LAZY_WHILE_FLAG = 3; 8013 8014 /** Used as references for various `Number` constants. */ 8015 var INFINITY = 1 / 0, 8016 MAX_SAFE_INTEGER = 9007199254740991, 8017 MAX_INTEGER = 1.7976931348623157e+308, 8018 NAN = 0 / 0; 8019 8020 /** Used as references for the maximum length and index of an array. */ 8021 var MAX_ARRAY_LENGTH = 4294967295, 8022 MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, 8023 HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; 8024 8025 /** Used to associate wrap methods with their bit flags. */ 8026 var wrapFlags = [ 8027 ['ary', WRAP_ARY_FLAG], 8028 ['bind', WRAP_BIND_FLAG], 8029 ['bindKey', WRAP_BIND_KEY_FLAG], 8030 ['curry', WRAP_CURRY_FLAG], 8031 ['curryRight', WRAP_CURRY_RIGHT_FLAG], 8032 ['flip', WRAP_FLIP_FLAG], 8033 ['partial', WRAP_PARTIAL_FLAG], 8034 ['partialRight', WRAP_PARTIAL_RIGHT_FLAG], 8035 ['rearg', WRAP_REARG_FLAG] 8036 ]; 8037 8038 /** `Object#toString` result references. */ 8039 var argsTag = '[object Arguments]', 8040 arrayTag = '[object Array]', 8041 asyncTag = '[object AsyncFunction]', 8042 boolTag = '[object Boolean]', 8043 dateTag = '[object Date]', 8044 domExcTag = '[object DOMException]', 8045 errorTag = '[object Error]', 8046 funcTag = '[object Function]', 8047 genTag = '[object GeneratorFunction]', 8048 mapTag = '[object Map]', 8049 numberTag = '[object Number]', 8050 nullTag = '[object Null]', 8051 objectTag = '[object Object]', 8052 promiseTag = '[object Promise]', 8053 proxyTag = '[object Proxy]', 8054 regexpTag = '[object RegExp]', 8055 setTag = '[object Set]', 8056 stringTag = '[object String]', 8057 symbolTag = '[object Symbol]', 8058 undefinedTag = '[object Undefined]', 8059 weakMapTag = '[object WeakMap]', 8060 weakSetTag = '[object WeakSet]'; 8061 8062 var arrayBufferTag = '[object ArrayBuffer]', 8063 dataViewTag = '[object DataView]', 8064 float32Tag = '[object Float32Array]', 8065 float64Tag = '[object Float64Array]', 8066 int8Tag = '[object Int8Array]', 8067 int16Tag = '[object Int16Array]', 8068 int32Tag = '[object Int32Array]', 8069 uint8Tag = '[object Uint8Array]', 8070 uint8ClampedTag = '[object Uint8ClampedArray]', 8071 uint16Tag = '[object Uint16Array]', 8072 uint32Tag = '[object Uint32Array]'; 8073 8074 /** Used to match empty string literals in compiled template source. */ 8075 var reEmptyStringLeading = /\b__p \+= '';/g, 8076 reEmptyStringMiddle = /\b(__p \+=) '' \+/g, 8077 reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; 8078 8079 /** Used to match HTML entities and HTML characters. */ 8080 var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, 8081 reUnescapedHtml = /[&<>"']/g, 8082 reHasEscapedHtml = RegExp(reEscapedHtml.source), 8083 reHasUnescapedHtml = RegExp(reUnescapedHtml.source); 8084 8085 /** Used to match template delimiters. */ 8086 var reEscape = /<%-([\s\S]+?)%>/g, 8087 reEvaluate = /<%([\s\S]+?)%>/g, 8088 reInterpolate = /<%=([\s\S]+?)%>/g; 8089 8090 /** Used to match property names within property paths. */ 8091 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, 8092 reIsPlainProp = /^\w*$/, 8093 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; 8094 8095 /** 8096 * Used to match `RegExp` 8097 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). 8098 */ 8099 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, 8100 reHasRegExpChar = RegExp(reRegExpChar.source); 8101 8102 /** Used to match leading and trailing whitespace. */ 8103 var reTrim = /^\s+|\s+$/g, 8104 reTrimStart = /^\s+/, 8105 reTrimEnd = /\s+$/; 8106 8107 /** Used to match wrap detail comments. */ 8108 var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, 8109 reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, 8110 reSplitDetails = /,? & /; 8111 8112 /** Used to match words composed of alphanumeric characters. */ 8113 var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; 8114 8115 /** Used to match backslashes in property paths. */ 8116 var reEscapeChar = /\\(\\)?/g; 8117 8118 /** 8119 * Used to match 8120 * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). 8121 */ 8122 var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; 8123 8124 /** Used to match `RegExp` flags from their coerced string values. */ 8125 var reFlags = /\w*$/; 8126 8127 /** Used to detect bad signed hexadecimal string values. */ 8128 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; 8129 8130 /** Used to detect binary string values. */ 8131 var reIsBinary = /^0b[01]+$/i; 8132 8133 /** Used to detect host constructors (Safari). */ 8134 var reIsHostCtor = /^\[object .+?Constructor\]$/; 8135 8136 /** Used to detect octal string values. */ 8137 var reIsOctal = /^0o[0-7]+$/i; 8138 8139 /** Used to detect unsigned integer values. */ 8140 var reIsUint = /^(?:0|[1-9]\d*)$/; 8141 8142 /** Used to match Latin Unicode letters (excluding mathematical operators). */
vendor: 5,311 bytes, lines 8143-8248
8143 var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; 8144 8145 /** Used to ensure capturing order of template delimiters. */ 8146 var reNoMatch = /($^)/; 8147 8148 /** Used to match unescaped characters in compiled string literals. */ 8149 var reUnescapedString = /['\n\r\u2028\u2029\\]/g; 8150 8151 /** Used to compose unicode character classes. */ 8152 var rsAstralRange = '\\ud800-\\udfff', 8153 rsComboMarksRange = '\\u0300-\\u036f', 8154 reComboHalfMarksRange = '\\ufe20-\\ufe2f', 8155 rsComboSymbolsRange = '\\u20d0-\\u20ff', 8156 rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, 8157 rsDingbatRange = '\\u2700-\\u27bf', 8158 rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', 8159 rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', 8160 rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', 8161 rsPunctuationRange = '\\u2000-\\u206f', 8162 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', 8163 rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', 8164 rsVarRange = '\\ufe0e\\ufe0f', 8165 rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; 8166 8167 /** Used to compose unicode capture groups. */ 8168 var rsApos = "['\u2019]", 8169 rsAstral = '[' + rsAstralRange + ']', 8170 rsBreak = '[' + rsBreakRange + ']', 8171 rsCombo = '[' + rsComboRange + ']', 8172 rsDigits = '\\d+', 8173 rsDingbat = '[' + rsDingbatRange + ']', 8174 rsLower = '[' + rsLowerRange + ']', 8175 rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', 8176 rsFitz = '\\ud83c[\\udffb-\\udfff]', 8177 rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', 8178 rsNonAstral = '[^' + rsAstralRange + ']', 8179 rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', 8180 rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', 8181 rsUpper = '[' + rsUpperRange + ']', 8182 rsZWJ = '\\u200d'; 8183 8184 /** Used to compose unicode regexes. */ 8185 var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', 8186 rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', 8187 rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', 8188 rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', 8189 reOptMod = rsModifier + '?', 8190 rsOptVar = '[' + rsVarRange + ']?', 8191 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', 8192 rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])', 8193 rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])', 8194 rsSeq = rsOptVar + reOptMod + rsOptJoin, 8195 rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, 8196 rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; 8197 8198 /** Used to match apostrophes. */ 8199 var reApos = RegExp(rsApos, 'g'); 8200 8201 /** 8202 * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and 8203 * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). 8204 */ 8205 var reComboMark = RegExp(rsCombo, 'g'); 8206 8207 /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ 8208 var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); 8209 8210 /** Used to match complex or compound words. */ 8211 var reUnicodeWord = RegExp([ 8212 rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', 8213 rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', 8214 rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, 8215 rsUpper + '+' + rsOptContrUpper, 8216 rsOrdUpper, 8217 rsOrdLower, 8218 rsDigits, 8219 rsEmoji 8220 ].join('|'), 'g'); 8221 8222 /** 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/). */ 8223 var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); 8224 8225 /** Used to detect strings that need a more robust regexp to match words. */ 8226 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 ]/; 8227 8228 /** Used to assign default `context` object properties. */ 8229 var contextProps = [ 8230 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', 8231 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', 8232 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', 8233 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', 8234 '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' 8235 ]; 8236 8237 /** Used to make template sourceURLs easier to identify. */ 8238 var templateCounter = -1; 8239 8240 /** Used to identify `toStringTag` values of typed arrays. */ 8241 var typedArrayTags = {}; 8242 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = 8243 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = 8244 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = 8245 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = 8246 typedArrayTags[uint32Tag] = true; 8247 typedArrayTags[argsTag] = typedArrayTags[arrayTag] = 8248 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
vendor: 5,923 bytes, lines 8249-8383
8249 typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = 8250 typedArrayTags[errorTag] = typedArrayTags[funcTag] = 8251 typedArrayTags[mapTag] = typedArrayTags[numberTag] = 8252 typedArrayTags[objectTag] = typedArrayTags[regexpTag] = 8253 typedArrayTags[setTag] = typedArrayTags[stringTag] = 8254 typedArrayTags[weakMapTag] = false; 8255 8256 /** Used to identify `toStringTag` values supported by `_.clone`. */ 8257 var cloneableTags = {}; 8258 cloneableTags[argsTag] = cloneableTags[arrayTag] = 8259 cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = 8260 cloneableTags[boolTag] = cloneableTags[dateTag] = 8261 cloneableTags[float32Tag] = cloneableTags[float64Tag] = 8262 cloneableTags[int8Tag] = cloneableTags[int16Tag] = 8263 cloneableTags[int32Tag] = cloneableTags[mapTag] = 8264 cloneableTags[numberTag] = cloneableTags[objectTag] = 8265 cloneableTags[regexpTag] = cloneableTags[setTag] = 8266 cloneableTags[stringTag] = cloneableTags[symbolTag] = 8267 cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = 8268 cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; 8269 cloneableTags[errorTag] = cloneableTags[funcTag] = 8270 cloneableTags[weakMapTag] = false; 8271 8272 /** Used to map Latin Unicode letters to basic Latin letters. */ 8273 var deburredLetters = { 8274 // Latin-1 Supplement block. 8275 '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', 8276 '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', 8277 '\xc7': 'C', '\xe7': 'c', 8278 '\xd0': 'D', '\xf0': 'd', 8279 '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', 8280 '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', 8281 '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', 8282 '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', 8283 '\xd1': 'N', '\xf1': 'n', 8284 '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', 8285 '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', 8286 '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', 8287 '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', 8288 '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', 8289 '\xc6': 'Ae', '\xe6': 'ae', 8290 '\xde': 'Th', '\xfe': 'th', 8291 '\xdf': 'ss', 8292 // Latin Extended-A block. 8293 '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', 8294 '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', 8295 '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', 8296 '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', 8297 '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', 8298 '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', 8299 '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', 8300 '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', 8301 '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', 8302 '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', 8303 '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', 8304 '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', 8305 '\u0134': 'J', '\u0135': 'j', 8306 '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', 8307 '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', 8308 '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', 8309 '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', 8310 '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', 8311 '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', 8312 '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', 8313 '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', 8314 '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', 8315 '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', 8316 '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', 8317 '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', 8318 '\u0163': 't', '\u0165': 't', '\u0167': 't', 8319 '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', 8320 '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', 8321 '\u0174': 'W', '\u0175': 'w', 8322 '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', 8323 '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', 8324 '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', 8325 '\u0132': 'IJ', '\u0133': 'ij', 8326 '\u0152': 'Oe', '\u0153': 'oe', 8327 '\u0149': "'n", '\u017f': 's' 8328 }; 8329 8330 /** Used to map characters to HTML entities. */ 8331 var htmlEscapes = { 8332 '&': '&', 8333 '<': '<', 8334 '>': '>', 8335 '"': '"', 8336 "'": ''' 8337 }; 8338 8339 /** Used to map HTML entities to characters. */ 8340 var htmlUnescapes = { 8341 '&': '&', 8342 '<': '<', 8343 '>': '>', 8344 '"': '"', 8345 ''': "'" 8346 }; 8347 8348 /** Used to escape characters for inclusion in compiled string literals. */ 8349 var stringEscapes = { 8350 '\\': '\\', 8351 "'": "'", 8352 '\n': 'n', 8353 '\r': 'r', 8354 '\u2028': 'u2028', 8355 '\u2029': 'u2029' 8356 }; 8357 8358 /** Built-in method references without a dependency on `root`. */ 8359 var freeParseFloat = parseFloat, 8360 freeParseInt = parseInt; 8361 8362 /** Detect free variable `global` from Node.js. */ 8363 var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; 8364 8365 /** Detect free variable `self`. */ 8366 var freeSelf = typeof self == 'object' && self && self.Object === Object && self; 8367 8368 /** Used as a reference to the global object. */ 8369 var root = freeGlobal || freeSelf || Function('return this')(); 8370 8371 /** Detect free variable `exports`. */ 8372 var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; 8373 8374 /** Detect free variable `module`. */ 8375 var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; 8376 8377 /** Detect the popular CommonJS extension `module.exports`. */ 8378 var moduleExports = freeModule && freeModule.exports === freeExports; 8379 8380 /** Detect free variable `process` from Node.js. */ 8381 var freeProcess = moduleExports && freeGlobal.process; 8382 8383 /** Used to access faster Node.js helpers. */
vendor: 8,860 bytes, lines 8384-8677
8384 var nodeUtil = (function() { 8385 try { 8386 // Use `util.types` for Node.js 10+. 8387 var types = freeModule && freeModule.require && freeModule.require('util').types; 8388 8389 if (types) { 8390 return types; 8391 } 8392 8393 // Legacy `process.binding('util')` for Node.js < 10. 8394 return freeProcess && freeProcess.binding && freeProcess.binding('util'); 8395 } catch (e) {} 8396 }()); 8397 8398 /* Node.js helper references. */ 8399 var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer, 8400 nodeIsDate = nodeUtil && nodeUtil.isDate, 8401 nodeIsMap = nodeUtil && nodeUtil.isMap, 8402 nodeIsRegExp = nodeUtil && nodeUtil.isRegExp, 8403 nodeIsSet = nodeUtil && nodeUtil.isSet, 8404 nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; 8405 8406 /*--------------------------------------------------------------------------*/ 8407 8408 /** 8409 * A faster alternative to `Function#apply`, this function invokes `func` 8410 * with the `this` binding of `thisArg` and the arguments of `args`. 8411 * 8412 * @private 8413 * @param {Function} func The function to invoke. 8414 * @param {*} thisArg The `this` binding of `func`. 8415 * @param {Array} args The arguments to invoke `func` with. 8416 * @returns {*} Returns the result of `func`. 8417 */ 8418 function apply(func, thisArg, args) { 8419 switch (args.length) { 8420 case 0: return func.call(thisArg); 8421 case 1: return func.call(thisArg, args[0]); 8422 case 2: return func.call(thisArg, args[0], args[1]); 8423 case 3: return func.call(thisArg, args[0], args[1], args[2]); 8424 } 8425 return func.apply(thisArg, args); 8426 } 8427 8428 /** 8429 * A specialized version of `baseAggregator` for arrays. 8430 * 8431 * @private 8432 * @param {Array} [array] The array to iterate over. 8433 * @param {Function} setter The function to set `accumulator` values. 8434 * @param {Function} iteratee The iteratee to transform keys. 8435 * @param {Object} accumulator The initial aggregated object. 8436 * @returns {Function} Returns `accumulator`. 8437 */ 8438 function arrayAggregator(array, setter, iteratee, accumulator) { 8439 var index = -1, 8440 length = array == null ? 0 : array.length; 8441 8442 while (++index < length) { 8443 var value = array[index]; 8444 setter(accumulator, value, iteratee(value), array); 8445 } 8446 return accumulator; 8447 } 8448 8449 /** 8450 * A specialized version of `_.forEach` for arrays without support for 8451 * iteratee shorthands. 8452 * 8453 * @private 8454 * @param {Array} [array] The array to iterate over. 8455 * @param {Function} iteratee The function invoked per iteration. 8456 * @returns {Array} Returns `array`. 8457 */ 8458 function arrayEach(array, iteratee) { 8459 var index = -1, 8460 length = array == null ? 0 : array.length; 8461 8462 while (++index < length) { 8463 if (iteratee(array[index], index, array) === false) { 8464 break; 8465 } 8466 } 8467 return array; 8468 } 8469 8470 /** 8471 * A specialized version of `_.forEachRight` for arrays without support for 8472 * iteratee shorthands. 8473 * 8474 * @private 8475 * @param {Array} [array] The array to iterate over. 8476 * @param {Function} iteratee The function invoked per iteration. 8477 * @returns {Array} Returns `array`. 8478 */ 8479 function arrayEachRight(array, iteratee) { 8480 var length = array == null ? 0 : array.length; 8481 8482 while (length--) { 8483 if (iteratee(array[length], length, array) === false) { 8484 break; 8485 } 8486 } 8487 return array; 8488 } 8489 8490 /** 8491 * A specialized version of `_.every` for arrays without support for 8492 * iteratee shorthands. 8493 * 8494 * @private 8495 * @param {Array} [array] The array to iterate over. 8496 * @param {Function} predicate The function invoked per iteration. 8497 * @returns {boolean} Returns `true` if all elements pass the predicate check, 8498 * else `false`. 8499 */ 8500 function arrayEvery(array, predicate) { 8501 var index = -1, 8502 length = array == null ? 0 : array.length; 8503 8504 while (++index < length) { 8505 if (!predicate(array[index], index, array)) { 8506 return false; 8507 } 8508 } 8509 return true; 8510 } 8511 8512 /** 8513 * A specialized version of `_.filter` for arrays without support for 8514 * iteratee shorthands. 8515 * 8516 * @private 8517 * @param {Array} [array] The array to iterate over. 8518 * @param {Function} predicate The function invoked per iteration. 8519 * @returns {Array} Returns the new filtered array. 8520 */ 8521 function arrayFilter(array, predicate) { 8522 var index = -1, 8523 length = array == null ? 0 : array.length, 8524 resIndex = 0, 8525 result = []; 8526 8527 while (++index < length) { 8528 var value = array[index]; 8529 if (predicate(value, index, array)) { 8530 result[resIndex++] = value; 8531 } 8532 } 8533 return result; 8534 } 8535 8536 /** 8537 * A specialized version of `_.includes` for arrays without support for 8538 * specifying an index to search from. 8539 * 8540 * @private 8541 * @param {Array} [array] The array to inspect. 8542 * @param {*} target The value to search for. 8543 * @returns {boolean} Returns `true` if `target` is found, else `false`. 8544 */ 8545 function arrayIncludes(array, value) { 8546 var length = array == null ? 0 : array.length; 8547 return !!length && baseIndexOf(array, value, 0) > -1; 8548 } 8549 8550 /** 8551 * This function is like `arrayIncludes` except that it accepts a comparator. 8552 * 8553 * @private 8554 * @param {Array} [array] The array to inspect. 8555 * @param {*} target The value to search for. 8556 * @param {Function} comparator The comparator invoked per element. 8557 * @returns {boolean} Returns `true` if `target` is found, else `false`. 8558 */ 8559 function arrayIncludesWith(array, value, comparator) { 8560 var index = -1, 8561 length = array == null ? 0 : array.length; 8562 8563 while (++index < length) { 8564 if (comparator(value, array[index])) { 8565 return true; 8566 } 8567 } 8568 return false; 8569 } 8570 8571 /** 8572 * A specialized version of `_.map` for arrays without support for iteratee 8573 * shorthands. 8574 * 8575 * @private 8576 * @param {Array} [array] The array to iterate over. 8577 * @param {Function} iteratee The function invoked per iteration. 8578 * @returns {Array} Returns the new mapped array. 8579 */ 8580 function arrayMap(array, iteratee) { 8581 var index = -1, 8582 length = array == null ? 0 : array.length, 8583 result = Array(length); 8584 8585 while (++index < length) { 8586 result[index] = iteratee(array[index], index, array); 8587 } 8588 return result; 8589 } 8590 8591 /** 8592 * Appends the elements of `values` to `array`. 8593 * 8594 * @private 8595 * @param {Array} array The array to modify. 8596 * @param {Array} values The values to append. 8597 * @returns {Array} Returns `array`. 8598 */ 8599 function arrayPush(array, values) { 8600 var index = -1, 8601 length = values.length, 8602 offset = array.length; 8603 8604 while (++index < length) { 8605 array[offset + index] = values[index]; 8606 } 8607 return array; 8608 } 8609 8610 /** 8611 * A specialized version of `_.reduce` for arrays without support for 8612 * iteratee shorthands. 8613 * 8614 * @private 8615 * @param {Array} [array] The array to iterate over. 8616 * @param {Function} iteratee The function invoked per iteration. 8617 * @param {*} [accumulator] The initial value. 8618 * @param {boolean} [initAccum] Specify using the first element of `array` as 8619 * the initial value. 8620 * @returns {*} Returns the accumulated value. 8621 */ 8622 function arrayReduce(array, iteratee, accumulator, initAccum) { 8623 var index = -1, 8624 length = array == null ? 0 : array.length; 8625 8626 if (initAccum && length) { 8627 accumulator = array[++index]; 8628 } 8629 while (++index < length) { 8630 accumulator = iteratee(accumulator, array[index], index, array); 8631 } 8632 return accumulator; 8633 } 8634 8635 /** 8636 * A specialized version of `_.reduceRight` for arrays without support for 8637 * iteratee shorthands. 8638 * 8639 * @private 8640 * @param {Array} [array] The array to iterate over. 8641 * @param {Function} iteratee The function invoked per iteration. 8642 * @param {*} [accumulator] The initial value. 8643 * @param {boolean} [initAccum] Specify using the last element of `array` as 8644 * the initial value. 8645 * @returns {*} Returns the accumulated value. 8646 */ 8647 function arrayReduceRight(array, iteratee, accumulator, initAccum) { 8648 var length = array == null ? 0 : array.length; 8649 if (initAccum && length) { 8650 accumulator = array[--length]; 8651 } 8652 while (length--) { 8653 accumulator = iteratee(accumulator, array[length], length, array); 8654 } 8655 return accumulator; 8656 } 8657 8658 /** 8659 * A specialized version of `_.some` for arrays without support for iteratee 8660 * shorthands. 8661 * 8662 * @private 8663 * @param {Array} [array] The array to iterate over. 8664 * @param {Function} predicate The function invoked per iteration. 8665 * @returns {boolean} Returns `true` if any element passes the predicate check, 8666 * else `false`. 8667 */ 8668 function arraySome(array, predicate) { 8669 var index = -1, 8670 length = array == null ? 0 : array.length; 8671 8672 while (++index < length) { 8673 if (predicate(array[index], index, array)) { 8674 return true; 8675 } 8676 } 8677 return false;
vendor: 6,984 bytes, lines 8678-8909
8678 } 8679 8680 /** 8681 * Gets the size of an ASCII `string`. 8682 * 8683 * @private 8684 * @param {string} string The string inspect. 8685 * @returns {number} Returns the string size. 8686 */ 8687 var asciiSize = baseProperty('length'); 8688 8689 /** 8690 * Converts an ASCII `string` to an array. 8691 * 8692 * @private 8693 * @param {string} string The string to convert. 8694 * @returns {Array} Returns the converted array. 8695 */ 8696 function asciiToArray(string) { 8697 return string.split(''); 8698 } 8699 8700 /** 8701 * Splits an ASCII `string` into an array of its words. 8702 * 8703 * @private 8704 * @param {string} The string to inspect. 8705 * @returns {Array} Returns the words of `string`. 8706 */ 8707 function asciiWords(string) { 8708 return string.match(reAsciiWord) || []; 8709 } 8710 8711 /** 8712 * The base implementation of methods like `_.findKey` and `_.findLastKey`, 8713 * without support for iteratee shorthands, which iterates over `collection` 8714 * using `eachFunc`. 8715 * 8716 * @private 8717 * @param {Array|Object} collection The collection to inspect. 8718 * @param {Function} predicate The function invoked per iteration. 8719 * @param {Function} eachFunc The function to iterate over `collection`. 8720 * @returns {*} Returns the found element or its key, else `undefined`. 8721 */ 8722 function baseFindKey(collection, predicate, eachFunc) { 8723 var result; 8724 eachFunc(collection, function(value, key, collection) { 8725 if (predicate(value, key, collection)) { 8726 result = key; 8727 return false; 8728 } 8729 }); 8730 return result; 8731 } 8732 8733 /** 8734 * The base implementation of `_.findIndex` and `_.findLastIndex` without 8735 * support for iteratee shorthands. 8736 * 8737 * @private 8738 * @param {Array} array The array to inspect. 8739 * @param {Function} predicate The function invoked per iteration. 8740 * @param {number} fromIndex The index to search from. 8741 * @param {boolean} [fromRight] Specify iterating from right to left. 8742 * @returns {number} Returns the index of the matched value, else `-1`. 8743 */ 8744 function baseFindIndex(array, predicate, fromIndex, fromRight) { 8745 var length = array.length, 8746 index = fromIndex + (fromRight ? 1 : -1); 8747 8748 while ((fromRight ? index-- : ++index < length)) { 8749 if (predicate(array[index], index, array)) { 8750 return index; 8751 } 8752 } 8753 return -1; 8754 } 8755 8756 /** 8757 * The base implementation of `_.indexOf` without `fromIndex` bounds checks. 8758 * 8759 * @private 8760 * @param {Array} array The array to inspect. 8761 * @param {*} value The value to search for. 8762 * @param {number} fromIndex The index to search from. 8763 * @returns {number} Returns the index of the matched value, else `-1`. 8764 */ 8765 function baseIndexOf(array, value, fromIndex) { 8766 return value === value 8767 ? strictIndexOf(array, value, fromIndex) 8768 : baseFindIndex(array, baseIsNaN, fromIndex); 8769 } 8770 8771 /** 8772 * This function is like `baseIndexOf` except that it accepts a comparator. 8773 * 8774 * @private 8775 * @param {Array} array The array to inspect. 8776 * @param {*} value The value to search for. 8777 * @param {number} fromIndex The index to search from. 8778 * @param {Function} comparator The comparator invoked per element. 8779 * @returns {number} Returns the index of the matched value, else `-1`. 8780 */ 8781 function baseIndexOfWith(array, value, fromIndex, comparator) { 8782 var index = fromIndex - 1, 8783 length = array.length; 8784 8785 while (++index < length) { 8786 if (comparator(array[index], value)) { 8787 return index; 8788 } 8789 } 8790 return -1; 8791 } 8792 8793 /** 8794 * The base implementation of `_.isNaN` without support for number objects. 8795 * 8796 * @private 8797 * @param {*} value The value to check. 8798 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 8799 */ 8800 function baseIsNaN(value) { 8801 return value !== value; 8802 } 8803 8804 /** 8805 * The base implementation of `_.mean` and `_.meanBy` without support for 8806 * iteratee shorthands. 8807 * 8808 * @private 8809 * @param {Array} array The array to iterate over. 8810 * @param {Function} iteratee The function invoked per iteration. 8811 * @returns {number} Returns the mean. 8812 */ 8813 function baseMean(array, iteratee) { 8814 var length = array == null ? 0 : array.length; 8815 return length ? (baseSum(array, iteratee) / length) : NAN; 8816 } 8817 8818 /** 8819 * The base implementation of `_.property` without support for deep paths. 8820 * 8821 * @private 8822 * @param {string} key The key of the property to get. 8823 * @returns {Function} Returns the new accessor function. 8824 */ 8825 function baseProperty(key) { 8826 return function(object) { 8827 return object == null ? undefined : object[key]; 8828 }; 8829 } 8830 8831 /** 8832 * The base implementation of `_.propertyOf` without support for deep paths. 8833 * 8834 * @private 8835 * @param {Object} object The object to query. 8836 * @returns {Function} Returns the new accessor function. 8837 */ 8838 function basePropertyOf(object) { 8839 return function(key) { 8840 return object == null ? undefined : object[key]; 8841 }; 8842 } 8843 8844 /** 8845 * The base implementation of `_.reduce` and `_.reduceRight`, without support 8846 * for iteratee shorthands, which iterates over `collection` using `eachFunc`. 8847 * 8848 * @private 8849 * @param {Array|Object} collection The collection to iterate over. 8850 * @param {Function} iteratee The function invoked per iteration. 8851 * @param {*} accumulator The initial value. 8852 * @param {boolean} initAccum Specify using the first or last element of 8853 * `collection` as the initial value. 8854 * @param {Function} eachFunc The function to iterate over `collection`. 8855 * @returns {*} Returns the accumulated value. 8856 */ 8857 function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { 8858 eachFunc(collection, function(value, index, collection) { 8859 accumulator = initAccum 8860 ? (initAccum = false, value) 8861 : iteratee(accumulator, value, index, collection); 8862 }); 8863 return accumulator; 8864 } 8865 8866 /** 8867 * The base implementation of `_.sortBy` which uses `comparer` to define the 8868 * sort order of `array` and replaces criteria objects with their corresponding 8869 * values. 8870 * 8871 * @private 8872 * @param {Array} array The array to sort. 8873 * @param {Function} comparer The function to define sort order. 8874 * @returns {Array} Returns `array`. 8875 */ 8876 function baseSortBy(array, comparer) { 8877 var length = array.length; 8878 8879 array.sort(comparer); 8880 while (length--) { 8881 array[length] = array[length].value; 8882 } 8883 return array; 8884 } 8885 8886 /** 8887 * The base implementation of `_.sum` and `_.sumBy` without support for 8888 * iteratee shorthands. 8889 * 8890 * @private 8891 * @param {Array} array The array to iterate over. 8892 * @param {Function} iteratee The function invoked per iteration. 8893 * @returns {number} Returns the sum. 8894 */ 8895 function baseSum(array, iteratee) { 8896 var result, 8897 index = -1, 8898 length = array.length; 8899 8900 while (++index < length) { 8901 var current = iteratee(array[index]); 8902 if (current !== undefined) { 8903 result = result === undefined ? current : (result + current); 8904 } 8905 } 8906 return result; 8907 } 8908 8909 /**
vendor: 5,596 bytes, lines 8910-9102
8910 * The base implementation of `_.times` without support for iteratee shorthands 8911 * or max array length checks. 8912 * 8913 * @private 8914 * @param {number} n The number of times to invoke `iteratee`. 8915 * @param {Function} iteratee The function invoked per iteration. 8916 * @returns {Array} Returns the array of results. 8917 */ 8918 function baseTimes(n, iteratee) { 8919 var index = -1, 8920 result = Array(n); 8921 8922 while (++index < n) { 8923 result[index] = iteratee(index); 8924 } 8925 return result; 8926 } 8927 8928 /** 8929 * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array 8930 * of key-value pairs for `object` corresponding to the property names of `props`. 8931 * 8932 * @private 8933 * @param {Object} object The object to query. 8934 * @param {Array} props The property names to get values for. 8935 * @returns {Object} Returns the key-value pairs. 8936 */ 8937 function baseToPairs(object, props) { 8938 return arrayMap(props, function(key) { 8939 return [key, object[key]]; 8940 }); 8941 } 8942 8943 /** 8944 * The base implementation of `_.unary` without support for storing metadata. 8945 * 8946 * @private 8947 * @param {Function} func The function to cap arguments for. 8948 * @returns {Function} Returns the new capped function. 8949 */ 8950 function baseUnary(func) { 8951 return function(value) { 8952 return func(value); 8953 }; 8954 } 8955 8956 /** 8957 * The base implementation of `_.values` and `_.valuesIn` which creates an 8958 * array of `object` property values corresponding to the property names 8959 * of `props`. 8960 * 8961 * @private 8962 * @param {Object} object The object to query. 8963 * @param {Array} props The property names to get values for. 8964 * @returns {Object} Returns the array of property values. 8965 */ 8966 function baseValues(object, props) { 8967 return arrayMap(props, function(key) { 8968 return object[key]; 8969 }); 8970 } 8971 8972 /** 8973 * Checks if a `cache` value for `key` exists. 8974 * 8975 * @private 8976 * @param {Object} cache The cache to query. 8977 * @param {string} key The key of the entry to check. 8978 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 8979 */ 8980 function cacheHas(cache, key) { 8981 return cache.has(key); 8982 } 8983 8984 /** 8985 * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol 8986 * that is not found in the character symbols. 8987 * 8988 * @private 8989 * @param {Array} strSymbols The string symbols to inspect. 8990 * @param {Array} chrSymbols The character symbols to find. 8991 * @returns {number} Returns the index of the first unmatched string symbol. 8992 */ 8993 function charsStartIndex(strSymbols, chrSymbols) { 8994 var index = -1, 8995 length = strSymbols.length; 8996 8997 while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 8998 return index; 8999 } 9000 9001 /** 9002 * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol 9003 * that is not found in the character symbols. 9004 * 9005 * @private 9006 * @param {Array} strSymbols The string symbols to inspect. 9007 * @param {Array} chrSymbols The character symbols to find. 9008 * @returns {number} Returns the index of the last unmatched string symbol. 9009 */ 9010 function charsEndIndex(strSymbols, chrSymbols) { 9011 var index = strSymbols.length; 9012 9013 while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 9014 return index; 9015 } 9016 9017 /** 9018 * Gets the number of `placeholder` occurrences in `array`. 9019 * 9020 * @private 9021 * @param {Array} array The array to inspect. 9022 * @param {*} placeholder The placeholder to search for. 9023 * @returns {number} Returns the placeholder count. 9024 */ 9025 function countHolders(array, placeholder) { 9026 var length = array.length, 9027 result = 0; 9028 9029 while (length--) { 9030 if (array[length] === placeholder) { 9031 ++result; 9032 } 9033 } 9034 return result; 9035 } 9036 9037 /** 9038 * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A 9039 * letters to basic Latin letters. 9040 * 9041 * @private 9042 * @param {string} letter The matched letter to deburr. 9043 * @returns {string} Returns the deburred letter. 9044 */ 9045 var deburrLetter = basePropertyOf(deburredLetters); 9046 9047 /** 9048 * Used by `_.escape` to convert characters to HTML entities. 9049 * 9050 * @private 9051 * @param {string} chr The matched character to escape. 9052 * @returns {string} Returns the escaped character. 9053 */ 9054 var escapeHtmlChar = basePropertyOf(htmlEscapes); 9055 9056 /** 9057 * Used by `_.template` to escape characters for inclusion in compiled string literals. 9058 * 9059 * @private 9060 * @param {string} chr The matched character to escape. 9061 * @returns {string} Returns the escaped character. 9062 */ 9063 function escapeStringChar(chr) { 9064 return '\\' + stringEscapes[chr]; 9065 } 9066 9067 /** 9068 * Gets the value at `key` of `object`. 9069 * 9070 * @private 9071 * @param {Object} [object] The object to query. 9072 * @param {string} key The key of the property to get. 9073 * @returns {*} Returns the property value. 9074 */ 9075 function getValue(object, key) { 9076 return object == null ? undefined : object[key]; 9077 } 9078 9079 /** 9080 * Checks if `string` contains Unicode symbols. 9081 * 9082 * @private 9083 * @param {string} string The string to inspect. 9084 * @returns {boolean} Returns `true` if a symbol is found, else `false`. 9085 */ 9086 function hasUnicode(string) { 9087 return reHasUnicode.test(string); 9088 } 9089 9090 /** 9091 * Checks if `string` contains a word composed of Unicode symbols. 9092 * 9093 * @private 9094 * @param {string} string The string to inspect. 9095 * @returns {boolean} Returns `true` if a word is found, else `false`. 9096 */ 9097 function hasUnicodeWord(string) { 9098 return reHasUnicodeWord.test(string); 9099 } 9100 9101 /** 9102 * Converts `iterator` to an array.
vendor: 4,118 bytes, lines 9103-9268
9103 * 9104 * @private 9105 * @param {Object} iterator The iterator to convert. 9106 * @returns {Array} Returns the converted array. 9107 */ 9108 function iteratorToArray(iterator) { 9109 var data, 9110 result = []; 9111 9112 while (!(data = iterator.next()).done) { 9113 result.push(data.value); 9114 } 9115 return result; 9116 } 9117 9118 /** 9119 * Converts `map` to its key-value pairs. 9120 * 9121 * @private 9122 * @param {Object} map The map to convert. 9123 * @returns {Array} Returns the key-value pairs. 9124 */ 9125 function mapToArray(map) { 9126 var index = -1, 9127 result = Array(map.size); 9128 9129 map.forEach(function(value, key) { 9130 result[++index] = [key, value]; 9131 }); 9132 return result; 9133 } 9134 9135 /** 9136 * Creates a unary function that invokes `func` with its argument transformed. 9137 * 9138 * @private 9139 * @param {Function} func The function to wrap. 9140 * @param {Function} transform The argument transform. 9141 * @returns {Function} Returns the new function. 9142 */ 9143 function overArg(func, transform) { 9144 return function(arg) { 9145 return func(transform(arg)); 9146 }; 9147 } 9148 9149 /** 9150 * Replaces all `placeholder` elements in `array` with an internal placeholder 9151 * and returns an array of their indexes. 9152 * 9153 * @private 9154 * @param {Array} array The array to modify. 9155 * @param {*} placeholder The placeholder to replace. 9156 * @returns {Array} Returns the new array of placeholder indexes. 9157 */ 9158 function replaceHolders(array, placeholder) { 9159 var index = -1, 9160 length = array.length, 9161 resIndex = 0, 9162 result = []; 9163 9164 while (++index < length) { 9165 var value = array[index]; 9166 if (value === placeholder || value === PLACEHOLDER) { 9167 array[index] = PLACEHOLDER; 9168 result[resIndex++] = index; 9169 } 9170 } 9171 return result; 9172 } 9173 9174 /** 9175 * Converts `set` to an array of its values. 9176 * 9177 * @private 9178 * @param {Object} set The set to convert. 9179 * @returns {Array} Returns the values. 9180 */ 9181 function setToArray(set) { 9182 var index = -1, 9183 result = Array(set.size); 9184 9185 set.forEach(function(value) { 9186 result[++index] = value; 9187 }); 9188 return result; 9189 } 9190 9191 /** 9192 * Converts `set` to its value-value pairs. 9193 * 9194 * @private 9195 * @param {Object} set The set to convert. 9196 * @returns {Array} Returns the value-value pairs. 9197 */ 9198 function setToPairs(set) { 9199 var index = -1, 9200 result = Array(set.size); 9201 9202 set.forEach(function(value) { 9203 result[++index] = [value, value]; 9204 }); 9205 return result; 9206 } 9207 9208 /** 9209 * A specialized version of `_.indexOf` which performs strict equality 9210 * comparisons of values, i.e. `===`. 9211 * 9212 * @private 9213 * @param {Array} array The array to inspect. 9214 * @param {*} value The value to search for. 9215 * @param {number} fromIndex The index to search from. 9216 * @returns {number} Returns the index of the matched value, else `-1`. 9217 */ 9218 function strictIndexOf(array, value, fromIndex) { 9219 var index = fromIndex - 1, 9220 length = array.length; 9221 9222 while (++index < length) { 9223 if (array[index] === value) { 9224 return index; 9225 } 9226 } 9227 return -1; 9228 } 9229 9230 /** 9231 * A specialized version of `_.lastIndexOf` which performs strict equality 9232 * comparisons of values, i.e. `===`. 9233 * 9234 * @private 9235 * @param {Array} array The array to inspect. 9236 * @param {*} value The value to search for. 9237 * @param {number} fromIndex The index to search from. 9238 * @returns {number} Returns the index of the matched value, else `-1`. 9239 */ 9240 function strictLastIndexOf(array, value, fromIndex) { 9241 var index = fromIndex + 1; 9242 while (index--) { 9243 if (array[index] === value) { 9244 return index; 9245 } 9246 } 9247 return index; 9248 } 9249 9250 /** 9251 * Gets the number of symbols in `string`. 9252 * 9253 * @private 9254 * @param {string} string The string to inspect. 9255 * @returns {number} Returns the string size. 9256 */ 9257 function stringSize(string) { 9258 return hasUnicode(string) 9259 ? unicodeSize(string) 9260 : asciiSize(string); 9261 } 9262 9263 /** 9264 * Converts `string` to an array. 9265 * 9266 * @private 9267 * @param {string} string The string to convert. 9268 * @returns {Array} Returns the converted array.
vendor: 10,876 bytes, lines 9269-9542
9269 */ 9270 function stringToArray(string) { 9271 return hasUnicode(string) 9272 ? unicodeToArray(string) 9273 : asciiToArray(string); 9274 } 9275 9276 /** 9277 * Used by `_.unescape` to convert HTML entities to characters. 9278 * 9279 * @private 9280 * @param {string} chr The matched character to unescape. 9281 * @returns {string} Returns the unescaped character. 9282 */ 9283 var unescapeHtmlChar = basePropertyOf(htmlUnescapes); 9284 9285 /** 9286 * Gets the size of a Unicode `string`. 9287 * 9288 * @private 9289 * @param {string} string The string inspect. 9290 * @returns {number} Returns the string size. 9291 */ 9292 function unicodeSize(string) { 9293 var result = reUnicode.lastIndex = 0; 9294 while (reUnicode.test(string)) { 9295 ++result; 9296 } 9297 return result; 9298 } 9299 9300 /** 9301 * Converts a Unicode `string` to an array. 9302 * 9303 * @private 9304 * @param {string} string The string to convert. 9305 * @returns {Array} Returns the converted array. 9306 */ 9307 function unicodeToArray(string) { 9308 return string.match(reUnicode) || []; 9309 } 9310 9311 /** 9312 * Splits a Unicode `string` into an array of its words. 9313 * 9314 * @private 9315 * @param {string} The string to inspect. 9316 * @returns {Array} Returns the words of `string`. 9317 */ 9318 function unicodeWords(string) { 9319 return string.match(reUnicodeWord) || []; 9320 } 9321 9322 /*--------------------------------------------------------------------------*/ 9323 9324 /** 9325 * Create a new pristine `lodash` function using the `context` object. 9326 * 9327 * @static 9328 * @memberOf _ 9329 * @since 1.1.0 9330 * @category Util 9331 * @param {Object} [context=root] The context object. 9332 * @returns {Function} Returns a new `lodash` function. 9333 * @example 9334 * 9335 * _.mixin({ 'foo': _.constant('foo') }); 9336 * 9337 * var lodash = _.runInContext(); 9338 * lodash.mixin({ 'bar': lodash.constant('bar') }); 9339 * 9340 * _.isFunction(_.foo); 9341 * // => true 9342 * _.isFunction(_.bar); 9343 * // => false 9344 * 9345 * lodash.isFunction(lodash.foo); 9346 * // => false 9347 * lodash.isFunction(lodash.bar); 9348 * // => true 9349 * 9350 * // Create a suped-up `defer` in Node.js. 9351 * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; 9352 */ 9353 var runInContext = (function runInContext(context) { 9354 context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps)); 9355 9356 /** Built-in constructor references. */ 9357 var Array = context.Array, 9358 Date = context.Date, 9359 Error = context.Error, 9360 Function = context.Function, 9361 Math = context.Math, 9362 Object = context.Object, 9363 RegExp = context.RegExp, 9364 String = context.String, 9365 TypeError = context.TypeError; 9366 9367 /** Used for built-in method references. */ 9368 var arrayProto = Array.prototype, 9369 funcProto = Function.prototype, 9370 objectProto = Object.prototype; 9371 9372 /** Used to detect overreaching core-js shims. */ 9373 var coreJsData = context['__core-js_shared__']; 9374 9375 /** Used to resolve the decompiled source of functions. */ 9376 var funcToString = funcProto.toString; 9377 9378 /** Used to check objects for own properties. */ 9379 var hasOwnProperty = objectProto.hasOwnProperty; 9380 9381 /** Used to generate unique IDs. */ 9382 var idCounter = 0; 9383 9384 /** Used to detect methods masquerading as native. */ 9385 var maskSrcKey = (function() { 9386 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); 9387 return uid ? ('Symbol(src)_1.' + uid) : ''; 9388 }()); 9389 9390 /** 9391 * Used to resolve the 9392 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) 9393 * of values. 9394 */ 9395 var nativeObjectToString = objectProto.toString; 9396 9397 /** Used to infer the `Object` constructor. */ 9398 var objectCtorString = funcToString.call(Object); 9399 9400 /** Used to restore the original `_` reference in `_.noConflict`. */ 9401 var oldDash = root._; 9402 9403 /** Used to detect if a method is native. */ 9404 var reIsNative = RegExp('^' + 9405 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') 9406 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' 9407 ); 9408 9409 /** Built-in value references. */ 9410 var Buffer = moduleExports ? context.Buffer : undefined, 9411 Symbol = context.Symbol, 9412 Uint8Array = context.Uint8Array, 9413 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined, 9414 getPrototype = overArg(Object.getPrototypeOf, Object), 9415 objectCreate = Object.create, 9416 propertyIsEnumerable = objectProto.propertyIsEnumerable, 9417 splice = arrayProto.splice, 9418 spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined, 9419 symIterator = Symbol ? Symbol.iterator : undefined, 9420 symToStringTag = Symbol ? Symbol.toStringTag : undefined; 9421 9422 var defineProperty = (function() { 9423 try { 9424 var func = getNative(Object, 'defineProperty'); 9425 func({}, '', {}); 9426 return func; 9427 } catch (e) {} 9428 }()); 9429 9430 /** Mocked built-ins. */ 9431 var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, 9432 ctxNow = Date && Date.now !== root.Date.now && Date.now, 9433 ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout; 9434 9435 /* Built-in method references for those with the same name as other `lodash` methods. */ 9436 var nativeCeil = Math.ceil, 9437 nativeFloor = Math.floor, 9438 nativeGetSymbols = Object.getOwnPropertySymbols, 9439 nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, 9440 nativeIsFinite = context.isFinite, 9441 nativeJoin = arrayProto.join, 9442 nativeKeys = overArg(Object.keys, Object), 9443 nativeMax = Math.max, 9444 nativeMin = Math.min, 9445 nativeNow = Date.now, 9446 nativeParseInt = context.parseInt, 9447 nativeRandom = Math.random, 9448 nativeReverse = arrayProto.reverse; 9449 9450 /* Built-in method references that are verified to be native. */ 9451 var DataView = getNative(context, 'DataView'), 9452 Map = getNative(context, 'Map'), 9453 Promise = getNative(context, 'Promise'), 9454 Set = getNative(context, 'Set'), 9455 WeakMap = getNative(context, 'WeakMap'), 9456 nativeCreate = getNative(Object, 'create'); 9457 9458 /** Used to store function metadata. */ 9459 var metaMap = WeakMap && new WeakMap; 9460 9461 /** Used to lookup unminified function names. */ 9462 var realNames = {}; 9463 9464 /** Used to detect maps, sets, and weakmaps. */ 9465 var dataViewCtorString = toSource(DataView), 9466 mapCtorString = toSource(Map), 9467 promiseCtorString = toSource(Promise), 9468 setCtorString = toSource(Set), 9469 weakMapCtorString = toSource(WeakMap); 9470 9471 /** Used to convert symbols to primitives and strings. */ 9472 var symbolProto = Symbol ? Symbol.prototype : undefined, 9473 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, 9474 symbolToString = symbolProto ? symbolProto.toString : undefined; 9475 9476 /*------------------------------------------------------------------------*/ 9477 9478 /** 9479 * Creates a `lodash` object which wraps `value` to enable implicit method 9480 * chain sequences. Methods that operate on and return arrays, collections, 9481 * and functions can be chained together. Methods that retrieve a single value 9482 * or may return a primitive value will automatically end the chain sequence 9483 * and return the unwrapped value. Otherwise, the value must be unwrapped 9484 * with `_#value`. 9485 * 9486 * Explicit chain sequences, which must be unwrapped with `_#value`, may be 9487 * enabled using `_.chain`. 9488 * 9489 * The execution of chained methods is lazy, that is, it's deferred until 9490 * `_#value` is implicitly or explicitly called. 9491 * 9492 * Lazy evaluation allows several methods to support shortcut fusion. 9493 * Shortcut fusion is an optimization to merge iteratee calls; this avoids 9494 * the creation of intermediate arrays and can greatly reduce the number of 9495 * iteratee executions. Sections of a chain sequence qualify for shortcut 9496 * fusion if the section is applied to an array and iteratees accept only 9497 * one argument. The heuristic for whether a section qualifies for shortcut 9498 * fusion is subject to change. 9499 * 9500 * Chaining is supported in custom builds as long as the `_#value` method is 9501 * directly or indirectly included in the build. 9502 * 9503 * In addition to lodash methods, wrappers have `Array` and `String` methods. 9504 * 9505 * The wrapper `Array` methods are: 9506 * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` 9507 * 9508 * The wrapper `String` methods are: 9509 * `replace` and `split` 9510 * 9511 * The wrapper methods that support shortcut fusion are: 9512 * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, 9513 * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, 9514 * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` 9515 * 9516 * The chainable wrapper methods are: 9517 * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, 9518 * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, 9519 * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, 9520 * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, 9521 * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, 9522 * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, 9523 * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, 9524 * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, 9525 * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, 9526 * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, 9527 * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, 9528 * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, 9529 * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, 9530 * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, 9531 * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, 9532 * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, 9533 * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, 9534 * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, 9535 * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, 9536 * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, 9537 * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, 9538 * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, 9539 * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, 9540 * `zipObject`, `zipObjectDeep`, and `zipWith` 9541 * 9542 * The wrapper methods that are **not** chainable by default are:
vendor: 18,450 bytes, lines 9543-10195
9543 * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, 9544 * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, 9545 * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, 9546 * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, 9547 * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`, 9548 * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, 9549 * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, 9550 * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, 9551 * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, 9552 * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, 9553 * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, 9554 * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, 9555 * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, 9556 * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, 9557 * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, 9558 * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, 9559 * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, 9560 * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, 9561 * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, 9562 * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`, 9563 * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`, 9564 * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`, 9565 * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, 9566 * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, 9567 * `upperFirst`, `value`, and `words` 9568 * 9569 * @name _ 9570 * @constructor 9571 * @category Seq 9572 * @param {*} value The value to wrap in a `lodash` instance. 9573 * @returns {Object} Returns the new `lodash` wrapper instance. 9574 * @example 9575 * 9576 * function square(n) { 9577 * return n * n; 9578 * } 9579 * 9580 * var wrapped = _([1, 2, 3]); 9581 * 9582 * // Returns an unwrapped value. 9583 * wrapped.reduce(_.add); 9584 * // => 6 9585 * 9586 * // Returns a wrapped value. 9587 * var squares = wrapped.map(square); 9588 * 9589 * _.isArray(squares); 9590 * // => false 9591 * 9592 * _.isArray(squares.value()); 9593 * // => true 9594 */ 9595 function lodash(value) { 9596 if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { 9597 if (value instanceof LodashWrapper) { 9598 return value; 9599 } 9600 if (hasOwnProperty.call(value, '__wrapped__')) { 9601 return wrapperClone(value); 9602 } 9603 } 9604 return new LodashWrapper(value); 9605 } 9606 9607 /** 9608 * The base implementation of `_.create` without support for assigning 9609 * properties to the created object. 9610 * 9611 * @private 9612 * @param {Object} proto The object to inherit from. 9613 * @returns {Object} Returns the new object. 9614 */ 9615 var baseCreate = (function() { 9616 function object() {} 9617 return function(proto) { 9618 if (!isObject(proto)) { 9619 return {}; 9620 } 9621 if (objectCreate) { 9622 return objectCreate(proto); 9623 } 9624 object.prototype = proto; 9625 var result = new object; 9626 object.prototype = undefined; 9627 return result; 9628 }; 9629 }()); 9630 9631 /** 9632 * The function whose prototype chain sequence wrappers inherit from. 9633 * 9634 * @private 9635 */ 9636 function baseLodash() { 9637 // No operation performed. 9638 } 9639 9640 /** 9641 * The base constructor for creating `lodash` wrapper objects. 9642 * 9643 * @private 9644 * @param {*} value The value to wrap. 9645 * @param {boolean} [chainAll] Enable explicit method chain sequences. 9646 */ 9647 function LodashWrapper(value, chainAll) { 9648 this.__wrapped__ = value; 9649 this.__actions__ = []; 9650 this.__chain__ = !!chainAll; 9651 this.__index__ = 0; 9652 this.__values__ = undefined; 9653 } 9654 9655 /** 9656 * By default, the template delimiters used by lodash are like those in 9657 * embedded Ruby (ERB) as well as ES2015 template strings. Change the 9658 * following template settings to use alternative delimiters. 9659 * 9660 * @static 9661 * @memberOf _ 9662 * @type {Object} 9663 */ 9664 lodash.templateSettings = { 9665 9666 /** 9667 * Used to detect `data` property values to be HTML-escaped. 9668 * 9669 * @memberOf _.templateSettings 9670 * @type {RegExp} 9671 */ 9672 'escape': reEscape, 9673 9674 /** 9675 * Used to detect code to be evaluated. 9676 * 9677 * @memberOf _.templateSettings 9678 * @type {RegExp} 9679 */ 9680 'evaluate': reEvaluate, 9681 9682 /** 9683 * Used to detect `data` property values to inject. 9684 * 9685 * @memberOf _.templateSettings 9686 * @type {RegExp} 9687 */ 9688 'interpolate': reInterpolate, 9689 9690 /** 9691 * Used to reference the data object in the template text. 9692 * 9693 * @memberOf _.templateSettings 9694 * @type {string} 9695 */ 9696 'variable': '', 9697 9698 /** 9699 * Used to import variables into the compiled template. 9700 * 9701 * @memberOf _.templateSettings 9702 * @type {Object} 9703 */ 9704 'imports': { 9705 9706 /** 9707 * A reference to the `lodash` function. 9708 * 9709 * @memberOf _.templateSettings.imports 9710 * @type {Function} 9711 */ 9712 '_': lodash 9713 } 9714 }; 9715 9716 // Ensure wrappers are instances of `baseLodash`. 9717 lodash.prototype = baseLodash.prototype; 9718 lodash.prototype.constructor = lodash; 9719 9720 LodashWrapper.prototype = baseCreate(baseLodash.prototype); 9721 LodashWrapper.prototype.constructor = LodashWrapper; 9722 9723 /*------------------------------------------------------------------------*/ 9724 9725 /** 9726 * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. 9727 * 9728 * @private 9729 * @constructor 9730 * @param {*} value The value to wrap. 9731 */ 9732 function LazyWrapper(value) { 9733 this.__wrapped__ = value; 9734 this.__actions__ = []; 9735 this.__dir__ = 1; 9736 this.__filtered__ = false; 9737 this.__iteratees__ = []; 9738 this.__takeCount__ = MAX_ARRAY_LENGTH; 9739 this.__views__ = []; 9740 } 9741 9742 /** 9743 * Creates a clone of the lazy wrapper object. 9744 * 9745 * @private 9746 * @name clone 9747 * @memberOf LazyWrapper 9748 * @returns {Object} Returns the cloned `LazyWrapper` object. 9749 */ 9750 function lazyClone() { 9751 var result = new LazyWrapper(this.__wrapped__); 9752 result.__actions__ = copyArray(this.__actions__); 9753 result.__dir__ = this.__dir__; 9754 result.__filtered__ = this.__filtered__; 9755 result.__iteratees__ = copyArray(this.__iteratees__); 9756 result.__takeCount__ = this.__takeCount__; 9757 result.__views__ = copyArray(this.__views__); 9758 return result; 9759 } 9760 9761 /** 9762 * Reverses the direction of lazy iteration. 9763 * 9764 * @private 9765 * @name reverse 9766 * @memberOf LazyWrapper 9767 * @returns {Object} Returns the new reversed `LazyWrapper` object. 9768 */ 9769 function lazyReverse() { 9770 if (this.__filtered__) { 9771 var result = new LazyWrapper(this); 9772 result.__dir__ = -1; 9773 result.__filtered__ = true; 9774 } else { 9775 result = this.clone(); 9776 result.__dir__ *= -1; 9777 } 9778 return result; 9779 } 9780 9781 /** 9782 * Extracts the unwrapped value from its lazy wrapper. 9783 * 9784 * @private 9785 * @name value 9786 * @memberOf LazyWrapper 9787 * @returns {*} Returns the unwrapped value. 9788 */ 9789 function lazyValue() { 9790 var array = this.__wrapped__.value(), 9791 dir = this.__dir__, 9792 isArr = isArray(array), 9793 isRight = dir < 0, 9794 arrLength = isArr ? array.length : 0, 9795 view = getView(0, arrLength, this.__views__), 9796 start = view.start, 9797 end = view.end, 9798 length = end - start, 9799 index = isRight ? end : (start - 1), 9800 iteratees = this.__iteratees__, 9801 iterLength = iteratees.length, 9802 resIndex = 0, 9803 takeCount = nativeMin(length, this.__takeCount__); 9804 9805 if (!isArr || (!isRight && arrLength == length && takeCount == length)) { 9806 return baseWrapperValue(array, this.__actions__); 9807 } 9808 var result = []; 9809 9810 outer: 9811 while (length-- && resIndex < takeCount) { 9812 index += dir; 9813 9814 var iterIndex = -1, 9815 value = array[index]; 9816 9817 while (++iterIndex < iterLength) { 9818 var data = iteratees[iterIndex], 9819 iteratee = data.iteratee, 9820 type = data.type, 9821 computed = iteratee(value); 9822 9823 if (type == LAZY_MAP_FLAG) { 9824 value = computed; 9825 } else if (!computed) { 9826 if (type == LAZY_FILTER_FLAG) { 9827 continue outer; 9828 } else { 9829 break outer; 9830 } 9831 } 9832 } 9833 result[resIndex++] = value; 9834 } 9835 return result; 9836 } 9837 9838 // Ensure `LazyWrapper` is an instance of `baseLodash`. 9839 LazyWrapper.prototype = baseCreate(baseLodash.prototype); 9840 LazyWrapper.prototype.constructor = LazyWrapper; 9841 9842 /*------------------------------------------------------------------------*/ 9843 9844 /** 9845 * Creates a hash object. 9846 * 9847 * @private 9848 * @constructor 9849 * @param {Array} [entries] The key-value pairs to cache. 9850 */ 9851 function Hash(entries) { 9852 var index = -1, 9853 length = entries == null ? 0 : entries.length; 9854 9855 this.clear(); 9856 while (++index < length) { 9857 var entry = entries[index]; 9858 this.set(entry[0], entry[1]); 9859 } 9860 } 9861 9862 /** 9863 * Removes all key-value entries from the hash. 9864 * 9865 * @private 9866 * @name clear 9867 * @memberOf Hash 9868 */ 9869 function hashClear() { 9870 this.__data__ = nativeCreate ? nativeCreate(null) : {}; 9871 this.size = 0; 9872 } 9873 9874 /** 9875 * Removes `key` and its value from the hash. 9876 * 9877 * @private 9878 * @name delete 9879 * @memberOf Hash 9880 * @param {Object} hash The hash to modify. 9881 * @param {string} key The key of the value to remove. 9882 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 9883 */ 9884 function hashDelete(key) { 9885 var result = this.has(key) && delete this.__data__[key]; 9886 this.size -= result ? 1 : 0; 9887 return result; 9888 } 9889 9890 /** 9891 * Gets the hash value for `key`. 9892 * 9893 * @private 9894 * @name get 9895 * @memberOf Hash 9896 * @param {string} key The key of the value to get. 9897 * @returns {*} Returns the entry value. 9898 */ 9899 function hashGet(key) { 9900 var data = this.__data__; 9901 if (nativeCreate) { 9902 var result = data[key]; 9903 return result === HASH_UNDEFINED ? undefined : result; 9904 } 9905 return hasOwnProperty.call(data, key) ? data[key] : undefined; 9906 } 9907 9908 /** 9909 * Checks if a hash value for `key` exists. 9910 * 9911 * @private 9912 * @name has 9913 * @memberOf Hash 9914 * @param {string} key The key of the entry to check. 9915 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 9916 */ 9917 function hashHas(key) { 9918 var data = this.__data__; 9919 return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); 9920 } 9921 9922 /** 9923 * Sets the hash `key` to `value`. 9924 * 9925 * @private 9926 * @name set 9927 * @memberOf Hash 9928 * @param {string} key The key of the value to set. 9929 * @param {*} value The value to set. 9930 * @returns {Object} Returns the hash instance. 9931 */ 9932 function hashSet(key, value) { 9933 var data = this.__data__; 9934 this.size += this.has(key) ? 0 : 1; 9935 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; 9936 return this; 9937 } 9938 9939 // Add methods to `Hash`. 9940 Hash.prototype.clear = hashClear; 9941 Hash.prototype['delete'] = hashDelete; 9942 Hash.prototype.get = hashGet; 9943 Hash.prototype.has = hashHas; 9944 Hash.prototype.set = hashSet; 9945 9946 /*------------------------------------------------------------------------*/ 9947 9948 /** 9949 * Creates an list cache object. 9950 * 9951 * @private 9952 * @constructor 9953 * @param {Array} [entries] The key-value pairs to cache. 9954 */ 9955 function ListCache(entries) { 9956 var index = -1, 9957 length = entries == null ? 0 : entries.length; 9958 9959 this.clear(); 9960 while (++index < length) { 9961 var entry = entries[index]; 9962 this.set(entry[0], entry[1]); 9963 } 9964 } 9965 9966 /** 9967 * Removes all key-value entries from the list cache. 9968 * 9969 * @private 9970 * @name clear 9971 * @memberOf ListCache 9972 */ 9973 function listCacheClear() { 9974 this.__data__ = []; 9975 this.size = 0; 9976 } 9977 9978 /** 9979 * Removes `key` and its value from the list cache. 9980 * 9981 * @private 9982 * @name delete 9983 * @memberOf ListCache 9984 * @param {string} key The key of the value to remove. 9985 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 9986 */ 9987 function listCacheDelete(key) { 9988 var data = this.__data__, 9989 index = assocIndexOf(data, key); 9990 9991 if (index < 0) { 9992 return false; 9993 } 9994 var lastIndex = data.length - 1; 9995 if (index == lastIndex) { 9996 data.pop(); 9997 } else { 9998 splice.call(data, index, 1); 9999 } 10000 --this.size; 10001 return true; 10002 } 10003 10004 /** 10005 * Gets the list cache value for `key`. 10006 * 10007 * @private 10008 * @name get 10009 * @memberOf ListCache 10010 * @param {string} key The key of the value to get. 10011 * @returns {*} Returns the entry value. 10012 */ 10013 function listCacheGet(key) { 10014 var data = this.__data__, 10015 index = assocIndexOf(data, key); 10016 10017 return index < 0 ? undefined : data[index][1]; 10018 } 10019 10020 /** 10021 * Checks if a list cache value for `key` exists. 10022 * 10023 * @private 10024 * @name has 10025 * @memberOf ListCache 10026 * @param {string} key The key of the entry to check. 10027 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 10028 */ 10029 function listCacheHas(key) { 10030 return assocIndexOf(this.__data__, key) > -1; 10031 } 10032 10033 /** 10034 * Sets the list cache `key` to `value`. 10035 * 10036 * @private 10037 * @name set 10038 * @memberOf ListCache 10039 * @param {string} key The key of the value to set. 10040 * @param {*} value The value to set. 10041 * @returns {Object} Returns the list cache instance. 10042 */ 10043 function listCacheSet(key, value) { 10044 var data = this.__data__, 10045 index = assocIndexOf(data, key); 10046 10047 if (index < 0) { 10048 ++this.size; 10049 data.push([key, value]); 10050 } else { 10051 data[index][1] = value; 10052 } 10053 return this; 10054 } 10055 10056 // Add methods to `ListCache`. 10057 ListCache.prototype.clear = listCacheClear; 10058 ListCache.prototype['delete'] = listCacheDelete; 10059 ListCache.prototype.get = listCacheGet; 10060 ListCache.prototype.has = listCacheHas; 10061 ListCache.prototype.set = listCacheSet; 10062 10063 /*------------------------------------------------------------------------*/ 10064 10065 /** 10066 * Creates a map cache object to store key-value pairs. 10067 * 10068 * @private 10069 * @constructor 10070 * @param {Array} [entries] The key-value pairs to cache. 10071 */ 10072 function MapCache(entries) { 10073 var index = -1, 10074 length = entries == null ? 0 : entries.length; 10075 10076 this.clear(); 10077 while (++index < length) { 10078 var entry = entries[index]; 10079 this.set(entry[0], entry[1]); 10080 } 10081 } 10082 10083 /** 10084 * Removes all key-value entries from the map. 10085 * 10086 * @private 10087 * @name clear 10088 * @memberOf MapCache 10089 */ 10090 function mapCacheClear() { 10091 this.size = 0; 10092 this.__data__ = { 10093 'hash': new Hash, 10094 'map': new (Map || ListCache), 10095 'string': new Hash 10096 }; 10097 } 10098 10099 /** 10100 * Removes `key` and its value from the map. 10101 * 10102 * @private 10103 * @name delete 10104 * @memberOf MapCache 10105 * @param {string} key The key of the value to remove. 10106 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 10107 */ 10108 function mapCacheDelete(key) { 10109 var result = getMapData(this, key)['delete'](key); 10110 this.size -= result ? 1 : 0; 10111 return result; 10112 } 10113 10114 /** 10115 * Gets the map value for `key`. 10116 * 10117 * @private 10118 * @name get 10119 * @memberOf MapCache 10120 * @param {string} key The key of the value to get. 10121 * @returns {*} Returns the entry value. 10122 */ 10123 function mapCacheGet(key) { 10124 return getMapData(this, key).get(key); 10125 } 10126 10127 /** 10128 * Checks if a map value for `key` exists. 10129 * 10130 * @private 10131 * @name has 10132 * @memberOf MapCache 10133 * @param {string} key The key of the entry to check. 10134 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 10135 */ 10136 function mapCacheHas(key) { 10137 return getMapData(this, key).has(key); 10138 } 10139 10140 /** 10141 * Sets the map `key` to `value`. 10142 * 10143 * @private 10144 * @name set 10145 * @memberOf MapCache 10146 * @param {string} key The key of the value to set. 10147 * @param {*} value The value to set. 10148 * @returns {Object} Returns the map cache instance. 10149 */ 10150 function mapCacheSet(key, value) { 10151 var data = getMapData(this, key), 10152 size = data.size; 10153 10154 data.set(key, value); 10155 this.size += data.size == size ? 0 : 1; 10156 return this; 10157 } 10158 10159 // Add methods to `MapCache`. 10160 MapCache.prototype.clear = mapCacheClear; 10161 MapCache.prototype['delete'] = mapCacheDelete; 10162 MapCache.prototype.get = mapCacheGet; 10163 MapCache.prototype.has = mapCacheHas; 10164 MapCache.prototype.set = mapCacheSet; 10165 10166 /*------------------------------------------------------------------------*/ 10167 10168 /** 10169 * 10170 * Creates an array cache object to store unique values. 10171 * 10172 * @private 10173 * @constructor 10174 * @param {Array} [values] The values to cache. 10175 */ 10176 function SetCache(values) { 10177 var index = -1, 10178 length = values == null ? 0 : values.length; 10179 10180 this.__data__ = new MapCache; 10181 while (++index < length) { 10182 this.add(values[index]); 10183 } 10184 } 10185 10186 /** 10187 * Adds `value` to the array cache. 10188 * 10189 * @private 10190 * @name add 10191 * @memberOf SetCache 10192 * @alias push 10193 * @param {*} value The value to cache. 10194 * @returns {Object} Returns the cache instance. 10195 */
vendor: 3,741 bytes, lines 10196-10332
10196 function setCacheAdd(value) { 10197 this.__data__.set(value, HASH_UNDEFINED); 10198 return this; 10199 } 10200 10201 /** 10202 * Checks if `value` is in the array cache. 10203 * 10204 * @private 10205 * @name has 10206 * @memberOf SetCache 10207 * @param {*} value The value to search for. 10208 * @returns {number} Returns `true` if `value` is found, else `false`. 10209 */ 10210 function setCacheHas(value) { 10211 return this.__data__.has(value); 10212 } 10213 10214 // Add methods to `SetCache`. 10215 SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; 10216 SetCache.prototype.has = setCacheHas; 10217 10218 /*------------------------------------------------------------------------*/ 10219 10220 /** 10221 * Creates a stack cache object to store key-value pairs. 10222 * 10223 * @private 10224 * @constructor 10225 * @param {Array} [entries] The key-value pairs to cache. 10226 */ 10227 function Stack(entries) { 10228 var data = this.__data__ = new ListCache(entries); 10229 this.size = data.size; 10230 } 10231 10232 /** 10233 * Removes all key-value entries from the stack. 10234 * 10235 * @private 10236 * @name clear 10237 * @memberOf Stack 10238 */ 10239 function stackClear() { 10240 this.__data__ = new ListCache; 10241 this.size = 0; 10242 } 10243 10244 /** 10245 * Removes `key` and its value from the stack. 10246 * 10247 * @private 10248 * @name delete 10249 * @memberOf Stack 10250 * @param {string} key The key of the value to remove. 10251 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 10252 */ 10253 function stackDelete(key) { 10254 var data = this.__data__, 10255 result = data['delete'](key); 10256 10257 this.size = data.size; 10258 return result; 10259 } 10260 10261 /** 10262 * Gets the stack value for `key`. 10263 * 10264 * @private 10265 * @name get 10266 * @memberOf Stack 10267 * @param {string} key The key of the value to get. 10268 * @returns {*} Returns the entry value. 10269 */ 10270 function stackGet(key) { 10271 return this.__data__.get(key); 10272 } 10273 10274 /** 10275 * Checks if a stack value for `key` exists. 10276 * 10277 * @private 10278 * @name has 10279 * @memberOf Stack 10280 * @param {string} key The key of the entry to check. 10281 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 10282 */ 10283 function stackHas(key) { 10284 return this.__data__.has(key); 10285 } 10286 10287 /** 10288 * Sets the stack `key` to `value`. 10289 * 10290 * @private 10291 * @name set 10292 * @memberOf Stack 10293 * @param {string} key The key of the value to set. 10294 * @param {*} value The value to set. 10295 * @returns {Object} Returns the stack cache instance. 10296 */ 10297 function stackSet(key, value) { 10298 var data = this.__data__; 10299 if (data instanceof ListCache) { 10300 var pairs = data.__data__; 10301 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { 10302 pairs.push([key, value]); 10303 this.size = ++data.size; 10304 return this; 10305 } 10306 data = this.__data__ = new MapCache(pairs); 10307 } 10308 data.set(key, value); 10309 this.size = data.size; 10310 return this; 10311 } 10312 10313 // Add methods to `Stack`. 10314 Stack.prototype.clear = stackClear; 10315 Stack.prototype['delete'] = stackDelete; 10316 Stack.prototype.get = stackGet; 10317 Stack.prototype.has = stackHas; 10318 Stack.prototype.set = stackSet; 10319 10320 /*------------------------------------------------------------------------*/ 10321 10322 /** 10323 * Creates an array of the enumerable property names of the array-like `value`. 10324 * 10325 * @private 10326 * @param {*} value The value to query. 10327 * @param {boolean} inherited Specify returning inherited property names. 10328 * @returns {Array} Returns the array of property names. 10329 */ 10330 function arrayLikeKeys(value, inherited) { 10331 var isArr = isArray(value), 10332 isArg = !isArr && isArguments(value),
vendor: 43,113 bytes, lines 10333-11609
10333 isBuff = !isArr && !isArg && isBuffer(value), 10334 isType = !isArr && !isArg && !isBuff && isTypedArray(value), 10335 skipIndexes = isArr || isArg || isBuff || isType, 10336 result = skipIndexes ? baseTimes(value.length, String) : [], 10337 length = result.length; 10338 10339 for (var key in value) { 10340 if ((inherited || hasOwnProperty.call(value, key)) && 10341 !(skipIndexes && ( 10342 // Safari 9 has enumerable `arguments.length` in strict mode. 10343 key == 'length' || 10344 // Node.js 0.10 has enumerable non-index properties on buffers. 10345 (isBuff && (key == 'offset' || key == 'parent')) || 10346 // PhantomJS 2 has enumerable non-index properties on typed arrays. 10347 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || 10348 // Skip index properties. 10349 isIndex(key, length) 10350 ))) { 10351 result.push(key); 10352 } 10353 } 10354 return result; 10355 } 10356 10357 /** 10358 * A specialized version of `_.sample` for arrays. 10359 * 10360 * @private 10361 * @param {Array} array The array to sample. 10362 * @returns {*} Returns the random element. 10363 */ 10364 function arraySample(array) { 10365 var length = array.length; 10366 return length ? array[baseRandom(0, length - 1)] : undefined; 10367 } 10368 10369 /** 10370 * A specialized version of `_.sampleSize` for arrays. 10371 * 10372 * @private 10373 * @param {Array} array The array to sample. 10374 * @param {number} n The number of elements to sample. 10375 * @returns {Array} Returns the random elements. 10376 */ 10377 function arraySampleSize(array, n) { 10378 return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length)); 10379 } 10380 10381 /** 10382 * A specialized version of `_.shuffle` for arrays. 10383 * 10384 * @private 10385 * @param {Array} array The array to shuffle. 10386 * @returns {Array} Returns the new shuffled array. 10387 */ 10388 function arrayShuffle(array) { 10389 return shuffleSelf(copyArray(array)); 10390 } 10391 10392 /** 10393 * This function is like `assignValue` except that it doesn't assign 10394 * `undefined` values. 10395 * 10396 * @private 10397 * @param {Object} object The object to modify. 10398 * @param {string} key The key of the property to assign. 10399 * @param {*} value The value to assign. 10400 */ 10401 function assignMergeValue(object, key, value) { 10402 if ((value !== undefined && !eq(object[key], value)) || 10403 (value === undefined && !(key in object))) { 10404 baseAssignValue(object, key, value); 10405 } 10406 } 10407 10408 /** 10409 * Assigns `value` to `key` of `object` if the existing value is not equivalent 10410 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 10411 * for equality comparisons. 10412 * 10413 * @private 10414 * @param {Object} object The object to modify. 10415 * @param {string} key The key of the property to assign. 10416 * @param {*} value The value to assign. 10417 */ 10418 function assignValue(object, key, value) { 10419 var objValue = object[key]; 10420 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || 10421 (value === undefined && !(key in object))) { 10422 baseAssignValue(object, key, value); 10423 } 10424 } 10425 10426 /** 10427 * Gets the index at which the `key` is found in `array` of key-value pairs. 10428 * 10429 * @private 10430 * @param {Array} array The array to inspect. 10431 * @param {*} key The key to search for. 10432 * @returns {number} Returns the index of the matched value, else `-1`. 10433 */ 10434 function assocIndexOf(array, key) { 10435 var length = array.length; 10436 while (length--) { 10437 if (eq(array[length][0], key)) { 10438 return length; 10439 } 10440 } 10441 return -1; 10442 } 10443 10444 /** 10445 * Aggregates elements of `collection` on `accumulator` with keys transformed 10446 * by `iteratee` and values set by `setter`. 10447 * 10448 * @private 10449 * @param {Array|Object} collection The collection to iterate over. 10450 * @param {Function} setter The function to set `accumulator` values. 10451 * @param {Function} iteratee The iteratee to transform keys. 10452 * @param {Object} accumulator The initial aggregated object. 10453 * @returns {Function} Returns `accumulator`. 10454 */ 10455 function baseAggregator(collection, setter, iteratee, accumulator) { 10456 baseEach(collection, function(value, key, collection) { 10457 setter(accumulator, value, iteratee(value), collection); 10458 }); 10459 return accumulator; 10460 } 10461 10462 /** 10463 * The base implementation of `_.assign` without support for multiple sources 10464 * or `customizer` functions. 10465 * 10466 * @private 10467 * @param {Object} object The destination object. 10468 * @param {Object} source The source object. 10469 * @returns {Object} Returns `object`. 10470 */ 10471 function baseAssign(object, source) { 10472 return object && copyObject(source, keys(source), object); 10473 } 10474 10475 /** 10476 * The base implementation of `_.assignIn` without support for multiple sources 10477 * or `customizer` functions. 10478 * 10479 * @private 10480 * @param {Object} object The destination object. 10481 * @param {Object} source The source object. 10482 * @returns {Object} Returns `object`. 10483 */ 10484 function baseAssignIn(object, source) { 10485 return object && copyObject(source, keysIn(source), object); 10486 } 10487 10488 /** 10489 * The base implementation of `assignValue` and `assignMergeValue` without 10490 * value checks. 10491 * 10492 * @private 10493 * @param {Object} object The object to modify. 10494 * @param {string} key The key of the property to assign. 10495 * @param {*} value The value to assign. 10496 */ 10497 function baseAssignValue(object, key, value) { 10498 if (key == '__proto__' && defineProperty) { 10499 defineProperty(object, key, { 10500 'configurable': true, 10501 'enumerable': true, 10502 'value': value, 10503 'writable': true 10504 }); 10505 } else { 10506 object[key] = value; 10507 } 10508 } 10509 10510 /** 10511 * The base implementation of `_.at` without support for individual paths. 10512 * 10513 * @private 10514 * @param {Object} object The object to iterate over. 10515 * @param {string[]} paths The property paths to pick. 10516 * @returns {Array} Returns the picked elements. 10517 */ 10518 function baseAt(object, paths) { 10519 var index = -1, 10520 length = paths.length, 10521 result = Array(length), 10522 skip = object == null; 10523 10524 while (++index < length) { 10525 result[index] = skip ? undefined : get(object, paths[index]); 10526 } 10527 return result; 10528 } 10529 10530 /** 10531 * The base implementation of `_.clamp` which doesn't coerce arguments. 10532 * 10533 * @private 10534 * @param {number} number The number to clamp. 10535 * @param {number} [lower] The lower bound. 10536 * @param {number} upper The upper bound. 10537 * @returns {number} Returns the clamped number. 10538 */ 10539 function baseClamp(number, lower, upper) { 10540 if (number === number) { 10541 if (upper !== undefined) { 10542 number = number <= upper ? number : upper; 10543 } 10544 if (lower !== undefined) { 10545 number = number >= lower ? number : lower; 10546 } 10547 } 10548 return number; 10549 } 10550 10551 /** 10552 * The base implementation of `_.clone` and `_.cloneDeep` which tracks 10553 * traversed objects. 10554 * 10555 * @private 10556 * @param {*} value The value to clone. 10557 * @param {boolean} bitmask The bitmask flags. 10558 * 1 - Deep clone 10559 * 2 - Flatten inherited properties 10560 * 4 - Clone symbols 10561 * @param {Function} [customizer] The function to customize cloning. 10562 * @param {string} [key] The key of `value`. 10563 * @param {Object} [object] The parent object of `value`. 10564 * @param {Object} [stack] Tracks traversed objects and their clone counterparts. 10565 * @returns {*} Returns the cloned value. 10566 */ 10567 function baseClone(value, bitmask, customizer, key, object, stack) { 10568 var result, 10569 isDeep = bitmask & CLONE_DEEP_FLAG, 10570 isFlat = bitmask & CLONE_FLAT_FLAG, 10571 isFull = bitmask & CLONE_SYMBOLS_FLAG; 10572 10573 if (customizer) { 10574 result = object ? customizer(value, key, object, stack) : customizer(value); 10575 } 10576 if (result !== undefined) { 10577 return result; 10578 } 10579 if (!isObject(value)) { 10580 return value; 10581 } 10582 var isArr = isArray(value); 10583 if (isArr) { 10584 result = initCloneArray(value); 10585 if (!isDeep) { 10586 return copyArray(value, result); 10587 } 10588 } else { 10589 var tag = getTag(value), 10590 isFunc = tag == funcTag || tag == genTag; 10591 10592 if (isBuffer(value)) { 10593 return cloneBuffer(value, isDeep); 10594 } 10595 if (tag == objectTag || tag == argsTag || (isFunc && !object)) { 10596 result = (isFlat || isFunc) ? {} : initCloneObject(value); 10597 if (!isDeep) { 10598 return isFlat 10599 ? copySymbolsIn(value, baseAssignIn(result, value)) 10600 : copySymbols(value, baseAssign(result, value)); 10601 } 10602 } else { 10603 if (!cloneableTags[tag]) { 10604 return object ? value : {}; 10605 } 10606 result = initCloneByTag(value, tag, isDeep); 10607 } 10608 } 10609 // Check for circular references and return its corresponding clone. 10610 stack || (stack = new Stack); 10611 var stacked = stack.get(value); 10612 if (stacked) { 10613 return stacked; 10614 } 10615 stack.set(value, result); 10616 10617 if (isSet(value)) { 10618 value.forEach(function(subValue) { 10619 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); 10620 }); 10621 } else if (isMap(value)) { 10622 value.forEach(function(subValue, key) { 10623 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); 10624 }); 10625 } 10626 10627 var keysFunc = isFull 10628 ? (isFlat ? getAllKeysIn : getAllKeys) 10629 : (isFlat ? keysIn : keys); 10630 10631 var props = isArr ? undefined : keysFunc(value); 10632 arrayEach(props || value, function(subValue, key) { 10633 if (props) { 10634 key = subValue; 10635 subValue = value[key]; 10636 } 10637 // Recursively populate clone (susceptible to call stack limits). 10638 assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); 10639 }); 10640 return result; 10641 } 10642 10643 /** 10644 * The base implementation of `_.conforms` which doesn't clone `source`. 10645 * 10646 * @private 10647 * @param {Object} source The object of property predicates to conform to. 10648 * @returns {Function} Returns the new spec function. 10649 */ 10650 function baseConforms(source) { 10651 var props = keys(source); 10652 return function(object) { 10653 return baseConformsTo(object, source, props); 10654 }; 10655 } 10656 10657 /** 10658 * The base implementation of `_.conformsTo` which accepts `props` to check. 10659 * 10660 * @private 10661 * @param {Object} object The object to inspect. 10662 * @param {Object} source The object of property predicates to conform to. 10663 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 10664 */ 10665 function baseConformsTo(object, source, props) { 10666 var length = props.length; 10667 if (object == null) { 10668 return !length; 10669 } 10670 object = Object(object); 10671 while (length--) { 10672 var key = props[length], 10673 predicate = source[key], 10674 value = object[key]; 10675 10676 if ((value === undefined && !(key in object)) || !predicate(value)) { 10677 return false; 10678 } 10679 } 10680 return true; 10681 } 10682 10683 /** 10684 * The base implementation of `_.delay` and `_.defer` which accepts `args` 10685 * to provide to `func`. 10686 * 10687 * @private 10688 * @param {Function} func The function to delay. 10689 * @param {number} wait The number of milliseconds to delay invocation. 10690 * @param {Array} args The arguments to provide to `func`. 10691 * @returns {number|Object} Returns the timer id or timeout object. 10692 */ 10693 function baseDelay(func, wait, args) { 10694 if (typeof func != 'function') { 10695 throw new TypeError(FUNC_ERROR_TEXT); 10696 } 10697 return setTimeout(function() { func.apply(undefined, args); }, wait); 10698 } 10699 10700 /** 10701 * The base implementation of methods like `_.difference` without support 10702 * for excluding multiple arrays or iteratee shorthands. 10703 * 10704 * @private 10705 * @param {Array} array The array to inspect. 10706 * @param {Array} values The values to exclude. 10707 * @param {Function} [iteratee] The iteratee invoked per element. 10708 * @param {Function} [comparator] The comparator invoked per element. 10709 * @returns {Array} Returns the new array of filtered values. 10710 */ 10711 function baseDifference(array, values, iteratee, comparator) { 10712 var index = -1, 10713 includes = arrayIncludes, 10714 isCommon = true, 10715 length = array.length, 10716 result = [], 10717 valuesLength = values.length; 10718 10719 if (!length) { 10720 return result; 10721 } 10722 if (iteratee) { 10723 values = arrayMap(values, baseUnary(iteratee)); 10724 } 10725 if (comparator) { 10726 includes = arrayIncludesWith; 10727 isCommon = false; 10728 } 10729 else if (values.length >= LARGE_ARRAY_SIZE) { 10730 includes = cacheHas; 10731 isCommon = false; 10732 values = new SetCache(values); 10733 } 10734 outer: 10735 while (++index < length) { 10736 var value = array[index], 10737 computed = iteratee == null ? value : iteratee(value); 10738 10739 value = (comparator || value !== 0) ? value : 0; 10740 if (isCommon && computed === computed) { 10741 var valuesIndex = valuesLength; 10742 while (valuesIndex--) { 10743 if (values[valuesIndex] === computed) { 10744 continue outer; 10745 } 10746 } 10747 result.push(value); 10748 } 10749 else if (!includes(values, computed, comparator)) { 10750 result.push(value); 10751 } 10752 } 10753 return result; 10754 } 10755 10756 /** 10757 * The base implementation of `_.forEach` without support for iteratee shorthands. 10758 * 10759 * @private 10760 * @param {Array|Object} collection The collection to iterate over. 10761 * @param {Function} iteratee The function invoked per iteration. 10762 * @returns {Array|Object} Returns `collection`. 10763 */ 10764 var baseEach = createBaseEach(baseForOwn); 10765 10766 /** 10767 * The base implementation of `_.forEachRight` without support for iteratee shorthands. 10768 * 10769 * @private 10770 * @param {Array|Object} collection The collection to iterate over. 10771 * @param {Function} iteratee The function invoked per iteration. 10772 * @returns {Array|Object} Returns `collection`. 10773 */ 10774 var baseEachRight = createBaseEach(baseForOwnRight, true); 10775 10776 /** 10777 * The base implementation of `_.every` without support for iteratee shorthands. 10778 * 10779 * @private 10780 * @param {Array|Object} collection The collection to iterate over. 10781 * @param {Function} predicate The function invoked per iteration. 10782 * @returns {boolean} Returns `true` if all elements pass the predicate check, 10783 * else `false` 10784 */ 10785 function baseEvery(collection, predicate) { 10786 var result = true; 10787 baseEach(collection, function(value, index, collection) { 10788 result = !!predicate(value, index, collection); 10789 return result; 10790 }); 10791 return result; 10792 } 10793 10794 /** 10795 * The base implementation of methods like `_.max` and `_.min` which accepts a 10796 * `comparator` to determine the extremum value. 10797 * 10798 * @private 10799 * @param {Array} array The array to iterate over. 10800 * @param {Function} iteratee The iteratee invoked per iteration. 10801 * @param {Function} comparator The comparator used to compare values. 10802 * @returns {*} Returns the extremum value. 10803 */ 10804 function baseExtremum(array, iteratee, comparator) { 10805 var index = -1, 10806 length = array.length; 10807 10808 while (++index < length) { 10809 var value = array[index], 10810 current = iteratee(value); 10811 10812 if (current != null && (computed === undefined 10813 ? (current === current && !isSymbol(current)) 10814 : comparator(current, computed) 10815 )) { 10816 var computed = current, 10817 result = value; 10818 } 10819 } 10820 return result; 10821 } 10822 10823 /** 10824 * The base implementation of `_.fill` without an iteratee call guard. 10825 * 10826 * @private 10827 * @param {Array} array The array to fill. 10828 * @param {*} value The value to fill `array` with. 10829 * @param {number} [start=0] The start position. 10830 * @param {number} [end=array.length] The end position. 10831 * @returns {Array} Returns `array`. 10832 */ 10833 function baseFill(array, value, start, end) { 10834 var length = array.length; 10835 10836 start = toInteger(start); 10837 if (start < 0) { 10838 start = -start > length ? 0 : (length + start); 10839 } 10840 end = (end === undefined || end > length) ? length : toInteger(end); 10841 if (end < 0) { 10842 end += length; 10843 } 10844 end = start > end ? 0 : toLength(end); 10845 while (start < end) { 10846 array[start++] = value; 10847 } 10848 return array; 10849 } 10850 10851 /** 10852 * The base implementation of `_.filter` without support for iteratee shorthands. 10853 * 10854 * @private 10855 * @param {Array|Object} collection The collection to iterate over. 10856 * @param {Function} predicate The function invoked per iteration. 10857 * @returns {Array} Returns the new filtered array. 10858 */ 10859 function baseFilter(collection, predicate) { 10860 var result = []; 10861 baseEach(collection, function(value, index, collection) { 10862 if (predicate(value, index, collection)) { 10863 result.push(value); 10864 } 10865 }); 10866 return result; 10867 } 10868 10869 /** 10870 * The base implementation of `_.flatten` with support for restricting flattening. 10871 * 10872 * @private 10873 * @param {Array} array The array to flatten. 10874 * @param {number} depth The maximum recursion depth. 10875 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. 10876 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. 10877 * @param {Array} [result=[]] The initial result value. 10878 * @returns {Array} Returns the new flattened array. 10879 */ 10880 function baseFlatten(array, depth, predicate, isStrict, result) { 10881 var index = -1, 10882 length = array.length; 10883 10884 predicate || (predicate = isFlattenable); 10885 result || (result = []); 10886 10887 while (++index < length) { 10888 var value = array[index]; 10889 if (depth > 0 && predicate(value)) { 10890 if (depth > 1) { 10891 // Recursively flatten arrays (susceptible to call stack limits). 10892 baseFlatten(value, depth - 1, predicate, isStrict, result); 10893 } else { 10894 arrayPush(result, value); 10895 } 10896 } else if (!isStrict) { 10897 result[result.length] = value; 10898 } 10899 } 10900 return result; 10901 } 10902 10903 /** 10904 * The base implementation of `baseForOwn` which iterates over `object` 10905 * properties returned by `keysFunc` and invokes `iteratee` for each property. 10906 * Iteratee functions may exit iteration early by explicitly returning `false`. 10907 * 10908 * @private 10909 * @param {Object} object The object to iterate over. 10910 * @param {Function} iteratee The function invoked per iteration. 10911 * @param {Function} keysFunc The function to get the keys of `object`. 10912 * @returns {Object} Returns `object`. 10913 */ 10914 var baseFor = createBaseFor(); 10915 10916 /** 10917 * This function is like `baseFor` except that it iterates over properties 10918 * in the opposite order. 10919 * 10920 * @private 10921 * @param {Object} object The object to iterate over. 10922 * @param {Function} iteratee The function invoked per iteration. 10923 * @param {Function} keysFunc The function to get the keys of `object`. 10924 * @returns {Object} Returns `object`. 10925 */ 10926 var baseForRight = createBaseFor(true); 10927 10928 /** 10929 * The base implementation of `_.forOwn` without support for iteratee shorthands. 10930 * 10931 * @private 10932 * @param {Object} object The object to iterate over. 10933 * @param {Function} iteratee The function invoked per iteration. 10934 * @returns {Object} Returns `object`. 10935 */ 10936 function baseForOwn(object, iteratee) { 10937 return object && baseFor(object, iteratee, keys); 10938 } 10939 10940 /** 10941 * The base implementation of `_.forOwnRight` without support for iteratee shorthands. 10942 * 10943 * @private 10944 * @param {Object} object The object to iterate over. 10945 * @param {Function} iteratee The function invoked per iteration. 10946 * @returns {Object} Returns `object`. 10947 */ 10948 function baseForOwnRight(object, iteratee) { 10949 return object && baseForRight(object, iteratee, keys); 10950 } 10951 10952 /** 10953 * The base implementation of `_.functions` which creates an array of 10954 * `object` function property names filtered from `props`. 10955 * 10956 * @private 10957 * @param {Object} object The object to inspect. 10958 * @param {Array} props The property names to filter. 10959 * @returns {Array} Returns the function names. 10960 */ 10961 function baseFunctions(object, props) { 10962 return arrayFilter(props, function(key) { 10963 return isFunction(object[key]); 10964 }); 10965 } 10966 10967 /** 10968 * The base implementation of `_.get` without support for default values. 10969 * 10970 * @private 10971 * @param {Object} object The object to query. 10972 * @param {Array|string} path The path of the property to get. 10973 * @returns {*} Returns the resolved value. 10974 */ 10975 function baseGet(object, path) { 10976 path = castPath(path, object); 10977 10978 var index = 0, 10979 length = path.length; 10980 10981 while (object != null && index < length) { 10982 object = object[toKey(path[index++])]; 10983 } 10984 return (index && index == length) ? object : undefined; 10985 } 10986 10987 /** 10988 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses 10989 * `keysFunc` and `symbolsFunc` to get the enumerable property names and 10990 * symbols of `object`. 10991 * 10992 * @private 10993 * @param {Object} object The object to query. 10994 * @param {Function} keysFunc The function to get the keys of `object`. 10995 * @param {Function} symbolsFunc The function to get the symbols of `object`. 10996 * @returns {Array} Returns the array of property names and symbols. 10997 */ 10998 function baseGetAllKeys(object, keysFunc, symbolsFunc) { 10999 var result = keysFunc(object); 11000 return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); 11001 } 11002 11003 /** 11004 * The base implementation of `getTag` without fallbacks for buggy environments. 11005 * 11006 * @private 11007 * @param {*} value The value to query. 11008 * @returns {string} Returns the `toStringTag`. 11009 */ 11010 function baseGetTag(value) { 11011 if (value == null) { 11012 return value === undefined ? undefinedTag : nullTag; 11013 } 11014 return (symToStringTag && symToStringTag in Object(value)) 11015 ? getRawTag(value) 11016 : objectToString(value); 11017 } 11018 11019 /** 11020 * The base implementation of `_.gt` which doesn't coerce arguments. 11021 * 11022 * @private 11023 * @param {*} value The value to compare. 11024 * @param {*} other The other value to compare. 11025 * @returns {boolean} Returns `true` if `value` is greater than `other`, 11026 * else `false`. 11027 */ 11028 function baseGt(value, other) { 11029 return value > other; 11030 } 11031 11032 /** 11033 * The base implementation of `_.has` without support for deep paths. 11034 * 11035 * @private 11036 * @param {Object} [object] The object to query. 11037 * @param {Array|string} key The key to check. 11038 * @returns {boolean} Returns `true` if `key` exists, else `false`. 11039 */ 11040 function baseHas(object, key) { 11041 return object != null && hasOwnProperty.call(object, key); 11042 } 11043 11044 /** 11045 * The base implementation of `_.hasIn` without support for deep paths. 11046 * 11047 * @private 11048 * @param {Object} [object] The object to query. 11049 * @param {Array|string} key The key to check. 11050 * @returns {boolean} Returns `true` if `key` exists, else `false`. 11051 */ 11052 function baseHasIn(object, key) { 11053 return object != null && key in Object(object); 11054 } 11055 11056 /** 11057 * The base implementation of `_.inRange` which doesn't coerce arguments. 11058 * 11059 * @private 11060 * @param {number} number The number to check. 11061 * @param {number} start The start of the range. 11062 * @param {number} end The end of the range. 11063 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 11064 */ 11065 function baseInRange(number, start, end) { 11066 return number >= nativeMin(start, end) && number < nativeMax(start, end); 11067 } 11068 11069 /** 11070 * The base implementation of methods like `_.intersection`, without support 11071 * for iteratee shorthands, that accepts an array of arrays to inspect. 11072 * 11073 * @private 11074 * @param {Array} arrays The arrays to inspect. 11075 * @param {Function} [iteratee] The iteratee invoked per element. 11076 * @param {Function} [comparator] The comparator invoked per element. 11077 * @returns {Array} Returns the new array of shared values. 11078 */ 11079 function baseIntersection(arrays, iteratee, comparator) { 11080 var includes = comparator ? arrayIncludesWith : arrayIncludes, 11081 length = arrays[0].length, 11082 othLength = arrays.length, 11083 othIndex = othLength, 11084 caches = Array(othLength), 11085 maxLength = Infinity, 11086 result = []; 11087 11088 while (othIndex--) { 11089 var array = arrays[othIndex]; 11090 if (othIndex && iteratee) { 11091 array = arrayMap(array, baseUnary(iteratee)); 11092 } 11093 maxLength = nativeMin(array.length, maxLength); 11094 caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) 11095 ? new SetCache(othIndex && array) 11096 : undefined; 11097 } 11098 array = arrays[0]; 11099 11100 var index = -1, 11101 seen = caches[0]; 11102 11103 outer: 11104 while (++index < length && result.length < maxLength) { 11105 var value = array[index], 11106 computed = iteratee ? iteratee(value) : value; 11107 11108 value = (comparator || value !== 0) ? value : 0; 11109 if (!(seen 11110 ? cacheHas(seen, computed) 11111 : includes(result, computed, comparator) 11112 )) { 11113 othIndex = othLength; 11114 while (--othIndex) { 11115 var cache = caches[othIndex]; 11116 if (!(cache 11117 ? cacheHas(cache, computed) 11118 : includes(arrays[othIndex], computed, comparator)) 11119 ) { 11120 continue outer; 11121 } 11122 } 11123 if (seen) { 11124 seen.push(computed); 11125 } 11126 result.push(value); 11127 } 11128 } 11129 return result; 11130 } 11131 11132 /** 11133 * The base implementation of `_.invert` and `_.invertBy` which inverts 11134 * `object` with values transformed by `iteratee` and set by `setter`. 11135 * 11136 * @private 11137 * @param {Object} object The object to iterate over. 11138 * @param {Function} setter The function to set `accumulator` values. 11139 * @param {Function} iteratee The iteratee to transform values. 11140 * @param {Object} accumulator The initial inverted object. 11141 * @returns {Function} Returns `accumulator`. 11142 */ 11143 function baseInverter(object, setter, iteratee, accumulator) { 11144 baseForOwn(object, function(value, key, object) { 11145 setter(accumulator, iteratee(value), key, object); 11146 }); 11147 return accumulator; 11148 } 11149 11150 /** 11151 * The base implementation of `_.invoke` without support for individual 11152 * method arguments. 11153 * 11154 * @private 11155 * @param {Object} object The object to query. 11156 * @param {Array|string} path The path of the method to invoke. 11157 * @param {Array} args The arguments to invoke the method with. 11158 * @returns {*} Returns the result of the invoked method. 11159 */ 11160 function baseInvoke(object, path, args) { 11161 path = castPath(path, object); 11162 object = parent(object, path); 11163 var func = object == null ? object : object[toKey(last(path))]; 11164 return func == null ? undefined : apply(func, object, args); 11165 } 11166 11167 /** 11168 * The base implementation of `_.isArguments`. 11169 * 11170 * @private 11171 * @param {*} value The value to check. 11172 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 11173 */ 11174 function baseIsArguments(value) { 11175 return isObjectLike(value) && baseGetTag(value) == argsTag; 11176 } 11177 11178 /** 11179 * The base implementation of `_.isArrayBuffer` without Node.js optimizations. 11180 * 11181 * @private 11182 * @param {*} value The value to check. 11183 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 11184 */ 11185 function baseIsArrayBuffer(value) { 11186 return isObjectLike(value) && baseGetTag(value) == arrayBufferTag; 11187 } 11188 11189 /** 11190 * The base implementation of `_.isDate` without Node.js optimizations. 11191 * 11192 * @private 11193 * @param {*} value The value to check. 11194 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 11195 */ 11196 function baseIsDate(value) { 11197 return isObjectLike(value) && baseGetTag(value) == dateTag; 11198 } 11199 11200 /** 11201 * The base implementation of `_.isEqual` which supports partial comparisons 11202 * and tracks traversed objects. 11203 * 11204 * @private 11205 * @param {*} value The value to compare. 11206 * @param {*} other The other value to compare. 11207 * @param {boolean} bitmask The bitmask flags. 11208 * 1 - Unordered comparison 11209 * 2 - Partial comparison 11210 * @param {Function} [customizer] The function to customize comparisons. 11211 * @param {Object} [stack] Tracks traversed `value` and `other` objects. 11212 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 11213 */ 11214 function baseIsEqual(value, other, bitmask, customizer, stack) { 11215 if (value === other) { 11216 return true; 11217 } 11218 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { 11219 return value !== value && other !== other; 11220 } 11221 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); 11222 } 11223 11224 /** 11225 * A specialized version of `baseIsEqual` for arrays and objects which performs 11226 * deep comparisons and tracks traversed objects enabling objects with circular 11227 * references to be compared. 11228 * 11229 * @private 11230 * @param {Object} object The object to compare. 11231 * @param {Object} other The other object to compare. 11232 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 11233 * @param {Function} customizer The function to customize comparisons. 11234 * @param {Function} equalFunc The function to determine equivalents of values. 11235 * @param {Object} [stack] Tracks traversed `object` and `other` objects. 11236 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 11237 */ 11238 function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { 11239 var objIsArr = isArray(object), 11240 othIsArr = isArray(other), 11241 objTag = objIsArr ? arrayTag : getTag(object), 11242 othTag = othIsArr ? arrayTag : getTag(other); 11243 11244 objTag = objTag == argsTag ? objectTag : objTag; 11245 othTag = othTag == argsTag ? objectTag : othTag; 11246 11247 var objIsObj = objTag == objectTag, 11248 othIsObj = othTag == objectTag, 11249 isSameTag = objTag == othTag; 11250 11251 if (isSameTag && isBuffer(object)) { 11252 if (!isBuffer(other)) { 11253 return false; 11254 } 11255 objIsArr = true; 11256 objIsObj = false; 11257 } 11258 if (isSameTag && !objIsObj) { 11259 stack || (stack = new Stack); 11260 return (objIsArr || isTypedArray(object)) 11261 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) 11262 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); 11263 } 11264 if (!(bitmask & COMPARE_PARTIAL_FLAG)) { 11265 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), 11266 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); 11267 11268 if (objIsWrapped || othIsWrapped) { 11269 var objUnwrapped = objIsWrapped ? object.value() : object, 11270 othUnwrapped = othIsWrapped ? other.value() : other; 11271 11272 stack || (stack = new Stack); 11273 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); 11274 } 11275 } 11276 if (!isSameTag) { 11277 return false; 11278 } 11279 stack || (stack = new Stack); 11280 return equalObjects(object, other, bitmask, customizer, equalFunc, stack); 11281 } 11282 11283 /** 11284 * The base implementation of `_.isMap` without Node.js optimizations. 11285 * 11286 * @private 11287 * @param {*} value The value to check. 11288 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 11289 */ 11290 function baseIsMap(value) { 11291 return isObjectLike(value) && getTag(value) == mapTag; 11292 } 11293 11294 /** 11295 * The base implementation of `_.isMatch` without support for iteratee shorthands. 11296 * 11297 * @private 11298 * @param {Object} object The object to inspect. 11299 * @param {Object} source The object of property values to match. 11300 * @param {Array} matchData The property names, values, and compare flags to match. 11301 * @param {Function} [customizer] The function to customize comparisons. 11302 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 11303 */ 11304 function baseIsMatch(object, source, matchData, customizer) { 11305 var index = matchData.length, 11306 length = index, 11307 noCustomizer = !customizer; 11308 11309 if (object == null) { 11310 return !length; 11311 } 11312 object = Object(object); 11313 while (index--) { 11314 var data = matchData[index]; 11315 if ((noCustomizer && data[2]) 11316 ? data[1] !== object[data[0]] 11317 : !(data[0] in object) 11318 ) { 11319 return false; 11320 } 11321 } 11322 while (++index < length) { 11323 data = matchData[index]; 11324 var key = data[0], 11325 objValue = object[key], 11326 srcValue = data[1]; 11327 11328 if (noCustomizer && data[2]) { 11329 if (objValue === undefined && !(key in object)) { 11330 return false; 11331 } 11332 } else { 11333 var stack = new Stack; 11334 if (customizer) { 11335 var result = customizer(objValue, srcValue, key, object, source, stack); 11336 } 11337 if (!(result === undefined 11338 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) 11339 : result 11340 )) { 11341 return false; 11342 } 11343 } 11344 } 11345 return true; 11346 } 11347 11348 /** 11349 * The base implementation of `_.isNative` without bad shim checks. 11350 * 11351 * @private 11352 * @param {*} value The value to check. 11353 * @returns {boolean} Returns `true` if `value` is a native function, 11354 * else `false`. 11355 */ 11356 function baseIsNative(value) { 11357 if (!isObject(value) || isMasked(value)) { 11358 return false; 11359 } 11360 var pattern = isFunction(value) ? reIsNative : reIsHostCtor; 11361 return pattern.test(toSource(value)); 11362 } 11363 11364 /** 11365 * The base implementation of `_.isRegExp` without Node.js optimizations. 11366 * 11367 * @private 11368 * @param {*} value The value to check. 11369 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 11370 */ 11371 function baseIsRegExp(value) { 11372 return isObjectLike(value) && baseGetTag(value) == regexpTag; 11373 } 11374 11375 /** 11376 * The base implementation of `_.isSet` without Node.js optimizations. 11377 * 11378 * @private 11379 * @param {*} value The value to check. 11380 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 11381 */ 11382 function baseIsSet(value) { 11383 return isObjectLike(value) && getTag(value) == setTag; 11384 } 11385 11386 /** 11387 * The base implementation of `_.isTypedArray` without Node.js optimizations. 11388 * 11389 * @private 11390 * @param {*} value The value to check. 11391 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 11392 */ 11393 function baseIsTypedArray(value) { 11394 return isObjectLike(value) && 11395 isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; 11396 } 11397 11398 /** 11399 * The base implementation of `_.iteratee`. 11400 * 11401 * @private 11402 * @param {*} [value=_.identity] The value to convert to an iteratee. 11403 * @returns {Function} Returns the iteratee. 11404 */ 11405 function baseIteratee(value) { 11406 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. 11407 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. 11408 if (typeof value == 'function') { 11409 return value; 11410 } 11411 if (value == null) { 11412 return identity; 11413 } 11414 if (typeof value == 'object') { 11415 return isArray(value) 11416 ? baseMatchesProperty(value[0], value[1]) 11417 : baseMatches(value); 11418 } 11419 return property(value); 11420 } 11421 11422 /** 11423 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. 11424 * 11425 * @private 11426 * @param {Object} object The object to query. 11427 * @returns {Array} Returns the array of property names. 11428 */ 11429 function baseKeys(object) { 11430 if (!isPrototype(object)) { 11431 return nativeKeys(object); 11432 } 11433 var result = []; 11434 for (var key in Object(object)) { 11435 if (hasOwnProperty.call(object, key) && key != 'constructor') { 11436 result.push(key); 11437 } 11438 } 11439 return result; 11440 } 11441 11442 /** 11443 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. 11444 * 11445 * @private 11446 * @param {Object} object The object to query. 11447 * @returns {Array} Returns the array of property names. 11448 */ 11449 function baseKeysIn(object) { 11450 if (!isObject(object)) { 11451 return nativeKeysIn(object); 11452 } 11453 var isProto = isPrototype(object), 11454 result = []; 11455 11456 for (var key in object) { 11457 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { 11458 result.push(key); 11459 } 11460 } 11461 return result; 11462 } 11463 11464 /** 11465 * The base implementation of `_.lt` which doesn't coerce arguments. 11466 * 11467 * @private 11468 * @param {*} value The value to compare. 11469 * @param {*} other The other value to compare. 11470 * @returns {boolean} Returns `true` if `value` is less than `other`, 11471 * else `false`. 11472 */ 11473 function baseLt(value, other) { 11474 return value < other; 11475 } 11476 11477 /** 11478 * The base implementation of `_.map` without support for iteratee shorthands. 11479 * 11480 * @private 11481 * @param {Array|Object} collection The collection to iterate over. 11482 * @param {Function} iteratee The function invoked per iteration. 11483 * @returns {Array} Returns the new mapped array. 11484 */ 11485 function baseMap(collection, iteratee) { 11486 var index = -1, 11487 result = isArrayLike(collection) ? Array(collection.length) : []; 11488 11489 baseEach(collection, function(value, key, collection) { 11490 result[++index] = iteratee(value, key, collection); 11491 }); 11492 return result; 11493 } 11494 11495 /** 11496 * The base implementation of `_.matches` which doesn't clone `source`. 11497 * 11498 * @private 11499 * @param {Object} source The object of property values to match. 11500 * @returns {Function} Returns the new spec function. 11501 */ 11502 function baseMatches(source) { 11503 var matchData = getMatchData(source); 11504 if (matchData.length == 1 && matchData[0][2]) { 11505 return matchesStrictComparable(matchData[0][0], matchData[0][1]); 11506 } 11507 return function(object) { 11508 return object === source || baseIsMatch(object, source, matchData); 11509 }; 11510 } 11511 11512 /** 11513 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. 11514 * 11515 * @private 11516 * @param {string} path The path of the property to get. 11517 * @param {*} srcValue The value to match. 11518 * @returns {Function} Returns the new spec function. 11519 */ 11520 function baseMatchesProperty(path, srcValue) { 11521 if (isKey(path) && isStrictComparable(srcValue)) { 11522 return matchesStrictComparable(toKey(path), srcValue); 11523 } 11524 return function(object) { 11525 var objValue = get(object, path); 11526 return (objValue === undefined && objValue === srcValue) 11527 ? hasIn(object, path) 11528 : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); 11529 }; 11530 } 11531 11532 /** 11533 * The base implementation of `_.merge` without support for multiple sources. 11534 * 11535 * @private 11536 * @param {Object} object The destination object. 11537 * @param {Object} source The source object. 11538 * @param {number} srcIndex The index of `source`. 11539 * @param {Function} [customizer] The function to customize merged values. 11540 * @param {Object} [stack] Tracks traversed source values and their merged 11541 * counterparts. 11542 */ 11543 function baseMerge(object, source, srcIndex, customizer, stack) { 11544 if (object === source) { 11545 return; 11546 } 11547 baseFor(source, function(srcValue, key) { 11548 stack || (stack = new Stack); 11549 if (isObject(srcValue)) { 11550 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); 11551 } 11552 else { 11553 var newValue = customizer 11554 ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) 11555 : undefined; 11556 11557 if (newValue === undefined) { 11558 newValue = srcValue; 11559 } 11560 assignMergeValue(object, key, newValue); 11561 } 11562 }, keysIn); 11563 } 11564 11565 /** 11566 * A specialized version of `baseMerge` for arrays and objects which performs 11567 * deep merges and tracks traversed objects enabling objects with circular 11568 * references to be merged. 11569 * 11570 * @private 11571 * @param {Object} object The destination object. 11572 * @param {Object} source The source object. 11573 * @param {string} key The key of the value to merge. 11574 * @param {number} srcIndex The index of `source`. 11575 * @param {Function} mergeFunc The function to merge values. 11576 * @param {Function} [customizer] The function to customize assigned values. 11577 * @param {Object} [stack] Tracks traversed source values and their merged 11578 * counterparts. 11579 */ 11580 function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { 11581 var objValue = safeGet(object, key), 11582 srcValue = safeGet(source, key), 11583 stacked = stack.get(srcValue); 11584 11585 if (stacked) { 11586 assignMergeValue(object, key, stacked); 11587 return; 11588 } 11589 var newValue = customizer 11590 ? customizer(objValue, srcValue, (key + ''), object, source, stack) 11591 : undefined; 11592 11593 var isCommon = newValue === undefined; 11594 11595 if (isCommon) { 11596 var isArr = isArray(srcValue), 11597 isBuff = !isArr && isBuffer(srcValue), 11598 isTyped = !isArr && !isBuff && isTypedArray(srcValue); 11599 11600 newValue = srcValue; 11601 if (isArr || isBuff || isTyped) { 11602 if (isArray(objValue)) { 11603 newValue = objValue; 11604 } 11605 else if (isArrayLikeObject(objValue)) { 11606 newValue = copyArray(objValue); 11607 } 11608 else if (isBuff) { 11609 isCommon = false;
vendor: 15,233 bytes, lines 11610-12088
11610 newValue = cloneBuffer(srcValue, true); 11611 } 11612 else if (isTyped) { 11613 isCommon = false; 11614 newValue = cloneTypedArray(srcValue, true); 11615 } 11616 else { 11617 newValue = []; 11618 } 11619 } 11620 else if (isPlainObject(srcValue) || isArguments(srcValue)) { 11621 newValue = objValue; 11622 if (isArguments(objValue)) { 11623 newValue = toPlainObject(objValue); 11624 } 11625 else if (!isObject(objValue) || isFunction(objValue)) { 11626 newValue = initCloneObject(srcValue); 11627 } 11628 } 11629 else { 11630 isCommon = false; 11631 } 11632 } 11633 if (isCommon) { 11634 // Recursively merge objects and arrays (susceptible to call stack limits). 11635 stack.set(srcValue, newValue); 11636 mergeFunc(newValue, srcValue, srcIndex, customizer, stack); 11637 stack['delete'](srcValue); 11638 } 11639 assignMergeValue(object, key, newValue); 11640 } 11641 11642 /** 11643 * The base implementation of `_.nth` which doesn't coerce arguments. 11644 * 11645 * @private 11646 * @param {Array} array The array to query. 11647 * @param {number} n The index of the element to return. 11648 * @returns {*} Returns the nth element of `array`. 11649 */ 11650 function baseNth(array, n) { 11651 var length = array.length; 11652 if (!length) { 11653 return; 11654 } 11655 n += n < 0 ? length : 0; 11656 return isIndex(n, length) ? array[n] : undefined; 11657 } 11658 11659 /** 11660 * The base implementation of `_.orderBy` without param guards. 11661 * 11662 * @private 11663 * @param {Array|Object} collection The collection to iterate over. 11664 * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. 11665 * @param {string[]} orders The sort orders of `iteratees`. 11666 * @returns {Array} Returns the new sorted array. 11667 */ 11668 function baseOrderBy(collection, iteratees, orders) { 11669 var index = -1; 11670 iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee())); 11671 11672 var result = baseMap(collection, function(value, key, collection) { 11673 var criteria = arrayMap(iteratees, function(iteratee) { 11674 return iteratee(value); 11675 }); 11676 return { 'criteria': criteria, 'index': ++index, 'value': value }; 11677 }); 11678 11679 return baseSortBy(result, function(object, other) { 11680 return compareMultiple(object, other, orders); 11681 }); 11682 } 11683 11684 /** 11685 * The base implementation of `_.pick` without support for individual 11686 * property identifiers. 11687 * 11688 * @private 11689 * @param {Object} object The source object. 11690 * @param {string[]} paths The property paths to pick. 11691 * @returns {Object} Returns the new object. 11692 */ 11693 function basePick(object, paths) { 11694 return basePickBy(object, paths, function(value, path) { 11695 return hasIn(object, path); 11696 }); 11697 } 11698 11699 /** 11700 * The base implementation of `_.pickBy` without support for iteratee shorthands. 11701 * 11702 * @private 11703 * @param {Object} object The source object. 11704 * @param {string[]} paths The property paths to pick. 11705 * @param {Function} predicate The function invoked per property. 11706 * @returns {Object} Returns the new object. 11707 */ 11708 function basePickBy(object, paths, predicate) { 11709 var index = -1, 11710 length = paths.length, 11711 result = {}; 11712 11713 while (++index < length) { 11714 var path = paths[index], 11715 value = baseGet(object, path); 11716 11717 if (predicate(value, path)) { 11718 baseSet(result, castPath(path, object), value); 11719 } 11720 } 11721 return result; 11722 } 11723 11724 /** 11725 * A specialized version of `baseProperty` which supports deep paths. 11726 * 11727 * @private 11728 * @param {Array|string} path The path of the property to get. 11729 * @returns {Function} Returns the new accessor function. 11730 */ 11731 function basePropertyDeep(path) { 11732 return function(object) { 11733 return baseGet(object, path); 11734 }; 11735 } 11736 11737 /** 11738 * The base implementation of `_.pullAllBy` without support for iteratee 11739 * shorthands. 11740 * 11741 * @private 11742 * @param {Array} array The array to modify. 11743 * @param {Array} values The values to remove. 11744 * @param {Function} [iteratee] The iteratee invoked per element. 11745 * @param {Function} [comparator] The comparator invoked per element. 11746 * @returns {Array} Returns `array`. 11747 */ 11748 function basePullAll(array, values, iteratee, comparator) { 11749 var indexOf = comparator ? baseIndexOfWith : baseIndexOf, 11750 index = -1, 11751 length = values.length, 11752 seen = array; 11753 11754 if (array === values) { 11755 values = copyArray(values); 11756 } 11757 if (iteratee) { 11758 seen = arrayMap(array, baseUnary(iteratee)); 11759 } 11760 while (++index < length) { 11761 var fromIndex = 0, 11762 value = values[index], 11763 computed = iteratee ? iteratee(value) : value; 11764 11765 while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { 11766 if (seen !== array) { 11767 splice.call(seen, fromIndex, 1); 11768 } 11769 splice.call(array, fromIndex, 1); 11770 } 11771 } 11772 return array; 11773 } 11774 11775 /** 11776 * The base implementation of `_.pullAt` without support for individual 11777 * indexes or capturing the removed elements. 11778 * 11779 * @private 11780 * @param {Array} array The array to modify. 11781 * @param {number[]} indexes The indexes of elements to remove. 11782 * @returns {Array} Returns `array`. 11783 */ 11784 function basePullAt(array, indexes) { 11785 var length = array ? indexes.length : 0, 11786 lastIndex = length - 1; 11787 11788 while (length--) { 11789 var index = indexes[length]; 11790 if (length == lastIndex || index !== previous) { 11791 var previous = index; 11792 if (isIndex(index)) { 11793 splice.call(array, index, 1); 11794 } else { 11795 baseUnset(array, index); 11796 } 11797 } 11798 } 11799 return array; 11800 } 11801 11802 /** 11803 * The base implementation of `_.random` without support for returning 11804 * floating-point numbers. 11805 * 11806 * @private 11807 * @param {number} lower The lower bound. 11808 * @param {number} upper The upper bound. 11809 * @returns {number} Returns the random number. 11810 */ 11811 function baseRandom(lower, upper) { 11812 return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); 11813 } 11814 11815 /** 11816 * The base implementation of `_.range` and `_.rangeRight` which doesn't 11817 * coerce arguments. 11818 * 11819 * @private 11820 * @param {number} start The start of the range. 11821 * @param {number} end The end of the range. 11822 * @param {number} step The value to increment or decrement by. 11823 * @param {boolean} [fromRight] Specify iterating from right to left. 11824 * @returns {Array} Returns the range of numbers. 11825 */ 11826 function baseRange(start, end, step, fromRight) { 11827 var index = -1, 11828 length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), 11829 result = Array(length); 11830 11831 while (length--) { 11832 result[fromRight ? length : ++index] = start; 11833 start += step; 11834 } 11835 return result; 11836 } 11837 11838 /** 11839 * The base implementation of `_.repeat` which doesn't coerce arguments. 11840 * 11841 * @private 11842 * @param {string} string The string to repeat. 11843 * @param {number} n The number of times to repeat the string. 11844 * @returns {string} Returns the repeated string. 11845 */ 11846 function baseRepeat(string, n) { 11847 var result = ''; 11848 if (!string || n < 1 || n > MAX_SAFE_INTEGER) { 11849 return result; 11850 } 11851 // Leverage the exponentiation by squaring algorithm for a faster repeat. 11852 // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. 11853 do { 11854 if (n % 2) { 11855 result += string; 11856 } 11857 n = nativeFloor(n / 2); 11858 if (n) { 11859 string += string; 11860 } 11861 } while (n); 11862 11863 return result; 11864 } 11865 11866 /** 11867 * The base implementation of `_.rest` which doesn't validate or coerce arguments. 11868 * 11869 * @private 11870 * @param {Function} func The function to apply a rest parameter to. 11871 * @param {number} [start=func.length-1] The start position of the rest parameter. 11872 * @returns {Function} Returns the new function. 11873 */ 11874 function baseRest(func, start) { 11875 return setToString(overRest(func, start, identity), func + ''); 11876 } 11877 11878 /** 11879 * The base implementation of `_.sample`. 11880 * 11881 * @private 11882 * @param {Array|Object} collection The collection to sample. 11883 * @returns {*} Returns the random element. 11884 */ 11885 function baseSample(collection) { 11886 return arraySample(values(collection)); 11887 } 11888 11889 /** 11890 * The base implementation of `_.sampleSize` without param guards. 11891 * 11892 * @private 11893 * @param {Array|Object} collection The collection to sample. 11894 * @param {number} n The number of elements to sample. 11895 * @returns {Array} Returns the random elements. 11896 */ 11897 function baseSampleSize(collection, n) { 11898 var array = values(collection); 11899 return shuffleSelf(array, baseClamp(n, 0, array.length)); 11900 } 11901 11902 /** 11903 * The base implementation of `_.set`. 11904 * 11905 * @private 11906 * @param {Object} object The object to modify. 11907 * @param {Array|string} path The path of the property to set. 11908 * @param {*} value The value to set. 11909 * @param {Function} [customizer] The function to customize path creation. 11910 * @returns {Object} Returns `object`. 11911 */ 11912 function baseSet(object, path, value, customizer) { 11913 if (!isObject(object)) { 11914 return object; 11915 } 11916 path = castPath(path, object); 11917 11918 var index = -1, 11919 length = path.length, 11920 lastIndex = length - 1, 11921 nested = object; 11922 11923 while (nested != null && ++index < length) { 11924 var key = toKey(path[index]), 11925 newValue = value; 11926 11927 if (index != lastIndex) { 11928 var objValue = nested[key]; 11929 newValue = customizer ? customizer(objValue, key, nested) : undefined; 11930 if (newValue === undefined) { 11931 newValue = isObject(objValue) 11932 ? objValue 11933 : (isIndex(path[index + 1]) ? [] : {}); 11934 } 11935 } 11936 assignValue(nested, key, newValue); 11937 nested = nested[key]; 11938 } 11939 return object; 11940 } 11941 11942 /** 11943 * The base implementation of `setData` without support for hot loop shorting. 11944 * 11945 * @private 11946 * @param {Function} func The function to associate metadata with. 11947 * @param {*} data The metadata. 11948 * @returns {Function} Returns `func`. 11949 */ 11950 var baseSetData = !metaMap ? identity : function(func, data) { 11951 metaMap.set(func, data); 11952 return func; 11953 }; 11954 11955 /** 11956 * The base implementation of `setToString` without support for hot loop shorting. 11957 * 11958 * @private 11959 * @param {Function} func The function to modify. 11960 * @param {Function} string The `toString` result. 11961 * @returns {Function} Returns `func`. 11962 */ 11963 var baseSetToString = !defineProperty ? identity : function(func, string) { 11964 return defineProperty(func, 'toString', { 11965 'configurable': true, 11966 'enumerable': false, 11967 'value': constant(string), 11968 'writable': true 11969 }); 11970 }; 11971 11972 /** 11973 * The base implementation of `_.shuffle`. 11974 * 11975 * @private 11976 * @param {Array|Object} collection The collection to shuffle. 11977 * @returns {Array} Returns the new shuffled array. 11978 */ 11979 function baseShuffle(collection) { 11980 return shuffleSelf(values(collection)); 11981 } 11982 11983 /** 11984 * The base implementation of `_.slice` without an iteratee call guard. 11985 * 11986 * @private 11987 * @param {Array} array The array to slice. 11988 * @param {number} [start=0] The start position. 11989 * @param {number} [end=array.length] The end position. 11990 * @returns {Array} Returns the slice of `array`. 11991 */ 11992 function baseSlice(array, start, end) { 11993 var index = -1, 11994 length = array.length; 11995 11996 if (start < 0) { 11997 start = -start > length ? 0 : (length + start); 11998 } 11999 end = end > length ? length : end; 12000 if (end < 0) { 12001 end += length; 12002 } 12003 length = start > end ? 0 : ((end - start) >>> 0); 12004 start >>>= 0; 12005 12006 var result = Array(length); 12007 while (++index < length) { 12008 result[index] = array[index + start]; 12009 } 12010 return result; 12011 } 12012 12013 /** 12014 * The base implementation of `_.some` without support for iteratee shorthands. 12015 * 12016 * @private 12017 * @param {Array|Object} collection The collection to iterate over. 12018 * @param {Function} predicate The function invoked per iteration. 12019 * @returns {boolean} Returns `true` if any element passes the predicate check, 12020 * else `false`. 12021 */ 12022 function baseSome(collection, predicate) { 12023 var result; 12024 12025 baseEach(collection, function(value, index, collection) { 12026 result = predicate(value, index, collection); 12027 return !result; 12028 }); 12029 return !!result; 12030 } 12031 12032 /** 12033 * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which 12034 * performs a binary search of `array` to determine the index at which `value` 12035 * should be inserted into `array` in order to maintain its sort order. 12036 * 12037 * @private 12038 * @param {Array} array The sorted array to inspect. 12039 * @param {*} value The value to evaluate. 12040 * @param {boolean} [retHighest] Specify returning the highest qualified index. 12041 * @returns {number} Returns the index at which `value` should be inserted 12042 * into `array`. 12043 */ 12044 function baseSortedIndex(array, value, retHighest) { 12045 var low = 0, 12046 high = array == null ? low : array.length; 12047 12048 if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { 12049 while (low < high) { 12050 var mid = (low + high) >>> 1, 12051 computed = array[mid]; 12052 12053 if (computed !== null && !isSymbol(computed) && 12054 (retHighest ? (computed <= value) : (computed < value))) { 12055 low = mid + 1; 12056 } else { 12057 high = mid; 12058 } 12059 } 12060 return high; 12061 } 12062 return baseSortedIndexBy(array, value, identity, retHighest); 12063 } 12064 12065 /** 12066 * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` 12067 * which invokes `iteratee` for `value` and each element of `array` to compute 12068 * their sort ranking. The iteratee is invoked with one argument; (value). 12069 * 12070 * @private 12071 * @param {Array} array The sorted array to inspect. 12072 * @param {*} value The value to evaluate. 12073 * @param {Function} iteratee The iteratee invoked per element. 12074 * @param {boolean} [retHighest] Specify returning the highest qualified index. 12075 * @returns {number} Returns the index at which `value` should be inserted 12076 * into `array`. 12077 */ 12078 function baseSortedIndexBy(array, value, iteratee, retHighest) { 12079 value = iteratee(value); 12080 12081 var low = 0, 12082 high = array == null ? 0 : array.length, 12083 valIsNaN = value !== value, 12084 valIsNull = value === null, 12085 valIsSymbol = isSymbol(value), 12086 valIsUndefined = value === undefined; 12087 12088 while (low < high) {
vendor: 51,297 bytes, lines 12089-13566
12089 var mid = nativeFloor((low + high) / 2), 12090 computed = iteratee(array[mid]), 12091 othIsDefined = computed !== undefined, 12092 othIsNull = computed === null, 12093 othIsReflexive = computed === computed, 12094 othIsSymbol = isSymbol(computed); 12095 12096 if (valIsNaN) { 12097 var setLow = retHighest || othIsReflexive; 12098 } else if (valIsUndefined) { 12099 setLow = othIsReflexive && (retHighest || othIsDefined); 12100 } else if (valIsNull) { 12101 setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); 12102 } else if (valIsSymbol) { 12103 setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol); 12104 } else if (othIsNull || othIsSymbol) { 12105 setLow = false; 12106 } else { 12107 setLow = retHighest ? (computed <= value) : (computed < value); 12108 } 12109 if (setLow) { 12110 low = mid + 1; 12111 } else { 12112 high = mid; 12113 } 12114 } 12115 return nativeMin(high, MAX_ARRAY_INDEX); 12116 } 12117 12118 /** 12119 * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without 12120 * support for iteratee shorthands. 12121 * 12122 * @private 12123 * @param {Array} array The array to inspect. 12124 * @param {Function} [iteratee] The iteratee invoked per element. 12125 * @returns {Array} Returns the new duplicate free array. 12126 */ 12127 function baseSortedUniq(array, iteratee) { 12128 var index = -1, 12129 length = array.length, 12130 resIndex = 0, 12131 result = []; 12132 12133 while (++index < length) { 12134 var value = array[index], 12135 computed = iteratee ? iteratee(value) : value; 12136 12137 if (!index || !eq(computed, seen)) { 12138 var seen = computed; 12139 result[resIndex++] = value === 0 ? 0 : value; 12140 } 12141 } 12142 return result; 12143 } 12144 12145 /** 12146 * The base implementation of `_.toNumber` which doesn't ensure correct 12147 * conversions of binary, hexadecimal, or octal string values. 12148 * 12149 * @private 12150 * @param {*} value The value to process. 12151 * @returns {number} Returns the number. 12152 */ 12153 function baseToNumber(value) { 12154 if (typeof value == 'number') { 12155 return value; 12156 } 12157 if (isSymbol(value)) { 12158 return NAN; 12159 } 12160 return +value; 12161 } 12162 12163 /** 12164 * The base implementation of `_.toString` which doesn't convert nullish 12165 * values to empty strings. 12166 * 12167 * @private 12168 * @param {*} value The value to process. 12169 * @returns {string} Returns the string. 12170 */ 12171 function baseToString(value) { 12172 // Exit early for strings to avoid a performance hit in some environments. 12173 if (typeof value == 'string') { 12174 return value; 12175 } 12176 if (isArray(value)) { 12177 // Recursively convert values (susceptible to call stack limits). 12178 return arrayMap(value, baseToString) + ''; 12179 } 12180 if (isSymbol(value)) { 12181 return symbolToString ? symbolToString.call(value) : ''; 12182 } 12183 var result = (value + ''); 12184 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 12185 } 12186 12187 /** 12188 * The base implementation of `_.uniqBy` without support for iteratee shorthands. 12189 * 12190 * @private 12191 * @param {Array} array The array to inspect. 12192 * @param {Function} [iteratee] The iteratee invoked per element. 12193 * @param {Function} [comparator] The comparator invoked per element. 12194 * @returns {Array} Returns the new duplicate free array. 12195 */ 12196 function baseUniq(array, iteratee, comparator) { 12197 var index = -1, 12198 includes = arrayIncludes, 12199 length = array.length, 12200 isCommon = true, 12201 result = [], 12202 seen = result; 12203 12204 if (comparator) { 12205 isCommon = false; 12206 includes = arrayIncludesWith; 12207 } 12208 else if (length >= LARGE_ARRAY_SIZE) { 12209 var set = iteratee ? null : createSet(array); 12210 if (set) { 12211 return setToArray(set); 12212 } 12213 isCommon = false; 12214 includes = cacheHas; 12215 seen = new SetCache; 12216 } 12217 else { 12218 seen = iteratee ? [] : result; 12219 } 12220 outer: 12221 while (++index < length) { 12222 var value = array[index], 12223 computed = iteratee ? iteratee(value) : value; 12224 12225 value = (comparator || value !== 0) ? value : 0; 12226 if (isCommon && computed === computed) { 12227 var seenIndex = seen.length; 12228 while (seenIndex--) { 12229 if (seen[seenIndex] === computed) { 12230 continue outer; 12231 } 12232 } 12233 if (iteratee) { 12234 seen.push(computed); 12235 } 12236 result.push(value); 12237 } 12238 else if (!includes(seen, computed, comparator)) { 12239 if (seen !== result) { 12240 seen.push(computed); 12241 } 12242 result.push(value); 12243 } 12244 } 12245 return result; 12246 } 12247 12248 /** 12249 * The base implementation of `_.unset`. 12250 * 12251 * @private 12252 * @param {Object} object The object to modify. 12253 * @param {Array|string} path The property path to unset. 12254 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 12255 */ 12256 function baseUnset(object, path) { 12257 path = castPath(path, object); 12258 object = parent(object, path); 12259 return object == null || delete object[toKey(last(path))]; 12260 } 12261 12262 /** 12263 * The base implementation of `_.update`. 12264 * 12265 * @private 12266 * @param {Object} object The object to modify. 12267 * @param {Array|string} path The path of the property to update. 12268 * @param {Function} updater The function to produce the updated value. 12269 * @param {Function} [customizer] The function to customize path creation. 12270 * @returns {Object} Returns `object`. 12271 */ 12272 function baseUpdate(object, path, updater, customizer) { 12273 return baseSet(object, path, updater(baseGet(object, path)), customizer); 12274 } 12275 12276 /** 12277 * The base implementation of methods like `_.dropWhile` and `_.takeWhile` 12278 * without support for iteratee shorthands. 12279 * 12280 * @private 12281 * @param {Array} array The array to query. 12282 * @param {Function} predicate The function invoked per iteration. 12283 * @param {boolean} [isDrop] Specify dropping elements instead of taking them. 12284 * @param {boolean} [fromRight] Specify iterating from right to left. 12285 * @returns {Array} Returns the slice of `array`. 12286 */ 12287 function baseWhile(array, predicate, isDrop, fromRight) { 12288 var length = array.length, 12289 index = fromRight ? length : -1; 12290 12291 while ((fromRight ? index-- : ++index < length) && 12292 predicate(array[index], index, array)) {} 12293 12294 return isDrop 12295 ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) 12296 : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); 12297 } 12298 12299 /** 12300 * The base implementation of `wrapperValue` which returns the result of 12301 * performing a sequence of actions on the unwrapped `value`, where each 12302 * successive action is supplied the return value of the previous. 12303 * 12304 * @private 12305 * @param {*} value The unwrapped value. 12306 * @param {Array} actions Actions to perform to resolve the unwrapped value. 12307 * @returns {*} Returns the resolved value. 12308 */ 12309 function baseWrapperValue(value, actions) { 12310 var result = value; 12311 if (result instanceof LazyWrapper) { 12312 result = result.value(); 12313 } 12314 return arrayReduce(actions, function(result, action) { 12315 return action.func.apply(action.thisArg, arrayPush([result], action.args)); 12316 }, result); 12317 } 12318 12319 /** 12320 * The base implementation of methods like `_.xor`, without support for 12321 * iteratee shorthands, that accepts an array of arrays to inspect. 12322 * 12323 * @private 12324 * @param {Array} arrays The arrays to inspect. 12325 * @param {Function} [iteratee] The iteratee invoked per element. 12326 * @param {Function} [comparator] The comparator invoked per element. 12327 * @returns {Array} Returns the new array of values. 12328 */ 12329 function baseXor(arrays, iteratee, comparator) { 12330 var length = arrays.length; 12331 if (length < 2) { 12332 return length ? baseUniq(arrays[0]) : []; 12333 } 12334 var index = -1, 12335 result = Array(length); 12336 12337 while (++index < length) { 12338 var array = arrays[index], 12339 othIndex = -1; 12340 12341 while (++othIndex < length) { 12342 if (othIndex != index) { 12343 result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator); 12344 } 12345 } 12346 } 12347 return baseUniq(baseFlatten(result, 1), iteratee, comparator); 12348 } 12349 12350 /** 12351 * This base implementation of `_.zipObject` which assigns values using `assignFunc`. 12352 * 12353 * @private 12354 * @param {Array} props The property identifiers. 12355 * @param {Array} values The property values. 12356 * @param {Function} assignFunc The function to assign values. 12357 * @returns {Object} Returns the new object. 12358 */ 12359 function baseZipObject(props, values, assignFunc) { 12360 var index = -1, 12361 length = props.length, 12362 valsLength = values.length, 12363 result = {}; 12364 12365 while (++index < length) { 12366 var value = index < valsLength ? values[index] : undefined; 12367 assignFunc(result, props[index], value); 12368 } 12369 return result; 12370 } 12371 12372 /** 12373 * Casts `value` to an empty array if it's not an array like object. 12374 * 12375 * @private 12376 * @param {*} value The value to inspect. 12377 * @returns {Array|Object} Returns the cast array-like object. 12378 */ 12379 function castArrayLikeObject(value) { 12380 return isArrayLikeObject(value) ? value : []; 12381 } 12382 12383 /** 12384 * Casts `value` to `identity` if it's not a function. 12385 * 12386 * @private 12387 * @param {*} value The value to inspect. 12388 * @returns {Function} Returns cast function. 12389 */ 12390 function castFunction(value) { 12391 return typeof value == 'function' ? value : identity; 12392 } 12393 12394 /** 12395 * Casts `value` to a path array if it's not one. 12396 * 12397 * @private 12398 * @param {*} value The value to inspect. 12399 * @param {Object} [object] The object to query keys on. 12400 * @returns {Array} Returns the cast property path array. 12401 */ 12402 function castPath(value, object) { 12403 if (isArray(value)) { 12404 return value; 12405 } 12406 return isKey(value, object) ? [value] : stringToPath(toString(value)); 12407 } 12408 12409 /** 12410 * A `baseRest` alias which can be replaced with `identity` by module 12411 * replacement plugins. 12412 * 12413 * @private 12414 * @type {Function} 12415 * @param {Function} func The function to apply a rest parameter to. 12416 * @returns {Function} Returns the new function. 12417 */ 12418 var castRest = baseRest; 12419 12420 /** 12421 * Casts `array` to a slice if it's needed. 12422 * 12423 * @private 12424 * @param {Array} array The array to inspect. 12425 * @param {number} start The start position. 12426 * @param {number} [end=array.length] The end position. 12427 * @returns {Array} Returns the cast slice. 12428 */ 12429 function castSlice(array, start, end) { 12430 var length = array.length; 12431 end = end === undefined ? length : end; 12432 return (!start && end >= length) ? array : baseSlice(array, start, end); 12433 } 12434 12435 /** 12436 * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout). 12437 * 12438 * @private 12439 * @param {number|Object} id The timer id or timeout object of the timer to clear. 12440 */ 12441 var clearTimeout = ctxClearTimeout || function(id) { 12442 return root.clearTimeout(id); 12443 }; 12444 12445 /** 12446 * Creates a clone of `buffer`. 12447 * 12448 * @private 12449 * @param {Buffer} buffer The buffer to clone. 12450 * @param {boolean} [isDeep] Specify a deep clone. 12451 * @returns {Buffer} Returns the cloned buffer. 12452 */ 12453 function cloneBuffer(buffer, isDeep) { 12454 if (isDeep) { 12455 return buffer.slice(); 12456 } 12457 var length = buffer.length, 12458 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); 12459 12460 buffer.copy(result); 12461 return result; 12462 } 12463 12464 /** 12465 * Creates a clone of `arrayBuffer`. 12466 * 12467 * @private 12468 * @param {ArrayBuffer} arrayBuffer The array buffer to clone. 12469 * @returns {ArrayBuffer} Returns the cloned array buffer. 12470 */ 12471 function cloneArrayBuffer(arrayBuffer) { 12472 var result = new arrayBuffer.constructor(arrayBuffer.byteLength); 12473 new Uint8Array(result).set(new Uint8Array(arrayBuffer)); 12474 return result; 12475 } 12476 12477 /** 12478 * Creates a clone of `dataView`. 12479 * 12480 * @private 12481 * @param {Object} dataView The data view to clone. 12482 * @param {boolean} [isDeep] Specify a deep clone. 12483 * @returns {Object} Returns the cloned data view. 12484 */ 12485 function cloneDataView(dataView, isDeep) { 12486 var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; 12487 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); 12488 } 12489 12490 /** 12491 * Creates a clone of `regexp`. 12492 * 12493 * @private 12494 * @param {Object} regexp The regexp to clone. 12495 * @returns {Object} Returns the cloned regexp. 12496 */ 12497 function cloneRegExp(regexp) { 12498 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); 12499 result.lastIndex = regexp.lastIndex; 12500 return result; 12501 } 12502 12503 /** 12504 * Creates a clone of the `symbol` object. 12505 * 12506 * @private 12507 * @param {Object} symbol The symbol object to clone. 12508 * @returns {Object} Returns the cloned symbol object. 12509 */ 12510 function cloneSymbol(symbol) { 12511 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; 12512 } 12513 12514 /** 12515 * Creates a clone of `typedArray`. 12516 * 12517 * @private 12518 * @param {Object} typedArray The typed array to clone. 12519 * @param {boolean} [isDeep] Specify a deep clone. 12520 * @returns {Object} Returns the cloned typed array. 12521 */ 12522 function cloneTypedArray(typedArray, isDeep) { 12523 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; 12524 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); 12525 } 12526 12527 /** 12528 * Compares values to sort them in ascending order. 12529 * 12530 * @private 12531 * @param {*} value The value to compare. 12532 * @param {*} other The other value to compare. 12533 * @returns {number} Returns the sort order indicator for `value`. 12534 */ 12535 function compareAscending(value, other) { 12536 if (value !== other) { 12537 var valIsDefined = value !== undefined, 12538 valIsNull = value === null, 12539 valIsReflexive = value === value, 12540 valIsSymbol = isSymbol(value); 12541 12542 var othIsDefined = other !== undefined, 12543 othIsNull = other === null, 12544 othIsReflexive = other === other, 12545 othIsSymbol = isSymbol(other); 12546 12547 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || 12548 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || 12549 (valIsNull && othIsDefined && othIsReflexive) || 12550 (!valIsDefined && othIsReflexive) || 12551 !valIsReflexive) { 12552 return 1; 12553 } 12554 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || 12555 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || 12556 (othIsNull && valIsDefined && valIsReflexive) || 12557 (!othIsDefined && valIsReflexive) || 12558 !othIsReflexive) { 12559 return -1; 12560 } 12561 } 12562 return 0; 12563 } 12564 12565 /** 12566 * Used by `_.orderBy` to compare multiple properties of a value to another 12567 * and stable sort them. 12568 * 12569 * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, 12570 * specify an order of "desc" for descending or "asc" for ascending sort order 12571 * of corresponding values. 12572 * 12573 * @private 12574 * @param {Object} object The object to compare. 12575 * @param {Object} other The other object to compare. 12576 * @param {boolean[]|string[]} orders The order to sort by for each property. 12577 * @returns {number} Returns the sort order indicator for `object`. 12578 */ 12579 function compareMultiple(object, other, orders) { 12580 var index = -1, 12581 objCriteria = object.criteria, 12582 othCriteria = other.criteria, 12583 length = objCriteria.length, 12584 ordersLength = orders.length; 12585 12586 while (++index < length) { 12587 var result = compareAscending(objCriteria[index], othCriteria[index]); 12588 if (result) { 12589 if (index >= ordersLength) { 12590 return result; 12591 } 12592 var order = orders[index]; 12593 return result * (order == 'desc' ? -1 : 1); 12594 } 12595 } 12596 // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications 12597 // that causes it, under certain circumstances, to provide the same value for 12598 // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 12599 // for more details. 12600 // 12601 // This also ensures a stable sort in V8 and other engines. 12602 // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. 12603 return object.index - other.index; 12604 } 12605 12606 /** 12607 * Creates an array that is the composition of partially applied arguments, 12608 * placeholders, and provided arguments into a single array of arguments. 12609 * 12610 * @private 12611 * @param {Array} args The provided arguments. 12612 * @param {Array} partials The arguments to prepend to those provided. 12613 * @param {Array} holders The `partials` placeholder indexes. 12614 * @params {boolean} [isCurried] Specify composing for a curried function. 12615 * @returns {Array} Returns the new array of composed arguments. 12616 */ 12617 function composeArgs(args, partials, holders, isCurried) { 12618 var argsIndex = -1, 12619 argsLength = args.length, 12620 holdersLength = holders.length, 12621 leftIndex = -1, 12622 leftLength = partials.length, 12623 rangeLength = nativeMax(argsLength - holdersLength, 0), 12624 result = Array(leftLength + rangeLength), 12625 isUncurried = !isCurried; 12626 12627 while (++leftIndex < leftLength) { 12628 result[leftIndex] = partials[leftIndex]; 12629 } 12630 while (++argsIndex < holdersLength) { 12631 if (isUncurried || argsIndex < argsLength) { 12632 result[holders[argsIndex]] = args[argsIndex]; 12633 } 12634 } 12635 while (rangeLength--) { 12636 result[leftIndex++] = args[argsIndex++]; 12637 } 12638 return result; 12639 } 12640 12641 /** 12642 * This function is like `composeArgs` except that the arguments composition 12643 * is tailored for `_.partialRight`. 12644 * 12645 * @private 12646 * @param {Array} args The provided arguments. 12647 * @param {Array} partials The arguments to append to those provided. 12648 * @param {Array} holders The `partials` placeholder indexes. 12649 * @params {boolean} [isCurried] Specify composing for a curried function. 12650 * @returns {Array} Returns the new array of composed arguments. 12651 */ 12652 function composeArgsRight(args, partials, holders, isCurried) { 12653 var argsIndex = -1, 12654 argsLength = args.length, 12655 holdersIndex = -1, 12656 holdersLength = holders.length, 12657 rightIndex = -1, 12658 rightLength = partials.length, 12659 rangeLength = nativeMax(argsLength - holdersLength, 0), 12660 result = Array(rangeLength + rightLength), 12661 isUncurried = !isCurried; 12662 12663 while (++argsIndex < rangeLength) { 12664 result[argsIndex] = args[argsIndex]; 12665 } 12666 var offset = argsIndex; 12667 while (++rightIndex < rightLength) { 12668 result[offset + rightIndex] = partials[rightIndex]; 12669 } 12670 while (++holdersIndex < holdersLength) { 12671 if (isUncurried || argsIndex < argsLength) { 12672 result[offset + holders[holdersIndex]] = args[argsIndex++]; 12673 } 12674 } 12675 return result; 12676 } 12677 12678 /** 12679 * Copies the values of `source` to `array`. 12680 * 12681 * @private 12682 * @param {Array} source The array to copy values from. 12683 * @param {Array} [array=[]] The array to copy values to. 12684 * @returns {Array} Returns `array`. 12685 */ 12686 function copyArray(source, array) { 12687 var index = -1, 12688 length = source.length; 12689 12690 array || (array = Array(length)); 12691 while (++index < length) { 12692 array[index] = source[index]; 12693 } 12694 return array; 12695 } 12696 12697 /** 12698 * Copies properties of `source` to `object`. 12699 * 12700 * @private 12701 * @param {Object} source The object to copy properties from. 12702 * @param {Array} props The property identifiers to copy. 12703 * @param {Object} [object={}] The object to copy properties to. 12704 * @param {Function} [customizer] The function to customize copied values. 12705 * @returns {Object} Returns `object`. 12706 */ 12707 function copyObject(source, props, object, customizer) { 12708 var isNew = !object; 12709 object || (object = {}); 12710 12711 var index = -1, 12712 length = props.length; 12713 12714 while (++index < length) { 12715 var key = props[index]; 12716 12717 var newValue = customizer 12718 ? customizer(object[key], source[key], key, object, source) 12719 : undefined; 12720 12721 if (newValue === undefined) { 12722 newValue = source[key]; 12723 } 12724 if (isNew) { 12725 baseAssignValue(object, key, newValue); 12726 } else { 12727 assignValue(object, key, newValue); 12728 } 12729 } 12730 return object; 12731 } 12732 12733 /** 12734 * Copies own symbols of `source` to `object`. 12735 * 12736 * @private 12737 * @param {Object} source The object to copy symbols from. 12738 * @param {Object} [object={}] The object to copy symbols to. 12739 * @returns {Object} Returns `object`. 12740 */ 12741 function copySymbols(source, object) { 12742 return copyObject(source, getSymbols(source), object); 12743 } 12744 12745 /** 12746 * Copies own and inherited symbols of `source` to `object`. 12747 * 12748 * @private 12749 * @param {Object} source The object to copy symbols from. 12750 * @param {Object} [object={}] The object to copy symbols to. 12751 * @returns {Object} Returns `object`. 12752 */ 12753 function copySymbolsIn(source, object) { 12754 return copyObject(source, getSymbolsIn(source), object); 12755 } 12756 12757 /** 12758 * Creates a function like `_.groupBy`. 12759 * 12760 * @private 12761 * @param {Function} setter The function to set accumulator values. 12762 * @param {Function} [initializer] The accumulator object initializer. 12763 * @returns {Function} Returns the new aggregator function. 12764 */ 12765 function createAggregator(setter, initializer) { 12766 return function(collection, iteratee) { 12767 var func = isArray(collection) ? arrayAggregator : baseAggregator, 12768 accumulator = initializer ? initializer() : {}; 12769 12770 return func(collection, setter, getIteratee(iteratee, 2), accumulator); 12771 }; 12772 } 12773 12774 /** 12775 * Creates a function like `_.assign`. 12776 * 12777 * @private 12778 * @param {Function} assigner The function to assign values. 12779 * @returns {Function} Returns the new assigner function. 12780 */ 12781 function createAssigner(assigner) { 12782 return baseRest(function(object, sources) { 12783 var index = -1, 12784 length = sources.length, 12785 customizer = length > 1 ? sources[length - 1] : undefined, 12786 guard = length > 2 ? sources[2] : undefined; 12787 12788 customizer = (assigner.length > 3 && typeof customizer == 'function') 12789 ? (length--, customizer) 12790 : undefined; 12791 12792 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 12793 customizer = length < 3 ? undefined : customizer; 12794 length = 1; 12795 } 12796 object = Object(object); 12797 while (++index < length) { 12798 var source = sources[index]; 12799 if (source) { 12800 assigner(object, source, index, customizer); 12801 } 12802 } 12803 return object; 12804 }); 12805 } 12806 12807 /** 12808 * Creates a `baseEach` or `baseEachRight` function. 12809 * 12810 * @private 12811 * @param {Function} eachFunc The function to iterate over a collection. 12812 * @param {boolean} [fromRight] Specify iterating from right to left. 12813 * @returns {Function} Returns the new base function. 12814 */ 12815 function createBaseEach(eachFunc, fromRight) { 12816 return function(collection, iteratee) { 12817 if (collection == null) { 12818 return collection; 12819 } 12820 if (!isArrayLike(collection)) { 12821 return eachFunc(collection, iteratee); 12822 } 12823 var length = collection.length, 12824 index = fromRight ? length : -1, 12825 iterable = Object(collection); 12826 12827 while ((fromRight ? index-- : ++index < length)) { 12828 if (iteratee(iterable[index], index, iterable) === false) { 12829 break; 12830 } 12831 } 12832 return collection; 12833 }; 12834 } 12835 12836 /** 12837 * Creates a base function for methods like `_.forIn` and `_.forOwn`. 12838 * 12839 * @private 12840 * @param {boolean} [fromRight] Specify iterating from right to left. 12841 * @returns {Function} Returns the new base function. 12842 */ 12843 function createBaseFor(fromRight) { 12844 return function(object, iteratee, keysFunc) { 12845 var index = -1, 12846 iterable = Object(object), 12847 props = keysFunc(object), 12848 length = props.length; 12849 12850 while (length--) { 12851 var key = props[fromRight ? length : ++index]; 12852 if (iteratee(iterable[key], key, iterable) === false) { 12853 break; 12854 } 12855 } 12856 return object; 12857 }; 12858 } 12859 12860 /** 12861 * Creates a function that wraps `func` to invoke it with the optional `this` 12862 * binding of `thisArg`. 12863 * 12864 * @private 12865 * @param {Function} func The function to wrap. 12866 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 12867 * @param {*} [thisArg] The `this` binding of `func`. 12868 * @returns {Function} Returns the new wrapped function. 12869 */ 12870 function createBind(func, bitmask, thisArg) { 12871 var isBind = bitmask & WRAP_BIND_FLAG, 12872 Ctor = createCtor(func); 12873 12874 function wrapper() { 12875 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 12876 return fn.apply(isBind ? thisArg : this, arguments); 12877 } 12878 return wrapper; 12879 } 12880 12881 /** 12882 * Creates a function like `_.lowerFirst`. 12883 * 12884 * @private 12885 * @param {string} methodName The name of the `String` case method to use. 12886 * @returns {Function} Returns the new case function. 12887 */ 12888 function createCaseFirst(methodName) { 12889 return function(string) { 12890 string = toString(string); 12891 12892 var strSymbols = hasUnicode(string) 12893 ? stringToArray(string) 12894 : undefined; 12895 12896 var chr = strSymbols 12897 ? strSymbols[0] 12898 : string.charAt(0); 12899 12900 var trailing = strSymbols 12901 ? castSlice(strSymbols, 1).join('') 12902 : string.slice(1); 12903 12904 return chr[methodName]() + trailing; 12905 }; 12906 } 12907 12908 /** 12909 * Creates a function like `_.camelCase`. 12910 * 12911 * @private 12912 * @param {Function} callback The function to combine each word. 12913 * @returns {Function} Returns the new compounder function. 12914 */ 12915 function createCompounder(callback) { 12916 return function(string) { 12917 return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); 12918 }; 12919 } 12920 12921 /** 12922 * Creates a function that produces an instance of `Ctor` regardless of 12923 * whether it was invoked as part of a `new` expression or by `call` or `apply`. 12924 * 12925 * @private 12926 * @param {Function} Ctor The constructor to wrap. 12927 * @returns {Function} Returns the new wrapped function. 12928 */ 12929 function createCtor(Ctor) { 12930 return function() { 12931 // Use a `switch` statement to work with class constructors. See 12932 // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist 12933 // for more details. 12934 var args = arguments; 12935 switch (args.length) { 12936 case 0: return new Ctor; 12937 case 1: return new Ctor(args[0]); 12938 case 2: return new Ctor(args[0], args[1]); 12939 case 3: return new Ctor(args[0], args[1], args[2]); 12940 case 4: return new Ctor(args[0], args[1], args[2], args[3]); 12941 case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); 12942 case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); 12943 case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); 12944 } 12945 var thisBinding = baseCreate(Ctor.prototype), 12946 result = Ctor.apply(thisBinding, args); 12947 12948 // Mimic the constructor's `return` behavior. 12949 // See https://es5.github.io/#x13.2.2 for more details. 12950 return isObject(result) ? result : thisBinding; 12951 }; 12952 } 12953 12954 /** 12955 * Creates a function that wraps `func` to enable currying. 12956 * 12957 * @private 12958 * @param {Function} func The function to wrap. 12959 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 12960 * @param {number} arity The arity of `func`. 12961 * @returns {Function} Returns the new wrapped function. 12962 */ 12963 function createCurry(func, bitmask, arity) { 12964 var Ctor = createCtor(func); 12965 12966 function wrapper() { 12967 var length = arguments.length, 12968 args = Array(length), 12969 index = length, 12970 placeholder = getHolder(wrapper); 12971 12972 while (index--) { 12973 args[index] = arguments[index]; 12974 } 12975 var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) 12976 ? [] 12977 : replaceHolders(args, placeholder); 12978 12979 length -= holders.length; 12980 if (length < arity) { 12981 return createRecurry( 12982 func, bitmask, createHybrid, wrapper.placeholder, undefined, 12983 args, holders, undefined, undefined, arity - length); 12984 } 12985 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 12986 return apply(fn, this, args); 12987 } 12988 return wrapper; 12989 } 12990 12991 /** 12992 * Creates a `_.find` or `_.findLast` function. 12993 * 12994 * @private 12995 * @param {Function} findIndexFunc The function to find the collection index. 12996 * @returns {Function} Returns the new find function. 12997 */ 12998 function createFind(findIndexFunc) { 12999 return function(collection, predicate, fromIndex) { 13000 var iterable = Object(collection); 13001 if (!isArrayLike(collection)) { 13002 var iteratee = getIteratee(predicate, 3); 13003 collection = keys(collection); 13004 predicate = function(key) { return iteratee(iterable[key], key, iterable); }; 13005 } 13006 var index = findIndexFunc(collection, predicate, fromIndex); 13007 return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; 13008 }; 13009 } 13010 13011 /** 13012 * Creates a `_.flow` or `_.flowRight` function. 13013 * 13014 * @private 13015 * @param {boolean} [fromRight] Specify iterating from right to left. 13016 * @returns {Function} Returns the new flow function. 13017 */ 13018 function createFlow(fromRight) { 13019 return flatRest(function(funcs) { 13020 var length = funcs.length, 13021 index = length, 13022 prereq = LodashWrapper.prototype.thru; 13023 13024 if (fromRight) { 13025 funcs.reverse(); 13026 } 13027 while (index--) { 13028 var func = funcs[index]; 13029 if (typeof func != 'function') { 13030 throw new TypeError(FUNC_ERROR_TEXT); 13031 } 13032 if (prereq && !wrapper && getFuncName(func) == 'wrapper') { 13033 var wrapper = new LodashWrapper([], true); 13034 } 13035 } 13036 index = wrapper ? index : length; 13037 while (++index < length) { 13038 func = funcs[index]; 13039 13040 var funcName = getFuncName(func), 13041 data = funcName == 'wrapper' ? getData(func) : undefined; 13042 13043 if (data && isLaziable(data[0]) && 13044 data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) && 13045 !data[4].length && data[9] == 1 13046 ) { 13047 wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); 13048 } else { 13049 wrapper = (func.length == 1 && isLaziable(func)) 13050 ? wrapper[funcName]() 13051 : wrapper.thru(func); 13052 } 13053 } 13054 return function() { 13055 var args = arguments, 13056 value = args[0]; 13057 13058 if (wrapper && args.length == 1 && isArray(value)) { 13059 return wrapper.plant(value).value(); 13060 } 13061 var index = 0, 13062 result = length ? funcs[index].apply(this, args) : value; 13063 13064 while (++index < length) { 13065 result = funcs[index].call(this, result); 13066 } 13067 return result; 13068 }; 13069 }); 13070 } 13071 13072 /** 13073 * Creates a function that wraps `func` to invoke it with optional `this` 13074 * binding of `thisArg`, partial application, and currying. 13075 * 13076 * @private 13077 * @param {Function|string} func The function or method name to wrap. 13078 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 13079 * @param {*} [thisArg] The `this` binding of `func`. 13080 * @param {Array} [partials] The arguments to prepend to those provided to 13081 * the new function. 13082 * @param {Array} [holders] The `partials` placeholder indexes. 13083 * @param {Array} [partialsRight] The arguments to append to those provided 13084 * to the new function. 13085 * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. 13086 * @param {Array} [argPos] The argument positions of the new function. 13087 * @param {number} [ary] The arity cap of `func`. 13088 * @param {number} [arity] The arity of `func`. 13089 * @returns {Function} Returns the new wrapped function. 13090 */ 13091 function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { 13092 var isAry = bitmask & WRAP_ARY_FLAG, 13093 isBind = bitmask & WRAP_BIND_FLAG, 13094 isBindKey = bitmask & WRAP_BIND_KEY_FLAG, 13095 isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), 13096 isFlip = bitmask & WRAP_FLIP_FLAG, 13097 Ctor = isBindKey ? undefined : createCtor(func); 13098 13099 function wrapper() { 13100 var length = arguments.length, 13101 args = Array(length), 13102 index = length; 13103 13104 while (index--) { 13105 args[index] = arguments[index]; 13106 } 13107 if (isCurried) { 13108 var placeholder = getHolder(wrapper), 13109 holdersCount = countHolders(args, placeholder); 13110 } 13111 if (partials) { 13112 args = composeArgs(args, partials, holders, isCurried); 13113 } 13114 if (partialsRight) { 13115 args = composeArgsRight(args, partialsRight, holdersRight, isCurried); 13116 } 13117 length -= holdersCount; 13118 if (isCurried && length < arity) { 13119 var newHolders = replaceHolders(args, placeholder); 13120 return createRecurry( 13121 func, bitmask, createHybrid, wrapper.placeholder, thisArg, 13122 args, newHolders, argPos, ary, arity - length 13123 ); 13124 } 13125 var thisBinding = isBind ? thisArg : this, 13126 fn = isBindKey ? thisBinding[func] : func; 13127 13128 length = args.length; 13129 if (argPos) { 13130 args = reorder(args, argPos); 13131 } else if (isFlip && length > 1) { 13132 args.reverse(); 13133 } 13134 if (isAry && ary < length) { 13135 args.length = ary; 13136 } 13137 if (this && this !== root && this instanceof wrapper) { 13138 fn = Ctor || createCtor(fn); 13139 } 13140 return fn.apply(thisBinding, args); 13141 } 13142 return wrapper; 13143 } 13144 13145 /** 13146 * Creates a function like `_.invertBy`. 13147 * 13148 * @private 13149 * @param {Function} setter The function to set accumulator values. 13150 * @param {Function} toIteratee The function to resolve iteratees. 13151 * @returns {Function} Returns the new inverter function. 13152 */ 13153 function createInverter(setter, toIteratee) { 13154 return function(object, iteratee) { 13155 return baseInverter(object, setter, toIteratee(iteratee), {}); 13156 }; 13157 } 13158 13159 /** 13160 * Creates a function that performs a mathematical operation on two values. 13161 * 13162 * @private 13163 * @param {Function} operator The function to perform the operation. 13164 * @param {number} [defaultValue] The value used for `undefined` arguments. 13165 * @returns {Function} Returns the new mathematical operation function. 13166 */ 13167 function createMathOperation(operator, defaultValue) { 13168 return function(value, other) { 13169 var result; 13170 if (value === undefined && other === undefined) { 13171 return defaultValue; 13172 } 13173 if (value !== undefined) { 13174 result = value; 13175 } 13176 if (other !== undefined) { 13177 if (result === undefined) { 13178 return other; 13179 } 13180 if (typeof value == 'string' || typeof other == 'string') { 13181 value = baseToString(value); 13182 other = baseToString(other); 13183 } else { 13184 value = baseToNumber(value); 13185 other = baseToNumber(other); 13186 } 13187 result = operator(value, other); 13188 } 13189 return result; 13190 }; 13191 } 13192 13193 /** 13194 * Creates a function like `_.over`. 13195 * 13196 * @private 13197 * @param {Function} arrayFunc The function to iterate over iteratees. 13198 * @returns {Function} Returns the new over function. 13199 */ 13200 function createOver(arrayFunc) { 13201 return flatRest(function(iteratees) { 13202 iteratees = arrayMap(iteratees, baseUnary(getIteratee())); 13203 return baseRest(function(args) { 13204 var thisArg = this; 13205 return arrayFunc(iteratees, function(iteratee) { 13206 return apply(iteratee, thisArg, args); 13207 }); 13208 }); 13209 }); 13210 } 13211 13212 /** 13213 * Creates the padding for `string` based on `length`. The `chars` string 13214 * is truncated if the number of characters exceeds `length`. 13215 * 13216 * @private 13217 * @param {number} length The padding length. 13218 * @param {string} [chars=' '] The string used as padding. 13219 * @returns {string} Returns the padding for `string`. 13220 */ 13221 function createPadding(length, chars) { 13222 chars = chars === undefined ? ' ' : baseToString(chars); 13223 13224 var charsLength = chars.length; 13225 if (charsLength < 2) { 13226 return charsLength ? baseRepeat(chars, length) : chars; 13227 } 13228 var result = baseRepeat(chars, nativeCeil(length / stringSize(chars))); 13229 return hasUnicode(chars) 13230 ? castSlice(stringToArray(result), 0, length).join('') 13231 : result.slice(0, length); 13232 } 13233 13234 /** 13235 * Creates a function that wraps `func` to invoke it with the `this` binding 13236 * of `thisArg` and `partials` prepended to the arguments it receives. 13237 * 13238 * @private 13239 * @param {Function} func The function to wrap. 13240 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 13241 * @param {*} thisArg The `this` binding of `func`. 13242 * @param {Array} partials The arguments to prepend to those provided to 13243 * the new function. 13244 * @returns {Function} Returns the new wrapped function. 13245 */ 13246 function createPartial(func, bitmask, thisArg, partials) { 13247 var isBind = bitmask & WRAP_BIND_FLAG, 13248 Ctor = createCtor(func); 13249 13250 function wrapper() { 13251 var argsIndex = -1, 13252 argsLength = arguments.length, 13253 leftIndex = -1, 13254 leftLength = partials.length, 13255 args = Array(leftLength + argsLength), 13256 fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 13257 13258 while (++leftIndex < leftLength) { 13259 args[leftIndex] = partials[leftIndex]; 13260 } 13261 while (argsLength--) { 13262 args[leftIndex++] = arguments[++argsIndex]; 13263 } 13264 return apply(fn, isBind ? thisArg : this, args); 13265 } 13266 return wrapper; 13267 } 13268 13269 /** 13270 * Creates a `_.range` or `_.rangeRight` function. 13271 * 13272 * @private 13273 * @param {boolean} [fromRight] Specify iterating from right to left. 13274 * @returns {Function} Returns the new range function. 13275 */ 13276 function createRange(fromRight) { 13277 return function(start, end, step) { 13278 if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { 13279 end = step = undefined; 13280 } 13281 // Ensure the sign of `-0` is preserved. 13282 start = toFinite(start); 13283 if (end === undefined) { 13284 end = start; 13285 start = 0; 13286 } else { 13287 end = toFinite(end); 13288 } 13289 step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); 13290 return baseRange(start, end, step, fromRight); 13291 }; 13292 } 13293 13294 /** 13295 * Creates a function that performs a relational operation on two values. 13296 * 13297 * @private 13298 * @param {Function} operator The function to perform the operation. 13299 * @returns {Function} Returns the new relational operation function. 13300 */ 13301 function createRelationalOperation(operator) { 13302 return function(value, other) { 13303 if (!(typeof value == 'string' && typeof other == 'string')) { 13304 value = toNumber(value); 13305 other = toNumber(other); 13306 } 13307 return operator(value, other); 13308 }; 13309 } 13310 13311 /** 13312 * Creates a function that wraps `func` to continue currying. 13313 * 13314 * @private 13315 * @param {Function} func The function to wrap. 13316 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 13317 * @param {Function} wrapFunc The function to create the `func` wrapper. 13318 * @param {*} placeholder The placeholder value. 13319 * @param {*} [thisArg] The `this` binding of `func`. 13320 * @param {Array} [partials] The arguments to prepend to those provided to 13321 * the new function. 13322 * @param {Array} [holders] The `partials` placeholder indexes. 13323 * @param {Array} [argPos] The argument positions of the new function. 13324 * @param {number} [ary] The arity cap of `func`. 13325 * @param {number} [arity] The arity of `func`. 13326 * @returns {Function} Returns the new wrapped function. 13327 */ 13328 function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { 13329 var isCurry = bitmask & WRAP_CURRY_FLAG, 13330 newHolders = isCurry ? holders : undefined, 13331 newHoldersRight = isCurry ? undefined : holders, 13332 newPartials = isCurry ? partials : undefined, 13333 newPartialsRight = isCurry ? undefined : partials; 13334 13335 bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG); 13336 bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG); 13337 13338 if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) { 13339 bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG); 13340 } 13341 var newData = [ 13342 func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, 13343 newHoldersRight, argPos, ary, arity 13344 ]; 13345 13346 var result = wrapFunc.apply(undefined, newData); 13347 if (isLaziable(func)) { 13348 setData(result, newData); 13349 } 13350 result.placeholder = placeholder; 13351 return setWrapToString(result, func, bitmask); 13352 } 13353 13354 /** 13355 * Creates a function like `_.round`. 13356 * 13357 * @private 13358 * @param {string} methodName The name of the `Math` method to use when rounding. 13359 * @returns {Function} Returns the new round function. 13360 */ 13361 function createRound(methodName) { 13362 var func = Math[methodName]; 13363 return function(number, precision) { 13364 number = toNumber(number); 13365 precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); 13366 if (precision && nativeIsFinite(number)) { 13367 // Shift with exponential notation to avoid floating-point issues. 13368 // See [MDN](https://mdn.io/round#Examples) for more details. 13369 var pair = (toString(number) + 'e').split('e'), 13370 value = func(pair[0] + 'e' + (+pair[1] + precision)); 13371 13372 pair = (toString(value) + 'e').split('e'); 13373 return +(pair[0] + 'e' + (+pair[1] - precision)); 13374 } 13375 return func(number); 13376 }; 13377 } 13378 13379 /** 13380 * Creates a set object of `values`. 13381 * 13382 * @private 13383 * @param {Array} values The values to add to the set. 13384 * @returns {Object} Returns the new set. 13385 */ 13386 var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { 13387 return new Set(values); 13388 }; 13389 13390 /** 13391 * Creates a `_.toPairs` or `_.toPairsIn` function. 13392 * 13393 * @private 13394 * @param {Function} keysFunc The function to get the keys of a given object. 13395 * @returns {Function} Returns the new pairs function. 13396 */ 13397 function createToPairs(keysFunc) { 13398 return function(object) { 13399 var tag = getTag(object); 13400 if (tag == mapTag) { 13401 return mapToArray(object); 13402 } 13403 if (tag == setTag) { 13404 return setToPairs(object); 13405 } 13406 return baseToPairs(object, keysFunc(object)); 13407 }; 13408 } 13409 13410 /** 13411 * Creates a function that either curries or invokes `func` with optional 13412 * `this` binding and partially applied arguments. 13413 * 13414 * @private 13415 * @param {Function|string} func The function or method name to wrap. 13416 * @param {number} bitmask The bitmask flags. 13417 * 1 - `_.bind` 13418 * 2 - `_.bindKey` 13419 * 4 - `_.curry` or `_.curryRight` of a bound function 13420 * 8 - `_.curry` 13421 * 16 - `_.curryRight` 13422 * 32 - `_.partial` 13423 * 64 - `_.partialRight` 13424 * 128 - `_.rearg` 13425 * 256 - `_.ary` 13426 * 512 - `_.flip` 13427 * @param {*} [thisArg] The `this` binding of `func`. 13428 * @param {Array} [partials] The arguments to be partially applied. 13429 * @param {Array} [holders] The `partials` placeholder indexes. 13430 * @param {Array} [argPos] The argument positions of the new function. 13431 * @param {number} [ary] The arity cap of `func`. 13432 * @param {number} [arity] The arity of `func`. 13433 * @returns {Function} Returns the new wrapped function. 13434 */ 13435 function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { 13436 var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; 13437 if (!isBindKey && typeof func != 'function') { 13438 throw new TypeError(FUNC_ERROR_TEXT); 13439 } 13440 var length = partials ? partials.length : 0; 13441 if (!length) { 13442 bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); 13443 partials = holders = undefined; 13444 } 13445 ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); 13446 arity = arity === undefined ? arity : toInteger(arity); 13447 length -= holders ? holders.length : 0; 13448 13449 if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { 13450 var partialsRight = partials, 13451 holdersRight = holders; 13452 13453 partials = holders = undefined; 13454 } 13455 var data = isBindKey ? undefined : getData(func); 13456 13457 var newData = [ 13458 func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, 13459 argPos, ary, arity 13460 ]; 13461 13462 if (data) { 13463 mergeData(newData, data); 13464 } 13465 func = newData[0]; 13466 bitmask = newData[1]; 13467 thisArg = newData[2]; 13468 partials = newData[3]; 13469 holders = newData[4]; 13470 arity = newData[9] = newData[9] === undefined 13471 ? (isBindKey ? 0 : func.length) 13472 : nativeMax(newData[9] - length, 0); 13473 13474 if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { 13475 bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); 13476 } 13477 if (!bitmask || bitmask == WRAP_BIND_FLAG) { 13478 var result = createBind(func, bitmask, thisArg); 13479 } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) { 13480 result = createCurry(func, bitmask, arity); 13481 } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) { 13482 result = createPartial(func, bitmask, thisArg, partials); 13483 } else { 13484 result = createHybrid.apply(undefined, newData); 13485 } 13486 var setter = data ? baseSetData : setData; 13487 return setWrapToString(setter(result, newData), func, bitmask); 13488 } 13489 13490 /** 13491 * Used by `_.defaults` to customize its `_.assignIn` use to assign properties 13492 * of source objects to the destination object for all destination properties 13493 * that resolve to `undefined`. 13494 * 13495 * @private 13496 * @param {*} objValue The destination value. 13497 * @param {*} srcValue The source value. 13498 * @param {string} key The key of the property to assign. 13499 * @param {Object} object The parent object of `objValue`. 13500 * @returns {*} Returns the value to assign. 13501 */ 13502 function customDefaultsAssignIn(objValue, srcValue, key, object) { 13503 if (objValue === undefined || 13504 (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { 13505 return srcValue; 13506 } 13507 return objValue; 13508 } 13509 13510 /** 13511 * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source 13512 * objects into destination objects that are passed thru. 13513 * 13514 * @private 13515 * @param {*} objValue The destination value. 13516 * @param {*} srcValue The source value. 13517 * @param {string} key The key of the property to merge. 13518 * @param {Object} object The parent object of `objValue`. 13519 * @param {Object} source The parent object of `srcValue`. 13520 * @param {Object} [stack] Tracks traversed source values and their merged 13521 * counterparts. 13522 * @returns {*} Returns the value to assign. 13523 */ 13524 function customDefaultsMerge(objValue, srcValue, key, object, source, stack) { 13525 if (isObject(objValue) && isObject(srcValue)) { 13526 // Recursively merge objects and arrays (susceptible to call stack limits). 13527 stack.set(srcValue, objValue); 13528 baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack); 13529 stack['delete'](srcValue); 13530 } 13531 return objValue; 13532 } 13533 13534 /** 13535 * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain 13536 * objects. 13537 * 13538 * @private 13539 * @param {*} value The value to inspect. 13540 * @param {string} key The key of the property to inspect. 13541 * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`. 13542 */ 13543 function customOmitClone(value) { 13544 return isPlainObject(value) ? undefined : value; 13545 } 13546 13547 /** 13548 * A specialized version of `baseIsEqualDeep` for arrays with support for 13549 * partial deep comparisons. 13550 * 13551 * @private 13552 * @param {Array} array The array to compare. 13553 * @param {Array} other The other array to compare. 13554 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 13555 * @param {Function} customizer The function to customize comparisons. 13556 * @param {Function} equalFunc The function to determine equivalents of values. 13557 * @param {Object} stack Tracks traversed `array` and `other` objects. 13558 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. 13559 */ 13560 function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { 13561 var isPartial = bitmask & COMPARE_PARTIAL_FLAG, 13562 arrLength = array.length, 13563 othLength = other.length; 13564 13565 if (arrLength != othLength && !(isPartial && othLength > arrLength)) { 13566 return false;
vendor: 1,304 bytes, lines 13567-13605
13567 } 13568 // Assume cyclic values are equal. 13569 var stacked = stack.get(array); 13570 if (stacked && stack.get(other)) { 13571 return stacked == other; 13572 } 13573 var index = -1, 13574 result = true, 13575 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; 13576 13577 stack.set(array, other); 13578 stack.set(other, array); 13579 13580 // Ignore non-index properties. 13581 while (++index < arrLength) { 13582 var arrValue = array[index], 13583 othValue = other[index]; 13584 13585 if (customizer) { 13586 var compared = isPartial 13587 ? customizer(othValue, arrValue, index, other, array, stack) 13588 : customizer(arrValue, othValue, index, array, other, stack); 13589 } 13590 if (compared !== undefined) { 13591 if (compared) { 13592 continue; 13593 } 13594 result = false; 13595 break; 13596 } 13597 // Recursively compare arrays (susceptible to call stack limits). 13598 if (seen) { 13599 if (!arraySome(other, function(othValue, othIndex) { 13600 if (!cacheHas(seen, othIndex) && 13601 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { 13602 return seen.push(othIndex); 13603 } 13604 })) { 13605 result = false;
vendor: 4,179 bytes, lines 13606-13717
13606 break; 13607 } 13608 } else if (!( 13609 arrValue === othValue || 13610 equalFunc(arrValue, othValue, bitmask, customizer, stack) 13611 )) { 13612 result = false; 13613 break; 13614 } 13615 } 13616 stack['delete'](array); 13617 stack['delete'](other); 13618 return result; 13619 } 13620 13621 /** 13622 * A specialized version of `baseIsEqualDeep` for comparing objects of 13623 * the same `toStringTag`. 13624 * 13625 * **Note:** This function only supports comparing values with tags of 13626 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. 13627 * 13628 * @private 13629 * @param {Object} object The object to compare. 13630 * @param {Object} other The other object to compare. 13631 * @param {string} tag The `toStringTag` of the objects to compare. 13632 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 13633 * @param {Function} customizer The function to customize comparisons. 13634 * @param {Function} equalFunc The function to determine equivalents of values. 13635 * @param {Object} stack Tracks traversed `object` and `other` objects. 13636 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 13637 */ 13638 function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { 13639 switch (tag) { 13640 case dataViewTag: 13641 if ((object.byteLength != other.byteLength) || 13642 (object.byteOffset != other.byteOffset)) { 13643 return false; 13644 } 13645 object = object.buffer; 13646 other = other.buffer; 13647 13648 case arrayBufferTag: 13649 if ((object.byteLength != other.byteLength) || 13650 !equalFunc(new Uint8Array(object), new Uint8Array(other))) { 13651 return false; 13652 } 13653 return true; 13654 13655 case boolTag: 13656 case dateTag: 13657 case numberTag: 13658 // Coerce booleans to `1` or `0` and dates to milliseconds. 13659 // Invalid dates are coerced to `NaN`. 13660 return eq(+object, +other); 13661 13662 case errorTag: 13663 return object.name == other.name && object.message == other.message; 13664 13665 case regexpTag: 13666 case stringTag: 13667 // Coerce regexes to strings and treat strings, primitives and objects, 13668 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring 13669 // for more details. 13670 return object == (other + ''); 13671 13672 case mapTag: 13673 var convert = mapToArray; 13674 13675 case setTag: 13676 var isPartial = bitmask & COMPARE_PARTIAL_FLAG; 13677 convert || (convert = setToArray); 13678 13679 if (object.size != other.size && !isPartial) { 13680 return false; 13681 } 13682 // Assume cyclic values are equal. 13683 var stacked = stack.get(object); 13684 if (stacked) { 13685 return stacked == other; 13686 } 13687 bitmask |= COMPARE_UNORDERED_FLAG; 13688 13689 // Recursively compare objects (susceptible to call stack limits). 13690 stack.set(object, other); 13691 var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); 13692 stack['delete'](object); 13693 return result; 13694 13695 case symbolTag: 13696 if (symbolValueOf) { 13697 return symbolValueOf.call(object) == symbolValueOf.call(other); 13698 } 13699 } 13700 return false; 13701 } 13702 13703 /** 13704 * A specialized version of `baseIsEqualDeep` for objects with support for 13705 * partial deep comparisons. 13706 * 13707 * @private 13708 * @param {Object} object The object to compare. 13709 * @param {Object} other The other object to compare. 13710 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 13711 * @param {Function} customizer The function to customize comparisons. 13712 * @param {Function} equalFunc The function to determine equivalents of values. 13713 * @param {Object} stack Tracks traversed `object` and `other` objects. 13714 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 13715 */ 13716 function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { 13717 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
vendor: 1,367 bytes, lines 13718-13758
13718 objProps = getAllKeys(object), 13719 objLength = objProps.length, 13720 othProps = getAllKeys(other), 13721 othLength = othProps.length; 13722 13723 if (objLength != othLength && !isPartial) { 13724 return false; 13725 } 13726 var index = objLength; 13727 while (index--) { 13728 var key = objProps[index]; 13729 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { 13730 return false; 13731 } 13732 } 13733 // Assume cyclic values are equal. 13734 var stacked = stack.get(object); 13735 if (stacked && stack.get(other)) { 13736 return stacked == other; 13737 } 13738 var result = true; 13739 stack.set(object, other); 13740 stack.set(other, object); 13741 13742 var skipCtor = isPartial; 13743 while (++index < objLength) { 13744 key = objProps[index]; 13745 var objValue = object[key], 13746 othValue = other[key]; 13747 13748 if (customizer) { 13749 var compared = isPartial 13750 ? customizer(othValue, objValue, key, other, object, stack) 13751 : customizer(objValue, othValue, key, object, other, stack); 13752 } 13753 // Recursively compare objects (susceptible to call stack limits). 13754 if (!(compared === undefined 13755 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) 13756 : compared 13757 )) { 13758 result = false;
vendor: 8,175 bytes, lines 13759-14024
13759 break; 13760 } 13761 skipCtor || (skipCtor = key == 'constructor'); 13762 } 13763 if (result && !skipCtor) { 13764 var objCtor = object.constructor, 13765 othCtor = other.constructor; 13766 13767 // Non `Object` object instances with different constructors are not equal. 13768 if (objCtor != othCtor && 13769 ('constructor' in object && 'constructor' in other) && 13770 !(typeof objCtor == 'function' && objCtor instanceof objCtor && 13771 typeof othCtor == 'function' && othCtor instanceof othCtor)) { 13772 result = false; 13773 } 13774 } 13775 stack['delete'](object); 13776 stack['delete'](other); 13777 return result; 13778 } 13779 13780 /** 13781 * A specialized version of `baseRest` which flattens the rest array. 13782 * 13783 * @private 13784 * @param {Function} func The function to apply a rest parameter to. 13785 * @returns {Function} Returns the new function. 13786 */ 13787 function flatRest(func) { 13788 return setToString(overRest(func, undefined, flatten), func + ''); 13789 } 13790 13791 /** 13792 * Creates an array of own enumerable property names and symbols of `object`. 13793 * 13794 * @private 13795 * @param {Object} object The object to query. 13796 * @returns {Array} Returns the array of property names and symbols. 13797 */ 13798 function getAllKeys(object) { 13799 return baseGetAllKeys(object, keys, getSymbols); 13800 } 13801 13802 /** 13803 * Creates an array of own and inherited enumerable property names and 13804 * symbols of `object`. 13805 * 13806 * @private 13807 * @param {Object} object The object to query. 13808 * @returns {Array} Returns the array of property names and symbols. 13809 */ 13810 function getAllKeysIn(object) { 13811 return baseGetAllKeys(object, keysIn, getSymbolsIn); 13812 } 13813 13814 /** 13815 * Gets metadata for `func`. 13816 * 13817 * @private 13818 * @param {Function} func The function to query. 13819 * @returns {*} Returns the metadata for `func`. 13820 */ 13821 var getData = !metaMap ? noop : function(func) { 13822 return metaMap.get(func); 13823 }; 13824 13825 /** 13826 * Gets the name of `func`. 13827 * 13828 * @private 13829 * @param {Function} func The function to query. 13830 * @returns {string} Returns the function name. 13831 */ 13832 function getFuncName(func) { 13833 var result = (func.name + ''), 13834 array = realNames[result], 13835 length = hasOwnProperty.call(realNames, result) ? array.length : 0; 13836 13837 while (length--) { 13838 var data = array[length], 13839 otherFunc = data.func; 13840 if (otherFunc == null || otherFunc == func) { 13841 return data.name; 13842 } 13843 } 13844 return result; 13845 } 13846 13847 /** 13848 * Gets the argument placeholder value for `func`. 13849 * 13850 * @private 13851 * @param {Function} func The function to inspect. 13852 * @returns {*} Returns the placeholder value. 13853 */ 13854 function getHolder(func) { 13855 var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func; 13856 return object.placeholder; 13857 } 13858 13859 /** 13860 * Gets the appropriate "iteratee" function. If `_.iteratee` is customized, 13861 * this function returns the custom method, otherwise it returns `baseIteratee`. 13862 * If arguments are provided, the chosen function is invoked with them and 13863 * its result is returned. 13864 * 13865 * @private 13866 * @param {*} [value] The value to convert to an iteratee. 13867 * @param {number} [arity] The arity of the created iteratee. 13868 * @returns {Function} Returns the chosen function or its result. 13869 */ 13870 function getIteratee() { 13871 var result = lodash.iteratee || iteratee; 13872 result = result === iteratee ? baseIteratee : result; 13873 return arguments.length ? result(arguments[0], arguments[1]) : result; 13874 } 13875 13876 /** 13877 * Gets the data for `map`. 13878 * 13879 * @private 13880 * @param {Object} map The map to query. 13881 * @param {string} key The reference key. 13882 * @returns {*} Returns the map data. 13883 */ 13884 function getMapData(map, key) { 13885 var data = map.__data__; 13886 return isKeyable(key) 13887 ? data[typeof key == 'string' ? 'string' : 'hash'] 13888 : data.map; 13889 } 13890 13891 /** 13892 * Gets the property names, values, and compare flags of `object`. 13893 * 13894 * @private 13895 * @param {Object} object The object to query. 13896 * @returns {Array} Returns the match data of `object`. 13897 */ 13898 function getMatchData(object) { 13899 var result = keys(object), 13900 length = result.length; 13901 13902 while (length--) { 13903 var key = result[length], 13904 value = object[key]; 13905 13906 result[length] = [key, value, isStrictComparable(value)]; 13907 } 13908 return result; 13909 } 13910 13911 /** 13912 * Gets the native function at `key` of `object`. 13913 * 13914 * @private 13915 * @param {Object} object The object to query. 13916 * @param {string} key The key of the method to get. 13917 * @returns {*} Returns the function if it's native, else `undefined`. 13918 */ 13919 function getNative(object, key) { 13920 var value = getValue(object, key); 13921 return baseIsNative(value) ? value : undefined; 13922 } 13923 13924 /** 13925 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. 13926 * 13927 * @private 13928 * @param {*} value The value to query. 13929 * @returns {string} Returns the raw `toStringTag`. 13930 */ 13931 function getRawTag(value) { 13932 var isOwn = hasOwnProperty.call(value, symToStringTag), 13933 tag = value[symToStringTag]; 13934 13935 try { 13936 value[symToStringTag] = undefined; 13937 var unmasked = true; 13938 } catch (e) {} 13939 13940 var result = nativeObjectToString.call(value); 13941 if (unmasked) { 13942 if (isOwn) { 13943 value[symToStringTag] = tag; 13944 } else { 13945 delete value[symToStringTag]; 13946 } 13947 } 13948 return result; 13949 } 13950 13951 /** 13952 * Creates an array of the own enumerable symbols of `object`. 13953 * 13954 * @private 13955 * @param {Object} object The object to query. 13956 * @returns {Array} Returns the array of symbols. 13957 */ 13958 var getSymbols = !nativeGetSymbols ? stubArray : function(object) { 13959 if (object == null) { 13960 return []; 13961 } 13962 object = Object(object); 13963 return arrayFilter(nativeGetSymbols(object), function(symbol) { 13964 return propertyIsEnumerable.call(object, symbol); 13965 }); 13966 }; 13967 13968 /** 13969 * Creates an array of the own and inherited enumerable symbols of `object`. 13970 * 13971 * @private 13972 * @param {Object} object The object to query. 13973 * @returns {Array} Returns the array of symbols. 13974 */ 13975 var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { 13976 var result = []; 13977 while (object) { 13978 arrayPush(result, getSymbols(object)); 13979 object = getPrototype(object); 13980 } 13981 return result; 13982 }; 13983 13984 /** 13985 * Gets the `toStringTag` of `value`. 13986 * 13987 * @private 13988 * @param {*} value The value to query. 13989 * @returns {string} Returns the `toStringTag`. 13990 */ 13991 var getTag = baseGetTag; 13992 13993 // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. 13994 if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || 13995 (Map && getTag(new Map) != mapTag) || 13996 (Promise && getTag(Promise.resolve()) != promiseTag) || 13997 (Set && getTag(new Set) != setTag) || 13998 (WeakMap && getTag(new WeakMap) != weakMapTag)) { 13999 getTag = function(value) { 14000 var result = baseGetTag(value), 14001 Ctor = result == objectTag ? value.constructor : undefined, 14002 ctorString = Ctor ? toSource(Ctor) : ''; 14003 14004 if (ctorString) { 14005 switch (ctorString) { 14006 case dataViewCtorString: return dataViewTag; 14007 case mapCtorString: return mapTag; 14008 case promiseCtorString: return promiseTag; 14009 case setCtorString: return setTag; 14010 case weakMapCtorString: return weakMapTag; 14011 } 14012 } 14013 return result; 14014 }; 14015 } 14016 14017 /** 14018 * Gets the view, applying any `transforms` to the `start` and `end` positions. 14019 * 14020 * @private 14021 * @param {number} start The start of the view. 14022 * @param {number} end The end of the view. 14023 * @param {Array} transforms The transformations to apply to the view. 14024 * @returns {Object}
vendor: 6,432 bytes, lines 14024-14229
14024 Returns an object containing the `start` and `end` 14025 * positions of the view. 14026 */ 14027 function getView(start, end, transforms) { 14028 var index = -1, 14029 length = transforms.length; 14030 14031 while (++index < length) { 14032 var data = transforms[index], 14033 size = data.size; 14034 14035 switch (data.type) { 14036 case 'drop': start += size; break; 14037 case 'dropRight': end -= size; break; 14038 case 'take': end = nativeMin(end, start + size); break; 14039 case 'takeRight': start = nativeMax(start, end - size); break; 14040 } 14041 } 14042 return { 'start': start, 'end': end }; 14043 } 14044 14045 /** 14046 * Extracts wrapper details from the `source` body comment. 14047 * 14048 * @private 14049 * @param {string} source The source to inspect. 14050 * @returns {Array} Returns the wrapper details. 14051 */ 14052 function getWrapDetails(source) { 14053 var match = source.match(reWrapDetails); 14054 return match ? match[1].split(reSplitDetails) : []; 14055 } 14056 14057 /** 14058 * Checks if `path` exists on `object`. 14059 * 14060 * @private 14061 * @param {Object} object The object to query. 14062 * @param {Array|string} path The path to check. 14063 * @param {Function} hasFunc The function to check properties. 14064 * @returns {boolean} Returns `true` if `path` exists, else `false`. 14065 */ 14066 function hasPath(object, path, hasFunc) { 14067 path = castPath(path, object); 14068 14069 var index = -1, 14070 length = path.length, 14071 result = false; 14072 14073 while (++index < length) { 14074 var key = toKey(path[index]); 14075 if (!(result = object != null && hasFunc(object, key))) { 14076 break; 14077 } 14078 object = object[key]; 14079 } 14080 if (result || ++index != length) { 14081 return result; 14082 } 14083 length = object == null ? 0 : object.length; 14084 return !!length && isLength(length) && isIndex(key, length) && 14085 (isArray(object) || isArguments(object)); 14086 } 14087 14088 /** 14089 * Initializes an array clone. 14090 * 14091 * @private 14092 * @param {Array} array The array to clone. 14093 * @returns {Array} Returns the initialized clone. 14094 */ 14095 function initCloneArray(array) { 14096 var length = array.length, 14097 result = new array.constructor(length); 14098 14099 // Add properties assigned by `RegExp#exec`. 14100 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { 14101 result.index = array.index; 14102 result.input = array.input; 14103 } 14104 return result; 14105 } 14106 14107 /** 14108 * Initializes an object clone. 14109 * 14110 * @private 14111 * @param {Object} object The object to clone. 14112 * @returns {Object} Returns the initialized clone. 14113 */ 14114 function initCloneObject(object) { 14115 return (typeof object.constructor == 'function' && !isPrototype(object)) 14116 ? baseCreate(getPrototype(object)) 14117 : {}; 14118 } 14119 14120 /** 14121 * Initializes an object clone based on its `toStringTag`. 14122 * 14123 * **Note:** This function only supports cloning values with tags of 14124 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. 14125 * 14126 * @private 14127 * @param {Object} object The object to clone. 14128 * @param {string} tag The `toStringTag` of the object to clone. 14129 * @param {boolean} [isDeep] Specify a deep clone. 14130 * @returns {Object} Returns the initialized clone. 14131 */ 14132 function initCloneByTag(object, tag, isDeep) { 14133 var Ctor = object.constructor; 14134 switch (tag) { 14135 case arrayBufferTag: 14136 return cloneArrayBuffer(object); 14137 14138 case boolTag: 14139 case dateTag: 14140 return new Ctor(+object); 14141 14142 case dataViewTag: 14143 return cloneDataView(object, isDeep); 14144 14145 case float32Tag: case float64Tag: 14146 case int8Tag: case int16Tag: case int32Tag: 14147 case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: 14148 return cloneTypedArray(object, isDeep); 14149 14150 case mapTag: 14151 return new Ctor; 14152 14153 case numberTag: 14154 case stringTag: 14155 return new Ctor(object); 14156 14157 case regexpTag: 14158 return cloneRegExp(object); 14159 14160 case setTag: 14161 return new Ctor; 14162 14163 case symbolTag: 14164 return cloneSymbol(object); 14165 } 14166 } 14167 14168 /** 14169 * Inserts wrapper `details` in a comment at the top of the `source` body. 14170 * 14171 * @private 14172 * @param {string} source The source to modify. 14173 * @returns {Array} details The details to insert. 14174 * @returns {string} Returns the modified source. 14175 */ 14176 function insertWrapDetails(source, details) { 14177 var length = details.length; 14178 if (!length) { 14179 return source; 14180 } 14181 var lastIndex = length - 1; 14182 details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; 14183 details = details.join(length > 2 ? ', ' : ' '); 14184 return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n'); 14185 } 14186 14187 /** 14188 * Checks if `value` is a flattenable `arguments` object or array. 14189 * 14190 * @private 14191 * @param {*} value The value to check. 14192 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. 14193 */ 14194 function isFlattenable(value) { 14195 return isArray(value) || isArguments(value) || 14196 !!(spreadableSymbol && value && value[spreadableSymbol]); 14197 } 14198 14199 /** 14200 * Checks if `value` is a valid array-like index. 14201 * 14202 * @private 14203 * @param {*} value The value to check. 14204 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. 14205 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. 14206 */ 14207 function isIndex(value, length) { 14208 var type = typeof value; 14209 length = length == null ? MAX_SAFE_INTEGER : length; 14210 14211 return !!length && 14212 (type == 'number' || 14213 (type != 'symbol' && reIsUint.test(value))) && 14214 (value > -1 && value % 1 == 0 && value < length); 14215 } 14216 14217 /** 14218 * Checks if the given arguments are from an iteratee call. 14219 * 14220 * @private 14221 * @param {*} value The potential iteratee value argument. 14222 * @param {*} index The potential iteratee index or key argument. 14223 * @param {*} object The potential iteratee object argument. 14224 * @returns {boolean} Returns `true` if the arguments are from an iteratee call, 14225 * else `false`. 14226 */ 14227 function isIterateeCall(value, index, object) { 14228 if (!isObject(object)) { 14229 return false;
vendor: 14,387 bytes, lines 14230-14676
14230 } 14231 var type = typeof index; 14232 if (type == 'number' 14233 ? (isArrayLike(object) && isIndex(index, object.length)) 14234 : (type == 'string' && index in object) 14235 ) { 14236 return eq(object[index], value); 14237 } 14238 return false; 14239 } 14240 14241 /** 14242 * Checks if `value` is a property name and not a property path. 14243 * 14244 * @private 14245 * @param {*} value The value to check. 14246 * @param {Object} [object] The object to query keys on. 14247 * @returns {boolean} Returns `true` if `value` is a property name, else `false`. 14248 */ 14249 function isKey(value, object) { 14250 if (isArray(value)) { 14251 return false; 14252 } 14253 var type = typeof value; 14254 if (type == 'number' || type == 'symbol' || type == 'boolean' || 14255 value == null || isSymbol(value)) { 14256 return true; 14257 } 14258 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || 14259 (object != null && value in Object(object)); 14260 } 14261 14262 /** 14263 * Checks if `value` is suitable for use as unique object key. 14264 * 14265 * @private 14266 * @param {*} value The value to check. 14267 * @returns {boolean} Returns `true` if `value` is suitable, else `false`. 14268 */ 14269 function isKeyable(value) { 14270 var type = typeof value; 14271 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') 14272 ? (value !== '__proto__') 14273 : (value === null); 14274 } 14275 14276 /** 14277 * Checks if `func` has a lazy counterpart. 14278 * 14279 * @private 14280 * @param {Function} func The function to check. 14281 * @returns {boolean} Returns `true` if `func` has a lazy counterpart, 14282 * else `false`. 14283 */ 14284 function isLaziable(func) { 14285 var funcName = getFuncName(func), 14286 other = lodash[funcName]; 14287 14288 if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { 14289 return false; 14290 } 14291 if (func === other) { 14292 return true; 14293 } 14294 var data = getData(other); 14295 return !!data && func === data[0]; 14296 } 14297 14298 /** 14299 * Checks if `func` has its source masked. 14300 * 14301 * @private 14302 * @param {Function} func The function to check. 14303 * @returns {boolean} Returns `true` if `func` is masked, else `false`. 14304 */ 14305 function isMasked(func) { 14306 return !!maskSrcKey && (maskSrcKey in func); 14307 } 14308 14309 /** 14310 * Checks if `func` is capable of being masked. 14311 * 14312 * @private 14313 * @param {*} value The value to check. 14314 * @returns {boolean} Returns `true` if `func` is maskable, else `false`. 14315 */ 14316 var isMaskable = coreJsData ? isFunction : stubFalse; 14317 14318 /** 14319 * Checks if `value` is likely a prototype object. 14320 * 14321 * @private 14322 * @param {*} value The value to check. 14323 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. 14324 */ 14325 function isPrototype(value) { 14326 var Ctor = value && value.constructor, 14327 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; 14328 14329 return value === proto; 14330 } 14331 14332 /** 14333 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. 14334 * 14335 * @private 14336 * @param {*} value The value to check. 14337 * @returns {boolean} Returns `true` if `value` if suitable for strict 14338 * equality comparisons, else `false`. 14339 */ 14340 function isStrictComparable(value) { 14341 return value === value && !isObject(value); 14342 } 14343 14344 /** 14345 * A specialized version of `matchesProperty` for source values suitable 14346 * for strict equality comparisons, i.e. `===`. 14347 * 14348 * @private 14349 * @param {string} key The key of the property to get. 14350 * @param {*} srcValue The value to match. 14351 * @returns {Function} Returns the new spec function. 14352 */ 14353 function matchesStrictComparable(key, srcValue) { 14354 return function(object) { 14355 if (object == null) { 14356 return false; 14357 } 14358 return object[key] === srcValue && 14359 (srcValue !== undefined || (key in Object(object))); 14360 }; 14361 } 14362 14363 /** 14364 * A specialized version of `_.memoize` which clears the memoized function's 14365 * cache when it exceeds `MAX_MEMOIZE_SIZE`. 14366 * 14367 * @private 14368 * @param {Function} func The function to have its output memoized. 14369 * @returns {Function} Returns the new memoized function. 14370 */ 14371 function memoizeCapped(func) { 14372 var result = memoize(func, function(key) { 14373 if (cache.size === MAX_MEMOIZE_SIZE) { 14374 cache.clear(); 14375 } 14376 return key; 14377 }); 14378 14379 var cache = result.cache; 14380 return result; 14381 } 14382 14383 /** 14384 * Merges the function metadata of `source` into `data`. 14385 * 14386 * Merging metadata reduces the number of wrappers used to invoke a function. 14387 * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` 14388 * may be applied regardless of execution order. Methods like `_.ary` and 14389 * `_.rearg` modify function arguments, making the order in which they are 14390 * executed important, preventing the merging of metadata. However, we make 14391 * an exception for a safe combined case where curried functions have `_.ary` 14392 * and or `_.rearg` applied. 14393 * 14394 * @private 14395 * @param {Array} data The destination metadata. 14396 * @param {Array} source The source metadata. 14397 * @returns {Array} Returns `data`. 14398 */ 14399 function mergeData(data, source) { 14400 var bitmask = data[1], 14401 srcBitmask = source[1], 14402 newBitmask = bitmask | srcBitmask, 14403 isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG); 14404 14405 var isCombo = 14406 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) || 14407 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) || 14408 ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG)); 14409 14410 // Exit early if metadata can't be merged. 14411 if (!(isCommon || isCombo)) { 14412 return data; 14413 } 14414 // Use source `thisArg` if available. 14415 if (srcBitmask & WRAP_BIND_FLAG) { 14416 data[2] = source[2]; 14417 // Set when currying a bound function. 14418 newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG; 14419 } 14420 // Compose partial arguments. 14421 var value = source[3]; 14422 if (value) { 14423 var partials = data[3]; 14424 data[3] = partials ? composeArgs(partials, value, source[4]) : value; 14425 data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4]; 14426 } 14427 // Compose partial right arguments. 14428 value = source[5]; 14429 if (value) { 14430 partials = data[5]; 14431 data[5] = partials ? composeArgsRight(partials, value, source[6]) : value; 14432 data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6]; 14433 } 14434 // Use source `argPos` if available. 14435 value = source[7]; 14436 if (value) { 14437 data[7] = value; 14438 } 14439 // Use source `ary` if it's smaller. 14440 if (srcBitmask & WRAP_ARY_FLAG) { 14441 data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); 14442 } 14443 // Use source `arity` if one is not provided. 14444 if (data[9] == null) { 14445 data[9] = source[9]; 14446 } 14447 // Use source `func` and merge bitmasks. 14448 data[0] = source[0]; 14449 data[1] = newBitmask; 14450 14451 return data; 14452 } 14453 14454 /** 14455 * This function is like 14456 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 14457 * except that it includes inherited enumerable properties. 14458 * 14459 * @private 14460 * @param {Object} object The object to query. 14461 * @returns {Array} Returns the array of property names. 14462 */ 14463 function nativeKeysIn(object) { 14464 var result = []; 14465 if (object != null) { 14466 for (var key in Object(object)) { 14467 result.push(key); 14468 } 14469 } 14470 return result; 14471 } 14472 14473 /** 14474 * Converts `value` to a string using `Object.prototype.toString`. 14475 * 14476 * @private 14477 * @param {*} value The value to convert. 14478 * @returns {string} Returns the converted string. 14479 */ 14480 function objectToString(value) { 14481 return nativeObjectToString.call(value); 14482 } 14483 14484 /** 14485 * A specialized version of `baseRest` which transforms the rest array. 14486 * 14487 * @private 14488 * @param {Function} func The function to apply a rest parameter to. 14489 * @param {number} [start=func.length-1] The start position of the rest parameter. 14490 * @param {Function} transform The rest array transform. 14491 * @returns {Function} Returns the new function. 14492 */ 14493 function overRest(func, start, transform) { 14494 start = nativeMax(start === undefined ? (func.length - 1) : start, 0); 14495 return function() { 14496 var args = arguments, 14497 index = -1, 14498 length = nativeMax(args.length - start, 0), 14499 array = Array(length); 14500 14501 while (++index < length) { 14502 array[index] = args[start + index]; 14503 } 14504 index = -1; 14505 var otherArgs = Array(start + 1); 14506 while (++index < start) { 14507 otherArgs[index] = args[index]; 14508 } 14509 otherArgs[start] = transform(array); 14510 return apply(func, this, otherArgs); 14511 }; 14512 } 14513 14514 /** 14515 * Gets the parent value at `path` of `object`. 14516 * 14517 * @private 14518 * @param {Object} object The object to query. 14519 * @param {Array} path The path to get the parent value of. 14520 * @returns {*} Returns the parent value. 14521 */ 14522 function parent(object, path) { 14523 return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); 14524 } 14525 14526 /** 14527 * Reorder `array` according to the specified indexes where the element at 14528 * the first index is assigned as the first element, the element at 14529 * the second index is assigned as the second element, and so on. 14530 * 14531 * @private 14532 * @param {Array} array The array to reorder. 14533 * @param {Array} indexes The arranged array indexes. 14534 * @returns {Array} Returns `array`. 14535 */ 14536 function reorder(array, indexes) { 14537 var arrLength = array.length, 14538 length = nativeMin(indexes.length, arrLength), 14539 oldArray = copyArray(array); 14540 14541 while (length--) { 14542 var index = indexes[length]; 14543 array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; 14544 } 14545 return array; 14546 } 14547 14548 /** 14549 * Gets the value at `key`, unless `key` is "__proto__" or "constructor". 14550 * 14551 * @private 14552 * @param {Object} object The object to query. 14553 * @param {string} key The key of the property to get. 14554 * @returns {*} Returns the property value. 14555 */ 14556 function safeGet(object, key) { 14557 if (key === 'constructor' && typeof object[key] === 'function') { 14558 return; 14559 } 14560 14561 if (key == '__proto__') { 14562 return; 14563 } 14564 14565 return object[key]; 14566 } 14567 14568 /** 14569 * Sets metadata for `func`. 14570 * 14571 * **Note:** If this function becomes hot, i.e. is invoked a lot in a short 14572 * period of time, it will trip its breaker and transition to an identity 14573 * function to avoid garbage collection pauses in V8. See 14574 * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) 14575 * for more details. 14576 * 14577 * @private 14578 * @param {Function} func The function to associate metadata with. 14579 * @param {*} data The metadata. 14580 * @returns {Function} Returns `func`. 14581 */ 14582 var setData = shortOut(baseSetData); 14583 14584 /** 14585 * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout). 14586 * 14587 * @private 14588 * @param {Function} func The function to delay. 14589 * @param {number} wait The number of milliseconds to delay invocation. 14590 * @returns {number|Object} Returns the timer id or timeout object. 14591 */ 14592 var setTimeout = ctxSetTimeout || function(func, wait) { 14593 return root.setTimeout(func, wait); 14594 }; 14595 14596 /** 14597 * Sets the `toString` method of `func` to return `string`. 14598 * 14599 * @private 14600 * @param {Function} func The function to modify. 14601 * @param {Function} string The `toString` result. 14602 * @returns {Function} Returns `func`. 14603 */ 14604 var setToString = shortOut(baseSetToString); 14605 14606 /** 14607 * Sets the `toString` method of `wrapper` to mimic the source of `reference` 14608 * with wrapper details in a comment at the top of the source body. 14609 * 14610 * @private 14611 * @param {Function} wrapper The function to modify. 14612 * @param {Function} reference The reference function. 14613 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 14614 * @returns {Function} Returns `wrapper`. 14615 */ 14616 function setWrapToString(wrapper, reference, bitmask) { 14617 var source = (reference + ''); 14618 return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); 14619 } 14620 14621 /** 14622 * Creates a function that'll short out and invoke `identity` instead 14623 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` 14624 * milliseconds. 14625 * 14626 * @private 14627 * @param {Function} func The function to restrict. 14628 * @returns {Function} Returns the new shortable function. 14629 */ 14630 function shortOut(func) { 14631 var count = 0, 14632 lastCalled = 0; 14633 14634 return function() { 14635 var stamp = nativeNow(), 14636 remaining = HOT_SPAN - (stamp - lastCalled); 14637 14638 lastCalled = stamp; 14639 if (remaining > 0) { 14640 if (++count >= HOT_COUNT) { 14641 return arguments[0]; 14642 } 14643 } else { 14644 count = 0; 14645 } 14646 return func.apply(undefined, arguments); 14647 }; 14648 } 14649 14650 /** 14651 * A specialized version of `_.shuffle` which mutates and sets the size of `array`. 14652 * 14653 * @private 14654 * @param {Array} array The array to shuffle. 14655 * @param {number} [size=array.length] The size of `array`. 14656 * @returns {Array} Returns `array`. 14657 */ 14658 function shuffleSelf(array, size) { 14659 var index = -1, 14660 length = array.length, 14661 lastIndex = length - 1; 14662 14663 size = size === undefined ? length : size; 14664 while (++index < size) { 14665 var rand = baseRandom(index, lastIndex), 14666 value = array[rand]; 14667 14668 array[rand] = array[index]; 14669 array[index] = value; 14670 } 14671 array.length = size; 14672 return array; 14673 } 14674 14675 /** 14676 * Converts `string` to a property path array.
vendor: 1,775 bytes, lines 14677-14737
14677 * 14678 * @private 14679 * @param {string} string The string to convert. 14680 * @returns {Array} Returns the property path array. 14681 */ 14682 var stringToPath = memoizeCapped(function(string) { 14683 var result = []; 14684 if (string.charCodeAt(0) === 46 /* . */) { 14685 result.push(''); 14686 } 14687 string.replace(rePropName, function(match, number, quote, subString) { 14688 result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); 14689 }); 14690 return result; 14691 }); 14692 14693 /** 14694 * Converts `value` to a string key if it's not a string or symbol. 14695 * 14696 * @private 14697 * @param {*} value The value to inspect. 14698 * @returns {string|symbol} Returns the key. 14699 */ 14700 function toKey(value) { 14701 if (typeof value == 'string' || isSymbol(value)) { 14702 return value; 14703 } 14704 var result = (value + ''); 14705 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 14706 } 14707 14708 /** 14709 * Converts `func` to its source code. 14710 * 14711 * @private 14712 * @param {Function} func The function to convert. 14713 * @returns {string} Returns the source code. 14714 */ 14715 function toSource(func) { 14716 if (func != null) { 14717 try { 14718 return funcToString.call(func); 14719 } catch (e) {} 14720 try { 14721 return (func + ''); 14722 } catch (e) {} 14723 } 14724 return ''; 14725 } 14726 14727 /** 14728 * Updates wrapper `details` based on `bitmask` flags. 14729 * 14730 * @private 14731 * @returns {Array} details The details to modify. 14732 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 14733 * @returns {Array} Returns `details`. 14734 */ 14735 function updateWrapDetails(details, bitmask) { 14736 arrayEach(wrapFlags, function(pair) { 14737 var value = '_.' + pair[0];
vendor: 69,323 bytes, lines 14738-17002
14738 if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { 14739 details.push(value); 14740 } 14741 }); 14742 return details.sort(); 14743 } 14744 14745 /** 14746 * Creates a clone of `wrapper`. 14747 * 14748 * @private 14749 * @param {Object} wrapper The wrapper to clone. 14750 * @returns {Object} Returns the cloned wrapper. 14751 */ 14752 function wrapperClone(wrapper) { 14753 if (wrapper instanceof LazyWrapper) { 14754 return wrapper.clone(); 14755 } 14756 var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); 14757 result.__actions__ = copyArray(wrapper.__actions__); 14758 result.__index__ = wrapper.__index__; 14759 result.__values__ = wrapper.__values__; 14760 return result; 14761 } 14762 14763 /*------------------------------------------------------------------------*/ 14764 14765 /** 14766 * Creates an array of elements split into groups the length of `size`. 14767 * If `array` can't be split evenly, the final chunk will be the remaining 14768 * elements. 14769 * 14770 * @static 14771 * @memberOf _ 14772 * @since 3.0.0 14773 * @category Array 14774 * @param {Array} array The array to process. 14775 * @param {number} [size=1] The length of each chunk 14776 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 14777 * @returns {Array} Returns the new array of chunks. 14778 * @example 14779 * 14780 * _.chunk(['a', 'b', 'c', 'd'], 2); 14781 * // => [['a', 'b'], ['c', 'd']] 14782 * 14783 * _.chunk(['a', 'b', 'c', 'd'], 3); 14784 * // => [['a', 'b', 'c'], ['d']] 14785 */ 14786 function chunk(array, size, guard) { 14787 if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) { 14788 size = 1; 14789 } else { 14790 size = nativeMax(toInteger(size), 0); 14791 } 14792 var length = array == null ? 0 : array.length; 14793 if (!length || size < 1) { 14794 return []; 14795 } 14796 var index = 0, 14797 resIndex = 0, 14798 result = Array(nativeCeil(length / size)); 14799 14800 while (index < length) { 14801 result[resIndex++] = baseSlice(array, index, (index += size)); 14802 } 14803 return result; 14804 } 14805 14806 /** 14807 * Creates an array with all falsey values removed. The values `false`, `null`, 14808 * `0`, `""`, `undefined`, and `NaN` are falsey. 14809 * 14810 * @static 14811 * @memberOf _ 14812 * @since 0.1.0 14813 * @category Array 14814 * @param {Array} array The array to compact. 14815 * @returns {Array} Returns the new array of filtered values. 14816 * @example 14817 * 14818 * _.compact([0, 1, false, 2, '', 3]); 14819 * // => [1, 2, 3] 14820 */ 14821 function compact(array) { 14822 var index = -1, 14823 length = array == null ? 0 : array.length, 14824 resIndex = 0, 14825 result = []; 14826 14827 while (++index < length) { 14828 var value = array[index]; 14829 if (value) { 14830 result[resIndex++] = value; 14831 } 14832 } 14833 return result; 14834 } 14835 14836 /** 14837 * Creates a new array concatenating `array` with any additional arrays 14838 * and/or values. 14839 * 14840 * @static 14841 * @memberOf _ 14842 * @since 4.0.0 14843 * @category Array 14844 * @param {Array} array The array to concatenate. 14845 * @param {...*} [values] The values to concatenate. 14846 * @returns {Array} Returns the new concatenated array. 14847 * @example 14848 * 14849 * var array = [1]; 14850 * var other = _.concat(array, 2, [3], [[4]]); 14851 * 14852 * console.log(other); 14853 * // => [1, 2, 3, [4]] 14854 * 14855 * console.log(array); 14856 * // => [1] 14857 */ 14858 function concat() { 14859 var length = arguments.length; 14860 if (!length) { 14861 return []; 14862 } 14863 var args = Array(length - 1), 14864 array = arguments[0], 14865 index = length; 14866 14867 while (index--) { 14868 args[index - 1] = arguments[index]; 14869 } 14870 return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1)); 14871 } 14872 14873 /** 14874 * Creates an array of `array` values not included in the other given arrays 14875 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 14876 * for equality comparisons. The order and references of result values are 14877 * determined by the first array. 14878 * 14879 * **Note:** Unlike `_.pullAll`, this method returns a new array. 14880 * 14881 * @static 14882 * @memberOf _ 14883 * @since 0.1.0 14884 * @category Array 14885 * @param {Array} array The array to inspect. 14886 * @param {...Array} [values] The values to exclude. 14887 * @returns {Array} Returns the new array of filtered values. 14888 * @see _.without, _.xor 14889 * @example 14890 * 14891 * _.difference([2, 1], [2, 3]); 14892 * // => [1] 14893 */ 14894 var difference = baseRest(function(array, values) { 14895 return isArrayLikeObject(array) 14896 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) 14897 : []; 14898 }); 14899 14900 /** 14901 * This method is like `_.difference` except that it accepts `iteratee` which 14902 * is invoked for each element of `array` and `values` to generate the criterion 14903 * by which they're compared. The order and references of result values are 14904 * determined by the first array. The iteratee is invoked with one argument: 14905 * (value). 14906 * 14907 * **Note:** Unlike `_.pullAllBy`, this method returns a new array. 14908 * 14909 * @static 14910 * @memberOf _ 14911 * @since 4.0.0 14912 * @category Array 14913 * @param {Array} array The array to inspect. 14914 * @param {...Array} [values] The values to exclude. 14915 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 14916 * @returns {Array} Returns the new array of filtered values. 14917 * @example 14918 * 14919 * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); 14920 * // => [1.2] 14921 * 14922 * // The `_.property` iteratee shorthand. 14923 * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); 14924 * // => [{ 'x': 2 }] 14925 */ 14926 var differenceBy = baseRest(function(array, values) { 14927 var iteratee = last(values); 14928 if (isArrayLikeObject(iteratee)) { 14929 iteratee = undefined; 14930 } 14931 return isArrayLikeObject(array) 14932 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)) 14933 : []; 14934 }); 14935 14936 /** 14937 * This method is like `_.difference` except that it accepts `comparator` 14938 * which is invoked to compare elements of `array` to `values`. The order and 14939 * references of result values are determined by the first array. The comparator 14940 * is invoked with two arguments: (arrVal, othVal). 14941 * 14942 * **Note:** Unlike `_.pullAllWith`, this method returns a new array. 14943 * 14944 * @static 14945 * @memberOf _ 14946 * @since 4.0.0 14947 * @category Array 14948 * @param {Array} array The array to inspect. 14949 * @param {...Array} [values] The values to exclude. 14950 * @param {Function} [comparator] The comparator invoked per element. 14951 * @returns {Array} Returns the new array of filtered values. 14952 * @example 14953 * 14954 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 14955 * 14956 * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); 14957 * // => [{ 'x': 2, 'y': 1 }] 14958 */ 14959 var differenceWith = baseRest(function(array, values) { 14960 var comparator = last(values); 14961 if (isArrayLikeObject(comparator)) { 14962 comparator = undefined; 14963 } 14964 return isArrayLikeObject(array) 14965 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) 14966 : []; 14967 }); 14968 14969 /** 14970 * Creates a slice of `array` with `n` elements dropped from the beginning. 14971 * 14972 * @static 14973 * @memberOf _ 14974 * @since 0.5.0 14975 * @category Array 14976 * @param {Array} array The array to query. 14977 * @param {number} [n=1] The number of elements to drop. 14978 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 14979 * @returns {Array} Returns the slice of `array`. 14980 * @example 14981 * 14982 * _.drop([1, 2, 3]); 14983 * // => [2, 3] 14984 * 14985 * _.drop([1, 2, 3], 2); 14986 * // => [3] 14987 * 14988 * _.drop([1, 2, 3], 5); 14989 * // => [] 14990 * 14991 * _.drop([1, 2, 3], 0); 14992 * // => [1, 2, 3] 14993 */ 14994 function drop(array, n, guard) { 14995 var length = array == null ? 0 : array.length; 14996 if (!length) { 14997 return []; 14998 } 14999 n = (guard || n === undefined) ? 1 : toInteger(n); 15000 return baseSlice(array, n < 0 ? 0 : n, length); 15001 } 15002 15003 /** 15004 * Creates a slice of `array` with `n` elements dropped from the end. 15005 * 15006 * @static 15007 * @memberOf _ 15008 * @since 3.0.0 15009 * @category Array 15010 * @param {Array} array The array to query. 15011 * @param {number} [n=1] The number of elements to drop. 15012 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 15013 * @returns {Array} Returns the slice of `array`. 15014 * @example 15015 * 15016 * _.dropRight([1, 2, 3]); 15017 * // => [1, 2] 15018 * 15019 * _.dropRight([1, 2, 3], 2); 15020 * // => [1] 15021 * 15022 * _.dropRight([1, 2, 3], 5); 15023 * // => [] 15024 * 15025 * _.dropRight([1, 2, 3], 0); 15026 * // => [1, 2, 3] 15027 */ 15028 function dropRight(array, n, guard) { 15029 var length = array == null ? 0 : array.length; 15030 if (!length) { 15031 return []; 15032 } 15033 n = (guard || n === undefined) ? 1 : toInteger(n); 15034 n = length - n; 15035 return baseSlice(array, 0, n < 0 ? 0 : n); 15036 } 15037 15038 /** 15039 * Creates a slice of `array` excluding elements dropped from the end. 15040 * Elements are dropped until `predicate` returns falsey. The predicate is 15041 * invoked with three arguments: (value, index, array). 15042 * 15043 * @static 15044 * @memberOf _ 15045 * @since 3.0.0 15046 * @category Array 15047 * @param {Array} array The array to query. 15048 * @param {Function} [predicate=_.identity] The function invoked per iteration. 15049 * @returns {Array} Returns the slice of `array`. 15050 * @example 15051 * 15052 * var users = [ 15053 * { 'user': 'barney', 'active': true }, 15054 * { 'user': 'fred', 'active': false }, 15055 * { 'user': 'pebbles', 'active': false } 15056 * ]; 15057 * 15058 * _.dropRightWhile(users, function(o) { return !o.active; }); 15059 * // => objects for ['barney'] 15060 * 15061 * // The `_.matches` iteratee shorthand. 15062 * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); 15063 * // => objects for ['barney', 'fred'] 15064 * 15065 * // The `_.matchesProperty` iteratee shorthand. 15066 * _.dropRightWhile(users, ['active', false]); 15067 * // => objects for ['barney'] 15068 * 15069 * // The `_.property` iteratee shorthand. 15070 * _.dropRightWhile(users, 'active'); 15071 * // => objects for ['barney', 'fred', 'pebbles'] 15072 */ 15073 function dropRightWhile(array, predicate) { 15074 return (array && array.length) 15075 ? baseWhile(array, getIteratee(predicate, 3), true, true) 15076 : []; 15077 } 15078 15079 /** 15080 * Creates a slice of `array` excluding elements dropped from the beginning. 15081 * Elements are dropped until `predicate` returns falsey. The predicate is 15082 * invoked with three arguments: (value, index, array). 15083 * 15084 * @static 15085 * @memberOf _ 15086 * @since 3.0.0 15087 * @category Array 15088 * @param {Array} array The array to query. 15089 * @param {Function} [predicate=_.identity] The function invoked per iteration. 15090 * @returns {Array} Returns the slice of `array`. 15091 * @example 15092 * 15093 * var users = [ 15094 * { 'user': 'barney', 'active': false }, 15095 * { 'user': 'fred', 'active': false }, 15096 * { 'user': 'pebbles', 'active': true } 15097 * ]; 15098 * 15099 * _.dropWhile(users, function(o) { return !o.active; }); 15100 * // => objects for ['pebbles'] 15101 * 15102 * // The `_.matches` iteratee shorthand. 15103 * _.dropWhile(users, { 'user': 'barney', 'active': false }); 15104 * // => objects for ['fred', 'pebbles'] 15105 * 15106 * // The `_.matchesProperty` iteratee shorthand. 15107 * _.dropWhile(users, ['active', false]); 15108 * // => objects for ['pebbles'] 15109 * 15110 * // The `_.property` iteratee shorthand. 15111 * _.dropWhile(users, 'active'); 15112 * // => objects for ['barney', 'fred', 'pebbles'] 15113 */ 15114 function dropWhile(array, predicate) { 15115 return (array && array.length) 15116 ? baseWhile(array, getIteratee(predicate, 3), true) 15117 : []; 15118 } 15119 15120 /** 15121 * Fills elements of `array` with `value` from `start` up to, but not 15122 * including, `end`. 15123 * 15124 * **Note:** This method mutates `array`. 15125 * 15126 * @static 15127 * @memberOf _ 15128 * @since 3.2.0 15129 * @category Array 15130 * @param {Array} array The array to fill. 15131 * @param {*} value The value to fill `array` with. 15132 * @param {number} [start=0] The start position. 15133 * @param {number} [end=array.length] The end position. 15134 * @returns {Array} Returns `array`. 15135 * @example 15136 * 15137 * var array = [1, 2, 3]; 15138 * 15139 * _.fill(array, 'a'); 15140 * console.log(array); 15141 * // => ['a', 'a', 'a'] 15142 * 15143 * _.fill(Array(3), 2); 15144 * // => [2, 2, 2] 15145 * 15146 * _.fill([4, 6, 8, 10], '*', 1, 3); 15147 * // => [4, '*', '*', 10] 15148 */ 15149 function fill(array, value, start, end) { 15150 var length = array == null ? 0 : array.length; 15151 if (!length) { 15152 return []; 15153 } 15154 if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { 15155 start = 0; 15156 end = length; 15157 } 15158 return baseFill(array, value, start, end); 15159 } 15160 15161 /** 15162 * This method is like `_.find` except that it returns the index of the first 15163 * element `predicate` returns truthy for instead of the element itself. 15164 * 15165 * @static 15166 * @memberOf _ 15167 * @since 1.1.0 15168 * @category Array 15169 * @param {Array} array The array to inspect. 15170 * @param {Function} [predicate=_.identity] The function invoked per iteration. 15171 * @param {number} [fromIndex=0] The index to search from. 15172 * @returns {number} Returns the index of the found element, else `-1`. 15173 * @example 15174 * 15175 * var users = [ 15176 * { 'user': 'barney', 'active': false }, 15177 * { 'user': 'fred', 'active': false }, 15178 * { 'user': 'pebbles', 'active': true } 15179 * ]; 15180 * 15181 * _.findIndex(users, function(o) { return o.user == 'barney'; }); 15182 * // => 0 15183 * 15184 * // The `_.matches` iteratee shorthand. 15185 * _.findIndex(users, { 'user': 'fred', 'active': false }); 15186 * // => 1 15187 * 15188 * // The `_.matchesProperty` iteratee shorthand. 15189 * _.findIndex(users, ['active', false]); 15190 * // => 0 15191 * 15192 * // The `_.property` iteratee shorthand. 15193 * _.findIndex(users, 'active'); 15194 * // => 2 15195 */ 15196 function findIndex(array, predicate, fromIndex) { 15197 var length = array == null ? 0 : array.length; 15198 if (!length) { 15199 return -1; 15200 } 15201 var index = fromIndex == null ? 0 : toInteger(fromIndex); 15202 if (index < 0) { 15203 index = nativeMax(length + index, 0); 15204 } 15205 return baseFindIndex(array, getIteratee(predicate, 3), index); 15206 } 15207 15208 /** 15209 * This method is like `_.findIndex` except that it iterates over elements 15210 * of `collection` from right to left. 15211 * 15212 * @static 15213 * @memberOf _ 15214 * @since 2.0.0 15215 * @category Array 15216 * @param {Array} array The array to inspect. 15217 * @param {Function} [predicate=_.identity] The function invoked per iteration. 15218 * @param {number} [fromIndex=array.length-1] The index to search from. 15219 * @returns {number} Returns the index of the found element, else `-1`. 15220 * @example 15221 * 15222 * var users = [ 15223 * { 'user': 'barney', 'active': true }, 15224 * { 'user': 'fred', 'active': false }, 15225 * { 'user': 'pebbles', 'active': false } 15226 * ]; 15227 * 15228 * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); 15229 * // => 2 15230 * 15231 * // The `_.matches` iteratee shorthand. 15232 * _.findLastIndex(users, { 'user': 'barney', 'active': true }); 15233 * // => 0 15234 * 15235 * // The `_.matchesProperty` iteratee shorthand. 15236 * _.findLastIndex(users, ['active', false]); 15237 * // => 2 15238 * 15239 * // The `_.property` iteratee shorthand. 15240 * _.findLastIndex(users, 'active'); 15241 * // => 0 15242 */ 15243 function findLastIndex(array, predicate, fromIndex) { 15244 var length = array == null ? 0 : array.length; 15245 if (!length) { 15246 return -1; 15247 } 15248 var index = length - 1; 15249 if (fromIndex !== undefined) { 15250 index = toInteger(fromIndex); 15251 index = fromIndex < 0 15252 ? nativeMax(length + index, 0) 15253 : nativeMin(index, length - 1); 15254 } 15255 return baseFindIndex(array, getIteratee(predicate, 3), index, true); 15256 } 15257 15258 /** 15259 * Flattens `array` a single level deep. 15260 * 15261 * @static 15262 * @memberOf _ 15263 * @since 0.1.0 15264 * @category Array 15265 * @param {Array} array The array to flatten. 15266 * @returns {Array} Returns the new flattened array. 15267 * @example 15268 * 15269 * _.flatten([1, [2, [3, [4]], 5]]); 15270 * // => [1, 2, [3, [4]], 5] 15271 */ 15272 function flatten(array) { 15273 var length = array == null ? 0 : array.length; 15274 return length ? baseFlatten(array, 1) : []; 15275 } 15276 15277 /** 15278 * Recursively flattens `array`. 15279 * 15280 * @static 15281 * @memberOf _ 15282 * @since 3.0.0 15283 * @category Array 15284 * @param {Array} array The array to flatten. 15285 * @returns {Array} Returns the new flattened array. 15286 * @example 15287 * 15288 * _.flattenDeep([1, [2, [3, [4]], 5]]); 15289 * // => [1, 2, 3, 4, 5] 15290 */ 15291 function flattenDeep(array) { 15292 var length = array == null ? 0 : array.length; 15293 return length ? baseFlatten(array, INFINITY) : []; 15294 } 15295 15296 /** 15297 * Recursively flatten `array` up to `depth` times. 15298 * 15299 * @static 15300 * @memberOf _ 15301 * @since 4.4.0 15302 * @category Array 15303 * @param {Array} array The array to flatten. 15304 * @param {number} [depth=1] The maximum recursion depth. 15305 * @returns {Array} Returns the new flattened array. 15306 * @example 15307 * 15308 * var array = [1, [2, [3, [4]], 5]]; 15309 * 15310 * _.flattenDepth(array, 1); 15311 * // => [1, 2, [3, [4]], 5] 15312 * 15313 * _.flattenDepth(array, 2); 15314 * // => [1, 2, 3, [4], 5] 15315 */ 15316 function flattenDepth(array, depth) { 15317 var length = array == null ? 0 : array.length; 15318 if (!length) { 15319 return []; 15320 } 15321 depth = depth === undefined ? 1 : toInteger(depth); 15322 return baseFlatten(array, depth); 15323 } 15324 15325 /** 15326 * The inverse of `_.toPairs`; this method returns an object composed 15327 * from key-value `pairs`. 15328 * 15329 * @static 15330 * @memberOf _ 15331 * @since 4.0.0 15332 * @category Array 15333 * @param {Array} pairs The key-value pairs. 15334 * @returns {Object} Returns the new object. 15335 * @example 15336 * 15337 * _.fromPairs([['a', 1], ['b', 2]]); 15338 * // => { 'a': 1, 'b': 2 } 15339 */ 15340 function fromPairs(pairs) { 15341 var index = -1, 15342 length = pairs == null ? 0 : pairs.length, 15343 result = {}; 15344 15345 while (++index < length) { 15346 var pair = pairs[index]; 15347 result[pair[0]] = pair[1]; 15348 } 15349 return result; 15350 } 15351 15352 /** 15353 * Gets the first element of `array`. 15354 * 15355 * @static 15356 * @memberOf _ 15357 * @since 0.1.0 15358 * @alias first 15359 * @category Array 15360 * @param {Array} array The array to query. 15361 * @returns {*} Returns the first element of `array`. 15362 * @example 15363 * 15364 * _.head([1, 2, 3]); 15365 * // => 1 15366 * 15367 * _.head([]); 15368 * // => undefined 15369 */ 15370 function head(array) { 15371 return (array && array.length) ? array[0] : undefined; 15372 } 15373 15374 /** 15375 * Gets the index at which the first occurrence of `value` is found in `array` 15376 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 15377 * for equality comparisons. If `fromIndex` is negative, it's used as the 15378 * offset from the end of `array`. 15379 * 15380 * @static 15381 * @memberOf _ 15382 * @since 0.1.0 15383 * @category Array 15384 * @param {Array} array The array to inspect. 15385 * @param {*} value The value to search for. 15386 * @param {number} [fromIndex=0] The index to search from. 15387 * @returns {number} Returns the index of the matched value, else `-1`. 15388 * @example 15389 * 15390 * _.indexOf([1, 2, 1, 2], 2); 15391 * // => 1 15392 * 15393 * // Search from the `fromIndex`. 15394 * _.indexOf([1, 2, 1, 2], 2, 2); 15395 * // => 3 15396 */ 15397 function indexOf(array, value, fromIndex) { 15398 var length = array == null ? 0 : array.length; 15399 if (!length) { 15400 return -1; 15401 } 15402 var index = fromIndex == null ? 0 : toInteger(fromIndex); 15403 if (index < 0) { 15404 index = nativeMax(length + index, 0); 15405 } 15406 return baseIndexOf(array, value, index); 15407 } 15408 15409 /** 15410 * Gets all but the last element of `array`. 15411 * 15412 * @static 15413 * @memberOf _ 15414 * @since 0.1.0 15415 * @category Array 15416 * @param {Array} array The array to query. 15417 * @returns {Array} Returns the slice of `array`. 15418 * @example 15419 * 15420 * _.initial([1, 2, 3]); 15421 * // => [1, 2] 15422 */ 15423 function initial(array) { 15424 var length = array == null ? 0 : array.length; 15425 return length ? baseSlice(array, 0, -1) : []; 15426 } 15427 15428 /** 15429 * Creates an array of unique values that are included in all given arrays 15430 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 15431 * for equality comparisons. The order and references of result values are 15432 * determined by the first array. 15433 * 15434 * @static 15435 * @memberOf _ 15436 * @since 0.1.0 15437 * @category Array 15438 * @param {...Array} [arrays] The arrays to inspect. 15439 * @returns {Array} Returns the new array of intersecting values. 15440 * @example 15441 * 15442 * _.intersection([2, 1], [2, 3]); 15443 * // => [2] 15444 */ 15445 var intersection = baseRest(function(arrays) { 15446 var mapped = arrayMap(arrays, castArrayLikeObject); 15447 return (mapped.length && mapped[0] === arrays[0]) 15448 ? baseIntersection(mapped) 15449 : []; 15450 }); 15451 15452 /** 15453 * This method is like `_.intersection` except that it accepts `iteratee` 15454 * which is invoked for each element of each `arrays` to generate the criterion 15455 * by which they're compared. The order and references of result values are 15456 * determined by the first array. The iteratee is invoked with one argument: 15457 * (value). 15458 * 15459 * @static 15460 * @memberOf _ 15461 * @since 4.0.0 15462 * @category Array 15463 * @param {...Array} [arrays] The arrays to inspect. 15464 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 15465 * @returns {Array} Returns the new array of intersecting values. 15466 * @example 15467 * 15468 * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); 15469 * // => [2.1] 15470 * 15471 * // The `_.property` iteratee shorthand. 15472 * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 15473 * // => [{ 'x': 1 }] 15474 */ 15475 var intersectionBy = baseRest(function(arrays) { 15476 var iteratee = last(arrays), 15477 mapped = arrayMap(arrays, castArrayLikeObject); 15478 15479 if (iteratee === last(mapped)) { 15480 iteratee = undefined; 15481 } else { 15482 mapped.pop(); 15483 } 15484 return (mapped.length && mapped[0] === arrays[0]) 15485 ? baseIntersection(mapped, getIteratee(iteratee, 2)) 15486 : []; 15487 }); 15488 15489 /** 15490 * This method is like `_.intersection` except that it accepts `comparator` 15491 * which is invoked to compare elements of `arrays`. The order and references 15492 * of result values are determined by the first array. The comparator is 15493 * invoked with two arguments: (arrVal, othVal). 15494 * 15495 * @static 15496 * @memberOf _ 15497 * @since 4.0.0 15498 * @category Array 15499 * @param {...Array} [arrays] The arrays to inspect. 15500 * @param {Function} [comparator] The comparator invoked per element. 15501 * @returns {Array} Returns the new array of intersecting values. 15502 * @example 15503 * 15504 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 15505 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 15506 * 15507 * _.intersectionWith(objects, others, _.isEqual); 15508 * // => [{ 'x': 1, 'y': 2 }] 15509 */ 15510 var intersectionWith = baseRest(function(arrays) { 15511 var comparator = last(arrays), 15512 mapped = arrayMap(arrays, castArrayLikeObject); 15513 15514 comparator = typeof comparator == 'function' ? comparator : undefined; 15515 if (comparator) { 15516 mapped.pop(); 15517 } 15518 return (mapped.length && mapped[0] === arrays[0]) 15519 ? baseIntersection(mapped, undefined, comparator) 15520 : []; 15521 }); 15522 15523 /** 15524 * Converts all elements in `array` into a string separated by `separator`. 15525 * 15526 * @static 15527 * @memberOf _ 15528 * @since 4.0.0 15529 * @category Array 15530 * @param {Array} array The array to convert. 15531 * @param {string} [separator=','] The element separator. 15532 * @returns {string} Returns the joined string. 15533 * @example 15534 * 15535 * _.join(['a', 'b', 'c'], '~'); 15536 * // => 'a~b~c' 15537 */ 15538 function join(array, separator) { 15539 return array == null ? '' : nativeJoin.call(array, separator); 15540 } 15541 15542 /** 15543 * Gets the last element of `array`. 15544 * 15545 * @static 15546 * @memberOf _ 15547 * @since 0.1.0 15548 * @category Array 15549 * @param {Array} array The array to query. 15550 * @returns {*} Returns the last element of `array`. 15551 * @example 15552 * 15553 * _.last([1, 2, 3]); 15554 * // => 3 15555 */ 15556 function last(array) { 15557 var length = array == null ? 0 : array.length; 15558 return length ? array[length - 1] : undefined; 15559 } 15560 15561 /** 15562 * This method is like `_.indexOf` except that it iterates over elements of 15563 * `array` from right to left. 15564 * 15565 * @static 15566 * @memberOf _ 15567 * @since 0.1.0 15568 * @category Array 15569 * @param {Array} array The array to inspect. 15570 * @param {*} value The value to search for. 15571 * @param {number} [fromIndex=array.length-1] The index to search from. 15572 * @returns {number} Returns the index of the matched value, else `-1`. 15573 * @example 15574 * 15575 * _.lastIndexOf([1, 2, 1, 2], 2); 15576 * // => 3 15577 * 15578 * // Search from the `fromIndex`. 15579 * _.lastIndexOf([1, 2, 1, 2], 2, 2); 15580 * // => 1 15581 */ 15582 function lastIndexOf(array, value, fromIndex) { 15583 var length = array == null ? 0 : array.length; 15584 if (!length) { 15585 return -1; 15586 } 15587 var index = length; 15588 if (fromIndex !== undefined) { 15589 index = toInteger(fromIndex); 15590 index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1); 15591 } 15592 return value === value 15593 ? strictLastIndexOf(array, value, index) 15594 : baseFindIndex(array, baseIsNaN, index, true); 15595 } 15596 15597 /** 15598 * Gets the element at index `n` of `array`. If `n` is negative, the nth 15599 * element from the end is returned. 15600 * 15601 * @static 15602 * @memberOf _ 15603 * @since 4.11.0 15604 * @category Array 15605 * @param {Array} array The array to query. 15606 * @param {number} [n=0] The index of the element to return. 15607 * @returns {*} Returns the nth element of `array`. 15608 * @example 15609 * 15610 * var array = ['a', 'b', 'c', 'd']; 15611 * 15612 * _.nth(array, 1); 15613 * // => 'b' 15614 * 15615 * _.nth(array, -2); 15616 * // => 'c'; 15617 */ 15618 function nth(array, n) { 15619 return (array && array.length) ? baseNth(array, toInteger(n)) : undefined; 15620 } 15621 15622 /** 15623 * Removes all given values from `array` using 15624 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 15625 * for equality comparisons. 15626 * 15627 * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` 15628 * to remove elements from an array by predicate. 15629 * 15630 * @static 15631 * @memberOf _ 15632 * @since 2.0.0 15633 * @category Array 15634 * @param {Array} array The array to modify. 15635 * @param {...*} [values] The values to remove. 15636 * @returns {Array} Returns `array`. 15637 * @example 15638 * 15639 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 15640 * 15641 * _.pull(array, 'a', 'c'); 15642 * console.log(array); 15643 * // => ['b', 'b'] 15644 */ 15645 var pull = baseRest(pullAll); 15646 15647 /** 15648 * This method is like `_.pull` except that it accepts an array of values to remove. 15649 * 15650 * **Note:** Unlike `_.difference`, this method mutates `array`. 15651 * 15652 * @static 15653 * @memberOf _ 15654 * @since 4.0.0 15655 * @category Array 15656 * @param {Array} array The array to modify. 15657 * @param {Array} values The values to remove. 15658 * @returns {Array} Returns `array`. 15659 * @example 15660 * 15661 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 15662 * 15663 * _.pullAll(array, ['a', 'c']); 15664 * console.log(array); 15665 * // => ['b', 'b'] 15666 */ 15667 function pullAll(array, values) { 15668 return (array && array.length && values && values.length) 15669 ? basePullAll(array, values) 15670 : array; 15671 } 15672 15673 /** 15674 * This method is like `_.pullAll` except that it accepts `iteratee` which is 15675 * invoked for each element of `array` and `values` to generate the criterion 15676 * by which they're compared. The iteratee is invoked with one argument: (value). 15677 * 15678 * **Note:** Unlike `_.differenceBy`, this method mutates `array`. 15679 * 15680 * @static 15681 * @memberOf _ 15682 * @since 4.0.0 15683 * @category Array 15684 * @param {Array} array The array to modify. 15685 * @param {Array} values The values to remove. 15686 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 15687 * @returns {Array} Returns `array`. 15688 * @example 15689 * 15690 * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; 15691 * 15692 * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); 15693 * console.log(array); 15694 * // => [{ 'x': 2 }] 15695 */ 15696 function pullAllBy(array, values, iteratee) { 15697 return (array && array.length && values && values.length) 15698 ? basePullAll(array, values, getIteratee(iteratee, 2)) 15699 : array; 15700 } 15701 15702 /** 15703 * This method is like `_.pullAll` except that it accepts `comparator` which 15704 * is invoked to compare elements of `array` to `values`. The comparator is 15705 * invoked with two arguments: (arrVal, othVal). 15706 * 15707 * **Note:** Unlike `_.differenceWith`, this method mutates `array`. 15708 * 15709 * @static 15710 * @memberOf _ 15711 * @since 4.6.0 15712 * @category Array 15713 * @param {Array} array The array to modify. 15714 * @param {Array} values The values to remove. 15715 * @param {Function} [comparator] The comparator invoked per element. 15716 * @returns {Array} Returns `array`. 15717 * @example 15718 * 15719 * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]; 15720 * 15721 * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual); 15722 * console.log(array); 15723 * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] 15724 */ 15725 function pullAllWith(array, values, comparator) { 15726 return (array && array.length && values && values.length) 15727 ? basePullAll(array, values, undefined, comparator) 15728 : array; 15729 } 15730 15731 /** 15732 * Removes elements from `array` corresponding to `indexes` and returns an 15733 * array of removed elements. 15734 * 15735 * **Note:** Unlike `_.at`, this method mutates `array`. 15736 * 15737 * @static 15738 * @memberOf _ 15739 * @since 3.0.0 15740 * @category Array 15741 * @param {Array} array The array to modify. 15742 * @param {...(number|number[])} [indexes] The indexes of elements to remove. 15743 * @returns {Array} Returns the new array of removed elements. 15744 * @example 15745 * 15746 * var array = ['a', 'b', 'c', 'd']; 15747 * var pulled = _.pullAt(array, [1, 3]); 15748 * 15749 * console.log(array); 15750 * // => ['a', 'c'] 15751 * 15752 * console.log(pulled); 15753 * // => ['b', 'd'] 15754 */ 15755 var pullAt = flatRest(function(array, indexes) { 15756 var length = array == null ? 0 : array.length, 15757 result = baseAt(array, indexes); 15758 15759 basePullAt(array, arrayMap(indexes, function(index) { 15760 return isIndex(index, length) ? +index : index; 15761 }).sort(compareAscending)); 15762 15763 return result; 15764 }); 15765 15766 /** 15767 * Removes all elements from `array` that `predicate` returns truthy for 15768 * and returns an array of the removed elements. The predicate is invoked 15769 * with three arguments: (value, index, array). 15770 * 15771 * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` 15772 * to pull elements from an array by value. 15773 * 15774 * @static 15775 * @memberOf _ 15776 * @since 2.0.0 15777 * @category Array 15778 * @param {Array} array The array to modify. 15779 * @param {Function} [predicate=_.identity] The function invoked per iteration. 15780 * @returns {Array} Returns the new array of removed elements. 15781 * @example 15782 * 15783 * var array = [1, 2, 3, 4]; 15784 * var evens = _.remove(array, function(n) { 15785 * return n % 2 == 0; 15786 * }); 15787 * 15788 * console.log(array); 15789 * // => [1, 3] 15790 * 15791 * console.log(evens); 15792 * // => [2, 4] 15793 */ 15794 function remove(array, predicate) { 15795 var result = []; 15796 if (!(array && array.length)) { 15797 return result; 15798 } 15799 var index = -1, 15800 indexes = [], 15801 length = array.length; 15802 15803 predicate = getIteratee(predicate, 3); 15804 while (++index < length) { 15805 var value = array[index]; 15806 if (predicate(value, index, array)) { 15807 result.push(value); 15808 indexes.push(index); 15809 } 15810 } 15811 basePullAt(array, indexes); 15812 return result; 15813 } 15814 15815 /** 15816 * Reverses `array` so that the first element becomes the last, the second 15817 * element becomes the second to last, and so on. 15818 * 15819 * **Note:** This method mutates `array` and is based on 15820 * [`Array#reverse`](https://mdn.io/Array/reverse). 15821 * 15822 * @static 15823 * @memberOf _ 15824 * @since 4.0.0 15825 * @category Array 15826 * @param {Array} array The array to modify. 15827 * @returns {Array} Returns `array`. 15828 * @example 15829 * 15830 * var array = [1, 2, 3]; 15831 * 15832 * _.reverse(array); 15833 * // => [3, 2, 1] 15834 * 15835 * console.log(array); 15836 * // => [3, 2, 1] 15837 */ 15838 function reverse(array) { 15839 return array == null ? array : nativeReverse.call(array); 15840 } 15841 15842 /** 15843 * Creates a slice of `array` from `start` up to, but not including, `end`. 15844 * 15845 * **Note:** This method is used instead of 15846 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are 15847 * returned. 15848 * 15849 * @static 15850 * @memberOf _ 15851 * @since 3.0.0 15852 * @category Array 15853 * @param {Array} array The array to slice. 15854 * @param {number} [start=0] The start position. 15855 * @param {number} [end=array.length] The end position. 15856 * @returns {Array} Returns the slice of `array`. 15857 */ 15858 function slice(array, start, end) { 15859 var length = array == null ? 0 : array.length; 15860 if (!length) { 15861 return []; 15862 } 15863 if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { 15864 start = 0; 15865 end = length; 15866 } 15867 else { 15868 start = start == null ? 0 : toInteger(start); 15869 end = end === undefined ? length : toInteger(end); 15870 } 15871 return baseSlice(array, start, end); 15872 } 15873 15874 /** 15875 * Uses a binary search to determine the lowest index at which `value` 15876 * should be inserted into `array` in order to maintain its sort order. 15877 * 15878 * @static 15879 * @memberOf _ 15880 * @since 0.1.0 15881 * @category Array 15882 * @param {Array} array The sorted array to inspect. 15883 * @param {*} value The value to evaluate. 15884 * @returns {number} Returns the index at which `value` should be inserted 15885 * into `array`. 15886 * @example 15887 * 15888 * _.sortedIndex([30, 50], 40); 15889 * // => 1 15890 */ 15891 function sortedIndex(array, value) { 15892 return baseSortedIndex(array, value); 15893 } 15894 15895 /** 15896 * This method is like `_.sortedIndex` except that it accepts `iteratee` 15897 * which is invoked for `value` and each element of `array` to compute their 15898 * sort ranking. The iteratee is invoked with one argument: (value). 15899 * 15900 * @static 15901 * @memberOf _ 15902 * @since 4.0.0 15903 * @category Array 15904 * @param {Array} array The sorted array to inspect. 15905 * @param {*} value The value to evaluate. 15906 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 15907 * @returns {number} Returns the index at which `value` should be inserted 15908 * into `array`. 15909 * @example 15910 * 15911 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 15912 * 15913 * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 15914 * // => 0 15915 * 15916 * // The `_.property` iteratee shorthand. 15917 * _.sortedIndexBy(objects, { 'x': 4 }, 'x'); 15918 * // => 0 15919 */ 15920 function sortedIndexBy(array, value, iteratee) { 15921 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2)); 15922 } 15923 15924 /** 15925 * This method is like `_.indexOf` except that it performs a binary 15926 * search on a sorted `array`. 15927 * 15928 * @static 15929 * @memberOf _ 15930 * @since 4.0.0 15931 * @category Array 15932 * @param {Array} array The array to inspect. 15933 * @param {*} value The value to search for. 15934 * @returns {number} Returns the index of the matched value, else `-1`. 15935 * @example 15936 * 15937 * _.sortedIndexOf([4, 5, 5, 5, 6], 5); 15938 * // => 1 15939 */ 15940 function sortedIndexOf(array, value) { 15941 var length = array == null ? 0 : array.length; 15942 if (length) { 15943 var index = baseSortedIndex(array, value); 15944 if (index < length && eq(array[index], value)) { 15945 return index; 15946 } 15947 } 15948 return -1; 15949 } 15950 15951 /** 15952 * This method is like `_.sortedIndex` except that it returns the highest 15953 * index at which `value` should be inserted into `array` in order to 15954 * maintain its sort order. 15955 * 15956 * @static 15957 * @memberOf _ 15958 * @since 3.0.0 15959 * @category Array 15960 * @param {Array} array The sorted array to inspect. 15961 * @param {*} value The value to evaluate. 15962 * @returns {number} Returns the index at which `value` should be inserted 15963 * into `array`. 15964 * @example 15965 * 15966 * _.sortedLastIndex([4, 5, 5, 5, 6], 5); 15967 * // => 4 15968 */ 15969 function sortedLastIndex(array, value) { 15970 return baseSortedIndex(array, value, true); 15971 } 15972 15973 /** 15974 * This method is like `_.sortedLastIndex` except that it accepts `iteratee` 15975 * which is invoked for `value` and each element of `array` to compute their 15976 * sort ranking. The iteratee is invoked with one argument: (value). 15977 * 15978 * @static 15979 * @memberOf _ 15980 * @since 4.0.0 15981 * @category Array 15982 * @param {Array} array The sorted array to inspect. 15983 * @param {*} value The value to evaluate. 15984 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 15985 * @returns {number} Returns the index at which `value` should be inserted 15986 * into `array`. 15987 * @example 15988 * 15989 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 15990 * 15991 * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 15992 * // => 1 15993 * 15994 * // The `_.property` iteratee shorthand. 15995 * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x'); 15996 * // => 1 15997 */ 15998 function sortedLastIndexBy(array, value, iteratee) { 15999 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true); 16000 } 16001 16002 /** 16003 * This method is like `_.lastIndexOf` except that it performs a binary 16004 * search on a sorted `array`. 16005 * 16006 * @static 16007 * @memberOf _ 16008 * @since 4.0.0 16009 * @category Array 16010 * @param {Array} array The array to inspect. 16011 * @param {*} value The value to search for. 16012 * @returns {number} Returns the index of the matched value, else `-1`. 16013 * @example 16014 * 16015 * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5); 16016 * // => 3 16017 */ 16018 function sortedLastIndexOf(array, value) { 16019 var length = array == null ? 0 : array.length; 16020 if (length) { 16021 var index = baseSortedIndex(array, value, true) - 1; 16022 if (eq(array[index], value)) { 16023 return index; 16024 } 16025 } 16026 return -1; 16027 } 16028 16029 /** 16030 * This method is like `_.uniq` except that it's designed and optimized 16031 * for sorted arrays. 16032 * 16033 * @static 16034 * @memberOf _ 16035 * @since 4.0.0 16036 * @category Array 16037 * @param {Array} array The array to inspect. 16038 * @returns {Array} Returns the new duplicate free array. 16039 * @example 16040 * 16041 * _.sortedUniq([1, 1, 2]); 16042 * // => [1, 2] 16043 */ 16044 function sortedUniq(array) { 16045 return (array && array.length) 16046 ? baseSortedUniq(array) 16047 : []; 16048 } 16049 16050 /** 16051 * This method is like `_.uniqBy` except that it's designed and optimized 16052 * for sorted arrays. 16053 * 16054 * @static 16055 * @memberOf _ 16056 * @since 4.0.0 16057 * @category Array 16058 * @param {Array} array The array to inspect. 16059 * @param {Function} [iteratee] The iteratee invoked per element. 16060 * @returns {Array} Returns the new duplicate free array. 16061 * @example 16062 * 16063 * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); 16064 * // => [1.1, 2.3] 16065 */ 16066 function sortedUniqBy(array, iteratee) { 16067 return (array && array.length) 16068 ? baseSortedUniq(array, getIteratee(iteratee, 2)) 16069 : []; 16070 } 16071 16072 /** 16073 * Gets all but the first element of `array`. 16074 * 16075 * @static 16076 * @memberOf _ 16077 * @since 4.0.0 16078 * @category Array 16079 * @param {Array} array The array to query. 16080 * @returns {Array} Returns the slice of `array`. 16081 * @example 16082 * 16083 * _.tail([1, 2, 3]); 16084 * // => [2, 3] 16085 */ 16086 function tail(array) { 16087 var length = array == null ? 0 : array.length; 16088 return length ? baseSlice(array, 1, length) : []; 16089 } 16090 16091 /** 16092 * Creates a slice of `array` with `n` elements taken from the beginning. 16093 * 16094 * @static 16095 * @memberOf _ 16096 * @since 0.1.0 16097 * @category Array 16098 * @param {Array} array The array to query. 16099 * @param {number} [n=1] The number of elements to take. 16100 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16101 * @returns {Array} Returns the slice of `array`. 16102 * @example 16103 * 16104 * _.take([1, 2, 3]); 16105 * // => [1] 16106 * 16107 * _.take([1, 2, 3], 2); 16108 * // => [1, 2] 16109 * 16110 * _.take([1, 2, 3], 5); 16111 * // => [1, 2, 3] 16112 * 16113 * _.take([1, 2, 3], 0); 16114 * // => [] 16115 */ 16116 function take(array, n, guard) { 16117 if (!(array && array.length)) { 16118 return []; 16119 } 16120 n = (guard || n === undefined) ? 1 : toInteger(n); 16121 return baseSlice(array, 0, n < 0 ? 0 : n); 16122 } 16123 16124 /** 16125 * Creates a slice of `array` with `n` elements taken from the end. 16126 * 16127 * @static 16128 * @memberOf _ 16129 * @since 3.0.0 16130 * @category Array 16131 * @param {Array} array The array to query. 16132 * @param {number} [n=1] The number of elements to take. 16133 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16134 * @returns {Array} Returns the slice of `array`. 16135 * @example 16136 * 16137 * _.takeRight([1, 2, 3]); 16138 * // => [3] 16139 * 16140 * _.takeRight([1, 2, 3], 2); 16141 * // => [2, 3] 16142 * 16143 * _.takeRight([1, 2, 3], 5); 16144 * // => [1, 2, 3] 16145 * 16146 * _.takeRight([1, 2, 3], 0); 16147 * // => [] 16148 */ 16149 function takeRight(array, n, guard) { 16150 var length = array == null ? 0 : array.length; 16151 if (!length) { 16152 return []; 16153 } 16154 n = (guard || n === undefined) ? 1 : toInteger(n); 16155 n = length - n; 16156 return baseSlice(array, n < 0 ? 0 : n, length); 16157 } 16158 16159 /** 16160 * Creates a slice of `array` with elements taken from the end. Elements are 16161 * taken until `predicate` returns falsey. The predicate is invoked with 16162 * three arguments: (value, index, array). 16163 * 16164 * @static 16165 * @memberOf _ 16166 * @since 3.0.0 16167 * @category Array 16168 * @param {Array} array The array to query. 16169 * @param {Function} [predicate=_.identity] The function invoked per iteration. 16170 * @returns {Array} Returns the slice of `array`. 16171 * @example 16172 * 16173 * var users = [ 16174 * { 'user': 'barney', 'active': true }, 16175 * { 'user': 'fred', 'active': false }, 16176 * { 'user': 'pebbles', 'active': false } 16177 * ]; 16178 * 16179 * _.takeRightWhile(users, function(o) { return !o.active; }); 16180 * // => objects for ['fred', 'pebbles'] 16181 * 16182 * // The `_.matches` iteratee shorthand. 16183 * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); 16184 * // => objects for ['pebbles'] 16185 * 16186 * // The `_.matchesProperty` iteratee shorthand. 16187 * _.takeRightWhile(users, ['active', false]); 16188 * // => objects for ['fred', 'pebbles'] 16189 * 16190 * // The `_.property` iteratee shorthand. 16191 * _.takeRightWhile(users, 'active'); 16192 * // => [] 16193 */ 16194 function takeRightWhile(array, predicate) { 16195 return (array && array.length) 16196 ? baseWhile(array, getIteratee(predicate, 3), false, true) 16197 : []; 16198 } 16199 16200 /** 16201 * Creates a slice of `array` with elements taken from the beginning. Elements 16202 * are taken until `predicate` returns falsey. The predicate is invoked with 16203 * three arguments: (value, index, array). 16204 * 16205 * @static 16206 * @memberOf _ 16207 * @since 3.0.0 16208 * @category Array 16209 * @param {Array} array The array to query. 16210 * @param {Function} [predicate=_.identity] The function invoked per iteration. 16211 * @returns {Array} Returns the slice of `array`. 16212 * @example 16213 * 16214 * var users = [ 16215 * { 'user': 'barney', 'active': false }, 16216 * { 'user': 'fred', 'active': false }, 16217 * { 'user': 'pebbles', 'active': true } 16218 * ]; 16219 * 16220 * _.takeWhile(users, function(o) { return !o.active; }); 16221 * // => objects for ['barney', 'fred'] 16222 * 16223 * // The `_.matches` iteratee shorthand. 16224 * _.takeWhile(users, { 'user': 'barney', 'active': false }); 16225 * // => objects for ['barney'] 16226 * 16227 * // The `_.matchesProperty` iteratee shorthand. 16228 * _.takeWhile(users, ['active', false]); 16229 * // => objects for ['barney', 'fred'] 16230 * 16231 * // The `_.property` iteratee shorthand. 16232 * _.takeWhile(users, 'active'); 16233 * // => [] 16234 */ 16235 function takeWhile(array, predicate) { 16236 return (array && array.length) 16237 ? baseWhile(array, getIteratee(predicate, 3)) 16238 : []; 16239 } 16240 16241 /** 16242 * Creates an array of unique values, in order, from all given arrays using 16243 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 16244 * for equality comparisons. 16245 * 16246 * @static 16247 * @memberOf _ 16248 * @since 0.1.0 16249 * @category Array 16250 * @param {...Array} [arrays] The arrays to inspect. 16251 * @returns {Array} Returns the new array of combined values. 16252 * @example 16253 * 16254 * _.union([2], [1, 2]); 16255 * // => [2, 1] 16256 */ 16257 var union = baseRest(function(arrays) { 16258 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); 16259 }); 16260 16261 /** 16262 * This method is like `_.union` except that it accepts `iteratee` which is 16263 * invoked for each element of each `arrays` to generate the criterion by 16264 * which uniqueness is computed. Result values are chosen from the first 16265 * array in which the value occurs. The iteratee is invoked with one argument: 16266 * (value). 16267 * 16268 * @static 16269 * @memberOf _ 16270 * @since 4.0.0 16271 * @category Array 16272 * @param {...Array} [arrays] The arrays to inspect. 16273 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 16274 * @returns {Array} Returns the new array of combined values. 16275 * @example 16276 * 16277 * _.unionBy([2.1], [1.2, 2.3], Math.floor); 16278 * // => [2.1, 1.2] 16279 * 16280 * // The `_.property` iteratee shorthand. 16281 * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 16282 * // => [{ 'x': 1 }, { 'x': 2 }] 16283 */ 16284 var unionBy = baseRest(function(arrays) { 16285 var iteratee = last(arrays); 16286 if (isArrayLikeObject(iteratee)) { 16287 iteratee = undefined; 16288 } 16289 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)); 16290 }); 16291 16292 /** 16293 * This method is like `_.union` except that it accepts `comparator` which 16294 * is invoked to compare elements of `arrays`. Result values are chosen from 16295 * the first array in which the value occurs. The comparator is invoked 16296 * with two arguments: (arrVal, othVal). 16297 * 16298 * @static 16299 * @memberOf _ 16300 * @since 4.0.0 16301 * @category Array 16302 * @param {...Array} [arrays] The arrays to inspect. 16303 * @param {Function} [comparator] The comparator invoked per element. 16304 * @returns {Array} Returns the new array of combined values. 16305 * @example 16306 * 16307 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 16308 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 16309 * 16310 * _.unionWith(objects, others, _.isEqual); 16311 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 16312 */ 16313 var unionWith = baseRest(function(arrays) { 16314 var comparator = last(arrays); 16315 comparator = typeof comparator == 'function' ? comparator : undefined; 16316 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator); 16317 }); 16318 16319 /** 16320 * Creates a duplicate-free version of an array, using 16321 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 16322 * for equality comparisons, in which only the first occurrence of each element 16323 * is kept. The order of result values is determined by the order they occur 16324 * in the array. 16325 * 16326 * @static 16327 * @memberOf _ 16328 * @since 0.1.0 16329 * @category Array 16330 * @param {Array} array The array to inspect. 16331 * @returns {Array} Returns the new duplicate free array. 16332 * @example 16333 * 16334 * _.uniq([2, 1, 2]); 16335 * // => [2, 1] 16336 */ 16337 function uniq(array) { 16338 return (array && array.length) ? baseUniq(array) : []; 16339 } 16340 16341 /** 16342 * This method is like `_.uniq` except that it accepts `iteratee` which is 16343 * invoked for each element in `array` to generate the criterion by which 16344 * uniqueness is computed. The order of result values is determined by the 16345 * order they occur in the array. The iteratee is invoked with one argument: 16346 * (value). 16347 * 16348 * @static 16349 * @memberOf _ 16350 * @since 4.0.0 16351 * @category Array 16352 * @param {Array} array The array to inspect. 16353 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 16354 * @returns {Array} Returns the new duplicate free array. 16355 * @example 16356 * 16357 * _.uniqBy([2.1, 1.2, 2.3], Math.floor); 16358 * // => [2.1, 1.2] 16359 * 16360 * // The `_.property` iteratee shorthand. 16361 * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); 16362 * // => [{ 'x': 1 }, { 'x': 2 }] 16363 */ 16364 function uniqBy(array, iteratee) { 16365 return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : []; 16366 } 16367 16368 /** 16369 * This method is like `_.uniq` except that it accepts `comparator` which 16370 * is invoked to compare elements of `array`. The order of result values is 16371 * determined by the order they occur in the array.The comparator is invoked 16372 * with two arguments: (arrVal, othVal). 16373 * 16374 * @static 16375 * @memberOf _ 16376 * @since 4.0.0 16377 * @category Array 16378 * @param {Array} array The array to inspect. 16379 * @param {Function} [comparator] The comparator invoked per element. 16380 * @returns {Array} Returns the new duplicate free array. 16381 * @example 16382 * 16383 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; 16384 * 16385 * _.uniqWith(objects, _.isEqual); 16386 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] 16387 */ 16388 function uniqWith(array, comparator) { 16389 comparator = typeof comparator == 'function' ? comparator : undefined; 16390 return (array && array.length) ? baseUniq(array, undefined, comparator) : []; 16391 } 16392 16393 /** 16394 * This method is like `_.zip` except that it accepts an array of grouped 16395 * elements and creates an array regrouping the elements to their pre-zip 16396 * configuration. 16397 * 16398 * @static 16399 * @memberOf _ 16400 * @since 1.2.0 16401 * @category Array 16402 * @param {Array} array The array of grouped elements to process. 16403 * @returns {Array} Returns the new array of regrouped elements. 16404 * @example 16405 * 16406 * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]); 16407 * // => [['a', 1, true], ['b', 2, false]] 16408 * 16409 * _.unzip(zipped); 16410 * // => [['a', 'b'], [1, 2], [true, false]] 16411 */ 16412 function unzip(array) { 16413 if (!(array && array.length)) { 16414 return []; 16415 } 16416 var length = 0; 16417 array = arrayFilter(array, function(group) { 16418 if (isArrayLikeObject(group)) { 16419 length = nativeMax(group.length, length); 16420 return true; 16421 } 16422 }); 16423 return baseTimes(length, function(index) { 16424 return arrayMap(array, baseProperty(index)); 16425 }); 16426 } 16427 16428 /** 16429 * This method is like `_.unzip` except that it accepts `iteratee` to specify 16430 * how regrouped values should be combined. The iteratee is invoked with the 16431 * elements of each group: (...group). 16432 * 16433 * @static 16434 * @memberOf _ 16435 * @since 3.8.0 16436 * @category Array 16437 * @param {Array} array The array of grouped elements to process. 16438 * @param {Function} [iteratee=_.identity] The function to combine 16439 * regrouped values. 16440 * @returns {Array} Returns the new array of regrouped elements. 16441 * @example 16442 * 16443 * var zipped = _.zip([1, 2], [10, 20], [100, 200]); 16444 * // => [[1, 10, 100], [2, 20, 200]] 16445 * 16446 * _.unzipWith(zipped, _.add); 16447 * // => [3, 30, 300] 16448 */ 16449 function unzipWith(array, iteratee) { 16450 if (!(array && array.length)) { 16451 return []; 16452 } 16453 var result = unzip(array); 16454 if (iteratee == null) { 16455 return result; 16456 } 16457 return arrayMap(result, function(group) { 16458 return apply(iteratee, undefined, group); 16459 }); 16460 } 16461 16462 /** 16463 * Creates an array excluding all given values using 16464 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 16465 * for equality comparisons. 16466 * 16467 * **Note:** Unlike `_.pull`, this method returns a new array. 16468 * 16469 * @static 16470 * @memberOf _ 16471 * @since 0.1.0 16472 * @category Array 16473 * @param {Array} array The array to inspect. 16474 * @param {...*} [values] The values to exclude. 16475 * @returns {Array} Returns the new array of filtered values. 16476 * @see _.difference, _.xor 16477 * @example 16478 * 16479 * _.without([2, 1, 2, 3], 1, 2); 16480 * // => [3] 16481 */ 16482 var without = baseRest(function(array, values) { 16483 return isArrayLikeObject(array) 16484 ? baseDifference(array, values) 16485 : []; 16486 }); 16487 16488 /** 16489 * Creates an array of unique values that is the 16490 * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) 16491 * of the given arrays. The order of result values is determined by the order 16492 * they occur in the arrays. 16493 * 16494 * @static 16495 * @memberOf _ 16496 * @since 2.4.0 16497 * @category Array 16498 * @param {...Array} [arrays] The arrays to inspect. 16499 * @returns {Array} Returns the new array of filtered values. 16500 * @see _.difference, _.without 16501 * @example 16502 * 16503 * _.xor([2, 1], [2, 3]); 16504 * // => [1, 3] 16505 */ 16506 var xor = baseRest(function(arrays) { 16507 return baseXor(arrayFilter(arrays, isArrayLikeObject)); 16508 }); 16509 16510 /** 16511 * This method is like `_.xor` except that it accepts `iteratee` which is 16512 * invoked for each element of each `arrays` to generate the criterion by 16513 * which by which they're compared. The order of result values is determined 16514 * by the order they occur in the arrays. The iteratee is invoked with one 16515 * argument: (value). 16516 * 16517 * @static 16518 * @memberOf _ 16519 * @since 4.0.0 16520 * @category Array 16521 * @param {...Array} [arrays] The arrays to inspect. 16522 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 16523 * @returns {Array} Returns the new array of filtered values. 16524 * @example 16525 * 16526 * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); 16527 * // => [1.2, 3.4] 16528 * 16529 * // The `_.property` iteratee shorthand. 16530 * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 16531 * // => [{ 'x': 2 }] 16532 */ 16533 var xorBy = baseRest(function(arrays) { 16534 var iteratee = last(arrays); 16535 if (isArrayLikeObject(iteratee)) { 16536 iteratee = undefined; 16537 } 16538 return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2)); 16539 }); 16540 16541 /** 16542 * This method is like `_.xor` except that it accepts `comparator` which is 16543 * invoked to compare elements of `arrays`. The order of result values is 16544 * determined by the order they occur in the arrays. The comparator is invoked 16545 * with two arguments: (arrVal, othVal). 16546 * 16547 * @static 16548 * @memberOf _ 16549 * @since 4.0.0 16550 * @category Array 16551 * @param {...Array} [arrays] The arrays to inspect. 16552 * @param {Function} [comparator] The comparator invoked per element. 16553 * @returns {Array} Returns the new array of filtered values. 16554 * @example 16555 * 16556 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 16557 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 16558 * 16559 * _.xorWith(objects, others, _.isEqual); 16560 * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 16561 */ 16562 var xorWith = baseRest(function(arrays) { 16563 var comparator = last(arrays); 16564 comparator = typeof comparator == 'function' ? comparator : undefined; 16565 return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator); 16566 }); 16567 16568 /** 16569 * Creates an array of grouped elements, the first of which contains the 16570 * first elements of the given arrays, the second of which contains the 16571 * second elements of the given arrays, and so on. 16572 * 16573 * @static 16574 * @memberOf _ 16575 * @since 0.1.0 16576 * @category Array 16577 * @param {...Array} [arrays] The arrays to process. 16578 * @returns {Array} Returns the new array of grouped elements. 16579 * @example 16580 * 16581 * _.zip(['a', 'b'], [1, 2], [true, false]); 16582 * // => [['a', 1, true], ['b', 2, false]] 16583 */ 16584 var zip = baseRest(unzip); 16585 16586 /** 16587 * This method is like `_.fromPairs` except that it accepts two arrays, 16588 * one of property identifiers and one of corresponding values. 16589 * 16590 * @static 16591 * @memberOf _ 16592 * @since 0.4.0 16593 * @category Array 16594 * @param {Array} [props=[]] The property identifiers. 16595 * @param {Array} [values=[]] The property values. 16596 * @returns {Object} Returns the new object. 16597 * @example 16598 * 16599 * _.zipObject(['a', 'b'], [1, 2]); 16600 * // => { 'a': 1, 'b': 2 } 16601 */ 16602 function zipObject(props, values) { 16603 return baseZipObject(props || [], values || [], assignValue); 16604 } 16605 16606 /** 16607 * This method is like `_.zipObject` except that it supports property paths. 16608 * 16609 * @static 16610 * @memberOf _ 16611 * @since 4.1.0 16612 * @category Array 16613 * @param {Array} [props=[]] The property identifiers. 16614 * @param {Array} [values=[]] The property values. 16615 * @returns {Object} Returns the new object. 16616 * @example 16617 * 16618 * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]); 16619 * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } 16620 */ 16621 function zipObjectDeep(props, values) { 16622 return baseZipObject(props || [], values || [], baseSet); 16623 } 16624 16625 /** 16626 * This method is like `_.zip` except that it accepts `iteratee` to specify 16627 * how grouped values should be combined. The iteratee is invoked with the 16628 * elements of each group: (...group). 16629 * 16630 * @static 16631 * @memberOf _ 16632 * @since 3.8.0 16633 * @category Array 16634 * @param {...Array} [arrays] The arrays to process. 16635 * @param {Function} [iteratee=_.identity] The function to combine 16636 * grouped values. 16637 * @returns {Array} Returns the new array of grouped elements. 16638 * @example 16639 * 16640 * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { 16641 * return a + b + c; 16642 * }); 16643 * // => [111, 222] 16644 */ 16645 var zipWith = baseRest(function(arrays) { 16646 var length = arrays.length, 16647 iteratee = length > 1 ? arrays[length - 1] : undefined; 16648 16649 iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined; 16650 return unzipWith(arrays, iteratee); 16651 }); 16652 16653 /*------------------------------------------------------------------------*/ 16654 16655 /** 16656 * Creates a `lodash` wrapper instance that wraps `value` with explicit method 16657 * chain sequences enabled. The result of such sequences must be unwrapped 16658 * with `_#value`. 16659 * 16660 * @static 16661 * @memberOf _ 16662 * @since 1.3.0 16663 * @category Seq 16664 * @param {*} value The value to wrap. 16665 * @returns {Object} Returns the new `lodash` wrapper instance. 16666 * @example 16667 * 16668 * var users = [ 16669 * { 'user': 'barney', 'age': 36 }, 16670 * { 'user': 'fred', 'age': 40 }, 16671 * { 'user': 'pebbles', 'age': 1 } 16672 * ]; 16673 * 16674 * var youngest = _ 16675 * .chain(users) 16676 * .sortBy('age') 16677 * .map(function(o) { 16678 * return o.user + ' is ' + o.age; 16679 * }) 16680 * .head() 16681 * .value(); 16682 * // => 'pebbles is 1' 16683 */ 16684 function chain(value) { 16685 var result = lodash(value); 16686 result.__chain__ = true; 16687 return result; 16688 } 16689 16690 /** 16691 * This method invokes `interceptor` and returns `value`. The interceptor 16692 * is invoked with one argument; (value). The purpose of this method is to 16693 * "tap into" a method chain sequence in order to modify intermediate results. 16694 * 16695 * @static 16696 * @memberOf _ 16697 * @since 0.1.0 16698 * @category Seq 16699 * @param {*} value The value to provide to `interceptor`. 16700 * @param {Function} interceptor The function to invoke. 16701 * @returns {*} Returns `value`. 16702 * @example 16703 * 16704 * _([1, 2, 3]) 16705 * .tap(function(array) { 16706 * // Mutate input array. 16707 * array.pop(); 16708 * }) 16709 * .reverse() 16710 * .value(); 16711 * // => [2, 1] 16712 */ 16713 function tap(value, interceptor) { 16714 interceptor(value); 16715 return value; 16716 } 16717 16718 /** 16719 * This method is like `_.tap` except that it returns the result of `interceptor`. 16720 * The purpose of this method is to "pass thru" values replacing intermediate 16721 * results in a method chain sequence. 16722 * 16723 * @static 16724 * @memberOf _ 16725 * @since 3.0.0 16726 * @category Seq 16727 * @param {*} value The value to provide to `interceptor`. 16728 * @param {Function} interceptor The function to invoke. 16729 * @returns {*} Returns the result of `interceptor`. 16730 * @example 16731 * 16732 * _(' abc ') 16733 * .chain() 16734 * .trim() 16735 * .thru(function(value) { 16736 * return [value]; 16737 * }) 16738 * .value(); 16739 * // => ['abc'] 16740 */ 16741 function thru(value, interceptor) { 16742 return interceptor(value); 16743 } 16744 16745 /** 16746 * This method is the wrapper version of `_.at`. 16747 * 16748 * @name at 16749 * @memberOf _ 16750 * @since 1.0.0 16751 * @category Seq 16752 * @param {...(string|string[])} [paths] The property paths to pick. 16753 * @returns {Object} Returns the new `lodash` wrapper instance. 16754 * @example 16755 * 16756 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 16757 * 16758 * _(object).at(['a[0].b.c', 'a[1]']).value(); 16759 * // => [3, 4] 16760 */ 16761 var wrapperAt = flatRest(function(paths) { 16762 var length = paths.length, 16763 start = length ? paths[0] : 0, 16764 value = this.__wrapped__, 16765 interceptor = function(object) { return baseAt(object, paths); }; 16766 16767 if (length > 1 || this.__actions__.length || 16768 !(value instanceof LazyWrapper) || !isIndex(start)) { 16769 return this.thru(interceptor); 16770 } 16771 value = value.slice(start, +start + (length ? 1 : 0)); 16772 value.__actions__.push({ 16773 'func': thru, 16774 'args': [interceptor], 16775 'thisArg': undefined 16776 }); 16777 return new LodashWrapper(value, this.__chain__).thru(function(array) { 16778 if (length && !array.length) { 16779 array.push(undefined); 16780 } 16781 return array; 16782 }); 16783 }); 16784 16785 /** 16786 * Creates a `lodash` wrapper instance with explicit method chain sequences enabled. 16787 * 16788 * @name chain 16789 * @memberOf _ 16790 * @since 0.1.0 16791 * @category Seq 16792 * @returns {Object} Returns the new `lodash` wrapper instance. 16793 * @example 16794 * 16795 * var users = [ 16796 * { 'user': 'barney', 'age': 36 }, 16797 * { 'user': 'fred', 'age': 40 } 16798 * ]; 16799 * 16800 * // A sequence without explicit chaining. 16801 * _(users).head(); 16802 * // => { 'user': 'barney', 'age': 36 } 16803 * 16804 * // A sequence with explicit chaining. 16805 * _(users) 16806 * .chain() 16807 * .head() 16808 * .pick('user') 16809 * .value(); 16810 * // => { 'user': 'barney' } 16811 */ 16812 function wrapperChain() { 16813 return chain(this); 16814 } 16815 16816 /** 16817 * Executes the chain sequence and returns the wrapped result. 16818 * 16819 * @name commit 16820 * @memberOf _ 16821 * @since 3.2.0 16822 * @category Seq 16823 * @returns {Object} Returns the new `lodash` wrapper instance. 16824 * @example 16825 * 16826 * var array = [1, 2]; 16827 * var wrapped = _(array).push(3); 16828 * 16829 * console.log(array); 16830 * // => [1, 2] 16831 * 16832 * wrapped = wrapped.commit(); 16833 * console.log(array); 16834 * // => [1, 2, 3] 16835 * 16836 * wrapped.last(); 16837 * // => 3 16838 * 16839 * console.log(array); 16840 * // => [1, 2, 3] 16841 */ 16842 function wrapperCommit() { 16843 return new LodashWrapper(this.value(), this.__chain__); 16844 } 16845 16846 /** 16847 * Gets the next value on a wrapped object following the 16848 * [iterator protocol](https://mdn.io/iteration_protocols#iterator). 16849 * 16850 * @name next 16851 * @memberOf _ 16852 * @since 4.0.0 16853 * @category Seq 16854 * @returns {Object} Returns the next iterator value. 16855 * @example 16856 * 16857 * var wrapped = _([1, 2]); 16858 * 16859 * wrapped.next(); 16860 * // => { 'done': false, 'value': 1 } 16861 * 16862 * wrapped.next(); 16863 * // => { 'done': false, 'value': 2 } 16864 * 16865 * wrapped.next(); 16866 * // => { 'done': true, 'value': undefined } 16867 */ 16868 function wrapperNext() { 16869 if (this.__values__ === undefined) { 16870 this.__values__ = toArray(this.value()); 16871 } 16872 var done = this.__index__ >= this.__values__.length, 16873 value = done ? undefined : this.__values__[this.__index__++]; 16874 16875 return { 'done': done, 'value': value }; 16876 } 16877 16878 /** 16879 * Enables the wrapper to be iterable. 16880 * 16881 * @name Symbol.iterator 16882 * @memberOf _ 16883 * @since 4.0.0 16884 * @category Seq 16885 * @returns {Object} Returns the wrapper object. 16886 * @example 16887 * 16888 * var wrapped = _([1, 2]); 16889 * 16890 * wrapped[Symbol.iterator]() === wrapped; 16891 * // => true 16892 * 16893 * Array.from(wrapped); 16894 * // => [1, 2] 16895 */ 16896 function wrapperToIterator() { 16897 return this; 16898 } 16899 16900 /** 16901 * Creates a clone of the chain sequence planting `value` as the wrapped value. 16902 * 16903 * @name plant 16904 * @memberOf _ 16905 * @since 3.2.0 16906 * @category Seq 16907 * @param {*} value The value to plant. 16908 * @returns {Object} Returns the new `lodash` wrapper instance. 16909 * @example 16910 * 16911 * function square(n) { 16912 * return n * n; 16913 * } 16914 * 16915 * var wrapped = _([1, 2]).map(square); 16916 * var other = wrapped.plant([3, 4]); 16917 * 16918 * other.value(); 16919 * // => [9, 16] 16920 * 16921 * wrapped.value(); 16922 * // => [1, 4] 16923 */ 16924 function wrapperPlant(value) { 16925 var result, 16926 parent = this; 16927 16928 while (parent instanceof baseLodash) { 16929 var clone = wrapperClone(parent); 16930 clone.__index__ = 0; 16931 clone.__values__ = undefined; 16932 if (result) { 16933 previous.__wrapped__ = clone; 16934 } else { 16935 result = clone; 16936 } 16937 var previous = clone; 16938 parent = parent.__wrapped__; 16939 } 16940 previous.__wrapped__ = value; 16941 return result; 16942 } 16943 16944 /** 16945 * This method is the wrapper version of `_.reverse`. 16946 * 16947 * **Note:** This method mutates the wrapped array. 16948 * 16949 * @name reverse 16950 * @memberOf _ 16951 * @since 0.1.0 16952 * @category Seq 16953 * @returns {Object} Returns the new `lodash` wrapper instance. 16954 * @example 16955 * 16956 * var array = [1, 2, 3]; 16957 * 16958 * _(array).reverse().value() 16959 * // => [3, 2, 1] 16960 * 16961 * console.log(array); 16962 * // => [3, 2, 1] 16963 */ 16964 function wrapperReverse() { 16965 var value = this.__wrapped__; 16966 if (value instanceof LazyWrapper) { 16967 var wrapped = value; 16968 if (this.__actions__.length) { 16969 wrapped = new LazyWrapper(this); 16970 } 16971 wrapped = wrapped.reverse(); 16972 wrapped.__actions__.push({ 16973 'func': thru, 16974 'args': [reverse], 16975 'thisArg': undefined 16976 }); 16977 return new LodashWrapper(wrapped, this.__chain__); 16978 } 16979 return this.thru(reverse); 16980 } 16981 16982 /** 16983 * Executes the chain sequence to resolve the unwrapped value. 16984 * 16985 * @name value 16986 * @memberOf _ 16987 * @since 0.1.0 16988 * @alias toJSON, valueOf 16989 * @category Seq 16990 * @returns {*} Returns the resolved unwrapped value. 16991 * @example 16992 * 16993 * _([1, 2, 3]).value(); 16994 * // => [1, 2, 3] 16995 */ 16996 function wrapperValue() { 16997 return baseWrapperValue(this.__wrapped__, this.__actions__); 16998 } 16999 17000 /*------------------------------------------------------------------------*/ 17001 17002 /**
vendor: 6,915 bytes, lines 17003-17193
17003 * Creates an object composed of keys generated from the results of running 17004 * each element of `collection` thru `iteratee`. The corresponding value of 17005 * each key is the number of times the key was returned by `iteratee`. The 17006 * iteratee is invoked with one argument: (value). 17007 * 17008 * @static 17009 * @memberOf _ 17010 * @since 0.5.0 17011 * @category Collection 17012 * @param {Array|Object} collection The collection to iterate over. 17013 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 17014 * @returns {Object} Returns the composed aggregate object. 17015 * @example 17016 * 17017 * _.countBy([6.1, 4.2, 6.3], Math.floor); 17018 * // => { '4': 1, '6': 2 } 17019 * 17020 * // The `_.property` iteratee shorthand. 17021 * _.countBy(['one', 'two', 'three'], 'length'); 17022 * // => { '3': 2, '5': 1 } 17023 */ 17024 var countBy = createAggregator(function(result, value, key) { 17025 if (hasOwnProperty.call(result, key)) { 17026 ++result[key]; 17027 } else { 17028 baseAssignValue(result, key, 1); 17029 } 17030 }); 17031 17032 /** 17033 * Checks if `predicate` returns truthy for **all** elements of `collection`. 17034 * Iteration is stopped once `predicate` returns falsey. The predicate is 17035 * invoked with three arguments: (value, index|key, collection). 17036 * 17037 * **Note:** This method returns `true` for 17038 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because 17039 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of 17040 * elements of empty collections. 17041 * 17042 * @static 17043 * @memberOf _ 17044 * @since 0.1.0 17045 * @category Collection 17046 * @param {Array|Object} collection The collection to iterate over. 17047 * @param {Function} [predicate=_.identity] The function invoked per iteration. 17048 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 17049 * @returns {boolean} Returns `true` if all elements pass the predicate check, 17050 * else `false`. 17051 * @example 17052 * 17053 * _.every([true, 1, null, 'yes'], Boolean); 17054 * // => false 17055 * 17056 * var users = [ 17057 * { 'user': 'barney', 'age': 36, 'active': false }, 17058 * { 'user': 'fred', 'age': 40, 'active': false } 17059 * ]; 17060 * 17061 * // The `_.matches` iteratee shorthand. 17062 * _.every(users, { 'user': 'barney', 'active': false }); 17063 * // => false 17064 * 17065 * // The `_.matchesProperty` iteratee shorthand. 17066 * _.every(users, ['active', false]); 17067 * // => true 17068 * 17069 * // The `_.property` iteratee shorthand. 17070 * _.every(users, 'active'); 17071 * // => false 17072 */ 17073 function every(collection, predicate, guard) { 17074 var func = isArray(collection) ? arrayEvery : baseEvery; 17075 if (guard && isIterateeCall(collection, predicate, guard)) { 17076 predicate = undefined; 17077 } 17078 return func(collection, getIteratee(predicate, 3)); 17079 } 17080 17081 /** 17082 * Iterates over elements of `collection`, returning an array of all elements 17083 * `predicate` returns truthy for. The predicate is invoked with three 17084 * arguments: (value, index|key, collection). 17085 * 17086 * **Note:** Unlike `_.remove`, this method returns a new array. 17087 * 17088 * @static 17089 * @memberOf _ 17090 * @since 0.1.0 17091 * @category Collection 17092 * @param {Array|Object} collection The collection to iterate over. 17093 * @param {Function} [predicate=_.identity] The function invoked per iteration. 17094 * @returns {Array} Returns the new filtered array. 17095 * @see _.reject 17096 * @example 17097 * 17098 * var users = [ 17099 * { 'user': 'barney', 'age': 36, 'active': true }, 17100 * { 'user': 'fred', 'age': 40, 'active': false } 17101 * ]; 17102 * 17103 * _.filter(users, function(o) { return !o.active; }); 17104 * // => objects for ['fred'] 17105 * 17106 * // The `_.matches` iteratee shorthand. 17107 * _.filter(users, { 'age': 36, 'active': true }); 17108 * // => objects for ['barney'] 17109 * 17110 * // The `_.matchesProperty` iteratee shorthand. 17111 * _.filter(users, ['active', false]); 17112 * // => objects for ['fred'] 17113 * 17114 * // The `_.property` iteratee shorthand. 17115 * _.filter(users, 'active'); 17116 * // => objects for ['barney'] 17117 */ 17118 function filter(collection, predicate) { 17119 var func = isArray(collection) ? arrayFilter : baseFilter; 17120 return func(collection, getIteratee(predicate, 3)); 17121 } 17122 17123 /** 17124 * Iterates over elements of `collection`, returning the first element 17125 * `predicate` returns truthy for. The predicate is invoked with three 17126 * arguments: (value, index|key, collection). 17127 * 17128 * @static 17129 * @memberOf _ 17130 * @since 0.1.0 17131 * @category Collection 17132 * @param {Array|Object} collection The collection to inspect. 17133 * @param {Function} [predicate=_.identity] The function invoked per iteration. 17134 * @param {number} [fromIndex=0] The index to search from. 17135 * @returns {*} Returns the matched element, else `undefined`. 17136 * @example 17137 * 17138 * var users = [ 17139 * { 'user': 'barney', 'age': 36, 'active': true }, 17140 * { 'user': 'fred', 'age': 40, 'active': false }, 17141 * { 'user': 'pebbles', 'age': 1, 'active': true } 17142 * ]; 17143 * 17144 * _.find(users, function(o) { return o.age < 40; }); 17145 * // => object for 'barney' 17146 * 17147 * // The `_.matches` iteratee shorthand. 17148 * _.find(users, { 'age': 1, 'active': true }); 17149 * // => object for 'pebbles' 17150 * 17151 * // The `_.matchesProperty` iteratee shorthand. 17152 * _.find(users, ['active', false]); 17153 * // => object for 'fred' 17154 * 17155 * // The `_.property` iteratee shorthand. 17156 * _.find(users, 'active'); 17157 * // => object for 'barney' 17158 */ 17159 var find = createFind(findIndex); 17160 17161 /** 17162 * This method is like `_.find` except that it iterates over elements of 17163 * `collection` from right to left. 17164 * 17165 * @static 17166 * @memberOf _ 17167 * @since 2.0.0 17168 * @category Collection 17169 * @param {Array|Object} collection The collection to inspect. 17170 * @param {Function} [predicate=_.identity] The function invoked per iteration. 17171 * @param {number} [fromIndex=collection.length-1] The index to search from. 17172 * @returns {*} Returns the matched element, else `undefined`. 17173 * @example 17174 * 17175 * _.findLast([1, 2, 3, 4], function(n) { 17176 * return n % 2 == 1; 17177 * }); 17178 * // => 3 17179 */ 17180 var findLast = createFind(findLastIndex); 17181 17182 /** 17183 * Creates a flattened array of values by running each element in `collection` 17184 * thru `iteratee` and flattening the mapped results. The iteratee is invoked 17185 * with three arguments: (value, index|key, collection). 17186 * 17187 * @static 17188 * @memberOf _ 17189 * @since 4.0.0 17190 * @category Collection 17191 * @param {Array|Object} collection The collection to iterate over. 17192 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 17193 * @returns {Array} Returns the new flattened array.
vendor: 3,950 bytes, lines 17194-17317
17194 * @example 17195 * 17196 * function duplicate(n) { 17197 * return [n, n]; 17198 * } 17199 * 17200 * _.flatMap([1, 2], duplicate); 17201 * // => [1, 1, 2, 2] 17202 */ 17203 function flatMap(collection, iteratee) { 17204 return baseFlatten(map(collection, iteratee), 1); 17205 } 17206 17207 /** 17208 * This method is like `_.flatMap` except that it recursively flattens the 17209 * mapped results. 17210 * 17211 * @static 17212 * @memberOf _ 17213 * @since 4.7.0 17214 * @category Collection 17215 * @param {Array|Object} collection The collection to iterate over. 17216 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 17217 * @returns {Array} Returns the new flattened array. 17218 * @example 17219 * 17220 * function duplicate(n) { 17221 * return [[[n, n]]]; 17222 * } 17223 * 17224 * _.flatMapDeep([1, 2], duplicate); 17225 * // => [1, 1, 2, 2] 17226 */ 17227 function flatMapDeep(collection, iteratee) { 17228 return baseFlatten(map(collection, iteratee), INFINITY); 17229 } 17230 17231 /** 17232 * This method is like `_.flatMap` except that it recursively flattens the 17233 * mapped results up to `depth` times. 17234 * 17235 * @static 17236 * @memberOf _ 17237 * @since 4.7.0 17238 * @category Collection 17239 * @param {Array|Object} collection The collection to iterate over. 17240 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 17241 * @param {number} [depth=1] The maximum recursion depth. 17242 * @returns {Array} Returns the new flattened array. 17243 * @example 17244 * 17245 * function duplicate(n) { 17246 * return [[[n, n]]]; 17247 * } 17248 * 17249 * _.flatMapDepth([1, 2], duplicate, 2); 17250 * // => [[1, 1], [2, 2]] 17251 */ 17252 function flatMapDepth(collection, iteratee, depth) { 17253 depth = depth === undefined ? 1 : toInteger(depth); 17254 return baseFlatten(map(collection, iteratee), depth); 17255 } 17256 17257 /** 17258 * Iterates over elements of `collection` and invokes `iteratee` for each element. 17259 * The iteratee is invoked with three arguments: (value, index|key, collection). 17260 * Iteratee functions may exit iteration early by explicitly returning `false`. 17261 * 17262 * **Note:** As with other "Collections" methods, objects with a "length" 17263 * property are iterated like arrays. To avoid this behavior use `_.forIn` 17264 * or `_.forOwn` for object iteration. 17265 * 17266 * @static 17267 * @memberOf _ 17268 * @since 0.1.0 17269 * @alias each 17270 * @category Collection 17271 * @param {Array|Object} collection The collection to iterate over. 17272 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 17273 * @returns {Array|Object} Returns `collection`. 17274 * @see _.forEachRight 17275 * @example 17276 * 17277 * _.forEach([1, 2], function(value) { 17278 * console.log(value); 17279 * }); 17280 * // => Logs `1` then `2`. 17281 * 17282 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { 17283 * console.log(key); 17284 * }); 17285 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 17286 */ 17287 function forEach(collection, iteratee) { 17288 var func = isArray(collection) ? arrayEach : baseEach; 17289 return func(collection, getIteratee(iteratee, 3)); 17290 } 17291 17292 /** 17293 * This method is like `_.forEach` except that it iterates over elements of 17294 * `collection` from right to left. 17295 * 17296 * @static 17297 * @memberOf _ 17298 * @since 2.0.0 17299 * @alias eachRight 17300 * @category Collection 17301 * @param {Array|Object} collection The collection to iterate over. 17302 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 17303 * @returns {Array|Object} Returns `collection`. 17304 * @see _.forEach 17305 * @example 17306 * 17307 * _.forEachRight([1, 2], function(value) { 17308 * console.log(value); 17309 * }); 17310 * // => Logs `2` then `1`. 17311 */ 17312 function forEachRight(collection, iteratee) { 17313 var func = isArray(collection) ? arrayEachRight : baseEachRight; 17314 return func(collection, getIteratee(iteratee, 3)); 17315 } 17316 17317 /**
vendor: 4,136 bytes, lines 17318-17425
17318 * Creates an object composed of keys generated from the results of running 17319 * each element of `collection` thru `iteratee`. The order of grouped values 17320 * is determined by the order they occur in `collection`. The corresponding 17321 * value of each key is an array of elements responsible for generating the 17322 * key. The iteratee is invoked with one argument: (value). 17323 * 17324 * @static 17325 * @memberOf _ 17326 * @since 0.1.0 17327 * @category Collection 17328 * @param {Array|Object} collection The collection to iterate over. 17329 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 17330 * @returns {Object} Returns the composed aggregate object. 17331 * @example 17332 * 17333 * _.groupBy([6.1, 4.2, 6.3], Math.floor); 17334 * // => { '4': [4.2], '6': [6.1, 6.3] } 17335 * 17336 * // The `_.property` iteratee shorthand. 17337 * _.groupBy(['one', 'two', 'three'], 'length'); 17338 * // => { '3': ['one', 'two'], '5': ['three'] } 17339 */ 17340 var groupBy = createAggregator(function(result, value, key) { 17341 if (hasOwnProperty.call(result, key)) { 17342 result[key].push(value); 17343 } else { 17344 baseAssignValue(result, key, [value]); 17345 } 17346 }); 17347 17348 /** 17349 * Checks if `value` is in `collection`. If `collection` is a string, it's 17350 * checked for a substring of `value`, otherwise 17351 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 17352 * is used for equality comparisons. If `fromIndex` is negative, it's used as 17353 * the offset from the end of `collection`. 17354 * 17355 * @static 17356 * @memberOf _ 17357 * @since 0.1.0 17358 * @category Collection 17359 * @param {Array|Object|string} collection The collection to inspect. 17360 * @param {*} value The value to search for. 17361 * @param {number} [fromIndex=0] The index to search from. 17362 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 17363 * @returns {boolean} Returns `true` if `value` is found, else `false`. 17364 * @example 17365 * 17366 * _.includes([1, 2, 3], 1); 17367 * // => true 17368 * 17369 * _.includes([1, 2, 3], 1, 2); 17370 * // => false 17371 * 17372 * _.includes({ 'a': 1, 'b': 2 }, 1); 17373 * // => true 17374 * 17375 * _.includes('abcd', 'bc'); 17376 * // => true 17377 */ 17378 function includes(collection, value, fromIndex, guard) { 17379 collection = isArrayLike(collection) ? collection : values(collection); 17380 fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0; 17381 17382 var length = collection.length; 17383 if (fromIndex < 0) { 17384 fromIndex = nativeMax(length + fromIndex, 0); 17385 } 17386 return isString(collection) 17387 ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1) 17388 : (!!length && baseIndexOf(collection, value, fromIndex) > -1); 17389 } 17390 17391 /** 17392 * Invokes the method at `path` of each element in `collection`, returning 17393 * an array of the results of each invoked method. Any additional arguments 17394 * are provided to each invoked method. If `path` is a function, it's invoked 17395 * for, and `this` bound to, each element in `collection`. 17396 * 17397 * @static 17398 * @memberOf _ 17399 * @since 4.0.0 17400 * @category Collection 17401 * @param {Array|Object} collection The collection to iterate over. 17402 * @param {Array|Function|string} path The path of the method to invoke or 17403 * the function invoked per iteration. 17404 * @param {...*} [args] The arguments to invoke each method with. 17405 * @returns {Array} Returns the array of results. 17406 * @example 17407 * 17408 * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); 17409 * // => [[1, 5, 7], [1, 2, 3]] 17410 * 17411 * _.invokeMap([123, 456], String.prototype.split, ''); 17412 * // => [['1', '2', '3'], ['4', '5', '6']] 17413 */ 17414 var invokeMap = baseRest(function(collection, path, args) { 17415 var index = -1, 17416 isFunc = typeof path == 'function', 17417 result = isArrayLike(collection) ? Array(collection.length) : []; 17418 17419 baseEach(collection, function(value) { 17420 result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args); 17421 }); 17422 return result; 17423 }); 17424 17425 /**
vendor: 15,265 bytes, lines 17426-17860
17426 * Creates an object composed of keys generated from the results of running 17427 * each element of `collection` thru `iteratee`. The corresponding value of 17428 * each key is the last element responsible for generating the key. The 17429 * iteratee is invoked with one argument: (value). 17430 * 17431 * @static 17432 * @memberOf _ 17433 * @since 4.0.0 17434 * @category Collection 17435 * @param {Array|Object} collection The collection to iterate over. 17436 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 17437 * @returns {Object} Returns the composed aggregate object. 17438 * @example 17439 * 17440 * var array = [ 17441 * { 'dir': 'left', 'code': 97 }, 17442 * { 'dir': 'right', 'code': 100 } 17443 * ]; 17444 * 17445 * _.keyBy(array, function(o) { 17446 * return String.fromCharCode(o.code); 17447 * }); 17448 * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } 17449 * 17450 * _.keyBy(array, 'dir'); 17451 * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } 17452 */ 17453 var keyBy = createAggregator(function(result, value, key) { 17454 baseAssignValue(result, key, value); 17455 }); 17456 17457 /** 17458 * Creates an array of values by running each element in `collection` thru 17459 * `iteratee`. The iteratee is invoked with three arguments: 17460 * (value, index|key, collection). 17461 * 17462 * Many lodash methods are guarded to work as iteratees for methods like 17463 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. 17464 * 17465 * The guarded methods are: 17466 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, 17467 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, 17468 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, 17469 * `template`, `trim`, `trimEnd`, `trimStart`, and `words` 17470 * 17471 * @static 17472 * @memberOf _ 17473 * @since 0.1.0 17474 * @category Collection 17475 * @param {Array|Object} collection The collection to iterate over. 17476 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 17477 * @returns {Array} Returns the new mapped array. 17478 * @example 17479 * 17480 * function square(n) { 17481 * return n * n; 17482 * } 17483 * 17484 * _.map([4, 8], square); 17485 * // => [16, 64] 17486 * 17487 * _.map({ 'a': 4, 'b': 8 }, square); 17488 * // => [16, 64] (iteration order is not guaranteed) 17489 * 17490 * var users = [ 17491 * { 'user': 'barney' }, 17492 * { 'user': 'fred' } 17493 * ]; 17494 * 17495 * // The `_.property` iteratee shorthand. 17496 * _.map(users, 'user'); 17497 * // => ['barney', 'fred'] 17498 */ 17499 function map(collection, iteratee) { 17500 var func = isArray(collection) ? arrayMap : baseMap; 17501 return func(collection, getIteratee(iteratee, 3)); 17502 } 17503 17504 /** 17505 * This method is like `_.sortBy` except that it allows specifying the sort 17506 * orders of the iteratees to sort by. If `orders` is unspecified, all values 17507 * are sorted in ascending order. Otherwise, specify an order of "desc" for 17508 * descending or "asc" for ascending sort order of corresponding values. 17509 * 17510 * @static 17511 * @memberOf _ 17512 * @since 4.0.0 17513 * @category Collection 17514 * @param {Array|Object} collection The collection to iterate over. 17515 * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]] 17516 * The iteratees to sort by. 17517 * @param {string[]} [orders] The sort orders of `iteratees`. 17518 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 17519 * @returns {Array} Returns the new sorted array. 17520 * @example 17521 * 17522 * var users = [ 17523 * { 'user': 'fred', 'age': 48 }, 17524 * { 'user': 'barney', 'age': 34 }, 17525 * { 'user': 'fred', 'age': 40 }, 17526 * { 'user': 'barney', 'age': 36 } 17527 * ]; 17528 * 17529 * // Sort by `user` in ascending order and by `age` in descending order. 17530 * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); 17531 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] 17532 */ 17533 function orderBy(collection, iteratees, orders, guard) { 17534 if (collection == null) { 17535 return []; 17536 } 17537 if (!isArray(iteratees)) { 17538 iteratees = iteratees == null ? [] : [iteratees]; 17539 } 17540 orders = guard ? undefined : orders; 17541 if (!isArray(orders)) { 17542 orders = orders == null ? [] : [orders]; 17543 } 17544 return baseOrderBy(collection, iteratees, orders); 17545 } 17546 17547 /** 17548 * Creates an array of elements split into two groups, the first of which 17549 * contains elements `predicate` returns truthy for, the second of which 17550 * contains elements `predicate` returns falsey for. The predicate is 17551 * invoked with one argument: (value). 17552 * 17553 * @static 17554 * @memberOf _ 17555 * @since 3.0.0 17556 * @category Collection 17557 * @param {Array|Object} collection The collection to iterate over. 17558 * @param {Function} [predicate=_.identity] The function invoked per iteration. 17559 * @returns {Array} Returns the array of grouped elements. 17560 * @example 17561 * 17562 * var users = [ 17563 * { 'user': 'barney', 'age': 36, 'active': false }, 17564 * { 'user': 'fred', 'age': 40, 'active': true }, 17565 * { 'user': 'pebbles', 'age': 1, 'active': false } 17566 * ]; 17567 * 17568 * _.partition(users, function(o) { return o.active; }); 17569 * // => objects for [['fred'], ['barney', 'pebbles']] 17570 * 17571 * // The `_.matches` iteratee shorthand. 17572 * _.partition(users, { 'age': 1, 'active': false }); 17573 * // => objects for [['pebbles'], ['barney', 'fred']] 17574 * 17575 * // The `_.matchesProperty` iteratee shorthand. 17576 * _.partition(users, ['active', false]); 17577 * // => objects for [['barney', 'pebbles'], ['fred']] 17578 * 17579 * // The `_.property` iteratee shorthand. 17580 * _.partition(users, 'active'); 17581 * // => objects for [['fred'], ['barney', 'pebbles']] 17582 */ 17583 var partition = createAggregator(function(result, value, key) { 17584 result[key ? 0 : 1].push(value); 17585 }, function() { return [[], []]; }); 17586 17587 /** 17588 * Reduces `collection` to a value which is the accumulated result of running 17589 * each element in `collection` thru `iteratee`, where each successive 17590 * invocation is supplied the return value of the previous. If `accumulator` 17591 * is not given, the first element of `collection` is used as the initial 17592 * value. The iteratee is invoked with four arguments: 17593 * (accumulator, value, index|key, collection). 17594 * 17595 * Many lodash methods are guarded to work as iteratees for methods like 17596 * `_.reduce`, `_.reduceRight`, and `_.transform`. 17597 * 17598 * The guarded methods are: 17599 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, 17600 * and `sortBy` 17601 * 17602 * @static 17603 * @memberOf _ 17604 * @since 0.1.0 17605 * @category Collection 17606 * @param {Array|Object} collection The collection to iterate over. 17607 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 17608 * @param {*} [accumulator] The initial value. 17609 * @returns {*} Returns the accumulated value. 17610 * @see _.reduceRight 17611 * @example 17612 * 17613 * _.reduce([1, 2], function(sum, n) { 17614 * return sum + n; 17615 * }, 0); 17616 * // => 3 17617 * 17618 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 17619 * (result[value] || (result[value] = [])).push(key); 17620 * return result; 17621 * }, {}); 17622 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) 17623 */ 17624 function reduce(collection, iteratee, accumulator) { 17625 var func = isArray(collection) ? arrayReduce : baseReduce, 17626 initAccum = arguments.length < 3; 17627 17628 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach); 17629 } 17630 17631 /** 17632 * This method is like `_.reduce` except that it iterates over elements of 17633 * `collection` from right to left. 17634 * 17635 * @static 17636 * @memberOf _ 17637 * @since 0.1.0 17638 * @category Collection 17639 * @param {Array|Object} collection The collection to iterate over. 17640 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 17641 * @param {*} [accumulator] The initial value. 17642 * @returns {*} Returns the accumulated value. 17643 * @see _.reduce 17644 * @example 17645 * 17646 * var array = [[0, 1], [2, 3], [4, 5]]; 17647 * 17648 * _.reduceRight(array, function(flattened, other) { 17649 * return flattened.concat(other); 17650 * }, []); 17651 * // => [4, 5, 2, 3, 0, 1] 17652 */ 17653 function reduceRight(collection, iteratee, accumulator) { 17654 var func = isArray(collection) ? arrayReduceRight : baseReduce, 17655 initAccum = arguments.length < 3; 17656 17657 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); 17658 } 17659 17660 /** 17661 * The opposite of `_.filter`; this method returns the elements of `collection` 17662 * that `predicate` does **not** return truthy for. 17663 * 17664 * @static 17665 * @memberOf _ 17666 * @since 0.1.0 17667 * @category Collection 17668 * @param {Array|Object} collection The collection to iterate over. 17669 * @param {Function} [predicate=_.identity] The function invoked per iteration. 17670 * @returns {Array} Returns the new filtered array. 17671 * @see _.filter 17672 * @example 17673 * 17674 * var users = [ 17675 * { 'user': 'barney', 'age': 36, 'active': false }, 17676 * { 'user': 'fred', 'age': 40, 'active': true } 17677 * ]; 17678 * 17679 * _.reject(users, function(o) { return !o.active; }); 17680 * // => objects for ['fred'] 17681 * 17682 * // The `_.matches` iteratee shorthand. 17683 * _.reject(users, { 'age': 40, 'active': true }); 17684 * // => objects for ['barney'] 17685 * 17686 * // The `_.matchesProperty` iteratee shorthand. 17687 * _.reject(users, ['active', false]); 17688 * // => objects for ['fred'] 17689 * 17690 * // The `_.property` iteratee shorthand. 17691 * _.reject(users, 'active'); 17692 * // => objects for ['barney'] 17693 */ 17694 function reject(collection, predicate) { 17695 var func = isArray(collection) ? arrayFilter : baseFilter; 17696 return func(collection, negate(getIteratee(predicate, 3))); 17697 } 17698 17699 /** 17700 * Gets a random element from `collection`. 17701 * 17702 * @static 17703 * @memberOf _ 17704 * @since 2.0.0 17705 * @category Collection 17706 * @param {Array|Object} collection The collection to sample. 17707 * @returns {*} Returns the random element. 17708 * @example 17709 * 17710 * _.sample([1, 2, 3, 4]); 17711 * // => 2 17712 */ 17713 function sample(collection) { 17714 var func = isArray(collection) ? arraySample : baseSample; 17715 return func(collection); 17716 } 17717 17718 /** 17719 * Gets `n` random elements at unique keys from `collection` up to the 17720 * size of `collection`. 17721 * 17722 * @static 17723 * @memberOf _ 17724 * @since 4.0.0 17725 * @category Collection 17726 * @param {Array|Object} collection The collection to sample. 17727 * @param {number} [n=1] The number of elements to sample. 17728 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 17729 * @returns {Array} Returns the random elements. 17730 * @example 17731 * 17732 * _.sampleSize([1, 2, 3], 2); 17733 * // => [3, 1] 17734 * 17735 * _.sampleSize([1, 2, 3], 4); 17736 * // => [2, 3, 1] 17737 */ 17738 function sampleSize(collection, n, guard) { 17739 if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) { 17740 n = 1; 17741 } else { 17742 n = toInteger(n); 17743 } 17744 var func = isArray(collection) ? arraySampleSize : baseSampleSize; 17745 return func(collection, n); 17746 } 17747 17748 /** 17749 * Creates an array of shuffled values, using a version of the 17750 * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). 17751 * 17752 * @static 17753 * @memberOf _ 17754 * @since 0.1.0 17755 * @category Collection 17756 * @param {Array|Object} collection The collection to shuffle. 17757 * @returns {Array} Returns the new shuffled array. 17758 * @example 17759 * 17760 * _.shuffle([1, 2, 3, 4]); 17761 * // => [4, 1, 3, 2] 17762 */ 17763 function shuffle(collection) { 17764 var func = isArray(collection) ? arrayShuffle : baseShuffle; 17765 return func(collection); 17766 } 17767 17768 /** 17769 * Gets the size of `collection` by returning its length for array-like 17770 * values or the number of own enumerable string keyed properties for objects. 17771 * 17772 * @static 17773 * @memberOf _ 17774 * @since 0.1.0 17775 * @category Collection 17776 * @param {Array|Object|string} collection The collection to inspect. 17777 * @returns {number} Returns the collection size. 17778 * @example 17779 * 17780 * _.size([1, 2, 3]); 17781 * // => 3 17782 * 17783 * _.size({ 'a': 1, 'b': 2 }); 17784 * // => 2 17785 * 17786 * _.size('pebbles'); 17787 * // => 7 17788 */ 17789 function size(collection) { 17790 if (collection == null) { 17791 return 0; 17792 } 17793 if (isArrayLike(collection)) { 17794 return isString(collection) ? stringSize(collection) : collection.length; 17795 } 17796 var tag = getTag(collection); 17797 if (tag == mapTag || tag == setTag) { 17798 return collection.size; 17799 } 17800 return baseKeys(collection).length; 17801 } 17802 17803 /** 17804 * Checks if `predicate` returns truthy for **any** element of `collection`. 17805 * Iteration is stopped once `predicate` returns truthy. The predicate is 17806 * invoked with three arguments: (value, index|key, collection). 17807 * 17808 * @static 17809 * @memberOf _ 17810 * @since 0.1.0 17811 * @category Collection 17812 * @param {Array|Object} collection The collection to iterate over. 17813 * @param {Function} [predicate=_.identity] The function invoked per iteration. 17814 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 17815 * @returns {boolean} Returns `true` if any element passes the predicate check, 17816 * else `false`. 17817 * @example 17818 * 17819 * _.some([null, 0, 'yes', false], Boolean); 17820 * // => true 17821 * 17822 * var users = [ 17823 * { 'user': 'barney', 'active': true }, 17824 * { 'user': 'fred', 'active': false } 17825 * ]; 17826 * 17827 * // The `_.matches` iteratee shorthand. 17828 * _.some(users, { 'user': 'barney', 'active': false }); 17829 * // => false 17830 * 17831 * // The `_.matchesProperty` iteratee shorthand. 17832 * _.some(users, ['active', false]); 17833 * // => true 17834 * 17835 * // The `_.property` iteratee shorthand. 17836 * _.some(users, 'active'); 17837 * // => true 17838 */ 17839 function some(collection, predicate, guard) { 17840 var func = isArray(collection) ? arraySome : baseSome; 17841 if (guard && isIterateeCall(collection, predicate, guard)) { 17842 predicate = undefined; 17843 } 17844 return func(collection, getIteratee(predicate, 3)); 17845 } 17846 17847 /** 17848 * Creates an array of elements, sorted in ascending order by the results of 17849 * running each element in a collection thru each iteratee. This method 17850 * performs a stable sort, that is, it preserves the original sort order of 17851 * equal elements. The iteratees are invoked with one argument: (value). 17852 * 17853 * @static 17854 * @memberOf _ 17855 * @since 0.1.0 17856 * @category Collection 17857 * @param {Array|Object} collection The collection to iterate over. 17858 * @param {...(Function|Function[])} [iteratees=[_.identity]] 17859 * The iteratees to sort by. 17860 * @returns {Array} Returns the new sorted array.
vendor: 6,758 bytes, lines 17861-18063
17861 * @example 17862 * 17863 * var users = [ 17864 * { 'user': 'fred', 'age': 48 }, 17865 * { 'user': 'barney', 'age': 36 }, 17866 * { 'user': 'fred', 'age': 40 }, 17867 * { 'user': 'barney', 'age': 34 } 17868 * ]; 17869 * 17870 * _.sortBy(users, [function(o) { return o.user; }]); 17871 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] 17872 * 17873 * _.sortBy(users, ['user', 'age']); 17874 * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]] 17875 */ 17876 var sortBy = baseRest(function(collection, iteratees) { 17877 if (collection == null) { 17878 return []; 17879 } 17880 var length = iteratees.length; 17881 if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { 17882 iteratees = []; 17883 } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { 17884 iteratees = [iteratees[0]]; 17885 } 17886 return baseOrderBy(collection, baseFlatten(iteratees, 1), []); 17887 }); 17888 17889 /*------------------------------------------------------------------------*/ 17890 17891 /** 17892 * Gets the timestamp of the number of milliseconds that have elapsed since 17893 * the Unix epoch (1 January 1970 00:00:00 UTC). 17894 * 17895 * @static 17896 * @memberOf _ 17897 * @since 2.4.0 17898 * @category Date 17899 * @returns {number} Returns the timestamp. 17900 * @example 17901 * 17902 * _.defer(function(stamp) { 17903 * console.log(_.now() - stamp); 17904 * }, _.now()); 17905 * // => Logs the number of milliseconds it took for the deferred invocation. 17906 */ 17907 var now = ctxNow || function() { 17908 return root.Date.now(); 17909 }; 17910 17911 /*------------------------------------------------------------------------*/ 17912 17913 /** 17914 * The opposite of `_.before`; this method creates a function that invokes 17915 * `func` once it's called `n` or more times. 17916 * 17917 * @static 17918 * @memberOf _ 17919 * @since 0.1.0 17920 * @category Function 17921 * @param {number} n The number of calls before `func` is invoked. 17922 * @param {Function} func The function to restrict. 17923 * @returns {Function} Returns the new restricted function. 17924 * @example 17925 * 17926 * var saves = ['profile', 'settings']; 17927 * 17928 * var done = _.after(saves.length, function() { 17929 * console.log('done saving!'); 17930 * }); 17931 * 17932 * _.forEach(saves, function(type) { 17933 * asyncSave({ 'type': type, 'complete': done }); 17934 * }); 17935 * // => Logs 'done saving!' after the two async saves have completed. 17936 */ 17937 function after(n, func) { 17938 if (typeof func != 'function') { 17939 throw new TypeError(FUNC_ERROR_TEXT); 17940 } 17941 n = toInteger(n); 17942 return function() { 17943 if (--n < 1) { 17944 return func.apply(this, arguments); 17945 } 17946 }; 17947 } 17948 17949 /** 17950 * Creates a function that invokes `func`, with up to `n` arguments, 17951 * ignoring any additional arguments. 17952 * 17953 * @static 17954 * @memberOf _ 17955 * @since 3.0.0 17956 * @category Function 17957 * @param {Function} func The function to cap arguments for. 17958 * @param {number} [n=func.length] The arity cap. 17959 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 17960 * @returns {Function} Returns the new capped function. 17961 * @example 17962 * 17963 * _.map(['6', '8', '10'], _.ary(parseInt, 1)); 17964 * // => [6, 8, 10] 17965 */ 17966 function ary(func, n, guard) { 17967 n = guard ? undefined : n; 17968 n = (func && n == null) ? func.length : n; 17969 return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n); 17970 } 17971 17972 /** 17973 * Creates a function that invokes `func`, with the `this` binding and arguments 17974 * of the created function, while it's called less than `n` times. Subsequent 17975 * calls to the created function return the result of the last `func` invocation. 17976 * 17977 * @static 17978 * @memberOf _ 17979 * @since 3.0.0 17980 * @category Function 17981 * @param {number} n The number of calls at which `func` is no longer invoked. 17982 * @param {Function} func The function to restrict. 17983 * @returns {Function} Returns the new restricted function. 17984 * @example 17985 * 17986 * jQuery(element).on('click', _.before(5, addContactToList)); 17987 * // => Allows adding up to 4 contacts to the list. 17988 */ 17989 function before(n, func) { 17990 var result; 17991 if (typeof func != 'function') { 17992 throw new TypeError(FUNC_ERROR_TEXT); 17993 } 17994 n = toInteger(n); 17995 return function() { 17996 if (--n > 0) { 17997 result = func.apply(this, arguments); 17998 } 17999 if (n <= 1) { 18000 func = undefined; 18001 } 18002 return result; 18003 }; 18004 } 18005 18006 /** 18007 * Creates a function that invokes `func` with the `this` binding of `thisArg` 18008 * and `partials` prepended to the arguments it receives. 18009 * 18010 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, 18011 * may be used as a placeholder for partially applied arguments. 18012 * 18013 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length" 18014 * property of bound functions. 18015 * 18016 * @static 18017 * @memberOf _ 18018 * @since 0.1.0 18019 * @category Function 18020 * @param {Function} func The function to bind. 18021 * @param {*} thisArg The `this` binding of `func`. 18022 * @param {...*} [partials] The arguments to be partially applied. 18023 * @returns {Function} Returns the new bound function. 18024 * @example 18025 * 18026 * function greet(greeting, punctuation) { 18027 * return greeting + ' ' + this.user + punctuation; 18028 * } 18029 * 18030 * var object = { 'user': 'fred' }; 18031 * 18032 * var bound = _.bind(greet, object, 'hi'); 18033 * bound('!'); 18034 * // => 'hi fred!' 18035 * 18036 * // Bound with placeholders. 18037 * var bound = _.bind(greet, object, _, '!'); 18038 * bound('hi'); 18039 * // => 'hi fred!' 18040 */ 18041 var bind = baseRest(function(func, thisArg, partials) { 18042 var bitmask = WRAP_BIND_FLAG; 18043 if (partials.length) { 18044 var holders = replaceHolders(partials, getHolder(bind)); 18045 bitmask |= WRAP_PARTIAL_FLAG; 18046 } 18047 return createWrap(func, bitmask, thisArg, partials, holders); 18048 }); 18049 18050 /** 18051 * Creates a function that invokes the method at `object[key]` with `partials` 18052 * prepended to the arguments it receives. 18053 * 18054 * This method differs from `_.bind` by allowing bound functions to reference 18055 * methods that may be redefined or don't yet exist. See 18056 * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) 18057 * for more details. 18058 * 18059 * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic 18060 * builds, may be used as a placeholder for partially applied arguments. 18061 * 18062 * @static 18063 * @memberOf _
vendor: 46,477 bytes, lines 18064-19540
18064 * @since 0.10.0 18065 * @category Function 18066 * @param {Object} object The object to invoke the method on. 18067 * @param {string} key The key of the method. 18068 * @param {...*} [partials] The arguments to be partially applied. 18069 * @returns {Function} Returns the new bound function. 18070 * @example 18071 * 18072 * var object = { 18073 * 'user': 'fred', 18074 * 'greet': function(greeting, punctuation) { 18075 * return greeting + ' ' + this.user + punctuation; 18076 * } 18077 * }; 18078 * 18079 * var bound = _.bindKey(object, 'greet', 'hi'); 18080 * bound('!'); 18081 * // => 'hi fred!' 18082 * 18083 * object.greet = function(greeting, punctuation) { 18084 * return greeting + 'ya ' + this.user + punctuation; 18085 * }; 18086 * 18087 * bound('!'); 18088 * // => 'hiya fred!' 18089 * 18090 * // Bound with placeholders. 18091 * var bound = _.bindKey(object, 'greet', _, '!'); 18092 * bound('hi'); 18093 * // => 'hiya fred!' 18094 */ 18095 var bindKey = baseRest(function(object, key, partials) { 18096 var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG; 18097 if (partials.length) { 18098 var holders = replaceHolders(partials, getHolder(bindKey)); 18099 bitmask |= WRAP_PARTIAL_FLAG; 18100 } 18101 return createWrap(key, bitmask, object, partials, holders); 18102 }); 18103 18104 /** 18105 * Creates a function that accepts arguments of `func` and either invokes 18106 * `func` returning its result, if at least `arity` number of arguments have 18107 * been provided, or returns a function that accepts the remaining `func` 18108 * arguments, and so on. The arity of `func` may be specified if `func.length` 18109 * is not sufficient. 18110 * 18111 * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, 18112 * may be used as a placeholder for provided arguments. 18113 * 18114 * **Note:** This method doesn't set the "length" property of curried functions. 18115 * 18116 * @static 18117 * @memberOf _ 18118 * @since 2.0.0 18119 * @category Function 18120 * @param {Function} func The function to curry. 18121 * @param {number} [arity=func.length] The arity of `func`. 18122 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 18123 * @returns {Function} Returns the new curried function. 18124 * @example 18125 * 18126 * var abc = function(a, b, c) { 18127 * return [a, b, c]; 18128 * }; 18129 * 18130 * var curried = _.curry(abc); 18131 * 18132 * curried(1)(2)(3); 18133 * // => [1, 2, 3] 18134 * 18135 * curried(1, 2)(3); 18136 * // => [1, 2, 3] 18137 * 18138 * curried(1, 2, 3); 18139 * // => [1, 2, 3] 18140 * 18141 * // Curried with placeholders. 18142 * curried(1)(_, 3)(2); 18143 * // => [1, 2, 3] 18144 */ 18145 function curry(func, arity, guard) { 18146 arity = guard ? undefined : arity; 18147 var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 18148 result.placeholder = curry.placeholder; 18149 return result; 18150 } 18151 18152 /** 18153 * This method is like `_.curry` except that arguments are applied to `func` 18154 * in the manner of `_.partialRight` instead of `_.partial`. 18155 * 18156 * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic 18157 * builds, may be used as a placeholder for provided arguments. 18158 * 18159 * **Note:** This method doesn't set the "length" property of curried functions. 18160 * 18161 * @static 18162 * @memberOf _ 18163 * @since 3.0.0 18164 * @category Function 18165 * @param {Function} func The function to curry. 18166 * @param {number} [arity=func.length] The arity of `func`. 18167 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 18168 * @returns {Function} Returns the new curried function. 18169 * @example 18170 * 18171 * var abc = function(a, b, c) { 18172 * return [a, b, c]; 18173 * }; 18174 * 18175 * var curried = _.curryRight(abc); 18176 * 18177 * curried(3)(2)(1); 18178 * // => [1, 2, 3] 18179 * 18180 * curried(2, 3)(1); 18181 * // => [1, 2, 3] 18182 * 18183 * curried(1, 2, 3); 18184 * // => [1, 2, 3] 18185 * 18186 * // Curried with placeholders. 18187 * curried(3)(1, _)(2); 18188 * // => [1, 2, 3] 18189 */ 18190 function curryRight(func, arity, guard) { 18191 arity = guard ? undefined : arity; 18192 var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 18193 result.placeholder = curryRight.placeholder; 18194 return result; 18195 } 18196 18197 /** 18198 * Creates a debounced function that delays invoking `func` until after `wait` 18199 * milliseconds have elapsed since the last time the debounced function was 18200 * invoked. The debounced function comes with a `cancel` method to cancel 18201 * delayed `func` invocations and a `flush` method to immediately invoke them. 18202 * Provide `options` to indicate whether `func` should be invoked on the 18203 * leading and/or trailing edge of the `wait` timeout. The `func` is invoked 18204 * with the last arguments provided to the debounced function. Subsequent 18205 * calls to the debounced function return the result of the last `func` 18206 * invocation. 18207 * 18208 * **Note:** If `leading` and `trailing` options are `true`, `func` is 18209 * invoked on the trailing edge of the timeout only if the debounced function 18210 * is invoked more than once during the `wait` timeout. 18211 * 18212 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 18213 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 18214 * 18215 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 18216 * for details over the differences between `_.debounce` and `_.throttle`. 18217 * 18218 * @static 18219 * @memberOf _ 18220 * @since 0.1.0 18221 * @category Function 18222 * @param {Function} func The function to debounce. 18223 * @param {number} [wait=0] The number of milliseconds to delay. 18224 * @param {Object} [options={}] The options object. 18225 * @param {boolean} [options.leading=false] 18226 * Specify invoking on the leading edge of the timeout. 18227 * @param {number} [options.maxWait] 18228 * The maximum time `func` is allowed to be delayed before it's invoked. 18229 * @param {boolean} [options.trailing=true] 18230 * Specify invoking on the trailing edge of the timeout. 18231 * @returns {Function} Returns the new debounced function. 18232 * @example 18233 * 18234 * // Avoid costly calculations while the window size is in flux. 18235 * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); 18236 * 18237 * // Invoke `sendMail` when clicked, debouncing subsequent calls. 18238 * jQuery(element).on('click', _.debounce(sendMail, 300, { 18239 * 'leading': true, 18240 * 'trailing': false 18241 * })); 18242 * 18243 * // Ensure `batchLog` is invoked once after 1 second of debounced calls. 18244 * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); 18245 * var source = new EventSource('/stream'); 18246 * jQuery(source).on('message', debounced); 18247 * 18248 * // Cancel the trailing debounced invocation. 18249 * jQuery(window).on('popstate', debounced.cancel); 18250 */ 18251 function debounce(func, wait, options) { 18252 var lastArgs, 18253 lastThis, 18254 maxWait, 18255 result, 18256 timerId, 18257 lastCallTime, 18258 lastInvokeTime = 0, 18259 leading = false, 18260 maxing = false, 18261 trailing = true; 18262 18263 if (typeof func != 'function') { 18264 throw new TypeError(FUNC_ERROR_TEXT); 18265 } 18266 wait = toNumber(wait) || 0; 18267 if (isObject(options)) { 18268 leading = !!options.leading; 18269 maxing = 'maxWait' in options; 18270 maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; 18271 trailing = 'trailing' in options ? !!options.trailing : trailing; 18272 } 18273 18274 function invokeFunc(time) { 18275 var args = lastArgs, 18276 thisArg = lastThis; 18277 18278 lastArgs = lastThis = undefined; 18279 lastInvokeTime = time; 18280 result = func.apply(thisArg, args); 18281 return result; 18282 } 18283 18284 function leadingEdge(time) { 18285 // Reset any `maxWait` timer. 18286 lastInvokeTime = time; 18287 // Start the timer for the trailing edge. 18288 timerId = setTimeout(timerExpired, wait); 18289 // Invoke the leading edge. 18290 return leading ? invokeFunc(time) : result; 18291 } 18292 18293 function remainingWait(time) { 18294 var timeSinceLastCall = time - lastCallTime, 18295 timeSinceLastInvoke = time - lastInvokeTime, 18296 timeWaiting = wait - timeSinceLastCall; 18297 18298 return maxing 18299 ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) 18300 : timeWaiting; 18301 } 18302 18303 function shouldInvoke(time) { 18304 var timeSinceLastCall = time - lastCallTime, 18305 timeSinceLastInvoke = time - lastInvokeTime; 18306 18307 // Either this is the first call, activity has stopped and we're at the 18308 // trailing edge, the system time has gone backwards and we're treating 18309 // it as the trailing edge, or we've hit the `maxWait` limit. 18310 return (lastCallTime === undefined || (timeSinceLastCall >= wait) || 18311 (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); 18312 } 18313 18314 function timerExpired() { 18315 var time = now(); 18316 if (shouldInvoke(time)) { 18317 return trailingEdge(time); 18318 } 18319 // Restart the timer. 18320 timerId = setTimeout(timerExpired, remainingWait(time)); 18321 } 18322 18323 function trailingEdge(time) { 18324 timerId = undefined; 18325 18326 // Only invoke if we have `lastArgs` which means `func` has been 18327 // debounced at least once. 18328 if (trailing && lastArgs) { 18329 return invokeFunc(time); 18330 } 18331 lastArgs = lastThis = undefined; 18332 return result; 18333 } 18334 18335 function cancel() { 18336 if (timerId !== undefined) { 18337 clearTimeout(timerId); 18338 } 18339 lastInvokeTime = 0; 18340 lastArgs = lastCallTime = lastThis = timerId = undefined; 18341 } 18342 18343 function flush() { 18344 return timerId === undefined ? result : trailingEdge(now()); 18345 } 18346 18347 function debounced() { 18348 var time = now(), 18349 isInvoking = shouldInvoke(time); 18350 18351 lastArgs = arguments; 18352 lastThis = this; 18353 lastCallTime = time; 18354 18355 if (isInvoking) { 18356 if (timerId === undefined) { 18357 return leadingEdge(lastCallTime); 18358 } 18359 if (maxing) { 18360 // Handle invocations in a tight loop. 18361 clearTimeout(timerId); 18362 timerId = setTimeout(timerExpired, wait); 18363 return invokeFunc(lastCallTime); 18364 } 18365 } 18366 if (timerId === undefined) { 18367 timerId = setTimeout(timerExpired, wait); 18368 } 18369 return result; 18370 } 18371 debounced.cancel = cancel; 18372 debounced.flush = flush; 18373 return debounced; 18374 } 18375 18376 /** 18377 * Defers invoking the `func` until the current call stack has cleared. Any 18378 * additional arguments are provided to `func` when it's invoked. 18379 * 18380 * @static 18381 * @memberOf _ 18382 * @since 0.1.0 18383 * @category Function 18384 * @param {Function} func The function to defer. 18385 * @param {...*} [args] The arguments to invoke `func` with. 18386 * @returns {number} Returns the timer id. 18387 * @example 18388 * 18389 * _.defer(function(text) { 18390 * console.log(text); 18391 * }, 'deferred'); 18392 * // => Logs 'deferred' after one millisecond. 18393 */ 18394 var defer = baseRest(function(func, args) { 18395 return baseDelay(func, 1, args); 18396 }); 18397 18398 /** 18399 * Invokes `func` after `wait` milliseconds. Any additional arguments are 18400 * provided to `func` when it's invoked. 18401 * 18402 * @static 18403 * @memberOf _ 18404 * @since 0.1.0 18405 * @category Function 18406 * @param {Function} func The function to delay. 18407 * @param {number} wait The number of milliseconds to delay invocation. 18408 * @param {...*} [args] The arguments to invoke `func` with. 18409 * @returns {number} Returns the timer id. 18410 * @example 18411 * 18412 * _.delay(function(text) { 18413 * console.log(text); 18414 * }, 1000, 'later'); 18415 * // => Logs 'later' after one second. 18416 */ 18417 var delay = baseRest(function(func, wait, args) { 18418 return baseDelay(func, toNumber(wait) || 0, args); 18419 }); 18420 18421 /** 18422 * Creates a function that invokes `func` with arguments reversed. 18423 * 18424 * @static 18425 * @memberOf _ 18426 * @since 4.0.0 18427 * @category Function 18428 * @param {Function} func The function to flip arguments for. 18429 * @returns {Function} Returns the new flipped function. 18430 * @example 18431 * 18432 * var flipped = _.flip(function() { 18433 * return _.toArray(arguments); 18434 * }); 18435 * 18436 * flipped('a', 'b', 'c', 'd'); 18437 * // => ['d', 'c', 'b', 'a'] 18438 */ 18439 function flip(func) { 18440 return createWrap(func, WRAP_FLIP_FLAG); 18441 } 18442 18443 /** 18444 * Creates a function that memoizes the result of `func`. If `resolver` is 18445 * provided, it determines the cache key for storing the result based on the 18446 * arguments provided to the memoized function. By default, the first argument 18447 * provided to the memoized function is used as the map cache key. The `func` 18448 * is invoked with the `this` binding of the memoized function. 18449 * 18450 * **Note:** The cache is exposed as the `cache` property on the memoized 18451 * function. Its creation may be customized by replacing the `_.memoize.Cache` 18452 * constructor with one whose instances implement the 18453 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) 18454 * method interface of `clear`, `delete`, `get`, `has`, and `set`. 18455 * 18456 * @static 18457 * @memberOf _ 18458 * @since 0.1.0 18459 * @category Function 18460 * @param {Function} func The function to have its output memoized. 18461 * @param {Function} [resolver] The function to resolve the cache key. 18462 * @returns {Function} Returns the new memoized function. 18463 * @example 18464 * 18465 * var object = { 'a': 1, 'b': 2 }; 18466 * var other = { 'c': 3, 'd': 4 }; 18467 * 18468 * var values = _.memoize(_.values); 18469 * values(object); 18470 * // => [1, 2] 18471 * 18472 * values(other); 18473 * // => [3, 4] 18474 * 18475 * object.a = 2; 18476 * values(object); 18477 * // => [1, 2] 18478 * 18479 * // Modify the result cache. 18480 * values.cache.set(object, ['a', 'b']); 18481 * values(object); 18482 * // => ['a', 'b'] 18483 * 18484 * // Replace `_.memoize.Cache`. 18485 * _.memoize.Cache = WeakMap; 18486 */ 18487 function memoize(func, resolver) { 18488 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { 18489 throw new TypeError(FUNC_ERROR_TEXT); 18490 } 18491 var memoized = function() { 18492 var args = arguments, 18493 key = resolver ? resolver.apply(this, args) : args[0], 18494 cache = memoized.cache; 18495 18496 if (cache.has(key)) { 18497 return cache.get(key); 18498 } 18499 var result = func.apply(this, args); 18500 memoized.cache = cache.set(key, result) || cache; 18501 return result; 18502 }; 18503 memoized.cache = new (memoize.Cache || MapCache); 18504 return memoized; 18505 } 18506 18507 // Expose `MapCache`. 18508 memoize.Cache = MapCache; 18509 18510 /** 18511 * Creates a function that negates the result of the predicate `func`. The 18512 * `func` predicate is invoked with the `this` binding and arguments of the 18513 * created function. 18514 * 18515 * @static 18516 * @memberOf _ 18517 * @since 3.0.0 18518 * @category Function 18519 * @param {Function} predicate The predicate to negate. 18520 * @returns {Function} Returns the new negated function. 18521 * @example 18522 * 18523 * function isEven(n) { 18524 * return n % 2 == 0; 18525 * } 18526 * 18527 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); 18528 * // => [1, 3, 5] 18529 */ 18530 function negate(predicate) { 18531 if (typeof predicate != 'function') { 18532 throw new TypeError(FUNC_ERROR_TEXT); 18533 } 18534 return function() { 18535 var args = arguments; 18536 switch (args.length) { 18537 case 0: return !predicate.call(this); 18538 case 1: return !predicate.call(this, args[0]); 18539 case 2: return !predicate.call(this, args[0], args[1]); 18540 case 3: return !predicate.call(this, args[0], args[1], args[2]); 18541 } 18542 return !predicate.apply(this, args); 18543 }; 18544 } 18545 18546 /** 18547 * Creates a function that is restricted to invoking `func` once. Repeat calls 18548 * to the function return the value of the first invocation. The `func` is 18549 * invoked with the `this` binding and arguments of the created function. 18550 * 18551 * @static 18552 * @memberOf _ 18553 * @since 0.1.0 18554 * @category Function 18555 * @param {Function} func The function to restrict. 18556 * @returns {Function} Returns the new restricted function. 18557 * @example 18558 * 18559 * var initialize = _.once(createApplication); 18560 * initialize(); 18561 * initialize(); 18562 * // => `createApplication` is invoked once 18563 */ 18564 function once(func) { 18565 return before(2, func); 18566 } 18567 18568 /** 18569 * Creates a function that invokes `func` with its arguments transformed. 18570 * 18571 * @static 18572 * @since 4.0.0 18573 * @memberOf _ 18574 * @category Function 18575 * @param {Function} func The function to wrap. 18576 * @param {...(Function|Function[])} [transforms=[_.identity]] 18577 * The argument transforms. 18578 * @returns {Function} Returns the new function. 18579 * @example 18580 * 18581 * function doubled(n) { 18582 * return n * 2; 18583 * } 18584 * 18585 * function square(n) { 18586 * return n * n; 18587 * } 18588 * 18589 * var func = _.overArgs(function(x, y) { 18590 * return [x, y]; 18591 * }, [square, doubled]); 18592 * 18593 * func(9, 3); 18594 * // => [81, 6] 18595 * 18596 * func(10, 5); 18597 * // => [100, 10] 18598 */ 18599 var overArgs = castRest(function(func, transforms) { 18600 transforms = (transforms.length == 1 && isArray(transforms[0])) 18601 ? arrayMap(transforms[0], baseUnary(getIteratee())) 18602 : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee())); 18603 18604 var funcsLength = transforms.length; 18605 return baseRest(function(args) { 18606 var index = -1, 18607 length = nativeMin(args.length, funcsLength); 18608 18609 while (++index < length) { 18610 args[index] = transforms[index].call(this, args[index]); 18611 } 18612 return apply(func, this, args); 18613 }); 18614 }); 18615 18616 /** 18617 * Creates a function that invokes `func` with `partials` prepended to the 18618 * arguments it receives. This method is like `_.bind` except it does **not** 18619 * alter the `this` binding. 18620 * 18621 * The `_.partial.placeholder` value, which defaults to `_` in monolithic 18622 * builds, may be used as a placeholder for partially applied arguments. 18623 * 18624 * **Note:** This method doesn't set the "length" property of partially 18625 * applied functions. 18626 * 18627 * @static 18628 * @memberOf _ 18629 * @since 0.2.0 18630 * @category Function 18631 * @param {Function} func The function to partially apply arguments to. 18632 * @param {...*} [partials] The arguments to be partially applied. 18633 * @returns {Function} Returns the new partially applied function. 18634 * @example 18635 * 18636 * function greet(greeting, name) { 18637 * return greeting + ' ' + name; 18638 * } 18639 * 18640 * var sayHelloTo = _.partial(greet, 'hello'); 18641 * sayHelloTo('fred'); 18642 * // => 'hello fred' 18643 * 18644 * // Partially applied with placeholders. 18645 * var greetFred = _.partial(greet, _, 'fred'); 18646 * greetFred('hi'); 18647 * // => 'hi fred' 18648 */ 18649 var partial = baseRest(function(func, partials) { 18650 var holders = replaceHolders(partials, getHolder(partial)); 18651 return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders); 18652 }); 18653 18654 /** 18655 * This method is like `_.partial` except that partially applied arguments 18656 * are appended to the arguments it receives. 18657 * 18658 * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic 18659 * builds, may be used as a placeholder for partially applied arguments. 18660 * 18661 * **Note:** This method doesn't set the "length" property of partially 18662 * applied functions. 18663 * 18664 * @static 18665 * @memberOf _ 18666 * @since 1.0.0 18667 * @category Function 18668 * @param {Function} func The function to partially apply arguments to. 18669 * @param {...*} [partials] The arguments to be partially applied. 18670 * @returns {Function} Returns the new partially applied function. 18671 * @example 18672 * 18673 * function greet(greeting, name) { 18674 * return greeting + ' ' + name; 18675 * } 18676 * 18677 * var greetFred = _.partialRight(greet, 'fred'); 18678 * greetFred('hi'); 18679 * // => 'hi fred' 18680 * 18681 * // Partially applied with placeholders. 18682 * var sayHelloTo = _.partialRight(greet, 'hello', _); 18683 * sayHelloTo('fred'); 18684 * // => 'hello fred' 18685 */ 18686 var partialRight = baseRest(function(func, partials) { 18687 var holders = replaceHolders(partials, getHolder(partialRight)); 18688 return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders); 18689 }); 18690 18691 /** 18692 * Creates a function that invokes `func` with arguments arranged according 18693 * to the specified `indexes` where the argument value at the first index is 18694 * provided as the first argument, the argument value at the second index is 18695 * provided as the second argument, and so on. 18696 * 18697 * @static 18698 * @memberOf _ 18699 * @since 3.0.0 18700 * @category Function 18701 * @param {Function} func The function to rearrange arguments for. 18702 * @param {...(number|number[])} indexes The arranged argument indexes. 18703 * @returns {Function} Returns the new function. 18704 * @example 18705 * 18706 * var rearged = _.rearg(function(a, b, c) { 18707 * return [a, b, c]; 18708 * }, [2, 0, 1]); 18709 * 18710 * rearged('b', 'c', 'a') 18711 * // => ['a', 'b', 'c'] 18712 */ 18713 var rearg = flatRest(function(func, indexes) { 18714 return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes); 18715 }); 18716 18717 /** 18718 * Creates a function that invokes `func` with the `this` binding of the 18719 * created function and arguments from `start` and beyond provided as 18720 * an array. 18721 * 18722 * **Note:** This method is based on the 18723 * [rest parameter](https://mdn.io/rest_parameters). 18724 * 18725 * @static 18726 * @memberOf _ 18727 * @since 4.0.0 18728 * @category Function 18729 * @param {Function} func The function to apply a rest parameter to. 18730 * @param {number} [start=func.length-1] The start position of the rest parameter. 18731 * @returns {Function} Returns the new function. 18732 * @example 18733 * 18734 * var say = _.rest(function(what, names) { 18735 * return what + ' ' + _.initial(names).join(', ') + 18736 * (_.size(names) > 1 ? ', & ' : '') + _.last(names); 18737 * }); 18738 * 18739 * say('hello', 'fred', 'barney', 'pebbles'); 18740 * // => 'hello fred, barney, & pebbles' 18741 */ 18742 function rest(func, start) { 18743 if (typeof func != 'function') { 18744 throw new TypeError(FUNC_ERROR_TEXT); 18745 } 18746 start = start === undefined ? start : toInteger(start); 18747 return baseRest(func, start); 18748 } 18749 18750 /** 18751 * Creates a function that invokes `func` with the `this` binding of the 18752 * create function and an array of arguments much like 18753 * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply). 18754 * 18755 * **Note:** This method is based on the 18756 * [spread operator](https://mdn.io/spread_operator). 18757 * 18758 * @static 18759 * @memberOf _ 18760 * @since 3.2.0 18761 * @category Function 18762 * @param {Function} func The function to spread arguments over. 18763 * @param {number} [start=0] The start position of the spread. 18764 * @returns {Function} Returns the new function. 18765 * @example 18766 * 18767 * var say = _.spread(function(who, what) { 18768 * return who + ' says ' + what; 18769 * }); 18770 * 18771 * say(['fred', 'hello']); 18772 * // => 'fred says hello' 18773 * 18774 * var numbers = Promise.all([ 18775 * Promise.resolve(40), 18776 * Promise.resolve(36) 18777 * ]); 18778 * 18779 * numbers.then(_.spread(function(x, y) { 18780 * return x + y; 18781 * })); 18782 * // => a Promise of 76 18783 */ 18784 function spread(func, start) { 18785 if (typeof func != 'function') { 18786 throw new TypeError(FUNC_ERROR_TEXT); 18787 } 18788 start = start == null ? 0 : nativeMax(toInteger(start), 0); 18789 return baseRest(function(args) { 18790 var array = args[start], 18791 otherArgs = castSlice(args, 0, start); 18792 18793 if (array) { 18794 arrayPush(otherArgs, array); 18795 } 18796 return apply(func, this, otherArgs); 18797 }); 18798 } 18799 18800 /** 18801 * Creates a throttled function that only invokes `func` at most once per 18802 * every `wait` milliseconds. The throttled function comes with a `cancel` 18803 * method to cancel delayed `func` invocations and a `flush` method to 18804 * immediately invoke them. Provide `options` to indicate whether `func` 18805 * should be invoked on the leading and/or trailing edge of the `wait` 18806 * timeout. The `func` is invoked with the last arguments provided to the 18807 * throttled function. Subsequent calls to the throttled function return the 18808 * result of the last `func` invocation. 18809 * 18810 * **Note:** If `leading` and `trailing` options are `true`, `func` is 18811 * invoked on the trailing edge of the timeout only if the throttled function 18812 * is invoked more than once during the `wait` timeout. 18813 * 18814 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 18815 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 18816 * 18817 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 18818 * for details over the differences between `_.throttle` and `_.debounce`. 18819 * 18820 * @static 18821 * @memberOf _ 18822 * @since 0.1.0 18823 * @category Function 18824 * @param {Function} func The function to throttle. 18825 * @param {number} [wait=0] The number of milliseconds to throttle invocations to. 18826 * @param {Object} [options={}] The options object. 18827 * @param {boolean} [options.leading=true] 18828 * Specify invoking on the leading edge of the timeout. 18829 * @param {boolean} [options.trailing=true] 18830 * Specify invoking on the trailing edge of the timeout. 18831 * @returns {Function} Returns the new throttled function. 18832 * @example 18833 * 18834 * // Avoid excessively updating the position while scrolling. 18835 * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); 18836 * 18837 * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. 18838 * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); 18839 * jQuery(element).on('click', throttled); 18840 * 18841 * // Cancel the trailing throttled invocation. 18842 * jQuery(window).on('popstate', throttled.cancel); 18843 */ 18844 function throttle(func, wait, options) { 18845 var leading = true, 18846 trailing = true; 18847 18848 if (typeof func != 'function') { 18849 throw new TypeError(FUNC_ERROR_TEXT); 18850 } 18851 if (isObject(options)) { 18852 leading = 'leading' in options ? !!options.leading : leading; 18853 trailing = 'trailing' in options ? !!options.trailing : trailing; 18854 } 18855 return debounce(func, wait, { 18856 'leading': leading, 18857 'maxWait': wait, 18858 'trailing': trailing 18859 }); 18860 } 18861 18862 /** 18863 * Creates a function that accepts up to one argument, ignoring any 18864 * additional arguments. 18865 * 18866 * @static 18867 * @memberOf _ 18868 * @since 4.0.0 18869 * @category Function 18870 * @param {Function} func The function to cap arguments for. 18871 * @returns {Function} Returns the new capped function. 18872 * @example 18873 * 18874 * _.map(['6', '8', '10'], _.unary(parseInt)); 18875 * // => [6, 8, 10] 18876 */ 18877 function unary(func) { 18878 return ary(func, 1); 18879 } 18880 18881 /** 18882 * Creates a function that provides `value` to `wrapper` as its first 18883 * argument. Any additional arguments provided to the function are appended 18884 * to those provided to the `wrapper`. The wrapper is invoked with the `this` 18885 * binding of the created function. 18886 * 18887 * @static 18888 * @memberOf _ 18889 * @since 0.1.0 18890 * @category Function 18891 * @param {*} value The value to wrap. 18892 * @param {Function} [wrapper=identity] The wrapper function. 18893 * @returns {Function} Returns the new function. 18894 * @example 18895 * 18896 * var p = _.wrap(_.escape, function(func, text) { 18897 * return '<p>' + func(text) + '</p>'; 18898 * }); 18899 * 18900 * p('fred, barney, & pebbles'); 18901 * // => '<p>fred, barney, & pebbles</p>' 18902 */ 18903 function wrap(value, wrapper) { 18904 return partial(castFunction(wrapper), value); 18905 } 18906 18907 /*------------------------------------------------------------------------*/ 18908 18909 /** 18910 * Casts `value` as an array if it's not one. 18911 * 18912 * @static 18913 * @memberOf _ 18914 * @since 4.4.0 18915 * @category Lang 18916 * @param {*} value The value to inspect. 18917 * @returns {Array} Returns the cast array. 18918 * @example 18919 * 18920 * _.castArray(1); 18921 * // => [1] 18922 * 18923 * _.castArray({ 'a': 1 }); 18924 * // => [{ 'a': 1 }] 18925 * 18926 * _.castArray('abc'); 18927 * // => ['abc'] 18928 * 18929 * _.castArray(null); 18930 * // => [null] 18931 * 18932 * _.castArray(undefined); 18933 * // => [undefined] 18934 * 18935 * _.castArray(); 18936 * // => [] 18937 * 18938 * var array = [1, 2, 3]; 18939 * console.log(_.castArray(array) === array); 18940 * // => true 18941 */ 18942 function castArray() { 18943 if (!arguments.length) { 18944 return []; 18945 } 18946 var value = arguments[0]; 18947 return isArray(value) ? value : [value]; 18948 } 18949 18950 /** 18951 * Creates a shallow clone of `value`. 18952 * 18953 * **Note:** This method is loosely based on the 18954 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) 18955 * and supports cloning arrays, array buffers, booleans, date objects, maps, 18956 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed 18957 * arrays. The own enumerable properties of `arguments` objects are cloned 18958 * as plain objects. An empty object is returned for uncloneable values such 18959 * as error objects, functions, DOM nodes, and WeakMaps. 18960 * 18961 * @static 18962 * @memberOf _ 18963 * @since 0.1.0 18964 * @category Lang 18965 * @param {*} value The value to clone. 18966 * @returns {*} Returns the cloned value. 18967 * @see _.cloneDeep 18968 * @example 18969 * 18970 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 18971 * 18972 * var shallow = _.clone(objects); 18973 * console.log(shallow[0] === objects[0]); 18974 * // => true 18975 */ 18976 function clone(value) { 18977 return baseClone(value, CLONE_SYMBOLS_FLAG); 18978 } 18979 18980 /** 18981 * This method is like `_.clone` except that it accepts `customizer` which 18982 * is invoked to produce the cloned value. If `customizer` returns `undefined`, 18983 * cloning is handled by the method instead. The `customizer` is invoked with 18984 * up to four arguments; (value [, index|key, object, stack]). 18985 * 18986 * @static 18987 * @memberOf _ 18988 * @since 4.0.0 18989 * @category Lang 18990 * @param {*} value The value to clone. 18991 * @param {Function} [customizer] The function to customize cloning. 18992 * @returns {*} Returns the cloned value. 18993 * @see _.cloneDeepWith 18994 * @example 18995 * 18996 * function customizer(value) { 18997 * if (_.isElement(value)) { 18998 * return value.cloneNode(false); 18999 * } 19000 * } 19001 * 19002 * var el = _.cloneWith(document.body, customizer); 19003 * 19004 * console.log(el === document.body); 19005 * // => false 19006 * console.log(el.nodeName); 19007 * // => 'BODY' 19008 * console.log(el.childNodes.length); 19009 * // => 0 19010 */ 19011 function cloneWith(value, customizer) { 19012 customizer = typeof customizer == 'function' ? customizer : undefined; 19013 return baseClone(value, CLONE_SYMBOLS_FLAG, customizer); 19014 } 19015 19016 /** 19017 * This method is like `_.clone` except that it recursively clones `value`. 19018 * 19019 * @static 19020 * @memberOf _ 19021 * @since 1.0.0 19022 * @category Lang 19023 * @param {*} value The value to recursively clone. 19024 * @returns {*} Returns the deep cloned value. 19025 * @see _.clone 19026 * @example 19027 * 19028 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 19029 * 19030 * var deep = _.cloneDeep(objects); 19031 * console.log(deep[0] === objects[0]); 19032 * // => false 19033 */ 19034 function cloneDeep(value) { 19035 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); 19036 } 19037 19038 /** 19039 * This method is like `_.cloneWith` except that it recursively clones `value`. 19040 * 19041 * @static 19042 * @memberOf _ 19043 * @since 4.0.0 19044 * @category Lang 19045 * @param {*} value The value to recursively clone. 19046 * @param {Function} [customizer] The function to customize cloning. 19047 * @returns {*} Returns the deep cloned value. 19048 * @see _.cloneWith 19049 * @example 19050 * 19051 * function customizer(value) { 19052 * if (_.isElement(value)) { 19053 * return value.cloneNode(true); 19054 * } 19055 * } 19056 * 19057 * var el = _.cloneDeepWith(document.body, customizer); 19058 * 19059 * console.log(el === document.body); 19060 * // => false 19061 * console.log(el.nodeName); 19062 * // => 'BODY' 19063 * console.log(el.childNodes.length); 19064 * // => 20 19065 */ 19066 function cloneDeepWith(value, customizer) { 19067 customizer = typeof customizer == 'function' ? customizer : undefined; 19068 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer); 19069 } 19070 19071 /** 19072 * Checks if `object` conforms to `source` by invoking the predicate 19073 * properties of `source` with the corresponding property values of `object`. 19074 * 19075 * **Note:** This method is equivalent to `_.conforms` when `source` is 19076 * partially applied. 19077 * 19078 * @static 19079 * @memberOf _ 19080 * @since 4.14.0 19081 * @category Lang 19082 * @param {Object} object The object to inspect. 19083 * @param {Object} source The object of property predicates to conform to. 19084 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 19085 * @example 19086 * 19087 * var object = { 'a': 1, 'b': 2 }; 19088 * 19089 * _.conformsTo(object, { 'b': function(n) { return n > 1; } }); 19090 * // => true 19091 * 19092 * _.conformsTo(object, { 'b': function(n) { return n > 2; } }); 19093 * // => false 19094 */ 19095 function conformsTo(object, source) { 19096 return source == null || baseConformsTo(object, source, keys(source)); 19097 } 19098 19099 /** 19100 * Performs a 19101 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 19102 * comparison between two values to determine if they are equivalent. 19103 * 19104 * @static 19105 * @memberOf _ 19106 * @since 4.0.0 19107 * @category Lang 19108 * @param {*} value The value to compare. 19109 * @param {*} other The other value to compare. 19110 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 19111 * @example 19112 * 19113 * var object = { 'a': 1 }; 19114 * var other = { 'a': 1 }; 19115 * 19116 * _.eq(object, object); 19117 * // => true 19118 * 19119 * _.eq(object, other); 19120 * // => false 19121 * 19122 * _.eq('a', 'a'); 19123 * // => true 19124 * 19125 * _.eq('a', Object('a')); 19126 * // => false 19127 * 19128 * _.eq(NaN, NaN); 19129 * // => true 19130 */ 19131 function eq(value, other) { 19132 return value === other || (value !== value && other !== other); 19133 } 19134 19135 /** 19136 * Checks if `value` is greater than `other`. 19137 * 19138 * @static 19139 * @memberOf _ 19140 * @since 3.9.0 19141 * @category Lang 19142 * @param {*} value The value to compare. 19143 * @param {*} other The other value to compare. 19144 * @returns {boolean} Returns `true` if `value` is greater than `other`, 19145 * else `false`. 19146 * @see _.lt 19147 * @example 19148 * 19149 * _.gt(3, 1); 19150 * // => true 19151 * 19152 * _.gt(3, 3); 19153 * // => false 19154 * 19155 * _.gt(1, 3); 19156 * // => false 19157 */ 19158 var gt = createRelationalOperation(baseGt); 19159 19160 /** 19161 * Checks if `value` is greater than or equal to `other`. 19162 * 19163 * @static 19164 * @memberOf _ 19165 * @since 3.9.0 19166 * @category Lang 19167 * @param {*} value The value to compare. 19168 * @param {*} other The other value to compare. 19169 * @returns {boolean} Returns `true` if `value` is greater than or equal to 19170 * `other`, else `false`. 19171 * @see _.lte 19172 * @example 19173 * 19174 * _.gte(3, 1); 19175 * // => true 19176 * 19177 * _.gte(3, 3); 19178 * // => true 19179 * 19180 * _.gte(1, 3); 19181 * // => false 19182 */ 19183 var gte = createRelationalOperation(function(value, other) { 19184 return value >= other; 19185 }); 19186 19187 /** 19188 * Checks if `value` is likely an `arguments` object. 19189 * 19190 * @static 19191 * @memberOf _ 19192 * @since 0.1.0 19193 * @category Lang 19194 * @param {*} value The value to check. 19195 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 19196 * else `false`. 19197 * @example 19198 * 19199 * _.isArguments(function() { return arguments; }()); 19200 * // => true 19201 * 19202 * _.isArguments([1, 2, 3]); 19203 * // => false 19204 */ 19205 var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { 19206 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && 19207 !propertyIsEnumerable.call(value, 'callee'); 19208 }; 19209 19210 /** 19211 * Checks if `value` is classified as an `Array` object. 19212 * 19213 * @static 19214 * @memberOf _ 19215 * @since 0.1.0 19216 * @category Lang 19217 * @param {*} value The value to check. 19218 * @returns {boolean} Returns `true` if `value` is an array, else `false`. 19219 * @example 19220 * 19221 * _.isArray([1, 2, 3]); 19222 * // => true 19223 * 19224 * _.isArray(document.body.children); 19225 * // => false 19226 * 19227 * _.isArray('abc'); 19228 * // => false 19229 * 19230 * _.isArray(_.noop); 19231 * // => false 19232 */ 19233 var isArray = Array.isArray; 19234 19235 /** 19236 * Checks if `value` is classified as an `ArrayBuffer` object. 19237 * 19238 * @static 19239 * @memberOf _ 19240 * @since 4.3.0 19241 * @category Lang 19242 * @param {*} value The value to check. 19243 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 19244 * @example 19245 * 19246 * _.isArrayBuffer(new ArrayBuffer(2)); 19247 * // => true 19248 * 19249 * _.isArrayBuffer(new Array(2)); 19250 * // => false 19251 */ 19252 var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; 19253 19254 /** 19255 * Checks if `value` is array-like. A value is considered array-like if it's 19256 * not a function and has a `value.length` that's an integer greater than or 19257 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. 19258 * 19259 * @static 19260 * @memberOf _ 19261 * @since 4.0.0 19262 * @category Lang 19263 * @param {*} value The value to check. 19264 * @returns {boolean} Returns `true` if `value` is array-like, else `false`. 19265 * @example 19266 * 19267 * _.isArrayLike([1, 2, 3]); 19268 * // => true 19269 * 19270 * _.isArrayLike(document.body.children); 19271 * // => true 19272 * 19273 * _.isArrayLike('abc'); 19274 * // => true 19275 * 19276 * _.isArrayLike(_.noop); 19277 * // => false 19278 */ 19279 function isArrayLike(value) { 19280 return value != null && isLength(value.length) && !isFunction(value); 19281 } 19282 19283 /** 19284 * This method is like `_.isArrayLike` except that it also checks if `value` 19285 * is an object. 19286 * 19287 * @static 19288 * @memberOf _ 19289 * @since 4.0.0 19290 * @category Lang 19291 * @param {*} value The value to check. 19292 * @returns {boolean} Returns `true` if `value` is an array-like object, 19293 * else `false`. 19294 * @example 19295 * 19296 * _.isArrayLikeObject([1, 2, 3]); 19297 * // => true 19298 * 19299 * _.isArrayLikeObject(document.body.children); 19300 * // => true 19301 * 19302 * _.isArrayLikeObject('abc'); 19303 * // => false 19304 * 19305 * _.isArrayLikeObject(_.noop); 19306 * // => false 19307 */ 19308 function isArrayLikeObject(value) { 19309 return isObjectLike(value) && isArrayLike(value); 19310 } 19311 19312 /** 19313 * Checks if `value` is classified as a boolean primitive or object. 19314 * 19315 * @static 19316 * @memberOf _ 19317 * @since 0.1.0 19318 * @category Lang 19319 * @param {*} value The value to check. 19320 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`. 19321 * @example 19322 * 19323 * _.isBoolean(false); 19324 * // => true 19325 * 19326 * _.isBoolean(null); 19327 * // => false 19328 */ 19329 function isBoolean(value) { 19330 return value === true || value === false || 19331 (isObjectLike(value) && baseGetTag(value) == boolTag); 19332 } 19333 19334 /** 19335 * Checks if `value` is a buffer. 19336 * 19337 * @static 19338 * @memberOf _ 19339 * @since 4.3.0 19340 * @category Lang 19341 * @param {*} value The value to check. 19342 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. 19343 * @example 19344 * 19345 * _.isBuffer(new Buffer(2)); 19346 * // => true 19347 * 19348 * _.isBuffer(new Uint8Array(2)); 19349 * // => false 19350 */ 19351 var isBuffer = nativeIsBuffer || stubFalse; 19352 19353 /** 19354 * Checks if `value` is classified as a `Date` object. 19355 * 19356 * @static 19357 * @memberOf _ 19358 * @since 0.1.0 19359 * @category Lang 19360 * @param {*} value The value to check. 19361 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 19362 * @example 19363 * 19364 * _.isDate(new Date); 19365 * // => true 19366 * 19367 * _.isDate('Mon April 23 2012'); 19368 * // => false 19369 */ 19370 var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; 19371 19372 /** 19373 * Checks if `value` is likely a DOM element. 19374 * 19375 * @static 19376 * @memberOf _ 19377 * @since 0.1.0 19378 * @category Lang 19379 * @param {*} value The value to check. 19380 * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. 19381 * @example 19382 * 19383 * _.isElement(document.body); 19384 * // => true 19385 * 19386 * _.isElement('<body>'); 19387 * // => false 19388 */ 19389 function isElement(value) { 19390 return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value); 19391 } 19392 19393 /** 19394 * Checks if `value` is an empty object, collection, map, or set. 19395 * 19396 * Objects are considered empty if they have no own enumerable string keyed 19397 * properties. 19398 * 19399 * Array-like values such as `arguments` objects, arrays, buffers, strings, or 19400 * jQuery-like collections are considered empty if they have a `length` of `0`. 19401 * Similarly, maps and sets are considered empty if they have a `size` of `0`. 19402 * 19403 * @static 19404 * @memberOf _ 19405 * @since 0.1.0 19406 * @category Lang 19407 * @param {*} value The value to check. 19408 * @returns {boolean} Returns `true` if `value` is empty, else `false`. 19409 * @example 19410 * 19411 * _.isEmpty(null); 19412 * // => true 19413 * 19414 * _.isEmpty(true); 19415 * // => true 19416 * 19417 * _.isEmpty(1); 19418 * // => true 19419 * 19420 * _.isEmpty([1, 2, 3]); 19421 * // => false 19422 * 19423 * _.isEmpty({ 'a': 1 }); 19424 * // => false 19425 */ 19426 function isEmpty(value) { 19427 if (value == null) { 19428 return true; 19429 } 19430 if (isArrayLike(value) && 19431 (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || 19432 isBuffer(value) || isTypedArray(value) || isArguments(value))) { 19433 return !value.length; 19434 } 19435 var tag = getTag(value); 19436 if (tag == mapTag || tag == setTag) { 19437 return !value.size; 19438 } 19439 if (isPrototype(value)) { 19440 return !baseKeys(value).length; 19441 } 19442 for (var key in value) { 19443 if (hasOwnProperty.call(value, key)) { 19444 return false; 19445 } 19446 } 19447 return true; 19448 } 19449 19450 /** 19451 * Performs a deep comparison between two values to determine if they are 19452 * equivalent. 19453 * 19454 * **Note:** This method supports comparing arrays, array buffers, booleans, 19455 * date objects, error objects, maps, numbers, `Object` objects, regexes, 19456 * sets, strings, symbols, and typed arrays. `Object` objects are compared 19457 * by their own, not inherited, enumerable properties. Functions and DOM 19458 * nodes are compared by strict equality, i.e. `===`. 19459 * 19460 * @static 19461 * @memberOf _ 19462 * @since 0.1.0 19463 * @category Lang 19464 * @param {*} value The value to compare. 19465 * @param {*} other The other value to compare. 19466 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 19467 * @example 19468 * 19469 * var object = { 'a': 1 }; 19470 * var other = { 'a': 1 }; 19471 * 19472 * _.isEqual(object, other); 19473 * // => true 19474 * 19475 * object === other; 19476 * // => false 19477 */ 19478 function isEqual(value, other) { 19479 return baseIsEqual(value, other); 19480 } 19481 19482 /** 19483 * This method is like `_.isEqual` except that it accepts `customizer` which 19484 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 19485 * are handled by the method instead. The `customizer` is invoked with up to 19486 * six arguments: (objValue, othValue [, index|key, object, other, stack]). 19487 * 19488 * @static 19489 * @memberOf _ 19490 * @since 4.0.0 19491 * @category Lang 19492 * @param {*} value The value to compare. 19493 * @param {*} other The other value to compare. 19494 * @param {Function} [customizer] The function to customize comparisons. 19495 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 19496 * @example 19497 * 19498 * function isGreeting(value) { 19499 * return /^h(?:i|ello)$/.test(value); 19500 * } 19501 * 19502 * function customizer(objValue, othValue) { 19503 * if (isGreeting(objValue) && isGreeting(othValue)) { 19504 * return true; 19505 * } 19506 * } 19507 * 19508 * var array = ['hello', 'goodbye']; 19509 * var other = ['hi', 'goodbye']; 19510 * 19511 * _.isEqualWith(array, other, customizer); 19512 * // => true 19513 */ 19514 function isEqualWith(value, other, customizer) { 19515 customizer = typeof customizer == 'function' ? customizer : undefined; 19516 var result = customizer ? customizer(value, other) : undefined; 19517 return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result; 19518 } 19519 19520 /** 19521 * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, 19522 * `SyntaxError`, `TypeError`, or `URIError` object. 19523 * 19524 * @static 19525 * @memberOf _ 19526 * @since 3.0.0 19527 * @category Lang 19528 * @param {*} value The value to check. 19529 * @returns {boolean} Returns `true` if `value` is an error object, else `false`. 19530 * @example 19531 * 19532 * _.isError(new Error); 19533 * // => true 19534 * 19535 * _.isError(Error); 19536 * // => false 19537 */ 19538 function isError(value) { 19539 if (!isObjectLike(value)) { 19540 return false;
vendor: 6,607 bytes, lines 19541-19778
19541 } 19542 var tag = baseGetTag(value); 19543 return tag == errorTag || tag == domExcTag || 19544 (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value)); 19545 } 19546 19547 /** 19548 * Checks if `value` is a finite primitive number. 19549 * 19550 * **Note:** This method is based on 19551 * [`Number.isFinite`](https://mdn.io/Number/isFinite). 19552 * 19553 * @static 19554 * @memberOf _ 19555 * @since 0.1.0 19556 * @category Lang 19557 * @param {*} value The value to check. 19558 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. 19559 * @example 19560 * 19561 * _.isFinite(3); 19562 * // => true 19563 * 19564 * _.isFinite(Number.MIN_VALUE); 19565 * // => true 19566 * 19567 * _.isFinite(Infinity); 19568 * // => false 19569 * 19570 * _.isFinite('3'); 19571 * // => false 19572 */ 19573 function isFinite(value) { 19574 return typeof value == 'number' && nativeIsFinite(value); 19575 } 19576 19577 /** 19578 * Checks if `value` is classified as a `Function` object. 19579 * 19580 * @static 19581 * @memberOf _ 19582 * @since 0.1.0 19583 * @category Lang 19584 * @param {*} value The value to check. 19585 * @returns {boolean} Returns `true` if `value` is a function, else `false`. 19586 * @example 19587 * 19588 * _.isFunction(_); 19589 * // => true 19590 * 19591 * _.isFunction(/abc/); 19592 * // => false 19593 */ 19594 function isFunction(value) { 19595 if (!isObject(value)) { 19596 return false; 19597 } 19598 // The use of `Object#toString` avoids issues with the `typeof` operator 19599 // in Safari 9 which returns 'object' for typed arrays and other constructors. 19600 var tag = baseGetTag(value); 19601 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; 19602 } 19603 19604 /** 19605 * Checks if `value` is an integer. 19606 * 19607 * **Note:** This method is based on 19608 * [`Number.isInteger`](https://mdn.io/Number/isInteger). 19609 * 19610 * @static 19611 * @memberOf _ 19612 * @since 4.0.0 19613 * @category Lang 19614 * @param {*} value The value to check. 19615 * @returns {boolean} Returns `true` if `value` is an integer, else `false`. 19616 * @example 19617 * 19618 * _.isInteger(3); 19619 * // => true 19620 * 19621 * _.isInteger(Number.MIN_VALUE); 19622 * // => false 19623 * 19624 * _.isInteger(Infinity); 19625 * // => false 19626 * 19627 * _.isInteger('3'); 19628 * // => false 19629 */ 19630 function isInteger(value) { 19631 return typeof value == 'number' && value == toInteger(value); 19632 } 19633 19634 /** 19635 * Checks if `value` is a valid array-like length. 19636 * 19637 * **Note:** This method is loosely based on 19638 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 19639 * 19640 * @static 19641 * @memberOf _ 19642 * @since 4.0.0 19643 * @category Lang 19644 * @param {*} value The value to check. 19645 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. 19646 * @example 19647 * 19648 * _.isLength(3); 19649 * // => true 19650 * 19651 * _.isLength(Number.MIN_VALUE); 19652 * // => false 19653 * 19654 * _.isLength(Infinity); 19655 * // => false 19656 * 19657 * _.isLength('3'); 19658 * // => false 19659 */ 19660 function isLength(value) { 19661 return typeof value == 'number' && 19662 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; 19663 } 19664 19665 /** 19666 * Checks if `value` is the 19667 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) 19668 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) 19669 * 19670 * @static 19671 * @memberOf _ 19672 * @since 0.1.0 19673 * @category Lang 19674 * @param {*} value The value to check. 19675 * @returns {boolean} Returns `true` if `value` is an object, else `false`. 19676 * @example 19677 * 19678 * _.isObject({}); 19679 * // => true 19680 * 19681 * _.isObject([1, 2, 3]); 19682 * // => true 19683 * 19684 * _.isObject(_.noop); 19685 * // => true 19686 * 19687 * _.isObject(null); 19688 * // => false 19689 */ 19690 function isObject(value) { 19691 var type = typeof value; 19692 return value != null && (type == 'object' || type == 'function'); 19693 } 19694 19695 /** 19696 * Checks if `value` is object-like. A value is object-like if it's not `null` 19697 * and has a `typeof` result of "object". 19698 * 19699 * @static 19700 * @memberOf _ 19701 * @since 4.0.0 19702 * @category Lang 19703 * @param {*} value The value to check. 19704 * @returns {boolean} Returns `true` if `value` is object-like, else `false`. 19705 * @example 19706 * 19707 * _.isObjectLike({}); 19708 * // => true 19709 * 19710 * _.isObjectLike([1, 2, 3]); 19711 * // => true 19712 * 19713 * _.isObjectLike(_.noop); 19714 * // => false 19715 * 19716 * _.isObjectLike(null); 19717 * // => false 19718 */ 19719 function isObjectLike(value) { 19720 return value != null && typeof value == 'object'; 19721 } 19722 19723 /** 19724 * Checks if `value` is classified as a `Map` object. 19725 * 19726 * @static 19727 * @memberOf _ 19728 * @since 4.3.0 19729 * @category Lang 19730 * @param {*} value The value to check. 19731 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 19732 * @example 19733 * 19734 * _.isMap(new Map); 19735 * // => true 19736 * 19737 * _.isMap(new WeakMap); 19738 * // => false 19739 */ 19740 var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; 19741 19742 /** 19743 * Performs a partial deep comparison between `object` and `source` to 19744 * determine if `object` contains equivalent property values. 19745 * 19746 * **Note:** This method is equivalent to `_.matches` when `source` is 19747 * partially applied. 19748 * 19749 * Partial comparisons will match empty array and empty object `source` 19750 * values against any array or object value, respectively. See `_.isEqual` 19751 * for a list of supported value comparisons. 19752 * 19753 * @static 19754 * @memberOf _ 19755 * @since 3.0.0 19756 * @category Lang 19757 * @param {Object} object The object to inspect. 19758 * @param {Object} source The object of property values to match. 19759 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 19760 * @example 19761 * 19762 * var object = { 'a': 1, 'b': 2 }; 19763 * 19764 * _.isMatch(object, { 'b': 2 }); 19765 * // => true 19766 * 19767 * _.isMatch(object, { 'b': 1 }); 19768 * // => false 19769 */ 19770 function isMatch(object, source) { 19771 return object === source || baseIsMatch(object, source, getMatchData(source)); 19772 } 19773 19774 /** 19775 * This method is like `_.isMatch` except that it accepts `customizer` which 19776 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 19777 * are handled by the method instead. The `customizer` is invoked with five 19778 * arguments: (objValue, srcValue, index|key, object, source).
vendor: 12,241 bytes, lines 19779-20244
19779 * 19780 * @static 19781 * @memberOf _ 19782 * @since 4.0.0 19783 * @category Lang 19784 * @param {Object} object The object to inspect. 19785 * @param {Object} source The object of property values to match. 19786 * @param {Function} [customizer] The function to customize comparisons. 19787 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 19788 * @example 19789 * 19790 * function isGreeting(value) { 19791 * return /^h(?:i|ello)$/.test(value); 19792 * } 19793 * 19794 * function customizer(objValue, srcValue) { 19795 * if (isGreeting(objValue) && isGreeting(srcValue)) { 19796 * return true; 19797 * } 19798 * } 19799 * 19800 * var object = { 'greeting': 'hello' }; 19801 * var source = { 'greeting': 'hi' }; 19802 * 19803 * _.isMatchWith(object, source, customizer); 19804 * // => true 19805 */ 19806 function isMatchWith(object, source, customizer) { 19807 customizer = typeof customizer == 'function' ? customizer : undefined; 19808 return baseIsMatch(object, source, getMatchData(source), customizer); 19809 } 19810 19811 /** 19812 * Checks if `value` is `NaN`. 19813 * 19814 * **Note:** This method is based on 19815 * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as 19816 * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for 19817 * `undefined` and other non-number values. 19818 * 19819 * @static 19820 * @memberOf _ 19821 * @since 0.1.0 19822 * @category Lang 19823 * @param {*} value The value to check. 19824 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 19825 * @example 19826 * 19827 * _.isNaN(NaN); 19828 * // => true 19829 * 19830 * _.isNaN(new Number(NaN)); 19831 * // => true 19832 * 19833 * isNaN(undefined); 19834 * // => true 19835 * 19836 * _.isNaN(undefined); 19837 * // => false 19838 */ 19839 function isNaN(value) { 19840 // An `NaN` primitive is the only value that is not equal to itself. 19841 // Perform the `toStringTag` check first to avoid errors with some 19842 // ActiveX objects in IE. 19843 return isNumber(value) && value != +value; 19844 } 19845 19846 /** 19847 * Checks if `value` is a pristine native function. 19848 * 19849 * **Note:** This method can't reliably detect native functions in the presence 19850 * of the core-js package because core-js circumvents this kind of detection. 19851 * Despite multiple requests, the core-js maintainer has made it clear: any 19852 * attempt to fix the detection will be obstructed. As a result, we're left 19853 * with little choice but to throw an error. Unfortunately, this also affects 19854 * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill), 19855 * which rely on core-js. 19856 * 19857 * @static 19858 * @memberOf _ 19859 * @since 3.0.0 19860 * @category Lang 19861 * @param {*} value The value to check. 19862 * @returns {boolean} Returns `true` if `value` is a native function, 19863 * else `false`. 19864 * @example 19865 * 19866 * _.isNative(Array.prototype.push); 19867 * // => true 19868 * 19869 * _.isNative(_); 19870 * // => false 19871 */ 19872 function isNative(value) { 19873 if (isMaskable(value)) { 19874 throw new Error(CORE_ERROR_TEXT); 19875 } 19876 return baseIsNative(value); 19877 } 19878 19879 /** 19880 * Checks if `value` is `null`. 19881 * 19882 * @static 19883 * @memberOf _ 19884 * @since 0.1.0 19885 * @category Lang 19886 * @param {*} value The value to check. 19887 * @returns {boolean} Returns `true` if `value` is `null`, else `false`. 19888 * @example 19889 * 19890 * _.isNull(null); 19891 * // => true 19892 * 19893 * _.isNull(void 0); 19894 * // => false 19895 */ 19896 function isNull(value) { 19897 return value === null; 19898 } 19899 19900 /** 19901 * Checks if `value` is `null` or `undefined`. 19902 * 19903 * @static 19904 * @memberOf _ 19905 * @since 4.0.0 19906 * @category Lang 19907 * @param {*} value The value to check. 19908 * @returns {boolean} Returns `true` if `value` is nullish, else `false`. 19909 * @example 19910 * 19911 * _.isNil(null); 19912 * // => true 19913 * 19914 * _.isNil(void 0); 19915 * // => true 19916 * 19917 * _.isNil(NaN); 19918 * // => false 19919 */ 19920 function isNil(value) { 19921 return value == null; 19922 } 19923 19924 /** 19925 * Checks if `value` is classified as a `Number` primitive or object. 19926 * 19927 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are 19928 * classified as numbers, use the `_.isFinite` method. 19929 * 19930 * @static 19931 * @memberOf _ 19932 * @since 0.1.0 19933 * @category Lang 19934 * @param {*} value The value to check. 19935 * @returns {boolean} Returns `true` if `value` is a number, else `false`. 19936 * @example 19937 * 19938 * _.isNumber(3); 19939 * // => true 19940 * 19941 * _.isNumber(Number.MIN_VALUE); 19942 * // => true 19943 * 19944 * _.isNumber(Infinity); 19945 * // => true 19946 * 19947 * _.isNumber('3'); 19948 * // => false 19949 */ 19950 function isNumber(value) { 19951 return typeof value == 'number' || 19952 (isObjectLike(value) && baseGetTag(value) == numberTag); 19953 } 19954 19955 /** 19956 * Checks if `value` is a plain object, that is, an object created by the 19957 * `Object` constructor or one with a `[[Prototype]]` of `null`. 19958 * 19959 * @static 19960 * @memberOf _ 19961 * @since 0.8.0 19962 * @category Lang 19963 * @param {*} value The value to check. 19964 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. 19965 * @example 19966 * 19967 * function Foo() { 19968 * this.a = 1; 19969 * } 19970 * 19971 * _.isPlainObject(new Foo); 19972 * // => false 19973 * 19974 * _.isPlainObject([1, 2, 3]); 19975 * // => false 19976 * 19977 * _.isPlainObject({ 'x': 0, 'y': 0 }); 19978 * // => true 19979 * 19980 * _.isPlainObject(Object.create(null)); 19981 * // => true 19982 */ 19983 function isPlainObject(value) { 19984 if (!isObjectLike(value) || baseGetTag(value) != objectTag) { 19985 return false; 19986 } 19987 var proto = getPrototype(value); 19988 if (proto === null) { 19989 return true; 19990 } 19991 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; 19992 return typeof Ctor == 'function' && Ctor instanceof Ctor && 19993 funcToString.call(Ctor) == objectCtorString; 19994 } 19995 19996 /** 19997 * Checks if `value` is classified as a `RegExp` object. 19998 * 19999 * @static 20000 * @memberOf _ 20001 * @since 0.1.0 20002 * @category Lang 20003 * @param {*} value The value to check. 20004 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 20005 * @example 20006 * 20007 * _.isRegExp(/abc/); 20008 * // => true 20009 * 20010 * _.isRegExp('/abc/'); 20011 * // => false 20012 */ 20013 var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; 20014 20015 /** 20016 * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 20017 * double precision number which isn't the result of a rounded unsafe integer. 20018 * 20019 * **Note:** This method is based on 20020 * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). 20021 * 20022 * @static 20023 * @memberOf _ 20024 * @since 4.0.0 20025 * @category Lang 20026 * @param {*} value The value to check. 20027 * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. 20028 * @example 20029 * 20030 * _.isSafeInteger(3); 20031 * // => true 20032 * 20033 * _.isSafeInteger(Number.MIN_VALUE); 20034 * // => false 20035 * 20036 * _.isSafeInteger(Infinity); 20037 * // => false 20038 * 20039 * _.isSafeInteger('3'); 20040 * // => false 20041 */ 20042 function isSafeInteger(value) { 20043 return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER; 20044 } 20045 20046 /** 20047 * Checks if `value` is classified as a `Set` object. 20048 * 20049 * @static 20050 * @memberOf _ 20051 * @since 4.3.0 20052 * @category Lang 20053 * @param {*} value The value to check. 20054 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 20055 * @example 20056 * 20057 * _.isSet(new Set); 20058 * // => true 20059 * 20060 * _.isSet(new WeakSet); 20061 * // => false 20062 */ 20063 var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; 20064 20065 /** 20066 * Checks if `value` is classified as a `String` primitive or object. 20067 * 20068 * @static 20069 * @since 0.1.0 20070 * @memberOf _ 20071 * @category Lang 20072 * @param {*} value The value to check. 20073 * @returns {boolean} Returns `true` if `value` is a string, else `false`. 20074 * @example 20075 * 20076 * _.isString('abc'); 20077 * // => true 20078 * 20079 * _.isString(1); 20080 * // => false 20081 */ 20082 function isString(value) { 20083 return typeof value == 'string' || 20084 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); 20085 } 20086 20087 /** 20088 * Checks if `value` is classified as a `Symbol` primitive or object. 20089 * 20090 * @static 20091 * @memberOf _ 20092 * @since 4.0.0 20093 * @category Lang 20094 * @param {*} value The value to check. 20095 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. 20096 * @example 20097 * 20098 * _.isSymbol(Symbol.iterator); 20099 * // => true 20100 * 20101 * _.isSymbol('abc'); 20102 * // => false 20103 */ 20104 function isSymbol(value) { 20105 return typeof value == 'symbol' || 20106 (isObjectLike(value) && baseGetTag(value) == symbolTag); 20107 } 20108 20109 /** 20110 * Checks if `value` is classified as a typed array. 20111 * 20112 * @static 20113 * @memberOf _ 20114 * @since 3.0.0 20115 * @category Lang 20116 * @param {*} value The value to check. 20117 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 20118 * @example 20119 * 20120 * _.isTypedArray(new Uint8Array); 20121 * // => true 20122 * 20123 * _.isTypedArray([]); 20124 * // => false 20125 */ 20126 var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; 20127 20128 /** 20129 * Checks if `value` is `undefined`. 20130 * 20131 * @static 20132 * @since 0.1.0 20133 * @memberOf _ 20134 * @category Lang 20135 * @param {*} value The value to check. 20136 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. 20137 * @example 20138 * 20139 * _.isUndefined(void 0); 20140 * // => true 20141 * 20142 * _.isUndefined(null); 20143 * // => false 20144 */ 20145 function isUndefined(value) { 20146 return value === undefined; 20147 } 20148 20149 /** 20150 * Checks if `value` is classified as a `WeakMap` object. 20151 * 20152 * @static 20153 * @memberOf _ 20154 * @since 4.3.0 20155 * @category Lang 20156 * @param {*} value The value to check. 20157 * @returns {boolean} Returns `true` if `value` is a weak map, else `false`. 20158 * @example 20159 * 20160 * _.isWeakMap(new WeakMap); 20161 * // => true 20162 * 20163 * _.isWeakMap(new Map); 20164 * // => false 20165 */ 20166 function isWeakMap(value) { 20167 return isObjectLike(value) && getTag(value) == weakMapTag; 20168 } 20169 20170 /** 20171 * Checks if `value` is classified as a `WeakSet` object. 20172 * 20173 * @static 20174 * @memberOf _ 20175 * @since 4.3.0 20176 * @category Lang 20177 * @param {*} value The value to check. 20178 * @returns {boolean} Returns `true` if `value` is a weak set, else `false`. 20179 * @example 20180 * 20181 * _.isWeakSet(new WeakSet); 20182 * // => true 20183 * 20184 * _.isWeakSet(new Set); 20185 * // => false 20186 */ 20187 function isWeakSet(value) { 20188 return isObjectLike(value) && baseGetTag(value) == weakSetTag; 20189 } 20190 20191 /** 20192 * Checks if `value` is less than `other`. 20193 * 20194 * @static 20195 * @memberOf _ 20196 * @since 3.9.0 20197 * @category Lang 20198 * @param {*} value The value to compare. 20199 * @param {*} other The other value to compare. 20200 * @returns {boolean} Returns `true` if `value` is less than `other`, 20201 * else `false`. 20202 * @see _.gt 20203 * @example 20204 * 20205 * _.lt(1, 3); 20206 * // => true 20207 * 20208 * _.lt(3, 3); 20209 * // => false 20210 * 20211 * _.lt(3, 1); 20212 * // => false 20213 */ 20214 var lt = createRelationalOperation(baseLt); 20215 20216 /** 20217 * Checks if `value` is less than or equal to `other`. 20218 * 20219 * @static 20220 * @memberOf _ 20221 * @since 3.9.0 20222 * @category Lang 20223 * @param {*} value The value to compare. 20224 * @param {*} other The other value to compare. 20225 * @returns {boolean} Returns `true` if `value` is less than or equal to 20226 * `other`, else `false`. 20227 * @see _.gte 20228 * @example 20229 * 20230 * _.lte(1, 3); 20231 * // => true 20232 * 20233 * _.lte(3, 3); 20234 * // => true 20235 * 20236 * _.lte(3, 1); 20237 * // => false 20238 */ 20239 var lte = createRelationalOperation(function(value, other) { 20240 return value <= other; 20241 }); 20242 20243 /** 20244 * Converts `value` to an array.
vendor: 4,495 bytes, lines 20245-20426
20245 * 20246 * @static 20247 * @since 0.1.0 20248 * @memberOf _ 20249 * @category Lang 20250 * @param {*} value The value to convert. 20251 * @returns {Array} Returns the converted array. 20252 * @example 20253 * 20254 * _.toArray({ 'a': 1, 'b': 2 }); 20255 * // => [1, 2] 20256 * 20257 * _.toArray('abc'); 20258 * // => ['a', 'b', 'c'] 20259 * 20260 * _.toArray(1); 20261 * // => [] 20262 * 20263 * _.toArray(null); 20264 * // => [] 20265 */ 20266 function toArray(value) { 20267 if (!value) { 20268 return []; 20269 } 20270 if (isArrayLike(value)) { 20271 return isString(value) ? stringToArray(value) : copyArray(value); 20272 } 20273 if (symIterator && value[symIterator]) { 20274 return iteratorToArray(value[symIterator]()); 20275 } 20276 var tag = getTag(value), 20277 func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values); 20278 20279 return func(value); 20280 } 20281 20282 /** 20283 * Converts `value` to a finite number. 20284 * 20285 * @static 20286 * @memberOf _ 20287 * @since 4.12.0 20288 * @category Lang 20289 * @param {*} value The value to convert. 20290 * @returns {number} Returns the converted number. 20291 * @example 20292 * 20293 * _.toFinite(3.2); 20294 * // => 3.2 20295 * 20296 * _.toFinite(Number.MIN_VALUE); 20297 * // => 5e-324 20298 * 20299 * _.toFinite(Infinity); 20300 * // => 1.7976931348623157e+308 20301 * 20302 * _.toFinite('3.2'); 20303 * // => 3.2 20304 */ 20305 function toFinite(value) { 20306 if (!value) { 20307 return value === 0 ? value : 0; 20308 } 20309 value = toNumber(value); 20310 if (value === INFINITY || value === -INFINITY) { 20311 var sign = (value < 0 ? -1 : 1); 20312 return sign * MAX_INTEGER; 20313 } 20314 return value === value ? value : 0; 20315 } 20316 20317 /** 20318 * Converts `value` to an integer. 20319 * 20320 * **Note:** This method is loosely based on 20321 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). 20322 * 20323 * @static 20324 * @memberOf _ 20325 * @since 4.0.0 20326 * @category Lang 20327 * @param {*} value The value to convert. 20328 * @returns {number} Returns the converted integer. 20329 * @example 20330 * 20331 * _.toInteger(3.2); 20332 * // => 3 20333 * 20334 * _.toInteger(Number.MIN_VALUE); 20335 * // => 0 20336 * 20337 * _.toInteger(Infinity); 20338 * // => 1.7976931348623157e+308 20339 * 20340 * _.toInteger('3.2'); 20341 * // => 3 20342 */ 20343 function toInteger(value) { 20344 var result = toFinite(value), 20345 remainder = result % 1; 20346 20347 return result === result ? (remainder ? result - remainder : result) : 0; 20348 } 20349 20350 /** 20351 * Converts `value` to an integer suitable for use as the length of an 20352 * array-like object. 20353 * 20354 * **Note:** This method is based on 20355 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 20356 * 20357 * @static 20358 * @memberOf _ 20359 * @since 4.0.0 20360 * @category Lang 20361 * @param {*} value The value to convert. 20362 * @returns {number} Returns the converted integer. 20363 * @example 20364 * 20365 * _.toLength(3.2); 20366 * // => 3 20367 * 20368 * _.toLength(Number.MIN_VALUE); 20369 * // => 0 20370 * 20371 * _.toLength(Infinity); 20372 * // => 4294967295 20373 * 20374 * _.toLength('3.2'); 20375 * // => 3 20376 */ 20377 function toLength(value) { 20378 return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0; 20379 } 20380 20381 /** 20382 * Converts `value` to a number. 20383 * 20384 * @static 20385 * @memberOf _ 20386 * @since 4.0.0 20387 * @category Lang 20388 * @param {*} value The value to process. 20389 * @returns {number} Returns the number. 20390 * @example 20391 * 20392 * _.toNumber(3.2); 20393 * // => 3.2 20394 * 20395 * _.toNumber(Number.MIN_VALUE); 20396 * // => 5e-324 20397 * 20398 * _.toNumber(Infinity); 20399 * // => Infinity 20400 * 20401 * _.toNumber('3.2'); 20402 * // => 3.2 20403 */ 20404 function toNumber(value) { 20405 if (typeof value == 'number') { 20406 return value; 20407 } 20408 if (isSymbol(value)) { 20409 return NAN; 20410 } 20411 if (isObject(value)) { 20412 var other = typeof value.valueOf == 'function' ? value.valueOf() : value; 20413 value = isObject(other) ? (other + '') : other; 20414 } 20415 if (typeof value != 'string') { 20416 return value === 0 ? value : +value; 20417 } 20418 value = value.replace(reTrim, ''); 20419 var isBinary = reIsBinary.test(value); 20420 return (isBinary || reIsOctal.test(value)) 20421 ? freeParseInt(value.slice(2), isBinary ? 2 : 8) 20422 : (reIsBadHex.test(value) ? NAN : +value); 20423 } 20424 20425 /** 20426 * Converts `value` to a plain object flattening inherited enumerable str
vendor: 7,271 bytes, lines 20426-20674
20426ing 20427 * keyed properties of `value` to own properties of the plain object. 20428 * 20429 * @static 20430 * @memberOf _ 20431 * @since 3.0.0 20432 * @category Lang 20433 * @param {*} value The value to convert. 20434 * @returns {Object} Returns the converted plain object. 20435 * @example 20436 * 20437 * function Foo() { 20438 * this.b = 2; 20439 * } 20440 * 20441 * Foo.prototype.c = 3; 20442 * 20443 * _.assign({ 'a': 1 }, new Foo); 20444 * // => { 'a': 1, 'b': 2 } 20445 * 20446 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); 20447 * // => { 'a': 1, 'b': 2, 'c': 3 } 20448 */ 20449 function toPlainObject(value) { 20450 return copyObject(value, keysIn(value)); 20451 } 20452 20453 /** 20454 * Converts `value` to a safe integer. A safe integer can be compared and 20455 * represented correctly. 20456 * 20457 * @static 20458 * @memberOf _ 20459 * @since 4.0.0 20460 * @category Lang 20461 * @param {*} value The value to convert. 20462 * @returns {number} Returns the converted integer. 20463 * @example 20464 * 20465 * _.toSafeInteger(3.2); 20466 * // => 3 20467 * 20468 * _.toSafeInteger(Number.MIN_VALUE); 20469 * // => 0 20470 * 20471 * _.toSafeInteger(Infinity); 20472 * // => 9007199254740991 20473 * 20474 * _.toSafeInteger('3.2'); 20475 * // => 3 20476 */ 20477 function toSafeInteger(value) { 20478 return value 20479 ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) 20480 : (value === 0 ? value : 0); 20481 } 20482 20483 /** 20484 * Converts `value` to a string. An empty string is returned for `null` 20485 * and `undefined` values. The sign of `-0` is preserved. 20486 * 20487 * @static 20488 * @memberOf _ 20489 * @since 4.0.0 20490 * @category Lang 20491 * @param {*} value The value to convert. 20492 * @returns {string} Returns the converted string. 20493 * @example 20494 * 20495 * _.toString(null); 20496 * // => '' 20497 * 20498 * _.toString(-0); 20499 * // => '-0' 20500 * 20501 * _.toString([1, 2, 3]); 20502 * // => '1,2,3' 20503 */ 20504 function toString(value) { 20505 return value == null ? '' : baseToString(value); 20506 } 20507 20508 /*------------------------------------------------------------------------*/ 20509 20510 /** 20511 * Assigns own enumerable string keyed properties of source objects to the 20512 * destination object. Source objects are applied from left to right. 20513 * Subsequent sources overwrite property assignments of previous sources. 20514 * 20515 * **Note:** This method mutates `object` and is loosely based on 20516 * [`Object.assign`](https://mdn.io/Object/assign). 20517 * 20518 * @static 20519 * @memberOf _ 20520 * @since 0.10.0 20521 * @category Object 20522 * @param {Object} object The destination object. 20523 * @param {...Object} [sources] The source objects. 20524 * @returns {Object} Returns `object`. 20525 * @see _.assignIn 20526 * @example 20527 * 20528 * function Foo() { 20529 * this.a = 1; 20530 * } 20531 * 20532 * function Bar() { 20533 * this.c = 3; 20534 * } 20535 * 20536 * Foo.prototype.b = 2; 20537 * Bar.prototype.d = 4; 20538 * 20539 * _.assign({ 'a': 0 }, new Foo, new Bar); 20540 * // => { 'a': 1, 'c': 3 } 20541 */ 20542 var assign = createAssigner(function(object, source) { 20543 if (isPrototype(source) || isArrayLike(source)) { 20544 copyObject(source, keys(source), object); 20545 return; 20546 } 20547 for (var key in source) { 20548 if (hasOwnProperty.call(source, key)) { 20549 assignValue(object, key, source[key]); 20550 } 20551 } 20552 }); 20553 20554 /** 20555 * This method is like `_.assign` except that it iterates over own and 20556 * inherited source properties. 20557 * 20558 * **Note:** This method mutates `object`. 20559 * 20560 * @static 20561 * @memberOf _ 20562 * @since 4.0.0 20563 * @alias extend 20564 * @category Object 20565 * @param {Object} object The destination object. 20566 * @param {...Object} [sources] The source objects. 20567 * @returns {Object} Returns `object`. 20568 * @see _.assign 20569 * @example 20570 * 20571 * function Foo() { 20572 * this.a = 1; 20573 * } 20574 * 20575 * function Bar() { 20576 * this.c = 3; 20577 * } 20578 * 20579 * Foo.prototype.b = 2; 20580 * Bar.prototype.d = 4; 20581 * 20582 * _.assignIn({ 'a': 0 }, new Foo, new Bar); 20583 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } 20584 */ 20585 var assignIn = createAssigner(function(object, source) { 20586 copyObject(source, keysIn(source), object); 20587 }); 20588 20589 /** 20590 * This method is like `_.assignIn` except that it accepts `customizer` 20591 * which is invoked to produce the assigned values. If `customizer` returns 20592 * `undefined`, assignment is handled by the method instead. The `customizer` 20593 * is invoked with five arguments: (objValue, srcValue, key, object, source). 20594 * 20595 * **Note:** This method mutates `object`. 20596 * 20597 * @static 20598 * @memberOf _ 20599 * @since 4.0.0 20600 * @alias extendWith 20601 * @category Object 20602 * @param {Object} object The destination object. 20603 * @param {...Object} sources The source objects. 20604 * @param {Function} [customizer] The function to customize assigned values. 20605 * @returns {Object} Returns `object`. 20606 * @see _.assignWith 20607 * @example 20608 * 20609 * function customizer(objValue, srcValue) { 20610 * return _.isUndefined(objValue) ? srcValue : objValue; 20611 * } 20612 * 20613 * var defaults = _.partialRight(_.assignInWith, customizer); 20614 * 20615 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 20616 * // => { 'a': 1, 'b': 2 } 20617 */ 20618 var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { 20619 copyObject(source, keysIn(source), object, customizer); 20620 }); 20621 20622 /** 20623 * This method is like `_.assign` except that it accepts `customizer` 20624 * which is invoked to produce the assigned values. If `customizer` returns 20625 * `undefined`, assignment is handled by the method instead. The `customizer` 20626 * is invoked with five arguments: (objValue, srcValue, key, object, source). 20627 * 20628 * **Note:** This method mutates `object`. 20629 * 20630 * @static 20631 * @memberOf _ 20632 * @since 4.0.0 20633 * @category Object 20634 * @param {Object} object The destination object. 20635 * @param {...Object} sources The source objects. 20636 * @param {Function} [customizer] The function to customize assigned values. 20637 * @returns {Object} Returns `object`. 20638 * @see _.assignInWith 20639 * @example 20640 * 20641 * function customizer(objValue, srcValue) { 20642 * return _.isUndefined(objValue) ? srcValue : objValue; 20643 * } 20644 * 20645 * var defaults = _.partialRight(_.assignWith, customizer); 20646 * 20647 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 20648 * // => { 'a': 1, 'b': 2 } 20649 */ 20650 var assignWith = createAssigner(function(object, source, srcIndex, customizer) { 20651 copyObject(source, keys(source), object, customizer); 20652 }); 20653 20654 /** 20655 * Creates an array of values corresponding to `paths` of `object`. 20656 * 20657 * @static 20658 * @memberOf _ 20659 * @since 1.0.0 20660 * @category Object 20661 * @param {Object} object The object to iterate over. 20662 * @param {...(string|string[])} [paths] The property paths to pick. 20663 * @returns {Array} Returns the picked values. 20664 * @example 20665 * 20666 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 20667 * 20668 * _.at(object, ['a[0].b.c', 'a[1]']); 20669 * // => [3, 4] 20670 */ 20671 var at = flatRest(baseAt); 20672 20673 /** 20674 * Creates an object that inherits from the `prototype` object. If a
vendor: 13,619 bytes, lines 20675-21139
20675 * `properties` object is given, its own enumerable string keyed properties 20676 * are assigned to the created object. 20677 * 20678 * @static 20679 * @memberOf _ 20680 * @since 2.3.0 20681 * @category Object 20682 * @param {Object} prototype The object to inherit from. 20683 * @param {Object} [properties] The properties to assign to the object. 20684 * @returns {Object} Returns the new object. 20685 * @example 20686 * 20687 * function Shape() { 20688 * this.x = 0; 20689 * this.y = 0; 20690 * } 20691 * 20692 * function Circle() { 20693 * Shape.call(this); 20694 * } 20695 * 20696 * Circle.prototype = _.create(Shape.prototype, { 20697 * 'constructor': Circle 20698 * }); 20699 * 20700 * var circle = new Circle; 20701 * circle instanceof Circle; 20702 * // => true 20703 * 20704 * circle instanceof Shape; 20705 * // => true 20706 */ 20707 function create(prototype, properties) { 20708 var result = baseCreate(prototype); 20709 return properties == null ? result : baseAssign(result, properties); 20710 } 20711 20712 /** 20713 * Assigns own and inherited enumerable string keyed properties of source 20714 * objects to the destination object for all destination properties that 20715 * resolve to `undefined`. Source objects are applied from left to right. 20716 * Once a property is set, additional values of the same property are ignored. 20717 * 20718 * **Note:** This method mutates `object`. 20719 * 20720 * @static 20721 * @since 0.1.0 20722 * @memberOf _ 20723 * @category Object 20724 * @param {Object} object The destination object. 20725 * @param {...Object} [sources] The source objects. 20726 * @returns {Object} Returns `object`. 20727 * @see _.defaultsDeep 20728 * @example 20729 * 20730 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 20731 * // => { 'a': 1, 'b': 2 } 20732 */ 20733 var defaults = baseRest(function(object, sources) { 20734 object = Object(object); 20735 20736 var index = -1; 20737 var length = sources.length; 20738 var guard = length > 2 ? sources[2] : undefined; 20739 20740 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 20741 length = 1; 20742 } 20743 20744 while (++index < length) { 20745 var source = sources[index]; 20746 var props = keysIn(source); 20747 var propsIndex = -1; 20748 var propsLength = props.length; 20749 20750 while (++propsIndex < propsLength) { 20751 var key = props[propsIndex]; 20752 var value = object[key]; 20753 20754 if (value === undefined || 20755 (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) { 20756 object[key] = source[key]; 20757 } 20758 } 20759 } 20760 20761 return object; 20762 }); 20763 20764 /** 20765 * This method is like `_.defaults` except that it recursively assigns 20766 * default properties. 20767 * 20768 * **Note:** This method mutates `object`. 20769 * 20770 * @static 20771 * @memberOf _ 20772 * @since 3.10.0 20773 * @category Object 20774 * @param {Object} object The destination object. 20775 * @param {...Object} [sources] The source objects. 20776 * @returns {Object} Returns `object`. 20777 * @see _.defaults 20778 * @example 20779 * 20780 * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); 20781 * // => { 'a': { 'b': 2, 'c': 3 } } 20782 */ 20783 var defaultsDeep = baseRest(function(args) { 20784 args.push(undefined, customDefaultsMerge); 20785 return apply(mergeWith, undefined, args); 20786 }); 20787 20788 /** 20789 * This method is like `_.find` except that it returns the key of the first 20790 * element `predicate` returns truthy for instead of the element itself. 20791 * 20792 * @static 20793 * @memberOf _ 20794 * @since 1.1.0 20795 * @category Object 20796 * @param {Object} object The object to inspect. 20797 * @param {Function} [predicate=_.identity] The function invoked per iteration. 20798 * @returns {string|undefined} Returns the key of the matched element, 20799 * else `undefined`. 20800 * @example 20801 * 20802 * var users = { 20803 * 'barney': { 'age': 36, 'active': true }, 20804 * 'fred': { 'age': 40, 'active': false }, 20805 * 'pebbles': { 'age': 1, 'active': true } 20806 * }; 20807 * 20808 * _.findKey(users, function(o) { return o.age < 40; }); 20809 * // => 'barney' (iteration order is not guaranteed) 20810 * 20811 * // The `_.matches` iteratee shorthand. 20812 * _.findKey(users, { 'age': 1, 'active': true }); 20813 * // => 'pebbles' 20814 * 20815 * // The `_.matchesProperty` iteratee shorthand. 20816 * _.findKey(users, ['active', false]); 20817 * // => 'fred' 20818 * 20819 * // The `_.property` iteratee shorthand. 20820 * _.findKey(users, 'active'); 20821 * // => 'barney' 20822 */ 20823 function findKey(object, predicate) { 20824 return baseFindKey(object, getIteratee(predicate, 3), baseForOwn); 20825 } 20826 20827 /** 20828 * This method is like `_.findKey` except that it iterates over elements of 20829 * a collection in the opposite order. 20830 * 20831 * @static 20832 * @memberOf _ 20833 * @since 2.0.0 20834 * @category Object 20835 * @param {Object} object The object to inspect. 20836 * @param {Function} [predicate=_.identity] The function invoked per iteration. 20837 * @returns {string|undefined} Returns the key of the matched element, 20838 * else `undefined`. 20839 * @example 20840 * 20841 * var users = { 20842 * 'barney': { 'age': 36, 'active': true }, 20843 * 'fred': { 'age': 40, 'active': false }, 20844 * 'pebbles': { 'age': 1, 'active': true } 20845 * }; 20846 * 20847 * _.findLastKey(users, function(o) { return o.age < 40; }); 20848 * // => returns 'pebbles' assuming `_.findKey` returns 'barney' 20849 * 20850 * // The `_.matches` iteratee shorthand. 20851 * _.findLastKey(users, { 'age': 36, 'active': true }); 20852 * // => 'barney' 20853 * 20854 * // The `_.matchesProperty` iteratee shorthand. 20855 * _.findLastKey(users, ['active', false]); 20856 * // => 'fred' 20857 * 20858 * // The `_.property` iteratee shorthand. 20859 * _.findLastKey(users, 'active'); 20860 * // => 'pebbles' 20861 */ 20862 function findLastKey(object, predicate) { 20863 return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight); 20864 } 20865 20866 /** 20867 * Iterates over own and inherited enumerable string keyed properties of an 20868 * object and invokes `iteratee` for each property. The iteratee is invoked 20869 * with three arguments: (value, key, object). Iteratee functions may exit 20870 * iteration early by explicitly returning `false`. 20871 * 20872 * @static 20873 * @memberOf _ 20874 * @since 0.3.0 20875 * @category Object 20876 * @param {Object} object The object to iterate over. 20877 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 20878 * @returns {Object} Returns `object`. 20879 * @see _.forInRight 20880 * @example 20881 * 20882 * function Foo() { 20883 * this.a = 1; 20884 * this.b = 2; 20885 * } 20886 * 20887 * Foo.prototype.c = 3; 20888 * 20889 * _.forIn(new Foo, function(value, key) { 20890 * console.log(key); 20891 * }); 20892 * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). 20893 */ 20894 function forIn(object, iteratee) { 20895 return object == null 20896 ? object 20897 : baseFor(object, getIteratee(iteratee, 3), keysIn); 20898 } 20899 20900 /** 20901 * This method is like `_.forIn` except that it iterates over properties of 20902 * `object` in the opposite order. 20903 * 20904 * @static 20905 * @memberOf _ 20906 * @since 2.0.0 20907 * @category Object 20908 * @param {Object} object The object to iterate over. 20909 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 20910 * @returns {Object} Returns `object`. 20911 * @see _.forIn 20912 * @example 20913 * 20914 * function Foo() { 20915 * this.a = 1; 20916 * this.b = 2; 20917 * } 20918 * 20919 * Foo.prototype.c = 3; 20920 * 20921 * _.forInRight(new Foo, function(value, key) { 20922 * console.log(key); 20923 * }); 20924 * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. 20925 */ 20926 function forInRight(object, iteratee) { 20927 return object == null 20928 ? object 20929 : baseForRight(object, getIteratee(iteratee, 3), keysIn); 20930 } 20931 20932 /** 20933 * Iterates over own enumerable string keyed properties of an object and 20934 * invokes `iteratee` for each property. The iteratee is invoked with three 20935 * arguments: (value, key, object). Iteratee functions may exit iteration 20936 * early by explicitly returning `false`. 20937 * 20938 * @static 20939 * @memberOf _ 20940 * @since 0.3.0 20941 * @category Object 20942 * @param {Object} object The object to iterate over. 20943 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 20944 * @returns {Object} Returns `object`. 20945 * @see _.forOwnRight 20946 * @example 20947 * 20948 * function Foo() { 20949 * this.a = 1; 20950 * this.b = 2; 20951 * } 20952 * 20953 * Foo.prototype.c = 3; 20954 * 20955 * _.forOwn(new Foo, function(value, key) { 20956 * console.log(key); 20957 * }); 20958 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 20959 */ 20960 function forOwn(object, iteratee) { 20961 return object && baseForOwn(object, getIteratee(iteratee, 3)); 20962 } 20963 20964 /** 20965 * This method is like `_.forOwn` except that it iterates over properties of 20966 * `object` in the opposite order. 20967 * 20968 * @static 20969 * @memberOf _ 20970 * @since 2.0.0 20971 * @category Object 20972 * @param {Object} object The object to iterate over. 20973 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 20974 * @returns {Object} Returns `object`. 20975 * @see _.forOwn 20976 * @example 20977 * 20978 * function Foo() { 20979 * this.a = 1; 20980 * this.b = 2; 20981 * } 20982 * 20983 * Foo.prototype.c = 3; 20984 * 20985 * _.forOwnRight(new Foo, function(value, key) { 20986 * console.log(key); 20987 * }); 20988 * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. 20989 */ 20990 function forOwnRight(object, iteratee) { 20991 return object && baseForOwnRight(object, getIteratee(iteratee, 3)); 20992 } 20993 20994 /** 20995 * Creates an array of function property names from own enumerable properties 20996 * of `object`. 20997 * 20998 * @static 20999 * @since 0.1.0 21000 * @memberOf _ 21001 * @category Object 21002 * @param {Object} object The object to inspect. 21003 * @returns {Array} Returns the function names. 21004 * @see _.functionsIn 21005 * @example 21006 * 21007 * function Foo() { 21008 * this.a = _.constant('a'); 21009 * this.b = _.constant('b'); 21010 * } 21011 * 21012 * Foo.prototype.c = _.constant('c'); 21013 * 21014 * _.functions(new Foo); 21015 * // => ['a', 'b'] 21016 */ 21017 function functions(object) { 21018 return object == null ? [] : baseFunctions(object, keys(object)); 21019 } 21020 21021 /** 21022 * Creates an array of function property names from own and inherited 21023 * enumerable properties of `object`. 21024 * 21025 * @static 21026 * @memberOf _ 21027 * @since 4.0.0 21028 * @category Object 21029 * @param {Object} object The object to inspect. 21030 * @returns {Array} Returns the function names. 21031 * @see _.functions 21032 * @example 21033 * 21034 * function Foo() { 21035 * this.a = _.constant('a'); 21036 * this.b = _.constant('b'); 21037 * } 21038 * 21039 * Foo.prototype.c = _.constant('c'); 21040 * 21041 * _.functionsIn(new Foo); 21042 * // => ['a', 'b', 'c'] 21043 */ 21044 function functionsIn(object) { 21045 return object == null ? [] : baseFunctions(object, keysIn(object)); 21046 } 21047 21048 /** 21049 * Gets the value at `path` of `object`. If the resolved value is 21050 * `undefined`, the `defaultValue` is returned in its place. 21051 * 21052 * @static 21053 * @memberOf _ 21054 * @since 3.7.0 21055 * @category Object 21056 * @param {Object} object The object to query. 21057 * @param {Array|string} path The path of the property to get. 21058 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 21059 * @returns {*} Returns the resolved value. 21060 * @example 21061 * 21062 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 21063 * 21064 * _.get(object, 'a[0].b.c'); 21065 * // => 3 21066 * 21067 * _.get(object, ['a', '0', 'b', 'c']); 21068 * // => 3 21069 * 21070 * _.get(object, 'a.b.c', 'default'); 21071 * // => 'default' 21072 */ 21073 function get(object, path, defaultValue) { 21074 var result = object == null ? undefined : baseGet(object, path); 21075 return result === undefined ? defaultValue : result; 21076 } 21077 21078 /** 21079 * Checks if `path` is a direct property of `object`. 21080 * 21081 * @static 21082 * @since 0.1.0 21083 * @memberOf _ 21084 * @category Object 21085 * @param {Object} object The object to query. 21086 * @param {Array|string} path The path to check. 21087 * @returns {boolean} Returns `true` if `path` exists, else `false`. 21088 * @example 21089 * 21090 * var object = { 'a': { 'b': 2 } }; 21091 * var other = _.create({ 'a': _.create({ 'b': 2 }) }); 21092 * 21093 * _.has(object, 'a'); 21094 * // => true 21095 * 21096 * _.has(object, 'a.b'); 21097 * // => true 21098 * 21099 * _.has(object, ['a', 'b']); 21100 * // => true 21101 * 21102 * _.has(other, 'a'); 21103 * // => false 21104 */ 21105 function has(object, path) { 21106 return object != null && hasPath(object, path, baseHas); 21107 } 21108 21109 /** 21110 * Checks if `path` is a direct or inherited property of `object`. 21111 * 21112 * @static 21113 * @memberOf _ 21114 * @since 4.0.0 21115 * @category Object 21116 * @param {Object} object The object to query. 21117 * @param {Array|string} path The path to check. 21118 * @returns {boolean} Returns `true` if `path` exists, else `false`. 21119 * @example 21120 * 21121 * var object = _.create({ 'a': _.create({ 'b': 2 }) }); 21122 * 21123 * _.hasIn(object, 'a'); 21124 * // => true 21125 * 21126 * _.hasIn(object, 'a.b'); 21127 * // => true 21128 * 21129 * _.hasIn(object, ['a', 'b']); 21130 * // => true 21131 * 21132 * _.hasIn(object, 'b'); 21133 * // => false 21134 */ 21135 function hasIn(object, path) { 21136 return object != null && hasPath(object, path, baseHasIn); 21137 } 21138 21139 /**
vendor: 11,848 bytes, lines 21140-21510
21140 * Creates an object composed of the inverted keys and values of `object`. 21141 * If `object` contains duplicate values, subsequent values overwrite 21142 * property assignments of previous values. 21143 * 21144 * @static 21145 * @memberOf _ 21146 * @since 0.7.0 21147 * @category Object 21148 * @param {Object} object The object to invert. 21149 * @returns {Object} Returns the new inverted object. 21150 * @example 21151 * 21152 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 21153 * 21154 * _.invert(object); 21155 * // => { '1': 'c', '2': 'b' } 21156 */ 21157 var invert = createInverter(function(result, value, key) { 21158 if (value != null && 21159 typeof value.toString != 'function') { 21160 value = nativeObjectToString.call(value); 21161 } 21162 21163 result[value] = key; 21164 }, constant(identity)); 21165 21166 /** 21167 * This method is like `_.invert` except that the inverted object is generated 21168 * from the results of running each element of `object` thru `iteratee`. The 21169 * corresponding inverted value of each inverted key is an array of keys 21170 * responsible for generating the inverted value. The iteratee is invoked 21171 * with one argument: (value). 21172 * 21173 * @static 21174 * @memberOf _ 21175 * @since 4.1.0 21176 * @category Object 21177 * @param {Object} object The object to invert. 21178 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 21179 * @returns {Object} Returns the new inverted object. 21180 * @example 21181 * 21182 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 21183 * 21184 * _.invertBy(object); 21185 * // => { '1': ['a', 'c'], '2': ['b'] } 21186 * 21187 * _.invertBy(object, function(value) { 21188 * return 'group' + value; 21189 * }); 21190 * // => { 'group1': ['a', 'c'], 'group2': ['b'] } 21191 */ 21192 var invertBy = createInverter(function(result, value, key) { 21193 if (value != null && 21194 typeof value.toString != 'function') { 21195 value = nativeObjectToString.call(value); 21196 } 21197 21198 if (hasOwnProperty.call(result, value)) { 21199 result[value].push(key); 21200 } else { 21201 result[value] = [key]; 21202 } 21203 }, getIteratee); 21204 21205 /** 21206 * Invokes the method at `path` of `object`. 21207 * 21208 * @static 21209 * @memberOf _ 21210 * @since 4.0.0 21211 * @category Object 21212 * @param {Object} object The object to query. 21213 * @param {Array|string} path The path of the method to invoke. 21214 * @param {...*} [args] The arguments to invoke the method with. 21215 * @returns {*} Returns the result of the invoked method. 21216 * @example 21217 * 21218 * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; 21219 * 21220 * _.invoke(object, 'a[0].b.c.slice', 1, 3); 21221 * // => [2, 3] 21222 */ 21223 var invoke = baseRest(baseInvoke); 21224 21225 /** 21226 * Creates an array of the own enumerable property names of `object`. 21227 * 21228 * **Note:** Non-object values are coerced to objects. See the 21229 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 21230 * for more details. 21231 * 21232 * @static 21233 * @since 0.1.0 21234 * @memberOf _ 21235 * @category Object 21236 * @param {Object} object The object to query. 21237 * @returns {Array} Returns the array of property names. 21238 * @example 21239 * 21240 * function Foo() { 21241 * this.a = 1; 21242 * this.b = 2; 21243 * } 21244 * 21245 * Foo.prototype.c = 3; 21246 * 21247 * _.keys(new Foo); 21248 * // => ['a', 'b'] (iteration order is not guaranteed) 21249 * 21250 * _.keys('hi'); 21251 * // => ['0', '1'] 21252 */ 21253 function keys(object) { 21254 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); 21255 } 21256 21257 /** 21258 * Creates an array of the own and inherited enumerable property names of `object`. 21259 * 21260 * **Note:** Non-object values are coerced to objects. 21261 * 21262 * @static 21263 * @memberOf _ 21264 * @since 3.0.0 21265 * @category Object 21266 * @param {Object} object The object to query. 21267 * @returns {Array} Returns the array of property names. 21268 * @example 21269 * 21270 * function Foo() { 21271 * this.a = 1; 21272 * this.b = 2; 21273 * } 21274 * 21275 * Foo.prototype.c = 3; 21276 * 21277 * _.keysIn(new Foo); 21278 * // => ['a', 'b', 'c'] (iteration order is not guaranteed) 21279 */ 21280 function keysIn(object) { 21281 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); 21282 } 21283 21284 /** 21285 * The opposite of `_.mapValues`; this method creates an object with the 21286 * same values as `object` and keys generated by running each own enumerable 21287 * string keyed property of `object` thru `iteratee`. The iteratee is invoked 21288 * with three arguments: (value, key, object). 21289 * 21290 * @static 21291 * @memberOf _ 21292 * @since 3.8.0 21293 * @category Object 21294 * @param {Object} object The object to iterate over. 21295 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 21296 * @returns {Object} Returns the new mapped object. 21297 * @see _.mapValues 21298 * @example 21299 * 21300 * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { 21301 * return key + value; 21302 * }); 21303 * // => { 'a1': 1, 'b2': 2 } 21304 */ 21305 function mapKeys(object, iteratee) { 21306 var result = {}; 21307 iteratee = getIteratee(iteratee, 3); 21308 21309 baseForOwn(object, function(value, key, object) { 21310 baseAssignValue(result, iteratee(value, key, object), value); 21311 }); 21312 return result; 21313 } 21314 21315 /** 21316 * Creates an object with the same keys as `object` and values generated 21317 * by running each own enumerable string keyed property of `object` thru 21318 * `iteratee`. The iteratee is invoked with three arguments: 21319 * (value, key, object). 21320 * 21321 * @static 21322 * @memberOf _ 21323 * @since 2.4.0 21324 * @category Object 21325 * @param {Object} object The object to iterate over. 21326 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 21327 * @returns {Object} Returns the new mapped object. 21328 * @see _.mapKeys 21329 * @example 21330 * 21331 * var users = { 21332 * 'fred': { 'user': 'fred', 'age': 40 }, 21333 * 'pebbles': { 'user': 'pebbles', 'age': 1 } 21334 * }; 21335 * 21336 * _.mapValues(users, function(o) { return o.age; }); 21337 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 21338 * 21339 * // The `_.property` iteratee shorthand. 21340 * _.mapValues(users, 'age'); 21341 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 21342 */ 21343 function mapValues(object, iteratee) { 21344 var result = {}; 21345 iteratee = getIteratee(iteratee, 3); 21346 21347 baseForOwn(object, function(value, key, object) { 21348 baseAssignValue(result, key, iteratee(value, key, object)); 21349 }); 21350 return result; 21351 } 21352 21353 /** 21354 * This method is like `_.assign` except that it recursively merges own and 21355 * inherited enumerable string keyed properties of source objects into the 21356 * destination object. Source properties that resolve to `undefined` are 21357 * skipped if a destination value exists. Array and plain object properties 21358 * are merged recursively. Other objects and value types are overridden by 21359 * assignment. Source objects are applied from left to right. Subsequent 21360 * sources overwrite property assignments of previous sources. 21361 * 21362 * **Note:** This method mutates `object`. 21363 * 21364 * @static 21365 * @memberOf _ 21366 * @since 0.5.0 21367 * @category Object 21368 * @param {Object} object The destination object. 21369 * @param {...Object} [sources] The source objects. 21370 * @returns {Object} Returns `object`. 21371 * @example 21372 * 21373 * var object = { 21374 * 'a': [{ 'b': 2 }, { 'd': 4 }] 21375 * }; 21376 * 21377 * var other = { 21378 * 'a': [{ 'c': 3 }, { 'e': 5 }] 21379 * }; 21380 * 21381 * _.merge(object, other); 21382 * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } 21383 */ 21384 var merge = createAssigner(function(object, source, srcIndex) { 21385 baseMerge(object, source, srcIndex); 21386 }); 21387 21388 /** 21389 * This method is like `_.merge` except that it accepts `customizer` which 21390 * is invoked to produce the merged values of the destination and source 21391 * properties. If `customizer` returns `undefined`, merging is handled by the 21392 * method instead. The `customizer` is invoked with six arguments: 21393 * (objValue, srcValue, key, object, source, stack). 21394 * 21395 * **Note:** This method mutates `object`. 21396 * 21397 * @static 21398 * @memberOf _ 21399 * @since 4.0.0 21400 * @category Object 21401 * @param {Object} object The destination object. 21402 * @param {...Object} sources The source objects. 21403 * @param {Function} customizer The function to customize assigned values. 21404 * @returns {Object} Returns `object`. 21405 * @example 21406 * 21407 * function customizer(objValue, srcValue) { 21408 * if (_.isArray(objValue)) { 21409 * return objValue.concat(srcValue); 21410 * } 21411 * } 21412 * 21413 * var object = { 'a': [1], 'b': [2] }; 21414 * var other = { 'a': [3], 'b': [4] }; 21415 * 21416 * _.mergeWith(object, other, customizer); 21417 * // => { 'a': [1, 3], 'b': [2, 4] } 21418 */ 21419 var mergeWith = createAssigner(function(object, source, srcIndex, customizer) { 21420 baseMerge(object, source, srcIndex, customizer); 21421 }); 21422 21423 /** 21424 * The opposite of `_.pick`; this method creates an object composed of the 21425 * own and inherited enumerable property paths of `object` that are not omitted. 21426 * 21427 * **Note:** This method is considerably slower than `_.pick`. 21428 * 21429 * @static 21430 * @since 0.1.0 21431 * @memberOf _ 21432 * @category Object 21433 * @param {Object} object The source object. 21434 * @param {...(string|string[])} [paths] The property paths to omit. 21435 * @returns {Object} Returns the new object. 21436 * @example 21437 * 21438 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 21439 * 21440 * _.omit(object, ['a', 'c']); 21441 * // => { 'b': '2' } 21442 */ 21443 var omit = flatRest(function(object, paths) { 21444 var result = {}; 21445 if (object == null) { 21446 return result; 21447 } 21448 var isDeep = false; 21449 paths = arrayMap(paths, function(path) { 21450 path = castPath(path, object); 21451 isDeep || (isDeep = path.length > 1); 21452 return path; 21453 }); 21454 copyObject(object, getAllKeysIn(object), result); 21455 if (isDeep) { 21456 result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone); 21457 } 21458 var length = paths.length; 21459 while (length--) { 21460 baseUnset(result, paths[length]); 21461 } 21462 return result; 21463 }); 21464 21465 /** 21466 * The opposite of `_.pickBy`; this method creates an object composed of 21467 * the own and inherited enumerable string keyed properties of `object` that 21468 * `predicate` doesn't return truthy for. The predicate is invoked with two 21469 * arguments: (value, key). 21470 * 21471 * @static 21472 * @memberOf _ 21473 * @since 4.0.0 21474 * @category Object 21475 * @param {Object} object The source object. 21476 * @param {Function} [predicate=_.identity] The function invoked per property. 21477 * @returns {Object} Returns the new object. 21478 * @example 21479 * 21480 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 21481 * 21482 * _.omitBy(object, _.isNumber); 21483 * // => { 'b': '2' } 21484 */ 21485 function omitBy(object, predicate) { 21486 return pickBy(object, negate(getIteratee(predicate))); 21487 } 21488 21489 /** 21490 * Creates an object composed of the picked `object` properties. 21491 * 21492 * @static 21493 * @since 0.1.0 21494 * @memberOf _ 21495 * @category Object 21496 * @param {Object} object The source object. 21497 * @param {...(string|string[])} [paths] The property paths to pick. 21498 * @returns {Object} Returns the new object. 21499 * @example 21500 * 21501 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 21502 * 21503 * _.pick(object, ['a', 'c']); 21504 * // => { 'a': 1, 'c': 3 } 21505 */ 21506 var pick = flatRest(function(object, paths) { 21507 return object == null ? {} : basePick(object, paths); 21508 }); 21509 21510 /**
vendor: 11,160 bytes, lines 21511-21849
21511 * Creates an object composed of the `object` properties `predicate` returns 21512 * truthy for. The predicate is invoked with two arguments: (value, key). 21513 * 21514 * @static 21515 * @memberOf _ 21516 * @since 4.0.0 21517 * @category Object 21518 * @param {Object} object The source object. 21519 * @param {Function} [predicate=_.identity] The function invoked per property. 21520 * @returns {Object} Returns the new object. 21521 * @example 21522 * 21523 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 21524 * 21525 * _.pickBy(object, _.isNumber); 21526 * // => { 'a': 1, 'c': 3 } 21527 */ 21528 function pickBy(object, predicate) { 21529 if (object == null) { 21530 return {}; 21531 } 21532 var props = arrayMap(getAllKeysIn(object), function(prop) { 21533 return [prop]; 21534 }); 21535 predicate = getIteratee(predicate); 21536 return basePickBy(object, props, function(value, path) { 21537 return predicate(value, path[0]); 21538 }); 21539 } 21540 21541 /** 21542 * This method is like `_.get` except that if the resolved value is a 21543 * function it's invoked with the `this` binding of its parent object and 21544 * its result is returned. 21545 * 21546 * @static 21547 * @since 0.1.0 21548 * @memberOf _ 21549 * @category Object 21550 * @param {Object} object The object to query. 21551 * @param {Array|string} path The path of the property to resolve. 21552 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 21553 * @returns {*} Returns the resolved value. 21554 * @example 21555 * 21556 * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; 21557 * 21558 * _.result(object, 'a[0].b.c1'); 21559 * // => 3 21560 * 21561 * _.result(object, 'a[0].b.c2'); 21562 * // => 4 21563 * 21564 * _.result(object, 'a[0].b.c3', 'default'); 21565 * // => 'default' 21566 * 21567 * _.result(object, 'a[0].b.c3', _.constant('default')); 21568 * // => 'default' 21569 */ 21570 function result(object, path, defaultValue) { 21571 path = castPath(path, object); 21572 21573 var index = -1, 21574 length = path.length; 21575 21576 // Ensure the loop is entered when path is empty. 21577 if (!length) { 21578 length = 1; 21579 object = undefined; 21580 } 21581 while (++index < length) { 21582 var value = object == null ? undefined : object[toKey(path[index])]; 21583 if (value === undefined) { 21584 index = length; 21585 value = defaultValue; 21586 } 21587 object = isFunction(value) ? value.call(object) : value; 21588 } 21589 return object; 21590 } 21591 21592 /** 21593 * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, 21594 * it's created. Arrays are created for missing index properties while objects 21595 * are created for all other missing properties. Use `_.setWith` to customize 21596 * `path` creation. 21597 * 21598 * **Note:** This method mutates `object`. 21599 * 21600 * @static 21601 * @memberOf _ 21602 * @since 3.7.0 21603 * @category Object 21604 * @param {Object} object The object to modify. 21605 * @param {Array|string} path The path of the property to set. 21606 * @param {*} value The value to set. 21607 * @returns {Object} Returns `object`. 21608 * @example 21609 * 21610 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 21611 * 21612 * _.set(object, 'a[0].b.c', 4); 21613 * console.log(object.a[0].b.c); 21614 * // => 4 21615 * 21616 * _.set(object, ['x', '0', 'y', 'z'], 5); 21617 * console.log(object.x[0].y.z); 21618 * // => 5 21619 */ 21620 function set(object, path, value) { 21621 return object == null ? object : baseSet(object, path, value); 21622 } 21623 21624 /** 21625 * This method is like `_.set` except that it accepts `customizer` which is 21626 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 21627 * path creation is handled by the method instead. The `customizer` is invoked 21628 * with three arguments: (nsValue, key, nsObject). 21629 * 21630 * **Note:** This method mutates `object`. 21631 * 21632 * @static 21633 * @memberOf _ 21634 * @since 4.0.0 21635 * @category Object 21636 * @param {Object} object The object to modify. 21637 * @param {Array|string} path The path of the property to set. 21638 * @param {*} value The value to set. 21639 * @param {Function} [customizer] The function to customize assigned values. 21640 * @returns {Object} Returns `object`. 21641 * @example 21642 * 21643 * var object = {}; 21644 * 21645 * _.setWith(object, '[0][1]', 'a', Object); 21646 * // => { '0': { '1': 'a' } } 21647 */ 21648 function setWith(object, path, value, customizer) { 21649 customizer = typeof customizer == 'function' ? customizer : undefined; 21650 return object == null ? object : baseSet(object, path, value, customizer); 21651 } 21652 21653 /** 21654 * Creates an array of own enumerable string keyed-value pairs for `object` 21655 * which can be consumed by `_.fromPairs`. If `object` is a map or set, its 21656 * entries are returned. 21657 * 21658 * @static 21659 * @memberOf _ 21660 * @since 4.0.0 21661 * @alias entries 21662 * @category Object 21663 * @param {Object} object The object to query. 21664 * @returns {Array} Returns the key-value pairs. 21665 * @example 21666 * 21667 * function Foo() { 21668 * this.a = 1; 21669 * this.b = 2; 21670 * } 21671 * 21672 * Foo.prototype.c = 3; 21673 * 21674 * _.toPairs(new Foo); 21675 * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) 21676 */ 21677 var toPairs = createToPairs(keys); 21678 21679 /** 21680 * Creates an array of own and inherited enumerable string keyed-value pairs 21681 * for `object` which can be consumed by `_.fromPairs`. If `object` is a map 21682 * or set, its entries are returned. 21683 * 21684 * @static 21685 * @memberOf _ 21686 * @since 4.0.0 21687 * @alias entriesIn 21688 * @category Object 21689 * @param {Object} object The object to query. 21690 * @returns {Array} Returns the key-value pairs. 21691 * @example 21692 * 21693 * function Foo() { 21694 * this.a = 1; 21695 * this.b = 2; 21696 * } 21697 * 21698 * Foo.prototype.c = 3; 21699 * 21700 * _.toPairsIn(new Foo); 21701 * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) 21702 */ 21703 var toPairsIn = createToPairs(keysIn); 21704 21705 /** 21706 * An alternative to `_.reduce`; this method transforms `object` to a new 21707 * `accumulator` object which is the result of running each of its own 21708 * enumerable string keyed properties thru `iteratee`, with each invocation 21709 * potentially mutating the `accumulator` object. If `accumulator` is not 21710 * provided, a new object with the same `[[Prototype]]` will be used. The 21711 * iteratee is invoked with four arguments: (accumulator, value, key, object). 21712 * Iteratee functions may exit iteration early by explicitly returning `false`. 21713 * 21714 * @static 21715 * @memberOf _ 21716 * @since 1.3.0 21717 * @category Object 21718 * @param {Object} object The object to iterate over. 21719 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 21720 * @param {*} [accumulator] The custom accumulator value. 21721 * @returns {*} Returns the accumulated value. 21722 * @example 21723 * 21724 * _.transform([2, 3, 4], function(result, n) { 21725 * result.push(n *= n); 21726 * return n % 2 == 0; 21727 * }, []); 21728 * // => [4, 9] 21729 * 21730 * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 21731 * (result[value] || (result[value] = [])).push(key); 21732 * }, {}); 21733 * // => { '1': ['a', 'c'], '2': ['b'] } 21734 */ 21735 function transform(object, iteratee, accumulator) { 21736 var isArr = isArray(object), 21737 isArrLike = isArr || isBuffer(object) || isTypedArray(object); 21738 21739 iteratee = getIteratee(iteratee, 4); 21740 if (accumulator == null) { 21741 var Ctor = object && object.constructor; 21742 if (isArrLike) { 21743 accumulator = isArr ? new Ctor : []; 21744 } 21745 else if (isObject(object)) { 21746 accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; 21747 } 21748 else { 21749 accumulator = {}; 21750 } 21751 } 21752 (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) { 21753 return iteratee(accumulator, value, index, object); 21754 }); 21755 return accumulator; 21756 } 21757 21758 /** 21759 * Removes the property at `path` of `object`. 21760 * 21761 * **Note:** This method mutates `object`. 21762 * 21763 * @static 21764 * @memberOf _ 21765 * @since 4.0.0 21766 * @category Object 21767 * @param {Object} object The object to modify. 21768 * @param {Array|string} path The path of the property to unset. 21769 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 21770 * @example 21771 * 21772 * var object = { 'a': [{ 'b': { 'c': 7 } }] }; 21773 * _.unset(object, 'a[0].b.c'); 21774 * // => true 21775 * 21776 * console.log(object); 21777 * // => { 'a': [{ 'b': {} }] }; 21778 * 21779 * _.unset(object, ['a', '0', 'b', 'c']); 21780 * // => true 21781 * 21782 * console.log(object); 21783 * // => { 'a': [{ 'b': {} }] }; 21784 */ 21785 function unset(object, path) { 21786 return object == null ? true : baseUnset(object, path); 21787 } 21788 21789 /** 21790 * This method is like `_.set` except that accepts `updater` to produce the 21791 * value to set. Use `_.updateWith` to customize `path` creation. The `updater` 21792 * is invoked with one argument: (value). 21793 * 21794 * **Note:** This method mutates `object`. 21795 * 21796 * @static 21797 * @memberOf _ 21798 * @since 4.6.0 21799 * @category Object 21800 * @param {Object} object The object to modify. 21801 * @param {Array|string} path The path of the property to set. 21802 * @param {Function} updater The function to produce the updated value. 21803 * @returns {Object} Returns `object`. 21804 * @example 21805 * 21806 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 21807 * 21808 * _.update(object, 'a[0].b.c', function(n) { return n * n; }); 21809 * console.log(object.a[0].b.c); 21810 * // => 9 21811 * 21812 * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; }); 21813 * console.log(object.x[0].y.z); 21814 * // => 0 21815 */ 21816 function update(object, path, updater) { 21817 return object == null ? object : baseUpdate(object, path, castFunction(updater)); 21818 } 21819 21820 /** 21821 * This method is like `_.update` except that it accepts `customizer` which is 21822 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 21823 * path creation is handled by the method instead. The `customizer` is invoked 21824 * with three arguments: (nsValue, key, nsObject). 21825 * 21826 * **Note:** This method mutates `object`. 21827 * 21828 * @static 21829 * @memberOf _ 21830 * @since 4.6.0 21831 * @category Object 21832 * @param {Object} object The object to modify. 21833 * @param {Array|string} path The path of the property to set. 21834 * @param {Function} updater The function to produce the updated value. 21835 * @param {Function} [customizer] The function to customize assigned values. 21836 * @returns {Object} Returns `object`. 21837 * @example 21838 * 21839 * var object = {}; 21840 * 21841 * _.updateWith(object, '[0][1]', _.constant('a'), Object); 21842 * // => { '0': { '1': 'a' } } 21843 */ 21844 function updateWith(object, path, updater, customizer) { 21845 customizer = typeof customizer == 'function' ? customizer : undefined; 21846 return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer); 21847 } 21848 21849 /**
vendor: 1,263 bytes, lines 21850-21899
21850 * Creates an array of the own enumerable string keyed property values of `object`. 21851 * 21852 * **Note:** Non-object values are coerced to objects. 21853 * 21854 * @static 21855 * @since 0.1.0 21856 * @memberOf _ 21857 * @category Object 21858 * @param {Object} object The object to query. 21859 * @returns {Array} Returns the array of property values. 21860 * @example 21861 * 21862 * function Foo() { 21863 * this.a = 1; 21864 * this.b = 2; 21865 * } 21866 * 21867 * Foo.prototype.c = 3; 21868 * 21869 * _.values(new Foo); 21870 * // => [1, 2] (iteration order is not guaranteed) 21871 * 21872 * _.values('hi'); 21873 * // => ['h', 'i'] 21874 */ 21875 function values(object) { 21876 return object == null ? [] : baseValues(object, keys(object)); 21877 } 21878 21879 /** 21880 * Creates an array of the own and inherited enumerable string keyed property 21881 * values of `object`. 21882 * 21883 * **Note:** Non-object values are coerced to objects. 21884 * 21885 * @static 21886 * @memberOf _ 21887 * @since 3.0.0 21888 * @category Object 21889 * @param {Object} object The object to query. 21890 * @returns {Array} Returns the array of property values. 21891 * @example 21892 * 21893 * function Foo() { 21894 * this.a = 1; 21895 * this.b = 2; 21896 * } 21897 * 21898 * Foo.prototype.c = 3; 21899 *
vendor: 9,679 bytes, lines 21900-22220
21900 * _.valuesIn(new Foo); 21901 * // => [1, 2, 3] (iteration order is not guaranteed) 21902 */ 21903 function valuesIn(object) { 21904 return object == null ? [] : baseValues(object, keysIn(object)); 21905 } 21906 21907 /*------------------------------------------------------------------------*/ 21908 21909 /** 21910 * Clamps `number` within the inclusive `lower` and `upper` bounds. 21911 * 21912 * @static 21913 * @memberOf _ 21914 * @since 4.0.0 21915 * @category Number 21916 * @param {number} number The number to clamp. 21917 * @param {number} [lower] The lower bound. 21918 * @param {number} upper The upper bound. 21919 * @returns {number} Returns the clamped number. 21920 * @example 21921 * 21922 * _.clamp(-10, -5, 5); 21923 * // => -5 21924 * 21925 * _.clamp(10, -5, 5); 21926 * // => 5 21927 */ 21928 function clamp(number, lower, upper) { 21929 if (upper === undefined) { 21930 upper = lower; 21931 lower = undefined; 21932 } 21933 if (upper !== undefined) { 21934 upper = toNumber(upper); 21935 upper = upper === upper ? upper : 0; 21936 } 21937 if (lower !== undefined) { 21938 lower = toNumber(lower); 21939 lower = lower === lower ? lower : 0; 21940 } 21941 return baseClamp(toNumber(number), lower, upper); 21942 } 21943 21944 /** 21945 * Checks if `n` is between `start` and up to, but not including, `end`. If 21946 * `end` is not specified, it's set to `start` with `start` then set to `0`. 21947 * If `start` is greater than `end` the params are swapped to support 21948 * negative ranges. 21949 * 21950 * @static 21951 * @memberOf _ 21952 * @since 3.3.0 21953 * @category Number 21954 * @param {number} number The number to check. 21955 * @param {number} [start=0] The start of the range. 21956 * @param {number} end The end of the range. 21957 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 21958 * @see _.range, _.rangeRight 21959 * @example 21960 * 21961 * _.inRange(3, 2, 4); 21962 * // => true 21963 * 21964 * _.inRange(4, 8); 21965 * // => true 21966 * 21967 * _.inRange(4, 2); 21968 * // => false 21969 * 21970 * _.inRange(2, 2); 21971 * // => false 21972 * 21973 * _.inRange(1.2, 2); 21974 * // => true 21975 * 21976 * _.inRange(5.2, 4); 21977 * // => false 21978 * 21979 * _.inRange(-3, -2, -6); 21980 * // => true 21981 */ 21982 function inRange(number, start, end) { 21983 start = toFinite(start); 21984 if (end === undefined) { 21985 end = start; 21986 start = 0; 21987 } else { 21988 end = toFinite(end); 21989 } 21990 number = toNumber(number); 21991 return baseInRange(number, start, end); 21992 } 21993 21994 /** 21995 * Produces a random number between the inclusive `lower` and `upper` bounds. 21996 * If only one argument is provided a number between `0` and the given number 21997 * is returned. If `floating` is `true`, or either `lower` or `upper` are 21998 * floats, a floating-point number is returned instead of an integer. 21999 * 22000 * **Note:** JavaScript follows the IEEE-754 standard for resolving 22001 * floating-point values which can produce unexpected results. 22002 * 22003 * @static 22004 * @memberOf _ 22005 * @since 0.7.0 22006 * @category Number 22007 * @param {number} [lower=0] The lower bound. 22008 * @param {number} [upper=1] The upper bound. 22009 * @param {boolean} [floating] Specify returning a floating-point number. 22010 * @returns {number} Returns the random number. 22011 * @example 22012 * 22013 * _.random(0, 5); 22014 * // => an integer between 0 and 5 22015 * 22016 * _.random(5); 22017 * // => also an integer between 0 and 5 22018 * 22019 * _.random(5, true); 22020 * // => a floating-point number between 0 and 5 22021 * 22022 * _.random(1.2, 5.2); 22023 * // => a floating-point number between 1.2 and 5.2 22024 */ 22025 function random(lower, upper, floating) { 22026 if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) { 22027 upper = floating = undefined; 22028 } 22029 if (floating === undefined) { 22030 if (typeof upper == 'boolean') { 22031 floating = upper; 22032 upper = undefined; 22033 } 22034 else if (typeof lower == 'boolean') { 22035 floating = lower; 22036 lower = undefined; 22037 } 22038 } 22039 if (lower === undefined && upper === undefined) { 22040 lower = 0; 22041 upper = 1; 22042 } 22043 else { 22044 lower = toFinite(lower); 22045 if (upper === undefined) { 22046 upper = lower; 22047 lower = 0; 22048 } else { 22049 upper = toFinite(upper); 22050 } 22051 } 22052 if (lower > upper) { 22053 var temp = lower; 22054 lower = upper; 22055 upper = temp; 22056 } 22057 if (floating || lower % 1 || upper % 1) { 22058 var rand = nativeRandom(); 22059 return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper); 22060 } 22061 return baseRandom(lower, upper); 22062 } 22063 22064 /*------------------------------------------------------------------------*/ 22065 22066 /** 22067 * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). 22068 * 22069 * @static 22070 * @memberOf _ 22071 * @since 3.0.0 22072 * @category String 22073 * @param {string} [string=''] The string to convert. 22074 * @returns {string} Returns the camel cased string. 22075 * @example 22076 * 22077 * _.camelCase('Foo Bar'); 22078 * // => 'fooBar' 22079 * 22080 * _.camelCase('--foo-bar--'); 22081 * // => 'fooBar' 22082 * 22083 * _.camelCase('__FOO_BAR__'); 22084 * // => 'fooBar' 22085 */ 22086 var camelCase = createCompounder(function(result, word, index) { 22087 word = word.toLowerCase(); 22088 return result + (index ? capitalize(word) : word); 22089 }); 22090 22091 /** 22092 * Converts the first character of `string` to upper case and the remaining 22093 * to lower case. 22094 * 22095 * @static 22096 * @memberOf _ 22097 * @since 3.0.0 22098 * @category String 22099 * @param {string} [string=''] The string to capitalize. 22100 * @returns {string} Returns the capitalized string. 22101 * @example 22102 * 22103 * _.capitalize('FRED'); 22104 * // => 'Fred' 22105 */ 22106 function capitalize(string) { 22107 return upperFirst(toString(string).toLowerCase()); 22108 } 22109 22110 /** 22111 * Deburrs `string` by converting 22112 * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) 22113 * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) 22114 * letters to basic Latin letters and removing 22115 * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). 22116 * 22117 * @static 22118 * @memberOf _ 22119 * @since 3.0.0 22120 * @category String 22121 * @param {string} [string=''] The string to deburr. 22122 * @returns {string} Returns the deburred string. 22123 * @example 22124 * 22125 * _.deburr('déjà vu'); 22126 * // => 'deja vu' 22127 */ 22128 function deburr(string) { 22129 string = toString(string); 22130 return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); 22131 } 22132 22133 /** 22134 * Checks if `string` ends with the given target string. 22135 * 22136 * @static 22137 * @memberOf _ 22138 * @since 3.0.0 22139 * @category String 22140 * @param {string} [string=''] The string to inspect. 22141 * @param {string} [target] The string to search for. 22142 * @param {number} [position=string.length] The position to search up to. 22143 * @returns {boolean} Returns `true` if `string` ends with `target`, 22144 * else `false`. 22145 * @example 22146 * 22147 * _.endsWith('abc', 'c'); 22148 * // => true 22149 * 22150 * _.endsWith('abc', 'b'); 22151 * // => false 22152 * 22153 * _.endsWith('abc', 'b', 2); 22154 * // => true 22155 */ 22156 function endsWith(string, target, position) { 22157 string = toString(string); 22158 target = baseToString(target); 22159 22160 var length = string.length; 22161 position = position === undefined 22162 ? length 22163 : baseClamp(toInteger(position), 0, length); 22164 22165 var end = position; 22166 position -= target.length; 22167 return position >= 0 && string.slice(position, end) == target; 22168 } 22169 22170 /** 22171 * Converts the characters "&", "<", ">", '"', and "'" in `string` to their 22172 * corresponding HTML entities. 22173 * 22174 * **Note:** No other characters are escaped. To escape additional 22175 * characters use a third-party library like [_he_](https://mths.be/he). 22176 * 22177 * Though the ">" character is escaped for symmetry, characters like 22178 * ">" and "/" don't need escaping in HTML and have no special meaning 22179 * unless they're part of a tag or unquoted attribute value. See 22180 * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) 22181 * (under "semi-related fun fact") for more details. 22182 * 22183 * When working with HTML you should always 22184 * [quote attribute values](http://wonko.com/post/html-escaping) to reduce 22185 * XSS vectors. 22186 * 22187 * @static 22188 * @since 0.1.0 22189 * @memberOf _ 22190 * @category String 22191 * @param {string} [string=''] The string to escape. 22192 * @returns {string} Returns the escaped string. 22193 * @example 22194 * 22195 * _.escape('fred, barney, & pebbles'); 22196 * // => 'fred, barney, & pebbles' 22197 */ 22198 function escape(string) { 22199 string = toString(string); 22200 return (string && reHasUnescapedHtml.test(string)) 22201 ? string.replace(reUnescapedHtml, escapeHtmlChar) 22202 : string; 22203 } 22204 22205 /** 22206 * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", 22207 * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. 22208 * 22209 * @static 22210 * @memberOf _ 22211 * @since 3.0.0 22212 * @category String 22213 * @param {string} [string=''] The string to escape. 22214 * @returns {string} Returns the escaped string. 22215 * @example 22216 * 22217 * _.escapeRegExp('[lodash](https://lodash.com/)'); 22218 * // => '\[lodash\]\(https://lodash\.com/\)' 22219 */ 22220 function escapeRegExp(string) {
vendor: 4,658 bytes, lines 22221-22390
22221 string = toString(string); 22222 return (string && reHasRegExpChar.test(string)) 22223 ? string.replace(reRegExpChar, '\\$&') 22224 : string; 22225 } 22226 22227 /** 22228 * Converts `string` to 22229 * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). 22230 * 22231 * @static 22232 * @memberOf _ 22233 * @since 3.0.0 22234 * @category String 22235 * @param {string} [string=''] The string to convert. 22236 * @returns {string} Returns the kebab cased string. 22237 * @example 22238 * 22239 * _.kebabCase('Foo Bar'); 22240 * // => 'foo-bar' 22241 * 22242 * _.kebabCase('fooBar'); 22243 * // => 'foo-bar' 22244 * 22245 * _.kebabCase('__FOO_BAR__'); 22246 * // => 'foo-bar' 22247 */ 22248 var kebabCase = createCompounder(function(result, word, index) { 22249 return result + (index ? '-' : '') + word.toLowerCase(); 22250 }); 22251 22252 /** 22253 * Converts `string`, as space separated words, to lower case. 22254 * 22255 * @static 22256 * @memberOf _ 22257 * @since 4.0.0 22258 * @category String 22259 * @param {string} [string=''] The string to convert. 22260 * @returns {string} Returns the lower cased string. 22261 * @example 22262 * 22263 * _.lowerCase('--Foo-Bar--'); 22264 * // => 'foo bar' 22265 * 22266 * _.lowerCase('fooBar'); 22267 * // => 'foo bar' 22268 * 22269 * _.lowerCase('__FOO_BAR__'); 22270 * // => 'foo bar' 22271 */ 22272 var lowerCase = createCompounder(function(result, word, index) { 22273 return result + (index ? ' ' : '') + word.toLowerCase(); 22274 }); 22275 22276 /** 22277 * Converts the first character of `string` to lower case. 22278 * 22279 * @static 22280 * @memberOf _ 22281 * @since 4.0.0 22282 * @category String 22283 * @param {string} [string=''] The string to convert. 22284 * @returns {string} Returns the converted string. 22285 * @example 22286 * 22287 * _.lowerFirst('Fred'); 22288 * // => 'fred' 22289 * 22290 * _.lowerFirst('FRED'); 22291 * // => 'fRED' 22292 */ 22293 var lowerFirst = createCaseFirst('toLowerCase'); 22294 22295 /** 22296 * Pads `string` on the left and right sides if it's shorter than `length`. 22297 * Padding characters are truncated if they can't be evenly divided by `length`. 22298 * 22299 * @static 22300 * @memberOf _ 22301 * @since 3.0.0 22302 * @category String 22303 * @param {string} [string=''] The string to pad. 22304 * @param {number} [length=0] The padding length. 22305 * @param {string} [chars=' '] The string used as padding. 22306 * @returns {string} Returns the padded string. 22307 * @example 22308 * 22309 * _.pad('abc', 8); 22310 * // => ' abc ' 22311 * 22312 * _.pad('abc', 8, '_-'); 22313 * // => '_-abc_-_' 22314 * 22315 * _.pad('abc', 3); 22316 * // => 'abc' 22317 */ 22318 function pad(string, length, chars) { 22319 string = toString(string); 22320 length = toInteger(length); 22321 22322 var strLength = length ? stringSize(string) : 0; 22323 if (!length || strLength >= length) { 22324 return string; 22325 } 22326 var mid = (length - strLength) / 2; 22327 return ( 22328 createPadding(nativeFloor(mid), chars) + 22329 string + 22330 createPadding(nativeCeil(mid), chars) 22331 ); 22332 } 22333 22334 /** 22335 * Pads `string` on the right side if it's shorter than `length`. Padding 22336 * characters are truncated if they exceed `length`. 22337 * 22338 * @static 22339 * @memberOf _ 22340 * @since 4.0.0 22341 * @category String 22342 * @param {string} [string=''] The string to pad. 22343 * @param {number} [length=0] The padding length. 22344 * @param {string} [chars=' '] The string used as padding. 22345 * @returns {string} Returns the padded string. 22346 * @example 22347 * 22348 * _.padEnd('abc', 6); 22349 * // => 'abc ' 22350 * 22351 * _.padEnd('abc', 6, '_-'); 22352 * // => 'abc_-_' 22353 * 22354 * _.padEnd('abc', 3); 22355 * // => 'abc' 22356 */ 22357 function padEnd(string, length, chars) { 22358 string = toString(string); 22359 length = toInteger(length); 22360 22361 var strLength = length ? stringSize(string) : 0; 22362 return (length && strLength < length) 22363 ? (string + createPadding(length - strLength, chars)) 22364 : string; 22365 } 22366 22367 /** 22368 * Pads `string` on the left side if it's shorter than `length`. Padding 22369 * characters are truncated if they exceed `length`. 22370 * 22371 * @static 22372 * @memberOf _ 22373 * @since 4.0.0 22374 * @category String 22375 * @param {string} [string=''] The string to pad. 22376 * @param {number} [length=0] The padding length. 22377 * @param {string} [chars=' '] The string used as padding. 22378 * @returns {string} Returns the padded string. 22379 * @example 22380 * 22381 * _.padStart('abc', 6); 22382 * // => ' abc' 22383 * 22384 * _.padStart('abc', 6, '_-'); 22385 * // => '_-_abc' 22386 * 22387 * _.padStart('abc', 3); 22388 * // => 'abc' 22389 */ 22390 function padStart(string, length, chars) {
vendor: 9,908 bytes, lines 22391-22683
22391 string = toString(string); 22392 length = toInteger(length); 22393 22394 var strLength = length ? stringSize(string) : 0; 22395 return (length && strLength < length) 22396 ? (createPadding(length - strLength, chars) + string) 22397 : string; 22398 } 22399 22400 /** 22401 * Converts `string` to an integer of the specified radix. If `radix` is 22402 * `undefined` or `0`, a `radix` of `10` is used unless `value` is a 22403 * hexadecimal, in which case a `radix` of `16` is used. 22404 * 22405 * **Note:** This method aligns with the 22406 * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. 22407 * 22408 * @static 22409 * @memberOf _ 22410 * @since 1.1.0 22411 * @category String 22412 * @param {string} string The string to convert. 22413 * @param {number} [radix=10] The radix to interpret `value` by. 22414 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 22415 * @returns {number} Returns the converted integer. 22416 * @example 22417 * 22418 * _.parseInt('08'); 22419 * // => 8 22420 * 22421 * _.map(['6', '08', '10'], _.parseInt); 22422 * // => [6, 8, 10] 22423 */ 22424 function parseInt(string, radix, guard) { 22425 if (guard || radix == null) { 22426 radix = 0; 22427 } else if (radix) { 22428 radix = +radix; 22429 } 22430 return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0); 22431 } 22432 22433 /** 22434 * Repeats the given string `n` times. 22435 * 22436 * @static 22437 * @memberOf _ 22438 * @since 3.0.0 22439 * @category String 22440 * @param {string} [string=''] The string to repeat. 22441 * @param {number} [n=1] The number of times to repeat the string. 22442 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 22443 * @returns {string} Returns the repeated string. 22444 * @example 22445 * 22446 * _.repeat('*', 3); 22447 * // => '***' 22448 * 22449 * _.repeat('abc', 2); 22450 * // => 'abcabc' 22451 * 22452 * _.repeat('abc', 0); 22453 * // => '' 22454 */ 22455 function repeat(string, n, guard) { 22456 if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) { 22457 n = 1; 22458 } else { 22459 n = toInteger(n); 22460 } 22461 return baseRepeat(toString(string), n); 22462 } 22463 22464 /** 22465 * Replaces matches for `pattern` in `string` with `replacement`. 22466 * 22467 * **Note:** This method is based on 22468 * [`String#replace`](https://mdn.io/String/replace). 22469 * 22470 * @static 22471 * @memberOf _ 22472 * @since 4.0.0 22473 * @category String 22474 * @param {string} [string=''] The string to modify. 22475 * @param {RegExp|string} pattern The pattern to replace. 22476 * @param {Function|string} replacement The match replacement. 22477 * @returns {string} Returns the modified string. 22478 * @example 22479 * 22480 * _.replace('Hi Fred', 'Fred', 'Barney'); 22481 * // => 'Hi Barney' 22482 */ 22483 function replace() { 22484 var args = arguments, 22485 string = toString(args[0]); 22486 22487 return args.length < 3 ? string : string.replace(args[1], args[2]); 22488 } 22489 22490 /** 22491 * Converts `string` to 22492 * [snake case](https://en.wikipedia.org/wiki/Snake_case). 22493 * 22494 * @static 22495 * @memberOf _ 22496 * @since 3.0.0 22497 * @category String 22498 * @param {string} [string=''] The string to convert. 22499 * @returns {string} Returns the snake cased string. 22500 * @example 22501 * 22502 * _.snakeCase('Foo Bar'); 22503 * // => 'foo_bar' 22504 * 22505 * _.snakeCase('fooBar'); 22506 * // => 'foo_bar' 22507 * 22508 * _.snakeCase('--FOO-BAR--'); 22509 * // => 'foo_bar' 22510 */ 22511 var snakeCase = createCompounder(function(result, word, index) { 22512 return result + (index ? '_' : '') + word.toLowerCase(); 22513 }); 22514 22515 /** 22516 * Splits `string` by `separator`. 22517 * 22518 * **Note:** This method is based on 22519 * [`String#split`](https://mdn.io/String/split). 22520 * 22521 * @static 22522 * @memberOf _ 22523 * @since 4.0.0 22524 * @category String 22525 * @param {string} [string=''] The string to split. 22526 * @param {RegExp|string} separator The separator pattern to split by. 22527 * @param {number} [limit] The length to truncate results to. 22528 * @returns {Array} Returns the string segments. 22529 * @example 22530 * 22531 * _.split('a-b-c', '-', 2); 22532 * // => ['a', 'b'] 22533 */ 22534 function split(string, separator, limit) { 22535 if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) { 22536 separator = limit = undefined; 22537 } 22538 limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0; 22539 if (!limit) { 22540 return []; 22541 } 22542 string = toString(string); 22543 if (string && ( 22544 typeof separator == 'string' || 22545 (separator != null && !isRegExp(separator)) 22546 )) { 22547 separator = baseToString(separator); 22548 if (!separator && hasUnicode(string)) { 22549 return castSlice(stringToArray(string), 0, limit); 22550 } 22551 } 22552 return string.split(separator, limit); 22553 } 22554 22555 /** 22556 * Converts `string` to 22557 * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). 22558 * 22559 * @static 22560 * @memberOf _ 22561 * @since 3.1.0 22562 * @category String 22563 * @param {string} [string=''] The string to convert. 22564 * @returns {string} Returns the start cased string. 22565 * @example 22566 * 22567 * _.startCase('--foo-bar--'); 22568 * // => 'Foo Bar' 22569 * 22570 * _.startCase('fooBar'); 22571 * // => 'Foo Bar' 22572 * 22573 * _.startCase('__FOO_BAR__'); 22574 * // => 'FOO BAR' 22575 */ 22576 var startCase = createCompounder(function(result, word, index) { 22577 return result + (index ? ' ' : '') + upperFirst(word); 22578 }); 22579 22580 /** 22581 * Checks if `string` starts with the given target string. 22582 * 22583 * @static 22584 * @memberOf _ 22585 * @since 3.0.0 22586 * @category String 22587 * @param {string} [string=''] The string to inspect. 22588 * @param {string} [target] The string to search for. 22589 * @param {number} [position=0] The position to search from. 22590 * @returns {boolean} Returns `true` if `string` starts with `target`, 22591 * else `false`. 22592 * @example 22593 * 22594 * _.startsWith('abc', 'a'); 22595 * // => true 22596 * 22597 * _.startsWith('abc', 'b'); 22598 * // => false 22599 * 22600 * _.startsWith('abc', 'b', 1); 22601 * // => true 22602 */ 22603 function startsWith(string, target, position) { 22604 string = toString(string); 22605 position = position == null 22606 ? 0 22607 : baseClamp(toInteger(position), 0, string.length); 22608 22609 target = baseToString(target); 22610 return string.slice(position, position + target.length) == target; 22611 } 22612 22613 /** 22614 * Creates a compiled template function that can interpolate data properties 22615 * in "interpolate" delimiters, HTML-escape interpolated data properties in 22616 * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data 22617 * properties may be accessed as free variables in the template. If a setting 22618 * object is given, it takes precedence over `_.templateSettings` values. 22619 * 22620 * **Note:** In the development build `_.template` utilizes 22621 * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) 22622 * for easier debugging. 22623 * 22624 * For more information on precompiling templates see 22625 * [lodash's custom builds documentation](https://lodash.com/custom-builds). 22626 * 22627 * For more information on Chrome extension sandboxes see 22628 * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). 22629 * 22630 * @static 22631 * @since 0.1.0 22632 * @memberOf _ 22633 * @category String 22634 * @param {string} [string=''] The template string. 22635 * @param {Object} [options={}] The options object. 22636 * @param {RegExp} [options.escape=_.templateSettings.escape] 22637 * The HTML "escape" delimiter. 22638 * @param {RegExp} [options.evaluate=_.templateSettings.evaluate] 22639 * The "evaluate" delimiter. 22640 * @param {Object} [options.imports=_.templateSettings.imports] 22641 * An object to import into the template as free variables. 22642 * @param {RegExp} [options.interpolate=_.templateSettings.interpolate] 22643 * The "interpolate" delimiter. 22644 * @param {string} [options.sourceURL='lodash.templateSources[n]'] 22645 * The sourceURL of the compiled template. 22646 * @param {string} [options.variable='obj'] 22647 * The data object variable name. 22648 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 22649 * @returns {Function} Returns the compiled template function. 22650 * @example 22651 * 22652 * // Use the "interpolate" delimiter to create a compiled template. 22653 * var compiled = _.template('hello <%= user %>!'); 22654 * compiled({ 'user': 'fred' }); 22655 * // => 'hello fred!' 22656 * 22657 * // Use the HTML "escape" delimiter to escape data property values. 22658 * var compiled = _.template('<b><%- value %></b>'); 22659 * compiled({ 'value': '<script>' }); 22660 * // => '<b><script></b>' 22661 * 22662 * // Use the "evaluate" delimiter to execute JavaScript and generate HTML. 22663 * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>'); 22664 * compiled({ 'users': ['fred', 'barney'] }); 22665 * // => '<li>fred</li><li>barney</li>' 22666 * 22667 * // Use the internal `print` function in "evaluate" delimiters. 22668 * var compiled = _.template('<% print("hello " + user); %>!'); 22669 * compiled({ 'user': 'barney' }); 22670 * // => 'hello barney!' 22671 * 22672 * // Use the ES template literal delimiter as an "interpolate" delimiter. 22673 * // Disable support by replacing the "interpolate" delimiter. 22674 * var compiled = _.template('hello ${ user }!'); 22675 * compiled({ 'user': 'pebbles' }); 22676 * // => 'hello pebbles!' 22677 * 22678 * // Use backslashes to treat delimiters as plain text. 22679 * var compiled = _.template('<%= "\\<%- value %\\>" %>'); 22680 * compiled({ 'value': 'ignored' }); 22681 * // => '<%- value %>' 22682 * 22683 * // Use the `imports` option to import `jQuery` as `jq`.
vendor: 14,162 bytes, lines 22684-23096
22684 * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>'; 22685 * var compiled = _.template(text, { 'imports': { 'jq': jQuery } }); 22686 * compiled({ 'users': ['fred', 'barney'] }); 22687 * // => '<li>fred</li><li>barney</li>' 22688 * 22689 * // Use the `sourceURL` option to specify a custom sourceURL for the template. 22690 * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' }); 22691 * compiled(data); 22692 * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector. 22693 * 22694 * // Use the `variable` option to ensure a with-statement isn't used in the compiled template. 22695 * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); 22696 * compiled.source; 22697 * // => function(data) { 22698 * // var __t, __p = ''; 22699 * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; 22700 * // return __p; 22701 * // } 22702 * 22703 * // Use custom template delimiters. 22704 * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g; 22705 * var compiled = _.template('hello {{ user }}!'); 22706 * compiled({ 'user': 'mustache' }); 22707 * // => 'hello mustache!' 22708 * 22709 * // Use the `source` property to inline compiled templates for meaningful 22710 * // line numbers in error messages and stack traces. 22711 * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\ 22712 * var JST = {\ 22713 * "main": ' + _.template(mainText).source + '\ 22714 * };\ 22715 * '); 22716 */ 22717 function template(string, options, guard) { 22718 // Based on John Resig's `tmpl` implementation 22719 // (http://ejohn.org/blog/javascript-micro-templating/) 22720 // and Laura Doktorova's doT.js (https://github.com/olado/doT). 22721 var settings = lodash.templateSettings; 22722 22723 if (guard && isIterateeCall(string, options, guard)) { 22724 options = undefined; 22725 } 22726 string = toString(string); 22727 options = assignInWith({}, options, settings, customDefaultsAssignIn); 22728 22729 var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn), 22730 importsKeys = keys(imports), 22731 importsValues = baseValues(imports, importsKeys); 22732 22733 var isEscaping, 22734 isEvaluating, 22735 index = 0, 22736 interpolate = options.interpolate || reNoMatch, 22737 source = "__p += '"; 22738 22739 // Compile the regexp to match each delimiter. 22740 var reDelimiters = RegExp( 22741 (options.escape || reNoMatch).source + '|' + 22742 interpolate.source + '|' + 22743 (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' + 22744 (options.evaluate || reNoMatch).source + '|$' 22745 , 'g'); 22746 22747 // Use a sourceURL for easier debugging. 22748 // The sourceURL gets injected into the source that's eval-ed, so be careful 22749 // with lookup (in case of e.g. prototype pollution), and strip newlines if any. 22750 // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection. 22751 var sourceURL = '//# sourceURL=' + 22752 (hasOwnProperty.call(options, 'sourceURL') 22753 ? (options.sourceURL + '').replace(/[\r\n]/g, ' ') 22754 : ('lodash.templateSources[' + (++templateCounter) + ']') 22755 ) + '\n'; 22756 22757 string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { 22758 interpolateValue || (interpolateValue = esTemplateValue); 22759 22760 // Escape characters that can't be included in string literals. 22761 source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); 22762 22763 // Replace delimiters with snippets. 22764 if (escapeValue) { 22765 isEscaping = true; 22766 source += "' +\n__e(" + escapeValue + ") +\n'"; 22767 } 22768 if (evaluateValue) { 22769 isEvaluating = true; 22770 source += "';\n" + evaluateValue + ";\n__p += '"; 22771 } 22772 if (interpolateValue) { 22773 source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'"; 22774 } 22775 index = offset + match.length; 22776 22777 // The JS engine embedded in Adobe products needs `match` returned in 22778 // order to produce the correct `offset` value. 22779 return match; 22780 }); 22781 22782 source += "';\n"; 22783 22784 // If `variable` is not specified wrap a with-statement around the generated 22785 // code to add the data object to the top of the scope chain. 22786 // Like with sourceURL, we take care to not check the option's prototype, 22787 // as this configuration is a code injection vector. 22788 var variable = hasOwnProperty.call(options, 'variable') && options.variable; 22789 if (!variable) { 22790 source = 'with (obj) {\n' + source + '\n}\n'; 22791 } 22792 // Cleanup code by stripping empty strings. 22793 source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source) 22794 .replace(reEmptyStringMiddle, '$1') 22795 .replace(reEmptyStringTrailing, '$1;'); 22796 22797 // Frame code as the function body. 22798 source = 'function(' + (variable || 'obj') + ') {\n' + 22799 (variable 22800 ? '' 22801 : 'obj || (obj = {});\n' 22802 ) + 22803 "var __t, __p = ''" + 22804 (isEscaping 22805 ? ', __e = _.escape' 22806 : '' 22807 ) + 22808 (isEvaluating 22809 ? ', __j = Array.prototype.join;\n' + 22810 "function print() { __p += __j.call(arguments, '') }\n" 22811 : ';\n' 22812 ) + 22813 source + 22814 'return __p\n}'; 22815 22816 var result = attempt(function() { 22817 return Function(importsKeys, sourceURL + 'return ' + source) 22818 .apply(undefined, importsValues); 22819 }); 22820 22821 // Provide the compiled function's source by its `toString` method or 22822 // the `source` property as a convenience for inlining compiled templates. 22823 result.source = source; 22824 if (isError(result)) { 22825 throw result; 22826 } 22827 return result; 22828 } 22829 22830 /** 22831 * Converts `string`, as a whole, to lower case just like 22832 * [String#toLowerCase](https://mdn.io/toLowerCase). 22833 * 22834 * @static 22835 * @memberOf _ 22836 * @since 4.0.0 22837 * @category String 22838 * @param {string} [string=''] The string to convert. 22839 * @returns {string} Returns the lower cased string. 22840 * @example 22841 * 22842 * _.toLower('--Foo-Bar--'); 22843 * // => '--foo-bar--' 22844 * 22845 * _.toLower('fooBar'); 22846 * // => 'foobar' 22847 * 22848 * _.toLower('__FOO_BAR__'); 22849 * // => '__foo_bar__' 22850 */ 22851 function toLower(value) { 22852 return toString(value).toLowerCase(); 22853 } 22854 22855 /** 22856 * Converts `string`, as a whole, to upper case just like 22857 * [String#toUpperCase](https://mdn.io/toUpperCase). 22858 * 22859 * @static 22860 * @memberOf _ 22861 * @since 4.0.0 22862 * @category String 22863 * @param {string} [string=''] The string to convert. 22864 * @returns {string} Returns the upper cased string. 22865 * @example 22866 * 22867 * _.toUpper('--foo-bar--'); 22868 * // => '--FOO-BAR--' 22869 * 22870 * _.toUpper('fooBar'); 22871 * // => 'FOOBAR' 22872 * 22873 * _.toUpper('__foo_bar__'); 22874 * // => '__FOO_BAR__' 22875 */ 22876 function toUpper(value) { 22877 return toString(value).toUpperCase(); 22878 } 22879 22880 /** 22881 * Removes leading and trailing whitespace or specified characters from `string`. 22882 * 22883 * @static 22884 * @memberOf _ 22885 * @since 3.0.0 22886 * @category String 22887 * @param {string} [string=''] The string to trim. 22888 * @param {string} [chars=whitespace] The characters to trim. 22889 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 22890 * @returns {string} Returns the trimmed string. 22891 * @example 22892 * 22893 * _.trim(' abc '); 22894 * // => 'abc' 22895 * 22896 * _.trim('-_-abc-_-', '_-'); 22897 * // => 'abc' 22898 * 22899 * _.map([' foo ', ' bar '], _.trim); 22900 * // => ['foo', 'bar'] 22901 */ 22902 function trim(string, chars, guard) { 22903 string = toString(string); 22904 if (string && (guard || chars === undefined)) { 22905 return string.replace(reTrim, ''); 22906 } 22907 if (!string || !(chars = baseToString(chars))) { 22908 return string; 22909 } 22910 var strSymbols = stringToArray(string), 22911 chrSymbols = stringToArray(chars), 22912 start = charsStartIndex(strSymbols, chrSymbols), 22913 end = charsEndIndex(strSymbols, chrSymbols) + 1; 22914 22915 return castSlice(strSymbols, start, end).join(''); 22916 } 22917 22918 /** 22919 * Removes trailing whitespace or specified characters from `string`. 22920 * 22921 * @static 22922 * @memberOf _ 22923 * @since 4.0.0 22924 * @category String 22925 * @param {string} [string=''] The string to trim. 22926 * @param {string} [chars=whitespace] The characters to trim. 22927 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 22928 * @returns {string} Returns the trimmed string. 22929 * @example 22930 * 22931 * _.trimEnd(' abc '); 22932 * // => ' abc' 22933 * 22934 * _.trimEnd('-_-abc-_-', '_-'); 22935 * // => '-_-abc' 22936 */ 22937 function trimEnd(string, chars, guard) { 22938 string = toString(string); 22939 if (string && (guard || chars === undefined)) { 22940 return string.replace(reTrimEnd, ''); 22941 } 22942 if (!string || !(chars = baseToString(chars))) { 22943 return string; 22944 } 22945 var strSymbols = stringToArray(string), 22946 end = charsEndIndex(strSymbols, stringToArray(chars)) + 1; 22947 22948 return castSlice(strSymbols, 0, end).join(''); 22949 } 22950 22951 /** 22952 * Removes leading whitespace or specified characters from `string`. 22953 * 22954 * @static 22955 * @memberOf _ 22956 * @since 4.0.0 22957 * @category String 22958 * @param {string} [string=''] The string to trim. 22959 * @param {string} [chars=whitespace] The characters to trim. 22960 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 22961 * @returns {string} Returns the trimmed string. 22962 * @example 22963 * 22964 * _.trimStart(' abc '); 22965 * // => 'abc ' 22966 * 22967 * _.trimStart('-_-abc-_-', '_-'); 22968 * // => 'abc-_-' 22969 */ 22970 function trimStart(string, chars, guard) { 22971 string = toString(string); 22972 if (string && (guard || chars === undefined)) { 22973 return string.replace(reTrimStart, ''); 22974 } 22975 if (!string || !(chars = baseToString(chars))) { 22976 return string; 22977 } 22978 var strSymbols = stringToArray(string), 22979 start = charsStartIndex(strSymbols, stringToArray(chars)); 22980 22981 return castSlice(strSymbols, start).join(''); 22982 } 22983 22984 /** 22985 * Truncates `string` if it's longer than the given maximum string length. 22986 * The last characters of the truncated string are replaced with the omission 22987 * string which defaults to "...". 22988 * 22989 * @static 22990 * @memberOf _ 22991 * @since 4.0.0 22992 * @category String 22993 * @param {string} [string=''] The string to truncate. 22994 * @param {Object} [options={}] The options object. 22995 * @param {number} [options.length=30] The maximum string length. 22996 * @param {string} [options.omission='...'] The string to indicate text is omitted. 22997 * @param {RegExp|string} [options.separator] The separator pattern to truncate to. 22998 * @returns {string} Returns the truncated string. 22999 * @example 23000 * 23001 * _.truncate('hi-diddly-ho there, neighborino'); 23002 * // => 'hi-diddly-ho there, neighbo...' 23003 * 23004 * _.truncate('hi-diddly-ho there, neighborino', { 23005 * 'length': 24, 23006 * 'separator': ' ' 23007 * }); 23008 * // => 'hi-diddly-ho there,...' 23009 * 23010 * _.truncate('hi-diddly-ho there, neighborino', { 23011 * 'length': 24, 23012 * 'separator': /,? +/ 23013 * }); 23014 * // => 'hi-diddly-ho there...' 23015 * 23016 * _.truncate('hi-diddly-ho there, neighborino', { 23017 * 'omission': ' [...]' 23018 * }); 23019 * // => 'hi-diddly-ho there, neig [...]' 23020 */ 23021 function truncate(string, options) { 23022 var length = DEFAULT_TRUNC_LENGTH, 23023 omission = DEFAULT_TRUNC_OMISSION; 23024 23025 if (isObject(options)) { 23026 var separator = 'separator' in options ? options.separator : separator; 23027 length = 'length' in options ? toInteger(options.length) : length; 23028 omission = 'omission' in options ? baseToString(options.omission) : omission; 23029 } 23030 string = toString(string); 23031 23032 var strLength = string.length; 23033 if (hasUnicode(string)) { 23034 var strSymbols = stringToArray(string); 23035 strLength = strSymbols.length; 23036 } 23037 if (length >= strLength) { 23038 return string; 23039 } 23040 var end = length - stringSize(omission); 23041 if (end < 1) { 23042 return omission; 23043 } 23044 var result = strSymbols 23045 ? castSlice(strSymbols, 0, end).join('') 23046 : string.slice(0, end); 23047 23048 if (separator === undefined) { 23049 return result + omission; 23050 } 23051 if (strSymbols) { 23052 end += (result.length - end); 23053 } 23054 if (isRegExp(separator)) { 23055 if (string.slice(end).search(separator)) { 23056 var match, 23057 substring = result; 23058 23059 if (!separator.global) { 23060 separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g'); 23061 } 23062 separator.lastIndex = 0; 23063 while ((match = separator.exec(substring))) { 23064 var newEnd = match.index; 23065 } 23066 result = result.slice(0, newEnd === undefined ? end : newEnd); 23067 } 23068 } else if (string.indexOf(baseToString(separator), end) != end) { 23069 var index = result.lastIndexOf(separator); 23070 if (index > -1) { 23071 result = result.slice(0, index); 23072 } 23073 } 23074 return result + omission; 23075 } 23076 23077 /** 23078 * The inverse of `_.escape`; this method converts the HTML entities 23079 * `&`, `<`, `>`, `"`, and `'` in `string` to 23080 * their corresponding characters. 23081 * 23082 * **Note:** No other HTML entities are unescaped. To unescape additional 23083 * HTML entities use a third-party library like [_he_](https://mths.be/he). 23084 * 23085 * @static 23086 * @memberOf _ 23087 * @since 0.6.0 23088 * @category String 23089 * @param {string} [string=''] The string to unescape. 23090 * @returns {string} Returns the unescaped string. 23091 * @example 23092 * 23093 * _.unescape('fred, barney, & pebbles'); 23094 * // => 'fred, barney, & pebbles' 23095 */ 23096 function unescape(string) {
vendor: 5,637 bytes, lines 23097-23284
23097 string = toString(string); 23098 return (string && reHasEscapedHtml.test(string)) 23099 ? string.replace(reEscapedHtml, unescapeHtmlChar) 23100 : string; 23101 } 23102 23103 /** 23104 * Converts `string`, as space separated words, to upper case. 23105 * 23106 * @static 23107 * @memberOf _ 23108 * @since 4.0.0 23109 * @category String 23110 * @param {string} [string=''] The string to convert. 23111 * @returns {string} Returns the upper cased string. 23112 * @example 23113 * 23114 * _.upperCase('--foo-bar'); 23115 * // => 'FOO BAR' 23116 * 23117 * _.upperCase('fooBar'); 23118 * // => 'FOO BAR' 23119 * 23120 * _.upperCase('__foo_bar__'); 23121 * // => 'FOO BAR' 23122 */ 23123 var upperCase = createCompounder(function(result, word, index) { 23124 return result + (index ? ' ' : '') + word.toUpperCase(); 23125 }); 23126 23127 /** 23128 * Converts the first character of `string` to upper case. 23129 * 23130 * @static 23131 * @memberOf _ 23132 * @since 4.0.0 23133 * @category String 23134 * @param {string} [string=''] The string to convert. 23135 * @returns {string} Returns the converted string. 23136 * @example 23137 * 23138 * _.upperFirst('fred'); 23139 * // => 'Fred' 23140 * 23141 * _.upperFirst('FRED'); 23142 * // => 'FRED' 23143 */ 23144 var upperFirst = createCaseFirst('toUpperCase'); 23145 23146 /** 23147 * Splits `string` into an array of its words. 23148 * 23149 * @static 23150 * @memberOf _ 23151 * @since 3.0.0 23152 * @category String 23153 * @param {string} [string=''] The string to inspect. 23154 * @param {RegExp|string} [pattern] The pattern to match words. 23155 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 23156 * @returns {Array} Returns the words of `string`. 23157 * @example 23158 * 23159 * _.words('fred, barney, & pebbles'); 23160 * // => ['fred', 'barney', 'pebbles'] 23161 * 23162 * _.words('fred, barney, & pebbles', /[^, ]+/g); 23163 * // => ['fred', 'barney', '&', 'pebbles'] 23164 */ 23165 function words(string, pattern, guard) { 23166 string = toString(string); 23167 pattern = guard ? undefined : pattern; 23168 23169 if (pattern === undefined) { 23170 return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); 23171 } 23172 return string.match(pattern) || []; 23173 } 23174 23175 /*------------------------------------------------------------------------*/ 23176 23177 /** 23178 * Attempts to invoke `func`, returning either the result or the caught error 23179 * object. Any additional arguments are provided to `func` when it's invoked. 23180 * 23181 * @static 23182 * @memberOf _ 23183 * @since 3.0.0 23184 * @category Util 23185 * @param {Function} func The function to attempt. 23186 * @param {...*} [args] The arguments to invoke `func` with. 23187 * @returns {*} Returns the `func` result or error object. 23188 * @example 23189 * 23190 * // Avoid throwing errors for invalid selectors. 23191 * var elements = _.attempt(function(selector) { 23192 * return document.querySelectorAll(selector); 23193 * }, '>_>'); 23194 * 23195 * if (_.isError(elements)) { 23196 * elements = []; 23197 * } 23198 */ 23199 var attempt = baseRest(function(func, args) { 23200 try { 23201 return apply(func, undefined, args); 23202 } catch (e) { 23203 return isError(e) ? e : new Error(e); 23204 } 23205 }); 23206 23207 /** 23208 * Binds methods of an object to the object itself, overwriting the existing 23209 * method. 23210 * 23211 * **Note:** This method doesn't set the "length" property of bound functions. 23212 * 23213 * @static 23214 * @since 0.1.0 23215 * @memberOf _ 23216 * @category Util 23217 * @param {Object} object The object to bind and assign the bound methods to. 23218 * @param {...(string|string[])} methodNames The object method names to bind. 23219 * @returns {Object} Returns `object`. 23220 * @example 23221 * 23222 * var view = { 23223 * 'label': 'docs', 23224 * 'click': function() { 23225 * console.log('clicked ' + this.label); 23226 * } 23227 * }; 23228 * 23229 * _.bindAll(view, ['click']); 23230 * jQuery(element).on('click', view.click); 23231 * // => Logs 'clicked docs' when clicked. 23232 */ 23233 var bindAll = flatRest(function(object, methodNames) { 23234 arrayEach(methodNames, function(key) { 23235 key = toKey(key); 23236 baseAssignValue(object, key, bind(object[key], object)); 23237 }); 23238 return object; 23239 }); 23240 23241 /** 23242 * Creates a function that iterates over `pairs` and invokes the corresponding 23243 * function of the first predicate to return truthy. The predicate-function 23244 * pairs are invoked with the `this` binding and arguments of the created 23245 * function. 23246 * 23247 * @static 23248 * @memberOf _ 23249 * @since 4.0.0 23250 * @category Util 23251 * @param {Array} pairs The predicate-function pairs. 23252 * @returns {Function} Returns the new composite function. 23253 * @example 23254 * 23255 * var func = _.cond([ 23256 * [_.matches({ 'a': 1 }), _.constant('matches A')], 23257 * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], 23258 * [_.stubTrue, _.constant('no match')] 23259 * ]); 23260 * 23261 * func({ 'a': 1, 'b': 2 }); 23262 * // => 'matches A' 23263 * 23264 * func({ 'a': 0, 'b': 1 }); 23265 * // => 'matches B' 23266 * 23267 * func({ 'a': '1', 'b': '2' }); 23268 * // => 'no match' 23269 */ 23270 function cond(pairs) { 23271 var length = pairs == null ? 0 : pairs.length, 23272 toIteratee = getIteratee(); 23273 23274 pairs = !length ? [] : arrayMap(pairs, function(pair) { 23275 if (typeof pair[1] != 'function') { 23276 throw new TypeError(FUNC_ERROR_TEXT); 23277 } 23278 return [toIteratee(pair[0]), pair[1]]; 23279 }); 23280 23281 return baseRest(function(args) { 23282 var index = -1; 23283 while (++index < length) { 23284 var pair = pairs[index];
vendor: 19,681 bytes, lines 23285-23980
23285 if (apply(pair[0], this, args)) { 23286 return apply(pair[1], this, args); 23287 } 23288 } 23289 }); 23290 } 23291 23292 /** 23293 * Creates a function that invokes the predicate properties of `source` with 23294 * the corresponding property values of a given object, returning `true` if 23295 * all predicates return truthy, else `false`. 23296 * 23297 * **Note:** The created function is equivalent to `_.conformsTo` with 23298 * `source` partially applied. 23299 * 23300 * @static 23301 * @memberOf _ 23302 * @since 4.0.0 23303 * @category Util 23304 * @param {Object} source The object of property predicates to conform to. 23305 * @returns {Function} Returns the new spec function. 23306 * @example 23307 * 23308 * var objects = [ 23309 * { 'a': 2, 'b': 1 }, 23310 * { 'a': 1, 'b': 2 } 23311 * ]; 23312 * 23313 * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } })); 23314 * // => [{ 'a': 1, 'b': 2 }] 23315 */ 23316 function conforms(source) { 23317 return baseConforms(baseClone(source, CLONE_DEEP_FLAG)); 23318 } 23319 23320 /** 23321 * Creates a function that returns `value`. 23322 * 23323 * @static 23324 * @memberOf _ 23325 * @since 2.4.0 23326 * @category Util 23327 * @param {*} value The value to return from the new function. 23328 * @returns {Function} Returns the new constant function. 23329 * @example 23330 * 23331 * var objects = _.times(2, _.constant({ 'a': 1 })); 23332 * 23333 * console.log(objects); 23334 * // => [{ 'a': 1 }, { 'a': 1 }] 23335 * 23336 * console.log(objects[0] === objects[1]); 23337 * // => true 23338 */ 23339 function constant(value) { 23340 return function() { 23341 return value; 23342 }; 23343 } 23344 23345 /** 23346 * Checks `value` to determine whether a default value should be returned in 23347 * its place. The `defaultValue` is returned if `value` is `NaN`, `null`, 23348 * or `undefined`. 23349 * 23350 * @static 23351 * @memberOf _ 23352 * @since 4.14.0 23353 * @category Util 23354 * @param {*} value The value to check. 23355 * @param {*} defaultValue The default value. 23356 * @returns {*} Returns the resolved value. 23357 * @example 23358 * 23359 * _.defaultTo(1, 10); 23360 * // => 1 23361 * 23362 * _.defaultTo(undefined, 10); 23363 * // => 10 23364 */ 23365 function defaultTo(value, defaultValue) { 23366 return (value == null || value !== value) ? defaultValue : value; 23367 } 23368 23369 /** 23370 * Creates a function that returns the result of invoking the given functions 23371 * with the `this` binding of the created function, where each successive 23372 * invocation is supplied the return value of the previous. 23373 * 23374 * @static 23375 * @memberOf _ 23376 * @since 3.0.0 23377 * @category Util 23378 * @param {...(Function|Function[])} [funcs] The functions to invoke. 23379 * @returns {Function} Returns the new composite function. 23380 * @see _.flowRight 23381 * @example 23382 * 23383 * function square(n) { 23384 * return n * n; 23385 * } 23386 * 23387 * var addSquare = _.flow([_.add, square]); 23388 * addSquare(1, 2); 23389 * // => 9 23390 */ 23391 var flow = createFlow(); 23392 23393 /** 23394 * This method is like `_.flow` except that it creates a function that 23395 * invokes the given functions from right to left. 23396 * 23397 * @static 23398 * @since 3.0.0 23399 * @memberOf _ 23400 * @category Util 23401 * @param {...(Function|Function[])} [funcs] The functions to invoke. 23402 * @returns {Function} Returns the new composite function. 23403 * @see _.flow 23404 * @example 23405 * 23406 * function square(n) { 23407 * return n * n; 23408 * } 23409 * 23410 * var addSquare = _.flowRight([square, _.add]); 23411 * addSquare(1, 2); 23412 * // => 9 23413 */ 23414 var flowRight = createFlow(true); 23415 23416 /** 23417 * This method returns the first argument it receives. 23418 * 23419 * @static 23420 * @since 0.1.0 23421 * @memberOf _ 23422 * @category Util 23423 * @param {*} value Any value. 23424 * @returns {*} Returns `value`. 23425 * @example 23426 * 23427 * var object = { 'a': 1 }; 23428 * 23429 * console.log(_.identity(object) === object); 23430 * // => true 23431 */ 23432 function identity(value) { 23433 return value; 23434 } 23435 23436 /** 23437 * Creates a function that invokes `func` with the arguments of the created 23438 * function. If `func` is a property name, the created function returns the 23439 * property value for a given element. If `func` is an array or object, the 23440 * created function returns `true` for elements that contain the equivalent 23441 * source properties, otherwise it returns `false`. 23442 * 23443 * @static 23444 * @since 4.0.0 23445 * @memberOf _ 23446 * @category Util 23447 * @param {*} [func=_.identity] The value to convert to a callback. 23448 * @returns {Function} Returns the callback. 23449 * @example 23450 * 23451 * var users = [ 23452 * { 'user': 'barney', 'age': 36, 'active': true }, 23453 * { 'user': 'fred', 'age': 40, 'active': false } 23454 * ]; 23455 * 23456 * // The `_.matches` iteratee shorthand. 23457 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true })); 23458 * // => [{ 'user': 'barney', 'age': 36, 'active': true }] 23459 * 23460 * // The `_.matchesProperty` iteratee shorthand. 23461 * _.filter(users, _.iteratee(['user', 'fred'])); 23462 * // => [{ 'user': 'fred', 'age': 40 }] 23463 * 23464 * // The `_.property` iteratee shorthand. 23465 * _.map(users, _.iteratee('user')); 23466 * // => ['barney', 'fred'] 23467 * 23468 * // Create custom iteratee shorthands. 23469 * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) { 23470 * return !_.isRegExp(func) ? iteratee(func) : function(string) { 23471 * return func.test(string); 23472 * }; 23473 * }); 23474 * 23475 * _.filter(['abc', 'def'], /ef/); 23476 * // => ['def'] 23477 */ 23478 function iteratee(func) { 23479 return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG)); 23480 } 23481 23482 /** 23483 * Creates a function that performs a partial deep comparison between a given 23484 * object and `source`, returning `true` if the given object has equivalent 23485 * property values, else `false`. 23486 * 23487 * **Note:** The created function is equivalent to `_.isMatch` with `source` 23488 * partially applied. 23489 * 23490 * Partial comparisons will match empty array and empty object `source` 23491 * values against any array or object value, respectively. See `_.isEqual` 23492 * for a list of supported value comparisons. 23493 * 23494 * @static 23495 * @memberOf _ 23496 * @since 3.0.0 23497 * @category Util 23498 * @param {Object} source The object of property values to match. 23499 * @returns {Function} Returns the new spec function. 23500 * @example 23501 * 23502 * var objects = [ 23503 * { 'a': 1, 'b': 2, 'c': 3 }, 23504 * { 'a': 4, 'b': 5, 'c': 6 } 23505 * ]; 23506 * 23507 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 })); 23508 * // => [{ 'a': 4, 'b': 5, 'c': 6 }] 23509 */ 23510 function matches(source) { 23511 return baseMatches(baseClone(source, CLONE_DEEP_FLAG)); 23512 } 23513 23514 /** 23515 * Creates a function that performs a partial deep comparison between the 23516 * value at `path` of a given object to `srcValue`, returning `true` if the 23517 * object value is equivalent, else `false`. 23518 * 23519 * **Note:** Partial comparisons will match empty array and empty object 23520 * `srcValue` values against any array or object value, respectively. See 23521 * `_.isEqual` for a list of supported value comparisons. 23522 * 23523 * @static 23524 * @memberOf _ 23525 * @since 3.2.0 23526 * @category Util 23527 * @param {Array|string} path The path of the property to get. 23528 * @param {*} srcValue The value to match. 23529 * @returns {Function} Returns the new spec function. 23530 * @example 23531 * 23532 * var objects = [ 23533 * { 'a': 1, 'b': 2, 'c': 3 }, 23534 * { 'a': 4, 'b': 5, 'c': 6 } 23535 * ]; 23536 * 23537 * _.find(objects, _.matchesProperty('a', 4)); 23538 * // => { 'a': 4, 'b': 5, 'c': 6 } 23539 */ 23540 function matchesProperty(path, srcValue) { 23541 return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG)); 23542 } 23543 23544 /** 23545 * Creates a function that invokes the method at `path` of a given object. 23546 * Any additional arguments are provided to the invoked method. 23547 * 23548 * @static 23549 * @memberOf _ 23550 * @since 3.7.0 23551 * @category Util 23552 * @param {Array|string} path The path of the method to invoke. 23553 * @param {...*} [args] The arguments to invoke the method with. 23554 * @returns {Function} Returns the new invoker function. 23555 * @example 23556 * 23557 * var objects = [ 23558 * { 'a': { 'b': _.constant(2) } }, 23559 * { 'a': { 'b': _.constant(1) } } 23560 * ]; 23561 * 23562 * _.map(objects, _.method('a.b')); 23563 * // => [2, 1] 23564 * 23565 * _.map(objects, _.method(['a', 'b'])); 23566 * // => [2, 1] 23567 */ 23568 var method = baseRest(function(path, args) { 23569 return function(object) { 23570 return baseInvoke(object, path, args); 23571 }; 23572 }); 23573 23574 /** 23575 * The opposite of `_.method`; this method creates a function that invokes 23576 * the method at a given path of `object`. Any additional arguments are 23577 * provided to the invoked method. 23578 * 23579 * @static 23580 * @memberOf _ 23581 * @since 3.7.0 23582 * @category Util 23583 * @param {Object} object The object to query. 23584 * @param {...*} [args] The arguments to invoke the method with. 23585 * @returns {Function} Returns the new invoker function. 23586 * @example 23587 * 23588 * var array = _.times(3, _.constant), 23589 * object = { 'a': array, 'b': array, 'c': array }; 23590 * 23591 * _.map(['a[2]', 'c[0]'], _.methodOf(object)); 23592 * // => [2, 0] 23593 * 23594 * _.map([['a', '2'], ['c', '0']], _.methodOf(object)); 23595 * // => [2, 0] 23596 */ 23597 var methodOf = baseRest(function(object, args) { 23598 return function(path) { 23599 return baseInvoke(object, path, args); 23600 }; 23601 }); 23602 23603 /** 23604 * Adds all own enumerable string keyed function properties of a source 23605 * object to the destination object. If `object` is a function, then methods 23606 * are added to its prototype as well. 23607 * 23608 * **Note:** Use `_.runInContext` to create a pristine `lodash` function to 23609 * avoid conflicts caused by modifying the original. 23610 * 23611 * @static 23612 * @since 0.1.0 23613 * @memberOf _ 23614 * @category Util 23615 * @param {Function|Object} [object=lodash] The destination object. 23616 * @param {Object} source The object of functions to add. 23617 * @param {Object} [options={}] The options object. 23618 * @param {boolean} [options.chain=true] Specify whether mixins are chainable. 23619 * @returns {Function|Object} Returns `object`. 23620 * @example 23621 * 23622 * function vowels(string) { 23623 * return _.filter(string, function(v) { 23624 * return /[aeiou]/i.test(v); 23625 * }); 23626 * } 23627 * 23628 * _.mixin({ 'vowels': vowels }); 23629 * _.vowels('fred'); 23630 * // => ['e'] 23631 * 23632 * _('fred').vowels().value(); 23633 * // => ['e'] 23634 * 23635 * _.mixin({ 'vowels': vowels }, { 'chain': false }); 23636 * _('fred').vowels(); 23637 * // => ['e'] 23638 */ 23639 function mixin(object, source, options) { 23640 var props = keys(source), 23641 methodNames = baseFunctions(source, props); 23642 23643 if (options == null && 23644 !(isObject(source) && (methodNames.length || !props.length))) { 23645 options = source; 23646 source = object; 23647 object = this; 23648 methodNames = baseFunctions(source, keys(source)); 23649 } 23650 var chain = !(isObject(options) && 'chain' in options) || !!options.chain, 23651 isFunc = isFunction(object); 23652 23653 arrayEach(methodNames, function(methodName) { 23654 var func = source[methodName]; 23655 object[methodName] = func; 23656 if (isFunc) { 23657 object.prototype[methodName] = function() { 23658 var chainAll = this.__chain__; 23659 if (chain || chainAll) { 23660 var result = object(this.__wrapped__), 23661 actions = result.__actions__ = copyArray(this.__actions__); 23662 23663 actions.push({ 'func': func, 'args': arguments, 'thisArg': object }); 23664 result.__chain__ = chainAll; 23665 return result; 23666 } 23667 return func.apply(object, arrayPush([this.value()], arguments)); 23668 }; 23669 } 23670 }); 23671 23672 return object; 23673 } 23674 23675 /** 23676 * Reverts the `_` variable to its previous value and returns a reference to 23677 * the `lodash` function. 23678 * 23679 * @static 23680 * @since 0.1.0 23681 * @memberOf _ 23682 * @category Util 23683 * @returns {Function} Returns the `lodash` function. 23684 * @example 23685 * 23686 * var lodash = _.noConflict(); 23687 */ 23688 function noConflict() { 23689 if (root._ === this) { 23690 root._ = oldDash; 23691 } 23692 return this; 23693 } 23694 23695 /** 23696 * This method returns `undefined`. 23697 * 23698 * @static 23699 * @memberOf _ 23700 * @since 2.3.0 23701 * @category Util 23702 * @example 23703 * 23704 * _.times(2, _.noop); 23705 * // => [undefined, undefined] 23706 */ 23707 function noop() { 23708 // No operation performed. 23709 } 23710 23711 /** 23712 * Creates a function that gets the argument at index `n`. If `n` is negative, 23713 * the nth argument from the end is returned. 23714 * 23715 * @static 23716 * @memberOf _ 23717 * @since 4.0.0 23718 * @category Util 23719 * @param {number} [n=0] The index of the argument to return. 23720 * @returns {Function} Returns the new pass-thru function. 23721 * @example 23722 * 23723 * var func = _.nthArg(1); 23724 * func('a', 'b', 'c', 'd'); 23725 * // => 'b' 23726 * 23727 * var func = _.nthArg(-2); 23728 * func('a', 'b', 'c', 'd'); 23729 * // => 'c' 23730 */ 23731 function nthArg(n) { 23732 n = toInteger(n); 23733 return baseRest(function(args) { 23734 return baseNth(args, n); 23735 }); 23736 } 23737 23738 /** 23739 * Creates a function that invokes `iteratees` with the arguments it receives 23740 * and returns their results. 23741 * 23742 * @static 23743 * @memberOf _ 23744 * @since 4.0.0 23745 * @category Util 23746 * @param {...(Function|Function[])} [iteratees=[_.identity]] 23747 * The iteratees to invoke. 23748 * @returns {Function} Returns the new function. 23749 * @example 23750 * 23751 * var func = _.over([Math.max, Math.min]); 23752 * 23753 * func(1, 2, 3, 4); 23754 * // => [4, 1] 23755 */ 23756 var over = createOver(arrayMap); 23757 23758 /** 23759 * Creates a function that checks if **all** of the `predicates` return 23760 * truthy when invoked with the arguments it receives. 23761 * 23762 * @static 23763 * @memberOf _ 23764 * @since 4.0.0 23765 * @category Util 23766 * @param {...(Function|Function[])} [predicates=[_.identity]] 23767 * The predicates to check. 23768 * @returns {Function} Returns the new function. 23769 * @example 23770 * 23771 * var func = _.overEvery([Boolean, isFinite]); 23772 * 23773 * func('1'); 23774 * // => true 23775 * 23776 * func(null); 23777 * // => false 23778 * 23779 * func(NaN); 23780 * // => false 23781 */ 23782 var overEvery = createOver(arrayEvery); 23783 23784 /** 23785 * Creates a function that checks if **any** of the `predicates` return 23786 * truthy when invoked with the arguments it receives. 23787 * 23788 * @static 23789 * @memberOf _ 23790 * @since 4.0.0 23791 * @category Util 23792 * @param {...(Function|Function[])} [predicates=[_.identity]] 23793 * The predicates to check. 23794 * @returns {Function} Returns the new function. 23795 * @example 23796 * 23797 * var func = _.overSome([Boolean, isFinite]); 23798 * 23799 * func('1'); 23800 * // => true 23801 * 23802 * func(null); 23803 * // => true 23804 * 23805 * func(NaN); 23806 * // => false 23807 */ 23808 var overSome = createOver(arraySome); 23809 23810 /** 23811 * Creates a function that returns the value at `path` of a given object. 23812 * 23813 * @static 23814 * @memberOf _ 23815 * @since 2.4.0 23816 * @category Util 23817 * @param {Array|string} path The path of the property to get. 23818 * @returns {Function} Returns the new accessor function. 23819 * @example 23820 * 23821 * var objects = [ 23822 * { 'a': { 'b': 2 } }, 23823 * { 'a': { 'b': 1 } } 23824 * ]; 23825 * 23826 * _.map(objects, _.property('a.b')); 23827 * // => [2, 1] 23828 * 23829 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); 23830 * // => [1, 2] 23831 */ 23832 function property(path) { 23833 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); 23834 } 23835 23836 /** 23837 * The opposite of `_.property`; this method creates a function that returns 23838 * the value at a given path of `object`. 23839 * 23840 * @static 23841 * @memberOf _ 23842 * @since 3.0.0 23843 * @category Util 23844 * @param {Object} object The object to query. 23845 * @returns {Function} Returns the new accessor function. 23846 * @example 23847 * 23848 * var array = [0, 1, 2], 23849 * object = { 'a': array, 'b': array, 'c': array }; 23850 * 23851 * _.map(['a[2]', 'c[0]'], _.propertyOf(object)); 23852 * // => [2, 0] 23853 * 23854 * _.map([['a', '2'], ['c', '0']], _.propertyOf(object)); 23855 * // => [2, 0] 23856 */ 23857 function propertyOf(object) { 23858 return function(path) { 23859 return object == null ? undefined : baseGet(object, path); 23860 }; 23861 } 23862 23863 /** 23864 * Creates an array of numbers (positive and/or negative) progressing from 23865 * `start` up to, but not including, `end`. A step of `-1` is used if a negative 23866 * `start` is specified without an `end` or `step`. If `end` is not specified, 23867 * it's set to `start` with `start` then set to `0`. 23868 * 23869 * **Note:** JavaScript follows the IEEE-754 standard for resolving 23870 * floating-point values which can produce unexpected results. 23871 * 23872 * @static 23873 * @since 0.1.0 23874 * @memberOf _ 23875 * @category Util 23876 * @param {number} [start=0] The start of the range. 23877 * @param {number} end The end of the range. 23878 * @param {number} [step=1] The value to increment or decrement by. 23879 * @returns {Array} Returns the range of numbers. 23880 * @see _.inRange, _.rangeRight 23881 * @example 23882 * 23883 * _.range(4); 23884 * // => [0, 1, 2, 3] 23885 * 23886 * _.range(-4); 23887 * // => [0, -1, -2, -3] 23888 * 23889 * _.range(1, 5); 23890 * // => [1, 2, 3, 4] 23891 * 23892 * _.range(0, 20, 5); 23893 * // => [0, 5, 10, 15] 23894 * 23895 * _.range(0, -4, -1); 23896 * // => [0, -1, -2, -3] 23897 * 23898 * _.range(1, 4, 0); 23899 * // => [1, 1, 1] 23900 * 23901 * _.range(0); 23902 * // => [] 23903 */ 23904 var range = createRange(); 23905 23906 /** 23907 * This method is like `_.range` except that it populates values in 23908 * descending order. 23909 * 23910 * @static 23911 * @memberOf _ 23912 * @since 4.0.0 23913 * @category Util 23914 * @param {number} [start=0] The start of the range. 23915 * @param {number} end The end of the range. 23916 * @param {number} [step=1] The value to increment or decrement by. 23917 * @returns {Array} Returns the range of numbers. 23918 * @see _.inRange, _.range 23919 * @example 23920 * 23921 * _.rangeRight(4); 23922 * // => [3, 2, 1, 0] 23923 * 23924 * _.rangeRight(-4); 23925 * // => [-3, -2, -1, 0] 23926 * 23927 * _.rangeRight(1, 5); 23928 * // => [4, 3, 2, 1] 23929 * 23930 * _.rangeRight(0, 20, 5); 23931 * // => [15, 10, 5, 0] 23932 * 23933 * _.rangeRight(0, -4, -1); 23934 * // => [-3, -2, -1, 0] 23935 * 23936 * _.rangeRight(1, 4, 0); 23937 * // => [1, 1, 1] 23938 * 23939 * _.rangeRight(0); 23940 * // => [] 23941 */ 23942 var rangeRight = createRange(true); 23943 23944 /** 23945 * This method returns a new empty array. 23946 * 23947 * @static 23948 * @memberOf _ 23949 * @since 4.13.0 23950 * @category Util 23951 * @returns {Array} Returns the new empty array. 23952 * @example 23953 * 23954 * var arrays = _.times(2, _.stubArray); 23955 * 23956 * console.log(arrays); 23957 * // => [[], []] 23958 * 23959 * console.log(arrays[0] === arrays[1]); 23960 * // => false 23961 */ 23962 function stubArray() { 23963 return []; 23964 } 23965 23966 /** 23967 * This method returns `false`. 23968 * 23969 * @static 23970 * @memberOf _ 23971 * @since 4.13.0 23972 * @category Util 23973 * @returns {boolean} Returns `false`. 23974 * @example 23975 * 23976 * _.times(2, _.stubFalse); 23977 * // => [false, false] 23978 */ 23979 function stubFalse() { 23980 return false;
vendor: 1,044 bytes, lines 23981-24034
23981 } 23982 23983 /** 23984 * This method returns a new empty object. 23985 * 23986 * @static 23987 * @memberOf _ 23988 * @since 4.13.0 23989 * @category Util 23990 * @returns {Object} Returns the new empty object. 23991 * @example 23992 * 23993 * var objects = _.times(2, _.stubObject); 23994 * 23995 * console.log(objects); 23996 * // => [{}, {}] 23997 * 23998 * console.log(objects[0] === objects[1]); 23999 * // => false 24000 */ 24001 function stubObject() { 24002 return {}; 24003 } 24004 24005 /** 24006 * This method returns an empty string. 24007 * 24008 * @static 24009 * @memberOf _ 24010 * @since 4.13.0 24011 * @category Util 24012 * @returns {string} Returns the empty string. 24013 * @example 24014 * 24015 * _.times(2, _.stubString); 24016 * // => ['', ''] 24017 */ 24018 function stubString() { 24019 return ''; 24020 } 24021 24022 /** 24023 * This method returns `true`. 24024 * 24025 * @static 24026 * @memberOf _ 24027 * @since 4.13.0 24028 * @category Util 24029 * @returns {boolean} Returns `true`. 24030 * @example 24031 * 24032 * _.times(2, _.stubTrue); 24033 * // => [true, true] 24034 */
vendor: 9,081 bytes, lines 24035-24378
24035 function stubTrue() { 24036 return true; 24037 } 24038 24039 /** 24040 * Invokes the iteratee `n` times, returning an array of the results of 24041 * each invocation. The iteratee is invoked with one argument; (index). 24042 * 24043 * @static 24044 * @since 0.1.0 24045 * @memberOf _ 24046 * @category Util 24047 * @param {number} n The number of times to invoke `iteratee`. 24048 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 24049 * @returns {Array} Returns the array of results. 24050 * @example 24051 * 24052 * _.times(3, String); 24053 * // => ['0', '1', '2'] 24054 * 24055 * _.times(4, _.constant(0)); 24056 * // => [0, 0, 0, 0] 24057 */ 24058 function times(n, iteratee) { 24059 n = toInteger(n); 24060 if (n < 1 || n > MAX_SAFE_INTEGER) { 24061 return []; 24062 } 24063 var index = MAX_ARRAY_LENGTH, 24064 length = nativeMin(n, MAX_ARRAY_LENGTH); 24065 24066 iteratee = getIteratee(iteratee); 24067 n -= MAX_ARRAY_LENGTH; 24068 24069 var result = baseTimes(length, iteratee); 24070 while (++index < n) { 24071 iteratee(index); 24072 } 24073 return result; 24074 } 24075 24076 /** 24077 * Converts `value` to a property path array. 24078 * 24079 * @static 24080 * @memberOf _ 24081 * @since 4.0.0 24082 * @category Util 24083 * @param {*} value The value to convert. 24084 * @returns {Array} Returns the new property path array. 24085 * @example 24086 * 24087 * _.toPath('a.b.c'); 24088 * // => ['a', 'b', 'c'] 24089 * 24090 * _.toPath('a[0].b.c'); 24091 * // => ['a', '0', 'b', 'c'] 24092 */ 24093 function toPath(value) { 24094 if (isArray(value)) { 24095 return arrayMap(value, toKey); 24096 } 24097 return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value))); 24098 } 24099 24100 /** 24101 * Generates a unique ID. If `prefix` is given, the ID is appended to it. 24102 * 24103 * @static 24104 * @since 0.1.0 24105 * @memberOf _ 24106 * @category Util 24107 * @param {string} [prefix=''] The value to prefix the ID with. 24108 * @returns {string} Returns the unique ID. 24109 * @example 24110 * 24111 * _.uniqueId('contact_'); 24112 * // => 'contact_104' 24113 * 24114 * _.uniqueId(); 24115 * // => '105' 24116 */ 24117 function uniqueId(prefix) { 24118 var id = ++idCounter; 24119 return toString(prefix) + id; 24120 } 24121 24122 /*------------------------------------------------------------------------*/ 24123 24124 /** 24125 * Adds two numbers. 24126 * 24127 * @static 24128 * @memberOf _ 24129 * @since 3.4.0 24130 * @category Math 24131 * @param {number} augend The first number in an addition. 24132 * @param {number} addend The second number in an addition. 24133 * @returns {number} Returns the total. 24134 * @example 24135 * 24136 * _.add(6, 4); 24137 * // => 10 24138 */ 24139 var add = createMathOperation(function(augend, addend) { 24140 return augend + addend; 24141 }, 0); 24142 24143 /** 24144 * Computes `number` rounded up to `precision`. 24145 * 24146 * @static 24147 * @memberOf _ 24148 * @since 3.10.0 24149 * @category Math 24150 * @param {number} number The number to round up. 24151 * @param {number} [precision=0] The precision to round up to. 24152 * @returns {number} Returns the rounded up number. 24153 * @example 24154 * 24155 * _.ceil(4.006); 24156 * // => 5 24157 * 24158 * _.ceil(6.004, 2); 24159 * // => 6.01 24160 * 24161 * _.ceil(6040, -2); 24162 * // => 6100 24163 */ 24164 var ceil = createRound('ceil'); 24165 24166 /** 24167 * Divide two numbers. 24168 * 24169 * @static 24170 * @memberOf _ 24171 * @since 4.7.0 24172 * @category Math 24173 * @param {number} dividend The first number in a division. 24174 * @param {number} divisor The second number in a division. 24175 * @returns {number} Returns the quotient. 24176 * @example 24177 * 24178 * _.divide(6, 4); 24179 * // => 1.5 24180 */ 24181 var divide = createMathOperation(function(dividend, divisor) { 24182 return dividend / divisor; 24183 }, 1); 24184 24185 /** 24186 * Computes `number` rounded down to `precision`. 24187 * 24188 * @static 24189 * @memberOf _ 24190 * @since 3.10.0 24191 * @category Math 24192 * @param {number} number The number to round down. 24193 * @param {number} [precision=0] The precision to round down to. 24194 * @returns {number} Returns the rounded down number. 24195 * @example 24196 * 24197 * _.floor(4.006); 24198 * // => 4 24199 * 24200 * _.floor(0.046, 2); 24201 * // => 0.04 24202 * 24203 * _.floor(4060, -2); 24204 * // => 4000 24205 */ 24206 var floor = createRound('floor'); 24207 24208 /** 24209 * Computes the maximum value of `array`. If `array` is empty or falsey, 24210 * `undefined` is returned. 24211 * 24212 * @static 24213 * @since 0.1.0 24214 * @memberOf _ 24215 * @category Math 24216 * @param {Array} array The array to iterate over. 24217 * @returns {*} Returns the maximum value. 24218 * @example 24219 * 24220 * _.max([4, 2, 8, 6]); 24221 * // => 8 24222 * 24223 * _.max([]); 24224 * // => undefined 24225 */ 24226 function max(array) { 24227 return (array && array.length) 24228 ? baseExtremum(array, identity, baseGt) 24229 : undefined; 24230 } 24231 24232 /** 24233 * This method is like `_.max` except that it accepts `iteratee` which is 24234 * invoked for each element in `array` to generate the criterion by which 24235 * the value is ranked. The iteratee is invoked with one argument: (value). 24236 * 24237 * @static 24238 * @memberOf _ 24239 * @since 4.0.0 24240 * @category Math 24241 * @param {Array} array The array to iterate over. 24242 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 24243 * @returns {*} Returns the maximum value. 24244 * @example 24245 * 24246 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 24247 * 24248 * _.maxBy(objects, function(o) { return o.n; }); 24249 * // => { 'n': 2 } 24250 * 24251 * // The `_.property` iteratee shorthand. 24252 * _.maxBy(objects, 'n'); 24253 * // => { 'n': 2 } 24254 */ 24255 function maxBy(array, iteratee) { 24256 return (array && array.length) 24257 ? baseExtremum(array, getIteratee(iteratee, 2), baseGt) 24258 : undefined; 24259 } 24260 24261 /** 24262 * Computes the mean of the values in `array`. 24263 * 24264 * @static 24265 * @memberOf _ 24266 * @since 4.0.0 24267 * @category Math 24268 * @param {Array} array The array to iterate over. 24269 * @returns {number} Returns the mean. 24270 * @example 24271 * 24272 * _.mean([4, 2, 8, 6]); 24273 * // => 5 24274 */ 24275 function mean(array) { 24276 return baseMean(array, identity); 24277 } 24278 24279 /** 24280 * This method is like `_.mean` except that it accepts `iteratee` which is 24281 * invoked for each element in `array` to generate the value to be averaged. 24282 * The iteratee is invoked with one argument: (value). 24283 * 24284 * @static 24285 * @memberOf _ 24286 * @since 4.7.0 24287 * @category Math 24288 * @param {Array} array The array to iterate over. 24289 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 24290 * @returns {number} Returns the mean. 24291 * @example 24292 * 24293 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 24294 * 24295 * _.meanBy(objects, function(o) { return o.n; }); 24296 * // => 5 24297 * 24298 * // The `_.property` iteratee shorthand. 24299 * _.meanBy(objects, 'n'); 24300 * // => 5 24301 */ 24302 function meanBy(array, iteratee) { 24303 return baseMean(array, getIteratee(iteratee, 2)); 24304 } 24305 24306 /** 24307 * Computes the minimum value of `array`. If `array` is empty or falsey, 24308 * `undefined` is returned. 24309 * 24310 * @static 24311 * @since 0.1.0 24312 * @memberOf _ 24313 * @category Math 24314 * @param {Array} array The array to iterate over. 24315 * @returns {*} Returns the minimum value. 24316 * @example 24317 * 24318 * _.min([4, 2, 8, 6]); 24319 * // => 2 24320 * 24321 * _.min([]); 24322 * // => undefined 24323 */ 24324 function min(array) { 24325 return (array && array.length) 24326 ? baseExtremum(array, identity, baseLt) 24327 : undefined; 24328 } 24329 24330 /** 24331 * This method is like `_.min` except that it accepts `iteratee` which is 24332 * invoked for each element in `array` to generate the criterion by which 24333 * the value is ranked. The iteratee is invoked with one argument: (value). 24334 * 24335 * @static 24336 * @memberOf _ 24337 * @since 4.0.0 24338 * @category Math 24339 * @param {Array} array The array to iterate over. 24340 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 24341 * @returns {*} Returns the minimum value. 24342 * @example 24343 * 24344 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 24345 * 24346 * _.minBy(objects, function(o) { return o.n; }); 24347 * // => { 'n': 1 } 24348 * 24349 * // The `_.property` iteratee shorthand. 24350 * _.minBy(objects, 'n'); 24351 * // => { 'n': 1 } 24352 */ 24353 function minBy(array, iteratee) { 24354 return (array && array.length) 24355 ? baseExtremum(array, getIteratee(iteratee, 2), baseLt) 24356 : undefined; 24357 } 24358 24359 /** 24360 * Multiply two numbers. 24361 * 24362 * @static 24363 * @memberOf _ 24364 * @since 4.7.0 24365 * @category Math 24366 * @param {number} multiplier The first number in a multiplication. 24367 * @param {number} multiplicand The second number in a multiplication. 24368 * @returns {number} Returns the product. 24369 * @example 24370 * 24371 * _.multiply(6, 4); 24372 * // => 24 24373 */ 24374 var multiply = createMathOperation(function(multiplier, multiplicand) { 24375 return multiplier * multiplicand; 24376 }, 1); 24377 24378 /**
vendor: 13,137 bytes, lines 24379-24817
24379 * Computes `number` rounded to `precision`. 24380 * 24381 * @static 24382 * @memberOf _ 24383 * @since 3.10.0 24384 * @category Math 24385 * @param {number} number The number to round. 24386 * @param {number} [precision=0] The precision to round to. 24387 * @returns {number} Returns the rounded number. 24388 * @example 24389 * 24390 * _.round(4.006); 24391 * // => 4 24392 * 24393 * _.round(4.006, 2); 24394 * // => 4.01 24395 * 24396 * _.round(4060, -2); 24397 * // => 4100 24398 */ 24399 var round = createRound('round'); 24400 24401 /** 24402 * Subtract two numbers. 24403 * 24404 * @static 24405 * @memberOf _ 24406 * @since 4.0.0 24407 * @category Math 24408 * @param {number} minuend The first number in a subtraction. 24409 * @param {number} subtrahend The second number in a subtraction. 24410 * @returns {number} Returns the difference. 24411 * @example 24412 * 24413 * _.subtract(6, 4); 24414 * // => 2 24415 */ 24416 var subtract = createMathOperation(function(minuend, subtrahend) { 24417 return minuend - subtrahend; 24418 }, 0); 24419 24420 /** 24421 * Computes the sum of the values in `array`. 24422 * 24423 * @static 24424 * @memberOf _ 24425 * @since 3.4.0 24426 * @category Math 24427 * @param {Array} array The array to iterate over. 24428 * @returns {number} Returns the sum. 24429 * @example 24430 * 24431 * _.sum([4, 2, 8, 6]); 24432 * // => 20 24433 */ 24434 function sum(array) { 24435 return (array && array.length) 24436 ? baseSum(array, identity) 24437 : 0; 24438 } 24439 24440 /** 24441 * This method is like `_.sum` except that it accepts `iteratee` which is 24442 * invoked for each element in `array` to generate the value to be summed. 24443 * The iteratee is invoked with one argument: (value). 24444 * 24445 * @static 24446 * @memberOf _ 24447 * @since 4.0.0 24448 * @category Math 24449 * @param {Array} array The array to iterate over. 24450 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 24451 * @returns {number} Returns the sum. 24452 * @example 24453 * 24454 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 24455 * 24456 * _.sumBy(objects, function(o) { return o.n; }); 24457 * // => 20 24458 * 24459 * // The `_.property` iteratee shorthand. 24460 * _.sumBy(objects, 'n'); 24461 * // => 20 24462 */ 24463 function sumBy(array, iteratee) { 24464 return (array && array.length) 24465 ? baseSum(array, getIteratee(iteratee, 2)) 24466 : 0; 24467 } 24468 24469 /*------------------------------------------------------------------------*/ 24470 24471 // Add methods that return wrapped values in chain sequences. 24472 lodash.after = after; 24473 lodash.ary = ary; 24474 lodash.assign = assign; 24475 lodash.assignIn = assignIn; 24476 lodash.assignInWith = assignInWith; 24477 lodash.assignWith = assignWith; 24478 lodash.at = at; 24479 lodash.before = before; 24480 lodash.bind = bind; 24481 lodash.bindAll = bindAll; 24482 lodash.bindKey = bindKey; 24483 lodash.castArray = castArray; 24484 lodash.chain = chain; 24485 lodash.chunk = chunk; 24486 lodash.compact = compact; 24487 lodash.concat = concat; 24488 lodash.cond = cond; 24489 lodash.conforms = conforms; 24490 lodash.constant = constant; 24491 lodash.countBy = countBy; 24492 lodash.create = create; 24493 lodash.curry = curry; 24494 lodash.curryRight = curryRight; 24495 lodash.debounce = debounce; 24496 lodash.defaults = defaults; 24497 lodash.defaultsDeep = defaultsDeep; 24498 lodash.defer = defer; 24499 lodash.delay = delay; 24500 lodash.difference = difference; 24501 lodash.differenceBy = differenceBy; 24502 lodash.differenceWith = differenceWith; 24503 lodash.drop = drop; 24504 lodash.dropRight = dropRight; 24505 lodash.dropRightWhile = dropRightWhile; 24506 lodash.dropWhile = dropWhile; 24507 lodash.fill = fill; 24508 lodash.filter = filter; 24509 lodash.flatMap = flatMap; 24510 lodash.flatMapDeep = flatMapDeep; 24511 lodash.flatMapDepth = flatMapDepth; 24512 lodash.flatten = flatten; 24513 lodash.flattenDeep = flattenDeep; 24514 lodash.flattenDepth = flattenDepth; 24515 lodash.flip = flip; 24516 lodash.flow = flow; 24517 lodash.flowRight = flowRight; 24518 lodash.fromPairs = fromPairs; 24519 lodash.functions = functions; 24520 lodash.functionsIn = functionsIn; 24521 lodash.groupBy = groupBy; 24522 lodash.initial = initial; 24523 lodash.intersection = intersection; 24524 lodash.intersectionBy = intersectionBy; 24525 lodash.intersectionWith = intersectionWith; 24526 lodash.invert = invert; 24527 lodash.invertBy = invertBy; 24528 lodash.invokeMap = invokeMap; 24529 lodash.iteratee = iteratee; 24530 lodash.keyBy = keyBy; 24531 lodash.keys = keys; 24532 lodash.keysIn = keysIn; 24533 lodash.map = map; 24534 lodash.mapKeys = mapKeys; 24535 lodash.mapValues = mapValues; 24536 lodash.matches = matches; 24537 lodash.matchesProperty = matchesProperty; 24538 lodash.memoize = memoize; 24539 lodash.merge = merge; 24540 lodash.mergeWith = mergeWith; 24541 lodash.method = method; 24542 lodash.methodOf = methodOf; 24543 lodash.mixin = mixin; 24544 lodash.negate = negate; 24545 lodash.nthArg = nthArg; 24546 lodash.omit = omit; 24547 lodash.omitBy = omitBy; 24548 lodash.once = once; 24549 lodash.orderBy = orderBy; 24550 lodash.over = over; 24551 lodash.overArgs = overArgs; 24552 lodash.overEvery = overEvery; 24553 lodash.overSome = overSome; 24554 lodash.partial = partial; 24555 lodash.partialRight = partialRight; 24556 lodash.partition = partition; 24557 lodash.pick = pick; 24558 lodash.pickBy = pickBy; 24559 lodash.property = property; 24560 lodash.propertyOf = propertyOf; 24561 lodash.pull = pull; 24562 lodash.pullAll = pullAll; 24563 lodash.pullAllBy = pullAllBy; 24564 lodash.pullAllWith = pullAllWith; 24565 lodash.pullAt = pullAt; 24566 lodash.range = range; 24567 lodash.rangeRight = rangeRight; 24568 lodash.rearg = rearg; 24569 lodash.reject = reject; 24570 lodash.remove = remove; 24571 lodash.rest = rest; 24572 lodash.reverse = reverse; 24573 lodash.sampleSize = sampleSize; 24574 lodash.set = set; 24575 lodash.setWith = setWith; 24576 lodash.shuffle = shuffle; 24577 lodash.slice = slice; 24578 lodash.sortBy = sortBy; 24579 lodash.sortedUniq = sortedUniq; 24580 lodash.sortedUniqBy = sortedUniqBy; 24581 lodash.split = split; 24582 lodash.spread = spread; 24583 lodash.tail = tail; 24584 lodash.take = take; 24585 lodash.takeRight = takeRight; 24586 lodash.takeRightWhile = takeRightWhile; 24587 lodash.takeWhile = takeWhile; 24588 lodash.tap = tap; 24589 lodash.throttle = throttle; 24590 lodash.thru = thru; 24591 lodash.toArray = toArray; 24592 lodash.toPairs = toPairs; 24593 lodash.toPairsIn = toPairsIn; 24594 lodash.toPath = toPath; 24595 lodash.toPlainObject = toPlainObject; 24596 lodash.transform = transform; 24597 lodash.unary = unary; 24598 lodash.union = union; 24599 lodash.unionBy = unionBy; 24600 lodash.unionWith = unionWith; 24601 lodash.uniq = uniq; 24602 lodash.uniqBy = uniqBy; 24603 lodash.uniqWith = uniqWith; 24604 lodash.unset = unset; 24605 lodash.unzip = unzip; 24606 lodash.unzipWith = unzipWith; 24607 lodash.update = update; 24608 lodash.updateWith = updateWith; 24609 lodash.values = values; 24610 lodash.valuesIn = valuesIn; 24611 lodash.without = without; 24612 lodash.words = words; 24613 lodash.wrap = wrap; 24614 lodash.xor = xor; 24615 lodash.xorBy = xorBy; 24616 lodash.xorWith = xorWith; 24617 lodash.zip = zip; 24618 lodash.zipObject = zipObject; 24619 lodash.zipObjectDeep = zipObjectDeep; 24620 lodash.zipWith = zipWith; 24621 24622 // Add aliases. 24623 lodash.entries = toPairs; 24624 lodash.entriesIn = toPairsIn; 24625 lodash.extend = assignIn; 24626 lodash.extendWith = assignInWith; 24627 24628 // Add methods to `lodash.prototype`. 24629 mixin(lodash, lodash); 24630 24631 /*------------------------------------------------------------------------*/ 24632 24633 // Add methods that return unwrapped values in chain sequences. 24634 lodash.add = add; 24635 lodash.attempt = attempt; 24636 lodash.camelCase = camelCase; 24637 lodash.capitalize = capitalize; 24638 lodash.ceil = ceil; 24639 lodash.clamp = clamp; 24640 lodash.clone = clone; 24641 lodash.cloneDeep = cloneDeep; 24642 lodash.cloneDeepWith = cloneDeepWith; 24643 lodash.cloneWith = cloneWith; 24644 lodash.conformsTo = conformsTo; 24645 lodash.deburr = deburr; 24646 lodash.defaultTo = defaultTo; 24647 lodash.divide = divide; 24648 lodash.endsWith = endsWith; 24649 lodash.eq = eq; 24650 lodash.escape = escape; 24651 lodash.escapeRegExp = escapeRegExp; 24652 lodash.every = every; 24653 lodash.find = find; 24654 lodash.findIndex = findIndex; 24655 lodash.findKey = findKey; 24656 lodash.findLast = findLast; 24657 lodash.findLastIndex = findLastIndex; 24658 lodash.findLastKey = findLastKey; 24659 lodash.floor = floor; 24660 lodash.forEach = forEach; 24661 lodash.forEachRight = forEachRight; 24662 lodash.forIn = forIn; 24663 lodash.forInRight = forInRight; 24664 lodash.forOwn = forOwn; 24665 lodash.forOwnRight = forOwnRight; 24666 lodash.get = get; 24667 lodash.gt = gt; 24668 lodash.gte = gte; 24669 lodash.has = has; 24670 lodash.hasIn = hasIn; 24671 lodash.head = head; 24672 lodash.identity = identity; 24673 lodash.includes = includes; 24674 lodash.indexOf = indexOf; 24675 lodash.inRange = inRange; 24676 lodash.invoke = invoke; 24677 lodash.isArguments = isArguments; 24678 lodash.isArray = isArray; 24679 lodash.isArrayBuffer = isArrayBuffer; 24680 lodash.isArrayLike = isArrayLike; 24681 lodash.isArrayLikeObject = isArrayLikeObject; 24682 lodash.isBoolean = isBoolean; 24683 lodash.isBuffer = isBuffer; 24684 lodash.isDate = isDate; 24685 lodash.isElement = isElement; 24686 lodash.isEmpty = isEmpty; 24687 lodash.isEqual = isEqual; 24688 lodash.isEqualWith = isEqualWith; 24689 lodash.isError = isError; 24690 lodash.isFinite = isFinite; 24691 lodash.isFunction = isFunction; 24692 lodash.isInteger = isInteger; 24693 lodash.isLength = isLength; 24694 lodash.isMap = isMap; 24695 lodash.isMatch = isMatch; 24696 lodash.isMatchWith = isMatchWith; 24697 lodash.isNaN = isNaN; 24698 lodash.isNative = isNative; 24699 lodash.isNil = isNil; 24700 lodash.isNull = isNull; 24701 lodash.isNumber = isNumber; 24702 lodash.isObject = isObject; 24703 lodash.isObjectLike = isObjectLike; 24704 lodash.isPlainObject = isPlainObject; 24705 lodash.isRegExp = isRegExp; 24706 lodash.isSafeInteger = isSafeInteger; 24707 lodash.isSet = isSet; 24708 lodash.isString = isString; 24709 lodash.isSymbol = isSymbol; 24710 lodash.isTypedArray = isTypedArray; 24711 lodash.isUndefined = isUndefined; 24712 lodash.isWeakMap = isWeakMap; 24713 lodash.isWeakSet = isWeakSet; 24714 lodash.join = join; 24715 lodash.kebabCase = kebabCase; 24716 lodash.last = last; 24717 lodash.lastIndexOf = lastIndexOf; 24718 lodash.lowerCase = lowerCase; 24719 lodash.lowerFirst = lowerFirst; 24720 lodash.lt = lt; 24721 lodash.lte = lte; 24722 lodash.max = max; 24723 lodash.maxBy = maxBy; 24724 lodash.mean = mean; 24725 lodash.meanBy = meanBy; 24726 lodash.min = min; 24727 lodash.minBy = minBy; 24728 lodash.stubArray = stubArray; 24729 lodash.stubFalse = stubFalse; 24730 lodash.stubObject = stubObject; 24731 lodash.stubString = stubString; 24732 lodash.stubTrue = stubTrue; 24733 lodash.multiply = multiply; 24734 lodash.nth = nth; 24735 lodash.noConflict = noConflict; 24736 lodash.noop = noop; 24737 lodash.now = now; 24738 lodash.pad = pad; 24739 lodash.padEnd = padEnd; 24740 lodash.padStart = padStart; 24741 lodash.parseInt = parseInt; 24742 lodash.random = random; 24743 lodash.reduce = reduce; 24744 lodash.reduceRight = reduceRight; 24745 lodash.repeat = repeat; 24746 lodash.replace = replace; 24747 lodash.result = result; 24748 lodash.round = round; 24749 lodash.runInContext = runInContext; 24750 lodash.sample = sample; 24751 lodash.size = size; 24752 lodash.snakeCase = snakeCase; 24753 lodash.some = some; 24754 lodash.sortedIndex = sortedIndex; 24755 lodash.sortedIndexBy = sortedIndexBy; 24756 lodash.sortedIndexOf = sortedIndexOf; 24757 lodash.sortedLastIndex = sortedLastIndex; 24758 lodash.sortedLastIndexBy = sortedLastIndexBy; 24759 lodash.sortedLastIndexOf = sortedLastIndexOf; 24760 lodash.startCase = startCase; 24761 lodash.startsWith = startsWith; 24762 lodash.subtract = subtract; 24763 lodash.sum = sum; 24764 lodash.sumBy = sumBy; 24765 lodash.template = template; 24766 lodash.times = times; 24767 lodash.toFinite = toFinite; 24768 lodash.toInteger = toInteger; 24769 lodash.toLength = toLength; 24770 lodash.toLower = toLower; 24771 lodash.toNumber = toNumber; 24772 lodash.toSafeInteger = toSafeInteger; 24773 lodash.toString = toString; 24774 lodash.toUpper = toUpper; 24775 lodash.trim = trim; 24776 lodash.trimEnd = trimEnd; 24777 lodash.trimStart = trimStart; 24778 lodash.truncate = truncate; 24779 lodash.unescape = unescape; 24780 lodash.uniqueId = uniqueId; 24781 lodash.upperCase = upperCase; 24782 lodash.upperFirst = upperFirst; 24783 24784 // Add aliases. 24785 lodash.each = forEach; 24786 lodash.eachRight = forEachRight; 24787 lodash.first = head; 24788 24789 mixin(lodash, (function() { 24790 var source = {}; 24791 baseForOwn(lodash, function(func, methodName) { 24792 if (!hasOwnProperty.call(lodash.prototype, methodName)) { 24793 source[methodName] = func; 24794 } 24795 }); 24796 return source; 24797 }()), { 'chain': false }); 24798 24799 /*------------------------------------------------------------------------*/ 24800 24801 /** 24802 * The semantic version number. 24803 * 24804 * @static 24805 * @memberOf _ 24806 * @type {string} 24807 */ 24808 lodash.VERSION = VERSION; 24809 24810 // Assign default placeholders. 24811 arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) { 24812 lodash[methodName].placeholder = lodash; 24813 }); 24814 24815 // Add `LazyWrapper` methods for `_.drop` and `_.take` variants. 24816 arrayEach(['drop', 'take'], function(methodName, index) { 24817 LazyWrapper.prototype[methodName] = function(n) {
vendor: 7,434 bytes, lines 24818-25035
24818 n = n === undefined ? 1 : nativeMax(toInteger(n), 0); 24819 24820 var result = (this.__filtered__ && !index) 24821 ? new LazyWrapper(this) 24822 : this.clone(); 24823 24824 if (result.__filtered__) { 24825 result.__takeCount__ = nativeMin(n, result.__takeCount__); 24826 } else { 24827 result.__views__.push({ 24828 'size': nativeMin(n, MAX_ARRAY_LENGTH), 24829 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') 24830 }); 24831 } 24832 return result; 24833 }; 24834 24835 LazyWrapper.prototype[methodName + 'Right'] = function(n) { 24836 return this.reverse()[methodName](n).reverse(); 24837 }; 24838 }); 24839 24840 // Add `LazyWrapper` methods that accept an `iteratee` value. 24841 arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { 24842 var type = index + 1, 24843 isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG; 24844 24845 LazyWrapper.prototype[methodName] = function(iteratee) { 24846 var result = this.clone(); 24847 result.__iteratees__.push({ 24848 'iteratee': getIteratee(iteratee, 3), 24849 'type': type 24850 }); 24851 result.__filtered__ = result.__filtered__ || isFilter; 24852 return result; 24853 }; 24854 }); 24855 24856 // Add `LazyWrapper` methods for `_.head` and `_.last`. 24857 arrayEach(['head', 'last'], function(methodName, index) { 24858 var takeName = 'take' + (index ? 'Right' : ''); 24859 24860 LazyWrapper.prototype[methodName] = function() { 24861 return this[takeName](1).value()[0]; 24862 }; 24863 }); 24864 24865 // Add `LazyWrapper` methods for `_.initial` and `_.tail`. 24866 arrayEach(['initial', 'tail'], function(methodName, index) { 24867 var dropName = 'drop' + (index ? '' : 'Right'); 24868 24869 LazyWrapper.prototype[methodName] = function() { 24870 return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1); 24871 }; 24872 }); 24873 24874 LazyWrapper.prototype.compact = function() { 24875 return this.filter(identity); 24876 }; 24877 24878 LazyWrapper.prototype.find = function(predicate) { 24879 return this.filter(predicate).head(); 24880 }; 24881 24882 LazyWrapper.prototype.findLast = function(predicate) { 24883 return this.reverse().find(predicate); 24884 }; 24885 24886 LazyWrapper.prototype.invokeMap = baseRest(function(path, args) { 24887 if (typeof path == 'function') { 24888 return new LazyWrapper(this); 24889 } 24890 return this.map(function(value) { 24891 return baseInvoke(value, path, args); 24892 }); 24893 }); 24894 24895 LazyWrapper.prototype.reject = function(predicate) { 24896 return this.filter(negate(getIteratee(predicate))); 24897 }; 24898 24899 LazyWrapper.prototype.slice = function(start, end) { 24900 start = toInteger(start); 24901 24902 var result = this; 24903 if (result.__filtered__ && (start > 0 || end < 0)) { 24904 return new LazyWrapper(result); 24905 } 24906 if (start < 0) { 24907 result = result.takeRight(-start); 24908 } else if (start) { 24909 result = result.drop(start); 24910 } 24911 if (end !== undefined) { 24912 end = toInteger(end); 24913 result = end < 0 ? result.dropRight(-end) : result.take(end - start); 24914 } 24915 return result; 24916 }; 24917 24918 LazyWrapper.prototype.takeRightWhile = function(predicate) { 24919 return this.reverse().takeWhile(predicate).reverse(); 24920 }; 24921 24922 LazyWrapper.prototype.toArray = function() { 24923 return this.take(MAX_ARRAY_LENGTH); 24924 }; 24925 24926 // Add `LazyWrapper` methods to `lodash.prototype`. 24927 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 24928 var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), 24929 isTaker = /^(?:head|last)$/.test(methodName), 24930 lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName], 24931 retUnwrapped = isTaker || /^find/.test(methodName); 24932 24933 if (!lodashFunc) { 24934 return; 24935 } 24936 lodash.prototype[methodName] = function() { 24937 var value = this.__wrapped__, 24938 args = isTaker ? [1] : arguments, 24939 isLazy = value instanceof LazyWrapper, 24940 iteratee = args[0], 24941 useLazy = isLazy || isArray(value); 24942 24943 var interceptor = function(value) { 24944 var result = lodashFunc.apply(lodash, arrayPush([value], args)); 24945 return (isTaker && chainAll) ? result[0] : result; 24946 }; 24947 24948 if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) { 24949 // Avoid lazy use if the iteratee has a "length" value other than `1`. 24950 isLazy = useLazy = false; 24951 } 24952 var chainAll = this.__chain__, 24953 isHybrid = !!this.__actions__.length, 24954 isUnwrapped = retUnwrapped && !chainAll, 24955 onlyLazy = isLazy && !isHybrid; 24956 24957 if (!retUnwrapped && useLazy) { 24958 value = onlyLazy ? value : new LazyWrapper(this); 24959 var result = func.apply(value, args); 24960 result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); 24961 return new LodashWrapper(result, chainAll); 24962 } 24963 if (isUnwrapped && onlyLazy) { 24964 return func.apply(this, args); 24965 } 24966 result = this.thru(interceptor); 24967 return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result; 24968 }; 24969 }); 24970 24971 // Add `Array` methods to `lodash.prototype`. 24972 arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { 24973 var func = arrayProto[methodName], 24974 chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', 24975 retUnwrapped = /^(?:pop|shift)$/.test(methodName); 24976 24977 lodash.prototype[methodName] = function() { 24978 var args = arguments; 24979 if (retUnwrapped && !this.__chain__) { 24980 var value = this.value(); 24981 return func.apply(isArray(value) ? value : [], args); 24982 } 24983 return this[chainName](function(value) { 24984 return func.apply(isArray(value) ? value : [], args); 24985 }); 24986 }; 24987 }); 24988 24989 // Map minified method names to their real names. 24990 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 24991 var lodashFunc = lodash[methodName]; 24992 if (lodashFunc) { 24993 var key = lodashFunc.name + ''; 24994 if (!hasOwnProperty.call(realNames, key)) { 24995 realNames[key] = []; 24996 } 24997 realNames[key].push({ 'name': methodName, 'func': lodashFunc }); 24998 } 24999 }); 25000 25001 realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{ 25002 'name': 'wrapper', 25003 'func': undefined 25004 }]; 25005 25006 // Add methods to `LazyWrapper`. 25007 LazyWrapper.prototype.clone = lazyClone; 25008 LazyWrapper.prototype.reverse = lazyReverse; 25009 LazyWrapper.prototype.value = lazyValue; 25010 25011 // Add chain sequence methods to the `lodash` wrapper. 25012 lodash.prototype.at = wrapperAt; 25013 lodash.prototype.chain = wrapperChain; 25014 lodash.prototype.commit = wrapperCommit; 25015 lodash.prototype.next = wrapperNext; 25016 lodash.prototype.plant = wrapperPlant; 25017 lodash.prototype.reverse = wrapperReverse; 25018 lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; 25019 25020 // Add lazy aliases. 25021 lodash.prototype.first = lodash.prototype.head; 25022 25023 if (symIterator) { 25024 lodash.prototype[symIterator] = wrapperToIterator; 25025 } 25026 return lodash; 25027 }); 25028 25029 /*--------------------------------------------------------------------------*/ 25030 25031 // Export lodash. 25032 var _ = runInContext(); 25033 25034 // Some AMD build optimizers, like r.js, check for condition patterns like: 25035 if (t
25035ypeof define == 'function' && typeof define.amd == 'object' && define.amd) { 25036 // Expose Lodash on the global object to prevent errors when Lodash is 25037 // loaded by a script tag in the presence of an AMD loader. 25038 // See http://requirejs.org/docs/errors.html#mismatch for more details. 25039 // Use `_.noConflict` to remove Lodash from the global object. 25040 root._ = _; 25041 25042 // Define as an anonymous module so, through path mapping, it can be 25043 // referenced as the "underscore" module. 25044 define(function() { 25045 return _; 25046 }); 25047 } 25048 // Check for `exports` after `define` in case a build optimizer adds it. 25049 else if (freeModule) { 25050 // Export for Node.js. 25051 (freeModule.exports = _)._ = _; 25052 // Export for CommonJS support. 25053 freeExports._ = _; 25054 } 25055 else { 25056 // Export to the global object. 25057 root._ = _; 25058 } 25059}.call(this)); 25060/******************* 25061** BANNER HERO - VANILLA JS ** 25062*******************/ 25063 25064// console.log('Banner Hero JS running...'); 25065 25066let bannerHeroVideoButtons = document.querySelectorAll('[data-bannerherovideo]'); 25067 25068let pauseStuff = (relativeBannerHeroWrap) => { 25069 relativeBannerHeroWrap.querySelector('.banner-hero-video-playpause-span-text').innerText = "Pause"; 25070 relativeBannerHeroWrap.querySelector('.banner-hero-video-playpause-span-icon').innerHTML = ` 25071 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 25072 <path d="M12 38h8V10h-8v28zm16-28v28h8V10h-8z"></path> 25073 </svg> 25074 `; 25075 relativeBannerHeroWrap.querySelector('.banner-hero-video-playpause-btn').setAttribute('aria-label', 'pause background video'); 25076} 25077 25078let playStuff = (relativeBannerHeroWrap) => { 25079 relativeBannerHeroWrap.querySelector('.banner-hero-video-playpause-span-text').innerText = "play"; 25080 relativeBannerHeroWrap.querySelector('.banner-hero-video-playpause-span-icon').innerHTML = ` 25081 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 25082 <path d="M16 10v28l22-14z"></path> 25083 </svg> 25084 `; 25085 relativeBannerHeroWrap.querySelector('.banner-hero-video-playpause-btn').setAttribute('aria-label', 'play background video'); 25086} 25087 25088 25089 25090if (bannerHeroVideoButtons.length > 0) { 25091 25092 function videoPlayPauseBtnClicked(e) { 25093 if(!e) { 25094 e = window["event"]; 25095 } 25096 25097 let bannerHeroWrap = e.target.closest(".banner-hero"); 25098 let bannerHeroVideoElem = bannerHeroWrap.querySelector('video'); 25099 25100 if (bannerHeroVideoElem.paused) { 25101 bannerHeroVideoElem.play(); 25102 pauseStuff(bannerHeroWrap); 25103 } else { 25104 bannerHeroVideoElem.pause(); 25105 playStuff(bannerHeroWrap); 25106 } 25107 } 25108 25109 for(let i = 0; i < bannerHeroVideoButtons.length; i++) { 25110 bannerHeroVideoButtons[i].addEventListener("click", videoPlayPauseBtnClicked); 25111 } 25112 25113 25114 25115 let getVideoElem = document.querySelectorAll(".banner-hero video"); 25116 25117 for(let k = 0; k < getVideoElem.length; k++) { 25118 let bannerHeroBox = getVideoElem[k].closest('.banner-hero'); 25119 25120 getVideoElem[k].onended = () => { 25121 playStuff(bannerHeroBox); 25122 }; 25123 25124 if(getVideoElem[k].hasAttribute('autoplay')) { 25125 pauseStuff(bannerHeroBox); 25126 } 25127 } 25128 25129} 25130 25131 25132 25133 25134 25135if(window.matchMedia('(prefers-reduced-motion)').matches) { 25136 25137 let bannerHeroVideos = document.querySelectorAll(".banner-hero video"); 25138 25139 if (bannerHeroVideos.length > 0) { 25140 for(var i = 0; i < bannerHeroVideos.length; i++) { 25141 bannerHeroVideos[i].removeAttribute('autoplay'); 25142 bannerHeroVideos[i].pause(); 25143 25144 let bannerHeroContainer = bannerHeroVideos[i].closest(".banner-hero"); 25145 25146 playStuff(bannerHeroContainer); 25147 } 25148 } 25149} 25150let emailSubscription = document.querySelectorAll(".email-subscription"); 25151emailSubscription.forEach(component => { 25152 const observer = new ResizeObserver(entries => { 25153 if (component.offsetWidth < 580) { 25154 component.classList.add("email-subscription-sm-media"); 25155 } else { 25156 component.classList.remove("email-subscription-sm-media"); 25157 } 25158 25159 if (component.offsetWidth < 520) { 25160 component.classList.add("email-subscription-xs-media"); 25161 } else { 25162 component.classList.remove("email-subscription-xs-media"); 25163 } 25164 }); 25165 25166 observer.observe(component); 25167}); 25168 25169const govDSnippet = (function () { 25170 document.querySelectorAll("[data-email-subscription-form]").forEach(form => { 25171 let typeSelect = form.querySelectorAll("select")[0]; 25172 let getStyleType = function (type) { 25173 if (typeSelect.value === type) { 25174 return "block"; 25175 } else { 25176 return "none"; 25177 } 25178 }; 25179 let toggleType = function () { 25180 form.querySelectorAll("li")[2].style.display = getStyleType("email"); 25181 if (getStyleType("email") === "none") { 25182 form.querySelectorAll("input")[3].required = "required"; 25183 } else { 25184 form.querySelectorAll("input")[3].required = false;
25185 } 25186 25187 form.querySelectorAll("li")[1].style.display = getStyleType("phone"); 25188 if (getStyleType("phone") === "none") { 25189 form.querySelectorAll("input")[4].required = "required"; 25190 } else { 25191 form.querySelectorAll("input")[4].required = false; 25192 } 25193 }; 25194 25195 if (typeSelect.addEventListener) { 25196 typeSelect.addEventListener("change", toggleType); 25197 } else if (typeSelect.attachEvent) { 25198 typeSelect.attachEvent("onchange", toggleType); 25199 } 25200 }); 25201})(); 25202 25203/******************* 25204 ** MEGA MENU - VANILLA JS ** 25205 *******************/ 25206// console.log("Mega Menu JS running..."); 25207 25208 25209// START - panel item grouping styling 25210 25211let menuWraps = document.querySelectorAll(".js-menu-wrap"); 25212// console.log("menuWraps: ", menuWraps); 25213 25214if (menuWraps) { 25215 for (let i = 0; i < menuWraps.length; i++) { 25216 25217 // console.log("menuWraps[i]: ", menuWraps[i]); 25218 25219 let menuItems = menuWraps[i].querySelectorAll(".js-item-wrap"); 25220 // console.log("menuItems: ", menuItems); 25221 25222 // Remove jserror backup CSS class 25223 if (menuWraps[i].classList.contains('mm-item-link-sect-jserror')) { 25224 menuWraps[i].classList.remove('mm-item-link-sect-jserror'); 25225 } 25226 25227 let menuAttrMaxColumns = "data-menu-max-columns"; 25228 let menuAttrMaxItemsPerColumn = "data-menu-max-itemspercol"; 25229 25230 let menuMaxColumnsVal = menuWraps[i].getAttribute(menuAttrMaxColumns); 25231 // console.log("menuMaxColumnsVal: ", menuMaxColumnsVal); 25232 let menuMaxItemsPerColumnVal = menuWraps[i].getAttribute(menuAttrMaxItemsPerColumn); 25233 // console.log("menuMaxItemsPerColumnVal: ", menuMaxItemsPerColumnVal); 25234 25235 if (menuItems) { 25236 25237 if (menuMaxColumnsVal || menuMaxItemsPerColumnVal) { 25238 // Convert buttons NodeList to an array 25239 var btnsArr = Array.prototype.slice.call(menuItems); 25240 // console.log(btnsArr); 25241 25242 let arrOfMenuItems = []; 25243 25244 for (let index = 0; index < menuItems.length; index++) { 25245 const element = menuItems[index].outerHTML; 25246 arrOfMenuItems.push(element); 25247 } 25248 25249 // console.log("arrOfMenuItems: ", arrOfMenuItems); 25250 25251 25252 25253 let tempCode = ""; 25254 let startMenuGroupDiv = '<ul class="menu-group list-unstyled">'; 25255 let endMenuGroupDiv = '</ul>'; 25256 25257 let itemsArrayLength = arrOfMenuItems.length; 25258 25259 let menuMaxItemsPerColumnDataVal; 25260 25261 25262 // If menuMaxColumnsVal custom data attribute is in the HTML and has value 25263 if (menuMaxColumnsVal) { 25264 menuMaxColumnsVal = parseInt(menuMaxColumnsVal); 25265 25266 // calculate how many items to put into each column 25267 let menuMaxItemsRawCalc = itemsArrayLength / menuMaxColumnsVal; 25268 // console.log("menuMaxItemsRawCalc: ", menuMaxItemsRawCalc); 25269 25270 menuMaxItemsPerColumnDataVal = Math.ceil(menuMaxItemsRawCalc); 25271 // console.log("menuMaxItemsPerColumnDataVal: ", menuMaxItemsPerColumnDataVal); 25272 25273 } else if (menuMaxItemsPerColumnVal) { 25274 menuMaxItemsPerColumnDataVal = parseInt(menuMaxItemsPerColumnVal); 25275 } 25276 25277 25278 for (let i = 0; i < itemsArrayLength; i++) { 25279 const element = arrOfMenuItems[i]; 25280 // console.log("theCalculation: ", i % menuMaxItemsPerColumnDataVal); 25281 25282 if (i === 0) { 25283 tempCode += ` 25284 ${startMenuGroupDiv} 25285 ${element} 25286 `; 25287 } else if (i % menuMaxItemsPerColumnDataVal === 0 && i + 1 === itemsArrayLength) { 25288 tempCode += ` 25289 ${endMenuGroupDiv} 25290 ${startMenuGroupDiv} 25291 ${element} 25292 ${endMenuGroupDiv} 25293 `; 25294 } else if (i % menuMaxItemsPerColumnDataVal === 0) { 25295 tempCode += ` 25296 ${endMenuGroupDiv} 25297 ${startMenuGroupDiv} 25298 ${element} 25299 `; 25300 } else if (i + 1 === itemsArrayLength) { 25301 tempCode += ` 25302 ${element} 25303 ${endMenuGroupDiv} 25304 `; 25305 } else { 25306 tempCode += element; 25307 } 25308 } 25309 25310 // console.log("tempCode: ", tempCode); 25311 25312 menuWraps[i].innerHTML = tempCode; 25313 25314 } 25315 25316 } 25317 25318 } 25319} 25320 25321// END - panel item grouping styling 25322 25323 25324 25325 25326 25327let txdotNavElem = document.querySelector('.mm-nav-element'); 25328let txdotMobileNavElem = document.querySelector('.mm-nav-mob-wrap'); 25329 25330if (txdotMobileNavElem) { 25331 let hamburgerMenu = document.querySelector('.mm-nav-mob-hamburger-icon-btn'); 25332 let expandCategory = document.querySelectorAll('.mm-nav-mob-item-btn'); 25333 25334 25335 hamburgerMenu.addEventListener("click", function(e) { 25336 let expandedMobileNav = document.querySelector('.mm-nav-element-mob'); 25337 setTimeout(() => { 25338 expandedMobileNav.querySelector('ul').focus(); 25339 }, 1000) 25340 }) 25341
25342 expandCategory.forEach(x => { 25343 x.addEventListener("click", function(e) { 25344 setTimeout(() => { 25345 let biggerthing = x.closest("li"); 25346 let smallerlist = biggerthing.querySelector("ul"); 25347 smallerlist.focus(); 25348 25349 }, 1000) 25350 }) 25351 }) 25352} 25353 25354 25355if (txdotNavElem) { 25356 25357 25358 let mmMegaWrapper = document.querySelectorAll('.mm-mega-wrapper'); 25359 25360 for (let j = 0; j < mmMegaWrapper.length; j++) { 25361 25362 let mmTabs = mmMegaWrapper[j].querySelectorAll('[data-mm-nav-button]'); 25363 let mmTabList = mmMegaWrapper[j].querySelector('[role="tablist"]'); 25364 25365 25366 25367 25368 if (mmTabs && mmTabList) { 25369 // console.log('gracious gracious'); 25370 25371 // Enable arrow navigation between mmTabs in the tab list 25372 let mmTabFocus = 0; 25373 25374 for (let k = 0; k < mmTabs.length; k++) { 25375 // console.log('mmTabs loop'); 25376 mmTabs[k].setAttribute("data-mmtabs-num", k); 25377 if (k == 0) { 25378 mmTabs[k].setAttribute("tabindex", "0"); 25379 } else { 25380 mmTabs[k].setAttribute("tabindex", "-1"); 25381 } 25382 // mmTabs[k].setAttribute("aria-selected", "false"); 25383 // mmTabs[k].setAttribute("aria-controls", "panel-" + (k + 1)); 25384 mmTabs[k].addEventListener("click", changeMMTabs); 25385 } 25386 25387 25388 mmTabList.addEventListener("keydown", function (e) { 25389 //tab through menu right 25390 if (e.keyCode === 9 && !e.shiftKey) { 25391 25392 mmTabFocus = document.activeElement.getAttribute("data-mmtabs-num"); 25393 25394 25395 if (parseInt(mmTabFocus) + 1 != mmTabs.length) { 25396 e.preventDefault(); 25397 mmTabs[mmTabFocus].setAttribute("tabindex", "-1"); 25398 mmTabFocus = parseInt(mmTabFocus) + 1; 25399 mmTabs[mmTabFocus].setAttribute("tabindex", "0"); 25400 mmTabs[mmTabFocus].focus(); 25401 } 25402 else { 25403 mmTabFocus = 0; 25404 mmTabs[(mmTabs.length - 1)].setAttribute("tabindex", "-1"); 25405 mmTabs[0].setAttribute("tabindex", "0"); 25406 } 25407 }; 25408 // //tab through menu left 25409 if (e.shiftKey && e.keyCode === 9) { 25410 if (mmTabFocus != 0) { 25411 e.preventDefault(); 25412 mmTabs[mmTabFocus].setAttribute("tabindex", "-1"); 25413 mmTabFocus = parseInt(mmTabFocus) - 1; 25414 mmTabs[mmTabFocus].setAttribute("tabindex", "0"); 25415 mmTabs[mmTabFocus].focus(); 25416 } 25417 else { 25418 mmTabFocus = 0; 25419 mmTabs[(mmTabs.length - 1)].setAttribute("tabindex", "-1"); 25420 mmTabs[0].setAttribute("tabindex", "0"); 25421 } 25422 }; 25423 // Move right 25424 if (e.keyCode === 39 || e.keyCode === 37) { 25425 mmTabs[mmTabFocus].setAttribute("tabindex", "-1"); 25426 if (e.keyCode === 39) { 25427 mmTabFocus = parseInt(mmTabFocus) + 1; 25428 // If we're at the end, go to the start 25429 if (mmTabFocus >= mmTabs.length) { 25430 mmTabFocus = 0; 25431 } 25432 // Move left 25433 } else if (e.keyCode === 37) { 25434 mmTabFocus = parseInt(mmTabFocus) - 1; 25435 // If we're at the start, move to the end 25436 if (mmTabFocus < 0) { 25437 mmTabFocus = mmTabs.length - 1; 25438 } 25439 } 25440 25441 mmTabs[mmTabFocus].setAttribute("tabindex", "0"); 25442 mmTabs[mmTabFocus].focus(); 25443 } 25444 25445 }); 25446 25447 function subNavListener(buttonselected) { 25448 setTimeout(() => { 25449 let openPanel = document.querySelector(".mm-item-wrap.acc-panel.d-block.acc-panel-sh
25449ow"); 25450 if (openPanel) { 25451 let allMenuGroups = openPanel.querySelectorAll('.menu-group'); 25452 let lastListColumn = allMenuGroups[allMenuGroups.length - 1]; 25453 let linkList = lastListColumn.querySelectorAll('li'); 25454 let lastLink = linkList[linkList.length - 1].querySelector('a'); 25455 let mmMegaWrapper = document.querySelectorAll('.mm-mega-wrapper'); 25456 let mmTabPanelsAll = mmMegaWrapper[j].querySelectorAll('[role="tabpanel"]'); 25457 25458 lastLink.addEventListener("keydown", function (e) { 25459 25460 e.preventDefault(); 25461 25462 for (let i = 0; i < mmTabPanelsAll.length; i++) { 25463 mmTabPanelsAll[i].setAttribute("hidden", ""); 25464 mmTabPanelsAll[i].setAttribute("class", "mm-item-wrap acc-panel"); 25465 } 25466 25467 25468 let navbuttons = document.querySelectorAll('[data-mm-nav-button]'); 25469 for (let i = 0; i < navbuttons.length; i++) { 25470 //navbuttons[i].setAttribute("class", ""); 25471 navbuttons[i].classList.remove("acc-active"); 25472 // navbuttons[i].setAttribute("aria-selected", "false"); 25473 } 25474 buttonselected.setAttribute('aria-expanded', false); 25475 buttonselected.setAttribute('aria-selected', false); 25476 buttonselected.focus(); 25477 25478 }); 25479 } 25480 }, "500"); 25481 25482 25483 } 25484 25485 function changeMMTabs(e) { 25486 25487 let mmEtargetBtn; 25488 25489 if (e.currentTarget.nodeName == "BUTTON") { 25490 mmEtargetBtn = e.currentTarget; 25491 } else { 25492 return; 25493 } 25494 25495 25496 //set aria-expanded correctly if item is not selected. This is for screen readers 25497 if (document.querySelector('.mm-nav-element')) { 25498 let navigation = document.querySelector('.mm-nav-element'); 25499 let navlistitems = navigation.querySelectorAll('li'); 25500 //console.log(navlistitems); 25501 navlistitems.forEach((x) => { 25502 if (x != e.target.closest('li')) { 25503 if (x.querySelector('button')) { 25504 let button = x.querySelector('button'); 25505 // button.setAttribute('aria-selected', false); 25506 } 25507 } 25508 }) 25509 } 25510 25511 let mmAriaSelectedTrue = mmEtargetBtn.closest('.mm-nav-element').querySelectorAll('[aria-selected="true"]'); 25512 let mmBttonAll = mmEtargetBtn.closest('.mm-nav-element').querySelectorAll('[data-mm-nav-button]'); 25513 25514 25515 25516 if (mmEtargetBtn.getAttribute("aria-selected") === "true") { 25517 // mmEtargetBtn.setAttribute("aria-selected", "false"); 25518 // console.log("changed aria-expanded to false"); 25519 } else { 25520 // mmEtargetBtn.setAttribute("aria-selected", "true"); 25521 // console.log("changed aria-expanded to true"); 25522 } 25523 25524 25525 for (let i = 0; i < mmAriaSelectedTrue.length; i++) { 25526 // mmAriaSelectedTrue[i].setAttribute("aria-selected", "false"); 25527 mmAriaSelectedTrue[i].setAttribute("tabindex", "-1"); 25528 } 25529 25530 25531 25532 mmTabFocus = mmEtargetBtn.getAttribute("data-mmtabs-num"); 25533 25534 25535 25536 for (let i = 0; i < mmBttonAll.length; i++) { 25537 mmBttonAll[i].setAttribute("tabindex", "-1"); 25538 } 25539 25540 // Set this tab as selected 25541 mmEtargetBtn.setAttribute("tabindex", "0"); 25542 // mmEtargetBtn.setAttribute("aria-selected", "true"); 25543 25544 25545 25546 let mmTabPanelsAll = mmMegaWrapper[j].querySelectorAll('[role="tabpanel"]'); 25547 25548 for (let i = 0; i < mmTabPanelsAll.length; i++) { 25549 mmTabPanelsAll[i].setAttribute("hidden", ""); 25550 } 25551 25552 document.addEventListener("keydown", function (e) { 25553 if (e.keyCode === 27) { 25554 for (let i = 0; i < mmTabPanelsAll.length; i++) { 25555 mmTabPanelsAll[i].setAttribute("hidden", ""); 25556 mmTabPanelsAll[i].setAttribute("class", "mm-item-wrap acc-panel"); 25557 } 25558 let navbuttons = document.querySelectorAll('[data-mm-nav-button]'); 25559 for (let i = 0; i < navbuttons.length; i++) { 25560 //navbuttons[i].setAttribute("class", ""); 25561 navbuttons[i].classList.remove("acc-active"); 25562 // navbuttons[i].setAttribute("aria-selected", "false"); 25563 } 25564 25565 mmEtargetBtn.focus(); 25566 } 25567 }); 25568 // console.log(mmEtargetBtn.querySelector(".mm-nav-button-text").innerText); 25569 // Show the selected panel 25570 mmMegaWrapper[j].querySelector('[data-mm-item="' + mmEtargetBtn.querySelector(".mm-nav-button-text").innerText + '"]').removeAttribute("hidden"); 25571 25572 var megaSections = document.getElementsByClassName('mm-item-wrap'); 25573 25574 25575 25576 //focus to first link in mega menu 25577 25578 for (let x of megaSections) { 25579 if (!x.hasAttribute('hidden')) { 25580 setTimeout(() => { 25581 if (x.querySelector("ul")) { 25582 x.querySelector("ul").setAttribute("tabindex", "0"); 25583 x.querySelector("ul").focus(); 25584 subNavListener(mmEtargetBtn); 25585 } 25586 else if (x.querySelector("input")) { 25587 x.querySelector("input").focus(); 25588 } 25589 }, "500"); 25590 } 25591 } 25592 25593 25594 }; 25595 25596 25597 25598 } 25599 } 25600 25601 25602} 25603// Date Time Script 25604 25605// browser support type="date" ? 25606let browsersupportdate = false;
25607let browsersupporttime = false; 25608let datefield = document.createElement("input"); 25609let timefield = document.createElement("input"); 25610 25611datefield.setAttribute("type", "date"); 25612timefield.setAttribute("type", "time"); 25613 25614// check if browser supports date 25615if (datefield.type == "date") { 25616 browsersupportdate = true; 25617} 25618 25619// Check if browser supports time field 25620if (timefield.type == "time") { 25621 browsersupporttime = true; 25622} 25623 25624// Find Current date/time 25625let fulldatetime = new Date(); 25626 25627 25628// store current time 25629let hours = fulldatetime.getHours(); 25630let minutes = fulldatetime.getMinutes(); 25631 25632// time consistancies 25633hours = hours ? hours : 12; // the hour '0' should be '12' 25634hours = hours < 10 ? '0' + hours : hours; 25635minutes = minutes < 10 ? '0' + minutes : minutes; 25636let currTime = hours + ':' + minutes; 25637 25638 25639let selctTime = document.querySelector("#selct-time"); 25640 25641if (selctTime) { 25642 // console.log('selctTime: ', selctTime); 25643 // Insert Current time into time input 25644 selctTime.value = currTime; 25645} 25646 25647 25648// Date 25649// Current date formatting for modern browsers 25650let currdatemodernbrows = fulldatetime.getFullYear() + '-' 25651+ ('0' + (fulldatetime.getMonth() + 1)).slice(-2) + '-' 25652+ ('0' + fulldatetime.getDate()).slice(-2); 25653 25654// Insert correct date formats into respected input values 25655if (browsersupportdate == true) { 25656 let selctDate = document.querySelector("#selct-date"); 25657 if (selctDate) { 25658 selctDate.value = currdatemodernbrows; 25659 } 25660} 25661let quoteWrap = document.querySelectorAll('[data-quote-wrap]'); 25662 25663if (quoteWrap) { 25664 for (let i = 0; i < quoteWrap.length; i++) { 25665 let quoteHeight = quoteWrap[i].offsetHeight; 25666 25667 if (quoteHeight > 400 && quoteHeight <= 460) { 25668 quoteWrap[i].querySelector('.quote-special-content-quote').classList.add('qs-fs-28'); 25669 } else if (quoteHeight > 460) { 25670 quoteWrap[i].querySelector('.quote-special-content-quote').classList.add('qs-fs-24'); 25671 } 25672 } 25673} 25674document.querySelectorAll('[data-wordcount-wrap]').forEach(element => { 25675 const textarea = element.querySelector("textarea"); 25676 const status = element.querySelector("[id^='wordCountStatus']"); 25677 const maxWords = 350; 25678 25679 if (textarea) { 25680 textarea.addEventListener("input", () => { 25681 let text = textarea.value.trim(); 25682 let wordsArray = text.split(/\s+/).filter(word => word.length > 0); 25683 let wordCount = wordsArray.length; 25684 25685 if (wordCount > maxWords) { 25686 textarea.value = wordsArray.slice(0, maxWords).join(" ") + " "; 25687 wordCount = maxWords; 25688 } 25689 25690 // Update all display-count spans 25691 element.querySelectorAll("[data-display-count]").forEach(span => { 25692 span.textContent = wordCount; 25693 }); 25694 25695 // Update all words-left spans 25696 element.querySelectorAll("[data-words-left]").forEach(span => { 25697 span.textContent = maxWords - wordCount; 25698 }); 25699 25700 // Update ARIA live region 25701 if (status) { 25702 status.textContent = `${wordCount} words. ${maxWords - wordCount} words left.`; 25703 } 25704 }); 25705 } 25706}); 25707// Custom File Input Upload Code 25708// rejected files types come from accept attribute on file upload input 25709let fileInputFP = document.querySelector('#file-input'); 25710let acceptattrvalue = fileInputFP ? fileInputFP.getAttribute("accept") : ''; 25711 25712var nospaceaccepted = acceptattrvalue.replace(/\s/g, ''); 25713var acceptedfiletypearray = nospaceaccepted.split(","); 25714var files = []; 25715var acceptedfiles = []; 25716var rejectedfiles = []; 25717var mb1tobytes = 1024000; 25718var mblimit = 5; 25719var maxfilelimitnum = 5; 25720 25721 25722function testfiles(filesvar) { 25723 // console.log(filesvar); 25724 25725 for (var i = 0; i < filesvar.length; i++) { 25726 var filetype = filesvar[i].type; 25727 var filesize = filesvar[i].size; 25728 if (acceptedfiletypearray.indexOf(filetype) !== -1) { 25729 // Code for accepted file type 25730 if (filesize < mb1tobytes * mblimit) { 25731 // Code for accepted file size 25732 if (acceptedfiles.length < maxfilelimitnum) { 25733 // count how many accepted files there are 25734 acceptedfiles.push(filesvar[i]); 25735 } else { 25736 // Code for rejected file size 25737 rejectedfiles.push([filesvar[i], 'MaxFileLimit']); 25738 } 25739 } else { 25740 // Code for rejected file size 25741 rejectedfiles.push([filesvar[i], 'MaxFileSizeError']); 25742 } 25743 } else { 25744 // Code for not accepted file type 25745 rejectedfiles.push([filesvar[i], 'FileTypeError']); 25746 } 25747 } 25748 // console.log("Accepted Files: ", acceptedfiles); 25749 // console.log("Rejected Files: ", rejectedfiles); 25750 document.querySelector("#acceptedresults").innerHTML = ""; 25751 document.querySelector("#rejectedresults").innerHTML = ""; 25752 refreshAcceptedFiles(); 25753 refreshRejectedFiles(); 25754} 25755 25756if (fileInputFP) { 25757 fileInputFP.addEventListener("change", function () { 25758 let filesvar = this.files; 25759 testfiles(filesvar); 25760 }) 25761} 25762 25763function refreshAcceptedFiles() { 25764 for (let i = 0; i < acceptedfiles.length; i++) { 25765 if (acceptedfiles[i].type.indexOf("image/") !== -1) { 25766 // preview image URL 25767 let previewURL = URL.createObjectURL(acceptedfiles[i]); 25768 let acceptedResultImage = `
25769 <div class="img-div"> 25770 <div class="preview-actions preview-actions-img"> 25771 <div class="selected-file"> 25772 ${acceptedfiles[i].name} 25773 </div> 25774 <div class="remove-file" image-id="accepted-${i}" onclick="removeFileXBtnFunc(this)"> 25775 <div class="cross"></div> 25776 </div> 25777 </div> 25778 <div class="preview-img-container"> 25779 <img class="preview-img" src="${previewURL}" alt="${acceptedfiles[i].name}" /> 25780 </div> 25781 </div> 25782 `; 25783 25784 document.getElementById("acceptedresults").insertAdjacentHTML('afterbegin', acceptedResultImage); 25785 } else { 25786 let acceptedResultFile = ` 25787 <div class="img-div"> 25788 <div class="preview-actions"> 25789 <div class="selected-file">${acceptedfiles[i].name}</div> 25790 <div class="remove-file" image-id="accepted-${i}" onclick="removeFileXBtnFunc(this)"> 25791 <div class="cross"></div> 25792 </div> 25793 </div> 25794 </div> 25795 `; 25796 25797 document.getElementById("acceptedresults").insertAdjacentHTML('afterbegin', acceptedResultFile); 25798 } 25799 } 25800} 25801 25802function refreshRejectedFiles() { 25803 for (let i = 0; i < rejectedfiles.length; i++) { 25804 let errortype = ""; 25805 if (rejectedfiles[i][1] == "FileTypeError") { 25806 errortype = "File type error: Only .jpg, .png, and .pdf are accepted"; 25807 } else if (rejectedfiles[i][1] == "MaxFileSizeError") { 25808 errortype = "Max file size error: " + mblimit + "mb file size limit"; 25809 } else if (rejectedfiles[i][1] == "MaxFileLimit") { 25810 errortype = "Max file limit: Limited to upload a total of " + maxfilelimitnum + " files"; 25811 } 25812 let rejectedResultFile = ` 25813 <div class="img-div"> 25814 <div class="preview-actions"> 25815 <div class="selected-file">${rejectedfiles[i][0].name}</div> 25816 <div class="remove-file" image-id="rejected-${i}" onclick="removeFileXBtnFunc(this)"> 25817 <div class="cross"></div> 25818 </div> 25819 </div> 25820 <div class="file-error-msg"> 25821 ${errortype} 25822 </div> 25823 </div> 25824 `; 25825 25826 document.getElementById("rejectedresults").insertAdjacentHTML('afterbegin', rejectedResultFile); 25827 } 25828} 25829 25830 25831function removeFileXBtnFunc(theThis) { 25832 const getIdOfClicked = theThis.getAttribute("image-id"); 25833 const idarray = getIdOfClicked.split("-"); 25834 const idnumber = parseInt(idarray[1]); 25835 if (idarray[0] == "accepted") { 25836 //code goes here 25837 // console.log("Delete accepted" + idnumber); 25838 acceptedfiles.splice(idnumber, 1); 25839 document.querySelector("#acceptedresults").innerHTML = ""; 25840 refreshAcceptedFiles(); 25841 // console.log("accepted files: ", acceptedfiles); 25842 } else if (idarray[0] == "rejected") { 25843 //code goes here 25844 // console.log("Delete rejected" + idnumber); 25845 rejectedfiles.splice(idnumber, 1); 25846 document.querySelector("#rejectedresults").innerHTML = ""; 25847 refreshRejectedFiles(); 25848 // console.log("rejected files: ", rejectedfiles); 25849 } 25850} 25851 25852 25853function sendUploadedFilesFunc(submitBtn) { 25854 submitBtn.preventDefault(); 25855 25856 if (acceptedfiles.length === 0) { 25857 return false; 25858 } 25859 25860 var fd = new FormData(); 25861 for (var i = 0; i < acceptedfiles.length; i++) { 25862 fd.append('img_' + i, acceptedfiles[i]); 25863 } 25864 25865 // avoid multiple repeated uploads 25866 // (histeric clicks on slow connection) 25867 submitBtn.disabled = true; 25868 let xhr = new XMLHttpRequest(); 25869 // do the request using form info 25870 xhr.open("POST", "upload-images.php"); 25871 // want to distinguish from non-JS submits? 25872 xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); 25873 xhr.send(fd); 25874 xhr.onload = function (e) { 25875 // clean up the form eventually 25876 console.log('Request Status', xhr.status); 25877 // make this form usable again 25878 submitBtn.disabled = false;
25879 // enable the submit on abort/error too 25880 // to make the user able to retry 25881 }; 25882} 25883 25884let oiqwefjoqweji = document.getElementById('btnSubmit'); 25885 25886if (oiqwefjoqweji) { 25887 oiqwefjoqweji.addEventListener('click', sendUploadedFilesFunc); 25888} 25889//////////////////////////// 25890// SITEMAP 25891///////////////////////////// 25892 25893 25894 25895// grab json data from page html 25896 25897let sitemapEl = document.querySelector('[data-sitemap-json]'); 25898 25899if (sitemapEl) { 25900 let sitemapDataData = JSON.parse(sitemapEl.innerHTML); 25901 25902 /* console.log("sitemap data:"); 25903 console.log(sitemapDataData);*/ 25904 25905 let sitemapLoopCount = 0; 25906 let dynamicReplacement = ""; 25907 let relativeLoopCount = 0; 25908 25909 let iterateCount = 0; 25910 25911 25912 function iterate(obj) { 25913 relativeLoopCount++; 25914 console.log("Relative loop count", relativeLoopCount); 25915 25916 for (let key in obj) { 25917 // console.log(key); 25918 // console.log(obj[key]); 25919 25920 25921 25922 if (obj.hasOwnProperty(key)) { 25923 25924 // BEGIN wrapper DIVS 25925 if(typeof obj[key] == "object" && key == "childrenn" && obj[key].length !== 0) { 25926 iterateCount = iterateCount + 1; 25927 console.log(iterateCount); 25928 25929 25930 let firstSitemapButtonBandoPanel = iterateCount === 1 ? "" : `data-bandoneon-panel="${obj.title}"`; 25931 let extraSitemapPanelClasses = iterateCount <= 1 ? "d-block acc-panel-show" : ""; 25932 let extraSitemapPanelInnerClasses = iterateCount <= 1 ? "acc-panel-inner-opacity" : ""; 25933 25934 dynamicReplacement += ` 25935 <div class="acc-panel test-acc-panel ${extraSitemapPanelClasses}" ${firstSitemapButtonBandoPanel}> 25936 <div class="acc-panel-inner ${extraSitemapPanelInnerClasses}"> 25937 <div class="sitemap-mut-wrap"> 25938 ` 25939 } 25940 25941 25942 25943 if (key == "title") { 25944 console.log(key); 25945 console.log(obj[key]); 25946 25947 sitemapLoopCount++; 25948 25949 console.log(obj.url); 25950 25951 25952 if (sitemapLoopCount === 1) { 25953 dynamicReplacement += ` 25954 <div class="sitemap-btn acc-active sitemap-root-wrap"> 25955 <span class="sitemap-btn-icon"> 25956 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 25957 <path d="M20 8H8c-2.21 0-3.98 1.79-3.98 4L4 36c0 2.21 1.79 4 4 4h32c2.21 0 4-1.79 4-4V16c0-2.21-1.79-4-4-4H24l-4-4z"></path> 25958 </svg> 25959 </span> 25960 <span>${obj.title}</span> 25961 </div> 25962 `; 25963 } else if (obj.childrenn == "") { 25964 dynamicReplacement += ` 25965 <div class="sitemap-bing-wrap"> 25966 <a class="sitemap-btn" href="${obj.url}"> 25967 <span class="sitemap-btn-icon"> 25968 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 25969 <path d="M7.8 24c0-3.42 2.78-6.2 6.2-6.2h8V14h-8C8.48 14 4 18.48 4 24s4.48 10 10 10h8v-3.8h-8c-3.42 0-6.2-2.78-6.2-6.2zm8.2 25970 2h16v-4H16v4zm18-12h-8v3.8h8c3.42 0 6.2 2.78 6.2 6.2s-2.78 6.2-6.2 6.2h-8V34h8c5.52 0 10-4.48 10-10s-4.48-10-10-10z"></path> 25971 </svg> 25972 </span> 25973 <span class="sitemap-btn-text">${obj.title}</span> 25974 </a> 25975 </div> 25976 `; 25977 } else { 25978 dynamicReplacement += ` 25979 <div class="sitemap-bing-wrap"> 25980 <button class="sitemap-btn" aria-selected="false" data-bandoneon-btn="${obj.title}">
25981 <span class="sitemap-btn-icon"> 25982 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 25983 <path d="M20 8H8c-2.21 0-3.98 1.79-3.98 4L4 36c0 2.21 1.79 4 4 4h32c2.21 0 4-1.79 4-4V16c0-2.21-1.79-4-4-4H24l-4-4z"></path> 25984 </svg> 25985 </span> 25986 <span class="sitemap-btn-text">${obj.title}</span> 25987 </button> 25988 <a href="${obj.url}" class="sitemap-btn-extra" aria-label="${obj.title}"> 25989 <span class="sitemap-btn-icon"> 25990 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> 25991 <path d="M7.8 24c0-3.42 2.78-6.2 6.2-6.2h8V14h-8C8.48 14 4 18.48 4 24s4.48 10 10 10h8v-3.8h-8c-3.42 0-6.2-2.78-6.2-6.2zm8.2 25992 2h16v-4H16v4zm18-12h-8v3.8h8c3.42 0 6.2 2.78 6.2 6.2s-2.78 6.2-6.2 6.2h-8V34h8c5.52 0 10-4.48 10-10s-4.48-10-10-10z"></path> 25993 </svg> 25994 </span> 25995 </a> 25996 </div> 25997 `; 25998 } 25999 26000 26001 } else if (key == "childrenn" && obj[key] != "") { 26002 console.log("childrenn"); 26003 console.log(obj[key]); 26004 } 26005 26006 26007 // iteration 26008 if (typeof obj[key] == "object" && obj[key] != "") { 26009 iterate(obj[key]); 26010 } 26011 26012 26013 // End wrapper DIVS 26014 if (typeof obj[key] == "object" && key == "childrenn" && obj[key].length !== 0) { 26015 iterateCount = iterateCount + 1; 26016 console.log(iterateCount); 26017 dynamicReplacement += ` 26018 </div> 26019 </div> 26020 </div> 26021 ` 26022 } 26023 26024 26025 } 26026 } 26027 } 26028 26029 iterate(sitemapDataData.sitemap[0]); 26030 26031 let asdfasdssalksdf = ` 26032 <div class="acc-container sitemap-wrap" data-sitemap> 26033 <div class="acc-show-hide-buttons"> 26034 <button class="btn btn-primary accs-all-show" aria-disabled="false">Show All</button> 26035 <button class="btn btn-primary accs-all-hide disabled" aria-disabled="true">Collapse All</button> 26036 </div> 26037 ${dynamicReplacement} 26038 </div> 26039 `; 26040 26041 26042 sitemapEl.insertAdjacentHTML('afterend', asdfasdssalksdf); 26043 26044 sitemapEl.remove(); 26045 26046 26047} 26048 26049 26050 26051 26052 26053 26054 26055// EXTRAS 26056 26057let sitemapInfoElement = document.querySelectorAll('[data-sitemap]'); 26058 26059if (sitemapInfoElement) { 26060 26061 function recurseSitemapLastClass(node, level) { 26062 for (var i = 0, count = node.children.length; i < count; i++) { 26063 // console.log(count); 26064 if (node.children[i].classList.contains('sitemap-bing-wrap')) { 26065 // console.log(level); 26066 node.children[i].children[0].insertAdjacentHTML('afterbegin', `<span class="sitemap-level-num">${Math.round(level)}</span>`); 26067 } 26068 26069 let levelIncrement = level + 0.333; 26070 let levelIncrementParseFloat = parseFloat(levelIncrement); 26071 // console.log(levelIncrementParseFloat); 26072 recurseSitemapLastClass(node.children[i], levelIncrementParseFloat); 26073 } 26074 } 26075 26076 26077 for (let i = 0; i < sitemapInfoElement.length; i++) { 26078 26079 let sitemapMutWraps = sitemapInfoElement[i].querySelectorAll('.sitemap-mut-wrap'); 26080 26081 sitemapMutWraps.forEach(muttwrap => { 26082 let bingWraps = muttwrap.querySelectorAll('.sitemap-bing-wrap'); 26083 let bingWrapCount = bingWraps.length; 26084 let lastEleChild = muttwrap.lastElementChild; 26085 // console.log(bingWrapCount); 26086 26087 if (bingWrapCount == 1) { 26088 // if there is only one sitemap-bing-wrap in sitemap-mut-wrap then add class to sitemap-bing-wrap that sets a specific height to the :before 26089 // console.log('There is only one bing-wrap in this mut-wrap'); 26090 bingWraps[0].classList.add('sitemap-bing-wrap-last'); 26091 } else if (bingWrapCount > 1 && lastEleChild.classList.contains('sitemap-bing-wrap')) { 26092 // console.log('at least one with bingwrapcount greater than one'); 26093 lastEleChild.classList.add('sitemap-bing-wrap-last'); 26094 // console.log(muttwrap.lastElementChild); 26095 } 26096 26097 if (lastEleChild.classList.contains('acc-panel')) { 26098 // console.log(lastEleChild); 26099 // console.log(bingWrapCount); 26100 lastEleChild.previousElementSibling.classList.add('sitemap-bing-wrap-magic'); 26101 // bingWraps[bingWrapCount - 1].classList.add('sitemap-bing-wrap-magic'); 26102 } 26103 26104 26105 26106 }); 26107 26108 26109 let oiluoipupoiu = sitemapInfoElement[i].querySelector('.acc-panel'); 26110 // console.log(oiluoipupoiu); 26111 recurseSitemapLastClass(oiluoipupoiu, 0.333); 26112 } 26113 26114 26115} 26116//////////////////////////// 26117// Submit Search Form 26118//////////////////////////// 26119 26120// Get references to the desktop and mobile search input fields 26121let searchInputDesk = document.querySelector("#mm-search-input-desk"); 26122let searchInputMobile = document.querySelector("#mm-search-input-mob"); 26123 26124// Get references to the desktop and mobile search submit buttons 26125let searchButtonDesk = document.querySelector('#mm-search-button-desk'); 26126let searchButtonMobile = document.querySelector('#mm-search-button-mob'); 26127 26128// Only continue if both search inputs exist on the page 26129if (searchInputDesk && searchInputMobile) { 26130 26131
26132 let searchInputKeyupFunc = (theThis, whichInput) => { 26133 // Tracks whether the input contains valid text 26134 let searchInputCanBeSubmitted = false; 26135 26136 // Remove leading/trailing spaces and check for content 26137 if (theThis.target.value.trim().length !== 0) { 26138 searchInputCanBeSubmitted = true; 26139 } 26140 26141 // Determine which submit button should be updated 26142 let correctSearchSubmitButton; 26143 26144 if (whichInput == "desktop") { 26145 correctSearchSubmitButton = searchButtonDesk; 26146 } else if (whichInput == "mobile") { 26147 correctSearchSubmitButton = searchButtonMobile; 26148 } 26149 26150 // Enable button if text exists; otherwise disable it 26151 if (searchInputCanBeSubmitted === true) { 26152 correctSearchSubmitButton.disabled = false; 26153 } else { 26154 correctSearchSubmitButton.disabled = true; 26155 } 26156 }; 26157 26158 26159 /** 26160 * Desktop search button click handler. 26161 * Prevents form submission if the search field is empty. 26162 */ 26163 let searchInputDeskClickFunc = (e) => { 26164 if (document.querySelector("#mm-search-input-desk").value.trim().length == 0) { 26165 e.preventDefault(); // Stop form submission 26166 console.log('nothing in the search box'); 26167 } 26168 } 26169 26170 /** 26171 * Mobile search button click handler. 26172 * Prevents form submission if the search field is empty. 26173 */ 26174 let searchInputMobClickFunc = (e) => { 26175 if (document.querySelector("#mm-search-input-mob").value.trim().length == 0) { 26176 e.preventDefault(); // Stop form submission 26177 console.log('nothing in the search box'); 26178 } 26179 } 26180 26181 26182 //////////////////// 26183 // EVENT LISTENERS 26184 //////////////////// 26185 26186 // Listen for typing in the desktop search box 26187 if (searchInputDesk) { 26188 let desktopInput = "desktop"; 26189 26190 searchInputDesk.addEventListener("keyup", theThis => { 26191 searchInputKeyupFunc(theThis, desktopInput); 26192 }); 26193 } 26194 26195 // Listen for typing in the mobile search box 26196 if (searchInputMobile) { 26197 let mobileInput = "mobile"; 26198 26199 searchInputMobile.addEventListener("keyup", theThis => { 26200 searchInputKeyupFunc(theThis, mobileInput); 26201 }); 26202 } 26203 26204 26205 // Prevent submission when search input is empty 26206 searchButtonDesk.addEventListener("click", searchInputDeskClickFunc); 26207 searchButtonMobile.addEventListener("click", searchInputMobClickFunc); 26208 26209}
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.