!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/common"),require("@angular/common/http"),require("@angular/core"),require("@angular/forms"),require("rxjs/operators"),require("@angular/platform-browser"),require("rxjs")):"function"==typeof define&&define.amd?define("ngx-miniprofiler-overlay",["exports","@angular/common","@angular/common/http","@angular/core","@angular/forms","rxjs/operators","@angular/platform-browser","rxjs"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["ngx-miniprofiler-overlay"]={},e.ng.common,e.ng.common.http,e.ng.core,e.ng.forms,e.rxjs.operators,e.ng.platformBrowser,e.rxjs)}(this,(function(e,t,r,n,o,i,a,s){"use strict";
/*! *****************************************************************************
    Copyright (c) Microsoft Corporation.

    Permission to use, copy, modify, and/or distribute this software for any
    purpose with or without fee is hereby granted.

    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
    REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
    INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
    LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    PERFORMANCE OF THIS SOFTWARE.
    ***************************************************************************** */Object.create;function l(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}Object.create;var c=function(){this.isVisible=!1,this.api="/mini-profiler-resources",this.matcher=["*"],this.thresholds={good:function(e){return!1},okay:function(e){return!1},bad:function(e){return!1}},this.enableDuplicateDetection=!0,this.duplicateDetectionExclude=["Open","OpenAsync","Close","CloseAsync"],this.overlayTrigger=function(e){return"Escape"===e.key}};c.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new c},token:c,providedIn:"root"}),c.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}];var d=function(){function e(e,t){this.http=e,this.config=t,this.profilerResponses=new s.Subject,this.profilerResponses$=this.profilerResponses.asObservable(),this.cached=new Set}return e.prototype.handleIncomingIds=function(e){var t,r,n=this;try{for(var o=l(e),i=o.next();!i.done;i=o.next()){var a=i.value;this.cached.has(a)||(this.cached.add(a),this.http.get(this.config.api+"/results?id="+a).subscribe((function(e){var t,r,o=!0;try{for(var i=(t=void 0,l(n.config.matcher)),a=i.next();!a.done;a=i.next()){var s=a.value;if(!n.isMatch(s,e.Name)){o=!1;break}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}o&&n.profilerResponses.next(e)})))}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}},e.prototype.getProfilerResponses=function(){return this.profilerResponses$},e.prototype.isMatch=function(e,t){return e.startsWith("!")?(e=e.substring(1),!new RegExp("^"+e.replace(/\*/g,".*")+"$").test(t)):new RegExp("^"+e.replace(/\*/g,".*")+"$").test(t)},e}();d.decorators=[{type:n.Injectable}],d.ctorParameters=function(){return[{type:r.HttpClient},{type:c}]};var p=function(){function e(e,t,r){this.service=e,this.sanitizer=t,this.config=r,this.search=new o.FormControl(""),this.data=[],this.colspan=7}return e.prototype.onOverlayTriggered=function(e){this.config.overlayTrigger(e)&&(this.config.isVisible=!this.config.isVisible)},e.prototype.ngOnInit=function(){this.config.enableDuplicateDetection||this.colspan--,this.subscribeLookups()},e.prototype.onExpand=function(e){e.IsLoaded=!0,e.IsOpen=!e.IsOpen},e.prototype.trackById=function(e,t){return t.Id},e.prototype.openNewTab=function(e){e.IsOpen=!e.IsOpen,window.open(e.Url,"_blank")},e.prototype.subscribeLookups=function(){var e=this;this.responsesSubscription=this.service.getProfilerResponses().pipe(i.map((function(t){return t.Url=e.config.api+"/results?id="+t.Id,t.SafeUrl=e.sanitizer.bypassSecurityTrustResourceUrl(t.Url),t.Colour=e.handleThresholds(t.DurationMilliseconds),t.NumberOfSimilar=e.data.filter((function(e){return e.Name===t.Name})).length,e.gatherData(t),t}))).subscribe((function(t){e.addAndSort(t)})),this.searchSubscription=this.search.valueChanges.pipe(i.debounceTime(400),i.distinctUntilChanged()).subscribe((function(t){var r,n,o,i;if((null==t?void 0:t.trim().length)>0)try{for(var a=l(e.data),s=a.next();!s.done;s=a.next()){(p=s.value).HasValue=JSON.stringify(p).toLowerCase().includes(t.toLowerCase())}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}else try{for(var c=l(e.data),d=c.next();!d.done;d=c.next()){var p;(p=d.value).HasValue=!1}}catch(e){o={error:e}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(o)throw o.error}}}))},e.prototype.addAndSort=function(e){this.data.push(e);for(var t=this.data.length-1,r=this.data[t];t>0&&r.Started>this.data[t-1].Started;)this.data[t]=this.data[t-1],t-=1;this.data[t]=r},e.prototype.handleThresholds=function(e){var t,r,n;return(null===(t=this.config.thresholds)||void 0===t?void 0:t.good(e))?"profiler-good":(null===(r=this.config.thresholds)||void 0===r?void 0:r.okay(e))?"profiler-okay":(null===(n=this.config.thresholds)||void 0===n?void 0:n.bad(e))?"profiler-bad":""},e.prototype.gatherData=function(e){var t=this,r=0,n=0,o=new Set;JSON.stringify(e,(function(e,i){if(i){var a=i.CommandString,s=i.ExecuteType,l=i.DurationMilliseconds;a&&!t.config.duplicateDetectionExclude.includes(s)&&(n+=l,o.has(a)?r++:o.add(a))}return i})),this.config.enableDuplicateDetection&&(e.Duplicates=r);var i=r+o.size;e.SqlCount=i,e.SqlDurationMilliseconds=Math.round(10*n)/10,e.SqlColour=this.handleThresholds(n)},e.prototype.ngOnDestroy=function(){var e,t;null===(e=this.responsesSubscription)||void 0===e||e.unsubscribe(),null===(t=this.searchSubscription)||void 0===t||t.unsubscribe()},e}();p.decorators=[{type:n.Component,args:[{selector:"ngx-miniprofiler-overlay",template:'<div class="overlay" [style.display]="config.isVisible ? \'block\' : \'none\'">\r\n  <div class="toolbar">\r\n    <input class="search" placeholder="Search..." type="text" [formControl]="search"/>\r\n  </div>\r\n\r\n  <table class="collapsible-parent clickable">\r\n    <ng-container *ngFor="let item of data; index as i; trackBy: trackById">\r\n        <tr (click)="onExpand(item)" [class.active]="item.HasValue" class="collapsible-item">\r\n          <td class="heading" title="Request name">\r\n            {{ item.Name }}\r\n          </td>\r\n          <td class="info" title="Number of calls that hit the same endpoint">\r\n            {{ item.NumberOfSimilar }}\r\n          </td>\r\n          <td *ngIf="config.enableDuplicateDetection" class="info" title="Number of duplicate SQL calls" [class.profiler-bad]="item.Duplicates > 0">\r\n            {{ item.Duplicates }}\r\n          </td>\r\n          <td class="info" title="SQL duration and number of SQL calls">\r\n            <span class="{{ item.SqlColour }}">{{ item.SqlDurationMilliseconds }}ms</span> ({{ item.SqlCount }})\r\n          </td>\r\n          <td class="info" title="Total Duration">\r\n            <span class="{{ item.Colour }}">{{ item.DurationMilliseconds }}ms</span>\r\n          </td>\r\n          <td class="info" title="Request start">\r\n            {{ item.Started | date:\'h:mm:ss.SSS a\' }}\r\n          </td>\r\n          <td class="info clickable hide-border" (click)="openNewTab(item)" title="Open in new tab"><b>+</b></td>\r\n        </tr>\r\n        <tr>\r\n  \t      <td class="content hide-border frame" [style.display]="item.IsOpen ? \'table-cell\' : \'none\'" [attr.colspan]="colspan">\r\n            <iframe *ngIf="item.IsLoaded" [src]="item.SafeUrl" frame></iframe>\r\n          </td>\r\n        </tr>\r\n    </ng-container>\r\n  </table>\r\n</div>\r\n',styles:[".overlay{position:fixed;display:none;width:100%;height:100%;top:0;left:0;right:0;bottom:0;background-color:rgba(0,0,0,.8);z-index:99999;overflow:auto}.clickable{cursor:pointer}.collapsible-parent{width:100%;background-color:#272c34;color:#fff}td,th{border-right:1px solid #fff;padding-right:5px;padding-left:5px}.hide-border{border-right:0}.info{width:1%;white-space:nowrap;text-align:right}.frame{width:100%;height:500px;border:none}.active,.collapsible-item:hover{background-color:#555}.content{overflow:hidden;background-color:#212121}.duration{float:right}iframe{width:100%;height:500px;border:none}.toolbar{width:50%;margin:10px auto}.search{border-radius:5px;width:100%;border-color:transparent}.warning{color:red;font-weight:700}.badge{background-color:#222;color:#fff;display:inline-block;padding-left:8px;padding-right:8px;text-align:center;border-radius:50%;margin-right:5px}.profiler-good{color:green}.profiler-okay{color:#ff0}.profiler-bad{color:red}"]}]}],p.ctorParameters=function(){return[{type:d},{type:a.DomSanitizer},{type:c}]},p.propDecorators={onOverlayTriggered:[{type:n.HostListener,args:["document:keyup",["$event"]]}]};var u=function(){function e(e,t,r){this.elementRef=e,this.config=t,this.changeDetector=r}return e.prototype.ngOnInit=function(){var e=this;this.elementRef.nativeElement.onload=function(){e.elementRef.nativeElement.contentWindow.document.addEventListener("keyup",(function(t){e.config.overlayTrigger(t)&&(e.config.isVisible=!e.config.isVisible,e.changeDetector.detectChanges())}))}},e}();u.decorators=[{type:n.Directive,args:[{selector:"[frame]"}]}],u.ctorParameters=function(){return[{type:n.ElementRef},{type:c},{type:n.ChangeDetectorRef}]};var f=function(){function e(e){this.service=e,this.key="x-miniprofiler-ids"}return e.prototype.intercept=function(e,t){var n=this;return t.handle(e).pipe(i.tap((function(e){var t,o;if(e.type===r.HttpEventType.Response||e instanceof r.HttpResponse){var i=e.headers.getAll(n.key);if(i)try{for(var a=l(i),s=a.next();!s.done;s=a.next()){var c=s.value,d=JSON.parse(c);d.length>0&&n.service.handleIncomingIds(d)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(t)throw t.error}}}})))},e}();f.decorators=[{type:n.Injectable}],f.ctorParameters=function(){return[{type:d}]};var h=function(){};h.decorators=[{type:n.NgModule,args:[{declarations:[p,u],imports:[t.CommonModule,r.HttpClientModule,o.ReactiveFormsModule],providers:[f,d,c],exports:[p]}]}],e.FrameDirective=u,e.NgxMiniprofilerOverlayComponent=p,e.NgxMiniprofilerOverlayInterceptor=f,e.NgxMiniprofilerOverlayModule=h,e.NgxMiniprofilerOverlayService=d,e.NgxMiniprofilerOverlayServiceConfig=c,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=ngx-miniprofiler-overlay.umd.min.js.map