'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),helpers=require("../common/helpers.js"),Text=require("../../text/components/Text.js"),core=require("@gem-sdk/core"),system=require("@gem-sdk/system"),attrs=require("../common/attrs.js"),classes=require("../common/classes.js"),styles=require("../common/styles.js"),useCountDownTimer=require("../hooks/useCountDownTimer.js");const Countdown=e=>{let{setting:s,styles:t,builderProps:l,advanced:a}=e,{labelTypo:r,numTypo:i,labelTypography:m,numTypography:n,enableLabelTextStyle:y}=t??{},{weekLabel:c,dayLabel:o,hourLabel:u,minuteLabel:d,secondLabel:x,enableWeek:j,enableDay:C,enableHour:g,enableMinute:p,enableSecond:h,redirectUrl:f,autoHideWhenTimeout:T}=s??{},q=core.useEditorMode(),{week:S,day:k,hour:R,minute:v,second:w,timeLeft:I,ref:N}=useCountDownTimer.default(s,l),b=!!f?.link&&"edit"!==q,D=system.createClass({...classes.getTextExpireClasses()});if(s?.autoHideWhenTimeout&&I<=0)return"edit"!==q?null:jsxRuntime.jsx("div",{className:D,children:jsxRuntime.jsx("span",{children:"Countdown is run out of time (this only visible in the editor)"})});let E=system.createAttr({...attrs.getAttr({uid:l?.uid||""})}),F=system.createStyle({...styles.getWrapperStyle(t)}),W=system.createClass({...classes.getWrapperClasses(a?.cssClass)}),A=system.createClass({...classes.getContentClasses({isLiquid:!1,autoHideWhenTimeout:T})}),B=system.createStyle({...styles.getContainStyle(t)}),L=system.createStyle({...styles.getDateStyle(t)}),M=e=>system.createClass({...classes.getDateClasses(e)}),_=system.createClass({...classes.getTextFrontClasses(t)}),H=system.createStyle({...styles.getTextFrontStyle(t)}),O=system.createStyle({...styles.getTextBackStyle(t)}),P=e=>system.createClass({...classes.getTextBackClasses(t,e)}),z=system.createClass({...classes.getLinkClasses()}),G=(e,s)=>{let t=helpers.formatTime(e);return jsxRuntime.jsxs("div",{style:L,className:M(s),children:[jsxRuntime.jsx(Text.default,{styles:{typography:n,typo:i},setting:{htmlTag:"div",text:t,excludeFlex:!0},className:_,style:H,disableEdit:!0}),system.If(!!y,jsxRuntime.jsx(Text.default,{styles:{typography:m,typo:r},setting:{text:s,htmlTag:"p",excludeFlex:!0},style:O,className:P(s),disableEdit:!0}))]})};return jsxRuntime.jsx("div",{ref:N,...E,className:W,style:F,children:jsxRuntime.jsxs("div",{className:A,style:B,children:[system.If(b,jsxRuntime.jsx("a",{href:f?.link,target:f?.target,"aria-label":"Countdown link",className:z,children:" "})),system.If(j,G(S,c)),system.If(C,G(k,o)),system.If(g,G(R,u)),system.If(p,G(v,d)),system.If(h,G(w,x))]})})};exports.default=Countdown;
