"use strict";var t=require("@gem-sdk/core"),e=require("../components/constants/product-bundle.js");const o=e=>({discountPercentAmount:0,discountAmount:t.formatMoney("0",e)}),n=(t,e)=>Math.round((e-t)/e*100),r=(e,o,n)=>t.formatMoney((o-e).toString(),n),u=(t,o)=>{let n=parseInt(o?.discountValue);return o?.discountType===e.DiscountType.Percentage?t*o.quantity*n/100:o?.discountType===e.DiscountType.FixedAmount?n:0},c=(t,e)=>Math.round(t/e*100);exports.applyBundleDiscountAmount=i=>{let{currentVariant:m,bundleItem:s,options:a}=i;if(!a?.useProductCompareAtPrice&&s?.discountType===e.DiscountType.NoDiscount||!s||!m?.price)return o(a?.moneyFormat||"${{amount}}");let d=t.convertDecimalToNumber(m?.price)??0,p=t.convertDecimalToNumber(m?.salePrice)??d,y=Number(s?.quantity),l=u(d,s),P=c(l,y*d),A=d*y-l,T=p*y;return p<=d&&l<=0?o(a?.moneyFormat||"${{amount}}"):{discountPercentAmount:a?.useProductCompareAtPrice?n(A,T):P,discountAmount:a?.useProductCompareAtPrice?r(A,T,a?.moneyFormat):t.formatMoney(l.toString(),a?.moneyFormat)}};
