import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
import { o as openWormhole } from './consumer.js';
import { d as defineCustomElement$3 } from './sc-icon2.js';
import { d as defineCustomElement$2 } from './sc-tag2.js';

const scCartHeaderCss = ".cart-header{display:flex;align-items:center;justify-content:space-between;width:100%;font-size:1em}.cart-title{text-align:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0 var(--sc-spacing-small)}.cart__close{cursor:pointer}";

const ScCartHeader$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    this.__attachShadow();
    this.scCloseCart = createEvent(this, "scCloseCart", 7);
  }
  /** Count the number of items in the cart. */
  getItemsCount() {
    const items = this.lineItems || [];
    let count = 0;
    items.forEach(item => {
      count = count + (item === null || item === void 0 ? void 0 : item.quantity);
    });
    return count;
  }
  render() {
    var _a;
    return (h("div", { class: "cart-header" }, h("sc-icon", { class: "cart__close", name: "arrow-right", onClick: () => this.scCloseCart.emit() }), h("div", { class: "cart-title" }, h("slot", null)), h("sc-tag", { size: "small" }, ((_a = this === null || this === void 0 ? void 0 : this.getItemsCount) === null || _a === void 0 ? void 0 : _a.call(this)) || 0)));
  }
  static get style() { return scCartHeaderCss; }
}, [1, "sc-cart-header", {
    "lineItems": [16]
  }]);
openWormhole(ScCartHeader$1, ['lineItems'], false);
function defineCustomElement$1() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["sc-cart-header", "sc-icon", "sc-tag"];
  components.forEach(tagName => { switch (tagName) {
    case "sc-cart-header":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, ScCartHeader$1);
      }
      break;
    case "sc-icon":
      if (!customElements.get(tagName)) {
        defineCustomElement$3();
      }
      break;
    case "sc-tag":
      if (!customElements.get(tagName)) {
        defineCustomElement$2();
      }
      break;
  } });
}
defineCustomElement$1();

const ScCartHeader = ScCartHeader$1;
const defineCustomElement = defineCustomElement$1;

export { ScCartHeader, defineCustomElement };
