#pragma once

#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/EventModifier.h>
#include <LibWeb/Bindings/InterfaceObject.h>
#include <LibWeb/Forward.h>
#include <LibWeb/WebIDL/Types.h>

namespace Web::Bindings {

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

private:
};

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

private:
    JS_DECLARE_NATIVE_FUNCTION(screen_x_getter);
    JS_DECLARE_NATIVE_FUNCTION(screen_y_getter);
    JS_DECLARE_NATIVE_FUNCTION(page_x_getter);
    JS_DECLARE_NATIVE_FUNCTION(page_y_getter);
    JS_DECLARE_NATIVE_FUNCTION(client_x_getter);
    JS_DECLARE_NATIVE_FUNCTION(client_y_getter);
    JS_DECLARE_NATIVE_FUNCTION(x_getter);
    JS_DECLARE_NATIVE_FUNCTION(y_getter);
    JS_DECLARE_NATIVE_FUNCTION(offset_x_getter);
    JS_DECLARE_NATIVE_FUNCTION(offset_y_getter);
    JS_DECLARE_NATIVE_FUNCTION(ctrl_key_getter);
    JS_DECLARE_NATIVE_FUNCTION(shift_key_getter);
    JS_DECLARE_NATIVE_FUNCTION(alt_key_getter);
    JS_DECLARE_NATIVE_FUNCTION(meta_key_getter);
    JS_DECLARE_NATIVE_FUNCTION(movement_x_getter);
    JS_DECLARE_NATIVE_FUNCTION(movement_y_getter);
    JS_DECLARE_NATIVE_FUNCTION(button_getter);
    JS_DECLARE_NATIVE_FUNCTION(buttons_getter);
    JS_DECLARE_NATIVE_FUNCTION(related_target_getter);
    JS_DECLARE_NATIVE_FUNCTION(get_modifier_state);
    JS_DECLARE_NATIVE_FUNCTION(init_mouse_event);
};

struct MouseEventInit : public EventModifierInit {
    WebIDL::Short button { 0 };
    WebIDL::UnsignedShort buttons { 0 };
    double client_x { 0 };
    double client_y { 0 };
    double movement_x { 0 };
    double movement_y { 0 };
    GC::Ptr<DOM::EventTarget> related_target { nullptr };
    double screen_x { 0 };
    double screen_y { 0 };
};

JS::ThrowCompletionOr<MouseEventInit> convert_to_idl_value_for_mouse_event_init(JS::VM&, JS::Value);

} // namespace Web::Bindings
