var $=jQuery.noConflict();$(document).ready(function(e){"use strict";e("#cfm-episode-share-modal").on("show.bs.modal",function(t){var a=e(t.relatedTarget).closest("tr").prop("id").split("-")[1];e(document).loadEpisodeShareModal(a)}),e("#cfm-episode-share-modal").on("hidden.bs.modal",function(t){e("#cfm-episode-share").html("")}),e.fn.loadEpisodeShareModal=function(t){e.ajax({url:cfmsync.ajaxurl,type:"post",data:{action:"share-episode",_nonce:cfmsync.ajaxnonce,post_id:t},beforeSend:function(){e("#cfm-episode-share").html(cfm_content_spinner)},success:function(t){e("#cfm-episode-share").html(t)}})},e(document).on("click","#cfm-toggle-episode",function(t){t.preventDefault();var a=e(this),o=a.html(),s=a.attr("data-reference"),i=a.attr("data-nonce");e.ajax({url:cfmsync.ajaxurl,type:"post",data:{action:"toggle-episode",_nonce:i,post_id:s},beforeSend:function(){a.prop("disabled",!0),a.siblings("button").prop("disabled",!0),a.html('<i class="fas fa-spinner fa-spin me-2"></i> Processing...')},success:function(t){a.prop("disabled",!1),a.siblings("button").prop("disabled",!1),a.html(o),e("#confirmation-modal").modal("hide"),"episode_deactivated"==t?(e("tr#post-"+s+" .btn-toggle").replaceWith('<a aria-label="Toggle" class="btn btn-toggle" data-bs-toggle="modal" data-bs-target="#confirmation-modal" data-confirmation-title="Activate Episode" data-confirmation-content="Are you sure you want to activate this episode? This episode will be activated and will be available publicly on this website." data-confirmation-button="cfm-toggle-episode" data-confirmation-button-text="Activate Episode" data-confirmation-reference="'+s+'" data-confirmation-nonce="'+i+'"><i class="fal fa-play"></i></a>'),cfmsync_toaster("success","Episode deactivated on this website.")):"episode_activated"==t?(e("tr#post-"+s+" .btn-toggle").replaceWith('<a aria-label="Toggle" class="btn btn-toggle" data-bs-toggle="modal" data-bs-target="#confirmation-modal" data-confirmation-title="Deactivate Episode" data-confirmation-content="Are you sure you want to deactivate this episode? This episode will be deactivated and will not be available publicly on this website. This action will not change the episode status and will not affect the episode in Captivate." data-confirmation-button="cfm-toggle-episode" data-confirmation-button-text="Deactivate Episode" data-confirmation-reference="'+s+'" data-confirmation-nonce="'+i+'"><i class="fal fa-pause"></i></a>'),cfmsync_toaster("success","Episode activated on this website.")):cfmsync_toaster("error","Something went wrong. Please refresh the page and try again.")}}),t.preventDefault()}),e(document).on("click","#cfm-trash-episode",function(t){t.preventDefault();var a=e(this),o=a.html(),s=a.attr("data-reference"),i=a.attr("data-nonce");e.ajax({url:cfmsync.ajaxurl,type:"post",data:{action:"trash-episode",_nonce:i,post_id:s},beforeSend:function(){a.prop("disabled",!0),a.siblings("button").prop("disabled",!0),a.html('<i class="fas fa-spinner fa-spin me-2"></i> Deleting episode...'),e("tr#post-"+s).css({"background-color":"#ff3333"},500)},success:function(t){a.prop("disabled",!1),a.siblings("button").prop("disabled",!1),a.html(o),e("#confirmation-modal").modal("hide"),"success"==t?(e("tr#post-"+s).fadeOut(500,function(){e("tr#post-"+s).remove()}),cfmsync_toaster("success","Episode deleted on this website and on Captivate.")):"duplicate_episode"==t?(e("tr#post-"+s).css({"background-color":"#ffffff"},500),cfmsync_toaster("error","Cannot delete episode. Possible duplicate found. Please contact support.")):"success_wp"==t?(e("tr#post-"+s).fadeOut(500,function(){e("tr#post-"+s).remove()}),cfmsync_toaster("success","Episode deleted on this website (episode not on Captivate).")):(e("tr#post-"+s).css({"background-color":"#ffffff"}),cfmsync_toaster("error","Something went wrong. Please refresh the page and try again."))}}),t.preventDefault()})});