"use strict";var e=require("@gem-sdk/core"),t=require("../utils/common.js"),o=require("../utils/getShapePosition.js"),r=require("../utils/getRotateShape.js"),i=require("../utils/getStyleAdvanced.js"),a=require("../utils/getWhiteSpace.js"),n=require("../utils/stylesV2.js"),s=require("../utils/shape.js"),p=require("../utils/renderBadgeILP.js");const g=e=>{let{setting:o,styles:r}=e,i=s.getShape(o?.shape),a=o?.contentType==="text",n=a?r?.textSizeV2:r?.imageSizeV2;return a?t.getSize(i,n):t.getSize(void 0,n)},l=({styles:e,setting:t})=>{let o=s.getShape(t?.shape),r=t?.contentType==="text";return o?.supportBorder?r?n.getStyleBorder(e?.textBadgeBorder):n.getStyleBorder(e?.imageBadgeBorder):{}},d=({styles:e,setting:t})=>{let o=s.getShape(t?.shape),r=t?.contentType==="text";return o?.supportCorner?r?n.getStyleCornerRadius(e?.textBadgeCorner,o?.shapeRadius):n.getStyleCornerRadius(e?.imageBadgeCorner,o?.shapeRadius):{}},u=({props:o,currentVariant:r,product:i,isEditMode:a})=>{let{"bundle-item":n,setting:s}=o;if(n)return 1;let g=s?.contentType==="text",l=g&&!s?.displayContent?.trim(),d=t.checkDiscountContentProductBadge(s?.displayContent);if(l)return a?.2:0;let u=e.convertDecimalToNumber(r?.price)??0,S=e.convertDecimalToNumber(r?.salePrice)??0,y=p.checkShowBadge(s?.displayTrigger,i,r);return(S-u>0||!d)&&y?1:a?.2:0};exports.getContainerStyle=(e,r=!1)=>{let{setting:a,styles:n,style:s,navigationPosition:p,imageData:l,dotData:d}=e,u=a?.positionWithImage==="outside",S=t.getWrapperStyle(r),y=o.getShapePosition({positionType:n?.position,navigationPosition:p,dataImage:{...l,...d}}),h=g(e),c=i.getStyleAdvanced(u?{}:{...y,...h},s);return{...!u&&{"--pos":"absolute"},...S,...c}},exports.getContentStyleInternal=e=>{let{styles:t,setting:o,builderProps:r}=e,i=o?.contentType==="text";return n.generateShadowCSS(`[id="${r?.uid}"] .product-badge-item`,i?t?.textBadgeShadow:t?.imageBadgeShadow)},exports.getImageContainerStyles=({styles:t,setting:o})=>{let r=l({setting:o,styles:t}),i=d({setting:o,styles:t}),a=e.makeGlobalSize(t?.imageSizeV2).padding;return{...r,...i,...a}},exports.getSubWrapperStyle=({props:e,product:t,currentVariant:o,isEditMode:r})=>{let{setting:i}=e,a=i?.positionWithImage==="outside",n=g(e),s=r&&o?u({props:e,currentVariant:o,product:t,isEditMode:r}):1;return{...a?{...n,"--mb":0}:{},opacity:s}},exports.getTextBadgeWrapperStyles=({styles:e,setting:o})=>{let i=s.getShape(o?.shape),a=l({setting:o,styles:e}),p=o?.positionWithImage==="outside",g=d({setting:o,styles:e}),u=t.getShapeWrapperPadding(i?.ratio);return{...a,...g,...r.composeShapeStyleByPosition(i,e?.position,p),...n.getStyleBackground(!i?.backgroundColorInText,e?.badgeColorV2),...u,height:i?.ratio===1?"0px":"100%"}},exports.getTextContentStyle=({styles:o,setting:i})=>{let p=e.makeGlobalSize(o?.textSizeV2).padding,g=s.getShape(i?.shape),l=i?.positionWithImage==="outside";return{...a.getWhiteSpaceStyle(o?.textSizeV2),...t.convertToStyle(g?.textStyle),...r.composeTextStyleByPosition(g,o?.position,l),...e.composeTypographyStyle(o?.typo),...e.getStyleShadow({value:o?.typo?.custom?.textShadow,styleAppliedFor:"text-shadow",isEnableShadow:o?.typo?.custom?.hasShadowText}),...n.getStyleBackground(!!g?.backgroundColorInText,o?.badgeColorV2),...p}};
