import{getResponsiveValueByScreen as e,makeAspectRatio as t,makeStyleResponsive as i,removeNullUndefined as o,DEVICES as r}from"@gem-sdk/core";let getTypeWidthDevice=e=>{let t=e?.desktop,i=e?.tablet===void 0?t:e?.tablet,o=e?.mobile===void 0?i:e?.mobile;return{desktop:t,tablet:i,mobile:o}},convertUnitToNumber=(e,t)=>{if(!e)return t;if("number"==typeof e)return e;let i=e.replaceAll("px","").replaceAll("%","").replaceAll("rem","").replaceAll("em","");return isNaN(Number(i))?t:Number(i)},convertSpacing=e=>{if(!e)return{desktop:5};let t=convertUnitToNumber(e.desktop,5),i=convertUnitToNumber(e.tablet,t),o=convertUnitToNumber(e.mobile,i);return{desktop:t,tablet:i,mobile:o}},getDisplayStyle=(e,t)=>{let i={},o=["desktop","mobile","tablet"];return o.forEach(o=>{i={...i,[`--d${"desktop"===o?"":`-${o}`}`]:`${e(o)?"none":t}`}}),i},checkAddOverFlowClass=e=>{let t=e?.["--radius"],i=e?.["--bblr"]||"0px",o=e?.["--bbrr"]||"0px",r=e?.["--btlr"]||"0px",l=e?.["--btrr"]||"0px";return t&&!t.toString().includes("none")&&"0"!==t.toString()||"0px"!==i||"0px"!==o||"0px"!==r||"0px"!==l},getAspectRatio=i=>{let o={},r=["desktop","mobile","tablet"];return r.forEach(t=>{let r=e(i,t)?.shapeValue;if(r)o={...o,[t]:r};else{let r=e(i,t)?.shape;switch(r){case"square":o={...o,[t]:"1/1"};break;case"vertical":o={...o,[t]:"3/4"};break;case"horizontal":o={...o,[t]:"4/3"};break;case"original":o={...o,[t]:""}}}}),t(o)},getStyleGridLayout=t=>{let i={"--gtc":"minmax(0, 12fr)","--gtc-tablet":"minmax(0, 12fr)","--gtc-mobile":"minmax(0, 12fr)"};if(!t.isHiddenGalleryImages){let o=!1;r.forEach(r=>{let l=e(t.position,r),a=e(t.ratioLayout,r),n=e(t.ratioLayoutRight,r),s="desktop"===r?"--gtc":`--gtc-${r}`,d="desktop"===r?"--gtr":`--gtr-${r}`,u="left"===l?a:n,c=["left","right"].includes(l||"");c&&u?(o=!0,Object.assign(i={...i,[s]:`minmax(0, ${u[0]}fr) minmax(0, ${u[1]}fr)`},{[d]:"fit-content(0)"})):o&&Object.assign(i,{[d]:"unset"})})}return i},getStyleGridOrderForFeature=t=>{let i={"--o":"0","--o-tablet":"0","--o-mobile":"0"},o=["desktop","mobile","tablet"];return o.forEach(o=>{let r=e(t.position,o),l="desktop"===o?"--o":`--o-${o}`;i={...i,[l]:"left"===r?"1":"0"}}),i},getStyleGridOrderForGallery=t=>{let i={"--o":"1","--o-tablet":"1","--o-mobile":"1"},o=["desktop","mobile","tablet"];return o.forEach(o=>{let r=e(t.position,o),l="desktop"===o?"--o":`--o-${o}`;i={...i,[l]:"left"===r?"0":"1"}}),i},getSrcImage=e=>`{{${e} | image_url: width: 480}} 480w, {{${e} | image_url: width: 768}} 768w, {{${e} | image_url: width: 1024}} 1024w, {{${e} | image_url: width: 1440}} 1440w`,convertSpacingForIndisdeLayout=e=>{let t=parseInt(e)?`${2*parseInt(e)}px`:`${e} * 2`;return t},getStyleInsideLayout=(t,r,l)=>{let a=["desktop","mobile","tablet"],n={},s={},d={},u={},c={},g={};return a.forEach(i=>{let o=e(t,i),a=e(r,i)?.width,m=e(l,i);if(n={...n,[i]:["inside-bottom","inside-left","inside-right"].includes(o)?"absolute":"static"},["inside-bottom"].includes(o)){let e=convertSpacingForIndisdeLayout(m);a=`calc(100% - ${e})`}["bottom-center","two-col","one-col"].includes(o)&&(a="100%"),d={...d,[i]:"inside-bottom"===o?`${m}`:"auto"},u={...u,[i]:["inside-left","inside-right"].includes(o)?`${m}`:"auto"},g={...g,[i]:["inside-bottom","inside-left"].includes(o)?`${m}`:"auto"},c={...c,[i]:"inside-right"===o?`${m}`:"auto"},s={...s,[i]:a}}),{...i("pos",n),...i("w",o(s)),...i("bottom",o(d)),...i("top",o(u)),...i("left",o(g)),...i("right",o(c))}},getConditionRenderGalleryImages=(t,i)=>{let o=["desktop","mobile","tablet"],r=!0,l=!1;return o.forEach(o=>{let a=e(t,o),n=e(i,o);a&&"only-feature"!==a&&(r=!1),(["two-col","one-col"].includes(a)||"images"===n)&&(l=!0)}),{isOnlyFeatureAllDevices:r,isRenderGalleryGrid:l}},setDefaultWhenUndefineSetting=e=>({...e,setting:{...e.setting}}),getValueFromValueContainUnit=e=>{let t=e.match(/\d+/g);return t?t[0]:e},getPaddingBottomByShapeSetting=t=>{let i=getAspectRatio(t),o={desktop:"auto",mobile:"auto",tablet:"auto"},r=["desktop","mobile","tablet"];return r.forEach(r=>{let l=e(t,r),a=l?.height,n=l?.width||"",s=getValueFromValueContainUnit(a||""),d=n.toString().match(/px/g)?getValueFromValueContainUnit(n):n;if(a&&n&&!isNaN(Number(s))&&!isNaN(Number(d))){o={...o,[r]:`${Number(s)/Number(d)*100}%`};return}if(a&&!isNaN(Number(s))){o={...o,[r]:a};return}let u=i?.[r]!=="auto"&&i?.[r]?i?.[r]?.split("/").reverse().join("/"):"{%if largestRatio == 0%} 100 / 100 {%else%} {{largestRatio}} {%endif%}";o={...o,[r]:`calc((${u})*100%)`}}),o};export{checkAddOverFlowClass,convertSpacing,convertSpacingForIndisdeLayout,convertUnitToNumber,getAspectRatio,getConditionRenderGalleryImages,getDisplayStyle,getPaddingBottomByShapeSetting,getSrcImage,getStyleGridLayout,getStyleGridOrderForFeature,getStyleGridOrderForGallery,getStyleInsideLayout,getTypeWidthDevice,setDefaultWhenUndefineSetting};
