{"version":3,"file":"index.sQZhb_1p.mjs","sources":["../../node_modules/turbo-stream/dist/turbo-stream.mjs","../../node_modules/cookie/dist/index.js","../../node_modules/set-cookie-parser/lib/set-cookie.js","../../node_modules/react-router/dist/development/chunk-D52XG6IA.mjs"],"sourcesContent":["// src/utils.ts\nvar HOLE = -1;\nvar NAN = -2;\nvar NEGATIVE_INFINITY = -3;\nvar NEGATIVE_ZERO = -4;\nvar NULL = -5;\nvar POSITIVE_INFINITY = -6;\nvar UNDEFINED = -7;\nvar TYPE_BIGINT = \"B\";\nvar TYPE_DATE = \"D\";\nvar TYPE_ERROR = \"E\";\nvar TYPE_MAP = \"M\";\nvar TYPE_NULL_OBJECT = \"N\";\nvar TYPE_PROMISE = \"P\";\nvar TYPE_REGEXP = \"R\";\nvar TYPE_SET = \"S\";\nvar TYPE_SYMBOL = \"Y\";\nvar TYPE_URL = \"U\";\nvar TYPE_PREVIOUS_RESOLVED = \"Z\";\nvar Deferred = class {\n promise;\n resolve;\n reject;\n constructor() {\n this.promise = new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n};\nfunction createLineSplittingTransform() {\n const decoder = new TextDecoder();\n let leftover = \"\";\n return new TransformStream({\n transform(chunk, controller) {\n const str = decoder.decode(chunk, { stream: true });\n const parts = (leftover + str).split(\"\\n\");\n leftover = parts.pop() || \"\";\n for (const part of parts) {\n controller.enqueue(part);\n }\n },\n flush(controller) {\n if (leftover) {\n controller.enqueue(leftover);\n }\n }\n });\n}\n\n// src/flatten.ts\nfunction flatten(input) {\n const { indices } = this;\n const existing = indices.get(input);\n if (existing)\n return [existing];\n if (input === void 0)\n return UNDEFINED;\n if (input === null)\n return NULL;\n if (Number.isNaN(input))\n return NAN;\n if (input === Number.POSITIVE_INFINITY)\n return POSITIVE_INFINITY;\n if (input === Number.NEGATIVE_INFINITY)\n return NEGATIVE_INFINITY;\n if (input === 0 && 1 / input < 0)\n return NEGATIVE_ZERO;\n const index = this.index++;\n indices.set(input, index);\n stringify.call(this, input, index);\n return index;\n}\nfunction stringify(input, index) {\n const { deferred, plugins, postPlugins } = this;\n const str = this.stringified;\n const stack = [[input, index]];\n while (stack.length > 0) {\n const [input2, index2] = stack.pop();\n const partsForObj = (obj) => Object.keys(obj).map((k) => `\"_${flatten.call(this, k)}\":${flatten.call(this, obj[k])}`).join(\",\");\n let error = null;\n switch (typeof input2) {\n case \"boolean\":\n case \"number\":\n case \"string\":\n str[index2] = JSON.stringify(input2);\n break;\n case \"bigint\":\n str[index2] = `[\"${TYPE_BIGINT}\",\"${input2}\"]`;\n break;\n case \"symbol\": {\n const keyFor = Symbol.keyFor(input2);\n if (!keyFor) {\n error = new Error(\n \"Cannot encode symbol unless created with Symbol.for()\"\n );\n } else {\n str[index2] = `[\"${TYPE_SYMBOL}\",${JSON.stringify(keyFor)}]`;\n }\n break;\n }\n case \"object\": {\n if (!input2) {\n str[index2] = `${NULL}`;\n break;\n }\n const isArray = Array.isArray(input2);\n let pluginHandled = false;\n if (!isArray && plugins) {\n for (const plugin of plugins) {\n const pluginResult = plugin(input2);\n if (Array.isArray(pluginResult)) {\n pluginHandled = true;\n const [pluginIdentifier, ...rest] = pluginResult;\n str[index2] = `[${JSON.stringify(pluginIdentifier)}`;\n if (rest.length > 0) {\n str[index2] += `,${rest.map((v) => flatten.call(this, v)).join(\",\")}`;\n }\n str[index2] += \"]\";\n break;\n }\n }\n }\n if (!pluginHandled) {\n let result = isArray ? \"[\" : \"{\";\n if (isArray) {\n for (let i = 0; i < input2.length; i++)\n result += (i ? \",\" : \"\") + (i in input2 ? flatten.call(this, input2[i]) : HOLE);\n str[index2] = `${result}]`;\n } else if (input2 instanceof Date) {\n str[index2] = `[\"${TYPE_DATE}\",${input2.getTime()}]`;\n } else if (input2 instanceof URL) {\n str[index2] = `[\"${TYPE_URL}\",${JSON.stringify(input2.href)}]`;\n } else if (input2 instanceof RegExp) {\n str[index2] = `[\"${TYPE_REGEXP}\",${JSON.stringify(\n input2.source\n )},${JSON.stringify(input2.flags)}]`;\n } else if (input2 instanceof Set) {\n if (input2.size > 0) {\n str[index2] = `[\"${TYPE_SET}\",${[...input2].map((val) => flatten.call(this, val)).join(\",\")}]`;\n } else {\n str[index2] = `[\"${TYPE_SET}\"]`;\n }\n } else if (input2 instanceof Map) {\n if (input2.size > 0) {\n str[index2] = `[\"${TYPE_MAP}\",${[...input2].flatMap(([k, v]) => [\n flatten.call(this, k),\n flatten.call(this, v)\n ]).join(\",\")}]`;\n } else {\n str[index2] = `[\"${TYPE_MAP}\"]`;\n }\n } else if (input2 instanceof Promise) {\n str[index2] = `[\"${TYPE_PROMISE}\",${index2}]`;\n deferred[index2] = input2;\n } else if (input2 instanceof Error) {\n str[index2] = `[\"${TYPE_ERROR}\",${JSON.stringify(input2.message)}`;\n if (input2.name !== \"Error\") {\n str[index2] += `,${JSON.stringify(input2.name)}`;\n }\n str[index2] += \"]\";\n } else if (Object.getPrototypeOf(input2) === null) {\n str[index2] = `[\"${TYPE_NULL_OBJECT}\",{${partsForObj(input2)}}]`;\n } else if (isPlainObject(input2)) {\n str[index2] = `{${partsForObj(input2)}}`;\n } else {\n error = new Error(\"Cannot encode object with prototype\");\n }\n }\n break;\n }\n default: {\n const isArray = Array.isArray(input2);\n let pluginHandled = false;\n if (!isArray && plugins) {\n for (const plugin of plugins) {\n const pluginResult = plugin(input2);\n if (Array.isArray(pluginResult)) {\n pluginHandled = true;\n const [pluginIdentifier, ...rest] = pluginResult;\n str[index2] = `[${JSON.stringify(pluginIdentifier)}`;\n if (rest.length > 0) {\n str[index2] += `,${rest.map((v) => flatten.call(this, v)).join(\",\")}`;\n }\n str[index2] += \"]\";\n break;\n }\n }\n }\n if (!pluginHandled) {\n error = new Error(\"Cannot encode function or unexpected type\");\n }\n }\n }\n if (error) {\n let pluginHandled = false;\n if (postPlugins) {\n for (const plugin of postPlugins) {\n const pluginResult = plugin(input2);\n if (Array.isArray(pluginResult)) {\n pluginHandled = true;\n const [pluginIdentifier, ...rest] = pluginResult;\n str[index2] = `[${JSON.stringify(pluginIdentifier)}`;\n if (rest.length > 0) {\n str[index2] += `,${rest.map((v) => flatten.call(this, v)).join(\",\")}`;\n }\n str[index2] += \"]\";\n break;\n }\n }\n }\n if (!pluginHandled) {\n throw error;\n }\n }\n }\n}\nvar objectProtoNames = Object.getOwnPropertyNames(Object.prototype).sort().join(\"\\0\");\nfunction isPlainObject(thing) {\n const proto = Object.getPrototypeOf(thing);\n return proto === Object.prototype || proto === null || Object.getOwnPropertyNames(proto).sort().join(\"\\0\") === objectProtoNames;\n}\n\n// src/unflatten.ts\nvar globalObj = typeof window !== \"undefined\" ? window : typeof globalThis !== \"undefined\" ? globalThis : void 0;\nfunction unflatten(parsed) {\n const { hydrated, values } = this;\n if (typeof parsed === \"number\")\n return hydrate.call(this, parsed);\n if (!Array.isArray(parsed) || !parsed.length)\n throw new SyntaxError();\n const startIndex = values.length;\n for (const value of parsed) {\n values.push(value);\n }\n hydrated.length = values.length;\n return hydrate.call(this, startIndex);\n}\nfunction hydrate(index) {\n const { hydrated, values, deferred, plugins } = this;\n let result;\n const stack = [\n [\n index,\n (v) => {\n result = v;\n }\n ]\n ];\n let postRun = [];\n while (stack.length > 0) {\n const [index2, set] = stack.pop();\n switch (index2) {\n case UNDEFINED:\n set(void 0);\n continue;\n case NULL:\n set(null);\n continue;\n case NAN:\n set(NaN);\n continue;\n case POSITIVE_INFINITY:\n set(Infinity);\n continue;\n case NEGATIVE_INFINITY:\n set(-Infinity);\n continue;\n case NEGATIVE_ZERO:\n set(-0);\n continue;\n }\n if (hydrated[index2]) {\n set(hydrated[index2]);\n continue;\n }\n const value = values[index2];\n if (!value || typeof value !== \"object\") {\n hydrated[index2] = value;\n set(value);\n continue;\n }\n if (Array.isArray(value)) {\n if (typeof value[0] === \"string\") {\n const [type, b, c] = value;\n switch (type) {\n case TYPE_DATE:\n set(hydrated[index2] = new Date(b));\n continue;\n case TYPE_URL:\n set(hydrated[index2] = new URL(b));\n continue;\n case TYPE_BIGINT:\n set(hydrated[index2] = BigInt(b));\n continue;\n case TYPE_REGEXP:\n set(hydrated[index2] = new RegExp(b, c));\n continue;\n case TYPE_SYMBOL:\n set(hydrated[index2] = Symbol.for(b));\n continue;\n case TYPE_SET:\n const newSet = /* @__PURE__ */ new Set();\n hydrated[index2] = newSet;\n for (let i = 1; i < value.length; i++)\n stack.push([\n value[i],\n (v) => {\n newSet.add(v);\n }\n ]);\n set(newSet);\n continue;\n case TYPE_MAP:\n const map = /* @__PURE__ */ new Map();\n hydrated[index2] = map;\n for (let i = 1; i < value.length; i += 2) {\n const r = [];\n stack.push([\n value[i + 1],\n (v) => {\n r[1] = v;\n }\n ]);\n stack.push([\n value[i],\n (k) => {\n r[0] = k;\n }\n ]);\n postRun.push(() => {\n map.set(r[0], r[1]);\n });\n }\n set(map);\n continue;\n case TYPE_NULL_OBJECT:\n const obj = /* @__PURE__ */ Object.create(null);\n hydrated[index2] = obj;\n for (const key of Object.keys(b).reverse()) {\n const r = [];\n stack.push([\n b[key],\n (v) => {\n r[1] = v;\n }\n ]);\n stack.push([\n Number(key.slice(1)),\n (k) => {\n r[0] = k;\n }\n ]);\n postRun.push(() => {\n obj[r[0]] = r[1];\n });\n }\n set(obj);\n continue;\n case TYPE_PROMISE:\n if (hydrated[b]) {\n set(hydrated[index2] = hydrated[b]);\n } else {\n const d = new Deferred();\n deferred[b] = d;\n set(hydrated[index2] = d.promise);\n }\n continue;\n case TYPE_ERROR:\n const [, message, errorType] = value;\n let error = errorType && globalObj && globalObj[errorType] ? new globalObj[errorType](message) : new Error(message);\n hydrated[index2] = error;\n set(error);\n continue;\n case TYPE_PREVIOUS_RESOLVED:\n set(hydrated[index2] = hydrated[b]);\n continue;\n default:\n if (Array.isArray(plugins)) {\n const r = [];\n const vals = value.slice(1);\n for (let i = 0; i < vals.length; i++) {\n const v = vals[i];\n stack.push([\n v,\n (v2) => {\n r[i] = v2;\n }\n ]);\n }\n postRun.push(() => {\n for (const plugin of plugins) {\n const result2 = plugin(value[0], ...r);\n if (result2) {\n set(hydrated[index2] = result2.value);\n return;\n }\n }\n throw new SyntaxError();\n });\n continue;\n }\n throw new SyntaxError();\n }\n } else {\n const array = [];\n hydrated[index2] = array;\n for (let i = 0; i < value.length; i++) {\n const n = value[i];\n if (n !== HOLE) {\n stack.push([\n n,\n (v) => {\n array[i] = v;\n }\n ]);\n }\n }\n set(array);\n continue;\n }\n } else {\n const object = {};\n hydrated[index2] = object;\n for (const key of Object.keys(value).reverse()) {\n const r = [];\n stack.push([\n value[key],\n (v) => {\n r[1] = v;\n }\n ]);\n stack.push([\n Number(key.slice(1)),\n (k) => {\n r[0] = k;\n }\n ]);\n postRun.push(() => {\n object[r[0]] = r[1];\n });\n }\n set(object);\n continue;\n }\n }\n while (postRun.length > 0) {\n postRun.pop()();\n }\n return result;\n}\n\n// src/turbo-stream.ts\nasync function decode(readable, options) {\n const { plugins } = options ?? {};\n const done = new Deferred();\n const reader = readable.pipeThrough(createLineSplittingTransform()).getReader();\n const decoder = {\n values: [],\n hydrated: [],\n deferred: {},\n plugins\n };\n const decoded = await decodeInitial.call(decoder, reader);\n let donePromise = done.promise;\n if (decoded.done) {\n done.resolve();\n } else {\n donePromise = decodeDeferred.call(decoder, reader).then(done.resolve).catch((reason) => {\n for (const deferred of Object.values(decoder.deferred)) {\n deferred.reject(reason);\n }\n done.reject(reason);\n });\n }\n return {\n done: donePromise.then(() => reader.closed),\n value: decoded.value\n };\n}\nasync function decodeInitial(reader) {\n const read = await reader.read();\n if (!read.value) {\n throw new SyntaxError();\n }\n let line;\n try {\n line = JSON.parse(read.value);\n } catch (reason) {\n throw new SyntaxError();\n }\n return {\n done: read.done,\n value: unflatten.call(this, line)\n };\n}\nasync function decodeDeferred(reader) {\n let read = await reader.read();\n while (!read.done) {\n if (!read.value)\n continue;\n const line = read.value;\n switch (line[0]) {\n case TYPE_PROMISE: {\n const colonIndex = line.indexOf(\":\");\n const deferredId = Number(line.slice(1, colonIndex));\n const deferred = this.deferred[deferredId];\n if (!deferred) {\n throw new Error(`Deferred ID ${deferredId} not found in stream`);\n }\n const lineData = line.slice(colonIndex + 1);\n let jsonLine;\n try {\n jsonLine = JSON.parse(lineData);\n } catch (reason) {\n throw new SyntaxError();\n }\n const value = unflatten.call(this, jsonLine);\n deferred.resolve(value);\n break;\n }\n case TYPE_ERROR: {\n const colonIndex = line.indexOf(\":\");\n const deferredId = Number(line.slice(1, colonIndex));\n const deferred = this.deferred[deferredId];\n if (!deferred) {\n throw new Error(`Deferred ID ${deferredId} not found in stream`);\n }\n const lineData = line.slice(colonIndex + 1);\n let jsonLine;\n try {\n jsonLine = JSON.parse(lineData);\n } catch (reason) {\n throw new SyntaxError();\n }\n const value = unflatten.call(this, jsonLine);\n deferred.reject(value);\n break;\n }\n default:\n throw new SyntaxError();\n }\n read = await reader.read();\n }\n}\nfunction encode(input, options) {\n const { plugins, postPlugins, signal } = options ?? {};\n const encoder = {\n deferred: {},\n index: 0,\n indices: /* @__PURE__ */ new Map(),\n stringified: [],\n plugins,\n postPlugins,\n signal\n };\n const textEncoder = new TextEncoder();\n let lastSentIndex = 0;\n const readable = new ReadableStream({\n async start(controller) {\n const id = flatten.call(encoder, input);\n if (Array.isArray(id)) {\n throw new Error(\"This should never happen\");\n }\n if (id < 0) {\n controller.enqueue(textEncoder.encode(`${id}\n`));\n } else {\n controller.enqueue(\n textEncoder.encode(`[${encoder.stringified.join(\",\")}]\n`)\n );\n lastSentIndex = encoder.stringified.length - 1;\n }\n const seenPromises = /* @__PURE__ */ new WeakSet();\n while (Object.keys(encoder.deferred).length > 0) {\n for (const [deferredId, deferred] of Object.entries(encoder.deferred)) {\n if (seenPromises.has(deferred))\n continue;\n seenPromises.add(\n encoder.deferred[Number(deferredId)] = raceSignal(\n deferred,\n encoder.signal\n ).then(\n (resolved) => {\n const id2 = flatten.call(encoder, resolved);\n if (Array.isArray(id2)) {\n controller.enqueue(\n textEncoder.encode(\n `${TYPE_PROMISE}${deferredId}:[[\"${TYPE_PREVIOUS_RESOLVED}\",${id2[0]}]]\n`\n )\n );\n encoder.index++;\n lastSentIndex++;\n } else if (id2 < 0) {\n controller.enqueue(\n textEncoder.encode(`${TYPE_PROMISE}${deferredId}:${id2}\n`)\n );\n } else {\n const values = encoder.stringified.slice(lastSentIndex + 1).join(\",\");\n controller.enqueue(\n textEncoder.encode(\n `${TYPE_PROMISE}${deferredId}:[${values}]\n`\n )\n );\n lastSentIndex = encoder.stringified.length - 1;\n }\n },\n (reason) => {\n if (!reason || typeof reason !== \"object\" || !(reason instanceof Error)) {\n reason = new Error(\"An unknown error occurred\");\n }\n const id2 = flatten.call(encoder, reason);\n if (Array.isArray(id2)) {\n controller.enqueue(\n textEncoder.encode(\n `${TYPE_ERROR}${deferredId}:[[\"${TYPE_PREVIOUS_RESOLVED}\",${id2[0]}]]\n`\n )\n );\n encoder.index++;\n lastSentIndex++;\n } else if (id2 < 0) {\n controller.enqueue(\n textEncoder.encode(`${TYPE_ERROR}${deferredId}:${id2}\n`)\n );\n } else {\n const values = encoder.stringified.slice(lastSentIndex + 1).join(\",\");\n controller.enqueue(\n textEncoder.encode(\n `${TYPE_ERROR}${deferredId}:[${values}]\n`\n )\n );\n lastSentIndex = encoder.stringified.length - 1;\n }\n }\n ).finally(() => {\n delete encoder.deferred[Number(deferredId)];\n })\n );\n }\n await Promise.race(Object.values(encoder.deferred));\n }\n await Promise.all(Object.values(encoder.deferred));\n controller.close();\n }\n });\n return readable;\n}\nfunction raceSignal(promise, signal) {\n if (!signal)\n return promise;\n if (signal.aborted)\n return Promise.reject(signal.reason || new Error(\"Signal was aborted.\"));\n const abort = new Promise((resolve, reject) => {\n signal.addEventListener(\"abort\", (event) => {\n reject(signal.reason || new Error(\"Signal was aborted.\"));\n });\n promise.then(resolve).catch(reject);\n });\n abort.catch(() => {\n });\n return Promise.race([abort, promise]);\n}\nexport {\n decode,\n encode\n};\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.parse = parse;\nexports.serialize = serialize;\n/**\n * RegExp to match cookie-name in RFC 6265 sec 4.1.1\n * This refers out to the obsoleted definition of token in RFC 2616 sec 2.2\n * which has been replaced by the token definition in RFC 7230 appendix B.\n *\n * cookie-name = token\n * token = 1*tchar\n * tchar = \"!\" / \"#\" / \"$\" / \"%\" / \"&\" / \"'\" /\n * \"*\" / \"+\" / \"-\" / \".\" / \"^\" / \"_\" /\n * \"`\" / \"|\" / \"~\" / DIGIT / ALPHA\n *\n * Note: Allowing more characters - https://github.com/jshttp/cookie/issues/191\n * Allow same range as cookie value, except `=`, which delimits end of name.\n */\nconst cookieNameRegExp = /^[\\u0021-\\u003A\\u003C\\u003E-\\u007E]+$/;\n/**\n * RegExp to match cookie-value in RFC 6265 sec 4.1.1\n *\n * cookie-value = *cookie-octet / ( DQUOTE *cookie-octet DQUOTE )\n * cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E\n * ; US-ASCII characters excluding CTLs,\n * ; whitespace DQUOTE, comma, semicolon,\n * ; and backslash\n *\n * Allowing more characters: https://github.com/jshttp/cookie/issues/191\n * Comma, backslash, and DQUOTE are not part of the parsing algorithm.\n */\nconst cookieValueRegExp = /^[\\u0021-\\u003A\\u003C-\\u007E]*$/;\n/**\n * RegExp to match domain-value in RFC 6265 sec 4.1.1\n *\n * domain-value = \n * ; defined in [RFC1034], Section 3.5, as\n * ; enhanced by [RFC1123], Section 2.1\n * =