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

const DevingenProductRootTaban = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
  }
  componentWillLoad() {
    this.fetchProductSettings();
  }
  fetchProductSettings() {
    this.apiDevingen.findProductSettingsTaban(this.product._id)
      .then(response => this.productSettings = response)
      .catch((e) => {
      var _a;
      if (((_a = e === null || e === void 0 ? void 0 : e.data) === null || _a === void 0 ? void 0 : _a.error) === 'product-setting-not-found-for-product') {
        this.apiDevingen.createProductSettingsTaban(this.product._id)
          .then((response) => {
          this.productSettings = response;
        })
          .catch(error => this.error = error);
      }
      else {
        this.error = e;
      }
    });
  }
  render() {
    const { error } = this;
    if (error) {
      return (h(Host, null, h("div", { class: "d-flex justify-content-center" }, h("devingen-error-card", { error: error, message: "Unexpected error occurred." }))));
    }
    return (h(Host, { class: "container d-flex flex-grow-1 flex-column" }));
  }
};

export { DevingenProductRootTaban as devingen_product_root_taban };
