Code coverage report for ./src/ocLazyLoad.core.js

Statements: 76.38% (262 / 343)      Branches: 58.65% (139 / 237)      Functions: 79.31% (46 / 58)      Lines: 76.38% (262 / 343)      Ignored: none     

All files » ./src/ » ocLazyLoad.core.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778    1     1                       1   1 29                           29 14 13       29   29 29 29 29             29       29                 29   29 27       108     27 108 108 108 108 108 108 108       27 27 27 27 27     27                   29       29 4   1 1     1 1   1       29 3     29 29             29                                     29 6       6     6 664 664 664   6     1 20 20       20 13 13     13 1     12 12 11 8 8   11   2 2 4     11 2   11 11 11 11 11     19 19 4         1 24     24 5   24 13   24 21 18   21 18 18 18       1 21   21 3 3 3     21     1 6     6       6 6               24 17 7 3 4   1     3       4   20     1 24       24 24 24 24 24 23 23         24 24 19 16       5 5 5 5 5   5 4       5 4 1 1 2 1                 1 12 12 12       12     1 2     2 2   2 2         29 28     28 28 28 28 28       28 19     28 41     41         1             28                   41               41 21   20                   22 1   21 19   2                 5 1   4 4               3                 5 6 6 2   6   5 2   5 4 4 6 2     2   1                                 12 12                                                 12           12   12     12 12         12     12     2 2 2 2 2                                                                                                                                     12                   17 17   17   17                     17 11 11 12 12 12 12 12 12   1 1 1     11 1   10               11 6     6   17                 12 12 2 2     12                                                                                                             29     1 1   1 1 1 1 1 1 1 1 1   1 1   1     1 33 15 15 15         1 1 32 32       1        
'use strict';
 
