import { SetRequired } from 'type-fest';

/**
 * This file was automatically generated by json-schema-to-typescript.
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
 * and run json-schema-to-typescript to regenerate this file.
 */
type Url = string;
/**
 * Don't show promo code.
 */
type HidePromoCode = boolean;
/**
 * The international 2-letter country code as defined by the ISO 3166-1 standard.
 */
type CountryCode = string;
/**
 * List of billing countries by identifier and label.
 */
type StateCountry = {
    value: CountryCode;
    /**
     * Name of the country.
     */
    label: string;
}[];
/**
 * List of shipping countries by identifier and label.
 */
type StateCountry1 = {
    value: CountryCode;
    /**
     * Name of the country.
     */
    label: string;
}[];
/**
 * List of shipping countries by identifier and label.
 *
 * This interface was referenced by `undefined`'s JSON-Schema definition
 * via the `patternProperty` "^.*$".
 */
type StateCountry2 = {
    value: CountryCode;
    /**
     * Name of the country.
     */
    label: string;
}[];
/**
 * List of shipping countries by identifier and label.
 *
 * This interface was referenced by `undefined`'s JSON-Schema definition
 * via the `patternProperty` "^.*$".
 */
type StateCountry3 = {
    value: CountryCode;
    /**
     * Name of the country.
     */
    label: string;
}[];
/**
 * Enable this option if you want to hide item codes.
 */
type HideItemCodes = boolean;
/**
 * Payload to use when using the config field of the Organization on CommerceLayer.
 */
interface ValidConfigForOrganizationsInCommerceLayer {
    mfe?: {
        default?: MfeConfig;
        [k: string]: MfeConfig | undefined;
    };
    /**
     * Default settings for apps.
     */
    apps?: {
        /**
         * Customers app settings.
         */
        customers?: {
            /**
             * Enable reset password flow for customers.
             */
            enable_reset_password?: boolean;
        };
        /**
         * Orders app settings.
         */
        orders?: {
            /**
             * Enable this option to allow external price.
             */
            external_price?: boolean;
        };
    };
    /**
     * Organization API behavior settings.
     */
    api?: {
        auth?: {
            /**
             * Allow JWT bearer token to see guest orders.
             */
            guest_orders?: boolean;
        };
        /**
         * Stream pusher configuration.
         */
        stream?: {
            /**
             * Where streaming is enabled: none, live, test or both.
             */
            scope?: "none" | "live" | "test" | "both";
        };
    };
    [k: string]: unknown;
}
/**
 * Default settings for links and checkout.
 *
 * This interface was referenced by `undefined`'s JSON-Schema definition
 * via the `patternProperty` "^market:id:[a-zA-Z0-9]*$$".
 */
interface MfeConfig {
    /**
     * Links for specific micro frontends.
     */
    links?: {
        cart?: Url;
        checkout?: Url;
        identity?: Url;
        microstore?: Url;
        my_account?: Url;
    };
    /**
     * Settings for the Checkout micro front end.
     */
    checkout?: {
        /**
         * Billing details not required for processing.
         */
        optional_billing_info?: boolean;
        hide_promo_code?: HidePromoCode;
        /**
         * Company name not required for processing.
         */
        optional_company_name?: boolean;
        /**
         * Show notes.
         */
        show_notes?: boolean;
        thankyou_page?: Url;
        billing_countries?: StateCountry;
        shipping_countries?: StateCountry1;
        default_country?: CountryCode;
        /**
         * List of states by country with identifier and label.
         */
        billing_states?: {
            [k: string]: StateCountry2;
        };
        /**
         * List of states by country with identifier and label.
         */
        shipping_states?: {
            [k: string]: StateCountry3;
        };
        hide_item_codes?: HideItemCodes;
    };
    /**
     * Checkout internal links settings.
     */
    urls?: {
        privacy?: Url;
        terms?: Url;
    };
    /**
     * Default language setting.
     */
    language?: string;
    /**
     * Cart settings.
     */
    cart?: {
        hide_item_codes?: HideItemCodes;
        hide_promo_code?: HidePromoCode;
    };
    /**
     * Microstore settings.
     */
    microstore?: {
        hide_item_codes?: HideItemCodes;
    };
    /**
     * My Account settings.
     */
    my_account?: {
        hide_item_codes?: HideItemCodes;
        /**
         * Enable this option if you want to hide returns.
         */
        hide_returns?: boolean;
        /**
         * Enable this option if you want to hide subscriptions.
         */
        hide_subscriptions?: boolean;
        /**
         * Don't show the wallet.
         */
        hide_wallet?: boolean;
        /**
         * Don't show the logout.
         */
        hide_logout?: boolean;
    };
}

