"use strict";const convertTime=(e,t)=>{let r=timeOffset(e);return{week:r.weeks,day:t.enableWeek?r.days:r.totalDays,hour:t.enableDay?r.hours:r.totalHours,minute:t.enableHour||t.enableDay||t.enableWeek?r.minutes:r.totalMinutes,second:t.enableMinute||t.enableHour||t.enableDay||t.enableWeek?r.seconds:r.totalSeconds}},timeOffset=e=>({seconds:e%60,minutes:Math.floor(e/60)%60,hours:Math.floor(e/60/60)%24,days:Math.floor(e/60/60/24)%7,weeks:Math.floor(e/60/60/24/7),months:Math.floor(e/60/60/24/30.4368),totalDays:Math.floor(e/60/60/24),totalHours:Math.floor(e/60/60),totalMinutes:Math.floor(e/60),totalSeconds:e}),formatTime=e=>Number.isNaN(e)||0===e?"00":e<10?`0${e}`:e,calculateTime=e=>{let t=new Date().getTime();e||(e=getEndTime(0,3,0));let r=Math.ceil((e-t)/1e3);return r>0?r:0},getEndTime=(e,t,r)=>{let a=new Date,n=new Date;return a.setDate(n.getDate()+e),a.setHours(n.getHours()+t),a.setMinutes(n.getMinutes()+r),a.setSeconds(n.getSeconds()),a.getTime()},daily=(e,t,r)=>{let a=new Date,n=to24HrTime(`${e}:${t} ${r}`);e=n.hours,t=n.mins;let s=new Date(a.getFullYear(),a.getMonth(),a.getDate(),e,t).getTime(),o=s-a.getTime();return o<0&&(o+=864e5),Math.ceil(o/1e3)},standard=(e,t,r)=>calculateTime(getStandardEndtime(e,t,r)),parseTimezoneOffset=e=>{let t=e?.match(/([+-]\d{2}):(\d{2})$/);if(t?.[1]&&t?.[2]){let e=parseInt(t[1]),r=parseInt(t[2]),a=60*e+(e>=0?r:-r);return-a}let r=e?.match(/GMT([+-])(\d{2})(\d{2})/);if(r?.[1]&&r?.[2]&&r?.[3]){let e="+"===r[1]?-1:1,t=parseInt(r[2])*e,a=parseInt(r[3])*e;return 60*t+a}return null},handleDateUTCFormat=(e,t)=>{let r=new Date().getTimezoneOffset();return(e=new Date(e.getTime()-6e4*r-36e5*t)).getTime()},handleDateGMTFormat=({endTime:e,timezoneNumber:t,standardType:r})=>{let a=new Date(e);if("specific-time-zone"===r){let r="string"==typeof e?parseTimezoneOffset(e):null,n=-(60*t);return r?a.getTime()-(r-n)*6e4:a.getTime()}let n=new Date().getTimezoneOffset(),s="string"==typeof e?parseTimezoneOffset(e):null;return s?a.getTime()+(n-s)*6e4:a.getTime()},getStandardEndtime=(e,t,r)=>{if(!e)return 0;let a=new Date(e),n=0;n=t&&parseInt(t)?parseInt(t):parseInt(t.slice(3));let s="number"==typeof e||"string"==typeof e&&e.includes("Z");return s?handleDateUTCFormat(a,n):handleDateGMTFormat({endTime:e,timezoneNumber:n,standardType:r})},evergreen=e=>{let{days:t,hours:r,mins:a,seconds:n=0}=e;return(t??0)*86400+(r??0)*3600+(a??0)*60+(n??0)},refreshAfterFinish=(e,t)=>{let r=new Date().getTime(),a=(86400*t.days+3600*t.hours+60*t.mins)*1e3,n=(r-e)%a;return Math.ceil((a-n)/1e3)},to24HrTime=e=>{let[t,r,a]=e.toLowerCase().match(/\d+|[a-z]+/g)||[],n=`${Number(t)%12+("am"==a?0:12)}:${r}`.split(":");return{hours:parseInt(n[0]?n[0]:"0"),mins:parseInt(n[1]?n[1]:"0")}};exports.calculateTime=calculateTime,exports.convertTime=convertTime,exports.daily=daily,exports.evergreen=evergreen,exports.formatTime=formatTime,exports.getEndTime=getEndTime,exports.getStandardEndtime=getStandardEndtime,exports.refreshAfterFinish=refreshAfterFinish,exports.standard=standard;
