import { Component, h, Event, Prop } from '@stencil/core';
import { openWormhole } from 'stencil-wormhole';
export class ScCartHeader {
  /** 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-left", 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 is() { return "sc-cart-header"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() { return {
    "$": ["sc-cart-header.scss"]
  }; }
  static get styleUrls() { return {
    "$": ["sc-cart-header.css"]
  }; }
  static get properties() { return {
    "lineItems": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Array<LineItem>",
        "resolved": "LineItem[]",
        "references": {
          "Array": {
            "location": "global"
          },
          "LineItem": {
            "location": "import",
            "path": "../../../../types"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    }
  }; }
  static get events() { return [{
      "method": "scCloseCart",
      "name": "scCloseCart",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "void",
        "resolved": "void",
        "references": {}
      }
    }]; }
}
openWormhole(ScCartHeader, ['lineItems'], false);
