// Code generated by `mise run codegen:captures`. DO NOT EDIT.

///|
/// A typed parameter type defined by the type itself. Implement it and one
/// of `FromGroups1` to `FromGroups8`, then register the type with
/// `define_type1` to `define_type8`.
pub(open) trait ParameterTypeDef {
  /// The name used in expressions, for example "color" for `{color}`.
  fn name() -> String
  /// The regexps that match the parameter.
  fn regexps() -> Array[RegexPattern]
  /// Default: `true`.
  fn use_for_snippets() -> Bool = _
  /// Default: `false`.
  fn prefer_for_regexp_match() -> Bool = _
}

///|
impl ParameterTypeDef with fn use_for_snippets() {
  true
}

///|
impl ParameterTypeDef with fn prefer_for_regexp_match() {
  false
}

///|
priv struct TypeDef {
  name : String
  regexps : Array[RegexPattern]
  use_for_snippets : Bool
  prefer_for_regexp_match : Bool
}

///|
/// Read the definition of `T`. The argument only selects `T`.
fn[T : ParameterTypeDef] type_def(_proxy : T?) -> TypeDef {
  {
    name: T::name(),
    regexps: T::regexps(),
    use_for_snippets: T::use_for_snippets(),
    prefer_for_regexp_match: T::prefer_for_regexp_match(),
  }
}

///|
/// Make a value from 1 capture group value.
pub(open) trait FromGroups1 {
  fn from_groups(String) -> Self raise
}

///|
fn[T : FromGroups1] from_groups1(g1 : String) -> T raise {
  T::from_groups(g1)
}

///|
/// Register the typed parameter type `T`, which takes 1 capture group
/// value. Select `T` with a type annotation, for example
/// `let color : ParameterType[Color] = registry.define_type1()`.
pub fn[T : ParameterTypeDef + FromGroups1] ParamTypeRegistry::define_type1(
  self : ParamTypeRegistry,
) -> ParameterType[T] raise ParameterTypeError {
  let def = type_def((None : T?))
  let captures : Captures1[T] = Captures::string().map(g1 => from_groups1(g1))
  self.define_with(
    def.name,
    def.regexps,
    captures,
    use_for_snippets=def.use_for_snippets,
    prefer_for_regexp_match=def.prefer_for_regexp_match,
  )
}

///|
/// Make a value from 2 capture group values.
pub(open) trait FromGroups2 {
  fn from_groups(String, String) -> Self raise
}

///|
fn[T : FromGroups2] from_groups2(g1 : String, g2 : String) -> T raise {
  T::from_groups(g1, g2)
}

///|
/// Register the typed parameter type `T`, which takes 2 capture group
/// values. Select `T` with a type annotation, for example
/// `let color : ParameterType[Color] = registry.define_type2()`.
pub fn[T : ParameterTypeDef + FromGroups2] ParamTypeRegistry::define_type2(
  self : ParamTypeRegistry,
) -> ParameterType[T] raise ParameterTypeError {
  let def = type_def((None : T?))
  let captures : Captures1[T] = Captures::string()
    .zip(Captures::string())
    .map((g1, g2) => from_groups2(g1, g2))
  self.define_with(
    def.name,
    def.regexps,
    captures,
    use_for_snippets=def.use_for_snippets,
    prefer_for_regexp_match=def.prefer_for_regexp_match,
  )
}

///|
/// Make a value from 3 capture group values.
pub(open) trait FromGroups3 {
  fn from_groups(String, String, String) -> Self raise
}

///|
fn[T : FromGroups3] from_groups3(
  g1 : String,
  g2 : String,
  g3 : String,
) -> T raise {
  T::from_groups(g1, g2, g3)
}

///|
/// Register the typed parameter type `T`, which takes 3 capture group
/// values. Select `T` with a type annotation, for example
/// `let color : ParameterType[Color] = registry.define_type3()`.
pub fn[T : ParameterTypeDef + FromGroups3] ParamTypeRegistry::define_type3(
  self : ParamTypeRegistry,
) -> ParameterType[T] raise ParameterTypeError {
  let def = type_def((None : T?))
  let captures : Captures1[T] = Captures::string()
    .zip(Captures::string())
    .zip(Captures::string())
    .map((g1, g2, g3) => from_groups3(g1, g2, g3))
  self.define_with(
    def.name,
    def.regexps,
    captures,
    use_for_snippets=def.use_for_snippets,
    prefer_for_regexp_match=def.prefer_for_regexp_match,
  )
}

///|
/// Make a value from 4 capture group values.
pub(open) trait FromGroups4 {
  fn from_groups(String, String, String, String) -> Self raise
}

///|
fn[T : FromGroups4] from_groups4(
  g1 : String,
  g2 : String,
  g3 : String,
  g4 : String,
) -> T raise {
  T::from_groups(g1, g2, g3, g4)
}

///|
/// Register the typed parameter type `T`, which takes 4 capture group
/// values. Select `T` with a type annotation, for example
/// `let color : ParameterType[Color] = registry.define_type4()`.
pub fn[T : ParameterTypeDef + FromGroups4] ParamTypeRegistry::define_type4(
  self : ParamTypeRegistry,
) -> ParameterType[T] raise ParameterTypeError {
  let def = type_def((None : T?))
  let captures : Captures1[T] = Captures::string()
    .zip(Captures::string())
    .zip(Captures::string())
    .zip(Captures::string())
    .map((g1, g2, g3, g4) => from_groups4(g1, g2, g3, g4))
  self.define_with(
    def.name,
    def.regexps,
    captures,
    use_for_snippets=def.use_for_snippets,
    prefer_for_regexp_match=def.prefer_for_regexp_match,
  )
}

