(()=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){for(var o=0;o<t.length;o++){var r=t[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,n(r.key),r)}}function n(t){var n=function(t,n){if("object"!=e(t)||!t)return t;var o=t[Symbol.toPrimitive];if(void 0!==o){var r=o.call(t,n||"default");if("object"!=e(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"==e(n)?n:n+""}var o=function(){return e=function e(){var t,o,r,a=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t=this,r=!1,(o=n(o="isDownloading"))in t?Object.defineProperty(t,o,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[o]=r,$(document).on("submit",".form-import-data",(function(e){a.submit(e)})).on("click",".download-template",(function(e){a.download(e)}))},(o=[{key:"submit",value:function(e){e.preventDefault();var t=$(e.currentTarget),n=new FormData(t.get(0)),o=t.find("button[type=submit]"),r=$("#imported-message"),a=$("#imported-listing"),i=$(".show-errors"),l=$("#failure-template").html();$(".main-form-message").addClass("hidden"),r.html(""),a.html(""),$httpClient.make().withLoading(t).withButtonLoading(o).post(t.prop("action"),n).then((function(e){var n=e.data;Botble.showSuccess(n.message),r.removeClass().addClass("alert alert-success").html(n.data.message),a.addClass("hidden").html(""),i.addClass("hidden"),t.trigger("reset")})).catch((function(e){var t=e.response.data,n="";t.data&&t.data.map((function(e){n+=l.replace("__row__",e.row).replace("__attribute__",e.attribute).replace("__errors__",e.errors.join(", "))})),r.removeClass().addClass("alert alert-danger").html(t.message),n&&(i.removeClass("hidden"),a.removeClass("hidden").html(n))})).finally((function(){$(".main-form-message").removeClass("hidden")}))}},{key:"download",value:function(e){var t=this;if(e.preventDefault(),!this.isDownloading){var n=$(e.currentTarget),o=n.data("extension"),r=n.html();$.ajax({url:n.data("url"),method:"POST",data:{extension:o},xhrFields:{responseType:"blob"},beforeSend:function(){n.html(n.data("downloading")),n.addClass("text-secondary"),t.isDownloading=!0},success:function(e){var t=document.createElement("a"),o=window.URL.createObjectURL(e);t.href=o,t.download=n.data("filename"),document.body.append(t),t.click(),t.remove(),window.URL.revokeObjectURL(o)},error:function(e){Botble.handleError(e)},complete:function(){setTimeout((function(){n.html(r),n.removeClass("text-secondary"),t.isDownloading=!1}),500)}})}}}])&&t(e.prototype,o),r&&t(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,o,r}();$((function(){return new o}))})();