import { t as supabase } from "./client-TD7udZC7.mjs";
//#region node_modules/.nitro/vite/services/ssr/assets/jobs-DK-Pa4Ss.js
var slugify = (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
async function fetchPublishedJobs() {
	const { data, error } = await supabase.from("jobs").select("*").eq("is_published", true).order("posted_at", { ascending: false });
	if (error) throw error;
	return data ?? [];
}
async function fetchJobBySlug(slug) {
	const { data, error } = await supabase.from("jobs").select("*").eq("slug", slug).maybeSingle();
	if (error) throw error;
	return data ?? null;
}
async function fetchAllJobs() {
	const { data, error } = await supabase.from("jobs").select("*").order("created_at", { ascending: false });
	if (error) throw error;
	return data ?? [];
}
async function fetchApplications() {
	const { data, error } = await supabase.from("job_applications").select("*, jobs(title)").order("created_at", { ascending: false });
	if (error) throw error;
	return data ?? [];
}
async function isAdmin(userId) {
	const { data, error } = await supabase.from("user_roles").select("role").eq("user_id", userId).eq("role", "admin");
	if (error) return false;
	return (data ?? []).length > 0;
}
//#endregion
export { isAdmin as a, fetchPublishedJobs as i, fetchApplications as n, slugify as o, fetchJobBySlug as r, fetchAllJobs as t };
