"use strict";var e=require("react"),t=require("@gem-sdk/core");exports.useGpDescription=r=>{let{htmlTag:i,transform:n,typo:s,typography:l}=r??{},u=e.useRef(null),c=e.useRef(!1),[o,a]=e.useState(!1),[m,p]=e.useState(!1),y=t.useProduct(),g=t.useCurrentDevice(),d=t.getResponsiveValueByScreen(r?.hasLineClamp,g),f=t.getResponsiveValueByScreen(r?.lineClamp,g),H=t.getResponsiveValueByScreen(s?.custom?.lineHeight,g),S=JSON.stringify(s),h=JSON.stringify(l),w=JSON.stringify(n),{redirectProductShopifyLink:v}=t.useProductShopifyEditLink(),P=t.useEditorMode(),R=e.useCallback(()=>{if(!u.current)return;let e=!o;c.current=e,u.current.style.maxHeight=e?"none":"",a(e)},[o]);return e.useEffect(()=>{c.current=!1,a(!1)},[d,f,y?.descriptionHtml]),e.useEffect(()=>{let e=u.current;if(!e)return;if(!d||!y?.descriptionHtml||!f){e.style.maxHeight="",p(!1);return}let t=()=>{if(c.current){e.style.maxHeight="none";return}e.style.maxHeight="";let t=e.style.getPropertyValue("--line-clamp");e.style.setProperty("--line-clamp",String(f));let r=e.scrollHeight-e.clientHeight>1;""!==t?e.style.setProperty("--line-clamp",t):e.style.removeProperty("--line-clamp"),p(r)},r=window.requestAnimationFrame(t),i=window.setTimeout(t,100),n=new ResizeObserver(()=>{t()});return n.observe(e),()=>{window.cancelAnimationFrame(r),window.clearTimeout(i),n.disconnect()}},[d,f,y?.descriptionHtml,H,i,w,S,h]),{ref:u,open:o,isShowViewMore:m,handleToggleShowMore:R,mode:P,redirectProductShopifyLink:v}};
