From a6b52aa5ff4405a4d6058d8ba053f17a6904119d Mon Sep 17 00:00:00 2001 From: Ryan Pandya Date: Sun, 15 Dec 2024 15:02:46 -0800 Subject: [PATCH] Small changes to frontend timeline view and sidebar --- apps/cli/bin/index.js | 15980 ++++++++++++++-- .../components/dashboard/sidebar/Sidebar.tsx | 36 +- .../dashboard/timeline/TimelineView.tsx | 4 +- 3 files changed, 14506 insertions(+), 1514 deletions(-) diff --git a/apps/cli/bin/index.js b/apps/cli/bin/index.js index 809f49b..e35ca2f 100644 --- a/apps/cli/bin/index.js +++ b/apps/cli/bin/index.js @@ -1,486 +1,15 @@ var _a, _b, _c, _d, _e, _f; -import process$1 from "node:process"; -import os from "node:os"; -import tty from "node:tty"; import require$$0 from "node:events"; import require$$1 from "node:child_process"; import require$$2 from "node:path"; import require$$3 from "node:fs"; -const ANSI_BACKGROUND_OFFSET = 10; -const wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`; -const wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`; -const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`; -const styles$1 = { - modifier: { - reset: [0, 0], - // 21 isn't widely supported and 22 does the same thing - bold: [1, 22], - dim: [2, 22], - italic: [3, 23], - underline: [4, 24], - overline: [53, 55], - inverse: [7, 27], - hidden: [8, 28], - strikethrough: [9, 29] - }, - color: { - black: [30, 39], - red: [31, 39], - green: [32, 39], - yellow: [33, 39], - blue: [34, 39], - magenta: [35, 39], - cyan: [36, 39], - white: [37, 39], - // Bright color - blackBright: [90, 39], - gray: [90, 39], - // Alias of `blackBright` - grey: [90, 39], - // Alias of `blackBright` - redBright: [91, 39], - greenBright: [92, 39], - yellowBright: [93, 39], - blueBright: [94, 39], - magentaBright: [95, 39], - cyanBright: [96, 39], - whiteBright: [97, 39] - }, - bgColor: { - bgBlack: [40, 49], - bgRed: [41, 49], - bgGreen: [42, 49], - bgYellow: [43, 49], - bgBlue: [44, 49], - bgMagenta: [45, 49], - bgCyan: [46, 49], - bgWhite: [47, 49], - // Bright color - bgBlackBright: [100, 49], - bgGray: [100, 49], - // Alias of `bgBlackBright` - bgGrey: [100, 49], - // Alias of `bgBlackBright` - bgRedBright: [101, 49], - bgGreenBright: [102, 49], - bgYellowBright: [103, 49], - bgBlueBright: [104, 49], - bgMagentaBright: [105, 49], - bgCyanBright: [106, 49], - bgWhiteBright: [107, 49] - } -}; -Object.keys(styles$1.modifier); -const foregroundColorNames = Object.keys(styles$1.color); -const backgroundColorNames = Object.keys(styles$1.bgColor); -[...foregroundColorNames, ...backgroundColorNames]; -function assembleStyles() { - const codes = /* @__PURE__ */ new Map(); - for (const [groupName, group] of Object.entries(styles$1)) { - for (const [styleName, style] of Object.entries(group)) { - styles$1[styleName] = { - open: `\x1B[${style[0]}m`, - close: `\x1B[${style[1]}m` - }; - group[styleName] = styles$1[styleName]; - codes.set(style[0], style[1]); - } - Object.defineProperty(styles$1, groupName, { - value: group, - enumerable: false - }); - } - Object.defineProperty(styles$1, "codes", { - value: codes, - enumerable: false - }); - styles$1.color.close = "\x1B[39m"; - styles$1.bgColor.close = "\x1B[49m"; - styles$1.color.ansi = wrapAnsi16(); - styles$1.color.ansi256 = wrapAnsi256(); - styles$1.color.ansi16m = wrapAnsi16m(); - styles$1.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET); - styles$1.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET); - styles$1.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET); - Object.defineProperties(styles$1, { - rgbToAnsi256: { - value(red, green, blue) { - if (red === green && green === blue) { - if (red < 8) { - return 16; - } - if (red > 248) { - return 231; - } - return Math.round((red - 8) / 247 * 24) + 232; - } - return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5); - }, - enumerable: false - }, - hexToRgb: { - value(hex) { - const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16)); - if (!matches) { - return [0, 0, 0]; - } - let [colorString] = matches; - if (colorString.length === 3) { - colorString = [...colorString].map((character) => character + character).join(""); - } - const integer = Number.parseInt(colorString, 16); - return [ - /* eslint-disable no-bitwise */ - integer >> 16 & 255, - integer >> 8 & 255, - integer & 255 - /* eslint-enable no-bitwise */ - ]; - }, - enumerable: false - }, - hexToAnsi256: { - value: (hex) => styles$1.rgbToAnsi256(...styles$1.hexToRgb(hex)), - enumerable: false - }, - ansi256ToAnsi: { - value(code) { - if (code < 8) { - return 30 + code; - } - if (code < 16) { - return 90 + (code - 8); - } - let red; - let green; - let blue; - if (code >= 232) { - red = ((code - 232) * 10 + 8) / 255; - green = red; - blue = red; - } else { - code -= 16; - const remainder = code % 36; - red = Math.floor(code / 36) / 5; - green = Math.floor(remainder / 6) / 5; - blue = remainder % 6 / 5; - } - const value = Math.max(red, green, blue) * 2; - if (value === 0) { - return 30; - } - let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red)); - if (value === 2) { - result += 60; - } - return result; - }, - enumerable: false - }, - rgbToAnsi: { - value: (red, green, blue) => styles$1.ansi256ToAnsi(styles$1.rgbToAnsi256(red, green, blue)), - enumerable: false - }, - hexToAnsi: { - value: (hex) => styles$1.ansi256ToAnsi(styles$1.hexToAnsi256(hex)), - enumerable: false - } - }); - return styles$1; -} -const ansiStyles = assembleStyles(); -function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process$1.argv) { - const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--"; - const position = argv.indexOf(prefix + flag); - const terminatorPosition = argv.indexOf("--"); - return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition); -} -const { env } = process$1; -let flagForceColor; -if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) { - flagForceColor = 0; -} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) { - flagForceColor = 1; -} -function envForceColor() { - if ("FORCE_COLOR" in env) { - if (env.FORCE_COLOR === "true") { - return 1; - } - if (env.FORCE_COLOR === "false") { - return 0; - } - return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3); - } -} -function translateLevel(level) { - if (level === 0) { - return false; - } - return { - level, - hasBasic: true, - has256: level >= 2, - has16m: level >= 3 - }; -} -function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) { - const noFlagForceColor = envForceColor(); - if (noFlagForceColor !== void 0) { - flagForceColor = noFlagForceColor; - } - const forceColor = sniffFlags ? flagForceColor : noFlagForceColor; - if (forceColor === 0) { - return 0; - } - if (sniffFlags) { - if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) { - return 3; - } - if (hasFlag("color=256")) { - return 2; - } - } - if ("TF_BUILD" in env && "AGENT_NAME" in env) { - return 1; - } - if (haveStream && !streamIsTTY && forceColor === void 0) { - return 0; - } - const min = forceColor || 0; - if (env.TERM === "dumb") { - return min; - } - if (process$1.platform === "win32") { - const osRelease = os.release().split("."); - if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) { - return Number(osRelease[2]) >= 14931 ? 3 : 2; - } - return 1; - } - if ("CI" in env) { - if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) { - return 3; - } - if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") { - return 1; - } - return min; - } - if ("TEAMCITY_VERSION" in env) { - return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0; - } - if (env.COLORTERM === "truecolor") { - return 3; - } - if (env.TERM === "xterm-kitty") { - return 3; - } - if ("TERM_PROGRAM" in env) { - const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10); - switch (env.TERM_PROGRAM) { - case "iTerm.app": { - return version >= 3 ? 3 : 2; - } - case "Apple_Terminal": { - return 2; - } - } - } - if (/-256(color)?$/i.test(env.TERM)) { - return 2; - } - if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { - return 1; - } - if ("COLORTERM" in env) { - return 1; - } - return min; -} -function createSupportsColor(stream, options = {}) { - const level = _supportsColor(stream, { - streamIsTTY: stream && stream.isTTY, - ...options - }); - return translateLevel(level); -} -const supportsColor = { - stdout: createSupportsColor({ isTTY: tty.isatty(1) }), - stderr: createSupportsColor({ isTTY: tty.isatty(2) }) -}; -function stringReplaceAll(string, substring, replacer) { - let index = string.indexOf(substring); - if (index === -1) { - return string; - } - const substringLength = substring.length; - let endIndex = 0; - let returnValue = ""; - do { - returnValue += string.slice(endIndex, index) + substring + replacer; - endIndex = index + substringLength; - index = string.indexOf(substring, endIndex); - } while (index !== -1); - returnValue += string.slice(endIndex); - return returnValue; -} -function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) { - let endIndex = 0; - let returnValue = ""; - do { - const gotCR = string[index - 1] === "\r"; - returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix; - endIndex = index + 1; - index = string.indexOf("\n", endIndex); - } while (index !== -1); - returnValue += string.slice(endIndex); - return returnValue; -} -const { stdout: stdoutColor, stderr: stderrColor } = supportsColor; -const GENERATOR = Symbol("GENERATOR"); -const STYLER = Symbol("STYLER"); -const IS_EMPTY = Symbol("IS_EMPTY"); -const levelMapping = [ - "ansi", - "ansi", - "ansi256", - "ansi16m" -]; -const styles = /* @__PURE__ */ Object.create(null); -const applyOptions = (object, options = {}) => { - if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) { - throw new Error("The `level` option should be an integer from 0 to 3"); - } - const colorLevel = stdoutColor ? stdoutColor.level : 0; - object.level = options.level === void 0 ? colorLevel : options.level; -}; -const chalkFactory = (options) => { - const chalk2 = (...strings) => strings.join(" "); - applyOptions(chalk2, options); - Object.setPrototypeOf(chalk2, createChalk.prototype); - return chalk2; -}; -function createChalk(options) { - return chalkFactory(options); -} -Object.setPrototypeOf(createChalk.prototype, Function.prototype); -for (const [styleName, style] of Object.entries(ansiStyles)) { - styles[styleName] = { - get() { - const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]); - Object.defineProperty(this, styleName, { value: builder }); - return builder; - } - }; -} -styles.visible = { - get() { - const builder = createBuilder(this, this[STYLER], true); - Object.defineProperty(this, "visible", { value: builder }); - return builder; - } -}; -const getModelAnsi = (model, level, type, ...arguments_) => { - if (model === "rgb") { - if (level === "ansi16m") { - return ansiStyles[type].ansi16m(...arguments_); - } - if (level === "ansi256") { - return ansiStyles[type].ansi256(ansiStyles.rgbToAnsi256(...arguments_)); - } - return ansiStyles[type].ansi(ansiStyles.rgbToAnsi(...arguments_)); - } - if (model === "hex") { - return getModelAnsi("rgb", level, type, ...ansiStyles.hexToRgb(...arguments_)); - } - return ansiStyles[type][model](...arguments_); -}; -const usedModels = ["rgb", "hex", "ansi256"]; -for (const model of usedModels) { - styles[model] = { - get() { - const { level } = this; - return function(...arguments_) { - const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansiStyles.color.close, this[STYLER]); - return createBuilder(this, styler, this[IS_EMPTY]); - }; - } - }; - const bgModel = "bg" + model[0].toUpperCase() + model.slice(1); - styles[bgModel] = { - get() { - const { level } = this; - return function(...arguments_) { - const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansiStyles.bgColor.close, this[STYLER]); - return createBuilder(this, styler, this[IS_EMPTY]); - }; - } - }; -} -const proto = Object.defineProperties(() => { -}, { - ...styles, - level: { - enumerable: true, - get() { - return this[GENERATOR].level; - }, - set(level) { - this[GENERATOR].level = level; - } - } -}); -const createStyler = (open, close, parent) => { - let openAll; - let closeAll; - if (parent === void 0) { - openAll = open; - closeAll = close; - } else { - openAll = parent.openAll + open; - closeAll = close + parent.closeAll; - } - return { - open, - close, - openAll, - closeAll, - parent - }; -}; -const createBuilder = (self, _styler, _isEmpty) => { - const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" ")); - Object.setPrototypeOf(builder, proto); - builder[GENERATOR] = self; - builder[STYLER] = _styler; - builder[IS_EMPTY] = _isEmpty; - return builder; -}; -const applyStyle = (self, string) => { - if (self.level <= 0 || !string) { - return self[IS_EMPTY] ? "" : string; - } - let styler = self[STYLER]; - if (styler === void 0) { - return string; - } - const { openAll, closeAll } = styler; - if (string.includes("\x1B")) { - while (styler !== void 0) { - string = stringReplaceAll(string, styler.close, styler.open); - styler = styler.parent; - } - } - const lfIndex = string.indexOf("\n"); - if (lfIndex !== -1) { - string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex); - } - return openAll + string + closeAll; -}; -Object.defineProperties(createChalk.prototype, styles); -const chalk = createChalk(); -createChalk({ level: stderrColor ? stderrColor.level : 0 }); +import process$2 from "node:process"; +import os$1 from "node:os"; +import tty from "node:tty"; +import require$$0$1 from "fs"; +import require$$1$1 from "path"; +import require$$2$1 from "os"; +import require$$3$1 from "crypto"; let globalOpts = void 0; function setGlobalOptions(opts) { globalOpts = opts; @@ -491,875 +20,7 @@ function getGlobalOptions() { } return globalOpts; } -function printStatusMessage(success, message) { - const status = "Error"; - const colorFunction = chalk.red; - console.error(colorFunction(`${status}: ${message}`)); -} -function printErrorMessageWithReason(message, error2) { - const errorMessage = "message" in error2 ? error2.message : error2; - printStatusMessage(false, `${message}. Reason: ${errorMessage}`); -} -function observable(subscribe) { - const self = { - subscribe(observer) { - let teardownRef = null; - let isDone = false; - let unsubscribed = false; - let teardownImmediately = false; - function unsubscribe() { - if (teardownRef === null) { - teardownImmediately = true; - return; - } - if (unsubscribed) { - return; - } - unsubscribed = true; - if (typeof teardownRef === "function") { - teardownRef(); - } else if (teardownRef) { - teardownRef.unsubscribe(); - } - } - teardownRef = subscribe({ - next(value) { - var _a2; - if (isDone) { - return; - } - (_a2 = observer.next) == null ? void 0 : _a2.call(observer, value); - }, - error(err) { - var _a2; - if (isDone) { - return; - } - isDone = true; - (_a2 = observer.error) == null ? void 0 : _a2.call(observer, err); - unsubscribe(); - }, - complete() { - var _a2; - if (isDone) { - return; - } - isDone = true; - (_a2 = observer.complete) == null ? void 0 : _a2.call(observer); - unsubscribe(); - } - }); - if (teardownImmediately) { - unsubscribe(); - } - return { - unsubscribe - }; - }, - pipe(...operations) { - return operations.reduce(pipeReducer, self); - } - }; - return self; -} -function pipeReducer(prev, fn) { - return fn(prev); -} -class ObservableAbortError extends Error { - constructor(message) { - super(message); - this.name = "ObservableAbortError"; - Object.setPrototypeOf(this, ObservableAbortError.prototype); - } -} -function observableToPromise(observable2) { - let abort; - const promise = new Promise((resolve, reject) => { - let isDone = false; - function onDone() { - if (isDone) { - return; - } - isDone = true; - reject(new ObservableAbortError("This operation was aborted.")); - obs$.unsubscribe(); - } - const obs$ = observable2.subscribe({ - next(data) { - isDone = true; - resolve(data); - onDone(); - }, - error(data) { - isDone = true; - reject(data); - onDone(); - }, - complete() { - isDone = true; - onDone(); - } - }); - abort = onDone; - }); - return { - promise, - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - abort - }; -} -function share(_opts) { - return (source) => { - let refCount = 0; - let subscription = null; - const observers = []; - function startIfNeeded() { - if (subscription) { - return; - } - subscription = source.subscribe({ - next(value) { - var _a2; - for (const observer of observers) { - (_a2 = observer.next) == null ? void 0 : _a2.call(observer, value); - } - }, - error(error2) { - var _a2; - for (const observer of observers) { - (_a2 = observer.error) == null ? void 0 : _a2.call(observer, error2); - } - }, - complete() { - var _a2; - for (const observer of observers) { - (_a2 = observer.complete) == null ? void 0 : _a2.call(observer); - } - } - }); - } - function resetIfNeeded() { - if (refCount === 0 && subscription) { - const _sub = subscription; - subscription = null; - _sub.unsubscribe(); - } - } - return observable((subscriber) => { - refCount++; - observers.push(subscriber); - startIfNeeded(); - return { - unsubscribe() { - refCount--; - resetIfNeeded(); - const index = observers.findIndex((v) => v === subscriber); - if (index > -1) { - observers.splice(index, 1); - } - } - }; - }); - }; -} -function createChain(opts) { - return observable((observer) => { - function execute(index = 0, op = opts.op) { - const next = opts.links[index]; - if (!next) { - throw new Error("No more links to execute - did you forget to add an ending link?"); - } - const subscription = next({ - op, - next(nextOp) { - const nextObserver = execute(index + 1, nextOp); - return nextObserver; - } - }); - return subscription; - } - const obs$ = execute(); - return obs$.subscribe(observer); - }); -} -const noop = () => { -}; -function createInnerProxy(callback, path2) { - const proxy = new Proxy(noop, { - get(_obj, key) { - if (typeof key !== "string" || key === "then") { - return void 0; - } - return createInnerProxy(callback, [ - ...path2, - key - ]); - }, - apply(_1, _2, args) { - const isApply = path2[path2.length - 1] === "apply"; - return callback({ - args: isApply ? args.length >= 2 ? args[1] : [] : args, - path: isApply ? path2.slice(0, -1) : path2 - }); - } - }); - return proxy; -} -const createRecursiveProxy = (callback) => createInnerProxy(callback, []); -const createFlatProxy = (callback) => { - return new Proxy(noop, { - get(_obj, name) { - if (typeof name !== "string" || name === "then") { - return void 0; - } - return callback(name); - } - }); -}; -function isObject(value) { - return !!value && !Array.isArray(value) && typeof value === "object"; -} -class UnknownCauseError extends Error { -} -function getCauseFromUnknown(cause) { - if (cause instanceof Error) { - return cause; - } - const type = typeof cause; - if (type === "undefined" || type === "function" || cause === null) { - return void 0; - } - if (type !== "object") { - return new Error(String(cause)); - } - if (isObject(cause)) { - const err = new UnknownCauseError(); - for (const key in cause) { - err[key] = cause[key]; - } - return err; - } - return void 0; -} -function transformResultInner(response, transformer) { - if ("error" in response) { - const error2 = transformer.deserialize(response.error); - return { - ok: false, - error: { - ...response, - error: error2 - } - }; - } - const result = { - ...response.result, - ...(!response.result.type || response.result.type === "data") && { - type: "data", - data: transformer.deserialize(response.result.data) - } - }; - return { - ok: true, - result - }; -} -class TransformResultError extends Error { - constructor() { - super("Unable to transform response from server"); - } -} -function transformResult(response, transformer) { - let result; - try { - result = transformResultInner(response, transformer); - } catch (err) { - throw new TransformResultError(); - } - if (!result.ok && (!isObject(result.error.error) || typeof result.error.error["code"] !== "number")) { - throw new TransformResultError(); - } - if (result.ok && !isObject(result.result)) { - throw new TransformResultError(); - } - return result; -} -typeof window === "undefined" || "Deno" in window || // eslint-disable-next-line @typescript-eslint/dot-notation -((_b = (_a = globalThis.process) == null ? void 0 : _a.env) == null ? void 0 : _b["NODE_ENV"]) === "test" || !!((_d = (_c = globalThis.process) == null ? void 0 : _c.env) == null ? void 0 : _d["JEST_WORKER_ID"]) || !!((_f = (_e = globalThis.process) == null ? void 0 : _e.env) == null ? void 0 : _f["VITEST_WORKER_ID"]); -function isTRPCClientError(cause) { - return cause instanceof TRPCClientError || /** - * @deprecated - * Delete in next major - */ - cause instanceof Error && cause.name === "TRPCClientError"; -} -function isTRPCErrorResponse(obj) { - return isObject(obj) && isObject(obj["error"]) && typeof obj["error"]["code"] === "number" && typeof obj["error"]["message"] === "string"; -} -class TRPCClientError extends Error { - static from(_cause, opts = {}) { - const cause = _cause; - if (isTRPCClientError(cause)) { - if (opts.meta) { - cause.meta = { - ...cause.meta, - ...opts.meta - }; - } - return cause; - } - if (isTRPCErrorResponse(cause)) { - return new TRPCClientError(cause.error.message, { - ...opts, - result: cause - }); - } - if (!(cause instanceof Error)) { - return new TRPCClientError("Unknown error", { - ...opts, - cause - }); - } - return new TRPCClientError(cause.message, { - ...opts, - cause: getCauseFromUnknown(cause) - }); - } - constructor(message, opts) { - var _a2, _b2; - const cause = opts == null ? void 0 : opts.cause; - super(message, { - cause - }); - this.meta = opts == null ? void 0 : opts.meta; - this.cause = cause; - this.shape = (_a2 = opts == null ? void 0 : opts.result) == null ? void 0 : _a2.error; - this.data = (_b2 = opts == null ? void 0 : opts.result) == null ? void 0 : _b2.error.data; - this.name = "TRPCClientError"; - Object.setPrototypeOf(this, TRPCClientError.prototype); - } -} -class TRPCUntypedClient { - $request({ type, input, path: path2, context = {} }) { - const chain$ = createChain({ - links: this.links, - op: { - id: ++this.requestId, - type, - path: path2, - input, - context - } - }); - return chain$.pipe(share()); - } - requestAsPromise(opts) { - const req$ = this.$request(opts); - const { promise, abort } = observableToPromise(req$); - const abortablePromise = new Promise((resolve, reject) => { - var _a2; - (_a2 = opts.signal) == null ? void 0 : _a2.addEventListener("abort", abort); - promise.then((envelope) => { - resolve(envelope.result.data); - }).catch((err) => { - reject(TRPCClientError.from(err)); - }); - }); - return abortablePromise; - } - query(path2, input, opts) { - return this.requestAsPromise({ - type: "query", - path: path2, - input, - context: opts == null ? void 0 : opts.context, - signal: opts == null ? void 0 : opts.signal - }); - } - mutation(path2, input, opts) { - return this.requestAsPromise({ - type: "mutation", - path: path2, - input, - context: opts == null ? void 0 : opts.context, - signal: opts == null ? void 0 : opts.signal - }); - } - subscription(path2, input, opts) { - const observable$ = this.$request({ - type: "subscription", - path: path2, - input, - context: opts == null ? void 0 : opts.context - }); - return observable$.subscribe({ - next(envelope) { - var _a2, _b2, _c2; - if (envelope.result.type === "started") { - (_a2 = opts.onStarted) == null ? void 0 : _a2.call(opts); - } else if (envelope.result.type === "stopped") { - (_b2 = opts.onStopped) == null ? void 0 : _b2.call(opts); - } else { - (_c2 = opts.onData) == null ? void 0 : _c2.call(opts, envelope.result.data); - } - }, - error(err) { - var _a2; - (_a2 = opts.onError) == null ? void 0 : _a2.call(opts, err); - }, - complete() { - var _a2; - (_a2 = opts.onComplete) == null ? void 0 : _a2.call(opts); - } - }); - } - constructor(opts) { - this.requestId = 0; - this.runtime = {}; - this.links = opts.links.map((link) => link(this.runtime)); - } -} -const clientCallTypeMap = { - query: "query", - mutate: "mutation", - subscribe: "subscription" -}; -const clientCallTypeToProcedureType = (clientCallType) => { - return clientCallTypeMap[clientCallType]; -}; -function createTRPCClientProxy(client) { - return createFlatProxy((key) => { - if (client.hasOwnProperty(key)) { - return client[key]; - } - if (key === "__untypedClient") { - return client; - } - return createRecursiveProxy(({ path: path2, args }) => { - const pathCopy = [ - key, - ...path2 - ]; - const procedureType = clientCallTypeToProcedureType(pathCopy.pop()); - const fullPath = pathCopy.join("."); - return client[procedureType](fullPath, ...args); - }); - }); -} -function createTRPCClient(opts) { - const client = new TRPCUntypedClient(opts); - const proxy = createTRPCClientProxy(client); - return proxy; -} -const isFunction = (fn) => typeof fn === "function"; -function getFetch(customFetchImpl) { - if (customFetchImpl) { - return customFetchImpl; - } - if (typeof window !== "undefined" && isFunction(window.fetch)) { - return window.fetch; - } - if (typeof globalThis !== "undefined" && isFunction(globalThis.fetch)) { - return globalThis.fetch; - } - throw new Error("No fetch implementation found"); -} -const throwFatalError = () => { - throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new"); -}; -function dataLoader(batchLoader) { - let pendingItems = null; - let dispatchTimer = null; - const destroyTimerAndPendingItems = () => { - clearTimeout(dispatchTimer); - dispatchTimer = null; - pendingItems = null; - }; - function groupItems(items) { - var _a2, _b2; - const groupedItems = [ - [] - ]; - let index = 0; - while (true) { - const item = items[index]; - if (!item) { - break; - } - const lastGroup = groupedItems[groupedItems.length - 1]; - if (item.aborted) { - (_a2 = item.reject) == null ? void 0 : _a2.call(item, new Error("Aborted")); - index++; - continue; - } - const isValid = batchLoader.validate(lastGroup.concat(item).map((it) => it.key)); - if (isValid) { - lastGroup.push(item); - index++; - continue; - } - if (lastGroup.length === 0) { - (_b2 = item.reject) == null ? void 0 : _b2.call(item, new Error("Input is too big for a single dispatch")); - index++; - continue; - } - groupedItems.push([]); - } - return groupedItems; - } - function dispatch() { - const groupedItems = groupItems(pendingItems); - destroyTimerAndPendingItems(); - for (const items of groupedItems) { - if (!items.length) { - continue; - } - const batch = { - items, - cancel: throwFatalError - }; - for (const item of items) { - item.batch = batch; - } - const unitResolver = (index, value) => { - var _a2; - const item = batch.items[index]; - (_a2 = item.resolve) == null ? void 0 : _a2.call(item, value); - item.batch = null; - item.reject = null; - item.resolve = null; - }; - const { promise, cancel } = batchLoader.fetch(batch.items.map((_item) => _item.key), unitResolver); - batch.cancel = cancel; - promise.then((result) => { - var _a2; - for (let i = 0; i < result.length; i++) { - const value = result[i]; - unitResolver(i, value); - } - for (const item of batch.items) { - (_a2 = item.reject) == null ? void 0 : _a2.call(item, new Error("Missing result")); - item.batch = null; - } - }).catch((cause) => { - var _a2; - for (const item of batch.items) { - (_a2 = item.reject) == null ? void 0 : _a2.call(item, cause); - item.batch = null; - } - }); - } - } - function load(key) { - const item = { - aborted: false, - key, - batch: null, - resolve: throwFatalError, - reject: throwFatalError - }; - const promise = new Promise((resolve, reject) => { - item.reject = reject; - item.resolve = resolve; - if (!pendingItems) { - pendingItems = []; - } - pendingItems.push(item); - }); - if (!dispatchTimer) { - dispatchTimer = setTimeout(dispatch); - } - const cancel = () => { - var _a2; - item.aborted = true; - if ((_a2 = item.batch) == null ? void 0 : _a2.items.every((item2) => item2.aborted)) { - item.batch.cancel(); - item.batch = null; - } - }; - return { - promise, - cancel - }; - } - return { - load - }; -} -function getAbortController(customAbortControllerImpl) { - if (customAbortControllerImpl) { - return customAbortControllerImpl; - } - if (typeof window !== "undefined" && window.AbortController) { - return window.AbortController; - } - if (typeof globalThis !== "undefined" && globalThis.AbortController) { - return globalThis.AbortController; - } - return null; -} -function getTransformer(transformer) { - const _transformer = transformer; - if (!_transformer) { - return { - input: { - serialize: (data) => data, - deserialize: (data) => data - }, - output: { - serialize: (data) => data, - deserialize: (data) => data - } - }; - } - if ("input" in _transformer) { - return _transformer; - } - return { - input: _transformer, - output: _transformer - }; -} -function resolveHTTPLinkOptions(opts) { - return { - url: opts.url.toString().replace(/\/$/, ""), - fetch: opts.fetch, - AbortController: getAbortController(opts.AbortController), - transformer: getTransformer(opts.transformer), - methodOverride: opts.methodOverride - }; -} -function arrayToDict(array) { - const dict = {}; - for (let index = 0; index < array.length; index++) { - const element = array[index]; - dict[index] = element; - } - return dict; -} -const METHOD = { - query: "GET", - mutation: "POST" -}; -function getInput(opts) { - return "input" in opts ? opts.transformer.input.serialize(opts.input) : arrayToDict(opts.inputs.map((_input) => opts.transformer.input.serialize(_input))); -} -const getUrl = (opts) => { - let url = opts.url + "/" + opts.path; - const queryParts = []; - if ("inputs" in opts) { - queryParts.push("batch=1"); - } - if (opts.type === "query") { - const input = getInput(opts); - if (input !== void 0 && opts.methodOverride !== "POST") { - queryParts.push(`input=${encodeURIComponent(JSON.stringify(input))}`); - } - } - if (queryParts.length) { - url += "?" + queryParts.join("&"); - } - return url; -}; -const getBody = (opts) => { - if (opts.type === "query" && opts.methodOverride !== "POST") { - return void 0; - } - const input = getInput(opts); - return input !== void 0 ? JSON.stringify(input) : void 0; -}; -const jsonHttpRequester = (opts) => { - return httpRequest({ - ...opts, - contentTypeHeader: "application/json", - getUrl, - getBody - }); -}; -async function fetchHTTPResponse(opts, ac) { - const url = opts.getUrl(opts); - const body = opts.getBody(opts); - const { type } = opts; - const resolvedHeaders = await (async () => { - const heads = await opts.headers(); - if (Symbol.iterator in heads) { - return Object.fromEntries(heads); - } - return heads; - })(); - /* istanbul ignore if -- @preserve */ - if (type === "subscription") { - throw new Error("Subscriptions should use wsLink"); - } - const headers = { - ...opts.contentTypeHeader ? { - "content-type": opts.contentTypeHeader - } : {}, - ...opts.batchModeHeader ? { - "trpc-batch-mode": opts.batchModeHeader - } : {}, - ...resolvedHeaders - }; - return getFetch(opts.fetch)(url, { - method: opts.methodOverride ?? METHOD[type], - signal: ac == null ? void 0 : ac.signal, - body, - headers - }); -} -function httpRequest(opts) { - const ac = opts.AbortController ? new opts.AbortController() : null; - const meta = {}; - let done = false; - const promise = new Promise((resolve, reject) => { - fetchHTTPResponse(opts, ac).then((_res) => { - meta.response = _res; - done = true; - return _res.json(); - }).then((json) => { - meta.responseJSON = json; - resolve({ - json, - meta - }); - }).catch((err) => { - done = true; - reject(TRPCClientError.from(err, { - meta - })); - }); - }); - const cancel = () => { - if (!done) { - ac == null ? void 0 : ac.abort(); - } - }; - return { - promise, - cancel - }; -} -function createHTTPBatchLink(requester) { - return function httpBatchLink2(opts) { - const resolvedOpts = resolveHTTPLinkOptions(opts); - const maxURLLength = opts.maxURLLength ?? Infinity; - return (runtime) => { - const batchLoader = (type) => { - const validate = (batchOps) => { - if (maxURLLength === Infinity) { - return true; - } - const path2 = batchOps.map((op) => op.path).join(","); - const inputs = batchOps.map((op) => op.input); - const url = getUrl({ - ...resolvedOpts, - type, - path: path2, - inputs - }); - return url.length <= maxURLLength; - }; - const fetch = requester({ - ...resolvedOpts, - runtime, - type, - opts - }); - return { - validate, - fetch - }; - }; - const query = dataLoader(batchLoader("query")); - const mutation = dataLoader(batchLoader("mutation")); - const subscription = dataLoader(batchLoader("subscription")); - const loaders = { - query, - subscription, - mutation - }; - return ({ op }) => { - return observable((observer) => { - const loader = loaders[op.type]; - const { promise, cancel } = loader.load(op); - let _res = void 0; - promise.then((res) => { - _res = res; - const transformed = transformResult(res.json, resolvedOpts.transformer.output); - if (!transformed.ok) { - observer.error(TRPCClientError.from(transformed.error, { - meta: res.meta - })); - return; - } - observer.next({ - context: res.meta, - result: transformed.result - }); - observer.complete(); - }).catch((err) => { - observer.error(TRPCClientError.from(err, { - meta: _res == null ? void 0 : _res.meta - })); - }); - return () => { - cancel(); - }; - }); - }; - }; - }; -} -const batchRequester = (requesterOpts) => { - return (batchOps) => { - const path2 = batchOps.map((op) => op.path).join(","); - const inputs = batchOps.map((op) => op.input); - const { promise, cancel } = jsonHttpRequester({ - ...requesterOpts, - path: path2, - inputs, - headers() { - if (!requesterOpts.opts.headers) { - return {}; - } - if (typeof requesterOpts.opts.headers === "function") { - return requesterOpts.opts.headers({ - opList: batchOps - }); - } - return requesterOpts.opts.headers; - } - }); - return { - promise: promise.then((res) => { - const resJSON = Array.isArray(res.json) ? res.json : batchOps.map(() => res.json); - const result = resJSON.map((item) => ({ - meta: res.meta, - json: item - })); - return result; - }), - cancel - }; - }; -}; -const httpBatchLink = createHTTPBatchLink(batchRequester); -function getAPIClient() { - const globals = getGlobalOptions(); - return createTRPCClient({ - links: [ - httpBatchLink({ - url: `${globals.serverAddr}/api/trpc`, - maxURLLength: 14e3, - headers() { - return { - authorization: `Bearer ${globals.apiKey}` - }; - } - }) - ] - }); -} +var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {}; function getDefaultExportFromCjs(x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x; } @@ -1374,8 +35,8 @@ let CommanderError$3 = class CommanderError extends Error { * @param {string} code an id string representing the error * @param {string} message human-readable description of the error */ - constructor(exitCode, code, message) { - super(message); + constructor(exitCode, code, message2) { + super(message2); Error.captureStackTrace(this, this.constructor); this.name = this.constructor.name; this.code = code; @@ -1388,8 +49,8 @@ let InvalidArgumentError$4 = class InvalidArgumentError extends CommanderError$3 * Constructs the InvalidArgumentError class * @param {string} [message] explanation of why argument is invalid */ - constructor(message) { - super(1, "commander.invalidArgument", message); + constructor(message2) { + super(1, "commander.invalidArgument", message2); Error.captureStackTrace(this, this.constructor); this.name = this.constructor.name; } @@ -1406,25 +67,25 @@ let Argument$3 = class Argument { * @param {string} name * @param {string} [description] */ - constructor(name, description) { - this.description = description || ""; + constructor(name2, description2) { + this.description = description2 || ""; this.variadic = false; this.parseArg = void 0; this.defaultValue = void 0; this.defaultValueDescription = void 0; this.argChoices = void 0; - switch (name[0]) { + switch (name2[0]) { case "<": this.required = true; - this._name = name.slice(1, -1); + this._name = name2.slice(1, -1); break; case "[": this.required = false; - this._name = name.slice(1, -1); + this._name = name2.slice(1, -1); break; default: this.required = true; - this._name = name; + this._name = name2; break; } if (this._name.length > 3 && this._name.slice(-3) === "...") { @@ -1456,9 +117,9 @@ let Argument$3 = class Argument { * @param {string} [description] * @return {Argument} */ - default(value, description) { + default(value, description2) { this.defaultValue = value; - this.defaultValueDescription = description; + this.defaultValueDescription = description2; return this; } /** @@ -1811,9 +472,9 @@ let Help$3 = class Help { const helpWidth = helper.helpWidth || 80; const itemIndentWidth = 2; const itemSeparatorWidth = 2; - function formatItem(term, description) { - if (description) { - const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`; + function formatItem(term, description2) { + if (description2) { + const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description2}`; return helper.wrap( fullText, helpWidth - itemIndentWidth, @@ -1914,12 +575,12 @@ let Help$3 = class Help { const indentString = " ".repeat(indent); const zeroWidthSpace = "​"; const breaks = `\\s${zeroWidthSpace}`; - const regex = new RegExp( + const regex2 = new RegExp( ` |.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`, "g" ); - const lines = columnText.match(regex) || []; + const lines = columnText.match(regex2) || []; return leadingStr + lines.map((line, i) => { if (line === "\n") return ""; return (i > 0 ? indentString : "") + line.trimEnd(); @@ -1936,9 +597,9 @@ let Option$3 = class Option { * @param {string} flags * @param {string} [description] */ - constructor(flags, description) { + constructor(flags, description2) { this.flags = flags; - this.description = description || ""; + this.description = description2 || ""; this.required = flags.includes("<"); this.optional = flags.includes("["); this.variadic = /\w\.\.\.[>\]]$/.test(flags); @@ -1967,9 +628,9 @@ let Option$3 = class Option { * @param {string} [description] * @return {Option} */ - default(value, description) { + default(value, description2) { this.defaultValue = value; - this.defaultValueDescription = description; + this.defaultValueDescription = description2; return this; } /** @@ -2032,8 +693,8 @@ let Option$3 = class Option { * @param {string} name * @return {Option} */ - env(name) { - this.envVar = name; + env(name2) { + this.envVar = name2; return this; } /** @@ -2271,9 +932,9 @@ function suggestSimilar$1(word, candidates) { suggestSimilar$2.suggestSimilar = suggestSimilar$1; const EventEmitter = require$$0.EventEmitter; const childProcess = require$$1; -const path = require$$2; -const fs = require$$3; -const process = process$1; +const path$1 = require$$2; +const fs$1 = require$$3; +const process$1 = process$2; const { Argument: Argument$2, humanReadableArgName } = argument; const { CommanderError: CommanderError$2 } = error; const { Help: Help$2 } = help; @@ -2285,7 +946,7 @@ let Command$2 = class Command extends EventEmitter { * * @param {string} [name] */ - constructor(name) { + constructor(name2) { super(); this.commands = []; this.options = []; @@ -2298,7 +959,7 @@ let Command$2 = class Command extends EventEmitter { this.rawArgs = []; this.processedArgs = []; this._scriptPath = null; - this._name = name || ""; + this._name = name2 || ""; this._optionValues = {}; this._optionValueSources = {}; this._storeOptionsAsProperties = false; @@ -2319,10 +980,10 @@ let Command$2 = class Command extends EventEmitter { this._showHelpAfterError = false; this._showSuggestionAfterError = true; this._outputConfiguration = { - writeOut: (str) => process.stdout.write(str), - writeErr: (str) => process.stderr.write(str), - getOutHelpWidth: () => process.stdout.isTTY ? process.stdout.columns : void 0, - getErrHelpWidth: () => process.stderr.isTTY ? process.stderr.columns : void 0, + writeOut: (str) => process$1.stdout.write(str), + writeErr: (str) => process$1.stderr.write(str), + getOutHelpWidth: () => process$1.stdout.isTTY ? process$1.stdout.columns : void 0, + getErrHelpWidth: () => process$1.stderr.isTTY ? process$1.stderr.columns : void 0, outputError: (str, write) => write(str) }; this._hidden = false; @@ -2396,8 +1057,8 @@ let Command$2 = class Command extends EventEmitter { desc = null; } opts = opts || {}; - const [, name, args] = nameAndArgs.match(/([^ ]+) *(.*)/); - const cmd = this.createCommand(name); + const [, name2, args] = nameAndArgs.match(/([^ ]+) *(.*)/); + const cmd = this.createCommand(name2); if (desc) { cmd.description(desc); cmd._executableHandler = true; @@ -2421,8 +1082,8 @@ let Command$2 = class Command extends EventEmitter { * @param {string} [name] * @return {Command} new command */ - createCommand(name) { - return new Command(name); + createCommand(name2) { + return new Command(name2); } /** * You can customise the help with a subclass of Help by overriding createHelp, @@ -2521,8 +1182,8 @@ let Command$2 = class Command extends EventEmitter { * @param {string} [description] * @return {Argument} new argument */ - createArgument(name, description) { - return new Argument$2(name, description); + createArgument(name2, description2) { + return new Argument$2(name2, description2); } /** * Define argument syntax for command. @@ -2540,8 +1201,8 @@ let Command$2 = class Command extends EventEmitter { * @param {*} [defaultValue] * @return {Command} `this` command for chaining */ - argument(name, description, fn, defaultValue) { - const argument2 = this.createArgument(name, description); + argument(name2, description2, fn, defaultValue) { + const argument2 = this.createArgument(name2, description2); if (typeof fn === "function") { argument2.default(defaultValue).argParser(fn); } else { @@ -2601,14 +1262,14 @@ let Command$2 = class Command extends EventEmitter { * @param {string} [description] - custom description * @return {Command} `this` command for chaining */ - helpCommand(enableOrNameAndArgs, description) { + helpCommand(enableOrNameAndArgs, description2) { if (typeof enableOrNameAndArgs === "boolean") { this._addImplicitHelpCommand = enableOrNameAndArgs; return this; } enableOrNameAndArgs = enableOrNameAndArgs ?? "help [command]"; const [, helpName, helpArgs] = enableOrNameAndArgs.match(/([^ ]+) *(.*)/); - const helpDescription = description ?? "display help for command"; + const helpDescription = description2 ?? "display help for command"; const helpCommand = this.createCommand(helpName); helpCommand.helpOption(false); if (helpArgs) helpCommand.arguments(helpArgs); @@ -2696,11 +1357,11 @@ Expecting one of '${allowedValues.join("', '")}'`); * @return never * @private */ - _exit(exitCode, code, message) { + _exit(exitCode, code, message2) { if (this._exitCallback) { - this._exitCallback(new CommanderError$2(exitCode, code, message)); + this._exitCallback(new CommanderError$2(exitCode, code, message2)); } - process.exit(exitCode); + process$1.exit(exitCode); } /** * Register callback `fn` for the command. @@ -2741,8 +1402,8 @@ Expecting one of '${allowedValues.join("', '")}'`); * @param {string} [description] * @return {Option} new option */ - createOption(flags, description) { - return new Option$2(flags, description); + createOption(flags, description2) { + return new Option$2(flags, description2); } /** * Wrap parseArgs to catch 'commander.invalidArgument'. @@ -2758,8 +1419,8 @@ Expecting one of '${allowedValues.join("', '")}'`); return target.parseArg(value, previous); } catch (err) { if (err.code === "commander.invalidArgument") { - const message = `${invalidArgumentMessage} ${err.message}`; - this.error(message, { exitCode: err.exitCode, code: err.code }); + const message2 = `${invalidArgumentMessage} ${err.message}`; + this.error(message2, { exitCode: err.exitCode, code: err.code }); } throw err; } @@ -2792,7 +1453,7 @@ Expecting one of '${allowedValues.join("', '")}'`); return [cmd.name()].concat(cmd.aliases()); }; const alreadyUsed = knownBy(command2).find( - (name) => this._findCommand(name) + (name2) => this._findCommand(name2) ); if (alreadyUsed) { const existingCmd = knownBy(this._findCommand(alreadyUsed)).join("|"); @@ -2812,24 +1473,24 @@ Expecting one of '${allowedValues.join("', '")}'`); addOption(option2) { this._registerOption(option2); const oname = option2.name(); - const name = option2.attributeName(); + const name2 = option2.attributeName(); if (option2.negate) { const positiveLongFlag = option2.long.replace(/^--no-/, "--"); if (!this._findOption(positiveLongFlag)) { this.setOptionValueWithSource( - name, + name2, option2.defaultValue === void 0 ? true : option2.defaultValue, "default" ); } } else if (option2.defaultValue !== void 0) { - this.setOptionValueWithSource(name, option2.defaultValue, "default"); + this.setOptionValueWithSource(name2, option2.defaultValue, "default"); } const handleOptionValue = (val, invalidValueMessage, valueSource) => { if (val == null && option2.presetArg !== void 0) { val = option2.presetArg; } - const oldValue = this.getOptionValue(name); + const oldValue = this.getOptionValue(name2); if (val !== null && option2.parseArg) { val = this._callParseArg(option2, val, oldValue, invalidValueMessage); } else if (val !== null && option2.variadic) { @@ -2844,7 +1505,7 @@ Expecting one of '${allowedValues.join("', '")}'`); val = ""; } } - this.setOptionValueWithSource(name, val, valueSource); + this.setOptionValueWithSource(name2, val, valueSource); }; this.on("option:" + oname, (val) => { const invalidValueMessage = `error: option '${option2.flags}' argument '${val}' is invalid.`; @@ -2864,20 +1525,20 @@ Expecting one of '${allowedValues.join("', '")}'`); * @return {Command} `this` command for chaining * @private */ - _optionEx(config, flags, description, fn, defaultValue) { + _optionEx(config2, flags, description2, fn, defaultValue) { if (typeof flags === "object" && flags instanceof Option$2) { throw new Error( "To add an Option object use addOption() instead of option() or requiredOption()" ); } - const option2 = this.createOption(flags, description); - option2.makeOptionMandatory(!!config.mandatory); + const option2 = this.createOption(flags, description2); + option2.makeOptionMandatory(!!config2.mandatory); if (typeof fn === "function") { option2.default(defaultValue).argParser(fn); } else if (fn instanceof RegExp) { - const regex = fn; + const regex2 = fn; fn = (val, def) => { - const m = regex.exec(val); + const m = regex2.exec(val); return m ? m[0] : def; }; option2.default(defaultValue).argParser(fn); @@ -2907,8 +1568,8 @@ Expecting one of '${allowedValues.join("', '")}'`); * @param {*} [defaultValue] * @return {Command} `this` command for chaining */ - option(flags, description, parseArg, defaultValue) { - return this._optionEx({}, flags, description, parseArg, defaultValue); + option(flags, description2, parseArg, defaultValue) { + return this._optionEx({}, flags, description2, parseArg, defaultValue); } /** * Add a required option which must have a value after parsing. This usually means @@ -2922,11 +1583,11 @@ Expecting one of '${allowedValues.join("', '")}'`); * @param {*} [defaultValue] * @return {Command} `this` command for chaining */ - requiredOption(flags, description, parseArg, defaultValue) { + requiredOption(flags, description2, parseArg, defaultValue) { return this._optionEx( { mandatory: true }, flags, - description, + description2, parseArg, defaultValue ); @@ -3099,16 +1760,16 @@ Expecting one of '${allowedValues.join("', '")}'`); } parseOptions = parseOptions || {}; if (argv === void 0 && parseOptions.from === void 0) { - if ((_a2 = process.versions) == null ? void 0 : _a2.electron) { + if ((_a2 = process$1.versions) == null ? void 0 : _a2.electron) { parseOptions.from = "electron"; } - const execArgv = process.execArgv ?? []; + const execArgv = process$1.execArgv ?? []; if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) { parseOptions.from = "eval"; } } if (argv === void 0) { - argv = process.argv; + argv = process$1.argv; } this.rawArgs = argv.slice(); let userArgs; @@ -3119,7 +1780,7 @@ Expecting one of '${allowedValues.join("', '")}'`); userArgs = argv.slice(2); break; case "electron": - if (process.defaultApp) { + if (process$1.defaultApp) { this._scriptPath = argv[1]; userArgs = argv.slice(2); } else { @@ -3204,11 +1865,11 @@ Expecting one of '${allowedValues.join("', '")}'`); let launchWithNode = false; const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"]; function findFile(baseDir, baseName) { - const localBin = path.resolve(baseDir, baseName); - if (fs.existsSync(localBin)) return localBin; - if (sourceExt.includes(path.extname(baseName))) return void 0; + const localBin = path$1.resolve(baseDir, baseName); + if (fs$1.existsSync(localBin)) return localBin; + if (sourceExt.includes(path$1.extname(baseName))) return void 0; const foundExt = sourceExt.find( - (ext) => fs.existsSync(`${localBin}${ext}`) + (ext) => fs$1.existsSync(`${localBin}${ext}`) ); if (foundExt) return `${localBin}${foundExt}`; return void 0; @@ -3220,21 +1881,21 @@ Expecting one of '${allowedValues.join("', '")}'`); if (this._scriptPath) { let resolvedScriptPath; try { - resolvedScriptPath = fs.realpathSync(this._scriptPath); + resolvedScriptPath = fs$1.realpathSync(this._scriptPath); } catch (err) { resolvedScriptPath = this._scriptPath; } - executableDir = path.resolve( - path.dirname(resolvedScriptPath), + executableDir = path$1.resolve( + path$1.dirname(resolvedScriptPath), executableDir ); } if (executableDir) { let localFile = findFile(executableDir, executableFile); if (!localFile && !subcommand._executableFile && this._scriptPath) { - const legacyName = path.basename( + const legacyName = path$1.basename( this._scriptPath, - path.extname(this._scriptPath) + path$1.extname(this._scriptPath) ); if (legacyName !== this._name) { localFile = findFile( @@ -3245,25 +1906,25 @@ Expecting one of '${allowedValues.join("', '")}'`); } executableFile = localFile || executableFile; } - launchWithNode = sourceExt.includes(path.extname(executableFile)); + launchWithNode = sourceExt.includes(path$1.extname(executableFile)); let proc; - if (process.platform !== "win32") { + if (process$1.platform !== "win32") { if (launchWithNode) { args.unshift(executableFile); - args = incrementNodeInspectorPort(process.execArgv).concat(args); - proc = childProcess.spawn(process.argv[0], args, { stdio: "inherit" }); + args = incrementNodeInspectorPort(process$1.execArgv).concat(args); + proc = childProcess.spawn(process$1.argv[0], args, { stdio: "inherit" }); } else { proc = childProcess.spawn(executableFile, args, { stdio: "inherit" }); } } else { args.unshift(executableFile); - args = incrementNodeInspectorPort(process.execArgv).concat(args); - proc = childProcess.spawn(process.execPath, args, { stdio: "inherit" }); + args = incrementNodeInspectorPort(process$1.execArgv).concat(args); + proc = childProcess.spawn(process$1.execPath, args, { stdio: "inherit" }); } if (!proc.killed) { const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"]; signals.forEach((signal) => { - process.on(signal, () => { + process$1.on(signal, () => { if (proc.killed === false && proc.exitCode === null) { proc.kill(signal); } @@ -3274,7 +1935,7 @@ Expecting one of '${allowedValues.join("', '")}'`); proc.on("close", (code) => { code = code ?? 1; if (!exitCallback) { - process.exit(code); + process$1.exit(code); } else { exitCallback( new CommanderError$2( @@ -3297,7 +1958,7 @@ Expecting one of '${allowedValues.join("', '")}'`); throw new Error(`'${executableFile}' not executable`); } if (!exitCallback) { - process.exit(1); + process$1.exit(1); } else { const wrappedError = new CommanderError$2( 1, @@ -3558,10 +2219,10 @@ Expecting one of '${allowedValues.join("', '")}'`); * @private * @return {Command | undefined} */ - _findCommand(name) { - if (!name) return void 0; + _findCommand(name2) { + if (!name2) return void 0; return this.commands.find( - (cmd) => cmd._name === name || cmd._aliases.includes(name) + (cmd) => cmd._name === name2 || cmd._aliases.includes(name2) ); } /** @@ -3764,9 +2425,9 @@ Expecting one of '${allowedValues.join("', '")}'`); * @param {string} [errorOptions.code] - an id string representing the error * @param {number} [errorOptions.exitCode] - used with process.exit */ - error(message, errorOptions) { + error(message2, errorOptions) { this._outputConfiguration.outputError( - `${message} + `${message2} `, this._outputConfiguration.writeErr ); @@ -3777,10 +2438,10 @@ Expecting one of '${allowedValues.join("', '")}'`); this._outputConfiguration.writeErr("\n"); this.outputHelp({ error: true }); } - const config = errorOptions || {}; - const exitCode = config.exitCode || 1; - const code = config.code || "commander.error"; - this._exit(exitCode, code, message); + const config2 = errorOptions || {}; + const exitCode = config2.exitCode || 1; + const code = config2.code || "commander.error"; + this._exit(exitCode, code, message2); } /** * Apply any option related environment variables, if option does @@ -3790,13 +2451,13 @@ Expecting one of '${allowedValues.join("', '")}'`); */ _parseOptionsEnv() { this.options.forEach((option2) => { - if (option2.envVar && option2.envVar in process.env) { + if (option2.envVar && option2.envVar in process$1.env) { const optionKey = option2.attributeName(); if (this.getOptionValue(optionKey) === void 0 || ["default", "config", "env"].includes( this.getOptionValueSource(optionKey) )) { if (option2.required || option2.optional) { - this.emit(`optionEnv:${option2.name()}`, process.env[option2.envVar]); + this.emit(`optionEnv:${option2.name()}`, process$1.env[option2.envVar]); } else { this.emit(`optionEnv:${option2.name()}`); } @@ -3835,9 +2496,9 @@ Expecting one of '${allowedValues.join("', '")}'`); * @param {string} name * @private */ - missingArgument(name) { - const message = `error: missing required argument '${name}'`; - this.error(message, { code: "commander.missingArgument" }); + missingArgument(name2) { + const message2 = `error: missing required argument '${name2}'`; + this.error(message2, { code: "commander.missingArgument" }); } /** * `Option` is missing an argument. @@ -3846,8 +2507,8 @@ Expecting one of '${allowedValues.join("', '")}'`); * @private */ optionMissingArgument(option2) { - const message = `error: option '${option2.flags}' argument missing`; - this.error(message, { code: "commander.optionMissingArgument" }); + const message2 = `error: option '${option2.flags}' argument missing`; + this.error(message2, { code: "commander.optionMissingArgument" }); } /** * `Option` does not have a value, and is a mandatory option. @@ -3856,8 +2517,8 @@ Expecting one of '${allowedValues.join("', '")}'`); * @private */ missingMandatoryOptionValue(option2) { - const message = `error: required option '${option2.flags}' not specified`; - this.error(message, { code: "commander.missingMandatoryOptionValue" }); + const message2 = `error: required option '${option2.flags}' not specified`; + this.error(message2, { code: "commander.missingMandatoryOptionValue" }); } /** * `Option` conflicts with another option. @@ -3890,8 +2551,8 @@ Expecting one of '${allowedValues.join("', '")}'`); } return `option '${bestOption.flags}'`; }; - const message = `error: ${getErrorMessage(option2)} cannot be used with ${getErrorMessage(conflictingOption)}`; - this.error(message, { code: "commander.conflictingOption" }); + const message2 = `error: ${getErrorMessage(option2)} cannot be used with ${getErrorMessage(conflictingOption)}`; + this.error(message2, { code: "commander.conflictingOption" }); } /** * Unknown option `flag`. @@ -3912,8 +2573,8 @@ Expecting one of '${allowedValues.join("', '")}'`); } while (command2 && !command2._enablePositionalOptions); suggestion = suggestSimilar(flag, candidateFlags); } - const message = `error: unknown option '${flag}'${suggestion}`; - this.error(message, { code: "commander.unknownOption" }); + const message2 = `error: unknown option '${flag}'${suggestion}`; + this.error(message2, { code: "commander.unknownOption" }); } /** * Excess arguments, more than expected. @@ -3926,8 +2587,8 @@ Expecting one of '${allowedValues.join("', '")}'`); const expected = this.registeredArguments.length; const s = expected === 1 ? "" : "s"; const forSubcommand = this.parent ? ` for '${this.name()}'` : ""; - const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`; - this.error(message, { code: "commander.excessArguments" }); + const message2 = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`; + this.error(message2, { code: "commander.excessArguments" }); } /** * Unknown command. @@ -3945,8 +2606,8 @@ Expecting one of '${allowedValues.join("', '")}'`); }); suggestion = suggestSimilar(unknownName, candidateNames); } - const message = `error: unknown command '${unknownName}'${suggestion}`; - this.error(message, { code: "commander.unknownCommand" }); + const message2 = `error: unknown command '${unknownName}'${suggestion}`; + this.error(message2, { code: "commander.unknownCommand" }); } /** * Get or set the program version. @@ -3960,12 +2621,12 @@ Expecting one of '${allowedValues.join("', '")}'`); * @param {string} [description] * @return {(this | string | undefined)} `this` command for chaining, or version string if no arguments */ - version(str, flags, description) { + version(str, flags, description2) { if (str === void 0) return this._version; this._version = str; flags = flags || "-V, --version"; - description = description || "output the version number"; - const versionOption = this.createOption(flags, description); + description2 = description2 || "output the version number"; + const versionOption = this.createOption(flags, description2); this._versionOptionName = versionOption.attributeName(); this._registerOption(versionOption); this.on("option:" + versionOption.name(), () => { @@ -4037,9 +2698,9 @@ Expecting one of '${allowedValues.join("', '")}'`); * @param {string[]} [aliases] * @return {(string[]|Command)} */ - aliases(aliases) { - if (aliases === void 0) return this._aliases; - aliases.forEach((alias) => this.alias(alias)); + aliases(aliases2) { + if (aliases2 === void 0) return this._aliases; + aliases2.forEach((alias) => this.alias(alias)); return this; } /** @@ -4087,7 +2748,7 @@ Expecting one of '${allowedValues.join("', '")}'`); * @return {Command} */ nameFromFilename(filename) { - this._name = path.basename(filename, path.extname(filename)); + this._name = path$1.basename(filename, path$1.extname(filename)); return this; } /** @@ -4180,7 +2841,7 @@ Expecting one of '${allowedValues.join("', '")}'`); * @param {string} [description] * @return {Command} `this` command for chaining */ - helpOption(flags, description) { + helpOption(flags, description2) { if (typeof flags === "boolean") { if (flags) { this._helpOption = this._helpOption ?? void 0; @@ -4190,8 +2851,8 @@ Expecting one of '${allowedValues.join("', '")}'`); return this; } flags = flags ?? "-h, --help"; - description = description ?? "display help for command"; - this._helpOption = this.createOption(flags, description); + description2 = description2 ?? "display help for command"; + this._helpOption = this.createOption(flags, description2); return this; } /** @@ -4227,7 +2888,7 @@ Expecting one of '${allowedValues.join("', '")}'`); */ help(contextOptions) { this.outputHelp(contextOptions); - let exitCode = process.exitCode || 0; + let exitCode = process$1.exitCode || 0; if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) { exitCode = 1; } @@ -4287,20 +2948,20 @@ function incrementNodeInspectorPort(args) { let debugOption; let debugHost = "127.0.0.1"; let debugPort = "9229"; - let match; - if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) { - debugOption = match[1]; - } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) { - debugOption = match[1]; - if (/^\d+$/.test(match[3])) { - debugPort = match[3]; + let match2; + if ((match2 = arg.match(/^(--inspect(-brk)?)$/)) !== null) { + debugOption = match2[1]; + } else if ((match2 = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) { + debugOption = match2[1]; + if (/^\d+$/.test(match2[3])) { + debugPort = match2[3]; } else { - debugHost = match[3]; + debugHost = match2[3]; } - } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) { - debugOption = match[1]; - debugHost = match[3]; - debugPort = match[4]; + } else if ((match2 = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) { + debugOption = match2[1]; + debugHost = match2[3]; + debugPort = match2[4]; } if (debugOption && debugPort !== "0") { return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`; @@ -4315,9 +2976,9 @@ const { CommanderError: CommanderError$1, InvalidArgumentError: InvalidArgumentE const { Help: Help$1 } = help; const { Option: Option$1 } = option; commander.program = new Command$1(); -commander.createCommand = (name) => new Command$1(name); -commander.createOption = (flags, description) => new Option$1(flags, description); -commander.createArgument = (name, description) => new Argument$1(name, description); +commander.createCommand = (name2) => new Command$1(name2); +commander.createOption = (flags, description2) => new Option$1(flags, description2); +commander.createArgument = (name2, description2) => new Argument$1(name2, description2); commander.Command = Command$1; commander.Option = Option$1; commander.Argument = Argument$1; @@ -4325,20 +2986,20 @@ commander.Help = Help$1; commander.CommanderError = CommanderError$1; commander.InvalidArgumentError = InvalidArgumentError$1; commander.InvalidOptionArgumentError = InvalidArgumentError$1; -(function(module, exports) { +(function(module, exports2) { const commander$1 = commander; - exports = module.exports = {}; - exports.program = new commander$1.Command(); - exports.Argument = commander$1.Argument; - exports.Command = commander$1.Command; - exports.CommanderError = commander$1.CommanderError; - exports.Help = commander$1.Help; - exports.InvalidArgumentError = commander$1.InvalidArgumentError; - exports.InvalidOptionArgumentError = commander$1.InvalidArgumentError; - exports.Option = commander$1.Option; - exports.createCommand = (name) => new commander$1.Command(name); - exports.createOption = (flags, description) => new commander$1.Option(flags, description); - exports.createArgument = (name, description) => new commander$1.Argument(name, description); + exports2 = module.exports = {}; + exports2.program = new commander$1.Command(); + exports2.Argument = commander$1.Argument; + exports2.Command = commander$1.Command; + exports2.CommanderError = commander$1.CommanderError; + exports2.Help = commander$1.Help; + exports2.InvalidArgumentError = commander$1.InvalidArgumentError; + exports2.InvalidOptionArgumentError = commander$1.InvalidArgumentError; + exports2.Option = commander$1.Option; + exports2.createCommand = (name2) => new commander$1.Command(name2); + exports2.createOption = (flags, description2) => new commander$1.Option(flags, description2); + exports2.createArgument = (name2, description2) => new commander$1.Argument(name2, description2); })(extraTypings, extraTypings.exports); var extraTypingsExports = extraTypings.exports; const extraTypingsCommander = /* @__PURE__ */ getDefaultExportFromCjs(extraTypingsExports); @@ -4356,19 +3017,14315 @@ const { Option: Option2, Help: Help2 } = extraTypingsCommander; -const helloWorldCmd = new Command2().name("hello-world").description("returns info about the server and stats"); -helloWorldCmd.command("test").description("does something specific I guess").action(async () => { - const api = getAPIClient(); - try { - console.dir(api); - } catch (error2) { - printErrorMessageWithReason( - "Something went horribly wrong", - error2 - ); +const ANSI_BACKGROUND_OFFSET = 10; +const wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`; +const wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`; +const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`; +const styles$1 = { + modifier: { + reset: [0, 0], + // 21 isn't widely supported and 22 does the same thing + bold: [1, 22], + dim: [2, 22], + italic: [3, 23], + underline: [4, 24], + overline: [53, 55], + inverse: [7, 27], + hidden: [8, 28], + strikethrough: [9, 29] + }, + color: { + black: [30, 39], + red: [31, 39], + green: [32, 39], + yellow: [33, 39], + blue: [34, 39], + magenta: [35, 39], + cyan: [36, 39], + white: [37, 39], + // Bright color + blackBright: [90, 39], + gray: [90, 39], + // Alias of `blackBright` + grey: [90, 39], + // Alias of `blackBright` + redBright: [91, 39], + greenBright: [92, 39], + yellowBright: [93, 39], + blueBright: [94, 39], + magentaBright: [95, 39], + cyanBright: [96, 39], + whiteBright: [97, 39] + }, + bgColor: { + bgBlack: [40, 49], + bgRed: [41, 49], + bgGreen: [42, 49], + bgYellow: [43, 49], + bgBlue: [44, 49], + bgMagenta: [45, 49], + bgCyan: [46, 49], + bgWhite: [47, 49], + // Bright color + bgBlackBright: [100, 49], + bgGray: [100, 49], + // Alias of `bgBlackBright` + bgGrey: [100, 49], + // Alias of `bgBlackBright` + bgRedBright: [101, 49], + bgGreenBright: [102, 49], + bgYellowBright: [103, 49], + bgBlueBright: [104, 49], + bgMagentaBright: [105, 49], + bgCyanBright: [106, 49], + bgWhiteBright: [107, 49] + } +}; +Object.keys(styles$1.modifier); +const foregroundColorNames = Object.keys(styles$1.color); +const backgroundColorNames = Object.keys(styles$1.bgColor); +[...foregroundColorNames, ...backgroundColorNames]; +function assembleStyles() { + const codes = /* @__PURE__ */ new Map(); + for (const [groupName, group] of Object.entries(styles$1)) { + for (const [styleName, style] of Object.entries(group)) { + styles$1[styleName] = { + open: `\x1B[${style[0]}m`, + close: `\x1B[${style[1]}m` + }; + group[styleName] = styles$1[styleName]; + codes.set(style[0], style[1]); + } + Object.defineProperty(styles$1, groupName, { + value: group, + enumerable: false + }); + } + Object.defineProperty(styles$1, "codes", { + value: codes, + enumerable: false + }); + styles$1.color.close = "\x1B[39m"; + styles$1.bgColor.close = "\x1B[49m"; + styles$1.color.ansi = wrapAnsi16(); + styles$1.color.ansi256 = wrapAnsi256(); + styles$1.color.ansi16m = wrapAnsi16m(); + styles$1.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET); + styles$1.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET); + styles$1.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET); + Object.defineProperties(styles$1, { + rgbToAnsi256: { + value(red, green, blue) { + if (red === green && green === blue) { + if (red < 8) { + return 16; + } + if (red > 248) { + return 231; + } + return Math.round((red - 8) / 247 * 24) + 232; + } + return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5); + }, + enumerable: false + }, + hexToRgb: { + value(hex) { + const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16)); + if (!matches) { + return [0, 0, 0]; + } + let [colorString] = matches; + if (colorString.length === 3) { + colorString = [...colorString].map((character) => character + character).join(""); + } + const integer = Number.parseInt(colorString, 16); + return [ + /* eslint-disable no-bitwise */ + integer >> 16 & 255, + integer >> 8 & 255, + integer & 255 + /* eslint-enable no-bitwise */ + ]; + }, + enumerable: false + }, + hexToAnsi256: { + value: (hex) => styles$1.rgbToAnsi256(...styles$1.hexToRgb(hex)), + enumerable: false + }, + ansi256ToAnsi: { + value(code) { + if (code < 8) { + return 30 + code; + } + if (code < 16) { + return 90 + (code - 8); + } + let red; + let green; + let blue; + if (code >= 232) { + red = ((code - 232) * 10 + 8) / 255; + green = red; + blue = red; + } else { + code -= 16; + const remainder = code % 36; + red = Math.floor(code / 36) / 5; + green = Math.floor(remainder / 6) / 5; + blue = remainder % 6 / 5; + } + const value = Math.max(red, green, blue) * 2; + if (value === 0) { + return 30; + } + let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red)); + if (value === 2) { + result += 60; + } + return result; + }, + enumerable: false + }, + rgbToAnsi: { + value: (red, green, blue) => styles$1.ansi256ToAnsi(styles$1.rgbToAnsi256(red, green, blue)), + enumerable: false + }, + hexToAnsi: { + value: (hex) => styles$1.ansi256ToAnsi(styles$1.hexToAnsi256(hex)), + enumerable: false + } + }); + return styles$1; +} +const ansiStyles$2 = assembleStyles(); +function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process$2.argv) { + const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--"; + const position = argv.indexOf(prefix + flag); + const terminatorPosition = argv.indexOf("--"); + return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition); +} +const { env } = process$2; +let flagForceColor; +if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) { + flagForceColor = 0; +} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) { + flagForceColor = 1; +} +function envForceColor() { + if ("FORCE_COLOR" in env) { + if (env.FORCE_COLOR === "true") { + return 1; + } + if (env.FORCE_COLOR === "false") { + return 0; + } + return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3); + } +} +function translateLevel(level) { + if (level === 0) { + return false; + } + return { + level, + hasBasic: true, + has256: level >= 2, + has16m: level >= 3 + }; +} +function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) { + const noFlagForceColor = envForceColor(); + if (noFlagForceColor !== void 0) { + flagForceColor = noFlagForceColor; + } + const forceColor = sniffFlags ? flagForceColor : noFlagForceColor; + if (forceColor === 0) { + return 0; + } + if (sniffFlags) { + if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) { + return 3; + } + if (hasFlag("color=256")) { + return 2; + } + } + if ("TF_BUILD" in env && "AGENT_NAME" in env) { + return 1; + } + if (haveStream && !streamIsTTY && forceColor === void 0) { + return 0; + } + const min = forceColor || 0; + if (env.TERM === "dumb") { + return min; + } + if (process$2.platform === "win32") { + const osRelease = os$1.release().split("."); + if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) { + return Number(osRelease[2]) >= 14931 ? 3 : 2; + } + return 1; + } + if ("CI" in env) { + if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) { + return 3; + } + if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") { + return 1; + } + return min; + } + if ("TEAMCITY_VERSION" in env) { + return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0; + } + if (env.COLORTERM === "truecolor") { + return 3; + } + if (env.TERM === "xterm-kitty") { + return 3; + } + if ("TERM_PROGRAM" in env) { + const version2 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10); + switch (env.TERM_PROGRAM) { + case "iTerm.app": { + return version2 >= 3 ? 3 : 2; + } + case "Apple_Terminal": { + return 2; + } + } + } + if (/-256(color)?$/i.test(env.TERM)) { + return 2; + } + if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { + return 1; + } + if ("COLORTERM" in env) { + return 1; + } + return min; +} +function createSupportsColor(stream, options = {}) { + const level = _supportsColor(stream, { + streamIsTTY: stream && stream.isTTY, + ...options + }); + return translateLevel(level); +} +const supportsColor = { + stdout: createSupportsColor({ isTTY: tty.isatty(1) }), + stderr: createSupportsColor({ isTTY: tty.isatty(2) }) +}; +function stringReplaceAll(string, substring, replacer) { + let index = string.indexOf(substring); + if (index === -1) { + return string; + } + const substringLength = substring.length; + let endIndex = 0; + let returnValue = ""; + do { + returnValue += string.slice(endIndex, index) + substring + replacer; + endIndex = index + substringLength; + index = string.indexOf(substring, endIndex); + } while (index !== -1); + returnValue += string.slice(endIndex); + return returnValue; +} +function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) { + let endIndex = 0; + let returnValue = ""; + do { + const gotCR = string[index - 1] === "\r"; + returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix; + endIndex = index + 1; + index = string.indexOf("\n", endIndex); + } while (index !== -1); + returnValue += string.slice(endIndex); + return returnValue; +} +const { stdout: stdoutColor, stderr: stderrColor } = supportsColor; +const GENERATOR = Symbol("GENERATOR"); +const STYLER = Symbol("STYLER"); +const IS_EMPTY = Symbol("IS_EMPTY"); +const levelMapping = [ + "ansi", + "ansi", + "ansi256", + "ansi16m" +]; +const styles = /* @__PURE__ */ Object.create(null); +const applyOptions = (object, options = {}) => { + if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) { + throw new Error("The `level` option should be an integer from 0 to 3"); + } + const colorLevel = stdoutColor ? stdoutColor.level : 0; + object.level = options.level === void 0 ? colorLevel : options.level; +}; +const chalkFactory = (options) => { + const chalk2 = (...strings) => strings.join(" "); + applyOptions(chalk2, options); + Object.setPrototypeOf(chalk2, createChalk.prototype); + return chalk2; +}; +function createChalk(options) { + return chalkFactory(options); +} +Object.setPrototypeOf(createChalk.prototype, Function.prototype); +for (const [styleName, style] of Object.entries(ansiStyles$2)) { + styles[styleName] = { + get() { + const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]); + Object.defineProperty(this, styleName, { value: builder }); + return builder; + } + }; +} +styles.visible = { + get() { + const builder = createBuilder(this, this[STYLER], true); + Object.defineProperty(this, "visible", { value: builder }); + return builder; + } +}; +const getModelAnsi = (model, level, type, ...arguments_) => { + if (model === "rgb") { + if (level === "ansi16m") { + return ansiStyles$2[type].ansi16m(...arguments_); + } + if (level === "ansi256") { + return ansiStyles$2[type].ansi256(ansiStyles$2.rgbToAnsi256(...arguments_)); + } + return ansiStyles$2[type].ansi(ansiStyles$2.rgbToAnsi(...arguments_)); + } + if (model === "hex") { + return getModelAnsi("rgb", level, type, ...ansiStyles$2.hexToRgb(...arguments_)); + } + return ansiStyles$2[type][model](...arguments_); +}; +const usedModels = ["rgb", "hex", "ansi256"]; +for (const model of usedModels) { + styles[model] = { + get() { + const { level } = this; + return function(...arguments_) { + const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansiStyles$2.color.close, this[STYLER]); + return createBuilder(this, styler, this[IS_EMPTY]); + }; + } + }; + const bgModel = "bg" + model[0].toUpperCase() + model.slice(1); + styles[bgModel] = { + get() { + const { level } = this; + return function(...arguments_) { + const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansiStyles$2.bgColor.close, this[STYLER]); + return createBuilder(this, styler, this[IS_EMPTY]); + }; + } + }; +} +const proto = Object.defineProperties(() => { +}, { + ...styles, + level: { + enumerable: true, + get() { + return this[GENERATOR].level; + }, + set(level) { + this[GENERATOR].level = level; + } } }); +const createStyler = (open, close, parent) => { + let openAll; + let closeAll; + if (parent === void 0) { + openAll = open; + closeAll = close; + } else { + openAll = parent.openAll + open; + closeAll = close + parent.closeAll; + } + return { + open, + close, + openAll, + closeAll, + parent + }; +}; +const createBuilder = (self2, _styler, _isEmpty) => { + const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" ")); + Object.setPrototypeOf(builder, proto); + builder[GENERATOR] = self2; + builder[STYLER] = _styler; + builder[IS_EMPTY] = _isEmpty; + return builder; +}; +const applyStyle = (self2, string) => { + if (self2.level <= 0 || !string) { + return self2[IS_EMPTY] ? "" : string; + } + let styler = self2[STYLER]; + if (styler === void 0) { + return string; + } + const { openAll, closeAll } = styler; + if (string.includes("\x1B")) { + while (styler !== void 0) { + string = stringReplaceAll(string, styler.close, styler.open); + styler = styler.parent; + } + } + const lfIndex = string.indexOf("\n"); + if (lfIndex !== -1) { + string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex); + } + return openAll + string + closeAll; +}; +Object.defineProperties(createChalk.prototype, styles); +const chalk = createChalk(); +createChalk({ level: stderrColor ? stderrColor.level : 0 }); +function printObject(output, extraOptions) { + if (getGlobalOptions().json) { + console.log(JSON.stringify(output, void 0, 4)); + } else { + console.dir(output, extraOptions); + } +} +function printStatusMessage(success, message2) { + const status = success ? "Success" : "Error"; + const colorFunction = success ? chalk.green : chalk.red; + console.error(colorFunction(`${status}: ${message2}`)); +} +function printSuccess(message2) { + return () => { + printStatusMessage(true, message2); + }; +} +function printError(message2) { + return (error2) => { + printErrorMessageWithReason(message2, error2); + }; +} +function printErrorMessageWithReason(message2, error2) { + const errorMessage = "message" in error2 ? error2.message : error2; + printStatusMessage(false, `${message2}. Reason: ${errorMessage}`); +} +function observable(subscribe) { + const self2 = { + subscribe(observer) { + let teardownRef = null; + let isDone = false; + let unsubscribed = false; + let teardownImmediately = false; + function unsubscribe() { + if (teardownRef === null) { + teardownImmediately = true; + return; + } + if (unsubscribed) { + return; + } + unsubscribed = true; + if (typeof teardownRef === "function") { + teardownRef(); + } else if (teardownRef) { + teardownRef.unsubscribe(); + } + } + teardownRef = subscribe({ + next(value) { + var _a2; + if (isDone) { + return; + } + (_a2 = observer.next) == null ? void 0 : _a2.call(observer, value); + }, + error(err) { + var _a2; + if (isDone) { + return; + } + isDone = true; + (_a2 = observer.error) == null ? void 0 : _a2.call(observer, err); + unsubscribe(); + }, + complete() { + var _a2; + if (isDone) { + return; + } + isDone = true; + (_a2 = observer.complete) == null ? void 0 : _a2.call(observer); + unsubscribe(); + } + }); + if (teardownImmediately) { + unsubscribe(); + } + return { + unsubscribe + }; + }, + pipe(...operations) { + return operations.reduce(pipeReducer, self2); + } + }; + return self2; +} +function pipeReducer(prev, fn) { + return fn(prev); +} +class ObservableAbortError extends Error { + constructor(message2) { + super(message2); + this.name = "ObservableAbortError"; + Object.setPrototypeOf(this, ObservableAbortError.prototype); + } +} +function observableToPromise(observable2) { + let abort; + const promise = new Promise((resolve, reject) => { + let isDone = false; + function onDone() { + if (isDone) { + return; + } + isDone = true; + reject(new ObservableAbortError("This operation was aborted.")); + obs$.unsubscribe(); + } + const obs$ = observable2.subscribe({ + next(data2) { + isDone = true; + resolve(data2); + onDone(); + }, + error(data2) { + isDone = true; + reject(data2); + onDone(); + }, + complete() { + isDone = true; + onDone(); + } + }); + abort = onDone; + }); + return { + promise, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + abort + }; +} +function share(_opts) { + return (source) => { + let refCount = 0; + let subscription = null; + const observers = []; + function startIfNeeded() { + if (subscription) { + return; + } + subscription = source.subscribe({ + next(value) { + var _a2; + for (const observer of observers) { + (_a2 = observer.next) == null ? void 0 : _a2.call(observer, value); + } + }, + error(error2) { + var _a2; + for (const observer of observers) { + (_a2 = observer.error) == null ? void 0 : _a2.call(observer, error2); + } + }, + complete() { + var _a2; + for (const observer of observers) { + (_a2 = observer.complete) == null ? void 0 : _a2.call(observer); + } + } + }); + } + function resetIfNeeded() { + if (refCount === 0 && subscription) { + const _sub = subscription; + subscription = null; + _sub.unsubscribe(); + } + } + return observable((subscriber) => { + refCount++; + observers.push(subscriber); + startIfNeeded(); + return { + unsubscribe() { + refCount--; + resetIfNeeded(); + const index = observers.findIndex((v) => v === subscriber); + if (index > -1) { + observers.splice(index, 1); + } + } + }; + }); + }; +} +function createChain(opts) { + return observable((observer) => { + function execute(index = 0, op = opts.op) { + const next = opts.links[index]; + if (!next) { + throw new Error("No more links to execute - did you forget to add an ending link?"); + } + const subscription = next({ + op, + next(nextOp) { + const nextObserver = execute(index + 1, nextOp); + return nextObserver; + } + }); + return subscription; + } + const obs$ = execute(); + return obs$.subscribe(observer); + }); +} +const noop = () => { +}; +function createInnerProxy(callback, path2) { + const proxy = new Proxy(noop, { + get(_obj, key) { + if (typeof key !== "string" || key === "then") { + return void 0; + } + return createInnerProxy(callback, [ + ...path2, + key + ]); + }, + apply(_1, _2, args) { + const isApply = path2[path2.length - 1] === "apply"; + return callback({ + args: isApply ? args.length >= 2 ? args[1] : [] : args, + path: isApply ? path2.slice(0, -1) : path2 + }); + } + }); + return proxy; +} +const createRecursiveProxy = (callback) => createInnerProxy(callback, []); +const createFlatProxy = (callback) => { + return new Proxy(noop, { + get(_obj, name2) { + if (typeof name2 !== "string" || name2 === "then") { + return void 0; + } + return callback(name2); + } + }); +}; +function isObject$1(value) { + return !!value && !Array.isArray(value) && typeof value === "object"; +} +class UnknownCauseError extends Error { +} +function getCauseFromUnknown(cause) { + if (cause instanceof Error) { + return cause; + } + const type = typeof cause; + if (type === "undefined" || type === "function" || cause === null) { + return void 0; + } + if (type !== "object") { + return new Error(String(cause)); + } + if (isObject$1(cause)) { + const err = new UnknownCauseError(); + for (const key in cause) { + err[key] = cause[key]; + } + return err; + } + return void 0; +} +function transformResultInner(response, transformer) { + if ("error" in response) { + const error2 = transformer.deserialize(response.error); + return { + ok: false, + error: { + ...response, + error: error2 + } + }; + } + const result = { + ...response.result, + ...(!response.result.type || response.result.type === "data") && { + type: "data", + data: transformer.deserialize(response.result.data) + } + }; + return { + ok: true, + result + }; +} +class TransformResultError extends Error { + constructor() { + super("Unable to transform response from server"); + } +} +function transformResult(response, transformer) { + let result; + try { + result = transformResultInner(response, transformer); + } catch (err) { + throw new TransformResultError(); + } + if (!result.ok && (!isObject$1(result.error.error) || typeof result.error.error["code"] !== "number")) { + throw new TransformResultError(); + } + if (result.ok && !isObject$1(result.result)) { + throw new TransformResultError(); + } + return result; +} +typeof window === "undefined" || "Deno" in window || // eslint-disable-next-line @typescript-eslint/dot-notation +((_b = (_a = globalThis.process) == null ? void 0 : _a.env) == null ? void 0 : _b["NODE_ENV"]) === "test" || !!((_d = (_c = globalThis.process) == null ? void 0 : _c.env) == null ? void 0 : _d["JEST_WORKER_ID"]) || !!((_f = (_e = globalThis.process) == null ? void 0 : _e.env) == null ? void 0 : _f["VITEST_WORKER_ID"]); +function isTRPCClientError(cause) { + return cause instanceof TRPCClientError || /** + * @deprecated + * Delete in next major + */ + cause instanceof Error && cause.name === "TRPCClientError"; +} +function isTRPCErrorResponse(obj) { + return isObject$1(obj) && isObject$1(obj["error"]) && typeof obj["error"]["code"] === "number" && typeof obj["error"]["message"] === "string"; +} +class TRPCClientError extends Error { + static from(_cause, opts = {}) { + const cause = _cause; + if (isTRPCClientError(cause)) { + if (opts.meta) { + cause.meta = { + ...cause.meta, + ...opts.meta + }; + } + return cause; + } + if (isTRPCErrorResponse(cause)) { + return new TRPCClientError(cause.error.message, { + ...opts, + result: cause + }); + } + if (!(cause instanceof Error)) { + return new TRPCClientError("Unknown error", { + ...opts, + cause + }); + } + return new TRPCClientError(cause.message, { + ...opts, + cause: getCauseFromUnknown(cause) + }); + } + constructor(message2, opts) { + var _a2, _b2; + const cause = opts == null ? void 0 : opts.cause; + super(message2, { + cause + }); + this.meta = opts == null ? void 0 : opts.meta; + this.cause = cause; + this.shape = (_a2 = opts == null ? void 0 : opts.result) == null ? void 0 : _a2.error; + this.data = (_b2 = opts == null ? void 0 : opts.result) == null ? void 0 : _b2.error.data; + this.name = "TRPCClientError"; + Object.setPrototypeOf(this, TRPCClientError.prototype); + } +} +class TRPCUntypedClient { + $request({ type, input, path: path2, context = {} }) { + const chain$ = createChain({ + links: this.links, + op: { + id: ++this.requestId, + type, + path: path2, + input, + context + } + }); + return chain$.pipe(share()); + } + requestAsPromise(opts) { + const req$ = this.$request(opts); + const { promise, abort } = observableToPromise(req$); + const abortablePromise = new Promise((resolve, reject) => { + var _a2; + (_a2 = opts.signal) == null ? void 0 : _a2.addEventListener("abort", abort); + promise.then((envelope) => { + resolve(envelope.result.data); + }).catch((err) => { + reject(TRPCClientError.from(err)); + }); + }); + return abortablePromise; + } + query(path2, input, opts) { + return this.requestAsPromise({ + type: "query", + path: path2, + input, + context: opts == null ? void 0 : opts.context, + signal: opts == null ? void 0 : opts.signal + }); + } + mutation(path2, input, opts) { + return this.requestAsPromise({ + type: "mutation", + path: path2, + input, + context: opts == null ? void 0 : opts.context, + signal: opts == null ? void 0 : opts.signal + }); + } + subscription(path2, input, opts) { + const observable$ = this.$request({ + type: "subscription", + path: path2, + input, + context: opts == null ? void 0 : opts.context + }); + return observable$.subscribe({ + next(envelope) { + var _a2, _b2, _c2; + if (envelope.result.type === "started") { + (_a2 = opts.onStarted) == null ? void 0 : _a2.call(opts); + } else if (envelope.result.type === "stopped") { + (_b2 = opts.onStopped) == null ? void 0 : _b2.call(opts); + } else { + (_c2 = opts.onData) == null ? void 0 : _c2.call(opts, envelope.result.data); + } + }, + error(err) { + var _a2; + (_a2 = opts.onError) == null ? void 0 : _a2.call(opts, err); + }, + complete() { + var _a2; + (_a2 = opts.onComplete) == null ? void 0 : _a2.call(opts); + } + }); + } + constructor(opts) { + this.requestId = 0; + this.runtime = {}; + this.links = opts.links.map((link) => link(this.runtime)); + } +} +const clientCallTypeMap = { + query: "query", + mutate: "mutation", + subscribe: "subscription" +}; +const clientCallTypeToProcedureType = (clientCallType) => { + return clientCallTypeMap[clientCallType]; +}; +function createTRPCClientProxy(client) { + return createFlatProxy((key) => { + if (client.hasOwnProperty(key)) { + return client[key]; + } + if (key === "__untypedClient") { + return client; + } + return createRecursiveProxy(({ path: path2, args }) => { + const pathCopy = [ + key, + ...path2 + ]; + const procedureType = clientCallTypeToProcedureType(pathCopy.pop()); + const fullPath = pathCopy.join("."); + return client[procedureType](fullPath, ...args); + }); + }); +} +function createTRPCClient(opts) { + const client = new TRPCUntypedClient(opts); + const proxy = createTRPCClientProxy(client); + return proxy; +} +const isFunction = (fn) => typeof fn === "function"; +function getFetch(customFetchImpl) { + if (customFetchImpl) { + return customFetchImpl; + } + if (typeof window !== "undefined" && isFunction(window.fetch)) { + return window.fetch; + } + if (typeof globalThis !== "undefined" && isFunction(globalThis.fetch)) { + return globalThis.fetch; + } + throw new Error("No fetch implementation found"); +} +const throwFatalError = () => { + throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new"); +}; +function dataLoader(batchLoader) { + let pendingItems = null; + let dispatchTimer = null; + const destroyTimerAndPendingItems = () => { + clearTimeout(dispatchTimer); + dispatchTimer = null; + pendingItems = null; + }; + function groupItems(items) { + var _a2, _b2; + const groupedItems = [ + [] + ]; + let index = 0; + while (true) { + const item = items[index]; + if (!item) { + break; + } + const lastGroup = groupedItems[groupedItems.length - 1]; + if (item.aborted) { + (_a2 = item.reject) == null ? void 0 : _a2.call(item, new Error("Aborted")); + index++; + continue; + } + const isValid2 = batchLoader.validate(lastGroup.concat(item).map((it) => it.key)); + if (isValid2) { + lastGroup.push(item); + index++; + continue; + } + if (lastGroup.length === 0) { + (_b2 = item.reject) == null ? void 0 : _b2.call(item, new Error("Input is too big for a single dispatch")); + index++; + continue; + } + groupedItems.push([]); + } + return groupedItems; + } + function dispatch() { + const groupedItems = groupItems(pendingItems); + destroyTimerAndPendingItems(); + for (const items of groupedItems) { + if (!items.length) { + continue; + } + const batch = { + items, + cancel: throwFatalError + }; + for (const item of items) { + item.batch = batch; + } + const unitResolver = (index, value) => { + var _a2; + const item = batch.items[index]; + (_a2 = item.resolve) == null ? void 0 : _a2.call(item, value); + item.batch = null; + item.reject = null; + item.resolve = null; + }; + const { promise, cancel } = batchLoader.fetch(batch.items.map((_item) => _item.key), unitResolver); + batch.cancel = cancel; + promise.then((result) => { + var _a2; + for (let i = 0; i < result.length; i++) { + const value = result[i]; + unitResolver(i, value); + } + for (const item of batch.items) { + (_a2 = item.reject) == null ? void 0 : _a2.call(item, new Error("Missing result")); + item.batch = null; + } + }).catch((cause) => { + var _a2; + for (const item of batch.items) { + (_a2 = item.reject) == null ? void 0 : _a2.call(item, cause); + item.batch = null; + } + }); + } + } + function load(key) { + const item = { + aborted: false, + key, + batch: null, + resolve: throwFatalError, + reject: throwFatalError + }; + const promise = new Promise((resolve, reject) => { + item.reject = reject; + item.resolve = resolve; + if (!pendingItems) { + pendingItems = []; + } + pendingItems.push(item); + }); + if (!dispatchTimer) { + dispatchTimer = setTimeout(dispatch); + } + const cancel = () => { + var _a2; + item.aborted = true; + if ((_a2 = item.batch) == null ? void 0 : _a2.items.every((item2) => item2.aborted)) { + item.batch.cancel(); + item.batch = null; + } + }; + return { + promise, + cancel + }; + } + return { + load + }; +} +function getAbortController(customAbortControllerImpl) { + if (customAbortControllerImpl) { + return customAbortControllerImpl; + } + if (typeof window !== "undefined" && window.AbortController) { + return window.AbortController; + } + if (typeof globalThis !== "undefined" && globalThis.AbortController) { + return globalThis.AbortController; + } + return null; +} +function getTransformer(transformer) { + const _transformer = transformer; + if (!_transformer) { + return { + input: { + serialize: (data2) => data2, + deserialize: (data2) => data2 + }, + output: { + serialize: (data2) => data2, + deserialize: (data2) => data2 + } + }; + } + if ("input" in _transformer) { + return _transformer; + } + return { + input: _transformer, + output: _transformer + }; +} +function resolveHTTPLinkOptions(opts) { + return { + url: opts.url.toString().replace(/\/$/, ""), + fetch: opts.fetch, + AbortController: getAbortController(opts.AbortController), + transformer: getTransformer(opts.transformer), + methodOverride: opts.methodOverride + }; +} +function arrayToDict(array) { + const dict = {}; + for (let index = 0; index < array.length; index++) { + const element = array[index]; + dict[index] = element; + } + return dict; +} +const METHOD = { + query: "GET", + mutation: "POST" +}; +function getInput(opts) { + return "input" in opts ? opts.transformer.input.serialize(opts.input) : arrayToDict(opts.inputs.map((_input) => opts.transformer.input.serialize(_input))); +} +const getUrl = (opts) => { + let url = opts.url + "/" + opts.path; + const queryParts = []; + if ("inputs" in opts) { + queryParts.push("batch=1"); + } + if (opts.type === "query") { + const input = getInput(opts); + if (input !== void 0 && opts.methodOverride !== "POST") { + queryParts.push(`input=${encodeURIComponent(JSON.stringify(input))}`); + } + } + if (queryParts.length) { + url += "?" + queryParts.join("&"); + } + return url; +}; +const getBody = (opts) => { + if (opts.type === "query" && opts.methodOverride !== "POST") { + return void 0; + } + const input = getInput(opts); + return input !== void 0 ? JSON.stringify(input) : void 0; +}; +const jsonHttpRequester = (opts) => { + return httpRequest({ + ...opts, + contentTypeHeader: "application/json", + getUrl, + getBody + }); +}; +async function fetchHTTPResponse(opts, ac) { + const url = opts.getUrl(opts); + const body = opts.getBody(opts); + const { type } = opts; + const resolvedHeaders = await (async () => { + const heads = await opts.headers(); + if (Symbol.iterator in heads) { + return Object.fromEntries(heads); + } + return heads; + })(); + /* istanbul ignore if -- @preserve */ + if (type === "subscription") { + throw new Error("Subscriptions should use wsLink"); + } + const headers = { + ...opts.contentTypeHeader ? { + "content-type": opts.contentTypeHeader + } : {}, + ...opts.batchModeHeader ? { + "trpc-batch-mode": opts.batchModeHeader + } : {}, + ...resolvedHeaders + }; + return getFetch(opts.fetch)(url, { + method: opts.methodOverride ?? METHOD[type], + signal: ac == null ? void 0 : ac.signal, + body, + headers + }); +} +function httpRequest(opts) { + const ac = opts.AbortController ? new opts.AbortController() : null; + const meta = {}; + let done = false; + const promise = new Promise((resolve, reject) => { + fetchHTTPResponse(opts, ac).then((_res) => { + meta.response = _res; + done = true; + return _res.json(); + }).then((json) => { + meta.responseJSON = json; + resolve({ + json, + meta + }); + }).catch((err) => { + done = true; + reject(TRPCClientError.from(err, { + meta + })); + }); + }); + const cancel = () => { + if (!done) { + ac == null ? void 0 : ac.abort(); + } + }; + return { + promise, + cancel + }; +} +function createHTTPBatchLink(requester) { + return function httpBatchLink2(opts) { + const resolvedOpts = resolveHTTPLinkOptions(opts); + const maxURLLength = opts.maxURLLength ?? Infinity; + return (runtime) => { + const batchLoader = (type) => { + const validate2 = (batchOps) => { + if (maxURLLength === Infinity) { + return true; + } + const path2 = batchOps.map((op) => op.path).join(","); + const inputs = batchOps.map((op) => op.input); + const url = getUrl({ + ...resolvedOpts, + type, + path: path2, + inputs + }); + return url.length <= maxURLLength; + }; + const fetch = requester({ + ...resolvedOpts, + runtime, + type, + opts + }); + return { + validate: validate2, + fetch + }; + }; + const query = dataLoader(batchLoader("query")); + const mutation = dataLoader(batchLoader("mutation")); + const subscription = dataLoader(batchLoader("subscription")); + const loaders = { + query, + subscription, + mutation + }; + return ({ op }) => { + return observable((observer) => { + const loader = loaders[op.type]; + const { promise, cancel } = loader.load(op); + let _res = void 0; + promise.then((res) => { + _res = res; + const transformed = transformResult(res.json, resolvedOpts.transformer.output); + if (!transformed.ok) { + observer.error(TRPCClientError.from(transformed.error, { + meta: res.meta + })); + return; + } + observer.next({ + context: res.meta, + result: transformed.result + }); + observer.complete(); + }).catch((err) => { + observer.error(TRPCClientError.from(err, { + meta: _res == null ? void 0 : _res.meta + })); + }); + return () => { + cancel(); + }; + }); + }; + }; + }; +} +const batchRequester = (requesterOpts) => { + return (batchOps) => { + const path2 = batchOps.map((op) => op.path).join(","); + const inputs = batchOps.map((op) => op.input); + const { promise, cancel } = jsonHttpRequester({ + ...requesterOpts, + path: path2, + inputs, + headers() { + if (!requesterOpts.opts.headers) { + return {}; + } + if (typeof requesterOpts.opts.headers === "function") { + return requesterOpts.opts.headers({ + opList: batchOps + }); + } + return requesterOpts.opts.headers; + } + }); + return { + promise: promise.then((res) => { + const resJSON = Array.isArray(res.json) ? res.json : batchOps.map(() => res.json); + const result = resJSON.map((item) => ({ + meta: res.meta, + json: item + })); + return result; + }), + cancel + }; + }; +}; +const httpBatchLink = createHTTPBatchLink(batchRequester); +class DoubleIndexedKV { + constructor() { + this.keyToValue = /* @__PURE__ */ new Map(); + this.valueToKey = /* @__PURE__ */ new Map(); + } + set(key, value) { + this.keyToValue.set(key, value); + this.valueToKey.set(value, key); + } + getByKey(key) { + return this.keyToValue.get(key); + } + getByValue(value) { + return this.valueToKey.get(value); + } + clear() { + this.keyToValue.clear(); + this.valueToKey.clear(); + } +} +class Registry { + constructor(generateIdentifier) { + this.generateIdentifier = generateIdentifier; + this.kv = new DoubleIndexedKV(); + } + register(value, identifier) { + if (this.kv.getByValue(value)) { + return; + } + if (!identifier) { + identifier = this.generateIdentifier(value); + } + this.kv.set(identifier, value); + } + clear() { + this.kv.clear(); + } + getIdentifier(value) { + return this.kv.getByValue(value); + } + getValue(identifier) { + return this.kv.getByKey(identifier); + } +} +class ClassRegistry extends Registry { + constructor() { + super((c) => c.name); + this.classToAllowedProps = /* @__PURE__ */ new Map(); + } + register(value, options) { + if (typeof options === "object") { + if (options.allowProps) { + this.classToAllowedProps.set(value, options.allowProps); + } + super.register(value, options.identifier); + } else { + super.register(value, options); + } + } + getAllowedProps(value) { + return this.classToAllowedProps.get(value); + } +} +function valuesOfObj(record) { + if ("values" in Object) { + return Object.values(record); + } + const values = []; + for (const key in record) { + if (record.hasOwnProperty(key)) { + values.push(record[key]); + } + } + return values; +} +function find$2(record, predicate) { + const values = valuesOfObj(record); + if ("find" in values) { + return values.find(predicate); + } + const valuesNotNever = values; + for (let i = 0; i < valuesNotNever.length; i++) { + const value = valuesNotNever[i]; + if (predicate(value)) { + return value; + } + } + return void 0; +} +function forEach(record, run) { + Object.entries(record).forEach(([key, value]) => run(value, key)); +} +function includes(arr, value) { + return arr.indexOf(value) !== -1; +} +function findArr(record, predicate) { + for (let i = 0; i < record.length; i++) { + const value = record[i]; + if (predicate(value)) { + return value; + } + } + return void 0; +} +class CustomTransformerRegistry { + constructor() { + this.transfomers = {}; + } + register(transformer) { + this.transfomers[transformer.name] = transformer; + } + findApplicable(v) { + return find$2(this.transfomers, (transformer) => transformer.isApplicable(v)); + } + findByName(name2) { + return this.transfomers[name2]; + } +} +const getType$1 = (payload) => Object.prototype.toString.call(payload).slice(8, -1); +const isUndefined = (payload) => typeof payload === "undefined"; +const isNull = (payload) => payload === null; +const isPlainObject$1 = (payload) => { + if (typeof payload !== "object" || payload === null) + return false; + if (payload === Object.prototype) + return false; + if (Object.getPrototypeOf(payload) === null) + return true; + return Object.getPrototypeOf(payload) === Object.prototype; +}; +const isEmptyObject = (payload) => isPlainObject$1(payload) && Object.keys(payload).length === 0; +const isArray$2 = (payload) => Array.isArray(payload); +const isString = (payload) => typeof payload === "string"; +const isNumber$2 = (payload) => typeof payload === "number" && !isNaN(payload); +const isBoolean$1 = (payload) => typeof payload === "boolean"; +const isRegExp = (payload) => payload instanceof RegExp; +const isMap = (payload) => payload instanceof Map; +const isSet = (payload) => payload instanceof Set; +const isSymbol = (payload) => getType$1(payload) === "Symbol"; +const isDate$2 = (payload) => payload instanceof Date && !isNaN(payload.valueOf()); +const isError = (payload) => payload instanceof Error; +const isNaNValue = (payload) => typeof payload === "number" && isNaN(payload); +const isPrimitive = (payload) => isBoolean$1(payload) || isNull(payload) || isUndefined(payload) || isNumber$2(payload) || isString(payload) || isSymbol(payload); +const isBigint = (payload) => typeof payload === "bigint"; +const isInfinite = (payload) => payload === Infinity || payload === -Infinity; +const isTypedArray = (payload) => ArrayBuffer.isView(payload) && !(payload instanceof DataView); +const isURL = (payload) => payload instanceof URL; +const escapeKey = (key) => key.replace(/\./g, "\\."); +const stringifyPath = (path2) => path2.map(String).map(escapeKey).join("."); +const parsePath = (string) => { + const result = []; + let segment = ""; + for (let i = 0; i < string.length; i++) { + let char = string.charAt(i); + const isEscapedDot = char === "\\" && string.charAt(i + 1) === "."; + if (isEscapedDot) { + segment += "."; + i++; + continue; + } + const isEndOfSegment = char === "."; + if (isEndOfSegment) { + result.push(segment); + segment = ""; + continue; + } + segment += char; + } + const lastSegment = segment; + result.push(lastSegment); + return result; +}; +function simpleTransformation(isApplicable, annotation, transform, untransform) { + return { + isApplicable, + annotation, + transform, + untransform + }; +} +const simpleRules = [ + simpleTransformation(isUndefined, "undefined", () => null, () => void 0), + simpleTransformation(isBigint, "bigint", (v) => v.toString(), (v) => { + if (typeof BigInt !== "undefined") { + return BigInt(v); + } + console.error("Please add a BigInt polyfill."); + return v; + }), + simpleTransformation(isDate$2, "Date", (v) => v.toISOString(), (v) => new Date(v)), + simpleTransformation(isError, "Error", (v, superJson) => { + const baseError = { + name: v.name, + message: v.message + }; + superJson.allowedErrorProps.forEach((prop) => { + baseError[prop] = v[prop]; + }); + return baseError; + }, (v, superJson) => { + const e = new Error(v.message); + e.name = v.name; + e.stack = v.stack; + superJson.allowedErrorProps.forEach((prop) => { + e[prop] = v[prop]; + }); + return e; + }), + simpleTransformation(isRegExp, "regexp", (v) => "" + v, (regex2) => { + const body = regex2.slice(1, regex2.lastIndexOf("/")); + const flags = regex2.slice(regex2.lastIndexOf("/") + 1); + return new RegExp(body, flags); + }), + simpleTransformation( + isSet, + "set", + // (sets only exist in es6+) + // eslint-disable-next-line es5/no-es6-methods + (v) => [...v.values()], + (v) => new Set(v) + ), + simpleTransformation(isMap, "map", (v) => [...v.entries()], (v) => new Map(v)), + simpleTransformation((v) => isNaNValue(v) || isInfinite(v), "number", (v) => { + if (isNaNValue(v)) { + return "NaN"; + } + if (v > 0) { + return "Infinity"; + } else { + return "-Infinity"; + } + }, Number), + simpleTransformation((v) => v === 0 && 1 / v === -Infinity, "number", () => { + return "-0"; + }, Number), + simpleTransformation(isURL, "URL", (v) => v.toString(), (v) => new URL(v)) +]; +function compositeTransformation(isApplicable, annotation, transform, untransform) { + return { + isApplicable, + annotation, + transform, + untransform + }; +} +const symbolRule = compositeTransformation((s, superJson) => { + if (isSymbol(s)) { + const isRegistered = !!superJson.symbolRegistry.getIdentifier(s); + return isRegistered; + } + return false; +}, (s, superJson) => { + const identifier = superJson.symbolRegistry.getIdentifier(s); + return ["symbol", identifier]; +}, (v) => v.description, (_, a, superJson) => { + const value = superJson.symbolRegistry.getValue(a[1]); + if (!value) { + throw new Error("Trying to deserialize unknown symbol"); + } + return value; +}); +const constructorToName = [ + Int8Array, + Uint8Array, + Int16Array, + Uint16Array, + Int32Array, + Uint32Array, + Float32Array, + Float64Array, + Uint8ClampedArray +].reduce((obj, ctor) => { + obj[ctor.name] = ctor; + return obj; +}, {}); +const typedArrayRule = compositeTransformation(isTypedArray, (v) => ["typed-array", v.constructor.name], (v) => [...v], (v, a) => { + const ctor = constructorToName[a[1]]; + if (!ctor) { + throw new Error("Trying to deserialize unknown typed array"); + } + return new ctor(v); +}); +function isInstanceOfRegisteredClass(potentialClass, superJson) { + if (potentialClass == null ? void 0 : potentialClass.constructor) { + const isRegistered = !!superJson.classRegistry.getIdentifier(potentialClass.constructor); + return isRegistered; + } + return false; +} +const classRule = compositeTransformation(isInstanceOfRegisteredClass, (clazz, superJson) => { + const identifier = superJson.classRegistry.getIdentifier(clazz.constructor); + return ["class", identifier]; +}, (clazz, superJson) => { + const allowedProps = superJson.classRegistry.getAllowedProps(clazz.constructor); + if (!allowedProps) { + return { ...clazz }; + } + const result = {}; + allowedProps.forEach((prop) => { + result[prop] = clazz[prop]; + }); + return result; +}, (v, a, superJson) => { + const clazz = superJson.classRegistry.getValue(a[1]); + if (!clazz) { + throw new Error("Trying to deserialize unknown class - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564"); + } + return Object.assign(Object.create(clazz.prototype), v); +}); +const customRule = compositeTransformation((value, superJson) => { + return !!superJson.customTransformerRegistry.findApplicable(value); +}, (value, superJson) => { + const transformer = superJson.customTransformerRegistry.findApplicable(value); + return ["custom", transformer.name]; +}, (value, superJson) => { + const transformer = superJson.customTransformerRegistry.findApplicable(value); + return transformer.serialize(value); +}, (v, a, superJson) => { + const transformer = superJson.customTransformerRegistry.findByName(a[1]); + if (!transformer) { + throw new Error("Trying to deserialize unknown custom value"); + } + return transformer.deserialize(v); +}); +const compositeRules = [classRule, symbolRule, customRule, typedArrayRule]; +const transformValue = (value, superJson) => { + const applicableCompositeRule = findArr(compositeRules, (rule) => rule.isApplicable(value, superJson)); + if (applicableCompositeRule) { + return { + value: applicableCompositeRule.transform(value, superJson), + type: applicableCompositeRule.annotation(value, superJson) + }; + } + const applicableSimpleRule = findArr(simpleRules, (rule) => rule.isApplicable(value, superJson)); + if (applicableSimpleRule) { + return { + value: applicableSimpleRule.transform(value, superJson), + type: applicableSimpleRule.annotation + }; + } + return void 0; +}; +const simpleRulesByAnnotation = {}; +simpleRules.forEach((rule) => { + simpleRulesByAnnotation[rule.annotation] = rule; +}); +const untransformValue = (json, type, superJson) => { + if (isArray$2(type)) { + switch (type[0]) { + case "symbol": + return symbolRule.untransform(json, type, superJson); + case "class": + return classRule.untransform(json, type, superJson); + case "custom": + return customRule.untransform(json, type, superJson); + case "typed-array": + return typedArrayRule.untransform(json, type, superJson); + default: + throw new Error("Unknown transformation: " + type); + } + } else { + const transformation = simpleRulesByAnnotation[type]; + if (!transformation) { + throw new Error("Unknown transformation: " + type); + } + return transformation.untransform(json, superJson); + } +}; +const getNthKey = (value, n) => { + const keys = value.keys(); + while (n > 0) { + keys.next(); + n--; + } + return keys.next().value; +}; +function validatePath(path2) { + if (includes(path2, "__proto__")) { + throw new Error("__proto__ is not allowed as a property"); + } + if (includes(path2, "prototype")) { + throw new Error("prototype is not allowed as a property"); + } + if (includes(path2, "constructor")) { + throw new Error("constructor is not allowed as a property"); + } +} +const getDeep = (object, path2) => { + validatePath(path2); + for (let i = 0; i < path2.length; i++) { + const key = path2[i]; + if (isSet(object)) { + object = getNthKey(object, +key); + } else if (isMap(object)) { + const row = +key; + const type = +path2[++i] === 0 ? "key" : "value"; + const keyOfRow = getNthKey(object, row); + switch (type) { + case "key": + object = keyOfRow; + break; + case "value": + object = object.get(keyOfRow); + break; + } + } else { + object = object[key]; + } + } + return object; +}; +const setDeep = (object, path2, mapper) => { + validatePath(path2); + if (path2.length === 0) { + return mapper(object); + } + let parent = object; + for (let i = 0; i < path2.length - 1; i++) { + const key = path2[i]; + if (isArray$2(parent)) { + const index = +key; + parent = parent[index]; + } else if (isPlainObject$1(parent)) { + parent = parent[key]; + } else if (isSet(parent)) { + const row = +key; + parent = getNthKey(parent, row); + } else if (isMap(parent)) { + const isEnd = i === path2.length - 2; + if (isEnd) { + break; + } + const row = +key; + const type = +path2[++i] === 0 ? "key" : "value"; + const keyOfRow = getNthKey(parent, row); + switch (type) { + case "key": + parent = keyOfRow; + break; + case "value": + parent = parent.get(keyOfRow); + break; + } + } + } + const lastKey = path2[path2.length - 1]; + if (isArray$2(parent)) { + parent[+lastKey] = mapper(parent[+lastKey]); + } else if (isPlainObject$1(parent)) { + parent[lastKey] = mapper(parent[lastKey]); + } + if (isSet(parent)) { + const oldValue = getNthKey(parent, +lastKey); + const newValue = mapper(oldValue); + if (oldValue !== newValue) { + parent.delete(oldValue); + parent.add(newValue); + } + } + if (isMap(parent)) { + const row = +path2[path2.length - 2]; + const keyToRow = getNthKey(parent, row); + const type = +lastKey === 0 ? "key" : "value"; + switch (type) { + case "key": { + const newKey = mapper(keyToRow); + parent.set(newKey, parent.get(keyToRow)); + if (newKey !== keyToRow) { + parent.delete(keyToRow); + } + break; + } + case "value": { + parent.set(keyToRow, mapper(parent.get(keyToRow))); + break; + } + } + } + return object; +}; +function traverse$1(tree, walker2, origin = []) { + if (!tree) { + return; + } + if (!isArray$2(tree)) { + forEach(tree, (subtree, key) => traverse$1(subtree, walker2, [...origin, ...parsePath(key)])); + return; + } + const [nodeValue, children] = tree; + if (children) { + forEach(children, (child, key) => { + traverse$1(child, walker2, [...origin, ...parsePath(key)]); + }); + } + walker2(nodeValue, origin); +} +function applyValueAnnotations(plain, annotations, superJson) { + traverse$1(annotations, (type, path2) => { + plain = setDeep(plain, path2, (v) => untransformValue(v, type, superJson)); + }); + return plain; +} +function applyReferentialEqualityAnnotations(plain, annotations) { + function apply(identicalPaths, path2) { + const object = getDeep(plain, parsePath(path2)); + identicalPaths.map(parsePath).forEach((identicalObjectPath) => { + plain = setDeep(plain, identicalObjectPath, () => object); + }); + } + if (isArray$2(annotations)) { + const [root, other] = annotations; + root.forEach((identicalPath) => { + plain = setDeep(plain, parsePath(identicalPath), () => plain); + }); + if (other) { + forEach(other, apply); + } + } else { + forEach(annotations, apply); + } + return plain; +} +const isDeep = (object, superJson) => isPlainObject$1(object) || isArray$2(object) || isMap(object) || isSet(object) || isInstanceOfRegisteredClass(object, superJson); +function addIdentity(object, path2, identities) { + const existingSet = identities.get(object); + if (existingSet) { + existingSet.push(path2); + } else { + identities.set(object, [path2]); + } +} +function generateReferentialEqualityAnnotations(identitites, dedupe) { + const result = {}; + let rootEqualityPaths = void 0; + identitites.forEach((paths) => { + if (paths.length <= 1) { + return; + } + if (!dedupe) { + paths = paths.map((path2) => path2.map(String)).sort((a, b) => a.length - b.length); + } + const [representativePath, ...identicalPaths] = paths; + if (representativePath.length === 0) { + rootEqualityPaths = identicalPaths.map(stringifyPath); + } else { + result[stringifyPath(representativePath)] = identicalPaths.map(stringifyPath); + } + }); + if (rootEqualityPaths) { + if (isEmptyObject(result)) { + return [rootEqualityPaths]; + } else { + return [rootEqualityPaths, result]; + } + } else { + return isEmptyObject(result) ? void 0 : result; + } +} +const walker = (object, identities, superJson, dedupe, path2 = [], objectsInThisPath = [], seenObjects = /* @__PURE__ */ new Map()) => { + const primitive = isPrimitive(object); + if (!primitive) { + addIdentity(object, path2, identities); + const seen = seenObjects.get(object); + if (seen) { + return dedupe ? { + transformedValue: null + } : seen; + } + } + if (!isDeep(object, superJson)) { + const transformed2 = transformValue(object, superJson); + const result2 = transformed2 ? { + transformedValue: transformed2.value, + annotations: [transformed2.type] + } : { + transformedValue: object + }; + if (!primitive) { + seenObjects.set(object, result2); + } + return result2; + } + if (includes(objectsInThisPath, object)) { + return { + transformedValue: null + }; + } + const transformationResult = transformValue(object, superJson); + const transformed = (transformationResult == null ? void 0 : transformationResult.value) ?? object; + const transformedValue = isArray$2(transformed) ? [] : {}; + const innerAnnotations = {}; + forEach(transformed, (value, index) => { + if (index === "__proto__" || index === "constructor" || index === "prototype") { + throw new Error(`Detected property ${index}. This is a prototype pollution risk, please remove it from your object.`); + } + const recursiveResult = walker(value, identities, superJson, dedupe, [...path2, index], [...objectsInThisPath, object], seenObjects); + transformedValue[index] = recursiveResult.transformedValue; + if (isArray$2(recursiveResult.annotations)) { + innerAnnotations[index] = recursiveResult.annotations; + } else if (isPlainObject$1(recursiveResult.annotations)) { + forEach(recursiveResult.annotations, (tree, key) => { + innerAnnotations[escapeKey(index) + "." + key] = tree; + }); + } + }); + const result = isEmptyObject(innerAnnotations) ? { + transformedValue, + annotations: !!transformationResult ? [transformationResult.type] : void 0 + } : { + transformedValue, + annotations: !!transformationResult ? [transformationResult.type, innerAnnotations] : innerAnnotations + }; + if (!primitive) { + seenObjects.set(object, result); + } + return result; +}; +function getType(payload) { + return Object.prototype.toString.call(payload).slice(8, -1); +} +function isArray$1(payload) { + return getType(payload) === "Array"; +} +function isPlainObject(payload) { + if (getType(payload) !== "Object") + return false; + const prototype = Object.getPrototypeOf(payload); + return !!prototype && prototype.constructor === Object && prototype === Object.prototype; +} +function assignProp(carry, key, newVal, originalObject, includeNonenumerable) { + const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable"; + if (propType === "enumerable") + carry[key] = newVal; + if (includeNonenumerable && propType === "nonenumerable") { + Object.defineProperty(carry, key, { + value: newVal, + enumerable: false, + writable: true, + configurable: true + }); + } +} +function copy(target, options = {}) { + if (isArray$1(target)) { + return target.map((item) => copy(item, options)); + } + if (!isPlainObject(target)) { + return target; + } + const props = Object.getOwnPropertyNames(target); + const symbols2 = Object.getOwnPropertySymbols(target); + return [...props, ...symbols2].reduce((carry, key) => { + if (isArray$1(options.props) && !options.props.includes(key)) { + return carry; + } + const val = target[key]; + const newVal = copy(val, options); + assignProp(carry, key, newVal, target, options.nonenumerable); + return carry; + }, {}); +} +class SuperJSON { + /** + * @param dedupeReferentialEqualities If true, SuperJSON will make sure only one instance of referentially equal objects are serialized and the rest are replaced with `null`. + */ + constructor({ dedupe = false } = {}) { + this.classRegistry = new ClassRegistry(); + this.symbolRegistry = new Registry((s) => s.description ?? ""); + this.customTransformerRegistry = new CustomTransformerRegistry(); + this.allowedErrorProps = []; + this.dedupe = dedupe; + } + serialize(object) { + const identities = /* @__PURE__ */ new Map(); + const output = walker(object, identities, this, this.dedupe); + const res = { + json: output.transformedValue + }; + if (output.annotations) { + res.meta = { + ...res.meta, + values: output.annotations + }; + } + const equalityAnnotations = generateReferentialEqualityAnnotations(identities, this.dedupe); + if (equalityAnnotations) { + res.meta = { + ...res.meta, + referentialEqualities: equalityAnnotations + }; + } + return res; + } + deserialize(payload) { + const { json, meta } = payload; + let result = copy(json); + if (meta == null ? void 0 : meta.values) { + result = applyValueAnnotations(result, meta.values, this); + } + if (meta == null ? void 0 : meta.referentialEqualities) { + result = applyReferentialEqualityAnnotations(result, meta.referentialEqualities); + } + return result; + } + stringify(object) { + return JSON.stringify(this.serialize(object)); + } + parse(string) { + return this.deserialize(JSON.parse(string)); + } + registerClass(v, options) { + this.classRegistry.register(v, options); + } + registerSymbol(v, identifier) { + this.symbolRegistry.register(v, identifier); + } + registerCustom(transformer, name2) { + this.customTransformerRegistry.register({ + name: name2, + ...transformer + }); + } + allowErrorProps(...props) { + this.allowedErrorProps.push(...props); + } +} +SuperJSON.defaultInstance = new SuperJSON(); +SuperJSON.serialize = SuperJSON.defaultInstance.serialize.bind(SuperJSON.defaultInstance); +SuperJSON.deserialize = SuperJSON.defaultInstance.deserialize.bind(SuperJSON.defaultInstance); +SuperJSON.stringify = SuperJSON.defaultInstance.stringify.bind(SuperJSON.defaultInstance); +SuperJSON.parse = SuperJSON.defaultInstance.parse.bind(SuperJSON.defaultInstance); +SuperJSON.registerClass = SuperJSON.defaultInstance.registerClass.bind(SuperJSON.defaultInstance); +SuperJSON.registerSymbol = SuperJSON.defaultInstance.registerSymbol.bind(SuperJSON.defaultInstance); +SuperJSON.registerCustom = SuperJSON.defaultInstance.registerCustom.bind(SuperJSON.defaultInstance); +SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(SuperJSON.defaultInstance); +SuperJSON.serialize; +SuperJSON.deserialize; +SuperJSON.stringify; +SuperJSON.parse; +SuperJSON.registerClass; +SuperJSON.registerCustom; +SuperJSON.registerSymbol; +SuperJSON.allowErrorProps; +function getAPIClient() { + const globals = getGlobalOptions(); + return createTRPCClient({ + links: [ + httpBatchLink({ + transformer: SuperJSON, + url: `${globals.serverAddr}/api/trpc`, + maxURLLength: 14e3, + headers() { + return { + authorization: `Bearer ${globals.apiKey}` + }; + } + }) + ] + }); +} +const whoamiCmd = new Command2().name("whoami").description("returns info about the owner of this API key").action(async () => { + await getAPIClient().users.whoami.query().then(printObject).catch( + printError( + `Unable to fetch information about the owner of this API key` + ) + ); +}); +var src = {}; +var createStream$1 = {}; +var alignTableData$1 = {}; +var alignString$1 = {}; +var stringWidth$1 = { exports: {} }; +var ansiRegex$1 = ({ onlyFirst = false } = {}) => { + const pattern = [ + "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", + "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))" + ].join("|"); + return new RegExp(pattern, onlyFirst ? void 0 : "g"); +}; +const ansiRegex = ansiRegex$1; +var stripAnsi$1 = (string) => typeof string === "string" ? string.replace(ansiRegex(), "") : string; +var isFullwidthCodePoint$3 = { exports: {} }; +const isFullwidthCodePoint$2 = (codePoint) => { + if (Number.isNaN(codePoint)) { + return false; + } + if (codePoint >= 4352 && (codePoint <= 4447 || // Hangul Jamo + codePoint === 9001 || // LEFT-POINTING ANGLE BRACKET + codePoint === 9002 || // RIGHT-POINTING ANGLE BRACKET + // CJK Radicals Supplement .. Enclosed CJK Letters and Months + 11904 <= codePoint && codePoint <= 12871 && codePoint !== 12351 || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A + 12880 <= codePoint && codePoint <= 19903 || // CJK Unified Ideographs .. Yi Radicals + 19968 <= codePoint && codePoint <= 42182 || // Hangul Jamo Extended-A + 43360 <= codePoint && codePoint <= 43388 || // Hangul Syllables + 44032 <= codePoint && codePoint <= 55203 || // CJK Compatibility Ideographs + 63744 <= codePoint && codePoint <= 64255 || // Vertical Forms + 65040 <= codePoint && codePoint <= 65049 || // CJK Compatibility Forms .. Small Form Variants + 65072 <= codePoint && codePoint <= 65131 || // Halfwidth and Fullwidth Forms + 65281 <= codePoint && codePoint <= 65376 || 65504 <= codePoint && codePoint <= 65510 || // Kana Supplement + 110592 <= codePoint && codePoint <= 110593 || // Enclosed Ideographic Supplement + 127488 <= codePoint && codePoint <= 127569 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane + 131072 <= codePoint && codePoint <= 262141)) { + return true; + } + return false; +}; +isFullwidthCodePoint$3.exports = isFullwidthCodePoint$2; +isFullwidthCodePoint$3.exports.default = isFullwidthCodePoint$2; +var isFullwidthCodePointExports = isFullwidthCodePoint$3.exports; +var emojiRegex$1 = function() { + return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g; +}; +const stripAnsi = stripAnsi$1; +const isFullwidthCodePoint$1 = isFullwidthCodePointExports; +const emojiRegex = emojiRegex$1; +const stringWidth = (string) => { + if (typeof string !== "string" || string.length === 0) { + return 0; + } + string = stripAnsi(string); + if (string.length === 0) { + return 0; + } + string = string.replace(emojiRegex(), " "); + let width = 0; + for (let i = 0; i < string.length; i++) { + const code = string.codePointAt(i); + if (code <= 31 || code >= 127 && code <= 159) { + continue; + } + if (code >= 768 && code <= 879) { + continue; + } + if (code > 65535) { + i++; + } + width += isFullwidthCodePoint$1(code) ? 2 : 1; + } + return width; +}; +stringWidth$1.exports = stringWidth; +stringWidth$1.exports.default = stringWidth; +var stringWidthExports = stringWidth$1.exports; +var utils = {}; +const regex = "[\uD800-\uDBFF][\uDC00-\uDFFF]"; +const astralRegex$1 = (options) => options && options.exact ? new RegExp(`^${regex}$`) : new RegExp(regex, "g"); +var astralRegex_1 = astralRegex$1; +var ansiStyles$1 = { exports: {} }; +var colorName; +var hasRequiredColorName; +function requireColorName() { + if (hasRequiredColorName) return colorName; + hasRequiredColorName = 1; + colorName = { + "aliceblue": [240, 248, 255], + "antiquewhite": [250, 235, 215], + "aqua": [0, 255, 255], + "aquamarine": [127, 255, 212], + "azure": [240, 255, 255], + "beige": [245, 245, 220], + "bisque": [255, 228, 196], + "black": [0, 0, 0], + "blanchedalmond": [255, 235, 205], + "blue": [0, 0, 255], + "blueviolet": [138, 43, 226], + "brown": [165, 42, 42], + "burlywood": [222, 184, 135], + "cadetblue": [95, 158, 160], + "chartreuse": [127, 255, 0], + "chocolate": [210, 105, 30], + "coral": [255, 127, 80], + "cornflowerblue": [100, 149, 237], + "cornsilk": [255, 248, 220], + "crimson": [220, 20, 60], + "cyan": [0, 255, 255], + "darkblue": [0, 0, 139], + "darkcyan": [0, 139, 139], + "darkgoldenrod": [184, 134, 11], + "darkgray": [169, 169, 169], + "darkgreen": [0, 100, 0], + "darkgrey": [169, 169, 169], + "darkkhaki": [189, 183, 107], + "darkmagenta": [139, 0, 139], + "darkolivegreen": [85, 107, 47], + "darkorange": [255, 140, 0], + "darkorchid": [153, 50, 204], + "darkred": [139, 0, 0], + "darksalmon": [233, 150, 122], + "darkseagreen": [143, 188, 143], + "darkslateblue": [72, 61, 139], + "darkslategray": [47, 79, 79], + "darkslategrey": [47, 79, 79], + "darkturquoise": [0, 206, 209], + "darkviolet": [148, 0, 211], + "deeppink": [255, 20, 147], + "deepskyblue": [0, 191, 255], + "dimgray": [105, 105, 105], + "dimgrey": [105, 105, 105], + "dodgerblue": [30, 144, 255], + "firebrick": [178, 34, 34], + "floralwhite": [255, 250, 240], + "forestgreen": [34, 139, 34], + "fuchsia": [255, 0, 255], + "gainsboro": [220, 220, 220], + "ghostwhite": [248, 248, 255], + "gold": [255, 215, 0], + "goldenrod": [218, 165, 32], + "gray": [128, 128, 128], + "green": [0, 128, 0], + "greenyellow": [173, 255, 47], + "grey": [128, 128, 128], + "honeydew": [240, 255, 240], + "hotpink": [255, 105, 180], + "indianred": [205, 92, 92], + "indigo": [75, 0, 130], + "ivory": [255, 255, 240], + "khaki": [240, 230, 140], + "lavender": [230, 230, 250], + "lavenderblush": [255, 240, 245], + "lawngreen": [124, 252, 0], + "lemonchiffon": [255, 250, 205], + "lightblue": [173, 216, 230], + "lightcoral": [240, 128, 128], + "lightcyan": [224, 255, 255], + "lightgoldenrodyellow": [250, 250, 210], + "lightgray": [211, 211, 211], + "lightgreen": [144, 238, 144], + "lightgrey": [211, 211, 211], + "lightpink": [255, 182, 193], + "lightsalmon": [255, 160, 122], + "lightseagreen": [32, 178, 170], + "lightskyblue": [135, 206, 250], + "lightslategray": [119, 136, 153], + "lightslategrey": [119, 136, 153], + "lightsteelblue": [176, 196, 222], + "lightyellow": [255, 255, 224], + "lime": [0, 255, 0], + "limegreen": [50, 205, 50], + "linen": [250, 240, 230], + "magenta": [255, 0, 255], + "maroon": [128, 0, 0], + "mediumaquamarine": [102, 205, 170], + "mediumblue": [0, 0, 205], + "mediumorchid": [186, 85, 211], + "mediumpurple": [147, 112, 219], + "mediumseagreen": [60, 179, 113], + "mediumslateblue": [123, 104, 238], + "mediumspringgreen": [0, 250, 154], + "mediumturquoise": [72, 209, 204], + "mediumvioletred": [199, 21, 133], + "midnightblue": [25, 25, 112], + "mintcream": [245, 255, 250], + "mistyrose": [255, 228, 225], + "moccasin": [255, 228, 181], + "navajowhite": [255, 222, 173], + "navy": [0, 0, 128], + "oldlace": [253, 245, 230], + "olive": [128, 128, 0], + "olivedrab": [107, 142, 35], + "orange": [255, 165, 0], + "orangered": [255, 69, 0], + "orchid": [218, 112, 214], + "palegoldenrod": [238, 232, 170], + "palegreen": [152, 251, 152], + "paleturquoise": [175, 238, 238], + "palevioletred": [219, 112, 147], + "papayawhip": [255, 239, 213], + "peachpuff": [255, 218, 185], + "peru": [205, 133, 63], + "pink": [255, 192, 203], + "plum": [221, 160, 221], + "powderblue": [176, 224, 230], + "purple": [128, 0, 128], + "rebeccapurple": [102, 51, 153], + "red": [255, 0, 0], + "rosybrown": [188, 143, 143], + "royalblue": [65, 105, 225], + "saddlebrown": [139, 69, 19], + "salmon": [250, 128, 114], + "sandybrown": [244, 164, 96], + "seagreen": [46, 139, 87], + "seashell": [255, 245, 238], + "sienna": [160, 82, 45], + "silver": [192, 192, 192], + "skyblue": [135, 206, 235], + "slateblue": [106, 90, 205], + "slategray": [112, 128, 144], + "slategrey": [112, 128, 144], + "snow": [255, 250, 250], + "springgreen": [0, 255, 127], + "steelblue": [70, 130, 180], + "tan": [210, 180, 140], + "teal": [0, 128, 128], + "thistle": [216, 191, 216], + "tomato": [255, 99, 71], + "turquoise": [64, 224, 208], + "violet": [238, 130, 238], + "wheat": [245, 222, 179], + "white": [255, 255, 255], + "whitesmoke": [245, 245, 245], + "yellow": [255, 255, 0], + "yellowgreen": [154, 205, 50] + }; + return colorName; +} +var conversions; +var hasRequiredConversions; +function requireConversions() { + if (hasRequiredConversions) return conversions; + hasRequiredConversions = 1; + const cssKeywords = requireColorName(); + const reverseKeywords = {}; + for (const key of Object.keys(cssKeywords)) { + reverseKeywords[cssKeywords[key]] = key; + } + const convert = { + rgb: { channels: 3, labels: "rgb" }, + hsl: { channels: 3, labels: "hsl" }, + hsv: { channels: 3, labels: "hsv" }, + hwb: { channels: 3, labels: "hwb" }, + cmyk: { channels: 4, labels: "cmyk" }, + xyz: { channels: 3, labels: "xyz" }, + lab: { channels: 3, labels: "lab" }, + lch: { channels: 3, labels: "lch" }, + hex: { channels: 1, labels: ["hex"] }, + keyword: { channels: 1, labels: ["keyword"] }, + ansi16: { channels: 1, labels: ["ansi16"] }, + ansi256: { channels: 1, labels: ["ansi256"] }, + hcg: { channels: 3, labels: ["h", "c", "g"] }, + apple: { channels: 3, labels: ["r16", "g16", "b16"] }, + gray: { channels: 1, labels: ["gray"] } + }; + conversions = convert; + for (const model of Object.keys(convert)) { + if (!("channels" in convert[model])) { + throw new Error("missing channels property: " + model); + } + if (!("labels" in convert[model])) { + throw new Error("missing channel labels property: " + model); + } + if (convert[model].labels.length !== convert[model].channels) { + throw new Error("channel and label counts mismatch: " + model); + } + const { channels, labels } = convert[model]; + delete convert[model].channels; + delete convert[model].labels; + Object.defineProperty(convert[model], "channels", { value: channels }); + Object.defineProperty(convert[model], "labels", { value: labels }); + } + convert.rgb.hsl = function(rgb) { + const r = rgb[0] / 255; + const g = rgb[1] / 255; + const b = rgb[2] / 255; + const min = Math.min(r, g, b); + const max = Math.max(r, g, b); + const delta = max - min; + let h; + let s; + if (max === min) { + h = 0; + } else if (r === max) { + h = (g - b) / delta; + } else if (g === max) { + h = 2 + (b - r) / delta; + } else if (b === max) { + h = 4 + (r - g) / delta; + } + h = Math.min(h * 60, 360); + if (h < 0) { + h += 360; + } + const l = (min + max) / 2; + if (max === min) { + s = 0; + } else if (l <= 0.5) { + s = delta / (max + min); + } else { + s = delta / (2 - max - min); + } + return [h, s * 100, l * 100]; + }; + convert.rgb.hsv = function(rgb) { + let rdif; + let gdif; + let bdif; + let h; + let s; + const r = rgb[0] / 255; + const g = rgb[1] / 255; + const b = rgb[2] / 255; + const v = Math.max(r, g, b); + const diff2 = v - Math.min(r, g, b); + const diffc = function(c) { + return (v - c) / 6 / diff2 + 1 / 2; + }; + if (diff2 === 0) { + h = 0; + s = 0; + } else { + s = diff2 / v; + rdif = diffc(r); + gdif = diffc(g); + bdif = diffc(b); + if (r === v) { + h = bdif - gdif; + } else if (g === v) { + h = 1 / 3 + rdif - bdif; + } else if (b === v) { + h = 2 / 3 + gdif - rdif; + } + if (h < 0) { + h += 1; + } else if (h > 1) { + h -= 1; + } + } + return [ + h * 360, + s * 100, + v * 100 + ]; + }; + convert.rgb.hwb = function(rgb) { + const r = rgb[0]; + const g = rgb[1]; + let b = rgb[2]; + const h = convert.rgb.hsl(rgb)[0]; + const w = 1 / 255 * Math.min(r, Math.min(g, b)); + b = 1 - 1 / 255 * Math.max(r, Math.max(g, b)); + return [h, w * 100, b * 100]; + }; + convert.rgb.cmyk = function(rgb) { + const r = rgb[0] / 255; + const g = rgb[1] / 255; + const b = rgb[2] / 255; + const k = Math.min(1 - r, 1 - g, 1 - b); + const c = (1 - r - k) / (1 - k) || 0; + const m = (1 - g - k) / (1 - k) || 0; + const y = (1 - b - k) / (1 - k) || 0; + return [c * 100, m * 100, y * 100, k * 100]; + }; + function comparativeDistance(x, y) { + return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2; + } + convert.rgb.keyword = function(rgb) { + const reversed = reverseKeywords[rgb]; + if (reversed) { + return reversed; + } + let currentClosestDistance = Infinity; + let currentClosestKeyword; + for (const keyword of Object.keys(cssKeywords)) { + const value = cssKeywords[keyword]; + const distance = comparativeDistance(rgb, value); + if (distance < currentClosestDistance) { + currentClosestDistance = distance; + currentClosestKeyword = keyword; + } + } + return currentClosestKeyword; + }; + convert.keyword.rgb = function(keyword) { + return cssKeywords[keyword]; + }; + convert.rgb.xyz = function(rgb) { + let r = rgb[0] / 255; + let g = rgb[1] / 255; + let b = rgb[2] / 255; + r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92; + g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92; + b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92; + const x = r * 0.4124 + g * 0.3576 + b * 0.1805; + const y = r * 0.2126 + g * 0.7152 + b * 0.0722; + const z = r * 0.0193 + g * 0.1192 + b * 0.9505; + return [x * 100, y * 100, z * 100]; + }; + convert.rgb.lab = function(rgb) { + const xyz = convert.rgb.xyz(rgb); + let x = xyz[0]; + let y = xyz[1]; + let z = xyz[2]; + x /= 95.047; + y /= 100; + z /= 108.883; + x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116; + y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116; + z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116; + const l = 116 * y - 16; + const a = 500 * (x - y); + const b = 200 * (y - z); + return [l, a, b]; + }; + convert.hsl.rgb = function(hsl) { + const h = hsl[0] / 360; + const s = hsl[1] / 100; + const l = hsl[2] / 100; + let t2; + let t3; + let val; + if (s === 0) { + val = l * 255; + return [val, val, val]; + } + if (l < 0.5) { + t2 = l * (1 + s); + } else { + t2 = l + s - l * s; + } + const t1 = 2 * l - t2; + const rgb = [0, 0, 0]; + for (let i = 0; i < 3; i++) { + t3 = h + 1 / 3 * -(i - 1); + if (t3 < 0) { + t3++; + } + if (t3 > 1) { + t3--; + } + if (6 * t3 < 1) { + val = t1 + (t2 - t1) * 6 * t3; + } else if (2 * t3 < 1) { + val = t2; + } else if (3 * t3 < 2) { + val = t1 + (t2 - t1) * (2 / 3 - t3) * 6; + } else { + val = t1; + } + rgb[i] = val * 255; + } + return rgb; + }; + convert.hsl.hsv = function(hsl) { + const h = hsl[0]; + let s = hsl[1] / 100; + let l = hsl[2] / 100; + let smin = s; + const lmin = Math.max(l, 0.01); + l *= 2; + s *= l <= 1 ? l : 2 - l; + smin *= lmin <= 1 ? lmin : 2 - lmin; + const v = (l + s) / 2; + const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s); + return [h, sv * 100, v * 100]; + }; + convert.hsv.rgb = function(hsv) { + const h = hsv[0] / 60; + const s = hsv[1] / 100; + let v = hsv[2] / 100; + const hi = Math.floor(h) % 6; + const f = h - Math.floor(h); + const p = 255 * v * (1 - s); + const q = 255 * v * (1 - s * f); + const t = 255 * v * (1 - s * (1 - f)); + v *= 255; + switch (hi) { + case 0: + return [v, t, p]; + case 1: + return [q, v, p]; + case 2: + return [p, v, t]; + case 3: + return [p, q, v]; + case 4: + return [t, p, v]; + case 5: + return [v, p, q]; + } + }; + convert.hsv.hsl = function(hsv) { + const h = hsv[0]; + const s = hsv[1] / 100; + const v = hsv[2] / 100; + const vmin = Math.max(v, 0.01); + let sl; + let l; + l = (2 - s) * v; + const lmin = (2 - s) * vmin; + sl = s * vmin; + sl /= lmin <= 1 ? lmin : 2 - lmin; + sl = sl || 0; + l /= 2; + return [h, sl * 100, l * 100]; + }; + convert.hwb.rgb = function(hwb) { + const h = hwb[0] / 360; + let wh = hwb[1] / 100; + let bl = hwb[2] / 100; + const ratio = wh + bl; + let f; + if (ratio > 1) { + wh /= ratio; + bl /= ratio; + } + const i = Math.floor(6 * h); + const v = 1 - bl; + f = 6 * h - i; + if ((i & 1) !== 0) { + f = 1 - f; + } + const n = wh + f * (v - wh); + let r; + let g; + let b; + switch (i) { + default: + case 6: + case 0: + r = v; + g = n; + b = wh; + break; + case 1: + r = n; + g = v; + b = wh; + break; + case 2: + r = wh; + g = v; + b = n; + break; + case 3: + r = wh; + g = n; + b = v; + break; + case 4: + r = n; + g = wh; + b = v; + break; + case 5: + r = v; + g = wh; + b = n; + break; + } + return [r * 255, g * 255, b * 255]; + }; + convert.cmyk.rgb = function(cmyk) { + const c = cmyk[0] / 100; + const m = cmyk[1] / 100; + const y = cmyk[2] / 100; + const k = cmyk[3] / 100; + const r = 1 - Math.min(1, c * (1 - k) + k); + const g = 1 - Math.min(1, m * (1 - k) + k); + const b = 1 - Math.min(1, y * (1 - k) + k); + return [r * 255, g * 255, b * 255]; + }; + convert.xyz.rgb = function(xyz) { + const x = xyz[0] / 100; + const y = xyz[1] / 100; + const z = xyz[2] / 100; + let r; + let g; + let b; + r = x * 3.2406 + y * -1.5372 + z * -0.4986; + g = x * -0.9689 + y * 1.8758 + z * 0.0415; + b = x * 0.0557 + y * -0.204 + z * 1.057; + r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92; + g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92; + b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92; + r = Math.min(Math.max(0, r), 1); + g = Math.min(Math.max(0, g), 1); + b = Math.min(Math.max(0, b), 1); + return [r * 255, g * 255, b * 255]; + }; + convert.xyz.lab = function(xyz) { + let x = xyz[0]; + let y = xyz[1]; + let z = xyz[2]; + x /= 95.047; + y /= 100; + z /= 108.883; + x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116; + y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116; + z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116; + const l = 116 * y - 16; + const a = 500 * (x - y); + const b = 200 * (y - z); + return [l, a, b]; + }; + convert.lab.xyz = function(lab) { + const l = lab[0]; + const a = lab[1]; + const b = lab[2]; + let x; + let y; + let z; + y = (l + 16) / 116; + x = a / 500 + y; + z = y - b / 200; + const y2 = y ** 3; + const x2 = x ** 3; + const z2 = z ** 3; + y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787; + x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787; + z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787; + x *= 95.047; + y *= 100; + z *= 108.883; + return [x, y, z]; + }; + convert.lab.lch = function(lab) { + const l = lab[0]; + const a = lab[1]; + const b = lab[2]; + let h; + const hr = Math.atan2(b, a); + h = hr * 360 / 2 / Math.PI; + if (h < 0) { + h += 360; + } + const c = Math.sqrt(a * a + b * b); + return [l, c, h]; + }; + convert.lch.lab = function(lch) { + const l = lch[0]; + const c = lch[1]; + const h = lch[2]; + const hr = h / 360 * 2 * Math.PI; + const a = c * Math.cos(hr); + const b = c * Math.sin(hr); + return [l, a, b]; + }; + convert.rgb.ansi16 = function(args, saturation = null) { + const [r, g, b] = args; + let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation; + value = Math.round(value / 50); + if (value === 0) { + return 30; + } + let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255)); + if (value === 2) { + ansi += 60; + } + return ansi; + }; + convert.hsv.ansi16 = function(args) { + return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]); + }; + convert.rgb.ansi256 = function(args) { + const r = args[0]; + const g = args[1]; + const b = args[2]; + if (r === g && g === b) { + if (r < 8) { + return 16; + } + if (r > 248) { + return 231; + } + return Math.round((r - 8) / 247 * 24) + 232; + } + const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5); + return ansi; + }; + convert.ansi16.rgb = function(args) { + let color = args % 10; + if (color === 0 || color === 7) { + if (args > 50) { + color += 3.5; + } + color = color / 10.5 * 255; + return [color, color, color]; + } + const mult = (~~(args > 50) + 1) * 0.5; + const r = (color & 1) * mult * 255; + const g = (color >> 1 & 1) * mult * 255; + const b = (color >> 2 & 1) * mult * 255; + return [r, g, b]; + }; + convert.ansi256.rgb = function(args) { + if (args >= 232) { + const c = (args - 232) * 10 + 8; + return [c, c, c]; + } + args -= 16; + let rem; + const r = Math.floor(args / 36) / 5 * 255; + const g = Math.floor((rem = args % 36) / 6) / 5 * 255; + const b = rem % 6 / 5 * 255; + return [r, g, b]; + }; + convert.rgb.hex = function(args) { + const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255); + const string = integer.toString(16).toUpperCase(); + return "000000".substring(string.length) + string; + }; + convert.hex.rgb = function(args) { + const match2 = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i); + if (!match2) { + return [0, 0, 0]; + } + let colorString = match2[0]; + if (match2[0].length === 3) { + colorString = colorString.split("").map((char) => { + return char + char; + }).join(""); + } + const integer = parseInt(colorString, 16); + const r = integer >> 16 & 255; + const g = integer >> 8 & 255; + const b = integer & 255; + return [r, g, b]; + }; + convert.rgb.hcg = function(rgb) { + const r = rgb[0] / 255; + const g = rgb[1] / 255; + const b = rgb[2] / 255; + const max = Math.max(Math.max(r, g), b); + const min = Math.min(Math.min(r, g), b); + const chroma = max - min; + let grayscale; + let hue; + if (chroma < 1) { + grayscale = min / (1 - chroma); + } else { + grayscale = 0; + } + if (chroma <= 0) { + hue = 0; + } else if (max === r) { + hue = (g - b) / chroma % 6; + } else if (max === g) { + hue = 2 + (b - r) / chroma; + } else { + hue = 4 + (r - g) / chroma; + } + hue /= 6; + hue %= 1; + return [hue * 360, chroma * 100, grayscale * 100]; + }; + convert.hsl.hcg = function(hsl) { + const s = hsl[1] / 100; + const l = hsl[2] / 100; + const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l); + let f = 0; + if (c < 1) { + f = (l - 0.5 * c) / (1 - c); + } + return [hsl[0], c * 100, f * 100]; + }; + convert.hsv.hcg = function(hsv) { + const s = hsv[1] / 100; + const v = hsv[2] / 100; + const c = s * v; + let f = 0; + if (c < 1) { + f = (v - c) / (1 - c); + } + return [hsv[0], c * 100, f * 100]; + }; + convert.hcg.rgb = function(hcg) { + const h = hcg[0] / 360; + const c = hcg[1] / 100; + const g = hcg[2] / 100; + if (c === 0) { + return [g * 255, g * 255, g * 255]; + } + const pure = [0, 0, 0]; + const hi = h % 1 * 6; + const v = hi % 1; + const w = 1 - v; + let mg = 0; + switch (Math.floor(hi)) { + case 0: + pure[0] = 1; + pure[1] = v; + pure[2] = 0; + break; + case 1: + pure[0] = w; + pure[1] = 1; + pure[2] = 0; + break; + case 2: + pure[0] = 0; + pure[1] = 1; + pure[2] = v; + break; + case 3: + pure[0] = 0; + pure[1] = w; + pure[2] = 1; + break; + case 4: + pure[0] = v; + pure[1] = 0; + pure[2] = 1; + break; + default: + pure[0] = 1; + pure[1] = 0; + pure[2] = w; + } + mg = (1 - c) * g; + return [ + (c * pure[0] + mg) * 255, + (c * pure[1] + mg) * 255, + (c * pure[2] + mg) * 255 + ]; + }; + convert.hcg.hsv = function(hcg) { + const c = hcg[1] / 100; + const g = hcg[2] / 100; + const v = c + g * (1 - c); + let f = 0; + if (v > 0) { + f = c / v; + } + return [hcg[0], f * 100, v * 100]; + }; + convert.hcg.hsl = function(hcg) { + const c = hcg[1] / 100; + const g = hcg[2] / 100; + const l = g * (1 - c) + 0.5 * c; + let s = 0; + if (l > 0 && l < 0.5) { + s = c / (2 * l); + } else if (l >= 0.5 && l < 1) { + s = c / (2 * (1 - l)); + } + return [hcg[0], s * 100, l * 100]; + }; + convert.hcg.hwb = function(hcg) { + const c = hcg[1] / 100; + const g = hcg[2] / 100; + const v = c + g * (1 - c); + return [hcg[0], (v - c) * 100, (1 - v) * 100]; + }; + convert.hwb.hcg = function(hwb) { + const w = hwb[1] / 100; + const b = hwb[2] / 100; + const v = 1 - b; + const c = v - w; + let g = 0; + if (c < 1) { + g = (v - c) / (1 - c); + } + return [hwb[0], c * 100, g * 100]; + }; + convert.apple.rgb = function(apple) { + return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255]; + }; + convert.rgb.apple = function(rgb) { + return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535]; + }; + convert.gray.rgb = function(args) { + return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255]; + }; + convert.gray.hsl = function(args) { + return [0, 0, args[0]]; + }; + convert.gray.hsv = convert.gray.hsl; + convert.gray.hwb = function(gray) { + return [0, 100, gray[0]]; + }; + convert.gray.cmyk = function(gray) { + return [0, 0, 0, gray[0]]; + }; + convert.gray.lab = function(gray) { + return [gray[0], 0, 0]; + }; + convert.gray.hex = function(gray) { + const val = Math.round(gray[0] / 100 * 255) & 255; + const integer = (val << 16) + (val << 8) + val; + const string = integer.toString(16).toUpperCase(); + return "000000".substring(string.length) + string; + }; + convert.rgb.gray = function(rgb) { + const val = (rgb[0] + rgb[1] + rgb[2]) / 3; + return [val / 255 * 100]; + }; + return conversions; +} +var route; +var hasRequiredRoute; +function requireRoute() { + if (hasRequiredRoute) return route; + hasRequiredRoute = 1; + const conversions2 = requireConversions(); + function buildGraph() { + const graph = {}; + const models = Object.keys(conversions2); + for (let len = models.length, i = 0; i < len; i++) { + graph[models[i]] = { + // http://jsperf.com/1-vs-infinity + // micro-opt, but this is simple. + distance: -1, + parent: null + }; + } + return graph; + } + function deriveBFS(fromModel) { + const graph = buildGraph(); + const queue = [fromModel]; + graph[fromModel].distance = 0; + while (queue.length) { + const current = queue.pop(); + const adjacents = Object.keys(conversions2[current]); + for (let len = adjacents.length, i = 0; i < len; i++) { + const adjacent = adjacents[i]; + const node = graph[adjacent]; + if (node.distance === -1) { + node.distance = graph[current].distance + 1; + node.parent = current; + queue.unshift(adjacent); + } + } + } + return graph; + } + function link(from, to) { + return function(args) { + return to(from(args)); + }; + } + function wrapConversion(toModel, graph) { + const path2 = [graph[toModel].parent, toModel]; + let fn = conversions2[graph[toModel].parent][toModel]; + let cur = graph[toModel].parent; + while (graph[cur].parent) { + path2.unshift(graph[cur].parent); + fn = link(conversions2[graph[cur].parent][cur], fn); + cur = graph[cur].parent; + } + fn.conversion = path2; + return fn; + } + route = function(fromModel) { + const graph = deriveBFS(fromModel); + const conversion = {}; + const models = Object.keys(graph); + for (let len = models.length, i = 0; i < len; i++) { + const toModel = models[i]; + const node = graph[toModel]; + if (node.parent === null) { + continue; + } + conversion[toModel] = wrapConversion(toModel, graph); + } + return conversion; + }; + return route; +} +var colorConvert; +var hasRequiredColorConvert; +function requireColorConvert() { + if (hasRequiredColorConvert) return colorConvert; + hasRequiredColorConvert = 1; + const conversions2 = requireConversions(); + const route2 = requireRoute(); + const convert = {}; + const models = Object.keys(conversions2); + function wrapRaw(fn) { + const wrappedFn = function(...args) { + const arg0 = args[0]; + if (arg0 === void 0 || arg0 === null) { + return arg0; + } + if (arg0.length > 1) { + args = arg0; + } + return fn(args); + }; + if ("conversion" in fn) { + wrappedFn.conversion = fn.conversion; + } + return wrappedFn; + } + function wrapRounded(fn) { + const wrappedFn = function(...args) { + const arg0 = args[0]; + if (arg0 === void 0 || arg0 === null) { + return arg0; + } + if (arg0.length > 1) { + args = arg0; + } + const result = fn(args); + if (typeof result === "object") { + for (let len = result.length, i = 0; i < len; i++) { + result[i] = Math.round(result[i]); + } + } + return result; + }; + if ("conversion" in fn) { + wrappedFn.conversion = fn.conversion; + } + return wrappedFn; + } + models.forEach((fromModel) => { + convert[fromModel] = {}; + Object.defineProperty(convert[fromModel], "channels", { value: conversions2[fromModel].channels }); + Object.defineProperty(convert[fromModel], "labels", { value: conversions2[fromModel].labels }); + const routes = route2(fromModel); + const routeModels = Object.keys(routes); + routeModels.forEach((toModel) => { + const fn = routes[toModel]; + convert[fromModel][toModel] = wrapRounded(fn); + convert[fromModel][toModel].raw = wrapRaw(fn); + }); + }); + colorConvert = convert; + return colorConvert; +} +ansiStyles$1.exports; +(function(module) { + const wrapAnsi162 = (fn, offset) => (...args) => { + const code = fn(...args); + return `\x1B[${code + offset}m`; + }; + const wrapAnsi2562 = (fn, offset) => (...args) => { + const code = fn(...args); + return `\x1B[${38 + offset};5;${code}m`; + }; + const wrapAnsi16m2 = (fn, offset) => (...args) => { + const rgb = fn(...args); + return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`; + }; + const ansi2ansi = (n) => n; + const rgb2rgb = (r, g, b) => [r, g, b]; + const setLazyProperty = (object, property, get) => { + Object.defineProperty(object, property, { + get: () => { + const value = get(); + Object.defineProperty(object, property, { + value, + enumerable: true, + configurable: true + }); + return value; + }, + enumerable: true, + configurable: true + }); + }; + let colorConvert2; + const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => { + if (colorConvert2 === void 0) { + colorConvert2 = requireColorConvert(); + } + const offset = isBackground ? 10 : 0; + const styles2 = {}; + for (const [sourceSpace, suite] of Object.entries(colorConvert2)) { + const name2 = sourceSpace === "ansi16" ? "ansi" : sourceSpace; + if (sourceSpace === targetSpace) { + styles2[name2] = wrap(identity, offset); + } else if (typeof suite === "object") { + styles2[name2] = wrap(suite[targetSpace], offset); + } + } + return styles2; + }; + function assembleStyles2() { + const codes = /* @__PURE__ */ new Map(); + const styles2 = { + modifier: { + reset: [0, 0], + // 21 isn't widely supported and 22 does the same thing + bold: [1, 22], + dim: [2, 22], + italic: [3, 23], + underline: [4, 24], + inverse: [7, 27], + hidden: [8, 28], + strikethrough: [9, 29] + }, + color: { + black: [30, 39], + red: [31, 39], + green: [32, 39], + yellow: [33, 39], + blue: [34, 39], + magenta: [35, 39], + cyan: [36, 39], + white: [37, 39], + // Bright color + blackBright: [90, 39], + redBright: [91, 39], + greenBright: [92, 39], + yellowBright: [93, 39], + blueBright: [94, 39], + magentaBright: [95, 39], + cyanBright: [96, 39], + whiteBright: [97, 39] + }, + bgColor: { + bgBlack: [40, 49], + bgRed: [41, 49], + bgGreen: [42, 49], + bgYellow: [43, 49], + bgBlue: [44, 49], + bgMagenta: [45, 49], + bgCyan: [46, 49], + bgWhite: [47, 49], + // Bright color + bgBlackBright: [100, 49], + bgRedBright: [101, 49], + bgGreenBright: [102, 49], + bgYellowBright: [103, 49], + bgBlueBright: [104, 49], + bgMagentaBright: [105, 49], + bgCyanBright: [106, 49], + bgWhiteBright: [107, 49] + } + }; + styles2.color.gray = styles2.color.blackBright; + styles2.bgColor.bgGray = styles2.bgColor.bgBlackBright; + styles2.color.grey = styles2.color.blackBright; + styles2.bgColor.bgGrey = styles2.bgColor.bgBlackBright; + for (const [groupName, group] of Object.entries(styles2)) { + for (const [styleName, style] of Object.entries(group)) { + styles2[styleName] = { + open: `\x1B[${style[0]}m`, + close: `\x1B[${style[1]}m` + }; + group[styleName] = styles2[styleName]; + codes.set(style[0], style[1]); + } + Object.defineProperty(styles2, groupName, { + value: group, + enumerable: false + }); + } + Object.defineProperty(styles2, "codes", { + value: codes, + enumerable: false + }); + styles2.color.close = "\x1B[39m"; + styles2.bgColor.close = "\x1B[49m"; + setLazyProperty(styles2.color, "ansi", () => makeDynamicStyles(wrapAnsi162, "ansi16", ansi2ansi, false)); + setLazyProperty(styles2.color, "ansi256", () => makeDynamicStyles(wrapAnsi2562, "ansi256", ansi2ansi, false)); + setLazyProperty(styles2.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m2, "rgb", rgb2rgb, false)); + setLazyProperty(styles2.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi162, "ansi16", ansi2ansi, true)); + setLazyProperty(styles2.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi2562, "ansi256", ansi2ansi, true)); + setLazyProperty(styles2.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m2, "rgb", rgb2rgb, true)); + return styles2; + } + Object.defineProperty(module, "exports", { + enumerable: true, + get: assembleStyles2 + }); +})(ansiStyles$1); +var ansiStylesExports = ansiStyles$1.exports; +const isFullwidthCodePoint = isFullwidthCodePointExports; +const astralRegex = astralRegex_1; +const ansiStyles = ansiStylesExports; +const ESCAPES = [ + "\x1B", + "›" +]; +const wrapAnsi = (code) => `${ESCAPES[0]}[${code}m`; +const checkAnsi = (ansiCodes, isEscapes, endAnsiCode) => { + let output = []; + ansiCodes = [...ansiCodes]; + for (let ansiCode of ansiCodes) { + const ansiCodeOrigin = ansiCode; + if (ansiCode.includes(";")) { + ansiCode = ansiCode.split(";")[0][0] + "0"; + } + const item = ansiStyles.codes.get(Number.parseInt(ansiCode, 10)); + if (item) { + const indexEscape = ansiCodes.indexOf(item.toString()); + if (indexEscape === -1) { + output.push(wrapAnsi(isEscapes ? item : ansiCodeOrigin)); + } else { + ansiCodes.splice(indexEscape, 1); + } + } else if (isEscapes) { + output.push(wrapAnsi(0)); + break; + } else { + output.push(wrapAnsi(ansiCodeOrigin)); + } + } + if (isEscapes) { + output = output.filter((element, index) => output.indexOf(element) === index); + if (endAnsiCode !== void 0) { + const fistEscapeCode = wrapAnsi(ansiStyles.codes.get(Number.parseInt(endAnsiCode, 10))); + output = output.reduce((current, next) => next === fistEscapeCode ? [next, ...current] : [...current, next], []); + } + } + return output.join(""); +}; +var sliceAnsi = (string, begin, end) => { + const characters = [...string]; + const ansiCodes = []; + let stringEnd = typeof end === "number" ? end : characters.length; + let isInsideEscape = false; + let ansiCode; + let visible = 0; + let output = ""; + for (const [index, character] of characters.entries()) { + let leftEscape = false; + if (ESCAPES.includes(character)) { + const code = /\d[^m]*/.exec(string.slice(index, index + 18)); + ansiCode = code && code.length > 0 ? code[0] : void 0; + if (visible < stringEnd) { + isInsideEscape = true; + if (ansiCode !== void 0) { + ansiCodes.push(ansiCode); + } + } + } else if (isInsideEscape && character === "m") { + isInsideEscape = false; + leftEscape = true; + } + if (!isInsideEscape && !leftEscape) { + visible++; + } + if (!astralRegex({ exact: true }).test(character) && isFullwidthCodePoint(character.codePointAt())) { + visible++; + if (typeof end !== "number") { + stringEnd++; + } + } + if (visible > begin && visible <= stringEnd) { + output += character; + } else if (visible === begin && !isInsideEscape && ansiCode !== void 0) { + output = checkAnsi(ansiCodes); + } else if (visible >= stringEnd) { + output += checkAnsi(ansiCodes, true, ansiCode); + break; + } + } + return output; +}; +var getBorderCharacters$1 = {}; +Object.defineProperty(getBorderCharacters$1, "__esModule", { value: true }); +getBorderCharacters$1.getBorderCharacters = void 0; +const getBorderCharacters = (name2) => { + if (name2 === "honeywell") { + return { + topBody: "═", + topJoin: "╤", + topLeft: "╔", + topRight: "╗", + bottomBody: "═", + bottomJoin: "╧", + bottomLeft: "╚", + bottomRight: "╝", + bodyLeft: "║", + bodyRight: "║", + bodyJoin: "│", + headerJoin: "┬", + joinBody: "─", + joinLeft: "╟", + joinRight: "╢", + joinJoin: "┼", + joinMiddleDown: "┬", + joinMiddleUp: "┴", + joinMiddleLeft: "┤", + joinMiddleRight: "├" + }; + } + if (name2 === "norc") { + return { + topBody: "─", + topJoin: "┬", + topLeft: "┌", + topRight: "┐", + bottomBody: "─", + bottomJoin: "┴", + bottomLeft: "└", + bottomRight: "┘", + bodyLeft: "│", + bodyRight: "│", + bodyJoin: "│", + headerJoin: "┬", + joinBody: "─", + joinLeft: "├", + joinRight: "┤", + joinJoin: "┼", + joinMiddleDown: "┬", + joinMiddleUp: "┴", + joinMiddleLeft: "┤", + joinMiddleRight: "├" + }; + } + if (name2 === "ramac") { + return { + topBody: "-", + topJoin: "+", + topLeft: "+", + topRight: "+", + bottomBody: "-", + bottomJoin: "+", + bottomLeft: "+", + bottomRight: "+", + bodyLeft: "|", + bodyRight: "|", + bodyJoin: "|", + headerJoin: "+", + joinBody: "-", + joinLeft: "|", + joinRight: "|", + joinJoin: "|", + joinMiddleDown: "+", + joinMiddleUp: "+", + joinMiddleLeft: "+", + joinMiddleRight: "+" + }; + } + if (name2 === "void") { + return { + topBody: "", + topJoin: "", + topLeft: "", + topRight: "", + bottomBody: "", + bottomJoin: "", + bottomLeft: "", + bottomRight: "", + bodyLeft: "", + bodyRight: "", + bodyJoin: "", + headerJoin: "", + joinBody: "", + joinLeft: "", + joinRight: "", + joinJoin: "", + joinMiddleDown: "", + joinMiddleUp: "", + joinMiddleLeft: "", + joinMiddleRight: "" + }; + } + throw new Error('Unknown border template "' + name2 + '".'); +}; +getBorderCharacters$1.getBorderCharacters = getBorderCharacters; +var __importDefault$5 = commonjsGlobal && commonjsGlobal.__importDefault || function(mod) { + return mod && mod.__esModule ? mod : { "default": mod }; +}; +Object.defineProperty(utils, "__esModule", { value: true }); +utils.isCellInRange = utils.areCellEqual = utils.calculateRangeCoordinate = utils.flatten = utils.extractTruncates = utils.sumArray = utils.sequence = utils.distributeUnevenly = utils.countSpaceSequence = utils.groupBySizes = utils.makeBorderConfig = utils.splitAnsi = utils.normalizeString = void 0; +const slice_ansi_1$2 = __importDefault$5(sliceAnsi); +const string_width_1$3 = __importDefault$5(stringWidthExports); +const strip_ansi_1$1 = __importDefault$5(stripAnsi$1); +const getBorderCharacters_1 = getBorderCharacters$1; +const normalizeString = (input) => { + return input.replace(/\r\n/g, "\n"); +}; +utils.normalizeString = normalizeString; +const splitAnsi = (input) => { + const lengths = (0, strip_ansi_1$1.default)(input).split("\n").map(string_width_1$3.default); + const result = []; + let startIndex = 0; + lengths.forEach((length) => { + result.push(length === 0 ? "" : (0, slice_ansi_1$2.default)(input, startIndex, startIndex + length)); + startIndex += length + 1; + }); + return result; +}; +utils.splitAnsi = splitAnsi; +const makeBorderConfig = (border) => { + return { + ...(0, getBorderCharacters_1.getBorderCharacters)("honeywell"), + ...border + }; +}; +utils.makeBorderConfig = makeBorderConfig; +const groupBySizes = (array, sizes) => { + let startIndex = 0; + return sizes.map((size) => { + const group = array.slice(startIndex, startIndex + size); + startIndex += size; + return group; + }); +}; +utils.groupBySizes = groupBySizes; +const countSpaceSequence = (input) => { + var _a2, _b2; + return (_b2 = (_a2 = input.match(/\s+/g)) === null || _a2 === void 0 ? void 0 : _a2.length) !== null && _b2 !== void 0 ? _b2 : 0; +}; +utils.countSpaceSequence = countSpaceSequence; +const distributeUnevenly = (sum, length) => { + const result = Array.from({ length }).fill(Math.floor(sum / length)); + return result.map((element, index) => { + return element + (index < sum % length ? 1 : 0); + }); +}; +utils.distributeUnevenly = distributeUnevenly; +const sequence = (start, end) => { + return Array.from({ length: end - start + 1 }, (_, index) => { + return index + start; + }); +}; +utils.sequence = sequence; +const sumArray = (array) => { + return array.reduce((accumulator, element) => { + return accumulator + element; + }, 0); +}; +utils.sumArray = sumArray; +const extractTruncates = (config2) => { + return config2.columns.map(({ truncate }) => { + return truncate; + }); +}; +utils.extractTruncates = extractTruncates; +const flatten = (array) => { + return [].concat(...array); +}; +utils.flatten = flatten; +const calculateRangeCoordinate = (spanningCellConfig) => { + const { row, col, colSpan = 1, rowSpan = 1 } = spanningCellConfig; + return { + bottomRight: { + col: col + colSpan - 1, + row: row + rowSpan - 1 + }, + topLeft: { + col, + row + } + }; +}; +utils.calculateRangeCoordinate = calculateRangeCoordinate; +const areCellEqual = (cell1, cell2) => { + return cell1.row === cell2.row && cell1.col === cell2.col; +}; +utils.areCellEqual = areCellEqual; +const isCellInRange = (cell, { topLeft, bottomRight }) => { + return topLeft.row <= cell.row && cell.row <= bottomRight.row && topLeft.col <= cell.col && cell.col <= bottomRight.col; +}; +utils.isCellInRange = isCellInRange; +var __importDefault$4 = commonjsGlobal && commonjsGlobal.__importDefault || function(mod) { + return mod && mod.__esModule ? mod : { "default": mod }; +}; +Object.defineProperty(alignString$1, "__esModule", { value: true }); +alignString$1.alignString = void 0; +const string_width_1$2 = __importDefault$4(stringWidthExports); +const utils_1$e = utils; +const alignLeft = (subject, width) => { + return subject + " ".repeat(width); +}; +const alignRight = (subject, width) => { + return " ".repeat(width) + subject; +}; +const alignCenter = (subject, width) => { + return " ".repeat(Math.floor(width / 2)) + subject + " ".repeat(Math.ceil(width / 2)); +}; +const alignJustify = (subject, width) => { + const spaceSequenceCount = (0, utils_1$e.countSpaceSequence)(subject); + if (spaceSequenceCount === 0) { + return alignLeft(subject, width); + } + const addingSpaces = (0, utils_1$e.distributeUnevenly)(width, spaceSequenceCount); + if (Math.max(...addingSpaces) > 3) { + return alignLeft(subject, width); + } + let spaceSequenceIndex = 0; + return subject.replace(/\s+/g, (groupSpace) => { + return groupSpace + " ".repeat(addingSpaces[spaceSequenceIndex++]); + }); +}; +const alignString = (subject, containerWidth, alignment) => { + const subjectWidth = (0, string_width_1$2.default)(subject); + if (subjectWidth === containerWidth) { + return subject; + } + if (subjectWidth > containerWidth) { + throw new Error("Subject parameter value width cannot be greater than the container width."); + } + if (subjectWidth === 0) { + return " ".repeat(containerWidth); + } + const availableWidth = containerWidth - subjectWidth; + if (alignment === "left") { + return alignLeft(subject, availableWidth); + } + if (alignment === "right") { + return alignRight(subject, availableWidth); + } + if (alignment === "justify") { + return alignJustify(subject, availableWidth); + } + return alignCenter(subject, availableWidth); +}; +alignString$1.alignString = alignString; +Object.defineProperty(alignTableData$1, "__esModule", { value: true }); +alignTableData$1.alignTableData = void 0; +const alignString_1$1 = alignString$1; +const alignTableData = (rows, config2) => { + return rows.map((row, rowIndex) => { + return row.map((cell, cellIndex) => { + var _a2; + const { width, alignment } = config2.columns[cellIndex]; + const containingRange = (_a2 = config2.spanningCellManager) === null || _a2 === void 0 ? void 0 : _a2.getContainingRange({ + col: cellIndex, + row: rowIndex + }, { mapped: true }); + if (containingRange) { + return cell; + } + return (0, alignString_1$1.alignString)(cell, width, alignment); + }); + }); +}; +alignTableData$1.alignTableData = alignTableData; +var calculateRowHeights$1 = {}; +var calculateCellHeight$1 = {}; +var wrapCell$1 = {}; +var wrapString$1 = {}; +var __importDefault$3 = commonjsGlobal && commonjsGlobal.__importDefault || function(mod) { + return mod && mod.__esModule ? mod : { "default": mod }; +}; +Object.defineProperty(wrapString$1, "__esModule", { value: true }); +wrapString$1.wrapString = void 0; +const slice_ansi_1$1 = __importDefault$3(sliceAnsi); +const string_width_1$1 = __importDefault$3(stringWidthExports); +const wrapString = (subject, size) => { + let subjectSlice = subject; + const chunks = []; + do { + chunks.push((0, slice_ansi_1$1.default)(subjectSlice, 0, size)); + subjectSlice = (0, slice_ansi_1$1.default)(subjectSlice, size).trim(); + } while ((0, string_width_1$1.default)(subjectSlice)); + return chunks; +}; +wrapString$1.wrapString = wrapString; +var wrapWord$1 = {}; +var __importDefault$2 = commonjsGlobal && commonjsGlobal.__importDefault || function(mod) { + return mod && mod.__esModule ? mod : { "default": mod }; +}; +Object.defineProperty(wrapWord$1, "__esModule", { value: true }); +wrapWord$1.wrapWord = void 0; +const slice_ansi_1 = __importDefault$2(sliceAnsi); +const strip_ansi_1 = __importDefault$2(stripAnsi$1); +const calculateStringLengths = (input, size) => { + let subject = (0, strip_ansi_1.default)(input); + const chunks = []; + const re2 = new RegExp("(^.{1," + String(Math.max(size, 1)) + "}(\\s+|$))|(^.{1," + String(Math.max(size - 1, 1)) + "}(\\\\|/|_|\\.|,|;|-))"); + do { + let chunk; + const match2 = re2.exec(subject); + if (match2) { + chunk = match2[0]; + subject = subject.slice(chunk.length); + const trimmedLength = chunk.trim().length; + const offset = chunk.length - trimmedLength; + chunks.push([trimmedLength, offset]); + } else { + chunk = subject.slice(0, size); + subject = subject.slice(size); + chunks.push([chunk.length, 0]); + } + } while (subject.length); + return chunks; +}; +const wrapWord = (input, size) => { + const result = []; + let startIndex = 0; + calculateStringLengths(input, size).forEach(([length, offset]) => { + result.push((0, slice_ansi_1.default)(input, startIndex, startIndex + length)); + startIndex += length + offset; + }); + return result; +}; +wrapWord$1.wrapWord = wrapWord; +Object.defineProperty(wrapCell$1, "__esModule", { value: true }); +wrapCell$1.wrapCell = void 0; +const utils_1$d = utils; +const wrapString_1 = wrapString$1; +const wrapWord_1 = wrapWord$1; +const wrapCell = (cellValue, cellWidth, useWrapWord) => { + const cellLines = (0, utils_1$d.splitAnsi)(cellValue); + for (let lineNr = 0; lineNr < cellLines.length; ) { + let lineChunks; + if (useWrapWord) { + lineChunks = (0, wrapWord_1.wrapWord)(cellLines[lineNr], cellWidth); + } else { + lineChunks = (0, wrapString_1.wrapString)(cellLines[lineNr], cellWidth); + } + cellLines.splice(lineNr, 1, ...lineChunks); + lineNr += lineChunks.length; + } + return cellLines; +}; +wrapCell$1.wrapCell = wrapCell; +Object.defineProperty(calculateCellHeight$1, "__esModule", { value: true }); +calculateCellHeight$1.calculateCellHeight = void 0; +const wrapCell_1$1 = wrapCell$1; +const calculateCellHeight = (value, columnWidth, useWrapWord = false) => { + return (0, wrapCell_1$1.wrapCell)(value, columnWidth, useWrapWord).length; +}; +calculateCellHeight$1.calculateCellHeight = calculateCellHeight; +Object.defineProperty(calculateRowHeights$1, "__esModule", { value: true }); +calculateRowHeights$1.calculateRowHeights = void 0; +const calculateCellHeight_1 = calculateCellHeight$1; +const utils_1$c = utils; +const calculateRowHeights = (rows, config2) => { + const rowHeights = []; + for (const [rowIndex, row] of rows.entries()) { + let rowHeight = 1; + row.forEach((cell, cellIndex) => { + var _a2; + const containingRange = (_a2 = config2.spanningCellManager) === null || _a2 === void 0 ? void 0 : _a2.getContainingRange({ + col: cellIndex, + row: rowIndex + }); + if (!containingRange) { + const cellHeight = (0, calculateCellHeight_1.calculateCellHeight)(cell, config2.columns[cellIndex].width, config2.columns[cellIndex].wrapWord); + rowHeight = Math.max(rowHeight, cellHeight); + return; + } + const { topLeft, bottomRight, height } = containingRange; + if (rowIndex === bottomRight.row) { + const totalOccupiedSpanningCellHeight = (0, utils_1$c.sumArray)(rowHeights.slice(topLeft.row)); + const totalHorizontalBorderHeight = bottomRight.row - topLeft.row; + const totalHiddenHorizontalBorderHeight = (0, utils_1$c.sequence)(topLeft.row + 1, bottomRight.row).filter((horizontalBorderIndex) => { + var _a3; + return !((_a3 = config2.drawHorizontalLine) === null || _a3 === void 0 ? void 0 : _a3.call(config2, horizontalBorderIndex, rows.length)); + }).length; + const cellHeight = height - totalOccupiedSpanningCellHeight - totalHorizontalBorderHeight + totalHiddenHorizontalBorderHeight; + rowHeight = Math.max(rowHeight, cellHeight); + } + }); + rowHeights.push(rowHeight); + } + return rowHeights; +}; +calculateRowHeights$1.calculateRowHeights = calculateRowHeights; +var drawBorder = {}; +var drawContent$1 = {}; +Object.defineProperty(drawContent$1, "__esModule", { value: true }); +drawContent$1.drawContent = void 0; +const drawContent = (parameters) => { + const { contents, separatorGetter, drawSeparator, spanningCellManager: spanningCellManager2, rowIndex, elementType } = parameters; + const contentSize = contents.length; + const result = []; + if (drawSeparator(0, contentSize)) { + result.push(separatorGetter(0, contentSize)); + } + contents.forEach((content, contentIndex) => { + if (!elementType || elementType === "border" || elementType === "row") { + result.push(content); + } + if (elementType === "cell" && rowIndex === void 0) { + result.push(content); + } + if (elementType === "cell" && rowIndex !== void 0) { + const containingRange = spanningCellManager2 === null || spanningCellManager2 === void 0 ? void 0 : spanningCellManager2.getContainingRange({ + col: contentIndex, + row: rowIndex + }); + if (!containingRange || contentIndex === containingRange.topLeft.col) { + result.push(content); + } + } + if (contentIndex + 1 < contentSize && drawSeparator(contentIndex + 1, contentSize)) { + const separator = separatorGetter(contentIndex + 1, contentSize); + if (elementType === "cell" && rowIndex !== void 0) { + const currentCell = { + col: contentIndex + 1, + row: rowIndex + }; + const containingRange = spanningCellManager2 === null || spanningCellManager2 === void 0 ? void 0 : spanningCellManager2.getContainingRange(currentCell); + if (!containingRange || containingRange.topLeft.col === currentCell.col) { + result.push(separator); + } + } else { + result.push(separator); + } + } + }); + if (drawSeparator(contentSize, contentSize)) { + result.push(separatorGetter(contentSize, contentSize)); + } + return result.join(""); +}; +drawContent$1.drawContent = drawContent; +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.createTableBorderGetter = exports2.drawBorderBottom = exports2.drawBorderJoin = exports2.drawBorderTop = exports2.drawBorder = exports2.createSeparatorGetter = exports2.drawBorderSegments = void 0; + const drawContent_12 = drawContent$1; + const drawBorderSegments = (columnWidths, parameters) => { + const { separator, horizontalBorderIndex, spanningCellManager: spanningCellManager2 } = parameters; + return columnWidths.map((columnWidth, columnIndex) => { + const normalSegment = separator.body.repeat(columnWidth); + if (horizontalBorderIndex === void 0) { + return normalSegment; + } + const range = spanningCellManager2 === null || spanningCellManager2 === void 0 ? void 0 : spanningCellManager2.getContainingRange({ + col: columnIndex, + row: horizontalBorderIndex + }); + if (!range) { + return normalSegment; + } + const { topLeft } = range; + if (horizontalBorderIndex === topLeft.row) { + return normalSegment; + } + if (columnIndex !== topLeft.col) { + return ""; + } + return range.extractBorderContent(horizontalBorderIndex); + }); + }; + exports2.drawBorderSegments = drawBorderSegments; + const createSeparatorGetter = (dependencies) => { + const { separator, spanningCellManager: spanningCellManager2, horizontalBorderIndex, rowCount } = dependencies; + return (verticalBorderIndex, columnCount) => { + const inSameRange2 = spanningCellManager2 === null || spanningCellManager2 === void 0 ? void 0 : spanningCellManager2.inSameRange; + if (horizontalBorderIndex !== void 0 && inSameRange2) { + const topCell = { + col: verticalBorderIndex, + row: horizontalBorderIndex - 1 + }; + const leftCell = { + col: verticalBorderIndex - 1, + row: horizontalBorderIndex + }; + const oppositeCell = { + col: verticalBorderIndex - 1, + row: horizontalBorderIndex - 1 + }; + const currentCell = { + col: verticalBorderIndex, + row: horizontalBorderIndex + }; + const pairs = [ + [oppositeCell, topCell], + [topCell, currentCell], + [currentCell, leftCell], + [leftCell, oppositeCell] + ]; + if (verticalBorderIndex === 0) { + if (inSameRange2(currentCell, topCell) && separator.bodyJoinOuter) { + return separator.bodyJoinOuter; + } + return separator.left; + } + if (verticalBorderIndex === columnCount) { + if (inSameRange2(oppositeCell, leftCell) && separator.bodyJoinOuter) { + return separator.bodyJoinOuter; + } + return separator.right; + } + if (horizontalBorderIndex === 0) { + if (inSameRange2(currentCell, leftCell)) { + return separator.body; + } + return separator.join; + } + if (horizontalBorderIndex === rowCount) { + if (inSameRange2(topCell, oppositeCell)) { + return separator.body; + } + return separator.join; + } + const sameRangeCount = pairs.map((pair) => { + return inSameRange2(...pair); + }).filter(Boolean).length; + if (sameRangeCount === 0) { + return separator.join; + } + if (sameRangeCount === 4) { + return ""; + } + if (sameRangeCount === 2) { + if (inSameRange2(...pairs[1]) && inSameRange2(...pairs[3]) && separator.bodyJoinInner) { + return separator.bodyJoinInner; + } + return separator.body; + } + if (sameRangeCount === 1) { + if (!separator.joinRight || !separator.joinLeft || !separator.joinUp || !separator.joinDown) { + throw new Error(`Can not get border separator for position [${horizontalBorderIndex}, ${verticalBorderIndex}]`); + } + if (inSameRange2(...pairs[0])) { + return separator.joinDown; + } + if (inSameRange2(...pairs[1])) { + return separator.joinLeft; + } + if (inSameRange2(...pairs[2])) { + return separator.joinUp; + } + return separator.joinRight; + } + throw new Error("Invalid case"); + } + if (verticalBorderIndex === 0) { + return separator.left; + } + if (verticalBorderIndex === columnCount) { + return separator.right; + } + return separator.join; + }; + }; + exports2.createSeparatorGetter = createSeparatorGetter; + const drawBorder2 = (columnWidths, parameters) => { + const borderSegments = (0, exports2.drawBorderSegments)(columnWidths, parameters); + const { drawVerticalLine, horizontalBorderIndex, spanningCellManager: spanningCellManager2 } = parameters; + return (0, drawContent_12.drawContent)({ + contents: borderSegments, + drawSeparator: drawVerticalLine, + elementType: "border", + rowIndex: horizontalBorderIndex, + separatorGetter: (0, exports2.createSeparatorGetter)(parameters), + spanningCellManager: spanningCellManager2 + }) + "\n"; + }; + exports2.drawBorder = drawBorder2; + const drawBorderTop = (columnWidths, parameters) => { + const { border } = parameters; + const result = (0, exports2.drawBorder)(columnWidths, { + ...parameters, + separator: { + body: border.topBody, + join: border.topJoin, + left: border.topLeft, + right: border.topRight + } + }); + if (result === "\n") { + return ""; + } + return result; + }; + exports2.drawBorderTop = drawBorderTop; + const drawBorderJoin = (columnWidths, parameters) => { + const { border } = parameters; + return (0, exports2.drawBorder)(columnWidths, { + ...parameters, + separator: { + body: border.joinBody, + bodyJoinInner: border.bodyJoin, + bodyJoinOuter: border.bodyLeft, + join: border.joinJoin, + joinDown: border.joinMiddleDown, + joinLeft: border.joinMiddleLeft, + joinRight: border.joinMiddleRight, + joinUp: border.joinMiddleUp, + left: border.joinLeft, + right: border.joinRight + } + }); + }; + exports2.drawBorderJoin = drawBorderJoin; + const drawBorderBottom = (columnWidths, parameters) => { + const { border } = parameters; + return (0, exports2.drawBorder)(columnWidths, { + ...parameters, + separator: { + body: border.bottomBody, + join: border.bottomJoin, + left: border.bottomLeft, + right: border.bottomRight + } + }); + }; + exports2.drawBorderBottom = drawBorderBottom; + const createTableBorderGetter = (columnWidths, parameters) => { + return (index, size) => { + const drawBorderParameters = { + ...parameters, + horizontalBorderIndex: index + }; + if (index === 0) { + return (0, exports2.drawBorderTop)(columnWidths, drawBorderParameters); + } else if (index === size) { + return (0, exports2.drawBorderBottom)(columnWidths, drawBorderParameters); + } + return (0, exports2.drawBorderJoin)(columnWidths, drawBorderParameters); + }; + }; + exports2.createTableBorderGetter = createTableBorderGetter; +})(drawBorder); +var drawRow$1 = {}; +Object.defineProperty(drawRow$1, "__esModule", { value: true }); +drawRow$1.drawRow = void 0; +const drawContent_1$1 = drawContent$1; +const drawRow = (row, config2) => { + const { border, drawVerticalLine, rowIndex, spanningCellManager: spanningCellManager2 } = config2; + return (0, drawContent_1$1.drawContent)({ + contents: row, + drawSeparator: drawVerticalLine, + elementType: "cell", + rowIndex, + separatorGetter: (index, columnCount) => { + if (index === 0) { + return border.bodyLeft; + } + if (index === columnCount) { + return border.bodyRight; + } + return border.bodyJoin; + }, + spanningCellManager: spanningCellManager2 + }) + "\n"; +}; +drawRow$1.drawRow = drawRow; +var makeStreamConfig$1 = {}; +var validateConfig$1 = {}; +var validators = {}; +var equal$1 = {}; +var fastDeepEqual = function equal(a, b) { + if (a === b) return true; + if (a && b && typeof a == "object" && typeof b == "object") { + if (a.constructor !== b.constructor) return false; + var length, i, keys; + if (Array.isArray(a)) { + length = a.length; + if (length != b.length) return false; + for (i = length; i-- !== 0; ) + if (!equal(a[i], b[i])) return false; + return true; + } + if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags; + if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf(); + if (a.toString !== Object.prototype.toString) return a.toString() === b.toString(); + keys = Object.keys(a); + length = keys.length; + if (length !== Object.keys(b).length) return false; + for (i = length; i-- !== 0; ) + if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false; + for (i = length; i-- !== 0; ) { + var key = keys[i]; + if (!equal(a[key], b[key])) return false; + } + return true; + } + return a !== a && b !== b; +}; +Object.defineProperty(equal$1, "__esModule", { value: true }); +const equal2 = fastDeepEqual; +equal2.code = 'require("ajv/dist/runtime/equal").default'; +equal$1.default = equal2; +(function(exports2) { + exports2["config.json"] = validate43; + const schema13 = { + "$id": "config.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "border": { + "$ref": "shared.json#/definitions/borders" + }, + "header": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "alignment": { + "$ref": "shared.json#/definitions/alignment" + }, + "wrapWord": { + "type": "boolean" + }, + "truncate": { + "type": "integer" + }, + "paddingLeft": { + "type": "integer" + }, + "paddingRight": { + "type": "integer" + } + }, + "required": ["content"], + "additionalProperties": false + }, + "columns": { + "$ref": "shared.json#/definitions/columns" + }, + "columnDefault": { + "$ref": "shared.json#/definitions/column" + }, + "drawVerticalLine": { + "typeof": "function" + }, + "drawHorizontalLine": { + "typeof": "function" + }, + "singleLine": { + "typeof": "boolean" + }, + "spanningCells": { + "type": "array", + "items": { + "type": "object", + "properties": { + "col": { + "type": "integer", + "minimum": 0 + }, + "row": { + "type": "integer", + "minimum": 0 + }, + "colSpan": { + "type": "integer", + "minimum": 1 + }, + "rowSpan": { + "type": "integer", + "minimum": 1 + }, + "alignment": { + "$ref": "shared.json#/definitions/alignment" + }, + "verticalAlignment": { + "$ref": "shared.json#/definitions/verticalAlignment" + }, + "wrapWord": { + "type": "boolean" + }, + "truncate": { + "type": "integer" + }, + "paddingLeft": { + "type": "integer" + }, + "paddingRight": { + "type": "integer" + } + }, + "required": ["row", "col"], + "additionalProperties": false + } + } + }, + "additionalProperties": false + }; + const schema15 = { + "type": "object", + "properties": { + "topBody": { + "$ref": "#/definitions/border" + }, + "topJoin": { + "$ref": "#/definitions/border" + }, + "topLeft": { + "$ref": "#/definitions/border" + }, + "topRight": { + "$ref": "#/definitions/border" + }, + "bottomBody": { + "$ref": "#/definitions/border" + }, + "bottomJoin": { + "$ref": "#/definitions/border" + }, + "bottomLeft": { + "$ref": "#/definitions/border" + }, + "bottomRight": { + "$ref": "#/definitions/border" + }, + "bodyLeft": { + "$ref": "#/definitions/border" + }, + "bodyRight": { + "$ref": "#/definitions/border" + }, + "bodyJoin": { + "$ref": "#/definitions/border" + }, + "headerJoin": { + "$ref": "#/definitions/border" + }, + "joinBody": { + "$ref": "#/definitions/border" + }, + "joinLeft": { + "$ref": "#/definitions/border" + }, + "joinRight": { + "$ref": "#/definitions/border" + }, + "joinJoin": { + "$ref": "#/definitions/border" + }, + "joinMiddleUp": { + "$ref": "#/definitions/border" + }, + "joinMiddleDown": { + "$ref": "#/definitions/border" + }, + "joinMiddleLeft": { + "$ref": "#/definitions/border" + }, + "joinMiddleRight": { + "$ref": "#/definitions/border" + } + }, + "additionalProperties": false + }; + const func8 = Object.prototype.hasOwnProperty; + function validate46(data2, { instancePath = "", parentData, parentDataProperty, rootData = data2 } = {}) { + let vErrors = null; + let errors = 0; + if (typeof data2 !== "string") { + const err0 = { + instancePath, + schemaPath: "#/type", + keyword: "type", + params: { + type: "string" + }, + message: "must be string" + }; + if (vErrors === null) { + vErrors = [err0]; + } else { + vErrors.push(err0); + } + errors++; + } + validate46.errors = vErrors; + return errors === 0; + } + function validate45(data2, { instancePath = "", parentData, parentDataProperty, rootData = data2 } = {}) { + let vErrors = null; + let errors = 0; + if (data2 && typeof data2 == "object" && !Array.isArray(data2)) { + for (const key0 in data2) { + if (!func8.call(schema15.properties, key0)) { + const err0 = { + instancePath, + schemaPath: "#/additionalProperties", + keyword: "additionalProperties", + params: { + additionalProperty: key0 + }, + message: "must NOT have additional properties" + }; + if (vErrors === null) { + vErrors = [err0]; + } else { + vErrors.push(err0); + } + errors++; + } + } + if (data2.topBody !== void 0) { + if (!validate46(data2.topBody, { + instancePath: instancePath + "/topBody", + parentData: data2, + parentDataProperty: "topBody", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.topJoin !== void 0) { + if (!validate46(data2.topJoin, { + instancePath: instancePath + "/topJoin", + parentData: data2, + parentDataProperty: "topJoin", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.topLeft !== void 0) { + if (!validate46(data2.topLeft, { + instancePath: instancePath + "/topLeft", + parentData: data2, + parentDataProperty: "topLeft", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.topRight !== void 0) { + if (!validate46(data2.topRight, { + instancePath: instancePath + "/topRight", + parentData: data2, + parentDataProperty: "topRight", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.bottomBody !== void 0) { + if (!validate46(data2.bottomBody, { + instancePath: instancePath + "/bottomBody", + parentData: data2, + parentDataProperty: "bottomBody", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.bottomJoin !== void 0) { + if (!validate46(data2.bottomJoin, { + instancePath: instancePath + "/bottomJoin", + parentData: data2, + parentDataProperty: "bottomJoin", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.bottomLeft !== void 0) { + if (!validate46(data2.bottomLeft, { + instancePath: instancePath + "/bottomLeft", + parentData: data2, + parentDataProperty: "bottomLeft", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.bottomRight !== void 0) { + if (!validate46(data2.bottomRight, { + instancePath: instancePath + "/bottomRight", + parentData: data2, + parentDataProperty: "bottomRight", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.bodyLeft !== void 0) { + if (!validate46(data2.bodyLeft, { + instancePath: instancePath + "/bodyLeft", + parentData: data2, + parentDataProperty: "bodyLeft", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.bodyRight !== void 0) { + if (!validate46(data2.bodyRight, { + instancePath: instancePath + "/bodyRight", + parentData: data2, + parentDataProperty: "bodyRight", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.bodyJoin !== void 0) { + if (!validate46(data2.bodyJoin, { + instancePath: instancePath + "/bodyJoin", + parentData: data2, + parentDataProperty: "bodyJoin", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.headerJoin !== void 0) { + if (!validate46(data2.headerJoin, { + instancePath: instancePath + "/headerJoin", + parentData: data2, + parentDataProperty: "headerJoin", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.joinBody !== void 0) { + if (!validate46(data2.joinBody, { + instancePath: instancePath + "/joinBody", + parentData: data2, + parentDataProperty: "joinBody", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.joinLeft !== void 0) { + if (!validate46(data2.joinLeft, { + instancePath: instancePath + "/joinLeft", + parentData: data2, + parentDataProperty: "joinLeft", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.joinRight !== void 0) { + if (!validate46(data2.joinRight, { + instancePath: instancePath + "/joinRight", + parentData: data2, + parentDataProperty: "joinRight", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.joinJoin !== void 0) { + if (!validate46(data2.joinJoin, { + instancePath: instancePath + "/joinJoin", + parentData: data2, + parentDataProperty: "joinJoin", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.joinMiddleUp !== void 0) { + if (!validate46(data2.joinMiddleUp, { + instancePath: instancePath + "/joinMiddleUp", + parentData: data2, + parentDataProperty: "joinMiddleUp", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.joinMiddleDown !== void 0) { + if (!validate46(data2.joinMiddleDown, { + instancePath: instancePath + "/joinMiddleDown", + parentData: data2, + parentDataProperty: "joinMiddleDown", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.joinMiddleLeft !== void 0) { + if (!validate46(data2.joinMiddleLeft, { + instancePath: instancePath + "/joinMiddleLeft", + parentData: data2, + parentDataProperty: "joinMiddleLeft", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.joinMiddleRight !== void 0) { + if (!validate46(data2.joinMiddleRight, { + instancePath: instancePath + "/joinMiddleRight", + parentData: data2, + parentDataProperty: "joinMiddleRight", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + } else { + const err1 = { + instancePath, + schemaPath: "#/type", + keyword: "type", + params: { + type: "object" + }, + message: "must be object" + }; + if (vErrors === null) { + vErrors = [err1]; + } else { + vErrors.push(err1); + } + errors++; + } + validate45.errors = vErrors; + return errors === 0; + } + const schema17 = { + "type": "string", + "enum": ["left", "right", "center", "justify"] + }; + equal$1.default; + function validate68(data2, { instancePath = "", parentData, parentDataProperty, rootData = data2 } = {}) { + let vErrors = null; + let errors = 0; + if (typeof data2 !== "string") { + const err0 = { + instancePath, + schemaPath: "#/type", + keyword: "type", + params: { + type: "string" + }, + message: "must be string" + }; + if (vErrors === null) { + vErrors = [err0]; + } else { + vErrors.push(err0); + } + errors++; + } + if (!(data2 === "left" || data2 === "right" || data2 === "center" || data2 === "justify")) { + const err1 = { + instancePath, + schemaPath: "#/enum", + keyword: "enum", + params: { + allowedValues: schema17.enum + }, + message: "must be equal to one of the allowed values" + }; + if (vErrors === null) { + vErrors = [err1]; + } else { + vErrors.push(err1); + } + errors++; + } + validate68.errors = vErrors; + return errors === 0; + } + const pattern0 = new RegExp("^[0-9]+$", "u"); + function validate72(data2, { instancePath = "", parentData, parentDataProperty, rootData = data2 } = {}) { + let vErrors = null; + let errors = 0; + if (typeof data2 !== "string") { + const err0 = { + instancePath, + schemaPath: "#/type", + keyword: "type", + params: { + type: "string" + }, + message: "must be string" + }; + if (vErrors === null) { + vErrors = [err0]; + } else { + vErrors.push(err0); + } + errors++; + } + if (!(data2 === "left" || data2 === "right" || data2 === "center" || data2 === "justify")) { + const err1 = { + instancePath, + schemaPath: "#/enum", + keyword: "enum", + params: { + allowedValues: schema17.enum + }, + message: "must be equal to one of the allowed values" + }; + if (vErrors === null) { + vErrors = [err1]; + } else { + vErrors.push(err1); + } + errors++; + } + validate72.errors = vErrors; + return errors === 0; + } + const schema21 = { + "type": "string", + "enum": ["top", "middle", "bottom"] + }; + function validate74(data2, { instancePath = "", parentData, parentDataProperty, rootData = data2 } = {}) { + let vErrors = null; + let errors = 0; + if (typeof data2 !== "string") { + const err0 = { + instancePath, + schemaPath: "#/type", + keyword: "type", + params: { + type: "string" + }, + message: "must be string" + }; + if (vErrors === null) { + vErrors = [err0]; + } else { + vErrors.push(err0); + } + errors++; + } + if (!(data2 === "top" || data2 === "middle" || data2 === "bottom")) { + const err1 = { + instancePath, + schemaPath: "#/enum", + keyword: "enum", + params: { + allowedValues: schema21.enum + }, + message: "must be equal to one of the allowed values" + }; + if (vErrors === null) { + vErrors = [err1]; + } else { + vErrors.push(err1); + } + errors++; + } + validate74.errors = vErrors; + return errors === 0; + } + function validate71(data2, { instancePath = "", parentData, parentDataProperty, rootData = data2 } = {}) { + let vErrors = null; + let errors = 0; + if (data2 && typeof data2 == "object" && !Array.isArray(data2)) { + for (const key0 in data2) { + if (!(key0 === "alignment" || key0 === "verticalAlignment" || key0 === "width" || key0 === "wrapWord" || key0 === "truncate" || key0 === "paddingLeft" || key0 === "paddingRight")) { + const err0 = { + instancePath, + schemaPath: "#/additionalProperties", + keyword: "additionalProperties", + params: { + additionalProperty: key0 + }, + message: "must NOT have additional properties" + }; + if (vErrors === null) { + vErrors = [err0]; + } else { + vErrors.push(err0); + } + errors++; + } + } + if (data2.alignment !== void 0) { + if (!validate72(data2.alignment, { + instancePath: instancePath + "/alignment", + parentData: data2, + parentDataProperty: "alignment", + rootData + })) { + vErrors = vErrors === null ? validate72.errors : vErrors.concat(validate72.errors); + errors = vErrors.length; + } + } + if (data2.verticalAlignment !== void 0) { + if (!validate74(data2.verticalAlignment, { + instancePath: instancePath + "/verticalAlignment", + parentData: data2, + parentDataProperty: "verticalAlignment", + rootData + })) { + vErrors = vErrors === null ? validate74.errors : vErrors.concat(validate74.errors); + errors = vErrors.length; + } + } + if (data2.width !== void 0) { + let data22 = data2.width; + if (!(typeof data22 == "number" && (!(data22 % 1) && !isNaN(data22)) && isFinite(data22))) { + const err1 = { + instancePath: instancePath + "/width", + schemaPath: "#/properties/width/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err1]; + } else { + vErrors.push(err1); + } + errors++; + } + if (typeof data22 == "number" && isFinite(data22)) { + if (data22 < 1 || isNaN(data22)) { + const err2 = { + instancePath: instancePath + "/width", + schemaPath: "#/properties/width/minimum", + keyword: "minimum", + params: { + comparison: ">=", + limit: 1 + }, + message: "must be >= 1" + }; + if (vErrors === null) { + vErrors = [err2]; + } else { + vErrors.push(err2); + } + errors++; + } + } + } + if (data2.wrapWord !== void 0) { + if (typeof data2.wrapWord !== "boolean") { + const err3 = { + instancePath: instancePath + "/wrapWord", + schemaPath: "#/properties/wrapWord/type", + keyword: "type", + params: { + type: "boolean" + }, + message: "must be boolean" + }; + if (vErrors === null) { + vErrors = [err3]; + } else { + vErrors.push(err3); + } + errors++; + } + } + if (data2.truncate !== void 0) { + let data4 = data2.truncate; + if (!(typeof data4 == "number" && (!(data4 % 1) && !isNaN(data4)) && isFinite(data4))) { + const err4 = { + instancePath: instancePath + "/truncate", + schemaPath: "#/properties/truncate/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err4]; + } else { + vErrors.push(err4); + } + errors++; + } + } + if (data2.paddingLeft !== void 0) { + let data5 = data2.paddingLeft; + if (!(typeof data5 == "number" && (!(data5 % 1) && !isNaN(data5)) && isFinite(data5))) { + const err5 = { + instancePath: instancePath + "/paddingLeft", + schemaPath: "#/properties/paddingLeft/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err5]; + } else { + vErrors.push(err5); + } + errors++; + } + } + if (data2.paddingRight !== void 0) { + let data6 = data2.paddingRight; + if (!(typeof data6 == "number" && (!(data6 % 1) && !isNaN(data6)) && isFinite(data6))) { + const err6 = { + instancePath: instancePath + "/paddingRight", + schemaPath: "#/properties/paddingRight/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err6]; + } else { + vErrors.push(err6); + } + errors++; + } + } + } else { + const err7 = { + instancePath, + schemaPath: "#/type", + keyword: "type", + params: { + type: "object" + }, + message: "must be object" + }; + if (vErrors === null) { + vErrors = [err7]; + } else { + vErrors.push(err7); + } + errors++; + } + validate71.errors = vErrors; + return errors === 0; + } + function validate70(data2, { instancePath = "", parentData, parentDataProperty, rootData = data2 } = {}) { + let vErrors = null; + let errors = 0; + const _errs0 = errors; + let valid0 = false; + let passing0 = null; + const _errs1 = errors; + if (data2 && typeof data2 == "object" && !Array.isArray(data2)) { + for (const key0 in data2) { + if (!pattern0.test(key0)) { + const err0 = { + instancePath, + schemaPath: "#/oneOf/0/additionalProperties", + keyword: "additionalProperties", + params: { + additionalProperty: key0 + }, + message: "must NOT have additional properties" + }; + if (vErrors === null) { + vErrors = [err0]; + } else { + vErrors.push(err0); + } + errors++; + } + } + for (const key1 in data2) { + if (pattern0.test(key1)) { + if (!validate71(data2[key1], { + instancePath: instancePath + "/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"), + parentData: data2, + parentDataProperty: key1, + rootData + })) { + vErrors = vErrors === null ? validate71.errors : vErrors.concat(validate71.errors); + errors = vErrors.length; + } + } + } + } else { + const err1 = { + instancePath, + schemaPath: "#/oneOf/0/type", + keyword: "type", + params: { + type: "object" + }, + message: "must be object" + }; + if (vErrors === null) { + vErrors = [err1]; + } else { + vErrors.push(err1); + } + errors++; + } + var _valid0 = _errs1 === errors; + if (_valid0) { + valid0 = true; + passing0 = 0; + } + const _errs5 = errors; + if (Array.isArray(data2)) { + const len0 = data2.length; + for (let i0 = 0; i0 < len0; i0++) { + if (!validate71(data2[i0], { + instancePath: instancePath + "/" + i0, + parentData: data2, + parentDataProperty: i0, + rootData + })) { + vErrors = vErrors === null ? validate71.errors : vErrors.concat(validate71.errors); + errors = vErrors.length; + } + } + } else { + const err2 = { + instancePath, + schemaPath: "#/oneOf/1/type", + keyword: "type", + params: { + type: "array" + }, + message: "must be array" + }; + if (vErrors === null) { + vErrors = [err2]; + } else { + vErrors.push(err2); + } + errors++; + } + var _valid0 = _errs5 === errors; + if (_valid0 && valid0) { + valid0 = false; + passing0 = [passing0, 1]; + } else { + if (_valid0) { + valid0 = true; + passing0 = 1; + } + } + if (!valid0) { + const err3 = { + instancePath, + schemaPath: "#/oneOf", + keyword: "oneOf", + params: { + passingSchemas: passing0 + }, + message: "must match exactly one schema in oneOf" + }; + if (vErrors === null) { + vErrors = [err3]; + } else { + vErrors.push(err3); + } + errors++; + } else { + errors = _errs0; + if (vErrors !== null) { + if (_errs0) { + vErrors.length = _errs0; + } else { + vErrors = null; + } + } + } + validate70.errors = vErrors; + return errors === 0; + } + function validate79(data2, { instancePath = "", parentData, parentDataProperty, rootData = data2 } = {}) { + let vErrors = null; + let errors = 0; + if (data2 && typeof data2 == "object" && !Array.isArray(data2)) { + for (const key0 in data2) { + if (!(key0 === "alignment" || key0 === "verticalAlignment" || key0 === "width" || key0 === "wrapWord" || key0 === "truncate" || key0 === "paddingLeft" || key0 === "paddingRight")) { + const err0 = { + instancePath, + schemaPath: "#/additionalProperties", + keyword: "additionalProperties", + params: { + additionalProperty: key0 + }, + message: "must NOT have additional properties" + }; + if (vErrors === null) { + vErrors = [err0]; + } else { + vErrors.push(err0); + } + errors++; + } + } + if (data2.alignment !== void 0) { + if (!validate72(data2.alignment, { + instancePath: instancePath + "/alignment", + parentData: data2, + parentDataProperty: "alignment", + rootData + })) { + vErrors = vErrors === null ? validate72.errors : vErrors.concat(validate72.errors); + errors = vErrors.length; + } + } + if (data2.verticalAlignment !== void 0) { + if (!validate74(data2.verticalAlignment, { + instancePath: instancePath + "/verticalAlignment", + parentData: data2, + parentDataProperty: "verticalAlignment", + rootData + })) { + vErrors = vErrors === null ? validate74.errors : vErrors.concat(validate74.errors); + errors = vErrors.length; + } + } + if (data2.width !== void 0) { + let data22 = data2.width; + if (!(typeof data22 == "number" && (!(data22 % 1) && !isNaN(data22)) && isFinite(data22))) { + const err1 = { + instancePath: instancePath + "/width", + schemaPath: "#/properties/width/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err1]; + } else { + vErrors.push(err1); + } + errors++; + } + if (typeof data22 == "number" && isFinite(data22)) { + if (data22 < 1 || isNaN(data22)) { + const err2 = { + instancePath: instancePath + "/width", + schemaPath: "#/properties/width/minimum", + keyword: "minimum", + params: { + comparison: ">=", + limit: 1 + }, + message: "must be >= 1" + }; + if (vErrors === null) { + vErrors = [err2]; + } else { + vErrors.push(err2); + } + errors++; + } + } + } + if (data2.wrapWord !== void 0) { + if (typeof data2.wrapWord !== "boolean") { + const err3 = { + instancePath: instancePath + "/wrapWord", + schemaPath: "#/properties/wrapWord/type", + keyword: "type", + params: { + type: "boolean" + }, + message: "must be boolean" + }; + if (vErrors === null) { + vErrors = [err3]; + } else { + vErrors.push(err3); + } + errors++; + } + } + if (data2.truncate !== void 0) { + let data4 = data2.truncate; + if (!(typeof data4 == "number" && (!(data4 % 1) && !isNaN(data4)) && isFinite(data4))) { + const err4 = { + instancePath: instancePath + "/truncate", + schemaPath: "#/properties/truncate/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err4]; + } else { + vErrors.push(err4); + } + errors++; + } + } + if (data2.paddingLeft !== void 0) { + let data5 = data2.paddingLeft; + if (!(typeof data5 == "number" && (!(data5 % 1) && !isNaN(data5)) && isFinite(data5))) { + const err5 = { + instancePath: instancePath + "/paddingLeft", + schemaPath: "#/properties/paddingLeft/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err5]; + } else { + vErrors.push(err5); + } + errors++; + } + } + if (data2.paddingRight !== void 0) { + let data6 = data2.paddingRight; + if (!(typeof data6 == "number" && (!(data6 % 1) && !isNaN(data6)) && isFinite(data6))) { + const err6 = { + instancePath: instancePath + "/paddingRight", + schemaPath: "#/properties/paddingRight/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err6]; + } else { + vErrors.push(err6); + } + errors++; + } + } + } else { + const err7 = { + instancePath, + schemaPath: "#/type", + keyword: "type", + params: { + type: "object" + }, + message: "must be object" + }; + if (vErrors === null) { + vErrors = [err7]; + } else { + vErrors.push(err7); + } + errors++; + } + validate79.errors = vErrors; + return errors === 0; + } + function validate84(data2, { instancePath = "", parentData, parentDataProperty, rootData = data2 } = {}) { + let vErrors = null; + let errors = 0; + if (typeof data2 !== "string") { + const err0 = { + instancePath, + schemaPath: "#/type", + keyword: "type", + params: { + type: "string" + }, + message: "must be string" + }; + if (vErrors === null) { + vErrors = [err0]; + } else { + vErrors.push(err0); + } + errors++; + } + if (!(data2 === "top" || data2 === "middle" || data2 === "bottom")) { + const err1 = { + instancePath, + schemaPath: "#/enum", + keyword: "enum", + params: { + allowedValues: schema21.enum + }, + message: "must be equal to one of the allowed values" + }; + if (vErrors === null) { + vErrors = [err1]; + } else { + vErrors.push(err1); + } + errors++; + } + validate84.errors = vErrors; + return errors === 0; + } + function validate43(data2, { instancePath = "", parentData, parentDataProperty, rootData = data2 } = {}) { + let vErrors = null; + let errors = 0; + if (data2 && typeof data2 == "object" && !Array.isArray(data2)) { + for (const key0 in data2) { + if (!(key0 === "border" || key0 === "header" || key0 === "columns" || key0 === "columnDefault" || key0 === "drawVerticalLine" || key0 === "drawHorizontalLine" || key0 === "singleLine" || key0 === "spanningCells")) { + const err0 = { + instancePath, + schemaPath: "#/additionalProperties", + keyword: "additionalProperties", + params: { + additionalProperty: key0 + }, + message: "must NOT have additional properties" + }; + if (vErrors === null) { + vErrors = [err0]; + } else { + vErrors.push(err0); + } + errors++; + } + } + if (data2.border !== void 0) { + if (!validate45(data2.border, { + instancePath: instancePath + "/border", + parentData: data2, + parentDataProperty: "border", + rootData + })) { + vErrors = vErrors === null ? validate45.errors : vErrors.concat(validate45.errors); + errors = vErrors.length; + } + } + if (data2.header !== void 0) { + let data1 = data2.header; + if (data1 && typeof data1 == "object" && !Array.isArray(data1)) { + if (data1.content === void 0) { + const err1 = { + instancePath: instancePath + "/header", + schemaPath: "#/properties/header/required", + keyword: "required", + params: { + missingProperty: "content" + }, + message: "must have required property 'content'" + }; + if (vErrors === null) { + vErrors = [err1]; + } else { + vErrors.push(err1); + } + errors++; + } + for (const key1 in data1) { + if (!(key1 === "content" || key1 === "alignment" || key1 === "wrapWord" || key1 === "truncate" || key1 === "paddingLeft" || key1 === "paddingRight")) { + const err2 = { + instancePath: instancePath + "/header", + schemaPath: "#/properties/header/additionalProperties", + keyword: "additionalProperties", + params: { + additionalProperty: key1 + }, + message: "must NOT have additional properties" + }; + if (vErrors === null) { + vErrors = [err2]; + } else { + vErrors.push(err2); + } + errors++; + } + } + if (data1.content !== void 0) { + if (typeof data1.content !== "string") { + const err3 = { + instancePath: instancePath + "/header/content", + schemaPath: "#/properties/header/properties/content/type", + keyword: "type", + params: { + type: "string" + }, + message: "must be string" + }; + if (vErrors === null) { + vErrors = [err3]; + } else { + vErrors.push(err3); + } + errors++; + } + } + if (data1.alignment !== void 0) { + if (!validate68(data1.alignment, { + instancePath: instancePath + "/header/alignment", + parentData: data1, + parentDataProperty: "alignment", + rootData + })) { + vErrors = vErrors === null ? validate68.errors : vErrors.concat(validate68.errors); + errors = vErrors.length; + } + } + if (data1.wrapWord !== void 0) { + if (typeof data1.wrapWord !== "boolean") { + const err4 = { + instancePath: instancePath + "/header/wrapWord", + schemaPath: "#/properties/header/properties/wrapWord/type", + keyword: "type", + params: { + type: "boolean" + }, + message: "must be boolean" + }; + if (vErrors === null) { + vErrors = [err4]; + } else { + vErrors.push(err4); + } + errors++; + } + } + if (data1.truncate !== void 0) { + let data5 = data1.truncate; + if (!(typeof data5 == "number" && (!(data5 % 1) && !isNaN(data5)) && isFinite(data5))) { + const err5 = { + instancePath: instancePath + "/header/truncate", + schemaPath: "#/properties/header/properties/truncate/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err5]; + } else { + vErrors.push(err5); + } + errors++; + } + } + if (data1.paddingLeft !== void 0) { + let data6 = data1.paddingLeft; + if (!(typeof data6 == "number" && (!(data6 % 1) && !isNaN(data6)) && isFinite(data6))) { + const err6 = { + instancePath: instancePath + "/header/paddingLeft", + schemaPath: "#/properties/header/properties/paddingLeft/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err6]; + } else { + vErrors.push(err6); + } + errors++; + } + } + if (data1.paddingRight !== void 0) { + let data7 = data1.paddingRight; + if (!(typeof data7 == "number" && (!(data7 % 1) && !isNaN(data7)) && isFinite(data7))) { + const err7 = { + instancePath: instancePath + "/header/paddingRight", + schemaPath: "#/properties/header/properties/paddingRight/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err7]; + } else { + vErrors.push(err7); + } + errors++; + } + } + } else { + const err8 = { + instancePath: instancePath + "/header", + schemaPath: "#/properties/header/type", + keyword: "type", + params: { + type: "object" + }, + message: "must be object" + }; + if (vErrors === null) { + vErrors = [err8]; + } else { + vErrors.push(err8); + } + errors++; + } + } + if (data2.columns !== void 0) { + if (!validate70(data2.columns, { + instancePath: instancePath + "/columns", + parentData: data2, + parentDataProperty: "columns", + rootData + })) { + vErrors = vErrors === null ? validate70.errors : vErrors.concat(validate70.errors); + errors = vErrors.length; + } + } + if (data2.columnDefault !== void 0) { + if (!validate79(data2.columnDefault, { + instancePath: instancePath + "/columnDefault", + parentData: data2, + parentDataProperty: "columnDefault", + rootData + })) { + vErrors = vErrors === null ? validate79.errors : vErrors.concat(validate79.errors); + errors = vErrors.length; + } + } + if (data2.drawVerticalLine !== void 0) { + if (typeof data2.drawVerticalLine != "function") { + const err9 = { + instancePath: instancePath + "/drawVerticalLine", + schemaPath: "#/properties/drawVerticalLine/typeof", + keyword: "typeof", + params: {}, + message: 'must pass "typeof" keyword validation' + }; + if (vErrors === null) { + vErrors = [err9]; + } else { + vErrors.push(err9); + } + errors++; + } + } + if (data2.drawHorizontalLine !== void 0) { + if (typeof data2.drawHorizontalLine != "function") { + const err10 = { + instancePath: instancePath + "/drawHorizontalLine", + schemaPath: "#/properties/drawHorizontalLine/typeof", + keyword: "typeof", + params: {}, + message: 'must pass "typeof" keyword validation' + }; + if (vErrors === null) { + vErrors = [err10]; + } else { + vErrors.push(err10); + } + errors++; + } + } + if (data2.singleLine !== void 0) { + if (typeof data2.singleLine != "boolean") { + const err11 = { + instancePath: instancePath + "/singleLine", + schemaPath: "#/properties/singleLine/typeof", + keyword: "typeof", + params: {}, + message: 'must pass "typeof" keyword validation' + }; + if (vErrors === null) { + vErrors = [err11]; + } else { + vErrors.push(err11); + } + errors++; + } + } + if (data2.spanningCells !== void 0) { + let data13 = data2.spanningCells; + if (Array.isArray(data13)) { + const len0 = data13.length; + for (let i0 = 0; i0 < len0; i0++) { + let data14 = data13[i0]; + if (data14 && typeof data14 == "object" && !Array.isArray(data14)) { + if (data14.row === void 0) { + const err12 = { + instancePath: instancePath + "/spanningCells/" + i0, + schemaPath: "#/properties/spanningCells/items/required", + keyword: "required", + params: { + missingProperty: "row" + }, + message: "must have required property 'row'" + }; + if (vErrors === null) { + vErrors = [err12]; + } else { + vErrors.push(err12); + } + errors++; + } + if (data14.col === void 0) { + const err13 = { + instancePath: instancePath + "/spanningCells/" + i0, + schemaPath: "#/properties/spanningCells/items/required", + keyword: "required", + params: { + missingProperty: "col" + }, + message: "must have required property 'col'" + }; + if (vErrors === null) { + vErrors = [err13]; + } else { + vErrors.push(err13); + } + errors++; + } + for (const key2 in data14) { + if (!func8.call(schema13.properties.spanningCells.items.properties, key2)) { + const err14 = { + instancePath: instancePath + "/spanningCells/" + i0, + schemaPath: "#/properties/spanningCells/items/additionalProperties", + keyword: "additionalProperties", + params: { + additionalProperty: key2 + }, + message: "must NOT have additional properties" + }; + if (vErrors === null) { + vErrors = [err14]; + } else { + vErrors.push(err14); + } + errors++; + } + } + if (data14.col !== void 0) { + let data15 = data14.col; + if (!(typeof data15 == "number" && (!(data15 % 1) && !isNaN(data15)) && isFinite(data15))) { + const err15 = { + instancePath: instancePath + "/spanningCells/" + i0 + "/col", + schemaPath: "#/properties/spanningCells/items/properties/col/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err15]; + } else { + vErrors.push(err15); + } + errors++; + } + if (typeof data15 == "number" && isFinite(data15)) { + if (data15 < 0 || isNaN(data15)) { + const err16 = { + instancePath: instancePath + "/spanningCells/" + i0 + "/col", + schemaPath: "#/properties/spanningCells/items/properties/col/minimum", + keyword: "minimum", + params: { + comparison: ">=", + limit: 0 + }, + message: "must be >= 0" + }; + if (vErrors === null) { + vErrors = [err16]; + } else { + vErrors.push(err16); + } + errors++; + } + } + } + if (data14.row !== void 0) { + let data16 = data14.row; + if (!(typeof data16 == "number" && (!(data16 % 1) && !isNaN(data16)) && isFinite(data16))) { + const err17 = { + instancePath: instancePath + "/spanningCells/" + i0 + "/row", + schemaPath: "#/properties/spanningCells/items/properties/row/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err17]; + } else { + vErrors.push(err17); + } + errors++; + } + if (typeof data16 == "number" && isFinite(data16)) { + if (data16 < 0 || isNaN(data16)) { + const err18 = { + instancePath: instancePath + "/spanningCells/" + i0 + "/row", + schemaPath: "#/properties/spanningCells/items/properties/row/minimum", + keyword: "minimum", + params: { + comparison: ">=", + limit: 0 + }, + message: "must be >= 0" + }; + if (vErrors === null) { + vErrors = [err18]; + } else { + vErrors.push(err18); + } + errors++; + } + } + } + if (data14.colSpan !== void 0) { + let data17 = data14.colSpan; + if (!(typeof data17 == "number" && (!(data17 % 1) && !isNaN(data17)) && isFinite(data17))) { + const err19 = { + instancePath: instancePath + "/spanningCells/" + i0 + "/colSpan", + schemaPath: "#/properties/spanningCells/items/properties/colSpan/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err19]; + } else { + vErrors.push(err19); + } + errors++; + } + if (typeof data17 == "number" && isFinite(data17)) { + if (data17 < 1 || isNaN(data17)) { + const err20 = { + instancePath: instancePath + "/spanningCells/" + i0 + "/colSpan", + schemaPath: "#/properties/spanningCells/items/properties/colSpan/minimum", + keyword: "minimum", + params: { + comparison: ">=", + limit: 1 + }, + message: "must be >= 1" + }; + if (vErrors === null) { + vErrors = [err20]; + } else { + vErrors.push(err20); + } + errors++; + } + } + } + if (data14.rowSpan !== void 0) { + let data18 = data14.rowSpan; + if (!(typeof data18 == "number" && (!(data18 % 1) && !isNaN(data18)) && isFinite(data18))) { + const err21 = { + instancePath: instancePath + "/spanningCells/" + i0 + "/rowSpan", + schemaPath: "#/properties/spanningCells/items/properties/rowSpan/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err21]; + } else { + vErrors.push(err21); + } + errors++; + } + if (typeof data18 == "number" && isFinite(data18)) { + if (data18 < 1 || isNaN(data18)) { + const err22 = { + instancePath: instancePath + "/spanningCells/" + i0 + "/rowSpan", + schemaPath: "#/properties/spanningCells/items/properties/rowSpan/minimum", + keyword: "minimum", + params: { + comparison: ">=", + limit: 1 + }, + message: "must be >= 1" + }; + if (vErrors === null) { + vErrors = [err22]; + } else { + vErrors.push(err22); + } + errors++; + } + } + } + if (data14.alignment !== void 0) { + if (!validate68(data14.alignment, { + instancePath: instancePath + "/spanningCells/" + i0 + "/alignment", + parentData: data14, + parentDataProperty: "alignment", + rootData + })) { + vErrors = vErrors === null ? validate68.errors : vErrors.concat(validate68.errors); + errors = vErrors.length; + } + } + if (data14.verticalAlignment !== void 0) { + if (!validate84(data14.verticalAlignment, { + instancePath: instancePath + "/spanningCells/" + i0 + "/verticalAlignment", + parentData: data14, + parentDataProperty: "verticalAlignment", + rootData + })) { + vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors); + errors = vErrors.length; + } + } + if (data14.wrapWord !== void 0) { + if (typeof data14.wrapWord !== "boolean") { + const err23 = { + instancePath: instancePath + "/spanningCells/" + i0 + "/wrapWord", + schemaPath: "#/properties/spanningCells/items/properties/wrapWord/type", + keyword: "type", + params: { + type: "boolean" + }, + message: "must be boolean" + }; + if (vErrors === null) { + vErrors = [err23]; + } else { + vErrors.push(err23); + } + errors++; + } + } + if (data14.truncate !== void 0) { + let data22 = data14.truncate; + if (!(typeof data22 == "number" && (!(data22 % 1) && !isNaN(data22)) && isFinite(data22))) { + const err24 = { + instancePath: instancePath + "/spanningCells/" + i0 + "/truncate", + schemaPath: "#/properties/spanningCells/items/properties/truncate/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err24]; + } else { + vErrors.push(err24); + } + errors++; + } + } + if (data14.paddingLeft !== void 0) { + let data23 = data14.paddingLeft; + if (!(typeof data23 == "number" && (!(data23 % 1) && !isNaN(data23)) && isFinite(data23))) { + const err25 = { + instancePath: instancePath + "/spanningCells/" + i0 + "/paddingLeft", + schemaPath: "#/properties/spanningCells/items/properties/paddingLeft/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err25]; + } else { + vErrors.push(err25); + } + errors++; + } + } + if (data14.paddingRight !== void 0) { + let data24 = data14.paddingRight; + if (!(typeof data24 == "number" && (!(data24 % 1) && !isNaN(data24)) && isFinite(data24))) { + const err26 = { + instancePath: instancePath + "/spanningCells/" + i0 + "/paddingRight", + schemaPath: "#/properties/spanningCells/items/properties/paddingRight/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err26]; + } else { + vErrors.push(err26); + } + errors++; + } + } + } else { + const err27 = { + instancePath: instancePath + "/spanningCells/" + i0, + schemaPath: "#/properties/spanningCells/items/type", + keyword: "type", + params: { + type: "object" + }, + message: "must be object" + }; + if (vErrors === null) { + vErrors = [err27]; + } else { + vErrors.push(err27); + } + errors++; + } + } + } else { + const err28 = { + instancePath: instancePath + "/spanningCells", + schemaPath: "#/properties/spanningCells/type", + keyword: "type", + params: { + type: "array" + }, + message: "must be array" + }; + if (vErrors === null) { + vErrors = [err28]; + } else { + vErrors.push(err28); + } + errors++; + } + } + } else { + const err29 = { + instancePath, + schemaPath: "#/type", + keyword: "type", + params: { + type: "object" + }, + message: "must be object" + }; + if (vErrors === null) { + vErrors = [err29]; + } else { + vErrors.push(err29); + } + errors++; + } + validate43.errors = vErrors; + return errors === 0; + } + exports2["streamConfig.json"] = validate86; + function validate87(data2, { instancePath = "", parentData, parentDataProperty, rootData = data2 } = {}) { + let vErrors = null; + let errors = 0; + if (data2 && typeof data2 == "object" && !Array.isArray(data2)) { + for (const key0 in data2) { + if (!func8.call(schema15.properties, key0)) { + const err0 = { + instancePath, + schemaPath: "#/additionalProperties", + keyword: "additionalProperties", + params: { + additionalProperty: key0 + }, + message: "must NOT have additional properties" + }; + if (vErrors === null) { + vErrors = [err0]; + } else { + vErrors.push(err0); + } + errors++; + } + } + if (data2.topBody !== void 0) { + if (!validate46(data2.topBody, { + instancePath: instancePath + "/topBody", + parentData: data2, + parentDataProperty: "topBody", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.topJoin !== void 0) { + if (!validate46(data2.topJoin, { + instancePath: instancePath + "/topJoin", + parentData: data2, + parentDataProperty: "topJoin", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.topLeft !== void 0) { + if (!validate46(data2.topLeft, { + instancePath: instancePath + "/topLeft", + parentData: data2, + parentDataProperty: "topLeft", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.topRight !== void 0) { + if (!validate46(data2.topRight, { + instancePath: instancePath + "/topRight", + parentData: data2, + parentDataProperty: "topRight", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.bottomBody !== void 0) { + if (!validate46(data2.bottomBody, { + instancePath: instancePath + "/bottomBody", + parentData: data2, + parentDataProperty: "bottomBody", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.bottomJoin !== void 0) { + if (!validate46(data2.bottomJoin, { + instancePath: instancePath + "/bottomJoin", + parentData: data2, + parentDataProperty: "bottomJoin", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.bottomLeft !== void 0) { + if (!validate46(data2.bottomLeft, { + instancePath: instancePath + "/bottomLeft", + parentData: data2, + parentDataProperty: "bottomLeft", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.bottomRight !== void 0) { + if (!validate46(data2.bottomRight, { + instancePath: instancePath + "/bottomRight", + parentData: data2, + parentDataProperty: "bottomRight", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.bodyLeft !== void 0) { + if (!validate46(data2.bodyLeft, { + instancePath: instancePath + "/bodyLeft", + parentData: data2, + parentDataProperty: "bodyLeft", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.bodyRight !== void 0) { + if (!validate46(data2.bodyRight, { + instancePath: instancePath + "/bodyRight", + parentData: data2, + parentDataProperty: "bodyRight", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.bodyJoin !== void 0) { + if (!validate46(data2.bodyJoin, { + instancePath: instancePath + "/bodyJoin", + parentData: data2, + parentDataProperty: "bodyJoin", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.headerJoin !== void 0) { + if (!validate46(data2.headerJoin, { + instancePath: instancePath + "/headerJoin", + parentData: data2, + parentDataProperty: "headerJoin", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.joinBody !== void 0) { + if (!validate46(data2.joinBody, { + instancePath: instancePath + "/joinBody", + parentData: data2, + parentDataProperty: "joinBody", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.joinLeft !== void 0) { + if (!validate46(data2.joinLeft, { + instancePath: instancePath + "/joinLeft", + parentData: data2, + parentDataProperty: "joinLeft", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.joinRight !== void 0) { + if (!validate46(data2.joinRight, { + instancePath: instancePath + "/joinRight", + parentData: data2, + parentDataProperty: "joinRight", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.joinJoin !== void 0) { + if (!validate46(data2.joinJoin, { + instancePath: instancePath + "/joinJoin", + parentData: data2, + parentDataProperty: "joinJoin", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.joinMiddleUp !== void 0) { + if (!validate46(data2.joinMiddleUp, { + instancePath: instancePath + "/joinMiddleUp", + parentData: data2, + parentDataProperty: "joinMiddleUp", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.joinMiddleDown !== void 0) { + if (!validate46(data2.joinMiddleDown, { + instancePath: instancePath + "/joinMiddleDown", + parentData: data2, + parentDataProperty: "joinMiddleDown", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.joinMiddleLeft !== void 0) { + if (!validate46(data2.joinMiddleLeft, { + instancePath: instancePath + "/joinMiddleLeft", + parentData: data2, + parentDataProperty: "joinMiddleLeft", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + if (data2.joinMiddleRight !== void 0) { + if (!validate46(data2.joinMiddleRight, { + instancePath: instancePath + "/joinMiddleRight", + parentData: data2, + parentDataProperty: "joinMiddleRight", + rootData + })) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } + } else { + const err1 = { + instancePath, + schemaPath: "#/type", + keyword: "type", + params: { + type: "object" + }, + message: "must be object" + }; + if (vErrors === null) { + vErrors = [err1]; + } else { + vErrors.push(err1); + } + errors++; + } + validate87.errors = vErrors; + return errors === 0; + } + function validate109(data2, { instancePath = "", parentData, parentDataProperty, rootData = data2 } = {}) { + let vErrors = null; + let errors = 0; + const _errs0 = errors; + let valid0 = false; + let passing0 = null; + const _errs1 = errors; + if (data2 && typeof data2 == "object" && !Array.isArray(data2)) { + for (const key0 in data2) { + if (!pattern0.test(key0)) { + const err0 = { + instancePath, + schemaPath: "#/oneOf/0/additionalProperties", + keyword: "additionalProperties", + params: { + additionalProperty: key0 + }, + message: "must NOT have additional properties" + }; + if (vErrors === null) { + vErrors = [err0]; + } else { + vErrors.push(err0); + } + errors++; + } + } + for (const key1 in data2) { + if (pattern0.test(key1)) { + if (!validate71(data2[key1], { + instancePath: instancePath + "/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"), + parentData: data2, + parentDataProperty: key1, + rootData + })) { + vErrors = vErrors === null ? validate71.errors : vErrors.concat(validate71.errors); + errors = vErrors.length; + } + } + } + } else { + const err1 = { + instancePath, + schemaPath: "#/oneOf/0/type", + keyword: "type", + params: { + type: "object" + }, + message: "must be object" + }; + if (vErrors === null) { + vErrors = [err1]; + } else { + vErrors.push(err1); + } + errors++; + } + var _valid0 = _errs1 === errors; + if (_valid0) { + valid0 = true; + passing0 = 0; + } + const _errs5 = errors; + if (Array.isArray(data2)) { + const len0 = data2.length; + for (let i0 = 0; i0 < len0; i0++) { + if (!validate71(data2[i0], { + instancePath: instancePath + "/" + i0, + parentData: data2, + parentDataProperty: i0, + rootData + })) { + vErrors = vErrors === null ? validate71.errors : vErrors.concat(validate71.errors); + errors = vErrors.length; + } + } + } else { + const err2 = { + instancePath, + schemaPath: "#/oneOf/1/type", + keyword: "type", + params: { + type: "array" + }, + message: "must be array" + }; + if (vErrors === null) { + vErrors = [err2]; + } else { + vErrors.push(err2); + } + errors++; + } + var _valid0 = _errs5 === errors; + if (_valid0 && valid0) { + valid0 = false; + passing0 = [passing0, 1]; + } else { + if (_valid0) { + valid0 = true; + passing0 = 1; + } + } + if (!valid0) { + const err3 = { + instancePath, + schemaPath: "#/oneOf", + keyword: "oneOf", + params: { + passingSchemas: passing0 + }, + message: "must match exactly one schema in oneOf" + }; + if (vErrors === null) { + vErrors = [err3]; + } else { + vErrors.push(err3); + } + errors++; + } else { + errors = _errs0; + if (vErrors !== null) { + if (_errs0) { + vErrors.length = _errs0; + } else { + vErrors = null; + } + } + } + validate109.errors = vErrors; + return errors === 0; + } + function validate113(data2, { instancePath = "", parentData, parentDataProperty, rootData = data2 } = {}) { + let vErrors = null; + let errors = 0; + if (data2 && typeof data2 == "object" && !Array.isArray(data2)) { + for (const key0 in data2) { + if (!(key0 === "alignment" || key0 === "verticalAlignment" || key0 === "width" || key0 === "wrapWord" || key0 === "truncate" || key0 === "paddingLeft" || key0 === "paddingRight")) { + const err0 = { + instancePath, + schemaPath: "#/additionalProperties", + keyword: "additionalProperties", + params: { + additionalProperty: key0 + }, + message: "must NOT have additional properties" + }; + if (vErrors === null) { + vErrors = [err0]; + } else { + vErrors.push(err0); + } + errors++; + } + } + if (data2.alignment !== void 0) { + if (!validate72(data2.alignment, { + instancePath: instancePath + "/alignment", + parentData: data2, + parentDataProperty: "alignment", + rootData + })) { + vErrors = vErrors === null ? validate72.errors : vErrors.concat(validate72.errors); + errors = vErrors.length; + } + } + if (data2.verticalAlignment !== void 0) { + if (!validate74(data2.verticalAlignment, { + instancePath: instancePath + "/verticalAlignment", + parentData: data2, + parentDataProperty: "verticalAlignment", + rootData + })) { + vErrors = vErrors === null ? validate74.errors : vErrors.concat(validate74.errors); + errors = vErrors.length; + } + } + if (data2.width !== void 0) { + let data22 = data2.width; + if (!(typeof data22 == "number" && (!(data22 % 1) && !isNaN(data22)) && isFinite(data22))) { + const err1 = { + instancePath: instancePath + "/width", + schemaPath: "#/properties/width/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err1]; + } else { + vErrors.push(err1); + } + errors++; + } + if (typeof data22 == "number" && isFinite(data22)) { + if (data22 < 1 || isNaN(data22)) { + const err2 = { + instancePath: instancePath + "/width", + schemaPath: "#/properties/width/minimum", + keyword: "minimum", + params: { + comparison: ">=", + limit: 1 + }, + message: "must be >= 1" + }; + if (vErrors === null) { + vErrors = [err2]; + } else { + vErrors.push(err2); + } + errors++; + } + } + } + if (data2.wrapWord !== void 0) { + if (typeof data2.wrapWord !== "boolean") { + const err3 = { + instancePath: instancePath + "/wrapWord", + schemaPath: "#/properties/wrapWord/type", + keyword: "type", + params: { + type: "boolean" + }, + message: "must be boolean" + }; + if (vErrors === null) { + vErrors = [err3]; + } else { + vErrors.push(err3); + } + errors++; + } + } + if (data2.truncate !== void 0) { + let data4 = data2.truncate; + if (!(typeof data4 == "number" && (!(data4 % 1) && !isNaN(data4)) && isFinite(data4))) { + const err4 = { + instancePath: instancePath + "/truncate", + schemaPath: "#/properties/truncate/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err4]; + } else { + vErrors.push(err4); + } + errors++; + } + } + if (data2.paddingLeft !== void 0) { + let data5 = data2.paddingLeft; + if (!(typeof data5 == "number" && (!(data5 % 1) && !isNaN(data5)) && isFinite(data5))) { + const err5 = { + instancePath: instancePath + "/paddingLeft", + schemaPath: "#/properties/paddingLeft/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err5]; + } else { + vErrors.push(err5); + } + errors++; + } + } + if (data2.paddingRight !== void 0) { + let data6 = data2.paddingRight; + if (!(typeof data6 == "number" && (!(data6 % 1) && !isNaN(data6)) && isFinite(data6))) { + const err6 = { + instancePath: instancePath + "/paddingRight", + schemaPath: "#/properties/paddingRight/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err6]; + } else { + vErrors.push(err6); + } + errors++; + } + } + } else { + const err7 = { + instancePath, + schemaPath: "#/type", + keyword: "type", + params: { + type: "object" + }, + message: "must be object" + }; + if (vErrors === null) { + vErrors = [err7]; + } else { + vErrors.push(err7); + } + errors++; + } + validate113.errors = vErrors; + return errors === 0; + } + function validate86(data2, { instancePath = "", parentData, parentDataProperty, rootData = data2 } = {}) { + let vErrors = null; + let errors = 0; + if (data2 && typeof data2 == "object" && !Array.isArray(data2)) { + if (data2.columnDefault === void 0) { + const err0 = { + instancePath, + schemaPath: "#/required", + keyword: "required", + params: { + missingProperty: "columnDefault" + }, + message: "must have required property 'columnDefault'" + }; + if (vErrors === null) { + vErrors = [err0]; + } else { + vErrors.push(err0); + } + errors++; + } + if (data2.columnCount === void 0) { + const err1 = { + instancePath, + schemaPath: "#/required", + keyword: "required", + params: { + missingProperty: "columnCount" + }, + message: "must have required property 'columnCount'" + }; + if (vErrors === null) { + vErrors = [err1]; + } else { + vErrors.push(err1); + } + errors++; + } + for (const key0 in data2) { + if (!(key0 === "border" || key0 === "columns" || key0 === "columnDefault" || key0 === "columnCount" || key0 === "drawVerticalLine")) { + const err2 = { + instancePath, + schemaPath: "#/additionalProperties", + keyword: "additionalProperties", + params: { + additionalProperty: key0 + }, + message: "must NOT have additional properties" + }; + if (vErrors === null) { + vErrors = [err2]; + } else { + vErrors.push(err2); + } + errors++; + } + } + if (data2.border !== void 0) { + if (!validate87(data2.border, { + instancePath: instancePath + "/border", + parentData: data2, + parentDataProperty: "border", + rootData + })) { + vErrors = vErrors === null ? validate87.errors : vErrors.concat(validate87.errors); + errors = vErrors.length; + } + } + if (data2.columns !== void 0) { + if (!validate109(data2.columns, { + instancePath: instancePath + "/columns", + parentData: data2, + parentDataProperty: "columns", + rootData + })) { + vErrors = vErrors === null ? validate109.errors : vErrors.concat(validate109.errors); + errors = vErrors.length; + } + } + if (data2.columnDefault !== void 0) { + if (!validate113(data2.columnDefault, { + instancePath: instancePath + "/columnDefault", + parentData: data2, + parentDataProperty: "columnDefault", + rootData + })) { + vErrors = vErrors === null ? validate113.errors : vErrors.concat(validate113.errors); + errors = vErrors.length; + } + } + if (data2.columnCount !== void 0) { + let data3 = data2.columnCount; + if (!(typeof data3 == "number" && (!(data3 % 1) && !isNaN(data3)) && isFinite(data3))) { + const err3 = { + instancePath: instancePath + "/columnCount", + schemaPath: "#/properties/columnCount/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err3]; + } else { + vErrors.push(err3); + } + errors++; + } + if (typeof data3 == "number" && isFinite(data3)) { + if (data3 < 1 || isNaN(data3)) { + const err4 = { + instancePath: instancePath + "/columnCount", + schemaPath: "#/properties/columnCount/minimum", + keyword: "minimum", + params: { + comparison: ">=", + limit: 1 + }, + message: "must be >= 1" + }; + if (vErrors === null) { + vErrors = [err4]; + } else { + vErrors.push(err4); + } + errors++; + } + } + } + if (data2.drawVerticalLine !== void 0) { + if (typeof data2.drawVerticalLine != "function") { + const err5 = { + instancePath: instancePath + "/drawVerticalLine", + schemaPath: "#/properties/drawVerticalLine/typeof", + keyword: "typeof", + params: {}, + message: 'must pass "typeof" keyword validation' + }; + if (vErrors === null) { + vErrors = [err5]; + } else { + vErrors.push(err5); + } + errors++; + } + } + } else { + const err6 = { + instancePath, + schemaPath: "#/type", + keyword: "type", + params: { + type: "object" + }, + message: "must be object" + }; + if (vErrors === null) { + vErrors = [err6]; + } else { + vErrors.push(err6); + } + errors++; + } + validate86.errors = vErrors; + return errors === 0; + } +})(validators); +var __importDefault$1 = commonjsGlobal && commonjsGlobal.__importDefault || function(mod) { + return mod && mod.__esModule ? mod : { "default": mod }; +}; +Object.defineProperty(validateConfig$1, "__esModule", { value: true }); +validateConfig$1.validateConfig = void 0; +const validators_1 = __importDefault$1(validators); +const validateConfig = (schemaId, config2) => { + const validate2 = validators_1.default[schemaId]; + if (!validate2(config2) && validate2.errors) { + const errors = validate2.errors.map((error2) => { + return { + message: error2.message, + params: error2.params, + schemaPath: error2.schemaPath + }; + }); + console.log("config", config2); + console.log("errors", errors); + throw new Error("Invalid config."); + } +}; +validateConfig$1.validateConfig = validateConfig; +Object.defineProperty(makeStreamConfig$1, "__esModule", { value: true }); +makeStreamConfig$1.makeStreamConfig = void 0; +const utils_1$b = utils; +const validateConfig_1$1 = validateConfig$1; +const makeColumnsConfig$1 = (columnCount, columns = {}, columnDefault) => { + return Array.from({ length: columnCount }).map((_, index) => { + return { + alignment: "left", + paddingLeft: 1, + paddingRight: 1, + truncate: Number.POSITIVE_INFINITY, + verticalAlignment: "top", + wrapWord: false, + ...columnDefault, + ...columns[index] + }; + }); +}; +const makeStreamConfig = (config2) => { + (0, validateConfig_1$1.validateConfig)("streamConfig.json", config2); + if (config2.columnDefault.width === void 0) { + throw new Error("Must provide config.columnDefault.width when creating a stream."); + } + return { + drawVerticalLine: () => { + return true; + }, + ...config2, + border: (0, utils_1$b.makeBorderConfig)(config2.border), + columns: makeColumnsConfig$1(config2.columnCount, config2.columns, config2.columnDefault) + }; +}; +makeStreamConfig$1.makeStreamConfig = makeStreamConfig; +var mapDataUsingRowHeights = {}; +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.mapDataUsingRowHeights = exports2.padCellVertically = void 0; + const utils_12 = utils; + const wrapCell_12 = wrapCell$1; + const createEmptyStrings = (length) => { + return new Array(length).fill(""); + }; + const padCellVertically = (lines, rowHeight, verticalAlignment) => { + const availableLines = rowHeight - lines.length; + if (verticalAlignment === "top") { + return [...lines, ...createEmptyStrings(availableLines)]; + } + if (verticalAlignment === "bottom") { + return [...createEmptyStrings(availableLines), ...lines]; + } + return [ + ...createEmptyStrings(Math.floor(availableLines / 2)), + ...lines, + ...createEmptyStrings(Math.ceil(availableLines / 2)) + ]; + }; + exports2.padCellVertically = padCellVertically; + const mapDataUsingRowHeights2 = (unmappedRows, rowHeights, config2) => { + const nColumns = unmappedRows[0].length; + const mappedRows = unmappedRows.map((unmappedRow, unmappedRowIndex) => { + const outputRowHeight = rowHeights[unmappedRowIndex]; + const outputRow = Array.from({ length: outputRowHeight }, () => { + return new Array(nColumns).fill(""); + }); + unmappedRow.forEach((cell, cellIndex) => { + var _a2; + const containingRange = (_a2 = config2.spanningCellManager) === null || _a2 === void 0 ? void 0 : _a2.getContainingRange({ + col: cellIndex, + row: unmappedRowIndex + }); + if (containingRange) { + containingRange.extractCellContent(unmappedRowIndex).forEach((cellLine, cellLineIndex) => { + outputRow[cellLineIndex][cellIndex] = cellLine; + }); + return; + } + const cellLines = (0, wrapCell_12.wrapCell)(cell, config2.columns[cellIndex].width, config2.columns[cellIndex].wrapWord); + const paddedCellLines = (0, exports2.padCellVertically)(cellLines, outputRowHeight, config2.columns[cellIndex].verticalAlignment); + paddedCellLines.forEach((cellLine, cellLineIndex) => { + outputRow[cellLineIndex][cellIndex] = cellLine; + }); + }); + return outputRow; + }); + return (0, utils_12.flatten)(mappedRows); + }; + exports2.mapDataUsingRowHeights = mapDataUsingRowHeights2; +})(mapDataUsingRowHeights); +var padTableData = {}; +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.padTableData = exports2.padString = void 0; + const padString = (input, paddingLeft, paddingRight) => { + return " ".repeat(paddingLeft) + input + " ".repeat(paddingRight); + }; + exports2.padString = padString; + const padTableData2 = (rows, config2) => { + return rows.map((cells, rowIndex) => { + return cells.map((cell, cellIndex) => { + var _a2; + const containingRange = (_a2 = config2.spanningCellManager) === null || _a2 === void 0 ? void 0 : _a2.getContainingRange({ + col: cellIndex, + row: rowIndex + }, { mapped: true }); + if (containingRange) { + return cell; + } + const { paddingLeft, paddingRight } = config2.columns[cellIndex]; + return (0, exports2.padString)(cell, paddingLeft, paddingRight); + }); + }); + }; + exports2.padTableData = padTableData2; +})(padTableData); +var stringifyTableData$1 = {}; +Object.defineProperty(stringifyTableData$1, "__esModule", { value: true }); +stringifyTableData$1.stringifyTableData = void 0; +const utils_1$a = utils; +const stringifyTableData = (rows) => { + return rows.map((cells) => { + return cells.map((cell) => { + return (0, utils_1$a.normalizeString)(String(cell)); + }); + }); +}; +stringifyTableData$1.stringifyTableData = stringifyTableData; +var truncateTableData = {}; +var lodash_truncate = { exports: {} }; +lodash_truncate.exports; +(function(module, exports2) { + var DEFAULT_TRUNC_LENGTH = 30, DEFAULT_TRUNC_OMISSION = "..."; + var INFINITY = 1 / 0, MAX_INTEGER = 17976931348623157e292, NAN = 0 / 0; + var regexpTag = "[object RegExp]", symbolTag = "[object Symbol]"; + var reTrim = /^\s+|\s+$/g; + var reFlags = /\w*$/; + var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; + var reIsBinary = /^0b[01]+$/i; + var reIsOctal = /^0o[0-7]+$/i; + var rsAstralRange = "\\ud800-\\udfff", rsComboMarksRange = "\\u0300-\\u036f\\ufe20-\\ufe23", rsComboSymbolsRange = "\\u20d0-\\u20f0", rsVarRange = "\\ufe0e\\ufe0f"; + var rsAstral = "[" + rsAstralRange + "]", rsCombo = "[" + rsComboMarksRange + rsComboSymbolsRange + "]", rsFitz = "\\ud83c[\\udffb-\\udfff]", rsModifier = "(?:" + rsCombo + "|" + rsFitz + ")", rsNonAstral = "[^" + rsAstralRange + "]", rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}", rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]", rsZWJ = "\\u200d"; + var reOptMod = rsModifier + "?", rsOptVar = "[" + rsVarRange + "]?", rsOptJoin = "(?:" + rsZWJ + "(?:" + [rsNonAstral, rsRegional, rsSurrPair].join("|") + ")" + rsOptVar + reOptMod + ")*", rsSeq = rsOptVar + reOptMod + rsOptJoin, rsSymbol = "(?:" + [rsNonAstral + rsCombo + "?", rsCombo, rsRegional, rsSurrPair, rsAstral].join("|") + ")"; + var reUnicode = RegExp(rsFitz + "(?=" + rsFitz + ")|" + rsSymbol + rsSeq, "g"); + var reHasUnicode = RegExp("[" + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + "]"); + var freeParseInt = parseInt; + var freeGlobal = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; + var freeSelf = typeof self == "object" && self && self.Object === Object && self; + var root = freeGlobal || freeSelf || Function("return this")(); + var freeExports = exports2 && !exports2.nodeType && exports2; + var freeModule = freeExports && true && module && !module.nodeType && module; + var moduleExports = freeModule && freeModule.exports === freeExports; + var freeProcess = moduleExports && freeGlobal.process; + var nodeUtil = function() { + try { + return freeProcess && freeProcess.binding("util"); + } catch (e) { + } + }(); + var nodeIsRegExp = nodeUtil && nodeUtil.isRegExp; + var asciiSize = baseProperty("length"); + function asciiToArray(string) { + return string.split(""); + } + function baseProperty(key) { + return function(object) { + return object == null ? void 0 : object[key]; + }; + } + function baseUnary(func) { + return function(value) { + return func(value); + }; + } + function hasUnicode(string) { + return reHasUnicode.test(string); + } + function stringSize(string) { + return hasUnicode(string) ? unicodeSize(string) : asciiSize(string); + } + function stringToArray(string) { + return hasUnicode(string) ? unicodeToArray(string) : asciiToArray(string); + } + function unicodeSize(string) { + var result = reUnicode.lastIndex = 0; + while (reUnicode.test(string)) { + result++; + } + return result; + } + function unicodeToArray(string) { + return string.match(reUnicode) || []; + } + var objectProto = Object.prototype; + var objectToString = objectProto.toString; + var Symbol2 = root.Symbol; + var symbolProto = Symbol2 ? Symbol2.prototype : void 0, symbolToString = symbolProto ? symbolProto.toString : void 0; + function baseIsRegExp(value) { + return isObject2(value) && objectToString.call(value) == regexpTag; + } + function baseSlice(array, start, end) { + var index = -1, length = array.length; + if (start < 0) { + start = -start > length ? 0 : length + start; + } + end = end > length ? length : end; + if (end < 0) { + end += length; + } + length = start > end ? 0 : end - start >>> 0; + start >>>= 0; + var result = Array(length); + while (++index < length) { + result[index] = array[index + start]; + } + return result; + } + function baseToString(value) { + if (typeof value == "string") { + return value; + } + if (isSymbol2(value)) { + return symbolToString ? symbolToString.call(value) : ""; + } + var result = value + ""; + return result == "0" && 1 / value == -INFINITY ? "-0" : result; + } + function castSlice(array, start, end) { + var length = array.length; + end = end === void 0 ? length : end; + return !start && end >= length ? array : baseSlice(array, start, end); + } + function isObject2(value) { + var type = typeof value; + return !!value && (type == "object" || type == "function"); + } + function isObjectLike(value) { + return !!value && typeof value == "object"; + } + var isRegExp2 = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; + function isSymbol2(value) { + return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag; + } + function toFinite(value) { + if (!value) { + return value === 0 ? value : 0; + } + value = toNumber(value); + if (value === INFINITY || value === -INFINITY) { + var sign = value < 0 ? -1 : 1; + return sign * MAX_INTEGER; + } + return value === value ? value : 0; + } + function toInteger(value) { + var result = toFinite(value), remainder = result % 1; + return result === result ? remainder ? result - remainder : result : 0; + } + function toNumber(value) { + if (typeof value == "number") { + return value; + } + if (isSymbol2(value)) { + return NAN; + } + if (isObject2(value)) { + var other = typeof value.valueOf == "function" ? value.valueOf() : value; + value = isObject2(other) ? other + "" : other; + } + if (typeof value != "string") { + return value === 0 ? value : +value; + } + value = value.replace(reTrim, ""); + var isBinary = reIsBinary.test(value); + return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value; + } + function toString(value) { + return value == null ? "" : baseToString(value); + } + function truncate(string, options) { + var length = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION; + if (isObject2(options)) { + var separator = "separator" in options ? options.separator : separator; + length = "length" in options ? toInteger(options.length) : length; + omission = "omission" in options ? baseToString(options.omission) : omission; + } + string = toString(string); + var strLength = string.length; + if (hasUnicode(string)) { + var strSymbols = stringToArray(string); + strLength = strSymbols.length; + } + if (length >= strLength) { + return string; + } + var end = length - stringSize(omission); + if (end < 1) { + return omission; + } + var result = strSymbols ? castSlice(strSymbols, 0, end).join("") : string.slice(0, end); + if (separator === void 0) { + return result + omission; + } + if (strSymbols) { + end += result.length - end; + } + if (isRegExp2(separator)) { + if (string.slice(end).search(separator)) { + var match2, substring = result; + if (!separator.global) { + separator = RegExp(separator.source, toString(reFlags.exec(separator)) + "g"); + } + separator.lastIndex = 0; + while (match2 = separator.exec(substring)) { + var newEnd = match2.index; + } + result = result.slice(0, newEnd === void 0 ? end : newEnd); + } + } else if (string.indexOf(baseToString(separator), end) != end) { + var index = result.lastIndexOf(separator); + if (index > -1) { + result = result.slice(0, index); + } + } + return result + omission; + } + module.exports = truncate; +})(lodash_truncate, lodash_truncate.exports); +var lodash_truncateExports = lodash_truncate.exports; +(function(exports2) { + var __importDefault2 = commonjsGlobal && commonjsGlobal.__importDefault || function(mod) { + return mod && mod.__esModule ? mod : { "default": mod }; + }; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.truncateTableData = exports2.truncateString = void 0; + const lodash_truncate_1 = __importDefault2(lodash_truncateExports); + const truncateString = (input, length) => { + return (0, lodash_truncate_1.default)(input, { + length, + omission: "…" + }); + }; + exports2.truncateString = truncateString; + const truncateTableData2 = (rows, truncates) => { + return rows.map((cells) => { + return cells.map((cell, cellIndex) => { + return (0, exports2.truncateString)(cell, truncates[cellIndex]); + }); + }); + }; + exports2.truncateTableData = truncateTableData2; +})(truncateTableData); +Object.defineProperty(createStream$1, "__esModule", { value: true }); +createStream$1.createStream = void 0; +const alignTableData_1$1 = alignTableData$1; +const calculateRowHeights_1$1 = calculateRowHeights$1; +const drawBorder_1$1 = drawBorder; +const drawRow_1$1 = drawRow$1; +const makeStreamConfig_1 = makeStreamConfig$1; +const mapDataUsingRowHeights_1$2 = mapDataUsingRowHeights; +const padTableData_1$2 = padTableData; +const stringifyTableData_1$1 = stringifyTableData$1; +const truncateTableData_1$2 = truncateTableData; +const utils_1$9 = utils; +const prepareData = (data2, config2) => { + let rows = (0, stringifyTableData_1$1.stringifyTableData)(data2); + rows = (0, truncateTableData_1$2.truncateTableData)(rows, (0, utils_1$9.extractTruncates)(config2)); + const rowHeights = (0, calculateRowHeights_1$1.calculateRowHeights)(rows, config2); + rows = (0, mapDataUsingRowHeights_1$2.mapDataUsingRowHeights)(rows, rowHeights, config2); + rows = (0, alignTableData_1$1.alignTableData)(rows, config2); + rows = (0, padTableData_1$2.padTableData)(rows, config2); + return rows; +}; +const create = (row, columnWidths, config2) => { + const rows = prepareData([row], config2); + const body = rows.map((literalRow) => { + return (0, drawRow_1$1.drawRow)(literalRow, config2); + }).join(""); + let output; + output = ""; + output += (0, drawBorder_1$1.drawBorderTop)(columnWidths, config2); + output += body; + output += (0, drawBorder_1$1.drawBorderBottom)(columnWidths, config2); + output = output.trimEnd(); + process.stdout.write(output); +}; +const append = (row, columnWidths, config2) => { + const rows = prepareData([row], config2); + const body = rows.map((literalRow) => { + return (0, drawRow_1$1.drawRow)(literalRow, config2); + }).join(""); + let output = ""; + const bottom = (0, drawBorder_1$1.drawBorderBottom)(columnWidths, config2); + if (bottom !== "\n") { + output = "\r\x1B[K"; + } + output += (0, drawBorder_1$1.drawBorderJoin)(columnWidths, config2); + output += body; + output += bottom; + output = output.trimEnd(); + process.stdout.write(output); +}; +const createStream = (userConfig) => { + const config2 = (0, makeStreamConfig_1.makeStreamConfig)(userConfig); + const columnWidths = Object.values(config2.columns).map((column) => { + return column.width + column.paddingLeft + column.paddingRight; + }); + let empty = true; + return { + write: (row) => { + if (row.length !== config2.columnCount) { + throw new Error("Row cell count does not match the config.columnCount."); + } + if (empty) { + empty = false; + create(row, columnWidths, config2); + } else { + append(row, columnWidths, config2); + } + } + }; +}; +createStream$1.createStream = createStream; +var table$1 = {}; +var calculateOutputColumnWidths$1 = {}; +Object.defineProperty(calculateOutputColumnWidths$1, "__esModule", { value: true }); +calculateOutputColumnWidths$1.calculateOutputColumnWidths = void 0; +const calculateOutputColumnWidths = (config2) => { + return config2.columns.map((col) => { + return col.paddingLeft + col.width + col.paddingRight; + }); +}; +calculateOutputColumnWidths$1.calculateOutputColumnWidths = calculateOutputColumnWidths; +var drawTable$1 = {}; +Object.defineProperty(drawTable$1, "__esModule", { value: true }); +drawTable$1.drawTable = void 0; +const drawBorder_1 = drawBorder; +const drawContent_1 = drawContent$1; +const drawRow_1 = drawRow$1; +const utils_1$8 = utils; +const drawTable = (rows, outputColumnWidths, rowHeights, config2) => { + const { drawHorizontalLine, singleLine } = config2; + const contents = (0, utils_1$8.groupBySizes)(rows, rowHeights).map((group, groupIndex) => { + return group.map((row) => { + return (0, drawRow_1.drawRow)(row, { + ...config2, + rowIndex: groupIndex + }); + }).join(""); + }); + return (0, drawContent_1.drawContent)({ + contents, + drawSeparator: (index, size) => { + if (index === 0 || index === size) { + return drawHorizontalLine(index, size); + } + return !singleLine && drawHorizontalLine(index, size); + }, + elementType: "row", + rowIndex: -1, + separatorGetter: (0, drawBorder_1.createTableBorderGetter)(outputColumnWidths, { + ...config2, + rowCount: contents.length + }), + spanningCellManager: config2.spanningCellManager + }); +}; +drawTable$1.drawTable = drawTable; +var injectHeaderConfig$1 = {}; +Object.defineProperty(injectHeaderConfig$1, "__esModule", { value: true }); +injectHeaderConfig$1.injectHeaderConfig = void 0; +const injectHeaderConfig = (rows, config2) => { + var _a2; + let spanningCellConfig = (_a2 = config2.spanningCells) !== null && _a2 !== void 0 ? _a2 : []; + const headerConfig = config2.header; + const adjustedRows = [...rows]; + if (headerConfig) { + spanningCellConfig = spanningCellConfig.map(({ row, ...rest }) => { + return { + ...rest, + row: row + 1 + }; + }); + const { content, ...headerStyles } = headerConfig; + spanningCellConfig.unshift({ + alignment: "center", + col: 0, + colSpan: rows[0].length, + paddingLeft: 1, + paddingRight: 1, + row: 0, + wrapWord: false, + ...headerStyles + }); + adjustedRows.unshift([content, ...Array.from({ length: rows[0].length - 1 }).fill("")]); + } + return [ + adjustedRows, + spanningCellConfig + ]; +}; +injectHeaderConfig$1.injectHeaderConfig = injectHeaderConfig; +var makeTableConfig$1 = {}; +var calculateMaximumColumnWidths = {}; +(function(exports2) { + var __importDefault2 = commonjsGlobal && commonjsGlobal.__importDefault || function(mod) { + return mod && mod.__esModule ? mod : { "default": mod }; + }; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.calculateMaximumColumnWidths = exports2.calculateMaximumCellWidth = void 0; + const string_width_12 = __importDefault2(stringWidthExports); + const utils_12 = utils; + const calculateMaximumCellWidth = (cell) => { + return Math.max(...cell.split("\n").map(string_width_12.default)); + }; + exports2.calculateMaximumCellWidth = calculateMaximumCellWidth; + const calculateMaximumColumnWidths2 = (rows, spanningCellConfigs = []) => { + const columnWidths = new Array(rows[0].length).fill(0); + const rangeCoordinates = spanningCellConfigs.map(utils_12.calculateRangeCoordinate); + const isSpanningCell = (rowIndex, columnIndex) => { + return rangeCoordinates.some((rangeCoordinate) => { + return (0, utils_12.isCellInRange)({ + col: columnIndex, + row: rowIndex + }, rangeCoordinate); + }); + }; + rows.forEach((row, rowIndex) => { + row.forEach((cell, cellIndex) => { + if (isSpanningCell(rowIndex, cellIndex)) { + return; + } + columnWidths[cellIndex] = Math.max(columnWidths[cellIndex], (0, exports2.calculateMaximumCellWidth)(cell)); + }); + }); + return columnWidths; + }; + exports2.calculateMaximumColumnWidths = calculateMaximumColumnWidths2; +})(calculateMaximumColumnWidths); +var spanningCellManager = {}; +var alignSpanningCell = {}; +var __importDefault = commonjsGlobal && commonjsGlobal.__importDefault || function(mod) { + return mod && mod.__esModule ? mod : { "default": mod }; +}; +Object.defineProperty(alignSpanningCell, "__esModule", { value: true }); +alignSpanningCell.alignVerticalRangeContent = alignSpanningCell.wrapRangeContent = void 0; +const string_width_1 = __importDefault(stringWidthExports); +const alignString_1 = alignString$1; +const mapDataUsingRowHeights_1$1 = mapDataUsingRowHeights; +const padTableData_1$1 = padTableData; +const truncateTableData_1$1 = truncateTableData; +const utils_1$7 = utils; +const wrapCell_1 = wrapCell$1; +const wrapRangeContent = (rangeConfig, rangeWidth, context) => { + const { topLeft, paddingRight, paddingLeft, truncate, wrapWord: wrapWord2, alignment } = rangeConfig; + const originalContent = context.rows[topLeft.row][topLeft.col]; + const contentWidth = rangeWidth - paddingLeft - paddingRight; + return (0, wrapCell_1.wrapCell)((0, truncateTableData_1$1.truncateString)(originalContent, truncate), contentWidth, wrapWord2).map((line) => { + const alignedLine = (0, alignString_1.alignString)(line, contentWidth, alignment); + return (0, padTableData_1$1.padString)(alignedLine, paddingLeft, paddingRight); + }); +}; +alignSpanningCell.wrapRangeContent = wrapRangeContent; +const alignVerticalRangeContent = (range, content, context) => { + const { rows, drawHorizontalLine, rowHeights } = context; + const { topLeft, bottomRight, verticalAlignment } = range; + if (rowHeights.length === 0) { + return []; + } + const totalCellHeight = (0, utils_1$7.sumArray)(rowHeights.slice(topLeft.row, bottomRight.row + 1)); + const totalBorderHeight = bottomRight.row - topLeft.row; + const hiddenHorizontalBorderCount = (0, utils_1$7.sequence)(topLeft.row + 1, bottomRight.row).filter((horizontalBorderIndex) => { + return !drawHorizontalLine(horizontalBorderIndex, rows.length); + }).length; + const availableRangeHeight = totalCellHeight + totalBorderHeight - hiddenHorizontalBorderCount; + return (0, mapDataUsingRowHeights_1$1.padCellVertically)(content, availableRangeHeight, verticalAlignment).map((line) => { + if (line.length === 0) { + return " ".repeat((0, string_width_1.default)(content[0])); + } + return line; + }); +}; +alignSpanningCell.alignVerticalRangeContent = alignVerticalRangeContent; +var calculateSpanningCellWidth$1 = {}; +Object.defineProperty(calculateSpanningCellWidth$1, "__esModule", { value: true }); +calculateSpanningCellWidth$1.calculateSpanningCellWidth = void 0; +const utils_1$6 = utils; +const calculateSpanningCellWidth = (rangeConfig, dependencies) => { + const { columnsConfig, drawVerticalLine } = dependencies; + const { topLeft, bottomRight } = rangeConfig; + const totalWidth = (0, utils_1$6.sumArray)(columnsConfig.slice(topLeft.col, bottomRight.col + 1).map(({ width }) => { + return width; + })); + const totalPadding = topLeft.col === bottomRight.col ? columnsConfig[topLeft.col].paddingRight + columnsConfig[bottomRight.col].paddingLeft : (0, utils_1$6.sumArray)(columnsConfig.slice(topLeft.col, bottomRight.col + 1).map(({ paddingLeft, paddingRight }) => { + return paddingLeft + paddingRight; + })); + const totalBorderWidths = bottomRight.col - topLeft.col; + const totalHiddenVerticalBorders = (0, utils_1$6.sequence)(topLeft.col + 1, bottomRight.col).filter((verticalBorderIndex) => { + return !drawVerticalLine(verticalBorderIndex, columnsConfig.length); + }).length; + return totalWidth + totalPadding + totalBorderWidths - totalHiddenVerticalBorders; +}; +calculateSpanningCellWidth$1.calculateSpanningCellWidth = calculateSpanningCellWidth; +var makeRangeConfig$1 = {}; +Object.defineProperty(makeRangeConfig$1, "__esModule", { value: true }); +makeRangeConfig$1.makeRangeConfig = void 0; +const utils_1$5 = utils; +const makeRangeConfig = (spanningCellConfig, columnsConfig) => { + var _a2; + const { topLeft, bottomRight } = (0, utils_1$5.calculateRangeCoordinate)(spanningCellConfig); + const cellConfig = { + ...columnsConfig[topLeft.col], + ...spanningCellConfig, + paddingRight: (_a2 = spanningCellConfig.paddingRight) !== null && _a2 !== void 0 ? _a2 : columnsConfig[bottomRight.col].paddingRight + }; + return { + ...cellConfig, + bottomRight, + topLeft + }; +}; +makeRangeConfig$1.makeRangeConfig = makeRangeConfig; +Object.defineProperty(spanningCellManager, "__esModule", { value: true }); +spanningCellManager.createSpanningCellManager = void 0; +const alignSpanningCell_1 = alignSpanningCell; +const calculateSpanningCellWidth_1 = calculateSpanningCellWidth$1; +const makeRangeConfig_1 = makeRangeConfig$1; +const utils_1$4 = utils; +const findRangeConfig = (cell, rangeConfigs) => { + return rangeConfigs.find((rangeCoordinate) => { + return (0, utils_1$4.isCellInRange)(cell, rangeCoordinate); + }); +}; +const getContainingRange = (rangeConfig, context) => { + const width = (0, calculateSpanningCellWidth_1.calculateSpanningCellWidth)(rangeConfig, context); + const wrappedContent = (0, alignSpanningCell_1.wrapRangeContent)(rangeConfig, width, context); + const alignedContent = (0, alignSpanningCell_1.alignVerticalRangeContent)(rangeConfig, wrappedContent, context); + const getCellContent = (rowIndex) => { + const { topLeft } = rangeConfig; + const { drawHorizontalLine, rowHeights } = context; + const totalWithinHorizontalBorderHeight = rowIndex - topLeft.row; + const totalHiddenHorizontalBorderHeight = (0, utils_1$4.sequence)(topLeft.row + 1, rowIndex).filter((index) => { + return !(drawHorizontalLine === null || drawHorizontalLine === void 0 ? void 0 : drawHorizontalLine(index, rowHeights.length)); + }).length; + const offset = (0, utils_1$4.sumArray)(rowHeights.slice(topLeft.row, rowIndex)) + totalWithinHorizontalBorderHeight - totalHiddenHorizontalBorderHeight; + return alignedContent.slice(offset, offset + rowHeights[rowIndex]); + }; + const getBorderContent = (borderIndex) => { + const { topLeft } = rangeConfig; + const offset = (0, utils_1$4.sumArray)(context.rowHeights.slice(topLeft.row, borderIndex)) + (borderIndex - topLeft.row - 1); + return alignedContent[offset]; + }; + return { + ...rangeConfig, + extractBorderContent: getBorderContent, + extractCellContent: getCellContent, + height: wrappedContent.length, + width + }; +}; +const inSameRange = (cell1, cell2, ranges) => { + const range1 = findRangeConfig(cell1, ranges); + const range2 = findRangeConfig(cell2, ranges); + if (range1 && range2) { + return (0, utils_1$4.areCellEqual)(range1.topLeft, range2.topLeft); + } + return false; +}; +const hashRange = (range) => { + const { row, col } = range.topLeft; + return `${row}/${col}`; +}; +const createSpanningCellManager = (parameters) => { + const { spanningCellConfigs, columnsConfig } = parameters; + const ranges = spanningCellConfigs.map((config2) => { + return (0, makeRangeConfig_1.makeRangeConfig)(config2, columnsConfig); + }); + const rangeCache = {}; + let rowHeights = []; + let rowIndexMapping = []; + return { + getContainingRange: (cell, options) => { + var _a2; + const originalRow = (options === null || options === void 0 ? void 0 : options.mapped) ? rowIndexMapping[cell.row] : cell.row; + const range = findRangeConfig({ + ...cell, + row: originalRow + }, ranges); + if (!range) { + return void 0; + } + if (rowHeights.length === 0) { + return getContainingRange(range, { + ...parameters, + rowHeights + }); + } + const hash = hashRange(range); + (_a2 = rangeCache[hash]) !== null && _a2 !== void 0 ? _a2 : rangeCache[hash] = getContainingRange(range, { + ...parameters, + rowHeights + }); + return rangeCache[hash]; + }, + inSameRange: (cell1, cell2) => { + return inSameRange(cell1, cell2, ranges); + }, + rowHeights, + rowIndexMapping, + setRowHeights: (_rowHeights) => { + rowHeights = _rowHeights; + }, + setRowIndexMapping: (mappedRowHeights) => { + rowIndexMapping = (0, utils_1$4.flatten)(mappedRowHeights.map((height, index) => { + return Array.from({ length: height }, () => { + return index; + }); + })); + } + }; +}; +spanningCellManager.createSpanningCellManager = createSpanningCellManager; +var validateSpanningCellConfig$1 = {}; +Object.defineProperty(validateSpanningCellConfig$1, "__esModule", { value: true }); +validateSpanningCellConfig$1.validateSpanningCellConfig = void 0; +const utils_1$3 = utils; +const inRange = (start, end, value) => { + return start <= value && value <= end; +}; +const validateSpanningCellConfig = (rows, configs) => { + const [nRow, nCol] = [rows.length, rows[0].length]; + configs.forEach((config2, configIndex) => { + const { colSpan, rowSpan } = config2; + if (colSpan === void 0 && rowSpan === void 0) { + throw new Error(`Expect at least colSpan or rowSpan is provided in config.spanningCells[${configIndex}]`); + } + if (colSpan !== void 0 && colSpan < 1) { + throw new Error(`Expect colSpan is not equal zero, instead got: ${colSpan} in config.spanningCells[${configIndex}]`); + } + if (rowSpan !== void 0 && rowSpan < 1) { + throw new Error(`Expect rowSpan is not equal zero, instead got: ${rowSpan} in config.spanningCells[${configIndex}]`); + } + }); + const rangeCoordinates = configs.map(utils_1$3.calculateRangeCoordinate); + rangeCoordinates.forEach(({ topLeft, bottomRight }, rangeIndex) => { + if (!inRange(0, nCol - 1, topLeft.col) || !inRange(0, nRow - 1, topLeft.row) || !inRange(0, nCol - 1, bottomRight.col) || !inRange(0, nRow - 1, bottomRight.row)) { + throw new Error(`Some cells in config.spanningCells[${rangeIndex}] are out of the table`); + } + }); + const configOccupy = Array.from({ length: nRow }, () => { + return Array.from({ length: nCol }); + }); + rangeCoordinates.forEach(({ topLeft, bottomRight }, rangeIndex) => { + (0, utils_1$3.sequence)(topLeft.row, bottomRight.row).forEach((row) => { + (0, utils_1$3.sequence)(topLeft.col, bottomRight.col).forEach((col) => { + if (configOccupy[row][col] !== void 0) { + throw new Error(`Spanning cells in config.spanningCells[${configOccupy[row][col]}] and config.spanningCells[${rangeIndex}] are overlap each other`); + } + configOccupy[row][col] = rangeIndex; + }); + }); + }); +}; +validateSpanningCellConfig$1.validateSpanningCellConfig = validateSpanningCellConfig; +Object.defineProperty(makeTableConfig$1, "__esModule", { value: true }); +makeTableConfig$1.makeTableConfig = void 0; +const calculateMaximumColumnWidths_1 = calculateMaximumColumnWidths; +const spanningCellManager_1 = spanningCellManager; +const utils_1$2 = utils; +const validateConfig_1 = validateConfig$1; +const validateSpanningCellConfig_1 = validateSpanningCellConfig$1; +const makeColumnsConfig = (rows, columns, columnDefault, spanningCellConfigs) => { + const columnWidths = (0, calculateMaximumColumnWidths_1.calculateMaximumColumnWidths)(rows, spanningCellConfigs); + return rows[0].map((_, columnIndex) => { + return { + alignment: "left", + paddingLeft: 1, + paddingRight: 1, + truncate: Number.POSITIVE_INFINITY, + verticalAlignment: "top", + width: columnWidths[columnIndex], + wrapWord: false, + ...columnDefault, + ...columns === null || columns === void 0 ? void 0 : columns[columnIndex] + }; + }); +}; +const makeTableConfig = (rows, config2 = {}, injectedSpanningCellConfig) => { + var _a2, _b2, _c2, _d2, _e2; + (0, validateConfig_1.validateConfig)("config.json", config2); + (0, validateSpanningCellConfig_1.validateSpanningCellConfig)(rows, (_a2 = config2.spanningCells) !== null && _a2 !== void 0 ? _a2 : []); + const spanningCellConfigs = (_b2 = injectedSpanningCellConfig !== null && injectedSpanningCellConfig !== void 0 ? injectedSpanningCellConfig : config2.spanningCells) !== null && _b2 !== void 0 ? _b2 : []; + const columnsConfig = makeColumnsConfig(rows, config2.columns, config2.columnDefault, spanningCellConfigs); + const drawVerticalLine = (_c2 = config2.drawVerticalLine) !== null && _c2 !== void 0 ? _c2 : () => { + return true; + }; + const drawHorizontalLine = (_d2 = config2.drawHorizontalLine) !== null && _d2 !== void 0 ? _d2 : () => { + return true; + }; + return { + ...config2, + border: (0, utils_1$2.makeBorderConfig)(config2.border), + columns: columnsConfig, + drawHorizontalLine, + drawVerticalLine, + singleLine: (_e2 = config2.singleLine) !== null && _e2 !== void 0 ? _e2 : false, + spanningCellManager: (0, spanningCellManager_1.createSpanningCellManager)({ + columnsConfig, + drawHorizontalLine, + drawVerticalLine, + rows, + spanningCellConfigs + }) + }; +}; +makeTableConfig$1.makeTableConfig = makeTableConfig; +var validateTableData$1 = {}; +Object.defineProperty(validateTableData$1, "__esModule", { value: true }); +validateTableData$1.validateTableData = void 0; +const utils_1$1 = utils; +const validateTableData = (rows) => { + if (!Array.isArray(rows)) { + throw new TypeError("Table data must be an array."); + } + if (rows.length === 0) { + throw new Error("Table must define at least one row."); + } + if (rows[0].length === 0) { + throw new Error("Table must define at least one column."); + } + const columnNumber = rows[0].length; + for (const row of rows) { + if (!Array.isArray(row)) { + throw new TypeError("Table row data must be an array."); + } + if (row.length !== columnNumber) { + throw new Error("Table must have a consistent number of cells."); + } + for (const cell of row) { + if (/[\u0001-\u0006\u0008\u0009\u000B-\u001A]/.test((0, utils_1$1.normalizeString)(String(cell)))) { + throw new Error("Table data must not contain control characters."); + } + } + } +}; +validateTableData$1.validateTableData = validateTableData; +Object.defineProperty(table$1, "__esModule", { value: true }); +table$1.table = void 0; +const alignTableData_1 = alignTableData$1; +const calculateOutputColumnWidths_1 = calculateOutputColumnWidths$1; +const calculateRowHeights_1 = calculateRowHeights$1; +const drawTable_1 = drawTable$1; +const injectHeaderConfig_1 = injectHeaderConfig$1; +const makeTableConfig_1 = makeTableConfig$1; +const mapDataUsingRowHeights_1 = mapDataUsingRowHeights; +const padTableData_1 = padTableData; +const stringifyTableData_1 = stringifyTableData$1; +const truncateTableData_1 = truncateTableData; +const utils_1 = utils; +const validateTableData_1 = validateTableData$1; +const table = (data2, userConfig = {}) => { + (0, validateTableData_1.validateTableData)(data2); + let rows = (0, stringifyTableData_1.stringifyTableData)(data2); + const [injectedRows, injectedSpanningCellConfig] = (0, injectHeaderConfig_1.injectHeaderConfig)(rows, userConfig); + const config2 = (0, makeTableConfig_1.makeTableConfig)(injectedRows, userConfig, injectedSpanningCellConfig); + rows = (0, truncateTableData_1.truncateTableData)(injectedRows, (0, utils_1.extractTruncates)(config2)); + const rowHeights = (0, calculateRowHeights_1.calculateRowHeights)(rows, config2); + config2.spanningCellManager.setRowHeights(rowHeights); + config2.spanningCellManager.setRowIndexMapping(rowHeights); + rows = (0, mapDataUsingRowHeights_1.mapDataUsingRowHeights)(rows, rowHeights, config2); + rows = (0, alignTableData_1.alignTableData)(rows, config2); + rows = (0, padTableData_1.padTableData)(rows, config2); + const outputColumnWidths = (0, calculateOutputColumnWidths_1.calculateOutputColumnWidths)(config2); + return (0, drawTable_1.drawTable)(rows, outputColumnWidths, rowHeights, config2); +}; +table$1.table = table; +var api = {}; +Object.defineProperty(api, "__esModule", { value: true }); +(function(exports2) { + var __createBinding = commonjsGlobal && commonjsGlobal.__createBinding || (Object.create ? function(o2, m, k, k2) { + if (k2 === void 0) k2 = k; + Object.defineProperty(o2, k2, { enumerable: true, get: function() { + return m[k]; + } }); + } : function(o2, m, k, k2) { + if (k2 === void 0) k2 = k; + o2[k2] = m[k]; + }); + var __exportStar = commonjsGlobal && commonjsGlobal.__exportStar || function(m, exports3) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p); + }; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.getBorderCharacters = exports2.createStream = exports2.table = void 0; + const createStream_1 = createStream$1; + Object.defineProperty(exports2, "createStream", { enumerable: true, get: function() { + return createStream_1.createStream; + } }); + const getBorderCharacters_12 = getBorderCharacters$1; + Object.defineProperty(exports2, "getBorderCharacters", { enumerable: true, get: function() { + return getBorderCharacters_12.getBorderCharacters; + } }); + const table_1 = table$1; + Object.defineProperty(exports2, "table", { enumerable: true, get: function() { + return table_1.table; + } }); + __exportStar(api, exports2); +})(src); +const colorsCmd = new Command2().name("colors").description("Manipulate custom colors"); +colorsCmd.command("list").description("lists all custom colors").action(async () => { + const api2 = getAPIClient(); + try { + const colors = (await api2.colors.list.query()).colors; + if (getGlobalOptions().json) { + printObject(colors); + } else { + const data2 = [["Name", "Hexcode", "Inverse"]]; + colors.forEach((color) => { + data2.push([color.name, color.hexcode, color.inverse]); + }); + console.log( + data2.length <= 1 ? "No colors found. Add one with `lifetracker colors create `" : src.table(data2, { + // border: getBorderCharacters("ramac"), + // singleLine: true, + drawVerticalLine: (lineIndex, columnCount) => { + return lineIndex === 0 || lineIndex === columnCount; + }, + drawHorizontalLine: (lineIndex, rowCount) => { + return lineIndex < 2 || lineIndex === rowCount; + } + }) + ); + } + } catch (error2) { + printErrorMessageWithReason("Failed to list all colors", error2); + } +}); +colorsCmd.command("create").description("create a color").argument("", "the name of the color").argument("", "the hexcode of the color").action(async (name2, hexcode) => { + const api2 = getAPIClient(); + await api2.colors.create.mutate({ + name: name2, + hexcode + }).then(printSuccess(`Successfully created the color "${name2}"`)).catch(printError(`Failed to create the color "${name2}"`)); +}); +colorsCmd.command("delete").description("delete a color").argument("", "the name of the color").action(async (name2) => { + const api2 = getAPIClient(); + await api2.colors.delete.mutate({ + colorName: name2 + }).then(printSuccess(`Successfully deleted the color "${name2}"`)).catch(printError(`Failed to delete the color "${name2}"`)); +}); +const categoriesCmd = new Command2().name("categories").description("Manipulate categories"); +categoriesCmd.command("list").description("lists all defined categories").action(async () => { + const api2 = getAPIClient(); + try { + const categories = (await api2.categories.list.query()).categories; + if (getGlobalOptions().json) { + printObject(categories); + } else { + const data2 = [["Code", "Name", "Description", "Color"]]; + categories.forEach((c) => { + data2.push([c.code.toString(), c.name, c.description ?? "none", c.color.name]); + }); + console.log( + data2.length <= 1 ? "No categories found. Add one with `lifetracker categories create `" : src.table(data2, { + // border: getBorderCharacters("ramac"), + // singleLine: true, + drawVerticalLine: (lineIndex, columnCount) => { + return lineIndex === 0 || lineIndex === columnCount; + }, + drawHorizontalLine: (lineIndex, rowCount) => { + return lineIndex < 2 || lineIndex === rowCount; + } + }) + ); + } + } catch (error2) { + printErrorMessageWithReason("Failed to list all categories", error2); + } +}); +categoriesCmd.command("create").description("create a category").argument("", "the code of the category").argument("", "the name of the category").argument("", "the description of the category").argument("[color]", "the color of the category").option("-p, --parent ", "specify a parent category by code").action(async (codeStr, name2, description2, colorName2, flags) => { + const api2 = getAPIClient(); + const color = (flags == null ? void 0 : flags.parent) === void 0 ? await api2.colors.get.query({ colorName: colorName2 }) : (await api2.categories.get.query({ categoryCode: parseInt(flags.parent) })).color; + try { + await api2.categories.create.mutate({ + code: parseFloat(codeStr), + name: name2, + description: description2, + color + }).then(printSuccess(`Successfully created the category "${name2}"`)).catch(printError(`Failed to create the category "${name2}"`)); + api2.categories.list; + } catch (e) { + console.log(e); + } +}); +categoriesCmd.command("delete").description("delete a category").argument("", "the code of the category").action(async (codeStr) => { + const api2 = getAPIClient(); + try { + await api2.categories.delete.mutate({ + categoryCode: parseInt(codeStr) + }).then(printSuccess(`Successfully deleted category "${codeStr}"`)).catch(printError(`Failed to delete category "${codeStr}"`)); + } catch (e) { + console.log(e); + } +}); +const millisecondsInWeek = 6048e5; +const millisecondsInDay = 864e5; +const constructFromSymbol = Symbol.for("constructDateFrom"); +function constructFrom(date2, value) { + if (typeof date2 === "function") return date2(value); + if (date2 && typeof date2 === "object" && constructFromSymbol in date2) + return date2[constructFromSymbol](value); + if (date2 instanceof Date) return new date2.constructor(value); + return new Date(value); +} +function toDate(argument2, context) { + return constructFrom(context || argument2, argument2); +} +let defaultOptions = {}; +function getDefaultOptions() { + return defaultOptions; +} +function startOfWeek(date2, options) { + var _a2, _b2, _c2, _d2; + const defaultOptions2 = getDefaultOptions(); + const weekStartsOn = (options == null ? void 0 : options.weekStartsOn) ?? ((_b2 = (_a2 = options == null ? void 0 : options.locale) == null ? void 0 : _a2.options) == null ? void 0 : _b2.weekStartsOn) ?? defaultOptions2.weekStartsOn ?? ((_d2 = (_c2 = defaultOptions2.locale) == null ? void 0 : _c2.options) == null ? void 0 : _d2.weekStartsOn) ?? 0; + const _date = toDate(date2, options == null ? void 0 : options.in); + const day = _date.getDay(); + const diff2 = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; + _date.setDate(_date.getDate() - diff2); + _date.setHours(0, 0, 0, 0); + return _date; +} +function startOfISOWeek(date2, options) { + return startOfWeek(date2, { ...options, weekStartsOn: 1 }); +} +function getISOWeekYear(date2, options) { + const _date = toDate(date2, options == null ? void 0 : options.in); + const year2 = _date.getFullYear(); + const fourthOfJanuaryOfNextYear = constructFrom(_date, 0); + fourthOfJanuaryOfNextYear.setFullYear(year2 + 1, 0, 4); + fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0); + const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear); + const fourthOfJanuaryOfThisYear = constructFrom(_date, 0); + fourthOfJanuaryOfThisYear.setFullYear(year2, 0, 4); + fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0); + const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear); + if (_date.getTime() >= startOfNextYear.getTime()) { + return year2 + 1; + } else if (_date.getTime() >= startOfThisYear.getTime()) { + return year2; + } else { + return year2 - 1; + } +} +function getTimezoneOffsetInMilliseconds(date2) { + const _date = toDate(date2); + const utcDate = new Date( + Date.UTC( + _date.getFullYear(), + _date.getMonth(), + _date.getDate(), + _date.getHours(), + _date.getMinutes(), + _date.getSeconds(), + _date.getMilliseconds() + ) + ); + utcDate.setUTCFullYear(_date.getFullYear()); + return +date2 - +utcDate; +} +function normalizeDates(context, ...dates2) { + const normalize2 = constructFrom.bind( + null, + dates2.find((date2) => typeof date2 === "object") + ); + return dates2.map(normalize2); +} +function startOfDay(date2, options) { + const _date = toDate(date2, options == null ? void 0 : options.in); + _date.setHours(0, 0, 0, 0); + return _date; +} +function differenceInCalendarDays(laterDate, earlierDate, options) { + const [laterDate_, earlierDate_] = normalizeDates( + options == null ? void 0 : options.in, + laterDate, + earlierDate + ); + const laterStartOfDay = startOfDay(laterDate_); + const earlierStartOfDay = startOfDay(earlierDate_); + const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay); + const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay); + return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay); +} +function startOfISOWeekYear(date2, options) { + const year2 = getISOWeekYear(date2, options); + const fourthOfJanuary = constructFrom(date2, 0); + fourthOfJanuary.setFullYear(year2, 0, 4); + fourthOfJanuary.setHours(0, 0, 0, 0); + return startOfISOWeek(fourthOfJanuary); +} +function isDate$1(value) { + return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]"; +} +function isValid(date2) { + return !(!isDate$1(date2) && typeof date2 !== "number" || isNaN(+toDate(date2))); +} +function startOfYear(date2, options) { + const date_ = toDate(date2, options == null ? void 0 : options.in); + date_.setFullYear(date_.getFullYear(), 0, 1); + date_.setHours(0, 0, 0, 0); + return date_; +} +const formatDistanceLocale = { + lessThanXSeconds: { + one: "less than a second", + other: "less than {{count}} seconds" + }, + xSeconds: { + one: "1 second", + other: "{{count}} seconds" + }, + halfAMinute: "half a minute", + lessThanXMinutes: { + one: "less than a minute", + other: "less than {{count}} minutes" + }, + xMinutes: { + one: "1 minute", + other: "{{count}} minutes" + }, + aboutXHours: { + one: "about 1 hour", + other: "about {{count}} hours" + }, + xHours: { + one: "1 hour", + other: "{{count}} hours" + }, + xDays: { + one: "1 day", + other: "{{count}} days" + }, + aboutXWeeks: { + one: "about 1 week", + other: "about {{count}} weeks" + }, + xWeeks: { + one: "1 week", + other: "{{count}} weeks" + }, + aboutXMonths: { + one: "about 1 month", + other: "about {{count}} months" + }, + xMonths: { + one: "1 month", + other: "{{count}} months" + }, + aboutXYears: { + one: "about 1 year", + other: "about {{count}} years" + }, + xYears: { + one: "1 year", + other: "{{count}} years" + }, + overXYears: { + one: "over 1 year", + other: "over {{count}} years" + }, + almostXYears: { + one: "almost 1 year", + other: "almost {{count}} years" + } +}; +const formatDistance = (token, count, options) => { + let result; + const tokenValue = formatDistanceLocale[token]; + if (typeof tokenValue === "string") { + result = tokenValue; + } else if (count === 1) { + result = tokenValue.one; + } else { + result = tokenValue.other.replace("{{count}}", count.toString()); + } + if (options == null ? void 0 : options.addSuffix) { + if (options.comparison && options.comparison > 0) { + return "in " + result; + } else { + return result + " ago"; + } + } + return result; +}; +function buildFormatLongFn(args) { + return (options = {}) => { + const width = options.width ? String(options.width) : args.defaultWidth; + const format2 = args.formats[width] || args.formats[args.defaultWidth]; + return format2; + }; +} +const dateFormats = { + full: "EEEE, MMMM do, y", + long: "MMMM do, y", + medium: "MMM d, y", + short: "MM/dd/yyyy" +}; +const timeFormats = { + full: "h:mm:ss a zzzz", + long: "h:mm:ss a z", + medium: "h:mm:ss a", + short: "h:mm a" +}; +const dateTimeFormats = { + full: "{{date}} 'at' {{time}}", + long: "{{date}} 'at' {{time}}", + medium: "{{date}}, {{time}}", + short: "{{date}}, {{time}}" +}; +const formatLong = { + date: buildFormatLongFn({ + formats: dateFormats, + defaultWidth: "full" + }), + time: buildFormatLongFn({ + formats: timeFormats, + defaultWidth: "full" + }), + dateTime: buildFormatLongFn({ + formats: dateTimeFormats, + defaultWidth: "full" + }) +}; +const formatRelativeLocale = { + lastWeek: "'last' eeee 'at' p", + yesterday: "'yesterday at' p", + today: "'today at' p", + tomorrow: "'tomorrow at' p", + nextWeek: "eeee 'at' p", + other: "P" +}; +const formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token]; +function buildLocalizeFn(args) { + return (value, options) => { + const context = (options == null ? void 0 : options.context) ? String(options.context) : "standalone"; + let valuesArray; + if (context === "formatting" && args.formattingValues) { + const defaultWidth = args.defaultFormattingWidth || args.defaultWidth; + const width = (options == null ? void 0 : options.width) ? String(options.width) : defaultWidth; + valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth]; + } else { + const defaultWidth = args.defaultWidth; + const width = (options == null ? void 0 : options.width) ? String(options.width) : args.defaultWidth; + valuesArray = args.values[width] || args.values[defaultWidth]; + } + const index = args.argumentCallback ? args.argumentCallback(value) : value; + return valuesArray[index]; + }; +} +const eraValues = { + narrow: ["B", "A"], + abbreviated: ["BC", "AD"], + wide: ["Before Christ", "Anno Domini"] +}; +const quarterValues = { + narrow: ["1", "2", "3", "4"], + abbreviated: ["Q1", "Q2", "Q3", "Q4"], + wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"] +}; +const monthValues = { + narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"], + abbreviated: [ + "Jan", + "Feb", + "Mar", + "Apr", + "May", + "Jun", + "Jul", + "Aug", + "Sep", + "Oct", + "Nov", + "Dec" + ], + wide: [ + "January", + "February", + "March", + "April", + "May", + "June", + "July", + "August", + "September", + "October", + "November", + "December" + ] +}; +const dayValues = { + narrow: ["S", "M", "T", "W", "T", "F", "S"], + short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], + abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], + wide: [ + "Sunday", + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday" + ] +}; +const dayPeriodValues = { + narrow: { + am: "a", + pm: "p", + midnight: "mi", + noon: "n", + morning: "morning", + afternoon: "afternoon", + evening: "evening", + night: "night" + }, + abbreviated: { + am: "AM", + pm: "PM", + midnight: "midnight", + noon: "noon", + morning: "morning", + afternoon: "afternoon", + evening: "evening", + night: "night" + }, + wide: { + am: "a.m.", + pm: "p.m.", + midnight: "midnight", + noon: "noon", + morning: "morning", + afternoon: "afternoon", + evening: "evening", + night: "night" + } +}; +const formattingDayPeriodValues = { + narrow: { + am: "a", + pm: "p", + midnight: "mi", + noon: "n", + morning: "in the morning", + afternoon: "in the afternoon", + evening: "in the evening", + night: "at night" + }, + abbreviated: { + am: "AM", + pm: "PM", + midnight: "midnight", + noon: "noon", + morning: "in the morning", + afternoon: "in the afternoon", + evening: "in the evening", + night: "at night" + }, + wide: { + am: "a.m.", + pm: "p.m.", + midnight: "midnight", + noon: "noon", + morning: "in the morning", + afternoon: "in the afternoon", + evening: "in the evening", + night: "at night" + } +}; +const ordinalNumber = (dirtyNumber, _options) => { + const number = Number(dirtyNumber); + const rem100 = number % 100; + if (rem100 > 20 || rem100 < 10) { + switch (rem100 % 10) { + case 1: + return number + "st"; + case 2: + return number + "nd"; + case 3: + return number + "rd"; + } + } + return number + "th"; +}; +const localize = { + ordinalNumber, + era: buildLocalizeFn({ + values: eraValues, + defaultWidth: "wide" + }), + quarter: buildLocalizeFn({ + values: quarterValues, + defaultWidth: "wide", + argumentCallback: (quarter) => quarter - 1 + }), + month: buildLocalizeFn({ + values: monthValues, + defaultWidth: "wide" + }), + day: buildLocalizeFn({ + values: dayValues, + defaultWidth: "wide" + }), + dayPeriod: buildLocalizeFn({ + values: dayPeriodValues, + defaultWidth: "wide", + formattingValues: formattingDayPeriodValues, + defaultFormattingWidth: "wide" + }) +}; +function buildMatchFn(args) { + return (string, options = {}) => { + const width = options.width; + const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth]; + const matchResult = string.match(matchPattern); + if (!matchResult) { + return null; + } + const matchedString = matchResult[0]; + const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth]; + const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : ( + // [TODO] -- I challenge you to fix the type + findKey(parsePatterns, (pattern) => pattern.test(matchedString)) + ); + let value; + value = args.valueCallback ? args.valueCallback(key) : key; + value = options.valueCallback ? ( + // [TODO] -- I challenge you to fix the type + options.valueCallback(value) + ) : value; + const rest = string.slice(matchedString.length); + return { value, rest }; + }; +} +function findKey(object, predicate) { + for (const key in object) { + if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) { + return key; + } + } + return void 0; +} +function findIndex(array, predicate) { + for (let key = 0; key < array.length; key++) { + if (predicate(array[key])) { + return key; + } + } + return void 0; +} +function buildMatchPatternFn(args) { + return (string, options = {}) => { + const matchResult = string.match(args.matchPattern); + if (!matchResult) return null; + const matchedString = matchResult[0]; + const parseResult = string.match(args.parsePattern); + if (!parseResult) return null; + let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0]; + value = options.valueCallback ? options.valueCallback(value) : value; + const rest = string.slice(matchedString.length); + return { value, rest }; + }; +} +const matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i; +const parseOrdinalNumberPattern = /\d+/i; +const matchEraPatterns = { + narrow: /^(b|a)/i, + abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i, + wide: /^(before christ|before common era|anno domini|common era)/i +}; +const parseEraPatterns = { + any: [/^b/i, /^(a|c)/i] +}; +const matchQuarterPatterns = { + narrow: /^[1234]/i, + abbreviated: /^q[1234]/i, + wide: /^[1234](th|st|nd|rd)? quarter/i +}; +const parseQuarterPatterns = { + any: [/1/i, /2/i, /3/i, /4/i] +}; +const matchMonthPatterns = { + narrow: /^[jfmasond]/i, + abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i, + wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i +}; +const parseMonthPatterns = { + narrow: [ + /^j/i, + /^f/i, + /^m/i, + /^a/i, + /^m/i, + /^j/i, + /^j/i, + /^a/i, + /^s/i, + /^o/i, + /^n/i, + /^d/i + ], + any: [ + /^ja/i, + /^f/i, + /^mar/i, + /^ap/i, + /^may/i, + /^jun/i, + /^jul/i, + /^au/i, + /^s/i, + /^o/i, + /^n/i, + /^d/i + ] +}; +const matchDayPatterns = { + narrow: /^[smtwf]/i, + short: /^(su|mo|tu|we|th|fr|sa)/i, + abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i, + wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i +}; +const parseDayPatterns = { + narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i], + any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i] +}; +const matchDayPeriodPatterns = { + narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i, + any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i +}; +const parseDayPeriodPatterns = { + any: { + am: /^a/i, + pm: /^p/i, + midnight: /^mi/i, + noon: /^no/i, + morning: /morning/i, + afternoon: /afternoon/i, + evening: /evening/i, + night: /night/i + } +}; +const match = { + ordinalNumber: buildMatchPatternFn({ + matchPattern: matchOrdinalNumberPattern, + parsePattern: parseOrdinalNumberPattern, + valueCallback: (value) => parseInt(value, 10) + }), + era: buildMatchFn({ + matchPatterns: matchEraPatterns, + defaultMatchWidth: "wide", + parsePatterns: parseEraPatterns, + defaultParseWidth: "any" + }), + quarter: buildMatchFn({ + matchPatterns: matchQuarterPatterns, + defaultMatchWidth: "wide", + parsePatterns: parseQuarterPatterns, + defaultParseWidth: "any", + valueCallback: (index) => index + 1 + }), + month: buildMatchFn({ + matchPatterns: matchMonthPatterns, + defaultMatchWidth: "wide", + parsePatterns: parseMonthPatterns, + defaultParseWidth: "any" + }), + day: buildMatchFn({ + matchPatterns: matchDayPatterns, + defaultMatchWidth: "wide", + parsePatterns: parseDayPatterns, + defaultParseWidth: "any" + }), + dayPeriod: buildMatchFn({ + matchPatterns: matchDayPeriodPatterns, + defaultMatchWidth: "any", + parsePatterns: parseDayPeriodPatterns, + defaultParseWidth: "any" + }) +}; +const enUS = { + code: "en-US", + formatDistance, + formatLong, + formatRelative, + localize, + match, + options: { + weekStartsOn: 0, + firstWeekContainsDate: 1 + } +}; +function getDayOfYear(date2, options) { + const _date = toDate(date2, options == null ? void 0 : options.in); + const diff2 = differenceInCalendarDays(_date, startOfYear(_date)); + const dayOfYear2 = diff2 + 1; + return dayOfYear2; +} +function getISOWeek(date2, options) { + const _date = toDate(date2, options == null ? void 0 : options.in); + const diff2 = +startOfISOWeek(_date) - +startOfISOWeekYear(_date); + return Math.round(diff2 / millisecondsInWeek) + 1; +} +function getWeekYear(date2, options) { + var _a2, _b2, _c2, _d2; + const _date = toDate(date2, options == null ? void 0 : options.in); + const year2 = _date.getFullYear(); + const defaultOptions2 = getDefaultOptions(); + const firstWeekContainsDate = (options == null ? void 0 : options.firstWeekContainsDate) ?? ((_b2 = (_a2 = options == null ? void 0 : options.locale) == null ? void 0 : _a2.options) == null ? void 0 : _b2.firstWeekContainsDate) ?? defaultOptions2.firstWeekContainsDate ?? ((_d2 = (_c2 = defaultOptions2.locale) == null ? void 0 : _c2.options) == null ? void 0 : _d2.firstWeekContainsDate) ?? 1; + const firstWeekOfNextYear = constructFrom((options == null ? void 0 : options.in) || date2, 0); + firstWeekOfNextYear.setFullYear(year2 + 1, 0, firstWeekContainsDate); + firstWeekOfNextYear.setHours(0, 0, 0, 0); + const startOfNextYear = startOfWeek(firstWeekOfNextYear, options); + const firstWeekOfThisYear = constructFrom((options == null ? void 0 : options.in) || date2, 0); + firstWeekOfThisYear.setFullYear(year2, 0, firstWeekContainsDate); + firstWeekOfThisYear.setHours(0, 0, 0, 0); + const startOfThisYear = startOfWeek(firstWeekOfThisYear, options); + if (+_date >= +startOfNextYear) { + return year2 + 1; + } else if (+_date >= +startOfThisYear) { + return year2; + } else { + return year2 - 1; + } +} +function startOfWeekYear(date2, options) { + var _a2, _b2, _c2, _d2; + const defaultOptions2 = getDefaultOptions(); + const firstWeekContainsDate = (options == null ? void 0 : options.firstWeekContainsDate) ?? ((_b2 = (_a2 = options == null ? void 0 : options.locale) == null ? void 0 : _a2.options) == null ? void 0 : _b2.firstWeekContainsDate) ?? defaultOptions2.firstWeekContainsDate ?? ((_d2 = (_c2 = defaultOptions2.locale) == null ? void 0 : _c2.options) == null ? void 0 : _d2.firstWeekContainsDate) ?? 1; + const year2 = getWeekYear(date2, options); + const firstWeek = constructFrom((options == null ? void 0 : options.in) || date2, 0); + firstWeek.setFullYear(year2, 0, firstWeekContainsDate); + firstWeek.setHours(0, 0, 0, 0); + const _date = startOfWeek(firstWeek, options); + return _date; +} +function getWeek(date2, options) { + const _date = toDate(date2, options == null ? void 0 : options.in); + const diff2 = +startOfWeek(_date, options) - +startOfWeekYear(_date, options); + return Math.round(diff2 / millisecondsInWeek) + 1; +} +function addLeadingZeros(number, targetLength) { + const sign = number < 0 ? "-" : ""; + const output = Math.abs(number).toString().padStart(targetLength, "0"); + return sign + output; +} +const lightFormatters = { + // Year + y(date2, token) { + const signedYear = date2.getFullYear(); + const year2 = signedYear > 0 ? signedYear : 1 - signedYear; + return addLeadingZeros(token === "yy" ? year2 % 100 : year2, token.length); + }, + // Month + M(date2, token) { + const month2 = date2.getMonth(); + return token === "M" ? String(month2 + 1) : addLeadingZeros(month2 + 1, 2); + }, + // Day of the month + d(date2, token) { + return addLeadingZeros(date2.getDate(), token.length); + }, + // AM or PM + a(date2, token) { + const dayPeriodEnumValue = date2.getHours() / 12 >= 1 ? "pm" : "am"; + switch (token) { + case "a": + case "aa": + return dayPeriodEnumValue.toUpperCase(); + case "aaa": + return dayPeriodEnumValue; + case "aaaaa": + return dayPeriodEnumValue[0]; + case "aaaa": + default: + return dayPeriodEnumValue === "am" ? "a.m." : "p.m."; + } + }, + // Hour [1-12] + h(date2, token) { + return addLeadingZeros(date2.getHours() % 12 || 12, token.length); + }, + // Hour [0-23] + H(date2, token) { + return addLeadingZeros(date2.getHours(), token.length); + }, + // Minute + m(date2, token) { + return addLeadingZeros(date2.getMinutes(), token.length); + }, + // Second + s(date2, token) { + return addLeadingZeros(date2.getSeconds(), token.length); + }, + // Fraction of second + S(date2, token) { + const numberOfDigits = token.length; + const milliseconds2 = date2.getMilliseconds(); + const fractionalSeconds = Math.trunc( + milliseconds2 * Math.pow(10, numberOfDigits - 3) + ); + return addLeadingZeros(fractionalSeconds, token.length); + } +}; +const dayPeriodEnum = { + am: "am", + pm: "pm", + midnight: "midnight", + noon: "noon", + morning: "morning", + afternoon: "afternoon", + evening: "evening", + night: "night" +}; +const formatters = { + // Era + G: function(date2, token, localize2) { + const era = date2.getFullYear() > 0 ? 1 : 0; + switch (token) { + case "G": + case "GG": + case "GGG": + return localize2.era(era, { width: "abbreviated" }); + case "GGGGG": + return localize2.era(era, { width: "narrow" }); + case "GGGG": + default: + return localize2.era(era, { width: "wide" }); + } + }, + // Year + y: function(date2, token, localize2) { + if (token === "yo") { + const signedYear = date2.getFullYear(); + const year2 = signedYear > 0 ? signedYear : 1 - signedYear; + return localize2.ordinalNumber(year2, { unit: "year" }); + } + return lightFormatters.y(date2, token); + }, + // Local week-numbering year + Y: function(date2, token, localize2, options) { + const signedWeekYear = getWeekYear(date2, options); + const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; + if (token === "YY") { + const twoDigitYear = weekYear % 100; + return addLeadingZeros(twoDigitYear, 2); + } + if (token === "Yo") { + return localize2.ordinalNumber(weekYear, { unit: "year" }); + } + return addLeadingZeros(weekYear, token.length); + }, + // ISO week-numbering year + R: function(date2, token) { + const isoWeekYear = getISOWeekYear(date2); + return addLeadingZeros(isoWeekYear, token.length); + }, + // Extended year. This is a single number designating the year of this calendar system. + // The main difference between `y` and `u` localizers are B.C. years: + // | Year | `y` | `u` | + // |------|-----|-----| + // | AC 1 | 1 | 1 | + // | BC 1 | 1 | 0 | + // | BC 2 | 2 | -1 | + // Also `yy` always returns the last two digits of a year, + // while `uu` pads single digit years to 2 characters and returns other years unchanged. + u: function(date2, token) { + const year2 = date2.getFullYear(); + return addLeadingZeros(year2, token.length); + }, + // Quarter + Q: function(date2, token, localize2) { + const quarter = Math.ceil((date2.getMonth() + 1) / 3); + switch (token) { + case "Q": + return String(quarter); + case "QQ": + return addLeadingZeros(quarter, 2); + case "Qo": + return localize2.ordinalNumber(quarter, { unit: "quarter" }); + case "QQQ": + return localize2.quarter(quarter, { + width: "abbreviated", + context: "formatting" + }); + case "QQQQQ": + return localize2.quarter(quarter, { + width: "narrow", + context: "formatting" + }); + case "QQQQ": + default: + return localize2.quarter(quarter, { + width: "wide", + context: "formatting" + }); + } + }, + // Stand-alone quarter + q: function(date2, token, localize2) { + const quarter = Math.ceil((date2.getMonth() + 1) / 3); + switch (token) { + case "q": + return String(quarter); + case "qq": + return addLeadingZeros(quarter, 2); + case "qo": + return localize2.ordinalNumber(quarter, { unit: "quarter" }); + case "qqq": + return localize2.quarter(quarter, { + width: "abbreviated", + context: "standalone" + }); + case "qqqqq": + return localize2.quarter(quarter, { + width: "narrow", + context: "standalone" + }); + case "qqqq": + default: + return localize2.quarter(quarter, { + width: "wide", + context: "standalone" + }); + } + }, + // Month + M: function(date2, token, localize2) { + const month2 = date2.getMonth(); + switch (token) { + case "M": + case "MM": + return lightFormatters.M(date2, token); + case "Mo": + return localize2.ordinalNumber(month2 + 1, { unit: "month" }); + case "MMM": + return localize2.month(month2, { + width: "abbreviated", + context: "formatting" + }); + case "MMMMM": + return localize2.month(month2, { + width: "narrow", + context: "formatting" + }); + case "MMMM": + default: + return localize2.month(month2, { width: "wide", context: "formatting" }); + } + }, + // Stand-alone month + L: function(date2, token, localize2) { + const month2 = date2.getMonth(); + switch (token) { + case "L": + return String(month2 + 1); + case "LL": + return addLeadingZeros(month2 + 1, 2); + case "Lo": + return localize2.ordinalNumber(month2 + 1, { unit: "month" }); + case "LLL": + return localize2.month(month2, { + width: "abbreviated", + context: "standalone" + }); + case "LLLLL": + return localize2.month(month2, { + width: "narrow", + context: "standalone" + }); + case "LLLL": + default: + return localize2.month(month2, { width: "wide", context: "standalone" }); + } + }, + // Local week of year + w: function(date2, token, localize2, options) { + const week2 = getWeek(date2, options); + if (token === "wo") { + return localize2.ordinalNumber(week2, { unit: "week" }); + } + return addLeadingZeros(week2, token.length); + }, + // ISO week of year + I: function(date2, token, localize2) { + const isoWeek = getISOWeek(date2); + if (token === "Io") { + return localize2.ordinalNumber(isoWeek, { unit: "week" }); + } + return addLeadingZeros(isoWeek, token.length); + }, + // Day of the month + d: function(date2, token, localize2) { + if (token === "do") { + return localize2.ordinalNumber(date2.getDate(), { unit: "date" }); + } + return lightFormatters.d(date2, token); + }, + // Day of year + D: function(date2, token, localize2) { + const dayOfYear2 = getDayOfYear(date2); + if (token === "Do") { + return localize2.ordinalNumber(dayOfYear2, { unit: "dayOfYear" }); + } + return addLeadingZeros(dayOfYear2, token.length); + }, + // Day of week + E: function(date2, token, localize2) { + const dayOfWeek = date2.getDay(); + switch (token) { + case "E": + case "EE": + case "EEE": + return localize2.day(dayOfWeek, { + width: "abbreviated", + context: "formatting" + }); + case "EEEEE": + return localize2.day(dayOfWeek, { + width: "narrow", + context: "formatting" + }); + case "EEEEEE": + return localize2.day(dayOfWeek, { + width: "short", + context: "formatting" + }); + case "EEEE": + default: + return localize2.day(dayOfWeek, { + width: "wide", + context: "formatting" + }); + } + }, + // Local day of week + e: function(date2, token, localize2, options) { + const dayOfWeek = date2.getDay(); + const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; + switch (token) { + case "e": + return String(localDayOfWeek); + case "ee": + return addLeadingZeros(localDayOfWeek, 2); + case "eo": + return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); + case "eee": + return localize2.day(dayOfWeek, { + width: "abbreviated", + context: "formatting" + }); + case "eeeee": + return localize2.day(dayOfWeek, { + width: "narrow", + context: "formatting" + }); + case "eeeeee": + return localize2.day(dayOfWeek, { + width: "short", + context: "formatting" + }); + case "eeee": + default: + return localize2.day(dayOfWeek, { + width: "wide", + context: "formatting" + }); + } + }, + // Stand-alone local day of week + c: function(date2, token, localize2, options) { + const dayOfWeek = date2.getDay(); + const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; + switch (token) { + case "c": + return String(localDayOfWeek); + case "cc": + return addLeadingZeros(localDayOfWeek, token.length); + case "co": + return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); + case "ccc": + return localize2.day(dayOfWeek, { + width: "abbreviated", + context: "standalone" + }); + case "ccccc": + return localize2.day(dayOfWeek, { + width: "narrow", + context: "standalone" + }); + case "cccccc": + return localize2.day(dayOfWeek, { + width: "short", + context: "standalone" + }); + case "cccc": + default: + return localize2.day(dayOfWeek, { + width: "wide", + context: "standalone" + }); + } + }, + // ISO day of week + i: function(date2, token, localize2) { + const dayOfWeek = date2.getDay(); + const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek; + switch (token) { + case "i": + return String(isoDayOfWeek); + case "ii": + return addLeadingZeros(isoDayOfWeek, token.length); + case "io": + return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" }); + case "iii": + return localize2.day(dayOfWeek, { + width: "abbreviated", + context: "formatting" + }); + case "iiiii": + return localize2.day(dayOfWeek, { + width: "narrow", + context: "formatting" + }); + case "iiiiii": + return localize2.day(dayOfWeek, { + width: "short", + context: "formatting" + }); + case "iiii": + default: + return localize2.day(dayOfWeek, { + width: "wide", + context: "formatting" + }); + } + }, + // AM or PM + a: function(date2, token, localize2) { + const hours2 = date2.getHours(); + const dayPeriodEnumValue = hours2 / 12 >= 1 ? "pm" : "am"; + switch (token) { + case "a": + case "aa": + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "abbreviated", + context: "formatting" + }); + case "aaa": + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "abbreviated", + context: "formatting" + }).toLowerCase(); + case "aaaaa": + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "narrow", + context: "formatting" + }); + case "aaaa": + default: + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "wide", + context: "formatting" + }); + } + }, + // AM, PM, midnight, noon + b: function(date2, token, localize2) { + const hours2 = date2.getHours(); + let dayPeriodEnumValue; + if (hours2 === 12) { + dayPeriodEnumValue = dayPeriodEnum.noon; + } else if (hours2 === 0) { + dayPeriodEnumValue = dayPeriodEnum.midnight; + } else { + dayPeriodEnumValue = hours2 / 12 >= 1 ? "pm" : "am"; + } + switch (token) { + case "b": + case "bb": + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "abbreviated", + context: "formatting" + }); + case "bbb": + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "abbreviated", + context: "formatting" + }).toLowerCase(); + case "bbbbb": + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "narrow", + context: "formatting" + }); + case "bbbb": + default: + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "wide", + context: "formatting" + }); + } + }, + // in the morning, in the afternoon, in the evening, at night + B: function(date2, token, localize2) { + const hours2 = date2.getHours(); + let dayPeriodEnumValue; + if (hours2 >= 17) { + dayPeriodEnumValue = dayPeriodEnum.evening; + } else if (hours2 >= 12) { + dayPeriodEnumValue = dayPeriodEnum.afternoon; + } else if (hours2 >= 4) { + dayPeriodEnumValue = dayPeriodEnum.morning; + } else { + dayPeriodEnumValue = dayPeriodEnum.night; + } + switch (token) { + case "B": + case "BB": + case "BBB": + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "abbreviated", + context: "formatting" + }); + case "BBBBB": + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "narrow", + context: "formatting" + }); + case "BBBB": + default: + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "wide", + context: "formatting" + }); + } + }, + // Hour [1-12] + h: function(date2, token, localize2) { + if (token === "ho") { + let hours2 = date2.getHours() % 12; + if (hours2 === 0) hours2 = 12; + return localize2.ordinalNumber(hours2, { unit: "hour" }); + } + return lightFormatters.h(date2, token); + }, + // Hour [0-23] + H: function(date2, token, localize2) { + if (token === "Ho") { + return localize2.ordinalNumber(date2.getHours(), { unit: "hour" }); + } + return lightFormatters.H(date2, token); + }, + // Hour [0-11] + K: function(date2, token, localize2) { + const hours2 = date2.getHours() % 12; + if (token === "Ko") { + return localize2.ordinalNumber(hours2, { unit: "hour" }); + } + return addLeadingZeros(hours2, token.length); + }, + // Hour [1-24] + k: function(date2, token, localize2) { + let hours2 = date2.getHours(); + if (hours2 === 0) hours2 = 24; + if (token === "ko") { + return localize2.ordinalNumber(hours2, { unit: "hour" }); + } + return addLeadingZeros(hours2, token.length); + }, + // Minute + m: function(date2, token, localize2) { + if (token === "mo") { + return localize2.ordinalNumber(date2.getMinutes(), { unit: "minute" }); + } + return lightFormatters.m(date2, token); + }, + // Second + s: function(date2, token, localize2) { + if (token === "so") { + return localize2.ordinalNumber(date2.getSeconds(), { unit: "second" }); + } + return lightFormatters.s(date2, token); + }, + // Fraction of second + S: function(date2, token) { + return lightFormatters.S(date2, token); + }, + // Timezone (ISO-8601. If offset is 0, output is always `'Z'`) + X: function(date2, token, _localize) { + const timezoneOffset = date2.getTimezoneOffset(); + if (timezoneOffset === 0) { + return "Z"; + } + switch (token) { + case "X": + return formatTimezoneWithOptionalMinutes(timezoneOffset); + case "XXXX": + case "XX": + return formatTimezone$1(timezoneOffset); + case "XXXXX": + case "XXX": + default: + return formatTimezone$1(timezoneOffset, ":"); + } + }, + // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent) + x: function(date2, token, _localize) { + const timezoneOffset = date2.getTimezoneOffset(); + switch (token) { + case "x": + return formatTimezoneWithOptionalMinutes(timezoneOffset); + case "xxxx": + case "xx": + return formatTimezone$1(timezoneOffset); + case "xxxxx": + case "xxx": + default: + return formatTimezone$1(timezoneOffset, ":"); + } + }, + // Timezone (GMT) + O: function(date2, token, _localize) { + const timezoneOffset = date2.getTimezoneOffset(); + switch (token) { + case "O": + case "OO": + case "OOO": + return "GMT" + formatTimezoneShort(timezoneOffset, ":"); + case "OOOO": + default: + return "GMT" + formatTimezone$1(timezoneOffset, ":"); + } + }, + // Timezone (specific non-location) + z: function(date2, token, _localize) { + const timezoneOffset = date2.getTimezoneOffset(); + switch (token) { + case "z": + case "zz": + case "zzz": + return "GMT" + formatTimezoneShort(timezoneOffset, ":"); + case "zzzz": + default: + return "GMT" + formatTimezone$1(timezoneOffset, ":"); + } + }, + // Seconds timestamp + t: function(date2, token, _localize) { + const timestamp = Math.trunc(+date2 / 1e3); + return addLeadingZeros(timestamp, token.length); + }, + // Milliseconds timestamp + T: function(date2, token, _localize) { + return addLeadingZeros(+date2, token.length); + } +}; +function formatTimezoneShort(offset, delimiter = "") { + const sign = offset > 0 ? "-" : "+"; + const absOffset = Math.abs(offset); + const hours2 = Math.trunc(absOffset / 60); + const minutes2 = absOffset % 60; + if (minutes2 === 0) { + return sign + String(hours2); + } + return sign + String(hours2) + delimiter + addLeadingZeros(minutes2, 2); +} +function formatTimezoneWithOptionalMinutes(offset, delimiter) { + if (offset % 60 === 0) { + const sign = offset > 0 ? "-" : "+"; + return sign + addLeadingZeros(Math.abs(offset) / 60, 2); + } + return formatTimezone$1(offset, delimiter); +} +function formatTimezone$1(offset, delimiter = "") { + const sign = offset > 0 ? "-" : "+"; + const absOffset = Math.abs(offset); + const hours2 = addLeadingZeros(Math.trunc(absOffset / 60), 2); + const minutes2 = addLeadingZeros(absOffset % 60, 2); + return sign + hours2 + delimiter + minutes2; +} +const dateLongFormatter = (pattern, formatLong2) => { + switch (pattern) { + case "P": + return formatLong2.date({ width: "short" }); + case "PP": + return formatLong2.date({ width: "medium" }); + case "PPP": + return formatLong2.date({ width: "long" }); + case "PPPP": + default: + return formatLong2.date({ width: "full" }); + } +}; +const timeLongFormatter = (pattern, formatLong2) => { + switch (pattern) { + case "p": + return formatLong2.time({ width: "short" }); + case "pp": + return formatLong2.time({ width: "medium" }); + case "ppp": + return formatLong2.time({ width: "long" }); + case "pppp": + default: + return formatLong2.time({ width: "full" }); + } +}; +const dateTimeLongFormatter = (pattern, formatLong2) => { + const matchResult = pattern.match(/(P+)(p+)?/) || []; + const datePattern = matchResult[1]; + const timePattern = matchResult[2]; + if (!timePattern) { + return dateLongFormatter(pattern, formatLong2); + } + let dateTimeFormat; + switch (datePattern) { + case "P": + dateTimeFormat = formatLong2.dateTime({ width: "short" }); + break; + case "PP": + dateTimeFormat = formatLong2.dateTime({ width: "medium" }); + break; + case "PPP": + dateTimeFormat = formatLong2.dateTime({ width: "long" }); + break; + case "PPPP": + default: + dateTimeFormat = formatLong2.dateTime({ width: "full" }); + break; + } + return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2)); +}; +const longFormatters = { + p: timeLongFormatter, + P: dateTimeLongFormatter +}; +const dayOfYearTokenRE = /^D+$/; +const weekYearTokenRE = /^Y+$/; +const throwTokens = ["D", "DD", "YY", "YYYY"]; +function isProtectedDayOfYearToken(token) { + return dayOfYearTokenRE.test(token); +} +function isProtectedWeekYearToken(token) { + return weekYearTokenRE.test(token); +} +function warnOrThrowProtectedError(token, format2, input) { + const _message = message(token, format2, input); + console.warn(_message); + if (throwTokens.includes(token)) throw new RangeError(_message); +} +function message(token, format2, input) { + const subject = token[0] === "Y" ? "years" : "days of the month"; + 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`; +} +const formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; +const longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g; +const escapedStringRegExp = /^'([^]*?)'?$/; +const doubleQuoteRegExp = /''/g; +const unescapedLatinCharacterRegExp = /[a-zA-Z]/; +function format$1(date2, formatStr, options) { + var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h; + const defaultOptions2 = getDefaultOptions(); + const locale = (options == null ? void 0 : options.locale) ?? defaultOptions2.locale ?? enUS; + const firstWeekContainsDate = (options == null ? void 0 : options.firstWeekContainsDate) ?? ((_b2 = (_a2 = options == null ? void 0 : options.locale) == null ? void 0 : _a2.options) == null ? void 0 : _b2.firstWeekContainsDate) ?? defaultOptions2.firstWeekContainsDate ?? ((_d2 = (_c2 = defaultOptions2.locale) == null ? void 0 : _c2.options) == null ? void 0 : _d2.firstWeekContainsDate) ?? 1; + const weekStartsOn = (options == null ? void 0 : options.weekStartsOn) ?? ((_f2 = (_e2 = options == null ? void 0 : options.locale) == null ? void 0 : _e2.options) == null ? void 0 : _f2.weekStartsOn) ?? defaultOptions2.weekStartsOn ?? ((_h = (_g = defaultOptions2.locale) == null ? void 0 : _g.options) == null ? void 0 : _h.weekStartsOn) ?? 0; + const originalDate = toDate(date2, options == null ? void 0 : options.in); + if (!isValid(originalDate)) { + throw new RangeError("Invalid time value"); + } + let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => { + const firstCharacter = substring[0]; + if (firstCharacter === "p" || firstCharacter === "P") { + const longFormatter = longFormatters[firstCharacter]; + return longFormatter(substring, locale.formatLong); + } + return substring; + }).join("").match(formattingTokensRegExp).map((substring) => { + if (substring === "''") { + return { isToken: false, value: "'" }; + } + const firstCharacter = substring[0]; + if (firstCharacter === "'") { + return { isToken: false, value: cleanEscapedString(substring) }; + } + if (formatters[firstCharacter]) { + return { isToken: true, value: substring }; + } + if (firstCharacter.match(unescapedLatinCharacterRegExp)) { + throw new RangeError( + "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`" + ); + } + return { isToken: false, value: substring }; + }); + if (locale.localize.preprocessor) { + parts = locale.localize.preprocessor(originalDate, parts); + } + const formatterOptions = { + firstWeekContainsDate, + weekStartsOn, + locale + }; + return parts.map((part) => { + if (!part.isToken) return part.value; + const token = part.value; + if (!(options == null ? void 0 : options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(token) || !(options == null ? void 0 : options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(token)) { + warnOrThrowProtectedError(token, formatStr, String(date2)); + } + const formatter = formatters[token[0]]; + return formatter(originalDate, token, locale.localize, formatterOptions); + }).join(""); +} +function cleanEscapedString(input) { + const matched = input.match(escapedStringRegExp); + if (!matched) { + return input; + } + return matched[1].replace(doubleQuoteRegExp, "'"); +} +class UTCDateMini extends Date { + constructor() { + super(); + this.setTime(arguments.length === 0 ? ( + // Enables Sinon's fake timers that override the constructor + Date.now() + ) : arguments.length === 1 ? typeof arguments[0] === "string" ? +new Date(arguments[0]) : arguments[0] : Date.UTC(...arguments)); + } + getTimezoneOffset() { + return 0; + } +} +const re = /^(get|set)(?!UTC)/; +Object.getOwnPropertyNames(Date.prototype).forEach((method) => { + if (re.test(method)) { + const utcMethod = Date.prototype[method.replace(re, "$1UTC")]; + if (utcMethod) UTCDateMini.prototype[method] = utcMethod; + } +}); +class UTCDate extends UTCDateMini { + toString() { + const date2 = this.toDateString(); + const time2 = this.toTimeString(); + return `${date2} ${time2}`; + } + toDateString() { + const weekday = weekdayFormat.format(this); + const date2 = dateFormat.format(this); + const year2 = this.getFullYear(); + return `${weekday} ${date2} ${year2}`; + } + toTimeString() { + const time2 = timeFormat.format(this); + return `${time2} GMT+0000 (Coordinated Universal Time)`; + } + toLocaleString(locales, options) { + return Date.prototype.toLocaleString.call(this, locales, { + timeZone: "UTC", + ...options + }); + } + toLocaleDateString(locales, options) { + return Date.prototype.toLocaleDateString.call(this, locales, { + timeZone: "UTC", + ...options + }); + } + toLocaleTimeString(locales, options) { + return Date.prototype.toLocaleTimeString.call(this, locales, { + timeZone: "UTC", + ...options + }); + } +} +var weekdayFormat = new Intl.DateTimeFormat("en-US", { + weekday: "short", + timeZone: "UTC" +}); +var dateFormat = new Intl.DateTimeFormat("en-US", { + month: "short", + day: "numeric", + timeZone: "UTC" +}); +var timeFormat = new Intl.DateTimeFormat("en-GB", { + hour12: false, + hour: "numeric", + minute: "numeric", + second: "numeric", + timeZone: "UTC" +}); +const utc = (value) => new UTCDate(+new Date(value)); +function getHourFromTime(time2, includePeriod = "none", displayTZ = "") { + const hour = time2 == 0 || time2 == 12 ? 12 : time2 % 12; + const period = time2 < 12 ? "AM" : "PM"; + switch (includePeriod) { + case "none": + return `${hour}`; + case "twelves": + return hour === 12 ? `${hour} ${period}` : `${hour}`; + case "all": + return `${hour} ${period}`; + default: + throw new Error("Invalid includePeriod option. Use either 'none', 'twelves', or 'all'"); + } +} +function getTimeFromHour(hour) { + const match2 = hour.match(/^(\d{1,2}) ?([aApP][mM])?$/); + if (!match2) { + throw new Error("Invalid time format"); + } + let time2 = parseInt(match2[1]); + const period = match2[2] ? match2[2].toUpperCase() : null; + if (period === "PM" && time2 !== 12) { + time2 += 12; + } else if (period === "AM" && time2 === 12) { + time2 = 0; + } + return time2; +} +const timezones$1 = { + // "Pacific/Midway": "Midway Island, Samoa", + "Pacific/Honolulu": "Hawaii", + // "America/Juneau": "Alaska", + "America/Boise": "Mountain Time", + // "America/Dawson": "Dawson, Yukon", + // "America/Chihuahua": "Chihuahua, La Paz, Mazatlan", + // "America/Phoenix": "Arizona", + "America/Chicago": "Central Time", + // "America/Regina": "Saskatchewan", + "America/Mexico_City": "Mexico", + // "America/Belize": "Central America", + "America/New_York": "Eastern Time", + // "America/Bogota": "Bogota, Lima, Quito", + // "America/Caracas": "Caracas, La Paz", + // "America/Santiago": "Santiago", + // "America/St_Johns": "Newfoundland and Labrador", + // "America/Sao_Paulo": "Brasilia", + // "America/Tijuana": "Mexico", + // "America/Montevideo": "Montevideo", + "America/Argentina/Buenos_Aires": "Argentina", + // "America/Godthab": "Greenland", + "America/Los_Angeles": "Pacific Time", + // "Atlantic/Azores": "Azores", + // "Atlantic/Cape_Verde": "Cape Verde Islands", + // GMT: "UTC", + "Europe/London": "The UK", + "Europe/Dublin": "Ireland", + // "Europe/Lisbon": "Lisbon", + // "Africa/Casablanca": "Casablanca, Monrovia", + // "Atlantic/Canary": "Canary Islands", + // "Europe/Belgrade": "Belgrade, Bratislava, Budapest, Ljubljana, Prague", + // "Europe/Sarajevo": "Sarajevo, Skopje, Warsaw, Zagreb", + // "Europe/Brussels": "Brussels, Copenhagen, Madrid, Paris", + "Europe/Amsterdam": "Western Europe", + // "Africa/Algiers": "West Central Africa", + // "Europe/Bucharest": "Bucharest", + // "Africa/Cairo": "Cairo", + "Europe/Helsinki": "Eastern Europe", + // "Europe/Athens": "Athens", + // "Asia/Jerusalem": "Jerusalem", + // "Africa/Harare": "Harare, Pretoria", + // "Europe/Moscow": "Istanbul, Minsk, Moscow, St. Petersburg, Volgograd", + // "Asia/Kuwait": "Kuwait, Riyadh", + "Africa/Nairobi": "Kenya", + "Africa/Johannesburg": "South Africa", + // "Asia/Baghdad": "Baghdad", + // "Asia/Tehran": "Tehran", + // "Asia/Dubai": "Abu Dhabi, Muscat", + // "Asia/Baku": "Baku, Tbilisi, Yerevan", + // "Asia/Kabul": "Kabul", + // "Asia/Yekaterinburg": "Ekaterinburg", + // "Asia/Karachi": "Islamabad, Karachi, Tashkent", + "Asia/Kolkata": "India", + // "Asia/Kathmandu": "Kathmandu", + // "Asia/Dhaka": "Astana, Dhaka", + // "Asia/Colombo": "Sri Jayawardenepura", + // "Asia/Almaty": "Almaty, Novosibirsk", + // "Asia/Rangoon": "Yangon Rangoon", + // "Asia/Bangkok": "Bangkok, Hanoi, Jakarta", + // "Asia/Krasnoyarsk": "Krasnoyarsk", + // "Asia/Shanghai": "Beijing, Chongqing, Hong Kong SAR, Urumqi", + // "Asia/Kuala_Lumpur": "Kuala Lumpur, Singapore", + // "Asia/Taipei": "Taipei", + // "Australia/Perth": "Perth", + // "Asia/Irkutsk": "Irkutsk, Ulaanbaatar", + // "Asia/Seoul": "Seoul", + "Asia/Tokyo": "Japan" + // "Asia/Yakutsk": "Yakutsk", + // "Australia/Darwin": "Darwin", + // "Australia/Adelaide": "Adelaide", + // "Australia/Sydney": "Canberra, Melbourne, Sydney", + // "Australia/Brisbane": "Brisbane", + // "Australia/Hobart": "Hobart", + // "Asia/Vladivostok": "Vladivostok", + // "Pacific/Guam": "Guam, Port Moresby", + // "Asia/Magadan": "Magadan, Solomon Islands, New Caledonia", + // "Asia/Kamchatka": "Kamchatka, Marshall Islands", + // "Pacific/Fiji": "Fiji Islands", + // "Pacific/Auckland": "Auckland, Wellington", + // "Pacific/Tongatapu": "Nuku'alofa", +}; +const MSEC_IN_HOUR = 60 * 60 * 1e3; +const toUtc = (dstChange, offset, year2) => { + const [month2, rest] = dstChange.split("/"); + const [day, hour] = rest.split(":"); + return Date.UTC(year2, month2 - 1, day, hour) - offset * MSEC_IN_HOUR; +}; +const inSummerTime = (epoch, start, end, summerOffset, winterOffset) => { + const year2 = new Date(epoch).getUTCFullYear(); + const startUtc = toUtc(start, winterOffset, year2); + const endUtc = toUtc(end, summerOffset, year2); + return epoch >= startUtc && epoch < endUtc; +}; +const quickOffset = (s) => { + let zones2 = s.timezones; + let obj = zones2[s.tz]; + if (obj === void 0) { + console.warn("Warning: couldn't find timezone " + s.tz); + return 0; + } + if (obj.dst === void 0) { + return obj.offset; + } + let jul = obj.offset; + let dec = obj.offset + 1; + if (obj.hem === "n") { + dec = jul - 1; + } + let split = obj.dst.split("->"); + let inSummer = inSummerTime(s.epoch, split[0], split[1], jul, dec); + if (inSummer === true) { + return jul; + } + return dec; +}; +const data = { + "9|s": "2/dili,2/jayapura", + "9|n": "2/chita,2/khandyga,2/pyongyang,2/seoul,2/tokyo,2/yakutsk,11/palau,japan,rok", + "9.5|s|04/07:03->10/06:04": "4/adelaide,4/broken_hill,4/south,4/yancowinna", + "9.5|s": "4/darwin,4/north", + "8|s|03/13:01->10/02:00": "12/casey", + "8|s": "2/kuala_lumpur,2/makassar,2/singapore,4/perth,2/ujung_pandang,4/west,singapore", + "8|n": "2/brunei,2/choibalsan,2/hong_kong,2/irkutsk,2/kuching,2/macau,2/manila,2/shanghai,2/taipei,2/ulaanbaatar,2/chongqing,2/chungking,2/harbin,2/macao,2/ulan_bator,hongkong,prc,roc", + "8.75|s": "4/eucla", + "7|s": "12/davis,2/jakarta,9/christmas", + "7|n": "2/bangkok,2/barnaul,2/hovd,2/krasnoyarsk,2/novokuznetsk,2/novosibirsk,2/phnom_penh,2/pontianak,2/ho_chi_minh,2/tomsk,2/vientiane,2/saigon", + "6|s": "12/vostok", + "6|n": "2/almaty,2/bishkek,2/dhaka,2/omsk,2/qyzylorda,2/qostanay,2/thimphu,2/urumqi,9/chagos,2/dacca,2/kashgar,2/thimbu", + "6.5|n": "2/yangon,9/cocos,2/rangoon", + "5|s": "12/mawson,9/kerguelen", + "5|n": "2/aqtau,2/aqtobe,2/ashgabat,2/atyrau,2/dushanbe,2/karachi,2/oral,2/samarkand,2/tashkent,2/yekaterinburg,9/maldives,2/ashkhabad", + "5.75|n": "2/kathmandu,2/katmandu", + "5.5|n": "2/kolkata,2/colombo,2/calcutta", + "4|s": "9/reunion", + "4|n": "2/baku,2/dubai,2/muscat,2/tbilisi,2/yerevan,8/astrakhan,8/samara,8/saratov,8/ulyanovsk,8/volgograd,9/mahe,9/mauritius,2/volgograd", + "4.5|n": "2/kabul", + "3|s": "12/syowa,9/antananarivo", + "3|n|04/26:02->10/31:24": "0/cairo,egypt", + "3|n|04/20:04->10/26:02": "2/gaza,2/hebron", + "3|n|03/31:05->10/27:04": "2/famagusta,2/nicosia,8/athens,8/bucharest,8/helsinki,8/kyiv,8/mariehamn,8/riga,8/sofia,8/tallinn,8/uzhgorod,8/vilnius,8/zaporozhye,8/nicosia,8/kiev,eet", + "3|n|03/31:04->10/27:03": "8/chisinau,8/tiraspol", + "3|n|03/31:02->10/26:24": "2/beirut", + "3|n|03/29:04->10/27:02": "2/jerusalem,2/tel_aviv,israel", + "3|n": "0/addis_ababa,0/asmara,0/asmera,0/dar_es_salaam,0/djibouti,0/juba,0/kampala,0/mogadishu,0/nairobi,2/aden,2/amman,2/baghdad,2/bahrain,2/damascus,2/kuwait,2/qatar,2/riyadh,8/istanbul,8/kirov,8/minsk,8/moscow,8/simferopol,9/comoro,9/mayotte,2/istanbul,turkey,w-su", + "3.5|n": "2/tehran,iran", + "2|s|03/31:04->10/27:02": "12/troll", + "2|s": "0/gaborone,0/harare,0/johannesburg,0/lubumbashi,0/lusaka,0/maputo,0/maseru,0/mbabane", + "2|n|03/31:04->10/27:03": "0/ceuta,arctic/longyearbyen,8/amsterdam,8/andorra,8/belgrade,8/berlin,8/bratislava,8/brussels,8/budapest,8/busingen,8/copenhagen,8/gibraltar,8/ljubljana,8/luxembourg,8/madrid,8/malta,8/monaco,8/oslo,8/paris,8/podgorica,8/prague,8/rome,8/san_marino,8/sarajevo,8/skopje,8/stockholm,8/tirane,8/vaduz,8/vatican,8/vienna,8/warsaw,8/zagreb,8/zurich,3/jan_mayen,poland,cet,met", + "2|n": "0/blantyre,0/bujumbura,0/khartoum,0/kigali,0/tripoli,8/kaliningrad,libya", + "1|s": "0/brazzaville,0/kinshasa,0/luanda,0/windhoek", + "1|n|03/31:03->10/27:02": "3/canary,3/faroe,3/madeira,8/dublin,8/guernsey,8/isle_of_man,8/jersey,8/lisbon,8/london,3/faeroe,eire,8/belfast,gb-eire,gb,portugal,wet", + "1|n": "0/algiers,0/bangui,0/douala,0/lagos,0/libreville,0/malabo,0/ndjamena,0/niamey,0/porto-novo,0/tunis", + "14|n": "11/kiritimati", + "13|s": "11/apia,11/tongatapu", + "13|n": "11/enderbury,11/kanton,11/fakaofo", + "12|s|04/07:03->09/29:04": "12/mcmurdo,11/auckland,12/south_pole,nz", + "12|s": "11/fiji", + "12|n": "2/anadyr,2/kamchatka,2/srednekolymsk,11/funafuti,11/kwajalein,11/majuro,11/nauru,11/tarawa,11/wake,11/wallis,kwajalein", + "12.75|s|04/07:03->04/07:02": "11/chatham,nz-chat", + "11|s|04/07:03->10/06:04": "12/macquarie", + "11|s": "11/bougainville", + "11|n": "2/magadan,2/sakhalin,11/efate,11/guadalcanal,11/kosrae,11/noumea,11/pohnpei,11/ponape", + "11.5|n|04/07:03->10/06:04": "11/norfolk", + "10|s|04/07:03->10/06:04": "4/currie,4/hobart,4/melbourne,4/sydney,4/act,4/canberra,4/nsw,4/tasmania,4/victoria", + "10|s": "12/dumontdurville,4/brisbane,4/lindeman,11/port_moresby,4/queensland", + "10|n": "2/ust-nera,2/vladivostok,11/guam,11/saipan,11/chuuk,11/truk,11/yap", + "10.5|s|04/07:01->10/06:02": "4/lord_howe,4/lhi", + "0|s|03/10:03->04/14:04": "0/casablanca,0/el_aaiun", + "0|n|03/31:02->10/27:01": "3/azores", + "0|n|03/31:01->10/26:24": "1/scoresbysund", + "0|n": "0/abidjan,0/accra,0/bamako,0/banjul,0/bissau,0/conakry,0/dakar,0/freetown,0/lome,0/monrovia,0/nouakchott,0/ouagadougou,0/sao_tome,1/danmarkshavn,3/reykjavik,3/st_helena,13/gmt,13/utc,0/timbuktu,13/greenwich,13/uct,13/universal,13/zulu,gmt-0,gmt+0,gmt0,greenwich,iceland,uct,universal,utc,zulu,13/unknown,factory", + "-9|n|03/10:04->11/03:02": "1/adak,1/atka,us/aleutian", + "-9|n": "11/gambier", + "-9.5|n": "11/marquesas", + "-8|n|03/10:04->11/03:02": "1/anchorage,1/juneau,1/metlakatla,1/nome,1/sitka,1/yakutat,us/alaska", + "-8|n": "11/pitcairn", + "-7|n|03/10:04->11/03:02": "1/los_angeles,1/santa_isabel,1/tijuana,1/vancouver,1/ensenada,6/pacific,10/bajanorte,us/pacific-new,us/pacific", + "-7|n": "1/creston,1/dawson,1/dawson_creek,1/fort_nelson,1/hermosillo,1/mazatlan,1/phoenix,1/whitehorse,6/yukon,10/bajasur,us/arizona,mst", + "-6|s|04/06:22->09/07:24": "11/easter,7/easterisland", + "-6|n|04/07:02->10/27:02": "1/merida", + "-6|n|03/10:04->11/03:02": "1/boise,1/cambridge_bay,1/denver,1/edmonton,1/inuvik,1/north_dakota,1/ojinaga,1/ciudad_juarez,1/yellowknife,1/shiprock,6/mountain,navajo,us/mountain", + "-6|n": "1/bahia_banderas,1/belize,1/chihuahua,1/costa_rica,1/el_salvador,1/guatemala,1/managua,1/mexico_city,1/monterrey,1/regina,1/swift_current,1/tegucigalpa,11/galapagos,6/east-saskatchewan,6/saskatchewan,10/general", + "-5|s": "1/lima,1/rio_branco,1/porto_acre,5/acre", + "-5|n|03/10:04->11/03:02": "1/chicago,1/matamoros,1/menominee,1/rainy_river,1/rankin_inlet,1/resolute,1/winnipeg,1/indiana/knox,1/indiana/tell_city,1/north_dakota/beulah,1/north_dakota/center,1/north_dakota/new_salem,1/knox_in,6/central,us/central,us/indiana-starke", + "-5|n": "1/bogota,1/cancun,1/cayman,1/coral_harbour,1/eirunepe,1/guayaquil,1/jamaica,1/panama,1/atikokan,jamaica,est", + "-4|s|04/06:24->09/08:02": "1/santiago,7/continental", + "-4|s|03/23:24->10/06:02": "1/asuncion", + "-4|s": "1/campo_grande,1/cuiaba,1/la_paz,1/manaus,5/west", + "-4|n|03/10:04->11/03:02": "1/detroit,1/grand_turk,1/indiana,1/indianapolis,1/iqaluit,1/kentucky,1/louisville,1/montreal,1/nassau,1/new_york,1/nipigon,1/pangnirtung,1/port-au-prince,1/thunder_bay,1/toronto,1/indiana/marengo,1/indiana/petersburg,1/indiana/vevay,1/indiana/vincennes,1/indiana/winamac,1/kentucky/monticello,1/fort_wayne,1/indiana/indianapolis,1/kentucky/louisville,6/eastern,us/east-indiana,us/eastern,us/michigan", + "-4|n|03/10:02->11/03:01": "1/havana,cuba", + "-4|n": "1/anguilla,1/antigua,1/aruba,1/barbados,1/blanc-sablon,1/boa_vista,1/caracas,1/curacao,1/dominica,1/grenada,1/guadeloupe,1/guyana,1/kralendijk,1/lower_princes,1/marigot,1/martinique,1/montserrat,1/port_of_spain,1/porto_velho,1/puerto_rico,1/santo_domingo,1/st_barthelemy,1/st_kitts,1/st_lucia,1/st_thomas,1/st_vincent,1/tortola,1/virgin", + "-3|s": "1/argentina,1/buenos_aires,1/catamarca,1/cordoba,1/fortaleza,1/jujuy,1/mendoza,1/montevideo,1/punta_arenas,1/sao_paulo,12/palmer,12/rothera,3/stanley,1/argentina/la_rioja,1/argentina/rio_gallegos,1/argentina/salta,1/argentina/san_juan,1/argentina/san_luis,1/argentina/tucuman,1/argentina/ushuaia,1/argentina/comodrivadavia,1/argentina/buenos_aires,1/argentina/catamarca,1/argentina/cordoba,1/argentina/jujuy,1/argentina/mendoza,1/argentina/rosario,1/rosario,5/east", + "-3|n|03/10:04->11/03:02": "1/glace_bay,1/goose_bay,1/halifax,1/moncton,1/thule,3/bermuda,6/atlantic", + "-3|n": "1/araguaina,1/bahia,1/belem,1/cayenne,1/maceio,1/paramaribo,1/recife,1/santarem", + "-2|n|03/31:01->10/26:24": "1/nuuk,1/godthab", + "-2|n|03/10:04->11/03:02": "1/miquelon", + "-2|n": "1/noronha,3/south_georgia,5/denoronha", + "-2.5|n|03/10:04->11/03:02": "1/st_johns,6/newfoundland", + "-1|n": "3/cape_verde", + "-11|n": "11/midway,11/niue,11/pago_pago,11/samoa,us/samoa", + "-10|n": "11/honolulu,11/johnston,11/rarotonga,11/tahiti,us/hawaii,hst" +}; +const prefixes = [ + "africa", + "america", + "asia", + "atlantic", + "australia", + "brazil", + "canada", + "chile", + "europe", + "indian", + "mexico", + "pacific", + "antarctica", + "etc" +]; +let all = {}; +Object.keys(data).forEach((k) => { + let split = k.split("|"); + let obj = { + offset: Number(split[0]), + hem: split[1] + }; + if (split[2]) { + obj.dst = split[2]; + } + let names = data[k].split(","); + names.forEach((str) => { + str = str.replace(/(^[0-9]+)\//, (before, num) => { + num = Number(num); + return prefixes[num] + "/"; + }); + all[str] = obj; + }); +}); +all.utc = { + offset: 0, + hem: "n" + //default to northern hemisphere - (sorry!) +}; +for (let i = -14; i <= 14; i += 0.5) { + let num = i; + if (num > 0) { + num = "+" + num; + } + let name2 = "etc/gmt" + num; + all[name2] = { + offset: i * -1, + //they're negative! + hem: "n" + //(sorry) + }; + name2 = "utc/gmt" + num; + all[name2] = { + offset: i * -1, + hem: "n" + }; +} +const fallbackTZ = "utc"; +const safeIntl = () => { + if (typeof Intl === "undefined" || typeof Intl.DateTimeFormat === "undefined") { + return null; + } + let format2 = Intl.DateTimeFormat(); + if (typeof format2 === "undefined" || typeof format2.resolvedOptions === "undefined") { + return null; + } + let timezone2 = format2.resolvedOptions().timeZone; + if (!timezone2) { + return null; + } + return timezone2.toLowerCase(); +}; +const guessTz = () => { + let timezone2 = safeIntl(); + if (timezone2 === null) { + return fallbackTZ; + } + return timezone2; +}; +const isOffset$1 = /(-?[0-9]+)h(rs)?/i; +const isNumber$1 = /(-?[0-9]+)/; +const utcOffset$1 = /utc([\-+]?[0-9]+)/i; +const gmtOffset$1 = /gmt([\-+]?[0-9]+)/i; +const toIana$1 = function(num) { + num = Number(num); + if (num >= -13 && num <= 13) { + num = num * -1; + num = (num > 0 ? "+" : "") + num; + return "etc/gmt" + num; + } + return null; +}; +const parseOffset$3 = function(tz) { + let m = tz.match(isOffset$1); + if (m !== null) { + return toIana$1(m[1]); + } + m = tz.match(utcOffset$1); + if (m !== null) { + return toIana$1(m[1]); + } + m = tz.match(gmtOffset$1); + if (m !== null) { + let num = Number(m[1]) * -1; + return toIana$1(num); + } + m = tz.match(isNumber$1); + if (m !== null) { + return toIana$1(m[1]); + } + return null; +}; +let local = guessTz(); +const cities = Object.keys(all).reduce((h, k) => { + let city = k.split("/")[1] || ""; + city = city.replace(/_/g, " "); + h[city] = k; + return h; +}, {}); +const normalize$3 = (tz) => { + tz = tz.replace(/ time/g, ""); + tz = tz.replace(/ (standard|daylight|summer)/g, ""); + tz = tz.replace(/\b(east|west|north|south)ern/g, "$1"); + tz = tz.replace(/\b(africa|america|australia)n/g, "$1"); + tz = tz.replace(/\beuropean/g, "europe"); + tz = tz.replace(/islands/g, "island"); + return tz; +}; +const lookupTz = (str, zones2) => { + if (!str) { + if (!zones2.hasOwnProperty(local)) { + console.warn(`Unrecognized IANA id '${local}'. Setting fallback tz to UTC.`); + local = "utc"; + } + return local; + } + if (typeof str !== "string") { + console.error("Timezone must be a string - recieved: '", str, "'\n"); + } + let tz = str.trim(); + tz = tz.toLowerCase(); + if (zones2.hasOwnProperty(tz) === true) { + return tz; + } + tz = normalize$3(tz); + if (zones2.hasOwnProperty(tz) === true) { + return tz; + } + if (cities.hasOwnProperty(tz) === true) { + return cities[tz]; + } + if (/[0-9]/.test(tz) === true) { + let id = parseOffset$3(tz); + if (id) { + return id; + } + } + throw new Error( + "Spacetime: Cannot find timezone named: '" + str + "'. Please enter an IANA timezone id." + ); +}; +function isLeapYear(year2) { + return year2 % 4 === 0 && year2 % 100 !== 0 || year2 % 400 === 0; +} +function isDate(d) { + return Object.prototype.toString.call(d) === "[object Date]" && !isNaN(d.valueOf()); +} +function isArray(input) { + return Object.prototype.toString.call(input) === "[object Array]"; +} +function isObject(input) { + return Object.prototype.toString.call(input) === "[object Object]"; +} +function isBoolean(input) { + return Object.prototype.toString.call(input) === "[object Boolean]"; +} +function zeroPad(str, len = 2) { + let pad = "0"; + str = str + ""; + return str.length >= len ? str : new Array(len - str.length + 1).join(pad) + str; +} +function titleCase$1(str) { + if (!str) { + return ""; + } + return str[0].toUpperCase() + str.substr(1); +} +function ordinal(i) { + let j = i % 10; + let k = i % 100; + if (j === 1 && k !== 11) { + return i + "st"; + } + if (j === 2 && k !== 12) { + return i + "nd"; + } + if (j === 3 && k !== 13) { + return i + "rd"; + } + return i + "th"; +} +function toCardinal(str) { + str = String(str); + str = str.replace(/([0-9])(st|nd|rd|th)$/i, "$1"); + return parseInt(str, 10); +} +function normalize$2(str = "") { + str = str.toLowerCase().trim(); + str = str.replace(/ies$/, "y"); + str = str.replace(/s$/, ""); + str = str.replace(/-/g, ""); + if (str === "day" || str === "days") { + return "date"; + } + if (str === "min" || str === "mins") { + return "minute"; + } + return str; +} +function getEpoch(tmp) { + if (typeof tmp === "number") { + return tmp; + } + if (isDate(tmp)) { + return tmp.getTime(); + } + if (tmp.epoch || tmp.epoch === 0) { + return tmp.epoch; + } + return null; +} +function beADate(d, s) { + if (isObject(d) === false) { + return s.clone().set(d); + } + return d; +} +function formatTimezone(offset, delimiter = "") { + const sign = offset > 0 ? "+" : "-"; + const absOffset = Math.abs(offset); + const hours2 = zeroPad(parseInt("" + absOffset, 10)); + const minutes2 = zeroPad(absOffset % 1 * 60); + return `${sign}${hours2}${delimiter}${minutes2}`; +} +const defaults$1 = { + year: (/* @__PURE__ */ new Date()).getFullYear(), + month: 0, + date: 1 +}; +const parseArray$1 = (s, arr, today) => { + if (arr.length === 0) { + return s; + } + let order2 = ["year", "month", "date", "hour", "minute", "second", "millisecond"]; + for (let i = 0; i < order2.length; i++) { + let num = arr[i] || today[order2[i]] || defaults$1[order2[i]] || 0; + s = s[order2[i]](num); + } + return s; +}; +const parseObject$1 = (s, obj, today) => { + if (Object.keys(obj).length === 0) { + return s; + } + obj = Object.assign({}, defaults$1, today, obj); + let keys = Object.keys(obj); + for (let i = 0; i < keys.length; i++) { + let unit = keys[i]; + if (s[unit] === void 0 || typeof s[unit] !== "function") { + continue; + } + if (obj[unit] === null || obj[unit] === void 0 || obj[unit] === "") { + continue; + } + let num = obj[unit] || today[unit] || defaults$1[unit] || 0; + s = s[unit](num); + } + return s; +}; +const parseNumber$1 = function(s, input) { + const minimumEpoch = 25e8; + if (input > 0 && input < minimumEpoch && s.silent === false) { + console.warn(" - Warning: You are setting the date to January 1970."); + console.warn(" - did input seconds instead of milliseconds?"); + } + s.epoch = input; + return s; +}; +const fns = { + parseArray: parseArray$1, + parseObject: parseObject$1, + parseNumber: parseNumber$1 +}; +const getNow = function(s) { + s.epoch = Date.now(); + Object.keys(s._today || {}).forEach((k) => { + if (typeof s[k] === "function") { + s = s[k](s._today[k]); + } + }); + return s; +}; +const dates = { + now: (s) => { + return getNow(s); + }, + today: (s) => { + return getNow(s); + }, + tonight: (s) => { + s = getNow(s); + s = s.hour(18); + return s; + }, + tomorrow: (s) => { + s = getNow(s); + s = s.add(1, "day"); + s = s.startOf("day"); + return s; + }, + yesterday: (s) => { + s = getNow(s); + s = s.subtract(1, "day"); + s = s.startOf("day"); + return s; + }, + christmas: (s) => { + let year2 = getNow(s).year(); + s = s.set([year2, 11, 25, 18, 0, 0]); + return s; + }, + "new years": (s) => { + let year2 = getNow(s).year(); + s = s.set([year2, 11, 31, 18, 0, 0]); + return s; + } +}; +dates["new years eve"] = dates["new years"]; +const normalize$1 = function(str) { + str = str.replace(/\b(mon|tues?|wed|wednes|thur?s?|fri|sat|satur|sun)(day)?\b/i, ""); + str = str.replace(/([0-9])(th|rd|st|nd)/, "$1"); + str = str.replace(/,/g, ""); + str = str.replace(/ +/g, " ").trim(); + return str; +}; +let o = { + millisecond: 1 +}; +o.second = 1e3; +o.minute = 6e4; +o.hour = 36e5; +o.day = 864e5; +o.date = o.day; +o.month = 864e5 * 29.5; +o.week = 6048e5; +o.year = 3154e7; +Object.keys(o).forEach((k) => { + o[k + "s"] = o[k]; +}); +const walk = (s, n, fn, unit, previous) => { + let current = s.d[fn](); + if (current === n) { + return; + } + let startUnit = previous === null ? null : s.d[previous](); + let original = s.epoch; + let diff2 = n - current; + s.epoch += o[unit] * diff2; + if (unit === "day") { + if (Math.abs(diff2) > 28 && n < 28) { + s.epoch += o.hour; + } + } + if (previous !== null && startUnit !== s.d[previous]()) { + s.epoch = original; + } + const halfStep = o[unit] / 2; + while (s.d[fn]() < n) { + s.epoch += halfStep; + } + while (s.d[fn]() > n) { + s.epoch -= halfStep; + } + if (previous !== null && startUnit !== s.d[previous]()) { + s.epoch = original; + } +}; +const units$4 = { + year: { + valid: (n) => n > -4e3 && n < 4e3, + walkTo: (s, n) => walk(s, n, "getFullYear", "year", null) + }, + month: { + valid: (n) => n >= 0 && n <= 11, + walkTo: (s, n) => { + let d = s.d; + let current = d.getMonth(); + let original = s.epoch; + let startUnit = d.getFullYear(); + if (current === n) { + return; + } + let diff2 = n - current; + s.epoch += o.day * (diff2 * 28); + if (startUnit !== s.d.getFullYear()) { + s.epoch = original; + } + while (s.d.getMonth() < n) { + s.epoch += o.day; + } + while (s.d.getMonth() > n) { + s.epoch -= o.day; + } + } + }, + date: { + valid: (n) => n > 0 && n <= 31, + walkTo: (s, n) => walk(s, n, "getDate", "day", "getMonth") + }, + hour: { + valid: (n) => n >= 0 && n < 24, + walkTo: (s, n) => walk(s, n, "getHours", "hour", "getDate") + }, + minute: { + valid: (n) => n >= 0 && n < 60, + walkTo: (s, n) => walk(s, n, "getMinutes", "minute", "getHours") + }, + second: { + valid: (n) => n >= 0 && n < 60, + walkTo: (s, n) => { + s.epoch = s.seconds(n).epoch; + } + }, + millisecond: { + valid: (n) => n >= 0 && n < 1e3, + walkTo: (s, n) => { + s.epoch = s.milliseconds(n).epoch; + } + } +}; +const walkTo = (s, wants) => { + let keys = Object.keys(units$4); + let old = s.clone(); + for (let i = 0; i < keys.length; i++) { + let k = keys[i]; + let n = wants[k]; + if (n === void 0) { + n = old[k](); + } + if (typeof n === "string") { + n = parseInt(n, 10); + } + if (!units$4[k].valid(n)) { + s.epoch = null; + if (s.silent === false) { + console.warn("invalid " + k + ": " + n); + } + return; + } + units$4[k].walkTo(s, n); + } + return; +}; +const monthLengths = [ + 31, + // January - 31 days + 28, + // February - 28 days in a common year and 29 days in leap years + 31, + // March - 31 days + 30, + // April - 30 days + 31, + // May - 31 days + 30, + // June - 30 days + 31, + // July - 31 days + 31, + // August - 31 days + 30, + // September - 30 days + 31, + // October - 31 days + 30, + // November - 30 days + 31 + // December - 31 days +]; +let shortMonths = [ + "jan", + "feb", + "mar", + "apr", + "may", + "jun", + "jul", + "aug", + "sep", + "oct", + "nov", + "dec" +]; +let longMonths = [ + "january", + "february", + "march", + "april", + "may", + "june", + "july", + "august", + "september", + "october", + "november", + "december" +]; +function buildMapping() { + const obj = { + sep: 8 + //support this format + }; + for (let i = 0; i < shortMonths.length; i++) { + obj[shortMonths[i]] = i; + } + for (let i = 0; i < longMonths.length; i++) { + obj[longMonths[i]] = i; + } + return obj; +} +function short$1() { + return shortMonths; +} +function long$1() { + return longMonths; +} +function mapping$1() { + return buildMapping(); +} +function set$5(i18n) { + shortMonths = i18n.short || shortMonths; + longMonths = i18n.long || longMonths; +} +const parseOffset$2 = (s, offset) => { + if (!offset) { + return s; + } + offset = offset.trim().toLowerCase(); + let num = 0; + if (/^[+-]?[0-9]{2}:[0-9]{2}$/.test(offset)) { + if (/:00/.test(offset) === true) { + offset = offset.replace(/:00/, ""); + } + if (/:30/.test(offset) === true) { + offset = offset.replace(/:30/, ".5"); + } + } + if (/^[+-]?[0-9]{4}$/.test(offset)) { + offset = offset.replace(/30$/, ".5"); + } + num = parseFloat(offset); + if (Math.abs(num) > 100) { + num = num / 100; + } + if (num === 0 || offset === "Z" || offset === "z") { + s.tz = "etc/gmt"; + return s; + } + num *= -1; + if (num >= 0) { + num = "+" + num; + } + let tz = "etc/gmt" + num; + let zones2 = s.timezones; + if (zones2[tz]) { + s.tz = tz; + } + return s; +}; +const parseMs = function(str = "") { + str = String(str); + if (str.length > 3) { + str = str.substring(0, 3); + } else if (str.length === 1) { + str = str + "00"; + } else if (str.length === 2) { + str = str + "0"; + } + return Number(str) || 0; +}; +const parseTime = (s, str = "") => { + str = str.replace(/^\s+/, "").toLowerCase(); + let arr = str.match(/([0-9]{1,2}):([0-9]{1,2}):?([0-9]{1,2})?[:.]?([0-9]{1,4})?/); + if (arr !== null) { + let [, h, m, sec, ms] = arr; + h = Number(h); + if (h < 0 || h > 24) { + return s.startOf("day"); + } + m = Number(m); + if (arr[2].length < 2 || m < 0 || m > 59) { + return s.startOf("day"); + } + s = s.hour(h); + s = s.minute(m); + s = s.seconds(sec || 0); + s = s.millisecond(parseMs(ms)); + let ampm = str.match(/[0-9] ?(am|pm)\b/); + if (ampm !== null && ampm[1]) { + s = s.ampm(ampm[1]); + } + return s; + } + arr = str.match(/([0-9]+) ?(am|pm)/); + if (arr !== null && arr[1]) { + let h = Number(arr[1]); + if (h > 12 || h < 1) { + return s.startOf("day"); + } + s = s.hour(arr[1] || 0); + s = s.ampm(arr[2]); + s = s.startOf("hour"); + return s; + } + s = s.startOf("day"); + return s; +}; +let months$1 = mapping$1(); +const validate$1 = (obj) => { + if (monthLengths.hasOwnProperty(obj.month) !== true) { + return false; + } + if (obj.month === 1) { + if (isLeapYear(obj.year) && obj.date <= 29) { + return true; + } else { + return obj.date <= 28; + } + } + let max = monthLengths[obj.month] || 0; + if (obj.date <= max) { + return true; + } + return false; +}; +const parseYear = (str = "", today) => { + str = str.trim(); + if (/^'[0-9][0-9]$/.test(str) === true) { + let num = Number(str.replace(/'/, "")); + if (num > 50) { + return 1900 + num; + } + return 2e3 + num; + } + let year2 = parseInt(str, 10); + if (!year2 && today) { + year2 = today.year; + } + year2 = year2 || (/* @__PURE__ */ new Date()).getFullYear(); + return year2; +}; +const parseMonth = function(str) { + str = str.toLowerCase().trim(); + if (str === "sept") { + return months$1.sep; + } + return months$1[str]; +}; +const ymd = [ + // ===== + // y-m-d + // ===== + //iso-this 1998-05-30T22:00:00:000Z, iso-that 2017-04-03T08:00:00-0700 + { + reg: /^(-?0{0,2}[0-9]{3,4})-([0-9]{1,2})-([0-9]{1,2})[T| ]([0-9.:]+)(Z|[0-9-+:]+)?$/i, + parse: (s, m) => { + let obj = { + year: m[1], + month: parseInt(m[2], 10) - 1, + date: m[3] + }; + if (validate$1(obj) === false) { + s.epoch = null; + return s; + } + parseOffset$2(s, m[5]); + walkTo(s, obj); + s = parseTime(s, m[4]); + return s; + } + }, + //short-iso "2015-03-25" or "2015/03/25" or "2015/03/25 12:26:14 PM" + { + reg: /^([0-9]{4})[\-/. ]([0-9]{1,2})[\-/. ]([0-9]{1,2})( [0-9]{1,2}(:[0-9]{0,2})?(:[0-9]{0,3})? ?(am|pm)?)?$/i, + parse: (s, m) => { + let obj = { + year: m[1], + month: parseInt(m[2], 10) - 1, + date: parseInt(m[3], 10) + }; + if (obj.month >= 12) { + obj.date = parseInt(m[2], 10); + obj.month = parseInt(m[3], 10) - 1; + } + if (validate$1(obj) === false) { + s.epoch = null; + return s; + } + walkTo(s, obj); + s = parseTime(s, m[4]); + return s; + } + }, + //text-month "2015-feb-25" + { + reg: /^([0-9]{4})[\-/. ]([a-z]+)[\-/. ]([0-9]{1,2})( [0-9]{1,2}(:[0-9]{0,2})?(:[0-9]{0,3})? ?(am|pm)?)?$/i, + parse: (s, m) => { + let obj = { + year: parseYear(m[1], s._today), + month: parseMonth(m[2]), + date: toCardinal(m[3] || "") + }; + if (validate$1(obj) === false) { + s.epoch = null; + return s; + } + walkTo(s, obj); + s = parseTime(s, m[4]); + return s; + } + } +]; +const mdy = [ + // ===== + // m-d-y + // ===== + //mm/dd/yyyy - uk/canada "6/28/2019, 12:26:14 PM" + { + reg: /^([0-9]{1,2})[-/.]([0-9]{1,2})[\-/.]?([0-9]{4})?( [0-9]{1,2}:[0-9]{2}:?[0-9]{0,2} ?(am|pm|gmt))?$/i, + parse: (s, arr) => { + let month2 = parseInt(arr[1], 10) - 1; + let date2 = parseInt(arr[2], 10); + if (s.british || month2 >= 12) { + date2 = parseInt(arr[1], 10); + month2 = parseInt(arr[2], 10) - 1; + } + let obj = { + date: date2, + month: month2, + year: parseYear(arr[3], s._today) || (/* @__PURE__ */ new Date()).getFullYear() + }; + if (validate$1(obj) === false) { + s.epoch = null; + return s; + } + walkTo(s, obj); + s = parseTime(s, arr[4]); + return s; + } + }, + //alt short format - "feb-25-2015" + { + reg: /^([a-z]+)[\-/. ]([0-9]{1,2})[\-/. ]?([0-9]{4}|'[0-9]{2})?( [0-9]{1,2}(:[0-9]{0,2})?(:[0-9]{0,3})? ?(am|pm)?)?$/i, + parse: (s, arr) => { + let obj = { + year: parseYear(arr[3], s._today), + month: parseMonth(arr[1]), + date: toCardinal(arr[2] || "") + }; + if (validate$1(obj) === false) { + s.epoch = null; + return s; + } + walkTo(s, obj); + s = parseTime(s, arr[4]); + return s; + } + }, + //Long "Mar 25 2015" + //February 22, 2017 15:30:00 + { + reg: /^([a-z]+) ([0-9]{1,2})( [0-9]{4})?( ([0-9:]+( ?am| ?pm| ?gmt)?))?$/i, + parse: (s, arr) => { + let obj = { + year: parseYear(arr[3], s._today), + month: parseMonth(arr[1]), + date: toCardinal(arr[2] || "") + }; + if (validate$1(obj) === false) { + s.epoch = null; + return s; + } + walkTo(s, obj); + s = parseTime(s, arr[4]); + return s; + } + }, + // 'Sun Mar 14 15:09:48 +0000 2021' + { + reg: /^([a-z]+) ([0-9]{1,2}) ([0-9]{1,2}:[0-9]{2}:?[0-9]{0,2})( \+[0-9]{4})?( [0-9]{4})?$/i, + parse: (s, arr) => { + let [, month2, date2, time2, tz, year2] = arr; + let obj = { + year: parseYear(year2, s._today), + month: parseMonth(month2), + date: toCardinal(date2 || "") + }; + if (validate$1(obj) === false) { + s.epoch = null; + return s; + } + walkTo(s, obj); + s = parseOffset$2(s, tz); + s = parseTime(s, time2); + return s; + } + } +]; +const dmy = [ + // ===== + // d-m-y + // ===== + //common british format - "25-feb-2015" + { + reg: /^([0-9]{1,2})[-/]([a-z]+)[\-/]?([0-9]{4})?$/i, + parse: (s, m) => { + let obj = { + year: parseYear(m[3], s._today), + month: parseMonth(m[2]), + date: toCardinal(m[1] || "") + }; + if (validate$1(obj) === false) { + s.epoch = null; + return s; + } + walkTo(s, obj); + s = parseTime(s, m[4]); + return s; + } + }, + // "25 Mar 2015" + { + reg: /^([0-9]{1,2})( [a-z]+)( [0-9]{4}| '[0-9]{2})? ?([0-9]{1,2}:[0-9]{2}:?[0-9]{0,2} ?(am|pm|gmt))?$/i, + parse: (s, m) => { + let obj = { + year: parseYear(m[3], s._today), + month: parseMonth(m[2]), + date: toCardinal(m[1]) + }; + if (!obj.month || validate$1(obj) === false) { + s.epoch = null; + return s; + } + walkTo(s, obj); + s = parseTime(s, m[4]); + return s; + } + }, + // 01-jan-2020 + { + reg: /^([0-9]{1,2})[. \-/]([a-z]+)[. \-/]([0-9]{4})?( [0-9]{1,2}(:[0-9]{0,2})?(:[0-9]{0,3})? ?(am|pm)?)?$/i, + parse: (s, m) => { + let obj = { + date: Number(m[1]), + month: parseMonth(m[2]), + year: Number(m[3]) + }; + if (validate$1(obj) === false) { + s.epoch = null; + return s; + } + walkTo(s, obj); + s = s.startOf("day"); + s = parseTime(s, m[4]); + return s; + } + } +]; +const misc$1 = [ + // ===== + // no dates + // ===== + // '2012-06' month-only + { + reg: /^([0-9]{4})[\-/]([0-9]{2})$/, + parse: (s, m) => { + let obj = { + year: m[1], + month: parseInt(m[2], 10) - 1, + date: 1 + }; + if (validate$1(obj) === false) { + s.epoch = null; + return s; + } + walkTo(s, obj); + s = parseTime(s, m[4]); + return s; + } + }, + //February 2017 (implied date) + { + reg: /^([a-z]+) ([0-9]{4})$/i, + parse: (s, arr) => { + let obj = { + year: parseYear(arr[2], s._today), + month: parseMonth(arr[1]), + date: s._today.date || 1 + }; + if (validate$1(obj) === false) { + s.epoch = null; + return s; + } + walkTo(s, obj); + s = parseTime(s, arr[4]); + return s; + } + }, + { + // 'q2 2002' + reg: /^(q[0-9])( of)?( [0-9]{4})?/i, + parse: (s, arr) => { + let quarter = arr[1] || ""; + s = s.quarter(quarter); + let year2 = arr[3] || ""; + if (year2) { + year2 = year2.trim(); + s = s.year(year2); + } + return s; + } + }, + { + // 'summer 2002' + reg: /^(spring|summer|winter|fall|autumn)( of)?( [0-9]{4})?/i, + parse: (s, arr) => { + let season = arr[1] || ""; + s = s.season(season); + let year2 = arr[3] || ""; + if (year2) { + year2 = year2.trim(); + s = s.year(year2); + } + return s; + } + }, + { + // '200bc' + reg: /^[0-9,]+ ?b\.?c\.?$/i, + parse: (s, arr) => { + let str = arr[0] || ""; + str = str.replace(/^([0-9,]+) ?b\.?c\.?$/i, "-$1"); + let d = /* @__PURE__ */ new Date(); + let obj = { + year: parseInt(str.trim(), 10), + month: d.getMonth(), + date: d.getDate() + }; + if (validate$1(obj) === false) { + s.epoch = null; + return s; + } + walkTo(s, obj); + s = parseTime(s); + return s; + } + }, + { + // '200ad' + reg: /^[0-9,]+ ?(a\.?d\.?|c\.?e\.?)$/i, + parse: (s, arr) => { + let str = arr[0] || ""; + str = str.replace(/,/g, ""); + let d = /* @__PURE__ */ new Date(); + let obj = { + year: parseInt(str.trim(), 10), + month: d.getMonth(), + date: d.getDate() + }; + if (validate$1(obj) === false) { + s.epoch = null; + return s; + } + walkTo(s, obj); + s = parseTime(s); + return s; + } + }, + { + // '1992' + reg: /^[0-9]{4}( ?a\.?d\.?)?$/i, + parse: (s, arr) => { + let today = s._today; + if (today.month && !today.date) { + today.date = 1; + } + let d = /* @__PURE__ */ new Date(); + let obj = { + year: parseYear(arr[0], today), + month: today.month || d.getMonth(), + date: today.date || d.getDate() + }; + if (validate$1(obj) === false) { + s.epoch = null; + return s; + } + walkTo(s, obj); + s = parseTime(s); + return s; + } + } +]; +const parsers = [].concat(ymd, mdy, dmy, misc$1); +const parseString = function(s, input, givenTz) { + for (let i = 0; i < parsers.length; i++) { + let m = input.match(parsers[i].reg); + if (m) { + let res = parsers[i].parse(s, m, givenTz); + if (res !== null && res.isValid()) { + return res; + } + } + } + if (s.silent === false) { + console.warn("Warning: couldn't parse date-string: '" + input + "'"); + } + s.epoch = null; + return s; +}; +const { parseArray, parseObject, parseNumber } = fns; +const defaults = { + year: (/* @__PURE__ */ new Date()).getFullYear(), + month: 0, + date: 1 +}; +const parseInput = (s, input) => { + let today = s._today || defaults; + if (typeof input === "number") { + return parseNumber(s, input); + } + s.epoch = Date.now(); + if (s._today && isObject(s._today) && Object.keys(s._today).length > 0) { + let res = parseObject(s, today, defaults); + if (res.isValid()) { + s.epoch = res.epoch; + } + } + if (input === null || input === void 0 || input === "") { + return s; + } + if (isDate(input) === true) { + s.epoch = input.getTime(); + return s; + } + if (isArray(input) === true) { + s = parseArray(s, input, today); + return s; + } + if (isObject(input) === true) { + if (input.epoch) { + s.epoch = input.epoch; + s.tz = input.tz; + return s; + } + s = parseObject(s, input, today); + return s; + } + if (typeof input !== "string") { + return s; + } + input = normalize$1(input); + if (dates.hasOwnProperty(input) === true) { + s = dates[input](s); + return s; + } + return parseString(s, input); +}; +let shortDays = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]; +let longDays = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"]; +function short() { + return shortDays; +} +function long() { + return longDays; +} +function set$4(i18n) { + shortDays = i18n.short || shortDays; + longDays = i18n.long || longDays; +} +const aliases$1 = { + mo: 1, + tu: 2, + we: 3, + th: 4, + fr: 5, + sa: 6, + su: 7, + tues: 2, + weds: 3, + wedn: 3, + thur: 4, + thurs: 4 +}; +let titleCaseEnabled = true; +function useTitleCase() { + return titleCaseEnabled; +} +function set$3(val) { + titleCaseEnabled = val; +} +const isoOffset = (s) => { + let offset = s.timezone().current.offset; + return !offset ? "Z" : formatTimezone(offset, ":"); +}; +const applyCaseFormat = (str) => { + if (useTitleCase()) { + return titleCase$1(str); + } + return str; +}; +const padYear = (num) => { + if (num >= 0) { + return zeroPad(num, 4); + } else { + num = Math.abs(num); + return "-" + zeroPad(num, 4); + } +}; +const format = { + day: (s) => applyCaseFormat(s.dayName()), + "day-short": (s) => applyCaseFormat(short()[s.day()]), + "day-number": (s) => s.day(), + "day-ordinal": (s) => ordinal(s.day()), + "day-pad": (s) => zeroPad(s.day()), + date: (s) => s.date(), + "date-ordinal": (s) => ordinal(s.date()), + "date-pad": (s) => zeroPad(s.date()), + month: (s) => applyCaseFormat(s.monthName()), + "month-short": (s) => applyCaseFormat(short$1()[s.month()]), + "month-number": (s) => s.month(), + "month-ordinal": (s) => ordinal(s.month()), + "month-pad": (s) => zeroPad(s.month()), + "iso-month": (s) => zeroPad(s.month() + 1), + //1-based months + year: (s) => { + let year2 = s.year(); + if (year2 > 0) { + return year2; + } + year2 = Math.abs(year2); + return year2 + " BC"; + }, + "year-short": (s) => { + let year2 = s.year(); + if (year2 > 0) { + return `'${String(s.year()).substr(2, 4)}`; + } + year2 = Math.abs(year2); + return year2 + " BC"; + }, + "iso-year": (s) => { + let year2 = s.year(); + let isNegative = year2 < 0; + let str = zeroPad(Math.abs(year2), 4); + if (isNegative) { + str = zeroPad(str, 6); + str = "-" + str; + } + return str; + }, + time: (s) => s.time(), + "time-24": (s) => `${s.hour24()}:${zeroPad(s.minute())}`, + hour: (s) => s.hour12(), + "hour-pad": (s) => zeroPad(s.hour12()), + "hour-24": (s) => s.hour24(), + "hour-24-pad": (s) => zeroPad(s.hour24()), + minute: (s) => s.minute(), + "minute-pad": (s) => zeroPad(s.minute()), + second: (s) => s.second(), + "second-pad": (s) => zeroPad(s.second()), + millisecond: (s) => s.millisecond(), + "millisecond-pad": (s) => zeroPad(s.millisecond(), 3), + ampm: (s) => s.ampm(), + AMPM: (s) => s.ampm().toUpperCase(), + quarter: (s) => "Q" + s.quarter(), + season: (s) => s.season(), + era: (s) => s.era(), + json: (s) => s.json(), + timezone: (s) => s.timezone().name, + offset: (s) => isoOffset(s), + numeric: (s) => `${s.year()}/${zeroPad(s.month() + 1)}/${zeroPad(s.date())}`, + // yyyy/mm/dd + "numeric-us": (s) => `${zeroPad(s.month() + 1)}/${zeroPad(s.date())}/${s.year()}`, + // mm/dd/yyyy + "numeric-uk": (s) => `${zeroPad(s.date())}/${zeroPad(s.month() + 1)}/${s.year()}`, + //dd/mm/yyyy + "mm/dd": (s) => `${zeroPad(s.month() + 1)}/${zeroPad(s.date())}`, + //mm/dd + // ... https://en.wikipedia.org/wiki/ISO_8601 ;((( + iso: (s) => { + let year2 = s.format("iso-year"); + let month2 = zeroPad(s.month() + 1); + let date2 = zeroPad(s.date()); + let hour = zeroPad(s.h24()); + let minute = zeroPad(s.minute()); + let second = zeroPad(s.second()); + let ms = zeroPad(s.millisecond(), 3); + let offset = isoOffset(s); + return `${year2}-${month2}-${date2}T${hour}:${minute}:${second}.${ms}${offset}`; + }, + "iso-short": (s) => { + let month2 = zeroPad(s.month() + 1); + let date2 = zeroPad(s.date()); + let year2 = padYear(s.year()); + return `${year2}-${month2}-${date2}`; + }, + "iso-utc": (s) => { + return new Date(s.epoch).toISOString(); + }, + //i made these up + nice: (s) => `${short$1()[s.month()]} ${ordinal(s.date())}, ${s.time()}`, + "nice-24": (s) => `${short$1()[s.month()]} ${ordinal(s.date())}, ${s.hour24()}:${zeroPad( + s.minute() + )}`, + "nice-year": (s) => `${short$1()[s.month()]} ${ordinal(s.date())}, ${s.year()}`, + "nice-day": (s) => `${short()[s.day()]} ${applyCaseFormat(short$1()[s.month()])} ${ordinal( + s.date() + )}`, + "nice-full": (s) => `${s.dayName()} ${applyCaseFormat(s.monthName())} ${ordinal(s.date())}, ${s.time()}`, + "nice-full-24": (s) => `${s.dayName()} ${applyCaseFormat(s.monthName())} ${ordinal( + s.date() + )}, ${s.hour24()}:${zeroPad(s.minute())}` +}; +const aliases = { + "day-name": "day", + "month-name": "month", + "iso 8601": "iso", + "time-h24": "time-24", + "time-12": "time", + "time-h12": "time", + tz: "timezone", + "day-num": "day-number", + "month-num": "month-number", + "month-iso": "iso-month", + "year-iso": "iso-year", + "nice-short": "nice", + "nice-short-24": "nice-24", + mdy: "numeric-us", + dmy: "numeric-uk", + ymd: "numeric", + "yyyy/mm/dd": "numeric", + "mm/dd/yyyy": "numeric-us", + "dd/mm/yyyy": "numeric-us", + "little-endian": "numeric-uk", + "big-endian": "numeric", + "day-nice": "nice-day" +}; +Object.keys(aliases).forEach((k) => format[k] = format[aliases[k]]); +const printFormat = (s, str = "") => { + if (s.isValid() !== true) { + return ""; + } + if (format.hasOwnProperty(str)) { + let out = format[str](s) || ""; + if (str !== "json") { + out = String(out); + if (str.toLowerCase() !== "ampm") { + out = applyCaseFormat(out); + } + } + return out; + } + if (str.indexOf("{") !== -1) { + let sections = /\{(.+?)\}/g; + str = str.replace(sections, (_, fmt2) => { + fmt2 = fmt2.trim(); + if (fmt2 !== "AMPM") { + fmt2 = fmt2.toLowerCase(); + } + if (format.hasOwnProperty(fmt2)) { + let out = String(format[fmt2](s)); + if (fmt2.toLowerCase() !== "ampm") { + return applyCaseFormat(out); + } + return out; + } + return ""; + }); + return str; + } + return s.format("iso-short"); +}; +const mapping = { + G: (s) => s.era(), + GG: (s) => s.era(), + GGG: (s) => s.era(), + GGGG: (s) => s.era() === "AD" ? "Anno Domini" : "Before Christ", + //year + y: (s) => s.year(), + yy: (s) => { + return zeroPad(Number(String(s.year()).substr(2, 4))); + }, + yyy: (s) => s.year(), + yyyy: (s) => s.year(), + yyyyy: (s) => "0" + s.year(), + // u: (s) => {},//extended non-gregorian years + //quarter + Q: (s) => s.quarter(), + QQ: (s) => s.quarter(), + QQQ: (s) => s.quarter(), + QQQQ: (s) => s.quarter(), + //month + M: (s) => s.month() + 1, + MM: (s) => zeroPad(s.month() + 1), + MMM: (s) => s.format("month-short"), + MMMM: (s) => s.format("month"), + //week + w: (s) => s.week(), + ww: (s) => zeroPad(s.week()), + //week of month + // W: (s) => s.week(), + //date of month + d: (s) => s.date(), + dd: (s) => zeroPad(s.date()), + //date of year + D: (s) => s.dayOfYear(), + DD: (s) => zeroPad(s.dayOfYear()), + DDD: (s) => zeroPad(s.dayOfYear(), 3), + // F: (s) => {},//date of week in month + // g: (s) => {},//modified julian day + //day + E: (s) => s.format("day-short"), + EE: (s) => s.format("day-short"), + EEE: (s) => s.format("day-short"), + EEEE: (s) => s.format("day"), + EEEEE: (s) => s.format("day")[0], + e: (s) => s.day(), + ee: (s) => s.day(), + eee: (s) => s.format("day-short"), + eeee: (s) => s.format("day"), + eeeee: (s) => s.format("day")[0], + //am/pm + a: (s) => s.ampm().toUpperCase(), + aa: (s) => s.ampm().toUpperCase(), + aaa: (s) => s.ampm().toUpperCase(), + aaaa: (s) => s.ampm().toUpperCase(), + //hour + h: (s) => s.h12(), + hh: (s) => zeroPad(s.h12()), + H: (s) => s.hour(), + HH: (s) => zeroPad(s.hour()), + // j: (s) => {},//weird hour format + m: (s) => s.minute(), + mm: (s) => zeroPad(s.minute()), + s: (s) => s.second(), + ss: (s) => zeroPad(s.second()), + //milliseconds + SSS: (s) => zeroPad(s.millisecond(), 3), + //milliseconds in the day + A: (s) => s.epoch - s.startOf("day").epoch, + //timezone + z: (s) => s.timezone().name, + zz: (s) => s.timezone().name, + zzz: (s) => s.timezone().name, + zzzz: (s) => s.timezone().name, + Z: (s) => formatTimezone(s.timezone().current.offset), + ZZ: (s) => formatTimezone(s.timezone().current.offset), + ZZZ: (s) => formatTimezone(s.timezone().current.offset), + ZZZZ: (s) => formatTimezone(s.timezone().current.offset, ":") +}; +const addAlias = (char, to, n) => { + let name2 = char; + let toName = to; + for (let i = 0; i < n; i += 1) { + mapping[name2] = mapping[toName]; + name2 += char; + toName += to; + } +}; +addAlias("q", "Q", 4); +addAlias("L", "M", 4); +addAlias("Y", "y", 4); +addAlias("c", "e", 4); +addAlias("k", "H", 2); +addAlias("K", "h", 2); +addAlias("S", "s", 2); +addAlias("v", "z", 4); +addAlias("V", "Z", 4); +const escapeChars = function(arr) { + for (let i = 0; i < arr.length; i += 1) { + if (arr[i] === `'`) { + for (let o2 = i + 1; o2 < arr.length; o2 += 1) { + if (arr[o2]) { + arr[i] += arr[o2]; + } + if (arr[o2] === `'`) { + arr[o2] = null; + break; + } + arr[o2] = null; + } + } + } + return arr.filter((ch) => ch); +}; +const combineRepeated = function(arr) { + for (let i = 0; i < arr.length; i += 1) { + let c = arr[i]; + for (let o2 = i + 1; o2 < arr.length; o2 += 1) { + if (arr[o2] === c) { + arr[i] += arr[o2]; + arr[o2] = null; + } else { + break; + } + } + } + arr = arr.filter((ch) => ch); + arr = arr.map((str) => { + if (str === `''`) { + str = `'`; + } + return str; + }); + return arr; +}; +const unixFmt = (s, str) => { + let arr = str.split(""); + arr = escapeChars(arr); + arr = combineRepeated(arr); + return arr.reduce((txt, c) => { + if (mapping[c] !== void 0) { + txt += mapping[c](s) || ""; + } else { + if (/^'.+'$/.test(c)) { + c = c.replace(/'/g, ""); + } + txt += c; + } + return txt; + }, ""); +}; +const units$3 = ["year", "season", "quarter", "month", "week", "day", "quarterHour", "hour", "minute"]; +const doUnit = function(s, k) { + let start = s.clone().startOf(k); + let end = s.clone().endOf(k); + let duration = end.epoch - start.epoch; + let percent = (s.epoch - start.epoch) / duration; + return parseFloat(percent.toFixed(2)); +}; +const progress = (s, unit) => { + if (unit) { + unit = normalize$2(unit); + return doUnit(s, unit); + } + let obj = {}; + units$3.forEach((k) => { + obj[k] = doUnit(s, k); + }); + return obj; +}; +const nearest = (s, unit) => { + let prog = s.progress(); + unit = normalize$2(unit); + if (unit === "quarterhour") { + unit = "quarterHour"; + } + if (prog[unit] !== void 0) { + if (prog[unit] > 0.5) { + s = s.add(1, unit); + } + s = s.startOf(unit); + } else if (s.silent === false) { + console.warn("no known unit '" + unit + "'"); + } + return s; +}; +const climb = (a, b, unit) => { + let i = 0; + a = a.clone(); + while (a.isBefore(b)) { + a = a.add(1, unit); + i += 1; + } + if (a.isAfter(b, unit)) { + i -= 1; + } + return i; +}; +const diffOne = (a, b, unit) => { + if (a.isBefore(b)) { + return climb(a, b, unit); + } else { + return climb(b, a, unit) * -1; + } +}; +const fastYear = (a, b) => { + let years = b.year() - a.year(); + a = a.year(b.year()); + if (a.isAfter(b)) { + years -= 1; + } + return years; +}; +const diff = function(a, b) { + let msDiff = b.epoch - a.epoch; + let obj = { + milliseconds: msDiff, + seconds: parseInt(msDiff / 1e3, 10) + }; + obj.minutes = parseInt(obj.seconds / 60, 10); + obj.hours = parseInt(obj.minutes / 60, 10); + let tmp = a.clone(); + obj.years = fastYear(tmp, b); + tmp = a.add(obj.years, "year"); + obj.months = obj.years * 12; + tmp = a.add(obj.months, "month"); + obj.months += diffOne(tmp, b, "month"); + obj.quarters = obj.years * 4; + obj.quarters += parseInt(obj.months % 12 / 3, 10); + obj.weeks = obj.years * 52; + tmp = a.add(obj.weeks, "week"); + obj.weeks += diffOne(tmp, b, "week"); + obj.days = obj.weeks * 7; + tmp = a.add(obj.days, "day"); + obj.days += diffOne(tmp, b, "day"); + return obj; +}; +const reverseDiff = function(obj) { + Object.keys(obj).forEach((k) => { + obj[k] *= -1; + }); + return obj; +}; +const main$3 = function(a, b, unit) { + b = beADate(b, a); + let reversed = false; + if (a.isAfter(b)) { + let tmp = a; + a = b; + b = tmp; + reversed = true; + } + let obj = diff(a, b); + if (reversed) { + obj = reverseDiff(obj); + } + if (unit) { + unit = normalize$2(unit); + if (/s$/.test(unit) !== true) { + unit += "s"; + } + if (unit === "dates") { + unit = "days"; + } + return obj[unit]; + } + return obj; +}; +const fmt = (n) => Math.abs(n) || 0; +const toISO = function(diff2) { + let iso = "P"; + iso += fmt(diff2.years) + "Y"; + iso += fmt(diff2.months) + "M"; + iso += fmt(diff2.days) + "DT"; + iso += fmt(diff2.hours) + "H"; + iso += fmt(diff2.minutes) + "M"; + iso += fmt(diff2.seconds) + "S"; + return iso; +}; +function getDiff(a, b) { + const isBefore = a.isBefore(b); + const later = isBefore ? b : a; + let earlier = isBefore ? a : b; + earlier = earlier.clone(); + const diff2 = { + years: 0, + months: 0, + days: 0, + hours: 0, + minutes: 0, + seconds: 0 + }; + Object.keys(diff2).forEach((unit) => { + if (earlier.isSame(later, unit)) { + return; + } + let max = earlier.diff(later, unit); + earlier = earlier.add(max, unit); + diff2[unit] = max; + }); + if (isBefore) { + Object.keys(diff2).forEach((u) => { + if (diff2[u] !== 0) { + diff2[u] *= -1; + } + }); + } + return diff2; +} +let units$2 = { + second: "second", + seconds: "seconds", + minute: "minute", + minutes: "minutes", + hour: "hour", + hours: "hours", + day: "day", + days: "days", + month: "month", + months: "months", + year: "year", + years: "years" +}; +function unitsString(unit) { + return units$2[unit] || ""; +} +function set$2(i18n = {}) { + units$2 = { + second: i18n.second || units$2.second, + seconds: i18n.seconds || units$2.seconds, + minute: i18n.minute || units$2.minute, + minutes: i18n.minutes || units$2.minutes, + hour: i18n.hour || units$2.hour, + hours: i18n.hours || units$2.hours, + day: i18n.day || units$2.day, + days: i18n.days || units$2.days, + month: i18n.month || units$2.month, + months: i18n.months || units$2.months, + year: i18n.year || units$2.year, + years: i18n.years || units$2.years + }; +} +let past = "past"; +let future = "future"; +let present = "present"; +let now = "now"; +let almost = "almost"; +let over = "over"; +let pastDistance = (value) => `${value} ago`; +let futureDistance = (value) => `in ${value}`; +function pastDistanceString(value) { + return pastDistance(value); +} +function futureDistanceString(value) { + return futureDistance(value); +} +function pastString() { + return past; +} +function futureString() { + return future; +} +function presentString() { + return present; +} +function nowString() { + return now; +} +function almostString() { + return almost; +} +function overString() { + return over; +} +function set$1(i18n) { + pastDistance = i18n.pastDistance || pastDistance; + futureDistance = i18n.futureDistance || futureDistance; + past = i18n.past || past; + future = i18n.future || future; + present = i18n.present || present; + now = i18n.now || now; + almost = i18n.almost || almost; + over = i18n.over || over; +} +const qualifiers = { + months: { + almost: 10, + over: 4 + }, + days: { + almost: 25, + over: 10 + }, + hours: { + almost: 20, + over: 8 + }, + minutes: { + almost: 50, + over: 20 + }, + seconds: { + almost: 50, + over: 20 + } +}; +function pluralize(value, unit) { + if (value === 1) { + return value + " " + unitsString(unit.slice(0, -1)); + } + return value + " " + unitsString(unit); +} +const toSoft = function(diff2) { + let rounded = null; + let qualified = null; + let abbreviated = []; + let englishValues = []; + Object.keys(diff2).forEach((unit, i, units2) => { + const value = Math.abs(diff2[unit]); + if (value === 0) { + return; + } + abbreviated.push(value + unit[0]); + const englishValue = pluralize(value, unit); + englishValues.push(englishValue); + if (!rounded) { + rounded = englishValue; + qualified = englishValue; + if (i > 4) { + return; + } + const nextUnit = units2[i + 1]; + const nextValue = Math.abs(diff2[nextUnit]); + if (nextValue > qualifiers[nextUnit].almost) { + rounded = pluralize(value + 1, unit); + qualified = almostString() + " " + rounded; + } else if (nextValue > qualifiers[nextUnit].over) { + qualified = overString() + " " + englishValue; + } + } + }); + return { qualified, rounded, abbreviated, englishValues }; +}; +const since = (start, end) => { + end = beADate(end, start); + const diff2 = getDiff(start, end); + const isNow = Object.keys(diff2).every((u) => !diff2[u]); + if (isNow === true) { + return { + diff: diff2, + rounded: nowString(), + qualified: nowString(), + precise: nowString(), + abbreviated: [], + iso: "P0Y0M0DT0H0M0S", + direction: presentString() + }; + } + let precise; + let direction = futureString(); + let { rounded, qualified, englishValues, abbreviated } = toSoft(diff2); + precise = englishValues.splice(0, 2).join(", "); + if (start.isAfter(end) === true) { + rounded = pastDistanceString(rounded); + qualified = pastDistanceString(qualified); + precise = pastDistanceString(precise); + direction = pastString(); + } else { + rounded = futureDistanceString(rounded); + qualified = futureDistanceString(qualified); + precise = futureDistanceString(precise); + } + let iso = toISO(diff2); + return { + diff: diff2, + rounded, + qualified, + precise, + abbreviated, + iso, + direction + }; +}; +const north = [ + ["spring", 2, 1], + ["summer", 5, 1], + ["fall", 8, 1], + ["autumn", 8, 1], + ["winter", 11, 1] + //dec 1 +]; +const south = [ + ["fall", 2, 1], + ["autumn", 2, 1], + ["winter", 5, 1], + ["spring", 8, 1], + ["summer", 11, 1] + //dec 1 +]; +const seasons = { north, south }; +const quarters = [ + null, + [0, 1], + //jan 1 + [3, 1], + //apr 1 + [6, 1], + //july 1 + [9, 1] + //oct 1 +]; +const units$1 = { + second: (s) => { + walkTo(s, { + millisecond: 0 + }); + return s; + }, + minute: (s) => { + walkTo(s, { + second: 0, + millisecond: 0 + }); + return s; + }, + quarterhour: (s) => { + let minute = s.minutes(); + if (minute >= 45) { + s = s.minutes(45); + } else if (minute >= 30) { + s = s.minutes(30); + } else if (minute >= 15) { + s = s.minutes(15); + } else { + s = s.minutes(0); + } + walkTo(s, { + second: 0, + millisecond: 0 + }); + return s; + }, + hour: (s) => { + walkTo(s, { + minute: 0, + second: 0, + millisecond: 0 + }); + return s; + }, + day: (s) => { + walkTo(s, { + hour: 0, + minute: 0, + second: 0, + millisecond: 0 + }); + return s; + }, + week: (s) => { + let original = s.clone(); + s = s.day(s._weekStart); + if (s.isAfter(original)) { + s = s.subtract(1, "week"); + } + walkTo(s, { + hour: 0, + minute: 0, + second: 0, + millisecond: 0 + }); + return s; + }, + month: (s) => { + walkTo(s, { + date: 1, + hour: 0, + minute: 0, + second: 0, + millisecond: 0 + }); + return s; + }, + quarter: (s) => { + let q = s.quarter(); + if (quarters[q]) { + walkTo(s, { + month: quarters[q][0], + date: quarters[q][1], + hour: 0, + minute: 0, + second: 0, + millisecond: 0 + }); + } + return s; + }, + season: (s) => { + let current = s.season(); + let hem = "north"; + if (s.hemisphere() === "South") { + hem = "south"; + } + for (let i = 0; i < seasons[hem].length; i++) { + if (seasons[hem][i][0] === current) { + let year2 = s.year(); + if (current === "winter" && s.month() < 3) { + year2 -= 1; + } + walkTo(s, { + year: year2, + month: seasons[hem][i][1], + date: seasons[hem][i][2], + hour: 0, + minute: 0, + second: 0, + millisecond: 0 + }); + return s; + } + } + return s; + }, + year: (s) => { + walkTo(s, { + month: 0, + date: 1, + hour: 0, + minute: 0, + second: 0, + millisecond: 0 + }); + return s; + }, + decade: (s) => { + s = s.startOf("year"); + let year2 = s.year(); + let decade = parseInt(year2 / 10, 10) * 10; + s = s.year(decade); + return s; + }, + century: (s) => { + s = s.startOf("year"); + let year2 = s.year(); + let decade = parseInt(year2 / 100, 10) * 100; + s = s.year(decade); + return s; + } +}; +units$1.date = units$1.day; +const startOf = (a, unit) => { + let s = a.clone(); + unit = normalize$2(unit); + if (units$1[unit]) { + return units$1[unit](s); + } + if (unit === "summer" || unit === "winter") { + s = s.season(unit); + return units$1.season(s); + } + return s; +}; +const endOf = (a, unit) => { + let s = a.clone(); + unit = normalize$2(unit); + if (units$1[unit]) { + s = units$1[unit](s); + s = s.add(1, unit); + s = s.subtract(1, "millisecond"); + return s; + } + return s; +}; +const isDay = function(unit) { + if (short().find((s) => s === unit)) { + return true; + } + if (long().find((s) => s === unit)) { + return true; + } + return false; +}; +const every = function(start, unit, end, stepCount = 1) { + if (!unit || !end) { + return []; + } + unit = normalize$2(unit); + end = start.clone().set(end); + if (start.isAfter(end)) { + let tmp = start; + start = end; + end = tmp; + } + if (start.diff(end, unit) < stepCount) { + return []; + } + let d = start.clone(); + if (isDay(unit)) { + d = d.next(unit); + unit = "week"; + } else { + let first = d.startOf(unit); + if (first.isBefore(start)) { + d = d.next(unit); + } + } + let result = []; + while (d.isBefore(end)) { + result.push(d); + d = d.add(stepCount, unit); + } + return result; +}; +const parseDst = (dst) => { + if (!dst) { + return []; + } + return dst.split("->"); +}; +const titleCase = (str) => { + str = str[0].toUpperCase() + str.substr(1); + str = str.replace(/[/_-]([a-z])/gi, (s) => { + return s.toUpperCase(); + }); + str = str.replace(/_(of|es)_/i, (s) => s.toLowerCase()); + str = str.replace(/\/gmt/i, "/GMT"); + str = str.replace(/\/Dumontdurville$/i, "/DumontDUrville"); + str = str.replace(/\/Mcmurdo$/i, "/McMurdo"); + str = str.replace(/\/Port-au-prince$/i, "/Port-au-Prince"); + return str; +}; +const timezone = (s) => { + let zones2 = s.timezones; + let tz = s.tz; + if (zones2.hasOwnProperty(tz) === false) { + tz = lookupTz(s.tz, zones2); + } + if (tz === null) { + if (s.silent === false) { + console.warn("Warn: could not find given or local timezone - '" + s.tz + "'"); + } + return { + current: { + epochShift: 0 + } + }; + } + let found = zones2[tz]; + let result = { + name: titleCase(tz), + hasDst: Boolean(found.dst), + default_offset: found.offset, + //do north-hemisphere version as default (sorry!) + hemisphere: found.hem === "s" ? "South" : "North", + current: {} + }; + if (result.hasDst) { + let arr = parseDst(found.dst); + result.change = { + start: arr[0], + back: arr[1] + }; + } + let summer = found.offset; + let winter = summer; + if (result.hasDst === true) { + if (result.hemisphere === "North") { + winter = summer - 1; + } else { + winter = found.offset + 1; + } + } + if (result.hasDst === false) { + result.current.offset = summer; + result.current.isDST = false; + } else if (inSummerTime(s.epoch, result.change.start, result.change.back, summer, winter) === true) { + result.current.offset = summer; + result.current.isDST = result.hemisphere === "North"; + } else { + result.current.offset = winter; + result.current.isDST = result.hemisphere === "South"; + } + return result; +}; +const units = [ + "century", + "decade", + "year", + "month", + "date", + "day", + "hour", + "minute", + "second", + "millisecond" +]; +const methods$4 = { + set: function(input, tz) { + let s = this.clone(); + s = parseInput(s, input); + if (tz) { + this.tz = lookupTz(tz); + } + return s; + }, + timezone: function() { + return timezone(this); + }, + isDST: function() { + return timezone(this).current.isDST; + }, + hasDST: function() { + return timezone(this).hasDst; + }, + offset: function() { + return timezone(this).current.offset * 60; + }, + hemisphere: function() { + return timezone(this).hemisphere; + }, + format: function(fmt2) { + return printFormat(this, fmt2); + }, + unixFmt: function(fmt2) { + return unixFmt(this, fmt2); + }, + startOf: function(unit) { + return startOf(this, unit); + }, + endOf: function(unit) { + return endOf(this, unit); + }, + leapYear: function() { + let year2 = this.year(); + return isLeapYear(year2); + }, + progress: function(unit) { + return progress(this, unit); + }, + nearest: function(unit) { + return nearest(this, unit); + }, + diff: function(d, unit) { + return main$3(this, d, unit); + }, + since: function(d) { + if (!d) { + d = this.clone().set(); + } + return since(this, d); + }, + next: function(unit) { + let s = this.add(1, unit); + return s.startOf(unit); + }, + //the start of the previous year/week/century + last: function(unit) { + let s = this.subtract(1, unit); + return s.startOf(unit); + }, + isValid: function() { + if (!this.epoch && this.epoch !== 0) { + return false; + } + return !isNaN(this.d.getTime()); + }, + //travel to this timezone + goto: function(tz) { + let s = this.clone(); + s.tz = lookupTz(tz, s.timezones); + return s; + }, + //get each week/month/day between a -> b + every: function(unit, to, stepCount) { + if (typeof unit === "object" && typeof to === "string") { + let tmp = to; + to = unit; + unit = tmp; + } + return every(this, unit, to, stepCount); + }, + isAwake: function() { + let hour = this.hour(); + if (hour < 8 || hour > 22) { + return false; + } + return true; + }, + isAsleep: function() { + return !this.isAwake(); + }, + daysInMonth: function() { + switch (this.month()) { + case 0: + return 31; + case 1: + return this.leapYear() ? 29 : 28; + case 2: + return 31; + case 3: + return 30; + case 4: + return 31; + case 5: + return 30; + case 6: + return 31; + case 7: + return 31; + case 8: + return 30; + case 9: + return 31; + case 10: + return 30; + case 11: + return 31; + default: + throw new Error("Invalid Month state."); + } + }, + //pretty-printing + log: function() { + console.log(""); + console.log(printFormat(this, "nice-short")); + return this; + }, + logYear: function() { + console.log(""); + console.log(printFormat(this, "full-short")); + return this; + }, + json: function() { + return units.reduce((h, unit) => { + h[unit] = this[unit](); + return h; + }, {}); + }, + debug: function() { + let tz = this.timezone(); + let date2 = this.format("MM") + " " + this.format("date-ordinal") + " " + this.year(); + date2 += "\n - " + this.format("time"); + console.log("\n\n", date2 + "\n - " + tz.name + " (" + tz.current.offset + ")"); + return this; + }, + //alias of 'since' but opposite - like moment.js + from: function(d) { + d = this.clone().set(d); + return d.since(this); + }, + fromNow: function() { + let d = this.clone().set(Date.now()); + return d.since(this); + }, + weekStart: function(input) { + if (typeof input === "number") { + this._weekStart = input; + return this; + } + if (typeof input === "string") { + input = input.toLowerCase().trim(); + let num = short().indexOf(input); + if (num === -1) { + num = long().indexOf(input); + } + if (num === -1) { + num = 1; + } + this._weekStart = num; + } else { + console.warn("Spacetime Error: Cannot understand .weekStart() input:", input); + } + return this; + } +}; +methods$4.inDST = methods$4.isDST; +methods$4.round = methods$4.nearest; +methods$4.each = methods$4.every; +const validate = (n) => { + if (typeof n === "string") { + n = parseInt(n, 10); + } + return n; +}; +const order$1 = ["year", "month", "date", "hour", "minute", "second", "millisecond"]; +const confirm = (s, tmp, unit) => { + let n = order$1.indexOf(unit); + let arr = order$1.slice(n, order$1.length); + for (let i = 0; i < arr.length; i++) { + let want = tmp[arr[i]](); + s[arr[i]](want); + } + return s; +}; +const fwdBkwd = function(s, old, goFwd, unit) { + if (goFwd === true && s.isBefore(old)) { + s = s.add(1, unit); + } else if (goFwd === false && s.isAfter(old)) { + s = s.minus(1, unit); + } + return s; +}; +const milliseconds = function(s, n) { + n = validate(n); + let current = s.millisecond(); + let diff2 = current - n; + return s.epoch - diff2; +}; +const seconds = function(s, n, goFwd) { + n = validate(n); + let old = s.clone(); + let diff2 = s.second() - n; + let shift = diff2 * o.second; + s.epoch = s.epoch - shift; + s = fwdBkwd(s, old, goFwd, "minute"); + return s.epoch; +}; +const minutes = function(s, n, goFwd) { + n = validate(n); + let old = s.clone(); + let diff2 = s.minute() - n; + let shift = diff2 * o.minute; + s.epoch -= shift; + confirm(s, old, "second"); + s = fwdBkwd(s, old, goFwd, "hour"); + return s.epoch; +}; +const hours = function(s, n, goFwd) { + n = validate(n); + if (n >= 24) { + n = 24; + } else if (n < 0) { + n = 0; + } + let old = s.clone(); + let diff2 = s.hour() - n; + let shift = diff2 * o.hour; + s.epoch -= shift; + if (s.date() !== old.date()) { + s = old.clone(); + if (diff2 > 1) { + diff2 -= 1; + } + if (diff2 < 1) { + diff2 += 1; + } + shift = diff2 * o.hour; + s.epoch -= shift; + } + walkTo(s, { + hour: n + }); + confirm(s, old, "minute"); + s = fwdBkwd(s, old, goFwd, "day"); + return s.epoch; +}; +const time = function(s, str, goFwd) { + let m = str.match(/([0-9]{1,2})[:h]([0-9]{1,2})(:[0-9]{1,2})? ?(am|pm)?/); + if (!m) { + m = str.match(/([0-9]{1,2}) ?(am|pm)/); + if (!m) { + return s.epoch; + } + m.splice(2, 0, "0"); + m.splice(3, 0, ""); + } + let h24 = false; + let hour = parseInt(m[1], 10); + let minute = parseInt(m[2], 10); + if (minute >= 60) { + minute = 59; + } + if (hour > 12) { + h24 = true; + } + if (h24 === false) { + if (m[4] === "am" && hour === 12) { + hour = 0; + } + if (m[4] === "pm" && hour < 12) { + hour += 12; + } + } + m[3] = m[3] || ""; + m[3] = m[3].replace(/:/, ""); + let sec = parseInt(m[3], 10) || 0; + let old = s.clone(); + s = s.hour(hour); + s = s.minute(minute); + s = s.second(sec); + s = s.millisecond(0); + s = fwdBkwd(s, old, goFwd, "day"); + return s.epoch; +}; +const date = function(s, n, goFwd) { + n = validate(n); + if (n > 28) { + let month2 = s.month(); + let max = monthLengths[month2]; + if (month2 === 1 && n === 29 && isLeapYear(s.year())) { + max = 29; + } + if (n > max) { + n = max; + } + } + if (n <= 0) { + n = 1; + } + let old = s.clone(); + walkTo(s, { + date: n + }); + s = fwdBkwd(s, old, goFwd, "month"); + return s.epoch; +}; +const month = function(s, n, goFwd) { + if (typeof n === "string") { + if (n === "sept") { + n = "sep"; + } + n = mapping$1()[n.toLowerCase()]; + } + n = validate(n); + if (n >= 12) { + n = 11; + } + if (n <= 0) { + n = 0; + } + let d = s.date(); + if (d > monthLengths[n]) { + d = monthLengths[n]; + } + let old = s.clone(); + walkTo(s, { + month: n, + d + }); + s = fwdBkwd(s, old, goFwd, "year"); + return s.epoch; +}; +const year = function(s, n) { + if (typeof n === "string" && /^'[0-9]{2}$/.test(n)) { + n = n.replace(/'/, "").trim(); + n = Number(n); + if (n > 30) { + n = 1900 + n; + } else { + n = 2e3 + n; + } + } + n = validate(n); + walkTo(s, { + year: n + }); + return s.epoch; +}; +const week = function(s, n, goFwd) { + let old = s.clone(); + n = validate(n); + s = s.month(0); + s = s.date(1); + s = s.day("monday"); + if (s.monthName() === "december" && s.date() >= 28) { + s = s.add(1, "week"); + } + n -= 1; + s = s.add(n, "weeks"); + s = fwdBkwd(s, old, goFwd, "year"); + return s.epoch; +}; +const dayOfYear = function(s, n, goFwd) { + n = validate(n); + let old = s.clone(); + n -= 1; + if (n <= 0) { + n = 0; + } else if (n >= 365) { + if (isLeapYear(s.year())) { + n = 365; + } else { + n = 364; + } + } + s = s.startOf("year"); + s = s.add(n, "day"); + confirm(s, old, "hour"); + s = fwdBkwd(s, old, goFwd, "year"); + return s.epoch; +}; +let morning = "am"; +let evening = "pm"; +function am() { + return morning; +} +function pm() { + return evening; +} +function set(i18n) { + morning = i18n.am || morning; + evening = i18n.pm || evening; +} +const methods$3 = { + millisecond: function(num) { + if (num !== void 0) { + let s = this.clone(); + s.epoch = milliseconds(s, num); + return s; + } + return this.d.getMilliseconds(); + }, + second: function(num, goFwd) { + if (num !== void 0) { + let s = this.clone(); + s.epoch = seconds(s, num, goFwd); + return s; + } + return this.d.getSeconds(); + }, + minute: function(num, goFwd) { + if (num !== void 0) { + let s = this.clone(); + s.epoch = minutes(s, num, goFwd); + return s; + } + return this.d.getMinutes(); + }, + hour: function(num, goFwd) { + let d = this.d; + if (num !== void 0) { + let s = this.clone(); + s.epoch = hours(s, num, goFwd); + return s; + } + return d.getHours(); + }, + //'3:30' is 3.5 + hourFloat: function(num, goFwd) { + if (num !== void 0) { + let s = this.clone(); + let minute2 = num % 1; + minute2 = minute2 * 60; + let hour2 = parseInt(num, 10); + s.epoch = hours(s, hour2, goFwd); + s.epoch = minutes(s, minute2, goFwd); + return s; + } + let d = this.d; + let hour = d.getHours(); + let minute = d.getMinutes(); + minute = minute / 60; + return hour + minute; + }, + // hour in 12h format + hour12: function(str, goFwd) { + let d = this.d; + if (str !== void 0) { + let s = this.clone(); + str = "" + str; + let m = str.match(/^([0-9]+)(am|pm)$/); + if (m) { + let hour = parseInt(m[1], 10); + if (m[2] === "pm") { + hour += 12; + } + s.epoch = hours(s, hour, goFwd); + } + return s; + } + let hour12 = d.getHours(); + if (hour12 > 12) { + hour12 = hour12 - 12; + } + if (hour12 === 0) { + hour12 = 12; + } + return hour12; + }, + //some ambiguity here with 12/24h + time: function(str, goFwd) { + if (str !== void 0) { + let s = this.clone(); + str = str.toLowerCase().trim(); + s.epoch = time(s, str, goFwd); + return s; + } + return `${this.h12()}:${zeroPad(this.minute())}${this.ampm()}`; + }, + // either 'am' or 'pm' + ampm: function(input, goFwd) { + let which = am(); + let hour = this.hour(); + if (hour >= 12) { + which = pm(); + } + if (typeof input !== "string") { + return which; + } + let s = this.clone(); + input = input.toLowerCase().trim(); + if (hour >= 12 && input === "am") { + hour -= 12; + return s.hour(hour, goFwd); + } + if (hour < 12 && input === "pm") { + hour += 12; + return s.hour(hour, goFwd); + } + return s; + }, + //some hard-coded times of day, like 'noon' + dayTime: function(str, goFwd) { + if (str !== void 0) { + const times = { + morning: "7:00", + breakfast: "7:00", + noon: "12:00", + lunch: "12:00", + afternoon: "14:00", + evening: "18:00", + dinner: "18:00", + night: "23:00", + midnight: "00:00" + }; + let s = this.clone(); + str = str || ""; + str = str.toLowerCase(); + if (times.hasOwnProperty(str) === true) { + s = s.time(times[str], goFwd); + } + return s; + } + let h = this.hour(); + if (h < 6) { + return "night"; + } + if (h < 12) { + return "morning"; + } + if (h < 17) { + return "afternoon"; + } + if (h < 22) { + return "evening"; + } + return "night"; + }, + //parse a proper iso string + iso: function(num) { + if (num !== void 0) { + return this.set(num); + } + return this.format("iso"); + } +}; +const methods$2 = { + // # day in the month + date: function(num, goFwd) { + if (num !== void 0) { + let s = this.clone(); + num = parseInt(num, 10); + if (num) { + s.epoch = date(s, num, goFwd); + } + return s; + } + return this.d.getDate(); + }, + //like 'wednesday' (hard!) + day: function(input, goFwd) { + if (input === void 0) { + return this.d.getDay(); + } + let original = this.clone(); + let want = input; + if (typeof input === "string") { + input = input.toLowerCase(); + if (aliases$1.hasOwnProperty(input)) { + want = aliases$1[input]; + } else { + want = short().indexOf(input); + if (want === -1) { + want = long().indexOf(input); + } + } + } + let day = this.d.getDay(); + let diff2 = day - want; + if (goFwd === true && diff2 > 0) { + diff2 = diff2 - 7; + } + if (goFwd === false && diff2 < 0) { + diff2 = diff2 + 7; + } + let s = this.subtract(diff2, "days"); + walkTo(s, { + hour: original.hour(), + minute: original.minute(), + second: original.second() + }); + return s; + }, + //these are helpful name-wrappers + dayName: function(input, goFwd) { + if (input === void 0) { + return long()[this.day()]; + } + let s = this.clone(); + s = s.day(input, goFwd); + return s; + } +}; +const clearMinutes = (s) => { + s = s.minute(0); + s = s.second(0); + s = s.millisecond(1); + return s; +}; +const methods$1 = { + // day 0-366 + dayOfYear: function(num, goFwd) { + if (num !== void 0) { + let s = this.clone(); + s.epoch = dayOfYear(s, num, goFwd); + return s; + } + let sum = 0; + let month2 = this.d.getMonth(); + let tmp; + for (let i = 1; i <= month2; i++) { + tmp = /* @__PURE__ */ new Date(); + tmp.setDate(1); + tmp.setFullYear(this.d.getFullYear()); + tmp.setHours(1); + tmp.setMinutes(1); + tmp.setMonth(i); + tmp.setHours(-2); + sum += tmp.getDate(); + } + return sum + this.d.getDate(); + }, + //since the start of the year + week: function(num, goFwd) { + if (num !== void 0) { + let s = this.clone(); + s.epoch = week(this, num, goFwd); + s = clearMinutes(s); + return s; + } + let tmp = this.clone(); + tmp = tmp.month(0); + tmp = tmp.date(1); + tmp = clearMinutes(tmp); + tmp = tmp.day("monday"); + if (tmp.month() === 11 && tmp.date() >= 25) { + tmp = tmp.add(1, "week"); + } + let toAdd = 1; + if (tmp.date() === 1) { + toAdd = 0; + } + tmp = tmp.minus(1, "second"); + const thisOne = this.epoch; + if (tmp.epoch > thisOne) { + return 1; + } + let i = 0; + let skipWeeks = this.month() * 4; + tmp.epoch += o.week * skipWeeks; + i += skipWeeks; + for (; i <= 52; i++) { + if (tmp.epoch > thisOne) { + return i + toAdd; + } + tmp = tmp.add(1, "week"); + } + return 52; + }, + //either name or number + month: function(input, goFwd) { + if (input !== void 0) { + let s = this.clone(); + s.epoch = month(s, input, goFwd); + return s; + } + return this.d.getMonth(); + }, + //'january' + monthName: function(input, goFwd) { + if (input !== void 0) { + let s = this.clone(); + s = s.month(input, goFwd); + return s; + } + return long$1()[this.month()]; + }, + //q1, q2, q3, q4 + quarter: function(num, goFwd) { + if (num !== void 0) { + if (typeof num === "string") { + num = num.replace(/^q/i, ""); + num = parseInt(num, 10); + } + if (quarters[num]) { + let s = this.clone(); + let month3 = quarters[num][0]; + s = s.month(month3, goFwd); + s = s.date(1, goFwd); + s = s.startOf("day"); + return s; + } + } + let month2 = this.d.getMonth(); + for (let i = 1; i < quarters.length; i++) { + if (month2 < quarters[i][0]) { + return i - 1; + } + } + return 4; + }, + //spring, summer, winter, fall + season: function(input, goFwd) { + let hem = "north"; + if (this.hemisphere() === "South") { + hem = "south"; + } + if (input !== void 0) { + let s = this.clone(); + for (let i = 0; i < seasons[hem].length; i++) { + if (input === seasons[hem][i][0]) { + s = s.month(seasons[hem][i][1], goFwd); + s = s.date(1); + s = s.startOf("day"); + } + } + return s; + } + let month2 = this.d.getMonth(); + for (let i = 0; i < seasons[hem].length - 1; i++) { + if (month2 >= seasons[hem][i][1] && month2 < seasons[hem][i + 1][1]) { + return seasons[hem][i][0]; + } + } + return hem === "north" ? "winter" : "summer"; + }, + //the year number + year: function(num) { + if (num !== void 0) { + let s = this.clone(); + s.epoch = year(s, num); + return s; + } + return this.d.getFullYear(); + }, + //bc/ad years + era: function(str) { + if (str !== void 0) { + let s = this.clone(); + str = str.toLowerCase(); + let year$1 = s.d.getFullYear(); + if (str === "bc" && year$1 > 0) { + s.epoch = year(s, year$1 * -1); + } + if (str === "ad" && year$1 < 0) { + s.epoch = year(s, year$1 * -1); + } + return s; + } + if (this.d.getFullYear() < 0) { + return "BC"; + } + return "AD"; + }, + // 2019 -> 2010 + decade: function(input) { + if (input !== void 0) { + input = String(input); + input = input.replace(/([0-9])'?s$/, "$1"); + input = input.replace(/([0-9])(th|rd|st|nd)/, "$1"); + if (!input) { + console.warn("Spacetime: Invalid decade input"); + return this; + } + if (input.length === 2 && /[0-9][0-9]/.test(input)) { + input = "19" + input; + } + let year2 = Number(input); + if (isNaN(year2)) { + return this; + } + year2 = Math.floor(year2 / 10) * 10; + return this.year(year2); + } + return this.startOf("decade").year(); + }, + // 1950 -> 19+1 + century: function(input) { + if (input !== void 0) { + if (typeof input === "string") { + input = input.replace(/([0-9])(th|rd|st|nd)/, "$1"); + input = input.replace(/([0-9]+) ?(b\.?c\.?|a\.?d\.?)/i, (a, b, c) => { + if (c.match(/b\.?c\.?/i)) { + b = "-" + b; + } + return b; + }); + input = input.replace(/c$/, ""); + } + let year2 = Number(input); + if (isNaN(input)) { + console.warn("Spacetime: Invalid century input"); + return this; + } + if (year2 === 0) { + year2 = 1; + } + if (year2 >= 0) { + year2 = (year2 - 1) * 100; + } else { + year2 = (year2 + 1) * 100; + } + return this.year(year2); + } + let num = this.startOf("century").year(); + num = Math.floor(num / 100); + if (num < 0) { + return num - 1; + } + return num + 1; + }, + // 2019 -> 2+1 + millenium: function(input) { + if (input !== void 0) { + if (typeof input === "string") { + input = input.replace(/([0-9])(th|rd|st|nd)/, "$1"); + input = Number(input); + if (isNaN(input)) { + console.warn("Spacetime: Invalid millenium input"); + return this; + } + } + if (input > 0) { + input -= 1; + } + let year2 = input * 1e3; + if (year2 === 0) { + year2 = 1; + } + return this.year(year2); + } + let num = Math.floor(this.year() / 1e3); + if (num >= 0) { + num += 1; + } + return num; + } +}; +const methods = Object.assign({}, methods$3, methods$2, methods$1); +methods.milliseconds = methods.millisecond; +methods.seconds = methods.second; +methods.minutes = methods.minute; +methods.hours = methods.hour; +methods.hour24 = methods.hour; +methods.h12 = methods.hour12; +methods.h24 = methods.hour24; +methods.days = methods.day; +const addMethods$4 = (Space) => { + Object.keys(methods).forEach((k) => { + Space.prototype[k] = methods[k]; + }); +}; +const getMonthLength = function(month2, year2) { + if (month2 === 1 && isLeapYear(year2)) { + return 29; + } + return monthLengths[month2]; +}; +const rollMonth = (want, old) => { + if (want.month > 0) { + let years = parseInt(want.month / 12, 10); + want.year = old.year() + years; + want.month = want.month % 12; + } else if (want.month < 0) { + let m = Math.abs(want.month); + let years = parseInt(m / 12, 10); + if (m % 12 !== 0) { + years += 1; + } + want.year = old.year() - years; + want.month = want.month % 12; + want.month = want.month + 12; + if (want.month === 12) { + want.month = 0; + } + } + return want; +}; +const rollDaysDown = (want, old, sum) => { + want.year = old.year(); + want.month = old.month(); + let date2 = old.date(); + want.date = date2 - Math.abs(sum); + while (want.date < 1) { + want.month -= 1; + if (want.month < 0) { + want.month = 11; + want.year -= 1; + } + let max = getMonthLength(want.month, want.year); + want.date += max; + } + return want; +}; +const rollDaysUp = (want, old, sum) => { + let year2 = old.year(); + let month2 = old.month(); + let max = getMonthLength(month2, year2); + while (sum > max) { + sum -= max; + month2 += 1; + if (month2 >= 12) { + month2 -= 12; + year2 += 1; + } + max = getMonthLength(month2, year2); + } + want.month = month2; + want.date = sum; + return want; +}; +const months = rollMonth; +const days = rollDaysUp; +const daysBack = rollDaysDown; +const order = ["millisecond", "second", "minute", "hour", "date", "month"]; +let keep = { + second: order.slice(0, 1), + minute: order.slice(0, 2), + quarterhour: order.slice(0, 2), + hour: order.slice(0, 3), + date: order.slice(0, 4), + month: order.slice(0, 4), + quarter: order.slice(0, 4), + season: order.slice(0, 4), + year: order, + decade: order, + century: order +}; +keep.week = keep.hour; +keep.season = keep.date; +keep.quarter = keep.date; +const dstAwareUnits = { + year: true, + quarter: true, + season: true, + month: true, + week: true, + date: true +}; +const keepDate = { + month: true, + quarter: true, + season: true, + year: true +}; +const addMethods$3 = (SpaceTime2) => { + SpaceTime2.prototype.add = function(num, unit) { + let s = this.clone(); + if (!unit || num === 0) { + return s; + } + let old = this.clone(); + unit = normalize$2(unit); + if (unit === "millisecond") { + s.epoch += num; + return s; + } + if (unit === "fortnight") { + num *= 2; + unit = "week"; + } + if (o[unit]) { + s.epoch += o[unit] * num; + } else if (unit === "week" || unit === "weekend") { + s.epoch += o.day * (num * 7); + } else if (unit === "quarter" || unit === "season") { + s.epoch += o.month * (num * 3); + } else if (unit === "quarterhour") { + s.epoch += o.minute * 15 * num; + } + let want = {}; + if (keep[unit]) { + keep[unit].forEach((u) => { + want[u] = old[u](); + }); + } + if (dstAwareUnits[unit]) { + const diff2 = old.timezone().current.offset - s.timezone().current.offset; + s.epoch += diff2 * 3600 * 1e3; + } + if (unit === "month") { + want.month = old.month() + num; + want = months(want, old); + } + if (unit === "week") { + let sum = old.date() + num * 7; + if (sum <= 28 && sum > 1) { + want.date = sum; + } + } + if (unit === "weekend" && s.dayName() !== "saturday") { + s = s.day("saturday", true); + } else if (unit === "date") { + if (num < 0) { + want = daysBack(want, old, num); + } else { + let sum = old.date() + num; + want = days(want, old, sum); + } + if (num !== 0 && old.isSame(s, "day")) { + want.date = old.date() + num; + } + } else if (unit === "quarter") { + want.month = old.month() + num * 3; + want.year = old.year(); + if (want.month < 0) { + let years = Math.floor(want.month / 12); + let remainder = want.month + Math.abs(years) * 12; + want.month = remainder; + want.year += years; + } else if (want.month >= 12) { + let years = Math.floor(want.month / 12); + want.month = want.month % 12; + want.year += years; + } + want.date = old.date(); + } else if (unit === "year") { + let wantYear = old.year() + num; + let haveYear = s.year(); + if (haveYear < wantYear) { + let toAdd = Math.floor(num / 4) || 1; + s.epoch += Math.abs(o.day * toAdd); + } else if (haveYear > wantYear) { + let toAdd = Math.floor(num / 4) || 1; + s.epoch += o.day * toAdd; + } + } else if (unit === "decade") { + want.year = s.year() + 10; + } else if (unit === "century") { + want.year = s.year() + 100; + } + if (keepDate[unit]) { + let max = monthLengths[want.month]; + want.date = old.date(); + if (want.date > max) { + want.date = max; + } + } + if (Object.keys(want).length > 1) { + walkTo(s, want); + } + return s; + }; + SpaceTime2.prototype.subtract = function(num, unit) { + let s = this.clone(); + return s.add(num * -1, unit); + }; + SpaceTime2.prototype.minus = SpaceTime2.prototype.subtract; + SpaceTime2.prototype.plus = SpaceTime2.prototype.add; +}; +const print = { + millisecond: (s) => { + return s.epoch; + }, + second: (s) => { + return [s.year(), s.month(), s.date(), s.hour(), s.minute(), s.second()].join("-"); + }, + minute: (s) => { + return [s.year(), s.month(), s.date(), s.hour(), s.minute()].join("-"); + }, + hour: (s) => { + return [s.year(), s.month(), s.date(), s.hour()].join("-"); + }, + day: (s) => { + return [s.year(), s.month(), s.date()].join("-"); + }, + week: (s) => { + return [s.year(), s.week()].join("-"); + }, + month: (s) => { + return [s.year(), s.month()].join("-"); + }, + quarter: (s) => { + return [s.year(), s.quarter()].join("-"); + }, + year: (s) => { + return s.year(); + } +}; +print.date = print.day; +const addMethods$2 = (SpaceTime2) => { + SpaceTime2.prototype.isSame = function(b, unit, tzAware = true) { + let a = this; + if (!unit) { + return null; + } + if (typeof b === "string" && typeof unit === "object") { + let tmp = b; + b = unit; + unit = tmp; + } + if (typeof b === "string" || typeof b === "number") { + b = new SpaceTime2(b, this.timezone.name); + } + unit = unit.replace(/s$/, ""); + if (tzAware === true && a.tz !== b.tz) { + b = b.clone(); + b.tz = a.tz; + } + if (print[unit]) { + return print[unit](a) === print[unit](b); + } + return null; + }; +}; +const addMethods$1 = (SpaceTime2) => { + const methods2 = { + isAfter: function(d) { + d = beADate(d, this); + let epoch = getEpoch(d); + if (epoch === null) { + return null; + } + return this.epoch > epoch; + }, + isBefore: function(d) { + d = beADate(d, this); + let epoch = getEpoch(d); + if (epoch === null) { + return null; + } + return this.epoch < epoch; + }, + isEqual: function(d) { + d = beADate(d, this); + let epoch = getEpoch(d); + if (epoch === null) { + return null; + } + return this.epoch === epoch; + }, + isBetween: function(start, end, isInclusive = false) { + start = beADate(start, this); + end = beADate(end, this); + let startEpoch = getEpoch(start); + if (startEpoch === null) { + return null; + } + let endEpoch = getEpoch(end); + if (endEpoch === null) { + return null; + } + if (isInclusive) { + return this.isBetween(start, end) || this.isEqual(start) || this.isEqual(end); + } + return startEpoch < this.epoch && this.epoch < endEpoch; + } + }; + Object.keys(methods2).forEach((k) => { + SpaceTime2.prototype[k] = methods2[k]; + }); +}; +const addMethods = (SpaceTime2) => { + const methods2 = { + i18n: function(data2) { + if (isObject(data2.days)) { + set$4(data2.days); + } + if (isObject(data2.months)) { + set$5(data2.months); + } + if (isBoolean(data2.useTitleCase)) { + set$3(data2.useTitleCase); + } + if (isObject(data2.ampm)) { + set(data2.ampm); + } + if (isObject(data2.distance)) { + set$1(data2.distance); + } + if (isObject(data2.units)) { + set$2(data2.units); + } + return this; + } + }; + Object.keys(methods2).forEach((k) => { + SpaceTime2.prototype[k] = methods2[k]; + }); +}; +let timezones = all; +const SpaceTime = function(input, tz, options = {}) { + this.epoch = null; + this.tz = lookupTz(tz, timezones); + this.silent = typeof options.silent !== "undefined" ? options.silent : true; + this.british = options.dmy || options.british; + this._weekStart = 1; + if (options.weekStart !== void 0) { + this._weekStart = options.weekStart; + } + this._today = {}; + if (options.today !== void 0) { + this._today = options.today; + } + Object.defineProperty(this, "d", { + // return a js date object + get: function() { + let offset = quickOffset(this); + let bias = new Date(this.epoch).getTimezoneOffset() || 0; + let shift = bias + offset * 60; + shift = shift * 60 * 1e3; + let epoch = this.epoch + shift; + let d = new Date(epoch); + return d; + } + }); + Object.defineProperty(this, "timezones", { + get: () => timezones, + set: (obj) => { + timezones = obj; + return obj; + } + }); + let tmp = parseInput(this, input); + this.epoch = tmp.epoch; + if (tmp.tz) { + this.tz = tmp.tz; + } +}; +Object.keys(methods$4).forEach((k) => { + SpaceTime.prototype[k] = methods$4[k]; +}); +SpaceTime.prototype.clone = function() { + return new SpaceTime(this.epoch, this.tz, { + silent: this.silent, + weekStart: this._weekStart, + today: this._today, + parsers: this.parsers + }); +}; +SpaceTime.prototype.toLocalDate = function() { + return this.toNativeDate(); +}; +SpaceTime.prototype.toNativeDate = function() { + return new Date(this.epoch); +}; +addMethods$4(SpaceTime); +addMethods$3(SpaceTime); +addMethods$2(SpaceTime); +addMethods$1(SpaceTime); +addMethods(SpaceTime); +const whereIts = (a, b) => { + let start = new SpaceTime(null); + let end = new SpaceTime(null); + start = start.time(a); + if (b) { + end = end.time(b); + } else { + end = start.add(59, "minutes"); + } + let startHour = start.hour(); + let endHour = end.hour(); + let tzs = Object.keys(start.timezones).filter((tz) => { + if (tz.indexOf("/") === -1) { + return false; + } + let m = new SpaceTime(null, tz); + let hour = m.hour(); + if (hour >= startHour && hour <= endHour) { + if (hour === startHour && m.minute() < start.minute()) { + return false; + } + if (hour === endHour && m.minute() > end.minute()) { + return false; + } + return true; + } + return false; + }); + return tzs; +}; +const version$3 = "7.6.2"; +const main$2 = (input, tz, options) => new SpaceTime(input, tz, options); +const setToday = function(s) { + let today = s._today || {}; + Object.keys(today).forEach((k) => { + s = s[k](today[k]); + }); + return s; +}; +main$2.now = (tz, options) => { + let s = new SpaceTime((/* @__PURE__ */ new Date()).getTime(), tz, options); + s = setToday(s); + return s; +}; +main$2.today = (tz, options) => { + let s = new SpaceTime((/* @__PURE__ */ new Date()).getTime(), tz, options); + s = setToday(s); + return s.startOf("day"); +}; +main$2.tomorrow = (tz, options) => { + let s = new SpaceTime((/* @__PURE__ */ new Date()).getTime(), tz, options); + s = setToday(s); + return s.add(1, "day").startOf("day"); +}; +main$2.yesterday = (tz, options) => { + let s = new SpaceTime((/* @__PURE__ */ new Date()).getTime(), tz, options); + s = setToday(s); + return s.subtract(1, "day").startOf("day"); +}; +main$2.extend = function(obj = {}) { + Object.keys(obj).forEach((k) => { + SpaceTime.prototype[k] = obj[k]; + }); + return this; +}; +main$2.timezones = function() { + let s = new SpaceTime(); + return s.timezones; +}; +main$2.max = function(tz, options) { + let s = new SpaceTime(null, tz, options); + s.epoch = 864e13; + return s; +}; +main$2.min = function(tz, options) { + let s = new SpaceTime(null, tz, options); + s.epoch = -864e13; + return s; +}; +main$2.whereIts = whereIts; +main$2.version = version$3; +main$2.plugin = main$2.extend; +const hoursCmd = new Command2().name("hour").description("Get or set data for a specific hour").argument("", "An hour between 0-23, or 1-12 [AM/PM]").argument("[code]", "Optionally set the code for this hour").option("-c, --comment ", "edit this hour's comment").action(async (dateQuery = "today", hour, code, flags) => { + return "Hello"; +}); +async function doHour(day, hourFlags, timezone2 = "UTC") { + var _a2; + const hourNum = getTimeFromHour(hourFlags.shift()); + const hour = day.hours[hourNum]; + if (hourFlags.length == 0) { + console.log("No new values to set; printing hour."); + printHour(hour, hourNum, day, timezone2); + } else { + const api2 = getAPIClient(); + let res; + try { + if (hourFlags[0] == "@") { + if (!hour.categoryCode) { + throw new Error("No category code yet -- '@' is meant to set the comment when the category is already set."); + } else { + hourFlags[0] = (_a2 = hour.categoryCode) == null ? void 0 : _a2.toString(); + } + } + const props = { dateQuery: hour.date, time: hour.time, code: hourFlags[0], comment: hourFlags[1] || null }; + res = await api2.hours.update.mutate({ ...props }); + printHour(res, hourNum, day, timezone2); + } catch (error2) { + printErrorMessageWithReason("Failed to manipulate hour", error2); + } + } +} +function printHour(hour, hourNum, day, timezone2) { + const data2 = [ + [hour.categoryName + ".", hour.categoryDesc ?? "Nothing stored yet."] + ]; + if (hour.comment) { + data2.push(["Comment:", hour.comment]); + } + console.log(src.table(data2, { + // border: getBorderCharacters("ramac"), + // singleLine: true, + columns: [{ width: 10 }, { width: 40 }], + header: { alignment: "center", content: `${main$2(day.date, timezone2).format("{day}, {month-short} {date-ordinal}")} at ${getHourFromTime(hourNum, "all", timezones$1[timezone2])}` }, + drawVerticalLine: (lineIndex, columnCount) => { + return lineIndex === 0 || lineIndex === columnCount || lineIndex === 0 && columnCount === 2; + }, + drawHorizontalLine: (lineIndex, rowCount) => { + return lineIndex < 2 || lineIndex === 2 || lineIndex === rowCount; + } + })); +} +const BASE = 36; +const seq = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; +const cache = seq.split("").reduce(function(h, c, i) { + h[c] = i; + return h; +}, {}); +const toAlphaCode = function(n) { + if (seq[n] !== void 0) { + return seq[n]; + } + let places = 1; + let range = BASE; + let s = ""; + for (; n >= range; n -= range, places++, range *= BASE) { + } + while (places--) { + const d = n % BASE; + s = String.fromCharCode((d < 10 ? 48 : 55) + d) + s; + n = (n - d) / BASE; + } + return s; +}; +const fromAlphaCode = function(s) { + if (cache[s] !== void 0) { + return cache[s]; + } + let n = 0; + let places = 1; + let range = BASE; + let pow = 1; + for (; places < s.length; n += range, places++, range *= BASE) { + } + for (let i = s.length - 1; i >= 0; i--, pow *= BASE) { + let d = s.charCodeAt(i) - 48; + if (d > 10) { + d -= 7; + } + n += d * pow; + } + return n; +}; +var encoding = { + toAlphaCode, + fromAlphaCode +}; +const symbols = function(t) { + const reSymbol = new RegExp("([0-9A-Z]+):([0-9A-Z]+)"); + for (let i = 0; i < t.nodes.length; i++) { + const m = reSymbol.exec(t.nodes[i]); + if (!m) { + t.symCount = i; + break; + } + t.syms[encoding.fromAlphaCode(m[1])] = encoding.fromAlphaCode(m[2]); + } + t.nodes = t.nodes.slice(t.symCount, t.nodes.length); +}; +var parseSymbols = symbols; +const indexFromRef = function(trie, ref, index) { + const dnode = encoding.fromAlphaCode(ref); + if (dnode < trie.symCount) { + return trie.syms[dnode]; + } + return index + dnode + 1 - trie.symCount; +}; +const toArray = function(trie) { + const all2 = []; + const crawl = (index, pref) => { + let node = trie.nodes[index]; + if (node[0] === "!") { + all2.push(pref); + node = node.slice(1); + } + const matches = node.split(/([A-Z0-9,]+)/g); + for (let i = 0; i < matches.length; i += 2) { + const str = matches[i]; + const ref = matches[i + 1]; + if (!str) { + continue; + } + const have = pref + str; + if (ref === "," || ref === void 0) { + all2.push(have); + continue; + } + const newIndex = indexFromRef(trie, ref, index); + crawl(newIndex, have); + } + }; + crawl(0, ""); + return all2; +}; +const unpack$2 = function(str) { + const trie = { + nodes: str.split(";"), + syms: [], + symCount: 0 + }; + if (str.match(":")) { + parseSymbols(trie); + } + return toArray(trie); +}; +var traverse = unpack$2; +const unpack = function(str) { + if (!str) { + return {}; + } + const obj = str.split("|").reduce((h, s) => { + const arr = s.split("¦"); + h[arr[0]] = arr[1]; + return h; + }, {}); + const all2 = {}; + Object.keys(obj).forEach(function(cat) { + const arr = traverse(obj[cat]); + if (cat === "true") { + cat = true; + } + for (let i = 0; i < arr.length; i++) { + const k = arr[i]; + if (all2.hasOwnProperty(k) === true) { + if (Array.isArray(all2[k]) === false) { + all2[k] = [all2[k], cat]; + } else { + all2[k].push(cat); + } + } else { + all2[k] = cat; + } + } + }); + return all2; +}; +var unpack$1 = unpack; +let patterns = { + usa: "2nd-sun-mar-2h|1st-sun-nov-2h", + // (From 1987 to 2006) + // mexico + mex: "1st-sun-apr-2h|last-sun-oct-2h", + // European Union zone + eu0: "last-sun-mar-0h|last-sun-oct-1h", + eu1: "last-sun-mar-1h|last-sun-oct-2h", + eu2: "last-sun-mar-2h|last-sun-oct-3h", + eu3: "last-sun-mar-3h|last-sun-oct-4h", + //greenland + green: "last-sat-mar-22h|last-sat-oct-23h", + // australia + aus: "1st-sun-apr-3h|1st-sun-oct-2h", + //lord howe australia + lhow: "1st-sun-apr-2h|1st-sun-oct-2h", + // new zealand + chat: "1st-sun-apr-3h|last-sun-sep-2h", + //technically 3:45h -> 2:45h + // new Zealand, antarctica + nz: "1st-sun-apr-3h|last-sun-sep-2h", + // casey - antarctica + ant: "2nd-sun-mar-0h|1st-sun-oct-0h", + // troll - antarctica + troll: "3rd-sun-mar-1h|last-sun-oct-3h", + //jordan + jord: "last-fri-feb-0h|last-fri-oct-1h", + // lebanon + leb: "last-sun-mar-0h|last-sun-oct-0h", + // syria + syr: "last-fri-mar-0h|last-fri-oct-0h", + //israel + // Start: Last Friday before April 2 -> The Sunday between Rosh Hashana and Yom Kippur + isr: "last-fri-mar-2h|last-sun-oct-2h", + //palestine + pal: "last-sun-mar-0h|last-fri-oct-1h", + // el aaiun + //this one seems to be on arabic calendar? + saha: "last-sun-mar-3h|1st-sun-may-2h", + // paraguay + par: "last-sun-mar-0h|1st-sun-oct-0h", + //cuba + cuba: "2nd-sun-mar-0h|1st-sun-nov-1h", + //chile + chile: "1st-sun-apr-0h|1st-sun-sep-0h", + //easter island + east: "1st-sat-apr-22h|1st-sat-sep-22h", + //fiji + fiji: "3rd-sun-jan-3h|2nd-sun-nov-2h" +}; +var dstPatterns = patterns; +var pcked = { "Africa": { "Abidjan": ["true¦a5bouake,coordinated universal4daloa,g1san ped0utc,yamoussouk0zulu;ro;h0mt,reenwich mean2;!a0;!na; ti3;b4frica0tlantic/st_helena;!/0;accra,ba1conakry,dakar,freetown,lo0nouakchott,ouagadougou,timbuktu;me;mako,njul;idjan,obo", "Greenwich Mean", "n"], "Algiers": ["true¦a8b6c3dz2or5s1t0;ebessa,iaret;etif,idi bel abbes;!a;e0hlef,onstantine;ntral europe0t;an;a0iskra,lida,oumerdas;b ezzouar,tna;frica,lg0nnaba;eria,iers", "Central European", "n"], "Bissau": ["true¦africa,b2coordinated universal1g0utc,zulu;mt,nb,reenwich mean0uinea b1w; time;issau", "Greenwich Mean", "n"], "Cairo": ["true¦a6bani suwayf,c5damanhur,e2giza,halw8i1kafr ad dawwar,luxor,new c5port said,qina,s0tanta,zagazig;hibin al kawm,ohag,uez;dku,smail8;astern europe5et,g0;!y0;!pt;airo;frica,l2s0;w0yut;an; 1exandr0;ia;fayyum,m0;a0inya;hallah al kubra,nsurah", "Eastern European", "n"], "Casablanca": ["true¦aCcasablanDfBkenitAm6oujda angad,rabat,sa4t1we0;stern europe2t;angier,e0;ma7tou0;an;fi,le0;! al jadida;a1ekn4o0;hammedia,rocco;!r0;!rakesh;ra;es;fri0gadir,l hoceima;ca", "Morocco Standard", "n", "saha"], "Ceuta": ["true¦africa,brussels,c0europe central,madrid,paris,romance;e0openhagen;ntral european,t,uta0;!melilla", "Central European", "n", "eu2"], "El_Aaiun": ["true¦afri3casablan3e2laayoune,morocco,we0;stern 0t;european,sahara;h,l_aaiun,sh;ca", "Morocco Standard", "n", "saha"], "Johannesburg": ["true¦africaIbEcAd9east londBharare,johannesHk7newcastDp6r5s3tembisa,uitenhage,v2w1za0;!f;elkom,itbank;anderbijlpark,ereeniging;ast,o0prings;uth africa,weto;andBichards bay,oodepoort;aarl,ietermaritzAort elizabeth,retoria;lerk0ruger0;sdorp;iepsloot,urb5;a1enturi0;on;pe town,rletonvil0;le;enoni,loemfontein,o1rakp0;an;ks0tshabelo;burg;! southern,/m0;aseru,babane", "South Africa", "s"], "Juba": ["true¦a3c2juba,s0winejok;outh sudan,s0;!d;at,entral a0;frica", "Central Africa", "n"], "Khartoum": ["true¦a7c6el 5k3ny4omdurm2port sud2s0wad medani;d0inga,ud1;!n;an;ass0hartoum,osti;ala;dae3fasher,obeid;at,entral af1;d damaz1f0l qadarif;rica;in", "Central Africa", "n"], "Lagos": ["true¦aVbTcReQgPiLjKkaIlGmDnnewi,oAport harcourt,s9u7w0zar8; c3a2est0; 0ern3;a3c1;rBst,t;entral0; a0;frica;gep,muah0yo;ia;a7hagamu,okoto;kDn1w0yo;er3o;do,itsha;a0in5ubi;idugu0kurdi;ri;agos,ek0;ki;du0no,tsi0;na;imeLos;badan,jebu ode,k1l0seHwo;a orangun,eDor7;eHi8ot ekp0;ene;ombe,usau;bute ikorodu,fon alaaye,nugu;alabar,d,hakwama,o0;d,ngo;auchi,en0;in;b8do7frica1ku0tani;re;! western,/0;b2douala,kinsha1l0malabo,niamey,porto-novo;ibre2uanda;sa;angui,razza0;ville; ekiti;a,eoku1u0;ja;ta", "West Africa", "n"], "Maputo": ["true¦africa7beiCc6ma4na2quelimaAwindhoek,z0;imbabwe,w0;!e;ca2m0;ibia,pu1;puto,to0;la;at,entral africa,himoio;! central,/0;b2gaboro1hara4kigali,lu0;bumbashi,saka;ne;lanty1ujumbu0;ra;re", "Central Africa", "s"], "Monrovia": ["true¦africa,coordinated universal3g2l0monrov1utc,zulu;br,iber0r;ia;mt,reenwich mean0; time", "Greenwich Mean", "n"], "Nairobi": ["true¦africa8e4indian/2kisumu,m1na0thika,yt;irobi,kuru;a1ombasa,yt;antananarivo,comoro,ma0;yotte; 2a0ldoret;st0t; 0ern 0;africa;! eastern,/0;a1d0kampala,mogadishu;ar_es_salaam,jibouti;ddis_ababa,sm0;a0e0;ra", "East Africa", "n"], "Ndjamena": ["true¦africaAchad,n8t7w0; c3a2est0; 0ern3;a3c1;st,t;entral0; a0;frica;cd,d;'d0d0;jamena;! western", "West Africa", "n"], "Sao_Tome": ["true¦africa,coordinated universal5g4s0utc,zulu;ao1t0;!p; 0_0;to2;mt,reenwich mean0; ti0;me", "Greenwich Mean", "n"], "Tripoli": ["true¦a4benghazi,e3l1misrat5t0zawi2;arhuna,ripoli;by,ib0y;ya;astern european,et;frica,l khums,z zawiy0;ah", "Eastern European", "n"], "Tunis": ["true¦africa,ce3sfax,t0;n,un0;!is0;!ia;ntral european,t", "Central European", "n"], "Windhoek": ["true¦africa3c2na0windhoek;!m0;!ibia;at,entral africa;! central", "Central Africa", "s"] }, "America": { "Adak": ["true¦a1h0nwt,us/aleutian;awaii s3dt,st;dak,leutian0merica/atka;! 0;islands,s0;tandard time", "Aleutian Standard", "n", "usa"], "Anchorage": ["true¦a0us/alaska;h6k5laska0merica,nchorage;! 1n0;! s1;s0t1;tandard t0;ime;dt,st,t;dt,st", "Alaska", "n", "usa"], "Araguaina": ["true¦araguaina,br1e0palmas,tocantins; south america s4ast south america;a0t;silia0zil;! 0;s0t1;tandard t0;ime", "Brasilia", "n"], "Argentina/Buenos_Aires": ["true¦a0buenos 4;merica/2r0;!g0;!e2;arge1buenos_0;aires;ntina", "Argentina", "s"], "Argentina/Catamarca": ["true¦a0c2;merica/0rgentina;argentina/comodrivadavia,c0;atamarca", "Argentina", "s"], "Argentina/Cordoba": ["true¦a0c2;merica/0rgentina;c0rosario;ordoba", "Argentina", "s"], "Argentina/Jujuy": ["true¦a0j1;merica/j0rgentina;ujuy", "Argentina", "s"], "Argentina/La_Rioja": ["true¦ar1b0city of b0la rioja;uenos aires;gentina0st,t;! 0;standard t0t0;ime", "Argentina", "s"], "Argentina/Mendoza": ["true¦a0m1;merica/m0rgentina;endoza", "Argentina", "s"], "Argentina/Rio_Gallegos": ["true¦ar1b0city of b0rio_gallegos;uenos aires;gentina0st,t;! 0;standard t0t0;ime", "Argentina", "s"], "Argentina/Salta": ["true¦ar1b0city of b0salta;uenos aires;gentina0st,t;! 0;standard t0t0;ime", "Argentina", "s"], "Argentina/San_Juan": ["true¦ar1b0city of b0san juan;uenos aires;gentina0st,t;! time", "Argentina", "s"], "Argentina/San_Luis": ["true¦ar1b0city of b0san luis;uenos aires;gentina0st,t;! time", "Argentina", "s"], "Argentina/Tucuman": ["true¦ar1b0city of b0tucuman;uenos aires;gentina0st,t;! time", "Argentina", "s"], "Argentina/Ushuaia": ["true¦ar1b0city of b0ushuaia;uenos aires;gentina0st,t;! time", "Argentina", "s"], "Asuncion": ["true¦asuncion,c3p0san lorenzo;araguay1ry,y0;!st,t;! time;apiata,iudad del este", "Paraguay", "s", "par"], "Bahia": ["true¦b2camacari,e1feira de santa0itabu0salvador,vitoria da conquista;na; south america s5ast south america;ahia,r0;a0t;silia0zil;! 0;s0t1;tandard t0;ime", "Brasilia", "n"], "Bahia_Banderas": ["true¦bah7c2guadalajara,m0;exico0onterrey;! city;entral 0st;mexic0standard 2;an,o0;! 0;time;ia_0ía de 0;banderas", "Central Mexico", "n", "mex"], "Barbados": ["true¦a1b0;arbados,b,rb;st,tlantic standard time", "Atlantic", "n"], "Belem": ["true¦ananindeua,b2e1macapa,par0;auapebas,á east amapá; south america s5ast south america;elem,r0;a0t;silia0zil;! 0;s0t1;tandard t0;ime", "Brasilia", "n"], "Belize": ["true¦b1c0;entral standard time,st;elize,lz,z", "Central", "n"], "Boa_Vista": ["true¦am3boa vista,c0roraima;entral brazil0uiaba;!ian0;! s3;azon0t;! 0;s0t1;tandard t0;ime", "Amazon", "n"], "Bogota": ["true¦armenGbBc7dosquebradas,floridablanca,i6m5neiva,p3s1v0;alledupar,illavicencio;anta marCincelejo,o0;acha,ledad;a0erei9opayan;lmi8sto;anizales,edellin,onterA;bague,taguei;a2o0ucu6;!l0st,t;!omb6;li,rtagena;arran3ello,ogo2u0;caramanga,enaventu0;ra;ta;cabermeja,quilla;ia", "Colombia", "n"], "Boise": ["true¦america4boise,idaho,m0;ountain0pt,st,t;! 0;id,standard t0t0;ime;! mountain", "Mountain", "n", "usa"], "Cambridge_Bay": ["true¦america4cambridge bay,m0;ddt,ountain0st,t;! 0;standard t0t0;ime;! mountain", "Mountain", "n", "usa"], "Campo_Grande": ["true¦am0brazil,campo grande,mato grosso do sul;azon standard time,t", "Amazon", "s"], "Cancun": ["true¦cancun,e0mexico,quintana roo;astern standard time,st", "Eastern", "n"], "Caracas": ["true¦alto barinKbarJcDguaBm8p7san6turmeFv0;alencia,e0;!n0t;!ezuela0;! 0n;standard t0t0;ime; cristobal,ta teresa del tuy;eta4uerto la cruz;a0ucumpiz;raca0turin;ibo,y;ren8ti0;re;a4iudad 2o1u0;a,m2;ro;bolivar,guay0;ana;bim1rac1;in0quisimeto,uta;as", "Venezuela", "n"], "Cayenne": ["true¦cayenne,french guiana3g0;f1u0;f,iana;!t;! time", "French Guiana", "n"], "Chicago": ["true¦aWbTcRdQfort worth,gPhOiMk00lJmCn8o7plano,s4t2us1wi0;chiGsconsW;/02a;ex0ulsa;!as;a0hreveport,ou4t 1;int 0n antonio;louGpaul;klahoXmaha,verland park;ashLe1or0;th dako7;braska,w 0;orleans,south me6;adisMe5i1o0;biHntgomery;lwaukee,nne1ss0;issippi,ouri;apol6so0;ta;mph4;aredo,i0ouisiana,ubb1;ncoln,ttle r0;ock;llino0owa,rving;is;oustAunts5;arland,rand prairie;allAes moines;dt,entral0hicago,orpus christi,st,t;! time;aton rouge,rowns0;vil0;le;laba8m5r1ust0;in;k1lingt0;on;ans0;as;arillo,erica0;! 0;central;ma", "Central", "n", "usa"], "Chihuahua": ["true¦chihuahua,h5la paz,m0;azatlan,exic1ountain 0;mexico,standard time (mexico);an pacific1o0;! pacific;! time;ep0np0p0;mx", "Mexican Pacific", "n", "mex"], "Costa_Rica": ["true¦c0sjmt;entral standard time,osta rica,r0st;!i", "Central", "n"], "Cuiaba": ["true¦am0brazil,cuiaba,mato grosso,varzea grande;azon standard time,t", "Amazon", "s"], "Danmarkshavn": ["true¦coordinated universal2d1g0utc,zulu;mt,reenwich mean1;anmarkshavn,enmark; time", "Greenwich Mean", "n"], "Dawson": ["true¦canada,dawson,m2y0;d0pt,wt;dt,t;ountain standard time,st", "Mountain", "n"], "Dawson_Creek": ["true¦canada,dawson creek,m1p0;pt,wt;ountain standard time,st,t", "Mountain", "n"], "Denver": ["true¦a5colorado springs,denver,el paso,m1navajo,salt lake,us0;/6a;dt,ountain0st,t;! 0;standard t0t0;ime;lbuquerque,merica0urora;! 0/shiprock;mountain", "Mountain", "n", "usa"], "Detroit": ["true¦america4detroit,e0grand rapids,us/michigan;astern0pt,st,t,wt;! 0;mi,standard t0t0;ime;! eastern", "Eastern", "n", "usa"], "Edmonton": ["true¦a6ca4edmonton,m0;ountain0st,t;! 0;standard t0t0;ime;lgary,nada0;!/1;lberta,merica 0;mountain", "Mountain", "n", "usa"], "Eirunepe": ["true¦a0brazil,eirunepe;c0mazonas west;re0t;! 0;standard t0t0;ime", "Acre", "n"], "El_Salvador": ["true¦c2el1s0;an0lv,oyapango,v; salvador;entral standard time,st", "Central", "n"], "Fort_Nelson": ["true¦british columbia,canada,fort nelson,m0;ountain standard time,st,t", "Mountain", "n"], "Fortaleza": ["true¦br5ca4e3fortaleza,imperatriz,j2m0natal,sao luis,teresina;a0ossoro;picernpb,racanau;oao pessoa,uazeiro do norte; south america s5ast south america;mpina grande,ucaia;a0t;silia0zil;! 0;s0t1;tandard t0;ime", "Brasilia", "s"], "Glace_Bay": ["true¦a1ca0glace_bay;nada,pe breton;st,t0;!lantic0;! 0;standard t0t0;ime", "Atlantic", "n", "usa"], "Goose_Bay": ["true¦a0canada,goose_bay,labrador,npt;st,t0;!lantic0;! 0;standard t0t0;ime", "Atlantic", "n", "usa"], "Grand_Turk": ["true¦america eastern,e2grand turk,kmt,t0;c0urks and caicos;!a;astern0st,t;! 0;standard t0t0;ime", "Eastern", "n", "usa"], "Guatemala": ["true¦c2g0mixco,villa nueva;t0uatemala;!m;entral standard time,st", "Central", "n"], "Guayaquil": ["true¦cuenca,ec2guayaquil,ma1q0santo domingo de los colorados;mt,uito;chala,nta;!t,u0;!ador0;! 0;mainland,time", "Ecuador", "n"], "Guyana": ["true¦g0;eorgetown,uy1y0;!t;!ana0;! time", "Guyana", "n"], "Halifax": ["true¦a4ca2halifax,n1p0;ei,rince edward island;ew brunswick,ova scotia;!nada0;!/atlantic;dt,st,t0;!lantic0;! 0;ns,standard t0t0;ime", "Atlantic", "n", "usa"], "Havana": ["true¦arroyo naranjo,bBc3diez de octubre,guantanDh1las tunas,pinar del rio,sant0;a clara,iago de cuba;avana,cu,e0n0olguin;cu;amaguey,i5u0;!b0;!a0;! 0;standard t0t0;ime;e0udad camilo cie0;nfueg1;ay1oyer0;os;amo", "Cuba", "n", "cuba"], "Hermosillo": ["true¦ciudad obregon,h1mexic0nogales,sonora;an pacific standard time,o;ermosillo,npmx", "Mexican Pacific", "n"], "Indiana/Indianapolis": ["true¦america2crawford,dadukmn,eastern in,i4p0star1us/east-indiana;erry,i0ulaski;ke;!/0;fort_wayne,i0;ndiana0;!polis", "Eastern", "n", "usa"], "Indiana/Knox": ["true¦america1c0indiana,knox,us/indiana-starke;entral standard time,st;!/knox_in", "Central", "n", "usa"], "Indiana/Marengo": ["true¦america,e0indiana,marengo;astern standard time,st", "Eastern", "n", "usa"], "Indiana/Petersburg": ["true¦america,e0indiana,petersburg;astern standard time,st", "Eastern", "n", "usa"], "Indiana/Tell_City": ["true¦america,c0indiana,tell_city;entral standard time,st", "Central", "n", "usa"], "Indiana/Vevay": ["true¦america,e0indiana,vevay;astern standard time,st", "Eastern", "n", "usa"], "Indiana/Vincennes": ["true¦america,e0indiana,vincennes;astern standard time,st", "Eastern", "n", "usa"], "Indiana/Winamac": ["true¦america,e0indiana,winamac;astern standard time,st", "Eastern", "n", "usa"], "Inuvik": ["true¦america mountain,canada,inuvik,m0pddt;ountain0st,t;! 0;standard t0t0;ime", "Mountain", "n", "usa"], "Iqaluit": ["true¦america eastern,canada,e0iqaluit;astern0ddt,st,t;! 0;standard t0t0;ime", "Eastern", "n", "usa"], "Jamaica": ["true¦e3j1k0new k0;ingston;am0m;!aica;astern standard time,st", "Eastern", "n"], "Juneau": ["true¦a0juneau;k5laska0merica;! 1n0;! s1;juneau area,s0t1;tandard t0;ime;st,t", "Alaska", "n", "usa"], "Kentucky/Louisville": ["true¦america0eastern 4k3l2wayne;!/0;k1l0;ouisville;entuc0;ky", "Eastern", "n", "usa"], "Kentucky/Monticello": ["true¦america,e0kentucky,monticello;astern standard time,st", "Eastern", "n", "usa"], "La_Paz": ["true¦bo1cochabamba,la paz,oruro,s0;anta cruz de la sierra,ucre;!l0t;!ivia0;! time", "Bolivia", "s"], "Lima": ["true¦arequiDc9huancCi8juliaca,lima,p2sant1t0;acna,rujillo;a anita los ficus,iago de sur8;e0iura,ucallA;!r0t;!u0;! 0;standard t0t0;ime;ca,quitos;allao,hi1us0;co;cl0mbote;ayo;pa", "Peru", "s"], "Los_Angeles": ["true¦a05ba03c00fWgarden grove,hTirviSlMmoJnIoFp9r8s1tacoma,us0washington state;/06a;a1eattle,f,p0tocktTunrise manor;okaPringH;cramenHn0; 1ta 0;aTclariV;bernardiRdiego,fran0jo4;!cisco;ancho cucamonga,ePiver7;a0dt,ort7st,t;cific1radi0;se;! 0;standard t0t0;ime;ak1cean0regFxnard;side;land;evada,orth las8;des1reno0; valley;to;a3o0;ng6s0; 0_0;angeles;!s0; vegas;ne;enders1untington0; beach;on;onta2re0;mont,s0;no;na;ali1hula vis0;ta;!f1;ja calif0kersfield;ornia;merica0naheim;! 0;pacific", "Pacific", "n", "usa"], "Maceio": ["true¦a6br1e0maceio; south america s3ast south america;asilia0t;! 0;s0t1;tandard t0;ime;lagoassergipe,racaju", "Brasilia", "n"], "Managua": ["true¦c3man2ni0;!c0;!ar0;agua;entral standard time,st", "Central", "n"], "Manaus": ["true¦am4brazil3c0manaus;entral brazil0uiaba;!ian0;! s5;!/we2;azon0t;! 1as ea0;st;s0t1;tandard t0;ime", "Amazon", "s"], "Martinique": ["true¦a3f1m0;a1q,tq;fmt,ort de france,rench ma0;rtinique;st,tlantic standard time", "Atlantic", "n"], "Matamoros": ["true¦america central,c2heroica ma1m0nuevo laredo,reynosa;a0exico;tamoros;entral0st,t;! 0;standard t0t0;ime", "Central", "n", "usa"], "Mazatlan": ["true¦cAh8l7m0tep4;azatlAexic1ountain 0;mexico,standard time (mexico);an pacific 2o0;! pacif0/bajasur;ic;standard t0t0;ime;a paz,os mochis;np0p0;mx;hihuahua,uliac0;an", "Mexican Pacific", "n", "mex"], "Menominee": ["true¦america4c0menominee,wisconsin;entral0st,t;! 0;standard t0t0;ime;! central", "Central", "n", "usa"], "Merida": ["true¦c3guadalajara,m0;e0onterrey;rida,xico0;! city;ampeche4entral 0st;mexic0standard 2;an,o0;! 0;time;!yucatán", "Central Mexico", "n", "mex"], "Metlakatla": ["true¦a0metlakatla;k5laska0merica;! 1n0;! s1;annette island,s0t1;tandard t0;ime;st,t", "Alaska", "n", "usa"], "Mexico_City": ["true¦a0Lb0JcYduran0Cecatepec de morel0AguThSiQjalis0Nleon de los alda06mInHoGpEqDs9t4uruap04v2x1yucat04za0;catec0Cpop03;alapa de enriqu0Pi0Lochimil0L;e0illahermosa;nustiano carranza,racruz;a3e7la1o0uxt03;luUna02;huac,l0quepaque,xca01;nepant00pW;bas0Emaulip04pachuZ;an0oledad de graciano sanch0H; luis potosi,t0;a maria chimal0iago de q1;huQ;ueretaG;achuca de soIoza rica de7ue0;bSrto vallar04;axaJjo de agua;aucalpan07icolas romeCuevo le06;agdalena contrerUex4i2o0x;nterrey,rel0;ia,os;choHguel0; h5;!ico0;! 0/general,_0;city;rap5xtapalu9zta0;cUpalapa;idalJ;a1erre0stavo adolfo made0;ro;dalajara,naj0;ua0;to;ampeche,eFhiCiudad Ao3st,u0wt;au1ernava0;ca;htemoc,titlan izcalli;a4l2yo0;ac0;an;i0onia del valle;ma;cEhui0tzacoalc2;la;lopez mate0nezahualcoyotl;os;ap1lpancin0;go;as;laya,ntral 0;mexic0standard 2;an,o0;! 0;time;enito6uenavis0;ta;capulco3guascalientes,lvaro obreg2zcapotz0;al0;co;on; de0; juar0;ez", "Central Mexico", "n", "mex"], "Miquelon": ["true¦hBmAp8s0;aint pierre2pm,t pierre 0;& miquelon 0a5;s2t3;! 0;a2s0;tandard t0;ime;nd1;ierre0m; m0;iquelon;npm,pm", "St. Pierre & Miquelon", "n", "usa"], "Moncton": ["true¦a0canada,hepm,moncton,new brunswick;st,t0;!lantic0;! 0;standard t0t0;ime", "Atlantic", "n", "usa"], "Monterrey": ["true¦c8g6m3sa1t0victoria de durango;ampico,orreon;ltillo,n0; nicolas de los garza,ta catarina;exico1on0;clova,terrey;! city;omez palacio,uadal0;ajara,upe;entral 1iudad 0st;apodaca,general escobedo,madero,victoria;mexic0standard 2;an,o0;! 0;time", "Central Mexico", "n", "mex"], "Montevideo": ["true¦montevideo5u0;r1y0;!st,t;uguay0y;! 0;s1t2;! s0;tandard t0;ime", "Uruguay", "s"], "New_York": ["true¦a0Rb0Oc0Hd0Ge0Bf07g05hialeah,i02j00kZlexingtonYmUnMoKpIquHrDsAt7u5v3w0yonkers;ashington1est 0inston salem,orcD;raEvirgin04;! dc;ermont,irginia0;! beach;nited states,s0;!/0Ma;a0enne1he bronx,oleD;llaha0mpa;ssee;outh 1t0; petersburg,aten3;bo0CcC;a2hode1ichmo06och0;ester; is03;lei2;eens,intana roo;ennsylvanNhiladelphNittsbur0rovidence;gh;hio,rlan0;do;ew3or1y0;!c;folk,th c0;aroliE; 1_yo0a0port news;rk;hampshiXje8york0;! staT;a1eads,i0;ami,chig1;ine,nhatt0ryMssachusetts;an;! fayetO;entucky,nox9;acks2e0;rsey;ndia1r0;on5;na;eorg0reensboro;ia;ayette1l0ort lauderda2;!orida;vil0;le;ast0dt,st,t; flatbush,ern0;! 0;standard t0t0;ime;elawa9urham;ape coral,h3incinnati,leve1o0;lumbus,nnecticut;la0;nd;a0esapeake;rlot0ttanooga;te;altimo1o0rooklyn,uffalo;st4;re;kr2merica0tlanta;! 0;eastern;on", "Eastern", "n", "usa"], "Nipigon": ["true¦america eastern,canada,e0nipigon;astern0st,t;! 0;standard t0t0;ime", "Eastern", "n", "usa"], "Nome": ["true¦a0no5;k5laska0merica;! 1n0;! s1;s0ti1west;tandard ti0;me;st,t", "Alaska", "n", "usa"], "Noronha": ["true¦atlantic islands,brazil3f0n4;ernando de noronha 0nt;standard t0t0;ime;!/den0;oronha", "Fernando de Noronha", "n"], "North_Dakota/Beulah": ["true¦america,beulah,c0north dakota;entral standard time,st", "Central", "n", "usa"], "North_Dakota/Center": ["true¦america,c1merc0north dakota,oliv0;er;ent0st;er,ral standard time", "Central", "n", "usa"], "North_Dakota/New_Salem": ["true¦america,c1n0;ew_salem,orth dakota;entral standard time,st", "Central", "n", "usa"], "Nuuk": ["true¦america3g1nuuk,wg0;st,t;l,r0;eenland,l;!/godthab", "West Greenland", "n", "green"], "Ojinaga": ["true¦america5c4m0ojinaga;ountain0st,t;! 0;standard t0t0;ime;hihuahua,iudad juarez;! mountain", "Mountain", "n", "usa"], "Panama": ["true¦a3coral h,e2pa0san miguelito;!n0;!ama;astern standard time,st;merica/0t2;at1c0;aym1oral_harbour;ikok0;an", "Eastern", "n"], "Pangnirtung": ["true¦a4baffin island,canada,e0nunavit,pangnirtung;astern0st,t;! 0;standard t0t0;ime;ddt,merica eastern", "Eastern", "n", "usa"], "Paramaribo": ["true¦paramaribo,s0;r2ur0;!iname0;! time;!t", "Suriname", "n"], "Phoenix": ["true¦aAc8g6idaho,m4n3phoenix,s2t1u0wyoming;s/arAtah;empe,ucsC;cottsd4inaloa,onora;ayarit,ew mexico;aryv2esa,o0st,t,wt;nta6untain standard time;ilbert,lend0;ale;h0olorado;andler,ihuahua;merica2r0;izo0;na;!/crest0;on", "Mountain", "n"], "Port-au-Prince": ["true¦america eastern,cAe6h4p0;etionville,ort0; 0-au-1;au 0de paix;prince;aiti,t0;!i;astern0st,t;! 0;standard t0t0;ime;arrefour,roix des bouquets", "Eastern", "n", "usa"], "Porto_Velho": ["true¦am5brazil,c2porto0rondônia; 0_0;velho;entral brazil0uiaba;!ian0;! s3;azon0t;! 0;s0t1;tandard t0;ime", "Amazon", "n"], "Puerto_Rico": ["true¦a2bayam9p0;r0uerto rico;!i;merica0st,tlantic standard time;!/0;a5blanc-sabl4curacao,dominica,g3kralendijk,lower_princes,m2port_of_spa1st_0torto7virg1;barthelemy,kitts,lucia,thomas,vincent;in;arigot,ontserrat;renada,uadeloupe;on;n0ruba;guil0tigua;la", "Atlantic", "n"], "Punta_Arenas": ["true¦c0punta arenas,region of magallanes;hile0lt;! standard time", "Chile", "s"], "Rainy_River": ["true¦america4c0ft frances,rainy river;entral0st,t;! 0;standard t0t0;ime;! central", "Central", "n", "usa"], "Rankin_Inlet": ["true¦america4c0rankin inlet;ddt,entral0st,t;! 0;standard t0t0;ime;! central", "Central", "n", "usa"], "Recife": ["true¦aAbr4caruaru,e3jaboatao2olinda,p0;aulista,e0;rnambuco,trolina;! dos guararapes; south america s4ast south a6;a0t;silia0zil;! 0;s0t1;tandard t0;ime;merica", "Brasilia", "n"], "Regina": ["true¦c2regina,s0;askat0k;c2oon;anada0entral standard time,st;!/saskatc0;hewan", "Central", "n"], "Resolute": ["true¦america4c0resolute;entral0st,t;! 0;standard t0t0;ime;! central", "Central", "n", "usa"], "Rio_Branco": ["true¦a1brazil0rio branco;!/1;c1merica/porto_0;acre;re0t;! 0;standard t0t0;ime", "Acre", "s"], "Santarem": ["true¦br1e0pará west,santarem; south america s4ast south america;a0t;silia0zil;! 0;s0t1;tandard t0;ime", "Brasilia", "n"], "Santiago": ["true¦aAc4iquique,la pintana,puente alto,rancagua,san3t1v0;alparaiso,ina del mar;alca0emuco;!huano; bernardo,tiago;h1l0oncepcion;!st,t;ile0l;! 0/continental;standard t0t0;ime;ntofagasta,rica", "Chile", "s", "chile"], "Santo_Domingo": ["true¦a8bella vista,do6la romana,s0;an0dmt; pedro de macoris,t0;iago de los caballeros,o domingo0;! 0;e0oe0;ste;!m0;!inican republic;st,tlantic standard time", "Atlantic", "n"], "Sao_Paulo": ["true¦a16b0Tc0Md0Je0Hf0Fg0Ahortol09i05j02l01mXnVosasco,pLriFs4ta3uber2v0;i0olta redon1A;amao,la velha,tor16;a0Ml06;boao da ser00uba10;a2e1oroNu0;maLzano;rXte lago0L;nt4o 0;bernardo do campo,carl03jo0leopolLpaulo,vicE;ao de meriti,se0;! do0; rio p8s camp00;a 1o0; andDs;barbara d'oes0Pluz0Tmar0T;beirao 3o0;! 0;cla0de janei0g6ver7;ro;das nev07p0;reto;asso fun8e7iraci6lanalti0Oo4r0;aia g1esidente prud0;en0G;ran0;de;nta grossa,rto aleg0;re;caW;lotYtro0F;do;iteroi,ov0;aJo hamburgo;a1o0;gi das cruzSntes clarD;ri0ua;l07n6;imei2ondri08;acarei,oinville,u0;iz de fo0ndi9;ra;ndaia2patin1ta0;bor6pevi,quaquece1;ga;tuG;andY;o3ravat2uaru0;ja,lh0;os;ai;iSvernador valadarC;loria5oz do0ran2; iguacu; south america sHast south ameri0mbu;ca;i0uque de caxi8;adema,vi0;noN;a1o0uriti2;ntagem,tK;choeiro de itapemirDmp1no3rapicui0scavel,xias do sul;ba;in1os dos goytacaz0;es;as;aBe7lumenau,r0;!a0st,t;!silia1zil0;!/east;! 0;s0t1;tandard t0;ime;l1t0;im;ford roxo,o horizon0;te;rueri,uru;lvora4merica3na2parecida de goi0;an0;ia;polis;na;da", "Brasilia", "s"], "Scoresbysund": ["true¦e3greenland2h0ittoqqortoormiit,scoresbysund;e0neg;eg,g;! eastern;ast greenland1g0;st,t;! 0;standard t0t0;ime", "East Greenland", "n", "eu0"], "Sitka": ["true¦a0sitka;k6laska0merica;! 1n0;! st2;s0t2;itka area,t0;andard t0;ime;st,t", "Alaska", "n", "usa"], "St_Johns": ["true¦canada7h5n0st johns;d3ewfoundland0st,t;! 0;labrador,standard t0t0;ime;dt,t;e0n0tn;tn;!/newfoundland", "Newfoundland", "n", "usa"], "Swift_Current": ["true¦c1s0;askatchewan,wift current;anada,entral standard time,st", "Central", "n"], "Tegucigalpa": ["true¦c2h0san pedro sula,tegucigalpa;n0onduras;!d;entral standard time,st", "Central", "n"], "Thule": ["true¦a0pituffik,thule;st,t0;!lantic0;! 0;standard t0t0;ime", "Atlantic", "n", "usa"], "Thunder_Bay": ["true¦canada,e0thunder bay;astern0st,t;! time", "Eastern", "n", "usa"], "Tijuana": ["true¦america8baja california,eAh6mexic4p0tijuana;acific0st,t;! 0;standard t0t0;ime;ali,o0;!/bajanorte;e0n0;nomx; pacific,/0;e0santa_isabel;nsenada", "Pacific", "n", "usa"], "Toronto": ["true¦americaGbEcaBe7gatineIhamilFkitchener,l4m3nepe2o0quebec,richmond hill,toronto,vaugh2windsor;n5sh0tt0;awa;an;arkham,ississauga,oF;avFon0;don on0gueuil;tario;astern0st,t;! 0;standard t0t0;ime;!n0;!ada0;!/7;arrie,ramp0;ton; 4/0;mo1nass0;au;ntre0;al;eastern", "Eastern", "n", "usa"], "Vancouver": ["true¦america 9b7ca5ladn4okanagan,p1surrey,v0yukon;ancouv3ictor7;acific0st,t;! 0;bc,standard time;er;!nada0;!/2;ritish columb0urnaby;ia;pacific", "Pacific", "n", "usa"], "Whitehorse": ["true¦canada1m0whitehorse,yst;ountain standard time,st;!/yukon", "Mountain", "n"], "Winnipeg": ["true¦america 7c2m1w0;est m0innipeg;anitoba;anada3entral0st,t;! 0;standard t0t0;ime;!/0;central", "Central", "n", "usa"], "Yakutat": ["true¦a0y4;k6laska0merica;! 1n0;! s2;s1t2y0;akutat;tandard t0;ime;st,t", "Alaska", "n", "usa"], "Yellowknife": ["true¦america mountain,canada,m0yellowknife;ountain0st,t;! 0;standard t0t0;ime", "Mountain", "n", "usa"] }, "Antarctica": { "Casey": ["true¦antarctica,cas0;ey,t", "Casey", "s", "ant"], "Davis": ["true¦a1dav0;is,t;ntarctica,q,ta", "Davis", "s"], "Macquarie": ["true¦a2canberra,eastern australia6m0sydney;acquarie0elbourne;! island;e4ntarctica,us0; east0tralia eastern;!ern0;! standard0; time;st,t", "Eastern Australia", "s", "aus"], "Mawson": ["true¦antarctica,maw0;son,t", "Mawson", "s"], "Rothera": ["true¦a1b0city of b0rothera;uenos aires;ntarctica1r0;gentina,st,t;!/palmer", "Argentina", "s"], "Troll": ["true¦antarctica,g2troll0;! 0;research station,t1;mt,reenwich mean t0;ime", "Troll", "s", "troll"], "Vostok": ["true¦antarctica,vost0;!ok", "Vostok", "s"] }, "Asia": { "Almaty": ["true¦a6central asia,east kazakhstan time,k2nur sultan,p1s0taraz,ust kamenogorsk;emey,hymkent;avlodar,etropavl;a0z;ragandy,z0;!akhstan0;! eastern;lm1s0;ia,tana;a0t; ata,ty", "East Kazakhstan", "n"], "Amman": ["true¦a2eet,irbid,jo0russeifa,wadi as sir,zarqa;!r0;!d1;mm0sia;an", "Eastern European", "n", "jord"], "Anadyr": ["true¦a0petropavlovsk kamchatsky;na0sia;dyr0t;! time", "Anadyr", "n"], "Aqtau": ["true¦a1kazakhstan western,mangghystaū/mankis3tashkent,west 0;asia,kazakhstan5;lm2q1s0;hgabat,ia;tau;a0t; ata,-ata0; time", "West Kazakhstan", "n"], "Aqtobe": ["true¦a1kazakhstan western,tashkent,west 0;asia,kazakhstan5;kto5lm2qt1s0;hgabat,ia;o3ö3;a0t; ata,-ata0; time;be", "West Kazakhstan", "n"], "Ashgabat": ["true¦as4t0;km,m2urkmen0;a4istan0;! time;!st,t;hga1ia0;!/ashkhabad;bat", "Turkmenistan", "n"], "Atyrau": ["true¦a1gur'yev,kazakhstan western,tashkent,west 0;asia,kazakhstan6;lm3s2t0;irau,yra0;u,ū;hgabat,ia;a0t; ata,-ata0; time", "West Kazakhstan", "n"], "Baghdad": ["true¦a6ba5dihok,erbil,i3k2mosul,na1r0;amadi,iyadh;jaf,sirC;arbala,irkuk,uwait;q,r0;aq,q;ghdad,sr9;bu ghurayb,d diw6l 5rab1s0; sulaym5ia,t;!i0;a0c;!n0;! time;amar2basrah al qadim2falluj2hill2kut,mawsil al jadid2;an0;iy0;ah", "Arabian", "n"], "Baku": ["true¦a0baku,ganja,lankaran,sumqayit;sia,z0;!e0t;!rbaijan0;! time", "Azerbaijan", "n"], "Bangkok": ["true¦asiaAbangkok,ch7h5i3jakarta,mueang nontha8na2pak kret,s0udon thani;amut prakan,e0i racha,outh east0; asia;khon ratchasima,m di9;ct,ndochina0;! time;a0ue;iphong,noi,t y2;iang m1on 0;buri;ai;!/0;phnom_pe0vientiane;nh", "Indochina", "n"], "Barnaul": ["true¦a3b2kra0north a3;snoyarsk0t;! time;arnaul,iysk;sia", "Krasnoyarsk", "n"], "Beirut": ["true¦asia,bei3e2l0ra's bay3;b0ebanon;!n;astern european time,et,urope eastern;rut", "Eastern European", "n", "leb"], "Bishkek": ["true¦asia,bishkek,k0osh;g2yrgy0;stan,zstan0;! time;!t,z", "Kyrgyzstan", "n"], "Brunei": ["true¦asia,b0;dt,n2r0;n,unei0;! darussalam time;!t", "Brunei Darussalam", "n"], "Chita": ["true¦asia,chita,yak0;t,utsk0;! time", "Yakutsk", "n"], "Choibalsan": ["true¦as2choibalsan,dornodsükhbaatar,mongol2ula0;anbaatar0t;! time;ia", "Ulaanbaatar", "n"], "Colombo": ["true¦as6c4dehiwala mount lavin6i2kolkata,lk1m0new delhi,sri lanka;oratuwa,umb4;!a;ndia0st;! time,n;henn0olombo;ai;ia", "India", "n"], "Damascus": ["true¦a4d3eet,h2latak5sy0;!r0;!ia;am3oms;amascus,eir ez zor;leppo,r raqq1s0;ia;ah", "Eastern European", "n", "syr"], "Dhaka": ["true¦asiaGbDcBd9jess8khul7mymensingh,na4pa3ra2s1t0;angail,ungi;aid8hib4ylhet;jshahi,ng7;b3ltan,r naogaon;gar5r0t3;ayan0singdi;ganj;na;ore;haka,inaj0;pur;hattogram,o0;milla,x's bazar;a0d,gd,ogra,st;gerhat,ngladesh0rishal;! time;!/dacca", "Bangladesh", "n"], "Dili": ["true¦asia,dili,east timor1tl0;!s,t;! time", "East Timor", "s"], "Dubai": ["true¦a5dubai,g3mus1om0ras al khaim2sharj2;!an,n;aff0c5;ah;st,ulf0;! time;bu dhabi,jm2rabi2sia0;!/musc0;at;an", "Gulf", "n"], "Dushanbe": ["true¦asia,dushanbe,t0;ajikistan1j0;!k,t;! time", "Tajikistan", "n"], "Famagusta": ["true¦asia,e0famagusta,northern cyprus;astern european time,et,urope eastern", "Eastern European", "n", "eu3"], "Gaza": ["true¦asia,eet,gaza2p0;alestine,s0;!e;! strip", "Eastern European", "n", "pal"], "Hebron": ["true¦asia,e0hebron,west bank;ast jerusalem,et", "Eastern European", "n", "pal"], "Ho_Chi_Minh": ["true¦asia7bien hoa,can tho,da 5ho3nha tr6qui nh8rach gia,sa dec,thi xa phu my,v0;ietnam1n0ung tau;!m;! south; chi 0_chi_0;minh;lat,n0;ang;!/saig0;on", "Indochina", "n"], "Hong_Kong": ["true¦asia,h0kowloon,tsuen wan;k3ong0; kong1_k0k0;ong;! time;!g,st,t", "Hong Kong", "n"], "Hovd": ["true¦as4bayan-ölgiigovi-altaihovduvszavkhan,hov2west0; 0ern 0;mongol2;d0t;! time;ia", "Hovd", "n"], "Irkutsk": ["true¦a2brat3irk0north asia east,ulan ude;t,utsk0;! time;ngar0sia;sk", "Irkutsk", "n"], "Jakarta": ["true¦aZbTcRdepQiNjKkediri,lJmGpArengasdengklQs4t2w0yogyakM;est0ib; indoneXern indonesia time;a0egal;n4sikmal3;ema4itubondo,outh tan3u0;kabumi,medaSra0;b0kF;aya;ge0;raO;a4e1robolinggo,urw0;akAokerto;ka1ma0rcut;laKtangsiantar;long2nbaru;daIl3mulaIruI;a1ed0;an;diun,laF;embaE;a0ember;k0mbi,vasumatra;arta;d1ndonesia0;! western;!n;ok;i0urug;ampea,bino5leungsir,mahi,putat,rebon;a1e0injai,ogor;kasi,ngkulu;nd0tam;a0u1; aceh,r lampu0;ng;sia", "Western Indonesia", "s"], "Jayapura": ["true¦a2east1indonesia eastern,jayapura,m0new guinea,wit;alukus,oluccas; indones1ern indonesia time;mbon,s0;ia", "Eastern Indonesia", "s"], "Jerusalem": ["true¦as7beersheba,haifa,i2j0petah tiqwa,rishon leziyyon,tel 9west je1;e0mt;rusalem;d3l,s0;r0t;!ael0;! time;dt,t;hdod,ia0;!/tel_0;aviv", "Israel", "n", "isr"], "Kabul": ["true¦a1herat,jalalabad,ka0mazar e sharif;bul,ndahar;f0sia;!g0t;!hanistan0;! time", "Afghanistan", "n"], "Kamchatka": ["true¦a2kamchatka,pet0;ropavlovsk0t; kamchatsky,-kamchatski time;nadyr,sia", "Petropavlovsk-Kamchatski", "n"], "Karachi": ["true¦asia,bLchiniKdera ghaziIfaisalHgujraGhyderHislamHjhang sadr,kElaDm8nawabshah,okaBp4quetta,ra3s0;a1h0ialkJukkN;ahkIekhupu9;ddiqEhiwal,rgodha;him yarEwalpindi;ak1eshawar,k0;!t;!istan0;! time;a3i1u0;lt9zaffar7;ngo0rpur khas;ra;lir cantonment,rd6;hore,rkana;a0otli;moke,rachi,s8;n5t;abad; kh0;an;ot;a1himber,ure0;wala;hawalp0ttagram;ur", "Pakistan", "n"], "Kathmandu": ["true¦asia3biratnagar,kath4n1p0;atan,okhara;epal,p0;!l,t;!/kat0;mandu", "Nepal", "n"], "Khandyga": ["true¦asia,khandyga,yak0;t,utsk0;! time", "Yakutsk", "n"], "Kolkata": ["true¦0:3D;1:3L;2:2D;3:3M;4:3J;a35b2Dc24d1We1Uf1Sg1Fh1Ci18j13k0Pl0Km0Cn05odis3KpVquthbull3DrNsFt9u8v5warang2Myamun1P;a6el1Ui5;jayawa2Vsakha0HzianagC;doda2Orana11;daip0jja23lhasn1ttar pradesh;a8eXh7iru5umk0;chirap0Mnelve2p5vottiy0;a39p0;ane,iruvananthapur0Noothuku2Yriss0;mb5njo1X;ar0L;aBecunder4h9i8lst,o7r1Fu5;jan37r5;at,endr1C;l2Znip2N;k3liguKngrau2rJ;ahj1Zi5ri2Oya0L;mo1Mvaji07;har1Xlem,mbh24ng2t04ug0Y;a6e0Eoh5;iItak;ebare2i9j7m5nc1Gtl0Aurke37;ag5g5p0;und08;a5kot;hmund26sth2A;ch0p0;a9imp8roddat0u5;ducher23n5rn17;a5e;sa;ri;li,n7rbha6t5;ia2Vna;ni;chku2Ti5;ha2Gp21;a7e6izam4o5;i1Vwrang2B;l0Sw del0Y;di2Kg7i0Ejaf2Fn5re2Oshik,vi mumb15;ded,g5;i,loi j1V;ercoil,p0;a8eerut,irz25o7u5yso0Y;lugu,mb10rwa1Izaffar5;n1p0;nghyr,rad4;chili7d6harasht1Fleg07n5thu1Fu;ga0Iip0;hya,ur0V;patnG;a7u5;cknow,dhia5;na;l bahadur5t0; n1;aDhaBo8u5;kat6lt5rno1P;a2i;pal2;l5rWta,zhikode;h1Nka1Kl5;am;nd5ragp0;wa;kina13l8marOnp0r5shmir,tih3;i6na5ol ba18;l,tV;mn1;lakuric03y11;a6han5odNunagadh;si;b0Rip0l6m5;mu,n1shedp0;andh3gGna;chalkaranji,mph0In5st;!d5;!ia5o00;! time,n;a6is3ospet,u5;b2g2;o0Hp0ridw3;aChazi4o9reater noi0Mu6wali5y04;or;jar0OlbarQnt0rg6wa5;ha12;aon;rak6sa5;ba;hp0;juw8n5ya;dh6g5;an1;in1;aka;ar5iroz4;id4rukh4;l5taw0M;loF;aAe8h6indigul,ombOurg5;!ap0;anb0Uul5;ia;hra dun,l5was;hi;rbhan5vange8;ga;a09h8o5uttack;ch6imbato5;re;in;a6enn5;ai;nd5pL;a5i0C;!nn1;aNeKhBi9or7rahm04u5;landshahr,rh5;anp0;iv2;li;d3har sharif,jZkan07l5;asp0imoC;aAi7op6u5;baneshw3sav5;al;l6wan5;di,i;ai,wa6;g6ratp0tpa5vn1yand3;ra;alp0;l5ngaluru;gaum,la5;ry;hAli,r6thin5;da;a6ddham5eilly;an;n1s5;at;a6rai5;gh;ramp0;gQhmLizawl,jmKkoRlHmDnantCrrBs6urang4va5;di;ans8ia5;!/ca5;lcut5;ta;ol;ah;ap0;arnath,batt0r5;ava5its3o9;ti;ur;appuz6i5lah4w3;garh;ha;er;adn1ed4;ab5;ad;ag3;ar;arta5ra;la", "India", "n"], "Krasnoyarsk": ["true¦a2kra0north a2;snoyarsk0t;! time;sia", "Krasnoyarsk", "n"], "Kuala_Lumpur": ["true¦aHbukit mertajGgeorge town,ipoh,johor bahFk8m4petali3s0taipiE;e1hah alFu0;ba1ngai petani;paBremb7;ng jaya;ala1y0;!s,t;cca,ysia0;! time;ampung baru suba5la5ota bha6ua0;la1nt0;an; 0_l1;l0terengganu;umpur;ng;ru;am;lor setar,sia", "Malaysia", "s"], "Kuching": ["true¦asia,k4m2s0tawau;a0ibu;bahsarawak,ndakan;alaysia0iri,yt;! time;ota kinabalu,uching", "Malaysia", "n"], "Macau": ["true¦asia6beiji5c2hong ko5m0urumqi;ac0o;!au;h0st;ina0ongqi1;! time;ng;!/macao", "China", "n"], "Magadan": ["true¦asia,mag0;adan0t;! time", "Magadan", "n"], "Makassar": ["true¦asiaBba8c5denpa4indonesia central,k3l2ma1palu,s0wita;amarinda,ulawesi;kas2nado,taram;abuan bajo,oa jan7;endari,up8;sar;e0ity of bal3;lebesbalinusa,ntral indonesia0;! time;l0njarmasin;ikpap0;an;!/ujung_pand0;ang", "Central Indonesia", "s"], "Manila": ["true¦a04bWcRdaPgeneral santOiMlJmCnaBoAp4quezIsan1ta0zamboanga;clobZguig,rlac,ytE; 1t0;a ro2ol;fernando,jose del monte,pab02;a3h1uerto prince0;sa;!ilippine0l,st,t; time,s;gadiRnalanoy,s0;ay,ig;longapo,rmoc;ga,votQ;a0eycauayN;balacat,gugpo poblaci4kati,l3n0;da1ila,silingLtamp0;ay;luyong,ue;ingDol6;on;a1egaspi,i0ucena;bertad,pa;pu lapu,s p4;l0mus;igCoiI;os;smar0v5;inB;a0ebu,otabato;b1gayan de oro,in5l0;amba,ooc6;anatu5uy0;ao;a4inan2u0;d0tu2;ta;!gon0;an;co1guio,tang0;as;lod,or;n0sia;geles,tipo0;lo", "Philippine", "n"], "Nicosia": ["true¦a5cy3e0n2;astern european time,et,urope0; eastern,/n0;ico2;!p0;!rus;sia", "Eastern European", "n", "eu3"], "Novokuznetsk": ["true¦a5k2no0prokop'yev1;rth a4vokuznet0;sk;emerovo,ra0;snoyarsk0t;! time;sia", "Krasnoyarsk", "n"], "Novosibirsk": ["true¦as3no0siber3;rth central as2v0;osibirsk0t;! time;ia", "Novosibirsk", "n"], "Omsk": ["true¦asia,oms0;k0t;! time", "Omsk", "n"], "Oral": ["true¦a2kazakhstan western,oral,tashkent,west 0;asia,kazakhstan0;! 4;lm1s0;hgabat,ia;a0t; ata,-ata 0;time", "West Kazakhstan", "n"], "Pontianak": ["true¦asia,b2indonesia western,pontianak,tanjung pinang,w0;est0ib; b0ern indonesia time;orneo", "Western Indonesia", "n"], "Pyongyang": ["true¦asia,chongjin,h7k4n3p2s0won8;ariw0eoul,inuiAunch'0;on;rk,yongya7;amp'o,orth korea;a1orea0p,st;!n time;eso3nggye;a1ungnam,ye0;san;e1mhu0;ng;ju", "Korean", "n"], "Qatar": ["true¦a2doha,kuwait,qa0riyadh;!t0;!ar;r2s0;ia0t;!/bahrain; rayyan,ab0;!i0;a0c;!n0;! time", "Arabian", "n"], "Qostanay": ["true¦a2central asia,east kazakhstan time,k0qo1;azakhstan eastern,o0;stanay;lmt,s0;ia,tana", "East Kazakhstan", "n"], "Qyzylorda": ["true¦a4k1qy2tashkent,west 0;asia,kazakhstan7;azakhstan western,y0zyl-1;zyl0;orda;lm1s0;hgabat,ia;a0t; ata,-ata0; time", "West Kazakhstan", "n"], "Riyadh": ["true¦a9burayd8dammam,ha7jedd8k6me5najran,riyadh,s4ta3y0;anbu,e0;!m0;!en;'if,buk;ultan3yot;cca,dina;hamis mush6uw6;'il,far al batin;ah;bha,l 8ntarctica/syowa,rab4s0;ia0t;!/0;aden,kuw0;ait;!i0;a0c;!n0;! time;hufuf,jubayl,kharj,mubarraz", "Arabian", "n"], "Sakhalin": ["true¦asia,sak0yuzhno sakhalinsk;halin0t;! 0;island,time", "Sakhalin", "n"], "Samarkand": ["true¦asia,bukhara,nukus,qarshi,samarkand,uz0;bekistan0t;! 0;time,west", "Uzbekistan", "n"], "Seoul": ["true¦aPbuMchHdaeGgChwaseoRiBjeAk7m6pohaFrok,s2u1wonJy0;aCeosu;ijeongbuQlsL;e1outh korea,u0;nEwH;joAo0;ngnamMul;asGokpo;imhae,or0r,st,wangmyo7;!ea0;!n time;ju,on8;cCksBn6;angneu2oyaEu1wa0;ng5;mi,ns8riD;ng;gu,je4;angw3eon2in1un0;che2;ju;an,gju7;on;c1s0;an;heon3;n0sia;san1ya0;ng0; si", "Korean", "n"], "Shanghai": ["true¦0:3J;1:36;2:34;3:37;4:3D;a3Cb31c2Nd2He30f2Cg26h1Qji1Ek1Bl0Ym0Wn0Tordos,p0Pq0Lrizh10s08t01u3FwSxLyEz5;aoCh6i5ouc3unyi;bo,go0;a7en6ouk2u5; c3h31maWzh2;g2Vj1Izh2;b1Vng5o3E;jiakou5zh2;! shi xuanhua qu;ya0z27;an9i7u5;ci,e18n5;c3fu;b4c9n5ya0;cZgk2;c3g5ji,t2Q;j17qu1sh16zh2;i6uc5;ha0;a6n5uyi0;di,gt2Lh1Gi0pu,t2Lx13ya0;m17n5;!g5ni0t0Eya0;t1ya0;aBe9u5;h6so0w1Cx5zh2;i,ue;a5u;i,n;i0Hn5;sh1zh2;fang5nxi1;di1;a8i6ong5;chuans0XhDli02sh1;an5eli0;j4sh10;i6ng5;gu,sh1;an,hec1Wyu1zh2;anmi0hAi8u5;i5zh2;h5zh2;ua;c5pi0;hu1;a7en6i5uangya14;jiaz15qi,y1;gli,ya0zh0G;n6o5s0I;gu1xi0;g5t2;h1Pqiu,rKyu;i5uan1J;aFn5o14qih1Y;g5huangdH;dGh1L;an0Ting7rc,u5;ti1yang5;! H;ding0QxZ;an5eijYingbo;ch5ji0ni0to0ya0;a0o0;entoug2ianRuda5;njU;aEi8u5;anc3o6qi5;ao;he,ya0;a7jPn5upansh02;fTxia 5yi;chengguanI;n0Do5;c3y5;a0u1;i0Wn5ohek2;g5zh2;fa0;ai6un5;mi0sh1;fe0yu1;'1aAe9l4n6u5xi;jCt0U;an,c3g5i0zh2;de5li0zh2;zhE;ya0;musi,n8o5xi0;j6z5;uo;ia0;g5shG;m7xi;aGeCkt,oBu5;a6i0Dlan ergi,m5n1;en;i7ng5y4;ga0s5;hi;'1b9n1;hhot,ng ko0;bi,f7ga0ng5ze;sh5ya0;ui;ei;i7n5rb4;d1g5;u,zh2;c3k2l0F;a9u5;an6i5li;l4ya0zh2;g5k2;do0yu1zh2;nsu,opi0;en7o6u5;ji1shQx4zh2;sh1;d2g5;hua0;a6eNong5;gu1hR;d6lian5ndo0qi0to0;!g;o5uk2;nghN;angHh5n,st,t;aAen7i5n,oZuG;fe0na5;! time;g5zh2;d5zho0;e,u;ng6o5;ya0zh2;ch7de,sh6zh5;i,ou;a,u;un;zh2;a9e5;i6n5;gbu,xi;'1h5ji0;ai;i7o5yan nur;di0t2;ou;c3sh1y4;an;he0;nDsia5;!/5;ch8harb4kashg6u5;rumqi;ar;in;o5ungki0;ng5;qi0;da,qi0sh5ya0;an,un;ng", "China", "n"], "Singapore": ["true¦asia,kuala lumpur,s0woodlands;g0ingapore;!p,t", "Singapore", "s"], "Srednekolymsk": ["true¦asia,chokurdakh,sre0;dnekolymsk,t", "Srednekolymsk", "n"], "Taipei": ["true¦asia,banqiao,cst,h7k5roc,t0;a1w0;!n;i0oyu1;ch2n0pei,w0;an;aohsi0eel0;ung;sinchu,ualien", "Taipei", "n"], "Tashkent": ["true¦a3namangan,qo`q4tashkent,uz0;!b0t;!ekistan0;! east;ndij0sia;on", "Uzbekistan", "n"], "Tbilisi": ["true¦asia,ge1kuta0tbil0;isi;!o0t;!rgia0;!n", "Georgia", "n"], "Tehran": ["true¦aQbMgorgWhamViKkCmaBn8orumiy7pasragad branch,q4rasht,s2t1varam6yazd,za0;hedVnjV;abHehrU;a0hirRirjT;bzevar,nandEri,v3;a0om;rchak,zv0;in;eh;a0eyshabur;jaf0zar0;ab4;layer,shh3;a4erman3ho0;meyni sDrram0wy;ab0sC;ad;!shah;h1r0;aj;riz;r0sfahB;!an,dt,n,st;a2irjand,o0uk9;jnu0ruje0;rd;b3ndar abbas;b4hv3m2r1sia,zads0;hahr;ak,dabil;ol;az;ad0;an", "Iran", "n"], "Thimphu": ["true¦asia2b0thimphu;hutan,t0;!n;!/thimbu", "Bhutan", "n"], "Tokyo": ["true¦0:11;1:1A;2:10;a18ch16fu0Zgifu14h0Oi0Ij0FkZmTnMoKsFt9u8waka05y3;a6o3;k3no;kaic1Co3;ha2su0;maKo;ji,tsun0F;aka7o3sukuba;k5makom05y3;a2o3;hOna0ta;oro03us0Qyo;m0Jrazu0sa1tsu1;a5end00hi4o0u3;i10zu0;monose1zuo0;ita2k3ppoLsebo;ai,u06;dawa05i0Wka3sa0t0E;ya2za1;a6eyaga0Qi3umazu;i4shi3; tokyo0Inomiya ha2;ga0R;g3ha,ra0G;a3oX;no,o0sa1;a5i3orio0;na3to,yaza1;mirinkOto;chiDeb4tsu3;do,m8ya2;as0J;aBi9o7u3y6;mam5r4shi3;ro;ashi1e,ume;oto;be,c0Dfu,ri3shigaK;ya2;shiwa3takyushu;da;gosVkogawacho honmKmirenjaku,na8s5wa3;g3sa1;oe,uc07;hi01u3;g3kabe;ai;zaY;ap4dt,oetJp3st;!n;an;bara1chi4ta3wa1zu3;mi;ha5n3;omi3;ya;ra;a8i3oncho;meBr4t3;acR;a4os3;a1hi2;kaNtsu0;chi5kodate,mam3;at3;su;nohe,o3;ji;ji8ku3;i6o0s3ya2;hi2;ma;ka; sD;!sa7;i3ofu;ba,g6;geoshimo,k7mag5njo,omori,s3tsugi;ahika3ia;wa;asa1;ki;as4i3;ta;hi", "Japan", "n"], "Tomsk": ["true¦asia,oms0tomsk;k,t", "Omsk", "n"], "Ulaanbaatar": ["true¦asia3m1ula0;anbaatar,n 3t;n0ongolia;!g;!/ulan_0;bator", "Ulaanbaatar", "n"], "Ust-Nera": ["true¦asia,ust-nera,vla0;divostok,t", "Vladivostok", "n"], "Vladivostok": ["true¦asia,k1vla0;divostok,t;habarovsk0omsomolsk on amur;! vtoroy", "Vladivostok", "n"], "Yakutsk": ["true¦asia,blagoveshchen1yak0;t,ut0;sk", "Yakutsk", "n"], "Yangon": ["true¦asia4b3kyain seikgyi township,m0nay pyi taw,pathein,sittwe,yang5;a1eiktila,m0onywa;!r,t;ndalay,wlamyine;ago,urma;!/rango0;on", "Myanmar", "n"], "Yekaterinburg": ["true¦asia,chelyabin7eka5k4magnitogor7nizhn3or2perm,s1tyumen,ufa,yek0zlatoust;a4t;terlitamak,urgut;e3sk;evartov3y tagil;amensk ural'skiy,urgan;teri0;nburg;sk", "Yekaterinburg", "n"], "Yerevan": ["true¦a0caucasus,yerevan;m2rm0s1;!en0;ia;!t", "Armenia", "n"] }, "Atlantic": { "Azores": ["true¦a0hmt;tlantic,zo0;res,st,t", "Azores", "n", "eu0"], "Bermuda": ["true¦a2b0;ermuda,m0;!u;st,t0;!lantic", "Atlantic", "n", "usa"], "Canary": ["true¦atlantic,canary1europe western,las palmas de gran canaria,santa cruz de tenerife,we0;stern european,t;! islands", "Western European", "n", "eu1"], "Cape_Verde": ["true¦atlantic,c0;a1pv,v0;!t;bo verde0pe verde;! is", "Cape Verde", "n"], "Faroe": ["true¦atlantic2f0;aroe0o,ro;! islands;!/faeroe", "Western European", "n", "eu1"], "Madeira": ["true¦atlantic,europe western,madeira1we0;stern european,t;! islands", "Western European", "n", "eu1"], "Reykjavik": ["true¦atlantic,coordinated universal3g2i0reykjavik,utc,zulu;celand,s0;!l;mt,reenwich mean0; time", "Greenwich Mean", "n"], "South_Georgia": ["true¦atlantic,gs1s0;gs,outh georgia;!t", "South Georgia", "n"], "Stanley": ["true¦atlantic,f0stanley;alkland1k0lk;!st,t;! island0;!s", "Falkland Islands", "s"] }, "Australia": { "Adelaide": ["true¦a2cen0south 1; 0tral 0;australia;c2delaide,ustralia0;! 0/south,n 0;central;dt,st,t", "Central Australia", "s", "aus"], "Brisbane": ["true¦a1brisbane0gold coa5logan,q4townsville;! time;e3ustralia0;!/q1n east0;!ern;ueensland;st", "Brisbane", "s"], "Broken_Hill": ["true¦a1broken_hill,cen0y3; australia standard time,tral australia;c2delaide,ustralia0;! central,/y0;ancowinna;st,t", "Central Australia", "s", "aus"], "Darwin": ["true¦a0darwin,northern territory;cst,ustralia0;!/north,n central", "Australian Central", "s"], "Eucla": ["true¦a0cw4eucla;cw4us0; central w1tralia0;!n central western;!e0;st;dt,st,t", "Australian Central Western", "s"], "Hobart": ["true¦a0canberra,eastern austral5hobart,king island,melbourne,sydney,t4;e8us0; east5tralia0;! 3/0n 3;currie,t0;asman0;ia;easte1;!e0;rn;dt,st,t", "Eastern Australia", "s", "aus"], "Lindeman": ["true¦a0brisbane time,lindeman,whitsunday islands;est,ustralia0;!n eastern", "Brisbane", "s"], "Lord_Howe": ["true¦australia3l0;h1ord howe0;! island;dt,st,t;!/lhi", "Lord Howe", "s", "lhow"], "Melbourne": ["true¦a0canberra,eastern austral4geelong,melbourne,sydney,v3;e7us0; east4tralia0;! 2/v0n 2;ictor0;ia;easte1;!e0;rn;dt,st,t", "Eastern Australia", "s", "aus"], "Perth": ["true¦a4perth,w0; 2est0; 1ern australia0;! time;australia;ustralia1w0;dt,st,t;! weste1/west,n west0;!e0;rn", "Western Australia", "s"], "Sydney": ["true¦a0c5eastern australia time,melbourne,new south wales,sydney,wollongong;e8u0;!s0;! east4tralia0;! 2/0n 2;act,c0nsw;anberra;easte1;!e0;rn;dt,st,t", "Eastern Australia", "s", "aus"] }, "Etc": { "GMT": ["true¦coordinated universal3etc2g0utc,zulu;mt,reenwich0;! mean1;!/greenwich; time", "Greenwich Mean", "n"], "UTC": ["true¦coordinated universal7etc2g1u0z4;ct,n5tc;mt,reenwich mean5;!/0;u1z0;ulu;ct,n0;iversal; time", "Greenwich Mean", "n"] }, "Europe": { "Amsterdam": ["true¦a9brussels,c6e4groning7madrid,n2paris,ro1t0utrecht;he hague,ilburg;mance,t9;etherlands,l0;!d;indhov2urope0;! central;e1openhag0;en;ntral european,st,t;lmere stad,m0;s0t;terdam", "Central European", "n", "eu2"], "Andorra": ["true¦a3brussels,c1europe0madrid,paris,romance;! central;e0openhagen;ntral european,st,t;d,nd0;!orra", "Central European", "n", "eu2"], "Astrakhan": ["true¦astrakh1europe,m0russi1st petersburg,volgograd time;oscow,sk;an", "Moscow", "n"], "Athens": ["true¦athens,e1gr0thessaloniki;!c,eece;astern european,et,urope0;! eastern", "Eastern European", "n", "eu3"], "Belgrade": ["true¦b9c7europe3madrid,n2p1romance,s0;i,lovenia,vn;aris,risti4;is,ovi sad;! central,/0;ljublja1podgorica,s0zagreb;arajevo,kopje;na;e0openhagen;ntral european,st,t;elgrade,russels", "Central European", "n", "eu2"], "Brussels": ["true¦antwerp6b3c1europe0gent,liege,madrid,paris,romance;! central;e0harleroi,openhag4;ntral european,st,t;e0mt,russels;!l0;!gium;en", "Central European", "n", "eu2"], "Bucharest": ["true¦b5c4e2gala1iasi,oradea,ploies1ro0timisoara;!mania,u;ti;astern european,et,urope0;! eastern;luj napoca,onstanta,raiova;ra0ucharest;ila,sov", "Eastern European", "n", "eu3"], "Budapest": ["true¦b6c3debrec4europe2hu0madrid,paris,romance;!n0;!gary;! central;e1openhag0;en;ntral european,st,t;russels,udapest", "Central European", "n", "eu2"], "Busingen": ["true¦b5c3de2europe1germa0madrid,paris,romance,saxo0;ny;! central,/berlin;!u;e0openhag3;ntral european,st,t;avaria,r0using1;em0ussels;en", "Central European", "n", "eu2"], "Chisinau": ["true¦chisinau,e2m0;d0oldova;!a;astern european,et,urope0;! eastern,/tiraspol", "Eastern European", "n", "eu2"], "Copenhagen": ["true¦arhus,brussels,c2d1europe0madrid,paris,romance;! central;enmark,k,nk;e0mt,openhagen;ntral european,st,t", "Central European", "n", "eu2"], "Dublin": ["true¦ace,british8cork,d7e6g5i3l0tse,waterford;i0ond1;merick,sb0;on;e,r0st;eland,l;alway,mt,reenwich mean2;dinburgh,ire,urope;mt,ublin; time", "Irish", "n", "eu1"], "Gibraltar": ["true¦b5c3europe2gi0madrid,paris,romance;!b0;!raltar;! central;e0openhagen;ntral european,st,t;dst,russels,st", "Central European", "n", "eu2"], "Helsinki": ["true¦e3fi1helsinki,t0vantaa;ampere,urku;!n0;!land;astern european,et,spoo,urope0;! eastern,/mariehamn", "Eastern European", "n", "eu3"], "Istanbul": ["true¦aYbScQdOeKgJiHkFmBosmAs4t1u0v07zeytinburnu;eskuedWmr9;arsus,r1ur0;!kZ;!abzon,t;a3i1ultan0;beyJgazi;sIv0;as,erek;msun,n0;cakteBliurfa;aniye;a1er0uratpaH;kezefendi,sin;l0niF;atQte6;a0irikkale,onPutahP;hramanmaras,rabaglGyseS;sJzmi0;r,t;aziantep,ebze;lazig,rzurum,s1uro0;pe;en0kiC;l8yurt;eniz0iyarbakB;li;ankaEor0;lu,um;a1ur0;sa;gcil2hcelievl1likes5sak4t0;ikent,mB;er;ar;d7n4rnavutko3sia/is2ta0;seh0;ir;tanbul;ey;kara,ta0;k0l0;ya;a1iyam0;an;na,paza0;ri", "Turkey", "n"], "Kaliningrad": ["true¦e0kaliningrad;astern european,et,urope", "Eastern European", "n"], "Kiev": ["true¦bila tserkLcherIdGeDhorlCivano frankivHk8l7m5odessa,poltaLriv4sumy,ternopil,u2vinnyts1z0;aporizhzh0hytomyr;ya;a,kr0;!ai0;ne;a0ykolayE;ki5riu8;ut9vC;amyanske,h1iev,r0yB;emenchuk,opyv1yvyy rih;ark9erson,mel0;nytskyy;ivka;astern european,et,urope0;! eastern,/simfero0;pol;nipro,onet0;sk;kasy,ni0;h0vtsi;iv;va", "Eastern European", "n", "eu3"], "Kirov": ["true¦europe,kirov,m0russian,st petersburg,volgograd time;oscow,sk", "Moscow", "n"], "Lisbon": ["true¦amadora,europe5lisbon,p2we0;st0t;! europe,ern european;ort0rt,t;o,ugal0;! mainland;! western", "Western European", "n", "eu1"], "London": ["true¦a0Ob0Ac07d03eXgThRiOj00kingston upon hull,lJmHnBoxSp9reading,s1w0yF;arwick0Aig00olverha7;heffield,o3t2u1w0;an4iH;ffolk,nderland,rr0IsYttL;afNoke on tre0C;meZuth0;a1end on 0;sea;mptG;ly0orts0restF;mouth;ew4o0;r0ttinghamT;th0wC; y0amptonR;orkV;castle upon tyne,port;ancheQi0;dlan4lton keynes;ancaRdn,e2i1o0ut5;nd4;ncolnPsb3verW;e0icesterJ;ds;psw1slingt0;on;ich;ampJert0;fordI;b2l1mt0reenwich mean M;! standard L;asgow,oucesterF;!-eF;dinburgh,s4urope0;!/0;belNguernsMisle_of_m1j0;ersL;an;sex;erby2o1u0;blin,dlH;rset;!sh5;a1ity of westmin0oventry,rawlE;ster;mbridge1rdiff;eAir9lack7r2st,uckingham0;sh0;ire;adford,e3i0;st4tish0;! 0;time;nt;po0;ol;kenhead,mingham;l1xl0;ey;fast;berdeen,rchway", "British", "n", "eu1"], "Luxembourg": ["true¦brussels,c3europe2lu0madrid,paris,romance;!x0;!embourg;! central;e0openhagen;ntral european,st,t", "Central European", "n", "eu2"], "Madrid": ["true¦aRbOcJeGfuenDgCjerez de la frontera,lBm8ovieFp6romance,s1terrassa,v0wemt,zaragoza;alladol9igo;a1evilla,pain0;! mainland;badell,n0; sebastiHt0; marti,ander,s montjuic;a0uente de vallecas;lma,mpIris;a0ostolLurcK;dr0laga;id;atiJeganI;asteiz/vitorGijon,ran1;carral el par1labr0;ada;do;ixample,lche,s1urope0;! centr2;!p;a3e1iudad line0openhagen;al;ntral europe0st,t;an;rabanchel,stello de la pla7;a0ilbao,russels,urgos;da0rce0sque;lo4; coru3l0;cala de henar1icante,mer0;ia;es;na", "Central European", "n", "eu2"], "Malta": ["true¦brussels,c3europe2m0paris,romance;a0lt,t;drid,lta;! central;e0openhagen;ntral european,st,t", "Central European", "n", "eu2"], "Minsk": ["true¦b4europe,h3m1russian,st petersburg,v0;iteb4olgograd time;ahily0in3osc0sk;ow;omyel,rodna;abruy0elarus,lr,rest,y;sk", "Moscow", "n"], "Monaco": ["true¦brussels,c3europe2m0paris,romance;adrid,c0onaco;!o;! central;e0openhagen;ntral european,st,t", "Central European", "n", "eu2"], "Moscow": ["true¦ar0Db0Ac07dzerzh06europe,fet,grozn05ivano04kYlipet0FmRnNorel,pKrFs8t6v2w-su,y0zelenograd;a0oshkar oW;roslavl,sene02;asyl'evsky ostrIelikiMladi2o0ykhino zhulebT;l0ronezh;gograd Pogda;kavkaz,m08;a0uQver;ganrog,mbD;a4ever3hakhty,molen06ochi,t0yktyvkR; 4a0;ryy osk0vrop0;ol;nSodvT;int 0rX;petersburg;ostov na donu,u1y0;azLbP;!s0;!sia0;!n;e1odolUsk0;ov;nza,trozavodS;a2izhn0ovorossiyR;ekamQi0;y novM;berezhnyye chelny,l'chik;a3dst,oscow1s0urmJ;d,k;! 0;time;khachka1r'0;ino;la;a2himki,ostroma,rasno0urG;d0gvargeisky;ar;l1z0;an;ininsk5uga;vo;yy;in8;entraln1he0;boksary,repovets;iy;el1ry0;an3;gorod;khangel'1mav0;ir;sk", "Moscow", "n"], "Oslo": ["true¦a6b5c3europe2madrid,oslo,paris,romance,s0;j0valbard and jan 6;!m;! central;e0openhag4;ntral european,st,t;erg2russels;rctic/longyearby1tlantic/jan_0;may0;en", "Central European", "n", "eu2"], "Paris": ["true¦bIcFeuropeEfrBl9m7n5paris,r3s0toulouH;aint 1t0; 0rasbourg;etienne;e0oman9;ims,nn1;ant0i7ormandy;es;a0et,ontpellier;drid,rsei1;e havre,i0yon;lle;!a0;!n0;ce;! central;e0openhagen;ntral european,rgy pontoi0st,t;se;ordeaux,russels", "Central European", "n", "eu2"], "Prague": ["true¦br6c4europe2madrid,ostr3p1romance,s0;k,lovakia,vk;aris,mt,rague;! central,/bratisl0;ava;e0openhagen;ntral european,st,t;no,ussels", "Central European", "n", "eu2"], "Riga": ["true¦e2kalt,l0riga;atvia,st,v0;!a;ast2e1urope0;! eastern;st,t; europe,ern european", "Eastern European", "n", "eu3"], "Rome": ["true¦bIcEeuropeCfloreBgenoa,mAnaples,p7r5sicily,t3v0;a0eroK;!t0;!ican city;aran4rieste,u0;rin,scany;mt,om0;a4e;a1ra0;to;dova,lermo,ris;adrid,essiAil6;nce;! central,/0;san_marino,vatic3;atan5e1o0;penhagen,rsica;ntral europe0st,t;an;ari,olog2r0;esc0ussels;ia;na", "Central European", "n", "eu2"], "Samara": ["true¦europe,izhevsk,s0togliatti on the volga;am0yzran;ara,t", "Samara", "n"], "Saratov": ["true¦balakovo,europe,izhevsk,sa0;m0ratov;ara,t", "Samara", "n"], "Sofia": ["true¦b2e0imt,plovdiv,sof4varna;astern european,et,urope0;! eastern;g2u0;lgar0rgas;ia;!r", "Eastern European", "n", "eu3"], "Stockholm": ["true¦brussels,c5europe4goeteborg,ma3paris,romance,s0;e1tockholm,we0;!d4;!t;drid,lmoe;! central;e1openhag0;en;ntral european,st,t", "Central European", "n", "eu2"], "Tallinn": ["true¦e0tallinn;astern european,e2st1urope0;! eastern;!onia;!t", "Eastern European", "n", "eu3"], "Tirane": ["true¦al4brussels,c2europe1madrid,paris,romance,tiran0;a,e;! central;e0openhagen;ntral european,st,t;!b0;!ania", "Central European", "n", "eu2"], "Ulyanovsk": ["true¦europe,m0russian,st petersburg,ulyanovsk,volgograd 2;oscow0sk;! 0;time", "Moscow", "n"], "Uzhgorod": ["true¦e0ruthenia,uzhgorod;astern european,et,urope0;! eastern", "Eastern European", "n", "eu3"], "Vienna": ["true¦a4brussels,c1donaustadt,europe0favorit2graz,linz,madrid,paris,romance,vienna;! central;e1openhag0;en;ntral european,st,t;t,u0;stria,t", "Central European", "n", "eu2"], "Vilnius": ["true¦e3k2l0vilnius;ithuania,t0;!u;aunas,laipeda;astern european,et,urope0;! eastern", "Eastern European", "n", "eu3"], "Volgograd": ["true¦europe,m2russian,st petersburg,vol0;gograd0t,zhskiy;! time;oscow,sk", "Moscow", "n"], "Warsaw": ["true¦bKcHeuropeGgCkAl8m7p4r3s2torun,w0zabrze;ars0rocl0;aw;osnowiec,zczec6;adIomanA;aris,l,o0raga poludnie;l0znD;!and;adrid,okot3;odz,ubl0;in;ato2iel3rak0;ow;d2li0;wi0;ce;ansk,ynia;! central;e0openhagen,zestochowa;ntral europe0st,t;an;i2russels,y0;dgoszcz,t0;om;alystok,elsko biala", "Central European", "n", "eu2"], "Zaporozhye": ["true¦e3luhansk2sevastopol,zapor0;izhia lugansk,ozh0;'ye,ye;! east;astern european,et,urope0;! eastern", "Eastern European", "n", "eu3"], "Zurich": ["true¦brussels,c4europe2geneve,li0madrid,paris,romance,swiss time,zurich;!e0;!chtenstein;! central,/0;busin1vaduz;e1openha0;gen;ntral european,st,t", "Central European", "n", "eu2"] }, "Indian": { "Chagos": ["true¦british indian ocean territory,c4i0;ndian1o0;!t;! 0;c0ocean;hagos", "Indian Ocean", "n"], "Christmas": ["true¦c0indian;hristmas1x0;!r,t;! island", "Christmas Island", "s"], "Cocos": ["true¦c0indian;c2ocos0;! island0;!s;!k,t", "Cocos Islands", "n"], "Kerguelen": ["true¦a5french southern2indian,kerguelen1tf0;!t;!st paul4;! 0;& antarctic time,and antarctic0;! lands;msterdam0tf; island", "French Southern & Antarctic", "s"], "Mahe": ["true¦indian,mahe,s0;c0eychelles,yc;!t", "Seychelles", "n"], "Maldives": ["true¦indian,m0;aldives,dv,v0;!t", "Maldives", "n"], "Mauritius": ["true¦indian,m0port louis;auritius,u0;!s,t", "Mauritius", "n"], "Reunion": ["true¦indian,r0;e0éu1;t,u0;nion", "Réunion", "s"] }, "Pacific": { "Apia": ["true¦apia,pacific,s2w0;est s1s0;!m,t;amoa", "West Samoa", "s"], "Auckland": ["true¦a2christchurch,manukau,n0pacific,wellington;ew zea2orth shore,z0;!dt,l,mt,st,t;ntarctica/1uck0;land;mcmurdo,south_pole", "New Zealand", "s", "nz"], "Bougainville": ["true¦bougainville,guinea2p0;a0gt;cific,pua new guinea;!n", "Papua New Guinea", "s"], "Chatham": ["true¦cha0nz-chat,pacific;dt,st,t0;!ham0;! 0;islands,time", "Chatham", "s", "chat"], "Chuuk": ["true¦chu2pacific0;!/0;truk,y2;t,uk0;!/truky0;ap", "Chuuk", "n"], "Easter": ["true¦chile/easter4e0pacific;as0mt;st,t0;!er0;! 0;island", "Easter Island", "s", "east"], "Efate": ["true¦efate,pacific,v0;anuatu,u0;!t", "Vanuatu", "n"], "Fakaofo": ["true¦fakaofo,pacific,t0;k0okelau;!l,t", "Tokelau", "n"], "Fiji": ["true¦f0pacific;iji,j0;!i,st,t", "Fiji", "s", "fiji"], "Funafuti": ["true¦funafuti,pacific,t0;uv1v0;!t;!alu", "Tuvalu", "n"], "Galapagos": ["true¦co1gal0pacific;apagos,t,ápagos islands;lombia,st,t", "Colombia", "n"], "Gambier": ["true¦gam0pacific;bier0t;! islands", "Gambier", "n"], "Guadalcanal": ["true¦guadalcanal,pacific,s0;b1lb,olomon0;! islands;!t", "Solomon Islands", "n"], "Guam": ["true¦ch5guam,m4northern mariana islands,p2west0; 0ern 0;pacific;acific0ort moresby;!/saipan;np,p;amorro,st", "Chamorro", "n"], "Honolulu": ["true¦aleutian4h1pacific0us/hawaii;!/johnston;a0onolulu,st;dt,st,t,waii0;! aleutian;! islands", "Hawaii-Aleutian", "n"], "Kanton": ["true¦kanton,p0;acific1ho0;enix islands,t;!/enderbury", "Phoenix Islands", "n"], "Kiritimati": ["true¦ki1lin0pacific;e islands,t;!r0;!i0;bati,timati0;! island", "Line Islands", "n"], "Kosrae": ["true¦kos0pacific;rae,t", "Kosrae", "n"], "Kwajalein": ["true¦kwajalein,m0pacific;arshall islands,ht", "Marshall Islands", "n"], "Majuro": ["true¦m0pacific;a1h0;!l,t;juro,rshall islands", "Marshall Islands", "n"], "Marquesas": ["true¦mar0pacific;quesas0t;! islands", "Marquesas", "n"], "Nauru": ["true¦n0pacific;auru,r0;!t,u", "Nauru", "n"], "Niue": ["true¦n0pacific;iu1u0;!t;!e", "Niue", "n"], "Norfolk": ["true¦n0pacific;f1orfolk0;! island;!dt,k,t", "Norfolk Island", "n", "aus"], "Noumea": ["true¦n0pacific;c0ew caledonia,oumea;!l,t", "New Caledonia", "n"], "Pago_Pago": ["true¦m5pa1s0us/sa4;a3st;cific0go_pago;!/0;m1sa0;moa;idway", "Samoa", "n"], "Palau": ["true¦p0;a1lw,w0;!t;cific,lau", "Palau", "n"], "Pitcairn": ["true¦p0;acific,cn,itcairn,n,st", "Pitcairn", "n"], "Pohnpei": ["true¦french polynesia,p0;acific1f,o0yf;hnpei0nt;!/ponape", "Ponape", "n"], "Port_Moresby": ["true¦antarctica/dumontd6dumont-d'6guinea5p0;a3g2ng,ort0; 0_0;moresby;!t;cific,pua new guinea;!n;urville", "Papua New Guinea", "s"], "Rarotonga": ["true¦c0pacific,rarotonga;k2o0;k,ok0;! islands;!t", "Cook Islands", "n"], "Tahiti": ["true¦pacific,society islands,tah0;iti,t", "Tahiti", "n"], "Tarawa": ["true¦gil0pacific,tarawa;bert islands,t", "Gilbert Islands", "n"], "Tongatapu": ["true¦nuku'alofa,pacific,to0;!n0t;!ga0;!tapu", "Tonga", "s"], "Wake": ["true¦pacific,u2wak0;e0t;! island;m0s minor outlying islands;!i", "Wake Island", "n"], "Wallis": ["true¦pacific,w0;allis1f0lf;!t;! 0;&0and0; futuna", "Wallis & Futuna", "n"] } }; +var misc = { + "gmt+0": ["Etc/GMT"], + "gmt-0": ["Etc/GMT"], + gmt0: ["Etc/GMT"], + "etc/gmt+0": ["Etc/GMT"], + "etc/gmt-0": ["Etc/GMT"], + "etc/gmt0": ["Etc/GMT"], + "msk+00": ["Europe/Moscow"], + "msk-01 - kaliningrad": ["Europe/Kaliningrad"], + "msk+00 - moscow area": ["Europe/Moscow"], + "msk+00 - crimea": ["Europe/Kiev"], + "msk+00 - volgograd": ["Europe/Volgograd"], + "msk+00 - kirov": ["Europe/Kirov"], + "msk+01 - astrakhan": ["Europe/Astrakhan"], + "msk+01 - saratov": ["Europe/Saratov"], + "msk+01 - ulyanovsk": ["Europe/Ulyanovsk"], + "msk+01 - samaraudmurtia": ["Europe/Samara"], + "msk+02 - urals": ["Asia/Yekaterinburg"], + "msk+03": ["Asia/Omsk"], + "msk+04 - novosibirsk": ["Asia/Novosibirsk"], + "msk+04 - altai": ["Asia/Barnaul"], + "msk+04": ["Asia/Tomsk"], + "msk+04 - kemerovo": ["Asia/Novokuznetsk"], + "msk+04 - krasnoyarsk area": ["Asia/Krasnoyarsk"], + "msk+05 - irkutskburyatia": ["Asia/Irkutsk"], + "msk+06 - zabaykalsky": ["Asia/Chita"], + "msk+06 - lena river": ["Asia/Yakutsk"], + "msk+06 - tomponskyust-maysky": ["Asia/Khandyga"], + "msk+07 - amur river": ["Asia/Vladivostok"], + "msk+07 - oymyakonsky": ["Asia/Ust-Nera"], + "msk+08 - magadan": ["Asia/Magadan"], + "msk+08 - sakhalin island": ["Asia/Sakhalin"], + "msk+08 - sakha (e) north kuril is": ["Asia/Srednekolymsk"], + "msk+09": ["Asia/Kamchatka"], + "msk+09 - bering sea": ["Asia/Anadyr"], + "russia time zone 11": ["Asia/Anadyr"], + "russia time zone 10": ["Asia/Srednekolymsk"], + "russia time zone 3": ["Europe/Samara"], + "coordinated universal time-09": ["Pacific/Gambier"], + "utc-09": ["Pacific/Gambier"], + "coordinated universal time-08": ["Pacific/Pitcairn"] +}; +const addEtc = function(zones2) { + for (let i = 0; i <= 14; i += 1) { + zones2[`Etc/GMT-${i}`] = { + offset: i, + meta: `gmt-${i}`, + hem: "n" + //sorry + }; + zones2[`Etc/GMT+${i}`] = { + offset: i * -1, + meta: `gmt+${i}`, + hem: "n" + //sorry + }; + } +}; +var addUTC = addEtc; +let zones = {}; +let lexicon = Object.assign({}, misc); +Object.keys(pcked).forEach((top) => { + Object.keys(pcked[top]).forEach((name2) => { + let [words, meta, hem, dst] = pcked[top][name2]; + let id = `${top}/${name2}`; + zones[id] = { meta, hem }; + let keys = Object.keys(unpack$1(words)); + keys.forEach((k) => { + lexicon[k] = lexicon[k] || []; + lexicon[k].push(id); + if (k.match(/\//)) { + let arr = k.split(/\//); + let last = arr[arr.length - 1].toLowerCase(); + lexicon[last] = lexicon[last] || []; + lexicon[last].push(id); + } + }); + zones[id].wordCount = keys.length; + if (dst) { + zones[id].dst = dstPatterns[dst].split(/\|/); + } + }); +}); +addUTC(zones); +const unique = function(arr) { + let obj = {}; + for (let i = 0; i < arr.length; i += 1) { + obj[arr[i]] = true; + } + return Object.keys(obj); +}; +Object.keys(lexicon).forEach((k) => { + if (lexicon[k].length > 1) { + lexicon[k] = unique(lexicon[k]); + lexicon[k] = lexicon[k].sort((a, b) => { + if (zones[a].wordCount > zones[b].wordCount) { + return -1; + } else if (zones[a].wordCount < zones[b].wordCount) { + return 1; + } + return 0; + }); + } +}); +const one = (str) => { + str = str.toLowerCase(); + str = str.replace(/^in /g, ""); + str = str.replace(/ time/g, ""); + str = str.replace(/ (standard|daylight|summer)/g, ""); + str = str.replace(/ - .*/g, ""); + str = str.replace(/, .*/g, ""); + str = str.replace(/\./g, ""); + return str.trim(); +}; +const two = function(str) { + str = str.replace(/\b(east|west|north|south)ern/g, "$1"); + str = str.replace(/\b(africa|america|australia)n/g, "$1"); + str = str.replace(/\beuropean/g, "europe"); + str = str.replace(/\islands/g, "island"); + str = str.replace(/.*\//g, ""); + return str.trim(); +}; +const three = function(str) { + str = str.replace(/\(.*\)/, ""); + str = str.replace(/ +/g, " "); + return str.trim(); +}; +var normalize = { one, two, three }; +const isOffset = /^([-+]?[0-9]+)h(r?s)?$/i; +const isNumber = /^([-+]?[0-9]+)$/; +const utcOffset = /utc([\-+]?[0-9]+)$/i; +const gmtOffset = /gmt([\-+]?[0-9]+)$/i; +const toIana = function(num) { + num = Number(num); + if (num > -13 && num < 13) { + num = num * -1; + num = (num > 0 ? "+" : "") + num; + return "Etc/GMT" + num; + } + return null; +}; +const parseOffset = function(tz) { + let m = tz.match(isOffset); + if (m !== null) { + return toIana(m[1]); + } + m = tz.match(utcOffset); + if (m !== null) { + return toIana(m[1]); + } + m = tz.match(gmtOffset); + if (m !== null) { + let num = Number(m[1]) * -1; + return toIana(num); + } + m = tz.match(isNumber); + if (m !== null) { + return toIana(m[1]); + } + return null; +}; +var parseOffset$1 = parseOffset; +const find = function(str) { + if (zones.hasOwnProperty(str)) { + return str; + } + if (lexicon.hasOwnProperty(str)) { + return lexicon[str]; + } + if (/[0-9]/.test(str)) { + let etc = parseOffset$1(str); + if (etc) { + return [etc]; + } + } + str = normalize.one(str); + if (lexicon.hasOwnProperty(str)) { + return lexicon[str]; + } + str = normalize.two(str); + if (lexicon.hasOwnProperty(str)) { + return lexicon[str]; + } + str = normalize.three(str); + if (lexicon.hasOwnProperty(str)) { + return lexicon[str]; + } + return null; +}; +var find$1 = find; +var metas = { + "India": { + "std": ["IST", 5.5], + "long": "(UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi" + }, + "China": { + "std": ["CST", 8], + "long": "(UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi" + }, + "Central European": { + "std": ["CET", 1], + "dst": ["CEST", 2, "Central European Summer Time"], + "long": "(UTC+01:00) Brussels, Copenhagen, Madrid, Paris" + }, + "Atlantic": { + "dupe": true, + "std": ["AST", -4], + "dst": ["ADT", -3], + "long": "(UTC-04:00) Atlantic Time (Canada)" + }, + "Greenwich Mean": { + "std": ["GMT", 0], + "long": "(UTC) Coordinated Universal Time" + }, + "Eastern European": { + "std": ["EET", 2], + "dst": [ + "EEST", + 3, + "Eastern European Summer Time" + ] + }, + "Central": { + "dupe": true, + "std": ["CST", -6], + "dst": ["CDT", -5], + "long": "(UTC-06:00) Central Time (US & Canada)" + }, + "Eastern": { + "std": ["EST", -5], + "dst": ["EDT", -4], + "long": "(UTC-05:00) Eastern Time (US & Canada)" + }, + "Argentina": { + "std": ["ART", -3], + "long": "(UTC-03:00) City of Buenos Aires" + }, + "East Africa": { + "std": ["EAT", 3], + "long": "(UTC+03:00) Nairobi" + }, + "West Africa": { + "std": ["WAT", 1], + "long": "(UTC+01:00) West Central Africa" + }, + "Moscow": { + "std": ["MSK", 3], + "long": "(UTC+03:00) Moscow, St. Petersburg" + }, + "Brasilia": { + "std": ["BRT", -3], + "long": "(UTC-03:00) Brasilia" + }, + "Mountain": { + "std": ["MST", -7], + "dst": ["MDT", -6], + "long": "(UTC-07:00) Mountain Time (US & Canada)" + }, + "Central Africa": { + "std": ["CAT", 2], + "long": "(UTC+02:00) Windhoek" + }, + "Arabian": { + "std": ["AST", 3], + "long": "(UTC+03:00) Kuwait, Riyadh" + }, + "Alaska": { + "std": ["AKST", -9], + "dst": ["AKDT", -8], + "long": "(UTC-09:00) Alaska" + }, + "British": { + "std": ["GMT", 0], + "dst": ["BST", 1, "British Summer Time"], + "long": "(UTC+00:00) Dublin, Edinburgh, Lisbon, London" + }, + "Irish": { + "std": ["GMT", 0], + "dst": ["IST", 1, "Irish Standard Time"] + }, + "West Kazakhstan": { + "std": ["ALMT", 5], + "long": "(UTC+05:00) Ashgabat, Tashkent" + }, + "Eastern Australia": { + "std": ["AEST", 10], + "dst": ["AEDT", 11, "Australian Eastern Daylight Time"], + "long": "(UTC+10:00) Canberra, Melbourne, Sydney" + }, + "Western European": { + "std": ["WET", 0], + "dst": ["WEST", 1, "Western European Summer Time"] + }, + "Indochina": { + "std": ["ICT", 7], + "long": "(UTC+07:00) Bangkok, Hanoi, Jakarta" + }, + "Central Mexico": { + "long": "(UTC-06:00) Guadalajara, Mexico City, Monterrey", + "std": ["CST", -6], + "dst": [ + "CDT", + -5, + "Central Daylight Time" + ] + }, + "South Africa": { + "std": ["SAST", 2], + "long": "(UTC+02:00) Harare, Pretoria" + }, + "Krasnoyarsk": { + "std": ["KRAT", 7], + "long": "(UTC+07:00) Krasnoyarsk" + }, + "Yakutsk": { + "std": ["YAKT", 9], + "long": "(UTC+09:00) Yakutsk" + }, + "Pacific": { + "std": ["PST", -8], + "dst": ["PDT", -7], + "long": "(UTC-08:00) Pacific Time (US & Canada)" + }, + "Amazon": { + "std": ["AMT", -4], + "long": "(UTC-04:00) Cuiaba" + }, + "Morocco Standard": { + "offset": 1, + "long": "(UTC+00:00) Casablanca", + "std": ["WET", 1], + "dst": [ + "WEST", + 0, + "Western European Summer Time" + ] + }, + "Gulf": { + "std": ["GST", 4], + "long": "(UTC+04:00) Abu Dhabi, Muscat" + }, + "Samara": { + "std": ["SAMT", 4], + "long": "(UTC+04:00) Izhevsk, Samara" + }, + "Uzbekistan": { + "std": ["UZT", 5] + }, + "East Kazakhstan": { + "std": ["ALMT", 6], + "long": "(UTC+06:00) Astana" + }, + "Omsk": { + "std": ["OMST", 6], + "long": "(UTC+06:00) Omsk" + }, + "Western Indonesia": { + "std": ["WIB", 7] + }, + "Ulaanbaatar": { + "std": ["ULAT", 8], + "long": "(UTC+08:00) Ulaanbaatar" + }, + "Malaysia": { + "std": ["MYT", 8] + }, + "Korean": { + "std": ["KST", 9], + "long": "(UTC+09:00) Seoul" + }, + "Central Australia": { + "std": ["ACST", 9.5], + "dst": ["ACDT", 10.5, "Australian Central Daylight Time"], + "long": "(UTC+09:30) Adelaide" + }, + "Brisbane": { + "dupe": true, + "std": ["AEST", 10] + }, + "Vladivostok": { + "std": ["VLAT", 10], + "long": "(UTC+10:00) Vladivostok" + }, + "Chamorro": { + "std": ["ChST", 10], + "long": "(UTC+10:00) Guam, Port Moresby" + }, + "Papua New Guinea": { + "std": ["PGT", 11] + }, + "New Zealand": { + "std": ["NZST", 12], + "dst": ["NZDT", 13], + "long": "(UTC+12:00) Auckland, Wellington" + }, + "Marshall Islands": { + "std": ["MHT", 12] + }, + "Samoa": { + "std": ["SST", -11], + "long": "(UTC+13:00) Samoa" + }, + "Hawaii-Aleutian": { + "std": ["HAST", -9], + "dst": ["HADT", -8], + "long": "(UTC-09:00) Aleutian Islands" + }, + "Mexican Pacific": { + "std": ["HNPMX", -7], + "dst": ["HEPMX", -6], + "long": "(UTC-07:00) Chihuahua, La Paz, Mazatlan" + }, + "Colombia": { + "std": ["COT", -5] + }, + "Acre": { + "std": ["ACT", -5] + }, + "Chile": { + "dupe": true, + "std": ["CLT", -3], + "dst": [ + "CLST", + -4, + "Chile Summer Time" + ] + }, + "Troll": { + "dupe": true, + "std": ["GMT", 0] + }, + "East Greenland": { + "std": ["HNEG", 0], + "dst": [ + "HEEG", + 1, + "East Greenland Summer Time" + ] + }, + "Israel": { + "std": ["IST", 2], + "dst": ["IDT", 3], + "long": "(UTC+02:00) Jerusalem" + }, + "Syowa": { + "std": ["SYOT", 3] + }, + "Turkey": { + "std": ["TRT", 3], + "long": "(UTC+03:00) Istanbul" + }, + "Iran": { + "std": ["IRST", 3.5], + "dst": ["IRDT", 4.5], + "long": "(UTC+03:30) Tehran" + }, + "Azerbaijan": { + "std": ["AZT", 4], + "long": "(UTC+04:00) Baku" + }, + "Georgia": { + "std": ["GET", 4], + "long": "(UTC+04:00) Tbilisi" + }, + "Armenia": { + "std": ["AMT", 4], + "long": "(UTC+04:00) Yerevan" + }, + "Seychelles": { + "std": ["SCT", 4] + }, + "Mauritius": { + "std": ["MUT", 4], + "long": "(UTC+04:00) Port Louis" + }, + "Réunion": { + "std": ["RET", 4] + }, + "Afghanistan": { + "std": ["AFT", 4.5], + "long": "(UTC+04:30) Kabul" + }, + "Mawson": { + "std": ["MAWT", 5] + }, + "Turkmenistan": { + "std": ["TMT", 5] + }, + "Tajikistan": { + "std": ["TJT", 5] + }, + "Pakistan": { + "std": ["PKT", 5], + "long": "(UTC+05:00) Islamabad, Karachi" + }, + "Yekaterinburg": { + "std": ["YEKT", 5], + "long": "(UTC+05:00) Ekaterinburg" + }, + "French Southern & Antarctic": { + "std": ["TFT", 5] + }, + "Maldives": { + "std": ["MVT", 5] + }, + "Nepal": { + "std": ["NPT", 5.75], + "long": "(UTC+05:45) Kathmandu" + }, + "Vostok": { + "std": ["MSK+4", 6] + }, + "Kyrgyzstan": { + "std": ["KGT", 6] + }, + "Bangladesh": { + "std": ["BST", 6], + "long": "(UTC+06:00) Dhaka" + }, + "Bhutan": { + "std": ["BT", 6] + }, + "Indian Ocean": { + "std": ["IOT", 6] + }, + "Myanmar": { + "std": ["MMT", 6.5], + "long": "(UTC+06:30) Yangon (Rangoon)" + }, + "Cocos Islands": { + "std": ["CCT", 6.5] + }, + "Davis": { + "std": ["DAVT", 7] + }, + "Hovd": { + "std": ["HOVT", 7], + "long": "(UTC+07:00) Hovd" + }, + "Novosibirsk": { + "std": ["NOVT", 7], + "long": "(UTC+07:00) Novosibirsk" + }, + "Christmas Island": { + "std": ["CXT", 7] + }, + "Brunei Darussalam": { + "std": ["BNT", 8] + }, + "Hong Kong": { + "std": ["HKT", 8] + }, + "Irkutsk": { + "std": ["IRKT", 8], + "long": "(UTC+08:00) Irkutsk" + }, + "Central Indonesia": { + "std": ["WITA", 8] + }, + "Philippine": { + "std": ["PHST", 8] + }, + "Singapore": { + "std": ["SGT", 8], + "long": "(UTC+08:00) Kuala Lumpur, Singapore" + }, + "Taipei": { + "std": ["CST", 8], + "long": "(UTC+08:00) Taipei" + }, + "Western Australia": { + "std": ["AWST", 8], + "long": "(UTC+08:00) Perth" + }, + "Australian Central Western": { + "std": ["ACWST", 8.75], + "long": "(UTC+08:45) Eucla" + }, + "East Timor": { + "std": ["TLT", 9] + }, + "Eastern Indonesia": { + "std": ["WIT", 9] + }, + "Japan": { + "std": ["JST", 9], + "long": "(UTC+09:00) Osaka, Sapporo, Tokyo" + }, + "Palau": { + "std": ["PWT", 9] + }, + "Australian Central": { + "dupe": true, + "std": ["ACST", 9.5] + }, + "Dumont-d’Urville": { + "std": ["CLST", 10] + }, + "Chuuk": { + "std": ["CHUT", 10] + }, + "Lord Howe": { + "std": ["LHST", 10.5], + "dst": ["LHDT", 11.5], + "long": "(UTC+10:30) Lord Howe Island" + }, + "Casey": { + "std": ["CAST", 11], + "dst": [ + "CAST", + 8, + "Casey Summer Time" + ] + }, + "Magadan": { + "std": ["MAGT", 11], + "long": "(UTC+11:00) Magadan" + }, + "Sakhalin": { + "std": ["SAKT", 11], + "long": "(UTC+11:00) Sakhalin" + }, + "Srednekolymsk": { + "std": ["SRET", 11], + "long": "(UTC+11:00) Chokurdakh" + }, + "Vanuatu": { + "std": ["VUT", 11] + }, + "Solomon Islands": { + "std": ["SBT", 11] + }, + "Kosrae": { + "std": ["KOST", 11] + }, + "New Caledonia": { + "std": ["NCT", 11] + }, + "Ponape": { + "std": ["PONT", 11] + }, + "Anadyr": { + "std": ["ANAT", 12], + "long": "(UTC+12:00) Anadyr, Petropavlovsk-Kamchatsky" + }, + "Petropavlovsk-Kamchatski": { + "std": ["PETT", 12], + "long": "(UTC+12:00) Anadyr, Petropavlovsk-Kamchatsky" + }, + "Fiji": { + "std": ["FJT", 12], + "dst": ["FJT", 13, "Fiji Summer Time"], + "long": "(UTC+12:00) Fiji" + }, + "Tuvalu": { + "std": ["TVT", 12] + }, + "Nauru": { + "std": ["NRT", 12] + }, + "Norfolk Island": { + "std": ["NFT", 12], + "dst": ["NFDT", 11], + "long": "(UTC+11:00) Norfolk Island" + }, + "Gilbert Islands": { + "std": ["GILT", 12] + }, + "Wake Island": { + "std": ["WAKT", 12] + }, + "Wallis & Futuna": { + "std": ["WFT", 12] + }, + "Chatham": { + "std": ["CHAST", 12.75], + "dst": ["CHADT", 13.75], + "long": "(UTC+12:45) Chatham Islands" + }, + "West Samoa": { + "std": ["WST", 13], + "dst": [ + "WST", + 14, + "West Samoa Summer Time" + ] + }, + "Phoenix Islands": { + "std": ["PHOT", 13] + }, + "Tokelau": { + "std": ["TKT", 13] + }, + "Tonga": { + "std": ["TOT", 13], + "long": "(UTC+13:00) Nuku'alofa" + }, + "Line Islands": { + "std": ["LINT", 14], + "long": "(UTC+14:00) Kiritimati Island" + }, + "Niue": { + "std": ["NUT", -11] + }, + "Cook Islands": { + "std": ["CKT", -10] + }, + "Tahiti": { + "std": ["TAHT", -10] + }, + "Marquesas": { + "std": ["MART", -9.5], + "long": "(UTC-09:30) Marquesas Islands" + }, + "Aleutian Standard": { + "iso": "(UTC-10:00) Aleutian Islands", + "std": ["HST", -10], + "dst": [ + "HDT", + -9, + "Hawaii Daylight Time" + ] + }, + "Gambier": { + "std": ["GAMT", -9], + "long": "(UTC-09:00) Coordinated Universal Time-09" + }, + "Pitcairn": { + "std": ["PST", -8], + "long": "(UTC-08:00) Coordinated Universal Time-08" + }, + "Northwest Mexico": { + "std": ["HNNOMX", -6], + "dst": ["HENOMX", -5], + "long": "(UTC-08:00) Baja California" + }, + "Easter Island": { + "std": ["EAST", -6], + "dst": ["EASST", -5, "Easter Island Summer Time"], + "long": "(UTC-06:00) Easter Island" + }, + "Ecuador": { + "std": ["ECT", -5] + }, + "Cuba": { + "std": ["HNCU", -5], + "dst": ["HECU", -4], + "long": "(UTC-05:00) Havana" + }, + "Peru": { + "std": ["PET", -5] + }, + "Paraguay": { + "std": ["PYT", -4], + "dst": ["PYST", -3, "Paraguay Summer Time"], + "long": "(UTC-04:00) Asuncion" + }, + "Venezuela": { + "std": ["VET", -4], + "long": "(UTC-04:00) Caracas" + }, + "Guyana": { + "std": ["GYT", -4] + }, + "Bolivia": { + "std": ["BOT", -4] + }, + "Newfoundland": { + "std": ["HNTN", -3.5], + "dst": ["HETN", -2.5], + "long": "(UTC-03:30) Newfoundland" + }, + "French Guiana": { + "std": ["GFT", -3] + }, + "West Greenland": { + "std": ["WGT", -3], + "dst": ["WGST", -2, "West Greenland Summer Time"], + "long": "(UTC-03:00) Greenland" + }, + "St. Pierre & Miquelon": { + "std": ["HNPM", -3], + "dst": ["HEPM", -2], + "long": "(UTC-03:00) Saint Pierre and Miquelon" + }, + "Uruguay": { + "std": ["UYT", -3], + "long": "(UTC-03:00) Montevideo" + }, + "Suriname": { + "std": ["SRT", -3] + }, + "Falkland Islands": { + "std": ["FKST", -3] + }, + "Fernando de Noronha": { + "std": ["FNT", -2] + }, + "South Georgia": { + "std": ["GST", -2] + }, + "Azores": { + "std": ["AZOT", -1], + "dst": ["AZOST", 0, "Azores Summer Time"], + "long": "(UTC-01:00) Azores" + }, + "Cape Verde": { + "std": ["CVT", -1], + "long": "(UTC-01:00) Cabo Verde Is." + } +}; +for (let i = 0; i <= 14; i += 1) { + metas[`gmt-${i}`] = { + name: `Etc/GMT-${i}`, + std: [`GMT-${i}`, i], + long: `(UTC-${i}:00) Coordinated Universal Time` + }; + metas[`gmt+${i}`] = { + name: `Etc/GMT+${i}`, + std: [`GMT+${i}`, -i], + long: `(UTC+${i}:00) Coordinated Universal Time` + }; +} +const display = function(id) { + if (!id) { + return null; + } + if (!zones[id]) { + console.error(`missing id ${id}`); + return null; + } + let metaName = zones[id].meta; + if (!metas[metaName]) { + console.error(`missing tz-meta ${metaName}`); + } + let meta = metas[metaName] || {}; + let dst = null; + if (zones[id].dst && meta.dst) { + let [abbr2, offset2, name3] = meta.dst; + name3 = name3 || `${metaName} Daylight Time`; + let [start, end] = zones[id].dst || []; + dst = { abbr: abbr2, offset: offset2, name: name3, start, end }; + } + let [abbr, offset] = meta.std; + let name2 = meta.name || `${metaName} Time`; + let long2 = meta.long || `(UTC+${offset}:00) ${name2}`; + return { + name: name2, + iana: id, + standard: { abbr, offset, name: meta.name || `${metaName} Standard Time` }, + daylight: dst || null, + long: long2 + }; +}; +var display$1 = display; +var version$2 = "1.5.2"; +const soft = function(str) { + let ids = find$1(str) || []; + if (typeof ids === "string") { + ids = [ids]; + } + ids = ids.map((id) => display$1(id)); + return ids; +}; +soft.prototype.version = version$2; +function moodToStars(mood) { + return "★".repeat(mood) + "☆".repeat(10 - mood); +} +function getTimezone(req) { + try { + const tz = soft(req)[0].iana; + if (timezones$1[tz] === void 0) { + throw new Error("Valid timezone, but not supported by Lifetracker. Add it to the timezones list in the shared utils or try a different request."); + } + return tz; + } catch (e) { + throw new Error("Invalid timezone..." + e); + } +} +const daysCmd = new Command2().name("day").description("Get data for a specific day").argument("[date]", 'A date in ISO-8601 format, or "yesterday", "today", "tomorrow", etc.', "today").option("-c, --comment ", "edit this day's comment").option("-m, --mood ", "edit this day's mood").option("-h, --hour ", "manipulate a specific hour (