!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("ngx-window-token"),require("rxjs"),require("@angular/common"),require("@angular/core")):"function"==typeof define&&define.amd?define("@dllcn/ngx-clipboard",["exports","ngx-window-token","rxjs","@angular/common","@angular/core"],t):t((e.dllcn=e.dllcn||{},e.dllcn["ngx-clipboard"]={}),e.i2,e.rxjs,e.ng.common,e.ng.core)}(this,function(e,t,r,n,o){"use strict";var i=(Object.defineProperty(s.prototype,"isSupported",{get:function(){return!!this.document.queryCommandSupported&&!!this.document.queryCommandSupported("copy")&&!!this.window},enumerable:!0,configurable:!0}),s.prototype.isTargetValid=function(e){if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){if(e.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');return!0}throw new Error("Target should be input or textarea")},s.prototype.copyFromInputElement=function(e){try{this.selectTarget(e);var t=this.copyText();return this.clearSelection(e,this.window),t&&this.isCopySuccessInIE11()}catch(r){return!1}},s.prototype.isCopySuccessInIE11=function(){var e=this.window.clipboardData;return!(e&&e.getData&&!e.getData("Text"))},s.prototype.copyFromContent=function(e,t){if(void 0===t&&(t=this.window.document.body),this.tempTextArea&&!t.contains(this.tempTextArea)&&this.destroy(this.tempTextArea.parentElement),!this.tempTextArea){this.tempTextArea=this.createTempTextArea(this.document,this.window);try{t.appendChild(this.tempTextArea)}catch(r){throw new Error("Container should be a Dom element")}}return this.tempTextArea.value=e,this.copyFromInputElement(this.tempTextArea)},s.prototype.destroy=function(e){void 0===e&&(e=this.window.document.body),this.tempTextArea&&(e.removeChild(this.tempTextArea),this.tempTextArea=undefined)},s.prototype.selectTarget=function(e){return e.select(),e.setSelectionRange(0,e.value.length),e.value.length},s.prototype.copyText=function(){return this.document.execCommand("copy")},s.prototype.clearSelection=function(e,t){e&&e.focus(),t.getSelection().removeAllRanges()},s.prototype.createTempTextArea=function(e,t){var r,n="rtl"===e.documentElement.getAttribute("dir");(r=e.createElement("textarea")).style.fontSize="12pt",r.style.border="0",r.style.padding="0",r.style.margin="0",r.style.position="absolute",r.style[n?"right":"left"]="-9999px";var o=t.pageYOffset||e.documentElement.scrollTop;return r.style.top=o+"px",r.setAttribute("readonly",""),r},s.prototype.pushCopyReponse=function(e){this.copySubject.next(e)},s.decorators=[{type:o.Injectable,args:[{providedIn:"root"}]}],s.ctorParameters=function(){return[{type:undefined,decorators:[{type:o.Inject,args:[n.DOCUMENT]}]},{type:undefined,decorators:[{type:o.Optional},{type:o.Inject,args:[t.WINDOW]}]}]},s.ngInjectableDef=o.defineInjectable({factory:function(){return new s(o.inject(n.DOCUMENT),o.inject(t.WINDOW,8))},token:s,providedIn:"root"}),s);function s(e,t){this.document=e,this.window=t,this.copySubject=new r.Subject,this.copyResponse$=this.copySubject.asObservable()}var c=(a.prototype.ngOnInit=function(){},a.prototype.ngOnDestroy=function(){this.clipboardSrv.destroy(this.container)},a.prototype.onClick=function(e){this.clipboardSrv.isSupported?this.targetElm&&this.clipboardSrv.isTargetValid(this.targetElm)?this.handleResult(this.clipboardSrv.copyFromInputElement(this.targetElm),this.targetElm.value,e):this.cbContent&&this.handleResult(this.clipboardSrv.copyFromContent(this.cbContent,this.container),this.cbContent,e):this.handleResult(!1,undefined,e)},a.prototype.handleResult=function(e,t,r){var n={isSuccess:e,event:r};e?(n=Object.assign(n,{content:t,successMessage:this.cbSuccessMsg}),this.cbOnSuccess.emit(n)):this.cbOnError.emit(n),this.clipboardSrv.pushCopyReponse(n)},a.decorators=[{type:o.Directive,args:[{selector:"[ngxClipboard]"}]}],a.ctorParameters=function(){return[{type:i}]},a.propDecorators={targetElm:[{type:o.Input,args:["ngxClipboard"]}],container:[{type:o.Input}],cbContent:[{type:o.Input}],cbSuccessMsg:[{type:o.Input}],cbOnSuccess:[{type:o.Output}],cbOnError:[{type:o.Output}],onClick:[{type:o.HostListener,args:["click",["$event.target"]]}]},a);function a(e){this.clipboardSrv=e,this.cbOnSuccess=new o.EventEmitter,this.cbOnError=new o.EventEmitter}var p=(u.prototype.ngOnInit=function(){this._clipboardService.isSupported&&this._viewContainerRef.createEmbeddedView(this._templateRef)},u.decorators=[{type:o.Directive,args:[{selector:"[ngxClipboardIfSupported]"}]}],u.ctorParameters=function(){return[{type:i},{type:o.ViewContainerRef},{type:o.TemplateRef}]},u);function u(e,t,r){this._clipboardService=e,this._viewContainerRef=t,this._templateRef=r}var d=(l.decorators=[{type:o.NgModule,args:[{imports:[n.CommonModule],declarations:[c,p],exports:[c,p]}]}],l);function l(){}e.ClipboardService=i,e.ClipboardDirective=c,e.ClipboardModule=d,e.ClipboardIfSupportedDirective=p,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=dllcn-ngx-clipboard.umd.min.js.map