"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),Text_liquid=require("../../text/components/Text.liquid.js"),helpers=require("../../helpers.js"),system=require("@gem-sdk/system"),attrs=require("../common/attrs.js"),styles=require("../common/styles.js"),classes=require("../common/classes.js"),helpers$1=require("../common/helpers.js");const Countdown=e=>{let{setting:t,styles:s,builderProps:a,advanced:r,pageContext:l}=e,{labelTypo:i,numTypo:n,numTypography:d,labelTypography:o,enableLabelTextStyle:c}=s??{},{weekLabel:y,dayLabel:u,hourLabel:m,minuteLabel:p,secondLabel:g,enableWeek:$,enableDay:f,enableHour:S,enableMinute:C,enableSecond:h,redirectUrl:x,translate:q}=t??{},w=!!x?.link,{urlData:b}=helpers.getInsertLinkData("",x),k=system.createStateOrContext({...t,...a}),v=system.createStyle({...styles.getDateStyle(s)}),I=e=>system.createClass({...classes.getDateClasses(e)}),T=system.createClass({...classes.getTextFrontClasses(s)}),j=system.createStyle({...styles.getTextFrontStyle(s)}),A=system.createStyle({...styles.getTextBackStyle(s)}),E=e=>system.createClass({...classes.getTextBackClasses(s,e)}),L=system.createAttr({...attrs.getAttr({uid:a?.uid||""})}),_=system.createAttr({...attrs.getAttrHref({uid:b.href||""})}),D=system.createStyle({...styles.getWrapperStyle(s)}),P=system.createClass({...classes.getWrapperClasses(r?.cssClass)}),W=system.createClass({...classes.getContentClasses()}),F=system.createStyle({...styles.getContainStyle(s)}),H=(e,s,r)=>core.template`
    <div style="${v}" class="${I(s)}">
    ${Text_liquid.default({styles:{typography:d,typo:n},setting:{...t,text:"00",excludeFlex:!0,translate:""},style:j,className:T,builderAttrs:{id:e},builderProps:{...a,uid:a?.uid,uidInteraction:`${a?.uid}-text`}})}
    ${system.If(!!c,core.template`
         ${Text_liquid.default({styles:{typography:o,typo:i},setting:{...t,text:s,excludeFlex:!0,translate:r},style:A,className:E(s),builderProps:{...a,uid:a?.uid,uidInteraction:`${a?.uid}-text`},pageContext:l})}
    `)}
    </div>
    `,N=system.createClass({...classes.getLinkClasses()}),O=helpers$1.getStandardEndtime(t?.dateStandard,t?.timeZone),R=()=>core.RenderIf(core.isLocalEnv,`<script ${helpers.getSettingPreloadData('class="gps-link" delay',"src")}="{{ 'gp-countdown-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${helpers.getSettingPreloadData('class="gps-link" delay',"src")}="${core.baseAssetURL}/assets-v2/gp-countdown-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`);return core.template`
    {%- liquid
      assign standardEndDate = ${O}
      assign typeCountdown = "${t?.behaviour.toString()||""}"
      assign autoHideWhenTimeout = ${!!t?.autoHideWhenTimeout}
      assign current_time = 'now' | date: '%s' | times: 1000

    -%}
   {% if standardEndDate == nil or current_time <= standardEndDate or typeCountdown != "standard" or autoHideWhenTimeout != true %}
      <gp-countdown-timer
        ${{...L}}
        ${{..._}}
        class="${P}"
        style="${D}"
        gp-data='${JSON.stringify(k).replaceAll("'","&#039;")}'>
        <div id="section-countdown" class="${W}" style="${F}">
          ${system.If(w,`<a
              href="${b.href}"
              target="${b?.target}"
              aria-label="Countdown link"
              class="${N}"
            > </a>`)}
          ${system.If($,H("week",y,q?"weekLabel":""))}
          ${system.If(f,H("day",u,q?"dayLabel":""))}
          ${system.If(S,H("hour",m,q?"hourLabel":""))}
          ${system.If(C,H("minute",p,q?"minuteLabel":""))}
          ${system.If(h,H("second",g,q?"secondLabel":""))}
        </div>
     </gp-countdown-timer>
    {% endif %}
    ${R()}
  `};exports.default=Countdown;
