import{Fragment,h}from"@stencil/core";import{state}from"../../../../store/upsell/index";import{__,sprintf}from"@wordpress/i18n";export class ScUpsellTotals{renderAmountDue(){var e,t;return state.amount_due>0?null===(e=null==state?void 0:state.line_item)||void 0===e?void 0:e.total_display_amount:(null===(t=null==state?void 0:state.line_item)||void 0===t?void 0:t.trial_amount)?__("Trial","surecart"):__("Free","surecart")}getCurrencyToDisplay(){var e,t,l,i,a,s,n;return(null===(l=null===(t=null===(e=null==state?void 0:state.line_item)||void 0===e?void 0:e.total_default_currency_display_amount)||void 0===t?void 0:t.toLowerCase())||void 0===l?void 0:l.includes(null===(a=null===(i=null==state?void 0:state.line_item)||void 0===i?void 0:i.currency)||void 0===a?void 0:a.toLowerCase()))?"":null===(n=null===(s=null==state?void 0:state.line_item)||void 0===s?void 0:s.currency)||void 0===n?void 0:n.toUpperCase()}renderConversion(){var e,t,l,i,a,s;const n=null==state?void 0:state.checkout;return(null==n?void 0:n.show_converted_total)?(null==n?void 0:n.currency)===(null==n?void 0:n.current_currency)?null:(null===(e=null==state?void 0:state.line_item)||void 0===e?void 0:e.total_amount)?h(Fragment,null,h("sc-divider",null),h("sc-line-item",{style:{"--price-size":"var(--sc-font-size-x-large)"}},h("span",{slot:"title"},h("slot",{name:"charge-amount-description"},sprintf(__("Payment Total","surecart"),null===(l=null===(t=null==state?void 0:state.line_item)||void 0===t?void 0:t.currency)||void 0===l?void 0:l.toUpperCase()))),h("span",{slot:"price"},this.getCurrencyToDisplay()&&h("span",{class:"currency-label"},this.getCurrencyToDisplay()),null===(i=null==state?void 0:state.line_item)||void 0===i?void 0:i.total_default_currency_display_amount)),h("sc-line-item",null,h("span",{slot:"description",class:"conversion-description"},sprintf(__("Your payment will be processed in %s.","surecart"),null===(s=null===(a=null==state?void 0:state.line_item)||void 0===a?void 0:a.currency)||void 0===s?void 0:s.toUpperCase())))):null:null}render(){var e,t,l,i,a,s,n;return h("sc-summary",{key:"f2a9a789c5ab146aa85b10ccb620ed5f747d88ec","open-text":"Total","closed-text":"Total",collapsible:!0,collapsed:!0},!!(null===(e=state.line_item)||void 0===e?void 0:e.id)&&h("span",{key:"183566a39c2765e17de88d985d1f93eb335c18c7",slot:"price"},this.renderAmountDue()),h("sc-divider",{key:"8322051ddcfcf14fdce826ca43b8fd717920999e"}),h("sc-line-item",{key:"de33cabc82f633851da4bae515fcf9642176ea2e"},h("span",{key:"25a1a714932dd6bce87691fdeb745f0aecf60c2a",slot:"description"},__("Subtotal","surecart")),h("span",{key:"c60058156150311acac7727e2e006e7356e19d59",slot:"price"},null===(t=state.line_item)||void 0===t?void 0:t.subtotal_display_amount)),((null===(i=null===(l=null==state?void 0:state.line_item)||void 0===l?void 0:l.fees)||void 0===i?void 0:i.data)||[]).filter((e=>"upsell"===e.fee_type)).map((e=>h("sc-line-item",null,h("span",{slot:"description"},e.description," ",`(${__("one time","surecart")})`),h("span",{slot:"price"},null==e?void 0:e.display_amount)))),!!(null===(a=state.line_item)||void 0===a?void 0:a.tax_amount)&&h("sc-line-item",{key:"0830506eb419cf4f91d7b9ae97bde09a1ec85c48"},h("span",{key:"6bb33b6d66a3daf7ed274996a2910b44b4d158b0",slot:"description"},__("Tax","surecart")),h("span",{key:"7f0fd638d841715fc280f8be94ac572f1141f1ca",slot:"price"},null===(s=state.line_item)||void 0===s?void 0:s.tax_display_amount)),h("sc-divider",{key:"535d5ebcbd3eb12bbc401dc673e08e8b3dae0fda"}),h("sc-line-item",{key:"f34a3e1b42306842cd8418f91a91c3af33d70aa5",style:{"--price-size":"var(--sc-font-size-x-large)"}},h("span",{key:"42cd6bd3e4ac3210e2a2a08b35b0b9fd942292bd",slot:"title"},__("Total","surecart")),h("span",{key:"68ca302cb45dec0716b10b8215c0cd582a606167",slot:"price"},null===(n=state.line_item)||void 0===n?void 0:n.total_display_amount)),this.renderConversion())}static get is(){return"sc-upsell-totals"}static get encapsulation(){return"shadow"}static get originalStyleUrls(){return{$:["sc-upsell-totals.css"]}}static get styleUrls(){return{$:["sc-upsell-totals.css"]}}}