import{useRef as e,useState as t,useEffect as r}from"react";import{useCollection as o,useCurrentDevice as i,getResponsiveValueByScreen as l,useEditorMode as n,isSafari as p}from"@gem-sdk/core";let m=m=>{let s=e(null),[a,c]=t(!1),[d,g]=t(!1),h=o(),u=i(),w=l(m?.hasLineClamp,u),C=l(m?.lineClamp,u),f=n();return r(()=>{let e=s.current;c(!1),e&&w&&h?.description&&setTimeout(()=>{let t=e?.scrollHeight??0,r=e?.clientHeight??0,o=window.getComputedStyle(e).getPropertyValue("line-height"),i=parseInt(o,10)||1,l=void 0!==C&&C<Math.round((t??0)/i),n=p()?l:r<t;C&&n?g(()=>!0):g(()=>!1)},100)},[w,C,h?.description]),{ref:s,open:a,isShowViewMore:d,handleToggleShowMore:()=>{c(e=>!e)},mode:f,hasLineClamp:w}};export{m as useGpDescription};
