import{h,Host}from"@stencil/core";import{state}from"../../../../store/product/index";import{state as upsellState}from"../../../../store/upsell/index";export class ScProductPrice{constructor(){this.prices=void 0,this.saleText=void 0,this.productId=void 0}renderRange(){var e;return null===(e=state[this.productId])||void 0===e?void 0:e.range_display_amount}renderVariantPrice(e){var t,i;const r=null===(i=null===(t=state[this.productId])||void 0===t?void 0:t.variants)||void 0===i?void 0:i.find((t=>(null==t?void 0:t.id)===(null==e?void 0:e.id)));return this.renderPrice(state[this.productId].selectedPrice,r)}renderPrice(e,t=null){var i,r,l,o,n,s;const u=null!==(r=null!==(i=null==t?void 0:t.display_amount)&&void 0!==i?i:null==e?void 0:e.display_amount)&&void 0!==r?r:"",d=(null===(l=null==upsellState?void 0:upsellState.line_item)||void 0===l?void 0:l.subtotal_with_upsell_discount_amount)||(null==e?void 0:e.amount),a=(null===(o=null==upsellState?void 0:upsellState.line_item)||void 0===o?void 0:o.subtotal_with_upsell_discount_display_amount)||u,c=(null===(n=null==upsellState?void 0:upsellState.line_item)||void 0===n?void 0:n.subtotal_amount)||(null==e?void 0:e.scratch_amount),p=(null===(s=null==upsellState?void 0:upsellState.line_item)||void 0===s?void 0:s.subtotal_display_amount)||(null==e?void 0:e.scratch_display_amount);return h("sc-price",{currency:null==e?void 0:e.currency,amount:d,displayAmount:a,scratchAmount:c,scratchDisplayAmount:p,saleText:this.saleText,adHoc:null==e?void 0:e.ad_hoc,trialDurationDays:null==e?void 0:e.trial_duration_days,setupFeeText:null==e?void 0:e.setup_fee_text,setupFeeAmount:(null==e?void 0:e.setup_fee_enabled)?null==e?void 0:e.setup_fee_amount:null,setupFeeName:(null==e?void 0:e.setup_fee_enabled)?null==e?void 0:e.setup_fee_name:null,recurringPeriodCount:null==e?void 0:e.recurring_period_count,recurringInterval:null==e?void 0:e.recurring_interval,recurringIntervalCount:null==e?void 0:e.recurring_interval_count})}render(){return h(Host,{key:"db06c43f30f8635d34dd12486b423999ad978847",role:"paragraph"},(()=>{var e,t,i,r,l;return(null===(e=state[this.productId])||void 0===e?void 0:e.selectedVariant)?this.renderVariantPrice(null===(t=state[this.productId])||void 0===t?void 0:t.selectedVariant):(null===(i=state[this.productId])||void 0===i?void 0:i.selectedPrice)?this.renderPrice(state[this.productId].selectedPrice):(null===(l=null===(r=state[this.productId])||void 0===r?void 0:r.prices)||void 0===l?void 0:l.length)?this.renderRange():h("slot",null)})())}static get is(){return"sc-product-price"}static get encapsulation(){return"shadow"}static get originalStyleUrls(){return{$:["sc-product-price.scss"]}}static get styleUrls(){return{$:["sc-product-price.css"]}}static get properties(){return{prices:{type:"unknown",mutable:!1,complexType:{original:"Price[]",resolved:"Price[]",references:{Price:{location:"import",path:"../../../../types",id:"src/types.ts::Price"}}},required:!1,optional:!1,docs:{tags:[],text:"The product's prices."}},saleText:{type:"string",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!1,docs:{tags:[],text:"The sale text"},attribute:"sale-text",reflect:!1},productId:{type:"string",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!1,docs:{tags:[],text:"The product id"},attribute:"product-id",reflect:!1}}}}