use super::super::{FunctionMeta, Registry};

pub mod abs;
pub mod average;
pub mod averageif;
pub mod ceiling_floor;
pub mod countif;
pub mod criterion;
pub mod exp;
pub mod fact;
pub mod int_fn;
pub mod log;
pub mod mod_fn;
pub mod power;
pub mod product;
pub mod quotient;
pub mod rand;
pub mod round;
pub mod sign;
pub mod sqrt;
pub mod sum;
pub mod sumif;
pub mod trig;

pub fn register_math(registry: &mut Registry) {
    registry.register_eager("SUM",        sum::sum_fn,                  FunctionMeta { category: "math",        signature: "SUM(value1,...)",                       description: "Sum of arguments" });
    registry.register_eager("AVERAGE",    average::average_fn,          FunctionMeta { category: "statistical", signature: "AVERAGE(value1,...)",                   description: "Arithmetic mean of arguments" });
    registry.register_eager("PRODUCT",    product::product_fn,          FunctionMeta { category: "math",        signature: "PRODUCT(value1,...)",                   description: "Product of arguments" });
    registry.register_eager("ROUND",      round::round_fn,              FunctionMeta { category: "math",        signature: "ROUND(number, digits)",                 description: "Round to specified decimal places" });
    registry.register_eager("ROUNDUP",    round::roundup_fn,            FunctionMeta { category: "math",        signature: "ROUNDUP(number, digits)",               description: "Round away from zero" });
    registry.register_eager("ROUNDDOWN",  round::rounddown_fn,          FunctionMeta { category: "math",        signature: "ROUNDDOWN(number, digits)",             description: "Round toward zero" });
    registry.register_eager("INT",        int_fn::int_fn,               FunctionMeta { category: "math",        signature: "INT(number)",                           description: "Round down to nearest integer" });
    registry.register_eager("ABS",        abs::abs_fn,                  FunctionMeta { category: "math",        signature: "ABS(number)",                           description: "Absolute value of a number" });
    registry.register_eager("SIGN",       sign::sign_fn,                FunctionMeta { category: "math",        signature: "SIGN(number)",                          description: "Sign of a number: -1, 0, or 1" });
    registry.register_eager("MOD",        mod_fn::mod_fn,               FunctionMeta { category: "math",        signature: "MOD(number, divisor)",                  description: "Remainder after division" });
    registry.register_eager("POWER",      power::power_fn,              FunctionMeta { category: "math",        signature: "POWER(number, power)",                  description: "Number raised to a power" });
    registry.register_eager("SQRT",       sqrt::sqrt_fn,                FunctionMeta { category: "math",        signature: "SQRT(number)",                          description: "Square root" });
    registry.register_eager("LOG",        log::log_fn,                  FunctionMeta { category: "math",        signature: "LOG(number, base)",                     description: "Logarithm to specified base" });
    registry.register_eager("LOG10",      log::log10_fn,                FunctionMeta { category: "math",        signature: "LOG10(number)",                         description: "Base-10 logarithm" });
    registry.register_eager("LN",         log::ln_fn,                   FunctionMeta { category: "math",        signature: "LN(number)",                            description: "Natural logarithm" });
    registry.register_eager("EXP",        exp::exp_fn,                  FunctionMeta { category: "math",        signature: "EXP(number)",                           description: "e raised to a power" });
    registry.register_eager("CEILING",    ceiling_floor::ceiling_fn,    FunctionMeta { category: "math",        signature: "CEILING(number, significance)",          description: "Round up to nearest multiple of significance" });
    registry.register_eager("FLOOR",      ceiling_floor::floor_fn,      FunctionMeta { category: "math",        signature: "FLOOR(number, significance)",            description: "Round down to nearest multiple of significance" });
    registry.register_eager("RAND",       rand::rand_fn,                FunctionMeta { category: "math",        signature: "RAND()",                                description: "Random number between 0 and 1" });
    registry.register_eager("RANDBETWEEN",rand::randbetween_fn,         FunctionMeta { category: "math",        signature: "RANDBETWEEN(low, high)",                description: "Random integer between two values" });
    registry.register_eager("PI",         trig::pi_fn,                  FunctionMeta { category: "math",        signature: "PI()",                                  description: "The value of pi (3.14159...)" });
    registry.register_eager("SIN",        trig::sin_fn,                 FunctionMeta { category: "math",        signature: "SIN(angle)",                            description: "Sine of an angle in radians" });
    registry.register_eager("COS",        trig::cos_fn,                 FunctionMeta { category: "math",        signature: "COS(angle)",                            description: "Cosine of an angle in radians" });
    registry.register_eager("TAN",        trig::tan_fn,                 FunctionMeta { category: "math",        signature: "TAN(angle)",                            description: "Tangent of an angle in radians" });
    registry.register_eager("ACOS",       trig::acos_fn,                FunctionMeta { category: "math",        signature: "ACOS(number)",                          description: "Arccosine in radians" });
    registry.register_eager("ASIN",       trig::asin_fn,                FunctionMeta { category: "math",        signature: "ASIN(number)",                          description: "Arcsine in radians" });
    registry.register_eager("ATAN",       trig::atan_fn,                FunctionMeta { category: "math",        signature: "ATAN(number)",                          description: "Arctangent in radians" });
    registry.register_eager("ATAN2",      trig::atan2_fn,               FunctionMeta { category: "math",        signature: "ATAN2(x, y)",                           description: "Arctangent of y/x in radians" });
    registry.register_eager("DEGREES",    trig::degrees_fn,             FunctionMeta { category: "math",        signature: "DEGREES(angle)",                        description: "Convert radians to degrees" });
    registry.register_eager("RADIANS",    trig::radians_fn,             FunctionMeta { category: "math",        signature: "RADIANS(angle)",                        description: "Convert degrees to radians" });
    registry.register_eager("SINH",       trig::sinh_fn,                FunctionMeta { category: "math",        signature: "SINH(number)",                          description: "Hyperbolic sine" });
    registry.register_eager("COSH",       trig::cosh_fn,                FunctionMeta { category: "math",        signature: "COSH(number)",                          description: "Hyperbolic cosine" });
    registry.register_eager("TANH",       trig::tanh_fn,                FunctionMeta { category: "math",        signature: "TANH(number)",                          description: "Hyperbolic tangent" });
    registry.register_eager("ACOSH",      trig::acosh_fn,               FunctionMeta { category: "math",        signature: "ACOSH(number)",                         description: "Inverse hyperbolic cosine" });
    registry.register_eager("ASINH",      trig::asinh_fn,               FunctionMeta { category: "math",        signature: "ASINH(number)",                         description: "Inverse hyperbolic sine" });
    registry.register_eager("ATANH",      trig::atanh_fn,               FunctionMeta { category: "math",        signature: "ATANH(number)",                         description: "Inverse hyperbolic tangent" });
    registry.register_eager("COT",        trig::cot_fn,                 FunctionMeta { category: "math",        signature: "COT(angle)",                            description: "Cotangent of an angle in radians" });
    registry.register_eager("COTH",       trig::coth_fn,                FunctionMeta { category: "math",        signature: "COTH(number)",                          description: "Hyperbolic cotangent" });
    registry.register_eager("CSC",        trig::csc_fn,                 FunctionMeta { category: "math",        signature: "CSC(angle)",                            description: "Cosecant of an angle in radians" });
    registry.register_eager("CSCH",       trig::csch_fn,                FunctionMeta { category: "math",        signature: "CSCH(number)",                          description: "Hyperbolic cosecant" });
    registry.register_eager("SEC",        trig::sec_fn,                 FunctionMeta { category: "math",        signature: "SEC(angle)",                            description: "Secant of an angle in radians" });
    registry.register_eager("SECH",       trig::sech_fn,                FunctionMeta { category: "math",        signature: "SECH(number)",                          description: "Hyperbolic secant" });
    registry.register_eager("ACOT",       trig::acot_fn,                FunctionMeta { category: "math",        signature: "ACOT(number)",                          description: "Inverse cotangent in radians" });
    registry.register_eager("ACOTH",      trig::acoth_fn,               FunctionMeta { category: "math",        signature: "ACOTH(number)",                         description: "Inverse hyperbolic cotangent" });
    registry.register_eager("QUOTIENT",   quotient::quotient_fn,        FunctionMeta { category: "math",        signature: "QUOTIENT(numerator, denominator)",       description: "Integer portion of division" });
    registry.register_eager("EVEN",       round::even_fn,               FunctionMeta { category: "math",        signature: "EVEN(number)",                          description: "Round up to nearest even integer" });
    registry.register_eager("ODD",        round::odd_fn,                FunctionMeta { category: "math",        signature: "ODD(number)",                           description: "Round up to nearest odd integer" });
    registry.register_eager("FACT",       fact::fact_fn,                FunctionMeta { category: "math",        signature: "FACT(number)",                          description: "Factorial of a number" });
    registry.register_eager("MROUND",     round::mround_fn,             FunctionMeta { category: "math",        signature: "MROUND(number, multiple)",               description: "Round to nearest multiple" });
    registry.register_eager("TRUNC",      round::trunc_fn,              FunctionMeta { category: "math",        signature: "TRUNC(number, digits)",                 description: "Truncate to integer or decimal places" });
    registry.register_eager("COUNTIF",    countif::countif_fn,          FunctionMeta { category: "math",        signature: "COUNTIF(range, criterion)",              description: "Count cells matching criterion" });
    registry.register_eager("SUMIF",      sumif::sumif_fn,              FunctionMeta { category: "math",        signature: "SUMIF(range, criterion, [sum_range])",   description: "Sum cells where range matches criterion" });
    registry.register_eager("AVERAGEIF",  averageif::averageif_fn,      FunctionMeta { category: "statistical", signature: "AVERAGEIF(range, criterion, [avg_range])", description: "Average cells where range matches criterion" });
}
