function page_generator_pro_research_get_status(e,t,a){page_generator_pro_research_timeout=setInterval((function(){jQuery.ajax({type:"POST",url:ajaxurl,data:{action:"page_generator_pro_research_get_status",id:e,nonce:page_generator_pro_tinymce.nonces.research},success:function(e){if(!e.success)return clearTimeout(page_generator_pro_research_timeout),wpzinc_modal_show_error_message(e.data);if(e.data.completed){switch(clearTimeout(page_generator_pro_research_timeout),a){case"tinymce":"undefined"!=typeof tinyMCE&&tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden()&&tinyMCE.activeEditor.execCommand("mceReplaceContent",!1,e.data.content);break;case"quicktags":QTags.insertContent(e.data.content);break;case"gutenberg":const t=wp.blocks.createBlock("core/html",{content:e.data.content});wp.data.dispatch("core/block-editor").insertBlocks(t);break}return wpzinc_modal_show_success_and_exit("Done!","")}wpzinc_modal_update_message(e.data.message)}})}),1e4)}var page_generator_pro_research_timeout;jQuery(document).ready((function($){$("body").on("click","#wpzinc-tinymce-modal div.mce-run button, .wpzinc-backbone-modal .media-frame-toolbar .media-toolbar button.run",(function(e){e.preventDefault();let t=$("form.wpzinc-tinymce-popup"),a=$('textarea[name="topic"]',$(t)).val(),n=$('select[name="content_type"]',$(t)).val(),c=$('input[name="limit"]',$(t)).val(),o=$('select[name="language"]',$(t)).val(),r=$('select[name="spintax"]',$(t)).val(),i=$('input[name="editor_type"]',$(t)).val();switch(i){case"tinymce":tinyMCE.activeEditor.windowManager.close();break;default:wpZincModal.close();break}wpzinc_modal_open("Researching..."),$.post(ajaxurl,{action:"page_generator_pro_research",nonce:page_generator_pro_tinymce.nonces.research,topic:a,content_type:n,limit:c,language:o,spintax:r},(function(e){if(!e.success)return wpzinc_modal_show_error_message(e.data);if(e.data.completed){switch(i){case"tinymce":"undefined"!=typeof tinyMCE&&tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden()&&tinyMCE.activeEditor.execCommand("mceReplaceContent",!1,e.data.content);break;case"quicktags":QTags.insertContent(e.data.content);break;case"gutenberg":const t=wp.blocks.createBlock("core/html",{content:e.data.content});wp.data.dispatch("core/block-editor").insertBlocks(t);break}return wpzinc_modal_show_success_and_exit("Done!","")}wpzinc_modal_update_message(e.data.message),page_generator_pro_research_get_status(e.data.id,e.data.estimated_time,i)}))}))}));