import { isDemo, useSetParent } from "@saasquatch/component-boilerplate";
import { withHooks } from "@saasquatch/stencil-hooks";
import { useState } from "@saasquatch/universal-hooks";
import { Component, Host, Prop, h } from "@stencil/core";
import deepmerge from "deepmerge";
import { getProps } from "../../../utils/utils";
import { TAX_CONTEXT_NAMESPACE } from "../data";
import { OtherRegionSlotView } from "../sqm-user-info-form/small-views/IndirectTaxDetailsView";
import { INDIRECT_TAX_PROVINCES, INDIRECT_TAX_SPAIN_REGIONS, } from "../subregions";
import { IndirectTaxFormView } from "./sqm-indirect-tax-form-view";
import { useIndirectTaxForm, } from "./useIndirectTaxForm";
/**
 * @uiName Indirect Tax Form
 * @exampleGroup Tax and Cash Components
 */
export class IndirectTaxForm {
  constructor() {
    /**
     * @uiName Setup progress
     */
    this.formStep = "Step {step} of {count}";
    /**
     * @uiName Step 2 title
     */
    this.indirectTax = "Indirect Tax";
    /**
     * Displayed under the title of this step.
     * @uiName Step 2 description
     * @uiWidget textArea
     */
    this.indirectTaxDescription = "Indirect taxes (e.g. VAT, HST, GST) are transaction based taxes often applied to goods and services. Service providers are typically required to register with their tax authority and collect these taxes on behalf governments.";
    /**
     * Displayed with indirect tax registration options.
     * @uiName Indirect tax details section title
     */
    this.indirectTaxDetails = "Indirect tax details";
    /**
     * @uiName Registered for indirect tax option
     * @uiWidget textArea
     */
    this.otherRegion = "Registered for indirect tax";
    /**
     * Selecting this option will display fields to enter indirect tax details.
     * @uiName Registered for indirect tax option description
     */
    this.otherRegionSubtext = "If you’ve registered with your tax authority, add your information to stay tax compliant.";
    /**
     * @uiName Not registered for indirect tax option
     * @uiWidget textArea
     */
    this.notRegistered = "Not registered for indirect tax";
    /**
     * Participants based in the US are  considered not registered.
     * @uiName Not registered for indirect tax option description
     */
    this.notRegisteredSubtext = "If you’ve never set up indirect tax with your tax authority, then you’re likely not considered registered.";
    /**
     * @uiName Region of indirect tax field label
     */
    this.selectedRegion = "Country / region of indirect tax";
    /**
     * @uiName Province field label
     */
    this.province = "Province";
    /**
     * @uiName Indirect tax number field label
     */
    this.indirectTaxNumber = "{taxType, select, GST {GST number} HST {HST number} VAT {VAT number} CT {CT number} SST {SST number} GENERAL {Indirect tax number} other {Tax number}}";
    /**
     * Displayed to participants registered for QST.
     * @uiName QST number field label
     */
    this.qstNumber = "QST number";
    /**
     * Displayed to participants registered for indirect tax in Quebec, Canada.
     * @uiName QST tax checkbox
     */
    this.isRegisteredQST = "I am registered for QST Tax";
    /**
     * Displayed to participants registered for indirect tax in Spain.
     * @uiName Spain income tax checkbox
     * @uiWidget textArea
     */
    this.isRegisteredSubRegionIncomeTax = "I am an individual registered for Income Tax purposes in Spain, and withholding tax will apply to any payments made to me.";
    /**
     * Displayed to participants registered in Spain.
     * @uiName Sub-region of indirect tax field label
     */
    this.subRegion = "Sub-region";
    /**
     * @uiName Income tax field label
     */
    this.subRegionTaxNumberLabel = "Income tax number";
    /**
     * @uiName Back button label
     */
    this.backButton = "Back";
    /**
     * Communicate that after this step, only Support can change personal and indirect tax information.
     * @uiName Submission confirmation alert
     * @uiWidget textArea
     */
    this.cannotChangeInfoAlert = "Changes to your personal and indirect tax information can only be made through our {supportLink} after you complete this step. Make sure these are correct before continuing.";
    /**
     * @uiName Missing indirect tax number error message
     */
    this.indirectTaxNumberError = "{taxType, select, GST {GST number} HST {HST number} VAT {VAT number} CT {CT number} SST {SST number} GENERAL {Indirect tax number} other {Tax number}} is required";
    /**
     * Placeholder text displayed in the country search dropdown
     * @uiName Country field placeholder text
     */
    this.searchForCountryText = "Search for country..";
    /**
     * Displayed under a field that is missing required information.
     * @uiName Empty form field error message
     */
    this.fieldRequiredError = "{fieldName} is required";
    /**
     * Part of the alert displayed at the top of the page if the participant is already a registered partner on impact.com.
     * @uiName Participant is a partner alert title
     * @uiWidget textArea
     */
    this.isPartnerAlertHeader = "An account with this email already exists with our referral program provider, impact.com";
    /**
     * Part of the alert displayed at the top of the page if the participant is already a registered partner on impact.com.
     * @uiName Participant is a partner alert description
     * @uiWidget textArea
     */
    this.isPartnerAlertDescription = "If you don’t recognize this referral program provider or believe this is a mistake, please contact our {supportLink} or sign up for this referral program with a different email.";
    /**
     * @uiName Continue button label
     */
    this.continueButton = "Continue";
    /**
     * @uiName Support link text
     */
    this.supportLink = "support team";
    /**
     * Part of the alert displayed at the top of the page.
     * @uiName Form submission error message title
     * @uiWidget textArea
     */
    this.generalErrorTitle = "There was a problem submitting your information";
    /**
     * Part of the alert displayed at the top of the page.
     * @uiName Form submission error message description
     * @uiWidget textArea
     */
    this.generalErrorDescription = "Please review your information and try again. If this problem continues, contact our {supportLink}.";
    /**
     * Part of the alert displayed at the top of the page.
     * @uiName Page load error message title
     * @uiWidget textArea
     */
    this.loadingErrorAlertHeader = "There was a problem loading your form";
    /**
     * Part of the alert displayed at the top of the page.
     * @uiName Page load error message description
     * @uiWidget textArea
     */
    this.loadingErrorAlertDescription = "Please refresh the page and try again. If this problem continues, contact our {supportLink}.";
    /**
     * Displayed at the top of the page on all set up steps.
     * @uiName Page description
     */
    this.taxAndPayoutsDescription = "Submit your tax documents and add your banking information to receive your rewards.";
    withHooks(this);
  }
  disconnectedCallback() { }
  getTextProps() {
    const props = getProps(this);
    return {
      ...props,
      error: {
        generalTitle: props.generalErrorTitle,
        generalDescription: props.generalErrorDescription,
        fieldRequiredError: props.fieldRequiredError,
        loadingErrorAlertHeader: props.loadingErrorAlertHeader,
        loadingErrorAlertDescription: props.loadingErrorAlertDescription,
      },
      slotText: {
        isRegisteredQST: props.isRegisteredQST,
        isRegisteredSubRegionIncomeTax: props.isRegisteredSubRegionIncomeTax,
        qstNumber: props.qstNumber,
        subRegion: props.subRegion,
        subRegionTaxNumberLabel: props.subRegionTaxNumberLabel,
        selectedRegion: props.selectedRegion,
        province: props.province,
        indirectTaxNumber: props.indirectTaxNumber,
        error: {
          indirectTaxNumber: props.indirectTaxNumberError,
          fieldRequiredError: props.fieldRequiredError,
        },
        searchForCountryText: props.searchForCountryText,
      },
    };
  }
  render() {
    const props = isDemo()
      ? useDemoIndirectTaxForm(this)
      : useIndirectTaxForm(this);
    const registeredInDifferentCountryDetailsSlot = (h(OtherRegionSlotView, { states: {
        hide: props.states.formState.checked !== "otherRegion",
        disabled: props.states.disabled || props.states.isPartner,
        formState: props.slotProps.formState,
        loading: props.states.loading,
        isPartner: props.states.isPartner,
      }, callbacks: props.callbacks, data: {
        esRegions: props.data.esRegions,
        countries: props.data.countries,
        provinces: props.data.provinces,
        allCountries: props.data.allCountries,
      }, text: props.text.slotText }));
    return (h(Host, null,
      h(IndirectTaxFormView, { callbacks: props.callbacks, states: props.states, refs: props.refs, text: props.text, slots: {
          registeredInDifferentCountryDetailsSlot,
        } })));
  }
  static get is() { return "sqm-indirect-tax-form"; }
  static get encapsulation() { return "shadow"; }
  static get properties() { return {
    "formStep": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Setup progress",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "form-step",
      "reflect": false,
      "defaultValue": "\"Step {step} of {count}\""
    },
    "indirectTax": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Step 2 title",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "indirect-tax",
      "reflect": false,
      "defaultValue": "\"Indirect Tax\""
    },
    "indirectTaxDescription": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Step 2 description",
            "name": "uiName"
          }, {
            "text": "textArea",
            "name": "uiWidget"
          }],
        "text": "Displayed under the title of this step."
      },
      "attribute": "indirect-tax-description",
      "reflect": false,
      "defaultValue": "\"Indirect taxes (e.g. VAT, HST, GST) are transaction based taxes often applied to goods and services. Service providers are typically required to register with their tax authority and collect these taxes on behalf governments.\""
    },
    "indirectTaxDetails": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Indirect tax details section title",
            "name": "uiName"
          }],
        "text": "Displayed with indirect tax registration options."
      },
      "attribute": "indirect-tax-details",
      "reflect": false,
      "defaultValue": "\"Indirect tax details\""
    },
    "otherRegion": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Registered for indirect tax option",
            "name": "uiName"
          }, {
            "text": "textArea",
            "name": "uiWidget"
          }],
        "text": ""
      },
      "attribute": "other-region",
      "reflect": false,
      "defaultValue": "\"Registered for indirect tax\""
    },
    "otherRegionSubtext": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Registered for indirect tax option description",
            "name": "uiName"
          }],
        "text": "Selecting this option will display fields to enter indirect tax details."
      },
      "attribute": "other-region-subtext",
      "reflect": false,
      "defaultValue": "\"If you\u2019ve registered with your tax authority, add your information to stay tax compliant.\""
    },
    "notRegistered": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Not registered for indirect tax option",
            "name": "uiName"
          }, {
            "text": "textArea",
            "name": "uiWidget"
          }],
        "text": ""
      },
      "attribute": "not-registered",
      "reflect": false,
      "defaultValue": "\"Not registered for indirect tax\""
    },
    "notRegisteredSubtext": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Not registered for indirect tax option description",
            "name": "uiName"
          }],
        "text": "Participants based in the US are  considered not registered."
      },
      "attribute": "not-registered-subtext",
      "reflect": false,
      "defaultValue": "\"If you\u2019ve never set up indirect tax with your tax authority, then you\u2019re likely not considered registered.\""
    },
    "selectedRegion": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Region of indirect tax field label",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "selected-region",
      "reflect": false,
      "defaultValue": "\"Country / region of indirect tax\""
    },
    "province": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Province field label",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "province",
      "reflect": false,
      "defaultValue": "\"Province\""
    },
    "indirectTaxNumber": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Indirect tax number field label",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "indirect-tax-number",
      "reflect": false,
      "defaultValue": "\"{taxType, select, GST {GST number} HST {HST number} VAT {VAT number} CT {CT number} SST {SST number} GENERAL {Indirect tax number} other {Tax number}}\""
    },
    "qstNumber": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "QST number field label",
            "name": "uiName"
          }],
        "text": "Displayed to participants registered for QST."
      },
      "attribute": "qst-number",
      "reflect": false,
      "defaultValue": "\"QST number\""
    },
    "isRegisteredQST": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "QST tax checkbox",
            "name": "uiName"
          }],
        "text": "Displayed to participants registered for indirect tax in Quebec, Canada."
      },
      "attribute": "is-registered-q-s-t",
      "reflect": false,
      "defaultValue": "\"I am registered for QST Tax\""
    },
    "isRegisteredSubRegionIncomeTax": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Spain income tax checkbox",
            "name": "uiName"
          }, {
            "text": "textArea",
            "name": "uiWidget"
          }],
        "text": "Displayed to participants registered for indirect tax in Spain."
      },
      "attribute": "is-registered-sub-region-income-tax",
      "reflect": false,
      "defaultValue": "\"I am an individual registered for Income Tax purposes in Spain, and withholding tax will apply to any payments made to me.\""
    },
    "subRegion": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Sub-region of indirect tax field label",
            "name": "uiName"
          }],
        "text": "Displayed to participants registered in Spain."
      },
      "attribute": "sub-region",
      "reflect": false,
      "defaultValue": "\"Sub-region\""
    },
    "subRegionTaxNumberLabel": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Income tax field label",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "sub-region-tax-number-label",
      "reflect": false,
      "defaultValue": "\"Income tax number\""
    },
    "backButton": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Back button label",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "back-button",
      "reflect": false,
      "defaultValue": "\"Back\""
    },
    "cannotChangeInfoAlert": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Submission confirmation alert",
            "name": "uiName"
          }, {
            "text": "textArea",
            "name": "uiWidget"
          }],
        "text": "Communicate that after this step, only Support can change personal and indirect tax information."
      },
      "attribute": "cannot-change-info-alert",
      "reflect": false,
      "defaultValue": "\"Changes to your personal and indirect tax information can only be made through our {supportLink} after you complete this step. Make sure these are correct before continuing.\""
    },
    "indirectTaxNumberError": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Missing indirect tax number error message",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "indirect-tax-number-error",
      "reflect": false,
      "defaultValue": "\"{taxType, select, GST {GST number} HST {HST number} VAT {VAT number} CT {CT number} SST {SST number} GENERAL {Indirect tax number} other {Tax number}} is required\""
    },
    "searchForCountryText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Country field placeholder text",
            "name": "uiName"
          }],
        "text": "Placeholder text displayed in the country search dropdown"
      },
      "attribute": "search-for-country-text",
      "reflect": false,
      "defaultValue": "\"Search for country..\""
    },
    "fieldRequiredError": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Empty form field error message",
            "name": "uiName"
          }],
        "text": "Displayed under a field that is missing required information."
      },
      "attribute": "field-required-error",
      "reflect": false,
      "defaultValue": "\"{fieldName} is required\""
    },
    "isPartnerAlertHeader": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Participant is a partner alert title",
            "name": "uiName"
          }, {
            "text": "textArea",
            "name": "uiWidget"
          }],
        "text": "Part of the alert displayed at the top of the page if the participant is already a registered partner on impact.com."
      },
      "attribute": "is-partner-alert-header",
      "reflect": false,
      "defaultValue": "\"An account with this email already exists with our referral program provider, impact.com\""
    },
    "isPartnerAlertDescription": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Participant is a partner alert description",
            "name": "uiName"
          }, {
            "text": "textArea",
            "name": "uiWidget"
          }],
        "text": "Part of the alert displayed at the top of the page if the participant is already a registered partner on impact.com."
      },
      "attribute": "is-partner-alert-description",
      "reflect": false,
      "defaultValue": "\"If you don\u2019t recognize this referral program provider or believe this is a mistake, please contact our {supportLink} or sign up for this referral program with a different email.\""
    },
    "continueButton": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Continue button label",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "continue-button",
      "reflect": false,
      "defaultValue": "\"Continue\""
    },
    "supportLink": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Support link text",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "support-link",
      "reflect": false,
      "defaultValue": "\"support team\""
    },
    "generalErrorTitle": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Form submission error message title",
            "name": "uiName"
          }, {
            "text": "textArea",
            "name": "uiWidget"
          }],
        "text": "Part of the alert displayed at the top of the page."
      },
      "attribute": "general-error-title",
      "reflect": false,
      "defaultValue": "\"There was a problem submitting your information\""
    },
    "generalErrorDescription": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Form submission error message description",
            "name": "uiName"
          }, {
            "text": "textArea",
            "name": "uiWidget"
          }],
        "text": "Part of the alert displayed at the top of the page."
      },
      "attribute": "general-error-description",
      "reflect": false,
      "defaultValue": "\"Please review your information and try again. If this problem continues, contact our {supportLink}.\""
    },
    "loadingErrorAlertHeader": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Page load error message title",
            "name": "uiName"
          }, {
            "text": "textArea",
            "name": "uiWidget"
          }],
        "text": "Part of the alert displayed at the top of the page."
      },
      "attribute": "loading-error-alert-header",
      "reflect": false,
      "defaultValue": "\"There was a problem loading your form\""
    },
    "loadingErrorAlertDescription": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Page load error message description",
            "name": "uiName"
          }, {
            "text": "textArea",
            "name": "uiWidget"
          }],
        "text": "Part of the alert displayed at the top of the page."
      },
      "attribute": "loading-error-alert-description",
      "reflect": false,
      "defaultValue": "\"Please refresh the page and try again. If this problem continues, contact our {supportLink}.\""
    },
    "taxAndPayoutsDescription": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Page description",
            "name": "uiName"
          }],
        "text": "Displayed at the top of the page on all set up steps."
      },
      "attribute": "tax-and-payouts-description",
      "reflect": false,
      "defaultValue": "\"Submit your tax documents and add your banking information to receive your rewards.\""
    },
    "demoData": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "DemoData<UseIndirectTaxFormResult>",
        "resolved": "{ states?: { step: string; hideSteps: boolean; disabled: boolean; loading: boolean; isPartner: boolean; loadingError: boolean; formState: { checked: \"hstCanada\" | \"otherRegion\" | \"notRegistered\"; errors: {}; }; }; refs?: { formRef: Ref<HTMLFormElement>; }; data?: { esRegions: { regionCode: string; taxType: string; displayName: string; }[]; countries: { countryCode: string; displayName: any; }[]; allCountries: { countryCode: string; displayName: any; }[]; provinces: { regionCode: string; taxType: string; displayName: string; }[]; }; slotProps?: { formState: { selectedRegion?: string; subRegion?: string; subRegionTaxNumber?: string; qstNumber?: string; province?: string; indirectTaxNumber?: string; hasQst?: boolean; hasSubRegionTaxNumber?: boolean; errors?: any; error?: string; }; }; }",
        "references": {
          "DemoData": {
            "location": "import",
            "path": "../../../global/demo"
          },
          "UseIndirectTaxFormResult": {
            "location": "import",
            "path": "./useIndirectTaxForm"
          }
        }
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": undefined,
            "name": "undocumented"
          }],
        "text": ""
      }
    }
  }; }
}
function useDemoIndirectTaxForm(props) {
  const setStep = useSetParent(TAX_CONTEXT_NAMESPACE);
  const [option, setOption] = useState("otherRegion");
  const [demoFormState, setDemoFormState] = useState({});
  return deepmerge({
    states: {
      step: "2",
      disabled: false,
      loading: false,
      isPartner: false,
      loadingError: false,
      errors: {},
      formState: {
        checked: option,
        errors: {
          general: false,
        },
      },
    },
    callbacks: {
      onFormChange: (field, e) => {
        var _a, _b;
        const value = (_b = (_a = e.detail) === null || _a === void 0 ? void 0 : _a.item) === null || _b === void 0 ? void 0 : _b.__value;
        if (!value)
          console.error("Could not detect select change");
        setDemoFormState((p) => ({ ...p, [field]: value }));
      },
      onBack: () => {
        setStep("/1");
      },
      onSubmit: async () => {
        setStep("/3");
      },
      onQstToggle: () => setDemoFormState((p) => ({ ...p, hasQst: !p.hasQst })),
      onSpainToggle: () => setDemoFormState((p) => ({
        ...p,
        hasSubRegionTaxNumber: !p.hasSubRegionTaxNumber,
      })),
      onChange: setOption,
      setCountrySearch: (c) => console.log(c),
    },
    data: {
      esRegions: INDIRECT_TAX_SPAIN_REGIONS,
      countries: [
        {
          countryCode: "CA",
          displayName: "Canada",
        },
        {
          countryCode: "ES",
          displayName: "Spain",
        },
        {
          countryCode: "UK",
          displayName: "United Kingdom",
        },
        {
          countryCode: "US",
          displayName: "United States",
        },
      ],
      provinces: INDIRECT_TAX_PROVINCES,
    },
    text: props.getTextProps(),
    refs: {
      formRef: { current: null },
    },
    slotProps: {
      formState: {
        ...demoFormState,
        errors: {
          selectedRegion: false,
          province: false,
          subRegion: false,
          qstNumber: false,
          subRegionTaxNumber: false,
          indirectTaxNumber: false,
        },
      },
    },
  }, props.demoData || {}, { arrayMerge: (_, a) => a });
}
