import{template as s,RenderIf as e,isLocalEnv as r,baseAssetURL as t}from"@gem-sdk/core";import{getDynamicSourceLocales as a,getStaticLocale as o,getSettingPreloadData as l}from"../../../helpers.js";import{composeContainerAttrs as i,composeAnchorAttrs as c,composeFormAttrs as m,composePopoverAttrs as d}from"./common/attrs.js";import{createClass as f,createStyle as n}from"@gem-sdk/system";import{composeFormStyles as p,popoverStyles as $}from"./common/styles.js";import{composeFormClasses as g}from"./common/classes.js";import{composeContainerStyles as u}from"../contact/common/styles.js";import{composeContainerClasses as v}from"../contact/common/classes.js";let Newsletter=({builderProps:y,setting:j,children:_,style:k,formType:w,advanced:N,pageContext:S,styles:M})=>{let b=a({val:j?.errorMessage,uid:y?.uid,settingId:"errorMessage",pageContext:S,defaultVal:S?.isPreviewing?`Can’t send email. Please try again later.`:o("Newsletter","err_msg_default"),translate:j?.translate}),E=a({val:j?.successMessage,uid:y?.uid,settingId:"successMessage",pageContext:S,defaultVal:S?.isPreviewing?"Thanks for subscribing":o("Newsletter","success_msg_default"),translate:j?.translate}),P=i(y,j),h=c(y,j),I=f(g()),V=n(p("error",j)),A=n(p("success",j)),C=m(y,"error"),G=m(y,"success"),O=d(y),R=$(y),T=n(u(j,M,k)),x=f(v());return s`
    <div class="${x}" style="${T}">
      <gp-form
        ${{...P}}
        data-callback='${JSON.stringify(j?.callbackURL)}'
      >
        <a
          ${{...h}}
        >
        </a>
        {% form '${w||"customer"}', class: 'gp-form-${y?.uid} ${N?.cssClass}', id: 'contact_form_${y?.uid}' %}
          {% if form.errors %}
            <div
              ${{...C}}
              class="${I}"
              style="${V}"
            >
              ${b}
            </div>
          {% endif %}
          <div popover ${{...O}}>
            <style>
              ${R}
            </style>
            <div
              ${{...G}}
              class="${I}"
              style="${A}"
            >
              ${E}
            </div>
          </div>
          ${_}
        {% endform %}
      </gp-form>
    </div>
    ${e(r,`<script ${l('class="gps-link" delay',"src")}="{{ 'gp-form-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${l('class="gps-link" delay',"src")}="${t}/assets-v2/gp-form-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
  `};export{Newsletter as default};
