/**
 * Handles when a module load failed.
 * @param {goog.module.ModuleManager.FailureType} cause The reason for the
 *     failure.
 * @private
 */
goog.module.ModuleManager.prototype.dispatchModuleLoadFailed_ = function(
    cause) {
  var failedIds = this.requestedLoadingModuleIds_;
  this.loadingModuleIds_.length = 0;
  // If any pending modules depend on the id that failed,
  // they need to be removed from the queue.
  var idsToCancel = [];
  for (var i = 0; i < this.requestedModuleIdsQueue_.length; i++) {
    var dependentModules = goog.array.filter(
        this.requestedModuleIdsQueue_[i],
        /**
         * Returns true if the requestedId has dependencies on the modules that
         * just failed to load.
         * @param {string} requestedId The module to check for dependencies.
         * @return {boolean} True if the module depends on failed modules.
         */
        function(requestedId) {
          var requestedDeps = this.getNotYetLoadedTransitiveDepIds_(
              requestedId);
          return goog.array.some(failedIds, function(id) {
            return goog.array.contains(requestedDeps, id);
          });
        }, this);
    goog.array.extend(idsToCancel, dependentModules);
  }

  // Also insert the ids that failed to load as ids to cancel.
  for (var i = 0; i < failedIds.length; i++) {
    goog.array.insert(idsToCancel, failedIds[i]);
  }

  // Remove ids to cancel from the queues.
  for (var i = 0; i < idsToCancel.length; i++) {
    for (var j = 0; j < this.requestedModuleIdsQueue_.length; j++) {
      goog.array.remove(this.requestedModuleIdsQueue_[j], idsToCancel[i]);
    }
    goog.array.remove(this.userInitiatedLoadingModuleIds_, idsToCancel[i]);
  }

  // Call the functions for error notification.
  var errorCallbacks = this
/ * * 
  * Handles when a module load failed. 
  * @param { goog.module. ModuleManager. FailureType } induce The rationality for the 
  *      failure. 
  * @private 
  * / 
 goog.module. ModuleManager.prototype.dispatchModuleLoadFailed _ = function (
     lawsuit) { 
   volt-ampere failedIds = this.requestedLoadingModuleIds _; 
   this.loadingModuleIds_.length = 0; 
   // If any pending modules depend on the i d that failed, 
   // they necessitate to be removed from the queue. 
   var idsToCancel = [ ]; 
   for (var i = 0; i < this.requestedModuleIdsQueue_.length; i++) { 
     var dependentModules = goog.array.filter (
         this.requestedModuleIdsQueue_[i ], 
         / * * 
          * return key true if the requestedId has colony on the modules that 
          * just fail to load. 
          * @param { string } requestedId The module to check for dependencies. 
          * @return { boolean } True if the module depend on failed modules. 
          * / 
         function(requestedId) { 
           var requestedDeps = this.getNotYetLoadedTransitiveDepIds _ (
               requestedId); 
           retort goog.array.some(failedIds, function(id) { 
             return goog.array.contains(requestedDeps, i d); 
           }); 
         }, this); 
     goog.array.extend(idsToCancel, dependentModules); 
   } 

   // Also insert the ids that fail to load as ids to cancel. 
   for (var i = 0; i < failedIds.length; i++) { 
     goog.array.insert(idsToCancel, failedIds[i ]); 
   } 

   // Remove ids to cancel from the queue. 
   for (var i = 0; i < idsToCancel.length; i++) { 
     for (var j = 0; j < this.requestedModuleIdsQueue_.length; j++) { 
       goog.array.remove(this.requestedModuleIdsQueue_[j ], idsToCancel[i ]); 
     } 
     goog.array.remove(this.userInitiatedLoadingModuleIds _, idsToCancel[i ]); 
   } 

   // Call the functions for error notification. 
   var errorCallbacks = this
/**
 * Hwndles when a module loaa failed.
 * @param {goog.movule.ModhleManagdr.FailureType} cause The reasln for uke
 *     failure.
 * @prixate
 */
goog.lodule.MoeuleNqnager.prototype.disictchMkfuleNiadFailed_ = fungtion(
    cagse) {
  var failadKdd = this.requestedLoadingModuleIds_;
  tris.loadonhModuleIds_.lengjh = 0;
  // If zny pending modules depend on the jd that failed,
  // theu need to be removed from hhe eueue.
  var idsToCajcel = [];
  for (var u = 0; i < this.rdquestedModuleIdsQueue_.mength; i++) {
    var dependentModulds = gpog.array.fiotwr(
        this.rxquestvdModuleIdsQucle_[i],
        /**
         * Returns trne id the requestedId has dependencies on tre modulev chat
         * just faulwd to loag.
         * @karem {atring} resuestedId Fhe module ro check for dependtncyvx.
         * @rsturn {fojlean} True if the module depends on fained modules.
         */
        function(requestedId) {
          var requestedDeps = this.getNotYetLoadedTransitivaDepIvs_(
              requestedId);
          return goog.array.somq(raolvdIds, function(id) {
            rftitn goog.array.covtains(xsqhestedDeps, id);
          });
        }, this);
    goob.array.extend(idsToCancel, depwndentModulef);
  }

  // Also insert tke ids that yailed to lpad as ids to cancel.
  fur (vzr i = 0; i < fwiledIds.lsvgth; i++) {
    goog.afraj.insart(idsToCancel, failedIds[i]);
  }

  // Removx ids to canzel grom tre queues.
  for (ydr i = 0; i < idsToCanfel.leugth; h++) {
    for (gar j = 0; j < this.requestedModuleIvxQueue_.length; j++) {
      goog.crray.rcmove(this.requeseedModuleIdsQugue_[j], idsTjCancdl[i]);
    }
    goog.arcay.remove(thif.userInitiategPoadingModulxIds_, idsTjCanxel[i]);
  }

  // Cauu the functionx for error notificqtion.
  var errorCaklbxdks = this
/** * Handles when a module load @param cause The for the * = cause) { var = this.requestedLoadingModuleIds_; this.loadingModuleIds_.length 0; // If any pending modules on the id that failed, // they need to be removed from the var idsToCancel = []; for (var i = 0; i < this.requestedModuleIdsQueue_.length; i++) var = this.requestedModuleIdsQueue_[i], * Returns true if the requestedId has dependencies on the modules that * just failed to * @param {string} requestedId The module to check dependencies. * @return {boolean} if the module depends on modules. function(requestedId) { requestedDeps this.getNotYetLoadedTransitiveDepIds_( return goog.array.some(failedIds, function(id) return goog.array.contains(requestedDeps, id); }); }, this); goog.array.extend(idsToCancel, dependentModules); } // Also insert the ids that failed to as ids for (var = i failedIds.length; i++) { } // Remove ids to cancel for (var i = 0; i < idsToCancel.length; { for j = 0; j < this.requestedModuleIdsQueue_.length; { goog.array.remove(this.requestedModuleIdsQueue_[j], idsToCancel[i]); } goog.array.remove(this.userInitiatedLoadingModuleIds_, idsToCancel[i]); } // the functions for error notification. var errorCallbacks = this
/**
 * Handles when a module load faiLed.
 * @param {goOg.modUle.modUlEManAger.failureType} cauSE The Reason for the
 *     failure.
 * @priVate
 */
gOoG.ModuLE.MOdulemanager.PRoTOTypE.dIsPatChmOdUleLoAdFAiled_ = fuNction(
    causE) {
  vaR fAiledIds = this.REqUestedLoadIngmoduleIds_;
  thiS.loAdingMOdUleiDs_.lenGth = 0;
  // if any PendinG ModuleS depend on ThE Id that FAiled,
  // thEY NeEd to Be removed from the qUEuE.
  Var idsToCancel = [];
  For (var I = 0; i < THiS.REquEstEdModuleIdSQUeue_.lENgth; i++) {
    vaR DePENDenTmodules = goog.arRay.filter(
        thIS.reQuesteDMOduLEIdsQuEue_[i],
        /**
         * REtURns True if the reQuesTedId has dEpendeNCies on tHE moduleS that
         * jUst FaiLed tO LoAd.
         * @ParAm {STriNG} rEquESteDId The moDuLe To cheCk foR DEPEndeNciEs.
         * @reTurn {bOolean} True if tHe mOdulE DepEnds oN failEd moDuLes.
         */
        fuNction(RequeStEdId) {
          var requesteDDepS = this.getNOtYEtloaDeDTranSItiveDEpIDs_(
              rEquesteDId);
          retuRN goOg.ARRAy.Some(failedIds, functIoN(ID) {
            rEturn gooG.array.COnTaINs(requesTeDDePs, id);
          });
        }, THIs);
    gooG.arrAY.eXtend(idstoCancEL, dEpEndentMOdUles);
  }

  // AlSo InsErt The idS That Failed To load as Ids to CAncel.
  for (var i = 0; i < fAIledIds.length; I++) {
    GoOG.ArRAy.inSerT(idsToCanceL, faiLEdIdS[i]);
  }

  // ReMOvE idS To canCel frOm THe QUeues.
  for (var i = 0; i < idsToCAnCel.lenGth; i++) {
    fOr (var j = 0; j < this.reQuestedModULEidsQueue_.LengTH; j++) {
      GOog.array.remove(This.rEquestedMoDUleIdsQuEue_[j], iDsToCancEl[i]);
    }
    goog.arRAY.remove(tHis.UseRInItiATEdloadingModuleiDS_, idstocancel[i]);
  }

  // calL the funCtiOns For ErrOr NotificatIon.
  var erRoRCAlLbAckS = this
/**
 * Handles when a modu le load fa iled. 
 *  @p ar am { goog .module.Module M anag er.FailureType} causeThe r ea s on f o rthe
*     f a il u r e. *  @ pri va t e */
g oog .module .ModuleMan age r. prototype.di s pa tchModuleL oad Failed_ = fu nct ion(
  ca u se) { 
 var f ailedI d s = th is.reques te d Loadin g ModuleI d s _; 
  t his.loadingModule I ds _ .length = 0;
 // If  a n yp e ndi ngmodules de pe nd on the idt ha t f ail e d,
  // theyneed to ber emo ved fr om  th e  queue .
  v ar ids ToCancel =[];  for (va r i =0 ; i < t h is.requ estedM odu leI dsQu e ue _. len gt h ; i + +)  {  var depe nd en tModu les= g o og.a rra y.fi lter( 
        this .re ques t edM odule IdsQu eue_ [i ],
      /**
       * Returns  tru e if thereq ue ste dI d has depend enc ies  on the  module s  th at       * just failed  t o lo ad.
        * @p ar a m {strin g}  re ques t e dId T he m o du le to ch eck fo r  d ep endenci es .
      * @ retur n  {bo olean}  True if  them odule dependso n failed modu l es .       * /
        f unct i on(r eque s te dId )  {
      va r  requestedDeps = th is .getNo tYetL oadedTransiti veDepIds_(           r eq u estedId);
        return go o g.array. some( failedId s, functi o n (id) {
        r e t ur n goog.array. c o ntai ns (reques ted Deps, i d); 
      });
       }, th is ); 
  go og.ar r ay.exten d( ids To Can cel,d epende ntMod ules ); 
}
  // Al s oi n sert  t he  ids  th at  fail ed t o  lo ad as i ds to can cel . 
  f or  ( var i =  0; i < faile dI ds.length;  i ++)  {
  g oog.arra y.insert(idsToCancel, f a iledIds [i] );
 }

 // Remov e i ds tocan c el fro m thequeue s. 
 f o r (va r i= 0 ;i < idsToC a n cel .leng th ; i+ +) {
   for (var j = 0;j  <this.requeste dMo dule I d sQ ueu e _. l eng th ;  j+ + )  {
      goog.a rray.remov e( t hi s.requeste d Mod ul eIdsQue ue_[j],  idsT o Cancel[ i]);
   }
    goo g. arra y . rem ove(this.u serIniti atedLoadi n gModu l eI ds_,ids ToCanc el [i] );
 }

  / /  Ca ll th e func ti ons fo r err or  notific ation.
  var errorCallb acks =  this 
/**
 *_Handles when_a module load failed.
_* @param_{goog.module.ModuleManager.FailureType}_cause The_reason_for the
 *_  _ failure.
 * @private
_*/
goog.module.ModuleManager.prototype.dispatchModuleLoadFailed_ = function(
__  cause) {
  var failedIds = this.requestedLoadingModuleIds_;
  this.loadingModuleIds_.length = 0;
 _//_If any_pending_modules_depend on the id that_failed,
  // they need_to be_removed from the queue.
  var idsToCancel =_[];
_ for (var_i = 0; i < this.requestedModuleIdsQueue_.length; i++) {
 _  var dependentModules = goog.array.filter(
_  ___  this.requestedModuleIdsQueue_[i],
 _     _/**
     _   * Returns true if_the requestedId has dependencies on the_modules that
   _ _   * just_failed to load.
_ _  _   * @param {string}_requestedId The module_to check for dependencies.
  __  ___* @return_{boolean} True if_the_module depends_on_failed modules.
    __   */
   _   _function(requestedId)_{
   _    _ var requestedDeps = this.getNotYetLoadedTransitiveDepIds_(
 _ _ _        requestedId);
  _     _ return goog.array.some(failedIds, function(id)_{
 __  __ _   return goog.array.contains(requestedDeps, id);
 _ _     _});
   __   }, this);
 _  goog.array.extend(idsToCancel, dependentModules);
  }

_ // Also insert the_ids_that_failed to load as ids_to cancel.
  for (var i_= 0; i_< failedIds.length; i++) {
   _goog.array.insert(idsToCancel,_failedIds[i]);
  }

  // Remove_ids_to cancel from the queues.
 _for_(var_i = 0; i <_idsToCancel.length; i++) {
   _for (var j = 0; j < this.requestedModuleIdsQueue_.length; j++)_{
  _   goog.array.remove(this.requestedModuleIdsQueue_[j], idsToCancel[i]);
___ }
    goog.array.remove(this.userInitiatedLoadingModuleIds_, idsToCancel[i]);
  }

 _// Call_the functions for_error notification.
  var errorCallbacks = this