import{HREF_TO_SALES_PAGE as e}from"../../constant.js";import{getAspectRatio as t,getNewBackupFileKey as r,getImageSrc as a,safeStringify as s,IMAGE_PLACEHOLDER as l,NEXT_IMAGE_CONFIG as i,getSrcSet as o,createBlurDataURL as g}from"./helpers.js";import{createAttr as p}from"@gem-sdk/system";import{handleClickLink as n}from"../../helpers.js";import{PRIORITY_LOAD_ATTRS as c}from"../constants.js";let u=(e,t)=>({...e,...t&&{"data-id":t}}),d=({urlData:t,imageLink:r,title:a,isLiquid:s=!1})=>{let l=s?{...t,...r?.noFollow&&{rel:"nofollow"},title:a}:{setting:t,title:a};return r?.type!=="go-to-sales-page"?r?.link?l:{}:s?{href:e,target:"_self"}:{setting:{href:e,target:"_self"}}},y=({pageContext:e})=>({...e&&{pageContext:e}}),m=({styles:e,setting:l,mode:i,isLiquid:o})=>{let{alt:g,srcSet:p,priority:u,qualityPercent:d,qualityType:y,title:m}=l??{},L=t({styles:e,setting:l}),k=p?.desktop?.backupFileKey?r(p?.desktop?.backupFileKey??"",p?.desktop?.src??""):"",A=o?a({src:p?.desktop?.src,backupFileKey:k,backupFilePath:p?.desktop?.backupFilePath,storage:p?.desktop?.storage}):p?.desktop?.src??"",b=u?{}:{"base-src":A??"","quality-type":s(y),"quality-percent":s(d)};return{pictureClass:"gp-contents",...g&&{alt:g},...m&&{title:m},...p&&{srcSet:p},...u&&c,...b,...e?.objectFit&&{layout:e.objectFit},onClick:()=>{n(l?.imageLink,i)},aspectRatio:L}},L=({styles:e,setting:r})=>{let{objectFit:a}=e??{},{vw:s,alt:l,title:i,quality:o,priority:g,isNotLazyload:p,qualityType:n,qualityPercent:c}=r??{},u=t({styles:e,setting:r});return{...r?.image,...s&&{vw:s},...l&&{alt:l},...i&&{title:i},...o&&{quality:o},...g&&{priority:g},isNotLazyload:p,setting:{aspectRatio:u,layout:a,qualityType:n,qualityPercent:c}}},k=e=>{let{srcset:t,setting:l,storage:n,baseSrc:c,priority:u,customAttrs:d,width:y=2237,height:m=1678,isNotLazyload:L,backupFileKey:k,backupFilePath:A,srcIsLiquidCode:b,pageContext:F,alt:f=i.DEFAULT_ALT,title:h,src:T=i.DEFAULT_SRC,sizes:E=i.DEFAULT_SIZES}=e,_=!L&&(F?.enableLazyLoadImage??!0)&&!u;return p({...d,...(()=>{let{qualityPercent:e,qualityType:t}=l??{},r=!u&&t&&e?{"quality-type":s(t),"quality-percent":s(e)}:{"quality-type":"","quality-percent":""};return{...f&&{alt:f},...h&&{title:h},width:y,height:m,draggable:"false",...r}})(),...(()=>{let e=k?r(k??"",T):"",s=b?c:a({src:T,backupFileKey:e,backupFilePath:A,storage:n}),l=b?T:o(e??"",n??"THEME",T),i={sizes:"100vw",src:g(y,m),...s&&!u?{"base-src":s}:{},...s?{"data-src":s}:{},...l?{"data-srcset":l}:{}},p={sizes:E,src:s??"",isNotLazyload:"true",srcset:t??"",...s&&!u?{"base-src":s}:{},...u?{loading:"eager",fetchpriority:"high"}:{loading:"lazy"}};return{"data-sizes":"auto",..._?i:p}})()})},A=e=>{let{width:t=i.DEFAULT_WIDTH_PROPS,height:r=i.DEFAULT_HEIGHT_PROPS,quality:a,priority:s,isNotLazyload:o,pageContext:g,base64:n=l,alt:c=i.DEFAULT_ALT,title:u,src:d=i.DEFAULT_SRC}=e,y=!o&&(g?.enableLazyLoadImage??!0)&&!s,m=p((()=>{let e={loading:"lazy",placeholder:"blur",...n&&{blurDataURL:n}};return{...y?e:{loading:"eager",fetchpriority:"high"}}})());return{src:d,alt:c,title:u,width:t,height:r,quality:a,...m}};export{m as getAdaptiveImageAttrs,u as getContainerAttrs,y as getImageLiquidAttrs,d as getLinkWrapperAttrs,L as getNextImageAttrs,k as getNextImageLiquidAttrs,A as getNextImageReactAttrs};
