import { eq } from 'drizzle-orm';
import { a as authServer } from './auth-server-BSz1rlv-.js';
import { d as db, u as userCard } from './index3-Cipag7JS.js';
import { c as cookieStrToObj } from './utils2-BNPuf_o4.js';
import { f as fakeCards } from './fakeCards-IUva2qU6.js';
import './index5-BOKyATXQ.js';
import 'nodemailer';
import 'drizzle-orm/libsql';
import 'drizzle-orm/sqlite-core';
import 'crypto';
import 'dotenv/config.js';
import 'arktype';

const BETTER_AUTH_SESSION_COOKIE = "better-auth.session_token";
const load = async ({ locals }) => {
  const user = locals.user;
  let wallet = [];
  if (user) {
    wallet = await db.select().from(userCard).where(eq(userCard.userId, user.id));
  }
  return { cards: fakeCards, wallet };
};
const actions = {
  async signout(event) {
    const authResponse = await authServer.api.signOut({
      headers: event.request.headers,
      asResponse: true
    });
    const setCookieHeader = authResponse.headers.get("set-cookie") ?? "";
    const cookiesObj = cookieStrToObj(setCookieHeader);
    event.cookies.delete(BETTER_AUTH_SESSION_COOKIE, { path: "/", ...cookiesObj });
    const data = await authResponse.json();
    return data;
  }
};

var _page_server = /*#__PURE__*/Object.freeze({
  __proto__: null,
  actions: actions,
  load: load
});

const index = 2;
let component_cache;
const component = async () => component_cache ??= (await import('./_page.svelte-CIZBI-vh.js')).default;
const server_id = "src/routes/+page.server.js";
const imports = ["_app/immutable/nodes/2.BILvN4pi.js","_app/immutable/chunks/cL9VaPgy.js","_app/immutable/chunks/C75YQU_W.js","_app/immutable/chunks/B4FYT0oR.js","_app/immutable/chunks/D-5ps19L.js","_app/immutable/chunks/Cz-4yBSw.js"];
const stylesheets = [];
const fonts = [];

export { component, fonts, imports, index, _page_server as server, server_id, stylesheets };
//# sourceMappingURL=2-CJ4C6rE2.js.map
