(()=>{function e(e){jQuery("#media-upload-error").show().html('<div class="error"><p>'+e+"</p></div>")}function a(e,a,d){d=pluploadL10n.error_uploading.replace("%s",a.name)+d;const r=jQuery("<div />").attr({id:"media-item-"+a.id,class:"error"}).append(jQuery("<p />").text(d));jQuery("#media-file-errors").append(r),e.removeFile(a)}jQuery((function(d){"object"==typeof dndImportObject.pluploadInit&&function(){const r=new plupload.Uploader(dndImportObject.pluploadInit);r.bind("Init",(function(e){const a=d("#plupload-upload-ui");e.features.dragdrop&&!d(document.body).hasClass("mobile")?(a.addClass("drag-drop"),d("#drag-drop-area").on("dragover.wp-uploader",(function(){a.addClass("drag-over")})).on("dragleave.wp-uploader, drop.wp-uploader",(function(){a.removeClass("drag-over")}))):(a.removeClass("drag-drop"),d("#drag-drop-area").off(".wp-uploader")),"html4"===e.runtime&&d(".upload-flash-bypass").hide()})),r.bind("postinit",(function(e){e.refresh()})),r.init(),r.bind("FilesAdded",(function(a,r){d("#media-upload-error").empty(),plupload.each(r,(function(d){var r;"image/heic"===d.type&&a.settings.heic_upload_error&&e(pluploadL10n.unsupported_image),r=d,jQuery('<div class="media-item">').attr("id","media-item-"+r.id).append('<div class="progress"><div class="percent">0%</div><div class="bar"></div></div>',jQuery('<div class="filename original">').text(" "+r.name)).appendTo(jQuery("#media-items"))})),a.refresh(),a.start()})),r.bind("UploadFile",(function(e,a){!function(e,a){var d=104857600;parseInt(e.settings.max_file_size,10)>d&&a.size>d&&setTimeout((function(){a.status<3&&0===a.loaded&&(fileError(a,pluploadL10n.big_upload_failed.replace("%1$s",'<a class="uploader-html" href="#">').replace("%2$s","</a>")),e.stop(),e.removeFile(a),e.start())}),1e4)}(e,a)})),r.bind("UploadProgress",(function(e,a){!function(e,a){var d=jQuery("#media-item-"+a.id);jQuery(".bar",d).width(200*a.loaded/a.size),jQuery(".percent",d).html(a.percent+"%")}(0,a)})),r.bind("Error",(function(d,r){!function(d,r,i,l){var o=104857600;switch(r){case plupload.FAILED:a(d,pluploadL10n.upload_failed);break;case plupload.FILE_EXTENSION_ERROR:!function(e,a,d){jQuery("#media-items").append('<div id="media-item-'+a.id+'" class="media-item error"><p>'+d+"</p></div>"),e.removeFile(a)}(l,d,pluploadL10n.invalid_filetype);break;case plupload.FILE_SIZE_ERROR:!function(e,a){const d=pluploadL10n.file_exceeds_size_limit.replace("%s",a.name),r=jQuery("<div />").attr({id:"media-item-"+a.id,class:"media-item error"}).append(jQuery("<p />").text(d));jQuery("#media-file-errors").append(r),e.removeFile(a)}(l,d);break;case plupload.IMAGE_FORMAT_ERROR:a(d,pluploadL10n.not_an_image);break;case plupload.IMAGE_MEMORY_ERROR:a(d,pluploadL10n.image_memory_exceeded);break;case plupload.IMAGE_DIMENSIONS_ERROR:a(d,pluploadL10n.image_dimensions_exceeded);break;case plupload.GENERIC_ERROR:e(pluploadL10n.upload_failed);break;case plupload.IO_ERROR:parseInt(l.settings.filters.max_file_size,10)>o&&d.size>o?a(d,pluploadL10n.big_upload_failed.replace("%1$s",'<a class="uploader-html" href="#">').replace("%2$s","</a>")):e(pluploadL10n.io_error);break;case plupload.HTTP_ERROR:e(pluploadL10n.http_error);break;case plupload.INIT_ERROR:jQuery(".media-upload-form").addClass("html-uploader");break;case plupload.SECURITY_ERROR:e(pluploadL10n.security_error);break;default:a(d,pluploadL10n.default_error)}}(r.file,r.code,r.message,d),d.refresh()})),r.bind("FileUploaded",(function(e,a,d){!function(e,a){const d=jQuery("#media-item-"+e.id);"string"==typeof a&&(a=a.replace(/^<pre>(\d+)<\/pre>$/,"$1"),/media-upload-error|error-div/.test(a))?d.html(a):(d.find(".percent").html(pluploadL10n.crunching),function(e,a){jQuery("#media-item-"+e.id).load(dndImportObject.ajaxurl,{document_id:a,action:"dlp_dnd_fetch"})}(e,a))}(a,d.response)})),r.bind("UploadComplete",(function(){}))}()}))})();