#pragma once

#include <LibJS/Forward.h>
#include <LibJS/Runtime/NativeFunction.h>
#include <LibJS/Runtime/Object.h>
#include <LibJS/Runtime/Value.h>
#include <LibWeb/Bindings/AudioNode.h>
#include <LibWeb/Bindings/InterfaceObject.h>
#include <LibWeb/WebIDL/Types.h>

namespace Web::Bindings {

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

private:
};

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

private:
    JS_DECLARE_NATIVE_FUNCTION(fft_size_getter);
    JS_DECLARE_NATIVE_FUNCTION(fft_size_setter);
    JS_DECLARE_NATIVE_FUNCTION(frequency_bin_count_getter);
    JS_DECLARE_NATIVE_FUNCTION(min_decibels_getter);
    JS_DECLARE_NATIVE_FUNCTION(min_decibels_setter);
    JS_DECLARE_NATIVE_FUNCTION(max_decibels_getter);
    JS_DECLARE_NATIVE_FUNCTION(max_decibels_setter);
    JS_DECLARE_NATIVE_FUNCTION(smoothing_time_constant_getter);
    JS_DECLARE_NATIVE_FUNCTION(smoothing_time_constant_setter);
    JS_DECLARE_NATIVE_FUNCTION(get_float_frequency_data);
    JS_DECLARE_NATIVE_FUNCTION(get_byte_frequency_data);
    JS_DECLARE_NATIVE_FUNCTION(get_float_time_domain_data);
    JS_DECLARE_NATIVE_FUNCTION(get_byte_time_domain_data);
};

struct AnalyserOptions : public AudioNodeOptions {
    WebIDL::UnsignedLong fft_size { 2048 };
    double max_decibels { -30 };
    double min_decibels { -100 };
    double smoothing_time_constant { 0.8 };
};

JS::ThrowCompletionOr<AnalyserOptions> convert_to_idl_value_for_analyser_options(JS::VM&, JS::Value);

} // namespace Web::Bindings
