import { r as registerInstance, h, H as Host } from './index-fd4790f6.js';

const scPriceRangeCss = ":host{display:block}";

const ScPriceRange = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
  }
  handlePricesChange() {
    var _a;
    let min, max;
    (_a = this.prices) === null || _a === void 0 ? void 0 : _a.forEach(price => {
      if (!max || price.amount > max.amount) {
        max = price;
      }
      if (!min || price.amount < min.amount) {
        min = price;
      }
    });
    this.minPrice = min;
    this.maxPrice = max;
  }
  componentWillLoad() {
    this.handlePricesChange();
  }
  render() {
    if (!this.maxPrice || !this.minPrice) {
      return h(Host, null);
    }
    return (h(Host, null, this.maxPrice.amount == this.minPrice.amount ? (h("span", { class: "price-range-display" }, h("sc-format-number", { type: "currency", currency: this.maxPrice.currency, value: this.maxPrice.amount }))) : (h("span", { class: "price-range-display" }, h("sc-format-number", { type: "currency", currency: this.minPrice.currency, value: this.minPrice.amount }), "-", h("sc-format-number", { type: "currency", currency: this.maxPrice.currency, value: this.maxPrice.amount })))));
  }
  static get watchers() { return {
    "prices": ["handlePricesChange"]
  }; }
};
ScPriceRange.style = scPriceRangeCss;

export { ScPriceRange as sc_price_range };
