FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
components
Edit File: sc-line-item-total.js
import{proxyCustomElement,HTMLElement,h,Fragment}from"@stencil/core/internal/client";import{f as formBusy}from"./getters3.js";import{s as state}from"./mutations2.js";import{d as defineCustomElement$8}from"./sc-divider2.js";import{d as defineCustomElement$7}from"./sc-icon2.js";import{d as defineCustomElement$6}from"./sc-line-item2.js";import{d as defineCustomElement$5}from"./sc-skeleton2.js";import{d as defineCustomElement$4}from"./sc-tooltip2.js";import{d as defineCustomElement$3}from"./sc-total2.js";import{d as defineCustomElement$2}from"./sc-visually-hidden2.js";const scLineItemTotalCss=":host{display:block}sc-line-item{text-align:left}.line-item-total__group sc-line-item{margin:4px 0px !important}.scratch-price{text-decoration:line-through;color:var(--sc-color-gray-500);font-size:var(--sc-font-size-small);margin-right:var(--sc-spacing-xx-small)}sc-line-item::part(base){grid-template-columns:max-content auto auto}.total-price{white-space:nowrap}.currency-label{color:var(--sc-color-gray-500);font-size:var(--sc-font-size-xx-small);margin-right:var(--sc-spacing-xx-small);vertical-align:middle}sc-divider{margin:16px 0 !important}.conversion-description{color:var(--sc-color-gray-500);font-size:var(--sc-font-size-small);margin-right:var(--sc-spacing-xx-small)}.total-payments-tooltip::part(base){display:flex;align-items:center;gap:0.25em}",ScLineItemTotalStyle0=scLineItemTotalCss,ScLineItemTotal$1=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.order_key={total:"total_amount",subtotal:"subtotal_amount",amount_due:"amount_due"},this.total="total",this.size=void 0,this.checkout=void 0}hasInstallmentPlan(t){return(null==t?void 0:t.full_amount)!==(null==t?void 0:t.subtotal_amount)}hasSubscription(t){var e;return((null===(e=null==t?void 0:t.line_items)||void 0===e?void 0:e.data)||[]).some((t=>{var e,s,l;return"month"===(null===(e=null==t?void 0:t.price)||void 0===e?void 0:e.recurring_interval)&&!!(null===(s=null==t?void 0:t.price)||void 0===s?void 0:s.recurring_interval)&&!(null===(l=null==t?void 0:t.price)||void 0===l?void 0:l.recurring_period_count)}))}renderLineItemTitle(t){return"total"===this.total&&this.hasInstallmentPlan(t)?h("span",{slot:"title"},h("slot",{name:"first-payment-total-description"},wp.i18n.__("Subtotal","surecart"))):h("span",{slot:"title"},h("slot",{name:"title"}))}renderCheckoutFees(t){var e,s,l,i;return(null===(s=null===(e=null==t?void 0:t.checkout_fees)||void 0===e?void 0:e.data)||void 0===s?void 0:s.length)?h(Fragment,null,null===(i=null===(l=null==t?void 0:t.checkout_fees)||void 0===l?void 0:l.data)||void 0===i?void 0:i.map((t=>h("sc-line-item",{key:t.id},h("span",{slot:"description"},t.description),h("span",{slot:"price"},t.display_amount))))):null}renderLineItemDescription(t){return"subtotal"===this.total&&this.hasInstallmentPlan(t)?h("span",{slot:"description"},h("slot",{name:"first-payment-subtotal-description"},wp.i18n.__("Initial Payment","surecart"))):h("span",{slot:"description"},h("slot",{name:"description"}))}getCurrencyToDisplay(){var t,e,s,l;const i=this.checkout||(null==state?void 0:state.checkout);return(null===(e=null===(t=null==i?void 0:i.amount_due_default_currency_display_amount)||void 0===t?void 0:t.toLowerCase())||void 0===e?void 0:e.includes(null===(s=null==i?void 0:i.currency)||void 0===s?void 0:s.toLowerCase()))?"":null===(l=null==i?void 0:i.currency)||void 0===l?void 0:l.toUpperCase()}renderConversion(){var t;if("total"!==this.total)return null;const e=this.checkout||(null==state?void 0:state.checkout);return(null==e?void 0:e.show_converted_total)?(null==e?void 0:e.currency)===(null==e?void 0:e.current_currency)?null:(null==e?void 0:e.amount_due)?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"},wp.i18n.__("Payment Total","surecart"))),h("span",{slot:"price"},this.getCurrencyToDisplay()&&h("span",{class:"currency-label"},this.getCurrencyToDisplay()),null==e?void 0:e.amount_due_default_currency_display_amount)),h("sc-line-item",null,h("span",{slot:"description",class:"conversion-description"},wp.i18n.sprintf(wp.i18n.__("Your payment will be processed in %s.","surecart"),null===(t=null==e?void 0:e.currency)||void 0===t?void 0:t.toUpperCase())))):null:null}render(){var t;const e=this.checkout||(null==state?void 0:state.checkout);return formBusy()&&!(null==e?void 0:e[null===(t=null==this?void 0:this.order_key)||void 0===t?void 0:t[null==this?void 0:this.total]])?h("sc-line-item",null,h("sc-skeleton",{slot:"title",style:{width:"120px",display:"inline-block"}}),h("sc-skeleton",{slot:"price",style:{width:"70px",display:"inline-block",height:"large"===this.size?"40px":"","--border-radius":"6px"}})):(null==e?void 0:e.currency)?"total"===this.total&&(null==e?void 0:e.total_amount)!==(null==e?void 0:e.amount_due)?h("div",{class:"line-item-total__group"},h("sc-line-item",null,h("span",{slot:"description"},this.hasInstallmentPlan(e)?this.renderLineItemTitle(e):h(Fragment,null,h("slot",{name:"title"}),h("slot",{name:"description"}))),h("span",{slot:"price"},h("sc-total",{total:this.total,checkout:e}))),!!e.trial_amount&&h("sc-line-item",null,h("span",{slot:"description"},h("slot",{name:"free-trial-description"},wp.i18n.__("Trial","surecart"))),h("span",{slot:"price"},null==e?void 0:e.trial_display_amount)),h("sc-line-item",{style:{"--price-size":"var(--sc-font-size-x-large)"}},this.hasSubscription(e)?h("span",{slot:"title"},h("slot",{name:"subscription-title"},wp.i18n.__("Total Due Today","surecart"))):h("span",{slot:"title"},h("slot",{name:"due-amount-description"},wp.i18n.__("Amount Due","surecart"))),h("span",{slot:"price"},null==e?void 0:e.amount_due_display_amount)),this.renderConversion()):h(Fragment,null,"subtotal"===this.total&&this.hasInstallmentPlan(e)&&h("sc-line-item",{style:"large"===this.size?{"--price-size":"var(--sc-font-size-x-large)"}:{}},h("span",{slot:"description"},(null==e?void 0:e.discount_amount)?h("sc-tooltip",{class:"total-payments-tooltip",type:"text",text:wp.i18n.__("This is the total of all installment payments at full price, before any discounts are applied.","surecart"),width:"275px"},h("slot",{name:"total-payments-description"},wp.i18n.__("Total Installments","surecart"))," ",wp.i18n.__("(before discounts)","surecart"),h("sc-icon",{name:"info","aria-hidden":"true"}),h("sc-visually-hidden",null,wp.i18n.__("This is the total of all installment payments at full price, before any discounts are applied.","surecart"))):h("slot",{name:"total-payments-description"},wp.i18n.__("Total Installments","surecart"))),h("span",{slot:"price"},null==e?void 0:e.full_display_amount)),h("sc-line-item",{style:"large"===this.size?{"--price-size":"var(--sc-font-size-x-large)"}:{}},this.renderLineItemTitle(e),this.renderLineItemDescription(e),h("span",{slot:"price"},!!(null==e?void 0:e.total_savings_amount)&&"total"===this.total&&h("span",{class:"scratch-price"},null==e?void 0:e.total_scratch_display_amount),h("sc-total",{class:"total-price",total:this.total,checkout:e}))),this.renderConversion(),"subtotal"===this.total&&this.renderCheckoutFees(e)):void 0}static get style(){return ScLineItemTotalStyle0}},[1,"sc-line-item-total",{total:[1],size:[1],checkout:[16]}]);function defineCustomElement$1(){"undefined"!=typeof customElements&&["sc-line-item-total","sc-divider","sc-icon","sc-line-item","sc-skeleton","sc-tooltip","sc-total","sc-visually-hidden"].forEach((t=>{switch(t){case"sc-line-item-total":customElements.get(t)||customElements.define(t,ScLineItemTotal$1);break;case"sc-divider":customElements.get(t)||defineCustomElement$8();break;case"sc-icon":customElements.get(t)||defineCustomElement$7();break;case"sc-line-item":customElements.get(t)||defineCustomElement$6();break;case"sc-skeleton":customElements.get(t)||defineCustomElement$5();break;case"sc-tooltip":customElements.get(t)||defineCustomElement$4();break;case"sc-total":customElements.get(t)||defineCustomElement$3();break;case"sc-visually-hidden":customElements.get(t)||defineCustomElement$2()}}))}const ScLineItemTotal=ScLineItemTotal$1,defineCustomElement=defineCustomElement$1;export{ScLineItemTotal,defineCustomElement};
Save
Back