use super::*;

pub(super) const NODE_CORE_ROWS: &[NativeModSig] = &[
    // ========== Node TTY ==========
    NativeModSig {
        module: "tty",
        has_receiver: false,
        method: "isatty",
        class_filter: None,
        runtime: "js_tty_isatty",
        args: &[NA_F64],
        ret: NR_F64,
    },
    // ========== Node URL ==========
    // `new Number/String/Boolean(...)` now lowers to
    // `Expr::BoxedPrimitiveNew` (see crates/perry-hir/src/lower/expr_new.rs)
    // and is emitted by codegen as a direct runtime call — no dispatch
    // table row needed.
    NativeModSig {
        module: "url",
        has_receiver: false,
        method: "fileURLToPath",
        class_filter: None,
        runtime: "js_url_file_url_to_path",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "url",
        has_receiver: false,
        method: "pathToFileURL",
        class_filter: None,
        runtime: "js_url_path_to_file_url",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "url",
        has_receiver: false,
        method: "domainToASCII",
        class_filter: None,
        runtime: "js_url_domain_to_ascii",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "url",
        has_receiver: false,
        method: "domainToUnicode",
        class_filter: None,
        runtime: "js_url_domain_to_unicode",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "url",
        has_receiver: false,
        method: "urlToHttpOptions",
        class_filter: None,
        runtime: "js_url_to_http_options",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "url",
        has_receiver: false,
        method: "format",
        class_filter: None,
        runtime: "js_url_format",
        args: &[NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "url",
        has_receiver: false,
        method: "parse",
        class_filter: None,
        runtime: "js_url_legacy_parse",
        args: &[NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "url",
        has_receiver: false,
        method: "resolve",
        class_filter: None,
        runtime: "js_url_legacy_resolve",
        args: &[NA_F64, NA_F64],
        ret: NR_F64,
    },
    // ========== Node console ==========
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "log",
        class_filter: None,
        runtime: "js_console_log_spread",
        args: &[NA_VARARGS],
        ret: NR_VOID,
    },
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "info",
        class_filter: None,
        runtime: "js_console_info_spread",
        args: &[NA_VARARGS],
        ret: NR_VOID,
    },
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "debug",
        class_filter: None,
        runtime: "js_console_debug_spread",
        args: &[NA_VARARGS],
        ret: NR_VOID,
    },
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "dirxml",
        class_filter: None,
        runtime: "js_console_log_spread",
        args: &[NA_VARARGS],
        ret: NR_VOID,
    },
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "error",
        class_filter: None,
        runtime: "js_console_error_spread",
        args: &[NA_VARARGS],
        ret: NR_VOID,
    },
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "warn",
        class_filter: None,
        runtime: "js_console_warn_spread",
        args: &[NA_VARARGS],
        ret: NR_VOID,
    },
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "assert",
        class_filter: None,
        runtime: "js_console_assert_spread",
        args: &[NA_F64, NA_VARARGS],
        ret: NR_VOID,
    },
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "dir",
        class_filter: None,
        runtime: "js_console_log_dynamic",
        args: &[NA_F64],
        ret: NR_VOID,
    },
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "trace",
        class_filter: None,
        runtime: "js_console_trace",
        args: &[NA_F64],
        ret: NR_VOID,
    },
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "table",
        class_filter: None,
        runtime: "js_console_table",
        args: &[NA_F64],
        ret: NR_VOID,
    },
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "clear",
        class_filter: None,
        runtime: "js_console_clear",
        args: &[],
        ret: NR_VOID,
    },
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "count",
        class_filter: None,
        runtime: "js_console_count",
        args: &[NA_STR],
        ret: NR_VOID,
    },
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "countReset",
        class_filter: None,
        runtime: "js_console_count_reset",
        args: &[NA_STR],
        ret: NR_VOID,
    },
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "time",
        class_filter: None,
        runtime: "js_console_time",
        args: &[NA_STR],
        ret: NR_VOID,
    },
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "timeEnd",
        class_filter: None,
        runtime: "js_console_time_end",
        args: &[NA_STR],
        ret: NR_VOID,
    },
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "timeLog",
        class_filter: None,
        runtime: "js_console_time_log",
        args: &[NA_STR],
        ret: NR_VOID,
    },
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "groupEnd",
        class_filter: None,
        runtime: "js_console_group_end",
        args: &[],
        ret: NR_VOID,
    },
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "group",
        class_filter: None,
        runtime: "js_console_group_begin",
        args: &[],
        ret: NR_VOID,
    },
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "groupCollapsed",
        class_filter: None,
        runtime: "js_console_group_begin",
        args: &[],
        ret: NR_VOID,
    },
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "profile",
        class_filter: None,
        runtime: "js_console_noop",
        args: &[],
        ret: NR_VOID,
    },
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "profileEnd",
        class_filter: None,
        runtime: "js_console_noop",
        args: &[],
        ret: NR_VOID,
    },
    NativeModSig {
        module: "console",
        has_receiver: false,
        method: "timeStamp",
        class_filter: None,
        runtime: "js_console_noop",
        args: &[],
        ret: NR_VOID,
    },
    // ========== Node assert ==========
    // Root-callable `assert(value, message?)` — HIR lowers
    // `import assert from "node:assert"; assert(x, m)` to a
    // `NativeMethodCall { module: "assert", method: "default" }`.
    // Route it to `js_assert_ok` (Node's default export aliases
    // `assert.ok`). Same for `node:assert/strict`.
    NativeModSig {
        module: "assert",
        has_receiver: false,
        method: "default",
        class_filter: None,
        runtime: "js_assert_ok",
        args: &[NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert/strict",
        has_receiver: false,
        method: "default",
        class_filter: None,
        runtime: "js_assert_ok",
        args: &[NA_F64, NA_F64],
        ret: NR_F64,
    },
    // `assert.strict(value, msg?)` — the `.strict` namespace itself is
    // callable and behaves like `assert.strict.ok`.
    NativeModSig {
        module: "assert",
        has_receiver: false,
        method: "strict",
        class_filter: None,
        runtime: "js_assert_ok",
        args: &[NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert",
        has_receiver: false,
        method: "ok",
        class_filter: None,
        runtime: "js_assert_ok",
        args: &[NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert",
        has_receiver: false,
        method: "fail",
        class_filter: None,
        runtime: "js_assert_fail",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert",
        has_receiver: false,
        method: "equal",
        class_filter: None,
        runtime: "js_assert_equal",
        args: &[NA_F64, NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert",
        has_receiver: false,
        method: "notEqual",
        class_filter: None,
        runtime: "js_assert_not_equal",
        args: &[NA_F64, NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert",
        has_receiver: false,
        method: "strictEqual",
        class_filter: None,
        runtime: "js_assert_strict_equal",
        args: &[NA_F64, NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert",
        has_receiver: false,
        method: "notStrictEqual",
        class_filter: None,
        runtime: "js_assert_not_strict_equal",
        args: &[NA_F64, NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert",
        has_receiver: false,
        method: "deepEqual",
        class_filter: None,
        runtime: "js_assert_deep_equal",
        args: &[NA_F64, NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert",
        has_receiver: false,
        method: "notDeepEqual",
        class_filter: None,
        runtime: "js_assert_not_deep_equal",
        args: &[NA_F64, NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert",
        has_receiver: false,
        method: "deepStrictEqual",
        class_filter: None,
        runtime: "js_assert_deep_strict_equal",
        args: &[NA_F64, NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert",
        has_receiver: false,
        method: "notDeepStrictEqual",
        class_filter: None,
        runtime: "js_assert_not_deep_strict_equal",
        args: &[NA_F64, NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert",
        has_receiver: false,
        method: "match",
        class_filter: None,
        runtime: "js_assert_match",
        args: &[NA_F64, NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert",
        has_receiver: false,
        method: "doesNotMatch",
        class_filter: None,
        runtime: "js_assert_does_not_match",
        args: &[NA_F64, NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert",
        has_receiver: false,
        method: "ifError",
        class_filter: None,
        runtime: "js_assert_if_error",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert/strict",
        has_receiver: false,
        method: "ok",
        class_filter: None,
        runtime: "js_assert_ok",
        args: &[NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert/strict",
        has_receiver: false,
        method: "fail",
        class_filter: None,
        runtime: "js_assert_fail",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert/strict",
        has_receiver: false,
        method: "equal",
        class_filter: None,
        runtime: "js_assert_strict_equal",
        args: &[NA_F64, NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert/strict",
        has_receiver: false,
        method: "notEqual",
        class_filter: None,
        runtime: "js_assert_not_strict_equal",
        args: &[NA_F64, NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert/strict",
        has_receiver: false,
        method: "deepEqual",
        class_filter: None,
        runtime: "js_assert_deep_strict_equal",
        args: &[NA_F64, NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert/strict",
        has_receiver: false,
        method: "notDeepEqual",
        class_filter: None,
        runtime: "js_assert_not_deep_strict_equal",
        args: &[NA_F64, NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert/strict",
        has_receiver: false,
        method: "strictEqual",
        class_filter: None,
        runtime: "js_assert_strict_equal",
        args: &[NA_F64, NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert/strict",
        has_receiver: false,
        method: "notStrictEqual",
        class_filter: None,
        runtime: "js_assert_not_strict_equal",
        args: &[NA_F64, NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert/strict",
        has_receiver: false,
        method: "deepStrictEqual",
        class_filter: None,
        runtime: "js_assert_deep_strict_equal",
        args: &[NA_F64, NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert/strict",
        has_receiver: false,
        method: "notDeepStrictEqual",
        class_filter: None,
        runtime: "js_assert_not_deep_strict_equal",
        args: &[NA_F64, NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert/strict",
        has_receiver: false,
        method: "match",
        class_filter: None,
        runtime: "js_assert_match",
        args: &[NA_F64, NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert/strict",
        has_receiver: false,
        method: "doesNotMatch",
        class_filter: None,
        runtime: "js_assert_does_not_match",
        args: &[NA_F64, NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "assert/strict",
        has_receiver: false,
        method: "ifError",
        class_filter: None,
        runtime: "js_assert_if_error",
        args: &[NA_F64],
        ret: NR_F64,
    },
    // ========== Node util ==========
    NativeModSig {
        module: "util",
        has_receiver: false,
        method: "inspect",
        class_filter: None,
        runtime: "js_util_inspect",
        args: &[NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "util",
        has_receiver: false,
        method: "isDeepStrictEqual",
        class_filter: None,
        runtime: "js_util_is_deep_strict_equal",
        args: &[NA_F64, NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "util",
        has_receiver: false,
        method: "stripVTControlCharacters",
        class_filter: None,
        runtime: "js_util_strip_vt_control_characters",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "util/types",
        has_receiver: false,
        method: "isPromise",
        class_filter: None,
        runtime: "js_util_types_is_promise",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "util/types",
        has_receiver: false,
        method: "isArrayBuffer",
        class_filter: None,
        runtime: "js_util_types_is_array_buffer",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "util/types",
        has_receiver: false,
        method: "isAnyArrayBuffer",
        class_filter: None,
        runtime: "js_util_types_is_array_buffer",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "util/types",
        has_receiver: false,
        method: "isArrayBufferView",
        class_filter: None,
        runtime: "js_util_types_is_array_buffer_view",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "util/types",
        has_receiver: false,
        method: "isTypedArray",
        class_filter: None,
        runtime: "js_util_types_is_typed_array",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "util/types",
        has_receiver: false,
        method: "isUint8Array",
        class_filter: None,
        runtime: "js_util_types_is_uint8_array",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "util/types",
        has_receiver: false,
        method: "isUint16Array",
        class_filter: None,
        runtime: "js_util_types_is_uint16_array",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "util/types",
        has_receiver: false,
        method: "isInt32Array",
        class_filter: None,
        runtime: "js_util_types_is_int32_array",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "util/types",
        has_receiver: false,
        method: "isFloat64Array",
        class_filter: None,
        runtime: "js_util_types_is_float64_array",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "util/types",
        has_receiver: false,
        method: "isMap",
        class_filter: None,
        runtime: "js_util_types_is_map",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "util/types",
        has_receiver: false,
        method: "isSet",
        class_filter: None,
        runtime: "js_util_types_is_set",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "util/types",
        has_receiver: false,
        method: "isDate",
        class_filter: None,
        runtime: "js_util_types_is_date",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "util/types",
        has_receiver: false,
        method: "isRegExp",
        class_filter: None,
        runtime: "js_util_types_is_reg_exp",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "util/types",
        has_receiver: false,
        method: "isNumberObject",
        class_filter: None,
        runtime: "js_util_types_is_number_object",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "util/types",
        has_receiver: false,
        method: "isStringObject",
        class_filter: None,
        runtime: "js_util_types_is_string_object",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "util/types",
        has_receiver: false,
        method: "isBooleanObject",
        class_filter: None,
        runtime: "js_util_types_is_boolean_object",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "util/types",
        has_receiver: false,
        method: "isBoxedPrimitive",
        class_filter: None,
        runtime: "js_util_types_is_boxed_primitive",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "buffer",
        has_receiver: false,
        method: "isAscii",
        class_filter: None,
        runtime: "js_buffer_is_ascii",
        args: &[NA_F64],
        ret: NR_F64,
    },
    NativeModSig {
        module: "buffer",
        has_receiver: false,
        method: "isUtf8",
        class_filter: None,
        runtime: "js_buffer_is_utf8",
        args: &[NA_F64],
        ret: NR_F64,
    },
    // Issue #1210: `buffer.transcode(source, fromEnc, toEnc)`.
    // Receiver-less Node-buffer export; arguments are NaN-boxed (source
    // is a Buffer pointer, encodings are strings). Returns a Buffer
    // pointer that must be NaN-boxed with POINTER_TAG by the dispatch
    // wrapper — `NR_PTR` handles that step.
    NativeModSig {
        module: "buffer",
        has_receiver: false,
        method: "transcode",
        class_filter: None,
        runtime: "js_buffer_transcode",
        args: &[NA_F64, NA_F64, NA_F64],
        ret: NR_PTR,
    },
    // Issue #1211: `import { resolveObjectURL } from "node:buffer"`.
    NativeModSig {
        module: "buffer",
        has_receiver: false,
        method: "resolveObjectURL",
        class_filter: None,
        runtime: "js_buffer_resolve_object_url",
        args: &[NA_F64],
        ret: NR_F64,
    },
    // Issue #1211: `URL.createObjectURL(blob)` /
    // `URL.revokeObjectURL(url)` — modelled as receiver-less
    // `("url", "createObjectURL"/"revokeObjectURL")` so the static
    // method dispatch in `expr_call/module_static.rs` picks them up.
    NativeModSig {
        module: "url",
        has_receiver: false,
        method: "createObjectURL",
        class_filter: None,
        runtime: "js_url_create_object_url",
        args: &[NA_F64],
        ret: NR_STR,
    },
    NativeModSig {
        module: "url",
        has_receiver: false,
        method: "revokeObjectURL",
        class_filter: None,
        runtime: "js_url_revoke_object_url",
        args: &[NA_F64],
        ret: NR_VOID,
    },
];
