/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/cdk/coercion"),require("@angular/cdk/scrolling"),require("@angular/common"),require("@angular/core"),require("rxjs"),require("rxjs/operators"),require("@angular/cdk/platform"),require("@angular/cdk/bidi"),require("@angular/cdk/portal"),require("@angular/cdk/keycodes")):"function"==typeof define&&define.amd?define("@angular/cdk/overlay",["exports","@angular/cdk/coercion","@angular/cdk/scrolling","@angular/common","@angular/core","rxjs","rxjs/operators","@angular/cdk/platform","@angular/cdk/bidi","@angular/cdk/portal","@angular/cdk/keycodes"],e):e((t.ng=t.ng||{},t.ng.cdk=t.ng.cdk||{},t.ng.cdk.overlay={}),t.ng.cdk.coercion,t.ng.cdk.scrolling,t.ng.common,t.ng.core,t.rxjs,t.rxjs.operators,t.ng.cdk.platform,t.ng.cdk.bidi,t.ng.cdk.portal,t.ng.cdk.keycodes)}(this,function(t,e,i,o,n,r,s,a,l,h,c){"use strict";function p(t,e){function i(){this.constructor=t}w(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}function u(){return Error("Scroll strategy has already been attached.")}function d(t,e){return e.some(function(e){var i=t.bottome.bottom,n=t.righte.right;return i||o||n||r})}function _(t,e){return e.some(function(e){var i=t.tope.bottom,n=t.lefte.right;return i||o||n||r})}function f(t,e){if("top"!==e&&"bottom"!==e&&"center"!==e)throw Error("ConnectedPosition: Invalid "+t+' "'+e+'". Expected "top", "bottom" or "center".')}function y(t,e){if("start"!==e&&"end"!==e&&"center"!==e)throw Error("ConnectedPosition: Invalid "+t+' "'+e+'". Expected "start", "end" or "center".')}function g(t,e){return t||new B(e)}function v(t,e){return t||new M(e)}function m(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t}function b(t){return function(){return t.scrollStrategies.reposition()}}var w=function(t,e){return(w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},O=function(){return O=Object.assign||function(t){for(var e,i=1,o=arguments.length;ie.height||t.scrollWidth>e.width},t}(),P=function(){function t(t,e,i,o){var n=this;this._scrollDispatcher=t,this._ngZone=e,this._viewportRuler=i,this._config=o,this._scrollSubscription=null,this._detach=function(){n.disable(),n._overlayRef.hasAttached()&&n._ngZone.run(function(){return n._overlayRef.detach()})}}return t.prototype.attach=function(t){if(this._overlayRef)throw u();this._overlayRef=t},t.prototype.enable=function(){var t=this;if(!this._scrollSubscription){var e=this._scrollDispatcher.scrolled(0);this._config&&this._config.threshold&&this._config.threshold>1?(this._initialScrollPosition=this._viewportRuler.getViewportScrollPosition().top,this._scrollSubscription=e.subscribe(function(){var e=t._viewportRuler.getViewportScrollPosition().top;Math.abs(e-t._initialScrollPosition)>t._config.threshold?t._detach():t._overlayRef.updatePosition()})):this._scrollSubscription=e.subscribe(this._detach)}},t.prototype.disable=function(){this._scrollSubscription&&(this._scrollSubscription.unsubscribe(),this._scrollSubscription=null)},t.prototype.detach=function(){this.disable(),this._overlayRef=null},t}(),k=function(){function t(){}return t.prototype.enable=function(){},t.prototype.disable=function(){},t.prototype.attach=function(){},t}(),S=function(){function t(t,e,i,o){this._scrollDispatcher=t,this._viewportRuler=e,this._ngZone=i,this._config=o,this._scrollSubscription=null}return t.prototype.attach=function(t){if(this._overlayRef)throw u();this._overlayRef=t},t.prototype.enable=function(){var t=this;if(!this._scrollSubscription){var e=this._config?this._config.scrollThrottle:0;this._scrollSubscription=this._scrollDispatcher.scrolled(e).subscribe(function(){if(t._overlayRef.updatePosition(),t._config&&t._config.autoClose){var e=t._overlayRef.overlayElement.getBoundingClientRect(),i=t._viewportRuler.getViewportSize(),o=i.width,n=i.height;d(e,[{width:o,height:n,bottom:n,right:o,top:0,left:0}])&&(t.disable(),t._ngZone.run(function(){return t._overlayRef.detach()}))}})}},t.prototype.disable=function(){this._scrollSubscription&&(this._scrollSubscription.unsubscribe(),this._scrollSubscription=null)},t.prototype.detach=function(){this.disable(),this._overlayRef=null},t}(),E=function(){function t(t,e,i,o){var n=this;this._scrollDispatcher=t,this._viewportRuler=e,this._ngZone=i,this.noop=function(){return new k},this.close=function(t){return new P(n._scrollDispatcher,n._ngZone,n._viewportRuler,t)},this.block=function(){return new C(n._viewportRuler,n._document)},this.reposition=function(t){return new S(n._scrollDispatcher,n._viewportRuler,n._ngZone,t)},this._document=o}return t.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],t.ctorParameters=function(){return[{type:i.ScrollDispatcher},{type:i.ViewportRuler},{type:n.NgZone},{type:void 0,decorators:[{type:n.Inject,args:[o.DOCUMENT]}]}]},t.ngInjectableDef=n.ɵɵdefineInjectable({factory:function(){return new t(n.ɵɵinject(i.ScrollDispatcher),n.ɵɵinject(i.ViewportRuler),n.ɵɵinject(n.NgZone),n.ɵɵinject(o.DOCUMENT))},token:t,providedIn:"root"}),t}(),R=function(){function t(t){if(this.scrollStrategy=new k,this.panelClass="",this.hasBackdrop=!1,this.backdropClass="cdk-overlay-dark-backdrop",this.disposeOnNavigation=!1,t)for(var e=Object.keys(t),i=0,o=e;i-1;o--)if(i[o]._keydownEventSubscriptions>0){i[o]._keydownEvents.next(t);break}},this._document=t}return t.prototype.ngOnDestroy=function(){this._detach()},t.prototype.add=function(t){this.remove(t),this._isAttached||(this._document.body.addEventListener("keydown",this._keydownListener),this._isAttached=!0),this._attachedOverlays.push(t)},t.prototype.remove=function(t){var e=this._attachedOverlays.indexOf(t);e>-1&&this._attachedOverlays.splice(e,1),0===this._attachedOverlays.length&&this._detach()},t.prototype._detach=function(){this._isAttached&&(this._document.body.removeEventListener("keydown",this._keydownListener),this._isAttached=!1)},t.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],t.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[o.DOCUMENT]}]}]},t.ngInjectableDef=n.ɵɵdefineInjectable({factory:function(){return new t(n.ɵɵinject(o.DOCUMENT))},token:t,providedIn:"root"}),t}(),I={provide:B,deps:[[new n.Optional,new n.SkipSelf,B],o.DOCUMENT],useFactory:g},M=function(){function t(t){this._document=t}return t.prototype.ngOnDestroy=function(){this._containerElement&&this._containerElement.parentNode&&this._containerElement.parentNode.removeChild(this._containerElement)},t.prototype.getContainerElement=function(){return this._containerElement||this._createContainer(),this._containerElement},t.prototype._createContainer=function(){for(var t=this._document.getElementsByClassName("cdk-overlay-container"),e=0;eu&&(u=y,p=f)}return this._isPushed=!1,void this._applyPosition(p.position,p.origin)}if(this._canPush)return this._isPushed=!0,void this._applyPosition(t.position,t.originPoint);this._applyPosition(t.position,t.originPoint)}},t.prototype.detach=function(){this._clearPanelClasses(),this._lastPosition=null,this._previousPushAmount=null,this._resizeSubscription.unsubscribe()},t.prototype.dispose=function(){this._isDisposed||(this._boundingBox&&m(this._boundingBox.style,{top:"",left:"",right:"",bottom:"",height:"",width:"",alignItems:"",justifyContent:""}),this._pane&&this._resetOverlayElementStyles(),this._overlayRef&&this._overlayRef.hostElement.classList.remove("cdk-overlay-connected-position-bounding-box"),this.detach(),this._positionChanges.complete(),this._overlayRef=this._boundingBox=null,this._isDisposed=!0)},t.prototype.reapplyLastPosition=function(){if(!this._isDisposed&&(!this._platform||this._platform.isBrowser)){this._originRect=this._getOriginRect(),this._overlayRect=this._pane.getBoundingClientRect(),this._viewportRect=this._getNarrowedViewportRect();var t=this._lastPosition||this._preferredPositions[0],e=this._getOriginPoint(this._originRect,t);this._applyPosition(t,e)}},t.prototype.withScrollableContainers=function(t){return this._scrollables=t,this},t.prototype.withPositions=function(t){return this._preferredPositions=t,-1===t.indexOf(this._lastPosition)&&(this._lastPosition=null),this._validatePositions(),this},t.prototype.withViewportMargin=function(t){return this._viewportMargin=t,this},t.prototype.withFlexibleDimensions=function(t){return void 0===t&&(t=!0),this._hasFlexibleDimensions=t,this},t.prototype.withGrowAfterOpen=function(t){return void 0===t&&(t=!0),this._growAfterOpen=t,this},t.prototype.withPush=function(t){return void 0===t&&(t=!0),this._canPush=t,this},t.prototype.withLockedPosition=function(t){return void 0===t&&(t=!0),this._positionLocked=t,this},t.prototype.setOrigin=function(t){return this._origin=t,this},t.prototype.withDefaultOffsetX=function(t){return this._offsetX=t,this},t.prototype.withDefaultOffsetY=function(t){return this._offsetY=t,this},t.prototype.withTransformOriginOn=function(t){return this._transformOriginSelector=t,this},t.prototype._getOriginPoint=function(t,e){var i;if("center"==e.originX)i=t.left+t.width/2;else{var o=this._isRtl()?t.right:t.left,n=this._isRtl()?t.left:t.right;i="start"==e.originX?o:n}var r;return r="center"==e.originY?t.top+t.height/2:"top"==e.originY?t.top:t.bottom,{x:i,y:r}},t.prototype._getOverlayPoint=function(t,e,i){var o;o="center"==i.overlayX?-e.width/2:"start"===i.overlayX?this._isRtl()?-e.width:0:this._isRtl()?0:-e.width;var n;return n="center"==i.overlayY?-e.height/2:"top"==i.overlayY?0:-e.height,{x:t.x+o,y:t.y+n}},t.prototype._getOverlayFit=function(t,e,i,o){var n=t.x,r=t.y,s=this._getOffset(o,"x"),a=this._getOffset(o,"y");s&&(n+=s),a&&(r+=a);var l=0-n,h=n+e.width-i.width,c=0-r,p=r+e.height-i.height,u=this._subtractOverflows(e.width,l,h),d=this._subtractOverflows(e.height,c,p),_=u*d;return{visibleArea:_,isCompletelyWithinViewport:e.width*e.height===_,fitsInViewportVertically:d===e.height,fitsInViewportHorizontally:u==e.width}},t.prototype._canFitWithFlexibleDimensions=function(t,e,i){if(this._hasFlexibleDimensions){var o=i.bottom-e.y,n=i.right-e.x,r=this._overlayRef.getConfig().minHeight,s=this._overlayRef.getConfig().minWidth,a=t.fitsInViewportVertically||null!=r&&r<=o,l=t.fitsInViewportHorizontally||null!=s&&s<=n;return a&&l}return!1},t.prototype._pushOverlayOnScreen=function(t,e,i){if(this._previousPushAmount&&this._positionLocked)return{x:t.x+this._previousPushAmount.x,y:t.y+this._previousPushAmount.y};var o=this._viewportRect,n=Math.max(t.x+e.width-o.right,0),r=Math.max(t.y+e.height-o.bottom,0),s=Math.max(o.top-i.top-t.y,0),a=Math.max(o.left-i.left-t.x,0),l=0,h=0;return l=e.width<=o.width?a||-n:t.xl&&!this._isInitialRender&&!this._growAfterOpen&&(o=t.y-l/2)}var h,c,p,u="start"===e.overlayX&&!s||"end"===e.overlayX&&s,d="end"===e.overlayX&&!s||"start"===e.overlayX&&s;if(d)p=r.width-t.x+this._viewportMargin,h=t.x-this._viewportMargin;else if(u)c=t.x,h=r.right-t.x;else{var a=Math.min(r.right-t.x+r.left,t.x),_=this._lastBoundingBoxSize.width;h=2*a,c=t.x-a,h>_&&!this._isInitialRender&&!this._growAfterOpen&&(c=t.x-_/2)}return{top:o,left:c,bottom:n,right:p,width:h,height:i}},t.prototype._setBoundingBoxStyles=function(t,i){var o=this._calculateBoundingBoxRect(t,i);this._isInitialRender||this._growAfterOpen||(o.height=Math.min(o.height,this._lastBoundingBoxSize.height),o.width=Math.min(o.width,this._lastBoundingBoxSize.width));var n={};if(this._hasExactPosition())n.top=n.left="0",n.bottom=n.right="",n.width=n.height="100%";else{var r=this._overlayRef.getConfig().maxHeight,s=this._overlayRef.getConfig().maxWidth;n.height=e.coerceCssPixelValue(o.height),n.top=e.coerceCssPixelValue(o.top),n.bottom=e.coerceCssPixelValue(o.bottom),n.width=e.coerceCssPixelValue(o.width),n.left=e.coerceCssPixelValue(o.left),n.right=e.coerceCssPixelValue(o.right),"center"===i.overlayX?n.alignItems="center":n.alignItems="end"===i.overlayX?"flex-end":"flex-start","center"===i.overlayY?n.justifyContent="center":n.justifyContent="bottom"===i.overlayY?"flex-end":"flex-start",r&&(n.maxHeight=e.coerceCssPixelValue(r)),s&&(n.maxWidth=e.coerceCssPixelValue(s))}this._lastBoundingBoxSize=o,m(this._boundingBox.style,n)},t.prototype._resetBoundingBoxStyles=function(){m(this._boundingBox.style,{top:"0",left:"0",right:"0",bottom:"0",height:"",width:"",alignItems:"",justifyContent:""})},t.prototype._resetOverlayElementStyles=function(){m(this._pane.style,{top:"",left:"",bottom:"",right:"",position:"",transform:""})},t.prototype._setOverlayElementStyles=function(t,e){var i={};if(this._hasExactPosition()){var o=this._viewportRuler.getViewportScrollPosition();m(i,this._getExactOverlayY(e,t,o)),m(i,this._getExactOverlayX(e,t,o))}else i.position="static";var n="",r=this._getOffset(e,"x"),s=this._getOffset(e,"y");r&&(n+="translateX("+r+"px) "),s&&(n+="translateY("+s+"px)"),i.transform=n.trim(),this._hasFlexibleDimensions&&this._overlayRef.getConfig().maxHeight&&(i.maxHeight=""),this._hasFlexibleDimensions&&this._overlayRef.getConfig().maxWidth&&(i.maxWidth=""),m(this._pane.style,i)},t.prototype._getExactOverlayY=function(t,i,o){var n={top:null,bottom:null},r=this._getOverlayPoint(i,this._overlayRect,t);this._isPushed&&(r=this._pushOverlayOnScreen(r,this._overlayRect,o));var s=this._overlayContainer.getContainerElement().getBoundingClientRect().top;if(r.y-=s,"bottom"===t.overlayY){var a=this._document.documentElement.clientHeight;n.bottom=a-(r.y+this._overlayRect.height)+"px"}else n.top=e.coerceCssPixelValue(r.y);return n},t.prototype._getExactOverlayX=function(t,i,o){var n={left:null,right:null},r=this._getOverlayPoint(i,this._overlayRect,t);this._isPushed&&(r=this._pushOverlayOnScreen(r,this._overlayRect,o));if("right"===(this._isRtl()?"end"===t.overlayX?"left":"right":"end"===t.overlayX?"right":"left")){var s=this._document.documentElement.clientWidth;n.right=s-(r.x+this._overlayRect.width)+"px"}else n.left=e.coerceCssPixelValue(r.x);return n},t.prototype._getScrollVisibility=function(){var t=this._getOriginRect(),e=this._pane.getBoundingClientRect(),i=this._scrollables.map(function(t){return t.getElementRef().nativeElement.getBoundingClientRect()});return{isOriginClipped:_(t,i),isOriginOutsideView:d(t,i),isOverlayClipped:_(e,i),isOverlayOutsideView:d(e,i)}},t.prototype._subtractOverflows=function(t){for(var e=[],i=1;i