import{getResponsiveValueByScreen as t,cloneDeep as e}from"@gem-sdk/core";import{getImageSrc as o,composeAspectRatio as i}from"../../image/common/helpers.js";import{getDynamicSourceLocales as a,createSettingId as r}from"../../helpers.js";import{ImageComparison as l}from"../settings/configs/translate.js";let n=({styles:t,leftImage:e,rightImage:o})=>{let i=(e?.width??0)/(e?.height??1),a=(o?.width??0)/(o?.height??1),r=i<=a?`${e?.width??0}/${e?.height??1}`:`${o?.width??0}/${o?.height??1}`,l=s({aspect:t?.aspectRatio,auto:i<=a?e:o,custom:t?.customAspectRadio,defaultRatio:r});return{defaultRatio:r,responsiveAspectRatio:l}},s=({aspect:t,auto:e,custom:o,defaultRatio:a})=>({desktop:i({device:"desktop",aspect:t,auto:e,custom:o})??a,tablet:i({device:"tablet",aspect:t,auto:e,custom:o}),mobile:i({device:"mobile",aspect:t,auto:e,custom:o})}),p=({input:e,isHorizontal:o})=>{let{device:i,positionHoz:a,positionVer:r}=e,l=o?t(a,i,"hoz-center"):t(r,i,"ver-center");return({"hoz-center":{topLeft:"50%",bottomRight:"auto"},top:{topLeft:"8px",bottomRight:"auto"},bottom:{topLeft:"auto",bottomRight:"8px"},"ver-center":{topLeft:"50%",bottomRight:"auto"},left:{topLeft:"8px",bottomRight:"auto"},right:{topLeft:"auto",bottomRight:"8px"}})[l]??{topLeft:"50%",bottomRight:"auto"}},g=({position:t,labelPositionHoz:e,labelPositionVer:o,isHorizontal:i})=>({desktop:p({input:{device:"desktop",positionHoz:e,positionVer:o},isHorizontal:i})?.[t??"topLeft"],tablet:p({input:{device:"tablet",positionHoz:e,positionVer:o},isHorizontal:i})?.[t??"topLeft"],mobile:p({input:{device:"mobile",positionHoz:e,positionVer:o},isHorizontal:i})?.[t??"topLeft"]}),c=({isHorizontal:t,labelPositionHoz:e,labelPositionVer:o})=>{let i=t?e:o,a={desktop:i?.desktop??"hoz-center",tablet:i?.tablet??i?.desktop??"hoz-center",mobile:i?.mobile??i?.tablet??i?.desktop??"hoz-center"},r={desktop:"translateX(0) translateY(0)",tablet:"translateX(0) translateY(0)",mobile:"translateX(0) translateY(0)"};for(let e in a){let o=a?.[e];o.includes("center")?r[e]=t?"translateX(0) translateY(-50%)":"translateX(-50%) translateY(0)":r[e]="translateX(0) translateY(0)"}return r},u=t=>{let e="string"==typeof t?parseInt(t??0):t;return(e??50)/100},f={left:"start",center:"center",right:"end",justify:"start"},d=t=>{let{handle:e=null,hover:i=!1,handleSize:a=40,leftImageAlt:r="",leftImageTitle:l="",leftImageCss:s={},leftImageLabel:p=null,rightImageAlt:g="",rightImageTitle:c="",rightImageCss:u={},rightImageLabel:f=null,sliderLineWidth:d=2,sliderLineColor:h="#ffffff",sliderPositionPercentage:m=.5,vertical:b=!1,componentUid:L="",styles:R={},leftImage:v,rightImage:S,enableLabel:$=!1,qualityType:y,qualityPercent:I}=t,k=(v?.width??0)<(S?.width??0)?{...v}:{...S},{responsiveAspectRatio:x,defaultRatio:z}=n({leftImage:v,rightImage:S,styles:R});return{styles:R,handle:e,hover:i,handleSize:a,leftImageAlt:r,leftImageTitle:l,leftImageCss:s,leftImageLabel:p,rightImageAlt:g,rightImageTitle:c,rightImageCss:u,rightImageLabel:f,sliderLineWidth:d,sliderLineColor:h,sliderPositionPercentage:m,vertical:b,componentUid:L,tempImage:k,aspectRatio:x,defaultRatio:z,isHorizontal:!b,hasLeftLabel:$&&!!p,hasRightLabel:$&&!!f,qualityType:y,qualityPercent:I,getLeftImageSrc:t=>{let{isLiquid:e}=t??{};return e?o(v):v?.src??""},getRightImageSrc:t=>{let{isLiquid:e}=t??{};return e?o(S):S?.src??""}}},h=t=>{let{isHorizontal:e,containerWidth:o,containerHeight:i,sliderPosition:a,type:r}=t,l=e?o*a:i*a;return"left"===r?{clip:e?`rect(auto, ${l}px, auto, auto)`:`rect(auto, auto, ${l}px, auto)`}:{clip:e?`rect(auto, auto, auto, ${l}px)`:`rect(${l}px, auto, auto, auto)`}},m=t=>{let{isHorizontal:e,containerWidth:o,containerHeight:i,sliderPosition:a,handleSize:r}=t;return{[e?"top":"left"]:0,[e?"left":"top"]:`${(e?o*a:i*a)-r/2}px`}},b=t=>({...h(t)}),L=t=>({sliderPosition:m(t),leftImageClip:h({...t,type:"left"}),rightImageClip:h({...t,type:"right"}),leftLabelContainer:b({...t,type:"left"}),rightLabelContainer:b({...t,type:"right"})}),R=({setting:t,uid:o,pageContext:i})=>{if(!t)return;let n=e(t);for(let t of["Left","Right"]){let e=`image${t}`,s=n[e];if(s?.src){let t=a({val:s.src,uid:o,settingId:l?.[e]?.id?`${l?.[e]?.id}_src`:"",pageContext:i});n[e].src=String(t)}let p=`alt${t}`,g=a({val:n[p],uid:o,settingId:r({id:l?.[p]?.id}),pageContext:i});n[p]=String(g);let c=`title${t}`,u=a({val:n[c],uid:o,settingId:r({id:l?.[c]?.id}),pageContext:i});n[c]=String(u)}return n};export{f as FLEX_ALIGN,p as composeLabelPosition,s as composeResponsiveAspectRatio,c as generateTranslateByDevices,n as getAspectRatioData,d as getData,h as getImageClipStyle,b as getLabelContainerStyles,g as getLabelPosition,L as getReactStyles,R as getSettingTranslatedImageComparisonAndSeo,u as getSliderPositionPercentage,m as getSliderPositionStyle};
