'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-cd6fab62.js');

const scPriceChoicesCss = "sc-price-choices{display:block;position:relative}sc-block-ui{z-index:9}";

const ScPriceChoices = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.scRemoveLineItem = index.createEvent(this, "scRemoveLineItem", 7);
    this.scUpdateLineItem = index.createEvent(this, "scUpdateLineItem", 7);
    /** 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 (index.h(index.Fragment, null, index.h("sc-choices", { label: this.label, required: this.required, class: "loaded price-selector", style: { '--columns': this.columns.toString() } }, index.h("slot", null))));
  }
  get el() { return index.getElement(this); }
};
ScPriceChoices.style = scPriceChoicesCss;

exports.sc_price_choices = ScPriceChoices;
