import { T as TSS_SERVER_FUNCTION, a as createServerFn } from "./server-CWcU6oWp.js";
import { z } from "zod";
import "node:async_hooks";
import "h3-v2";
import "@tanstack/router-core";
import "seroval";
import "@tanstack/history";
import "@tanstack/router-core/ssr/client";
import "@tanstack/router-core/ssr/server";
import "react";
import "@tanstack/react-router";
import "react/jsx-runtime";
import "@tanstack/react-router/ssr/server";
var createServerRpc = (serverFnMeta, splitImportFn) => {
  const url = "/_serverFn/" + serverFnMeta.id;
  return Object.assign(splitImportFn, {
    url,
    serverFnMeta,
    [TSS_SERVER_FUNCTION]: true
  });
};
const leadSchema = z.object({
  full_name: z.string().trim().min(1, "Required").max(120),
  phone: z.string().trim().min(4, "Required").max(40),
  email: z.string().trim().email("Invalid email").max(200),
  budget: z.string().trim().max(80).optional().or(z.literal("")),
  property_interest: z.string().trim().max(120).optional().or(z.literal("")),
  preferred_location: z.string().trim().max(120).optional().or(z.literal("")),
  message: z.string().trim().max(2e3).optional().or(z.literal("")),
  source_page: z.string().trim().max(120).optional().or(z.literal("")),
  // honeypot — must be empty
  company: z.string().max(0).optional().or(z.literal(""))
});
const submitLead_createServerFn_handler = createServerRpc({
  id: "e211e8c27eee0a1053129b7769a37cb2e31b3dc869a84a1c647eee19cfb57993",
  name: "submitLead",
  filename: "src/lib/leads.functions.ts"
}, (opts) => submitLead.__executeServer(opts));
const submitLead = createServerFn({
  method: "POST"
}).inputValidator((data) => leadSchema.parse(data)).handler(submitLead_createServerFn_handler, async ({
  data
}) => {
  const {
    supabaseAdmin
  } = await import("./client.server-D5ro3rAQ.js");
  const {
    error
  } = await supabaseAdmin.from("leads").insert({
    full_name: data.full_name,
    phone: data.phone,
    email: data.email,
    budget: data.budget || null,
    property_interest: data.property_interest || null,
    preferred_location: data.preferred_location || null,
    message: data.message || null,
    source_page: data.source_page || null
  });
  if (error) throw new Error(error.message);
  return {
    ok: true
  };
});
export {
  submitLead_createServerFn_handler
};
