#pragma once

#include <AK/Optional.h>
#include <AK/Utf16String.h>
#include <LibGC/Ptr.h>
#include <LibJS/Forward.h>
#include <LibJS/Runtime/Value.h>
#include <LibWeb/WebIDL/CallbackType.h>
#include <LibWeb/WebIDL/Types.h>

namespace Web::Bindings {

enum class ReadableStreamType : u8 {
    Bytes,
};

JS::ThrowCompletionOr<ReadableStreamType> convert_to_idl_value_for_readable_stream_type(JS::VM&, JS::Value);

Utf16String idl_enum_to_string(ReadableStreamType);

struct UnderlyingSource {
    Optional<WebIDL::UnsignedLongLong> auto_allocate_chunk_size {};
    GC::Ptr<WebIDL::CallbackType> cancel {};
    GC::Ptr<WebIDL::CallbackType> pull {};
    GC::Ptr<WebIDL::CallbackType> start {};
    Optional<ReadableStreamType> type {};
};

JS::ThrowCompletionOr<UnderlyingSource> convert_to_idl_value_for_underlying_source(JS::VM&, JS::Value);

} // namespace Web::Bindings
