!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("rxjs"),require("rxjs/operators"),require("@angular/common/http"),require("@angular/common")):"function"==typeof define&&define.amd?define("@isaiahiroko/ng-paystack",["exports","@angular/core","rxjs","rxjs/operators","@angular/common/http","@angular/common"],e):e((t.isaiahiroko=t.isaiahiroko||{},t.isaiahiroko["ng-paystack"]={}),t.ng.core,t.rxjs,t.rxjs.operators,t.ng.common.http,t.ng.common)}(this,function(t,r,i,e,n,o){"use strict";var s=function(){return(s=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function a(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||0<e--)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(n=i["return"])&&n.call(i)}finally{if(o)throw o.error}}return s}var c=function(){function t(){this.scripts=[]}return t.prototype.load=function(r){var o=this;return new i.Observable(function(e){o.scripts.find(function(t){return t.name==r.name});o.scripts=function n(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(a(arguments[e]));return t}(o.scripts,[r]);var t=document.createElement("script");t.type="text/javascript",t.src=r.src,t.onload=function(){r.loaded=!0,e.next(r),e.complete()},t.onerror=function(t){e.error("Couldn't load script "+r.src)},document.getElementsByTagName("body")[0].appendChild(t)}).pipe(e.retryWhen(function(t){return t.pipe(e.zip(i.range(1,4)),e.mergeMap(function(t){var e=a(t,2),n=e[0],r=e[1];return 3<r?i.throwError(n):i.timer(1e3*r)}))}),e.filter(function(t){return t.loaded}))},t.decorators=[{type:r.Injectable}],t}(),u=new r.InjectionToken("NG_PAYSTACK_DATA"),p=function(){function t(t,e,n){this.loader=t,this.http=e,this.data=n,this.success=new r.EventEmitter,this.failure=new r.EventEmitter,this.request=this.request?this.request:this.data,console.info("conponent init",this.request)}return t.prototype.ngOnInit=function(){console.info("init",this.request)},t.prototype.ngAfterViewInit=function(){console.info("after view init",this.request),"embed"==this.request.type&&this.payEmbed()},t.prototype.payEmbed=function(t){var e=this;this.pay(s({},t,{container:"paystack-embed-container",callback:function(t){e.success.emit(s({},t,{verified:!1})),console.log("Payment successful, but yet to be verified. You might be contacted if their is any issue with your payment.")}},this.request))},t.prototype.payInline=function(t){var e=this;this.pay(s({},t,{callback:function(t){t=s({},t,{verified:!1}),e.success.emit(t),console.log("Payment successful, but yet to be verified. You might be contacted if their is any issue with your payment.")}},this.request))},t.prototype.pay=function(n){var r=this;this.paystackScript=this.loader.load({name:"Paystack",src:"https://js.paystack.co/v1/inline.js",loaded:!1}).pipe(e.catchError(function(t){return console.error("Cannot load PaystackPop as a member of window object. Verify that https://js.paystack.co/v1/inline.js loaded correctly."),i.empty()})).subscribe(function(t){var e=window.PaystackPop.setup(n);"inline"==r.request.type&&e.openIframe()})},t.prototype.ngOnDestroy=function(){console.info("component destroyed",this.request),this.paystackScript.unsubscribe(),window.PaystackPop=null},t.decorators=[{type:r.Component,args:[{selector:"ng-paystack",template:'<div id="paystack-embed-container" *ngIf="request.type == \'embed\'"></div>\n<div id="paystack-inline-container" *ngIf="request.type == \'inline\'">\n    <button type="button" (click)="payInline($event)" class="{{ request.classes }}" id="{{ request.id }}"> Pay </button> \n</div>\n',changeDetection:r.ChangeDetectionStrategy.OnPush}]}],t.ctorParameters=function(){return[{type:c},{type:n.HttpClient},{type:undefined,decorators:[{type:r.Optional},{type:r.Inject,args:[u]}]}]},t.propDecorators={request:[{type:r.Input}],success:[{type:r.Output}],failure:[{type:r.Output}]},t}(),l=function(){function t(){}return t.decorators=[{type:r.NgModule,args:[{declarations:[p],imports:[o.CommonModule],exports:[p]}]}],t}();t.NG_PAYSTACK_DATA=u,t.PAYSTACK_RESPONSE="PAYSTACK_RESPONSE",t.PaystackComponent=p,t.PaystackModule=l,t.ScriptLoaderService=c,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=isaiahiroko-ng-paystack.umd.min.js.map