#pragma once

#include <AK/Optional.h>
#include <LibGC/Ptr.h>
#include <LibJS/Forward.h>
#include <LibJS/Runtime/NativeFunction.h>
#include <LibJS/Runtime/Object.h>
#include <LibJS/Runtime/Value.h>
#include <LibWeb/Bindings/EventTarget.h>
#include <LibWeb/Bindings/InterfaceObject.h>
#include <LibWeb/Forward.h>

namespace Web::Bindings {

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

private:
};

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

private:
    JS_DECLARE_NATIVE_FUNCTION(add_event_listener);
    JS_DECLARE_NATIVE_FUNCTION(remove_event_listener);
    JS_DECLARE_NATIVE_FUNCTION(dispatch_event);
};

struct EventListenerOptions {
    bool capture { false };
};

JS::ThrowCompletionOr<EventListenerOptions> convert_to_idl_value_for_event_listener_options(JS::VM&, JS::Value);

struct AddEventListenerOptions : public EventListenerOptions {
    bool once { false };
    Optional<bool> passive {};
    GC::Ptr<DOM::AbortSignal> signal {};
};

JS::ThrowCompletionOr<AddEventListenerOptions> convert_to_idl_value_for_add_event_listener_options(JS::VM&, JS::Value);

} // namespace Web::Bindings
