diff --git a/.vercel/output/config.json b/.vercel/output/config.json new file mode 100644 index 0000000..3ce598e --- /dev/null +++ b/.vercel/output/config.json @@ -0,0 +1,19 @@ +{ + "version": 3, + "routes": [ + { + "src": "/_app/immutable/.+", + "headers": { + "cache-control": "public, immutable, max-age=31536000" + } + }, + { + "handle": "filesystem" + }, + { + "src": "/.*", + "dest": "/render" + } + ], + "overrides": {} +} \ No newline at end of file diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/chunks/Elements.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/chunks/Elements.js new file mode 100644 index 0000000..c8927df --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/chunks/Elements.js @@ -0,0 +1,70 @@ +import { c as create_ssr_component, a as setContext } from "./index2.js"; +import { r as register } from "./util.js"; +const Elements = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let appearance; + let { stripe } = $$props; + let { mode = void 0 } = $$props; + let { theme = "stripe" } = $$props; + let { variables = {} } = $$props; + let { rules = {} } = $$props; + let { labels = "above" } = $$props; + let { loader = "auto" } = $$props; + let { fonts = [] } = $$props; + let { locale = "auto" } = $$props; + let { currency = void 0 } = $$props; + let { amount = void 0 } = $$props; + let { clientSecret = void 0 } = $$props; + let { elements = null } = $$props; + if ($$props.stripe === void 0 && $$bindings.stripe && stripe !== void 0) + $$bindings.stripe(stripe); + if ($$props.mode === void 0 && $$bindings.mode && mode !== void 0) + $$bindings.mode(mode); + if ($$props.theme === void 0 && $$bindings.theme && theme !== void 0) + $$bindings.theme(theme); + if ($$props.variables === void 0 && $$bindings.variables && variables !== void 0) + $$bindings.variables(variables); + if ($$props.rules === void 0 && $$bindings.rules && rules !== void 0) + $$bindings.rules(rules); + if ($$props.labels === void 0 && $$bindings.labels && labels !== void 0) + $$bindings.labels(labels); + if ($$props.loader === void 0 && $$bindings.loader && loader !== void 0) + $$bindings.loader(loader); + if ($$props.fonts === void 0 && $$bindings.fonts && fonts !== void 0) + $$bindings.fonts(fonts); + if ($$props.locale === void 0 && $$bindings.locale && locale !== void 0) + $$bindings.locale(locale); + if ($$props.currency === void 0 && $$bindings.currency && currency !== void 0) + $$bindings.currency(currency); + if ($$props.amount === void 0 && $$bindings.amount && amount !== void 0) + $$bindings.amount(amount); + if ($$props.clientSecret === void 0 && $$bindings.clientSecret && clientSecret !== void 0) + $$bindings.clientSecret(clientSecret); + if ($$props.elements === void 0 && $$bindings.elements && elements !== void 0) + $$bindings.elements(elements); + appearance = { theme, variables, rules, labels }; + { + if (stripe && !elements) { + elements = stripe.elements({ + mode, + currency, + amount, + appearance, + clientSecret, + fonts, + loader, + locale + }); + register(stripe); + setContext("stripe", { stripe, elements }); + } + } + { + if (elements) { + elements.update({ appearance, locale }); + } + } + return `${stripe && elements ? `${slots.default ? slots.default({}) : ``}` : ``}`; +}); +export { + Elements as E +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/chunks/index.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/chunks/index.js new file mode 100644 index 0000000..a33876f --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/chunks/index.js @@ -0,0 +1,90 @@ +class HttpError { + /** + * @param {number} status + * @param {{message: string} extends App.Error ? (App.Error | string | undefined) : App.Error} body + */ + constructor(status, body) { + this.status = status; + if (typeof body === "string") { + this.body = { message: body }; + } else if (body) { + this.body = body; + } else { + this.body = { message: `Error: ${status}` }; + } + } + toString() { + return JSON.stringify(this.body); + } +} +class Redirect { + /** + * @param {300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308} status + * @param {string} location + */ + constructor(status, location) { + this.status = status; + this.location = location; + } +} +class ActionFailure { + /** + * @param {number} status + * @param {T} [data] + */ + constructor(status, data) { + this.status = status; + this.data = data; + } +} +function error(status, body) { + if (isNaN(status) || status < 400 || status > 599) { + throw new Error(`HTTP error status codes must be between 400 and 599 — ${status} is invalid`); + } + return new HttpError(status, body); +} +function redirect(status, location) { + if (isNaN(status) || status < 300 || status > 308) { + throw new Error("Invalid status code"); + } + return new Redirect(status, location.toString()); +} +function json(data, init) { + const body = JSON.stringify(data); + const headers = new Headers(init?.headers); + if (!headers.has("content-length")) { + headers.set("content-length", encoder.encode(body).byteLength.toString()); + } + if (!headers.has("content-type")) { + headers.set("content-type", "application/json"); + } + return new Response(body, { + ...init, + headers + }); +} +const encoder = new TextEncoder(); +function text(body, init) { + const headers = new Headers(init?.headers); + if (!headers.has("content-length")) { + const encoded = encoder.encode(body); + headers.set("content-length", encoded.byteLength.toString()); + return new Response(encoded, { + ...init, + headers + }); + } + return new Response(body, { + ...init, + headers + }); +} +export { + ActionFailure as A, + HttpError as H, + Redirect as R, + error as e, + json as j, + redirect as r, + text as t +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/chunks/index2.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/chunks/index2.js new file mode 100644 index 0000000..feda5e3 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/chunks/index2.js @@ -0,0 +1,143 @@ +function noop() { +} +function run(fn) { + return fn(); +} +function blank_object() { + return /* @__PURE__ */ Object.create(null); +} +function run_all(fns) { + fns.forEach(run); +} +function safe_not_equal(a, b) { + return a != a ? b == b : a !== b || (a && typeof a === "object" || typeof a === "function"); +} +function subscribe(store, ...callbacks) { + if (store == null) { + return noop; + } + const unsub = store.subscribe(...callbacks); + return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub; +} +function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) { + const e = document.createEvent("CustomEvent"); + e.initCustomEvent(type, bubbles, cancelable, detail); + return e; +} +let current_component; +function set_current_component(component) { + current_component = component; +} +function get_current_component() { + if (!current_component) + throw new Error("Function called outside component initialization"); + return current_component; +} +function onDestroy(fn) { + get_current_component().$$.on_destroy.push(fn); +} +function createEventDispatcher() { + const component = get_current_component(); + return (type, detail, { cancelable = false } = {}) => { + const callbacks = component.$$.callbacks[type]; + if (callbacks) { + const event = custom_event(type, detail, { cancelable }); + callbacks.slice().forEach((fn) => { + fn.call(component, event); + }); + return !event.defaultPrevented; + } + return true; + }; +} +function setContext(key, context) { + get_current_component().$$.context.set(key, context); + return context; +} +function getContext(key) { + return get_current_component().$$.context.get(key); +} +const ATTR_REGEX = /[&"]/g; +const CONTENT_REGEX = /[&<]/g; +function escape(value, is_attr = false) { + const str = String(value); + const pattern = is_attr ? ATTR_REGEX : CONTENT_REGEX; + pattern.lastIndex = 0; + let escaped = ""; + let last = 0; + while (pattern.test(str)) { + const i = pattern.lastIndex - 1; + const ch = str[i]; + escaped += str.substring(last, i) + (ch === "&" ? "&" : ch === '"' ? """ : "<"); + last = i + 1; + } + return escaped + str.substring(last); +} +const missing_component = { + $$render: () => "" +}; +function validate_component(component, name) { + if (!component || !component.$$render) { + if (name === "svelte:component") + name += " this={...}"; + throw new Error(`<${name}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules. Otherwise you may need to fix a <${name}>.`); + } + return component; +} +let on_destroy; +function create_ssr_component(fn) { + function $$render(result, props, bindings, slots, context) { + const parent_component = current_component; + const $$ = { + on_destroy, + context: new Map(context || (parent_component ? parent_component.$$.context : [])), + // these will be immediately discarded + on_mount: [], + before_update: [], + after_update: [], + callbacks: blank_object() + }; + set_current_component({ $$ }); + const html = fn(result, props, bindings, slots); + set_current_component(parent_component); + return html; + } + return { + render: (props = {}, { $$slots = {}, context = /* @__PURE__ */ new Map() } = {}) => { + on_destroy = []; + const result = { title: "", head: "", css: /* @__PURE__ */ new Set() }; + const html = $$render(result, props, {}, $$slots, context); + run_all(on_destroy); + return { + html, + css: { + code: Array.from(result.css).map((css) => css.code).join("\n"), + map: null + // TODO + }, + head: result.title + result.head + }; + }, + $$render + }; +} +function add_attribute(name, value, boolean) { + if (value == null || boolean && !value) + return ""; + const assignment = boolean && value === true ? "" : `="${escape(value, true)}"`; + return ` ${name}${assignment}`; +} +export { + setContext as a, + subscribe as b, + create_ssr_component as c, + add_attribute as d, + escape as e, + createEventDispatcher as f, + getContext as g, + missing_component as m, + noop as n, + onDestroy as o, + safe_not_equal as s, + validate_component as v +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/chunks/internal.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/chunks/internal.js new file mode 100644 index 0000000..8c4d967 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/chunks/internal.js @@ -0,0 +1,200 @@ +import { c as create_ssr_component, a as setContext, v as validate_component, m as missing_component } from "./index2.js"; +let base = ""; +let assets = base; +const initial = { base, assets }; +function reset() { + base = initial.base; + assets = initial.assets; +} +function set_assets(path) { + assets = initial.assets = path; +} +let public_env = {}; +function set_private_env(environment) { +} +function set_public_env(environment) { + public_env = environment; +} +function afterUpdate() { +} +function set_building() { +} +const Root = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let { stores } = $$props; + let { page } = $$props; + let { constructors } = $$props; + let { components = [] } = $$props; + let { form } = $$props; + let { data_0 = null } = $$props; + let { data_1 = null } = $$props; + { + setContext("__svelte__", stores); + } + afterUpdate(stores.page.notify); + if ($$props.stores === void 0 && $$bindings.stores && stores !== void 0) + $$bindings.stores(stores); + if ($$props.page === void 0 && $$bindings.page && page !== void 0) + $$bindings.page(page); + if ($$props.constructors === void 0 && $$bindings.constructors && constructors !== void 0) + $$bindings.constructors(constructors); + if ($$props.components === void 0 && $$bindings.components && components !== void 0) + $$bindings.components(components); + if ($$props.form === void 0 && $$bindings.form && form !== void 0) + $$bindings.form(form); + if ($$props.data_0 === void 0 && $$bindings.data_0 && data_0 !== void 0) + $$bindings.data_0(data_0); + if ($$props.data_1 === void 0 && $$bindings.data_1 && data_1 !== void 0) + $$bindings.data_1(data_1); + let $$settled; + let $$rendered; + do { + $$settled = true; + { + stores.page.set(page); + } + $$rendered = ` + + +${constructors[1] ? `${validate_component(constructors[0] || missing_component, "svelte:component").$$render( + $$result, + { data: data_0, this: components[0] }, + { + this: ($$value) => { + components[0] = $$value; + $$settled = false; + } + }, + { + default: () => { + return `${validate_component(constructors[1] || missing_component, "svelte:component").$$render( + $$result, + { data: data_1, form, this: components[1] }, + { + this: ($$value) => { + components[1] = $$value; + $$settled = false; + } + }, + {} + )}`; + } + } + )}` : `${validate_component(constructors[0] || missing_component, "svelte:component").$$render( + $$result, + { data: data_0, form, this: components[0] }, + { + this: ($$value) => { + components[0] = $$value; + $$settled = false; + } + }, + {} + )}`} + +${``}`; + } while (!$$settled); + return $$rendered; +}); +const options = { + app_template_contains_nonce: false, + csp: { "mode": "auto", "directives": { "upgrade-insecure-requests": false, "block-all-mixed-content": false }, "reportOnly": { "upgrade-insecure-requests": false, "block-all-mixed-content": false } }, + csrf_check_origin: true, + track_server_fetches: false, + embedded: false, + env_public_prefix: "PUBLIC_", + env_private_prefix: "", + hooks: null, + // added lazily, via `get_hooks` + preload_strategy: "modulepreload", + root: Root, + service_worker: false, + templates: { + app: ({ head, body, assets: assets2, nonce, env }) => '\n\n \n \n \n \n \n \n \n ' + head + '\n \n \n
' + body + "
\n \n\n", + error: ({ status, message }) => '\n\n \n \n ' + message + ` + + + + +
+ ` + status + '\n
\n

' + message + "

\n
\n
\n \n\n" + }, + version_hash: "1130dfg" +}; +function get_hooks() { + return {}; +} +export { + assets as a, + base as b, + set_public_env as c, + set_assets as d, + set_building as e, + get_hooks as g, + options as o, + public_env as p, + reset as r, + set_private_env as s +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/chunks/private.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/chunks/private.js new file mode 100644 index 0000000..e9a4cdf --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/chunks/private.js @@ -0,0 +1,10 @@ +const SECRET_STRIPE_KEY_JP = ""; +const STRIPE_WEBHOOK_SECRET = ""; +const DOMAIN = "https://localhost:5173"; +const SECRET_STRIPE_KEY = "sk_test_51L0t1EHfKEQGgXe5Kwp2QdBU8W3ATIv3fIjc2VghMKbalShQgvz9WsVtO1ECz9TlzUFURXDePBI8YxYaOtLfCsYk00RDs9vrZt"; +export { + DOMAIN as D, + SECRET_STRIPE_KEY as S, + STRIPE_WEBHOOK_SECRET as a, + SECRET_STRIPE_KEY_JP as b +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/chunks/util.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/chunks/util.js new file mode 100644 index 0000000..38f78ed --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/chunks/util.js @@ -0,0 +1,12 @@ +const isServer = typeof window === "undefined"; +function register(stripe) { + if (!isServer) { + return stripe.registerAppInfo({ + name: "svelte-stripe-js", + url: "https://svelte-stripe-js.vercel.app" + }); + } +} +export { + register as r +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/afterpay-clearpay/payment-intent/_server.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/afterpay-clearpay/payment-intent/_server.js new file mode 100644 index 0000000..3c249ee --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/afterpay-clearpay/payment-intent/_server.js @@ -0,0 +1,17 @@ +import { j as json } from "../../../../../chunks/index.js"; +import Stripe from "stripe"; +import { S as SECRET_STRIPE_KEY } from "../../../../../chunks/private.js"; +const stripe = new Stripe(SECRET_STRIPE_KEY); +async function POST() { + const paymentIntent = await stripe.paymentIntents.create({ + amount: 2e3, + currency: "USD", + payment_method_types: ["afterpay_clearpay"] + }); + return json({ + clientSecret: paymentIntent.client_secret + }); +} +export { + POST +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/afterpay-clearpay/return/_server.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/afterpay-clearpay/return/_server.js new file mode 100644 index 0000000..496717a --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/afterpay-clearpay/return/_server.js @@ -0,0 +1,19 @@ +import { r as redirect } from "../../../../../chunks/index.js"; +import Stripe from "stripe"; +import { S as SECRET_STRIPE_KEY } from "../../../../../chunks/private.js"; +const stripe = new Stripe(SECRET_STRIPE_KEY); +async function GET(req) { + const { searchParams } = req.url; + const intentId = searchParams.get("payment_intent"); + const clientSecret = searchParams.get("payment_intent_client_secret"); + const paymentIntent = await stripe.paymentIntents.retrieve(intentId); + if (paymentIntent.client_secret !== clientSecret) + throw new Error("Client secret mismatch"); + if (paymentIntent.status === "succeeded") { + throw redirect(302, "/examples/afterpay-clearpay/thanks"); + } + throw redirect(302, "/examples/afterpay-clearpay?error=true"); +} +export { + GET +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/alipay/payment-intent/_server.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/alipay/payment-intent/_server.js new file mode 100644 index 0000000..9112010 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/alipay/payment-intent/_server.js @@ -0,0 +1,19 @@ +import { j as json } from "../../../../../chunks/index.js"; +import Stripe from "stripe"; +import { S as SECRET_STRIPE_KEY } from "../../../../../chunks/private.js"; +const stripe = new Stripe(SECRET_STRIPE_KEY); +async function POST({ request }) { + const { email } = await request.json(); + const paymentIntent = await stripe.paymentIntents.create({ + amount: 2e3, + currency: "cny", + payment_method_types: ["alipay"], + receipt_email: email + }); + return json({ + clientSecret: paymentIntent.client_secret + }); +} +export { + POST +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/alipay/return/_server.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/alipay/return/_server.js new file mode 100644 index 0000000..c05883e --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/alipay/return/_server.js @@ -0,0 +1,19 @@ +import { r as redirect } from "../../../../../chunks/index.js"; +import Stripe from "stripe"; +import { S as SECRET_STRIPE_KEY } from "../../../../../chunks/private.js"; +const stripe = new Stripe(SECRET_STRIPE_KEY); +async function GET(req) { + const { searchParams } = req.url; + const intentId = searchParams.get("payment_intent"); + const clientSecret = searchParams.get("payment_intent_client_secret"); + const paymentIntent = await stripe.paymentIntents.retrieve(intentId); + if (paymentIntent.client_secret !== clientSecret) + throw new Error("Client secret mismatch"); + if (paymentIntent.status === "succeeded") { + throw redirect(302, "/examples/alipay/thanks"); + } + throw redirect(302, "/examples/alipay?error=true"); +} +export { + GET +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/credit-card/payment-intent/_server.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/credit-card/payment-intent/_server.js new file mode 100644 index 0000000..f0b97a1 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/credit-card/payment-intent/_server.js @@ -0,0 +1,17 @@ +import { j as json } from "../../../../../chunks/index.js"; +import Stripe from "stripe"; +import { S as SECRET_STRIPE_KEY } from "../../../../../chunks/private.js"; +const stripe = new Stripe(SECRET_STRIPE_KEY); +async function POST() { + const paymentIntent = await stripe.paymentIntents.create({ + amount: 2e3, + currency: "usd", + payment_method_types: ["card"] + }); + return json({ + clientSecret: paymentIntent.client_secret + }); +} +export { + POST +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/credit-card/webhooks/_server.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/credit-card/webhooks/_server.js new file mode 100644 index 0000000..ca186f8 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/credit-card/webhooks/_server.js @@ -0,0 +1,22 @@ +import Stripe from "stripe"; +import { S as SECRET_STRIPE_KEY, a as STRIPE_WEBHOOK_SECRET } from "../../../../../chunks/private.js"; +const stripe = new Stripe(SECRET_STRIPE_KEY); +async function POST({ request }) { + const body = await request.text(); + const signature = request.headers.get("stripe-signature"); + let event; + try { + event = stripe.webhooks.constructEvent(body, signature, STRIPE_WEBHOOK_SECRET); + } catch (err) { + console.warn("⚠️ Webhook signature verification failed.", err.message); + return new Response(void 0, { status: 400 }); + } + if (event.type == "charge.succeeded") { + const charge = event.data.object; + console.log(`✅ Charge succeeded ${charge.id}`); + } + return new Response(void 0); +} +export { + POST +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/express-checkout/payment-intent/_server.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/express-checkout/payment-intent/_server.js new file mode 100644 index 0000000..e3e498d --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/express-checkout/payment-intent/_server.js @@ -0,0 +1,19 @@ +import { j as json } from "../../../../../chunks/index.js"; +import Stripe from "stripe"; +import { S as SECRET_STRIPE_KEY } from "../../../../../chunks/private.js"; +const stripe = new Stripe(SECRET_STRIPE_KEY); +async function POST() { + const paymentIntent = await stripe.paymentIntents.create({ + amount: 1099, + currency: "usd", + automatic_payment_methods: { + enabled: true + } + }); + return json({ + clientSecret: paymentIntent.client_secret + }); +} +export { + POST +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/ideal/payment-intent/_server.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/ideal/payment-intent/_server.js new file mode 100644 index 0000000..80f20f0 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/ideal/payment-intent/_server.js @@ -0,0 +1,18 @@ +import { j as json } from "../../../../../chunks/index.js"; +import Stripe from "stripe"; +import { S as SECRET_STRIPE_KEY } from "../../../../../chunks/private.js"; +const stripe = new Stripe(SECRET_STRIPE_KEY); +async function POST({ request }) { + const body = await request.json(); + const paymentIntent = await stripe.paymentIntents.create({ + amount: body.amount, + currency: "eur", + payment_method_types: ["ideal"] + }); + return json({ + clientSecret: paymentIntent.client_secret + }); +} +export { + POST +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/ideal/return/_server.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/ideal/return/_server.js new file mode 100644 index 0000000..a70e833 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/ideal/return/_server.js @@ -0,0 +1,19 @@ +import { r as redirect } from "../../../../../chunks/index.js"; +import Stripe from "stripe"; +import { S as SECRET_STRIPE_KEY } from "../../../../../chunks/private.js"; +const stripe = new Stripe(SECRET_STRIPE_KEY); +async function GET(req) { + const { searchParams } = req.url; + const intentId = searchParams.get("payment_intent"); + const clientSecret = searchParams.get("payment_intent_client_secret"); + const paymentIntent = await stripe.paymentIntents.retrieve(intentId); + if (paymentIntent.client_secret !== clientSecret) + throw new Error("Client secret mismatch"); + if (paymentIntent.status === "succeeded") { + throw redirect(302, "/examples/ideal/thanks"); + } + throw redirect(302, "/examples/ideal?error=true"); +} +export { + GET +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/klarna/payment-intent/_server.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/klarna/payment-intent/_server.js new file mode 100644 index 0000000..f12061a --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/klarna/payment-intent/_server.js @@ -0,0 +1,17 @@ +import { j as json } from "../../../../../chunks/index.js"; +import Stripe from "stripe"; +import { S as SECRET_STRIPE_KEY } from "../../../../../chunks/private.js"; +const stripe = new Stripe(SECRET_STRIPE_KEY); +async function POST() { + const paymentIntent = await stripe.paymentIntents.create({ + amount: 2e3, + currency: "USD", + payment_method_types: ["klarna"] + }); + return json({ + clientSecret: paymentIntent.client_secret + }); +} +export { + POST +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/klarna/return/_server.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/klarna/return/_server.js new file mode 100644 index 0000000..72eba3f --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/klarna/return/_server.js @@ -0,0 +1,19 @@ +import { r as redirect } from "../../../../../chunks/index.js"; +import Stripe from "stripe"; +import { S as SECRET_STRIPE_KEY } from "../../../../../chunks/private.js"; +const stripe = new Stripe(SECRET_STRIPE_KEY); +async function GET(req) { + const { searchParams } = req.url; + const intentId = searchParams.get("payment_intent"); + const clientSecret = searchParams.get("payment_intent_client_secret"); + const paymentIntent = await stripe.paymentIntents.retrieve(intentId); + if (paymentIntent.client_secret !== clientSecret) + throw new Error("Client secret mismatch"); + if (paymentIntent.status === "succeeded") { + throw redirect(302, "/examples/klarna/thanks"); + } + throw redirect(302, "/examples/klarna?error=true"); +} +export { + GET +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/konbini/payment-intent/_server.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/konbini/payment-intent/_server.js new file mode 100644 index 0000000..3f481b7 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/konbini/payment-intent/_server.js @@ -0,0 +1,23 @@ +import { j as json } from "../../../../../chunks/index.js"; +import Stripe from "stripe"; +import { b as SECRET_STRIPE_KEY_JP } from "../../../../../chunks/private.js"; +const stripe = new Stripe(SECRET_STRIPE_KEY_JP); +async function POST() { + const paymentIntent = await stripe.paymentIntents.create({ + amount: 2e3, + currency: "jpy", + payment_method_types: ["konbini"], + payment_method_options: { + konbini: { + product_description: "Tシャツ", + expires_after_days: 3 + } + } + }); + return json({ + clientSecret: paymentIntent.client_secret + }); +} +export { + POST +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/payment-element/payment-intent/_server.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/payment-element/payment-intent/_server.js new file mode 100644 index 0000000..a8e99f9 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/payment-element/payment-intent/_server.js @@ -0,0 +1,19 @@ +import { j as json } from "../../../../../chunks/index.js"; +import Stripe from "stripe"; +import { S as SECRET_STRIPE_KEY } from "../../../../../chunks/private.js"; +const stripe = new Stripe(SECRET_STRIPE_KEY); +async function POST() { + const paymentIntent = await stripe.paymentIntents.create({ + amount: 2e3, + currency: "usd", + automatic_payment_methods: { + enabled: true + } + }); + return json({ + clientSecret: paymentIntent.client_secret + }); +} +export { + POST +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/payment-request/payment-intent/_server.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/payment-request/payment-intent/_server.js new file mode 100644 index 0000000..f0b97a1 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/payment-request/payment-intent/_server.js @@ -0,0 +1,17 @@ +import { j as json } from "../../../../../chunks/index.js"; +import Stripe from "stripe"; +import { S as SECRET_STRIPE_KEY } from "../../../../../chunks/private.js"; +const stripe = new Stripe(SECRET_STRIPE_KEY); +async function POST() { + const paymentIntent = await stripe.paymentIntents.create({ + amount: 2e3, + currency: "usd", + payment_method_types: ["card"] + }); + return json({ + clientSecret: paymentIntent.client_secret + }); +} +export { + POST +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/sepa/payment-intent/_server.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/sepa/payment-intent/_server.js new file mode 100644 index 0000000..fef06e7 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/sepa/payment-intent/_server.js @@ -0,0 +1,18 @@ +import { j as json } from "../../../../../chunks/index.js"; +import Stripe from "stripe"; +import { S as SECRET_STRIPE_KEY } from "../../../../../chunks/private.js"; +const stripe = new Stripe(SECRET_STRIPE_KEY); +async function POST({ request }) { + const body = await request.json(); + const paymentIntent = await stripe.paymentIntents.create({ + amount: body.amount, + currency: "eur", + payment_method_types: ["sepa_debit"] + }); + return json({ + clientSecret: paymentIntent.client_secret + }); +} +export { + POST +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/sofort/payment-intent/_server.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/sofort/payment-intent/_server.js new file mode 100644 index 0000000..d702382 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/sofort/payment-intent/_server.js @@ -0,0 +1,17 @@ +import { j as json } from "../../../../../chunks/index.js"; +import Stripe from "stripe"; +import { S as SECRET_STRIPE_KEY } from "../../../../../chunks/private.js"; +const stripe = new Stripe(SECRET_STRIPE_KEY); +async function POST() { + const paymentIntent = await stripe.paymentIntents.create({ + amount: 2e3, + currency: "EUR", + payment_method_types: ["sofort"] + }); + return json({ + clientSecret: paymentIntent.client_secret + }); +} +export { + POST +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/sofort/return/_server.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/sofort/return/_server.js new file mode 100644 index 0000000..4bd342a --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/sofort/return/_server.js @@ -0,0 +1,19 @@ +import { r as redirect } from "../../../../../chunks/index.js"; +import Stripe from "stripe"; +import { S as SECRET_STRIPE_KEY } from "../../../../../chunks/private.js"; +const stripe = new Stripe(SECRET_STRIPE_KEY); +async function GET(req) { + const { searchParams } = req.url; + const intentId = searchParams.get("payment_intent"); + const clientSecret = searchParams.get("payment_intent_client_secret"); + const paymentIntent = await stripe.paymentIntents.retrieve(intentId); + if (paymentIntent.client_secret !== clientSecret) + throw new Error("Client secret mismatch"); + if (paymentIntent.status === "processing") { + throw redirect(302, "/examples/sofort/thanks"); + } + throw redirect(302, "/examples/sofort?error=true"); +} +export { + GET +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/wechat-pay/payment-intent/_server.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/wechat-pay/payment-intent/_server.js new file mode 100644 index 0000000..8f13a10 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/endpoints/examples/wechat-pay/payment-intent/_server.js @@ -0,0 +1,24 @@ +import { j as json } from "../../../../../chunks/index.js"; +import Stripe from "stripe"; +import { S as SECRET_STRIPE_KEY } from "../../../../../chunks/private.js"; +const stripe = new Stripe(SECRET_STRIPE_KEY); +async function POST({ request }) { + const { email } = await request.json(); + const paymentIntent = await stripe.paymentIntents.create({ + amount: 2e3, + currency: "cny", + payment_method_types: ["wechat_pay"], + payment_method_options: { + wechat_pay: { + client: "web" + } + }, + receipt_email: email + }); + return json({ + clientSecret: paymentIntent.client_secret + }); +} +export { + POST +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/fallbacks/error.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/fallbacks/error.svelte.js new file mode 100644 index 0000000..d271ba4 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/fallbacks/error.svelte.js @@ -0,0 +1,32 @@ +import { g as getContext, c as create_ssr_component, b as subscribe, e as escape } from "../../chunks/index2.js"; +const getStores = () => { + const stores = getContext("__svelte__"); + return { + /** @type {typeof page} */ + page: { + subscribe: stores.page.subscribe + }, + /** @type {typeof navigating} */ + navigating: { + subscribe: stores.navigating.subscribe + }, + /** @type {typeof updated} */ + updated: stores.updated + }; +}; +const page = { + subscribe(fn) { + const store = getStores().page; + return store.subscribe(fn); + } +}; +const Error$1 = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let $page, $$unsubscribe_page; + $$unsubscribe_page = subscribe(page, (value) => $page = value); + $$unsubscribe_page(); + return `

${escape($page.status)}

+

${escape($page.error?.message)}

`; +}); +export { + Error$1 as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/_layout.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/_layout.svelte.js new file mode 100644 index 0000000..c859560 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/_layout.svelte.js @@ -0,0 +1,39 @@ +import { c as create_ssr_component, v as validate_component } from "../../chunks/index2.js"; +const prismTheme = ""; +const app = ""; +const GithubBadge_svelte_svelte_type_style_lang = ""; +const css = { + code: ".github-corner.svelte-9fn96p:hover .octo-arm.svelte-9fn96p{animation:svelte-9fn96p-octocat-wave 560ms ease-in-out}@keyframes svelte-9fn96p-octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media(max-width: 500px){.github-corner.svelte-9fn96p:hover .octo-arm.svelte-9fn96p{animation:none}.github-corner.svelte-9fn96p .octo-arm.svelte-9fn96p{animation:svelte-9fn96p-octocat-wave 560ms ease-in-out}}", + map: null +}; +const GithubBadge = create_ssr_component(($$result, $$props, $$bindings, slots) => { + $$result.css.add(css); + return ` +`; +}); +const Layout = create_ssr_component(($$result, $$props, $$bindings, slots) => { + return `${validate_component(GithubBadge, "GithubBadge").$$render($$result, {}, {}, {})} + +
+ +
${slots.default ? slots.default({}) : ``}
`; +}); +export { + Layout as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/_page.md.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/_page.md.js new file mode 100644 index 0000000..8cde5cd --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/_page.md.js @@ -0,0 +1,303 @@ +import { c as create_ssr_component } from "../../chunks/index2.js"; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + return `${$$result.head += `${$$result.title = `svelte-stripe`, ""}`, ""} + + +

svelte-stripe

+

Everything you need to add Stripe Elements to your Svelte & SvelteKit projects.

+

Links: +npm +github +changelog +license

+

Installation

+

To configure your project, add these 2 packages:

+
${`pnpm install -D stripe svelte-stripe`}
+ +

Docs

+

Set up Stripe

+

Add your private and public keys to your environment:

+
${`PUBLIC_STRIPE_KEY=pk_test_...
+SECRET_STRIPE_KEY=sk_test_...`}
+

In your payment page, initialize Stripe and add a <Elements> component:

+
${`<script>
+  import { loadStripe } from '@stripe/stripe-js'
+  import { Elements } from 'svelte-stripe'
+  import { onMount } from 'svelte'
+  import { PUBLIC_STRIPE_KEY } from '$env/static/public'
+
+  let stripe = null
+
+  onMount(async () => {
+    stripe = await loadStripe(PUBLIC_STRIPE_KEY)
+  })
+</script>
+
+<Elements {stripe}>
+  <!-- this is where your Stripe components go -->
+</Elements>`}
+

Creating a payment intent

+

Before making a charge, Stripe should be notified by creating a payment intent. It’s a way to tell Stripe what amount to capture and to attach any relavent metadata, for example, the products they are buying. This must happen server-side to avoid anyone tampering with the amount.

+

Let’s add an endpoint src/routes/create-payment-intent/+server.js to create the “payment intent”:

+
${`import Stripe from 'stripe'
+import { SECRET_STRIPE_KEY } from '$env/static/private'
+
+// initialize Stripe
+const stripe = new Stripe(SECRET_STRIPE_KEY)
+
+// handle POST /create-payment-intent
+export async function POST() {
+  // create the payment intent
+  const paymentIntent = await stripe.paymentIntents.create({
+    amount: 2000,
+    // note, for some EU-only payment methods it must be EUR
+    currency: 'usd',
+    // specify what payment methods are allowed
+    // can be card, sepa_debit, ideal, etc...
+    payment_method_types: ['card']
+  })
+
+  // return the clientSecret to the client
+  return {
+    body: {
+      clientSecret: paymentIntent.client_secret
+    }
+  }
+}`}
+

Accepting payments

+

There are several types of payment you can accept:

+

Payment Element

+

An all-in-one component that supports credit cards, SEPA, GooglePay and ApplePay.

+

To use it, drop a <PaymentElement> component in your form:

+
${`<form on:submit|preventDefault="{submit}">
+  <Elements {stripe} {clientSecret} bind:elements>
+    <PaymentElement options={...} />
+  </Elements>
+
+  <button>Pay</button>
+</form>`}
+

Then when creating the payment intent, enable the automatic_payment_methods: option:

+
${`const paymentIntent = await stripe.paymentIntents.create({
+  amount: 2000,
+  currency: 'eur',
+  automatic_payment_methods: {
+    enabled: true
+  }
+})`}
+

Once the form is submitted, call stripe.confirmPayment()

+
${`const result = await stripe.confirmPayment({
+  elements,
+  // specify redirect: 'if_required' or a `return_url`
+  redirect: 'if_required'
+})`}
+

code +demo

+ +

With Link, customer’s don’t have to re-enter payment and address details for each purchase. Their details are retreived based on their e-mail address.

+

Once they enter their e-mail they receive an SMS code to verify their identity.

+

It works in conjuction with <PaymentElement>:

+
${`<form on:submit|preventDefault="{submit}">
+  <Elements {stripe} {clientSecret} bind:elements>
+    <LinkAuthenticationElement />
+    <PaymentElement />
+  </Elements>
+
+  <button>Pay</button>
+</form>`}
+

code +demo

+

Credit Cards

+

These use the <CardNumber>, <CardExpiry> and <CardCvc> components:

+
${`<Elements {stripe}>
+  <form on:submit|preventDefault="{submit}">
+    <CardNumber bind:element="{cardElement}" />
+    <CardExpiry />
+    <CardCvc />
+
+    <button>Pay</button>
+  </form>
+</Elements>`}
+

When the form submits, pass the cardElement to stripe.confirmCardPayment(), ie:

+
${`const result = await stripe
+  .confirmCardPayment(clientSecret, {
+    payment_method: {
+      card: cardElement,
+      billing_details: {
+        ...
+      }
+    }
+  })`}
+

code +demo

+

GooglePay & ApplePay

+

To display a GooglePay or ApplePay button, use the <PaymentRequestButton/>.

+
${`<Elements {stripe}>
+  <PaymentRequestButton {paymentRequest} on:paymentmethod="{pay}" />
+</Elements>`}
+

It requires that you pass metadata using the paymentRequest prop:

+
${`// declare payment metadata (amounts must match payment intent)
+const paymentRequest = {
+  country: 'US',
+  currency: 'usd',
+  total: { label: 'Demo total', amount: 1099 },
+  requestPayerName: true,
+  requestPayerEmail: true
+}`}
+

And define an event handler for the on:paymentmethod event:

+
${`async function pay(e) {
+  const paymentMethod = e.detail.paymentMethod
+
+  let result = await stripe.confirmCardPayment(clientSecret, {
+    payment_method: paymentMethod.id
+  })
+
+  if (result.error) {
+    // mark failed
+    e.detail.complete('fail')
+
+    // payment failed, notify user
+    error = result.error
+  } else {
+    // mark succeeded
+    e.detail.complete('success')
+
+    // payment succeeded, redirect to "thank you" page
+    goto('/thanks')
+  }
+}`}
+

code +demo

+

SEPA

+

To process SEPA debits, use the <Iban> component:

+
${`<Elements {stripe}>
+  <form on:submit|preventDefault="{submit}">
+    <input name="name" bind:value="{name}" placeholder="Name" />
+
+    <!-- customize the list of countries, or use "SEPA" to allow all supported countries -->
+    <Iban supportedCountries={['SEPA']} bind:element={ibanElement}/>
+
+    <button>Pay</button>
+  </form>
+</Elements>`}
+

To process the payment use stripe.confirmSepaDebitPayment():

+
${`const result = await stripe.confirmSepaDebitPayment(clientSecret, {
+  payment_method: {
+    sepa_debit: ibanElement,
+    billing_details: {
+      name,
+      email
+    }
+  }
+})`}
+

code +demo

+

iDEAL

+

To accept iDEAL payments, use the <Ideal> component:

+
${`<Elements {stripe}>
+  <form on:submit|preventDefault="{submit}">
+    <input name="name" bind:value="{name}" placeholder="Name" />
+    <input name="email" bind:value="{email}" placeholder="E-mail" type="email" />
+    <Ideal bind:element="{idealElement}" />
+
+    <button>Pay</button>
+  </form>
+</Elements>`}
+

To complete the payment call stripe.confirmIdealPayment(), and make sure the pass a return_url:

+
${`const result = await stripe.confirmIdealPayment(clientSecret, {
+  payment_method: {
+    ideal: idealElement,
+    billing_details: {
+      name,
+      email
+    }
+  },
+  return_url: `${window.location.origin}/return`
+})`}
+

code +demo

+

Webhooks

+

After the payment succeeds or fails, Stripe will send out a webhook, which can be used to provision or fulfill the purchase.

+

The webhook payload contains a signature that should be verified to ensure the data originated from Stripe.

+

Here’s an example of handling a charge.succeeded webhook with SvelteKit:

+
${`// in src/routes/stripe/webhooks/+server.js
+import Stripe from 'stripe'
+import { error, json } from '@sveltejs/kit'
+import { env } from '$env/dynamic/private'
+
+// init api client
+const stripe = new Stripe(env.SECRET_STRIPE_KEY)
+
+// endpoint to handle incoming webhooks
+export async function POST({ request }) {
+  // extract body
+  const body = await request.text()
+
+  // get the signature from the header
+  const signature = request.headers.get('stripe-signature')
+
+  // var to hold event data
+  let event
+
+  // verify it
+  try {
+    event = stripe.webhooks.constructEvent(body, signature, env.STRIPE_WEBHOOK_SECRET)
+  } catch (err) {
+    // signature is invalid!
+    console.warn('⚠️  Webhook signature verification failed.', err.message)
+
+    // return, because it's a bad request
+    throw error(400, 'Invalid request')
+  }
+
+  // signature has been verified, so we can process events
+  // full list of events: https://stripe.com/docs/api/events/list
+  if (event.type == 'charge.succeeded') {
+    // get data object
+    const charge = event.data.object
+
+    // TODO: fulfill the order here
+    console.log(`✅ Charge succeeded ${charge.id}`)
+  }
+
+  // return a 200 with an empty JSON response
+  return json()
+}`}
+

code

+

In development mode, webhooks can be routed to your dev machine using Stripe’s CLI. Example:

+
${`stripe listen --forward-to localhost:5173/stripe/webhooks`}
+

For more information on webhooks, see Stripe’s Webhook Docs.

+

Styling

+

Components can be styled by setting attributes on the <Elements/> container.

+
${`<Elements
+  theme="flat"
+  labels="floating"
+  variables={{ colorPrimary: 'pink' }}
+  rules={...}
+  />`}
+

See appearance docs for more examples.

+

Examples

+

All demos are running in test-mode, any of Stripe’s test card numbers will work.

+ +

Sponsors

+

This project is made possible by:

+Stripe's logo`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/afterpay-clearpay/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/afterpay-clearpay/_page.svelte.js new file mode 100644 index 0000000..7201c79 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/afterpay-clearpay/_page.svelte.js @@ -0,0 +1,118 @@ +import { c as create_ssr_component, e as escape, d as add_attribute, v as validate_component } from "../../../../chunks/index2.js"; +import "@stripe/stripe-js"; +const Address_svelte_svelte_type_style_lang = ""; +const css$1 = { + code: "fieldset.svelte-13dsafx{display:flex;flex-direction:column;gap:1rem;border:2px solid var(--link-color);-moz-border-radius:8px;-webkit-border-radius:8px;border-radius:8px;padding:3rem;margin-bottom:2rem}", + map: null +}; +const Address = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let { legend } = $$props; + let { address } = $$props; + if ($$props.legend === void 0 && $$bindings.legend && legend !== void 0) + $$bindings.legend(legend); + if ($$props.address === void 0 && $$bindings.address && address !== void 0) + $$bindings.address(address); + $$result.css.add(css$1); + return `
${escape(legend)} + + ${slots.default ? slots.default({}) : ``} + + + + + + + + + + + + + + + + + + +
`; +}); +const _page_svelte_svelte_type_style_lang = ""; +const css = { + code: ".error.svelte-15xrav7{color:tomato;margin:2rem 0 0}form.svelte-15xrav7{display:flex;flex-direction:column;gap:10px;margin:2rem 0}form.svelte-15xrav7 input,.input,form.svelte-15xrav7 select{border:solid 1px var(--gray-color);padding:1rem;border-radius:5px;background:white}button.svelte-15xrav7{padding:1rem;border-radius:5px;border:solid 1px #ccc;color:white;background:var(--link-color);font-size:1.2rem;margin:1rem 0}", + map: null +}; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let email = "jsmith@example.com"; + let name = "John Smith"; + let billingAddress = { + line1: "123 Main", + line2: "Apt 100", + state: "CA", + city: "Los Angeles", + country: "US", + postal_code: "1000" + }; + let shippingAddress = { + line1: "123 Main", + line2: "Apt 100", + state: "CA", + city: "Los Angeles", + country: "US", + postal_code: "1000" + }; + $$result.css.add(css); + let $$settled; + let $$rendered; + do { + $$settled = true; + $$rendered = `

Afterpay/Clearpay Example

+ + + +${``} + +
${validate_component(Address, "Address").$$render( + $$result, + { + legend: "Billing", + address: billingAddress + }, + { + address: ($$value) => { + billingAddress = $$value; + $$settled = false; + } + }, + { + default: () => { + return ` + + + `; + } + } + )} + + ${validate_component(Address, "Address").$$render( + $$result, + { + legend: "Shipping", + address: shippingAddress + }, + { + address: ($$value) => { + shippingAddress = $$value; + $$settled = false; + } + }, + {} + )} + + +
`; + } while (!$$settled); + return $$rendered; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/afterpay-clearpay/thanks/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/afterpay-clearpay/thanks/_page.svelte.js new file mode 100644 index 0000000..00a8a48 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/afterpay-clearpay/thanks/_page.svelte.js @@ -0,0 +1,8 @@ +import { c as create_ssr_component } from "../../../../../chunks/index2.js"; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + return `

Success!

+

Afterpay/Clearpay payment was successfully processed.

`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/alipay/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/alipay/_page.svelte.js new file mode 100644 index 0000000..00af343 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/alipay/_page.svelte.js @@ -0,0 +1,24 @@ +import { c as create_ssr_component, d as add_attribute } from "../../../../chunks/index2.js"; +import "@stripe/stripe-js"; +const _page_svelte_svelte_type_style_lang = ""; +const css = { + code: ".error.svelte-4i9m9b{color:tomato;margin:2rem 0 0}form.svelte-4i9m9b{display:flex;flex-direction:column;gap:10px;margin:2rem 0}input.svelte-4i9m9b,.input{border:solid 1px var(--gray-color);padding:1rem;border-radius:5px;background:white}button.svelte-4i9m9b{padding:1rem;border-radius:5px;border:solid 1px #ccc;color:white;background:var(--link-color);font-size:1.2rem;margin:1rem 0}", + map: null +}; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let email; + $$result.css.add(css); + return `

Alipay Example

+ + + +${``} + +
+ + +
`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/alipay/thanks/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/alipay/thanks/_page.svelte.js new file mode 100644 index 0000000..166635f --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/alipay/thanks/_page.svelte.js @@ -0,0 +1,8 @@ +import { c as create_ssr_component } from "../../../../../chunks/index2.js"; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + return `

Success!

+

Alipay payment was successfully processed.

`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/credit-card/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/credit-card/_page.svelte.js new file mode 100644 index 0000000..1485546 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/credit-card/_page.svelte.js @@ -0,0 +1,182 @@ +import { c as create_ssr_component, f as createEventDispatcher, g as getContext, d as add_attribute, v as validate_component } from "../../../../chunks/index2.js"; +import "@stripe/stripe-js"; +import { E as Elements } from "../../../../chunks/Elements.js"; +const CardNumber = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let { classes = {} } = $$props; + let { style = {} } = $$props; + let { placeholder = "Card number" } = $$props; + let { disabled = false } = $$props; + let { showIcon = true } = $$props; + let { iconStyle = "default" } = $$props; + let { element = null } = $$props; + let wrapper; + createEventDispatcher(); + getContext("stripe"); + function blur() { + element.blur(); + } + function clear() { + element.clear(); + } + function destroy() { + element.destroy(); + } + function focus() { + element.focus(); + } + if ($$props.classes === void 0 && $$bindings.classes && classes !== void 0) + $$bindings.classes(classes); + if ($$props.style === void 0 && $$bindings.style && style !== void 0) + $$bindings.style(style); + if ($$props.placeholder === void 0 && $$bindings.placeholder && placeholder !== void 0) + $$bindings.placeholder(placeholder); + if ($$props.disabled === void 0 && $$bindings.disabled && disabled !== void 0) + $$bindings.disabled(disabled); + if ($$props.showIcon === void 0 && $$bindings.showIcon && showIcon !== void 0) + $$bindings.showIcon(showIcon); + if ($$props.iconStyle === void 0 && $$bindings.iconStyle && iconStyle !== void 0) + $$bindings.iconStyle(iconStyle); + if ($$props.element === void 0 && $$bindings.element && element !== void 0) + $$bindings.element(element); + if ($$props.blur === void 0 && $$bindings.blur && blur !== void 0) + $$bindings.blur(blur); + if ($$props.clear === void 0 && $$bindings.clear && clear !== void 0) + $$bindings.clear(clear); + if ($$props.destroy === void 0 && $$bindings.destroy && destroy !== void 0) + $$bindings.destroy(destroy); + if ($$props.focus === void 0 && $$bindings.focus && focus !== void 0) + $$bindings.focus(focus); + return ``; +}); +const CardExpiry = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let { classes = {} } = $$props; + let { style = {} } = $$props; + let { placeholder = "MM / YY" } = $$props; + let { disabled = false } = $$props; + let { element = null } = $$props; + let wrapper; + createEventDispatcher(); + getContext("stripe"); + function blur() { + element.blur(); + } + function clear() { + element.clear(); + } + function destroy() { + element.destroy(); + } + function focus() { + element.focus(); + } + if ($$props.classes === void 0 && $$bindings.classes && classes !== void 0) + $$bindings.classes(classes); + if ($$props.style === void 0 && $$bindings.style && style !== void 0) + $$bindings.style(style); + if ($$props.placeholder === void 0 && $$bindings.placeholder && placeholder !== void 0) + $$bindings.placeholder(placeholder); + if ($$props.disabled === void 0 && $$bindings.disabled && disabled !== void 0) + $$bindings.disabled(disabled); + if ($$props.element === void 0 && $$bindings.element && element !== void 0) + $$bindings.element(element); + if ($$props.blur === void 0 && $$bindings.blur && blur !== void 0) + $$bindings.blur(blur); + if ($$props.clear === void 0 && $$bindings.clear && clear !== void 0) + $$bindings.clear(clear); + if ($$props.destroy === void 0 && $$bindings.destroy && destroy !== void 0) + $$bindings.destroy(destroy); + if ($$props.focus === void 0 && $$bindings.focus && focus !== void 0) + $$bindings.focus(focus); + return ``; +}); +const CardCvc = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let { classes = {} } = $$props; + let { style = {} } = $$props; + let { placeholder = "CVC" } = $$props; + let { disabled = false } = $$props; + let { element = null } = $$props; + let wrapper; + createEventDispatcher(); + getContext("stripe"); + function blur() { + element.blur(); + } + function clear() { + element.clear(); + } + function destroy() { + element.destroy(); + } + function focus() { + element.focus(); + } + if ($$props.classes === void 0 && $$bindings.classes && classes !== void 0) + $$bindings.classes(classes); + if ($$props.style === void 0 && $$bindings.style && style !== void 0) + $$bindings.style(style); + if ($$props.placeholder === void 0 && $$bindings.placeholder && placeholder !== void 0) + $$bindings.placeholder(placeholder); + if ($$props.disabled === void 0 && $$bindings.disabled && disabled !== void 0) + $$bindings.disabled(disabled); + if ($$props.element === void 0 && $$bindings.element && element !== void 0) + $$bindings.element(element); + if ($$props.blur === void 0 && $$bindings.blur && blur !== void 0) + $$bindings.blur(blur); + if ($$props.clear === void 0 && $$bindings.clear && clear !== void 0) + $$bindings.clear(clear); + if ($$props.destroy === void 0 && $$bindings.destroy && destroy !== void 0) + $$bindings.destroy(destroy); + if ($$props.focus === void 0 && $$bindings.focus && focus !== void 0) + $$bindings.focus(focus); + return ``; +}); +const _page_svelte_svelte_type_style_lang = ""; +const css = { + code: ".error.svelte-1e3zach{color:tomato;margin:2rem 0 0}form.svelte-1e3zach{display:flex;flex-direction:column;gap:10px;margin:2rem 0}.row.svelte-1e3zach{display:flex;flex-direction:row;gap:5px}input.svelte-1e3zach,.input{border:solid 1px var(--gray-color);padding:1rem;border-radius:5px;background:white}.row.svelte-1e3zach .input{width:20%}button.svelte-1e3zach{padding:1rem;border-radius:5px;border:solid 1px #ccc;color:white;background:var(--link-color);font-size:1.2rem;margin:1rem 0}", + map: null +}; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let stripe = null; + let cardElement; + let name; + $$result.css.add(css); + let $$settled; + let $$rendered; + do { + $$settled = true; + $$rendered = `

Credit Card Example

+ + + +${``} + +${validate_component(Elements, "Elements").$$render($$result, { stripe }, {}, { + default: () => { + return `
+ ${validate_component(CardNumber, "CardNumber").$$render( + $$result, + { + classes: { base: "input" }, + element: cardElement + }, + { + element: ($$value) => { + cardElement = $$value; + $$settled = false; + } + }, + {} + )} + +
${validate_component(CardExpiry, "CardExpiry").$$render($$result, { classes: { base: "input" } }, {}, {})} + ${validate_component(CardCvc, "CardCvc").$$render($$result, { classes: { base: "input" } }, {}, {})}
+ +
`; + } + })}`; + } while (!$$settled); + return $$rendered; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/credit-card/thanks/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/credit-card/thanks/_page.svelte.js new file mode 100644 index 0000000..2470a6b --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/credit-card/thanks/_page.svelte.js @@ -0,0 +1,8 @@ +import { c as create_ssr_component } from "../../../../../chunks/index2.js"; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + return `

Success!

+

Credit card payment was successfully processed.

`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/embedded-checkout/_page.server.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/embedded-checkout/_page.server.js new file mode 100644 index 0000000..ea17056 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/embedded-checkout/_page.server.js @@ -0,0 +1,23 @@ +import Stripe from "stripe"; +import { S as SECRET_STRIPE_KEY, D as DOMAIN } from "../../../../chunks/private.js"; +const stripe = new Stripe(SECRET_STRIPE_KEY); +const return_url = new URL("/examples/embedded-checkout/thanks?session_id={CHECKOUT_SESSION_ID}", DOMAIN).toString(); +async function load() { + const session = await stripe.checkout.sessions.create({ + ui_mode: "embedded", + line_items: [ + { + price: "price_1ODEgRHfKEQGgXe5p6BvaWV2", + quantity: 1 + } + ], + mode: "payment", + return_url + }); + return { + clientSecret: session.client_secret + }; +} +export { + load +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/embedded-checkout/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/embedded-checkout/_page.svelte.js new file mode 100644 index 0000000..4e0c328 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/embedded-checkout/_page.svelte.js @@ -0,0 +1,44 @@ +import { c as create_ssr_component, o as onDestroy, d as add_attribute, v as validate_component } from "../../../../chunks/index2.js"; +import "@stripe/stripe-js"; +import { r as register } from "../../../../chunks/util.js"; +const EmbeddedCheckout = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let { stripe } = $$props; + let { clientSecret } = $$props; + let wrapper; + let checkoutElement; + onDestroy(() => { + checkoutElement?.destroy(); + }); + if ($$props.stripe === void 0 && $$bindings.stripe && stripe !== void 0) + $$bindings.stripe(stripe); + if ($$props.clientSecret === void 0 && $$bindings.clientSecret && clientSecret !== void 0) + $$bindings.clientSecret(clientSecret); + { + if (stripe) { + register(stripe); + } + } + { + if (stripe && clientSecret && wrapper) { + stripe.initEmbeddedCheckout({ clientSecret }).then((element) => { + checkoutElement = element; + checkoutElement.mount(wrapper); + }); + } + } + return `${stripe && clientSecret ? `` : ``}`; +}); +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let { data } = $$props; + let stripe = null; + if ($$props.data === void 0 && $$bindings.data && data !== void 0) + $$bindings.data(data); + return `

Embedded Checkout Example

+ + + +${validate_component(EmbeddedCheckout, "EmbeddedCheckout").$$render($$result, { stripe, clientSecret: data.clientSecret }, {}, {})}`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/embedded-checkout/thanks/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/embedded-checkout/thanks/_page.svelte.js new file mode 100644 index 0000000..81a0883 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/embedded-checkout/thanks/_page.svelte.js @@ -0,0 +1,8 @@ +import { c as create_ssr_component } from "../../../../../chunks/index2.js"; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + return `

Success!

+

Payment was successfully processed.

`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/express-checkout/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/express-checkout/_page.svelte.js new file mode 100644 index 0000000..421f75a --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/express-checkout/_page.svelte.js @@ -0,0 +1,106 @@ +import { c as create_ssr_component, f as createEventDispatcher, g as getContext, d as add_attribute, v as validate_component } from "../../../../chunks/index2.js"; +import "@stripe/stripe-js"; +import { E as Elements } from "../../../../chunks/Elements.js"; +const ExpressCheckout = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let { buttonHeight = void 0 } = $$props; + let { buttonTheme = void 0 } = $$props; + let { buttonType = void 0 } = $$props; + let { layout = void 0 } = $$props; + let { paymentMethodOrder = void 0 } = $$props; + let { wallets = void 0 } = $$props; + let { element = null } = $$props; + let wrapper; + createEventDispatcher(); + getContext("stripe"); + function blur() { + element.blur(); + } + function clear() { + element.clear(); + } + function destroy() { + element.destroy(); + } + function focus() { + element.focus(); + } + if ($$props.buttonHeight === void 0 && $$bindings.buttonHeight && buttonHeight !== void 0) + $$bindings.buttonHeight(buttonHeight); + if ($$props.buttonTheme === void 0 && $$bindings.buttonTheme && buttonTheme !== void 0) + $$bindings.buttonTheme(buttonTheme); + if ($$props.buttonType === void 0 && $$bindings.buttonType && buttonType !== void 0) + $$bindings.buttonType(buttonType); + if ($$props.layout === void 0 && $$bindings.layout && layout !== void 0) + $$bindings.layout(layout); + if ($$props.paymentMethodOrder === void 0 && $$bindings.paymentMethodOrder && paymentMethodOrder !== void 0) + $$bindings.paymentMethodOrder(paymentMethodOrder); + if ($$props.wallets === void 0 && $$bindings.wallets && wallets !== void 0) + $$bindings.wallets(wallets); + if ($$props.element === void 0 && $$bindings.element && element !== void 0) + $$bindings.element(element); + if ($$props.blur === void 0 && $$bindings.blur && blur !== void 0) + $$bindings.blur(blur); + if ($$props.clear === void 0 && $$bindings.clear && clear !== void 0) + $$bindings.clear(clear); + if ($$props.destroy === void 0 && $$bindings.destroy && destroy !== void 0) + $$bindings.destroy(destroy); + if ($$props.focus === void 0 && $$bindings.focus && focus !== void 0) + $$bindings.focus(focus); + return ``; +}); +const _page_svelte_svelte_type_style_lang = ""; +const css = { + code: ".error.svelte-6ufdvm{color:tomato;margin:2rem 0 0}", + map: null +}; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let stripe = null; + let elements; + $$result.css.add(css); + let $$settled; + let $$rendered; + do { + $$settled = true; + $$rendered = `

Express Checkout Example

+ + + +${``} + +${validate_component(Elements, "Elements").$$render( + $$result, + { + stripe, + mode: "payment", + currency: "usd", + amount: 1099, + elements + }, + { + elements: ($$value) => { + elements = $$value; + $$settled = false; + } + }, + { + default: () => { + return `${validate_component(ExpressCheckout, "ExpressCheckout").$$render( + $$result, + { + buttonHeight: 50, + buttonTheme: { googlePay: "white" }, + buttonType: { googlePay: "donate" }, + paymentMethodOrder: ["googlePay", "link"] + }, + {}, + {} + )}`; + } + } + )}`; + } while (!$$settled); + return $$rendered; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/express-checkout/thanks/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/express-checkout/thanks/_page.svelte.js new file mode 100644 index 0000000..81a0883 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/express-checkout/thanks/_page.svelte.js @@ -0,0 +1,8 @@ +import { c as create_ssr_component } from "../../../../../chunks/index2.js"; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + return `

Success!

+

Payment was successfully processed.

`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/ideal/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/ideal/_page.svelte.js new file mode 100644 index 0000000..805eb14 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/ideal/_page.svelte.js @@ -0,0 +1,96 @@ +import { c as create_ssr_component, f as createEventDispatcher, g as getContext, d as add_attribute, v as validate_component } from "../../../../chunks/index2.js"; +import "@stripe/stripe-js"; +import { E as Elements } from "../../../../chunks/Elements.js"; +const Ideal = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let { classes = {} } = $$props; + let { style = {} } = $$props; + let { value = "" } = $$props; + let { disabled = false } = $$props; + let { hideIcon = true } = $$props; + let { element = null } = $$props; + let wrapper; + createEventDispatcher(); + getContext("stripe"); + function blur() { + element.blur(); + } + function clear() { + element.clear(); + } + function destroy() { + element.destroy(); + } + function focus() { + element.focus(); + } + if ($$props.classes === void 0 && $$bindings.classes && classes !== void 0) + $$bindings.classes(classes); + if ($$props.style === void 0 && $$bindings.style && style !== void 0) + $$bindings.style(style); + if ($$props.value === void 0 && $$bindings.value && value !== void 0) + $$bindings.value(value); + if ($$props.disabled === void 0 && $$bindings.disabled && disabled !== void 0) + $$bindings.disabled(disabled); + if ($$props.hideIcon === void 0 && $$bindings.hideIcon && hideIcon !== void 0) + $$bindings.hideIcon(hideIcon); + if ($$props.element === void 0 && $$bindings.element && element !== void 0) + $$bindings.element(element); + if ($$props.blur === void 0 && $$bindings.blur && blur !== void 0) + $$bindings.blur(blur); + if ($$props.clear === void 0 && $$bindings.clear && clear !== void 0) + $$bindings.clear(clear); + if ($$props.destroy === void 0 && $$bindings.destroy && destroy !== void 0) + $$bindings.destroy(destroy); + if ($$props.focus === void 0 && $$bindings.focus && focus !== void 0) + $$bindings.focus(focus); + return ``; +}); +const _page_svelte_svelte_type_style_lang = ""; +const css = { + code: ".error.svelte-4i9m9b{color:tomato;margin:2rem 0 0}form.svelte-4i9m9b{display:flex;flex-direction:column;gap:10px;margin:2rem 0}input.svelte-4i9m9b,.input{border:solid 1px var(--gray-color);padding:1rem;border-radius:5px;background:white}button.svelte-4i9m9b{padding:1rem;border-radius:5px;border:solid 1px #ccc;color:white;background:var(--link-color);font-size:1.2rem;margin:1rem 0}", + map: null +}; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let stripe = null; + let idealElement; + let name; + let email; + $$result.css.add(css); + let $$settled; + let $$rendered; + do { + $$settled = true; + $$rendered = `

iDEAL Example

+ + + +${``} + +${validate_component(Elements, "Elements").$$render($$result, { stripe }, {}, { + default: () => { + return `
+ + ${validate_component(Ideal, "Ideal").$$render( + $$result, + { + classes: { base: "input" }, + element: idealElement + }, + { + element: ($$value) => { + idealElement = $$value; + $$settled = false; + } + }, + {} + )} + +
`; + } + })}`; + } while (!$$settled); + return $$rendered; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/ideal/thanks/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/ideal/thanks/_page.svelte.js new file mode 100644 index 0000000..63bbdd7 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/ideal/thanks/_page.svelte.js @@ -0,0 +1,8 @@ +import { c as create_ssr_component } from "../../../../../chunks/index2.js"; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + return `

Success!

+

iDEAL payment was successfully processed.

`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/klarna/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/klarna/_page.svelte.js new file mode 100644 index 0000000..475fe47 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/klarna/_page.svelte.js @@ -0,0 +1,26 @@ +import { c as create_ssr_component, d as add_attribute } from "../../../../chunks/index2.js"; +import "@stripe/stripe-js"; +const _page_svelte_svelte_type_style_lang = ""; +const css = { + code: ".error.svelte-4i9m9b{color:tomato;margin:2rem 0 0}form.svelte-4i9m9b{display:flex;flex-direction:column;gap:10px;margin:2rem 0}input.svelte-4i9m9b,.input{border:solid 1px var(--gray-color);padding:1rem;border-radius:5px;background:white}button.svelte-4i9m9b{padding:1rem;border-radius:5px;border:solid 1px #ccc;color:white;background:var(--link-color);font-size:1.2rem;margin:1rem 0}", + map: null +}; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let email; + let name; + $$result.css.add(css); + return `

Klarna Example

+ + + +${``} + +
+ + + +
`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/klarna/thanks/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/klarna/thanks/_page.svelte.js new file mode 100644 index 0000000..a1bfe5d --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/klarna/thanks/_page.svelte.js @@ -0,0 +1,8 @@ +import { c as create_ssr_component } from "../../../../../chunks/index2.js"; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + return `

Success!

+

Klarna payment was successfully processed.

`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/konbini/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/konbini/_page.svelte.js new file mode 100644 index 0000000..d44d616 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/konbini/_page.svelte.js @@ -0,0 +1,28 @@ +import { c as create_ssr_component, d as add_attribute } from "../../../../chunks/index2.js"; +import "@stripe/stripe-js"; +const _page_svelte_svelte_type_style_lang = ""; +const css = { + code: ".error.svelte-4i9m9b{color:tomato;margin:2rem 0 0}form.svelte-4i9m9b{display:flex;flex-direction:column;gap:10px;margin:2rem 0}input.svelte-4i9m9b,.input{border:solid 1px var(--gray-color);padding:1rem;border-radius:5px;background:white}button.svelte-4i9m9b{padding:1rem;border-radius:5px;border:solid 1px #ccc;color:white;background:var(--link-color);font-size:1.2rem;margin:1rem 0}", + map: null +}; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let email; + let name; + let phone; + $$result.css.add(css); + return `

Konbini Example

+ + + +${``} + +
+ + + + +
`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/konbini/next-steps/_page.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/konbini/next-steps/_page.js new file mode 100644 index 0000000..a742825 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/konbini/next-steps/_page.js @@ -0,0 +1,4 @@ +const prerender = false; +export { + prerender +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/konbini/next-steps/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/konbini/next-steps/_page.svelte.js new file mode 100644 index 0000000..1e9f903 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/konbini/next-steps/_page.svelte.js @@ -0,0 +1,10 @@ +import { c as create_ssr_component, d as add_attribute } from "../../../../../chunks/index2.js"; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let hosted_voucher_url; + return `

Next steps

+ +

Follow these instructions to complete the Konbini payment.

`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/payment-element/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/payment-element/_page.svelte.js new file mode 100644 index 0000000..0955e83 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/payment-element/_page.svelte.js @@ -0,0 +1,26 @@ +import { c as create_ssr_component } from "../../../../chunks/index2.js"; +import "@stripe/stripe-js"; +const _page_svelte_svelte_type_style_lang = ""; +const css = { + code: ".error.svelte-y4pdr7{color:tomato;margin:2rem 0 0}form.svelte-y4pdr7{display:flex;flex-direction:column;gap:10px;margin:2rem 0}button.svelte-y4pdr7{padding:1rem;border-radius:5px;border:solid 1px #ccc;color:white;background:var(--link-color);font-size:1.2rem;margin:1rem 0}", + map: null +}; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + $$result.css.add(css); + let $$settled; + let $$rendered; + do { + $$settled = true; + $$rendered = `

Payment Element Example

+ + + +${``} + +${`Loading...`}`; + } while (!$$settled); + return $$rendered; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/payment-element/thanks/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/payment-element/thanks/_page.svelte.js new file mode 100644 index 0000000..81a0883 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/payment-element/thanks/_page.svelte.js @@ -0,0 +1,8 @@ +import { c as create_ssr_component } from "../../../../../chunks/index2.js"; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + return `

Success!

+

Payment was successfully processed.

`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/payment-method-messaging/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/payment-method-messaging/_page.svelte.js new file mode 100644 index 0000000..0a4ec9d --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/payment-method-messaging/_page.svelte.js @@ -0,0 +1,55 @@ +import { c as create_ssr_component, f as createEventDispatcher, g as getContext, d as add_attribute, v as validate_component } from "../../../../chunks/index2.js"; +import "@stripe/stripe-js"; +import { E as Elements } from "../../../../chunks/Elements.js"; +const PaymentMethodMessaging = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let { amount } = $$props; + let { currency } = $$props; + let { paymentMethodTypes } = $$props; + let { countryCode } = $$props; + let { logoColor = null } = $$props; + let { metadata = null } = $$props; + let { element = null } = $$props; + let wrapper; + createEventDispatcher(); + getContext("stripe"); + if ($$props.amount === void 0 && $$bindings.amount && amount !== void 0) + $$bindings.amount(amount); + if ($$props.currency === void 0 && $$bindings.currency && currency !== void 0) + $$bindings.currency(currency); + if ($$props.paymentMethodTypes === void 0 && $$bindings.paymentMethodTypes && paymentMethodTypes !== void 0) + $$bindings.paymentMethodTypes(paymentMethodTypes); + if ($$props.countryCode === void 0 && $$bindings.countryCode && countryCode !== void 0) + $$bindings.countryCode(countryCode); + if ($$props.logoColor === void 0 && $$bindings.logoColor && logoColor !== void 0) + $$bindings.logoColor(logoColor); + if ($$props.metadata === void 0 && $$bindings.metadata && metadata !== void 0) + $$bindings.metadata(metadata); + if ($$props.element === void 0 && $$bindings.element && element !== void 0) + $$bindings.element(element); + return ``; +}); +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let stripe = null; + return `

Payment Method Messaging Example

+ + + +${validate_component(Elements, "Elements").$$render($$result, { stripe }, {}, { + default: () => { + return `${validate_component(PaymentMethodMessaging, "PaymentMethodMessaging").$$render( + $$result, + { + currency: "USD", + countryCode: "US", + amount: 1e5, + paymentMethodTypes: ["afterpay_clearpay", "klarna", "affirm"] + }, + {}, + {} + )}`; + } + })}`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/payment-request/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/payment-request/_page.svelte.js new file mode 100644 index 0000000..17fd9cf --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/payment-request/_page.svelte.js @@ -0,0 +1,59 @@ +import { c as create_ssr_component, f as createEventDispatcher, g as getContext, d as add_attribute, v as validate_component } from "../../../../chunks/index2.js"; +import "@stripe/stripe-js"; +import { E as Elements } from "../../../../chunks/Elements.js"; +const PaymentRequestButton = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let { classes = {} } = $$props; + let { style = {} } = $$props; + let { paymentRequest } = $$props; + let { element = null } = $$props; + let { canMakePayment = null } = $$props; + let wrapper; + createEventDispatcher(); + getContext("stripe"); + if ($$props.classes === void 0 && $$bindings.classes && classes !== void 0) + $$bindings.classes(classes); + if ($$props.style === void 0 && $$bindings.style && style !== void 0) + $$bindings.style(style); + if ($$props.paymentRequest === void 0 && $$bindings.paymentRequest && paymentRequest !== void 0) + $$bindings.paymentRequest(paymentRequest); + if ($$props.element === void 0 && $$bindings.element && element !== void 0) + $$bindings.element(element); + if ($$props.canMakePayment === void 0 && $$bindings.canMakePayment && canMakePayment !== void 0) + $$bindings.canMakePayment(canMakePayment); + return ``; +}); +const _page_svelte_svelte_type_style_lang = ""; +const css = { + code: ".error.svelte-cwv56c{color:tomato}.wrapper.svelte-cwv56c{margin:3rem 0;width:300px}", + map: null +}; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let stripe = null; + const paymentRequest = { + country: "US", + currency: "usd", + total: { label: "Demo total", amount: 1099 }, + requestPayerName: true, + requestPayerEmail: true + }; + $$result.css.add(css); + return `

Payment Request Example

+ +

If you see a blank screen, it's because this demo will only work if the TLD is https://localhost or if you're using production keys. +

+

For ApplePay, the production domain must be submitted to Apple. +

+ + + +${``} + +${validate_component(Elements, "Elements").$$render($$result, { stripe }, {}, { + default: () => { + return `
${validate_component(PaymentRequestButton, "PaymentRequestButton").$$render($$result, { paymentRequest }, {}, {})}
`; + } + })}`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/payment-request/thanks/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/payment-request/thanks/_page.svelte.js new file mode 100644 index 0000000..6212d7a --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/payment-request/thanks/_page.svelte.js @@ -0,0 +1,8 @@ +import { c as create_ssr_component } from "../../../../../chunks/index2.js"; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + return `

Success!

+

Payment request was successfully processed.

`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/sepa/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/sepa/_page.svelte.js new file mode 100644 index 0000000..645a5cc --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/sepa/_page.svelte.js @@ -0,0 +1,103 @@ +import { c as create_ssr_component, f as createEventDispatcher, g as getContext, d as add_attribute, v as validate_component } from "../../../../chunks/index2.js"; +import "@stripe/stripe-js"; +import { E as Elements } from "../../../../chunks/Elements.js"; +const Iban = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let { classes = {} } = $$props; + let { style = {} } = $$props; + let { supportedCountries = [] } = $$props; + let { placeholderCountry = "" } = $$props; + let { hideIcon = false } = $$props; + let { iconStyle = "default" } = $$props; + let { disabled = false } = $$props; + let { element = null } = $$props; + let wrapper; + createEventDispatcher(); + getContext("stripe"); + function blur() { + element.blur(); + } + function clear() { + element.clear(); + } + function destroy() { + element.destroy(); + } + function focus() { + element.focus(); + } + if ($$props.classes === void 0 && $$bindings.classes && classes !== void 0) + $$bindings.classes(classes); + if ($$props.style === void 0 && $$bindings.style && style !== void 0) + $$bindings.style(style); + if ($$props.supportedCountries === void 0 && $$bindings.supportedCountries && supportedCountries !== void 0) + $$bindings.supportedCountries(supportedCountries); + if ($$props.placeholderCountry === void 0 && $$bindings.placeholderCountry && placeholderCountry !== void 0) + $$bindings.placeholderCountry(placeholderCountry); + if ($$props.hideIcon === void 0 && $$bindings.hideIcon && hideIcon !== void 0) + $$bindings.hideIcon(hideIcon); + if ($$props.iconStyle === void 0 && $$bindings.iconStyle && iconStyle !== void 0) + $$bindings.iconStyle(iconStyle); + if ($$props.disabled === void 0 && $$bindings.disabled && disabled !== void 0) + $$bindings.disabled(disabled); + if ($$props.element === void 0 && $$bindings.element && element !== void 0) + $$bindings.element(element); + if ($$props.blur === void 0 && $$bindings.blur && blur !== void 0) + $$bindings.blur(blur); + if ($$props.clear === void 0 && $$bindings.clear && clear !== void 0) + $$bindings.clear(clear); + if ($$props.destroy === void 0 && $$bindings.destroy && destroy !== void 0) + $$bindings.destroy(destroy); + if ($$props.focus === void 0 && $$bindings.focus && focus !== void 0) + $$bindings.focus(focus); + return ``; +}); +const _page_svelte_svelte_type_style_lang = ""; +const css = { + code: ".error.svelte-4i9m9b{color:tomato;margin:2rem 0 0}form.svelte-4i9m9b{display:flex;flex-direction:column;gap:10px;margin:2rem 0}input.svelte-4i9m9b,.input{border:solid 1px var(--gray-color);padding:1rem;border-radius:5px;background:white}button.svelte-4i9m9b{padding:1rem;border-radius:5px;border:solid 1px #ccc;color:white;background:var(--link-color);font-size:1.2rem;margin:1rem 0}", + map: null +}; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let stripe = null; + let ibanElement; + let name; + let email; + $$result.css.add(css); + let $$settled; + let $$rendered; + do { + $$settled = true; + $$rendered = `

SEPA Example

+ + + +${``} + +${validate_component(Elements, "Elements").$$render($$result, { stripe }, {}, { + default: () => { + return `
+ + ${validate_component(Iban, "Iban").$$render( + $$result, + { + supportedCountries: ["SEPA"], + classes: { base: "input" }, + element: ibanElement + }, + { + element: ($$value) => { + ibanElement = $$value; + $$settled = false; + } + }, + {} + )} + +
`; + } + })}`; + } while (!$$settled); + return $$rendered; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/sepa/thanks/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/sepa/thanks/_page.svelte.js new file mode 100644 index 0000000..9586ca6 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/sepa/thanks/_page.svelte.js @@ -0,0 +1,8 @@ +import { c as create_ssr_component } from "../../../../../chunks/index2.js"; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + return `

Success!

+

SEPA payment was successfully processed.

`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/sofort/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/sofort/_page.svelte.js new file mode 100644 index 0000000..b85d080 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/sofort/_page.svelte.js @@ -0,0 +1,26 @@ +import { c as create_ssr_component, d as add_attribute } from "../../../../chunks/index2.js"; +import "@stripe/stripe-js"; +const _page_svelte_svelte_type_style_lang = ""; +const css = { + code: ".error.svelte-4i9m9b{color:tomato;margin:2rem 0 0}form.svelte-4i9m9b{display:flex;flex-direction:column;gap:10px;margin:2rem 0}input.svelte-4i9m9b,.input{border:solid 1px var(--gray-color);padding:1rem;border-radius:5px;background:white}button.svelte-4i9m9b{padding:1rem;border-radius:5px;border:solid 1px #ccc;color:white;background:var(--link-color);font-size:1.2rem;margin:1rem 0}", + map: null +}; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let email; + let name; + $$result.css.add(css); + return `

Sofort Example

+ + + +${``} + +
+ + + +
`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/sofort/thanks/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/sofort/thanks/_page.svelte.js new file mode 100644 index 0000000..4a7e28d --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/sofort/thanks/_page.svelte.js @@ -0,0 +1,8 @@ +import { c as create_ssr_component } from "../../../../../chunks/index2.js"; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + return `

Success!

+

Sofort payment is now processing.

`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/wechat-pay/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/wechat-pay/_page.svelte.js new file mode 100644 index 0000000..16dad27 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/wechat-pay/_page.svelte.js @@ -0,0 +1,24 @@ +import { c as create_ssr_component, d as add_attribute } from "../../../../chunks/index2.js"; +import "@stripe/stripe-js"; +const _page_svelte_svelte_type_style_lang = ""; +const css = { + code: ".error.svelte-4i9m9b{color:tomato;margin:2rem 0 0}form.svelte-4i9m9b{display:flex;flex-direction:column;gap:10px;margin:2rem 0}input.svelte-4i9m9b,.input{border:solid 1px var(--gray-color);padding:1rem;border-radius:5px;background:white}button.svelte-4i9m9b{padding:1rem;border-radius:5px;border:solid 1px #ccc;color:white;background:var(--link-color);font-size:1.2rem;margin:1rem 0}", + map: null +}; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + let email; + $$result.css.add(css); + return `

WeChat Pay Example

+ + + +${``} + +
+ + +
`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/wechat-pay/thanks/_page.svelte.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/wechat-pay/thanks/_page.svelte.js new file mode 100644 index 0000000..06bf6d0 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/entries/pages/examples/wechat-pay/thanks/_page.svelte.js @@ -0,0 +1,8 @@ +import { c as create_ssr_component } from "../../../../../chunks/index2.js"; +const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { + return `

Success!

+

WeChat Pay payment was successfully processed.

`; +}); +export { + Page as default +}; diff --git a/.vercel/output/functions/render.func/.svelte-kit/output/server/index.js b/.vercel/output/functions/render.func/.svelte-kit/output/server/index.js new file mode 100644 index 0000000..d02b838 --- /dev/null +++ b/.vercel/output/functions/render.func/.svelte-kit/output/server/index.js @@ -0,0 +1,3620 @@ +import { b as base, a as assets, r as reset, p as public_env, o as options, s as set_private_env, c as set_public_env, g as get_hooks } from "./chunks/internal.js"; +import { t as text, H as HttpError, j as json, R as Redirect, e as error, A as ActionFailure } from "./chunks/index.js"; +import { n as noop, s as safe_not_equal } from "./chunks/index2.js"; +const DEV = false; +const SVELTE_KIT_ASSETS = "/_svelte_kit_assets"; +const ENDPOINT_METHODS = /* @__PURE__ */ new Set([ + "GET", + "POST", + "PUT", + "PATCH", + "DELETE", + "OPTIONS", + "HEAD" +]); +const PAGE_METHODS = /* @__PURE__ */ new Set(["GET", "POST", "HEAD"]); +function negotiate(accept, types) { + const parts = []; + accept.split(",").forEach((str, i) => { + const match = /([^/]+)\/([^;]+)(?:;q=([0-9.]+))?/.exec(str); + if (match) { + const [, type, subtype, q = "1"] = match; + parts.push({ type, subtype, q: +q, i }); + } + }); + parts.sort((a, b) => { + if (a.q !== b.q) { + return b.q - a.q; + } + if (a.subtype === "*" !== (b.subtype === "*")) { + return a.subtype === "*" ? 1 : -1; + } + if (a.type === "*" !== (b.type === "*")) { + return a.type === "*" ? 1 : -1; + } + return a.i - b.i; + }); + let accepted; + let min_priority = Infinity; + for (const mimetype of types) { + const [type, subtype] = mimetype.split("/"); + const priority = parts.findIndex( + (part) => (part.type === type || part.type === "*") && (part.subtype === subtype || part.subtype === "*") + ); + if (priority !== -1 && priority < min_priority) { + accepted = mimetype; + min_priority = priority; + } + } + return accepted; +} +function is_content_type(request, ...types) { + const type = request.headers.get("content-type")?.split(";", 1)[0].trim() ?? ""; + return types.includes(type.toLowerCase()); +} +function is_form_content_type(request) { + return is_content_type( + request, + "application/x-www-form-urlencoded", + "multipart/form-data", + "text/plain" + ); +} +function exec(match, params, matchers) { + const result = {}; + const values = match.slice(1); + const values_needing_match = values.filter((value) => value !== void 0); + let buffered = 0; + for (let i = 0; i < params.length; i += 1) { + const param = params[i]; + let value = values[i - buffered]; + if (param.chained && param.rest && buffered) { + value = values.slice(i - buffered, i + 1).filter((s2) => s2).join("/"); + buffered = 0; + } + if (value === void 0) { + if (param.rest) + result[param.name] = ""; + continue; + } + if (!param.matcher || matchers[param.matcher](value)) { + result[param.name] = value; + const next_param = params[i + 1]; + const next_value = values[i + 1]; + if (next_param && !next_param.rest && next_param.optional && next_value && param.chained) { + buffered = 0; + } + if (!next_param && !next_value && Object.keys(result).length === values_needing_match.length) { + buffered = 0; + } + continue; + } + if (param.optional && param.chained) { + buffered++; + continue; + } + return; + } + if (buffered) + return; + return result; +} +function coalesce_to_error(err) { + return err instanceof Error || err && /** @type {any} */ + err.name && /** @type {any} */ + err.message ? ( + /** @type {Error} */ + err + ) : new Error(JSON.stringify(err)); +} +function normalize_error(error2) { + return ( + /** @type {import('../runtime/control.js').Redirect | import('../runtime/control.js').HttpError | Error} */ + error2 + ); +} +function method_not_allowed(mod, method) { + return text(`${method} method not allowed`, { + status: 405, + headers: { + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405 + // "The server must generate an Allow header field in a 405 status code response" + allow: allowed_methods(mod).join(", ") + } + }); +} +function allowed_methods(mod) { + const allowed = Array.from(ENDPOINT_METHODS).filter((method) => method in mod); + if ("GET" in mod || "HEAD" in mod) + allowed.push("HEAD"); + return allowed; +} +function static_error_page(options2, status, message) { + let page = options2.templates.error({ status, message }); + return text(page, { + headers: { "content-type": "text/html; charset=utf-8" }, + status + }); +} +async function handle_fatal_error(event, options2, error2) { + error2 = error2 instanceof HttpError ? error2 : coalesce_to_error(error2); + const status = error2 instanceof HttpError ? error2.status : 500; + const body = await handle_error_and_jsonify(event, options2, error2); + const type = negotiate(event.request.headers.get("accept") || "text/html", [ + "application/json", + "text/html" + ]); + if (event.isDataRequest || type === "application/json") { + return json(body, { + status + }); + } + return static_error_page(options2, status, body.message); +} +async function handle_error_and_jsonify(event, options2, error2) { + if (error2 instanceof HttpError) { + return error2.body; + } else { + return await options2.hooks.handleError({ error: error2, event }) ?? { + message: event.route.id != null ? "Internal Error" : "Not Found" + }; + } +} +function redirect_response(status, location) { + const response = new Response(void 0, { + status, + headers: { location } + }); + return response; +} +function clarify_devalue_error(event, error2) { + if (error2.path) { + return `Data returned from \`load\` while rendering ${event.route.id} is not serializable: ${error2.message} (data${error2.path})`; + } + if (error2.path === "") { + return `Data returned from \`load\` while rendering ${event.route.id} is not a plain object`; + } + return error2.message; +} +function stringify_uses(node) { + const uses = []; + if (node.uses && node.uses.dependencies.size > 0) { + uses.push(`"dependencies":${JSON.stringify(Array.from(node.uses.dependencies))}`); + } + if (node.uses && node.uses.params.size > 0) { + uses.push(`"params":${JSON.stringify(Array.from(node.uses.params))}`); + } + if (node.uses?.parent) + uses.push('"parent":1'); + if (node.uses?.route) + uses.push('"route":1'); + if (node.uses?.url) + uses.push('"url":1'); + return `"uses":{${uses.join(",")}}`; +} +async function render_endpoint(event, mod, state) { + const method = ( + /** @type {import('types').HttpMethod} */ + event.request.method + ); + let handler = mod[method] || mod.fallback; + if (method === "HEAD" && mod.GET && !mod.HEAD) { + handler = mod.GET; + } + if (!handler) { + return method_not_allowed(mod, method); + } + const prerender = mod.prerender ?? state.prerender_default; + if (prerender && (mod.POST || mod.PATCH || mod.PUT || mod.DELETE)) { + throw new Error("Cannot prerender endpoints that have mutative methods"); + } + if (state.prerendering && !prerender) { + if (state.depth > 0) { + throw new Error(`${event.route.id} is not prerenderable`); + } else { + return new Response(void 0, { status: 204 }); + } + } + try { + let response = await handler( + /** @type {import('@sveltejs/kit').RequestEvent>} */ + event + ); + if (!(response instanceof Response)) { + throw new Error( + `Invalid response from route ${event.url.pathname}: handler should return a Response object` + ); + } + if (state.prerendering) { + response = new Response(response.body, { + status: response.status, + statusText: response.statusText, + headers: new Headers(response.headers) + }); + response.headers.set("x-sveltekit-prerender", String(prerender)); + } + return response; + } catch (e) { + if (e instanceof Redirect) { + return new Response(void 0, { + status: e.status, + headers: { location: e.location } + }); + } + throw e; + } +} +function is_endpoint_request(event) { + const { method, headers } = event.request; + if (ENDPOINT_METHODS.has(method) && !PAGE_METHODS.has(method)) { + return true; + } + if (method === "POST" && headers.get("x-sveltekit-action") === "true") + return false; + const accept = event.request.headers.get("accept") ?? "*/*"; + return negotiate(accept, ["*", "text/html"]) !== "text/html"; +} +function compact(arr) { + return arr.filter( + /** @returns {val is NonNullable} */ + (val) => val != null + ); +} +function normalize_path(path, trailing_slash) { + if (path === "/" || trailing_slash === "ignore") + return path; + if (trailing_slash === "never") { + return path.endsWith("/") ? path.slice(0, -1) : path; + } else if (trailing_slash === "always" && !path.endsWith("/")) { + return path + "/"; + } + return path; +} +function decode_pathname(pathname) { + return pathname.split("%25").map(decodeURI).join("%25"); +} +function decode_params(params) { + for (const key2 in params) { + params[key2] = decodeURIComponent(params[key2]); + } + return params; +} +const tracked_url_properties = ( + /** @type {const} */ + [ + "href", + "pathname", + "search", + "searchParams", + "toString", + "toJSON" + ] +); +function make_trackable(url, callback) { + const tracked = new URL(url); + for (const property of tracked_url_properties) { + Object.defineProperty(tracked, property, { + get() { + callback(); + return url[property]; + }, + enumerable: true, + configurable: true + }); + } + { + tracked[Symbol.for("nodejs.util.inspect.custom")] = (depth, opts, inspect) => { + return inspect(url, opts); + }; + } + disable_hash(tracked); + return tracked; +} +function disable_hash(url) { + allow_nodejs_console_log(url); + Object.defineProperty(url, "hash", { + get() { + throw new Error( + "Cannot access event.url.hash. Consider using `$page.url.hash` inside a component instead" + ); + } + }); +} +function disable_search(url) { + allow_nodejs_console_log(url); + for (const property of ["search", "searchParams"]) { + Object.defineProperty(url, property, { + get() { + throw new Error(`Cannot access url.${property} on a page with prerendering enabled`); + } + }); + } +} +function allow_nodejs_console_log(url) { + { + url[Symbol.for("nodejs.util.inspect.custom")] = (depth, opts, inspect) => { + return inspect(new URL(url), opts); + }; + } +} +const DATA_SUFFIX = "/__data.json"; +function has_data_suffix(pathname) { + return pathname.endsWith(DATA_SUFFIX); +} +function add_data_suffix(pathname) { + return pathname.replace(/\/$/, "") + DATA_SUFFIX; +} +function strip_data_suffix(pathname) { + return pathname.slice(0, -DATA_SUFFIX.length); +} +const escaped = { + "<": "\\u003C", + "\\": "\\\\", + "\b": "\\b", + "\f": "\\f", + "\n": "\\n", + "\r": "\\r", + " ": "\\t", + "\u2028": "\\u2028", + "\u2029": "\\u2029" +}; +class DevalueError extends Error { + /** + * @param {string} message + * @param {string[]} keys + */ + constructor(message, keys) { + super(message); + this.name = "DevalueError"; + this.path = keys.join(""); + } +} +function is_primitive(thing) { + return Object(thing) !== thing; +} +const object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames( + Object.prototype +).sort().join("\0"); +function is_plain_object(thing) { + const proto = Object.getPrototypeOf(thing); + return proto === Object.prototype || proto === null || Object.getOwnPropertyNames(proto).sort().join("\0") === object_proto_names; +} +function get_type(thing) { + return Object.prototype.toString.call(thing).slice(8, -1); +} +function get_escaped_char(char) { + switch (char) { + case '"': + return '\\"'; + case "<": + return "\\u003C"; + case "\\": + return "\\\\"; + case "\n": + return "\\n"; + case "\r": + return "\\r"; + case " ": + return "\\t"; + case "\b": + return "\\b"; + case "\f": + return "\\f"; + case "\u2028": + return "\\u2028"; + case "\u2029": + return "\\u2029"; + default: + return char < " " ? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}` : ""; + } +} +function stringify_string(str) { + let result = ""; + let last_pos = 0; + const len = str.length; + for (let i = 0; i < len; i += 1) { + const char = str[i]; + const replacement = get_escaped_char(char); + if (replacement) { + result += str.slice(last_pos, i) + replacement; + last_pos = i + 1; + } + } + return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`; +} +const chars$1 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$"; +const unsafe_chars = /[<\b\f\n\r\t\0\u2028\u2029]/g; +const reserved = /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/; +function uneval(value, replacer) { + const counts = /* @__PURE__ */ new Map(); + const keys = []; + const custom = /* @__PURE__ */ new Map(); + function walk(thing) { + if (typeof thing === "function") { + throw new DevalueError(`Cannot stringify a function`, keys); + } + if (!is_primitive(thing)) { + if (counts.has(thing)) { + counts.set(thing, counts.get(thing) + 1); + return; + } + counts.set(thing, 1); + if (replacer) { + const str2 = replacer(thing); + if (typeof str2 === "string") { + custom.set(thing, str2); + return; + } + } + const type = get_type(thing); + switch (type) { + case "Number": + case "BigInt": + case "String": + case "Boolean": + case "Date": + case "RegExp": + return; + case "Array": + thing.forEach((value2, i) => { + keys.push(`[${i}]`); + walk(value2); + keys.pop(); + }); + break; + case "Set": + Array.from(thing).forEach(walk); + break; + case "Map": + for (const [key2, value2] of thing) { + keys.push( + `.get(${is_primitive(key2) ? stringify_primitive$1(key2) : "..."})` + ); + walk(value2); + keys.pop(); + } + break; + default: + if (!is_plain_object(thing)) { + throw new DevalueError( + `Cannot stringify arbitrary non-POJOs`, + keys + ); + } + if (Object.getOwnPropertySymbols(thing).length > 0) { + throw new DevalueError( + `Cannot stringify POJOs with symbolic keys`, + keys + ); + } + for (const key2 in thing) { + keys.push(`.${key2}`); + walk(thing[key2]); + keys.pop(); + } + } + } + } + walk(value); + const names = /* @__PURE__ */ new Map(); + Array.from(counts).filter((entry) => entry[1] > 1).sort((a, b) => b[1] - a[1]).forEach((entry, i) => { + names.set(entry[0], get_name(i)); + }); + function stringify2(thing) { + if (names.has(thing)) { + return names.get(thing); + } + if (is_primitive(thing)) { + return stringify_primitive$1(thing); + } + if (custom.has(thing)) { + return custom.get(thing); + } + const type = get_type(thing); + switch (type) { + case "Number": + case "String": + case "Boolean": + return `Object(${stringify2(thing.valueOf())})`; + case "RegExp": + return `new RegExp(${stringify_string(thing.source)}, "${thing.flags}")`; + case "Date": + return `new Date(${thing.getTime()})`; + case "Array": + const members = ( + /** @type {any[]} */ + thing.map( + (v, i) => i in thing ? stringify2(v) : "" + ) + ); + const tail = thing.length === 0 || thing.length - 1 in thing ? "" : ","; + return `[${members.join(",")}${tail}]`; + case "Set": + case "Map": + return `new ${type}([${Array.from(thing).map(stringify2).join(",")}])`; + default: + const obj = `{${Object.keys(thing).map((key2) => `${safe_key(key2)}:${stringify2(thing[key2])}`).join(",")}}`; + const proto = Object.getPrototypeOf(thing); + if (proto === null) { + return Object.keys(thing).length > 0 ? `Object.assign(Object.create(null),${obj})` : `Object.create(null)`; + } + return obj; + } + } + const str = stringify2(value); + if (names.size) { + const params = []; + const statements = []; + const values = []; + names.forEach((name, thing) => { + params.push(name); + if (custom.has(thing)) { + values.push( + /** @type {string} */ + custom.get(thing) + ); + return; + } + if (is_primitive(thing)) { + values.push(stringify_primitive$1(thing)); + return; + } + const type = get_type(thing); + switch (type) { + case "Number": + case "String": + case "Boolean": + values.push(`Object(${stringify2(thing.valueOf())})`); + break; + case "RegExp": + values.push(thing.toString()); + break; + case "Date": + values.push(`new Date(${thing.getTime()})`); + break; + case "Array": + values.push(`Array(${thing.length})`); + thing.forEach((v, i) => { + statements.push(`${name}[${i}]=${stringify2(v)}`); + }); + break; + case "Set": + values.push(`new Set`); + statements.push( + `${name}.${Array.from(thing).map((v) => `add(${stringify2(v)})`).join(".")}` + ); + break; + case "Map": + values.push(`new Map`); + statements.push( + `${name}.${Array.from(thing).map(([k, v]) => `set(${stringify2(k)}, ${stringify2(v)})`).join(".")}` + ); + break; + default: + values.push( + Object.getPrototypeOf(thing) === null ? "Object.create(null)" : "{}" + ); + Object.keys(thing).forEach((key2) => { + statements.push( + `${name}${safe_prop(key2)}=${stringify2(thing[key2])}` + ); + }); + } + }); + statements.push(`return ${str}`); + return `(function(${params.join(",")}){${statements.join( + ";" + )}}(${values.join(",")}))`; + } else { + return str; + } +} +function get_name(num) { + let name = ""; + do { + name = chars$1[num % chars$1.length] + name; + num = ~~(num / chars$1.length) - 1; + } while (num >= 0); + return reserved.test(name) ? `${name}0` : name; +} +function escape_unsafe_char(c) { + return escaped[c] || c; +} +function escape_unsafe_chars(str) { + return str.replace(unsafe_chars, escape_unsafe_char); +} +function safe_key(key2) { + return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key2) ? key2 : escape_unsafe_chars(JSON.stringify(key2)); +} +function safe_prop(key2) { + return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key2) ? `.${key2}` : `[${escape_unsafe_chars(JSON.stringify(key2))}]`; +} +function stringify_primitive$1(thing) { + if (typeof thing === "string") + return stringify_string(thing); + if (thing === void 0) + return "void 0"; + if (thing === 0 && 1 / thing < 0) + return "-0"; + const str = String(thing); + if (typeof thing === "number") + return str.replace(/^(-)?0\./, "$1."); + if (typeof thing === "bigint") + return thing + "n"; + return str; +} +const UNDEFINED = -1; +const HOLE = -2; +const NAN = -3; +const POSITIVE_INFINITY = -4; +const NEGATIVE_INFINITY = -5; +const NEGATIVE_ZERO = -6; +function stringify(value, reducers) { + const stringified = []; + const indexes = /* @__PURE__ */ new Map(); + const custom = []; + for (const key2 in reducers) { + custom.push({ key: key2, fn: reducers[key2] }); + } + const keys = []; + let p = 0; + function flatten(thing) { + if (typeof thing === "function") { + throw new DevalueError(`Cannot stringify a function`, keys); + } + if (indexes.has(thing)) + return indexes.get(thing); + if (thing === void 0) + return UNDEFINED; + if (Number.isNaN(thing)) + return NAN; + if (thing === Infinity) + return POSITIVE_INFINITY; + if (thing === -Infinity) + return NEGATIVE_INFINITY; + if (thing === 0 && 1 / thing < 0) + return NEGATIVE_ZERO; + const index2 = p++; + indexes.set(thing, index2); + for (const { key: key2, fn } of custom) { + const value2 = fn(thing); + if (value2) { + stringified[index2] = `["${key2}",${flatten(value2)}]`; + return index2; + } + } + let str = ""; + if (is_primitive(thing)) { + str = stringify_primitive(thing); + } else { + const type = get_type(thing); + switch (type) { + case "Number": + case "String": + case "Boolean": + str = `["Object",${stringify_primitive(thing)}]`; + break; + case "BigInt": + str = `["BigInt",${thing}]`; + break; + case "Date": + str = `["Date","${thing.toISOString()}"]`; + break; + case "RegExp": + const { source, flags } = thing; + str = flags ? `["RegExp",${stringify_string(source)},"${flags}"]` : `["RegExp",${stringify_string(source)}]`; + break; + case "Array": + str = "["; + for (let i = 0; i < thing.length; i += 1) { + if (i > 0) + str += ","; + if (i in thing) { + keys.push(`[${i}]`); + str += flatten(thing[i]); + keys.pop(); + } else { + str += HOLE; + } + } + str += "]"; + break; + case "Set": + str = '["Set"'; + for (const value2 of thing) { + str += `,${flatten(value2)}`; + } + str += "]"; + break; + case "Map": + str = '["Map"'; + for (const [key2, value2] of thing) { + keys.push( + `.get(${is_primitive(key2) ? stringify_primitive(key2) : "..."})` + ); + str += `,${flatten(key2)},${flatten(value2)}`; + } + str += "]"; + break; + default: + if (!is_plain_object(thing)) { + throw new DevalueError( + `Cannot stringify arbitrary non-POJOs`, + keys + ); + } + if (Object.getOwnPropertySymbols(thing).length > 0) { + throw new DevalueError( + `Cannot stringify POJOs with symbolic keys`, + keys + ); + } + if (Object.getPrototypeOf(thing) === null) { + str = '["null"'; + for (const key2 in thing) { + keys.push(`.${key2}`); + str += `,${stringify_string(key2)},${flatten(thing[key2])}`; + keys.pop(); + } + str += "]"; + } else { + str = "{"; + let started = false; + for (const key2 in thing) { + if (started) + str += ","; + started = true; + keys.push(`.${key2}`); + str += `${stringify_string(key2)}:${flatten(thing[key2])}`; + keys.pop(); + } + str += "}"; + } + } + } + stringified[index2] = str; + return index2; + } + const index = flatten(value); + if (index < 0) + return `${index}`; + return `[${stringified.join(",")}]`; +} +function stringify_primitive(thing) { + const type = typeof thing; + if (type === "string") + return stringify_string(thing); + if (thing instanceof String) + return stringify_string(thing.toString()); + if (thing === void 0) + return UNDEFINED.toString(); + if (thing === 0 && 1 / thing < 0) + return NEGATIVE_ZERO.toString(); + if (type === "bigint") + return `["BigInt","${thing}"]`; + return String(thing); +} +function is_action_json_request(event) { + const accept = negotiate(event.request.headers.get("accept") ?? "*/*", [ + "application/json", + "text/html" + ]); + return accept === "application/json" && event.request.method === "POST"; +} +async function handle_action_json_request(event, options2, server) { + const actions = server?.actions; + if (!actions) { + const no_actions_error = error(405, "POST method not allowed. No actions exist for this page"); + return action_json( + { + type: "error", + error: await handle_error_and_jsonify(event, options2, no_actions_error) + }, + { + status: no_actions_error.status, + headers: { + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405 + // "The server must generate an Allow header field in a 405 status code response" + allow: "GET" + } + } + ); + } + check_named_default_separate(actions); + try { + const data = await call_action(event, actions); + if (false) + ; + if (data instanceof ActionFailure) { + return action_json({ + type: "failure", + status: data.status, + // @ts-expect-error we assign a string to what is supposed to be an object. That's ok + // because we don't use the object outside, and this way we have better code navigation + // through knowing where the related interface is used. + data: stringify_action_response( + data.data, + /** @type {string} */ + event.route.id + ) + }); + } else { + return action_json({ + type: "success", + status: data ? 200 : 204, + // @ts-expect-error see comment above + data: stringify_action_response( + data, + /** @type {string} */ + event.route.id + ) + }); + } + } catch (e) { + const err = normalize_error(e); + if (err instanceof Redirect) { + return action_json_redirect(err); + } + return action_json( + { + type: "error", + error: await handle_error_and_jsonify(event, options2, check_incorrect_fail_use(err)) + }, + { + status: err instanceof HttpError ? err.status : 500 + } + ); + } +} +function check_incorrect_fail_use(error2) { + return error2 instanceof ActionFailure ? new Error('Cannot "throw fail()". Use "return fail()"') : error2; +} +function action_json_redirect(redirect) { + return action_json({ + type: "redirect", + status: redirect.status, + location: redirect.location + }); +} +function action_json(data, init2) { + return json(data, init2); +} +function is_action_request(event) { + return event.request.method === "POST"; +} +async function handle_action_request(event, server) { + const actions = server?.actions; + if (!actions) { + event.setHeaders({ + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405 + // "The server must generate an Allow header field in a 405 status code response" + allow: "GET" + }); + return { + type: "error", + error: error(405, "POST method not allowed. No actions exist for this page") + }; + } + check_named_default_separate(actions); + try { + const data = await call_action(event, actions); + if (false) + ; + if (data instanceof ActionFailure) { + return { + type: "failure", + status: data.status, + data: data.data + }; + } else { + return { + type: "success", + status: 200, + // @ts-expect-error this will be removed upon serialization, so `undefined` is the same as omission + data + }; + } + } catch (e) { + const err = normalize_error(e); + if (err instanceof Redirect) { + return { + type: "redirect", + status: err.status, + location: err.location + }; + } + return { + type: "error", + error: check_incorrect_fail_use(err) + }; + } +} +function check_named_default_separate(actions) { + if (actions.default && Object.keys(actions).length > 1) { + throw new Error( + "When using named actions, the default action cannot be used. See the docs for more info: https://kit.svelte.dev/docs/form-actions#named-actions" + ); + } +} +async function call_action(event, actions) { + const url = new URL(event.request.url); + let name = "default"; + for (const param of url.searchParams) { + if (param[0].startsWith("/")) { + name = param[0].slice(1); + if (name === "default") { + throw new Error('Cannot use reserved action name "default"'); + } + break; + } + } + const action = actions[name]; + if (!action) { + throw new Error(`No action with name '${name}' found`); + } + if (!is_form_content_type(event.request)) { + throw new Error( + `Actions expect form-encoded data (received ${event.request.headers.get("content-type")})` + ); + } + return action(event); +} +function validate_action_return(data) { + if (data instanceof Redirect) { + throw new Error("Cannot `return redirect(...)` — use `throw redirect(...)` instead"); + } + if (data instanceof HttpError) { + throw new Error( + "Cannot `return error(...)` — use `throw error(...)` or `return fail(...)` instead" + ); + } +} +function uneval_action_response(data, route_id) { + return try_deserialize(data, uneval, route_id); +} +function stringify_action_response(data, route_id) { + return try_deserialize(data, stringify, route_id); +} +function try_deserialize(data, fn, route_id) { + try { + return fn(data); + } catch (e) { + const error2 = ( + /** @type {any} */ + e + ); + if ("path" in error2) { + let message = `Data returned from action inside ${route_id} is not serializable: ${error2.message}`; + if (error2.path !== "") + message += ` (data.${error2.path})`; + throw new Error(message); + } + throw error2; + } +} +async function unwrap_promises(object) { + for (const key2 in object) { + if (typeof object[key2]?.then === "function") { + return Object.fromEntries( + await Promise.all(Object.entries(object).map(async ([key3, value]) => [key3, await value])) + ); + } + } + return object; +} +const INVALIDATED_PARAM = "x-sveltekit-invalidated"; +const TRAILING_SLASH_PARAM = "x-sveltekit-trailing-slash"; +async function load_server_data({ + event, + state, + node, + parent, + // TODO 2.0: Remove this + track_server_fetches +}) { + if (!node?.server) + return null; + const uses = { + dependencies: /* @__PURE__ */ new Set(), + params: /* @__PURE__ */ new Set(), + parent: false, + route: false, + url: false + }; + const url = make_trackable(event.url, () => { + uses.url = true; + }); + if (state.prerendering) { + disable_search(url); + } + const result = await node.server.load?.call(null, { + ...event, + fetch: (info, init2) => { + const url2 = new URL(info instanceof Request ? info.url : info, event.url); + if (track_server_fetches) { + uses.dependencies.add(url2.href); + } + return event.fetch(info, init2); + }, + /** @param {string[]} deps */ + depends: (...deps) => { + for (const dep of deps) { + const { href } = new URL(dep, event.url); + uses.dependencies.add(href); + } + }, + params: new Proxy(event.params, { + get: (target, key2) => { + uses.params.add(key2); + return target[ + /** @type {string} */ + key2 + ]; + } + }), + parent: async () => { + uses.parent = true; + return parent(); + }, + route: new Proxy(event.route, { + get: (target, key2) => { + uses.route = true; + return target[ + /** @type {'id'} */ + key2 + ]; + } + }), + url + }); + const data = result ? await unwrap_promises(result) : null; + return { + type: "data", + data, + uses, + slash: node.server.trailingSlash + }; +} +async function load_data({ + event, + fetched, + node, + parent, + server_data_promise, + state, + resolve_opts, + csr +}) { + const server_data_node = await server_data_promise; + if (!node?.universal?.load) { + return server_data_node?.data ?? null; + } + const result = await node.universal.load.call(null, { + url: event.url, + params: event.params, + data: server_data_node?.data ?? null, + route: event.route, + fetch: create_universal_fetch(event, state, fetched, csr, resolve_opts), + setHeaders: event.setHeaders, + depends: () => { + }, + parent + }); + const data = result ? await unwrap_promises(result) : null; + return data; +} +function create_universal_fetch(event, state, fetched, csr, resolve_opts) { + return async (input, init2) => { + const cloned_body = input instanceof Request && input.body ? input.clone().body : null; + const cloned_headers = input instanceof Request && [...input.headers].length ? new Headers(input.headers) : init2?.headers; + let response = await event.fetch(input, init2); + const url = new URL(input instanceof Request ? input.url : input, event.url); + const same_origin = url.origin === event.url.origin; + let dependency; + if (same_origin) { + if (state.prerendering) { + dependency = { response, body: null }; + state.prerendering.dependencies.set(url.pathname, dependency); + } + } else { + const mode = input instanceof Request ? input.mode : init2?.mode ?? "cors"; + if (mode === "no-cors") { + response = new Response("", { + status: response.status, + statusText: response.statusText, + headers: response.headers + }); + } else { + const acao = response.headers.get("access-control-allow-origin"); + if (!acao || acao !== event.url.origin && acao !== "*") { + throw new Error( + `CORS error: ${acao ? "Incorrect" : "No"} 'Access-Control-Allow-Origin' header is present on the requested resource` + ); + } + } + } + const proxy = new Proxy(response, { + get(response2, key2, _receiver) { + async function text2() { + const body = await response2.text(); + if (!body || typeof body === "string") { + const status_number = Number(response2.status); + if (isNaN(status_number)) { + throw new Error( + `response.status is not a number. value: "${response2.status}" type: ${typeof response2.status}` + ); + } + fetched.push({ + url: same_origin ? url.href.slice(event.url.origin.length) : url.href, + method: event.request.method, + request_body: ( + /** @type {string | ArrayBufferView | undefined} */ + input instanceof Request && cloned_body ? await stream_to_string(cloned_body) : init2?.body + ), + request_headers: cloned_headers, + response_body: body, + response: response2 + }); + } + if (dependency) { + dependency.body = body; + } + return body; + } + if (key2 === "arrayBuffer") { + return async () => { + const buffer = await response2.arrayBuffer(); + if (dependency) { + dependency.body = new Uint8Array(buffer); + } + return buffer; + }; + } + if (key2 === "text") { + return text2; + } + if (key2 === "json") { + return async () => { + return JSON.parse(await text2()); + }; + } + return Reflect.get(response2, key2, response2); + } + }); + if (csr) { + const get = response.headers.get; + response.headers.get = (key2) => { + const lower = key2.toLowerCase(); + const value = get.call(response.headers, lower); + if (value && !lower.startsWith("x-sveltekit-")) { + const included = resolve_opts.filterSerializedResponseHeaders(lower, value); + if (!included) { + throw new Error( + `Failed to get response header "${lower}" — it must be included by the \`filterSerializedResponseHeaders\` option: https://kit.svelte.dev/docs/hooks#server-hooks-handle (at ${event.route.id})` + ); + } + } + return value; + }; + } + return proxy; + }; +} +async function stream_to_string(stream) { + let result = ""; + const reader = stream.getReader(); + const decoder = new TextDecoder(); + while (true) { + const { done, value } = await reader.read(); + if (done) { + break; + } + result += decoder.decode(value); + } + return result; +} +const subscriber_queue = []; +function readable(value, start) { + return { + subscribe: writable(value, start).subscribe + }; +} +function writable(value, start = noop) { + let stop; + const subscribers = /* @__PURE__ */ new Set(); + function set(new_value) { + if (safe_not_equal(value, new_value)) { + value = new_value; + if (stop) { + const run_queue = !subscriber_queue.length; + for (const subscriber of subscribers) { + subscriber[1](); + subscriber_queue.push(subscriber, value); + } + if (run_queue) { + for (let i = 0; i < subscriber_queue.length; i += 2) { + subscriber_queue[i][0](subscriber_queue[i + 1]); + } + subscriber_queue.length = 0; + } + } + } + } + function update(fn) { + set(fn(value)); + } + function subscribe(run, invalidate = noop) { + const subscriber = [run, invalidate]; + subscribers.add(subscriber); + if (subscribers.size === 1) { + stop = start(set) || noop; + } + run(value); + return () => { + subscribers.delete(subscriber); + if (subscribers.size === 0 && stop) { + stop(); + stop = null; + } + }; + } + return { set, update, subscribe }; +} +function hash(...values) { + let hash2 = 5381; + for (const value of values) { + if (typeof value === "string") { + let i = value.length; + while (i) + hash2 = hash2 * 33 ^ value.charCodeAt(--i); + } else if (ArrayBuffer.isView(value)) { + const buffer = new Uint8Array(value.buffer, value.byteOffset, value.byteLength); + let i = buffer.length; + while (i) + hash2 = hash2 * 33 ^ buffer[--i]; + } else { + throw new TypeError("value must be a string or TypedArray"); + } + } + return (hash2 >>> 0).toString(36); +} +const escape_html_attr_dict = { + "&": "&", + '"': """ +}; +const escape_html_attr_regex = new RegExp( + // special characters + `[${Object.keys(escape_html_attr_dict).join("")}]|[\\ud800-\\udbff](?![\\udc00-\\udfff])|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\udc00-\\udfff]`, + "g" +); +function escape_html_attr(str) { + const escaped_str = str.replace(escape_html_attr_regex, (match) => { + if (match.length === 2) { + return match; + } + return escape_html_attr_dict[match] ?? `&#${match.charCodeAt(0)};`; + }); + return `"${escaped_str}"`; +} +const replacements = { + "<": "\\u003C", + "\u2028": "\\u2028", + "\u2029": "\\u2029" +}; +const pattern = new RegExp(`[${Object.keys(replacements).join("")}]`, "g"); +function serialize_data(fetched, filter, prerendering = false) { + const headers = {}; + let cache_control = null; + let age = null; + let varyAny = false; + for (const [key2, value] of fetched.response.headers) { + if (filter(key2, value)) { + headers[key2] = value; + } + if (key2 === "cache-control") + cache_control = value; + else if (key2 === "age") + age = value; + else if (key2 === "vary" && value.trim() === "*") + varyAny = true; + } + const payload = { + status: fetched.response.status, + statusText: fetched.response.statusText, + headers, + body: fetched.response_body + }; + const safe_payload = JSON.stringify(payload).replace(pattern, (match) => replacements[match]); + const attrs = [ + 'type="application/json"', + "data-sveltekit-fetched", + `data-url=${escape_html_attr(fetched.url)}` + ]; + if (fetched.request_headers || fetched.request_body) { + const values = []; + if (fetched.request_headers) { + values.push([...new Headers(fetched.request_headers)].join(",")); + } + if (fetched.request_body) { + values.push(fetched.request_body); + } + attrs.push(`data-hash="${hash(...values)}"`); + } + if (!prerendering && fetched.method === "GET" && cache_control && !varyAny) { + const match = /s-maxage=(\d+)/g.exec(cache_control) ?? /max-age=(\d+)/g.exec(cache_control); + if (match) { + const ttl = +match[1] - +(age ?? "0"); + attrs.push(`data-ttl="${ttl}"`); + } + } + return `