diff --git a/crates/yaak-wasm/pkg/yaak_wasm.js b/crates/yaak-wasm/pkg/yaak_wasm.js index 76f0b2b1..fc83815b 100644 --- a/crates/yaak-wasm/pkg/yaak_wasm.js +++ b/crates/yaak-wasm/pkg/yaak_wasm.js @@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./yaak_wasm_bg.js"; __wbg_set_wasm(wasm); wasm.__wbindgen_start(); export { - blob_delete, blob_get, blob_put, boot, prepare_http_send, rpc + blob_delete, blob_get, blob_put, boot, prepare_http_send, render_template, rpc } from "./yaak_wasm_bg.js"; diff --git a/crates/yaak-wasm/pkg/yaak_wasm_bg.js b/crates/yaak-wasm/pkg/yaak_wasm_bg.js index 40ba3616..9ff2e631 100644 --- a/crates/yaak-wasm/pkg/yaak_wasm_bg.js +++ b/crates/yaak-wasm/pkg/yaak_wasm_bg.js @@ -732,7 +732,7 @@ export function __wbindgen_cast_0000000000000002(arg0, arg1) { } export function __wbindgen_cast_0000000000000003(arg0, arg1) { // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("IDBVersionChangeEvent")], shim_idx: 74, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`. - const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h20ab1db2d80221ce); + const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__he166673e9c1b4e95); return ret; } export function __wbindgen_cast_0000000000000004(arg0, arg1) { @@ -789,8 +789,8 @@ function wasm_bindgen__convert__closures_____invoke__ha1c2fa93df0107f3(arg0, arg } } -function wasm_bindgen__convert__closures_____invoke__h20ab1db2d80221ce(arg0, arg1, arg2) { - const ret = wasm.wasm_bindgen__convert__closures_____invoke__h20ab1db2d80221ce(arg0, arg1, arg2); +function wasm_bindgen__convert__closures_____invoke__he166673e9c1b4e95(arg0, arg1, arg2) { + const ret = wasm.wasm_bindgen__convert__closures_____invoke__he166673e9c1b4e95(arg0, arg1, arg2); if (ret[1]) { throw takeFromExternrefTable0(ret[0]); } diff --git a/crates/yaak-wasm/pkg/yaak_wasm_bg.wasm b/crates/yaak-wasm/pkg/yaak_wasm_bg.wasm index f5686930..5673bea8 100644 Binary files a/crates/yaak-wasm/pkg/yaak_wasm_bg.wasm and b/crates/yaak-wasm/pkg/yaak_wasm_bg.wasm differ diff --git a/crates/yaak-wasm/pkg/yaak_wasm_bg.wasm.d.ts b/crates/yaak-wasm/pkg/yaak_wasm_bg.wasm.d.ts index e0deaa2f..34a270e7 100644 --- a/crates/yaak-wasm/pkg/yaak_wasm_bg.wasm.d.ts +++ b/crates/yaak-wasm/pkg/yaak_wasm_bg.wasm.d.ts @@ -19,7 +19,7 @@ export const rust_sqlite_wasm_realloc: (a: number, b: number) => number; export const sqlite3_os_end: () => number; export const sqlite3_os_init: () => number; export const wasm_bindgen__convert__closures_____invoke__ha1c2fa93df0107f3: (a: number, b: number, c: any) => [number, number]; -export const wasm_bindgen__convert__closures_____invoke__h20ab1db2d80221ce: (a: number, b: number, c: any) => [number, number]; +export const wasm_bindgen__convert__closures_____invoke__he166673e9c1b4e95: (a: number, b: number, c: any) => [number, number]; export const wasm_bindgen__convert__closures_____invoke__h2cf3f4cce3b29948: (a: number, b: number, c: any, d: any) => void; export const wasm_bindgen__convert__closures_____invoke__ha7903b6e296dd8f4: (a: number, b: number, c: any) => void; export const wasm_bindgen__convert__closures_____invoke__ha1b480b83daa641f: (a: number, b: number) => void; diff --git a/packages/platform/src/web/connection.ts b/packages/platform/src/web/connection.ts index 9a9c6ed7..e0ea86b8 100644 --- a/packages/platform/src/web/connection.ts +++ b/packages/platform/src/web/connection.ts @@ -202,7 +202,7 @@ export class WorkerConnection { return this.request((id) => ({ type: "prepare_http_send", id, payload })); } - /** See `render_template` in crates/yaak-web. */ + /** See `render_template` in crates/yaak-wasm. */ renderTemplate(payload: unknown): Promise { return this.request((id) => ({ type: "render_template", id, payload })); } diff --git a/packages/platform/src/web/sandboxPlugins.generated.ts b/packages/platform/src/web/sandboxPlugins.generated.ts index 840de91f..de8aa165 100644 --- a/packages/platform/src/web/sandboxPlugins.generated.ts +++ b/packages/platform/src/web/sandboxPlugins.generated.ts @@ -10,6 +10,6 @@ export interface SandboxPluginBundle { export const SANDBOX_PLUGINS: SandboxPluginBundle[] = [ { name: "template-function-timestamp", source: "\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// plugins/template-function-timestamp/src/index.ts\nvar index_exports = {};\n__export(index_exports, {\n calculateDatetime: () => calculateDatetime,\n formatDatetime: () => formatDatetime,\n plugin: () => plugin\n});\nmodule.exports = __toCommonJS(index_exports);\n\n// node_modules/date-fns/constants.js\nvar daysInYear = 365.2425;\nvar maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;\nvar minTime = -maxTime;\nvar millisecondsInWeek = 6048e5;\nvar millisecondsInDay = 864e5;\nvar millisecondsInMinute = 6e4;\nvar millisecondsInHour = 36e5;\nvar secondsInHour = 3600;\nvar secondsInDay = secondsInHour * 24;\nvar secondsInWeek = secondsInDay * 7;\nvar secondsInYear = secondsInDay * daysInYear;\nvar secondsInMonth = secondsInYear / 12;\nvar secondsInQuarter = secondsInMonth * 3;\nvar constructFromSymbol = /* @__PURE__ */ Symbol.for(\"constructDateFrom\");\n\n// node_modules/date-fns/constructFrom.js\nfunction constructFrom(date, value) {\n if (typeof date === \"function\") return date(value);\n if (date && typeof date === \"object\" && constructFromSymbol in date)\n return date[constructFromSymbol](value);\n if (date instanceof Date) return new date.constructor(value);\n return new Date(value);\n}\n\n// node_modules/date-fns/toDate.js\nfunction toDate(argument, context) {\n return constructFrom(context || argument, argument);\n}\n\n// node_modules/date-fns/addDays.js\nfunction addDays(date, amount, options) {\n const _date = toDate(date, options?.in);\n if (isNaN(amount)) return constructFrom(options?.in || date, NaN);\n if (!amount) return _date;\n _date.setDate(_date.getDate() + amount);\n return _date;\n}\n\n// node_modules/date-fns/addMonths.js\nfunction addMonths(date, amount, options) {\n const _date = toDate(date, options?.in);\n if (isNaN(amount)) return constructFrom(options?.in || date, NaN);\n if (!amount) {\n return _date;\n }\n const dayOfMonth = _date.getDate();\n const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());\n endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);\n const daysInMonth = endOfDesiredMonth.getDate();\n if (dayOfMonth >= daysInMonth) {\n return endOfDesiredMonth;\n } else {\n _date.setFullYear(\n endOfDesiredMonth.getFullYear(),\n endOfDesiredMonth.getMonth(),\n dayOfMonth\n );\n return _date;\n }\n}\n\n// node_modules/date-fns/addMilliseconds.js\nfunction addMilliseconds(date, amount, options) {\n return constructFrom(options?.in || date, +toDate(date) + amount);\n}\n\n// node_modules/date-fns/addHours.js\nfunction addHours(date, amount, options) {\n return addMilliseconds(date, amount * millisecondsInHour, options);\n}\n\n// node_modules/date-fns/_lib/defaultOptions.js\nvar defaultOptions = {};\nfunction getDefaultOptions() {\n return defaultOptions;\n}\n\n// node_modules/date-fns/startOfWeek.js\nfunction startOfWeek(date, options) {\n const defaultOptions2 = getDefaultOptions();\n const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;\n const _date = toDate(date, options?.in);\n const day = _date.getDay();\n const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;\n _date.setDate(_date.getDate() - diff);\n _date.setHours(0, 0, 0, 0);\n return _date;\n}\n\n// node_modules/date-fns/startOfISOWeek.js\nfunction startOfISOWeek(date, options) {\n return startOfWeek(date, { ...options, weekStartsOn: 1 });\n}\n\n// node_modules/date-fns/getISOWeekYear.js\nfunction getISOWeekYear(date, options) {\n const _date = toDate(date, options?.in);\n const year = _date.getFullYear();\n const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);\n fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);\n fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);\n const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);\n const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);\n fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);\n fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);\n const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);\n if (_date.getTime() >= startOfNextYear.getTime()) {\n return year + 1;\n } else if (_date.getTime() >= startOfThisYear.getTime()) {\n return year;\n } else {\n return year - 1;\n }\n}\n\n// node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js\nfunction getTimezoneOffsetInMilliseconds(date) {\n const _date = toDate(date);\n const utcDate = new Date(\n Date.UTC(\n _date.getFullYear(),\n _date.getMonth(),\n _date.getDate(),\n _date.getHours(),\n _date.getMinutes(),\n _date.getSeconds(),\n _date.getMilliseconds()\n )\n );\n utcDate.setUTCFullYear(_date.getFullYear());\n return +date - +utcDate;\n}\n\n// node_modules/date-fns/_lib/normalizeDates.js\nfunction normalizeDates(context, ...dates) {\n const normalize = constructFrom.bind(\n null,\n context || dates.find((date) => typeof date === \"object\")\n );\n return dates.map(normalize);\n}\n\n// node_modules/date-fns/startOfDay.js\nfunction startOfDay(date, options) {\n const _date = toDate(date, options?.in);\n _date.setHours(0, 0, 0, 0);\n return _date;\n}\n\n// node_modules/date-fns/differenceInCalendarDays.js\nfunction differenceInCalendarDays(laterDate, earlierDate, options) {\n const [laterDate_, earlierDate_] = normalizeDates(\n options?.in,\n laterDate,\n earlierDate\n );\n const laterStartOfDay = startOfDay(laterDate_);\n const earlierStartOfDay = startOfDay(earlierDate_);\n const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);\n const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);\n return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);\n}\n\n// node_modules/date-fns/startOfISOWeekYear.js\nfunction startOfISOWeekYear(date, options) {\n const year = getISOWeekYear(date, options);\n const fourthOfJanuary = constructFrom(options?.in || date, 0);\n fourthOfJanuary.setFullYear(year, 0, 4);\n fourthOfJanuary.setHours(0, 0, 0, 0);\n return startOfISOWeek(fourthOfJanuary);\n}\n\n// node_modules/date-fns/addMinutes.js\nfunction addMinutes(date, amount, options) {\n const _date = toDate(date, options?.in);\n _date.setTime(_date.getTime() + amount * millisecondsInMinute);\n return _date;\n}\n\n// node_modules/date-fns/addSeconds.js\nfunction addSeconds(date, amount, options) {\n return addMilliseconds(date, amount * 1e3, options);\n}\n\n// node_modules/date-fns/addYears.js\nfunction addYears(date, amount, options) {\n return addMonths(date, amount * 12, options);\n}\n\n// node_modules/date-fns/isDate.js\nfunction isDate(value) {\n return value instanceof Date || typeof value === \"object\" && Object.prototype.toString.call(value) === \"[object Date]\";\n}\n\n// node_modules/date-fns/isValid.js\nfunction isValid(date) {\n return !(!isDate(date) && typeof date !== \"number\" || isNaN(+toDate(date)));\n}\n\n// node_modules/date-fns/startOfYear.js\nfunction startOfYear(date, options) {\n const date_ = toDate(date, options?.in);\n date_.setFullYear(date_.getFullYear(), 0, 1);\n date_.setHours(0, 0, 0, 0);\n return date_;\n}\n\n// node_modules/date-fns/locale/en-US/_lib/formatDistance.js\nvar formatDistanceLocale = {\n lessThanXSeconds: {\n one: \"less than a second\",\n other: \"less than {{count}} seconds\"\n },\n xSeconds: {\n one: \"1 second\",\n other: \"{{count}} seconds\"\n },\n halfAMinute: \"half a minute\",\n lessThanXMinutes: {\n one: \"less than a minute\",\n other: \"less than {{count}} minutes\"\n },\n xMinutes: {\n one: \"1 minute\",\n other: \"{{count}} minutes\"\n },\n aboutXHours: {\n one: \"about 1 hour\",\n other: \"about {{count}} hours\"\n },\n xHours: {\n one: \"1 hour\",\n other: \"{{count}} hours\"\n },\n xDays: {\n one: \"1 day\",\n other: \"{{count}} days\"\n },\n aboutXWeeks: {\n one: \"about 1 week\",\n other: \"about {{count}} weeks\"\n },\n xWeeks: {\n one: \"1 week\",\n other: \"{{count}} weeks\"\n },\n aboutXMonths: {\n one: \"about 1 month\",\n other: \"about {{count}} months\"\n },\n xMonths: {\n one: \"1 month\",\n other: \"{{count}} months\"\n },\n aboutXYears: {\n one: \"about 1 year\",\n other: \"about {{count}} years\"\n },\n xYears: {\n one: \"1 year\",\n other: \"{{count}} years\"\n },\n overXYears: {\n one: \"over 1 year\",\n other: \"over {{count}} years\"\n },\n almostXYears: {\n one: \"almost 1 year\",\n other: \"almost {{count}} years\"\n }\n};\nvar formatDistance = (token, count, options) => {\n let result;\n const tokenValue = formatDistanceLocale[token];\n if (typeof tokenValue === \"string\") {\n result = tokenValue;\n } else if (count === 1) {\n result = tokenValue.one;\n } else {\n result = tokenValue.other.replace(\"{{count}}\", count.toString());\n }\n if (options?.addSuffix) {\n if (options.comparison && options.comparison > 0) {\n return \"in \" + result;\n } else {\n return result + \" ago\";\n }\n }\n return result;\n};\n\n// node_modules/date-fns/locale/_lib/buildFormatLongFn.js\nfunction buildFormatLongFn(args) {\n return (options = {}) => {\n const width = options.width ? String(options.width) : args.defaultWidth;\n const format2 = args.formats[width] || args.formats[args.defaultWidth];\n return format2;\n };\n}\n\n// node_modules/date-fns/locale/en-US/_lib/formatLong.js\nvar dateFormats = {\n full: \"EEEE, MMMM do, y\",\n long: \"MMMM do, y\",\n medium: \"MMM d, y\",\n short: \"MM/dd/yyyy\"\n};\nvar timeFormats = {\n full: \"h:mm:ss a zzzz\",\n long: \"h:mm:ss a z\",\n medium: \"h:mm:ss a\",\n short: \"h:mm a\"\n};\nvar dateTimeFormats = {\n full: \"{{date}} 'at' {{time}}\",\n long: \"{{date}} 'at' {{time}}\",\n medium: \"{{date}}, {{time}}\",\n short: \"{{date}}, {{time}}\"\n};\nvar formatLong = {\n date: buildFormatLongFn({\n formats: dateFormats,\n defaultWidth: \"full\"\n }),\n time: buildFormatLongFn({\n formats: timeFormats,\n defaultWidth: \"full\"\n }),\n dateTime: buildFormatLongFn({\n formats: dateTimeFormats,\n defaultWidth: \"full\"\n })\n};\n\n// node_modules/date-fns/locale/en-US/_lib/formatRelative.js\nvar formatRelativeLocale = {\n lastWeek: \"'last' eeee 'at' p\",\n yesterday: \"'yesterday at' p\",\n today: \"'today at' p\",\n tomorrow: \"'tomorrow at' p\",\n nextWeek: \"eeee 'at' p\",\n other: \"P\"\n};\nvar formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];\n\n// node_modules/date-fns/locale/_lib/buildLocalizeFn.js\nfunction buildLocalizeFn(args) {\n return (value, options) => {\n const context = options?.context ? String(options.context) : \"standalone\";\n let valuesArray;\n if (context === \"formatting\" && args.formattingValues) {\n const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;\n const width = options?.width ? String(options.width) : defaultWidth;\n valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];\n } else {\n const defaultWidth = args.defaultWidth;\n const width = options?.width ? String(options.width) : args.defaultWidth;\n valuesArray = args.values[width] || args.values[defaultWidth];\n }\n const index = args.argumentCallback ? args.argumentCallback(value) : value;\n return valuesArray[index];\n };\n}\n\n// node_modules/date-fns/locale/en-US/_lib/localize.js\nvar eraValues = {\n narrow: [\"B\", \"A\"],\n abbreviated: [\"BC\", \"AD\"],\n wide: [\"Before Christ\", \"Anno Domini\"]\n};\nvar quarterValues = {\n narrow: [\"1\", \"2\", \"3\", \"4\"],\n abbreviated: [\"Q1\", \"Q2\", \"Q3\", \"Q4\"],\n wide: [\"1st quarter\", \"2nd quarter\", \"3rd quarter\", \"4th quarter\"]\n};\nvar monthValues = {\n narrow: [\"J\", \"F\", \"M\", \"A\", \"M\", \"J\", \"J\", \"A\", \"S\", \"O\", \"N\", \"D\"],\n abbreviated: [\n \"Jan\",\n \"Feb\",\n \"Mar\",\n \"Apr\",\n \"May\",\n \"Jun\",\n \"Jul\",\n \"Aug\",\n \"Sep\",\n \"Oct\",\n \"Nov\",\n \"Dec\"\n ],\n wide: [\n \"January\",\n \"February\",\n \"March\",\n \"April\",\n \"May\",\n \"June\",\n \"July\",\n \"August\",\n \"September\",\n \"October\",\n \"November\",\n \"December\"\n ]\n};\nvar dayValues = {\n narrow: [\"S\", \"M\", \"T\", \"W\", \"T\", \"F\", \"S\"],\n short: [\"Su\", \"Mo\", \"Tu\", \"We\", \"Th\", \"Fr\", \"Sa\"],\n abbreviated: [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"],\n wide: [\n \"Sunday\",\n \"Monday\",\n \"Tuesday\",\n \"Wednesday\",\n \"Thursday\",\n \"Friday\",\n \"Saturday\"\n ]\n};\nvar dayPeriodValues = {\n narrow: {\n am: \"a\",\n pm: \"p\",\n midnight: \"mi\",\n noon: \"n\",\n morning: \"morning\",\n afternoon: \"afternoon\",\n evening: \"evening\",\n night: \"night\"\n },\n abbreviated: {\n am: \"AM\",\n pm: \"PM\",\n midnight: \"midnight\",\n noon: \"noon\",\n morning: \"morning\",\n afternoon: \"afternoon\",\n evening: \"evening\",\n night: \"night\"\n },\n wide: {\n am: \"a.m.\",\n pm: \"p.m.\",\n midnight: \"midnight\",\n noon: \"noon\",\n morning: \"morning\",\n afternoon: \"afternoon\",\n evening: \"evening\",\n night: \"night\"\n }\n};\nvar formattingDayPeriodValues = {\n narrow: {\n am: \"a\",\n pm: \"p\",\n midnight: \"mi\",\n noon: \"n\",\n morning: \"in the morning\",\n afternoon: \"in the afternoon\",\n evening: \"in the evening\",\n night: \"at night\"\n },\n abbreviated: {\n am: \"AM\",\n pm: \"PM\",\n midnight: \"midnight\",\n noon: \"noon\",\n morning: \"in the morning\",\n afternoon: \"in the afternoon\",\n evening: \"in the evening\",\n night: \"at night\"\n },\n wide: {\n am: \"a.m.\",\n pm: \"p.m.\",\n midnight: \"midnight\",\n noon: \"noon\",\n morning: \"in the morning\",\n afternoon: \"in the afternoon\",\n evening: \"in the evening\",\n night: \"at night\"\n }\n};\nvar ordinalNumber = (dirtyNumber, _options) => {\n const number = Number(dirtyNumber);\n const rem100 = number % 100;\n if (rem100 > 20 || rem100 < 10) {\n switch (rem100 % 10) {\n case 1:\n return number + \"st\";\n case 2:\n return number + \"nd\";\n case 3:\n return number + \"rd\";\n }\n }\n return number + \"th\";\n};\nvar localize = {\n ordinalNumber,\n era: buildLocalizeFn({\n values: eraValues,\n defaultWidth: \"wide\"\n }),\n quarter: buildLocalizeFn({\n values: quarterValues,\n defaultWidth: \"wide\",\n argumentCallback: (quarter) => quarter - 1\n }),\n month: buildLocalizeFn({\n values: monthValues,\n defaultWidth: \"wide\"\n }),\n day: buildLocalizeFn({\n values: dayValues,\n defaultWidth: \"wide\"\n }),\n dayPeriod: buildLocalizeFn({\n values: dayPeriodValues,\n defaultWidth: \"wide\",\n formattingValues: formattingDayPeriodValues,\n defaultFormattingWidth: \"wide\"\n })\n};\n\n// node_modules/date-fns/locale/_lib/buildMatchFn.js\nfunction buildMatchFn(args) {\n return (string, options = {}) => {\n const width = options.width;\n const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];\n const matchResult = string.match(matchPattern);\n if (!matchResult) {\n return null;\n }\n const matchedString = matchResult[0];\n const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];\n const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (\n // [TODO] -- I challenge you to fix the type\n findKey(parsePatterns, (pattern) => pattern.test(matchedString))\n );\n let value;\n value = args.valueCallback ? args.valueCallback(key) : key;\n value = options.valueCallback ? (\n // [TODO] -- I challenge you to fix the type\n options.valueCallback(value)\n ) : value;\n const rest = string.slice(matchedString.length);\n return { value, rest };\n };\n}\nfunction findKey(object, predicate) {\n for (const key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {\n return key;\n }\n }\n return void 0;\n}\nfunction findIndex(array, predicate) {\n for (let key = 0; key < array.length; key++) {\n if (predicate(array[key])) {\n return key;\n }\n }\n return void 0;\n}\n\n// node_modules/date-fns/locale/_lib/buildMatchPatternFn.js\nfunction buildMatchPatternFn(args) {\n return (string, options = {}) => {\n const matchResult = string.match(args.matchPattern);\n if (!matchResult) return null;\n const matchedString = matchResult[0];\n const parseResult = string.match(args.parsePattern);\n if (!parseResult) return null;\n let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];\n value = options.valueCallback ? options.valueCallback(value) : value;\n const rest = string.slice(matchedString.length);\n return { value, rest };\n };\n}\n\n// node_modules/date-fns/locale/en-US/_lib/match.js\nvar matchOrdinalNumberPattern = /^(\\d+)(th|st|nd|rd)?/i;\nvar parseOrdinalNumberPattern = /\\d+/i;\nvar matchEraPatterns = {\n narrow: /^(b|a)/i,\n abbreviated: /^(b\\.?\\s?c\\.?|b\\.?\\s?c\\.?\\s?e\\.?|a\\.?\\s?d\\.?|c\\.?\\s?e\\.?)/i,\n wide: /^(before christ|before common era|anno domini|common era)/i\n};\nvar parseEraPatterns = {\n any: [/^b/i, /^(a|c)/i]\n};\nvar matchQuarterPatterns = {\n narrow: /^[1234]/i,\n abbreviated: /^q[1234]/i,\n wide: /^[1234](th|st|nd|rd)? quarter/i\n};\nvar parseQuarterPatterns = {\n any: [/1/i, /2/i, /3/i, /4/i]\n};\nvar matchMonthPatterns = {\n narrow: /^[jfmasond]/i,\n abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,\n wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i\n};\nvar parseMonthPatterns = {\n narrow: [\n /^j/i,\n /^f/i,\n /^m/i,\n /^a/i,\n /^m/i,\n /^j/i,\n /^j/i,\n /^a/i,\n /^s/i,\n /^o/i,\n /^n/i,\n /^d/i\n ],\n any: [\n /^ja/i,\n /^f/i,\n /^mar/i,\n /^ap/i,\n /^may/i,\n /^jun/i,\n /^jul/i,\n /^au/i,\n /^s/i,\n /^o/i,\n /^n/i,\n /^d/i\n ]\n};\nvar matchDayPatterns = {\n narrow: /^[smtwf]/i,\n short: /^(su|mo|tu|we|th|fr|sa)/i,\n abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,\n wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i\n};\nvar parseDayPatterns = {\n narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],\n any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]\n};\nvar matchDayPeriodPatterns = {\n narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,\n any: /^([ap]\\.?\\s?m\\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i\n};\nvar parseDayPeriodPatterns = {\n any: {\n am: /^a/i,\n pm: /^p/i,\n midnight: /^mi/i,\n noon: /^no/i,\n morning: /morning/i,\n afternoon: /afternoon/i,\n evening: /evening/i,\n night: /night/i\n }\n};\nvar match = {\n ordinalNumber: buildMatchPatternFn({\n matchPattern: matchOrdinalNumberPattern,\n parsePattern: parseOrdinalNumberPattern,\n valueCallback: (value) => parseInt(value, 10)\n }),\n era: buildMatchFn({\n matchPatterns: matchEraPatterns,\n defaultMatchWidth: \"wide\",\n parsePatterns: parseEraPatterns,\n defaultParseWidth: \"any\"\n }),\n quarter: buildMatchFn({\n matchPatterns: matchQuarterPatterns,\n defaultMatchWidth: \"wide\",\n parsePatterns: parseQuarterPatterns,\n defaultParseWidth: \"any\",\n valueCallback: (index) => index + 1\n }),\n month: buildMatchFn({\n matchPatterns: matchMonthPatterns,\n defaultMatchWidth: \"wide\",\n parsePatterns: parseMonthPatterns,\n defaultParseWidth: \"any\"\n }),\n day: buildMatchFn({\n matchPatterns: matchDayPatterns,\n defaultMatchWidth: \"wide\",\n parsePatterns: parseDayPatterns,\n defaultParseWidth: \"any\"\n }),\n dayPeriod: buildMatchFn({\n matchPatterns: matchDayPeriodPatterns,\n defaultMatchWidth: \"any\",\n parsePatterns: parseDayPeriodPatterns,\n defaultParseWidth: \"any\"\n })\n};\n\n// node_modules/date-fns/locale/en-US.js\nvar enUS = {\n code: \"en-US\",\n formatDistance,\n formatLong,\n formatRelative,\n localize,\n match,\n options: {\n weekStartsOn: 0,\n firstWeekContainsDate: 1\n }\n};\n\n// node_modules/date-fns/getDayOfYear.js\nfunction getDayOfYear(date, options) {\n const _date = toDate(date, options?.in);\n const diff = differenceInCalendarDays(_date, startOfYear(_date));\n const dayOfYear = diff + 1;\n return dayOfYear;\n}\n\n// node_modules/date-fns/getISOWeek.js\nfunction getISOWeek(date, options) {\n const _date = toDate(date, options?.in);\n const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);\n return Math.round(diff / millisecondsInWeek) + 1;\n}\n\n// node_modules/date-fns/getWeekYear.js\nfunction getWeekYear(date, options) {\n const _date = toDate(date, options?.in);\n const year = _date.getFullYear();\n const defaultOptions2 = getDefaultOptions();\n const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;\n const firstWeekOfNextYear = constructFrom(options?.in || date, 0);\n firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);\n firstWeekOfNextYear.setHours(0, 0, 0, 0);\n const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);\n const firstWeekOfThisYear = constructFrom(options?.in || date, 0);\n firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);\n firstWeekOfThisYear.setHours(0, 0, 0, 0);\n const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);\n if (+_date >= +startOfNextYear) {\n return year + 1;\n } else if (+_date >= +startOfThisYear) {\n return year;\n } else {\n return year - 1;\n }\n}\n\n// node_modules/date-fns/startOfWeekYear.js\nfunction startOfWeekYear(date, options) {\n const defaultOptions2 = getDefaultOptions();\n const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;\n const year = getWeekYear(date, options);\n const firstWeek = constructFrom(options?.in || date, 0);\n firstWeek.setFullYear(year, 0, firstWeekContainsDate);\n firstWeek.setHours(0, 0, 0, 0);\n const _date = startOfWeek(firstWeek, options);\n return _date;\n}\n\n// node_modules/date-fns/getWeek.js\nfunction getWeek(date, options) {\n const _date = toDate(date, options?.in);\n const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);\n return Math.round(diff / millisecondsInWeek) + 1;\n}\n\n// node_modules/date-fns/_lib/addLeadingZeros.js\nfunction addLeadingZeros(number, targetLength) {\n const sign = number < 0 ? \"-\" : \"\";\n const output = Math.abs(number).toString().padStart(targetLength, \"0\");\n return sign + output;\n}\n\n// node_modules/date-fns/_lib/format/lightFormatters.js\nvar lightFormatters = {\n // Year\n y(date, token) {\n const signedYear = date.getFullYear();\n const year = signedYear > 0 ? signedYear : 1 - signedYear;\n return addLeadingZeros(token === \"yy\" ? year % 100 : year, token.length);\n },\n // Month\n M(date, token) {\n const month = date.getMonth();\n return token === \"M\" ? String(month + 1) : addLeadingZeros(month + 1, 2);\n },\n // Day of the month\n d(date, token) {\n return addLeadingZeros(date.getDate(), token.length);\n },\n // AM or PM\n a(date, token) {\n const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? \"pm\" : \"am\";\n switch (token) {\n case \"a\":\n case \"aa\":\n return dayPeriodEnumValue.toUpperCase();\n case \"aaa\":\n return dayPeriodEnumValue;\n case \"aaaaa\":\n return dayPeriodEnumValue[0];\n case \"aaaa\":\n default:\n return dayPeriodEnumValue === \"am\" ? \"a.m.\" : \"p.m.\";\n }\n },\n // Hour [1-12]\n h(date, token) {\n return addLeadingZeros(date.getHours() % 12 || 12, token.length);\n },\n // Hour [0-23]\n H(date, token) {\n return addLeadingZeros(date.getHours(), token.length);\n },\n // Minute\n m(date, token) {\n return addLeadingZeros(date.getMinutes(), token.length);\n },\n // Second\n s(date, token) {\n return addLeadingZeros(date.getSeconds(), token.length);\n },\n // Fraction of second\n S(date, token) {\n const numberOfDigits = token.length;\n const milliseconds = date.getMilliseconds();\n const fractionalSeconds = Math.trunc(\n milliseconds * Math.pow(10, numberOfDigits - 3)\n );\n return addLeadingZeros(fractionalSeconds, token.length);\n }\n};\n\n// node_modules/date-fns/_lib/format/formatters.js\nvar dayPeriodEnum = {\n am: \"am\",\n pm: \"pm\",\n midnight: \"midnight\",\n noon: \"noon\",\n morning: \"morning\",\n afternoon: \"afternoon\",\n evening: \"evening\",\n night: \"night\"\n};\nvar formatters = {\n // Era\n G: function(date, token, localize2) {\n const era = date.getFullYear() > 0 ? 1 : 0;\n switch (token) {\n // AD, BC\n case \"G\":\n case \"GG\":\n case \"GGG\":\n return localize2.era(era, { width: \"abbreviated\" });\n // A, B\n case \"GGGGG\":\n return localize2.era(era, { width: \"narrow\" });\n // Anno Domini, Before Christ\n case \"GGGG\":\n default:\n return localize2.era(era, { width: \"wide\" });\n }\n },\n // Year\n y: function(date, token, localize2) {\n if (token === \"yo\") {\n const signedYear = date.getFullYear();\n const year = signedYear > 0 ? signedYear : 1 - signedYear;\n return localize2.ordinalNumber(year, { unit: \"year\" });\n }\n return lightFormatters.y(date, token);\n },\n // Local week-numbering year\n Y: function(date, token, localize2, options) {\n const signedWeekYear = getWeekYear(date, options);\n const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;\n if (token === \"YY\") {\n const twoDigitYear = weekYear % 100;\n return addLeadingZeros(twoDigitYear, 2);\n }\n if (token === \"Yo\") {\n return localize2.ordinalNumber(weekYear, { unit: \"year\" });\n }\n return addLeadingZeros(weekYear, token.length);\n },\n // ISO week-numbering year\n R: function(date, token) {\n const isoWeekYear = getISOWeekYear(date);\n return addLeadingZeros(isoWeekYear, token.length);\n },\n // Extended year. This is a single number designating the year of this calendar system.\n // The main difference between `y` and `u` localizers are B.C. years:\n // | Year | `y` | `u` |\n // |------|-----|-----|\n // | AC 1 | 1 | 1 |\n // | BC 1 | 1 | 0 |\n // | BC 2 | 2 | -1 |\n // Also `yy` always returns the last two digits of a year,\n // while `uu` pads single digit years to 2 characters and returns other years unchanged.\n u: function(date, token) {\n const year = date.getFullYear();\n return addLeadingZeros(year, token.length);\n },\n // Quarter\n Q: function(date, token, localize2) {\n const quarter = Math.ceil((date.getMonth() + 1) / 3);\n switch (token) {\n // 1, 2, 3, 4\n case \"Q\":\n return String(quarter);\n // 01, 02, 03, 04\n case \"QQ\":\n return addLeadingZeros(quarter, 2);\n // 1st, 2nd, 3rd, 4th\n case \"Qo\":\n return localize2.ordinalNumber(quarter, { unit: \"quarter\" });\n // Q1, Q2, Q3, Q4\n case \"QQQ\":\n return localize2.quarter(quarter, {\n width: \"abbreviated\",\n context: \"formatting\"\n });\n // 1, 2, 3, 4 (narrow quarter; could be not numerical)\n case \"QQQQQ\":\n return localize2.quarter(quarter, {\n width: \"narrow\",\n context: \"formatting\"\n });\n // 1st quarter, 2nd quarter, ...\n case \"QQQQ\":\n default:\n return localize2.quarter(quarter, {\n width: \"wide\",\n context: \"formatting\"\n });\n }\n },\n // Stand-alone quarter\n q: function(date, token, localize2) {\n const quarter = Math.ceil((date.getMonth() + 1) / 3);\n switch (token) {\n // 1, 2, 3, 4\n case \"q\":\n return String(quarter);\n // 01, 02, 03, 04\n case \"qq\":\n return addLeadingZeros(quarter, 2);\n // 1st, 2nd, 3rd, 4th\n case \"qo\":\n return localize2.ordinalNumber(quarter, { unit: \"quarter\" });\n // Q1, Q2, Q3, Q4\n case \"qqq\":\n return localize2.quarter(quarter, {\n width: \"abbreviated\",\n context: \"standalone\"\n });\n // 1, 2, 3, 4 (narrow quarter; could be not numerical)\n case \"qqqqq\":\n return localize2.quarter(quarter, {\n width: \"narrow\",\n context: \"standalone\"\n });\n // 1st quarter, 2nd quarter, ...\n case \"qqqq\":\n default:\n return localize2.quarter(quarter, {\n width: \"wide\",\n context: \"standalone\"\n });\n }\n },\n // Month\n M: function(date, token, localize2) {\n const month = date.getMonth();\n switch (token) {\n case \"M\":\n case \"MM\":\n return lightFormatters.M(date, token);\n // 1st, 2nd, ..., 12th\n case \"Mo\":\n return localize2.ordinalNumber(month + 1, { unit: \"month\" });\n // Jan, Feb, ..., Dec\n case \"MMM\":\n return localize2.month(month, {\n width: \"abbreviated\",\n context: \"formatting\"\n });\n // J, F, ..., D\n case \"MMMMM\":\n return localize2.month(month, {\n width: \"narrow\",\n context: \"formatting\"\n });\n // January, February, ..., December\n case \"MMMM\":\n default:\n return localize2.month(month, { width: \"wide\", context: \"formatting\" });\n }\n },\n // Stand-alone month\n L: function(date, token, localize2) {\n const month = date.getMonth();\n switch (token) {\n // 1, 2, ..., 12\n case \"L\":\n return String(month + 1);\n // 01, 02, ..., 12\n case \"LL\":\n return addLeadingZeros(month + 1, 2);\n // 1st, 2nd, ..., 12th\n case \"Lo\":\n return localize2.ordinalNumber(month + 1, { unit: \"month\" });\n // Jan, Feb, ..., Dec\n case \"LLL\":\n return localize2.month(month, {\n width: \"abbreviated\",\n context: \"standalone\"\n });\n // J, F, ..., D\n case \"LLLLL\":\n return localize2.month(month, {\n width: \"narrow\",\n context: \"standalone\"\n });\n // January, February, ..., December\n case \"LLLL\":\n default:\n return localize2.month(month, { width: \"wide\", context: \"standalone\" });\n }\n },\n // Local week of year\n w: function(date, token, localize2, options) {\n const week = getWeek(date, options);\n if (token === \"wo\") {\n return localize2.ordinalNumber(week, { unit: \"week\" });\n }\n return addLeadingZeros(week, token.length);\n },\n // ISO week of year\n I: function(date, token, localize2) {\n const isoWeek = getISOWeek(date);\n if (token === \"Io\") {\n return localize2.ordinalNumber(isoWeek, { unit: \"week\" });\n }\n return addLeadingZeros(isoWeek, token.length);\n },\n // Day of the month\n d: function(date, token, localize2) {\n if (token === \"do\") {\n return localize2.ordinalNumber(date.getDate(), { unit: \"date\" });\n }\n return lightFormatters.d(date, token);\n },\n // Day of year\n D: function(date, token, localize2) {\n const dayOfYear = getDayOfYear(date);\n if (token === \"Do\") {\n return localize2.ordinalNumber(dayOfYear, { unit: \"dayOfYear\" });\n }\n return addLeadingZeros(dayOfYear, token.length);\n },\n // Day of week\n E: function(date, token, localize2) {\n const dayOfWeek = date.getDay();\n switch (token) {\n // Tue\n case \"E\":\n case \"EE\":\n case \"EEE\":\n return localize2.day(dayOfWeek, {\n width: \"abbreviated\",\n context: \"formatting\"\n });\n // T\n case \"EEEEE\":\n return localize2.day(dayOfWeek, {\n width: \"narrow\",\n context: \"formatting\"\n });\n // Tu\n case \"EEEEEE\":\n return localize2.day(dayOfWeek, {\n width: \"short\",\n context: \"formatting\"\n });\n // Tuesday\n case \"EEEE\":\n default:\n return localize2.day(dayOfWeek, {\n width: \"wide\",\n context: \"formatting\"\n });\n }\n },\n // Local day of week\n e: function(date, token, localize2, options) {\n const dayOfWeek = date.getDay();\n const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;\n switch (token) {\n // Numerical value (Nth day of week with current locale or weekStartsOn)\n case \"e\":\n return String(localDayOfWeek);\n // Padded numerical value\n case \"ee\":\n return addLeadingZeros(localDayOfWeek, 2);\n // 1st, 2nd, ..., 7th\n case \"eo\":\n return localize2.ordinalNumber(localDayOfWeek, { unit: \"day\" });\n case \"eee\":\n return localize2.day(dayOfWeek, {\n width: \"abbreviated\",\n context: \"formatting\"\n });\n // T\n case \"eeeee\":\n return localize2.day(dayOfWeek, {\n width: \"narrow\",\n context: \"formatting\"\n });\n // Tu\n case \"eeeeee\":\n return localize2.day(dayOfWeek, {\n width: \"short\",\n context: \"formatting\"\n });\n // Tuesday\n case \"eeee\":\n default:\n return localize2.day(dayOfWeek, {\n width: \"wide\",\n context: \"formatting\"\n });\n }\n },\n // Stand-alone local day of week\n c: function(date, token, localize2, options) {\n const dayOfWeek = date.getDay();\n const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;\n switch (token) {\n // Numerical value (same as in `e`)\n case \"c\":\n return String(localDayOfWeek);\n // Padded numerical value\n case \"cc\":\n return addLeadingZeros(localDayOfWeek, token.length);\n // 1st, 2nd, ..., 7th\n case \"co\":\n return localize2.ordinalNumber(localDayOfWeek, { unit: \"day\" });\n case \"ccc\":\n return localize2.day(dayOfWeek, {\n width: \"abbreviated\",\n context: \"standalone\"\n });\n // T\n case \"ccccc\":\n return localize2.day(dayOfWeek, {\n width: \"narrow\",\n context: \"standalone\"\n });\n // Tu\n case \"cccccc\":\n return localize2.day(dayOfWeek, {\n width: \"short\",\n context: \"standalone\"\n });\n // Tuesday\n case \"cccc\":\n default:\n return localize2.day(dayOfWeek, {\n width: \"wide\",\n context: \"standalone\"\n });\n }\n },\n // ISO day of week\n i: function(date, token, localize2) {\n const dayOfWeek = date.getDay();\n const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;\n switch (token) {\n // 2\n case \"i\":\n return String(isoDayOfWeek);\n // 02\n case \"ii\":\n return addLeadingZeros(isoDayOfWeek, token.length);\n // 2nd\n case \"io\":\n return localize2.ordinalNumber(isoDayOfWeek, { unit: \"day\" });\n // Tue\n case \"iii\":\n return localize2.day(dayOfWeek, {\n width: \"abbreviated\",\n context: \"formatting\"\n });\n // T\n case \"iiiii\":\n return localize2.day(dayOfWeek, {\n width: \"narrow\",\n context: \"formatting\"\n });\n // Tu\n case \"iiiiii\":\n return localize2.day(dayOfWeek, {\n width: \"short\",\n context: \"formatting\"\n });\n // Tuesday\n case \"iiii\":\n default:\n return localize2.day(dayOfWeek, {\n width: \"wide\",\n context: \"formatting\"\n });\n }\n },\n // AM or PM\n a: function(date, token, localize2) {\n const hours = date.getHours();\n const dayPeriodEnumValue = hours / 12 >= 1 ? \"pm\" : \"am\";\n switch (token) {\n case \"a\":\n case \"aa\":\n return localize2.dayPeriod(dayPeriodEnumValue, {\n width: \"abbreviated\",\n context: \"formatting\"\n });\n case \"aaa\":\n return localize2.dayPeriod(dayPeriodEnumValue, {\n width: \"abbreviated\",\n context: \"formatting\"\n }).toLowerCase();\n case \"aaaaa\":\n return localize2.dayPeriod(dayPeriodEnumValue, {\n width: \"narrow\",\n context: \"formatting\"\n });\n case \"aaaa\":\n default:\n return localize2.dayPeriod(dayPeriodEnumValue, {\n width: \"wide\",\n context: \"formatting\"\n });\n }\n },\n // AM, PM, midnight, noon\n b: function(date, token, localize2) {\n const hours = date.getHours();\n let dayPeriodEnumValue;\n if (hours === 12) {\n dayPeriodEnumValue = dayPeriodEnum.noon;\n } else if (hours === 0) {\n dayPeriodEnumValue = dayPeriodEnum.midnight;\n } else {\n dayPeriodEnumValue = hours / 12 >= 1 ? \"pm\" : \"am\";\n }\n switch (token) {\n case \"b\":\n case \"bb\":\n return localize2.dayPeriod(dayPeriodEnumValue, {\n width: \"abbreviated\",\n context: \"formatting\"\n });\n case \"bbb\":\n return localize2.dayPeriod(dayPeriodEnumValue, {\n width: \"abbreviated\",\n context: \"formatting\"\n }).toLowerCase();\n case \"bbbbb\":\n return localize2.dayPeriod(dayPeriodEnumValue, {\n width: \"narrow\",\n context: \"formatting\"\n });\n case \"bbbb\":\n default:\n return localize2.dayPeriod(dayPeriodEnumValue, {\n width: \"wide\",\n context: \"formatting\"\n });\n }\n },\n // in the morning, in the afternoon, in the evening, at night\n B: function(date, token, localize2) {\n const hours = date.getHours();\n let dayPeriodEnumValue;\n if (hours >= 17) {\n dayPeriodEnumValue = dayPeriodEnum.evening;\n } else if (hours >= 12) {\n dayPeriodEnumValue = dayPeriodEnum.afternoon;\n } else if (hours >= 4) {\n dayPeriodEnumValue = dayPeriodEnum.morning;\n } else {\n dayPeriodEnumValue = dayPeriodEnum.night;\n }\n switch (token) {\n case \"B\":\n case \"BB\":\n case \"BBB\":\n return localize2.dayPeriod(dayPeriodEnumValue, {\n width: \"abbreviated\",\n context: \"formatting\"\n });\n case \"BBBBB\":\n return localize2.dayPeriod(dayPeriodEnumValue, {\n width: \"narrow\",\n context: \"formatting\"\n });\n case \"BBBB\":\n default:\n return localize2.dayPeriod(dayPeriodEnumValue, {\n width: \"wide\",\n context: \"formatting\"\n });\n }\n },\n // Hour [1-12]\n h: function(date, token, localize2) {\n if (token === \"ho\") {\n let hours = date.getHours() % 12;\n if (hours === 0) hours = 12;\n return localize2.ordinalNumber(hours, { unit: \"hour\" });\n }\n return lightFormatters.h(date, token);\n },\n // Hour [0-23]\n H: function(date, token, localize2) {\n if (token === \"Ho\") {\n return localize2.ordinalNumber(date.getHours(), { unit: \"hour\" });\n }\n return lightFormatters.H(date, token);\n },\n // Hour [0-11]\n K: function(date, token, localize2) {\n const hours = date.getHours() % 12;\n if (token === \"Ko\") {\n return localize2.ordinalNumber(hours, { unit: \"hour\" });\n }\n return addLeadingZeros(hours, token.length);\n },\n // Hour [1-24]\n k: function(date, token, localize2) {\n let hours = date.getHours();\n if (hours === 0) hours = 24;\n if (token === \"ko\") {\n return localize2.ordinalNumber(hours, { unit: \"hour\" });\n }\n return addLeadingZeros(hours, token.length);\n },\n // Minute\n m: function(date, token, localize2) {\n if (token === \"mo\") {\n return localize2.ordinalNumber(date.getMinutes(), { unit: \"minute\" });\n }\n return lightFormatters.m(date, token);\n },\n // Second\n s: function(date, token, localize2) {\n if (token === \"so\") {\n return localize2.ordinalNumber(date.getSeconds(), { unit: \"second\" });\n }\n return lightFormatters.s(date, token);\n },\n // Fraction of second\n S: function(date, token) {\n return lightFormatters.S(date, token);\n },\n // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)\n X: function(date, token, _localize) {\n const timezoneOffset = date.getTimezoneOffset();\n if (timezoneOffset === 0) {\n return \"Z\";\n }\n switch (token) {\n // Hours and optional minutes\n case \"X\":\n return formatTimezoneWithOptionalMinutes(timezoneOffset);\n // Hours, minutes and optional seconds without `:` delimiter\n // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets\n // so this token always has the same output as `XX`\n case \"XXXX\":\n case \"XX\":\n return formatTimezone(timezoneOffset);\n // Hours, minutes and optional seconds with `:` delimiter\n // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets\n // so this token always has the same output as `XXX`\n case \"XXXXX\":\n case \"XXX\":\n // Hours and minutes with `:` delimiter\n default:\n return formatTimezone(timezoneOffset, \":\");\n }\n },\n // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)\n x: function(date, token, _localize) {\n const timezoneOffset = date.getTimezoneOffset();\n switch (token) {\n // Hours and optional minutes\n case \"x\":\n return formatTimezoneWithOptionalMinutes(timezoneOffset);\n // Hours, minutes and optional seconds without `:` delimiter\n // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets\n // so this token always has the same output as `xx`\n case \"xxxx\":\n case \"xx\":\n return formatTimezone(timezoneOffset);\n // Hours, minutes and optional seconds with `:` delimiter\n // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets\n // so this token always has the same output as `xxx`\n case \"xxxxx\":\n case \"xxx\":\n // Hours and minutes with `:` delimiter\n default:\n return formatTimezone(timezoneOffset, \":\");\n }\n },\n // Timezone (GMT)\n O: function(date, token, _localize) {\n const timezoneOffset = date.getTimezoneOffset();\n switch (token) {\n // Short\n case \"O\":\n case \"OO\":\n case \"OOO\":\n return \"GMT\" + formatTimezoneShort(timezoneOffset, \":\");\n // Long\n case \"OOOO\":\n default:\n return \"GMT\" + formatTimezone(timezoneOffset, \":\");\n }\n },\n // Timezone (specific non-location)\n z: function(date, token, _localize) {\n const timezoneOffset = date.getTimezoneOffset();\n switch (token) {\n // Short\n case \"z\":\n case \"zz\":\n case \"zzz\":\n return \"GMT\" + formatTimezoneShort(timezoneOffset, \":\");\n // Long\n case \"zzzz\":\n default:\n return \"GMT\" + formatTimezone(timezoneOffset, \":\");\n }\n },\n // Seconds timestamp\n t: function(date, token, _localize) {\n const timestamp = Math.trunc(+date / 1e3);\n return addLeadingZeros(timestamp, token.length);\n },\n // Milliseconds timestamp\n T: function(date, token, _localize) {\n return addLeadingZeros(+date, token.length);\n }\n};\nfunction formatTimezoneShort(offset, delimiter = \"\") {\n const sign = offset > 0 ? \"-\" : \"+\";\n const absOffset = Math.abs(offset);\n const hours = Math.trunc(absOffset / 60);\n const minutes = absOffset % 60;\n if (minutes === 0) {\n return sign + String(hours);\n }\n return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);\n}\nfunction formatTimezoneWithOptionalMinutes(offset, delimiter) {\n if (offset % 60 === 0) {\n const sign = offset > 0 ? \"-\" : \"+\";\n return sign + addLeadingZeros(Math.abs(offset) / 60, 2);\n }\n return formatTimezone(offset, delimiter);\n}\nfunction formatTimezone(offset, delimiter = \"\") {\n const sign = offset > 0 ? \"-\" : \"+\";\n const absOffset = Math.abs(offset);\n const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);\n const minutes = addLeadingZeros(absOffset % 60, 2);\n return sign + hours + delimiter + minutes;\n}\n\n// node_modules/date-fns/_lib/format/longFormatters.js\nvar dateLongFormatter = (pattern, formatLong2) => {\n switch (pattern) {\n case \"P\":\n return formatLong2.date({ width: \"short\" });\n case \"PP\":\n return formatLong2.date({ width: \"medium\" });\n case \"PPP\":\n return formatLong2.date({ width: \"long\" });\n case \"PPPP\":\n default:\n return formatLong2.date({ width: \"full\" });\n }\n};\nvar timeLongFormatter = (pattern, formatLong2) => {\n switch (pattern) {\n case \"p\":\n return formatLong2.time({ width: \"short\" });\n case \"pp\":\n return formatLong2.time({ width: \"medium\" });\n case \"ppp\":\n return formatLong2.time({ width: \"long\" });\n case \"pppp\":\n default:\n return formatLong2.time({ width: \"full\" });\n }\n};\nvar dateTimeLongFormatter = (pattern, formatLong2) => {\n const matchResult = pattern.match(/(P+)(p+)?/) || [];\n const datePattern = matchResult[1];\n const timePattern = matchResult[2];\n if (!timePattern) {\n return dateLongFormatter(pattern, formatLong2);\n }\n let dateTimeFormat;\n switch (datePattern) {\n case \"P\":\n dateTimeFormat = formatLong2.dateTime({ width: \"short\" });\n break;\n case \"PP\":\n dateTimeFormat = formatLong2.dateTime({ width: \"medium\" });\n break;\n case \"PPP\":\n dateTimeFormat = formatLong2.dateTime({ width: \"long\" });\n break;\n case \"PPPP\":\n default:\n dateTimeFormat = formatLong2.dateTime({ width: \"full\" });\n break;\n }\n return dateTimeFormat.replace(\"{{date}}\", dateLongFormatter(datePattern, formatLong2)).replace(\"{{time}}\", timeLongFormatter(timePattern, formatLong2));\n};\nvar longFormatters = {\n p: timeLongFormatter,\n P: dateTimeLongFormatter\n};\n\n// node_modules/date-fns/_lib/protectedTokens.js\nvar dayOfYearTokenRE = /^D+$/;\nvar weekYearTokenRE = /^Y+$/;\nvar throwTokens = [\"D\", \"DD\", \"YY\", \"YYYY\"];\nfunction isProtectedDayOfYearToken(token) {\n return dayOfYearTokenRE.test(token);\n}\nfunction isProtectedWeekYearToken(token) {\n return weekYearTokenRE.test(token);\n}\nfunction warnOrThrowProtectedError(token, format2, input) {\n const _message = message(token, format2, input);\n console.warn(_message);\n if (throwTokens.includes(token)) throw new RangeError(_message);\n}\nfunction message(token, format2, input) {\n const subject = token[0] === \"Y\" ? \"years\" : \"days of the month\";\n return `Use \\`${token.toLowerCase()}\\` instead of \\`${token}\\` (in \\`${format2}\\`) for formatting ${subject} to the input \\`${input}\\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;\n}\n\n// node_modules/date-fns/format.js\nvar formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\\w)\\1*|''|'(''|[^'])+('|$)|./g;\nvar longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;\nvar escapedStringRegExp = /^'([^]*?)'?$/;\nvar doubleQuoteRegExp = /''/g;\nvar unescapedLatinCharacterRegExp = /[a-zA-Z]/;\nfunction format(date, formatStr, options) {\n const defaultOptions2 = getDefaultOptions();\n const locale = options?.locale ?? defaultOptions2.locale ?? enUS;\n const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;\n const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;\n const originalDate = toDate(date, options?.in);\n if (!isValid(originalDate)) {\n throw new RangeError(\"Invalid time value\");\n }\n let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {\n const firstCharacter = substring[0];\n if (firstCharacter === \"p\" || firstCharacter === \"P\") {\n const longFormatter = longFormatters[firstCharacter];\n return longFormatter(substring, locale.formatLong);\n }\n return substring;\n }).join(\"\").match(formattingTokensRegExp).map((substring) => {\n if (substring === \"''\") {\n return { isToken: false, value: \"'\" };\n }\n const firstCharacter = substring[0];\n if (firstCharacter === \"'\") {\n return { isToken: false, value: cleanEscapedString(substring) };\n }\n if (formatters[firstCharacter]) {\n return { isToken: true, value: substring };\n }\n if (firstCharacter.match(unescapedLatinCharacterRegExp)) {\n throw new RangeError(\n \"Format string contains an unescaped latin alphabet character `\" + firstCharacter + \"`\"\n );\n }\n return { isToken: false, value: substring };\n });\n if (locale.localize.preprocessor) {\n parts = locale.localize.preprocessor(originalDate, parts);\n }\n const formatterOptions = {\n firstWeekContainsDate,\n weekStartsOn,\n locale\n };\n return parts.map((part) => {\n if (!part.isToken) return part.value;\n const token = part.value;\n if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {\n warnOrThrowProtectedError(token, formatStr, String(date));\n }\n const formatter = formatters[token[0]];\n return formatter(originalDate, token, locale.localize, formatterOptions);\n }).join(\"\");\n}\nfunction cleanEscapedString(input) {\n const matched = input.match(escapedStringRegExp);\n if (!matched) {\n return input;\n }\n return matched[1].replace(doubleQuoteRegExp, \"'\");\n}\n\n// node_modules/date-fns/subDays.js\nfunction subDays(date, amount, options) {\n return addDays(date, -amount, options);\n}\n\n// node_modules/date-fns/parseISO.js\nfunction parseISO(argument, options) {\n const invalidDate = () => constructFrom(options?.in, NaN);\n const additionalDigits = options?.additionalDigits ?? 2;\n const dateStrings = splitDateString(argument);\n let date;\n if (dateStrings.date) {\n const parseYearResult = parseYear(dateStrings.date, additionalDigits);\n date = parseDate(parseYearResult.restDateString, parseYearResult.year);\n }\n if (!date || isNaN(+date)) return invalidDate();\n const timestamp = +date;\n let time = 0;\n let offset;\n if (dateStrings.time) {\n time = parseTime(dateStrings.time);\n if (isNaN(time)) return invalidDate();\n }\n if (dateStrings.timezone) {\n offset = parseTimezone(dateStrings.timezone);\n if (isNaN(offset)) return invalidDate();\n } else {\n const tmpDate = new Date(timestamp + time);\n const result = toDate(0, options?.in);\n result.setFullYear(\n tmpDate.getUTCFullYear(),\n tmpDate.getUTCMonth(),\n tmpDate.getUTCDate()\n );\n result.setHours(\n tmpDate.getUTCHours(),\n tmpDate.getUTCMinutes(),\n tmpDate.getUTCSeconds(),\n tmpDate.getUTCMilliseconds()\n );\n return result;\n }\n return toDate(timestamp + time + offset, options?.in);\n}\nvar patterns = {\n dateTimeDelimiter: /[T ]/,\n timeZoneDelimiter: /[Z ]/i,\n timezone: /([Z+-].*)$/\n};\nvar dateRegex = /^-?(?:(\\d{3})|(\\d{2})(?:-?(\\d{2}))?|W(\\d{2})(?:-?(\\d{1}))?|)$/;\nvar timeRegex = /^(\\d{2}(?:[.,]\\d*)?)(?::?(\\d{2}(?:[.,]\\d*)?))?(?::?(\\d{2}(?:[.,]\\d*)?))?$/;\nvar timezoneRegex = /^([+-])(\\d{2})(?::?(\\d{2}))?$/;\nfunction splitDateString(dateString) {\n const dateStrings = {};\n const array = dateString.split(patterns.dateTimeDelimiter);\n let timeString;\n if (array.length > 2) {\n return dateStrings;\n }\n if (/:/.test(array[0])) {\n timeString = array[0];\n } else {\n dateStrings.date = array[0];\n timeString = array[1];\n if (patterns.timeZoneDelimiter.test(dateStrings.date)) {\n dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];\n timeString = dateString.substr(\n dateStrings.date.length,\n dateString.length\n );\n }\n }\n if (timeString) {\n const token = patterns.timezone.exec(timeString);\n if (token) {\n dateStrings.time = timeString.replace(token[1], \"\");\n dateStrings.timezone = token[1];\n } else {\n dateStrings.time = timeString;\n }\n }\n return dateStrings;\n}\nfunction parseYear(dateString, additionalDigits) {\n const regex = new RegExp(\n \"^(?:(\\\\d{4}|[+-]\\\\d{\" + (4 + additionalDigits) + \"})|(\\\\d{2}|[+-]\\\\d{\" + (2 + additionalDigits) + \"})$)\"\n );\n const captures = dateString.match(regex);\n if (!captures) return { year: NaN, restDateString: \"\" };\n const year = captures[1] ? parseInt(captures[1]) : null;\n const century = captures[2] ? parseInt(captures[2]) : null;\n return {\n year: century === null ? year : century * 100,\n restDateString: dateString.slice((captures[1] || captures[2]).length)\n };\n}\nfunction parseDate(dateString, year) {\n if (year === null) return /* @__PURE__ */ new Date(NaN);\n const captures = dateString.match(dateRegex);\n if (!captures) return /* @__PURE__ */ new Date(NaN);\n const isWeekDate = !!captures[4];\n const dayOfYear = parseDateUnit(captures[1]);\n const month = parseDateUnit(captures[2]) - 1;\n const day = parseDateUnit(captures[3]);\n const week = parseDateUnit(captures[4]);\n const dayOfWeek = parseDateUnit(captures[5]) - 1;\n if (isWeekDate) {\n if (!validateWeekDate(year, week, dayOfWeek)) {\n return /* @__PURE__ */ new Date(NaN);\n }\n return dayOfISOWeekYear(year, week, dayOfWeek);\n } else {\n const date = /* @__PURE__ */ new Date(0);\n if (!validateDate(year, month, day) || !validateDayOfYearDate(year, dayOfYear)) {\n return /* @__PURE__ */ new Date(NaN);\n }\n date.setUTCFullYear(year, month, Math.max(dayOfYear, day));\n return date;\n }\n}\nfunction parseDateUnit(value) {\n return value ? parseInt(value) : 1;\n}\nfunction parseTime(timeString) {\n const captures = timeString.match(timeRegex);\n if (!captures) return NaN;\n const hours = parseTimeUnit(captures[1]);\n const minutes = parseTimeUnit(captures[2]);\n const seconds = parseTimeUnit(captures[3]);\n if (!validateTime(hours, minutes, seconds)) {\n return NaN;\n }\n return hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1e3;\n}\nfunction parseTimeUnit(value) {\n return value && parseFloat(value.replace(\",\", \".\")) || 0;\n}\nfunction parseTimezone(timezoneString) {\n if (timezoneString === \"Z\") return 0;\n const captures = timezoneString.match(timezoneRegex);\n if (!captures) return 0;\n const sign = captures[1] === \"+\" ? -1 : 1;\n const hours = parseInt(captures[2]);\n const minutes = captures[3] && parseInt(captures[3]) || 0;\n if (!validateTimezone(hours, minutes)) {\n return NaN;\n }\n return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);\n}\nfunction dayOfISOWeekYear(isoWeekYear, week, day) {\n const date = /* @__PURE__ */ new Date(0);\n date.setUTCFullYear(isoWeekYear, 0, 4);\n const fourthOfJanuaryDay = date.getUTCDay() || 7;\n const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;\n date.setUTCDate(date.getUTCDate() + diff);\n return date;\n}\nvar daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\nfunction isLeapYearIndex(year) {\n return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;\n}\nfunction validateDate(year, month, date) {\n return month >= 0 && month <= 11 && date >= 1 && date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28));\n}\nfunction validateDayOfYearDate(year, dayOfYear) {\n return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);\n}\nfunction validateWeekDate(_year, week, day) {\n return week >= 1 && week <= 53 && day >= 0 && day <= 6;\n}\nfunction validateTime(hours, minutes, seconds) {\n if (hours === 24) {\n return minutes === 0 && seconds === 0;\n }\n return seconds >= 0 && seconds < 60 && minutes >= 0 && minutes < 60 && hours >= 0 && hours < 25;\n}\nfunction validateTimezone(_hours, minutes) {\n return minutes >= 0 && minutes <= 59;\n}\n\n// node_modules/date-fns/subMonths.js\nfunction subMonths(date, amount, options) {\n return addMonths(date, -amount, options);\n}\n\n// node_modules/date-fns/subHours.js\nfunction subHours(date, amount, options) {\n return addHours(date, -amount, options);\n}\n\n// node_modules/date-fns/subMinutes.js\nfunction subMinutes(date, amount, options) {\n return addMinutes(date, -amount, options);\n}\n\n// node_modules/date-fns/subSeconds.js\nfunction subSeconds(date, amount, options) {\n return addSeconds(date, -amount, options);\n}\n\n// node_modules/date-fns/subYears.js\nfunction subYears(date, amount, options) {\n return addYears(date, -amount, options);\n}\n\n// plugins/template-function-timestamp/src/index.ts\nvar dateArg = {\n type: \"text\",\n name: \"date\",\n label: \"Timestamp\",\n optional: true,\n description: \"Can be a timestamp in milliseconds, ISO string, or anything parseable by JS `new Date()`\",\n placeholder: (/* @__PURE__ */ new Date()).toISOString()\n};\nvar expressionArg = {\n type: \"text\",\n name: \"expression\",\n label: \"Expression\",\n description: \"Modification expression (eg. '-5d +2h 3m'). Available units: y, M, d, h, m, s\",\n optional: true,\n placeholder: \"-5d +2h 3m\"\n};\nvar formatArg = {\n name: \"format\",\n label: \"Format String\",\n description: `date-fns format string to describe the output (eg. \"yyyy-MM-dd 'at' HH:mm:ss\"). Wrap literal text in single quotes to escape it`,\n optional: true,\n placeholder: \"yyyy-MM-dd HH:mm:ss\",\n type: \"text\"\n};\nvar formatDocsBanner = {\n type: \"banner\",\n color: \"info\",\n inputs: [\n {\n type: \"markdown\",\n content: \"Uses [date-fns format tokens](https://date-fns.org/docs/format), not dayjs or Moment. Wrap literal text in single quotes to escape it.\"\n }\n ]\n};\nvar plugin = {\n templateFunctions: [\n {\n name: \"timestamp.unix\",\n description: \"Get the timestamp in seconds\",\n args: [dateArg],\n onRender: async (_ctx, args) => {\n const d = parseDateString(String(args.values.date ?? \"\"));\n return String(Math.floor(d.getTime() / 1e3));\n }\n },\n {\n name: \"timestamp.unixMillis\",\n description: \"Get the timestamp in milliseconds\",\n args: [dateArg],\n onRender: async (_ctx, args) => {\n const d = parseDateString(String(args.values.date ?? \"\"));\n return String(d.getTime());\n }\n },\n {\n name: \"timestamp.iso8601\",\n description: \"Get the date in ISO8601 format\",\n args: [dateArg],\n onRender: async (_ctx, args) => {\n const d = parseDateString(String(args.values.date ?? \"\"));\n return d.toISOString();\n }\n },\n {\n name: \"timestamp.format\",\n description: \"Format a date using a date-fns format string\",\n args: [formatDocsBanner, dateArg, formatArg],\n previewArgs: [formatArg.name],\n onRender: async (_ctx, args) => formatDatetime(args.values)\n },\n {\n name: \"timestamp.offset\",\n description: \"Get the offset of a date based on an expression\",\n args: [dateArg, expressionArg],\n previewArgs: [expressionArg.name],\n onRender: async (_ctx, args) => calculateDatetime(args.values)\n }\n ]\n};\nfunction applyDateOp(d, sign, amount, unit) {\n switch (unit) {\n case \"y\":\n return sign === \"-\" ? subYears(d, amount) : addYears(d, amount);\n case \"M\":\n return sign === \"-\" ? subMonths(d, amount) : addMonths(d, amount);\n case \"d\":\n return sign === \"-\" ? subDays(d, amount) : addDays(d, amount);\n case \"h\":\n return sign === \"-\" ? subHours(d, amount) : addHours(d, amount);\n case \"m\":\n return sign === \"-\" ? subMinutes(d, amount) : addMinutes(d, amount);\n case \"s\":\n return sign === \"-\" ? subSeconds(d, amount) : addSeconds(d, amount);\n default:\n throw new Error(`Invalid data calculation unit: ${unit}`);\n }\n}\nfunction parseOp(op) {\n const match2 = op.match(/^([+-]?)(\\d+)([yMdhms])$/);\n if (!match2) {\n throw new Error(`Invalid date expression: ${op}`);\n }\n const [, sign, amount, unit] = match2;\n if (!unit) return null;\n return { sign: sign ?? \"+\", amount: Number(amount ?? 0), unit };\n}\nfunction parseDateString(date) {\n if (!date.trim()) {\n return /* @__PURE__ */ new Date();\n }\n const isoDate = parseISO(date);\n if (isValid(isoDate)) {\n return isoDate;\n }\n const jsDate = /^\\d+(\\.\\d+)?$/.test(date) ? new Date(Number(date)) : new Date(date);\n if (isValid(jsDate)) {\n return jsDate;\n }\n throw new Error(`Invalid date: ${date}`);\n}\nfunction calculateDatetime(args) {\n const { date, expression } = args;\n let jsDate = parseDateString(date ?? \"\");\n if (expression) {\n const ops = String(expression).split(\" \").map((s) => s.trim()).filter(Boolean);\n for (const op of ops) {\n const parsed = parseOp(op);\n if (parsed) {\n jsDate = applyDateOp(jsDate, parsed.sign, parsed.amount, parsed.unit);\n }\n }\n }\n return jsDate.toISOString();\n}\nfunction formatDatetime(args) {\n const { date, format: format2 } = args;\n const d = parseDateString(date ?? \"\");\n return format(d, String(format2 || \"yyyy-MM-dd HH:mm:ss\"), { in: args.in });\n}\n" }, - { name: "importer-curl", source: "\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// plugins/importer-curl/src/index.ts\nvar index_exports = {};\n__export(index_exports, {\n convertCurl: () => convertCurl,\n plugin: () => plugin\n});\nmodule.exports = __toCommonJS(index_exports);\n\n// node_modules/shlex/shlex.js\nvar Shlexer = class {\n constructor(string) {\n this.i = 0;\n this.string = string;\n this.whitespace = \" \t\\r\\n\";\n this.quotes = `'\"`;\n this.escapes = \"\\\\\";\n this.escapedQuotes = '\"';\n this.ansiCQuotes = true;\n this.localeQuotes = true;\n this.debug = false;\n }\n readChar() {\n return this.string.charAt(this.i++);\n }\n processEscapes(string, quote, isAnsiCQuote) {\n if (!isAnsiCQuote && !this.escapedQuotes.includes(quote)) {\n return string;\n }\n const anyEscape = \"[\" + this.escapes.replace(/(.)/g, \"\\\\$1\") + \"]\";\n if (!isAnsiCQuote && this.escapedQuotes.includes(quote)) {\n const re = new RegExp(\n anyEscape + \"(\" + anyEscape + \"|\\\\\" + quote + \")\",\n \"g\"\n );\n return string.replace(re, \"$1\");\n }\n if (isAnsiCQuote) {\n const patterns = {\n // Literal characters\n \"([\\\\\\\\'\\\"?])\": (x) => x,\n // Non-printable ASCII characters\n \"a\": () => \"\\x07\",\n \"b\": () => \"\\b\",\n \"e|E\": () => \"\\x1B\",\n \"f\": () => \"\\f\",\n \"n\": () => \"\\n\",\n \"r\": () => \"\\r\",\n \"t\": () => \"\t\",\n \"v\": () => \"\\v\",\n // Octal bytes\n \"([0-7]{1,3})\": (x) => String.fromCharCode(parseInt(x, 8)),\n // Hexadecimal bytes\n \"x([0-9a-fA-F]{1,2})\": (x) => String.fromCharCode(parseInt(x, 16)),\n // Unicode code units\n \"u([0-9a-fA-F]{1,4})\": (x) => String.fromCharCode(parseInt(x, 16)),\n \"U([0-9a-fA-F]{1,8})\": (x) => String.fromCharCode(parseInt(x, 16)),\n // Control characters\n // https://en.wikipedia.org/wiki/Control_character#How_control_characters_map_to_keyboards\n \"c(.)\": (x) => {\n if (x === \"?\") {\n return \"\\x7F\";\n } else if (x === \"@\") {\n return \"\\0\";\n } else {\n return String.fromCharCode(x.charCodeAt(0) & 31);\n }\n }\n };\n const re = new RegExp(\n anyEscape + \"(\" + Object.keys(patterns).join(\"|\") + \")\",\n \"g\"\n );\n return string.replace(re, function(m, p1) {\n for (const matched in patterns) {\n const mm = new RegExp(\"^\" + matched + \"$\").exec(p1);\n if (mm === null) {\n continue;\n }\n return patterns[matched].apply(null, mm.slice(1));\n }\n });\n }\n return void 0;\n }\n *[Symbol.iterator]() {\n let inQuote = false;\n let inDollarQuote = false;\n let escaped = false;\n let lastDollar = -2;\n let token;\n if (this.debug) {\n console.log(\"full input:\", \">\" + this.string + \"<\");\n }\n while (true) {\n const pos = this.i;\n const char = this.readChar();\n if (this.debug) {\n console.log(\n \"position:\",\n pos,\n \"input:\",\n \">\" + char + \"<\",\n \"accumulated:\",\n token,\n \"inQuote:\",\n inQuote,\n \"inDollarQuote:\",\n inDollarQuote,\n \"lastDollar:\",\n lastDollar,\n \"escaped:\",\n escaped\n );\n }\n if (char === \"\") {\n if (inQuote) {\n throw new Error(\"Got EOF while in a quoted string\");\n }\n if (escaped) {\n throw new Error(\"Got EOF while in an escape sequence\");\n }\n if (token !== void 0) {\n yield token;\n }\n return;\n }\n if (escaped) {\n if (char === \"\\n\") {\n } else if (inQuote) {\n token = (token || \"\") + escaped + char;\n } else {\n token = (token || \"\") + char;\n }\n escaped = false;\n continue;\n }\n if (this.escapes.includes(char)) {\n if (!inQuote || inDollarQuote !== false || this.escapedQuotes.includes(inQuote)) {\n escaped = char;\n continue;\n } else {\n }\n }\n if (inQuote !== false) {\n if (char === inQuote) {\n token = this.processEscapes(token, inQuote, inDollarQuote === \"'\");\n inQuote = false;\n inDollarQuote = false;\n continue;\n }\n token = (token || \"\") + char;\n continue;\n }\n if (this.quotes.includes(char)) {\n inQuote = char;\n if (lastDollar === pos - 1) {\n if (char === \"'\" && !this.ansiCQuotes) {\n } else if (char === '\"' && !this.localeQuotes) {\n } else {\n inDollarQuote = char;\n }\n }\n token = token || \"\";\n if (inDollarQuote !== false) {\n token = token.slice(0, -1);\n }\n continue;\n }\n if (inQuote === false && char === \"$\") {\n lastDollar = pos;\n }\n if (this.whitespace.includes(char)) {\n if (token !== void 0) {\n yield token;\n }\n token = void 0;\n continue;\n }\n token = (token || \"\") + char;\n }\n }\n};\nfunction split(s) {\n return Array.from(new Shlexer(s));\n}\n\n// plugins/importer-curl/src/graphql.ts\nfunction parseGraphQLJsonBody({\n mimeType,\n text,\n url\n}) {\n if (mimeType !== \"application/json\") {\n return null;\n }\n let parsed;\n try {\n parsed = JSON.parse(text);\n } catch {\n return null;\n }\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n return null;\n }\n const body = parsed;\n if (typeof body.query !== \"string\") {\n return null;\n }\n if (hasExtraGraphQLEnvelopeFields(body)) {\n return null;\n }\n const signals = getGraphQLDetectionSignals(body, url);\n const score = signals.reduce((total, signal) => total + signal.score, 0);\n const hasGraphQLDocument = signals.some((signal) => signal.requiresGraphQLDocument);\n if (!hasGraphQLDocument || score < 4) {\n return null;\n }\n const result = { query: body.query };\n if (body.variables != null) {\n result.variables = typeof body.variables === \"string\" ? body.variables : JSON.stringify(body.variables, null, 2);\n }\n if (typeof body.operationName === \"string\") {\n result.operationName = body.operationName;\n }\n return result;\n}\nfunction hasExtraGraphQLEnvelopeFields(body) {\n const allowedKeys = /* @__PURE__ */ new Set([\"query\", \"variables\", \"operationName\"]);\n return Object.keys(body).some((key) => !allowedKeys.has(key));\n}\nfunction getGraphQLDetectionSignals(body, url) {\n const signals = [];\n const query = body.query;\n const urlPath = getUrlPath(url).toLowerCase();\n if (/\\b(graphql|gql)\\b/.test(urlPath)) {\n signals.push({ score: 2 });\n }\n if (/^(query|mutation|subscription|fragment)\\b/.test(query.trim())) {\n signals.push({ score: 3 });\n } else if (/^\\{[\\s\\S]*\\}$/.test(query.trim())) {\n signals.push({ score: 3, requiresGraphQLDocument: true });\n }\n if (/\\{[\\s\\S]*\\}/.test(query)) {\n signals.push({ score: 1, requiresGraphQLDocument: true });\n }\n if (typeof body.operationName === \"string\" && body.operationName.trim() !== \"\") {\n signals.push({ score: 1 });\n }\n if (body.variables != null && (typeof body.variables === \"object\" || typeof body.variables === \"string\")) {\n signals.push({ score: 1 });\n }\n return signals;\n}\nfunction getUrlPath(url) {\n try {\n return new URL(url).pathname;\n } catch {\n return url;\n }\n}\n\n// plugins/importer-curl/src/index.ts\nvar DATA_FLAGS = [\"d\", \"data\", \"data-raw\", \"data-urlencode\", \"data-binary\", \"data-ascii\"];\nvar SUPPORTED_FLAGS = [\n [\"cookie\", \"b\"],\n [\"d\", \"data\"],\n // Add url encoded data\n [\"data-ascii\"],\n [\"data-binary\"],\n [\"data-raw\"],\n [\"data-urlencode\"],\n [\"digest\"],\n // Apply auth as digest\n [\"form\", \"F\"],\n // Add multipart data\n [\"get\", \"G\"],\n // Put the post data in the URL\n [\"header\", \"H\"],\n [\"request\", \"X\"],\n // Request method\n [\"url\"],\n // Specify the URL explicitly\n [\"url-query\"],\n [\"user\", \"u\"],\n // Authentication\n DATA_FLAGS\n].flat();\nvar BOOLEAN_FLAGS = [\"G\", \"get\", \"digest\"];\nvar plugin = {\n importer: {\n name: \"cURL\",\n description: \"Import cURL commands\",\n onImport(_ctx, args) {\n return convertCurl(args.text);\n }\n }\n};\nfunction splitCommands(rawData) {\n const joined = rawData.replace(/\\\\\\r?\\n/g, \" \");\n function isEscaped(i) {\n let backslashes = 0;\n let j = i - 1;\n while (j >= 0 && joined[j] === \"\\\\\") {\n backslashes++;\n j--;\n }\n return backslashes % 2 !== 0;\n }\n const commands = [];\n let current = \"\";\n let inSingleQuote = false;\n let inDoubleQuote = false;\n let inDollarQuote = false;\n for (let i = 0; i < joined.length; i++) {\n if (joined[i] === void 0) break;\n const ch = joined[i];\n const next = joined[i + 1];\n if (!inDoubleQuote && !inDollarQuote && ch === \"'\" && !inSingleQuote) {\n inSingleQuote = true;\n current += ch;\n continue;\n }\n if (inSingleQuote && ch === \"'\") {\n inSingleQuote = false;\n current += ch;\n continue;\n }\n if (!inSingleQuote && !inDollarQuote && ch === '\"' && !inDoubleQuote) {\n inDoubleQuote = true;\n current += ch;\n continue;\n }\n if (inDoubleQuote && ch === '\"' && !isEscaped(i)) {\n inDoubleQuote = false;\n current += ch;\n continue;\n }\n if (!inSingleQuote && !inDoubleQuote && !inDollarQuote && ch === \"$\" && next === \"'\") {\n inDollarQuote = true;\n current += ch + next;\n i++;\n continue;\n }\n if (inDollarQuote && ch === \"'\" && !isEscaped(i)) {\n inDollarQuote = false;\n current += ch;\n continue;\n }\n const inQuote = inSingleQuote || inDoubleQuote || inDollarQuote;\n if (!inQuote && !isEscaped(i) && (ch === \";\" || ch === \"\\n\" || ch === \"\\r\" && next === \"\\n\")) {\n if (ch === \"\\r\") i++;\n if (current.trim()) {\n commands.push(current.trim());\n }\n current = \"\";\n continue;\n }\n current += ch;\n }\n if (current.trim()) {\n commands.push(current.trim());\n }\n return commands;\n}\nfunction convertCurl(rawData) {\n if (!rawData.match(/^\\s*curl /)) {\n return null;\n }\n const commands = splitCommands(rawData).map((cmd) => {\n const tokens = split(cmd);\n return tokens.flatMap((token) => {\n if (token.startsWith(\"-\") && !token.startsWith(\"--\") && token.length > 2) {\n return [token.slice(0, 2), token.slice(2)];\n }\n return token;\n });\n });\n const workspace = {\n model: \"workspace\",\n id: generateId(\"workspace\"),\n name: \"Curl Import\"\n };\n const requests = commands.filter((command) => command[0] === \"curl\").map((v) => importCommand(v, workspace.id));\n return {\n resources: {\n httpRequests: requests,\n workspaces: [workspace]\n }\n };\n}\nfunction extractAuthenticationFromHeaders(headers) {\n const authorizationHeaderIndex = headers.findIndex(\n (h) => h.name.toLowerCase() === \"authorization\"\n );\n const authorizationHeader = headers[authorizationHeaderIndex];\n if (authorizationHeader == null) {\n return {\n authenticationType: null,\n authentication: {},\n filteredHeaders: headers\n };\n }\n const value = authorizationHeader.value.trim();\n const spaceIndex = value.indexOf(\" \");\n if (spaceIndex <= 0) {\n return {\n authenticationType: null,\n authentication: {},\n filteredHeaders: headers\n };\n }\n const scheme = value.slice(0, spaceIndex).toLowerCase();\n const credentials = value.slice(spaceIndex + 1).trim();\n if (scheme === \"bearer\") {\n const filteredHeaders = headers.filter((_, i) => i !== authorizationHeaderIndex);\n return {\n authenticationType: \"bearer\",\n authentication: { token: credentials, prefix: \"Bearer\" },\n filteredHeaders\n };\n }\n if (scheme === \"basic\") {\n try {\n const decoded = Buffer.from(credentials, \"base64\").toString();\n const colonIndex = decoded.indexOf(\":\");\n if (colonIndex > 0) {\n const filteredHeaders = headers.filter((_, i) => i !== authorizationHeaderIndex);\n return {\n authenticationType: \"basic\",\n authentication: {\n username: decoded.slice(0, colonIndex),\n password: decoded.slice(colonIndex + 1)\n },\n filteredHeaders\n };\n }\n } catch {\n }\n }\n return {\n authenticationType: null,\n authentication: {},\n filteredHeaders: headers\n };\n}\nfunction importCommand(parseEntries, workspaceId) {\n const flagsByName = {};\n const singletons = [];\n for (let i = 1; i < parseEntries.length; i++) {\n let parseEntry = parseEntries[i];\n if (typeof parseEntry === \"string\") {\n parseEntry = parseEntry.trim();\n }\n if (typeof parseEntry === \"string\" && parseEntry.match(/^-{1,2}[\\w-]+/)) {\n const isSingleDash = parseEntry[0] === \"-\" && parseEntry[1] !== \"-\";\n let name = parseEntry.replace(/^-{1,2}/, \"\");\n if (!SUPPORTED_FLAGS.includes(name)) {\n continue;\n }\n let value;\n const nextEntry = parseEntries[i + 1];\n const hasValue = !BOOLEAN_FLAGS.includes(name);\n const nextEntryIsFlag = typeof nextEntry === \"string\" && (nextEntry.match(/^-[a-zA-Z]/) || nextEntry.match(/^--[a-zA-Z]/));\n if (isSingleDash && name.length > 1) {\n value = name.slice(1);\n name = name.slice(0, 1);\n } else if (typeof nextEntry === \"string\" && hasValue && !nextEntryIsFlag) {\n value = nextEntry;\n i++;\n } else {\n value = true;\n }\n flagsByName[name] = flagsByName[name] || [];\n flagsByName[name]?.push(value);\n } else if (parseEntry) {\n singletons.push(parseEntry);\n }\n }\n const urlArg = getPairValue(flagsByName, singletons[0] || \"\", [\"url\"]);\n const [baseUrl, search] = splitOnce(urlArg, \"?\");\n const urlParameters = search?.split(\"&\").map((p) => {\n const v = splitOnce(p, \"=\");\n return {\n name: decodeURIComponent(v[0] ?? \"\"),\n value: decodeURIComponent(v[1] ?? \"\"),\n enabled: true\n };\n }) ?? [];\n const url = baseUrl ?? urlArg;\n for (const p of flagsByName[\"url-query\"] ?? []) {\n if (typeof p !== \"string\") {\n continue;\n }\n const [name, value] = p.split(\"=\");\n urlParameters.push({\n name: name ?? \"\",\n value: value ?? \"\",\n enabled: true\n });\n }\n const [username, password] = getPairValue(flagsByName, \"\", [\"u\", \"user\"]).split(/:(.*)$/);\n const isDigest = getPairValue(flagsByName, false, [\"digest\"]);\n const authenticationType = username ? isDigest ? \"digest\" : \"basic\" : null;\n const authentication = username ? {\n username: username.trim(),\n password: (password ?? \"\").trim()\n } : {};\n const headers = [\n ...flagsByName.header || [],\n ...flagsByName.H || []\n ].map((header) => {\n const [name, value] = header.split(/:(.*)$/);\n if (!value) {\n return {\n name: (name ?? \"\").trim().replace(/;$/, \"\"),\n value: \"\",\n enabled: true\n };\n }\n return {\n name: (name ?? \"\").trim(),\n value: value.trim(),\n enabled: true\n };\n });\n const cookieHeaderValue = [\n ...flagsByName.cookie || [],\n ...flagsByName.b || []\n ].map((str) => {\n const name = str.split(\"=\", 1)[0];\n const value = str.replace(`${name}=`, \"\");\n return `${name}=${value}`;\n }).join(\"; \");\n const existingCookieHeader = headers.find((header) => header.name.toLowerCase() === \"cookie\");\n if (cookieHeaderValue && existingCookieHeader) {\n existingCookieHeader.value += `; ${cookieHeaderValue}`;\n } else if (cookieHeaderValue) {\n headers.push({\n name: \"Cookie\",\n value: cookieHeaderValue,\n enabled: true\n });\n }\n const {\n authenticationType: extractedAuthenticationType,\n authentication: extractedAuthentication,\n filteredHeaders\n } = extractAuthenticationFromHeaders(headers);\n const finalAuthenticationType = extractedAuthenticationType || authenticationType;\n const finalAuthentication = extractedAuthenticationType ? extractedAuthentication : authentication;\n const contentTypeHeader = filteredHeaders.find(\n (header) => header.name.toLowerCase() === \"content-type\"\n );\n const mimeType = contentTypeHeader ? contentTypeHeader.value.split(\";\")[0]?.trim() : null;\n const boundaryMatch = contentTypeHeader?.value.match(/boundary=([^\\s;]+)/i);\n const boundary = boundaryMatch?.[1];\n const rawDataValues = [\n ...flagsByName[\"data-raw\"] || [],\n ...flagsByName.d || [],\n ...flagsByName.data || [],\n ...flagsByName[\"data-binary\"] || [],\n ...flagsByName[\"data-ascii\"] || []\n ];\n let multipartFormDataFromRaw = null;\n if (mimeType === \"multipart/form-data\" && boundary && rawDataValues.length > 0) {\n const rawBody = rawDataValues.join(\"\");\n multipartFormDataFromRaw = parseMultipartFormData(rawBody, boundary);\n }\n const dataParameters = pairsToDataParameters(flagsByName);\n const formDataParams = [\n ...flagsByName.form || [],\n ...flagsByName.F || []\n ].map((str) => {\n const parts = str.split(\"=\");\n const name = parts[0] ?? \"\";\n const value = parts[1] ?? \"\";\n const item = {\n name,\n enabled: true\n };\n if (value.indexOf(\"@\") === 0) {\n item.file = value.slice(1);\n } else {\n item.value = value;\n }\n return item;\n });\n let body = {};\n let bodyType = null;\n const bodyAsGET = getPairValue(flagsByName, false, [\"G\", \"get\"]);\n const hasDataBody = dataParameters.length > 0 && !bodyAsGET;\n const hasFormBody = multipartFormDataFromRaw != null || formDataParams.length > 0;\n if (multipartFormDataFromRaw) {\n bodyType = \"multipart/form-data\";\n body = {\n form: multipartFormDataFromRaw\n };\n } else if (dataParameters.length > 0 && bodyAsGET) {\n urlParameters.push(...dataParameters);\n } else if (dataParameters.length > 0 && (mimeType == null || mimeType === \"application/x-www-form-urlencoded\")) {\n bodyType = mimeType ?? \"application/x-www-form-urlencoded\";\n body = {\n form: dataParameters.map((parameter) => ({\n ...parameter,\n name: decodeURIComponent(parameter.name || \"\"),\n value: decodeURIComponent(parameter.value || \"\")\n }))\n };\n filteredHeaders.push({\n name: \"Content-Type\",\n value: \"application/x-www-form-urlencoded\",\n enabled: true\n });\n } else if (dataParameters.length > 0) {\n const text = dataParameters.map(({ name, value }) => name && value ? `${name}=${value}` : name || value).join(\"&\");\n const graphqlBody = parseGraphQLJsonBody({ mimeType, text, url });\n if (graphqlBody != null) {\n bodyType = \"graphql\";\n body = graphqlBody;\n } else if (mimeType === \"application/json\" || mimeType === \"text/xml\" || mimeType === \"text/plain\") {\n bodyType = mimeType;\n body = { text };\n } else {\n bodyType = \"other\";\n body = { text };\n }\n } else if (formDataParams.length) {\n bodyType = mimeType ?? \"multipart/form-data\";\n body = {\n form: formDataParams\n };\n if (mimeType == null) {\n filteredHeaders.push({\n name: \"Content-Type\",\n value: \"multipart/form-data\",\n enabled: true\n });\n }\n }\n let method = getPairValue(flagsByName, \"\", [\"X\", \"request\"]).toUpperCase();\n if (method === \"\") {\n method = hasDataBody || hasFormBody ? \"POST\" : \"GET\";\n }\n const request = {\n id: generateId(\"http_request\"),\n model: \"http_request\",\n workspaceId,\n name: \"\",\n urlParameters,\n url,\n method,\n headers: filteredHeaders,\n authentication: finalAuthentication,\n authenticationType: finalAuthenticationType,\n body,\n bodyType,\n folderId: null,\n sortPriority: 0\n };\n return request;\n}\nfunction pairsToDataParameters(keyedPairs) {\n const dataParameters = [];\n for (const flagName of DATA_FLAGS) {\n const pairs = keyedPairs[flagName];\n if (!pairs || pairs.length === 0) {\n continue;\n }\n for (const p of pairs) {\n if (typeof p !== \"string\") continue;\n const params = p.split(\"&\");\n for (const param of params) {\n const [name, value] = splitOnce(param, \"=\");\n if (param.startsWith(\"@\")) {\n dataParameters.push({\n name: name ?? \"\",\n value: \"\",\n filePath: param.slice(1),\n enabled: true\n });\n } else {\n dataParameters.push({\n name: name ?? \"\",\n value: flagName === \"data-urlencode\" ? encodeURIComponent(value ?? \"\") : value ?? \"\",\n enabled: true\n });\n }\n }\n }\n }\n return dataParameters;\n}\nvar getPairValue = (pairsByName, defaultValue, names) => {\n for (const name of names) {\n if (pairsByName[name]?.length) {\n return pairsByName[name]?.[0];\n }\n }\n return defaultValue;\n};\nfunction splitOnce(str, sep) {\n const index = str.indexOf(sep);\n if (index > -1) {\n return [str.slice(0, index), str.slice(index + 1)];\n }\n return [str];\n}\nfunction parseMultipartFormData(rawBody, boundary) {\n const results = [];\n const boundaryMarker = `--${boundary}`;\n const parts = rawBody.split(boundaryMarker);\n for (const part of parts) {\n if (!part || part.trim() === \"--\" || part.trim() === \"--\\r\\n\") {\n continue;\n }\n const headerContentSplit = part.indexOf(\"\\r\\n\\r\\n\");\n if (headerContentSplit === -1) {\n continue;\n }\n const headerSection = part.slice(0, headerContentSplit);\n let content = part.slice(headerContentSplit + 4);\n if (content.endsWith(\"\\r\\n\")) {\n content = content.slice(0, -2);\n }\n const contentDispositionMatch = headerSection.match(\n /Content-Disposition:\\s*form-data;\\s*name=\"([^\"]+)\"(?:;\\s*filename=\"([^\"]+)\")?/i\n );\n if (!contentDispositionMatch) {\n continue;\n }\n const name = contentDispositionMatch[1] ?? \"\";\n const filename = contentDispositionMatch[2];\n const item = {\n name,\n enabled: true\n };\n if (filename) {\n item.file = filename;\n } else {\n item.value = content;\n }\n results.push(item);\n }\n return results.length > 0 ? results : null;\n}\nvar idCount = {};\nfunction generateId(model) {\n idCount[model] = (idCount[model] ?? -1) + 1;\n return `GENERATE_ID::${model.toUpperCase()}_${idCount[model]}`;\n}\n" }, + { name: "importer-curl", source: "\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// plugins/importer-curl/src/index.ts\nvar index_exports = {};\n__export(index_exports, {\n convertCurl: () => convertCurl,\n plugin: () => plugin\n});\nmodule.exports = __toCommonJS(index_exports);\n\n// node_modules/shlex/shlex.js\nvar Shlexer = class {\n constructor(string) {\n this.i = 0;\n this.string = string;\n this.whitespace = \" \t\\r\\n\";\n this.quotes = `'\"`;\n this.escapes = \"\\\\\";\n this.escapedQuotes = '\"';\n this.ansiCQuotes = true;\n this.localeQuotes = true;\n this.debug = false;\n }\n readChar() {\n return this.string.charAt(this.i++);\n }\n processEscapes(string, quote, isAnsiCQuote) {\n if (!isAnsiCQuote && !this.escapedQuotes.includes(quote)) {\n return string;\n }\n const anyEscape = \"[\" + this.escapes.replace(/(.)/g, \"\\\\$1\") + \"]\";\n if (!isAnsiCQuote && this.escapedQuotes.includes(quote)) {\n const re = new RegExp(\n anyEscape + \"(\" + anyEscape + \"|\\\\\" + quote + \")\",\n \"g\"\n );\n return string.replace(re, \"$1\");\n }\n if (isAnsiCQuote) {\n const patterns = {\n // Literal characters\n \"([\\\\\\\\'\\\"?])\": (x) => x,\n // Non-printable ASCII characters\n \"a\": () => \"\\x07\",\n \"b\": () => \"\\b\",\n \"e|E\": () => \"\\x1B\",\n \"f\": () => \"\\f\",\n \"n\": () => \"\\n\",\n \"r\": () => \"\\r\",\n \"t\": () => \"\t\",\n \"v\": () => \"\\v\",\n // Octal bytes\n \"([0-7]{1,3})\": (x) => String.fromCharCode(parseInt(x, 8)),\n // Hexadecimal bytes\n \"x([0-9a-fA-F]{1,2})\": (x) => String.fromCharCode(parseInt(x, 16)),\n // Unicode code units\n \"u([0-9a-fA-F]{1,4})\": (x) => String.fromCharCode(parseInt(x, 16)),\n \"U([0-9a-fA-F]{1,8})\": (x) => String.fromCharCode(parseInt(x, 16)),\n // Control characters\n // https://en.wikipedia.org/wiki/Control_character#How_control_characters_map_to_keyboards\n \"c(.)\": (x) => {\n if (x === \"?\") {\n return \"\\x7F\";\n } else if (x === \"@\") {\n return \"\\0\";\n } else {\n return String.fromCharCode(x.charCodeAt(0) & 31);\n }\n }\n };\n const re = new RegExp(\n anyEscape + \"(\" + Object.keys(patterns).join(\"|\") + \")\",\n \"g\"\n );\n return string.replace(re, function(m, p1) {\n for (const matched in patterns) {\n const mm = new RegExp(\"^\" + matched + \"$\").exec(p1);\n if (mm === null) {\n continue;\n }\n return patterns[matched].apply(null, mm.slice(1));\n }\n });\n }\n return void 0;\n }\n *[Symbol.iterator]() {\n let inQuote = false;\n let inDollarQuote = false;\n let escaped = false;\n let lastDollar = -2;\n let token;\n if (this.debug) {\n console.log(\"full input:\", \">\" + this.string + \"<\");\n }\n while (true) {\n const pos = this.i;\n const char = this.readChar();\n if (this.debug) {\n console.log(\n \"position:\",\n pos,\n \"input:\",\n \">\" + char + \"<\",\n \"accumulated:\",\n token,\n \"inQuote:\",\n inQuote,\n \"inDollarQuote:\",\n inDollarQuote,\n \"lastDollar:\",\n lastDollar,\n \"escaped:\",\n escaped\n );\n }\n if (char === \"\") {\n if (inQuote) {\n throw new Error(\"Got EOF while in a quoted string\");\n }\n if (escaped) {\n throw new Error(\"Got EOF while in an escape sequence\");\n }\n if (token !== void 0) {\n yield token;\n }\n return;\n }\n if (escaped) {\n if (char === \"\\n\") {\n } else if (inQuote) {\n token = (token || \"\") + escaped + char;\n } else {\n token = (token || \"\") + char;\n }\n escaped = false;\n continue;\n }\n if (this.escapes.includes(char)) {\n if (!inQuote || inDollarQuote !== false || this.escapedQuotes.includes(inQuote)) {\n escaped = char;\n continue;\n } else {\n }\n }\n if (inQuote !== false) {\n if (char === inQuote) {\n token = this.processEscapes(token, inQuote, inDollarQuote === \"'\");\n inQuote = false;\n inDollarQuote = false;\n continue;\n }\n token = (token || \"\") + char;\n continue;\n }\n if (this.quotes.includes(char)) {\n inQuote = char;\n if (lastDollar === pos - 1) {\n if (char === \"'\" && !this.ansiCQuotes) {\n } else if (char === '\"' && !this.localeQuotes) {\n } else {\n inDollarQuote = char;\n }\n }\n token = token || \"\";\n if (inDollarQuote !== false) {\n token = token.slice(0, -1);\n }\n continue;\n }\n if (inQuote === false && char === \"$\") {\n lastDollar = pos;\n }\n if (this.whitespace.includes(char)) {\n if (token !== void 0) {\n yield token;\n }\n token = void 0;\n continue;\n }\n token = (token || \"\") + char;\n }\n }\n};\nfunction split(s) {\n return Array.from(new Shlexer(s));\n}\n\n// plugins/importer-curl/src/graphql.ts\nfunction parseGraphQLJsonBody({\n mimeType,\n text,\n url\n}) {\n if (mimeType !== \"application/json\") {\n return null;\n }\n let parsed;\n try {\n parsed = JSON.parse(text);\n } catch {\n return null;\n }\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n return null;\n }\n const body = parsed;\n if (typeof body.query !== \"string\") {\n return null;\n }\n if (hasExtraGraphQLEnvelopeFields(body)) {\n return null;\n }\n const signals = getGraphQLDetectionSignals(body, url);\n const score = signals.reduce((total, signal) => total + signal.score, 0);\n const hasGraphQLDocument = signals.some((signal) => signal.requiresGraphQLDocument);\n if (!hasGraphQLDocument || score < 4) {\n return null;\n }\n const result = { query: body.query };\n if (body.variables != null) {\n result.variables = typeof body.variables === \"string\" ? body.variables : JSON.stringify(body.variables, null, 2);\n }\n if (typeof body.operationName === \"string\") {\n result.operationName = body.operationName;\n }\n return result;\n}\nfunction hasExtraGraphQLEnvelopeFields(body) {\n const allowedKeys = /* @__PURE__ */ new Set([\"query\", \"variables\", \"operationName\"]);\n return Object.keys(body).some((key) => !allowedKeys.has(key));\n}\nfunction getGraphQLDetectionSignals(body, url) {\n const signals = [];\n const query = body.query;\n const urlPath = getUrlPath(url).toLowerCase();\n if (/\\b(graphql|gql)\\b/.test(urlPath)) {\n signals.push({ score: 2 });\n }\n if (/^(query|mutation|subscription|fragment)\\b/.test(query.trim())) {\n signals.push({ score: 3 });\n } else if (/^\\{[\\s\\S]*\\}$/.test(query.trim())) {\n signals.push({ score: 3, requiresGraphQLDocument: true });\n }\n if (/\\{[\\s\\S]*\\}/.test(query)) {\n signals.push({ score: 1, requiresGraphQLDocument: true });\n }\n if (typeof body.operationName === \"string\" && body.operationName.trim() !== \"\") {\n signals.push({ score: 1 });\n }\n if (body.variables != null && (typeof body.variables === \"object\" || typeof body.variables === \"string\")) {\n signals.push({ score: 1 });\n }\n return signals;\n}\nfunction getUrlPath(url) {\n try {\n return new URL(url).pathname;\n } catch {\n return url;\n }\n}\n\n// plugins/importer-curl/src/index.ts\nvar DATA_FLAGS = [\"d\", \"data\", \"data-raw\", \"data-urlencode\", \"data-binary\", \"data-ascii\"];\nvar SUPPORTED_FLAGS = [\n [\"cookie\", \"b\"],\n [\"d\", \"data\"],\n // Add url encoded data\n [\"data-ascii\"],\n [\"data-binary\"],\n [\"data-raw\"],\n [\"data-urlencode\"],\n [\"digest\"],\n // Apply auth as digest\n [\"form\", \"F\"],\n // Add multipart data\n [\"get\", \"G\"],\n // Put the post data in the URL\n [\"header\", \"H\"],\n [\"request\", \"X\"],\n // Request method\n [\"url\"],\n // Specify the URL explicitly\n [\"url-query\"],\n [\"user\", \"u\"],\n // Authentication\n DATA_FLAGS\n].flat();\nvar BOOLEAN_FLAGS = [\"G\", \"get\", \"digest\"];\nvar VALUE_SHORT_FLAGS = SUPPORTED_FLAGS.flat().filter(\n (name) => name.length === 1 && !BOOLEAN_FLAGS.includes(name)\n);\nfunction expandShortFlags(token) {\n if (!token.startsWith(\"-\") || token.startsWith(\"--\") || token.length <= 2) {\n return [token];\n }\n const expanded = [];\n for (let i = 1; i < token.length; i++) {\n const name = token[i] ?? \"\";\n expanded.push(`-${name}`);\n if (VALUE_SHORT_FLAGS.includes(name)) {\n const value = token.slice(i + 1);\n if (value) {\n expanded.push(value);\n }\n break;\n }\n }\n return expanded;\n}\nvar plugin = {\n importer: {\n name: \"cURL\",\n description: \"Import cURL commands\",\n onImport(_ctx, args) {\n return convertCurl(args.text);\n }\n }\n};\nfunction splitCommands(rawData) {\n const joined = rawData.replace(/\\\\\\r?\\n/g, \" \");\n function isEscaped(i) {\n let backslashes = 0;\n let j = i - 1;\n while (j >= 0 && joined[j] === \"\\\\\") {\n backslashes++;\n j--;\n }\n return backslashes % 2 !== 0;\n }\n const commands = [];\n let current = \"\";\n let inSingleQuote = false;\n let inDoubleQuote = false;\n let inDollarQuote = false;\n for (let i = 0; i < joined.length; i++) {\n if (joined[i] === void 0) break;\n const ch = joined[i];\n const next = joined[i + 1];\n if (!inDoubleQuote && !inDollarQuote && ch === \"'\" && !inSingleQuote) {\n inSingleQuote = true;\n current += ch;\n continue;\n }\n if (inSingleQuote && ch === \"'\") {\n inSingleQuote = false;\n current += ch;\n continue;\n }\n if (!inSingleQuote && !inDollarQuote && ch === '\"' && !inDoubleQuote) {\n inDoubleQuote = true;\n current += ch;\n continue;\n }\n if (inDoubleQuote && ch === '\"' && !isEscaped(i)) {\n inDoubleQuote = false;\n current += ch;\n continue;\n }\n if (!inSingleQuote && !inDoubleQuote && !inDollarQuote && ch === \"$\" && next === \"'\") {\n inDollarQuote = true;\n current += ch + next;\n i++;\n continue;\n }\n if (inDollarQuote && ch === \"'\" && !isEscaped(i)) {\n inDollarQuote = false;\n current += ch;\n continue;\n }\n const inQuote = inSingleQuote || inDoubleQuote || inDollarQuote;\n if (!inQuote && !isEscaped(i) && (ch === \";\" || ch === \"\\n\" || ch === \"\\r\" && next === \"\\n\")) {\n if (ch === \"\\r\") i++;\n if (current.trim()) {\n commands.push(current.trim());\n }\n current = \"\";\n continue;\n }\n current += ch;\n }\n if (current.trim()) {\n commands.push(current.trim());\n }\n return commands;\n}\nfunction convertCurl(rawData) {\n if (!rawData.match(/^\\s*curl /)) {\n return null;\n }\n const commands = splitCommands(rawData).map((cmd) => {\n const tokens = split(cmd);\n return tokens.flatMap(expandShortFlags);\n });\n const workspace = {\n model: \"workspace\",\n id: generateId(\"workspace\"),\n name: \"Curl Import\"\n };\n const requests = commands.filter((command) => command[0] === \"curl\").map((v) => importCommand(v, workspace.id));\n return {\n resources: {\n httpRequests: requests,\n workspaces: [workspace]\n }\n };\n}\nfunction extractAuthenticationFromHeaders(headers) {\n const authorizationHeaderIndex = headers.findIndex(\n (h) => h.name.toLowerCase() === \"authorization\"\n );\n const authorizationHeader = headers[authorizationHeaderIndex];\n if (authorizationHeader == null) {\n return {\n authenticationType: null,\n authentication: {},\n filteredHeaders: headers\n };\n }\n const value = authorizationHeader.value.trim();\n const spaceIndex = value.indexOf(\" \");\n if (spaceIndex <= 0) {\n return {\n authenticationType: null,\n authentication: {},\n filteredHeaders: headers\n };\n }\n const scheme = value.slice(0, spaceIndex).toLowerCase();\n const credentials = value.slice(spaceIndex + 1).trim();\n if (scheme === \"bearer\") {\n const filteredHeaders = headers.filter((_, i) => i !== authorizationHeaderIndex);\n return {\n authenticationType: \"bearer\",\n authentication: { token: credentials, prefix: \"Bearer\" },\n filteredHeaders\n };\n }\n if (scheme === \"basic\") {\n try {\n const decoded = Buffer.from(credentials, \"base64\").toString();\n const colonIndex = decoded.indexOf(\":\");\n if (colonIndex > 0) {\n const filteredHeaders = headers.filter((_, i) => i !== authorizationHeaderIndex);\n return {\n authenticationType: \"basic\",\n authentication: {\n username: decoded.slice(0, colonIndex),\n password: decoded.slice(colonIndex + 1)\n },\n filteredHeaders\n };\n }\n } catch {\n }\n }\n return {\n authenticationType: null,\n authentication: {},\n filteredHeaders: headers\n };\n}\nfunction importCommand(parseEntries, workspaceId) {\n const flagsByName = {};\n const singletons = [];\n for (let i = 1; i < parseEntries.length; i++) {\n let parseEntry = parseEntries[i];\n if (typeof parseEntry === \"string\") {\n parseEntry = parseEntry.trim();\n }\n if (typeof parseEntry === \"string\" && parseEntry.match(/^-{1,2}[\\w-]+/)) {\n const isSingleDash = parseEntry[0] === \"-\" && parseEntry[1] !== \"-\";\n let name = parseEntry.replace(/^-{1,2}/, \"\");\n if (!SUPPORTED_FLAGS.includes(name)) {\n continue;\n }\n let value;\n const nextEntry = parseEntries[i + 1];\n const hasValue = !BOOLEAN_FLAGS.includes(name);\n const nextEntryIsFlag = typeof nextEntry === \"string\" && (nextEntry.match(/^-[a-zA-Z]/) || nextEntry.match(/^--[a-zA-Z]/));\n if (isSingleDash && name.length > 1) {\n value = name.slice(1);\n name = name.slice(0, 1);\n } else if (typeof nextEntry === \"string\" && hasValue && !nextEntryIsFlag) {\n value = nextEntry;\n i++;\n } else {\n value = true;\n }\n flagsByName[name] = flagsByName[name] || [];\n flagsByName[name]?.push(value);\n } else if (parseEntry) {\n singletons.push(parseEntry);\n }\n }\n const urlArg = getPairValue(flagsByName, singletons[0] || \"\", [\"url\"]);\n const [baseUrl, search] = splitOnce(urlArg, \"?\");\n const urlParameters = search?.split(\"&\").map((p) => {\n const v = splitOnce(p, \"=\");\n return {\n name: decodeURIComponent(v[0] ?? \"\"),\n value: decodeURIComponent(v[1] ?? \"\"),\n enabled: true\n };\n }) ?? [];\n const url = baseUrl ?? urlArg;\n for (const p of flagsByName[\"url-query\"] ?? []) {\n if (typeof p !== \"string\") {\n continue;\n }\n const [name, value] = p.split(\"=\");\n urlParameters.push({\n name: name ?? \"\",\n value: value ?? \"\",\n enabled: true\n });\n }\n const [username, password] = getPairValue(flagsByName, \"\", [\"u\", \"user\"]).split(/:(.*)$/);\n const isDigest = getPairValue(flagsByName, false, [\"digest\"]);\n const authenticationType = username ? isDigest ? \"digest\" : \"basic\" : null;\n const authentication = username ? {\n username: username.trim(),\n password: (password ?? \"\").trim()\n } : {};\n const headers = [\n ...flagsByName.header || [],\n ...flagsByName.H || []\n ].map((header) => {\n const [name, value] = header.split(/:(.*)$/);\n if (!value) {\n return {\n name: (name ?? \"\").trim().replace(/;$/, \"\"),\n value: \"\",\n enabled: true\n };\n }\n return {\n name: (name ?? \"\").trim(),\n value: value.trim(),\n enabled: true\n };\n });\n const cookieHeaderValue = [\n ...flagsByName.cookie || [],\n ...flagsByName.b || []\n ].map((str) => {\n const name = str.split(\"=\", 1)[0];\n const value = str.replace(`${name}=`, \"\");\n return `${name}=${value}`;\n }).join(\"; \");\n const existingCookieHeader = headers.find((header) => header.name.toLowerCase() === \"cookie\");\n if (cookieHeaderValue && existingCookieHeader) {\n existingCookieHeader.value += `; ${cookieHeaderValue}`;\n } else if (cookieHeaderValue) {\n headers.push({\n name: \"Cookie\",\n value: cookieHeaderValue,\n enabled: true\n });\n }\n const {\n authenticationType: extractedAuthenticationType,\n authentication: extractedAuthentication,\n filteredHeaders\n } = extractAuthenticationFromHeaders(headers);\n const finalAuthenticationType = extractedAuthenticationType || authenticationType;\n const finalAuthentication = extractedAuthenticationType ? extractedAuthentication : authentication;\n const contentTypeHeader = filteredHeaders.find(\n (header) => header.name.toLowerCase() === \"content-type\"\n );\n const mimeType = contentTypeHeader ? contentTypeHeader.value.split(\";\")[0]?.trim() : null;\n const boundaryMatch = contentTypeHeader?.value.match(/boundary=([^\\s;]+)/i);\n const boundary = boundaryMatch?.[1];\n const rawDataValues = [\n ...flagsByName[\"data-raw\"] || [],\n ...flagsByName.d || [],\n ...flagsByName.data || [],\n ...flagsByName[\"data-binary\"] || [],\n ...flagsByName[\"data-ascii\"] || []\n ];\n let multipartFormDataFromRaw = null;\n if (mimeType === \"multipart/form-data\" && boundary && rawDataValues.length > 0) {\n const rawBody = rawDataValues.join(\"\");\n multipartFormDataFromRaw = parseMultipartFormData(rawBody, boundary);\n }\n const dataParameters = pairsToDataParameters(flagsByName);\n const formDataParams = [\n ...flagsByName.form || [],\n ...flagsByName.F || []\n ].map((str) => {\n const parts = str.split(\"=\");\n const name = parts[0] ?? \"\";\n const value = parts[1] ?? \"\";\n const item = {\n name,\n enabled: true\n };\n if (value.indexOf(\"@\") === 0) {\n item.file = value.slice(1);\n } else {\n item.value = value;\n }\n return item;\n });\n let body = {};\n let bodyType = null;\n const bodyAsGET = getPairValue(flagsByName, false, [\"G\", \"get\"]);\n const hasDataBody = dataParameters.length > 0 && !bodyAsGET;\n const hasFormBody = multipartFormDataFromRaw != null || formDataParams.length > 0;\n if (multipartFormDataFromRaw) {\n bodyType = \"multipart/form-data\";\n body = {\n form: multipartFormDataFromRaw\n };\n } else if (dataParameters.length > 0 && bodyAsGET) {\n urlParameters.push(...dataParameters);\n } else if (dataParameters.length > 0 && (mimeType == null || mimeType === \"application/x-www-form-urlencoded\")) {\n bodyType = mimeType ?? \"application/x-www-form-urlencoded\";\n body = {\n form: dataParameters.map((parameter) => ({\n ...parameter,\n name: decodeURIComponent(parameter.name || \"\"),\n value: decodeURIComponent(parameter.value || \"\")\n }))\n };\n filteredHeaders.push({\n name: \"Content-Type\",\n value: \"application/x-www-form-urlencoded\",\n enabled: true\n });\n } else if (dataParameters.length > 0) {\n const text = dataParameters.map(({ name, value }) => name && value ? `${name}=${value}` : name || value).join(\"&\");\n const graphqlBody = parseGraphQLJsonBody({ mimeType, text, url });\n if (graphqlBody != null) {\n bodyType = \"graphql\";\n body = graphqlBody;\n } else if (mimeType === \"application/json\" || mimeType === \"text/xml\" || mimeType === \"text/plain\") {\n bodyType = mimeType;\n body = { text };\n } else {\n bodyType = \"other\";\n body = { text };\n }\n } else if (formDataParams.length) {\n bodyType = mimeType ?? \"multipart/form-data\";\n body = {\n form: formDataParams\n };\n if (mimeType == null) {\n filteredHeaders.push({\n name: \"Content-Type\",\n value: \"multipart/form-data\",\n enabled: true\n });\n }\n }\n let method = getPairValue(flagsByName, \"\", [\"X\", \"request\"]).toUpperCase();\n if (method === \"\") {\n method = hasDataBody || hasFormBody ? \"POST\" : \"GET\";\n }\n const request = {\n id: generateId(\"http_request\"),\n model: \"http_request\",\n workspaceId,\n name: \"\",\n urlParameters,\n url,\n method,\n headers: filteredHeaders,\n authentication: finalAuthentication,\n authenticationType: finalAuthenticationType,\n body,\n bodyType,\n folderId: null,\n sortPriority: 0\n };\n return request;\n}\nfunction pairsToDataParameters(keyedPairs) {\n const dataParameters = [];\n for (const flagName of DATA_FLAGS) {\n const pairs = keyedPairs[flagName];\n if (!pairs || pairs.length === 0) {\n continue;\n }\n for (const p of pairs) {\n if (typeof p !== \"string\") continue;\n const params = p.split(\"&\");\n for (const param of params) {\n const [name, value] = splitOnce(param, \"=\");\n if (param.startsWith(\"@\")) {\n dataParameters.push({\n name: name ?? \"\",\n value: \"\",\n filePath: param.slice(1),\n enabled: true\n });\n } else {\n dataParameters.push({\n name: name ?? \"\",\n value: flagName === \"data-urlencode\" ? encodeURIComponent(value ?? \"\") : value ?? \"\",\n enabled: true\n });\n }\n }\n }\n }\n return dataParameters;\n}\nvar getPairValue = (pairsByName, defaultValue, names) => {\n for (const name of names) {\n if (pairsByName[name]?.length) {\n return pairsByName[name]?.[0];\n }\n }\n return defaultValue;\n};\nfunction splitOnce(str, sep) {\n const index = str.indexOf(sep);\n if (index > -1) {\n return [str.slice(0, index), str.slice(index + 1)];\n }\n return [str];\n}\nfunction parseMultipartFormData(rawBody, boundary) {\n const results = [];\n const boundaryMarker = `--${boundary}`;\n const parts = rawBody.split(boundaryMarker);\n for (const part of parts) {\n if (!part || part.trim() === \"--\" || part.trim() === \"--\\r\\n\") {\n continue;\n }\n const headerContentSplit = part.indexOf(\"\\r\\n\\r\\n\");\n if (headerContentSplit === -1) {\n continue;\n }\n const headerSection = part.slice(0, headerContentSplit);\n let content = part.slice(headerContentSplit + 4);\n if (content.endsWith(\"\\r\\n\")) {\n content = content.slice(0, -2);\n }\n const contentDispositionMatch = headerSection.match(\n /Content-Disposition:\\s*form-data;\\s*name=\"([^\"]+)\"(?:;\\s*filename=\"([^\"]+)\")?/i\n );\n if (!contentDispositionMatch) {\n continue;\n }\n const name = contentDispositionMatch[1] ?? \"\";\n const filename = contentDispositionMatch[2];\n const item = {\n name,\n enabled: true\n };\n if (filename) {\n item.file = filename;\n } else {\n item.value = content;\n }\n results.push(item);\n }\n return results.length > 0 ? results : null;\n}\nvar idCount = {};\nfunction generateId(model) {\n idCount[model] = (idCount[model] ?? -1) + 1;\n return `GENERATE_ID::${model.toUpperCase()}_${idCount[model]}`;\n}\n" }, { name: "auth-bearer", source: "\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// plugins/auth-bearer/src/index.ts\nvar index_exports = {};\n__export(index_exports, {\n plugin: () => plugin\n});\nmodule.exports = __toCommonJS(index_exports);\nvar plugin = {\n authentication: {\n name: \"bearer\",\n label: \"Bearer Token\",\n shortLabel: \"Bearer\",\n args: [\n {\n type: \"text\",\n name: \"token\",\n label: \"Token\",\n optional: true,\n password: true\n },\n {\n type: \"text\",\n name: \"prefix\",\n label: \"Prefix\",\n optional: true,\n placeholder: \"\",\n defaultValue: \"Bearer\",\n description: 'The prefix to use for the Authorization header, which will be of the format \" \".'\n }\n ],\n async onApply(_ctx, { values }) {\n return { setHeaders: [generateAuthorizationHeader(values)] };\n }\n }\n};\nfunction generateAuthorizationHeader(values) {\n const token = String(values.token || \"\").trim();\n const prefix = String(values.prefix || \"\").trim();\n const value = `${prefix} ${token}`.trim();\n return { name: \"Authorization\", value };\n}\n" }, ]; diff --git a/packages/platform/src/web/send.ts b/packages/platform/src/web/send.ts index aad3e751..3eb2240e 100644 --- a/packages/platform/src/web/send.ts +++ b/packages/platform/src/web/send.ts @@ -60,12 +60,12 @@ interface PreparedHttpSend { } /** - * The desktop applies auth to the sendable request; here the proxy builds that, - * so the plugin's answer goes onto the model and the proxy folds it in. Same + * The desktop applies auth to the sendable request; here the server builds that, + * so the plugin's answer goes onto the model and the server folds it in. Same * bytes for a method that sets a header, which is every one that runs here. * * Not the same for one that *signs*, since the plugin sees the request before - * the proxy assembles it. AWS SigV4 and OAuth 1.0 are refused rather than + * the server assembles it. AWS SigV4 and OAuth 1.0 are refused rather than * mis-signed; see the sandbox README. */ async function applyAuthentication(