#pragma once

#include <LibGC/RootVector.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 MessagePortConstructor {
public:
    static void initialize(JS::Realm&, JS::NativeFunction&);
    static JS::ThrowCompletionOr<GC::Ref<JS::Object>> construct(InterfaceConstructor&, JS::FunctionObject&);

private:
};

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

private:
    JS_DECLARE_NATIVE_FUNCTION(onmessage_getter);
    JS_DECLARE_NATIVE_FUNCTION(onmessage_setter);
    JS_DECLARE_NATIVE_FUNCTION(onmessageerror_getter);
    JS_DECLARE_NATIVE_FUNCTION(onmessageerror_setter);
    JS_DECLARE_NATIVE_FUNCTION(post_message);
    JS_DECLARE_NATIVE_FUNCTION(post_message0);
    JS_DECLARE_NATIVE_FUNCTION(post_message1);
    JS_DECLARE_NATIVE_FUNCTION(start);
    JS_DECLARE_NATIVE_FUNCTION(close);
};

struct StructuredSerializeOptions {
    GC::RootVector<GC::Ref<JS::Object>> transfer { GC::RootVector<GC::Ref<JS::Object>> {} };
};

JS::ThrowCompletionOr<StructuredSerializeOptions> convert_to_idl_value_for_structured_serialize_options(JS::VM&, JS::Value);

} // namespace Web::Bindings
