import{NgModule,Component,ElementRef,Input,Output,EventEmitter,ChangeDetectionStrategy,ViewChild,ContentChildren,ViewEncapsulation,ChangeDetectorRef}from"@angular/core";import{CommonModule}from"@angular/common";import{SharedModule,PrimeTemplate}from"primeng/api";import{UniqueComponentId}from"primeng/utils";import{DomHandler}from"primeng/dom";import{RippleModule}from"primeng/ripple";export class Galleria{constructor(e,t){this.element=e,this.cd=t,this.fullScreen=!1,this.numVisible=3,this.showItemNavigators=!1,this.showThumbnailNavigators=!0,this.showItemNavigatorsOnHover=!1,this.changeItemOnIndicatorHover=!1,this.circular=!1,this.autoPlay=!1,this.transitionInterval=4e3,this.showThumbnails=!0,this.thumbnailsPosition="bottom",this.verticalThumbnailViewPortHeight="300px",this.showIndicators=!1,this.showIndicatorsOnItem=!1,this.indicatorsPosition="bottom",this.baseZIndex=0,this.activeIndexChange=new EventEmitter,this.visibleChange=new EventEmitter,this._visible=!1,this._activeIndex=0}get activeIndex(){return this._activeIndex}set activeIndex(e){this._activeIndex=e}get visible(){return this._visible}set visible(e){this._visible=e}ngAfterContentInit(){this.templates.forEach(e=>{switch(e.getType()){case"header":this.headerFacet=e.template;break;case"footer":this.footerFacet=e.template;break;case"indicator":this.indicatorFacet=e.template;break;case"caption":this.captionFacet=e.template}})}ngOnChanges(e){this.fullScreen&&e.visible&&(e.visible.currentValue?(DomHandler.addClass(document.body,"p-overflow-hidden"),this.zIndex=String(this.baseZIndex+ ++DomHandler.zindex)):DomHandler.removeClass(document.body,"p-overflow-hidden"))}onMaskHide(){this.visible=!1,this.visibleChange.emit(!1)}onActiveItemChange(e){this.activeIndex!==e&&(this.activeIndex=e,this.activeIndexChange.emit(e))}ngOnDestroy(){this.fullScreen&&DomHandler.removeClass(document.body,"p-overflow-hidden")}};Galleria.decorators=[{type:Component,args:[{selector:"p-galleria",template:'\n
\n\n \n \n \n ',changeDetection:ChangeDetectionStrategy.OnPush,encapsulation:ViewEncapsulation.None,styles:[".p-galleria-content,.p-galleria-item-wrapper{display:flex;flex-direction:column}.p-galleria-item-wrapper{position:relative}.p-galleria-item-container{display:flex;height:100%;position:relative}.p-galleria-item-nav{align-items:center;display:inline-flex;justify-content:center;margin-top:-.5rem;overflow:hidden;position:absolute;top:50%}.p-galleria-item-prev{border-bottom-left-radius:0;border-top-left-radius:0;left:0}.p-galleria-item-next{border-bottom-right-radius:0;border-top-right-radius:0;right:0}.p-galleria-item{align-items:center;display:flex;height:100%;justify-content:center;width:100%}.p-galleria-item-nav-onhover .p-galleria-item-nav{opacity:0;pointer-events:none;transition:opacity .2s ease-in-out}.p-galleria-item-nav-onhover .p-galleria-item-wrapper:hover .p-galleria-item-nav{opacity:1;pointer-events:all}.p-galleria-item-nav-onhover .p-galleria-item-wrapper:hover .p-galleria-item-nav.p-disabled{pointer-events:none}.p-galleria-caption{bottom:0;left:0;position:absolute;width:100%}.p-galleria-thumbnail-wrapper{display:flex;flex-direction:column;flex-shrink:0;overflow:auto}.p-galleria-thumbnail-next,.p-galleria-thumbnail-prev{-ms-grid-row-align:center;align-self:center;flex:0 0 auto;overflow:hidden;position:relative}.p-galleria-thumbnail-next,.p-galleria-thumbnail-next span,.p-galleria-thumbnail-prev,.p-galleria-thumbnail-prev span{align-items:center;display:flex;justify-content:center}.p-galleria-thumbnail-container{display:flex;flex-direction:row}.p-galleria-thumbnail-items-container{overflow:hidden}.p-galleria-thumbnail-items{display:flex}.p-galleria-thumbnail-item{align-items:center;cursor:pointer;display:flex;justify-content:center;opacity:.5;overflow:auto}.p-galleria-thumbnail-item:hover{opacity:1;transition:opacity .3s}.p-galleria-thumbnail-item-current{opacity:1}.p-galleria-thumbnails-left .p-galleria-content,.p-galleria-thumbnails-left .p-galleria-item-wrapper,.p-galleria-thumbnails-right .p-galleria-content,.p-galleria-thumbnails-right .p-galleria-item-wrapper{flex-direction:row}.p-galleria-thumbnails-left p-galleriaitem,.p-galleria-thumbnails-top p-galleriaitem{order:2}.p-galleria-thumbnails-left p-galleriathumbnails,.p-galleria-thumbnails-top p-galleriathumbnails{order:1}.p-galleria-thumbnails-left .p-galleria-thumbnail-container,.p-galleria-thumbnails-right .p-galleria-thumbnail-container{flex-direction:column;flex-grow:1}.p-galleria-thumbnails-left .p-galleria-thumbnail-items,.p-galleria-thumbnails-right .p-galleria-thumbnail-items{flex-direction:column;height:100%}.p-galleria-thumbnails-left .p-galleria-thumbnail-wrapper,.p-galleria-thumbnails-right .p-galleria-thumbnail-wrapper{height:100%}.p-galleria-indicators{align-items:center;display:flex;justify-content:center}.p-galleria-indicator>button{align-items:center;display:inline-flex}.p-galleria-indicators-left .p-galleria-item-wrapper,.p-galleria-indicators-right .p-galleria-item-wrapper{align-items:center;flex-direction:row}.p-galleria-indicators-left .p-galleria-item-container,.p-galleria-indicators-top .p-galleria-item-container{order:2}.p-galleria-indicators-left .p-galleria-indicators,.p-galleria-indicators-top .p-galleria-indicators{order:1}.p-galleria-indicators-left .p-galleria-indicators,.p-galleria-indicators-right .p-galleria-indicators{flex-direction:column}.p-galleria-indicator-onitem .p-galleria-indicators{display:flex;position:absolute;z-index:1}.p-galleria-indicator-onitem.p-galleria-indicators-top .p-galleria-indicators{align-items:flex-start;left:0;top:0;width:100%}.p-galleria-indicator-onitem.p-galleria-indicators-right .p-galleria-indicators{align-items:flex-end;height:100%;right:0;top:0}.p-galleria-indicator-onitem.p-galleria-indicators-bottom .p-galleria-indicators{align-items:flex-end;bottom:0;left:0;width:100%}.p-galleria-indicator-onitem.p-galleria-indicators-left .p-galleria-indicators{align-items:flex-start;height:100%;left:0;top:0}.p-galleria-mask{background-color:transparent;height:100%;left:0;position:fixed;transition-property:background-color;width:100%}.p-galleria-close,.p-galleria-mask{align-items:center;display:flex;justify-content:center;top:0}.p-galleria-close{overflow:hidden;position:absolute;right:0}.p-galleria-mask .p-galleria-item-nav{margin-top:-.5rem;position:fixed;top:50%}.p-galleria-mask.p-galleria-mask-leave{background-color:transparent}.p-items-hidden .p-galleria-thumbnail-item{visibility:hidden}.p-items-hidden .p-galleria-thumbnail-item.p-galleria-thumbnail-item-active{visibility:visible}"]}]}],Galleria.ctorParameters=(()=>[{type:ElementRef},{type:ChangeDetectorRef}]),Galleria.propDecorators={activeIndex:[{type:Input}],fullScreen:[{type:Input}],id:[{type:Input}],value:[{type:Input}],numVisible:[{type:Input}],responsiveOptions:[{type:Input}],showItemNavigators:[{type:Input}],showThumbnailNavigators:[{type:Input}],showItemNavigatorsOnHover:[{type:Input}],changeItemOnIndicatorHover:[{type:Input}],circular:[{type:Input}],autoPlay:[{type:Input}],transitionInterval:[{type:Input}],showThumbnails:[{type:Input}],thumbnailsPosition:[{type:Input}],verticalThumbnailViewPortHeight:[{type:Input}],showIndicators:[{type:Input}],showIndicatorsOnItem:[{type:Input}],indicatorsPosition:[{type:Input}],baseZIndex:[{type:Input}],maskClass:[{type:Input}],containerClass:[{type:Input}],containerStyle:[{type:Input}],mask:[{type:ViewChild,args:["mask",{static:!1}]}],visible:[{type:Input}],activeIndexChange:[{type:Output}],visibleChange:[{type:Output}],templates:[{type:ContentChildren,args:[PrimeTemplate]}]};export class GalleriaContent{constructor(e,t){this.galleria=e,this.cd=t,this.value=[],this.maskHide=new EventEmitter,this.activeItemChange=new EventEmitter,this.id=this.galleria.id||UniqueComponentId(),this.slideShowActicve=!1,this._activeIndex=0,this.slideShowActive=!0}get activeIndex(){return this._activeIndex}set activeIndex(e){this._activeIndex=e}galleriaClass(){const e=this.galleria.showThumbnails&&this.getPositionClass("p-galleria-thumbnails",this.galleria.thumbnailsPosition),t=this.galleria.showIndicators&&this.getPositionClass("p-galleria-indicators",this.galleria.indicatorsPosition);return(this.galleria.containerClass?this.galleria.containerClass+" ":"")+(e?e+" ":"")+(t?t+" ":"")}startSlideShow(){this.interval=setInterval(()=>{let e=this.galleria.circular&&this.value.length-1===this.activeIndex?0:this.activeIndex+1;this.onActiveIndexChange(e),this.activeIndex=e},this.galleria.transitionInterval),this.slideShowActive=!0}stopSlideShow(){this.interval&&clearInterval(this.interval),this.slideShowActive=!1}getPositionClass(e,t){const i=["top","left","bottom","right"].find(e=>e===t);return i?`${e}-${i}`:""}isVertical(){return"left"===this.galleria.thumbnailsPosition||"right"===this.galleria.thumbnailsPosition}onActiveIndexChange(e){this.activeIndex!==e&&(this.activeIndex=e,this.activeItemChange.emit(this.activeIndex))}};GalleriaContent.decorators=[{type:Component,args:[{selector:"p-galleriaContent",template:'\n 0" [ngClass]="{\'p-galleria p-component\': true, \'p-galleria-fullscreen\': this.galleria.fullScreen, \n \'p-galleria-indicator-onitem\': this.galleria.showIndicatorsOnItem, \'p-galleria-item-nav-onhover\': this.galleria.showItemNavigatorsOnHover && !this.galleria.fullScreen}"\n [ngStyle]="!galleria.fullScreen ? galleria.containerStyle : {}" [class]="galleriaClass()">\n
\n \n
\n \n
\n ',changeDetection:ChangeDetectionStrategy.OnPush}]}],GalleriaContent.ctorParameters=(()=>[{type:Galleria},{type:ChangeDetectorRef}]),GalleriaContent.propDecorators={activeIndex:[{type:Input}],value:[{type:Input}],maskHide:[{type:Output}],activeItemChange:[{type:Output}]};export class GalleriaItemSlot{get item(){return this._item}set item(e){this._item=e,this.templates&&this.templates.forEach(e=>{if(e.getType()===this.type)switch(this.type){case"item":case"caption":case"thumbnail":this.context={$implicit:this.item},this.contentTemplate=e.template}})}ngAfterContentInit(){this.templates.forEach(e=>{if(e.getType()===this.type)switch(this.type){case"item":case"caption":case"thumbnail":this.context={$implicit:this.item},this.contentTemplate=e.template;break;case"indicator":this.context={$implicit:this.index},this.contentTemplate=e.template;break;default:this.context={},this.contentTemplate=e.template}})}};GalleriaItemSlot.decorators=[{type:Component,args:[{selector:"p-galleriaItemSlot",template:'\n \n \n \n ',changeDetection:ChangeDetectionStrategy.OnPush}]}],GalleriaItemSlot.propDecorators={templates:[{type:Input}],index:[{type:Input}],item:[{type:Input}],type:[{type:Input}]};export class GalleriaItem{constructor(){this.circular=!1,this.showItemNavigators=!1,this.showIndicators=!0,this.slideShowActive=!0,this.changeItemOnIndicatorHover=!0,this.autoPlay=!1,this.startSlideShow=new EventEmitter,this.stopSlideShow=new EventEmitter,this.onActiveIndexChange=new EventEmitter,this._activeIndex=0}get activeIndex(){return this._activeIndex}set activeIndex(e){this._activeIndex=e,this.activeItem=this.value[this._activeIndex]}ngOnInit(){this.autoPlay&&this.startSlideShow.emit()}next(){let e=this.activeIndex+1,t=this.circular&&this.value.length-1===this.activeIndex?0:e;this.onActiveIndexChange.emit(t)}prev(){let e=0!==this.activeIndex?this.activeIndex-1:0,t=this.circular&&0===this.activeIndex?this.value.length-1:e;this.onActiveIndexChange.emit(t)}stopTheSlideShow(){this.slideShowActive&&this.stopSlideShow&&this.stopSlideShow.emit()}navForward(e){this.stopTheSlideShow(),this.next(),e&&e.cancelable&&e.preventDefault()}navBackward(e){this.stopTheSlideShow(),this.prev(),e&&e.cancelable&&e.preventDefault()}onIndicatorClick(e){this.stopTheSlideShow(),this.onActiveIndexChange.emit(e)}onIndicatorMouseEnter(e){this.changeItemOnIndicatorHover&&(this.stopTheSlideShow(),this.onActiveIndexChange.emit(e))}onIndicatorKeyDown(e){this.stopTheSlideShow(),this.onActiveIndexChange.emit(e)}isNavForwardDisabled(){return!this.circular&&this.activeIndex===this.value.length-1}isNavBackwardDisabled(){return!this.circular&&0===this.activeIndex}isIndicatorItemActive(e){return this.activeIndex===e}};GalleriaItem.decorators=[{type:Component,args:[{selector:"p-galleriaItem",template:'\n \n
\n
\n
\n
\n
\n
\n
\n
\n ',changeDetection:ChangeDetectionStrategy.OnPush}]}],GalleriaItem.propDecorators={circular:[{type:Input}],value:[{type:Input}],showItemNavigators:[{type:Input}],showIndicators:[{type:Input}],slideShowActive:[{type:Input}],changeItemOnIndicatorHover:[{type:Input}],autoPlay:[{type:Input}],templates:[{type:Input}],indicatorFacet:[{type:Input}],captionFacet:[{type:Input}],startSlideShow:[{type:Output}],stopSlideShow:[{type:Output}],onActiveIndexChange:[{type:Output}],activeIndex:[{type:Input}]};export class GalleriaThumbnails{constructor(){this.isVertical=!1,this.slideShowActive=!1,this.circular=!1,this.contentHeight="300px",this.showThumbnailNavigators=!0,this.onActiveIndexChange=new EventEmitter,this.stopSlideShow=new EventEmitter,this.startPos=null,this.thumbnailsStyle=null,this.sortedResponsiveOptions=null,this.totalShiftedItems=0,this.page=0,this._numVisible=0,this.d_numVisible=0,this._oldNumVisible=0,this._activeIndex=0,this._oldactiveIndex=0}get numVisible(){return this._numVisible}set numVisible(e){this._numVisible=e,this._oldNumVisible=this.d_numVisible,this.d_numVisible=e}get activeIndex(){return this._activeIndex}set activeIndex(e){this._oldactiveIndex=this._activeIndex,this._activeIndex=e}ngOnInit(){this.createStyle(),this.calculatePosition(),this.responsiveOptions&&this.bindDocumentListeners()}ngAfterContentChecked(){let e=this.totalShiftedItems;this._oldNumVisible===this.d_numVisible&&this._oldactiveIndex===this._activeIndex||!this.itemsContainer||((e=this._activeIndex<=this.getMedianItemIndex()?0:this.value.length-this.d_numVisible+this.getMedianItemIndex(){const i=e.breakpoint,a=t.breakpoint;let n=null;return-1*(n=null==i&&null!=a?-1:null!=i&&null==a?1:null==i&&null==a?0:"string"==typeof i&&"string"==typeof a?i.localeCompare(a,void 0,{numeric:!0}):ia?1:0)});for(let t=0;t=e&&(t=a)}this.d_numVisible!==t.numVisible&&(this.d_numVisible=t.numVisible)}}getTabIndex(e){return this.isItemActive(e)?0:null}navForward(e){this.stopTheSlideShow();let t=this._activeIndex+1;t+this.totalShiftedItems>this.getMedianItemIndex()&&(-1*this.totalShiftedItemsthis.getMedianItemIndex()&&(-1*this.totalShiftedItems!=0||this.circular)&&this.step(1);let a=this.circular&&0===this._activeIndex?this.value.length-1:t;this.onActiveIndexChange.emit(a),e.cancelable&&e.preventDefault()}onItemClick(e){this.stopTheSlideShow();let t=e;if(t!==this._activeIndex){const e=t+this.totalShiftedItems;let i=0;t0&&-1*this.totalShiftedItems!=0&&this.step(i):(i=this.getMedianItemIndex()-e)<0&&-1*this.totalShiftedItemsthis.value.length-1?t=this.d_numVisible-this.value.length:e>0&&t>0&&(t=0),this.circular&&(e<0&&this.value.length-1===this._activeIndex?t=0:e>0&&0===this._activeIndex&&(t=this.d_numVisible-this.value.length)),this.itemsContainer&&(DomHandler.removeClass(this.itemsContainer.nativeElement,"p-items-hidden"),this.itemsContainer.nativeElement.style.transform=this.isVertical?`translate3d(0, ${t*(100/this.d_numVisible)}%, 0)`:`translate3d(${t*(100/this.d_numVisible)}%, 0, 0)`,this.itemsContainer.nativeElement.style.transition="transform 500ms ease 0s"),this.totalShiftedItems=t}stopTheSlideShow(){this.slideShowActive&&this.stopSlideShow&&this.stopSlideShow.emit()}changePageOnTouch(e,t){t<0?this.navForward(e):this.navBackward(e)}getTotalPageNumber(){return this.value.length>this.d_numVisible?this.value.length-this.d_numVisible+1:0}getMedianItemIndex(){let e=Math.floor(this.d_numVisible/2);return this.d_numVisible%2?e:e-1}onTransitionEnd(){this.itemsContainer&&this.itemsContainer.nativeElement&&(DomHandler.addClass(this.itemsContainer.nativeElement,"p-items-hidden"),this.itemsContainer.nativeElement.style.transition="")}onTouchEnd(e){let t=e.changedTouches[0];this.isVertical?this.changePageOnTouch(e,t.pageY-this.startPos.y):this.changePageOnTouch(e,t.pageX-this.startPos.x)}onTouchMove(e){e.cancelable&&e.preventDefault()}onTouchStart(e){let t=e.changedTouches[0];this.startPos={x:t.pageX,y:t.pageY}}isNavBackwardDisabled(){return!this.circular&&0===this._activeIndex||this.value.length<=this.d_numVisible}isNavForwardDisabled(){return!this.circular&&this._activeIndex===this.value.length-1||this.value.length<=this.d_numVisible}firstItemAciveIndex(){return-1*this.totalShiftedItems}lastItemActiveIndex(){return this.firstItemAciveIndex()+this.d_numVisible-1}isItemActive(e){return this.firstItemAciveIndex()<=e&&this.lastItemActiveIndex()>=e}bindDocumentListeners(){this.documentResizeListener||(this.documentResizeListener=(()=>{this.calculatePosition()}),window.addEventListener("resize",this.documentResizeListener))}unbindDocumentListeners(){this.documentResizeListener&&(window.removeEventListener("resize",this.documentResizeListener),this.documentResizeListener=null)}ngOnDestroy(){this.responsiveOptions&&this.unbindDocumentListeners(),this.thumbnailsStyle&&this.thumbnailsStyle.parentNode.removeChild(this.thumbnailsStyle)}};GalleriaThumbnails.decorators=[{type:Component,args:[{selector:"p-galleriaThumbnails",template:'\n \n ',changeDetection:ChangeDetectionStrategy.OnPush}]}],GalleriaThumbnails.propDecorators={containerId:[{type:Input}],value:[{type:Input}],isVertical:[{type:Input}],slideShowActive:[{type:Input}],circular:[{type:Input}],responsiveOptions:[{type:Input}],contentHeight:[{type:Input}],showThumbnailNavigators:[{type:Input}],templates:[{type:Input}],onActiveIndexChange:[{type:Output}],stopSlideShow:[{type:Output}],itemsContainer:[{type:ViewChild,args:["itemsContainer"]}],numVisible:[{type:Input}],activeIndex:[{type:Input}]};export class GalleriaModule{};GalleriaModule.decorators=[{type:NgModule,args:[{imports:[CommonModule,SharedModule,RippleModule],exports:[CommonModule,Galleria,GalleriaContent,GalleriaItemSlot,GalleriaItem,GalleriaThumbnails,SharedModule],declarations:[Galleria,GalleriaContent,GalleriaItemSlot,GalleriaItem,GalleriaThumbnails]}]}];