var themifyMediaLib={};!function($){"use strict";themifyMediaLib={init(){themifyMediaLib.mediaUploader()},mediaUploader(){var e="";$("body").on("click",".themify-media-lib-browse",(function(i){var t=$(this),a=t.data("submit"),d=t.data("type");(e=wp.media.frames.file_frame=wp.media({title:$(this).data("uploader-title"),library:{type:d},button:{text:$(this).data("uploader-button-text")},multiple:!1})).on("select",(()=>{var i=e.state().get("selection").first().toJSON();a.attach_id=i.id;var l=t.data("fields");$("#"+l).val(i.url),$("body").trigger("themify_metabox_lib_selected",[t,i,e]),"image"===d?$.ajax({type:"POST",url:ajaxurl,data:a,dataType:"json",success(e){themifyMediaLib.setPreviewIcon(t.closest(".themify_field, .themify_field_row"),e.thumb)}}):"audio"!==d&&"video"!==d||t.closest(".themify_field_row").find(".themify_featimg_remove").removeClass("hide")})),e.open(),i.preventDefault()}))},setPreviewIcon(e,i){var t=$('<a href="'+i+'" target="_blank"><img src="'+i+'" width="40" /></a>').fadeIn(1e3).css("display","inline-block");e.find(".themify_upload_preview").find("a").length>0&&e.find(".themify_upload_preview").find("a").remove(),e.find(".themify_upload_preview").fadeIn().append(t),e.find(".themify_featimg_remove").removeClass("hide")}},$(themifyMediaLib.init)}(jQuery);