jQuery(document).ready(function(a){var b;let c,d=function(b,c,d){let e=a("#wpo-wcpdf-settings").find(d).filter(function(){let a=b.parent("div");return a.length&&"false"===a.attr("aria-hidden")});return e.length?e:c.find(d)};a("#wpo-wcpdf-settings, .wpo-wcpdf-setup").on("click",".wpo_upload_image_button",function(e){return e.preventDefault(),c=a(this).parent(),b?void b.open():void(b=wp.media.frames.file_frame=wp.media({title:a(this).data("uploader_title"),button:{text:a(this).data("uploader_button_text")},multiple:!1}),b.on("select",function(){let e=d(a(this),c,"input.media-upload-id"),f=d(a(this),c,"img.media-upload-preview"),g=b.state().get("selection").first().toJSON();e.val(g.id),f.length&&f.attr("src",g.url),d(a(this),c,".attachment-resolution, .attachment-resolution-warning").remove(),c.parent().block({message:null,overlayCSS:{background:"#fff",opacity:.6}});let h={security:e.data("ajax_nonce"),action:"wpo_wcpdf_get_media_upload_setting_html",args:e.data("settings_callback_args"),attachment_id:g.id};xhr=a.ajax({type:"POST",url:wpo_wcpdf_admin.ajaxurl,data:h,success:function(b){b&&"undefined"!=typeof b.success&&!0===b.success&&c.html(b.data),c.removeAttr("style"),c.parent().unblock(),e=d(a(this),c,"input.media-upload-id"),a(document.body).trigger("wpo-wcpdf-media-upload-setting-updated",[e])},error:function(){c.parent().unblock()}})}),b.open())}),a("#wpo-wcpdf-settings, .wpo-wcpdf-setup").on("click",".wpo_remove_image_button",function(){let b=a(this).parent(),c=b.find("input.media-upload-id"),e=b.find("img.media-upload-preview");c.val(""),e.remove(),a(this).remove(),d(a(this),b,".attachment-resolution, .attachment-resolution-warning").remove()})});