/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/angular2-promise-buttons@6.0.0/bundles/angular2-promise-buttons.umd.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("rxjs")):"function"==typeof define&&define.amd?define("angular2-promise-buttons",["exports","@angular/core","rxjs"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["angular2-promise-buttons"]={},e.ng.core,e.rxjs)}(this,(function(e,t,n){"use strict";function i(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var o=i(t),r={spinnerTpl:'<span class="btn-spinner"></span>',disableBtn:!0,btnLoadingClass:"is-loading",handleCurrentBtnOnly:!1,minDuration:null},s=new t.InjectionToken("cfg"),a=function(){function e(e,t){this.cfg=Object.assign({},r,t),this.btnEl=e.nativeElement}return Object.defineProperty(e.prototype,"isDisabledFromTheOutsideSetter",{set:function(e){this.isDisabledFromTheOutside=e,e?this.btnEl.setAttribute("disabled","disabled"):(this.isPromiseDone||void 0===this.isPromiseDone)&&this.btnEl.removeAttribute("disabled")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"promiseBtn",{set:function(e){var t=e instanceof n.Observable,i=e instanceof n.Subscription,o="boolean"==typeof e,r=e instanceof Promise||null!==e&&"object"==typeof e&&"function"==typeof e.then&&"function"==typeof e.catch;if(t)throw new TypeError("promiseBtn must be an instance of Subscription, instance of Observable given");if(i){var s=e;s.closed||(this.promise=new Promise((function(e){s.add(e)})))}else r?this.promise=e:o&&(this.promise=this.createPromiseFromBoolean(e));this.checkAndInitPromiseHandler(this.btnEl)},enumerable:!1,configurable:!0}),e.prototype.ngAfterContentInit=function(){this.prepareBtnEl(this.btnEl),this.checkAndInitPromiseHandler(this.btnEl)},e.prototype.ngOnDestroy=function(){this.minDurationTimeout&&clearTimeout(this.minDurationTimeout)},e.prototype.createPromiseFromBoolean=function(e){var t=this;return e?new Promise((function(e){t._fakePromiseResolve=e})):(this._fakePromiseResolve&&this._fakePromiseResolve(),this.promise)},e.prototype.prepareBtnEl=function(e){this.appendSpinnerTpl(e)},e.prototype.checkAndInitPromiseHandler=function(e){e&&this.promise&&this.initPromiseHandler(e)},e.prototype.addLoadingClass=function(e){"string"==typeof this.cfg.btnLoadingClass&&e.classList.add(this.cfg.btnLoadingClass)},e.prototype.removeLoadingClass=function(e){"string"==typeof this.cfg.btnLoadingClass&&e.classList.remove(this.cfg.btnLoadingClass)},e.prototype.initLoadingState=function(e){this.addLoadingClass(e),this.disableBtn(e)},e.prototype.cancelLoadingStateIfPromiseAndMinDurationDone=function(e){this.cfg.minDuration&&!this.isMinDurationTimeoutDone||!this.isPromiseDone||(this.removeLoadingClass(e),this.enableBtn(e))},e.prototype.disableBtn=function(e){this.cfg.disableBtn&&e.setAttribute("disabled","disabled")},e.prototype.enableBtn=function(e){this.cfg.disableBtn&&(this.isDisabledFromTheOutside?e.setAttribute("disabled","disabled"):e.removeAttribute("disabled"))},e.prototype.initPromiseHandler=function(e){var t=this,n=this.promise;this.isMinDurationTimeoutDone=!1,this.isPromiseDone=!1,this.cfg.minDuration&&(this.minDurationTimeout=window.setTimeout((function(){t.isMinDurationTimeoutDone=!0,t.cancelLoadingStateIfPromiseAndMinDurationDone(e)}),this.cfg.minDuration));var i=function(){t.isPromiseDone=!0,t.cancelLoadingStateIfPromiseAndMinDurationDone(e)};this.cfg.handleCurrentBtnOnly||this.initLoadingState(e),n.finally?n.finally(i):n.then(i).catch(i)},e.prototype.appendSpinnerTpl=function(e){e.insertAdjacentHTML("beforeend",this.cfg.spinnerTpl)},e.prototype.handleCurrentBtnOnly=function(){var e=this;if(!this.cfg.handleCurrentBtnOnly)return!0;window.setTimeout((function(){e.promise&&e.initLoadingState(e.btnEl)}),0)},e}();a.ɵfac=o.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"12.2.17",ngImport:o,type:a,deps:[{token:o.ElementRef},{token:s}],target:o.ɵɵFactoryTarget.Directive}),a.ɵdir=o.ɵɵngDeclareDirective({minVersion:"12.0.0",version:"12.2.17",type:a,selector:"[promiseBtn]",inputs:{isDisabledFromTheOutsideSetter:["disabled","isDisabledFromTheOutsideSetter"],promiseBtn:"promiseBtn"},host:{listeners:{click:"handleCurrentBtnOnly()"}},ngImport:o}),o.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"12.2.17",ngImport:o,type:a,decorators:[{type:t.Directive,args:[{selector:"[promiseBtn]"}]}],ctorParameters:function(){return[{type:o.ElementRef},{type:void 0,decorators:[{type:t.Inject,args:[s]}]}]},propDecorators:{isDisabledFromTheOutsideSetter:[{type:t.Input,args:["disabled"]}],promiseBtn:[{type:t.Input}],handleCurrentBtnOnly:[{type:t.HostListener,args:["click"]}]}});var l=function(){function e(){}return e.forRoot=function(t){return{ngModule:e,providers:[{provide:s,useValue:t}]}},e}();l.ɵfac=o.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"12.2.17",ngImport:o,type:l,deps:[],target:o.ɵɵFactoryTarget.NgModule}),l.ɵmod=o.ɵɵngDeclareNgModule({minVersion:"12.0.0",version:"12.2.17",ngImport:o,type:l,declarations:[a],exports:[a]}),l.ɵinj=o.ɵɵngDeclareInjector({minVersion:"12.0.0",version:"12.2.17",ngImport:o,type:l,providers:[],imports:[[]]}),o.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"12.2.17",ngImport:o,type:l,decorators:[{type:t.NgModule,args:[{declarations:[a],imports:[],exports:[a],providers:[]}]}]}),e.Angular2PromiseButtonModule=l,e.PromiseBtnDirective=a,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=/sm/85142b45800fe3dc07021a0a9b9db3cb8d5461bc5171d2778003900fbf8999ff.map