#pragma once

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

namespace Web::Bindings {

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

private:
};

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

private:
    JS_DECLARE_NATIVE_FUNCTION(context_getter);
    JS_DECLARE_NATIVE_FUNCTION(number_of_inputs_getter);
    JS_DECLARE_NATIVE_FUNCTION(number_of_outputs_getter);
    JS_DECLARE_NATIVE_FUNCTION(channel_count_getter);
    JS_DECLARE_NATIVE_FUNCTION(channel_count_setter);
    JS_DECLARE_NATIVE_FUNCTION(channel_count_mode_getter);
    JS_DECLARE_NATIVE_FUNCTION(channel_count_mode_setter);
    JS_DECLARE_NATIVE_FUNCTION(channel_interpretation_getter);
    JS_DECLARE_NATIVE_FUNCTION(channel_interpretation_setter);
    JS_DECLARE_NATIVE_FUNCTION(connect);
    JS_DECLARE_NATIVE_FUNCTION(connect0);
    JS_DECLARE_NATIVE_FUNCTION(connect1);
    JS_DECLARE_NATIVE_FUNCTION(disconnect);
    JS_DECLARE_NATIVE_FUNCTION(disconnect0);
    JS_DECLARE_NATIVE_FUNCTION(disconnect1);
    JS_DECLARE_NATIVE_FUNCTION(disconnect2);
    JS_DECLARE_NATIVE_FUNCTION(disconnect3);
    JS_DECLARE_NATIVE_FUNCTION(disconnect4);
    JS_DECLARE_NATIVE_FUNCTION(disconnect5);
    JS_DECLARE_NATIVE_FUNCTION(disconnect6);
};

enum class ChannelCountMode : u8 {
    Max,
    ClampedMax,
    Explicit,
};

JS::ThrowCompletionOr<ChannelCountMode> convert_to_idl_value_for_channel_count_mode(JS::VM&, JS::Value);

Utf16String idl_enum_to_string(ChannelCountMode);

enum class ChannelInterpretation : u8 {
    Speakers,
    Discrete,
};

JS::ThrowCompletionOr<ChannelInterpretation> convert_to_idl_value_for_channel_interpretation(JS::VM&, JS::Value);

Utf16String idl_enum_to_string(ChannelInterpretation);

struct AudioNodeOptions {
    Optional<WebIDL::UnsignedLong> channel_count {};
    Optional<ChannelCountMode> channel_count_mode {};
    Optional<ChannelInterpretation> channel_interpretation {};
};

JS::ThrowCompletionOr<AudioNodeOptions> convert_to_idl_value_for_audio_node_options(JS::VM&, JS::Value);

} // namespace Web::Bindings