/**
 * Represents a type that can be null or undefined, making it optional in use.
 * @template T The type that is being made nullable.
 */
type NullableType<T> = T | null | undefined;
/**
 * Params used by the getConfig function
 */
interface ConfigParams {
    /**
     * Language code (e.g., 'en', 'fr') used to dynamically replace the `:lang` placeholder in URLs.
     */
    lang?: NullableType<string>;
    /**
     * Organization slug used to replace the `:slug` placeholder in URLs.
     */
    slug?: NullableType<string>;
    /**
     * Access token string used to replace the `:access_token` placeholder in URLs.
     */
    accessToken?: NullableType<string>;
    /**
     * Unique identifier for an order used to replace the `:order_id` placeholder in URLs.
     */
    orderId?: NullableType<string>;
    /**
     * Order token string used to replace the `:token` placeholder in URLs.
     */
    token?: NullableType<string>;
    /**
     * Unique identifier for an SKU list used to replace the `:sku_list_id` placeholder in URLs.
     */
    skuListId?: NullableType<string>;
    /**
     * Unique identifier for an SKU used to replace the `:sku_id` placeholder in URLs.
     */
    skuId?: NullableType<string>;
    /**
     * Type used for the identity, which can be used to replace a `:identity_type` placeholder in URLs.
     */
    identityType?: NullableType<"login" | "signup">;
    /**
     * Client ID used for authentication, which can be used to replace a `:client_id` placeholder in URLs.
     */
    clientId?: NullableType<string>;
    /**
     * For the identity, it is the market used for the login process (e.g. a private market).
     */
    scope?: NullableType<string>;
    /**
     * For the identity, it is the default scope used by the app to obtain the organization settings needed to customize the UI (name, logo, colors, etc.).
     */
    publicScope?: NullableType<string>;
    /**
     * Return URL after certain actions, which can be used to replace a `:return_url` placeholder in URLs.
     */
    returnUrl?: NullableType<string>;
    /**
     * URL to the reset password page, which can be used to replace a `:reset_password_url` placeholder in URLs.
     */
    resetPasswordUrl?: NullableType<string>;
}
interface GetMfeConfigProps {
    /**
     * `config` attribute of the organization
     */
    jsonConfig?: {
        mfe?: MfeConfigs;
    } | null;
    /**
     *  Market identifier for fetching specific configuration overrides. (`market:id:hashid`)
     */
    market?: string;
    /**
     * Parameters for replacing URL placeholders.
     */
    params?: ConfigParams;
}
type MfeConfigs = NonNullable<ValidConfigForOrganizationsInCommerceLayer["mfe"]>;
type DefaultMfeConfig = NonNullable<NonNullable<ValidConfigForOrganizationsInCommerceLayer["mfe"]>["default"]>;
/**
 * Retrieves and merges the default organization configuration with market-specific overrides based on the provided market identifier.
 * Placeholder values in the configuration URLs can be replaced with actual values from the `params`.
 *
 * @param jsonConfig The complete configuration object of the organization.
 * @param market The market identifier used to get market-specific configuration overrides.
 * @param params The object containing replacement values for URL placeholders, such as language and access token.
 * @returns The merged configuration object for the specified market, or null if no configuration is found.
 */
declare function getMfeConfig({ jsonConfig, market, params, }: GetMfeConfigProps): DefaultMfeConfig | null;
declare function hasValidLinks(config: ReturnType<typeof getMfeConfig>): config is MfeConfigWithLinks;
type MfeConfigWithLinks = Omit<DefaultMfeConfig, "links"> & {
    links: SetRequired<NonNullable<DefaultMfeConfig["links"]>, "cart" | "checkout" | "identity" | "my_account">;
};

export { type DefaultMfeConfig, type MfeConfigWithLinks, type MfeConfigs, getMfeConfig, hasValidLinks };
