import { r as registerInstance, h } from './index-fd4790f6.js';
import { g as getOrder, c as clearOrder } from './watchers-0c79cf4e.js';
import { u as uiStore } from './ui-bfbc2b0b.js';
import './index-26bbcef3.js';
import './add-query-args-f4c5962b.js';

const scCartLoaderCss = ":host{position:absolute;z-index:var(--sc-cart-z-index, 999999);font-family:var(--sc-font-sans)}";

const ScCartLoader = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    /** The mode for the form. */
    this.mode = 'live';
  }
  render() {
    var _a, _b, _c, _d;
    /**
     * Search for the sc-checkout component on a page to make sure
     * we don't show the cart on a checkout page.
     */
    if (!!document.querySelector('sc-checkout'))
      return null;
    // clear the order if it's already paid.
    const order = getOrder(this.formId, this.mode);
    if ((order === null || order === void 0 ? void 0 : order.status) === 'paid') {
      clearOrder(this.formId, this.mode);
      return null;
    }
    // return the loader.
    return h("div", { innerHTML: ((_b = (_a = order === null || order === void 0 ? void 0 : order.line_items) === null || _a === void 0 ? void 0 : _a.pagination) === null || _b === void 0 ? void 0 : _b.count) || ((_d = (_c = uiStore === null || uiStore === void 0 ? void 0 : uiStore.state) === null || _c === void 0 ? void 0 : _c.cart) === null || _d === void 0 ? void 0 : _d.open) ? this.template : '' });
  }
};
ScCartLoader.style = scCartLoaderCss;

export { ScCartLoader as sc_cart_loader };
