{%- for import in imports %}
/// <reference path="./{{ import.name }}-{{ import.version }}.d.ts" />
{%- endfor %}

/**
 * Type Definitions for GJS (https://gjs.guide/), generated by [GirGen](https://github.com/aylur/girgen)
 * If you found a bug, create a bug report on [GirGen's Repository](https://github.com/aylur/girgen/issues/new)
 */
{% for namespace in namespaces -%}
declare module "gi://{{ namespace.name }}?version={{ namespace.version }}" {
    {%- for import in imports %}
    import type {{ import.name }} from "gi://{{ import.name }}?version={{ import.version }}"
    {%- endfor %}

    {{ namespace.content|indent(4) if namespace.content }}


    namespace {{ namespace.name }} {
        const __name__: "{{ namespace.name }}"
        const __version: "{{ namespace.version }}"

        {%- for interface in namespace.interfaces %}
        {{ interface.content|indent(8) }}
        {%- endfor %}

        {%- for class in namespace.classes %}
        {{ class.content|indent(8) }}
        {%- endfor %}

        {%- for record in namespace.records %}
        {{ record.content|indent(8) }}
        {%- endfor %}

        {%- for function in namespace.functions %}
        {{ function.content|indent(8) }}
        {%- endfor %}

        {%- for constant in namespace.constants %}
        {{ constant.content|indent(8) }}
        {%- endfor %}

        {%- for union in namespace.unions %}
        {{ union.content|indent(8) }}
        {%- endfor %}

        {%- for enum in namespace.enums %}
        {{ enum.content|indent(8) }}
        {%- endfor %}

        {%- for bitfield in namespace.bitfields %}
        {{ bitfield.content|indent(8) }}
        {%- endfor %}

        {%- for callback in namespace.callbacks %}
        {{ callback.content|indent(8) }}
        {%- endfor %}

        {%- for alias in namespace.aliases %}
        {{ alias.content|indent(8) }}
        {%- endfor %}
    }

    export default {{ namespace.name }}
}
{%- endfor -%}
