'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),React=require("react"),Text=require("../../text/components/Text.js"),useDynamicProduct=require("../hooks/useDynamicProduct.js"),TooltipHover=require("../../../common/components/TooltipHover.js");const PostPurchaseProductPrice=({styles:e,style:r,builderAttrs:o,builderProps:t,children:s,setting:c})=>{let i=core.useCurrentVariant(),u=core.useProduct(),a=core.convertDecimalToNumber(i?.price)??0,p=core.convertDecimalToNumber(i?.salePrice)??0,n=parseFloat(core.shopifyPriceRounding(core.useProductOfferDiscount(),2)),d=a-n>0?a-n:a,{isDynamicProduct:l}=useDynamicProduct.useDynamicProduct(),{t:m}=core.useI18nStore(),{isEditMode:x}=core.useRenderMode(),{priceType:g,source:h}=c??{},y="compare"===g,P="offer"===g,f="price"===h,j="compare-price"===h,b=React.useMemo(()=>y?f?a:p:P?d:a,[y,f,P,a,p,d]),R=core.useFormatMoney(parseFloat(core.shopifyPriceRounding(Number(b)||0,2)),!1),N=u?.baseID?.replace("gid://shopify/Product/",""),v=React.useMemo(()=>y&&(!n&&p<a||j&&!p||f&&a<=0),[y,n,a,p,j]);return(!b&&!P||v)&&x?jsxRuntime.jsx(TooltipHover.default,{enable:!0,text:"Not be displayed when published",width:"205px",position:"bottom",className:"gp-arrow-left-offset-10",children:jsxRuntime.jsx("div",{className:"gp-h-[28px] gp-px-1.5 gp-py-1 gp-flex gp-border gp-border-light-200 gp-items-center gp-justify-center gp-rounded-lg",style:{borderStyle:"dashed",strokeDasharray:"2,2"},children:jsxRuntime.jsx("span",{className:"gp-text-dark-400 gp-text-[12px] gp-leading-5",children:m("No compare price")})})}):v&&!x?null:jsxRuntime.jsxs("div",{...o,className:core.cls(t?.uid),style:{...r},id:`shopify-text-element-${t?.uid}`,"data-product-id":N,children:[jsxRuntime.jsx(Text.default,{styles:e,setting:{text:l?"$???":R},className:core.cls({"gp-money":P,"gp-product-compare-price":y,"gp-line-through":y&&e?.lineThrough})}),s]})};exports.default=PostPurchaseProductPrice;
