import {
	type Metadata,
	type ModuleLibrary,
} from '@divi/types';
import React from 'react';
import { DynamicLinkEdit } from './edit';
import metadata from './module.json';
import { SettingsAdvanced } from './settings-advanced';
import { SettingsContent } from './settings-content';
import { SettingsDesign } from './settings-design';
import { DynamicLinkAttrs } from './types';
import { placeholderContent } from './placeholder-content';
import { generateModuleAttributes } from '../../utils';

import './module.scss';

metadata.attributes = { ...metadata.attributes, ...generateModuleAttributes( 'dynamicLink' ) }

export const dynamicLink: ModuleLibrary.Module.RegisterDefinition<DynamicLinkAttrs> = {
	// Imported json has no inferred type hence type-cast is necessary.
	metadata: metadata as Metadata.Values<DynamicLinkAttrs>,
	placeholderContent,
	settings: {
		content:  SettingsContent,
		design:   SettingsDesign,
		advanced: SettingsAdvanced,
	},
	renderers: {
		edit: DynamicLinkEdit,
	},
};
