import e from"../../text/components/TextInline.js";import{getDynamicSourceLocales as t,createSettingId as a}from"../../helpers.js";import{createClass as r}from"@gem-sdk/system";import{getStyleEstimateDate as u}from"./styles.js";import{EstimateDate as l}from"../settings/configs/translate.js";let n=e=>e?"number"==typeof e?e:Number(e.split("days")[0]):0,s=e=>{let t=new Date(Date.now()),a=n(e?.estimateTime),r=n(e?.minEstimate),u=n(e?.maxEstimate),l=e?.typeFormat==="Custom"?e?.customFormat:e?.typeFormat;if(!l)return"";if(e?.typeEstimate===d.SPECIFIC){let e=`${p(g(a),l)}`;return e}p(t);let s=`${p(g(r),l)} - ${p(g(u),l)}`;return s},i=e=>{switch(e?.htmlTag){case 1:return"h1";case 2:return"h2";case 3:return"h3";case 4:return"h4";case 5:return"h5";case 6:return"h6";default:return"div"}},o=({type:e,styles:t,setting:a,builderProps:r,pageContext:u})=>{let l="React"===e,n=m({type:e,styles:t,setting:a,builderProps:r,pageContext:u});return{text:n,htmlTag:i(a),globalSize:a?.globalSize,background:a?.background,...!l&&{isForceValue:!0}}},m=({type:n,styles:i,setting:o,builderProps:m,pageContext:y})=>{let d="React"===n,p=r({"estimate-date-main":!0}),g=d||y?.isPreviewing?o?.customText:t({val:o?.customText,uid:m?.uid,settingId:a({id:l?.customText?.id}),pageContext:y??{},isCapitalize:i?.typo?.attrs?.transform==="capitalize"}).toString();return`${o?.enableCustomText===!1?"":e({styles:u(i,"typoCustom"),setting:{text:g},elementAttrs:{debugText:JSON.stringify({pageContext:y,setting:o,isReact:d,builderProps:m,textWithTranslate:g}).replaceAll("'","&#039;")}})} ${e({styles:u(i,"typoDate"),setting:{text:s(o)},className:p})}`},y={SHOW:"show",HIDE:"hide"},d={SPECIFIC:"specific",RANGE:"range"},p=(e,t="%B %d, %Y")=>{let a=e.getMonth()+1,r=e.getDate(),u=e.getFullYear(),l=[{type:"%a",value:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][e.getDay()]},{type:"%A",value:["Sunday","Monday","Tueday","Wednesday","Thursday","Friday","Saturday"][e.getDay()]},{type:"%d",value:r.toString().padStart(2,"0")},{type:"%b",value:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][a-1]},{type:"%B",value:["January","February","March","April","May","June","July","August","September","October","November","December"][a-1]},{type:"%m",value:a.toString().padStart(2,"0")},{type:"%y",value:u.toString().slice(-2)},{type:"%Y",value:u},{type:"%sf",value:function(e){let t=Math.floor(e/10)%10,a=e%10;return 1===a&&1!==t?"st":2===a&&1!==t?"nd":3===a&&1!==t?"rd":"th"}(r)}];return l.forEach(e=>{t=t.replaceAll(e?.type,e?.value?.toString()||"")}),t},g=e=>{let t=new Date,a=new Date(t);return a.setDate(t.getDate()+Number(e)),a},c=()=>{let e=new Date(Date.now());return{FORMAT_1:{Label:p(e,"%b %d"),value:"%b %d"},FORMAT_2:{Label:p(e,"%b %d, %Y"),value:"%b %d, %Y"},FORMAT_3:{Label:p(e,"%a, %b %d"),value:"%a, %b %d"},FORMAT_4:{Label:p(e,"%d/%m/%Y"),value:"%d/%m/%Y"},FORMAT_5:{Label:p(e,"%Y/%m/%d"),value:"%Y/%m/%d"},FORMAT_6:{Label:"Custom"}}};export{d as ESTIMATE_DAYS,y as OUT_OF_STOCK,p as getDayFormat,g as getFutureDay,o as getNewSetting,c as listFormatDate};
