"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@gem-sdk/core"),r=require("./useTimeLeft.js"),t=require("react"),n=require("../common/helpers.js"),i=require("../../product/components/product-variants/common/common.js");exports.default=(o,a)=>{let u=t.useRef(null),{trigger:s}=e.useInteraction(),{timerDaily:c,timerEverygreen:l,dateStandard:d,behaviour:m,redirectUrl:p,timeZone:b,standardType:f,enableDay:g,enableHour:v,enableMinute:j,enableWeek:y,autoHideWhenTimeout:h}=o??{},q="evergreen"===m&&!h&&o?.loopAfterFinish,O=r.default({timerDaily:c,timerEverygreen:l,dateStandard:d,behaviour:m,loopAfterFinish:q,redirectUrl:p,timeZone:b,standardType:f}),{week:A,day:N,hour:T,minute:E,second:M}=n.convertTime(O,{enableWeek:y,enableDay:g,enableHour:v,enableMinute:j});i.useTransition(e=>{e!==O&&S(O)},[O]);let S=e=>{let r=u.current,t=new Map(Object.entries(JSON.parse(r?.getAttribute("gp-interaction-counter")??"{}")));t.size<=0||t.forEach((n,i)=>{e!==Number(i)||(s({event:"gp:countdown-timer",selector:`[data-id="${a?.uid}"]`,element:r,data:Number(i)}),q||(t.delete(i),r.setAttribute("gp-interaction-counter",JSON.stringify(Object.fromEntries(t)))))})};return{week:A,day:N,hour:T,minute:E,second:M,timeLeft:O,ref:u}};
