"use client";
import { jsx } from 'react/jsx-runtime';
import { clerkIntl } from '../lib/clerk-intl.mjs';
import { ClerkProvider } from '@clerk/nextjs';

function ClerkProviderClient({ children, locale, localePrefixAsNeeded = true, defaultLocale = 'en', signInUrl, signUpUrl, fallbackSignInUrl, fallbackSignUpUrl, waitlistUrl, }) {
    var _a, _b;
    const currentLocalization = (_b = (_a = clerkIntl[locale]) !== null && _a !== void 0 ? _a : clerkIntl[defaultLocale]) !== null && _b !== void 0 ? _b : clerkIntl.en;
    // In as-needed mode, skip prefixing for the default locale so /sign-in stays unprefixed.
    const shouldPrefixLocale = localePrefixAsNeeded ? locale !== defaultLocale : true;
    const localeSegment = shouldPrefixLocale && locale ? `/${locale}` : '';
    const buildUrl = (path) => path ? `${localeSegment}${path}` : undefined;
    // build the ClerkProvider props, only add when the parameter is not empty
    const clerkProviderProps = {
        localization: currentLocalization,
    };
    // Only add URL when the parameter is not empty
    const signInWithLocale = buildUrl(signInUrl);
    if (signInWithLocale) {
        clerkProviderProps.signInUrl = signInWithLocale;
    }
    const signUpWithLocale = buildUrl(signUpUrl);
    if (signUpWithLocale) {
        clerkProviderProps.signUpUrl = signUpWithLocale;
    }
    const signInFallbackWithLocale = buildUrl(fallbackSignInUrl);
    if (signInFallbackWithLocale) {
        clerkProviderProps.signInFallbackRedirectUrl = signInFallbackWithLocale;
    }
    const signUpFallbackWithLocale = buildUrl(fallbackSignUpUrl);
    if (signUpFallbackWithLocale) {
        clerkProviderProps.signUpFallbackRedirectUrl = signUpFallbackWithLocale;
    }
    const waitlistWithLocale = buildUrl(waitlistUrl);
    if (waitlistWithLocale) {
        clerkProviderProps.waitlistUrl = waitlistWithLocale;
    }
    // console.log('ClerkProviderClient props:', clerkProviderProps);
    return (jsx(ClerkProvider, Object.assign({}, clerkProviderProps, { children: children })));
}

export { ClerkProviderClient };
