use super::*;

pub(super) const DATES_ROWS: &[NativeModSig] = &[
    // ========== dayjs ==========
    // Factory: `import dayjs from 'dayjs'; dayjs()` → method:"default".
    // Named import: `import { dayjs } from 'dayjs'; dayjs()` → method:"dayjs".
    // Instance methods: handle is a small i64 stored in f64 bits; unbox_to_i64
    // does bitcast+mask which is identity for small values, so has_receiver:true works.
    // dayjs handle args (isBefore/isAfter/diff) use NA_JSV (bitcast, no mask).
    // Note: moment instance methods use f64 handle ABI so cannot use this path.
    NativeModSig {
        module: "dayjs",
        has_receiver: false,
        method: "default",
        class_filter: None,
        runtime: "js_dayjs_now",
        args: &[],
        ret: NR_F64,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: false,
        method: "dayjs",
        class_filter: None,
        runtime: "js_dayjs_now",
        args: &[],
        ret: NR_F64,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "format",
        class_filter: None,
        runtime: "js_dayjs_format",
        args: &[NA_STR],
        ret: NR_STR,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "year",
        class_filter: None,
        runtime: "js_dayjs_year",
        args: &[],
        ret: NR_F64,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "month",
        class_filter: None,
        runtime: "js_dayjs_month",
        args: &[],
        ret: NR_F64,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "date",
        class_filter: None,
        runtime: "js_dayjs_date",
        args: &[],
        ret: NR_F64,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "day",
        class_filter: None,
        runtime: "js_dayjs_day",
        args: &[],
        ret: NR_F64,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "hour",
        class_filter: None,
        runtime: "js_dayjs_hour",
        args: &[],
        ret: NR_F64,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "minute",
        class_filter: None,
        runtime: "js_dayjs_minute",
        args: &[],
        ret: NR_F64,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "second",
        class_filter: None,
        runtime: "js_dayjs_second",
        args: &[],
        ret: NR_F64,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "millisecond",
        class_filter: None,
        runtime: "js_dayjs_millisecond",
        args: &[],
        ret: NR_F64,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "valueOf",
        class_filter: None,
        runtime: "js_dayjs_value_of",
        args: &[],
        ret: NR_F64,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "unix",
        class_filter: None,
        runtime: "js_dayjs_unix",
        args: &[],
        ret: NR_F64,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "toISOString",
        class_filter: None,
        runtime: "js_dayjs_to_iso_string",
        args: &[],
        ret: NR_STR,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "add",
        class_filter: None,
        runtime: "js_dayjs_add",
        args: &[NA_F64, NA_STR],
        ret: NR_F64,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "subtract",
        class_filter: None,
        runtime: "js_dayjs_subtract",
        args: &[NA_F64, NA_STR],
        ret: NR_F64,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "startOf",
        class_filter: None,
        runtime: "js_dayjs_start_of",
        args: &[NA_STR],
        ret: NR_F64,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "endOf",
        class_filter: None,
        runtime: "js_dayjs_end_of",
        args: &[NA_STR],
        ret: NR_F64,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "isBefore",
        class_filter: None,
        runtime: "js_dayjs_is_before",
        args: &[NA_JSV],
        ret: NR_F64,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "isAfter",
        class_filter: None,
        runtime: "js_dayjs_is_after",
        args: &[NA_JSV],
        ret: NR_F64,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "isSame",
        class_filter: None,
        runtime: "js_dayjs_is_same",
        args: &[NA_JSV],
        ret: NR_F64,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "isValid",
        class_filter: None,
        runtime: "js_dayjs_is_valid",
        args: &[],
        ret: NR_F64,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "diff",
        class_filter: None,
        runtime: "js_dayjs_diff",
        args: &[NA_JSV, NA_STR],
        ret: NR_F64,
    },
    NativeModSig {
        module: "dayjs",
        has_receiver: true,
        method: "clone",
        class_filter: None,
        runtime: "js_dayjs_value_of",
        args: &[],
        ret: NR_F64,
    },
    // ========== date-fns ==========
    // date-fns exports free functions: `format(date, pattern)`,
    // `addDays(date, n)`, etc. The first argument is a Date (NaN-boxed
    // f64 timestamp from `new Date(...)`). The manifest entries surface
    // these as receiver-less NativeMethodCalls on module "date-fns".
    // Without these rows the dispatch returns None and the call falls
    // through to undefined. Refs date-fns format() blocker.
    NativeModSig {
        module: "date-fns",
        has_receiver: false,
        method: "format",
        class_filter: None,
        runtime: "js_datefns_format",
        args: &[NA_F64, NA_STR],
        ret: NR_STR,
    },
    NativeModSig {
        module: "date-fns",
        has_receiver: false,
        method: "parseISO",
        class_filter: None,
        runtime: "js_datefns_parse_iso",
        args: &[NA_STR],
        ret: NR_F64,
    },
    NativeModSig {
        module: "date-fns",
        has_receiver: false,
        method: "addDays",
        class_filter: None,
        runtime: "js_datefns_add_days",
        args: &[NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "date-fns",
        has_receiver: false,
        method: "addMonths",
        class_filter: None,
        runtime: "js_datefns_add_months",
        args: &[NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "date-fns",
        has_receiver: false,
        method: "addYears",
        class_filter: None,
        runtime: "js_datefns_add_years",
        args: &[NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "date-fns",
        has_receiver: false,
        method: "differenceInDays",
        class_filter: None,
        runtime: "js_datefns_difference_in_days",
        args: &[NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "date-fns",
        has_receiver: false,
        method: "differenceInHours",
        class_filter: None,
        runtime: "js_datefns_difference_in_hours",
        args: &[NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "date-fns",
        has_receiver: false,
        method: "differenceInMinutes",
        class_filter: None,
        runtime: "js_datefns_difference_in_minutes",
        args: &[NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "date-fns",
        has_receiver: false,
        method: "isAfter",
        class_filter: None,
        runtime: "js_datefns_is_after",
        args: &[NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "date-fns",
        has_receiver: false,
        method: "isBefore",
        class_filter: None,
        runtime: "js_datefns_is_before",
        args: &[NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "date-fns",
        has_receiver: false,
        method: "startOfDay",
        class_filter: None,
        runtime: "js_datefns_start_of_day",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "date-fns",
        has_receiver: false,
        method: "endOfDay",
        class_filter: None,
        runtime: "js_datefns_end_of_day",
        args: &[NA_F64],
        ret: NR_F64,
    },
    // ========== moment ==========
    // Only factory wired: moment instance methods take f64 handle (not i64),
    // incompatible with the has_receiver:true i64-first-arg dispatch ABI.
    NativeModSig {
        module: "moment",
        has_receiver: false,
        method: "default",
        class_filter: None,
        runtime: "js_moment_now",
        args: &[],
        ret: NR_F64,
    },
    NativeModSig {
        module: "moment",
        has_receiver: false,
        method: "moment",
        class_filter: None,
        runtime: "js_moment_now",
        args: &[],
        ret: NR_F64,
    },
];