///|
/// Make a value from 5 capture group values.
pub(open) trait FromGroups5 {
  fn from_groups(String, String, String, String, String) -> Self raise
}

///|
fn[T : FromGroups5] from_groups5(
  g1 : String,
  g2 : String,
  g3 : String,
  g4 : String,
  g5 : String,
) -> T raise {
  T::from_groups(g1, g2, g3, g4, g5)
}

///|
/// Register the typed parameter type `T`, which takes 5 capture group
/// values. Select `T` with a type annotation, for example
/// `let color : ParameterType[Color] = registry.define_type5()`.
pub fn[T : ParameterTypeDef + FromGroups5] ParamTypeRegistry::define_type5(
  self : ParamTypeRegistry,
) -> ParameterType[T] raise ParameterTypeError {
  let def = type_def((None : T?))
  let captures : Captures1[T] = Captures::string()
    .zip(Captures::string())
    .zip(Captures::string())
    .zip(Captures::string())
    .zip(Captures::string())
    .map((g1, g2, g3, g4, g5) => from_groups5(g1, g2, g3, g4, g5))
  self.define_with(
    def.name,
    def.regexps,
    captures,
    use_for_snippets=def.use_for_snippets,
    prefer_for_regexp_match=def.prefer_for_regexp_match,
  )
}

///|
/// Make a value from 6 capture group values.
pub(open) trait FromGroups6 {
  fn from_groups(String, String, String, String, String, String) -> Self raise
}

///|
fn[T : FromGroups6] from_groups6(
  g1 : String,
  g2 : String,
  g3 : String,
  g4 : String,
  g5 : String,
  g6 : String,
) -> T raise {
  T::from_groups(g1, g2, g3, g4, g5, g6)
}

///|
/// Register the typed parameter type `T`, which takes 6 capture group
/// values. Select `T` with a type annotation, for example
/// `let color : ParameterType[Color] = registry.define_type6()`.
pub fn[T : ParameterTypeDef + FromGroups6] ParamTypeRegistry::define_type6(
  self : ParamTypeRegistry,
) -> ParameterType[T] raise ParameterTypeError {
  let def = type_def((None : T?))
  let captures : Captures1[T] = Captures::string()
    .zip(Captures::string())
    .zip(Captures::string())
    .zip(Captures::string())
    .zip(Captures::string())
    .zip(Captures::string())
    .map((g1, g2, g3, g4, g5, g6) => from_groups6(g1, g2, g3, g4, g5, g6))
  self.define_with(
    def.name,
    def.regexps,
    captures,
    use_for_snippets=def.use_for_snippets,
    prefer_for_regexp_match=def.prefer_for_regexp_match,
  )
}

///|
/// Make a value from 7 capture group values.
pub(open) trait FromGroups7 {
  fn from_groups(String, String, String, String, String, String, String) -> Self raise
}

///|
fn[T : FromGroups7] from_groups7(
  g1 : String,
  g2 : String,
  g3 : String,
  g4 : String,
  g5 : String,
  g6 : String,
  g7 : String,
) -> T raise {
  T::from_groups(g1, g2, g3, g4, g5, g6, g7)
}

///|
/// Register the typed parameter type `T`, which takes 7 capture group
/// values. Select `T` with a type annotation, for example
/// `let color : ParameterType[Color] = registry.define_type7()`.
pub fn[T : ParameterTypeDef + FromGroups7] ParamTypeRegistry::define_type7(
  self : ParamTypeRegistry,
) -> ParameterType[T] raise ParameterTypeError {
  let def = type_def((None : T?))
  let captures : Captures1[T] = Captures::string()
    .zip(Captures::string())
    .zip(Captures::string())
    .zip(Captures::string())
    .zip(Captures::string())
    .zip(Captures::string())
    .zip(Captures::string())
    .map((g1, g2, g3, g4, g5, g6, g7) => {
      from_groups7(g1, g2, g3, g4, g5, g6, g7)
    })
  self.define_with(
    def.name,
    def.regexps,
    captures,
    use_for_snippets=def.use_for_snippets,
    prefer_for_regexp_match=def.prefer_for_regexp_match,
  )
}

///|
/// Make a value from 8 capture group values.
pub(open) trait FromGroups8 {
  fn from_groups(String, String, String, String, String, String, String, String) -> Self raise
}

///|
fn[T : FromGroups8] from_groups8(
  g1 : String,
  g2 : String,
  g3 : String,
  g4 : String,
  g5 : String,
  g6 : String,
  g7 : String,
  g8 : String,
) -> T raise {
  T::from_groups(g1, g2, g3, g4, g5, g6, g7, g8)
}

///|
/// Register the typed parameter type `T`, which takes 8 capture group
/// values. Select `T` with a type annotation, for example
/// `let color : ParameterType[Color] = registry.define_type8()`.
pub fn[T : ParameterTypeDef + FromGroups8] ParamTypeRegistry::define_type8(
  self : ParamTypeRegistry,
) -> ParameterType[T] raise ParameterTypeError {
  let def = type_def((None : T?))
  let captures : Captures1[T] = Captures::string()
    .zip(Captures::string())
    .zip(Captures::string())
    .zip(Captures::string())
    .zip(Captures::string())
    .zip(Captures::string())
    .zip(Captures::string())
    .zip(Captures::string())
    .map((g1, g2, g3, g4, g5, g6, g7, g8) => {
      from_groups8(g1, g2, g3, g4, g5, g6, g7, g8)
    })
  self.define_with(
    def.name,
    def.regexps,
    captures,
    use_for_snippets=def.use_for_snippets,
    prefer_for_regexp_match=def.prefer_for_regexp_match,
  )
}