#pragma once

#include <AK/String.h>
#include <AK/Utf16String.h>
#include <LibJS/Forward.h>
#include <LibJS/Runtime/NativeFunction.h>
#include <LibJS/Runtime/Object.h>
#include <LibJS/Runtime/Value.h>
#include <LibWeb/Bindings/InterfaceObject.h>

namespace Web::Bindings {

struct BlobConstructor {
public:
    static void initialize(JS::Realm&, JS::NativeFunction&);
    static JS::ThrowCompletionOr<GC::Ref<JS::Object>> construct(InterfaceConstructor&, JS::FunctionObject&);

private:
};

struct BlobPrototype {
public:
    static void initialize(JS::Realm&, JS::Object&);
    static void define_unforgeable_attributes(JS::Realm&, JS::Object&);

private:
    JS_DECLARE_NATIVE_FUNCTION(size_getter);
    JS_DECLARE_NATIVE_FUNCTION(type_getter);
    JS_DECLARE_NATIVE_FUNCTION(slice);
    JS_DECLARE_NATIVE_FUNCTION(stream);
    JS_DECLARE_NATIVE_FUNCTION(text);
    JS_DECLARE_NATIVE_FUNCTION(array_buffer);
    JS_DECLARE_NATIVE_FUNCTION(bytes);
};

enum class EndingType : u8 {
    Transparent,
    Native,
};

JS::ThrowCompletionOr<EndingType> convert_to_idl_value_for_ending_type(JS::VM&, JS::Value);

Utf16String idl_enum_to_string(EndingType);

struct BlobPropertyBag {
    EndingType endings { EndingType::Transparent };
    String type { String {} };
};

JS::ThrowCompletionOr<BlobPropertyBag> convert_to_idl_value_for_blob_property_bag(JS::VM&, JS::Value);

} // namespace Web::Bindings
