import{useRef as e,useMemo as t}from"react";import{useCurrentDevice as i,useEditorMode as r,usePageType as n,getBgVideoByDevice as o,isEmptyChildren as l,getResponsiveValue as s}from"@gem-sdk/core";import{createClass as u}from"@gem-sdk/system";import{useInView as c}from"../../common/hooks/useInView.js";let useRowSettings=m=>{let{setting:d,styles:g,children:h,maxWidthWithEmptyChildren:p,builderAttrs:f}=m,{isSection:a,lazy:w,layout:y,blockAlignment:P}=d??{},{background:S}=g??{},T=i(),k=r(),R=n(),C=o(S,T),b=e(null),v=t(()=>l(h),[h]),x=e=>{b.current&&(clearTimeout(b.current),b.current=null);let t=e?.getBoundingClientRect().height;e.style.height=`${t||500}px`,e.style.overflow="hidden"},E=e=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{e.style.height="",e.style.overflow="",b.current=null},1500)},[H,O]=c({initialInView:!w,triggerOnce:!0,skip:!a,onChange:(e,t)=>{t&&t instanceof HTMLElement&&"edit"===k&&(e?E(t):x(t))}}),A=t(()=>!O&&"edit"==k&&"POST_PURCHASE"!==R,[O,k,R]),I=t(()=>"edit"!==k&&w&&!O,[O,w,k]),U=()=>{let e=p&&v&&"edit"===k;if(!e)return{};let t=s(y,"display"),i=t[T];return{width:"fit"===i?"fit-content":"400px"}},V=u({...U,"gp-content-visibility-hidden":I}),_=()=>({desktop:P,tablet:P,mobile:P});return{ref:H,isRowEmpty:v,bgVideo:C,rowClassEditorOnly:V,isRenderPlaceholderViewBox:A,builderAttrs:f,children:h,isPostPurchase:"POST_PURCHASE"===R,postPurchaseVerticalAlign:_}};export{useRowSettings};
