import{makeStyleResponsive as e,makeLineClamp as t,template as s,dataStringify as i,isLocalEnv as o,baseAssetURL as r}from"@gem-sdk/core";import{getDynamicSourceLocales as p,getSettingPreloadData as l}from"../../../helpers.js";import{createClass as a,createStyle as n,createAttr as d,createStateOrContext as c,LiquidIf as m,Liquid as $,LiquidUnless as u,If as g}from"@gem-sdk/system";import{getClasses as v,getButtonClasses as w,getClassPreBuilt as x}from"./common/classes.js";import{getTextStyle as f,getButtonStyle as h,getStaticCss as y}from"./common/styles.js";import{ICON_SVG as M}from"./common/helpers.js";let ProductDescription=b=>{let{setting:C,advanced:L,builderProps:S,pageContext:T}=b,{htmlTag:j,translate:I,viewMoreText:k,viewLessText:E}=C??{},P="html"===j?"div":"p",V=a({"gp-product-description":!0,[L?.cssClass]:!0}),A=a(v({setting:C,isLiquid:!0})),D=a(w({setting:C})),G=a({"gp-show-more-text":!0}),_=a({"gp-show-more-icon gp-ml-1":!0}),q=n({...f({setting:C,renderMaxHeight:!0}),...e("line-clamp",t(C?.lineClamp,C?.hasLineClamp))}),H=a(x()),N=n(h({setting:C})),O=d({"data-id":`${S?.uid}`}),R=d({"data-gp-text":""}),{textDescriptionCss:z,gpDescriptionCss:B}=y(),F="product.description == blank",J=()=>{let e=o?"{{ 'gp-product-description-v7-5.js' | asset_url }}":`${r}/assets-v2/gp-product-description-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}`;return`<script ${l('class="gps-link" delay',"src")}="${e}" defer="defer"></script>`},K=c({setting:{lineClamp:C?.lineClamp,hasLineClamp:C?.hasLineClamp,viewMoreText:C?.viewMoreText,viewLessText:C?.viewLessText,enableViewMoreIcon:C?.enableViewMoreIcon},textStyle:q}),Q=p({val:k,uid:S?.uid,settingId:"viewMoreText",pageContext:T,translate:I}),U=p({val:E,uid:S?.uid,settingId:"viewLessText",pageContext:T,translate:I});return m(F,"",$(s`
    <gp-product-description
      ${O}
      class="${V}"
      gp-data='${i(K).replaceAll("'","&#039;")}'
      data-view-more-text="${Q}"
      data-view-less-text="${U}"
    >
      <style>${z}</style>
      <style>${B}</style>
      <div class="${H}" ></div>
      ${u("product","<p>Product not found</p>",s`<${P} ${R} class="${A}" style="${q}">
          {{product.description}}
        </${P}>
        ${u(F,s`<button type="button" class="${D}" style="${N}">
          <span class="${G}">
            ${g(!1,U?.toString(),Q?.toString())}
          </span>
          ${g(C?.enableViewMoreIcon,s`<span class="${_}">${M}</span>`," ")}
          </button>`)}`)}
    </gp-product-description>

    ${J()}
  `))};export{ProductDescription as default};
