import{useCurrentDevice as e,getResponsiveValueByScreen as r}from"@gem-sdk/core";import{useRef as t,useState as i,useEffect as o}from"react";import{getTypeWidthDevice as n}from"../common/common.js";let useFeatureImageWithGallery=l=>{let{setting:u,styles:s}=l,m={...u,...s},c=e(),f=t(null),a=t(null),[g,d]=i(""),[h,p]=i(100),[y,b]=i(),v=r(m?.position,c),F="slider"===n(m?.type)[c]||["left","right","inside-left","inside-right"].includes(v),G=(e,r=200)=>{e&&(f.current&&clearTimeout(f.current),f.current=setTimeout(()=>p(a?.current?.offsetHeight||200),r))};return o(()=>{let e=a?.current;if(!e)return;let r=new ResizeObserver(()=>{p(e.offsetHeight||200)});return r.observe(e),()=>{r.disconnect()}}),{isShowCarousel:F,featureImageHeight:h,featureWrapperImage:a,onClickFeatureArrow:g,activeIndexFromFeatureImage:y,setOnClickFeatureArrow:d,onHandleLoadedFeatureImage:G,setActiveIndexFromFeatureImage:b}};export{useFeatureImageWithGallery};
