const StateOptions = [
    {
        label: 'Choose state',
        value: '',
    },
    {
        label: 'Alabama',
        value: 'AL',
    },
    {
        label: 'Alaska',
        value: 'AK',
    },
    {
        label: 'American Samoa',
        value: 'AS',
    },
    {
        label: 'Arizona',
        value: 'AZ',
    },
    {
        label: 'Arkansas',
        value: 'AR',
    },
    {
        label: 'California',
        value: 'CA',
    },
    {
        label: 'Colorado',
        value: 'CO',
    },
    {
        label: 'Connecticut',
        value: 'CT',
    },
    {
        label: 'Delaware',
        value: 'DE',
    },
    {
        label: 'District Of Columbia',
        value: 'DC',
    },
    {
        label: 'Federated States Of Micronesia',
        value: 'FM',
    },
    {
        label: 'Florida',
        value: 'FL',
    },
    {
        label: 'Georgia',
        value: 'GA',
    },
    {
        label: 'Guam',
        value: 'GU',
    },
    {
        label: 'Hawaii',
        value: 'HI',
    },
    {
        label: 'Idaho',
        value: 'ID',
    },
    {
        label: 'Illinois',
        value: 'IL',
    },
    {
        label: 'Indiana',
        value: 'IN',
    },
    {
        label: 'Iowa',
        value: 'IA',
    },
    {
        label: 'Kansas',
        value: 'KS',
    },
    {
        label: 'Kentucky',
        value: 'KY',
    },
    {
        label: 'Louisiana',
        value: 'LA',
    },
    {
        label: 'Maine',
        value: 'ME',
    },
    {
        label: 'Marshall Islands',
        value: 'MH',
    },
    {
        label: 'Maryland',
        value: 'MD',
    },
    {
        label: 'Massachusetts',
        value: 'MA',
    },
    {
        label: 'Michigan',
        value: 'MI',
    },
    {
        label: 'Minnesota',
        value: 'MN',
    },
    {
        label: 'Mississippi',
        value: 'MS',
    },
    {
        label: 'Missouri',
        value: 'MO',
    },
    {
        label: 'Montana',
        value: 'MT',
    },
    {
        label: 'Nebraska',
        value: 'NE',
    },
    {
        label: 'Nevada',
        value: 'NV',
    },
    {
        label: 'New Hampshire',
        value: 'NH',
    },
    {
        label: 'New Jersey',
        value: 'NJ',
    },
    {
        label: 'New Mexico',
        value: 'NM',
    },
    {
        label: 'New York',
        value: 'NY',
    },
    {
        label: 'North Carolina',
        value: 'NC',
    },
    {
        label: 'North Dakota',
        value: 'ND',
    },
    {
        label: 'Northern Mariana Islands',
        value: 'MP',
    },
    {
        label: 'Ohio',
        value: 'OH',
    },
    {
        label: 'Oklahoma',
        value: 'OK',
    },
    {
        label: 'Oregon',
        value: 'OR',
    },
    {
        label: 'Palau',
        value: 'PW',
    },
    {
        label: 'Pennsylvania',
        value: 'PA',
    },
    {
        label: 'Puerto Rico',
        value: 'PR',
    },
    {
        label: 'Rhode Island',
        value: 'RI',
    },
    {
        label: 'South Carolina',
        value: 'SC',
    },
    {
        label: 'South Dakota',
        value: 'SD',
    },
    {
        label: 'Tennessee',
        value: 'TN',
    },
    {
        label: 'Texas',
        value: 'TX',
    },
    {
        label: 'Utah',
        value: 'UT',
    },
    {
        label: 'Vermont',
        value: 'VT',
    },
    {
        label: 'Virgin Islands',
        value: 'VI',
    },
    {
        label: 'Virginia',
        value: 'VA',
    },
    {
        label: 'Washington',
        value: 'WA',
    },
    {
        label: 'West Virginia',
        value: 'WV',
    },
    {
        label: 'Wisconsin',
        value: 'WI',
    },
    {
        label: 'Wyoming',
        value: 'WY',
    },
];

function getStateAbbreviation(stateName) {
    const state = StateOptions.find(s => s.label === stateName);
    return state ? state.value : stateName;
}
// filterNumber is intended to be used to format a string that contains a single digit to a two digit string. 
function filterNumber(num) {
    if (/^\d$/.test(num)) {
        return '0' + num;
    }
    return num;
}
function constructDate(year, month, day) {
    if (!year || !month || !day) {
        return;
    }
    return `${year}-${filterNumber(month)}-${filterNumber(day)}`;
}
function deconstructDate(formInput) {
    const dateString = formInput.value;
    const [dob_year, dob_month, dob_day] = dateString.split('-');
    return { dob_year, dob_month, dob_day };
}
function checkProvisioningStatus(business) {
    return business.associated_accounts.length > 0;
}

