<?php
declare(strict_types=1);
require_once __DIR__.'/../../../_runtime.php';
$config=require __DIR__.'/bootstrap.php';
try {
    $provider=preg_replace('/[^a-z]/','',strtolower((string)($_GET['provider']??''))); $intent=(($_GET['intent']??'login')==='register')?'register':'login';
    $url=(new \PpPhp\Generated\SocialAuth\SocialAuthManager($config))->begin($provider,$intent);
    \PpPhp\Core\Events::fire('global.auth.socialLoginStarted',['provider'=>$provider,'intent'=>$intent]); header('Location: '.$url); exit;
} catch (\Throwable $e) { $_SESSION['_flash']=['message'=>$e->getMessage(),'type'=>'danger']; header('Location: '.APP_BASE.'/generated/auth/login.php'); exit; }
