"use strict";var e=require("../../text/components/TextInline.js"),t=require("../../helpers.js"),a=require("@gem-sdk/system"),r=require("./styles.js"),s=require("../settings/configs/translate.js");const u=e=>e?"number"==typeof e?e:Number(e.split("days")[0]):0,l=e=>{let t=new Date(Date.now()),a=u(e?.estimateTime),r=u(e?.minEstimate),s=u(e?.maxEstimate),l=e?.typeFormat==="Custom"?e?.customFormat:e?.typeFormat;if(!l)return"";if(e?.typeEstimate===o.SPECIFIC){let e=`${m(y(a),l)}`;return e}m(t);let n=`${m(y(r),l)} - ${m(y(s),l)}`;return n},n=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"}},i=({type:u,styles:n,setting:i,builderProps:o,pageContext:m})=>{let y="React"===u,d=a.createClass({"estimate-date-main":!0}),c=y||m?.isPreviewing?i?.customText:t.getDynamicSourceLocales({val:i?.customText,uid:o?.uid,settingId:t.createSettingId({id:s.EstimateDate?.customText?.id}),pageContext:m??{},isCapitalize:n?.typo?.attrs?.transform==="capitalize"}).toString();return`${i?.enableCustomText===!1?"":e.default({styles:r.getStyleEstimateDate(n,"typoCustom"),setting:{text:c},elementAttrs:{debugText:JSON.stringify({pageContext:m,setting:i,isReact:y,builderProps:o,textWithTranslate:c}).replaceAll("'","&#039;")}})} ${e.default({styles:r.getStyleEstimateDate(n,"typoDate"),setting:{text:l(i)},className:d})}`},o={SPECIFIC:"specific",RANGE:"range"},m=(e,t="%B %d, %Y")=>{let a=e.getMonth()+1,r=e.getDate(),s=e.getFullYear(),u=[{type:"%a",value:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][e.getDay()]},{type:"%A",value:["Sunday","Monday","Tuesday","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:s.toString().slice(-2)},{type:"%Y",value:s},{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 u.forEach(e=>{t=t.replaceAll(e?.type,e?.value?.toString()||"")}),t},y=e=>{let t=new Date,a=new Date(t);return a.setDate(t.getDate()+Number(e)),a};exports.ESTIMATE_DAYS=o,exports.OUT_OF_STOCK={SHOW:"show",HIDE:"hide"},exports.getDayFormat=m,exports.getFutureDay=y,exports.getNewSetting=({type:e,styles:t,setting:a,builderProps:r,pageContext:s})=>{let u="React"===e,l=i({type:e,styles:t,setting:a,builderProps:r,pageContext:s});return{text:l,htmlTag:n(a),globalSize:a?.globalSize,background:a?.background,...!u&&{isForceValue:!0}}},exports.listFormatDate=()=>{let e=new Date(Date.now());return{FORMAT_1:{Label:m(e,"%b %d"),value:"%b %d"},FORMAT_2:{Label:m(e,"%b %d, %Y"),value:"%b %d, %Y"},FORMAT_3:{Label:m(e,"%a, %b %d"),value:"%a, %b %d"},FORMAT_4:{Label:m(e,"%d/%m/%Y"),value:"%d/%m/%Y"},FORMAT_5:{Label:m(e,"%Y/%m/%d"),value:"%Y/%m/%d"},FORMAT_6:{Label:"Custom"}}};