class Owner {
    constructor(owner) {
        this.address = Object.assign({}, new Address(owner.address || {}));
        this.created_at = owner.created_at;
        this.dob_day = filterNumber(owner.dob_day);
        this.dob_month = filterNumber(owner.dob_month);
        this.dob_year = owner.dob_year;
        this.dob_full =
            constructDate(this.dob_year, this.dob_month, this.dob_day) || '';
        this.documents = owner.documents;
        this.email = owner.email;
        this.id = owner.id;
        this.business_id = owner.business_id;
        this.is_owner = owner.is_owner;
        this.metadata = owner.metadata;
        this.name = owner.name;
        this.phone = owner.phone;
        this.platform_account_id = owner.platform_account_id;
        this.identification_number = owner.identification_number;
        this.ssn_last4 = owner.ssn_last4;
        this.title = owner.title;
        this.ownership_percentage = owner.ownership_percentage;
        this.updated_at = owner.updated_at;
    }
    // Getter method to return the payload in the desired shape
    get payload() {
        return {
            address: new Address(this.address || {}).payload,
            dob_day: this.dob_day || '',
            dob_month: this.dob_month || '',
            dob_year: this.dob_year || '',
            email: this.email || '',
            identification_number: this.identification_number || undefined,
            is_owner: this.is_owner || false,
            metadata: this.metadata || null,
            name: this.name || '',
            phone: this.phone || '',
            platform_account_id: this.platform_account_id || null,
            title: this.title || '',
            ownership_percentage: this.ownership_percentage || undefined,
        };
    }
}
class Representative {
    constructor(representative) {
        this.address = Object.assign({}, new Address(representative.address || {}));
        this.created_at = representative.created_at;
        this.dob_day = filterNumber(representative.dob_day);
        this.dob_month = filterNumber(representative.dob_month);
        this.dob_year = representative.dob_year;
        this.dob_full =
            constructDate(this.dob_year, this.dob_month, this.dob_day) || '';
        this.documents = representative.documents;
        this.email = representative.email;
        this.id = representative.id;
        this.business_id = representative.business_id;
        this.is_owner = representative.is_owner;
        this.metadata = representative.metadata;
        this.name = representative.name;
        this.phone = representative.phone;
        this.platform_account_id = representative.platform_account_id;
        this.identification_number = representative.identification_number;
        this.ssn_last4 = representative.ssn_last4;
        this.title = representative.title;
        this.ownership_percentage = representative.ownership_percentage;
        this.updated_at = representative.updated_at;
    }
    // Getter method to return the payload in the desired shape
    get payload() {
        return {
            address: new Address(this.address || {}).payload,
            dob_day: this.dob_day || '',
            dob_month: this.dob_month || '',
            dob_year: this.dob_year || '',
            email: this.email || '',
            is_owner: this.is_owner || false,
            identification_number: this.identification_number || undefined,
            metadata: this.metadata || null,
            name: this.name || '',
            phone: this.phone || '',
            platform_account_id: this.platform_account_id || null,
            title: this.title || '',
        };
    }
}

var CountryCode;
(function (CountryCode) {
    CountryCode["USA"] = "USA";
    CountryCode["CAN"] = "CAN";
})(CountryCode || (CountryCode = {}));

