define(function () {
    class AiGenerativeBlogPlugin {
        install(host) {
            this.host = host
        }

        onOpen() {
            var $title = $('#new_newstitle');
            var $short_summary = $('#new_newstext');

            if (!$title.length || !$short_summary.length) {
                return;
            }

            var title = $title.val();
            var short_summary = $short_summary.val();

            if ($short_summary.wysibb !== 'undefined') {
                short_summary = $short_summary.wysibb().bbcode();
            }

            if (!title || !short_summary) {
                return;
            }

            this.host.SetPrompt(lmsg('blog.ai.prompt.text_summary', title, short_summary));
        }
    }

    return new AiGenerativeBlogPlugin();
});
