import { SdkBase } from './SdkBase.js';
export class AuthSdk extends SdkBase {
    /**
     * Redirects to the API server to perform authentication for a given provider.
     *
     * @param provider The provider to use
     * @param redirect The path or the full URL
     */
    oauthRedirect(provider, opts = {}) {
        const { redirect, type = 'redirect' } = opts;
        const base = new URL(this.sdk.baseUri);
        let url;
        switch (provider) {
            case 'google':
                url = new URL('/auth/google/redirect', base);
                break;
            case 'github':
                url = new URL('/auth/github/redirect', base);
                break;
            case 'linkedin':
                url = new URL('/auth/linkedin/redirect', base);
                break;
            default:
                throw new Error(`Invalid provider: ${provider}`);
        }
        if (redirect) {
            url.searchParams.set('r', redirect);
        }
        if (type === 'redirect') {
            window.location.href = url.toString();
            return null;
        }
        const ref = window.open(url.toString(), '_blank');
        return ref;
    }
}
//# sourceMappingURL=AuthSdk.js.map