"use strict";var e=require("react"),t=require("@gem-sdk/core");exports.useGpDescription=r=>{let s=e.useRef(null),[u,i]=e.useState(!1),[l,n]=e.useState(!1),a=t.useProduct(),c=t.useCurrentDevice(),o=t.getResponsiveValueByScreen(r?.hasLineClamp,c),p=t.getResponsiveValueByScreen(r?.lineClamp,c),{redirectProductShopifyLink:d}=t.useProductShopifyEditLink(),g=t.useEditorMode(),h=e.useCallback(()=>`calc(${p} * 1lh)`,[p]),m=e.useCallback(e=>o&&p&&e||"auto",[o,p]),y=e.useCallback(()=>{s.current&&(s.current.style.maxHeight=u?h():"none",i(e=>!e))},[u,h]);return e.useEffect(()=>{m(h())},[r?.typo?.custom,m,h]),e.useEffect(()=>{let e=s.current;if(i(!1),!e)return;let r=o&&a?.descriptionHtml;r?setTimeout(()=>{let r=e?.scrollHeight??0,s=e?.clientHeight??0,u=window.getComputedStyle(e).getPropertyValue("line-height"),i=parseInt(u,10)||1,l=void 0!==p&&p<Math.round((r??0)/i),a=t.isSafari()?l:s<r;e.style.maxHeight=h(),p&&a?n(()=>!0):n(()=>!1)},100):e.style.maxHeight="none"},[o,p,a?.descriptionHtml,h]),{ref:s,open:u,isShowViewMore:l,handleToggleShowMore:y,mode:g,redirectProductShopifyLink:d}};
