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"),l=t.data("type");(e=wp.media.frames.file_frame=wp.media({title:$(this).data("uploader-title"),library:{type:l},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 d=t.data("fields");$("#"+d).val(i.url),$("body").trigger("themify_metabox_lib_selected",[t,i,e]),"image"===l?$.ajax({type:"POST",url:ajaxurl,data:a,dataType:"json",success(e){e.thumb&&themifyMediaLib.setPreviewIcon(t.closest(".themify_field, .themify_field_row"),e.thumb)}}):"audio"!==l&&"video"!==l||t.closest(".themify_field_row").find(".themify_clear_field").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_clear_field").removeClass("hide")}},$(themifyMediaLib.init)}(jQuery);