// ESLint directives, to have no conflicts with project ESLint settings
/* eslint-disable @typescript-eslint/no-redundant-type-constituents, @typescript-eslint/no-empty-object-type, @typescript-eslint/no-unsafe-function-type */

{{#each clazz._dts.globalImports}}
{{#if @first}}
/**
 * Original webc imports
 */
{{/if}}
{{{generateImports @key this}}}

{{/each}}

/**
 * Default imports
 */
import type { default as WebComponentMetadata } from "sap/ui/core/webc/WebComponentMetadata";

{{#each clazz._dts.imports}}
	{{#if @first}}

	/**
	 * Dynamic imports
	 */
	{{/if}}
	{{{generateImports @key this}}}

{{/each}}
declare module "{{{clazz._ui5QualifiedNameSlashes}}}" {

		export interface ${{{clazz.name}}}Settings extends ${{{clazz._dts.extends}}}Settings {
			{{#each clazz._dts.properties}}
				{{#if @first}}

				/**
				 * Properties
				 */

				{{/if}}
				{{#if this.description}}

				{{{generateApiDocumentation this.description}}}
				{{/if}}
				{{{@key}}}?: {{{generatePropertySettingsWithBindingInfo this.types}}}
			{{/each}}
			{{#each clazz._dts.aggregations}}
				{{#if @first}}

				/**
				 * Aggregations
				 */

				{{/if}}
				{{#if this.description}}

				{{{generateApiDocumentation this.description}}}
				{{/if}}
				{{{@key}}}?: {{{generateAggregationSettings this.types}}}
			{{/each}}
			{{#each clazz._dts.associations}}
				{{#if @first}}

				/**
				 * Associations
				 */

				{{/if}}
				{{#if this.description}}

				{{{generateApiDocumentation this.description}}}
				{{/if}}
				{{{@key}}}?: {{{generateAssociationSettings this.types}}}
			{{/each}}
			{{#each clazz._dts.events}}
				{{#if @first}}

				/**
				 * Events
				 */

				{{/if}}
				{{#if this.description}}

				{{{generateApiDocumentation this.description}}}
				{{/if}}
				{{{@key}}}?: (oEvent: {{{generateEventSettings @root.clazz.name @key}}}) => void
			{{/each}}
		}
		{{#each clazz._dts.events}}
			export interface {{{generateEventSettings @root.clazz.name @key}}}Parameters {
				{{#each this.parameters}}
					{{#if this.dtsParamDescription}}

					 {{{generateApiDocumentation this.dtsParamDescription}}}
					{{/if}}
					{{{@key}}}?: {{{processTypes this.types}}}
				{{/each}}
			}

			export type {{{generateEventSettings @root.clazz.name @key}}} = Event<
				{{{generateEventSettings @root.clazz.name @key}}}Parameters,
				{{{@root.clazz.name}}}
			>;
		{{/each}}

		export default class {{{clazz.name}}} extends {{{clazz._dts.extends}}}
	{{#if clazz._dts.implements}}
		implements {{join clazz._dts.implements}}
	{{/if}}
		{
			{{#each clazz._dts.implementsMarker}}
				{{{escapeInterfaceName this.package this.name}}}
			{{/each}}

			constructor(
				/**
				* Initial settings for the new control
				*/
				mSettings?: ${{{clazz.name}}}Settings
			);

			constructor(
				/**
				* ID for the new control, generated automatically if no ID is given
				*/
				id?: string,
				/**
				* Initial settings for the new control
				*/
				mSettings?: ${{{clazz.name}}}Settings
			);


			/**
			 * Creates a new subclass of class "{{{clazz._ui5QualifiedNameSlashes}}}" with name `sClassName` and enriches it with the information
			 * contained in `oClassInfo`.
			 *
			 * `oClassInfo` might contain the same kind of information as described in {@link sap.ui.core.Control.extend}.
			 *
			 *
			 * @returns Created class / constructor function
			 */
			static extend<T extends Record<string, unknown>>(
				/**
				 * Name of the class being created
				 */
				sClassName: string,
				/**
				 * Object literal with information about the class
				 */
				oClassInfo?: sap.ClassInfo<T, {{{clazz.name}}}>,
				/**
				 * Constructor function for the metadata object; if not given, it defaults to the metadata implementation
				 * used by this class
				 */
				FNMetaImpl?: Function
			): Function;

			/**
			 * Returns a metadata object for class "{{{clazz._ui5QualifiedNameSlashes}}}".
			 *
			 *
			 * @returns Metadata object describing this class
			 */
			static getMetadata(): WebComponentMetadata;
			{{#each clazz._dts.methods}}

				{{#if this.description}}
				{{{this.description}}}
				{{/if}}
				{{{this.methodName}}}({{#each this.params}}
				{{{generateApiDocumentation this.description}}}
				{{@key}}Value{{#if this.optional}}?{{/if}}: {{{processTypes this.types}}},
				{{/each}}): {{#if this.returnValueTypes}}{{{processTypes this.returnValueTypes}}}{{else}}void{{/if}};
			{{/each}}
		}
}