import { Component, Element, Event, Fragment, h, Listen, Prop } from '@stencil/core';
export class ScPriceChoices {
  constructor() {
    /** Number of columns */
    this.columns = 1;
    /** Required by default */
    this.required = true;
  }
  handleChange() {
    this.el.querySelectorAll('sc-price-choice').forEach(priceChoice => {
      // get the underlying control
      const choice = priceChoice.querySelector('sc-choice');
      if (!choice.checked) {
        this.scRemoveLineItem.emit({ price_id: priceChoice.priceId, quantity: priceChoice.quantity });
      }
      else {
        this.scUpdateLineItem.emit({ price_id: priceChoice.priceId, quantity: priceChoice.quantity });
      }
    });
  }
  render() {
    return (h(Fragment, null,
      h("sc-choices", { label: this.label, required: this.required, class: "loaded price-selector", style: { '--columns': this.columns.toString() } },
        h("slot", null))));
  }
  static get is() { return "sc-price-choices"; }
  static get originalStyleUrls() { return {
    "$": ["sc-price-choices.css"]
  }; }
  static get styleUrls() { return {
    "$": ["sc-price-choices.css"]
  }; }
  static get properties() { return {
    "label": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "Selector label"
      },
      "attribute": "label",
      "reflect": false
    },
    "columns": {
      "type": "number",
      "mutable": false,
      "complexType": {
        "original": "number",
        "resolved": "number",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "Number of columns"
      },
      "attribute": "columns",
      "reflect": false,
      "defaultValue": "1"
    },
    "required": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "Required by default"
      },
      "attribute": "required",
      "reflect": false,
      "defaultValue": "true"
    }
  }; }
  static get events() { return [{
      "method": "scRemoveLineItem",
      "name": "scRemoveLineItem",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": "Toggle line item event"
      },
      "complexType": {
        "original": "LineItemData",
        "resolved": "LineItemData",
        "references": {
          "LineItemData": {
            "location": "import",
            "path": "../../../../types"
          }
        }
      }
    }, {
      "method": "scUpdateLineItem",
      "name": "scUpdateLineItem",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": "Toggle line item event"
      },
      "complexType": {
        "original": "LineItemData",
        "resolved": "LineItemData",
        "references": {
          "LineItemData": {
            "location": "import",
            "path": "../../../../types"
          }
        }
      }
    }]; }
  static get elementRef() { return "el"; }
  static get listeners() { return [{
      "name": "scChange",
      "method": "handleChange",
      "target": undefined,
      "capture": false,
      "passive": false
    }]; }
}
