From b78af8f718d03b38e49a2ad9a38b081963c03cdd Mon Sep 17 00:00:00 2001 From: Eugen Hildt Date: Thu, 19 Mar 2026 11:27:54 +0100 Subject: [PATCH] 0026: replaced outdated packages --- .changeset/busy-baboons-crash.md | 5 + .depcruise.mjs | 2 +- .wiki/status-badges/codecov-badges.md | 24 +- .wiki/status-badges/docker-badges.md | 32 +- .wiki/status-badges/github-badges.md | 42 +- .wiki/status-badges/socket-badges.md | 12 +- .wiki/status-badges/tile-badges.md | 20 +- AGENTS.md | 148 +- README.md | 3 - depbadgerc.yml | 16 +- dist/index.mjs | 19335 ++++++++-------- package.json | 4 +- pnpm-lock.yaml | 53 +- .../compute-state-integrity.spec.ts | 4 +- src/depbadgerc/compute-state-integrity.ts | 4 +- .../read-depbadgerc-with-defaults.spec.ts | 4 +- .../read-depbadgerc-with-defaults.ts | 37 +- src/shared/hash-string-to-hex.ts | 3 +- src/shared/resolve-yaml-merge-key.spec.ts | 79 + src/shared/resolve-yaml-merge-key.ts | 26 + 20 files changed, 9642 insertions(+), 10211 deletions(-) create mode 100644 .changeset/busy-baboons-crash.md create mode 100644 src/shared/resolve-yaml-merge-key.spec.ts create mode 100644 src/shared/resolve-yaml-merge-key.ts diff --git a/.changeset/busy-baboons-crash.md b/.changeset/busy-baboons-crash.md new file mode 100644 index 0000000..b64926a --- /dev/null +++ b/.changeset/busy-baboons-crash.md @@ -0,0 +1,5 @@ +--- +"@ehildt/depbadge": minor +--- + +Replace js-yaml with yaml and yargs with native parseArgs, add resolveYamlMergeKey for YAML 1.1 merge key support diff --git a/.depcruise.mjs b/.depcruise.mjs index 567a5db..2adebf0 100755 --- a/.depcruise.mjs +++ b/.depcruise.mjs @@ -1,7 +1,7 @@ const WHITELIST = { noOrphans: [], notToDevDep: ["src/config.yml.loader.ts"], - notToUnresolvable: [], + notToUnresolvable: ["src/depbadgerc/read-depbadgerc-with-defaults.ts"], }; /** @type {import('dependency-cruiser').IConfiguration} */ diff --git a/.wiki/status-badges/codecov-badges.md b/.wiki/status-badges/codecov-badges.md index adfb920..606ea12 100644 --- a/.wiki/status-badges/codecov-badges.md +++ b/.wiki/status-badges/codecov-badges.md @@ -8,18 +8,18 @@ Display code coverage from Codecov using shields.io. ### Configuration -| Property | Type | Required | Description | -|----------|------|----------|-------------| -| `name` | string | Yes | Must be `"codecov"` | -| `user` | string | Yes | Codecov username or organization | -| `repo` | string | Yes | Repository name | -| `branch` | string | No | Branch name | -| `flag` | string | No | Specific coverage flag (e.g., `unit`, `integration`) | -| `token` | string | No | Codecov upload token (required for private repos) | -| `link` | string | No | Custom link URL | -| `style` | string | No | Badge style: `flat`, `flat-square`, `plastic`, `for-the-badge`, `social` | -| `color` | string | No | Badge color (hex or named color) | -| `labelColor` | string | No | Label background color | +| Property | Type | Required | Description | +| ------------ | ------ | -------- | ------------------------------------------------------------------------ | +| `name` | string | Yes | Must be `"codecov"` | +| `user` | string | Yes | Codecov username or organization | +| `repo` | string | Yes | Repository name | +| `branch` | string | No | Branch name | +| `flag` | string | No | Specific coverage flag (e.g., `unit`, `integration`) | +| `token` | string | No | Codecov upload token (required for private repos) | +| `link` | string | No | Custom link URL | +| `style` | string | No | Badge style: `flat`, `flat-square`, `plastic`, `for-the-badge`, `social` | +| `color` | string | No | Badge color (hex or named color) | +| `labelColor` | string | No | Label background color | ### Examples diff --git a/.wiki/status-badges/docker-badges.md b/.wiki/status-badges/docker-badges.md index 8379bcb..795c3a2 100644 --- a/.wiki/status-badges/docker-badges.md +++ b/.wiki/status-badges/docker-badges.md @@ -8,25 +8,25 @@ Display Docker Hub metrics using shields.io. ### Configuration -| Property | Type | Required | Description | -|----------|------|----------|-------------| -| `name` | string | Yes | Must be `"docker"` | -| `metric` | string | Yes | One of: `pulls`, `stars`, `v` | -| `user` | string | Yes | Docker Hub username or organization | -| `image` | string | Yes | Image name | -| `tag` | string | No | Image tag | -| `link` | string | No | Custom link URL | -| `style` | string | No | Badge style: `flat`, `flat-square`, `plastic`, `for-the-badge`, `social` | -| `color` | string | No | Badge color (hex or named color) | -| `labelColor` | string | No | Label background color | +| Property | Type | Required | Description | +| ------------ | ------ | -------- | ------------------------------------------------------------------------ | +| `name` | string | Yes | Must be `"docker"` | +| `metric` | string | Yes | One of: `pulls`, `stars`, `v` | +| `user` | string | Yes | Docker Hub username or organization | +| `image` | string | Yes | Image name | +| `tag` | string | No | Image tag | +| `link` | string | No | Custom link URL | +| `style` | string | No | Badge style: `flat`, `flat-square`, `plastic`, `for-the-badge`, `social` | +| `color` | string | No | Badge color (hex or named color) | +| `labelColor` | string | No | Label background color | ### Metrics -| Metric | Description | -|--------|-------------| -| `pulls` | Number of pulls | -| `stars` | Number of stars | -| `v` | Latest version/tag | +| Metric | Description | +| ------- | ------------------ | +| `pulls` | Number of pulls | +| `stars` | Number of stars | +| `v` | Latest version/tag | ### Examples diff --git a/.wiki/status-badges/github-badges.md b/.wiki/status-badges/github-badges.md index c1d6ecd..658b24a 100644 --- a/.wiki/status-badges/github-badges.md +++ b/.wiki/status-badges/github-badges.md @@ -8,30 +8,30 @@ Display GitHub metrics for repositories using shields.io. ### Configuration -| Property | Type | Required | Description | -|----------|------|----------|-------------| -| `name` | string | Yes | Must be `"github"` | -| `metric` | string | Yes | One of: `stars`, `license`, `release`, `issues`, `forks`, `watchers`, `actions` | -| `user` | string | Yes | GitHub username or organization | -| `repo` | string | Yes | Repository name | -| `branch` | string | No | Branch name | -| `workflow` | string | Conditional | Required when `metric` is `actions` | -| `link` | string | No | Custom link URL | -| `style` | string | No | Badge style: `flat`, `flat-square`, `plastic`, `for-the-badge`, `social` | -| `color` | string | No | Badge color (hex or named color) | -| `labelColor` | string | No | Label background color | +| Property | Type | Required | Description | +| ------------ | ------ | ----------- | ------------------------------------------------------------------------------- | +| `name` | string | Yes | Must be `"github"` | +| `metric` | string | Yes | One of: `stars`, `license`, `release`, `issues`, `forks`, `watchers`, `actions` | +| `user` | string | Yes | GitHub username or organization | +| `repo` | string | Yes | Repository name | +| `branch` | string | No | Branch name | +| `workflow` | string | Conditional | Required when `metric` is `actions` | +| `link` | string | No | Custom link URL | +| `style` | string | No | Badge style: `flat`, `flat-square`, `plastic`, `for-the-badge`, `social` | +| `color` | string | No | Badge color (hex or named color) | +| `labelColor` | string | No | Label background color | ### Metrics -| Metric | Description | -|--------|-------------| -| `stars` | Number of stars | -| `forks` | Number of forks | -| `issues` | Number of open issues | -| `watchers` | Number of watchers | -| `license` | Repository license | -| `release` | Latest release version | -| `actions` | Workflow status | +| Metric | Description | +| ---------- | ---------------------- | +| `stars` | Number of stars | +| `forks` | Number of forks | +| `issues` | Number of open issues | +| `watchers` | Number of watchers | +| `license` | Repository license | +| `release` | Latest release version | +| `actions` | Workflow status | ### Examples diff --git a/.wiki/status-badges/socket-badges.md b/.wiki/status-badges/socket-badges.md index 2fc13cb..3b5a25f 100644 --- a/.wiki/status-badges/socket-badges.md +++ b/.wiki/status-badges/socket-badges.md @@ -8,12 +8,12 @@ Display supply chain security scores from [Socket.dev](https://socket.dev/) for ### Configuration -| Property | Type | Required | Default | Description | -|----------|------|----------|---------|-------------| -| `name` | string | Yes | - | Must be `"socket"` | -| `package` | string | Yes | - | npm package name (e.g., `"express"`, `"@babel/core"`) | -| `version` | string | No | `"*"` | Package version or `"*"` for latest | -| `link` | string | No | npm package URL | Custom link URL | +| Property | Type | Required | Default | Description | +| --------- | ------ | -------- | --------------- | ----------------------------------------------------- | +| `name` | string | Yes | - | Must be `"socket"` | +| `package` | string | Yes | - | npm package name (e.g., `"express"`, `"@babel/core"`) | +| `version` | string | No | `"*"` | Package version or `"*"` for latest | +| `link` | string | No | npm package URL | Custom link URL | ### What the Badge Shows diff --git a/.wiki/status-badges/tile-badges.md b/.wiki/status-badges/tile-badges.md index f1c0cae..47acab3 100644 --- a/.wiki/status-badges/tile-badges.md +++ b/.wiki/status-badges/tile-badges.md @@ -8,16 +8,16 @@ Display custom static badges with arbitrary text using shields.io. ### Configuration -| Property | Type | Required | Description | -|----------|------|----------|-------------| -| `name` | string | Yes | Must be `"tile"` | -| `label` | string | Yes | Left side text | -| `message` | string | Yes | Right side text | -| `color` | string | No | Badge color (hex or named color like `brightgreen`, `orange`, `red`) | -| `labelColor` | string | No | Label background color | -| `isError` | boolean | No | Force error-style rendering | -| `link` | string | No | Custom link URL | -| `style` | string | No | Badge style: `flat`, `flat-square`, `plastic`, `for-the-badge`, `social` | +| Property | Type | Required | Description | +| ------------ | ------- | -------- | ------------------------------------------------------------------------ | +| `name` | string | Yes | Must be `"tile"` | +| `label` | string | Yes | Left side text | +| `message` | string | Yes | Right side text | +| `color` | string | No | Badge color (hex or named color like `brightgreen`, `orange`, `red`) | +| `labelColor` | string | No | Label background color | +| `isError` | boolean | No | Force error-style rendering | +| `link` | string | No | Custom link URL | +| `style` | string | No | Badge style: `flat`, `flat-square`, `plastic`, `for-the-badge`, `social` | ### Examples diff --git a/AGENTS.md b/AGENTS.md index 222ce6e..db95cf7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -8,11 +8,13 @@ This is a TypeScript project that generates shield.io badges from package manife ## Build Commands -| Command | Description | -| --------------------- | ---------------------------------------------------- | -| `pnpm install` | Install dependencies (use `--frozen-lockfile` in CI) | -| `pnpm build` | Build the project (runs tsup) | -| `pnpm prepublishOnly` | Build before publishing | +| Command | Description | +| --------------------- | ------------------------------------------------------------ | +| `pnpm install` | Install dependencies (use `--frozen-lockfile` in CI) | +| `pnpm prepare` | Set up husky hooks | +| `pnpm build` | Build the project (runs tsup, outputs to `dist/`) | +| `pnpm prepublishOnly` | Build before publishing | +| `pnpm depbadge` | Run the CLI tool (`rimraf .depbadge && node dist/index.mjs`) | ## Lint & Format Commands @@ -21,9 +23,14 @@ This is a TypeScript project that generates shield.io badges from package manife | `pnpm lint` | Run ESLint on `./src` | | `pnpm format` | Format all files with Prettier | | `pnpm depcruise` | Run dependency-cruiser analysis | +| `pnpm depcheck` | Check for unused dependencies | | `pnpm lint:unused` | Check for unused exports | | `pnpm lint-staged` | Run linters on staged files | +### Pre-commit Hook + +Husky runs `pnpm lint-staged` on commit. The pre-commit hook is in `.husky/_/pre-commit`. + ## Test Commands | Command | Description | @@ -34,12 +41,20 @@ This is a TypeScript project that generates shield.io badges from package manife ### Running a Single Test -Use vitest's filter option: +Use vitest's `--` filter option: ```bash +# By test name (partial match) pnpm test -- encodeLabel pnpm test -- "get-dependencies" +pnpm test -- "Status badge markdown mapping" + +# By file path pnpm test -- "src/shared/encode-label.spec.ts" +pnpm test -- "src/store/ctx-store.spec.ts" + +# By file name +pnpm test -- "ctx-store.spec.ts" ``` ## Code Style @@ -49,55 +64,70 @@ pnpm test -- "src/shared/encode-label.spec.ts" - Strict mode enabled (`strict: true` in tsconfig.json) - Module resolution: `nodenext` - Target: `esnext` -- No implicit `any` (but `any` is allowed with opt-out) +- No implicit `any` (but `any` is allowed with opt-out via `@ts-ignore` or `eslint-disable`) +- Build config: `tsconfig.build.json` (generates declarations, excludes spec files) ### Formatting (Prettier) -- Print width: 120 characters -- Single quotes: `true` -- Trailing commas: `all` -- Semicolons: `true` -- Use tabs: `false` -- End of line: `lf` -- Bracket spacing: `true` +| Option | Value | +| --------------- | ------- | +| Print width | 120 | +| Single quotes | `true` | +| Trailing commas | `all` | +| Semicolons | `true` | +| Use tabs | `false` | +| End of line | `lf` | +| Bracket spacing | `true` | ### ESLint Rules - `no-console`: warning (use `console.error` for errors in CLI) - `@typescript-eslint/no-unused-vars`: warn - `@typescript-eslint/no-floating-promises`: warn +- `@typescript-eslint/no-explicit-any`: off - `sonarjs/cognitive-complexity`: warn - `sonarjs/no-identical-expressions`: warn ### Import Sorting (simple-import-sort) -Order groups: +Order groups (strict): -1. `node:` imports -2. External packages (`@?\\w`) +1. `node:` imports (e.g., `node:fs`) +2. External packages (`@?\w`) 3. Internal packages (`@app`, `@modules`, `@services`) -4. Side-effect imports (`\\u0000`) -5. Parent imports (`\\.\\.(?!/?$)`, `\\.\\./?$`) +4. Side-effect imports (`\u0000`) +5. Parent imports (`\.\.(?!/?$)`, `\.\./?$`) 6. Relative imports (same directory) 7. Type imports 8. CSS/SCSS files ### Naming Conventions -- Files: kebab-case (e.g., `ctx-store.ts`, `get-version.ts`) -- Types/Interfaces: PascalCase with descriptive names -- Functions: camelCase, verb-prefixed (e.g., `getDependencies`, `useCtxStore`) -- Test files: `*.spec.ts` suffix +| Type | Convention | Example | +| ------------------ | -------------------------- | -------------------------------- | +| Files | kebab-case | `ctx-store.ts`, `get-version.ts` | +| Test files | `*.spec.ts` suffix | `encode-label.spec.ts` | +| Types/Interfaces | PascalCase, descriptive | `CtxStore` | +| Type aliases | `type` keyword, PascalCase | `type UserId = string` | +| Functions | camelCase, verb-prefixed | `getDependencies`, `useCtxStore` | +| Methods | camelCase | `increment`, `getDependencies` | +| Store state types | `CtxState` suffix | `DepbadgeRCState` | +| Store method types | `CtxMethods` suffix | `DepbadgeRCMethods` | ### Error Handling -- Use try/catch in CLI entry points -- Always handle caught errors: - ```typescript +CLI entry points must use try/catch: + +```typescript +try { + // ... main logic + process.exit(0); +} catch (error) { const message = error instanceof Error ? error.message : String(error); - ``` -- Exit with `process.exit(1)` on error -- Use `console.error` with `::error::` prefix for GitHub Actions + console.error(`::error::${message}`); + process.exit(1); +} +``` ### Type Patterns @@ -105,18 +135,37 @@ Order groups: - Use `export type` for types that need to be imported - Generic types with meaningful names (e.g., `CtxStore`) - Optional properties use `?` modifier +- Avoid `any` unless necessary; prefer `unknown` for truly unknown types ### Store Pattern (ctx-store) The project uses a custom immutable store pattern: -- `useCtxStore()` - creates frozen store -- `useCtxCallback()` - binds callbacks to store -- All stores are frozen with `Object.freeze()` +```typescript +import { useCtxCallback, useCtxStore } from "./ctx-store.ts"; + +// State and methods are separate types +type CtxState = { count: number }; +type CtxMethods = { increment: (delta: number) => number }; + +// Create store with frozen state +const store = useCtxStore( + { count: 5 }, + { + increment: (s) => (delta: number) => s.count + delta, + } +); + +// Stores are frozen (immutable) +Object.isFrozen(store); // true + +// Use useCtxCallback to bind callbacks +const callback = useCtxCallback((s) => () => console.log(s.count)); +``` ## Development Workflow -1. **Before committing**: Run `pnpm lint-staged` (automatically runs on pre-commit via husky) +1. **Before committing**: Run `pnpm lint-staged` (auto-runs on pre-commit via husky) 2. **Before pushing**: Run `pnpm test` and `pnpm build` 3. **CI Pipeline**: Lint → Build → Test (in that order) @@ -133,21 +182,34 @@ src/ │ ├── pyproject-toml/ │ └── cargo.toml/ ├── shared/ # Utility functions +│ ├── encode-label.ts +│ ├── find-file.ts +│ └── *.spec.ts └── store/ # Store implementation + ├── ctx-store.ts + └── ctx-store.spec.ts ``` ## Key Dependencies -- **yargs**: CLI argument parsing -- **js-yaml**: YAML parsing -- **colord**: Color manipulation -- **@iarna/toml**: TOML parsing +| Package | Purpose | +| ----------- | -------------------- | +| yargs | CLI argument parsing | +| js-yaml | YAML parsing | +| colord | Color manipulation | +| @iarna/toml | TOML parsing | +| vitest | Testing | +| tsup | Build tool | ## Configuration Files -- `eslint.config.ts` - ESLint configuration -- `prettier.config.mjs` - Prettier configuration -- `vitest.config.ts` - Test configuration -- `tsconfig.json` - TypeScript configuration -- `cspell.config.yml` - Spell checker configuration -- `tsup.config.ts` - Build tool configuration +| File | Purpose | +| --------------------- | -------------------------------- | +| `eslint.config.ts` | ESLint configuration | +| `prettier.config.mjs` | Prettier configuration | +| `vitest.config.ts` | Test configuration | +| `tsconfig.json` | TypeScript configuration | +| `tsconfig.build.json` | Build-specific TypeScript config | +| `cspell.config.yml` | Spell checker configuration | +| `tsup.config.ts` | Build tool configuration | +| `.lintstagedrc` | Lint-staged configuration | diff --git a/README.md b/README.md index 3752116..6cdb65b 100644 --- a/README.md +++ b/README.md @@ -37,9 +37,7 @@ Depbadge is a CLI tool that automatically generates and maintains dependency and
[![colord](https://img.shields.io/badge/colord-v2.9.3-bc1cc4.svg?labelColor=333&cacheSeconds=3600&logo=npm&logoColor=bc1cc4&logoWidth=40&style=for-the-badge)](https://github.com/omgovich/colord) -[![js-yaml](https://img.shields.io/badge/js_yaml-v4.1.1-6c3ad9.svg?labelColor=333&cacheSeconds=3600&logo=npm&logoColor=6c3ad9&logoWidth=40&style=for-the-badge)](https://github.com/nodeca/js-yaml) [![@iarna/toml](https://img.shields.io/badge/_iarna_toml-v2.2.5-d53f5d.svg?labelColor=333&cacheSeconds=3600&logo=toml&logoColor=d53f5d&logoWidth=40&style=for-the-badge)](https://github.com/iarna/iarna-toml) -[![yargs](https://img.shields.io/badge/yargs-v18.0.0-c0e01f.svg?labelColor=333&cacheSeconds=3600&logo=freebsd&logoColor=c0e01f&logoWidth=40&style=for-the-badge)](https://github.com/yargs/yargs)
@@ -73,7 +71,6 @@ Depbadge is a CLI tool that automatically generates and maintains dependency and ![ts-unused-exports](https://img.shields.io/badge/ts_unused_exports-v11.0.1-5e26c0.svg?labelColor=333&cacheSeconds=3600&logo=npm&logoColor=5e26c0&logoWidth=40&style=flat-square) ![typescript](https://img.shields.io/badge/typescript-v5.9.3-4c2eb8.svg?labelColor=333&cacheSeconds=3600&logo=typescript&logoColor=4c2eb8&logoWidth=40&style=flat-square) ![typescript-eslint](https://img.shields.io/badge/typescript_eslint-v8.57.1-dc2e59.svg?labelColor=333&cacheSeconds=3600&logo=eslint&logoColor=dc2e59&logoWidth=40&style=flat-square) -![@types/yargs](https://img.shields.io/badge/_types_yargs-v17.0.35-9db92d.svg?labelColor=333&cacheSeconds=3600&logo=freebsd&logoColor=9db92d&logoWidth=40&style=flat-square) diff --git a/depbadgerc.yml b/depbadgerc.yml index 00c3ccf..59a3c10 100644 --- a/depbadgerc.yml +++ b/depbadgerc.yml @@ -1,5 +1,5 @@ # yaml-language-server: $schema=./depbadgerc.schema.json -integrity: 7e0ca4fb48dfc72250a2f0badf01959937a3e1605ad410262c98940c5e69abee +integrity: 2dba81fa2bc8c81cc09452035d6b34e781d69536b2af3db6ada1d586c2f1e63a target: README.md manifest: package.json output: @@ -32,21 +32,16 @@ dependencies: - name: colord namedLogo: npm link: https://github.com/omgovich/colord - - name: js-yaml - namedLogo: npm - link: https://github.com/nodeca/js-yaml - name: "@iarna/toml" namedLogo: toml link: https://github.com/iarna/iarna-toml - - name: yargs - namedLogo: freebsd - link: https://github.com/yargs/yargs devDependencies: layout: *DEPENDENCIES_LAYOUT badgeStyle: <<: *DEPENDENCIES_STYLE style: flat-square + # labelColor: "333" items: - name: "@changesets/cli" namedLogo: npm @@ -100,8 +95,6 @@ devDependencies: namedLogo: typescript - name: typescript-eslint namedLogo: eslint - - name: "@types/yargs" - namedLogo: freebsd statusBadges: layout: @@ -138,8 +131,3 @@ statusBadges: label: My favorite color: "777" link: https://sallysbakingaddiction.com/chewy-chocolate-chip-cookies/ - - name: socket - package: '@ehildt/depbadge' - metric: quality - version: 1.1.4 - style: for-the-badge diff --git a/dist/index.mjs b/dist/index.mjs index 988d030..dd3f012 100755 --- a/dist/index.mjs +++ b/dist/index.mjs @@ -1,11 +1,10 @@ #!/usr/bin/env node import { createRequire } from 'module'; -import path2, { resolve, normalize, join, relative, extname, dirname, basename } from 'path'; -import { fileURLToPath } from 'url'; -import fs2, { readFileSync, writeFile, readdirSync, statSync } from 'fs'; +import path2 from 'path'; +import 'url'; +import fs2 from 'fs'; import crypto from 'crypto'; -import { strictEqual, notStrictEqual } from 'assert'; -import { format, inspect } from 'util'; +import { parseArgs } from 'util'; const require$1 = createRequire(import.meta.url); @@ -48,10385 +47,9692 @@ var init_esm_shims = __esm({ } }); -// node_modules/.pnpm/get-caller-file@2.0.5/node_modules/get-caller-file/index.js -var require_get_caller_file = __commonJS({ - "node_modules/.pnpm/get-caller-file@2.0.5/node_modules/get-caller-file/index.js"(exports2, module2) { +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/identity.js +var require_identity = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/identity.js"(exports2) { init_esm_shims(); - module2.exports = function getCallerFile2(position) { - if (position === void 0) { - position = 2; - } - if (position >= Error.stackTraceLimit) { - throw new TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `" + position + "` and Error.stackTraceLimit was: `" + Error.stackTraceLimit + "`"); - } - var oldPrepareStackTrace = Error.prepareStackTrace; - Error.prepareStackTrace = function(_, stack2) { - return stack2; - }; - var stack = new Error().stack; - Error.prepareStackTrace = oldPrepareStackTrace; - if (stack !== null && typeof stack === "object") { - return stack[position] ? stack[position].getFileName() : void 0; - } - }; + var ALIAS = /* @__PURE__ */ Symbol.for("yaml.alias"); + var DOC = /* @__PURE__ */ Symbol.for("yaml.document"); + var MAP = /* @__PURE__ */ Symbol.for("yaml.map"); + var PAIR = /* @__PURE__ */ Symbol.for("yaml.pair"); + var SCALAR = /* @__PURE__ */ Symbol.for("yaml.scalar"); + var SEQ = /* @__PURE__ */ Symbol.for("yaml.seq"); + var NODE_TYPE = /* @__PURE__ */ Symbol.for("yaml.node.type"); + var isAlias = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === ALIAS; + var isDocument = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === DOC; + var isMap = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === MAP; + var isPair = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === PAIR; + var isScalar = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === SCALAR; + var isSeq = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === SEQ; + function isCollection(node) { + if (node && typeof node === "object") + switch (node[NODE_TYPE]) { + case MAP: + case SEQ: + return true; + } + return false; + } + function isNode(node) { + if (node && typeof node === "object") + switch (node[NODE_TYPE]) { + case ALIAS: + case MAP: + case SCALAR: + case SEQ: + return true; + } + return false; + } + var hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor; + exports2.ALIAS = ALIAS; + exports2.DOC = DOC; + exports2.MAP = MAP; + exports2.NODE_TYPE = NODE_TYPE; + exports2.PAIR = PAIR; + exports2.SCALAR = SCALAR; + exports2.SEQ = SEQ; + exports2.hasAnchor = hasAnchor; + exports2.isAlias = isAlias; + exports2.isCollection = isCollection; + exports2.isDocument = isDocument; + exports2.isMap = isMap; + exports2.isNode = isNode; + exports2.isPair = isPair; + exports2.isScalar = isScalar; + exports2.isSeq = isSeq; } }); -// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/parser.js -var require_parser = __commonJS({ - "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/parser.js"(exports2, module2) { +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/visit.js +var require_visit = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/visit.js"(exports2) { init_esm_shims(); - var ParserEND = 1114112; - var ParserError = class _ParserError extends Error { - /* istanbul ignore next */ - constructor(msg, filename, linenumber) { - super("[ParserError] " + msg, filename, linenumber); - this.name = "ParserError"; - this.code = "ParserError"; - if (Error.captureStackTrace) Error.captureStackTrace(this, _ParserError); + var identity = require_identity(); + var BREAK = /* @__PURE__ */ Symbol("break visit"); + var SKIP = /* @__PURE__ */ Symbol("skip children"); + var REMOVE = /* @__PURE__ */ Symbol("remove node"); + function visit(node, visitor) { + const visitor_ = initVisitor(visitor); + if (identity.isDocument(node)) { + const cd = visit_(null, node.contents, visitor_, Object.freeze([node])); + if (cd === REMOVE) + node.contents = null; + } else + visit_(null, node, visitor_, Object.freeze([])); + } + visit.BREAK = BREAK; + visit.SKIP = SKIP; + visit.REMOVE = REMOVE; + function visit_(key, node, visitor, path4) { + const ctrl = callVisitor(key, node, visitor, path4); + if (identity.isNode(ctrl) || identity.isPair(ctrl)) { + replaceNode(key, path4, ctrl); + return visit_(key, ctrl, visitor, path4); + } + if (typeof ctrl !== "symbol") { + if (identity.isCollection(node)) { + path4 = Object.freeze(path4.concat(node)); + for (let i2 = 0; i2 < node.items.length; ++i2) { + const ci = visit_(i2, node.items[i2], visitor, path4); + if (typeof ci === "number") + i2 = ci - 1; + else if (ci === BREAK) + return BREAK; + else if (ci === REMOVE) { + node.items.splice(i2, 1); + i2 -= 1; + } + } + } else if (identity.isPair(node)) { + path4 = Object.freeze(path4.concat(node)); + const ck = visit_("key", node.key, visitor, path4); + if (ck === BREAK) + return BREAK; + else if (ck === REMOVE) + node.key = null; + const cv = visit_("value", node.value, visitor, path4); + if (cv === BREAK) + return BREAK; + else if (cv === REMOVE) + node.value = null; + } + } + return ctrl; + } + async function visitAsync(node, visitor) { + const visitor_ = initVisitor(visitor); + if (identity.isDocument(node)) { + const cd = await visitAsync_(null, node.contents, visitor_, Object.freeze([node])); + if (cd === REMOVE) + node.contents = null; + } else + await visitAsync_(null, node, visitor_, Object.freeze([])); + } + visitAsync.BREAK = BREAK; + visitAsync.SKIP = SKIP; + visitAsync.REMOVE = REMOVE; + async function visitAsync_(key, node, visitor, path4) { + const ctrl = await callVisitor(key, node, visitor, path4); + if (identity.isNode(ctrl) || identity.isPair(ctrl)) { + replaceNode(key, path4, ctrl); + return visitAsync_(key, ctrl, visitor, path4); + } + if (typeof ctrl !== "symbol") { + if (identity.isCollection(node)) { + path4 = Object.freeze(path4.concat(node)); + for (let i2 = 0; i2 < node.items.length; ++i2) { + const ci = await visitAsync_(i2, node.items[i2], visitor, path4); + if (typeof ci === "number") + i2 = ci - 1; + else if (ci === BREAK) + return BREAK; + else if (ci === REMOVE) { + node.items.splice(i2, 1); + i2 -= 1; + } + } + } else if (identity.isPair(node)) { + path4 = Object.freeze(path4.concat(node)); + const ck = await visitAsync_("key", node.key, visitor, path4); + if (ck === BREAK) + return BREAK; + else if (ck === REMOVE) + node.key = null; + const cv = await visitAsync_("value", node.value, visitor, path4); + if (cv === BREAK) + return BREAK; + else if (cv === REMOVE) + node.value = null; + } + } + return ctrl; + } + function initVisitor(visitor) { + if (typeof visitor === "object" && (visitor.Collection || visitor.Node || visitor.Value)) { + return Object.assign({ + Alias: visitor.Node, + Map: visitor.Node, + Scalar: visitor.Node, + Seq: visitor.Node + }, visitor.Value && { + Map: visitor.Value, + Scalar: visitor.Value, + Seq: visitor.Value + }, visitor.Collection && { + Map: visitor.Collection, + Seq: visitor.Collection + }, visitor); + } + return visitor; + } + function callVisitor(key, node, visitor, path4) { + if (typeof visitor === "function") + return visitor(key, node, path4); + if (identity.isMap(node)) + return visitor.Map?.(key, node, path4); + if (identity.isSeq(node)) + return visitor.Seq?.(key, node, path4); + if (identity.isPair(node)) + return visitor.Pair?.(key, node, path4); + if (identity.isScalar(node)) + return visitor.Scalar?.(key, node, path4); + if (identity.isAlias(node)) + return visitor.Alias?.(key, node, path4); + return void 0; + } + function replaceNode(key, path4, node) { + const parent = path4[path4.length - 1]; + if (identity.isCollection(parent)) { + parent.items[key] = node; + } else if (identity.isPair(parent)) { + if (key === "key") + parent.key = node; + else + parent.value = node; + } else if (identity.isDocument(parent)) { + parent.contents = node; + } else { + const pt = identity.isAlias(parent) ? "alias" : "scalar"; + throw new Error(`Cannot replace node with ${pt} parent`); } + } + exports2.visit = visit; + exports2.visitAsync = visitAsync; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/doc/directives.js +var require_directives = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/doc/directives.js"(exports2) { + init_esm_shims(); + var identity = require_identity(); + var visit = require_visit(); + var escapeChars = { + "!": "%21", + ",": "%2C", + "[": "%5B", + "]": "%5D", + "{": "%7B", + "}": "%7D" }; - var State2 = class { - constructor(parser2) { - this.parser = parser2; - this.buf = ""; - this.returned = null; - this.result = null; - this.resultTable = null; - this.resultArr = null; + var escapeTagName = (tn) => tn.replace(/[!,[\]{}]/g, (ch) => escapeChars[ch]); + var Directives = class _Directives { + constructor(yaml3, tags) { + this.docStart = null; + this.docEnd = false; + this.yaml = Object.assign({}, _Directives.defaultYaml, yaml3); + this.tags = Object.assign({}, _Directives.defaultTags, tags); + } + clone() { + const copy = new _Directives(this.yaml, this.tags); + copy.docStart = this.docStart; + return copy; + } + /** + * During parsing, get a Directives instance for the current document and + * update the stream state according to the current version's spec. + */ + atDocument() { + const res = new _Directives(this.yaml, this.tags); + switch (this.yaml.version) { + case "1.1": + this.atNextDocument = true; + break; + case "1.2": + this.atNextDocument = false; + this.yaml = { + explicit: _Directives.defaultYaml.explicit, + version: "1.2" + }; + this.tags = Object.assign({}, _Directives.defaultTags); + break; + } + return res; + } + /** + * @param onError - May be called even if the action was successful + * @returns `true` on success + */ + add(line, onError) { + if (this.atNextDocument) { + this.yaml = { explicit: _Directives.defaultYaml.explicit, version: "1.1" }; + this.tags = Object.assign({}, _Directives.defaultTags); + this.atNextDocument = false; + } + const parts = line.trim().split(/[ \t]+/); + const name = parts.shift(); + switch (name) { + case "%TAG": { + if (parts.length !== 2) { + onError(0, "%TAG directive should contain exactly two parts"); + if (parts.length < 2) + return false; + } + const [handle, prefix] = parts; + this.tags[handle] = prefix; + return true; + } + case "%YAML": { + this.yaml.explicit = true; + if (parts.length !== 1) { + onError(0, "%YAML directive should contain exactly one part"); + return false; + } + const [version] = parts; + if (version === "1.1" || version === "1.2") { + this.yaml.version = version; + return true; + } else { + const isValid = /^\d+\.\d+$/.test(version); + onError(6, `Unsupported YAML version ${version}`, isValid); + return false; + } + } + default: + onError(0, `Unknown directive ${name}`, true); + return false; + } + } + /** + * Resolves a tag, matching handles to those defined in %TAG directives. + * + * @returns Resolved tag, which may also be the non-specific tag `'!'` or a + * `'!local'` tag, or `null` if unresolvable. + */ + tagName(source, onError) { + if (source === "!") + return "!"; + if (source[0] !== "!") { + onError(`Not a valid tag: ${source}`); + return null; + } + if (source[1] === "<") { + const verbatim = source.slice(2, -1); + if (verbatim === "!" || verbatim === "!!") { + onError(`Verbatim tags aren't resolved, so ${source} is invalid.`); + return null; + } + if (source[source.length - 1] !== ">") + onError("Verbatim tags must end with a >"); + return verbatim; + } + const [, handle, suffix] = source.match(/^(.*!)([^!]*)$/s); + if (!suffix) + onError(`The ${source} tag has no suffix`); + const prefix = this.tags[handle]; + if (prefix) { + try { + return prefix + decodeURIComponent(suffix); + } catch (error) { + onError(String(error)); + return null; + } + } + if (handle === "!") + return source; + onError(`Could not resolve tag: ${source}`); + return null; + } + /** + * Given a fully resolved tag, returns its printable string form, + * taking into account current tag prefixes and defaults. + */ + tagString(tag) { + for (const [handle, prefix] of Object.entries(this.tags)) { + if (tag.startsWith(prefix)) + return handle + escapeTagName(tag.substring(prefix.length)); + } + return tag[0] === "!" ? tag : `!<${tag}>`; + } + toString(doc) { + const lines = this.yaml.explicit ? [`%YAML ${this.yaml.version || "1.2"}`] : []; + const tagEntries = Object.entries(this.tags); + let tagNames; + if (doc && tagEntries.length > 0 && identity.isNode(doc.contents)) { + const tags = {}; + visit.visit(doc.contents, (_key, node) => { + if (identity.isNode(node) && node.tag) + tags[node.tag] = true; + }); + tagNames = Object.keys(tags); + } else + tagNames = []; + for (const [handle, prefix] of tagEntries) { + if (handle === "!!" && prefix === "tag:yaml.org,2002:") + continue; + if (!doc || tagNames.some((tn) => tn.startsWith(prefix))) + lines.push(`%TAG ${handle} ${prefix}`); + } + return lines.join("\n"); } }; - var Parser2 = class { - constructor() { - this.pos = 0; - this.col = 0; - this.line = 0; - this.obj = {}; - this.ctx = this.obj; - this.stack = []; - this._buf = ""; - this.char = null; - this.ii = 0; - this.state = new State2(this.parseStart); + Directives.defaultYaml = { explicit: false, version: "1.2" }; + Directives.defaultTags = { "!!": "tag:yaml.org,2002:" }; + exports2.Directives = Directives; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/doc/anchors.js +var require_anchors = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/doc/anchors.js"(exports2) { + init_esm_shims(); + var identity = require_identity(); + var visit = require_visit(); + function anchorIsValid(anchor) { + if (/[\x00-\x19\s,[\]{}]/.test(anchor)) { + const sa = JSON.stringify(anchor); + const msg = `Anchor must not contain whitespace or control characters: ${sa}`; + throw new Error(msg); } - parse(str2) { - if (str2.length === 0 || str2.length == null) return; - this._buf = String(str2); - this.ii = -1; - this.char = -1; - let getNext; - while (getNext === false || this.nextChar()) { - getNext = this.runOne(); + return true; + } + function anchorNames(root) { + const anchors = /* @__PURE__ */ new Set(); + visit.visit(root, { + Value(_key, node) { + if (node.anchor) + anchors.add(node.anchor); } - this._buf = null; + }); + return anchors; + } + function findNewAnchor(prefix, exclude) { + for (let i2 = 1; true; ++i2) { + const name = `${prefix}${i2}`; + if (!exclude.has(name)) + return name; } - nextChar() { - if (this.char === 10) { - ++this.line; - this.col = -1; + } + function createNodeAnchors(doc, prefix) { + const aliasObjects = []; + const sourceObjects = /* @__PURE__ */ new Map(); + let prevAnchors = null; + return { + onAnchor: (source) => { + aliasObjects.push(source); + prevAnchors ?? (prevAnchors = anchorNames(doc)); + const anchor = findNewAnchor(prefix, prevAnchors); + prevAnchors.add(anchor); + return anchor; + }, + /** + * With circular references, the source node is only resolved after all + * of its child nodes are. This is why anchors are set only after all of + * the nodes have been created. + */ + setAnchors: () => { + for (const source of aliasObjects) { + const ref = sourceObjects.get(source); + if (typeof ref === "object" && ref.anchor && (identity.isScalar(ref.node) || identity.isCollection(ref.node))) { + ref.node.anchor = ref.anchor; + } else { + const error = new Error("Failed to resolve repeated object (this should not happen)"); + error.source = source; + throw error; + } + } + }, + sourceObjects + }; + } + exports2.anchorIsValid = anchorIsValid; + exports2.anchorNames = anchorNames; + exports2.createNodeAnchors = createNodeAnchors; + exports2.findNewAnchor = findNewAnchor; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/doc/applyReviver.js +var require_applyReviver = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/doc/applyReviver.js"(exports2) { + init_esm_shims(); + function applyReviver(reviver, obj, key, val) { + if (val && typeof val === "object") { + if (Array.isArray(val)) { + for (let i2 = 0, len = val.length; i2 < len; ++i2) { + const v0 = val[i2]; + const v1 = applyReviver(reviver, val, String(i2), v0); + if (v1 === void 0) + delete val[i2]; + else if (v1 !== v0) + val[i2] = v1; + } + } else if (val instanceof Map) { + for (const k of Array.from(val.keys())) { + const v0 = val.get(k); + const v1 = applyReviver(reviver, val, k, v0); + if (v1 === void 0) + val.delete(k); + else if (v1 !== v0) + val.set(k, v1); + } + } else if (val instanceof Set) { + for (const v0 of Array.from(val)) { + const v1 = applyReviver(reviver, val, v0, v0); + if (v1 === void 0) + val.delete(v0); + else if (v1 !== v0) { + val.delete(v0); + val.add(v1); + } + } + } else { + for (const [k, v0] of Object.entries(val)) { + const v1 = applyReviver(reviver, val, k, v0); + if (v1 === void 0) + delete val[k]; + else if (v1 !== v0) + val[k] = v1; + } } - ++this.ii; - this.char = this._buf.codePointAt(this.ii); - ++this.pos; - ++this.col; - return this.haveBuffer(); - } - haveBuffer() { - return this.ii < this._buf.length; - } - runOne() { - return this.state.parser.call(this, this.state.returned); - } - finish() { - this.char = ParserEND; - let last; - do { - last = this.state.parser; - this.runOne(); - } while (this.state.parser !== last); - this.ctx = null; - this.state = null; - this._buf = null; - return this.obj; - } - next(fn) { - if (typeof fn !== "function") throw new ParserError("Tried to set state to non-existent state: " + JSON.stringify(fn)); - this.state.parser = fn; - } - goto(fn) { - this.next(fn); - return this.runOne(); - } - call(fn, returnWith) { - if (returnWith) this.next(returnWith); - this.stack.push(this.state); - this.state = new State2(fn); - } - callNow(fn, returnWith) { - this.call(fn, returnWith); - return this.runOne(); - } - return(value) { - if (this.stack.length === 0) throw this.error(new ParserError("Stack underflow")); - if (value === void 0) value = this.state.buf; - this.state = this.stack.pop(); - this.state.returned = value; - } - returnNow(value) { - this.return(value); - return this.runOne(); - } - consume() { - if (this.char === ParserEND) throw this.error(new ParserError("Unexpected end-of-buffer")); - this.state.buf += this._buf[this.ii]; - } - error(err) { - err.line = this.line; - err.col = this.col; - err.pos = this.pos; - return err; - } - /* istanbul ignore next */ - parseStart() { - throw new ParserError("Must declare a parseStart method"); } - }; - Parser2.END = ParserEND; - Parser2.Error = ParserError; - module2.exports = Parser2; + return reviver.call(obj, key, val); + } + exports2.applyReviver = applyReviver; } }); -// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime.js -var require_create_datetime = __commonJS({ - "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime.js"(exports2, module2) { +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/toJS.js +var require_toJS = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/toJS.js"(exports2) { init_esm_shims(); - module2.exports = (value) => { - const date = new Date(value); - if (isNaN(date)) { - throw new TypeError("Invalid Datetime"); - } else { - return date; + var identity = require_identity(); + function toJS(value, arg, ctx) { + if (Array.isArray(value)) + return value.map((v2, i2) => toJS(v2, String(i2), ctx)); + if (value && typeof value.toJSON === "function") { + if (!ctx || !identity.hasAnchor(value)) + return value.toJSON(arg, ctx); + const data = { aliasCount: 0, count: 1, res: void 0 }; + ctx.anchors.set(value, data); + ctx.onCreate = (res2) => { + data.res = res2; + delete ctx.onCreate; + }; + const res = value.toJSON(arg, ctx); + if (ctx.onCreate) + ctx.onCreate(res); + return res; } - }; + if (typeof value === "bigint" && !ctx?.keep) + return Number(value); + return value; + } + exports2.toJS = toJS; } }); -// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/format-num.js -var require_format_num = __commonJS({ - "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/format-num.js"(exports2, module2) { +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/Node.js +var require_Node = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/Node.js"(exports2) { init_esm_shims(); - module2.exports = (d2, num) => { - num = String(num); - while (num.length < d2) num = "0" + num; - return num; + var applyReviver = require_applyReviver(); + var identity = require_identity(); + var toJS = require_toJS(); + var NodeBase = class { + constructor(type) { + Object.defineProperty(this, identity.NODE_TYPE, { value: type }); + } + /** Create a copy of this node. */ + clone() { + const copy = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this)); + if (this.range) + copy.range = this.range.slice(); + return copy; + } + /** A plain JavaScript representation of this node. */ + toJS(doc, { mapAsMap, maxAliasCount, onAnchor, reviver } = {}) { + if (!identity.isDocument(doc)) + throw new TypeError("A document argument is required"); + const ctx = { + anchors: /* @__PURE__ */ new Map(), + doc, + keep: true, + mapAsMap: mapAsMap === true, + mapKeyWarned: false, + maxAliasCount: typeof maxAliasCount === "number" ? maxAliasCount : 100 + }; + const res = toJS.toJS(this, "", ctx); + if (typeof onAnchor === "function") + for (const { count, res: res2 } of ctx.anchors.values()) + onAnchor(res2, count); + return typeof reviver === "function" ? applyReviver.applyReviver(reviver, { "": res }, "", res) : res; + } }; + exports2.NodeBase = NodeBase; } }); -// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime-float.js -var require_create_datetime_float = __commonJS({ - "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime-float.js"(exports2, module2) { +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/Alias.js +var require_Alias = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/Alias.js"(exports2) { init_esm_shims(); - var f2 = require_format_num(); - var FloatingDateTime = class extends Date { - constructor(value) { - super(value + "Z"); - this.isFloating = true; + var anchors = require_anchors(); + var visit = require_visit(); + var identity = require_identity(); + var Node = require_Node(); + var toJS = require_toJS(); + var Alias = class extends Node.NodeBase { + constructor(source) { + super(identity.ALIAS); + this.source = source; + Object.defineProperty(this, "tag", { + set() { + throw new Error("Alias nodes cannot have tags"); + } + }); } - toISOString() { - const date = `${this.getUTCFullYear()}-${f2(2, this.getUTCMonth() + 1)}-${f2(2, this.getUTCDate())}`; - const time = `${f2(2, this.getUTCHours())}:${f2(2, this.getUTCMinutes())}:${f2(2, this.getUTCSeconds())}.${f2(3, this.getUTCMilliseconds())}`; - return `${date}T${time}`; + /** + * Resolve the value of this alias within `doc`, finding the last + * instance of the `source` anchor before this node. + */ + resolve(doc, ctx) { + let nodes; + if (ctx?.aliasResolveCache) { + nodes = ctx.aliasResolveCache; + } else { + nodes = []; + visit.visit(doc, { + Node: (_key, node) => { + if (identity.isAlias(node) || identity.hasAnchor(node)) + nodes.push(node); + } + }); + if (ctx) + ctx.aliasResolveCache = nodes; + } + let found = void 0; + for (const node of nodes) { + if (node === this) + break; + if (node.anchor === this.source) + found = node; + } + return found; } - }; - module2.exports = (value) => { - const date = new FloatingDateTime(value); - if (isNaN(date)) { - throw new TypeError("Invalid Datetime"); - } else { - return date; + toJSON(_arg, ctx) { + if (!ctx) + return { source: this.source }; + const { anchors: anchors2, doc, maxAliasCount } = ctx; + const source = this.resolve(doc, ctx); + if (!source) { + const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`; + throw new ReferenceError(msg); + } + let data = anchors2.get(source); + if (!data) { + toJS.toJS(source, null, ctx); + data = anchors2.get(source); + } + if (data?.res === void 0) { + const msg = "This should not happen: Alias anchor was not resolved?"; + throw new ReferenceError(msg); + } + if (maxAliasCount >= 0) { + data.count += 1; + if (data.aliasCount === 0) + data.aliasCount = getAliasCount(doc, source, anchors2); + if (data.count * data.aliasCount > maxAliasCount) { + const msg = "Excessive alias count indicates a resource exhaustion attack"; + throw new ReferenceError(msg); + } + } + return data.res; + } + toString(ctx, _onComment, _onChompKeep) { + const src = `*${this.source}`; + if (ctx) { + anchors.anchorIsValid(this.source); + if (ctx.options.verifyAliasOrder && !ctx.anchors.has(this.source)) { + const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`; + throw new Error(msg); + } + if (ctx.implicitKey) + return `${src} `; + } + return src; } }; + function getAliasCount(doc, node, anchors2) { + if (identity.isAlias(node)) { + const source = node.resolve(doc); + const anchor = anchors2 && source && anchors2.get(source); + return anchor ? anchor.count * anchor.aliasCount : 0; + } else if (identity.isCollection(node)) { + let count = 0; + for (const item of node.items) { + const c2 = getAliasCount(doc, item, anchors2); + if (c2 > count) + count = c2; + } + return count; + } else if (identity.isPair(node)) { + const kc = getAliasCount(doc, node.key, anchors2); + const vc = getAliasCount(doc, node.value, anchors2); + return Math.max(kc, vc); + } + return 1; + } + exports2.Alias = Alias; } }); -// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-date.js -var require_create_date = __commonJS({ - "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-date.js"(exports2, module2) { +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/Scalar.js +var require_Scalar = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/Scalar.js"(exports2) { init_esm_shims(); - var f2 = require_format_num(); - var DateTime = global.Date; - var Date2 = class extends DateTime { + var identity = require_identity(); + var Node = require_Node(); + var toJS = require_toJS(); + var isScalarValue = (value) => !value || typeof value !== "function" && typeof value !== "object"; + var Scalar = class extends Node.NodeBase { constructor(value) { - super(value); - this.isDate = true; + super(identity.SCALAR); + this.value = value; } - toISOString() { - return `${this.getUTCFullYear()}-${f2(2, this.getUTCMonth() + 1)}-${f2(2, this.getUTCDate())}`; + toJSON(arg, ctx) { + return ctx?.keep ? this.value : toJS.toJS(this.value, arg, ctx); } - }; - module2.exports = (value) => { - const date = new Date2(value); - if (isNaN(date)) { - throw new TypeError("Invalid Datetime"); - } else { - return date; + toString() { + return String(this.value); } }; + Scalar.BLOCK_FOLDED = "BLOCK_FOLDED"; + Scalar.BLOCK_LITERAL = "BLOCK_LITERAL"; + Scalar.PLAIN = "PLAIN"; + Scalar.QUOTE_DOUBLE = "QUOTE_DOUBLE"; + Scalar.QUOTE_SINGLE = "QUOTE_SINGLE"; + exports2.Scalar = Scalar; + exports2.isScalarValue = isScalarValue; } }); -// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-time.js -var require_create_time = __commonJS({ - "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-time.js"(exports2, module2) { +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/doc/createNode.js +var require_createNode = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/doc/createNode.js"(exports2) { init_esm_shims(); - var f2 = require_format_num(); - var Time = class extends Date { - constructor(value) { - super(`0000-01-01T${value}Z`); - this.isTime = true; + var Alias = require_Alias(); + var identity = require_identity(); + var Scalar = require_Scalar(); + var defaultTagPrefix = "tag:yaml.org,2002:"; + function findTagObject(value, tagName, tags) { + if (tagName) { + const match = tags.filter((t2) => t2.tag === tagName); + const tagObj = match.find((t2) => !t2.format) ?? match[0]; + if (!tagObj) + throw new Error(`Tag ${tagName} not found`); + return tagObj; + } + return tags.find((t2) => t2.identify?.(value) && !t2.format); + } + function createNode(value, tagName, ctx) { + if (identity.isDocument(value)) + value = value.contents; + if (identity.isNode(value)) + return value; + if (identity.isPair(value)) { + const map = ctx.schema[identity.MAP].createNode?.(ctx.schema, null, ctx); + map.items.push(value); + return map; + } + if (value instanceof String || value instanceof Number || value instanceof Boolean || typeof BigInt !== "undefined" && value instanceof BigInt) { + value = value.valueOf(); + } + const { aliasDuplicateObjects, onAnchor, onTagObj, schema, sourceObjects } = ctx; + let ref = void 0; + if (aliasDuplicateObjects && value && typeof value === "object") { + ref = sourceObjects.get(value); + if (ref) { + ref.anchor ?? (ref.anchor = onAnchor(value)); + return new Alias.Alias(ref.anchor); + } else { + ref = { anchor: null, node: null }; + sourceObjects.set(value, ref); + } } - toISOString() { - return `${f2(2, this.getUTCHours())}:${f2(2, this.getUTCMinutes())}:${f2(2, this.getUTCSeconds())}.${f2(3, this.getUTCMilliseconds())}`; + if (tagName?.startsWith("!!")) + tagName = defaultTagPrefix + tagName.slice(2); + let tagObj = findTagObject(value, tagName, schema.tags); + if (!tagObj) { + if (value && typeof value.toJSON === "function") { + value = value.toJSON(); + } + if (!value || typeof value !== "object") { + const node2 = new Scalar.Scalar(value); + if (ref) + ref.node = node2; + return node2; + } + tagObj = value instanceof Map ? schema[identity.MAP] : Symbol.iterator in Object(value) ? schema[identity.SEQ] : schema[identity.MAP]; } - }; - module2.exports = (value) => { - const date = new Time(value); - if (isNaN(date)) { - throw new TypeError("Invalid Datetime"); - } else { - return date; + if (onTagObj) { + onTagObj(tagObj); + delete ctx.onTagObj; } - }; + const node = tagObj?.createNode ? tagObj.createNode(ctx.schema, value, ctx) : typeof tagObj?.nodeClass?.from === "function" ? tagObj.nodeClass.from(ctx.schema, value, ctx) : new Scalar.Scalar(value); + if (tagName) + node.tag = tagName; + else if (!tagObj.default) + node.tag = tagObj.tag; + if (ref) + ref.node = node; + return node; + } + exports2.createNode = createNode; } }); -// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/toml-parser.js -var require_toml_parser = __commonJS({ - "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/toml-parser.js"(exports$1, module) { +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/Collection.js +var require_Collection = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/Collection.js"(exports2) { init_esm_shims(); - module.exports = makeParserClass(require_parser()); - module.exports.makeParserClass = makeParserClass; - var TomlError = class _TomlError extends Error { - constructor(msg) { - super(msg); - this.name = "TomlError"; - if (Error.captureStackTrace) Error.captureStackTrace(this, _TomlError); - this.fromTOML = true; - this.wrapped = null; + var createNode = require_createNode(); + var identity = require_identity(); + var Node = require_Node(); + function collectionFromPath(schema, path4, value) { + let v2 = value; + for (let i2 = path4.length - 1; i2 >= 0; --i2) { + const k = path4[i2]; + if (typeof k === "number" && Number.isInteger(k) && k >= 0) { + const a2 = []; + a2[k] = v2; + v2 = a2; + } else { + v2 = /* @__PURE__ */ new Map([[k, v2]]); + } + } + return createNode.createNode(v2, void 0, { + aliasDuplicateObjects: false, + keepUndefined: false, + onAnchor: () => { + throw new Error("This should not happen, please report a bug."); + }, + schema, + sourceObjects: /* @__PURE__ */ new Map() + }); + } + var isEmptyPath = (path4) => path4 == null || typeof path4 === "object" && !!path4[Symbol.iterator]().next().done; + var Collection = class extends Node.NodeBase { + constructor(type, schema) { + super(type); + Object.defineProperty(this, "schema", { + value: schema, + configurable: true, + enumerable: false, + writable: true + }); + } + /** + * Create a copy of this collection. + * + * @param schema - If defined, overwrites the original's schema + */ + clone(schema) { + const copy = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this)); + if (schema) + copy.schema = schema; + copy.items = copy.items.map((it) => identity.isNode(it) || identity.isPair(it) ? it.clone(schema) : it); + if (this.range) + copy.range = this.range.slice(); + return copy; + } + /** + * Adds a value to the collection. For `!!map` and `!!omap` the value must + * be a Pair instance or a `{ key, value }` object, which may not have a key + * that already exists in the map. + */ + addIn(path4, value) { + if (isEmptyPath(path4)) + this.add(value); + else { + const [key, ...rest] = path4; + const node = this.get(key, true); + if (identity.isCollection(node)) + node.addIn(rest, value); + else if (node === void 0 && this.schema) + this.set(key, collectionFromPath(this.schema, rest, value)); + else + throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`); + } + } + /** + * Removes a value from the collection. + * @returns `true` if the item was found and removed. + */ + deleteIn(path4) { + const [key, ...rest] = path4; + if (rest.length === 0) + return this.delete(key); + const node = this.get(key, true); + if (identity.isCollection(node)) + return node.deleteIn(rest); + else + throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`); + } + /** + * Returns item at `key`, or `undefined` if not found. By default unwraps + * scalar values from their surrounding node; to disable set `keepScalar` to + * `true` (collections are always returned intact). + */ + getIn(path4, keepScalar) { + const [key, ...rest] = path4; + const node = this.get(key, true); + if (rest.length === 0) + return !keepScalar && identity.isScalar(node) ? node.value : node; + else + return identity.isCollection(node) ? node.getIn(rest, keepScalar) : void 0; + } + hasAllNullValues(allowScalar) { + return this.items.every((node) => { + if (!identity.isPair(node)) + return false; + const n2 = node.value; + return n2 == null || allowScalar && identity.isScalar(n2) && n2.value == null && !n2.commentBefore && !n2.comment && !n2.tag; + }); + } + /** + * Checks if the collection includes a value with the key `key`. + */ + hasIn(path4) { + const [key, ...rest] = path4; + if (rest.length === 0) + return this.has(key); + const node = this.get(key, true); + return identity.isCollection(node) ? node.hasIn(rest) : false; + } + /** + * Sets a value in this collection. For `!!set`, `value` needs to be a + * boolean to add/remove the item from the set. + */ + setIn(path4, value) { + const [key, ...rest] = path4; + if (rest.length === 0) { + this.set(key, value); + } else { + const node = this.get(key, true); + if (identity.isCollection(node)) + node.setIn(rest, value); + else if (node === void 0 && this.schema) + this.set(key, collectionFromPath(this.schema, rest, value)); + else + throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`); + } } }; - TomlError.wrap = (err) => { - const terr = new TomlError(err.message); - terr.code = err.code; - terr.wrapped = err; - return terr; - }; - module.exports.TomlError = TomlError; - var createDateTime = require_create_datetime(); - var createDateTimeFloat = require_create_datetime_float(); - var createDate = require_create_date(); - var createTime = require_create_time(); - var CTRL_I = 9; - var CTRL_J = 10; - var CTRL_M = 13; - var CTRL_CHAR_BOUNDARY = 31; - var CHAR_SP = 32; - var CHAR_QUOT = 34; - var CHAR_NUM = 35; - var CHAR_APOS = 39; - var CHAR_PLUS = 43; - var CHAR_COMMA = 44; - var CHAR_HYPHEN = 45; - var CHAR_PERIOD = 46; - var CHAR_0 = 48; - var CHAR_1 = 49; - var CHAR_7 = 55; - var CHAR_9 = 57; - var CHAR_COLON = 58; - var CHAR_EQUALS = 61; - var CHAR_A = 65; - var CHAR_E = 69; - var CHAR_F = 70; - var CHAR_T = 84; - var CHAR_U = 85; - var CHAR_Z = 90; - var CHAR_LOWBAR = 95; - var CHAR_a = 97; - var CHAR_b = 98; - var CHAR_e = 101; - var CHAR_f = 102; - var CHAR_i = 105; - var CHAR_l = 108; - var CHAR_n = 110; - var CHAR_o = 111; - var CHAR_r = 114; - var CHAR_s = 115; - var CHAR_t = 116; - var CHAR_u = 117; - var CHAR_x = 120; - var CHAR_z = 122; - var CHAR_LCUB = 123; - var CHAR_RCUB = 125; - var CHAR_LSQB = 91; - var CHAR_BSOL = 92; - var CHAR_RSQB = 93; - var CHAR_DEL = 127; - var SURROGATE_FIRST = 55296; - var SURROGATE_LAST = 57343; - var escapes = { - [CHAR_b]: "\b", - [CHAR_t]: " ", - [CHAR_n]: "\n", - [CHAR_f]: "\f", - [CHAR_r]: "\r", - [CHAR_QUOT]: '"', - [CHAR_BSOL]: "\\" - }; - function isDigit(cp) { - return cp >= CHAR_0 && cp <= CHAR_9; + exports2.Collection = Collection; + exports2.collectionFromPath = collectionFromPath; + exports2.isEmptyPath = isEmptyPath; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringifyComment.js +var require_stringifyComment = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringifyComment.js"(exports2) { + init_esm_shims(); + var stringifyComment = (str) => str.replace(/^(?!$)(?: $)?/gm, "#"); + function indentComment(comment, indent) { + if (/^\n+$/.test(comment)) + return comment.substring(1); + return indent ? comment.replace(/^(?! *$)/gm, indent) : comment; } - function isHexit(cp) { - return cp >= CHAR_A && cp <= CHAR_F || cp >= CHAR_a && cp <= CHAR_f || cp >= CHAR_0 && cp <= CHAR_9; + var lineComment = (str, indent, comment) => str.endsWith("\n") ? indentComment(comment, indent) : comment.includes("\n") ? "\n" + indentComment(comment, indent) : (str.endsWith(" ") ? "" : " ") + comment; + exports2.indentComment = indentComment; + exports2.lineComment = lineComment; + exports2.stringifyComment = stringifyComment; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/foldFlowLines.js +var require_foldFlowLines = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/foldFlowLines.js"(exports2) { + init_esm_shims(); + var FOLD_FLOW = "flow"; + var FOLD_BLOCK = "block"; + var FOLD_QUOTED = "quoted"; + function foldFlowLines(text, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) { + if (!lineWidth || lineWidth < 0) + return text; + if (lineWidth < minContentWidth) + minContentWidth = 0; + const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length); + if (text.length <= endStep) + return text; + const folds = []; + const escapedFolds = {}; + let end = lineWidth - indent.length; + if (typeof indentAtStart === "number") { + if (indentAtStart > lineWidth - Math.max(2, minContentWidth)) + folds.push(0); + else + end = lineWidth - indentAtStart; + } + let split = void 0; + let prev = void 0; + let overflow = false; + let i2 = -1; + let escStart = -1; + let escEnd = -1; + if (mode === FOLD_BLOCK) { + i2 = consumeMoreIndentedLines(text, i2, indent.length); + if (i2 !== -1) + end = i2 + endStep; + } + for (let ch; ch = text[i2 += 1]; ) { + if (mode === FOLD_QUOTED && ch === "\\") { + escStart = i2; + switch (text[i2 + 1]) { + case "x": + i2 += 3; + break; + case "u": + i2 += 5; + break; + case "U": + i2 += 9; + break; + default: + i2 += 1; + } + escEnd = i2; + } + if (ch === "\n") { + if (mode === FOLD_BLOCK) + i2 = consumeMoreIndentedLines(text, i2, indent.length); + end = i2 + indent.length + endStep; + split = void 0; + } else { + if (ch === " " && prev && prev !== " " && prev !== "\n" && prev !== " ") { + const next = text[i2 + 1]; + if (next && next !== " " && next !== "\n" && next !== " ") + split = i2; + } + if (i2 >= end) { + if (split) { + folds.push(split); + end = split + endStep; + split = void 0; + } else if (mode === FOLD_QUOTED) { + while (prev === " " || prev === " ") { + prev = ch; + ch = text[i2 += 1]; + overflow = true; + } + const j2 = i2 > escEnd + 1 ? i2 - 2 : escStart - 1; + if (escapedFolds[j2]) + return text; + folds.push(j2); + escapedFolds[j2] = true; + end = j2 + endStep; + split = void 0; + } else { + overflow = true; + } + } + } + prev = ch; + } + if (overflow && onOverflow) + onOverflow(); + if (folds.length === 0) + return text; + if (onFold) + onFold(); + let res = text.slice(0, folds[0]); + for (let i3 = 0; i3 < folds.length; ++i3) { + const fold = folds[i3]; + const end2 = folds[i3 + 1] || text.length; + if (fold === 0) + res = ` +${indent}${text.slice(0, end2)}`; + else { + if (mode === FOLD_QUOTED && escapedFolds[fold]) + res += `${text[fold]}\\`; + res += ` +${indent}${text.slice(fold + 1, end2)}`; + } + } + return res; + } + function consumeMoreIndentedLines(text, i2, indent) { + let end = i2; + let start = i2 + 1; + let ch = text[start]; + while (ch === " " || ch === " ") { + if (i2 < start + indent) { + ch = text[++i2]; + } else { + do { + ch = text[++i2]; + } while (ch && ch !== "\n"); + end = i2; + start = i2 + 1; + ch = text[start]; + } + } + return end; } - function isBit(cp) { - return cp === CHAR_1 || cp === CHAR_0; + exports2.FOLD_BLOCK = FOLD_BLOCK; + exports2.FOLD_FLOW = FOLD_FLOW; + exports2.FOLD_QUOTED = FOLD_QUOTED; + exports2.foldFlowLines = foldFlowLines; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringifyString.js +var require_stringifyString = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringifyString.js"(exports2) { + init_esm_shims(); + var Scalar = require_Scalar(); + var foldFlowLines = require_foldFlowLines(); + var getFoldOptions = (ctx, isBlock) => ({ + indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart, + lineWidth: ctx.options.lineWidth, + minContentWidth: ctx.options.minContentWidth + }); + var containsDocumentMarker = (str) => /^(%|---|\.\.\.)/m.test(str); + function lineLengthOverLimit(str, lineWidth, indentLength) { + if (!lineWidth || lineWidth < 0) + return false; + const limit = lineWidth - indentLength; + const strLen = str.length; + if (strLen <= limit) + return false; + for (let i2 = 0, start = 0; i2 < strLen; ++i2) { + if (str[i2] === "\n") { + if (i2 - start > limit) + return true; + start = i2 + 1; + if (strLen - start <= limit) + return false; + } + } + return true; } - function isOctit(cp) { - return cp >= CHAR_0 && cp <= CHAR_7; + function doubleQuotedString(value, ctx) { + const json = JSON.stringify(value); + if (ctx.options.doubleQuotedAsJSON) + return json; + const { implicitKey } = ctx; + const minMultiLineLength = ctx.options.doubleQuotedMinMultiLineLength; + const indent = ctx.indent || (containsDocumentMarker(value) ? " " : ""); + let str = ""; + let start = 0; + for (let i2 = 0, ch = json[i2]; ch; ch = json[++i2]) { + if (ch === " " && json[i2 + 1] === "\\" && json[i2 + 2] === "n") { + str += json.slice(start, i2) + "\\ "; + i2 += 1; + start = i2; + ch = "\\"; + } + if (ch === "\\") + switch (json[i2 + 1]) { + case "u": + { + str += json.slice(start, i2); + const code = json.substr(i2 + 2, 4); + switch (code) { + case "0000": + str += "\\0"; + break; + case "0007": + str += "\\a"; + break; + case "000b": + str += "\\v"; + break; + case "001b": + str += "\\e"; + break; + case "0085": + str += "\\N"; + break; + case "00a0": + str += "\\_"; + break; + case "2028": + str += "\\L"; + break; + case "2029": + str += "\\P"; + break; + default: + if (code.substr(0, 2) === "00") + str += "\\x" + code.substr(2); + else + str += json.substr(i2, 6); + } + i2 += 5; + start = i2 + 1; + } + break; + case "n": + if (implicitKey || json[i2 + 2] === '"' || json.length < minMultiLineLength) { + i2 += 1; + } else { + str += json.slice(start, i2) + "\n\n"; + while (json[i2 + 2] === "\\" && json[i2 + 3] === "n" && json[i2 + 4] !== '"') { + str += "\n"; + i2 += 2; + } + str += indent; + if (json[i2 + 2] === " ") + str += "\\"; + i2 += 1; + start = i2 + 1; + } + break; + default: + i2 += 1; + } + } + str = start ? str + json.slice(start) : json; + return implicitKey ? str : foldFlowLines.foldFlowLines(str, indent, foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx, false)); + } + function singleQuotedString(value, ctx) { + if (ctx.options.singleQuote === false || ctx.implicitKey && value.includes("\n") || /[ \t]\n|\n[ \t]/.test(value)) + return doubleQuotedString(value, ctx); + const indent = ctx.indent || (containsDocumentMarker(value) ? " " : ""); + const res = "'" + value.replace(/'/g, "''").replace(/\n+/g, `$& +${indent}`) + "'"; + return ctx.implicitKey ? res : foldFlowLines.foldFlowLines(res, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx, false)); + } + function quotedString(value, ctx) { + const { singleQuote } = ctx.options; + let qs; + if (singleQuote === false) + qs = doubleQuotedString; + else { + const hasDouble = value.includes('"'); + const hasSingle = value.includes("'"); + if (hasDouble && !hasSingle) + qs = singleQuotedString; + else if (hasSingle && !hasDouble) + qs = doubleQuotedString; + else + qs = singleQuote ? singleQuotedString : doubleQuotedString; + } + return qs(value, ctx); } - function isAlphaNumQuoteHyphen(cp) { - return cp >= CHAR_A && cp <= CHAR_Z || cp >= CHAR_a && cp <= CHAR_z || cp >= CHAR_0 && cp <= CHAR_9 || cp === CHAR_APOS || cp === CHAR_QUOT || cp === CHAR_LOWBAR || cp === CHAR_HYPHEN; + var blockEndNewlines; + try { + blockEndNewlines = new RegExp("(^|(?\n"; + let chomp; + let endStart; + for (endStart = value.length; endStart > 0; --endStart) { + const ch = value[endStart - 1]; + if (ch !== "\n" && ch !== " " && ch !== " ") + break; + } + let end = value.substring(endStart); + const endNlPos = end.indexOf("\n"); + if (endNlPos === -1) { + chomp = "-"; + } else if (value === end || endNlPos !== end.length - 1) { + chomp = "+"; + if (onChompKeep) + onChompKeep(); + } else { + chomp = ""; + } + if (end) { + value = value.slice(0, -end.length); + if (end[end.length - 1] === "\n") + end = end.slice(0, -1); + end = end.replace(blockEndNewlines, `$&${indent}`); + } + let startWithSpace = false; + let startEnd; + let startNlPos = -1; + for (startEnd = 0; startEnd < value.length; ++startEnd) { + const ch = value[startEnd]; + if (ch === " ") + startWithSpace = true; + else if (ch === "\n") + startNlPos = startEnd; + else + break; + } + let start = value.substring(0, startNlPos < startEnd ? startNlPos + 1 : startEnd); + if (start) { + value = value.substring(start.length); + start = start.replace(/\n+/g, `$&${indent}`); + } + const indentSize = indent ? "2" : "1"; + let header = (startWithSpace ? indentSize : "") + chomp; + if (comment) { + header += " " + commentString(comment.replace(/ ?[\r\n]+/g, " ")); + if (onComment) + onComment(); + } + if (!literal) { + const foldedValue = value.replace(/\n+/g, "\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, "$1$2").replace(/\n+/g, `$&${indent}`); + let literalFallback = false; + const foldOptions = getFoldOptions(ctx, true); + if (blockQuote !== "folded" && type !== Scalar.Scalar.BLOCK_FOLDED) { + foldOptions.onOverflow = () => { + literalFallback = true; + }; + } + const body = foldFlowLines.foldFlowLines(`${start}${foldedValue}${end}`, indent, foldFlowLines.FOLD_BLOCK, foldOptions); + if (!literalFallback) + return `>${header} +${indent}${body}`; + } + value = value.replace(/\n+/g, `$&${indent}`); + return `|${header} +${indent}${start}${value}${end}`; + } + function plainString(item, ctx, onComment, onChompKeep) { + const { type, value } = item; + const { actualString, implicitKey, indent, indentStep, inFlow } = ctx; + if (implicitKey && value.includes("\n") || inFlow && /[[\]{},]/.test(value)) { + return quotedString(value, ctx); + } + if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) { + return implicitKey || inFlow || !value.includes("\n") ? quotedString(value, ctx) : blockString(item, ctx, onComment, onChompKeep); + } + if (!implicitKey && !inFlow && type !== Scalar.Scalar.PLAIN && value.includes("\n")) { + return blockString(item, ctx, onComment, onChompKeep); + } + if (containsDocumentMarker(value)) { + if (indent === "") { + ctx.forceBlockIndent = true; + return blockString(item, ctx, onComment, onChompKeep); + } else if (implicitKey && indent === indentStep) { + return quotedString(value, ctx); + } + } + const str = value.replace(/\n+/g, `$& +${indent}`); + if (actualString) { + const test = (tag) => tag.default && tag.tag !== "tag:yaml.org,2002:str" && tag.test?.test(str); + const { compat, tags } = ctx.doc.schema; + if (tags.some(test) || compat?.some(test)) + return quotedString(value, ctx); + } + return implicitKey ? str : foldFlowLines.foldFlowLines(str, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx, false)); + } + function stringifyString(item, ctx, onComment, onChompKeep) { + const { implicitKey, inFlow } = ctx; + const ss = typeof item.value === "string" ? item : Object.assign({}, item, { value: String(item.value) }); + let { type } = item; + if (type !== Scalar.Scalar.QUOTE_DOUBLE) { + if (/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(ss.value)) + type = Scalar.Scalar.QUOTE_DOUBLE; + } + const _stringify = (_type2) => { + switch (_type2) { + case Scalar.Scalar.BLOCK_FOLDED: + case Scalar.Scalar.BLOCK_LITERAL: + return implicitKey || inFlow ? quotedString(ss.value, ctx) : blockString(ss, ctx, onComment, onChompKeep); + case Scalar.Scalar.QUOTE_DOUBLE: + return doubleQuotedString(ss.value, ctx); + case Scalar.Scalar.QUOTE_SINGLE: + return singleQuotedString(ss.value, ctx); + case Scalar.Scalar.PLAIN: + return plainString(ss, ctx, onComment, onChompKeep); + default: + return null; + } + }; + let res = _stringify(type); + if (res === null) { + const { defaultKeyType, defaultStringType } = ctx.options; + const t2 = implicitKey && defaultKeyType || defaultStringType; + res = _stringify(t2); + if (res === null) + throw new Error(`Unsupported default string type ${t2}`); + } + return res; } - function isAlphaNumHyphen(cp) { - return cp >= CHAR_A && cp <= CHAR_Z || cp >= CHAR_a && cp <= CHAR_z || cp >= CHAR_0 && cp <= CHAR_9 || cp === CHAR_LOWBAR || cp === CHAR_HYPHEN; + exports2.stringifyString = stringifyString; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringify.js +var require_stringify = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringify.js"(exports2) { + init_esm_shims(); + var anchors = require_anchors(); + var identity = require_identity(); + var stringifyComment = require_stringifyComment(); + var stringifyString = require_stringifyString(); + function createStringifyContext(doc, options) { + const opt = Object.assign({ + blockQuote: true, + commentString: stringifyComment.stringifyComment, + defaultKeyType: null, + defaultStringType: "PLAIN", + directives: null, + doubleQuotedAsJSON: false, + doubleQuotedMinMultiLineLength: 40, + falseStr: "false", + flowCollectionPadding: true, + indentSeq: true, + lineWidth: 80, + minContentWidth: 20, + nullStr: "null", + simpleKeys: false, + singleQuote: null, + trueStr: "true", + verifyAliasOrder: true + }, doc.schema.toStringOptions, options); + let inFlow; + switch (opt.collectionStyle) { + case "block": + inFlow = false; + break; + case "flow": + inFlow = true; + break; + default: + inFlow = null; + } + return { + anchors: /* @__PURE__ */ new Set(), + doc, + flowCollectionPadding: opt.flowCollectionPadding ? " " : "", + indent: "", + indentStep: typeof opt.indent === "number" ? " ".repeat(opt.indent) : " ", + inFlow, + options: opt + }; } - var _type = /* @__PURE__ */ Symbol("type"); - var _declared = /* @__PURE__ */ Symbol("declared"); - var hasOwnProperty = Object.prototype.hasOwnProperty; - var defineProperty = Object.defineProperty; - var descriptor = { configurable: true, enumerable: true, writable: true, value: void 0 }; - function hasKey(obj, key) { - if (hasOwnProperty.call(obj, key)) return true; - if (key === "__proto__") defineProperty(obj, "__proto__", descriptor); - return false; + function getTagObject(tags, item) { + if (item.tag) { + const match = tags.filter((t2) => t2.tag === item.tag); + if (match.length > 0) + return match.find((t2) => t2.format === item.format) ?? match[0]; + } + let tagObj = void 0; + let obj; + if (identity.isScalar(item)) { + obj = item.value; + let match = tags.filter((t2) => t2.identify?.(obj)); + if (match.length > 1) { + const testMatch = match.filter((t2) => t2.test); + if (testMatch.length > 0) + match = testMatch; + } + tagObj = match.find((t2) => t2.format === item.format) ?? match.find((t2) => !t2.format); + } else { + obj = item; + tagObj = tags.find((t2) => t2.nodeClass && obj instanceof t2.nodeClass); + } + if (!tagObj) { + const name = obj?.constructor?.name ?? (obj === null ? "null" : typeof obj); + throw new Error(`Tag not resolved for ${name} value`); + } + return tagObj; + } + function stringifyProps(node, tagObj, { anchors: anchors$1, doc }) { + if (!doc.directives) + return ""; + const props = []; + const anchor = (identity.isScalar(node) || identity.isCollection(node)) && node.anchor; + if (anchor && anchors.anchorIsValid(anchor)) { + anchors$1.add(anchor); + props.push(`&${anchor}`); + } + const tag = node.tag ?? (tagObj.default ? null : tagObj.tag); + if (tag) + props.push(doc.directives.tagString(tag)); + return props.join(" "); + } + function stringify(item, ctx, onComment, onChompKeep) { + if (identity.isPair(item)) + return item.toString(ctx, onComment, onChompKeep); + if (identity.isAlias(item)) { + if (ctx.doc.directives) + return item.toString(ctx); + if (ctx.resolvedAliases?.has(item)) { + throw new TypeError(`Cannot stringify circular structure without alias nodes`); + } else { + if (ctx.resolvedAliases) + ctx.resolvedAliases.add(item); + else + ctx.resolvedAliases = /* @__PURE__ */ new Set([item]); + item = item.resolve(ctx.doc); + } + } + let tagObj = void 0; + const node = identity.isNode(item) ? item : ctx.doc.createNode(item, { onTagObj: (o2) => tagObj = o2 }); + tagObj ?? (tagObj = getTagObject(ctx.doc.schema.tags, node)); + const props = stringifyProps(node, tagObj, ctx); + if (props.length > 0) + ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1; + const str = typeof tagObj.stringify === "function" ? tagObj.stringify(node, ctx, onComment, onChompKeep) : identity.isScalar(node) ? stringifyString.stringifyString(node, ctx, onComment, onChompKeep) : node.toString(ctx, onComment, onChompKeep); + if (!props) + return str; + return identity.isScalar(node) || str[0] === "{" || str[0] === "[" ? `${props} ${str}` : `${props} +${ctx.indent}${str}`; } - var INLINE_TABLE = /* @__PURE__ */ Symbol("inline-table"); - function InlineTable() { - return Object.defineProperties({}, { - [_type]: { value: INLINE_TABLE } + exports2.createStringifyContext = createStringifyContext; + exports2.stringify = stringify; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringifyPair.js +var require_stringifyPair = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringifyPair.js"(exports2) { + init_esm_shims(); + var identity = require_identity(); + var Scalar = require_Scalar(); + var stringify = require_stringify(); + var stringifyComment = require_stringifyComment(); + function stringifyPair({ key, value }, ctx, onComment, onChompKeep) { + const { allNullValues, doc, indent, indentStep, options: { commentString, indentSeq, simpleKeys } } = ctx; + let keyComment = identity.isNode(key) && key.comment || null; + if (simpleKeys) { + if (keyComment) { + throw new Error("With simple keys, key nodes cannot have comments"); + } + if (identity.isCollection(key) || !identity.isNode(key) && typeof key === "object") { + const msg = "With simple keys, collection cannot be used as a key value"; + throw new Error(msg); + } + } + let explicitKey = !simpleKeys && (!key || keyComment && value == null && !ctx.inFlow || identity.isCollection(key) || (identity.isScalar(key) ? key.type === Scalar.Scalar.BLOCK_FOLDED || key.type === Scalar.Scalar.BLOCK_LITERAL : typeof key === "object")); + ctx = Object.assign({}, ctx, { + allNullValues: false, + implicitKey: !explicitKey && (simpleKeys || !allNullValues), + indent: indent + indentStep }); + let keyCommentDone = false; + let chompKeep = false; + let str = stringify.stringify(key, ctx, () => keyCommentDone = true, () => chompKeep = true); + if (!explicitKey && !ctx.inFlow && str.length > 1024) { + if (simpleKeys) + throw new Error("With simple keys, single line scalar must not span more than 1024 characters"); + explicitKey = true; + } + if (ctx.inFlow) { + if (allNullValues || value == null) { + if (keyCommentDone && onComment) + onComment(); + return str === "" ? "?" : explicitKey ? `? ${str}` : str; + } + } else if (allNullValues && !simpleKeys || value == null && explicitKey) { + str = `? ${str}`; + if (keyComment && !keyCommentDone) { + str += stringifyComment.lineComment(str, ctx.indent, commentString(keyComment)); + } else if (chompKeep && onChompKeep) + onChompKeep(); + return str; + } + if (keyCommentDone) + keyComment = null; + if (explicitKey) { + if (keyComment) + str += stringifyComment.lineComment(str, ctx.indent, commentString(keyComment)); + str = `? ${str} +${indent}:`; + } else { + str = `${str}:`; + if (keyComment) + str += stringifyComment.lineComment(str, ctx.indent, commentString(keyComment)); + } + let vsb, vcb, valueComment; + if (identity.isNode(value)) { + vsb = !!value.spaceBefore; + vcb = value.commentBefore; + valueComment = value.comment; + } else { + vsb = false; + vcb = null; + valueComment = null; + if (value && typeof value === "object") + value = doc.createNode(value); + } + ctx.implicitKey = false; + if (!explicitKey && !keyComment && identity.isScalar(value)) + ctx.indentAtStart = str.length + 1; + chompKeep = false; + if (!indentSeq && indentStep.length >= 2 && !ctx.inFlow && !explicitKey && identity.isSeq(value) && !value.flow && !value.tag && !value.anchor) { + ctx.indent = ctx.indent.substring(2); + } + let valueCommentDone = false; + const valueStr = stringify.stringify(value, ctx, () => valueCommentDone = true, () => chompKeep = true); + let ws = " "; + if (keyComment || vsb || vcb) { + ws = vsb ? "\n" : ""; + if (vcb) { + const cs = commentString(vcb); + ws += ` +${stringifyComment.indentComment(cs, ctx.indent)}`; + } + if (valueStr === "" && !ctx.inFlow) { + if (ws === "\n" && valueComment) + ws = "\n\n"; + } else { + ws += ` +${ctx.indent}`; + } + } else if (!explicitKey && identity.isCollection(value)) { + const vs0 = valueStr[0]; + const nl0 = valueStr.indexOf("\n"); + const hasNewline = nl0 !== -1; + const flow = ctx.inFlow ?? value.flow ?? value.items.length === 0; + if (hasNewline || !flow) { + let hasPropsLine = false; + if (hasNewline && (vs0 === "&" || vs0 === "!")) { + let sp0 = valueStr.indexOf(" "); + if (vs0 === "&" && sp0 !== -1 && sp0 < nl0 && valueStr[sp0 + 1] === "!") { + sp0 = valueStr.indexOf(" ", sp0 + 1); + } + if (sp0 === -1 || nl0 < sp0) + hasPropsLine = true; + } + if (!hasPropsLine) + ws = ` +${ctx.indent}`; + } + } else if (valueStr === "" || valueStr[0] === "\n") { + ws = ""; + } + str += ws + valueStr; + if (ctx.inFlow) { + if (valueCommentDone && onComment) + onComment(); + } else if (valueComment && !valueCommentDone) { + str += stringifyComment.lineComment(str, ctx.indent, commentString(valueComment)); + } else if (chompKeep && onChompKeep) { + onChompKeep(); + } + return str; } - function isInlineTable(obj) { - if (obj === null || typeof obj !== "object") return false; - return obj[_type] === INLINE_TABLE; + exports2.stringifyPair = stringifyPair; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/log.js +var require_log = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/log.js"(exports2) { + init_esm_shims(); + var node_process = __require("process"); + function debug(logLevel, ...messages) { + if (logLevel === "debug") + console.log(...messages); + } + function warn(logLevel, warning) { + if (logLevel === "debug" || logLevel === "warn") { + if (typeof node_process.emitWarning === "function") + node_process.emitWarning(warning); + else + console.warn(warning); + } } - var TABLE = /* @__PURE__ */ Symbol("table"); - function Table() { - return Object.defineProperties({}, { - [_type]: { value: TABLE }, - [_declared]: { value: false, writable: true } - }); + exports2.debug = debug; + exports2.warn = warn; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/merge.js +var require_merge = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/merge.js"(exports2) { + init_esm_shims(); + var identity = require_identity(); + var Scalar = require_Scalar(); + var MERGE_KEY = "<<"; + var merge = { + identify: (value) => value === MERGE_KEY || typeof value === "symbol" && value.description === MERGE_KEY, + default: "key", + tag: "tag:yaml.org,2002:merge", + test: /^<<$/, + resolve: () => Object.assign(new Scalar.Scalar(Symbol(MERGE_KEY)), { + addToJSMap: addMergeToJSMap + }), + stringify: () => MERGE_KEY + }; + var isMergeKey = (ctx, key) => (merge.identify(key) || identity.isScalar(key) && (!key.type || key.type === Scalar.Scalar.PLAIN) && merge.identify(key.value)) && ctx?.doc.schema.tags.some((tag) => tag.tag === merge.tag && tag.default); + function addMergeToJSMap(ctx, map, value) { + value = ctx && identity.isAlias(value) ? value.resolve(ctx.doc) : value; + if (identity.isSeq(value)) + for (const it of value.items) + mergeValue(ctx, map, it); + else if (Array.isArray(value)) + for (const it of value) + mergeValue(ctx, map, it); + else + mergeValue(ctx, map, value); + } + function mergeValue(ctx, map, value) { + const source = ctx && identity.isAlias(value) ? value.resolve(ctx.doc) : value; + if (!identity.isMap(source)) + throw new Error("Merge sources must be maps or map aliases"); + const srcMap = source.toJSON(null, ctx, Map); + for (const [key, value2] of srcMap) { + if (map instanceof Map) { + if (!map.has(key)) + map.set(key, value2); + } else if (map instanceof Set) { + map.add(key); + } else if (!Object.prototype.hasOwnProperty.call(map, key)) { + Object.defineProperty(map, key, { + value: value2, + writable: true, + enumerable: true, + configurable: true + }); + } + } + return map; } - function isTable(obj) { - if (obj === null || typeof obj !== "object") return false; - return obj[_type] === TABLE; + exports2.addMergeToJSMap = addMergeToJSMap; + exports2.isMergeKey = isMergeKey; + exports2.merge = merge; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/addPairToJSMap.js +var require_addPairToJSMap = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/addPairToJSMap.js"(exports2) { + init_esm_shims(); + var log = require_log(); + var merge = require_merge(); + var stringify = require_stringify(); + var identity = require_identity(); + var toJS = require_toJS(); + function addPairToJSMap(ctx, map, { key, value }) { + if (identity.isNode(key) && key.addToJSMap) + key.addToJSMap(ctx, map, value); + else if (merge.isMergeKey(ctx, key)) + merge.addMergeToJSMap(ctx, map, value); + else { + const jsKey = toJS.toJS(key, "", ctx); + if (map instanceof Map) { + map.set(jsKey, toJS.toJS(value, jsKey, ctx)); + } else if (map instanceof Set) { + map.add(jsKey); + } else { + const stringKey = stringifyKey(key, jsKey, ctx); + const jsValue = toJS.toJS(value, stringKey, ctx); + if (stringKey in map) + Object.defineProperty(map, stringKey, { + value: jsValue, + writable: true, + enumerable: true, + configurable: true + }); + else + map[stringKey] = jsValue; + } + } + return map; } - var _contentType = /* @__PURE__ */ Symbol("content-type"); - var INLINE_LIST = /* @__PURE__ */ Symbol("inline-list"); - function InlineList(type2) { - return Object.defineProperties([], { - [_type]: { value: INLINE_LIST }, - [_contentType]: { value: type2 } - }); + function stringifyKey(key, jsKey, ctx) { + if (jsKey === null) + return ""; + if (typeof jsKey !== "object") + return String(jsKey); + if (identity.isNode(key) && ctx?.doc) { + const strCtx = stringify.createStringifyContext(ctx.doc, {}); + strCtx.anchors = /* @__PURE__ */ new Set(); + for (const node of ctx.anchors.keys()) + strCtx.anchors.add(node.anchor); + strCtx.inFlow = true; + strCtx.inStringifyKey = true; + const strKey = key.toString(strCtx); + if (!ctx.mapKeyWarned) { + let jsonStr = JSON.stringify(strKey); + if (jsonStr.length > 40) + jsonStr = jsonStr.substring(0, 36) + '..."'; + log.warn(ctx.doc.options.logLevel, `Keys with collection values will be stringified due to JS Object restrictions: ${jsonStr}. Set mapAsMap: true to use object keys.`); + ctx.mapKeyWarned = true; + } + return strKey; + } + return JSON.stringify(jsKey); } - function isInlineList(obj) { - if (obj === null || typeof obj !== "object") return false; - return obj[_type] === INLINE_LIST; - } - var LIST = /* @__PURE__ */ Symbol("list"); - function List() { - return Object.defineProperties([], { - [_type]: { value: LIST } + exports2.addPairToJSMap = addPairToJSMap; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/Pair.js +var require_Pair = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/Pair.js"(exports2) { + init_esm_shims(); + var createNode = require_createNode(); + var stringifyPair = require_stringifyPair(); + var addPairToJSMap = require_addPairToJSMap(); + var identity = require_identity(); + function createPair(key, value, ctx) { + const k = createNode.createNode(key, void 0, ctx); + const v2 = createNode.createNode(value, void 0, ctx); + return new Pair(k, v2); + } + var Pair = class _Pair { + constructor(key, value = null) { + Object.defineProperty(this, identity.NODE_TYPE, { value: identity.PAIR }); + this.key = key; + this.value = value; + } + clone(schema) { + let { key, value } = this; + if (identity.isNode(key)) + key = key.clone(schema); + if (identity.isNode(value)) + value = value.clone(schema); + return new _Pair(key, value); + } + toJSON(_, ctx) { + const pair = ctx?.mapAsMap ? /* @__PURE__ */ new Map() : {}; + return addPairToJSMap.addPairToJSMap(ctx, pair, this); + } + toString(ctx, onComment, onChompKeep) { + return ctx?.doc ? stringifyPair.stringifyPair(this, ctx, onComment, onChompKeep) : JSON.stringify(this); + } + }; + exports2.Pair = Pair; + exports2.createPair = createPair; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringifyCollection.js +var require_stringifyCollection = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringifyCollection.js"(exports2) { + init_esm_shims(); + var identity = require_identity(); + var stringify = require_stringify(); + var stringifyComment = require_stringifyComment(); + function stringifyCollection(collection, ctx, options) { + const flow = ctx.inFlow ?? collection.flow; + const stringify2 = flow ? stringifyFlowCollection : stringifyBlockCollection; + return stringify2(collection, ctx, options); + } + function stringifyBlockCollection({ comment, items }, ctx, { blockItemPrefix, flowChars, itemIndent, onChompKeep, onComment }) { + const { indent, options: { commentString } } = ctx; + const itemCtx = Object.assign({}, ctx, { indent: itemIndent, type: null }); + let chompKeep = false; + const lines = []; + for (let i2 = 0; i2 < items.length; ++i2) { + const item = items[i2]; + let comment2 = null; + if (identity.isNode(item)) { + if (!chompKeep && item.spaceBefore) + lines.push(""); + addCommentBefore(ctx, lines, item.commentBefore, chompKeep); + if (item.comment) + comment2 = item.comment; + } else if (identity.isPair(item)) { + const ik = identity.isNode(item.key) ? item.key : null; + if (ik) { + if (!chompKeep && ik.spaceBefore) + lines.push(""); + addCommentBefore(ctx, lines, ik.commentBefore, chompKeep); + } + } + chompKeep = false; + let str2 = stringify.stringify(item, itemCtx, () => comment2 = null, () => chompKeep = true); + if (comment2) + str2 += stringifyComment.lineComment(str2, itemIndent, commentString(comment2)); + if (chompKeep && comment2) + chompKeep = false; + lines.push(blockItemPrefix + str2); + } + let str; + if (lines.length === 0) { + str = flowChars.start + flowChars.end; + } else { + str = lines[0]; + for (let i2 = 1; i2 < lines.length; ++i2) { + const line = lines[i2]; + str += line ? ` +${indent}${line}` : "\n"; + } + } + if (comment) { + str += "\n" + stringifyComment.indentComment(commentString(comment), indent); + if (onComment) + onComment(); + } else if (chompKeep && onChompKeep) + onChompKeep(); + return str; + } + function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) { + const { indent, indentStep, flowCollectionPadding: fcPadding, options: { commentString } } = ctx; + itemIndent += indentStep; + const itemCtx = Object.assign({}, ctx, { + indent: itemIndent, + inFlow: true, + type: null }); - } - function isList(obj) { - if (obj === null || typeof obj !== "object") return false; - return obj[_type] === LIST; - } - var _custom; - try { - const utilInspect = eval("require('util').inspect"); - _custom = utilInspect.custom; - } catch (_) { - } - var _inspect = _custom || "inspect"; - var BoxedBigInt = class { - constructor(value) { - try { - this.value = global.BigInt.asIntN(64, value); - } catch (_) { - this.value = null; + let reqNewline = false; + let linesAtValue = 0; + const lines = []; + for (let i2 = 0; i2 < items.length; ++i2) { + const item = items[i2]; + let comment = null; + if (identity.isNode(item)) { + if (item.spaceBefore) + lines.push(""); + addCommentBefore(ctx, lines, item.commentBefore, false); + if (item.comment) + comment = item.comment; + } else if (identity.isPair(item)) { + const ik = identity.isNode(item.key) ? item.key : null; + if (ik) { + if (ik.spaceBefore) + lines.push(""); + addCommentBefore(ctx, lines, ik.commentBefore, false); + if (ik.comment) + reqNewline = true; + } + const iv = identity.isNode(item.value) ? item.value : null; + if (iv) { + if (iv.comment) + comment = iv.comment; + if (iv.commentBefore) + reqNewline = true; + } else if (item.value == null && ik?.comment) { + comment = ik.comment; + } + } + if (comment) + reqNewline = true; + let str = stringify.stringify(item, itemCtx, () => comment = null); + if (i2 < items.length - 1) + str += ","; + if (comment) + str += stringifyComment.lineComment(str, itemIndent, commentString(comment)); + if (!reqNewline && (lines.length > linesAtValue || str.includes("\n"))) + reqNewline = true; + lines.push(str); + linesAtValue = lines.length; + } + const { start, end } = flowChars; + if (lines.length === 0) { + return start + end; + } else { + if (!reqNewline) { + const len = lines.reduce((sum, line) => sum + line.length + 2, 2); + reqNewline = ctx.options.lineWidth > 0 && len > ctx.options.lineWidth; + } + if (reqNewline) { + let str = start; + for (const line of lines) + str += line ? ` +${indentStep}${indent}${line}` : "\n"; + return `${str} +${indent}${end}`; + } else { + return `${start}${fcPadding}${lines.join(" ")}${fcPadding}${end}`; } - Object.defineProperty(this, _type, { value: INTEGER }); } - isNaN() { - return this.value === null; + } + function addCommentBefore({ indent, options: { commentString } }, lines, comment, chompKeep) { + if (comment && chompKeep) + comment = comment.replace(/^\n+/, ""); + if (comment) { + const ic = stringifyComment.indentComment(commentString(comment), indent); + lines.push(ic.trimStart()); } - /* istanbul ignore next */ - toString() { - return String(this.value); + } + exports2.stringifyCollection = stringifyCollection; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/YAMLMap.js +var require_YAMLMap = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/YAMLMap.js"(exports2) { + init_esm_shims(); + var stringifyCollection = require_stringifyCollection(); + var addPairToJSMap = require_addPairToJSMap(); + var Collection = require_Collection(); + var identity = require_identity(); + var Pair = require_Pair(); + var Scalar = require_Scalar(); + function findPair(items, key) { + const k = identity.isScalar(key) ? key.value : key; + for (const it of items) { + if (identity.isPair(it)) { + if (it.key === key || it.key === k) + return it; + if (identity.isScalar(it.key) && it.key.value === k) + return it; + } } - /* istanbul ignore next */ - [_inspect]() { - return `[BigInt: ${this.toString()}]}`; + return void 0; + } + var YAMLMap = class extends Collection.Collection { + static get tagName() { + return "tag:yaml.org,2002:map"; + } + constructor(schema) { + super(identity.MAP, schema); + this.items = []; + } + /** + * A generic collection parsing method that can be extended + * to other node classes that inherit from YAMLMap + */ + static from(schema, obj, ctx) { + const { keepUndefined, replacer } = ctx; + const map = new this(schema); + const add = (key, value) => { + if (typeof replacer === "function") + value = replacer.call(obj, key, value); + else if (Array.isArray(replacer) && !replacer.includes(key)) + return; + if (value !== void 0 || keepUndefined) + map.items.push(Pair.createPair(key, value, ctx)); + }; + if (obj instanceof Map) { + for (const [key, value] of obj) + add(key, value); + } else if (obj && typeof obj === "object") { + for (const key of Object.keys(obj)) + add(key, obj[key]); + } + if (typeof schema.sortMapEntries === "function") { + map.items.sort(schema.sortMapEntries); + } + return map; + } + /** + * Adds a value to the collection. + * + * @param overwrite - If not set `true`, using a key that is already in the + * collection will throw. Otherwise, overwrites the previous value. + */ + add(pair, overwrite) { + let _pair; + if (identity.isPair(pair)) + _pair = pair; + else if (!pair || typeof pair !== "object" || !("key" in pair)) { + _pair = new Pair.Pair(pair, pair?.value); + } else + _pair = new Pair.Pair(pair.key, pair.value); + const prev = findPair(this.items, _pair.key); + const sortEntries = this.schema?.sortMapEntries; + if (prev) { + if (!overwrite) + throw new Error(`Key ${_pair.key} already set`); + if (identity.isScalar(prev.value) && Scalar.isScalarValue(_pair.value)) + prev.value.value = _pair.value; + else + prev.value = _pair.value; + } else if (sortEntries) { + const i2 = this.items.findIndex((item) => sortEntries(_pair, item) < 0); + if (i2 === -1) + this.items.push(_pair); + else + this.items.splice(i2, 0, _pair); + } else { + this.items.push(_pair); + } } - valueOf() { - return this.value; + delete(key) { + const it = findPair(this.items, key); + if (!it) + return false; + const del = this.items.splice(this.items.indexOf(it), 1); + return del.length > 0; + } + get(key, keepScalar) { + const it = findPair(this.items, key); + const node = it?.value; + return (!keepScalar && identity.isScalar(node) ? node.value : node) ?? void 0; + } + has(key) { + return !!findPair(this.items, key); + } + set(key, value) { + this.add(new Pair.Pair(key, value), true); + } + /** + * @param ctx - Conversion context, originally set in Document#toJS() + * @param {Class} Type - If set, forces the returned collection type + * @returns Instance of Type, Map, or Object + */ + toJSON(_, ctx, Type) { + const map = Type ? new Type() : ctx?.mapAsMap ? /* @__PURE__ */ new Map() : {}; + if (ctx?.onCreate) + ctx.onCreate(map); + for (const item of this.items) + addPairToJSMap.addPairToJSMap(ctx, map, item); + return map; + } + toString(ctx, onComment, onChompKeep) { + if (!ctx) + return JSON.stringify(this); + for (const item of this.items) { + if (!identity.isPair(item)) + throw new Error(`Map items must all be pairs; found ${JSON.stringify(item)} instead`); + } + if (!ctx.allNullValues && this.hasAllNullValues(false)) + ctx = Object.assign({}, ctx, { allNullValues: true }); + return stringifyCollection.stringifyCollection(this, ctx, { + blockItemPrefix: "", + flowChars: { start: "{", end: "}" }, + itemIndent: ctx.indent || "", + onChompKeep, + onComment + }); } }; - var INTEGER = /* @__PURE__ */ Symbol("integer"); - function Integer(value) { - let num = Number(value); - if (Object.is(num, -0)) num = 0; - if (global.BigInt && !Number.isSafeInteger(num)) { - return new BoxedBigInt(value); - } else { - return Object.defineProperties(new Number(num), { - isNaN: { value: function() { - return isNaN(this); - } }, - [_type]: { value: INTEGER }, - [_inspect]: { value: () => `[Integer: ${value}]` } + exports2.YAMLMap = YAMLMap; + exports2.findPair = findPair; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/common/map.js +var require_map = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/common/map.js"(exports2) { + init_esm_shims(); + var identity = require_identity(); + var YAMLMap = require_YAMLMap(); + var map = { + collection: "map", + default: true, + nodeClass: YAMLMap.YAMLMap, + tag: "tag:yaml.org,2002:map", + resolve(map2, onError) { + if (!identity.isMap(map2)) + onError("Expected a mapping for this tag"); + return map2; + }, + createNode: (schema, obj, ctx) => YAMLMap.YAMLMap.from(schema, obj, ctx) + }; + exports2.map = map; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/YAMLSeq.js +var require_YAMLSeq = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/YAMLSeq.js"(exports2) { + init_esm_shims(); + var createNode = require_createNode(); + var stringifyCollection = require_stringifyCollection(); + var Collection = require_Collection(); + var identity = require_identity(); + var Scalar = require_Scalar(); + var toJS = require_toJS(); + var YAMLSeq = class extends Collection.Collection { + static get tagName() { + return "tag:yaml.org,2002:seq"; + } + constructor(schema) { + super(identity.SEQ, schema); + this.items = []; + } + add(value) { + this.items.push(value); + } + /** + * Removes a value from the collection. + * + * `key` must contain a representation of an integer for this to succeed. + * It may be wrapped in a `Scalar`. + * + * @returns `true` if the item was found and removed. + */ + delete(key) { + const idx = asItemIndex(key); + if (typeof idx !== "number") + return false; + const del = this.items.splice(idx, 1); + return del.length > 0; + } + get(key, keepScalar) { + const idx = asItemIndex(key); + if (typeof idx !== "number") + return void 0; + const it = this.items[idx]; + return !keepScalar && identity.isScalar(it) ? it.value : it; + } + /** + * Checks if the collection includes a value with the key `key`. + * + * `key` must contain a representation of an integer for this to succeed. + * It may be wrapped in a `Scalar`. + */ + has(key) { + const idx = asItemIndex(key); + return typeof idx === "number" && idx < this.items.length; + } + /** + * Sets a value in this collection. For `!!set`, `value` needs to be a + * boolean to add/remove the item from the set. + * + * If `key` does not contain a representation of an integer, this will throw. + * It may be wrapped in a `Scalar`. + */ + set(key, value) { + const idx = asItemIndex(key); + if (typeof idx !== "number") + throw new Error(`Expected a valid index, not ${key}.`); + const prev = this.items[idx]; + if (identity.isScalar(prev) && Scalar.isScalarValue(value)) + prev.value = value; + else + this.items[idx] = value; + } + toJSON(_, ctx) { + const seq = []; + if (ctx?.onCreate) + ctx.onCreate(seq); + let i2 = 0; + for (const item of this.items) + seq.push(toJS.toJS(item, String(i2++), ctx)); + return seq; + } + toString(ctx, onComment, onChompKeep) { + if (!ctx) + return JSON.stringify(this); + return stringifyCollection.stringifyCollection(this, ctx, { + blockItemPrefix: "- ", + flowChars: { start: "[", end: "]" }, + itemIndent: (ctx.indent || "") + " ", + onChompKeep, + onComment }); } - } - function isInteger(obj) { - if (obj === null || typeof obj !== "object") return false; - return obj[_type] === INTEGER; - } - var FLOAT = /* @__PURE__ */ Symbol("float"); - function Float(value) { - return Object.defineProperties(new Number(value), { - [_type]: { value: FLOAT }, - [_inspect]: { value: () => `[Float: ${value}]` } - }); - } - function isFloat(obj) { - if (obj === null || typeof obj !== "object") return false; - return obj[_type] === FLOAT; - } - function tomlType(value) { - const type2 = typeof value; - if (type2 === "object") { - if (value === null) return "null"; - if (value instanceof Date) return "datetime"; - if (_type in value) { - switch (value[_type]) { - case INLINE_TABLE: - return "inline-table"; - case INLINE_LIST: - return "inline-list"; - /* istanbul ignore next */ - case TABLE: - return "table"; - /* istanbul ignore next */ - case LIST: - return "list"; - case FLOAT: - return "float"; - case INTEGER: - return "integer"; + static from(schema, obj, ctx) { + const { replacer } = ctx; + const seq = new this(schema); + if (obj && Symbol.iterator in Object(obj)) { + let i2 = 0; + for (let it of obj) { + if (typeof replacer === "function") { + const key = obj instanceof Set ? it : String(i2++); + it = replacer.call(obj, key, it); + } + seq.items.push(createNode.createNode(it, void 0, ctx)); } } + return seq; } - return type2; + }; + function asItemIndex(key) { + let idx = identity.isScalar(key) ? key.value : key; + if (idx && typeof idx === "string") + idx = Number(idx); + return typeof idx === "number" && Number.isInteger(idx) && idx >= 0 ? idx : null; } - function makeParserClass(Parser2) { - class TOMLParser extends Parser2 { - constructor() { - super(); - this.ctx = this.obj = Table(); + exports2.YAMLSeq = YAMLSeq; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/common/seq.js +var require_seq = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/common/seq.js"(exports2) { + init_esm_shims(); + var identity = require_identity(); + var YAMLSeq = require_YAMLSeq(); + var seq = { + collection: "seq", + default: true, + nodeClass: YAMLSeq.YAMLSeq, + tag: "tag:yaml.org,2002:seq", + resolve(seq2, onError) { + if (!identity.isSeq(seq2)) + onError("Expected a sequence for this tag"); + return seq2; + }, + createNode: (schema, obj, ctx) => YAMLSeq.YAMLSeq.from(schema, obj, ctx) + }; + exports2.seq = seq; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/common/string.js +var require_string = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/common/string.js"(exports2) { + init_esm_shims(); + var stringifyString = require_stringifyString(); + var string = { + identify: (value) => typeof value === "string", + default: true, + tag: "tag:yaml.org,2002:str", + resolve: (str) => str, + stringify(item, ctx, onComment, onChompKeep) { + ctx = Object.assign({ actualString: true }, ctx); + return stringifyString.stringifyString(item, ctx, onComment, onChompKeep); + } + }; + exports2.string = string; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/common/null.js +var require_null = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/common/null.js"(exports2) { + init_esm_shims(); + var Scalar = require_Scalar(); + var nullTag = { + identify: (value) => value == null, + createNode: () => new Scalar.Scalar(null), + default: true, + tag: "tag:yaml.org,2002:null", + test: /^(?:~|[Nn]ull|NULL)?$/, + resolve: () => new Scalar.Scalar(null), + stringify: ({ source }, ctx) => typeof source === "string" && nullTag.test.test(source) ? source : ctx.options.nullStr + }; + exports2.nullTag = nullTag; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/core/bool.js +var require_bool = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/core/bool.js"(exports2) { + init_esm_shims(); + var Scalar = require_Scalar(); + var boolTag = { + identify: (value) => typeof value === "boolean", + default: true, + tag: "tag:yaml.org,2002:bool", + test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/, + resolve: (str) => new Scalar.Scalar(str[0] === "t" || str[0] === "T"), + stringify({ source, value }, ctx) { + if (source && boolTag.test.test(source)) { + const sv = source[0] === "t" || source[0] === "T"; + if (value === sv) + return source; + } + return value ? ctx.options.trueStr : ctx.options.falseStr; + } + }; + exports2.boolTag = boolTag; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringifyNumber.js +var require_stringifyNumber = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringifyNumber.js"(exports2) { + init_esm_shims(); + function stringifyNumber({ format, minFractionDigits, tag, value }) { + if (typeof value === "bigint") + return String(value); + const num = typeof value === "number" ? value : Number(value); + if (!isFinite(num)) + return isNaN(num) ? ".nan" : num < 0 ? "-.inf" : ".inf"; + let n2 = Object.is(value, -0) ? "-0" : JSON.stringify(value); + if (!format && minFractionDigits && (!tag || tag === "tag:yaml.org,2002:float") && /^\d/.test(n2)) { + let i2 = n2.indexOf("."); + if (i2 < 0) { + i2 = n2.length; + n2 += "."; + } + let d2 = minFractionDigits - (n2.length - i2 - 1); + while (d2-- > 0) + n2 += "0"; + } + return n2; + } + exports2.stringifyNumber = stringifyNumber; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/core/float.js +var require_float = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/core/float.js"(exports2) { + init_esm_shims(); + var Scalar = require_Scalar(); + var stringifyNumber = require_stringifyNumber(); + var floatNaN = { + identify: (value) => typeof value === "number", + default: true, + tag: "tag:yaml.org,2002:float", + test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/, + resolve: (str) => str.slice(-3).toLowerCase() === "nan" ? NaN : str[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY, + stringify: stringifyNumber.stringifyNumber + }; + var floatExp = { + identify: (value) => typeof value === "number", + default: true, + tag: "tag:yaml.org,2002:float", + format: "EXP", + test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/, + resolve: (str) => parseFloat(str), + stringify(node) { + const num = Number(node.value); + return isFinite(num) ? num.toExponential() : stringifyNumber.stringifyNumber(node); + } + }; + var float = { + identify: (value) => typeof value === "number", + default: true, + tag: "tag:yaml.org,2002:float", + test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/, + resolve(str) { + const node = new Scalar.Scalar(parseFloat(str)); + const dot = str.indexOf("."); + if (dot !== -1 && str[str.length - 1] === "0") + node.minFractionDigits = str.length - dot - 1; + return node; + }, + stringify: stringifyNumber.stringifyNumber + }; + exports2.float = float; + exports2.floatExp = floatExp; + exports2.floatNaN = floatNaN; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/core/int.js +var require_int = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/core/int.js"(exports2) { + init_esm_shims(); + var stringifyNumber = require_stringifyNumber(); + var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value); + var intResolve = (str, offset, radix, { intAsBigInt }) => intAsBigInt ? BigInt(str) : parseInt(str.substring(offset), radix); + function intStringify(node, radix, prefix) { + const { value } = node; + if (intIdentify(value) && value >= 0) + return prefix + value.toString(radix); + return stringifyNumber.stringifyNumber(node); + } + var intOct = { + identify: (value) => intIdentify(value) && value >= 0, + default: true, + tag: "tag:yaml.org,2002:int", + format: "OCT", + test: /^0o[0-7]+$/, + resolve: (str, _onError, opt) => intResolve(str, 2, 8, opt), + stringify: (node) => intStringify(node, 8, "0o") + }; + var int = { + identify: intIdentify, + default: true, + tag: "tag:yaml.org,2002:int", + test: /^[-+]?[0-9]+$/, + resolve: (str, _onError, opt) => intResolve(str, 0, 10, opt), + stringify: stringifyNumber.stringifyNumber + }; + var intHex = { + identify: (value) => intIdentify(value) && value >= 0, + default: true, + tag: "tag:yaml.org,2002:int", + format: "HEX", + test: /^0x[0-9a-fA-F]+$/, + resolve: (str, _onError, opt) => intResolve(str, 2, 16, opt), + stringify: (node) => intStringify(node, 16, "0x") + }; + exports2.int = int; + exports2.intHex = intHex; + exports2.intOct = intOct; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/core/schema.js +var require_schema = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/core/schema.js"(exports2) { + init_esm_shims(); + var map = require_map(); + var _null = require_null(); + var seq = require_seq(); + var string = require_string(); + var bool = require_bool(); + var float = require_float(); + var int = require_int(); + var schema = [ + map.map, + seq.seq, + string.string, + _null.nullTag, + bool.boolTag, + int.intOct, + int.int, + int.intHex, + float.floatNaN, + float.floatExp, + float.float + ]; + exports2.schema = schema; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/json/schema.js +var require_schema2 = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/json/schema.js"(exports2) { + init_esm_shims(); + var Scalar = require_Scalar(); + var map = require_map(); + var seq = require_seq(); + function intIdentify(value) { + return typeof value === "bigint" || Number.isInteger(value); + } + var stringifyJSON = ({ value }) => JSON.stringify(value); + var jsonScalars = [ + { + identify: (value) => typeof value === "string", + default: true, + tag: "tag:yaml.org,2002:str", + resolve: (str) => str, + stringify: stringifyJSON + }, + { + identify: (value) => value == null, + createNode: () => new Scalar.Scalar(null), + default: true, + tag: "tag:yaml.org,2002:null", + test: /^null$/, + resolve: () => null, + stringify: stringifyJSON + }, + { + identify: (value) => typeof value === "boolean", + default: true, + tag: "tag:yaml.org,2002:bool", + test: /^true$|^false$/, + resolve: (str) => str === "true", + stringify: stringifyJSON + }, + { + identify: intIdentify, + default: true, + tag: "tag:yaml.org,2002:int", + test: /^-?(?:0|[1-9][0-9]*)$/, + resolve: (str, _onError, { intAsBigInt }) => intAsBigInt ? BigInt(str) : parseInt(str, 10), + stringify: ({ value }) => intIdentify(value) ? value.toString() : JSON.stringify(value) + }, + { + identify: (value) => typeof value === "number", + default: true, + tag: "tag:yaml.org,2002:float", + test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/, + resolve: (str) => parseFloat(str), + stringify: stringifyJSON + } + ]; + var jsonError = { + default: true, + tag: "", + test: /^/, + resolve(str, onError) { + onError(`Unresolved plain scalar ${JSON.stringify(str)}`); + return str; + } + }; + var schema = [map.map, seq.seq].concat(jsonScalars, jsonError); + exports2.schema = schema; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/binary.js +var require_binary = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/binary.js"(exports2) { + init_esm_shims(); + var node_buffer = __require("buffer"); + var Scalar = require_Scalar(); + var stringifyString = require_stringifyString(); + var binary = { + identify: (value) => value instanceof Uint8Array, + // Buffer inherits from Uint8Array + default: false, + tag: "tag:yaml.org,2002:binary", + /** + * Returns a Buffer in node and an Uint8Array in browsers + * + * To use the resulting buffer as an image, you'll want to do something like: + * + * const blob = new Blob([buffer], { type: 'image/jpeg' }) + * document.querySelector('#photo').src = URL.createObjectURL(blob) + */ + resolve(src, onError) { + if (typeof node_buffer.Buffer === "function") { + return node_buffer.Buffer.from(src, "base64"); + } else if (typeof atob === "function") { + const str = atob(src.replace(/[\n\r]/g, "")); + const buffer = new Uint8Array(str.length); + for (let i2 = 0; i2 < str.length; ++i2) + buffer[i2] = str.charCodeAt(i2); + return buffer; + } else { + onError("This environment does not support reading binary tags; either Buffer or atob is required"); + return src; } - /* MATCH HELPER */ - atEndOfWord() { - return this.char === CHAR_NUM || this.char === CTRL_I || this.char === CHAR_SP || this.atEndOfLine(); + }, + stringify({ comment, type, value }, ctx, onComment, onChompKeep) { + if (!value) + return ""; + const buf = value; + let str; + if (typeof node_buffer.Buffer === "function") { + str = buf instanceof node_buffer.Buffer ? buf.toString("base64") : node_buffer.Buffer.from(buf.buffer).toString("base64"); + } else if (typeof btoa === "function") { + let s2 = ""; + for (let i2 = 0; i2 < buf.length; ++i2) + s2 += String.fromCharCode(buf[i2]); + str = btoa(s2); + } else { + throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required"); } - atEndOfLine() { - return this.char === Parser2.END || this.char === CTRL_J || this.char === CTRL_M; + type ?? (type = Scalar.Scalar.BLOCK_LITERAL); + if (type !== Scalar.Scalar.QUOTE_DOUBLE) { + const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth); + const n2 = Math.ceil(str.length / lineWidth); + const lines = new Array(n2); + for (let i2 = 0, o2 = 0; i2 < n2; ++i2, o2 += lineWidth) { + lines[i2] = str.substr(o2, lineWidth); + } + str = lines.join(type === Scalar.Scalar.BLOCK_LITERAL ? "\n" : " "); } - parseStart() { - if (this.char === Parser2.END) { - return null; - } else if (this.char === CHAR_LSQB) { - return this.call(this.parseTableOrList); - } else if (this.char === CHAR_NUM) { - return this.call(this.parseComment); - } else if (this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) { - return null; - } else if (isAlphaNumQuoteHyphen(this.char)) { - return this.callNow(this.parseAssignStatement); + return stringifyString.stringifyString({ comment, type, value: str }, ctx, onComment, onChompKeep); + } + }; + exports2.binary = binary; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +var require_pairs = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/pairs.js"(exports2) { + init_esm_shims(); + var identity = require_identity(); + var Pair = require_Pair(); + var Scalar = require_Scalar(); + var YAMLSeq = require_YAMLSeq(); + function resolvePairs(seq, onError) { + if (identity.isSeq(seq)) { + for (let i2 = 0; i2 < seq.items.length; ++i2) { + let item = seq.items[i2]; + if (identity.isPair(item)) + continue; + else if (identity.isMap(item)) { + if (item.items.length > 1) + onError("Each pair must have its own sequence indicator"); + const pair = item.items[0] || new Pair.Pair(new Scalar.Scalar(null)); + if (item.commentBefore) + pair.key.commentBefore = pair.key.commentBefore ? `${item.commentBefore} +${pair.key.commentBefore}` : item.commentBefore; + if (item.comment) { + const cn = pair.value ?? pair.key; + cn.comment = cn.comment ? `${item.comment} +${cn.comment}` : item.comment; + } + item = pair; + } + seq.items[i2] = identity.isPair(item) ? item : new Pair.Pair(item); + } + } else + onError("Expected a sequence for this tag"); + return seq; + } + function createPairs(schema, iterable, ctx) { + const { replacer } = ctx; + const pairs2 = new YAMLSeq.YAMLSeq(schema); + pairs2.tag = "tag:yaml.org,2002:pairs"; + let i2 = 0; + if (iterable && Symbol.iterator in Object(iterable)) + for (let it of iterable) { + if (typeof replacer === "function") + it = replacer.call(iterable, String(i2++), it); + let key, value; + if (Array.isArray(it)) { + if (it.length === 2) { + key = it[0]; + value = it[1]; + } else + throw new TypeError(`Expected [key, value] tuple: ${it}`); + } else if (it && it instanceof Object) { + const keys = Object.keys(it); + if (keys.length === 1) { + key = keys[0]; + value = it[key]; + } else { + throw new TypeError(`Expected tuple with one key, not ${keys.length} keys`); + } } else { - throw this.error(new TomlError(`Unknown character "${this.char}"`)); + key = it; } + pairs2.items.push(Pair.createPair(key, value, ctx)); } - // HELPER, this strips any whitespace and comments to the end of the line - // then RETURNS. Last state in a production. - parseWhitespaceToEOL() { - if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) { - return null; - } else if (this.char === CHAR_NUM) { - return this.goto(this.parseComment); - } else if (this.char === Parser2.END || this.char === CTRL_J) { - return this.return(); + return pairs2; + } + var pairs = { + collection: "seq", + default: false, + tag: "tag:yaml.org,2002:pairs", + resolve: resolvePairs, + createNode: createPairs + }; + exports2.createPairs = createPairs; + exports2.pairs = pairs; + exports2.resolvePairs = resolvePairs; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/omap.js +var require_omap = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/omap.js"(exports2) { + init_esm_shims(); + var identity = require_identity(); + var toJS = require_toJS(); + var YAMLMap = require_YAMLMap(); + var YAMLSeq = require_YAMLSeq(); + var pairs = require_pairs(); + var YAMLOMap = class _YAMLOMap extends YAMLSeq.YAMLSeq { + constructor() { + super(); + this.add = YAMLMap.YAMLMap.prototype.add.bind(this); + this.delete = YAMLMap.YAMLMap.prototype.delete.bind(this); + this.get = YAMLMap.YAMLMap.prototype.get.bind(this); + this.has = YAMLMap.YAMLMap.prototype.has.bind(this); + this.set = YAMLMap.YAMLMap.prototype.set.bind(this); + this.tag = _YAMLOMap.tag; + } + /** + * If `ctx` is given, the return type is actually `Map`, + * but TypeScript won't allow widening the signature of a child method. + */ + toJSON(_, ctx) { + if (!ctx) + return super.toJSON(_); + const map = /* @__PURE__ */ new Map(); + if (ctx?.onCreate) + ctx.onCreate(map); + for (const pair of this.items) { + let key, value; + if (identity.isPair(pair)) { + key = toJS.toJS(pair.key, "", ctx); + value = toJS.toJS(pair.value, key, ctx); } else { - throw this.error(new TomlError("Unexpected character, expected only whitespace or comments till end of line")); + key = toJS.toJS(pair, "", ctx); } + if (map.has(key)) + throw new Error("Ordered maps must not include duplicate keys"); + map.set(key, value); } - /* ASSIGNMENT: key = value */ - parseAssignStatement() { - return this.callNow(this.parseAssign, this.recordAssignStatement); - } - recordAssignStatement(kv) { - let target = this.ctx; - let finalKey = kv.key.pop(); - for (let kw of kv.key) { - if (hasKey(target, kw) && (!isTable(target[kw]) || target[kw][_declared])) { - throw this.error(new TomlError("Can't redefine existing key")); + return map; + } + static from(schema, iterable, ctx) { + const pairs$1 = pairs.createPairs(schema, iterable, ctx); + const omap2 = new this(); + omap2.items = pairs$1.items; + return omap2; + } + }; + YAMLOMap.tag = "tag:yaml.org,2002:omap"; + var omap = { + collection: "seq", + identify: (value) => value instanceof Map, + nodeClass: YAMLOMap, + default: false, + tag: "tag:yaml.org,2002:omap", + resolve(seq, onError) { + const pairs$1 = pairs.resolvePairs(seq, onError); + const seenKeys = []; + for (const { key } of pairs$1.items) { + if (identity.isScalar(key)) { + if (seenKeys.includes(key.value)) { + onError(`Ordered maps must not include duplicate keys: ${key.value}`); + } else { + seenKeys.push(key.value); } - target = target[kw] = target[kw] || Table(); } - if (hasKey(target, finalKey)) { - throw this.error(new TomlError("Can't redefine existing key")); + } + return Object.assign(new YAMLOMap(), pairs$1); + }, + createNode: (schema, iterable, ctx) => YAMLOMap.from(schema, iterable, ctx) + }; + exports2.YAMLOMap = YAMLOMap; + exports2.omap = omap; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/bool.js +var require_bool2 = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/bool.js"(exports2) { + init_esm_shims(); + var Scalar = require_Scalar(); + function boolStringify({ value, source }, ctx) { + const boolObj = value ? trueTag : falseTag; + if (source && boolObj.test.test(source)) + return source; + return value ? ctx.options.trueStr : ctx.options.falseStr; + } + var trueTag = { + identify: (value) => value === true, + default: true, + tag: "tag:yaml.org,2002:bool", + test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/, + resolve: () => new Scalar.Scalar(true), + stringify: boolStringify + }; + var falseTag = { + identify: (value) => value === false, + default: true, + tag: "tag:yaml.org,2002:bool", + test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/, + resolve: () => new Scalar.Scalar(false), + stringify: boolStringify + }; + exports2.falseTag = falseTag; + exports2.trueTag = trueTag; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/float.js +var require_float2 = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/float.js"(exports2) { + init_esm_shims(); + var Scalar = require_Scalar(); + var stringifyNumber = require_stringifyNumber(); + var floatNaN = { + identify: (value) => typeof value === "number", + default: true, + tag: "tag:yaml.org,2002:float", + test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/, + resolve: (str) => str.slice(-3).toLowerCase() === "nan" ? NaN : str[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY, + stringify: stringifyNumber.stringifyNumber + }; + var floatExp = { + identify: (value) => typeof value === "number", + default: true, + tag: "tag:yaml.org,2002:float", + format: "EXP", + test: /^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/, + resolve: (str) => parseFloat(str.replace(/_/g, "")), + stringify(node) { + const num = Number(node.value); + return isFinite(num) ? num.toExponential() : stringifyNumber.stringifyNumber(node); + } + }; + var float = { + identify: (value) => typeof value === "number", + default: true, + tag: "tag:yaml.org,2002:float", + test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/, + resolve(str) { + const node = new Scalar.Scalar(parseFloat(str.replace(/_/g, ""))); + const dot = str.indexOf("."); + if (dot !== -1) { + const f2 = str.substring(dot + 1).replace(/_/g, ""); + if (f2[f2.length - 1] === "0") + node.minFractionDigits = f2.length; + } + return node; + }, + stringify: stringifyNumber.stringifyNumber + }; + exports2.float = float; + exports2.floatExp = floatExp; + exports2.floatNaN = floatNaN; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/int.js +var require_int2 = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/int.js"(exports2) { + init_esm_shims(); + var stringifyNumber = require_stringifyNumber(); + var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value); + function intResolve(str, offset, radix, { intAsBigInt }) { + const sign = str[0]; + if (sign === "-" || sign === "+") + offset += 1; + str = str.substring(offset).replace(/_/g, ""); + if (intAsBigInt) { + switch (radix) { + case 2: + str = `0b${str}`; + break; + case 8: + str = `0o${str}`; + break; + case 16: + str = `0x${str}`; + break; + } + const n3 = BigInt(str); + return sign === "-" ? BigInt(-1) * n3 : n3; + } + const n2 = parseInt(str, radix); + return sign === "-" ? -1 * n2 : n2; + } + function intStringify(node, radix, prefix) { + const { value } = node; + if (intIdentify(value)) { + const str = value.toString(radix); + return value < 0 ? "-" + prefix + str.substr(1) : prefix + str; + } + return stringifyNumber.stringifyNumber(node); + } + var intBin = { + identify: intIdentify, + default: true, + tag: "tag:yaml.org,2002:int", + format: "BIN", + test: /^[-+]?0b[0-1_]+$/, + resolve: (str, _onError, opt) => intResolve(str, 2, 2, opt), + stringify: (node) => intStringify(node, 2, "0b") + }; + var intOct = { + identify: intIdentify, + default: true, + tag: "tag:yaml.org,2002:int", + format: "OCT", + test: /^[-+]?0[0-7_]+$/, + resolve: (str, _onError, opt) => intResolve(str, 1, 8, opt), + stringify: (node) => intStringify(node, 8, "0") + }; + var int = { + identify: intIdentify, + default: true, + tag: "tag:yaml.org,2002:int", + test: /^[-+]?[0-9][0-9_]*$/, + resolve: (str, _onError, opt) => intResolve(str, 0, 10, opt), + stringify: stringifyNumber.stringifyNumber + }; + var intHex = { + identify: intIdentify, + default: true, + tag: "tag:yaml.org,2002:int", + format: "HEX", + test: /^[-+]?0x[0-9a-fA-F_]+$/, + resolve: (str, _onError, opt) => intResolve(str, 2, 16, opt), + stringify: (node) => intStringify(node, 16, "0x") + }; + exports2.int = int; + exports2.intBin = intBin; + exports2.intHex = intHex; + exports2.intOct = intOct; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/set.js +var require_set = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/set.js"(exports2) { + init_esm_shims(); + var identity = require_identity(); + var Pair = require_Pair(); + var YAMLMap = require_YAMLMap(); + var YAMLSet = class _YAMLSet extends YAMLMap.YAMLMap { + constructor(schema) { + super(schema); + this.tag = _YAMLSet.tag; + } + add(key) { + let pair; + if (identity.isPair(key)) + pair = key; + else if (key && typeof key === "object" && "key" in key && "value" in key && key.value === null) + pair = new Pair.Pair(key.key, null); + else + pair = new Pair.Pair(key, null); + const prev = YAMLMap.findPair(this.items, pair.key); + if (!prev) + this.items.push(pair); + } + /** + * If `keepPair` is `true`, returns the Pair matching `key`. + * Otherwise, returns the value of that Pair's key. + */ + get(key, keepPair) { + const pair = YAMLMap.findPair(this.items, key); + return !keepPair && identity.isPair(pair) ? identity.isScalar(pair.key) ? pair.key.value : pair.key : pair; + } + set(key, value) { + if (typeof value !== "boolean") + throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof value}`); + const prev = YAMLMap.findPair(this.items, key); + if (prev && !value) { + this.items.splice(this.items.indexOf(prev), 1); + } else if (!prev && value) { + this.items.push(new Pair.Pair(key)); + } + } + toJSON(_, ctx) { + return super.toJSON(_, ctx, Set); + } + toString(ctx, onComment, onChompKeep) { + if (!ctx) + return JSON.stringify(this); + if (this.hasAllNullValues(true)) + return super.toString(Object.assign({}, ctx, { allNullValues: true }), onComment, onChompKeep); + else + throw new Error("Set items must all have null values"); + } + static from(schema, iterable, ctx) { + const { replacer } = ctx; + const set2 = new this(schema); + if (iterable && Symbol.iterator in Object(iterable)) + for (let value of iterable) { + if (typeof replacer === "function") + value = replacer.call(iterable, value, value); + set2.items.push(Pair.createPair(value, null, ctx)); } - if (isInteger(kv.value) || isFloat(kv.value)) { - target[finalKey] = kv.value.valueOf(); + return set2; + } + }; + YAMLSet.tag = "tag:yaml.org,2002:set"; + var set = { + collection: "map", + identify: (value) => value instanceof Set, + nodeClass: YAMLSet, + default: false, + tag: "tag:yaml.org,2002:set", + createNode: (schema, iterable, ctx) => YAMLSet.from(schema, iterable, ctx), + resolve(map, onError) { + if (identity.isMap(map)) { + if (map.hasAllNullValues(true)) + return Object.assign(new YAMLSet(), map); + else + onError("Set items must all have null values"); + } else + onError("Expected a mapping for this tag"); + return map; + } + }; + exports2.YAMLSet = YAMLSet; + exports2.set = set; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +var require_timestamp = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js"(exports2) { + init_esm_shims(); + var stringifyNumber = require_stringifyNumber(); + function parseSexagesimal(str, asBigInt) { + const sign = str[0]; + const parts = sign === "-" || sign === "+" ? str.substring(1) : str; + const num = (n2) => asBigInt ? BigInt(n2) : Number(n2); + const res = parts.replace(/_/g, "").split(":").reduce((res2, p2) => res2 * num(60) + num(p2), num(0)); + return sign === "-" ? num(-1) * res : res; + } + function stringifySexagesimal(node) { + let { value } = node; + let num = (n2) => n2; + if (typeof value === "bigint") + num = (n2) => BigInt(n2); + else if (isNaN(value) || !isFinite(value)) + return stringifyNumber.stringifyNumber(node); + let sign = ""; + if (value < 0) { + sign = "-"; + value *= num(-1); + } + const _60 = num(60); + const parts = [value % _60]; + if (value < 60) { + parts.unshift(0); + } else { + value = (value - parts[0]) / _60; + parts.unshift(value % _60); + if (value >= 60) { + value = (value - parts[0]) / _60; + parts.unshift(value); + } + } + return sign + parts.map((n2) => String(n2).padStart(2, "0")).join(":").replace(/000000\d*$/, ""); + } + var intTime = { + identify: (value) => typeof value === "bigint" || Number.isInteger(value), + default: true, + tag: "tag:yaml.org,2002:int", + format: "TIME", + test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/, + resolve: (str, _onError, { intAsBigInt }) => parseSexagesimal(str, intAsBigInt), + stringify: stringifySexagesimal + }; + var floatTime = { + identify: (value) => typeof value === "number", + default: true, + tag: "tag:yaml.org,2002:float", + format: "TIME", + test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/, + resolve: (str) => parseSexagesimal(str, false), + stringify: stringifySexagesimal + }; + var timestamp = { + identify: (value) => value instanceof Date, + default: true, + tag: "tag:yaml.org,2002:timestamp", + // If the time zone is omitted, the timestamp is assumed to be specified in UTC. The time part + // may be omitted altogether, resulting in a date format. In such a case, the time part is + // assumed to be 00:00:00Z (start of day, UTC). + test: RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"), + resolve(str) { + const match = str.match(timestamp.test); + if (!match) + throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd"); + const [, year, month, day, hour, minute, second] = match.map(Number); + const millisec = match[7] ? Number((match[7] + "00").substr(1, 3)) : 0; + let date = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec); + const tz = match[8]; + if (tz && tz !== "Z") { + let d2 = parseSexagesimal(tz, false); + if (Math.abs(d2) < 30) + d2 *= 60; + date -= 6e4 * d2; + } + return new Date(date); + }, + stringify: ({ value }) => value?.toISOString().replace(/(T00:00:00)?\.000Z$/, "") ?? "" + }; + exports2.floatTime = floatTime; + exports2.intTime = intTime; + exports2.timestamp = timestamp; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/schema.js +var require_schema3 = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/schema.js"(exports2) { + init_esm_shims(); + var map = require_map(); + var _null = require_null(); + var seq = require_seq(); + var string = require_string(); + var binary = require_binary(); + var bool = require_bool2(); + var float = require_float2(); + var int = require_int2(); + var merge = require_merge(); + var omap = require_omap(); + var pairs = require_pairs(); + var set = require_set(); + var timestamp = require_timestamp(); + var schema = [ + map.map, + seq.seq, + string.string, + _null.nullTag, + bool.trueTag, + bool.falseTag, + int.intBin, + int.intOct, + int.int, + int.intHex, + float.floatNaN, + float.floatExp, + float.float, + binary.binary, + merge.merge, + omap.omap, + pairs.pairs, + set.set, + timestamp.intTime, + timestamp.floatTime, + timestamp.timestamp + ]; + exports2.schema = schema; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/tags.js +var require_tags = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/tags.js"(exports2) { + init_esm_shims(); + var map = require_map(); + var _null = require_null(); + var seq = require_seq(); + var string = require_string(); + var bool = require_bool(); + var float = require_float(); + var int = require_int(); + var schema = require_schema(); + var schema$1 = require_schema2(); + var binary = require_binary(); + var merge = require_merge(); + var omap = require_omap(); + var pairs = require_pairs(); + var schema$2 = require_schema3(); + var set = require_set(); + var timestamp = require_timestamp(); + var schemas = /* @__PURE__ */ new Map([ + ["core", schema.schema], + ["failsafe", [map.map, seq.seq, string.string]], + ["json", schema$1.schema], + ["yaml11", schema$2.schema], + ["yaml-1.1", schema$2.schema] + ]); + var tagsByName = { + binary: binary.binary, + bool: bool.boolTag, + float: float.float, + floatExp: float.floatExp, + floatNaN: float.floatNaN, + floatTime: timestamp.floatTime, + int: int.int, + intHex: int.intHex, + intOct: int.intOct, + intTime: timestamp.intTime, + map: map.map, + merge: merge.merge, + null: _null.nullTag, + omap: omap.omap, + pairs: pairs.pairs, + seq: seq.seq, + set: set.set, + timestamp: timestamp.timestamp + }; + var coreKnownTags = { + "tag:yaml.org,2002:binary": binary.binary, + "tag:yaml.org,2002:merge": merge.merge, + "tag:yaml.org,2002:omap": omap.omap, + "tag:yaml.org,2002:pairs": pairs.pairs, + "tag:yaml.org,2002:set": set.set, + "tag:yaml.org,2002:timestamp": timestamp.timestamp + }; + function getTags(customTags, schemaName, addMergeTag) { + const schemaTags = schemas.get(schemaName); + if (schemaTags && !customTags) { + return addMergeTag && !schemaTags.includes(merge.merge) ? schemaTags.concat(merge.merge) : schemaTags.slice(); + } + let tags = schemaTags; + if (!tags) { + if (Array.isArray(customTags)) + tags = []; + else { + const keys = Array.from(schemas.keys()).filter((key) => key !== "yaml11").map((key) => JSON.stringify(key)).join(", "); + throw new Error(`Unknown schema "${schemaName}"; use one of ${keys} or define customTags array`); + } + } + if (Array.isArray(customTags)) { + for (const tag of customTags) + tags = tags.concat(tag); + } else if (typeof customTags === "function") { + tags = customTags(tags.slice()); + } + if (addMergeTag) + tags = tags.concat(merge.merge); + return tags.reduce((tags2, tag) => { + const tagObj = typeof tag === "string" ? tagsByName[tag] : tag; + if (!tagObj) { + const tagName = JSON.stringify(tag); + const keys = Object.keys(tagsByName).map((key) => JSON.stringify(key)).join(", "); + throw new Error(`Unknown custom tag ${tagName}; use one of ${keys}`); + } + if (!tags2.includes(tagObj)) + tags2.push(tagObj); + return tags2; + }, []); + } + exports2.coreKnownTags = coreKnownTags; + exports2.getTags = getTags; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/Schema.js +var require_Schema = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/Schema.js"(exports2) { + init_esm_shims(); + var identity = require_identity(); + var map = require_map(); + var seq = require_seq(); + var string = require_string(); + var tags = require_tags(); + var sortMapEntriesByKey = (a2, b2) => a2.key < b2.key ? -1 : a2.key > b2.key ? 1 : 0; + var Schema = class _Schema { + constructor({ compat, customTags, merge, resolveKnownTags, schema, sortMapEntries, toStringDefaults }) { + this.compat = Array.isArray(compat) ? tags.getTags(compat, "compat") : compat ? tags.getTags(null, compat) : null; + this.name = typeof schema === "string" && schema || "core"; + this.knownTags = resolveKnownTags ? tags.coreKnownTags : {}; + this.tags = tags.getTags(customTags, this.name, merge); + this.toStringOptions = toStringDefaults ?? null; + Object.defineProperty(this, identity.MAP, { value: map.map }); + Object.defineProperty(this, identity.SCALAR, { value: string.string }); + Object.defineProperty(this, identity.SEQ, { value: seq.seq }); + this.sortMapEntries = typeof sortMapEntries === "function" ? sortMapEntries : sortMapEntries === true ? sortMapEntriesByKey : null; + } + clone() { + const copy = Object.create(_Schema.prototype, Object.getOwnPropertyDescriptors(this)); + copy.tags = this.tags.slice(); + return copy; + } + }; + exports2.Schema = Schema; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringifyDocument.js +var require_stringifyDocument = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringifyDocument.js"(exports2) { + init_esm_shims(); + var identity = require_identity(); + var stringify = require_stringify(); + var stringifyComment = require_stringifyComment(); + function stringifyDocument(doc, options) { + const lines = []; + let hasDirectives = options.directives === true; + if (options.directives !== false && doc.directives) { + const dir = doc.directives.toString(doc); + if (dir) { + lines.push(dir); + hasDirectives = true; + } else if (doc.directives.docStart) + hasDirectives = true; + } + if (hasDirectives) + lines.push("---"); + const ctx = stringify.createStringifyContext(doc, options); + const { commentString } = ctx.options; + if (doc.commentBefore) { + if (lines.length !== 1) + lines.unshift(""); + const cs = commentString(doc.commentBefore); + lines.unshift(stringifyComment.indentComment(cs, "")); + } + let chompKeep = false; + let contentComment = null; + if (doc.contents) { + if (identity.isNode(doc.contents)) { + if (doc.contents.spaceBefore && hasDirectives) + lines.push(""); + if (doc.contents.commentBefore) { + const cs = commentString(doc.contents.commentBefore); + lines.push(stringifyComment.indentComment(cs, "")); + } + ctx.forceBlockIndent = !!doc.comment; + contentComment = doc.contents.comment; + } + const onChompKeep = contentComment ? void 0 : () => chompKeep = true; + let body = stringify.stringify(doc.contents, ctx, () => contentComment = null, onChompKeep); + if (contentComment) + body += stringifyComment.lineComment(body, "", commentString(contentComment)); + if ((body[0] === "|" || body[0] === ">") && lines[lines.length - 1] === "---") { + lines[lines.length - 1] = `--- ${body}`; + } else + lines.push(body); + } else { + lines.push(stringify.stringify(doc.contents, ctx)); + } + if (doc.directives?.docEnd) { + if (doc.comment) { + const cs = commentString(doc.comment); + if (cs.includes("\n")) { + lines.push("..."); + lines.push(stringifyComment.indentComment(cs, "")); } else { - target[finalKey] = kv.value; + lines.push(`... ${cs}`); } - return this.goto(this.parseWhitespaceToEOL); + } else { + lines.push("..."); } - /* ASSSIGNMENT expression, key = value possibly inside an inline table */ - parseAssign() { - return this.callNow(this.parseKeyword, this.recordAssignKeyword); + } else { + let dc = doc.comment; + if (dc && chompKeep) + dc = dc.replace(/^\n+/, ""); + if (dc) { + if ((!chompKeep || contentComment) && lines[lines.length - 1] !== "") + lines.push(""); + lines.push(stringifyComment.indentComment(commentString(dc), "")); } - recordAssignKeyword(key) { - if (this.state.resultTable) { - this.state.resultTable.push(key); - } else { - this.state.resultTable = [key]; - } - return this.goto(this.parseAssignKeywordPreDot); + } + return lines.join("\n") + "\n"; + } + exports2.stringifyDocument = stringifyDocument; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/doc/Document.js +var require_Document = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/doc/Document.js"(exports2) { + init_esm_shims(); + var Alias = require_Alias(); + var Collection = require_Collection(); + var identity = require_identity(); + var Pair = require_Pair(); + var toJS = require_toJS(); + var Schema = require_Schema(); + var stringifyDocument = require_stringifyDocument(); + var anchors = require_anchors(); + var applyReviver = require_applyReviver(); + var createNode = require_createNode(); + var directives = require_directives(); + var Document = class _Document { + constructor(value, replacer, options) { + this.commentBefore = null; + this.comment = null; + this.errors = []; + this.warnings = []; + Object.defineProperty(this, identity.NODE_TYPE, { value: identity.DOC }); + let _replacer = null; + if (typeof replacer === "function" || Array.isArray(replacer)) { + _replacer = replacer; + } else if (options === void 0 && replacer) { + options = replacer; + replacer = void 0; + } + const opt = Object.assign({ + intAsBigInt: false, + keepSourceTokens: false, + logLevel: "warn", + prettyErrors: true, + strict: true, + stringKeys: false, + uniqueKeys: true, + version: "1.2" + }, options); + this.options = opt; + let { version } = opt; + if (options?._directives) { + this.directives = options._directives.atDocument(); + if (this.directives.yaml.explicit) + version = this.directives.yaml.version; + } else + this.directives = new directives.Directives({ version }); + this.setSchema(version, options); + this.contents = value === void 0 ? null : this.createNode(value, _replacer, options); + } + /** + * Create a deep copy of this Document and its contents. + * + * Custom Node values that inherit from `Object` still refer to their original instances. + */ + clone() { + const copy = Object.create(_Document.prototype, { + [identity.NODE_TYPE]: { value: identity.DOC } + }); + copy.commentBefore = this.commentBefore; + copy.comment = this.comment; + copy.errors = this.errors.slice(); + copy.warnings = this.warnings.slice(); + copy.options = Object.assign({}, this.options); + if (this.directives) + copy.directives = this.directives.clone(); + copy.schema = this.schema.clone(); + copy.contents = identity.isNode(this.contents) ? this.contents.clone(copy.schema) : this.contents; + if (this.range) + copy.range = this.range.slice(); + return copy; + } + /** Adds a value to the document. */ + add(value) { + if (assertCollection(this.contents)) + this.contents.add(value); + } + /** Adds a value to the document. */ + addIn(path4, value) { + if (assertCollection(this.contents)) + this.contents.addIn(path4, value); + } + /** + * Create a new `Alias` node, ensuring that the target `node` has the required anchor. + * + * If `node` already has an anchor, `name` is ignored. + * Otherwise, the `node.anchor` value will be set to `name`, + * or if an anchor with that name is already present in the document, + * `name` will be used as a prefix for a new unique anchor. + * If `name` is undefined, the generated anchor will use 'a' as a prefix. + */ + createAlias(node, name) { + if (!node.anchor) { + const prev = anchors.anchorNames(this); + node.anchor = // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + !name || prev.has(name) ? anchors.findNewAnchor(name || "a", prev) : name; + } + return new Alias.Alias(node.anchor); + } + createNode(value, replacer, options) { + let _replacer = void 0; + if (typeof replacer === "function") { + value = replacer.call({ "": value }, "", value); + _replacer = replacer; + } else if (Array.isArray(replacer)) { + const keyToStr = (v2) => typeof v2 === "number" || v2 instanceof String || v2 instanceof Number; + const asStr = replacer.filter(keyToStr).map(String); + if (asStr.length > 0) + replacer = replacer.concat(asStr); + _replacer = replacer; + } else if (options === void 0 && replacer) { + options = replacer; + replacer = void 0; + } + const { aliasDuplicateObjects, anchorPrefix, flow, keepUndefined, onTagObj, tag } = options ?? {}; + const { onAnchor, setAnchors, sourceObjects } = anchors.createNodeAnchors( + this, + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + anchorPrefix || "a" + ); + const ctx = { + aliasDuplicateObjects: aliasDuplicateObjects ?? true, + keepUndefined: keepUndefined ?? false, + onAnchor, + onTagObj, + replacer: _replacer, + schema: this.schema, + sourceObjects + }; + const node = createNode.createNode(value, tag, ctx); + if (flow && identity.isCollection(node)) + node.flow = true; + setAnchors(); + return node; + } + /** + * Convert a key and a value into a `Pair` using the current schema, + * recursively wrapping all values as `Scalar` or `Collection` nodes. + */ + createPair(key, value, options = {}) { + const k = this.createNode(key, null, options); + const v2 = this.createNode(value, null, options); + return new Pair.Pair(k, v2); + } + /** + * Removes a value from the document. + * @returns `true` if the item was found and removed. + */ + delete(key) { + return assertCollection(this.contents) ? this.contents.delete(key) : false; + } + /** + * Removes a value from the document. + * @returns `true` if the item was found and removed. + */ + deleteIn(path4) { + if (Collection.isEmptyPath(path4)) { + if (this.contents == null) + return false; + this.contents = null; + return true; } - parseAssignKeywordPreDot() { - if (this.char === CHAR_PERIOD) { - return this.next(this.parseAssignKeywordPostDot); - } else if (this.char !== CHAR_SP && this.char !== CTRL_I) { - return this.goto(this.parseAssignEqual); + return assertCollection(this.contents) ? this.contents.deleteIn(path4) : false; + } + /** + * Returns item at `key`, or `undefined` if not found. By default unwraps + * scalar values from their surrounding node; to disable set `keepScalar` to + * `true` (collections are always returned intact). + */ + get(key, keepScalar) { + return identity.isCollection(this.contents) ? this.contents.get(key, keepScalar) : void 0; + } + /** + * Returns item at `path`, or `undefined` if not found. By default unwraps + * scalar values from their surrounding node; to disable set `keepScalar` to + * `true` (collections are always returned intact). + */ + getIn(path4, keepScalar) { + if (Collection.isEmptyPath(path4)) + return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents; + return identity.isCollection(this.contents) ? this.contents.getIn(path4, keepScalar) : void 0; + } + /** + * Checks if the document includes a value with the key `key`. + */ + has(key) { + return identity.isCollection(this.contents) ? this.contents.has(key) : false; + } + /** + * Checks if the document includes a value at `path`. + */ + hasIn(path4) { + if (Collection.isEmptyPath(path4)) + return this.contents !== void 0; + return identity.isCollection(this.contents) ? this.contents.hasIn(path4) : false; + } + /** + * Sets a value in this document. For `!!set`, `value` needs to be a + * boolean to add/remove the item from the set. + */ + set(key, value) { + if (this.contents == null) { + this.contents = Collection.collectionFromPath(this.schema, [key], value); + } else if (assertCollection(this.contents)) { + this.contents.set(key, value); + } + } + /** + * Sets a value in this document. For `!!set`, `value` needs to be a + * boolean to add/remove the item from the set. + */ + setIn(path4, value) { + if (Collection.isEmptyPath(path4)) { + this.contents = value; + } else if (this.contents == null) { + this.contents = Collection.collectionFromPath(this.schema, Array.from(path4), value); + } else if (assertCollection(this.contents)) { + this.contents.setIn(path4, value); + } + } + /** + * Change the YAML version and schema used by the document. + * A `null` version disables support for directives, explicit tags, anchors, and aliases. + * It also requires the `schema` option to be given as a `Schema` instance value. + * + * Overrides all previously set schema options. + */ + setSchema(version, options = {}) { + if (typeof version === "number") + version = String(version); + let opt; + switch (version) { + case "1.1": + if (this.directives) + this.directives.yaml.version = "1.1"; + else + this.directives = new directives.Directives({ version: "1.1" }); + opt = { resolveKnownTags: false, schema: "yaml-1.1" }; + break; + case "1.2": + case "next": + if (this.directives) + this.directives.yaml.version = version; + else + this.directives = new directives.Directives({ version }); + opt = { resolveKnownTags: true, schema: "core" }; + break; + case null: + if (this.directives) + delete this.directives; + opt = null; + break; + default: { + const sv = JSON.stringify(version); + throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${sv}`); } } - parseAssignKeywordPostDot() { - if (this.char !== CHAR_SP && this.char !== CTRL_I) { - return this.callNow(this.parseKeyword, this.recordAssignKeyword); + if (options.schema instanceof Object) + this.schema = options.schema; + else if (opt) + this.schema = new Schema.Schema(Object.assign(opt, options)); + else + throw new Error(`With a null YAML version, the { schema: Schema } option is required`); + } + // json & jsonArg are only used from toJSON() + toJS({ json, jsonArg, mapAsMap, maxAliasCount, onAnchor, reviver } = {}) { + const ctx = { + anchors: /* @__PURE__ */ new Map(), + doc: this, + keep: !json, + mapAsMap: mapAsMap === true, + mapKeyWarned: false, + maxAliasCount: typeof maxAliasCount === "number" ? maxAliasCount : 100 + }; + const res = toJS.toJS(this.contents, jsonArg ?? "", ctx); + if (typeof onAnchor === "function") + for (const { count, res: res2 } of ctx.anchors.values()) + onAnchor(res2, count); + return typeof reviver === "function" ? applyReviver.applyReviver(reviver, { "": res }, "", res) : res; + } + /** + * A JSON representation of the document `contents`. + * + * @param jsonArg Used by `JSON.stringify` to indicate the array index or + * property name. + */ + toJSON(jsonArg, onAnchor) { + return this.toJS({ json: true, jsonArg, mapAsMap: false, onAnchor }); + } + /** A YAML representation of the document. */ + toString(options = {}) { + if (this.errors.length > 0) + throw new Error("Document with errors cannot be stringified"); + if ("indent" in options && (!Number.isInteger(options.indent) || Number(options.indent) <= 0)) { + const s2 = JSON.stringify(options.indent); + throw new Error(`"indent" option must be a positive integer, not ${s2}`); + } + return stringifyDocument.stringifyDocument(this, options); + } + }; + function assertCollection(contents) { + if (identity.isCollection(contents)) + return true; + throw new Error("Expected a YAML collection as document contents"); + } + exports2.Document = Document; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/errors.js +var require_errors = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/errors.js"(exports2) { + init_esm_shims(); + var YAMLError = class extends Error { + constructor(name, pos, code, message) { + super(); + this.name = name; + this.code = code; + this.message = message; + this.pos = pos; + } + }; + var YAMLParseError = class extends YAMLError { + constructor(pos, code, message) { + super("YAMLParseError", pos, code, message); + } + }; + var YAMLWarning = class extends YAMLError { + constructor(pos, code, message) { + super("YAMLWarning", pos, code, message); + } + }; + var prettifyError = (src, lc) => (error) => { + if (error.pos[0] === -1) + return; + error.linePos = error.pos.map((pos) => lc.linePos(pos)); + const { line, col } = error.linePos[0]; + error.message += ` at line ${line}, column ${col}`; + let ci = col - 1; + let lineStr = src.substring(lc.lineStarts[line - 1], lc.lineStarts[line]).replace(/[\n\r]+$/, ""); + if (ci >= 60 && lineStr.length > 80) { + const trimStart = Math.min(ci - 39, lineStr.length - 79); + lineStr = "\u2026" + lineStr.substring(trimStart); + ci -= trimStart - 1; + } + if (lineStr.length > 80) + lineStr = lineStr.substring(0, 79) + "\u2026"; + if (line > 1 && /^ *$/.test(lineStr.substring(0, ci))) { + let prev = src.substring(lc.lineStarts[line - 2], lc.lineStarts[line - 1]); + if (prev.length > 80) + prev = prev.substring(0, 79) + "\u2026\n"; + lineStr = prev + lineStr; + } + if (/[^ ]/.test(lineStr)) { + let count = 1; + const end = error.linePos[1]; + if (end?.line === line && end.col > col) { + count = Math.max(1, Math.min(end.col - col, 80 - ci)); + } + const pointer = " ".repeat(ci) + "^".repeat(count); + error.message += `: + +${lineStr} +${pointer} +`; + } + }; + exports2.YAMLError = YAMLError; + exports2.YAMLParseError = YAMLParseError; + exports2.YAMLWarning = YAMLWarning; + exports2.prettifyError = prettifyError; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/resolve-props.js +var require_resolve_props = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/resolve-props.js"(exports2) { + init_esm_shims(); + function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIndent, startOnNewline }) { + let spaceBefore = false; + let atNewline = startOnNewline; + let hasSpace = startOnNewline; + let comment = ""; + let commentSep = ""; + let hasNewline = false; + let reqSpace = false; + let tab = null; + let anchor = null; + let tag = null; + let newlineAfterProp = null; + let comma = null; + let found = null; + let start = null; + for (const token of tokens) { + if (reqSpace) { + if (token.type !== "space" && token.type !== "newline" && token.type !== "comma") + onError(token.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space"); + reqSpace = false; + } + if (tab) { + if (atNewline && token.type !== "comment" && token.type !== "newline") { + onError(tab, "TAB_AS_INDENT", "Tabs are not allowed as indentation"); + } + tab = null; + } + switch (token.type) { + case "space": + if (!flow && (indicator !== "doc-start" || next?.type !== "flow-collection") && token.source.includes(" ")) { + tab = token; + } + hasSpace = true; + break; + case "comment": { + if (!hasSpace) + onError(token, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters"); + const cb = token.source.substring(1) || " "; + if (!comment) + comment = cb; + else + comment += commentSep + cb; + commentSep = ""; + atNewline = false; + break; } - } - parseAssignEqual() { - if (this.char === CHAR_EQUALS) { - return this.next(this.parseAssignPreValue); - } else { - throw this.error(new TomlError('Invalid character, expected "="')); + case "newline": + if (atNewline) { + if (comment) + comment += token.source; + else if (!found || indicator !== "seq-item-ind") + spaceBefore = true; + } else + commentSep += token.source; + atNewline = true; + hasNewline = true; + if (anchor || tag) + newlineAfterProp = token; + hasSpace = true; + break; + case "anchor": + if (anchor) + onError(token, "MULTIPLE_ANCHORS", "A node can have at most one anchor"); + if (token.source.endsWith(":")) + onError(token.offset + token.source.length - 1, "BAD_ALIAS", "Anchor ending in : is ambiguous", true); + anchor = token; + start ?? (start = token.offset); + atNewline = false; + hasSpace = false; + reqSpace = true; + break; + case "tag": { + if (tag) + onError(token, "MULTIPLE_TAGS", "A node can have at most one tag"); + tag = token; + start ?? (start = token.offset); + atNewline = false; + hasSpace = false; + reqSpace = true; + break; } + case indicator: + if (anchor || tag) + onError(token, "BAD_PROP_ORDER", `Anchors and tags must be after the ${token.source} indicator`); + if (found) + onError(token, "UNEXPECTED_TOKEN", `Unexpected ${token.source} in ${flow ?? "collection"}`); + found = token; + atNewline = indicator === "seq-item-ind" || indicator === "explicit-key-ind"; + hasSpace = false; + break; + case "comma": + if (flow) { + if (comma) + onError(token, "UNEXPECTED_TOKEN", `Unexpected , in ${flow}`); + comma = token; + atNewline = false; + hasSpace = false; + break; + } + // else fallthrough + default: + onError(token, "UNEXPECTED_TOKEN", `Unexpected ${token.type} token`); + atNewline = false; + hasSpace = false; } - parseAssignPreValue() { - if (this.char === CHAR_SP || this.char === CTRL_I) { - return null; - } else { - return this.callNow(this.parseValue, this.recordAssignValue); + } + const last = tokens[tokens.length - 1]; + const end = last ? last.offset + last.source.length : offset; + if (reqSpace && next && next.type !== "space" && next.type !== "newline" && next.type !== "comma" && (next.type !== "scalar" || next.source !== "")) { + onError(next.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space"); + } + if (tab && (atNewline && tab.indent <= parentIndent || next?.type === "block-map" || next?.type === "block-seq")) + onError(tab, "TAB_AS_INDENT", "Tabs are not allowed as indentation"); + return { + comma, + found, + spaceBefore, + comment, + hasNewline, + anchor, + tag, + newlineAfterProp, + end, + start: start ?? end + }; + } + exports2.resolveProps = resolveProps; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/util-contains-newline.js +var require_util_contains_newline = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/util-contains-newline.js"(exports2) { + init_esm_shims(); + function containsNewline(key) { + if (!key) + return null; + switch (key.type) { + case "alias": + case "scalar": + case "double-quoted-scalar": + case "single-quoted-scalar": + if (key.source.includes("\n")) + return true; + if (key.end) { + for (const st of key.end) + if (st.type === "newline") + return true; } + return false; + case "flow-collection": + for (const it of key.items) { + for (const st of it.start) + if (st.type === "newline") + return true; + if (it.sep) { + for (const st of it.sep) + if (st.type === "newline") + return true; + } + if (containsNewline(it.key) || containsNewline(it.value)) + return true; + } + return false; + default: + return true; + } + } + exports2.containsNewline = containsNewline; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/util-flow-indent-check.js +var require_util_flow_indent_check = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/util-flow-indent-check.js"(exports2) { + init_esm_shims(); + var utilContainsNewline = require_util_contains_newline(); + function flowIndentCheck(indent, fc, onError) { + if (fc?.type === "flow-collection") { + const end = fc.end[0]; + if (end.indent === indent && (end.source === "]" || end.source === "}") && utilContainsNewline.containsNewline(fc)) { + const msg = "Flow end indicator should be more indented than parent"; + onError(end, "BAD_INDENT", msg, true); } - recordAssignValue(value) { - return this.returnNow({ key: this.state.resultTable, value }); - } - /* COMMENTS: #...eol */ - parseComment() { - do { - if (this.char === Parser2.END || this.char === CTRL_J) { - return this.return(); + } + } + exports2.flowIndentCheck = flowIndentCheck; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/util-map-includes.js +var require_util_map_includes = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/util-map-includes.js"(exports2) { + init_esm_shims(); + var identity = require_identity(); + function mapIncludes(ctx, items, search) { + const { uniqueKeys } = ctx.options; + if (uniqueKeys === false) + return false; + const isEqual = typeof uniqueKeys === "function" ? uniqueKeys : (a2, b2) => a2 === b2 || identity.isScalar(a2) && identity.isScalar(b2) && a2.value === b2.value; + return items.some((pair) => isEqual(pair.key, search)); + } + exports2.mapIncludes = mapIncludes; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/resolve-block-map.js +var require_resolve_block_map = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/resolve-block-map.js"(exports2) { + init_esm_shims(); + var Pair = require_Pair(); + var YAMLMap = require_YAMLMap(); + var resolveProps = require_resolve_props(); + var utilContainsNewline = require_util_contains_newline(); + var utilFlowIndentCheck = require_util_flow_indent_check(); + var utilMapIncludes = require_util_map_includes(); + var startColMsg = "All mapping items must start at the same column"; + function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, tag) { + const NodeClass = tag?.nodeClass ?? YAMLMap.YAMLMap; + const map = new NodeClass(ctx.schema); + if (ctx.atRoot) + ctx.atRoot = false; + let offset = bm.offset; + let commentEnd = null; + for (const collItem of bm.items) { + const { start, key, sep, value } = collItem; + const keyProps = resolveProps.resolveProps(start, { + indicator: "explicit-key-ind", + next: key ?? sep?.[0], + offset, + onError, + parentIndent: bm.indent, + startOnNewline: true + }); + const implicitKey = !keyProps.found; + if (implicitKey) { + if (key) { + if (key.type === "block-seq") + onError(offset, "BLOCK_AS_IMPLICIT_KEY", "A block sequence may not be used as an implicit map key"); + else if ("indent" in key && key.indent !== bm.indent) + onError(offset, "BAD_INDENT", startColMsg); + } + if (!keyProps.anchor && !keyProps.tag && !sep) { + commentEnd = keyProps.end; + if (keyProps.comment) { + if (map.comment) + map.comment += "\n" + keyProps.comment; + else + map.comment = keyProps.comment; } - } while (this.nextChar()); + continue; + } + if (keyProps.newlineAfterProp || utilContainsNewline.containsNewline(key)) { + onError(key ?? start[start.length - 1], "MULTILINE_IMPLICIT_KEY", "Implicit keys need to be on a single line"); + } + } else if (keyProps.found?.indent !== bm.indent) { + onError(offset, "BAD_INDENT", startColMsg); + } + ctx.atKey = true; + const keyStart = keyProps.end; + const keyNode = key ? composeNode(ctx, key, keyProps, onError) : composeEmptyNode(ctx, keyStart, start, null, keyProps, onError); + if (ctx.schema.compat) + utilFlowIndentCheck.flowIndentCheck(bm.indent, key, onError); + ctx.atKey = false; + if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode)) + onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique"); + const valueProps = resolveProps.resolveProps(sep ?? [], { + indicator: "map-value-ind", + next: value, + offset: keyNode.range[2], + onError, + parentIndent: bm.indent, + startOnNewline: !key || key.type === "block-scalar" + }); + offset = valueProps.end; + if (valueProps.found) { + if (implicitKey) { + if (value?.type === "block-map" && !valueProps.hasNewline) + onError(offset, "BLOCK_AS_IMPLICIT_KEY", "Nested mappings are not allowed in compact mappings"); + if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024) + onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key"); + } + const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep, null, valueProps, onError); + if (ctx.schema.compat) + utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError); + offset = valueNode.range[2]; + const pair = new Pair.Pair(keyNode, valueNode); + if (ctx.options.keepSourceTokens) + pair.srcToken = collItem; + map.items.push(pair); + } else { + if (implicitKey) + onError(keyNode.range, "MISSING_CHAR", "Implicit map keys need to be followed by map values"); + if (valueProps.comment) { + if (keyNode.comment) + keyNode.comment += "\n" + valueProps.comment; + else + keyNode.comment = valueProps.comment; + } + const pair = new Pair.Pair(keyNode); + if (ctx.options.keepSourceTokens) + pair.srcToken = collItem; + map.items.push(pair); } - /* TABLES AND LISTS, [foo] and [[foo]] */ - parseTableOrList() { - if (this.char === CHAR_LSQB) { - this.next(this.parseList); + } + if (commentEnd && commentEnd < offset) + onError(commentEnd, "IMPOSSIBLE", "Map comment with trailing content"); + map.range = [bm.offset, offset, commentEnd ?? offset]; + return map; + } + exports2.resolveBlockMap = resolveBlockMap; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/resolve-block-seq.js +var require_resolve_block_seq = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/resolve-block-seq.js"(exports2) { + init_esm_shims(); + var YAMLSeq = require_YAMLSeq(); + var resolveProps = require_resolve_props(); + var utilFlowIndentCheck = require_util_flow_indent_check(); + function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError, tag) { + const NodeClass = tag?.nodeClass ?? YAMLSeq.YAMLSeq; + const seq = new NodeClass(ctx.schema); + if (ctx.atRoot) + ctx.atRoot = false; + if (ctx.atKey) + ctx.atKey = false; + let offset = bs.offset; + let commentEnd = null; + for (const { start, value } of bs.items) { + const props = resolveProps.resolveProps(start, { + indicator: "seq-item-ind", + next: value, + offset, + onError, + parentIndent: bs.indent, + startOnNewline: true + }); + if (!props.found) { + if (props.anchor || props.tag || value) { + if (value?.type === "block-seq") + onError(props.end, "BAD_INDENT", "All sequence items must start at the same column"); + else + onError(offset, "MISSING_CHAR", "Sequence item without - indicator"); } else { - return this.goto(this.parseTable); + commentEnd = props.end; + if (props.comment) + seq.comment = props.comment; + continue; } } - /* TABLE [foo.bar.baz] */ - parseTable() { - this.ctx = this.obj; - return this.goto(this.parseTableNext); - } - parseTableNext() { - if (this.char === CHAR_SP || this.char === CTRL_I) { - return null; - } else { - return this.callNow(this.parseKeyword, this.parseTableMore); + const node = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, start, null, props, onError); + if (ctx.schema.compat) + utilFlowIndentCheck.flowIndentCheck(bs.indent, value, onError); + offset = node.range[2]; + seq.items.push(node); + } + seq.range = [bs.offset, offset, commentEnd ?? offset]; + return seq; + } + exports2.resolveBlockSeq = resolveBlockSeq; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/resolve-end.js +var require_resolve_end = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/resolve-end.js"(exports2) { + init_esm_shims(); + function resolveEnd(end, offset, reqSpace, onError) { + let comment = ""; + if (end) { + let hasSpace = false; + let sep = ""; + for (const token of end) { + const { source, type } = token; + switch (type) { + case "space": + hasSpace = true; + break; + case "comment": { + if (reqSpace && !hasSpace) + onError(token, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters"); + const cb = source.substring(1) || " "; + if (!comment) + comment = cb; + else + comment += sep + cb; + sep = ""; + break; + } + case "newline": + if (comment) + sep += source; + hasSpace = true; + break; + default: + onError(token, "UNEXPECTED_TOKEN", `Unexpected ${type} at node end`); } + offset += source.length; } - parseTableMore(keyword) { - if (this.char === CHAR_SP || this.char === CTRL_I) { - return null; - } else if (this.char === CHAR_RSQB) { - if (hasKey(this.ctx, keyword) && (!isTable(this.ctx[keyword]) || this.ctx[keyword][_declared])) { - throw this.error(new TomlError("Can't redefine existing key")); - } else { - this.ctx = this.ctx[keyword] = this.ctx[keyword] || Table(); - this.ctx[_declared] = true; + } + return { comment, offset }; + } + exports2.resolveEnd = resolveEnd; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/resolve-flow-collection.js +var require_resolve_flow_collection = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/resolve-flow-collection.js"(exports2) { + init_esm_shims(); + var identity = require_identity(); + var Pair = require_Pair(); + var YAMLMap = require_YAMLMap(); + var YAMLSeq = require_YAMLSeq(); + var resolveEnd = require_resolve_end(); + var resolveProps = require_resolve_props(); + var utilContainsNewline = require_util_contains_newline(); + var utilMapIncludes = require_util_map_includes(); + var blockMsg = "Block collections are not allowed within flow collections"; + var isBlock = (token) => token && (token.type === "block-map" || token.type === "block-seq"); + function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onError, tag) { + const isMap = fc.start.source === "{"; + const fcName = isMap ? "flow map" : "flow sequence"; + const NodeClass = tag?.nodeClass ?? (isMap ? YAMLMap.YAMLMap : YAMLSeq.YAMLSeq); + const coll = new NodeClass(ctx.schema); + coll.flow = true; + const atRoot = ctx.atRoot; + if (atRoot) + ctx.atRoot = false; + if (ctx.atKey) + ctx.atKey = false; + let offset = fc.offset + fc.start.source.length; + for (let i2 = 0; i2 < fc.items.length; ++i2) { + const collItem = fc.items[i2]; + const { start, key, sep, value } = collItem; + const props = resolveProps.resolveProps(start, { + flow: fcName, + indicator: "explicit-key-ind", + next: key ?? sep?.[0], + offset, + onError, + parentIndent: fc.indent, + startOnNewline: false + }); + if (!props.found) { + if (!props.anchor && !props.tag && !sep && !value) { + if (i2 === 0 && props.comma) + onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`); + else if (i2 < fc.items.length - 1) + onError(props.start, "UNEXPECTED_TOKEN", `Unexpected empty item in ${fcName}`); + if (props.comment) { + if (coll.comment) + coll.comment += "\n" + props.comment; + else + coll.comment = props.comment; } - return this.next(this.parseWhitespaceToEOL); - } else if (this.char === CHAR_PERIOD) { - if (!hasKey(this.ctx, keyword)) { - this.ctx = this.ctx[keyword] = Table(); - } else if (isTable(this.ctx[keyword])) { - this.ctx = this.ctx[keyword]; - } else if (isList(this.ctx[keyword])) { - this.ctx = this.ctx[keyword][this.ctx[keyword].length - 1]; - } else { - throw this.error(new TomlError("Can't redefine existing key")); - } - return this.next(this.parseTableNext); - } else { - throw this.error(new TomlError("Unexpected character, expected whitespace, . or ]")); - } - } - /* LIST [[a.b.c]] */ - parseList() { - this.ctx = this.obj; - return this.goto(this.parseListNext); - } - parseListNext() { - if (this.char === CHAR_SP || this.char === CTRL_I) { - return null; - } else { - return this.callNow(this.parseKeyword, this.parseListMore); + offset = props.end; + continue; } - } - parseListMore(keyword) { - if (this.char === CHAR_SP || this.char === CTRL_I) { - return null; - } else if (this.char === CHAR_RSQB) { - if (!hasKey(this.ctx, keyword)) { - this.ctx[keyword] = List(); + if (!isMap && ctx.options.strict && utilContainsNewline.containsNewline(key)) + onError( + key, + // checked by containsNewline() + "MULTILINE_IMPLICIT_KEY", + "Implicit keys of flow sequence pairs need to be on a single line" + ); + } + if (i2 === 0) { + if (props.comma) + onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`); + } else { + if (!props.comma) + onError(props.start, "MISSING_CHAR", `Missing , between ${fcName} items`); + if (props.comment) { + let prevItemComment = ""; + loop: for (const st of start) { + switch (st.type) { + case "comma": + case "space": + break; + case "comment": + prevItemComment = st.source.substring(1); + break loop; + default: + break loop; + } } - if (isInlineList(this.ctx[keyword])) { - throw this.error(new TomlError("Can't extend an inline array")); - } else if (isList(this.ctx[keyword])) { - const next = Table(); - this.ctx[keyword].push(next); - this.ctx = next; - } else { - throw this.error(new TomlError("Can't redefine an existing key")); + if (prevItemComment) { + let prev = coll.items[coll.items.length - 1]; + if (identity.isPair(prev)) + prev = prev.value ?? prev.key; + if (prev.comment) + prev.comment += "\n" + prevItemComment; + else + prev.comment = prevItemComment; + props.comment = props.comment.substring(prevItemComment.length + 1); } - return this.next(this.parseListEnd); - } else if (this.char === CHAR_PERIOD) { - if (!hasKey(this.ctx, keyword)) { - this.ctx = this.ctx[keyword] = Table(); - } else if (isInlineList(this.ctx[keyword])) { - throw this.error(new TomlError("Can't extend an inline array")); - } else if (isInlineTable(this.ctx[keyword])) { - throw this.error(new TomlError("Can't extend an inline table")); - } else if (isList(this.ctx[keyword])) { - this.ctx = this.ctx[keyword][this.ctx[keyword].length - 1]; - } else if (isTable(this.ctx[keyword])) { - this.ctx = this.ctx[keyword]; - } else { - throw this.error(new TomlError("Can't redefine an existing key")); + } + } + if (!isMap && !sep && !props.found) { + const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep, null, props, onError); + coll.items.push(valueNode); + offset = valueNode.range[2]; + if (isBlock(value)) + onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg); + } else { + ctx.atKey = true; + const keyStart = props.end; + const keyNode = key ? composeNode(ctx, key, props, onError) : composeEmptyNode(ctx, keyStart, start, null, props, onError); + if (isBlock(key)) + onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg); + ctx.atKey = false; + const valueProps = resolveProps.resolveProps(sep ?? [], { + flow: fcName, + indicator: "map-value-ind", + next: value, + offset: keyNode.range[2], + onError, + parentIndent: fc.indent, + startOnNewline: false + }); + if (valueProps.found) { + if (!isMap && !props.found && ctx.options.strict) { + if (sep) + for (const st of sep) { + if (st === valueProps.found) + break; + if (st.type === "newline") { + onError(st, "MULTILINE_IMPLICIT_KEY", "Implicit keys of flow sequence pairs need to be on a single line"); + break; + } + } + if (props.start < valueProps.found.offset - 1024) + onError(valueProps.found, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit flow sequence key"); } - return this.next(this.parseListNext); + } else if (value) { + if ("source" in value && value.source?.[0] === ":") + onError(value, "MISSING_CHAR", `Missing space after : in ${fcName}`); + else + onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`); + } + const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep, null, valueProps, onError) : null; + if (valueNode) { + if (isBlock(value)) + onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg); + } else if (valueProps.comment) { + if (keyNode.comment) + keyNode.comment += "\n" + valueProps.comment; + else + keyNode.comment = valueProps.comment; + } + const pair = new Pair.Pair(keyNode, valueNode); + if (ctx.options.keepSourceTokens) + pair.srcToken = collItem; + if (isMap) { + const map = coll; + if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode)) + onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique"); + map.items.push(pair); } else { - throw this.error(new TomlError("Unexpected character, expected whitespace, . or ]")); - } + const map = new YAMLMap.YAMLMap(ctx.schema); + map.flow = true; + map.items.push(pair); + const endRange = (valueNode ?? keyNode).range; + map.range = [keyNode.range[0], endRange[1], endRange[2]]; + coll.items.push(map); + } + offset = valueNode ? valueNode.range[2] : valueProps.end; + } + } + const expectedEnd = isMap ? "}" : "]"; + const [ce, ...ee] = fc.end; + let cePos = offset; + if (ce?.source === expectedEnd) + cePos = ce.offset + ce.source.length; + else { + const name = fcName[0].toUpperCase() + fcName.substring(1); + const msg = atRoot ? `${name} must end with a ${expectedEnd}` : `${name} in block collection must be sufficiently indented and end with a ${expectedEnd}`; + onError(offset, atRoot ? "MISSING_CHAR" : "BAD_INDENT", msg); + if (ce && ce.source.length !== 1) + ee.unshift(ce); + } + if (ee.length > 0) { + const end = resolveEnd.resolveEnd(ee, cePos, ctx.options.strict, onError); + if (end.comment) { + if (coll.comment) + coll.comment += "\n" + end.comment; + else + coll.comment = end.comment; } - parseListEnd(keyword) { - if (this.char === CHAR_RSQB) { - return this.next(this.parseWhitespaceToEOL); + coll.range = [fc.offset, cePos, end.offset]; + } else { + coll.range = [fc.offset, cePos, cePos]; + } + return coll; + } + exports2.resolveFlowCollection = resolveFlowCollection; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/compose-collection.js +var require_compose_collection = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/compose-collection.js"(exports2) { + init_esm_shims(); + var identity = require_identity(); + var Scalar = require_Scalar(); + var YAMLMap = require_YAMLMap(); + var YAMLSeq = require_YAMLSeq(); + var resolveBlockMap = require_resolve_block_map(); + var resolveBlockSeq = require_resolve_block_seq(); + var resolveFlowCollection = require_resolve_flow_collection(); + function resolveCollection(CN, ctx, token, onError, tagName, tag) { + const coll = token.type === "block-map" ? resolveBlockMap.resolveBlockMap(CN, ctx, token, onError, tag) : token.type === "block-seq" ? resolveBlockSeq.resolveBlockSeq(CN, ctx, token, onError, tag) : resolveFlowCollection.resolveFlowCollection(CN, ctx, token, onError, tag); + const Coll = coll.constructor; + if (tagName === "!" || tagName === Coll.tagName) { + coll.tag = Coll.tagName; + return coll; + } + if (tagName) + coll.tag = tagName; + return coll; + } + function composeCollection(CN, ctx, token, props, onError) { + const tagToken = props.tag; + const tagName = !tagToken ? null : ctx.directives.tagName(tagToken.source, (msg) => onError(tagToken, "TAG_RESOLVE_FAILED", msg)); + if (token.type === "block-seq") { + const { anchor, newlineAfterProp: nl } = props; + const lastProp = anchor && tagToken ? anchor.offset > tagToken.offset ? anchor : tagToken : anchor ?? tagToken; + if (lastProp && (!nl || nl.offset < lastProp.offset)) { + const message = "Missing newline after block sequence props"; + onError(lastProp, "MISSING_CHAR", message); + } + } + const expType = token.type === "block-map" ? "map" : token.type === "block-seq" ? "seq" : token.start.source === "{" ? "map" : "seq"; + if (!tagToken || !tagName || tagName === "!" || tagName === YAMLMap.YAMLMap.tagName && expType === "map" || tagName === YAMLSeq.YAMLSeq.tagName && expType === "seq") { + return resolveCollection(CN, ctx, token, onError, tagName); + } + let tag = ctx.schema.tags.find((t2) => t2.tag === tagName && t2.collection === expType); + if (!tag) { + const kt = ctx.schema.knownTags[tagName]; + if (kt?.collection === expType) { + ctx.schema.tags.push(Object.assign({}, kt, { default: false })); + tag = kt; + } else { + if (kt) { + onError(tagToken, "BAD_COLLECTION_TYPE", `${kt.tag} used for ${expType} collection, but expects ${kt.collection ?? "scalar"}`, true); } else { - throw this.error(new TomlError("Unexpected character, expected whitespace, . or ]")); + onError(tagToken, "TAG_RESOLVE_FAILED", `Unresolved tag: ${tagName}`, true); } + return resolveCollection(CN, ctx, token, onError, tagName); } - /* VALUE string, number, boolean, inline list, inline object */ - parseValue() { - if (this.char === Parser2.END) { - throw this.error(new TomlError("Key without value")); - } else if (this.char === CHAR_QUOT) { - return this.next(this.parseDoubleString); + } + const coll = resolveCollection(CN, ctx, token, onError, tagName, tag); + const res = tag.resolve?.(coll, (msg) => onError(tagToken, "TAG_RESOLVE_FAILED", msg), ctx.options) ?? coll; + const node = identity.isNode(res) ? res : new Scalar.Scalar(res); + node.range = coll.range; + node.tag = tagName; + if (tag?.format) + node.format = tag.format; + return node; + } + exports2.composeCollection = composeCollection; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/resolve-block-scalar.js +var require_resolve_block_scalar = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/resolve-block-scalar.js"(exports2) { + init_esm_shims(); + var Scalar = require_Scalar(); + function resolveBlockScalar(ctx, scalar, onError) { + const start = scalar.offset; + const header = parseBlockScalarHeader(scalar, ctx.options.strict, onError); + if (!header) + return { value: "", type: null, comment: "", range: [start, start, start] }; + const type = header.mode === ">" ? Scalar.Scalar.BLOCK_FOLDED : Scalar.Scalar.BLOCK_LITERAL; + const lines = scalar.source ? splitLines(scalar.source) : []; + let chompStart = lines.length; + for (let i2 = lines.length - 1; i2 >= 0; --i2) { + const content = lines[i2][1]; + if (content === "" || content === "\r") + chompStart = i2; + else + break; + } + if (chompStart === 0) { + const value2 = header.chomp === "+" && lines.length > 0 ? "\n".repeat(Math.max(1, lines.length - 1)) : ""; + let end2 = start + header.length; + if (scalar.source) + end2 += scalar.source.length; + return { value: value2, type, comment: header.comment, range: [start, end2, end2] }; + } + let trimIndent = scalar.indent + header.indent; + let offset = scalar.offset + header.length; + let contentStart = 0; + for (let i2 = 0; i2 < chompStart; ++i2) { + const [indent, content] = lines[i2]; + if (content === "" || content === "\r") { + if (header.indent === 0 && indent.length > trimIndent) + trimIndent = indent.length; + } else { + if (indent.length < trimIndent) { + const message = "Block scalars with more-indented leading empty lines must use an explicit indentation indicator"; + onError(offset + indent.length, "MISSING_CHAR", message); } - if (this.char === CHAR_APOS) { - return this.next(this.parseSingleString); - } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) { - return this.goto(this.parseNumberSign); - } else if (this.char === CHAR_i) { - return this.next(this.parseInf); - } else if (this.char === CHAR_n) { - return this.next(this.parseNan); - } else if (isDigit(this.char)) { - return this.goto(this.parseNumberOrDateTime); - } else if (this.char === CHAR_t || this.char === CHAR_f) { - return this.goto(this.parseBoolean); - } else if (this.char === CHAR_LSQB) { - return this.call(this.parseInlineList, this.recordValue); - } else if (this.char === CHAR_LCUB) { - return this.call(this.parseInlineTable, this.recordValue); - } else { - throw this.error(new TomlError("Unexpected character, expecting string, number, datetime, boolean, inline array or inline table")); + if (header.indent === 0) + trimIndent = indent.length; + contentStart = i2; + if (trimIndent === 0 && !ctx.atRoot) { + const message = "Block scalar values in collections must be indented"; + onError(offset, "BAD_INDENT", message); } + break; } - recordValue(value) { - return this.returnNow(value); - } - parseInf() { - if (this.char === CHAR_n) { - return this.next(this.parseInf2); - } else { - throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"')); - } + offset += indent.length + content.length + 1; + } + for (let i2 = lines.length - 1; i2 >= chompStart; --i2) { + if (lines[i2][0].length > trimIndent) + chompStart = i2 + 1; + } + let value = ""; + let sep = ""; + let prevMoreIndented = false; + for (let i2 = 0; i2 < contentStart; ++i2) + value += lines[i2][0].slice(trimIndent) + "\n"; + for (let i2 = contentStart; i2 < chompStart; ++i2) { + let [indent, content] = lines[i2]; + offset += indent.length + content.length + 1; + const crlf = content[content.length - 1] === "\r"; + if (crlf) + content = content.slice(0, -1); + if (content && indent.length < trimIndent) { + const src = header.indent ? "explicit indentation indicator" : "first line"; + const message = `Block scalar lines must not be less indented than their ${src}`; + onError(offset - content.length - (crlf ? 2 : 1), "BAD_INDENT", message); + indent = ""; + } + if (type === Scalar.Scalar.BLOCK_LITERAL) { + value += sep + indent.slice(trimIndent) + content; + sep = "\n"; + } else if (indent.length > trimIndent || content[0] === " ") { + if (sep === " ") + sep = "\n"; + else if (!prevMoreIndented && sep === "\n") + sep = "\n\n"; + value += sep + indent.slice(trimIndent) + content; + sep = "\n"; + prevMoreIndented = true; + } else if (content === "") { + if (sep === "\n") + value += "\n"; + else + sep = "\n"; + } else { + value += sep + content; + sep = " "; + prevMoreIndented = false; } - parseInf2() { - if (this.char === CHAR_f) { - if (this.state.buf === "-") { - return this.return(-Infinity); - } else { - return this.return(Infinity); + } + switch (header.chomp) { + case "-": + break; + case "+": + for (let i2 = chompStart; i2 < lines.length; ++i2) + value += "\n" + lines[i2][0].slice(trimIndent); + if (value[value.length - 1] !== "\n") + value += "\n"; + break; + default: + value += "\n"; + } + const end = start + header.length + scalar.source.length; + return { value, type, comment: header.comment, range: [start, end, end] }; + } + function parseBlockScalarHeader({ offset, props }, strict, onError) { + if (props[0].type !== "block-scalar-header") { + onError(props[0], "IMPOSSIBLE", "Block scalar header not found"); + return null; + } + const { source } = props[0]; + const mode = source[0]; + let indent = 0; + let chomp = ""; + let error = -1; + for (let i2 = 1; i2 < source.length; ++i2) { + const ch = source[i2]; + if (!chomp && (ch === "-" || ch === "+")) + chomp = ch; + else { + const n2 = Number(ch); + if (!indent && n2) + indent = n2; + else if (error === -1) + error = offset + i2; + } + } + if (error !== -1) + onError(error, "UNEXPECTED_TOKEN", `Block scalar header includes extra characters: ${source}`); + let hasSpace = false; + let comment = ""; + let length = source.length; + for (let i2 = 1; i2 < props.length; ++i2) { + const token = props[i2]; + switch (token.type) { + case "space": + hasSpace = true; + // fallthrough + case "newline": + length += token.source.length; + break; + case "comment": + if (strict && !hasSpace) { + const message = "Comments must be separated from other tokens by white space characters"; + onError(token, "MISSING_CHAR", message); } - } else { - throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"')); - } - } - parseNan() { - if (this.char === CHAR_a) { - return this.next(this.parseNan2); - } else { - throw this.error(new TomlError('Unexpected character, expected "nan"')); + length += token.source.length; + comment = token.source.substring(1); + break; + case "error": + onError(token, "UNEXPECTED_TOKEN", token.message); + length += token.source.length; + break; + /* istanbul ignore next should not happen */ + default: { + const message = `Unexpected token in block scalar header: ${token.type}`; + onError(token, "UNEXPECTED_TOKEN", message); + const ts = token.source; + if (ts && typeof ts === "string") + length += ts.length; } } - parseNan2() { - if (this.char === CHAR_n) { - return this.return(NaN); - } else { - throw this.error(new TomlError('Unexpected character, expected "nan"')); - } + } + return { mode, indent, chomp, comment, length }; + } + function splitLines(source) { + const split = source.split(/\n( *)/); + const first = split[0]; + const m2 = first.match(/^( *)/); + const line0 = m2?.[1] ? [m2[1], first.slice(m2[1].length)] : ["", first]; + const lines = [line0]; + for (let i2 = 1; i2 < split.length; i2 += 2) + lines.push([split[i2], split[i2 + 1]]); + return lines; + } + exports2.resolveBlockScalar = resolveBlockScalar; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/resolve-flow-scalar.js +var require_resolve_flow_scalar = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/resolve-flow-scalar.js"(exports2) { + init_esm_shims(); + var Scalar = require_Scalar(); + var resolveEnd = require_resolve_end(); + function resolveFlowScalar(scalar, strict, onError) { + const { offset, type, source, end } = scalar; + let _type2; + let value; + const _onError = (rel, code, msg) => onError(offset + rel, code, msg); + switch (type) { + case "scalar": + _type2 = Scalar.Scalar.PLAIN; + value = plainValue(source, _onError); + break; + case "single-quoted-scalar": + _type2 = Scalar.Scalar.QUOTE_SINGLE; + value = singleQuotedValue(source, _onError); + break; + case "double-quoted-scalar": + _type2 = Scalar.Scalar.QUOTE_DOUBLE; + value = doubleQuotedValue(source, _onError); + break; + /* istanbul ignore next should not happen */ + default: + onError(scalar, "UNEXPECTED_TOKEN", `Expected a flow scalar value, but found: ${type}`); + return { + value: "", + type: null, + comment: "", + range: [offset, offset + source.length, offset + source.length] + }; + } + const valueEnd = offset + source.length; + const re = resolveEnd.resolveEnd(end, valueEnd, strict, onError); + return { + value, + type: _type2, + comment: re.comment, + range: [offset, valueEnd, re.offset] + }; + } + function plainValue(source, onError) { + let badChar = ""; + switch (source[0]) { + /* istanbul ignore next should not happen */ + case " ": + badChar = "a tab character"; + break; + case ",": + badChar = "flow indicator character ,"; + break; + case "%": + badChar = "directive indicator character %"; + break; + case "|": + case ">": { + badChar = `block scalar indicator ${source[0]}`; + break; } - /* KEYS, barewords or basic, literal, or dotted */ - parseKeyword() { - if (this.char === CHAR_QUOT) { - return this.next(this.parseBasicString); - } else if (this.char === CHAR_APOS) { - return this.next(this.parseLiteralString); - } else { - return this.goto(this.parseBareKey); - } + case "@": + case "`": { + badChar = `reserved character ${source[0]}`; + break; } - /* KEYS: barewords */ - parseBareKey() { - do { - if (this.char === Parser2.END) { - throw this.error(new TomlError("Key ended without value")); - } else if (isAlphaNumHyphen(this.char)) { - this.consume(); - } else if (this.state.buf.length === 0) { - throw this.error(new TomlError("Empty bare keys are not allowed")); - } else { - return this.returnNow(); - } - } while (this.nextChar()); + } + if (badChar) + onError(0, "BAD_SCALAR_START", `Plain value cannot start with ${badChar}`); + return foldLines(source); + } + function singleQuotedValue(source, onError) { + if (source[source.length - 1] !== "'" || source.length === 1) + onError(source.length, "MISSING_CHAR", "Missing closing 'quote"); + return foldLines(source.slice(1, -1)).replace(/''/g, "'"); + } + function foldLines(source) { + let first, line; + try { + first = new RegExp("(.*?)(? wsStart ? source.slice(wsStart, i2 + 1) : ch; + } else { + res += ch; } - parseLiteralString() { - do { - if (this.char === CHAR_APOS) { - return this.return(); - } else if (this.atEndOfLine()) { - throw this.error(new TomlError("Unterminated string")); - } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I) { - throw this.errorControlCharInString(); - } else { - this.consume(); - } - } while (this.nextChar()); + } + if (source[source.length - 1] !== '"' || source.length === 1) + onError(source.length, "MISSING_CHAR", 'Missing closing "quote'); + return res; + } + function foldNewline(source, offset) { + let fold = ""; + let ch = source[offset + 1]; + while (ch === " " || ch === " " || ch === "\n" || ch === "\r") { + if (ch === "\r" && source[offset + 2] !== "\n") + break; + if (ch === "\n") + fold += "\n"; + offset += 1; + ch = source[offset + 1]; + } + if (!fold) + fold = " "; + return { fold, offset }; + } + var escapeCodes = { + "0": "\0", + // null character + a: "\x07", + // bell character + b: "\b", + // backspace + e: "\x1B", + // escape character + f: "\f", + // form feed + n: "\n", + // line feed + r: "\r", + // carriage return + t: " ", + // horizontal tab + v: "\v", + // vertical tab + N: "\x85", + // Unicode next line + _: "\xA0", + // Unicode non-breaking space + L: "\u2028", + // Unicode line separator + P: "\u2029", + // Unicode paragraph separator + " ": " ", + '"': '"', + "/": "/", + "\\": "\\", + " ": " " + }; + function parseCharCode(source, offset, length, onError) { + const cc = source.substr(offset, length); + const ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc); + const code = ok ? parseInt(cc, 16) : NaN; + if (isNaN(code)) { + const raw = source.substr(offset - 2, length + 2); + onError(offset - 2, "BAD_DQ_ESCAPE", `Invalid escape sequence ${raw}`); + return raw; + } + return String.fromCodePoint(code); + } + exports2.resolveFlowScalar = resolveFlowScalar; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/compose-scalar.js +var require_compose_scalar = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/compose-scalar.js"(exports2) { + init_esm_shims(); + var identity = require_identity(); + var Scalar = require_Scalar(); + var resolveBlockScalar = require_resolve_block_scalar(); + var resolveFlowScalar = require_resolve_flow_scalar(); + function composeScalar(ctx, token, tagToken, onError) { + const { value, type, comment, range } = token.type === "block-scalar" ? resolveBlockScalar.resolveBlockScalar(ctx, token, onError) : resolveFlowScalar.resolveFlowScalar(token, ctx.options.strict, onError); + const tagName = tagToken ? ctx.directives.tagName(tagToken.source, (msg) => onError(tagToken, "TAG_RESOLVE_FAILED", msg)) : null; + let tag; + if (ctx.options.stringKeys && ctx.atKey) { + tag = ctx.schema[identity.SCALAR]; + } else if (tagName) + tag = findScalarTagByName(ctx.schema, value, tagName, tagToken, onError); + else if (token.type === "scalar") + tag = findScalarTagByTest(ctx, value, token, onError); + else + tag = ctx.schema[identity.SCALAR]; + let scalar; + try { + const res = tag.resolve(value, (msg) => onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg), ctx.options); + scalar = identity.isScalar(res) ? res : new Scalar.Scalar(res); + } catch (error) { + const msg = error instanceof Error ? error.message : String(error); + onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg); + scalar = new Scalar.Scalar(value); + } + scalar.range = range; + scalar.source = value; + if (type) + scalar.type = type; + if (tagName) + scalar.tag = tagName; + if (tag.format) + scalar.format = tag.format; + if (comment) + scalar.comment = comment; + return scalar; + } + function findScalarTagByName(schema, value, tagName, tagToken, onError) { + if (tagName === "!") + return schema[identity.SCALAR]; + const matchWithTest = []; + for (const tag of schema.tags) { + if (!tag.collection && tag.tag === tagName) { + if (tag.default && tag.test) + matchWithTest.push(tag); + else + return tag; } - parseLiteralMultiStringMaybe() { - if (this.char === CHAR_APOS) { - return this.next(this.parseLiteralMultiString); - } else { - return this.returnNow(); - } + } + for (const tag of matchWithTest) + if (tag.test?.test(value)) + return tag; + const kt = schema.knownTags[tagName]; + if (kt && !kt.collection) { + schema.tags.push(Object.assign({}, kt, { default: false, test: void 0 })); + return kt; + } + onError(tagToken, "TAG_RESOLVE_FAILED", `Unresolved tag: ${tagName}`, tagName !== "tag:yaml.org,2002:str"); + return schema[identity.SCALAR]; + } + function findScalarTagByTest({ atKey, directives, schema }, value, token, onError) { + const tag = schema.tags.find((tag2) => (tag2.default === true || atKey && tag2.default === "key") && tag2.test?.test(value)) || schema[identity.SCALAR]; + if (schema.compat) { + const compat = schema.compat.find((tag2) => tag2.default && tag2.test?.test(value)) ?? schema[identity.SCALAR]; + if (tag.tag !== compat.tag) { + const ts = directives.tagString(tag.tag); + const cs = directives.tagString(compat.tag); + const msg = `Value may be parsed as either ${ts} or ${cs}`; + onError(token, "TAG_RESOLVE_FAILED", msg, true); } - parseLiteralMultiString() { - if (this.char === CTRL_M) { - return null; - } else if (this.char === CTRL_J) { - return this.next(this.parseLiteralMultiStringContent); - } else { - return this.goto(this.parseLiteralMultiStringContent); + } + return tag; + } + exports2.composeScalar = composeScalar; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/util-empty-scalar-position.js +var require_util_empty_scalar_position = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/util-empty-scalar-position.js"(exports2) { + init_esm_shims(); + function emptyScalarPosition(offset, before, pos) { + if (before) { + pos ?? (pos = before.length); + for (let i2 = pos - 1; i2 >= 0; --i2) { + let st = before[i2]; + switch (st.type) { + case "space": + case "comment": + case "newline": + offset -= st.source.length; + continue; + } + st = before[++i2]; + while (st?.type === "space") { + offset += st.source.length; + st = before[++i2]; } + break; } - parseLiteralMultiStringContent() { - do { - if (this.char === CHAR_APOS) { - return this.next(this.parseLiteralMultiEnd); - } else if (this.char === Parser2.END) { - throw this.error(new TomlError("Unterminated multi-line string")); - } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M) { - throw this.errorControlCharInString(); - } else { - this.consume(); - } - } while (this.nextChar()); - } - parseLiteralMultiEnd() { - if (this.char === CHAR_APOS) { - return this.next(this.parseLiteralMultiEnd2); + } + return offset; + } + exports2.emptyScalarPosition = emptyScalarPosition; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/compose-node.js +var require_compose_node = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/compose-node.js"(exports2) { + init_esm_shims(); + var Alias = require_Alias(); + var identity = require_identity(); + var composeCollection = require_compose_collection(); + var composeScalar = require_compose_scalar(); + var resolveEnd = require_resolve_end(); + var utilEmptyScalarPosition = require_util_empty_scalar_position(); + var CN = { composeNode, composeEmptyNode }; + function composeNode(ctx, token, props, onError) { + const atKey = ctx.atKey; + const { spaceBefore, comment, anchor, tag } = props; + let node; + let isSrcToken = true; + switch (token.type) { + case "alias": + node = composeAlias(ctx, token, onError); + if (anchor || tag) + onError(token, "ALIAS_PROPS", "An alias node must not specify any properties"); + break; + case "scalar": + case "single-quoted-scalar": + case "double-quoted-scalar": + case "block-scalar": + node = composeScalar.composeScalar(ctx, token, tag, onError); + if (anchor) + node.anchor = anchor.source.substring(1); + break; + case "block-map": + case "block-seq": + case "flow-collection": + node = composeCollection.composeCollection(CN, ctx, token, props, onError); + if (anchor) + node.anchor = anchor.source.substring(1); + break; + default: { + const message = token.type === "error" ? token.message : `Unsupported token (type: ${token.type})`; + onError(token, "UNEXPECTED_TOKEN", message); + node = composeEmptyNode(ctx, token.offset, void 0, null, props, onError); + isSrcToken = false; + } + } + if (anchor && node.anchor === "") + onError(anchor, "BAD_ALIAS", "Anchor cannot be an empty string"); + if (atKey && ctx.options.stringKeys && (!identity.isScalar(node) || typeof node.value !== "string" || node.tag && node.tag !== "tag:yaml.org,2002:str")) { + const msg = "With stringKeys, all keys must be strings"; + onError(tag ?? token, "NON_STRING_KEY", msg); + } + if (spaceBefore) + node.spaceBefore = true; + if (comment) { + if (token.type === "scalar" && token.source === "") + node.comment = comment; + else + node.commentBefore = comment; + } + if (ctx.options.keepSourceTokens && isSrcToken) + node.srcToken = token; + return node; + } + function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anchor, tag, end }, onError) { + const token = { + type: "scalar", + offset: utilEmptyScalarPosition.emptyScalarPosition(offset, before, pos), + indent: -1, + source: "" + }; + const node = composeScalar.composeScalar(ctx, token, tag, onError); + if (anchor) { + node.anchor = anchor.source.substring(1); + if (node.anchor === "") + onError(anchor, "BAD_ALIAS", "Anchor cannot be an empty string"); + } + if (spaceBefore) + node.spaceBefore = true; + if (comment) { + node.comment = comment; + node.range[2] = end; + } + return node; + } + function composeAlias({ options }, { offset, source, end }, onError) { + const alias = new Alias.Alias(source.substring(1)); + if (alias.source === "") + onError(offset, "BAD_ALIAS", "Alias cannot be an empty string"); + if (alias.source.endsWith(":")) + onError(offset + source.length - 1, "BAD_ALIAS", "Alias ending in : is ambiguous", true); + const valueEnd = offset + source.length; + const re = resolveEnd.resolveEnd(end, valueEnd, options.strict, onError); + alias.range = [offset, valueEnd, re.offset]; + if (re.comment) + alias.comment = re.comment; + return alias; + } + exports2.composeEmptyNode = composeEmptyNode; + exports2.composeNode = composeNode; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/compose-doc.js +var require_compose_doc = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/compose-doc.js"(exports2) { + init_esm_shims(); + var Document = require_Document(); + var composeNode = require_compose_node(); + var resolveEnd = require_resolve_end(); + var resolveProps = require_resolve_props(); + function composeDoc(options, directives, { offset, start, value, end }, onError) { + const opts = Object.assign({ _directives: directives }, options); + const doc = new Document.Document(void 0, opts); + const ctx = { + atKey: false, + atRoot: true, + directives: doc.directives, + options: doc.options, + schema: doc.schema + }; + const props = resolveProps.resolveProps(start, { + indicator: "doc-start", + next: value ?? end?.[0], + offset, + onError, + parentIndent: 0, + startOnNewline: true + }); + if (props.found) { + doc.directives.docStart = true; + if (value && (value.type === "block-map" || value.type === "block-seq") && !props.hasNewline) + onError(props.end, "MISSING_CHAR", "Block collection cannot start on same line with directives-end marker"); + } + doc.contents = value ? composeNode.composeNode(ctx, value, props, onError) : composeNode.composeEmptyNode(ctx, props.end, start, null, props, onError); + const contentEnd = doc.contents.range[2]; + const re = resolveEnd.resolveEnd(end, contentEnd, false, onError); + if (re.comment) + doc.comment = re.comment; + doc.range = [offset, contentEnd, re.offset]; + return doc; + } + exports2.composeDoc = composeDoc; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/composer.js +var require_composer = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/composer.js"(exports2) { + init_esm_shims(); + var node_process = __require("process"); + var directives = require_directives(); + var Document = require_Document(); + var errors = require_errors(); + var identity = require_identity(); + var composeDoc = require_compose_doc(); + var resolveEnd = require_resolve_end(); + function getErrorPos(src) { + if (typeof src === "number") + return [src, src + 1]; + if (Array.isArray(src)) + return src.length === 2 ? src : [src[0], src[1]]; + const { offset, source } = src; + return [offset, offset + (typeof source === "string" ? source.length : 1)]; + } + function parsePrelude(prelude) { + let comment = ""; + let atComment = false; + let afterEmptyLine = false; + for (let i2 = 0; i2 < prelude.length; ++i2) { + const source = prelude[i2]; + switch (source[0]) { + case "#": + comment += (comment === "" ? "" : afterEmptyLine ? "\n\n" : "\n") + (source.substring(1) || " "); + atComment = true; + afterEmptyLine = false; + break; + case "%": + if (prelude[i2 + 1]?.[0] !== "#") + i2 += 1; + atComment = false; + break; + default: + if (!atComment) + afterEmptyLine = true; + atComment = false; + } + } + return { comment, afterEmptyLine }; + } + var Composer = class { + constructor(options = {}) { + this.doc = null; + this.atDirectives = false; + this.prelude = []; + this.errors = []; + this.warnings = []; + this.onError = (source, code, message, warning) => { + const pos = getErrorPos(source); + if (warning) + this.warnings.push(new errors.YAMLWarning(pos, code, message)); + else + this.errors.push(new errors.YAMLParseError(pos, code, message)); + }; + this.directives = new directives.Directives({ version: options.version || "1.2" }); + this.options = options; + } + decorate(doc, afterDoc) { + const { comment, afterEmptyLine } = parsePrelude(this.prelude); + if (comment) { + const dc = doc.contents; + if (afterDoc) { + doc.comment = doc.comment ? `${doc.comment} +${comment}` : comment; + } else if (afterEmptyLine || doc.directives.docStart || !dc) { + doc.commentBefore = comment; + } else if (identity.isCollection(dc) && !dc.flow && dc.items.length > 0) { + let it = dc.items[0]; + if (identity.isPair(it)) + it = it.key; + const cb = it.commentBefore; + it.commentBefore = cb ? `${comment} +${cb}` : comment; } else { - this.state.buf += "'"; - return this.goto(this.parseLiteralMultiStringContent); + const cb = dc.commentBefore; + dc.commentBefore = cb ? `${comment} +${cb}` : comment; } } - parseLiteralMultiEnd2() { - if (this.char === CHAR_APOS) { - return this.return(); - } else { - this.state.buf += "''"; - return this.goto(this.parseLiteralMultiStringContent); + if (afterDoc) { + Array.prototype.push.apply(doc.errors, this.errors); + Array.prototype.push.apply(doc.warnings, this.warnings); + } else { + doc.errors = this.errors; + doc.warnings = this.warnings; + } + this.prelude = []; + this.errors = []; + this.warnings = []; + } + /** + * Current stream status information. + * + * Mostly useful at the end of input for an empty stream. + */ + streamInfo() { + return { + comment: parsePrelude(this.prelude).comment, + directives: this.directives, + errors: this.errors, + warnings: this.warnings + }; + } + /** + * Compose tokens into documents. + * + * @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document. + * @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly. + */ + *compose(tokens, forceDoc = false, endOffset = -1) { + for (const token of tokens) + yield* this.next(token); + yield* this.end(forceDoc, endOffset); + } + /** Advance the composer by one CST token. */ + *next(token) { + if (node_process.env.LOG_STREAM) + console.dir(token, { depth: null }); + switch (token.type) { + case "directive": + this.directives.add(token.source, (offset, message, warning) => { + const pos = getErrorPos(token); + pos[0] += offset; + this.onError(pos, "BAD_DIRECTIVE", message, warning); + }); + this.prelude.push(token.source); + this.atDirectives = true; + break; + case "document": { + const doc = composeDoc.composeDoc(this.options, this.directives, token, this.onError); + if (this.atDirectives && !doc.directives.docStart) + this.onError(token, "MISSING_CHAR", "Missing directives-end/doc-start indicator line"); + this.decorate(doc, false); + if (this.doc) + yield this.doc; + this.doc = doc; + this.atDirectives = false; + break; } - } - /* STRINGS double quoted */ - parseDoubleString() { - if (this.char === CHAR_QUOT) { - return this.next(this.parseMultiStringMaybe); - } else { - return this.goto(this.parseBasicString); + case "byte-order-mark": + case "space": + break; + case "comment": + case "newline": + this.prelude.push(token.source); + break; + case "error": { + const msg = token.source ? `${token.message}: ${JSON.stringify(token.source)}` : token.message; + const error = new errors.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", msg); + if (this.atDirectives || !this.doc) + this.errors.push(error); + else + this.doc.errors.push(error); + break; } - } - parseBasicString() { - do { - if (this.char === CHAR_BSOL) { - return this.call(this.parseEscape, this.recordEscapeReplacement); - } else if (this.char === CHAR_QUOT) { - return this.return(); - } else if (this.atEndOfLine()) { - throw this.error(new TomlError("Unterminated string")); - } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I) { - throw this.errorControlCharInString(); - } else { - this.consume(); + case "doc-end": { + if (!this.doc) { + const msg = "Unexpected doc-end without preceding document"; + this.errors.push(new errors.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", msg)); + break; } - } while (this.nextChar()); + this.doc.directives.docEnd = true; + const end = resolveEnd.resolveEnd(token.end, token.offset + token.source.length, this.doc.options.strict, this.onError); + this.decorate(this.doc, true); + if (end.comment) { + const dc = this.doc.comment; + this.doc.comment = dc ? `${dc} +${end.comment}` : end.comment; + } + this.doc.range[2] = end.offset; + break; + } + default: + this.errors.push(new errors.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", `Unsupported token ${token.type}`)); + } + } + /** + * Call at end of input to yield any remaining document. + * + * @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document. + * @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly. + */ + *end(forceDoc = false, endOffset = -1) { + if (this.doc) { + this.decorate(this.doc, true); + yield this.doc; + this.doc = null; + } else if (forceDoc) { + const opts = Object.assign({ _directives: this.directives }, this.options); + const doc = new Document.Document(void 0, opts); + if (this.atDirectives) + this.onError(endOffset, "MISSING_CHAR", "Missing directives-end indicator line"); + doc.range = [0, endOffset, endOffset]; + this.decorate(doc, false); + yield doc; } - recordEscapeReplacement(replacement) { - this.state.buf += replacement; - return this.goto(this.parseBasicString); + } + }; + exports2.Composer = Composer; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/parse/cst-scalar.js +var require_cst_scalar = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/parse/cst-scalar.js"(exports2) { + init_esm_shims(); + var resolveBlockScalar = require_resolve_block_scalar(); + var resolveFlowScalar = require_resolve_flow_scalar(); + var errors = require_errors(); + var stringifyString = require_stringifyString(); + function resolveAsScalar(token, strict = true, onError) { + if (token) { + const _onError = (pos, code, message) => { + const offset = typeof pos === "number" ? pos : Array.isArray(pos) ? pos[0] : pos.offset; + if (onError) + onError(offset, code, message); + else + throw new errors.YAMLParseError([offset, offset + 1], code, message); + }; + switch (token.type) { + case "scalar": + case "single-quoted-scalar": + case "double-quoted-scalar": + return resolveFlowScalar.resolveFlowScalar(token, strict, _onError); + case "block-scalar": + return resolveBlockScalar.resolveBlockScalar({ options: { strict } }, token, _onError); } - parseMultiStringMaybe() { - if (this.char === CHAR_QUOT) { - return this.next(this.parseMultiString); - } else { - return this.returnNow(); + } + return null; + } + function createScalarToken(value, context) { + const { implicitKey = false, indent, inFlow = false, offset = -1, type = "PLAIN" } = context; + const source = stringifyString.stringifyString({ type, value }, { + implicitKey, + indent: indent > 0 ? " ".repeat(indent) : "", + inFlow, + options: { blockQuote: true, lineWidth: -1 } + }); + const end = context.end ?? [ + { type: "newline", offset: -1, indent, source: "\n" } + ]; + switch (source[0]) { + case "|": + case ">": { + const he = source.indexOf("\n"); + const head = source.substring(0, he); + const body = source.substring(he + 1) + "\n"; + const props = [ + { type: "block-scalar-header", offset, indent, source: head } + ]; + if (!addEndtoBlockProps(props, end)) + props.push({ type: "newline", offset: -1, indent, source: "\n" }); + return { type: "block-scalar", offset, indent, props, source: body }; + } + case '"': + return { type: "double-quoted-scalar", offset, indent, source, end }; + case "'": + return { type: "single-quoted-scalar", offset, indent, source, end }; + default: + return { type: "scalar", offset, indent, source, end }; + } + } + function setScalarValue(token, value, context = {}) { + let { afterKey = false, implicitKey = false, inFlow = false, type } = context; + let indent = "indent" in token ? token.indent : null; + if (afterKey && typeof indent === "number") + indent += 2; + if (!type) + switch (token.type) { + case "single-quoted-scalar": + type = "QUOTE_SINGLE"; + break; + case "double-quoted-scalar": + type = "QUOTE_DOUBLE"; + break; + case "block-scalar": { + const header = token.props[0]; + if (header.type !== "block-scalar-header") + throw new Error("Invalid block scalar header"); + type = header.source[0] === ">" ? "BLOCK_FOLDED" : "BLOCK_LITERAL"; + break; } + default: + type = "PLAIN"; } - parseMultiString() { - if (this.char === CTRL_M) { - return null; - } else if (this.char === CTRL_J) { - return this.next(this.parseMultiStringContent); - } else { - return this.goto(this.parseMultiStringContent); + const source = stringifyString.stringifyString({ type, value }, { + implicitKey: implicitKey || indent === null, + indent: indent !== null && indent > 0 ? " ".repeat(indent) : "", + inFlow, + options: { blockQuote: true, lineWidth: -1 } + }); + switch (source[0]) { + case "|": + case ">": + setBlockScalarValue(token, source); + break; + case '"': + setFlowScalarValue(token, source, "double-quoted-scalar"); + break; + case "'": + setFlowScalarValue(token, source, "single-quoted-scalar"); + break; + default: + setFlowScalarValue(token, source, "scalar"); + } + } + function setBlockScalarValue(token, source) { + const he = source.indexOf("\n"); + const head = source.substring(0, he); + const body = source.substring(he + 1) + "\n"; + if (token.type === "block-scalar") { + const header = token.props[0]; + if (header.type !== "block-scalar-header") + throw new Error("Invalid block scalar header"); + header.source = head; + token.source = body; + } else { + const { offset } = token; + const indent = "indent" in token ? token.indent : -1; + const props = [ + { type: "block-scalar-header", offset, indent, source: head } + ]; + if (!addEndtoBlockProps(props, "end" in token ? token.end : void 0)) + props.push({ type: "newline", offset: -1, indent, source: "\n" }); + for (const key of Object.keys(token)) + if (key !== "type" && key !== "offset") + delete token[key]; + Object.assign(token, { type: "block-scalar", indent, props, source: body }); + } + } + function addEndtoBlockProps(props, end) { + if (end) + for (const st of end) + switch (st.type) { + case "space": + case "comment": + props.push(st); + break; + case "newline": + props.push(st); + return true; } + return false; + } + function setFlowScalarValue(token, source, type) { + switch (token.type) { + case "scalar": + case "double-quoted-scalar": + case "single-quoted-scalar": + token.type = type; + token.source = source; + break; + case "block-scalar": { + const end = token.props.slice(1); + let oa = source.length; + if (token.props[0].type === "block-scalar-header") + oa -= token.props[0].source.length; + for (const tok of end) + tok.offset += oa; + delete token.props; + Object.assign(token, { type, source, end }); + break; } - parseMultiStringContent() { - do { - if (this.char === CHAR_BSOL) { - return this.call(this.parseMultiEscape, this.recordMultiEscapeReplacement); - } else if (this.char === CHAR_QUOT) { - return this.next(this.parseMultiEnd); - } else if (this.char === Parser2.END) { - throw this.error(new TomlError("Unterminated multi-line string")); - } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M) { - throw this.errorControlCharInString(); - } else { - this.consume(); - } - } while (this.nextChar()); - } - errorControlCharInString() { - let displayCode = "\\u00"; - if (this.char < 16) { - displayCode += "0"; - } - displayCode += this.char.toString(16); - return this.error(new TomlError(`Control characters (codes < 0x1f and 0x7f) are not allowed in strings, use ${displayCode} instead`)); + case "block-map": + case "block-seq": { + const offset = token.offset + source.length; + const nl = { type: "newline", offset, indent: token.indent, source: "\n" }; + delete token.items; + Object.assign(token, { type, source, end: [nl] }); + break; } - recordMultiEscapeReplacement(replacement) { - this.state.buf += replacement; - return this.goto(this.parseMultiStringContent); + default: { + const indent = "indent" in token ? token.indent : -1; + const end = "end" in token && Array.isArray(token.end) ? token.end.filter((st) => st.type === "space" || st.type === "comment" || st.type === "newline") : []; + for (const key of Object.keys(token)) + if (key !== "type" && key !== "offset") + delete token[key]; + Object.assign(token, { type, indent, source, end }); } - parseMultiEnd() { - if (this.char === CHAR_QUOT) { - return this.next(this.parseMultiEnd2); - } else { - this.state.buf += '"'; - return this.goto(this.parseMultiStringContent); + } + } + exports2.createScalarToken = createScalarToken; + exports2.resolveAsScalar = resolveAsScalar; + exports2.setScalarValue = setScalarValue; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/parse/cst-stringify.js +var require_cst_stringify = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/parse/cst-stringify.js"(exports2) { + init_esm_shims(); + var stringify = (cst) => "type" in cst ? stringifyToken(cst) : stringifyItem(cst); + function stringifyToken(token) { + switch (token.type) { + case "block-scalar": { + let res = ""; + for (const tok of token.props) + res += stringifyToken(tok); + return res + token.source; + } + case "block-map": + case "block-seq": { + let res = ""; + for (const item of token.items) + res += stringifyItem(item); + return res; + } + case "flow-collection": { + let res = token.start.source; + for (const item of token.items) + res += stringifyItem(item); + for (const st of token.end) + res += st.source; + return res; + } + case "document": { + let res = stringifyItem(token); + if (token.end) + for (const st of token.end) + res += st.source; + return res; + } + default: { + let res = token.source; + if ("end" in token && token.end) + for (const st of token.end) + res += st.source; + return res; + } + } + } + function stringifyItem({ start, key, sep, value }) { + let res = ""; + for (const st of start) + res += st.source; + if (key) + res += stringifyToken(key); + if (sep) + for (const st of sep) + res += st.source; + if (value) + res += stringifyToken(value); + return res; + } + exports2.stringify = stringify; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/parse/cst-visit.js +var require_cst_visit = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/parse/cst-visit.js"(exports2) { + init_esm_shims(); + var BREAK = /* @__PURE__ */ Symbol("break visit"); + var SKIP = /* @__PURE__ */ Symbol("skip children"); + var REMOVE = /* @__PURE__ */ Symbol("remove item"); + function visit(cst, visitor) { + if ("type" in cst && cst.type === "document") + cst = { start: cst.start, value: cst.value }; + _visit(Object.freeze([]), cst, visitor); + } + visit.BREAK = BREAK; + visit.SKIP = SKIP; + visit.REMOVE = REMOVE; + visit.itemAtPath = (cst, path4) => { + let item = cst; + for (const [field, index] of path4) { + const tok = item?.[field]; + if (tok && "items" in tok) { + item = tok.items[index]; + } else + return void 0; + } + return item; + }; + visit.parentCollection = (cst, path4) => { + const parent = visit.itemAtPath(cst, path4.slice(0, -1)); + const field = path4[path4.length - 1][0]; + const coll = parent?.[field]; + if (coll && "items" in coll) + return coll; + throw new Error("Parent collection not found"); + }; + function _visit(path4, item, visitor) { + let ctrl = visitor(item, path4); + if (typeof ctrl === "symbol") + return ctrl; + for (const field of ["key", "value"]) { + const token = item[field]; + if (token && "items" in token) { + for (let i2 = 0; i2 < token.items.length; ++i2) { + const ci = _visit(Object.freeze(path4.concat([[field, i2]])), token.items[i2], visitor); + if (typeof ci === "number") + i2 = ci - 1; + else if (ci === BREAK) + return BREAK; + else if (ci === REMOVE) { + token.items.splice(i2, 1); + i2 -= 1; + } } + if (typeof ctrl === "function" && field === "key") + ctrl = ctrl(item, path4); } - parseMultiEnd2() { - if (this.char === CHAR_QUOT) { - return this.return(); + } + return typeof ctrl === "function" ? ctrl(item, path4) : ctrl; + } + exports2.visit = visit; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/parse/cst.js +var require_cst = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/parse/cst.js"(exports2) { + init_esm_shims(); + var cstScalar = require_cst_scalar(); + var cstStringify = require_cst_stringify(); + var cstVisit = require_cst_visit(); + var BOM = "\uFEFF"; + var DOCUMENT = ""; + var FLOW_END = ""; + var SCALAR = ""; + var isCollection = (token) => !!token && "items" in token; + var isScalar = (token) => !!token && (token.type === "scalar" || token.type === "single-quoted-scalar" || token.type === "double-quoted-scalar" || token.type === "block-scalar"); + function prettyToken(token) { + switch (token) { + case BOM: + return ""; + case DOCUMENT: + return ""; + case FLOW_END: + return ""; + case SCALAR: + return ""; + default: + return JSON.stringify(token); + } + } + function tokenType(source) { + switch (source) { + case BOM: + return "byte-order-mark"; + case DOCUMENT: + return "doc-mode"; + case FLOW_END: + return "flow-error-end"; + case SCALAR: + return "scalar"; + case "---": + return "doc-start"; + case "...": + return "doc-end"; + case "": + case "\n": + case "\r\n": + return "newline"; + case "-": + return "seq-item-ind"; + case "?": + return "explicit-key-ind"; + case ":": + return "map-value-ind"; + case "{": + return "flow-map-start"; + case "}": + return "flow-map-end"; + case "[": + return "flow-seq-start"; + case "]": + return "flow-seq-end"; + case ",": + return "comma"; + } + switch (source[0]) { + case " ": + case " ": + return "space"; + case "#": + return "comment"; + case "%": + return "directive-line"; + case "*": + return "alias"; + case "&": + return "anchor"; + case "!": + return "tag"; + case "'": + return "single-quoted-scalar"; + case '"': + return "double-quoted-scalar"; + case "|": + case ">": + return "block-scalar-header"; + } + return null; + } + exports2.createScalarToken = cstScalar.createScalarToken; + exports2.resolveAsScalar = cstScalar.resolveAsScalar; + exports2.setScalarValue = cstScalar.setScalarValue; + exports2.stringify = cstStringify.stringify; + exports2.visit = cstVisit.visit; + exports2.BOM = BOM; + exports2.DOCUMENT = DOCUMENT; + exports2.FLOW_END = FLOW_END; + exports2.SCALAR = SCALAR; + exports2.isCollection = isCollection; + exports2.isScalar = isScalar; + exports2.prettyToken = prettyToken; + exports2.tokenType = tokenType; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/parse/lexer.js +var require_lexer = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/parse/lexer.js"(exports2) { + init_esm_shims(); + var cst = require_cst(); + function isEmpty(ch) { + switch (ch) { + case void 0: + case " ": + case "\n": + case "\r": + case " ": + return true; + default: + return false; + } + } + var hexDigits = new Set("0123456789ABCDEFabcdef"); + var tagChars = new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"); + var flowIndicatorChars = new Set(",[]{}"); + var invalidAnchorChars = new Set(" ,[]{}\n\r "); + var isNotAnchorChar = (ch) => !ch || invalidAnchorChars.has(ch); + var Lexer = class { + constructor() { + this.atEnd = false; + this.blockScalarIndent = -1; + this.blockScalarKeep = false; + this.buffer = ""; + this.flowKey = false; + this.flowLevel = 0; + this.indentNext = 0; + this.indentValue = 0; + this.lineEndPos = null; + this.next = null; + this.pos = 0; + } + /** + * Generate YAML tokens from the `source` string. If `incomplete`, + * a part of the last line may be left as a buffer for the next call. + * + * @returns A generator of lexical tokens + */ + *lex(source, incomplete = false) { + if (source) { + if (typeof source !== "string") + throw TypeError("source is not a string"); + this.buffer = this.buffer ? this.buffer + source : source; + this.lineEndPos = null; + } + this.atEnd = !incomplete; + let next = this.next ?? "stream"; + while (next && (incomplete || this.hasChars(1))) + next = yield* this.parseNext(next); + } + atLineEnd() { + let i2 = this.pos; + let ch = this.buffer[i2]; + while (ch === " " || ch === " ") + ch = this.buffer[++i2]; + if (!ch || ch === "#" || ch === "\n") + return true; + if (ch === "\r") + return this.buffer[i2 + 1] === "\n"; + return false; + } + charAt(n2) { + return this.buffer[this.pos + n2]; + } + continueScalar(offset) { + let ch = this.buffer[offset]; + if (this.indentNext > 0) { + let indent = 0; + while (ch === " ") + ch = this.buffer[++indent + offset]; + if (ch === "\r") { + const next = this.buffer[indent + offset + 1]; + if (next === "\n" || !next && !this.atEnd) + return offset + indent + 1; + } + return ch === "\n" || indent >= this.indentNext || !ch && !this.atEnd ? offset + indent : -1; + } + if (ch === "-" || ch === ".") { + const dt = this.buffer.substr(offset, 3); + if ((dt === "---" || dt === "...") && isEmpty(this.buffer[offset + 3])) + return -1; + } + return offset; + } + getLine() { + let end = this.lineEndPos; + if (typeof end !== "number" || end !== -1 && end < this.pos) { + end = this.buffer.indexOf("\n", this.pos); + this.lineEndPos = end; + } + if (end === -1) + return this.atEnd ? this.buffer.substring(this.pos) : null; + if (this.buffer[end - 1] === "\r") + end -= 1; + return this.buffer.substring(this.pos, end); + } + hasChars(n2) { + return this.pos + n2 <= this.buffer.length; + } + setNext(state) { + this.buffer = this.buffer.substring(this.pos); + this.pos = 0; + this.lineEndPos = null; + this.next = state; + return null; + } + peek(n2) { + return this.buffer.substr(this.pos, n2); + } + *parseNext(next) { + switch (next) { + case "stream": + return yield* this.parseStream(); + case "line-start": + return yield* this.parseLineStart(); + case "block-start": + return yield* this.parseBlockStart(); + case "doc": + return yield* this.parseDocument(); + case "flow": + return yield* this.parseFlowCollection(); + case "quoted-scalar": + return yield* this.parseQuotedScalar(); + case "block-scalar": + return yield* this.parseBlockScalar(); + case "plain-scalar": + return yield* this.parsePlainScalar(); + } + } + *parseStream() { + let line = this.getLine(); + if (line === null) + return this.setNext("stream"); + if (line[0] === cst.BOM) { + yield* this.pushCount(1); + line = line.substring(1); + } + if (line[0] === "%") { + let dirEnd = line.length; + let cs = line.indexOf("#"); + while (cs !== -1) { + const ch = line[cs - 1]; + if (ch === " " || ch === " ") { + dirEnd = cs - 1; + break; + } else { + cs = line.indexOf("#", cs + 1); + } + } + while (true) { + const ch = line[dirEnd - 1]; + if (ch === " " || ch === " ") + dirEnd -= 1; + else + break; + } + const n2 = (yield* this.pushCount(dirEnd)) + (yield* this.pushSpaces(true)); + yield* this.pushCount(line.length - n2); + this.pushNewline(); + return "stream"; + } + if (this.atLineEnd()) { + const sp = yield* this.pushSpaces(true); + yield* this.pushCount(line.length - sp); + yield* this.pushNewline(); + return "stream"; + } + yield cst.DOCUMENT; + return yield* this.parseLineStart(); + } + *parseLineStart() { + const ch = this.charAt(0); + if (!ch && !this.atEnd) + return this.setNext("line-start"); + if (ch === "-" || ch === ".") { + if (!this.atEnd && !this.hasChars(4)) + return this.setNext("line-start"); + const s2 = this.peek(3); + if ((s2 === "---" || s2 === "...") && isEmpty(this.charAt(3))) { + yield* this.pushCount(3); + this.indentValue = 0; + this.indentNext = 0; + return s2 === "---" ? "doc" : "stream"; + } + } + this.indentValue = yield* this.pushSpaces(false); + if (this.indentNext > this.indentValue && !isEmpty(this.charAt(1))) + this.indentNext = this.indentValue; + return yield* this.parseBlockStart(); + } + *parseBlockStart() { + const [ch0, ch1] = this.peek(2); + if (!ch1 && !this.atEnd) + return this.setNext("block-start"); + if ((ch0 === "-" || ch0 === "?" || ch0 === ":") && isEmpty(ch1)) { + const n2 = (yield* this.pushCount(1)) + (yield* this.pushSpaces(true)); + this.indentNext = this.indentValue + 1; + this.indentValue += n2; + return yield* this.parseBlockStart(); + } + return "doc"; + } + *parseDocument() { + yield* this.pushSpaces(true); + const line = this.getLine(); + if (line === null) + return this.setNext("doc"); + let n2 = yield* this.pushIndicators(); + switch (line[n2]) { + case "#": + yield* this.pushCount(line.length - n2); + // fallthrough + case void 0: + yield* this.pushNewline(); + return yield* this.parseLineStart(); + case "{": + case "[": + yield* this.pushCount(1); + this.flowKey = false; + this.flowLevel = 1; + return "flow"; + case "}": + case "]": + yield* this.pushCount(1); + return "doc"; + case "*": + yield* this.pushUntil(isNotAnchorChar); + return "doc"; + case '"': + case "'": + return yield* this.parseQuotedScalar(); + case "|": + case ">": + n2 += yield* this.parseBlockScalarHeader(); + n2 += yield* this.pushSpaces(true); + yield* this.pushCount(line.length - n2); + yield* this.pushNewline(); + return yield* this.parseBlockScalar(); + default: + return yield* this.parsePlainScalar(); + } + } + *parseFlowCollection() { + let nl, sp; + let indent = -1; + do { + nl = yield* this.pushNewline(); + if (nl > 0) { + sp = yield* this.pushSpaces(false); + this.indentValue = indent = sp; } else { - this.state.buf += '""'; - return this.goto(this.parseMultiStringContent); + sp = 0; + } + sp += yield* this.pushSpaces(true); + } while (nl + sp > 0); + const line = this.getLine(); + if (line === null) + return this.setNext("flow"); + if (indent !== -1 && indent < this.indentNext && line[0] !== "#" || indent === 0 && (line.startsWith("---") || line.startsWith("...")) && isEmpty(line[3])) { + const atFlowEndMarker = indent === this.indentNext - 1 && this.flowLevel === 1 && (line[0] === "]" || line[0] === "}"); + if (!atFlowEndMarker) { + this.flowLevel = 0; + yield cst.FLOW_END; + return yield* this.parseLineStart(); + } + } + let n2 = 0; + while (line[n2] === ",") { + n2 += yield* this.pushCount(1); + n2 += yield* this.pushSpaces(true); + this.flowKey = false; + } + n2 += yield* this.pushIndicators(); + switch (line[n2]) { + case void 0: + return "flow"; + case "#": + yield* this.pushCount(line.length - n2); + return "flow"; + case "{": + case "[": + yield* this.pushCount(1); + this.flowKey = false; + this.flowLevel += 1; + return "flow"; + case "}": + case "]": + yield* this.pushCount(1); + this.flowKey = true; + this.flowLevel -= 1; + return this.flowLevel ? "flow" : "doc"; + case "*": + yield* this.pushUntil(isNotAnchorChar); + return "flow"; + case '"': + case "'": + this.flowKey = true; + return yield* this.parseQuotedScalar(); + case ":": { + const next = this.charAt(1); + if (this.flowKey || isEmpty(next) || next === ",") { + this.flowKey = false; + yield* this.pushCount(1); + yield* this.pushSpaces(true); + return "flow"; + } } + // fallthrough + default: + this.flowKey = false; + return yield* this.parsePlainScalar(); } - parseMultiEscape() { - if (this.char === CTRL_M || this.char === CTRL_J) { - return this.next(this.parseMultiTrim); - } else if (this.char === CHAR_SP || this.char === CTRL_I) { - return this.next(this.parsePreMultiTrim); - } else { - return this.goto(this.parseEscape); + } + *parseQuotedScalar() { + const quote = this.charAt(0); + let end = this.buffer.indexOf(quote, this.pos + 1); + if (quote === "'") { + while (end !== -1 && this.buffer[end + 1] === "'") + end = this.buffer.indexOf("'", end + 2); + } else { + while (end !== -1) { + let n2 = 0; + while (this.buffer[end - 1 - n2] === "\\") + n2 += 1; + if (n2 % 2 === 0) + break; + end = this.buffer.indexOf('"', end + 1); } } - parsePreMultiTrim() { - if (this.char === CHAR_SP || this.char === CTRL_I) { - return null; - } else if (this.char === CTRL_M || this.char === CTRL_J) { - return this.next(this.parseMultiTrim); - } else { - throw this.error(new TomlError("Can't escape whitespace")); + const qb = this.buffer.substring(0, end); + let nl = qb.indexOf("\n", this.pos); + if (nl !== -1) { + while (nl !== -1) { + const cs = this.continueScalar(nl + 1); + if (cs === -1) + break; + nl = qb.indexOf("\n", cs); + } + if (nl !== -1) { + end = nl - (qb[nl - 1] === "\r" ? 2 : 1); + } + } + if (end === -1) { + if (!this.atEnd) + return this.setNext("quoted-scalar"); + end = this.buffer.length; + } + yield* this.pushToIndex(end + 1, false); + return this.flowLevel ? "flow" : "doc"; + } + *parseBlockScalarHeader() { + this.blockScalarIndent = -1; + this.blockScalarKeep = false; + let i2 = this.pos; + while (true) { + const ch = this.buffer[++i2]; + if (ch === "+") + this.blockScalarKeep = true; + else if (ch > "0" && ch <= "9") + this.blockScalarIndent = Number(ch) - 1; + else if (ch !== "-") + break; + } + return yield* this.pushUntil((ch) => isEmpty(ch) || ch === "#"); + } + *parseBlockScalar() { + let nl = this.pos - 1; + let indent = 0; + let ch; + loop: for (let i3 = this.pos; ch = this.buffer[i3]; ++i3) { + switch (ch) { + case " ": + indent += 1; + break; + case "\n": + nl = i3; + indent = 0; + break; + case "\r": { + const next = this.buffer[i3 + 1]; + if (!next && !this.atEnd) + return this.setNext("block-scalar"); + if (next === "\n") + break; + } + // fallthrough + default: + break loop; } } - parseMultiTrim() { - if (this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) { - return null; + if (!ch && !this.atEnd) + return this.setNext("block-scalar"); + if (indent >= this.indentNext) { + if (this.blockScalarIndent === -1) + this.indentNext = indent; + else { + this.indentNext = this.blockScalarIndent + (this.indentNext === 0 ? 1 : this.indentNext); + } + do { + const cs = this.continueScalar(nl + 1); + if (cs === -1) + break; + nl = this.buffer.indexOf("\n", cs); + } while (nl !== -1); + if (nl === -1) { + if (!this.atEnd) + return this.setNext("block-scalar"); + nl = this.buffer.length; + } + } + let i2 = nl + 1; + ch = this.buffer[i2]; + while (ch === " ") + ch = this.buffer[++i2]; + if (ch === " ") { + while (ch === " " || ch === " " || ch === "\r" || ch === "\n") + ch = this.buffer[++i2]; + nl = i2 - 1; + } else if (!this.blockScalarKeep) { + do { + let i3 = nl - 1; + let ch2 = this.buffer[i3]; + if (ch2 === "\r") + ch2 = this.buffer[--i3]; + const lastChar = i3; + while (ch2 === " ") + ch2 = this.buffer[--i3]; + if (ch2 === "\n" && i3 >= this.pos && i3 + 1 + indent > lastChar) + nl = i3; + else + break; + } while (true); + } + yield cst.SCALAR; + yield* this.pushToIndex(nl + 1, true); + return yield* this.parseLineStart(); + } + *parsePlainScalar() { + const inFlow = this.flowLevel > 0; + let end = this.pos - 1; + let i2 = this.pos - 1; + let ch; + while (ch = this.buffer[++i2]) { + if (ch === ":") { + const next = this.buffer[i2 + 1]; + if (isEmpty(next) || inFlow && flowIndicatorChars.has(next)) + break; + end = i2; + } else if (isEmpty(ch)) { + let next = this.buffer[i2 + 1]; + if (ch === "\r") { + if (next === "\n") { + i2 += 1; + ch = "\n"; + next = this.buffer[i2 + 1]; + } else + end = i2; + } + if (next === "#" || inFlow && flowIndicatorChars.has(next)) + break; + if (ch === "\n") { + const cs = this.continueScalar(i2 + 1); + if (cs === -1) + break; + i2 = Math.max(i2, cs - 2); + } } else { - return this.returnNow(); + if (inFlow && flowIndicatorChars.has(ch)) + break; + end = i2; + } + } + if (!ch && !this.atEnd) + return this.setNext("plain-scalar"); + yield cst.SCALAR; + yield* this.pushToIndex(end + 1, true); + return inFlow ? "flow" : "doc"; + } + *pushCount(n2) { + if (n2 > 0) { + yield this.buffer.substr(this.pos, n2); + this.pos += n2; + return n2; + } + return 0; + } + *pushToIndex(i2, allowEmpty) { + const s2 = this.buffer.slice(this.pos, i2); + if (s2) { + yield s2; + this.pos += s2.length; + return s2.length; + } else if (allowEmpty) + yield ""; + return 0; + } + *pushIndicators() { + switch (this.charAt(0)) { + case "!": + return (yield* this.pushTag()) + (yield* this.pushSpaces(true)) + (yield* this.pushIndicators()); + case "&": + return (yield* this.pushUntil(isNotAnchorChar)) + (yield* this.pushSpaces(true)) + (yield* this.pushIndicators()); + case "-": + // this is an error + case "?": + // this is an error outside flow collections + case ":": { + const inFlow = this.flowLevel > 0; + const ch1 = this.charAt(1); + if (isEmpty(ch1) || inFlow && flowIndicatorChars.has(ch1)) { + if (!inFlow) + this.indentNext = this.indentValue + 1; + else if (this.flowKey) + this.flowKey = false; + return (yield* this.pushCount(1)) + (yield* this.pushSpaces(true)) + (yield* this.pushIndicators()); + } } } - parseEscape() { - if (this.char in escapes) { - return this.return(escapes[this.char]); - } else if (this.char === CHAR_u) { - return this.call(this.parseSmallUnicode, this.parseUnicodeReturn); - } else if (this.char === CHAR_U) { - return this.call(this.parseLargeUnicode, this.parseUnicodeReturn); - } else { - throw this.error(new TomlError("Unknown escape character: " + this.char)); + return 0; + } + *pushTag() { + if (this.charAt(1) === "<") { + let i2 = this.pos + 2; + let ch = this.buffer[i2]; + while (!isEmpty(ch) && ch !== ">") + ch = this.buffer[++i2]; + return yield* this.pushToIndex(ch === ">" ? i2 + 1 : i2, false); + } else { + let i2 = this.pos + 1; + let ch = this.buffer[i2]; + while (ch) { + if (tagChars.has(ch)) + ch = this.buffer[++i2]; + else if (ch === "%" && hexDigits.has(this.buffer[i2 + 1]) && hexDigits.has(this.buffer[i2 + 2])) { + ch = this.buffer[i2 += 3]; + } else + break; } + return yield* this.pushToIndex(i2, false); } - parseUnicodeReturn(char) { - try { - const codePoint = parseInt(char, 16); - if (codePoint >= SURROGATE_FIRST && codePoint <= SURROGATE_LAST) { - throw this.error(new TomlError("Invalid unicode, character in range 0xD800 - 0xDFFF is reserved")); - } - return this.returnNow(String.fromCodePoint(codePoint)); - } catch (err) { - throw this.error(TomlError.wrap(err)); - } + } + *pushNewline() { + const ch = this.buffer[this.pos]; + if (ch === "\n") + return yield* this.pushCount(1); + else if (ch === "\r" && this.charAt(1) === "\n") + return yield* this.pushCount(2); + else + return 0; + } + *pushSpaces(allowTabs) { + let i2 = this.pos - 1; + let ch; + do { + ch = this.buffer[++i2]; + } while (ch === " " || allowTabs && ch === " "); + const n2 = i2 - this.pos; + if (n2 > 0) { + yield this.buffer.substr(this.pos, n2); + this.pos = i2; + } + return n2; + } + *pushUntil(test) { + let i2 = this.pos; + let ch = this.buffer[i2]; + while (!test(ch)) + ch = this.buffer[++i2]; + return yield* this.pushToIndex(i2, false); + } + }; + exports2.Lexer = Lexer; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/parse/line-counter.js +var require_line_counter = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/parse/line-counter.js"(exports2) { + init_esm_shims(); + var LineCounter = class { + constructor() { + this.lineStarts = []; + this.addNewLine = (offset) => this.lineStarts.push(offset); + this.linePos = (offset) => { + let low = 0; + let high = this.lineStarts.length; + while (low < high) { + const mid = low + high >> 1; + if (this.lineStarts[mid] < offset) + low = mid + 1; + else + high = mid; + } + if (this.lineStarts[low] === offset) + return { line: low + 1, col: 1 }; + if (low === 0) + return { line: 0, col: offset }; + const start = this.lineStarts[low - 1]; + return { line: low, col: offset - start + 1 }; + }; + } + }; + exports2.LineCounter = LineCounter; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/parse/parser.js +var require_parser = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/parse/parser.js"(exports2) { + init_esm_shims(); + var node_process = __require("process"); + var cst = require_cst(); + var lexer = require_lexer(); + function includesToken(list, type) { + for (let i2 = 0; i2 < list.length; ++i2) + if (list[i2].type === type) + return true; + return false; + } + function findNonEmptyIndex(list) { + for (let i2 = 0; i2 < list.length; ++i2) { + switch (list[i2].type) { + case "space": + case "comment": + case "newline": + break; + default: + return i2; } - parseSmallUnicode() { - if (!isHexit(this.char)) { - throw this.error(new TomlError("Invalid character in unicode sequence, expected hex")); - } else { - this.consume(); - if (this.state.buf.length >= 4) return this.return(); - } + } + return -1; + } + function isFlowToken(token) { + switch (token?.type) { + case "alias": + case "scalar": + case "single-quoted-scalar": + case "double-quoted-scalar": + case "flow-collection": + return true; + default: + return false; + } + } + function getPrevProps(parent) { + switch (parent.type) { + case "document": + return parent.start; + case "block-map": { + const it = parent.items[parent.items.length - 1]; + return it.sep ?? it.start; } - parseLargeUnicode() { - if (!isHexit(this.char)) { - throw this.error(new TomlError("Invalid character in unicode sequence, expected hex")); - } else { - this.consume(); - if (this.state.buf.length >= 8) return this.return(); + case "block-seq": + return parent.items[parent.items.length - 1].start; + /* istanbul ignore next should not happen */ + default: + return []; + } + } + function getFirstKeyStartProps(prev) { + if (prev.length === 0) + return []; + let i2 = prev.length; + loop: while (--i2 >= 0) { + switch (prev[i2].type) { + case "doc-start": + case "explicit-key-ind": + case "map-value-ind": + case "seq-item-ind": + case "newline": + break loop; + } + } + while (prev[++i2]?.type === "space") { + } + return prev.splice(i2, prev.length); + } + function fixFlowSeqItems(fc) { + if (fc.start.type === "flow-seq-start") { + for (const it of fc.items) { + if (it.sep && !it.value && !includesToken(it.start, "explicit-key-ind") && !includesToken(it.sep, "map-value-ind")) { + if (it.key) + it.value = it.key; + delete it.key; + if (isFlowToken(it.value)) { + if (it.value.end) + Array.prototype.push.apply(it.value.end, it.sep); + else + it.value.end = it.sep; + } else + Array.prototype.push.apply(it.start, it.sep); + delete it.sep; + } + } + } + } + var Parser = class { + /** + * @param onNewLine - If defined, called separately with the start position of + * each new line (in `parse()`, including the start of input). + */ + constructor(onNewLine) { + this.atNewLine = true; + this.atScalar = false; + this.indent = 0; + this.offset = 0; + this.onKeyLine = false; + this.stack = []; + this.source = ""; + this.type = ""; + this.lexer = new lexer.Lexer(); + this.onNewLine = onNewLine; + } + /** + * Parse `source` as a YAML stream. + * If `incomplete`, a part of the last line may be left as a buffer for the next call. + * + * Errors are not thrown, but yielded as `{ type: 'error', message }` tokens. + * + * @returns A generator of tokens representing each directive, document, and other structure. + */ + *parse(source, incomplete = false) { + if (this.onNewLine && this.offset === 0) + this.onNewLine(0); + for (const lexeme of this.lexer.lex(source, incomplete)) + yield* this.next(lexeme); + if (!incomplete) + yield* this.end(); + } + /** + * Advance the parser by the `source` of one lexical token. + */ + *next(source) { + this.source = source; + if (node_process.env.LOG_TOKENS) + console.log("|", cst.prettyToken(source)); + if (this.atScalar) { + this.atScalar = false; + yield* this.step(); + this.offset += source.length; + return; + } + const type = cst.tokenType(source); + if (!type) { + const message = `Not a YAML token: ${source}`; + yield* this.pop({ type: "error", offset: this.offset, message, source }); + this.offset += source.length; + } else if (type === "scalar") { + this.atNewLine = false; + this.atScalar = true; + this.type = "scalar"; + } else { + this.type = type; + yield* this.step(); + switch (type) { + case "newline": + this.atNewLine = true; + this.indent = 0; + if (this.onNewLine) + this.onNewLine(this.offset + source.length); + break; + case "space": + if (this.atNewLine && source[0] === " ") + this.indent += source.length; + break; + case "explicit-key-ind": + case "map-value-ind": + case "seq-item-ind": + if (this.atNewLine) + this.indent += source.length; + break; + case "doc-mode": + case "flow-error-end": + return; + default: + this.atNewLine = false; } + this.offset += source.length; } - /* NUMBERS */ - parseNumberSign() { - this.consume(); - return this.next(this.parseMaybeSignedInfOrNan); + } + /** Call at end of input to push out any remaining constructions */ + *end() { + while (this.stack.length > 0) + yield* this.pop(); + } + get sourceToken() { + const st = { + type: this.type, + offset: this.offset, + indent: this.indent, + source: this.source + }; + return st; + } + *step() { + const top = this.peek(1); + if (this.type === "doc-end" && top?.type !== "doc-end") { + while (this.stack.length > 0) + yield* this.pop(); + this.stack.push({ + type: "doc-end", + offset: this.offset, + source: this.source + }); + return; } - parseMaybeSignedInfOrNan() { - if (this.char === CHAR_i) { - return this.next(this.parseInf); - } else if (this.char === CHAR_n) { - return this.next(this.parseNan); - } else { - return this.callNow(this.parseNoUnder, this.parseNumberIntegerStart); + if (!top) + return yield* this.stream(); + switch (top.type) { + case "document": + return yield* this.document(top); + case "alias": + case "scalar": + case "single-quoted-scalar": + case "double-quoted-scalar": + return yield* this.scalar(top); + case "block-scalar": + return yield* this.blockScalar(top); + case "block-map": + return yield* this.blockMap(top); + case "block-seq": + return yield* this.blockSequence(top); + case "flow-collection": + return yield* this.flowCollection(top); + case "doc-end": + return yield* this.documentEnd(top); + } + yield* this.pop(); + } + peek(n2) { + return this.stack[this.stack.length - n2]; + } + *pop(error) { + const token = error ?? this.stack.pop(); + if (!token) { + const message = "Tried to pop an empty stack"; + yield { type: "error", offset: this.offset, source: "", message }; + } else if (this.stack.length === 0) { + yield token; + } else { + const top = this.peek(1); + if (token.type === "block-scalar") { + token.indent = "indent" in top ? top.indent : 0; + } else if (token.type === "flow-collection" && top.type === "document") { + token.indent = 0; + } + if (token.type === "flow-collection") + fixFlowSeqItems(token); + switch (top.type) { + case "document": + top.value = token; + break; + case "block-scalar": + top.props.push(token); + break; + case "block-map": { + const it = top.items[top.items.length - 1]; + if (it.value) { + top.items.push({ start: [], key: token, sep: [] }); + this.onKeyLine = true; + return; + } else if (it.sep) { + it.value = token; + } else { + Object.assign(it, { key: token, sep: [] }); + this.onKeyLine = !it.explicitKey; + return; + } + break; + } + case "block-seq": { + const it = top.items[top.items.length - 1]; + if (it.value) + top.items.push({ start: [], value: token }); + else + it.value = token; + break; + } + case "flow-collection": { + const it = top.items[top.items.length - 1]; + if (!it || it.value) + top.items.push({ start: [], key: token, sep: [] }); + else if (it.sep) + it.value = token; + else + Object.assign(it, { key: token, sep: [] }); + return; + } + /* istanbul ignore next should not happen */ + default: + yield* this.pop(); + yield* this.pop(token); + } + if ((top.type === "document" || top.type === "block-map" || top.type === "block-seq") && (token.type === "block-map" || token.type === "block-seq")) { + const last = token.items[token.items.length - 1]; + if (last && !last.sep && !last.value && last.start.length > 0 && findNonEmptyIndex(last.start) === -1 && (token.indent === 0 || last.start.every((st) => st.type !== "comment" || st.indent < token.indent))) { + if (top.type === "document") + top.end = last.start; + else + top.items.push({ start: last.start }); + token.items.splice(-1, 1); + } } } - parseNumberIntegerStart() { - if (this.char === CHAR_0) { - this.consume(); - return this.next(this.parseNumberIntegerExponentOrDecimal); - } else { - return this.goto(this.parseNumberInteger); + } + *stream() { + switch (this.type) { + case "directive-line": + yield { type: "directive", offset: this.offset, source: this.source }; + return; + case "byte-order-mark": + case "space": + case "comment": + case "newline": + yield this.sourceToken; + return; + case "doc-mode": + case "doc-start": { + const doc = { + type: "document", + offset: this.offset, + start: [] + }; + if (this.type === "doc-start") + doc.start.push(this.sourceToken); + this.stack.push(doc); + return; } } - parseNumberIntegerExponentOrDecimal() { - if (this.char === CHAR_PERIOD) { - this.consume(); - return this.call(this.parseNoUnder, this.parseNumberFloat); - } else if (this.char === CHAR_E || this.char === CHAR_e) { - this.consume(); - return this.next(this.parseNumberExponentSign); - } else { - return this.returnNow(Integer(this.state.buf)); + yield { + type: "error", + offset: this.offset, + message: `Unexpected ${this.type} token in YAML stream`, + source: this.source + }; + } + *document(doc) { + if (doc.value) + return yield* this.lineEnd(doc); + switch (this.type) { + case "doc-start": { + if (findNonEmptyIndex(doc.start) !== -1) { + yield* this.pop(); + yield* this.step(); + } else + doc.start.push(this.sourceToken); + return; } + case "anchor": + case "tag": + case "space": + case "comment": + case "newline": + doc.start.push(this.sourceToken); + return; } - parseNumberInteger() { - if (isDigit(this.char)) { - this.consume(); - } else if (this.char === CHAR_LOWBAR) { - return this.call(this.parseNoUnder); - } else if (this.char === CHAR_E || this.char === CHAR_e) { - this.consume(); - return this.next(this.parseNumberExponentSign); - } else if (this.char === CHAR_PERIOD) { - this.consume(); - return this.call(this.parseNoUnder, this.parseNumberFloat); - } else { - const result = Integer(this.state.buf); - if (result.isNaN()) { - throw this.error(new TomlError("Invalid number")); + const bv = this.startBlockValue(doc); + if (bv) + this.stack.push(bv); + else { + yield { + type: "error", + offset: this.offset, + message: `Unexpected ${this.type} token in YAML document`, + source: this.source + }; + } + } + *scalar(scalar) { + if (this.type === "map-value-ind") { + const prev = getPrevProps(this.peek(2)); + const start = getFirstKeyStartProps(prev); + let sep; + if (scalar.end) { + sep = scalar.end; + sep.push(this.sourceToken); + delete scalar.end; + } else + sep = [this.sourceToken]; + const map = { + type: "block-map", + offset: scalar.offset, + indent: scalar.indent, + items: [{ start, key: scalar, sep }] + }; + this.onKeyLine = true; + this.stack[this.stack.length - 1] = map; + } else + yield* this.lineEnd(scalar); + } + *blockScalar(scalar) { + switch (this.type) { + case "space": + case "comment": + case "newline": + scalar.props.push(this.sourceToken); + return; + case "scalar": + scalar.source = this.source; + this.atNewLine = true; + this.indent = 0; + if (this.onNewLine) { + let nl = this.source.indexOf("\n") + 1; + while (nl !== 0) { + this.onNewLine(this.offset + nl); + nl = this.source.indexOf("\n", nl) + 1; + } + } + yield* this.pop(); + break; + /* istanbul ignore next should not happen */ + default: + yield* this.pop(); + yield* this.step(); + } + } + *blockMap(map) { + const it = map.items[map.items.length - 1]; + switch (this.type) { + case "newline": + this.onKeyLine = false; + if (it.value) { + const end = "end" in it.value ? it.value.end : void 0; + const last = Array.isArray(end) ? end[end.length - 1] : void 0; + if (last?.type === "comment") + end?.push(this.sourceToken); + else + map.items.push({ start: [this.sourceToken] }); + } else if (it.sep) { + it.sep.push(this.sourceToken); } else { - return this.returnNow(result); + it.start.push(this.sourceToken); } - } + return; + case "space": + case "comment": + if (it.value) { + map.items.push({ start: [this.sourceToken] }); + } else if (it.sep) { + it.sep.push(this.sourceToken); + } else { + if (this.atIndentedComment(it.start, map.indent)) { + const prev = map.items[map.items.length - 2]; + const end = prev?.value?.end; + if (Array.isArray(end)) { + Array.prototype.push.apply(end, it.start); + end.push(this.sourceToken); + map.items.pop(); + return; + } + } + it.start.push(this.sourceToken); + } + return; } - parseNoUnder() { - if (this.char === CHAR_LOWBAR || this.char === CHAR_PERIOD || this.char === CHAR_E || this.char === CHAR_e) { - throw this.error(new TomlError("Unexpected character, expected digit")); - } else if (this.atEndOfWord()) { - throw this.error(new TomlError("Incomplete number")); + if (this.indent >= map.indent) { + const atMapIndent = !this.onKeyLine && this.indent === map.indent; + const atNextItem = atMapIndent && (it.sep || it.explicitKey) && this.type !== "seq-item-ind"; + let start = []; + if (atNextItem && it.sep && !it.value) { + const nl = []; + for (let i2 = 0; i2 < it.sep.length; ++i2) { + const st = it.sep[i2]; + switch (st.type) { + case "newline": + nl.push(i2); + break; + case "space": + break; + case "comment": + if (st.indent > map.indent) + nl.length = 0; + break; + default: + nl.length = 0; + } + } + if (nl.length >= 2) + start = it.sep.splice(nl[1]); + } + switch (this.type) { + case "anchor": + case "tag": + if (atNextItem || it.value) { + start.push(this.sourceToken); + map.items.push({ start }); + this.onKeyLine = true; + } else if (it.sep) { + it.sep.push(this.sourceToken); + } else { + it.start.push(this.sourceToken); + } + return; + case "explicit-key-ind": + if (!it.sep && !it.explicitKey) { + it.start.push(this.sourceToken); + it.explicitKey = true; + } else if (atNextItem || it.value) { + start.push(this.sourceToken); + map.items.push({ start, explicitKey: true }); + } else { + this.stack.push({ + type: "block-map", + offset: this.offset, + indent: this.indent, + items: [{ start: [this.sourceToken], explicitKey: true }] + }); + } + this.onKeyLine = true; + return; + case "map-value-ind": + if (it.explicitKey) { + if (!it.sep) { + if (includesToken(it.start, "newline")) { + Object.assign(it, { key: null, sep: [this.sourceToken] }); + } else { + const start2 = getFirstKeyStartProps(it.start); + this.stack.push({ + type: "block-map", + offset: this.offset, + indent: this.indent, + items: [{ start: start2, key: null, sep: [this.sourceToken] }] + }); + } + } else if (it.value) { + map.items.push({ start: [], key: null, sep: [this.sourceToken] }); + } else if (includesToken(it.sep, "map-value-ind")) { + this.stack.push({ + type: "block-map", + offset: this.offset, + indent: this.indent, + items: [{ start, key: null, sep: [this.sourceToken] }] + }); + } else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) { + const start2 = getFirstKeyStartProps(it.start); + const key = it.key; + const sep = it.sep; + sep.push(this.sourceToken); + delete it.key; + delete it.sep; + this.stack.push({ + type: "block-map", + offset: this.offset, + indent: this.indent, + items: [{ start: start2, key, sep }] + }); + } else if (start.length > 0) { + it.sep = it.sep.concat(start, this.sourceToken); + } else { + it.sep.push(this.sourceToken); + } + } else { + if (!it.sep) { + Object.assign(it, { key: null, sep: [this.sourceToken] }); + } else if (it.value || atNextItem) { + map.items.push({ start, key: null, sep: [this.sourceToken] }); + } else if (includesToken(it.sep, "map-value-ind")) { + this.stack.push({ + type: "block-map", + offset: this.offset, + indent: this.indent, + items: [{ start: [], key: null, sep: [this.sourceToken] }] + }); + } else { + it.sep.push(this.sourceToken); + } + } + this.onKeyLine = true; + return; + case "alias": + case "scalar": + case "single-quoted-scalar": + case "double-quoted-scalar": { + const fs10 = this.flowScalar(this.type); + if (atNextItem || it.value) { + map.items.push({ start, key: fs10, sep: [] }); + this.onKeyLine = true; + } else if (it.sep) { + this.stack.push(fs10); + } else { + Object.assign(it, { key: fs10, sep: [] }); + this.onKeyLine = true; + } + return; + } + default: { + const bv = this.startBlockValue(map); + if (bv) { + if (bv.type === "block-seq") { + if (!it.explicitKey && it.sep && !includesToken(it.sep, "newline")) { + yield* this.pop({ + type: "error", + offset: this.offset, + message: "Unexpected block-seq-ind on same line with key", + source: this.source + }); + return; + } + } else if (atMapIndent) { + map.items.push({ start }); + } + this.stack.push(bv); + return; + } + } } - return this.returnNow(); } - parseNoUnderHexOctBinLiteral() { - if (this.char === CHAR_LOWBAR || this.char === CHAR_PERIOD) { - throw this.error(new TomlError("Unexpected character, expected digit")); - } else if (this.atEndOfWord()) { - throw this.error(new TomlError("Incomplete number")); - } - return this.returnNow(); + yield* this.pop(); + yield* this.step(); + } + *blockSequence(seq) { + const it = seq.items[seq.items.length - 1]; + switch (this.type) { + case "newline": + if (it.value) { + const end = "end" in it.value ? it.value.end : void 0; + const last = Array.isArray(end) ? end[end.length - 1] : void 0; + if (last?.type === "comment") + end?.push(this.sourceToken); + else + seq.items.push({ start: [this.sourceToken] }); + } else + it.start.push(this.sourceToken); + return; + case "space": + case "comment": + if (it.value) + seq.items.push({ start: [this.sourceToken] }); + else { + if (this.atIndentedComment(it.start, seq.indent)) { + const prev = seq.items[seq.items.length - 2]; + const end = prev?.value?.end; + if (Array.isArray(end)) { + Array.prototype.push.apply(end, it.start); + end.push(this.sourceToken); + seq.items.pop(); + return; + } + } + it.start.push(this.sourceToken); + } + return; + case "anchor": + case "tag": + if (it.value || this.indent <= seq.indent) + break; + it.start.push(this.sourceToken); + return; + case "seq-item-ind": + if (this.indent !== seq.indent) + break; + if (it.value || includesToken(it.start, "seq-item-ind")) + seq.items.push({ start: [this.sourceToken] }); + else + it.start.push(this.sourceToken); + return; } - parseNumberFloat() { - if (this.char === CHAR_LOWBAR) { - return this.call(this.parseNoUnder, this.parseNumberFloat); - } else if (isDigit(this.char)) { - this.consume(); - } else if (this.char === CHAR_E || this.char === CHAR_e) { - this.consume(); - return this.next(this.parseNumberExponentSign); - } else { - return this.returnNow(Float(this.state.buf)); + if (this.indent > seq.indent) { + const bv = this.startBlockValue(seq); + if (bv) { + this.stack.push(bv); + return; } } - parseNumberExponentSign() { - if (isDigit(this.char)) { - return this.goto(this.parseNumberExponent); - } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) { - this.consume(); - this.call(this.parseNoUnder, this.parseNumberExponent); - } else { - throw this.error(new TomlError("Unexpected character, expected -, + or digit")); + yield* this.pop(); + yield* this.step(); + } + *flowCollection(fc) { + const it = fc.items[fc.items.length - 1]; + if (this.type === "flow-error-end") { + let top; + do { + yield* this.pop(); + top = this.peek(1); + } while (top?.type === "flow-collection"); + } else if (fc.end.length === 0) { + switch (this.type) { + case "comma": + case "explicit-key-ind": + if (!it || it.sep) + fc.items.push({ start: [this.sourceToken] }); + else + it.start.push(this.sourceToken); + return; + case "map-value-ind": + if (!it || it.value) + fc.items.push({ start: [], key: null, sep: [this.sourceToken] }); + else if (it.sep) + it.sep.push(this.sourceToken); + else + Object.assign(it, { key: null, sep: [this.sourceToken] }); + return; + case "space": + case "comment": + case "newline": + case "anchor": + case "tag": + if (!it || it.value) + fc.items.push({ start: [this.sourceToken] }); + else if (it.sep) + it.sep.push(this.sourceToken); + else + it.start.push(this.sourceToken); + return; + case "alias": + case "scalar": + case "single-quoted-scalar": + case "double-quoted-scalar": { + const fs10 = this.flowScalar(this.type); + if (!it || it.value) + fc.items.push({ start: [], key: fs10, sep: [] }); + else if (it.sep) + this.stack.push(fs10); + else + Object.assign(it, { key: fs10, sep: [] }); + return; + } + case "flow-map-end": + case "flow-seq-end": + fc.end.push(this.sourceToken); + return; } - } - parseNumberExponent() { - if (isDigit(this.char)) { - this.consume(); - } else if (this.char === CHAR_LOWBAR) { - return this.call(this.parseNoUnder); - } else { - return this.returnNow(Float(this.state.buf)); + const bv = this.startBlockValue(fc); + if (bv) + this.stack.push(bv); + else { + yield* this.pop(); + yield* this.step(); } - } - /* NUMBERS or DATETIMES */ - parseNumberOrDateTime() { - if (this.char === CHAR_0) { - this.consume(); - return this.next(this.parseNumberBaseOrDateTime); + } else { + const parent = this.peek(2); + if (parent.type === "block-map" && (this.type === "map-value-ind" && parent.indent === fc.indent || this.type === "newline" && !parent.items[parent.items.length - 1].sep)) { + yield* this.pop(); + yield* this.step(); + } else if (this.type === "map-value-ind" && parent.type !== "flow-collection") { + const prev = getPrevProps(parent); + const start = getFirstKeyStartProps(prev); + fixFlowSeqItems(fc); + const sep = fc.end.splice(1, fc.end.length); + sep.push(this.sourceToken); + const map = { + type: "block-map", + offset: fc.offset, + indent: fc.indent, + items: [{ start, key: fc, sep }] + }; + this.onKeyLine = true; + this.stack[this.stack.length - 1] = map; } else { - return this.goto(this.parseNumberOrDateTimeOnly); + yield* this.lineEnd(fc); } } - parseNumberOrDateTimeOnly() { - if (this.char === CHAR_LOWBAR) { - return this.call(this.parseNoUnder, this.parseNumberInteger); - } else if (isDigit(this.char)) { - this.consume(); - if (this.state.buf.length > 4) this.next(this.parseNumberInteger); - } else if (this.char === CHAR_E || this.char === CHAR_e) { - this.consume(); - return this.next(this.parseNumberExponentSign); - } else if (this.char === CHAR_PERIOD) { - this.consume(); - return this.call(this.parseNoUnder, this.parseNumberFloat); - } else if (this.char === CHAR_HYPHEN) { - return this.goto(this.parseDateTime); - } else if (this.char === CHAR_COLON) { - return this.goto(this.parseOnlyTimeHour); - } else { - return this.returnNow(Integer(this.state.buf)); + } + flowScalar(type) { + if (this.onNewLine) { + let nl = this.source.indexOf("\n") + 1; + while (nl !== 0) { + this.onNewLine(this.offset + nl); + nl = this.source.indexOf("\n", nl) + 1; } } - parseDateTimeOnly() { - if (this.state.buf.length < 4) { - if (isDigit(this.char)) { - return this.consume(); - } else if (this.char === CHAR_COLON) { - return this.goto(this.parseOnlyTimeHour); - } else { - throw this.error(new TomlError("Expected digit while parsing year part of a date")); - } - } else { - if (this.char === CHAR_HYPHEN) { - return this.goto(this.parseDateTime); - } else { - throw this.error(new TomlError("Expected hyphen (-) while parsing year part of date")); - } - } - } - parseNumberBaseOrDateTime() { - if (this.char === CHAR_b) { - this.consume(); - return this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerBin); - } else if (this.char === CHAR_o) { - this.consume(); - return this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerOct); - } else if (this.char === CHAR_x) { - this.consume(); - return this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerHex); - } else if (this.char === CHAR_PERIOD) { - return this.goto(this.parseNumberInteger); - } else if (isDigit(this.char)) { - return this.goto(this.parseDateTimeOnly); - } else { - return this.returnNow(Integer(this.state.buf)); - } - } - parseIntegerHex() { - if (isHexit(this.char)) { - this.consume(); - } else if (this.char === CHAR_LOWBAR) { - return this.call(this.parseNoUnderHexOctBinLiteral); - } else { - const result = Integer(this.state.buf); - if (result.isNaN()) { - throw this.error(new TomlError("Invalid number")); - } else { - return this.returnNow(result); - } - } - } - parseIntegerOct() { - if (isOctit(this.char)) { - this.consume(); - } else if (this.char === CHAR_LOWBAR) { - return this.call(this.parseNoUnderHexOctBinLiteral); - } else { - const result = Integer(this.state.buf); - if (result.isNaN()) { - throw this.error(new TomlError("Invalid number")); - } else { - return this.returnNow(result); - } - } - } - parseIntegerBin() { - if (isBit(this.char)) { - this.consume(); - } else if (this.char === CHAR_LOWBAR) { - return this.call(this.parseNoUnderHexOctBinLiteral); - } else { - const result = Integer(this.state.buf); - if (result.isNaN()) { - throw this.error(new TomlError("Invalid number")); - } else { - return this.returnNow(result); - } - } - } - /* DATETIME */ - parseDateTime() { - if (this.state.buf.length < 4) { - throw this.error(new TomlError("Years less than 1000 must be zero padded to four characters")); - } - this.state.result = this.state.buf; - this.state.buf = ""; - return this.next(this.parseDateMonth); - } - parseDateMonth() { - if (this.char === CHAR_HYPHEN) { - if (this.state.buf.length < 2) { - throw this.error(new TomlError("Months less than 10 must be zero padded to two characters")); - } - this.state.result += "-" + this.state.buf; - this.state.buf = ""; - return this.next(this.parseDateDay); - } else if (isDigit(this.char)) { - this.consume(); - } else { - throw this.error(new TomlError("Incomplete datetime")); - } - } - parseDateDay() { - if (this.char === CHAR_T || this.char === CHAR_SP) { - if (this.state.buf.length < 2) { - throw this.error(new TomlError("Days less than 10 must be zero padded to two characters")); - } - this.state.result += "-" + this.state.buf; - this.state.buf = ""; - return this.next(this.parseStartTimeHour); - } else if (this.atEndOfWord()) { - return this.returnNow(createDate(this.state.result + "-" + this.state.buf)); - } else if (isDigit(this.char)) { - this.consume(); - } else { - throw this.error(new TomlError("Incomplete datetime")); - } - } - parseStartTimeHour() { - if (this.atEndOfWord()) { - return this.returnNow(createDate(this.state.result)); - } else { - return this.goto(this.parseTimeHour); - } - } - parseTimeHour() { - if (this.char === CHAR_COLON) { - if (this.state.buf.length < 2) { - throw this.error(new TomlError("Hours less than 10 must be zero padded to two characters")); - } - this.state.result += "T" + this.state.buf; - this.state.buf = ""; - return this.next(this.parseTimeMin); - } else if (isDigit(this.char)) { - this.consume(); - } else { - throw this.error(new TomlError("Incomplete datetime")); - } - } - parseTimeMin() { - if (this.state.buf.length < 2 && isDigit(this.char)) { - this.consume(); - } else if (this.state.buf.length === 2 && this.char === CHAR_COLON) { - this.state.result += ":" + this.state.buf; - this.state.buf = ""; - return this.next(this.parseTimeSec); - } else { - throw this.error(new TomlError("Incomplete datetime")); - } + return { + type, + offset: this.offset, + indent: this.indent, + source: this.source + }; + } + startBlockValue(parent) { + switch (this.type) { + case "alias": + case "scalar": + case "single-quoted-scalar": + case "double-quoted-scalar": + return this.flowScalar(this.type); + case "block-scalar-header": + return { + type: "block-scalar", + offset: this.offset, + indent: this.indent, + props: [this.sourceToken], + source: "" + }; + case "flow-map-start": + case "flow-seq-start": + return { + type: "flow-collection", + offset: this.offset, + indent: this.indent, + start: this.sourceToken, + items: [], + end: [] + }; + case "seq-item-ind": + return { + type: "block-seq", + offset: this.offset, + indent: this.indent, + items: [{ start: [this.sourceToken] }] + }; + case "explicit-key-ind": { + this.onKeyLine = true; + const prev = getPrevProps(parent); + const start = getFirstKeyStartProps(prev); + start.push(this.sourceToken); + return { + type: "block-map", + offset: this.offset, + indent: this.indent, + items: [{ start, explicitKey: true }] + }; + } + case "map-value-ind": { + this.onKeyLine = true; + const prev = getPrevProps(parent); + const start = getFirstKeyStartProps(prev); + return { + type: "block-map", + offset: this.offset, + indent: this.indent, + items: [{ start, key: null, sep: [this.sourceToken] }] + }; + } + } + return null; + } + atIndentedComment(start, indent) { + if (this.type !== "comment") + return false; + if (this.indent <= indent) + return false; + return start.every((st) => st.type === "newline" || st.type === "space"); + } + *documentEnd(docEnd) { + if (this.type !== "doc-mode") { + if (docEnd.end) + docEnd.end.push(this.sourceToken); + else + docEnd.end = [this.sourceToken]; + if (this.type === "newline") + yield* this.pop(); + } + } + *lineEnd(token) { + switch (this.type) { + case "comma": + case "doc-start": + case "doc-end": + case "flow-seq-end": + case "flow-map-end": + case "map-value-ind": + yield* this.pop(); + yield* this.step(); + break; + case "newline": + this.onKeyLine = false; + // fallthrough + case "space": + case "comment": + default: + if (token.end) + token.end.push(this.sourceToken); + else + token.end = [this.sourceToken]; + if (this.type === "newline") + yield* this.pop(); } - parseTimeSec() { - if (isDigit(this.char)) { - this.consume(); - if (this.state.buf.length === 2) { - this.state.result += ":" + this.state.buf; - this.state.buf = ""; - return this.next(this.parseTimeZoneOrFraction); - } - } else { - throw this.error(new TomlError("Incomplete datetime")); - } + } + }; + exports2.Parser = Parser; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/public-api.js +var require_public_api = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/public-api.js"(exports2) { + init_esm_shims(); + var composer = require_composer(); + var Document = require_Document(); + var errors = require_errors(); + var log = require_log(); + var identity = require_identity(); + var lineCounter = require_line_counter(); + var parser = require_parser(); + function parseOptions(options) { + const prettyErrors = options.prettyErrors !== false; + const lineCounter$1 = options.lineCounter || prettyErrors && new lineCounter.LineCounter() || null; + return { lineCounter: lineCounter$1, prettyErrors }; + } + function parseAllDocuments(source, options = {}) { + const { lineCounter: lineCounter2, prettyErrors } = parseOptions(options); + const parser$1 = new parser.Parser(lineCounter2?.addNewLine); + const composer$1 = new composer.Composer(options); + const docs = Array.from(composer$1.compose(parser$1.parse(source))); + if (prettyErrors && lineCounter2) + for (const doc of docs) { + doc.errors.forEach(errors.prettifyError(source, lineCounter2)); + doc.warnings.forEach(errors.prettifyError(source, lineCounter2)); + } + if (docs.length > 0) + return docs; + return Object.assign([], { empty: true }, composer$1.streamInfo()); + } + function parseDocument(source, options = {}) { + const { lineCounter: lineCounter2, prettyErrors } = parseOptions(options); + const parser$1 = new parser.Parser(lineCounter2?.addNewLine); + const composer$1 = new composer.Composer(options); + let doc = null; + for (const _doc of composer$1.compose(parser$1.parse(source), true, source.length)) { + if (!doc) + doc = _doc; + else if (doc.options.logLevel !== "silent") { + doc.errors.push(new errors.YAMLParseError(_doc.range.slice(0, 2), "MULTIPLE_DOCS", "Source contains multiple documents; please use YAML.parseAllDocuments()")); + break; } - parseOnlyTimeHour() { - if (this.char === CHAR_COLON) { - if (this.state.buf.length < 2) { - throw this.error(new TomlError("Hours less than 10 must be zero padded to two characters")); - } - this.state.result = this.state.buf; - this.state.buf = ""; - return this.next(this.parseOnlyTimeMin); - } else { - throw this.error(new TomlError("Incomplete time")); - } + } + if (prettyErrors && lineCounter2) { + doc.errors.forEach(errors.prettifyError(source, lineCounter2)); + doc.warnings.forEach(errors.prettifyError(source, lineCounter2)); + } + return doc; + } + function parse3(src, reviver, options) { + let _reviver = void 0; + if (typeof reviver === "function") { + _reviver = reviver; + } else if (options === void 0 && reviver && typeof reviver === "object") { + options = reviver; + } + const doc = parseDocument(src, options); + if (!doc) + return null; + doc.warnings.forEach((warning) => log.warn(doc.options.logLevel, warning)); + if (doc.errors.length > 0) { + if (doc.options.logLevel !== "silent") + throw doc.errors[0]; + else + doc.errors = []; + } + return doc.toJS(Object.assign({ reviver: _reviver }, options)); + } + function stringify(value, replacer, options) { + let _replacer = null; + if (typeof replacer === "function" || Array.isArray(replacer)) { + _replacer = replacer; + } else if (options === void 0 && replacer) { + options = replacer; + } + if (typeof options === "string") + options = options.length; + if (typeof options === "number") { + const indent = Math.round(options); + options = indent < 1 ? void 0 : indent > 8 ? { indent: 8 } : { indent }; + } + if (value === void 0) { + const { keepUndefined } = options ?? replacer ?? {}; + if (!keepUndefined) + return void 0; + } + if (identity.isDocument(value) && !_replacer) + return value.toString(options); + return new Document.Document(value, _replacer, options).toString(options); + } + exports2.parse = parse3; + exports2.parseAllDocuments = parseAllDocuments; + exports2.parseDocument = parseDocument; + exports2.stringify = stringify; + } +}); + +// node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/index.js +var require_dist = __commonJS({ + "node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/index.js"(exports2) { + init_esm_shims(); + var composer = require_composer(); + var Document = require_Document(); + var Schema = require_Schema(); + var errors = require_errors(); + var Alias = require_Alias(); + var identity = require_identity(); + var Pair = require_Pair(); + var Scalar = require_Scalar(); + var YAMLMap = require_YAMLMap(); + var YAMLSeq = require_YAMLSeq(); + var cst = require_cst(); + var lexer = require_lexer(); + var lineCounter = require_line_counter(); + var parser = require_parser(); + var publicApi = require_public_api(); + var visit = require_visit(); + exports2.Composer = composer.Composer; + exports2.Document = Document.Document; + exports2.Schema = Schema.Schema; + exports2.YAMLError = errors.YAMLError; + exports2.YAMLParseError = errors.YAMLParseError; + exports2.YAMLWarning = errors.YAMLWarning; + exports2.Alias = Alias.Alias; + exports2.isAlias = identity.isAlias; + exports2.isCollection = identity.isCollection; + exports2.isDocument = identity.isDocument; + exports2.isMap = identity.isMap; + exports2.isNode = identity.isNode; + exports2.isPair = identity.isPair; + exports2.isScalar = identity.isScalar; + exports2.isSeq = identity.isSeq; + exports2.Pair = Pair.Pair; + exports2.Scalar = Scalar.Scalar; + exports2.YAMLMap = YAMLMap.YAMLMap; + exports2.YAMLSeq = YAMLSeq.YAMLSeq; + exports2.CST = cst; + exports2.Lexer = lexer.Lexer; + exports2.LineCounter = lineCounter.LineCounter; + exports2.Parser = parser.Parser; + exports2.parse = publicApi.parse; + exports2.parseAllDocuments = publicApi.parseAllDocuments; + exports2.parseDocument = publicApi.parseDocument; + exports2.stringify = publicApi.stringify; + exports2.visit = visit.visit; + exports2.visitAsync = visit.visitAsync; + } +}); + +// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/parser.js +var require_parser2 = __commonJS({ + "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/parser.js"(exports2, module2) { + init_esm_shims(); + var ParserEND = 1114112; + var ParserError = class _ParserError extends Error { + /* istanbul ignore next */ + constructor(msg, filename, linenumber) { + super("[ParserError] " + msg, filename, linenumber); + this.name = "ParserError"; + this.code = "ParserError"; + if (Error.captureStackTrace) Error.captureStackTrace(this, _ParserError); + } + }; + var State = class { + constructor(parser) { + this.parser = parser; + this.buf = ""; + this.returned = null; + this.result = null; + this.resultTable = null; + this.resultArr = null; + } + }; + var Parser = class { + constructor() { + this.pos = 0; + this.col = 0; + this.line = 0; + this.obj = {}; + this.ctx = this.obj; + this.stack = []; + this._buf = ""; + this.char = null; + this.ii = 0; + this.state = new State(this.parseStart); + } + parse(str) { + if (str.length === 0 || str.length == null) return; + this._buf = String(str); + this.ii = -1; + this.char = -1; + let getNext; + while (getNext === false || this.nextChar()) { + getNext = this.runOne(); } - parseOnlyTimeMin() { - if (this.state.buf.length < 2 && isDigit(this.char)) { - this.consume(); - } else if (this.state.buf.length === 2 && this.char === CHAR_COLON) { - this.state.result += ":" + this.state.buf; - this.state.buf = ""; - return this.next(this.parseOnlyTimeSec); - } else { - throw this.error(new TomlError("Incomplete time")); - } - } - parseOnlyTimeSec() { - if (isDigit(this.char)) { - this.consume(); - if (this.state.buf.length === 2) { - return this.next(this.parseOnlyTimeFractionMaybe); - } - } else { - throw this.error(new TomlError("Incomplete time")); - } - } - parseOnlyTimeFractionMaybe() { - this.state.result += ":" + this.state.buf; - if (this.char === CHAR_PERIOD) { - this.state.buf = ""; - this.next(this.parseOnlyTimeFraction); - } else { - return this.return(createTime(this.state.result)); - } - } - parseOnlyTimeFraction() { - if (isDigit(this.char)) { - this.consume(); - } else if (this.atEndOfWord()) { - if (this.state.buf.length === 0) throw this.error(new TomlError("Expected digit in milliseconds")); - return this.returnNow(createTime(this.state.result + "." + this.state.buf)); - } else { - throw this.error(new TomlError("Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z")); - } - } - parseTimeZoneOrFraction() { - if (this.char === CHAR_PERIOD) { - this.consume(); - this.next(this.parseDateTimeFraction); - } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) { - this.consume(); - this.next(this.parseTimeZoneHour); - } else if (this.char === CHAR_Z) { - this.consume(); - return this.return(createDateTime(this.state.result + this.state.buf)); - } else if (this.atEndOfWord()) { - return this.returnNow(createDateTimeFloat(this.state.result + this.state.buf)); - } else { - throw this.error(new TomlError("Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z")); - } - } - parseDateTimeFraction() { - if (isDigit(this.char)) { - this.consume(); - } else if (this.state.buf.length === 1) { - throw this.error(new TomlError("Expected digit in milliseconds")); - } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) { - this.consume(); - this.next(this.parseTimeZoneHour); - } else if (this.char === CHAR_Z) { - this.consume(); - return this.return(createDateTime(this.state.result + this.state.buf)); - } else if (this.atEndOfWord()) { - return this.returnNow(createDateTimeFloat(this.state.result + this.state.buf)); - } else { - throw this.error(new TomlError("Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z")); - } - } - parseTimeZoneHour() { - if (isDigit(this.char)) { - this.consume(); - if (/\d\d$/.test(this.state.buf)) return this.next(this.parseTimeZoneSep); - } else { - throw this.error(new TomlError("Unexpected character in datetime, expected digit")); - } - } - parseTimeZoneSep() { - if (this.char === CHAR_COLON) { - this.consume(); - this.next(this.parseTimeZoneMin); - } else { - throw this.error(new TomlError("Unexpected character in datetime, expected colon")); - } - } - parseTimeZoneMin() { - if (isDigit(this.char)) { - this.consume(); - if (/\d\d$/.test(this.state.buf)) return this.return(createDateTime(this.state.result + this.state.buf)); - } else { - throw this.error(new TomlError("Unexpected character in datetime, expected digit")); - } - } - /* BOOLEAN */ - parseBoolean() { - if (this.char === CHAR_t) { - this.consume(); - return this.next(this.parseTrue_r); - } else if (this.char === CHAR_f) { - this.consume(); - return this.next(this.parseFalse_a); - } - } - parseTrue_r() { - if (this.char === CHAR_r) { - this.consume(); - return this.next(this.parseTrue_u); - } else { - throw this.error(new TomlError("Invalid boolean, expected true or false")); - } - } - parseTrue_u() { - if (this.char === CHAR_u) { - this.consume(); - return this.next(this.parseTrue_e); - } else { - throw this.error(new TomlError("Invalid boolean, expected true or false")); - } - } - parseTrue_e() { - if (this.char === CHAR_e) { - return this.return(true); - } else { - throw this.error(new TomlError("Invalid boolean, expected true or false")); - } - } - parseFalse_a() { - if (this.char === CHAR_a) { - this.consume(); - return this.next(this.parseFalse_l); - } else { - throw this.error(new TomlError("Invalid boolean, expected true or false")); - } - } - parseFalse_l() { - if (this.char === CHAR_l) { - this.consume(); - return this.next(this.parseFalse_s); - } else { - throw this.error(new TomlError("Invalid boolean, expected true or false")); - } - } - parseFalse_s() { - if (this.char === CHAR_s) { - this.consume(); - return this.next(this.parseFalse_e); - } else { - throw this.error(new TomlError("Invalid boolean, expected true or false")); - } - } - parseFalse_e() { - if (this.char === CHAR_e) { - return this.return(false); - } else { - throw this.error(new TomlError("Invalid boolean, expected true or false")); - } - } - /* INLINE LISTS */ - parseInlineList() { - if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J) { - return null; - } else if (this.char === Parser2.END) { - throw this.error(new TomlError("Unterminated inline array")); - } else if (this.char === CHAR_NUM) { - return this.call(this.parseComment); - } else if (this.char === CHAR_RSQB) { - return this.return(this.state.resultArr || InlineList()); - } else { - return this.callNow(this.parseValue, this.recordInlineListValue); - } - } - recordInlineListValue(value) { - if (this.state.resultArr) { - const listType = this.state.resultArr[_contentType]; - const valueType = tomlType(value); - if (listType !== valueType) { - throw this.error(new TomlError(`Inline lists must be a single type, not a mix of ${listType} and ${valueType}`)); - } - } else { - this.state.resultArr = InlineList(tomlType(value)); - } - if (isFloat(value) || isInteger(value)) { - this.state.resultArr.push(value.valueOf()); - } else { - this.state.resultArr.push(value); - } - return this.goto(this.parseInlineListNext); - } - parseInlineListNext() { - if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J) { - return null; - } else if (this.char === CHAR_NUM) { - return this.call(this.parseComment); - } else if (this.char === CHAR_COMMA) { - return this.next(this.parseInlineList); - } else if (this.char === CHAR_RSQB) { - return this.goto(this.parseInlineList); - } else { - throw this.error(new TomlError("Invalid character, expected whitespace, comma (,) or close bracket (])")); - } - } - /* INLINE TABLE */ - parseInlineTable() { - if (this.char === CHAR_SP || this.char === CTRL_I) { - return null; - } else if (this.char === Parser2.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) { - throw this.error(new TomlError("Unterminated inline array")); - } else if (this.char === CHAR_RCUB) { - return this.return(this.state.resultTable || InlineTable()); - } else { - if (!this.state.resultTable) this.state.resultTable = InlineTable(); - return this.callNow(this.parseAssign, this.recordInlineTableValue); - } - } - recordInlineTableValue(kv) { - let target = this.state.resultTable; - let finalKey = kv.key.pop(); - for (let kw of kv.key) { - if (hasKey(target, kw) && (!isTable(target[kw]) || target[kw][_declared])) { - throw this.error(new TomlError("Can't redefine existing key")); - } - target = target[kw] = target[kw] || Table(); - } - if (hasKey(target, finalKey)) { - throw this.error(new TomlError("Can't redefine existing key")); - } - if (isInteger(kv.value) || isFloat(kv.value)) { - target[finalKey] = kv.value.valueOf(); - } else { - target[finalKey] = kv.value; - } - return this.goto(this.parseInlineTableNext); - } - parseInlineTableNext() { - if (this.char === CHAR_SP || this.char === CTRL_I) { - return null; - } else if (this.char === Parser2.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) { - throw this.error(new TomlError("Unterminated inline array")); - } else if (this.char === CHAR_COMMA) { - return this.next(this.parseInlineTable); - } else if (this.char === CHAR_RCUB) { - return this.goto(this.parseInlineTable); - } else { - throw this.error(new TomlError("Invalid character, expected whitespace, comma (,) or close bracket (])")); - } + this._buf = null; + } + nextChar() { + if (this.char === 10) { + ++this.line; + this.col = -1; } + ++this.ii; + this.char = this._buf.codePointAt(this.ii); + ++this.pos; + ++this.col; + return this.haveBuffer(); } - return TOMLParser; - } - } -}); - -// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-pretty-error.js -var require_parse_pretty_error = __commonJS({ - "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-pretty-error.js"(exports2, module2) { - init_esm_shims(); - module2.exports = prettyError; - function prettyError(err, buf) { - if (err.pos == null || err.line == null) return err; - let msg = err.message; - msg += ` at row ${err.line + 1}, col ${err.col + 1}, pos ${err.pos}: -`; - if (buf && buf.split) { - const lines = buf.split(/\n/); - const lineNumWidth = String(Math.min(lines.length, err.line + 3)).length; - let linePadding = " "; - while (linePadding.length < lineNumWidth) linePadding += " "; - for (let ii = Math.max(0, err.line - 1); ii < Math.min(lines.length, err.line + 2); ++ii) { - let lineNum = String(ii + 1); - if (lineNum.length < lineNumWidth) lineNum = " " + lineNum; - if (err.line === ii) { - msg += lineNum + "> " + lines[ii] + "\n"; - msg += linePadding + " "; - for (let hh = 0; hh < err.col; ++hh) { - msg += " "; - } - msg += "^\n"; - } else { - msg += lineNum + ": " + lines[ii] + "\n"; - } - } + haveBuffer() { + return this.ii < this._buf.length; } - err.message = msg + "\n"; - return err; - } + runOne() { + return this.state.parser.call(this, this.state.returned); + } + finish() { + this.char = ParserEND; + let last; + do { + last = this.state.parser; + this.runOne(); + } while (this.state.parser !== last); + this.ctx = null; + this.state = null; + this._buf = null; + return this.obj; + } + next(fn) { + if (typeof fn !== "function") throw new ParserError("Tried to set state to non-existent state: " + JSON.stringify(fn)); + this.state.parser = fn; + } + goto(fn) { + this.next(fn); + return this.runOne(); + } + call(fn, returnWith) { + if (returnWith) this.next(returnWith); + this.stack.push(this.state); + this.state = new State(fn); + } + callNow(fn, returnWith) { + this.call(fn, returnWith); + return this.runOne(); + } + return(value) { + if (this.stack.length === 0) throw this.error(new ParserError("Stack underflow")); + if (value === void 0) value = this.state.buf; + this.state = this.stack.pop(); + this.state.returned = value; + } + returnNow(value) { + this.return(value); + return this.runOne(); + } + consume() { + if (this.char === ParserEND) throw this.error(new ParserError("Unexpected end-of-buffer")); + this.state.buf += this._buf[this.ii]; + } + error(err) { + err.line = this.line; + err.col = this.col; + err.pos = this.pos; + return err; + } + /* istanbul ignore next */ + parseStart() { + throw new ParserError("Must declare a parseStart method"); + } + }; + Parser.END = ParserEND; + Parser.Error = ParserError; + module2.exports = Parser; } }); -// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-string.js -var require_parse_string = __commonJS({ - "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-string.js"(exports2, module2) { +// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime.js +var require_create_datetime = __commonJS({ + "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime.js"(exports2, module2) { init_esm_shims(); - module2.exports = parseString; - var TOMLParser = require_toml_parser(); - var prettyError = require_parse_pretty_error(); - function parseString(str2) { - if (global.Buffer && global.Buffer.isBuffer(str2)) { - str2 = str2.toString("utf8"); - } - const parser2 = new TOMLParser(); - try { - parser2.parse(str2); - return parser2.finish(); - } catch (err) { - throw prettyError(err, str2); + module2.exports = (value) => { + const date = new Date(value); + if (isNaN(date)) { + throw new TypeError("Invalid Datetime"); + } else { + return date; } - } + }; } }); -// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-async.js -var require_parse_async = __commonJS({ - "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-async.js"(exports2, module2) { +// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/format-num.js +var require_format_num = __commonJS({ + "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/format-num.js"(exports2, module2) { init_esm_shims(); - module2.exports = parseAsync; - var TOMLParser = require_toml_parser(); - var prettyError = require_parse_pretty_error(); - function parseAsync(str2, opts) { - if (!opts) opts = {}; - const index = 0; - const blocksize = opts.blocksize || 40960; - const parser2 = new TOMLParser(); - return new Promise((resolve5, reject) => { - setImmediate(parseAsyncNext, index, blocksize, resolve5, reject); - }); - function parseAsyncNext(index2, blocksize2, resolve5, reject) { - if (index2 >= str2.length) { - try { - return resolve5(parser2.finish()); - } catch (err) { - return reject(prettyError(err, str2)); - } - } - try { - parser2.parse(str2.slice(index2, index2 + blocksize2)); - setImmediate(parseAsyncNext, index2 + blocksize2, blocksize2, resolve5, reject); - } catch (err) { - reject(prettyError(err, str2)); - } - } - } + module2.exports = (d2, num) => { + num = String(num); + while (num.length < d2) num = "0" + num; + return num; + }; } }); -// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-stream.js -var require_parse_stream = __commonJS({ - "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-stream.js"(exports2, module2) { +// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime-float.js +var require_create_datetime_float = __commonJS({ + "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime-float.js"(exports2, module2) { init_esm_shims(); - module2.exports = parseStream; - var stream = __require("stream"); - var TOMLParser = require_toml_parser(); - function parseStream(stm) { - if (stm) { - return parseReadable(stm); + var f2 = require_format_num(); + var FloatingDateTime = class extends Date { + constructor(value) { + super(value + "Z"); + this.isFloating = true; + } + toISOString() { + const date = `${this.getUTCFullYear()}-${f2(2, this.getUTCMonth() + 1)}-${f2(2, this.getUTCDate())}`; + const time = `${f2(2, this.getUTCHours())}:${f2(2, this.getUTCMinutes())}:${f2(2, this.getUTCSeconds())}.${f2(3, this.getUTCMilliseconds())}`; + return `${date}T${time}`; + } + }; + module2.exports = (value) => { + const date = new FloatingDateTime(value); + if (isNaN(date)) { + throw new TypeError("Invalid Datetime"); } else { - return parseTransform(); + return date; } - } - function parseReadable(stm) { - const parser2 = new TOMLParser(); - stm.setEncoding("utf8"); - return new Promise((resolve5, reject) => { - let readable; - let ended = false; - let errored = false; - function finish() { - ended = true; - if (readable) return; - try { - resolve5(parser2.finish()); - } catch (err) { - reject(err); - } - } - function error(err) { - errored = true; - reject(err); - } - stm.once("end", finish); - stm.once("error", error); - readNext(); - function readNext() { - readable = true; - let data; - while ((data = stm.read()) !== null) { - try { - parser2.parse(data); - } catch (err) { - return error(err); - } - } - readable = false; - if (ended) return finish(); - if (errored) return; - stm.once("readable", readNext); - } - }); - } - function parseTransform() { - const parser2 = new TOMLParser(); - return new stream.Transform({ - objectMode: true, - transform(chunk, encoding, cb) { - try { - parser2.parse(chunk.toString(encoding)); - } catch (err) { - this.emit("error", err); - } - cb(); - }, - flush(cb) { - try { - this.push(parser2.finish()); - } catch (err) { - this.emit("error", err); - } - cb(); - } - }); - } + }; } }); -// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse.js -var require_parse = __commonJS({ - "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse.js"(exports2, module2) { +// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-date.js +var require_create_date = __commonJS({ + "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-date.js"(exports2, module2) { init_esm_shims(); - module2.exports = require_parse_string(); - module2.exports.async = require_parse_async(); - module2.exports.stream = require_parse_stream(); - module2.exports.prettyError = require_parse_pretty_error(); + var f2 = require_format_num(); + var DateTime = global.Date; + var Date2 = class extends DateTime { + constructor(value) { + super(value); + this.isDate = true; + } + toISOString() { + return `${this.getUTCFullYear()}-${f2(2, this.getUTCMonth() + 1)}-${f2(2, this.getUTCDate())}`; + } + }; + module2.exports = (value) => { + const date = new Date2(value); + if (isNaN(date)) { + throw new TypeError("Invalid Datetime"); + } else { + return date; + } + }; } }); -// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/stringify.js -var require_stringify = __commonJS({ - "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/stringify.js"(exports2, module2) { +// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-time.js +var require_create_time = __commonJS({ + "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-time.js"(exports2, module2) { init_esm_shims(); - module2.exports = stringify; - module2.exports.value = stringifyInline; - function stringify(obj) { - if (obj === null) throw typeError("null"); - if (obj === void 0) throw typeError("undefined"); - if (typeof obj !== "object") throw typeError(typeof obj); - if (typeof obj.toJSON === "function") obj = obj.toJSON(); - if (obj == null) return null; - const type2 = tomlType2(obj); - if (type2 !== "table") throw typeError(type2); - return stringifyObject("", "", obj); - } - function typeError(type2) { - return new Error("Can only stringify objects, not " + type2); - } - function arrayOneTypeError() { - return new Error("Array values can't have mixed types"); - } - function getInlineKeys(obj) { - return Object.keys(obj).filter((key) => isInline(obj[key])); - } - function getComplexKeys(obj) { - return Object.keys(obj).filter((key) => !isInline(obj[key])); - } - function toJSON(obj) { - let nobj = Array.isArray(obj) ? [] : Object.prototype.hasOwnProperty.call(obj, "__proto__") ? { ["__proto__"]: void 0 } : {}; - for (let prop of Object.keys(obj)) { - if (obj[prop] && typeof obj[prop].toJSON === "function" && !("toISOString" in obj[prop])) { - nobj[prop] = obj[prop].toJSON(); - } else { - nobj[prop] = obj[prop]; - } + var f2 = require_format_num(); + var Time = class extends Date { + constructor(value) { + super(`0000-01-01T${value}Z`); + this.isTime = true; } - return nobj; - } - function stringifyObject(prefix, indent, obj) { - obj = toJSON(obj); - var inlineKeys; - var complexKeys; - inlineKeys = getInlineKeys(obj); - complexKeys = getComplexKeys(obj); - var result = []; - var inlineIndent = indent || ""; - inlineKeys.forEach((key) => { - var type2 = tomlType2(obj[key]); - if (type2 !== "undefined" && type2 !== "null") { - result.push(inlineIndent + stringifyKey(key) + " = " + stringifyAnyInline(obj[key], true)); - } - }); - if (result.length > 0) result.push(""); - var complexIndent = prefix && inlineKeys.length > 0 ? indent + " " : ""; - complexKeys.forEach((key) => { - result.push(stringifyComplex(prefix, complexIndent, key, obj[key])); - }); - return result.join("\n"); - } - function isInline(value) { - switch (tomlType2(value)) { - case "undefined": - case "null": - case "integer": - case "nan": - case "float": - case "boolean": - case "string": - case "datetime": - return true; - case "array": - return value.length === 0 || tomlType2(value[0]) !== "table"; - case "table": - return Object.keys(value).length === 0; - /* istanbul ignore next */ - default: - return false; + toISOString() { + return `${f2(2, this.getUTCHours())}:${f2(2, this.getUTCMinutes())}:${f2(2, this.getUTCSeconds())}.${f2(3, this.getUTCMilliseconds())}`; } - } - function tomlType2(value) { - if (value === void 0) { - return "undefined"; - } else if (value === null) { - return "null"; - } else if (typeof value === "bigint" || Number.isInteger(value) && !Object.is(value, -0)) { - return "integer"; - } else if (typeof value === "number") { - return "float"; - } else if (typeof value === "boolean") { - return "boolean"; - } else if (typeof value === "string") { - return "string"; - } else if ("toISOString" in value) { - return isNaN(value) ? "undefined" : "datetime"; - } else if (Array.isArray(value)) { - return "array"; + }; + module2.exports = (value) => { + const date = new Time(value); + if (isNaN(date)) { + throw new TypeError("Invalid Datetime"); } else { - return "table"; + return date; } - } - function stringifyKey(key) { - var keyStr = String(key); - if (/^[-A-Za-z0-9_]+$/.test(keyStr)) { - return keyStr; - } else { - return stringifyBasicString(keyStr); + }; + } +}); + +// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/toml-parser.js +var require_toml_parser = __commonJS({ + "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/toml-parser.js"(exports$1, module) { + init_esm_shims(); + module.exports = makeParserClass(require_parser2()); + module.exports.makeParserClass = makeParserClass; + var TomlError = class _TomlError extends Error { + constructor(msg) { + super(msg); + this.name = "TomlError"; + if (Error.captureStackTrace) Error.captureStackTrace(this, _TomlError); + this.fromTOML = true; + this.wrapped = null; } + }; + TomlError.wrap = (err) => { + const terr = new TomlError(err.message); + terr.code = err.code; + terr.wrapped = err; + return terr; + }; + module.exports.TomlError = TomlError; + var createDateTime = require_create_datetime(); + var createDateTimeFloat = require_create_datetime_float(); + var createDate = require_create_date(); + var createTime = require_create_time(); + var CTRL_I = 9; + var CTRL_J = 10; + var CTRL_M = 13; + var CTRL_CHAR_BOUNDARY = 31; + var CHAR_SP = 32; + var CHAR_QUOT = 34; + var CHAR_NUM = 35; + var CHAR_APOS = 39; + var CHAR_PLUS = 43; + var CHAR_COMMA = 44; + var CHAR_HYPHEN = 45; + var CHAR_PERIOD = 46; + var CHAR_0 = 48; + var CHAR_1 = 49; + var CHAR_7 = 55; + var CHAR_9 = 57; + var CHAR_COLON = 58; + var CHAR_EQUALS = 61; + var CHAR_A = 65; + var CHAR_E = 69; + var CHAR_F = 70; + var CHAR_T = 84; + var CHAR_U = 85; + var CHAR_Z = 90; + var CHAR_LOWBAR = 95; + var CHAR_a = 97; + var CHAR_b = 98; + var CHAR_e = 101; + var CHAR_f = 102; + var CHAR_i = 105; + var CHAR_l = 108; + var CHAR_n = 110; + var CHAR_o = 111; + var CHAR_r = 114; + var CHAR_s = 115; + var CHAR_t = 116; + var CHAR_u = 117; + var CHAR_x = 120; + var CHAR_z = 122; + var CHAR_LCUB = 123; + var CHAR_RCUB = 125; + var CHAR_LSQB = 91; + var CHAR_BSOL = 92; + var CHAR_RSQB = 93; + var CHAR_DEL = 127; + var SURROGATE_FIRST = 55296; + var SURROGATE_LAST = 57343; + var escapes = { + [CHAR_b]: "\b", + [CHAR_t]: " ", + [CHAR_n]: "\n", + [CHAR_f]: "\f", + [CHAR_r]: "\r", + [CHAR_QUOT]: '"', + [CHAR_BSOL]: "\\" + }; + function isDigit(cp) { + return cp >= CHAR_0 && cp <= CHAR_9; } - function stringifyBasicString(str2) { - return '"' + escapeString2(str2).replace(/"/g, '\\"') + '"'; - } - function stringifyLiteralString(str2) { - return "'" + str2 + "'"; + function isHexit(cp) { + return cp >= CHAR_A && cp <= CHAR_F || cp >= CHAR_a && cp <= CHAR_f || cp >= CHAR_0 && cp <= CHAR_9; } - function numpad(num, str2) { - while (str2.length < num) str2 = "0" + str2; - return str2; + function isBit(cp) { + return cp === CHAR_1 || cp === CHAR_0; } - function escapeString2(str2) { - return str2.replace(/\\/g, "\\\\").replace(/[\b]/g, "\\b").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\f/g, "\\f").replace(/\r/g, "\\r").replace(/([\u0000-\u001f\u007f])/, (c2) => "\\u" + numpad(4, c2.codePointAt(0).toString(16))); + function isOctit(cp) { + return cp >= CHAR_0 && cp <= CHAR_7; } - function stringifyMultilineString(str2) { - let escaped = str2.split(/\n/).map((str3) => { - return escapeString2(str3).replace(/"(?="")/g, '\\"'); - }).join("\n"); - if (escaped.slice(-1) === '"') escaped += "\\\n"; - return '"""\n' + escaped + '"""'; + function isAlphaNumQuoteHyphen(cp) { + return cp >= CHAR_A && cp <= CHAR_Z || cp >= CHAR_a && cp <= CHAR_z || cp >= CHAR_0 && cp <= CHAR_9 || cp === CHAR_APOS || cp === CHAR_QUOT || cp === CHAR_LOWBAR || cp === CHAR_HYPHEN; } - function stringifyAnyInline(value, multilineOk) { - let type2 = tomlType2(value); - if (type2 === "string") { - if (multilineOk && /\n/.test(value)) { - type2 = "string-multiline"; - } else if (!/[\b\t\n\f\r']/.test(value) && /"/.test(value)) { - type2 = "string-literal"; - } - } - return stringifyInline(value, type2); + function isAlphaNumHyphen(cp) { + return cp >= CHAR_A && cp <= CHAR_Z || cp >= CHAR_a && cp <= CHAR_z || cp >= CHAR_0 && cp <= CHAR_9 || cp === CHAR_LOWBAR || cp === CHAR_HYPHEN; } - function stringifyInline(value, type2) { - if (!type2) type2 = tomlType2(value); - switch (type2) { - case "string-multiline": - return stringifyMultilineString(value); - case "string": - return stringifyBasicString(value); - case "string-literal": - return stringifyLiteralString(value); - case "integer": - return stringifyInteger(value); - case "float": - return stringifyFloat(value); - case "boolean": - return stringifyBoolean(value); - case "datetime": - return stringifyDatetime(value); - case "array": - return stringifyInlineArray(value.filter((_) => tomlType2(_) !== "null" && tomlType2(_) !== "undefined" && tomlType2(_) !== "nan")); - case "table": - return stringifyInlineTable(value); - /* istanbul ignore next */ - default: - throw typeError(type2); - } + var _type = /* @__PURE__ */ Symbol("type"); + var _declared = /* @__PURE__ */ Symbol("declared"); + var hasOwnProperty = Object.prototype.hasOwnProperty; + var defineProperty = Object.defineProperty; + var descriptor = { configurable: true, enumerable: true, writable: true, value: void 0 }; + function hasKey(obj, key) { + if (hasOwnProperty.call(obj, key)) return true; + if (key === "__proto__") defineProperty(obj, "__proto__", descriptor); + return false; } - function stringifyInteger(value) { - return String(value).replace(/\B(?=(\d{3})+(?!\d))/g, "_"); + var INLINE_TABLE = /* @__PURE__ */ Symbol("inline-table"); + function InlineTable() { + return Object.defineProperties({}, { + [_type]: { value: INLINE_TABLE } + }); } - function stringifyFloat(value) { - if (value === Infinity) { - return "inf"; - } else if (value === -Infinity) { - return "-inf"; - } else if (Object.is(value, NaN)) { - return "nan"; - } else if (Object.is(value, -0)) { - return "-0.0"; - } - var chunks = String(value).split("."); - var int2 = chunks[0]; - var dec = chunks[1] || 0; - return stringifyInteger(int2) + "." + dec; + function isInlineTable(obj) { + if (obj === null || typeof obj !== "object") return false; + return obj[_type] === INLINE_TABLE; } - function stringifyBoolean(value) { - return String(value); + var TABLE = /* @__PURE__ */ Symbol("table"); + function Table() { + return Object.defineProperties({}, { + [_type]: { value: TABLE }, + [_declared]: { value: false, writable: true } + }); } - function stringifyDatetime(value) { - return value.toISOString(); - } - function isNumber(type2) { - return type2 === "float" || type2 === "integer"; - } - function arrayType(values) { - var contentType = tomlType2(values[0]); - if (values.every((_) => tomlType2(_) === contentType)) return contentType; - if (values.every((_) => isNumber(tomlType2(_)))) return "float"; - return "mixed"; + function isTable(obj) { + if (obj === null || typeof obj !== "object") return false; + return obj[_type] === TABLE; } - function validateArray(values) { - const type2 = arrayType(values); - if (type2 === "mixed") { - throw arrayOneTypeError(); - } - return type2; + var _contentType = /* @__PURE__ */ Symbol("content-type"); + var INLINE_LIST = /* @__PURE__ */ Symbol("inline-list"); + function InlineList(type) { + return Object.defineProperties([], { + [_type]: { value: INLINE_LIST }, + [_contentType]: { value: type } + }); } - function stringifyInlineArray(values) { - values = toJSON(values); - const type2 = validateArray(values); - var result = "["; - var stringified = values.map((_) => stringifyInline(_, type2)); - if (stringified.join(", ").length > 60 || /\n/.test(stringified)) { - result += "\n " + stringified.join(",\n ") + "\n"; - } else { - result += " " + stringified.join(", ") + (stringified.length > 0 ? " " : ""); - } - return result + "]"; + function isInlineList(obj) { + if (obj === null || typeof obj !== "object") return false; + return obj[_type] === INLINE_LIST; } - function stringifyInlineTable(value) { - value = toJSON(value); - var result = []; - Object.keys(value).forEach((key) => { - result.push(stringifyKey(key) + " = " + stringifyAnyInline(value[key], false)); + var LIST = /* @__PURE__ */ Symbol("list"); + function List() { + return Object.defineProperties([], { + [_type]: { value: LIST } }); - return "{ " + result.join(", ") + (result.length > 0 ? " " : "") + "}"; } - function stringifyComplex(prefix, indent, key, value) { - var valueType = tomlType2(value); - if (valueType === "array") { - return stringifyArrayOfTables(prefix, indent, key, value); - } else if (valueType === "table") { - return stringifyComplexTable(prefix, indent, key, value); - } else { - throw typeError(valueType); - } + function isList(obj) { + if (obj === null || typeof obj !== "object") return false; + return obj[_type] === LIST; } - function stringifyArrayOfTables(prefix, indent, key, values) { - values = toJSON(values); - validateArray(values); - var firstValueType = tomlType2(values[0]); - if (firstValueType !== "table") throw typeError(firstValueType); - var fullKey = prefix + stringifyKey(key); - var result = ""; - values.forEach((table) => { - if (result.length > 0) result += "\n"; - result += indent + "[[" + fullKey + "]]\n"; - result += stringifyObject(fullKey + ".", indent, table); - }); - return result; + var _custom; + try { + const utilInspect = eval("require('util').inspect"); + _custom = utilInspect.custom; + } catch (_) { } - function stringifyComplexTable(prefix, indent, key, value) { - var fullKey = prefix + stringifyKey(key); - var result = ""; - if (getInlineKeys(value).length > 0) { - result += indent + "[" + fullKey + "]\n"; + var _inspect = _custom || "inspect"; + var BoxedBigInt = class { + constructor(value) { + try { + this.value = global.BigInt.asIntN(64, value); + } catch (_) { + this.value = null; + } + Object.defineProperty(this, _type, { value: INTEGER }); + } + isNaN() { + return this.value === null; + } + /* istanbul ignore next */ + toString() { + return String(this.value); + } + /* istanbul ignore next */ + [_inspect]() { + return `[BigInt: ${this.toString()}]}`; + } + valueOf() { + return this.value; + } + }; + var INTEGER = /* @__PURE__ */ Symbol("integer"); + function Integer(value) { + let num = Number(value); + if (Object.is(num, -0)) num = 0; + if (global.BigInt && !Number.isSafeInteger(num)) { + return new BoxedBigInt(value); + } else { + return Object.defineProperties(new Number(num), { + isNaN: { value: function() { + return isNaN(this); + } }, + [_type]: { value: INTEGER }, + [_inspect]: { value: () => `[Integer: ${value}]` } + }); } - return result + stringifyObject(fullKey + ".", indent, value); - } - } -}); - -// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/toml.js -var require_toml = __commonJS({ - "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/toml.js"(exports2) { - init_esm_shims(); - exports2.parse = require_parse(); - exports2.stringify = require_stringify(); - } -}); - -// src/index.ts -init_esm_shims(); - -// src/depbadgerc/depbadgerc.store.ts -init_esm_shims(); - -// src/store/ctx-store.ts -init_esm_shims(); -function useCtxStore(ctxState, methodFactories) { - const store = { ...ctxState }; - if (methodFactories) - for (const CtxMethodKey in methodFactories) - store[CtxMethodKey] = methodFactories[CtxMethodKey](store); - return Object.freeze(store); -} -function useCtxCallback(callback) { - return ((store) => (...args) => callback(store, ...args)); -} - -// src/depbadgerc/apply-markdown-to-target.ts -init_esm_shims(); - -// src/shared/find-file.ts -init_esm_shims(); -function findFile(filename, startDir = process.cwd()) { - let dir = startDir; - while (true) { - const candidate = path2.join(dir, filename); - if (fs2.existsSync(candidate)) return candidate; - const parent = path2.dirname(dir); - if (parent === dir) break; - dir = parent; - } - return null; -} - -// src/depbadgerc/apply-markdown-to-target.ts -function formatMarkdown(store, markdowns) { - return markdowns.flatMap( - (md) => Object.entries(md).map(([section, badges]) => { - const layout = store[section]?.layout; - const headerText = layout?.showHeader ? layout?.header ?? section : ""; - const content = `${headerText ? ` - -# ${headerText} - -` : ""}${badges.join("\n")}`; - return layout?.position ? `
- -${content} - -
` : content; - }) - ).join("\n\n
\n\n").trim(); -} -var applyMarkdownToTarget = useCtxCallback((store, ...markdowns) => { - const fileAbsPath = findFile(store.target ?? "README.md"); - if (!fileAbsPath) return; - const renderedMarkdown = formatMarkdown(store, markdowns); - const fileContent = fs2.readFileSync(fileAbsPath, "utf8").replace( - /[\s\S]*?/, - ` -${renderedMarkdown} -` - ); - fs2.writeFileSync(fileAbsPath, fileContent, "utf8"); -}); - -// src/depbadgerc/compute-state-integrity.ts -init_esm_shims(); - -// node_modules/.pnpm/js-yaml@4.1.1/node_modules/js-yaml/dist/js-yaml.mjs -init_esm_shims(); -function isNothing(subject) { - return typeof subject === "undefined" || subject === null; -} -function isObject(subject) { - return typeof subject === "object" && subject !== null; -} -function toArray(sequence) { - if (Array.isArray(sequence)) return sequence; - else if (isNothing(sequence)) return []; - return [sequence]; -} -function extend(target, source) { - var index, length, key, sourceKeys; - if (source) { - sourceKeys = Object.keys(source); - for (index = 0, length = sourceKeys.length; index < length; index += 1) { - key = sourceKeys[index]; - target[key] = source[key]; } - } - return target; -} -function repeat(string, count) { - var result = "", cycle; - for (cycle = 0; cycle < count; cycle += 1) { - result += string; - } - return result; -} -function isNegativeZero(number) { - return number === 0 && Number.NEGATIVE_INFINITY === 1 / number; -} -var isNothing_1 = isNothing; -var isObject_1 = isObject; -var toArray_1 = toArray; -var repeat_1 = repeat; -var isNegativeZero_1 = isNegativeZero; -var extend_1 = extend; -var common = { - isNothing: isNothing_1, - isObject: isObject_1, - toArray: toArray_1, - repeat: repeat_1, - isNegativeZero: isNegativeZero_1, - extend: extend_1 -}; -function formatError(exception2, compact) { - var where = "", message = exception2.reason || "(unknown reason)"; - if (!exception2.mark) return message; - if (exception2.mark.name) { - where += 'in "' + exception2.mark.name + '" '; - } - where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")"; - if (!compact && exception2.mark.snippet) { - where += "\n\n" + exception2.mark.snippet; - } - return message + " " + where; -} -function YAMLException$1(reason, mark) { - Error.call(this); - this.name = "YAMLException"; - this.reason = reason; - this.mark = mark; - this.message = formatError(this, false); - if (Error.captureStackTrace) { - Error.captureStackTrace(this, this.constructor); - } else { - this.stack = new Error().stack || ""; - } -} -YAMLException$1.prototype = Object.create(Error.prototype); -YAMLException$1.prototype.constructor = YAMLException$1; -YAMLException$1.prototype.toString = function toString(compact) { - return this.name + ": " + formatError(this, compact); -}; -var exception = YAMLException$1; -function getLine(buffer, lineStart, lineEnd, position, maxLineLength) { - var head = ""; - var tail = ""; - var maxHalfLength = Math.floor(maxLineLength / 2) - 1; - if (position - lineStart > maxHalfLength) { - head = " ... "; - lineStart = position - maxHalfLength + head.length; - } - if (lineEnd - position > maxHalfLength) { - tail = " ..."; - lineEnd = position + maxHalfLength - tail.length; - } - return { - str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail, - pos: position - lineStart + head.length - // relative position - }; -} -function padStart(string, max) { - return common.repeat(" ", max - string.length) + string; -} -function makeSnippet(mark, options) { - options = Object.create(options || null); - if (!mark.buffer) return null; - if (!options.maxLength) options.maxLength = 79; - if (typeof options.indent !== "number") options.indent = 1; - if (typeof options.linesBefore !== "number") options.linesBefore = 3; - if (typeof options.linesAfter !== "number") options.linesAfter = 2; - var re = /\r?\n|\r|\0/g; - var lineStarts = [0]; - var lineEnds = []; - var match; - var foundLineNo = -1; - while (match = re.exec(mark.buffer)) { - lineEnds.push(match.index); - lineStarts.push(match.index + match[0].length); - if (mark.position <= match.index && foundLineNo < 0) { - foundLineNo = lineStarts.length - 2; + function isInteger(obj) { + if (obj === null || typeof obj !== "object") return false; + return obj[_type] === INTEGER; } - } - if (foundLineNo < 0) foundLineNo = lineStarts.length - 1; - var result = "", i2, line; - var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length; - var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3); - for (i2 = 1; i2 <= options.linesBefore; i2++) { - if (foundLineNo - i2 < 0) break; - line = getLine( - mark.buffer, - lineStarts[foundLineNo - i2], - lineEnds[foundLineNo - i2], - mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i2]), - maxLineLength - ); - result = common.repeat(" ", options.indent) + padStart((mark.line - i2 + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result; - } - line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength); - result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n"; - result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n"; - for (i2 = 1; i2 <= options.linesAfter; i2++) { - if (foundLineNo + i2 >= lineEnds.length) break; - line = getLine( - mark.buffer, - lineStarts[foundLineNo + i2], - lineEnds[foundLineNo + i2], - mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i2]), - maxLineLength - ); - result += common.repeat(" ", options.indent) + padStart((mark.line + i2 + 1).toString(), lineNoLength) + " | " + line.str + "\n"; - } - return result.replace(/\n$/, ""); -} -var snippet = makeSnippet; -var TYPE_CONSTRUCTOR_OPTIONS = [ - "kind", - "multi", - "resolve", - "construct", - "instanceOf", - "predicate", - "represent", - "representName", - "defaultStyle", - "styleAliases" -]; -var YAML_NODE_KINDS = [ - "scalar", - "sequence", - "mapping" -]; -function compileStyleAliases(map2) { - var result = {}; - if (map2 !== null) { - Object.keys(map2).forEach(function(style) { - map2[style].forEach(function(alias) { - result[String(alias)] = style; + var FLOAT = /* @__PURE__ */ Symbol("float"); + function Float(value) { + return Object.defineProperties(new Number(value), { + [_type]: { value: FLOAT }, + [_inspect]: { value: () => `[Float: ${value}]` } }); - }); - } - return result; -} -function Type$1(tag, options) { - options = options || {}; - Object.keys(options).forEach(function(name) { - if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { - throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); } - }); - this.options = options; - this.tag = tag; - this.kind = options["kind"] || null; - this.resolve = options["resolve"] || function() { - return true; - }; - this.construct = options["construct"] || function(data) { - return data; - }; - this.instanceOf = options["instanceOf"] || null; - this.predicate = options["predicate"] || null; - this.represent = options["represent"] || null; - this.representName = options["representName"] || null; - this.defaultStyle = options["defaultStyle"] || null; - this.multi = options["multi"] || false; - this.styleAliases = compileStyleAliases(options["styleAliases"] || null); - if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { - throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); - } -} -var type = Type$1; -function compileList(schema2, name) { - var result = []; - schema2[name].forEach(function(currentType) { - var newIndex = result.length; - result.forEach(function(previousType, previousIndex) { - if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) { - newIndex = previousIndex; - } - }); - result[newIndex] = currentType; - }); - return result; -} -function compileMap() { - var result = { - scalar: {}, - sequence: {}, - mapping: {}, - fallback: {}, - multi: { - scalar: [], - sequence: [], - mapping: [], - fallback: [] - } - }, index, length; - function collectType(type2) { - if (type2.multi) { - result.multi[type2.kind].push(type2); - result.multi["fallback"].push(type2); - } else { - result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2; + function isFloat(obj) { + if (obj === null || typeof obj !== "object") return false; + return obj[_type] === FLOAT; } - } - for (index = 0, length = arguments.length; index < length; index += 1) { - arguments[index].forEach(collectType); - } - return result; -} -function Schema$1(definition) { - return this.extend(definition); -} -Schema$1.prototype.extend = function extend2(definition) { - var implicit = []; - var explicit = []; - if (definition instanceof type) { - explicit.push(definition); - } else if (Array.isArray(definition)) { - explicit = explicit.concat(definition); - } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) { - if (definition.implicit) implicit = implicit.concat(definition.implicit); - if (definition.explicit) explicit = explicit.concat(definition.explicit); - } else { - throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })"); - } - implicit.forEach(function(type$1) { - if (!(type$1 instanceof type)) { - throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object."); - } - if (type$1.loadKind && type$1.loadKind !== "scalar") { - throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported."); - } - if (type$1.multi) { - throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit."); - } - }); - explicit.forEach(function(type$1) { - if (!(type$1 instanceof type)) { - throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object."); - } - }); - var result = Object.create(Schema$1.prototype); - result.implicit = (this.implicit || []).concat(implicit); - result.explicit = (this.explicit || []).concat(explicit); - result.compiledImplicit = compileList(result, "implicit"); - result.compiledExplicit = compileList(result, "explicit"); - result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit); - return result; -}; -var schema = Schema$1; -var str = new type("tag:yaml.org,2002:str", { - kind: "scalar", - construct: function(data) { - return data !== null ? data : ""; - } -}); -var seq = new type("tag:yaml.org,2002:seq", { - kind: "sequence", - construct: function(data) { - return data !== null ? data : []; - } -}); -var map = new type("tag:yaml.org,2002:map", { - kind: "mapping", - construct: function(data) { - return data !== null ? data : {}; - } -}); -var failsafe = new schema({ - explicit: [ - str, - seq, - map - ] -}); -function resolveYamlNull(data) { - if (data === null) return true; - var max = data.length; - return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL"); -} -function constructYamlNull() { - return null; -} -function isNull(object) { - return object === null; -} -var _null = new type("tag:yaml.org,2002:null", { - kind: "scalar", - resolve: resolveYamlNull, - construct: constructYamlNull, - predicate: isNull, - represent: { - canonical: function() { - return "~"; - }, - lowercase: function() { - return "null"; - }, - uppercase: function() { - return "NULL"; - }, - camelcase: function() { - return "Null"; - }, - empty: function() { - return ""; - } - }, - defaultStyle: "lowercase" -}); -function resolveYamlBoolean(data) { - if (data === null) return false; - var max = data.length; - return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE"); -} -function constructYamlBoolean(data) { - return data === "true" || data === "True" || data === "TRUE"; -} -function isBoolean(object) { - return Object.prototype.toString.call(object) === "[object Boolean]"; -} -var bool = new type("tag:yaml.org,2002:bool", { - kind: "scalar", - resolve: resolveYamlBoolean, - construct: constructYamlBoolean, - predicate: isBoolean, - represent: { - lowercase: function(object) { - return object ? "true" : "false"; - }, - uppercase: function(object) { - return object ? "TRUE" : "FALSE"; - }, - camelcase: function(object) { - return object ? "True" : "False"; - } - }, - defaultStyle: "lowercase" -}); -function isHexCode(c2) { - return 48 <= c2 && c2 <= 57 || 65 <= c2 && c2 <= 70 || 97 <= c2 && c2 <= 102; -} -function isOctCode(c2) { - return 48 <= c2 && c2 <= 55; -} -function isDecCode(c2) { - return 48 <= c2 && c2 <= 57; -} -function resolveYamlInteger(data) { - if (data === null) return false; - var max = data.length, index = 0, hasDigits = false, ch; - if (!max) return false; - ch = data[index]; - if (ch === "-" || ch === "+") { - ch = data[++index]; - } - if (ch === "0") { - if (index + 1 === max) return true; - ch = data[++index]; - if (ch === "b") { - index++; - for (; index < max; index++) { - ch = data[index]; - if (ch === "_") continue; - if (ch !== "0" && ch !== "1") return false; - hasDigits = true; - } - return hasDigits && ch !== "_"; - } - if (ch === "x") { - index++; - for (; index < max; index++) { - ch = data[index]; - if (ch === "_") continue; - if (!isHexCode(data.charCodeAt(index))) return false; - hasDigits = true; - } - return hasDigits && ch !== "_"; - } - if (ch === "o") { - index++; - for (; index < max; index++) { - ch = data[index]; - if (ch === "_") continue; - if (!isOctCode(data.charCodeAt(index))) return false; - hasDigits = true; - } - return hasDigits && ch !== "_"; - } - } - if (ch === "_") return false; - for (; index < max; index++) { - ch = data[index]; - if (ch === "_") continue; - if (!isDecCode(data.charCodeAt(index))) { - return false; - } - hasDigits = true; - } - if (!hasDigits || ch === "_") return false; - return true; -} -function constructYamlInteger(data) { - var value = data, sign = 1, ch; - if (value.indexOf("_") !== -1) { - value = value.replace(/_/g, ""); - } - ch = value[0]; - if (ch === "-" || ch === "+") { - if (ch === "-") sign = -1; - value = value.slice(1); - ch = value[0]; - } - if (value === "0") return 0; - if (ch === "0") { - if (value[1] === "b") return sign * parseInt(value.slice(2), 2); - if (value[1] === "x") return sign * parseInt(value.slice(2), 16); - if (value[1] === "o") return sign * parseInt(value.slice(2), 8); - } - return sign * parseInt(value, 10); -} -function isInteger2(object) { - return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object)); -} -var int = new type("tag:yaml.org,2002:int", { - kind: "scalar", - resolve: resolveYamlInteger, - construct: constructYamlInteger, - predicate: isInteger2, - represent: { - binary: function(obj) { - return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1); - }, - octal: function(obj) { - return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1); - }, - decimal: function(obj) { - return obj.toString(10); - }, - /* eslint-disable max-len */ - hexadecimal: function(obj) { - return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1); - } - }, - defaultStyle: "decimal", - styleAliases: { - binary: [2, "bin"], - octal: [8, "oct"], - decimal: [10, "dec"], - hexadecimal: [16, "hex"] - } -}); -var YAML_FLOAT_PATTERN = new RegExp( - // 2.5e4, 2.5 and integers - "^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$" -); -function resolveYamlFloat(data) { - if (data === null) return false; - if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_` - // Probably should update regexp & check speed - data[data.length - 1] === "_") { - return false; - } - return true; -} -function constructYamlFloat(data) { - var value, sign; - value = data.replace(/_/g, "").toLowerCase(); - sign = value[0] === "-" ? -1 : 1; - if ("+-".indexOf(value[0]) >= 0) { - value = value.slice(1); - } - if (value === ".inf") { - return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; - } else if (value === ".nan") { - return NaN; - } - return sign * parseFloat(value, 10); -} -var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; -function representYamlFloat(object, style) { - var res; - if (isNaN(object)) { - switch (style) { - case "lowercase": - return ".nan"; - case "uppercase": - return ".NAN"; - case "camelcase": - return ".NaN"; - } - } else if (Number.POSITIVE_INFINITY === object) { - switch (style) { - case "lowercase": - return ".inf"; - case "uppercase": - return ".INF"; - case "camelcase": - return ".Inf"; - } - } else if (Number.NEGATIVE_INFINITY === object) { - switch (style) { - case "lowercase": - return "-.inf"; - case "uppercase": - return "-.INF"; - case "camelcase": - return "-.Inf"; - } - } else if (common.isNegativeZero(object)) { - return "-0.0"; - } - res = object.toString(10); - return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res; -} -function isFloat2(object) { - return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object)); -} -var float = new type("tag:yaml.org,2002:float", { - kind: "scalar", - resolve: resolveYamlFloat, - construct: constructYamlFloat, - predicate: isFloat2, - represent: representYamlFloat, - defaultStyle: "lowercase" -}); -var json = failsafe.extend({ - implicit: [ - _null, - bool, - int, - float - ] -}); -var core = json; -var YAML_DATE_REGEXP = new RegExp( - "^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$" -); -var YAML_TIMESTAMP_REGEXP = new RegExp( - "^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$" -); -function resolveYamlTimestamp(data) { - if (data === null) return false; - if (YAML_DATE_REGEXP.exec(data) !== null) return true; - if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true; - return false; -} -function constructYamlTimestamp(data) { - var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date; - match = YAML_DATE_REGEXP.exec(data); - if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data); - if (match === null) throw new Error("Date resolve error"); - year = +match[1]; - month = +match[2] - 1; - day = +match[3]; - if (!match[4]) { - return new Date(Date.UTC(year, month, day)); - } - hour = +match[4]; - minute = +match[5]; - second = +match[6]; - if (match[7]) { - fraction = match[7].slice(0, 3); - while (fraction.length < 3) { - fraction += "0"; - } - fraction = +fraction; - } - if (match[9]) { - tz_hour = +match[10]; - tz_minute = +(match[11] || 0); - delta = (tz_hour * 60 + tz_minute) * 6e4; - if (match[9] === "-") delta = -delta; - } - date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); - if (delta) date.setTime(date.getTime() - delta); - return date; -} -function representYamlTimestamp(object) { - return object.toISOString(); -} -var timestamp = new type("tag:yaml.org,2002:timestamp", { - kind: "scalar", - resolve: resolveYamlTimestamp, - construct: constructYamlTimestamp, - instanceOf: Date, - represent: representYamlTimestamp -}); -function resolveYamlMerge(data) { - return data === "<<" || data === null; -} -var merge = new type("tag:yaml.org,2002:merge", { - kind: "scalar", - resolve: resolveYamlMerge -}); -var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r"; -function resolveYamlBinary(data) { - if (data === null) return false; - var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP; - for (idx = 0; idx < max; idx++) { - code = map2.indexOf(data.charAt(idx)); - if (code > 64) continue; - if (code < 0) return false; - bitlen += 6; - } - return bitlen % 8 === 0; -} -function constructYamlBinary(data) { - var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = []; - for (idx = 0; idx < max; idx++) { - if (idx % 4 === 0 && idx) { - result.push(bits >> 16 & 255); - result.push(bits >> 8 & 255); - result.push(bits & 255); - } - bits = bits << 6 | map2.indexOf(input.charAt(idx)); - } - tailbits = max % 4 * 6; - if (tailbits === 0) { - result.push(bits >> 16 & 255); - result.push(bits >> 8 & 255); - result.push(bits & 255); - } else if (tailbits === 18) { - result.push(bits >> 10 & 255); - result.push(bits >> 2 & 255); - } else if (tailbits === 12) { - result.push(bits >> 4 & 255); - } - return new Uint8Array(result); -} -function representYamlBinary(object) { - var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP; - for (idx = 0; idx < max; idx++) { - if (idx % 3 === 0 && idx) { - result += map2[bits >> 18 & 63]; - result += map2[bits >> 12 & 63]; - result += map2[bits >> 6 & 63]; - result += map2[bits & 63]; - } - bits = (bits << 8) + object[idx]; - } - tail = max % 3; - if (tail === 0) { - result += map2[bits >> 18 & 63]; - result += map2[bits >> 12 & 63]; - result += map2[bits >> 6 & 63]; - result += map2[bits & 63]; - } else if (tail === 2) { - result += map2[bits >> 10 & 63]; - result += map2[bits >> 4 & 63]; - result += map2[bits << 2 & 63]; - result += map2[64]; - } else if (tail === 1) { - result += map2[bits >> 2 & 63]; - result += map2[bits << 4 & 63]; - result += map2[64]; - result += map2[64]; - } - return result; -} -function isBinary(obj) { - return Object.prototype.toString.call(obj) === "[object Uint8Array]"; -} -var binary = new type("tag:yaml.org,2002:binary", { - kind: "scalar", - resolve: resolveYamlBinary, - construct: constructYamlBinary, - predicate: isBinary, - represent: representYamlBinary -}); -var _hasOwnProperty$3 = Object.prototype.hasOwnProperty; -var _toString$2 = Object.prototype.toString; -function resolveYamlOmap(data) { - if (data === null) return true; - var objectKeys2 = [], index, length, pair, pairKey, pairHasKey, object = data; - for (index = 0, length = object.length; index < length; index += 1) { - pair = object[index]; - pairHasKey = false; - if (_toString$2.call(pair) !== "[object Object]") return false; - for (pairKey in pair) { - if (_hasOwnProperty$3.call(pair, pairKey)) { - if (!pairHasKey) pairHasKey = true; - else return false; - } - } - if (!pairHasKey) return false; - if (objectKeys2.indexOf(pairKey) === -1) objectKeys2.push(pairKey); - else return false; - } - return true; -} -function constructYamlOmap(data) { - return data !== null ? data : []; -} -var omap = new type("tag:yaml.org,2002:omap", { - kind: "sequence", - resolve: resolveYamlOmap, - construct: constructYamlOmap -}); -var _toString$1 = Object.prototype.toString; -function resolveYamlPairs(data) { - if (data === null) return true; - var index, length, pair, keys, result, object = data; - result = new Array(object.length); - for (index = 0, length = object.length; index < length; index += 1) { - pair = object[index]; - if (_toString$1.call(pair) !== "[object Object]") return false; - keys = Object.keys(pair); - if (keys.length !== 1) return false; - result[index] = [keys[0], pair[keys[0]]]; - } - return true; -} -function constructYamlPairs(data) { - if (data === null) return []; - var index, length, pair, keys, result, object = data; - result = new Array(object.length); - for (index = 0, length = object.length; index < length; index += 1) { - pair = object[index]; - keys = Object.keys(pair); - result[index] = [keys[0], pair[keys[0]]]; - } - return result; -} -var pairs = new type("tag:yaml.org,2002:pairs", { - kind: "sequence", - resolve: resolveYamlPairs, - construct: constructYamlPairs -}); -var _hasOwnProperty$2 = Object.prototype.hasOwnProperty; -function resolveYamlSet(data) { - if (data === null) return true; - var key, object = data; - for (key in object) { - if (_hasOwnProperty$2.call(object, key)) { - if (object[key] !== null) return false; - } - } - return true; -} -function constructYamlSet(data) { - return data !== null ? data : {}; -} -var set = new type("tag:yaml.org,2002:set", { - kind: "mapping", - resolve: resolveYamlSet, - construct: constructYamlSet -}); -var _default = core.extend({ - implicit: [ - timestamp, - merge - ], - explicit: [ - binary, - omap, - pairs, - set - ] -}); -var _hasOwnProperty$1 = Object.prototype.hasOwnProperty; -var CONTEXT_FLOW_IN = 1; -var CONTEXT_FLOW_OUT = 2; -var CONTEXT_BLOCK_IN = 3; -var CONTEXT_BLOCK_OUT = 4; -var CHOMPING_CLIP = 1; -var CHOMPING_STRIP = 2; -var CHOMPING_KEEP = 3; -var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; -var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; -var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; -var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; -var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; -function _class(obj) { - return Object.prototype.toString.call(obj); -} -function is_EOL(c2) { - return c2 === 10 || c2 === 13; -} -function is_WHITE_SPACE(c2) { - return c2 === 9 || c2 === 32; -} -function is_WS_OR_EOL(c2) { - return c2 === 9 || c2 === 32 || c2 === 10 || c2 === 13; -} -function is_FLOW_INDICATOR(c2) { - return c2 === 44 || c2 === 91 || c2 === 93 || c2 === 123 || c2 === 125; -} -function fromHexCode(c2) { - var lc; - if (48 <= c2 && c2 <= 57) { - return c2 - 48; - } - lc = c2 | 32; - if (97 <= lc && lc <= 102) { - return lc - 97 + 10; - } - return -1; -} -function escapedHexLen(c2) { - if (c2 === 120) { - return 2; - } - if (c2 === 117) { - return 4; - } - if (c2 === 85) { - return 8; - } - return 0; -} -function fromDecimalCode(c2) { - if (48 <= c2 && c2 <= 57) { - return c2 - 48; - } - return -1; -} -function simpleEscapeSequence(c2) { - return c2 === 48 ? "\0" : c2 === 97 ? "\x07" : c2 === 98 ? "\b" : c2 === 116 ? " " : c2 === 9 ? " " : c2 === 110 ? "\n" : c2 === 118 ? "\v" : c2 === 102 ? "\f" : c2 === 114 ? "\r" : c2 === 101 ? "\x1B" : c2 === 32 ? " " : c2 === 34 ? '"' : c2 === 47 ? "/" : c2 === 92 ? "\\" : c2 === 78 ? "\x85" : c2 === 95 ? "\xA0" : c2 === 76 ? "\u2028" : c2 === 80 ? "\u2029" : ""; -} -function charFromCodepoint(c2) { - if (c2 <= 65535) { - return String.fromCharCode(c2); - } - return String.fromCharCode( - (c2 - 65536 >> 10) + 55296, - (c2 - 65536 & 1023) + 56320 - ); -} -function setProperty(object, key, value) { - if (key === "__proto__") { - Object.defineProperty(object, key, { - configurable: true, - enumerable: true, - writable: true, - value - }); - } else { - object[key] = value; - } -} -var simpleEscapeCheck = new Array(256); -var simpleEscapeMap = new Array(256); -for (i2 = 0; i2 < 256; i2++) { - simpleEscapeCheck[i2] = simpleEscapeSequence(i2) ? 1 : 0; - simpleEscapeMap[i2] = simpleEscapeSequence(i2); -} -var i2; -function State$1(input, options) { - this.input = input; - this.filename = options["filename"] || null; - this.schema = options["schema"] || _default; - this.onWarning = options["onWarning"] || null; - this.legacy = options["legacy"] || false; - this.json = options["json"] || false; - this.listener = options["listener"] || null; - this.implicitTypes = this.schema.compiledImplicit; - this.typeMap = this.schema.compiledTypeMap; - this.length = input.length; - this.position = 0; - this.line = 0; - this.lineStart = 0; - this.lineIndent = 0; - this.firstTabInLine = -1; - this.documents = []; -} -function generateError(state, message) { - var mark = { - name: state.filename, - buffer: state.input.slice(0, -1), - // omit trailing \0 - position: state.position, - line: state.line, - column: state.position - state.lineStart - }; - mark.snippet = snippet(mark); - return new exception(message, mark); -} -function throwError(state, message) { - throw generateError(state, message); -} -function throwWarning(state, message) { - if (state.onWarning) { - state.onWarning.call(null, generateError(state, message)); - } -} -var directiveHandlers = { - YAML: function handleYamlDirective(state, name, args) { - var match, major, minor; - if (state.version !== null) { - throwError(state, "duplication of %YAML directive"); - } - if (args.length !== 1) { - throwError(state, "YAML directive accepts exactly one argument"); - } - match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); - if (match === null) { - throwError(state, "ill-formed argument of the YAML directive"); - } - major = parseInt(match[1], 10); - minor = parseInt(match[2], 10); - if (major !== 1) { - throwError(state, "unacceptable YAML version of the document"); - } - state.version = args[0]; - state.checkLineBreaks = minor < 2; - if (minor !== 1 && minor !== 2) { - throwWarning(state, "unsupported YAML version of the document"); - } - }, - TAG: function handleTagDirective(state, name, args) { - var handle, prefix; - if (args.length !== 2) { - throwError(state, "TAG directive accepts exactly two arguments"); - } - handle = args[0]; - prefix = args[1]; - if (!PATTERN_TAG_HANDLE.test(handle)) { - throwError(state, "ill-formed tag handle (first argument) of the TAG directive"); - } - if (_hasOwnProperty$1.call(state.tagMap, handle)) { - throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); - } - if (!PATTERN_TAG_URI.test(prefix)) { - throwError(state, "ill-formed tag prefix (second argument) of the TAG directive"); - } - try { - prefix = decodeURIComponent(prefix); - } catch (err) { - throwError(state, "tag prefix is malformed: " + prefix); - } - state.tagMap[handle] = prefix; - } -}; -function captureSegment(state, start, end, checkJson) { - var _position, _length, _character, _result; - if (start < end) { - _result = state.input.slice(start, end); - if (checkJson) { - for (_position = 0, _length = _result.length; _position < _length; _position += 1) { - _character = _result.charCodeAt(_position); - if (!(_character === 9 || 32 <= _character && _character <= 1114111)) { - throwError(state, "expected valid JSON character"); - } - } - } else if (PATTERN_NON_PRINTABLE.test(_result)) { - throwError(state, "the stream contains non-printable characters"); - } - state.result += _result; - } -} -function mergeMappings(state, destination, source, overridableKeys) { - var sourceKeys, key, index, quantity; - if (!common.isObject(source)) { - throwError(state, "cannot merge mappings; the provided source object is unacceptable"); - } - sourceKeys = Object.keys(source); - for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { - key = sourceKeys[index]; - if (!_hasOwnProperty$1.call(destination, key)) { - setProperty(destination, key, source[key]); - overridableKeys[key] = true; - } - } -} -function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) { - var index, quantity; - if (Array.isArray(keyNode)) { - keyNode = Array.prototype.slice.call(keyNode); - for (index = 0, quantity = keyNode.length; index < quantity; index += 1) { - if (Array.isArray(keyNode[index])) { - throwError(state, "nested arrays are not supported inside keys"); - } - if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") { - keyNode[index] = "[object Object]"; - } - } - } - if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") { - keyNode = "[object Object]"; - } - keyNode = String(keyNode); - if (_result === null) { - _result = {}; - } - if (keyTag === "tag:yaml.org,2002:merge") { - if (Array.isArray(valueNode)) { - for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { - mergeMappings(state, _result, valueNode[index], overridableKeys); - } - } else { - mergeMappings(state, _result, valueNode, overridableKeys); - } - } else { - if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) { - state.line = startLine || state.line; - state.lineStart = startLineStart || state.lineStart; - state.position = startPos || state.position; - throwError(state, "duplicated mapping key"); - } - setProperty(_result, keyNode, valueNode); - delete overridableKeys[keyNode]; - } - return _result; -} -function readLineBreak(state) { - var ch; - ch = state.input.charCodeAt(state.position); - if (ch === 10) { - state.position++; - } else if (ch === 13) { - state.position++; - if (state.input.charCodeAt(state.position) === 10) { - state.position++; - } - } else { - throwError(state, "a line break is expected"); - } - state.line += 1; - state.lineStart = state.position; - state.firstTabInLine = -1; -} -function skipSeparationSpace(state, allowComments, checkIndent) { - var lineBreaks = 0, ch = state.input.charCodeAt(state.position); - while (ch !== 0) { - while (is_WHITE_SPACE(ch)) { - if (ch === 9 && state.firstTabInLine === -1) { - state.firstTabInLine = state.position; - } - ch = state.input.charCodeAt(++state.position); - } - if (allowComments && ch === 35) { - do { - ch = state.input.charCodeAt(++state.position); - } while (ch !== 10 && ch !== 13 && ch !== 0); - } - if (is_EOL(ch)) { - readLineBreak(state); - ch = state.input.charCodeAt(state.position); - lineBreaks++; - state.lineIndent = 0; - while (ch === 32) { - state.lineIndent++; - ch = state.input.charCodeAt(++state.position); - } - } else { - break; - } - } - if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { - throwWarning(state, "deficient indentation"); - } - return lineBreaks; -} -function testDocumentSeparator(state) { - var _position = state.position, ch; - ch = state.input.charCodeAt(_position); - if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) { - _position += 3; - ch = state.input.charCodeAt(_position); - if (ch === 0 || is_WS_OR_EOL(ch)) { - return true; - } - } - return false; -} -function writeFoldedLines(state, count) { - if (count === 1) { - state.result += " "; - } else if (count > 1) { - state.result += common.repeat("\n", count - 1); - } -} -function readPlainScalar(state, nodeIndent, withinFlowCollection) { - var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch; - ch = state.input.charCodeAt(state.position); - if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) { - return false; - } - if (ch === 63 || ch === 45) { - following = state.input.charCodeAt(state.position + 1); - if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) { - return false; - } - } - state.kind = "scalar"; - state.result = ""; - captureStart = captureEnd = state.position; - hasPendingContent = false; - while (ch !== 0) { - if (ch === 58) { - following = state.input.charCodeAt(state.position + 1); - if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) { - break; - } - } else if (ch === 35) { - preceding = state.input.charCodeAt(state.position - 1); - if (is_WS_OR_EOL(preceding)) { - break; - } - } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) { - break; - } else if (is_EOL(ch)) { - _line = state.line; - _lineStart = state.lineStart; - _lineIndent = state.lineIndent; - skipSeparationSpace(state, false, -1); - if (state.lineIndent >= nodeIndent) { - hasPendingContent = true; - ch = state.input.charCodeAt(state.position); - continue; - } else { - state.position = captureEnd; - state.line = _line; - state.lineStart = _lineStart; - state.lineIndent = _lineIndent; - break; - } - } - if (hasPendingContent) { - captureSegment(state, captureStart, captureEnd, false); - writeFoldedLines(state, state.line - _line); - captureStart = captureEnd = state.position; - hasPendingContent = false; - } - if (!is_WHITE_SPACE(ch)) { - captureEnd = state.position + 1; - } - ch = state.input.charCodeAt(++state.position); - } - captureSegment(state, captureStart, captureEnd, false); - if (state.result) { - return true; - } - state.kind = _kind; - state.result = _result; - return false; -} -function readSingleQuotedScalar(state, nodeIndent) { - var ch, captureStart, captureEnd; - ch = state.input.charCodeAt(state.position); - if (ch !== 39) { - return false; - } - state.kind = "scalar"; - state.result = ""; - state.position++; - captureStart = captureEnd = state.position; - while ((ch = state.input.charCodeAt(state.position)) !== 0) { - if (ch === 39) { - captureSegment(state, captureStart, state.position, true); - ch = state.input.charCodeAt(++state.position); - if (ch === 39) { - captureStart = state.position; - state.position++; - captureEnd = state.position; - } else { - return true; - } - } else if (is_EOL(ch)) { - captureSegment(state, captureStart, captureEnd, true); - writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); - captureStart = captureEnd = state.position; - } else if (state.position === state.lineStart && testDocumentSeparator(state)) { - throwError(state, "unexpected end of the document within a single quoted scalar"); - } else { - state.position++; - captureEnd = state.position; - } - } - throwError(state, "unexpected end of the stream within a single quoted scalar"); -} -function readDoubleQuotedScalar(state, nodeIndent) { - var captureStart, captureEnd, hexLength, hexResult, tmp, ch; - ch = state.input.charCodeAt(state.position); - if (ch !== 34) { - return false; - } - state.kind = "scalar"; - state.result = ""; - state.position++; - captureStart = captureEnd = state.position; - while ((ch = state.input.charCodeAt(state.position)) !== 0) { - if (ch === 34) { - captureSegment(state, captureStart, state.position, true); - state.position++; - return true; - } else if (ch === 92) { - captureSegment(state, captureStart, state.position, true); - ch = state.input.charCodeAt(++state.position); - if (is_EOL(ch)) { - skipSeparationSpace(state, false, nodeIndent); - } else if (ch < 256 && simpleEscapeCheck[ch]) { - state.result += simpleEscapeMap[ch]; - state.position++; - } else if ((tmp = escapedHexLen(ch)) > 0) { - hexLength = tmp; - hexResult = 0; - for (; hexLength > 0; hexLength--) { - ch = state.input.charCodeAt(++state.position); - if ((tmp = fromHexCode(ch)) >= 0) { - hexResult = (hexResult << 4) + tmp; - } else { - throwError(state, "expected hexadecimal character"); + function tomlType(value) { + const type = typeof value; + if (type === "object") { + if (value === null) return "null"; + if (value instanceof Date) return "datetime"; + if (_type in value) { + switch (value[_type]) { + case INLINE_TABLE: + return "inline-table"; + case INLINE_LIST: + return "inline-list"; + /* istanbul ignore next */ + case TABLE: + return "table"; + /* istanbul ignore next */ + case LIST: + return "list"; + case FLOAT: + return "float"; + case INTEGER: + return "integer"; } } - state.result += charFromCodepoint(hexResult); - state.position++; - } else { - throwError(state, "unknown escape sequence"); - } - captureStart = captureEnd = state.position; - } else if (is_EOL(ch)) { - captureSegment(state, captureStart, captureEnd, true); - writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); - captureStart = captureEnd = state.position; - } else if (state.position === state.lineStart && testDocumentSeparator(state)) { - throwError(state, "unexpected end of the document within a double quoted scalar"); - } else { - state.position++; - captureEnd = state.position; - } - } - throwError(state, "unexpected end of the stream within a double quoted scalar"); -} -function readFlowCollection(state, nodeIndent) { - var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = /* @__PURE__ */ Object.create(null), keyNode, keyTag, valueNode, ch; - ch = state.input.charCodeAt(state.position); - if (ch === 91) { - terminator = 93; - isMapping = false; - _result = []; - } else if (ch === 123) { - terminator = 125; - isMapping = true; - _result = {}; - } else { - return false; - } - if (state.anchor !== null) { - state.anchorMap[state.anchor] = _result; - } - ch = state.input.charCodeAt(++state.position); - while (ch !== 0) { - skipSeparationSpace(state, true, nodeIndent); - ch = state.input.charCodeAt(state.position); - if (ch === terminator) { - state.position++; - state.tag = _tag; - state.anchor = _anchor; - state.kind = isMapping ? "mapping" : "sequence"; - state.result = _result; - return true; - } else if (!readNext) { - throwError(state, "missed comma between flow collection entries"); - } else if (ch === 44) { - throwError(state, "expected the node content, but found ','"); - } - keyTag = keyNode = valueNode = null; - isPair = isExplicitPair = false; - if (ch === 63) { - following = state.input.charCodeAt(state.position + 1); - if (is_WS_OR_EOL(following)) { - isPair = isExplicitPair = true; - state.position++; - skipSeparationSpace(state, true, nodeIndent); - } - } - _line = state.line; - _lineStart = state.lineStart; - _pos = state.position; - composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); - keyTag = state.tag; - keyNode = state.result; - skipSeparationSpace(state, true, nodeIndent); - ch = state.input.charCodeAt(state.position); - if ((isExplicitPair || state.line === _line) && ch === 58) { - isPair = true; - ch = state.input.charCodeAt(++state.position); - skipSeparationSpace(state, true, nodeIndent); - composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); - valueNode = state.result; - } - if (isMapping) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos); - } else if (isPair) { - _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos)); - } else { - _result.push(keyNode); - } - skipSeparationSpace(state, true, nodeIndent); - ch = state.input.charCodeAt(state.position); - if (ch === 44) { - readNext = true; - ch = state.input.charCodeAt(++state.position); - } else { - readNext = false; - } - } - throwError(state, "unexpected end of the stream within a flow collection"); -} -function readBlockScalar(state, nodeIndent) { - var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch; - ch = state.input.charCodeAt(state.position); - if (ch === 124) { - folding = false; - } else if (ch === 62) { - folding = true; - } else { - return false; - } - state.kind = "scalar"; - state.result = ""; - while (ch !== 0) { - ch = state.input.charCodeAt(++state.position); - if (ch === 43 || ch === 45) { - if (CHOMPING_CLIP === chomping) { - chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP; - } else { - throwError(state, "repeat of a chomping mode identifier"); - } - } else if ((tmp = fromDecimalCode(ch)) >= 0) { - if (tmp === 0) { - throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one"); - } else if (!detectedIndent) { - textIndent = nodeIndent + tmp - 1; - detectedIndent = true; - } else { - throwError(state, "repeat of an indentation width identifier"); } - } else { - break; + return type; } - } - if (is_WHITE_SPACE(ch)) { - do { - ch = state.input.charCodeAt(++state.position); - } while (is_WHITE_SPACE(ch)); - if (ch === 35) { - do { - ch = state.input.charCodeAt(++state.position); - } while (!is_EOL(ch) && ch !== 0); - } - } - while (ch !== 0) { - readLineBreak(state); - state.lineIndent = 0; - ch = state.input.charCodeAt(state.position); - while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) { - state.lineIndent++; - ch = state.input.charCodeAt(++state.position); - } - if (!detectedIndent && state.lineIndent > textIndent) { - textIndent = state.lineIndent; - } - if (is_EOL(ch)) { - emptyLines++; - continue; - } - if (state.lineIndent < textIndent) { - if (chomping === CHOMPING_KEEP) { - state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines); - } else if (chomping === CHOMPING_CLIP) { - if (didReadContent) { - state.result += "\n"; - } - } - break; - } - if (folding) { - if (is_WHITE_SPACE(ch)) { - atMoreIndented = true; - state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines); - } else if (atMoreIndented) { - atMoreIndented = false; - state.result += common.repeat("\n", emptyLines + 1); - } else if (emptyLines === 0) { - if (didReadContent) { - state.result += " "; + function makeParserClass(Parser) { + class TOMLParser extends Parser { + constructor() { + super(); + this.ctx = this.obj = Table(); } - } else { - state.result += common.repeat("\n", emptyLines); - } - } else { - state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines); - } - didReadContent = true; - detectedIndent = true; - emptyLines = 0; - captureStart = state.position; - while (!is_EOL(ch) && ch !== 0) { - ch = state.input.charCodeAt(++state.position); - } - captureSegment(state, captureStart, state.position, false); - } - return true; -} -function readBlockSequence(state, nodeIndent) { - var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch; - if (state.firstTabInLine !== -1) return false; - if (state.anchor !== null) { - state.anchorMap[state.anchor] = _result; - } - ch = state.input.charCodeAt(state.position); - while (ch !== 0) { - if (state.firstTabInLine !== -1) { - state.position = state.firstTabInLine; - throwError(state, "tab characters must not be used in indentation"); - } - if (ch !== 45) { - break; - } - following = state.input.charCodeAt(state.position + 1); - if (!is_WS_OR_EOL(following)) { - break; - } - detected = true; - state.position++; - if (skipSeparationSpace(state, true, -1)) { - if (state.lineIndent <= nodeIndent) { - _result.push(null); - ch = state.input.charCodeAt(state.position); - continue; - } - } - _line = state.line; - composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); - _result.push(state.result); - skipSeparationSpace(state, true, -1); - ch = state.input.charCodeAt(state.position); - if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) { - throwError(state, "bad indentation of a sequence entry"); - } else if (state.lineIndent < nodeIndent) { - break; - } - } - if (detected) { - state.tag = _tag; - state.anchor = _anchor; - state.kind = "sequence"; - state.result = _result; - return true; - } - return false; -} -function readBlockMapping(state, nodeIndent, flowIndent) { - var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = /* @__PURE__ */ Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch; - if (state.firstTabInLine !== -1) return false; - if (state.anchor !== null) { - state.anchorMap[state.anchor] = _result; - } - ch = state.input.charCodeAt(state.position); - while (ch !== 0) { - if (!atExplicitKey && state.firstTabInLine !== -1) { - state.position = state.firstTabInLine; - throwError(state, "tab characters must not be used in indentation"); - } - following = state.input.charCodeAt(state.position + 1); - _line = state.line; - if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) { - if (ch === 63) { - if (atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); - keyTag = keyNode = valueNode = null; - } - detected = true; - atExplicitKey = true; - allowCompact = true; - } else if (atExplicitKey) { - atExplicitKey = false; - allowCompact = true; - } else { - throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"); - } - state.position += 1; - ch = following; - } else { - _keyLine = state.line; - _keyLineStart = state.lineStart; - _keyPos = state.position; - if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { - break; - } - if (state.line === _line) { - ch = state.input.charCodeAt(state.position); - while (is_WHITE_SPACE(ch)) { - ch = state.input.charCodeAt(++state.position); - } - if (ch === 58) { - ch = state.input.charCodeAt(++state.position); - if (!is_WS_OR_EOL(ch)) { - throwError(state, "a whitespace character is expected after the key-value separator within a block mapping"); - } - if (atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); - keyTag = keyNode = valueNode = null; - } - detected = true; - atExplicitKey = false; - allowCompact = false; - keyTag = state.tag; - keyNode = state.result; - } else if (detected) { - throwError(state, "can not read an implicit mapping pair; a colon is missed"); - } else { - state.tag = _tag; - state.anchor = _anchor; - return true; + /* MATCH HELPER */ + atEndOfWord() { + return this.char === CHAR_NUM || this.char === CTRL_I || this.char === CHAR_SP || this.atEndOfLine(); } - } else if (detected) { - throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key"); - } else { - state.tag = _tag; - state.anchor = _anchor; - return true; - } - } - if (state.line === _line || state.lineIndent > nodeIndent) { - if (atExplicitKey) { - _keyLine = state.line; - _keyLineStart = state.lineStart; - _keyPos = state.position; - } - if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { - if (atExplicitKey) { - keyNode = state.result; - } else { - valueNode = state.result; + atEndOfLine() { + return this.char === Parser.END || this.char === CTRL_J || this.char === CTRL_M; } - } - if (!atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos); - keyTag = keyNode = valueNode = null; - } - skipSeparationSpace(state, true, -1); - ch = state.input.charCodeAt(state.position); - } - if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) { - throwError(state, "bad indentation of a mapping entry"); - } else if (state.lineIndent < nodeIndent) { - break; - } - } - if (atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); - } - if (detected) { - state.tag = _tag; - state.anchor = _anchor; - state.kind = "mapping"; - state.result = _result; - } - return detected; -} -function readTagProperty(state) { - var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch; - ch = state.input.charCodeAt(state.position); - if (ch !== 33) return false; - if (state.tag !== null) { - throwError(state, "duplication of a tag property"); - } - ch = state.input.charCodeAt(++state.position); - if (ch === 60) { - isVerbatim = true; - ch = state.input.charCodeAt(++state.position); - } else if (ch === 33) { - isNamed = true; - tagHandle = "!!"; - ch = state.input.charCodeAt(++state.position); - } else { - tagHandle = "!"; - } - _position = state.position; - if (isVerbatim) { - do { - ch = state.input.charCodeAt(++state.position); - } while (ch !== 0 && ch !== 62); - if (state.position < state.length) { - tagName = state.input.slice(_position, state.position); - ch = state.input.charCodeAt(++state.position); - } else { - throwError(state, "unexpected end of the stream within a verbatim tag"); - } - } else { - while (ch !== 0 && !is_WS_OR_EOL(ch)) { - if (ch === 33) { - if (!isNamed) { - tagHandle = state.input.slice(_position - 1, state.position + 1); - if (!PATTERN_TAG_HANDLE.test(tagHandle)) { - throwError(state, "named tag handle cannot contain such characters"); - } - isNamed = true; - _position = state.position + 1; - } else { - throwError(state, "tag suffix cannot contain exclamation marks"); + parseStart() { + if (this.char === Parser.END) { + return null; + } else if (this.char === CHAR_LSQB) { + return this.call(this.parseTableOrList); + } else if (this.char === CHAR_NUM) { + return this.call(this.parseComment); + } else if (this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) { + return null; + } else if (isAlphaNumQuoteHyphen(this.char)) { + return this.callNow(this.parseAssignStatement); + } else { + throw this.error(new TomlError(`Unknown character "${this.char}"`)); + } } - } - ch = state.input.charCodeAt(++state.position); - } - tagName = state.input.slice(_position, state.position); - if (PATTERN_FLOW_INDICATORS.test(tagName)) { - throwError(state, "tag suffix cannot contain flow indicator characters"); - } - } - if (tagName && !PATTERN_TAG_URI.test(tagName)) { - throwError(state, "tag name cannot contain such characters: " + tagName); - } - try { - tagName = decodeURIComponent(tagName); - } catch (err) { - throwError(state, "tag name is malformed: " + tagName); - } - if (isVerbatim) { - state.tag = tagName; - } else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) { - state.tag = state.tagMap[tagHandle] + tagName; - } else if (tagHandle === "!") { - state.tag = "!" + tagName; - } else if (tagHandle === "!!") { - state.tag = "tag:yaml.org,2002:" + tagName; - } else { - throwError(state, 'undeclared tag handle "' + tagHandle + '"'); - } - return true; -} -function readAnchorProperty(state) { - var _position, ch; - ch = state.input.charCodeAt(state.position); - if (ch !== 38) return false; - if (state.anchor !== null) { - throwError(state, "duplication of an anchor property"); - } - ch = state.input.charCodeAt(++state.position); - _position = state.position; - while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { - ch = state.input.charCodeAt(++state.position); - } - if (state.position === _position) { - throwError(state, "name of an anchor node must contain at least one character"); - } - state.anchor = state.input.slice(_position, state.position); - return true; -} -function readAlias(state) { - var _position, alias, ch; - ch = state.input.charCodeAt(state.position); - if (ch !== 42) return false; - ch = state.input.charCodeAt(++state.position); - _position = state.position; - while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { - ch = state.input.charCodeAt(++state.position); - } - if (state.position === _position) { - throwError(state, "name of an alias node must contain at least one character"); - } - alias = state.input.slice(_position, state.position); - if (!_hasOwnProperty$1.call(state.anchorMap, alias)) { - throwError(state, 'unidentified alias "' + alias + '"'); - } - state.result = state.anchorMap[alias]; - skipSeparationSpace(state, true, -1); - return true; -} -function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) { - var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent; - if (state.listener !== null) { - state.listener("open", state); - } - state.tag = null; - state.anchor = null; - state.kind = null; - state.result = null; - allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext; - if (allowToSeek) { - if (skipSeparationSpace(state, true, -1)) { - atNewLine = true; - if (state.lineIndent > parentIndent) { - indentStatus = 1; - } else if (state.lineIndent === parentIndent) { - indentStatus = 0; - } else if (state.lineIndent < parentIndent) { - indentStatus = -1; - } - } - } - if (indentStatus === 1) { - while (readTagProperty(state) || readAnchorProperty(state)) { - if (skipSeparationSpace(state, true, -1)) { - atNewLine = true; - allowBlockCollections = allowBlockStyles; - if (state.lineIndent > parentIndent) { - indentStatus = 1; - } else if (state.lineIndent === parentIndent) { - indentStatus = 0; - } else if (state.lineIndent < parentIndent) { - indentStatus = -1; + // HELPER, this strips any whitespace and comments to the end of the line + // then RETURNS. Last state in a production. + parseWhitespaceToEOL() { + if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) { + return null; + } else if (this.char === CHAR_NUM) { + return this.goto(this.parseComment); + } else if (this.char === Parser.END || this.char === CTRL_J) { + return this.return(); + } else { + throw this.error(new TomlError("Unexpected character, expected only whitespace or comments till end of line")); + } } - } else { - allowBlockCollections = false; - } - } - } - if (allowBlockCollections) { - allowBlockCollections = atNewLine || allowCompact; - } - if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { - if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { - flowIndent = parentIndent; - } else { - flowIndent = parentIndent + 1; - } - blockIndent = state.position - state.lineStart; - if (indentStatus === 1) { - if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) { - hasContent = true; - } else { - if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) { - hasContent = true; - } else if (readAlias(state)) { - hasContent = true; - if (state.tag !== null || state.anchor !== null) { - throwError(state, "alias node should not have any properties"); + /* ASSIGNMENT: key = value */ + parseAssignStatement() { + return this.callNow(this.parseAssign, this.recordAssignStatement); + } + recordAssignStatement(kv) { + let target = this.ctx; + let finalKey = kv.key.pop(); + for (let kw of kv.key) { + if (hasKey(target, kw) && (!isTable(target[kw]) || target[kw][_declared])) { + throw this.error(new TomlError("Can't redefine existing key")); + } + target = target[kw] = target[kw] || Table(); } - } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { - hasContent = true; - if (state.tag === null) { - state.tag = "?"; + if (hasKey(target, finalKey)) { + throw this.error(new TomlError("Can't redefine existing key")); + } + if (isInteger(kv.value) || isFloat(kv.value)) { + target[finalKey] = kv.value.valueOf(); + } else { + target[finalKey] = kv.value; } + return this.goto(this.parseWhitespaceToEOL); } - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; + /* ASSSIGNMENT expression, key = value possibly inside an inline table */ + parseAssign() { + return this.callNow(this.parseKeyword, this.recordAssignKeyword); } - } - } else if (indentStatus === 0) { - hasContent = allowBlockCollections && readBlockSequence(state, blockIndent); - } - } - if (state.tag === null) { - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; - } - } else if (state.tag === "?") { - if (state.result !== null && state.kind !== "scalar") { - throwError(state, 'unacceptable node kind for ! tag; it should be "scalar", not "' + state.kind + '"'); - } - for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { - type2 = state.implicitTypes[typeIndex]; - if (type2.resolve(state.result)) { - state.result = type2.construct(state.result); - state.tag = type2.tag; - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; - } - break; - } - } - } else if (state.tag !== "!") { - if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) { - type2 = state.typeMap[state.kind || "fallback"][state.tag]; - } else { - type2 = null; - typeList = state.typeMap.multi[state.kind || "fallback"]; - for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) { - if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) { - type2 = typeList[typeIndex]; - break; + recordAssignKeyword(key) { + if (this.state.resultTable) { + this.state.resultTable.push(key); + } else { + this.state.resultTable = [key]; + } + return this.goto(this.parseAssignKeywordPreDot); } - } - } - if (!type2) { - throwError(state, "unknown tag !<" + state.tag + ">"); - } - if (state.result !== null && type2.kind !== state.kind) { - throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"'); - } - if (!type2.resolve(state.result, state.tag)) { - throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag"); - } else { - state.result = type2.construct(state.result, state.tag); - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; - } - } - } - if (state.listener !== null) { - state.listener("close", state); - } - return state.tag !== null || state.anchor !== null || hasContent; -} -function readDocument(state) { - var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch; - state.version = null; - state.checkLineBreaks = state.legacy; - state.tagMap = /* @__PURE__ */ Object.create(null); - state.anchorMap = /* @__PURE__ */ Object.create(null); - while ((ch = state.input.charCodeAt(state.position)) !== 0) { - skipSeparationSpace(state, true, -1); - ch = state.input.charCodeAt(state.position); - if (state.lineIndent > 0 || ch !== 37) { - break; - } - hasDirectives = true; - ch = state.input.charCodeAt(++state.position); - _position = state.position; - while (ch !== 0 && !is_WS_OR_EOL(ch)) { - ch = state.input.charCodeAt(++state.position); - } - directiveName = state.input.slice(_position, state.position); - directiveArgs = []; - if (directiveName.length < 1) { - throwError(state, "directive name must not be less than one character in length"); - } - while (ch !== 0) { - while (is_WHITE_SPACE(ch)) { - ch = state.input.charCodeAt(++state.position); - } - if (ch === 35) { - do { - ch = state.input.charCodeAt(++state.position); - } while (ch !== 0 && !is_EOL(ch)); - break; - } - if (is_EOL(ch)) break; - _position = state.position; - while (ch !== 0 && !is_WS_OR_EOL(ch)) { - ch = state.input.charCodeAt(++state.position); - } - directiveArgs.push(state.input.slice(_position, state.position)); - } - if (ch !== 0) readLineBreak(state); - if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) { - directiveHandlers[directiveName](state, directiveName, directiveArgs); - } else { - throwWarning(state, 'unknown document directive "' + directiveName + '"'); - } - } - skipSeparationSpace(state, true, -1); - if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) { - state.position += 3; - skipSeparationSpace(state, true, -1); - } else if (hasDirectives) { - throwError(state, "directives end mark is expected"); - } - composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); - skipSeparationSpace(state, true, -1); - if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) { - throwWarning(state, "non-ASCII line breaks are interpreted as content"); - } - state.documents.push(state.result); - if (state.position === state.lineStart && testDocumentSeparator(state)) { - if (state.input.charCodeAt(state.position) === 46) { - state.position += 3; - skipSeparationSpace(state, true, -1); - } - return; - } - if (state.position < state.length - 1) { - throwError(state, "end of the stream or a document separator is expected"); - } else { - return; - } -} -function loadDocuments(input, options) { - input = String(input); - options = options || {}; - if (input.length !== 0) { - if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) { - input += "\n"; - } - if (input.charCodeAt(0) === 65279) { - input = input.slice(1); - } - } - var state = new State$1(input, options); - var nullpos = input.indexOf("\0"); - if (nullpos !== -1) { - state.position = nullpos; - throwError(state, "null byte is not allowed in input"); - } - state.input += "\0"; - while (state.input.charCodeAt(state.position) === 32) { - state.lineIndent += 1; - state.position += 1; - } - while (state.position < state.length - 1) { - readDocument(state); - } - return state.documents; -} -function loadAll$1(input, iterator, options) { - if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") { - options = iterator; - iterator = null; - } - var documents = loadDocuments(input, options); - if (typeof iterator !== "function") { - return documents; - } - for (var index = 0, length = documents.length; index < length; index += 1) { - iterator(documents[index]); - } -} -function load$1(input, options) { - var documents = loadDocuments(input, options); - if (documents.length === 0) { - return void 0; - } else if (documents.length === 1) { - return documents[0]; - } - throw new exception("expected a single document in the stream, but found more"); -} -var loadAll_1 = loadAll$1; -var load_1 = load$1; -var loader = { - loadAll: loadAll_1, - load: load_1 -}; -var _toString = Object.prototype.toString; -var _hasOwnProperty = Object.prototype.hasOwnProperty; -var CHAR_BOM = 65279; -var CHAR_TAB = 9; -var CHAR_LINE_FEED = 10; -var CHAR_CARRIAGE_RETURN = 13; -var CHAR_SPACE = 32; -var CHAR_EXCLAMATION = 33; -var CHAR_DOUBLE_QUOTE = 34; -var CHAR_SHARP = 35; -var CHAR_PERCENT = 37; -var CHAR_AMPERSAND = 38; -var CHAR_SINGLE_QUOTE = 39; -var CHAR_ASTERISK = 42; -var CHAR_COMMA2 = 44; -var CHAR_MINUS = 45; -var CHAR_COLON2 = 58; -var CHAR_EQUALS2 = 61; -var CHAR_GREATER_THAN = 62; -var CHAR_QUESTION = 63; -var CHAR_COMMERCIAL_AT = 64; -var CHAR_LEFT_SQUARE_BRACKET = 91; -var CHAR_RIGHT_SQUARE_BRACKET = 93; -var CHAR_GRAVE_ACCENT = 96; -var CHAR_LEFT_CURLY_BRACKET = 123; -var CHAR_VERTICAL_LINE = 124; -var CHAR_RIGHT_CURLY_BRACKET = 125; -var ESCAPE_SEQUENCES = {}; -ESCAPE_SEQUENCES[0] = "\\0"; -ESCAPE_SEQUENCES[7] = "\\a"; -ESCAPE_SEQUENCES[8] = "\\b"; -ESCAPE_SEQUENCES[9] = "\\t"; -ESCAPE_SEQUENCES[10] = "\\n"; -ESCAPE_SEQUENCES[11] = "\\v"; -ESCAPE_SEQUENCES[12] = "\\f"; -ESCAPE_SEQUENCES[13] = "\\r"; -ESCAPE_SEQUENCES[27] = "\\e"; -ESCAPE_SEQUENCES[34] = '\\"'; -ESCAPE_SEQUENCES[92] = "\\\\"; -ESCAPE_SEQUENCES[133] = "\\N"; -ESCAPE_SEQUENCES[160] = "\\_"; -ESCAPE_SEQUENCES[8232] = "\\L"; -ESCAPE_SEQUENCES[8233] = "\\P"; -var DEPRECATED_BOOLEANS_SYNTAX = [ - "y", - "Y", - "yes", - "Yes", - "YES", - "on", - "On", - "ON", - "n", - "N", - "no", - "No", - "NO", - "off", - "Off", - "OFF" -]; -var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/; -function compileStyleMap(schema2, map2) { - var result, keys, index, length, tag, style, type2; - if (map2 === null) return {}; - result = {}; - keys = Object.keys(map2); - for (index = 0, length = keys.length; index < length; index += 1) { - tag = keys[index]; - style = String(map2[tag]); - if (tag.slice(0, 2) === "!!") { - tag = "tag:yaml.org,2002:" + tag.slice(2); - } - type2 = schema2.compiledTypeMap["fallback"][tag]; - if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) { - style = type2.styleAliases[style]; - } - result[tag] = style; - } - return result; -} -function encodeHex(character) { - var string, handle, length; - string = character.toString(16).toUpperCase(); - if (character <= 255) { - handle = "x"; - length = 2; - } else if (character <= 65535) { - handle = "u"; - length = 4; - } else if (character <= 4294967295) { - handle = "U"; - length = 8; - } else { - throw new exception("code point within a string may not be greater than 0xFFFFFFFF"); - } - return "\\" + handle + common.repeat("0", length - string.length) + string; -} -var QUOTING_TYPE_SINGLE = 1; -var QUOTING_TYPE_DOUBLE = 2; -function State(options) { - this.schema = options["schema"] || _default; - this.indent = Math.max(1, options["indent"] || 2); - this.noArrayIndent = options["noArrayIndent"] || false; - this.skipInvalid = options["skipInvalid"] || false; - this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"]; - this.styleMap = compileStyleMap(this.schema, options["styles"] || null); - this.sortKeys = options["sortKeys"] || false; - this.lineWidth = options["lineWidth"] || 80; - this.noRefs = options["noRefs"] || false; - this.noCompatMode = options["noCompatMode"] || false; - this.condenseFlow = options["condenseFlow"] || false; - this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE; - this.forceQuotes = options["forceQuotes"] || false; - this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null; - this.implicitTypes = this.schema.compiledImplicit; - this.explicitTypes = this.schema.compiledExplicit; - this.tag = null; - this.result = ""; - this.duplicates = []; - this.usedDuplicates = null; -} -function indentString(string, spaces) { - var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length; - while (position < length) { - next = string.indexOf("\n", position); - if (next === -1) { - line = string.slice(position); - position = length; - } else { - line = string.slice(position, next + 1); - position = next + 1; - } - if (line.length && line !== "\n") result += ind; - result += line; - } - return result; -} -function generateNextLine(state, level) { - return "\n" + common.repeat(" ", state.indent * level); -} -function testImplicitResolving(state, str2) { - var index, length, type2; - for (index = 0, length = state.implicitTypes.length; index < length; index += 1) { - type2 = state.implicitTypes[index]; - if (type2.resolve(str2)) { - return true; - } - } - return false; -} -function isWhitespace(c2) { - return c2 === CHAR_SPACE || c2 === CHAR_TAB; -} -function isPrintable(c2) { - return 32 <= c2 && c2 <= 126 || 161 <= c2 && c2 <= 55295 && c2 !== 8232 && c2 !== 8233 || 57344 <= c2 && c2 <= 65533 && c2 !== CHAR_BOM || 65536 <= c2 && c2 <= 1114111; -} -function isNsCharOrWhitespace(c2) { - return isPrintable(c2) && c2 !== CHAR_BOM && c2 !== CHAR_CARRIAGE_RETURN && c2 !== CHAR_LINE_FEED; -} -function isPlainSafe(c2, prev, inblock) { - var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c2); - var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c2); - return ( - // ns-plain-safe - (inblock ? ( - // c = flow-in - cIsNsCharOrWhitespace - ) : cIsNsCharOrWhitespace && c2 !== CHAR_COMMA2 && c2 !== CHAR_LEFT_SQUARE_BRACKET && c2 !== CHAR_RIGHT_SQUARE_BRACKET && c2 !== CHAR_LEFT_CURLY_BRACKET && c2 !== CHAR_RIGHT_CURLY_BRACKET) && c2 !== CHAR_SHARP && !(prev === CHAR_COLON2 && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c2 === CHAR_SHARP || prev === CHAR_COLON2 && cIsNsChar - ); -} -function isPlainSafeFirst(c2) { - return isPrintable(c2) && c2 !== CHAR_BOM && !isWhitespace(c2) && c2 !== CHAR_MINUS && c2 !== CHAR_QUESTION && c2 !== CHAR_COLON2 && c2 !== CHAR_COMMA2 && c2 !== CHAR_LEFT_SQUARE_BRACKET && c2 !== CHAR_RIGHT_SQUARE_BRACKET && c2 !== CHAR_LEFT_CURLY_BRACKET && c2 !== CHAR_RIGHT_CURLY_BRACKET && c2 !== CHAR_SHARP && c2 !== CHAR_AMPERSAND && c2 !== CHAR_ASTERISK && c2 !== CHAR_EXCLAMATION && c2 !== CHAR_VERTICAL_LINE && c2 !== CHAR_EQUALS2 && c2 !== CHAR_GREATER_THAN && c2 !== CHAR_SINGLE_QUOTE && c2 !== CHAR_DOUBLE_QUOTE && c2 !== CHAR_PERCENT && c2 !== CHAR_COMMERCIAL_AT && c2 !== CHAR_GRAVE_ACCENT; -} -function isPlainSafeLast(c2) { - return !isWhitespace(c2) && c2 !== CHAR_COLON2; -} -function codePointAt(string, pos) { - var first = string.charCodeAt(pos), second; - if (first >= 55296 && first <= 56319 && pos + 1 < string.length) { - second = string.charCodeAt(pos + 1); - if (second >= 56320 && second <= 57343) { - return (first - 55296) * 1024 + second - 56320 + 65536; - } - } - return first; -} -function needIndentIndicator(string) { - var leadingSpaceRe = /^\n* /; - return leadingSpaceRe.test(string); -} -var STYLE_PLAIN = 1; -var STYLE_SINGLE = 2; -var STYLE_LITERAL = 3; -var STYLE_FOLDED = 4; -var STYLE_DOUBLE = 5; -function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) { - var i2; - var char = 0; - var prevChar = null; - var hasLineBreak = false; - var hasFoldableLine = false; - var shouldTrackWidth = lineWidth !== -1; - var previousLineBreak = -1; - var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1)); - if (singleLineOnly || forceQuotes) { - for (i2 = 0; i2 < string.length; char >= 65536 ? i2 += 2 : i2++) { - char = codePointAt(string, i2); - if (!isPrintable(char)) { - return STYLE_DOUBLE; - } - plain = plain && isPlainSafe(char, prevChar, inblock); - prevChar = char; - } - } else { - for (i2 = 0; i2 < string.length; char >= 65536 ? i2 += 2 : i2++) { - char = codePointAt(string, i2); - if (char === CHAR_LINE_FEED) { - hasLineBreak = true; - if (shouldTrackWidth) { - hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented. - i2 - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " "; - previousLineBreak = i2; - } - } else if (!isPrintable(char)) { - return STYLE_DOUBLE; - } - plain = plain && isPlainSafe(char, prevChar, inblock); - prevChar = char; - } - hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i2 - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " "); - } - if (!hasLineBreak && !hasFoldableLine) { - if (plain && !forceQuotes && !testAmbiguousType(string)) { - return STYLE_PLAIN; - } - return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; - } - if (indentPerLevel > 9 && needIndentIndicator(string)) { - return STYLE_DOUBLE; - } - if (!forceQuotes) { - return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL; - } - return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; -} -function writeScalar(state, string, level, iskey, inblock) { - state.dump = (function() { - if (string.length === 0) { - return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''"; - } - if (!state.noCompatMode) { - if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) { - return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'"; - } - } - var indent = state.indent * Math.max(1, level); - var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); - var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel; - function testAmbiguity(string2) { - return testImplicitResolving(state, string2); - } - switch (chooseScalarStyle( - string, - singleLineOnly, - state.indent, - lineWidth, - testAmbiguity, - state.quotingType, - state.forceQuotes && !iskey, - inblock - )) { - case STYLE_PLAIN: - return string; - case STYLE_SINGLE: - return "'" + string.replace(/'/g, "''") + "'"; - case STYLE_LITERAL: - return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent)); - case STYLE_FOLDED: - return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent)); - case STYLE_DOUBLE: - return '"' + escapeString(string) + '"'; - default: - throw new exception("impossible error: invalid scalar style"); - } - })(); -} -function blockHeader(string, indentPerLevel) { - var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : ""; - var clip = string[string.length - 1] === "\n"; - var keep = clip && (string[string.length - 2] === "\n" || string === "\n"); - var chomp = keep ? "+" : clip ? "" : "-"; - return indentIndicator + chomp + "\n"; -} -function dropEndingNewline(string) { - return string[string.length - 1] === "\n" ? string.slice(0, -1) : string; -} -function foldString(string, width) { - var lineRe = /(\n+)([^\n]*)/g; - var result = (function() { - var nextLF = string.indexOf("\n"); - nextLF = nextLF !== -1 ? nextLF : string.length; - lineRe.lastIndex = nextLF; - return foldLine(string.slice(0, nextLF), width); - })(); - var prevMoreIndented = string[0] === "\n" || string[0] === " "; - var moreIndented; - var match; - while (match = lineRe.exec(string)) { - var prefix = match[1], line = match[2]; - moreIndented = line[0] === " "; - result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width); - prevMoreIndented = moreIndented; - } - return result; -} -function foldLine(line, width) { - if (line === "" || line[0] === " ") return line; - var breakRe = / [^ ]/g; - var match; - var start = 0, end, curr = 0, next = 0; - var result = ""; - while (match = breakRe.exec(line)) { - next = match.index; - if (next - start > width) { - end = curr > start ? curr : next; - result += "\n" + line.slice(start, end); - start = end + 1; - } - curr = next; - } - result += "\n"; - if (line.length - start > width && curr > start) { - result += line.slice(start, curr) + "\n" + line.slice(curr + 1); - } else { - result += line.slice(start); - } - return result.slice(1); -} -function escapeString(string) { - var result = ""; - var char = 0; - var escapeSeq; - for (var i2 = 0; i2 < string.length; char >= 65536 ? i2 += 2 : i2++) { - char = codePointAt(string, i2); - escapeSeq = ESCAPE_SEQUENCES[char]; - if (!escapeSeq && isPrintable(char)) { - result += string[i2]; - if (char >= 65536) result += string[i2 + 1]; - } else { - result += escapeSeq || encodeHex(char); - } - } - return result; -} -function writeFlowSequence(state, level, object) { - var _result = "", _tag = state.tag, index, length, value; - for (index = 0, length = object.length; index < length; index += 1) { - value = object[index]; - if (state.replacer) { - value = state.replacer.call(object, String(index), value); - } - if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) { - if (_result !== "") _result += "," + (!state.condenseFlow ? " " : ""); - _result += state.dump; - } - } - state.tag = _tag; - state.dump = "[" + _result + "]"; -} -function writeBlockSequence(state, level, object, compact) { - var _result = "", _tag = state.tag, index, length, value; - for (index = 0, length = object.length; index < length; index += 1) { - value = object[index]; - if (state.replacer) { - value = state.replacer.call(object, String(index), value); - } - if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) { - if (!compact || _result !== "") { - _result += generateNextLine(state, level); - } - if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { - _result += "-"; - } else { - _result += "- "; - } - _result += state.dump; - } - } - state.tag = _tag; - state.dump = _result || "[]"; -} -function writeFlowMapping(state, level, object) { - var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer; - for (index = 0, length = objectKeyList.length; index < length; index += 1) { - pairBuffer = ""; - if (_result !== "") pairBuffer += ", "; - if (state.condenseFlow) pairBuffer += '"'; - objectKey = objectKeyList[index]; - objectValue = object[objectKey]; - if (state.replacer) { - objectValue = state.replacer.call(object, objectKey, objectValue); - } - if (!writeNode(state, level, objectKey, false, false)) { - continue; - } - if (state.dump.length > 1024) pairBuffer += "? "; - pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " "); - if (!writeNode(state, level, objectValue, false, false)) { - continue; - } - pairBuffer += state.dump; - _result += pairBuffer; - } - state.tag = _tag; - state.dump = "{" + _result + "}"; -} -function writeBlockMapping(state, level, object, compact) { - var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer; - if (state.sortKeys === true) { - objectKeyList.sort(); - } else if (typeof state.sortKeys === "function") { - objectKeyList.sort(state.sortKeys); - } else if (state.sortKeys) { - throw new exception("sortKeys must be a boolean or a function"); - } - for (index = 0, length = objectKeyList.length; index < length; index += 1) { - pairBuffer = ""; - if (!compact || _result !== "") { - pairBuffer += generateNextLine(state, level); - } - objectKey = objectKeyList[index]; - objectValue = object[objectKey]; - if (state.replacer) { - objectValue = state.replacer.call(object, objectKey, objectValue); - } - if (!writeNode(state, level + 1, objectKey, true, true, true)) { - continue; - } - explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024; - if (explicitPair) { - if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { - pairBuffer += "?"; - } else { - pairBuffer += "? "; - } - } - pairBuffer += state.dump; - if (explicitPair) { - pairBuffer += generateNextLine(state, level); - } - if (!writeNode(state, level + 1, objectValue, true, explicitPair)) { - continue; - } - if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { - pairBuffer += ":"; - } else { - pairBuffer += ": "; - } - pairBuffer += state.dump; - _result += pairBuffer; - } - state.tag = _tag; - state.dump = _result || "{}"; -} -function detectType(state, object, explicit) { - var _result, typeList, index, length, type2, style; - typeList = explicit ? state.explicitTypes : state.implicitTypes; - for (index = 0, length = typeList.length; index < length; index += 1) { - type2 = typeList[index]; - if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) { - if (explicit) { - if (type2.multi && type2.representName) { - state.tag = type2.representName(object); - } else { - state.tag = type2.tag; + parseAssignKeywordPreDot() { + if (this.char === CHAR_PERIOD) { + return this.next(this.parseAssignKeywordPostDot); + } else if (this.char !== CHAR_SP && this.char !== CTRL_I) { + return this.goto(this.parseAssignEqual); + } } - } else { - state.tag = "?"; - } - if (type2.represent) { - style = state.styleMap[type2.tag] || type2.defaultStyle; - if (_toString.call(type2.represent) === "[object Function]") { - _result = type2.represent(object, style); - } else if (_hasOwnProperty.call(type2.represent, style)) { - _result = type2.represent[style](object, style); - } else { - throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style'); + parseAssignKeywordPostDot() { + if (this.char !== CHAR_SP && this.char !== CTRL_I) { + return this.callNow(this.parseKeyword, this.recordAssignKeyword); + } } - state.dump = _result; - } - return true; - } - } - return false; -} -function writeNode(state, level, object, block, compact, iskey, isblockseq) { - state.tag = null; - state.dump = object; - if (!detectType(state, object, false)) { - detectType(state, object, true); - } - var type2 = _toString.call(state.dump); - var inblock = block; - var tagStr; - if (block) { - block = state.flowLevel < 0 || state.flowLevel > level; - } - var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate; - if (objectOrArray) { - duplicateIndex = state.duplicates.indexOf(object); - duplicate = duplicateIndex !== -1; - } - if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) { - compact = false; - } - if (duplicate && state.usedDuplicates[duplicateIndex]) { - state.dump = "*ref_" + duplicateIndex; - } else { - if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { - state.usedDuplicates[duplicateIndex] = true; - } - if (type2 === "[object Object]") { - if (block && Object.keys(state.dump).length !== 0) { - writeBlockMapping(state, level, state.dump, compact); - if (duplicate) { - state.dump = "&ref_" + duplicateIndex + state.dump; + parseAssignEqual() { + if (this.char === CHAR_EQUALS) { + return this.next(this.parseAssignPreValue); + } else { + throw this.error(new TomlError('Invalid character, expected "="')); + } } - } else { - writeFlowMapping(state, level, state.dump); - if (duplicate) { - state.dump = "&ref_" + duplicateIndex + " " + state.dump; + parseAssignPreValue() { + if (this.char === CHAR_SP || this.char === CTRL_I) { + return null; + } else { + return this.callNow(this.parseValue, this.recordAssignValue); + } } - } - } else if (type2 === "[object Array]") { - if (block && state.dump.length !== 0) { - if (state.noArrayIndent && !isblockseq && level > 0) { - writeBlockSequence(state, level - 1, state.dump, compact); - } else { - writeBlockSequence(state, level, state.dump, compact); + recordAssignValue(value) { + return this.returnNow({ key: this.state.resultTable, value }); } - if (duplicate) { - state.dump = "&ref_" + duplicateIndex + state.dump; + /* COMMENTS: #...eol */ + parseComment() { + do { + if (this.char === Parser.END || this.char === CTRL_J) { + return this.return(); + } + } while (this.nextChar()); } - } else { - writeFlowSequence(state, level, state.dump); - if (duplicate) { - state.dump = "&ref_" + duplicateIndex + " " + state.dump; + /* TABLES AND LISTS, [foo] and [[foo]] */ + parseTableOrList() { + if (this.char === CHAR_LSQB) { + this.next(this.parseList); + } else { + return this.goto(this.parseTable); + } } - } - } else if (type2 === "[object String]") { - if (state.tag !== "?") { - writeScalar(state, state.dump, level, iskey, inblock); - } - } else if (type2 === "[object Undefined]") { - return false; - } else { - if (state.skipInvalid) return false; - throw new exception("unacceptable kind of an object to dump " + type2); - } - if (state.tag !== null && state.tag !== "?") { - tagStr = encodeURI( - state.tag[0] === "!" ? state.tag.slice(1) : state.tag - ).replace(/!/g, "%21"); - if (state.tag[0] === "!") { - tagStr = "!" + tagStr; - } else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") { - tagStr = "!!" + tagStr.slice(18); - } else { - tagStr = "!<" + tagStr + ">"; - } - state.dump = tagStr + " " + state.dump; - } - } - return true; -} -function getDuplicateReferences(object, state) { - var objects = [], duplicatesIndexes = [], index, length; - inspectNode(object, objects, duplicatesIndexes); - for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) { - state.duplicates.push(objects[duplicatesIndexes[index]]); - } - state.usedDuplicates = new Array(length); -} -function inspectNode(object, objects, duplicatesIndexes) { - var objectKeyList, index, length; - if (object !== null && typeof object === "object") { - index = objects.indexOf(object); - if (index !== -1) { - if (duplicatesIndexes.indexOf(index) === -1) { - duplicatesIndexes.push(index); - } - } else { - objects.push(object); - if (Array.isArray(object)) { - for (index = 0, length = object.length; index < length; index += 1) { - inspectNode(object[index], objects, duplicatesIndexes); + /* TABLE [foo.bar.baz] */ + parseTable() { + this.ctx = this.obj; + return this.goto(this.parseTableNext); } - } else { - objectKeyList = Object.keys(object); - for (index = 0, length = objectKeyList.length; index < length; index += 1) { - inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes); + parseTableNext() { + if (this.char === CHAR_SP || this.char === CTRL_I) { + return null; + } else { + return this.callNow(this.parseKeyword, this.parseTableMore); + } } - } - } - } -} -function dump$1(input, options) { - options = options || {}; - var state = new State(options); - if (!state.noRefs) getDuplicateReferences(input, state); - var value = input; - if (state.replacer) { - value = state.replacer.call({ "": value }, "", value); - } - if (writeNode(state, 0, value, true, true)) return state.dump + "\n"; - return ""; -} -var dump_1 = dump$1; -var dumper = { - dump: dump_1 -}; -function renamed(from, to) { - return function() { - throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default."); - }; -} -var Type = type; -var Schema = schema; -var FAILSAFE_SCHEMA = failsafe; -var JSON_SCHEMA = json; -var CORE_SCHEMA = core; -var DEFAULT_SCHEMA = _default; -var load = loader.load; -var loadAll = loader.loadAll; -var dump = dumper.dump; -var YAMLException = exception; -var types = { - binary, - float, - map, - null: _null, - pairs, - set, - timestamp, - bool, - int, - merge, - omap, - seq, - str -}; -var safeLoad = renamed("safeLoad", "load"); -var safeLoadAll = renamed("safeLoadAll", "loadAll"); -var safeDump = renamed("safeDump", "dump"); -var jsYaml = { - Type, - Schema, - FAILSAFE_SCHEMA, - JSON_SCHEMA, - CORE_SCHEMA, - DEFAULT_SCHEMA, - load, - loadAll, - dump, - YAMLException, - types, - safeLoad, - safeLoadAll, - safeDump -}; - -// src/depbadgerc/compute-state-integrity.ts -var computeStateIntegrity = useCtxCallback((store, ...rest) => { - const payloadStringified = JSON.stringify(rest); - const hash = crypto.createHash("sha256"); - const yml = jsYaml.dump({ - ...JSON.parse(JSON.stringify(store)), - integrity: null - }); - hash.update(`${yml} --- ${payloadStringified}`, "utf8"); - return hash.digest("hex"); -}); - -// src/depbadgerc/get-dependencies.ts -init_esm_shims(); -var getDependencies = useCtxCallback( - (store) => { - const result = {}; - if (store.dependencies) result.dependencies = store.dependencies; - if (store.devDependencies) result.devDependencies = store.devDependencies; - if (store.peerDependencies) result.peerDependencies = store.peerDependencies; - return result; - } -); - -// src/depbadgerc/get-status-badges.ts -init_esm_shims(); -var getStatusBadges = useCtxCallback( - (store) => { - const result = {}; - if (store.statusBadges) result.statusBadges = store.statusBadges; - return result; - } -); - -// src/depbadgerc/hydrate-dependency-badges.ts -init_esm_shims(); -var hydrateDependencyBadges = useCtxCallback( - (_, deps, mfdm) => { - return Object.entries(deps).reduce( - (acc, [section, config]) => { - if (!config?.items?.length) return acc; - const entries = config.items.flatMap((item) => { - const message = mfdm[section]?.[item.name]; - return message === void 0 ? [] : [ - [ - item.name, - { - ...item, - message - } - ] - ]; - }); - if (!entries.length) return acc; - acc[section] = { - ...acc[section] ?? {}, - ...Object.fromEntries(entries) - }; - return acc; - }, - {} - ); - } -); - -// src/depbadgerc/hydrate-status-badges.ts -init_esm_shims(); -var hydrateStatusBadges = useCtxCallback( - (_, statusBadges) => Object.entries(statusBadges).reduce( - (acc, [section, statusBadges2]) => { - if (!statusBadges2?.items?.length) return acc; - acc[section] = [...acc[section] ?? [], ...statusBadges2.items]; - return acc; - }, - {} - ) -); - -// src/depbadgerc/map-badges-to-markdown.ts -init_esm_shims(); -var REGEX = /[^a-zA-Z0-9]/g; -var encodeMessage = (s2) => encodeURIComponent(s2.replace(/^\^/, "v")); -var encodeLabel = (s2) => encodeURIComponent(s2?.replace(REGEX, "_")); -var mapBadgesToMarkdown = useCtxCallback( - (_, hdm) => { - return Object.fromEntries( - Object.entries(hdm).map(([section, badgeMap]) => [ - section, - Object.entries(badgeMap).flatMap(([name, badge]) => { - const urlSearchParams = new URLSearchParams({ - ...badge.isError && { isError: "true" }, - ...badge.labelColor && { labelColor: badge.labelColor }, - ...badge.cacheSeconds && { - cacheSeconds: badge.cacheSeconds?.toString() - }, - ...badge.namedLogo && { logo: badge.namedLogo }, - ...badge.logoColor && { logoColor: badge.logoColor }, - ...badge.logoWidth && { logoWidth: badge.logoWidth.toString() }, - ...badge.style && { style: badge.style }, - ...badge.logoSvg && { - logo: `data:image/svg+xml;utf8,${encodeURIComponent(badge.logoSvg)}` + parseTableMore(keyword) { + if (this.char === CHAR_SP || this.char === CTRL_I) { + return null; + } else if (this.char === CHAR_RSQB) { + if (hasKey(this.ctx, keyword) && (!isTable(this.ctx[keyword]) || this.ctx[keyword][_declared])) { + throw this.error(new TomlError("Can't redefine existing key")); + } else { + this.ctx = this.ctx[keyword] = this.ctx[keyword] || Table(); + this.ctx[_declared] = true; } - }).toString(); - const dependency = encodeLabel(name); - const message = encodeMessage(badge.message); - const color = encodeURIComponent(badge.color); - const url = `https://img.shields.io/badge/${dependency}-${message}-${color}.svg?${urlSearchParams}`; - return badge.link ? `[![${name}](${url})](${badge.link})` : `![${name}](${url})`; - }) - ]) - ); - } -); - -// src/depbadgerc/map-status-badges-to-markdown.ts -init_esm_shims(); - -// src/depbadgerc/map-codecov-status-badge-to-markdown.ts -init_esm_shims(); - -// src/shared/encode-label.ts -init_esm_shims(); -var encodeLabel2 = (s2) => { - return (s2 ?? "").replace(/-/g, "--").replace(/_/g, "__").replace(/\s+/g, "_"); -}; - -// src/depbadgerc/map-codecov-status-badge-to-markdown.ts -function mapCodecovStatusBadgeToMarkdown(badge) { - const urlSearchParams = new URLSearchParams({ - ...badge?.labelColor && { labelColor: badge.labelColor }, - ...badge?.isError && { isError: "true" }, - ...badge?.cacheSeconds && { cacheSeconds: badge.cacheSeconds.toString() }, - ...badge?.namedLogo && { logo: badge.namedLogo }, - ...badge?.logoColor && { logoColor: badge.logoColor }, - ...badge?.logoWidth && { logoWidth: badge.logoWidth.toString() }, - ...badge.style && { style: badge.style }, - ...badge?.color && { color: badge.color }, - ...badge?.logoSvg && { - logo: `data:image/svg+xml;utf8,${encodeURIComponent(badge.logoSvg)}` - }, - ...badge.branch && { branch: badge.branch }, - ...badge.token && { token: badge.token } - }).toString(); - const label = badge.name; - const user = encodeLabel2(badge.user ?? "library"); - const repo = encodeLabel2(badge.repo); - const provider = encodeLabel2("github"); - const flag = encodeLabel2(badge.flag ?? "c"); - const url = `https://img.shields.io/codecov/${flag}/${provider}/${user}/${repo}?${urlSearchParams}`; - return badge?.link ? `[![${label}](${url})](${badge.link})` : `![${label}](${url})`; -} - -// src/depbadgerc/map-dockerhub-status-badge-to-markdown.ts -init_esm_shims(); -function mapDockerHubStatusBadgeToMarkdown(badge) { - const urlSearchParams = new URLSearchParams({ - ...badge?.labelColor && { labelColor: badge.labelColor }, - ...badge?.isError && { isError: "true" }, - ...badge?.namedLogo && { logo: badge.namedLogo }, - ...badge?.logoColor && { logoColor: badge.logoColor }, - ...badge?.logoWidth && { logoWidth: badge.logoWidth.toString() }, - ...badge.style && { style: badge.style }, - ...badge?.cacheSeconds && { cacheSeconds: badge.cacheSeconds.toString() }, - ...badge?.color && { color: badge.color }, - ...badge?.logoSvg && { - logo: `data:image/svg+xml;utf8,${encodeURIComponent(badge.logoSvg)}` - }, - ...badge.tag && badge.metric === "v" && { tag: badge.tag } - }).toString(); - const label = badge.name; - const src = encodeLabel2(label); - const user = encodeLabel2(badge.user ?? "library"); - const metric = encodeLabel2(badge.metric ?? "v"); - const image = encodeLabel2(badge.image); - const url = `https://img.shields.io/${src}/${metric}/${user}/${image}?${urlSearchParams}`; - return badge?.link ? `[![${label}](${url})](${badge.link})` : `![${label}](${url})`; -} - -// src/depbadgerc/map-github-status-badge-to-markdown.ts -init_esm_shims(); -function mapGithubStatusBadgeToMarkdown(badge) { - const urlSearchParams = new URLSearchParams({ - ...badge?.labelColor && { labelColor: badge.labelColor }, - ...badge.style && { style: badge.style }, - ...badge?.cacheSeconds && { cacheSeconds: badge.cacheSeconds.toString() }, - ...badge?.color && { color: badge.color }, - ...badge?.isError && { isError: "true" }, - ...badge?.namedLogo && { logo: badge.namedLogo }, - ...badge?.logoColor && { logoColor: badge.logoColor }, - ...badge?.logoWidth && { logoWidth: badge.logoWidth.toString() }, - ...badge?.logoSvg && { - logo: `data:image/svg+xml;utf8,${encodeURIComponent(badge.logoSvg)}` - }, - ...badge.branch && { branch: badge.branch } - }).toString(); - const label = badge.name; - const src = encodeLabel2(label); - const user = encodeLabel2(badge.user); - const workflow = encodeLabel2(badge.workflow); - const metric = encodeLabel2(badge.metric); - const repo = encodeLabel2(badge.repo); - const url = badge.metric === "actions" ? `https://img.shields.io/${src}/${metric}/workflow/status/${user}/${repo}/${workflow}?${urlSearchParams}` : `https://img.shields.io/${src}/${metric}/${user}/${repo}?${urlSearchParams}`; - return badge?.link ? `[![${label}](${url})](${badge.link})` : `![${label}](${url})`; -} - -// src/depbadgerc/map-socket-status-badge-to-markdown.ts -init_esm_shims(); -function mapSocketStatusBadgeToMarkdown(badge) { - const label = badge.name; - const version = badge.version ?? "*"; - const url = `https://badge.socket.dev/npm/package/${badge.package}/${version}`; - const link = badge.link ?? `https://www.npmjs.com/package/${badge.package}`; - return `[![${label}](${url})](${link})`; -} - -// src/depbadgerc/map-tile-status-badge-to-markdown.ts -init_esm_shims(); -function mapTileStatusBadgeToMarkdown(badge) { - const urlSearchParams = new URLSearchParams({ - ...badge?.labelColor && { labelColor: badge.labelColor }, - ...badge?.isError && { isError: "true" }, - ...badge?.cacheSeconds && { cacheSeconds: badge.cacheSeconds.toString() }, - ...badge?.namedLogo && { logo: badge.namedLogo }, - ...badge?.logoColor && { logoColor: badge.logoColor }, - ...badge?.logoWidth && { logoWidth: badge.logoWidth.toString() }, - ...badge.style && { style: badge.style }, - ...badge?.logoSvg && { - logo: `data:image/svg+xml;utf8,${encodeURIComponent(badge.logoSvg)}` - } - }).toString(); - const label = encodeLabel2(badge.label); - const message = encodeLabel2(badge.message); - const color = badge.color; - const url = `https://img.shields.io/badge/${label}-${message}-${color}?${urlSearchParams}`; - return badge?.link ? `[![${label}](${url})](${badge.link})` : `![${label}](${url})`; -} - -// src/depbadgerc/map-status-badges-to-markdown.ts -var mapStatusBadgesToMarkdown = useCtxCallback( - (_, statusBadges) => Object.fromEntries( - Object.entries(statusBadges).map(([section, badges]) => [ - section, - badges.map((item) => { - if (item.name === "github") return mapGithubStatusBadgeToMarkdown(item); - if (item.name === "docker") return mapDockerHubStatusBadgeToMarkdown(item); - if (item.name === "codecov") return mapCodecovStatusBadgeToMarkdown(item); - if (item.name === "tile") return mapTileStatusBadgeToMarkdown(item); - if (item.name === "socket") return mapSocketStatusBadgeToMarkdown(item); - }).filter((x2) => Boolean(x2)) - ]) - ) -); - -// src/depbadgerc/output-markdown-preview.ts -init_esm_shims(); -var outputMarkdownPreview = useCtxCallback( - (store, type2, badgeMarkdownMap, dir = ".depbadge") => { - const md = Object.entries(badgeMarkdownMap).map(([section, badges]) => { - const layout = store[section]?.layout; - const header = layout?.header ?? section; - const content = `${layout?.showHeader ? ` -# ${header}` : ""} - -${badges.join("\n")}`; - return layout?.position ? `
-${content} - -
` : content; - }).join("").trim(); - if (!md?.length) return; - fs2.mkdirSync(dir, { recursive: true }); - fs2.writeFileSync(`${dir}/${type2}.md`, md); - } -); - -// src/depbadgerc/output-shieldio-badges-json.ts -init_esm_shims(); -var outputShieldioBadgesJson = useCtxCallback((_, hbm, dir = ".depbadge") => { - Object.entries(hbm).forEach(([section, badgesMap]) => { - const sectionPath = path2.join(dir, section); - fs2.mkdirSync(sectionPath, { recursive: true }); - Object.entries(badgesMap).forEach(([name, badge]) => { - const safeName = name.replace(/^@/, "").replace(/\//g, "__"); - const filePath = path2.join(sectionPath, `${safeName}.json`); - fs2.writeFileSync(filePath, JSON.stringify(badge, null, 2)); - }); - }); -}); - -// src/depbadgerc/process-manifest.ts -init_esm_shims(); - -// src/depbadgerc/update-integrity.ts -init_esm_shims(); -function updateIntegrity(integrity, path4 = "depbadgerc.yml") { - const absFilePath = findFile(path4); - if (!absFilePath) return; - const content = fs2.readFileSync(absFilePath, "utf8"); - const newContent = content.match(/^integrity: .*/m) ? content.replace(/^integrity: .*/m, `integrity: ${integrity}`) : `integrity: ${integrity} -${content}`; - fs2.writeFileSync(absFilePath, newContent, "utf8"); -} - -// src/depbadgerc/process-manifest.ts -function canOutput(x2 = [], y2) { - return x2?.includes(y2) ?? false; -} -function canUpdate(x2, y2) { - return x2 ? !y2.includes(x2) : true; -} -var processManifest = useCtxCallback((store, mfc) => { - const version = mfc.getVersion(); - const mfDeps = mfc.getDependencies(); - const rcDeps = store.getDependencies(); - const dependencyBadges = store.hydrateDependencyBadges(rcDeps, mfDeps); - const integrity = store.computeStateIntegrity(dependencyBadges, version); - const statusBadgeMap = store.getStatusBadges(); - const statusBadges = store.hydrateStatusBadges(statusBadgeMap); - const badgesMarkdown = store.mapBadgesToMarkdown(dependencyBadges); - const statusBadgesMarkdown = store.mapStatusBadgesToMarkdown(statusBadges); - if (canOutput(store.output, "json")) store.outputShieldioBadgesJson(dependencyBadges); - if (canOutput(store.output, "markdown")) { - store.outputMarkdownPreview("BADGES", badgesMarkdown); - store.outputMarkdownPreview("STATUS_BADGES", statusBadgesMarkdown); - } - store.applyMarkdownToTarget(statusBadgesMarkdown, badgesMarkdown); - if (canUpdate(store.integrity, integrity)) updateIntegrity(integrity); -}); - -// src/depbadgerc/read-depbadgerc-with-defaults.ts -init_esm_shims(); - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/index.mjs -init_esm_shims(); - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/lib/platform-shims/esm.mjs -init_esm_shims(); - -// node_modules/.pnpm/cliui@9.0.1/node_modules/cliui/index.mjs -init_esm_shims(); - -// node_modules/.pnpm/cliui@9.0.1/node_modules/cliui/build/lib/index.js -init_esm_shims(); -var align = { - right: alignRight, - center: alignCenter -}; -var top = 0; -var right = 1; -var bottom = 2; -var left = 3; -var UI = class { - constructor(opts) { - var _a2; - this.width = opts.width; - this.wrap = (_a2 = opts.wrap) !== null && _a2 !== void 0 ? _a2 : true; - this.rows = []; - } - span(...args) { - const cols = this.div(...args); - cols.span = true; - } - resetOutput() { - this.rows = []; - } - div(...args) { - if (args.length === 0) { - this.div(""); - } - if (this.wrap && this.shouldApplyLayoutDSL(...args) && typeof args[0] === "string") { - return this.applyLayoutDSL(args[0]); - } - const cols = args.map((arg) => { - if (typeof arg === "string") { - return this.colFromString(arg); - } - return arg; - }); - this.rows.push(cols); - return cols; - } - shouldApplyLayoutDSL(...args) { - return args.length === 1 && typeof args[0] === "string" && /[\t\n]/.test(args[0]); - } - applyLayoutDSL(str2) { - const rows = str2.split("\n").map((row) => row.split(" ")); - let leftColumnWidth = 0; - rows.forEach((columns) => { - if (columns.length > 1 && mixin.stringWidth(columns[0]) > leftColumnWidth) { - leftColumnWidth = Math.min(Math.floor(this.width * 0.5), mixin.stringWidth(columns[0])); - } - }); - rows.forEach((columns) => { - this.div(...columns.map((r2, i2) => { - return { - text: r2.trim(), - padding: this.measurePadding(r2), - width: i2 === 0 && columns.length > 1 ? leftColumnWidth : void 0 - }; - })); - }); - return this.rows[this.rows.length - 1]; - } - colFromString(text) { - return { - text, - padding: this.measurePadding(text) - }; - } - measurePadding(str2) { - const noAnsi = mixin.stripAnsi(str2); - return [0, noAnsi.match(/\s*$/)[0].length, 0, noAnsi.match(/^\s*/)[0].length]; - } - toString() { - const lines = []; - this.rows.forEach((row) => { - this.rowToString(row, lines); - }); - return lines.filter((line) => !line.hidden).map((line) => line.text).join("\n"); - } - rowToString(row, lines) { - this.rasterize(row).forEach((rrow, r2) => { - let str2 = ""; - rrow.forEach((col, c2) => { - const { width } = row[c2]; - const wrapWidth = this.negatePadding(row[c2]); - let ts = col; - if (wrapWidth > mixin.stringWidth(col)) { - ts += " ".repeat(wrapWidth - mixin.stringWidth(col)); - } - if (row[c2].align && row[c2].align !== "left" && this.wrap) { - const fn = align[row[c2].align]; - ts = fn(ts, wrapWidth); - if (mixin.stringWidth(ts) < wrapWidth) { - ts += " ".repeat((width || 0) - mixin.stringWidth(ts) - 1); - } - } - const padding = row[c2].padding || [0, 0, 0, 0]; - if (padding[left]) { - str2 += " ".repeat(padding[left]); - } - str2 += addBorder(row[c2], ts, "| "); - str2 += ts; - str2 += addBorder(row[c2], ts, " |"); - if (padding[right]) { - str2 += " ".repeat(padding[right]); - } - if (r2 === 0 && lines.length > 0) { - str2 = this.renderInline(str2, lines[lines.length - 1]); + return this.next(this.parseWhitespaceToEOL); + } else if (this.char === CHAR_PERIOD) { + if (!hasKey(this.ctx, keyword)) { + this.ctx = this.ctx[keyword] = Table(); + } else if (isTable(this.ctx[keyword])) { + this.ctx = this.ctx[keyword]; + } else if (isList(this.ctx[keyword])) { + this.ctx = this.ctx[keyword][this.ctx[keyword].length - 1]; + } else { + throw this.error(new TomlError("Can't redefine existing key")); + } + return this.next(this.parseTableNext); + } else { + throw this.error(new TomlError("Unexpected character, expected whitespace, . or ]")); + } + } + /* LIST [[a.b.c]] */ + parseList() { + this.ctx = this.obj; + return this.goto(this.parseListNext); + } + parseListNext() { + if (this.char === CHAR_SP || this.char === CTRL_I) { + return null; + } else { + return this.callNow(this.parseKeyword, this.parseListMore); + } + } + parseListMore(keyword) { + if (this.char === CHAR_SP || this.char === CTRL_I) { + return null; + } else if (this.char === CHAR_RSQB) { + if (!hasKey(this.ctx, keyword)) { + this.ctx[keyword] = List(); + } + if (isInlineList(this.ctx[keyword])) { + throw this.error(new TomlError("Can't extend an inline array")); + } else if (isList(this.ctx[keyword])) { + const next = Table(); + this.ctx[keyword].push(next); + this.ctx = next; + } else { + throw this.error(new TomlError("Can't redefine an existing key")); + } + return this.next(this.parseListEnd); + } else if (this.char === CHAR_PERIOD) { + if (!hasKey(this.ctx, keyword)) { + this.ctx = this.ctx[keyword] = Table(); + } else if (isInlineList(this.ctx[keyword])) { + throw this.error(new TomlError("Can't extend an inline array")); + } else if (isInlineTable(this.ctx[keyword])) { + throw this.error(new TomlError("Can't extend an inline table")); + } else if (isList(this.ctx[keyword])) { + this.ctx = this.ctx[keyword][this.ctx[keyword].length - 1]; + } else if (isTable(this.ctx[keyword])) { + this.ctx = this.ctx[keyword]; + } else { + throw this.error(new TomlError("Can't redefine an existing key")); + } + return this.next(this.parseListNext); + } else { + throw this.error(new TomlError("Unexpected character, expected whitespace, . or ]")); + } + } + parseListEnd(keyword) { + if (this.char === CHAR_RSQB) { + return this.next(this.parseWhitespaceToEOL); + } else { + throw this.error(new TomlError("Unexpected character, expected whitespace, . or ]")); + } + } + /* VALUE string, number, boolean, inline list, inline object */ + parseValue() { + if (this.char === Parser.END) { + throw this.error(new TomlError("Key without value")); + } else if (this.char === CHAR_QUOT) { + return this.next(this.parseDoubleString); + } + if (this.char === CHAR_APOS) { + return this.next(this.parseSingleString); + } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) { + return this.goto(this.parseNumberSign); + } else if (this.char === CHAR_i) { + return this.next(this.parseInf); + } else if (this.char === CHAR_n) { + return this.next(this.parseNan); + } else if (isDigit(this.char)) { + return this.goto(this.parseNumberOrDateTime); + } else if (this.char === CHAR_t || this.char === CHAR_f) { + return this.goto(this.parseBoolean); + } else if (this.char === CHAR_LSQB) { + return this.call(this.parseInlineList, this.recordValue); + } else if (this.char === CHAR_LCUB) { + return this.call(this.parseInlineTable, this.recordValue); + } else { + throw this.error(new TomlError("Unexpected character, expecting string, number, datetime, boolean, inline array or inline table")); + } + } + recordValue(value) { + return this.returnNow(value); + } + parseInf() { + if (this.char === CHAR_n) { + return this.next(this.parseInf2); + } else { + throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"')); + } + } + parseInf2() { + if (this.char === CHAR_f) { + if (this.state.buf === "-") { + return this.return(-Infinity); + } else { + return this.return(Infinity); + } + } else { + throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"')); + } + } + parseNan() { + if (this.char === CHAR_a) { + return this.next(this.parseNan2); + } else { + throw this.error(new TomlError('Unexpected character, expected "nan"')); + } + } + parseNan2() { + if (this.char === CHAR_n) { + return this.return(NaN); + } else { + throw this.error(new TomlError('Unexpected character, expected "nan"')); + } + } + /* KEYS, barewords or basic, literal, or dotted */ + parseKeyword() { + if (this.char === CHAR_QUOT) { + return this.next(this.parseBasicString); + } else if (this.char === CHAR_APOS) { + return this.next(this.parseLiteralString); + } else { + return this.goto(this.parseBareKey); + } + } + /* KEYS: barewords */ + parseBareKey() { + do { + if (this.char === Parser.END) { + throw this.error(new TomlError("Key ended without value")); + } else if (isAlphaNumHyphen(this.char)) { + this.consume(); + } else if (this.state.buf.length === 0) { + throw this.error(new TomlError("Empty bare keys are not allowed")); + } else { + return this.returnNow(); + } + } while (this.nextChar()); + } + /* STRINGS, single quoted (literal) */ + parseSingleString() { + if (this.char === CHAR_APOS) { + return this.next(this.parseLiteralMultiStringMaybe); + } else { + return this.goto(this.parseLiteralString); + } + } + parseLiteralString() { + do { + if (this.char === CHAR_APOS) { + return this.return(); + } else if (this.atEndOfLine()) { + throw this.error(new TomlError("Unterminated string")); + } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I) { + throw this.errorControlCharInString(); + } else { + this.consume(); + } + } while (this.nextChar()); + } + parseLiteralMultiStringMaybe() { + if (this.char === CHAR_APOS) { + return this.next(this.parseLiteralMultiString); + } else { + return this.returnNow(); + } + } + parseLiteralMultiString() { + if (this.char === CTRL_M) { + return null; + } else if (this.char === CTRL_J) { + return this.next(this.parseLiteralMultiStringContent); + } else { + return this.goto(this.parseLiteralMultiStringContent); + } + } + parseLiteralMultiStringContent() { + do { + if (this.char === CHAR_APOS) { + return this.next(this.parseLiteralMultiEnd); + } else if (this.char === Parser.END) { + throw this.error(new TomlError("Unterminated multi-line string")); + } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M) { + throw this.errorControlCharInString(); + } else { + this.consume(); + } + } while (this.nextChar()); + } + parseLiteralMultiEnd() { + if (this.char === CHAR_APOS) { + return this.next(this.parseLiteralMultiEnd2); + } else { + this.state.buf += "'"; + return this.goto(this.parseLiteralMultiStringContent); + } + } + parseLiteralMultiEnd2() { + if (this.char === CHAR_APOS) { + return this.return(); + } else { + this.state.buf += "''"; + return this.goto(this.parseLiteralMultiStringContent); + } + } + /* STRINGS double quoted */ + parseDoubleString() { + if (this.char === CHAR_QUOT) { + return this.next(this.parseMultiStringMaybe); + } else { + return this.goto(this.parseBasicString); + } + } + parseBasicString() { + do { + if (this.char === CHAR_BSOL) { + return this.call(this.parseEscape, this.recordEscapeReplacement); + } else if (this.char === CHAR_QUOT) { + return this.return(); + } else if (this.atEndOfLine()) { + throw this.error(new TomlError("Unterminated string")); + } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I) { + throw this.errorControlCharInString(); + } else { + this.consume(); + } + } while (this.nextChar()); + } + recordEscapeReplacement(replacement) { + this.state.buf += replacement; + return this.goto(this.parseBasicString); + } + parseMultiStringMaybe() { + if (this.char === CHAR_QUOT) { + return this.next(this.parseMultiString); + } else { + return this.returnNow(); + } + } + parseMultiString() { + if (this.char === CTRL_M) { + return null; + } else if (this.char === CTRL_J) { + return this.next(this.parseMultiStringContent); + } else { + return this.goto(this.parseMultiStringContent); + } + } + parseMultiStringContent() { + do { + if (this.char === CHAR_BSOL) { + return this.call(this.parseMultiEscape, this.recordMultiEscapeReplacement); + } else if (this.char === CHAR_QUOT) { + return this.next(this.parseMultiEnd); + } else if (this.char === Parser.END) { + throw this.error(new TomlError("Unterminated multi-line string")); + } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M) { + throw this.errorControlCharInString(); + } else { + this.consume(); + } + } while (this.nextChar()); + } + errorControlCharInString() { + let displayCode = "\\u00"; + if (this.char < 16) { + displayCode += "0"; + } + displayCode += this.char.toString(16); + return this.error(new TomlError(`Control characters (codes < 0x1f and 0x7f) are not allowed in strings, use ${displayCode} instead`)); + } + recordMultiEscapeReplacement(replacement) { + this.state.buf += replacement; + return this.goto(this.parseMultiStringContent); } - }); - lines.push({ - text: str2.replace(/ +$/, ""), - span: row.span - }); - }); - return lines; - } - // if the full 'source' can render in - // the target line, do so. - renderInline(source, previousLine) { - const match = source.match(/^ */); - const leadingWhitespace = match ? match[0].length : 0; - const target = previousLine.text; - const targetTextWidth = mixin.stringWidth(target.trimRight()); - if (!previousLine.span) { - return source; - } - if (!this.wrap) { - previousLine.hidden = true; - return target + source; - } - if (leadingWhitespace < targetTextWidth) { - return source; - } - previousLine.hidden = true; - return target.trimRight() + " ".repeat(leadingWhitespace - targetTextWidth) + source.trimLeft(); - } - rasterize(row) { - const rrows = []; - const widths = this.columnWidths(row); - let wrapped; - row.forEach((col, c2) => { - col.width = widths[c2]; - if (this.wrap) { - wrapped = mixin.wrap(col.text, this.negatePadding(col), { hard: true }).split("\n"); - } else { - wrapped = col.text.split("\n"); - } - if (col.border) { - wrapped.unshift("." + "-".repeat(this.negatePadding(col) + 2) + "."); - wrapped.push("'" + "-".repeat(this.negatePadding(col) + 2) + "'"); - } - if (col.padding) { - wrapped.unshift(...new Array(col.padding[top] || 0).fill("")); - wrapped.push(...new Array(col.padding[bottom] || 0).fill("")); - } - wrapped.forEach((str2, r2) => { - if (!rrows[r2]) { - rrows.push([]); + parseMultiEnd() { + if (this.char === CHAR_QUOT) { + return this.next(this.parseMultiEnd2); + } else { + this.state.buf += '"'; + return this.goto(this.parseMultiStringContent); + } + } + parseMultiEnd2() { + if (this.char === CHAR_QUOT) { + return this.return(); + } else { + this.state.buf += '""'; + return this.goto(this.parseMultiStringContent); + } + } + parseMultiEscape() { + if (this.char === CTRL_M || this.char === CTRL_J) { + return this.next(this.parseMultiTrim); + } else if (this.char === CHAR_SP || this.char === CTRL_I) { + return this.next(this.parsePreMultiTrim); + } else { + return this.goto(this.parseEscape); + } + } + parsePreMultiTrim() { + if (this.char === CHAR_SP || this.char === CTRL_I) { + return null; + } else if (this.char === CTRL_M || this.char === CTRL_J) { + return this.next(this.parseMultiTrim); + } else { + throw this.error(new TomlError("Can't escape whitespace")); + } + } + parseMultiTrim() { + if (this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) { + return null; + } else { + return this.returnNow(); + } + } + parseEscape() { + if (this.char in escapes) { + return this.return(escapes[this.char]); + } else if (this.char === CHAR_u) { + return this.call(this.parseSmallUnicode, this.parseUnicodeReturn); + } else if (this.char === CHAR_U) { + return this.call(this.parseLargeUnicode, this.parseUnicodeReturn); + } else { + throw this.error(new TomlError("Unknown escape character: " + this.char)); + } + } + parseUnicodeReturn(char) { + try { + const codePoint = parseInt(char, 16); + if (codePoint >= SURROGATE_FIRST && codePoint <= SURROGATE_LAST) { + throw this.error(new TomlError("Invalid unicode, character in range 0xD800 - 0xDFFF is reserved")); + } + return this.returnNow(String.fromCodePoint(codePoint)); + } catch (err) { + throw this.error(TomlError.wrap(err)); + } + } + parseSmallUnicode() { + if (!isHexit(this.char)) { + throw this.error(new TomlError("Invalid character in unicode sequence, expected hex")); + } else { + this.consume(); + if (this.state.buf.length >= 4) return this.return(); + } + } + parseLargeUnicode() { + if (!isHexit(this.char)) { + throw this.error(new TomlError("Invalid character in unicode sequence, expected hex")); + } else { + this.consume(); + if (this.state.buf.length >= 8) return this.return(); + } + } + /* NUMBERS */ + parseNumberSign() { + this.consume(); + return this.next(this.parseMaybeSignedInfOrNan); + } + parseMaybeSignedInfOrNan() { + if (this.char === CHAR_i) { + return this.next(this.parseInf); + } else if (this.char === CHAR_n) { + return this.next(this.parseNan); + } else { + return this.callNow(this.parseNoUnder, this.parseNumberIntegerStart); + } + } + parseNumberIntegerStart() { + if (this.char === CHAR_0) { + this.consume(); + return this.next(this.parseNumberIntegerExponentOrDecimal); + } else { + return this.goto(this.parseNumberInteger); + } + } + parseNumberIntegerExponentOrDecimal() { + if (this.char === CHAR_PERIOD) { + this.consume(); + return this.call(this.parseNoUnder, this.parseNumberFloat); + } else if (this.char === CHAR_E || this.char === CHAR_e) { + this.consume(); + return this.next(this.parseNumberExponentSign); + } else { + return this.returnNow(Integer(this.state.buf)); + } + } + parseNumberInteger() { + if (isDigit(this.char)) { + this.consume(); + } else if (this.char === CHAR_LOWBAR) { + return this.call(this.parseNoUnder); + } else if (this.char === CHAR_E || this.char === CHAR_e) { + this.consume(); + return this.next(this.parseNumberExponentSign); + } else if (this.char === CHAR_PERIOD) { + this.consume(); + return this.call(this.parseNoUnder, this.parseNumberFloat); + } else { + const result = Integer(this.state.buf); + if (result.isNaN()) { + throw this.error(new TomlError("Invalid number")); + } else { + return this.returnNow(result); + } + } + } + parseNoUnder() { + if (this.char === CHAR_LOWBAR || this.char === CHAR_PERIOD || this.char === CHAR_E || this.char === CHAR_e) { + throw this.error(new TomlError("Unexpected character, expected digit")); + } else if (this.atEndOfWord()) { + throw this.error(new TomlError("Incomplete number")); + } + return this.returnNow(); + } + parseNoUnderHexOctBinLiteral() { + if (this.char === CHAR_LOWBAR || this.char === CHAR_PERIOD) { + throw this.error(new TomlError("Unexpected character, expected digit")); + } else if (this.atEndOfWord()) { + throw this.error(new TomlError("Incomplete number")); + } + return this.returnNow(); + } + parseNumberFloat() { + if (this.char === CHAR_LOWBAR) { + return this.call(this.parseNoUnder, this.parseNumberFloat); + } else if (isDigit(this.char)) { + this.consume(); + } else if (this.char === CHAR_E || this.char === CHAR_e) { + this.consume(); + return this.next(this.parseNumberExponentSign); + } else { + return this.returnNow(Float(this.state.buf)); + } + } + parseNumberExponentSign() { + if (isDigit(this.char)) { + return this.goto(this.parseNumberExponent); + } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) { + this.consume(); + this.call(this.parseNoUnder, this.parseNumberExponent); + } else { + throw this.error(new TomlError("Unexpected character, expected -, + or digit")); + } + } + parseNumberExponent() { + if (isDigit(this.char)) { + this.consume(); + } else if (this.char === CHAR_LOWBAR) { + return this.call(this.parseNoUnder); + } else { + return this.returnNow(Float(this.state.buf)); + } + } + /* NUMBERS or DATETIMES */ + parseNumberOrDateTime() { + if (this.char === CHAR_0) { + this.consume(); + return this.next(this.parseNumberBaseOrDateTime); + } else { + return this.goto(this.parseNumberOrDateTimeOnly); + } + } + parseNumberOrDateTimeOnly() { + if (this.char === CHAR_LOWBAR) { + return this.call(this.parseNoUnder, this.parseNumberInteger); + } else if (isDigit(this.char)) { + this.consume(); + if (this.state.buf.length > 4) this.next(this.parseNumberInteger); + } else if (this.char === CHAR_E || this.char === CHAR_e) { + this.consume(); + return this.next(this.parseNumberExponentSign); + } else if (this.char === CHAR_PERIOD) { + this.consume(); + return this.call(this.parseNoUnder, this.parseNumberFloat); + } else if (this.char === CHAR_HYPHEN) { + return this.goto(this.parseDateTime); + } else if (this.char === CHAR_COLON) { + return this.goto(this.parseOnlyTimeHour); + } else { + return this.returnNow(Integer(this.state.buf)); + } + } + parseDateTimeOnly() { + if (this.state.buf.length < 4) { + if (isDigit(this.char)) { + return this.consume(); + } else if (this.char === CHAR_COLON) { + return this.goto(this.parseOnlyTimeHour); + } else { + throw this.error(new TomlError("Expected digit while parsing year part of a date")); + } + } else { + if (this.char === CHAR_HYPHEN) { + return this.goto(this.parseDateTime); + } else { + throw this.error(new TomlError("Expected hyphen (-) while parsing year part of date")); + } + } + } + parseNumberBaseOrDateTime() { + if (this.char === CHAR_b) { + this.consume(); + return this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerBin); + } else if (this.char === CHAR_o) { + this.consume(); + return this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerOct); + } else if (this.char === CHAR_x) { + this.consume(); + return this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerHex); + } else if (this.char === CHAR_PERIOD) { + return this.goto(this.parseNumberInteger); + } else if (isDigit(this.char)) { + return this.goto(this.parseDateTimeOnly); + } else { + return this.returnNow(Integer(this.state.buf)); + } } - const rrow = rrows[r2]; - for (let i2 = 0; i2 < c2; i2++) { - if (rrow[i2] === void 0) { - rrow.push(""); + parseIntegerHex() { + if (isHexit(this.char)) { + this.consume(); + } else if (this.char === CHAR_LOWBAR) { + return this.call(this.parseNoUnderHexOctBinLiteral); + } else { + const result = Integer(this.state.buf); + if (result.isNaN()) { + throw this.error(new TomlError("Invalid number")); + } else { + return this.returnNow(result); + } } } - rrow.push(str2); - }); - }); - return rrows; - } - negatePadding(col) { - let wrapWidth = col.width || 0; - if (col.padding) { - wrapWidth -= (col.padding[left] || 0) + (col.padding[right] || 0); - } - if (col.border) { - wrapWidth -= 4; - } - return wrapWidth; - } - columnWidths(row) { - if (!this.wrap) { - return row.map((col) => { - return col.width || mixin.stringWidth(col.text); - }); - } - let unset = row.length; - let remainingWidth = this.width; - const widths = row.map((col) => { - if (col.width) { - unset--; - remainingWidth -= col.width; - return col.width; - } - return void 0; - }); - const unsetWidth = unset ? Math.floor(remainingWidth / unset) : 0; - return widths.map((w2, i2) => { - if (w2 === void 0) { - return Math.max(unsetWidth, _minWidth(row[i2])); - } - return w2; - }); - } -}; -function addBorder(col, ts, style) { - if (col.border) { - if (/[.']-+[.']/.test(ts)) { - return ""; - } - if (ts.trim().length !== 0) { - return style; - } - return " "; - } - return ""; -} -function _minWidth(col) { - const padding = col.padding || []; - const minWidth = 1 + (padding[left] || 0) + (padding[right] || 0); - if (col.border) { - return minWidth + 4; - } - return minWidth; -} -function getWindowWidth() { - if (typeof process === "object" && process.stdout && process.stdout.columns) { - return process.stdout.columns; - } - return 80; -} -function alignRight(str2, width) { - str2 = str2.trim(); - const strWidth = mixin.stringWidth(str2); - if (strWidth < width) { - return " ".repeat(width - strWidth) + str2; - } - return str2; -} -function alignCenter(str2, width) { - str2 = str2.trim(); - const strWidth = mixin.stringWidth(str2); - if (strWidth >= width) { - return str2; - } - return " ".repeat(width - strWidth >> 1) + str2; -} -var mixin; -function cliui(opts, _mixin) { - mixin = _mixin; - return new UI({ - width: (opts === null || opts === void 0 ? void 0 : opts.width) || getWindowWidth(), - wrap: opts === null || opts === void 0 ? void 0 : opts.wrap - }); -} - -// node_modules/.pnpm/string-width@7.2.0/node_modules/string-width/index.js -init_esm_shims(); - -// node_modules/.pnpm/strip-ansi@7.1.2/node_modules/strip-ansi/index.js -init_esm_shims(); - -// node_modules/.pnpm/ansi-regex@6.2.2/node_modules/ansi-regex/index.js -init_esm_shims(); -function ansiRegex({ onlyFirst = false } = {}) { - const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)"; - const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`; - const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]"; - const pattern = `${osc}|${csi}`; - return new RegExp(pattern, onlyFirst ? void 0 : "g"); -} - -// node_modules/.pnpm/strip-ansi@7.1.2/node_modules/strip-ansi/index.js -var regex = ansiRegex(); -function stripAnsi(string) { - if (typeof string !== "string") { - throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``); - } - return string.replace(regex, ""); -} - -// node_modules/.pnpm/get-east-asian-width@1.4.0/node_modules/get-east-asian-width/index.js -init_esm_shims(); - -// node_modules/.pnpm/get-east-asian-width@1.4.0/node_modules/get-east-asian-width/lookup.js -init_esm_shims(); -function isAmbiguous(x2) { - return x2 === 161 || x2 === 164 || x2 === 167 || x2 === 168 || x2 === 170 || x2 === 173 || x2 === 174 || x2 >= 176 && x2 <= 180 || x2 >= 182 && x2 <= 186 || x2 >= 188 && x2 <= 191 || x2 === 198 || x2 === 208 || x2 === 215 || x2 === 216 || x2 >= 222 && x2 <= 225 || x2 === 230 || x2 >= 232 && x2 <= 234 || x2 === 236 || x2 === 237 || x2 === 240 || x2 === 242 || x2 === 243 || x2 >= 247 && x2 <= 250 || x2 === 252 || x2 === 254 || x2 === 257 || x2 === 273 || x2 === 275 || x2 === 283 || x2 === 294 || x2 === 295 || x2 === 299 || x2 >= 305 && x2 <= 307 || x2 === 312 || x2 >= 319 && x2 <= 322 || x2 === 324 || x2 >= 328 && x2 <= 331 || x2 === 333 || x2 === 338 || x2 === 339 || x2 === 358 || x2 === 359 || x2 === 363 || x2 === 462 || x2 === 464 || x2 === 466 || x2 === 468 || x2 === 470 || x2 === 472 || x2 === 474 || x2 === 476 || x2 === 593 || x2 === 609 || x2 === 708 || x2 === 711 || x2 >= 713 && x2 <= 715 || x2 === 717 || x2 === 720 || x2 >= 728 && x2 <= 731 || x2 === 733 || x2 === 735 || x2 >= 768 && x2 <= 879 || x2 >= 913 && x2 <= 929 || x2 >= 931 && x2 <= 937 || x2 >= 945 && x2 <= 961 || x2 >= 963 && x2 <= 969 || x2 === 1025 || x2 >= 1040 && x2 <= 1103 || x2 === 1105 || x2 === 8208 || x2 >= 8211 && x2 <= 8214 || x2 === 8216 || x2 === 8217 || x2 === 8220 || x2 === 8221 || x2 >= 8224 && x2 <= 8226 || x2 >= 8228 && x2 <= 8231 || x2 === 8240 || x2 === 8242 || x2 === 8243 || x2 === 8245 || x2 === 8251 || x2 === 8254 || x2 === 8308 || x2 === 8319 || x2 >= 8321 && x2 <= 8324 || x2 === 8364 || x2 === 8451 || x2 === 8453 || x2 === 8457 || x2 === 8467 || x2 === 8470 || x2 === 8481 || x2 === 8482 || x2 === 8486 || x2 === 8491 || x2 === 8531 || x2 === 8532 || x2 >= 8539 && x2 <= 8542 || x2 >= 8544 && x2 <= 8555 || x2 >= 8560 && x2 <= 8569 || x2 === 8585 || x2 >= 8592 && x2 <= 8601 || x2 === 8632 || x2 === 8633 || x2 === 8658 || x2 === 8660 || x2 === 8679 || x2 === 8704 || x2 === 8706 || x2 === 8707 || x2 === 8711 || x2 === 8712 || x2 === 8715 || x2 === 8719 || x2 === 8721 || x2 === 8725 || x2 === 8730 || x2 >= 8733 && x2 <= 8736 || x2 === 8739 || x2 === 8741 || x2 >= 8743 && x2 <= 8748 || x2 === 8750 || x2 >= 8756 && x2 <= 8759 || x2 === 8764 || x2 === 8765 || x2 === 8776 || x2 === 8780 || x2 === 8786 || x2 === 8800 || x2 === 8801 || x2 >= 8804 && x2 <= 8807 || x2 === 8810 || x2 === 8811 || x2 === 8814 || x2 === 8815 || x2 === 8834 || x2 === 8835 || x2 === 8838 || x2 === 8839 || x2 === 8853 || x2 === 8857 || x2 === 8869 || x2 === 8895 || x2 === 8978 || x2 >= 9312 && x2 <= 9449 || x2 >= 9451 && x2 <= 9547 || x2 >= 9552 && x2 <= 9587 || x2 >= 9600 && x2 <= 9615 || x2 >= 9618 && x2 <= 9621 || x2 === 9632 || x2 === 9633 || x2 >= 9635 && x2 <= 9641 || x2 === 9650 || x2 === 9651 || x2 === 9654 || x2 === 9655 || x2 === 9660 || x2 === 9661 || x2 === 9664 || x2 === 9665 || x2 >= 9670 && x2 <= 9672 || x2 === 9675 || x2 >= 9678 && x2 <= 9681 || x2 >= 9698 && x2 <= 9701 || x2 === 9711 || x2 === 9733 || x2 === 9734 || x2 === 9737 || x2 === 9742 || x2 === 9743 || x2 === 9756 || x2 === 9758 || x2 === 9792 || x2 === 9794 || x2 === 9824 || x2 === 9825 || x2 >= 9827 && x2 <= 9829 || x2 >= 9831 && x2 <= 9834 || x2 === 9836 || x2 === 9837 || x2 === 9839 || x2 === 9886 || x2 === 9887 || x2 === 9919 || x2 >= 9926 && x2 <= 9933 || x2 >= 9935 && x2 <= 9939 || x2 >= 9941 && x2 <= 9953 || x2 === 9955 || x2 === 9960 || x2 === 9961 || x2 >= 9963 && x2 <= 9969 || x2 === 9972 || x2 >= 9974 && x2 <= 9977 || x2 === 9979 || x2 === 9980 || x2 === 9982 || x2 === 9983 || x2 === 10045 || x2 >= 10102 && x2 <= 10111 || x2 >= 11094 && x2 <= 11097 || x2 >= 12872 && x2 <= 12879 || x2 >= 57344 && x2 <= 63743 || x2 >= 65024 && x2 <= 65039 || x2 === 65533 || x2 >= 127232 && x2 <= 127242 || x2 >= 127248 && x2 <= 127277 || x2 >= 127280 && x2 <= 127337 || x2 >= 127344 && x2 <= 127373 || x2 === 127375 || x2 === 127376 || x2 >= 127387 && x2 <= 127404 || x2 >= 917760 && x2 <= 917999 || x2 >= 983040 && x2 <= 1048573 || x2 >= 1048576 && x2 <= 1114109; -} -function isFullWidth(x2) { - return x2 === 12288 || x2 >= 65281 && x2 <= 65376 || x2 >= 65504 && x2 <= 65510; -} -function isWide(x2) { - return x2 >= 4352 && x2 <= 4447 || x2 === 8986 || x2 === 8987 || x2 === 9001 || x2 === 9002 || x2 >= 9193 && x2 <= 9196 || x2 === 9200 || x2 === 9203 || x2 === 9725 || x2 === 9726 || x2 === 9748 || x2 === 9749 || x2 >= 9776 && x2 <= 9783 || x2 >= 9800 && x2 <= 9811 || x2 === 9855 || x2 >= 9866 && x2 <= 9871 || x2 === 9875 || x2 === 9889 || x2 === 9898 || x2 === 9899 || x2 === 9917 || x2 === 9918 || x2 === 9924 || x2 === 9925 || x2 === 9934 || x2 === 9940 || x2 === 9962 || x2 === 9970 || x2 === 9971 || x2 === 9973 || x2 === 9978 || x2 === 9981 || x2 === 9989 || x2 === 9994 || x2 === 9995 || x2 === 10024 || x2 === 10060 || x2 === 10062 || x2 >= 10067 && x2 <= 10069 || x2 === 10071 || x2 >= 10133 && x2 <= 10135 || x2 === 10160 || x2 === 10175 || x2 === 11035 || x2 === 11036 || x2 === 11088 || x2 === 11093 || x2 >= 11904 && x2 <= 11929 || x2 >= 11931 && x2 <= 12019 || x2 >= 12032 && x2 <= 12245 || x2 >= 12272 && x2 <= 12287 || x2 >= 12289 && x2 <= 12350 || x2 >= 12353 && x2 <= 12438 || x2 >= 12441 && x2 <= 12543 || x2 >= 12549 && x2 <= 12591 || x2 >= 12593 && x2 <= 12686 || x2 >= 12688 && x2 <= 12773 || x2 >= 12783 && x2 <= 12830 || x2 >= 12832 && x2 <= 12871 || x2 >= 12880 && x2 <= 42124 || x2 >= 42128 && x2 <= 42182 || x2 >= 43360 && x2 <= 43388 || x2 >= 44032 && x2 <= 55203 || x2 >= 63744 && x2 <= 64255 || x2 >= 65040 && x2 <= 65049 || x2 >= 65072 && x2 <= 65106 || x2 >= 65108 && x2 <= 65126 || x2 >= 65128 && x2 <= 65131 || x2 >= 94176 && x2 <= 94180 || x2 >= 94192 && x2 <= 94198 || x2 >= 94208 && x2 <= 101589 || x2 >= 101631 && x2 <= 101662 || x2 >= 101760 && x2 <= 101874 || x2 >= 110576 && x2 <= 110579 || x2 >= 110581 && x2 <= 110587 || x2 === 110589 || x2 === 110590 || x2 >= 110592 && x2 <= 110882 || x2 === 110898 || x2 >= 110928 && x2 <= 110930 || x2 === 110933 || x2 >= 110948 && x2 <= 110951 || x2 >= 110960 && x2 <= 111355 || x2 >= 119552 && x2 <= 119638 || x2 >= 119648 && x2 <= 119670 || x2 === 126980 || x2 === 127183 || x2 === 127374 || x2 >= 127377 && x2 <= 127386 || x2 >= 127488 && x2 <= 127490 || x2 >= 127504 && x2 <= 127547 || x2 >= 127552 && x2 <= 127560 || x2 === 127568 || x2 === 127569 || x2 >= 127584 && x2 <= 127589 || x2 >= 127744 && x2 <= 127776 || x2 >= 127789 && x2 <= 127797 || x2 >= 127799 && x2 <= 127868 || x2 >= 127870 && x2 <= 127891 || x2 >= 127904 && x2 <= 127946 || x2 >= 127951 && x2 <= 127955 || x2 >= 127968 && x2 <= 127984 || x2 === 127988 || x2 >= 127992 && x2 <= 128062 || x2 === 128064 || x2 >= 128066 && x2 <= 128252 || x2 >= 128255 && x2 <= 128317 || x2 >= 128331 && x2 <= 128334 || x2 >= 128336 && x2 <= 128359 || x2 === 128378 || x2 === 128405 || x2 === 128406 || x2 === 128420 || x2 >= 128507 && x2 <= 128591 || x2 >= 128640 && x2 <= 128709 || x2 === 128716 || x2 >= 128720 && x2 <= 128722 || x2 >= 128725 && x2 <= 128728 || x2 >= 128732 && x2 <= 128735 || x2 === 128747 || x2 === 128748 || x2 >= 128756 && x2 <= 128764 || x2 >= 128992 && x2 <= 129003 || x2 === 129008 || x2 >= 129292 && x2 <= 129338 || x2 >= 129340 && x2 <= 129349 || x2 >= 129351 && x2 <= 129535 || x2 >= 129648 && x2 <= 129660 || x2 >= 129664 && x2 <= 129674 || x2 >= 129678 && x2 <= 129734 || x2 === 129736 || x2 >= 129741 && x2 <= 129756 || x2 >= 129759 && x2 <= 129770 || x2 >= 129775 && x2 <= 129784 || x2 >= 131072 && x2 <= 196605 || x2 >= 196608 && x2 <= 262141; -} - -// node_modules/.pnpm/get-east-asian-width@1.4.0/node_modules/get-east-asian-width/index.js -function validate(codePoint) { - if (!Number.isSafeInteger(codePoint)) { - throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`); - } -} -function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) { - validate(codePoint); - if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) { - return 2; - } - return 1; -} - -// node_modules/.pnpm/emoji-regex@10.6.0/node_modules/emoji-regex/index.mjs -init_esm_shims(); -var emoji_regex_default = () => { - return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g; -}; - -// node_modules/.pnpm/string-width@7.2.0/node_modules/string-width/index.js -var segmenter = new Intl.Segmenter(); -var defaultIgnorableCodePointRegex = new RegExp("^\\p{Default_Ignorable_Code_Point}$", "u"); -function stringWidth(string, options = {}) { - if (typeof string !== "string" || string.length === 0) { - return 0; - } - const { - ambiguousIsNarrow = true, - countAnsiEscapeCodes = false - } = options; - if (!countAnsiEscapeCodes) { - string = stripAnsi(string); - } - if (string.length === 0) { - return 0; - } - let width = 0; - const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow }; - for (const { segment: character } of segmenter.segment(string)) { - const codePoint = character.codePointAt(0); - if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) { - continue; - } - if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) { - continue; - } - if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) { - continue; - } - if (codePoint >= 55296 && codePoint <= 57343) { - continue; - } - if (codePoint >= 65024 && codePoint <= 65039) { - continue; - } - if (defaultIgnorableCodePointRegex.test(character)) { - continue; - } - if (emoji_regex_default().test(character)) { - width += 2; - continue; - } - width += eastAsianWidth(codePoint, eastAsianWidthOptions); - } - return width; -} - -// node_modules/.pnpm/wrap-ansi@9.0.2/node_modules/wrap-ansi/index.js -init_esm_shims(); - -// node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.js -init_esm_shims(); -var ANSI_BACKGROUND_OFFSET = 10; -var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`; -var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`; -var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`; -var styles = { - 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.modifier); -var foregroundColorNames = Object.keys(styles.color); -var backgroundColorNames = Object.keys(styles.bgColor); -[...foregroundColorNames, ...backgroundColorNames]; -function assembleStyles() { - const codes = /* @__PURE__ */ new Map(); - for (const [groupName, group] of Object.entries(styles)) { - for (const [styleName, style] of Object.entries(group)) { - styles[styleName] = { - open: `\x1B[${style[0]}m`, - close: `\x1B[${style[1]}m` - }; - group[styleName] = styles[styleName]; - codes.set(style[0], style[1]); - } - Object.defineProperty(styles, groupName, { - value: group, - enumerable: false - }); - } - Object.defineProperty(styles, "codes", { - value: codes, - enumerable: false - }); - styles.color.close = "\x1B[39m"; - styles.bgColor.close = "\x1B[49m"; - styles.color.ansi = wrapAnsi16(); - styles.color.ansi256 = wrapAnsi256(); - styles.color.ansi16m = wrapAnsi16m(); - styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET); - styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET); - styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET); - Object.defineProperties(styles, { - 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.rgbToAnsi256(...styles.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; + parseIntegerOct() { + if (isOctit(this.char)) { + this.consume(); + } else if (this.char === CHAR_LOWBAR) { + return this.call(this.parseNoUnderHexOctBinLiteral); + } else { + const result = Integer(this.state.buf); + if (result.isNaN()) { + throw this.error(new TomlError("Invalid number")); + } else { + return this.returnNow(result); + } + } } - const value = Math.max(red, green, blue) * 2; - if (value === 0) { - return 30; + parseIntegerBin() { + if (isBit(this.char)) { + this.consume(); + } else if (this.char === CHAR_LOWBAR) { + return this.call(this.parseNoUnderHexOctBinLiteral); + } else { + const result = Integer(this.state.buf); + if (result.isNaN()) { + throw this.error(new TomlError("Invalid number")); + } else { + return this.returnNow(result); + } + } } - let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red)); - if (value === 2) { - result += 60; + /* DATETIME */ + parseDateTime() { + if (this.state.buf.length < 4) { + throw this.error(new TomlError("Years less than 1000 must be zero padded to four characters")); + } + this.state.result = this.state.buf; + this.state.buf = ""; + return this.next(this.parseDateMonth); } - return result; - }, - enumerable: false - }, - rgbToAnsi: { - value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)), - enumerable: false - }, - hexToAnsi: { - value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)), - enumerable: false - } - }); - return styles; -} -var ansiStyles = assembleStyles(); -var ansi_styles_default = ansiStyles; - -// node_modules/.pnpm/wrap-ansi@9.0.2/node_modules/wrap-ansi/index.js -var ESCAPES = /* @__PURE__ */ new Set([ - "\x1B", - "\x9B" -]); -var END_CODE = 39; -var ANSI_ESCAPE_BELL = "\x07"; -var ANSI_CSI = "["; -var ANSI_OSC = "]"; -var ANSI_SGR_TERMINATOR = "m"; -var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`; -var wrapAnsiCode = (code) => `${ESCAPES.values().next().value}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`; -var wrapAnsiHyperlink = (url) => `${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`; -var wordLengths = (string) => string.split(" ").map((character) => stringWidth(character)); -var wrapWord = (rows, word, columns) => { - const characters = [...word]; - let isInsideEscape = false; - let isInsideLinkEscape = false; - let visible = stringWidth(stripAnsi(rows.at(-1))); - for (const [index, character] of characters.entries()) { - const characterLength = stringWidth(character); - if (visible + characterLength <= columns) { - rows[rows.length - 1] += character; - } else { - rows.push(character); - visible = 0; - } - if (ESCAPES.has(character)) { - isInsideEscape = true; - const ansiEscapeLinkCandidate = characters.slice(index + 1, index + 1 + ANSI_ESCAPE_LINK.length).join(""); - isInsideLinkEscape = ansiEscapeLinkCandidate === ANSI_ESCAPE_LINK; - } - if (isInsideEscape) { - if (isInsideLinkEscape) { - if (character === ANSI_ESCAPE_BELL) { - isInsideEscape = false; - isInsideLinkEscape = false; - } - } else if (character === ANSI_SGR_TERMINATOR) { - isInsideEscape = false; - } - continue; - } - visible += characterLength; - if (visible === columns && index < characters.length - 1) { - rows.push(""); - visible = 0; - } - } - if (!visible && rows.at(-1).length > 0 && rows.length > 1) { - rows[rows.length - 2] += rows.pop(); - } -}; -var stringVisibleTrimSpacesRight = (string) => { - const words = string.split(" "); - let last = words.length; - while (last > 0) { - if (stringWidth(words[last - 1]) > 0) { - break; - } - last--; - } - if (last === words.length) { - return string; - } - return words.slice(0, last).join(" ") + words.slice(last).join(""); -}; -var exec = (string, columns, options = {}) => { - if (options.trim !== false && string.trim() === "") { - return ""; - } - let returnValue = ""; - let escapeCode; - let escapeUrl; - const lengths = wordLengths(string); - let rows = [""]; - for (const [index, word] of string.split(" ").entries()) { - if (options.trim !== false) { - rows[rows.length - 1] = rows.at(-1).trimStart(); - } - let rowLength = stringWidth(rows.at(-1)); - if (index !== 0) { - if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) { - rows.push(""); - rowLength = 0; - } - if (rowLength > 0 || options.trim === false) { - rows[rows.length - 1] += " "; - rowLength++; - } - } - if (options.hard && lengths[index] > columns) { - const remainingColumns = columns - rowLength; - const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns); - const breaksStartingNextLine = Math.floor((lengths[index] - 1) / columns); - if (breaksStartingNextLine < breaksStartingThisLine) { - rows.push(""); - } - wrapWord(rows, word, columns); - continue; - } - if (rowLength + lengths[index] > columns && rowLength > 0 && lengths[index] > 0) { - if (options.wordWrap === false && rowLength < columns) { - wrapWord(rows, word, columns); - continue; - } - rows.push(""); - } - if (rowLength + lengths[index] > columns && options.wordWrap === false) { - wrapWord(rows, word, columns); - continue; - } - rows[rows.length - 1] += word; - } - if (options.trim !== false) { - rows = rows.map((row) => stringVisibleTrimSpacesRight(row)); - } - const preString = rows.join("\n"); - const pre = [...preString]; - let preStringIndex = 0; - for (const [index, character] of pre.entries()) { - returnValue += character; - if (ESCAPES.has(character)) { - const { groups } = new RegExp(`(?:\\${ANSI_CSI}(?\\d+)m|\\${ANSI_ESCAPE_LINK}(?.*)${ANSI_ESCAPE_BELL})`).exec(preString.slice(preStringIndex)) || { groups: {} }; - if (groups.code !== void 0) { - const code2 = Number.parseFloat(groups.code); - escapeCode = code2 === END_CODE ? void 0 : code2; - } else if (groups.uri !== void 0) { - escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri; - } - } - const code = ansi_styles_default.codes.get(Number(escapeCode)); - if (pre[index + 1] === "\n") { - if (escapeUrl) { - returnValue += wrapAnsiHyperlink(""); - } - if (escapeCode && code) { - returnValue += wrapAnsiCode(code); - } - } else if (character === "\n") { - if (escapeCode && code) { - returnValue += wrapAnsiCode(escapeCode); - } - if (escapeUrl) { - returnValue += wrapAnsiHyperlink(escapeUrl); - } - } - preStringIndex += character.length; - } - return returnValue; -}; -function wrapAnsi(string, columns, options) { - return String(string).normalize().replaceAll("\r\n", "\n").split("\n").map((line) => exec(line, columns, options)).join("\n"); -} - -// node_modules/.pnpm/cliui@9.0.1/node_modules/cliui/index.mjs -function ui(opts) { - return cliui(opts, { - stringWidth, - stripAnsi, - wrap: wrapAnsi - }); -} - -// node_modules/.pnpm/escalade@3.2.0/node_modules/escalade/sync/index.mjs -init_esm_shims(); -function sync_default(start, callback) { - let dir = resolve(".", start); - let tmp, stats = statSync(dir); - if (!stats.isDirectory()) { - dir = dirname(dir); - } - while (true) { - tmp = callback(dir, readdirSync(dir)); - if (tmp) return resolve(dir, tmp); - dir = dirname(tmp = dir); - if (tmp === dir) break; - } -} - -// node_modules/.pnpm/yargs-parser@22.0.0/node_modules/yargs-parser/build/lib/index.js -init_esm_shims(); - -// node_modules/.pnpm/yargs-parser@22.0.0/node_modules/yargs-parser/build/lib/string-utils.js -init_esm_shims(); -function camelCase(str2) { - const isCamelCase = str2 !== str2.toLowerCase() && str2 !== str2.toUpperCase(); - if (!isCamelCase) { - str2 = str2.toLowerCase(); - } - if (str2.indexOf("-") === -1 && str2.indexOf("_") === -1) { - return str2; - } else { - let camelcase = ""; - let nextChrUpper = false; - const leadingHyphens = str2.match(/^-+/); - for (let i2 = leadingHyphens ? leadingHyphens[0].length : 0; i2 < str2.length; i2++) { - let chr = str2.charAt(i2); - if (nextChrUpper) { - nextChrUpper = false; - chr = chr.toUpperCase(); - } - if (i2 !== 0 && (chr === "-" || chr === "_")) { - nextChrUpper = true; - } else if (chr !== "-" && chr !== "_") { - camelcase += chr; - } - } - return camelcase; - } -} -function decamelize(str2, joinString) { - const lowercase = str2.toLowerCase(); - joinString = joinString || "-"; - let notCamelcase = ""; - for (let i2 = 0; i2 < str2.length; i2++) { - const chrLower = lowercase.charAt(i2); - const chrString = str2.charAt(i2); - if (chrLower !== chrString && i2 > 0) { - notCamelcase += `${joinString}${lowercase.charAt(i2)}`; - } else { - notCamelcase += chrString; - } - } - return notCamelcase; -} -function looksLikeNumber(x2) { - if (x2 === null || x2 === void 0) - return false; - if (typeof x2 === "number") - return true; - if (/^0x[0-9a-f]+$/i.test(x2)) - return true; - if (/^0[^.]/.test(x2)) - return false; - return /^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x2); -} - -// node_modules/.pnpm/yargs-parser@22.0.0/node_modules/yargs-parser/build/lib/yargs-parser.js -init_esm_shims(); - -// node_modules/.pnpm/yargs-parser@22.0.0/node_modules/yargs-parser/build/lib/tokenize-arg-string.js -init_esm_shims(); -function tokenizeArgString(argString) { - if (Array.isArray(argString)) { - return argString.map((e2) => typeof e2 !== "string" ? e2 + "" : e2); - } - argString = argString.trim(); - let i2 = 0; - let prevC = null; - let c2 = null; - let opening = null; - const args = []; - for (let ii = 0; ii < argString.length; ii++) { - prevC = c2; - c2 = argString.charAt(ii); - if (c2 === " " && !opening) { - if (!(prevC === " ")) { - i2++; - } - continue; - } - if (c2 === opening) { - opening = null; - } else if ((c2 === "'" || c2 === '"') && !opening) { - opening = c2; - } - if (!args[i2]) - args[i2] = ""; - args[i2] += c2; - } - return args; -} - -// node_modules/.pnpm/yargs-parser@22.0.0/node_modules/yargs-parser/build/lib/yargs-parser-types.js -init_esm_shims(); -var DefaultValuesForTypeKey; -(function(DefaultValuesForTypeKey2) { - DefaultValuesForTypeKey2["BOOLEAN"] = "boolean"; - DefaultValuesForTypeKey2["STRING"] = "string"; - DefaultValuesForTypeKey2["NUMBER"] = "number"; - DefaultValuesForTypeKey2["ARRAY"] = "array"; -})(DefaultValuesForTypeKey || (DefaultValuesForTypeKey = {})); - -// node_modules/.pnpm/yargs-parser@22.0.0/node_modules/yargs-parser/build/lib/yargs-parser.js -var mixin2; -var YargsParser = class { - constructor(_mixin) { - mixin2 = _mixin; - } - parse(argsInput, options) { - const opts = Object.assign({ - alias: void 0, - array: void 0, - boolean: void 0, - config: void 0, - configObjects: void 0, - configuration: void 0, - coerce: void 0, - count: void 0, - default: void 0, - envPrefix: void 0, - narg: void 0, - normalize: void 0, - string: void 0, - number: void 0, - __: void 0, - key: void 0 - }, options); - const args = tokenizeArgString(argsInput); - const inputIsString = typeof argsInput === "string"; - const aliases = combineAliases(Object.assign(/* @__PURE__ */ Object.create(null), opts.alias)); - const configuration = Object.assign({ - "boolean-negation": true, - "camel-case-expansion": true, - "combine-arrays": false, - "dot-notation": true, - "duplicate-arguments-array": true, - "flatten-duplicate-arrays": true, - "greedy-arrays": true, - "halt-at-non-option": false, - "nargs-eats-options": false, - "negation-prefix": "no-", - "parse-numbers": true, - "parse-positional-numbers": true, - "populate--": false, - "set-placeholder-key": false, - "short-option-groups": true, - "strip-aliased": false, - "strip-dashed": false, - "unknown-options-as-args": false - }, opts.configuration); - const defaults = Object.assign(/* @__PURE__ */ Object.create(null), opts.default); - const configObjects = opts.configObjects || []; - const envPrefix = opts.envPrefix; - const notFlagsOption = configuration["populate--"]; - const notFlagsArgv = notFlagsOption ? "--" : "_"; - const newAliases = /* @__PURE__ */ Object.create(null); - const defaulted = /* @__PURE__ */ Object.create(null); - const __ = opts.__ || mixin2.format; - const flags = { - aliases: /* @__PURE__ */ Object.create(null), - arrays: /* @__PURE__ */ Object.create(null), - bools: /* @__PURE__ */ Object.create(null), - strings: /* @__PURE__ */ Object.create(null), - numbers: /* @__PURE__ */ Object.create(null), - counts: /* @__PURE__ */ Object.create(null), - normalize: /* @__PURE__ */ Object.create(null), - configs: /* @__PURE__ */ Object.create(null), - nargs: /* @__PURE__ */ Object.create(null), - coercions: /* @__PURE__ */ Object.create(null), - keys: [] - }; - const negative = /^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/; - const negatedBoolean = new RegExp("^--" + configuration["negation-prefix"] + "(.+)"); - [].concat(opts.array || []).filter(Boolean).forEach(function(opt) { - const key = typeof opt === "object" ? opt.key : opt; - const assignment = Object.keys(opt).map(function(key2) { - const arrayFlagKeys = { - boolean: "bools", - string: "strings", - number: "numbers" - }; - return arrayFlagKeys[key2]; - }).filter(Boolean).pop(); - if (assignment) { - flags[assignment][key] = true; - } - flags.arrays[key] = true; - flags.keys.push(key); - }); - [].concat(opts.boolean || []).filter(Boolean).forEach(function(key) { - flags.bools[key] = true; - flags.keys.push(key); - }); - [].concat(opts.string || []).filter(Boolean).forEach(function(key) { - flags.strings[key] = true; - flags.keys.push(key); - }); - [].concat(opts.number || []).filter(Boolean).forEach(function(key) { - flags.numbers[key] = true; - flags.keys.push(key); - }); - [].concat(opts.count || []).filter(Boolean).forEach(function(key) { - flags.counts[key] = true; - flags.keys.push(key); - }); - [].concat(opts.normalize || []).filter(Boolean).forEach(function(key) { - flags.normalize[key] = true; - flags.keys.push(key); - }); - if (typeof opts.narg === "object") { - Object.entries(opts.narg).forEach(([key, value]) => { - if (typeof value === "number") { - flags.nargs[key] = value; - flags.keys.push(key); + parseDateMonth() { + if (this.char === CHAR_HYPHEN) { + if (this.state.buf.length < 2) { + throw this.error(new TomlError("Months less than 10 must be zero padded to two characters")); + } + this.state.result += "-" + this.state.buf; + this.state.buf = ""; + return this.next(this.parseDateDay); + } else if (isDigit(this.char)) { + this.consume(); + } else { + throw this.error(new TomlError("Incomplete datetime")); + } } - }); - } - if (typeof opts.coerce === "object") { - Object.entries(opts.coerce).forEach(([key, value]) => { - if (typeof value === "function") { - flags.coercions[key] = value; - flags.keys.push(key); + parseDateDay() { + if (this.char === CHAR_T || this.char === CHAR_SP) { + if (this.state.buf.length < 2) { + throw this.error(new TomlError("Days less than 10 must be zero padded to two characters")); + } + this.state.result += "-" + this.state.buf; + this.state.buf = ""; + return this.next(this.parseStartTimeHour); + } else if (this.atEndOfWord()) { + return this.returnNow(createDate(this.state.result + "-" + this.state.buf)); + } else if (isDigit(this.char)) { + this.consume(); + } else { + throw this.error(new TomlError("Incomplete datetime")); + } } - }); - } - if (typeof opts.config !== "undefined") { - if (Array.isArray(opts.config) || typeof opts.config === "string") { - [].concat(opts.config).filter(Boolean).forEach(function(key) { - flags.configs[key] = true; - }); - } else if (typeof opts.config === "object") { - Object.entries(opts.config).forEach(([key, value]) => { - if (typeof value === "boolean" || typeof value === "function") { - flags.configs[key] = value; + parseStartTimeHour() { + if (this.atEndOfWord()) { + return this.returnNow(createDate(this.state.result)); + } else { + return this.goto(this.parseTimeHour); } - }); - } - } - extendAliases(opts.key, aliases, opts.default, flags.arrays); - Object.keys(defaults).forEach(function(key) { - (flags.aliases[key] || []).forEach(function(alias) { - defaults[alias] = defaults[key]; - }); - }); - let error = null; - checkConfiguration(); - let notFlags = []; - const argv = Object.assign(/* @__PURE__ */ Object.create(null), { _: [] }); - const argvReturn = {}; - for (let i2 = 0; i2 < args.length; i2++) { - const arg = args[i2]; - const truncatedArg = arg.replace(/^-{3,}/, "---"); - let broken; - let key; - let letters; - let m2; - let next; - let value; - if (arg !== "--" && /^-/.test(arg) && isUnknownOptionAsArg(arg)) { - pushPositional(arg); - } else if (truncatedArg.match(/^---+(=|$)/)) { - pushPositional(arg); - continue; - } else if (arg.match(/^--.+=/) || !configuration["short-option-groups"] && arg.match(/^-.+=/)) { - m2 = arg.match(/^--?([^=]+)=([\s\S]*)$/); - if (m2 !== null && Array.isArray(m2) && m2.length >= 3) { - if (checkAllAliases(m2[1], flags.arrays)) { - i2 = eatArray(i2, m2[1], args, m2[2]); - } else if (checkAllAliases(m2[1], flags.nargs) !== false) { - i2 = eatNargs(i2, m2[1], args, m2[2]); + } + parseTimeHour() { + if (this.char === CHAR_COLON) { + if (this.state.buf.length < 2) { + throw this.error(new TomlError("Hours less than 10 must be zero padded to two characters")); + } + this.state.result += "T" + this.state.buf; + this.state.buf = ""; + return this.next(this.parseTimeMin); + } else if (isDigit(this.char)) { + this.consume(); } else { - setArg(m2[1], m2[2], true); - } - } - } else if (arg.match(negatedBoolean) && configuration["boolean-negation"]) { - m2 = arg.match(negatedBoolean); - if (m2 !== null && Array.isArray(m2) && m2.length >= 2) { - key = m2[1]; - setArg(key, checkAllAliases(key, flags.arrays) ? [false] : false); - } - } else if (arg.match(/^--.+/) || !configuration["short-option-groups"] && arg.match(/^-[^-]+/)) { - m2 = arg.match(/^--?(.+)/); - if (m2 !== null && Array.isArray(m2) && m2.length >= 2) { - key = m2[1]; - if (checkAllAliases(key, flags.arrays)) { - i2 = eatArray(i2, key, args); - } else if (checkAllAliases(key, flags.nargs) !== false) { - i2 = eatNargs(i2, key, args); + throw this.error(new TomlError("Incomplete datetime")); + } + } + parseTimeMin() { + if (this.state.buf.length < 2 && isDigit(this.char)) { + this.consume(); + } else if (this.state.buf.length === 2 && this.char === CHAR_COLON) { + this.state.result += ":" + this.state.buf; + this.state.buf = ""; + return this.next(this.parseTimeSec); } else { - next = args[i2 + 1]; - if (next !== void 0 && (!next.match(/^-/) || next.match(negative)) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) { - setArg(key, next); - i2++; - } else if (/^(true|false)$/.test(next)) { - setArg(key, next); - i2++; - } else { - setArg(key, defaultValue(key)); - } + throw this.error(new TomlError("Incomplete datetime")); } } - } else if (arg.match(/^-.\..+=/)) { - m2 = arg.match(/^-([^=]+)=([\s\S]*)$/); - if (m2 !== null && Array.isArray(m2) && m2.length >= 3) { - setArg(m2[1], m2[2]); - } - } else if (arg.match(/^-.\..+/) && !arg.match(negative)) { - next = args[i2 + 1]; - m2 = arg.match(/^-(.\..+)/); - if (m2 !== null && Array.isArray(m2) && m2.length >= 2) { - key = m2[1]; - if (next !== void 0 && !next.match(/^-/) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) { - setArg(key, next); - i2++; - } else { - setArg(key, defaultValue(key)); - } - } - } else if (arg.match(/^-[^-]+/) && !arg.match(negative)) { - letters = arg.slice(1, -1).split(""); - broken = false; - for (let j2 = 0; j2 < letters.length; j2++) { - next = arg.slice(j2 + 2); - if (letters[j2 + 1] && letters[j2 + 1] === "=") { - value = arg.slice(j2 + 3); - key = letters[j2]; - if (checkAllAliases(key, flags.arrays)) { - i2 = eatArray(i2, key, args, value); - } else if (checkAllAliases(key, flags.nargs) !== false) { - i2 = eatNargs(i2, key, args, value); - } else { - setArg(key, value); + parseTimeSec() { + if (isDigit(this.char)) { + this.consume(); + if (this.state.buf.length === 2) { + this.state.result += ":" + this.state.buf; + this.state.buf = ""; + return this.next(this.parseTimeZoneOrFraction); } - broken = true; - break; - } - if (next === "-") { - setArg(letters[j2], next); - continue; - } - if (/[A-Za-z]/.test(letters[j2]) && /^-?\d+(\.\d*)?(e-?\d+)?$/.test(next) && checkAllAliases(next, flags.bools) === false) { - setArg(letters[j2], next); - broken = true; - break; - } - if (letters[j2 + 1] && letters[j2 + 1].match(/\W/)) { - setArg(letters[j2], next); - broken = true; - break; } else { - setArg(letters[j2], defaultValue(letters[j2])); + throw this.error(new TomlError("Incomplete datetime")); } } - key = arg.slice(-1)[0]; - if (!broken && key !== "-") { - if (checkAllAliases(key, flags.arrays)) { - i2 = eatArray(i2, key, args); - } else if (checkAllAliases(key, flags.nargs) !== false) { - i2 = eatNargs(i2, key, args); - } else { - next = args[i2 + 1]; - if (next !== void 0 && (!/^(-|--)[^-]/.test(next) || next.match(negative)) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) { - setArg(key, next); - i2++; - } else if (/^(true|false)$/.test(next)) { - setArg(key, next); - i2++; - } else { - setArg(key, defaultValue(key)); + parseOnlyTimeHour() { + if (this.char === CHAR_COLON) { + if (this.state.buf.length < 2) { + throw this.error(new TomlError("Hours less than 10 must be zero padded to two characters")); } + this.state.result = this.state.buf; + this.state.buf = ""; + return this.next(this.parseOnlyTimeMin); + } else { + throw this.error(new TomlError("Incomplete time")); } } - } else if (arg.match(/^-[0-9]$/) && arg.match(negative) && checkAllAliases(arg.slice(1), flags.bools)) { - key = arg.slice(1); - setArg(key, defaultValue(key)); - } else if (arg === "--") { - notFlags = args.slice(i2 + 1); - break; - } else if (configuration["halt-at-non-option"]) { - notFlags = args.slice(i2); - break; - } else { - pushPositional(arg); - } - } - applyEnvVars(argv, true); - applyEnvVars(argv, false); - setConfig(argv); - setConfigObjects(); - applyDefaultsAndAliases(argv, flags.aliases, defaults, true); - applyCoercions(argv); - if (configuration["set-placeholder-key"]) - setPlaceholderKeys(argv); - Object.keys(flags.counts).forEach(function(key) { - if (!hasKey2(argv, key.split("."))) - setArg(key, 0); - }); - if (notFlagsOption && notFlags.length) - argv[notFlagsArgv] = []; - notFlags.forEach(function(key) { - argv[notFlagsArgv].push(key); - }); - if (configuration["camel-case-expansion"] && configuration["strip-dashed"]) { - Object.keys(argv).filter((key) => key !== "--" && key.includes("-")).forEach((key) => { - delete argv[key]; - }); - } - if (configuration["strip-aliased"]) { - [].concat(...Object.keys(aliases).map((k) => aliases[k])).forEach((alias) => { - if (configuration["camel-case-expansion"] && alias.includes("-")) { - delete argv[alias.split(".").map((prop) => camelCase(prop)).join(".")]; - } - delete argv[alias]; - }); - } - function pushPositional(arg) { - const maybeCoercedNumber = maybeCoerceNumber("_", arg); - if (typeof maybeCoercedNumber === "string" || typeof maybeCoercedNumber === "number") { - argv._.push(maybeCoercedNumber); - } - } - function eatNargs(i2, key, args2, argAfterEqualSign) { - let ii; - let toEat = checkAllAliases(key, flags.nargs); - toEat = typeof toEat !== "number" || isNaN(toEat) ? 1 : toEat; - if (toEat === 0) { - if (!isUndefined(argAfterEqualSign)) { - error = Error(__("Argument unexpected for: %s", key)); - } - setArg(key, defaultValue(key)); - return i2; - } - let available = isUndefined(argAfterEqualSign) ? 0 : 1; - if (configuration["nargs-eats-options"]) { - if (args2.length - (i2 + 1) + available < toEat) { - error = Error(__("Not enough arguments following: %s", key)); - } - available = toEat; - } else { - for (ii = i2 + 1; ii < args2.length; ii++) { - if (!args2[ii].match(/^-[^0-9]/) || args2[ii].match(negative) || isUnknownOptionAsArg(args2[ii])) - available++; - else - break; - } - if (available < toEat) - error = Error(__("Not enough arguments following: %s", key)); - } - let consumed = Math.min(available, toEat); - if (!isUndefined(argAfterEqualSign) && consumed > 0) { - setArg(key, argAfterEqualSign); - consumed--; - } - for (ii = i2 + 1; ii < consumed + i2 + 1; ii++) { - setArg(key, args2[ii]); - } - return i2 + consumed; - } - function eatArray(i2, key, args2, argAfterEqualSign) { - let argsToSet = []; - let next = argAfterEqualSign || args2[i2 + 1]; - const nargsCount = checkAllAliases(key, flags.nargs); - if (checkAllAliases(key, flags.bools) && !/^(true|false)$/.test(next)) { - argsToSet.push(true); - } else if (isUndefined(next) || isUndefined(argAfterEqualSign) && /^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next)) { - if (defaults[key] !== void 0) { - const defVal = defaults[key]; - argsToSet = Array.isArray(defVal) ? defVal : [defVal]; - } - } else { - if (!isUndefined(argAfterEqualSign)) { - argsToSet.push(processValue(key, argAfterEqualSign, true)); - } - for (let ii = i2 + 1; ii < args2.length; ii++) { - if (!configuration["greedy-arrays"] && argsToSet.length > 0 || nargsCount && typeof nargsCount === "number" && argsToSet.length >= nargsCount) - break; - next = args2[ii]; - if (/^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next)) - break; - i2 = ii; - argsToSet.push(processValue(key, next, inputIsString)); - } - } - if (typeof nargsCount === "number" && (nargsCount && argsToSet.length < nargsCount || isNaN(nargsCount) && argsToSet.length === 0)) { - error = Error(__("Not enough arguments following: %s", key)); - } - setArg(key, argsToSet); - return i2; - } - function setArg(key, val, shouldStripQuotes = inputIsString) { - if (/-/.test(key) && configuration["camel-case-expansion"]) { - const alias = key.split(".").map(function(prop) { - return camelCase(prop); - }).join("."); - addNewAlias(key, alias); - } - const value = processValue(key, val, shouldStripQuotes); - const splitKey = key.split("."); - setKey(argv, splitKey, value); - if (flags.aliases[key]) { - flags.aliases[key].forEach(function(x2) { - const keyProperties = x2.split("."); - setKey(argv, keyProperties, value); - }); - } - if (splitKey.length > 1 && configuration["dot-notation"]) { - (flags.aliases[splitKey[0]] || []).forEach(function(x2) { - let keyProperties = x2.split("."); - const a2 = [].concat(splitKey); - a2.shift(); - keyProperties = keyProperties.concat(a2); - if (!(flags.aliases[key] || []).includes(keyProperties.join("."))) { - setKey(argv, keyProperties, value); + parseOnlyTimeMin() { + if (this.state.buf.length < 2 && isDigit(this.char)) { + this.consume(); + } else if (this.state.buf.length === 2 && this.char === CHAR_COLON) { + this.state.result += ":" + this.state.buf; + this.state.buf = ""; + return this.next(this.parseOnlyTimeSec); + } else { + throw this.error(new TomlError("Incomplete time")); } - }); - } - if (checkAllAliases(key, flags.normalize) && !checkAllAliases(key, flags.arrays)) { - const keys = [key].concat(flags.aliases[key] || []); - keys.forEach(function(key2) { - Object.defineProperty(argvReturn, key2, { - enumerable: true, - get() { - return val; - }, - set(value2) { - val = typeof value2 === "string" ? mixin2.normalize(value2) : value2; - } - }); - }); - } - } - function addNewAlias(key, alias) { - if (!(flags.aliases[key] && flags.aliases[key].length)) { - flags.aliases[key] = [alias]; - newAliases[alias] = true; - } - if (!(flags.aliases[alias] && flags.aliases[alias].length)) { - addNewAlias(alias, key); - } - } - function processValue(key, val, shouldStripQuotes) { - if (shouldStripQuotes) { - val = stripQuotes(val); - } - if (checkAllAliases(key, flags.bools) || checkAllAliases(key, flags.counts)) { - if (typeof val === "string") - val = val === "true"; - } - let value = Array.isArray(val) ? val.map(function(v2) { - return maybeCoerceNumber(key, v2); - }) : maybeCoerceNumber(key, val); - if (checkAllAliases(key, flags.counts) && (isUndefined(value) || typeof value === "boolean")) { - value = increment(); - } - if (checkAllAliases(key, flags.normalize) && checkAllAliases(key, flags.arrays)) { - if (Array.isArray(val)) - value = val.map((val2) => { - return mixin2.normalize(val2); - }); - else - value = mixin2.normalize(val); - } - return value; - } - function maybeCoerceNumber(key, value) { - if (!configuration["parse-positional-numbers"] && key === "_") - return value; - if (!checkAllAliases(key, flags.strings) && !checkAllAliases(key, flags.bools) && !Array.isArray(value)) { - const shouldCoerceNumber = looksLikeNumber(value) && configuration["parse-numbers"] && Number.isSafeInteger(Math.floor(parseFloat(`${value}`))); - if (shouldCoerceNumber || !isUndefined(value) && checkAllAliases(key, flags.numbers)) { - value = Number(value); } - } - return value; - } - function setConfig(argv2) { - const configLookup = /* @__PURE__ */ Object.create(null); - applyDefaultsAndAliases(configLookup, flags.aliases, defaults); - Object.keys(flags.configs).forEach(function(configKey) { - const configPath = argv2[configKey] || configLookup[configKey]; - if (configPath) { - try { - let config = null; - const resolvedConfigPath = mixin2.resolve(mixin2.cwd(), configPath); - const resolveConfig = flags.configs[configKey]; - if (typeof resolveConfig === "function") { - try { - config = resolveConfig(resolvedConfigPath); - } catch (e2) { - config = e2; - } - if (config instanceof Error) { - error = config; - return; - } - } else { - config = mixin2.require(resolvedConfigPath); + parseOnlyTimeSec() { + if (isDigit(this.char)) { + this.consume(); + if (this.state.buf.length === 2) { + return this.next(this.parseOnlyTimeFractionMaybe); } - setConfigObject(config); - } catch (ex) { - if (ex.name === "PermissionDenied") - error = ex; - else if (argv2[configKey]) - error = Error(__("Invalid JSON config file: %s", configPath)); + } else { + throw this.error(new TomlError("Incomplete time")); } } - }); - } - function setConfigObject(config, prev) { - Object.keys(config).forEach(function(key) { - const value = config[key]; - const fullKey = prev ? prev + "." + key : key; - if (typeof value === "object" && value !== null && !Array.isArray(value) && configuration["dot-notation"]) { - setConfigObject(value, fullKey); - } else { - if (!hasKey2(argv, fullKey.split(".")) || checkAllAliases(fullKey, flags.arrays) && configuration["combine-arrays"]) { - setArg(fullKey, value); + parseOnlyTimeFractionMaybe() { + this.state.result += ":" + this.state.buf; + if (this.char === CHAR_PERIOD) { + this.state.buf = ""; + this.next(this.parseOnlyTimeFraction); + } else { + return this.return(createTime(this.state.result)); } } - }); - } - function setConfigObjects() { - if (typeof configObjects !== "undefined") { - configObjects.forEach(function(configObject) { - setConfigObject(configObject); - }); - } - } - function applyEnvVars(argv2, configOnly) { - if (typeof envPrefix === "undefined") - return; - const prefix = typeof envPrefix === "string" ? envPrefix : ""; - const env2 = mixin2.env(); - Object.keys(env2).forEach(function(envVar) { - if (prefix === "" || envVar.lastIndexOf(prefix, 0) === 0) { - const keys = envVar.split("__").map(function(key, i2) { - if (i2 === 0) { - key = key.substring(prefix.length); - } - return camelCase(key); - }); - if ((configOnly && flags.configs[keys.join(".")] || !configOnly) && !hasKey2(argv2, keys)) { - setArg(keys.join("."), env2[envVar]); + parseOnlyTimeFraction() { + if (isDigit(this.char)) { + this.consume(); + } else if (this.atEndOfWord()) { + if (this.state.buf.length === 0) throw this.error(new TomlError("Expected digit in milliseconds")); + return this.returnNow(createTime(this.state.result + "." + this.state.buf)); + } else { + throw this.error(new TomlError("Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z")); } } - }); - } - function applyCoercions(argv2) { - let coerce; - const applied = /* @__PURE__ */ new Set(); - Object.keys(argv2).forEach(function(key) { - if (!applied.has(key)) { - coerce = checkAllAliases(key, flags.coercions); - if (typeof coerce === "function") { - try { - const value = maybeCoerceNumber(key, coerce(argv2[key])); - [].concat(flags.aliases[key] || [], key).forEach((ali) => { - applied.add(ali); - argv2[ali] = value; - }); - } catch (err) { - error = err; - } + parseTimeZoneOrFraction() { + if (this.char === CHAR_PERIOD) { + this.consume(); + this.next(this.parseDateTimeFraction); + } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) { + this.consume(); + this.next(this.parseTimeZoneHour); + } else if (this.char === CHAR_Z) { + this.consume(); + return this.return(createDateTime(this.state.result + this.state.buf)); + } else if (this.atEndOfWord()) { + return this.returnNow(createDateTimeFloat(this.state.result + this.state.buf)); + } else { + throw this.error(new TomlError("Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z")); } } - }); - } - function setPlaceholderKeys(argv2) { - flags.keys.forEach((key) => { - if (~key.indexOf(".")) - return; - if (typeof argv2[key] === "undefined") - argv2[key] = void 0; - }); - return argv2; - } - function applyDefaultsAndAliases(obj, aliases2, defaults2, canLog = false) { - Object.keys(defaults2).forEach(function(key) { - if (!hasKey2(obj, key.split("."))) { - setKey(obj, key.split("."), defaults2[key]); - if (canLog) - defaulted[key] = true; - (aliases2[key] || []).forEach(function(x2) { - if (hasKey2(obj, x2.split("."))) - return; - setKey(obj, x2.split("."), defaults2[key]); - }); - } - }); - } - function hasKey2(obj, keys) { - let o2 = obj; - if (!configuration["dot-notation"]) - keys = [keys.join(".")]; - keys.slice(0, -1).forEach(function(key2) { - o2 = o2[key2] || {}; - }); - const key = keys[keys.length - 1]; - if (typeof o2 !== "object") - return false; - else - return key in o2; - } - function setKey(obj, keys, value) { - let o2 = obj; - if (!configuration["dot-notation"]) - keys = [keys.join(".")]; - keys.slice(0, -1).forEach(function(key2) { - key2 = sanitizeKey(key2); - if (typeof o2 === "object" && o2[key2] === void 0) { - o2[key2] = {}; - } - if (typeof o2[key2] !== "object" || Array.isArray(o2[key2])) { - if (Array.isArray(o2[key2])) { - o2[key2].push({}); + parseDateTimeFraction() { + if (isDigit(this.char)) { + this.consume(); + } else if (this.state.buf.length === 1) { + throw this.error(new TomlError("Expected digit in milliseconds")); + } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) { + this.consume(); + this.next(this.parseTimeZoneHour); + } else if (this.char === CHAR_Z) { + this.consume(); + return this.return(createDateTime(this.state.result + this.state.buf)); + } else if (this.atEndOfWord()) { + return this.returnNow(createDateTimeFloat(this.state.result + this.state.buf)); } else { - o2[key2] = [o2[key2], {}]; + throw this.error(new TomlError("Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z")); } - o2 = o2[key2][o2[key2].length - 1]; - } else { - o2 = o2[key2]; } - }); - const key = sanitizeKey(keys[keys.length - 1]); - const isTypeArray = checkAllAliases(keys.join("."), flags.arrays); - const isValueArray = Array.isArray(value); - let duplicate = configuration["duplicate-arguments-array"]; - if (!duplicate && checkAllAliases(key, flags.nargs)) { - duplicate = true; - if (!isUndefined(o2[key]) && flags.nargs[key] === 1 || Array.isArray(o2[key]) && o2[key].length === flags.nargs[key]) { - o2[key] = void 0; - } - } - if (value === increment()) { - o2[key] = increment(o2[key]); - } else if (Array.isArray(o2[key])) { - if (duplicate && isTypeArray && isValueArray) { - o2[key] = configuration["flatten-duplicate-arrays"] ? o2[key].concat(value) : (Array.isArray(o2[key][0]) ? o2[key] : [o2[key]]).concat([value]); - } else if (!duplicate && Boolean(isTypeArray) === Boolean(isValueArray)) { - o2[key] = value; - } else { - o2[key] = o2[key].concat([value]); + parseTimeZoneHour() { + if (isDigit(this.char)) { + this.consume(); + if (/\d\d$/.test(this.state.buf)) return this.next(this.parseTimeZoneSep); + } else { + throw this.error(new TomlError("Unexpected character in datetime, expected digit")); + } } - } else if (o2[key] === void 0 && isTypeArray) { - o2[key] = isValueArray ? value : [value]; - } else if (duplicate && !(o2[key] === void 0 || checkAllAliases(key, flags.counts) || checkAllAliases(key, flags.bools))) { - o2[key] = [o2[key], value]; - } else { - o2[key] = value; - } - } - function extendAliases(...args2) { - args2.forEach(function(obj) { - Object.keys(obj || {}).forEach(function(key) { - if (flags.aliases[key]) - return; - flags.aliases[key] = [].concat(aliases[key] || []); - flags.aliases[key].concat(key).forEach(function(x2) { - if (/-/.test(x2) && configuration["camel-case-expansion"]) { - const c2 = camelCase(x2); - if (c2 !== key && flags.aliases[key].indexOf(c2) === -1) { - flags.aliases[key].push(c2); - newAliases[c2] = true; - } - } - }); - flags.aliases[key].concat(key).forEach(function(x2) { - if (x2.length > 1 && /[A-Z]/.test(x2) && configuration["camel-case-expansion"]) { - const c2 = decamelize(x2, "-"); - if (c2 !== key && flags.aliases[key].indexOf(c2) === -1) { - flags.aliases[key].push(c2); - newAliases[c2] = true; - } - } - }); - flags.aliases[key].forEach(function(x2) { - flags.aliases[x2] = [key].concat(flags.aliases[key].filter(function(y2) { - return x2 !== y2; - })); - }); - }); - }); - } - function checkAllAliases(key, flag) { - const toCheck = [].concat(flags.aliases[key] || [], key); - const keys = Object.keys(flag); - const setAlias = toCheck.find((key2) => keys.includes(key2)); - return setAlias ? flag[setAlias] : false; - } - function hasAnyFlag(key) { - const flagsKeys = Object.keys(flags); - const toCheck = [].concat(flagsKeys.map((k) => flags[k])); - return toCheck.some(function(flag) { - return Array.isArray(flag) ? flag.includes(key) : flag[key]; - }); - } - function hasFlagsMatching(arg, ...patterns) { - const toCheck = [].concat(...patterns); - return toCheck.some(function(pattern) { - const match = arg.match(pattern); - return match && hasAnyFlag(match[1]); - }); - } - function hasAllShortFlags(arg) { - if (arg.match(negative) || !arg.match(/^-[^-]+/)) { - return false; - } - let hasAllFlags = true; - let next; - const letters = arg.slice(1).split(""); - for (let j2 = 0; j2 < letters.length; j2++) { - next = arg.slice(j2 + 2); - if (!hasAnyFlag(letters[j2])) { - hasAllFlags = false; - break; + parseTimeZoneSep() { + if (this.char === CHAR_COLON) { + this.consume(); + this.next(this.parseTimeZoneMin); + } else { + throw this.error(new TomlError("Unexpected character in datetime, expected colon")); + } } - if (letters[j2 + 1] && letters[j2 + 1] === "=" || next === "-" || /[A-Za-z]/.test(letters[j2]) && /^-?\d+(\.\d*)?(e-?\d+)?$/.test(next) || letters[j2 + 1] && letters[j2 + 1].match(/\W/)) { - break; + parseTimeZoneMin() { + if (isDigit(this.char)) { + this.consume(); + if (/\d\d$/.test(this.state.buf)) return this.return(createDateTime(this.state.result + this.state.buf)); + } else { + throw this.error(new TomlError("Unexpected character in datetime, expected digit")); + } } - } - return hasAllFlags; - } - function isUnknownOptionAsArg(arg) { - return configuration["unknown-options-as-args"] && isUnknownOption(arg); - } - function isUnknownOption(arg) { - arg = arg.replace(/^-{3,}/, "--"); - if (arg.match(negative)) { - return false; - } - if (hasAllShortFlags(arg)) { - return false; - } - const flagWithEquals = /^-+([^=]+?)=[\s\S]*$/; - const normalFlag = /^-+([^=]+?)$/; - const flagEndingInHyphen = /^-+([^=]+?)-$/; - const flagEndingInDigits = /^-+([^=]+?\d+)$/; - const flagEndingInNonWordCharacters = /^-+([^=]+?)\W+.*$/; - return !hasFlagsMatching(arg, flagWithEquals, negatedBoolean, normalFlag, flagEndingInHyphen, flagEndingInDigits, flagEndingInNonWordCharacters); - } - function defaultValue(key) { - if (!checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts) && `${key}` in defaults) { - return defaults[key]; - } else { - return defaultForType(guessType2(key)); - } - } - function defaultForType(type2) { - const def = { - [DefaultValuesForTypeKey.BOOLEAN]: true, - [DefaultValuesForTypeKey.STRING]: "", - [DefaultValuesForTypeKey.NUMBER]: void 0, - [DefaultValuesForTypeKey.ARRAY]: [] - }; - return def[type2]; - } - function guessType2(key) { - let type2 = DefaultValuesForTypeKey.BOOLEAN; - if (checkAllAliases(key, flags.strings)) - type2 = DefaultValuesForTypeKey.STRING; - else if (checkAllAliases(key, flags.numbers)) - type2 = DefaultValuesForTypeKey.NUMBER; - else if (checkAllAliases(key, flags.bools)) - type2 = DefaultValuesForTypeKey.BOOLEAN; - else if (checkAllAliases(key, flags.arrays)) - type2 = DefaultValuesForTypeKey.ARRAY; - return type2; - } - function isUndefined(num) { - return num === void 0; - } - function checkConfiguration() { - Object.keys(flags.counts).find((key) => { - if (checkAllAliases(key, flags.arrays)) { - error = Error(__("Invalid configuration: %s, opts.count excludes opts.array.", key)); - return true; - } else if (checkAllAliases(key, flags.nargs)) { - error = Error(__("Invalid configuration: %s, opts.count excludes opts.narg.", key)); - return true; + /* BOOLEAN */ + parseBoolean() { + if (this.char === CHAR_t) { + this.consume(); + return this.next(this.parseTrue_r); + } else if (this.char === CHAR_f) { + this.consume(); + return this.next(this.parseFalse_a); + } } - return false; - }); - } - return { - aliases: Object.assign({}, flags.aliases), - argv: Object.assign(argvReturn, argv), - configuration, - defaulted: Object.assign({}, defaulted), - error, - newAliases: Object.assign({}, newAliases) - }; - } -}; -function combineAliases(aliases) { - const aliasArrays = []; - const combined = /* @__PURE__ */ Object.create(null); - let change = true; - Object.keys(aliases).forEach(function(key) { - aliasArrays.push([].concat(aliases[key], key)); - }); - while (change) { - change = false; - for (let i2 = 0; i2 < aliasArrays.length; i2++) { - for (let ii = i2 + 1; ii < aliasArrays.length; ii++) { - const intersect = aliasArrays[i2].filter(function(v2) { - return aliasArrays[ii].indexOf(v2) !== -1; - }); - if (intersect.length) { - aliasArrays[i2] = aliasArrays[i2].concat(aliasArrays[ii]); - aliasArrays.splice(ii, 1); - change = true; - break; + parseTrue_r() { + if (this.char === CHAR_r) { + this.consume(); + return this.next(this.parseTrue_u); + } else { + throw this.error(new TomlError("Invalid boolean, expected true or false")); + } } - } - } - } - aliasArrays.forEach(function(aliasArray) { - aliasArray = aliasArray.filter(function(v2, i2, self) { - return self.indexOf(v2) === i2; - }); - const lastAlias = aliasArray.pop(); - if (lastAlias !== void 0 && typeof lastAlias === "string") { - combined[lastAlias] = aliasArray; - } - }); - return combined; -} -function increment(orig) { - return orig !== void 0 ? orig + 1 : 1; -} -function sanitizeKey(key) { - if (key === "__proto__") - return "___proto___"; - return key; -} -function stripQuotes(val) { - return typeof val === "string" && (val[0] === "'" || val[0] === '"') && val[val.length - 1] === val[0] ? val.substring(1, val.length - 1) : val; -} -var _a; -var _b; -var _c; -var minNodeVersion = process && process.env && process.env.YARGS_MIN_NODE_VERSION ? Number(process.env.YARGS_MIN_NODE_VERSION) : 20; -var nodeVersion = (_b = (_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node) !== null && _b !== void 0 ? _b : (_c = process === null || process === void 0 ? void 0 : process.version) === null || _c === void 0 ? void 0 : _c.slice(1); -if (nodeVersion) { - const major = Number(nodeVersion.match(/^([^.]+)/)[1]); - if (major < minNodeVersion) { - throw Error(`yargs parser supports a minimum Node.js version of ${minNodeVersion}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`); - } -} -var env = process ? process.env : {}; -var require2 = createRequire ? createRequire(import.meta.url) : void 0; -var parser = new YargsParser({ - cwd: process.cwd, - env: () => { - return env; - }, - format, - normalize, - resolve: resolve, - require: (path4) => { - if (typeof require2 !== "undefined") { - return require2(path4); - } else if (path4.match(/\.json$/)) { - return JSON.parse(readFileSync(path4, "utf8")); - } else { - throw Error("only .json config files are supported in ESM"); - } - } -}); -var yargsParser = function Parser(args, opts) { - const result = parser.parse(args.slice(), opts); - return result.argv; -}; -yargsParser.detailed = function(args, opts) { - return parser.parse(args.slice(), opts); -}; -yargsParser.camelCase = camelCase; -yargsParser.decamelize = decamelize; -yargsParser.looksLikeNumber = looksLikeNumber; -var lib_default = yargsParser; - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/utils/process-argv.js -init_esm_shims(); -function getProcessArgvBinIndex() { - if (isBundledElectronApp()) - return 0; - return 1; -} -function isBundledElectronApp() { - return isElectronApp() && !process.defaultApp; -} -function isElectronApp() { - return !!process.versions.electron; -} -function hideBin(argv) { - return argv.slice(getProcessArgvBinIndex() + 1); -} -function getProcessArgvBin() { - return process.argv[getProcessArgvBinIndex()]; -} - -// node_modules/.pnpm/y18n@5.0.8/node_modules/y18n/index.mjs -init_esm_shims(); - -// node_modules/.pnpm/y18n@5.0.8/node_modules/y18n/build/lib/platform-shims/node.js -init_esm_shims(); -var node_default = { - fs: { - readFileSync: readFileSync, - writeFile - }, - format: format, - resolve: resolve, - exists: (file) => { - try { - return statSync(file).isFile(); - } catch (err) { - return false; - } - } -}; - -// node_modules/.pnpm/y18n@5.0.8/node_modules/y18n/build/lib/index.js -init_esm_shims(); -var shim; -var Y18N = class { - constructor(opts) { - opts = opts || {}; - this.directory = opts.directory || "./locales"; - this.updateFiles = typeof opts.updateFiles === "boolean" ? opts.updateFiles : true; - this.locale = opts.locale || "en"; - this.fallbackToLanguage = typeof opts.fallbackToLanguage === "boolean" ? opts.fallbackToLanguage : true; - this.cache = /* @__PURE__ */ Object.create(null); - this.writeQueue = []; - } - __(...args) { - if (typeof arguments[0] !== "string") { - return this._taggedLiteral(arguments[0], ...arguments); - } - const str2 = args.shift(); - let cb = function() { - }; - if (typeof args[args.length - 1] === "function") - cb = args.pop(); - cb = cb || function() { - }; - if (!this.cache[this.locale]) - this._readLocaleFile(); - if (!this.cache[this.locale][str2] && this.updateFiles) { - this.cache[this.locale][str2] = str2; - this._enqueueWrite({ - directory: this.directory, - locale: this.locale, - cb - }); - } else { - cb(); - } - return shim.format.apply(shim.format, [this.cache[this.locale][str2] || str2].concat(args)); - } - __n() { - const args = Array.prototype.slice.call(arguments); - const singular = args.shift(); - const plural = args.shift(); - const quantity = args.shift(); - let cb = function() { - }; - if (typeof args[args.length - 1] === "function") - cb = args.pop(); - if (!this.cache[this.locale]) - this._readLocaleFile(); - let str2 = quantity === 1 ? singular : plural; - if (this.cache[this.locale][singular]) { - const entry = this.cache[this.locale][singular]; - str2 = entry[quantity === 1 ? "one" : "other"]; - } - if (!this.cache[this.locale][singular] && this.updateFiles) { - this.cache[this.locale][singular] = { - one: singular, - other: plural - }; - this._enqueueWrite({ - directory: this.directory, - locale: this.locale, - cb - }); - } else { - cb(); - } - const values = [str2]; - if (~str2.indexOf("%d")) - values.push(quantity); - return shim.format.apply(shim.format, values.concat(args)); - } - setLocale(locale) { - this.locale = locale; - } - getLocale() { - return this.locale; - } - updateLocale(obj) { - if (!this.cache[this.locale]) - this._readLocaleFile(); - for (const key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - this.cache[this.locale][key] = obj[key]; - } - } - } - _taggedLiteral(parts, ...args) { - let str2 = ""; - parts.forEach(function(part, i2) { - const arg = args[i2 + 1]; - str2 += part; - if (typeof arg !== "undefined") { - str2 += "%s"; - } - }); - return this.__.apply(this, [str2].concat([].slice.call(args, 1))); - } - _enqueueWrite(work) { - this.writeQueue.push(work); - if (this.writeQueue.length === 1) - this._processWriteQueue(); - } - _processWriteQueue() { - const _this = this; - const work = this.writeQueue[0]; - const directory = work.directory; - const locale = work.locale; - const cb = work.cb; - const languageFile = this._resolveLocaleFile(directory, locale); - const serializedLocale = JSON.stringify(this.cache[locale], null, 2); - shim.fs.writeFile(languageFile, serializedLocale, "utf-8", function(err) { - _this.writeQueue.shift(); - if (_this.writeQueue.length > 0) - _this._processWriteQueue(); - cb(err); - }); - } - _readLocaleFile() { - let localeLookup = {}; - const languageFile = this._resolveLocaleFile(this.directory, this.locale); - try { - if (shim.fs.readFileSync) { - localeLookup = JSON.parse(shim.fs.readFileSync(languageFile, "utf-8")); - } - } catch (err) { - if (err instanceof SyntaxError) { - err.message = "syntax error in " + languageFile; - } - if (err.code === "ENOENT") - localeLookup = {}; - else - throw err; - } - this.cache[this.locale] = localeLookup; - } - _resolveLocaleFile(directory, locale) { - let file = shim.resolve(directory, "./", locale + ".json"); - if (this.fallbackToLanguage && !this._fileExistsSync(file) && ~locale.lastIndexOf("_")) { - const languageFile = shim.resolve(directory, "./", locale.split("_")[0] + ".json"); - if (this._fileExistsSync(languageFile)) - file = languageFile; - } - return file; - } - _fileExistsSync(file) { - return shim.exists(file); - } -}; -function y18n(opts, _shim) { - shim = _shim; - const y18n3 = new Y18N(opts); - return { - __: y18n3.__.bind(y18n3), - __n: y18n3.__n.bind(y18n3), - setLocale: y18n3.setLocale.bind(y18n3), - getLocale: y18n3.getLocale.bind(y18n3), - updateLocale: y18n3.updateLocale.bind(y18n3), - locale: y18n3.locale - }; -} - -// node_modules/.pnpm/y18n@5.0.8/node_modules/y18n/index.mjs -var y18n2 = (opts) => { - return y18n(opts, node_default); -}; -var y18n_default = y18n2; - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/lib/platform-shims/esm.mjs -var import_get_caller_file = __toESM(require_get_caller_file()); -var __dirname2 = fileURLToPath(import.meta.url); -var mainFilename = __dirname2.substring(0, __dirname2.lastIndexOf("node_modules")); -var require3 = createRequire(import.meta.url); -var esm_default = { - assert: { - notStrictEqual, - strictEqual - }, - cliui: ui, - findUp: sync_default, - getEnv: (key) => { - return process.env[key]; - }, - inspect, - getProcessArgvBin, - mainFilename: mainFilename || process.cwd(), - Parser: lib_default, - path: { - basename, - dirname: dirname, - extname, - relative, - resolve: resolve, - join - }, - process: { - argv: () => process.argv, - cwd: process.cwd, - emitWarning: (warning, type2) => process.emitWarning(warning, type2), - execPath: () => process.execPath, - exit: (code) => { - process.exit(code); - }, - nextTick: process.nextTick, - stdColumns: typeof process.stdout.columns !== "undefined" ? process.stdout.columns : null - }, - readFileSync: readFileSync, - readdirSync: readdirSync, - require: require3, - getCallerFile: () => { - const callerFile = (0, import_get_caller_file.default)(3); - return callerFile.match(/^file:\/\//) ? fileURLToPath(callerFile) : callerFile; - }, - stringWidth, - y18n: y18n_default({ - directory: resolve(__dirname2, "../../../locales"), - updateFiles: false - }) -}; - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/yargs-factory.js -init_esm_shims(); - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/command.js -init_esm_shims(); - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/typings/common-types.js -init_esm_shims(); -function assertNotStrictEqual(actual, expected, shim3, message) { - shim3.assert.notStrictEqual(actual, expected, message); -} -function assertSingleKey(actual, shim3) { - shim3.assert.strictEqual(typeof actual, "string"); -} -function objectKeys(object) { - return Object.keys(object); -} - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/utils/is-promise.js -init_esm_shims(); -function isPromise(maybePromise) { - return !!maybePromise && !!maybePromise.then && typeof maybePromise.then === "function"; -} - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/middleware.js -init_esm_shims(); - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/argsert.js -init_esm_shims(); - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/yerror.js -init_esm_shims(); -var YError = class _YError extends Error { - constructor(msg) { - super(msg || "yargs error"); - this.name = "YError"; - if (Error.captureStackTrace) { - Error.captureStackTrace(this, _YError); - } - } -}; - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/parse-command.js -init_esm_shims(); -function parseCommand(cmd) { - const extraSpacesStrippedCommand = cmd.replace(/\s{2,}/g, " "); - const splitCommand = extraSpacesStrippedCommand.split(/\s+(?![^[]*]|[^<]*>)/); - const bregex = /\.*[\][<>]/g; - const firstCommand = splitCommand.shift(); - if (!firstCommand) - throw new Error(`No command found in: ${cmd}`); - const parsedCommand = { - cmd: firstCommand.replace(bregex, ""), - demanded: [], - optional: [] - }; - splitCommand.forEach((cmd2, i2) => { - let variadic = false; - cmd2 = cmd2.replace(/\s/g, ""); - if (/\.+[\]>]/.test(cmd2) && i2 === splitCommand.length - 1) - variadic = true; - if (/^\[/.test(cmd2)) { - parsedCommand.optional.push({ - cmd: cmd2.replace(bregex, "").split("|"), - variadic - }); - } else { - parsedCommand.demanded.push({ - cmd: cmd2.replace(bregex, "").split("|"), - variadic - }); - } - }); - return parsedCommand; -} - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/argsert.js -var positionName = ["first", "second", "third", "fourth", "fifth", "sixth"]; -function argsert(arg1, arg2, arg3) { - function parseArgs() { - return typeof arg1 === "object" ? [{ demanded: [], optional: [] }, arg1, arg2] : [ - parseCommand(`cmd ${arg1}`), - arg2, - arg3 - ]; - } - try { - let position = 0; - const [parsed, callerArguments, _length] = parseArgs(); - const args = [].slice.call(callerArguments); - while (args.length && args[args.length - 1] === void 0) - args.pop(); - const length = _length || args.length; - if (length < parsed.demanded.length) { - throw new YError(`Not enough arguments provided. Expected ${parsed.demanded.length} but received ${args.length}.`); - } - const totalCommands = parsed.demanded.length + parsed.optional.length; - if (length > totalCommands) { - throw new YError(`Too many arguments provided. Expected max ${totalCommands} but received ${length}.`); - } - parsed.demanded.forEach((demanded) => { - const arg = args.shift(); - const observedType = guessType(arg); - const matchingTypes = demanded.cmd.filter((type2) => type2 === observedType || type2 === "*"); - if (matchingTypes.length === 0) - argumentTypeError(observedType, demanded.cmd, position); - position += 1; - }); - parsed.optional.forEach((optional) => { - if (args.length === 0) - return; - const arg = args.shift(); - const observedType = guessType(arg); - const matchingTypes = optional.cmd.filter((type2) => type2 === observedType || type2 === "*"); - if (matchingTypes.length === 0) - argumentTypeError(observedType, optional.cmd, position); - position += 1; - }); - } catch (err) { - console.warn(err.stack); - } -} -function guessType(arg) { - if (Array.isArray(arg)) { - return "array"; - } else if (arg === null) { - return "null"; - } - return typeof arg; -} -function argumentTypeError(observedType, allowedTypes, position) { - throw new YError(`Invalid ${positionName[position] || "manyith"} argument. Expected ${allowedTypes.join(" or ")} but received ${observedType}.`); -} - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/middleware.js -var GlobalMiddleware = class { - constructor(yargs) { - this.globalMiddleware = []; - this.frozens = []; - this.yargs = yargs; - } - addMiddleware(callback, applyBeforeValidation, global2 = true, mutates = false) { - argsert(" [boolean] [boolean] [boolean]", [callback, applyBeforeValidation, global2], arguments.length); - if (Array.isArray(callback)) { - for (let i2 = 0; i2 < callback.length; i2++) { - if (typeof callback[i2] !== "function") { - throw Error("middleware must be a function"); - } - const m2 = callback[i2]; - m2.applyBeforeValidation = applyBeforeValidation; - m2.global = global2; - } - Array.prototype.push.apply(this.globalMiddleware, callback); - } else if (typeof callback === "function") { - const m2 = callback; - m2.applyBeforeValidation = applyBeforeValidation; - m2.global = global2; - m2.mutates = mutates; - this.globalMiddleware.push(callback); - } - return this.yargs; - } - addCoerceMiddleware(callback, option) { - const aliases = this.yargs.getAliases(); - this.globalMiddleware = this.globalMiddleware.filter((m2) => { - const toCheck = [...aliases[option] || [], option]; - if (!m2.option) - return true; - else - return !toCheck.includes(m2.option); - }); - callback.option = option; - return this.addMiddleware(callback, true, true, true); - } - getMiddleware() { - return this.globalMiddleware; - } - freeze() { - this.frozens.push([...this.globalMiddleware]); - } - unfreeze() { - const frozen = this.frozens.pop(); - if (frozen !== void 0) - this.globalMiddleware = frozen; - } - reset() { - this.globalMiddleware = this.globalMiddleware.filter((m2) => m2.global); - } -}; -function commandMiddlewareFactory(commandMiddleware) { - if (!commandMiddleware) - return []; - return commandMiddleware.map((middleware) => { - middleware.applyBeforeValidation = false; - return middleware; - }); -} -function applyMiddleware(argv, yargs, middlewares, beforeValidation) { - return middlewares.reduce((acc, middleware) => { - if (middleware.applyBeforeValidation !== beforeValidation) { - return acc; - } - if (middleware.mutates) { - if (middleware.applied) - return acc; - middleware.applied = true; - } - if (isPromise(acc)) { - return acc.then((initialObj) => Promise.all([initialObj, middleware(initialObj, yargs)])).then(([initialObj, middlewareObj]) => Object.assign(initialObj, middlewareObj)); - } else { - const result = middleware(acc, yargs); - return isPromise(result) ? result.then((middlewareObj) => Object.assign(acc, middlewareObj)) : Object.assign(acc, result); - } - }, argv); -} - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/utils/maybe-async-result.js -init_esm_shims(); -function maybeAsyncResult(getResult, resultHandler, errorHandler = (err) => { - throw err; -}) { - try { - const result = isFunction(getResult) ? getResult() : getResult; - return isPromise(result) ? result.then((result2) => resultHandler(result2)) : resultHandler(result); - } catch (err) { - return errorHandler(err); - } -} -function isFunction(arg) { - return typeof arg === "function"; -} - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/command.js -var DEFAULT_MARKER = /(^\*)|(^\$0)/; -var CommandInstance = class { - constructor(usage2, validation2, globalMiddleware, shim3) { - this.requireCache = /* @__PURE__ */ new Set(); - this.handlers = {}; - this.aliasMap = {}; - this.frozens = []; - this.shim = shim3; - this.usage = usage2; - this.globalMiddleware = globalMiddleware; - this.validation = validation2; - } - addDirectory(dir, req, callerFile, opts) { - opts = opts || {}; - this.requireCache.add(callerFile); - const fullDirPath = this.shim.path.resolve(this.shim.path.dirname(callerFile), dir); - const files = this.shim.readdirSync(fullDirPath, { - recursive: opts.recurse ? true : false - }); - if (!Array.isArray(opts.extensions)) - opts.extensions = ["js"]; - const visit = typeof opts.visit === "function" ? opts.visit : (o2) => o2; - for (const fileb of files) { - const file = fileb.toString(); - if (opts.exclude) { - let exclude = false; - if (typeof opts.exclude === "function") { - exclude = opts.exclude(file); - } else { - exclude = opts.exclude.test(file); + parseTrue_u() { + if (this.char === CHAR_u) { + this.consume(); + return this.next(this.parseTrue_e); + } else { + throw this.error(new TomlError("Invalid boolean, expected true or false")); + } } - if (exclude) - continue; - } - if (opts.include) { - let include = false; - if (typeof opts.include === "function") { - include = opts.include(file); - } else { - include = opts.include.test(file); + parseTrue_e() { + if (this.char === CHAR_e) { + return this.return(true); + } else { + throw this.error(new TomlError("Invalid boolean, expected true or false")); + } } - if (!include) - continue; - } - let supportedExtension = false; - for (const ext of opts.extensions) { - if (file.endsWith(ext)) - supportedExtension = true; - } - if (supportedExtension) { - const joined = this.shim.path.join(fullDirPath, file); - const module2 = req(joined); - const extendableModule = Object.create(null, Object.getOwnPropertyDescriptors({ ...module2 })); - const visited = visit(extendableModule, joined, file); - if (visited) { - if (this.requireCache.has(joined)) - continue; - else - this.requireCache.add(joined); - if (!extendableModule.command) { - extendableModule.command = this.shim.path.basename(joined, this.shim.path.extname(joined)); + parseFalse_a() { + if (this.char === CHAR_a) { + this.consume(); + return this.next(this.parseFalse_l); + } else { + throw this.error(new TomlError("Invalid boolean, expected true or false")); } - this.addHandler(extendableModule); } - } - } - } - addHandler(cmd, description, builder, handler, commandMiddleware, deprecated) { - let aliases = []; - const middlewares = commandMiddlewareFactory(commandMiddleware); - handler = handler || (() => { - }); - if (Array.isArray(cmd)) { - if (isCommandAndAliases(cmd)) { - [cmd, ...aliases] = cmd; - } else { - for (const command2 of cmd) { - this.addHandler(command2); - } - } - } else if (isCommandHandlerDefinition(cmd)) { - let command2 = Array.isArray(cmd.command) || typeof cmd.command === "string" ? cmd.command : null; - if (command2 === null) { - throw new Error(`No command name given for module: ${this.shim.inspect(cmd)}`); - } - if (cmd.aliases) - command2 = [].concat(command2).concat(cmd.aliases); - this.addHandler(command2, this.extractDesc(cmd), cmd.builder, cmd.handler, cmd.middlewares, cmd.deprecated); - return; - } else if (isCommandBuilderDefinition(builder)) { - this.addHandler([cmd].concat(aliases), description, builder.builder, builder.handler, builder.middlewares, builder.deprecated); - return; - } - if (typeof cmd === "string") { - const parsedCommand = parseCommand(cmd); - aliases = aliases.map((alias) => parseCommand(alias).cmd); - let isDefault = false; - const parsedAliases = [parsedCommand.cmd].concat(aliases).filter((c2) => { - if (DEFAULT_MARKER.test(c2)) { - isDefault = true; - return false; + parseFalse_l() { + if (this.char === CHAR_l) { + this.consume(); + return this.next(this.parseFalse_s); + } else { + throw this.error(new TomlError("Invalid boolean, expected true or false")); + } } - return true; - }); - if (parsedAliases.length === 0 && isDefault) - parsedAliases.push("$0"); - if (isDefault) { - parsedCommand.cmd = parsedAliases[0]; - aliases = parsedAliases.slice(1); - cmd = cmd.replace(DEFAULT_MARKER, parsedCommand.cmd); - } - aliases.forEach((alias) => { - this.aliasMap[alias] = parsedCommand.cmd; - }); - if (description !== false) { - this.usage.command(cmd, description, isDefault, aliases, deprecated); - } - this.handlers[parsedCommand.cmd] = { - original: cmd, - description, - handler, - builder: builder || {}, - middlewares, - deprecated, - demanded: parsedCommand.demanded, - optional: parsedCommand.optional - }; - if (isDefault) - this.defaultCommand = this.handlers[parsedCommand.cmd]; - } - } - getCommandHandlers() { - return this.handlers; - } - getCommands() { - return Object.keys(this.handlers).concat(Object.keys(this.aliasMap)); - } - hasDefaultCommand() { - return !!this.defaultCommand; - } - runCommand(command2, yargs, parsed, commandIndex, helpOnly, helpOrVersionSet) { - const commandHandler = this.handlers[command2] || this.handlers[this.aliasMap[command2]] || this.defaultCommand; - const currentContext = yargs.getInternalMethods().getContext(); - const parentCommands = currentContext.commands.slice(); - const isDefaultCommand = !command2; - if (command2) { - currentContext.commands.push(command2); - currentContext.fullCommands.push(commandHandler.original); - } - const builderResult = this.applyBuilderUpdateUsageAndParse(isDefaultCommand, commandHandler, yargs, parsed.aliases, parentCommands, commandIndex, helpOnly, helpOrVersionSet); - return isPromise(builderResult) ? builderResult.then((result) => this.applyMiddlewareAndGetResult(isDefaultCommand, commandHandler, result.innerArgv, currentContext, helpOnly, result.aliases, yargs)) : this.applyMiddlewareAndGetResult(isDefaultCommand, commandHandler, builderResult.innerArgv, currentContext, helpOnly, builderResult.aliases, yargs); - } - applyBuilderUpdateUsageAndParse(isDefaultCommand, commandHandler, yargs, aliases, parentCommands, commandIndex, helpOnly, helpOrVersionSet) { - const builder = commandHandler.builder; - let innerYargs = yargs; - if (isCommandBuilderCallback(builder)) { - yargs.getInternalMethods().getUsageInstance().freeze(); - const builderOutput = builder(yargs.getInternalMethods().reset(aliases), helpOrVersionSet); - if (isPromise(builderOutput)) { - return builderOutput.then((output) => { - innerYargs = isYargsInstance(output) ? output : yargs; - return this.parseAndUpdateUsage(isDefaultCommand, commandHandler, innerYargs, parentCommands, commandIndex, helpOnly); - }); - } - } else if (isCommandBuilderOptionDefinitions(builder)) { - yargs.getInternalMethods().getUsageInstance().freeze(); - innerYargs = yargs.getInternalMethods().reset(aliases); - Object.keys(commandHandler.builder).forEach((key) => { - innerYargs.option(key, builder[key]); - }); - } - return this.parseAndUpdateUsage(isDefaultCommand, commandHandler, innerYargs, parentCommands, commandIndex, helpOnly); - } - parseAndUpdateUsage(isDefaultCommand, commandHandler, innerYargs, parentCommands, commandIndex, helpOnly) { - if (isDefaultCommand) - innerYargs.getInternalMethods().getUsageInstance().unfreeze(true); - if (this.shouldUpdateUsage(innerYargs)) { - innerYargs.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(parentCommands, commandHandler), commandHandler.description); - } - const innerArgv = innerYargs.getInternalMethods().runYargsParserAndExecuteCommands(null, void 0, true, commandIndex, helpOnly); - return isPromise(innerArgv) ? innerArgv.then((argv) => ({ - aliases: innerYargs.parsed.aliases, - innerArgv: argv - })) : { - aliases: innerYargs.parsed.aliases, - innerArgv - }; - } - shouldUpdateUsage(yargs) { - return !yargs.getInternalMethods().getUsageInstance().getUsageDisabled() && yargs.getInternalMethods().getUsageInstance().getUsage().length === 0; - } - usageFromParentCommandsCommandHandler(parentCommands, commandHandler) { - const c2 = DEFAULT_MARKER.test(commandHandler.original) ? commandHandler.original.replace(DEFAULT_MARKER, "").trim() : commandHandler.original; - const pc = parentCommands.filter((c3) => { - return !DEFAULT_MARKER.test(c3); - }); - pc.push(c2); - return `$0 ${pc.join(" ")}`; - } - handleValidationAndGetResult(isDefaultCommand, commandHandler, innerArgv, currentContext, aliases, yargs, middlewares, positionalMap) { - if (!yargs.getInternalMethods().getHasOutput()) { - const validation2 = yargs.getInternalMethods().runValidation(aliases, positionalMap, yargs.parsed.error, isDefaultCommand); - innerArgv = maybeAsyncResult(innerArgv, (result) => { - validation2(result); - return result; - }); - } - if (commandHandler.handler && !yargs.getInternalMethods().getHasOutput()) { - yargs.getInternalMethods().setHasOutput(); - const populateDoubleDash = !!yargs.getOptions().configuration["populate--"]; - yargs.getInternalMethods().postProcess(innerArgv, populateDoubleDash, false, false); - innerArgv = applyMiddleware(innerArgv, yargs, middlewares, false); - innerArgv = maybeAsyncResult(innerArgv, (result) => { - const handlerResult = commandHandler.handler(result); - return isPromise(handlerResult) ? handlerResult.then(() => result) : result; - }); - if (!isDefaultCommand) { - yargs.getInternalMethods().getUsageInstance().cacheHelpMessage(); - } - if (isPromise(innerArgv) && !yargs.getInternalMethods().hasParseCallback()) { - innerArgv.catch((error) => { - try { - yargs.getInternalMethods().getUsageInstance().fail(null, error); - } catch (_err) { + parseFalse_s() { + if (this.char === CHAR_s) { + this.consume(); + return this.next(this.parseFalse_e); + } else { + throw this.error(new TomlError("Invalid boolean, expected true or false")); } - }); - } - } - if (!isDefaultCommand) { - currentContext.commands.pop(); - currentContext.fullCommands.pop(); - } - return innerArgv; - } - applyMiddlewareAndGetResult(isDefaultCommand, commandHandler, innerArgv, currentContext, helpOnly, aliases, yargs) { - let positionalMap = {}; - if (helpOnly) - return innerArgv; - if (!yargs.getInternalMethods().getHasOutput()) { - positionalMap = this.populatePositionals(commandHandler, innerArgv, currentContext, yargs); - } - const middlewares = this.globalMiddleware.getMiddleware().slice(0).concat(commandHandler.middlewares); - const maybePromiseArgv = applyMiddleware(innerArgv, yargs, middlewares, true); - return isPromise(maybePromiseArgv) ? maybePromiseArgv.then((resolvedInnerArgv) => this.handleValidationAndGetResult(isDefaultCommand, commandHandler, resolvedInnerArgv, currentContext, aliases, yargs, middlewares, positionalMap)) : this.handleValidationAndGetResult(isDefaultCommand, commandHandler, maybePromiseArgv, currentContext, aliases, yargs, middlewares, positionalMap); - } - populatePositionals(commandHandler, argv, context, yargs) { - argv._ = argv._.slice(context.commands.length); - const demanded = commandHandler.demanded.slice(0); - const optional = commandHandler.optional.slice(0); - const positionalMap = {}; - this.validation.positionalCount(demanded.length, argv._.length); - while (demanded.length) { - const demand = demanded.shift(); - this.populatePositional(demand, argv, positionalMap); - } - while (optional.length) { - const maybe = optional.shift(); - this.populatePositional(maybe, argv, positionalMap); - } - argv._ = context.commands.concat(argv._.map((a2) => "" + a2)); - this.postProcessPositionals(argv, positionalMap, this.cmdToParseOptions(commandHandler.original), yargs); - return positionalMap; - } - populatePositional(positional, argv, positionalMap) { - const cmd = positional.cmd[0]; - if (positional.variadic) { - positionalMap[cmd] = argv._.splice(0).map(String); - } else { - if (argv._.length) - positionalMap[cmd] = [String(argv._.shift())]; - } - } - cmdToParseOptions(cmdString) { - const parseOptions = { - array: [], - default: {}, - alias: {}, - demand: {} - }; - const parsed = parseCommand(cmdString); - parsed.demanded.forEach((d2) => { - const [cmd, ...aliases] = d2.cmd; - if (d2.variadic) { - parseOptions.array.push(cmd); - parseOptions.default[cmd] = []; - } - parseOptions.alias[cmd] = aliases; - parseOptions.demand[cmd] = true; - }); - parsed.optional.forEach((o2) => { - const [cmd, ...aliases] = o2.cmd; - if (o2.variadic) { - parseOptions.array.push(cmd); - parseOptions.default[cmd] = []; - } - parseOptions.alias[cmd] = aliases; - }); - return parseOptions; - } - postProcessPositionals(argv, positionalMap, parseOptions, yargs) { - const options = Object.assign({}, yargs.getOptions()); - options.default = Object.assign(parseOptions.default, options.default); - for (const key of Object.keys(parseOptions.alias)) { - options.alias[key] = (options.alias[key] || []).concat(parseOptions.alias[key]); - } - options.array = options.array.concat(parseOptions.array); - options.config = {}; - const unparsed = []; - Object.keys(positionalMap).forEach((key) => { - positionalMap[key].map((value) => { - if (options.configuration["unknown-options-as-args"]) - options.key[key] = true; - unparsed.push(`--${key}`); - unparsed.push(value); - }); - }); - if (!unparsed.length) - return; - const config = Object.assign({}, options.configuration, { - "populate--": false - }); - const parsed = this.shim.Parser.detailed(unparsed, Object.assign({}, options, { - configuration: config - })); - if (parsed.error) { - yargs.getInternalMethods().getUsageInstance().fail(parsed.error.message, parsed.error); - } else { - const positionalKeys = Object.keys(positionalMap); - Object.keys(positionalMap).forEach((key) => { - positionalKeys.push(...parsed.aliases[key]); - }); - Object.keys(parsed.argv).forEach((key) => { - if (positionalKeys.includes(key)) { - if (!positionalMap[key]) - positionalMap[key] = parsed.argv[key]; - if (!this.isInConfigs(yargs, key) && !this.isDefaulted(yargs, key) && Object.prototype.hasOwnProperty.call(argv, key) && Object.prototype.hasOwnProperty.call(parsed.argv, key) && (Array.isArray(argv[key]) || Array.isArray(parsed.argv[key]))) { - argv[key] = [].concat(argv[key], parsed.argv[key]); + } + parseFalse_e() { + if (this.char === CHAR_e) { + return this.return(false); + } else { + throw this.error(new TomlError("Invalid boolean, expected true or false")); + } + } + /* INLINE LISTS */ + parseInlineList() { + if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J) { + return null; + } else if (this.char === Parser.END) { + throw this.error(new TomlError("Unterminated inline array")); + } else if (this.char === CHAR_NUM) { + return this.call(this.parseComment); + } else if (this.char === CHAR_RSQB) { + return this.return(this.state.resultArr || InlineList()); } else { - argv[key] = parsed.argv[key]; + return this.callNow(this.parseValue, this.recordInlineListValue); } } - }); - } - } - isDefaulted(yargs, key) { - const { default: defaults } = yargs.getOptions(); - return Object.prototype.hasOwnProperty.call(defaults, key) || Object.prototype.hasOwnProperty.call(defaults, this.shim.Parser.camelCase(key)); - } - isInConfigs(yargs, key) { - const { configObjects } = yargs.getOptions(); - return configObjects.some((c2) => Object.prototype.hasOwnProperty.call(c2, key)) || configObjects.some((c2) => Object.prototype.hasOwnProperty.call(c2, this.shim.Parser.camelCase(key))); - } - runDefaultBuilderOn(yargs) { - if (!this.defaultCommand) - return; - if (this.shouldUpdateUsage(yargs)) { - const commandString = DEFAULT_MARKER.test(this.defaultCommand.original) ? this.defaultCommand.original : this.defaultCommand.original.replace(/^[^[\]<>]*/, "$0 "); - yargs.getInternalMethods().getUsageInstance().usage(commandString, this.defaultCommand.description); - } - const builder = this.defaultCommand.builder; - if (isCommandBuilderCallback(builder)) { - return builder(yargs, true); - } else if (!isCommandBuilderDefinition(builder)) { - Object.keys(builder).forEach((key) => { - yargs.option(key, builder[key]); - }); - } - return void 0; - } - extractDesc({ describe, description, desc }) { - for (const test of [describe, description, desc]) { - if (typeof test === "string" || test === false) - return test; - assertNotStrictEqual(test, true, this.shim); - } - return false; - } - freeze() { - this.frozens.push({ - handlers: this.handlers, - aliasMap: this.aliasMap, - defaultCommand: this.defaultCommand - }); - } - unfreeze() { - const frozen = this.frozens.pop(); - assertNotStrictEqual(frozen, void 0, this.shim); - ({ - handlers: this.handlers, - aliasMap: this.aliasMap, - defaultCommand: this.defaultCommand - } = frozen); - } - reset() { - this.handlers = {}; - this.aliasMap = {}; - this.defaultCommand = void 0; - this.requireCache = /* @__PURE__ */ new Set(); - return this; - } -}; -function command(usage2, validation2, globalMiddleware, shim3) { - return new CommandInstance(usage2, validation2, globalMiddleware, shim3); -} -function isCommandBuilderDefinition(builder) { - return typeof builder === "object" && !!builder.builder && typeof builder.handler === "function"; -} -function isCommandAndAliases(cmd) { - return cmd.every((c2) => typeof c2 === "string"); -} -function isCommandBuilderCallback(builder) { - return typeof builder === "function"; -} -function isCommandBuilderOptionDefinitions(builder) { - return typeof builder === "object"; -} -function isCommandHandlerDefinition(cmd) { - return typeof cmd === "object" && !Array.isArray(cmd); -} - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/usage.js -init_esm_shims(); - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/utils/obj-filter.js -init_esm_shims(); -function objFilter(original = {}, filter = () => true) { - const obj = {}; - objectKeys(original).forEach((key) => { - if (filter(key, original[key])) { - obj[key] = original[key]; - } - }); - return obj; -} - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/utils/set-blocking.js -init_esm_shims(); -function setBlocking(blocking) { - if (typeof process === "undefined") - return; - [process.stdout, process.stderr].forEach((_stream) => { - const stream = _stream; - if (stream._handle && stream.isTTY && typeof stream._handle.setBlocking === "function") { - stream._handle.setBlocking(blocking); - } - }); -} - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/usage.js -function isBoolean2(fail) { - return typeof fail === "boolean"; -} -function usage(yargs, shim3) { - const __ = shim3.y18n.__; - const self = {}; - const fails = []; - self.failFn = function failFn(f2) { - fails.push(f2); - }; - let failMessage = null; - let globalFailMessage = null; - let showHelpOnFail = true; - self.showHelpOnFail = function showHelpOnFailFn(arg1 = true, arg2) { - const [enabled, message] = typeof arg1 === "string" ? [true, arg1] : [arg1, arg2]; - if (yargs.getInternalMethods().isGlobalContext()) { - globalFailMessage = message; - } - failMessage = message; - showHelpOnFail = enabled; - return self; - }; - let failureOutput = false; - self.fail = function fail(msg, err) { - const logger = yargs.getInternalMethods().getLoggerInstance(); - if (fails.length) { - for (let i2 = fails.length - 1; i2 >= 0; --i2) { - const fail2 = fails[i2]; - if (isBoolean2(fail2)) { - if (err) - throw err; - else if (msg) - throw Error(msg); - } else { - fail2(msg, err, self); - } - } - } else { - if (yargs.getExitProcess()) - setBlocking(true); - if (!failureOutput) { - failureOutput = true; - if (showHelpOnFail) { - yargs.showHelp("error"); - logger.error(); - } - if (msg || err) - logger.error(msg || err); - const globalOrCommandFailMessage = failMessage || globalFailMessage; - if (globalOrCommandFailMessage) { - if (msg || err) - logger.error(""); - logger.error(globalOrCommandFailMessage); - } - } - err = err || new YError(msg); - if (yargs.getExitProcess()) { - return yargs.exit(1); - } else if (yargs.getInternalMethods().hasParseCallback()) { - return yargs.exit(1, err); - } else { - throw err; - } - } - }; - let usages = []; - let usageDisabled = false; - self.usage = (msg, description) => { - if (msg === null) { - usageDisabled = true; - usages = []; - return self; - } - usageDisabled = false; - usages.push([msg, description || ""]); - return self; - }; - self.getUsage = () => { - return usages; - }; - self.getUsageDisabled = () => { - return usageDisabled; - }; - self.getPositionalGroupName = () => { - return __("Positionals:"); - }; - let examples = []; - self.example = (cmd, description) => { - examples.push([cmd, description || ""]); - }; - let commands = []; - self.command = function command2(cmd, description, isDefault, aliases, deprecated = false) { - if (isDefault) { - commands = commands.map((cmdArray) => { - cmdArray[2] = false; - return cmdArray; - }); - } - commands.push([cmd, description || "", isDefault, aliases, deprecated]); - }; - self.getCommands = () => commands; - let descriptions = {}; - self.describe = function describe(keyOrKeys, desc) { - if (Array.isArray(keyOrKeys)) { - keyOrKeys.forEach((k) => { - self.describe(k, desc); - }); - } else if (typeof keyOrKeys === "object") { - Object.keys(keyOrKeys).forEach((k) => { - self.describe(k, keyOrKeys[k]); - }); - } else { - descriptions[keyOrKeys] = desc; - } - }; - self.getDescriptions = () => descriptions; - let epilogs = []; - self.epilog = (msg) => { - epilogs.push(msg); - }; - let wrapSet = false; - let wrap; - self.wrap = (cols) => { - wrapSet = true; - wrap = cols; - }; - self.getWrap = () => { - if (shim3.getEnv("YARGS_DISABLE_WRAP")) { - return null; - } - if (!wrapSet) { - wrap = windowWidth(); - wrapSet = true; - } - return wrap; - }; - const deferY18nLookupPrefix = "__yargsString__:"; - self.deferY18nLookup = (str2) => deferY18nLookupPrefix + str2; - self.help = function help() { - if (cachedHelpMessage) - return cachedHelpMessage; - normalizeAliases(); - const base$0 = yargs.customScriptName ? yargs.$0 : shim3.path.basename(yargs.$0); - const demandedOptions = yargs.getDemandedOptions(); - const demandedCommands = yargs.getDemandedCommands(); - const deprecatedOptions = yargs.getDeprecatedOptions(); - const groups = yargs.getGroups(); - const options = yargs.getOptions(); - let keys = []; - keys = keys.concat(Object.keys(descriptions)); - keys = keys.concat(Object.keys(demandedOptions)); - keys = keys.concat(Object.keys(demandedCommands)); - keys = keys.concat(Object.keys(options.default)); - keys = keys.filter(filterHiddenOptions); - keys = Object.keys(keys.reduce((acc, key) => { - if (key !== "_") - acc[key] = true; - return acc; - }, {})); - const theWrap = self.getWrap(); - const ui2 = shim3.cliui({ - width: theWrap, - wrap: !!theWrap - }); - if (!usageDisabled) { - if (usages.length) { - usages.forEach((usage2) => { - ui2.div({ text: `${usage2[0].replace(/\$0/g, base$0)}` }); - if (usage2[1]) { - ui2.div({ text: `${usage2[1]}`, padding: [1, 0, 0, 0] }); + recordInlineListValue(value) { + if (this.state.resultArr) { + const listType = this.state.resultArr[_contentType]; + const valueType = tomlType(value); + if (listType !== valueType) { + throw this.error(new TomlError(`Inline lists must be a single type, not a mix of ${listType} and ${valueType}`)); + } + } else { + this.state.resultArr = InlineList(tomlType(value)); } - }); - ui2.div(); - } else if (commands.length) { - let u2 = null; - if (demandedCommands._) { - u2 = `${base$0} <${__("command")}> -`; - } else { - u2 = `${base$0} [${__("command")}] -`; + if (isFloat(value) || isInteger(value)) { + this.state.resultArr.push(value.valueOf()); + } else { + this.state.resultArr.push(value); + } + return this.goto(this.parseInlineListNext); } - ui2.div(`${u2}`); - } - } - if (commands.length > 1 || commands.length === 1 && !commands[0][2]) { - ui2.div(__("Commands:")); - const context = yargs.getInternalMethods().getContext(); - const parentCommands = context.commands.length ? `${context.commands.join(" ")} ` : ""; - if (yargs.getInternalMethods().getParserConfiguration()["sort-commands"] === true) { - commands = commands.sort((a2, b2) => a2[0].localeCompare(b2[0])); - } - const prefix = base$0 ? `${base$0} ` : ""; - commands.forEach((command2) => { - const commandString = `${prefix}${parentCommands}${command2[0].replace(/^\$0 ?/, "")}`; - ui2.span({ - text: commandString, - padding: [0, 2, 0, 2], - width: maxWidth(commands, theWrap, `${base$0}${parentCommands}`) + 4 - }, { text: command2[1] }); - const hints = []; - if (command2[2]) - hints.push(`[${__("default")}]`); - if (command2[3] && command2[3].length) { - hints.push(`[${__("aliases:")} ${command2[3].join(", ")}]`); - } - if (command2[4]) { - if (typeof command2[4] === "string") { - hints.push(`[${__("deprecated: %s", command2[4])}]`); + parseInlineListNext() { + if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J) { + return null; + } else if (this.char === CHAR_NUM) { + return this.call(this.parseComment); + } else if (this.char === CHAR_COMMA) { + return this.next(this.parseInlineList); + } else if (this.char === CHAR_RSQB) { + return this.goto(this.parseInlineList); } else { - hints.push(`[${__("deprecated")}]`); + throw this.error(new TomlError("Invalid character, expected whitespace, comma (,) or close bracket (])")); } } - if (hints.length) { - ui2.div({ - text: hints.join(" "), - padding: [0, 0, 0, 2], - align: "right" - }); - } else { - ui2.div(); + /* INLINE TABLE */ + parseInlineTable() { + if (this.char === CHAR_SP || this.char === CTRL_I) { + return null; + } else if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) { + throw this.error(new TomlError("Unterminated inline array")); + } else if (this.char === CHAR_RCUB) { + return this.return(this.state.resultTable || InlineTable()); + } else { + if (!this.state.resultTable) this.state.resultTable = InlineTable(); + return this.callNow(this.parseAssign, this.recordInlineTableValue); + } } - }); - ui2.div(); - } - const aliasKeys = (Object.keys(options.alias) || []).concat(Object.keys(yargs.parsed.newAliases) || []); - keys = keys.filter((key) => !yargs.parsed.newAliases[key] && aliasKeys.every((alias) => (options.alias[alias] || []).indexOf(key) === -1)); - const defaultGroup = __("Options:"); - if (!groups[defaultGroup]) - groups[defaultGroup] = []; - addUngroupedKeys(keys, options.alias, groups, defaultGroup); - const isLongSwitch = (sw) => /^--/.test(getText(sw)); - const displayedGroups = Object.keys(groups).filter((groupName) => groups[groupName].length > 0).map((groupName) => { - const normalizedKeys = groups[groupName].filter(filterHiddenOptions).map((key) => { - if (aliasKeys.includes(key)) - return key; - for (let i2 = 0, aliasKey; (aliasKey = aliasKeys[i2]) !== void 0; i2++) { - if ((options.alias[aliasKey] || []).includes(key)) - return aliasKey; - } - return key; - }); - return { groupName, normalizedKeys }; - }).filter(({ normalizedKeys }) => normalizedKeys.length > 0).map(({ groupName, normalizedKeys }) => { - const switches = normalizedKeys.reduce((acc, key) => { - acc[key] = [key].concat(options.alias[key] || []).map((sw) => { - if (groupName === self.getPositionalGroupName()) - return sw; - else { - return (/^[0-9]$/.test(sw) ? options.boolean.includes(key) ? "-" : "--" : sw.length > 1 ? "--" : "-") + sw; + recordInlineTableValue(kv) { + let target = this.state.resultTable; + let finalKey = kv.key.pop(); + for (let kw of kv.key) { + if (hasKey(target, kw) && (!isTable(target[kw]) || target[kw][_declared])) { + throw this.error(new TomlError("Can't redefine existing key")); + } + target = target[kw] = target[kw] || Table(); } - }).sort((sw1, sw2) => isLongSwitch(sw1) === isLongSwitch(sw2) ? 0 : isLongSwitch(sw1) ? 1 : -1).join(", "); - return acc; - }, {}); - return { groupName, normalizedKeys, switches }; - }); - const shortSwitchesUsed = displayedGroups.filter(({ groupName }) => groupName !== self.getPositionalGroupName()).some(({ normalizedKeys, switches }) => !normalizedKeys.every((key) => isLongSwitch(switches[key]))); - if (shortSwitchesUsed) { - displayedGroups.filter(({ groupName }) => groupName !== self.getPositionalGroupName()).forEach(({ normalizedKeys, switches }) => { - normalizedKeys.forEach((key) => { - if (isLongSwitch(switches[key])) { - switches[key] = addIndentation(switches[key], "-x, ".length); + if (hasKey(target, finalKey)) { + throw this.error(new TomlError("Can't redefine existing key")); } - }); - }); - } - displayedGroups.forEach(({ groupName, normalizedKeys, switches }) => { - ui2.div(groupName); - normalizedKeys.forEach((key) => { - const kswitch = switches[key]; - let desc = descriptions[key] || ""; - let type2 = null; - if (desc.includes(deferY18nLookupPrefix)) - desc = __(desc.substring(deferY18nLookupPrefix.length)); - if (options.boolean.includes(key)) - type2 = `[${__("boolean")}]`; - if (options.count.includes(key)) - type2 = `[${__("count")}]`; - if (options.string.includes(key)) - type2 = `[${__("string")}]`; - if (options.normalize.includes(key)) - type2 = `[${__("string")}]`; - if (options.array.includes(key)) - type2 = `[${__("array")}]`; - if (options.number.includes(key)) - type2 = `[${__("number")}]`; - const deprecatedExtra = (deprecated) => typeof deprecated === "string" ? `[${__("deprecated: %s", deprecated)}]` : `[${__("deprecated")}]`; - const extra = [ - key in deprecatedOptions ? deprecatedExtra(deprecatedOptions[key]) : null, - type2, - key in demandedOptions ? `[${__("required")}]` : null, - options.choices && options.choices[key] ? `[${__("choices:")} ${self.stringifiedValues(options.choices[key])}]` : null, - defaultString(options.default[key], options.defaultDescription[key]) - ].filter(Boolean).join(" "); - ui2.span({ - text: getText(kswitch), - padding: [0, 2, 0, 2 + getIndentation(kswitch)], - width: maxWidth(switches, theWrap) + 4 - }, desc); - const shouldHideOptionExtras = yargs.getInternalMethods().getUsageConfiguration()["hide-types"] === true; - if (extra && !shouldHideOptionExtras) - ui2.div({ text: extra, padding: [0, 0, 0, 2], align: "right" }); - else - ui2.div(); - }); - ui2.div(); - }); - if (examples.length) { - ui2.div(__("Examples:")); - examples.forEach((example) => { - example[0] = example[0].replace(/\$0/g, base$0); - }); - examples.forEach((example) => { - if (example[1] === "") { - ui2.div({ - text: example[0], - padding: [0, 2, 0, 2] - }); - } else { - ui2.div({ - text: example[0], - padding: [0, 2, 0, 2], - width: maxWidth(examples, theWrap) + 4 - }, { - text: example[1] - }); - } - }); - ui2.div(); - } - if (epilogs.length > 0) { - const e2 = epilogs.map((epilog) => epilog.replace(/\$0/g, base$0)).join("\n"); - ui2.div(`${e2} -`); - } - return ui2.toString().replace(/\s*$/, ""); - }; - function maxWidth(table, theWrap, modifier) { - let width = 0; - if (!Array.isArray(table)) { - table = Object.values(table).map((v2) => [v2]); - } - table.forEach((v2) => { - width = Math.max(shim3.stringWidth(modifier ? `${modifier} ${getText(v2[0])}` : getText(v2[0])) + getIndentation(v2[0]), width); - }); - if (theWrap) - width = Math.min(width, parseInt((theWrap * 0.5).toString(), 10)); - return width; - } - function normalizeAliases() { - const demandedOptions = yargs.getDemandedOptions(); - const options = yargs.getOptions(); - (Object.keys(options.alias) || []).forEach((key) => { - options.alias[key].forEach((alias) => { - if (descriptions[alias]) - self.describe(key, descriptions[alias]); - if (alias in demandedOptions) - yargs.demandOption(key, demandedOptions[alias]); - if (options.boolean.includes(alias)) - yargs.boolean(key); - if (options.count.includes(alias)) - yargs.count(key); - if (options.string.includes(alias)) - yargs.string(key); - if (options.normalize.includes(alias)) - yargs.normalize(key); - if (options.array.includes(alias)) - yargs.array(key); - if (options.number.includes(alias)) - yargs.number(key); - }); - }); - } - let cachedHelpMessage; - self.cacheHelpMessage = function() { - cachedHelpMessage = this.help(); - }; - self.clearCachedHelpMessage = function() { - cachedHelpMessage = void 0; - }; - self.hasCachedHelpMessage = function() { - return !!cachedHelpMessage; - }; - function addUngroupedKeys(keys, aliases, groups, defaultGroup) { - let groupedKeys = []; - let toCheck = null; - Object.keys(groups).forEach((group) => { - groupedKeys = groupedKeys.concat(groups[group]); - }); - keys.forEach((key) => { - toCheck = [key].concat(aliases[key]); - if (!toCheck.some((k) => groupedKeys.indexOf(k) !== -1)) { - groups[defaultGroup].push(key); - } - }); - return groupedKeys; - } - function filterHiddenOptions(key) { - return yargs.getOptions().hiddenOptions.indexOf(key) < 0 || yargs.parsed.argv[yargs.getOptions().showHiddenOpt]; - } - self.showHelp = (level) => { - const logger = yargs.getInternalMethods().getLoggerInstance(); - if (!level) - level = "error"; - const emit = typeof level === "function" ? level : logger[level]; - emit(self.help()); - }; - self.functionDescription = (fn) => { - const description = fn.name ? shim3.Parser.decamelize(fn.name, "-") : __("generated-value"); - return ["(", description, ")"].join(""); - }; - self.stringifiedValues = function stringifiedValues(values, separator) { - let string = ""; - const sep = separator || ", "; - const array = [].concat(values); - if (!values || !array.length) - return string; - array.forEach((value) => { - if (string.length) - string += sep; - string += JSON.stringify(value); - }); - return string; - }; - function defaultString(value, defaultDescription) { - let string = `[${__("default:")} `; - if (value === void 0 && !defaultDescription) - return null; - if (defaultDescription) { - string += defaultDescription; - } else { - switch (typeof value) { - case "string": - string += `"${value}"`; - break; - case "object": - string += JSON.stringify(value); - break; - default: - string += value; - } - } - return `${string}]`; - } - function windowWidth() { - const maxWidth2 = 80; - if (shim3.process.stdColumns) { - return Math.min(maxWidth2, shim3.process.stdColumns); - } else { - return maxWidth2; - } - } - let version = null; - self.version = (ver) => { - version = ver; - }; - self.showVersion = (level) => { - const logger = yargs.getInternalMethods().getLoggerInstance(); - if (!level) - level = "error"; - const emit = typeof level === "function" ? level : logger[level]; - emit(version); - }; - self.reset = function reset(localLookup) { - failMessage = null; - failureOutput = false; - usages = []; - usageDisabled = false; - epilogs = []; - examples = []; - commands = []; - descriptions = objFilter(descriptions, (k) => !localLookup[k]); - return self; - }; - const frozens = []; - self.freeze = function freeze() { - frozens.push({ - failMessage, - failureOutput, - usages, - usageDisabled, - epilogs, - examples, - commands, - descriptions - }); - }; - self.unfreeze = function unfreeze(defaultCommand = false) { - const frozen = frozens.pop(); - if (!frozen) - return; - if (defaultCommand) { - descriptions = { ...frozen.descriptions, ...descriptions }; - commands = [...frozen.commands, ...commands]; - usages = [...frozen.usages, ...usages]; - examples = [...frozen.examples, ...examples]; - epilogs = [...frozen.epilogs, ...epilogs]; - } else { - ({ - failMessage, - failureOutput, - usages, - usageDisabled, - epilogs, - examples, - commands, - descriptions - } = frozen); - } - }; - return self; -} -function isIndentedText(text) { - return typeof text === "object"; -} -function addIndentation(text, indent) { - return isIndentedText(text) ? { text: text.text, indentation: text.indentation + indent } : { text, indentation: indent }; -} -function getIndentation(text) { - return isIndentedText(text) ? text.indentation : 0; -} -function getText(text) { - return isIndentedText(text) ? text.text : text; -} - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/completion.js -init_esm_shims(); - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/completion-templates.js -init_esm_shims(); -var completionShTemplate = `###-begin-{{app_name}}-completions-### -# -# yargs command completion script -# -# Installation: {{app_path}} {{completion_command}} >> ~/.bashrc -# or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX. -# -_{{app_name}}_yargs_completions() -{ - local cur_word args type_list - - cur_word="\${COMP_WORDS[COMP_CWORD]}" - args=("\${COMP_WORDS[@]}") - - # ask yargs to generate completions. - # see https://stackoverflow.com/a/40944195/7080036 for the spaces-handling awk - mapfile -t type_list < <({{app_path}} --get-yargs-completions "\${args[@]}") - mapfile -t COMPREPLY < <(compgen -W "$( printf '%q ' "\${type_list[@]}" )" -- "\${cur_word}" | - awk '/ / { print "\\""$0"\\"" } /^[^ ]+$/ { print $0 }') - - # if no match was found, fall back to filename completion - if [ \${#COMPREPLY[@]} -eq 0 ]; then - COMPREPLY=() - fi - - return 0 -} -complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}} -###-end-{{app_name}}-completions-### -`; -var completionZshTemplate = `#compdef {{app_name}} -###-begin-{{app_name}}-completions-### -# -# yargs command completion script -# -# Installation: {{app_path}} {{completion_command}} >> ~/.zshrc -# or {{app_path}} {{completion_command}} >> ~/.zprofile on OSX. -# -_{{app_name}}_yargs_completions() -{ - local reply - local si=$IFS - IFS=$' -' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "\${words[@]}")) - IFS=$si - if [[ \${#reply} -gt 0 ]]; then - _describe 'values' reply - else - _default - fi -} -if [[ "'\${zsh_eval_context[-1]}" == "loadautofunc" ]]; then - _{{app_name}}_yargs_completions "$@" -else - compdef _{{app_name}}_yargs_completions {{app_name}} -fi -###-end-{{app_name}}-completions-### -`; - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/completion.js -var Completion = class { - constructor(yargs, usage2, command2, shim3) { - var _a2, _b2, _c2; - this.yargs = yargs; - this.usage = usage2; - this.command = command2; - this.shim = shim3; - this.completionKey = "get-yargs-completions"; - this.aliases = null; - this.customCompletionFunction = null; - this.indexAfterLastReset = 0; - this.zshShell = (_c2 = ((_a2 = this.shim.getEnv("SHELL")) === null || _a2 === void 0 ? void 0 : _a2.includes("zsh")) || ((_b2 = this.shim.getEnv("ZSH_NAME")) === null || _b2 === void 0 ? void 0 : _b2.includes("zsh"))) !== null && _c2 !== void 0 ? _c2 : false; - } - defaultCompletion(args, argv, current, done) { - const handlers = this.command.getCommandHandlers(); - for (let i2 = 0, ii = args.length; i2 < ii; ++i2) { - if (handlers[args[i2]] && handlers[args[i2]].builder) { - const builder = handlers[args[i2]].builder; - if (isCommandBuilderCallback(builder)) { - this.indexAfterLastReset = i2 + 1; - const y2 = this.yargs.getInternalMethods().reset(); - builder(y2, true); - return y2.argv; - } - } - } - const completions = []; - this.commandCompletions(completions, args, current); - this.optionCompletions(completions, args, argv, current); - this.choicesFromOptionsCompletions(completions, args, argv, current); - this.choicesFromPositionalsCompletions(completions, args, argv, current); - done(null, completions); - } - commandCompletions(completions, args, current) { - const parentCommands = this.yargs.getInternalMethods().getContext().commands; - if (!current.match(/^-/) && parentCommands[parentCommands.length - 1] !== current && !this.previousArgHasChoices(args)) { - this.usage.getCommands().forEach((usageCommand) => { - const commandName = parseCommand(usageCommand[0]).cmd; - if (args.indexOf(commandName) === -1) { - if (!this.zshShell) { - completions.push(commandName); + if (isInteger(kv.value) || isFloat(kv.value)) { + target[finalKey] = kv.value.valueOf(); } else { - const desc = usageCommand[1] || ""; - completions.push(commandName.replace(/:/g, "\\:") + ":" + desc); + target[finalKey] = kv.value; } + return this.goto(this.parseInlineTableNext); } - }); - } - } - optionCompletions(completions, args, argv, current) { - if ((current.match(/^-/) || current === "" && completions.length === 0) && !this.previousArgHasChoices(args)) { - const options = this.yargs.getOptions(); - const positionalKeys = this.yargs.getGroups()[this.usage.getPositionalGroupName()] || []; - Object.keys(options.key).forEach((key) => { - const negable = !!options.configuration["boolean-negation"] && options.boolean.includes(key); - const isPositionalKey = positionalKeys.includes(key); - if (!isPositionalKey && !options.hiddenOptions.includes(key) && !this.argsContainKey(args, key, negable)) { - this.completeOptionKey(key, completions, current, negable && !!options.default[key]); - } - }); - } - } - choicesFromOptionsCompletions(completions, args, argv, current) { - if (this.previousArgHasChoices(args)) { - const choices = this.getPreviousArgChoices(args); - if (choices && choices.length > 0) { - completions.push(...choices.map((c2) => c2.replace(/:/g, "\\:"))); - } - } - } - choicesFromPositionalsCompletions(completions, args, argv, current) { - if (current === "" && completions.length > 0 && this.previousArgHasChoices(args)) { - return; - } - const positionalKeys = this.yargs.getGroups()[this.usage.getPositionalGroupName()] || []; - const offset = Math.max(this.indexAfterLastReset, this.yargs.getInternalMethods().getContext().commands.length + 1); - const positionalKey = positionalKeys[argv._.length - offset - 1]; - if (!positionalKey) { - return; - } - const choices = this.yargs.getOptions().choices[positionalKey] || []; - for (const choice of choices) { - if (choice.startsWith(current)) { - completions.push(choice.replace(/:/g, "\\:")); - } - } - } - getPreviousArgChoices(args) { - if (args.length < 1) - return; - let previousArg = args[args.length - 1]; - let filter = ""; - if (!previousArg.startsWith("-") && args.length > 1) { - filter = previousArg; - previousArg = args[args.length - 2]; - } - if (!previousArg.startsWith("-")) - return; - const previousArgKey = previousArg.replace(/^-+/, ""); - const options = this.yargs.getOptions(); - const possibleAliases = [ - previousArgKey, - ...this.yargs.getAliases()[previousArgKey] || [] - ]; - let choices; - for (const possibleAlias of possibleAliases) { - if (Object.prototype.hasOwnProperty.call(options.key, possibleAlias) && Array.isArray(options.choices[possibleAlias])) { - choices = options.choices[possibleAlias]; - break; - } - } - if (choices) { - return choices.filter((choice) => !filter || choice.startsWith(filter)); - } - } - previousArgHasChoices(args) { - const choices = this.getPreviousArgChoices(args); - return choices !== void 0 && choices.length > 0; - } - argsContainKey(args, key, negable) { - const argsContains = (s2) => args.indexOf((/^[^0-9]$/.test(s2) ? "-" : "--") + s2) !== -1; - if (argsContains(key)) - return true; - if (negable && argsContains(`no-${key}`)) - return true; - if (this.aliases) { - for (const alias of this.aliases[key]) { - if (argsContains(alias)) - return true; - } - } - return false; - } - completeOptionKey(key, completions, current, negable) { - var _a2, _b2, _c2, _d; - let keyWithDesc = key; - if (this.zshShell) { - const descs = this.usage.getDescriptions(); - const aliasKey = (_b2 = (_a2 = this === null || this === void 0 ? void 0 : this.aliases) === null || _a2 === void 0 ? void 0 : _a2[key]) === null || _b2 === void 0 ? void 0 : _b2.find((alias) => { - const desc2 = descs[alias]; - return typeof desc2 === "string" && desc2.length > 0; - }); - const descFromAlias = aliasKey ? descs[aliasKey] : void 0; - const desc = (_d = (_c2 = descs[key]) !== null && _c2 !== void 0 ? _c2 : descFromAlias) !== null && _d !== void 0 ? _d : ""; - keyWithDesc = `${key.replace(/:/g, "\\:")}:${desc.replace("__yargsString__:", "").replace(/(\r\n|\n|\r)/gm, " ")}`; - } - const startsByTwoDashes = (s2) => /^--/.test(s2); - const isShortOption = (s2) => /^[^0-9]$/.test(s2); - const dashes = !startsByTwoDashes(current) && isShortOption(key) ? "-" : "--"; - completions.push(dashes + keyWithDesc); - if (negable) { - completions.push(dashes + "no-" + keyWithDesc); - } - } - customCompletion(args, argv, current, done) { - assertNotStrictEqual(this.customCompletionFunction, null, this.shim); - if (isSyncCompletionFunction(this.customCompletionFunction)) { - const result = this.customCompletionFunction(current, argv); - if (isPromise(result)) { - return result.then((list) => { - this.shim.process.nextTick(() => { - done(null, list); - }); - }).catch((err) => { - this.shim.process.nextTick(() => { - done(err, void 0); - }); - }); - } - return done(null, result); - } else if (isFallbackCompletionFunction(this.customCompletionFunction)) { - return this.customCompletionFunction(current, argv, (onCompleted = done) => this.defaultCompletion(args, argv, current, onCompleted), (completions) => { - done(null, completions); - }); - } else { - return this.customCompletionFunction(current, argv, (completions) => { - done(null, completions); - }); - } - } - getCompletion(args, done) { - const current = args.length ? args[args.length - 1] : ""; - const argv = this.yargs.parse(args, true); - const completionFunction = this.customCompletionFunction ? (argv2) => this.customCompletion(args, argv2, current, done) : (argv2) => this.defaultCompletion(args, argv2, current, done); - return isPromise(argv) ? argv.then(completionFunction) : completionFunction(argv); - } - generateCompletionScript($0, cmd) { - let script = this.zshShell ? completionZshTemplate : completionShTemplate; - const name = this.shim.path.basename($0); - if ($0.match(/\.js$/)) - $0 = `./${$0}`; - script = script.replace(/{{app_name}}/g, name); - script = script.replace(/{{completion_command}}/g, cmd); - return script.replace(/{{app_path}}/g, $0); - } - registerFunction(fn) { - this.customCompletionFunction = fn; - } - setParsed(parsed) { - this.aliases = parsed.aliases; - } -}; -function completion(yargs, usage2, command2, shim3) { - return new Completion(yargs, usage2, command2, shim3); -} -function isSyncCompletionFunction(completionFunction) { - return completionFunction.length < 3; -} -function isFallbackCompletionFunction(completionFunction) { - return completionFunction.length > 3; -} - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/validation.js -init_esm_shims(); - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/utils/levenshtein.js -init_esm_shims(); -function levenshtein(a2, b2) { - if (a2.length === 0) - return b2.length; - if (b2.length === 0) - return a2.length; - const matrix = []; - let i2; - for (i2 = 0; i2 <= b2.length; i2++) { - matrix[i2] = [i2]; - } - let j2; - for (j2 = 0; j2 <= a2.length; j2++) { - matrix[0][j2] = j2; - } - for (i2 = 1; i2 <= b2.length; i2++) { - for (j2 = 1; j2 <= a2.length; j2++) { - if (b2.charAt(i2 - 1) === a2.charAt(j2 - 1)) { - matrix[i2][j2] = matrix[i2 - 1][j2 - 1]; - } else { - if (i2 > 1 && j2 > 1 && b2.charAt(i2 - 2) === a2.charAt(j2 - 1) && b2.charAt(i2 - 1) === a2.charAt(j2 - 2)) { - matrix[i2][j2] = matrix[i2 - 2][j2 - 2] + 1; - } else { - matrix[i2][j2] = Math.min(matrix[i2 - 1][j2 - 1] + 1, Math.min(matrix[i2][j2 - 1] + 1, matrix[i2 - 1][j2] + 1)); + parseInlineTableNext() { + if (this.char === CHAR_SP || this.char === CTRL_I) { + return null; + } else if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) { + throw this.error(new TomlError("Unterminated inline array")); + } else if (this.char === CHAR_COMMA) { + return this.next(this.parseInlineTable); + } else if (this.char === CHAR_RCUB) { + return this.goto(this.parseInlineTable); + } else { + throw this.error(new TomlError("Invalid character, expected whitespace, comma (,) or close bracket (])")); + } } } + return TOMLParser; } } - return matrix[b2.length][a2.length]; -} +}); -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/validation.js -var specialKeys = ["$0", "--", "_"]; -function validation(yargs, usage2, shim3) { - const __ = shim3.y18n.__; - const __n = shim3.y18n.__n; - const self = {}; - self.nonOptionCount = function nonOptionCount(argv) { - const demandedCommands = yargs.getDemandedCommands(); - const positionalCount = argv._.length + (argv["--"] ? argv["--"].length : 0); - const _s = positionalCount - yargs.getInternalMethods().getContext().commands.length; - if (demandedCommands._ && (_s < demandedCommands._.min || _s > demandedCommands._.max)) { - if (_s < demandedCommands._.min) { - if (demandedCommands._.minMsg !== void 0) { - usage2.fail(demandedCommands._.minMsg ? demandedCommands._.minMsg.replace(/\$0/g, _s.toString()).replace(/\$1/, demandedCommands._.min.toString()) : null); - } else { - usage2.fail(__n("Not enough non-option arguments: got %s, need at least %s", "Not enough non-option arguments: got %s, need at least %s", _s, _s.toString(), demandedCommands._.min.toString())); - } - } else if (_s > demandedCommands._.max) { - if (demandedCommands._.maxMsg !== void 0) { - usage2.fail(demandedCommands._.maxMsg ? demandedCommands._.maxMsg.replace(/\$0/g, _s.toString()).replace(/\$1/, demandedCommands._.max.toString()) : null); - } else { - usage2.fail(__n("Too many non-option arguments: got %s, maximum of %s", "Too many non-option arguments: got %s, maximum of %s", _s, _s.toString(), demandedCommands._.max.toString())); +// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-pretty-error.js +var require_parse_pretty_error = __commonJS({ + "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-pretty-error.js"(exports2, module2) { + init_esm_shims(); + module2.exports = prettyError; + function prettyError(err, buf) { + if (err.pos == null || err.line == null) return err; + let msg = err.message; + msg += ` at row ${err.line + 1}, col ${err.col + 1}, pos ${err.pos}: +`; + if (buf && buf.split) { + const lines = buf.split(/\n/); + const lineNumWidth = String(Math.min(lines.length, err.line + 3)).length; + let linePadding = " "; + while (linePadding.length < lineNumWidth) linePadding += " "; + for (let ii = Math.max(0, err.line - 1); ii < Math.min(lines.length, err.line + 2); ++ii) { + let lineNum = String(ii + 1); + if (lineNum.length < lineNumWidth) lineNum = " " + lineNum; + if (err.line === ii) { + msg += lineNum + "> " + lines[ii] + "\n"; + msg += linePadding + " "; + for (let hh = 0; hh < err.col; ++hh) { + msg += " "; + } + msg += "^\n"; + } else { + msg += lineNum + ": " + lines[ii] + "\n"; + } } } + err.message = msg + "\n"; + return err; } - }; - self.positionalCount = function positionalCount(required, observed) { - if (observed < required) { - usage2.fail(__n("Not enough non-option arguments: got %s, need at least %s", "Not enough non-option arguments: got %s, need at least %s", observed, observed + "", required + "")); - } - }; - self.requiredArguments = function requiredArguments(argv, demandedOptions) { - let missing = null; - for (const key of Object.keys(demandedOptions)) { - if (!Object.prototype.hasOwnProperty.call(argv, key) || typeof argv[key] === "undefined") { - missing = missing || {}; - missing[key] = demandedOptions[key]; + } +}); + +// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-string.js +var require_parse_string = __commonJS({ + "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-string.js"(exports2, module2) { + init_esm_shims(); + module2.exports = parseString; + var TOMLParser = require_toml_parser(); + var prettyError = require_parse_pretty_error(); + function parseString(str) { + if (global.Buffer && global.Buffer.isBuffer(str)) { + str = str.toString("utf8"); } - } - if (missing) { - const customMsgs = []; - for (const key of Object.keys(missing)) { - const msg = missing[key]; - if (msg && customMsgs.indexOf(msg) < 0) { - customMsgs.push(msg); - } + const parser = new TOMLParser(); + try { + parser.parse(str); + return parser.finish(); + } catch (err) { + throw prettyError(err, str); } - const customMsg = customMsgs.length ? ` -${customMsgs.join("\n")}` : ""; - usage2.fail(__n("Missing required argument: %s", "Missing required arguments: %s", Object.keys(missing).length, Object.keys(missing).join(", ") + customMsg)); } - }; - self.unknownArguments = function unknownArguments(argv, aliases, positionalMap, isDefaultCommand, checkPositionals = true) { - var _a2; - const commandKeys = yargs.getInternalMethods().getCommandInstance().getCommands(); - const unknown = []; - const currentContext = yargs.getInternalMethods().getContext(); - Object.keys(argv).forEach((key) => { - if (!specialKeys.includes(key) && !Object.prototype.hasOwnProperty.call(positionalMap, key) && !Object.prototype.hasOwnProperty.call(yargs.getInternalMethods().getParseContext(), key) && !self.isValidAndSomeAliasIsNotNew(key, aliases)) { - unknown.push(key); - } - }); - if (checkPositionals && (currentContext.commands.length > 0 || commandKeys.length > 0 || isDefaultCommand)) { - argv._.slice(currentContext.commands.length).forEach((key) => { - if (!commandKeys.includes("" + key)) { - unknown.push("" + key); - } + } +}); + +// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-async.js +var require_parse_async = __commonJS({ + "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-async.js"(exports2, module2) { + init_esm_shims(); + module2.exports = parseAsync; + var TOMLParser = require_toml_parser(); + var prettyError = require_parse_pretty_error(); + function parseAsync(str, opts) { + if (!opts) opts = {}; + const index = 0; + const blocksize = opts.blocksize || 40960; + const parser = new TOMLParser(); + return new Promise((resolve, reject) => { + setImmediate(parseAsyncNext, index, blocksize, resolve, reject); }); - } - if (checkPositionals) { - const demandedCommands = yargs.getDemandedCommands(); - const maxNonOptDemanded = ((_a2 = demandedCommands._) === null || _a2 === void 0 ? void 0 : _a2.max) || 0; - const expected = currentContext.commands.length + maxNonOptDemanded; - if (expected < argv._.length) { - argv._.slice(expected).forEach((key) => { - key = String(key); - if (!currentContext.commands.includes(key) && !unknown.includes(key)) { - unknown.push(key); + function parseAsyncNext(index2, blocksize2, resolve, reject) { + if (index2 >= str.length) { + try { + return resolve(parser.finish()); + } catch (err) { + return reject(prettyError(err, str)); } - }); - } - } - if (unknown.length) { - usage2.fail(__n("Unknown argument: %s", "Unknown arguments: %s", unknown.length, unknown.map((s2) => s2.trim() ? s2 : `"${s2}"`).join(", "))); - } - }; - self.unknownCommands = function unknownCommands(argv) { - const commandKeys = yargs.getInternalMethods().getCommandInstance().getCommands(); - const unknown = []; - const currentContext = yargs.getInternalMethods().getContext(); - if (currentContext.commands.length > 0 || commandKeys.length > 0) { - argv._.slice(currentContext.commands.length).forEach((key) => { - if (!commandKeys.includes("" + key)) { - unknown.push("" + key); } - }); - } - if (unknown.length > 0) { - usage2.fail(__n("Unknown command: %s", "Unknown commands: %s", unknown.length, unknown.join(", "))); - return true; - } else { - return false; - } - }; - self.isValidAndSomeAliasIsNotNew = function isValidAndSomeAliasIsNotNew(key, aliases) { - if (!Object.prototype.hasOwnProperty.call(aliases, key)) { - return false; - } - const newAliases = yargs.parsed.newAliases; - return [key, ...aliases[key]].some((a2) => !Object.prototype.hasOwnProperty.call(newAliases, a2) || !newAliases[key]); - }; - self.limitedChoices = function limitedChoices(argv) { - const options = yargs.getOptions(); - const invalid = {}; - if (!Object.keys(options.choices).length) - return; - Object.keys(argv).forEach((key) => { - if (specialKeys.indexOf(key) === -1 && Object.prototype.hasOwnProperty.call(options.choices, key)) { - [].concat(argv[key]).forEach((value) => { - if (options.choices[key].indexOf(value) === -1 && value !== void 0) { - invalid[key] = (invalid[key] || []).concat(value); - } - }); - } - }); - const invalidKeys = Object.keys(invalid); - if (!invalidKeys.length) - return; - let msg = __("Invalid values:"); - invalidKeys.forEach((key) => { - msg += ` - ${__("Argument: %s, Given: %s, Choices: %s", key, usage2.stringifiedValues(invalid[key]), usage2.stringifiedValues(options.choices[key]))}`; - }); - usage2.fail(msg); - }; - let implied = {}; - self.implies = function implies(key, value) { - argsert(" [array|number|string]", [key, value], arguments.length); - if (typeof key === "object") { - Object.keys(key).forEach((k) => { - self.implies(k, key[k]); - }); - } else { - yargs.global(key); - if (!implied[key]) { - implied[key] = []; - } - if (Array.isArray(value)) { - value.forEach((i2) => self.implies(key, i2)); - } else { - assertNotStrictEqual(value, void 0, shim3); - implied[key].push(value); + try { + parser.parse(str.slice(index2, index2 + blocksize2)); + setImmediate(parseAsyncNext, index2 + blocksize2, blocksize2, resolve, reject); + } catch (err) { + reject(prettyError(err, str)); + } } } - }; - self.getImplied = function getImplied() { - return implied; - }; - function keyExists(argv, val) { - const num = Number(val); - val = isNaN(num) ? val : num; - if (typeof val === "number") { - val = argv._.length >= val; - } else if (val.match(/^--no-.+/)) { - val = val.match(/^--no-(.+)/)[1]; - val = !Object.prototype.hasOwnProperty.call(argv, val); - } else { - val = Object.prototype.hasOwnProperty.call(argv, val); - } - return val; } - self.implications = function implications(argv) { - const implyFail = []; - Object.keys(implied).forEach((key) => { - const origKey = key; - (implied[key] || []).forEach((value) => { - let key2 = origKey; - const origValue = value; - key2 = keyExists(argv, key2); - value = keyExists(argv, value); - if (key2 && !value) { - implyFail.push(` ${origKey} -> ${origValue}`); - } - }); - }); - if (implyFail.length) { - let msg = `${__("Implications failed:")} -`; - implyFail.forEach((value) => { - msg += value; - }); - usage2.fail(msg); - } - }; - let conflicting = {}; - self.conflicts = function conflicts(key, value) { - argsert(" [array|string]", [key, value], arguments.length); - if (typeof key === "object") { - Object.keys(key).forEach((k) => { - self.conflicts(k, key[k]); - }); - } else { - yargs.global(key); - if (!conflicting[key]) { - conflicting[key] = []; - } - if (Array.isArray(value)) { - value.forEach((i2) => self.conflicts(key, i2)); +}); + +// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-stream.js +var require_parse_stream = __commonJS({ + "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-stream.js"(exports2, module2) { + init_esm_shims(); + module2.exports = parseStream; + var stream = __require("stream"); + var TOMLParser = require_toml_parser(); + function parseStream(stm) { + if (stm) { + return parseReadable(stm); } else { - conflicting[key].push(value); + return parseTransform(); } } - }; - self.getConflicting = () => conflicting; - self.conflicting = function conflictingFn(argv) { - Object.keys(argv).forEach((key) => { - if (conflicting[key]) { - conflicting[key].forEach((value) => { - if (value && argv[key] !== void 0 && argv[value] !== void 0) { - usage2.fail(__("Arguments %s and %s are mutually exclusive", key, value)); + function parseReadable(stm) { + const parser = new TOMLParser(); + stm.setEncoding("utf8"); + return new Promise((resolve, reject) => { + let readable; + let ended = false; + let errored = false; + function finish() { + ended = true; + if (readable) return; + try { + resolve(parser.finish()); + } catch (err) { + reject(err); } - }); - } - }); - if (yargs.getInternalMethods().getParserConfiguration()["strip-dashed"]) { - Object.keys(conflicting).forEach((key) => { - conflicting[key].forEach((value) => { - if (value && argv[shim3.Parser.camelCase(key)] !== void 0 && argv[shim3.Parser.camelCase(value)] !== void 0) { - usage2.fail(__("Arguments %s and %s are mutually exclusive", key, value)); + } + function error(err) { + errored = true; + reject(err); + } + stm.once("end", finish); + stm.once("error", error); + readNext(); + function readNext() { + readable = true; + let data; + while ((data = stm.read()) !== null) { + try { + parser.parse(data); + } catch (err) { + return error(err); + } } - }); + readable = false; + if (ended) return finish(); + if (errored) return; + stm.once("readable", readNext); + } }); } - }; - self.recommendCommands = function recommendCommands(cmd, potentialCommands) { - const threshold = 3; - potentialCommands = potentialCommands.sort((a2, b2) => b2.length - a2.length); - let recommended = null; - let bestDistance = Infinity; - for (let i2 = 0, candidate; (candidate = potentialCommands[i2]) !== void 0; i2++) { - const d2 = levenshtein(cmd, candidate); - if (d2 <= threshold && d2 < bestDistance) { - bestDistance = d2; - recommended = candidate; - } - } - if (recommended) - usage2.fail(__("Did you mean %s?", recommended)); - }; - self.reset = function reset(localLookup) { - implied = objFilter(implied, (k) => !localLookup[k]); - conflicting = objFilter(conflicting, (k) => !localLookup[k]); - return self; - }; - const frozens = []; - self.freeze = function freeze() { - frozens.push({ - implied, - conflicting - }); - }; - self.unfreeze = function unfreeze() { - const frozen = frozens.pop(); - assertNotStrictEqual(frozen, void 0, shim3); - ({ implied, conflicting } = frozen); - }; - return self; -} - -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/utils/apply-extends.js -init_esm_shims(); -var previouslyVisitedConfigs = []; -var shim2; -function applyExtends(config, cwd, mergeExtends, _shim) { - shim2 = _shim; - let defaultConfig = {}; - if (Object.prototype.hasOwnProperty.call(config, "extends")) { - if (typeof config.extends !== "string") - return defaultConfig; - const isPath = /\.json|\..*rc$/.test(config.extends); - let pathToDefault = null; - if (!isPath) { - try { - pathToDefault = import.meta.resolve(config.extends); - } catch (_err) { - return config; - } - } else { - pathToDefault = getPathToDefaultConfig(cwd, config.extends); - } - checkForCircularExtends(pathToDefault); - previouslyVisitedConfigs.push(pathToDefault); - defaultConfig = isPath ? JSON.parse(shim2.readFileSync(pathToDefault, "utf8")) : _shim.require(config.extends); - delete config.extends; - defaultConfig = applyExtends(defaultConfig, shim2.path.dirname(pathToDefault), mergeExtends, shim2); - } - previouslyVisitedConfigs = []; - return mergeExtends ? mergeDeep(defaultConfig, config) : Object.assign({}, defaultConfig, config); -} -function checkForCircularExtends(cfgPath) { - if (previouslyVisitedConfigs.indexOf(cfgPath) > -1) { - throw new YError(`Circular extended configurations: '${cfgPath}'.`); - } -} -function getPathToDefaultConfig(cwd, pathToExtend) { - return shim2.path.resolve(cwd, pathToExtend); -} -function mergeDeep(config1, config2) { - const target = {}; - function isObject2(obj) { - return obj && typeof obj === "object" && !Array.isArray(obj); - } - Object.assign(target, config1); - for (const key of Object.keys(config2)) { - if (isObject2(config2[key]) && isObject2(target[key])) { - target[key] = mergeDeep(config1[key], config2[key]); - } else { - target[key] = config2[key]; + function parseTransform() { + const parser = new TOMLParser(); + return new stream.Transform({ + objectMode: true, + transform(chunk, encoding, cb) { + try { + parser.parse(chunk.toString(encoding)); + } catch (err) { + this.emit("error", err); + } + cb(); + }, + flush(cb) { + try { + this.push(parser.finish()); + } catch (err) { + this.emit("error", err); + } + cb(); + } + }); } } - return target; -} +}); -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/build/lib/yargs-factory.js -var __classPrivateFieldSet = function(receiver, state, value, kind, f2) { - if (typeof state === "function" ? receiver !== state || true : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); - return state.set(receiver, value), value; -}; -var __classPrivateFieldGet = function(receiver, state, kind, f2) { - if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); - return kind === "m" ? f2 : kind === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver); -}; -var _YargsInstance_command; -var _YargsInstance_cwd; -var _YargsInstance_context; -var _YargsInstance_completion; -var _YargsInstance_completionCommand; -var _YargsInstance_defaultShowHiddenOpt; -var _YargsInstance_exitError; -var _YargsInstance_detectLocale; -var _YargsInstance_emittedWarnings; -var _YargsInstance_exitProcess; -var _YargsInstance_frozens; -var _YargsInstance_globalMiddleware; -var _YargsInstance_groups; -var _YargsInstance_hasOutput; -var _YargsInstance_helpOpt; -var _YargsInstance_isGlobalContext; -var _YargsInstance_logger; -var _YargsInstance_output; -var _YargsInstance_options; -var _YargsInstance_parentRequire; -var _YargsInstance_parserConfig; -var _YargsInstance_parseFn; -var _YargsInstance_parseContext; -var _YargsInstance_pkgs; -var _YargsInstance_preservedGroups; -var _YargsInstance_processArgs; -var _YargsInstance_recommendCommands; -var _YargsInstance_shim; -var _YargsInstance_strict; -var _YargsInstance_strictCommands; -var _YargsInstance_strictOptions; -var _YargsInstance_usage; -var _YargsInstance_usageConfig; -var _YargsInstance_versionOpt; -var _YargsInstance_validation; -function YargsFactory(_shim) { - return (processArgs = [], cwd = _shim.process.cwd(), parentRequire) => { - const yargs = new YargsInstance(processArgs, cwd, parentRequire, _shim); - Object.defineProperty(yargs, "argv", { - get: () => { - return yargs.parse(); - }, - enumerable: true - }); - yargs.help(); - yargs.version(); - return yargs; - }; -} -var kCopyDoubleDash = /* @__PURE__ */ Symbol("copyDoubleDash"); -var kCreateLogger = /* @__PURE__ */ Symbol("copyDoubleDash"); -var kDeleteFromParserHintObject = /* @__PURE__ */ Symbol("deleteFromParserHintObject"); -var kEmitWarning = /* @__PURE__ */ Symbol("emitWarning"); -var kFreeze = /* @__PURE__ */ Symbol("freeze"); -var kGetDollarZero = /* @__PURE__ */ Symbol("getDollarZero"); -var kGetParserConfiguration = /* @__PURE__ */ Symbol("getParserConfiguration"); -var kGetUsageConfiguration = /* @__PURE__ */ Symbol("getUsageConfiguration"); -var kGuessLocale = /* @__PURE__ */ Symbol("guessLocale"); -var kGuessVersion = /* @__PURE__ */ Symbol("guessVersion"); -var kParsePositionalNumbers = /* @__PURE__ */ Symbol("parsePositionalNumbers"); -var kPkgUp = /* @__PURE__ */ Symbol("pkgUp"); -var kPopulateParserHintArray = /* @__PURE__ */ Symbol("populateParserHintArray"); -var kPopulateParserHintSingleValueDictionary = /* @__PURE__ */ Symbol("populateParserHintSingleValueDictionary"); -var kPopulateParserHintArrayDictionary = /* @__PURE__ */ Symbol("populateParserHintArrayDictionary"); -var kPopulateParserHintDictionary = /* @__PURE__ */ Symbol("populateParserHintDictionary"); -var kSanitizeKey = /* @__PURE__ */ Symbol("sanitizeKey"); -var kSetKey = /* @__PURE__ */ Symbol("setKey"); -var kUnfreeze = /* @__PURE__ */ Symbol("unfreeze"); -var kValidateAsync = /* @__PURE__ */ Symbol("validateAsync"); -var kGetCommandInstance = /* @__PURE__ */ Symbol("getCommandInstance"); -var kGetContext = /* @__PURE__ */ Symbol("getContext"); -var kGetHasOutput = /* @__PURE__ */ Symbol("getHasOutput"); -var kGetLoggerInstance = /* @__PURE__ */ Symbol("getLoggerInstance"); -var kGetParseContext = /* @__PURE__ */ Symbol("getParseContext"); -var kGetUsageInstance = /* @__PURE__ */ Symbol("getUsageInstance"); -var kGetValidationInstance = /* @__PURE__ */ Symbol("getValidationInstance"); -var kHasParseCallback = /* @__PURE__ */ Symbol("hasParseCallback"); -var kIsGlobalContext = /* @__PURE__ */ Symbol("isGlobalContext"); -var kPostProcess = /* @__PURE__ */ Symbol("postProcess"); -var kRebase = /* @__PURE__ */ Symbol("rebase"); -var kReset = /* @__PURE__ */ Symbol("reset"); -var kRunYargsParserAndExecuteCommands = /* @__PURE__ */ Symbol("runYargsParserAndExecuteCommands"); -var kRunValidation = /* @__PURE__ */ Symbol("runValidation"); -var kSetHasOutput = /* @__PURE__ */ Symbol("setHasOutput"); -var kTrackManuallySetKeys = /* @__PURE__ */ Symbol("kTrackManuallySetKeys"); -var DEFAULT_LOCALE = "en_US"; -var YargsInstance = class { - constructor(processArgs = [], cwd, parentRequire, shim3) { - this.customScriptName = false; - this.parsed = false; - _YargsInstance_command.set(this, void 0); - _YargsInstance_cwd.set(this, void 0); - _YargsInstance_context.set(this, { commands: [], fullCommands: [] }); - _YargsInstance_completion.set(this, null); - _YargsInstance_completionCommand.set(this, null); - _YargsInstance_defaultShowHiddenOpt.set(this, "show-hidden"); - _YargsInstance_exitError.set(this, null); - _YargsInstance_detectLocale.set(this, true); - _YargsInstance_emittedWarnings.set(this, {}); - _YargsInstance_exitProcess.set(this, true); - _YargsInstance_frozens.set(this, []); - _YargsInstance_globalMiddleware.set(this, void 0); - _YargsInstance_groups.set(this, {}); - _YargsInstance_hasOutput.set(this, false); - _YargsInstance_helpOpt.set(this, null); - _YargsInstance_isGlobalContext.set(this, true); - _YargsInstance_logger.set(this, void 0); - _YargsInstance_output.set(this, ""); - _YargsInstance_options.set(this, void 0); - _YargsInstance_parentRequire.set(this, void 0); - _YargsInstance_parserConfig.set(this, {}); - _YargsInstance_parseFn.set(this, null); - _YargsInstance_parseContext.set(this, null); - _YargsInstance_pkgs.set(this, {}); - _YargsInstance_preservedGroups.set(this, {}); - _YargsInstance_processArgs.set(this, void 0); - _YargsInstance_recommendCommands.set(this, false); - _YargsInstance_shim.set(this, void 0); - _YargsInstance_strict.set(this, false); - _YargsInstance_strictCommands.set(this, false); - _YargsInstance_strictOptions.set(this, false); - _YargsInstance_usage.set(this, void 0); - _YargsInstance_usageConfig.set(this, {}); - _YargsInstance_versionOpt.set(this, null); - _YargsInstance_validation.set(this, void 0); - __classPrivateFieldSet(this, _YargsInstance_shim, shim3); - __classPrivateFieldSet(this, _YargsInstance_processArgs, processArgs); - __classPrivateFieldSet(this, _YargsInstance_cwd, cwd); - __classPrivateFieldSet(this, _YargsInstance_parentRequire, parentRequire); - __classPrivateFieldSet(this, _YargsInstance_globalMiddleware, new GlobalMiddleware(this)); - this.$0 = this[kGetDollarZero](); - this[kReset](); - __classPrivateFieldSet(this, _YargsInstance_command, __classPrivateFieldGet(this, _YargsInstance_command, "f")); - __classPrivateFieldSet(this, _YargsInstance_usage, __classPrivateFieldGet(this, _YargsInstance_usage, "f")); - __classPrivateFieldSet(this, _YargsInstance_validation, __classPrivateFieldGet(this, _YargsInstance_validation, "f")); - __classPrivateFieldSet(this, _YargsInstance_options, __classPrivateFieldGet(this, _YargsInstance_options, "f")); - __classPrivateFieldGet(this, _YargsInstance_options, "f").showHiddenOpt = __classPrivateFieldGet(this, _YargsInstance_defaultShowHiddenOpt, "f"); - __classPrivateFieldSet(this, _YargsInstance_logger, this[kCreateLogger]()); - __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.setLocale(DEFAULT_LOCALE); - } - addHelpOpt(opt, msg) { - const defaultHelpOpt = "help"; - argsert("[string|boolean] [string]", [opt, msg], arguments.length); - if (__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")) { - this[kDeleteFromParserHintObject](__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")); - __classPrivateFieldSet(this, _YargsInstance_helpOpt, null); - } - if (opt === false && msg === void 0) - return this; - __classPrivateFieldSet(this, _YargsInstance_helpOpt, typeof opt === "string" ? opt : defaultHelpOpt); - this.boolean(__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")); - this.describe(__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"), msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Show help")); - return this; - } - help(opt, msg) { - return this.addHelpOpt(opt, msg); - } - addShowHiddenOpt(opt, msg) { - argsert("[string|boolean] [string]", [opt, msg], arguments.length); - if (opt === false && msg === void 0) - return this; - const showHiddenOpt = typeof opt === "string" ? opt : __classPrivateFieldGet(this, _YargsInstance_defaultShowHiddenOpt, "f"); - this.boolean(showHiddenOpt); - this.describe(showHiddenOpt, msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Show hidden options")); - __classPrivateFieldGet(this, _YargsInstance_options, "f").showHiddenOpt = showHiddenOpt; - return this; - } - showHidden(opt, msg) { - return this.addShowHiddenOpt(opt, msg); - } - alias(key, value) { - argsert(" [string|array]", [key, value], arguments.length); - this[kPopulateParserHintArrayDictionary](this.alias.bind(this), "alias", key, value); - return this; - } - array(keys) { - argsert("", [keys], arguments.length); - this[kPopulateParserHintArray]("array", keys); - this[kTrackManuallySetKeys](keys); - return this; - } - boolean(keys) { - argsert("", [keys], arguments.length); - this[kPopulateParserHintArray]("boolean", keys); - this[kTrackManuallySetKeys](keys); - return this; - } - check(f2, global2) { - argsert(" [boolean]", [f2, global2], arguments.length); - this.middleware((argv, _yargs) => { - return maybeAsyncResult(() => { - return f2(argv, _yargs.getOptions()); - }, (result) => { - if (!result) { - __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(__classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.__("Argument check failed: %s", f2.toString())); - } else if (typeof result === "string" || result instanceof Error) { - __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(result.toString(), result); - } - return argv; - }, (err) => { - __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(err.message ? err.message : err.toString(), err); - return argv; - }); - }, false, global2); - return this; - } - choices(key, value) { - argsert(" [string|array]", [key, value], arguments.length); - this[kPopulateParserHintArrayDictionary](this.choices.bind(this), "choices", key, value); - return this; - } - coerce(keys, value) { - argsert(" [function]", [keys, value], arguments.length); - if (Array.isArray(keys)) { - if (!value) { - throw new YError("coerce callback must be provided"); - } - for (const key of keys) { - this.coerce(key, value); - } - return this; - } else if (typeof keys === "object") { - for (const key of Object.keys(keys)) { - this.coerce(key, keys[key]); - } - return this; - } - if (!value) { - throw new YError("coerce callback must be provided"); - } - const coerceKey = keys; - __classPrivateFieldGet(this, _YargsInstance_options, "f").key[coerceKey] = true; - __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addCoerceMiddleware((argv, yargs) => { - var _a2; - const coerceKeyAliases = (_a2 = yargs.getAliases()[coerceKey]) !== null && _a2 !== void 0 ? _a2 : []; - const argvKeys = [coerceKey, ...coerceKeyAliases].filter((key) => Object.prototype.hasOwnProperty.call(argv, key)); - if (argvKeys.length === 0) { - return argv; - } - return maybeAsyncResult(() => { - return value(argv[argvKeys[0]]); - }, (result) => { - argvKeys.forEach((key) => { - argv[key] = result; - }); - return argv; - }, (err) => { - throw new YError(err.message); - }); - }, coerceKey); - return this; - } - conflicts(key1, key2) { - argsert(" [string|array]", [key1, key2], arguments.length); - __classPrivateFieldGet(this, _YargsInstance_validation, "f").conflicts(key1, key2); - return this; - } - config(key = "config", msg, parseFn) { - argsert("[object|string] [string|function] [function]", [key, msg, parseFn], arguments.length); - if (typeof key === "object" && !Array.isArray(key)) { - key = applyExtends(key, __classPrivateFieldGet(this, _YargsInstance_cwd, "f"), this[kGetParserConfiguration]()["deep-merge-config"] || false, __classPrivateFieldGet(this, _YargsInstance_shim, "f")); - __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = (__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || []).concat(key); - return this; - } - if (typeof msg === "function") { - parseFn = msg; - msg = void 0; - } - this.describe(key, msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Path to JSON config file")); - (Array.isArray(key) ? key : [key]).forEach((k) => { - __classPrivateFieldGet(this, _YargsInstance_options, "f").config[k] = parseFn || true; - }); - return this; - } - completion(cmd, desc, fn) { - argsert("[string] [string|boolean|function] [function]", [cmd, desc, fn], arguments.length); - if (typeof desc === "function") { - fn = desc; - desc = void 0; - } - __classPrivateFieldSet(this, _YargsInstance_completionCommand, cmd || __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") || "completion"); - if (!desc && desc !== false) { - desc = "generate completion script"; - } - this.command(__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f"), desc); - if (fn) - __classPrivateFieldGet(this, _YargsInstance_completion, "f").registerFunction(fn); - return this; - } - command(cmd, description, builder, handler, middlewares, deprecated) { - argsert(" [string|boolean] [function|object] [function] [array] [boolean|string]", [cmd, description, builder, handler, middlewares, deprecated], arguments.length); - __classPrivateFieldGet(this, _YargsInstance_command, "f").addHandler(cmd, description, builder, handler, middlewares, deprecated); - return this; - } - commands(cmd, description, builder, handler, middlewares, deprecated) { - return this.command(cmd, description, builder, handler, middlewares, deprecated); - } - commandDir(dir, opts) { - argsert(" [object]", [dir, opts], arguments.length); - const req = __classPrivateFieldGet(this, _YargsInstance_parentRequire, "f") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").require; - __classPrivateFieldGet(this, _YargsInstance_command, "f").addDirectory(dir, req, __classPrivateFieldGet(this, _YargsInstance_shim, "f").getCallerFile(), opts); - return this; - } - count(keys) { - argsert("", [keys], arguments.length); - this[kPopulateParserHintArray]("count", keys); - this[kTrackManuallySetKeys](keys); - return this; - } - default(key, value, defaultDescription) { - argsert(" [*] [string]", [key, value, defaultDescription], arguments.length); - if (defaultDescription) { - assertSingleKey(key, __classPrivateFieldGet(this, _YargsInstance_shim, "f")); - __classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = defaultDescription; - } - if (typeof value === "function") { - assertSingleKey(key, __classPrivateFieldGet(this, _YargsInstance_shim, "f")); - if (!__classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key]) - __classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = __classPrivateFieldGet(this, _YargsInstance_usage, "f").functionDescription(value); - value = value.call(); - } - this[kPopulateParserHintSingleValueDictionary](this.default.bind(this), "default", key, value); - return this; - } - defaults(key, value, defaultDescription) { - return this.default(key, value, defaultDescription); - } - demandCommand(min = 1, max, minMsg, maxMsg) { - argsert("[number] [number|string] [string|null|undefined] [string|null|undefined]", [min, max, minMsg, maxMsg], arguments.length); - if (typeof max !== "number") { - minMsg = max; - max = Infinity; - } - this.global("_", false); - __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedCommands._ = { - min, - max, - minMsg, - maxMsg - }; - return this; +// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse.js +var require_parse = __commonJS({ + "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse.js"(exports2, module2) { + init_esm_shims(); + module2.exports = require_parse_string(); + module2.exports.async = require_parse_async(); + module2.exports.stream = require_parse_stream(); + module2.exports.prettyError = require_parse_pretty_error(); } - demand(keys, max, msg) { - if (Array.isArray(max)) { - max.forEach((key) => { - assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f")); - this.demandOption(key, msg); - }); - max = Infinity; - } else if (typeof max !== "number") { - msg = max; - max = Infinity; - } - if (typeof keys === "number") { - assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f")); - this.demandCommand(keys, max, msg, msg); - } else if (Array.isArray(keys)) { - keys.forEach((key) => { - assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f")); - this.demandOption(key, msg); - }); - } else { - if (typeof msg === "string") { - this.demandOption(keys, msg); - } else if (msg === true || typeof msg === "undefined") { - this.demandOption(keys); - } +}); + +// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/stringify.js +var require_stringify2 = __commonJS({ + "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/stringify.js"(exports2, module2) { + init_esm_shims(); + module2.exports = stringify; + module2.exports.value = stringifyInline; + function stringify(obj) { + if (obj === null) throw typeError("null"); + if (obj === void 0) throw typeError("undefined"); + if (typeof obj !== "object") throw typeError(typeof obj); + if (typeof obj.toJSON === "function") obj = obj.toJSON(); + if (obj == null) return null; + const type = tomlType2(obj); + if (type !== "table") throw typeError(type); + return stringifyObject("", "", obj); + } + function typeError(type) { + return new Error("Can only stringify objects, not " + type); + } + function arrayOneTypeError() { + return new Error("Array values can't have mixed types"); } - return this; - } - demandOption(keys, msg) { - argsert(" [string]", [keys, msg], arguments.length); - this[kPopulateParserHintSingleValueDictionary](this.demandOption.bind(this), "demandedOptions", keys, msg); - return this; - } - deprecateOption(option, message) { - argsert(" [string|boolean]", [option, message], arguments.length); - __classPrivateFieldGet(this, _YargsInstance_options, "f").deprecatedOptions[option] = message; - return this; - } - describe(keys, description) { - argsert(" [string]", [keys, description], arguments.length); - this[kSetKey](keys, true); - __classPrivateFieldGet(this, _YargsInstance_usage, "f").describe(keys, description); - return this; - } - detectLocale(detect) { - argsert("", [detect], arguments.length); - __classPrivateFieldSet(this, _YargsInstance_detectLocale, detect); - return this; - } - env(prefix) { - argsert("[string|boolean]", [prefix], arguments.length); - if (prefix === false) - delete __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix; - else - __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix = prefix || ""; - return this; - } - epilogue(msg) { - argsert("", [msg], arguments.length); - __classPrivateFieldGet(this, _YargsInstance_usage, "f").epilog(msg); - return this; - } - epilog(msg) { - return this.epilogue(msg); - } - example(cmd, description) { - argsert(" [string]", [cmd, description], arguments.length); - if (Array.isArray(cmd)) { - cmd.forEach((exampleParams) => this.example(...exampleParams)); - } else { - __classPrivateFieldGet(this, _YargsInstance_usage, "f").example(cmd, description); - } - return this; - } - exit(code, err) { - __classPrivateFieldSet(this, _YargsInstance_hasOutput, true); - __classPrivateFieldSet(this, _YargsInstance_exitError, err); - if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f")) - __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.exit(code); - } - exitProcess(enabled = true) { - argsert("[boolean]", [enabled], arguments.length); - __classPrivateFieldSet(this, _YargsInstance_exitProcess, enabled); - return this; - } - fail(f2) { - argsert("", [f2], arguments.length); - if (typeof f2 === "boolean" && f2 !== false) { - throw new YError("Invalid first argument. Expected function or boolean 'false'"); + function getInlineKeys(obj) { + return Object.keys(obj).filter((key) => isInline(obj[key])); } - __classPrivateFieldGet(this, _YargsInstance_usage, "f").failFn(f2); - return this; - } - getAliases() { - return this.parsed ? this.parsed.aliases : {}; - } - async getCompletion(args, done) { - argsert(" [function]", [args, done], arguments.length); - if (!done) { - return new Promise((resolve5, reject) => { - __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => { - if (err) - reject(err); - else - resolve5(completions); - }); - }); - } else { - return __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, done); + function getComplexKeys(obj) { + return Object.keys(obj).filter((key) => !isInline(obj[key])); } - } - getDemandedOptions() { - argsert([], 0); - return __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedOptions; - } - getDemandedCommands() { - argsert([], 0); - return __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedCommands; - } - getDeprecatedOptions() { - argsert([], 0); - return __classPrivateFieldGet(this, _YargsInstance_options, "f").deprecatedOptions; - } - getDetectLocale() { - return __classPrivateFieldGet(this, _YargsInstance_detectLocale, "f"); - } - getExitProcess() { - return __classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"); - } - getGroups() { - return Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_groups, "f"), __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")); - } - getHelp() { - __classPrivateFieldSet(this, _YargsInstance_hasOutput, true); - if (!__classPrivateFieldGet(this, _YargsInstance_usage, "f").hasCachedHelpMessage()) { - if (!this.parsed) { - const parse3 = this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this, _YargsInstance_processArgs, "f"), void 0, void 0, 0, true); - if (isPromise(parse3)) { - return parse3.then(() => { - return __classPrivateFieldGet(this, _YargsInstance_usage, "f").help(); - }); + function toJSON(obj) { + let nobj = Array.isArray(obj) ? [] : Object.prototype.hasOwnProperty.call(obj, "__proto__") ? { ["__proto__"]: void 0 } : {}; + for (let prop of Object.keys(obj)) { + if (obj[prop] && typeof obj[prop].toJSON === "function" && !("toISOString" in obj[prop])) { + nobj[prop] = obj[prop].toJSON(); + } else { + nobj[prop] = obj[prop]; } } - const builderResponse = __classPrivateFieldGet(this, _YargsInstance_command, "f").runDefaultBuilderOn(this); - if (isPromise(builderResponse)) { - return builderResponse.then(() => { - return __classPrivateFieldGet(this, _YargsInstance_usage, "f").help(); - }); - } + return nobj; } - return Promise.resolve(__classPrivateFieldGet(this, _YargsInstance_usage, "f").help()); - } - getOptions() { - return __classPrivateFieldGet(this, _YargsInstance_options, "f"); - } - getStrict() { - return __classPrivateFieldGet(this, _YargsInstance_strict, "f"); - } - getStrictCommands() { - return __classPrivateFieldGet(this, _YargsInstance_strictCommands, "f"); - } - getStrictOptions() { - return __classPrivateFieldGet(this, _YargsInstance_strictOptions, "f"); - } - global(globals, global2) { - argsert(" [boolean]", [globals, global2], arguments.length); - globals = [].concat(globals); - if (global2 !== false) { - __classPrivateFieldGet(this, _YargsInstance_options, "f").local = __classPrivateFieldGet(this, _YargsInstance_options, "f").local.filter((l2) => globals.indexOf(l2) === -1); - } else { - globals.forEach((g2) => { - if (!__classPrivateFieldGet(this, _YargsInstance_options, "f").local.includes(g2)) - __classPrivateFieldGet(this, _YargsInstance_options, "f").local.push(g2); + function stringifyObject(prefix, indent, obj) { + obj = toJSON(obj); + var inlineKeys; + var complexKeys; + inlineKeys = getInlineKeys(obj); + complexKeys = getComplexKeys(obj); + var result = []; + var inlineIndent = indent || ""; + inlineKeys.forEach((key) => { + var type = tomlType2(obj[key]); + if (type !== "undefined" && type !== "null") { + result.push(inlineIndent + stringifyKey(key) + " = " + stringifyAnyInline(obj[key], true)); + } }); - } - return this; - } - group(opts, groupName) { - argsert(" ", [opts, groupName], arguments.length); - const existing = __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName] || __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName]; - if (__classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName]) { - delete __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName]; - } - const seen = {}; - __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName] = (existing || []).concat(opts).filter((key) => { - if (seen[key]) - return false; - return seen[key] = true; - }); - return this; - } - hide(key) { - argsert("", [key], arguments.length); - __classPrivateFieldGet(this, _YargsInstance_options, "f").hiddenOptions.push(key); - return this; - } - implies(key, value) { - argsert(" [number|string|array]", [key, value], arguments.length); - __classPrivateFieldGet(this, _YargsInstance_validation, "f").implies(key, value); - return this; - } - locale(locale) { - argsert("[string]", [locale], arguments.length); - if (locale === void 0) { - this[kGuessLocale](); - return __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.getLocale(); - } - __classPrivateFieldSet(this, _YargsInstance_detectLocale, false); - __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.setLocale(locale); - return this; - } - middleware(callback, applyBeforeValidation, global2) { - return __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addMiddleware(callback, !!applyBeforeValidation, global2); - } - nargs(key, value) { - argsert(" [number]", [key, value], arguments.length); - this[kPopulateParserHintSingleValueDictionary](this.nargs.bind(this), "narg", key, value); - return this; - } - normalize(keys) { - argsert("", [keys], arguments.length); - this[kPopulateParserHintArray]("normalize", keys); - return this; - } - number(keys) { - argsert("", [keys], arguments.length); - this[kPopulateParserHintArray]("number", keys); - this[kTrackManuallySetKeys](keys); - return this; - } - option(key, opt) { - argsert(" [object]", [key, opt], arguments.length); - if (typeof key === "object") { - Object.keys(key).forEach((k) => { - this.options(k, key[k]); + if (result.length > 0) result.push(""); + var complexIndent = prefix && inlineKeys.length > 0 ? indent + " " : ""; + complexKeys.forEach((key) => { + result.push(stringifyComplex(prefix, complexIndent, key, obj[key])); }); - } else { - if (typeof opt !== "object") { - opt = {}; - } - this[kTrackManuallySetKeys](key); - if (__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f") && (key === "version" || (opt === null || opt === void 0 ? void 0 : opt.alias) === "version")) { - this[kEmitWarning]([ - '"version" is a reserved word.', - "Please do one of the following:", - '- Disable version with `yargs.version(false)` if using "version" as an option', - "- Use the built-in `yargs.version` method instead (if applicable)", - "- Use a different option key", - "https://yargs.js.org/docs/#api-reference-version" - ].join("\n"), void 0, "versionWarning"); - } - __classPrivateFieldGet(this, _YargsInstance_options, "f").key[key] = true; - if (opt.alias) - this.alias(key, opt.alias); - const deprecate = opt.deprecate || opt.deprecated; - if (deprecate) { - this.deprecateOption(key, deprecate); - } - const demand = opt.demand || opt.required || opt.require; - if (demand) { - this.demand(key, demand); - } - if (opt.demandOption) { - this.demandOption(key, typeof opt.demandOption === "string" ? opt.demandOption : void 0); - } - if (opt.conflicts) { - this.conflicts(key, opt.conflicts); - } - if ("default" in opt) { - this.default(key, opt.default); - } - if (opt.implies !== void 0) { - this.implies(key, opt.implies); - } - if (opt.nargs !== void 0) { - this.nargs(key, opt.nargs); - } - if (opt.config) { - this.config(key, opt.configParser); - } - if (opt.normalize) { - this.normalize(key); - } - if (opt.choices) { - this.choices(key, opt.choices); - } - if (opt.coerce) { - this.coerce(key, opt.coerce); - } - if (opt.group) { - this.group(key, opt.group); - } - if (opt.boolean || opt.type === "boolean") { - this.boolean(key); - if (opt.alias) - this.boolean(opt.alias); - } - if (opt.array || opt.type === "array") { - this.array(key); - if (opt.alias) - this.array(opt.alias); - } - if (opt.number || opt.type === "number") { - this.number(key); - if (opt.alias) - this.number(opt.alias); - } - if (opt.string || opt.type === "string") { - this.string(key); - if (opt.alias) - this.string(opt.alias); - } - if (opt.count || opt.type === "count") { - this.count(key); - } - if (typeof opt.global === "boolean") { - this.global(key, opt.global); - } - if (opt.defaultDescription) { - __classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = opt.defaultDescription; - } - if (opt.skipValidation) { - this.skipValidation(key); - } - const desc = opt.describe || opt.description || opt.desc; - const descriptions = __classPrivateFieldGet(this, _YargsInstance_usage, "f").getDescriptions(); - if (!Object.prototype.hasOwnProperty.call(descriptions, key) || typeof desc === "string") { - this.describe(key, desc); + return result.join("\n"); + } + function isInline(value) { + switch (tomlType2(value)) { + case "undefined": + case "null": + case "integer": + case "nan": + case "float": + case "boolean": + case "string": + case "datetime": + return true; + case "array": + return value.length === 0 || tomlType2(value[0]) !== "table"; + case "table": + return Object.keys(value).length === 0; + /* istanbul ignore next */ + default: + return false; } - if (opt.hidden) { - this.hide(key); + } + function tomlType2(value) { + if (value === void 0) { + return "undefined"; + } else if (value === null) { + return "null"; + } else if (typeof value === "bigint" || Number.isInteger(value) && !Object.is(value, -0)) { + return "integer"; + } else if (typeof value === "number") { + return "float"; + } else if (typeof value === "boolean") { + return "boolean"; + } else if (typeof value === "string") { + return "string"; + } else if ("toISOString" in value) { + return isNaN(value) ? "undefined" : "datetime"; + } else if (Array.isArray(value)) { + return "array"; + } else { + return "table"; } - if (opt.requiresArg) { - this.requiresArg(key); + } + function stringifyKey(key) { + var keyStr = String(key); + if (/^[-A-Za-z0-9_]+$/.test(keyStr)) { + return keyStr; + } else { + return stringifyBasicString(keyStr); } } - return this; - } - options(key, opt) { - return this.option(key, opt); - } - parse(args, shortCircuit, _parseFn) { - argsert("[string|array] [function|boolean|object] [function]", [args, shortCircuit, _parseFn], arguments.length); - this[kFreeze](); - if (typeof args === "undefined") { - args = __classPrivateFieldGet(this, _YargsInstance_processArgs, "f"); - } - if (typeof shortCircuit === "object") { - __classPrivateFieldSet(this, _YargsInstance_parseContext, shortCircuit); - shortCircuit = _parseFn; - } - if (typeof shortCircuit === "function") { - __classPrivateFieldSet(this, _YargsInstance_parseFn, shortCircuit); - shortCircuit = false; - } - if (!shortCircuit) - __classPrivateFieldSet(this, _YargsInstance_processArgs, args); - if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")) - __classPrivateFieldSet(this, _YargsInstance_exitProcess, false); - const parsed = this[kRunYargsParserAndExecuteCommands](args, !!shortCircuit); - const tmpParsed = this.parsed; - __classPrivateFieldGet(this, _YargsInstance_completion, "f").setParsed(this.parsed); - if (isPromise(parsed)) { - return parsed.then((argv) => { - if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")) - __classPrivateFieldGet(this, _YargsInstance_parseFn, "f").call(this, __classPrivateFieldGet(this, _YargsInstance_exitError, "f"), argv, __classPrivateFieldGet(this, _YargsInstance_output, "f")); - return argv; - }).catch((err) => { - if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")) { - __classPrivateFieldGet(this, _YargsInstance_parseFn, "f")(err, this.parsed.argv, __classPrivateFieldGet(this, _YargsInstance_output, "f")); - } - throw err; - }).finally(() => { - this[kUnfreeze](); - this.parsed = tmpParsed; - }); - } else { - if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")) - __classPrivateFieldGet(this, _YargsInstance_parseFn, "f").call(this, __classPrivateFieldGet(this, _YargsInstance_exitError, "f"), parsed, __classPrivateFieldGet(this, _YargsInstance_output, "f")); - this[kUnfreeze](); - this.parsed = tmpParsed; + function stringifyBasicString(str) { + return '"' + escapeString(str).replace(/"/g, '\\"') + '"'; } - return parsed; - } - parseAsync(args, shortCircuit, _parseFn) { - const maybePromise = this.parse(args, shortCircuit, _parseFn); - return !isPromise(maybePromise) ? Promise.resolve(maybePromise) : maybePromise; - } - parseSync(args, shortCircuit, _parseFn) { - const maybePromise = this.parse(args, shortCircuit, _parseFn); - if (isPromise(maybePromise)) { - throw new YError(".parseSync() must not be used with asynchronous builders, handlers, or middleware"); + function stringifyLiteralString(str) { + return "'" + str + "'"; } - return maybePromise; - } - parserConfiguration(config) { - argsert("", [config], arguments.length); - __classPrivateFieldSet(this, _YargsInstance_parserConfig, config); - return this; - } - pkgConf(key, rootPath) { - argsert(" [string]", [key, rootPath], arguments.length); - let conf = null; - const obj = this[kPkgUp](rootPath || __classPrivateFieldGet(this, _YargsInstance_cwd, "f")); - if (obj[key] && typeof obj[key] === "object") { - conf = applyExtends(obj[key], rootPath || __classPrivateFieldGet(this, _YargsInstance_cwd, "f"), this[kGetParserConfiguration]()["deep-merge-config"] || false, __classPrivateFieldGet(this, _YargsInstance_shim, "f")); - __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = (__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || []).concat(conf); - } - return this; - } - positional(key, opts) { - argsert(" ", [key, opts], arguments.length); - const supportedOpts = [ - "default", - "defaultDescription", - "implies", - "normalize", - "choices", - "conflicts", - "coerce", - "type", - "describe", - "desc", - "description", - "alias" - ]; - opts = objFilter(opts, (k, v2) => { - if (k === "type" && !["string", "number", "boolean"].includes(v2)) - return false; - return supportedOpts.includes(k); - }); - const fullCommand = __classPrivateFieldGet(this, _YargsInstance_context, "f").fullCommands[__classPrivateFieldGet(this, _YargsInstance_context, "f").fullCommands.length - 1]; - const parseOptions = fullCommand ? __classPrivateFieldGet(this, _YargsInstance_command, "f").cmdToParseOptions(fullCommand) : { - array: [], - alias: {}, - default: {}, - demand: {} - }; - objectKeys(parseOptions).forEach((pk) => { - const parseOption = parseOptions[pk]; - if (Array.isArray(parseOption)) { - if (parseOption.indexOf(key) !== -1) - opts[pk] = true; - } else { - if (parseOption[key] && !(pk in opts)) - opts[pk] = parseOption[key]; - } - }); - this.group(key, __classPrivateFieldGet(this, _YargsInstance_usage, "f").getPositionalGroupName()); - return this.option(key, opts); - } - recommendCommands(recommend = true) { - argsert("[boolean]", [recommend], arguments.length); - __classPrivateFieldSet(this, _YargsInstance_recommendCommands, recommend); - return this; - } - required(keys, max, msg) { - return this.demand(keys, max, msg); - } - require(keys, max, msg) { - return this.demand(keys, max, msg); - } - requiresArg(keys) { - argsert(" [number]", [keys], arguments.length); - if (typeof keys === "string" && __classPrivateFieldGet(this, _YargsInstance_options, "f").narg[keys]) { - return this; - } else { - this[kPopulateParserHintSingleValueDictionary](this.requiresArg.bind(this), "narg", keys, NaN); - } - return this; - } - showCompletionScript($0, cmd) { - argsert("[string] [string]", [$0, cmd], arguments.length); - $0 = $0 || this.$0; - __classPrivateFieldGet(this, _YargsInstance_logger, "f").log(__classPrivateFieldGet(this, _YargsInstance_completion, "f").generateCompletionScript($0, cmd || __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") || "completion")); - return this; - } - showHelp(level) { - argsert("[string|function]", [level], arguments.length); - __classPrivateFieldSet(this, _YargsInstance_hasOutput, true); - if (!__classPrivateFieldGet(this, _YargsInstance_usage, "f").hasCachedHelpMessage()) { - if (!this.parsed) { - const parse3 = this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this, _YargsInstance_processArgs, "f"), void 0, void 0, 0, true); - if (isPromise(parse3)) { - parse3.then(() => { - __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level); - }); - return this; + function numpad(num, str) { + while (str.length < num) str = "0" + str; + return str; + } + function escapeString(str) { + return str.replace(/\\/g, "\\\\").replace(/[\b]/g, "\\b").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\f/g, "\\f").replace(/\r/g, "\\r").replace(/([\u0000-\u001f\u007f])/, (c2) => "\\u" + numpad(4, c2.codePointAt(0).toString(16))); + } + function stringifyMultilineString(str) { + let escaped = str.split(/\n/).map((str2) => { + return escapeString(str2).replace(/"(?="")/g, '\\"'); + }).join("\n"); + if (escaped.slice(-1) === '"') escaped += "\\\n"; + return '"""\n' + escaped + '"""'; + } + function stringifyAnyInline(value, multilineOk) { + let type = tomlType2(value); + if (type === "string") { + if (multilineOk && /\n/.test(value)) { + type = "string-multiline"; + } else if (!/[\b\t\n\f\r']/.test(value) && /"/.test(value)) { + type = "string-literal"; } } - const builderResponse = __classPrivateFieldGet(this, _YargsInstance_command, "f").runDefaultBuilderOn(this); - if (isPromise(builderResponse)) { - builderResponse.then(() => { - __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level); - }); - return this; - } + return stringifyInline(value, type); } - __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level); - return this; - } - scriptName(scriptName) { - this.customScriptName = true; - this.$0 = scriptName; - return this; - } - showHelpOnFail(enabled, message) { - argsert("[boolean|string] [string]", [enabled, message], arguments.length); - __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelpOnFail(enabled, message); - return this; - } - showVersion(level) { - argsert("[string|function]", [level], arguments.length); - __classPrivateFieldGet(this, _YargsInstance_usage, "f").showVersion(level); - return this; - } - skipValidation(keys) { - argsert("", [keys], arguments.length); - this[kPopulateParserHintArray]("skipValidation", keys); - return this; - } - strict(enabled) { - argsert("[boolean]", [enabled], arguments.length); - __classPrivateFieldSet(this, _YargsInstance_strict, enabled !== false); - return this; - } - strictCommands(enabled) { - argsert("[boolean]", [enabled], arguments.length); - __classPrivateFieldSet(this, _YargsInstance_strictCommands, enabled !== false); - return this; - } - strictOptions(enabled) { - argsert("[boolean]", [enabled], arguments.length); - __classPrivateFieldSet(this, _YargsInstance_strictOptions, enabled !== false); - return this; - } - string(keys) { - argsert("", [keys], arguments.length); - this[kPopulateParserHintArray]("string", keys); - this[kTrackManuallySetKeys](keys); - return this; - } - terminalWidth() { - argsert([], 0); - return __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.stdColumns; - } - updateLocale(obj) { - return this.updateStrings(obj); - } - updateStrings(obj) { - argsert("", [obj], arguments.length); - __classPrivateFieldSet(this, _YargsInstance_detectLocale, false); - __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.updateLocale(obj); - return this; - } - usage(msg, description, builder, handler) { - argsert(" [string|boolean] [function|object] [function]", [msg, description, builder, handler], arguments.length); - if (description !== void 0) { - assertNotStrictEqual(msg, null, __classPrivateFieldGet(this, _YargsInstance_shim, "f")); - if ((msg || "").match(/^\$0( |$)/)) { - return this.command(msg, description, builder, handler); - } else { - throw new YError(".usage() description must start with $0 if being used as alias for .command()"); + function stringifyInline(value, type) { + if (!type) type = tomlType2(value); + switch (type) { + case "string-multiline": + return stringifyMultilineString(value); + case "string": + return stringifyBasicString(value); + case "string-literal": + return stringifyLiteralString(value); + case "integer": + return stringifyInteger(value); + case "float": + return stringifyFloat(value); + case "boolean": + return stringifyBoolean(value); + case "datetime": + return stringifyDatetime(value); + case "array": + return stringifyInlineArray(value.filter((_) => tomlType2(_) !== "null" && tomlType2(_) !== "undefined" && tomlType2(_) !== "nan")); + case "table": + return stringifyInlineTable(value); + /* istanbul ignore next */ + default: + throw typeError(type); } - } else { - __classPrivateFieldGet(this, _YargsInstance_usage, "f").usage(msg); - return this; } - } - usageConfiguration(config) { - argsert("", [config], arguments.length); - __classPrivateFieldSet(this, _YargsInstance_usageConfig, config); - return this; - } - version(opt, msg, ver) { - const defaultVersionOpt = "version"; - argsert("[boolean|string] [string] [string]", [opt, msg, ver], arguments.length); - if (__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f")) { - this[kDeleteFromParserHintObject](__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f")); - __classPrivateFieldGet(this, _YargsInstance_usage, "f").version(void 0); - __classPrivateFieldSet(this, _YargsInstance_versionOpt, null); - } - if (arguments.length === 0) { - ver = this[kGuessVersion](); - opt = defaultVersionOpt; - } else if (arguments.length === 1) { - if (opt === false) { - return this; - } - ver = opt; - opt = defaultVersionOpt; - } else if (arguments.length === 2) { - ver = msg; - msg = void 0; - } - __classPrivateFieldSet(this, _YargsInstance_versionOpt, typeof opt === "string" ? opt : defaultVersionOpt); - msg = msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Show version number"); - __classPrivateFieldGet(this, _YargsInstance_usage, "f").version(ver || void 0); - this.boolean(__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f")); - this.describe(__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"), msg); - return this; - } - wrap(cols) { - argsert("", [cols], arguments.length); - __classPrivateFieldGet(this, _YargsInstance_usage, "f").wrap(cols); - return this; - } - [(_YargsInstance_command = /* @__PURE__ */ new WeakMap(), _YargsInstance_cwd = /* @__PURE__ */ new WeakMap(), _YargsInstance_context = /* @__PURE__ */ new WeakMap(), _YargsInstance_completion = /* @__PURE__ */ new WeakMap(), _YargsInstance_completionCommand = /* @__PURE__ */ new WeakMap(), _YargsInstance_defaultShowHiddenOpt = /* @__PURE__ */ new WeakMap(), _YargsInstance_exitError = /* @__PURE__ */ new WeakMap(), _YargsInstance_detectLocale = /* @__PURE__ */ new WeakMap(), _YargsInstance_emittedWarnings = /* @__PURE__ */ new WeakMap(), _YargsInstance_exitProcess = /* @__PURE__ */ new WeakMap(), _YargsInstance_frozens = /* @__PURE__ */ new WeakMap(), _YargsInstance_globalMiddleware = /* @__PURE__ */ new WeakMap(), _YargsInstance_groups = /* @__PURE__ */ new WeakMap(), _YargsInstance_hasOutput = /* @__PURE__ */ new WeakMap(), _YargsInstance_helpOpt = /* @__PURE__ */ new WeakMap(), _YargsInstance_isGlobalContext = /* @__PURE__ */ new WeakMap(), _YargsInstance_logger = /* @__PURE__ */ new WeakMap(), _YargsInstance_output = /* @__PURE__ */ new WeakMap(), _YargsInstance_options = /* @__PURE__ */ new WeakMap(), _YargsInstance_parentRequire = /* @__PURE__ */ new WeakMap(), _YargsInstance_parserConfig = /* @__PURE__ */ new WeakMap(), _YargsInstance_parseFn = /* @__PURE__ */ new WeakMap(), _YargsInstance_parseContext = /* @__PURE__ */ new WeakMap(), _YargsInstance_pkgs = /* @__PURE__ */ new WeakMap(), _YargsInstance_preservedGroups = /* @__PURE__ */ new WeakMap(), _YargsInstance_processArgs = /* @__PURE__ */ new WeakMap(), _YargsInstance_recommendCommands = /* @__PURE__ */ new WeakMap(), _YargsInstance_shim = /* @__PURE__ */ new WeakMap(), _YargsInstance_strict = /* @__PURE__ */ new WeakMap(), _YargsInstance_strictCommands = /* @__PURE__ */ new WeakMap(), _YargsInstance_strictOptions = /* @__PURE__ */ new WeakMap(), _YargsInstance_usage = /* @__PURE__ */ new WeakMap(), _YargsInstance_usageConfig = /* @__PURE__ */ new WeakMap(), _YargsInstance_versionOpt = /* @__PURE__ */ new WeakMap(), _YargsInstance_validation = /* @__PURE__ */ new WeakMap(), kCopyDoubleDash)](argv) { - if (!argv._ || !argv["--"]) - return argv; - argv._.push.apply(argv._, argv["--"]); - try { - delete argv["--"]; - } catch (_err) { + function stringifyInteger(value) { + return String(value).replace(/\B(?=(\d{3})+(?!\d))/g, "_"); } - return argv; - } - [kCreateLogger]() { - return { - log: (...args) => { - if (!this[kHasParseCallback]()) - console.log(...args); - __classPrivateFieldSet(this, _YargsInstance_hasOutput, true); - if (__classPrivateFieldGet(this, _YargsInstance_output, "f").length) - __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + "\n"); - __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + args.join(" ")); - }, - error: (...args) => { - if (!this[kHasParseCallback]()) - console.error(...args); - __classPrivateFieldSet(this, _YargsInstance_hasOutput, true); - if (__classPrivateFieldGet(this, _YargsInstance_output, "f").length) - __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + "\n"); - __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + args.join(" ")); - } - }; - } - [kDeleteFromParserHintObject](optionKey) { - objectKeys(__classPrivateFieldGet(this, _YargsInstance_options, "f")).forEach((hintKey) => { - if (/* @__PURE__ */ ((key) => key === "configObjects")(hintKey)) - return; - const hint = __classPrivateFieldGet(this, _YargsInstance_options, "f")[hintKey]; - if (Array.isArray(hint)) { - if (hint.includes(optionKey)) - hint.splice(hint.indexOf(optionKey), 1); - } else if (typeof hint === "object") { - delete hint[optionKey]; + function stringifyFloat(value) { + if (value === Infinity) { + return "inf"; + } else if (value === -Infinity) { + return "-inf"; + } else if (Object.is(value, NaN)) { + return "nan"; + } else if (Object.is(value, -0)) { + return "-0.0"; } - }); - delete __classPrivateFieldGet(this, _YargsInstance_usage, "f").getDescriptions()[optionKey]; - } - [kEmitWarning](warning, type2, deduplicationId) { - if (!__classPrivateFieldGet(this, _YargsInstance_emittedWarnings, "f")[deduplicationId]) { - __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.emitWarning(warning, type2); - __classPrivateFieldGet(this, _YargsInstance_emittedWarnings, "f")[deduplicationId] = true; + var chunks = String(value).split("."); + var int = chunks[0]; + var dec = chunks[1] || 0; + return stringifyInteger(int) + "." + dec; } - } - [kFreeze]() { - __classPrivateFieldGet(this, _YargsInstance_frozens, "f").push({ - options: __classPrivateFieldGet(this, _YargsInstance_options, "f"), - configObjects: __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects.slice(0), - exitProcess: __classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"), - groups: __classPrivateFieldGet(this, _YargsInstance_groups, "f"), - strict: __classPrivateFieldGet(this, _YargsInstance_strict, "f"), - strictCommands: __classPrivateFieldGet(this, _YargsInstance_strictCommands, "f"), - strictOptions: __classPrivateFieldGet(this, _YargsInstance_strictOptions, "f"), - completionCommand: __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f"), - output: __classPrivateFieldGet(this, _YargsInstance_output, "f"), - exitError: __classPrivateFieldGet(this, _YargsInstance_exitError, "f"), - hasOutput: __classPrivateFieldGet(this, _YargsInstance_hasOutput, "f"), - parsed: this.parsed, - parseFn: __classPrivateFieldGet(this, _YargsInstance_parseFn, "f"), - parseContext: __classPrivateFieldGet(this, _YargsInstance_parseContext, "f") - }); - __classPrivateFieldGet(this, _YargsInstance_usage, "f").freeze(); - __classPrivateFieldGet(this, _YargsInstance_validation, "f").freeze(); - __classPrivateFieldGet(this, _YargsInstance_command, "f").freeze(); - __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").freeze(); - } - [kGetDollarZero]() { - let $0 = ""; - let default$0; - if (/\b(node|iojs|electron)(\.exe)?$/.test(__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv()[0])) { - default$0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv().slice(1, 2); - } else { - default$0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv().slice(0, 1); - } - $0 = default$0.map((x2) => { - const b2 = this[kRebase](__classPrivateFieldGet(this, _YargsInstance_cwd, "f"), x2); - return x2.match(/^(\/|([a-zA-Z]:)?\\)/) && b2.length < x2.length ? b2 : x2; - }).join(" ").trim(); - if (__classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("_") && __classPrivateFieldGet(this, _YargsInstance_shim, "f").getProcessArgvBin() === __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("_")) { - $0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("_").replace(`${__classPrivateFieldGet(this, _YargsInstance_shim, "f").path.dirname(__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.execPath())}/`, ""); - } - return $0; - } - [kGetParserConfiguration]() { - return __classPrivateFieldGet(this, _YargsInstance_parserConfig, "f"); - } - [kGetUsageConfiguration]() { - return __classPrivateFieldGet(this, _YargsInstance_usageConfig, "f"); - } - [kGuessLocale]() { - if (!__classPrivateFieldGet(this, _YargsInstance_detectLocale, "f")) - return; - const locale = __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("LC_ALL") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("LC_MESSAGES") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("LANG") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("LANGUAGE") || "en_US"; - this.locale(locale.replace(/[.:].*/, "")); - } - [kGuessVersion]() { - const obj = this[kPkgUp](); - return obj.version || "unknown"; - } - [kParsePositionalNumbers](argv) { - const args = argv["--"] ? argv["--"] : argv._; - for (let i2 = 0, arg; (arg = args[i2]) !== void 0; i2++) { - if (__classPrivateFieldGet(this, _YargsInstance_shim, "f").Parser.looksLikeNumber(arg) && Number.isSafeInteger(Math.floor(parseFloat(`${arg}`)))) { - args[i2] = Number(arg); + function stringifyBoolean(value) { + return String(value); + } + function stringifyDatetime(value) { + return value.toISOString(); + } + function isNumber(type) { + return type === "float" || type === "integer"; + } + function arrayType(values) { + var contentType = tomlType2(values[0]); + if (values.every((_) => tomlType2(_) === contentType)) return contentType; + if (values.every((_) => isNumber(tomlType2(_)))) return "float"; + return "mixed"; + } + function validateArray(values) { + const type = arrayType(values); + if (type === "mixed") { + throw arrayOneTypeError(); } + return type; } - return argv; - } - [kPkgUp](rootPath) { - const npath = rootPath || "*"; - if (__classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath]) - return __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath]; - let obj = {}; - try { - let startDir = rootPath || __classPrivateFieldGet(this, _YargsInstance_shim, "f").mainFilename; - if (__classPrivateFieldGet(this, _YargsInstance_shim, "f").path.extname(startDir)) { - startDir = __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.dirname(startDir); + function stringifyInlineArray(values) { + values = toJSON(values); + const type = validateArray(values); + var result = "["; + var stringified = values.map((_) => stringifyInline(_, type)); + if (stringified.join(", ").length > 60 || /\n/.test(stringified)) { + result += "\n " + stringified.join(",\n ") + "\n"; + } else { + result += " " + stringified.join(", ") + (stringified.length > 0 ? " " : ""); } - const pkgJsonPath = __classPrivateFieldGet(this, _YargsInstance_shim, "f").findUp(startDir, (dir, names) => { - if (names.includes("package.json")) { - return "package.json"; - } else { - return void 0; - } - }); - assertNotStrictEqual(pkgJsonPath, void 0, __classPrivateFieldGet(this, _YargsInstance_shim, "f")); - obj = JSON.parse(__classPrivateFieldGet(this, _YargsInstance_shim, "f").readFileSync(pkgJsonPath, "utf8")); - } catch (_noop) { + return result + "]"; } - __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath] = obj || {}; - return __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath]; - } - [kPopulateParserHintArray](type2, keys) { - keys = [].concat(keys); - keys.forEach((key) => { - key = this[kSanitizeKey](key); - __classPrivateFieldGet(this, _YargsInstance_options, "f")[type2].push(key); - }); - } - [kPopulateParserHintSingleValueDictionary](builder, type2, key, value) { - this[kPopulateParserHintDictionary](builder, type2, key, value, (type3, key2, value2) => { - __classPrivateFieldGet(this, _YargsInstance_options, "f")[type3][key2] = value2; - }); - } - [kPopulateParserHintArrayDictionary](builder, type2, key, value) { - this[kPopulateParserHintDictionary](builder, type2, key, value, (type3, key2, value2) => { - __classPrivateFieldGet(this, _YargsInstance_options, "f")[type3][key2] = (__classPrivateFieldGet(this, _YargsInstance_options, "f")[type3][key2] || []).concat(value2); - }); - } - [kPopulateParserHintDictionary](builder, type2, key, value, singleKeyHandler) { - if (Array.isArray(key)) { - key.forEach((k) => { - builder(k, value); + function stringifyInlineTable(value) { + value = toJSON(value); + var result = []; + Object.keys(value).forEach((key) => { + result.push(stringifyKey(key) + " = " + stringifyAnyInline(value[key], false)); }); - } else if (/* @__PURE__ */ ((key2) => typeof key2 === "object")(key)) { - for (const k of objectKeys(key)) { - builder(k, key[k]); + return "{ " + result.join(", ") + (result.length > 0 ? " " : "") + "}"; + } + function stringifyComplex(prefix, indent, key, value) { + var valueType = tomlType2(value); + if (valueType === "array") { + return stringifyArrayOfTables(prefix, indent, key, value); + } else if (valueType === "table") { + return stringifyComplexTable(prefix, indent, key, value); + } else { + throw typeError(valueType); } - } else { - singleKeyHandler(type2, this[kSanitizeKey](key), value); } - } - [kSanitizeKey](key) { - if (key === "__proto__") - return "___proto___"; - return key; - } - [kSetKey](key, set2) { - this[kPopulateParserHintSingleValueDictionary](this[kSetKey].bind(this), "key", key, set2); - return this; - } - [kUnfreeze]() { - var _a2, _b2, _c2, _d, _e, _f, _g, _h, _j, _k, _l, _m; - const frozen = __classPrivateFieldGet(this, _YargsInstance_frozens, "f").pop(); - assertNotStrictEqual(frozen, void 0, __classPrivateFieldGet(this, _YargsInstance_shim, "f")); - let configObjects; - _a2 = this, _b2 = this, _c2 = this, _d = this, _e = this, _f = this, _g = this, _h = this, _j = this, _k = this, _l = this, _m = this, { - options: { set value(_o) { - __classPrivateFieldSet(_a2, _YargsInstance_options, _o); - } }.value, - configObjects, - exitProcess: { set value(_o) { - __classPrivateFieldSet(_b2, _YargsInstance_exitProcess, _o); - } }.value, - groups: { set value(_o) { - __classPrivateFieldSet(_c2, _YargsInstance_groups, _o); - } }.value, - output: { set value(_o) { - __classPrivateFieldSet(_d, _YargsInstance_output, _o); - } }.value, - exitError: { set value(_o) { - __classPrivateFieldSet(_e, _YargsInstance_exitError, _o); - } }.value, - hasOutput: { set value(_o) { - __classPrivateFieldSet(_f, _YargsInstance_hasOutput, _o); - } }.value, - parsed: this.parsed, - strict: { set value(_o) { - __classPrivateFieldSet(_g, _YargsInstance_strict, _o); - } }.value, - strictCommands: { set value(_o) { - __classPrivateFieldSet(_h, _YargsInstance_strictCommands, _o); - } }.value, - strictOptions: { set value(_o) { - __classPrivateFieldSet(_j, _YargsInstance_strictOptions, _o); - } }.value, - completionCommand: { set value(_o) { - __classPrivateFieldSet(_k, _YargsInstance_completionCommand, _o); - } }.value, - parseFn: { set value(_o) { - __classPrivateFieldSet(_l, _YargsInstance_parseFn, _o); - } }.value, - parseContext: { set value(_o) { - __classPrivateFieldSet(_m, _YargsInstance_parseContext, _o); - } }.value - } = frozen; - __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = configObjects; - __classPrivateFieldGet(this, _YargsInstance_usage, "f").unfreeze(); - __classPrivateFieldGet(this, _YargsInstance_validation, "f").unfreeze(); - __classPrivateFieldGet(this, _YargsInstance_command, "f").unfreeze(); - __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").unfreeze(); - } - [kValidateAsync](validation2, argv) { - return maybeAsyncResult(argv, (result) => { - validation2(result); + function stringifyArrayOfTables(prefix, indent, key, values) { + values = toJSON(values); + validateArray(values); + var firstValueType = tomlType2(values[0]); + if (firstValueType !== "table") throw typeError(firstValueType); + var fullKey = prefix + stringifyKey(key); + var result = ""; + values.forEach((table) => { + if (result.length > 0) result += "\n"; + result += indent + "[[" + fullKey + "]]\n"; + result += stringifyObject(fullKey + ".", indent, table); + }); return result; - }); - } - getInternalMethods() { - return { - getCommandInstance: this[kGetCommandInstance].bind(this), - getContext: this[kGetContext].bind(this), - getHasOutput: this[kGetHasOutput].bind(this), - getLoggerInstance: this[kGetLoggerInstance].bind(this), - getParseContext: this[kGetParseContext].bind(this), - getParserConfiguration: this[kGetParserConfiguration].bind(this), - getUsageConfiguration: this[kGetUsageConfiguration].bind(this), - getUsageInstance: this[kGetUsageInstance].bind(this), - getValidationInstance: this[kGetValidationInstance].bind(this), - hasParseCallback: this[kHasParseCallback].bind(this), - isGlobalContext: this[kIsGlobalContext].bind(this), - postProcess: this[kPostProcess].bind(this), - reset: this[kReset].bind(this), - runValidation: this[kRunValidation].bind(this), - runYargsParserAndExecuteCommands: this[kRunYargsParserAndExecuteCommands].bind(this), - setHasOutput: this[kSetHasOutput].bind(this) - }; - } - [kGetCommandInstance]() { - return __classPrivateFieldGet(this, _YargsInstance_command, "f"); - } - [kGetContext]() { - return __classPrivateFieldGet(this, _YargsInstance_context, "f"); - } - [kGetHasOutput]() { - return __classPrivateFieldGet(this, _YargsInstance_hasOutput, "f"); - } - [kGetLoggerInstance]() { - return __classPrivateFieldGet(this, _YargsInstance_logger, "f"); - } - [kGetParseContext]() { - return __classPrivateFieldGet(this, _YargsInstance_parseContext, "f") || {}; + } + function stringifyComplexTable(prefix, indent, key, value) { + var fullKey = prefix + stringifyKey(key); + var result = ""; + if (getInlineKeys(value).length > 0) { + result += indent + "[" + fullKey + "]\n"; + } + return result + stringifyObject(fullKey + ".", indent, value); + } } - [kGetUsageInstance]() { - return __classPrivateFieldGet(this, _YargsInstance_usage, "f"); +}); + +// node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/toml.js +var require_toml = __commonJS({ + "node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/toml.js"(exports2) { + init_esm_shims(); + exports2.parse = require_parse(); + exports2.stringify = require_stringify2(); } - [kGetValidationInstance]() { - return __classPrivateFieldGet(this, _YargsInstance_validation, "f"); +}); + +// src/index.ts +init_esm_shims(); + +// src/depbadgerc/depbadgerc.store.ts +init_esm_shims(); + +// src/store/ctx-store.ts +init_esm_shims(); +function useCtxStore(ctxState, methodFactories) { + const store = { ...ctxState }; + if (methodFactories) + for (const CtxMethodKey in methodFactories) + store[CtxMethodKey] = methodFactories[CtxMethodKey](store); + return Object.freeze(store); +} +function useCtxCallback(callback) { + return ((store) => (...args) => callback(store, ...args)); +} + +// src/depbadgerc/apply-markdown-to-target.ts +init_esm_shims(); + +// src/shared/find-file.ts +init_esm_shims(); +function findFile(filename, startDir = process.cwd()) { + let dir = startDir; + while (true) { + const candidate = path2.join(dir, filename); + if (fs2.existsSync(candidate)) return candidate; + const parent = path2.dirname(dir); + if (parent === dir) break; + dir = parent; } - [kHasParseCallback]() { - return !!__classPrivateFieldGet(this, _YargsInstance_parseFn, "f"); + return null; +} + +// src/depbadgerc/apply-markdown-to-target.ts +function formatMarkdown(store, markdowns) { + return markdowns.flatMap( + (md) => Object.entries(md).map(([section, badges]) => { + const layout = store[section]?.layout; + const headerText = layout?.showHeader ? layout?.header ?? section : ""; + const content = `${headerText ? ` + +# ${headerText} + +` : ""}${badges.join("\n")}`; + return layout?.position ? `
+ +${content} + +
` : content; + }) + ).join("\n\n
\n\n").trim(); +} +var applyMarkdownToTarget = useCtxCallback((store, ...markdowns) => { + const fileAbsPath = findFile(store.target ?? "README.md"); + if (!fileAbsPath) return; + const renderedMarkdown = formatMarkdown(store, markdowns); + const fileContent = fs2.readFileSync(fileAbsPath, "utf8").replace( + /[\s\S]*?/, + ` +${renderedMarkdown} +` + ); + fs2.writeFileSync(fileAbsPath, fileContent, "utf8"); +}); + +// src/depbadgerc/compute-state-integrity.ts +init_esm_shims(); +var import_yaml = __toESM(require_dist()); +var computeStateIntegrity = useCtxCallback((store, ...rest) => { + const payloadStringified = JSON.stringify(rest); + const hash = crypto.createHash("sha256"); + const yml = import_yaml.default.stringify({ + ...JSON.parse(JSON.stringify(store)), + integrity: null + }); + hash.update(`${yml} --- ${payloadStringified}`, "utf8"); + return hash.digest("hex"); +}); + +// src/depbadgerc/get-dependencies.ts +init_esm_shims(); +var getDependencies = useCtxCallback( + (store) => { + const result = {}; + if (store.dependencies) result.dependencies = store.dependencies; + if (store.devDependencies) result.devDependencies = store.devDependencies; + if (store.peerDependencies) result.peerDependencies = store.peerDependencies; + return result; } - [kIsGlobalContext]() { - return __classPrivateFieldGet(this, _YargsInstance_isGlobalContext, "f"); +); + +// src/depbadgerc/get-status-badges.ts +init_esm_shims(); +var getStatusBadges = useCtxCallback( + (store) => { + const result = {}; + if (store.statusBadges) result.statusBadges = store.statusBadges; + return result; } - [kPostProcess](argv, populateDoubleDash, calledFromCommand, runGlobalMiddleware) { - if (calledFromCommand) - return argv; - if (isPromise(argv)) - return argv; - if (!populateDoubleDash) { - argv = this[kCopyDoubleDash](argv); - } - const parsePositionalNumbers = this[kGetParserConfiguration]()["parse-positional-numbers"] || this[kGetParserConfiguration]()["parse-positional-numbers"] === void 0; - if (parsePositionalNumbers) { - argv = this[kParsePositionalNumbers](argv); - } - if (runGlobalMiddleware) { - argv = applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), false); - } - return argv; +); + +// src/depbadgerc/hydrate-dependency-badges.ts +init_esm_shims(); +var hydrateDependencyBadges = useCtxCallback( + (_, deps, mfdm) => { + return Object.entries(deps).reduce( + (acc, [section, config]) => { + if (!config?.items?.length) return acc; + const entries = config.items.flatMap((item) => { + const message = mfdm[section]?.[item.name]; + return message === void 0 ? [] : [ + [ + item.name, + { + ...item, + message + } + ] + ]; + }); + if (!entries.length) return acc; + acc[section] = { + ...acc[section] ?? {}, + ...Object.fromEntries(entries) + }; + return acc; + }, + {} + ); } - [kReset](aliases = {}) { - __classPrivateFieldSet(this, _YargsInstance_options, __classPrivateFieldGet(this, _YargsInstance_options, "f") || {}); - const tmpOptions = {}; - tmpOptions.local = __classPrivateFieldGet(this, _YargsInstance_options, "f").local || []; - tmpOptions.configObjects = __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || []; - const localLookup = {}; - tmpOptions.local.forEach((l2) => { - localLookup[l2] = true; - (aliases[l2] || []).forEach((a2) => { - localLookup[a2] = true; - }); - }); - Object.assign(__classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f"), Object.keys(__classPrivateFieldGet(this, _YargsInstance_groups, "f")).reduce((acc, groupName) => { - const keys = __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName].filter((key) => !(key in localLookup)); - if (keys.length > 0) { - acc[groupName] = keys; - } +); + +// src/depbadgerc/hydrate-status-badges.ts +init_esm_shims(); +var hydrateStatusBadges = useCtxCallback( + (_, statusBadges) => Object.entries(statusBadges).reduce( + (acc, [section, statusBadges2]) => { + if (!statusBadges2?.items?.length) return acc; + acc[section] = [...acc[section] ?? [], ...statusBadges2.items]; return acc; - }, {})); - __classPrivateFieldSet(this, _YargsInstance_groups, {}); - const arrayOptions = [ - "array", - "boolean", - "string", - "skipValidation", - "count", - "normalize", - "number", - "hiddenOptions" - ]; - const objectOptions = [ - "narg", - "key", - "alias", - "default", - "defaultDescription", - "config", - "choices", - "demandedOptions", - "demandedCommands", - "deprecatedOptions" - ]; - arrayOptions.forEach((k) => { - tmpOptions[k] = (__classPrivateFieldGet(this, _YargsInstance_options, "f")[k] || []).filter((k2) => !localLookup[k2]); - }); - objectOptions.forEach((k) => { - tmpOptions[k] = objFilter(__classPrivateFieldGet(this, _YargsInstance_options, "f")[k], (k2) => !localLookup[k2]); - }); - tmpOptions.envPrefix = __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix; - __classPrivateFieldSet(this, _YargsInstance_options, tmpOptions); - __classPrivateFieldSet(this, _YargsInstance_usage, __classPrivateFieldGet(this, _YargsInstance_usage, "f") ? __classPrivateFieldGet(this, _YargsInstance_usage, "f").reset(localLookup) : usage(this, __classPrivateFieldGet(this, _YargsInstance_shim, "f"))); - __classPrivateFieldSet(this, _YargsInstance_validation, __classPrivateFieldGet(this, _YargsInstance_validation, "f") ? __classPrivateFieldGet(this, _YargsInstance_validation, "f").reset(localLookup) : validation(this, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f"))); - __classPrivateFieldSet(this, _YargsInstance_command, __classPrivateFieldGet(this, _YargsInstance_command, "f") ? __classPrivateFieldGet(this, _YargsInstance_command, "f").reset() : command(__classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_validation, "f"), __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f"))); - if (!__classPrivateFieldGet(this, _YargsInstance_completion, "f")) - __classPrivateFieldSet(this, _YargsInstance_completion, completion(this, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_command, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f"))); - __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").reset(); - __classPrivateFieldSet(this, _YargsInstance_completionCommand, null); - __classPrivateFieldSet(this, _YargsInstance_output, ""); - __classPrivateFieldSet(this, _YargsInstance_exitError, null); - __classPrivateFieldSet(this, _YargsInstance_hasOutput, false); - this.parsed = false; - return this; - } - [kRebase](base, dir) { - return __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.relative(base, dir); - } - [kRunYargsParserAndExecuteCommands](args, shortCircuit, calledFromCommand, commandIndex = 0, helpOnly = false) { - var _a2, _b2, _c2, _d; - let skipValidation = !!calledFromCommand || helpOnly; - args = args || __classPrivateFieldGet(this, _YargsInstance_processArgs, "f"); - __classPrivateFieldGet(this, _YargsInstance_options, "f").__ = __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.__; - __classPrivateFieldGet(this, _YargsInstance_options, "f").configuration = this[kGetParserConfiguration](); - const populateDoubleDash = !!__classPrivateFieldGet(this, _YargsInstance_options, "f").configuration["populate--"]; - const config = Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_options, "f").configuration, { - "populate--": true - }); - const parsed = __classPrivateFieldGet(this, _YargsInstance_shim, "f").Parser.detailed(args, Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_options, "f"), { - configuration: { "parse-positional-numbers": false, ...config } - })); - const argv = Object.assign(parsed.argv, __classPrivateFieldGet(this, _YargsInstance_parseContext, "f")); - let argvPromise = void 0; - const aliases = parsed.aliases; - let helpOptSet = false; - let versionOptSet = false; - Object.keys(argv).forEach((key) => { - if (key === __classPrivateFieldGet(this, _YargsInstance_helpOpt, "f") && argv[key]) { - helpOptSet = true; - } else if (key === __classPrivateFieldGet(this, _YargsInstance_versionOpt, "f") && argv[key]) { - versionOptSet = true; - } - }); - argv.$0 = this.$0; - this.parsed = parsed; - if (commandIndex === 0) { - __classPrivateFieldGet(this, _YargsInstance_usage, "f").clearCachedHelpMessage(); - } - try { - this[kGuessLocale](); - if (shortCircuit) { - return this[kPostProcess](argv, populateDoubleDash, !!calledFromCommand, false); - } - if (__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")) { - const helpCmds = [__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")].concat(aliases[__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")] || []).filter((k) => k.length > 1); - if (helpCmds.includes("" + argv._[argv._.length - 1])) { - argv._.pop(); - helpOptSet = true; - } - } - __classPrivateFieldSet(this, _YargsInstance_isGlobalContext, false, "f"); - const handlerKeys = __classPrivateFieldGet(this, _YargsInstance_command, "f").getCommands(); - const requestCompletions = ((_a2 = __classPrivateFieldGet(this, _YargsInstance_completion, "f")) === null || _a2 === void 0 ? void 0 : _a2.completionKey) ? [ - (_b2 = __classPrivateFieldGet(this, _YargsInstance_completion, "f")) === null || _b2 === void 0 ? void 0 : _b2.completionKey, - ...(_d = this.getAliases()[(_c2 = __classPrivateFieldGet(this, _YargsInstance_completion, "f")) === null || _c2 === void 0 ? void 0 : _c2.completionKey]) !== null && _d !== void 0 ? _d : [] - ].some((key) => Object.prototype.hasOwnProperty.call(argv, key)) : false; - const skipRecommendation = helpOptSet || requestCompletions || helpOnly; - if (argv._.length) { - if (handlerKeys.length) { - let firstUnknownCommand; - for (let i2 = commandIndex || 0, cmd; argv._[i2] !== void 0; i2++) { - cmd = String(argv._[i2]); - if (handlerKeys.includes(cmd) && cmd !== __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) { - const innerArgv = __classPrivateFieldGet(this, _YargsInstance_command, "f").runCommand(cmd, this, parsed, i2 + 1, helpOnly, helpOptSet || versionOptSet || helpOnly); - return this[kPostProcess](innerArgv, populateDoubleDash, !!calledFromCommand, false); - } else if (!firstUnknownCommand && cmd !== __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) { - firstUnknownCommand = cmd; - break; + }, + {} + ) +); + +// src/depbadgerc/map-badges-to-markdown.ts +init_esm_shims(); +var REGEX = /[^a-zA-Z0-9]/g; +var encodeMessage = (s2) => encodeURIComponent(s2.replace(/^\^/, "v")); +var encodeLabel = (s2) => encodeURIComponent(s2?.replace(REGEX, "_")); +var mapBadgesToMarkdown = useCtxCallback( + (_, hdm) => { + return Object.fromEntries( + Object.entries(hdm).map(([section, badgeMap]) => [ + section, + Object.entries(badgeMap).flatMap(([name, badge]) => { + const urlSearchParams = new URLSearchParams({ + ...badge.isError && { isError: "true" }, + ...badge.labelColor && { labelColor: badge.labelColor }, + ...badge.cacheSeconds && { + cacheSeconds: badge.cacheSeconds?.toString() + }, + ...badge.namedLogo && { logo: badge.namedLogo }, + ...badge.logoColor && { logoColor: badge.logoColor }, + ...badge.logoWidth && { logoWidth: badge.logoWidth.toString() }, + ...badge.style && { style: badge.style }, + ...badge.logoSvg && { + logo: `data:image/svg+xml;utf8,${encodeURIComponent(badge.logoSvg)}` } - } - if (!__classPrivateFieldGet(this, _YargsInstance_command, "f").hasDefaultCommand() && __classPrivateFieldGet(this, _YargsInstance_recommendCommands, "f") && firstUnknownCommand && !skipRecommendation) { - __classPrivateFieldGet(this, _YargsInstance_validation, "f").recommendCommands(firstUnknownCommand, handlerKeys); - } - } - if (__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") && argv._.includes(__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) && !requestCompletions) { - if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f")) - setBlocking(true); - this.showCompletionScript(); - this.exit(0); - } - } - if (__classPrivateFieldGet(this, _YargsInstance_command, "f").hasDefaultCommand() && !skipRecommendation) { - const innerArgv = __classPrivateFieldGet(this, _YargsInstance_command, "f").runCommand(null, this, parsed, 0, helpOnly, helpOptSet || versionOptSet || helpOnly); - return this[kPostProcess](innerArgv, populateDoubleDash, !!calledFromCommand, false); - } - if (requestCompletions) { - if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f")) - setBlocking(true); - args = [].concat(args); - const completionArgs = args.slice(args.indexOf(`--${__classPrivateFieldGet(this, _YargsInstance_completion, "f").completionKey}`) + 1); - __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(completionArgs, (err, completions) => { - if (err) - throw new YError(err.message); - (completions || []).forEach((completion2) => { - __classPrivateFieldGet(this, _YargsInstance_logger, "f").log(completion2); - }); - this.exit(0); - }); - return this[kPostProcess](argv, !populateDoubleDash, !!calledFromCommand, false); - } - if (!__classPrivateFieldGet(this, _YargsInstance_hasOutput, "f")) { - if (helpOptSet) { - if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f")) - setBlocking(true); - skipValidation = true; - this.showHelp((message) => { - __classPrivateFieldGet(this, _YargsInstance_logger, "f").log(message); - this.exit(0); - }); - } else if (versionOptSet) { - if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f")) - setBlocking(true); - skipValidation = true; - __classPrivateFieldGet(this, _YargsInstance_usage, "f").showVersion("log"); - this.exit(0); - } - } - if (!skipValidation && __classPrivateFieldGet(this, _YargsInstance_options, "f").skipValidation.length > 0) { - skipValidation = Object.keys(argv).some((key) => __classPrivateFieldGet(this, _YargsInstance_options, "f").skipValidation.indexOf(key) >= 0 && argv[key] === true); - } - if (!skipValidation) { - if (parsed.error) - throw new YError(parsed.error.message); - if (!requestCompletions) { - const validation2 = this[kRunValidation](aliases, {}, parsed.error); - if (!calledFromCommand) { - argvPromise = applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), true); - } - argvPromise = this[kValidateAsync](validation2, argvPromise !== null && argvPromise !== void 0 ? argvPromise : argv); - if (isPromise(argvPromise) && !calledFromCommand) { - argvPromise = argvPromise.then(() => { - return applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), false); - }); - } - } - } - } catch (err) { - if (err instanceof YError) - __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(err.message, err); - else - throw err; - } - return this[kPostProcess](argvPromise !== null && argvPromise !== void 0 ? argvPromise : argv, populateDoubleDash, !!calledFromCommand, true); - } - [kRunValidation](aliases, positionalMap, parseErrors, isDefaultCommand) { - const demandedOptions = { ...this.getDemandedOptions() }; - return (argv) => { - if (parseErrors) - throw new YError(parseErrors.message); - __classPrivateFieldGet(this, _YargsInstance_validation, "f").nonOptionCount(argv); - __classPrivateFieldGet(this, _YargsInstance_validation, "f").requiredArguments(argv, demandedOptions); - let failedStrictCommands = false; - if (__classPrivateFieldGet(this, _YargsInstance_strictCommands, "f")) { - failedStrictCommands = __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownCommands(argv); - } - if (__classPrivateFieldGet(this, _YargsInstance_strict, "f") && !failedStrictCommands) { - __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownArguments(argv, aliases, positionalMap, !!isDefaultCommand); - } else if (__classPrivateFieldGet(this, _YargsInstance_strictOptions, "f")) { - __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownArguments(argv, aliases, {}, false, false); - } - __classPrivateFieldGet(this, _YargsInstance_validation, "f").limitedChoices(argv); - __classPrivateFieldGet(this, _YargsInstance_validation, "f").implications(argv); - __classPrivateFieldGet(this, _YargsInstance_validation, "f").conflicting(argv); - }; - } - [kSetHasOutput]() { - __classPrivateFieldSet(this, _YargsInstance_hasOutput, true); + }).toString(); + const dependency = encodeLabel(name); + const message = encodeMessage(badge.message); + const color = encodeURIComponent(badge.color); + const url = `https://img.shields.io/badge/${dependency}-${message}-${color}.svg?${urlSearchParams}`; + return badge.link ? `[![${name}](${url})](${badge.link})` : `![${name}](${url})`; + }) + ]) + ); } - [kTrackManuallySetKeys](keys) { - if (typeof keys === "string") { - __classPrivateFieldGet(this, _YargsInstance_options, "f").key[keys] = true; - } else { - for (const k of keys) { - __classPrivateFieldGet(this, _YargsInstance_options, "f").key[k] = true; - } +); + +// src/depbadgerc/map-status-badges-to-markdown.ts +init_esm_shims(); + +// src/depbadgerc/map-codecov-status-badge-to-markdown.ts +init_esm_shims(); + +// src/shared/encode-label.ts +init_esm_shims(); +var encodeLabel2 = (s2) => { + return (s2 ?? "").replace(/-/g, "--").replace(/_/g, "__").replace(/\s+/g, "_"); +}; + +// src/depbadgerc/map-codecov-status-badge-to-markdown.ts +function mapCodecovStatusBadgeToMarkdown(badge) { + const urlSearchParams = new URLSearchParams({ + ...badge?.labelColor && { labelColor: badge.labelColor }, + ...badge?.isError && { isError: "true" }, + ...badge?.cacheSeconds && { cacheSeconds: badge.cacheSeconds.toString() }, + ...badge?.namedLogo && { logo: badge.namedLogo }, + ...badge?.logoColor && { logoColor: badge.logoColor }, + ...badge?.logoWidth && { logoWidth: badge.logoWidth.toString() }, + ...badge.style && { style: badge.style }, + ...badge?.color && { color: badge.color }, + ...badge?.logoSvg && { + logo: `data:image/svg+xml;utf8,${encodeURIComponent(badge.logoSvg)}` + }, + ...badge.branch && { branch: badge.branch }, + ...badge.token && { token: badge.token } + }).toString(); + const label = badge.name; + const user = encodeLabel2(badge.user ?? "library"); + const repo = encodeLabel2(badge.repo); + const provider = encodeLabel2("github"); + const flag = encodeLabel2(badge.flag ?? "c"); + const url = `https://img.shields.io/codecov/${flag}/${provider}/${user}/${repo}?${urlSearchParams}`; + return badge?.link ? `[![${label}](${url})](${badge.link})` : `![${label}](${url})`; +} + +// src/depbadgerc/map-dockerhub-status-badge-to-markdown.ts +init_esm_shims(); +function mapDockerHubStatusBadgeToMarkdown(badge) { + const urlSearchParams = new URLSearchParams({ + ...badge?.labelColor && { labelColor: badge.labelColor }, + ...badge?.isError && { isError: "true" }, + ...badge?.namedLogo && { logo: badge.namedLogo }, + ...badge?.logoColor && { logoColor: badge.logoColor }, + ...badge?.logoWidth && { logoWidth: badge.logoWidth.toString() }, + ...badge.style && { style: badge.style }, + ...badge?.cacheSeconds && { cacheSeconds: badge.cacheSeconds.toString() }, + ...badge?.color && { color: badge.color }, + ...badge?.logoSvg && { + logo: `data:image/svg+xml;utf8,${encodeURIComponent(badge.logoSvg)}` + }, + ...badge.tag && badge.metric === "v" && { tag: badge.tag } + }).toString(); + const label = badge.name; + const src = encodeLabel2(label); + const user = encodeLabel2(badge.user ?? "library"); + const metric = encodeLabel2(badge.metric ?? "v"); + const image = encodeLabel2(badge.image); + const url = `https://img.shields.io/${src}/${metric}/${user}/${image}?${urlSearchParams}`; + return badge?.link ? `[![${label}](${url})](${badge.link})` : `![${label}](${url})`; +} + +// src/depbadgerc/map-github-status-badge-to-markdown.ts +init_esm_shims(); +function mapGithubStatusBadgeToMarkdown(badge) { + const urlSearchParams = new URLSearchParams({ + ...badge?.labelColor && { labelColor: badge.labelColor }, + ...badge.style && { style: badge.style }, + ...badge?.cacheSeconds && { cacheSeconds: badge.cacheSeconds.toString() }, + ...badge?.color && { color: badge.color }, + ...badge?.isError && { isError: "true" }, + ...badge?.namedLogo && { logo: badge.namedLogo }, + ...badge?.logoColor && { logoColor: badge.logoColor }, + ...badge?.logoWidth && { logoWidth: badge.logoWidth.toString() }, + ...badge?.logoSvg && { + logo: `data:image/svg+xml;utf8,${encodeURIComponent(badge.logoSvg)}` + }, + ...badge.branch && { branch: badge.branch } + }).toString(); + const label = badge.name; + const src = encodeLabel2(label); + const user = encodeLabel2(badge.user); + const workflow = encodeLabel2(badge.workflow); + const metric = encodeLabel2(badge.metric); + const repo = encodeLabel2(badge.repo); + const url = badge.metric === "actions" ? `https://img.shields.io/${src}/${metric}/workflow/status/${user}/${repo}/${workflow}?${urlSearchParams}` : `https://img.shields.io/${src}/${metric}/${user}/${repo}?${urlSearchParams}`; + return badge?.link ? `[![${label}](${url})](${badge.link})` : `![${label}](${url})`; +} + +// src/depbadgerc/map-socket-status-badge-to-markdown.ts +init_esm_shims(); +function mapSocketStatusBadgeToMarkdown(badge) { + const label = badge.name; + const version = badge.version ?? "*"; + const url = `https://badge.socket.dev/npm/package/${badge.package}/${version}`; + const link = badge.link ?? `https://www.npmjs.com/package/${badge.package}`; + return `[![${label}](${url})](${link})`; +} + +// src/depbadgerc/map-tile-status-badge-to-markdown.ts +init_esm_shims(); +function mapTileStatusBadgeToMarkdown(badge) { + const urlSearchParams = new URLSearchParams({ + ...badge?.labelColor && { labelColor: badge.labelColor }, + ...badge?.isError && { isError: "true" }, + ...badge?.cacheSeconds && { cacheSeconds: badge.cacheSeconds.toString() }, + ...badge?.namedLogo && { logo: badge.namedLogo }, + ...badge?.logoColor && { logoColor: badge.logoColor }, + ...badge?.logoWidth && { logoWidth: badge.logoWidth.toString() }, + ...badge.style && { style: badge.style }, + ...badge?.logoSvg && { + logo: `data:image/svg+xml;utf8,${encodeURIComponent(badge.logoSvg)}` } + }).toString(); + const label = encodeLabel2(badge.label); + const message = encodeLabel2(badge.message); + const color = badge.color; + const url = `https://img.shields.io/badge/${label}-${message}-${color}?${urlSearchParams}`; + return badge?.link ? `[![${label}](${url})](${badge.link})` : `![${label}](${url})`; +} + +// src/depbadgerc/map-status-badges-to-markdown.ts +var mapStatusBadgesToMarkdown = useCtxCallback( + (_, statusBadges) => Object.fromEntries( + Object.entries(statusBadges).map(([section, badges]) => [ + section, + badges.map((item) => { + if (item.name === "github") return mapGithubStatusBadgeToMarkdown(item); + if (item.name === "docker") return mapDockerHubStatusBadgeToMarkdown(item); + if (item.name === "codecov") return mapCodecovStatusBadgeToMarkdown(item); + if (item.name === "tile") return mapTileStatusBadgeToMarkdown(item); + if (item.name === "socket") return mapSocketStatusBadgeToMarkdown(item); + }).filter((x2) => Boolean(x2)) + ]) + ) +); + +// src/depbadgerc/output-markdown-preview.ts +init_esm_shims(); +var outputMarkdownPreview = useCtxCallback( + (store, type, badgeMarkdownMap, dir = ".depbadge") => { + const md = Object.entries(badgeMarkdownMap).map(([section, badges]) => { + const layout = store[section]?.layout; + const header = layout?.header ?? section; + const content = `${layout?.showHeader ? ` +# ${header}` : ""} + +${badges.join("\n")}`; + return layout?.position ? `
+${content} + +
` : content; + }).join("").trim(); + if (!md?.length) return; + fs2.mkdirSync(dir, { recursive: true }); + fs2.writeFileSync(`${dir}/${type}.md`, md); } -}; -function isYargsInstance(y2) { - return !!y2 && typeof y2.getInternalMethods === "function"; +); + +// src/depbadgerc/output-shieldio-badges-json.ts +init_esm_shims(); +var outputShieldioBadgesJson = useCtxCallback((_, hbm, dir = ".depbadge") => { + Object.entries(hbm).forEach(([section, badgesMap]) => { + const sectionPath = path2.join(dir, section); + fs2.mkdirSync(sectionPath, { recursive: true }); + Object.entries(badgesMap).forEach(([name, badge]) => { + const safeName = name.replace(/^@/, "").replace(/\//g, "__"); + const filePath = path2.join(sectionPath, `${safeName}.json`); + fs2.writeFileSync(filePath, JSON.stringify(badge, null, 2)); + }); + }); +}); + +// src/depbadgerc/process-manifest.ts +init_esm_shims(); + +// src/depbadgerc/update-integrity.ts +init_esm_shims(); +function updateIntegrity(integrity, path4 = "depbadgerc.yml") { + const absFilePath = findFile(path4); + if (!absFilePath) return; + const content = fs2.readFileSync(absFilePath, "utf8"); + const newContent = content.match(/^integrity: .*/m) ? content.replace(/^integrity: .*/m, `integrity: ${integrity}`) : `integrity: ${integrity} +${content}`; + fs2.writeFileSync(absFilePath, newContent, "utf8"); } -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/index.mjs -var Yargs = YargsFactory(esm_default); -var yargs_default = Yargs; +// src/depbadgerc/process-manifest.ts +function canOutput(x2 = [], y2) { + return x2?.includes(y2) ?? false; +} +function canUpdate(x2, y2) { + return x2 ? !y2.includes(x2) : true; +} +var processManifest = useCtxCallback((store, mfc) => { + const version = mfc.getVersion(); + const mfDeps = mfc.getDependencies(); + const rcDeps = store.getDependencies(); + const dependencyBadges = store.hydrateDependencyBadges(rcDeps, mfDeps); + const integrity = store.computeStateIntegrity(dependencyBadges, version); + const statusBadgeMap = store.getStatusBadges(); + const statusBadges = store.hydrateStatusBadges(statusBadgeMap); + const badgesMarkdown = store.mapBadgesToMarkdown(dependencyBadges); + const statusBadgesMarkdown = store.mapStatusBadgesToMarkdown(statusBadges); + if (canOutput(store.output, "json")) store.outputShieldioBadgesJson(dependencyBadges); + if (canOutput(store.output, "markdown")) { + store.outputMarkdownPreview("BADGES", badgesMarkdown); + store.outputMarkdownPreview("STATUS_BADGES", statusBadgesMarkdown); + } + store.applyMarkdownToTarget(statusBadgesMarkdown, badgesMarkdown); + if (canUpdate(store.integrity, integrity)) updateIntegrity(integrity); +}); -// node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/helpers/helpers.mjs +// src/depbadgerc/read-depbadgerc-with-defaults.ts init_esm_shims(); +var import_yaml2 = __toESM(require_dist()); // src/shared/hash-string-to-hex.ts init_esm_shims(); @@ -10591,10 +9897,11 @@ var w = function(r2) { }; // src/shared/hash-string-to-hex.ts -function hashStringToHex(str2) { +function hashStringToHex(str) { + if (!str?.length) str = "default"; let h2 = 0; - for (let i2 = 0; i2 < str2.length; i2++) { - h2 = str2.charCodeAt(i2) + ((h2 << 5) - h2); + for (let i2 = 0; i2 < str.length; i2++) { + h2 = str.charCodeAt(i2) + ((h2 << 5) - h2); } const hue = (h2 % 360 + 360) % 360; const sat = 60 + Math.abs(h2 >> 8) % 20; @@ -10602,6 +9909,27 @@ function hashStringToHex(str2) { return w({ h: hue, s: sat, l: lit }).toHex().replace("#", ""); } +// src/shared/resolve-yaml-merge-key.ts +init_esm_shims(); +function resolveYamlMergeKey(obj) { + if (Array.isArray(obj)) return obj.map(resolveYamlMergeKey); + if (obj && typeof obj === "object") { + const result = {}; + for (const [key, value] of Object.entries(obj)) { + if (key === "<<") { + const merged = resolveYamlMergeKey(value); + if (Array.isArray(merged)) { + merged.forEach((m2) => { + if (m2 && typeof m2 === "object") Object.assign(result, resolveYamlMergeKey(m2)); + }); + } else if (merged && typeof merged === "object") Object.assign(result, resolveYamlMergeKey(merged)); + } else result[key] = resolveYamlMergeKey(value); + } + return result; + } + return obj; +} + // src/depbadgerc/read-depbadgerc-with-defaults.ts function mergeLayout(defaultLayout, sectionLayout) { return defaultLayout || sectionLayout ? { ...defaultLayout, ...sectionLayout } : void 0; @@ -10639,18 +9967,29 @@ function withDefaults(rc) { function readDepbadgeRC(path4 = "depbadgerc.yml") { const filePath = findFile(path4); if (!filePath) throw new Error(`${path4} not found`); - const rc = jsYaml.load(fs2.readFileSync(filePath, "utf8")); + const rc = resolveYamlMergeKey(import_yaml2.default.parse(fs2.readFileSync(filePath, "utf8"))); return rc; } -function withYargs(rc) { +function withArgs(rc) { rc.output ??= []; - const argv = yargs_default(hideBin(process.argv)).parse(); + const { values } = parseArgs({ + options: { + g: { + type: "string", + multiple: true + }, + generate: { + type: "string", + multiple: true + } + } + }); const arrayfy = (v2) => v2 ? Array.isArray(v2) ? v2 : [v2] : []; - const gSet = /* @__PURE__ */ new Set([...arrayfy(argv.g), ...arrayfy(argv.generate)]); + const gSet = /* @__PURE__ */ new Set([...arrayfy(values.g), ...arrayfy(values.generate)]); ["json", "markdown"].forEach((t2) => gSet.has(t2) && !rc.output.includes(t2) && rc.output.push(t2)); return rc; } -var getDepbadgeRC = () => withYargs(withDefaults(readDepbadgeRC())); +var getDepbadgeRC = () => withArgs(withDefaults(readDepbadgeRC())); // src/depbadgerc/depbadgerc.store.ts var rcCtx = useCtxStore(getDepbadgeRC(), { @@ -10815,27 +10154,3 @@ try { console.error(`::error::${message}`); process.exit(1); } -/*! Bundled license information: - -js-yaml/dist/js-yaml.mjs: - (*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT *) - -yargs-parser/build/lib/string-utils.js: -yargs-parser/build/lib/tokenize-arg-string.js: -yargs-parser/build/lib/yargs-parser-types.js: -yargs-parser/build/lib/yargs-parser.js: - (** - * @license - * Copyright (c) 2016, Contributors - * SPDX-License-Identifier: ISC - *) - -yargs-parser/build/lib/index.js: - (** - * @fileoverview Main entrypoint for libraries using yargs-parser in Node.js - * - * @license - * Copyright (c) 2016, Contributors - * SPDX-License-Identifier: ISC - *) -*/ diff --git a/package.json b/package.json index c7fad4c..844c9b5 100755 --- a/package.json +++ b/package.json @@ -47,15 +47,13 @@ "dependencies": { "@iarna/toml": "^2.2.5", "colord": "^2.9.3", - "js-yaml": "^4.1.1", - "yargs": "^18.0.0" + "yaml": "^2.8.2" }, "devDependencies": { "@changesets/cli": "^2.30.0", "@eslint/js": "^10.0.1", "@types/eslint": "^9.6.1", "@types/node": "^25.5.0", - "@types/yargs": "^17.0.35", "@vitest/coverage-v8": "4.1.0", "depcheck": "^1.4.7", "dependency-cruiser": "^17.3.9", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bcf9b54..2820e97 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,12 +14,9 @@ importers: colord: specifier: ^2.9.3 version: 2.9.3 - js-yaml: - specifier: ^4.1.1 - version: 4.1.1 - yargs: - specifier: ^18.0.0 - version: 18.0.0 + yaml: + specifier: ^2.8.2 + version: 2.8.2 devDependencies: '@changesets/cli': specifier: ^2.30.0 @@ -33,9 +30,6 @@ importers: '@types/node': specifier: ^25.5.0 version: 25.5.0 - '@types/yargs': - specifier: ^17.0.35 - version: 17.0.35 '@vitest/coverage-v8': specifier: 4.1.0 version: 4.1.0(vitest@4.1.0(@types/node@25.5.0)(vite@8.0.0(@types/node@25.5.0)(esbuild@0.27.3)(jiti@2.6.1)(terser@5.46.0)(yaml@2.8.2))) @@ -785,12 +779,6 @@ packages: '@types/parse-json@4.0.2': resolution: {integrity: sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==} - '@types/yargs-parser@21.0.3': - resolution: {integrity: sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==} - - '@types/yargs@17.0.35': - resolution: {integrity: sha512-qUHkeCyQFxMXg79wQfTtfndEC+N9ZZg76HJftDJp+qH2tV7Gj4OJi7l+PiWwJ+pWtW8GwSmqsDj/oymhrTWXjg==} - '@typescript-eslint/eslint-plugin@8.57.1': resolution: {integrity: sha512-Gn3aqnvNl4NGc6x3/Bqk1AOn0thyTU9bqDRhiRnUWezgvr2OnhYCWCgC8zXXRVqBsIL1pSDt7T9nJUe0oM0kDQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -1163,10 +1151,6 @@ packages: cliui@7.0.4: resolution: {integrity: sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==} - cliui@9.0.1: - resolution: {integrity: sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==} - engines: {node: '>=20'} - color-convert@2.0.1: resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} engines: {node: '>=7.0.0'} @@ -2657,18 +2641,10 @@ packages: resolution: {integrity: sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==} engines: {node: '>=10'} - yargs-parser@22.0.0: - resolution: {integrity: sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==} - engines: {node: ^20.19.0 || ^22.12.0 || >=23} - yargs@16.2.0: resolution: {integrity: sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==} engines: {node: '>=10'} - yargs@18.0.0: - resolution: {integrity: sha512-4UEqdc2RYGHZc7Doyqkrqiln3p9X2DZVxaGbwhn2pi7MrRagKaOcIKe8L3OxYcbhXLgLFUS3zAYuQjKBQgmuNg==} - engines: {node: ^20.19.0 || ^22.12.0 || >=23} - yn@3.1.1: resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==} engines: {node: '>=6'} @@ -3264,12 +3240,6 @@ snapshots: '@types/parse-json@4.0.2': {} - '@types/yargs-parser@21.0.3': {} - - '@types/yargs@17.0.35': - dependencies: - '@types/yargs-parser': 21.0.3 - '@typescript-eslint/eslint-plugin@8.57.1(@typescript-eslint/parser@8.57.1(eslint@10.0.3(jiti@2.6.1))(typescript@5.9.3))(eslint@10.0.3(jiti@2.6.1))(typescript@5.9.3)': dependencies: '@eslint-community/regexpp': 4.12.2 @@ -3703,12 +3673,6 @@ snapshots: strip-ansi: 6.0.1 wrap-ansi: 7.0.0 - cliui@9.0.1: - dependencies: - string-width: 7.2.0 - strip-ansi: 7.1.2 - wrap-ansi: 9.0.2 - color-convert@2.0.1: dependencies: color-name: 1.1.4 @@ -5164,8 +5128,6 @@ snapshots: yargs-parser@20.2.9: {} - yargs-parser@22.0.0: {} - yargs@16.2.0: dependencies: cliui: 7.0.4 @@ -5176,15 +5138,6 @@ snapshots: y18n: 5.0.8 yargs-parser: 20.2.9 - yargs@18.0.0: - dependencies: - cliui: 9.0.1 - escalade: 3.2.0 - get-caller-file: 2.0.5 - string-width: 7.2.0 - y18n: 5.0.8 - yargs-parser: 22.0.0 - yn@3.1.1: {} yocto-queue@0.1.0: {} diff --git a/src/depbadgerc/compute-state-integrity.spec.ts b/src/depbadgerc/compute-state-integrity.spec.ts index 3dbd595..d693ff5 100644 --- a/src/depbadgerc/compute-state-integrity.spec.ts +++ b/src/depbadgerc/compute-state-integrity.spec.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ import crypto from "crypto"; -import yaml from "js-yaml"; +import yaml from "yaml"; import { computeStateIntegrity } from "./compute-state-integrity.ts"; import { Methods } from "./depbadgerc.store.ts"; @@ -68,7 +68,7 @@ describe("computeStateIntegrity", () => { const result = computeStateIntegrity(store)(...payload); const hash = crypto.createHash("sha256"); - const yml = yaml.dump({ ...pickState(store), integrity: null }); + const yml = yaml.stringify({ ...pickState(store), integrity: null }); const payloadStringified = JSON.stringify(payload); hash.update(`${yml} --- ${payloadStringified}`, "utf8"); const expectedHash = hash.digest("hex"); diff --git a/src/depbadgerc/compute-state-integrity.ts b/src/depbadgerc/compute-state-integrity.ts index 6eb0516..ecc4444 100644 --- a/src/depbadgerc/compute-state-integrity.ts +++ b/src/depbadgerc/compute-state-integrity.ts @@ -1,5 +1,5 @@ import crypto from "crypto"; -import yaml from "js-yaml"; +import yaml from "yaml"; import { CtxStore, useCtxCallback } from "../store/ctx-store.ts"; @@ -9,7 +9,7 @@ import { DepbadgeRC } from "./depbadgerc.type.ts"; export const computeStateIntegrity = useCtxCallback>((store, ...rest: unknown[]) => { const payloadStringified = JSON.stringify(rest); const hash = crypto.createHash("sha256"); - const yml = yaml.dump({ + const yml = yaml.stringify({ ...JSON.parse(JSON.stringify(store)), integrity: null, }); diff --git a/src/depbadgerc/read-depbadgerc-with-defaults.spec.ts b/src/depbadgerc/read-depbadgerc-with-defaults.spec.ts index 02374b6..7df28ef 100644 --- a/src/depbadgerc/read-depbadgerc-with-defaults.spec.ts +++ b/src/depbadgerc/read-depbadgerc-with-defaults.spec.ts @@ -9,7 +9,7 @@ import { mergeLayout, mergeStyle, readDepbadgeRC, - withYargs, + withArgs, } from "./read-depbadgerc-with-defaults.ts"; vi.mock("../shared/find-file", () => ({ findFile: vi.fn() })); @@ -65,7 +65,7 @@ describe("read-depbadgerc-with-defaults", () => { const rc = { manifest: "package.json", dependencies: { items: [] } } as any; const originalArgv = process.argv; process.argv = ["node", "test", "--g", "json", "--generate", "markdown"]; - const result = withYargs(rc); + const result = withArgs(rc); expect(result.output).toEqual(["json", "markdown"]); process.argv = originalArgv; }); diff --git a/src/depbadgerc/read-depbadgerc-with-defaults.ts b/src/depbadgerc/read-depbadgerc-with-defaults.ts index dc66b7e..3ba5ad8 100644 --- a/src/depbadgerc/read-depbadgerc-with-defaults.ts +++ b/src/depbadgerc/read-depbadgerc-with-defaults.ts @@ -1,12 +1,13 @@ -import fs from "fs"; -import yaml from "js-yaml"; -import yargs from "yargs"; -import { hideBin } from "yargs/helpers"; +import fs from "node:fs"; +import { parseArgs } from "node:util"; + +import yaml from "yaml"; import { findFile } from "../shared/find-file.ts"; import { hashStringToHex } from "../shared/hash-string-to-hex.ts"; +import { resolveYamlMergeKey } from "../shared/resolve-yaml-merge-key.ts"; -import { BadgeStyle, DepbadgeRC, DependencyItem, Layout, OutputFormat } from "./depbadgerc.type.ts"; +import type { BadgeStyle, DepbadgeRC, DependencyItem, Layout, OutputFormat } from "./depbadgerc.type.ts"; type Section = { layout?: Layout; @@ -71,22 +72,28 @@ export function withDefaults(rc: DepbadgeRC): DepbadgeRC { export function readDepbadgeRC(path = "depbadgerc.yml"): DepbadgeRC { const filePath = findFile(path); if (!filePath) throw new Error(`${path} not found`); - const rc = yaml.load(fs.readFileSync(filePath, "utf8")) as DepbadgeRC; + const rc = resolveYamlMergeKey(yaml.parse(fs.readFileSync(filePath, "utf8"))) as DepbadgeRC; return rc; } -type ARGV = { - g?: string[]; - generate?: string[]; -}; - -export function withYargs(rc: DepbadgeRC): DepbadgeRC { +export function withArgs(rc: DepbadgeRC): DepbadgeRC { rc.output ??= []; - const argv = yargs(hideBin(process.argv)).parse() as ARGV; + const { values } = parseArgs({ + options: { + g: { + type: "string", + multiple: true, + }, + generate: { + type: "string", + multiple: true, + }, + }, + }); const arrayfy = (v?: string | string[]) => (v ? (Array.isArray(v) ? v : [v]) : []); - const gSet = new Set([...arrayfy(argv.g), ...arrayfy(argv.generate)]); + const gSet = new Set([...arrayfy(values.g), ...arrayfy(values.generate)]); (["json", "markdown"] as OutputFormat[]).forEach((t) => gSet.has(t) && !rc.output!.includes(t) && rc.output!.push(t)); return rc; } -export const getDepbadgeRC = () => withYargs(withDefaults(readDepbadgeRC())); +export const getDepbadgeRC = () => withArgs(withDefaults(readDepbadgeRC())); diff --git a/src/shared/hash-string-to-hex.ts b/src/shared/hash-string-to-hex.ts index 6180fae..9ca04e5 100644 --- a/src/shared/hash-string-to-hex.ts +++ b/src/shared/hash-string-to-hex.ts @@ -1,6 +1,7 @@ import { colord } from "colord"; -export function hashStringToHex(str: string) { +export function hashStringToHex(str: string): string { + if (!str?.length) str = "default"; let h = 0; for (let i = 0; i < str.length; i++) { h = str.charCodeAt(i) + ((h << 5) - h); diff --git a/src/shared/resolve-yaml-merge-key.spec.ts b/src/shared/resolve-yaml-merge-key.spec.ts new file mode 100644 index 0000000..29dce53 --- /dev/null +++ b/src/shared/resolve-yaml-merge-key.spec.ts @@ -0,0 +1,79 @@ +import { resolveYamlMergeKey } from "./resolve-yaml-merge-key.ts"; + +describe("resolveYamlMergeKey", () => { + test("should handle empty object", () => { + expect(resolveYamlMergeKey({})).toEqual({}); + }); + + test("should handle null", () => { + expect(resolveYamlMergeKey(null)).toBeNull(); + }); + + test("should pass through primitives", () => { + expect(resolveYamlMergeKey("test")).toBe("test"); + expect(resolveYamlMergeKey(42)).toBe(42); + expect(resolveYamlMergeKey(true)).toBe(true); + }); + + test("should merge single anchor reference", () => { + const input = { + defaults: { a: 1, b: 2 }, + merged: { "<<": { a: 1, b: 2 }, c: 3 }, + }; + const result = resolveYamlMergeKey(input); + expect(result.merged).toEqual({ a: 1, b: 2, c: 3 }); + }); + + test("should merge multiple anchor references in array", () => { + const input = { + defaults: { a: 1 }, + extra: { b: 2 }, + merged: { "<<": [{ a: 1 }, { b: 2 }], c: 3 }, + }; + const result = resolveYamlMergeKey(input); + expect(result.merged).toEqual({ a: 1, b: 2, c: 3 }); + }); + + test("should override merged values with explicit ones", () => { + const input = { + defaults: { a: 1, b: 2, c: 3 }, + merged: { "<<": { a: 1, b: 2 }, b: 99, c: 3 }, + }; + const result = resolveYamlMergeKey(input); + expect(result.merged).toEqual({ a: 1, b: 99, c: 3 }); + }); + + test("should handle nested objects with merge keys", () => { + const input = { + outer: { + defaults: { x: 1 }, + inner: { "<<": { x: 1 }, y: 2 }, + }, + }; + const result = resolveYamlMergeKey(input); + expect(result.outer.inner).toEqual({ x: 1, y: 2 }); + }); + + test("should handle arrays with merge keys", () => { + const input = [{ a: 1 }, { "<<": { b: 2 }, c: 3 }]; + const result = resolveYamlMergeKey(input); + expect(result).toEqual([{ a: 1 }, { b: 2, c: 3 }]); + }); + + test("should handle real-world depbadgerc style config", () => { + const input = { + dependenciesStyle: { labelColor: "333", style: "for-the-badge" }, + dependencies: { + badgeStyle: { labelColor: "333", style: "for-the-badge" }, + }, + devDependencies: { + badgeStyle: { "<<": { labelColor: "333", style: "for-the-badge" }, style: "flat-square" }, + }, + }; + const result = resolveYamlMergeKey(input); + expect(result.devDependencies.badgeStyle).toEqual({ + labelColor: "333", + style: "flat-square", + }); + }); +}); diff --git a/src/shared/resolve-yaml-merge-key.ts b/src/shared/resolve-yaml-merge-key.ts new file mode 100644 index 0000000..af2244c --- /dev/null +++ b/src/shared/resolve-yaml-merge-key.ts @@ -0,0 +1,26 @@ +/** + * Resolves YAML merge key (<<: *anchor) that is not handled by the YAML 1.2 spec.\ + * YAML 1.1 supported <<: to merge one mapping into another, but this was removed in YAML 1.2.\ + * This function post-processes the parsed YAML to restore that functionality. + */ +export function resolveYamlMergeKey(obj: T): T { + if (Array.isArray(obj)) return obj.map(resolveYamlMergeKey) as T; + if (obj && typeof obj === "object") { + const result: Record = {}; + + for (const [key, value] of Object.entries(obj)) { + if (key === "<<") { + const merged = resolveYamlMergeKey(value); + if (Array.isArray(merged)) { + merged.forEach((m) => { + if (m && typeof m === "object") Object.assign(result, resolveYamlMergeKey(m)); + }); + } else if (merged && typeof merged === "object") Object.assign(result, resolveYamlMergeKey(merged)); + } else result[key] = resolveYamlMergeKey(value); + } + + return result as T; + } + + return obj; +}