import { f as formatCurrency } from './utils-C25uIOK0.js';

var ComponentErrorCodes;
(function (ComponentErrorCodes) {
    ComponentErrorCodes["MISSING_PROPS"] = "missing-props";
    ComponentErrorCodes["FETCH_ERROR"] = "fetch-error";
    ComponentErrorCodes["PATCH_ERROR"] = "patch-error";
    ComponentErrorCodes["POST_ERROR"] = "post-error";
    ComponentErrorCodes["UNKNOWN_ERROR"] = "unknown-error";
    ComponentErrorCodes["TOKENIZE_ERROR"] = "tokenize-error";
    ComponentErrorCodes["COMPLETE_CHECKOUT_ERROR"] = "complete-checkout-error";
    ComponentErrorCodes["CHECKOUT_ALREADY_COMPLETED"] = "checkout-already-completed";
    ComponentErrorCodes["CHECKOUT_EXPIRED"] = "checkout-expired";
    ComponentErrorCodes["NOT_AUTHENTICATED"] = "not-authenticated";
    ComponentErrorCodes["INVALID_PARAMETER"] = "invalid-parameter";
    ComponentErrorCodes["PROVISIONING_REQUESTED"] = "provisioning-already-requested";
    ComponentErrorCodes["INVALID_REFUND_AMOUNT"] = "invalid-refund-amount";
    ComponentErrorCodes["VALIDATION_ERROR"] = "validation-error";
})(ComponentErrorCodes || (ComponentErrorCodes = {}));
var ComponentErrorSeverity;
(function (ComponentErrorSeverity) {
    ComponentErrorSeverity["INFO"] = "info";
    ComponentErrorSeverity["WARNING"] = "warning";
    ComponentErrorSeverity["ERROR"] = "error";
})(ComponentErrorSeverity || (ComponentErrorSeverity = {}));
var ComponentErrorMessages;
(function (ComponentErrorMessages) {
    ComponentErrorMessages["NOT_AUTHENTICATED"] = "Not authenticated. Please provide a valid auth token, checkout id, and account id.";
    ComponentErrorMessages["CHECKOUT_ALREADY_COMPLETED"] = "Checkout already completed. Please create a new checkout.";
    ComponentErrorMessages["CHECKOUT_EXPIRED"] = "Checkout expired. Please create a new checkout.";
})(ComponentErrorMessages || (ComponentErrorMessages = {}));

