JezK
Edit File: sc-upsell-totals.cjs.entry.js
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); const index = require('./index-be4abba1.js'); require('./watchers-08c6f04b.js'); const store = require('./store-401bdb4d.js'); require('./watchers-b5cd03f1.js'); require('./index-c3de642f.js'); require('./google-5d965da2.js'); require('./currency-71fce0f0.js'); require('./google-8dbad1a6.js'); require('./utils-a9d13080.js'); require('./util-a15c420c.js'); require('./index-fb76df07.js'); require('./getters-bc65a40b.js'); require('./mutations-463da571.js'); require('./fetch-5e8dc1d5.js'); require('./index-7ced8198.js'); require('./add-query-args-49dcb630.js'); require('./remove-query-args-b57e8cd3.js'); require('./mutations-d5d6ddf1.js'); const scUpsellTotalsCss = ":host{display:block}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)}"; const ScUpsellTotalsStyle0 = scUpsellTotalsCss; const ScUpsellTotals = class { constructor(hostRef) { index.registerInstance(this, hostRef); } renderAmountDue() { var _a, _b; return store.state.amount_due > 0 ? (_a = store.state === null || store.state === void 0 ? void 0 : store.state.line_item) === null || _a === void 0 ? void 0 : _a.total_display_amount : !!((_b = store.state === null || store.state === void 0 ? void 0 : store.state.line_item) === null || _b === void 0 ? void 0 : _b.trial_amount) ? wp.i18n.__('Trial', 'surecart') : wp.i18n.__('Free', 'surecart'); } // Determine if the currency should be displayed to avoid duplication in the amount display. getCurrencyToDisplay() { var _a, _b, _c, _d, _e, _f, _g; return ((_c = (_b = (_a = store.state === null || store.state === void 0 ? void 0 : store.state.line_item) === null || _a === void 0 ? void 0 : _a.total_default_currency_display_amount) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === null || _c === void 0 ? void 0 : _c.includes((_e = (_d = store.state === null || store.state === void 0 ? void 0 : store.state.line_item) === null || _d === void 0 ? void 0 : _d.currency) === null || _e === void 0 ? void 0 : _e.toLowerCase())) ? '' : (_g = (_f = store.state === null || store.state === void 0 ? void 0 : store.state.line_item) === null || _f === void 0 ? void 0 : _f.currency) === null || _g === void 0 ? void 0 : _g.toUpperCase(); } renderConversion() { var _a, _b, _c, _d, _e, _f; // need to check the checkout for a few things. const checkout = store.state === null || store.state === void 0 ? void 0 : store.state.checkout; if (!(checkout === null || checkout === void 0 ? void 0 : checkout.show_converted_total)) { return null; } // the currency is the same as the current currency. if ((checkout === null || checkout === void 0 ? void 0 : checkout.currency) === (checkout === null || checkout === void 0 ? void 0 : checkout.current_currency)) { return null; } // there is no amount due. if (!((_a = store.state === null || store.state === void 0 ? void 0 : store.state.line_item) === null || _a === void 0 ? void 0 : _a.total_amount)) { return null; } return (index.h(index.Fragment, null, index.h("sc-divider", null), index.h("sc-line-item", { style: { '--price-size': 'var(--sc-font-size-x-large)' } }, index.h("span", { slot: "title" }, index.h("slot", { name: "charge-amount-description" }, wp.i18n.sprintf(wp.i18n.__('Payment Total', 'surecart'), (_c = (_b = store.state === null || store.state === void 0 ? void 0 : store.state.line_item) === null || _b === void 0 ? void 0 : _b.currency) === null || _c === void 0 ? void 0 : _c.toUpperCase()))), index.h("span", { slot: "price" }, this.getCurrencyToDisplay() && index.h("span", { class: "currency-label" }, this.getCurrencyToDisplay()), (_d = store.state === null || store.state === void 0 ? void 0 : store.state.line_item) === null || _d === void 0 ? void 0 : _d.total_default_currency_display_amount)), index.h("sc-line-item", null, index.h("span", { slot: "description", class: "conversion-description" }, wp.i18n.sprintf(wp.i18n.__('Your payment will be processed in %s.', 'surecart'), (_f = (_e = store.state === null || store.state === void 0 ? void 0 : store.state.line_item) === null || _e === void 0 ? void 0 : _e.currency) === null || _f === void 0 ? void 0 : _f.toUpperCase()))))); } render() { var _a, _b, _c, _d, _e, _f, _g; return (index.h("sc-summary", { key: '747b67d7ad42320d6adb06cc5ae4fe436fe4a235', "open-text": "Total", "closed-text": "Total", collapsible: true, collapsed: true }, !!((_a = store.state.line_item) === null || _a === void 0 ? void 0 : _a.id) && index.h("span", { key: '196450bc06fc13b019597a2a43f8f828451a6a48', slot: "price" }, this.renderAmountDue()), index.h("sc-divider", { key: '75928d2ebbcf0182a73d99bec267a037c74bb735' }), index.h("sc-line-item", { key: '85ecf7678ac9745cd476a5b5955de119d3d9ffbf' }, index.h("span", { key: '48b1d5f1e2531fd0063381daab4474d996c6adb2', slot: "description" }, wp.i18n.__('Subtotal', 'surecart')), index.h("span", { key: '9868f8f7e434781799d6efa348843ced7e688d08', slot: "price" }, (_b = store.state.line_item) === null || _b === void 0 ? void 0 : _b.subtotal_display_amount)), (((_d = (_c = store.state === null || store.state === void 0 ? void 0 : store.state.line_item) === null || _c === void 0 ? void 0 : _c.fees) === null || _d === void 0 ? void 0 : _d.data) || []) .filter(fee => fee.fee_type === 'upsell') // only upsell fees. .map(fee => { return (index.h("sc-line-item", null, index.h("span", { slot: "description" }, fee.description, " ", `(${wp.i18n.__('one time', 'surecart')})`), index.h("span", { slot: "price" }, fee === null || fee === void 0 ? void 0 : fee.display_amount))); }), !!((_e = store.state.line_item) === null || _e === void 0 ? void 0 : _e.tax_amount) && (index.h("sc-line-item", { key: 'd63bab2a8923f2ca489a06a9de404c212df04664' }, index.h("span", { key: 'ff98910f35dc395785b8143a5bcda2927c786146', slot: "description" }, wp.i18n.__('Tax', 'surecart')), index.h("span", { key: '74b6f6a9d2ddeb60c16b9cf0996732e1770e06e9', slot: "price" }, (_f = store.state.line_item) === null || _f === void 0 ? void 0 : _f.tax_display_amount))), index.h("sc-divider", { key: 'b2f92fd9d64201ce657af3f19453e08cc09388a3' }), index.h("sc-line-item", { key: 'b06804f6fea2d1a420ff84996f52fff18fe18ebe', style: { '--price-size': 'var(--sc-font-size-x-large)' } }, index.h("span", { key: 'fc7f52b8e713f67f465c962642a5053bcbe1b2bd', slot: "title" }, wp.i18n.__('Total', 'surecart')), index.h("span", { key: '257336b340f5c54be8b442af8653b5a7ce7b5f6a', slot: "price" }, (_g = store.state.line_item) === null || _g === void 0 ? void 0 : _g.total_display_amount)), this.renderConversion())); } }; ScUpsellTotals.style = ScUpsellTotalsStyle0; exports.sc_upsell_totals = ScUpsellTotals; //# sourceMappingURL=sc-upsell-totals.cjs.entry.js.map