import { Component, h, State, Element, Watch, Prop } from '@stencil/core';
export class ScOrderConfirmComponentsValidator {
  handleOrderChange() {
    var _a;
    if ((_a = this.checkout) === null || _a === void 0 ? void 0 : _a.manual_payment) {
      this.addManualPaymentInstructions();
    }
  }
  addManualPaymentInstructions() {
    var _a, _b;
    if (this.hasManualInstructions)
      return;
    const details = this.el.shadowRoot
      .querySelector('slot')
      .assignedElements({ flatten: true })
      .find(element => element.tagName === 'SC-ORDER-CONFIRMATION-DETAILS');
    const address = document.createElement('sc-order-manual-instructions');
    (_b = (_a = details === null || details === void 0 ? void 0 : details.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore) === null || _b === void 0 ? void 0 : _b.call(_a, address, details);
    this.hasManualInstructions = true;
  }
  componentWillLoad() {
    this.hasManualInstructions = !!this.el.querySelector('sc-order-manual-instructions');
  }
  render() {
    return h("slot", null);
  }
  static get is() { return "sc-order-confirm-components-validator"; }
  static get encapsulation() { return "shadow"; }
  static get properties() { return {
    "checkout": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Checkout",
        "resolved": "Checkout",
        "references": {
          "Checkout": {
            "location": "import",
            "path": "../../../types"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "The checkout"
      }
    }
  }; }
  static get states() { return {
    "hasManualInstructions": {}
  }; }
  static get elementRef() { return "el"; }
  static get watchers() { return [{
      "propName": "checkout",
      "methodName": "handleOrderChange"
    }]; }
}
