import { Route , Routes , } from '@angular/router' ; import { DaffExternalRouterNoWildcardError } from '../../errors/no-wildcard' ; import { DaffExternalRouterInsertionStrategy } from '../../model/insertion-strategy.type' ; /**
 * Inserts a Route into Routes right before the wildcard route.
 * If no wildcard is found, it fails fast with a `DaffExternalRouterNoWildcardError`.
 */ export const daffInsertRouteBeforeWildCardStrategy = ( route , routes ) : Routes => { const index = routes . findIndex ( ( r ) => r . path === '**' ) ; if ( index === - 1 ) { throw new DaffExternalRouterNoWildcardError ( 'No wildcard (**) route was found during route resolution.' ) ; } return [ ... routes . slice ( 0 , index ) , route , ... routes . slice ( index ) , ] ; } ;