#pragma once

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

private:
};

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

private:
    JS_DECLARE_NATIVE_FUNCTION(installing_getter);
    JS_DECLARE_NATIVE_FUNCTION(waiting_getter);
    JS_DECLARE_NATIVE_FUNCTION(active_getter);
    JS_DECLARE_NATIVE_FUNCTION(scope_getter);
    JS_DECLARE_NATIVE_FUNCTION(update_via_cache_getter);
};

enum class ServiceWorkerUpdateViaCache : u8 {
    Imports,
    All,
    None,
};

JS::ThrowCompletionOr<ServiceWorkerUpdateViaCache> convert_to_idl_value_for_service_worker_update_via_cache(JS::VM&, JS::Value);

Utf16String idl_enum_to_string(ServiceWorkerUpdateViaCache);

} // namespace Web::Bindings
