#pragma once

#include <AK/Optional.h>
#include <AK/String.h>
#include <AK/Vector.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>
#include <LibWeb/WebIDL/Types.h>

namespace Web::Bindings {

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

private:
    JS_DECLARE_NATIVE_FUNCTION(supported_entry_types_getter);
};

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

private:
    JS_DECLARE_NATIVE_FUNCTION(observe);
    JS_DECLARE_NATIVE_FUNCTION(disconnect);
    JS_DECLARE_NATIVE_FUNCTION(take_records);
};

struct PerformanceObserverCallbackOptions {
    Optional<WebIDL::UnsignedLongLong> dropped_entries_count {};
};

JS::ThrowCompletionOr<PerformanceObserverCallbackOptions> convert_to_idl_value_for_performance_observer_callback_options(JS::VM&, JS::Value);

struct PerformanceObserverInit {
    Optional<bool> buffered {};
    Optional<Vector<String>> entry_types {};
    Optional<String> type {};
};

JS::ThrowCompletionOr<PerformanceObserverInit> convert_to_idl_value_for_performance_observer_init(JS::VM&, JS::Value);

} // namespace Web::Bindings
