jQuery((function(e){const t=function(){e("#dlw_add_file_button").on("click",this.handleAddFile),e("#dlw_remove_file_button").on("click",this.handleRemoveFile),e("#dlw_document_link_type").on("change",this.handleSelectBox),this.initMetaboxLocking()};t.wpMedia=null,t.prototype.handleSelectBox=function(t){const l=e(this).find(":selected").val(),a=e("#dlw_file_attachment_details"),i=e("#dlw_link_url_details"),d=e("#dlw_file_size_input");switch(l){case"file":i.removeClass("active"),a.addClass("active"),d.prop("disabled",!0);break;case"url":i.addClass("active"),a.removeClass("active"),d.removeAttr("disabled");break;default:i.removeClass("active"),a.removeClass("active"),d.removeAttr("disabled")}},t.prototype.handleAddFile=function(l){l.preventDefault();const a=e(this),i=e("#dlw_file_name"),d=e(".dlw_file_name_text"),n=e("#dlw_file_id"),o=e(".dlw_file_attached");null===t.wpMedia?((t.wpMedia=wp.media({title:dlwAdminObject.i18n.select_file,button:{text:dlwAdminObject.i18n.add_file}})).on("select",(function(){t.wpMedia.state().get("selection").map((function(e){e=e.toJSON(),i.val(e.filename),d.text(e.filename),n.val(e.id),o.addClass("active"),a.text(dlwAdminObject.i18n.replace_file)}))})),t.wpMedia.open()):t.wpMedia.open()},t.prototype.handleRemoveFile=function(t){t.preventDefault();const l=e("#dlw_file_name"),a=e("#dlw_file_id"),i=e(".dlw_file_attached"),d=e("#dlw_add_file_button");i.removeClass("active"),l.val(""),a.val(""),d.text(dlwAdminObject.i18n.add_file)},t.prototype.initMetaboxLocking=function(){const t=e("#document_link"),l=e("#dlp_below_title-sortables");t.length&&(t.addClass("postbox-locked"),t.removeAttr("draggable").removeClass("ui-sortable-handle"),t.find("*").removeAttr("draggable").removeClass("ui-sortable-handle"),t.find(".postbox-header h2").css("cursor","default"),t.find(".handle-order-higher, .handle-order-lower").remove(),t.off(".dlp-lock").on("mousedown.dlp-lock dragstart.dlp-lock drag.dlp-lock",(function(t){return!(!e(t.target).is("input, select, button, textarea, option, .handlediv")&&!e(t.target).closest("input, select, button, textarea, .handlediv").length&&(t.stopImmediatePropagation(),t.preventDefault(),1))})),l.length&&l.hasClass("ui-sortable")&&l.sortable("option",{cancel:"#document_link, #document_link *:not(.handlediv)",items:"> .postbox:not(#document_link)"}))},new t}));