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:"0739e9a5e58f06809010600ee86477fc0b6445cd","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:"b32507711695115f0153a8ee1845b60206fff5cb",slot:"price"},this.renderAmountDue()),h("sc-divider",{key:"540e49f003316e25de41c89a9aae25c92fc3eb19"}),h("sc-line-item",{key:"42685d605e95d41c0cec77d90e38b4faa6ac4e62"},h("span",{key:"62b4150b6662b7d1ccdf289ef4c8750b7099f3a8",slot:"description"},__("Subtotal","surecart")),h("span",{key:"4e2d9964124462f81f134ac3e4372afe71dda97e",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:"19e1a9d0655108d70503d86b215411c00487d6e4"},h("span",{key:"e2eafc99985ade97f4e11f95d4a6789d3fb78116",slot:"description"},__("Tax","surecart")),h("span",{key:"9f0a4cf920bc02c09e1821f26626bbce40a48737",slot:"price"},null===(s=state.line_item)||void 0===s?void 0:s.tax_display_amount)),h("sc-divider",{key:"6545d8c687d93a4a36665089c25aa9d308a86a89"}),h("sc-line-item",{key:"8b83c46bf4aca2026ed11cce8f2e2c90bb14dc57",style:{"--price-size":"var(--sc-font-size-x-large)"}},h("span",{key:"e2543cabacdde57f186326db3526cbaadc3181fe",slot:"title"},__("Total","surecart")),h("span",{key:"753e87177fd456753ed4ac3f306aa4b1a5193737",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"]}}}