(function (window, $) {
	'use strict';

	const app = window.WPMDEmailTemplatesApp;

	if (!app) {
		return;
	}

	app.register(() => {
		const formService = app.resolve('form');
		const notices = app.resolve('notices');

		if (!formService) {
			return;
		}

		$(document).on('click', '.wpmd-insert-logo', function (event) {
			event.preventDefault();

			const snippet = '<div class="wpmd-email__logo">{{shop_brand}}</div>\n';
			const inserted = formService.insertHtmlSnippet(snippet);

			if (inserted) {
				if (app.config.i18n && app.config.i18n.insertLogo && notices) {
					notices.show(app.config.i18n.insertLogo);
				}

				formService.evaluateLogoHint();
			}
		});

	});
})(window, jQuery);
