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:"747b67d7ad42320d6adb06cc5ae4fe436fe4a235","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:"196450bc06fc13b019597a2a43f8f828451a6a48",slot:"price"},this.renderAmountDue()),h("sc-divider",{key:"75928d2ebbcf0182a73d99bec267a037c74bb735"}),h("sc-line-item",{key:"85ecf7678ac9745cd476a5b5955de119d3d9ffbf"},h("span",{key:"48b1d5f1e2531fd0063381daab4474d996c6adb2",slot:"description"},__("Subtotal","surecart")),h("span",{key:"9868f8f7e434781799d6efa348843ced7e688d08",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:"d63bab2a8923f2ca489a06a9de404c212df04664"},h("span",{key:"ff98910f35dc395785b8143a5bcda2927c786146",slot:"description"},__("Tax","surecart")),h("span",{key:"74b6f6a9d2ddeb60c16b9cf0996732e1770e06e9",slot:"price"},null===(s=state.line_item)||void 0===s?void 0:s.tax_display_amount)),h("sc-divider",{key:"b2f92fd9d64201ce657af3f19453e08cc09388a3"}),h("sc-line-item",{key:"b06804f6fea2d1a420ff84996f52fff18fe18ebe",style:{"--price-size":"var(--sc-font-size-x-large)"}},h("span",{key:"fc7f52b8e713f67f465c962642a5053bcbe1b2bd",slot:"title"},__("Total","surecart")),h("span",{key:"257336b340f5c54be8b442af8653b5a7ce7b5f6a",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"]}}}