!function(e){"use strict";var t=window.rslIeMediaLibraryExport||{},n="rsl-ie-media-library-export-button";function a(){var t=[];if(window.wp&&window.wp.media&&window.wp.media.frame&&"function"==typeof window.wp.media.frame.state){var n=window.wp.media.frame.state(),a=n&&"function"==typeof n.get?n.get("selection"):null;a&&"function"==typeof a.each&&a.each((function(e){var n=e&&"function"==typeof e.get?e.get("id"):e&&e.id;n&&t.push(String(n))}))}return e(".attachments .attachment.selected").each((function(){var n=e(this).data("id");n&&t.push(String(n))})),t.filter((function(e){return/^\d+$/.test(e)&&parseInt(e,10)>0})).filter((function(e,t,n){return n.indexOf(e)===t}))}function i(){var a=e(".".concat(n)),i=function(){for(var t=[".media-toolbar-primary:visible",".media-toolbar-secondary:visible",".media-toolbar-primary",".media-toolbar-secondary"],n=0;n<t.length;n++){var a=e(t[n]).first();if(a.length)return a}return e()}();(e("body").hasClass("mode-select")||e(".media-frame").hasClass("mode-select")||e(".delete-selected-button:visible, .media-button-delete-selected:visible").length>0)&&i.length?a.length?e.contains(i[0],a[0])||(a.detach(),r(i,a)):r(i,e("<button>",{type:"button",class:"button button-primary media-button ".concat(n),text:o(),disabled:!0,"aria-disabled":"true",title:t.disabledTitle||"Select one or more media files to enable export."})):a.remove()}function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return e>0?"".concat(t.exportLabel||"Export"," (").concat(e,")"):t.exportLabel||"Export"}function r(e,t){var n=e.find(".delete-selected-button, .media-button-delete-selected, .select-mode-toggle-button").first();n.length?t.insertAfter(n):e.append(t)}function d(){i();var t=a(),r=e(".".concat(n));if(r.length){var d=t.length>0;r.prop("disabled",!d).attr("aria-disabled",d?"false":"true").text(o(d?t.length:0))}}e(document).on("click",".select-mode-toggle-button, .attachment, .attachment .check, .delete-selected-button, .media-button-delete-selected",(function(){window.setTimeout(d,50)})),e(document).on("click",".".concat(n),(function(e){e.preventDefault();var n=a();n.length?window.open(function(e){var n=t.exportUrl||"".concat(window.ajaxurl?window.ajaxurl.replace("admin-ajax.php","admin.php"):"admin.php","?page=rsl-ie-export"),a=-1===n.indexOf("?")?"?":"&",i=new URLSearchParams({rsl_ie_prefill:"media_library",media_ids:e.join(",")});return"".concat(n).concat(a).concat(i.toString())}(n),"_blank","noopener"):d()})),e((function(){i(),function(){if(window.wp&&window.wp.media&&window.wp.media.frame&&"function"==typeof window.wp.media.frame.state){var e=window.wp.media.frame.state(),t=e&&"function"==typeof e.get?e.get("selection"):null;t&&"function"==typeof t.on&&t.on("add remove reset",d)}}(),d()}))}(jQuery);
//# sourceMappingURL=media-library-export.js.map