//! Node: `cxx:Function:Luau.Analysis:Analysis/src/TypePack.cpp:308:size`
//! Source: `Analysis/src/TypePack.cpp:308-315` (hand-ported)

use crate::functions::follow_type_pack::follow_type_pack_id;
use crate::records::txn_log::TxnLog;
use crate::records::type_pack::TypePack;
use crate::type_aliases::type_pack_id::TypePackId;
use crate::type_aliases::type_pack_variant::TypePackVariantMember;

/// C++ `size_t size(TypePackId tp, TxnLog* log = nullptr)`.
pub fn size(tp: TypePackId, log: *mut TxnLog) -> usize {
    unsafe {
        let tp = if !log.is_null() {
            (*log).follow_type_pack_id(tp)
        } else {
            follow_type_pack_id(tp)
        };
        if let Some(pack) = TypePack::get_if(&(*tp).ty) {
            crate::functions::size_type_pack_alt_b::size(pack, log)
        } else {
            0
        }
    }
}
