import t,{Component as e}from"react";import{classNames as i,UniqueComponentId as n,DomHandler as r,ZIndexUtils as s}from"primereact/utils";import{Ripple as a}from"primereact/ripple";import o from"primereact/api";import{CSSTransition as l}from"primereact/csstransition";import{Portal as p}from"primereact/portal";function c(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function h(t,e){for(var i=0;it.length)&&(e=t.length);for(var i=0,n=new Array(e);ithis.props.value.length-1?e=this.state.numVisible-this.props.value.length:t>0&&e>0&&(e=0),this.props.circular&&(t<0&&this.props.value.length-1===this.props.activeItemIndex?e=0:t>0&&0===this.props.activeItemIndex&&(e=this.state.numVisible-this.props.value.length)),this.itemsContainer&&(r.removeClass(this.itemsContainer,"p-items-hidden"),this.itemsContainer.style.transform=this.props.isVertical?"translate3d(0, ".concat(e*(100/this.state.numVisible),"%, 0)"):"translate3d(".concat(e*(100/this.state.numVisible),"%, 0, 0)"),this.itemsContainer.style.transition="transform 500ms ease 0s"),this.setState({totalShiftedItems:e})}},{key:"stopSlideShow",value:function(){this.props.slideShowActive&&this.props.stopSlideShow&&this.props.stopSlideShow()}},{key:"getMedianItemIndex",value:function(){var t=Math.floor(this.state.numVisible/2);return this.state.numVisible%2?t:t-1}},{key:"navBackward",value:function(t){this.stopSlideShow();var e=0!==this.props.activeItemIndex?this.props.activeItemIndex-1:0;this.state.numVisible-(e+this.state.totalShiftedItems)-1>this.getMedianItemIndex()&&(-1*this.state.totalShiftedItems!=0||this.props.circular)&&this.step(1),this.props.onActiveItemChange({index:this.props.circular&&0===this.props.activeItemIndex?this.props.value.length-1:e}),t.cancelable&&t.preventDefault()}},{key:"navForward",value:function(t){this.stopSlideShow();var e=this.props.activeItemIndex+1;e+this.state.totalShiftedItems>this.getMedianItemIndex()&&(-1*this.state.totalShiftedItems0&&-1*this.state.totalShiftedItems!=0&&this.step(n):(n=this.getMedianItemIndex()-i)<0&&-1*this.state.totalShiftedItemsthis.state.numVisible?this.props.value.length-this.state.numVisible+1:0}},{key:"createStyle",value:function(){this.thumbnailsStyle||(this.thumbnailsStyle=r.createInlineStyle(o.nonce));var t,e="\n .p-galleria-thumbnail-items[".concat(this.attributeSelector,"] .p-galleria-thumbnail-item {\n flex: 1 0 ").concat(100/this.state.numVisible,"%\n }\n ");if(this.props.responsiveOptions){this.responsiveOptions=E(t=this.props.responsiveOptions)||C(t)||O(t)||N(),this.responsiveOptions.sort((function(t,e){var i=t.breakpoint,n=e.breakpoint;return-1*(null==i&&null!=n?-1:null!=i&&null==n?1:null==i&&null==n?0:"string"==typeof i&&"string"==typeof n?i.localeCompare(n,void 0,{numeric:!0}):in?1:0)}));for(var i=0;i=t&&(e=n)}this.state.numVisible!==e.numVisible&&this.setState({numVisible:e.numVisible})}}},{key:"bindDocumentListeners",value:function(){var t=this;this.documentResizeListener||(this.documentResizeListener=function(){t.calculatePosition()},window.addEventListener("resize",this.documentResizeListener))}},{key:"unbindDocumentListeners",value:function(){this.documentResizeListener&&(window.removeEventListener("resize",this.documentResizeListener),this.documentResizeListener=null)}},{key:"componentDidMount",value:function(){this.itemsContainer&&this.itemsContainer.setAttribute(this.attributeSelector,""),this.createStyle(),this.calculatePosition(),this.props.responsiveOptions&&this.bindDocumentListeners()}},{key:"componentDidUpdate",value:function(t,e){var i=this.state.totalShiftedItems;e.numVisible===this.state.numVisible&&t.activeItemIndex===this.props.activeItemIndex||((i=this.props.activeItemIndex<=this.getMedianItemIndex()?0:this.props.value.length-this.state.numVisible+this.getMedianItemIndex()=n,start:r===n,end:s===n,onItemClick:e.onItemClick,current:e.props.activeItemIndex===n})}))}},{key:"renderBackwardNavigator",value:function(){if(this.props.showThumbnailNavigators){var e=!this.props.circular&&0===this.props.activeItemIndex||this.props.value.length<=this.state.numVisible,n=i("p-galleria-thumbnail-prev p-link",{"p-disabled":e}),r=i("p-galleria-thumbnail-prev-icon pi",{"pi-chevron-left":!this.props.isVertical,"pi-chevron-up":this.props.isVertical});return t.createElement("button",{className:n,onClick:this.navBackward,disabled:e},t.createElement("span",{className:r}),t.createElement(a,null))}return null}},{key:"renderForwardNavigator",value:function(){if(this.props.showThumbnailNavigators){var e=!this.props.circular&&this.props.activeItemIndex===this.props.value.length-1||this.props.value.length<=this.state.numVisible,n=i("p-galleria-thumbnail-next p-link",{"p-disabled":e}),r=i("p-galleria-thumbnail-next-icon pi",{"pi-chevron-right":!this.props.isVertical,"pi-chevron-down":this.props.isVertical});return t.createElement("button",{className:n,onClick:this.navForward,disabled:e},t.createElement("span",{className:r}),t.createElement(a,null))}return null}},{key:"renderContent",value:function(){var e=this,i=this.renderItems(),n=this.props.isVertical?this.props.contentHeight:"",r=this.renderBackwardNavigator(),s=this.renderForwardNavigator();return t.createElement("div",{className:"p-galleria-thumbnail-container"},r,t.createElement("div",{className:"p-galleria-thumbnail-items-container",style:{height:n}},t.createElement("div",{ref:function(t){return e.itemsContainer=t},className:"p-galleria-thumbnail-items",onTransitionEnd:this.onTransitionEnd,onTouchStart:this.onTouchStart,onTouchMove:this.onTouchMove,onTouchEnd:this.onTouchEnd},i)),s)}},{key:"render",value:function(){var e=this.renderContent();return t.createElement("div",{className:"p-galleria-thumbnail-wrapper"},e)}}]),p}();function R(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function j(t){for(var e=1;e0&&this.renderGalleria()}}]),y}();y(M,"defaultProps",{id:null,value:null,activeIndex:0,fullScreen:!1,item:null,thumbnail:null,indicator:null,caption:null,className:null,style:null,header:null,footer:null,numVisible:3,responsiveOptions:null,showItemNavigators:!1,showThumbnailNavigators:!0,showItemNavigatorsOnHover:!1,changeItemOnIndicatorHover:!1,circular:!1,autoPlay:!1,transitionInterval:4e3,showThumbnails:!0,thumbnailsPosition:"bottom",verticalThumbnailViewPortHeight:"300px",showIndicators:!1,showIndicatorsOnItem:!1,indicatorsPosition:"bottom",baseZIndex:0,transitionOptions:null,onItemChange:null});export{M as Galleria};