import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
import { o as openWormhole } from './consumer.js';
import { d as defineCustomElement$1 } from './sc-format-number2.js';

const scTotalCss = ":host{display:block}";

const ScTotal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    this.total = 'amount_due';
    this.order_key = {
      total: 'total_amount',
      subtotal: 'subtotal_amount',
      amount_due: 'amount_due',
    };
  }
  render() {
    var _a, _b, _c, _d, _e;
    if (!((_a = this.order) === null || _a === void 0 ? void 0 : _a.currency))
      return;
    if (!((_d = (_c = (_b = this.order) === null || _b === void 0 ? void 0 : _b.line_items) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.length))
      return;
    return h("sc-format-number", { type: "currency", currency: this.order.currency, value: (_e = this.order) === null || _e === void 0 ? void 0 : _e[this.order_key[this.total]] });
  }
  static get style() { return scTotalCss; }
}, [0, "sc-total", {
    "total": [1],
    "order": [16]
  }]);
openWormhole(ScTotal, ['order'], false);
function defineCustomElement() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["sc-total", "sc-format-number"];
  components.forEach(tagName => { switch (tagName) {
    case "sc-total":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, ScTotal);
      }
      break;
    case "sc-format-number":
      if (!customElements.get(tagName)) {
        defineCustomElement$1();
      }
      break;
  } });
}
defineCustomElement();

export { ScTotal as S, defineCustomElement as d };
