import { u as userCardSchema } from './validation-D8AX0Tpi.js';
import { d as db, u as userCard } from './index3-Cipag7JS.js';
import { f as fakeCards } from './fakeCards-IUva2qU6.js';
import { r as requireUserMiddleware, v as validateBodyMiddleware } from './middleware-DEO9L-XC.js';
import 'arktype';
import 'drizzle-orm/libsql';
import 'drizzle-orm/sqlite-core';
import 'drizzle-orm';
import 'crypto';
import 'dotenv/config.js';
import './index-wpIsICWW.js';
import './utils2-BNPuf_o4.js';

const load = async (event) => {
  requireUserMiddleware(event);
  let template = {};
  const templateId = event.url.searchParams.get("template");
  if (templateId) {
    const match = fakeCards.find((card) => {
      return card.id === templateId;
    });
    template = match;
  }
  return {
    template
  };
};
const actions = {
  async default(event) {
    const user = requireUserMiddleware(event);
    const body = await validateBodyMiddleware(userCardSchema, event);
    const [card] = await db.insert(userCard).values({
      nickname: body.nickname,
      openedAt: body.openedAt,
      bonusAmount: body.bonusAmount,
      bonusType: body.bonusType,
      bonusSpend: body.bonusSpend,
      bonusDeadline: body.bonusDeadline,
      annualFee: body.annualFee,
      userId: user.id
    }).returning();
    return card;
  }
};

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

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

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