!function(t,p){"object"==typeof exports&&"undefined"!=typeof module?p(exports,require("@angular/core"),require("rxjs"),require("@angular/platform-browser"),require("@angular/common")):"function"==typeof define&&define.amd?define("@clementvh/angular-popup",["exports","@angular/core","rxjs","@angular/platform-browser","@angular/common"],p):p((t.clementvh=t.clementvh||{},t.clementvh["angular-popup"]={}),t.ng.core,t.rxjs,t.ng.platformBrowser,t.ng.common)}(this,function(t,p,o,n,e){"use strict";var i=function(){function t(){this.popupSource=new o.Subject,this.popupSource$=this.popupSource.asObservable(),this.iframeLoadSource=new o.Subject,this.iframeLoadSource$=this.iframeLoadSource.asObservable()}return t.prototype.openHtml=function(t,p){void 0===p&&(p={}),this.popupSource.next({component:t,options:p,type:"html-popup"})},t.prototype.openConfirm=function(t,p,o){void 0===o&&(o={}),this.popupSource.next({title:t,text:p,options:o,type:"confirm-popup"})},t.prototype.openIframe=function(t,p){void 0===p&&(p={}),this.popupSource.next({url:t,options:p,type:"iframe-popup"})},t.prototype.dispatchLoadEvent=function(){this.iframeLoadSource.next()},t.prototype.close=function(){this.popupSource.next()},t.decorators=[{type:p.Injectable}],t.ctorParameters=function(){return[]},t}(),r=function(){function t(t){this.viewContainerRef=t}return t.decorators=[{type:p.Directive,args:[{selector:"[popup-host]"}]}],t.ctorParameters=function(){return[{type:p.ViewContainerRef}]},t}(),a=function(t,p){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,p){t.__proto__=p}||function(t,p){for(var o in p)p.hasOwnProperty(o)&&(t[o]=p[o])})(t,p)};function s(t,p){function o(){this.constructor=t}a(t,p),t.prototype=null===p?Object.create(p):(o.prototype=p.prototype,new o)}var c=function u(t){Object.assign(this,t)},l=function(t){function p(){return null!==t&&t.apply(this,arguments)||this}return s(p,t),p}(c),f=function(){function t(t){this.popup=t}return t.prototype.load=function(){this.popup.dispatchLoadEvent()},t.decorators=[{type:p.Component,args:[{selector:"app-iframe",template:'<iframe #iframe (load)="load()" [src]="url | urlSafe" *ngIf="url" frameborder="0"></iframe>'}]}],t.ctorParameters=function(){return[{type:i}]},t.propDecorators={iframe:[{type:p.ViewChild,args:["iframe"]}]},t}(),m=function(p){function t(){var t=null!==p&&p.apply(this,arguments)||this;return t.component=f,t}return s(t,p),t}(c),h=function(){function t(){}return t.decorators=[{type:p.Component,args:[{selector:"app-confirm",template:'<div class="app-popup-title" [innerHtml]="title | htmlSafe"></div>\n<div class="app-popup-text" [innerHtml]="text | htmlSafe"></div>',styles:[".app-popup-title{font-size:20px;text-align:center;padding:30px 15px 15px}.app-popup-text{font-size:18px;text-align:center}"]}]}],t}(),d=function(p){function t(){var t=null!==p&&p.apply(this,arguments)||this;return t.component=h,t}return s(t,p),t}(c),g=function(){function t(t,p){var o=this;this.popup=t,this.componentFactoryResolver=p,this.isOpen=!1,this.isConfirm=!1,this.isIframe=!1,this.isHtml=!1,this.spinning=!1,this.options={},this.default_options={id:"",dismissable:!0,title:"Title",text:"Text",cancelText:"Cancel",confirmText:"Confirm",showClose:!0,spin:!0},this.handleOpenEvent=function(t){t?"html-popup"===t.type?o.openHtml(new l(t)):"confirm-popup"===t.type?o.openConfirm(new d(t)):"iframe-popup"===t.type&&o.openIframe(new m(t)):o.close()},this.handleLoadEvent=function(){o.options.spin&&(o.spinning=!1)}}return t.prototype.ngOnInit=function(){this.popup.popupSource$.subscribe(this.handleOpenEvent),this.popup.iframeLoadSource$.subscribe(this.handleLoadEvent)},t.prototype.openHtml=function(t){var p=this.componentFactoryResolver.resolveComponentFactory(t.component);this.openPopup(p,t.options),this.isHtml=!0},t.prototype.openIframe=function(t){var p=this.componentFactoryResolver.resolveComponentFactory(t.component);this.openPopup(p,t.options).instance.url=t.url,this.isIframe=!0},t.prototype.openConfirm=function(t){var p=this.componentFactoryResolver.resolveComponentFactory(t.component),o=this.openPopup(p,t.options);o.instance.title=t.title,o.instance.text=t.text,this.isConfirm=!0},t.prototype.openPopup=function(t,p){this.close(),this.isOpen=!0;var o=JSON.parse(JSON.stringify(this.default_options));return this.options=Object.assign(o,p),this.options.spin&&(this.spinning=!0),this.appPopup.viewContainerRef.createComponent(t)},t.prototype.dismiss=function(t){"app-popup"===t.target.id&&this.options.dismissable&&this.close()},t.prototype.cancel=function(){var t=this.options.cancel;"function"==typeof t&&t()},t.prototype.confirm=function(){var t=this.options.confirm;"function"==typeof t&&t()},t.prototype.close=function(){this.appPopup.viewContainerRef.clear(),this.isOpen=!1,this.isConfirm=!1,this.isIframe=!1,this.isHtml=!1,this.spinning=!1},t.decorators=[{type:p.Component,args:[{selector:"ng-popup",template:'<div id="app-popup" [ngClass]="{\'open\': isOpen, \'confirm\': isConfirm, \'iframe\': isIframe}" (click)="dismiss($event)">\n\n  <div class="app-popup-container" [ngClass]="options.id">\n\n    <div class="app-popup-spinner" *ngIf="isOpen && isIframe && options.spin && spinning"></div>\n\n    <div class="app-popup-close" (click)="close()" *ngIf="options.showClose"></div>\n\n    <div class="app-popup-content" [ngClass]="{\'spin\': isOpen && isIframe && options.spin && spinning}">\n\n      <ng-template popup-host></ng-template>\n\n    </div>\n\n    <div class="app-popup-confirm">\n\n      <p class="popup-label-cancel" (click)="cancel()">{{ options.cancelText }}</p>\n\n      <p class="popup-label-confirm" (click)="confirm()">{{ options.confirmText }}</p>\n\n    </div>\n\n  </div>\n\n</div>',styles:["#app-popup{display:none;position:absolute;top:0;left:0;height:100vh;width:100vw;background-color:rgba(0,0,0,.6);align-items:center;justify-content:center}#app-popup .app-popup-container{position:relative;min-width:300px;max-width:80vw;min-height:250px;max-height:80vh;background-color:#fff;border-radius:3px;box-shadow:0 1px 4px 0 rgba(0,0,0,.08);display:flex;flex-direction:column}#app-popup .app-popup-container .app-popup-close{position:absolute;z-index:1;top:16px;right:16px;height:25px;width:25px;background-image:url(assets/close.svg);background-size:10px 10px;background-position:center;background-repeat:no-repeat;cursor:pointer}#app-popup .app-popup-container .app-popup-content{box-sizing:border-box;padding:20px 30px;max-height:calc(80vh - 30px);overflow:hidden;overflow-y:auto}#app-popup.confirm .app-popup-container{max-width:500px}#app-popup .app-popup-container .app-popup-content.spin{-webkit-filter:blur(3px);filter:blur(3px)}#app-popup .app-popup-container .app-popup-confirm{width:100%;height:60px;display:none;margin-top:auto;border-top:1px solid}#app-popup .app-popup-container .app-popup-confirm>p{width:50%;height:100%;cursor:pointer;line-height:60px;text-align:center;margin:0;font-size:24px}#app-popup .app-popup-container .app-popup-confirm>p.popup-label-cancel{border-right:1px solid}#app-popup.confirm .app-popup-container .app-popup-content{max-height:calc(80vh - 90px)}#app-popup.confirm .app-popup-container .app-popup-confirm,#app-popup.open{display:flex}#app-popup .app-popup-spinner{height:100%;width:100%;position:absolute;top:0;left:0;background-color:transparent;z-index:10}#app-popup .app-popup-spinner:after{content:'';position:absolute;top:50%;left:50%;height:40px;width:40px;-webkit-transform:translate3d(-50%,-50%,0);transform:translate3d(-50%,-50%,0);border:3px solid gray;border-top-color:transparent;border-radius:50%;-webkit-animation:1s linear infinite spin;animation:1s linear infinite spin}@keyframes spin{0%{-webkit-transform:translate(-50%,-50%) rotate(0);transform:translate(-50%,-50%) rotate(0)}100%{-webkit-transform:translate(-50%,-50%) rotate(360deg);transform:translate(-50%,-50%) rotate(360deg)}}@-webkit-keyframes spin{0%{-webkit-transform:translate(-50%,-50%) rotate(0);transform:translate(-50%,-50%) rotate(0)}100%{-webkit-transform:translate(-50%,-50%) rotate(360deg);transform:translate(-50%,-50%) rotate(360deg)}}"]}]}],t.ctorParameters=function(){return[{type:i},{type:p.ComponentFactoryResolver}]},t.propDecorators={appPopup:[{type:p.ViewChild,args:[r]}]},t}(),y=function(){function t(t){this.sanitizer=t}return t.prototype.transform=function(t){return this.sanitizer.bypassSecurityTrustResourceUrl(t)},t.decorators=[{type:p.Pipe,args:[{name:"urlSafe"}]}],t.ctorParameters=function(){return[{type:n.DomSanitizer}]},t}(),x=function(){function t(t){this.sanitizer=t}return t.prototype.transform=function(t){return this.sanitizer.bypassSecurityTrustHtml(t)},t.decorators=[{type:p.Pipe,args:[{name:"htmlSafe"}]}],t.ctorParameters=function(){return[{type:n.DomSanitizer}]},t}(),v=function(){function t(){}return t.decorators=[{type:p.NgModule,args:[{imports:[e.CommonModule],providers:[i],declarations:[g,r,f,h,y,x],entryComponents:[f,h],exports:[g]}]}],t}();t.PopupModule=v,t.PopupService=i,t.ConfirmPopupItem=d,t.HtmlPopupItem=l,t.IframePopupItem=m,t.PopupItem=c,t.ɵd=h,t.ɵf=x,t.ɵc=f,t.ɵe=y,t.ɵa=g,t.ɵb=r,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=clementvh-angular-popup.umd.min.js.map