(function (angular, window) {
    'use strict';
 
    var regModules = ['ng', 'oc.lazyLoad'],
        regInvokes = {},
        regConfigs = [],
        modulesToLoad = [],
        // modules to load from angular.module or other sources
    realModules = [],
        // real modules called from angular.module
    recordDeclarations = [],
        broadcast = angular.noop,
        runBlocks = {},
        justLoaded = [];
 
    var ocLazyLoad = angular.module('oc.lazyLoad', ['ng']);
 
    ocLazyLoad.provider('$ocLazyLoad', function ($controllerProvider, $provide, $compileProvider, $filterProvider, $injector, $animateProvider) {
        var modules = {},
            providers = {
            $controllerProvider: $controllerProvider,
            $compileProvider: $compileProvider,
            $filterProvider: $filterProvider,
            $provide: $provide, // other things (constant, decorator, provider, factory, service)
            $injector: $injector,
            $animateProvider: $animateProvider
        },
            debug = false,
            events = false,
            moduleCache = [],
            modulePromises = {};
 
        moduleCache.push = function (value) {
            if (this.indexOf(value) === -1) {
                Array.prototype.push.apply(this, arguments);
            }
        };
 
        this.config = function (config) {
            // If we want to define modules configs
            Eif (angular.isDefined(config.modules)) {
                Eif (angular.isArray(config.modules)) {
                    angular.forEach(config.modules, function (moduleConfig) {
                        modules[moduleConfig.name] = moduleConfig;
                    });
                } else {
                    modules[config.modules.name] = config.modules;
                }
            }
 
            Iif (angular.isDefined(config.debug)) {
                debug = config.debug;
            }
 
            Iif (angular.isDefined(config.events)) {
                events = config.events;
            }
        };
 
        /**
         * Get the list of existing registered modules
         * @param element
         */
        this._init = function _init(element) {
            // this is probably useless now because we override angular.bootstrap
            if (modulesToLoad.length === 0) {
                var elements = [element],
                    names = ['ng:app', 'ng-app', 'x-ng-app', 'data-ng-app'],
                    NG_APP_CLASS_REGEXP = /\sng[:\-]app(:\s*([\w\d_]+);?)?\s/,
                    append = function append(elm) {
                    return elm && elements.push(elm);
                };
 
                angular.forEach(names, function (name) {
                    names[name] = true;
                    append(document.getElementById(name));
                    name = name.replace(':', '\\:');
                    Eif (typeof element[0] !== 'undefined' && element[0].querySelectorAll) {
                        angular.forEach(element[0].querySelectorAll('.' + name), append);
                        angular.forEach(element[0].querySelectorAll('.' + name + '\\:'), append);
                        angular.forEach(element[0].querySelectorAll('[' + name + ']'), append);
                    }
                });
 
                angular.forEach(elements, function (elm) {
                    Eif (modulesToLoad.length === 0) {
                        var className = ' ' + element.className + ' ';
                        var match = NG_APP_CLASS_REGEXP.exec(className);
                        Iif (match) {
                            modulesToLoad.push((match[2] || '').replace(/\s+/g, ','));
                        } else {
                            angular.forEach(elm.attributes, function (attr) {
                                if (modulesToLoad.length === 0 && names[attr.name]) {
                                    modulesToLoad.push(attr.value);
                                }
                            });
                        }
                    }
                });
            }
 
            Iif (modulesToLoad.length === 0 && !((window.jasmine || window.mocha) && angular.isDefined(angular.mock))) {
                console.error('No module found during bootstrap, unable to init ocLazyLoad. You should always use the ng-app directive or angular.boostrap when you use ocLazyLoad.');
            }
 
            var addReg = function addReg(moduleName) {
                if (regModules.indexOf(moduleName) === -1) {
                    // register existing modules
                    regModules.push(moduleName);
                    var mainModule = angular.module(moduleName);
 
                    // register existing components (directives, services, ...)
                    _invokeQueue(null, mainModule._invokeQueue, moduleName);
                    _invokeQueue(null, mainModule._configBlocks, moduleName); // angular 1.3+
 
                    angular.forEach(mainModule.requires, addReg);
                }
            };
 
            angular.forEach(modulesToLoad, function (moduleName) {
                addReg(moduleName);
            });
 
            modulesToLoad = []; // reset for next bootstrap
            recordDeclarations.pop(); // wait for the next lazy load
        };
 
        /**
         * Like JSON.stringify but that doesn't throw on circular references
         * @param obj
         */
        var stringify = function stringify(obj) {
            try {
                return JSON.stringify(obj);
            } catch (e) {
                var cache = [];
                return JSON.stringify(obj, function (key, value) {
                    if (angular.isObject(value) && value !== null) {
                        if (cache.indexOf(value) !== -1) {
                            // Circular reference found, discard key
                            return;
                        }
                        // Store value in our collection
                        cache.push(value);
                    }
                    return value;
                });
            }
        };
 
        var hashCode = function hashCode(str) {
            var hash = 0,
                i,
                chr,
                len;
            Iif (str.length == 0) {
                return hash;
            }
            for (i = 0, len = str.length; i < len; i++) {
                chr = str.charCodeAt(i);
                hash = (hash << 5) - hash + chr;
                hash |= 0; // Convert to 32bit integer
            }
            return hash;
        };
 
        function _register(providers, registerModules, params) {
            Eif (registerModules) {
                var k,
                    moduleName,
                    moduleFn,
                    tempRunBlocks = [];
                for (k = registerModules.length - 1; k >= 0; k--) {
                    moduleName = registerModules[k];
                    Iif (!angular.isString(moduleName)) {
                        moduleName = getModuleName(moduleName);
                    }
                    if (!moduleName || justLoaded.indexOf(moduleName) !== -1 || modules[moduleName] && realModules.indexOf(moduleName) === -1) {
                        continue;
                    }
                    // new if not registered
                    var newModule = regModules.indexOf(moduleName) === -1;
                    moduleFn = ngModuleFct(moduleName);
                    if (newModule) {
                        regModules.push(moduleName);
                        _register(providers, moduleFn.requires, params);
                    }
                    if (moduleFn._runBlocks.length > 0) {
                        // new run blocks detected! Replace the old ones (if existing)
                        runBlocks[moduleName] = [];
                        while (moduleFn._runBlocks.length > 0) {
                            runBlocks[moduleName].push(moduleFn._runBlocks.shift());
                        }
                    }
                    if (angular.isDefined(runBlocks[moduleName]) && (newModule || params.rerun)) {
                        tempRunBlocks = tempRunBlocks.concat(runBlocks[moduleName]);
                    }
                    _invokeQueue(providers, moduleFn._invokeQueue, moduleName, params.reconfig);
                    _invokeQueue(providers, moduleFn._configBlocks, moduleName, params.reconfig); // angular 1.3+
                    broadcast(newModule ? 'ocLazyLoad.moduleLoaded' : 'ocLazyLoad.moduleReloaded', moduleName);
                    registerModules.pop();
                    justLoaded.push(moduleName);
                }
                // execute the run blocks at the end
                var instanceInjector = providers.getInstanceInjector();
                angular.forEach(tempRunBlocks, function (fn) {
                    instanceInjector.invoke(fn);
                });
            }
        }
 
        function _registerInvokeList(args, moduleName) {
            var invokeList = args[2][0],
                type = args[1],
                newInvoke = false;
            if (angular.isUndefined(regInvokes[moduleName])) {
                regInvokes[moduleName] = {};
            }
            if (angular.isUndefined(regInvokes[moduleName][type])) {
                regInvokes[moduleName][type] = {};
            }
            var onInvoke = function onInvoke(invokeName, invoke) {
                if (!regInvokes[moduleName][type].hasOwnProperty(invokeName)) {
                    regInvokes[moduleName][type][invokeName] = [];
                }
                if (checkHashes(invoke, regInvokes[moduleName][type][invokeName])) {
                    newInvoke = true;
                    regInvokes[moduleName][type][invokeName].push(invoke);
                    broadcast('ocLazyLoad.componentLoaded', [moduleName, type, invokeName]);
                }
            };
 
            function checkHashes(potentialNew, invokes) {
                var isNew = true,
                    newHash;
                if (invokes.length) {
                    newHash = signature(potentialNew);
                    angular.forEach(invokes, function (invoke) {
                        isNew = isNew && signature(invoke) !== newHash;
                    });
                }
                return isNew;
            }
 
            function signature(data) {
                Iif (angular.isArray(data)) {
                    // arrays are objects, we need to test for it first
                    return hashCode(data.toString());
                } else Iif (angular.isObject(data)) {
                    // constants & values for example
                    return hashCode(stringify(data));
                } else {
                    Eif (angular.isDefined(data) && data !== null) {
                        return hashCode(data.toString());
                    } else {
                        // null & undefined constants
                        return data;
                    }
                }
            }
 
            if (angular.isString(invokeList)) {
                onInvoke(invokeList, args[2][1]);
            } else if (angular.isObject(invokeList)) {
                angular.forEach(invokeList, function (invoke, key) {
                    if (angular.isString(invoke)) {
                        // decorators for example
                        onInvoke(invoke, invokeList[1]);
                    } else {
                        // components registered as object lists {"componentName": function() {}}
                        onInvoke(key, invoke);
                    }
                });
            } else {
                return false;
            }
            return newInvoke;
        }
 
        function _invokeQueue(providers, queue, moduleName, reconfig) {
            Iif (!queue) {
                return;
            }
 
            var i, len, args, provider;
            for (i = 0, len = queue.length; i < len; i++) {
                args = queue[i];
                Eif (angular.isArray(args)) {
                    if (providers !== null) {
                        Eif (providers.hasOwnProperty(args[0])) {
                            provider = providers[args[0]];
                        } else {
                            throw new Error('unsupported provider ' + args[0]);
                        }
                    }
                    var isNew = _registerInvokeList(args, moduleName);
                    if (args[1] !== 'invoke') {
                        if (isNew && angular.isDefined(provider)) {
                            provider[args[1]].apply(provider, args[2]);
                        }
                    } else {
                        // config block
                        var callInvoke = function callInvoke(fct) {
                            var invoked = regConfigs.indexOf(moduleName + '-' + fct);
                            Eif (invoked === -1 || reconfig) {
                                Eif (invoked === -1) {
                                    regConfigs.push(moduleName + '-' + fct);
                                }
                                if (angular.isDefined(provider)) {
                                    provider[args[1]].apply(provider, args[2]);
                                }
                            }
                        };
                        if (angular.isFunction(args[2][0])) {
                            callInvoke(args[2][0]);
                        } else Eif (angular.isArray(args[2][0])) {
                            for (var j = 0, jlen = args[2][0].length; j < jlen; j++) {
                                if (angular.isFunction(args[2][0][j])) {
                                    callInvoke(args[2][0][j]);
                                }
                            }
                        }
                    }
                }
            }
        }
 
        function getModuleName(module) {
            var moduleName = null;
            Eif (angular.isString(module)) {
                moduleName = module;
            } else if (angular.isObject(module) && module.hasOwnProperty('name') && angular.isString(module.name)) {
                moduleName = module.name;
            }
            return moduleName;
        }
 
        function moduleExists(moduleName) {
            Iif (!angular.isString(moduleName)) {
                return false;
            }
            try {
                return ngModuleFct(moduleName);
            } catch (e) {
                Eif (/No module/.test(e) || e.message.indexOf('$injector:nomod') > -1) {
                    return false;
                }
            }
        }
 
        this.$get = function ($log, $rootElement, $rootScope, $cacheFactory, $q) {
            var instanceInjector,
                filesCache = $cacheFactory('ocLazyLoad');
 
            Eif (!debug) {
                $log = {};
                $log['error'] = angular.noop;
                $log['warn'] = angular.noop;
                $log['info'] = angular.noop;
            }
 
            // Make this lazy because when $get() is called the instance injector hasn't been assigned to the rootElement yet
            providers.getInstanceInjector = function () {
                return instanceInjector ? instanceInjector : instanceInjector = $rootElement.data('$injector') || angular.injector();
            };
 
            broadcast = function broadcast(eventName, params) {
                Iif (events) {
                    $rootScope.$broadcast(eventName, params);
                }
                Iif (debug) {
                    $log.info(eventName, params);
                }
            };
 
            function reject(e) {
                var deferred = $q.defer();
                $log.error(e.message);
                deferred.reject(e);
                return deferred.promise;
            }
 
            return {
                _broadcast: broadcast,
 
                _$log: $log,
 
                /**
                 * Returns the files cache used by the loaders to store the files currently loading
                 * @returns {*}
                 */
                _getFilesCache: function getFilesCache() {
                    return filesCache;
                },
 
                /**
                 * Let the service know that it should monitor angular.module because files are loading
                 * @param watch boolean
                 */
                toggleWatch: function toggleWatch(watch) {
                    if (watch) {
                        recordDeclarations.push(true);
                    } else {
                        recordDeclarations.pop();
                    }
                },
 
                /**
                 * Let you get a module config object
                 * @param moduleName String the name of the module
                 * @returns {*}
                 */
                getModuleConfig: function getModuleConfig(moduleName) {
                    if (!angular.isString(moduleName)) {
                        throw new Error('You need to give the name of the module to get');
                    }
                    if (!modules[moduleName]) {
                        return null;
                    }
                    return angular.copy(modules[moduleName]);
                },
 
                /**
                 * Let you define a module config object
                 * @param moduleConfig Object the module config object
                 * @returns {*}
                 */
                setModuleConfig: function setModuleConfig(moduleConfig) {
                    if (!angular.isObject(moduleConfig)) {
                        throw new Error('You need to give the module config object to set');
                    }
                    modules[moduleConfig.name] = moduleConfig;
                    return moduleConfig;
                },
 
                /**
                 * Returns the list of loaded modules
                 * @returns {string[]}
                 */
                getModules: function getModules() {
                    return regModules;
                },
 
                /**
                 * Let you check if a module has been loaded into Angular or not
                 * @param modulesNames String/Object a module name, or a list of module names
                 * @returns {boolean}
                 */
                isLoaded: function isLoaded(modulesNames) {
                    var moduleLoaded = function moduleLoaded(module) {
                        var isLoaded = regModules.indexOf(module) > -1;
                        if (!isLoaded) {
                            isLoaded = !!moduleExists(module);
                        }
                        return isLoaded;
                    };
                    if (angular.isString(modulesNames)) {
                        modulesNames = [modulesNames];
                    }
                    if (angular.isArray(modulesNames)) {
                        var i, len;
                        for (i = 0, len = modulesNames.length; i < len; i++) {
                            if (!moduleLoaded(modulesNames[i])) {
                                return false;
                            }
                        }
                        return true;
                    } else {
                        throw new Error('You need to define the module(s) name(s)');
                    }
                },
 
                /**
                 * Given a module, return its name
                 * @param module
                 * @returns {String}
                 */
                _getModuleName: getModuleName,
 
                /**
                 * Returns a module if it exists
                 * @param moduleName
                 * @returns {module}
                 */
                _getModule: function getModule(moduleName) {
                    try {
                        return ngModuleFct(moduleName);
                    } catch (e) {
                        // this error message really suxx
                        if (/No module/.test(e) || e.message.indexOf('$injector:nomod') > -1) {
                            e.message = 'The module "' + stringify(moduleName) + '" that you are trying to load does not exist. ' + e.message;
                        }
                        throw e;
                    }
                },
 
                /**
                 * Check if a module exists and returns it if it does
                 * @param moduleName
                 * @returns {boolean}
                 */
                moduleExists: moduleExists,
 
                /**
                 * Load the dependencies, and might try to load new files depending on the config
                 * @param moduleName (String or Array of Strings)
                 * @param localParams
                 * @returns {*}
                 * @private
                 */
                _loadDependencies: function _loadDependencies(moduleName, localParams) {
                    var loadedModule,
                        requires,
                        diff,
                        promisesList = [],
                        self = this;
 
                    moduleName = self._getModuleName(moduleName);
 
                    Iif (moduleName === null) {
                        return $q.when();
                    } else {
                        try {
                            loadedModule = self._getModule(moduleName);
                        } catch (e) {
                            return reject(e);
                        }
                        // get unloaded requires
                        requires = self.getRequires(loadedModule);
                    }
 
                    angular.forEach(requires, function (requireEntry) {
                        // If no configuration is provided, try and find one from a previous load.
                        // If there isn't one, bail and let the normal flow run
                        Eif (angular.isString(requireEntry)) {
                            var config = self.getModuleConfig(requireEntry);
                            Eif (config === null) {
                                moduleCache.push(requireEntry); // We don't know about this module, but something else might, so push it anyway.
                                return;
                            }
                            requireEntry = config;
                            // ignore the name because it's probably not a real module name
                            config.name = undefined;
                        }
 
                        // Check if this dependency has been loaded previously
                        if (self.moduleExists(requireEntry.name)) {
                            // compare against the already loaded module to see if the new definition adds any new files
                            diff = requireEntry.files.filter(function (n) {
                                return self.getModuleConfig(requireEntry.name).files.indexOf(n) < 0;
                            });
 
                            // If the module was redefined, advise via the console
                            if (diff.length !== 0) {
                                self._$log.warn('Module "', moduleName, '" attempted to redefine configuration for dependency. "', requireEntry.name, '"\n Additional Files Loaded:', diff);
                            }
 
                            // Push everything to the file loader, it will weed out the duplicates.
                            if (angular.isDefined(self.filesLoader)) {
                                // if a files loader is defined
                                promisesList.push(self.filesLoader(requireEntry, localParams).then(function () {
                                    return self._loadDependencies(requireEntry);
                                }));
                            } else {
                                return reject(new Error('Error: New dependencies need to be loaded from external files (' + requireEntry.files + '), but no loader has been defined.'));
                            }
                            return;
                        } else if (angular.isArray(requireEntry)) {
                            var files = [];
                            angular.forEach(requireEntry, function (entry) {
                                // let's check if the entry is a file name or a config name
                                var config = self.getModuleConfig(entry);
                                if (config === null) {
                                    files.push(entry);
                                } else if (config.files) {
                                    files = files.concat(config.files);
                                }
                            });
                            if (files.length > 0) {
                                requireEntry = {
                                    files: files
                                };
                            }
                        } else if (angular.isObject(requireEntry)) {
                            if (requireEntry.hasOwnProperty('name') && requireEntry['name']) {
                                // The dependency doesn't exist in the module cache and is a new configuration, so store and push it.
                                self.setModuleConfig(requireEntry);
                                moduleCache.push(requireEntry['name']);
                            }
                        }
 
                        // Check if the dependency has any files that need to be loaded. If there are, push a new promise to the promise list.
                        if (angular.isDefined(requireEntry.files) && requireEntry.files.length !== 0) {
                            if (angular.isDefined(self.filesLoader)) {
                                // if a files loader is defined
                                promisesList.push(self.filesLoader(requireEntry, localParams).then(function () {
                                    return self._loadDependencies(requireEntry);
                                }));
                            } else {
                                return reject(new Error('Error: the module "' + requireEntry.name + '" is defined in external files (' + requireEntry.files + '), but no loader has been defined.'));
                            }
                        }
                    });
 
                    // Create a wrapper promise to watch the promise list and resolve it once everything is done.
                    return $q.all(promisesList);
                },
 
                /**
                 * Inject new modules into Angular
                 * @param moduleName
                 * @param localParams
                 * @param real
                 */
                inject: function inject(moduleName) {
                    var localParams = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
                    var real = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2];
 
                    var self = this,
                        deferred = $q.defer();
                    Iif (angular.isDefined(moduleName) && moduleName !== null) {
                        if (angular.isArray(moduleName)) {
                            var promisesList = [];
                            angular.forEach(moduleName, function (module) {
                                promisesList.push(self.inject(module, localParams, real));
                            });
                            return $q.all(promisesList);
                        } else {
                            self._addToLoadList(self._getModuleName(moduleName), true, real);
                        }
                    }
                    if (modulesToLoad.length > 0) {
                        var res = modulesToLoad.slice(); // clean copy
                        var loadNext = function loadNext(moduleName) {
                            moduleCache.push(moduleName);
                            modulePromises[moduleName] = deferred.promise;
                            self._loadDependencies(moduleName, localParams).then(function success() {
                                try {
                                    justLoaded = [];
                                    _register(providers, moduleCache, localParams);
                                } catch (e) {
                                    self._$log.error(e.message);
                                    deferred.reject(e);
                                    return;
                                }
 
                                if (modulesToLoad.length > 0) {
                                    loadNext(modulesToLoad.shift()); // load the next in list
                                } else {
                                        deferred.resolve(res); // everything has been loaded, resolve
                                    }
                            }, function error(err) {
                                deferred.reject(err);
                            });
                        };
 
                        // load the first in list
                        loadNext(modulesToLoad.shift());
                    } else Iif (localParams && localParams.name && modulePromises[localParams.name]) {
                        return modulePromises[localParams.name];
                    } else {
                        deferred.resolve();
                    }
                    return deferred.promise;
                },
 
                /**
                 * Get the list of required modules/services/... for this module
                 * @param module
                 * @returns {Array}
                 */
                getRequires: function getRequires(module) {
                    var requires = [];
                    angular.forEach(module.requires, function (requireModule) {
                        Eif (regModules.indexOf(requireModule) === -1) {
                            requires.push(requireModule);
                        }
                    });
                    return requires;
                },
 
                /**
                 * Invoke the new modules & component by their providers
                 * @param providers
                 * @param queue
                 * @param moduleName
                 * @param reconfig
                 * @private
                 */
                _invokeQueue: _invokeQueue,
 
                /**
                 * Check if a module has been invoked and registers it if not
                 * @param args
                 * @param moduleName
                 * @returns {boolean} is new
                 */
                _registerInvokeList: _registerInvokeList,
 
                /**
                 * Register a new module and loads it, executing the run/config blocks if needed
                 * @param providers
                 * @param registerModules
                 * @param params
                 * @private
                 */
                _register: _register,
 
                /**
                 * Add a module name to the list of modules that will be loaded in the next inject
                 * @param name
                 * @param force
                 * @private
                 */
                _addToLoadList: _addToLoadList,
 
                /**
                 * Unregister modules (you shouldn't have to use this)
                 * @param modules
                 */
                _unregister: function _unregister(modules) {
                    if (angular.isDefined(modules)) {
                        if (angular.isArray(modules)) {
                            angular.forEach(modules, function (module) {
                                regInvokes[module] = undefined;
                            });
                        }
                    }
                }
            };
        };
 
        // Let's get the list of loaded modules & components
        this._init(angular.element(window.document));
    });
 
    var bootstrapFct = angular.bootstrap;
    angular.bootstrap = function (element, modules, config) {
        // Clean state from previous bootstrap
        regModules = ['ng', 'oc.lazyLoad'];
        regInvokes = {};
        regConfigs = [];
        modulesToLoad = [];
        realModules = [];
        recordDeclarations = [];
        broadcast = angular.noop;
        runBlocks = {};
        justLoaded = [];
        // we use slice to make a clean copy
        angular.forEach(modules.slice(), function (module) {
            _addToLoadList(module, true, true);
        });
        return bootstrapFct(element, modules, config);
    };
 
    var _addToLoadList = function _addToLoadList(name, force, real) {
        if ((recordDeclarations.length > 0 || force) && angular.isString(name) && modulesToLoad.indexOf(name) === -1) {
            modulesToLoad.push(name);
            Eif (real) {
                realModules.push(name);
            }
        }
    };
 
    var ngModuleFct = angular.module;
    angular.module = function (name, requires, configFn) {
        _addToLoadList(name, false, true);
        return ngModuleFct(name, requires, configFn);
    };
 
    // CommonJS package manager support:
    Iif (typeof module !== 'undefined' && typeof exports !== 'undefined' && module.exports === exports) {
        module.exports = 'oc.lazyLoad';
    }
})(angular, window);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkM6L3d3dy9vY0xhenlMb2FkL3NyYy9vY0xhenlMb2FkLmNvcmUuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxDQUFDLFVBQUMsT0FBTyxFQUFFLE1BQU0sRUFBSztBQUNsQixnQkFBWSxDQUFDOztBQUViLFFBQUksVUFBVSxHQUFHLENBQ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5tb2R1bGUoJ29jLmxhenlMb2FkJywgWyduZyddKTtcclxuXHJcbiAgICBvY0xhenlMb2FkLnByb3ZpZGVyKCckb2NMYXp5TG9hZCcsIGZ1bmN0aW9uKCRjb250cm9sbGVyUHJvdmlkZXIsICRwcm92aWRlLCAkY29tcGlsZVByb3ZpZGVyLCAkZmlsdGVyUHJvdmlkZXIsICRpbmplY3RvciwgJGFuaW1hdGVQcm92aWRlcikge1xyXG4gICAgICAgIHZhciBtb2R1bGVzID0ge30sXHJcbiAgICAgICAgICAgIHByb3ZpZGVycyA9IHtcclxuICAgICAgICAgICAgICAgICRjb250cm9sbGVyUHJvdmlkZXI6ICRjb250cm9sbGVyUHJvdmlkZXIsXHJcbiAgICAgICAgICAgICAgICAkY29tcGlsZVByb3ZpZGVyOiAkY29tcGlsZVByb3ZpZGVyLFxyXG4gICAgICAgICAgICAgICAgJGZpbHRlclByb3ZpZGVyOiAkZmlsdGVyUHJvdmlkZXIsXHJcbiAgICAgICAgICAgICAgICAkcHJvdmlkZTogJHByb3ZpZGUsIC8vIG90aGVyIHRoaW5ncyAoY29uc3RhbnQsIGRlY29yYXRvciwgcHJvdmlkZXIsIGZhY3RvcnksIHNlcnZpY2UpXHJcbiAgICAgICAgICAgICAgICAkaW5qZWN0b3I6ICRpbmplY3RvcixcclxuICAgICAgICAgICAgICAgICRhbmltYXRlUHJvdmlkZXI6ICRhbmltYXRlUHJvdmlkZXJcclxuICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgZGVidWcgPSBmYWxzZSxcclxuICAgICAgICAgICAgZXZlbnRzID0gZmFsc2UsXHJcbiAgICAgICAgICAgIG1vZHVsZUNhY2hlID0gW10sXHJcbiAgICAgICAgICAgIG1vZHVsZVByb21pc2VzID0ge307XHJcblxyXG4gICAgICAgIG1vZHVsZUNhY2hlLnB1c2ggPSBmdW5jdGlvbih2YWx1ZSkge1xyXG4gICAgICAgICAgICBpZih0aGlzLmluZGV4T2YodmFsdWUpID09PSAtMSkge1xyXG4gICAgICAgICAgICAgICAgQXJyYXkucHJvdG90eXBlLnB1c2guYXBwbHkodGhpcywgYXJndW1lbnRzKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH07XHJcblxyXG4gICAgICAgIHRoaXMuY29uZmlnID0gZnVuY3Rpb24oY29uZmlnKSB7XHJcbiAgICAgICAgICAgIC8vIElmIHdlIHdhbnQgdG8gZGVmaW5lIG1vZHVsZXMgY29uZmlnc1xyXG4gICAgICAgICAgICBpZihhbmd1bGFyLmlzRGVmaW5lZChjb25maWcubW9kdWxlcykpIHtcclxuICAgICAgICAgICAgICAgIGlmKGFuZ3VsYXIuaXNBcnJheShjb25maWcubW9kdWxlcykpIHtcclxuICAgICAgICAgICAgICAgICAgICBhbmd1bGFyLmZvckVhY2goY29uZmlnLm1vZHVsZXMsIG1vZHVsZUNvbmZpZyA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG1vZHVsZXNbbW9kdWxlQ29uZmlnLm5hbWVdID0gbW9kdWxlQ29uZmlnO1xyXG4gICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICBtb2R1bGVzW2NvbmZpZy5tb2R1bGVzLm5hbWVdID0gY29uZmlnLm1vZHVsZXM7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGlmKGFuZ3VsYXIuaXNEZWZpbmVkKGNvbmZpZy5kZWJ1ZykpIHtcclxuICAgICAgICAgICAgICAgIGRlYnVnID0gY29uZmlnLmRlYnVnO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBpZihhbmd1bGFyLmlzRGVmaW5lZChjb25maWcuZXZlbnRzKSkge1xyXG4gICAgICAgICAgICAgICAgZXZlbnRzID0gY29uZmlnLmV2ZW50cztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH07XHJcblxyXG4gICAgICAgIC8qKlxyXG4gICAgICAgICAqIEdldCB0aGUgbGlzdCBvZiBleGlzdGluZyByZWdpc3RlcmVkIG1vZHVsZXNcclxuICAgICAgICAgKiBAcGFyYW0gZWxlbWVudFxyXG4gICAgICAgICAqL1xyXG4gICAgICAgIHRoaXMuX2luaXQgPSBmdW5jdGlvbiBfaW5pdChlbGVtZW50KSB7XHJcbiAgICAgICAgICAgIC8vIHRoaXMgaXMgcHJvYmFibHkgdXNlbGVzcyBub3cgYmVjYXVzZSB3ZSBvdmVycmlkZSBhbmd1bGFyLmJvb3RzdHJhcFxyXG4gICAgICAgICAgICBpZihtb2R1bGVzVG9Mb2FkLmxlbmd0aCA9PT0gMCkge1xyXG4gICAgICAgICAgICAgICAgdmFyIGVsZW1lbnRzID0gW2VsZW1lbnRdLFxyXG4gICAgICAgICAgICAgICAgICAgIG5hbWVzID0gWyduZzphcHAnLCAnbmctYXBwJywgJ3gtbmctYXBwJywgJ2RhdGEtbmctYXBwJ10sXHJcbiAgICAgICAgICAgICAgICAgICAgTkdfQVBQX0NMQVNTX1JFR0VYUCA9IC9cXHNuZ1s6XFwtXWFwcCg6XFxzKihbXFx3XFxkX10rKTs/KT9cXHMvLFxyXG4gICAgICAgICAgICAgICAgICAgIGFwcGVuZCA9IGZ1bmN0aW9uIGFwcGVuZChlbG0pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChlbG0gJiYgZWxlbWVudHMucHVzaChlbG0pKTtcclxuICAgICAgICAgICAgICAgICAgICB9O1xyXG5cclxuICAgICAgICAgICAgICAgIGFuZ3VsYXIuZm9yRWFjaChuYW1lcywgbmFtZSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgbmFtZXNbbmFtZV0gPSB0cnVlO1xyXG4gICAgICAgICAgICAgICAgICAgIGFwcGVuZChkb2N1bWVudC5nZXRFbGVtZW50QnlJZChuYW1lKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgbmFtZSA9IG5hbWUucmVwbGFjZSgnOicsICdcXFxcOicpO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmKHR5cGVvZihlbGVtZW50WzBdKSAhPT0gJ3VuZGVmaW5lZCcgJiYgZWxlbWVudFswXS5xdWVyeVNlbGVjdG9yQWxsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGFuZ3VsYXIuZm9yRWFjaChlbGVtZW50WzBdLnF1ZXJ5U2VsZWN0b3JBbGwoYC4keyBuYW1lIH1gKSwgYXBwZW5kKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYW5ndWxhci5mb3JFYWNoKGVsZW1lbnRbMF0ucXVlcnlTZWxlY3RvckFsbChgLiR7IG5hbWUgfVxcXFw6YCksIGFwcGVuZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGFuZ3VsYXIuZm9yRWFjaChlbGVtZW50WzBdLnF1ZXJ5U2VsZWN0b3JBbGwoYFskeyBuYW1lIH1dYCksIGFwcGVuZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfSk7XHJcblxyXG4gICAgICAgICAgICAgICAgYW5ndWxhci5mb3JFYWNoKGVsZW1lbnRzLCBlbG0gPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmKG1vZHVsZXNUb0xvYWQubGVuZ3RoID09PSAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBjbGFzc05hbWUgPSBgICR7IGVsZW1lbnQuY2xhc3NOYW1lIH0gYDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIG1hdGNoID0gTkdfQVBQX0NMQVNTX1JFR0VYUC5leGVjKGNsYXNzTmFtZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmKG1hdGNoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb2R1bGVzVG9Mb2FkLnB1c2goKG1hdGNoWzJdIHx8ICcnKS5yZXBsYWNlKC9cXHMrL2csICcsJykpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ndWxhci5mb3JFYWNoKGVsbS5hdHRyaWJ1dGVzLCBhdHRyID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZihtb2R1bGVzVG9Mb2FkLmxlbmd0aCA9PT0gMCAmJiBuYW1lc1thdHRyLm5hbWVdKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZHVsZXNUb0xvYWQucHVzaChhdHRyLnZhbHVlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBpZihtb2R1bGVzVG9Mb2FkLmxlbmd0aCA9PT0gMCAmJiAhKCh3aW5kb3cuamFzbWluZSB8fCB3aW5kb3cubW9jaGEpICYmIGFuZ3VsYXIuaXNEZWZpbmVkKGFuZ3VsYXIubW9jaykpKSB7XHJcbiAgICAgICAgICAgICAgICBjb25zb2xlLmVycm9yKCdObyBtb2R1bGUgZm91bmQgZHVyaW5nIGJvb3RzdHJhcCwgdW5hYmxlIHRvIGluaXQgb2NMYXp5TG9hZC4gWW91IHNob3VsZCBhbHdheXMgdXNlIHRoZSBuZy1hcHAgZGlyZWN0aXZlIG9yIGFuZ3VsYXIuYm9vc3RyYXAgd2hlbiB5b3UgdXNlIG9jTGF6eUxvYWQuJyk7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIHZhciBhZGRSZWcgPSBmdW5jdGlvbiBhZGRSZWcobW9kdWxlTmFtZSkge1xyXG4gICAgICAgICAgICAgICAgaWYocmVnTW9kdWxlcy5pbmRleE9mKG1vZHVsZU5hbWUpID09PSAtMSkge1xyXG4gICAgICAgICAgICAgICAgICAgIC8vIHJlZ2lzdGVyIGV4aXN0aW5nIG1vZHVsZXNcclxuICAgICAgICAgICAgICAgICAgICByZWdNb2R1bGVzLnB1c2gobW9kdWxlTmFtZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgdmFyIG1haW5Nb2R1bGUgPSBhbmd1bGFyLm1vZHVsZShtb2R1bGVOYW1lKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgLy8gcmVnaXN0ZXIgZXhpc3RpbmcgY29tcG9uZW50cyAoZGlyZWN0aXZlcywgc2VydmljZXMsIC4uLilcclxuICAgICAgICAgICAgICAgICAgICBfaW52b2tlUXVldWUobnVsbCwgbWFpbk1vZHVsZS5faW52b2tlUXVldWUsIG1vZHVsZU5hbWUpO1xyXG4gICAgICAgICAgICAgICAgICAgIF9pbnZva2VRdWV1ZShudWxsLCBtYWluTW9kdWxlLl9jb25maWdCbG9ja3MsIG1vZHVsZU5hbWUpOyAvLyBhbmd1bGFyIDEuMytcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgYW5ndWxhci5mb3JFYWNoKG1haW5Nb2R1bGUucmVxdWlyZXMsIGFkZFJlZyk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH07XHJcblxyXG4gICAgICAgICAgICBhbmd1bGFyLmZvckVhY2gobW9kdWxlc1RvTG9hZCwgbW9kdWxlTmFtZSA9PiB7XHJcbiAgICAgICAgICAgICAgICBhZGRSZWcobW9kdWxlTmFtZSk7XHJcbiAgICAgICAgICAgIH0pO1xyXG5cclxuICAgICAgICAgICAgbW9kdWxlc1RvTG9hZCA9IFtdOyAvLyByZXNldCBmb3IgbmV4dCBib290c3RyYXBcclxuICAgICAgICAgICAgcmVjb3JkRGVjbGFyYXRpb25zLnBvcCgpOyAvLyB3YWl0IGZvciB0aGUgbmV4dCBsYXp5IGxvYWRcclxuICAgICAgICB9O1xyXG5cclxuICAgICAgICAvKipcclxuICAgICAgICAgKiBMaWtlIEpTT04uc3RyaW5naWZ5IGJ1dCB0aGF0IGRvZXNuJ3QgdGhyb3cgb24gY2lyY3VsYXIgcmVmZXJlbmNlc1xyXG4gICAgICAgICAqIEBwYXJhbSBvYmpcclxuICAgICAgICAgKi9cclxuICAgICAgICB2YXIgc3RyaW5naWZ5ID0gZnVuY3Rpb24gc3RyaW5naWZ5KG9iaikge1xyXG4gICAgICAgICAgICB0cnkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KG9iaik7XHJcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcclxuICAgICAgICAgICAgICAgIHZhciBjYWNoZSA9IFtdO1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KG9iaiwgKGtleSwgdmFsdWUpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBpZihhbmd1bGFyLmlzT2JqZWN0KHZhbHVlKSAmJiB2YWx1ZSAhPT0gbnVsbCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZihjYWNoZS5pbmRleE9mKHZhbHVlKSAhPT0gLTEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIENpcmN1bGFyIHJlZmVyZW5jZSBmb3VuZCwgZGlzY2FyZCBrZXlcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBTdG9yZSB2YWx1ZSBpbiBvdXIgY29sbGVjdGlvblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBjYWNoZS5wdXNoKHZhbHVlKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlO1xyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9O1xyXG5cclxuICAgICAgICB2YXIgaGFzaENvZGUgPSBmdW5jdGlvbiBoYXNoQ29kZShzdHIpIHtcclxuICAgICAgICAgICAgdmFyIGhhc2ggPSAwLCBpLCBjaHIsIGxlbjtcclxuICAgICAgICAgICAgaWYoc3RyLmxlbmd0aCA9PSAwKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gaGFzaDtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBmb3IoaSA9IDAsIGxlbiA9IHN0ci5sZW5ndGg7IGkgPCBsZW47IGkrKykge1xyXG4gICAgICAgICAgICAgICAgY2hyID0gc3RyLmNoYXJDb2RlQXQoaSk7XHJcbiAgICAgICAgICAgICAgICBoYXNoID0gKGhhc2ggPDwgNSkgLSBoYXNoICsgY2hyO1xyXG4gICAgICAgICAgICAgICAgaGFzaCB8PSAwOyAvLyBDb252ZXJ0IHRvIDMyYml0IGludGVnZXJcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICByZXR1cm4gaGFzaDtcclxuICAgICAgICB9O1xyXG5cclxuICAgICAgICBmdW5jdGlvbiBfcmVnaXN0ZXIocHJvdmlkZXJzLCByZWdpc3Rlck1vZHVsZXMsIHBhcmFtcykge1xyXG4gICAgICAgICAgICBpZihyZWdpc3Rlck1vZHVsZXMpIHtcclxuICAgICAgICAgICAgICAgIHZhciBrLCBtb2R1bGVOYW1lLCBtb2R1bGVGbiwgdGVtcFJ1bkJsb2NrcyA9IFtdO1xyXG4gICAgICAgICAgICAgICAgZm9yKGsgPSByZWdpc3Rlck1vZHVsZXMubGVuZ3RoIC0gMTsgayA+PSAwOyBrLS0pIHtcclxuICAgICAgICAgICAgICAgICAgICBtb2R1bGVOYW1lID0gcmVnaXN0ZXJNb2R1bGVzW2tdO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmKCFhbmd1bGFyLmlzU3RyaW5nKG1vZHVsZU5hbWUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG1vZHVsZU5hbWUgPSBnZXRNb2R1bGVOYW1lKG1vZHVsZU5hbWUpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBpZighbW9kdWxlTmFtZSB8fCBqdXN0TG9hZGVkLmluZGV4T2YobW9kdWxlTmFtZSkgIT09IC0xIHx8IChtb2R1bGVzW21vZHVsZU5hbWVdICYmIHJlYWxNb2R1bGVzLmluZGV4T2YobW9kdWxlTmFtZSkgPT09IC0xKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgLy8gbmV3IGlmIG5vdCByZWdpc3RlcmVkXHJcbiAgICAgICAgICAgICAgICAgICAgdmFyIG5ld01vZHVsZSA9IHJlZ01vZHVsZXMuaW5kZXhPZihtb2R1bGVOYW1lKSA9PT0gLTE7XHJcbiAgICAgICAgICAgICAgICAgICAgbW9kdWxlRm4gPSBuZ01vZHVsZUZjdChtb2R1bGVOYW1lKTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAobmV3TW9kdWxlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlZ01vZHVsZXMucHVzaChtb2R1bGVOYW1lKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgX3JlZ2lzdGVyKHByb3ZpZGVycywgbW9kdWxlRm4ucmVxdWlyZXMsIHBhcmFtcyk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGlmKG1vZHVsZUZuLl9ydW5CbG9ja3MubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBuZXcgcnVuIGJsb2NrcyBkZXRlY3RlZCEgUmVwbGFjZSB0aGUgb2xkIG9uZXMgKGlmIGV4aXN0aW5nKVxyXG4gICAgICAgICAgICAgICAgICAgICAgICBydW5CbG9ja3NbbW9kdWxlTmFtZV0gPSBbXTtcclxuICAgICAgICAgICAgICAgICAgICA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gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAvLyBleGVjdXRlIHRoZSBydW4gYmxvY2tzIGF0IHRoZSBlbmRcclxuICAgICAgICAgICAgICAgIHZhciBpbnN0YW5jZUluamVjdG9yID0gcHJvdmlkZXJzLmdldEluc3RhbmNlSW5qZWN0b3IoKTtcclxuICAgICAgICAgICAgICAgIGFuZ3VsYXIuZm9yRWFjaCh0ZW1wUnVuQmxvY2tzLCBmbiA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgaW5zdGFuY2VJbmplY3Rvci5pbnZva2UoZm4pO1xyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGZ1bmN0aW9uIF9yZWdpc3Rlckludm9rZUxpc3QoYXJncywgbW9kdWxlTmFtZSkge1xyXG4gICAgICAgICAgICB2YXIgaW52b2tlTGlzdCA9IGFyZ3NbMl1bMF0sXHJcbiAgICAgICAgICAgICAgICB0eXBlID0gYXJnc1sxXSxcclxuICAgICAgICAgICAgICAgIG5ld0ludm9rZSA9IGZhbHNlO1xyXG4gICAgICAgICAgICBpZihhbmd1bGFyLmlzVW5kZWZpbmVkKHJlZ0ludm9rZXNbbW9kdWxlTmFtZV0pKSB7XHJcbiAgICAgICAgICAgICAgICByZWdJbnZva2VzW21vZHVsZU5hbWVdID0ge307XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYoYW5ndWxhci5pc1VuZGVmaW5lZChyZWdJbnZva2VzW21vZHVsZU5hbWVdW3R5cGVdKSkge1xyXG4gICAgICAgICAgICAgICAgcmVnSW52b2tlc1ttb2R1bGVOYW1lXVt0eXBlXSA9IHt9O1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHZhciBvbkludm9rZSA9IGZ1bmN0aW9uKGludm9rZU5hbWUsIGludm9rZSkge1xyXG4gICAgICAgICAgICAgICAgaWYoIXJlZ0ludm9rZXNbbW9kdWxlTmFtZV1bdHlwZV0uaGFzT3duUHJvcGVydHkoaW52b2tlTmFtZSkpIHtcclxuICAgICAgICAgICAgICAgICAgICByZWdJbnZva2VzW21vZHVsZU5hbWVdW3R5cGVdW2ludm9rZU5hbWVdID0gW107XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBpZihjaGVja0hhc2hlcyhpbnZva2UsIHJlZ0ludm9rZXNbbW9kdWxlTmFtZV1bdHlwZV1baW52b2tlTmFtZV0pKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgbmV3SW52b2tlID0gdHJ1ZTtcclxuICAgICAgICAgICAgICAgICAgICByZWdJbnZva2VzW21vZHVsZU5hbWVdW3R5cGVdW2ludm9rZU5hbWVdLnB1c2goaW52b2tlKTtcclxuICAgICAgICAgICAgICAgICAgICBicm9hZGNhc3QoJ29jTGF6eUxvYWQuY29tcG9uZW50TG9hZGVkJywgW21vZHVsZU5hbWUsIHR5cGUsIGludm9rZU5hbWVdKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfTtcclxuXHJcbiAgICAgICAgICAgIGZ1bmN0aW9uIGNoZWNrSGFzaGVzKHBvdGVudGlhbE5ldywgaW52b2tlcykge1xyXG4gICAgICAgICAgICAgICAgdmFyIGlzTmV3ID0gdHJ1ZSxcclxuICAgICAgICAgICAgICAgICAgICBuZXdIYXNoO1xyXG4gICAgICAgICAgICAgICAgaWYgKGludm9rZXMubGVuZ3RoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgbmV3SGFzaCA9IHNpZ25hdHVyZShwb3RlbnRpYWxOZXcpO1xyXG4gICAgICAgICAgICAgICAgICAgIGFuZ3VsYXIuZm9yRWFjaChpbnZva2VzLCBpbnZva2UgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpc05ldyA9IGlzTmV3ICYmIHNpZ25hdHVyZShpbnZva2UpICE9PSBuZXdIYXNoO1xyXG4gICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIGlzTmV3O1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBmdW5jdGlvbiBzaWduYXR1cmUoZGF0YSkge1xyXG4gICAgICAgICAgICAgICAgaWYoYW5ndWxhci5pc0FycmF5KGRhdGEpKSB7IC8vIGFycmF5cyBhcmUgb2JqZWN0cywgd2UgbmVlZCB0byB0ZXN0IGZvciBpdCBmaXJzdFxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBoYXNoQ29kZShkYXRhLnRvU3RyaW5nKCkpO1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmKGFuZ3VsYXIuaXNPYmplY3QoZGF0YSkpIHsgLy8gY29uc3RhbnRzICYgdmFsdWVzIGZvciBleGFtcGxlXHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGhhc2hDb2RlKHN0cmluZ2lmeShkYXRhKSk7XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmKGFuZ3VsYXIuaXNEZWZpbmVkKGRhdGEpICYmIGRhdGEgIT09IG51bGwpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGhhc2hDb2RlKGRhdGEudG9TdHJpbmcoKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsgLy8gbnVsbCAmIHVuZGVmaW5lZCBjb25zdGFudHNcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGE7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBpZihhbmd1bGFyLmlzU3RyaW5nKGludm9rZUxpc3QpKSB7XHJcbiAgICAgICAgICAgICAgICBvbkludm9rZShpbnZva2VMaXN0LCBhcmdzWzJdWzFdKTtcclxuICAgICAgICAgICAgfSBlbHNlIGlmKGFuZ3VsYXIuaXNPYmplY3QoaW52b2tlTGlzdCkpIHtcclxuICAgICAgICAgICAgICAgIGFuZ3VsYXIuZm9yRWFjaChpbnZva2VMaXN0LCBmdW5jdGlvbihpbnZva2UsIGtleSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmKGFuZ3VsYXIuaXNTdHJpbmcoaW52b2tlKSkgeyAvLyBkZWNvcmF0b3JzIGZvciBleGFtcGxlXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG9uSW52b2tlKGludm9rZSwgaW52b2tlTGlzdFsxXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsgLy8gY29tcG9uZW50cyByZWdpc3RlcmVkIGFzIG9iamVjdCBsaXN0cyB7XCJjb21wb25lbnROYW1lXCI6IGZ1bmN0aW9uKCkge319XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG9uSW52b2tlKGtleSwgaW52b2tlKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICByZXR1cm4gbmV3SW52b2tlO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgZnVuY3Rpb24gX2ludm9rZVF1ZXVlKHByb3ZpZGVycywgcXVldWUsIG1vZHVsZU5hbWUsIHJlY29uZmlnKSB7XHJcbiAgICAgICAgICAgIGlmKCFxdWV1ZSkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICB2YXIgaSwgbGVuLCBhcmdzLCBwcm92aWRlcjtcclxuICAgICAgICAgICAgZm9yKGkgPSAwLCBsZW4gPSBxdWV1ZS5sZW5ndGg7IGkgPCBsZW47IGkrKykge1xyXG4gICAgICAgICAgICAgICAgYXJncyA9IHF1ZXVlW2ldO1xyXG4gICAgICAgICAgICAgICAgaWYoYW5ndWxhci5pc0FycmF5KGFyZ3MpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYocHJvdmlkZXJzICE9PSBudWxsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmKHByb3ZpZGVycy5oYXNPd25Qcm9wZXJ0eShhcmdzWzBdKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvdmlkZXIgPSBwcm92aWRlcnNbYXJnc1swXV07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYHVuc3VwcG9ydGVkIHByb3ZpZGVyICR7IGFyZ3NbMF0gfWApO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIHZhciBpc05ldyA9IF9yZWdpc3Rlckludm9rZUxpc3QoYXJncywgbW9kdWxlTmFtZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYoYXJnc1sxXSAhPT0gJ2ludm9rZScpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYoaXNOZXcgJiYgYW5ndWxhci5pc0RlZmluZWQocHJvdmlkZXIpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm92aWRlclthcmdzWzFdXS5hcHBseShwcm92aWRlciwgYXJnc1syXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgeyAvLyBjb25maWcgYmxvY2tcclxuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGNhbGxJbnZva2UgPSBmdW5jdGlvbihmY3QpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBpbnZva2VkID0gcmVnQ29uZmlncy5pbmRleE9mKGAkeyBtb2R1bGVOYW1lIH0tJHsgZmN0IH1gKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKGludm9rZWQgPT09IC0xIHx8IHJlY29uZmlnKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYoaW52b2tlZCA9PT0gLTEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVnQ29uZmlncy5wdXNoKGAkeyBtb2R1bGVOYW1lIH0tJHsgZmN0IH1gKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYoYW5ndWxhci5pc0RlZmluZWQocHJvdmlkZXIpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb3ZpZGVyW2FyZ3NbMV1dLmFwcGx5KHByb3ZpZGVyLCBhcmdzWzJdKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmKGFuZ3VsYXIuaXNGdW5jdGlvbihhcmdzWzJdWzBdKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbEludm9rZShhcmdzWzJdWzBdKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmKGFuZ3VsYXIuaXNBcnJheShhcmdzWzJdWzBdKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yKHZhciBqID0gMCwgamxlbiA9IGFyZ3NbMl1bMF0ubGVuZ3RoOyBqIDwgamxlbjsgaisrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYoYW5ndWxhci5pc0Z1bmN0aW9uKGFyZ3NbMl1bMF1bal0pKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxJbnZva2UoYXJnc1syXVswXVtqXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBmdW5jdGlvbiBnZXRNb2R1bGVOYW1lKG1vZHVsZSkge1xyXG4gICAgICAgICAgICB2YXIgbW9kdWxlTmFtZSA9IG51bGw7XHJcbiAgICAgICAgICAgIGlmKGFuZ3VsYXIuaXNTdHJpbmcobW9kdWxlKSkge1xyXG4gICAgICAgICAgICAgICAgbW9kdWxlTmFtZSA9IG1vZHVsZTtcclxuICAgICAgICAgICAgfSBlbHNlIGlmKGFuZ3VsYXIuaXNPYmplY3QobW9kdWxlKSAmJiBtb2R1bGUuaGFzT3duUHJvcGVydHkoJ25hbWUnKSAmJiBhbmd1bGFyLmlzU3RyaW5nKG1vZHVsZS5uYW1lKSkge1xyXG4gICAgICAgICAgICAgICAgbW9kdWxlTmFtZSA9IG1vZHVsZS5uYW1lO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHJldHVybiBtb2R1bGVOYW1lO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgZnVuY3Rpb24gbW9kdWxlRXhpc3RzKG1vZHVsZU5hbWUpIHtcclxuICAgICAgICAgICAgaWYoIWFuZ3VsYXIuaXNTdHJpbmcobW9kdWxlTmFtZSkpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB0cnkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIG5nTW9kdWxlRmN0KG1vZHVsZU5hbWUpO1xyXG4gICAgICAgICAgICB9IGNhdGNoKGUpIHtcclxuICAgICAgICAgICAgICAgIGlmKC9ObyBtb2R1bGUvLnRlc3QoZSkgfHwgZS5tZXNzYWdlLmluZGV4T2YoJyRpbmplY3Rvcjpub21vZCcpID4gLTEpIHtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHRoaXMuJGdldCA9IGZ1bmN0aW9uKCRsb2csICRyb290RWxlbWVudCwgJHJvb3RTY29wZSwgJGNhY2hlRmFjdG9yeSwgJHEpIHtcclxuICAgICAgICAgICAgdmFyIGluc3RhbmNlSW5qZWN0b3IsXHJcbiAgICAgICAgICAgICAgICBmaWxlc0NhY2hlID0gJGNhY2hlRmFjdG9yeSgnb2NMYXp5TG9hZCcpO1xyXG5cclxuICAgICAgICAgICAgaWYoIWRlYnVnKSB7XHJcbiAgICAgICAgICAgICAgICAkbG9nID0ge307XHJcbiAgICAgICAgICAgICAgICAkbG9nWydlcnJvciddID0gYW5ndWxhci5ub29wO1xyXG4gICAgICAgICAgICAgICAgJGxvZ1snd2FybiddID0gYW5ndWxhci5ub29wO1xyXG4gICAgICAgICAgICAgICAgJGxvZ1snaW5mbyddID0gYW5ndWxhci5ub29wO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAvLyBNYWtlIHRoaXMgbGF6eSBiZWNhdXNlIHdoZW4gJGdldCgpIGlzIGNhbGxlZCB0aGUgaW5zdGFuY2UgaW5qZWN0b3IgaGFzbid0IGJlZW4gYXNzaWduZWQgdG8gdGhlIHJvb3RFbGVtZW50IHlldFxyXG4gICAgICAgICAgICBwcm92aWRlcnMuZ2V0SW5zdGFuY2VJbmplY3RvciA9IGZ1bmN0aW9uKCkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIGluc3RhbmNlSW5qZWN0b3IgPyBpbnN0YW5jZUluamVjdG9yIDogKGluc3RhbmNlSW5qZWN0b3IgPSAoJHJvb3RFbGVtZW50LmRhdGEoJyRpbmplY3RvcicpIHx8IGFuZ3VsYXIuaW5qZWN0b3IoKSkpO1xyXG4gICAgICAgICAgICB9O1xyXG5cclxuICAgICAgICAgICAgYnJvYWRjYXN0ID0gZnVuY3Rpb24gYnJvYWRjYXN0KGV2ZW50TmFtZSwgcGFyYW1zKSB7XHJcbiAgICAgICAgICAgICAgICBpZihldmVudHMpIHtcclxuICAgICAgICAgICAgICAgICAgICAkcm9vdFNjb3BlLiRicm9hZGNhc3QoZXZlbnROYW1lLCBwYXJhbXMpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgaWYoZGVidWcpIHtcclxuICAgICAgICAgICAgICAgICAgICAkbG9nLmluZm8oZXZlbnROYW1lLCBwYXJhbXMpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9O1xyXG5cclxuICAgICAgICAgICAgZnVuY3Rpb24gcmVqZWN0KGUpIHtcclxuICAgICAgICAgICAgICAgIHZhciBkZWZlcnJlZCA9ICRxLmRlZmVyKCk7XHJcbiAgICAgICAgICAgICAgICAkbG9nLmVycm9yKGUubWVzc2FnZSk7XHJcbiAgICAgICAgICAgICAgICBkZWZlcnJlZC5yZWplY3QoZSk7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gZGVmZXJyZWQucHJvbWlzZTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgcmV0dXJuIHtcclxuICAgICAgICAgICAgICAgIF9icm9hZGNhc3Q6IGJyb2FkY2FzdCxcclxuXHJcbiAgICAgICAgICAgICAgICBfJGxvZzogJGxvZyxcclxuXHJcbiAgICAgICAgICAgICAgICAvKipcclxuICAgICAgICAgICAgICAgICAqIFJldHVybnMgdGhlIGZpbGVzIGNhY2hlIHVzZWQgYnkgdGhlIGxvYWRlcnMgdG8gc3RvcmUgdGhlIGZpbGVzIGN1cnJlbnRseSBsb2FkaW5nXHJcbiAgICAgICAgICAgICAgICAgKiBAcmV0dXJucyB7Kn1cclxuICAgICAgICAgICAgICAgICAqL1xyXG4gICAgICAgICAgICAgICAgX2dldEZpbGVzQ2FjaGU6IGZ1bmN0aW9uIGdldEZpbGVzQ2FjaGUoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZpbGVzQ2FjaGU7XHJcbiAgICAgICAgICAgICAgICB9LFxyXG5cclxuICAgICAgICAgICAgICAgIC8qKlxyXG4gICAgICAgICAgICAgICAgICogTGV0IHRoZSBzZXJ2aWNlIGtub3cgdGhhdCBpdCBzaG91bGQgbW9uaXRvciBhbmd1bGFyLm1vZHVsZSBiZWNhdXNlIGZpbGVzIGFyZSBsb2FkaW5nXHJcbiAgICAgICAgICAgICAgICAgKiBAcGFyYW0gd2F0Y2ggYm9vbGVhblxyXG4gICAgICAgICAgICAgICAgICovXHJcbiAgICAgICAgICAgICAgICB0b2dnbGVXYXRjaDogZnVuY3Rpb24od2F0Y2gpIHtcclxuICAgICAgICAgICAgICAgICAgICBpZih3YXRjaCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZWNvcmREZWNsYXJhdGlvbnMucHVzaCh0cnVlKTtcclxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZWNvcmREZWNsYXJhdGlvbnMucG9wKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfSxcclxuXHJcbiAgICAgICAgICAgICAgICAvKipcclxuICAgICAgICAgICAgICAgICAqIExldCB5b3UgZ2V0IGEgbW9kdWxlIGNvbmZpZyBvYmplY3RcclxuICAgICAgICAgICAgICAgICAqIEBwYXJhbSBtb2R1bGVOYW1lIFN0cmluZyB0aGUgbmFtZSBvZiB0aGUgbW9kdWxlXHJcbiAgICAgICAgICAgICAgICAgKiBAcmV0dXJucyB7Kn1cclxuICAgICAgICAgICAgICAgICAqL1xyXG4gICAgICAgICAgICAgICAgZ2V0TW9kdWxlQ29uZmlnOiBmdW5jdGlvbihtb2R1bGVOYW1lKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYoIWFuZ3VsYXIuaXNTdHJpbmcobW9kdWxlTmFtZSkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdZb3UgbmVlZCB0byBnaXZlIHRoZSBuYW1lIG9mIHRoZSBtb2R1bGUgdG8gZ2V0Jyk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGlmKCFtb2R1bGVzW21vZHVsZU5hbWVdKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gYW5ndWxhci5jb3B5KG1vZHVsZXNbbW9kdWxlTmFtZV0pO1xyXG4gICAgICAgICAgICAgICAgfSxcclxuXHJcbiAgICAgICAgICAgICAgICAvKipcclxuICAgICAgICAgICAgICAgICAqIExldCB5b3UgZGVmaW5lIGEgbW9kdWxlIGNvbmZpZyBvYmplY3RcclxuICAgICAgICAgICAgICAgICAqIEBwYXJhbSBtb2R1bGVDb25maWcgT2JqZWN0IHRoZSBtb2R1bGUgY29uZmlnIG9iamVjdFxyXG4gICAgICAgICAgICAgICAgICogQHJldHVybnMgeyp9XHJcbiAgICAgICAgICAgICAgICAgKi9cclxuICAgICAgICAgICAgICAgIHNldE1vZHVsZUNvbmZpZzogZnVuY3Rpb24obW9kdWxlQ29uZmlnKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYoIWFuZ3VsYXIuaXNPYmplY3QobW9kdWxlQ29uZmlnKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ1lvdSBuZWVkIHRvIGdpdmUgdGhlIG1vZHVsZSBjb25maWcgb2JqZWN0IHRvIHNldCcpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBtb2R1bGVzW21vZHVsZUNvbmZpZy5uYW1lXSA9IG1vZHVsZUNvbmZpZztcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gbW9kdWxlQ29uZmlnO1xyXG4gICAgICAgICAgICAgICAgfSxcclxuXHJcbiAgICAgICAgICAgICAgICAvKipcclxuICAgICAgICAgICAgICAgICAqIFJldHVybnMgdGhlIGxpc3Qgb2YgbG9hZGVkIG1vZHVsZXNcclxuICAgICAgICAgICAgICAgICAqIEByZXR1cm5zIHtzdHJpbmdbXX1cclxuICAgICAgICAgICAgICAgICAqL1xyXG4gICAgICAgICAgICAgICAgZ2V0TW9kdWxlczogKCkgPT4gcmVnTW9kdWxlcyxcclxuXHJcbiAgICAgICAgICAgICAgICAvKipcclxuICAgICAgICAgICAgICAgICAqIExldCB5b3UgY2hlY2sgaWYgYSBtb2R1bGUgaGFzIGJlZW4gbG9hZGVkIGludG8gQW5ndWxhciBvciBub3RcclxuICAgICAgICAgICAgICAgICAqIEBwYXJhbSBtb2R1bGVzTmFtZXMgU3RyaW5nL09iamVjdCBhIG1vZHVsZSBuYW1lLCBvciBhIGxpc3Qgb2YgbW9kdWxlIG5hbWVzXHJcbiAgICAgICAgICAgICAgICAgKiBAcmV0dXJucyB7Ym9vbGVhbn1cclxuICAgICAgICAgICAgICAgICAqL1xyXG4gICAgICAgICAgICAgICAgaXNMb2FkZWQ6IGZ1bmN0aW9uKG1vZHVsZXNOYW1lcykge1xyXG4gICAgICAgICAgICAgICAgICAgIHZhciBtb2R1bGVMb2FkZWQgPSBmdW5jdGlvbihtb2R1bGUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGlzTG9hZGVkID0gcmVnTW9kdWxlcy5pbmRleE9mKG1vZHVsZSkgPiAtMTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYoIWlzTG9hZGVkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0xvYWRlZCA9ICEhbW9kdWxlRXhpc3RzKG1vZHVsZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGlzTG9hZGVkO1xyXG4gICAgICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgICAgICAgICAgaWYoYW5ndWxhci5pc1N0cmluZyhtb2R1bGVzTmFtZXMpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG1vZHVsZXNOYW1lcyA9IFttb2R1bGVzTmFtZXNdO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBpZihhbmd1bGFyLmlzQXJyYXkobW9kdWxlc05hbWVzKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaSwgbGVuO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IoaSA9IDAsIGxlbiA9IG1vZHVsZXNOYW1lcy5sZW5ndGg7IGkgPCBsZW47IGkrKykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYoIW1vZHVsZUxvYWRlZChtb2R1bGVzTmFtZXNbaV0pKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignWW91IG5lZWQgdG8gZGVmaW5lIHRoZSBtb2R1bGUocykgbmFtZShzKScpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH0sXHJcblxyXG4gICAgICAgICAgICAgICAgLyoqXHJcbiAgICAgICAgICAgICAgICAgKiBHaXZlbiBhIG1vZHVsZSwgcmV0dXJuIGl0cyBuYW1lXHJcbiAgICAgICAgICAgICAgICAgKiBAcGFyYW0gbW9kdWxlXHJcbiAgICAgICAgICAgICAgICAgKiBAcmV0dXJucyB7U3RyaW5nfVxyXG4gICAgICAgICAgICAgICAgICovXHJcbiAgICAgICAgICAgICAgICBfZ2V0TW9kdWxlTmFtZTogZ2V0TW9kdWxlTmFtZSxcclxuXHJcbiAgICAgICAgICAgICAgICAvKipcclxuICAgICAgICAgICAgICAgICAqIFJldHVybnMgYSBtb2R1bGUgaWYgaXQgZXhpc3RzXHJcbiAgICAgICAgICAgICAgICAgKiBAcGFyYW0gbW9kdWxlTmFtZVxyXG4gICAgICAgICAgICAgICAgICogQHJldHVybnMge21vZHVsZX1cclxuICAgICAgICAgICAgICAgICAqL1xyXG4gICAgICAgICAgICAgICAgX2dldE1vZHVsZTogZnVuY3Rpb24gZ2V0TW9kdWxlKG1vZHVsZU5hbWUpIHtcclxuICAgICAgICAgICAgICAgICAgICB0cnkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmdNb2R1bGVGY3QobW9kdWxlTmFtZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaChlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIHRoaXMgZXJyb3IgbWVzc2FnZSByZWFsbHkgc3V4eFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZigvTm8gbW9kdWxlLy50ZXN0KGUpIHx8IGUubWVzc2FnZS5pbmRleE9mKCckaW5qZWN0b3I6bm9tb2QnKSA+IC0xKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlLm1lc3NhZ2UgPSBgVGhlIG1vZHVsZSBcIiR7IHN0cmluZ2lmeShtb2R1bGVOYW1lKSB9XCIgdGhhdCB5b3UgYXJlIHRyeWluZyB0byBsb2FkIGRvZXMgbm90IGV4aXN0LiAkeyBlLm1lc3NhZ2UgfWA7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgZTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9LFxyXG5cclxuICAgICAgICAgICAgICAgIC8qKlxyXG4gICAgICAgICAgICAgICAgICogQ2hlY2sgaWYgYSBtb2R1bGUgZXhpc3RzIGFuZCByZXR1cm5zIGl0IGlmIGl0IGRvZXNcclxuICAgICAgICAgICAgICAgICAqIEBwYXJhbSBtb2R1bGVOYW1lXHJcbiAgICAgICAgICAgICAgICAgKiBAcmV0dXJucyB7Ym9vbGVhbn1cclxuICAgICAgICAgICAgICAgICAqL1xyXG4gICAgICAgICAgICAgICAgbW9kdWxlRXhpc3RzOiBtb2R1bGVFeGlzdHMsXHJcblxyXG4gICAgICAgICAgICAgICAgLyoqXHJcbiAgICAgICAgICAgICAgICAgKiBMb2FkIHRoZSBkZXBlbmRlbmNpZXMsIGFuZCBtaWdodCB0cnkgdG8gbG9hZCBuZXcgZmlsZXMgZGVwZW5kaW5nIG9uIHRoZSBjb25maWdcclxuICAgICAgICAgICAgICAgICAqIEBwYXJhbSBtb2R1bGVOYW1lIChTdHJpbmcgb3IgQXJyYXkgb2YgU3RyaW5ncylcclxuICAgICAgICAgICAgICAgICAqIEBwYXJhbSBsb2NhbFBhcmFtc1xyXG4gICAgICAgICAgICAgICAgICogQHJldHVybnMgeyp9XHJcbiAgICAgICAgICAgICAgICAgKiBAcHJpdmF0ZVxyXG4gICAgICAgICAgICAgICAgICovXHJcbiAgICAgICAgICAgICAgICBfbG9hZERlcGVuZGVuY2llczogZnVuY3Rpb24gX2xvYWREZXBlbmRlbmNpZXMobW9kdWxlTmFtZSwgbG9jYWxQYXJhbXMpIHtcclxuICAgICAgICAgICAgICAgICAgICB2YXIgbG9hZGVkTW9kdWxlLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICByZXF1aXJlcyxcclxuICAgICAgICAgICAgICAgICAgICAgICAgZGlmZixcclxuICAgICAgICAgICAgICAgICAgICAgICAgcHJvbWlzZXNMaXN0ID0gW10sXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYgPSB0aGlzO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICBtb2R1bGVOYW1lID0gc2VsZi5fZ2V0TW9kdWxlTmFtZShtb2R1bGVOYW1lKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgaWYobW9kdWxlTmFtZSA9PT0gbnVsbCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJHEud2hlbigpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkZWRNb2R1bGUgPSBzZWxmLl9nZXRNb2R1bGUobW9kdWxlTmFtZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2goZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlamVjdChlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBnZXQgdW5sb2FkZWQgcmVxdWlyZXNcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWlyZXMgPSBzZWxmLmdldFJlcXVpcmVzKGxvYWRlZE1vZHVsZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICBhbmd1bGFyLmZvckVhY2gocmVxdWlyZXMsIHJlcXVpcmVFbnRyeSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIElmIG5vIGNvbmZpZ3VyYXRpb24gaXMgcHJvdmlkZWQsIHRyeSBhbmQgZmluZCBvbmUgZnJvbSBhIHByZXZpb3VzIGxvYWQuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIElmIHRoZXJlIGlzbid0IG9uZSwgYmFpbCBhbmQgbGV0IHRoZSBub3JtYWwgZmxvdyBydW5cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYoYW5ndWxhci5pc1N0cmluZyhyZXF1aXJlRW50cnkpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgY29uZmlnID0gc2VsZi5nZXRNb2R1bGVDb25maWcocmVxdWlyZUVudHJ5KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKGNvbmZpZyA9PT0gbnVsbCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZHVsZUNhY2hlLnB1c2gocmVxdWlyZUVudHJ5KTsgLy8gV2UgZG9uJ3Qga25vdyBhYm91dCB0aGlzIG1vZHVsZSwgYnV0IHNvbWV0aGluZyBlbHNlIG1pZ2h0LCBzbyBwdXNoIGl0IGFueXdheS5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1aXJlRW50cnkgPSBjb25maWc7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBpZ25vcmUgdGhlIG5hbWUgYmVjYXVzZSBpdCdzIHByb2JhYmx5IG5vdCBhIHJlYWwgbW9kdWxlIG5hbWVcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpZy5uYW1lID0gdW5kZWZpbmVkO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBDaGVjayBpZiB0aGlzIGRlcGVuZGVuY3kgaGFzIGJlZW4gbG9hZGVkIHByZXZpb3VzbHlcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYoc2VsZi5tb2R1bGVFeGlzdHMocmVxdWlyZUVudHJ5Lm5hbWUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBjb21wYXJlIGFnYWluc3QgdGhlIGFscmVhZHkgbG9hZGVkIG1vZHVsZSB0byBzZWUgaWYgdGhlIG5ldyBkZWZpbml0aW9uIGFkZHMgYW55IG5ldyBmaWxlc1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlmZiA9IHJlcXVpcmVFbnRyeS5maWxlcy5maWx0ZXIobiA9PiBzZWxmLmdldE1vZHVsZUNvbmZpZyhyZXF1aXJlRW50cnkubmFtZSkuZmlsZXMuaW5kZXhPZihuKSA8IDApO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIElmIHRoZSBtb2R1bGUgd2FzIHJlZGVmaW5lZCwgYWR2aXNlIHZpYSB0aGUgY29uc29sZVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYoZGlmZi5sZW5ndGggIT09IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl8kbG9nLndhcm4oJ01vZHVsZSBcIicsIG1vZHVsZU5hbWUsICdcIiBhdHRlbXB0ZWQgdG8gcmVkZWZpbmUgY29uZmlndXJhdGlvbiBmb3IgZGVwZW5kZW5jeS4gXCInLCByZXF1aXJlRW50cnkubmFtZSwgJ1wiXFxuIEFkZGl0aW9uYWwgRmlsZXMgTG9hZGVkOicsIGRpZmYpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIFB1c2ggZXZlcnl0aGluZyB0byB0aGUgZmlsZSBsb2FkZXIsIGl0IHdpbGwgd2VlZCBvdXQgdGhlIGR1cGxpY2F0ZXMuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZihhbmd1bGFyLmlzRGVmaW5lZChzZWxmLmZpbGVzTG9hZGVyKSkgeyAvLyBpZiBhIGZpbGVzIGxvYWRlciBpcyBkZWZpbmVkXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvbWlzZXNMaXN0LnB1c2goc2VsZi5maWxlc0xvYWRlcihyZXF1aXJlRW50cnksIGxvY2FsUGFyYW1zKS50aGVuKCgpID0+IHNlbGYuX2xvYWREZXBlbmRlbmNpZXMocmVxdWlyZUVudHJ5KSkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVqZWN0KG5ldyBFcnJvcihgRXJyb3I6IE5ldyBkZXBlbmRlbmNpZXMgbmVlZCB0byBiZSBsb2FkZWQgZnJvbSBleHRlcm5hbCBmaWxlcyAoJHtyZXF1aXJlRW50cnkuZmlsZXN9KSwgYnV0IG5vIGxvYWRlciBoYXMgYmVlbiBkZWZpbmVkLmApKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmKGFuZ3VsYXIuaXNBcnJheShyZXF1aXJlRW50cnkpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgZmlsZXMgPSBbXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFuZ3VsYXIuZm9yRWFjaChyZXF1aXJlRW50cnksIGVudHJ5ID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBsZXQncyBjaGVjayBpZiB0aGUgZW50cnkgaXMgYSBmaWxlIG5hbWUgb3IgYSBjb25maWcgbmFtZVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBjb25maWcgPSBzZWxmLmdldE1vZHVsZUNvbmZpZyhlbnRyeSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNvbmZpZyA9PT0gbnVsbCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWxlcy5wdXNoKGVudHJ5KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYoY29uZmlnLmZpbGVzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVzID0gZmlsZXMuY29uY2F0KGNvbmZpZy5maWxlcyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZihmaWxlcy5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWlyZUVudHJ5ID0ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWxlczogZmlsZXNcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYoYW5ndWxhci5pc09iamVjdChyZXF1aXJlRW50cnkpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZihyZXF1aXJlRW50cnkuaGFzT3duUHJvcGVydHkoJ25hbWUnKSAmJiByZXF1aXJlRW50cnlbJ25hbWUnXSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIFRoZSBkZXBlbmRlbmN5IGRvZXNuJ3QgZXhpc3QgaW4gdGhlIG1vZHVsZSBjYWNoZSBhbmQgaXMgYSBuZXcgY29uZmlndXJhdGlvbiwgc28gc3RvcmUgYW5kIHB1c2ggaXQuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5zZXRNb2R1bGVDb25maWcocmVxdWlyZUVudHJ5KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb2R1bGVDYWNoZS5wdXNoKHJlcXVpcmVFbnRyeVsnbmFtZSddKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gQ2hlY2sgaWYgdGhlIGRlcGVuZGVuY3kgaGFzIGFueSBmaWxlcyB0aGF0IG5lZWQgdG8gYmUgbG9hZGVkLiBJZiB0aGVyZSBhcmUsIHB1c2ggYSBuZXcgcHJvbWlzZSB0byB0aGUgcHJvbWlzZSBsaXN0LlxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZihhbmd1bGFyLmlzRGVmaW5lZChyZXF1aXJlRW50cnkuZmlsZXMpICYmIHJlcXVpcmVFbnRyeS5maWxlcy5sZW5ndGggIT09IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKGFuZ3VsYXIuaXNEZWZpbmVkKHNlbGYuZmlsZXNMb2FkZXIpKSB7IC8vIGlmIGEgZmlsZXMgbG9hZGVyIGlzIGRlZmluZWRcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9taXNlc0xpc3QucHVzaChzZWxmLmZpbGVzTG9hZGVyKHJlcXVpcmVFbnRyeSwgbG9jYWxQYXJhbXMpLnRoZW4oKCkgPT4gc2VsZi5fbG9hZERlcGVuZGVuY2llcyhyZXF1aXJlRW50cnkpKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZWplY3QobmV3IEVycm9yKGBFcnJvcjogdGhlIG1vZHVsZSBcIiR7cmVxdWlyZUVudHJ5Lm5hbWV9XCIgaXMgZGVmaW5lZCBpbiBleHRlcm5hbCBmaWxlcyAoJHtyZXF1aXJlRW50cnkuZmlsZXN9KSwgYnV0IG5vIGxvYWRlciBoYXMgYmVlbiBkZWZpbmVkLmApKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH0pO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAvLyBDcmVhdGUgYSB3cmFwcGVyIHByb21pc2UgdG8gd2F0Y2ggdGhlIHByb21pc2UgbGlzdCBhbmQgcmVzb2x2ZSBpdCBvbmNlIGV2ZXJ5dGhpbmcgaXMgZG9uZS5cclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJHEuYWxsKHByb21pc2VzTGlzdCk7XHJcbiAgICAgICAgICAgICAgICB9LFxyXG5cclxuICAgICAgICAgICAgICAgIC8qKlxyXG4gICAgICAgICAgICAgICAgICogSW5qZWN0IG5ldyBtb2R1bGVzIGludG8gQW5ndWxhclxyXG4gICAgICAgICAgICAgICAgICogQHBhcmFtIG1vZHVsZU5hbWVcclxuICAgICAgICAgICAgICAgICAqIEBwYXJhbSBsb2NhbFBhcmFtc1xyXG4gICAgICAgICAgICAgICAgICogQHBhcmFtIHJlYWxcclxuICAgICAgICAgICAgICAgICAqL1xyXG4gICAgICAgICAgICAgICAgaW5qZWN0OiBmdW5jdGlvbihtb2R1bGVOYW1lLCBsb2NhbFBhcmFtcyA9IHt9LCByZWFsID0gZmFsc2UpIHtcclxuICAgICAgICAgICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmVycmVkID0gJHEuZGVmZXIoKTtcclxuICAgICAgICAgICAgICAgICAgICBpZihhbmd1bGFyLmlzRGVmaW5lZChtb2R1bGVOYW1lKSAmJiBtb2R1bGVOYW1lICE9PSBudWxsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmKGFuZ3VsYXIuaXNBcnJheShtb2R1bGVOYW1lKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHByb21pc2VzTGlzdCA9IFtdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ndWxhci5mb3JFYWNoKG1vZHVsZU5hbWUsIG1vZHVsZSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvbWlzZXNMaXN0LnB1c2goc2VsZi5pbmplY3QobW9kdWxlLCBsb2NhbFBhcmFtcywgcmVhbCkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJHEuYWxsKHByb21pc2VzTGlzdCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl9hZGRUb0xvYWRMaXN0KHNlbGYuX2dldE1vZHVsZU5hbWUobW9kdWxlTmFtZSksIHRydWUsIHJlYWwpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGlmKG1vZHVsZXNUb0xvYWQubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgcmVzID0gbW9kdWxlc1RvTG9hZC5zbGljZSgpOyAvLyBjbGVhbiBjb3B5XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBsb2FkTmV4dCA9IGZ1bmN0aW9uIGxvYWROZXh0KG1vZHVsZU5hbWUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZHVsZUNhY2hlLnB1c2gobW9kdWxlTmFtZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb2R1bGVQcm9taXNlc1ttb2R1bGVOYW1lXSA9IGRlZmVycmVkLnByb21pc2U7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl9sb2FkRGVwZW5kZW5jaWVzKG1vZHVsZU5hbWUsIGxvY2FsUGFyYW1zKS50aGVuKGZ1bmN0aW9uIHN1Y2Nlc3MoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAganVzdExvYWRlZCA9IFtdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfcmVnaXN0ZXIocHJvdmlkZXJzLCBtb2R1bGVDYWNoZSwgbG9jYWxQYXJhbXMpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2goZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl8kbG9nLmVycm9yKGUubWVzc2FnZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmVycmVkLnJlamVjdChlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYobW9kdWxlc1RvTG9hZC5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWROZXh0KG1vZHVsZXNUb0xvYWQuc2hpZnQoKSk7IC8vIGxvYWQgdGhlIG5leHQgaW4gbGlzdFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmVycmVkLnJlc29sdmUocmVzKTsgLy8gZXZlcnl0aGluZyBoYXMgYmVlbiBsb2FkZWQsIHJlc29sdmVcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBmdW5jdGlvbiBlcnJvcihlcnIpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZlcnJlZC5yZWplY3QoZXJyKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gbG9hZCB0aGUgZmlyc3QgaW4gbGlzdFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBsb2FkTmV4dChtb2R1bGVzVG9Mb2FkLnNoaWZ0KCkpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobG9jYWxQYXJhbXMgJiYgbG9jYWxQYXJhbXMubmFtZSAmJiBtb2R1bGVQcm9taXNlc1tsb2NhbFBhcmFtcy5uYW1lXSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbW9kdWxlUHJvbWlzZXNbbG9jYWxQYXJhbXMubmFtZV07XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZGVmZXJyZWQucmVzb2x2ZSgpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZGVmZXJyZWQucHJvbWlzZTtcclxuICAgICAgICAgICAgICAgIH0sXHJcblxyXG4gICAgICAgICAgICAgICAgLyoqXHJcbiAgICAgICAgICAgICAgICAgKiBHZXQgdGhlIGxpc3Qgb2YgcmVxdWlyZWQgbW9kdWxlcy9zZXJ2aWNlcy8uLi4gZm9yIHRoaXMgbW9kdWxlXHJcbiAgICAgICAgICAgICAgICAgKiBAcGFyYW0gbW9kdWxlXHJcbiAgICAgICAgICAgICAgICAgKiBAcmV0dXJucyB7QXJyYXl9XHJcbiAgICAgICAgICAgICAgICAgKi9cclxuICAgICAgICAgICAgICAgIGdldFJlcXVpcmVzOiBmdW5jdGlvbiBnZXRSZXF1aXJlcyhtb2R1bGUpIHtcclxuICAgICAgICAgICAgICAgICAgICB2YXIgcmVxdWlyZXMgPSBbXTtcclxuICAgICAgICAgICAgICAgICAgICBhbmd1bGFyLmZvckVhY2gobW9kdWxlLnJlcXVpcmVzLCByZXF1aXJlTW9kdWxlID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYocmVnTW9kdWxlcy5pbmRleE9mKHJlcXVpcmVNb2R1bGUpID09PSAtMSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWlyZXMucHVzaChyZXF1aXJlTW9kdWxlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiByZXF1aXJlcztcclxuICAgICAgICAgICAgICAgIH0sXHJcblxyXG4gICAgICAgICAgICAgICAgLyoqXHJcbiAgICAgICAgICAgICAgICAgKiBJbnZva2UgdGhlIG5ldyBtb2R1bGVzICYgY29tcG9uZW50IGJ5IHRoZWlyIHByb3ZpZGVyc1xyXG4gICAgICAgICAgICAgICAgICogQHBhcmFtIHByb3ZpZGVyc1xyXG4gICAgICAgICAgICAgICAgICogQHBhcmFtIHF1ZXVlXHJcbiAgICAgICAgICAgICAgICAgKiBAcGFyYW0gbW9kdWxlTmFtZVxyXG4gICAgICAgICAgICAgICAgICogQHBhcmFtIHJlY29uZmlnXHJcbiAgICAgICAgICAgICAgICAgKiBAcHJpdmF0ZVxyXG4gICAgICAgICAgICAgICAgICovXHJcbiAgICAgICAgICAgICAgICBfaW52b2tlUXVldWU6IF9pbnZva2VRdWV1ZSxcclxuXHJcbiAgICAgICAgICAgICAgICAvKipcclxuICAgICAgICAgICAgICAgICAqIENoZWNrIGlmIGEgbW9kdWxlIGhhcyBiZWVuIGludm9rZWQgYW5kIHJlZ2lzdGVycyBpdCBpZiBub3RcclxuICAgICAgICAgICAgICAgICAqIEBwYXJhbSBhcmdzXHJcbiAgICAgICAgICAgICAgICAgKiBAcGFyYW0gbW9kdWxlTmFtZVxyXG4gICAgICAgICAgICAgICAgICogQHJldHVybnMge2Jvb2xlYW59IGlzIG5ld1xyXG4gICAgICAgICAgICAgICAgICovXHJcbiAgICAgICAgICAgICAgICBfcmVnaXN0ZXJJbnZva2VMaXN0OiBfcmVnaXN0ZXJJbnZva2VMaXN0LFxyXG5cclxuICAgICAgICAgICAgICAgIC8qKlxyXG4gICAgICAgICAgICAgICAgICogUmVnaXN0ZXIgYSBuZXcgbW9kdWxlIGFuZCBsb2FkcyBpdCwgZXhlY3V0aW5nIHRoZSBydW4vY29uZmlnIGJsb2NrcyBpZiBuZWVkZWRcclxuICAgICAgICAgICAgICAgICAqIEBwYXJhbSBwcm92aWRlcnNcclxuICAgICAgICAgICAgICAgICAqIEBwYXJhbSByZWdpc3Rlck1vZHVsZXNcclxuICAgICAgICAgICAgICAgICAqIEBwYXJhbSBwYXJhbXNcclxuICAgICAgICAgICAgICAgICAqIEBwcml2YXRlXHJcbiAgICAgICAgICAgICAgICAgKi9cclxuICAgICAgICAgICAgICAgIF9yZWdpc3RlcjogX3JlZ2lzdGVyLFxyXG5cclxuICAgICAgICAgICAgICAgIC8qKlxyXG4gICAgICAgICAgICAgICAgICogQWRkIGEgbW9kdWxlIG5hbWUgdG8gdGhlIGxpc3Qgb2YgbW9kdWxlcyB0aGF0IHdpbGwgYmUgbG9hZGVkIGluIHRoZSBuZXh0IGluamVjdFxyXG4gICAgICAgICAgICAgICAgICogQHBhcmFtIG5hbWVcclxuICAgICAgICAgICAgICAgICAqIEBwYXJhbSBmb3JjZVxyXG4gICAgICAgICAgICAgICAgICogQHByaXZhdGVcclxuICAgICAgICAgICAgICAgICAqL1xyXG4gICAgICAgICAgICAgICAgX2FkZFRvTG9hZExpc3Q6IF9hZGRUb0xvYWRMaXN0LFxyXG5cclxuICAgICAgICAgICAgICAgIC8qKlxyXG4gICAgICAgICAgICAgICAgICogVW5yZWdpc3RlciBtb2R1bGVzICh5b3Ugc2hvdWxkbid0IGhhdmUgdG8gdXNlIHRoaXMpXHJcbiAgICAgICAgICAgICAgICAgKiBAcGFyYW0gbW9kdWxlc1xyXG4gICAgICAgICAgICAgICAgICovXHJcbiAgICAgICAgICAgICAgICBfdW5yZWdpc3RlcjogZnVuY3Rpb24obW9kdWxlcykge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmKGFuZ3VsYXIuaXNEZWZpbmVkKG1vZHVsZXMpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmKGFuZ3VsYXIuaXNBcnJheShtb2R1bGVzKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ndWxhci5mb3JFYWNoKG1vZHVsZXMsIG1vZHVsZSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVnSW52b2tlc1ttb2R1bGVdID0gdW5kZWZpbmVkO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH07XHJcbiAgICAgICAgfTtcclxuXHJcbiAgICAgICAgLy8gTGV0J3MgZ2V0IHRoZSBsaXN0IG9mIGxvYWRlZCBtb2R1bGVzICYgY29tcG9uZW50c1xyXG4gICAgICAgIHRoaXMuX2luaXQoYW5ndWxhci5lbGVtZW50KHdpbmRvdy5kb2N1bWVudCkpO1xyXG4gICAgfSk7XHJcblxyXG4gICAgdmFyIGJvb3RzdHJhcEZjdCA9IGFuZ3VsYXIuYm9vdHN0cmFwO1xyXG4gICAgYW5ndWxhci5ib290c3RyYXAgPSBmdW5jdGlvbihlbGVtZW50LCBtb2R1bGVzLCBjb25maWcpIHtcclxuICAgICAgICAvLyBDbGVhbiBzdGF0ZSBmcm9tIHByZXZpb3VzIGJvb3RzdHJhcFxyXG4gICAgICAgIHJlZ01vZHVsZXMgPSBbJ25nJywgJ29jLmxhenlMb2FkJ107XHJcbiAgICAgICAgcmVnSW52b2tlcyA9IHt9O1xyXG4gICAgICAgIHJlZ0NvbmZpZ3MgPSBbXTtcclxuICAgICAgICBtb2R1bGVzVG9Mb2FkID0gW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