class Completion {
    constructor(data) {
        this.payment_mode = ICheckoutPaymentMode[data.payment_mode];
        this.payment_token = data.payment_token;
        this.payment_status = data.payment_status;
        this.payment_response = data.payment_response;
        this.payment_error_code = data.payment_error_code;
        this.payment_error_description = data.payment_error_description;
        this.checkout_id = data.checkout_id;
        this.additional_transactions = data.additional_transactions;
        this.payment_id = data.payment_id;
        this.payment_method_id = data.payment_method_id;
        this.status = data.status;
        this.created_at = data.created_at;
        this.updated_at = data.updated_at;
    }
}
class Checkout {
    constructor(data) {
        var _a;
        this.id = data.id;
        this.description = data.description;
        this.payment_intent_id = data.payment_intent_id;
        this.account_id = data.account_id;
        this.platform_account_id = data.platform_account_id;
        this.payment_amount = data.payment_amount;
        this.payment_client_id = data.payment_client_id;
        this.payment_description = data.payment_description;
        this.payment_methods = data.payment_methods;
        this.payment_method_group_id = data.payment_method_group_id;
        this.payment_settings = data.payment_settings;
        this.bnpl = data.bnpl;
        this.total_amount = data.total_amount;
        this.insurance_amount = data.insurance_amount;
        this.status = ICheckoutStatus[data.status];
        this.payment_currency = data.payment_currency;
        this.mode = data.mode;
        this.statement_descriptor = data.statement_descriptor;
        this.application_fees = data.application_fees;
        this.successful_payment_id = data.successful_payment_id;
        this.created_at = data.created_at;
        this.updated_at = data.updated_at;
        this.completions = (_a = data.completions) === null || _a === void 0 ? void 0 : _a.map((completion) => new Completion(completion));
    }
    get payment_mode() {
        var _a, _b, _c, _d, _e, _f;
        let paymentMode;
        if (!this.completions || this.completions.length === 0) {
            return ICheckoutPaymentMode.unknown;
        }
        const sortedCompletions = this.completions.sort((a, b) => {
            return (new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime());
        });
        const lastCompletion = sortedCompletions[0];
        if (lastCompletion.payment_mode) {
            paymentMode = lastCompletion.payment_mode;
        }
        else if ((_c = (_b = (_a = lastCompletion.payment_response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.payment_method) === null || _c === void 0 ? void 0 : _c.card) {
            paymentMode = ICheckoutPaymentMode.card;
        }
        else if ((_f = (_e = (_d = lastCompletion.payment_response) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.payment_method) === null || _f === void 0 ? void 0 : _f.bank_account) {
            paymentMode = ICheckoutPaymentMode.bank_account;
        }
        return paymentMode;
    }
    formattedPaymentAmount(amount) {
        return formatCurrency(amount, this.payment_currency);
    }
}
var ICheckoutPaymentMode;
(function (ICheckoutPaymentMode) {
    ICheckoutPaymentMode["bnpl"] = "Buy Now Pay Later";
    ICheckoutPaymentMode["ecom"] = "E-commerce";
    ICheckoutPaymentMode["card"] = "Card";
    ICheckoutPaymentMode["bank_account"] = "Bank Account";
    ICheckoutPaymentMode["card_present"] = "Card Present";
    ICheckoutPaymentMode["apple_pay"] = "Apple Pay";
    ICheckoutPaymentMode["unknown"] = "";
})(ICheckoutPaymentMode || (ICheckoutPaymentMode = {}));
var ICheckoutPaymentModeParam;
(function (ICheckoutPaymentModeParam) {
    ICheckoutPaymentModeParam["bnpl"] = "bnpl";
    ICheckoutPaymentModeParam["ecom"] = "ecom";
    ICheckoutPaymentModeParam["apple_pay"] = "apple_pay";
})(ICheckoutPaymentModeParam || (ICheckoutPaymentModeParam = {}));
var ICheckoutStatus;
(function (ICheckoutStatus) {
    ICheckoutStatus["created"] = "created";
    ICheckoutStatus["completed"] = "completed";
    ICheckoutStatus["attempted"] = "attempted";
    ICheckoutStatus["expired"] = "expired";
})(ICheckoutStatus || (ICheckoutStatus = {}));
var CompletionStatuses;
(function (CompletionStatuses) {
    CompletionStatuses["failed"] = "failed";
    CompletionStatuses["succeeded"] = "succeeded";
})(CompletionStatuses || (CompletionStatuses = {}));

var DisputeStatus;
(function (DisputeStatus) {
    DisputeStatus["won"] = "won";
    DisputeStatus["lost"] = "lost";
    DisputeStatus["underReview"] = "under_review";
    DisputeStatus["needsResponse"] = "needs_response";
})(DisputeStatus || (DisputeStatus = {}));
class Dispute {
    get needsResponse() {
        return this.status == DisputeStatus.needsResponse;
    }
    get underReview() {
        return this.status == DisputeStatus.underReview;
    }
    get won() {
        return this.status == DisputeStatus.won;
    }
    get lost() {
        return this.status == DisputeStatus.lost;
    }
    constructor(dispute) {
        this.id = dispute.id;
        this.amount = dispute.amount;
        this.currency = dispute.currency;
        this.payment_id = dispute.payment_id;
        this.reason = dispute.reason;
        this.due_date = dispute.due_date;
        this.status = dispute.status;
        this.metadata = dispute.metadata;
        this.created_at = dispute.created_at;
        this.updated_at = dispute.updated_at;
        this.dispute_response = dispute.dispute_response ? new DisputeResponse(dispute.dispute_response) : undefined;
    }
}
class DisputeResponse {
    constructor(response) {
        this.additional_statement = response.additional_statement;
        this.cancellation_policy_disclosure = response.cancellation_policy_disclosure;
        this.cancellation_rebuttal = response.cancellation_rebuttal;
        this.customer_billing_address = response.customer_billing_address;
        this.customer_email_address = response.customer_email_address;
        this.customer_name = response.customer_name;
        this.customer_purchase_ip_address = response.customer_purchase_ip_address;
        this.duplicate_charge_explanation = response.duplicate_charge_explanation;
        this.product_description = response.product_description;
        this.refund_policy_disclosure = response.refund_policy_disclosure;
        this.refund_refusal_explanation = response.refund_refusal_explanation;
        this.service_date = response.service_date;
        this.shipping_address = response.shipping_address;
        this.shipping_carrier = response.shipping_carrier;
        this.shipping_date = response.shipping_date;
        this.shipping_tracking_number = response.shipping_tracking_number;
        this.duplicate_charge_original_payment_id = response.duplicate_charge_original_payment_id;
    }
}

var CaptureStrategy;
(function (CaptureStrategy) {
    CaptureStrategy["automatic"] = "automatic";
    CaptureStrategy["manual"] = "manual";
})(CaptureStrategy || (CaptureStrategy = {}));
var PaymentMethodTypes;
(function (PaymentMethodTypes) {
    PaymentMethodTypes["card"] = "card";
    PaymentMethodTypes["bankAccount"] = "bankAccount";
    PaymentMethodTypes["sezzle"] = "sezzle";
    PaymentMethodTypes["plaid"] = "plaid";
    PaymentMethodTypes["applePay"] = "applePay";
})(PaymentMethodTypes || (PaymentMethodTypes = {}));
var PaymentTypes;
(function (PaymentTypes) {
    PaymentTypes["card"] = "Card";
    PaymentTypes["bankAccount"] = "ACH";
    PaymentTypes["unknown"] = "Unknown";
})(PaymentTypes || (PaymentTypes = {}));
var PaymentStatuses;
(function (PaymentStatuses) {
    PaymentStatuses["pending"] = "pending";
    PaymentStatuses["automatic"] = "automatic";
    PaymentStatuses["authorized"] = "authorized";
    PaymentStatuses["succeeded"] = "succeeded";
    PaymentStatuses["failed"] = "failed";
    PaymentStatuses["canceled"] = "canceled";
    PaymentStatuses["disputed"] = "disputed";
    PaymentStatuses["fully_refunded"] = "fully_refunded";
    PaymentStatuses["partially_refunded"] = "partially_refunded";
})(PaymentStatuses || (PaymentStatuses = {}));
var CurrencyTypes;
(function (CurrencyTypes) {
    CurrencyTypes["usd"] = "usd";
    CurrencyTypes["cad"] = "cad";
})(CurrencyTypes || (CurrencyTypes = {}));
class PaymentMethod {
    constructor(paymentMethod) {
        this.card = paymentMethod.card ? new Card(paymentMethod.card) : undefined;
        this.bank_account = paymentMethod.bank_account
            ? new BankAccount(paymentMethod.bank_account)
            : undefined;
    }
    get payersName() {
        if (this.card) {
            return this.card.name;
        }
        else if (this.bank_account) {
            return this.bank_account.name;
        }
        return null;
    }
    get lastFourDigits() {
        if (this.card) {
            return `**** ${this.card.acct_last_four}`;
        }
        else if (this.bank_account) {
            return `**** ${this.bank_account.acct_last_four}`;
        }
        return null;
    }
}
class BankAccount {
    constructor(bankAccount) {
        this.id = bankAccount.id;
        this.acct_last_four = bankAccount.acct_last_four;
        this.name = bankAccount.name;
        this.brand = bankAccount.brand;
        this.token = bankAccount.token;
        this.created_at = bankAccount.created_at;
        this.updated_at = bankAccount.updated_at;
    }
}
class Card {
    constructor(card) {
        this.id = card.id || '';
        this.acct_last_four = card.acct_last_four;
        this.name = card.name;
        this.brand = card.brand;
        this.token = card.token;
        this.created_at = card.created_at;
        this.updated_at = card.updated_at;
    }
}
class Payment {
    constructor(payment) {
        this.id = payment.id;
        this.account_id = payment.account_id;
        this.currency = payment.currency;
        this.amount = payment.amount;
        this.amount_disputed = payment.amount_disputed;
        this.amount_refundable = payment.amount_refundable;
        this.amount_refunded = payment.amount_refunded;
        this.balance = payment.balance;
        this.captured = payment.captured;
        this.capture_strategy = payment.capture_strategy;
        this.description = payment.description;
        this.disputed = payment.disputed;
        this.disputes = payment.disputes;
        this.error_code = payment.error_code;
        this.error_description = payment.error_description;
        this.expedited = payment.expedited;
        this.fee_amount = payment.fee_amount;
        this.is_test = payment.is_test;
        this.metadata = payment.metadata;
        this.payment_method = new PaymentMethod(payment.payment_method);
        this.payment_intent_id = payment.payment_intent_id;
        this.refunded = payment.refunded;
        this.status = payment.status;
        this.created_at = payment.created_at;
        this.updated_at = payment.updated_at;
    }
    get disputedStatus() {
        const lost = this.disputes.some((dispute) => dispute.status === DisputeStatus.lost);
        // if a dispute is 'won', we don't show a dispute status, just general status
        // TODO: update this logic to work with new DisputeStatus enum
        // (cast 'open' as DisputeStatus in the meantime to keep existing functionality)
        if (!this.disputed) {
            return null;
        }
        else if (lost) {
            return DisputeStatus.lost;
        }
        else {
            return 'open';
        }
    }
    get payment_type() {
        if (this.payment_method) {
            return this.payment_method.card
                ? PaymentTypes.card
                : PaymentTypes.bankAccount;
        }
        else {
            return PaymentTypes.unknown;
        }
    }
    get payers_name() {
        return this.payment_method.payersName;
    }
    get last_four_digits() {
        return this.payment_method.lastFourDigits;
    }
    formattedPaymentAmount(amount) {
        return formatCurrency(amount, this.currency);
    }
}

var PaymentBalanceTxnType;
(function (PaymentBalanceTxnType) {
    PaymentBalanceTxnType["payment"] = "payment";
    PaymentBalanceTxnType["paymentFee"] = "payment_fee";
    PaymentBalanceTxnType["payout"] = "payout";
    PaymentBalanceTxnType["refund"] = "refund";
    PaymentBalanceTxnType["feeRefund"] = "fee_refund";
    PaymentBalanceTxnType["dispute"] = "dispute";
    PaymentBalanceTxnType["disputeFee"] = "dispute_fee";
    PaymentBalanceTxnType["disputeFeeRefund"] = "dispute_fee_refund";
    PaymentBalanceTxnType["disputeRefund"] = "dispute_refund";
    PaymentBalanceTxnType["applicationFeeReturned"] = "application_fee_returned";
})(PaymentBalanceTxnType || (PaymentBalanceTxnType = {}));
class PaymentBalanceTransaction {
    constructor(balanceTransaction) {
        this.id = balanceTransaction.id;
        this.amount = balanceTransaction.amount;
        this.balance = balanceTransaction.balance;
        this.currency = balanceTransaction.currency;
        this.financial_transaction_id = balanceTransaction.financial_transaction_id;
        this.payment_id = balanceTransaction.payment_id;
        this.payment_balance_txn_type = balanceTransaction.payment_balance_txn_type;
        this.source_id = balanceTransaction.source_id;
        this.source_type = balanceTransaction.source_type;
        this.created_at = balanceTransaction.created_at;
        this.updated_at = balanceTransaction.updated_at;
    }
    get displayTransactionId() {
        if (this.payment_balance_txn_type === PaymentBalanceTxnType.paymentFee) {
            return '--';
        }
        else if (this.payment_balance_txn_type === PaymentBalanceTxnType.applicationFeeReturned) {
            return '--';
        }
        else {
            return this.source_id;
        }
    }
    formattedPaymentAmount(amount) {
        return formatCurrency(amount, this.currency);
    }
}

var PayoutStatuses;
(function (PayoutStatuses) {
    PayoutStatuses["paid"] = "paid";
    PayoutStatuses["failed"] = "failed";
    PayoutStatuses["forwarded"] = "forwarded";
    PayoutStatuses["scheduled"] = "scheduled";
    PayoutStatuses["in_transit"] = "in_transit";
    PayoutStatuses["canceled"] = "canceled";
})(PayoutStatuses || (PayoutStatuses = {}));
var PayoutStatusesSafeNames;
(function (PayoutStatusesSafeNames) {
    PayoutStatusesSafeNames["paid"] = "Paid";
    PayoutStatusesSafeNames["failed"] = "Failed";
    PayoutStatusesSafeNames["forwarded"] = "Forwarded";
    PayoutStatusesSafeNames["scheduled"] = "Scheduled";
    PayoutStatusesSafeNames["in_transit"] = "In Transit";
    PayoutStatusesSafeNames["canceled"] = "Canceled";
})(PayoutStatusesSafeNames || (PayoutStatusesSafeNames = {}));
class Payout {
    constructor(payout) {
        this.id = payout.id;
        this.account_id = payout.account_id;
        this.currency = payout.currency;
        this.amount = payout.amount;
        this.bank_account = payout.bank_account;
        this.delivery_method = payout.delivery_method || 'standard';
        this.description = payout.description;
        this.deposits_at = payout.deposits_at;
        this.fees_total = payout.fees_total;
        this.refunds_count = payout.refunds_count;
        this.refunds_total = payout.refunds_total;
        this.payments_count = payout.payments_count;
        this.payments_total = payout.payments_total;
        this.payout_type = payout.payout_type;
        this.other_total = payout.other_total;
        this.status = payout.status;
        this.metadata = payout.metadata;
        this.created_at = payout.created_at;
        this.updated_at = payout.updated_at;
        this.settlement_priority = payout.settlement_priority || 'standard';
    }
    formattedPaymentAmount(amount) {
        return formatCurrency(amount, this.currency);
    }
}

var PayoutBalanceTransactionType;
(function (PayoutBalanceTransactionType) {
    PayoutBalanceTransactionType["fee"] = "fee";
    PayoutBalanceTransactionType["payment"] = "payment";
    PayoutBalanceTransactionType["payout"] = "payout";
    PayoutBalanceTransactionType["sellerPaymentRefund"] = "seller_payment_refund";
    PayoutBalanceTransactionType["disputeAmountCollected"] = "dispute_amount_collected";
    PayoutBalanceTransactionType["disputeFeeCollected"] = "dispute_fee_collected";
    PayoutBalanceTransactionType["sellerPayment"] = "seller_payment";
    PayoutBalanceTransactionType["transfer"] = "transfer";
    PayoutBalanceTransactionType["partnerPlatformProceedsCredit"] = "partner_platform_proceeds_credit";
})(PayoutBalanceTransactionType || (PayoutBalanceTransactionType = {}));
class PayoutBalanceTransaction {
    constructor(balanceTransaction) {
        this.id = balanceTransaction.id;
        this.account_id = balanceTransaction.account_id;
        this.payout_id = balanceTransaction.payout_id;
        this.financial_transaction_id = balanceTransaction.financial_transaction_id;
        this.amount = balanceTransaction.amount;
        this.fee = balanceTransaction.fee;
        this.net = balanceTransaction.net;
        this.currency = balanceTransaction.currency;
        this.source_id = balanceTransaction.source_id;
        this.description = balanceTransaction.description;
        this.txn_type = balanceTransaction.txn_type;
        this.created_at = balanceTransaction.created_at;
        this.available_on = balanceTransaction.available_on;
        this.updated_at = balanceTransaction.updated_at;
    }
    formattedPaymentAmount(amount) {
        return formatCurrency(amount, this.currency);
    }
}

var ITerminalStatus;
(function (ITerminalStatus) {
    ITerminalStatus["connected"] = "connected";
    ITerminalStatus["disconnected"] = "disconnected";
    ITerminalStatus["unknown"] = "unknown";
    ITerminalStatus["pending_configuration"] = "pending_configuration";
    ITerminalStatus["archived"] = "archived";
})(ITerminalStatus || (ITerminalStatus = {}));
var TerminalProviders;
(function (TerminalProviders) {
    TerminalProviders["verifone"] = "verifone";
})(TerminalProviders || (TerminalProviders = {}));
class Terminal {
    constructor(data) {
        this.id = data.id || '';
        this.status = data.status;
        this.account_id = data.account_id || '';
        this.platform_account_id = data.platform_account_id || '';
        this.provider = data.provider || null;
        this.provider_id = data.provider_id || '';
        this.provider_serial_number = data.provider_serial_number || '';
        this.created_at = data.created_at || '';
        this.updated_at = data.updated_at || '';
        this.verified_at = data.verified_at || '';
        this.nickname = data.nickname || '';
        this.model_name = data.model_name || null;
    }
}

var TerminalOrderType;
(function (TerminalOrderType) {
    TerminalOrderType["boardingOnly"] = "boarding_only";
    TerminalOrderType["boardingShipping"] = "boarding_shipping";
})(TerminalOrderType || (TerminalOrderType = {}));
var TerminalOrderStatus;
(function (TerminalOrderStatus) {
    TerminalOrderStatus["created"] = "created";
    TerminalOrderStatus["submitted"] = "submitted";
    TerminalOrderStatus["completed"] = "completed";
    TerminalOrderStatus["in_progress"] = "in_progress";
    TerminalOrderStatus["on_hold"] = "on_hold";
    TerminalOrderStatus["canceled"] = "canceled";
})(TerminalOrderStatus || (TerminalOrderStatus = {}));
class TerminalOrder {
    constructor(data) {
        this.id = data.id;
        this.business_id = data.business_id;
        this.company_name = data.company_name;
        this.sub_account_id = data.sub_account_id;
        this.provider = data.provider || TerminalProviders.verifone;
        this.order_items = [];
        this.order_type = data.order_type;
        this.order_status = data.order_status;
        this.terminals = data.terminals;
        this.created_at = data.created_at;
        this.updated_at = data.updated_at;
    }
    get payload() {
        return {
            business_id: this.business_id,
            sub_account_id: this.sub_account_id,
            order_type: this.order_type,
            order_items: this.order_items,
        };
    }
    get totalQuantity() {
        return this.order_items.reduce((acc, item) => acc + item.quantity, 0);
    }
    updateTerminal(model_name, quantity) {
        // if quantity is 0, remove terminal
        if (quantity === 0) {
            this.order_items = this.order_items.filter((t) => t.model_name !== model_name);
            return;
        }
        const terminal = this.order_items.find((t) => t.model_name === model_name);
        if (terminal) {
            terminal.quantity = quantity;
        }
        else {
            this.order_items.push({ model_name, quantity });
        }
    }
}

var TerminalModelName;
(function (TerminalModelName) {
    TerminalModelName["v400"] = "v400";
    TerminalModelName["p400"] = "p400+";
    TerminalModelName["e285"] = "e285";
})(TerminalModelName || (TerminalModelName = {}));
class TerminalModel {
    constructor(data) {
        this.id = data.id;
        this.model_name = data.model_name;
        this.description = data.description;
        this.image_url = data.image_url;
        this.help_url = data.help_url;
    }
}

var AccountType;
(function (AccountType) {
    AccountType["test"] = "test";
    AccountType["live"] = "live";
})(AccountType || (AccountType = {}));
var AccountStatus;
(function (AccountStatus) {
    AccountStatus["created"] = "created";
    AccountStatus["submitted"] = "submitted";
    AccountStatus["information_needed"] = "information_needed";
    AccountStatus["rejected"] = "rejected";
    AccountStatus["enabled"] = "enabled";
    AccountStatus["disabled"] = "disabled";
    AccountStatus["archived"] = "archived";
})(AccountStatus || (AccountStatus = {}));
class SubAccount {
    constructor(subAccount) {
        this.id = subAccount.id;
        this.name = subAccount.name;
        this.account_type = subAccount.account_type;
        this.status = subAccount.status;
        this.currency = subAccount.currency;
        this.platform_account_id = subAccount.platform_account_id;
        this.payout_account_id = subAccount.payout_account_id;
        this.business_id = subAccount.business_id;
        this.application_fee_rates = subAccount.application_fee_rates;
        this.processing_ready = subAccount.processing_ready;
        this.payout_ready = subAccount.payout_ready;
        this.related_accounts = subAccount.related_accounts;
        this.created_at = subAccount.created_at;
        this.updated_at = subAccount.updated_at;
    }
}

var EntityDocumentType;
(function (EntityDocumentType) {
    EntityDocumentType["voidedCheck"] = "voided_check";
    EntityDocumentType["balanceSheet"] = "balance_sheet";
    EntityDocumentType["bankStatement"] = "bank_statement";
    EntityDocumentType["governmentId"] = "government_id";
    EntityDocumentType["profitAndLossStatement"] = "profit_and_loss_statement";
    EntityDocumentType["taxReturn"] = "tax_return";
    EntityDocumentType["other"] = "other";
    EntityDocumentType["articlesOfIncorporation"] = "articles_of_incorporation";
    EntityDocumentType["businessRegistration"] = "business_registration";
    EntityDocumentType["passport"] = "passport";
    EntityDocumentType["driverLicense"] = "driver_license";
    EntityDocumentType["residentCard"] = "resident_card";
    EntityDocumentType["statusCard"] = "status_card";
    EntityDocumentType["nexusCard"] = "nexus_card";
    EntityDocumentType["citizenshipCard"] = "citizenship_card";
    EntityDocumentType["foreignPassport"] = "foreign_passport";
    EntityDocumentType["birthCertificate"] = "birth_certificate";
    EntityDocumentType["sinCard"] = "sin_card";
    EntityDocumentType["ssnCard"] = "ssn_card";
})(EntityDocumentType || (EntityDocumentType = {}));
var EntityDocumentStatus;
(function (EntityDocumentStatus) {
    EntityDocumentStatus["pending"] = "pending";
    EntityDocumentStatus["uploaded"] = "uploaded";
    EntityDocumentStatus["canceled"] = "canceled";
    EntityDocumentStatus["needed"] = "needed";
})(EntityDocumentStatus || (EntityDocumentStatus = {}));
class EntityDocument {
    constructor(fileData, business_id) {
        this.fileData = null;
        this.file = fileData.file;
        this.document_type = fileData.document_type;
        this.presigned_url = null;
        this.record_data = {
            business_id: business_id,
            document_type: this.document_type,
            file_name: this.file.name,
            file_type: this.file.type,
        };
    }
    async getFileData() {
        if (this.fileData) {
            return this.fileData;
        }
        const fileDataPromise = new Promise((resolve, reject) => {
            const reader = new FileReader();
            reader.onload = (e) => {
                this.fileData = e.target.result;
                resolve(this.fileData);
            };
            reader.onerror = () => {
                reject(new Error('Error reading file'));
            };
            reader.readAsArrayBuffer(this.file);
        });
        return await fileDataPromise;
    }
    setPresignedUrl(url) {
        this.presigned_url = url;
    }
}

var RefundStatuses;
(function (RefundStatuses) {
    RefundStatuses["succeeded"] = "succeeded";
    RefundStatuses["failed"] = "failed";
})(RefundStatuses || (RefundStatuses = {}));
var RefundReasons;
(function (RefundReasons) {
    RefundReasons["customerRequest"] = "customer_request";
    RefundReasons["duplicate"] = "duplicate";
    RefundReasons["fraudulent"] = "fraudulent";
})(RefundReasons || (RefundReasons = {}));
class RefundPayload {
    constructor(refundPayload) {
        this.amount = refundPayload.amount;
        this.reason = refundPayload.reason;
        this.description = refundPayload.description;
        this.metadata = refundPayload.metadata;
    }
}

var ApplePaySessionStatus;
(function (ApplePaySessionStatus) {
    ApplePaySessionStatus["STATUS_SUCCESS"] = "STATUS_SUCCESS";
    ApplePaySessionStatus["STATUS_FAILURE"] = "STATUS_FAILURE";
})(ApplePaySessionStatus || (ApplePaySessionStatus = {}));
var ApplePayButtonType;
(function (ApplePayButtonType) {
    ApplePayButtonType["PLAIN"] = "plain";
    ApplePayButtonType["BUY"] = "buy";
    ApplePayButtonType["SET_UP"] = "set-up";
    ApplePayButtonType["DONATE"] = "donate";
    ApplePayButtonType["CHECK_OUT"] = "check-out";
    ApplePayButtonType["BOOK"] = "book";
    ApplePayButtonType["SUBSCRIBE"] = "subscribe";
})(ApplePayButtonType || (ApplePayButtonType = {}));
var ApplePayButtonStyle;
(function (ApplePayButtonStyle) {
    ApplePayButtonStyle["BLACK"] = "black";
    ApplePayButtonStyle["WHITE"] = "white";
    ApplePayButtonStyle["WHITE_OUTLINE"] = "white-outline";
})(ApplePayButtonStyle || (ApplePayButtonStyle = {}));
var ApplePayMerchantCapability;
(function (ApplePayMerchantCapability) {
    ApplePayMerchantCapability["SUPPORTS_3DS"] = "supports3DS";
    ApplePayMerchantCapability["SUPPORTS_EMV"] = "supportsEMV";
    ApplePayMerchantCapability["SUPPORTS_CREDIT"] = "supportsCredit";
    ApplePayMerchantCapability["SUPPORTS_DEBIT"] = "supportsDebit";
})(ApplePayMerchantCapability || (ApplePayMerchantCapability = {}));
class ApplePayConfig {
    constructor(data) {
        this.merchantIdentifier = data.merchantIdentifier;
        this.displayName = data.displayName;
        this.initiative = data.initiative;
        this.initiativeContext = data.initiativeContext;
        this.buttonType = data.buttonType || ApplePayButtonType.PLAIN;
        this.buttonStyle = data.buttonStyle || ApplePayButtonStyle.BLACK;
        this.buttonLocale = data.buttonLocale || 'en-US';
    }
    get isValid() {
        return !!(this.merchantIdentifier &&
            this.displayName &&
            this.initiative &&
            this.initiativeContext);
    }
}
class ApplePayPaymentRequest {
    constructor(data) {
        this.countryCode = data.countryCode;
        this.currencyCode = data.currencyCode;
        this.merchantCapabilities = data.merchantCapabilities;
        this.supportedNetworks = data.supportedNetworks;
        this.total = data.total;
        this.lineItems = data.lineItems;
        this.shippingMethods = data.shippingMethods;
        this.applicationData = data.applicationData;
        this.supportedCountries = data.supportedCountries;
    }
    get isValid() {
        var _a, _b, _c, _d;
        return !!(this.countryCode &&
            this.currencyCode &&
            ((_a = this.merchantCapabilities) === null || _a === void 0 ? void 0 : _a.length) &&
            ((_b = this.supportedNetworks) === null || _b === void 0 ? void 0 : _b.length) &&
            ((_c = this.total) === null || _c === void 0 ? void 0 : _c.label) &&
            ((_d = this.total) === null || _d === void 0 ? void 0 : _d.amount));
    }
}
class ApplePayHelpers {
    static isApplePaySupported() {
        var _a;
        return (typeof window !== 'undefined' &&
            'ApplePaySession' in window &&
            ((_a = window.ApplePaySession) === null || _a === void 0 ? void 0 : _a.supportsVersion(3)));
    }
    static canMakePayments() {
        var _a;
        if (!this.isApplePaySupported()) {
            return false;
        }
        return ((_a = window.ApplePaySession) === null || _a === void 0 ? void 0 : _a.canMakePayments()) || false;
    }
    static async canMakePaymentsWithActiveCard(merchantIdentifier) {
        var _a;
        if (!this.isApplePaySupported()) {
            return false;
        }
        try {
            return ((await ((_a = window.ApplePaySession) === null || _a === void 0 ? void 0 : _a.canMakePaymentsWithActiveCard(merchantIdentifier))) || false);
        }
        catch (error) {
            console.error('Error checking Apple Pay active card:', error);
            return false;
        }
    }
    static formatAmount(amount) {
        return (amount / 100).toFixed(2);
    }
    static parseAmount(amount) {
        return Math.round(parseFloat(amount) * 100);
    }
    static createLineItem(label, amount, type = 'final') {
        return {
            label,
            amount: this.formatAmount(amount),
            type,
        };
    }
    static getDefaultSupportedNetworks() {
        return ['amex', 'discover', 'masterCard', 'visa'];
    }
    static getDefaultMerchantCapabilities() {
        return [
            ApplePayMerchantCapability.SUPPORTS_3DS,
            ApplePayMerchantCapability.SUPPORTS_EMV,
            ApplePayMerchantCapability.SUPPORTS_CREDIT,
            ApplePayMerchantCapability.SUPPORTS_DEBIT,
        ];
    }
}

// Plaid-specific error codes
var PlaidErrorCodes;
(function (PlaidErrorCodes) {
    PlaidErrorCodes["PLAID_SDK_LOAD_FAILED"] = "plaid-sdk-load-failed";
    PlaidErrorCodes["PLAID_LINK_INIT_FAILED"] = "plaid-link-init-failed";
    PlaidErrorCodes["PLAID_LINK_TOKEN_FAILED"] = "plaid-link-token-failed";
    PlaidErrorCodes["PLAID_AUTHENTICATION_FAILED"] = "plaid-authentication-failed";
    PlaidErrorCodes["PLAID_BANK_NOT_SUPPORTED"] = "plaid-bank-not-supported";
    PlaidErrorCodes["PLAID_TOKEN_EXPIRED"] = "plaid-token-expired";
    PlaidErrorCodes["PLAID_NETWORK_ERROR"] = "plaid-network-error";
    PlaidErrorCodes["PLAID_USER_CANCELLED"] = "plaid-user-cancelled";
    PlaidErrorCodes["PLAID_TIMEOUT"] = "plaid-timeout";
    PlaidErrorCodes["PLAID_INVALID_CREDENTIALS"] = "plaid-invalid-credentials";
    PlaidErrorCodes["PLAID_ACCOUNT_LOCKED"] = "plaid-account-locked";
    PlaidErrorCodes["PLAID_MAINTENANCE"] = "plaid-maintenance";
    PlaidErrorCodes["PLAID_RATE_LIMITED"] = "plaid-rate-limited";
})(PlaidErrorCodes || (PlaidErrorCodes = {}));
// Plaid error message mapping
const PLAID_ERROR_MESSAGES = {
    [PlaidErrorCodes.PLAID_SDK_LOAD_FAILED]: 'Unable to load Plaid. Please refresh the page and try again.',
    [PlaidErrorCodes.PLAID_LINK_INIT_FAILED]: 'Unable to initialize bank connection. Please try again.',
    [PlaidErrorCodes.PLAID_LINK_TOKEN_FAILED]: 'Unable to connect to bank service. Please try again.',
    [PlaidErrorCodes.PLAID_AUTHENTICATION_FAILED]: 'Bank authentication failed. Please try again.',
    [PlaidErrorCodes.PLAID_BANK_NOT_SUPPORTED]: 'Your bank is not currently supported. Please try a different payment method.',
    [PlaidErrorCodes.PLAID_TOKEN_EXPIRED]: 'Your bank session has expired. Please reconnect your account.',
    [PlaidErrorCodes.PLAID_NETWORK_ERROR]: 'Network connection issue. Please check your internet connection and try again.',
    [PlaidErrorCodes.PLAID_USER_CANCELLED]: 'Bank connection was cancelled. Click to try again.',
    [PlaidErrorCodes.PLAID_TIMEOUT]: 'Bank connection timed out. Please try again.',
    [PlaidErrorCodes.PLAID_INVALID_CREDENTIALS]: 'Invalid bank credentials. Please check your username and password.',
    [PlaidErrorCodes.PLAID_ACCOUNT_LOCKED]: 'Your bank account is temporarily locked. Please contact your bank.',
    [PlaidErrorCodes.PLAID_MAINTENANCE]: 'Bank service is temporarily unavailable. Please try again later.',
    [PlaidErrorCodes.PLAID_RATE_LIMITED]: 'Too many connection attempts. Please wait a moment and try again.',
};
// Plaid error severity mapping
const PLAID_ERROR_SEVERITY = {
    [PlaidErrorCodes.PLAID_SDK_LOAD_FAILED]: ComponentErrorSeverity.ERROR,
    [PlaidErrorCodes.PLAID_LINK_INIT_FAILED]: ComponentErrorSeverity.ERROR,
    [PlaidErrorCodes.PLAID_LINK_TOKEN_FAILED]: ComponentErrorSeverity.ERROR,
    [PlaidErrorCodes.PLAID_AUTHENTICATION_FAILED]: ComponentErrorSeverity.ERROR,
    [PlaidErrorCodes.PLAID_BANK_NOT_SUPPORTED]: ComponentErrorSeverity.WARNING,
    [PlaidErrorCodes.PLAID_TOKEN_EXPIRED]: ComponentErrorSeverity.WARNING,
    [PlaidErrorCodes.PLAID_NETWORK_ERROR]: ComponentErrorSeverity.WARNING,
    [PlaidErrorCodes.PLAID_USER_CANCELLED]: ComponentErrorSeverity.INFO,
    [PlaidErrorCodes.PLAID_TIMEOUT]: ComponentErrorSeverity.WARNING,
    [PlaidErrorCodes.PLAID_INVALID_CREDENTIALS]: ComponentErrorSeverity.ERROR,
    [PlaidErrorCodes.PLAID_ACCOUNT_LOCKED]: ComponentErrorSeverity.ERROR,
    [PlaidErrorCodes.PLAID_MAINTENANCE]: ComponentErrorSeverity.WARNING,
    [PlaidErrorCodes.PLAID_RATE_LIMITED]: ComponentErrorSeverity.WARNING,
};

export { ApplePayConfig as A, EntityDocument as B, ComponentErrorSeverity as C, Dispute as D, EntityDocumentType as E, ICheckoutStatus as I, PayoutStatusesSafeNames as P, RefundReasons as R, SubAccount as S, TerminalOrderStatus as T, ICheckoutPaymentModeParam as a, ComponentErrorCodes as b, ComponentErrorMessages as c, CompletionStatuses as d, Payment as e, TerminalOrderType as f, ITerminalStatus as g, DisputeStatus as h, PaymentStatuses as i, PaymentBalanceTransaction as j, Payout as k, PayoutBalanceTransaction as l, Checkout as m, Terminal as n, TerminalModel as o, TerminalOrder as p, RefundPayload as q, ApplePayHelpers as r, ApplePayPaymentRequest as s, ApplePaySessionStatus as t, ApplePayButtonStyle as u, ApplePayButtonType as v, ApplePayMerchantCapability as w, PLAID_ERROR_SEVERITY as x, PLAID_ERROR_MESSAGES as y, PlaidErrorCodes as z };
