<?php
require_once __DIR__.'/../../config.php';
require_once __DIR__ . '/../../engine/Kernel.php';
Kernel::handle(['auth' => false, 'public' => true]);
require_once __DIR__ . '/../../engine/Logger.php';
require_once __DIR__.'/../../engine/MerchantEngine.php';
$lat  = (float)($_GET['lat']??0);
$lng  = (float)($_GET['lng']??0);
$type = preg_replace('/[^a-z]/','',$_GET['type']??'');
if(!$lat||!$lng){http_response_code(400);die(json_encode(['error'=>'location_required']));}
$merchants = MerchantEngine::searchNearby($lat,$lng,$type);
echo json_encode(['ok'=>true,'data'=>$merchants], JSON_UNESCAPED_UNICODE);
