(()=>{function e(e,t){for(var o=0;o<t.length;o++){var a=t[o];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}var t=function(){function t(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t)}var o,a,r;return o=t,(a=[{key:"init",value:function(){var e=$("#table-backups");e.on("click",".deleteDialog",(function(e){e.preventDefault(),$(".delete-crud-entry").data("section",$(e.currentTarget).data("section")),$(".modal-confirm-delete").modal("show")})),e.on("click",".restoreBackup",(function(e){e.preventDefault(),$("#restore-backup-button").data("section",$(e.currentTarget).data("section")),$("#restore-backup-modal").modal("show")})),$(".delete-crud-entry").on("click",(function(t){t.preventDefault(),$(".modal-confirm-delete").modal("hide");var o=$(t.currentTarget).data("section");$.ajax({url:o,type:"POST",data:{_method:"DELETE"},success:function(t){t.error?Botble.showError(t.message):(e.find("tbody tr").length<=1&&e.load(window.location.href+" #table-backups > *"),e.find('a[data-section="'+o+'"]').closest("tr").remove(),Botble.showSuccess(t.message))},error:function(e){Botble.handleError(e)}})})),$("#restore-backup-button").on("click",(function(e){e.preventDefault();var t=$(e.currentTarget);t.addClass("button-loading"),$.ajax({url:t.data("section"),type:"GET",success:function(e){t.removeClass("button-loading"),t.closest(".modal").modal("hide"),e.error?Botble.showError(e.message):(Botble.showSuccess(e.message),window.location.reload())},error:function(e){t.removeClass("button-loading"),Botble.handleError(e)}})})),$(document).on("click","#generate_backup",(function(e){e.preventDefault(),$("#name").val(""),$("#description").val(""),$("#create-backup-modal").modal("show")})),$("#create-backup-modal").on("click","#create-backup-button",(function(t){t.preventDefault();var o=$(t.currentTarget);o.addClass("button-loading");var a=$("#name").val(),r=$("#description").val(),n=!1;""!==a&&null!==a||(n=!0,Botble.showError("Backup name is required!")),n?o.removeClass("button-loading"):$.ajax({url:$("div[data-route-create]").data("route-create"),type:"POST",data:{name:a,description:r},success:function(t){o.removeClass("button-loading"),o.closest(".modal").modal("hide"),t.error?Botble.showError(t.message):(e.find(".no-backup-row").remove(),e.find("tbody").append(t.data),Botble.showSuccess(t.message))},error:function(e){o.removeClass("button-loading"),Botble.handleError(e)}})}))}}])&&e(o.prototype,a),r&&e(o,r),Object.defineProperty(o,"prototype",{writable:!1}),t}();$(document).ready((function(){(new t).init()}))})();