#pragma once

#include <LibJS/Runtime/NativeFunction.h>
#include <LibJS/Runtime/Object.h>
#include <LibWeb/Bindings/InterfaceObject.h>

namespace Web::Bindings {

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

private:
};

class ServiceWorkerGlobalScopePrototype : public JS::Object {
    JS_OBJECT(ServiceWorkerGlobalScopePrototype, JS::Object);
    GC_DECLARE_ALLOCATOR(ServiceWorkerGlobalScopePrototype);

public:
    static void define_unforgeable_attributes(JS::Realm&, JS::Object&);

    explicit ServiceWorkerGlobalScopePrototype(JS::Realm&);
    virtual void initialize(JS::Realm&) override;
    virtual ~ServiceWorkerGlobalScopePrototype() override;
    virtual JS::ThrowCompletionOr<bool> internal_set_prototype_of(JS::Object*) override;

private:
    JS_DECLARE_NATIVE_FUNCTION(oninstall_getter);
    JS_DECLARE_NATIVE_FUNCTION(oninstall_setter);
    JS_DECLARE_NATIVE_FUNCTION(onactivate_getter);
    JS_DECLARE_NATIVE_FUNCTION(onactivate_setter);
    JS_DECLARE_NATIVE_FUNCTION(onfetch_getter);
    JS_DECLARE_NATIVE_FUNCTION(onfetch_setter);
    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(cookie_store_getter);
};

class ServiceWorkerGlobalScopeGlobalMixin {
public:
    void initialize(JS::Realm&, JS::Object&);
    void define_unforgeable_attributes(JS::Realm&, JS::Object&);
    ServiceWorkerGlobalScopeGlobalMixin();
    virtual ~ServiceWorkerGlobalScopeGlobalMixin();

private:
    JS_DECLARE_NATIVE_FUNCTION(oninstall_getter);
    JS_DECLARE_NATIVE_FUNCTION(oninstall_setter);
    JS_DECLARE_NATIVE_FUNCTION(onactivate_getter);
    JS_DECLARE_NATIVE_FUNCTION(onactivate_setter);
    JS_DECLARE_NATIVE_FUNCTION(onfetch_getter);
    JS_DECLARE_NATIVE_FUNCTION(onfetch_setter);
    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(cookie_store_getter);
};

} // namespace Web::Bindings
