UNPKG

voyagesdk-ts

Version:
1,464 lines (1,431 loc) 209 kB
var __create = Object.create; var __getProtoOf = Object.getPrototypeOf; var __defProp = Object.defineProperty; var __getOwnPropNames = Object.getOwnPropertyNames; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __hasOwnProp = Object.prototype.hasOwnProperty; var __toESM = (mod, isNodeMode, target) => { target = mod != null ? __create(__getProtoOf(mod)) : {}; const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target; for (let key of __getOwnPropNames(mod)) if (!__hasOwnProp.call(to, key)) __defProp(to, key, { get: () => mod[key], enumerable: true }); return to; }; var __moduleCache = /* @__PURE__ */ new WeakMap; var __toCommonJS = (from) => { var entry = __moduleCache.get(from), desc; if (entry) return entry; entry = __defProp({}, "__esModule", { value: true }); if (from && typeof from === "object" || typeof from === "function") __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable })); __moduleCache.set(from, entry); return entry; }; var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports); var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true, configurable: true, set: (newValue) => all[name] = () => newValue }); }; var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res); // node_modules/@supabase/node-fetch/browser.js var exports_browser = {}; __export(exports_browser, { fetch: () => fetch2, default: () => browser_default, Response: () => Response2, Request: () => Request2, Headers: () => Headers2 }); var getGlobal = function() { if (typeof self !== "undefined") { return self; } if (typeof window !== "undefined") { return window; } if (typeof global !== "undefined") { return global; } throw new Error("unable to locate global object"); }, globalObject, fetch2, browser_default, Headers2, Request2, Response2; var init_browser = __esm(() => { globalObject = getGlobal(); fetch2 = globalObject.fetch; browser_default = globalObject.fetch.bind(globalObject); Headers2 = globalObject.Headers; Request2 = globalObject.Request; Response2 = globalObject.Response; }); // node_modules/@supabase/postgrest-js/dist/cjs/PostgrestError.js var require_PostgrestError = __commonJS((exports2) => { Object.defineProperty(exports2, "__esModule", { value: true }); class PostgrestError extends Error { constructor(context) { super(context.message); this.name = "PostgrestError"; this.details = context.details; this.hint = context.hint; this.code = context.code; } } exports2.default = PostgrestError; }); // node_modules/@supabase/postgrest-js/dist/cjs/PostgrestBuilder.js var require_PostgrestBuilder = __commonJS((exports2) => { var __importDefault = exports2 && exports2.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { default: mod }; }; Object.defineProperty(exports2, "__esModule", { value: true }); var node_fetch_1 = __importDefault((init_browser(), __toCommonJS(exports_browser))); var PostgrestError_1 = __importDefault(require_PostgrestError()); class PostgrestBuilder { constructor(builder) { this.shouldThrowOnError = false; this.method = builder.method; this.url = builder.url; this.headers = builder.headers; this.schema = builder.schema; this.body = builder.body; this.shouldThrowOnError = builder.shouldThrowOnError; this.signal = builder.signal; this.isMaybeSingle = builder.isMaybeSingle; if (builder.fetch) { this.fetch = builder.fetch; } else if (typeof fetch === "undefined") { this.fetch = node_fetch_1.default; } else { this.fetch = fetch; } } throwOnError() { this.shouldThrowOnError = true; return this; } setHeader(name, value) { this.headers = Object.assign({}, this.headers); this.headers[name] = value; return this; } then(onfulfilled, onrejected) { if (this.schema === undefined) { } else if (["GET", "HEAD"].includes(this.method)) { this.headers["Accept-Profile"] = this.schema; } else { this.headers["Content-Profile"] = this.schema; } if (this.method !== "GET" && this.method !== "HEAD") { this.headers["Content-Type"] = "application/json"; } const _fetch = this.fetch; let res = _fetch(this.url.toString(), { method: this.method, headers: this.headers, body: JSON.stringify(this.body), signal: this.signal }).then(async (res2) => { var _a, _b, _c; let error = null; let data = null; let count = null; let status = res2.status; let statusText = res2.statusText; if (res2.ok) { if (this.method !== "HEAD") { const body = await res2.text(); if (body === "") { } else if (this.headers["Accept"] === "text/csv") { data = body; } else if (this.headers["Accept"] && this.headers["Accept"].includes("application/vnd.pgrst.plan+text")) { data = body; } else { data = JSON.parse(body); } } const countHeader = (_a = this.headers["Prefer"]) === null || _a === undefined ? undefined : _a.match(/count=(exact|planned|estimated)/); const contentRange = (_b = res2.headers.get("content-range")) === null || _b === undefined ? undefined : _b.split("/"); if (countHeader && contentRange && contentRange.length > 1) { count = parseInt(contentRange[1]); } if (this.isMaybeSingle && this.method === "GET" && Array.isArray(data)) { if (data.length > 1) { error = { code: "PGRST116", details: `Results contain ${data.length} rows, application/vnd.pgrst.object+json requires 1 row`, hint: null, message: "JSON object requested, multiple (or no) rows returned" }; data = null; count = null; status = 406; statusText = "Not Acceptable"; } else if (data.length === 1) { data = data[0]; } else { data = null; } } } else { const body = await res2.text(); try { error = JSON.parse(body); if (Array.isArray(error) && res2.status === 404) { data = []; error = null; status = 200; statusText = "OK"; } } catch (_d) { if (res2.status === 404 && body === "") { status = 204; statusText = "No Content"; } else { error = { message: body }; } } if (error && this.isMaybeSingle && ((_c = error === null || error === undefined ? undefined : error.details) === null || _c === undefined ? undefined : _c.includes("0 rows"))) { error = null; status = 200; statusText = "OK"; } if (error && this.shouldThrowOnError) { throw new PostgrestError_1.default(error); } } const postgrestResponse = { error, data, count, status, statusText }; return postgrestResponse; }); if (!this.shouldThrowOnError) { res = res.catch((fetchError) => { var _a, _b, _c; return { error: { message: `${(_a = fetchError === null || fetchError === undefined ? undefined : fetchError.name) !== null && _a !== undefined ? _a : "FetchError"}: ${fetchError === null || fetchError === undefined ? undefined : fetchError.message}`, details: `${(_b = fetchError === null || fetchError === undefined ? undefined : fetchError.stack) !== null && _b !== undefined ? _b : ""}`, hint: "", code: `${(_c = fetchError === null || fetchError === undefined ? undefined : fetchError.code) !== null && _c !== undefined ? _c : ""}` }, data: null, count: null, status: 0, statusText: "" }; }); } return res.then(onfulfilled, onrejected); } } exports2.default = PostgrestBuilder; }); // node_modules/@supabase/postgrest-js/dist/cjs/PostgrestTransformBuilder.js var require_PostgrestTransformBuilder = __commonJS((exports2) => { var __importDefault = exports2 && exports2.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { default: mod }; }; Object.defineProperty(exports2, "__esModule", { value: true }); var PostgrestBuilder_1 = __importDefault(require_PostgrestBuilder()); class PostgrestTransformBuilder extends PostgrestBuilder_1.default { select(columns) { let quoted = false; const cleanedColumns = (columns !== null && columns !== undefined ? columns : "*").split("").map((c2) => { if (/\s/.test(c2) && !quoted) { return ""; } if (c2 === '"') { quoted = !quoted; } return c2; }).join(""); this.url.searchParams.set("select", cleanedColumns); if (this.headers["Prefer"]) { this.headers["Prefer"] += ","; } this.headers["Prefer"] += "return=representation"; return this; } order(column, { ascending = true, nullsFirst, foreignTable, referencedTable = foreignTable } = {}) { const key = referencedTable ? `${referencedTable}.order` : "order"; const existingOrder = this.url.searchParams.get(key); this.url.searchParams.set(key, `${existingOrder ? `${existingOrder},` : ""}${column}.${ascending ? "asc" : "desc"}${nullsFirst === undefined ? "" : nullsFirst ? ".nullsfirst" : ".nullslast"}`); return this; } limit(count, { foreignTable, referencedTable = foreignTable } = {}) { const key = typeof referencedTable === "undefined" ? "limit" : `${referencedTable}.limit`; this.url.searchParams.set(key, `${count}`); return this; } range(from, to, { foreignTable, referencedTable = foreignTable } = {}) { const keyOffset = typeof referencedTable === "undefined" ? "offset" : `${referencedTable}.offset`; const keyLimit = typeof referencedTable === "undefined" ? "limit" : `${referencedTable}.limit`; this.url.searchParams.set(keyOffset, `${from}`); this.url.searchParams.set(keyLimit, `${to - from + 1}`); return this; } abortSignal(signal) { this.signal = signal; return this; } single() { this.headers["Accept"] = "application/vnd.pgrst.object+json"; return this; } maybeSingle() { if (this.method === "GET") { this.headers["Accept"] = "application/json"; } else { this.headers["Accept"] = "application/vnd.pgrst.object+json"; } this.isMaybeSingle = true; return this; } csv() { this.headers["Accept"] = "text/csv"; return this; } geojson() { this.headers["Accept"] = "application/geo+json"; return this; } explain({ analyze = false, verbose = false, settings = false, buffers = false, wal = false, format = "text" } = {}) { var _a; const options = [ analyze ? "analyze" : null, verbose ? "verbose" : null, settings ? "settings" : null, buffers ? "buffers" : null, wal ? "wal" : null ].filter(Boolean).join("|"); const forMediatype = (_a = this.headers["Accept"]) !== null && _a !== undefined ? _a : "application/json"; this.headers["Accept"] = `application/vnd.pgrst.plan+${format}; for="${forMediatype}"; options=${options};`; if (format === "json") return this; else return this; } rollback() { var _a; if (((_a = this.headers["Prefer"]) !== null && _a !== undefined ? _a : "").trim().length > 0) { this.headers["Prefer"] += ",tx=rollback"; } else { this.headers["Prefer"] = "tx=rollback"; } return this; } returns() { return this; } } exports2.default = PostgrestTransformBuilder; }); // node_modules/@supabase/postgrest-js/dist/cjs/PostgrestFilterBuilder.js var require_PostgrestFilterBuilder = __commonJS((exports2) => { var __importDefault = exports2 && exports2.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { default: mod }; }; Object.defineProperty(exports2, "__esModule", { value: true }); var PostgrestTransformBuilder_1 = __importDefault(require_PostgrestTransformBuilder()); class PostgrestFilterBuilder extends PostgrestTransformBuilder_1.default { eq(column, value) { this.url.searchParams.append(column, `eq.${value}`); return this; } neq(column, value) { this.url.searchParams.append(column, `neq.${value}`); return this; } gt(column, value) { this.url.searchParams.append(column, `gt.${value}`); return this; } gte(column, value) { this.url.searchParams.append(column, `gte.${value}`); return this; } lt(column, value) { this.url.searchParams.append(column, `lt.${value}`); return this; } lte(column, value) { this.url.searchParams.append(column, `lte.${value}`); return this; } like(column, pattern) { this.url.searchParams.append(column, `like.${pattern}`); return this; } likeAllOf(column, patterns) { this.url.searchParams.append(column, `like(all).{${patterns.join(",")}}`); return this; } likeAnyOf(column, patterns) { this.url.searchParams.append(column, `like(any).{${patterns.join(",")}}`); return this; } ilike(column, pattern) { this.url.searchParams.append(column, `ilike.${pattern}`); return this; } ilikeAllOf(column, patterns) { this.url.searchParams.append(column, `ilike(all).{${patterns.join(",")}}`); return this; } ilikeAnyOf(column, patterns) { this.url.searchParams.append(column, `ilike(any).{${patterns.join(",")}}`); return this; } is(column, value) { this.url.searchParams.append(column, `is.${value}`); return this; } in(column, values) { const cleanedValues = Array.from(new Set(values)).map((s2) => { if (typeof s2 === "string" && new RegExp("[,()]").test(s2)) return `"${s2}"`; else return `${s2}`; }).join(","); this.url.searchParams.append(column, `in.(${cleanedValues})`); return this; } contains(column, value) { if (typeof value === "string") { this.url.searchParams.append(column, `cs.${value}`); } else if (Array.isArray(value)) { this.url.searchParams.append(column, `cs.{${value.join(",")}}`); } else { this.url.searchParams.append(column, `cs.${JSON.stringify(value)}`); } return this; } containedBy(column, value) { if (typeof value === "string") { this.url.searchParams.append(column, `cd.${value}`); } else if (Array.isArray(value)) { this.url.searchParams.append(column, `cd.{${value.join(",")}}`); } else { this.url.searchParams.append(column, `cd.${JSON.stringify(value)}`); } return this; } rangeGt(column, range) { this.url.searchParams.append(column, `sr.${range}`); return this; } rangeGte(column, range) { this.url.searchParams.append(column, `nxl.${range}`); return this; } rangeLt(column, range) { this.url.searchParams.append(column, `sl.${range}`); return this; } rangeLte(column, range) { this.url.searchParams.append(column, `nxr.${range}`); return this; } rangeAdjacent(column, range) { this.url.searchParams.append(column, `adj.${range}`); return this; } overlaps(column, value) { if (typeof value === "string") { this.url.searchParams.append(column, `ov.${value}`); } else { this.url.searchParams.append(column, `ov.{${value.join(",")}}`); } return this; } textSearch(column, query, { config, type } = {}) { let typePart = ""; if (type === "plain") { typePart = "pl"; } else if (type === "phrase") { typePart = "ph"; } else if (type === "websearch") { typePart = "w"; } const configPart = config === undefined ? "" : `(${config})`; this.url.searchParams.append(column, `${typePart}fts${configPart}.${query}`); return this; } match(query) { Object.entries(query).forEach(([column, value]) => { this.url.searchParams.append(column, `eq.${value}`); }); return this; } not(column, operator, value) { this.url.searchParams.append(column, `not.${operator}.${value}`); return this; } or(filters, { foreignTable, referencedTable = foreignTable } = {}) { const key = referencedTable ? `${referencedTable}.or` : "or"; this.url.searchParams.append(key, `(${filters})`); return this; } filter(column, operator, value) { this.url.searchParams.append(column, `${operator}.${value}`); return this; } } exports2.default = PostgrestFilterBuilder; }); // node_modules/@supabase/postgrest-js/dist/cjs/PostgrestQueryBuilder.js var require_PostgrestQueryBuilder = __commonJS((exports2) => { var __importDefault = exports2 && exports2.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { default: mod }; }; Object.defineProperty(exports2, "__esModule", { value: true }); var PostgrestFilterBuilder_1 = __importDefault(require_PostgrestFilterBuilder()); class PostgrestQueryBuilder { constructor(url, { headers = {}, schema, fetch: fetch3 }) { this.url = url; this.headers = headers; this.schema = schema; this.fetch = fetch3; } select(columns, { head = false, count } = {}) { const method = head ? "HEAD" : "GET"; let quoted = false; const cleanedColumns = (columns !== null && columns !== undefined ? columns : "*").split("").map((c2) => { if (/\s/.test(c2) && !quoted) { return ""; } if (c2 === '"') { quoted = !quoted; } return c2; }).join(""); this.url.searchParams.set("select", cleanedColumns); if (count) { this.headers["Prefer"] = `count=${count}`; } return new PostgrestFilterBuilder_1.default({ method, url: this.url, headers: this.headers, schema: this.schema, fetch: this.fetch, allowEmpty: false }); } insert(values, { count, defaultToNull = true } = {}) { const method = "POST"; const prefersHeaders = []; if (this.headers["Prefer"]) { prefersHeaders.push(this.headers["Prefer"]); } if (count) { prefersHeaders.push(`count=${count}`); } if (!defaultToNull) { prefersHeaders.push("missing=default"); } this.headers["Prefer"] = prefersHeaders.join(","); if (Array.isArray(values)) { const columns = values.reduce((acc, x) => acc.concat(Object.keys(x)), []); if (columns.length > 0) { const uniqueColumns = [...new Set(columns)].map((column) => `"${column}"`); this.url.searchParams.set("columns", uniqueColumns.join(",")); } } return new PostgrestFilterBuilder_1.default({ method, url: this.url, headers: this.headers, schema: this.schema, body: values, fetch: this.fetch, allowEmpty: false }); } upsert(values, { onConflict, ignoreDuplicates = false, count, defaultToNull = true } = {}) { const method = "POST"; const prefersHeaders = [`resolution=${ignoreDuplicates ? "ignore" : "merge"}-duplicates`]; if (onConflict !== undefined) this.url.searchParams.set("on_conflict", onConflict); if (this.headers["Prefer"]) { prefersHeaders.push(this.headers["Prefer"]); } if (count) { prefersHeaders.push(`count=${count}`); } if (!defaultToNull) { prefersHeaders.push("missing=default"); } this.headers["Prefer"] = prefersHeaders.join(","); if (Array.isArray(values)) { const columns = values.reduce((acc, x) => acc.concat(Object.keys(x)), []); if (columns.length > 0) { const uniqueColumns = [...new Set(columns)].map((column) => `"${column}"`); this.url.searchParams.set("columns", uniqueColumns.join(",")); } } return new PostgrestFilterBuilder_1.default({ method, url: this.url, headers: this.headers, schema: this.schema, body: values, fetch: this.fetch, allowEmpty: false }); } update(values, { count } = {}) { const method = "PATCH"; const prefersHeaders = []; if (this.headers["Prefer"]) { prefersHeaders.push(this.headers["Prefer"]); } if (count) { prefersHeaders.push(`count=${count}`); } this.headers["Prefer"] = prefersHeaders.join(","); return new PostgrestFilterBuilder_1.default({ method, url: this.url, headers: this.headers, schema: this.schema, body: values, fetch: this.fetch, allowEmpty: false }); } delete({ count } = {}) { const method = "DELETE"; const prefersHeaders = []; if (count) { prefersHeaders.push(`count=${count}`); } if (this.headers["Prefer"]) { prefersHeaders.unshift(this.headers["Prefer"]); } this.headers["Prefer"] = prefersHeaders.join(","); return new PostgrestFilterBuilder_1.default({ method, url: this.url, headers: this.headers, schema: this.schema, fetch: this.fetch, allowEmpty: false }); } } exports2.default = PostgrestQueryBuilder; }); // node_modules/@supabase/postgrest-js/dist/cjs/version.js var require_version = __commonJS((exports2) => { Object.defineProperty(exports2, "__esModule", { value: true }); exports2.version = undefined; exports2.version = "0.0.0-automated"; }); // node_modules/@supabase/postgrest-js/dist/cjs/constants.js var require_constants = __commonJS((exports2) => { Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DEFAULT_HEADERS = undefined; var version_1 = require_version(); exports2.DEFAULT_HEADERS = { "X-Client-Info": `postgrest-js/${version_1.version}` }; }); // node_modules/@supabase/postgrest-js/dist/cjs/PostgrestClient.js var require_PostgrestClient = __commonJS((exports2) => { var __importDefault = exports2 && exports2.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { default: mod }; }; Object.defineProperty(exports2, "__esModule", { value: true }); var PostgrestQueryBuilder_1 = __importDefault(require_PostgrestQueryBuilder()); var PostgrestFilterBuilder_1 = __importDefault(require_PostgrestFilterBuilder()); var constants_1 = require_constants(); class PostgrestClient { constructor(url, { headers = {}, schema, fetch: fetch3 } = {}) { this.url = url; this.headers = Object.assign(Object.assign({}, constants_1.DEFAULT_HEADERS), headers); this.schemaName = schema; this.fetch = fetch3; } from(relation) { const url = new URL(`${this.url}/${relation}`); return new PostgrestQueryBuilder_1.default(url, { headers: Object.assign({}, this.headers), schema: this.schemaName, fetch: this.fetch }); } schema(schema) { return new PostgrestClient(this.url, { headers: this.headers, schema, fetch: this.fetch }); } rpc(fn, args = {}, { head = false, get = false, count } = {}) { let method; const url = new URL(`${this.url}/rpc/${fn}`); let body; if (head || get) { method = head ? "HEAD" : "GET"; Object.entries(args).filter(([_, value]) => value !== undefined).map(([name, value]) => [name, Array.isArray(value) ? `{${value.join(",")}}` : `${value}`]).forEach(([name, value]) => { url.searchParams.append(name, value); }); } else { method = "POST"; body = args; } const headers = Object.assign({}, this.headers); if (count) { headers["Prefer"] = `count=${count}`; } return new PostgrestFilterBuilder_1.default({ method, url, headers, schema: this.schemaName, body, fetch: this.fetch, allowEmpty: false }); } } exports2.default = PostgrestClient; }); // node_modules/@supabase/postgrest-js/dist/cjs/index.js var require_cjs = __commonJS((exports2) => { var __importDefault = exports2 && exports2.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { default: mod }; }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.PostgrestError = exports2.PostgrestBuilder = exports2.PostgrestTransformBuilder = exports2.PostgrestFilterBuilder = exports2.PostgrestQueryBuilder = exports2.PostgrestClient = undefined; var PostgrestClient_1 = __importDefault(require_PostgrestClient()); exports2.PostgrestClient = PostgrestClient_1.default; var PostgrestQueryBuilder_1 = __importDefault(require_PostgrestQueryBuilder()); exports2.PostgrestQueryBuilder = PostgrestQueryBuilder_1.default; var PostgrestFilterBuilder_1 = __importDefault(require_PostgrestFilterBuilder()); exports2.PostgrestFilterBuilder = PostgrestFilterBuilder_1.default; var PostgrestTransformBuilder_1 = __importDefault(require_PostgrestTransformBuilder()); exports2.PostgrestTransformBuilder = PostgrestTransformBuilder_1.default; var PostgrestBuilder_1 = __importDefault(require_PostgrestBuilder()); exports2.PostgrestBuilder = PostgrestBuilder_1.default; var PostgrestError_1 = __importDefault(require_PostgrestError()); exports2.PostgrestError = PostgrestError_1.default; exports2.default = { PostgrestClient: PostgrestClient_1.default, PostgrestQueryBuilder: PostgrestQueryBuilder_1.default, PostgrestFilterBuilder: PostgrestFilterBuilder_1.default, PostgrestTransformBuilder: PostgrestTransformBuilder_1.default, PostgrestBuilder: PostgrestBuilder_1.default, PostgrestError: PostgrestError_1.default }; }); // node_modules/ws/browser.js var require_browser = __commonJS((exports2, module2) => { module2.exports = function() { throw new Error("ws does not work in the browser. Browser clients must use the native " + "WebSocket object"); }; }); // src/index.ts var exports_src = {}; __export(exports_src, { default: () => VoyageSDK }); module.exports = __toCommonJS(exports_src); // node_modules/@elysiajs/eden/dist/chunk-XYW4OUFN.mjs var s = class extends Error { constructor(e, n) { super(n + ""); this.status = e; this.value = n; } }; var i = /(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/; var o = /(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/; var c = /^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/; var u = (t) => t.trim().length !== 0 && !Number.isNaN(Number(t)); var d = (t) => { if (typeof t != "string") return null; let r = t.replace(/"/g, ""); if (i.test(r) || o.test(r) || c.test(r)) { let e = new Date(r); if (!Number.isNaN(e.getTime())) return e; } return null; }; var a = (t) => { let r = t.charCodeAt(0), e = t.charCodeAt(t.length - 1); return r === 123 && e === 125 || r === 91 && e === 93; }; var p = (t) => JSON.parse(t, (r, e) => { let n = d(e); return n || e; }); var g = (t) => { if (!t) return t; if (u(t)) return +t; if (t === "true") return true; if (t === "false") return false; let r = d(t); if (r) return r; if (a(t)) try { return p(t); } catch { } return t; }; var S = (t) => { let r = t.data.toString(); return r === "null" ? null : g(r); }; // node_modules/@elysiajs/eden/dist/chunk-2IHGLN7W.mjs var $ = typeof FileList > "u"; // node_modules/@elysiajs/eden/dist/chunk-7WO4HTSU.mjs var F = class { constructor(t) { this.url = t; this.ws = new WebSocket(t); } ws; send(t) { return Array.isArray(t) ? (t.forEach((n) => this.send(n)), this) : (this.ws.send(typeof t == "object" ? JSON.stringify(t) : t.toString()), this); } on(t, n, s2) { return this.addEventListener(t, n, s2); } off(t, n, s2) { return this.ws.removeEventListener(t, n, s2), this; } subscribe(t, n) { return this.addEventListener("message", t, n); } addEventListener(t, n, s2) { return this.ws.addEventListener(t, (c2) => { if (t === "message") { let f = S(c2); n({ ...c2, data: f }); } else n(c2); }, s2), this; } removeEventListener(t, n, s2) { return this.off(t, n, s2), this; } close() { return this.ws.close(), this; } }; var N = ["get", "post", "put", "delete", "patch", "options", "head", "connect", "subscribe"]; var I = ["localhost", "127.0.0.1", "0.0.0.0"]; var C = typeof FileList > "u"; var q = (e) => C ? e instanceof Blob : e instanceof FileList || e instanceof File; var P = (e) => { if (!e) return false; for (let t in e) if (q(e[t]) || Array.isArray(e[t]) && e[t].find(q)) return true; return false; }; var j = (e) => C ? e : new Promise((t) => { let n = new FileReader; n.onload = () => { let s2 = new File([n.result], e.name, { lastModified: e.lastModified, type: e.type }); t(s2); }, n.readAsArrayBuffer(e); }); var b = (e, t, n = {}, s2 = {}) => { if (Array.isArray(e)) { for (let c2 of e) if (!Array.isArray(c2)) s2 = b(c2, t, n, s2); else { let f = c2[0]; if (typeof f == "string") s2[f.toLowerCase()] = c2[1]; else for (let [a2, w] of f) s2[a2.toLowerCase()] = w; } return s2; } if (!e) return s2; switch (typeof e) { case "function": if (e instanceof Headers) return b(e, t, n, s2); let c2 = e(t, n); return c2 ? b(c2, t, n, s2) : s2; case "object": if (e instanceof Headers) return e.forEach((f, a2) => { s2[a2.toLowerCase()] = f; }), s2; for (let [f, a2] of Object.entries(e)) s2[f.toLowerCase()] = a2; return s2; default: return s2; } }; async function* U(e) { let t = e.body; if (!t) return; let n = t.getReader(), s2 = new TextDecoder; try { for (;; ) { let { done: c2, value: f } = await n.read(); if (c2) break; let a2 = s2.decode(f); yield g(a2); } } finally { n.releaseLock(); } } var A = (e, t, n = [], s2) => new Proxy(() => { }, { get(c2, f) { return A(e, t, f === "index" ? n : [...n, f], s2); }, apply(c2, f, [a2, w]) { if (!a2 || w || typeof a2 == "object" && Object.keys(a2).length !== 1 || N.includes(n.at(-1))) { let K = [...n], k = K.pop(), g2 = "/" + K.join("/"), { fetcher: D = fetch, headers: L, onRequest: p2, onResponse: E, fetch: H } = t, m = k === "get" || k === "head" || k === "subscribe"; L = b(L, g2, w); let T = m ? a2?.query : w?.query, R = ""; if (T) { let r = (h, d2) => { R += (R ? "&" : "?") + `${encodeURIComponent(h)}=${encodeURIComponent(d2)}`; }; for (let [h, d2] of Object.entries(T)) { if (Array.isArray(d2)) { for (let o2 of d2) r(h, o2); continue; } if (typeof d2 == "object") { r(h, JSON.stringify(d2)); continue; } r(h, `${d2}`); } } if (k === "subscribe") { let r = e.replace(/^([^]+):\/\//, e.startsWith("https://") ? "wss://" : e.startsWith("http://") || I.find((h) => e.includes(h)) ? "ws://" : "wss://") + g2 + R; return new F(r); } return (async () => { let r = { method: k?.toUpperCase(), body: a2, ...H, headers: L }; r.headers = { ...L, ...b(m ? a2?.headers : w?.headers, g2, r) }; let h = m && typeof a2 == "object" ? a2.fetch : w?.fetch; if (r = { ...r, ...h }, m && delete r.body, p2) { Array.isArray(p2) || (p2 = [p2]); for (let y of p2) { let i2 = await y(g2, r); typeof i2 == "object" && (r = { ...r, ...i2, headers: { ...r.headers, ...b(i2.headers, g2, r) } }); } } if (m && delete r.body, P(a2)) { let y = new FormData; for (let [i2, u2] of Object.entries(r.body)) { if (C) { y.append(i2, u2); continue; } if (u2 instanceof File) { y.append(i2, await j(u2)); continue; } if (u2 instanceof FileList) { for (let v = 0;v < u2.length; v++) y.append(i2, await j(u2[v])); continue; } if (Array.isArray(u2)) { for (let v = 0;v < u2.length; v++) { let W = u2[v]; y.append(i2, W instanceof File ? await j(W) : W); } continue; } y.append(i2, u2); } r.body = y; } else typeof a2 == "object" ? (r.headers["content-type"] = "application/json", r.body = JSON.stringify(a2)) : a2 != null && (r.headers["content-type"] = "text/plain"); if (m && delete r.body, p2) { Array.isArray(p2) || (p2 = [p2]); for (let y of p2) { let i2 = await y(g2, r); typeof i2 == "object" && (r = { ...r, ...i2, headers: { ...r.headers, ...b(i2.headers, g2, r) } }); } } let d2 = e + g2 + R, o2 = await (s2?.handle(new Request(d2, r)) ?? D(d2, r)), l = null, S2 = null; if (E) { Array.isArray(E) || (E = [E]); for (let y of E) try { let i2 = await y(o2.clone()); if (i2 != null) { l = i2; break; } } catch (i2) { i2 instanceof s ? S2 = i2 : S2 = new s(422, i2); break; } } if (l !== null) return { data: l, error: S2, response: o2, status: o2.status, headers: o2.headers }; switch (o2.headers.get("Content-Type")?.split(";")[0]) { case "text/event-stream": l = U(o2); break; case "application/json": l = await o2.json(); break; case "application/octet-stream": l = await o2.arrayBuffer(); break; case "multipart/form-data": let y = await o2.formData(); l = {}, y.forEach((i2, u2) => { l[u2] = i2; }); break; default: l = await o2.text().then(g); } return (o2.status >= 300 || o2.status < 200) && (S2 = new s(o2.status, l), l = null), { data: l, error: S2, response: o2, status: o2.status, headers: o2.headers }; })(); } return typeof a2 == "object" ? A(e, t, [...n, Object.values(a2)[0]], s2) : A(e, t, n); } }); var V = (e, t = {}) => typeof e == "string" ? (t.keepDomain || (e.includes("://") || (e = (I.find((n) => e.includes(n)) ? "http://" : "https://") + e), e.endsWith("/") && (e = e.slice(0, -1))), A(e, t)) : (typeof window < "u" && console.warn("Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead."), A("http://e.ly", t, [], e)); // node_modules/@supabase/functions-js/dist/module/helper.js var resolveFetch = (customFetch) => { let _fetch; if (customFetch) { _fetch = customFetch; } else if (typeof fetch === "undefined") { _fetch = (...args) => Promise.resolve().then(() => (init_browser(), exports_browser)).then(({ default: fetch3 }) => fetch3(...args)); } else { _fetch = fetch; } return (...args) => _fetch(...args); }; // node_modules/@supabase/functions-js/dist/module/types.js class FunctionsError extends Error { constructor(message, name = "FunctionsError", context) { super(message); this.name = name; this.context = context; } } class FunctionsFetchError extends FunctionsError { constructor(context) { super("Failed to send a request to the Edge Function", "FunctionsFetchError", context); } } class FunctionsRelayError extends FunctionsError { constructor(context) { super("Relay Error invoking the Edge Function", "FunctionsRelayError", context); } } class FunctionsHttpError extends FunctionsError { constructor(context) { super("Edge Function returned a non-2xx status code", "FunctionsHttpError", context); } } var FunctionRegion; (function(FunctionRegion2) { FunctionRegion2["Any"] = "any"; FunctionRegion2["ApNortheast1"] = "ap-northeast-1"; FunctionRegion2["ApNortheast2"] = "ap-northeast-2"; FunctionRegion2["ApSouth1"] = "ap-south-1"; FunctionRegion2["ApSoutheast1"] = "ap-southeast-1"; FunctionRegion2["ApSoutheast2"] = "ap-southeast-2"; FunctionRegion2["CaCentral1"] = "ca-central-1"; FunctionRegion2["EuCentral1"] = "eu-central-1"; FunctionRegion2["EuWest1"] = "eu-west-1"; FunctionRegion2["EuWest2"] = "eu-west-2"; FunctionRegion2["EuWest3"] = "eu-west-3"; FunctionRegion2["SaEast1"] = "sa-east-1"; FunctionRegion2["UsEast1"] = "us-east-1"; FunctionRegion2["UsWest1"] = "us-west-1"; FunctionRegion2["UsWest2"] = "us-west-2"; })(FunctionRegion || (FunctionRegion = {})); // node_modules/@supabase/functions-js/dist/module/FunctionsClient.js var __awaiter = function(thisArg, _arguments, P2, generator) { function adopt(value) { return value instanceof P2 ? value : new P2(function(resolve) { resolve(value); }); } return new (P2 || (P2 = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; class FunctionsClient { constructor(url, { headers = {}, customFetch, region = FunctionRegion.Any } = {}) { this.url = url; this.headers = headers; this.region = region; this.fetch = resolveFetch(customFetch); } setAuth(token) { this.headers.Authorization = `Bearer ${token}`; } invoke(functionName, options = {}) { var _a; return __awaiter(this, undefined, undefined, function* () { try { const { headers, method, body: functionArgs } = options; let _headers = {}; let { region } = options; if (!region) { region = this.region; } if (region && region !== "any") { _headers["x-region"] = region; } let body; if (functionArgs && (headers && !Object.prototype.hasOwnProperty.call(headers, "Content-Type") || !headers)) { if (typeof Blob !== "undefined" && functionArgs instanceof Blob || functionArgs instanceof ArrayBuffer) { _headers["Content-Type"] = "application/octet-stream"; body = functionArgs; } else if (typeof functionArgs === "string") { _headers["Content-Type"] = "text/plain"; body = functionArgs; } else if (typeof FormData !== "undefined" && functionArgs instanceof FormData) { body = functionArgs; } else { _headers["Content-Type"] = "application/json"; body = JSON.stringify(functionArgs); } } const response = yield this.fetch(`${this.url}/${functionName}`, { method: method || "POST", headers: Object.assign(Object.assign(Object.assign({}, _headers), this.headers), headers), body }).catch((fetchError) => { throw new FunctionsFetchError(fetchError); }); const isRelayError = response.headers.get("x-relay-error"); if (isRelayError && isRelayError === "true") { throw new FunctionsRelayError(response); } if (!response.ok) { throw new FunctionsHttpError(response); } let responseType = ((_a = response.headers.get("Content-Type")) !== null && _a !== undefined ? _a : "text/plain").split(";")[0].trim(); let data; if (responseType === "application/json") { data = yield response.json(); } else if (responseType === "application/octet-stream") { data = yield response.blob(); } else if (responseType === "text/event-stream") { data = response; } else if (responseType === "multipart/form-data") { data = yield response.formData(); } else { data = yield response.text(); } return { data, error: null }; } catch (error) { return { data: null, error }; } }); } } // node_modules/@supabase/postgrest-js/dist/esm/wrapper.mjs var import_cjs = __toESM(require_cjs()); var { PostgrestClient, PostgrestQueryBuilder, PostgrestFilterBuilder, PostgrestTransformBuilder, PostgrestBuilder } = import_cjs.default; // node_modules/@supabase/realtime-js/dist/module/lib/version.js var version = "2.10.7"; // node_modules/@supabase/realtime-js/dist/module/lib/constants.js var DEFAULT_HEADERS = { "X-Client-Info": `realtime-js/${version}` }; var VSN = "1.0.0"; var DEFAULT_TIMEOUT = 1e4; var WS_CLOSE_NORMAL = 1000; var SOCKET_STATES; (function(SOCKET_STATES2) { SOCKET_STATES2[SOCKET_STATES2["connecting"] = 0] = "connecting"; SOCKET_STATES2[SOCKET_STATES2["open"] = 1] = "open"; SOCKET_STATES2[SOCKET_STATES2["closing"] = 2] = "closing"; SOCKET_STATES2[SOCKET_STATES2["closed"] = 3] = "closed"; })(SOCKET_STATES || (SOCKET_STATES = {})); var CHANNEL_STATES; (function(CHANNEL_STATES2) { CHANNEL_STATES2["closed"] = "closed"; CHANNEL_STATES2["errored"] = "errored"; CHANNEL_STATES2["joined"] = "joined"; CHANNEL_STATES2["joining"] = "joining"; CHANNEL_STATES2["leaving"] = "leaving"; })(CHANNEL_STATES || (CHANNEL_STATES = {})); var CHANNEL_EVENTS; (function(CHANNEL_EVENTS2) { CHANNEL_EVENTS2["close"] = "phx_close"; CHANNEL_EVENTS2["error"] = "phx_error"; CHANNEL_EVENTS2["join"] = "phx_join"; CHANNEL_EVENTS2["reply"] = "phx_reply"; CHANNEL_EVENTS2["leave"] = "phx_leave"; CHANNEL_EVENTS2["access_token"] = "access_token"; })(CHANNEL_EVENTS || (CHANNEL_EVENTS = {})); var TRANSPORTS; (function(TRANSPORTS2) { TRANSPORTS2["websocket"] = "websocket"; })(TRANSPORTS || (TRANSPORTS = {})); var CONNECTION_STATE; (function(CONNECTION_STATE2) { CONNECTION_STATE2["Connecting"] = "connecting"; CONNECTION_STATE2["Open"] = "open"; CONNECTION_STATE2["Closing"] = "closing"; CONNECTION_STATE2["Closed"] = "closed"; })(CONNECTION_STATE || (CONNECTION_STATE = {})); // node_modules/@supabase/realtime-js/dist/module/lib/serializer.js class Serializer { constructor() { this.HEADER_LENGTH = 1; } decode(rawPayload, callback) { if (rawPayload.constructor === ArrayBuffer) { return callback(this._binaryDecode(rawPayload)); } if (typeof rawPayload === "string") { return callback(JSON.parse(rawPayload)); } return callback({}); } _binaryDecode(buffer) { const view = new DataView(buffer); const decoder = new TextDecoder; return this._decodeBroadcast(buffer, view, decoder); } _decodeBroadcast(buffer, view, decoder) { const topicSize = view.getUint8(1); const eventSize = view.getUint8(2); let offset = this.HEADER_LENGTH + 2; const topic = decoder.decode(buffer.slice(offset, offset + topicSize)); offset = offset + topicSize; const event = decoder.decode(buffer.slice(offset, offset + eventSize)); offset = offset + eventSize; const data = JSON.parse(decoder.decode(buffer.slice(offset, buffer.byteLength))); return { ref: null, topic, event, payload: data }; } } // node_modules/@supabase/realtime-js/dist/module/lib/timer.js class Timer { constructor(callback, timerCalc) { this.callback = callback; this.timerCalc = timerCalc; this.timer = undefined; this.tries = 0; this.callback = callback; this.timerCalc = timerCalc; } reset() { this.tries = 0; clearTimeout(this.timer); } scheduleTimeout() { clearTimeout(this.timer); this.timer = setTimeout(() => { this.tries = this.tries + 1; this.callback(); }, this.timerCalc(this.tries + 1)); } } // node_modules/@supabase/realtime-js/dist/module/lib/transformers.js var PostgresTypes; (function(PostgresTypes2) { PostgresTypes2["abstime"] = "abstime"; PostgresTypes2["bool"] = "bool"; PostgresTypes2["date"] = "date"; PostgresTypes2["daterange"] = "daterange"; PostgresTypes2["float4"] = "float4"; PostgresTypes2["float8"] = "float8"; PostgresTypes2["int2"] = "int2"; PostgresTypes2["int4"] = "int4"; PostgresTypes2["int4range"] = "int4range"; PostgresTypes2["int8"] = "int8"; PostgresTypes2["int8range"] = "int8range"; PostgresTypes2["json"] = "json"; PostgresTypes2["jsonb"] = "jsonb"; PostgresTypes2["money"] = "money"; PostgresTypes2["numeric"] = "numeric"; PostgresTypes2["oid"] = "oid"; PostgresTypes2["reltime"] = "reltime"; PostgresTypes2["text"] = "text"; PostgresTypes2["time"] = "time"; PostgresTypes2["timestamp"] = "timestamp"; PostgresTypes2["timestamptz"] = "timestamptz"; PostgresTypes2["timetz"] = "timetz"; PostgresTypes2["tsrange"] = "tsrange"; PostgresTypes2["tstzrange"] = "tstzrange"; })(PostgresTypes || (PostgresTypes = {})); var convertChangeData = (columns, record, options = {}) => { var _a; const skipTypes = (_a = options.skipTypes) !== null && _a !== undefined ? _a : []; return Object.keys(record).reduce((acc, rec_key) => { acc[rec_key] = convertColumn(rec_key, columns, record, skipTypes); return acc; }, {}); }; var convertColumn = (columnName, columns, record, skipTypes) => { const column = columns.find((x) => x.name === columnName); const colType = column === null || column === undefined ? undefined : column.type; const value = record[columnName]; if (colType && !skipTypes.includes(colType)) { return convertCell(colType, value); } return noop(value); }; var convertCell = (type, value) => { if (type.charAt(0) === "_") { const dataType = type.slice(1, type.length); return toArray(value, dataType); } switch (type) { case PostgresTypes.bool: return toBoolean(value); case PostgresTypes.float4: case PostgresTypes.float8: case PostgresTypes.int2: case PostgresTypes.int4: case PostgresTypes.int8: case PostgresTypes.numeric: case PostgresTypes.oid: return toNumber(value); case PostgresTypes.json: case PostgresTypes.jsonb: return toJson(value); case PostgresTypes.timestamp: return toTimestampString(value); case PostgresTypes.abstime: case PostgresTypes.date: case PostgresTypes.daterange: case PostgresTypes.int4range: case PostgresTypes.int8range: case PostgresTypes.money: case PostgresTypes.reltime: case PostgresTypes.text: case PostgresTypes.time: case PostgresTypes.timestamptz: case PostgresTypes.timetz: case PostgresTypes.tsrange: case PostgresTypes.tstzrange: return noop(value); default: return noop(value); } }; var noop = (value) => { return value; }; var toBoolean = (value) => { switch (value) { case "t": return true; case "f": return false; default: return value; } }; var toNumber = (value) => { if (typeof value === "string") { const parsedValue = parseFloat(value); if (!Number.isNaN(parsedValue)) { return parsedValue; } } return value; }; var toJson = (value) => { if (typeof value === "string") { try { return JSON.parse(value); } catch (error) { console.log(`JSON parse error: ${error}`); return value; } } return value; }; var toArray = (value, type) => { if (typeof value !== "string") { return value; } const lastIdx = value.length - 1; const closeBrace = value[lastIdx]; const openBrace = value[0]; if (openBrace === "{" && closeBrace === "}") { let arr; const valTrim = value.slice(1, lastIdx); try { arr = JSON.parse("[" + valTrim + "]"); } catch (_) { arr = valTrim ? valTrim.split(",") : []; } return arr.map((val) => convertCell(type, val)); } return value; }; var toTimestampString = (value) => { if (typeof value === "string") { return value.replace(" ", "T"); } return value; }; var httpEndpointURL = (socketUrl) => { let url = socketUrl; url = url.replace(/^ws/i, "http"); url = url.replace(/(\/s