// Normalize various incoming country representations to strict CountryCode values
const normalizeCountry = (value) => {
    const v = (value || '').toString().trim().toUpperCase();
    if (v === 'US' || v === 'USA' || v === CountryCode.USA)
        return CountryCode.USA;
    if (v === 'CA' || v === 'CAN' || v === CountryCode.CAN)
        return CountryCode.CAN;
    return CountryCode.USA;
};
var BusinessFormServerErrors;
(function (BusinessFormServerErrors) {
    BusinessFormServerErrors["fetchData"] = "Error retrieving business data";
    BusinessFormServerErrors["patchData"] = "Error updating business data";
})(BusinessFormServerErrors || (BusinessFormServerErrors = {}));
var BusinessClassification;
(function (BusinessClassification) {
    BusinessClassification["sole_proprietor"] = "sole_proprietor";
    BusinessClassification["partnership"] = "partnership";
    BusinessClassification["corporation"] = "corporation";
    BusinessClassification["public_company"] = "public_company";
    BusinessClassification["limited"] = "limited";
    BusinessClassification["non_profit"] = "non_profit";
    BusinessClassification["government"] = "government";
})(BusinessClassification || (BusinessClassification = {}));
class Address {
    constructor(address) {
        this.id = address.id;
        this.platform_account_id = address.platform_account_id;
        this.line1 = address.line1;
        this.line2 = address.line2;
        this.postal_code = address.postal_code;
        this.city = address.city;
        this.state = getStateAbbreviation(address.state);
        this.country = normalizeCountry(address.country);
        this.created_at = address.created_at;
        this.updated_at = address.updated_at;
    }
    get payload() {
        return {
            platform_account_id: this.platform_account_id || '',
            line1: this.line1 || '',
            line2: this.line2 || '',
            postal_code: this.postal_code || '',
            city: this.city || '',
            state: this.state || '',
            country: this.country || '',
        };
    }
}
class AdditionalQuestions {
    constructor(additionalQuestions) {
        this.business_revenue = additionalQuestions.business_revenue;
        this.business_payment_volume = additionalQuestions.business_payment_volume;
        this.business_average_transaction_amount = additionalQuestions.business_average_transaction_amount;
        this.business_when_service_received =
            additionalQuestions.business_when_service_received;
        this.business_recurring_payments =
            additionalQuestions.business_recurring_payments;
        this.business_recurring_payments_percentage =
            additionalQuestions.business_recurring_payments_percentage;
        this.business_seasonal = additionalQuestions.business_seasonal;
        this.business_other_payment_details =
            additionalQuestions.business_other_payment_details;
    }
    get payload() {
        return {
            business_revenue: this.business_revenue || '',
            business_payment_volume: this.business_payment_volume || '',
            business_average_transaction_amount: this.business_average_transaction_amount || '',
            business_when_service_received: this.business_when_service_received || '',
            business_recurring_payments: this.business_recurring_payments || '',
            business_recurring_payments_percentage: this.business_recurring_payments_percentage || '',
            business_seasonal: this.business_seasonal || '',
            business_other_payment_details: this.business_other_payment_details || '',
        };
    }
}
class CoreBusinessInfo {
    constructor(coreBusinessInfo) {
        this.classification = coreBusinessInfo.classification;
        this.legal_name = coreBusinessInfo.legal_name;
        this.doing_business_as = coreBusinessInfo.doing_business_as;
        this.industry = coreBusinessInfo.industry;
        this.tax_id = coreBusinessInfo.tax_id;
        this.tax_id_last4 = coreBusinessInfo.tax_id_last4;
        this.website_url = coreBusinessInfo.website_url;
        this.email = coreBusinessInfo.email;
        this.phone = coreBusinessInfo.phone;
        this.date_of_incorporation = coreBusinessInfo.date_of_incorporation;
    }
    get payload() {
        return Object.assign(Object.assign({ classification: this.classification || '', legal_name: this.legal_name || '', doing_business_as: this.doing_business_as || '', industry: this.industry || '' }, (!this.tax_id_last4 && { tax_id: this.tax_id || '' })), { website_url: this.website_url || '', email: this.email || '', phone: this.phone || '', date_of_incorporation: this.date_of_incorporation || '' });
    }
}
class Business {
    constructor(business) {
        this.additional_questions = business.additional_questions
            ? new AdditionalQuestions(business.additional_questions)
            : null;
        this.associated_accounts = business.associated_accounts;
        this.classification = business.classification;
        this.bank_accounts = business.bank_accounts;
        this.created_at = business.created_at;
        this.documents = business.documents;
        this.doing_business_as = business.doing_business_as;
        this.email = business.email;
        this.id = business.id;
        this.industry = business.industry;
        this.legal_address = (business === null || business === void 0 ? void 0 : business.legal_address)
            ? new Address(business.legal_address)
            : null;
        this.legal_name = business.legal_name;
        this.metadata = business.metadata;
        this.owners = business.owners;
        this.phone = business.phone;
        this.platform_account_id = business.platform_account_id;
        this.product_categories = business.product_categories;
        this.representative = business.representative
            ? new Representative(business.representative)
            : null;
        this.tax_id = business.tax_id;
        this.tax_id_last4 = business.tax_id_last4;
        this.terms_conditions_accepted = business.terms_conditions_accepted;
        this.updated_at = business.updated_at;
        this.website_url = business.website_url;
        this.date_of_incorporation = business.date_of_incorporation;
        this.country_of_establishment = normalizeCountry(business.country_of_establishment);
        this.bank_account_verification = business.bank_account_verification;
    }
    get payload() {
        return Object.assign(Object.assign({ additional_questions: new AdditionalQuestions(this.additional_questions)
                .payload, classification: this.classification || '', doing_business_as: this.doing_business_as || '', email: this.email || '', industry: this.industry || '', legal_address: new Address(this.legal_address).payload, legal_name: this.legal_name || '', metadata: this.metadata || {}, owners: this.owners.map((owner) => ({ id: owner.id })), phone: this.phone || '', platform_account_id: this.platform_account_id || '', representative: new Representative(this.representative).payload }, (!this.tax_id_last4 && { tax_id: this.tax_id || '' })), { tax_id_last4: this.tax_id_last4 || '', website_url: this.website_url || '', date_of_incorporation: this.date_of_incorporation || '', country_of_establishment: this.country_of_establishment || CountryCode.USA });
    }
}

export { AdditionalQuestions as A, BusinessClassification as B, CoreBusinessInfo as C, Owner as O, Representative as R, StateOptions as S, CountryCode as a, Business as b, Address as c, deconstructDate as d, BusinessFormServerErrors as e, checkProvisioningStatus as f };
