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