@import play.routes.compiler._
@import play.routes.compiler.templates._
@(sourceInfo: RoutesSourceInfo, pkg: Option[String], imports: Seq[String], packageName: Option[String], routes: Seq[Route], namespaceReverseRouter: Boolean, useInjector: Route => Boolean)
// @@GENERATOR:play-routes-compiler
// @@SOURCE:@sourceInfo.source
// @@DATE:@sourceInfo.date

import play.api.routing.JavaScriptReverseRoute

@for(i <- imports) {
import @if(!i.startsWith("_root_.")){_root_.}@i}

@markLines(routes: _*)
package @{packageName.map(_ + ".").getOrElse("")}javascript @ob
@for((controller, routes) <- groupRoutesByController(routes)) {
  @markLines(routes: _*)
  class Reverse@(controller.replace(".", "_"))(_prefix: => String) @ob

    def _defaultPrefix: String = @ob
      if (_prefix.endsWith("/")) "" else "/"
    @cb

  @for(((method, _), routes) <- groupRoutesByMethod(routes)) {@routes match {
  case Seq(route: Route) => {
    @markLines(route)
    def @method: JavaScriptReverseRoute = JavaScriptReverseRoute(
      "@{packageName.map(_ + ".").getOrElse("")}@(controller).@(method)",
      @tq
        function(@reverseParametersJavascript(routes).map(_._1.name).mkString(",")) @ob
          @javascriptCall(route, reverseLocalNames(route, reverseParametersJavascript(routes)))
        @cb
      @tq
    )
  }
  case _ => {
    @markLines(routes: _*)
    def @method: JavaScriptReverseRoute = JavaScriptReverseRoute(
      "@{packageName.map(_ + ".").getOrElse("")}@(controller).@(method)",
      @tq
        function(@reverseParametersJavascript(routes).map(_._1.name).mkString(",")) @ob
        @for((route, localNames, constraints) <- javascriptCollectNonDeadRoutes(routes)) {
          if (@constraints) @ob
            @javascriptCall(route, localNames)
          @cb
        }
        @cb
      @tq
    )
  }}}
  @cb
}

@cb
